git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <junkio@cox.net>,
	git@vger.kernel.org, Johannes.Schindelin@gmx.de
Subject: [PATCH] Improve output of %p and %P format in git-rev-list --pretty=format:
Date: Wed, 28 Mar 2007 22:11:23 +0200	[thread overview]
Message-ID: <20070328201123.GB2588@steel.home> (raw)
In-Reply-To: <20070328000828.GA13273@coredump.intra.peff.net>

Remove the terminating space from the space-separated list of parents.
Also fix the test t6006: it wrongly assumed that the initial commit
has a parent and was not executable.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

The test even hardcoded parents of the initial commit to the
initial commit itself, which does not make any sense at all.

 commit.c                   |    5 +++--
 t/t6006-rev-list-format.sh |    8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/commit.c b/commit.c
index a92958c..94b3713 100644
--- a/commit.c
+++ b/commit.c
@@ -852,13 +852,14 @@ static long format_commit_message(const struct commit *commit,
 	for (i = 0, p = commit->parents;
 			p && i < sizeof(parents) - 1;
 			p = p->next)
-		i += snprintf(parents + i, sizeof(parents) - i - 1, "%s ",
+		i += snprintf(parents + i, sizeof(parents) - i - 1, " %s" + !i,
 			sha1_to_hex(p->item->object.sha1));
 	interp_set_entry(table, IPARENTS, parents);
+	*parents = '\0';
 	for (i = 0, p = commit->parents;
 			p && i < sizeof(parents) - 1;
 			p = p->next)
-		i += snprintf(parents + i, sizeof(parents) - i - 1, "%s ",
+		i += snprintf(parents + i, sizeof(parents) - i - 1, " %s" + !i,
 			find_unique_abbrev(p->item->object.sha1,
 				DEFAULT_ABBREV));
 	interp_set_entry(table, IPARENTS_ABBREV, parents);
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cf096c3..ce9c7dc 100644
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -39,11 +39,11 @@ EOF
 
 test_format parents %P%n%p <<'EOF'
 commit 131a310eb913d107dd3c09a65d1651175898735d
-86c75cfd708a0e5868dc876ed5b8bb66c80b4873 
-86c75cf 
+86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+86c75cf
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
-86c75cf 
-86c75cf 
+
+
 EOF
 
 # we don't test relative here
-- 
1.5.1.rc2.18.g157b4

  parent reply	other threads:[~2007-03-28 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-28  0:08 [PATCH] Add some basic tests of rev-list --pretty=format Jeff King
2007-03-28 19:21 ` Alex Riesen
2007-03-28 20:37   ` [PATCH] Fix "--pretty=format:" for parent related items Junio C Hamano
2007-03-28 20:11 ` Alex Riesen [this message]
2007-03-28 20:24   ` [PATCH] Improve output of %p and %P format in git-rev-list --pretty=format: Jeff King

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=20070328201123.GB2588@steel.home \
    --to=raa.lkml@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=peff@peff.net \
    /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).