public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku•dk>
To: Petr Baudis <pasky@ucw•cz>
Cc: git@vger•kernel.org
Subject: [PATCH 1/3] cg-commit: Move author picking to cg-Xlib
Date: Tue, 7 Feb 2006 23:44:19 +0100	[thread overview]
Message-ID: <20060207224419.GA24790@diku.dk> (raw)

Adds pick_author utility function to cg-Xlib that uses the author line from
git-cat-file output to print a string that sets the GIT_AUTHOR_* env
variables. This string should then be eval'd by the caller.

Signed-off-by: Jonas Fonseca <fonseca@diku•dk>
---
commit 5095aca7013d87ccdb08dad20a9fb93d7465d33d
tree 9ec064a96718b937d373769c52d830b8c3a6daca
parent d3cabc9974357947eac035d613557d4318b85f9f
author Jonas Fonseca <fonseca@diku•dk> Tue, 07 Feb 2006 23:05:19 +0100
committer Jonas Fonseca <fonseca@antimatter•localdomain> Tue, 07 Feb 2006 23:05:19 +0100

 cg-Xlib   |   26 ++++++++++++++++++++++++++
 cg-commit |   28 +---------------------------
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
index 308d798..e17c82f 100644
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -236,6 +236,32 @@ list_untracked_files()
 	git-ls-files -z --others $listdirs "${EXCLUDE[@]}"
 }
 
+pick_author()
+{
+	local pick_author_script='
+		/^author /{
+			s/'\''/'\''\\'\'\''/g
+			h
+			s/^author \([^<]*\) <[^>]*> .*$/\1/
+			s/'\''/'\''\'\'\''/g
+			s/.*/export GIT_AUTHOR_NAME='\''&'\''/p
+
+			g
+			s/^author [^<]* <\([^>]*\)> .*$/\1/
+			s/'\''/'\''\'\'\''/g
+			s/.*/export GIT_AUTHOR_EMAIL='\''&'\''/p
+
+			g
+			s/^author [^<]* <[^>]*> \(.*\)$/\1/
+			s/'\''/'\''\'\'\''/g
+			s/.*/export GIT_AUTHOR_DATE='\''&'\''/p
+
+			q
+		}
+	'
+	LANG=C LC_ALL=C sed -ne "$pick_author_script"
+}
+
 # Usage: showdate SECONDS TIMEZONE [FORMAT]
 # Display date nicely based on how GIT stores it.
 # Save the date to $_showdate
diff --git a/cg-commit b/cg-commit
index e5e98b4..06ab0c0 100755
--- a/cg-commit
+++ b/cg-commit
@@ -276,33 +276,7 @@ for msg in "${msgs[@]}"; do
 done
 
 if [ "$copy_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
-		}
-	'
-	set_author_env="$(git-cat-file commit "$copy_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 "$(git-cat-file commit "$copy_commit" | pick_author)"
 	git-cat-file commit "$copy_commit" | sed -e '1,/^$/d'
         written=1
 fi >>"$LOGMSG"

-- 
Jonas Fonseca

                 reply	other threads:[~2006-02-07 22:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060207224419.GA24790@diku.dk \
    --to=fonseca@diku$(echo .)dk \
    --cc=git@vger$(echo .)kernel.org \
    --cc=pasky@ucw$(echo .)cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox