From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Neal Kreitzinger <nkreitzinger@gmail.com>, git@vger.kernel.org
Subject: Re: who's on first? - following first parent and merge-management
Date: Thu, 8 Mar 2012 02:14:03 -0500 [thread overview]
Message-ID: <20120308071403.GE7643@sigill.intra.peff.net> (raw)
In-Reply-To: <7vty1zfwmd.fsf@alter.siamese.dyndns.org>
On Wed, Mar 07, 2012 at 10:13:46PM -0800, Junio C Hamano wrote:
> If you are a purist, you could instead do this when "git push" is
> rejected in the original sequence:
>
> $ git reset --hard HEAD^ ;# cancel the merge of mywork
> $ git pull --ff-only ;# get the updated tip of shared history
> $ git merge mywork
> $ test
> $ git push
This gave me an idea that I think is probably crazy, but that I hadn't
seen mentioned before.
What if the user could specify a partial ordering of refs, and we used
that order when listing merge parents in the resulting commit. So for
example, if you said that:
refs/remotes/origin/master > refs/heads/master
then doing:
$ git checkout master
$ git pull origin master
would result in a "flipped" merge commit, with origin/master as the
first parent, and master as the second. That makes the CVS-style
central workflow (i.e. "oops, somebody else pushed, I'll just pull &&
push") follow the first-parent flow that people expect.
You could extend it to topic branches, too ("refs/heads/master >
refs/heads/jk/*"). Of course, depending on your workflow, you might
_want_ to have them flipped. I.e., when it is not just laziness or lack
of understanding, and you really are making a merge commit to say "topic
XYZ depends on something that is now in master, so let's merge that in
before continuing topic development".
So I think the primary audience would be people doing clueless
centralized-repo development. Of course you'd perhaps want to flip the
merge message, too. And I do think people are overly-interested in
--first-parent in the first place, so the effort of specifying the
parent ordering like this is probably not worth it.
I think when people ask about --first-parent, what they really want to
say is "what happened on branch X, and what happened on this other
branch". I wonder if we would do better to annotate the ref name of each
side of the merge, and then people could follow a particular ref through
history if they felt like it. That feels very un-git, as the DAG
fundamentally does not care about the ref names. On the other hand,
people do care, and we actually do have that information already in our
stock merge commit messages
What if we had something like "git log --follow-branch=master", and it
was implemented something like:
if commit has no parents
add nothing to traversal
else if commit has one parent
consider parent for traversal (subject to usual UNINTERESTING, etc)
else
match commit message against /Merge branch '(.*)'( into (.*))?/
if $2 is empty, then set $2 to 'master'
if $1 is 'master', add parent 2 to traversal
if $2 is 'master', add parent 1 to traversal
IOW, mine the commit messages to make a guess about the original state.
I wonder how well it would work in practice. Git lets you do funny
things like merge on a detached HEAD and assign the result to a ref.
That may give you an odd merge message, but that's OK, because nothing
is parsing it. But it would break a traversal like this.
Like I said, I think these probably crazy ideas, but they were
interesting enough to me to think through. Maybe they will inspire
something not-crazy from somebody else. :)
-Peff
next prev parent reply other threads:[~2012-03-08 7:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 5:36 who's on first? - following first parent and merge-management Neal Kreitzinger
2012-03-07 7:37 ` Junio C Hamano
2012-03-08 6:13 ` Junio C Hamano
2012-03-08 7:14 ` Jeff King [this message]
2012-03-08 7:38 ` Junio C Hamano
2012-03-08 8:03 ` Johannes Sixt
2012-03-08 17:30 ` Junio C Hamano
2012-03-09 12:05 ` Holger Hellmuth
2012-03-09 12:29 ` Johannes Sixt
2012-03-09 13:25 ` Holger Hellmuth
2012-03-09 16:26 ` Junio C Hamano
2012-03-08 7:49 ` Jonathan Nieder
2012-03-08 22:52 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120308071403.GE7643@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nkreitzinger@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).