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

Move the pick_author code to git-sh-setup

At the moment, only git-commit uses that code, to pick the author name, email and date from a given commit. This code will be reused in git rebase --interactive. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jun 25, 2007 at 01:04 UTC 0cae23467ada9b94210a0e770064841efea8ad40
2 files changed +29 -28
git-commit.sh
+2 -28
@@ -483,34 +483,8 @@ fi >>"$GIT_DIR"/COMMIT_EDITMSG
483 # Author
484 if test '' != "$use_commit"
485 then
486 - pick_author_script='
487 - /^author /{
488 - s/'\''/'\''\\'\'\''/g
489 - h
490 - s/^author \([^<]*\) <[^>]*> .*$/\1/
491 - s/'\''/'\''\'\'\''/g
492 - s/.*/GIT_AUTHOR_NAME='\''&'\''/p
493 -
494 - g
495 - s/^author [^<]* <\([^>]*\)> .*$/\1/
496 - s/'\''/'\''\'\'\''/g
497 - s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
498 -
499 - g
500 - s/^author [^<]* <[^>]*> \(.*\)$/\1/
501 - s/'\''/'\''\'\'\''/g
502 - s/.*/GIT_AUTHOR_DATE='\''&'\''/p
503 -
504 - q
505 - }
506 - '
507 - encoding=$(git config i18n.commitencoding || echo UTF-8)
508 - set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
509 - LANG=C LC_ALL=C sed -ne "$pick_author_script"`
510 - eval "$set_author_env"
511 - export GIT_AUTHOR_NAME
512 - export GIT_AUTHOR_EMAIL
513 - export GIT_AUTHOR_DATE
486 + eval "$(get_author_ident_from_commit "$use_commit")"
487 + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
488 fi
489 if test '' != "$force_author"
490 then
git-sh-setup.sh
+27
@@ -53,6 +53,33 @@ require_work_tree () {
53 die "fatal: $0 cannot be used without a working tree."
54 }
55
56 +get_author_ident_from_commit () {
57 + pick_author_script='
58 + /^author /{
59 + s/'\''/'\''\\'\'\''/g
60 + h
61 + s/^author \([^<]*\) <[^>]*> .*$/\1/
62 + s/'\''/'\''\'\'\''/g
63 + s/.*/GIT_AUTHOR_NAME='\''&'\''/p
64 +
65 + g
66 + s/^author [^<]* <\([^>]*\)> .*$/\1/
67 + s/'\''/'\''\'\'\''/g
68 + s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p
69 +
70 + g
71 + s/^author [^<]* <[^>]*> \(.*\)$/\1/
72 + s/'\''/'\''\'\'\''/g
73 + s/.*/GIT_AUTHOR_DATE='\''&'\''/p
74 +
75 + q
76 + }
77 + '
78 + encoding=$(git config i18n.commitencoding || echo UTF-8)
79 + git show -s --pretty=raw --encoding="$encoding" "$1" |
80 + LANG=C LC_ALL=C sed -ne "$pick_author_script"
81 +}
82 +
83 if [ -z "$LONG_USAGE" ]
84 then
85 LONG_USAGE="Usage: $0 $USAGE"