Skip to content

Commit

Permalink
checkout: Always replace existing content
Browse files Browse the repository at this point in the history
The combination of the "honor whiteout" and "union" flags
are intended to basically be "merge trees like overlayfs does".
But we were missing this case in order to support e.g. replacing
a symlink with a directory.
  • Loading branch information
cgwalters committed Mar 13, 2024
1 parent 223a1af commit ba1e9b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libostree/ostree-repo-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,16 @@ checkout_tree_at_recurse (OstreeRepo *self, OstreeRepoCheckoutAtOptions *options
contents_csum_v = NULL; /* iter_loop freed it */
}

/* In this mode, we're flattening in a manner similar to overlayfs, so ensure
* any content that was there before is gone.
*/
if (!is_opaque_whiteout && options->process_whiteouts
&& options->overwrite_mode == OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES)
{
if (!glnx_shutil_rm_rf_at (destination_parent_fd, destination_name, NULL, error))
return FALSE;
}

/* First, make the directory. Push a new scope in case we end up using
* setfscreatecon().
*/
Expand Down
8 changes: 8 additions & 0 deletions tests/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,14 @@ if touch overlay/baz/.wh.cow && touch overlay/.wh.deeper && touch overlay/baz/an
assert_has_file overlay-co/baz
test -L overlay-co/anewdir

rm overlay-co overlay -rf
mkdir -p overlay/somelink
$OSTREE --repo=repo commit ${COMMIT_ARGS} -b overlay-symlink-convert --tree=dir=overlay
for branch in test2 overlay-symlink-convert; do
$OSTREE --repo=repo checkout --union --whiteouts ${branch} overlay-co
done
test -d overlay-co/somelink || fatal "should replace symlink with dir"
rm overlay-co overlay -rf
echo "ok whiteouts enabled"

# Now double check whiteouts are not processed without --whiteouts
Expand Down

0 comments on commit ba1e9b1

Please sign in to comment.