git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make reflog query '@{1219188291}' act as '@{2008/08/19 16:24:51}'
@ 2008-08-19 23:44 Shawn O. Pearce
  2008-08-19 23:57 ` Junio C Hamano
  2008-08-20 19:35 ` Alex Riesen
  0 siblings, 2 replies; 10+ messages in thread
From: Shawn O. Pearce @ 2008-08-19 23:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

As we support seconds-since-epoch in $GIT_COMMITTER_TIME we should
also support it in a reflog @{...} style notation.  We can easily
tell this apart from @{nth} style notation by looking to see if
the value is unreasonably large for an @{nth} style notation.

The value 1112911993 was chosen for the limit as it is the commit
timestamp for e83c516331 "Initial revision of "git" ...". Any
reflogs in existance should contain timestamps dated later than
the date Linus first stored Git into itself, as reflogs came about
quite a bit after that.

Additionally a reflog with 1,112,911,993 record entries is also
simply not valid.  Such a reflog would require at least 87 TB to
store just the old and new SHA-1 values.  So our randomly chosen
upper limit for @{nth} notation is "big enough" that users will
not run into it by accident.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 sha1_name.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 4fb77f8..e25f56a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -349,7 +349,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 			else
 				nth = -1;
 		}
-		if (0 <= nth)
+		if (1112911993 <= nth) {
+			at_time = nth;
+			nth = -1;
+		} else if (0 <= nth)
 			at_time = 0;
 		else {
 			char *tmp = xstrndup(str + at + 2, reflog_len);
-- 
1.6.0.96.g2fad1.dirty

-- 
Shawn.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-08-21 15:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-19 23:44 [PATCH] Make reflog query '@{1219188291}' act as '@{2008/08/19 16:24:51}' Shawn O. Pearce
2008-08-19 23:57 ` Junio C Hamano
2008-08-20  0:03   ` Shawn O. Pearce
2008-08-20 19:35 ` Alex Riesen
2008-08-20 19:44   ` Shawn O. Pearce
2008-08-20 19:54     ` Alex Riesen
2008-08-20 20:00       ` Shawn O. Pearce
2008-08-20 20:09         ` Alex Riesen
2008-08-20 22:20     ` Junio C Hamano
2008-08-21 15:40       ` Shawn O. Pearce

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).