зеркало из https://github.com/microsoft/git.git
rev-list --left-right
The output from "symmetric diff", i.e. A...B, does not distinguish between commits that are reachable from A and the ones that are reachable from B. In this picture, such a symmetric diff includes commits marked with a and b. x---b---b branch B / \ / / . / / \ o---x---a---a branch A However, you cannot tell which ones are 'a' and which ones are 'b' from the output. Sometimes this is frustrating. This adds an output option, --left-right, to rev-list. rev-list --left-right A...B would show ones reachable from A prefixed with '<' and the ones reachable from B prefixed with '>'. When combined with --boundary, boundary commits (the ones marked with 'x' in the above picture) are shown with prefix '-', so you would see list that looks like this: git rev-list --left-right --boundary --pretty=oneline A...B >bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 3rd on b >bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 2nd on b <aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3rd on a <aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2nd on a -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1st on b -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1st on a Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
ee6002aa42
Коммит
577ed5c20b
|
@ -45,6 +45,7 @@ static int bisect_list;
|
||||||
static int show_timestamp;
|
static int show_timestamp;
|
||||||
static int hdr_termination;
|
static int hdr_termination;
|
||||||
static const char *header_prefix;
|
static const char *header_prefix;
|
||||||
|
static int show_left_right;
|
||||||
|
|
||||||
static void show_commit(struct commit *commit)
|
static void show_commit(struct commit *commit)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,12 @@ static void show_commit(struct commit *commit)
|
||||||
fputs(header_prefix, stdout);
|
fputs(header_prefix, stdout);
|
||||||
if (commit->object.flags & BOUNDARY)
|
if (commit->object.flags & BOUNDARY)
|
||||||
putchar('-');
|
putchar('-');
|
||||||
|
else if (show_left_right) {
|
||||||
|
if (commit->object.flags & SYMMETRIC_LEFT)
|
||||||
|
putchar('<');
|
||||||
|
else
|
||||||
|
putchar('>');
|
||||||
|
}
|
||||||
if (revs.abbrev_commit && revs.abbrev)
|
if (revs.abbrev_commit && revs.abbrev)
|
||||||
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
|
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
|
||||||
stdout);
|
stdout);
|
||||||
|
@ -240,6 +247,10 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
|
||||||
bisect_list = 1;
|
bisect_list = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--left-right")) {
|
||||||
|
show_left_right = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--stdin")) {
|
if (!strcmp(arg, "--stdin")) {
|
||||||
if (read_from_stdin++)
|
if (read_from_stdin++)
|
||||||
die("--stdin given twice?");
|
die("--stdin given twice?");
|
||||||
|
|
10
commit.c
10
commit.c
|
@ -868,11 +868,11 @@ void sort_in_topological_order_fn(struct commit_list ** list, int lifo,
|
||||||
|
|
||||||
/* merge-rebase stuff */
|
/* merge-rebase stuff */
|
||||||
|
|
||||||
/* bits #0..7 in revision.h */
|
/* bits #0..15 in revision.h */
|
||||||
#define PARENT1 (1u<< 8)
|
#define PARENT1 (1u<<16)
|
||||||
#define PARENT2 (1u<< 9)
|
#define PARENT2 (1u<<17)
|
||||||
#define STALE (1u<<10)
|
#define STALE (1u<<18)
|
||||||
#define RESULT (1u<<11)
|
#define RESULT (1u<<19)
|
||||||
|
|
||||||
static struct commit *interesting(struct commit_list *list)
|
static struct commit *interesting(struct commit_list *list)
|
||||||
{
|
{
|
||||||
|
|
|
@ -344,6 +344,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
|
||||||
static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
|
static void add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
|
||||||
{
|
{
|
||||||
struct commit_list *parent = commit->parents;
|
struct commit_list *parent = commit->parents;
|
||||||
|
unsigned left_flag;
|
||||||
|
|
||||||
if (commit->object.flags & ADDED)
|
if (commit->object.flags & ADDED)
|
||||||
return;
|
return;
|
||||||
|
@ -388,6 +389,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
|
||||||
if (revs->no_walk)
|
if (revs->no_walk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
left_flag = (commit->object.flags & SYMMETRIC_LEFT);
|
||||||
parent = commit->parents;
|
parent = commit->parents;
|
||||||
while (parent) {
|
while (parent) {
|
||||||
struct commit *p = parent->item;
|
struct commit *p = parent->item;
|
||||||
|
@ -395,6 +397,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
|
||||||
parent = parent->next;
|
parent = parent->next;
|
||||||
|
|
||||||
parse_commit(p);
|
parse_commit(p);
|
||||||
|
p->object.flags |= left_flag;
|
||||||
if (p->object.flags & SEEN)
|
if (p->object.flags & SEEN)
|
||||||
continue;
|
continue;
|
||||||
p->object.flags |= SEEN;
|
p->object.flags |= SEEN;
|
||||||
|
@ -640,7 +643,7 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
|
||||||
add_pending_commit_list(revs, exclude,
|
add_pending_commit_list(revs, exclude,
|
||||||
flags_exclude);
|
flags_exclude);
|
||||||
free_commit_list(exclude);
|
free_commit_list(exclude);
|
||||||
a->object.flags |= flags;
|
a->object.flags |= flags | SYMMETRIC_LEFT;
|
||||||
} else
|
} else
|
||||||
a->object.flags |= flags_exclude;
|
a->object.flags |= flags_exclude;
|
||||||
b->object.flags |= flags;
|
b->object.flags |= flags;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define BOUNDARY (1u<<5)
|
#define BOUNDARY (1u<<5)
|
||||||
#define BOUNDARY_SHOW (1u<<6)
|
#define BOUNDARY_SHOW (1u<<6)
|
||||||
#define ADDED (1u<<7) /* Parents already parsed and added? */
|
#define ADDED (1u<<7) /* Parents already parsed and added? */
|
||||||
|
#define SYMMETRIC_LEFT (1u<<8)
|
||||||
|
|
||||||
struct rev_info;
|
struct rev_info;
|
||||||
struct log_info;
|
struct log_info;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче