threads / discuss / 46297

git log use of date format differs between Command Line and script usage.

Subject: git log use of date format differs between Command Line and script usage.

## tl;dr

4 messages between Jun 30, 2017 and Jun 30, 2017.

replies: 3people: 3as markdown or json

Shaun Uldrikis· Jun 30, 2017, 16:06 UTC · lore
If you supply a non-standard format to the date configuration for git
log, something like:
[log]
        date = format:%Y-%m-%d %H:%M

then, when you run 'git log' inside a script, or when using gitk (anywhere), it fails on decoding the format.

fatal: unknown date format format: %Y-%m-%d %H:%M

However, that format works correctly on the command line. I do not have a patch to address this issue.

-Shaun
René Scharfe· Jun 30, 2017, 16:41 UTC · re: Shaun Uldrikis · lore

Re: git log use of date format differs between Command Line and script usage.

Am 30.06.2017 um 18:06 schrieb Shaun Uldrikis:
Show 13 quoted lines
> If you supply a non-standard format to the date configuration for git
> log, something like:
> [log]
>          date = format:%Y-%m-%d %H:%M
> 
> then, when you run 'git log' inside a script, or when using gitk
> (anywhere), it fails on decoding the format.
> 
> fatal: unknown date format format: %Y-%m-%d %H:%M
> 
> 
> However, that format works correctly on the command line.
> I do not have a patch to address this issue.

I guess you have two versions of git on your system, and the one used in scripts is older than 2.6.0, which introduced this feature.

René
Stefan Beller· Jun 30, 2017, 16:43 UTC · re: Shaun Uldrikis · lore

Re: git log use of date format differs between Command Line and script usage.

On Fri, Jun 30, 2017 at 9:06 AM, Shaun Uldrikis <stuldrikis@gmail.com> wrote:
> If you supply a non-standard format to the date configuration for git
> log, something like:
> [log]
>         date = format:%Y-%m-%d %H:%M
So I ran
    $ git config log.date  "format:%Y-%m-%d %H:%M"
    $ git config --list |grep log.date
    log.date=format:%Y-%m-%d %H:%M
Then I have a script as
  $ cat script.sh
  #!/bin/sh
  git log >out
after executing I get:
  $ head out
  commit 7930db48ca31b41ac335ae8cd25cb29094d1de5e
  Author: Stefan Beller <sbeller@google.com>
  Date:   2017-06-30 09:26
Also gitk seems to work here.

Rene's answer sounds reasonable, check the version(s) of Git on your system?

Shaun Uldrikis· Jun 30, 2017, 17:29 UTC · re: Stefan Beller · lore

Re: git log use of date format differs between Command Line and script usage.

Yes. That is the case. Just confirmed it. I'll remove the old version. Sorry to have bothered the mailing list.

Thank you.
-Shaun
On Fri, Jun 30, 2017 at 12:43 PM, Stefan Beller <sbeller@google.com> wrote:
Show 29 quoted lines
> On Fri, Jun 30, 2017 at 9:06 AM, Shaun Uldrikis <stuldrikis@gmail.com> wrote:
>> If you supply a non-standard format to the date configuration for git
>> log, something like:
>> [log]
>>         date = format:%Y-%m-%d %H:%M
>
> So I ran
>
>     $ git config log.date  "format:%Y-%m-%d %H:%M"
>     $ git config --list |grep log.date
>     log.date=format:%Y-%m-%d %H:%M
>
> Then I have a script as
>   $ cat script.sh
>   #!/bin/sh
>
>   git log >out
>
> after executing I get:
>
>   $ head out
>   commit 7930db48ca31b41ac335ae8cd25cb29094d1de5e
>   Author: Stefan Beller <sbeller@google.com>
>   Date:   2017-06-30 09:26
>
> Also gitk seems to work here.
>
> Rene's answer sounds reasonable,
> check the version(s) of Git on your system?

← back to recent threads