Skip to content

Commit b09c255

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 <[email protected]> Signed-off-by: Ben Peart <[email protected]>
1 parent b8f54a1 commit b09c255

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

config.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,11 +2757,25 @@ int repo_config_get_virtualfilesystem(struct repository *r)
27572757
if (core_virtualfilesystem && !*core_virtualfilesystem)
27582758
core_virtualfilesystem = NULL;
27592759

2760-
/* virtual file system relies on the sparse checkout logic so force it on */
27612760
if (core_virtualfilesystem) {
2762-
core_apply_sparse_checkout = 1;
2763-
virtual_filesystem_result = 1;
2764-
return 1;
2761+
/*
2762+
* Some git commands spawn helpers and redirect the index to a different
2763+
* location. These include "difftool -d" and the sequencer
2764+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2765+
* In those instances we don't want to update their temporary index with
2766+
* our virtualization data.
2767+
*/
2768+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2769+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2770+
2771+
free(default_index_file);
2772+
if (should_run_hook) {
2773+
/* virtual file system relies on the sparse checkout logic so force it on */
2774+
core_apply_sparse_checkout = 1;
2775+
virtual_filesystem_result = 1;
2776+
return 1;
2777+
}
2778+
core_virtualfilesystem = NULL;
27652779
}
27662780

27672781
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)