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>
This commit is contained in:

committed by
Junio C Hamano

parent
d045719ac8
commit
35f070b4de
@ -1575,7 +1575,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
die(_("could not move back to %s"),
|
die(_("could not move back to %s"),
|
||||||
oid_to_hex(&options.orig_head));
|
oid_to_hex(&options.orig_head));
|
||||||
remove_branch_state(the_repository, 0);
|
remove_branch_state(the_repository, 0);
|
||||||
ret = !!finish_rebase(&options);
|
ret = finish_rebase(&options);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
case ACTION_QUIT: {
|
case ACTION_QUIT: {
|
||||||
@ -1584,11 +1584,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
struct replay_opts replay = REPLAY_OPTS_INIT;
|
struct replay_opts replay = REPLAY_OPTS_INIT;
|
||||||
|
|
||||||
replay.action = REPLAY_INTERACTIVE_REBASE;
|
replay.action = REPLAY_INTERACTIVE_REBASE;
|
||||||
ret = !!sequencer_remove_state(&replay);
|
ret = sequencer_remove_state(&replay);
|
||||||
} else {
|
} else {
|
||||||
strbuf_reset(&buf);
|
strbuf_reset(&buf);
|
||||||
strbuf_addstr(&buf, options.state_dir);
|
strbuf_addstr(&buf, options.state_dir);
|
||||||
ret = !!remove_dir_recursively(&buf, 0);
|
ret = remove_dir_recursively(&buf, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
error(_("could not remove '%s'"),
|
error(_("could not remove '%s'"),
|
||||||
options.state_dir);
|
options.state_dir);
|
||||||
@ -1960,7 +1960,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
if (require_clean_work_tree(the_repository, "rebase",
|
if (require_clean_work_tree(the_repository, "rebase",
|
||||||
_("Please commit or stash them."), 1, 1)) {
|
_("Please commit or stash them."), 1, 1)) {
|
||||||
ret = 1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1995,7 +1995,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
|
RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
|
||||||
NULL, buf.buf,
|
NULL, buf.buf,
|
||||||
DEFAULT_REFLOG_ACTION) < 0) {
|
DEFAULT_REFLOG_ACTION) < 0) {
|
||||||
ret = !!error(_("could not switch to "
|
ret = error(_("could not switch to "
|
||||||
"%s"),
|
"%s"),
|
||||||
options.switch_to);
|
options.switch_to);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2010,7 +2010,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
else
|
else
|
||||||
printf(_("Current branch %s is up to date.\n"),
|
printf(_("Current branch %s is up to date.\n"),
|
||||||
branch_name);
|
branch_name);
|
||||||
ret = !!finish_rebase(&options);
|
ret = finish_rebase(&options);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (!(options.flags & REBASE_NO_QUIET))
|
} else if (!(options.flags & REBASE_NO_QUIET))
|
||||||
; /* be quiet */
|
; /* be quiet */
|
||||||
@ -2088,7 +2088,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
RESET_HEAD_REFS_ONLY, "HEAD", msg.buf,
|
RESET_HEAD_REFS_ONLY, "HEAD", msg.buf,
|
||||||
DEFAULT_REFLOG_ACTION);
|
DEFAULT_REFLOG_ACTION);
|
||||||
strbuf_release(&msg);
|
strbuf_release(&msg);
|
||||||
ret = !!finish_rebase(&options);
|
ret = finish_rebase(&options);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2102,7 +2102,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
options.revisions = revisions.buf;
|
options.revisions = revisions.buf;
|
||||||
|
|
||||||
run_rebase:
|
run_rebase:
|
||||||
ret = !!run_specific_rebase(&options, action);
|
ret = run_specific_rebase(&options, action);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
@ -2113,5 +2113,5 @@ cleanup:
|
|||||||
free(options.strategy);
|
free(options.strategy);
|
||||||
strbuf_release(&options.git_format_patch_opt);
|
strbuf_release(&options.git_format_patch_opt);
|
||||||
free(squash_onto_name);
|
free(squash_onto_name);
|
||||||
return ret;
|
return !!ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user