Skip to content

Commit 1fdc2ab

Browse files
pcloudsgitster
authored andcommitted
reflog: avoid constructing .lock path with git_path
Among pathnames in $GIT_DIR, e.g. "index" or "packed-refs", we want to automatically and silently map some of them to the $GIT_DIR of the repository we are borrowing from via $GIT_COMMON_DIR mechanism. When we formulate the pathname for its lockfile, we want it to be in the same location as its final destination. "index" is not shared and needs to remain in the borrowing repository, while "packed-refs" is shared and needs to go to the borrowed repository. git_path() could be taught about the ".lock" suffix and map "index.lock" and "packed-refs.lock" the same way their basenames are mapped, but instead the caller can help by asking where the basename (e.g. "index") is mapped to git_path() and then appending ".lock" after the mapping is done. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c697b57 commit 1fdc2ab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/reflog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
372372
if (!reflog_exists(ref))
373373
goto finish;
374374
if (!cmd->dry_run) {
375-
newlog_path = git_pathdup("logs/%s.lock", ref);
375+
newlog_path = mkpathdup("%s.lock", log_file);
376376
cb.newlog = fopen(newlog_path, "w");
377377
}
378378

0 commit comments

Comments
 (0)