summaryrefslogtreecommitdiff
path: root/refspec.h
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2025-03-18 18:50:18 -0400
committerJunio C Hamano <gitster@pobox.com>2025-03-21 01:45:15 -0700
commit3809633d0adb77b02ba8cfe87578134e6a30f54d (patch)
treed4c2ee1d05664ad85ac8a8148f358a5250ac9526 /refspec.h
parentf543202a16f52f5951a10b2ed6b67d2cd1f1dd17 (diff)
refspec: treat 'fetch' as a Boolean value
Since 6d4c057859 (refspec: introduce struct refspec, 2018-05-16), we have macros called REFSPEC_FETCH and REFSPEC_PUSH. This confusingly suggests that we might introduce other modes in the future, which, while possible, is highly unlikely. But these values are treated as a Boolean, and stored in a struct field called 'fetch'. So the following: if (refspec->fetch == REFSPEC_FETCH) { ... } , and if (refspec->fetch) { ... } are equivalent. Let's avoid renaming the Boolean values "true" and "false" here and remove the two REFSPEC_ macros mentioned above. Since this value is truly a Boolean and will only ever take on a value of 0 or 1, we can declare it as a single bit unsigned field. In practice this won't shrink the size of 'struct refspec', but it more clearly indicates the intent. Note that this introduces some awkwardness like: refspec_item_init_or_die(&spec, refspec, 1); , where it's unclear what the final "1" does. This will be addressed in the following commits. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refspec.h')
-rw-r--r--refspec.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/refspec.h b/refspec.h
index e2b5cc54ef..155494cd3a 100644
--- a/refspec.h
+++ b/refspec.h
@@ -32,11 +32,8 @@ struct refspec_item {
struct string_list;
-#define REFSPEC_FETCH 1
-#define REFSPEC_PUSH 0
-
-#define REFSPEC_INIT_FETCH { .fetch = REFSPEC_FETCH }
-#define REFSPEC_INIT_PUSH { .fetch = REFSPEC_PUSH }
+#define REFSPEC_INIT_FETCH { .fetch = 1 }
+#define REFSPEC_INIT_PUSH { .fetch = 0 }
/**
* An array of strings can be parsed into a struct refspec using
@@ -47,7 +44,7 @@ struct refspec {
int alloc;
int nr;
- int fetch;
+ unsigned fetch : 1;
};
int refspec_item_init(struct refspec_item *item, const char *refspec,