git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH B] GIT-VERSION-GEN: refresh the index before judging a working dir to be dirty

From
CJChristian Jaeger <christian@jaeger.mine.nu>
Date
Aug 7, 2008, 17:59 UTC
Message-ID
<a921f9287bf93b1f4de21968ee02a06fe69198a8.1218137290.git.christian@jaeger.mine.nu>
In-Reply-To
<sjj6zt28jy9qy7y8@jaeger.mine.nu>

When building under the control of the "fakeroot" tool [*], as is the case when building a Debian package using "dpkg-buildpackage -rfakeroot", GIT-VERSION-GEN appended "-dirty" to the version number; this happens because "git diff-index --name-only HEAD --" would report all files as changed if they have a non-root owner/group, since they appear as owned by root under fakeroot, leading to non-empty output. Refreshing the index first makes the decision based on content changes only.

[*] http://fakeroot.alioth.debian.org/
Signed-off-by: Christian Jaeger <christian@jaeger.mine.nu>
---
 GIT-VERSION-GEN |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index cb7cd4b..fb3e2d8 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -17,6 +17,12 @@ elif test -d .git -o -f .git &&
 	*$LF*) (exit 1) ;;
 	v[0-9]*)
 		test -z "$(git diff-index --name-only HEAD --)" ||
+		{
+			# some metadata of files has changed; what
+			# about the contents?
+			git update-index --refresh
+			test -z "$(git diff-index --name-only HEAD --)"
+		} ||
 		VN="$VN-dirty" ;;
 	esac
 then
-- 
1.6.0.rc2.1.g7e734
Previous: Christian JaegerNext: Junio C Hamano
Message 3 of 5 in “GIT-VERSION-GEN gives "-dirty" when file metadata changed”
  1. Christian JaegerAug 7, 2008
  2. GIT-VERSION-GEN: refresh the index before judging a working dir to be dirtyChristian Jaeger, Aug 7, 2008
  3. GIT-VERSION-GEN: refresh the index before judging a working dir to be dirtyChristian Jaeger, Aug 7, 2008
  4. Junio C HamanoAug 7, 2008
  5. Christian JaegerAug 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.