* [PATCH 12/13] sequencer: add "--cherry-pick" option to "git sequencer--helper"
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
From: Stephan Beyer <s-beyer@gmx.net>
This patch adds some code that comes from the sequencer GSoC project:
git://repo.or.cz/git/sbeyer.git
(commit e7b8dab0c2a73ade92017a52bb1405ea1534ef20)
Most of the code is taken from the insn_pick_act() function.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-sequencer--helper.c | 52 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 51 insertions(+), 1 deletions(-)
diff --git a/builtin-sequencer--helper.c b/builtin-sequencer--helper.c
index 61a8f2e..0f2255a 100644
--- a/builtin-sequencer--helper.c
+++ b/builtin-sequencer--helper.c
@@ -288,7 +288,7 @@ static int do_commit(unsigned char *parent_sha1)
if (update_ref(reflog, "HEAD", commit_sha1, NULL, 0, 0))
return error("Could not update HEAD to %s.",
- sha1_to_hex(commit_sha1));
+ sha1_to_hex(commit_sha1));
return 0;
}
@@ -436,6 +436,7 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
char *patch_commit = NULL;
char *reset_commit = NULL;
char *ff_commit = NULL;
+ char *cp_commit = NULL;
struct option options[] = {
OPT_STRING(0, "make-patch", &patch_commit, "commit",
"create a patch from commit"),
@@ -443,6 +444,8 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
"reset to commit"),
OPT_STRING(0, "fast-forward", &ff_commit, "commit",
"fast forward to commit"),
+ OPT_STRING(0, "cherry-pick", &cp_commit, "commit",
+ "cherry pick commit"),
OPT_END()
};
@@ -488,5 +491,52 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
return reset_almost_hard(sha1);
}
+ if (cp_commit) {
+ struct commit *commit;
+ int failed;
+ const char *author;
+ int no_commit = 0;
+
+ if (argc != 0 && argc != 1)
+ usage_with_options(git_sequencer_helper_usage,
+ options);
+
+ if (argc == 1 && *argv[0] && strcmp(argv[0], "0"))
+ no_commit = 1;
+
+ if (get_sha1("HEAD", head_sha1))
+ return error("You do not have a valid HEAD.");
+
+ commit = get_commit(cp_commit);
+ if (!commit)
+ return 1;
+
+ set_pick_subject(cp_commit, commit);
+
+ failed = pick_commit(commit, 0, 0, &next_commit.summary);
+
+ set_message_source(sha1_to_hex(commit->object.sha1));
+ author = strstr(commit->buffer, "\nauthor ");
+ if (author)
+ set_author_info(author + 8);
+
+ /* We do not want extra Conflicts: lines on cherry-pick,
+ so just take the old commit message. */
+ if (failed) {
+ strbuf_setlen(&next_commit.summary, 0);
+ strbuf_addstr(&next_commit.summary,
+ strstr(commit->buffer, "\n\n") + 2);
+ rerere();
+ make_patch(commit);
+ write_commit_summary_into(MERGE_MSG);
+ return error(pick_help_msg(commit->object.sha1, 0));
+ }
+
+ if (!no_commit && do_commit(head_sha1))
+ return error("Could not commit.");
+
+ return 0;
+ }
+
usage_with_options(git_sequencer_helper_usage, options);
}
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 10/13] pick: libify "pick_help_msg()"
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
This function gives an help message when pick or revert failed.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-revert.c | 23 +----------------------
pick.c | 22 ++++++++++++++++++++++
pick.h | 1 +
3 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/builtin-revert.c b/builtin-revert.c
index 4797ac5..e5250bd 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -142,27 +142,6 @@ static void set_author_ident_env(const char *message)
sha1_to_hex(commit->object.sha1));
}
-static char *help_msg(const unsigned char *sha1)
-{
- static char helpbuf[1024];
- char *msg = getenv("GIT_CHERRY_PICK_HELP");
-
- if (msg)
- return msg;
-
- strcpy(helpbuf, " After resolving the conflicts,\n"
- "mark the corrected paths with 'git add <paths>' "
- "or 'git rm <paths>' and commit the result.");
-
- if (!(flags & PICK_REVERSE)) {
- sprintf(helpbuf + strlen(helpbuf),
- "\nWhen commiting, use the option "
- "'-c %s' to retain authorship and message.",
- find_unique_abbrev(sha1, DEFAULT_ABBREV));
- }
- return helpbuf;
-}
-
static void write_message(struct strbuf *msgbuf, const char *filename)
{
struct lock_file msg_file;
@@ -211,7 +190,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
exit(1);
} else if (failed > 0) {
fprintf(stderr, "Automatic %s failed.%s\n",
- me, help_msg(commit->object.sha1));
+ me, pick_help_msg(commit->object.sha1, flags));
write_message(&msgbuf, git_path("MERGE_MSG"));
rerere();
exit(1);
diff --git a/pick.c b/pick.c
index 058b877..4f882bb 100644
--- a/pick.c
+++ b/pick.c
@@ -208,3 +208,25 @@ int pick_commit(struct commit *pick_commit, int mainline, int flags,
return ret;
}
+
+char *pick_help_msg(const unsigned char *sha1, int flags)
+{
+ static char helpbuf[1024];
+ char *msg = getenv("GIT_CHERRY_PICK_HELP");
+
+ if (msg)
+ return msg;
+
+ strcpy(helpbuf, " After resolving the conflicts,\n"
+ "mark the corrected paths with 'git add <paths>' "
+ "or 'git rm <paths>' and commit the result.");
+
+ if (!(flags & PICK_REVERSE)) {
+ sprintf(helpbuf + strlen(helpbuf),
+ "\nWhen commiting, use the option "
+ "'-c %s' to retain authorship and message.",
+ find_unique_abbrev(sha1, DEFAULT_ABBREV));
+ }
+ return helpbuf;
+}
+
diff --git a/pick.h b/pick.h
index 7a74ad8..115541a 100644
--- a/pick.h
+++ b/pick.h
@@ -9,5 +9,6 @@
/* We don't need a PICK_QUIET. This is done by
* setenv("GIT_MERGE_VERBOSITY", "0", 1); */
extern int pick_commit(struct commit *commit, int mainline, int flags, struct strbuf *msg);
+extern char *pick_help_msg(const unsigned char *sha1, int flags);
#endif
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 13/13] rebase -i: use "git sequencer--helper --cherry-pick"
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
instead of "git cherry-pick", as this will make it easier to
port "git-rebase--interactive.sh" to C.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
git-rebase--interactive.sh | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 7651fd6..30af512 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -147,7 +147,7 @@ pick_one () {
pick_one_preserving_merges "$@" && return
if test ! -z "$REBASE_ROOT"
then
- output git cherry-pick "$@"
+ git sequencer--helper --cherry-pick $sha1 $no_ff
return
fi
parent_sha1=$(git rev-parse --verify $sha1^) ||
@@ -157,7 +157,7 @@ pick_one () {
git sequencer--helper --fast-forward $sha1 \
"$GIT_REFLOG_ACTION" "$VERBOSE"
else
- output git cherry-pick "$@"
+ git sequencer--helper --cherry-pick $sha1 $no_ff
fi
}
@@ -269,7 +269,9 @@ pick_one_preserving_merges () {
fi
;;
*)
- output git cherry-pick "$@" ||
+ no_commit=
+ test "a$1" = "a-n" && no_commit=t
+ git sequencer--helper --cherry-pick $sha1 $no_commit ||
die_with_patch $sha1 "Could not pick $sha1"
;;
esac
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 08/13] pick: remove useless PICK_REVERSE => PICK_ADD_NOTE code
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
Useless of the removed code was found by Junio.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
pick.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/pick.c b/pick.c
index 13bf793..a6b1d6f 100644
--- a/pick.c
+++ b/pick.c
@@ -84,9 +84,6 @@ int pick_commit(struct commit *pick_commit, int mainline, int flags,
strbuf_init(msg, 0);
commit = pick_commit;
- if (flags & PICK_REVERSE) /* REVERSE implies ADD_NOTE */
- flags |= PICK_ADD_NOTE;
-
/*
* We do not intend to commit immediately. We just want to
* merge the differences in, so let's compute the tree
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 07/13] pick: rename "pick()" to "pick_commit()"
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-revert.c | 2 +-
pick.c | 8 ++++----
pick.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin-revert.c b/builtin-revert.c
index 6dd29a3..4797ac5 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -206,7 +206,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
git_commit_encoding, encoding)))
commit->buffer = reencoded_message;
- failed = pick(commit, mainline, flags, &msgbuf);
+ failed = pick_commit(commit, mainline, flags, &msgbuf);
if (failed < 0) {
exit(1);
} else if (failed > 0) {
diff --git a/pick.c b/pick.c
index 6fea39c..13bf793 100644
--- a/pick.c
+++ b/pick.c
@@ -60,16 +60,16 @@ static struct tree *empty_tree(void)
}
/*
- * Pick changes introduced by pick_commit into current working tree
- * and index.
+ * Pick changes introduced by "commit" argument into current working
+ * tree and index.
*
* Return 0 on success.
* Return negative value on error before picking,
* and a positive value after picking,
* and return 1 if and only if a conflict occurs but no other error.
*/
-int pick(struct commit *pick_commit, int mainline, int flags,
- struct strbuf *msg)
+int pick_commit(struct commit *pick_commit, int mainline, int flags,
+ struct strbuf *msg)
{
unsigned char head[20];
struct commit *base, *next, *parent;
diff --git a/pick.h b/pick.h
index 7eb0d3a..7a74ad8 100644
--- a/pick.h
+++ b/pick.h
@@ -8,6 +8,6 @@
#define PICK_ADD_NOTE 2 /* add note about original commit (unless conflict) */
/* We don't need a PICK_QUIET. This is done by
* setenv("GIT_MERGE_VERBOSITY", "0", 1); */
-extern int pick(struct commit *pick_commit, int mainline, int flags, struct strbuf *msg);
+extern int pick_commit(struct commit *commit, int mainline, int flags, struct strbuf *msg);
#endif
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 01/13] sequencer: add "do_fast_forward()" to perform a fast forward
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
From: Stephan Beyer <s-beyer@gmx.net>
This code is taken from the sequencer GSoC project:
git://repo.or.cz/git/sbeyer.git
(commit e7b8dab0c2a73ade92017a52bb1405ea1534ef20)
but the messages have been changed to be the same as those
displayed by git-rebase--interactive.sh.
Mentored-by: Daniel Barkalow <barkalow@iabervon.org>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-sequencer--helper.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/builtin-sequencer--helper.c b/builtin-sequencer--helper.c
index be030bc..0cd7e98 100644
--- a/builtin-sequencer--helper.c
+++ b/builtin-sequencer--helper.c
@@ -171,6 +171,15 @@ static struct commit *get_commit(const char *arg)
return lookup_commit_reference(sha1);
}
+static int do_fast_forward(const unsigned char *sha)
+{
+ if (reset_almost_hard(sha))
+ return error("Cannot fast forward to %s", sha1_to_hex(sha));
+ if (verbosity > 1)
+ printf("Fast forward to %s\n", sha1_to_hex(sha));
+ return 0;
+}
+
static int set_verbosity(int verbose)
{
char tmp[] = "0";
--
1.6.4.271.ge010d
^ permalink raw reply related
* [PATCH 00/13] more changes to port rebase -i to C using sequencer code
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
These is just the current state of my work.
Some patches have already been sent but are not yet in pu.
Christian Couder (9):
sequencer: add "--fast-forward" option to "git sequencer--helper"
sequencer: let "git sequencer--helper" callers set "allow_dirty"
rebase -i: use "git sequencer--helper --fast-forward"
pick: simplify "error(...)" followed by "return -1"
pick: rename "pick()" to "pick_commit()"
pick: remove useless PICK_REVERSE => PICK_ADD_NOTE code
pick: simplify bogus comment about commiting immediately
pick: libify "pick_help_msg()"
rebase -i: use "git sequencer--helper --cherry-pick"
Stephan Beyer (4):
sequencer: add "do_fast_forward()" to perform a fast forward
revert: libify pick
sequencer: add "do_commit()" and related functions
sequencer: add "--cherry-pick" option to "git sequencer--helper"
Makefile | 2 +
builtin-revert.c | 293 +++++++------------------------------------
builtin-sequencer--helper.c | 298 ++++++++++++++++++++++++++++++++++++++++++-
git-rebase--interactive.sh | 19 +--
pick.c | 232 +++++++++++++++++++++++++++++++++
pick.h | 14 ++
6 files changed, 592 insertions(+), 266 deletions(-)
create mode 100644 pick.c
create mode 100644 pick.h
^ permalink raw reply
* [PATCH 02/13] sequencer: add "--fast-forward" option to "git sequencer--helper"
From: Christian Couder @ 2009-08-12 5:15 UTC (permalink / raw)
To: Junio C Hamano
Cc: git, Johannes Schindelin, Stephan Beyer, Daniel Barkalow,
Jakub Narebski
In-Reply-To: <20090812051116.18155.70541.chriscool@tuxfamily.org>
This new option uses the "do_fast_forward()" function to perform
a fast forward.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-sequencer--helper.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/builtin-sequencer--helper.c b/builtin-sequencer--helper.c
index 0cd7e98..bd72f65 100644
--- a/builtin-sequencer--helper.c
+++ b/builtin-sequencer--helper.c
@@ -19,6 +19,7 @@ static unsigned char head_sha1[20];
static const char * const git_sequencer_helper_usage[] = {
"git sequencer--helper --make-patch <commit>",
"git sequencer--helper --reset-hard <commit> <reflog-msg> <verbosity>",
+ "git sequencer--helper --fast-forward <commit> <reflog-msg> <verbosity>",
NULL
};
@@ -218,11 +219,14 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
{
char *patch_commit = NULL;
char *reset_commit = NULL;
+ char *ff_commit = NULL;
struct option options[] = {
OPT_STRING(0, "make-patch", &patch_commit, "commit",
"create a patch from commit"),
OPT_STRING(0, "reset-hard", &reset_commit, "commit",
"reset to commit"),
+ OPT_STRING(0, "fast-forward", &ff_commit, "commit",
+ "fast forward to commit"),
OPT_END()
};
@@ -239,15 +243,16 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
return 0;
}
- if (reset_commit) {
+ if (ff_commit || reset_commit) {
unsigned char sha1[20];
+ char *commit = ff_commit ? ff_commit : reset_commit;
if (argc != 2)
usage_with_options(git_sequencer_helper_usage,
options);
- if (get_sha1(reset_commit, sha1)) {
- error("Could not find '%s'", reset_commit);
+ if (get_sha1(commit, sha1)) {
+ error("Could not find '%s'", commit);
return 1;
}
@@ -258,7 +263,10 @@ int cmd_sequencer__helper(int argc, const char **argv, const char *prefix)
return 1;
}
- return reset_almost_hard(sha1);
+ if (ff_commit)
+ return do_fast_forward(sha1);
+ else
+ return reset_almost_hard(sha1);
}
usage_with_options(git_sequencer_helper_usage, options);
--
1.6.4.271.ge010d
^ permalink raw reply related
* Re: [RFC PATCH v3 7/8] Support sparse checkout in unpack_trees() and read-tree
From: skillzero @ 2009-08-12 4:59 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy
Cc: Jakub Narebski, git, Johannes Schindelin, Junio C Hamano
In-Reply-To: <fcaeb9bf0908111830n50bd4733h5033c6f13a45999@mail.gmail.com>
On Tue, Aug 11, 2009 at 6:30 PM, Nguyen Thai Ngoc Duy<pclouds@gmail.com> wrote:
> I think it's as easy as writing exclude patterns once you figure out '*'.
That solves it for me. Thanks.
^ permalink raw reply
* Git<->Accurev Bridge
From: Joshua Jensen @ 2009-08-12 4:02 UTC (permalink / raw)
To: git
Early last year, there was mention of a bridge between Git and Accurev.
Does anyone know what became of this project?
Thanks.
Josh
^ permalink raw reply
* Re: fatal: bad revision 'HEAD'
From: Jeff King @ 2009-08-12 3:27 UTC (permalink / raw)
To: Joel Mahoney; +Cc: Junio C Hamano, Johannes Schindelin, git
In-Reply-To: <C44788EB-02BA-4D69-8091-9E97827223A0@gmail.com>
[re-adding git@vger, since this discussion really belongs on the list]
On Tue, Aug 11, 2009 at 10:30:49AM -0600, Joel Mahoney wrote:
> here's what I get now:
>
> trace: built-in: git 'init'
> Initialized empty Git repository in /path/to/project/vendor/plugins/
> paperclip/.git/
> trace: exec: 'git-pull' '--depth' '1' 'git://github.com/thoughtbot/
> paperclip.git'
> trace: built-in: git 'rev-parse' '--git-dir'
> trace: built-in: git 'rev-parse' '--is-inside-work-tree'
> trace: built-in: git 'rev-parse' '--show-cdup'
> trace: built-in: git 'ls-files' '-u'
> trace: built-in: git 'symbolic-ref' '-q' 'HEAD'
> trace: built-in: git 'config' '--bool' 'branch.master.rebase'
> trace: built-in: git 'update-index' '--ignore-submodules' '--refresh'
> trace: built-in: git 'diff-files' '--ignore-submodules' '--quiet'
> trace: built-in: git 'diff-index' '--ignore-submodules' '--cached'
> '--quiet' 'HEAD' '--'
> fatal: bad revision 'HEAD'
> refusing to pull with rebase: your working tree is not up-to-date
I was able to replicate your problem, but only if I set
branch.master.rebase to "true" in my user-wide git config (i.e.,
~/.gitconfig). It looks like "git pull" is not capable of handling a
rebase when you have no commits yet.
I'm slightly dubious that such a configuration is sane, but probably
"git pull" should handle this case anyway, as you can easily replicate
it without config by doing:
git init && git pull --rebase /any/git/repo
Patch is below.
-- >8 --
Subject: [PATCH] allow pull --rebase on branch yet to be born
When doing a "pull --rebase", we check to make sure that the
index and working tree are clean. The index-clean check
compares the index against HEAD. The test erroneously
reports dirtiness if we don't have a HEAD yet.
In the case that we don't have a HEAD, we should just check
if the index has anything in it, which we can do by
comparing to the empty tree.
Signed-off-by: Jeff King <peff@peff.net>
---
Actually, this test is slightly more strict than the "index dirty" check
in git-rebase.sh itself. That test does "git diff-index HEAD", but
doesn't check the return code. It actually looks at whether it generates
output. So it would consider an index with something in it on a branch
yet-to-be-born to be clean, which is perhaps wrong.
Such a thing seems pretty unlikely in practice, though. I don't know if
it is worth making the two tests the same (maybe it is worth refactoring
into an index_is_clean function in git-sh-setup).
git-pull.sh | 8 +++++++-
t/t5520-pull.sh | 11 +++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 0f24182..427b5c6 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -119,9 +119,15 @@ error_on_no_merge_candidates () {
}
test true = "$rebase" && {
+ if git rev-parse -q --verify HEAD >/dev/null; then
+ parent_tree=HEAD
+ else # empty tree
+ parent_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+ fi
+
git update-index --ignore-submodules --refresh &&
git diff-files --ignore-submodules --quiet &&
- git diff-index --ignore-submodules --cached --quiet HEAD -- ||
+ git diff-index --ignore-submodules --cached --quiet $parent_tree -- ||
die "refusing to pull with rebase: your working tree is not up-to-date"
oldremoteref= &&
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index e78d402..dd2ee84 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -149,4 +149,15 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
'
+test_expect_success 'pull --rebase works on branch yet to be born' '
+ git rev-parse master >expect &&
+ mkdir empty_repo &&
+ (cd empty_repo &&
+ git init &&
+ git pull --rebase .. master &&
+ git rev-parse HEAD >../actual
+ ) &&
+ test_cmp expect actual
+'
+
test_done
--
1.6.4.228.g9ab2.dirty
^ permalink raw reply related
* Re: [PATCH 5/8] Add a config option for remotes to specify a foreign vcs
From: Junio C Hamano @ 2009-08-12 3:26 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Jeff King, Nanako Shiraishi, Bert Wesarg, Junio C Hamano,
Daniel Barkalow, git, Brian Gernhardt
In-Reply-To: <alpine.DEB.1.00.0908120212500.8306@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> I have no problem with that, and I think it makes it even more visually
>> obvious what is going. For example:
>>
>> svn::http://server/path/to/repo
>>
>> makes the "svn" prefix jump out a bit more.
>
> ... and http:://repo.or.cz/r/git.git ? Thanks. But no, thanks.
Huh?
If you meant a "canonical format that always spells out the name of the
helper, and then whatever string the chosen helper uses to identify the
repository", that would be spelled as:
libcurl::http://repo.or.cz/r/git.git/
and will be handled by a single helper, git-remote-libcurl, that is
essentially what Linus and Daniel ejected from the builtin.
And in fact, that would be vastly more sensible than "we have one helper
that uses libcurl, but we hide the implementation detail and call the
helper with three names git-remote-{http,https,ftp}, so you would spell
the repository http://repo.or.cz/r/git.git/", which is what we have queued
in 'next/pu'.
And of course the use of "canonical format" for transports that git
traditionally has known about is only for consistency; we would want to
give shortcut for them. Obviously we would want "http://<anything>" to be
a short-hand for "curl::http://<anything>".
^ permalink raw reply
* [PATCH] svn: allow branches outside of refs/remotes
From: Adam Brewster @ 2009-08-12 3:14 UTC (permalink / raw)
To: git; +Cc: Eric Wong, Adam Brewster
In-Reply-To: <1250046867-13655-1-git-send-email-adambrewster@gmail.com>
It may be convenient for some users to store svn remote tracking
branches outside of the refs/remotes/ heirarchy.
To accomplish this feat, this patch includes the entire path to
the ref in $r->{'refname'} in &read_all_remotes and tries to change
references to this entry so the new value makes sense.
Signed-off-by: Adam Brewster <adambrewster@gmail.com>
---
git-svn.perl | 82 +++++++++++++++++++++----------------
t/lib-git-svn.sh | 2 +-
t/t9104-git-svn-follow-parent.sh | 10 ++--
t/t9107-git-svn-migrate.sh | 14 +++----
t/t9143-git-svn-gc.sh | 10 ++--
5 files changed, 63 insertions(+), 55 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index b0bfb74..cafd7fe 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -909,7 +909,7 @@ sub cmd_multi_init {
}
do_git_init_db();
if (defined $_trunk) {
- my $trunk_ref = $_prefix . 'trunk';
+ my $trunk_ref = 'refs/remotes/' . $_prefix . 'trunk';
# try both old-style and new-style lookups:
my $gs_trunk = eval { Git::SVN->new($trunk_ref) };
unless ($gs_trunk) {
@@ -1643,23 +1643,23 @@ sub resolve_local_globs {
return unless defined $glob_spec;
my $ref = $glob_spec->{ref};
my $path = $glob_spec->{path};
- foreach (command(qw#for-each-ref --format=%(refname) refs/remotes#)) {
- next unless m#^refs/remotes/$ref->{regex}$#;
+ foreach (command(qw#for-each-ref --format=%(refname) refs/#)) {
+ next unless m#^$ref->{regex}$#;
my $p = $1;
my $pathname = desanitize_refname($path->full_path($p));
my $refname = desanitize_refname($ref->full_path($p));
if (my $existing = $fetch->{$pathname}) {
if ($existing ne $refname) {
die "Refspec conflict:\n",
- "existing: refs/remotes/$existing\n",
- " globbed: refs/remotes/$refname\n";
+ "existing: $existing\n",
+ " globbed: $refname\n";
}
- my $u = (::cmt_metadata("refs/remotes/$refname"))[0];
+ my $u = (::cmt_metadata("$refname"))[0];
$u =~ s!^\Q$url\E(/|$)!! or die
- "refs/remotes/$refname: '$url' not found in '$u'\n";
+ "$refname: '$url' not found in '$u'\n";
if ($pathname ne $u) {
warn "W: Refspec glob conflict ",
- "(ref: refs/remotes/$refname):\n",
+ "(ref: $refname):\n",
"expected path: $pathname\n",
" real path: $u\n",
"Continuing ahead with $u\n";
@@ -1737,33 +1737,34 @@ sub read_all_remotes {
my $use_svm_props = eval { command_oneline(qw/config --bool
svn.useSvmProps/) };
$use_svm_props = $use_svm_props eq 'true' if $use_svm_props;
+ my $svn_refspec = qr{\s*/?(.*?)\s*:\s*(.+?)\s*};
foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
- if (m!^(.+)\.fetch=\s*(.*)\s*:\s*(.+)\s*$!) {
- my ($remote, $local_ref, $_remote_ref) = ($1, $2, $3);
- die("svn-remote.$remote: remote ref '$_remote_ref' "
- . "must start with 'refs/remotes/'\n")
- unless $_remote_ref =~ m{^refs/remotes/(.+)};
- my $remote_ref = $1;
- $local_ref =~ s{^/}{};
+ if (m!^(.+)\.fetch=$svn_refspec$!) {
+ my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
+ die("svn-remote.$remote: remote ref '$remote_ref' "
+ . "must start with 'refs/'\n")
+ unless $remote_ref =~ m{^refs/};
$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
$r->{$remote}->{svm} = {} if $use_svm_props;
} elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
$r->{$1}->{svm} = {};
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
$r->{$1}->{url} = $2;
- } elsif (m!^(.+)\.(branches|tags)=
- (.*):refs/remotes/(.+)\s*$/!x) {
- my ($p, $g) = ($3, $4);
+ } elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) {
+ my ($remote, $t, $local_ref, $remote_ref) = ($1, $2, $3, $4);
+ die("svn-remote.$remote: remote ref '$remote_ref' ($t) "
+ . "must start with 'refs/'\n")
+ unless $remote_ref =~ m{^refs/};
my $rs = {
- t => $2,
- remote => $1,
- path => Git::SVN::GlobSpec->new($p),
- ref => Git::SVN::GlobSpec->new($g) };
+ t => $t,
+ remote => $remote,
+ path => Git::SVN::GlobSpec->new($local_ref),
+ ref => Git::SVN::GlobSpec->new($remote_ref) };
if (length($rs->{ref}->{right}) != 0) {
die "The '*' glob character must be the last ",
- "character of '$g'\n";
+ "character of '$remote_ref'\n";
}
- push @{ $r->{$1}->{$2} }, $rs;
+ push @{ $r->{$remote}->{$t} }, $rs;
}
}
@@ -1871,9 +1872,9 @@ sub init_remote_config {
}
}
my ($xrepo_id, $xpath) = find_ref($self->refname);
- if (defined $xpath) {
+ if (!$no_write && defined $xpath) {
die "svn-remote.$xrepo_id.fetch already set to track ",
- "$xpath:refs/remotes/", $self->refname, "\n";
+ "$xpath:", $self->refname, "\n";
}
unless ($no_write) {
command_noisy('config',
@@ -1948,7 +1949,7 @@ sub find_ref {
my ($ref_id) = @_;
foreach (command(qw/config -l/)) {
next unless m!^svn-remote\.(.+)\.fetch=
- \s*(.*)\s*:\s*refs/remotes/(.+)\s*$!x;
+ \s*/?(.*?)\s*:\s*(.+?)\s*$!x;
my ($repo_id, $path, $ref) = ($1, $2, $3);
if ($ref eq $ref_id) {
$path = '' if ($path =~ m#^\./?#);
@@ -1965,16 +1966,16 @@ sub new {
if (!defined $repo_id) {
die "Could not find a \"svn-remote.*.fetch\" key ",
"in the repository configuration matching: ",
- "refs/remotes/$ref_id\n";
+ "$ref_id\n";
}
}
my $self = _new($class, $repo_id, $ref_id, $path);
if (!defined $self->{path} || !length $self->{path}) {
my $fetch = command_oneline('config', '--get',
"svn-remote.$repo_id.fetch",
- ":refs/remotes/$ref_id\$") or
+ ":$ref_id\$") or
die "Failed to read \"svn-remote.$repo_id.fetch\" ",
- "\":refs/remotes/$ref_id\$\" in config\n";
+ "\":$ref_id\$\" in config\n";
($self->{path}, undef) = split(/\s*:\s*/, $fetch);
}
$self->{url} = command_oneline('config', '--get',
@@ -1985,7 +1986,7 @@ sub new {
}
sub refname {
- my ($refname) = "refs/remotes/$_[0]->{ref_id}" ;
+ my ($refname) = $_[0]->{ref_id} ;
# It cannot end with a slash /, we'll throw up on this because
# SVN can't have directories with a slash in their name, either:
@@ -3320,12 +3321,12 @@ sub _new {
}
unless (defined $ref_id && length $ref_id) {
$_prefix = '' unless defined($_prefix);
- $_[2] = $ref_id = $_prefix . $Git::SVN::default_ref_id;
+ $_[2] = $ref_id = 'refs/remotes/' . $_prefix . $Git::SVN::default_ref_id;
}
$_[1] = $repo_id;
my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
$_[3] = $path = '' unless (defined $path);
- mkpath(["$ENV{GIT_DIR}/svn"]);
+ mkpath(["$ENV{GIT_DIR}/svn/$ref_id"]);
bless {
ref_id => $ref_id, dir => $dir, index => "$dir/index",
path => $path, config => "$ENV{GIT_DIR}/svn/config",
@@ -3354,7 +3355,16 @@ sub rev_db_path {
sub map_path {
my ($self, $uuid) = @_;
$uuid ||= $self->ra_uuid;
- "$self->{map_root}.$uuid";
+ my $map_path = "$self->{map_root}.$uuid";
+ return $map_path if ( -f $map_path );
+
+ my $db_path = $map_path;
+ $db_path =~ s/\.rev_map/.rev_db/;
+ return $map_path if ( -f $db_path );
+
+ return $1 if ($map_path =~ m(refs/remotes/(.*)) && -f $1);
+ return $1 if ($db_path =~ m(refs/remotes/(.*)) && -f $1);
+ return $map_path;
}
sub uri_encode {
@@ -5498,7 +5508,7 @@ sub minimize_connections {
my $pfx = "svn-remote.$x->{old_repo_id}";
my $old_fetch = quotemeta("$x->{old_path}:".
- "refs/remotes/$x->{ref_id}");
+ "$x->{ref_id}");
command_noisy(qw/config --unset/,
"$pfx.fetch", '^'. $old_fetch . '$');
delete $r->{$x->{old_repo_id}}->
@@ -5567,7 +5577,7 @@ sub new {
my ($class, $glob) = @_;
my $re = $glob;
$re =~ s!/+$!!g; # no need for trailing slashes
- $re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!;
+ $re =~ m!^([^*]*)(\*(?:/\*)*)(.*)$!;
my $temp = $re;
my ($left, $right) = ($1, $3);
$re = $2;
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 5654962..fd8631f 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -14,7 +14,7 @@ if ! test_have_prereq PERL; then
fi
GIT_DIR=$PWD/.git
-GIT_SVN_DIR=$GIT_DIR/svn/git-svn
+GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
SVN_TREE=$GIT_SVN_DIR/svn-tree
svn >/dev/null 2>&1
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 78610b6..bbfd7f4 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -172,11 +172,11 @@ test_expect_success "follow-parent is atomic" '
git update-ref refs/remotes/flunk@18 refs/remotes/stunk~2 &&
git update-ref -d refs/remotes/stunk &&
git config --unset svn-remote.svn.fetch stunk &&
- mkdir -p "$GIT_DIR"/svn/flunk@18 &&
- rev_map=$(cd "$GIT_DIR"/svn/stunk && ls .rev_map*) &&
- dd if="$GIT_DIR"/svn/stunk/$rev_map \
- of="$GIT_DIR"/svn/flunk@18/$rev_map bs=24 count=1 &&
- rm -rf "$GIT_DIR"/svn/stunk &&
+ mkdir -p "$GIT_DIR"/svn/refs/remotes/flunk@18 &&
+ rev_map=$(cd "$GIT_DIR"/svn/refs/remotes/stunk && ls .rev_map*) &&
+ dd if="$GIT_DIR"/svn/refs/remotes/stunk/$rev_map \
+ of="$GIT_DIR"/svn/refs/remotes/flunk@18/$rev_map bs=24 count=1 &&
+ rm -rf "$GIT_DIR"/svn/refs/remotes/stunk &&
git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
git svn fetch -i flunk &&
git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
index c0098d9..901b8e0 100755
--- a/t/t9107-git-svn-migrate.sh
+++ b/t/t9107-git-svn-migrate.sh
@@ -16,9 +16,7 @@ test_expect_success 'setup old-looking metadata' '
cd .. &&
git svn init "$svnrepo" &&
git svn fetch &&
- mv "$GIT_DIR"/svn/* "$GIT_DIR"/ &&
- mv "$GIT_DIR"/svn/.metadata "$GIT_DIR"/ &&
- rmdir "$GIT_DIR"/svn &&
+ rm -rf "$GIT_DIR"/svn &&
git update-ref refs/heads/git-svn-HEAD refs/${remotes_git_svn} &&
git update-ref refs/heads/svn-HEAD refs/${remotes_git_svn} &&
git update-ref -d refs/${remotes_git_svn} refs/${remotes_git_svn}
@@ -87,7 +85,7 @@ test_expect_success 'migrate --minimize on old inited layout' '
rm -rf "$GIT_DIR"/svn &&
for i in `cat fetch.out`; do
path=`expr $i : "\([^:]*\):.*$"`
- ref=`expr $i : "[^:]*:refs/remotes/\(.*\)$"`
+ ref=`expr $i : "[^:]*:\(refs/remotes/.*\)$"`
if test -z "$ref"; then continue; fi
if test -n "$path"; then path="/$path"; fi
( mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
@@ -107,16 +105,16 @@ test_expect_success 'migrate --minimize on old inited layout' '
test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
git svn fetch -i trunk &&
- test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
- expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" &&
+ test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
+ expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
test -n "$expect" &&
rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
convert_to_rev_db "$expect" "$rev_db" &&
rm -f "$expect" &&
test -f "$rev_db" &&
git svn fetch -i trunk &&
- test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
- test ! -e "$GIT_DIR"/svn/trunk/.rev_db &&
+ test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
+ test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
test -f "$expect"
'
diff --git a/t/t9143-git-svn-gc.sh b/t/t9143-git-svn-gc.sh
index f2ba2d1..99f69c6 100755
--- a/t/t9143-git-svn-gc.sh
+++ b/t/t9143-git-svn-gc.sh
@@ -28,26 +28,26 @@ test_expect_success 'Setup repo' 'git svn init "$svnrepo"'
test_expect_success 'Fetch repo' 'git svn fetch'
test_expect_success 'make backup copy of unhandled.log' '
- cp .git/svn/git-svn/unhandled.log tmp
+ cp .git/svn/refs/remotes/git-svn/unhandled.log tmp
'
-test_expect_success 'create leftover index' '> .git/svn/git-svn/index'
+test_expect_success 'create leftover index' '> .git/svn/refs/remotes/git-svn/index'
test_expect_success 'git svn gc runs' 'git svn gc'
-test_expect_success 'git svn index removed' '! test -f .git/svn/git-svn/index'
+test_expect_success 'git svn index removed' '! test -f .git/svn/refs/remotes/git-svn/index'
if perl -MCompress::Zlib -e 0 2>/dev/null
then
test_expect_success 'git svn gc produces a valid gzip file' '
- gunzip .git/svn/git-svn/unhandled.log.gz
+ gunzip .git/svn/refs/remotes/git-svn/unhandled.log.gz
'
else
say "Perl Compress::Zlib unavailable, skipping gunzip test"
fi
test_expect_success 'git svn gc does not change unhandled.log files' '
- test_cmp .git/svn/git-svn/unhandled.log tmp/unhandled.log
+ test_cmp .git/svn/refs/remotes/git-svn/unhandled.log tmp/unhandled.log
'
test_done
--
1.6.0.6
^ permalink raw reply related
* Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh
From: Adam Brewster @ 2009-08-12 3:14 UTC (permalink / raw)
To: git; +Cc: Eric Wong
In-Reply-To: <20090810083234.GA8698@dcvr.yhbt.net>
Eric,
Any thoughts on the other patch?
Am I close or is there a better way to go about this?
I didn't really know what to do with .git/svn/*. The easy answer is
mkdir -p $GIT_DIR/svn/refs/remotes &&
mv $GIT_DIR/svn/* $GIT_DIR/svn/refs/remotes
>From the comments in the Migration module, it seems like that's frowned
upon, so I came up with looking for .rev_map (or .rev_db) in both
locations (.git/svn/git-svn and .git/svn/refs/remotes/svn) and letting
it stay in whichever location it already exists. (The next email has a
slightly improved version of the patch.)
This solution is particularly inelegant in it's handling of
unhandled.log, but as far as I know that file is unused.
There's also the problem of what to do if someone has a ref called
ref/remotes/refs/remotes/..., but that seems unlikely enough to not
cause concern.
Adam
^ permalink raw reply
* Re: A tiny documentation patch
From: Junio C Hamano @ 2009-08-12 2:55 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Thomas Rast, Štěpán Němec, git
In-Reply-To: <4A812575.50105@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
> In current next's Documentation/, we have 149 lines with `-- and 48
> lines with `\--. How is our policy regarding old AsciiDoc?
We could drop support for AsciiDoc 7 after all mainstream distros stop
shipping it. If the need to bend backwards in order to support it gets
too much for us, we might be tempted to drop it sooner, but are we getting
to that point? I hope not.
> (read: volunteer) making these things uniform one way or the other,
> depending which versions we want to support.
Thanks. 150 does not sound too bad to classify between ones that should
be em-dash and that should be double dashes.
^ permalink raw reply
* Re: RFC: default version of the documentation tool chain (git 1.7)
From: Junio C Hamano @ 2009-08-12 2:53 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Git Mailing List
In-Reply-To: <4A8139C5.9030703@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
> The current defaults for building the documentation are so that asciidoc
> up to 7.1.2 and docbook-xsl 1.69.0 and 1.71.1 need no extra settings,
> whereas all other versions need extra options (1 or more of ASCIIDOC8,
> ASCIIDOC_NO_ROFF, DOCBOOK_XSL_172, DOCBOOK_SUPPRESS_SP), see below. This
> basically means that all current distros need extra options.
>
> I suggest changing the defaults for the git-1.7 cycle.
Do you mean that people with older asciidoc would set a new option, say
ASCIIDOC7, instead of not setting ASCIIDOC8?
> Based on that, I suggest the following defaults for the git-1.7
> documentation build file:
> - ASCIIDOC8=yes. Caters for everything non-EOLed (8.0 and above)
> - ASCIIDOC_NO_ROFF=yes. Caters for everything non-EOLed (1.73 and above,
> 1.68.1 and below)
I would say that is a sensible default.
^ permalink raw reply
* Re: [RFC PATCH v3 3/8] Read .gitignore from index if it is assume-unchanged
From: Junio C Hamano @ 2009-08-12 2:51 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git, Johannes Schindelin
In-Reply-To: <1250005446-12047-4-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> diff --git a/Documentation/technical/api-directory-listing.txt b/Documentation/technical/api-directory-listing.txt
> index 5bbd18f..7d0e282 100644
> --- a/Documentation/technical/api-directory-listing.txt
> +++ b/Documentation/technical/api-directory-listing.txt
> @@ -58,6 +58,9 @@ The result of the enumeration is left in these fields::
> Calling sequence
> ----------------
>
> +* Ensure the_index is populated as it may have CE_VALID entries that
> + affect directory listing.
> +
When you want to enumerate all paths in the work tree, instead of not just
the untracked ones, it used to be possible to first run read_directory()
before calling read_cache(). You are now forbidding this.
I do not think it is hard to resurrect the feature if it is necessary (add
an option to dir_struct and teach dir_add_name() not to ignore paths the
index knows about), and I do not think none of the existing code relies on
it anymore (I think "git add" used to), but there may be some codepath I
forgot about, which is a concern.
> diff --git a/builtin-clean.c b/builtin-clean.c
> index 2d8c735..d917472 100644
> --- a/builtin-clean.c
> +++ b/builtin-clean.c
> @@ -71,8 +71,11 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
>
> dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
>
> - if (!ignored)
> + if (!ignored) {
> + if (read_cache() < 0)
> + die("index file corrupt");
> setup_standard_excludes(&dir);
> + }
>
> pathspec = get_pathspec(prefix, argv);
> read_cache();
Wouldn't it be much cleaner to move the existing read_cache() up, like you
did for ls-files, instead of conditionally reading the index at a random
place in the program sequence depending on the combinations of options?
^ permalink raw reply
* Re: [PATCH] Re: [TRIVIAL] Documentation: merge: one <remote> is required
From: Junio C Hamano @ 2009-08-12 2:48 UTC (permalink / raw)
To: Paul Bolle; +Cc: Nicolas Sebrecht, git
In-Reply-To: <1250002681.2707.2.camel@localhost.localdomain>
Paul Bolle <pebolle@tiscali.nl> writes:
>> Shoudn't be
>>
>> [-m <msg>] <remote> [<remote>...]
>
> No, since "<remote>..." means one or more instances of the "<remote>"
> option.
Does it really?
After you brought up this "one or more", I re-read the docs your patches
touched, thinking that the author might have meant 'zero or more of A'
with these '<A>...' notation.
And I realized that they made perfect sense.
In general, you can write:
<command> ...
and read this as "The <command> can be followed by nothing or something
(zero or more) of unspecified kind". If <command> takes only one type of
zero or more things, you can _clarify the ellipses_ by prefixing them with
what kind of "stuff" you are talking about:
<command> <remote>...
and read this as "The <command> can be followed by nothing or something
(zero or more) of <remote>s".
On the other hand, you can also say (note that the ellipses stand on their
own and are not associated with <remote>):
<command> <remote> ...
and read this as "It takes one <remote> followed by nothing or something
(zero or more) of unspecified kind".
^ permalink raw reply
* Re: RFC for 1.7: Do not checkout -b master origin/master on clone
From: Junio C Hamano @ 2009-08-12 2:45 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Git Mailing List
In-Reply-To: <4A818B90.9050206@drmicha.warpmail.net>
Michael J Gruber <git@drmicha.warpmail.net> writes:
> One common source of confusion for newcomers is the fact that master is
> given such a special treatment in git. While it is certainly okay and
> helpful to set up a default branch in a new repository (git init) it is
> not at all clear why it should be treated specially in any other
> situation, such as:
>
> - Why is master the only local branch which git clone sets up (git
> checkout -b master origin/master)?
As you know it is not strictly "master". It is the primary branch at the
cloned repository, which by convention is master", but whatever remote end
points at with its HEAD.
We check out that primary branch to make it easy for people to work with
the simplest kind of CVS/SVN-like settings, which I suspect is 99% of
peoples' projects. Single "trunk" that is checked out immediately after
cloning from a distribution point (read: a bare repository) ready to be
used.
> - Why does git svn set up a local branch with an svn upstream which is
> determined by latest svn commit at the time of the first git svn fetch?
I do not have comments on design decisions in git-svn, other than trusting
that Eric would exercise good design tastes to make things coherent with
the git native workflow when the consistency makes sense.
> ..., and git clone
> sets up a local branch according to HEAD (and does some other guess work
> when cloning bare repos), which means that git clone shows the same
> "random" behaviour...
It is because you are cloning from a repository that is used actively to
build new history, flipping the HEAD left and right. That is where the
randomness comes from. IOW, a repository with an active work tree.
If you are cloning because you have your own private working area and you
would want to get another private working area to work simultaneously, you
have "clone -n && checkout -t origin/whatever". Also if you are doing
this on a local machine (which is somewhat common), there is new-workdir
script in contrib/. But this is _not_ the most common case we should
optimize the usability of "clone" for.
^ permalink raw reply
* [PATCHv2] git-instaweb: detect difference between mod_cgi and mod_cgid for apache2
From: Mark A Rada @ 2009-08-12 2:34 UTC (permalink / raw)
To: git
Comments?
--
Mark A Rada (ferrous26)
marada@uwaterloo.ca
--->8----
Some people have mod_cgid in place of mod_cgi, this will check which one
the user has available to them first and then act accordingly.
It is possible to have both mod_cgi and mod_cgid installed at the same
time; in these cases, mod_cgi will preferred over mod_cgid to make
things easier.
In the case that no CGI modules are available for apache2 the script
will print a message to the user notifying him/her about the problem.
Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
git-instaweb.sh | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 5f5cac7..ec0b518 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -298,7 +298,20 @@ EOF
resolve_full_httpd
list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
- echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+ if test -f "$module_path/mod_cgi.so"
+ then
+ echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+ else
+ $list_mods | grep 'mod_cgid\.c' >/dev/null 2>&1 || \
+ if test -f "$module_path/mod_cgid.so"
+ then
+ echo "LoadModule cgid_module $module_path/mod_cgid.so" >> "$conf"
+ else
+ echo "You don't have any CGI support!"
+ exit 2
+ fi
+ echo "ScriptSock logs/gitweb.sock" >> "$conf"
+ fi
cat >> "$conf" <<EOF
AddHandler cgi-script .cgi
<Location /gitweb.cgi>
--
1.6.4
^ permalink raw reply related
* Re: block-sha1: improve code on large-register-set machines
From: Nicolas Pitre @ 2009-08-12 2:26 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Git Mailing List, Junio C Hamano
In-Reply-To: <alpine.LFD.2.01.0908111602020.28882@localhost.localdomain>
On Tue, 11 Aug 2009, Linus Torvalds wrote:
>
>
> On Tue, 11 Aug 2009, Linus Torvalds wrote:
>
> >
> >
> > On Tue, 11 Aug 2009, Nicolas Pitre wrote:
> > >
> > > Well... gcc is really strange in this case (and similar other ones) with
> > > ARM compilation. A good indicator of the quality of the code is the
> > > size of the stack frame. When using the "+m" then gcc creates a 816
> > > byte stack frame, the generated binary grows by approx 3000 bytes, and
> > > performances is almost halved (7.600s). Looking at the assembly result
> > > I just can't figure out all the crazy moves taking place. Even the
> > > version with no barrier what so ever produces better assembly with a
> > > stack frame of 560 bytes.
> >
> > Ok, that's just crazy. That function has a required stack size of exactly
> > 64 bytes, and anything more than that is just spilling. And if you end up
> > with a stack frame of 560 bytes, that means that gcc is doing some _crazy_
> > spilling.
>
> Btw, what I think happens is:
>
> - gcc turns all those array accesses into pseudo's
>
> So now the 'array[16]' is seen as just another 16 variables rather than
> an array.
>
> - gcc then turns it into SSA, where each assignment basically creates a
> new variable. So the 16 array variables (and 5 regular variables) are
> now expanded to 80 SSA asignments (one array assignment per SHA1 round)
> plus an additional 2 assignments to the "regular" variables per round
> (B and E are changed each round). So in SSA form, you actually end up
> having 240 pseudo's associated with the actual variables. Plus all
> the temporaries of course.
>
> - the thing then goes crazy and tries to generate great code from that
> internal SSA model. And since there are never more than ~25 things
> _live_ at any particular point, it works fine with lots of registers,
> but on small-register machines gcc just goes crazy and has to spill.
> And it doesn't spill 'array[x]' entries - it spills the _pseudo's_ it
> has created - hundreds of them.
>
> - End result: if the spill code doesn't share slots, it's going to create
> a totally unholy mess of crap.
>
> That's what the whole 'volatile unsigned int *' game tried to avoid. But
> it really sounds like it's not working too well for you. And the _big_
> memory barrier ends up helping just because with that in place, you end up
> being almost entirely unable to schedule _anything_ between the different
> SHA rounds, so you end up with only six or seven variables "live" in
> between those barriers, and the stupid register allocator/spill logic
> doesn't break down too badly.
>
> The thing is, if you do full memory barriers, then you're probably better
> off making both the loads and the stores be "volatile". That should have
> similar effects.
If the loads are volatile then gcc has less flexibility when scheduling
them.
> The downside with that is that it really limits the loads. So (like the
> full memory barrier) it's a big hammer approach. But it probably generates
> better code for you, because it avoids the mental breakdown of gcc
> spilling its pseudo's.
Actually, all my previous tests were done with gcc-4.3.2. I now have
installed Fedora 11 which has gcc-4.4.0. And now the stack frame is a
nice 64 bytes. ;-)
That's with the "memory" though. With the volatile, stack frame goes up
to 224 bytes and performance, although not as bad as before, is like
5.160s instead of 4.410s. The "+m" version is not much better: 208 byte
stack frame and similar performance.
The version with no barrier what so ever runs in 4.580s and uses a 88
byte stack frame. The generated assembly contains stupid things, but
this is still the second best version, even better than the "+m" and
volatile ptr ones.
Conclusion: the full "memory" barrier remains the best choice on ARM.
Nicolas
^ permalink raw reply
* Re: [RFCv3 2/4] Add Python support library for CVS remote helper
From: David Aguilar @ 2009-08-12 2:10 UTC (permalink / raw)
To: Johan Herland; +Cc: git, barkalow, gitster, Johannes.Schindelin
In-Reply-To: <1250036031-32272-3-git-send-email-johan@herland.net>
On Wed, Aug 12, 2009 at 02:13:49AM +0200, Johan Herland wrote:
> This patch introduces a Python package called "git_remote_cvs" containing
> the building blocks of the CVS remote helper. The CVS remote helper itself
> is NOT part of this patch.
Interesting...
> diff --git a/git_remote_cvs/changeset.py b/git_remote_cvs/changeset.py
> new file mode 100644
> index 0000000..27c4129
> --- /dev/null
> +++ b/git_remote_cvs/changeset.py
> @@ -0,0 +1,114 @@
> +#!/usr/bin/env python
> +
> +"""Functionality for collecting individual CVS revisions into "changesets"
> +
> +A changeset is a collection of CvsRev objects that belong together in the same
> +"commit". This is a somewhat artificial construct on top of CVS, which only
> +stores changes at the per-file level. Normally, CVS users create several CVS
> +revisions simultaneously by applying the "cvs commit" command to several files
> +with related changes. This module tries to reconstruct this notion of related
> +revisions.
> +"""
> +
> +from util import *
Importing * is frowned upon in Python.
It's much easier to see where things are coming from if you
'import util' and use the namespaced util.foo() way of accessing
the functions.
Furthermore, you're going to want to use absolute imports.
Anyone can create 'util.py' and blindly importing 'util' is
asking for trouble.
Instead use:
from git_remote_cvs import util
> +class Changeset (object):
> + """Encapsulate a single changeset/commit"""
I think it reads better as Changeset(object)
(drop the spaces before the parens).
That applies to the rest of this patch as well.
This also had me wondering about the following:
git uses tabs for indentation
BUT, the python convention is to use 4-space indents ala PEP-8
http://www.python.org/dev/peps/pep-0008/
It might be appealing to when-in-Rome (Rome being Python) here
and do things the python way when we code in Python.
Consistency with pep8 is good if we expect to get python hackers
to contribute to git_remote_cvs.
> +
> + __slots__ = ('revs', 'date', 'author', 'message')
__slots__ is pretty esoteric in Python-land.
But, if your justification is to minimize memory usage, then
yes, this is a good thing to do.
> + def __init__ (self, date, author, message):
> + self.revs = {} # dict: path -> CvsRev object
> + self.date = date # CvsDate object
> + self.author = author
> + self.message = message # Lines of commit message
pep8 and other parts of the git codebase recommend against
lining up the equals signs like that. Ya, sorry for the nits
being that they're purely stylistic.
> + if len(msg) > 25: msg = msg[:22] + "..." # Max 25 chars long
> + return "<Changeset @(%s) by %s (%s) updating %i files>" % (
> + self.date, self.author, msg, len(self.revs))
Similar to the git coding style, this might be better written:
...
if len(msg) > 25:
msg = msg[:22] + '...' # Max 25 chars long
...
(aka avoid single-line ifs)
There's a few other instances of this in the patch as well.
> diff --git a/git_remote_cvs/cvs.py b/git_remote_cvs/cvs.py
> new file mode 100644
> index 0000000..cc2e13f
> --- /dev/null
> +++ b/git_remote_cvs/cvs.py
> @@ -0,0 +1,884 @@
> [...]
> +
> + def enumerate (self):
> + """Return a list of integer components in this CVS number"""
> + return list(self.l)
enumerate has special meaning in Python.
items = (1, 2, 3, 4)
for idx, item in enumerate(items):
print idx, item
I'm not sure if this would cause confusion...
> [...]
> + else: # revision number
> + assert self.l[-1] > 0
asserts go away when running with PYTHONOPTIMIZE.
If this is really an error then we should we raise an exception
instead?
> + @classmethod
> + def test (cls):
> + assert cls("1.2.4") == cls("1.2.0.4")
Hmm.. Does it make more sense to use the unittest module?
e.g. self.assertEqual(foo, bar)
> diff --git a/git_remote_cvs/cvs_revision_map.py b/git_remote_cvs/cvs_revision_map.py
> new file mode 100644
> index 0000000..7d7810f
> --- /dev/null
> +++ b/git_remote_cvs/cvs_revision_map.py
> @@ -0,0 +1,362 @@
> +#!/usr/bin/env python
> +
> +"""Functionality for mapping CVS revisions to associated metainformation"""
> +
> +from util import *
> +from cvs import CvsNum, CvsDate
> +from git import GitFICommit, GitFastImport, GitObjectFetcher
We definitely need absolute imports here.
'import git' could find the git-python project's git module.
Nonetheless, interesting stuff.
--
David
^ permalink raw reply
* Re: [RFC PATCH v3 7/8] Support sparse checkout in unpack_trees() and read-tree
From: Nguyen Thai Ngoc Duy @ 2009-08-12 1:30 UTC (permalink / raw)
To: skillzero; +Cc: Jakub Narebski, git, Johannes Schindelin, Junio C Hamano
In-Reply-To: <2729632a0908111503i7f035c1aw4e84151eab821006@mail.gmail.com>
On Wed, Aug 12, 2009 at 5:03 AM, <skillzero@gmail.com> wrote:
> On Tue, Aug 11, 2009 at 2:38 PM, Jakub Narebski<jnareb@gmail.com> wrote:
>> skillzero@gmail.com writes:
>>> 2009/8/11 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:
>>
>>> > [1] .git/info/sparse has the same syntax as .git/info/exclude. Files
>>> > that match the patterns will be set as CE_VALID.
>>>
>>> Does this mean it will only support excluding paths you don't want
>>> rather than letting you only include paths you do want?
>>
>> Errr... what I read is that paths set by .git/info/sparse would be
>> excluded from checkout (marked as assume-unchanged / CE_VALID).
>>
>> But if it is the same mechanism as gitignore, then you can use !
>> prefix to set files (patterns) to include, e.g.
>>
>> !Documentation/
>> *
>>
>> (I think rules are processed top-down, first matching wins).
>
> I wasn't sure because the .gitignore negation stuff mentions negating
> a previously ignored pattern. But for sparse patterns, there likely
> wouldn't be a previous pattern.
No problem. We put pattern '*' at top (match everything). Previous
pattern issue solved.
> Include patterns are a little
> different in that if there are no include patterns (but maybe some
> exclude patterns), I think the expectation is that everything will be
> included (minus excludes), but if you have some include patterns then
> only those paths will be included (minus any excludes).
Let's say you want to include foo/ and bar/ only, this should work:
*
!foo/
!bar/
The evaluating order is from bottom up. When it first matches 'bar/',
because it a negate pattern, it returns "no don't match" and stops.
When it matches neither foo/ nor bar/ then it will be caught by '*'
and return "yes it matches" - that means "ignored" from checkout area.
In the end only foo/* and bar/* survive.
I think it's as easy as writing exclude patterns once you figure out '*'.
--
Duy
^ permalink raw reply
* Re: How do gmail users try out patches from this list?
From: Wesley J. Landaker @ 2009-08-12 1:17 UTC (permalink / raw)
To: Nicolas Sebrecht; +Cc: skillzero, git
In-Reply-To: <20090811221408.GC12956@vidovic>
On Tuesday 11 August 2009 16:14:08 Nicolas Sebrecht wrote:
> The 11/08/09, skillzero@gmail.com wrote:
> > Sorry if this is dumb question, but I didn't see any good info in my
> > searches.
> >
> > How do gmail users normally apply patches that come through the list?
>
> It doesn't rely on your address mail provider but on your local email
> workflow/MUA.
I'm not in this situation, but my guess is that a lot of people use gmail
primarily through the web interface (e.g. because of corporate firewalls or
some other reason). Maybe someone in that situation should make an new "git
imap-am" command? Kind of the reverse to imap-send. Just a thought. =)
^ permalink raw reply
* [JGIT PATCH] Add PathSuffixFilter class which is TreeFilter.
From: Grzegorz Kossakowski @ 2009-08-12 1:16 UTC (permalink / raw)
To: git; +Cc: Grzegorz Kossakowski
From: Grzegorz Kossakowski <grek@google.com>
Added a simple TreeFilter that filters all entries that have path with
given suffix. This filter is always recursive.
Signed-off-by: Grzegorz Kossakowski <grek@google.com>
---
.../treewalk/filter/PathSuffixFilterTestCase.java | 133 ++++++++++++++++++++
.../src/org/spearce/jgit/treewalk/TreeWalk.java | 32 +++++
.../jgit/treewalk/filter/PathSuffixFilter.java | 97 ++++++++++++++
3 files changed, 262 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/filter/PathSuffixFilterTestCase.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/PathSuffixFilter.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/filter/PathSuffixFilterTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/filter/PathSuffixFilterTestCase.java
new file mode 100644
index 0000000..5240ed9
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/treewalk/filter/PathSuffixFilterTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * 2009 Copyright Google, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.treewalk.filter;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.spearce.jgit.dircache.DirCache;
+import org.spearce.jgit.dircache.DirCacheBuilder;
+import org.spearce.jgit.dircache.DirCacheEntry;
+import org.spearce.jgit.lib.FileMode;
+import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.ObjectWriter;
+import org.spearce.jgit.lib.RepositoryTestCase;
+import org.spearce.jgit.treewalk.TreeWalk;
+
+public class PathSuffixFilterTestCase extends RepositoryTestCase {
+
+ public void testNonRecursiveFiltering() throws IOException {
+ final ObjectWriter ow = new ObjectWriter(db);
+ final ObjectId aSth = ow.writeBlob("a.sth".getBytes());
+ final ObjectId aTxt = ow.writeBlob("a.txt".getBytes());
+ final DirCache dc = DirCache.read(db);
+ final DirCacheBuilder builder = dc.builder();
+ final DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
+ aSthEntry.setFileMode(FileMode.REGULAR_FILE);
+ aSthEntry.setObjectId(aSth);
+ final DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
+ aTxtEntry.setFileMode(FileMode.REGULAR_FILE);
+ aTxtEntry.setObjectId(aTxt);
+ builder.add(aSthEntry);
+ builder.add(aTxtEntry);
+ builder.finish();
+ final ObjectId treeId = dc.writeTree(ow);
+
+
+ final TreeWalk tw = new TreeWalk(db);
+ tw.setFilter(PathSuffixFilter.create(".txt"));
+ tw.addTree(treeId);
+
+ List<String> paths = new LinkedList<String>();
+ while (tw.next()) {
+ paths.add(tw.getPathString());
+ }
+
+ List<String> expected = new LinkedList<String>();
+ expected.add("a.txt");
+
+ assertEquals(expected, paths);
+ }
+
+ public void testRecursiveFiltering() throws IOException {
+ final ObjectWriter ow = new ObjectWriter(db);
+ final ObjectId aSth = ow.writeBlob("a.sth".getBytes());
+ final ObjectId aTxt = ow.writeBlob("a.txt".getBytes());
+ final ObjectId bSth = ow.writeBlob("b.sth".getBytes());
+ final ObjectId bTxt = ow.writeBlob("b.txt".getBytes());
+ final DirCache dc = DirCache.read(db);
+ final DirCacheBuilder builder = dc.builder();
+ final DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
+ aSthEntry.setFileMode(FileMode.REGULAR_FILE);
+ aSthEntry.setObjectId(aSth);
+ final DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
+ aTxtEntry.setFileMode(FileMode.REGULAR_FILE);
+ aTxtEntry.setObjectId(aTxt);
+ builder.add(aSthEntry);
+ builder.add(aTxtEntry);
+ final DirCacheEntry bSthEntry = new DirCacheEntry("sub/b.sth");
+ bSthEntry.setFileMode(FileMode.REGULAR_FILE);
+ bSthEntry.setObjectId(bSth);
+ final DirCacheEntry bTxtEntry = new DirCacheEntry("sub/b.txt");
+ bTxtEntry.setFileMode(FileMode.REGULAR_FILE);
+ bTxtEntry.setObjectId(bTxt);
+ builder.add(bSthEntry);
+ builder.add(bTxtEntry);
+ builder.finish();
+ final ObjectId treeId = dc.writeTree(ow);
+
+
+ final TreeWalk tw = new TreeWalk(db);
+ tw.setRecursive(true);
+ tw.setFilter(PathSuffixFilter.create(".txt"));
+ tw.addTree(treeId);
+
+ List<String> paths = new LinkedList<String>();
+ while (tw.next()) {
+ paths.add(tw.getPathString());
+ }
+
+ List<String> expected = new LinkedList<String>();
+ expected.add("a.txt");
+ expected.add("sub/b.txt");
+
+ assertEquals(expected, paths);
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 5705936..16088b4 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -739,6 +739,38 @@ public int isPathPrefix(final byte[] p, final int pLen) {
}
/**
+ * Test if the supplied path matches (being suffix of) the current entry's
+ * path.
+ * <p>
+ * This method tests that the supplied path is exactly equal to the current
+ * entry, or is relative to one of entry's parent directories. It is faster
+ * to use this method then to use {@link #getPathString()} to first create
+ * a String object, then test <code>endsWith</code> or some other type of
+ * string match function.
+ *
+ * @param p
+ * path buffer to test.
+ * @param pLen
+ * number of bytes from <code>buf</code> to test.
+ * @return true if p is suffix of the current path;
+ * false if otherwise
+ *
+ */
+ public boolean isPathSuffix(final byte[] p, final int pLen) {
+ final AbstractTreeIterator t = currentHead;
+ final byte[] c = t.path;
+ final int cLen = t.pathLen;
+ int ci;
+
+ for (ci = 1; ci < cLen && ci < pLen; ci++) {
+ if (c[cLen-ci] != p[pLen-ci])
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Get the current subtree depth of this walker.
*
* @return the current subtree depth of this walker.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/PathSuffixFilter.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/PathSuffixFilter.java
new file mode 100644
index 0000000..8777e7d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/filter/PathSuffixFilter.java
@@ -0,0 +1,97 @@
+/*
+ * 2009 Copyright Google, Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.treewalk.filter;
+
+import java.io.IOException;
+
+import org.spearce.jgit.errors.IncorrectObjectTypeException;
+import org.spearce.jgit.errors.MissingObjectException;
+import org.spearce.jgit.lib.Constants;
+import org.spearce.jgit.treewalk.TreeWalk;
+
+/**
+ * Includes tree entries only if they match the configured path.
+ */
+public class PathSuffixFilter extends TreeFilter {
+
+ /**
+ * Create a new tree filter for a user supplied path.
+ * <p>
+ * Path strings use '/' to delimit directories on all platforms.
+ *
+ * @param path
+ * the path (suffix) to filter on. Must not be the empty string.
+ * @return a new filter for the requested path.
+ * @throws IllegalArgumentException
+ * the path supplied was the empty string.
+ */
+ public static PathSuffixFilter create(String path) {
+ if (path.length() == 0)
+ throw new IllegalArgumentException("Empty path not permitted.");
+ return new PathSuffixFilter(path);
+ }
+
+ final String pathStr;
+ final byte[] pathRaw;
+
+ private PathSuffixFilter(final String s) {
+ pathStr = s;
+ pathRaw = Constants.encode(pathStr);
+ }
+
+ @Override
+ public TreeFilter clone() {
+ return this;
+ }
+
+ @Override
+ public boolean include(TreeWalk walker) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
+ if (walker.isSubtree())
+ return true;
+ else
+ return walker.isPathSuffix(pathRaw, pathRaw.length);
+
+ }
+
+ @Override
+ public boolean shouldBeRecursive() {
+ return true;
+ }
+
+}
--
1.6.3.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox