rev-parse --show-prefix: add in trailing newline

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>

Ross Lagerwall committed Apr 9, 2012 at 15:27 UTC 658219f1c75e25adbe530a3b681ba3d2332caca6
2 files changed +3 -1
builtin/rev-parse.c
+2
@@ -634,6 +634,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
634 if (!strcmp(arg, "--show-prefix")) {
635 if (prefix)
636 puts(prefix);
637 + else
638 + putchar('\n');
639 continue;
640 }
641 if (!strcmp(arg, "--show-cdup")) {
t/t1501-worktree.sh
+1 -1
@@ -68,7 +68,7 @@ test_expect_success 'inside work tree' '
68 )
69 '
70
71 -test_expect_failure 'empty prefix is actually written out' '
71 +test_expect_success 'empty prefix is actually written out' '
72 echo >expected &&
73 (
74 cd work &&