Skip to content

Commit 5ece083

Browse files
committed
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 <[email protected]>
1 parent 256b9d7 commit 5ece083

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

cache.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,8 @@ struct ref {
10011001
char *symref;
10021002
unsigned int
10031003
force:1,
1004-
requires_force:1,
1004+
forced_update:1,
10051005
merge:1,
1006-
nonfastforward:1,
1007-
update:1,
10081006
deletion:1;
10091007
enum {
10101008
REF_STATUS_NONE = 0,

remote.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,27 +1317,23 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
13171317
* passing the --force argument
13181318
*/
13191319

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 =
13261322
!has_sha1_file(ref->old_sha1)
1327-
|| !ref_newer(ref->new_sha1, ref->old_sha1);
1323+
|| !ref_newer(ref->new_sha1, ref->old_sha1);
13281324

13291325
if (!prefixcmp(ref->name, "refs/tags/")) {
1330-
ref->requires_force = 1;
13311326
if (!force_ref_update) {
13321327
ref->status = REF_STATUS_REJECT_ALREADY_EXISTS;
13331328
continue;
13341329
}
1335-
} else if (ref->nonfastforward) {
1336-
ref->requires_force = 1;
1330+
ref->forced_update = 1;
1331+
} else if (nonfastforward) {
13371332
if (!force_ref_update) {
13381333
ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
13391334
continue;
13401335
}
1336+
ref->forced_update = 1;
13411337
}
13421338
}
13431339
}

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
659659
const char *msg;
660660

661661
strcpy(quickref, status_abbrev(ref->old_sha1));
662-
if (ref->requires_force) {
662+
if (ref->forced_update) {
663663
strcat(quickref, "...");
664664
type = '+';
665665
msg = "forced update";

0 commit comments

Comments
 (0)