Skip to content

Commit

Permalink
Make reflog query '@{1219188291}' act as '@{2008.8.19.16:24:51.-0700}'
Browse files Browse the repository at this point in the history
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 part from @{nth} style notation by looking to see if the
value is unreasonably large for an @{nth} style notation.

The value 100000000 was chosen as it is already used by date.c to
disambiguate yyyymmdd format from a seconds-since-epoch time value.

A reflog with 100,000,000 record entries is also simply not valid.
Such a reflog would require at least 7.7 GB to store just the old
and new SHA-1 values.  So our randomly chosen upper limit for @{nth}
notation is "big enough".

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Aug 22, 2008
1 parent 1352fdb commit ea360dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
else
nth = -1;
}
if (0 <= nth)
if (100000000 <= nth) {
at_time = nth;
nth = -1;
} else if (0 <= nth)
at_time = 0;
else {
char *tmp = xstrndup(str + at + 2, reflog_len);
Expand Down

0 comments on commit ea360dd

Please sign in to comment.