revision: allow --ancestry-path to take an argument

We have long allowed users to run e.g.
    git log --ancestry-path master..seen
which shows all commits which satisfy all three of these criteria:
  * are an ancestor of seen
  * are not an ancestor of master
  * have master as an ancestor

This commit allows another variant:
    git log --ancestry-path=$TOPIC master..seen
which shows all commits which satisfy all of these criteria:
  * are an ancestor of seen
  * are not an ancestor of master
  * have $TOPIC in their ancestry-path
that last bullet can be defined as commits meeting any of these
criteria:
    * are an ancestor of $TOPIC
    * have $TOPIC as an ancestor
    * are $TOPIC

This also allows multiple --ancestry-path arguments, which can be
used to find commits with any of the given topics in their ancestry
path.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren
2022-08-19 04:28:10 +00:00
committed by Junio C Hamano
parent 1838e21cff
commit 257418c590
5 changed files with 115 additions and 43 deletions

View File

@ -48,6 +48,7 @@
*/
#define NOT_USER_GIVEN (1u<<25)
#define TRACK_LINEAR (1u<<26)
#define ANCESTRY_PATH (1u<<27)
#define ALL_REV_FLAGS (((1u<<11)-1) | NOT_USER_GIVEN | TRACK_LINEAR | PULL_MERGE)
#define DECORATE_SHORT_REFS 1
@ -164,6 +165,13 @@ struct rev_info {
cherry_mark:1,
bisect:1,
ancestry_path:1,
/* True if --ancestry-path was specified without an
* argument. The bottom revisions are implicitly
* the arguments in this case.
*/
ancestry_path_implicit_bottoms:1,
first_parent_only:1,
exclude_first_parent_only:1,
line_level_traverse:1,
@ -306,6 +314,7 @@ struct rev_info {
struct saved_parents *saved_parents_slab;
struct commit_list *previous_parents;
struct commit_list *ancestry_path_bottoms;
const char *break_bar;
struct revision_sources *sources;