From: Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
Subject: [PATCH v2] Fix notes handling in rev-list
Date: Mon, 16 Jul 2012 21:30:09 +0300 [thread overview]
Message-ID: <1342463409-6919-1-git-send-email-jukka.lehtniemi@gmail.com> (raw)
In-Reply-To: <20120325005504.GA27651@sigill.intra.peff.net>
Display notes in the rev-list when switch '--notes' is used.
Also expand notes place holder (%N) in user format.
Previously rev-list ignored both of these.
Signed-off-by: Jukka Lehtniemi <jukka.lehtniemi@gmail.com>
---
Thanks for your feedback Peff!
builtin/rev-list.c | 16 +++++++++++++++-
t/t6006-rev-list-format.sh | 22 +++++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index ff5a383..ad8abcb 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -7,6 +7,7 @@
#include "log-tree.h"
#include "graph.h"
#include "bisect.h"
+#include "notes.h"
static const char rev_list_usage[] =
"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
@@ -111,6 +112,7 @@ static void show_commit(struct commit *commit, void *data)
ctx.date_mode = revs->date_mode;
ctx.date_mode_explicit = revs->date_mode_explicit;
ctx.fmt = revs->commit_format;
+ ctx.show_notes = revs->show_notes;
pretty_print_commit(&ctx, commit, &buf);
if (revs->graph) {
if (buf.len) {
@@ -159,6 +161,12 @@ static void show_commit(struct commit *commit, void *data)
} else {
if (graph_show_remainder(revs->graph))
putchar('\n');
+ if (revs->show_notes_given) {
+ struct strbuf buf = STRBUF_INIT;
+ format_display_notes(commit->object.sha1, &buf, 0, NOTES_SHOW_HEADER|NOTES_INDENT);
+ fwrite(buf.buf, 1, buf.len, stdout);
+ strbuf_release(&buf);
+ }
}
maybe_flush_or_die(stdout, "stdout");
finish_commit(commit, data);
@@ -309,6 +317,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
struct rev_list_info info;
+ struct userformat_want userformat_want = {0};
int i;
int bisect_list = 0;
int bisect_show_vars = 0;
@@ -322,9 +331,14 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
memset(&info, 0, sizeof(info));
info.revs = &revs;
+
+ userformat_find_requirements(NULL, &userformat_want);
+ if (userformat_want.notes)
+ revs.show_notes = 1;
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 f94f0c4..ab616a0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -7,7 +7,8 @@ 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
@@ -19,6 +20,25 @@ test_cmp expect.$1 output.$1
"
}
+test_expect_success 'notes switch' "
+cat >expect.notes_switch <<'EOF'
+131a310eb913d107dd3c09a65d1651175898735d
+
+Notes:
+ note foo
+86c75cfd708a0e5868dc876ed5b8bb66c80b4873
+EOF
+git rev-list --notes master >output.notes_switch &&
+test_cmp expect.notes_switch output.notes_switch
+"
+
+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 prev parent reply other threads:[~2012-07-16 18:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-24 19:38 [PATCH] rev-list: fix place holder %N (notes) in user format Jukka Lehtniemi
2012-03-25 0:55 ` Jeff King
2012-07-16 18:30 ` Jukka Lehtniemi [this message]
2012-07-16 19:03 ` [PATCH v2] Fix notes handling in rev-list 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=1342463409-6919-1-git-send-email-jukka.lehtniemi@gmail.com \
--to=jukka.lehtniemi@gmail.com \
--cc=git@vger.kernel.org \
--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).