[PATCH] rev-list: fix place holder %N (notes) in user format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jukka Lehtniemi <jukka.lehtniemi@xxxxxxxxx>
---

 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]