diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-03-26 17:11:20 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-03-26 17:11:20 -0700 |
| commit | 4e4baee3f44da26a5eaab27c76d597b04fef5259 (patch) | |
| tree | 5d0ebb218dddd9fc17531ac75d140bf59eb056da /builtin/reset.c | |
| parent | fa82be982dfc5b463a125991a2d381f1cd0ad9eb (diff) | |
| parent | 0c0f8a7f28672fa323312fbba394e5a9949b2aad (diff) | |
| download | git-4e4baee3f44da26a5eaab27c76d597b04fef5259.tar.xz | |
Merge branch 'bc/filter-process'
Provide more information (e.g. the object of the tree-ish in which
the blob being converted appears, in addition to its path, which
has already been given) to smudge/clean conversion filters.
* bc/filter-process:
t0021: test filter metadata for additional cases
builtin/reset: compute checkout metadata for reset
builtin/rebase: compute checkout metadata for rebases
builtin/clone: compute checkout metadata for clones
builtin/checkout: compute checkout metadata for checkouts
convert: provide additional metadata to filters
convert: permit passing additional metadata to filter processes
builtin/checkout: pass branch info down to checkout_worktree
Diffstat (limited to 'builtin/reset.c')
| -rw-r--r-- | builtin/reset.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin/reset.c b/builtin/reset.c index 18228c312e..4c634111bd 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)) |
