Skip to content

Commit f38798f

Browse files
felipecgitster
authored andcommitted
reset: trivial refactoring
After commit 3fde386 (reset [--mixed]: use diff-based reset whether or not pathspec was given), some code can be moved to the 'reset_type == MIXED' check. Let's move the code that is specific to MIXED. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 992c386 commit f38798f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

builtin/reset.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
326326
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
327327
int newfd = hold_locked_index(lock, 1);
328328
if (reset_type == MIXED) {
329+
int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
329330
if (read_from_tree(pathspec, sha1))
330331
return 1;
332+
refresh_index(&the_index, flags, NULL, NULL,
333+
_("Unstaged changes after reset:"));
331334
} else {
332335
int err = reset_index(sha1, reset_type, quiet);
333336
if (reset_type == KEEP && !err)
@@ -336,12 +339,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
336339
die(_("Could not reset index file to revision '%s'."), rev);
337340
}
338341

339-
if (reset_type == MIXED) { /* Report what has not been updated. */
340-
int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
341-
refresh_index(&the_index, flags, NULL, NULL,
342-
_("Unstaged changes after reset:"));
343-
}
344-
345342
if (write_cache(newfd, active_cache, active_nr) ||
346343
commit_locked_index(lock))
347344
die(_("Could not write new index file."));

0 commit comments

Comments
 (0)