push: flag updates that require force
Add a flag for indicating an update to a reference requires force. Currently the `nonfastforward` flag is used for this when generating the status message. A separate flag insulates dependent logic from the details of set_ref_status_for_push(). 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
8c5f6f717d136c5a0e9d6d3879bf2a7bdeb42154
3 files changed
+12
-5
cache.h
+3
-1
@@ -999,7 +999,9 @@ struct ref {
999
unsigned char old_sha1[20];
1000
unsigned char new_sha1[20];
1001
char *symref;
1002
- unsigned int force:1,
1002
+ unsigned int
1003
+ force:1,
1004
+ requires_force:1,
1005
merge:1,
1006
nonfastforward:1,
1007
not_forwardable:1,
remote.c
+8
-3
@@ -1293,6 +1293,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1293
struct ref *ref;
1294
1295
for (ref = remote_refs; ref; ref = ref->next) {
1296
+ int force_ref_update = ref->force || force_update;
1297
+
1298
if (ref->peer_ref)
1299
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
1300
else if (!send_mirror)
@@ -1335,9 +1337,12 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1337
!has_sha1_file(ref->old_sha1)
1338
|| !ref_newer(ref->new_sha1, ref->old_sha1);
1339
1338
- if (ref->nonfastforward && !ref->force && !force_update) {
1339
- ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
1340
- continue;
1340
+ if (ref->nonfastforward) {
1341
+ ref->requires_force = 1;
1342
+ if (!force_ref_update) {
1343
+ ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
1344
+ continue;
1345
+ }
1346
}
1347
}
1348
}
transport.c
+1
-1
@@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
659
const char *msg;
660
661
strcpy(quickref, status_abbrev(ref->old_sha1));
662
- if (ref->nonfastforward) {
662
+ if (ref->requires_force) {
663
strcat(quickref, "...");
664
type = '+';
665
msg = "forced update";