Thread (57 messages) flat view 57 messages, 5 authors, 2016-06-16
STALE3749d

Revision v7 of 3 in this series.

Revisions (3)
  1. v4 [diff vs current]
  2. v6 [diff vs current]
  3. v7 current

[PATCH v7 16/33] refs: handle non-normal ref renames

From: David Turner <hidden>
Date: 2016-06-15 23:08:34
Subsystem: the rest · Maintainer: Linus Torvalds

Forbid cross-backend ref renames.  This would be pretty weird, but
since it will break, we should prevent it.

Also make the files backend deal with all non-normal ref renames.

Signed-off-by: David Turner <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
 refs.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index 5364dc6..4610a44 100644
--- a/refs.c
+++ b/refs.c
@@ -1418,5 +1418,15 @@ int delete_refs(struct string_list *refnames)
 
 int rename_ref(const char *oldref, const char *newref, const char *logmsg)
 {
-	return the_refs_backend->rename_ref(oldref, newref, logmsg);
+	if ((ref_type(oldref) == REF_TYPE_NORMAL) !=
+	    (ref_type(newref) == REF_TYPE_NORMAL)) {
+		return error(
+			_("Both ref arguments to rename_ref must be normal, "
+			  "or both must be per-worktree/pseudorefs"));
+	}
+	if (ref_type(oldref) == REF_TYPE_NORMAL)
+		/* The files backend always deals with non-normal refs */
+		return the_refs_backend->rename_ref(oldref, newref, logmsg);
+	else
+		return refs_be_files.rename_ref(oldref, newref, logmsg);
 }
-- 
2.4.2.767.g62658d5-twtrsrc
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help