Skip to content

Commit 352f58a

Browse files
martinvonzgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bca0e4 commit 352f58a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

builtin/reset.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,13 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
337337
/* Soft reset does not touch the index file nor the working tree
338338
* at all, but requires them in a good order. Other resets reset
339339
* the index file to the tree object we are switching to. */
340-
if (reset_type == SOFT)
340+
if (reset_type == SOFT || reset_type == KEEP)
341341
die_if_unmerged_cache(reset_type);
342-
else {
343-
int err;
344-
if (reset_type == KEEP)
345-
die_if_unmerged_cache(reset_type);
346-
err = reset_index_file(sha1, reset_type, quiet);
347-
if (reset_type == KEEP)
348-
err = err || reset_index_file(sha1, MIXED, quiet);
342+
343+
if (reset_type != SOFT) {
344+
int err = reset_index_file(sha1, reset_type, quiet);
345+
if (reset_type == KEEP && !err)
346+
err = reset_index_file(sha1, MIXED, quiet);
349347
if (err)
350348
die(_("Could not reset index file to revision '%s'."), rev);
351349
}

0 commit comments

Comments
 (0)