{"thread":{"id":"19342","subject":"Re: [Q] merge squash unexpected conflicts","startedAt":"2009-05-14T02:42:36Z","lastAt":"2009-05-14T18:25:23Z","messageCount":11,"participants":["Cory Sharp","Junio C Hamano","Michael Radziej","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"113863","messageId":"bb9d69200905131942t7a43a29fh9638d2548e9f12dc@mail.gmail.com","threadId":"19342","inReplyTo":"bb9d69200905131706m61b0dda1xc347ca2e719ec142@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T02:42:36Z","receivedAt":"2009-05-14T02:42:36Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"Using git 1.6.3.1, when using \"git merge --squash\" I get unexpected\nconflicts when merging an update to a file that was added after the\noriginal branch point, like this\n\n  * Initialize git repo\n  * Add hello to master\n  * Create topic branch\n  * Add goodbye to master\n  * Merge squash master into topic, gets new goodbye\n  * Update goodbye in master\n  * Again merge squash master into topic, update goodbye\n\nThe second merge squash produces a conflict in goodbye.\n\nAm I doing something a little wrong or unexpected?  Is there a way\naround this squash conflict behavior?  This doesn't seem to happen\nwith plain merge without squash.  I've appended a small bash script to\nshow this behavior - run it from an empty directory.\n\nThanks,\nCory\n\n\n#!/bin/sh\n\ntry() {\n    echo \"$@\"\n    \"$@\" || exit 1\n}\n\nnote() {\n    echo\n    echo \"##\" \"$@\" \"##\"\n}\n\n[ -d .git ] && echo .git already exists, aborting. && exit 1\n\nnote \"Initialize git repo\"\ntry git init\n\nnote \"Add hello to master\"\necho \"hello world\" > hello.txt\ntry git add hello.txt\ntry git commit -m \"Added hello\"\n\nnote \"Create topic branch\"\ntry git checkout -b topic\n\nnote \"Add goodbye to master\"\ntry git checkout master\necho \"farewell world\" > goodbye.txt\ntry git add goodbye.txt\ntry git commit -m \"Added goodbye\"\n\nnote \"Merge master into topic, gets new goodbye\"\ntry git checkout topic\ntry git merge --squash master\ntry git commit -m \"Merged master\"\n\nnote \"Update goodbye in master\"\ntry git checkout master\necho \"goodbye world\" > goodbye.txt\ntry git add goodbye.txt\ntry git commit -m \"Updated goodbye\"\n\nnote \"Again merge master into topic, update goodbye\"\ntry git checkout topic\ntry git merge --squash master\n"},{"id":"113865","messageId":"7v4ovo1iap.fsf@alter.siamese.dyndns.org","threadId":"19342","inReplyTo":"bb9d69200905131942t7a43a29fh9638d2548e9f12dc@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-14T03:21:02Z","receivedAt":"2009-05-14T03:21:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Cory Sharp <cory.sharp@gmail.com> writes:\n\n> Am I doing something a little wrong or unexpected?  Is there a way\n> around this squash conflict behavior?  This doesn't seem to happen\n> with plain merge without squash.\n\nOf course.  That's the whole point of recording a merge as a merge.\n"},{"id":"113867","messageId":"bb9d69200905132057u60adc2f8vb9ba9a35791f72ac@mail.gmail.com","threadId":"19342","inReplyTo":"7v4ovo1iap.fsf@alter.siamese.dyndns.org","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T03:57:43Z","receivedAt":"2009-05-14T03:57:43Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"On Wed, May 13, 2009 at 8:21 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Cory Sharp <cory.sharp@gmail.com> writes:\n>\n>> Am I doing something a little wrong or unexpected?  Is there a way\n>> around this squash conflict behavior?  This doesn't seem to happen\n>> with plain merge without squash.\n>\n> Of course.  That's the whole point of recording a merge as a merge.\n>\n\n$ git help merge\n\n  --squash\n           Produce the working tree and index state as if a real merge\nhappened. ... This allows you to create a\n           single commit on top of the current branch whose effect is\nthe same as merging another branch.\n"},{"id":"113870","messageId":"7veiusz45w.fsf@alter.siamese.dyndns.org","threadId":"19342","inReplyTo":"bb9d69200905132057u60adc2f8vb9ba9a35791f72ac@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-14T04:42:19Z","receivedAt":"2009-05-14T04:42:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Cory Sharp <cory.sharp@gmail.com> writes:\n\n> On Wed, May 13, 2009 at 8:21 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> ..\n>> Of course.  That's the whole point of recording a merge as a merge.\n>>\n>\n> $ git help merge\n>\n>   --squash\n>            Produce the working tree and index state as if a real merge\n> happened. ... This allows you to create a\n>            single commit on top of the current branch whose effect is\n> the same as merging another branch.\n\nWhat's your point?\n\nWIth --squash, the tree and the index state becomes the same as if a real\nmerge happened.  But the merge history is discarded with --squash.  It is\na simulation of a merge in CVS and SVN (before they added \"merge tracking\").\n\nIf you want support for repeated merges by merge tracking, you do not want\ntodiscard the merge history by using --squash.\n"},{"id":"113887","messageId":"bb9d69200905132334m7a4e3a4akde3529abeab5a09@mail.gmail.com","threadId":"19342","inReplyTo":"7veiusz45w.fsf@alter.siamese.dyndns.org","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T06:34:24Z","receivedAt":"2009-05-14T06:34:24Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"On Wed, May 13, 2009 at 9:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> What's your point?\n\nI am asking for help and understanding.\n\n> WIth --squash, the tree and the index state becomes the same as if a real\n> merge happened.  But the merge history is discarded with --squash.  It is\n> a simulation of a merge in CVS and SVN (before they added \"merge tracking\").\n>\n> If you want support for repeated merges by merge tracking, you do not want\n> todiscard the merge history by using --squash.\n\nWhy doesn't --squash do merge tracking?  The help didn't indicate that\nit doesn't, and I don't understand why it shouldn't -- since I *could*\ntrack the previous merge point manually and do \"git diff --binary\nPREV_MERGE..NEXT_MERGE | git apply -\" to do the merge myself.\n\nBut since that's me manually performing merge tracking, why doesn't\n\"merge --squash\" track like just \"merge\" does?  If I didn't want\ntracking, I would expect to use some other command than \"git merge\n[options]\".\n\nThanks for your help,\nCory\n"},{"id":"113891","messageId":"7v4ovoxk0n.fsf@alter.siamese.dyndns.org","threadId":"19342","inReplyTo":"bb9d69200905132334m7a4e3a4akde3529abeab5a09@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-14T06:42:48Z","receivedAt":"2009-05-14T06:42:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Cory Sharp <cory.sharp@gmail.com> writes:\n\n>> If you want support for repeated merges by merge tracking, you do not want\n>> todiscard the merge history by using --squash.\n>\n> Why doesn't --squash do merge tracking?  The help didn't indicate that\n> it doesn't, and I don't understand why ...\n\nBecause \"merge\" is (no surprise) what tracks what (two or more) things\nwere merged.  And with --squash you are choosing not to make a merge.  I\nam not sure if there is any more thing to be explained...\n"},{"id":"113892","messageId":"bb9d69200905132354h6b64171g24351840fb1d0893@mail.gmail.com","threadId":"19342","inReplyTo":"7v4ovoxk0n.fsf@alter.siamese.dyndns.org","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T06:54:41Z","receivedAt":"2009-05-14T06:54:41Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"On Wed, May 13, 2009 at 11:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Because \"merge\" is (no surprise) what tracks what (two or more) things\n> were merged.  And with --squash you are choosing not to make a merge.  I\n> am not sure if there is any more thing to be explained...\n\nYeah I'm not quite getting it.  Thanks for trying to explain, though.\n"},{"id":"113894","messageId":"20090514070129.GL8212@noris.de","threadId":"19342","inReplyTo":"bb9d69200905132354h6b64171g24351840fb1d0893@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Michael Radziej","fromEmail":"mir@noris.de","sentAt":"2009-05-14T07:01:29Z","receivedAt":"2009-05-14T07:01:29Z","isPatch":false,"sender":{"key":"mir@noris.de","avatar":null},"body":"On Wed, May 13, Cory Sharp wrote:\n\n> Yeah I'm not quite getting it.  Thanks for trying to explain, though.\n\ngit merge --squash is not a merge at all. It only creates a regular commit\nwith one parent. It is useful only in very special circumstances.\n\n\nMichael\n\n-- \nnoris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -\nTel +49-911-9352-0 - Fax +49-911-9352-100\nhttp://www.noris.de - The IT-Outsourcing Company\n \nVorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - \nVorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689\n"},{"id":"113923","messageId":"4A0C0BDF.9020803@drmicha.warpmail.net","threadId":"19342","inReplyTo":"bb9d69200905132057u60adc2f8vb9ba9a35791f72ac@mail.gmail.com","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-14T12:17:35Z","receivedAt":"2009-05-14T12:17:35Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Cory Sharp venit, vidit, dixit 14.05.2009 05:57:\n> On Wed, May 13, 2009 at 8:21 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Cory Sharp <cory.sharp@gmail.com> writes:\n>>\n>>> Am I doing something a little wrong or unexpected?  Is there a way\n>>> around this squash conflict behavior?  This doesn't seem to happen\n>>> with plain merge without squash.\n>>\n>> Of course.  That's the whole point of recording a merge as a merge.\n>>\n> \n> $ git help merge\n> \n>   --squash\n>            Produce the working tree and index state as if a real merge\n> happened. ... This allows you to create a\n>            single commit on top of the current branch whose effect is\n> the same as merging another branch.\n\nThe problem is simply in the \"...\". You cut out the vital part:\n\n\n        but do not actually make a commit or\n        move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to\n        cause the next `git commit` command to create a merge\n        commit.\n\nSee? Tree: yes, index: yes, merge info: no.\n\nGit does perform a (tree) merge with --squash, but records the resulting\ntree as an ordinary non-merge commit (with a single parent).\n\nI'm not sure whether the statement about the index is completely\ncorrect, though. During a merge the index records info about the merge\n(stages :1: etc.) but that as missing with --squash. Only the resulting\ntree is added to the index. How about the below?\n\nMichael\n\ndiff --git a/Documentation/merge-options.txt\nb/Documentation/merge-options.txt\nindex 637b53f..adadf8e 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -39,7 +39,8 @@\n\n --squash::\n        Produce the working tree and index state as if a real\n-       merge happened, but do not actually make a commit or\n+       merge happened (except for the merge information),\n+       but do not actually make a commit or\n        move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to\n        cause the next `git commit` command to create a merge\n        commit.  This allows you to create a single commit on\n"},{"id":"113935","messageId":"bb9d69200905140747j60b2e09flaabbb4db09b371b4@mail.gmail.com","threadId":"19342","inReplyTo":"4A0C0BDF.9020803@drmicha.warpmail.net","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T14:47:40Z","receivedAt":"2009-05-14T14:47:40Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"On Thu, May 14, 2009 at 5:17 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> Cory Sharp venit, vidit, dixit 14.05.2009 05:57:\n>> On Wed, May 13, 2009 at 8:21 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>> Cory Sharp <cory.sharp@gmail.com> writes:\n>>>\n>>>> Am I doing something a little wrong or unexpected?  Is there a way\n>>>> around this squash conflict behavior?  This doesn't seem to happen\n>>>> with plain merge without squash.\n>>>\n>>> Of course.  That's the whole point of recording a merge as a merge.\n>>>\n>>\n>> $ git help merge\n>>\n>>   --squash\n>>            Produce the working tree and index state as if a real merge\n>> happened. ... This allows you to create a\n>>            single commit on top of the current branch whose effect is\n>> the same as merging another branch.\n>\n> The problem is simply in the \"...\". You cut out the vital part:\n>\n>\n>        but do not actually make a commit or\n>        move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to\n>        cause the next `git commit` command to create a merge\n>        commit.\n>\n> See? Tree: yes, index: yes, merge info: no.\n>\n> Git does perform a (tree) merge with --squash, but records the resulting\n> tree as an ordinary non-merge commit (with a single parent).\n>\n> I'm not sure whether the statement about the index is completely\n> correct, though. During a merge the index records info about the merge\n> (stages :1: etc.) but that as missing with --squash. Only the resulting\n> tree is added to the index. How about the below?\n\nNow I see, thanks for the help.  The elided part, at the time I elided\nit, did not make me understand that merge info was not written,\nparticularly when surrounded by its original accompanying text.\n\nThanks again,\nCory\n"},{"id":"113947","messageId":"bb9d69200905141125i4a8ffaa8j6aea2a6c44de0c7d@mail.gmail.com","threadId":"19342","inReplyTo":"20090514070129.GL8212@noris.de","subject":"Re: [Q] merge squash unexpected conflicts","fromName":"Cory Sharp","fromEmail":"cory.sharp@gmail.com","sentAt":"2009-05-14T18:25:23Z","receivedAt":"2009-05-14T18:25:23Z","isPatch":false,"sender":{"key":"cory.sharp@gmail.com","avatar":null},"body":"On Thu, May 14, 2009 at 12:01 AM, Michael Radziej <mir@noris.de> wrote:\n> git merge --squash is not a merge at all. ...\n> It is useful only in very special circumstances.\n\nYou're right.  I (incorrectly) thought I had to use --squash to\nproperly interface with an svn branch and trunk through git-svn.  I\nthought not using squash would trigger hundreds of commits - it\ndoesn't, nice things happen with just \"merge\".\n\nThanks everyone for helping me,\nCory\n"}]}