{"thread":{"id":"25523","subject":"[PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","startedAt":"2010-10-22T11:24:12Z","lastAt":"2010-10-27T14:28:53Z","messageCount":7,"participants":["Mathias Lafeldt","Jonathan Nieder","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"154135","messageId":"4CC1745C.70506@debugon.org","threadId":"25523","inReplyTo":"cover.1287746107.git.misfire@debugon.org","subject":"[PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","fromName":"Mathias Lafeldt","fromEmail":"misfire@debugon.org","sentAt":"2010-10-22T11:24:12Z","receivedAt":"2010-10-22T11:24:12Z","isPatch":true,"sender":{"key":"misfire@debugon.org","avatar":"https://avatars.githubusercontent.com/u/158074?v=4"},"body":"Currently, GIT-VERSION-GEN invokes the plumbing commands \"git update-index\" and\n\"git diff-index\" to determine if the working tree is dirty. It then appends\n\"-dirty\" to the version string returned by \"git describe\".\n\nHowever, as of Git v1.6.6, \"git describe\" can be told to do all that with the\n\"--dirty\" option, saving us the plumbing.\n\nSigned-off-by: Mathias Lafeldt <misfire@debugon.org>\n---\n GIT-VERSION-GEN |    7 ++-----\n 1 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex d441d88..73d5cf9 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -12,13 +12,10 @@ if test -f version\n then\n \tVN=$(cat version) || VN=\"$DEF_VER\"\n elif test -d .git -o -f .git &&\n-\tVN=$(git describe --match \"v[0-9]*\" --abbrev=4 HEAD 2>/dev/null) &&\n+\tVN=$(git describe --match \"v[0-9]*\" --abbrev=4 --dirty 2>/dev/null) &&\n \tcase \"$VN\" in\n \t*$LF*) (exit 1) ;;\n-\tv[0-9]*)\n-\t\tgit update-index -q --refresh\n-\t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n-\t\tVN=\"$VN-dirty\" ;;\n+\tv[0-9]*) : ;;\n \tesac\n then\n \tVN=$(echo \"$VN\" | sed -e 's/-/./g');\n-- \n1.7.3.2\n"},{"id":"154136","messageId":"4CC17465.9040100@debugon.org","threadId":"25523","inReplyTo":"cover.1287746107.git.misfire@debugon.org","subject":"[PATCH 2/3] GIT-VERSION-GEN: tweak processing of version file","fromName":"Mathias Lafeldt","fromEmail":"misfire@debugon.org","sentAt":"2010-10-22T11:24:21Z","receivedAt":"2010-10-22T11:24:21Z","isPatch":true,"sender":{"key":"misfire@debugon.org","avatar":"https://avatars.githubusercontent.com/u/158074?v=4"},"body":"- check for version file with \"test -r\"\n- read version file using shell builtin \"read\" rather than \"cat\"\n\nSigned-off-by: Mathias Lafeldt <misfire@debugon.org>\n---\n GIT-VERSION-GEN |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 73d5cf9..427d5d6 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -8,9 +8,9 @@ LF='\n \n # First see if there is a version file (included in release tarballs),\n # then try git-describe, then default.\n-if test -f version\n+if test -r version\n then\n-\tVN=$(cat version) || VN=\"$DEF_VER\"\n+\tread VN 2>/dev/null < version || VN=\"$DEF_VER\"\n elif test -d .git -o -f .git &&\n \tVN=$(git describe --match \"v[0-9]*\" --abbrev=4 --dirty 2>/dev/null) &&\n \tcase \"$VN\" in\n-- \n1.7.3.2\n"},{"id":"154138","messageId":"4CC1746D.5070907@debugon.org","threadId":"25523","inReplyTo":"cover.1287746107.git.misfire@debugon.org","subject":"[PATCH 3/3] GIT-VERSION-GEN: style nitpicks","fromName":"Mathias Lafeldt","fromEmail":"misfire@debugon.org","sentAt":"2010-10-22T11:24:29Z","receivedAt":"2010-10-22T11:24:29Z","isPatch":true,"sender":{"key":"misfire@debugon.org","avatar":"https://avatars.githubusercontent.com/u/158074?v=4"},"body":"- remove superfluous semicolon\n- simplify version comparison\n- remove empty lines at end of file\n\nSigned-off-by: Mathias Lafeldt <misfire@debugon.org>\n---\n GIT-VERSION-GEN |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 427d5d6..60bef5a 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -18,7 +18,7 @@ elif test -d .git -o -f .git &&\n \tv[0-9]*) : ;;\n \tesac\n then\n-\tVN=$(echo \"$VN\" | sed -e 's/-/./g');\n+\tVN=$(echo \"$VN\" | sed -e 's/-/./g')\n else\n \tVN=\"$DEF_VER\"\n fi\n@@ -31,9 +31,9 @@ then\n else\n \tVC=unset\n fi\n-test \"$VN\" = \"$VC\" || {\n+\n+if test \"$VN\" != \"$VC\"\n+then\n \techo >&2 \"GIT_VERSION = $VN\"\n \techo \"GIT_VERSION = $VN\" >$GVF\n-}\n-\n-\n+fi\n-- \n1.7.3.2\n"},{"id":"154154","messageId":"20101022151140.GC9224@burratino","threadId":"25523","inReplyTo":"4CC1745C.70506@debugon.org","subject":"Re: [PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-22T15:11:40Z","receivedAt":"2010-10-22T15:11:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Mathias Lafeldt wrote:\n\n> Currently, GIT-VERSION-GEN invokes the plumbing commands \"git update-index\" and\n> \"git diff-index\" to determine if the working tree is dirty. It then appends\n> \"-dirty\" to the version string returned by \"git describe\".\n> \n> However, as of Git v1.6.6, \"git describe\" can be told to do all that with the\n> \"--dirty\" option, saving us the plumbing.\n\nThis has a minor downside, which is avoiding the nice version numbers when\nbuilding Git with git 1.5.6 installed.  What is the upside?\n"},{"id":"154237","messageId":"4CC2D3B4.5030607@debugon.org","threadId":"25523","inReplyTo":"20101022151140.GC9224@burratino","subject":"Re: [PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","fromName":"Mathias Lafeldt","fromEmail":"misfire@debugon.org","sentAt":"2010-10-23T12:23:16Z","receivedAt":"2010-10-23T12:23:16Z","isPatch":true,"sender":{"key":"misfire@debugon.org","avatar":"https://avatars.githubusercontent.com/u/158074?v=4"},"body":"On 10/22/2010 05:11 PM, Jonathan Nieder wrote:\n> Mathias Lafeldt wrote:\n> \n>> Currently, GIT-VERSION-GEN invokes the plumbing commands \"git update-index\" and\n>> \"git diff-index\" to determine if the working tree is dirty. It then appends\n>> \"-dirty\" to the version string returned by \"git describe\".\n>>\n>> However, as of Git v1.6.6, \"git describe\" can be told to do all that with the\n>> \"--dirty\" option, saving us the plumbing.\n> \n> This has a minor downside, which is avoiding the nice version numbers when\n> building Git with git 1.5.6 installed.  What is the upside?\n\nThe upside is that the number of executed commands to get the version string\nis reduced from three to one.\n\nI understand your point, though it would only be a \"problem\" once when\ndoing the upgrade.\n\nIf backwards compatibility is more important here, I'd at least add a comment\nto GIT-VERSION-GEN. Something like:\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex d441d88..5c226f6 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -16,6 +16,10 @@ elif test -d .git -o -f .git &&\n        case \"$VN\" in\n        *$LF*) (exit 1) ;;\n        v[0-9]*)\n+               # As of Git v1.6.6, we can use \"git describe --dirty\" to\n+               # determine if the working tree is dirty. However, to still\n+               # have nice version numbers when building Git with older\n+               # versions of git installed, we keep using plumbing.\n                git update-index -q --refresh\n                test -z \"$(git diff-index --name-only HEAD --)\" ||\n                VN=\"$VN-dirty\" ;;\n\n-Mathias\n"},{"id":"154479","messageId":"4CC7D9CA.1080609@debugon.org","threadId":"25523","inReplyTo":"4CC2D3B4.5030607@debugon.org","subject":"Re: [PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","fromName":"Mathias Lafeldt","fromEmail":"misfire@debugon.org","sentAt":"2010-10-27T07:50:34Z","receivedAt":"2010-10-27T07:50:34Z","isPatch":true,"sender":{"key":"misfire@debugon.org","avatar":"https://avatars.githubusercontent.com/u/158074?v=4"},"body":"Mathias Lafeldt wrote:\n> On 10/22/2010 05:11 PM, Jonathan Nieder wrote:\n>> Mathias Lafeldt wrote:\n>>\n>>> Currently, GIT-VERSION-GEN invokes the plumbing commands \"git update-index\" and\n>>> \"git diff-index\" to determine if the working tree is dirty. It then appends\n>>> \"-dirty\" to the version string returned by \"git describe\".\n>>>\n>>> However, as of Git v1.6.6, \"git describe\" can be told to do all that with the\n>>> \"--dirty\" option, saving us the plumbing.\n>> This has a minor downside, which is avoiding the nice version numbers when\n>> building Git with git 1.5.6 installed.  What is the upside?\n> \n> The upside is that the number of executed commands to get the version string\n> is reduced from three to one.\n> \n> I understand your point, though it would only be a \"problem\" once when\n> doing the upgrade.\n> \n> If backwards compatibility is more important here, I'd at least add a comment\n> to GIT-VERSION-GEN. Something like:\n> \n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index d441d88..5c226f6 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -16,6 +16,10 @@ elif test -d .git -o -f .git &&\n>         case \"$VN\" in\n>         *$LF*) (exit 1) ;;\n>         v[0-9]*)\n> +               # As of Git v1.6.6, we can use \"git describe --dirty\" to\n> +               # determine if the working tree is dirty. However, to still\n> +               # have nice version numbers when building Git with older\n> +               # versions of git installed, we keep using plumbing.\n>                 git update-index -q --refresh\n>                 test -z \"$(git diff-index --name-only HEAD --)\" ||\n>                 VN=\"$VN-dirty\" ;;\n> \n\nAny feedback would be welcome.\n\n-Mathias\n"},{"id":"154492","messageId":"m3sjzriuc2.fsf@localhost.localdomain","threadId":"25523","inReplyTo":"4CC7D9CA.1080609@debugon.org","subject":"Re: [PATCH 1/3] GIT-VERSION-GEN: make use of git describe --dirty","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-10-27T14:28:53Z","receivedAt":"2010-10-27T14:28:53Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Mathias Lafeldt <misfire@debugon.org> writes:\n> Mathias Lafeldt wrote:\n\n> > diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> > index d441d88..5c226f6 100755\n> > --- a/GIT-VERSION-GEN\n> > +++ b/GIT-VERSION-GEN\n> > @@ -16,6 +16,10 @@ elif test -d .git -o -f .git &&\n> >         case \"$VN\" in\n> >         *$LF*) (exit 1) ;;\n> >         v[0-9]*)\n> > +               # As of Git v1.6.6, we can use \"git describe --dirty\" to\n> > +               # determine if the working tree is dirty. However, to still\n> > +               # have nice version numbers when building Git with older\n> > +               # versions of git installed, we keep using plumbing.\n> >                 git update-index -q --refresh\n> >                 test -z \"$(git diff-index --name-only HEAD --)\" ||\n> >                 VN=\"$VN-dirty\" ;;\n> > \n> \n> Any feedback would be welcome.\n\nI like it, also because people who use GIT-VERSION-GEN from git\nrepository as inspiration would get to know more modern technique.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}