Skip to content

Commit 8259e41

Browse files
newrenchriscool
authored andcommitted
replay: change rev walking options
Let's force the rev walking options we need after calling setup_revisions() instead of before. This might override some user supplied rev walking command line options though. So let's detect that and warn users by: a) setting the desired values, before setup_revisions(), b) checking after setup_revisions() whether these values differ from the desired values, c) if so throwing a warning and setting the desired values again. We want the command to work from older commits to newer ones by default. Also we don't want history simplification, as we want to deal with all the commits in the affected range. Helped-by: Johannes Schindelin <[email protected]> Co-authored-by: Christian Couder <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e787e66 commit 8259e41

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

builtin/replay.c

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,56 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
173173

174174
repo_init_revisions(the_repository, &revs, prefix);
175175

176-
revs.verbose_header = 1;
177-
revs.max_parents = 1;
178-
revs.cherry_mark = 1;
179-
revs.limited = 1;
176+
strvec_pushl(&rev_walk_args, "", argv[2], "--not", argv[1], NULL);
177+
178+
/*
179+
* Set desired values for rev walking options here. If they
180+
* are changed by some user specified option in setup_revisions()
181+
* below, we will detect that below and then warn.
182+
*
183+
* TODO: In the future we might want to either die(), or allow
184+
* some options changing these values if we think they could
185+
* be useful.
186+
*/
180187
revs.reverse = 1;
181-
revs.right_only = 1;
182188
revs.sort_order = REV_SORT_IN_GRAPH_ORDER;
183189
revs.topo_order = 1;
184-
185-
strvec_pushl(&rev_walk_args, "", argv[2], "--not", argv[1], NULL);
190+
revs.simplify_history = 0;
186191

187192
if (setup_revisions(rev_walk_args.nr, rev_walk_args.v, &revs, NULL) > 1) {
188193
ret = error(_("unhandled options"));
189194
goto cleanup;
190195
}
191196

197+
/*
198+
* Detect and warn if we override some user specified rev
199+
* walking options.
200+
*/
201+
if (revs.reverse != 1) {
202+
warning(_("some rev walking options will be overridden as "
203+
"'%s' bit in 'struct rev_info' will be forced"),
204+
"reverse");
205+
revs.reverse = 1;
206+
}
207+
if (revs.sort_order != REV_SORT_IN_GRAPH_ORDER) {
208+
warning(_("some rev walking options will be overridden as "
209+
"'%s' bit in 'struct rev_info' will be forced"),
210+
"sort_order");
211+
revs.sort_order = REV_SORT_IN_GRAPH_ORDER;
212+
}
213+
if (revs.topo_order != 1) {
214+
warning(_("some rev walking options will be overridden as "
215+
"'%s' bit in 'struct rev_info' will be forced"),
216+
"topo_order");
217+
revs.topo_order = 1;
218+
}
219+
if (revs.simplify_history != 0) {
220+
warning(_("some rev walking options will be overridden as "
221+
"'%s' bit in 'struct rev_info' will be forced"),
222+
"simplify_history");
223+
revs.simplify_history = 0;
224+
}
225+
192226
strvec_clear(&rev_walk_args);
193227

194228
if (prepare_revision_walk(&revs) < 0) {

0 commit comments

Comments
 (0)