Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/libostree/ostree-mutable-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ struct OstreeMutableTree
{
GObject parent_instance;

/* This is the checksum of the Dirtree object that corresponds to the current
* contents of this directory. contents_checksum can be NULL if the SHA was
* never calculated or contents of the mtree has been modified. Even if
* contents_checksum is not NULL it may be out of date. */
char *contents_checksum;

/* This is the checksum of the DirMeta object that holds the uid, gid, mode
* and xattrs of this directory. This can be NULL. */
char *metadata_checksum;

/* const char* filename -> const char* checksum */
GHashTable *files;

/* const char* filename -> OstreeMutableTree* subtree */
GHashTable *subdirs;
};

Expand Down Expand Up @@ -176,6 +186,16 @@ ostree_mutable_tree_replace_file (OstreeMutableTree *self,
return ret;
}

/**
* ostree_mutable_tree_ensure_dir:
* @self: Tree
* @name: Name of subdirectory of self to retrieve/creates
* @out_subdir: (out) (transfer full): the subdirectory
* @error: a #GError
*
* Returns the subdirectory of self with filename @name, creating an empty one
* it if it doesn't exist.
*/
gboolean
ostree_mutable_tree_ensure_dir (OstreeMutableTree *self,
const char *name,
Expand Down
48 changes: 48 additions & 0 deletions tests/basic-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,54 @@ $OSTREE checkout test3-combined checkout-test3-combined
assert_has_file checkout-test3-combined/file-a
assert_has_file checkout-test3-combined/file-b

mkdir -p tree-C/usr/share tree-C/usr/bin tree-C/etc tree-D/etc

echo exe >tree-C/usr/bin/exe
echo sudoers1 >tree-C/etc/sudoers
echo mtab >tree-C/etc/mtab

echo sudoers2 >tree-D/etc/sudoers

$OSTREE commit ${COMMIT_ARGS} -b test3-C1 --tree=dir=tree-C
$OSTREE commit ${COMMIT_ARGS} -b test3-D --tree=dir=tree-D

echo sudoers2 >tree-C/etc/sudoers
$OSTREE commit ${COMMIT_ARGS} -b test3-C2 --tree=dir=tree-C
echo sudoers1 >tree-C/etc/sudoers

$OSTREE commit ${COMMIT_ARGS} -b test3-ref-ref --tree=ref=test3-C1 --tree=ref=test3-D
$OSTREE commit ${COMMIT_ARGS} -b test3-dir-ref --tree=dir=tree-C --tree=ref=test3-D
$OSTREE commit ${COMMIT_ARGS} -b test3-ref-dir --tree=ref=test3-C1 --tree=dir=tree-D
$OSTREE commit ${COMMIT_ARGS} -b test3-dir-dir --tree=dir=tree-C --tree=dir=tree-D

assert_trees_identical() {
$OSTREE diff "$1" "$2" > "diff-$1-$2"
cat "diff-$1-$2" 1>&2
assert_file_empty "diff-$1-$2"
rm "diff-$1-$2"
}

for x in ref dir
do
for y in ref dir
do
assert_trees_identical test3-C2 "test3-$x-$y"
done
done

# Regression test

mkdir -p tree-E/etc
mkdir -p tree-F/etc/apt/sources.list.d/
echo contents >tree-F/etc/apt/sources.list.d/universe.list

$OSTREE commit ${COMMIT_ARGS} -b test3-E --tree=dir=tree-E
$OSTREE commit ${COMMIT_ARGS} -b test3-F --tree=dir=tree-F

$OSTREE commit ${COMMIT_ARGS} -b test3-F2 --tree=ref=test3-E --tree=ref=test3-F

assert_trees_identical test3-F test3-F2

echo "ok commit combined ref trees"

# NB: The + is optional, but we need to make sure we support it
Expand Down