git-reflog: gc.* configuration and documentation.

Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Junio C Hamano 2006-12-27 01:47:57 -08:00
parent 48c3242450
commit 4aec56d12b
4 changed files with 94 additions and 2 deletions

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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];