push: further clean up fields of "struct ref"

The "nonfastforward" and "update" fields are only used while deciding what value to assign to the "status" locally in a single function. Remove them from the "struct ref". The "requires_force" field is not used to decide if the proposed update requires a --force option to succeed, or to record such a decision made elsewhere. It is used by status reporting code that the particular update was "forced". Rename it to "forced_update", and move the code to assign to it around to further clarify how it is used and what it is used for. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 21, 2013 at 20:24 UTC 5ece083fc7ffd60d38b9abf7797fbf00decd2bcc
3 files changed +8 -14
cache.h
+1 -3
@@ -1001,10 +1001,8 @@ struct ref {
1001 char *symref;
1002 unsigned int
1003 force:1,
1004 - requires_force:1,
1004 + forced_update:1,
1005 merge:1,
1006 - nonfastforward:1,
1007 - update:1,
1006 deletion:1;
1007 enum {
1008 REF_STATUS_NONE = 0,
remote.c
+6 -10
@@ -1317,27 +1317,23 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1317 * passing the --force argument
1318 */
1319
1320 - ref->update =
1321 - !ref->deletion &&
1322 - !is_null_sha1(ref->old_sha1);
1323 -
1324 - if (ref->update) {
1325 - ref->nonfastforward =
1320 + if (!ref->deletion && !is_null_sha1(ref->old_sha1)) {
1321 + int nonfastforward =
1322 !has_sha1_file(ref->old_sha1)
1327 - || !ref_newer(ref->new_sha1, ref->old_sha1);
1323 + || !ref_newer(ref->new_sha1, ref->old_sha1);
1324
1325 if (!prefixcmp(ref->name, "refs/tags/")) {
1330 - ref->requires_force = 1;
1326 if (!force_ref_update) {
1327 ref->status = REF_STATUS_REJECT_ALREADY_EXISTS;
1328 continue;
1329 }
1335 - } else if (ref->nonfastforward) {
1336 - ref->requires_force = 1;
1330 + ref->forced_update = 1;
1331 + } else if (nonfastforward) {
1332 if (!force_ref_update) {
1333 ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
1334 continue;
1335 }
1336 + ref->forced_update = 1;
1337 }
1338 }
1339 }
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->requires_force) {
662 + if (ref->forced_update) {
663 strcat(quickref, "...");
664 type = '+';
665 msg = "forced update";