aboutsummaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@ksplice.com>2010-09-29 16:49:49 -0400
committerJunio C Hamano <gitster@pobox.com>2010-10-13 16:39:45 -0700
commita1980c4efcfea516e2ba442bf7e56a39d9a7933f (patch)
treea1f0bbfe13af6e7d36e76e53646337c4f7b94d07 /builtin/apply.c
parent87b50542a08ac6caa083ddc376e674424e37940a (diff)
downloadgit-a1980c4efcfea516e2ba442bf7e56a39d9a7933f.tar.gz
git-a1980c4efcfea516e2ba442bf7e56a39d9a7933f.tar.xz
apply: Recognize epoch timestamps with : in the timezone
Some patches have a timezone formatted like ‘-08:00’ instead of ‘-0800’ (e.g. http://lwn.net/Articles/131729/), so git apply would fail to recognize the epoch timestamp of deleted files and would create empty files instead. Teach it to support both formats, and add a test case. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 23c18c573..000d3e529 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -733,8 +733,8 @@ static int has_epoch_timestamp(const char *nameline)
" "
"[0-2][0-9]:[0-5][0-9]:00(\\.0+)?"
" "
- "([-+][0-2][0-9][0-5][0-9])\n";
- const char *timestamp = NULL, *cp;
+ "([-+][0-2][0-9]:?[0-5][0-9])\n";
+ const char *timestamp = NULL, *cp, *colon;
static regex_t *stamp;
regmatch_t m[10];
int zoneoffset;
@@ -764,8 +764,11 @@ static int has_epoch_timestamp(const char *nameline)
return 0;
}
- zoneoffset = strtol(timestamp + m[3].rm_so + 1, NULL, 10);
- zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100);
+ zoneoffset = strtol(timestamp + m[3].rm_so + 1, (char **) &colon, 10);
+ if (*colon == ':')
+ zoneoffset = zoneoffset * 60 + strtol(colon + 1, NULL, 10);
+ else
+ zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100);
if (timestamp[m[3].rm_so] == '-')
zoneoffset = -zoneoffset;