lib/commit: Honor commit filter for libarchive --tar-autocreate-parents

This makes `ostree commit --tree=tar` honor `--owner-uid` and `--owner-gid`
for the root directory.

Prep for further commit filtering work, although mostly for the unit test cases;
this ensures we can use `ostree checkout` after autocreating a root directory.

Closes: #1104
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-08-23 10:09:44 -04:00 committed by Atomic Bot
parent 556e2deb93
commit eb6f7c6db8
2 changed files with 16 additions and 2 deletions

View File

@ -861,7 +861,11 @@ ostree_repo_import_archive_to_mtree (OstreeRepo *self,
g_file_info_set_attribute_uint32 (fi, "unix::gid", 0); g_file_info_set_attribute_uint32 (fi, "unix::gid", 0);
g_file_info_set_attribute_uint32 (fi, "unix::mode", DEFAULT_DIRMODE); g_file_info_set_attribute_uint32 (fi, "unix::mode", DEFAULT_DIRMODE);
if (!aic_ensure_parent_dir_with_file_info (&aictx, mtree, "/", fi, NULL, g_autoptr(GFileInfo) mfi = NULL;
(void)_ostree_repo_commit_modifier_apply (self, modifier, "/",
fi, &mfi);
if (!aic_ensure_parent_dir_with_file_info (&aictx, mtree, "/", mfi, NULL,
cancellable, error)) cancellable, error))
goto out; goto out;
} }

View File

@ -26,7 +26,7 @@ fi
. $(dirname $0)/libtest.sh . $(dirname $0)/libtest.sh
echo "1..20" echo "1..21"
setup_test_repository "bare" setup_test_repository "bare"
@ -154,3 +154,13 @@ $OSTREE checkout partial partial-checkout
cd partial-checkout cd partial-checkout
assert_file_has_content subdir/original "original" assert_file_has_content subdir/original "original"
echo "ok tar partial commit contents" echo "ok tar partial commit contents"
cd ${test_tmpdir}
tar -cf empty.tar.gz -T /dev/null
uid=$(id -u)
gid=$(id -g)
$OSTREE commit -b tar-empty --tar-autocreate-parents \
--owner-uid=${uid} --owner-gid=${gid} --tree=tar=empty.tar.gz
$OSTREE ls tar-empty > ls.txt
assert_file_has_content ls.txt "d00755 ${uid} ${gid} 0 /"
echo "ok tar autocreate with owner uid/gid"