The shell function `get_author_ident_from_commit` defined by
git-sh-setup retrieves the author information from the named commit
and returns assignments of the environment variables


ready for evaluation by the shell.

This interface is used in conjunction with the so-called author
script which is a git-rebase--interactive state file that contains
the `get_author_ident_from_commit` output. It is sourced when `git
rebase --continue` is executed after conflict resolution to retain
the original commit authorship.

The variable assignments are only exported by the subshell that
executes the git-commit command line that commits the resolved
conflicts. That is taken care of by wrapping the git-commit call in
`do_with_author`. However, this is not enough protection from
modifying the git environment variables unintentionally because the
user running git-rebase could have already exported those herself.
And therefore, a bare git-commit could result in an authorship that
is neither intended by the user nor by git-rebase--interactive.

While it is not an issue now (either `do_with_author`,
git-cherry-pick or `--amend` are used to create commits), the
unnecessary loss of the author name and e-mail copied from the user
environment, and the unneeded fixing of the author date might become
a problem when we decide to support something similar to
`--reset-author` or `--ignore-date in interactive git-rebase.

Do not assign the git environment variables until in the
`do_with_author` subshell.

Signed-off-by: Fabian Ruch <>
--- | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ b/
index 73c97a1..8fbfe6d 100644
--- a/
+++ b/
@@ -166,7 +166,7 @@ make_patch () {
        test -f "$msg" ||
                commit_message "$1" > "$msg"
        test -f "$author_script" ||
-               get_author_ident_from_commit "$1" > "$author_script"
+               echo "$1" > "$author_script"
 die_with_patch () {
@@ -215,9 +215,13 @@ is_merge_commit()
 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
-# GIT_AUTHOR_DATE exported from the current environment.
+# GIT_AUTHOR_DATE assigned the author information extracted from the
+# named commit and exported.
 do_with_author () {
+               sha1=$1
+               shift
+               eval $(get_author_ident_from_commit $sha1)
@@ -348,13 +352,11 @@ pick_one_preserving_merges () {
                        test "a$1" = a-n && die "Refusing to squash a merge: 
                        # redo merge
-                       author_script_content=$(get_author_ident_from_commit 
-                       eval "$author_script_content"
                        msg_content="$(commit_message $sha1)"
                        # No point in merging the first parent, that's HEAD
                        new_parents=${new_parents# $first_parent}
                        merge_args="--no-log --no-ff"
-                       if ! do_with_author output eval \
+                       if ! do_with_author $sha1 output eval \
                        'git merge ${gpg_sign_opt:+"$gpg_sign_opt"} \
                                $merge_args $strategy_args -m "$msg_content" 
@@ -592,8 +594,7 @@ do_pick () {
                if test -z "$rewrite_reset_author" && test -z "$rewrite_amend"
-                       eval $(get_author_ident_from_commit $1)
-                       do_with_author=do_with_author
+                       do_with_author="do_with_author $1"
                $do_with_author output git commit \
                           --allow-empty --no-post-rewrite -n --no-edit \
@@ -1041,9 +1042,9 @@ first and then run 'git rebase --continue' again."
                                ${gpg_sign_opt:+"$gpg_sign_opt"} ||
                                die "Could not commit staged changes."
-                       . "$author_script" ||
+                       test -r "$author_script" ||
                                die "Error trying to find the author identity 
to amend commit"
-                       do_with_author git commit --no-verify -F "$msg" -e \
+                       do_with_author $(cat "$author_script") git commit 
--no-verify -F "$msg" -e \
                                ${gpg_sign_opt:+"$gpg_sign_opt"} ||
                                die "Could not commit staged changes."

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to