threads / patch / 1662

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

Subject: RE: [PATCH] Fix pulling into the same branch.

## tl;dr

7 messages between Aug 26, 2005 and Sep 11, 2005. Diffs are folded; open one to read it.

replies: 6people: 4as markdown or json

Luck, Tony· Aug 26, 2005, 18:13 UTC · lore
Show 5 quoted lines
>I am tempted to move this logic to "git fetch" instead, because
>it has the same issue.  Tony's "linus" branch example has been
>updated to do a "git fetch" instead of "git pull" from the
>earlier description in his howto, but if he happens to be on the
>"linus" branch, he would still have this same problem.

I don't spend much time on the linus branch (just to build an updated cscope database, etc.). I never want to check anything in on that branch [sometime I should figure out how use the "hooks" to keep me from shooting myself in the foot here].

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

-Tony
Junio C Hamano· Aug 27, 2005, 03:31 UTC · re: Luck, Tony · lore

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

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

Johannes Schindelin· Sep 11, 2005, 09:56 UTC · re: Junio C Hamano · lore

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

Hi,
On Fri, 26 Aug 2005, Junio C Hamano wrote:
Show 7 quoted lines
> 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"?
I'm fine with it.

Although it might make more sense to check for dirty state, and fast-forward only for a clean state (together with a checkout of the new HEAD).

Ciao, Dscho

Junio C Hamano· Sep 11, 2005, 17:36 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> On Fri, 26 Aug 2005, Junio C Hamano wrote:
>
>> Johannes, what do you think, as the original advocate of "push in
>> reverse"?
>
> I'm fine with it.
Wow, blast from the past ;-).
> Although it might make more sense to check for dirty state, and 
> fast-forward only for a clean state (together with a checkout of the new 
> HEAD).

Yes, but the issue becomes how we can reliably tell if a repository is naked or has an associated working tree. I've seen people rsync only .git subdirectory of their live working tree to publish to a public repository, which means their pulic repository has <project>.git/index file, so it is kind of tricky.

Linus Torvalds· Sep 11, 2005, 17:58 UTC · re: Junio C Hamano · lore

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

On Sun, 11 Sep 2005, Junio C Hamano wrote:
> 
> Yes, but the issue becomes how we can reliably tell if a
> repository is naked or has an associated working tree.
You can't "git pull" into a naked thing anyway. And
	git-read-tree -m -u <old-head> <new-head>

should always do the right thing (ie if there is dirty state that would be updated, it will fail gracefully).

Or did I miss something?
		Linus
Junio C Hamano· Sep 11, 2005, 18:41 UTC · re: Linus Torvalds · lore

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

Linus Torvalds <torvalds@osdl.org> writes:
Show 13 quoted lines
> On Sun, 11 Sep 2005, Junio C Hamano wrote:
>> 
>> Yes, but the issue becomes how we can reliably tell if a
>> repository is naked or has an associated working tree.
>
> You can't "git pull" into a naked thing anyway. And
>
> 	git-read-tree -m -u <old-head> <new-head>
>
> should always do the right thing (ie if there is dirty state that would be
> updated, it will fail gracefully).
>
> Or did I miss something?
No, I just stated my view poorly.

You cannot do pull into a naked one, but you can still fetch into it. My comment Johannes was responding to was what to do when you do 'git fetch' into the repository associated with your working tree and your branch is fast forwarded. We obviously want to prevent it from happening. However, it is OK to do so if the fetch is happening into a naked one and I was wondering if there is a reliable way to tell that situation and allowing that.

Johannes Schindelin· Sep 11, 2005, 23:15 UTC · re: Junio C Hamano · lore

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

Hi,
On Sun, 11 Sep 2005, Junio C Hamano wrote:
Show 10 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Fri, 26 Aug 2005, Junio C Hamano wrote:
> >
> >> Johannes, what do you think, as the original advocate of "push in
> >> reverse"?
> >
> > I'm fine with it.
> 
> Wow, blast from the past ;-).

Sorry, I tried to relax for two weeks. That didn't work, though (pun intended).

Show 10 quoted lines
> > Although it might make more sense to check for dirty state, and 
> > fast-forward only for a clean state (together with a checkout of the new 
> > HEAD).
> 
> Yes, but the issue becomes how we can reliably tell if a
> repository is naked or has an associated working tree.  I've
> seen people rsync only .git subdirectory of their live working
> tree to publish to a public repository, which means their pulic
> repository has <project>.git/index file, so it is kind of
> tricky.

I think it is easy to discern the two states "up to date checkout" and "dirty checkout or no checkout at all". But then, you're right: git fetch should not touch the working copy.

Ciao, Dscho

← back to recent threads