{"thread":{"id":"25606","subject":"git stash and manually edited chunks","startedAt":"2010-11-01T07:27:04Z","lastAt":"2010-11-03T10:53:44Z","messageCount":6,"participants":["Olivier Verdier","Matthieu Moy","Gavin Guo"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"154916","messageId":"AANLkTik6esqP2EkA6SFmfS0zdokG1iTKXqivA2wnpq=9@mail.gmail.com","threadId":"25606","inReplyTo":null,"subject":"git stash and manually edited chunks","fromName":"Olivier Verdier","fromEmail":"zelbier@gmail.com","sentAt":"2010-11-01T07:27:04Z","receivedAt":"2010-11-01T07:27:04Z","isPatch":false,"sender":{"key":"zelbier@gmail.com","avatar":null},"body":"Hi!\nI asked a question on stackoverflow\n(http://stackoverflow.com/questions/4058372/git-stash-and-edited-chunks)\nand someone suggested it might be a bug...\nFor convenience, I reproduce the question here:\n\n I occasionally have the following problem, which is reproduced by the\nfollowing sequence of commands:\n\n* git add -p my_file\n* I edit a chunk *manually* (using e)\n* git stash --keep-index\n* git stash pop\n\nNow the problem occurs: the file my_file is now considered as\nconflicted, and git has completely messed with my edited chunk, so I\nhave to edit the file, remove the merge marks, and run git add my_file\nfollowed by git reset HEAD\n\nI'm puzzled because this happens only when editing a chunk manually. I\ndon't see how this should make any difference at all.\n\nI'm using version 1.7.3.1 on Mac OS X.\n\nThanks!!\n"},{"id":"154931","messageId":"vpqfwvlkmkv.fsf@bauges.imag.fr","threadId":"25606","inReplyTo":"AANLkTik6esqP2EkA6SFmfS0zdokG1iTKXqivA2wnpq=9@mail.gmail.com","subject":"Re: git stash and manually edited chunks","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-11-01T16:58:24Z","receivedAt":"2010-11-01T16:58:24Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Olivier Verdier <zelbier@gmail.com> writes:\n\n> Hi!\n> I asked a question on stackoverflow\n> (http://stackoverflow.com/questions/4058372/git-stash-and-edited-chunks)\n> and someone suggested it might be a bug...\n> For convenience, I reproduce the question here:\n>\n>  I occasionally have the following problem, which is reproduced by the\n> following sequence of commands:\n\nLet's say the state of your working tree here is A (and last commit is\nHEAD).\n\n> * git add -p my_file\n> * I edit a chunk *manually* (using e)\n\nHere, the index contains a state which is neither in the working tree\nnor in the last commit. Let's call this state B.\n\n> * git stash --keep-index\n\nHere, the working tree takes state B.\n\n> * git stash pop\n\nHere, you're trying to apply the stash, which is somehow a diff\nbetween HEAD and A, on your tree which is in state B. Hence the\nconflicts.\n\n\nIf you do a \"git reset --hard\" before the \"git stash pop\", you'll come\nback to state HEAD, and the stash will apply without conflict.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"154956","messageId":"AANLkTiknhRGuBMFEKbVdyN83SiF9j2nNz=v-nMaD-iTb@mail.gmail.com","threadId":"25606","inReplyTo":"vpqfwvlkmkv.fsf@bauges.imag.fr","subject":"Re: git stash and manually edited chunks","fromName":"Olivier Verdier","fromEmail":"zelbier@gmail.com","sentAt":"2010-11-02T08:37:46Z","receivedAt":"2010-11-02T08:37:46Z","isPatch":false,"sender":{"key":"zelbier@gmail.com","avatar":null},"body":"Thank you,\n\nbut that does not explain why there is a conflict *only* when I edit\nthe chunk manually, does it?\n\nBesides, some people tried to reproduce my problem on Linux and they\ngot no conflict after edited chunks.\n\nSo it seems that it could be a bug specific to Mac OS X.\n\n== Olivier\n\nOn 1 November 2010 17:58, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> Olivier Verdier <zelbier@gmail.com> writes:\n>\n>> Hi!\n>> I asked a question on stackoverflow\n>> (http://stackoverflow.com/questions/4058372/git-stash-and-edited-chunks)\n>> and someone suggested it might be a bug...\n>> For convenience, I reproduce the question here:\n>>\n>>  I occasionally have the following problem, which is reproduced by the\n>> following sequence of commands:\n>\n> Let's say the state of your working tree here is A (and last commit is\n> HEAD).\n>\n>> * git add -p my_file\n>> * I edit a chunk *manually* (using e)\n>\n> Here, the index contains a state which is neither in the working tree\n> nor in the last commit. Let's call this state B.\n>\n>> * git stash --keep-index\n>\n> Here, the working tree takes state B.\n>\n>> * git stash pop\n>\n> Here, you're trying to apply the stash, which is somehow a diff\n> between HEAD and A, on your tree which is in state B. Hence the\n> conflicts.\n>\n>\n> If you do a \"git reset --hard\" before the \"git stash pop\", you'll come\n> back to state HEAD, and the stash will apply without conflict.\n>\n> --\n> Matthieu Moy\n> http://www-verimag.imag.fr/~moy/\n>\n"},{"id":"154959","messageId":"vpqd3qoxfma.fsf@bauges.imag.fr","threadId":"25606","inReplyTo":"AANLkTiknhRGuBMFEKbVdyN83SiF9j2nNz=v-nMaD-iTb@mail.gmail.com","subject":"Re: git stash and manually edited chunks","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-11-02T09:02:37Z","receivedAt":"2010-11-02T09:02:37Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Olivier Verdier <zelbier@gmail.com> writes:\n\n> Thank you,\n>\n> but that does not explain why there is a conflict *only* when I edit\n> the chunk manually, does it?\n\nIt does.\n\nIf you did not edit the hunk manually, each hunk will be either in\nstate HEAD or in state A, and applying the diff between HEAD and A to\nsuch file will be either a no-op (hunk already applied), or a\nsuccessfull application.\n\n> Besides, some people tried to reproduce my problem on Linux and they\n> got no conflict after edited chunks.\n\nI did, on Linux. I get the same behavior as you.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"155017","messageId":"AANLkTi=O8oPjcPN1j8513Kp+OtY7Cs5WgdiVhHnyzX=C@mail.gmail.com","threadId":"25606","inReplyTo":"vpqfwvlkmkv.fsf@bauges.imag.fr","subject":"Re: git stash and manually edited chunks","fromName":"Gavin Guo","fromEmail":"tuffkidtt@gmail.com","sentAt":"2010-11-03T03:06:30Z","receivedAt":"2010-11-03T03:06:30Z","isPatch":false,"sender":{"key":"tuffkidtt@gmail.com","avatar":null},"body":"> Let's say the state of your working tree here is A (and last commit is\n> HEAD).\n>\n>> * git add -p my_file\n>> * I edit a chunk *manually* (using e)\n>\n> Here, the index contains a state which is neither in the working tree\n> nor in the last commit. Let's call this state B.\n>\n>> * git stash --keep-index\n>\n> Here, the working tree takes state B.\n>\n>> * git stash pop\n>\n> Here, you're trying to apply the stash, which is somehow a diff\n> between HEAD and A, on your tree which is in state B. Hence the\n> conflicts.\n\nI am confusing about the description here. Git stash --keep-index\nexist after editing the hunk, so why stash will save the difference\nbetween HEAD and A, I think it should be the state which is modified\nby git add -p(using e), and as a result of no conflict.\n\nGavin Guo\n"},{"id":"155041","messageId":"vpqr5f2ptjb.fsf@bauges.imag.fr","threadId":"25606","inReplyTo":"AANLkTi=O8oPjcPN1j8513Kp+OtY7Cs5WgdiVhHnyzX=C@mail.gmail.com","subject":"Re: git stash and manually edited chunks","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-11-03T10:53:44Z","receivedAt":"2010-11-03T10:53:44Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Gavin Guo <tuffkidtt@gmail.com> writes:\n\n>> Let's say the state of your working tree here is A (and last commit is\n>> HEAD).\n>>\n>>> * git add -p my_file\n>>> * I edit a chunk *manually* (using e)\n>>\n>> Here, the index contains a state which is neither in the working tree\n>> nor in the last commit. Let's call this state B.\n>>\n>>> * git stash --keep-index\n>>\n>> Here, the working tree takes state B.\n>>\n>>> * git stash pop\n>>\n>> Here, you're trying to apply the stash, which is somehow a diff\n>> between HEAD and A, on your tree which is in state B. Hence the\n>> conflicts.\n>\n> I am confusing about the description here. Git stash --keep-index\n> exist after editing the hunk, so why stash will save the difference\n> between HEAD and A, I think it should be the state which is modified\n> by git add -p(using e), and as a result of no conflict.\n\nIt's actually both. And indeed, \"diff\" is slightly oversimplified :\nstash saves the state of HEAD and of the index, as two commits. Try\nrunning \"gitk --all\" after stash to see what's going on.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}