aboutsummaryrefslogtreecommitdiff
path: root/builtin/reset.c
diff options
context:
space:
mode:
authorMartin von Zweigbergk <martinvonz@gmail.com>2013-01-14 21:47:40 -0800
committerJunio C Hamano <gitster@pobox.com>2013-01-15 09:38:07 -0800
commit352f58a57ba3050adbdc2dcdcd3839e584f1431b (patch)
treec5da0826a6d52c88d25b41e49bb359a5cd9543b1 /builtin/reset.c
parent7bca0e451b8e502fa882b458d6fc825da80034cb (diff)
downloadgit-352f58a57ba3050adbdc2dcdcd3839e584f1431b.tar.gz
git-352f58a57ba3050adbdc2dcdcd3839e584f1431b.tar.xz
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>
Diffstat (limited to 'builtin/reset.c')
-rw-r--r--builtin/reset.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index 2187d6453..4e341950a 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -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
* at all, but requires them in a good order. Other resets reset
* 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);
- else {
- int err;
- if (reset_type == KEEP)
- die_if_unmerged_cache(reset_type);
- err = reset_index_file(sha1, reset_type, quiet);
- if (reset_type == KEEP)
- err = err || reset_index_file(sha1, MIXED, quiet);
+
+ if (reset_type != SOFT) {
+ int err = reset_index_file(sha1, reset_type, quiet);
+ if (reset_type == KEEP && !err)
+ err = reset_index_file(sha1, MIXED, quiet);
if (err)
die(_("Could not reset index file to revision '%s'."), rev);
}