threads / discuss / 2728

resolve (merge) problems

Subject: resolve (merge) problems

## tl;dr

11 messages between Dec 1, 2005 and Dec 2, 2005.

replies: 10people: 3as markdown or json

Luben Tuikov· Dec 1, 2005, 23:18 UTC · lore
Hi,

$git resolve HEAD master "merge linus' tree" Trying to merge 5666c0947ede0432ba5148570aa66ffb9febff5b into 32df3299405fb7054b76346899f3db2fa29150fb using 458af5439fe7ae7d95ca14106844e61f0795166c. Simple merge failed, trying Automatic merge Removing arch/arm/configs/poodle_defconfig Removing drivers/atm/atmdev_init.c fatal: merge program failed Automatic merge failed, fix up by hand

How do I proceed from here?
The output from git-diff-index is:

$git-diff-index --name-status HEAD M Documentation/usb/error-codes.txt M Makefile M arch/arm/configs/corgi_defconfig U arch/arm/configs/poodle_defconfig M arch/arm/configs/spitz_defconfig M arch/arm/kernel/head.S M arch/arm/mach-pxa/Kconfig M arch/arm/mach-realview/core.c M arch/arm/mm/consistent.c M arch/arm/tools/mach-types M arch/frv/kernel/semaphore.c M arch/frv/mb93090-mb00/pci-irq.c M arch/frv/mm/init.c M arch/frv/mm/pgalloc.c M arch/i386/kernel/io_apic.c M arch/i386/kernel/reboot.c M arch/ia64/kernel/ia64_ksyms.c M arch/ia64/kernel/kprobes.c M arch/ia64/kernel/traps.c M arch/m32r/kernel/io_mappi3.c M arch/m32r/kernel/setup_mappi3.c M arch/m32r/kernel/sys_m32r.c M arch/powerpc/kernel/ppc_ksyms.c M arch/powerpc/kernel/process.c M arch/powerpc/kernel/prom_init.c M arch/powerpc/kernel/vdso.c M arch/ppc/kernel/ppc_ksyms.c M arch/ppc/kernel/process.c M arch/sparc/mm/generic.c M arch/sparc64/mm/generic.c M drivers/atm/Kconfig M drivers/atm/Makefile A drivers/atm/adummy.c U drivers/atm/atmdev_init.c M drivers/atm/atmtcp.c M drivers/atm/lanai.c M drivers/char/drm/drm_context.c M drivers/char/mem.c M drivers/cpufreq/cpufreq.c M drivers/hwmon/w83792d.c M drivers/md/md.c M drivers/md/raid1.c M drivers/md/raid10.c M drivers/md/raid5.c M drivers/md/raid6main.c M drivers/media/video/Kconfig M drivers/media/video/cx88/Kconfig M drivers/media/video/cx88/Makefile M drivers/media/video/saa7134/Kconfig M drivers/media/video/saa7134/Makefile M drivers/message/fusion/mptbase.c M drivers/message/fusion/mptbase.h M drivers/mmc/mmc.c M drivers/mtd/chips/cfi_cmdset_0001.c M drivers/mtd/chips/cfi_probe.c M drivers/mtd/chips/sharp.c M drivers/mtd/devices/block2mtd.c M drivers/mtd/devices/ms02-nv.c M drivers/mtd/ftl.c M drivers/mtd/maps/Kconfig M drivers/mtd/maps/Makefile M drivers/mtd/maps/ixp4xx.c M drivers/mtd/maps/nettel.c M drivers/mtd/maps/pci.c M drivers/mtd/maps/physmap.c M drivers/mtd/maps/sc520cdp.c M drivers/mtd/nand/nandsim.c M drivers/mtd/rfd_ftl.c M drivers/pcmcia/m32r_cfc.c M drivers/scsi/megaraid.c M drivers/serial/8250.c M drivers/serial/8250_pci.c M drivers/serial/serial_core.c M drivers/serial/serial_cs.c M drivers/usb/atm/cxacru.c M drivers/usb/atm/usbatm.c M drivers/usb/core/hcd-pci.c M drivers/usb/core/hcd.c M drivers/usb/core/hcd.h M drivers/usb/host/ehci-pci.c M drivers/usb/host/ehci-q.c M drivers/usb/host/ehci-sched.c M drivers/usb/host/ohci-hcd.c M drivers/usb/host/ohci-hub.c M drivers/usb/host/ohci-pci.c M drivers/usb/host/uhci-hcd.c M drivers/video/Kconfig M drivers/video/cirrusfb.c M drivers/video/console/fbcon_ccw.c M drivers/video/console/fbcon_rotate.h M fs/9p/vfs_inode.c M fs/cifs/CHANGES M fs/cifs/README M fs/cifs/TODO M fs/cifs/cifsfs.c M fs/cifs/cifssmb.c M fs/cifs/dir.c M fs/cifs/inode.c M fs/cifs/misc.c M fs/cifs/netmisc.c M fs/cifs/transport.c M fs/dquot.c M fs/exec.c M fs/ext3/resize.c M fs/fuse/dir.c M fs/hfsplus/hfsplus_fs.h M fs/hfsplus/hfsplus_raw.h M fs/hfsplus/options.c M fs/hfsplus/super.c M fs/jffs2/fs.c M fs/jffs2/super.c M fs/proc/task_mmu.c M fs/reiserfs/inode.c M fs/reiserfs/journal.c M include/asm-arm/arch-s3c2410/regs-gpio.h M include/asm-arm/arch-sa1100/io.h M include/asm-frv/hardirq.h M include/asm-frv/ide.h M include/asm-frv/page.h M include/asm-frv/semaphore.h M include/asm-frv/thread_info.h M include/asm-ia64/page.h M include/asm-m32r/atomic.h M include/asm-m32r/ide.h M include/asm-m32r/mappi3/mappi3_pld.h M include/asm-m32r/system.h M include/asm-sparc64/pgtable.h M include/linux/atmdev.h M include/linux/cn_proc.h M include/linux/cpu.h M include/linux/memory.h M include/linux/mm.h M include/linux/mmc/protocol.h M include/linux/mtd/cfi.h M include/linux/rmap.h M include/linux/sched.h M include/linux/serial_core.h M include/linux/swap.h M kernel/cpu.c M kernel/fork.c M kernel/posix-cpu-timers.c M kernel/power/main.c M kernel/ptrace.c M kernel/workqueue.c M lib/genalloc.c M mm/fremap.c M mm/madvise.c M mm/memory.c M mm/mempolicy.c M mm/msync.c M mm/nommu.c M mm/page_alloc.c M mm/rmap.c M mm/thrash.c M mm/vmscan.c M net/atm/atm_misc.c M net/atm/common.c M net/atm/common.h M net/atm/resources.c M net/atm/resources.h M net/ipv4/fib_hash.c M net/ipv4/fib_semantics.c M net/ipv4/icmp.c M net/ipv4/ip_gre.c M net/ipv4/ip_output.c M net/ipv4/ipvs/ip_vs_conn.c M net/ipv4/ipvs/ip_vs_ctl.c M net/ipv4/ipvs/ip_vs_proto_tcp.c M net/ipv4/netfilter/ip_conntrack_amanda.c M net/ipv4/netfilter/ip_conntrack_core.c M net/ipv4/netfilter/ip_conntrack_ftp.c M net/ipv4/netfilter/ip_conntrack_irc.c M net/ipv4/netfilter/ip_conntrack_proto_icmp.c M net/ipv4/netfilter/ip_conntrack_proto_sctp.c M net/ipv4/netfilter/ip_conntrack_proto_tcp.c M net/ipv4/netfilter/ip_nat_core.c M net/ipv4/netfilter/ip_tables.c M net/ipv4/netfilter/ipt_LOG.c M net/ipv4/proc.c M net/ipv4/route.c M net/ipv4/tcp.c M net/ipv6/addrconf.c M net/ipv6/icmp.c M net/ipv6/ip6_output.c M net/ipv6/ipv6_sockglue.c M net/ipv6/netfilter/ip6_tables.c

Thanks,
   Luben
Junio C Hamano· Dec 1, 2005, 23:58 UTC · re: Luben Tuikov · lore

Re: resolve (merge) problems

Luben Tuikov <ltuikov@yahoo.com> writes:
Show 19 quoted lines
> $ git resolve HEAD master "merge linus' tree"
> Trying to merge 5666c0947ede0432ba5148570aa66ffb9febff5b into
> 32df3299405fb7054b76346899f3db2fa29150fb using 458af5439fe7ae7d95ca14106844e61f0795166c.
> Simple merge failed, trying Automatic merge
> Removing arch/arm/configs/poodle_defconfig
> Removing drivers/atm/atmdev_init.c
> fatal: merge program failed
> Automatic merge failed, fix up by hand
>
> How do I proceed from here?
>
> The output from git-diff-index is:
>
> $git-diff-index --name-status HEAD
> M       Documentation/usb/error-codes.txt
> M       Makefile
> M       arch/arm/configs/corgi_defconfig
> U       arch/arm/configs/poodle_defconfig
> M       arch/arm/configs/spitz_defconfig
Easier to read is:
	$ git-diff-files --name-status

which would tell you that there two files have conflicting changes:

U arch/arm/configs/poodle_defconfig U drivers/atm/atmdev_init.c

and you would hopefully not see anything else (you saw tons of paths only because you compared against HEAD, which shows not just conflicts but everything the merge brought in).

	$ git diff arch/arm/configs/poodle_defconfig drivers/atm/atmdev_init.c

would give you the diff between your version (before merging) and the half-merged file with conflict markers. Resolve them just like you would resolve conflicting changes. I would usually just open these files in an editor, and pick one of the sections between <<< == >>> these markers.

One nifty tool I saw suggested on the list recently was xxdiff:
	$ xxdiff -U arch/arm/configs/poodle_defconfig

No matter how you would resolve, the first goal of yours is to get these files in your working tree into a good shape, which may involve compiling and testing. Once you have these files in a good enough shape, you tell git that you are done with them:

	$ git update-index \
        	arch/arm/configs/poodle_defconfig drivers/atm/atmdev_init.c
and commit.
	$ git commit

The commit message editor would loudly warn you that you are committing a merge, but that is OK because that is what you are doing. You might want to describe how you resolved (which side you picked) the conflicting changes in the log, in addition to the standard boilerplate "merged that branch" message.

Luben Tuikov· Dec 2, 2005, 00:07 UTC · re: Junio C Hamano · lore

Re: resolve (merge) problems

--- Junio C Hamano <junkio@cox.net> wrote:
> Easier to read is:
> 
> 	$ git-diff-files --name-status
Ok this is what it shows:

$git-diff-files --name-status U arch/arm/configs/poodle_defconfig D arch/arm/configs/poodle_defconfig U drivers/atm/atmdev_init.c D drivers/atm/atmdev_init.c

Unmerged and deleted?  Is this correct?
    Luben
Junio C Hamano· Dec 2, 2005, 00:58 UTC · re: Luben Tuikov · lore

Re: resolve (merge) problems

Luben Tuikov <ltuikov@yahoo.com> writes:
Show 14 quoted lines
> --- Junio C Hamano <junkio@cox.net> wrote:
>> Easier to read is:
>> 
>> 	$ git-diff-files --name-status
>
> Ok this is what it shows:
>
> $git-diff-files --name-status
> U       arch/arm/configs/poodle_defconfig
> D       arch/arm/configs/poodle_defconfig
> U       drivers/atm/atmdev_init.c
> D       drivers/atm/atmdev_init.c
>
> Unmerged and deleted?  Is this correct?

Yes, the first lets you notice it is unmerged, and the second says the file does not remain in the working tree.

However, there is a bug recently introduced in the merge-one-file script.

Although the conflict resolution procedure I described applies if you really had a real conflicting merge, I suspect your merge should not have failed in the first place.

        case "${1:-.}${2:-.}${3:-.}" in
        #
        # Deleted in both or deleted in one and unchanged in the other
        #
        "$1.." | "$1.$1" | "$1$1.")
                if [ "$2" ]; then
                        echo "Removing $4"
                fi
                if test -f "$4"; then
                        rm -f -- "$4" &&
                        rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null
                fi &&
                        exec git-update-index --remove -- "$4"
                ;;

The faliure code from "rmdir -p" leaks up and makes git-update-index to be skipped. Here is a fix.

-- >8 -- [PATCH] merge-one-file fix

9ae2172aed289f2706a0e88288909fa47eddd7e7 used "rmdir -p" carelessly, causing the "git-update-index --remove" to be skipped.

---
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 739a072..9a049f4 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -26,7 +26,7 @@ case "${1:-.}${2:-.}${3:-.}" in
 	fi
 	if test -f "$4"; then
 		rm -f -- "$4" &&
-		rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null
+		rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null || :
 	fi &&
 		exec git-update-index --remove -- "$4"
 	;;
Luben Tuikov· Dec 2, 2005, 01:50 UTC · re: Junio C Hamano · lore

Re: resolve (merge) problems

--- Junio C Hamano <junkio@cox.net> wrote:
> However, there is a bug recently introduced in the
> merge-one-file script.  

Ok, if your patch below resolves the bug (please see my other email just posted) please submit it. (I'm hitting this bug everytime there's a file deleted from the kernel tree and I try to merge.)

Thanks,
   Luben
Show 52 quoted lines
> 
> Although the conflict resolution procedure I described applies
> if you really had a real conflicting merge, I suspect your merge
> should not have failed in the first place.
> 
>         case "${1:-.}${2:-.}${3:-.}" in
>         #
>         # Deleted in both or deleted in one and unchanged in the other
>         #
>         "$1.." | "$1.$1" | "$1$1.")
>                 if [ "$2" ]; then
>                         echo "Removing $4"
>                 fi
>                 if test -f "$4"; then
>                         rm -f -- "$4" &&
>                         rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null
>                 fi &&
>                         exec git-update-index --remove -- "$4"
>                 ;;
> 
> The faliure code from "rmdir -p" leaks up and makes
> git-update-index to be skipped.  Here is a fix.
> 
> -- >8 --
> [PATCH] merge-one-file fix
> 
> 9ae2172aed289f2706a0e88288909fa47eddd7e7 used "rmdir -p"
> carelessly, causing the "git-update-index --remove" to be
> skipped.
> 
> ---
> diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
> index 739a072..9a049f4 100755
> --- a/git-merge-one-file.sh
> +++ b/git-merge-one-file.sh
> @@ -26,7 +26,7 @@ case "${1:-.}${2:-.}${3:-.}" in
>  	fi
>  	if test -f "$4"; then
>  		rm -f -- "$4" &&
> -		rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null
> +		rmdir -p "$(expr "$4" : '\(.*\)/')" 2>/dev/null || :
>  	fi &&
>  		exec git-update-index --remove -- "$4"
>  	;;
> 
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Junio C Hamano· Dec 2, 2005, 01:58 UTC · re: Luben Tuikov · lore

Re: resolve (merge) problems

Luben Tuikov <ltuikov@yahoo.com> writes:
> Ok, if your patch below resolves the bug (please see my
> other email just posted) please submit it.  (I'm hitting
> this bug everytime there's a file deleted from the
> kernel tree and I try to merge.)

Sorry to hear that. The patch I sent you is already pushed out and mirrored the public machines.

The failure from '-s recursive' (lack of heapq) makes me suspect that your Python installation is too old. The 'resolve' method you've been using should work fine for this case; otherwise replace '-s recursive' in the message from Linus with '-s resolve' for the 'git merge' commandline, like this:

	$ git merge -s resolve "merge linus' tree" HEAD master
Luben Tuikov· Dec 2, 2005, 02:05 UTC · re: Junio C Hamano · lore

Re: resolve (merge) problems

--- Junio C Hamano <junkio@cox.net> wrote:
Show 9 quoted lines
> Luben Tuikov <ltuikov@yahoo.com> writes:
> 
> > Ok, if your patch below resolves the bug (please see my
> > other email just posted) please submit it.  (I'm hitting
> > this bug everytime there's a file deleted from the
> > kernel tree and I try to merge.)
> 
> Sorry to hear that.  The patch I sent you is already pushed out
> and mirrored the public machines.
Yes, I pulled right after I posted and saw you pushed it.
> 
> The failure from '-s recursive' (lack of heapq) makes me suspect
> that your Python installation is too old.  The 'resolve' method
> you've been using should work fine for this case; 

$python -V Python 2.4.2 $which python /usr/local/bin/python

Show 5 quoted lines
>otherwise
> replace '-s recursive' in the message from Linus with '-s
> resolve' for the 'git merge' commandline, like this:
> 
> 	$ git merge -s resolve "merge linus' tree" HEAD master
Ok, I'll try this next time I hit this problem.
Thanks,
   Luben
Junio C Hamano· Dec 2, 2005, 05:09 UTC · re: Luben Tuikov · lore

Re: resolve (merge) problems

Luben Tuikov <ltuikov@yahoo.com> writes:
> $python -V
> Python 2.4.2
> $which python
> /usr/local/bin/python

Since you do not want to use /usr/bin/python but from your own location /usr/local/bin/python, I presume you built git with

	$ make PYTHON_PATH=/usr/local/bin/python

among other installation specific override needed on your machine?

Luben Tuikov· Dec 2, 2005, 13:59 UTC · re: Junio C Hamano · lore

Re: resolve (merge) problems

--- Junio C Hamano <junkio@cox.net> wrote:
Show 14 quoted lines
> Luben Tuikov <ltuikov@yahoo.com> writes:
> 
> > $python -V
> > Python 2.4.2
> > $which python
> > /usr/local/bin/python
> 
> Since you do not want to use /usr/bin/python but from your own
> location /usr/local/bin/python, I presume you built git with
> 
> 	$ make PYTHON_PATH=/usr/local/bin/python
> 
> among other installation specific override needed on your
> machine?
Oops :-) (lol)
Thanks,
    Luben
Linus Torvalds· Dec 2, 2005, 00:07 UTC · re: Luben Tuikov · lore

Re: resolve (merge) problems

On Thu, 1 Dec 2005, Luben Tuikov wrote:
Show 11 quoted lines
> 
> $git resolve HEAD master "merge linus' tree"
> Trying to merge 5666c0947ede0432ba5148570aa66ffb9febff5b into
> 32df3299405fb7054b76346899f3db2fa29150fb using 458af5439fe7ae7d95ca14106844e61f0795166c.
> Simple merge failed, trying Automatic merge
> Removing arch/arm/configs/poodle_defconfig
> Removing drivers/atm/atmdev_init.c
> fatal: merge program failed
> Automatic merge failed, fix up by hand
> 
> How do I proceed from here?

Well, first off, you would probably have been better off with the smarter recursive merge instead of the old "git resolve":

	git merge -s recursive "merge linus' tree" HEAD master
(the "-s recursive" isn't really needed, it _should_ be the default).

You can re-try that by doing a "git reset --hard" (to get rid of the partial merge) and just starting over.

> The output from git-diff-index is:

Don't. You'll see all the changes relative to HEAD, which _includes_ all the stuff that got cleanly merged.

Instead, do just a
	git diff
or perhaps
	git-diff-files --name-status

which will show much better what is going on. In this case, I suspect that the problem is that my branch removed "poodle_defconfig", and you had changes in it, no? Or maybe there were conflicts in atmdev_init.c, so they got left in an unmerged state..

Regardless, the git-diff-files interface should show you which files are unmerged and need to be fixed up.

Just fix them up: either remove them, or edit them to taste, and then do "git-update-index <filename>" (add the "--remove" option if you deleted the file), and then finish it off when you're happy with a "git commit".

That _should_ fix it all up.
		Linus
Luben Tuikov· Dec 2, 2005, 01:44 UTC · re: Linus Torvalds · lore

Re: resolve (merge) problems

--- Linus Torvalds <torvalds@osdl.org> wrote:
Show 9 quoted lines
> Well, first off, you would probably have been better off with the smarter 
> recursive merge instead of the old "git resolve":
> 
> 	git merge -s recursive "merge linus' tree" HEAD master
> 
> (the "-s recursive" isn't really needed, it _should_ be the default).
> 
> You can re-try that by doing a "git reset --hard" (to get rid of the 
> partial merge) and just starting over.

Ok, what I've been doing is: git-read-tree --reset -u <last committish> git-checkout-index -u -f -a

to "roll-back" the index to the last "good" state. (but I guess that has the same effect)

Then I re-tried the new git merge, and got this:
$git merge -s recursive "merge linus' tree" HEAD master 
Trying really trivial in-index merge...
fatal: Merge requires file-level merging
Nope.
Traceback (most recent call last):
  File "/home/luben/bin/git-merge-recursive", line 10, in ?
    from heapq import heappush, heappop
ImportError: No module named heapq
Automatic merge failed/prevented; fix up by hand
The git I have is latest: b34403aa97047f90c0cdd5177e63a8e7530e3388
Show 17 quoted lines
> > The output from git-diff-index is:
> 
> Don't. You'll see all the changes relative to HEAD, which _includes_ all 
> the stuff that got cleanly merged.
> 
> Instead, do just a
> 
> 	git diff
> 
> or perhaps
> 
> 	git-diff-files --name-status
> 
> which will show much better what is going on. In this case, I suspect that 
> the problem is that my branch removed "poodle_defconfig", and you had 
> changes in it, no? Or maybe there were conflicts in atmdev_init.c, so they 
> got left in an unmerged state..

The former. Simple deletion. I've noticed that I've those problems only when the file has been completely deleted in the tree I'm trying to merge (from).

The index is left in a state where the file doesn't exist in the working tree but is in the index.

Not sure if this is a general problem. I'd like to note though that the branches are in _different_ directories, (different index and HEAD of course), but everything else is shared (symlinks).

Show 9 quoted lines
> 
> Regardless, the git-diff-files interface should show you which files are 
> unmerged and need to be fixed up.
> 
> Just fix them up: either remove them, or edit them to taste, and then do 
> "git-update-index <filename>" (add the "--remove" option if you deleted 
> the file), and then finish it off when you're happy with a "git commit".
> 
> That _should_ fix it all up.
Ok, that worked.  The sequence I did is:

$git reset --hard $git resolve HEAD master "merge linus' tree" Trying to merge deda498710e190c7922c2634ed630ee64ce86c05 into 6fea38404a5ce270d73df9cde561135defe9ab39 using 5666c0947ede0432ba5148570aa66ffb9febff5b. Simple merge failed, trying Automatic merge Auto-merging MAINTAINERS. Removing drivers/net/sk98lin/skcsum.c fatal: merge program failed Automatic merge failed, fix up by hand $git-diff-files --name-status U drivers/net/sk98lin/skcsum.c D drivers/net/sk98lin/skcsum.c $git-update-index --remove drivers/net/sk98lin/skcsum.c $git commit -s "merge linus' tree"

And that worked. But at some point it did the right thing only with "git resolve ..." What has changed?

Thanks,
   Luben

← back to recent threads