summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorbrian m. carlson <bk2204@github.com>2020-03-16 18:05:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-16 18:37:02 (GMT)
commit4cf76f6bbf8b4d7d32c7c6aec0576959c6accb63 (patch)
tree5ec835097f6aefe18a5895482e9839d539c9a04b /builtin
parent3f267856243693676c04b4d6dfa1e22de62e407a (diff)
downloadgit-4cf76f6bbf8b4d7d32c7c6aec0576959c6accb63.zip
git-4cf76f6bbf8b4d7d32c7c6aec0576959c6accb63.tar.gz
git-4cf76f6bbf8b4d7d32c7c6aec0576959c6accb63.tar.bz2
builtin/reset: compute checkout metadata for reset
Pass the commit, and if we have it, the ref to the filters when we perform a checkout. This should only be the case when we invoke git reset --hard; the metadata will be unused otherwise. Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/reset.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index 18228c3..4c63411 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -46,7 +46,7 @@ static inline int is_merge(void)
return !access(git_path_merge_head(the_repository), F_OK);
}
-static int reset_index(const struct object_id *oid, int reset_type, int quiet)
+static int reset_index(const char *ref, const struct object_id *oid, int reset_type, int quiet)
{
int i, nr = 0;
struct tree_desc desc[2];
@@ -60,6 +60,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;
+ init_checkout_metadata(&opts.meta, ref, oid, NULL);
if (!quiet)
opts.verbose_update = 1;
switch (reset_type) {
@@ -418,11 +419,20 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
}
}
} else {
- int err = reset_index(&oid, reset_type, quiet);
+ struct object_id dummy;
+ char *ref = NULL;
+ int err;
+
+ dwim_ref(rev, strlen(rev), &dummy, &ref);
+ if (ref && !starts_with(ref, "refs/"))
+ ref = NULL;
+
+ err = reset_index(ref, &oid, reset_type, quiet);
if (reset_type == KEEP && !err)
- err = reset_index(&oid, MIXED, quiet);
+ err = reset_index(ref, &oid, MIXED, quiet);
if (err)
die(_("Could not reset index file to revision '%s'."), rev);
+ free(ref);
}
if (write_locked_index(&the_index, &lock, COMMIT_LOCK))