forked from Mirrors/flatpak-builder
git: Always deep clone for old git versions if bundling sources
If we're bundling sources we really need to fetch from them because we want to bundle shallow clones. However, this doesn't work for older git versions, so pre-emptively fetch those deeply. Closes: #62 Approved by: alexlarssontingping/wmclass
parent
25805d5220
commit
784328e397
|
@ -349,10 +349,8 @@ git_mirror_submodules (const char *repo_location,
|
|||
g_autofree gchar *gitmodules = g_strconcat (revision, ":.gitmodules", NULL);
|
||||
gsize num_submodules;
|
||||
|
||||
/* Older versions of git can't fetch from shallow repos, so always clone submodule
|
||||
repos deeply so git submodule update works */
|
||||
if (!git_version_supports_fetch_from_shallow ())
|
||||
flags |= FLATPAK_GIT_MIRROR_FLAGS_DISABLE_SHALLOW;
|
||||
/* The submodule update will fetch from this repo */
|
||||
flags |= FLATPAK_GIT_MIRROR_FLAGS_WILL_FETCH_FROM;
|
||||
|
||||
if (!git (mirror_dir, &rev_parse_output, 0, NULL, "rev-parse", "--verify", "--quiet", gitmodules, NULL))
|
||||
return TRUE;
|
||||
|
@ -493,7 +491,16 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
if (!created && !was_shallow)
|
||||
do_disable_shallow = TRUE;
|
||||
|
||||
if (update || !already_exists)
|
||||
/* Older versions of git can't fetch from shallow repos, so for
|
||||
those, always clone deeply anything we will later fetch from.
|
||||
(This is typically submodules and regular repos if we're bundling
|
||||
sources) */
|
||||
if ((flags & FLATPAK_GIT_MIRROR_FLAGS_WILL_FETCH_FROM) != 0 &&
|
||||
!git_version_supports_fetch_from_shallow ())
|
||||
{
|
||||
do_disable_shallow = TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
g_autofree char *full_ref = NULL;
|
||||
g_autoptr(GFile) cached_git_dir = NULL;
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef enum {
|
|||
FLATPAK_GIT_MIRROR_FLAGS_MIRROR_SUBMODULES = 1 << 1,
|
||||
FLATPAK_GIT_MIRROR_FLAGS_DISABLE_FSCK = 1 << 2,
|
||||
FLATPAK_GIT_MIRROR_FLAGS_DISABLE_SHALLOW = 1 << 3,
|
||||
FLATPAK_GIT_MIRROR_FLAGS_WILL_FETCH_FROM = 1 << 4,
|
||||
} FlatpakGitMirrorFlags;
|
||||
|
||||
gboolean builder_git_mirror_repo (const char *repo_location,
|
||||
|
|
|
@ -242,6 +242,8 @@ builder_source_git_download (BuilderSource *source,
|
|||
flags |= FLATPAK_GIT_MIRROR_FLAGS_DISABLE_FSCK;
|
||||
if (self->disable_shallow_clone)
|
||||
flags |= FLATPAK_GIT_MIRROR_FLAGS_DISABLE_SHALLOW;
|
||||
if (builder_context_get_bundle_sources (context))
|
||||
flags |= FLATPAK_GIT_MIRROR_FLAGS_WILL_FETCH_FROM;
|
||||
|
||||
if (!builder_git_mirror_repo (location, NULL, flags,
|
||||
get_branch (self),
|
||||
|
|
Loading…
Reference in New Issue