{"thread":{"id":"41228","subject":"git status during interactive rebase","startedAt":"2016-01-20T23:21:47Z","lastAt":"2016-01-22T16:28:25Z","messageCount":6,"participants":["Stefan Beller","Matthieu Moy","Johannes Schindelin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"276467","messageId":"CAGZ79kbUwJ+CN=YoQUP=rm=EhU=fU2ynt_7Q-cd7Dic-bsx+TA@mail.gmail.com","threadId":"41228","inReplyTo":null,"subject":"git status during interactive rebase","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-01-20T23:21:47Z","receivedAt":"2016-01-20T23:21:47Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"So I ran an interactive rebase, and while editing\n.git/rebase-merge/git-rebase-todo I tried to run\n`git status` in another terminal to inquire about a\nfilename of an untracked file.\n\nHowever, I got:\n\n$ git status\nOn branch submodule-groups-v3\nfatal: Could not open file .git/rebase-merge/done for reading: No such\nfile or directory\n\nWas this behavior always the case? (IIRC it worked a long time ago?)\nWould it make sense to not abort completely but give a limited status?\n\nThanks,\nStefan\n"},{"id":"276488","messageId":"vpqpowvz6g0.fsf@anie.imag.fr","threadId":"41228","inReplyTo":"CAGZ79kbUwJ+CN=YoQUP=rm=EhU=fU2ynt_7Q-cd7Dic-bsx+TA@mail.gmail.com","subject":"Re: git status during interactive rebase","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2016-01-21T08:23:59Z","receivedAt":"2016-01-21T08:23:59Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> So I ran an interactive rebase, and while editing\n> .git/rebase-merge/git-rebase-todo I tried to run\n> `git status` in another terminal to inquire about a\n> filename of an untracked file.\n>\n> However, I got:\n>\n> $ git status\n> On branch submodule-groups-v3\n> fatal: Could not open file .git/rebase-merge/done for reading: No such\n> file or directory\n>\n> Was this behavior always the case? (IIRC it worked a long time ago?)\n\n>From the list of recipients, I guess you already found that the issue\nprobably comes from 84e6fb9 (status: give more information during rebase\n-i, 2015-07-06), which introduced\nread_rebase_todolist(\"rebase-merge/done\", &have_done); in wt-status.c.\n\n> Would it make sense to not abort completely but give a limited status?\n\nYes.\n\nI guess read_rebase_todolist should be changed:\n\nstatic void read_rebase_todolist(const char *fname, struct string_list *lines)\n{\n\tstruct strbuf line = STRBUF_INIT;\n\tFILE *f = fopen(git_path(\"%s\", fname), \"r\");\n\n\tif (!f)\n\t\tdie_errno(\"Could not open file %s for reading\",\n\t\t\t  git_path(\"%s\", fname));\n\nThis should return an empty string_list instead of dying when the file\ndoes not exist. The case of an empty list is already dealt with later:\n\n\t\tif (have_done.nr == 0)\n\t\t\tstatus_printf_ln(s, color, _(\"No commands done.\"));\n\nNo time to work on a patch for now :-(.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"276491","messageId":"alpine.DEB.2.20.1601211016140.2964@virtualbox","threadId":"41228","inReplyTo":"CAGZ79kbUwJ+CN=YoQUP=rm=EhU=fU2ynt_7Q-cd7Dic-bsx+TA@mail.gmail.com","subject":"Re: git status during interactive rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-01-21T09:28:29Z","receivedAt":"2016-01-21T09:28:29Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Stefan,\n\nOn Wed, 20 Jan 2016, Stefan Beller wrote:\n\n> So I ran an interactive rebase, and while editing\n> .git/rebase-merge/git-rebase-todo I tried to run\n> `git status` in another terminal to inquire about a\n> filename of an untracked file.\n\nHeh, I don't think that anybody did that before, because the rebase has\nnot even quite started yet...\n\nThe cop-out would be to write an empty 'done' file before editing the\ntodo, but it would give the wrong impression that it is safe to run `git\nrebase --continue` now... Interactive rebase is *definitely* not\nthread-safe ;-)\n\nSo the proper fix might be to test for the presence of the \"done\" file and\notherwise tell the user that this rebase has not even started yet.\n\nCiao,\nDscho\n"},{"id":"276517","messageId":"CAGZ79ka7MVuHyTrjuR7BhBAxxJ-PuMCSDnRVWCbeeRSq9rGdWQ@mail.gmail.com","threadId":"41228","inReplyTo":"vpqpowvz6g0.fsf@anie.imag.fr","subject":"Re: git status during interactive rebase","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-01-21T22:16:40Z","receivedAt":"2016-01-21T22:16:40Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jan 21, 2016 at 12:23 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> So I ran an interactive rebase, and while editing\n>> .git/rebase-merge/git-rebase-todo I tried to run\n>> `git status` in another terminal to inquire about a\n>> filename of an untracked file.\n>>\n>> However, I got:\n>>\n>> $ git status\n>> On branch submodule-groups-v3\n>> fatal: Could not open file .git/rebase-merge/done for reading: No such\n>> file or directory\n>>\n>> Was this behavior always the case? (IIRC it worked a long time ago?)\n>\n> From the list of recipients, I guess you already found that the issue\n> probably comes from 84e6fb9 (status: give more information during rebase\n> -i, 2015-07-06), which introduced\n> read_rebase_todolist(\"rebase-merge/done\", &have_done); in wt-status.c.\n\nI just remembered you working on git-status specially during rebase,\nso I figured you may have a clue here.\n\n> No time to work on a patch for now :-(.\n\n:-(\n\n> The cop-out would be to write an empty 'done' file before editing the\n> todo, but it would give the wrong impression that it is safe to run `git\n> rebase --continue` now... Interactive rebase is *definitely* not\n> thread-safe ;-)\n\nok. As I did not start the rebase yet, I figured I may still ask a thing. :P\n\n> So the proper fix might be to test for the presence of the \"done\" file and\n> otherwise tell the user that this rebase has not even started yet.\n\nSo what Matthieu said?\n\nThanks,\nStefan\n"},{"id":"276521","messageId":"xmqqtwm6woh1.fsf@gitster.mtv.corp.google.com","threadId":"41228","inReplyTo":"CAGZ79ka7MVuHyTrjuR7BhBAxxJ-PuMCSDnRVWCbeeRSq9rGdWQ@mail.gmail.com","subject":"Re: git status during interactive rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-01-21T22:35:06Z","receivedAt":"2016-01-21T22:35:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>> So the proper fix might be to test for the presence of the \"done\" file and\n>> otherwise tell the user that this rebase has not even started yet.\n>\n> So what Matthieu said?\n\nYup, I think that is the right thing to do.\n\nPerhaps something along this line (not tested and done on 'pu', so I\nam not committing it to anywhere myself)?\n\n wt-status.c | 18 +++++++++++-------\n 1 file changed, 11 insertions(+), 7 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex ab4f80d..90b2474 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -1068,14 +1068,17 @@ static void abbrev_sha1_in_line(struct strbuf *line)\n \n }\n \n-static void read_rebase_todolist(const char *fname, struct string_list *lines)\n+static int read_rebase_todolist(const char *fname, struct string_list *lines)\n {\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *f = fopen(git_path(\"%s\", fname), \"r\");\n \n-\tif (!f)\n+\tif (!f) {\n+\t\tif (errno == ENOENT)\n+\t\t\treturn -1;\n \t\tdie_errno(\"Could not open file %s for reading\",\n \t\t\t  git_path(\"%s\", fname));\n+\t}\n \twhile (!strbuf_getline_lf(&line, f)) {\n \t\tif (line.len && line.buf[0] == comment_line_char)\n \t\t\tcontinue;\n@@ -1085,6 +1088,7 @@ static void read_rebase_todolist(const char *fname, struct string_list *lines)\n \t\tabbrev_sha1_in_line(&line);\n \t\tstring_list_append(lines, line.buf);\n \t}\n+\treturn 0;\n }\n \n static void show_rebase_information(struct wt_status *s,\n@@ -1098,12 +1102,12 @@ static void show_rebase_information(struct wt_status *s,\n \t\tstruct string_list have_done = STRING_LIST_INIT_DUP;\n \t\tstruct string_list yet_to_do = STRING_LIST_INIT_DUP;\n \n-\t\tread_rebase_todolist(\"rebase-merge/done\", &have_done);\n-\t\tread_rebase_todolist(\"rebase-merge/git-rebase-todo\", &yet_to_do);\n-\n-\t\tif (have_done.nr == 0)\n+\t\tif ((read_rebase_todolist(\"rebase-merge/done\", &have_done) < 0) ||\n+\t\t    (read_rebase_todolist(\"rebase-merge/git-rebase-todo\", &yet_to_do) < 0)) {\n+\t\t\tstatus_printf_ln(s, color, _(\"rebase-i not started yet.\"));\n+\t\t} else if (have_done.nr == 0) {\n \t\t\tstatus_printf_ln(s, color, _(\"No commands done.\"));\n-\t\telse {\n+\t\t} else {\n \t\t\tstatus_printf_ln(s, color,\n \t\t\t\tQ_(\"Last command done (%d command done):\",\n \t\t\t\t\t\"Last commands done (%d commands done):\",\n"},{"id":"276541","messageId":"alpine.DEB.2.20.1601221712520.2964@virtualbox","threadId":"41228","inReplyTo":"xmqqtwm6woh1.fsf@gitster.mtv.corp.google.com","subject":"Re: git status during interactive rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-01-22T16:28:25Z","receivedAt":"2016-01-22T16:28:25Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[Stefan, please do not drop me from the Cc: list ;-)]\n\nOn Thu, 21 Jan 2016, Junio C Hamano wrote:\n\n> Perhaps something along this line (not tested and done on 'pu', so I\n> am not committing it to anywhere myself)?\n\nI like it!\n\nI tested it, amended it and am about to send out a mail with a commit\nmessage.\n\nCiao,\nDscho\n"}]}