git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Teach approxidate() to understand "never"
@ 2007-07-24 18:18 Johannes Schindelin
  0 siblings, 0 replies; only message in thread
From: Johannes Schindelin @ 2007-07-24 18:18 UTC (permalink / raw)
  To: git, gitster


If you want to keep the reflogs around for a really long time, you should be
able to say so:

	$ git config gc.reflogExpire never

Now it works, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	Guess how surprised I was when "gc.reflogExpire = never" triggered 
	a pruning of _all_ reflogs!  Happily, this was only in a test 
	environment.

	Another strange thing there is this:  As an alternative, I set
	reflogExpire to "1970", which git interpreted as "now" (just like 
	"never", before this patch).  Another alternative was even worse: 
	"1 Jan 1970".  Because I am at +0100 right now, the debugger said 
	this:

	Breakpoint 1, cmd_reflog_expire (argc=1, argv=0xbfb92968, prefix=0x0)
	    at builtin-reflog.c:307
	307             if (!default_reflog_expire_unreachable)
	(gdb) p show_date(default_reflog_expire, 0, 0)
	$3 = 0x8113560 "Wed Dec 31 23:00:00 1969 +0000"
	(gdb) p default_reflog_expire
	$4 = 4294963696

	IOW, if I had not looked at the timestamp, I would have thunk 
	everything is fine, while "git reflog expire" again would have 
	merrily removed _every_ reflog.

 date.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/date.c b/date.c
index 45b0b1d..59fe4f8 100644
--- a/date.c
+++ b/date.c
@@ -660,6 +660,12 @@ static void date_am(struct tm *tm, int *num)
 	tm->tm_hour = (hour % 12);
 }
 
+static void date_never(struct tm *tm, int *num)
+{
+	tm->tm_year = tm->tm_mon = tm->tm_mday = tm->tm_wday = tm->tm_yday
+		= tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
+}
+
 static const struct special {
 	const char *name;
 	void (*fn)(struct tm *, int *);
@@ -670,6 +676,7 @@ static const struct special {
 	{ "tea", date_tea },
 	{ "PM", date_pm },
 	{ "AM", date_am },
+	{ "never", date_never },
 	{ NULL }
 };
 
-- 
1.5.3.rc2.42.gda8d

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-24 18:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-24 18:18 [PATCH] Teach approxidate() to understand "never" Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).