Skip to content

Commit 8e32060

Browse files
bk2204gitster
authored andcommitted
fast-import: make find_marks work on any mark set
In the future, we'll use multiple different mark sets with this function, so make it take an argument that points to the mark set to operate on. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1780d8f commit 8e32060

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

fast-import.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,9 @@ static void insert_mark(struct mark_set *s, uintmax_t idnum, struct object_entry
517517
s->data.marked[idnum] = oe;
518518
}
519519

520-
static struct object_entry *find_mark(uintmax_t idnum)
520+
static void *find_mark(struct mark_set *s, uintmax_t idnum)
521521
{
522522
uintmax_t orig_idnum = idnum;
523-
struct mark_set *s = marks;
524523
struct object_entry *oe = NULL;
525524
if ((idnum >> s->shift) < 1024) {
526525
while (s && s->shift) {
@@ -2225,7 +2224,7 @@ static void file_change_m(const char *p, struct branch *b)
22252224
}
22262225

22272226
if (*p == ':') {
2228-
oe = find_mark(parse_mark_ref_space(&p));
2227+
oe = find_mark(marks, parse_mark_ref_space(&p));
22292228
oidcpy(&oid, &oe->idx.oid);
22302229
} else if (skip_prefix(p, "inline ", &p)) {
22312230
inline_data = 1;
@@ -2399,7 +2398,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
23992398
/* Now parse the notemodify command. */
24002399
/* <dataref> or 'inline' */
24012400
if (*p == ':') {
2402-
oe = find_mark(parse_mark_ref_space(&p));
2401+
oe = find_mark(marks, parse_mark_ref_space(&p));
24032402
oidcpy(&oid, &oe->idx.oid);
24042403
} else if (skip_prefix(p, "inline ", &p)) {
24052404
inline_data = 1;
@@ -2420,7 +2419,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
24202419
oidcpy(&commit_oid, &s->oid);
24212420
} else if (*p == ':') {
24222421
uintmax_t commit_mark = parse_mark_ref_eol(p);
2423-
struct object_entry *commit_oe = find_mark(commit_mark);
2422+
struct object_entry *commit_oe = find_mark(marks, commit_mark);
24242423
if (commit_oe->type != OBJ_COMMIT)
24252424
die("Mark :%" PRIuMAX " not a commit", commit_mark);
24262425
oidcpy(&commit_oid, &commit_oe->idx.oid);
@@ -2524,7 +2523,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
25242523
oidcpy(&b->branch_tree.versions[1].oid, t);
25252524
} else if (*objectish == ':') {
25262525
uintmax_t idnum = parse_mark_ref_eol(objectish);
2527-
struct object_entry *oe = find_mark(idnum);
2526+
struct object_entry *oe = find_mark(marks, idnum);
25282527
if (oe->type != OBJ_COMMIT)
25292528
die("Mark :%" PRIuMAX " not a commit", idnum);
25302529
if (!oideq(&b->oid, &oe->idx.oid)) {
@@ -2588,7 +2587,7 @@ static struct hash_list *parse_merge(unsigned int *count)
25882587
oidcpy(&n->oid, &s->oid);
25892588
else if (*from == ':') {
25902589
uintmax_t idnum = parse_mark_ref_eol(from);
2591-
struct object_entry *oe = find_mark(idnum);
2590+
struct object_entry *oe = find_mark(marks, idnum);
25922591
if (oe->type != OBJ_COMMIT)
25932592
die("Mark :%" PRIuMAX " not a commit", idnum);
25942593
oidcpy(&n->oid, &oe->idx.oid);
@@ -2762,7 +2761,7 @@ static void parse_new_tag(const char *arg)
27622761
} else if (*from == ':') {
27632762
struct object_entry *oe;
27642763
from_mark = parse_mark_ref_eol(from);
2765-
oe = find_mark(from_mark);
2764+
oe = find_mark(marks, from_mark);
27662765
type = oe->type;
27672766
oidcpy(&oid, &oe->idx.oid);
27682767
} else if (!get_oid(from, &oid)) {
@@ -2920,7 +2919,7 @@ static void parse_get_mark(const char *p)
29202919
if (*p != ':')
29212920
die("Not a mark: %s", p);
29222921

2923-
oe = find_mark(parse_mark_ref_eol(p));
2922+
oe = find_mark(marks, parse_mark_ref_eol(p));
29242923
if (!oe)
29252924
die("Unknown mark: %s", command_buf.buf);
29262925

@@ -2935,7 +2934,7 @@ static void parse_cat_blob(const char *p)
29352934

29362935
/* cat-blob SP <object> LF */
29372936
if (*p == ':') {
2938-
oe = find_mark(parse_mark_ref_eol(p));
2937+
oe = find_mark(marks, parse_mark_ref_eol(p));
29392938
if (!oe)
29402939
die("Unknown mark: %s", command_buf.buf);
29412940
oidcpy(&oid, &oe->idx.oid);
@@ -3010,7 +3009,7 @@ static struct object_entry *parse_treeish_dataref(const char **p)
30103009
struct object_entry *e;
30113010

30123011
if (**p == ':') { /* <mark> */
3013-
e = find_mark(parse_mark_ref_space(p));
3012+
e = find_mark(marks, parse_mark_ref_space(p));
30143013
if (!e)
30153014
die("Unknown mark: %s", command_buf.buf);
30163015
oidcpy(&oid, &e->idx.oid);

0 commit comments

Comments
 (0)