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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

	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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux