git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ross Lagerwall <rosslagerwall@gmail.com>
To: git@vger.kernel.org
Cc: Ross Lagerwall <rosslagerwall@gmail.com>
Subject: [PATCH] rev-parse --show-prefix: add in trailing newline
Date: Mon,  9 Apr 2012 15:27:56 +0200	[thread overview]
Message-ID: <1333978076-29968-1-git-send-email-rosslagerwall@gmail.com> (raw)

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>
---
 builtin/rev-parse.c |    2 ++
 t/t1501-worktree.sh |    2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 98d1cbe..733f626 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -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")) {
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index e661147..8f36aa9 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -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 &&
-- 
1.7.10

             reply	other threads:[~2012-04-09 13:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09 13:27 Ross Lagerwall [this message]
2012-04-09 19:07 ` [PATCH] rev-parse --show-prefix: add in trailing newline Junio C Hamano
2012-04-10  5:30   ` Ross Lagerwall
2012-04-10 14:04   ` Jonathan Nieder
2012-04-10 14:41   ` Andreas Schwab
2012-04-10 16:14     ` Junio C Hamano
2012-04-10 17:36 ` Jonathan Nieder
2012-04-10 17:56   ` Junio C Hamano
2012-04-10 22:51   ` Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1333978076-29968-1-git-send-email-rosslagerwall@gmail.com \
    --to=rosslagerwall@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).