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

Re: [PATCH] Fix pulling into the same branch.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 27, 2005, 03:31 UTC
Message-ID
<7vzmr43vix.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<B8E391BBE9FE384DAA4C5C003888BE6F043BA469@scsmsx401.amr.corp.intel.com>
"Luck, Tony" <tony.luck@intel.com> writes:
Show 7 quoted lines
>>In the meantime, warning the user about the issue and suggesting
>>how to do the fast-forwarding of the working tree himself in the
>>warning message might be the safest and the most sensible thing
>>to do.
>
> Yes please ... a big fat warning with coloured flashing lights
> and explosions from the sound card.

Yeah, but what to do afterwards? I can see this as an compromise:

 * "git fetch", just like the updated "git pull", reads
   $GIT_DIR/HEAD before it starts its work, and compares it with
   $GIT_DIR/HEAD after it is done.  If the --update-head-ok flag
   is not given on the command line, and if the HEAD changed,
   then barf and exit with non-zero status after reverting
   $GIT_DIR/HEAD to its original value.  If --update-head-ok is
   given, none of the above check and revert happens.
 * "git pull" calls "git fetch" with the extra flag, and does
   its thing the current way.

So if you are calling from the command line, "git fetch linus", when you were still on "linus" branch (which you do not normally do but just to prevent mistakes), it would trigger the check and your $GIT_DIR/HEAD would stay intact. If you stayed on your own branch, "git fetch linus" would continue to just fast forward "linus" head without touching the working tree.

Come to think of it, it may be cleaner to simply forbid fast-forward fetching into the current repository (whether it is "git fetch" or "git pull"). At least in your workflow you do not do that ever anyway.

Johannes, what do you think, as the original advocate of "push in reverse"?

Previous: Luck, TonyNext: Johannes Schindelin
Message 2 of 7 in “RE: [PATCH] Fix pulling into the same branch.”
  1. Luck, TonyAug 26, 2005
  2. Junio C HamanoAug 27, 2005
  3. Johannes SchindelinSep 11, 2005
  4. Junio C HamanoSep 11, 2005
  5. Linus TorvaldsSep 11, 2005
  6. Junio C HamanoSep 11, 2005
  7. Johannes SchindelinSep 11, 2005

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.