Re: Working copy revision and push pain

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Sunday, March 23, 2008 - 12:42 pm

Junio C Hamano <gitster@pobox.com> writes:


Let's back up a bit and try again.

I was trying to say what Mercurial presents at the UI level may be much
nicer with respect to pushing into a checked out repository.  Their notion
of 'head' (and 'branch' in general) is quite different from ours in that
their branch can have more than one 'head's that the user can choose to
merge into its 'tip', and 'push' does not update the 'tip'.  It instead
adds a new (unmerged) 'head' or fast-forwards an existing 'head', and the
user can choose to merge them into 'tip' when convenient (please correct
me here, since I am talking from my reading their documentation and I may
have misread it).

In git, a branch is just a ref and points at a single commit, and push and
fetch updates a single ref.  There is no direct notion of "these other
refs are related to this branch ref and you may want to merge them" at the
low level plumbing layer, so if you push to update a ref, git does what it
is told to do.  The branch ref is directly updated, and won't get split to
be merged back later like Mercurial does.

My objection to the "always detach HEAD automatically" is because that
solution, while it may solve the issue of work tree and HEAD getting
inconsistent silently behind user's back, would introduce more confusion.

 - The repository loses where we were (so we would add a hack to record
   which branch you were on), and operations after that silent detaching
   will _not_ advance your local branch anymore, because the push took
   over the branch 'tip'.  If you switch to some other branch, you lose.

 - The final merge happens in the wrong direction.  The other commit is
   already called the official 'tip' of the branch because push took over
   the branch 'tip', and after merging it into your stale HEAD, you have
   to update 'master' with the merge made on the detached HEAD.

 - It's your repository and the commit you were on when this push from
   sideways happened should _stay_ as the official 'tip' of the branch,
   until you tell git so.  In that sense, pushing into a non-bare
   repository's refs/heads/ hierarchy directly is conceptually wrong,
   whether the branch in question is currently checked out or not.

Although we do not have their split branch heads, we do have a similar
concept by the name of "branch tracking".  Your 'master' is marked as
being related to 'remotes/origin/master' by "git clone" and by "git
checkout -b foo remotes/origin/foo", and recent "git checkout" to switch
to such a branch will report how diverged you are from the other party.

The mothership-satellite configuration described in FAQ is about using
this facility, because "git push" into a non-bare repository is exactly a
"git fetch" run in the reverse direction (i.e. fetching to pushed-into
repository from pushed-from repository).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 5:39 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 6:02 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 6:19 am)
Re: Working copy revision and push pain, Elijah Newren, (Sun Mar 23, 6:45 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 6:54 am)
Re: Working copy revision and push pain, Elijah Newren, (Sun Mar 23, 7:06 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 7:11 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 7:22 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 7:27 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 7:34 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 7:35 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 7:48 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 7:56 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 8:25 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 9:00 am)
Re: Working copy revision and push pain, Johan Herland, (Sun Mar 23, 9:20 am)
Re: Working copy revision and push pain, Jonathan Watt, (Sun Mar 23, 10:24 am)
Re: Working copy revision and push pain, Junio C Hamano, (Sun Mar 23, 11:21 am)
Re: Working copy revision and push pain, Johannes Schindelin, (Sun Mar 23, 11:23 am)
Re: Working copy revision and push pain, Junio C Hamano, (Sun Mar 23, 12:42 pm)
Re: Working copy revision and push pain, Elijah Newren, (Sun Mar 23, 12:48 pm)
Re: Working copy revision and push pain, Johannes Schindelin, (Mon Mar 24, 8:22 am)
Re: Working copy revision and push pain, Johan Herland, (Mon Mar 24, 11:00 am)
Re: Auto detaching head options (Re: Working copy revision ..., Johannes Schindelin, (Tue Mar 25, 12:58 pm)