From: Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
Subject: [PATCH] rev-list: fix place holder %N (notes) in user format
Date: Sat, 24 Mar 2012 21:38:31 +0200 [thread overview]
Message-ID: <1332617911-8281-1-git-send-email-jukka.lehtniemi@gmail.com> (raw)
Signed-off-by: Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
---
Fixes a bug where the place holder for notes (%N) was not expanded
in rev-list. To reproduce the bug:
$ git notes add -m foo
$ git rev-list --notes --format=format:%N HEAD ^HEAD^
builtin/rev-list.c | 4 +++-
t/t6006-rev-list-format.sh | 12 ++++++++++--
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 4c4d404..d6e7dfc 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -110,6 +110,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.abbrev = revs->abbrev;
ctx.date_mode = revs->date_mode;
ctx.fmt = revs->commit_format;
+ ctx.show_notes = revs->show_notes;
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
@@ -323,7 +324,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
info.revs = &revs;
if (revs.bisect)
bisect_list = 1;
-
+ if (revs.show_notes)
+ init_display_notes(&revs.notes_opt);
if (DIFF_OPT_TST(&revs.diffopt, QUICK))
info.flags |= REV_LIST_QUIET;
for (i = 1 ; i < argc; i++) {
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 4442790..76af40a 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,18 +7,26 @@ test_description='git rev-list --pretty=format test'
test_tick
test_expect_success 'setup' '
touch foo && git add foo && git commit -m "added foo" &&
- echo changed >foo && git commit -a -m "changed foo"
+ echo changed >foo && git commit -a -m "changed foo" &&
+ git notes add -m "note foo"
'
# usage: test_format name format_string <expected_output
test_format() {
cat >expect.$1
test_expect_success "format $1" "
-git rev-list --pretty=format:'$2' master >output.$1 &&
+git rev-list --notes --pretty=format:'$2' master >output.$1 &&
test_cmp expect.$1 output.$1
"
}
+test_format notes %N <<'EOF'
+commit 131a310eb913d107dd3c09a65d1651175898735d
+note foo
+
+commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+EOF
+
test_format percent %%h <<'EOF'
commit 131a310eb913d107dd3c09a65d1651175898735d
%h
--
1.7.4.1
next reply other threads:[~2012-03-24 19:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-24 19:38 Jukka Lehtniemi [this message]
2012-03-25 0:55 ` [PATCH] rev-list: fix place holder %N (notes) in user format Jeff King
2012-07-16 18:30 ` [PATCH v2] Fix notes handling in rev-list Jukka Lehtniemi
2012-07-16 19:03 ` Junio C Hamano
2012-07-17 3:17 ` Jeff King
2012-07-17 3:40 ` Junio C Hamano
2012-07-17 3:51 ` Jeff King
2012-07-17 3:46 ` Jeff King
2012-07-17 5:42 ` Junio C Hamano
2012-07-17 21:22 ` Jukka Lehtniemi
2012-07-18 7:21 ` Jeff King
2012-07-18 22:39 ` Junio C Hamano
2012-07-19 11:35 ` Jeff King
2012-07-19 17:20 ` Junio C Hamano
2012-07-19 17:25 ` 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=1332617911-8281-1-git-send-email-jukka.lehtniemi@gmail.com \
--to=jukka.lehtniemi@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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).