diff options
Diffstat (limited to 'src/refdb_fs.c')
| -rw-r--r-- | src/refdb_fs.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 450b3f3ec..b325d2763 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -739,6 +739,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char * { int error, filebuf_flags; git_buf ref_path = GIT_BUF_INIT; + const char *basedir; assert(file && backend && name); @@ -747,13 +748,18 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char * return GIT_EINVALIDSPEC; } + if (is_per_worktree_ref(name)) + basedir = backend->gitpath; + else + basedir = backend->commonpath; + /* Remove a possibly existing empty directory hierarchy * which name would collide with the reference name */ - if ((error = git_futils_rmdir_r(name, backend->gitpath, GIT_RMDIR_SKIP_NONEMPTY)) < 0) + if ((error = git_futils_rmdir_r(name, basedir, GIT_RMDIR_SKIP_NONEMPTY)) < 0) return error; - if (git_buf_joinpath(&ref_path, backend->gitpath, name) < 0) + if (git_buf_joinpath(&ref_path, basedir, name) < 0) return -1; filebuf_flags = GIT_FILEBUF_FORCE; |
