git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Watt <jwatt@jwatt.org>
Cc: Johan Herland <johan@herland.net>,
	git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Elijah Newren <newren@gmail.com>
Subject: Re: Working copy revision and push pain
Date: Sun, 23 Mar 2008 12:42:18 -0700	[thread overview]
Message-ID: <7vhcex4485.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vd4pl713g.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Sun, 23 Mar 2008 11:21:39 -0700")

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

> Jonathan Watt <jwatt@jwatt.org> writes:
>
> My understanding is if you push into a non-bare tree in merc, they make
> the branch head into "unmerged" state, and as far as the work tree is
> concerned you are still on the previous commit, and you merge "the other
> commit" that was pushed into from sideways to update the branch tip with
> pushed-into commit.
>
> In git, if you detach HEAD when you push into a checked-out 'master', your
> work tree won't be associated with 'master' anymore, and to merge the
> pushed-into state into the history of 'master', you would need:
> ...
> The second point bothers me quite a lot, as you are assuming that the
> user at the repository that was pushed into does _not_ know what is going
> on, and may keep working on a detached HEAD _without knowing_ what is
> going on.

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

  reply	other threads:[~2008-03-23 19:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-23 12:39 Working copy revision and push pain Jonathan Watt
2008-03-23 13:02 ` Johannes Schindelin
2008-03-23 13:19   ` Jonathan Watt
2008-03-23 13:45     ` Elijah Newren
2008-03-23 13:54       ` Jonathan Watt
2008-03-23 14:06         ` Elijah Newren
2008-03-23 14:22           ` Johannes Schindelin
2008-03-23 14:48             ` Jonathan Watt
2008-03-23 14:56               ` Johannes Schindelin
2008-03-23 15:25                 ` Jonathan Watt
2008-03-23 16:00                   ` Johannes Schindelin
2008-03-25 19:25                     ` Auto detaching head options (Re: Working copy revision and push pain) Jan Hudec
2008-03-25 19:58                       ` Johannes Schindelin
2008-03-25 23:24                       ` Jeff King
2008-03-26 18:49                         ` Junio C Hamano
2008-03-29  8:27                           ` Auto detaching head options (update) " Jan Hudec
2008-03-29  8:47                             ` Jeff King
2008-03-31  1:53                               ` Junio C Hamano
2008-03-31  1:59                                 ` Jeff King
2008-03-31  2:09                                   ` Jeff King
2008-03-23 19:48             ` Working copy revision and push pain Elijah Newren
2008-03-23 14:27           ` Jonathan Watt
2008-03-23 14:34             ` Johannes Schindelin
2008-03-23 16:20               ` Johan Herland
2008-03-23 17:24                 ` Jonathan Watt
2008-03-23 18:21                   ` Junio C Hamano
2008-03-23 19:42                     ` Junio C Hamano [this message]
2008-03-23 18:23                   ` Johannes Schindelin
2008-03-24 15:22                 ` Johannes Schindelin
2008-03-24 18:00                   ` Johan Herland
2008-03-23 14:11     ` Johannes Schindelin
2008-03-23 14:35       ` Jonathan Watt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vhcex4485.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=johan@herland.net \
    --cc=jwatt@jwatt.org \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).