{"thread":{"id":"63283","subject":"Bug in git-stash","startedAt":"2025-04-11T12:27:24Z","lastAt":"2025-04-12T16:29:18Z","messageCount":3,"participants":["Filip Skogstjärna","D. Ben Knoble","Lucas Seiki Oshiro"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"515997","messageId":"AE8657E8-D68A-4B86-9644-B57AEE743794@gmail.com","threadId":"63283","inReplyTo":null,"subject":"Bug in git-stash","fromName":"Filip Skogstjärna","fromEmail":"f.skogstjarna@gmail.com","sentAt":"2025-04-11T12:27:10Z","receivedAt":"2025-04-11T12:27:24Z","isPatch":false,"sender":{"key":"f.skogstjarna@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nedit a file\n\n`git add <file>`\n\nedit the same line again\n\n`git stash -k`\n\nWhat did you expect to happen? (Expected behavior)\nI expect the stash to contain the diff between the staged file and the unstaged file\n\nWhat happened instead? (Actual behavior)\nThe stash contains the diff between HEAD and the unstaged file\n\nWhat's different between what you expected and what actually happened?\nThe difference is that `git stash pop` will result in a merge conflict,\neven though no files has been changed between stashing and unstashing.\n\nAnything else you want to add:\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.39.5 (Apple Git-154)\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 23.6.0 Darwin Kernel Version 23.6.0: Fri Nov 15 15:11:49 PST 2024; root:xnu-10063.141.1.702.7~1/RELEASE_ARM64_T6020 arm64\ncompiler info: clang: 16.0.0 (clang-1600.0.26.6)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh"},{"id":"516008","messageId":"CALnO6CC9QiaE5xdSVr_PYm=TPHPR=7US2KEFeo5DzYs4KouzbQ@mail.gmail.com","threadId":"63283","inReplyTo":"AE8657E8-D68A-4B86-9644-B57AEE743794@gmail.com","subject":"Re: Bug in git-stash","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-04-11T18:55:52Z","receivedAt":"2025-04-11T18:56:05Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Fri, Apr 11, 2025 at 8:29 AM Filip Skogstjärna\n<f.skogstjarna@gmail.com> wrote:\n>\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>\n> edit a file\n>\n> `git add <file>`\n>\n> edit the same line again\n>\n> `git stash -k`\n\nI think you might find the following thread instructive:\nhttps://lore.kernel.org/git/ZikMqXeDnOqK_wlq@thechases.com/\n\nCheers,\n-- \nD. Ben Knoble\n"},{"id":"516044","messageId":"A17CFE85-47BD-4DD1-B377-8EA27A1262BA@gmail.com","threadId":"63283","inReplyTo":"AE8657E8-D68A-4B86-9644-B57AEE743794@gmail.com","subject":"Re: Bug in git-stash","fromName":"Lucas Seiki Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-04-12T16:29:03Z","receivedAt":"2025-04-12T16:29:18Z","isPatch":false,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"Hi!\n\n> The stash contains the diff between HEAD and the unstaged file\n\nThis is expected behavior. From the git stash manpage:\n\n\"\"\"\nAll changes already added to the index are left intact.\n\"\"\"\n\nThis is, it works just like running `git stash` but without\ntouching the index and keeping the already staged changes in\nthe working directory.\n\nBut still, each stash entry is two commits, one containing\nthe state of the index and other containing the state of the\nworking tree. You can see that in git stash manpage, in the\nsection \"DISCUSSION\". This way, you can operate on them like\nany other commit.\n\nMore specifically, if you want the stashed changes from the\nindex to the working directory, you can run:\n\ngit cherry-pick -n -m 2 stash\n\nwhere:\n\n-n: cherry-picks the content without creating a commit\n\n-m 2: given that the last commit is a merge commit whose\n  parents are the HEAD at the moment of stashing changes (the\n  first parent) and the commit containing the state of the\n  index (the second parent), apply the changes based on the\n  second parent (i.e. what was in the working directory but\n  not in the index)\n\n- stash: this is the stash reference (just like any other\n  reference, like branches or tags). It points to the last\n  commit of the last stash entry. If you want to use other\n  entry, follow the reflog syntax (i.e. stash@{1})\n"}]}