git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git rebase and merge commits
@ 2010-10-20 16:45 Dominique Quatravaux
  2010-10-20 17:32 ` Jonathan Nieder
  0 siblings, 1 reply; 5+ messages in thread
From: Dominique Quatravaux @ 2010-10-20 16:45 UTC (permalink / raw)
  To: git

Hi all, I'm trying to write "git shove", a wrapper around git rebase
--interactive that would turn this


#        A---B---C---K targetbranch
#       /         \
#  D---E---F---G---H---I--J srcbranch

into this:

#   A---B---C---I'---K'  targetbranch
#  /             \
# D---E---F---G---H'---J' srcbranch
#

(ie I has been shoved into targetbranch).

It seemed to me that the first step should be to simply rebase I, H, and J (in
this order) onto C. Unfortunately git rebase --interactive -p C proposes a
git-rebase-todo that contains only "noop"; if I forcefully put this instead,

edit iiii I
edit hhhh H
edit jjjj J

it seems to me that the HEAD jumps backward to the original H on the second
rebase step, instead of daisy-chaining H behind I.  This is with git 1.7.3.1.

Here are the outputs of git log --graph --pretty=oneline --abbrev-commit at each
rebase step:

1/3

* a810395 I
*   1cfccc7 H
|\
| * c477d4e C
| * 7002290 B
| * aa9f1d0 A
* | b614d31 G
* | 2ad4496 F
|/
* 0d512e9 E
* b6cbc2b D

2/3

*   1cfccc7 H
|\
| * c477d4e C
| * 7002290 B
| * aa9f1d0 A
* | b614d31 G
* | 2ad4496 F
|/
* 0d512e9 E
* b6cbc2b D

3/3

* 3a41a45 J
* a810395 I
*   1cfccc7 H
|\
| * c477d4e C
| * 7002290 B
| * aa9f1d0 A
* | b614d31 G
* | 2ad4496 F
|/
* 0d512e9 E
* b6cbc2b D


Is there a way to do a real rebase of a merge commit?

FWIW, here is the script I use to create my toy environment in the current
directory:

function _make_commit() {
  echo "$1" > "$1"
  git add "$1"
  git commit -a -m "$1"
  git tag "$1" HEAD
}

function _prepare_merged_history() {
  git init
  _make_commit "D"
  git checkout -b targetbranch
  _make_commit "E"
  _make_commit "A"
  _make_commit "B"
  _make_commit "C"
  _make_commit "K"
  git checkout E
  git checkout -b srcbranch
  _make_commit "F"
  _make_commit "G"
  git merge  -m "H" C
  git tag H HEAD
  _make_commit "I"
  _make_commit "J"
}

function _git_rebase_todo_line() {
  echo -n "pick "
  git rev-list -n 1 --pretty=oneline --abbrev-commit --abbrev=7 "$1"
}

function _make_git_rebase_todo() {
  {
    _git_rebase_todo_line refs/tags/I
    _git_rebase_todo_line refs/tags/H
    _git_rebase_todo_line refs/tags/J
  } > git-rebase-todo
}

[ -d ".git" ] && exit
_prepare_merged_history
_make_git_rebase_todo


Thanks in advance,

-- 
  Dominique Quatravaux
  +41 79 609 40 72

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

* Re: git rebase and merge commits
  2010-10-20 16:45 git rebase and merge commits Dominique Quatravaux
@ 2010-10-20 17:32 ` Jonathan Nieder
  2010-10-20 17:44   ` Joshua Jensen
  2010-10-25 11:23   ` Dominique Quatravaux
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Nieder @ 2010-10-20 17:32 UTC (permalink / raw)
  To: Dominique Quatravaux; +Cc: git

Hi Dominique,

Dominique Quatravaux wrote:

> #        A---B---C---K targetbranch
> #       /         \
> #  D---E---F---G---H---I--J srcbranch
> 
> into this:
> 
> #   A---B---C---I'---K'  targetbranch
> #  /             \
> # D---E---F---G---H'---J' srcbranch
> #
> 
> (ie I has been shoved into targetbranch).
> 
> It seemed to me that the first step should be to simply rebase I, H, and J (in
> this order) onto C. Unfortunately git rebase --interactive -p C proposes
[...]

I'm sorry to break this news, but "rebase --interactive --preserve-merges"
(unlike "rebase --preserve-merges" without --interactive) was never
implemented completely.  See the BUGS section of the git-rebase man page.

Luckily, there is a roadmap for anyone interested in implementing it.  Maybe
it could be you?  See [1] and the surrounding thread.

Thanks for your interest,
Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144

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

* Re: git rebase and merge commits
  2010-10-20 17:32 ` Jonathan Nieder
@ 2010-10-20 17:44   ` Joshua Jensen
  2010-10-20 18:12     ` Joshua Jensen
  2010-10-25 11:23   ` Dominique Quatravaux
  1 sibling, 1 reply; 5+ messages in thread
From: Joshua Jensen @ 2010-10-20 17:44 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Dominique Quatravaux, git

----- Original Message -----
From: Jonathan Nieder
Date: 10/20/2010 11:32 AM
> I'm sorry to break this news, but "rebase --interactive --preserve-merges"
> (unlike "rebase --preserve-merges" without --interactive) was never
> implemented completely.  See the BUGS section of the git-rebase man page.
>
> Luckily, there is a roadmap for anyone interested in implementing it.  Maybe
> it could be you?  See [1] and the surrounding thread.
>
> Thanks for your interest,
> Jonathan
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144
I applied that patch to my git-rebase--interactive, although it did not 
cleanly apply.  I hacked a few bits to get it going again.  I could post 
the entire file here, if someone wants to clean it up.

It does properly rebase the first-parent merges fine.

Josh

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

* Re: git rebase and merge commits
  2010-10-20 17:44   ` Joshua Jensen
@ 2010-10-20 18:12     ` Joshua Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Joshua Jensen @ 2010-10-20 18:12 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Dominique Quatravaux, git

----- Original Message -----
From: Joshua Jensen
Date: 10/20/2010 11:44 AM
> ----- Original Message -----
> From: Jonathan Nieder
> Date: 10/20/2010 11:32 AM
>> I'm sorry to break this news, but "rebase --interactive 
>> --preserve-merges"
>> (unlike "rebase --preserve-merges" without --interactive) was never
>> implemented completely.  See the BUGS section of the git-rebase man 
>> page.
>>
>> Luckily, there is a roadmap for anyone interested in implementing 
>> it.  Maybe
>> it could be you?  See [1] and the surrounding thread.
>>
>> Thanks for your interest,
>> Jonathan
>>
>> [1] 
>> http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144
> I applied that patch to my git-rebase--interactive, although it did 
> not cleanly apply.  I hacked a few bits to get it going again.  I 
> could post the entire file here, if someone wants to clean it up.
>
> It does properly rebase the first-parent merges fine.

Never mind.  I applied this patch: 
http://marc.info/?l=git&m=119379735525213&w=2

Josh

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

* Re: git rebase and merge commits
  2010-10-20 17:32 ` Jonathan Nieder
  2010-10-20 17:44   ` Joshua Jensen
@ 2010-10-25 11:23   ` Dominique Quatravaux
  1 sibling, 0 replies; 5+ messages in thread
From: Dominique Quatravaux @ 2010-10-25 11:23 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

On Wed, Oct 20, 2010 at 7:32 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Luckily, there is a roadmap for anyone interested in implementing it.  Maybe
> it could be you?  See [1] and the surrounding thread.
>
> Thanks for your interest,
> Jonathan
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/148059/focus=148144
>

I gave it a shot last week, but this is more that I can chew on in my
spare time. Sorry! Thanks for the information anyway.


-- 
  Dominique Quatravaux
  +41 79 609 40 72

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-20 16:45 git rebase and merge commits Dominique Quatravaux
2010-10-20 17:32 ` Jonathan Nieder
2010-10-20 17:44   ` Joshua Jensen
2010-10-20 18:12     ` Joshua Jensen
2010-10-25 11:23   ` Dominique Quatravaux

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).