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>

Martin von Zweigbergk committed Jan 14, 2013 at 21:47 UTC 352f58a57ba3050adbdc2dcdcd3839e584f1431b
1 file changed +6 -8
builtin/reset.c
+6 -8
@@ -337,15 +337,13 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
337 /* Soft reset does not touch the index file nor the working tree
338 * at all, but requires them in a good order. Other resets reset
339 * the index file to the tree object we are switching to. */
340 - if (reset_type == SOFT)
340 + if (reset_type == SOFT || reset_type == KEEP)
341 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);
347 if (err)
348 die(_("Could not reset index file to revision '%s'."), rev);
349 }