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

bug: git stash list --format='%gd' --date=format:'…'

From
STStephen Talley <stephentalley@nerdysoftware.com>
Date
Aug 5, 2017, 19:05 UTC
Message-ID
<20170805190553.GA12649@nerd>
Synopsis:
When expanding '%gd' placeholder (reflog selector), git substitutes user-specified --date format, which mangles the reflog.
Description:
I was writing a script that expects a stash reflog and a date on stdin:
    % git stash list --format='%gd%n%ad'
    stash@{0}
    Sat Aug 5 13:26:30 2017 -0400
    stash@{1}
    Sat Aug 5 13:18:54 2017 -0400
    …
Since this date is going to be presented to the user, I wanted to apply my own date format:
    % git stash list --format='%gd%n%ad' --date=format:%Y/%m/%d
    stash@{2017/08/05}
    2017/08/05
    stash@{2017/08/05}
    2017/08/05
    …
Unfortunately this mangles the reflog as well (e.g. "stash@{2017/08/05}"), making it useless when passed back to git.
Apparently stashes can be referenced by date, which is fine I suppose.  But those dates should never be subject to user-defined formatting via --date=format:….
I'd expect the above command to instead output:
    % git stash list --format='%gd%n%ad' --date=format:%Y/%m/%d
    stash@{0}
    2017/08/05
    stash@{1}
    2017/08/05
    …
or at least always use the ISO date format:
    % git stash list --format='%gd%n%ad'
    stash@{2017-08-05 13:26:30 -0400}
    2017-08-05 13:26:30 -0400
    stash@{2017-08-05 13:18:54 -0400}
    2017-08-05 13:18:54 -0400
    …
Steve
Message 1 of 1 in “bug: git stash list --format='%gd' --date=format:'…'”
  1. Stephen TalleyAug 5, 2017

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.