* Re: Puzzled by a t9500 test failure
From: Junio C Hamano @ 2008-10-14 0:13 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20081013234851.GY4856@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Junio C Hamano <gitster@pobox.com> wrote:
>> With recent tip of 'master':
>>
>> $ make
>> $ mkdir t/trash
>> $ cd t && sh t9500-*.sh -i
>>
>> fails at the very first test. Can anybody figure out why?
>
> Hmmph. Near as I can tell its because gitweb.log has this in it:
>
> $ cat gitweb.log
> [Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in scalar chomp at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 1811.
> [Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in addition (+) at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 3772.
> HASH..
>
> The test does a grep for '[[]' and if it matches, fails. I'm not
> sure why this started showing up now. Obviously I merged something
> that failed the test suite, but I was pretty sure I had run the full
> set before publishing anything.
Nothing as far as I can tell changed while you were the pumpking.
I was just wondering why the presense of that extra, should-be-unused,
t/trash directory affects the outcome of the test.
^ permalink raw reply
* Re: Puzzled by a t9500 test failure
From: Shawn O. Pearce @ 2008-10-14 0:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Petr Baudis
In-Reply-To: <20081013234851.GY4856@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
> Junio C Hamano <gitster@pobox.com> wrote:
> > With recent tip of 'master':
> >
> > $ make
> > $ mkdir t/trash
> > $ cd t && sh t9500-*.sh -i
> >
> > fails at the very first test. Can anybody figure out why?
>
> Hmmph. Near as I can tell its because gitweb.log has this in it:
>
> $ cat gitweb.log
> [Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in scalar chomp at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 1811.
> [Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in addition (+) at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 3772.
> HASH..
bisect says its aed93de428d7d12ee23d84d27265af1e37eb348f,
"gitweb: Support for tag clouds".
This appears to fix it. As for how I missed this, I do not know.
I usually tested topic branches pretty heavily before merging them
to next, and I tested both master and next daily. So I thought
the topic was ready to merge into master. Apparently it was not.
How I missed the failed merge, I don't know. :-\
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1116800..793166e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1808,7 +1808,7 @@ sub git_get_project_ctags {
foreach (<$git_dir/ctags/*>) {
open CT, $_ or next;
my $val = <CT>;
- chomp $val;
+ chomp $val if defined $val;
close CT;
my $ctag = $_; $ctag =~ s#.*/##;
$ctags->{$ctag} = $val;
@@ -1822,7 +1822,11 @@ sub git_populate_project_tagcloud {
# First, merge different-cased tags; tags vote on casing
my %ctags_lc;
foreach (keys %$ctags) {
- $ctags_lc{lc $_}->{count} += $ctags->{$_};
+ if (defined ($ctags_lc{lc $_}->{count})) {
+ $ctags_lc{lc $_}->{count} += $ctags->{$_};
+ } else {
+ $ctags_lc{lc $_}->{count} = $ctags->{$_};
+ }
if (not $ctags_lc{lc $_}->{topcount}
or $ctags_lc{lc $_}->{topcount} < $ctags->{$_}) {
$ctags_lc{lc $_}->{topcount} = $ctags->{$_};
@@ -3769,7 +3773,11 @@ sub git_project_list_body {
my %ctags;
foreach my $p (@projects) {
foreach my $ct (keys %{$p->{'ctags'}}) {
- $ctags{$ct} += $p->{'ctags'}->{$ct};
+ if (defined $ctags{$ct}) {
+ $ctags{$ct} += $p->{'ctags'}->{$ct};
+ } else {
+ $ctags{$ct} = $p->{'ctags'}->{$ct};
+ }
}
}
my $cloud = git_populate_project_tagcloud(\%ctags);
--
Shawn.
^ permalink raw reply related
* Re: Puzzled by a t9500 test failure
From: Shawn O. Pearce @ 2008-10-13 23:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vljws83nd.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> wrote:
> With recent tip of 'master':
>
> $ make
> $ mkdir t/trash
> $ cd t && sh t9500-*.sh -i
>
> fails at the very first test. Can anybody figure out why?
Hmmph. Near as I can tell its because gitweb.log has this in it:
$ cat gitweb.log
[Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in scalar chomp at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 1811.
[Mon Oct 13 23:43:36 2008] gitweb.perl: Use of uninitialized value in addition (+) at /home/sop/local/maint-git/t/../gitweb/gitweb.perl line 3772.
HASH..
The test does a grep for '[[]' and if it matches, fails. I'm not
sure why this started showing up now. Obviously I merged something
that failed the test suite, but I was pretty sure I had run the full
set before publishing anything.
--
Shawn.
^ permalink raw reply
* The behaviour of git bisect skip
From: H. Peter Anvin @ 2008-10-13 23:42 UTC (permalink / raw)
To: Git Mailing List
I recently had the unhappy experience of trying to bisect a tree with a
large region of the history obscured by auxilliary bugs. "git bisect
skip" will stay in the central region, thus being largely useless.
I was thinking about how to possibly do it better. This is something I
came up with, and thought it might be interesing.
a. we obviously cannot move the start and end (good and bad) markers,
since they have not been shown one way or the other.
b. however, the practice of testing the centermost point is merely the
*optimal*, corresponding to 1 bit of information per iteration. An
off-center test is also possible (as long as the value depends on both
endpoints, and isn't fixed from one of the endpoints; in that case we
have a linear search), corresponding to a smaller amount of information
- for example, sampling at the one-quarter point corresponds to
3/4*log2(3/4) + 1/4*log2(1/4) =~ 0.811 bits of information.
I would suggest something based on the following algorithm:
Given an interval with a certain number of skip points, subdivide the
interval into subintervals each separated by a skip point. Pick the
centermost point of the *largest* of these intervals. If there is more
than one largest interval, choose the one centermost point that ends up
being centermost in the overall interval.
This algorithm obviously needs some adjustment (as does plain binary
search) in order to deal with a branched history, but I thought it might
be an interesting starting point. It has the desirable property that it
can make forward progress even in the presence of skip points, and that
it avoids needlessly searching close to skip points.
-hpa
^ permalink raw reply
* Puzzled by a t9500 test failure
From: Junio C Hamano @ 2008-10-13 23:40 UTC (permalink / raw)
To: git
With recent tip of 'master':
$ make
$ mkdir t/trash
$ cd t && sh t9500-*.sh -i
fails at the very first test. Can anybody figure out why?
^ permalink raw reply
* [PATCH] rebase: Document --no-verify option to bypass pre-rebase hook
From: Nanako Shiraishi @ 2008-10-13 23:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O. Pearce
In-Reply-To: <20081012212543.GG4856@spearce.org>
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
---
"Shawn O. Pearce" <spearce@spearce.org> writes:
> * ns/rebase-noverify (Mon Oct 6 14:14:29 2008 +0900) 1 commit
> + rebase --no-verify
>
> This adds --no-verify to git rebase, to avoid the pre-rebase hook.
> Lacks documentation but otherwise looks sound.
Here it is.
Documentation/git-rebase.txt | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 32f0f12..4e84380 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
- [-s <strategy> | --strategy=<strategy>]
+ [-s <strategy> | --strategy=<strategy>] [--no-verify]
[-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
[--onto <newbase>] <upstream> [<branch>]
'git rebase' --continue | --skip | --abort
@@ -232,6 +232,9 @@ OPTIONS
--verbose::
Display a diffstat of what changed upstream since the last rebase.
+--no-verify::
+ This option bypasses the pre-rebase hook. See also linkgit:githooks[5].
+
-C<n>::
Ensure at least <n> lines of surrounding context match before
and after each change. When fewer lines of surrounding
--
1.6.0.2
--
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
^ permalink raw reply related
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Tuncer Ayaz @ 2008-10-13 22:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vzll887ps.fsf@gitster.siamese.dyndns.org>
On Tue, Oct 14, 2008 at 12:13 AM, Junio C Hamano <gitster@pobox.com> wrote:
> tuncer.ayaz@gmail.com writes:
>
>> From: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>>
>> Updated patch to current Junio master.
>
> That's not a commit log message, is it?
Sorry, I was referring to my previous post and
this was my first post via send-email.
Is it ok for me to include the log message here?
-->
After fixing clone -q I noticed that pull -q does not do what
it's supposed to do and implemented --quiet/--verbose by
adding it to builtin-merge and fixing two places in builtin-fetch.
I have not touched/adjusted contrib/completion/git-completion.bash
but can take a look if wanted. I think it already needs one or two
adjustments caused by recent --OPTIONS changes in master.
I've tested the following invocations with the below changes applied:
$ git pull
$ git pull -q
$ git pull -v
<--
is that good enough or did I miss something?
>> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>> ---
>> Documentation/merge-options.txt | 8 ++++++++
>> builtin-fetch.c | 5 +++--
>> builtin-merge.c | 22 +++++++++++++++-------
>> git-pull.sh | 10 ++++++++--
>> 4 files changed, 34 insertions(+), 11 deletions(-)
>>
>> diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
>> index 007909a..427cdef 100644
>> --- a/Documentation/merge-options.txt
>> +++ b/Documentation/merge-options.txt
>> @@ -1,3 +1,11 @@
>> +-q::
>> +--quiet::
>> + Operate quietly.
>> +
>> +-v::
>> +--verbose::
>> + Be verbose.
>> +
>> --stat::
>> Show a diffstat at the end of the merge. The diffstat is also
>> controlled by the configuration option merge.stat.
>> diff --git a/builtin-fetch.c b/builtin-fetch.c
>> index ee93d3a..287ce33 100644
>> --- a/builtin-fetch.c
>> +++ b/builtin-fetch.c
>> @@ -372,12 +372,13 @@ static int store_updated_refs(const char *url, const char *remote_name,
>> SUMMARY_WIDTH, *kind ? kind : "branch",
>> REFCOL_WIDTH, *what ? what : "HEAD");
>> if (*note) {
>> - if (!shown_url) {
>> + if ((verbose || !quiet) && !shown_url) {
>
> A pair of external verbosity flag -q and -v may be acceptable, but is it
> sane to have a pair of variables in code always used like this? In other
> words, this makes me wonder if a single "verbosity level" variable that
> can be set to quiet, normal and verbose would make it more readable. For
> example, this one would say:
>
> if (verbosity >= VERBOSITY_NORMAL && !shown_url) {
> ...
> }
what I would actually prefer to implement are separate
printf functions for verbose, info and error messages
and display them according to:
info: sent to ouput if verbose is set or quiet is not set
error: always sent to ouput
verbose: only sent to output if verbose is set
you could get that with your "verbosity level" solution.
to keep it simple I would avoid adding any more
levels or topics to logging and if someone really wants
to either declare trace_printf to be debug_printf
or rename it :).
if that make sense I would like to teach this to
git as a general option as far as possible and get
rid of all the if clauses in front of printf calls.
> Also what does your command line parsing code do when the user gives -q
> and -v at the same time? Does the last one on the command line win?
> Shouldn't you instead get an error message (which of course would mean you
> would need to fix the caller in git-pull.sh)?
I thought about that also and at least in this patch
tried to handle it by ignoring quiet if verbose is set.
this may not be the logic everyone wants to have
and exclusively allowing either -q or -v makes
more sense.
>> + if (verbose || !quiet)
>> + fprintf(stderr, " %s\n", note);
>
> Ditto.
>
>> + if (verbose || !quiet)
>> + printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
>
> Ditto.
>
>> + if (verbose || !quiet)
>> + printf("%s\n", msg);
>> + if ((verbose || !quiet) && !merge_msg.len)
>
> Ditto.
>
>> + if (!verbose && quiet)
>> + show_diffstat = 0;
>
> Hmph, ah, that's (!(verbose || !quiet)). See the readability issue?
your version is more readable. the human mind seems to
have a problem with double or triple negations :).
>> + if (verbose || !quiet)
>> + printf("Updating %s..%s\n",
>> + hex,
>> + find_unique_abbrev(remoteheads->item->object.sha1,
>> + DEFAULT_ABBREV));
>
> Ditto.
>
^ permalink raw reply
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Junio C Hamano @ 2008-10-13 22:13 UTC (permalink / raw)
To: tuncer.ayaz; +Cc: git
In-Reply-To: <1223934148-13942-1-git-send-email-tuncer.ayaz@gmail.com>
tuncer.ayaz@gmail.com writes:
> From: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>
> Updated patch to current Junio master.
That's not a commit log message, is it?
> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
> ---
> Documentation/merge-options.txt | 8 ++++++++
> builtin-fetch.c | 5 +++--
> builtin-merge.c | 22 +++++++++++++++-------
> git-pull.sh | 10 ++++++++--
> 4 files changed, 34 insertions(+), 11 deletions(-)
>
> diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
> index 007909a..427cdef 100644
> --- a/Documentation/merge-options.txt
> +++ b/Documentation/merge-options.txt
> @@ -1,3 +1,11 @@
> +-q::
> +--quiet::
> + Operate quietly.
> +
> +-v::
> +--verbose::
> + Be verbose.
> +
> --stat::
> Show a diffstat at the end of the merge. The diffstat is also
> controlled by the configuration option merge.stat.
> diff --git a/builtin-fetch.c b/builtin-fetch.c
> index ee93d3a..287ce33 100644
> --- a/builtin-fetch.c
> +++ b/builtin-fetch.c
> @@ -372,12 +372,13 @@ static int store_updated_refs(const char *url, const char *remote_name,
> SUMMARY_WIDTH, *kind ? kind : "branch",
> REFCOL_WIDTH, *what ? what : "HEAD");
> if (*note) {
> - if (!shown_url) {
> + if ((verbose || !quiet) && !shown_url) {
A pair of external verbosity flag -q and -v may be acceptable, but is it
sane to have a pair of variables in code always used like this? In other
words, this makes me wonder if a single "verbosity level" variable that
can be set to quiet, normal and verbose would make it more readable. For
example, this one would say:
if (verbosity >= VERBOSITY_NORMAL && !shown_url) {
...
}
Also what does your command line parsing code do when the user gives -q
and -v at the same time? Does the last one on the command line win?
Shouldn't you instead get an error message (which of course would mean you
would need to fix the caller in git-pull.sh)?
> + if (verbose || !quiet)
> + fprintf(stderr, " %s\n", note);
Ditto.
> + if (verbose || !quiet)
> + printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
Ditto.
> + if (verbose || !quiet)
> + printf("%s\n", msg);
> + if ((verbose || !quiet) && !merge_msg.len)
Ditto.
> + if (!verbose && quiet)
> + show_diffstat = 0;
Hmph, ah, that's (!(verbose || !quiet)). See the readability issue?
> + if (verbose || !quiet)
> + printf("Updating %s..%s\n",
> + hex,
> + find_unique_abbrev(remoteheads->item->object.sha1,
> + DEFAULT_ABBREV));
Ditto.
^ permalink raw reply
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Tuncer Ayaz @ 2008-10-13 21:44 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20081013211327.GW4856@spearce.org>
On Mon, Oct 13, 2008 at 11:13 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
>> On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
>> > Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
>> >> Hi Shawn and list,
>> >>
>> >> I've updated the patch to current Junio master.
>> >>
>> >> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>> >
>> > Looks good to me.
>>
>> GMail borked it by inserting some linebreaks :(
>> is that a problem for this single diff or should
>> I first resend it properly via SMTP?
>
> I would resend it. For a one line diff its easy to hand apply,
> but with multiple hunks like this you don't to waste Junio's time
> by trying to fix up the patch by hand.
OK, configured my local setup for send-email to work
and used that.
^ permalink raw reply
* [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: tuncer.ayaz @ 2008-10-13 21:42 UTC (permalink / raw)
To: git; +Cc: Tuncer Ayaz
From: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Updated patch to current Junio master.
Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
---
Documentation/merge-options.txt | 8 ++++++++
builtin-fetch.c | 5 +++--
builtin-merge.c | 22 +++++++++++++++-------
git-pull.sh | 10 ++++++++--
4 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 007909a..427cdef 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,3 +1,11 @@
+-q::
+--quiet::
+ Operate quietly.
+
+-v::
+--verbose::
+ Be verbose.
+
--stat::
Show a diffstat at the end of the merge. The diffstat is also
controlled by the configuration option merge.stat.
diff --git a/builtin-fetch.c b/builtin-fetch.c
index ee93d3a..287ce33 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url, const char *remote_name,
SUMMARY_WIDTH, *kind ? kind : "branch",
REFCOL_WIDTH, *what ? what : "HEAD");
if (*note) {
- if (!shown_url) {
+ if ((verbose || !quiet) && !shown_url) {
fprintf(stderr, "From %.*s\n",
url_len, url);
shown_url = 1;
}
- fprintf(stderr, " %s\n", note);
+ if (verbose || !quiet)
+ fprintf(stderr, " %s\n", note);
}
}
fclose(fp);
diff --git a/builtin-merge.c b/builtin-merge.c
index 5e2b7f1..4f90501 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -44,6 +44,7 @@ static const char * const builtin_merge_usage[] = {
static int show_diffstat = 1, option_log, squash;
static int option_commit = 1, allow_fast_forward = 1;
static int allow_trivial = 1, have_message;
+static int quiet, verbose;
static struct strbuf merge_msg;
static struct commit_list *remoteheads;
static unsigned char head[20], stash[20];
@@ -152,6 +153,8 @@ static int option_parse_n(const struct option *opt,
}
static struct option builtin_merge_options[] = {
+ OPT__QUIET(&quiet),
+ OPT__VERBOSE(&verbose),
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
"do not show a diffstat at the end of the merge",
PARSE_OPT_NOARG, option_parse_n },
@@ -249,7 +252,8 @@ static void restore_state(void)
/* This is called when no merge was necessary. */
static void finish_up_to_date(const char *msg)
{
- printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+ if (verbose || !quiet)
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
drop_save();
}
@@ -330,14 +334,15 @@ static void finish(const unsigned char *new_head, const char *msg)
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
- printf("%s\n", msg);
+ if (verbose || !quiet)
+ printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message();
} else {
- if (!merge_msg.len)
+ if ((verbose || !quiet) && !merge_msg.len)
printf("No merge message -- not updating HEAD\n");
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
@@ -871,6 +876,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, builtin_merge_options,
builtin_merge_usage, 0);
+ if (!verbose && quiet)
+ show_diffstat = 0;
if (squash) {
if (!allow_fast_forward)
@@ -1012,10 +1019,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
- printf("Updating %s..%s\n",
- hex,
- find_unique_abbrev(remoteheads->item->object.sha1,
- DEFAULT_ABBREV));
+ if (verbose || !quiet)
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));
strbuf_addstr(&msg, "Fast forward");
if (have_message)
strbuf_addstr(&msg,
diff --git a/git-pull.sh b/git-pull.sh
index 75c3610..8e25d44 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,6 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
+quiet= verbose=
strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
@@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
+ -q|--quiet)
+ quiet=-q ;;
+ -v|--verbose)
+ verbose=-v ;;
-n|--no-stat|--no-summary)
no_stat=-n ;;
--stat|--summary)
@@ -121,7 +126,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git fetch --update-head-ok "$@" || exit 1
+git fetch $verbose $quiet --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
-exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
+exec git-merge $quiet $verbose $no_stat $no_commit \
+ $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
--
1.6.0.2.GIT
^ permalink raw reply related
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Shawn O. Pearce @ 2008-10-13 21:13 UTC (permalink / raw)
To: Tuncer Ayaz; +Cc: git
In-Reply-To: <4ac8254d0810131412o34c01a4cla30eadc45e2e4e06@mail.gmail.com>
Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> > Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> >> Hi Shawn and list,
> >>
> >> I've updated the patch to current Junio master.
> >>
> >> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
> >
> > Looks good to me.
>
> GMail borked it by inserting some linebreaks :(
> is that a problem for this single diff or should
> I first resend it properly via SMTP?
I would resend it. For a one line diff its easy to hand apply,
but with multiple hunks like this you don't to waste Junio's time
by trying to fix up the patch by hand.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Tuncer Ayaz @ 2008-10-13 21:12 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <20081013210607.GV4856@spearce.org>
On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
>> Hi Shawn and list,
>>
>> I've updated the patch to current Junio master.
>>
>> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
>
> Looks good to me.
GMail borked it by inserting some linebreaks :(
is that a problem for this single diff or should
I first resend it properly via SMTP?
^ permalink raw reply
* [JGIT PATCH 3/8] Add writeTree support to DirCache
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-3-git-send-email-spearce@spearce.org>
This way we can write a full tree from the DirCache, including reusing
any valid tree entries stored within the 'TREE' cache extension. By
reusing those entries we can avoid generating the tree objects that
are already stored in the Git repository.
The algorithm may cause up to 3 passes over the DirCache entries:
* Pass 1: Compute the tree structure
* Pass 2: Compute the sizes of each tree
* Pass 3: Write the tree object to the object store
These extra passes cause more CPU time to be expended in exchange
for a lower memory requirement during the tree writing. The code
is only formatting the lowest level leaf tree which has not yet
been written to the object store, so higher level trees do not
occupy memory while they are waiting for the leaves to write out.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/dircache/DirCache.java | 20 ++++
.../org/spearce/jgit/dircache/DirCacheTree.java | 115 ++++++++++++++++++++
.../spearce/jgit/errors/UnmergedPathException.java | 67 ++++++++++++
.../src/org/spearce/jgit/lib/FileMode.java | 7 ++
.../src/org/spearce/jgit/lib/ObjectWriter.java | 12 ++-
5 files changed, 219 insertions(+), 2 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
index 76657c4..b3c57ad 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
@@ -51,8 +51,11 @@
import java.util.Comparator;
import org.spearce.jgit.errors.CorruptObjectException;
+import org.spearce.jgit.errors.UnmergedPathException;
import org.spearce.jgit.lib.Constants;
import org.spearce.jgit.lib.LockFile;
+import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.ObjectWriter;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.util.MutableInteger;
import org.spearce.jgit.util.NB;
@@ -692,4 +695,21 @@ public DirCacheTree getCacheTree(final boolean build) {
}
return tree;
}
+
+ /**
+ * Write all index trees to the object store, returning the root tree.
+ *
+ * @param ow
+ * the writer to use when serializing to the store.
+ * @return identity for the root tree.
+ * @throws UnmergedPathException
+ * one or more paths contain higher-order stages (stage > 0),
+ * which cannot be stored in a tree object.
+ * @throws IOException
+ * an unexpected error occurred writing to the object store.
+ */
+ public ObjectId writeTree(final ObjectWriter ow)
+ throws UnmergedPathException, IOException {
+ return getCacheTree(true).writeTree(sortedEntries, 0, 0, ow);
+ }
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
index 26b6348..cf96ded 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheTree.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
+ * Copyright (C) 2008, Google Inc.
*
* All rights reserved.
*
@@ -37,14 +38,20 @@
package org.spearce.jgit.dircache;
+import static org.spearce.jgit.lib.Constants.OBJECT_ID_LENGTH;
+
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
+import org.spearce.jgit.errors.UnmergedPathException;
import org.spearce.jgit.lib.Constants;
+import org.spearce.jgit.lib.FileMode;
import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.ObjectWriter;
import org.spearce.jgit.util.MutableInteger;
import org.spearce.jgit.util.RawParseUtils;
@@ -273,6 +280,114 @@ public String getPathString() {
return r.toString();
}
+ /**
+ * Write (if necessary) this tree to the object store.
+ *
+ * @param cache
+ * the complete cache from DirCache.
+ * @param cIdx
+ * first position of <code>cache</code> that is a member of this
+ * tree. The path of <code>cache[cacheIdx].path</code> for the
+ * range <code>[0,pathOff-1)</code> matches the complete path of
+ * this tree, from the root of the repository.
+ * @param pathOffset
+ * number of bytes of <code>cache[cacheIdx].path</code> that
+ * matches this tree's path. The value at array position
+ * <code>cache[cacheIdx].path[pathOff-1]</code> is always '/' if
+ * <code>pathOff</code> is > 0.
+ * @param ow
+ * the writer to use when serializing to the store.
+ * @return identity of this tree.
+ * @throws UnmergedPathException
+ * one or more paths contain higher-order stages (stage > 0),
+ * which cannot be stored in a tree object.
+ * @throws IOException
+ * an unexpected error occurred writing to the object store.
+ */
+ ObjectId writeTree(final DirCacheEntry[] cache, int cIdx,
+ final int pathOffset, final ObjectWriter ow)
+ throws UnmergedPathException, IOException {
+ if (id == null) {
+ final int endIdx = cIdx + entrySpan;
+ final int size = computeSize(cache, cIdx, pathOffset, ow);
+ final ByteArrayOutputStream out = new ByteArrayOutputStream(size);
+ int childIdx = 0;
+ int entryIdx = cIdx;
+
+ while (entryIdx < endIdx) {
+ final DirCacheEntry e = cache[entryIdx];
+ final byte[] ep = e.path;
+ if (childIdx < childCnt) {
+ final DirCacheTree st = children[childIdx];
+ if (st.contains(ep, pathOffset, ep.length)) {
+ FileMode.TREE.copyTo(out);
+ out.write(' ');
+ out.write(st.encodedName);
+ out.write(0);
+ st.id.copyRawTo(out);
+
+ entryIdx += st.entrySpan;
+ childIdx++;
+ continue;
+ }
+ }
+
+ e.getFileMode().copyTo(out);
+ out.write(' ');
+ out.write(ep, pathOffset, ep.length - pathOffset);
+ out.write(0);
+ out.write(e.idBuffer(), e.idOffset(), OBJECT_ID_LENGTH);
+ entryIdx++;
+ }
+
+ id = ow.writeCanonicalTree(out.toByteArray());
+ }
+ return id;
+ }
+
+ private int computeSize(final DirCacheEntry[] cache, int cIdx,
+ final int pathOffset, final ObjectWriter ow)
+ throws UnmergedPathException, IOException {
+ final int endIdx = cIdx + entrySpan;
+ int childIdx = 0;
+ int entryIdx = cIdx;
+ int size = 0;
+
+ while (entryIdx < endIdx) {
+ final DirCacheEntry e = cache[entryIdx];
+ if (e.getStage() != 0)
+ throw new UnmergedPathException(e);
+
+ final byte[] ep = e.path;
+ if (childIdx < childCnt) {
+ final DirCacheTree st = children[childIdx];
+ if (st.contains(ep, pathOffset, ep.length)) {
+ final int stOffset = pathOffset + st.nameLength() + 1;
+ st.writeTree(cache, entryIdx, stOffset, ow);
+
+ size += FileMode.TREE.copyToLength();
+ size += st.nameLength();
+ size += OBJECT_ID_LENGTH + 2;
+
+ entryIdx += st.entrySpan;
+ childIdx++;
+ continue;
+ }
+ }
+
+ final FileMode mode = e.getFileMode();
+ if (mode.getObjectType() == Constants.OBJ_BAD)
+ throw new UnmergedPathException(e);
+
+ size += mode.copyToLength();
+ size += ep.length - pathOffset;
+ size += OBJECT_ID_LENGTH + 2;
+ entryIdx++;
+ }
+
+ return size;
+ }
+
private void appendName(final StringBuilder r) {
if (parent != null) {
parent.appendName(r);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java b/org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java
new file mode 100644
index 0000000..17a3965
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2008, 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.errors;
+
+import java.io.IOException;
+
+import org.spearce.jgit.dircache.DirCacheEntry;
+
+/**
+ * Indicates one or more paths in a DirCache have non-zero stages present.
+ */
+public class UnmergedPathException extends IOException {
+ private static final long serialVersionUID = 1L;
+
+ private final DirCacheEntry entry;
+
+ /**
+ * Create a new unmerged path exception.
+ *
+ * @param dce
+ * the first non-zero stage of the unmerged path.
+ */
+ public UnmergedPathException(final DirCacheEntry dce) {
+ super("Unmerged path: " + dce.getPathString());
+ entry = dce;
+ }
+
+ /** @return the first non-zero stage of the unmerged path */
+ public DirCacheEntry getDirCacheEntry() {
+ return entry;
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
index fe5f2f6..cf42f37 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/FileMode.java
@@ -191,6 +191,13 @@ public void copyTo(final OutputStream os) throws IOException {
}
/**
+ * @return the number of bytes written by {@link #copyTo(OutputStream)}.
+ */
+ public int copyToLength() {
+ return octalBytes.length;
+ }
+
+ /**
* Get the object type that should appear for this type of mode.
* <p>
* See the object type constants in {@link Constants}.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
index 6c2cd4f..ffa7837 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
@@ -155,10 +155,18 @@ public ObjectId writeTree(final Tree t) throws IOException {
o.write(0);
id.copyRawTo(o);
}
- return writeTree(o.toByteArray());
+ return writeCanonicalTree(o.toByteArray());
}
- private ObjectId writeTree(final byte[] b) throws IOException {
+ /**
+ * Write a canonical tree to the object database.
+ *
+ * @param b
+ * the canonical encoding of the tree object.
+ * @return SHA-1 of the tree
+ * @throws IOException
+ */
+ public ObjectId writeCanonicalTree(final byte[] b) throws IOException {
return writeTree(b.length, new ByteArrayInputStream(b));
}
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 8/8] Define a basic merge API, and a two-way tree merge strategy
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-8-git-send-email-spearce@spearce.org>
This basic merge implementation is sufficient to merge two commits in
memory and write the result out as a new commit, without having a work
tree on the local filesystem. It is therefore suitable for use within
a batch server process where human intervention is not available to
resolve conflicts.
This API should permit extending it with the working tree and a copy
of the work tree's DirCache, so edits in the tree can be merged in
parallel with edits from commits. But the functionality is not yet
implemented, so it is still a pie-in-the-sky concept.
The main strategy "simple-two-way-in-core" provides a basic 3 way
merge on the path level only. File contents are never patched by
this strategy, making it somewhat safe for automatic merges.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/merge/MergeStrategy.java | 134 +++++++++++++
.../src/org/spearce/jgit/merge/Merger.java | 207 ++++++++++++++++++++
.../org/spearce/jgit/merge/StrategyOneSided.java | 98 +++++++++
.../jgit/merge/StrategySimpleTwoWayInCore.java | 179 +++++++++++++++++
4 files changed, 618 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java b/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
new file mode 100644
index 0000000..d28dcc1
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2008, 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.merge;
+
+import java.util.HashMap;
+
+import org.spearce.jgit.lib.Repository;
+
+/**
+ * A method of combining two or more trees together to form an output tree.
+ * <p>
+ * Different strategies may employ different techniques for deciding which paths
+ * (and ObjectIds) to carry from the input trees into the final output tree.
+ */
+public abstract class MergeStrategy {
+ /** Simple strategy that sets the output tree to the first input tree. */
+ public static final MergeStrategy OURS = new StrategyOneSided("ours", 0);
+
+ /** Simple strategy that sets the output tree to the second input tree. */
+ public static final MergeStrategy THEIRS = new StrategyOneSided("theirs", 1);
+
+ /** Simple strategy to merge paths, without simultaneous edits. */
+ public static final MergeStrategy SIMPLE_TWO_WAY_IN_CORE = StrategySimpleTwoWayInCore.INSTANCE;
+
+ private static final HashMap<String, MergeStrategy> STRATEGIES = new HashMap<String, MergeStrategy>();
+
+ static {
+ register(OURS);
+ register(THEIRS);
+ register(SIMPLE_TWO_WAY_IN_CORE);
+ }
+
+ /**
+ * Register a merge strategy so it can later be obtained by name.
+ *
+ * @param imp
+ * the strategy to register.
+ * @throws IllegalArgumentException
+ * a strategy by the same name has already been registered.
+ */
+ public static void register(final MergeStrategy imp) {
+ register(imp.getName(), imp);
+ }
+
+ /**
+ * Register a merge strategy so it can later be obtained by name.
+ *
+ * @param name
+ * name the strategy can be looked up under.
+ * @param imp
+ * the strategy to register.
+ * @throws IllegalArgumentException
+ * a strategy by the same name has already been registered.
+ */
+ public static synchronized void register(final String name,
+ final MergeStrategy imp) {
+ if (STRATEGIES.containsKey(name))
+ throw new IllegalArgumentException("Merge strategy \"" + name
+ + "\" already exists as a default strategy");
+ STRATEGIES.put(name, imp);
+ }
+
+ /**
+ * Locate a strategy by name.
+ *
+ * @param name
+ * name of the strategy to locate.
+ * @return the strategy instance; null if no strategy matches the name.
+ */
+ public static synchronized MergeStrategy get(final String name) {
+ return STRATEGIES.get(name);
+ }
+
+ /**
+ * Get all registered strategies.
+ *
+ * @return the registered strategy instances. No inherit order is returned;
+ * the caller may modify (and/or sort) the returned array if
+ * necessary to obtain a reasonable ordering.
+ */
+ public static synchronized MergeStrategy[] get() {
+ final MergeStrategy[] r = new MergeStrategy[STRATEGIES.size()];
+ STRATEGIES.values().toArray(r);
+ return r;
+ }
+
+ /** @return default name of this strategy implementation. */
+ public abstract String getName();
+
+ /**
+ * Create a new merge instance.
+ *
+ * @param db
+ * repository database the merger will read from, and eventually
+ * write results back to.
+ * @return the new merge instance which implements this strategy.
+ */
+ public abstract Merger newMerger(Repository db);
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java b/org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java
new file mode 100644
index 0000000..fb8d7b2
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2008, 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.merge;
+
+import java.io.IOException;
+
+import org.spearce.jgit.errors.IncorrectObjectTypeException;
+import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Constants;
+import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.ObjectWriter;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.revwalk.RevCommit;
+import org.spearce.jgit.revwalk.RevObject;
+import org.spearce.jgit.revwalk.RevTree;
+import org.spearce.jgit.revwalk.RevWalk;
+import org.spearce.jgit.revwalk.filter.RevFilter;
+import org.spearce.jgit.treewalk.AbstractTreeIterator;
+import org.spearce.jgit.treewalk.CanonicalTreeParser;
+import org.spearce.jgit.treewalk.EmptyTreeIterator;
+
+/**
+ * Instance of a specific {@link MergeStrategy} for a single {@link Repository}.
+ */
+public abstract class Merger {
+ /** The repository this merger operates on. */
+ protected final Repository db;
+
+ /** A RevWalk for computing merge bases, or listing incoming commits. */
+ protected final RevWalk walk;
+
+ private ObjectWriter writer;
+
+ /** The original objects supplied in the merge; this can be any tree-ish. */
+ protected RevObject[] sourceObjects;
+
+ /** If {@link #sourceObjects}[i] is a commit, this is the commit. */
+ protected RevCommit[] sourceCommits;
+
+ /** The trees matching every entry in {@link #sourceObjects}. */
+ protected RevTree[] sourceTrees;
+
+ /**
+ * Create a new merge instance for a repository.
+ *
+ * @param local
+ * the repository this merger will read and write data on.
+ */
+ protected Merger(final Repository local) {
+ db = local;
+ walk = new RevWalk(db);
+ }
+
+ /**
+ * @return the repository this merger operates on.
+ */
+ public Repository getRepository() {
+ return db;
+ }
+
+ /**
+ * @return an object writer to create objects in {@link #getRepository()}.
+ */
+ public ObjectWriter getObjectWriter() {
+ if (writer == null)
+ writer = new ObjectWriter(getRepository());
+ return writer;
+ }
+
+ /**
+ * Merge together two or more tree-ish objects.
+ * <p>
+ * Any tree-ish may be supplied as inputs. Commits and/or tags pointing at
+ * trees or commits may be passed as input objects.
+ *
+ * @param tips
+ * source trees to be combined together. The merge base is not
+ * included in this set.
+ * @return true if the merge was completed without conflicts; false if the
+ * merge strategy cannot handle this merge or there were conflicts
+ * preventing it from automatically resolving all paths.
+ * @throws IncorrectObjectTypeException
+ * one of the input objects is not a commit, but the strategy
+ * requires it to be a commit.
+ * @throws IOException
+ * one or more sources could not be read, or outputs could not
+ * be written to the Repository.
+ */
+ public final boolean merge(final AnyObjectId[] tips) throws IOException {
+ sourceObjects = new RevObject[tips.length];
+ for (int i = 0; i < tips.length; i++)
+ sourceObjects[i] = walk.parseAny(tips[i]);
+
+ sourceCommits = new RevCommit[sourceObjects.length];
+ for (int i = 0; i < sourceObjects.length; i++) {
+ try {
+ sourceCommits[i] = walk.parseCommit(sourceObjects[i]);
+ } catch (IncorrectObjectTypeException err) {
+ sourceCommits[i] = null;
+ }
+ }
+
+ sourceTrees = new RevTree[sourceObjects.length];
+ for (int i = 0; i < sourceObjects.length; i++)
+ sourceTrees[i] = walk.parseTree(sourceObjects[i]);
+
+ return mergeImpl();
+ }
+
+ /**
+ * Create an iterator to walk the merge base of two commits.
+ *
+ * @param aIdx
+ * index of the first commit in {@link #sourceObjects}.
+ * @param bIdx
+ * index of the second commit in {@link #sourceObjects}.
+ * @return the new iterator
+ * @throws IncorrectObjectTypeException
+ * one of the input objects is not a commit.
+ * @throws IOException
+ * objects are missing or multiple merge bases were found.
+ */
+ protected AbstractTreeIterator mergeBase(final int aIdx, final int bIdx)
+ throws IOException {
+ if (sourceCommits[aIdx] == null)
+ throw new IncorrectObjectTypeException(sourceObjects[aIdx],
+ Constants.TYPE_COMMIT);
+ if (sourceCommits[bIdx] == null)
+ throw new IncorrectObjectTypeException(sourceObjects[bIdx],
+ Constants.TYPE_COMMIT);
+
+ walk.reset();
+ walk.setRevFilter(RevFilter.MERGE_BASE);
+ walk.markStart(sourceCommits[aIdx]);
+ walk.markStart(sourceCommits[bIdx]);
+ final RevCommit base = walk.next();
+ if (base == null)
+ return new EmptyTreeIterator();
+ final RevCommit base2 = walk.next();
+ if (base2 != null) {
+ throw new IOException("Multiple merge bases for:" + "\n "
+ + sourceCommits[aIdx].name() + "\n "
+ + sourceCommits[bIdx].name() + "found:" + "\n "
+ + base.name() + "\n " + base2.name());
+ }
+ return new CanonicalTreeParser(null, db, base.getTree());
+ }
+
+ /**
+ * Execute the merge.
+ * <p>
+ * This method is called from {@link #merge(AnyObjectId[])} after the
+ * {@link #sourceObjects}, {@link #sourceCommits} and {@link #sourceTrees}
+ * have been populated.
+ *
+ * @return true if the merge was completed without conflicts; false if the
+ * merge strategy cannot handle this merge or there were conflicts
+ * preventing it from automatically resolving all paths.
+ * @throws IncorrectObjectTypeException
+ * one of the input objects is not a commit, but the strategy
+ * requires it to be a commit.
+ * @throws IOException
+ * one or more sources could not be read, or outputs could not
+ * be written to the Repository.
+ */
+ protected abstract boolean mergeImpl() throws IOException;
+
+ /**
+ * @return resulting tree, if {@link #merge(AnyObjectId[])} returned true.
+ */
+ public abstract ObjectId getResultTreeId();
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java
new file mode 100644
index 0000000..0c3dcc2
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2008, 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.merge;
+
+import java.io.IOException;
+
+import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.Repository;
+
+/**
+ * Trivial merge strategy to make the resulting tree exactly match an input.
+ * <p>
+ * This strategy can be used to cauterize an entire side branch of history, by
+ * setting the output tree to one of the inputs, and ignoring any of the paths
+ * of the other inputs.
+ */
+public class StrategyOneSided extends MergeStrategy {
+ private final String strategyName;
+
+ private final int treeIndex;
+
+ /**
+ * Create a new merge strategy to select a specific input tree.
+ *
+ * @param name
+ * name of this strategy.
+ * @param index
+ * the position of the input tree to accept as the result.
+ */
+ protected StrategyOneSided(final String name, final int index) {
+ strategyName = name;
+ treeIndex = index;
+ }
+
+ @Override
+ public String getName() {
+ return strategyName;
+ }
+
+ @Override
+ public Merger newMerger(final Repository db) {
+ return new OneSide(db, treeIndex);
+ }
+
+ protected static class OneSide extends Merger {
+ private final int treeIndex;
+
+ protected OneSide(final Repository local, final int index) {
+ super(local);
+ treeIndex = index;
+ }
+
+ @Override
+ protected boolean mergeImpl() throws IOException {
+ return treeIndex < sourceTrees.length;
+ }
+
+ @Override
+ public ObjectId getResultTreeId() {
+ return sourceTrees[treeIndex];
+ }
+ }
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
new file mode 100644
index 0000000..893add9
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2008, 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.merge;
+
+import java.io.IOException;
+
+import org.spearce.jgit.dircache.DirCache;
+import org.spearce.jgit.dircache.DirCacheBuilder;
+import org.spearce.jgit.dircache.DirCacheEntry;
+import org.spearce.jgit.errors.UnmergedPathException;
+import org.spearce.jgit.lib.ObjectId;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.treewalk.AbstractTreeIterator;
+import org.spearce.jgit.treewalk.NameConflictTreeWalk;
+
+/**
+ * Merges two commits together in-memory, ignoring any working directory.
+ * <p>
+ * The strategy chooses a path from one of the two input trees if the path is
+ * unchanged in the other relative to their common merge base tree. This is a
+ * trivial 3-way merge (at the file path level only).
+ * <p>
+ * Modifications of the same file path (content and/or file mode) by both input
+ * trees will cause a merge conflict, as this strategy does not attempt to merge
+ * file contents.
+ */
+public class StrategySimpleTwoWayInCore extends MergeStrategy {
+ static final MergeStrategy INSTANCE = new StrategySimpleTwoWayInCore();
+
+ /** Create a new instance of the strategy. */
+ protected StrategySimpleTwoWayInCore() {
+ //
+ }
+
+ @Override
+ public String getName() {
+ return "simple-two-way-in-core";
+ }
+
+ @Override
+ public Merger newMerger(final Repository db) {
+ return new InCoreMerger(db);
+ }
+
+ private static class InCoreMerger extends Merger {
+ private static final int T_BASE = 0;
+
+ private static final int T_OURS = 1;
+
+ private static final int T_THEIRS = 2;
+
+ private final NameConflictTreeWalk tw;
+
+ private final DirCache cache;
+
+ private DirCacheBuilder builder;
+
+ private ObjectId resultTree;
+
+ InCoreMerger(final Repository local) {
+ super(local);
+ tw = new NameConflictTreeWalk(db);
+ cache = DirCache.newInCore();
+ }
+
+ @Override
+ protected boolean mergeImpl() throws IOException {
+ if (sourceTrees.length != 2)
+ return false;
+
+ tw.reset();
+ tw.addTree(mergeBase(0, 1));
+ tw.addTree(sourceTrees[0]);
+ tw.addTree(sourceTrees[1]);
+
+ boolean hasConflict = false;
+ builder = cache.builder();
+ while (tw.next()) {
+ final int modeO = tw.getRawMode(T_OURS);
+ final int modeT = tw.getRawMode(T_THEIRS);
+ if (modeO == modeT && tw.idEqual(T_OURS, T_THEIRS)) {
+ same();
+ continue;
+ }
+
+ final int modeB = tw.getRawMode(T_BASE);
+ if (modeB == modeO && tw.idEqual(T_BASE, T_OURS))
+ add(T_THEIRS, DirCacheEntry.STAGE_0);
+ else if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS))
+ add(T_OURS, DirCacheEntry.STAGE_0);
+ else {
+ conflict();
+ hasConflict = true;
+ }
+ }
+ builder.finish();
+ builder = null;
+
+ if (hasConflict)
+ return false;
+ try {
+ resultTree = cache.writeTree(getObjectWriter());
+ return true;
+ } catch (UnmergedPathException upe) {
+ resultTree = null;
+ return false;
+ }
+ }
+
+ private void same() throws IOException {
+ if (tw.isSubtree())
+ builder.addTree(tw.getRawPath(), db, tw.getObjectId(1));
+ else
+ add(T_OURS, DirCacheEntry.STAGE_0);
+ }
+
+ private void conflict() {
+ add(T_BASE, DirCacheEntry.STAGE_1);
+ add(T_OURS, DirCacheEntry.STAGE_2);
+ add(T_THEIRS, DirCacheEntry.STAGE_3);
+ }
+
+ private void add(final int tree, final int stage) {
+ final AbstractTreeIterator i = getTree(tree);
+ if (i != null) {
+ final DirCacheEntry e;
+
+ e = new DirCacheEntry(tw.getRawPath(), stage);
+ e.setObjectIdFromRaw(i.idBuffer(), i.idOffset());
+ e.setFileMode(tw.getFileMode(tree));
+ builder.add(e);
+ }
+ }
+
+ private AbstractTreeIterator getTree(final int tree) {
+ return tw.getTree(tree, AbstractTreeIterator.class);
+ }
+
+ @Override
+ public ObjectId getResultTreeId() {
+ return resultTree;
+ }
+ }
+}
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 5/8] Allow CanonicalTreeParsers to be created with a UTF-8 path prefix
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-5-git-send-email-spearce@spearce.org>
Creating an iterator with a path prefix permits a tree to be
"mounted" at a different part of a repository, permitting more
sophisticated merge strategies beyond just 1:1 path matching.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../jgit/treewalk/AbstractTreeIterator.java | 31 ++++++++++++++++++++
.../spearce/jgit/treewalk/CanonicalTreeParser.java | 28 ++++++++++++++++++
.../src/org/spearce/jgit/treewalk/TreeWalk.java | 2 +-
3 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
index 5226ab6..adfbb11 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
@@ -170,6 +170,37 @@ protected AbstractTreeIterator(final String prefix) {
}
/**
+ * Create a new iterator with no parent and a prefix.
+ * <p>
+ * The prefix path supplied is inserted in front of all paths generated by
+ * this iterator. It is intended to be used when an iterator is being
+ * created for a subsection of an overall repository and needs to be
+ * combined with other iterators that are created to run over the entire
+ * repository namespace.
+ *
+ * @param prefix
+ * position of this iterator in the repository tree. The value
+ * may be null or the empty array to indicate the prefix is the
+ * root of the repository. A trailing slash ('/') is
+ * automatically appended if the prefix does not end in '/'.
+ */
+ protected AbstractTreeIterator(final byte[] prefix) {
+ parent = null;
+
+ if (prefix != null && prefix.length > 0) {
+ pathLen = prefix.length;
+ path = new byte[Math.max(DEFAULT_PATH_SIZE, pathLen + 1)];
+ System.arraycopy(prefix, 0, path, 0, pathLen);
+ if (path[pathLen - 1] != '/')
+ path[pathLen++] = '/';
+ pathOffset = pathLen;
+ } else {
+ path = new byte[DEFAULT_PATH_SIZE];
+ pathOffset = 0;
+ }
+ }
+
+ /**
* Create an iterator for a subtree of an existing iterator.
*
* @param p
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
index dcc53cd..3dac6dd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
@@ -62,6 +62,34 @@ public CanonicalTreeParser() {
// Nothing necessary.
}
+ /**
+ * Create a new parser for a tree appearing in a subset of a repository.
+ *
+ * @param prefix
+ * position of this iterator in the repository tree. The value
+ * may be null or the empty array to indicate the prefix is the
+ * root of the repository. A trailing slash ('/') is
+ * automatically appended if the prefix does not end in '/'.
+ * @param repo
+ * repository to load the tree data from.
+ * @param treeId
+ * identity of the tree being parsed; used only in exception
+ * messages if data corruption is found.
+ * @throws MissingObjectException
+ * the object supplied is not available from the repository.
+ * @throws IncorrectObjectTypeException
+ * the object supplied as an argument is not actually a tree and
+ * cannot be parsed as though it were a tree.
+ * @throws IOException
+ * a loose object or pack file could not be read.
+ */
+ public CanonicalTreeParser(final byte[] prefix, final Repository repo,
+ final ObjectId treeId) throws IncorrectObjectTypeException,
+ IOException {
+ super(prefix);
+ reset(repo, treeId);
+ }
+
private CanonicalTreeParser(final CanonicalTreeParser p) {
super(p);
}
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 3af3d09..b1cbd2d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -307,7 +307,7 @@ public void reset(final ObjectId[] ids) throws MissingObjectException,
o = trees[i];
while (o.parent != null)
o = o.parent;
- if (o instanceof CanonicalTreeParser) {
+ if (o instanceof CanonicalTreeParser && o.pathOffset == 0) {
o.matches = null;
o.matchShift = 0;
((CanonicalTreeParser) o).reset(db, ids[i]);
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 4/8] Allow a DirCache to be created with no backing store file
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-4-git-send-email-spearce@spearce.org>
This permits using a DirCache as a temporary storage area in memory
only, with no chance of it being written out to disk.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/dircache/DirCache.java | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
index b3c57ad..c5a4f91 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
@@ -111,6 +111,17 @@ static int cmp(final byte[] aPath, final int aLen, final byte[] bPath,
}
/**
+ * Create a new empty index which is never stored on disk.
+ *
+ * @return an empty cache which has no backing store file. The cache may not
+ * be read or written, but it may be queried and updated (in
+ * memory).
+ */
+ public static DirCache newInCore() {
+ return new DirCache(null);
+ }
+
+ /**
* Create a new in-core index representation and read an index from disk.
* <p>
* The new index will be read before it is returned to the caller. Read
@@ -297,6 +308,8 @@ void replace(final DirCacheEntry[] e, final int cnt) {
* library does not support.
*/
public void read() throws IOException, CorruptObjectException {
+ if (liveFile == null)
+ throw new IOException("DirCache does not have a backing file");
if (!liveFile.exists())
clear();
else if (liveFile.lastModified() != lastModified) {
@@ -407,6 +420,8 @@ private static boolean is_DIRC(final byte[] hdr) {
* hold the lock.
*/
public boolean lock() throws IOException {
+ if (liveFile == null)
+ throw new IOException("DirCache does not have a backing file");
final LockFile tmp = new LockFile(liveFile);
if (tmp.lock()) {
tmp.setNeedStatInformation(true);
@@ -515,6 +530,8 @@ public boolean commit() {
}
private void requireLocked(final LockFile tmp) {
+ if (liveFile == null)
+ throw new IllegalStateException("DirCache is not locked");
if (tmp == null)
throw new IllegalStateException("DirCache "
+ liveFile.getAbsolutePath() + " not locked.");
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 7/8] Allow DirCacheEntry instances to be created with stage > 0
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-7-git-send-email-spearce@spearce.org>
As the stage is part of the sorting criteria for DirCacheEntry
objects we don't allow the stage to be modified on the fly in
an existing instance. Instead the stage must be set by reading
it from the on-disk format or by creating a new entry with the
proper path and stage components.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../org/spearce/jgit/dircache/DirCacheEntry.java | 52 +++++++++++++++++---
1 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
index 355cd3e..9304501 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
@@ -60,6 +60,18 @@
public class DirCacheEntry {
private static final byte[] nullpad = new byte[8];
+ /** The standard (fully merged) stage for an entry. */
+ public static final int STAGE_0 = 0;
+
+ /** The base tree revision for an entry. */
+ public static final int STAGE_1 = 1;
+
+ /** The first tree revision (usually called "ours"). */
+ public static final int STAGE_2 = 2;
+
+ /** The second tree revision (usually called "theirs"). */
+ public static final int STAGE_3 = 3;
+
// private static final int P_CTIME = 0;
// private static final int P_CTIME_NSEC = 4;
@@ -141,8 +153,8 @@ DirCacheEntry(final byte[] sharedInfo, final int infoAt,
}
/**
- * Create an empty entry.
- *
+ * Create an empty entry at stage 0.
+ *
* @param newPath
* name of the cache entry.
*/
@@ -151,20 +163,46 @@ public DirCacheEntry(final String newPath) {
}
/**
- * Create an empty entry.
- *
+ * Create an empty entry at the specified stage.
+ *
+ * @param newPath
+ * name of the cache entry.
+ * @param stage
+ * the stage index of the new entry.
+ */
+ public DirCacheEntry(final String newPath, final int stage) {
+ this(Constants.encode(newPath), stage);
+ }
+
+ /**
+ * Create an empty entry at stage 0.
+ *
* @param newPath
* name of the cache entry, in the standard encoding.
*/
public DirCacheEntry(final byte[] newPath) {
+ this(newPath, STAGE_0);
+ }
+
+ /**
+ * Create an empty entry at the specified stage.
+ *
+ * @param newPath
+ * name of the cache entry, in the standard encoding.
+ * @param stage
+ * the stage index of the new entry.
+ */
+ public DirCacheEntry(final byte[] newPath, final int stage) {
info = new byte[INFO_LEN];
infoOffset = 0;
-
path = newPath;
+
+ int flags = ((stage & 0x3) << 12);
if (path.length < NAME_MASK)
- NB.encodeInt16(info, infoOffset + P_FLAGS, path.length);
+ flags |= path.length;
else
- NB.encodeInt16(info, infoOffset + P_FLAGS, NAME_MASK);
+ flags |= NAME_MASK;
+ NB.encodeInt16(info, infoOffset + P_FLAGS, flags);
}
void write(final OutputStream os) throws IOException {
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 6/8] Recursively load an entire tree into a DirCacheBuilder
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-6-git-send-email-spearce@spearce.org>
This implements the DirCache portion of "git read-tree", where a
tree can be recursively read into a DirCache instance without an
impact on the working directory.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../org/spearce/jgit/dircache/DirCacheBuilder.java | 58 ++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuilder.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuilder.java
index 3a37054..88bda4d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuilder.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheBuilder.java
@@ -37,8 +37,15 @@
package org.spearce.jgit.dircache;
+import java.io.IOException;
import java.util.Arrays;
+import org.spearce.jgit.lib.AnyObjectId;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.treewalk.AbstractTreeIterator;
+import org.spearce.jgit.treewalk.CanonicalTreeParser;
+import org.spearce.jgit.treewalk.TreeWalk;
+
/**
* Updates a {@link DirCache} by adding individual {@link DirCacheEntry}s.
* <p>
@@ -112,6 +119,57 @@ public void keep(final int pos, int cnt) {
fastKeep(pos, cnt);
}
+ /**
+ * Recursively add an entire tree into this builder.
+ * <p>
+ * If pathPrefix is "a/b" and the tree contains file "c" then the resulting
+ * DirCacheEntry will have the path "a/b/c".
+ * <p>
+ * All entries are inserted at stage 0, therefore assuming that the
+ * application will not insert any other paths with the same pathPrefix.
+ *
+ * @param pathPrefix
+ * UTF-8 encoded prefix to mount the tree's entries at. If the
+ * path does not end with '/' one will be automatically inserted
+ * as necessary.
+ * @param db
+ * repository the tree(s) will be read from during recursive
+ * traversal. This must be the same repository that the resulting
+ * DirCache would be written out to (or used in) otherwise the
+ * caller is simply asking for deferred MissingObjectExceptions.
+ * @param tree
+ * the tree to recursively add. This tree's contents will appear
+ * under <code>pathPrefix</code>. The ObjectId must be that of a
+ * tree; the caller is responsible for dereferencing a tag or
+ * commit (if necessary).
+ * @throws IOException
+ * a tree cannot be read to iterate through its entries.
+ */
+ public void addTree(final byte[] pathPrefix, final Repository db,
+ final AnyObjectId tree) throws IOException {
+ final TreeWalk tw = new TreeWalk(db);
+ tw.reset();
+ tw.addTree(new CanonicalTreeParser(pathPrefix, db, tree.toObjectId()));
+ tw.setRecursive(true);
+ if (tw.next()) {
+ final DirCacheEntry newEntry = toEntry(tw);
+ beforeAdd(newEntry);
+ fastAdd(newEntry);
+ while (tw.next())
+ fastAdd(toEntry(tw));
+ }
+ }
+
+ private DirCacheEntry toEntry(final TreeWalk tw) {
+ final DirCacheEntry e = new DirCacheEntry(tw.getRawPath());
+ final AbstractTreeIterator i;
+
+ i = tw.getTree(0, AbstractTreeIterator.class);
+ e.setFileMode(tw.getFileMode(0));
+ e.setObjectIdFromRaw(i.idBuffer(), i.idOffset());
+ return e;
+ }
+
public void finish() {
if (!sorted)
resort();
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 2/8] Expose DirCacheEntry.getFileMode as a utility function
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-2-git-send-email-spearce@spearce.org>
Its easier to get the FileMode object in some applications than to
get the raw mode and convert it to the FileMode in the application
code. Its slower, but sometimes you just have to have the proper
FileMode singleton.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../org/spearce/jgit/dircache/DirCacheEntry.java | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
index cc683d7..355cd3e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCacheEntry.java
@@ -295,6 +295,15 @@ public int getRawMode() {
}
/**
+ * Obtain the {@link FileMode} for this entry.
+ *
+ * @return the file mode singleton for this entry.
+ */
+ public FileMode getFileMode() {
+ return FileMode.fromBits(getRawMode());
+ }
+
+ /**
* Set the file mode for this entry.
*
* @param mode
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 1/8] Expose the raw path for the current entry of a TreeWalk
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
In-Reply-To: <1223932217-4771-1-git-send-email-spearce@spearce.org>
Copying the path byte array (keeping it encoded in UTF-8) is quicker
than converting to String and then back again to UTF-8 when creating
a DirCacheEntry for the current position in a TreeWalk.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/treewalk/TreeWalk.java | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
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 26544b5..3af3d09 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -582,6 +582,21 @@ public String getPathString() {
}
/**
+ * Get the current entry's complete path as a UTF-8 byte array.
+ *
+ * @return complete path of the current entry, from the root of the
+ * repository. If the current entry is in a subtree there will be at
+ * least one '/' in the returned string.
+ */
+ public byte[] getRawPath() {
+ final AbstractTreeIterator t = currentHead;
+ final int n = t.pathLen;
+ final byte[] r = new byte[n];
+ System.arraycopy(t.path, 0, r, 0, n);
+ return r;
+ }
+
+ /**
* Test if the supplied path matches the current entry's path.
* <p>
* This method tests that the supplied path is exactly equal to the current
--
1.6.0.2.706.g340fc
^ permalink raw reply related
* [JGIT PATCH 0/8] Crude merge support
From: Shawn O. Pearce @ 2008-10-13 21:10 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
This series add some basic merge support to JGit. Its more of a
"merge toolkit" than a merge implementation. I have about 200
lines of code in another codebase that calls this stuff in JGit to
actually make a merge. Eventually I hope to migrate a lot of that
code back into JGit, but for now its not here as I'm not entirely
sure what API merge applications need, and how much of that code
is application specific and how much of it should be core to JGit.
FWIW, that code will be open-sourced soon-ish too. But I really
think a lot of it belongs in JGit, so it will probably migrate over.
No unit tests yet. Yea, I know. I've had this done and in use
for about 3 or 4 weeks now. I just couldn't find the time to get
the Javadoc cleaned up to post to the list for comments, let alone
write unit tests.
But it does add the missing "write-tree" support to DirCache. :)
Shawn O. Pearce (8):
Expose the raw path for the current entry of a TreeWalk
Expose DirCacheEntry.getFileMode as a utility function
Add writeTree support to DirCache
Allow a DirCache to be created with no backing store file
Allow CanonicalTreeParsers to be created with a UTF-8 path prefix
Recursively load an entire tree into a DirCacheBuilder
Allow DirCacheEntry instances to be created with stage > 0
Define a basic merge API, and a two-way tree merge strategy
.../src/org/spearce/jgit/dircache/DirCache.java | 37 ++++
.../org/spearce/jgit/dircache/DirCacheBuilder.java | 58 ++++++
.../org/spearce/jgit/dircache/DirCacheEntry.java | 61 +++++-
.../org/spearce/jgit/dircache/DirCacheTree.java | 115 +++++++++++
.../spearce/jgit/errors/UnmergedPathException.java | 67 +++++++
.../src/org/spearce/jgit/lib/FileMode.java | 7 +
.../src/org/spearce/jgit/lib/ObjectWriter.java | 12 +-
.../src/org/spearce/jgit/merge/MergeStrategy.java | 134 +++++++++++++
.../src/org/spearce/jgit/merge/Merger.java | 207 ++++++++++++++++++++
.../org/spearce/jgit/merge/StrategyOneSided.java | 98 +++++++++
.../jgit/merge/StrategySimpleTwoWayInCore.java | 179 +++++++++++++++++
.../jgit/treewalk/AbstractTreeIterator.java | 31 +++
.../spearce/jgit/treewalk/CanonicalTreeParser.java | 28 +++
.../src/org/spearce/jgit/treewalk/TreeWalk.java | 17 ++-
14 files changed, 1041 insertions(+), 10 deletions(-)
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/errors/UnmergedPathException.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/MergeStrategy.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/Merger.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategyOneSided.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
^ permalink raw reply
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Shawn O. Pearce @ 2008-10-13 21:06 UTC (permalink / raw)
To: Tuncer Ayaz; +Cc: git
In-Reply-To: <4ac8254d0810131403i4c8c57d6r71531e34321e9b50@mail.gmail.com>
Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:
> Hi Shawn and list,
>
> I've updated the patch to current Junio master.
>
> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
Looks good to me.
--
Shawn.
^ permalink raw reply
* Re: [PATCH] Add testcase to ensure merging an early part of a branch is done properly
From: Shawn O. Pearce @ 2008-10-13 21:03 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Junio C Hamano, git
In-Reply-To: <1223931265-8862-1-git-send-email-vmiklos@frugalware.org>
Miklos Vajna <vmiklos@frugalware.org> wrote:
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>
> [ Adding Shawn to CC as the interim maintainer. ]
In case you missed it, Junio has the pumpkin now. (He's picked up
my topics, merged my tree, and has freed me from the time sink that
is known as maintainership.)
--
Shawn.
^ permalink raw reply
* Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose
From: Tuncer Ayaz @ 2008-10-13 21:03 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
In-Reply-To: <4ac8254d0810121436x6285d17ew631f04e768a6fb62@mail.gmail.com>
Hi Shawn and list,
I've updated the patch to current Junio master.
Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>
---
Documentation/merge-options.txt | 8 ++++++++
builtin-fetch.c | 5 +++--
builtin-merge.c | 22 +++++++++++++++-------
git-pull.sh | 10 ++++++++--
4 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 007909a..427cdef 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,3 +1,11 @@
+-q::
+--quiet::
+ Operate quietly.
+
+-v::
+--verbose::
+ Be verbose.
+
--stat::
Show a diffstat at the end of the merge. The diffstat is also
controlled by the configuration option merge.stat.
diff --git a/builtin-fetch.c b/builtin-fetch.c
index ee93d3a..287ce33 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url,
const char *remote_name,
SUMMARY_WIDTH, *kind ? kind : "branch",
REFCOL_WIDTH, *what ? what : "HEAD");
if (*note) {
- if (!shown_url) {
+ if ((verbose || !quiet) && !shown_url) {
fprintf(stderr, "From %.*s\n",
url_len, url);
shown_url = 1;
}
- fprintf(stderr, " %s\n", note);
+ if (verbose || !quiet)
+ fprintf(stderr, " %s\n", note);
}
}
fclose(fp);
diff --git a/builtin-merge.c b/builtin-merge.c
index 5e2b7f1..4f90501 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -44,6 +44,7 @@ static const char * const builtin_merge_usage[] = {
static int show_diffstat = 1, option_log, squash;
static int option_commit = 1, allow_fast_forward = 1;
static int allow_trivial = 1, have_message;
+static int quiet, verbose;
static struct strbuf merge_msg;
static struct commit_list *remoteheads;
static unsigned char head[20], stash[20];
@@ -152,6 +153,8 @@ static int option_parse_n(const struct option *opt,
}
static struct option builtin_merge_options[] = {
+ OPT__QUIET(&quiet),
+ OPT__VERBOSE(&verbose),
{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,
"do not show a diffstat at the end of the merge",
PARSE_OPT_NOARG, option_parse_n },
@@ -249,7 +252,8 @@ static void restore_state(void)
/* This is called when no merge was necessary. */
static void finish_up_to_date(const char *msg)
{
- printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+ if (verbose || !quiet)
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
drop_save();
}
@@ -330,14 +334,15 @@ static void finish(const unsigned char
*new_head, const char *msg)
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
else {
- printf("%s\n", msg);
+ if (verbose || !quiet)
+ printf("%s\n", msg);
strbuf_addf(&reflog_message, "%s: %s",
getenv("GIT_REFLOG_ACTION"), msg);
}
if (squash) {
squash_message();
} else {
- if (!merge_msg.len)
+ if ((verbose || !quiet) && !merge_msg.len)
printf("No merge message -- not updating HEAD\n");
else {
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
@@ -871,6 +876,8 @@ int cmd_merge(int argc, const char **argv, const
char *prefix)
argc = parse_options(argc, argv, builtin_merge_options,
builtin_merge_usage, 0);
+ if (!verbose && quiet)
+ show_diffstat = 0;
if (squash) {
if (!allow_fast_forward)
@@ -1012,10 +1019,11 @@ int cmd_merge(int argc, const char **argv,
const char *prefix)
strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
- printf("Updating %s..%s\n",
- hex,
- find_unique_abbrev(remoteheads->item->object.sha1,
- DEFAULT_ABBREV));
+ if (verbose || !quiet)
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));
strbuf_addstr(&msg, "Fast forward");
if (have_message)
strbuf_addstr(&msg,
diff --git a/git-pull.sh b/git-pull.sh
index 75c3610..8e25d44 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,6 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
+quiet= verbose=
strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
@@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
+ -q|--quiet)
+ quiet=-q ;;
+ -v|--verbose)
+ verbose=-v ;;
-n|--no-stat|--no-summary)
no_stat=-n ;;
--stat|--summary)
@@ -121,7 +126,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git fetch --update-head-ok "$@" || exit 1
+git fetch $verbose $quiet --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg
<"$GIT_DIR/FETCH_HEAD") || exit
test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
-exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
+exec git-merge $quiet $verbose $no_stat $no_commit \
+ $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
--
1.6.0.2.GIT
^ permalink raw reply related
* [PATCH] Add testcase to ensure merging an early part of a branch is done properly
From: Miklos Vajna @ 2008-10-13 20:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git
In-Reply-To: <1217438608-28855-1-git-send-email-vmiklos@frugalware.org>
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
[ Adding Shawn to CC as the interim maintainer. ]
On Wed, Jul 30, 2008 at 07:23:28PM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> Uh-oh. Here is a testcase that fails with master, but passes with your
> patch.
I remember you had a note about it's a bad habit to write a new test for
every bug, so here is an updated version that just improves
t7600-merge.sh and does not adds a new one.
t/t7600-merge.sh | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 7313ac2..a4443a7 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -520,4 +520,30 @@ test_expect_success 'refresh the index before merging' '
test_debug 'gitk --all'
+cat >expected <<EOF
+Merge branch 'c5' (early part)
+EOF
+
+test_expect_success 'merge early part of c2' '
+ git reset --hard c3 &&
+ echo c4 > c4.c &&
+ git add c4.c &&
+ git commit -m c4 &&
+ git tag c4 &&
+ echo c5 > c5.c &&
+ git add c5.c &&
+ git commit -m c5 &&
+ git tag c5 &&
+ git reset --hard c3 &&
+ echo c6 > c6.c &&
+ git add c6.c &&
+ git commit -m c6 &&
+ git tag c6 &&
+ git merge c5~1 &&
+ git show -s --pretty=format:%s HEAD > actual &&
+ test_cmp actual expected
+'
+
+test_debug 'gitk --all'
+
test_done
--
1.6.0.2
^ 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