From e1ac13f0e27df36c60768182923e4b265c806e23 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Wed, 19 Oct 2022 15:12:18 +0200 Subject: [PATCH 1/2] Pass worktree_path to Create hook fixes #102 --- lua/git-worktree/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/git-worktree/init.lua b/lua/git-worktree/init.lua index 0fb5295..5af25d8 100644 --- a/lua/git-worktree/init.lua +++ b/lua/git-worktree/init.lua @@ -368,14 +368,14 @@ local function create_worktree(path, branch, upstream, found_branch) end vim.schedule(function() - emit_on_change(Enum.Operations.Create, {path = path, branch = branch, upstream = upstream}) + emit_on_change(Enum.Operations.Create, {path = worktree_path, branch = branch, upstream = upstream}) M.switch_worktree(path) end) end) else create:after(function() vim.schedule(function() - emit_on_change(Enum.Operations.Create, {path = path, branch = branch, upstream = upstream}) + emit_on_change(Enum.Operations.Create, {path = worktree_path, branch = branch, upstream = upstream}) M.switch_worktree(path) end) end) From 99b2ae676d68af0e266cfcdf11d2c7b841f646b7 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 25 Oct 2022 10:51:19 +0200 Subject: [PATCH 2/2] Pass absolute worktree_path to switch_worktree --- lua/git-worktree/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/git-worktree/init.lua b/lua/git-worktree/init.lua index 5af25d8..35dce97 100644 --- a/lua/git-worktree/init.lua +++ b/lua/git-worktree/init.lua @@ -369,14 +369,14 @@ local function create_worktree(path, branch, upstream, found_branch) vim.schedule(function() emit_on_change(Enum.Operations.Create, {path = worktree_path, branch = branch, upstream = upstream}) - M.switch_worktree(path) + M.switch_worktree(worktree_path) end) end) else create:after(function() vim.schedule(function() emit_on_change(Enum.Operations.Create, {path = worktree_path, branch = branch, upstream = upstream}) - M.switch_worktree(path) + M.switch_worktree(worktree_path) end) end) end