git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Effective difference between git-rebase and git-resolve
@ 2006-03-25  3:54 Marc Singer
  2006-03-25  4:23 ` Linus Torvalds
  0 siblings, 1 reply; 10+ messages in thread
From: Marc Singer @ 2006-03-25  3:54 UTC (permalink / raw
  To: git

The process I've been using to keep my patches current with the latest
development is this:

  git checkout linus && git pull linus
  git checkout work

When I'm ready to merge,

  git resolve work linus "Update with head"
  git tag basis

This lets me diff against basis even when the linus branch continues
to follow the latest developments.

Today, I wanted to move everything forward.  But the resolve failed to
merge some files.  In fact, one file was apparently so thorny that
resolve just gave up and left no working file.  Bothersome, but I
recovered by moving back to the previous work point.

Then, I found git-rebase which seems to be more what I'd like to use
since it moves my patches along on top of the main development line.

  git rebase linus

This time, almost everything merged without a hitch except for the
thorny file from before.  I edited the file, removing the conflict
markers, and started a build.  But what I found was that some of the
changes I'd made were no longer present.  Several files showed no sign
of the patches even though the kernel versions hadn't changed.

So, I have a couple of questions:

  1) Am I using rebase correctly?
  2) If not, did it leave some of my changes uncommitted and hidden
     somewhere? git-ls-files --unmerged shows no sign of them.
  3) Do I have to pull all of my patches off, apply them to the head
     of the tree, and only use git-rebase to make this work?
  4) Should I prefer rebase over resolve?

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  3:54 Effective difference between git-rebase and git-resolve Marc Singer
@ 2006-03-25  4:23 ` Linus Torvalds
  2006-03-25  6:08   ` Junio C Hamano
       [not found]   ` <20060325043507.GA14644@buici.com>
  0 siblings, 2 replies; 10+ messages in thread
From: Linus Torvalds @ 2006-03-25  4:23 UTC (permalink / raw
  To: Marc Singer; +Cc: Git Mailing List, Junio C Hamano



On Fri, 24 Mar 2006, Marc Singer wrote:
>
> The process I've been using to keep my patches current with the latest
> development is this:
> 
>   git checkout linus && git pull linus
>   git checkout work

You'd be much more efficient if you just did

	git fetch linus

which avoids switching back-and-forth (and speeds up the pull too, since 
it doesn't need to update any working directories).

> When I'm ready to merge,
> 
>   git resolve work linus "Update with head"

No, don't do this.

"git resolve" is the _old_ stupid merger, which isn't very helpful at all. 
So please use

	git merge "Merge with Linus" work linus

instead, which will use the proper "recursive" merge functionality.

> Then, I found git-rebase which seems to be more what I'd like to use
> since it moves my patches along on top of the main development line.
> 
>   git rebase linus
> 
> This time, almost everything merged without a hitch except for the
> thorny file from before.  I edited the file, removing the conflict
> markers, and started a build.  But what I found was that some of the
> changes I'd made were no longer present.

Yeah, "git rebase" is not _nearly_ as intuitive as doing a real merge.

What happened was that you resolved the thorny merge, but the rebase had 
stopped when it hit it, so it never actually did the rest of the rebase. 
Which explains why some of your changes are no longer present: they are 
still in the "rebase queue".

>   1) Am I using rebase correctly?

Yes, but you missed the fact that unlike "git merge", rebasing really is a 
"move one commit at a time" thing, and it stopped on the middle.

>   4) Should I prefer rebase over resolve?

You should never do "resolve", it's very oldfashioned. If you want to 
merge, just use "git merge", which will do the right thing.

As to rebase, it often is very nice, but on the other hand, it leaves 
things in a total mess when it fails, which is a pity. Maybe there's a 
nice way to just continue, but I end up just doing a

	git reset --hard ORIG_HEAD

to undo the failed rebase.

Junio, is there some magic to restart a rebase after you've fixed up the 
conflicts?

		Linus

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  4:23 ` Linus Torvalds
@ 2006-03-25  6:08   ` Junio C Hamano
  2006-03-25  6:32     ` Marc Singer
       [not found]   ` <20060325043507.GA14644@buici.com>
  1 sibling, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2006-03-25  6:08 UTC (permalink / raw
  To: Linus Torvalds; +Cc: Marc Singer, Git Mailing List

Linus Torvalds <torvalds@osdl.org> writes:

> As to rebase, it often is very nice, but on the other hand, it leaves 
> things in a total mess when it fails, which is a pity. Maybe there's a 
> nice way to just continue, but I end up just doing a
>
> 	git reset --hard ORIG_HEAD
>
> to undo the failed rebase.
>
> Junio, is there some magic to restart a rebase after you've fixed up the 
> conflicts?

The modern rebase is essentially git-format-patch piped to
git-am (with -3 flag to allow falling back to three-way merge),
and all the familiar "the patch did not apply -- what now?"
techniques can be employed.

Since the pre-image blobs recorded in the intermediate
format-patch output by definition exist in your repository, it
always falls back to three-way merge when the patch does not
apply cleanly.  Then you can resolve and say "git am --resolved"
to continue.

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

* Re: Effective difference between git-rebase and git-resolve
       [not found]   ` <20060325043507.GA14644@buici.com>
@ 2006-03-25  6:10     ` Junio C Hamano
  2006-03-25  9:37       ` Johannes Schindelin
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2006-03-25  6:10 UTC (permalink / raw
  To: Marc Singer; +Cc: Linus Torvalds, Git Mailing List

Marc Singer <elf@buici.com> writes:

>> 	git merge "Merge with Linus" work linus
>> 
>> instead, which will use the proper "recursive" merge functionality.
>
> OK.  I'll see if that is more successful.  It would be nice if the
> resolve command printed a message about the command being deprecated.

The only reason I didn't do that was because I just did not want
to disrupt the workflow by Linus.  If nobody in the upper
echelon of kernel people (meaning, longest-time git users) use
git-resolve anymore, I think we should mark it deprecated and
remove it eventually.

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  6:08   ` Junio C Hamano
@ 2006-03-25  6:32     ` Marc Singer
  2006-03-25  7:15       ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Marc Singer @ 2006-03-25  6:32 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Linus Torvalds, Git Mailing List

On Fri, Mar 24, 2006 at 10:08:09PM -0800, Junio C Hamano wrote:
> > Junio, is there some magic to restart a rebase after you've fixed up the 
> > conflicts?
> 
> The modern rebase is essentially git-format-patch piped to
> git-am (with -3 flag to allow falling back to three-way merge),
> and all the familiar "the patch did not apply -- what now?"
> techniques can be employed.
> 
> Since the pre-image blobs recorded in the intermediate
> format-patch output by definition exist in your repository, it
> always falls back to three-way merge when the patch does not
> apply cleanly.  Then you can resolve and say "git am --resolved"
> to continue.

By modern do you mean newer than 1.2.4?  I comprehend what you're
layin' down here, but I don't know if I need to do something
different.

Moreover, it isn't clear to me if git-rebase is better than git-merge.

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  6:32     ` Marc Singer
@ 2006-03-25  7:15       ` Junio C Hamano
  2006-03-26 20:29         ` J. Bruce Fields
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2006-03-25  7:15 UTC (permalink / raw
  To: Marc Singer; +Cc: git

Marc Singer <elf@buici.com> writes:

[I'm shuffling this part to the top]

> Moreover, it isn't clear to me if git-rebase is better than git-merge.

Merge preserves commit ancestry, so if you are hoping it to
clean up your history, that is not the tool to do it.  Both
rebase and cherry-pick are to help you create a cleaner,
alternate history.  So none is better than the other.  They
serve different purposes.

> On Fri, Mar 24, 2006 at 10:08:09PM -0800, Junio C Hamano wrote:
>> > Junio, is there some magic to restart a rebase after you've fixed up the 
>> > conflicts?
>> 
>> The modern rebase is essentially git-format-patch piped to
>> git-am (with -3 flag to allow falling back to three-way merge),
>> and all the familiar "the patch did not apply -- what now?"
>> techniques can be employed.
>...
> By modern do you mean newer than 1.2.4?  I comprehend what you're
> layin' down here, but I don't know if I need to do something
> different.

By modern, I meant v0.99.9-g7f59dbb.

diff-tree 7f59dbb... (from f9039f3...)
Author: Junio C Hamano <junkio@cox.net>
Date:   Mon Nov 14 00:41:53 2005 -0800

    Rewrite rebase to use git-format-patch piped to git-am.
    
    The current rebase implementation finds commits in our tree but
    not in the upstream tree using git-cherry, and tries to apply
    them using git-cherry-pick (i.e. always use 3-way) one by one.
    
    Which is fine, but when some of the changes do not apply
    cleanly, it punts, and punts badly.
    
    Suppose you have commits A-B-C-D-E since you forked from the
    upstream and submitted the changes for inclusion.  You fetch
    from upstream head U and find that B has been picked up.  You
    run git-rebase to update your branch, which tries to apply
    changes contained in A-C-D-E, in this order, but replaying of C
    fails, because the upstream got changes that touch the same area
    from elsewhere.
    
    Now what?
    
    It notes that fact, and goes ahead to apply D and E, and at the
    very end tells you to deal with C by hand.  Even if you somehow
    managed to replay C on top of the result, you would now end up
    with ...-B-...-U-A-D-E-C.
    
    Breaking the order between B and others was the conscious
    decision made by the upstream, so we would not worry about it,
    and even if it were worrisome, it is too late for us to fix now.
    What D and E do may well depend on having C applied before them,
    which is a problem for us.
    
    This rewrites rebase to use git-format-patch piped to git-am,
    and when the patch does not apply, have git-am fall back on
    3-way merge.  The updated diff/patch pair knows how to apply
    trivial binary patches as long as the pre- and post-images are
    locally available, so this should work on a repository with
    binary files as well.
    
    The primary benefit of this change is that it makes rebase
    easier to use when some of the changes do not replay cleanly.
    In the "unapplicable patch in the middle" case, this "rebase"
    works like this:
    
     - A series of patches in e-mail form is created that records
       what A-C-D-E do, and is fed to git-am.  This is stored in
       .dotest/ directory, just like the case you tried to apply
       them from your mailbox.  Your branch is rewound to the tip of
       upstream U, and the original head is kept in .git/ORIG_HEAD,
       so you could "git reset --hard ORIG_HEAD" in case the end
       result is really messy.
    
     - Patch A applies cleanly.  This could either be a clean patch
       application on top of rewound head (i.e. same as upstream
       head), or git-am might have internally fell back on 3-way
       (i.e.  it would have done the same thing as git-cherry-pick).
       In either case, a rebased commit A is made on top of U.
    
     - Patch C does not apply.  git-am stops here, with conflicts to
       be resolved in the working tree.  Yet-to-be-applied D and E
       are still kept in .dotest/ directory at this point.  What the
       user does is exactly the same as fixing up unapplicable patch
       when running git-am:
    
       - Resolve conflict just like any merge conflicts.
       - "git am --resolved --3way" to continue applying the patches.
    
     - This applies the fixed-up patch so by definition it had
       better apply.  "git am" knows the patch after the fixed-up
       one is D and then E; it applies them, and you will get the
       changes from A-C-D-E commits on top of U, in this order.
    
    I've been using this without noticing any problem, and as people
    may know I do a lot of rebases.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  6:10     ` Junio C Hamano
@ 2006-03-25  9:37       ` Johannes Schindelin
  2006-03-25 11:08         ` Mark Wooding
  0 siblings, 1 reply; 10+ messages in thread
From: Johannes Schindelin @ 2006-03-25  9:37 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Git Mailing List

Hi,

On Fri, 24 Mar 2006, Junio C Hamano wrote:

> If nobody in the upper echelon of kernel people (meaning, longest-time 
> git users) use git-resolve anymore, I think we should mark it deprecated 
> and remove it eventually.

I am nowhere near kernel people, but I am using git on a machine where it 
is too cumbersome to install python. If git-resolve goes, I am without a 
merge strategy (at least until git-recursive is ported to C... was that 
not the plan with git-merge-tree? What happened on that front?).

Ciao,
Dscho

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  9:37       ` Johannes Schindelin
@ 2006-03-25 11:08         ` Mark Wooding
  2006-03-25 11:26           ` Johannes Schindelin
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Wooding @ 2006-03-25 11:08 UTC (permalink / raw
  To: git

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> I am nowhere near kernel people, but I am using git on a machine where it 
> is too cumbersome to install python. If git-resolve goes, I am without a 
> merge strategy (at least until git-recursive is ported to C... was that 
> not the plan with git-merge-tree? What happened on that front?).

Err... git-resolve isn't the same as git-merge-resolve.  The latter is a
stupid merge strategy which fits into the git-merge/git-pull
infrastructure.  The former is a different program which does merges
badly, and you didn't want to use it even if you don't have Python!

I'd forgotten all about git-resolve until it got mentioned just now.

-- [mdw]

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25 11:08         ` Mark Wooding
@ 2006-03-25 11:26           ` Johannes Schindelin
  0 siblings, 0 replies; 10+ messages in thread
From: Johannes Schindelin @ 2006-03-25 11:26 UTC (permalink / raw
  To: Mark Wooding; +Cc: git

Hi,

On Sat, 25 Mar 2006, Mark Wooding wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > I am nowhere near kernel people, but I am using git on a machine where it 
> > is too cumbersome to install python. If git-resolve goes, I am without a 
> > merge strategy (at least until git-recursive is ported to C... was that 
> > not the plan with git-merge-tree? What happened on that front?).
> 
> Err... git-resolve isn't the same as git-merge-resolve.

Oooops.

Thank you,
Dscho

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

* Re: Effective difference between git-rebase and git-resolve
  2006-03-25  7:15       ` Junio C Hamano
@ 2006-03-26 20:29         ` J. Bruce Fields
  0 siblings, 0 replies; 10+ messages in thread
From: J. Bruce Fields @ 2006-03-26 20:29 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Marc Singer, git

On Fri, Mar 24, 2006 at 11:15:57PM -0800, Junio C Hamano wrote:
>      - Patch C does not apply.  git-am stops here, with conflicts to
>        be resolved in the working tree.  Yet-to-be-applied D and E
>        are still kept in .dotest/ directory at this point.  What the
>        user does is exactly the same as fixing up unapplicable patch
>        when running git-am:
>     
>        - Resolve conflict just like any merge conflicts.
>        - "git am --resolved --3way" to continue applying the patches.

So, does this sum it up accurately for the man page?

--b.

Document git-rebase behavior on conflicts.

---

 Documentation/git-rebase.txt |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

3ef0c8cc7a505f9023a87e7e1ca22251a91bf188
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index b36276c..4a7e67a 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -48,6 +48,18 @@ would be:
              /
     D---E---F---G master
 
+In case of conflict, git-rebase will stop at the first problematic commit
+and leave conflict markers in the tree.  After resolving the conflict manually
+and updating the index with the desired resolution, you can continue the
+rebasing process with
+
+    git am --resolved --3way
+
+Alternatively, you can undo the git-rebase with
+
+    git reset --hard ORIG_HEAD
+    rm -r .dotest
+
 OPTIONS
 -------
 <newbase>::
-- 
1.2.4.g0382

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

end of thread, other threads:[~2006-03-26 20:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-25  3:54 Effective difference between git-rebase and git-resolve Marc Singer
2006-03-25  4:23 ` Linus Torvalds
2006-03-25  6:08   ` Junio C Hamano
2006-03-25  6:32     ` Marc Singer
2006-03-25  7:15       ` Junio C Hamano
2006-03-26 20:29         ` J. Bruce Fields
     [not found]   ` <20060325043507.GA14644@buici.com>
2006-03-25  6:10     ` Junio C Hamano
2006-03-25  9:37       ` Johannes Schindelin
2006-03-25 11:08         ` Mark Wooding
2006-03-25 11:26           ` Johannes Schindelin

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