summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 116eb3a)
raw | patch | inline | side by side (parent: 116eb3a)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 2 Feb 2012 21:41:43 +0000 (13:41 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 4 Feb 2012 07:11:32 +0000 (23:11 -0800) |
The only place that the issue this series addresses was observed
where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE
in order to replay a commit with an ancient timestamp.
With the previous patch alone, "git commit --date='20100917 +0900'"
can be misinterpreted to mean an ancient timestamp, not September in
year 2010. Guard this codepath by requring an extra '@' in front of
the raw git timestamp on the parsing side. This of course needs to
be compensated by updating get_author_ident_from_commit and the code
for "git commit --amend" to prepend '@' to the string read from the
existing commit in the GIT_AUTHOR_DATE environment variable.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE
in order to replay a commit with an ancient timestamp.
With the previous patch alone, "git commit --date='20100917 +0900'"
can be misinterpreted to mean an ancient timestamp, not September in
year 2010. Guard this codepath by requring an extra '@' in front of
the raw git timestamp on the parsing side. This of course needs to
be compensated by updating get_author_ident_from_commit and the code
for "git commit --amend" to prepend '@' to the string read from the
existing commit in the GIT_AUTHOR_DATE environment variable.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/commit.c | patch | blob | history | |
date.c | patch | blob | history | |
git-sh-setup.sh | patch | blob | history | |
t/t3400-rebase.sh | patch | blob | history |
diff --git a/builtin/commit.c b/builtin/commit.c
index cbc9613ec661bc2cef8274cd66efb06b9cab55b6..bcb0db2db53de93887a5d91465a910bb0e4b9a24 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
if (author_message) {
const char *a, *lb, *rb, *eol;
+ size_t len;
a = strstr(author_message_buffer, "\nauthor ");
if (!a)
(a + strlen("\nauthor "))));
email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
+ len = eol - (rb + strlen("> "));
+ date = xmalloc(len + 2);
+ *date = '@';
+ memcpy(date + 1, rb + strlen("> "), len);
+ date[len + 1] = '\0';
}
if (force_author) {
index 099ddbe7fc9ea1595be8797fb4bca230fa143a32..bf8e088e6aec6278ec4be054732e517ce3abaafc 100644 (file)
--- a/date.c
+++ b/date.c
*offset = -1;
tm_gmt = 0;
- if (!match_object_header_date(date, timestamp, offset))
+ if (*date == '@' &&
+ !match_object_header_date(date + 1, timestamp, offset))
return 0; /* success */
for (;;) {
int match = 0;
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 8e427dab31c27bd78d9eac1ad15bc1f5dcc044c4..015fe6e336314c4994b68b966d41b5c09f97d956 100644 (file)
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
g
- s/^author [^<]* <[^>]*> \(.*\)$/\1/
+ s/^author [^<]* <[^>]*> \(.*\)$/@\1/
s/.*/GIT_AUTHOR_DATE='\''&'\''/p
q
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6eaecec906c49749237b243f772f2e33eb0efedd..e26e14dd535d13ca1da1590461b07c0953d8dcd6 100755 (executable)
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
test "a note" = "$(git notes show HEAD)"
'
+test_expect_success 'rebase commit with an ancient timestamp' '
+ git reset --hard &&
+
+ >old.one && git add old.one && test_tick &&
+ git commit --date="@12345 +0400" -m "Old one" &&
+ >old.two && git add old.two && test_tick &&
+ git commit --date="@23456 +0500" -m "Old two" &&
+ >old.three && git add old.three && test_tick &&
+ git commit --date="@34567 +0600" -m "Old three" &&
+
+ git cat-file commit HEAD^^ >actual &&
+ grep "author .* 12345 +0400$" actual &&
+ git cat-file commit HEAD^ >actual &&
+ grep "author .* 23456 +0500$" actual &&
+ git cat-file commit HEAD >actual &&
+ grep "author .* 34567 +0600$" actual &&
+
+ git rebase --onto HEAD^^ HEAD^ &&
+
+ git cat-file commit HEAD >actual &&
+ grep "author .* 34567 +0600$" actual
+'
+
test_done