git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2] reflog: show committer date in verbose mode
@ 2013-06-03  1:58 Jiang Xin
  2013-06-03 10:00 ` Ramkumar Ramachandra
  0 siblings, 1 reply; 5+ messages in thread
From: Jiang Xin @ 2013-06-03  1:58 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jiang Xin

By default, reflog won't show committer date and for some cases won't
show commit log either. It will be helpful to show them all by passing
a more complicated pretty formatter to `git reflog` like this:

    $ git reflog show \
      --pretty="%Cred%h%Creset %gd: %gs%n  >> %Cblue%ci (%cr)%Creset: %s"

It will be nice to add this pretty formatter automatically when run
`git reflog` in verbose mode. And in order to support verbose mode, add
new flag "verbose" in struct rev_info.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
---

For example:

$ git reflog show -3 master
727a4 master@{0}: merge kernel/master: Fast-forward
edca41 master@{1}: merge kernel/master: Fast-forward
5e49f master@{2}: merge kernel/master: Fast-forward

$ git reflog show -3 -v master
727a4 master@{0}: merge kernel/master: Fast-forward
    Wed May 29 15:21:47 2013 -0700 (by Junio C Hamano, at 4 days ago)
edca41 master@{1}: merge kernel/master: Fast-forward
    Fri May 24 11:34:46 2013 -0700 (by Junio C Hamano, at 9 days ago)
5e49f master@{2}: merge kernel/master: Fast-forward
    Tue May 21 09:33:24 2013 -0700 (by Junio C Hamano, at 12 days ago)

$ git reflog show -3 -v -v master

727a4 master@{0}: merge kernel/master: Fast-forward
    Wed May 29 15:21:47 2013 -0700 (by Junio C Hamano, at 4 days ago)
    Sync with maint
edca41 master@{1}: merge kernel/master: Fast-forward
    Fri May 24 11:34:46 2013 -0700 (by Junio C Hamano, at 9 days ago)
    Git 1.8.3
5e49f master@{2}: merge kernel/master: Fast-forward
    Tue May 21 09:33:24 2013 -0700 (by Junio C Hamano, at 12 days ago)
    remote-hg: fix order of configuration comments

 builtin/log.c | 15 +++++++++++++++
 revision.c    |  1 +
 revision.h    |  1 +
 3 files changed, 17 insertions(+)

diff --git a/builtin/log.c b/builtin/log.c
index dd3f10..d611b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -615,6 +615,21 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 	rev.use_terminator = 1;
 	rev.always_show_header = 1;
 	cmd_log_init_finish(argc, argv, prefix, &rev, &opt);
+	if (rev.verbose && !rev.pretty_given) {
+		struct strbuf formatter = STRBUF_INIT;
+		rev.verbose_header = 1;
+		rev.pretty_given = 1;
+		strbuf_addf(&formatter, "%s%%h%s %%gd: %%gs%%n",
+			    diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
+			    diff_get_color_opt(&rev.diffopt, DIFF_RESET));
+		strbuf_addf(&formatter, "    %s%%cd%s (by %%cn, at %%cr)",
+			    diff_get_color_opt(&rev.diffopt, DIFF_METAINFO),
+			    diff_get_color_opt(&rev.diffopt, DIFF_RESET));
+		if (rev.verbose > 1)
+			strbuf_addstr(&formatter, "%n    %s");
+		get_commit_format(formatter.buf, &rev);
+		strbuf_release(&formatter);
+	}
 
 	return cmd_log_walk(&rev);
 }
diff --git a/revision.c b/revision.c
index 518cd..f7483 100644
--- a/revision.c
+++ b/revision.c
@@ -1514,6 +1514,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		revs->combine_merges = 1;
 	} else if (!strcmp(arg, "-v")) {
 		revs->verbose_header = 1;
+		revs->verbose++;
 	} else if (!strcmp(arg, "--pretty")) {
 		revs->verbose_header = 1;
 		revs->pretty_given = 1;
diff --git a/revision.h b/revision.h
index a313a..dc4d8 100644
--- a/revision.h
+++ b/revision.h
@@ -119,6 +119,7 @@ struct rev_info {
 			show_notes_given:1,
 			show_signature:1,
 			pretty_given:1,
+			verbose:3,
 			abbrev_commit:1,
 			abbrev_commit_given:1,
 			use_terminator:1,
-- 
1.8.3.490.gfd67a58.dirty

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2] reflog: show committer date in verbose mode
  2013-06-03  1:58 [RFC v2] reflog: show committer date in verbose mode Jiang Xin
@ 2013-06-03 10:00 ` Ramkumar Ramachandra
  2013-06-03 10:37   ` Duy Nguyen
  2013-06-03 11:20   ` Jiang Xin
  0 siblings, 2 replies; 5+ messages in thread
From: Ramkumar Ramachandra @ 2013-06-03 10:00 UTC (permalink / raw)
  To: Jiang Xin; +Cc: Git List, Junio C Hamano

Jiang Xin wrote:
> It will be nice to add this pretty formatter automatically when run
> `git reflog` in verbose mode. And in order to support verbose mode, add
> new flag "verbose" in struct rev_info.

Sorry I missed earlier revisions of this patch.  Generally speaking,
"verbose" is a bad way to control format-specifiers.  Why not add to
the list of pretty-format specifiers (like oneline, short, medium,
full)?  Also, this patch is extremely pervasive in that it teaches a
poorly defined "verbosity" to a very low layer: revision.c/revision.h.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2] reflog: show committer date in verbose mode
  2013-06-03 10:00 ` Ramkumar Ramachandra
@ 2013-06-03 10:37   ` Duy Nguyen
  2013-06-03 11:20   ` Jiang Xin
  1 sibling, 0 replies; 5+ messages in thread
From: Duy Nguyen @ 2013-06-03 10:37 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Jiang Xin, Git List, Junio C Hamano

On Mon, Jun 3, 2013 at 5:00 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> Jiang Xin wrote:
>> It will be nice to add this pretty formatter automatically when run
>> `git reflog` in verbose mode. And in order to support verbose mode, add
>> new flag "verbose" in struct rev_info.
>
> Sorry I missed earlier revisions of this patch.  Generally speaking,
> "verbose" is a bad way to control format-specifiers.  Why not add to
> the list of pretty-format specifiers (like oneline, short, medium,
> full)?

I think allowing to override the default format (e.g. via config key
reflog.format or something) and even format of -v(s) may be more
useful. People can define how "reflog show", "reflog show -v", "reflog
show -vv".. will display.
--
Duy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2] reflog: show committer date in verbose mode
  2013-06-03 10:00 ` Ramkumar Ramachandra
  2013-06-03 10:37   ` Duy Nguyen
@ 2013-06-03 11:20   ` Jiang Xin
  2013-06-03 17:43     ` Junio C Hamano
  1 sibling, 1 reply; 5+ messages in thread
From: Jiang Xin @ 2013-06-03 11:20 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Git List, Junio C Hamano

2013/6/3 Ramkumar Ramachandra <artagnon@gmail.com>:
> Jiang Xin wrote:
>> It will be nice to add this pretty formatter automatically when run
>> `git reflog` in verbose mode. And in order to support verbose mode, add
>> new flag "verbose" in struct rev_info.
>
> Sorry I missed earlier revisions of this patch.  Generally speaking,
> "verbose" is a bad way to control format-specifiers.  Why not add to
> the list of pretty-format specifiers (like oneline, short, medium,
> full)?  Also, this patch is extremely pervasive in that it teaches a
> poorly defined "verbosity" to a very low layer: revision.c/revision.h.

I also feel bad when adding new flag "verbose" into rev_info. = =b

CommitDate is more significant than AuthorDate for reflog. In order to
show CommitDate, at least we provide "fuller" formatter, such as
"git reflog --pretty=fuller". It's output is not as compact as:

    $ git reflog show \
       --pretty="%Cred%h%Creset %gd: %gs%n    %Cblue%ci (%cr)%Creset%n    %s"

Introduce new pretty-format like this is not suitable I think. Maybe
I have to define my own alias and use it myself. ;-)


-- 
Jiang Xin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC v2] reflog: show committer date in verbose mode
  2013-06-03 11:20   ` Jiang Xin
@ 2013-06-03 17:43     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2013-06-03 17:43 UTC (permalink / raw)
  To: Jiang Xin; +Cc: Ramkumar Ramachandra, Git List

Jiang Xin <worldhello.net@gmail.com> writes:

> 2013/6/3 Ramkumar Ramachandra <artagnon@gmail.com>:
>> Jiang Xin wrote:
>>> It will be nice to add this pretty formatter automatically when run
>>> `git reflog` in verbose mode. And in order to support verbose mode, add
>>> new flag "verbose" in struct rev_info.
>>
>> Sorry I missed earlier revisions of this patch.  Generally speaking,
>> "verbose" is a bad way to control format-specifiers.  Why not add to
>> the list of pretty-format specifiers (like oneline, short, medium,
>> full)?  Also, this patch is extremely pervasive in that it teaches a
>> poorly defined "verbosity" to a very low layer: revision.c/revision.h.
>
> I also feel bad when adding new flag "verbose" into rev_info. = =b
>
> CommitDate is more significant than AuthorDate for reflog.

This is a curious statement, as I've seen it in a different context
recently.

Is it committer date that you really care about, or are you using it
as a substitute for something else you care more about, namely, the
time of the event the reflog entry was created (i.e. when you
committed, when you resetted, when you "branch -f"ed)?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-03 17:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03  1:58 [RFC v2] reflog: show committer date in verbose mode Jiang Xin
2013-06-03 10:00 ` Ramkumar Ramachandra
2013-06-03 10:37   ` Duy Nguyen
2013-06-03 11:20   ` Jiang Xin
2013-06-03 17:43     ` Junio C Hamano

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).