revision: separate walk and unsorted flags
The `--no-walk` flag supports two modes: either it sorts the revisions given as input input or it doesn't. This is reflected in a single `no_walk` flag, which reflects one of the three states "walk", "don't walk but without sorting" and "don't walk but with sorting". Split up the flag into two separate bits, one indicating whether we should walk or not and one indicating whether the input should be sorted or not. This will allow us to more easily introduce a new flag `--unsorted-input`, which only impacts the sorting bit. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Aug 5, 2021 at 13:25 UTC
29ef1f27fed21b5b7d3c996a01f1364e7e841917
4 files changed
+10
-11
builtin/log.c
+1
-1
@@ -637,7 +637,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
637
repo_init_revisions(the_repository, &rev, prefix);
638
rev.diff = 1;
639
rev.always_show_header = 1;
640
- rev.no_walk = REVISION_WALK_NO_WALK_SORTED;
640
+ rev.no_walk = 1;
641
rev.diffopt.stat_width = -1; /* Scale to real terminal size */
642
643
memset(&opt, 0, sizeof(opt));
builtin/revert.c
+2
-1
@@ -191,7 +191,8 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
191
struct setup_revision_opt s_r_opt;
192
opts->revs = xmalloc(sizeof(*opts->revs));
193
repo_init_revisions(the_repository, opts->revs, NULL);
194
- opts->revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED;
194
+ opts->revs->no_walk = 1;
195
+ opts->revs->unsorted_input = 1;
196
if (argc < 2)
197
usage_with_options(usage_str, options);
198
if (!strcmp(argv[1], "-"))
revision.c
+5
-4
@@ -2651,16 +2651,17 @@ static int handle_revision_pseudo_opt(const char *submodule,
2651
} else if (!strcmp(arg, "--not")) {
2652
*flags ^= UNINTERESTING | BOTTOM;
2653
} else if (!strcmp(arg, "--no-walk")) {
2654
- revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2654
+ revs->no_walk = 1;
2655
} else if (skip_prefix(arg, "--no-walk=", &optarg)) {
2656
/*
2657
* Detached form ("--no-walk X" as opposed to "--no-walk=X")
2658
* not allowed, since the argument is optional.
2659
*/
2660
+ revs->no_walk = 1;
2661
if (!strcmp(optarg, "sorted"))
2661
- revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2662
+ revs->unsorted_input = 0;
2663
else if (!strcmp(optarg, "unsorted"))
2663
- revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED;
2664
+ revs->unsorted_input = 1;
2665
else
2666
return error("invalid argument to --no-walk");
2667
} else if (!strcmp(arg, "--do-walk")) {
@@ -3584,7 +3585,7 @@ int prepare_revision_walk(struct rev_info *revs)
3585
3586
if (!revs->reflog_info)
3587
prepare_to_use_bloom_filter(revs);
3587
- if (revs->no_walk != REVISION_WALK_NO_WALK_UNSORTED)
3588
+ if (!revs->unsorted_input)
3589
commit_list_sort_by_date(&revs->commits);
3590
if (revs->no_walk)
3591
return 0;
revision.h
+2
-5
@@ -79,10 +79,6 @@ struct rev_cmdline_info {
79
} *rev;
80
};
81
82
-#define REVISION_WALK_WALK 0
83
-#define REVISION_WALK_NO_WALK_SORTED 1
84
-#define REVISION_WALK_NO_WALK_UNSORTED 2
85
-
82
struct oidset;
83
struct topo_walk_info;
84
@@ -129,7 +125,8 @@ struct rev_info {
125
/* Traversal flags */
126
unsigned int dense:1,
127
prune:1,
132
- no_walk:2,
128
+ no_walk:1,
129
+ unsorted_input:1,
130
remove_empty_trees:1,
131
simplify_history:1,
132
show_pulls:1,