Skip to content

Commit 513d5ec

Browse files
benpeartderrickstolee
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 d5e00e2 commit 513d5ec

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

config.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,10 +2371,24 @@ int git_config_get_virtualfilesystem(void)
23712371
if (core_virtualfilesystem && !*core_virtualfilesystem)
23722372
core_virtualfilesystem = NULL;
23732373

2374-
/* virtual file system relies on the sparse checkout logic so force it on */
23752374
if (core_virtualfilesystem) {
2376-
core_apply_sparse_checkout = 1;
2377-
return 1;
2375+
/*
2376+
* Some git commands spawn helpers and redirect the index to a different
2377+
* location. These include "difftool -d" and the sequencer
2378+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2379+
* In those instances we don't want to update their temporary index with
2380+
* our virtualization data.
2381+
*/
2382+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2383+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2384+
2385+
free(default_index_file);
2386+
if (should_run_hook) {
2387+
/* virtual file system relies on the sparse checkout logic so force it on */
2388+
core_apply_sparse_checkout = 1;
2389+
return 1;
2390+
}
2391+
core_virtualfilesystem = NULL;
23782392
}
23792393

23802394
return 0;

0 commit comments

Comments
 (0)