diff options
author | Peter Pettersson <boretrk@hotmail.com> | 2021-08-08 12:13:16 +0200 |
---|---|---|
committer | Peter Pettersson <boretrk@hotmail.com> | 2021-08-08 13:38:32 +0200 |
commit | 4584660e11ee5fd6e9fb44b0d00bf7cb8df8edb4 (patch) | |
tree | 017825ea28e844390db1477f4e52e5653c33ae88 | |
parent | d095502ed797e20a73a00b65cc9d70d91f7d7ab4 (diff) | |
download | libgit2-4584660e11ee5fd6e9fb44b0d00bf7cb8df8edb4.tar.gz |
bugfix: don't generate paths with empty segments
-rw-r--r-- | src/refdb_fs.c | 5 | ||||
-rw-r--r-- | src/worktree.c | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 0b8e103c2..7cf48b13d 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -578,7 +578,7 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter) } } - if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 || + if ((error = git_buf_puts(&path, backend->commonpath)) < 0 || (error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0) { git_buf_dispose(&path); return error; @@ -1609,8 +1609,9 @@ static char *setup_namespace(git_repository *repo, const char *in) GIT_MKDIR_PATH, NULL) < 0) goto done; - /* Return root of the namespaced gitpath, i.e. without the trailing '/refs' */ + /* Return root of the namespaced gitpath, i.e. without the trailing 'refs' */ git_buf_rtruncate_at_char(&path, '/'); + git_buf_putc(&path, '/'); out = git_buf_detach(&path); done: diff --git a/src/worktree.c b/src/worktree.c index 0bced6d4a..fe8db7743 100644 --- a/src/worktree.c +++ b/src/worktree.c @@ -43,7 +43,7 @@ int git_worktree_list(git_strarray *wts, git_repository *repo) wts->count = 0; wts->strings = NULL; - if ((error = git_buf_printf(&path, "%s/worktrees/", repo->commondir)) < 0) + if ((error = git_buf_joinpath(&path, repo->commondir, "worktrees/")) < 0) goto exit; if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr)) goto exit; @@ -182,7 +182,7 @@ int git_worktree_lookup(git_worktree **out, git_repository *repo, const char *na *out = NULL; - if ((error = git_buf_printf(&path, "%s/worktrees/%s", repo->commondir, name)) < 0) + if ((error = git_buf_join3(&path, '/', repo->commondir, "worktrees", name)) < 0) goto out; if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0) @@ -592,7 +592,7 @@ int git_worktree_prune(git_worktree *wt, } /* Delete gitdir in parent repository */ - if ((err = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name)) < 0) + if ((err = git_buf_join3(&path, '/', wt->commondir_path, "worktrees", wt->name)) < 0) goto out; if (!git_path_exists(path.ptr)) { |