Skip to content

Commit 1eb0a12

Browse files
committed
Merge branch 'nd/tree-walk-with-repo'
The tree-walk API learned to pass an in-core repository instance throughout more codepaths. * nd/tree-walk-with-repo: t7814: do not generate same commits in different repos Use the right 'struct repository' instead of the_repository match-trees.c: remove the_repo from shift_tree*() tree-walk.c: remove the_repo from get_tree_entry_follow_symlinks() tree-walk.c: remove the_repo from get_tree_entry() tree-walk.c: remove the_repo from fill_tree_descriptor() sha1-file.c: remove the_repo from read_object_with_reference()
2 parents d97c62c + 663d250 commit 1eb0a12

26 files changed

+146
-98
lines changed

archive.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ static void parse_treeish_arg(const char **argv,
418418
unsigned short mode;
419419
int err;
420420

421-
err = get_tree_entry(&tree->object.oid, prefix, &tree_oid,
421+
err = get_tree_entry(ar_args->repo,
422+
&tree->object.oid,
423+
prefix, &tree_oid,
422424
&mode);
423425
if (err || !S_ISDIR(mode))
424426
die(_("current working directory is untracked"));

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void verify_working_tree_path(struct repository *r,
101101
struct object_id blob_oid;
102102
unsigned short mode;
103103

104-
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
104+
if (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&
105105
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
106106
return;
107107
}
@@ -1232,7 +1232,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
12321232
{
12331233
if (!is_null_oid(&origin->blob_oid))
12341234
return 0;
1235-
if (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
1235+
if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
12361236
goto error_out;
12371237
if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
12381238
goto error_out;

builtin/cat-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
172172
* fall-back to the usual case.
173173
*/
174174
}
175-
buf = read_object_with_reference(&oid, exp_type, &size, NULL);
175+
buf = read_object_with_reference(the_repository,
176+
&oid, exp_type, &size, NULL);
176177
break;
177178

178179
default:

builtin/grep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ static int grep_submodule(struct grep_opt *opt,
458458
object = parse_object_or_die(oid, oid_to_hex(oid));
459459

460460
grep_read_lock();
461-
data = read_object_with_reference(&object->oid, tree_type,
461+
data = read_object_with_reference(&subrepo,
462+
&object->oid, tree_type,
462463
&size, NULL);
463464
grep_read_unlock();
464465

@@ -623,7 +624,8 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
623624
int hit, len;
624625

625626
grep_read_lock();
626-
data = read_object_with_reference(&obj->oid, tree_type,
627+
data = read_object_with_reference(opt->repo,
628+
&obj->oid, tree_type,
627629
&size, NULL);
628630
grep_read_unlock();
629631

builtin/merge-tree.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void resolve(const struct traverse_info *info, struct name_entry *ours, s
205205
static void unresolved_directory(const struct traverse_info *info,
206206
struct name_entry n[3])
207207
{
208+
struct repository *r = the_repository;
208209
char *newbase;
209210
struct name_entry *p;
210211
struct tree_desc t[3];
@@ -220,9 +221,9 @@ static void unresolved_directory(const struct traverse_info *info,
220221
newbase = traverse_path(info, p);
221222

222223
#define ENTRY_OID(e) (((e)->mode && S_ISDIR((e)->mode)) ? &(e)->oid : NULL)
223-
buf0 = fill_tree_descriptor(t + 0, ENTRY_OID(n + 0));
224-
buf1 = fill_tree_descriptor(t + 1, ENTRY_OID(n + 1));
225-
buf2 = fill_tree_descriptor(t + 2, ENTRY_OID(n + 2));
224+
buf0 = fill_tree_descriptor(r, t + 0, ENTRY_OID(n + 0));
225+
buf1 = fill_tree_descriptor(r, t + 1, ENTRY_OID(n + 1));
226+
buf2 = fill_tree_descriptor(r, t + 2, ENTRY_OID(n + 2));
226227
#undef ENTRY_OID
227228

228229
merge_trees(t, newbase);
@@ -351,30 +352,33 @@ static void merge_trees(struct tree_desc t[3], const char *base)
351352
traverse_trees(&the_index, 3, t, &info);
352353
}
353354

354-
static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
355+
static void *get_tree_descriptor(struct repository *r,
356+
struct tree_desc *desc,
357+
const char *rev)
355358
{
356359
struct object_id oid;
357360
void *buf;
358361

359-
if (get_oid(rev, &oid))
362+
if (repo_get_oid(r, rev, &oid))
360363
die("unknown rev %s", rev);
361-
buf = fill_tree_descriptor(desc, &oid);
364+
buf = fill_tree_descriptor(r, desc, &oid);
362365
if (!buf)
363366
die("%s is not a tree", rev);
364367
return buf;
365368
}
366369

367370
int cmd_merge_tree(int argc, const char **argv, const char *prefix)
368371
{
372+
struct repository *r = the_repository;
369373
struct tree_desc t[3];
370374
void *buf1, *buf2, *buf3;
371375

372376
if (argc != 4)
373377
usage(merge_tree_usage);
374378

375-
buf1 = get_tree_descriptor(t+0, argv[1]);
376-
buf2 = get_tree_descriptor(t+1, argv[2]);
377-
buf3 = get_tree_descriptor(t+2, argv[3]);
379+
buf1 = get_tree_descriptor(r, t+0, argv[1]);
380+
buf2 = get_tree_descriptor(r, t+1, argv[2]);
381+
buf3 = get_tree_descriptor(r, t+2, argv[3]);
378382
merge_trees(t, "");
379383
free(buf1);
380384
free(buf2);

builtin/pack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,8 @@ static void add_preferred_base(struct object_id *oid)
14281428
if (window <= num_preferred_base++)
14291429
return;
14301430

1431-
data = read_object_with_reference(oid, tree_type, &size, &tree_oid);
1431+
data = read_object_with_reference(the_repository, oid,
1432+
tree_type, &size, &tree_oid);
14321433
if (!data)
14331434
return;
14341435

builtin/rebase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,13 +850,13 @@ static int reset_head(struct object_id *oid, const char *action,
850850
goto leave_reset_head;
851851
}
852852

853-
if (!reset_hard && !fill_tree_descriptor(&desc[nr++], &head_oid)) {
853+
if (!reset_hard && !fill_tree_descriptor(the_repository, &desc[nr++], &head_oid)) {
854854
ret = error(_("failed to find tree of %s"),
855855
oid_to_hex(&head_oid));
856856
goto leave_reset_head;
857857
}
858858

859-
if (!fill_tree_descriptor(&desc[nr++], oid)) {
859+
if (!fill_tree_descriptor(the_repository, &desc[nr++], oid)) {
860860
ret = error(_("failed to find tree of %s"), oid_to_hex(oid));
861861
goto leave_reset_head;
862862
}

builtin/reset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)
7979
struct object_id head_oid;
8080
if (get_oid("HEAD", &head_oid))
8181
return error(_("You do not have a valid HEAD."));
82-
if (!fill_tree_descriptor(desc + nr, &head_oid))
82+
if (!fill_tree_descriptor(the_repository, desc + nr, &head_oid))
8383
return error(_("Failed to find tree of HEAD."));
8484
nr++;
8585
opts.fn = twoway_merge;
8686
}
8787

88-
if (!fill_tree_descriptor(desc + nr, oid)) {
88+
if (!fill_tree_descriptor(the_repository, desc + nr, oid)) {
8989
error(_("Failed to find tree of %s."), oid_to_hex(oid));
9090
goto out;
9191
}

builtin/rm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int check_local_mod(struct object_id *head, int index_only)
179179
* way as changed from the HEAD.
180180
*/
181181
if (no_head
182-
|| get_tree_entry(head, name, &oid, &mode)
182+
|| get_tree_entry(the_repository, head, name, &oid, &mode)
183183
|| ce->ce_mode != create_ce_mode(mode)
184184
|| !oideq(&ce->oid, &oid))
185185
staged_changes = 1;

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static struct cache_entry *read_one_ent(const char *which,
601601
struct object_id oid;
602602
struct cache_entry *ce;
603603

604-
if (get_tree_entry(ent, path, &oid, &mode)) {
604+
if (get_tree_entry(the_repository, ent, path, &oid, &mode)) {
605605
if (which)
606606
error("%s: not in %s branch.", path, which);
607607
return NULL;

0 commit comments

Comments
 (0)