@matheusbsbs / matheus-bagliano / commits / 4aec56d12b
Fork 0

git-reflog: gc.* configuration and documentation.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 27, 2006 at 01:47 UTC 4aec56d12ba66a321ce8a6db2ab60f81be5ccfc5
4 files changed +94 -2
Documentation/config.txt
+9
@@ -192,6 +192,15 @@ format.headers::
192 Additional email headers to include in a patch to be submitted
193 by mail. See gitlink:git-format-patch[1].
194
195 +gc.reflogexpire::
196 + `git reflog expire` removes reflog entries older than
197 + this time; defaults to 90 days.
198 +
199 +gc.reflogexpireunreachable::
200 + `git reflog expire` removes reflog entries older than
201 + this time and are not reachable from the current tip;
202 + defaults to 30 days.
203 +
204 gc.rerereresolved::
205 Records of conflicted merge you resolved earlier are
206 kept for this many days when `git rerere gc` is run.
Documentation/git-reflog.txt new
+59
@@ -0,0 +1,59 @@
1 +git-reflog(1)
2 +=============
3 +
4 +NAME
5 +----
6 +git-reflog - Manage reflog information
7 +
8 +
9 +SYNOPSIS
10 +--------
11 +[verse]
12 +'git-reflog' expire [--dry-run]
13 + [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
14 +
15 +
16 +DESCRIPTION
17 +-----------
18 +
19 +Reflog is a mechanism to record when the tip of branches are
20 +updated. This command is to manage the information recorded in it.
21 +
22 +The subcommand "expire" is used to prune older reflog entries.
23 +Entries older than `expire` time, or entries older than
24 +`expire-unreachable` time and are not reachable from the current
25 +tip, are removed from the reflog. This is typically not used
26 +directly by the end users -- instead, see gitlink:git-gc[1].
27 +
28 +
29 +
30 +OPTIONS
31 +-------
32 +
33 +--expire=<time>::
34 + Entries older than this time are pruned. Without the
35 + option it is taken from configuration `gc.reflogExpire`,
36 + which in turn defaults to 90 days.
37 +
38 +--expire-unreachable=<time>::
39 + Entries older than this time and are not reachable from
40 + the current tip of the branch are pruned. Without the
41 + option it is taken from configuration
42 + `gc.reflogExpireUnreachable`, which in turn defaults to
43 + 30 days.
44 +
45 +--all::
46 + Instead of listing <refs> explicitly, prune all refs.
47 +
48 +Author
49 +------
50 +Written by Junio C Hamano <junkio@cox.net>
51 +
52 +Documentation
53 +--------------
54 +Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
55 +
56 +GIT
57 +---
58 +Part of the gitlink:git[7] suite
59 +
Documentation/git.txt
+3
@@ -224,6 +224,9 @@ gitlink:git-prune[1]::
224 gitlink:git-quiltimport[1]::
225 Applies a quilt patchset onto the current branch.
226
227 +gitlink:git-reflog[1]::
228 + Manage reflog information.
229 +
230 gitlink:git-relink[1]::
231 Hardlink common objects in local repositories.
232
builtin-reflog.c
+23 -2
@@ -5,6 +5,9 @@
5 #include "dir.h"
6 #include "tree-walk.h"
7
8 +static unsigned long default_reflog_expire;
9 +static unsigned long default_reflog_expire_unreachable;
10 +
11 struct expire_reflog_cb {
12 FILE *newlog;
13 const char *ref;
@@ -150,6 +153,17 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
153 return status;
154 }
155
156 +static int reflog_expire_config(const char *var, const char *value)
157 +{
158 + if (!strcmp(var, "gc.reflogexpire"))
159 + default_reflog_expire = approxidate(value);
160 + else if (!strcmp(var, "gc.reflogexpireunreachable"))
161 + default_reflog_expire_unreachable = approxidate(value);
162 + else
163 + return git_default_config(var, value);
164 + return 0;
165 +}
166 +
167 static const char reflog_expire_usage[] =
168 "git-reflog expire [--dry-run] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
169
@@ -159,11 +173,18 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
173 unsigned long now = time(NULL);
174 int i, status, do_all;
175
176 + git_config(reflog_expire_config);
177 +
178 save_commit_buffer = 0;
179 do_all = status = 0;
180 memset(&cb, 0, sizeof(cb));
165 - cb.expire_total = now - 90 * 24 * 3600;
166 - cb.expire_unreachable = now - 30 * 24 * 3600;
181 +
182 + if (!default_reflog_expire_unreachable)
183 + default_reflog_expire_unreachable = now - 30 * 24 * 3600;
184 + if (!default_reflog_expire)
185 + default_reflog_expire = now - 90 * 24 * 3600;
186 + cb.expire_total = default_reflog_expire;
187 + cb.expire_unreachable = default_reflog_expire_unreachable;
188
189 for (i = 1; i < argc; i++) {
190 const char *arg = argv[i];