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

Re: Fix recent 'unpack_trees()'-related changes breaking 'git stash'

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 15, 2008, 04:40 UTC
Message-ID
<alpine.LFD.1.00.0803142133160.3557@woody.linux-foundation.org>
In-Reply-To
<alpine.LFD.1.00.0803142023490.3557@woody.linux-foundation.org>
On Fri, 14 Mar 2008, Linus Torvalds wrote:
> 
> The trivial fix is to just copy the index timestamp from the source index 
> into the result index. But we only do this if we *have* a source index, of 
> course, and if we will even bother to use the result.

Actually, that second part of the test is just unnecessarily clever, and it's just asking for trouble.

Even if we never use the "result" for anything in the end, it's probably a good idea to have its timestamp match the source timestamp just in case somebody wants to do the "is_racy_timestamp()" on the result while it's being generated (and before it is thrown away).

In particular, it would not be necessarily wrong to use ie_match_stat() on the result index in a callback.

So it might be better to make that thing be just
>  	memset(&o->result, 0, sizeof(o->result));
> +	if (o->src_index)
> +		o->result.timestamp = o->src_index->timestamp;
>  	o->merge_size = len;

instead of checking both src_index *and* dst_index. The source index is all that matters anyway. Even if 'o->result' isn't used in the end, who cares? We can still give it the right timestamp.

And no, this really isn't likely to matter, but let's pick the simpler version if it doesn't matter.

		Linus
Previous: Linus TorvaldsNext: Szeder Gábor
Message 3 of 8 in “recent 'unpack_trees()'-related changes break 'git stash'”
  1. SZEDER GáborMar 15, 2008
  2. Fix recent 'unpack_trees()'-related changes breaking 'git stash'Linus Torvalds, Mar 15, 2008
  3. Linus TorvaldsMar 15, 2008
  4. Szeder GáborMar 15, 2008
  5. Junio C HamanoMar 15, 2008
  6. Szeder GáborMar 15, 2008
  7. Linus TorvaldsMar 15, 2008
  8. git-stash: use git-read-tree --index-output optionしらいしななこ, Mar 30, 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.