git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Dirk Süsserott" <newsletter@dirk.my1.cc>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: Q: rebasing (moving) a whole tree (not just one branch)
Date: Fri, 18 Mar 2011 16:34:18 -0500	[thread overview]
Message-ID: <20110318213417.GB23407@elie> (raw)
In-Reply-To: <7vaagsw2qb.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
>> Dirk Süsserott wrote:

>>> I'd like to rebase a whole tree from A to B. Not just a single
>>> branch, but a whole tree. Let's say I have the following history:
>>>
>>> --- A --- B
>>>     |
>>>     + -- C -- D
>>>          |
>>>          + E -- F
>>> 
>>> I'd like to rebase C and its descendants from A to B
[...]
> I am not a huge fan of filter-branch, but shouldn't you be able to
> filter-branch D and F (and no other branch) on top of B?

Yes, something like

	git filter-branch \
		--commit-filter '
			if test "$GIT_COMMIT" = '"$(git rev-parse A^{commit})"'
			then
				git rev-parse B^{commit}
			else
				git_commit_non_empty_tree "$@"
			fi
		' \
		--index-filter '
			if test -n "$(git rev-list -1 "$GIT_COMMIT"..A)"
			then
				# descends from A
				git merge-recursive A -- "$GIT_COMMIT" B
			fi
		' -- --all --not A^

might do it, assuming the diff from A to B is simple enough for a
fully automatic rebase.

But in practice, something may well be much better.  It depends why we
are performing this mass-rebasing --- do A and B have the same content
in the moment and different histories?  How did the topics we are
rebasing get tangled, and is their history going to remain meaningful
after this operation?

Jonathan

  reply	other threads:[~2011-03-18 21:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 20:05 Q: rebasing (moving) a whole tree (not just one branch) Dirk Süsserott
2011-03-18 20:26 ` Jonathan Nieder
2011-03-18 21:14   ` Junio C Hamano
2011-03-18 21:34     ` Jonathan Nieder [this message]
2011-03-18 22:53     ` Johannes Sixt

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=20110318213417.GB23407@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newsletter@dirk.my1.cc \
    /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).