sequencer: remove unreachable exit condition in pick_commits()
PATCH 1/1 sequencer: remove unreachable exit condition in pick_commits()
This was introduced by 56dc3ab04 ("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), and was pointless from the get-go, as the command causes an early return.
---
this remains valid after phillip's pending series, through it becomes marginally harder to prove (c.f. "sequencer: factor out part of pick_commits()").
--- sequencer.c | 4 ---- 1 file changed, 4 deletions(-)
sequencer.c +0 -4
@@ -4832,10 +4832,6 @@ static int pick_commits(struct repository *r,struct strbuf head_ref =STRBUF_INIT , buf =STRBUF_INIT ;struct stat st; -/* Stopped in the middle, as planned? */ -if (todo_list->current < todo_list->nr) -return 0 ; -if (read_oneliner (&head_ref,rebase_path_head_name (),0 ) &&starts_with (head_ref.buf,"refs/" )) {const char *msg;
Signature · 1 line
2.40.0.152.g15d061e6df
Hi Oswald
Quoted 3 lines · Oswald Buddenhagen
This was introduced by
56dc3ab04("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), and was pointless from the get-go, as the command causes an early return.
While I agree this code is unreachable, just because it was unused when it was added does not mean it is unused now. It would be helpful for the commit message to explain that there are no "break" or "goto" statements in the loop body and therefore this code is only reachable when the loop terminates because todo_list->current == todo_list->nr
Best Wishes
Phillip
Quoted 28 lines
Signed-off-by Oswald Buddenhagen <[email protected]>---
this remains valid after phillip's pending series, through it becomes marginally harder to prove (c.f. "sequencer: factor out part ofpick_commits()").Cc Johannes Schindelin <[email protected]>Cc Phillip Wood <[email protected]>--- sequencer.c | 4 ---- 1 file changed, 4 deletions(-)sequencer.c +0
-4@@ -4832,10 +4832,6 @@ static int pick_commits(struct repository *r,struct strbuf head_ref =STRBUF_INIT , buf =STRBUF_INIT ;struct stat st; -/* Stopped in the middle, as planned? */ -if (todo_list->current < todo_list->nr) -return 0 ; -if (read_oneliner (&head_ref,rebase_path_head_name (),0 ) &&starts_with (head_ref.buf,"refs/" )) {const char *msg;
PATCH v2 1/1 sequencer: remove unreachable exit condition in pick_commits()
This was introduced by 56dc3ab04 ("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), and was pointless from the get-go: all early exits from the loop above are returns, so todo_list->current == todo_list->nr is an invariant after the loop.
---
v2:
- improved commit message
--- sequencer.c | 4 ---- 1 file changed, 4 deletions(-)
sequencer.c +0 -4
@@ -4832,10 +4832,6 @@ static int pick_commits(struct repository *r,struct strbuf head_ref =STRBUF_INIT , buf =STRBUF_INIT ;struct stat st; -/* Stopped in the middle, as planned? */ -if (todo_list->current < todo_list->nr) -return 0 ; -if (read_oneliner (&head_ref,rebase_path_head_name (),0 ) &&starts_with (head_ref.buf,"refs/" )) {const char *msg;
Signature · 1 line
2.42.0.419.g70bf8a5751
Quoted 6 lines · Oswald Buddenhagen
This was introduced by
56dc3ab04("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), and was pointless from the get-go: all early exits from the loop above are returns, sotodo_list->current==todo_list->nris an invariant after the loop.Signed-off-by Oswald Buddenhagen <[email protected]>
Thanks for updating the commit message, I think it is clearer now
Best Wishes
Phillip
Quoted 26 lines
---
v2:
- improved commit messageCc Johannes Schindelin <[email protected]>Cc Phillip Wood <[email protected]>Cc Junio C Hamano <[email protected]>--- sequencer.c | 4 ---- 1 file changed, 4 deletions(-)sequencer.c +0
-4@@ -4832,10 +4832,6 @@ static int pick_commits(struct repository *r,struct strbuf head_ref =STRBUF_INIT , buf =STRBUF_INIT ;struct stat st; -/* Stopped in the middle, as planned? */ -if (todo_list->current < todo_list->nr) -return 0 ; -if (read_oneliner (&head_ref,rebase_path_head_name (),0 ) &&starts_with (head_ref.buf,"refs/" )) {const char *msg;
Quoted 8 lines · Phillip Wood
Quoted 5 lines · Oswald Buddenhagen
This was introduced by
56dc3ab04("sequencer (rebase -i): implement the 'edit' command", 2017-01-02), and was pointless from the get-go: all early exits from the loop above are returns, sotodo_list->current==todo_list->nris an invariant after the loop.Signed-off-by Oswald Buddenhagen <[email protected]>Thanks for updating the commit message, I think it is clearer now
Thanks, both. Queued.