reset.c: share call to die_if_unmerged_cache()
Use a single condition to guard the call to die_if_unmerged_cache for both --soft and --keep. This avoids the small distraction of the precondition check from the logic following it. Also change an instance of if (e) err = err || f(); to the almost as short, but clearer if (e && !err) err = f(); (which is equivalent since we only care whether exit code is 0) Signed-off-by: Martin von Zweigbergk <martinvonz@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
7bca0e451b
commit
352f58a57b
@ -337,15 +337,13 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
|||||||
/* Soft reset does not touch the index file nor the working tree
|
/* Soft reset does not touch the index file nor the working tree
|
||||||
* at all, but requires them in a good order. Other resets reset
|
* at all, but requires them in a good order. Other resets reset
|
||||||
* the index file to the tree object we are switching to. */
|
* the index file to the tree object we are switching to. */
|
||||||
if (reset_type == SOFT)
|
if (reset_type == SOFT || reset_type == KEEP)
|
||||||
die_if_unmerged_cache(reset_type);
|
die_if_unmerged_cache(reset_type);
|
||||||
else {
|
|
||||||
int err;
|
if (reset_type != SOFT) {
|
||||||
if (reset_type == KEEP)
|
int err = reset_index_file(sha1, reset_type, quiet);
|
||||||
die_if_unmerged_cache(reset_type);
|
if (reset_type == KEEP && !err)
|
||||||
err = reset_index_file(sha1, reset_type, quiet);
|
err = reset_index_file(sha1, MIXED, quiet);
|
||||||
if (reset_type == KEEP)
|
|
||||||
err = err || reset_index_file(sha1, MIXED, quiet);
|
|
||||||
if (err)
|
if (err)
|
||||||
die(_("Could not reset index file to revision '%s'."), rev);
|
die(_("Could not reset index file to revision '%s'."), rev);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user