diff options
-rw-r--r-- | Documentation/config.txt | 9 | ||||
-rw-r--r-- | Documentation/git-reflog.txt | 59 | ||||
-rw-r--r-- | Documentation/git.txt | 3 | ||||
-rw-r--r-- | builtin-reflog.c | 25 |
4 files changed, 94 insertions, 2 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt index 4d636267a3..6452a8be14 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -192,6 +192,15 @@ format.headers:: Additional email headers to include in a patch to be submitted by mail. See gitlink:git-format-patch[1]. +gc.reflogexpire:: + `git reflog expire` removes reflog entries older than + this time; defaults to 90 days. + +gc.reflogexpireunreachable:: + `git reflog expire` removes reflog entries older than + this time and are not reachable from the current tip; + defaults to 30 days. + gc.rerereresolved:: Records of conflicted merge you resolved earlier are kept for this many days when `git rerere gc` is run. diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt new file mode 100644 index 0000000000..55a24d3266 --- /dev/null +++ b/Documentation/git-reflog.txt @@ -0,0 +1,59 @@ +git-reflog(1) +============= + +NAME +---- +git-reflog - Manage reflog information + + +SYNOPSIS +-------- +[verse] +'git-reflog' expire [--dry-run] + [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... + + +DESCRIPTION +----------- + +Reflog is a mechanism to record when the tip of branches are +updated. This command is to manage the information recorded in it. + +The subcommand "expire" is used to prune older reflog entries. +Entries older than `expire` time, or entries older than +`expire-unreachable` time and are not reachable from the current +tip, are removed from the reflog. This is typically not used +directly by the end users -- instead, see gitlink:git-gc[1]. + + + +OPTIONS +------- + +--expire=<time>:: + Entries older than this time are pruned. Without the + option it is taken from configuration `gc.reflogExpire`, + which in turn defaults to 90 days. + +--expire-unreachable=<time>:: + Entries older than this time and are not reachable from + the current tip of the branch are pruned. Without the + option it is taken from configuration + `gc.reflogExpireUnreachable`, which in turn defaults to + 30 days. + +--all:: + Instead of listing <refs> explicitly, prune all refs. + +Author +------ +Written by Junio C Hamano <junkio@cox.net> + +Documentation +-------------- +Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>. + +GIT +--- +Part of the gitlink:git[7] suite + diff --git a/Documentation/git.txt b/Documentation/git.txt index 2a9e97dac1..4ed3eed13d 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -224,6 +224,9 @@ gitlink:git-prune[1]:: gitlink:git-quiltimport[1]:: Applies a quilt patchset onto the current branch. +gitlink:git-reflog[1]:: + Manage reflog information. + gitlink:git-relink[1]:: Hardlink common objects in local repositories. diff --git a/builtin-reflog.c b/builtin-reflog.c index de31967b99..d3f2f50d2b 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -5,6 +5,9 @@ #include "dir.h" #include "tree-walk.h" +static unsigned long default_reflog_expire; +static unsigned long default_reflog_expire_unreachable; + struct expire_reflog_cb { FILE *newlog; const char *ref; @@ -150,6 +153,17 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, return status; } +static int reflog_expire_config(const char *var, const char *value) +{ + if (!strcmp(var, "gc.reflogexpire")) + default_reflog_expire = approxidate(value); + else if (!strcmp(var, "gc.reflogexpireunreachable")) + default_reflog_expire_unreachable = approxidate(value); + else + return git_default_config(var, value); + return 0; +} + static const char reflog_expire_usage[] = "git-reflog expire [--dry-run] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>..."; @@ -159,11 +173,18 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) unsigned long now = time(NULL); int i, status, do_all; + git_config(reflog_expire_config); + save_commit_buffer = 0; do_all = status = 0; memset(&cb, 0, sizeof(cb)); - cb.expire_total = now - 90 * 24 * 3600; - cb.expire_unreachable = now - 30 * 24 * 3600; + + if (!default_reflog_expire_unreachable) + default_reflog_expire_unreachable = now - 30 * 24 * 3600; + if (!default_reflog_expire) + default_reflog_expire = now - 90 * 24 * 3600; + cb.expire_total = default_reflog_expire; + cb.expire_unreachable = default_reflog_expire_unreachable; for (i = 1; i < argc; i++) { const char *arg = argv[i]; |