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

Re: Unusual behavior from git describe

From
Allan Caffee <allan.caffee@gmail.com>
Date
Jul 30, 2011, 16:23 UTC
Message-ID
<CA+jCPNfsQ2oqDzTpJL4ck0vNBJnfXwb+aaSrzStrs55kq+CTHA@mail.gmail.com>
In-Reply-To
<CAGdFq_imU3_=E1LK-AG33Tj70iOJBTmt2_qdUKVHL9DVW2yJRQ@mail.gmail.com>
On Sat, Jul 30, 2011 at 9:32 AM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Does it perhaps touch some of the tracked files? That way it would
> make sense git at first thinks it's dirty (since the lstat info
> changed), but then 'git status' will actually check the contents of
> the file and notice that they're equal? Just guessing here though.

Sounds like you're on the right track. git diff-index reveals that the index is stale

========>8==============>8========= :100644 100644 781975ec321be574e0b016c9e699804430a4cefc 0000000000000000000000000000000000000000 M MANIFEST.in :100644 100644 bddeac47f9d67e8496a7e1d76f3e024e644ee332 0000000000000000000000000000000000000000 M fabfile.py ... :100644 100644 4f09e2dbb7b0b7aeb0063468bd1931e5c969d2d6 0000000000000000000000000000000000000000 M flaskapi/__init__.py :100644 100644 e4cc0de216a9c5a68ca87650bbe0be24f327df27 0000000000000000000000000000000000000000 M version.py ===============>8==============>8==

It looks like this was caused by setuptools hardlinking files into a temp directory and then deleting the links, as demonstrated by:

% git diff-index HEAD -- % ln MANIFEST.in file && rm file % git diff-index HEAD -- :100644 100644 781975ec321be574e0b016c9e699804430a4cefc 0000000000000000000000000000000000000000 M MANIFEST.in

I've tried adding a call to refresh_index() in describe.c but it doesn't seem to have any effect on the results. (Patch below.) Any idea what the proper fix is for this?

-- Allan

diff --git a/builtin/describe.c b/builtin/describe.c
index 66fc291..73e98ed 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -462,8 +462,11 @@ int cmd_describe(int argc, const char **argv,
const char *prefix)
                die(_("No names found, cannot describe anything."));

        if (argc == 0) {
-               if (dirty &&
!cmd_diff_index(ARRAY_SIZE(diff_index_args) - 1, diff_index_args,
prefix))
-                       dirty = NULL;
+               if (dirty) {
+                   refresh_index(&the_index,
REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
+                   if (!cmd_diff_index(ARRAY_SIZE(diff_index_args) -
1, diff_index_args, prefix))
+                           dirty = NULL;
+               }
                describe("HEAD", 1);
        } else if (dirty) {
                die(_("--dirty is incompatible with committishes"));
Previous: Sverre RabbelierNext: Jeff King
Message 5 of 10 in “Unusual behavior from git describe”
  1. Allan CaffeeJul 29, 2011
  2. Sverre RabbelierJul 29, 2011
  3. Allan CaffeeJul 30, 2011
  4. Sverre RabbelierJul 30, 2011
  5. Allan CaffeeJul 30, 2011
  6. Jeff KingJul 31, 2011
  7. describe: Refresh the index when run with --dirtyAllan Caffee, Aug 1, 2011
  8. Jeff KingAug 1, 2011
  9. Junio C HamanoAug 2, 2011
  10. Allan CaffeeAug 2, 2011

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.