Skip to content

Commit e339aa9

Browse files
peffgitster
authored andcommitted
clean up struct ref's nonfastforward field
Each ref structure contains a "nonfastforward" field which is set during push to show whether the ref rewound history. Originally this was a single bit, but it was changed in f25950f (push: Provide situational hints for non-fast-forward errors) to an enum differentiating a non-ff of the current branch versus another branch. However, we never actually set the member according to the enum values, nor did we ever read it expecting anything but a boolean value. But we did use the side effect of declaring the enum constants to store those values in a totally different integer variable. The code as-is isn't buggy, but the enum declaration inside "struct ref" is somewhat misleading. Let's convert nonfastforward back into a single bit, and then define the NON_FF_* constants closer to where they would be used (they are returned via the "int *nonfastforward" parameter to transport_push, so we can define them there). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f25950f commit e339aa9

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

cache.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ struct ref {
10091009
char *symref;
10101010
unsigned int force:1,
10111011
merge:1,
1012+
nonfastforward:1,
10121013
deletion:1;
10131014
enum {
10141015
REF_STATUS_NONE = 0,
@@ -1019,10 +1020,6 @@ struct ref {
10191020
REF_STATUS_REMOTE_REJECT,
10201021
REF_STATUS_EXPECTING_REPORT
10211022
} status;
1022-
enum {
1023-
NON_FF_HEAD = 1,
1024-
NON_FF_OTHER
1025-
} nonfastforward;
10261023
char *remote_status;
10271024
struct ref *peer_ref; /* when renaming */
10281025
char name[FLEX_ARRAY]; /* more */

transport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ int transport_set_option(struct transport *transport, const char *name,
138138
void transport_set_verbosity(struct transport *transport, int verbosity,
139139
int force_progress);
140140

141+
#define NON_FF_HEAD 1
142+
#define NON_FF_OTHER 2
141143
int transport_push(struct transport *connection,
142144
int refspec_nr, const char **refspec, int flags,
143145
int * nonfastforward);

0 commit comments

Comments
 (0)