`do_pick` is the git-cherry-pick wrapper in git-rebase--interactive
that is used to implement many of the to-do list commands.
Eventually, the complete `do_pick` interface will be exposed to the
user in some form or another and those commands will become simple
aliases for the `do_pick` options now used to implement them.

Add the git-commit option `--reset-author` to the options pool of
`do_pick`. It rewrites the author date and name of the picked commit
to match the committer date and name.

If `--reset-author` is passed to `do_pick`, set the `rewrite` flag
and relay the option to the git-commit command line which creates the
final commit. If `--amend` is not passed as well, the fresh
authorship effect is achieved by the mere fact that we are creating a
new commit. Do not even source the ident information in that case
because the user shell might have already exported the respective
environment variables.

Signed-off-by: Fabian Ruch <baf...@gmail.com>
 git-rebase--interactive.sh | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 8b39f2d..6c75bc5 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -464,10 +464,18 @@ record_in_rewritten() {
 # Apply the changes introduced by the given commit to the current head.
-# do_pick [--amend] [--file <file>] [--edit] <commit>
+# do_pick [--reset-author] [--amend] [--file <file>] [--edit] <commit>
 # Wrapper around git-cherry-pick.
+# --reset-author
+#     Pretend the changes were made for the first time. Declare that the
+#     authorship of the resulting commit now belongs to the committer.
+#     This also renews the author timestamp. This creates a fresh
+#     commit.
+#     _This is not a git-cherry-pick option._
 # --amend
 #     After picking <commit>, replace the current head commit with a new
 #     commit that also introduces the changes of <commit>.
@@ -496,12 +504,17 @@ record_in_rewritten() {
 do_pick () {
+       rewrite_reset_author=
        while test $# -gt 0
                case "$1" in
+               --reset-author)
+                       rewrite=y
+                       rewrite_reset_author=y
+                       ;;
                        if test "$(git rev-parse HEAD)" = "$squash_onto" || ! 
git rev-parse -q --verify HEAD >/dev/null
@@ -566,11 +579,16 @@ do_pick () {
        if test -n "$rewrite"
-               eval $(get_author_ident_from_commit $1)
-               do_with_author output git commit \
+               do_with_author=
+               if test -z "$rewrite_reset_author" && test -z "$rewrite_amend"
+               then
+                       eval $(get_author_ident_from_commit $1)
+                       do_with_author=do_with_author
+               fi
+               $do_with_author output git commit \
                           --allow-empty --no-post-rewrite -n --no-edit \
                           ${allow_empty_message:+--allow-empty-message} \
-                          ${rewrite_amend:+--amend} \
+                          ${rewrite_amend:+--amend 
${rewrite_reset_author:+--reset-author}} \
                           ${rewrite_edit:+--edit --commit-msg} \
                           ${rewrite_message:+--file "$rewrite_message"} \
                           ${gpg_sign_opt:+"$gpg_sign_opt"} || return 3

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to