* 'git stash list' vs. non-default 'log.date' setting
@ 2010-08-09 10:40 SZEDER Gábor
2010-08-09 15:02 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: SZEDER Gábor @ 2010-08-09 10:40 UTC (permalink / raw)
To: git; +Cc: Thomas Rast
Hi,
Commits 8f8f547 (Introduce new pretty formats %g[sdD] for reflog
information, 2009-10-19) and 391c53b (stash list: use new %g formats
instead of sed, 2009-10-19) (Thomas on Cc:) changed the way how the
output of 'git stash list' is generated. I agree that avoiding a sed
invocation and respecting pager settings are good things (although I
also think that if you have so many stashes that you need a pager,
then you are doing something wrong).
However, these changes have some side-effects:
1) The output of 'git stash list' is affected by the 'log.date' config
variable:
$ git config --get log.date
$ git stash list
stash@{0}: On master: foo
$ git config log.date iso8601
$ git stash list
stash@{2010-08-03 16:54:34 +0200}: On master: foo
I would expect that stashes are always listed as stash@{num}, no
matter what I have in 'log.date' (just like 'git reflog'). It
takes up less screen space and is easier to remember.
2) The bash completion script expects that, too, because a non-default
value for 'log.date' breaks the completion of 'git stash'
subcommands with a stash argument:
$ git stash apply <TAB>
16 stash@{2010-08-03
Fortunately, fixing 2) is a no-brainer:
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6756990..e3600d4 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2167,7 +2167,7 @@ _git_stash ()
COMPREPLY=()
;;
show,*|apply,*|drop,*|pop,*|branch,*)
- __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
+ __gitcomp "$(git --git-dir="$(__gitdir)" stash list --date=default \
| sed -n -e 's/:.*//p')"
;;
*)
But what to do with 1)? Of course, I would hate to use --date=default
by 'git stash list' invocations, and, (again) of course, I don't want
to change my 'log.date' setting either. Maybe changing the %gd (and
%gD) format specifiers to ignore 'log.date' altogether but still
respect --date=<whatever>?
Best,
Gábor
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: 'git stash list' vs. non-default 'log.date' setting
2010-08-09 10:40 'git stash list' vs. non-default 'log.date' setting SZEDER Gábor
@ 2010-08-09 15:02 ` Junio C Hamano
2010-08-10 15:40 ` SZEDER Gábor
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-08-09 15:02 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: git, Thomas Rast
SZEDER Gábor <szeder@ira.uka.de> writes:
> Fortunately, fixing 2) is a no-brainer:
I don't think it is a "no-brainer" to "fix" it, even though it may be so
to hack it around. Having to give "--date=default" to "git log -g" to
cause it to show reflog entries in non-date format sounds like a terrible
UI bug to me. I'd expect
$ git log -g --date=default
to give you the logs in the default date format, overriding log.date, and
perhaps either of these
$ git log -g --no-date
$ git log -g --date=no
$ git log -g --numbered
to countermand log.date and force it to show numbered entries.
I _think_ "git log -g" uses a hacky heuristics to choose between date/number
based on how you give the stating ref. I personally do not like this dwim
very much, but it seems to be stable and established by now, so it may be
a good thing to use here instead:
$ git log -g refs/stash@{0}
$ git log -g refs/stash@{now}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'git stash list' vs. non-default 'log.date' setting
2010-08-09 15:02 ` Junio C Hamano
@ 2010-08-10 15:40 ` SZEDER Gábor
0 siblings, 0 replies; 3+ messages in thread
From: SZEDER Gábor @ 2010-08-10 15:40 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Thomas Rast
Hi,
On Mon, Aug 09, 2010 at 08:02:49AM -0700, Junio C Hamano wrote:
> SZEDER Gábor <szeder@ira.uka.de> writes:
>
> > Fortunately, fixing 2) is a no-brainer:
>
> I don't think it is a "no-brainer" to "fix" it, even though it may be so
> to hack it around. Having to give "--date=default" to "git log -g" to
> cause it to show reflog entries in non-date format sounds like a terrible
> UI bug to me. I'd expect
>
> $ git log -g --date=default
>
> to give you the logs in the default date format, overriding log.date
Indeed. I was just trying to get back the old behavior quickly and
with minimal effort, and didn't think about what the default date
format should actually mean.
> and perhaps either of these
>
> $ git log -g --no-date
> $ git log -g --date=no
> $ git log -g --numbered
>
> to countermand log.date and force it to show numbered entries.
It never occured to me before that that number in @{<num>} in reflogs
is actually kind of a date format. But since it seems to be the case,
a dedicated --date=<whatever> option for this format might be good to
have, although I don't think that this date format would be applicable
to regular logs.
> I _think_ "git log -g" uses a hacky heuristics to choose between date/number
> based on how you give the stating ref. I personally do not like this dwim
> very much, but it seems to be stable and established by now, so it may be
> a good thing to use here instead:
>
> $ git log -g refs/stash@{0}
> $ git log -g refs/stash@{now}
I see the DWIMery in this case, but 'git stash list' uses
reflog-specific format specifiers to generate the list of stashes:
git log --format="%gd: %gs" -g "$@" $ref_stash --
and unfortunately the %gd (and %gD) format specifier performs this
DWIMery only when log.date is not set, otherwise log.date takes over:
$ git config --get log.date
$ git log --format="%gd: %gs" -g refs/stash@{0}
stash@{0}: On master: foo
$ git log --format="%gd: %gs" -g refs/stash@{now}
stash@{2010-08-09 17:41:37 +0200}: On master: foo
$ git config log.date iso8601
$ git log --format="%gd: %gs" -g refs/stash@{0}
stash@{2010-08-09 17:41:37 +0200}: On master: foo
$ git log --format="%gd: %gs" -g refs/stash@{now}
stash@{2010-08-09 17:41:37 +0200}: On master: foo
Best,
Gábor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-10 15:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-09 10:40 'git stash list' vs. non-default 'log.date' setting SZEDER Gábor
2010-08-09 15:02 ` Junio C Hamano
2010-08-10 15:40 ` SZEDER Gábor
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).