push: cleanup push rules comment
Rewrite to remove inter-dependencies amongst the rules. Signed-off-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Chris Rorvick committed
Nov 29, 2012 at 19:41 UTC
a272b2896dcfd2758e97e0f35cb14df4436d7101
1 file changed
+17
-15
remote.c
+17
-15
@@ -1319,27 +1319,29 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1319
continue;
1320
}
1321
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:
1326
*
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
1328
*
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)
1331
*
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:
1333
*
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
1337
*
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.
1342
*
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
1345
*/
1346
1347
ref->not_forwardable = !is_forwardable(ref);