Skip to content

Commit a74093d

Browse files
stefanbellergitster
authored andcommitted
tag: add repository argument to deref_tag
Add a repository argument to allow the callers of deref_tag to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e740fe commit a74093d

18 files changed

+42
-26
lines changed

blame.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ static struct commit *find_single_final(struct rev_info *revs,
16741674
struct object *obj = revs->pending.objects[i].item;
16751675
if (obj->flags & UNINTERESTING)
16761676
continue;
1677-
obj = deref_tag(obj, NULL, 0);
1677+
obj = deref_tag(the_repository, obj, NULL, 0);
16781678
if (obj->type != OBJ_COMMIT)
16791679
die("Non commit %s?", revs->pending.objects[i].name);
16801680
if (found)
@@ -1705,7 +1705,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
17051705

17061706
/* Is that sole rev a committish? */
17071707
obj = revs->pending.objects[0].item;
1708-
obj = deref_tag(obj, NULL, 0);
1708+
obj = deref_tag(the_repository, obj, NULL, 0);
17091709
if (obj->type != OBJ_COMMIT)
17101710
return NULL;
17111711

@@ -1741,7 +1741,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
17411741
struct object *obj = revs->pending.objects[i].item;
17421742
if (!(obj->flags & UNINTERESTING))
17431743
continue;
1744-
obj = deref_tag(obj, NULL, 0);
1744+
obj = deref_tag(the_repository, obj, NULL, 0);
17451745
if (obj->type != OBJ_COMMIT)
17461746
die("Non commit %s?", revs->pending.objects[i].name);
17471747
if (found)

builtin/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
402402
int flags = (obj->flags & UNINTERESTING);
403403
if (!obj->parsed)
404404
obj = parse_object(the_repository, &obj->oid);
405-
obj = deref_tag(obj, NULL, 0);
405+
obj = deref_tag(the_repository, obj, NULL, 0);
406406
if (!obj)
407407
die(_("invalid object '%s' given."), name);
408408
if (obj->type == OBJ_COMMIT)

builtin/fmt-merge-msg.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ static void shortlog(const char *name,
344344
const struct object_id *oid = &origin_data->oid;
345345
int limit = opts->shortlog_len;
346346

347-
branch = deref_tag(parse_object(the_repository, oid), oid_to_hex(oid),
347+
branch = deref_tag(the_repository, parse_object(the_repository, oid),
348+
oid_to_hex(oid),
348349
GIT_SHA1_HEXSZ);
349350
if (!branch || branch->type != OBJ_COMMIT)
350351
return;

builtin/grep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
647647

648648
for (i = 0; i < nr; i++) {
649649
struct object *real_obj;
650-
real_obj = deref_tag(list->objects[i].item, NULL, 0);
650+
real_obj = deref_tag(the_repository, list->objects[i].item,
651+
NULL, 0);
651652

652653
/* load the gitmodules file for this rev */
653654
if (recurse_submodules) {

builtin/name-rev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
455455
commit = NULL;
456456
object = parse_object(the_repository, &oid);
457457
if (object) {
458-
struct object *peeled = deref_tag(object, *argv, 0);
458+
struct object *peeled = deref_tag(the_repository,
459+
object, *argv, 0);
459460
if (peeled && peeled->type == OBJ_COMMIT)
460461
commit = (struct commit *)peeled;
461462
}

commit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const char *commit_type = "commit";
2727
struct commit *lookup_commit_reference_gently_the_repository(
2828
const struct object_id *oid, int quiet)
2929
{
30-
struct object *obj = deref_tag(parse_object(the_repository, oid),
30+
struct object *obj = deref_tag(the_repository,
31+
parse_object(the_repository, oid),
3132
NULL, 0);
3233

3334
if (!obj)

fetch-pack.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)
126126

127127
static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
128128
{
129-
struct object *o = deref_tag(parse_object(the_repository, oid),
129+
struct object *o = deref_tag(the_repository,
130+
parse_object(the_repository, oid),
130131
refname, 0);
131132

132133
if (o && o->type == OBJ_COMMIT)
@@ -144,7 +145,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *
144145
static int clear_marks(const char *refname, const struct object_id *oid,
145146
int flag, void *cb_data)
146147
{
147-
struct object *o = deref_tag(parse_object(the_repository, oid),
148+
struct object *o = deref_tag(the_repository,
149+
parse_object(the_repository, oid),
148150
refname, 0);
149151

150152
if (o && o->type == OBJ_COMMIT)
@@ -802,7 +804,8 @@ static int everything_local(struct fetch_pack_args *args,
802804
* Don't mark them common yet; the server has to be told so first.
803805
*/
804806
for (ref = *refs; ref; ref = ref->next) {
805-
struct object *o = deref_tag(lookup_object(the_repository,
807+
struct object *o = deref_tag(the_repository,
808+
lookup_object(the_repository,
806809
ref->old_oid.hash),
807810
NULL, 0);
808811

http-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,
442442

443443
strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
444444
if (o->type == OBJ_TAG) {
445-
o = deref_tag(o, name, 0);
445+
o = deref_tag(the_repository, o, name, 0);
446446
if (!o)
447447
return 0;
448448
strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid),

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
14771477
oid_to_hex(&ref->old_oid), ls->dentry_name);
14781478

14791479
if (o->type == OBJ_TAG) {
1480-
o = deref_tag(o, ls->dentry_name, 0);
1480+
o = deref_tag(the_repository, o, ls->dentry_name, 0);
14811481
if (o)
14821482
strbuf_addf(buf, "%s\t%s^{}\n",
14831483
oid_to_hex(&o->oid), ls->dentry_name);

line-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
479479
struct object *obj = revs->pending.objects[i].item;
480480
if (obj->flags & UNINTERESTING)
481481
continue;
482-
obj = deref_tag(obj, NULL, 0);
482+
obj = deref_tag(the_repository, obj, NULL, 0);
483483
if (obj->type != OBJ_COMMIT)
484484
die("Non commit %s?", revs->pending.objects[i].name);
485485
if (commit)

0 commit comments

Comments
 (0)