git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Darrin Thompson <darrint@progeny.com>
Cc: git@vger.kernel.org
Subject: Re: Merges without bases
Date: Thu, 25 Aug 2005 15:26:36 -0700	[thread overview]
Message-ID: <7vvf1tps9v.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <1125004228.4110.20.camel@localhost.localdomain> (Darrin Thompson's message of "Thu, 25 Aug 2005 16:10:28 -0500")

Darrin Thompson <darrint@progeny.com> writes:

> I have a weird situation I want to support. I want to be able to merge a
> foreign-tree repeatedly.
>
> What makes the foreign tree foreign is that it may not yet share any
> history with this branch.

I believe that's exactly what Linus did when he merged gitk into
git.  As you discovered, the initial one could easily be
scripted, if you wanted to, with something like this:

        #!/bin/sh
        #
        # git-merge-projects-script
        #
        . git-sh-setup-script || die "Not a git archive."

        foreign_project="$1"
        head=`git-rev-parse --verify HEAD` &&
        foreign=`git-rev-parse --verify $foreign_project^0` || exit

        rm -f .no-such-file
        empty=`GIT_INDEX_FILE=.no-such-file git-write-tree`
        git-read-tree -m -u $empty $head $foreign ||
        git-merge-cache -o git-merge-one-file-script -a || exit

        tree=`git-write-tree` &&
        echo Merge $foreign_project in. |
                git-commit-tree $tree -p $head -p $foreign \
                >"$GIT_DIR/HEAD" &&
	git show-branch --more=10 HEAD $foreign_project

Unlike my other "scripts written in e-mail buffer", I
actually tested this one ;-).

	$ cd /var/tmp && rm -fr junk && mkdir junk
	$ cd /var/tmp/junk
	$ git init-db
        $ cat >./git-merge-projects-script
        : type the above and end with ^D
	$ chmod +x git-merge-projects-script
        $ git add git-merge-projects-script
	$ git commit -m 'My Project'
	$ git fetch http://www.kernel.org/pub/scm/git/git.git master:git
	$ ./git-merge-projects-script git
	$ git diff git..HEAD

The "weird" situation to cause "git resolve" barf happens only
for the first time and once they are merged you can repeatedly
pull from that subset foreign branch without any "weirdo"
support.  Since even the oddball initial case can easily be
scripted like above, and that initial case should happen very
very rarely anyway, I do not think this deserves any core-level
change, such as changes to read-tree you suggest.

The above merge-projects-script _may_ deserve a "contrib"
status to be in the source tree, though.

One thing that makes me reluctant to recommend this "merging
unrelated projects" business is that I suspect that it makes
things _much_ harder for the upstream project that is being
merged, and should not be done without prior arrangement; Linus
merged gitk after talking with paulus, so that was OK.

Suppose the above "My Project" is published, people send patches
for core GIT part to it, and you as the maintainer of that "My
Project" accept those patches.  The users of "My Project" would
be happy with the new features and wouldn't care less where
their core GIT tools come from.  But how would _I_ pull from
that "My Project", if I did not want to pull unrelated stuff in?

In this particular example, it only has git-merge-projects
script which _is_ related to core GIT so this objection would
not apply, but if I were paulus (gitk maintainer whose project
has only one file, the great gitk script) and if the git.git
repository had a lot of changes to gitk, I would like to pick up
updates from there without pulling the rest of core GIT.  That
is not something the current set of tools support, and offhand I
do not think of a good way to implement it cleanly.  That is the
reason why I never pick up any patch for gitk myself --- I
always slurp changes to gitk via paulus tree, or feed patches
to him and then slurp the changes from him.

What I think _might_ deserve a bit more support would be a merge
of a foreign project as a subdirectory of a project.  Linus
could have made gitk/ subdirectory in the core git project, and
made that subtree in sync with the toplevel of paulus gitk
project.  But even this could be done without the core-level
change.  You would run ls-tree of the main project to figure out
the tree object name of that subdirectory, and 3-way merge that
with the top of the paulus project tree, and replace the tree
entry with the resulting tree.

Once that kind of "merging an unrelated project as a
subdirectory of a superproject" workflow is established, pulling
from a subdirectory that corresponds to my project after my
project gets merged this way into the superproject would become
easier to manage and would even become a useful workflow
element.

  parent reply	other threads:[~2005-08-25 22:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-25 21:10 Merges without bases Darrin Thompson
2005-08-25 21:29 ` Darrin Thompson
2005-08-25 22:26 ` Junio C Hamano [this message]
2005-08-25 22:59   ` Darrin Thompson
2005-09-08 18:01     ` Tim Ottinger
2005-08-26  4:09   ` Daniel Barkalow
2005-08-26  8:00     ` Junio C Hamano
2005-09-09 12:02       ` Eric W. Biederman
2005-08-26  9:17   ` Martin Langhoff
2005-08-26 16:37     ` Daniel Barkalow
2005-08-27  6:48       ` Martin Langhoff
2005-08-27 20:49         ` Daniel Barkalow

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=7vvf1tps9v.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=darrint@progeny.com \
    --cc=git@vger.kernel.org \
    /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).