From 1cd12926cedb340d176db607e087495381032ce2 Mon Sep 17 00:00:00 2001 From: Charles Bailey Date: Mon, 25 May 2009 01:21:13 +0100 Subject: [PATCH 1/7] t6023: merge-file fails to output anything for a degenerate merge In the case that merge-file is passed three files with identical contents it wipes the contents of the output file instead of leaving it unchanged. Althought merge-file is porcelain and this will never happen in normal usage, it is still wrong. Signed-off-by: Charles Bailey Signed-off-by: Junio C Hamano --- t/t6023-merge-file.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index f674c48cab..19556350b5 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -54,6 +54,12 @@ deduxit me super semitas jusitiae, EOF printf "propter nomen suum." >> new4.txt +test_expect_failure 'merge with no changes' ' + cp orig.txt test.txt && + git merge-file test.txt orig.txt orig.txt && + test_cmp test.txt orig.txt +' + cp new1.txt test.txt test_expect_success "merge without conflict" \ "git merge-file test.txt orig.txt new2.txt" From 5719db91ce5915ee07c50f1afdc94fe34e91529f Mon Sep 17 00:00:00 2001 From: Charles Bailey Date: Mon, 25 May 2009 01:21:14 +0100 Subject: [PATCH 2/7] Change xdl_merge to generate output even for null merges xdl_merge used to have a check to ensure that there was at least some change in one or other side being merged but this suppressed output for the degenerate case when base, local and remote contents were all identical. Removing this check enables correct output in the degenerate case and xdl_free_script handles freeing NULL scripts so there is no need to have the check for these calls. Signed-off-by: Charles Bailey Signed-off-by: Junio C Hamano --- t/t6023-merge-file.sh | 2 +- xdiff/xmerge.c | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 19556350b5..796f2128da 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -54,7 +54,7 @@ deduxit me super semitas jusitiae, EOF printf "propter nomen suum." >> new4.txt -test_expect_failure 'merge with no changes' ' +test_expect_success 'merge with no changes' ' cp orig.txt test.txt && git merge-file test.txt orig.txt orig.txt && test_cmp test.txt orig.txt diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c index 82b3573e7a..1ef1d358ce 100644 --- a/xdiff/xmerge.c +++ b/xdiff/xmerge.c @@ -470,23 +470,22 @@ int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1, return -1; } status = 0; - if (xscr1 || xscr2) { - if (!xscr1) { - result->ptr = xdl_malloc(mf2->size); - memcpy(result->ptr, mf2->ptr, mf2->size); - result->size = mf2->size; - } else if (!xscr2) { - result->ptr = xdl_malloc(mf1->size); - memcpy(result->ptr, mf1->ptr, mf1->size); - result->size = mf1->size; - } else { - status = xdl_do_merge(&xe1, xscr1, name1, - &xe2, xscr2, name2, - level, xpp, result); - } - xdl_free_script(xscr1); - xdl_free_script(xscr2); + if (!xscr1) { + result->ptr = xdl_malloc(mf2->size); + memcpy(result->ptr, mf2->ptr, mf2->size); + result->size = mf2->size; + } else if (!xscr2) { + result->ptr = xdl_malloc(mf1->size); + memcpy(result->ptr, mf1->ptr, mf1->size); + result->size = mf1->size; + } else { + status = xdl_do_merge(&xe1, xscr1, name1, + &xe2, xscr2, name2, + level, xpp, result); } + xdl_free_script(xscr1); + xdl_free_script(xscr2); + xdl_free_env(&xe1); xdl_free_env(&xe2); From 7b8988e113b44b9a2d806dde6161c133750c14e5 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 28 May 2009 11:40:15 +0200 Subject: [PATCH 3/7] Documentation: teach stash/pop workflow instead of stash/apply Recent discussion on the list showed some comments in favour of a stash/pop workflow: http://marc.info/?l=git&m=124234911423358&w=2 http://marc.info/?l=git&m=124235348327711&w=2 Change the stash documentation and examples to document pop in its own right (and apply in terms of pop), and use stash/pop in the examples. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- Documentation/git-stash.txt | 30 ++++++++++++++++-------------- Documentation/user-manual.txt | 4 ++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 051f94d26f..1cc24cc47e 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -75,14 +75,22 @@ show []:: it will accept any format known to 'git-diff' (e.g., `git stash show -p stash@\{1}` to view the second most recent stash in patch form). -apply [--index] []:: +pop []:: - Restore the changes recorded in the stash on top of the current - working tree state. When no `` is given, applies the latest - one. The working directory must match the index. + Remove a single stashed state from the stash list and apply it + on top of the current working tree state, i.e., do the inverse + operation of `git stash save`. The working directory must + match the index. + -This operation can fail with conflicts; you need to resolve them -by hand in the working tree. +Applying the state can fail with conflicts; in this case, it is not +removed from the stash list. You need to resolve the conflicts by hand +and call `git stash drop` manually afterwards. ++ +When no `` is given, `stash@\{0}` is assumed. See also `apply`. + +apply [--index] []:: + + Like `pop`, but do not remove the state from the stash list. + If the `--index` option is used, then tries to reinstate not only the working tree's changes, but also the index's ones. However, this can fail, when you @@ -112,12 +120,6 @@ drop []:: Remove a single stashed state from the stash list. When no `` is given, it removes the latest one. i.e. `stash@\{0}` -pop []:: - - Remove a single stashed state from the stash list and apply on top - of the current working tree state. When no `` is given, - `stash@\{0}` is assumed. See also `apply`. - create:: Create a stash (which is a regular commit object) and return its @@ -163,7 +165,7 @@ $ git pull file foobar not up to date, cannot merge. $ git stash $ git pull -$ git stash apply +$ git stash pop ---------------------------------------------------------------- Interrupted workflow:: @@ -192,7 +194,7 @@ You can use 'git-stash' to simplify the above, like this: $ git stash $ edit emergency fix $ git commit -a -m "Fix in a hurry" -$ git stash apply +$ git stash pop # ... continue hacking ... ---------------------------------------------------------------- diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index dbbeb7e7c7..0b88a51d0b 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1520,10 +1520,10 @@ $ git commit -a -m "blorpl: typofix" ------------------------------------------------ After that, you can go back to what you were working on with -`git stash apply`: +`git stash pop`: ------------------------------------------------ -$ git stash apply +$ git stash pop ------------------------------------------------ From 1f5b9cc40e80a8a7902236a26844be138887b1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Mon, 1 Jun 2009 23:53:05 +0200 Subject: [PATCH 4/7] grep: fix colouring of matches with zero length If a zero-length match is encountered, break out of loop and show the rest of the line uncoloured. Otherwise we'd be looping forever, trying to make progress by advancing the pointer by zero characters. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- grep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grep.c b/grep.c index cc6d5b04c1..7bf4a60ac7 100644 --- a/grep.c +++ b/grep.c @@ -500,6 +500,8 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, *eol = '\0'; while (next_match(opt, bol, eol, ctx, &match, eflags)) { + if (match.rm_so == match.rm_eo) + break; printf("%.*s%s%.*s%s", (int)match.rm_so, bol, opt->color_match, From 40bad52d7d559177e373127f50c7bb3a19d56d85 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 2 Jun 2009 07:57:39 -0700 Subject: [PATCH 5/7] Update draft release notes for 1.6.3.2 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.6.3.2.txt | 40 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Documentation/RelNotes-1.6.3.2.txt b/Documentation/RelNotes-1.6.3.2.txt index a3fceebb11..0b48d1a1df 100644 --- a/Documentation/RelNotes-1.6.3.2.txt +++ b/Documentation/RelNotes-1.6.3.2.txt @@ -8,44 +8,56 @@ Fixes since v1.6.3.1 casting the (char *) pointer to (int *); GCC 4.4 did not like this, and aborted compilation. - * http-push had a small use-after-free bug. - - * command completion code in bash did not reliably detect that we are - in a bare repository. - - * "git for-each-ref" had a segfaulting bug when dealing with a tag object - created by an ancient git. - * Some unlink(2) failures went undiagnosed. * The "recursive" merge strategy misbehaved when faced rename/delete conflicts while coming up with an intermediate merge base. + * The low-level merge algorithm did not handle a degenerate case of + merging a file with itself using itself as the common ancestor + gracefully. It should produce the file itself, but instead + produced an empty result. + * GIT_TRACE mechanism segfaulted when tracing a shell-quoted aliases. + * OpenBSD also uses st_ctimspec in "struct stat", instead of "st_ctim". + + * With NO_CROSS_DIRECTORY_HARDLINKS, "make install" can be told not to + create hardlinks between $(gitexecdir)/git-$builtin_commands and + $(bindir)/git. + + * command completion code in bash did not reliably detect that we are + in a bare repository. + * "git add ." in an empty directory complained that pathspec "." did not match anything, which may be technically correct, but not useful. We silently make it a no-op now. + * "git add -p" (and "patch" action in "git add -i") was broken when + the first hunk that adds a line at the top was split into two and + both halves are marked to be used. + + * "git for-each-ref" had a segfaulting bug when dealing with a tag object + created by an ancient git. + * "git format-patch -k" still added patch numbers if format.numbered configuration was set. - * OpenBSD also uses st_ctimspec in "struct stat", instead of "st_ctim". + * "git grep --color ''" did not terminate. - * With NO_CROSS_DIRECTORY_HARDLINKS, "make install" can be told not to - create hardlinks between $(gitexecdir)/git-$builtin_commands and - $(bindir)/git. + * http-push had a small use-after-free bug. * "git push" was converting OFS_DELTA pack representation into less efficient REF_DELTA representation unconditionally upon transfer, making the transferred data unnecessarily larger. + * "git remote show origin" segfaulted when origin was still empty. + Many other general usability updates around help text, diagnostic messages and documentation are included as well. --- exec >/var/tmp/1 -O=v1.6.3.1-51-g2a1feb9 +O=v1.6.3.1-68-g456cb4c echo O=$(git describe maint) git shortlog --no-merges $O..maint - From 8dc3a47c3edcee923225000e93f8052c50e5a004 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Tue, 2 Jun 2009 23:34:27 +0200 Subject: [PATCH 6/7] add -i: do not dump patch during application Remove a debugging print that snuck in at 7a26e65 (Revert "git-add--interactive: remove hunk coalescing", 2009-05-16). Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- git-add--interactive.perl | 1 - 1 file changed, 1 deletion(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index a06172c69f..df9f231635 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1317,7 +1317,6 @@ sub patch_update_file { open $fh, '| git apply --cached --recount'; for (@{$head->{TEXT}}, @result) { print $fh $_; - print STDERR $_; } if (!close $fh) { for (@{$head->{TEXT}}, @result) { From a9b2d42486ee0b461220bf3895114926d9ddf9be Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 3 Jun 2009 00:43:22 -0700 Subject: [PATCH 7/7] blame: correctly handle a path that used to be a directory When trying to see if the same path exists in the parent, we ran "diff-tree" with pathspec set to the path we are interested in with the parent, and expect either to have exactly one resulting filepair (either "changed from the parent", "created when there was none") or nothing (when there is no change from the parent). If the path used to be a directory, however, we will also see unbounded number of entries that talk about the files that used to exist underneath the directory in question. Correctly pick only the entry that describes the path we are interested in in such a case (namely, the creation of the path as a regular file). Noticed by Ben Willard. Signed-off-by: Junio C Hamano --- builtin-blame.c | 26 ++++++++++++++++++-------- t/t8003-blame.sh | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/builtin-blame.c b/builtin-blame.c index cf74a92614..0afdb16cb0 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -362,18 +362,28 @@ static struct origin *find_origin(struct scoreboard *sb, "", &diff_opts); diffcore_std(&diff_opts); - /* It is either one entry that says "modified", or "created", - * or nothing. - */ if (!diff_queued_diff.nr) { /* The path is the same as parent */ porigin = get_origin(sb, parent, origin->path); hashcpy(porigin->blob_sha1, origin->blob_sha1); - } - else if (diff_queued_diff.nr != 1) - die("internal error in blame::find_origin"); - else { - struct diff_filepair *p = diff_queued_diff.queue[0]; + } else { + /* + * Since origin->path is a pathspec, if the parent + * commit had it as a directory, we will see a whole + * bunch of deletion of files in the directory that we + * do not care about. + */ + int i; + struct diff_filepair *p = NULL; + for (i = 0; i < diff_queued_diff.nr; i++) { + const char *name; + p = diff_queued_diff.queue[i]; + name = p->one->path ? p->one->path : p->two->path; + if (!strcmp(name, origin->path)) + break; + } + if (!p) + die("internal error in blame::find_origin"); switch (p->status) { default: die("internal error in blame::find_origin (%c)", diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh index 966bb0a61a..13c25f1d52 100755 --- a/t/t8003-blame.sh +++ b/t/t8003-blame.sh @@ -129,4 +129,19 @@ test_expect_success 'blame wholesale copy and more' ' ' +test_expect_success 'blame path that used to be a directory' ' + mkdir path && + echo A A A A A >path/file && + echo B B B B B >path/elif && + git add path && + test_tick && + git commit -m "path was a directory" && + rm -fr path && + echo A A A A A >path && + git add path && + test_tick && + git commit -m "path is a regular file" && + git blame HEAD^.. -- path +' + test_done