{"thread":{"id":"11885","subject":"Possible kinder GIT-VERSION-GEN?","startedAt":"2008-02-04T20:28:48Z","lastAt":"2008-02-04T22:32:10Z","messageCount":3,"participants":["Bill Lear","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"67415","messageId":"18343.30080.67524.3427@lisa.zopyra.com","threadId":"11885","inReplyTo":null,"subject":"Possible kinder GIT-VERSION-GEN?","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2008-02-04T20:28:48Z","receivedAt":"2008-02-04T20:28:48Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"I have my home directory under git control, and I have a build\ndirectory (not tracked by git) under my home directory into which I\nuntar files and then in which I build things, including git.\n\nWhen doing this, the version reported always contains the '-dirty'\nsuffix, which I find annoying (and potentially misleading).  I traced\nthis to the GIT-VERSION-GEN script, and I \"fixed\" it by checking\nif there is a '.git' directory present before invoking git diff-index,\nsomething like this:\n\ndirty=$(sh -c 'test -f .git && git diff-index --name-only HEAD' 2>/dev/null) || dirty=\ncase \"$dirty\" in\n'')\n        ;;\n*)\n        VN=\"$VN dirty\" ;;\nesac\n\nIf someone of authority here thinks this seems reasonable (or has a\nbetter way), I will test this (along with any suggested improvements)\nwith the git repo itself (to ensure it puts '-dirty' when it really\nshould), and submit a patch.\n\n\nBill\n"},{"id":"67434","messageId":"7vve54ids2.fsf@gitster.siamese.dyndns.org","threadId":"11885","inReplyTo":"18343.30080.67524.3427@lisa.zopyra.com","subject":"Re: Possible kinder GIT-VERSION-GEN?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-04T21:59:25Z","receivedAt":"2008-02-04T21:59:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bill Lear <rael@zopyra.com> writes:\n\n> I have my home directory under git control, and I have a build\n> directory (not tracked by git) under my home directory into which I\n> untar files and then in which I build things, including git.\n\nLet me make sure I understand you by rephrasing.  You are\nextracting git tarball as an untracked subdirectory in an\nunrelated project, and GIT-VERSION-GEN misbehaves.  One such\nmisbehaviour is that it adds -dirty.\n\nAnd I think you are right.  The -dirty suffix should be relative\nto the output of \"git describe\".  Version string derived from\nany other codepath should not get the suffix, simply because we\ndo not even know if it is dirty.  In fact, we should not even\nattempt to run that diff-index to figure out if it is dirty.\n\n---\n\n GIT-VERSION-GEN |   12 +++---------\n 1 files changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 38a3273..127c428 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -15,7 +15,9 @@ elif test -d .git &&\n \tVN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n \tcase \"$VN\" in\n \t*$LF*) (exit 1) ;;\n-\tv[0-9]*) : happy ;;\n+\tv[0-9]*)\n+\t\tdirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) &&\n+\t\tVN=\"$VN-dirty\" ;;\n \tesac\n then\n \tVN=$(echo \"$VN\" | sed -e 's/-/./g');\n@@ -25,14 +27,6 @@ fi\n \n VN=$(expr \"$VN\" : v*'\\(.*\\)')\n \n-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=\n-case \"$dirty\" in\n-'')\n-\t;;\n-*)\n-\tVN=\"$VN-dirty\" ;;\n-esac\n-\n if test -r $GVF\n then\n \tVC=$(sed -e 's/^GIT_VERSION = //' <$GVF)\n"},{"id":"67440","messageId":"18343.37482.618436.999319@lisa.zopyra.com","threadId":"11885","inReplyTo":"7vve54ids2.fsf@gitster.siamese.dyndns.org","subject":"Re: Possible kinder GIT-VERSION-GEN?","fromName":"Bill Lear","fromEmail":"rael@zopyra.com","sentAt":"2008-02-04T22:32:10Z","receivedAt":"2008-02-04T22:32:10Z","isPatch":false,"sender":{"key":"rael@zopyra.com","avatar":"https://gravatar.com/avatar/c4f2d2790ca3828d3b4e7dfebabf61d2fe94fd82fa49cdac2a5295dd2d46a874?d=mp&s=160"},"body":"On Monday, February 4, 2008 at 13:59:25 (-0800) Junio C Hamano writes:\n>Bill Lear <rael@zopyra.com> writes:\n>\n>> I have my home directory under git control, and I have a build\n>> directory (not tracked by git) under my home directory into which I\n>> untar files and then in which I build things, including git.\n>\n>Let me make sure I understand you by rephrasing.  You are\n>extracting git tarball as an untracked subdirectory in an\n>unrelated project, and GIT-VERSION-GEN misbehaves.  One such\n>misbehaviour is that it adds -dirty.\n\nYes, that is correct.\n\n>And I think you are right.  The -dirty suffix should be relative\n>to the output of \"git describe\".  Version string derived from\n>any other codepath should not get the suffix, simply because we\n>do not even know if it is dirty.  In fact, we should not even\n>attempt to run that diff-index to figure out if it is dirty.\n\nOk, I trust you know what you are talking about with git-describe.:-)\n\n\nBill\n"}]}