{"thread":{"id":"53584","subject":"Re: [BUG?] 'git rebase --abort' couldn't abort aborted rebase","startedAt":"2020-05-30T16:24:18Z","lastAt":"2020-06-05T15:29:36Z","messageCount":4,"participants":["Elijah Newren","Thomas Braun","Phillip Wood","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"398935","messageId":"CABPp-BGh0T1xio-pRb=JVNbJDK1PWpo+v877nDfjcm6khn6NDg@mail.gmail.com","threadId":"53584","inReplyTo":"CADhmr77EbC+3f=Oa+bm18Z_SSEMK8vCjNHQniuvkdfaZdRT_5A@mail.gmail.com","subject":"Re: [BUG?] 'git rebase --abort' couldn't abort aborted rebase","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2020-05-30T16:24:04Z","receivedAt":"2020-05-30T16:24:18Z","isPatch":false,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"Hi,\n\nOn Sat, May 30, 2020 at 3:52 AM Md Naeim <naeim249@gmail.com> wrote:\n>\n>\n>\n> 01718479491\n\nCould you provide any details beyond the subject, such as the output\nfrom 'git rebase --abort', your git version, the output of `git\nstatus`, whether there are any untracked files with special status\n(e.g. ignored but a submodule in the way of something?), any special\nfile permissions (does root own some files and prevent git from\nupdating things?), operating system you are on, link to a repository\npeople can use to reproduce?  Without more details, this report is\nunactionable.\n"},{"id":"399079","messageId":"63139842-8548-6c64-1214-5469eedb8d4f@virtuell-zuhause.de","threadId":"53584","inReplyTo":"CABPp-BGh0T1xio-pRb=JVNbJDK1PWpo+v877nDfjcm6khn6NDg@mail.gmail.com","subject":"Re: [BUG?] 'git rebase --abort' couldn't abort aborted rebase","fromName":"Thomas Braun","fromEmail":"thomas.braun@virtuell-zuhause.de","sentAt":"2020-06-03T16:09:07Z","receivedAt":"2020-06-03T16:47:36Z","isPatch":false,"sender":{"key":"thomas.braun@virtuell-zuhause.de","avatar":"https://avatars.githubusercontent.com/u/1185677?v=4"},"body":"On 30.05.2020 18:24, Elijah Newren wrote:\n> On Sat, May 30, 2020 at 3:52 AM Md Naeim <naeim249@gmail.com> wrote:\n\n[...]\n\n> Could you provide any details beyond the subject, such as the output\n> from 'git rebase --abort', your git version, the output of `git\n> status`, whether there are any untracked files with special status\n> (e.g. ignored but a submodule in the way of something?), any special\n> file permissions (does root own some files and prevent git from\n> updating things?), operating system you are on, link to a repository\n> people can use to reproduce?  Without more details, this report is\n> unactionable.\n> \n\nI don't know the OPs details but I can reproduce with the following\nclumsy snippet:\n\n#!/bin/sh\n\ngit init\ngit config --global user.email \"you@example.com\"\ngit config --global user.name \"Your Name\"\ngit config rebase.autostash true\ngit config core.autocrlf false\necho \"*.abcd !eol\" > .gitattributes\ngit add .gitattributes\ngit commit -m \"Add attributes\"\necho -e \"1\\r\\n\" > test.abcd\ngit add test.abcd\ngit commit --no-verify -m \"Added test.abcd\" test.abcd\necho \"*.abcd eol=lf\" > .gitattributes\ngit add .gitattributes\ngit commit -m \"Add attributes (LF)\"\ngit rebase --root --interactive\ngit rebase --abort\nwhich gives\n\n ./run.sh\nInitialized empty Git repository in E:/projekte/test-init/.git/\n[master (root-commit) 7169943] Add attributes\n 1 file changed, 1 insertion(+)\n create mode 100644 .gitattributes\n[master 61f0599] Added test.abcd\n 1 file changed, 2 insertions(+)\n create mode 100644 test.abcd\n[master 0acd46a] Add attributes (LF)\n 1 file changed, 1 insertion(+), 1 deletion(-)\nwarning: CRLF will be replaced by LF in test.abcd.\nThe file will have its original line endings in your working directory\nCreated autostash: 310f745\nerror: cannot rebase: You have unstaged changes.\nerror: Please commit or stash them.\nerror: could not read '.git/rebase-merge/head-name': No such file or\ndirectory\n\nand\n\n$ ls -la .git/rebase-merge/\ntotal 5\ndrwxr-xr-x 1 thomas 197121  0 Jun  3 17:57 ./\ndrwxr-xr-x 1 thomas 197121  0 Jun  3 17:57 ../\n-rw-r--r-- 1 thomas 197121 41 Jun  3 17:57 autostash\n\nI'm running on Windows, both 2.27.0.windows.1 and 2.26.2.windows.1 show\nthe problem. And I'm pretty sure it is not Windows specific.\n\nAlthough my test case uses EOL normalization, I think the real issue is\nthat autostashing for the rebase fails (in the sense that the working\ntree is clean afterwards) and that is unexpected.\n"},{"id":"399109","messageId":"b83568b8-e465-243e-cd84-eba88c4e95d9@gmail.com","threadId":"53584","inReplyTo":"63139842-8548-6c64-1214-5469eedb8d4f@virtuell-zuhause.de","subject":"Re: [BUG?] 'git rebase --abort' couldn't abort aborted rebase","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2020-06-04T10:19:56Z","receivedAt":"2020-06-04T10:20:03Z","isPatch":false,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Thomas\n\nOn 03/06/2020 17:09, Thomas Braun wrote:\n> On 30.05.2020 18:24, Elijah Newren wrote:\n>> On Sat, May 30, 2020 at 3:52 AM Md Naeim <naeim249@gmail.com> wrote:\n> \n> [...]\n> \n>> Could you provide any details beyond the subject, such as the output\n>> from 'git rebase --abort', your git version, the output of `git\n>> status`, whether there are any untracked files with special status\n>> (e.g. ignored but a submodule in the way of something?), any special\n>> file permissions (does root own some files and prevent git from\n>> updating things?), operating system you are on, link to a repository\n>> people can use to reproduce?  Without more details, this report is\n>> unactionable.\n>>\n> \n> I don't know the OPs details but I can reproduce with the following\n> clumsy snippet:\n\nThanks for the script, I've annotated the error messages in an attempt\nto understand what's happening\n\n> #!/bin/sh\n> \n> git init\n> git config --global user.email \"you@example.com\"\n> git config --global user.name \"Your Name\"\n> git config rebase.autostash true\n> git config core.autocrlf false\n> echo \"*.abcd !eol\" > .gitattributes\n> git add .gitattributes\n> git commit -m \"Add attributes\"\n> echo -e \"1\\r\\n\" > test.abcd\n> git add test.abcd\n> git commit --no-verify -m \"Added test.abcd\" test.abcd\n> echo \"*.abcd eol=lf\" > .gitattributes\n> git add .gitattributes\n> git commit -m \"Add attributes (LF)\"\n> git rebase --root --interactive\n> git rebase --abort\n> which gives\n> \n>  ./run.sh\n> Initialized empty Git repository in E:/projekte/test-init/.git/\n> [master (root-commit) 7169943] Add attributes\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 .gitattributes\n> [master 61f0599] Added test.abcd\n>  1 file changed, 2 insertions(+)\n>  create mode 100644 test.abcd\n> [master 0acd46a] Add attributes (LF)\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> warning: CRLF will be replaced by LF in test.abcd.\n> The file will have its original line endings in your working directory\n> Created autostash: 310f745\n> error: cannot rebase: You have unstaged changes.\n\nThe stash fails to stash all the changes because of some line ending\nissue I've yet to understand but the stash command exit code is zero as\nif it had succeeded in stashing everything so the rebase creates\n.git/rebase-merge/autostash and continues\n\n> error: Please commit or stash them.\n\nonly for the clean worktree check to fail. The cleanup path from that\npoint assumes we have not yet created .git/rebase-merge which is not\ntrue if an autostash has been created. This means we do not pop the stash.\n\n> error: could not read '.git/rebase-merge/head-name': No such file or\n> directory\n\nWhen we try to abort we try to read some state that does not exist\nbecause the rebase never really started\n\n> and\n> \n> $ ls -la .git/rebase-merge/\n> total 5\n> drwxr-xr-x 1 thomas 197121  0 Jun  3 17:57 ./\n> drwxr-xr-x 1 thomas 197121  0 Jun  3 17:57 ../\n> -rw-r--r-- 1 thomas 197121 41 Jun  3 17:57 autostash\n> \n> I'm running on Windows, both 2.27.0.windows.1 and 2.26.2.windows.1 show\n> the problem. And I'm pretty sure it is not Windows specific.\n\nYou're right I can reproduce it on linux\n\n> Although my test case uses EOL normalization, I think the real issue is\n> that autostashing for the rebase fails (in the sense that the working\n> tree is clean afterwards) and that is unexpected.\n\nYes. I'm not sure what to do for the best. A simple fix to the stash\nfailure is to check for a clean worktree after we've stashed and apply\nthe stash and exit if the worktree is not clean. Ideally `git stash`\nwould be able to tell us that it didn't stash everything, but that\nwarning comes from `void check_global_conv_flags_eol()` in convert.c so\nit does not pass along that information to the caller.\n\nWe should also improve the cleanup code path so that it applies the\nautostash (and removes the state dir) if it exists as after a quick\nglance through the code it seems we might not be applying the autostash\nif `git checkout`.\n\nBest Wishes\n\nPhillip\n\n"},{"id":"399184","messageId":"xmqqpnado7jc.fsf@gitster.c.googlers.com","threadId":"53584","inReplyTo":"b83568b8-e465-243e-cd84-eba88c4e95d9@gmail.com","subject":"Re: [BUG?] 'git rebase --abort' couldn't abort aborted rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-06-05T15:29:27Z","receivedAt":"2020-06-05T15:29:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n>> Although my test case uses EOL normalization, I think the real issue is\n>> that autostashing for the rebase fails (in the sense that the working\n>> tree is clean afterwards) and that is unexpected.\n>\n> Yes. I'm not sure what to do for the best. A simple fix to the stash\n> failure is to check for a clean worktree after we've stashed and apply\n> the stash and exit if the worktree is not clean.\n\nThe suggested fix covers all cases where the auto-stash step fails\nto revert the index and the working tree to the prestine state for\nany reason, not limited to the eol normalization.  It is not just a\nsimple but necessary fix, regardless of what other things we do.\n\nWhy doesn't the internal \"stash\" fail to clean the index and the\nworking tree to pristine state in the first place, though?  It may\nbe another thing that needs fixing, but in a sense, that is of\nsecondary importance.\n\nThanks.\n\n\n"}]}