Skip to contentSkip to conversation

stgit - continue rebase after merge conflict?

DISCUSSION Alex Chiang 3 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi Catalin,

How does one do a stg rebase if there are merge conflicts?

I see:

-------------------------------------------------------

achiang@blender:~/kernels/linux-2.6$ stg rebase origin
Upgraded branch stg-pci-slots to format version 2
Checking for changes in the working directory ... done
Popping all applied patches ... done
Rebasing to "origin" ... done
Pushing patch "0001-Remove-path-attribute-from-sgi_hotplug.patch" ... done
Pushing patch "0002-Construct-one-fakephp-slot-per-pci-slot.patch" ... 
  CONFLICT (content): Merge conflict in drivers/pci/hotplug/fakephp.c
  Error: The merge failed during "push".
         Revert the operation with "push --undo".
  stg rebase: 1 conflict(s)
-------------------------------------------------------

This output tells you how to undo the rebase, but doesn't give any clues on how to continue it, like git would:

-------------------------------------------------------
When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort".
-------------------------------------------------------

Doing an 'stg help rebase' isn't so helpful.

My *guess* is that I want to:

- manually resolve the merge conflicts
- stg refresh
- ???

Any hints are appreciated.

Thanks.

/ac

#1 lore raw
Quoted 1 line · Alex Chiang

How does one do a stg rebase if there are merge conflicts?

Basically, you solve the conflict, refresh the current patch and continue with 'stg push' or 'stg goto <top patch>'. The 'rebase' command does 'pop --all', 'git reset', 'push --all'. In your conflict, the base of the stack was already changed to the latest and hence only push/goto is needed. To fix it:

$ vi files   # or simply use 'resolved -i' below
$ stg resolved -a [-i]
$ stg refresh
$ stg goto top-patch

or (if you want to skip that patch):

$ stg push --undo
$ stg push next-patch..

The 'rebase' command doesn't store any information about the state of the stack and cannot continue it. Maybe we'll do something in the next release as the refactored code has support for transactions.

Yet another option is to enable the automatic interactive merge ('git config stgit.autoimerge yes') and, at a conflict, it calls your three-way merge tool (emacs, xxdiff etc.). If the merge tool succeeds, the rebase will simply continue.

Quoted 10 lines

This output tells you how to undo the rebase, but doesn't give any clues on how to continue it, like git would:

-------------------------------------------------------
When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort".
-------------------------------------------------------

Doing an 'stg help rebase' isn't so helpful.

Yes, indeed. It could be made better.

Signature · 1 line
Catalin
#2 lore raw

* Catalin Marinas <[email protected]>:

Quoted 5 lines · Alex Chiang
Quoted 1 line

How does one do a stg rebase if there are merge conflicts?

Basically, you solve the conflict, refresh the current patch and continue with 'stg push' or 'stg goto <top patch>'.

Thanks.

Quoted 3 lines

The 'rebase' command doesn't store any information about the state of the stack and cannot continue it. Maybe we'll do something in the next release as the refactored code has support for transactions.

I see.

Quoted 3 lines
Quoted 1 line

Doing an 'stg help rebase' isn't so helpful.

Yes, indeed. It could be made better.

How about this?

/ac

From: Alex Chiang <[email protected]>

Enhance rebase help string by providing guidance on merge conflict resolution during a rebase.

Based on text suggested by Catalin Marinas.

---

stgit/commands/rebase.py +13 -1
index 12faaf8..29d741b 100644
@@ -27,7 +27,19 @@ help = 'move the stack base to another point in history'
 usage = """%prog [options] <new-base-id>
 
 Pop all patches from current stack, move the stack base to the given
-<new-base-id> and push the patches back."""
+<new-base-id> and push the patches back.
+
+If you experience merge conflicts, resolve the problem and continue
+the rebase by executing the following sequence:
+
+	$ stg resolved -a [-i]
+	$ stg refresh
+	$ stg goto top-patch
+
+Or if you want to skip that patch:
+
+	$ stg push --undo
+	$ stg push next-patch.."""
 
 directory = DirectoryGotoToplevel()
 options = [make_option('-n', '--nopush',
#3 lore raw
In reply to Catalin Marinas
Quoted 4 lines · Catalin Marinas

or (if you want to skip that patch):

$ stg push --undo
$ stg push next-patch..

Better use

  $ stg push next-patch..top-patch

which works even if you don't want to push _all_ patches.

Quoted 3 lines

The 'rebase' command doesn't store any information about the state of the stack and cannot continue it. Maybe we'll do something in the next release as the refactored code has support for transactions.

Hmm, that's an interesting idea. Maybe an "stg resume" command that one would run after having resolved the conflicts.

One implementation would be to save a .stgit-todo file with contents like this:

push foo
push bar
push baz

It would have to handle more than just pushes, however. For example, stg coalesce will try to first push the given patches in order, and then coalesce them, so for that case .stgit-todo might look like this:

push bar
push baz
coalesce foo bar baz
push frotz

We should be able to redefine each non-atomic stgit command in terms of such atomic commands, and get resumeability all over the place.

I'm not sure this is a good idea, but it is intriguing.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#4 lore raw
In reply to Catalin Marinas

* Catalin Marinas <[email protected]>:

Quoted 9 lines · Alex Chiang
Quoted 1 line

How does one do a stg rebase if there are merge conflicts?

Basically, you solve the conflict, refresh the current patch and continue with 'stg push' or 'stg goto <top patch>'. The 'rebase' command does 'pop --all', 'git reset', 'push --all'. In your conflict, the base of the stack was already changed to the latest and hence only push/goto is needed. To fix it:

Quoted 4 lines
$ vi files   # or simply use 'resolved -i' below
$ stg resolved -a [-i]
$ stg refresh
$ stg goto top-patch

That goto command doesn't tell you about merge conflicts:

achiang@blender:~/kernels/linux-2.6$ stg series
+ 0001-Remove-path-attribute-from-sgi_hotplug.patch
Quoted 1 line

0002-Construct-one-fakephp-slot-per-pci-slot.patch

- 0003-Introduce-pci_slot.patch
- 0004-ACPI-PCI-slot-detection-driver.patch

achiang@blender:~/kernels/linux-2.6$ stg goto 0004-ACPI-PCI-slot-detection-driver.patch 
Pushed 0003-Introduce-pci_slot.patch (conflict)
Error: Merge conflict
Now at patch "0003-Introduce-pci_slot.patch"
achiang@blender:~/kernels/linux-2.6$ stg series
+ 0001-Remove-path-attribute-from-sgi_hotplug.patch
+ 0002-Construct-one-fakephp-slot-per-pci-slot.patch
Quoted 1 line

0003-Introduce-pci_slot.patch

- 0004-ACPI-PCI-slot-detection-driver.patch

Since this patch series is small, I just did a 'stg push' and now it tells me about the conflicts. But I don't think I'd want to do that if I was managing tens or hundreds of patches...

achiang@blender:~/kernels/linux-2.6$ stg push --undo
Undoing push of "0003-Introduce-pci_slot.patch" ... done
Now at patch "0002-Construct-one-fakephp-slot-per-pci-slot.patch"
achiang@blender:~/kernels/linux-2.6$ stg push
Checking for changes in the working directory ... done
Pushing patch "0003-Introduce-pci_slot.patch" ... 
  CONFLICT (content): Merge conflict in drivers/pci/hotplug/acpiphp_ibm.c
  CONFLICT (content): Merge conflict in drivers/pci/hotplug/pci_hotplug_core.c
  CONFLICT (content): Merge conflict in drivers/pci/hotplug/rpadlpar_sysfs.c
  CONFLICT (content): Merge conflict in include/linux/pci.h
  CONFLICT (content): Merge conflict in include/linux/pci_hotplug.h
  Error: The merge failed during "push".
         Revert the operation with "push --undo".
  stg push: 5 conflict(s)

Is this pilot error? Or is goto misbehaving?

Thanks.

/ac

#5 lore raw
Quoted 18 lines · Alex Chiang

* Catalin Marinas <[email protected]>:

Quoted 9 lines · Alex Chiang
Quoted 1 line

How does one do a stg rebase if there are merge conflicts?

Basically, you solve the conflict, refresh the current patch and continue with 'stg push' or 'stg goto <top patch>'. The 'rebase' command does 'pop --all', 'git reset', 'push --all'. In your conflict, the base of the stack was already changed to the latest and hence only push/goto is needed. To fix it:

Quoted 4 lines
$ vi files   # or simply use 'resolved -i' below
$ stg resolved -a [-i]
$ stg refresh
$ stg goto top-patch

That goto command doesn't tell you about merge conflicts:

[...]

Quoted 4 lines
 achiang@blender:~/kernels/linux-2.6$ stg goto 0004-ACPI-PCI-slot-detection-driver.patch
 Pushed 0003-Introduce-pci_slot.patch (conflict)
 Error: Merge conflict
 Now at patch "0003-Introduce-pci_slot.patch"

It says that it's a merge conflict but isn't more precise than that. You can run 'stg status' to check the conflicts.

The reason is that you are probably using the development branch of StGIT and we (actually Karl) are refactoring the GIT objects handling. The 'goto' command (but not 'push') was moved to the new infrastructure but missed some of the UI stuff. They'll be added back.

I could use the stable branch until we sort out these issues.

Signature · 1 line
Catalin
#6 lore raw
Quoted 8 lines · Catalin Marinas

It says that it's a merge conflict but isn't more precise than that. You can run 'stg status' to check the conflicts.

The reason is that you are probably using the development branch of StGIT and we (actually Karl) are refactoring the GIT objects handling. The 'goto' command (but not 'push') was moved to the new infrastructure but missed some of the UI stuff. They'll be added back.

Yeah, I'd forgotten all about that. I rarely get conflicts when running "stg goto".

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle