path: root/builtin/prune.c
diff options
authorJeff King <>2015-06-23 10:54:11 (GMT)
committerJunio C Hamano <>2015-06-25 00:09:35 (GMT)
commit067fbd4105c5aa8260a73cc6961854be0e93fa03 (patch)
tree302bb72cb8414580c24bd4d896bc4879e31b8a66 /builtin/prune.c
parent00a09d57eb8a041e6a6b0470c53533719c049bab (diff)
introduce "preciousObjects" repository extension
If this extension is used in a repository, then no operations should run which may drop objects from the object storage. This can be useful if you are sharing that storage with other repositories whose refs you cannot see. For instance, if you do: $ git clone -s parent child $ git -C parent config extensions.preciousObjects true $ git -C parent config core.repositoryformatversion 1 you now have additional safety when running git in the parent repository. Prunes and repacks will bail with an error, and `git gc` will skip those operations (it will continue to pack refs and do other non-object operations). Older versions of git, when run in the repository, will fail on every operation. Note that we do not set the preciousObjects extension by default when doing a "clone -s", as doing so breaks backwards compatibility. It is a decision the user should make explicitly. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/prune.c')
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin/prune.c b/builtin/prune.c
index 0c73246..6a58e75 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -218,6 +218,9 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
return 0;
+ if (repository_format_precious_objects)
+ die(_("cannot prune in a precious-objects repo"));
while (argc--) {
unsigned char sha1[20];
const char *name = *argv++;