Skip to content

Commit cea4243

Browse files
benpeartdscho
authored andcommitted
virtualfilesystem: don't run the virtual file system hook if the index has been redirected
Fixes #13 Some git commands spawn helpers and redirect the index to a different location. These include "difftool -d" and the sequencer (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others. In those instances we don't want to update their temporary index with our virtualization data. Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
1 parent 5c9c248 commit cea4243

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎config.c‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,11 +2495,25 @@ int repo_config_get_virtualfilesystem(struct repository *r)
24952495
if (core_virtualfilesystem && !*core_virtualfilesystem)
24962496
FREE_AND_NULL(core_virtualfilesystem);
24972497

2498-
/* virtual file system relies on the sparse checkout logic so force it on */
24992498
if (core_virtualfilesystem) {
2500-
core_apply_sparse_checkout = 1;
2501-
virtual_filesystem_result = 1;
2502-
return 1;
2499+
/*
2500+
* Some git commands spawn helpers and redirect the index to a different
2501+
* location. These include "difftool -d" and the sequencer
2502+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2503+
* In those instances we don't want to update their temporary index with
2504+
* our virtualization data.
2505+
*/
2506+
char *default_index_file = xstrfmt("%s/%s", r->gitdir, "index");
2507+
int should_run_hook = !strcmp(default_index_file, r->index_file);
2508+
2509+
free(default_index_file);
2510+
if (should_run_hook) {
2511+
/* virtual file system relies on the sparse checkout logic so force it on */
2512+
core_apply_sparse_checkout = 1;
2513+
virtual_filesystem_result = 1;
2514+
return 1;
2515+
}
2516+
FREE_AND_NULL(core_virtualfilesystem);
25032517
}
25042518

25052519
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)