Thread (2 messages) flat view 2 messages, 1 author, 2016-06-15

git-commit: allow From: line to be entered in commit message

From: sean <hidden>
Date: 2016-06-15 22:42:16
Subsystem: the rest · Maintainer: Linus Torvalds

Mostly just for comment to see if there is any support
for this feature....

Sean

---
Use the author name and email information given as the 
first line of the commit message in the form of:

From: name <email>

as the author's name and email address in the resulting
commit object.  This makes committing foreign patches
a little less cumbersome to handle for some workflows.

diff --git a/git-commit.sh b/git-commit.sh
index 193feeb..6004cd4 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -219,7 +219,7 @@ t)
 	fi
 esac
 
-grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG |
+grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG | sed -e '1s/^[ \t]*from:.*//I' |
 git-stripspace > "$GIT_DIR"/COMMIT_MSG
 
 if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
@@ -227,6 +227,13 @@ if cnt=`grep -v -i '^Signed-off-by' "$GI
 	wc -l` &&
    test 0 -lt $cnt
 then
+	FROM=$(grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG | sed -ne '1s/from:[ \t]*\(.*\)/\1/Ip;q')
+	NAME=$(echo "$FROM" | sed -e 's/<.*//;s/[ \t]*$//')
+	EMAIL=$(echo "$FROM" | sed -e 's/.*<\(.*\)>.*/\1/')
+	if test -n "$FROM"; then
+		export GIT_AUTHOR_NAME="$NAME"
+		export GIT_AUTHOR_EMAIL="$EMAIL"
+	fi
 	tree=$(git-write-tree) &&
 	commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
 	git-update-ref HEAD $commit $current &&
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help