Skip to content

Commit fbdfd6e

Browse files
dschoKevin Willford
authored and
Kevin Willford
committed
Merge 'update/virtual-file-system'
Update the virtualfilesystem support to specify it needs to be run from the root of the git work tree. This enables the hook to be found even if the current working directory is not the root of the repo (like when running 'git diff' with Beyond Compare configured as the diff tool). Also simplify how argv[] parameter is created to match the model currently accepted in master.
2 parents 0bbac43 + 591ee79 commit fbdfd6e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

virtualfilesystem.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@ static int vfs_hashmap_cmp(const void *unused_cmp_data,
3232
static void get_virtual_filesystem_data(struct strbuf *vfs_data)
3333
{
3434
struct child_process cp = CHILD_PROCESS_INIT;
35-
char ver[64];
36-
const char *argv[3];
3735
int err;
3836

3937
strbuf_init(vfs_data, 0);
4038

41-
snprintf(ver, sizeof(ver), "%d", HOOK_INTERFACE_VERSION);
42-
argv[0] = core_virtualfilesystem;
43-
argv[1] = ver;
44-
argv[2] = NULL;
45-
cp.argv = argv;
39+
argv_array_push(&cp.args, core_virtualfilesystem);
40+
argv_array_pushf(&cp.args, "%d", HOOK_INTERFACE_VERSION);
4641
cp.use_shell = 1;
42+
cp.dir = get_git_work_tree();
4743

4844
err = capture_command(&cp, vfs_data, 1024);
4945
if (err)

0 commit comments

Comments
 (0)