Skip to content

Commit 29ef1f2

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5a14dd commit 29ef1f2

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
637637
repo_init_revisions(the_repository, &rev, prefix);
638638
rev.diff = 1;
639639
rev.always_show_header = 1;
640-
rev.no_walk = REVISION_WALK_NO_WALK_SORTED;
640+
rev.no_walk = 1;
641641
rev.diffopt.stat_width = -1; /* Scale to real terminal size */
642642

643643
memset(&opt, 0, sizeof(opt));

builtin/revert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
191191
struct setup_revision_opt s_r_opt;
192192
opts->revs = xmalloc(sizeof(*opts->revs));
193193
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;
195196
if (argc < 2)
196197
usage_with_options(usage_str, options);
197198
if (!strcmp(argv[1], "-"))

revision.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,16 +2651,17 @@ static int handle_revision_pseudo_opt(const char *submodule,
26512651
} else if (!strcmp(arg, "--not")) {
26522652
*flags ^= UNINTERESTING | BOTTOM;
26532653
} else if (!strcmp(arg, "--no-walk")) {
2654-
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2654+
revs->no_walk = 1;
26552655
} else if (skip_prefix(arg, "--no-walk=", &optarg)) {
26562656
/*
26572657
* Detached form ("--no-walk X" as opposed to "--no-walk=X")
26582658
* not allowed, since the argument is optional.
26592659
*/
2660+
revs->no_walk = 1;
26602661
if (!strcmp(optarg, "sorted"))
2661-
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
2662+
revs->unsorted_input = 0;
26622663
else if (!strcmp(optarg, "unsorted"))
2663-
revs->no_walk = REVISION_WALK_NO_WALK_UNSORTED;
2664+
revs->unsorted_input = 1;
26642665
else
26652666
return error("invalid argument to --no-walk");
26662667
} else if (!strcmp(arg, "--do-walk")) {
@@ -3584,7 +3585,7 @@ int prepare_revision_walk(struct rev_info *revs)
35843585

35853586
if (!revs->reflog_info)
35863587
prepare_to_use_bloom_filter(revs);
3587-
if (revs->no_walk != REVISION_WALK_NO_WALK_UNSORTED)
3588+
if (!revs->unsorted_input)
35883589
commit_list_sort_by_date(&revs->commits);
35893590
if (revs->no_walk)
35903591
return 0;

revision.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ struct rev_cmdline_info {
7979
} *rev;
8080
};
8181

82-
#define REVISION_WALK_WALK 0
83-
#define REVISION_WALK_NO_WALK_SORTED 1
84-
#define REVISION_WALK_NO_WALK_UNSORTED 2
85-
8682
struct oidset;
8783
struct topo_walk_info;
8884

@@ -129,7 +125,8 @@ struct rev_info {
129125
/* Traversal flags */
130126
unsigned int dense:1,
131127
prune:1,
132-
no_walk:2,
128+
no_walk:1,
129+
unsorted_input:1,
133130
remove_empty_trees:1,
134131
simplify_history:1,
135132
show_pulls:1,

0 commit comments

Comments
 (0)