From 59c27e1ed017a948b5fec326b427198006425be9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Dec 2017 15:23:16 -0800 Subject: wip --- builtin/reset.c | 10 +++++++--- t/t7102-reset.sh | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/reset.c b/builtin/reset.c index e15f595799..4081c93a35 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -42,7 +42,8 @@ static inline int is_merge(void) return !access(git_path_merge_head(), F_OK); } -static int reset_index(const struct object_id *oid, int reset_type, int quiet) +static int reset_index(struct pathspec *pathspec, + const struct object_id *oid, int reset_type, int quiet) { int i, nr = 0; struct tree_desc desc[2]; @@ -56,6 +57,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet) opts.dst_index = &the_index; opts.fn = oneway_merge; opts.merge = 1; + opts.pathspec = pathspec; if (!quiet) opts.verbose_update = 1; switch (reset_type) { @@ -353,6 +355,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (pathspec.nr) { if (reset_type == MIXED) warning(_("--mixed with paths is deprecated; use 'git reset -- ' instead.")); + else if (reset_type == HARD) + ; /* let's try this */ else if (reset_type != NONE) die(_("Cannot do %s reset with paths."), _(reset_type_names[reset_type])); @@ -387,9 +391,9 @@ int cmd_reset(int argc, const char **argv, const char *prefix) refresh_index(&the_index, flags, NULL, NULL, _("Unstaged changes after reset:")); } else { - int err = reset_index(&oid, reset_type, quiet); + int err = reset_index(&pathspec, &oid, reset_type, quiet); if (reset_type == KEEP && !err) - err = reset_index(&oid, MIXED, quiet); + err = reset_index(&pathspec, &oid, MIXED, quiet); if (err) die(_("Could not reset index file to revision '%s'."), rev); } diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 95653a08ca..b68891638f 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -102,11 +102,9 @@ test_expect_success 'reset --soft with unmerged index should fail' ' ' test_expect_success \ - 'giving paths with options different than --mixed should fail' ' + 'giving paths with options different than --mixed/--hard should fail' ' test_must_fail git reset --soft -- first && - test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first && - test_must_fail git reset --hard HEAD^ -- first && check_changes $head5 ' -- cgit v1.2.1