summaryrefslogtreecommitdiff
path: root/src/cherrypick.c
diff options
context:
space:
mode:
authorSebastian Henke <s.henke@henke-informatik.de>2019-10-10 15:28:46 +0200
committerSebastian Henke <s.henke@henke-informatik.de>2019-10-10 15:30:26 +0200
commit3335a0346a409695ec5ab43448604a51e45a2d08 (patch)
treef38ba79ddba4abe4335d912dde3089a47384311e /src/cherrypick.c
parentf04a58b00c1a350e2cd90bddcdaa7865183c9d2f (diff)
downloadlibgit2-3335a0346a409695ec5ab43448604a51e45a2d08.tar.gz
refs: fix locks getting forcibly removed
The flag GIT_FILEBUF_FORCE currently does two things: 1. It will cause the filebuf to create non-existing leading directories for the file that is about to be written. 2. It will forcibly remove any pre-existing locks. While most call sites actually do want (1), they do not want to remove pre-existing locks, as that renders the locking mechanisms effectively useless. Introduce a new flag `GIT_FILEBUF_CREATE_LEADING_DIRS` to separate both behaviours cleanly from each other and convert callers to use it instead of `GIT_FILEBUF_FORCE` to have them honor locked files correctly. As this conversion removes all current users of `GIT_FILEBUF_FORCE`, this commit removes the flag altogether.
Diffstat (limited to 'src/cherrypick.c')
-rw-r--r--src/cherrypick.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cherrypick.c b/src/cherrypick.c
index d5ba74c66..640d11a7b 100644
--- a/src/cherrypick.c
+++ b/src/cherrypick.c
@@ -30,7 +30,7 @@ static int write_cherrypick_head(
int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_CHERRYPICK_HEAD_FILE)) >= 0 &&
- (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) >= 0 &&
+ (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_CHERRYPICK_FILE_MODE)) >= 0 &&
(error = git_filebuf_printf(&file, "%s\n", commit_oidstr)) >= 0)
error = git_filebuf_commit(&file);
@@ -51,7 +51,7 @@ static int write_merge_msg(
int error = 0;
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MSG_FILE)) < 0 ||
- (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_FORCE, GIT_CHERRYPICK_FILE_MODE)) < 0 ||
+ (error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_CHERRYPICK_FILE_MODE)) < 0 ||
(error = git_filebuf_printf(&file, "%s", commit_msg)) < 0)
goto cleanup;