From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Schindelin Subject: [PATCH 1/2] Move the pick_author code to git-sh-setup Date: Mon, 25 Jun 2007 01:04:11 +0100 (BST) Message-ID: References: <7v4pkxydim.fsf@assigned-by-dhcp.cox.net> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: git@vger.kernel.org To: Junio C Hamano , Brian Gernhardt X-From: git-owner@vger.kernel.org Mon Jun 25 02:04:20 2007 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1I2c42-00087E-IH for gcvg-git@gmane.org; Mon, 25 Jun 2007 02:04:18 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751418AbXFYAER (ORCPT ); Sun, 24 Jun 2007 20:04:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751430AbXFYAER (ORCPT ); Sun, 24 Jun 2007 20:04:17 -0400 Received: from mail.gmx.net ([213.165.64.20]:49740 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751226AbXFYAEQ (ORCPT ); Sun, 24 Jun 2007 20:04:16 -0400 Received: (qmail invoked by alias); 25 Jun 2007 00:04:14 -0000 Received: from wbgn013.biozentrum.uni-wuerzburg.de (EHLO localhost) [132.187.25.13] by mail.gmx.net (mp023) with SMTP; 25 Jun 2007 02:04:14 +0200 X-Authenticated: #1490710 X-Provags-ID: V01U2FsdGVkX18eZ0449UYe82x7HkDbhrfIMgXRxQobIIs03JWvL4 YvMmYmToX4LeYT X-X-Sender: gene099@racer.site In-Reply-To: X-Y-GMX-Trusted: 0 Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: 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 --- Just the eval was changed, by dq'ing its argument. git-commit.sh | 30 ++---------------------------- git-sh-setup.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/git-commit.sh b/git-commit.sh index 5547a02..d43bdd8 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -483,34 +483,8 @@ fi >>"$GIT_DIR"/COMMIT_EDITMSG # Author if test '' != "$use_commit" then - pick_author_script=' - /^author /{ - s/'\''/'\''\\'\'\''/g - h - s/^author \([^<]*\) <[^>]*> .*$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_NAME='\''&'\''/p - - g - s/^author [^<]* <\([^>]*\)> .*$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p - - g - s/^author [^<]* <[^>]*> \(.*\)$/\1/ - s/'\''/'\''\'\'\''/g - s/.*/GIT_AUTHOR_DATE='\''&'\''/p - - q - } - ' - encoding=$(git config i18n.commitencoding || echo UTF-8) - set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" | - LANG=C LC_ALL=C sed -ne "$pick_author_script"` - eval "$set_author_env" - export GIT_AUTHOR_NAME - export GIT_AUTHOR_EMAIL - export GIT_AUTHOR_DATE + eval "$(get_author_ident_from_commit "$use_commit")" + export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE fi if test '' != "$force_author" then diff --git a/git-sh-setup.sh b/git-sh-setup.sh index f24c7f2..d861db3 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -53,6 +53,33 @@ require_work_tree () { die "fatal: $0 cannot be used without a working tree." } +get_author_ident_from_commit () { + pick_author_script=' + /^author /{ + s/'\''/'\''\\'\'\''/g + h + s/^author \([^<]*\) <[^>]*> .*$/\1/ + s/'\''/'\''\'\'\''/g + s/.*/GIT_AUTHOR_NAME='\''&'\''/p + + g + s/^author [^<]* <\([^>]*\)> .*$/\1/ + s/'\''/'\''\'\'\''/g + s/.*/GIT_AUTHOR_EMAIL='\''&'\''/p + + g + s/^author [^<]* <[^>]*> \(.*\)$/\1/ + s/'\''/'\''\'\'\''/g + s/.*/GIT_AUTHOR_DATE='\''&'\''/p + + q + } + ' + encoding=$(git config i18n.commitencoding || echo UTF-8) + git show -s --pretty=raw --encoding="$encoding" "$1" | + LANG=C LC_ALL=C sed -ne "$pick_author_script" +} + if [ -z "$LONG_USAGE" ] then LONG_USAGE="Usage: $0 $USAGE" -- 1.5.2.2.279.g9b198-dirty