Git development
 help / color / mirror / Atom feed
* Possible kinder GIT-VERSION-GEN?
@ 2008-02-04 20:28 Bill Lear
  2008-02-04 21:59 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Bill Lear @ 2008-02-04 20:28 UTC (permalink / raw)
  To: git

I have my home directory under git control, and I have a build
directory (not tracked by git) under my home directory into which I
untar files and then in which I build things, including git.

When doing this, the version reported always contains the '-dirty'
suffix, which I find annoying (and potentially misleading).  I traced
this to the GIT-VERSION-GEN script, and I "fixed" it by checking
if there is a '.git' directory present before invoking git diff-index,
something like this:

dirty=$(sh -c 'test -f .git && git diff-index --name-only HEAD' 2>/dev/null) || dirty=
case "$dirty" in
'')
        ;;
*)
        VN="$VN dirty" ;;
esac

If someone of authority here thinks this seems reasonable (or has a
better way), I will test this (along with any suggested improvements)
with the git repo itself (to ensure it puts '-dirty' when it really
should), and submit a patch.


Bill

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible kinder GIT-VERSION-GEN?
  2008-02-04 20:28 Possible kinder GIT-VERSION-GEN? Bill Lear
@ 2008-02-04 21:59 ` Junio C Hamano
  2008-02-04 22:32   ` Bill Lear
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-02-04 21:59 UTC (permalink / raw)
  To: Bill Lear; +Cc: git

Bill Lear <rael@zopyra.com> writes:

> I have my home directory under git control, and I have a build
> directory (not tracked by git) under my home directory into which I
> untar files and then in which I build things, including git.

Let me make sure I understand you by rephrasing.  You are
extracting git tarball as an untracked subdirectory in an
unrelated project, and GIT-VERSION-GEN misbehaves.  One such
misbehaviour is that it adds -dirty.

And I think you are right.  The -dirty suffix should be relative
to the output of "git describe".  Version string derived from
any other codepath should not get the suffix, simply because we
do not even know if it is dirty.  In fact, we should not even
attempt to run that diff-index to figure out if it is dirty.

---

 GIT-VERSION-GEN |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 38a3273..127c428 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -15,7 +15,9 @@ elif test -d .git &&
 	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
 	case "$VN" in
 	*$LF*) (exit 1) ;;
-	v[0-9]*) : happy ;;
+	v[0-9]*)
+		dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) &&
+		VN="$VN-dirty" ;;
 	esac
 then
 	VN=$(echo "$VN" | sed -e 's/-/./g');
@@ -25,14 +27,6 @@ fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
 
-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
-case "$dirty" in
-'')
-	;;
-*)
-	VN="$VN-dirty" ;;
-esac
-
 if test -r $GVF
 then
 	VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Possible kinder GIT-VERSION-GEN?
  2008-02-04 21:59 ` Junio C Hamano
@ 2008-02-04 22:32   ` Bill Lear
  0 siblings, 0 replies; 3+ messages in thread
From: Bill Lear @ 2008-02-04 22:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Monday, February 4, 2008 at 13:59:25 (-0800) Junio C Hamano writes:
>Bill Lear <rael@zopyra.com> writes:
>
>> I have my home directory under git control, and I have a build
>> directory (not tracked by git) under my home directory into which I
>> untar files and then in which I build things, including git.
>
>Let me make sure I understand you by rephrasing.  You are
>extracting git tarball as an untracked subdirectory in an
>unrelated project, and GIT-VERSION-GEN misbehaves.  One such
>misbehaviour is that it adds -dirty.

Yes, that is correct.

>And I think you are right.  The -dirty suffix should be relative
>to the output of "git describe".  Version string derived from
>any other codepath should not get the suffix, simply because we
>do not even know if it is dirty.  In fact, we should not even
>attempt to run that diff-index to figure out if it is dirty.

Ok, I trust you know what you are talking about with git-describe.:-)


Bill

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-04 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-04 20:28 Possible kinder GIT-VERSION-GEN? Bill Lear
2008-02-04 21:59 ` Junio C Hamano
2008-02-04 22:32   ` Bill Lear

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox