{"thread":{"id":"47210","subject":"[PATCH] sequencer: reschedule pick if index can't be locked","startedAt":"2017-11-15T10:41:57Z","lastAt":"2017-11-16T14:19:32Z","messageCount":7,"participants":["Phillip Wood","Martin Ågren","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"332601","messageId":"20171115104125.1686-1-phillip.wood@talktalk.net","threadId":"47210","inReplyTo":null,"subject":"[PATCH] sequencer: reschedule pick if index can't be locked","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-11-15T10:41:25Z","receivedAt":"2017-11-15T10:41:57Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nReturn an error instead of dying if the index cannot be locked in\ndo_recursive_merge() as if the commit cannot be picked it needs to be\nrescheduled when performing an interactive rebase. If the pick is not\nrescheduled and the user runs 'git rebase --continue' rather than 'git\nrebase --abort' then the commit gets silently dropped.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n sequencer.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 6d027b06c8d8dc69b14d05752637a65aa121ab24..8c10442b84068d3fb7ec809ef1faa0203cb83e60 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \tchar **xopt;\n \tstatic struct lock_file index_lock;\n \n-\thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n+\tif (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR))\n+\t\treturn -1;\n \n \tread_cache();\n \n-- \n2.15.0\n\n"},{"id":"332613","messageId":"CAN0heSrbszhhFauYHNs70-WWk+bju0sSVzjavRcwg09CzCXSjA@mail.gmail.com","threadId":"47210","inReplyTo":"20171115104125.1686-1-phillip.wood@talktalk.net","subject":"Re: [PATCH] sequencer: reschedule pick if index can't be locked","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-11-15T18:44:00Z","receivedAt":"2017-11-15T18:44:07Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On 15 November 2017 at 11:41, Phillip Wood <phillip.wood@talktalk.net> wrote:\n> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n>\n> Return an error instead of dying if the index cannot be locked in\n> do_recursive_merge() as if the commit cannot be picked it needs to be\n> rescheduled when performing an interactive rebase. If the pick is not\n> rescheduled and the user runs 'git rebase --continue' rather than 'git\n> rebase --abort' then the commit gets silently dropped.\n\nMakes sense. (Your analysis, not the current behavior. ;-) )\n\n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> ---\n>  sequencer.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/sequencer.c b/sequencer.c\n> index 6d027b06c8d8dc69b14d05752637a65aa121ab24..8c10442b84068d3fb7ec809ef1faa0203cb83e60 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n>         char **xopt;\n>         static struct lock_file index_lock;\n>\n> -       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n> +       if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR))\n> +               return -1;\n>\n>         read_cache();\n\nFrom the commit message, I would have expected the flags to be zero. This patch\ndoes not only turn off the die-ing, it also tells the lockfile-API to print an\nerror message before returning. I don't have an opinion on whether that extra\nverboseness is good or bad, but if it's wanted, I think the commit message\nshould mention this change.\n\nAlso, don't you want to check \"< 0\" rather than \"!= 0\"? If all goes\nwell, the return value will be a file descriptor. I think that it will\nalways be non-zero, so I think you'll always return -1 here.\n\nMartin\n"},{"id":"332621","messageId":"alpine.DEB.2.21.1.1711152301510.6482@virtualbox","threadId":"47210","inReplyTo":"20171115104125.1686-1-phillip.wood@talktalk.net","subject":"Re: [PATCH] sequencer: reschedule pick if index can't be locked","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-11-15T22:03:45Z","receivedAt":"2017-11-15T22:03:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Phillip,\n\nOn Wed, 15 Nov 2017, Phillip Wood wrote:\n\n> diff --git a/sequencer.c b/sequencer.c\n> index 6d027b06c8d8dc69b14d05752637a65aa121ab24..8c10442b84068d3fb7ec809ef1faa0203cb83e60 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n>  \tchar **xopt;\n>  \tstatic struct lock_file index_lock;\n>  \n> -\thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n> +\tif (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR))\n\nIf you test the return value for *negative* values, I am fully on board\nwith the change.\n\nAs far as I understand the code, hold_locked_index() returns -1 on error,\nbut *a file descriptor* (which is usually not 0) upon success...\n\nCiao,\nDscho\n"},{"id":"332650","messageId":"xmqqshdex0ff.fsf@gitster.mtv.corp.google.com","threadId":"47210","inReplyTo":"20171115104125.1686-1-phillip.wood@talktalk.net","subject":"[PATCH v2] sequencer: reschedule pick if index can't be locked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-11-16T05:22:28Z","receivedAt":"2017-11-16T05:23:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\nDate: Wed, 15 Nov 2017 10:41:25 +0000\n\nIf the index cannot be locked in do_recursive_merge(), issue an\nerror message and go on to the error recovery codepath, instead of\ndying.  When the commit cannot be picked, it needs to be rescheduled\nwhen performing an interactive rebase, but just dying there won't\nallow that to happen, and when the user runs 'git rebase --continue'\nrather than 'git rebase --abort', the commit gets silently dropped.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n\n * I've queue this, taking input from responses by Dscho and Martin.\n\n sequencer.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 332a383b03..10924ffd49 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \tchar **xopt;\n \tstatic struct lock_file index_lock;\n \n-\thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n+\tif (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)\n+\t\treturn -1;\n \n \tread_cache();\n \n-- \n2.15.0-360-gf2497ca0e5\n\n"},{"id":"332657","messageId":"804e30dd-3c06-02c1-e5c0-f07265635943@talktalk.net","threadId":"47210","inReplyTo":"CAN0heSrbszhhFauYHNs70-WWk+bju0sSVzjavRcwg09CzCXSjA@mail.gmail.com","subject":"Re: [PATCH] sequencer: reschedule pick if index can't be locked","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-11-16T10:43:48Z","receivedAt":"2017-11-16T10:43:58Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 15/11/17 18:44, Martin Ågren wrote:\n> On 15 November 2017 at 11:41, Phillip Wood <phillip.wood@talktalk.net> wrote:\n>> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n>>\n>> Return an error instead of dying if the index cannot be locked in\n>> do_recursive_merge() as if the commit cannot be picked it needs to be\n>> rescheduled when performing an interactive rebase. If the pick is not\n>> rescheduled and the user runs 'git rebase --continue' rather than 'git\n>> rebase --abort' then the commit gets silently dropped.\n> \n> Makes sense. (Your analysis, not the current behavior. ;-) )\n> \n>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n>> ---\n>>   sequencer.c | 3 ++-\n>>   1 file changed, 2 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/sequencer.c b/sequencer.c\n>> index 6d027b06c8d8dc69b14d05752637a65aa121ab24..8c10442b84068d3fb7ec809ef1faa0203cb83e60 100644\n>> --- a/sequencer.c\n>> +++ b/sequencer.c\n>> @@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n>>          char **xopt;\n>>          static struct lock_file index_lock;\n>>\n>> -       hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n>> +       if (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR))\n>> +               return -1;\n>>\n>>          read_cache();\n> \n>  From the commit message, I would have expected the flags to be zero. This patch\n> does not only turn off the die-ing, it also tells the lockfile-API to print an\n> error message before returning. I don't have an opinion on whether that extra\n> verboseness is good or bad, but if it's wanted, I think the commit message\n> should mention this change.\n\nHi Martin, thanks for your comments. LOCK_DIE_ON_ERROR also prints the \nsame warning so that behavior is unchanged by this patch, though \nmentioning it in the commit message would be no bad thing.\n\n> \n> Also, don't you want to check \"< 0\" rather than \"!= 0\"? If all goes\n> well, the return value will be a file descriptor. I think that it will\n> always be non-zero, so I think you'll always return -1 here.\n\nYes you're right, thanks. I thought I had tested this but I now realise \nmy so called test just fast-forwarded so didn't touch this code path\n\nBest Wishes\n\nPhillip\n\n> Martin\n> \n\n"},{"id":"332659","messageId":"CAN0heSrcAQhyzzB5c=W-diQecHgVQUC69xQwqnc36hSPVBpNig@mail.gmail.com","threadId":"47210","inReplyTo":"804e30dd-3c06-02c1-e5c0-f07265635943@talktalk.net","subject":"Re: [PATCH] sequencer: reschedule pick if index can't be locked","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2017-11-16T10:55:55Z","receivedAt":"2017-11-16T10:56:14Z","isPatch":true,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On 16 November 2017 at 11:43, Phillip Wood <phillip.wood@talktalk.net> wrote:\n> On 15/11/17 18:44, Martin Ågren wrote:\n>>\n>> On 15 November 2017 at 11:41, Phillip Wood <phillip.wood@talktalk.net>\n>> wrote:\n>>\n>>  From the commit message, I would have expected the flags to be zero. This\n>> patch\n>> does not only turn off the die-ing, it also tells the lockfile-API to\n>> print an\n>> error message before returning. I don't have an opinion on whether that\n>> extra\n>> verboseness is good or bad, but if it's wanted, I think the commit message\n>> should mention this change.\n>\n>\n> Hi Martin, thanks for your comments. LOCK_DIE_ON_ERROR also prints the same\n> warning so that behavior is unchanged by this patch, though mentioning it in\n> the commit message would be no bad thing.\n\nArgh, you're right of course. Sorry for this.\n\nMartin\n"},{"id":"332663","messageId":"b2ea8018-7afc-46fa-381d-5c471a438fe5@talktalk.net","threadId":"47210","inReplyTo":"xmqqshdex0ff.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] sequencer: reschedule pick if index can't be locked","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2017-11-16T14:19:23Z","receivedAt":"2017-11-16T14:19:32Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 16/11/17 05:22, Junio C Hamano wrote:\n> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n> Date: Wed, 15 Nov 2017 10:41:25 +0000\n> \n> If the index cannot be locked in do_recursive_merge(), issue an\n> error message and go on to the error recovery codepath, instead of\n> dying.  When the commit cannot be picked, it needs to be rescheduled\n> when performing an interactive rebase, but just dying there won't\n> allow that to happen, and when the user runs 'git rebase --continue'\n> rather than 'git rebase --abort', the commit gets silently dropped.\n> \n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> ---\n> \n>  * I've queue this, taking input from responses by Dscho and Martin.\n\nThat's great thanks, sorry for the bug in the original\n\nBest Wishes\n\nPhillip\n\n>  sequencer.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/sequencer.c b/sequencer.c\n> index 332a383b03..10924ffd49 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -438,7 +438,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n>  \tchar **xopt;\n>  \tstatic struct lock_file index_lock;\n>  \n> -\thold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);\n> +\tif (hold_locked_index(&index_lock, LOCK_REPORT_ON_ERROR) < 0)\n> +\t\treturn -1;\n>  \n>  \tread_cache();\n>  \n> \n\n"}]}