[PATCH v2 02/38] rename_ref_available(): add docstring

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

 



From: David Turner <dturner@xxxxxxxxxxxxxxxx>

And improve the internal variable names.

Signed-off-by: David Turner <dturner@xxxxxxxxxxxxxxxx>
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 refs.c               | 12 ++++++------
 refs/refs-internal.h | 12 +++++++++++-
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/refs.c b/refs.c
index b4e7cac..4c609df 100644
--- a/refs.c
+++ b/refs.c
@@ -1081,20 +1081,20 @@ const char *find_descendant_ref(const char *dirname,
 	return NULL;
 }
 
-int rename_ref_available(const char *oldname, const char *newname)
+int rename_ref_available(const char *old_refname, const char *new_refname)
 {
 	struct string_list skip = STRING_LIST_INIT_NODUP;
 	struct strbuf err = STRBUF_INIT;
-	int ret;
+	int ok;
 
-	string_list_insert(&skip, oldname);
-	ret = !verify_refname_available(newname, NULL, &skip, &err);
-	if (!ret)
+	string_list_insert(&skip, old_refname);
+	ok = !verify_refname_available(new_refname, NULL, &skip, &err);
+	if (!ok)
 		error("%s", err.buf);
 
 	string_list_clear(&skip, 0);
 	strbuf_release(&err);
-	return ret;
+	return ok;
 }
 
 int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index efe5847..0206e2b 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -240,7 +240,17 @@ const char *find_descendant_ref(const char *dirname,
 				const struct string_list *extras,
 				const struct string_list *skip);
 
-int rename_ref_available(const char *oldname, const char *newname);
+/*
+ * Check whether an attempt to rename old_refname to new_refname would
+ * cause a D/F conflict with any existing reference (other than
+ * possibly old_refname). If there would be a conflict, emit an error
+ * message and return false; otherwise, return true.
+ *
+ * Note that this function is not safe against all races with other
+ * processes (though rename_ref() catches some races that might get by
+ * this check).
+ */
+int rename_ref_available(const char *old_refname, const char *new_refname);
 
 /* We allow "recursive" symbolic refs. Only within reason, though */
 #define SYMREF_MAXDEPTH 5
-- 
2.9.3




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