rev-parse --show-prefix: add in trailing newline
authorRoss Lagerwall <rosslagerwall@gmail.com>
Mon, 9 Apr 2012 13:27:56 +0000 (15:27 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Apr 2012 16:25:35 +0000 (09:25 -0700)
Print out a trailing newline when --show-prefix is run with cwd
at the top level of the tree which results in an empty prefix.
Behavior is now like --show-cdup.

Fixes an expected failure in t1501.

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rev-parse.c
t/t1501-worktree.sh

index 98d1cbeccacc4b22dee88dab3d0154a3f70afe81..733f626f6c3e4ef54d54df923230f7ae4fbb2d7d 100644 (file)
@@ -634,6 +634,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                        if (!strcmp(arg, "--show-prefix")) {
                                if (prefix)
                                        puts(prefix);
+                               else
+                                       putchar('\n');
                                continue;
                        }
                        if (!strcmp(arg, "--show-cdup")) {
index e661147c573fa7312e8f533a4a4c8ea1eda7763f..8f36aa9fc4d2bdd8b590e3241eccf88609db4ee2 100755 (executable)
@@ -68,7 +68,7 @@ test_expect_success 'inside work tree' '
        )
 '
 
-test_expect_failure 'empty prefix is actually written out' '
+test_expect_success 'empty prefix is actually written out' '
        echo >expected &&
        (
                cd work &&