summaryrefslogtreecommitdiff
path: root/builtin/reset.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-08-30 21:56:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-08-31 03:58:43 (GMT)
commitf38798f48dc8ed53fe001cc5a0d422f5c56b9d81 (patch)
tree4933aab3bcc1b75d18a71f9451412af034116ab5 /builtin/reset.c
parent992c38644a4b001bdc89b5b5008fc5f6674ed5b7 (diff)
downloadgit-f38798f48dc8ed53fe001cc5a0d422f5c56b9d81.zip
git-f38798f48dc8ed53fe001cc5a0d422f5c56b9d81.tar.gz
git-f38798f48dc8ed53fe001cc5a0d422f5c56b9d81.tar.bz2
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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/reset.c')
-rw-r--r--builtin/reset.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index afa6e02..225e3f1 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -326,8 +326,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
int newfd = hold_locked_index(lock, 1);
if (reset_type == MIXED) {
+ int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
if (read_from_tree(pathspec, sha1))
return 1;
+ refresh_index(&the_index, flags, NULL, NULL,
+ _("Unstaged changes after reset:"));
} else {
int err = reset_index(sha1, reset_type, quiet);
if (reset_type == KEEP && !err)
@@ -336,12 +339,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die(_("Could not reset index file to revision '%s'."), rev);
}
- if (reset_type == MIXED) { /* Report what has not been updated. */
- int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
- refresh_index(&the_index, flags, NULL, NULL,
- _("Unstaged changes after reset:"));
- }
-
if (write_cache(newfd, active_cache, active_nr) ||
commit_locked_index(lock))
die(_("Could not write new index file."));