builtin/repack.c: use named flags for existing_packs
We use the `util` pointer for items in the `existing_packs` string list to indicate which packs are going to be deleted. Since that has so far been the only use of that `util` pointer, we just set it to 0 or 1. But we're going to add an additional state to this field in the next patch, so prepare for that by adding a #define for the first bit so we can more expressively inspect the flags state. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
May 20, 2022 at 19:18 UTC
72263ffc322d0b6c8646a4f096981a0b4bad17ba
1 file changed
+6
-3
builtin/repack.c
+6
-3
@@ -22,6 +22,8 @@
22
#define LOOSEN_UNREACHABLE 2
23
#define PACK_CRUFT 4
24
25
+#define DELETE_PACK 1
26
+
27
static int pack_everything;
28
static int delta_base_offset = 1;
29
static int pack_kept_objects = -1;
@@ -564,7 +566,7 @@ static void midx_included_packs(struct string_list *include,
566
}
567
} else {
568
for_each_string_list_item(item, existing_nonkept_packs) {
567
- if (item->util)
569
+ if ((uintptr_t)item->util & DELETE_PACK)
570
continue;
571
string_list_insert(include, xstrfmt("%s.idx", item->string));
572
}
@@ -1002,7 +1004,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1004
* was given) and that we will actually delete this pack
1005
* (if `-d` was given).
1006
*/
1005
- item->util = (void*)(intptr_t)!string_list_has_string(&names, sha1);
1007
+ if (!string_list_has_string(&names, sha1))
1008
+ item->util = (void*)(uintptr_t)((size_t)item->util | DELETE_PACK);
1009
}
1010
}
1011
@@ -1026,7 +1029,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1029
if (delete_redundant) {
1030
int opts = 0;
1031
for_each_string_list_item(item, &existing_nonkept_packs) {
1029
- if (!item->util)
1032
+ if (!((uintptr_t)item->util & DELETE_PACK))
1033
continue;
1034
remove_redundant_pack(packdir, item->string);
1035
}