commit - 15f404b1ceddb96797adc6a015786806435fc153
commit + 21f077265038a0c30c857035d2ab286f293573b1
blob - 1ff53d9f2259c53d193902d67d5cbf3c5c1fd1c7
blob + d21399f4a8f84abbee2384d2577953581215edd6
--- got/got.c
+++ got/got.c
while (*author && *author != '\n' && *author != '<' && *author != '>')
author++;
+ if (author != email && *author == '<' && *(author - 1) != ' ')
+ return got_error_fmt(GOT_ERR_COMMIT_BAD_AUTHOR, "%s: space "
+ "between author name and email required", email);
if (*author++ != '<')
return got_error_fmt(GOT_ERR_COMMIT_NO_EMAIL, "%s", email);
while (*author && *author != '\n' && *author != '<' && *author != '>')
blob - f0c22e965e0b95671ae7f6667830714b714ecbe9
blob + bbfa823cda9c46a471aefb0a9263d11583de85b4
--- include/got_error.h
+++ include/got_error.h
#define GOT_ERR_REFS_PROTECTED 163
#define GOT_ERR_REF_PROTECTED 164
#define GOT_ERR_REF_BUSY 165
+#define GOT_ERR_COMMIT_BAD_AUTHOR 166
struct got_error {
int code;
blob - d12ab759e6d259c67d2d70004b3aab5e63c0210c
blob + 3b3a634ed0c2f2b1d0dd925891e217c07e57cf5c
--- lib/error.c
+++ lib/error.c
{ GOT_ERR_REFS_PROTECTED, "reference namespace may not be modified" },
{ GOT_ERR_REF_PROTECTED," reference may not be modified" },
{ GOT_ERR_REF_BUSY, "reference cannot be updated; please try again" },
+ { GOT_ERR_COMMIT_BAD_AUTHOR, "commit author formatting would "
+ "make Git unhappy" },
};
static struct got_custom_error {
blob - d2688f0de1e8d3514a41b90c5ac5e0af154f5cbe
blob + bf310d5b1b095c5545625bae6cba5acc7abc8a66
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
test_done "$testroot" "$ret"
}
+
+test_commit_bad_author() {
+ local testroot=`test_init commit_bad_author`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done "$testroot" $ret
+ return 1
+ fi
+
+ echo "modified alpha" > $testroot/wt/alpha
+
+ (cd $testroot/wt && got commit \
+ -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
+ > /dev/null 2> $testroot/stderr
+ ret=$?
+ if [ $ret -eq 0 ]; then
+ test_done "$testroot" 1
+ return 1
+ fi
+ echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
+ > $testroot/stderr.expected
+ echo -n 'space between author name and email required: ' \
+ >> $testroot/stderr.expected
+ echo 'commit author formatting would make Git unhappy' \
+ >> $testroot/stderr.expected
+ cmp -s $testroot/stderr.expected $testroot/stderr
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stderr.expected $testroot/stderr
+ test_done "$testroot" $ret
+ return 1
+ fi
+ test_done "$testroot" 0
+}
+
test_parseargs "$@"
run_test test_commit_basic
run_test test_commit_new_subdir
run_test test_commit_prepared_logmsg
run_test test_commit_large_file
run_test test_commit_gitignore
+run_test test_commit_bad_author