git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: FETCH_HEAD question
Date: Tue, 17 Feb 2009 00:35:54 -0800	[thread overview]
Message-ID: <7vy6w5795h.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <76718490902162341y2f122427i470c77d3915ff554@mail.gmail.com> (Jay Soffian's message of "Tue, 17 Feb 2009 02:41:15 -0500")

Jay Soffian <jaysoffian@gmail.com> writes:

> So then, why does "git merge FETCH_HEAD" bother to strip out a
> not-for-merge marker that wouldn't be there?

In general, FETCH_HEAD is usable as an extended SHA-1, in that any file
that is in .git/ and begins with [0-9a-f]{40} names that object.  That is
how "git log -p ..FETCH_HEAD" in my example worked.

The reason stripping of not-for-merge is done is to support a usage that
is not so sane as well.

You can do a wildcard fetch that leaves full of not-for-merge entries in
FETCH_HEAD, and then use FETCH_HEAD as an extended SHA-1 to merge the one
that happens to be on the first line.  "git merge" *could* in such a case
produce:

	Merge commit $ugly_40_hexadecimal_name

to say that it merged that commit named by a random extended SHA-1, but it
knows that FETCH_HEAD has better information than that.  The line tells
where you got that commit from.  And that is recorded past not-for-merge
marker (if exists, otherwise it is an empty string) that is enclosed by a
HT on each side.  This is a direct translation from the scripted version
that did:

	sed -e 's/	not-for-merge	/		/' -e 1q

It is being overly nice to produce a sensible merge message, even when you
asked it to do something not very sensible.

Now to something totally useless.

After reading the builtin-merge.c and original git-merge.sh (now in
contrib/examples) script, I think it could have done something entirely
different.

It could have done this instead.

	sed -e '/	not-for-merge	/d'

to learn the commits and their human-readable origins, and it could have
tried to reproduce what "git pull" did when it invoked git-merge using
that information.  Then you could use this workflow:

	$ git pull <possibly with arguments>
        ... oops, conflicted and is very messy.
        ... I tried to resolve, but failed and made the mess even worse.
        ... Let's start over.
        $ git reset --hard
        ... FETCH_HEAD knows which refs are for merging
        $ git merge FETCH_HEAD

That is, no matter what the arguments were for the initial "git pull",
what should be merged is recorded in FETCH_HEAD, and that is how you can
retry the merge without refetching over the network.

But such a change makes FETCH_HEAD different from what it traditionally
meant, and does that only to "git merge", making the result very
inconsistent.  For example, "git log ..FETCH_HEAD" will still use the
object name on the first line, and it won't be a way to convince yourself
that the changes are sensible and it is Ok to run "git merge FETCH_HEAD"
anymore.  So I do not think such a change will be an improvement.

  reply	other threads:[~2009-02-17  8:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17  4:43 FETCH_HEAD question Jay Soffian
2009-02-17  5:11 ` Jay Soffian
2009-02-17  5:36 ` Junio C Hamano
2009-02-17  6:21   ` Jay Soffian
2009-02-17  7:18     ` Junio C Hamano
2009-02-17  7:41       ` Jay Soffian
2009-02-17  8:35         ` Junio C Hamano [this message]
2009-02-17 17:14           ` Jay Soffian
2009-02-17 17:22             ` Johannes Schindelin
2009-02-17 17:34               ` Jay Soffian
2009-02-17 22:58                 ` PUSH_HEAD, was " Johannes Schindelin
2009-02-17 23:43                   ` Junio C Hamano
2009-02-18  0:29                     ` Jay Soffian
2009-02-18  0:30                     ` Johannes Schindelin
2009-02-17  8:25     ` Sitaram Chamarty

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=7vy6w5795h.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jaysoffian@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).