[PATCH 5/7] move create_symref() past log_ref_write()

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

 



This doesn't change the code at all.  It is done to makes the next patch
more obvious.

Signed-off-by: Nicolas Pitre <nico@xxxxxxx>
---
 refs.c |   86 ++++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/refs.c b/refs.c
index 92fa2e4..f91e853 100644
--- a/refs.c
+++ b/refs.c
@@ -309,49 +309,6 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
 	return ref;
 }
 
-int create_symref(const char *ref_target, const char *refs_heads_master)
-{
-	const char *lockpath;
-	char ref[1000];
-	int fd, len, written;
-	const char *git_HEAD = git_path("%s", ref_target);
-
-#ifndef NO_SYMLINK_HEAD
-	if (prefer_symlink_refs) {
-		unlink(git_HEAD);
-		if (!symlink(refs_heads_master, git_HEAD))
-			return 0;
-		fprintf(stderr, "no symlink - falling back to symbolic ref\n");
-	}
-#endif
-
-	len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
-	if (sizeof(ref) <= len) {
-		error("refname too long: %s", refs_heads_master);
-		return -1;
-	}
-	lockpath = mkpath("%s.lock", git_HEAD);
-	fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);	
-	written = write_in_full(fd, ref, len);
-	close(fd);
-	if (written != len) {
-		unlink(lockpath);
-		error("Unable to write to %s", lockpath);
-		return -2;
-	}
-	if (rename(lockpath, git_HEAD) < 0) {
-		unlink(lockpath);
-		error("Unable to create %s", git_HEAD);
-		return -3;
-	}
-	if (adjust_shared_perm(git_HEAD)) {
-		unlink(lockpath);
-		error("Unable to fix permissions on %s", lockpath);
-		return -4;
-	}
-	return 0;
-}
-
 int read_ref(const char *ref, unsigned char *sha1)
 {
 	if (resolve_ref(ref, sha1, 1, NULL))
@@ -1022,6 +979,49 @@ int write_ref_sha1(struct ref_lock *lock,
 	return 0;
 }
 
+int create_symref(const char *ref_target, const char *refs_heads_master)
+{
+	const char *lockpath;
+	char ref[1000];
+	int fd, len, written;
+	const char *git_HEAD = git_path("%s", ref_target);
+
+#ifndef NO_SYMLINK_HEAD
+	if (prefer_symlink_refs) {
+		unlink(git_HEAD);
+		if (!symlink(refs_heads_master, git_HEAD))
+			return 0;
+		fprintf(stderr, "no symlink - falling back to symbolic ref\n");
+	}
+#endif
+
+	len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
+	if (sizeof(ref) <= len) {
+		error("refname too long: %s", refs_heads_master);
+		return -1;
+	}
+	lockpath = mkpath("%s.lock", git_HEAD);
+	fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);	
+	written = write_in_full(fd, ref, len);
+	close(fd);
+	if (written != len) {
+		unlink(lockpath);
+		error("Unable to write to %s", lockpath);
+		return -2;
+	}
+	if (rename(lockpath, git_HEAD) < 0) {
+		unlink(lockpath);
+		error("Unable to create %s", git_HEAD);
+		return -3;
+	}
+	if (adjust_shared_perm(git_HEAD)) {
+		unlink(lockpath);
+		error("Unable to fix permissions on %s", lockpath);
+		return -4;
+	}
+	return 0;
+}
+
 static char *ref_msg(const char *line, const char *endp)
 {
 	const char *ep;
-- 
1.5.0.rc2.g6e2c

-
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]