Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sha1_name: check @{-N} errors sooner
author
Ramkumar Ramachandra
<artagnon@gmail.com>
Tue, 7 May 2013 21:55:11 +0000
(16:55 -0500)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 8 May 2013 19:13:12 +0000
(12:13 -0700)
It's trivial to check for them in the @{N} parsing loop.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_name.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
128fd54
)
diff --git
a/sha1_name.c
b/sha1_name.c
index 45b89d9df00de3c31a39a74a0cc0e635b0095cbc..446cc62c4ecfced70dd480674aef370e0f860141 100644
(file)
--- a/
sha1_name.c
+++ b/
sha1_name.c
@@
-448,7
+448,10
@@
static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
if (len && str[len-1] == '}') {
for (at = len-4; at >= 0; at--) {
if (str[at] == '@' && str[at+1] == '{') {
if (len && str[len-1] == '}') {
for (at = len-4; at >= 0; at--) {
if (str[at] == '@' && str[at+1] == '{') {
- if (at == 0 && str[2] == '-') {
+ if (str[at+2] == '-') {
+ if (at != 0)
+ /* @{-N} not at start */
+ return -1;
nth_prior = 1;
continue;
}
nth_prior = 1;
continue;
}
@@
-497,10
+500,6
@@
static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
unsigned long co_time;
int co_tz, co_cnt;
unsigned long co_time;
int co_tz, co_cnt;
- /* a @{-N} placed anywhere except the start is an error */
- if (str[at+2] == '-')
- return -1;
-
/* Is it asking for N-th entry, or approxidate? */
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];
/* Is it asking for N-th entry, or approxidate? */
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];