threads / patch / 9206

patchTeach approxidate() to understand "never"

Subject: [PATCH] Teach approxidate() to understand "never"

## tl;dr

One message between Jul 24, 2007 and Jul 24, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Johannes Schindelin· Jul 24, 2007, 18:18 UTC · lore

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(-)
Show changes to date.c +7 −0
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

← back to recent threads