Merge pull request #4559 from jacquesg/worktree-const Worktree lock reason should be const
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index d3fa88e..a2a5d44 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -123,7 +123,7 @@ GIT_EXTERN(int) git_worktree_add(git_worktree **out, git_repository *repo,
* @param reason Reason why the working tree is being locked
* @return 0 on success, non-zero otherwise
*/
-GIT_EXTERN(int) git_worktree_lock(git_worktree *wt, char *reason);
+GIT_EXTERN(int) git_worktree_lock(git_worktree *wt, const char *reason);
/**
* Unlock a locked worktree
diff --git a/src/worktree.c b/src/worktree.c
index 5a814a2..4b18db7 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -383,7 +383,7 @@ out:
return err;
}
-int git_worktree_lock(git_worktree *wt, char *creason)
+int git_worktree_lock(git_worktree *wt, const char *reason)
{
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
int err;
@@ -396,8 +396,8 @@ int git_worktree_lock(git_worktree *wt, char *creason)
if ((err = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0)
goto out;
- if (creason)
- git_buf_attach_notowned(&buf, creason, strlen(creason));
+ if (reason)
+ git_buf_attach_notowned(&buf, reason, strlen(reason));
if ((err = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
goto out;