[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Really update the git index to avoid false -dirty versions
From: |
Jim Meyering |
Subject: |
Re: [PATCH] Really update the git index to avoid false -dirty versions |
Date: |
Mon, 12 Apr 2010 20:11:34 +0200 |
Andreas Gruenbacher wrote:
> On Monday 12 April 2010 19:38:07 Jim Meyering wrote:
>> Andreas Gruenbacher wrote:
>> > On Monday 12 April 2010 18:25:01 Jim Meyering wrote:
>> >> Can you describe a scenario in which
>> >> using "git update-index --refresh" makes
>> >> git-version-gen work better than with "git status"?
>> >> In the example I tried (touch an unmodified, vc'd file),
>> >> they appear to have the same net effect.
>> >
>> > I can't pinpoint it. In some versions or configurations of git, git
> status
>> > seems to be enough, but I get the following here with git
> 1.7.0.2.273.gc2413:
>> >
>> > $ git diff-index --name-only HEAD
>> > $ touch README
>> > $ git diff-index --name-only HEAD
>> > README
>> > $ git status > /dev/null
>> > $ git diff-index --name-only HEAD
>> > README
>> > $ git update-index --refresh
>> > $ git diff-index --name-only HEAD
>>
>> Yes, that's exactly what I tried.
>> Only for me (with git's "next"), they work as well.
>>
>> $ git diff-index --name-only HEAD
>> $ touch README
>> $ git diff-index --name-only HEAD
>> README
>> $ git status > /dev/null
>> $ git diff-index --name-only HEAD
>> $ git --version
>> git version 1.7.1.rc1.237.ge1730
>
> I see ... given that "git update-index" is documented to do exactly what git-
> version-gen want to do while "git status" does that only as a side effect, and
> apparently only sometimes, would it make sense to switch to "git update-
> index"?
Yes, that is cleaner, too. Thanks.
I've adjusted the log, added a matching (duplicate) ChangeLog entry
and pushed this:
>From 0ff2040cb94233daffca8706a97774af3afd7a3c Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <address@hidden>
Date: Mon, 12 Apr 2010 17:56:27 +0200
Subject: [PATCH] git-version-gen: use "git update-index..." rather than "git
status"
* build-aux/git-version-gen: Use git update-index --refresh, not
"git status". With some versions of git, "git status" would fail
to update the index and result in an unwarranted "-dirty" suffix.
---
ChangeLog | 7 +++++++
build-aux/git-version-gen | 2 +-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8dc4d2c..73c6e30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-12 Andreas Gruenbacher <address@hidden>
+
+ git-version-gen: use "git update-index..." rather than "git status"
+ * build-aux/git-version-gen: Use git update-index --refresh, not
+ "git status". With some versions of git, "git status" would fail
+ to update the index and result in an unwarranted "-dirty" suffix.
+
2010-04-11 Jim Meyering <address@hidden>
openat: correct formatting (no semantic change)
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 16da2a8..e754c77 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -127,7 +127,7 @@ fi
v=`echo "$v" |sed 's/^v//'`
# Don't declare a version "dirty" merely because a time stamp has changed.
-git status > /dev/null 2>&1
+git update-index --refresh > /dev/null 2>&1
dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
case "$dirty" in
--
1.7.1.rc1.237.ge1730