threads / discuss / 37772

git reflog --date

Subject: git reflog --date

## tl;dr

8 messages between Oct 21, 2014 and Nov 4, 2014.

replies: 7people: 3as markdown or json

John Tapsell· Oct 21, 2014, 08:11 UTC · lore
Hi all,
  Could we add a default to "--date" so that:
git reflog --date

just works? (Currently you need to do: git reflog --date=iso) It should probably obey the default in log.date?

Also, could we add this "--date" option to the man page please? It's an extremely useful option to know. At the moment you have to notice the comment that "all normal log options" are there, and then try to work it out from there etc.

Thank you,
John
John
Junio C Hamano· Oct 21, 2014, 17:24 UTC · re: John Tapsell · lore

Re: git reflog --date

John Tapsell <johnflux@gmail.com> writes:
Show 8 quoted lines
> Hi all,
>
>   Could we add a default to "--date" so that:
>
> git reflog --date
>
> just works?  (Currently you need to do:   git reflog --date=iso)  It
> should probably obey the default in log.date?

Hmph. "--date=<style>" is not the way to choose between timed and counted output in the first place, though.

In a similar way that "git log -g @{now}" and "git log -g @{0}" switch between two, "git reflog @{now}" and "git reflog @{0}" have been the primary way to choose between them. Only because it is clear that you want the timed format when you specify any date style e.g. "git reflog --date=relative", we give timed output without @{<time>/<number>} but that is just icing on the cake.

That at least is why things are the way they are. And once you understand the above, you would understand why "--date=<style>" is not singled out as a useful option in the documentation, because that is not a primary way to choose between timed and counted output, but because it is merely a way to influence how times are shown once you chose timed output.

Having said all that, I have a few comments:
 - Perhaps use of @{<time>} vs @{<count>} as _the_ way to choose
   between timed and counted output is not documented clearly enough
   to lead to such a misunderstanding?
 - Perhaps use of @{<time>} vs @{<count>} is a less intuitive than
   ideal way to choose between them in the first place?
 - Perhaps adding --date with no date-style specification as another
   way to trigger "You said 'date' so you must mean you want timed
   output" heuristics just like existing "--date=<style>" does may
   let us get away without answering the above two questions,
   sidestepping the issues?
I dunno.
John Tapsell· Oct 21, 2014, 17:31 UTC · re: Junio C Hamano · lore

Re: git reflog --date

For me, writing "git reflog @{now}" is a lot less intuitive than "git reflog --date"

Currently the top google search for this question is here:
http://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
Which doesn't mention "@{now}"   at all.
My opinion:
1. Add --date   as an option to reflog.  Perhaps using the log.date
format as the default.
2. Document --date in the man page for "git reflog"
3. Document @{now}  in the man page for "git reflog"
Sound good?
John
On 21 October 2014 18:24, Junio C Hamano <gitster@pobox.com> wrote:
Show 44 quoted lines
> John Tapsell <johnflux@gmail.com> writes:
>
>> Hi all,
>>
>>   Could we add a default to "--date" so that:
>>
>> git reflog --date
>>
>> just works?  (Currently you need to do:   git reflog --date=iso)  It
>> should probably obey the default in log.date?
>
> Hmph.  "--date=<style>" is not the way to choose between timed and
> counted output in the first place, though.
>
> In a similar way that "git log -g @{now}" and "git log -g @{0}"
> switch between two, "git reflog @{now}" and "git reflog @{0}" have
> been the primary way to choose between them.  Only because it is
> clear that you want the timed format when you specify any date style
> e.g. "git reflog --date=relative", we give timed output without
> @{<time>/<number>} but that is just icing on the cake.
>
> That at least is why things are the way they are.  And once you
> understand the above, you would understand why "--date=<style>" is
> not singled out as a useful option in the documentation, because
> that is not a primary way to choose between timed and counted
> output, but because it is merely a way to influence how times are
> shown once you chose timed output.
>
> Having said all that, I have a few comments:
>
>  - Perhaps use of @{<time>} vs @{<count>} as _the_ way to choose
>    between timed and counted output is not documented clearly enough
>    to lead to such a misunderstanding?
>
>  - Perhaps use of @{<time>} vs @{<count>} is a less intuitive than
>    ideal way to choose between them in the first place?
>
>  - Perhaps adding --date with no date-style specification as another
>    way to trigger "You said 'date' so you must mean you want timed
>    output" heuristics just like existing "--date=<style>" does may
>    let us get away without answering the above two questions,
>    sidestepping the issues?
>
> I dunno.
Junio C Hamano· Oct 21, 2014, 18:06 UTC · re: John Tapsell · lore

Re: git reflog --date

John Tapsell <johnflux@gmail.com> writes:
Show 8 quoted lines
> For me, writing "git reflog @{now}"  is a lot less intuitive than "git
> reflog --date"
>
> Currently the top google search for this question is here:
>
> http://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
>
> Which doesn't mention "@{now}"   at all.

I would say that a site where cluelesses attempt to lead other cluelesses is not the best source of information ;-), but that tells us that either our docs are not read by people or they do not give necessary information to them clearly enough.

Show 8 quoted lines
> My opinion:
>
> 1. Add --date   as an option to reflog.  Perhaps using the log.date
> format as the default.
> 2. Document --date in the man page for "git reflog"
> 3. Document @{now}  in the man page for "git reflog"
>
> Sound good?

The order of changes is questionable, but other than that, I think that would be a good way forward.

John Tapsell· Oct 21, 2014, 18:12 UTC · re: Junio C Hamano · lore

Re: git reflog --date

Great - now I just need to persuade someone very nice nicely.. :-)
On 21 October 2014 19:06, Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
> John Tapsell <johnflux@gmail.com> writes:
>
>> For me, writing "git reflog @{now}"  is a lot less intuitive than "git
>> reflog --date"
>>
>> Currently the top google search for this question is here:
>>
>> http://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
>>
>> Which doesn't mention "@{now}"   at all.
>
> I would say that a site where cluelesses attempt to lead other
> cluelesses is not the best source of information ;-), but that tells
> us that either our docs are not read by people or they do not give
> necessary information to them clearly enough.
>
>> My opinion:
>>
>> 1. Add --date   as an option to reflog.  Perhaps using the log.date
>> format as the default.
>> 2. Document --date in the man page for "git reflog"
>> 3. Document @{now}  in the man page for "git reflog"
>>
>> Sound good?
>
> The order of changes is questionable, but other than that, I think
> that would be a good way forward.
Junio C Hamano· Oct 21, 2014, 23:11 UTC · re: John Tapsell · lore

Re: git reflog --date

John Tapsell <johnflux@gmail.com> writes:
Show 30 quoted lines
> On 21 October 2014 19:06, Junio C Hamano <gitster@pobox.com> wrote:
>> John Tapsell <johnflux@gmail.com> writes:
>>
>>> For me, writing "git reflog @{now}"  is a lot less intuitive than "git
>>> reflog --date"
>>>
>>> Currently the top google search for this question is here:
>>>
>>> http://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
>>>
>>> Which doesn't mention "@{now}"   at all.
>>
>> I would say that a site where cluelesses attempt to lead other
>> cluelesses is not the best source of information ;-), but that tells
>> us that either our docs are not read by people or they do not give
>> necessary information to them clearly enough.
>>
>>> My opinion:
>>>
>>> 1. Add --date   as an option to reflog.  Perhaps using the log.date
>>> format as the default.
>>> 2. Document --date in the man page for "git reflog"
>>> 3. Document @{now}  in the man page for "git reflog"
>>>
>>> Sound good?
>>
>> The order of changes is questionable, but other than that, I think
>> that would be a good way forward.
>
> Great - now I just need to persuade someone very nice nicely.. :-)
You should note that #1 is unworkable, as it would make:
    $ git log -g --date default

ambiguous. Is it asking the timed reflog output using log.date format on the "default" branch, or is it asking the timed reflog output using the "default" time format on the HEAD?

You would need to disambiguate by
    $ git log -g --date -- default ;# on default branch
    $ git log -g --date default -- ;# using default time format

or something, which means --date can be the last dashed option on the command line, and also you close the door for us to ever add another dashed command line option that takes an optional argument.

So the best you could do is
    1. Add document commit@{timestamp} vs commit@{count} notation
       we have for "git log" also to "git reflog", perhaps?
    2. Document --date=<style> (but not --date alone) as a way to
       trigger timed output for reflog entries, and refer to that
       from "--walk-reflogs" option description as "see also".
 
Junio C Hamano· Oct 21, 2014, 22:21 UTC · re: Junio C Hamano · lore

Re: git reflog --date

Junio C Hamano <gitster@pobox.com> writes:
Show 15 quoted lines
> John Tapsell <johnflux@gmail.com> writes:
>
>> For me, writing "git reflog @{now}"  is a lot less intuitive than "git
>> reflog --date"
>>
>> Currently the top google search for this question is here:
>>
>> http://stackoverflow.com/questions/17369254/is-there-a-way-to-cause-git-reflog-to-show-a-date-alongside-each-entry
>>
>> Which doesn't mention "@{now}"   at all.
>
> I would say that a site where cluelesses attempt to lead other
> cluelesses is not the best source of information ;-), but that tells
> us that either our docs are not read by people or they do not give
> necessary information to them clearly enough.

And it turns out it is a little bit of both. We have this shown in "git log --help":

    -g::
    --walk-reflogs::
    ...
    By default, 'commit@\{Nth}' notation is
    used in the output.  When the starting commit is specified as
    'commit@\{now}', output also uses 'commit@\{timestamp}' notation
    instead.

and "git reflog --help" says that "It is an alias for git log -g --abbrev-commit --pretty=oneline; see git-log(1)." in fairly early part of its description.

Phil Hord· Nov 4, 2014, 17:06 UTC · re: Junio C Hamano · lore

Re: git reflog --date

On Tue, Oct 21, 2014 at 1:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> John Tapsell <johnflux@gmail.com> writes:
>
>> Hi all,
>>
>>   Could we add a default to "--date" so that:
>>
>> git reflog --date
>>
>> just works?  (Currently you need to do:   git reflog --date=iso)  It
>> should probably obey the default in log.date?
>
> Hmph.  "--date=<style>" is not the way to choose between timed and
> counted output in the first place, though.
Of course not.  I always use --relative-date for this.

← back to recent threads