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

Determining if a tree is clean

From
Adam Mercer <ramercer@gmail.com>
Date
Mar 6, 2010, 15:12 UTC
Message-ID
<799406d61003060712t120d7f11me6e2ab212c55271@mail.gmail.com>
Hi

In one of the projects I work in we have a script which creates a header file containing various commit information, such as the id of the HEAD commit, the date it was committed, who made the commit, and if the tree is clean (i.e. no uncommitted changes). In order to determine if the tree is clean we use the command

git diff-index --quiet HEAD

and if the this exits with a non-zero return code then we assume that the tree is unclean. However I have found a case when this exits with a return code of 1 when the tree has no uncommitted changes, e.g.:

$ git diff-index --quiet HEAD $ echo $? 1 $

and when I look at what file it thinks is unclean I get:

$ git diff-index HEAD :100644 100644 3b839718d3f182119db5d9e2b88e516e02ecc00b 0000000000000000000000000000000000000000 M lal/include/lal/LALConfig.h.in $ git diff-index -p HEAD

diff --git a/lal/include/lal/LALConfig.h.in b/lal/include/lal/LALConfig.h.in
$

which shows no changes in the actual file. This file is the template
for a header created using the AC_CONFIG_HEADERS() autoconf macro.
From the above it looks like the build process has created a new file
with exactly the same contents as the file specifies in the index. Is
there a way that I can tell git-diff-index that this is OK? Or is
there another way I can determine if the tree has any uncommitted
changes?

I'm seeing this with git-1.7, on Mac OS X 10.6, and git-1.5.5.6, on RHEL5.

Cheers

Adam
Next: Junio C Hamano
Message 1 of 3 in “Determining if a tree is clean”
  1. Adam MercerMar 6, 2010
  2. Junio C HamanoMar 6, 2010
  3. Adam MercerMar 6, 2010

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.