diff options
author | Elijah Newren <newren@gmail.com> | 2021-09-27 18:33:41 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-27 22:38:37 +0200 |
commit | 04988c8d182da945cd9420274f33487157c5636f (patch) | |
tree | 32ab1cf9026d6e4a05fae3096a7ae2e38bdf4222 /reset.c | |
parent | read-tree, merge-recursive: overwrite ignored files by default (diff) | |
download | git-04988c8d182da945cd9420274f33487157c5636f.tar.xz git-04988c8d182da945cd9420274f33487157c5636f.zip |
unpack-trees: introduce preserve_ignored to unpack_trees_options
Currently, every caller of unpack_trees() that wants to ensure ignored
files are overwritten by default needs to:
* allocate unpack_trees_options.dir
* flip the DIR_SHOW_IGNORED flag in unpack_trees_options.dir->flags
* call setup_standard_excludes
AND then after the call to unpack_trees() needs to
* call dir_clear()
* deallocate unpack_trees_options.dir
That's a fair amount of boilerplate, and every caller uses identical
code. Make this easier by instead introducing a new boolean value where
the default value (0) does what we want so that new callers of
unpack_trees() automatically get the appropriate behavior. And move all
the handling of unpack_trees_options.dir into unpack_trees() itself.
While preserve_ignored = 0 is the behavior we feel is the appropriate
default, we defer fixing commands to use the appropriate default until a
later commit. So, this commit introduces several locations where we
manually set preserve_ignored=1. This makes it clear where code paths
were previously preserving ignored files when they should not have been;
a future commit will flip these to instead use a value of 0 to get the
behavior we want.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reset.c')
-rw-r--r-- | reset.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -56,6 +56,8 @@ int reset_head(struct repository *r, struct object_id *oid, const char *action, unpack_tree_opts.fn = reset_hard ? oneway_merge : twoway_merge; unpack_tree_opts.update = 1; unpack_tree_opts.merge = 1; + /* FIXME: Default should be to remove ignored files */ + unpack_tree_opts.preserve_ignored = 1; init_checkout_metadata(&unpack_tree_opts.meta, switch_to_branch, oid, NULL); if (!detach_head) unpack_tree_opts.reset = 1; |