prune: Error if --static-deltas-only without --delete-commit

The original changes here apparently had the *idea* that `--static-deltas-only`
would be useful in general, but we never implemented that.  The current
situation where it's ignored unless `--delete-commit` is specified is
very misleading and I can easily see it leading to data loss for people.

Let's error out until we have a chance to make it actually useful.

Related: https://github.com/ostreedev/ostree/issues/1479

Closes: #1482
Approved by: giuseppe
This commit is contained in:
Colin Walters 2018-03-05 10:42:19 -05:00 committed by Atomic Bot
parent 733c0498dc
commit 79d6f635df
2 changed files with 13 additions and 3 deletions

View File

@ -174,6 +174,15 @@ ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation
else if (!delete_commit (repo, opt_delete_commit, cancellable, error)) else if (!delete_commit (repo, opt_delete_commit, cancellable, error))
return FALSE; return FALSE;
} }
else
{
/* In the future we should make this useful, but for now let's
* error out since what we were doing before was very misleading.
* https://github.com/ostreedev/ostree/issues/1479
*/
if (opt_static_deltas_only)
return glnx_throw (error, "--static-deltas-only requires --delete-commit; see https://github.com/ostreedev/ostree/issues/1479");
}
OstreeRepoPruneFlags pruneflags = 0; OstreeRepoPruneFlags pruneflags = 0;
if (opt_refs_only) if (opt_refs_only)

View File

@ -141,9 +141,10 @@ assert_file_has_content deltascount "^1$"
${CMD_PREFIX} ostree --repo=repo static-delta generate test ${CMD_PREFIX} ostree --repo=repo static-delta generate test
${CMD_PREFIX} ostree --repo=repo static-delta list | wc -l > deltascount ${CMD_PREFIX} ostree --repo=repo static-delta list | wc -l > deltascount
assert_file_has_content deltascount "^2$" assert_file_has_content deltascount "^2$"
${CMD_PREFIX} ostree --repo=repo prune --static-deltas-only --keep-younger-than="October 20 2015" if ${CMD_PREFIX} ostree --repo=repo prune --static-deltas-only --keep-younger-than="October 20 2015" 2>err.txt; then
${CMD_PREFIX} ostree --repo=repo static-delta list | wc -l > deltascount fatal "pruned deltas only"
assert_file_has_content deltascount "^1$" fi
assert_file_has_content_literal err.txt "--static-deltas-only requires --delete-commit"
echo "ok prune" echo "ok prune"