Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,13 @@ static int checkout_paths(const struct checkout_opts *opts,
checkout_index = opts->checkout_index;

if (checkout_index) {
/* Some scenarios that checkout the index may update skipworktree bits,
* such as `restore --staged` after `cherry-pick -n` or `reset --soft`,
* so this flag should be set to ensure the correct virtual filesystem
* event is sent.
*/
the_repository->index->updated_skipworktree = 1;

if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
die(_("unable to write new index file"));
} else {
Expand Down
3 changes: 2 additions & 1 deletion read-cache-ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
drop_cache_tree : 1,
updated_workdir : 1,
updated_skipworktree : 1,
fsmonitor_has_run_once : 1;
fsmonitor_has_run_once : 1,
clear_skip_worktree_for_added_entries : 0;

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / win build

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / win build

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / win build

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / win build

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / almalinux-8 (almalinux:8)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / almalinux-8 (almalinux:8)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / pedantic (fedora:latest)

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / pedantic (fedora:latest)

read-cache-ll.h:180:18: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux32 (i386/ubuntu:focal)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux32 (i386/ubuntu:focal)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux32 (i386/ubuntu:focal)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / debian-11 (debian:11)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / debian-11 (debian:11)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / debian-11 (debian:11)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / debian-11 (debian:11)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-TEST-vars (ubuntu:20.04)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-TEST-vars (ubuntu:20.04)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-TEST-vars (ubuntu:20.04)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-TEST-vars (ubuntu:20.04)

read-cache-ll.h:180:4: zero width for bit-field 'clear_skip_worktree_for_added_entries'

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-breaking-changes (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-breaking-changes (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-breaking-changes (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-breaking-changes (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-reftable-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’

Check failure on line 180 in read-cache-ll.h

View workflow job for this annotation

GitHub Actions / linux-reftable-leaks (ubuntu:rolling)

read-cache-ll.h:180:18: zero width for bit-field ‘clear_skip_worktree_for_added_entries’
enum sparse_index_mode sparse_index;
struct hashmap name_hash;
struct hashmap dir_hash;
Expand Down
14 changes: 13 additions & 1 deletion sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ static int do_recursive_merge(struct repository *r,
int clean, show_output;
int i;
struct lock_file index_lock = LOCK_INIT;
int flags;

if (repo_hold_locked_index(r, &index_lock, LOCK_REPORT_ON_ERROR) < 0)
return -1;
Expand Down Expand Up @@ -787,15 +788,26 @@ static int do_recursive_merge(struct repository *r,
* to be replace with the tree the index matched before we
* started doing any picks.
*/
if (opts->no_commit && core_virtualfilesystem) {
/* When using the virtual file system, staged new files
* should clear SKIP_WORKTREE because the virtual file
* system only tracks files that are not modified in index.
* Without this, `restore --staged` will delete the new files
* from disk as well as from index.
*/
o.repo->index->clear_skip_worktree_for_added_entries = 1;
}
merge_switch_to_result(&o, head_tree, &result, 1, show_output);
o.repo->index->clear_skip_worktree_for_added_entries = 0;

clean = result.clean;
if (clean < 0) {
rollback_lock_file(&index_lock);
return clean;
}

if (write_locked_index(r->index, &index_lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
COMMIT_LOCK | SKIP_IF_UNCHANGED) < 0)
/*
* TRANSLATORS: %s will be "revert", "cherry-pick" or
* "rebase".
Expand Down
15 changes: 15 additions & 0 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,21 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
enable_fscache(istate->cache_nr);
clear_ce_flags(istate, select_flag, skip_wt_flag, pl, show_progress);
disable_fscache();

/*
* 3. If clear_skip_worktree_for_added_entries is set and we are checking for
* added entries, clear skip_wt_flag from all added entries.
*/
if ((select_flag & CE_ADDED)
&& istate->clear_skip_worktree_for_added_entries) {
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce = istate->cache[i];
if ((ce->ce_flags & (CE_ADDED | skip_wt_flag))
== (CE_ADDED | skip_wt_flag)) {
ce->ce_flags &= ~skip_wt_flag;
}
}
}
}

static void populate_from_existing_patterns(struct unpack_trees_options *o,
Expand Down
Loading