{"thread":{"id":"3725","subject":"Why would merge fail on a one-line addition?","startedAt":"2006-03-25T22:26:01Z","lastAt":"2006-03-26T01:32:30Z","messageCount":3,"participants":["Marc Singer","Linus Torvalds","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"17955","messageId":"20060325222601.GA1500@buici.com","threadId":"3725","inReplyTo":null,"subject":"Why would merge fail on a one-line addition?","fromName":"Marc Singer","fromEmail":"elf@buici.com","sentAt":"2006-03-25T22:26:01Z","receivedAt":"2006-03-25T22:26:01Z","isPatch":false,"sender":{"key":"elf@buici.com","avatar":null},"body":"One of the unmerged files leaves this trail.\n\n  elf@florence ~...git/linux-2.6 > git-ls-files --unmerged\n  100644 6262d449120cdcde5db1b079806dcc0d9b5e6b7c 1       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n  100644 dcb4e17b941990eabe8992680c9aa9b67afb6fd4 3       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n\n  elf@florence ~...git/linux-2.6 > git-cat-file blob 6262d449120cdcde5db1b079806dcc0d9b5e6b7c > a\n  elf@florence ~...git/linux-2.6 > git-cat-file blob dcb4e17b941990eabe8992680c9aa9b67afb6fd4 > b\n  elf@florence ~...git/linux-2.6 > diff a b                                       21a22\n  > #include \"common.h\"\n\nWhy would git have a problem with this?\n"},{"id":"17960","messageId":"Pine.LNX.4.64.0603251629330.15714@g5.osdl.org","threadId":"3725","inReplyTo":"20060325222601.GA1500@buici.com","subject":"Re: Why would merge fail on a one-line addition?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-03-26T00:31:26Z","receivedAt":"2006-03-26T00:31:26Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 25 Mar 2006, Marc Singer wrote:\n\n> One of the unmerged files leaves this trail.\n> \n>   elf@florence ~...git/linux-2.6 > git-ls-files --unmerged\n>   100644 6262d449120cdcde5db1b079806dcc0d9b5e6b7c 1       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n>   100644 dcb4e17b941990eabe8992680c9aa9b67afb6fd4 3       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n> \n>   elf@florence ~...git/linux-2.6 > git-cat-file blob 6262d449120cdcde5db1b079806dcc0d9b5e6b7c > a\n>   elf@florence ~...git/linux-2.6 > git-cat-file blob dcb4e17b941990eabe8992680c9aa9b67afb6fd4 > b\n>   elf@florence ~...git/linux-2.6 > diff a b                                       21a22\n>   > #include \"common.h\"\n> \n> Why would git have a problem with this?\n\nThat whole file was apparently removed in the branch you are merging into \n(no stage 2). So what should the merge do? Throw away the one-liner \naddition (likely the correct thing) or maybe it should go somewhere else \n(ie maybe it wasn't removed outright, but the contents moved into another \nfile, which would now need the one-line addition).\n\n\t\tLinus\n"},{"id":"17968","messageId":"7vfyl6t2hd.fsf@assigned-by-dhcp.cox.net","threadId":"3725","inReplyTo":"20060325222601.GA1500@buici.com","subject":"Re: Why would merge fail on a one-line addition?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-26T01:32:30Z","receivedAt":"2006-03-26T01:32:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marc Singer <elf@buici.com> writes:\n\n> One of the unmerged files leaves this trail.\n>\n>   elf@florence ~...git/linux-2.6 > git-ls-files --unmerged\n>   100644 6262d449120cdcde5db1b079806dcc0d9b5e6b7c 1       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n>   100644 dcb4e17b941990eabe8992680c9aa9b67afb6fd4 3       arch/arm/mach-lh7a40x/irq-lpd7a40x.c\n\n> Why would git have a problem with this?\n\nYour change and the change in the other branch are conflicting\nand git is helping you notice that.\n\nThe index has different #1 and #3 with #2 missing.  This means\nthe common ancestor (#1) had it, you (#2) _removed_ it, while\nthe other branch (#3) modified it.  Should it carry forward the\nmodification (one line addition) made by the other branch and\nthen remove the file to match yours, or should it remove it to\nmatch yours and ignore what the other branch did?\n\nIf you do not want to have that file in the result, record the\npath as such and make a commit.  Since there is no #2, your\nworking tree probably do not have that path, so:\n\n        $ git update-index --remove arch/arm/mach-lh7a40x/irq-lpa7a40x.c\n\nto resolve the path, resolve other conflicts if you have any and\nthen commit the result.\n\nHowever, this _might_ be a case where your line of development\nsomewhere between the common ancestor and your tip moved that\nfile somewhere else in which case you may want to do three-way\nmerge between 6262d4 blob, your tip and dcb4e1 blob _and_ commit\nthe result at the path you have.  I do not know if that is the\ncase and even if so I do not know where you have the\ncorresponding file in your tree, but just as an example if you\nhave it in arch/arm/mach-foo/irq-lpd7a40x.c, you would:\n\n\t$ cd arch/arm/mach-foo/\n\t$ common=$(git unpack-file 6262d4)\n        $ his=$(git unpack-file dcb4e1)\n        $ merge irq-lpd7a40x.c $common $his\n        $ rm -f $common $his\n\nAnd then eyeball the result of the merge, fix it up as\nnecessary, and then:\n\n\t$ git update-index --remove arch/arm/mach-lh7a40x/irq-lpa7a40x.c\n        $ git update-index arch/arm/mach-foo/irq-lpd7a40x.c\n\nbefore committing.\n"}]}