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

Re: Unusual behavior from git describe

From
Jeff King <peff@peff.net>
Date
Jul 31, 2011, 06:20 UTC
Message-ID
<20110731062055.GB14384@sigill.intra.peff.net>
In-Reply-To
<CA+jCPNfsQ2oqDzTpJL4ck0vNBJnfXwb+aaSrzStrs55kq+CTHA@mail.gmail.com>
On Sat, Jul 30, 2011 at 12:23:30PM -0400, Allan Caffee wrote:
Show 11 quoted lines
> 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
> [...]
> It looks like this was caused by setuptools hardlinking files into a
> temp directory and then deleting the links, as demonstrated by:

Yeah, that would modify the file's ctime, which is part of what git uses to check whether its stat-cache is fresh.

The problem is that we call the diff-index plumbing to determine the dirty state, but it expects the index to have been refreshed already. Describe is probably porcelain-ish enough that it should be doing the refresh for the user and writing the result out (at least if the --dirty flag is passed, as otherwise it doesn't care), just as porcelains like "diff" and "status" do.

> 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?

You call refresh_index, but you never actually load the index in the first place. So nothing gets refreshed. If you add a call to read_cache just beforehand, it works as you expect.

However, if describe is going to the trouble to refresh the index, it should probably actually write out the result. In that case, you would want to emulate what cmd_status does in builtin/commit.c, which writes out the new index via update_index_if_able.

-Peff
Previous: Allan CaffeeNext: Allan Caffee
Message 6 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.