lib/commit: Honor commit filter for libarchive --tar-autocreate-parents
authorColin Walters <walters@verbum.org>
Wed, 23 Aug 2017 14:09:44 +0000 (10:09 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 23 Aug 2017 14:48:12 +0000 (14:48 +0000)
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

src/libostree/ostree-repo-libarchive.c
tests/test-libarchive.sh

index 1839a088182bea3d500b31d169d0b6681e5baf3a..8d9e8969b5df922d1e4595557ef00c113939398d 100644 (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::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))
         goto out;
     }
index 6540b94b6715b8b8cc82099e0bfd7932acf29b19..6653fa6af13cd53fbb783fbabbd99ed9a8c21b9e 100755 (executable)
@@ -26,7 +26,7 @@ fi
 
 . $(dirname $0)/libtest.sh
 
-echo "1..20"
+echo "1..21"
 
 setup_test_repository "bare"
 
@@ -154,3 +154,13 @@ $OSTREE checkout partial partial-checkout
 cd partial-checkout
 assert_file_has_content subdir/original "original"
 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"