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

Re: Add compiled date to git --version output?

From
David Aguilar <davvid@gmail.com>
Date
Sep 18, 2009, 05:03 UTC
Message-ID
<20090918050351.GA11242@gmail.com>
In-Reply-To
<544dda350909172117r44761577m11e7d30a1a5d0c91@mail.gmail.com>
On Fri, Sep 18, 2009 at 12:17:48PM +0800, Nazri Ramliy wrote:
> Sometimes I wanted to know how outdated git is on my system.
	$ ls -la $(which git)
Show 25 quoted lines
> Coming up with a script to parse "git --version" output to get the SHA1,
> and compare that to master's SHA1 seemed a little overkill compared to
> this:
> 
> diff --git a/help.c b/help.c
> index 294337e..bc83491 100644
> --- a/help.c
> +++ b/help.c
> @@ -361,6 +361,9 @@ const char *help_unknown_cmd(const char *cmd)
> 
>  int cmd_version(int argc, const char **argv, const char *prefix)
>  {
> -       printf("git version %s\n", git_version_string);
> +       printf("git version %s compiled %s %s\n",
> +                       git_version_string,
> +                       __DATE__,
> +                       __TIME__);
>         return 0;
>  }
> 
> With this, git --version gives:
> 
>         git version 1.6.5.rc1.19.g8426.dirty compiled Sep 18 2009 12:03:29
> 
> Thoughts?

For whatever it's worth, I would feel more comfortable if this were guarded behind an option e.g. 'git version --date'.

I suspect that there are a fair number of scripts out there parsing the output of 'git version'. 'git version' is not plumbing but we still might want to avoid breaking them.

Is it better to say "compiled on $date" or "compiled $date"?

It's meant to be informational (aka not an actual English sentence) so I guess it could go either way; "compiled on" is a little more proper, though.

What about "born on $date" since it gives users a subliminal suggestion that they should consider upgrading to a fresh git? ;)

-- 
	David
Previous: Brian GernhardtNext: Junio C Hamano
Message 3 of 5 in “Add compiled date to git --version output?”
  1. Nazri RamliySep 18, 2009
  2. Brian GernhardtSep 18, 2009
  3. David AguilarSep 18, 2009
  4. Junio C HamanoSep 18, 2009
  5. Nazri RamliySep 18, 2009

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.