{"thread":{"id":"18487","subject":"git rebase + fuzz = possible bad merge","startedAt":"2009-03-23T10:41:34Z","lastAt":"2009-03-23T15:36:24Z","messageCount":4,"participants":["Benny Halevy","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"109039","messageId":"49C7675E.9000309@panasas.com","threadId":"18487","inReplyTo":null,"subject":"git rebase + fuzz = possible bad merge","fromName":"Benny Halevy","fromEmail":"bhalevy@panasas.com","sentAt":"2009-03-23T10:41:34Z","receivedAt":"2009-03-23T10:41:34Z","isPatch":false,"sender":{"key":"bhalevy@panasas.com","avatar":null},"body":"I'm hitting bad merges with (non interactive) git rebase\nwhen a hunk is merged pre-maturely into an inexact match\nwhen there's fuzz.\n\nThe following shell script reproduce this with\ngit version 1.6.2.1:\n\n#!/bin/sh\n\nrm -rf test_file .git\ngit init\n\ncat >test_file <<EOF\nstruct one {\n\tline 1;\n\tline 2;\n\tline 3;\n\tline 4;\n\tline 5;\n\tline 6;\n\tline 7;\n};\n\nstruct two {\n\tline 1;\n\tline 2;\n\tline 3;\n\tline 4;\n\tline 5;\n\tline 6;\n\tline 7;\n};\nEOF\n\ngit add test_file\ngit commit -m test_file\n\ngit am <<EOF\nFrom: Benny Halevy <bhalevy@panasas.com>\nSubject: change struct two\n\ndiff --git a/test_file b/test_file\n--- a/test_file\n+++ b/test_file\n@@ -12,7 +12,7 @@ struct two {\n \tline 1;\n \tline 2;\n \tline 3;\n-\tline 4;\n+\tLINE 4;\n \tline 5;\n \tline 6;\n \tline 7;\nEOF\n\ngit checkout -b test_branch HEAD^\n{ for i in {1..10}; do echo fuzz $i; done; echo; cat test_file; } > fuzz_file\nmv fuzz_file test_file\n\ngit commit -a -m fuzz\n\ngit rebase --onto test_branch master^ master\n\nif [ $(awk '/LINE/ {print NR}' test_file) != 26 ]; then\n\techo 1>&2 $0: test failed\n\texit 1\nelse\n\techo 1>&2 $0: test succeeded\nfi\n"},{"id":"109059","messageId":"200903231454.48600.trast@student.ethz.ch","threadId":"18487","inReplyTo":"49C7675E.9000309@panasas.com","subject":"Re: git rebase + fuzz = possible bad merge","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-03-23T13:54:43Z","receivedAt":"2009-03-23T13:54:43Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Benny Halevy wrote:\n> I'm hitting bad merges with (non interactive) git rebase\n> when a hunk is merged pre-maturely into an inexact match\n> when there's fuzz.\n[...]\n> { for i in {1..10}; do echo fuzz $i; done; echo; cat test_file; } > fuzz_file\n[...]\n> git rebase --onto test_branch master^ master\n\ngit-am, and by extension rebase, by default doesn't take history into\naccount.  It just applies the patches \"blindly\".  Thus, there's no way\nto know which series of 'line N' you really wanted it to go onto.\n\nTo avoid this issue, use the -m option to git-rebase so that it uses a\n\"real\" merge.  (You can achieve similar effects for git-am with the -3\noption.)\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"109063","messageId":"49C79780.20105@panasas.com","threadId":"18487","inReplyTo":"200903231454.48600.trast@student.ethz.ch","subject":"Re: git rebase + fuzz = possible bad merge","fromName":"Benny Halevy","fromEmail":"bhalevy@panasas.com","sentAt":"2009-03-23T14:06:56Z","receivedAt":"2009-03-23T14:06:56Z","isPatch":false,"sender":{"key":"bhalevy@panasas.com","avatar":null},"body":"On Mar. 23, 2009, 15:54 +0200, Thomas Rast <trast@student.ethz.ch> wrote:\n> Benny Halevy wrote:\n>> I'm hitting bad merges with (non interactive) git rebase\n>> when a hunk is merged pre-maturely into an inexact match\n>> when there's fuzz.\n> [...]\n>> { for i in {1..10}; do echo fuzz $i; done; echo; cat test_file; } > fuzz_file\n> [...]\n>> git rebase --onto test_branch master^ master\n> \n> git-am, and by extension rebase, by default doesn't take history into\n> account.  It just applies the patches \"blindly\".  Thus, there's no way\n> to know which series of 'line N' you really wanted it to go onto.\n> \n> To avoid this issue, use the -m option to git-rebase so that it uses a\n> \"real\" merge.  (You can achieve similar effects for git-am with the -3\n> option.)\n> \n\nOK. -m indeed helps and I'm certainly going to adopt it for my rebase scripts.\ngit rebase -i does too, BTW.\n\nI would expect though that the default mode for automatic rebase would be\nthe strictest and safest...\n\nBenny\n"},{"id":"109080","messageId":"49C7AC78.5070801@panasas.com","threadId":"18487","inReplyTo":"49C79780.20105@panasas.com","subject":"Re: git rebase + fuzz = possible bad merge","fromName":"Benny Halevy","fromEmail":"bhalevy@panasas.com","sentAt":"2009-03-23T15:36:24Z","receivedAt":"2009-03-23T15:36:24Z","isPatch":false,"sender":{"key":"bhalevy@panasas.com","avatar":null},"body":"On Mar. 23, 2009, 16:06 +0200, Benny Halevy <bhalevy@panasas.com> wrote:\n> On Mar. 23, 2009, 15:54 +0200, Thomas Rast <trast@student.ethz.ch> wrote:\n>> Benny Halevy wrote:\n>>> I'm hitting bad merges with (non interactive) git rebase\n>>> when a hunk is merged pre-maturely into an inexact match\n>>> when there's fuzz.\n>> [...]\n>>> { for i in {1..10}; do echo fuzz $i; done; echo; cat test_file; } > fuzz_file\n>> [...]\n>>> git rebase --onto test_branch master^ master\n>> git-am, and by extension rebase, by default doesn't take history into\n>> account.  It just applies the patches \"blindly\".  ...\n\ngit am, in contrast to git rebase, errs on fuzz and you'll need to\napply the patch manually.  It might be annoying, but it'd be safer\nif git rebase would either stop on fuzz too or revert to using\nmerge strategies (same as using git rebase -m) by default.\n\n>> ...  Thus, there's no way\n>> to know which series of 'line N' you really wanted it to go onto.\n\nWell, there's the hunk header.\n\nBenny\n\n>>\n>> To avoid this issue, use the -m option to git-rebase so that it uses a\n>> \"real\" merge.  (You can achieve similar effects for git-am with the -3\n>> option.)\n>>\n> \n> OK. -m indeed helps and I'm certainly going to adopt it for my rebase scripts.\n> git rebase -i does too, BTW.\n> \n> I would expect though that the default mode for automatic rebase would be\n> the strictest and safest...\n> \n> Benny\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}