@@ -1319,27 +1319,29 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
13191319 continue ;
13201320 }
13211321
1322- /* This part determines what can overwrite what.
1323- * The rules are:
1322+ /*
1323+ * The below logic determines whether an individual
1324+ * refspec A:B can be pushed. The push will succeed
1325+ * if any of the following are true:
13241326 *
1325- * (0) you can always use --force or +A:B notation to
1326- * selectively force individual ref pairs.
1327+ * (1) the remote reference B does not exist
13271328 *
1328- * (1) if the old thing does not exist, it is OK.
1329+ * (2) the remote reference B is being removed (i.e.,
1330+ * pushing :B where no source is specified)
13291331 *
1330- * (2) if the destination is under refs/tags/ you are
1331- * not allowed to overwrite it; tags are expected
1332- * to be static once created
1332+ * (3) the update meets all fast-forwarding criteria:
13331333 *
1334- * (3) if you do not have the old thing, you are not allowed
1335- * to overwrite it; you would not know what you are losing
1336- * otherwise.
1334+ * (a) the destination is not under refs/tags/
1335+ * (b) the old is a commit
1336+ * (c) the new is a descendant of the old
13371337 *
1338- * (4) if old is a commit and new is a descendant of old
1339- * (implying new is commit-ish), it is OK.
1338+ * NOTE: We must actually have the old object in
1339+ * order to overwrite it in the remote reference,
1340+ * and the new object must be commit-ish. These are
1341+ * implied by (b) and (c) respectively.
13401342 *
1341- * (5) regardless of all of the above, removing :B is
1342- * always allowed.
1343+ * (4) it is forced using the +A :B notation, or by
1344+ * passing the --force argument
13431345 */
13441346
13451347 ref -> not_forwardable = !is_forwardable (ref );
0 commit comments