From 0b7c5a5450951dfed9017ff4dec5682219228639 Mon Sep 17 00:00:00 2001 From: Liu Yubao Date: Fri, 15 Sep 2006 13:46:07 -0700 Subject: Fix duplicate xmalloc in builtin-add [jc: patch came without sign-off but it was too obvious and trivial.] Signed-off-by: Junio C Hamano diff --git a/builtin-add.c b/builtin-add.c index 0cb9c81..febb75e 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -70,7 +70,6 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) base = ""; if (baselen) { char *common = xmalloc(baselen + 1); - common = xmalloc(baselen + 1); memcpy(common, *pathspec, baselen); common[baselen] = 0; path = base = common; -- cgit v0.10.2-6-g49f6 From f2b5792564754d5ba812a0d3eaec2440dfc0652a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Sep 2006 23:19:02 -0700 Subject: Fix git-am safety checks An earlier commit cbd64af added a check that prevents "git-am" to run without its standard input connected to a terminal while resuming operation. This was to catch a user error to try feeding a new patch from its standard input while recovery. The assumption of the check was that it is an indication that a new patch is being fed if the standard input is not connected to a terminal. It is however not quite correct (the standard input can be /dev/null if the user knows the operation does not need any input, for example). This broke t3403 when the test was run with its standard input connected to /dev/null. When git-am is given an explicit command such as --skip, there is no reason to insist that the standard input is a terminal; we are not going to read a new patch anyway. Credit goes to Gerrit Pape for noticing and reporting the problem with t3403-rebase-skip test. Signed-off-by: Junio C Hamano diff --git a/git-am.sh b/git-am.sh index d0af786..afe322b 100755 --- a/git-am.sh +++ b/git-am.sh @@ -166,10 +166,25 @@ fi if test -d "$dotest" then - if test ",$#," != ",0," || ! tty -s - then - die "previous dotest directory $dotest still exists but mbox given." - fi + case "$#,$skip$resolved" in + 0,*t*) + # Explicit resume command and we do not have file, so + # we are happy. + : ;; + 0,) + # No file input but without resume parameters; catch + # user error to feed us a patch from standard input + # when there is already .dotest. This is somewhat + # unreliable -- stdin could be /dev/null for example + # and the caller did not intend to feed us a patch but + # wanted to continue unattended. + tty -s + ;; + *) + false + ;; + esac || + die "previous dotest directory $dotest still exists but mbox given." resume=yes else # Make sure we are not given --skip nor --resolved -- cgit v0.10.2-6-g49f6 From 82ca50556471eadfc3212cb478161c3da5c4d02a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 29 Sep 2006 02:06:24 -0700 Subject: git-diff -B output fix. Geert noticed that complete rewrite diff missed the usual a/ and b/ leading paths. Pickaxe says it never worked, ever. Embarrassing. Signed-off-by: Junio C Hamano (cherry picked from bc1a5807575b2f34538d4158834da6524a4fc1f7 commit) diff --git a/diff.c b/diff.c index b3b1781..5dbc913 100644 --- a/diff.c +++ b/diff.c @@ -333,7 +333,7 @@ static void emit_rewrite_diff(const char *name_a, diff_populate_filespec(two, 0); lc_a = count_lines(one->data, one->size); lc_b = count_lines(two->data, two->size); - printf("--- %s\n+++ %s\n@@ -", name_a, name_b); + printf("--- a/%s\n+++ b/%s\n@@ -", name_a, name_b); print_line_count(lc_a); printf(" +"); print_line_count(lc_b); -- cgit v0.10.2-6-g49f6