commit - 84bf00a657aa272bf25d00785cfc8302c60e2fca
commit + 17431c138a938066f1f24d60a05fcbc2934b2dfc
blob - 2026976547ad6f6b1827376170f282135b76ad9d
blob + f8f3434892efa89ff78a8b2a7af18e27afa3e24e
--- got/got.c
+++ got/got.c
{
printf("A %s\n", path);
return NULL;
+}
+
+static int
+valid_author(const char *author)
+{
+ /*
+ * Really dumb email address check; we're only doing this to
+ * avoid git's object parser breaking on commits we create.
+ */
+ while (*author && *author != '<')
+ author++;
+ if (*author != '<')
+ return 0;
+ while (*author && *author != '@')
+ author++;
+ if (*author != '@')
+ return 0;
+ while (*author && *author != '>')
+ author++;
+ return *author == '>';
}
static const struct got_error *
if (*author == NULL)
return got_error_from_errno("strdup");
- /*
- * Really dumb email address check; we're only doing this to
- * avoid git's object parser breaking on commits we create.
- */
- while (*got_author && *got_author != '<')
- got_author++;
- if (*got_author != '<') {
- err = got_error(GOT_ERR_COMMIT_NO_EMAIL);
- goto done;
- }
- while (*got_author && *got_author != '@')
- got_author++;
- if (*got_author != '@') {
- err = got_error(GOT_ERR_COMMIT_NO_EMAIL);
- goto done;
- }
- while (*got_author && *got_author != '>')
- got_author++;
- if (*got_author != '>')
- err = got_error(GOT_ERR_COMMIT_NO_EMAIL);
-done:
- if (err) {
+ if (!valid_author(*author)) {
+ err = got_error_fmt(GOT_ERR_COMMIT_NO_EMAIL, "%s", *author);
free(*author);
*author = NULL;
}
blob - c3199cc5662e657eb2b2bc0279e30f8a26837ed8
blob + 1661e22874323e45e56e6ee0023fa60f779e90b8
--- include/got_error.h
+++ include/got_error.h
{ GOT_ERR_STAGED_PATHS, "work tree contains files with staged "
"changes; these changes must be committed or unstaged first" },
{ GOT_ERR_PATCH_CHOICE, "invalid patch choice" },
- { GOT_ERR_COMMIT_NO_EMAIL,"GOT_AUTHOR environment variable contains "
- "no email address; an email address is required for compatibility "
- "with Git" },
+ { GOT_ERR_COMMIT_NO_EMAIL, "commit author's email address is required "
+ "for compatibility with Git" },
{ GOT_ERR_TAG_EXISTS,"specified tag already exists" },
{ GOT_ERR_GIT_REPO_FORMAT,"unknown git repository format version" },
{ GOT_ERR_REBASE_REQUIRED,"specified branch must be rebased first" },
blob - 9b4393a8e419399a857c9350288351203b1b3646
blob + df89676d05f1b65383d7d57859f044ad97adae15
--- regress/cmdline/commit.sh
+++ regress/cmdline/commit.sh
got commit -m 'test no email' > $testroot/stdout \
2> $testroot/stderr)
- echo -n "got: GOT_AUTHOR environment variable contains no email " \
+ echo -n "got: :flan_hacker:: commit author's email address " \
> $testroot/stderr.expected
- echo -n "address; an email address is required for compatibility "\
+ echo "is required for compatibility with Git" \
>> $testroot/stderr.expected
- echo "with Git" >> $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"
if [ "$ret" != "0" ]; then