{"thread":{"id":"19893","subject":"[PATCH v3 2/2] rebase -i: save only original commit sha1 to save author information","startedAt":"2009-06-22T04:28:30Z","lastAt":"2009-06-22T09:27:57Z","messageCount":3,"participants":["Christian Couder","Jakub Narebski","Johannes Schindelin"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"116736","messageId":"20090622042831.3858.67926.chriscool@tuxfamily.org","threadId":"19893","inReplyTo":null,"subject":"[PATCH v3 2/2] rebase -i: save only original commit sha1 to save author information","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-06-22T04:28:30Z","receivedAt":"2009-06-22T04:28:30Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is better than saving author information in a shell script,\nbecause it will make it much easier to port \"rebase -i\" to C.\n\nThis also removes some sed regexps and some \"eval\"s.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-rebase--interactive.sh |   69 ++++++++++++++++++++-----------------------\n 1 files changed, 32 insertions(+), 37 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 92e2523..a7a169e 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -40,6 +40,7 @@ MSG=\"$DOTEST\"/message\n SQUASH_MSG=\"$DOTEST\"/message-squash\n REWRITTEN=\"$DOTEST\"/rewritten\n DROPPED=\"$DOTEST\"/dropped\n+SAVED_COMMIT=\"$DOTEST\"/saved-commit\n PRESERVE_MERGES=\n STRATEGY=\n ONTO=\n@@ -117,30 +118,25 @@ mark_action_done () {\n }\n \n get_author_ident_from_commit () {\n-\tpick_author_script='\n-\t/^author /{\n-\t\ts/'\\''/'\\''\\\\'\\'\\''/g\n-\t\th\n-\t\ts/^author \\([^<]*\\) <[^>]*> .*$/\\1/\n-\t\ts/'\\''/'\\''\\'\\'\\''/g\n-\t\ts/.*/GIT_AUTHOR_NAME='\\''&'\\''/p\n-\n-\t\tg\n-\t\ts/^author [^<]* <\\([^>]*\\)> .*$/\\1/\n-\t\ts/'\\''/'\\''\\'\\'\\''/g\n-\t\ts/.*/GIT_AUTHOR_EMAIL='\\''&'\\''/p\n-\n-\t\tg\n-\t\ts/^author [^<]* <[^>]*> \\(.*\\)$/\\1/\n-\t\ts/'\\''/'\\''\\'\\'\\''/g\n-\t\ts/.*/GIT_AUTHOR_DATE='\\''&'\\''/p\n-\n-\t\tq\n-\t}\n-\t'\n-\tencoding=$(git config i18n.commitencoding || echo UTF-8)\n-\tgit show -s --pretty=raw --encoding=\"$encoding\" \"$1\" -- |\n-\tLANG=C LC_ALL=C sed -ne \"$pick_author_script\"\n+\tencoding=$(git config i18n.commitencoding || echo UTF-8) &&\n+\tauthor_ident_name=$(git show -s --pretty=\"format:%an\" \\\n+\t\t--encoding=\"$encoding\" \"$1\" --) &&\n+\tauthor_ident_email=$(git show -s --pretty=\"format:%ae\" \\\n+\t\t--encoding=\"$encoding\" \"$1\" --) &&\n+\tauthor_ident_date=$(git show -s --pretty=\"format:%ai\" \\\n+\t\t--encoding=\"$encoding\" \"$1\" --)\n+}\n+\n+set_author_ident () {\n+\tGIT_AUTHOR_NAME=\"$author_ident_name\" &&\n+\tGIT_AUTHOR_EMAIL=\"$author_ident_email\" &&\n+\tGIT_AUTHOR_DATE=\"$author_ident_date\"\n+}\n+\n+load_author_ident () {\n+\tcommit=$(cat \"$SAVED_COMMIT\") &&\n+\tget_author_ident_from_commit \"$commit\" &&\n+\tset_author_ident\n }\n \n make_patch () {\n@@ -158,8 +154,8 @@ make_patch () {\n \tesac > \"$DOTEST\"/patch\n \ttest -f \"$DOTEST\"/message ||\n \t\tgit cat-file commit \"$1\" | sed \"1,/^$/d\" > \"$DOTEST\"/message\n-\ttest -f \"$DOTEST\"/author-script ||\n-\t\tget_author_ident_from_commit \"$1\" > \"$DOTEST\"/author-script\n+\ttest -f \"$SAVED_COMMIT\" ||\n+\t\techo $(git rev-parse --verify \"$1\") > \"$SAVED_COMMIT\"\n }\n \n die_with_patch () {\n@@ -294,8 +290,8 @@ pick_one_preserving_merges () {\n \t\t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n \n \t\t\t# redo merge\n-\t\t\tauthor_script=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script\"\n+\t\t\tget_author_ident_from_commit $sha1\n+\t\t\tset_author_ident\n \t\t\tmsg=\"$(git cat-file commit $sha1 | sed -e '1,/^$/d')\"\n \t\t\t# No point in merging the first parent, that's HEAD\n \t\t\tnew_parents=${new_parents# $first_parent}\n@@ -353,8 +349,7 @@ peek_next_command () {\n }\n \n do_next () {\n-\trm -f \"$DOTEST\"/message \"$DOTEST\"/author-script \\\n-\t\t\"$DOTEST\"/amend || exit\n+\trm -f \"$DOTEST\"/message \"$DOTEST\"/amend \"$SAVED_COMMIT\" || exit\n \tread command sha1 rest < \"$TODO\"\n \tcase \"$command\" in\n \t'#'*|''|noop)\n@@ -395,7 +390,8 @@ do_next () {\n \t\tmark_action_done\n \t\tmake_squash_message $sha1 > \"$MSG\"\n \t\tfailed=f\n-\t\tauthor_script=$(get_author_ident_from_commit HEAD)\n+\t\tget_author_ident_from_commit HEAD\n+\t\tcommit=$(git rev-parse --verify HEAD)\n \t\toutput git reset --soft HEAD^\n \t\tpick_one -n $sha1 || failed=t\n \t\tcase \"$(peek_next_command)\" in\n@@ -414,14 +410,13 @@ do_next () {\n \t\t\trm -f \"$GIT_DIR\"/MERGE_MSG || exit\n \t\t\t;;\n \t\tesac\n-\t\techo \"$author_script\" > \"$DOTEST\"/author-script\n+\t\techo \"$commit\" > \"$SAVED_COMMIT\"\n \t\tif test $failed = f\n \t\tthen\n \t\t\t# This is like --amend, but with a different message\n-\t\t\teval \"$author_script\"\n-\t\t\tGIT_AUTHOR_NAME=\"$GIT_AUTHOR_NAME\" \\\n-\t\t\tGIT_AUTHOR_EMAIL=\"$GIT_AUTHOR_EMAIL\" \\\n-\t\t\tGIT_AUTHOR_DATE=\"$GIT_AUTHOR_DATE\" \\\n+\t\t\tGIT_AUTHOR_NAME=\"$author_ident_name\" \\\n+\t\t\tGIT_AUTHOR_EMAIL=\"$author_ident_email\" \\\n+\t\t\tGIT_AUTHOR_DATE=\"$author_ident_date\" \\\n \t\t\t$USE_OUTPUT git commit --no-verify \\\n \t\t\t\t$MSG_OPT \"$EDIT_OR_FILE\" || failed=t\n \t\tfi\n@@ -536,7 +531,7 @@ do\n \t\tthen\n \t\t\t: Nothing to commit -- skip this\n \t\telse\n-\t\t\t. \"$DOTEST\"/author-script ||\n+\t\t\tload_author_ident ||\n \t\t\t\tdie \"Cannot find the author identity\"\n \t\t\tamend=\n \t\t\tif test -f \"$DOTEST\"/amend\n-- \n1.6.3.GIT\n"},{"id":"116741","messageId":"200906220935.11581.jnareb@gmail.com","threadId":"19893","inReplyTo":"20090622042831.3858.67926.chriscool@tuxfamily.org","subject":"Re: [PATCH v3 2/2] rebase -i: save only original commit sha1 to save author information","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-06-22T07:35:08Z","receivedAt":"2009-06-22T07:35:08Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Christian Couder wrote:\n\n> +                       GIT_AUTHOR_NAME=\"$author_ident_name\" \\\n> +                       GIT_AUTHOR_EMAIL=\"$author_ident_email\" \\\n> +                       GIT_AUTHOR_DATE=\"$author_ident_date\" \\\n>                         $USE_OUTPUT git commit --no-verify \\\n>                                 $MSG_OPT \"$EDIT_OR_FILE\" || failed=t\n\nWhy not use 'git commit -C $(cat \"$SAVED_COMMIT\") ...' ?\n\n-- \nJakub Narebski\nPoland\n"},{"id":"116750","messageId":"alpine.DEB.1.00.0906221126040.4168@intel-tinevez-2-302","threadId":"19893","inReplyTo":"200906220935.11581.jnareb@gmail.com","subject":"Re: [PATCH v3 2/2] rebase -i: save only original commit sha1 to save author information","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-22T09:27:57Z","receivedAt":"2009-06-22T09:27:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Jun 2009, Jakub Narebski wrote:\n\n> Christian Couder wrote:\n> \n> > +                       GIT_AUTHOR_NAME=\"$author_ident_name\" \\\n> > +                       GIT_AUTHOR_EMAIL=\"$author_ident_email\" \\\n> > +                       GIT_AUTHOR_DATE=\"$author_ident_date\" \\\n> >                         $USE_OUTPUT git commit --no-verify \\\n> >                                 $MSG_OPT \"$EDIT_OR_FILE\" || failed=t\n> \n> Why not use 'git commit -C $(cat \"$SAVED_COMMIT\") ...' ?\n\nUnfortunately, the quoted part lacks context, so I can only guess that the \nissue is \"squash\".  You need to retain authorship, but want to present a \nmessage to the user that is in no commit yet.  And no, constructing a new \ncommit for the purpose of passing it to \"commit -C\" would be way too \nshabby coding IMO.\n\nCiao,\nDscho\n"}]}