SYNOPSIS
--------
-'git-prune' [-n] [--grace=<time>]
+'git-prune' [-n] [--] [<head>...]
DESCRIPTION
-----------
Do not remove anything; just report what it would
remove.
---grace=<time>::
- Do not prune loose objects that are younger than the
- specified time. This gives a grace period to newly
- created objects from getting pruned.
-
-////////////////////////////////////////////
\--::
Do not interpret any more arguments as options.
------------
$ git prune $(cd ../another && $(git-rev-parse --all))
------------
-////////////////////////////////////////////
Author
------
#include "builtin.h"
#include "reachable.h"
-static const char prune_usage[] = "git-prune [-n] [--grace=time]";
+static const char prune_usage[] = "git-prune [-n]";
static int show_only;
-static int prune_grace_period;
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
{
char name[100];
unsigned char sha1[20];
int len = strlen(de->d_name);
- struct stat st;
switch (len) {
case 2:
if (lookup_object(sha1))
continue;
- if (prune_grace_period > 0 &&
- !stat(mkpath("%s/%s", path, de->d_name), &st) &&
- st.st_mtime > prune_grace_period)
- continue;
-
prune_object(path, de->d_name, sha1);
continue;
}
}
}
-static int git_prune_config(const char *var, const char *value)
-{
- if (!strcmp(var, "gc.prunegrace")) {
- if (!strcmp(value, "off"))
- prune_grace_period = 0;
- else
- prune_grace_period = approxidate(value);
- return 0;
- }
- return git_default_config(var, value);
-}
-
int cmd_prune(int argc, const char **argv, const char *prefix)
{
int i;
struct rev_info revs;
- prune_grace_period = time(NULL)-24*60*60;
-
- git_config(git_prune_config);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
show_only = 1;
continue;
}
- if (!strncmp(arg, "--grace=", 8)) {
- if (!strcmp(arg+8, "off"))
- prune_grace_period = 0;
- else
- prune_grace_period = approxidate(arg+8);
- continue;
- }
usage(prune_usage);
}
check_have A B C D E F G H I J K L &&
- git prune --grace=off &&
+ git prune &&
check_have A B C D E F G H I J K L &&
check_have A B C D E F G H I J K L &&
- git prune --grace=off &&
+ git prune &&
check_have A B C D E F G H I J K L &&
test_expect_success 'prune and fsck' '
- git prune --grace=off &&
+ git prune &&
check_fsck &&
check_have A B C D E H L &&