Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 7f34a46

Browse files
kjbracey2gitster
authored andcommitted
revision.c: add BOTTOM flag for commits
When performing edge-based operations on the revision graph, it can be useful to be able to identify the INTERESTING graph's connection(s) to the bottom commit(s) specified by the user. Conceptually when the user specifies "A..B" (== B ^A), they are asking for the history from A to B. The first connection from A onto the INTERESTING graph is part of that history, and should be considered. If we consider only INTERESTING nodes and their connections, then we're really only considering the history from A's immediate descendants to B. This patch does not change behaviour, but adds a new BOTTOM flag to indicate the bottom commits specified by the user, ready to be used by following patches. We immediately use the BOTTOM flag to return collect_bottom_commits() to its original approach of examining the pending commit list rather than the command line. This will ensure alignment of the definition of "bottom" with future patches. Signed-off-by: Kevin Bracey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 143f1ea commit 7f34a46

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

revision.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -909,16 +909,12 @@ static void limit_to_ancestry(struct commit_list *bottom, struct commit_list *li
909909
* to filter the result of "A..B" further to the ones that can actually
910910
* reach A.
911911
*/
912-
static struct commit_list *collect_bottom_commits(struct rev_info *revs)
912+
static struct commit_list *collect_bottom_commits(struct commit_list *list)
913913
{
914-
struct commit_list *bottom = NULL;
915-
int i;
916-
for (i = 0; i < revs->cmdline.nr; i++) {
917-
struct rev_cmdline_entry *elem = &revs->cmdline.rev[i];
918-
if ((elem->flags & UNINTERESTING) &&
919-
elem->item->type == OBJ_COMMIT)
920-
commit_list_insert((struct commit *)elem->item, &bottom);
921-
}
914+
struct commit_list *elem, *bottom = NULL;
915+
for (elem = list; elem; elem = elem->next)
916+
if (elem->item->object.flags & BOTTOM)
917+
commit_list_insert(elem->item, &bottom);
922918
return bottom;
923919
}
924920

@@ -949,7 +945,7 @@ static int limit_list(struct rev_info *revs)
949945
struct commit_list *bottom = NULL;
950946

951947
if (revs->ancestry_path) {
952-
bottom = collect_bottom_commits(revs);
948+
bottom = collect_bottom_commits(list);
953949
if (!bottom)
954950
die("--ancestry-path given but there are no bottom commits");
955951
}
@@ -1121,7 +1117,7 @@ static int add_parents_only(struct rev_info *revs, const char *arg_, int flags)
11211117
const char *arg = arg_;
11221118

11231119
if (*arg == '^') {
1124-
flags ^= UNINTERESTING;
1120+
flags ^= UNINTERESTING | BOTTOM;
11251121
arg++;
11261122
}
11271123
if (get_sha1_committish(arg, sha1))
@@ -1213,8 +1209,8 @@ static void prepare_show_merge(struct rev_info *revs)
12131209
add_pending_object(revs, &head->object, "HEAD");
12141210
add_pending_object(revs, &other->object, "MERGE_HEAD");
12151211
bases = get_merge_bases(head, other, 1);
1216-
add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING);
1217-
add_pending_commit_list(revs, bases, UNINTERESTING);
1212+
add_rev_cmdline_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING | BOTTOM);
1213+
add_pending_commit_list(revs, bases, UNINTERESTING | BOTTOM);
12181214
free_commit_list(bases);
12191215
head->object.flags |= SYMMETRIC_LEFT;
12201216

@@ -1250,13 +1246,15 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
12501246
int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;
12511247
unsigned get_sha1_flags = 0;
12521248

1249+
flags = flags & UNINTERESTING ? flags | BOTTOM : flags & ~BOTTOM;
1250+
12531251
dotdot = strstr(arg, "..");
12541252
if (dotdot) {
12551253
unsigned char from_sha1[20];
12561254
const char *next = dotdot + 2;
12571255
const char *this = arg;
12581256
int symmetric = *next == '.';
1259-
unsigned int flags_exclude = flags ^ UNINTERESTING;
1257+
unsigned int flags_exclude = flags ^ (UNINTERESTING | BOTTOM);
12601258
static const char head_by_default[] = "HEAD";
12611259
unsigned int a_flags;
12621260

@@ -1332,13 +1330,13 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
13321330
dotdot = strstr(arg, "^!");
13331331
if (dotdot && !dotdot[2]) {
13341332
*dotdot = 0;
1335-
if (!add_parents_only(revs, arg, flags ^ UNINTERESTING))
1333+
if (!add_parents_only(revs, arg, flags ^ (UNINTERESTING | BOTTOM)))
13361334
*dotdot = '^';
13371335
}
13381336

13391337
local_flags = 0;
13401338
if (*arg == '^') {
1341-
local_flags = UNINTERESTING;
1339+
local_flags = UNINTERESTING | BOTTOM;
13421340
arg++;
13431341
}
13441342

@@ -1815,7 +1813,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
18151813
handle_refs(submodule, revs, *flags, for_each_branch_ref_submodule);
18161814
} else if (!strcmp(arg, "--bisect")) {
18171815
handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref);
1818-
handle_refs(submodule, revs, *flags ^ UNINTERESTING, for_each_good_bisect_ref);
1816+
handle_refs(submodule, revs, *flags ^ (UNINTERESTING | BOTTOM), for_each_good_bisect_ref);
18191817
revs->bisect = 1;
18201818
} else if (!strcmp(arg, "--tags")) {
18211819
handle_refs(submodule, revs, *flags, for_each_tag_ref_submodule);
@@ -1841,7 +1839,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
18411839
} else if (!strcmp(arg, "--reflog")) {
18421840
handle_reflog(revs, *flags);
18431841
} else if (!strcmp(arg, "--not")) {
1844-
*flags ^= UNINTERESTING;
1842+
*flags ^= UNINTERESTING | BOTTOM;
18451843
} else if (!strcmp(arg, "--no-walk")) {
18461844
revs->no_walk = REVISION_WALK_NO_WALK_SORTED;
18471845
} else if (!prefixcmp(arg, "--no-walk=")) {

revision.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#define ADDED (1u<<7) /* Parents already parsed and added? */
1616
#define SYMMETRIC_LEFT (1u<<8)
1717
#define PATCHSAME (1u<<9)
18-
#define ALL_REV_FLAGS ((1u<<10)-1)
18+
#define BOTTOM (1u<<10)
19+
#define ALL_REV_FLAGS ((1u<<11)-1)
1920

2021
#define DECORATE_SHORT_REFS 1
2122
#define DECORATE_FULL_REFS 2

0 commit comments

Comments
 (0)