pack-objects: fix --no-keep-true-parents
Since 99fb6e04cb (pack-objects: convert to use parse_options(), 2012-02-01) git pack-objects has accepted --no-keep-true-parents, but this option does the same as --keep-true-parents. That's because it's defined using OPT_SET_INT with a value of 0, which sets 0 when negated as well. Turn --no-keep-true-parents into the opposite of --keep-true-parents by using OPT_BOOL and storing the option's status directly in a variable named "grafts_keep_true_parents" instead of in negative form in "grafts_replace_parents". Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jul 21, 2023 at 14:41 UTC
3a5f30874120880ddaa53d0db4c3b4ec0a07297a
4 files changed
+5
-5
builtin/pack-objects.c
+2
-2
@@ -4256,8 +4256,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
4256
N_("ignore this pack")),
4257
OPT_INTEGER(0, "compression", &pack_compression_level,
4258
N_("pack compression level")),
4259
- OPT_SET_INT(0, "keep-true-parents", &grafts_replace_parents,
4260
- N_("do not hide commits by grafts"), 0),
4259
+ OPT_BOOL(0, "keep-true-parents", &grafts_keep_true_parents,
4260
+ N_("do not hide commits by grafts")),
4261
OPT_BOOL(0, "use-bitmap-index", &use_bitmap_index,
4262
N_("use a bitmap index if available to speed up counting objects")),
4263
OPT_SET_INT(0, "write-bitmap-index", &write_bitmap_index,
commit.c
+1
-1
@@ -516,7 +516,7 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
516
* The clone is shallow if nr_parent < 0, and we must
517
* not traverse its real parents even when we unhide them.
518
*/
519
- if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
519
+ if (graft && (graft->nr_parent < 0 || !grafts_keep_true_parents))
520
continue;
521
new_parent = lookup_commit(r, &parent);
522
if (!new_parent)
environment.c
+1
-1
@@ -75,7 +75,7 @@ enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
75
#endif
76
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
77
char *notes_ref_name;
78
-int grafts_replace_parents = 1;
78
+int grafts_keep_true_parents;
79
int core_apply_sparse_checkout;
80
int core_sparse_checkout_cone;
81
int sparse_expect_files_outside_of_patterns;
environment.h
+1
-1
@@ -194,7 +194,7 @@ extern enum object_creation_mode object_creation_mode;
194
195
extern char *notes_ref_name;
196
197
-extern int grafts_replace_parents;
197
+extern int grafts_keep_true_parents;
198
199
extern int repository_format_precious_objects;
200
extern int repository_format_worktree_config;