rebase: use our standard error return value

Git uses −1 to signal an error. The builtin rebase converts these to +1 all over the place using !! (presumably because the in the scripted version an error was signalled by +1). This is confusing and clutters the code, we only need to convert the value when the function returns. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Sep 21, 2021 at 10:24 UTC 35f070b4de8fa01c11d9478297ea074d633bd7d5
1 file changed +9 -9
builtin/rebase.c
+9 -9
@@ -1575,7 +1575,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1575 die(_("could not move back to %s"),
1576 oid_to_hex(&options.orig_head));
1577 remove_branch_state(the_repository, 0);
1578 - ret = !!finish_rebase(&options);
1578 + ret = finish_rebase(&options);
1579 goto cleanup;
1580 }
1581 case ACTION_QUIT: {
@@ -1584,11 +1584,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1584 struct replay_opts replay = REPLAY_OPTS_INIT;
1585
1586 replay.action = REPLAY_INTERACTIVE_REBASE;
1587 - ret = !!sequencer_remove_state(&replay);
1587 + ret = sequencer_remove_state(&replay);
1588 } else {
1589 strbuf_reset(&buf);
1590 strbuf_addstr(&buf, options.state_dir);
1591 - ret = !!remove_dir_recursively(&buf, 0);
1591 + ret = remove_dir_recursively(&buf, 0);
1592 if (ret)
1593 error(_("could not remove '%s'"),
1594 options.state_dir);
@@ -1960,7 +1960,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1960
1961 if (require_clean_work_tree(the_repository, "rebase",
1962 _("Please commit or stash them."), 1, 1)) {
1963 - ret = 1;
1963 + ret = -1;
1964 goto cleanup;
1965 }
1966
@@ -1995,7 +1995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1995 RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
1996 NULL, buf.buf,
1997 DEFAULT_REFLOG_ACTION) < 0) {
1998 - ret = !!error(_("could not switch to "
1998 + ret = error(_("could not switch to "
1999 "%s"),
2000 options.switch_to);
2001 goto cleanup;
@@ -2010,7 +2010,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2010 else
2011 printf(_("Current branch %s is up to date.\n"),
2012 branch_name);
2013 - ret = !!finish_rebase(&options);
2013 + ret = finish_rebase(&options);
2014 goto cleanup;
2015 } else if (!(options.flags & REBASE_NO_QUIET))
2016 ; /* be quiet */
@@ -2088,7 +2088,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2088 RESET_HEAD_REFS_ONLY, "HEAD", msg.buf,
2089 DEFAULT_REFLOG_ACTION);
2090 strbuf_release(&msg);
2091 - ret = !!finish_rebase(&options);
2091 + ret = finish_rebase(&options);
2092 goto cleanup;
2093 }
2094
@@ -2102,7 +2102,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
2102 options.revisions = revisions.buf;
2103
2104 run_rebase:
2105 - ret = !!run_specific_rebase(&options, action);
2105 + ret = run_specific_rebase(&options, action);
2106
2107 cleanup:
2108 strbuf_release(&buf);
@@ -2113,5 +2113,5 @@ cleanup:
2113 free(options.strategy);
2114 strbuf_release(&options.git_format_patch_opt);
2115 free(squash_onto_name);
2116 - return ret;
2116 + return !!ret;
2117 }