summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-05-20 23:18:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-05-26 22:48:26 (GMT)
commit72263ffc322d0b6c8646a4f096981a0b4bad17ba (patch)
tree92bb7537dd8d91f61a21ac68a033b4de73b42f73 /builtin
parent4571324b99fcf7bd9e58fce677801fbf72b0e0a5 (diff)
downloadgit-72263ffc322d0b6c8646a4f096981a0b4bad17ba.zip
git-72263ffc322d0b6c8646a4f096981a0b4bad17ba.tar.gz
git-72263ffc322d0b6c8646a4f096981a0b4bad17ba.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/repack.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin/repack.c b/builtin/repack.c
index b85483a..36d1f03 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -22,6 +22,8 @@
#define LOOSEN_UNREACHABLE 2
#define PACK_CRUFT 4
+#define DELETE_PACK 1
+
static int pack_everything;
static int delta_base_offset = 1;
static int pack_kept_objects = -1;
@@ -564,7 +566,7 @@ static void midx_included_packs(struct string_list *include,
}
} else {
for_each_string_list_item(item, existing_nonkept_packs) {
- if (item->util)
+ if ((uintptr_t)item->util & DELETE_PACK)
continue;
string_list_insert(include, xstrfmt("%s.idx", item->string));
}
@@ -1002,7 +1004,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
* was given) and that we will actually delete this pack
* (if `-d` was given).
*/
- item->util = (void*)(intptr_t)!string_list_has_string(&names, sha1);
+ if (!string_list_has_string(&names, sha1))
+ item->util = (void*)(uintptr_t)((size_t)item->util | DELETE_PACK);
}
}
@@ -1026,7 +1029,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
if (delete_redundant) {
int opts = 0;
for_each_string_list_item(item, &existing_nonkept_packs) {
- if (!item->util)
+ if (!((uintptr_t)item->util & DELETE_PACK))
continue;
remove_redundant_pack(packdir, item->string);
}