Skip to content

Commit 80054cf

Browse files
crorvickgitster
authored andcommitted
push: clarify rejection of update to non-commit-ish
Pushes must already (by default) update to a commit-ish due to the fast- forward check in set_ref_status_for_push(). But rejecting for not being a fast-forward suggests the situation can be resolved with a merge. Flag these updates (i.e., to a blob or a tree) as not forwardable so the user is presented with more appropriate advice. While updating *from* a tag object is potentially destructive, updating *to* a tag is not. Additionally, a push to the refs/tags/ hierarchy is already excluded from fast-forwarding, and refs/heads/ is protected from anything but commit objects by a check in write_ref_sha1(). Thus someone fast-forwarding to a tag is probably not doing so by accident. Since updating to a tag is benign and unlikely to cause confusion, allow it in case someone finds the behavior useful. Signed-off-by: Chris Rorvick <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 40eff17 commit 80054cf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

remote.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,11 @@ static inline int is_forwardable(struct ref* ref)
12911291
if (!o || o->type != OBJ_COMMIT)
12921292
return 0;
12931293

1294+
/* new object must be commit-ish */
1295+
o = deref_tag(parse_object(ref->new_sha1), NULL, 0);
1296+
if (!o || o->type != OBJ_COMMIT)
1297+
return 0;
1298+
12941299
return 1;
12951300
}
12961301

0 commit comments

Comments
 (0)