summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorChris Rorvick <chris@rorvick.com>2012-11-29 19:41:38 -0600
committerJunio C Hamano <gitster@pobox.com>2012-12-02 01:44:49 -0800
commit40eff1799983b958d6dbe09fb499ad505bcf6f8d (patch)
tree0de96f181ffa8de1990f42305a4ad4f0bbc11f02 /remote.c
parentdbfeddb12e5bb540ed3c852eebda3df9117bd150 (diff)
downloadgit-40eff1799983b958d6dbe09fb499ad505bcf6f8d.tar.gz
push: require force for annotated tags
Do not allow fast-forwarding of references that point to a tag object. Updating from a tag is potentially destructive since it would likely leave the tag dangling. Disallowing updates to a tag also makes sense semantically and is consistent with the behavior of lightweight tags. Signed-off-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index 012b52f6fd..f5bc4e7260 100644
--- a/remote.c
+++ b/remote.c
@@ -1281,9 +1281,16 @@ int match_push_refs(struct ref *src, struct ref **dst,
static inline int is_forwardable(struct ref* ref)
{
+ struct object *o;
+
if (!prefixcmp(ref->name, "refs/tags/"))
return 0;
+ /* old object must be a commit */
+ o = parse_object(ref->old_sha1);
+ if (!o || o->type != OBJ_COMMIT)
+ return 0;
+
return 1;
}
@@ -1323,8 +1330,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
* to overwrite it; you would not know what you are losing
* otherwise.
*
- * (4) if both new and old are commit-ish, and new is a
- * descendant of old, it is OK.
+ * (4) if old is a commit and new is a descendant of old
+ * (implying new is commit-ish), it is OK.
*
* (5) regardless of all of the above, removing :B is
* always allowed.