forked from Mirrors/flatpak-builder
git: Never do shallow pulls if we once had a deep one
This seems to break on old versions of git. For example: $ git --version git version 1.8.3.1 $ git clone --mirror https://github.com/divVerent/s2tc.git Cloning into bare repository 's2tc.git'... remote: Counting objects: 740, done. remote: Total 740 (delta 0), reused 0 (delta 0), pack-reused 740 Receiving objects: 100% (740/740), 1.47 MiB | 0 bytes/s, done. Resolving deltas: 100% (493/493), done. $ cd s2tc.git/ $ git fetch -p --no-recurse-submodules --no-tags --depth=1 -f origin '+HEAD:HEAD' fatal: git fetch-pack: expected shallow list Closes: #55 Approved by: alexlarssontingping/wmclass
parent
17f659ee71
commit
a39f727adf
|
@ -325,7 +325,9 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
g_autofree char *current_commit = NULL;
|
||||
g_autoptr(GHashTable) refs = NULL;
|
||||
gboolean already_exists = FALSE;
|
||||
gboolean created = FALSE;
|
||||
gboolean was_shallow = FALSE;
|
||||
gboolean do_disable_shallow = FALSE;
|
||||
|
||||
cache_mirror_dir = git_get_mirror_dir (repo_location, context);
|
||||
|
||||
|
@ -351,6 +353,8 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
"remote", "add", "--mirror=fetch", "origin",
|
||||
repo_location, NULL))
|
||||
return FALSE;
|
||||
|
||||
created = TRUE;
|
||||
}
|
||||
|
||||
shallow_file = g_file_get_child (mirror_dir, "shallow");
|
||||
|
@ -361,6 +365,13 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
"cat-file", "-e", ref, NULL))
|
||||
already_exists = TRUE;
|
||||
|
||||
do_disable_shallow = disable_shallow;
|
||||
|
||||
/* If we ever pulled non-shallow, then keep doing so, because
|
||||
otherwise old git clients break */
|
||||
if (!created && !was_shallow)
|
||||
do_disable_shallow = TRUE;
|
||||
|
||||
if (update || !already_exists)
|
||||
{
|
||||
g_autofree char *full_ref = NULL;
|
||||
|
@ -402,7 +413,7 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
"config", "transfer.fsckObjects", disable_fsck ? "0" : "1", NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!disable_shallow)
|
||||
if (!do_disable_shallow)
|
||||
full_ref = lookup_full_ref (refs, ref);
|
||||
if (full_ref)
|
||||
{
|
||||
|
@ -430,7 +441,7 @@ builder_git_mirror_repo (const char *repo_location,
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
else if (!already_exists || disable_shallow)
|
||||
else if (!already_exists || do_disable_shallow)
|
||||
/* We don't fetch everything if it already exists (and we're not disabling shallow), because
|
||||
since it failed to resolve to full_ref it is a commit id
|
||||
which can't change and thus need no updates */
|
||||
|
|
Loading…
Reference in New Issue