struct repository *repo;
int result;
const char *path;
+ const struct object_id *super_oid;
};
static int check_has_commit(const struct object_id *oid, void *data)
struct repository subrepo;
enum object_type type;
- if (repo_submodule_init(&subrepo, cb->repo, cb->path, null_oid())) {
+ if (repo_submodule_init(&subrepo, cb->repo, cb->path, cb->super_oid)) {
cb->result = 0;
goto cleanup;
}
static int submodule_has_commits(struct repository *r,
const char *path,
+ const struct object_id *super_oid,
struct oid_array *commits)
{
- struct has_commit_data has_commit = { r, 1, path };
+ struct has_commit_data has_commit = {
+ .repo = r,
+ .result = 1,
+ .path = path,
+ .super_oid = super_oid
+ };
/*
* Perform a cheap, but incorrect check for the existence of 'commits'.
const char *path,
struct oid_array *commits)
{
- if (!submodule_has_commits(r, path, commits))
+ if (!submodule_has_commits(r, path, null_oid(), commits))
/*
* NOTE: We do consider it safe to return "no" here. The
* correct answer would be "We do not know" instead of
if (!path)
continue;
- if (submodule_has_commits(r, path, commits)) {
+ if (submodule_has_commits(r, path, null_oid(), commits)) {
oid_array_clear(commits);
*name->string = '\0';
}
}
static struct fetch_task *fetch_task_create(struct repository *r,
- const char *path)
+ const char *path,
+ const struct object_id *treeish_name)
{
struct fetch_task *task = xmalloc(sizeof(*task));
memset(task, 0, sizeof(*task));
- task->sub = submodule_from_path(r, null_oid(), path);
+ task->sub = submodule_from_path(r, treeish_name, path);
if (!task->sub) {
/*
* No entry in .gitmodules? Technically not a submodule,
}
static struct repository *get_submodule_repo_for(struct repository *r,
- const char *path)
+ const char *path,
+ const struct object_id *treeish_name)
{
struct repository *ret = xmalloc(sizeof(*ret));
- if (repo_submodule_init(ret, r, path, null_oid())) {
+ if (repo_submodule_init(ret, r, path, treeish_name)) {
free(ret);
return NULL;
}
if (!S_ISGITLINK(ce->ce_mode))
continue;
- task = fetch_task_create(spf->r, ce->name);
+ task = fetch_task_create(spf->r, ce->name, null_oid());
if (!task)
continue;
continue;
}
- task->repo = get_submodule_repo_for(spf->r, task->sub->path);
+ task->repo = get_submodule_repo_for(spf->r, task->sub->path, null_oid());
if (task->repo) {
struct strbuf submodule_prefix = STRBUF_INIT;
child_process_init(cp);