repository: repo_submodule_init to take a submodule struct
When constructing a struct repository for a submodule for some revision of the superproject where the submodule is not contained in the index, it may not be present in the working tree currently either. In that situation giving a 'path' argument is not useful. Upgrade the repo_submodule_init function to take a struct submodule instead. The submodule struct can be obtained via submodule_from_{path, name} or an artificial submodule struct can be passed in. While we are at it, rename the repository struct in the repo_submodule_init function, which is to be initialized, to a name that is not confused with the struct submodule as easily. Perform such renames in similar functions as well. Also move its documentation into the header file. Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
bcd7337243
commit
d5498e0871
@ -206,17 +206,19 @@ static void show_files(struct repository *repo, struct dir_struct *dir);
|
||||
static void show_submodule(struct repository *superproject,
|
||||
struct dir_struct *dir, const char *path)
|
||||
{
|
||||
struct repository submodule;
|
||||
struct repository subrepo;
|
||||
const struct submodule *sub = submodule_from_path(superproject,
|
||||
&null_oid, path);
|
||||
|
||||
if (repo_submodule_init(&submodule, superproject, path))
|
||||
if (repo_submodule_init(&subrepo, superproject, sub))
|
||||
return;
|
||||
|
||||
if (repo_read_index(&submodule) < 0)
|
||||
if (repo_read_index(&subrepo) < 0)
|
||||
die("index file corrupt");
|
||||
|
||||
show_files(&submodule, dir);
|
||||
show_files(&subrepo, dir);
|
||||
|
||||
repo_clear(&submodule);
|
||||
repo_clear(&subrepo);
|
||||
}
|
||||
|
||||
static void show_ce(struct repository *repo, struct dir_struct *dir,
|
||||
|
Reference in New Issue
Block a user