Skip to content

Commit 7816883

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 117d4e1 commit 7816883

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
@@ -2936,11 +2936,25 @@ int git_config_get_virtualfilesystem(void)
29362936
if (core_virtualfilesystem && !*core_virtualfilesystem)
29372937
core_virtualfilesystem = NULL;
29382938

2939-
/* virtual file system relies on the sparse checkout logic so force it on */
29402939
if (core_virtualfilesystem) {
2941-
core_apply_sparse_checkout = 1;
2942-
virtual_filesystem_result = 1;
2943-
return 1;
2940+
/*
2941+
* Some git commands spawn helpers and redirect the index to a different
2942+
* location. These include "difftool -d" and the sequencer
2943+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2944+
* In those instances we don't want to update their temporary index with
2945+
* our virtualization data.
2946+
*/
2947+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2948+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2949+
2950+
free(default_index_file);
2951+
if (should_run_hook) {
2952+
/* virtual file system relies on the sparse checkout logic so force it on */
2953+
core_apply_sparse_checkout = 1;
2954+
virtual_filesystem_result = 1;
2955+
return 1;
2956+
}
2957+
core_virtualfilesystem = NULL;
29442958
}
29452959

29462960
virtual_filesystem_result = 0;

0 commit comments

Comments
 (0)