summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 05bb5a2)
raw | patch | inline | side by side (parent: 05bb5a2)
author | Jeff King <peff@peff.net> | |
Mon, 13 Dec 2010 17:02:25 +0000 (12:02 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 20 Dec 2010 18:28:19 +0000 (10:28 -0800) |
If the user gives "git commit --date=foobar", we silently
ignore the --date flag. We should note the error.
This patch puts the fix at the lowest level of fmt_ident,
which means it also handles GIT_AUTHOR_DATE=foobar, as well.
There are two down-sides to this approach:
1. Technically this breaks somebody doing something like
"git commit --date=now", which happened to work because
bogus data is the same as "now". Though we do
explicitly handle the empty string, so anybody passing
an empty variable through the environment will still
work.
If the error is too much, perhaps it can be downgraded
to a warning?
2. The error checking happens _after_ the commit message
is written, which can be annoying to the user. We can
put explicit checks closer to the beginning of
git-commit, but that feels a little hack-ish; suddenly
git-commit has to care about how fmt_ident works. Maybe
we could simply call fmt_ident earlier?
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ignore the --date flag. We should note the error.
This patch puts the fix at the lowest level of fmt_ident,
which means it also handles GIT_AUTHOR_DATE=foobar, as well.
There are two down-sides to this approach:
1. Technically this breaks somebody doing something like
"git commit --date=now", which happened to work because
bogus data is the same as "now". Though we do
explicitly handle the empty string, so anybody passing
an empty variable through the environment will still
work.
If the error is too much, perhaps it can be downgraded
to a warning?
2. The error checking happens _after_ the commit message
is written, which can be annoying to the user. We can
put explicit checks closer to the beginning of
git-commit, but that feels a little hack-ish; suddenly
git-commit has to care about how fmt_ident works. Maybe
we could simply call fmt_ident earlier?
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ident.c | patch | blob | history | |
t/t7501-commit.sh | patch | blob | history |
index 9e2438826dfce158e04549933d5c588dd6abcf5c..1c4adb0a9a7e94936ba64d286cedd65f4b8255a6 100644 (file)
--- a/ident.c
+++ b/ident.c
}
strcpy(date, git_default_date);
- if (!name_addr_only && date_str)
- parse_date(date_str, date, sizeof(date));
+ if (!name_addr_only && date_str && date_str[0]) {
+ if (parse_date(date_str, date, sizeof(date)) < 0)
+ die("invalid date format: %s", date_str);
+ }
i = copy(buffer, sizeof(buffer), 0, name);
i = add_raw(buffer, sizeof(buffer), i, " <");
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 8297cb4f1e6e2d903dfbf6fde825d2c787082e58..8980738c7540b79eaa566d6054f3e76b202bd27e 100755 (executable)
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
'
+test_expect_success 'commit complains about bogus date' '
+ test_must_fail git commit --amend --date=10.11.2010
+'
+
test_expect_success 'sign off (1)' '
echo 1 >positive &&