From: Nguyễn Thái Ngọc Duy Date: Sat, 01 Mar 2014 12:12:43 GMT Subject: [PATCH v4 07/27] reflog: avoid constructing .lock path with git_path Message-ID: <1393675983-3232-8-git-send-email-pclouds@gmail.com> In-Reply-To: <1393675983-3232-1-git-send-email-pclouds@gmail.com> git_path() soon understands the path given to it and can transform the path instead of just prepending $GIT_DIR. So given path "abc", git_path() may return "$GIT_DIR/abc". But given path "def", git_path() may return "$GIT_DIR/ghi". Giving path "def.lock" to git_path() may confuse it and make it believe "def.lock" should not be transformed because the signature is "def.lock" not "def". But we want the lock file to have the same base name with the locked file (e.g. "ghi.lock", not "def.lock"). It's best to append ".lock" after git_path() has done its conversion. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/reflog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 852cff6..ccf2cf6 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -372,7 +372,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, if (!file_exists(log_file)) goto finish; if (!cmd->dry_run) { - newlog_path = git_pathdup("logs/%s.lock", ref); + newlog_path = mkpathdup("%s.lock", log_file); cb.newlog = fopen(newlog_path, "w"); } -- 1.9.0.40.gaa8c3ea