{"thread":{"id":"33663","subject":"`git describe` in an export-subst format string?","startedAt":"2013-04-28T18:02:04Z","lastAt":"2013-04-28T22:52:20Z","messageCount":3,"participants":["John Gallagher","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"215793","messageId":"CAFoDJR8RQExLwXcrViAJpWgvq+wBopY-Wq1keHxVqB3QwtAz4A@mail.gmail.com","threadId":"33663","inReplyTo":null,"subject":"`git describe` in an export-subst format string?","fromName":"John Gallagher","fromEmail":"johnkgallagher@gmail.com","sentAt":"2013-04-28T18:02:04Z","receivedAt":"2013-04-28T18:02:04Z","isPatch":false,"sender":{"key":"johnkgallagher@gmail.com","avatar":null},"body":"I originally posted this as a question about getting `git log` to\noutput the same thing that `git describe` does to the git-users\nmailing list, and was directed here. The actual thing I want to do is\nsomething like this:\n\n  static const char *project_version = \"$Format:...$\";\n\nwhere \"...\" is something that `git archive` will replace with the\noutput of `git describe`, given the file has the export-subst\nproperty, possibly with arguments to git describe (--tags, --all,\netc.). In a normal build I can do this with the build system just\ncalling git directly, but if I'm archiving a tarball off there doesn't\nseem to be a way to do this (other than manually replacing the format\nstring myself as some secondary step).\n\nDoes this seem like a reasonable thing to do, or am I overlooking a\nbetter alternative? If this is something that seems reasonable, I\nwouldn't mind taking a stab at implementing it. If that sounds okay,\ncould make sure I'm pointed in the right direction? E.g., should `git\nlog --format=...` have options that spit out `git describe` strings\nsince that's what export-subst currently uses, or should there be a\nseparate $Format:...$ option that runs git describe?\n\nThanks,\nJohn\n"},{"id":"215812","messageId":"7vobcypciw.fsf@alter.siamese.dyndns.org","threadId":"33663","inReplyTo":"CAFoDJR8RQExLwXcrViAJpWgvq+wBopY-Wq1keHxVqB3QwtAz4A@mail.gmail.com","subject":"Re: `git describe` in an export-subst format string?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-28T21:32:07Z","receivedAt":"2013-04-28T21:32:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Gallagher <johnkgallagher@gmail.com> writes:\n\n> The actual thing I want to do is\n> something like this:\n>\n>   static const char *project_version = \"$Format:...$\";\n>\n> where \"...\" is something that `git archive` will replace with the\n> output of `git describe`,...\n\nYou need to find an appropriate pair of placeholders that can\nrepresent \"git describe $it\" and \"git describe --contains $it\".\n\nI am tempted to suggest a more generalized way that is not limited\nto describe at all, perhaps like this:\n\n    $ git show --format='%x( git describe %H )'\n    $ git show --format='%x( git describe --contains %H )'\n"},{"id":"215814","messageId":"7vbo8yp8t7.fsf@alter.siamese.dyndns.org","threadId":"33663","inReplyTo":"7vobcypciw.fsf@alter.siamese.dyndns.org","subject":"Re: `git describe` in an export-subst format string?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-28T22:52:20Z","receivedAt":"2013-04-28T22:52:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> John Gallagher <johnkgallagher@gmail.com> writes:\n>\n>> The actual thing I want to do is\n>> something like this:\n>>\n>>   static const char *project_version = \"$Format:...$\";\n>>\n>> where \"...\" is something that `git archive` will replace with the\n>> output of `git describe`,...\n>\n> You need to find an appropriate pair of placeholders that can\n> represent \"git describe $it\" and \"git describe --contains $it\".\n>\n> I am tempted to suggest a more generalized way that is not limited\n> to describe at all, perhaps like this:\n>\n>     $ git show --format='%x( git describe %H )'\n>     $ git show --format='%x( git describe --contains %H )'\n\nJust in case anybody takes it too seriously, this particular\nimplementaiton will never be acceptable at least for use in\n\"$Format:\" of export-subst.\n\nI am \"tempted to\" suggest, but am not crazy enough to actually doing\nso ;-).\n"}]}