{"thread":{"id":"20996","subject":"Add compiled date to git --version output?","startedAt":"2009-09-18T04:17:48Z","lastAt":"2009-09-18T06:04:28Z","messageCount":5,"participants":["Nazri Ramliy","Brian Gernhardt","David Aguilar","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123475","messageId":"544dda350909172117r44761577m11e7d30a1a5d0c91@mail.gmail.com","threadId":"20996","inReplyTo":null,"subject":"Add compiled date to git --version output?","fromName":"Nazri Ramliy","fromEmail":"ayiehere@gmail.com","sentAt":"2009-09-18T04:17:48Z","receivedAt":"2009-09-18T04:17:48Z","isPatch":false,"sender":{"key":"ayiehere@gmail.com","avatar":"https://avatars.githubusercontent.com/u/164756?v=4"},"body":"Sometimes I wanted to know how outdated git is on my system.\n\nComing up with a script to parse \"git --version\" output to get the SHA1,\nand compare that to master's SHA1 seemed a little overkill compared to\nthis:\n\ndiff --git a/help.c b/help.c\nindex 294337e..bc83491 100644\n--- a/help.c\n+++ b/help.c\n@@ -361,6 +361,9 @@ const char *help_unknown_cmd(const char *cmd)\n\n int cmd_version(int argc, const char **argv, const char *prefix)\n {\n-       printf(\"git version %s\\n\", git_version_string);\n+       printf(\"git version %s compiled %s %s\\n\",\n+                       git_version_string,\n+                       __DATE__,\n+                       __TIME__);\n        return 0;\n }\n\nWith this, git --version gives:\n\n        git version 1.6.5.rc1.19.g8426.dirty compiled Sep 18 2009 12:03:29\n\nThoughts?\n\nNazri\n"},{"id":"123476","messageId":"F73940A6-02F5-48EE-BD11-FCEC5B21B054@gernhardtsoftware.com","threadId":"20996","inReplyTo":"544dda350909172117r44761577m11e7d30a1a5d0c91@mail.gmail.com","subject":"Re: Add compiled date to git --version output?","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2009-09-18T04:43:47Z","receivedAt":"2009-09-18T04:43:47Z","isPatch":false,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 18, 2009, at 12:17 AM, Nazri Ramliy wrote:\n\n> +       printf(\"git version %s compiled %s %s\\n\",\n> +                       git_version_string,\n> +                       __DATE__,\n> +                       __TIME__);\n\n> Thoughts?\n\nAny idea how compatible that is?  Sure, it'll work with GCC's cpp, but  \nwe try to work with a huge variety of compilers.\n\nAt the very least you might want to wrap it all in #ifdefs or something:\n\n#if defined(__DATE__) && defined(__TIME__)\n/* your version */\n#else\n/* old version */\n#endif\n\n(Or play fun tricks with #ifndef ... #define, but then you also have  \nto play with the format string or something.)\n\n~~Brian\n"},{"id":"123477","messageId":"20090918050351.GA11242@gmail.com","threadId":"20996","inReplyTo":"544dda350909172117r44761577m11e7d30a1a5d0c91@mail.gmail.com","subject":"Re: Add compiled date to git --version output?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-09-18T05:03:52Z","receivedAt":"2009-09-18T05:03:52Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Fri, Sep 18, 2009 at 12:17:48PM +0800, Nazri Ramliy wrote:\n> Sometimes I wanted to know how outdated git is on my system.\n\n\t$ ls -la $(which git)\n\n\n> Coming up with a script to parse \"git --version\" output to get the SHA1,\n> and compare that to master's SHA1 seemed a little overkill compared to\n> this:\n> \n> diff --git a/help.c b/help.c\n> index 294337e..bc83491 100644\n> --- a/help.c\n> +++ b/help.c\n> @@ -361,6 +361,9 @@ const char *help_unknown_cmd(const char *cmd)\n> \n>  int cmd_version(int argc, const char **argv, const char *prefix)\n>  {\n> -       printf(\"git version %s\\n\", git_version_string);\n> +       printf(\"git version %s compiled %s %s\\n\",\n> +                       git_version_string,\n> +                       __DATE__,\n> +                       __TIME__);\n>         return 0;\n>  }\n> \n> With this, git --version gives:\n> \n>         git version 1.6.5.rc1.19.g8426.dirty compiled Sep 18 2009 12:03:29\n> \n> Thoughts?\n\nFor whatever it's worth, I would feel more comfortable if this\nwere guarded behind an option e.g. 'git version --date'.\n\nI suspect that there are a fair number of scripts out there\nparsing the output of 'git version'.  'git version' is not\nplumbing but we still might want to avoid breaking them.\n\nIs it better to say \"compiled on $date\" or \"compiled $date\"?\n\nIt's meant to be informational (aka not an actual English\nsentence) so I guess it could go either way; \"compiled on\"\nis a little more proper, though.\n\nWhat about \"born on $date\" since it gives users a subliminal\nsuggestion that they should consider upgrading to a fresh git?\n;)\n\n\n-- \n\n\tDavid\n"},{"id":"123478","messageId":"7v8wgchmcc.fsf@alter.siamese.dyndns.org","threadId":"20996","inReplyTo":"544dda350909172117r44761577m11e7d30a1a5d0c91@mail.gmail.com","subject":"Re: Add compiled date to git --version output?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-09-18T05:07:47Z","receivedAt":"2009-09-18T05:07:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nazri Ramliy <ayiehere@gmail.com> writes:\n\n> Sometimes I wanted to know how outdated git is on my system.\n>\n> Coming up with a script to parse \"git --version\" output to get the SHA1,\n> and compare that to master's SHA1 seemed a little overkill compared to\n> this:\n>\n> diff --git a/help.c b/help.c\n> index 294337e..bc83491 100644\n> --- a/help.c\n> +++ b/help.c\n> @@ -361,6 +361,9 @@ const char *help_unknown_cmd(const char *cmd)\n>\n>  int cmd_version(int argc, const char **argv, const char *prefix)\n>  {\n> -       printf(\"git version %s\\n\", git_version_string);\n> +       printf(\"git version %s compiled %s %s\\n\",\n> +                       git_version_string,\n> +                       __DATE__,\n> +                       __TIME__);\n>         return 0;\n>  }\n>\n> With this, git --version gives:\n>\n>         git version 1.6.5.rc1.19.g8426.dirty compiled Sep 18 2009 12:03:29\n>\n> Thoughts?\n\nIt's open source, so you are welcome to do that to your binary.\n\nPersonally, I do not want it.  My build scripts depend on the version\nstring at the end if the output to omit re-building what is already\ninstalled.\n\nSeriously, the version number is useful to track down the bug, and perhaps\nyour compiler and library versions might be useful to help diagnose build\nrelated errors, but when would that __DATE__/__TIME__ be useful more than\nwhat \"ls -l /usr/bin/git\" would give you?\n"},{"id":"123479","messageId":"544dda350909172304i2d603719ra44bef520389f024@mail.gmail.com","threadId":"20996","inReplyTo":"7v8wgchmcc.fsf@alter.siamese.dyndns.org","subject":"Re: Add compiled date to git --version output?","fromName":"Nazri Ramliy","fromEmail":"ayiehere@gmail.com","sentAt":"2009-09-18T06:04:28Z","receivedAt":"2009-09-18T06:04:28Z","isPatch":false,"sender":{"key":"ayiehere@gmail.com","avatar":"https://avatars.githubusercontent.com/u/164756?v=4"},"body":"Thanks for the input guys, I've come to the conclusion that the extra\neffort needed to properly implement this is not worth the benefit of\nthe outcome.\n\nAs some of you mentioned, ls -l `which git` is better suited for the\npurpose, and that can be done universally for all files where the\nfilesystem stores the create timestamp of each.\n\nnazri.\n"}]}