Skip to content

Commit

Permalink
git-reflog: gc.* configuration and documentation.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Dec 27, 2006
1 parent 48c3242 commit 4aec56d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
59 changes: 59 additions & 0 deletions Documentation/git-reflog.txt
Original file line number Diff line number Diff line change
@@ -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

3 changes: 3 additions & 0 deletions Documentation/git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 23 additions & 2 deletions builtin-reflog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>...";

Expand All @@ -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];
Expand Down

0 comments on commit 4aec56d

Please sign in to comment.