Skip to content

Commit

Permalink
squash! pull: Fix local pull with depth and truncated source history
Browse files Browse the repository at this point in the history
factor out tombstone handline for missing parent commit
  • Loading branch information
dbnicholson committed Jan 12, 2021
1 parent fb1046f commit f42c7d0
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions src/libostree/ostree-repo-pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,32 @@ is_parent_commit (OtPullData *pull_data,
return g_hash_table_contains (pull_data->commit_to_depth, checksum);
}

static gboolean
try_missing_parent_tombstone (OtPullData *pull_data,
FetchObjectData *fetch_data,
const char *checksum,
GCancellable *cancellable,
GError **error)
{
/* If the remote repo supports tombstone commits, check if the commit
* was intentionally deleted.
*/
if (!pull_data->has_tombstone_commits)
return TRUE;

if (pull_data->remote_repo_local)
return _ostree_repo_import_object (pull_data->repo, pull_data->remote_repo_local,
OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
checksum, pull_data->importflags,
cancellable, error);
else
{
enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
fetch_data->path, FALSE, FALSE, NULL);
return TRUE;
}
}

static void
meta_fetch_on_complete (GObject *object,
GAsyncResult *result,
Expand Down Expand Up @@ -1167,20 +1193,16 @@ meta_fetch_on_complete (GObject *object,
}

/* When traversing parents, do not fail on a missing commit.
* We may be pulling from a partial repository that ends in
* a dangling parent reference. */
* We may be pulling from a partial repository that ends in a
* dangling parent reference. This logic should match the
* local case in scan_one_metadata_object.
*/
else if (objtype == OSTREE_OBJECT_TYPE_COMMIT &&
pull_data->maxdepth != 0 &&
is_parent_commit (pull_data, checksum))
{
g_clear_error (&local_error);
/* If the remote repo supports tombstone commits, check if the commit was intentionally
deleted. */
if (pull_data->has_tombstone_commits)
{
enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
fetch_data->path, FALSE, FALSE, NULL);
}
try_missing_parent_tombstone (pull_data, fetch_data, checksum, NULL, NULL);
}
}

Expand Down Expand Up @@ -1827,29 +1849,19 @@ scan_one_metadata_object (OtPullData *pull_data,
{
/* When traversing parents, do not fail on a missing commit.
* We may be pulling from a partial repository that ends in a
* dangling parent reference.
* dangling parent reference. This logic should match the
* remote case in meta_fetch_on_complete.
*
* Note early return.
*/
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
objtype == OSTREE_OBJECT_TYPE_COMMIT &&
pull_data->maxdepth != 0 &&
is_parent_commit (pull_data, checksum))
{
g_clear_error (&local_error);

/* If the remote repo supports tombstone commits, check if
* the commit was intentionally deleted.
*/
if (pull_data->has_tombstone_commits)
{
if (!_ostree_repo_import_object (pull_data->repo, pull_data->remote_repo_local,
OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
checksum, pull_data->importflags,
cancellable, error))
return FALSE;
}

/* Note early return */
return TRUE;
return try_missing_parent_tombstone (pull_data, NULL, checksum,
cancellable, error);
}
else
{
Expand Down

0 comments on commit f42c7d0

Please sign in to comment.