Skip to content

Commit 6560a73

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent 8d41dbb commit 6560a73

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builtin/repack.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define LOOSEN_UNREACHABLE 2
2323
#define PACK_CRUFT 4
2424

25+
#define DELETE_PACK 1
26+
2527
static int pack_everything;
2628
static int delta_base_offset = 1;
2729
static int pack_kept_objects = -1;
@@ -561,7 +563,7 @@ static void midx_included_packs(struct string_list *include,
561563
}
562564
} else {
563565
for_each_string_list_item(item, existing_nonkept_packs) {
564-
if (item->util)
566+
if ((uintptr_t)item->util & DELETE_PACK)
565567
continue;
566568
string_list_insert(include, xstrfmt("%s.idx", item->string));
567569
}
@@ -1000,7 +1002,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
10001002
* was given) and that we will actually delete this pack
10011003
* (if `-d` was given).
10021004
*/
1003-
item->util = (void*)(intptr_t)!string_list_has_string(&names, sha1);
1005+
if (!string_list_has_string(&names, sha1))
1006+
item->util = (void*)(uintptr_t)((size_t)item->util | DELETE_PACK);
10041007
}
10051008
}
10061009

@@ -1024,7 +1027,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
10241027
if (delete_redundant) {
10251028
int opts = 0;
10261029
for_each_string_list_item(item, &existing_nonkept_packs) {
1027-
if (!item->util)
1030+
if (!((uintptr_t)item->util & DELETE_PACK))
10281031
continue;
10291032
remove_redundant_pack(packdir, item->string);
10301033
}

0 commit comments

Comments
 (0)