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

Re: aborted 'git fetch' leaves workspace unusable

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 3, 2014, 17:58 UTC
Message-ID
<xmqqsit5lzfw.fsf@gitster.dls.corp.google.com>
In-Reply-To
<85iou13fse.fsf@stephe-leake.org>
Stephen Leake <stephen_leake@stephe-leake.org> writes:
Show 25 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> stephen_leake@stephe-leake.org writes:
>>
>>> However, in this case, even running the fetch was a mistake; I would
>>> have prefered that it leave FETCH_HEAD in its previous state.
>>
>> I think the clearing of leftover FETCH_HEAD is one of the early
>> things "git fetch" does, unless "--append" is in effect.  I haven't
>> looked at the code for a long time, but it may be possible to move
>> the logic of doing so around so that this clearing is done as lazily
>> as possible.
>>
>> I however suspect that such a change may have fallouts on other
>> people who are writing tools like yours; they may be depending on
>> seeing FETCH_HEAD cleared after a failed fetch, and be surprised to
>> see a stale contents after they (attempt to) run "git fetch" in it.
>>
>> So it is not so clear if it is a good thing to change the behaviour
>> of "git fetch" not to touch FETCH_HEAD upon a failure.
>
> Ok; backwards compatibility is important.
>
> Perhaps FETCH_HEAD could be copied to FETCH_HEAD_prev or some such, to
> allow recovering in an error case?

As FETCH_HEAD is purely ephemeral (so are other ephemeral markers like MERGE_HEAD and friends), and the promise between "git fetch" and its users has always been that an invocation of "git fetch" clears FETCH_HEAD (logical consequence of which is that the user runs "git fetch" only when s/he are _done_ with the old FETCH_HEAD), I doubt FETCH_HEAD_prev would add much value to the system and only introduce more things we have to worry about, like "when will it be cleaned?", "what happens to the old value in FETCH_HEAD_prev?".

It is like asking "Should 'rm -f foo' save the original 'foo' to somewhere else just in case?".

If your emacs wrapper for some reason needs to know what happened in the last fetch, I imagine that it can check and record what was in FETCH_HEAD before issuing "git fetch", so...

Previous: Stephen Leake
Message 4 of 4 in “Re: aborted 'git fetch' leaves workspace unusable”
  1. stephen_leake@stephe-leake.orgDec 31, 2013
  2. Junio C HamanoJan 2, 2014
  3. Stephen LeakeJan 3, 2014
  4. Junio C HamanoJan 3, 2014

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.