Skip to content

Commit

Permalink
lib/refs: Ignore files starting with . in refs/
Browse files Browse the repository at this point in the history
Ignore any files that start with a `.` under the assumption they're metadata for
some other tool. This is a bit ugly as `.` *is* valid in refs, but I don't see
many people using that in the wild.

Closes: ostreedev#1285
  • Loading branch information
cgwalters committed Oct 18, 2017
1 parent 9955695 commit 0bd0294
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libostree/ostree-repo-refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ enumerate_refs_recurse (OstreeRepo *repo,
if (dent == NULL)
break;

/* https://github.com/ostreedev/ostree/issues/1285
* Ignore any files that start with a `.` under the assumption they're
* metadata for some other tool. This is a bit ugly as `.` *is* valid
* in refs, but I don't see many people using that in the wild.
**/
if (g_str_has_prefix (dent->d_name, "."))
continue;

g_string_append (base_path, dent->d_name);

if (dent->d_type == DT_DIR)
Expand Down
13 changes: 13 additions & 0 deletions tests/test-refs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ if ${CMD_PREFIX} ostree --repo=repo refs foo/ctest --create=ctest; then
assert_not_reached "refs --create unexpectedly succeeded in overwriting an existing prefix!"
fi

# https://github.com/ostreedev/ostree/issues/1285
# One tool was creating .latest_rsync files in each dir, let's ignore stuff like
# that.
echo '👻' > repo/refs/heads/.spooky_and_hidden
ostree --repo=repo refs > refs.txt
assert_not_file_has_content refs.txt 'spooky'
${CMD_PREFIX} ostree --repo=repo refs ctest --create=exampleos/x86_64/standard
echo '👻' > repo/refs/heads/exampleos/x86_64/.further_spooky_and_hidden
ostree --repo=repo refs > refs.txt
assert_file_has_content refs.txt 'exampleos/x86_64/standard'
assert_not_file_has_content refs.txt 'spooky'
rm repo/refs/heads/exampleos -rf

#Check to see if any uncleaned tmp files were created after failed --create
${CMD_PREFIX} ostree --repo=repo refs | wc -l > refscount.create1
assert_file_has_content refscount.create1 "^5$"
Expand Down

0 comments on commit 0bd0294

Please sign in to comment.