git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug in git-stash(.sh) ?

From
Jeff King <peff@peff.net>
Date
Apr 29, 2012, 22:01 UTC
Message-ID
<20120429220132.GB4491@sigill.intra.peff.net>
In-Reply-To
<20380.33897.666338.766096@winooski.ccs.neu.edu>
On Sat, Apr 28, 2012 at 07:59:37PM -0400, Eli Barzilay wrote:
Show 8 quoted lines
> > How exactly do you make magit generate these calls?  AFAICT, Magit
> > should operate on whatever "git stash list" outputs, meaning
> > stash@{N}. So I guess I'm missing something.
> 
> ... right: the offending configuration I had was log.date = iso.  This
> calls for a simple chane for git-stash.sh to use `--date default':
> 
> 	git log --date default --format="%gd: %gs" -g "$@" $ref_stash --

I seem to remember dealing with this once a long time ago. And while "--date=default" works, it is papering over the symptom of a larger problem, which is that "log" should not use a non-commandline date to make the stash selector decision. Searching turned up this discussion:

  http://thread.gmane.org/gmane.comp.version-control.git/128569

which led to f4ea32f (improve reflog date/number heuristic, 2009-09-24). That fixed the case of:

  git config log.date iso
  git log -g --oneline

But later, 8f8f547 (Introduce new pretty formats %g[sdD] for reflog information, 2009-10-19) added another way to show selectors, and it did not respect the date_mode_explicit flag from f4ea32f. Which I think is a bug.

So the right solution is to pass the date_mode_explicit flag through to the pretty-print --format code, and then pass it along to the reflog code.

> Another point is being able to see these dates, eg, make "stash list"
> show the stash{N} and also show the dates.
You can do so with:
  git stash list --date=iso

but there is no way to do it automatically via config (and indeed, you can see that it creates problems for scripts when you do so. :) ).

> It looks to me like the date code in get_reflog_selector() should be
> *removed* since it can be printed with "%cd" or "%ad" in the log line.
No, all three are distinct dates. For example, from my git.git reflog:
  $ git log -g --format='%gd / %cd / %ad' --date=short
  HEAD@{2012-04-29} / 2009-09-29 / 2009-09-24

That's a commit (which happens to be f4ea32f) that was written on 2009-09-24 (author date), sent as a patch to the list and applied upstream on 2009-09-29 (committer date), and reached my HEAD reflog via "git checkout f4ea32f" three years later.

-Peff
Previous: Eli BarzilayNext: Junio C Hamano
Message 7 of 26 in “Bug in git-stash(.sh) ?”
  1. Eli BarzilayApr 27, 2012
  2. Junio C HamanoApr 27, 2012
  3. Eli BarzilayApr 28, 2012
  4. Andreas SchwabApr 28, 2012
  5. Yann HodiqueApr 28, 2012
  6. Eli BarzilayApr 28, 2012
  7. Jeff KingApr 29, 2012
  8. Junio C HamanoApr 29, 2012
  9. Eli BarzilayApr 29, 2012
  10. Jeff KingMay 1, 2012
  11. Eli BarzilayApr 29, 2012
  12. Jeff KingMay 1, 2012
  13. [git] Re: Bug in git-stash(.sh) ?Eli Barzilay, May 3, 2012
  14. Jeff KingMay 4, 2012
  15. 3/4 reflog-walk: clean up "flag" field of commit_reflog structJeff King, May 4, 2012
  16. 1/4 t1411: add more selector index/date testsJeff King, May 4, 2012
  17. 2/4 log: respect date_mode_explicit with --format:%gdJeff King, May 4, 2012
  18. 4/4 reflog-walk: always make HEAD@{0} show indexed selectorsJeff King, May 4, 2012
  19. Junio C HamanoMay 4, 2012
  20. Eli BarzilayMay 4, 2012
  21. Eli BarzilayMay 4, 2012
  22. Jeff KingMay 7, 2012
  23. Jeff KingMay 10, 2012
  24. Junio C HamanoMay 10, 2012
  25. OT: gmane address mangling selectorsJeff King, May 10, 2012
  26. Eli BarzilayMay 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.