@matheusbsbs / matheus-bagliano / commits / a7de713089
Fork 0

pack-objects: remove some double negative logic

Parsing !no_reuse_delta everywhere makes my brain spend extra cycles wondering each time. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed May 2, 2008 at 15:11 UTC a7de713089082005d14679b694fd3999978fb735
1 file changed +9 -8
builtin-pack-objects.c
+9 -8
@@ -65,7 +65,8 @@ static struct pack_idx_entry **written_list;
65 static uint32_t nr_objects, nr_alloc, nr_result, nr_written;
66
67 static int non_empty;
68 -static int no_reuse_delta, no_reuse_object, keep_unreachable, include_tag;
68 +static int reuse_delta = 1, reuse_object = 1;
69 +static int keep_unreachable, include_tag;
70 static int local;
71 static int incremental;
72 static int allow_ofs_delta;
@@ -251,7 +252,7 @@ static unsigned long write_object(struct sha1file *f,
252 crc32_begin(f);
253
254 obj_type = entry->type;
254 - if (no_reuse_object)
255 + if (!reuse_object)
256 to_reuse = 0; /* explicit */
257 else if (!entry->in_pack)
258 to_reuse = 0; /* can't reuse what we don't have */
@@ -1021,7 +1022,7 @@ static void check_object(struct object_entry *entry)
1022 unuse_pack(&w_curs);
1023 return;
1024 case OBJ_REF_DELTA:
1024 - if (!no_reuse_delta && !entry->preferred_base)
1025 + if (reuse_delta && !entry->preferred_base)
1026 base_ref = use_pack(p, &w_curs,
1027 entry->in_pack_offset + used, NULL);
1028 entry->in_pack_header_size = used + 20;
@@ -1044,7 +1045,7 @@ static void check_object(struct object_entry *entry)
1045 die("delta base offset out of bound for %s",
1046 sha1_to_hex(entry->idx.sha1));
1047 ofs = entry->in_pack_offset - ofs;
1047 - if (!no_reuse_delta && !entry->preferred_base) {
1048 + if (reuse_delta && !entry->preferred_base) {
1049 struct revindex_entry *revidx;
1050 revidx = find_pack_revindex(p, ofs);
1051 base_ref = nth_packed_object_sha1(p, revidx->nr);
@@ -1232,7 +1233,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
1233 * We do not bother to try a delta that we discarded
1234 * on an earlier try, but only when reusing delta data.
1235 */
1235 - if (!no_reuse_delta && trg_entry->in_pack &&
1236 + if (reuse_delta && trg_entry->in_pack &&
1237 trg_entry->in_pack == src_entry->in_pack &&
1238 trg_entry->in_pack_type != OBJ_REF_DELTA &&
1239 trg_entry->in_pack_type != OBJ_OFS_DELTA)
@@ -1687,7 +1688,7 @@ static void prepare_pack(int window, int depth)
1688
1689 if (entry->delta)
1690 /* This happens if we decided to reuse existing
1690 - * delta from a pack. "!no_reuse_delta &&" is implied.
1691 + * delta from a pack. "reuse_delta &&" is implied.
1692 */
1693 continue;
1694
@@ -2049,11 +2050,11 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
2050 continue;
2051 }
2052 if (!strcmp("--no-reuse-delta", arg)) {
2052 - no_reuse_delta = 1;
2053 + reuse_delta = 0;
2054 continue;
2055 }
2056 if (!strcmp("--no-reuse-object", arg)) {
2056 - no_reuse_object = no_reuse_delta = 1;
2057 + reuse_object = reuse_delta = 0;
2058 continue;
2059 }
2060 if (!strcmp("--delta-base-offset", arg)) {