@matheusbsbs / matheus-bagliano / commits / a45d46ba72
Fork 0

Preparation to call determine_author_info from prepare_to_commit

Reorder functions definitions such that determine_author_info is defined before prepare_to_commit. No code changes. Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Santi Béjar committed May 4, 2008 at 18:04 UTC a45d46ba72a8be16eeb30f608620bac7d9296803
1 file changed +39 -39
builtin-commit.c
+39 -39
@@ -395,6 +395,45 @@ static int is_a_merge(const unsigned char *sha1)
395
396 static const char sign_off_header[] = "Signed-off-by: ";
397
398 +static void determine_author_info(struct strbuf *sb)
399 +{
400 + char *name, *email, *date;
401 +
402 + name = getenv("GIT_AUTHOR_NAME");
403 + email = getenv("GIT_AUTHOR_EMAIL");
404 + date = getenv("GIT_AUTHOR_DATE");
405 +
406 + if (use_message) {
407 + const char *a, *lb, *rb, *eol;
408 +
409 + a = strstr(use_message_buffer, "\nauthor ");
410 + if (!a)
411 + die("invalid commit: %s", use_message);
412 +
413 + lb = strstr(a + 8, " <");
414 + rb = strstr(a + 8, "> ");
415 + eol = strchr(a + 8, '\n');
416 + if (!lb || !rb || !eol)
417 + die("invalid commit: %s", use_message);
418 +
419 + name = xstrndup(a + 8, lb - (a + 8));
420 + email = xstrndup(lb + 2, rb - (lb + 2));
421 + date = xstrndup(rb + 2, eol - (rb + 2));
422 + }
423 +
424 + if (force_author) {
425 + const char *lb = strstr(force_author, " <");
426 + const char *rb = strchr(force_author, '>');
427 +
428 + if (!lb || !rb)
429 + die("malformed --author parameter");
430 + name = xstrndup(force_author, lb - force_author);
431 + email = xstrndup(lb + 2, rb - (lb + 2));
432 + }
433 +
434 + strbuf_addf(sb, "author %s\n", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));
435 +}
436 +
437 static int prepare_to_commit(const char *index_file, const char *prefix)
438 {
439 struct stat statbuf;
@@ -622,45 +661,6 @@ static int message_is_empty(struct strbuf *sb, int start)
661 return 1;
662 }
663
625 -static void determine_author_info(struct strbuf *sb)
626 -{
627 - char *name, *email, *date;
628 -
629 - name = getenv("GIT_AUTHOR_NAME");
630 - email = getenv("GIT_AUTHOR_EMAIL");
631 - date = getenv("GIT_AUTHOR_DATE");
632 -
633 - if (use_message) {
634 - const char *a, *lb, *rb, *eol;
635 -
636 - a = strstr(use_message_buffer, "\nauthor ");
637 - if (!a)
638 - die("invalid commit: %s", use_message);
639 -
640 - lb = strstr(a + 8, " <");
641 - rb = strstr(a + 8, "> ");
642 - eol = strchr(a + 8, '\n');
643 - if (!lb || !rb || !eol)
644 - die("invalid commit: %s", use_message);
645 -
646 - name = xstrndup(a + 8, lb - (a + 8));
647 - email = xstrndup(lb + 2, rb - (lb + 2));
648 - date = xstrndup(rb + 2, eol - (rb + 2));
649 - }
650 -
651 - if (force_author) {
652 - const char *lb = strstr(force_author, " <");
653 - const char *rb = strchr(force_author, '>');
654 -
655 - if (!lb || !rb)
656 - die("malformed --author parameter");
657 - name = xstrndup(force_author, lb - force_author);
658 - email = xstrndup(lb + 2, rb - (lb + 2));
659 - }
660 -
661 - strbuf_addf(sb, "author %s\n", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));
662 -}
663 -
664 static int parse_and_validate_options(int argc, const char *argv[],
665 const char * const usage[])
666 {