Skip to content

Commit 1ca38f8

Browse files
martinvonzgitster
authored andcommitted
reset: avoid redundant error message
If writing or committing the new index file fails, we print "Could not write new index file." followed by "Could not reset index file to revision $rev.". The first message seems to imply the second, so print only the first message. Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b7099a0 commit 1ca38f8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/reset.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
338338
int err = reset_index(sha1, reset_type, quiet);
339339
if (reset_type == KEEP && !err)
340340
err = reset_index(sha1, MIXED, quiet);
341-
if (!err &&
342-
(write_cache(newfd, active_cache, active_nr) ||
343-
commit_locked_index(lock))) {
344-
err = error(_("Could not write new index file."));
345-
}
346341
if (err)
347342
die(_("Could not reset index file to revision '%s'."), rev);
343+
if (write_cache(newfd, active_cache, active_nr) ||
344+
commit_locked_index(lock))
345+
die(_("Could not write new index file."));
348346
}
349347

350348
/* Any resets update HEAD to the head being switched to,

0 commit comments

Comments
 (0)