reset: avoid redundant error message
[gitweb.git] / builtin / reset.c
index 7c440add07979527ef0c0ad9e03d48a0aec0b234..97fa9f78592b28e741c57d9157a111f13ac99893 100644 (file)
@@ -338,13 +338,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
                int err = reset_index(sha1, reset_type, quiet);
                if (reset_type == KEEP && !err)
                        err = reset_index(sha1, MIXED, quiet);
-               if (!err &&
-                   (write_cache(newfd, active_cache, active_nr) ||
-                    commit_locked_index(lock))) {
-                       err = error(_("Could not write new index file."));
-               }
                if (err)
                        die(_("Could not reset index file to revision '%s'."), rev);
+               if (write_cache(newfd, active_cache, active_nr) ||
+                   commit_locked_index(lock))
+                       die(_("Could not write new index file."));
        }
 
        /* Any resets update HEAD to the head being switched to,