Git development
 help / color / mirror / Atom feed
* Symmetric of rebase / more intelligent cherry-pick
@ 2011-10-11 15:54 Lionel Elie Mamane
  2011-10-11 19:36 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Lionel Elie Mamane @ 2011-10-11 15:54 UTC (permalink / raw)
  To: git

Hi,

I was thinking about a sort of symmetric to rebase, a kind of
"intelligent" mass cherry-pick. For the sake of example let's call it
"basere", although a better name would have to be found.

While
 git rebase UPSTREAM
moves the *current* branch (and any commit in it, but not in UPSTREAM)
on top of UPSTREAM,
 git basere UPSTREAM
would "cherry-pick" all commits in UPSTREAM that are not in HEAD to
the current branch.

git cherry-pick ..UPSTREAM
*nearly* does what I want, except that it lacks rebase's intelligence
of skipping commits that do the same textual changes as a commit
already in the current branch. So maybe it should be an option to
cherry-pick rather than a new command? E.g. --skip-same? What about
making it cherry-picks *default* behaviour?

Why do I think it is useful? Take the case of a developer following
two different origins A and B, and B uses rebase (not merge) to
integrate changes from A, but not as often as one would like. A could
for example be the "official" tree (e.g. linux Linus tree), and B a
feature branch of a developer that is meant to eventually go into A
"cleanly" at some future time and A's policy is that one has to rebase
before sending a merge request. Then another developer wants to keep
up with changes from *both* A and B. So, the situation could look
like:

      A---A---A remotes/A/master
     /
X---X---B0---B1---L master
     \
      B0---B1---B2--B3 remotes/B/master

So one does "git rebase remotes/A/master master" and one gets

      A---A---A---B0---B1---L master
     /
X---X
     \
      B0---B1---B2--B3 remotes/B/master

I'd like to go to the situation:

      A---A---A---B0---B1---L---B2--B3 master
     /
X---X
     \
      B0---B1---B2--B3 remotes/B/master

Without having to manually find the cutoff point "B2"
(or worse, if the history is more messy than that, as in:

      A---A---A---B1---L master
     /
X---X
     \
      B0---B1---B2--B3 remotes/B/master
)


The best way I have found to do that is:

git fetch B
git checkout --no-track -b TMP remotes/B/master
git rebase master
git checkout master
git merge --ff-only TMP
git branch -d TMP

or less commands but more messy/fragile (and more work for git):

git fetch B
git tag TMP
git rebase remotes/B/master
git rebase TMP
git tag -d TMP

but that is rather onerous for something that should be just one
command.


So what are your thoughts on that?

 - Good idea? Would you take a patch that does something like that?

 - Should it be cherry-picks's default behaviour?

 - An option to cherry-pick?

 - A new command? What name? Maybe "multi-cherry-pick"?

 - An option to rebase, e.g. "--pull" or "--incoming" or "--here"?
   ("--pull" is probably too confusing wrt to "git pull"; people will
    have trouble remembering which is which between "git pull
    --rebase" and "git rebase --pull"...)

-- 
Lionel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-11 22:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 15:54 Symmetric of rebase / more intelligent cherry-pick Lionel Elie Mamane
2011-10-11 19:36 ` Junio C Hamano
2011-10-11 21:28   ` Junio C Hamano
2011-10-11 22:23     ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox