summaryrefslogtreecommitdiff
path: root/src/submodule.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-21 09:14:16 -0800
committerRussell Belfer <rb@github.com>2014-04-01 09:45:20 -0700
commit18234b14ad55157581ca26ec763afc1af3ec6e76 (patch)
tree0093ff2001a591cf08116d61fa57c912f4c26d3b /src/submodule.c
parent2450d4c63a58958100d1be0e5082efa930e09650 (diff)
downloadlibgit2-18234b14ad55157581ca26ec763afc1af3ec6e76.tar.gz
Add efficient git_buf join3 API
There are a few places where we need to join three strings to assemble a path. This adds a simple join3 function to avoid the comparatively expensive join_n (which calls strlen on each string twice).
Diffstat (limited to 'src/submodule.c')
-rw-r--r--src/submodule.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/submodule.c b/src/submodule.c
index fdcc2251a..a0ce5317f 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -168,10 +168,11 @@ int git_submodule_lookup(
if (git_repository_workdir(repo)) {
git_buf path = GIT_BUF_INIT;
- if (git_buf_joinpath(&path, git_repository_workdir(repo), name) < 0)
+ if (git_buf_join3(&path,
+ '/', git_repository_workdir(repo), name, DOT_GIT) < 0)
return -1;
- if (git_path_contains(&path, DOT_GIT))
+ if (git_path_exists(path.ptr))
error = GIT_EEXISTS;
git_buf_free(&path);
@@ -328,8 +329,8 @@ int git_submodule_add_setup(
else if (use_gitlink) {
git_buf repodir = GIT_BUF_INIT;
- error = git_buf_join_n(
- &repodir, '/', 3, git_repository_path(repo), "modules", path);
+ error = git_buf_join3(
+ &repodir, '/', git_repository_path(repo), "modules", path);
if (error < 0)
goto cleanup;