@matheusbsbs / matheus-bagliano / commits / 11d8ef3ee7
Fork 0

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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 22, 2020 at 20:17 UTC 11d8ef3ee7ab8cfe56a4276ea4b62794d23293e3
1 file changed +10 -11
fast-import.c
+10 -11
@@ -517,10 +517,9 @@ static void insert_mark(struct mark_set *s, uintmax_t idnum, struct object_entry
517 s->data.marked[idnum] = oe;
518 }
519
520 -static struct object_entry *find_mark(uintmax_t idnum)
520 +static void *find_mark(struct mark_set *s, uintmax_t idnum)
521 {
522 uintmax_t orig_idnum = idnum;
523 - struct mark_set *s = marks;
523 struct object_entry *oe = NULL;
524 if ((idnum >> s->shift) < 1024) {
525 while (s && s->shift) {
@@ -2225,7 +2224,7 @@ static void file_change_m(const char *p, struct branch *b)
2224 }
2225
2226 if (*p == ':') {
2228 - oe = find_mark(parse_mark_ref_space(&p));
2227 + oe = find_mark(marks, parse_mark_ref_space(&p));
2228 oidcpy(&oid, &oe->idx.oid);
2229 } else if (skip_prefix(p, "inline ", &p)) {
2230 inline_data = 1;
@@ -2399,7 +2398,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2398 /* Now parse the notemodify command. */
2399 /* <dataref> or 'inline' */
2400 if (*p == ':') {
2402 - oe = find_mark(parse_mark_ref_space(&p));
2401 + oe = find_mark(marks, parse_mark_ref_space(&p));
2402 oidcpy(&oid, &oe->idx.oid);
2403 } else if (skip_prefix(p, "inline ", &p)) {
2404 inline_data = 1;
@@ -2420,7 +2419,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2419 oidcpy(&commit_oid, &s->oid);
2420 } else if (*p == ':') {
2421 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);
2423 if (commit_oe->type != OBJ_COMMIT)
2424 die("Mark :%" PRIuMAX " not a commit", commit_mark);
2425 oidcpy(&commit_oid, &commit_oe->idx.oid);
@@ -2524,7 +2523,7 @@ static int parse_objectish(struct branch *b, const char *objectish)
2523 oidcpy(&b->branch_tree.versions[1].oid, t);
2524 } else if (*objectish == ':') {
2525 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);
2527 if (oe->type != OBJ_COMMIT)
2528 die("Mark :%" PRIuMAX " not a commit", idnum);
2529 if (!oideq(&b->oid, &oe->idx.oid)) {
@@ -2588,7 +2587,7 @@ static struct hash_list *parse_merge(unsigned int *count)
2587 oidcpy(&n->oid, &s->oid);
2588 else if (*from == ':') {
2589 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);
2591 if (oe->type != OBJ_COMMIT)
2592 die("Mark :%" PRIuMAX " not a commit", idnum);
2593 oidcpy(&n->oid, &oe->idx.oid);
@@ -2762,7 +2761,7 @@ static void parse_new_tag(const char *arg)
2761 } else if (*from == ':') {
2762 struct object_entry *oe;
2763 from_mark = parse_mark_ref_eol(from);
2765 - oe = find_mark(from_mark);
2764 + oe = find_mark(marks, from_mark);
2765 type = oe->type;
2766 oidcpy(&oid, &oe->idx.oid);
2767 } else if (!get_oid(from, &oid)) {
@@ -2920,7 +2919,7 @@ static void parse_get_mark(const char *p)
2919 if (*p != ':')
2920 die("Not a mark: %s", p);
2921
2923 - oe = find_mark(parse_mark_ref_eol(p));
2922 + oe = find_mark(marks, parse_mark_ref_eol(p));
2923 if (!oe)
2924 die("Unknown mark: %s", command_buf.buf);
2925
@@ -2935,7 +2934,7 @@ static void parse_cat_blob(const char *p)
2934
2935 /* cat-blob SP <object> LF */
2936 if (*p == ':') {
2938 - oe = find_mark(parse_mark_ref_eol(p));
2937 + oe = find_mark(marks, parse_mark_ref_eol(p));
2938 if (!oe)
2939 die("Unknown mark: %s", command_buf.buf);
2940 oidcpy(&oid, &oe->idx.oid);
@@ -3010,7 +3009,7 @@ static struct object_entry *parse_treeish_dataref(const char **p)
3009 struct object_entry *e;
3010
3011 if (**p == ':') { /* <mark> */
3013 - e = find_mark(parse_mark_ref_space(p));
3012 + e = find_mark(marks, parse_mark_ref_space(p));
3013 if (!e)
3014 die("Unknown mark: %s", command_buf.buf);
3015 oidcpy(&oid, &e->idx.oid);