[PATCH v2 18/21] refs: adjust reflog path for repos/<id>/HEAD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 refs.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/refs.c b/refs.c
index 5e5a382..3691ef5 100644
--- a/refs.c
+++ b/refs.c
@@ -2676,13 +2676,24 @@ static int copy_msg(char *buf, const char *msg)
 int log_ref_setup(const char *refname, char *logfile, int bufsize)
 {
 	int logfd, oflags = O_APPEND | O_WRONLY;
+	const char *p = NULL;
 
-	git_snpath(logfile, bufsize, "logs/%s", refname);
+	/*
+	 * reflog of repos/XXX/HEAD is repos/XXX/logs/HEAD, not
+	 * refs/repos/XXX/HEAD
+	 */
+	if (!strncmp(refname, "repos/", 6) &&
+	    (p = strchr(refname + 6, '/')) != 0)
+		git_snpath(logfile, bufsize, "%.*s/logs/%s",
+			   (int)(p - refname), refname, p + 1);
+	else
+		git_snpath(logfile, bufsize, "logs/%s", refname);
 	if (log_all_ref_updates &&
 	    (!prefixcmp(refname, "refs/heads/") ||
 	     !prefixcmp(refname, "refs/remotes/") ||
 	     !prefixcmp(refname, "refs/notes/") ||
-	     !strcmp(refname, "HEAD"))) {
+	     !strcmp(refname, "HEAD") ||
+	     (p && !strcmp(p + 1, "HEAD")))) {
 		if (safe_create_leading_directories(logfile) < 0)
 			return error("unable to create directory for %s",
 				     logfile);
-- 
1.8.5.1.77.g42c48fa

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]