git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
sean <seanlkml@sympatico.ca>
Date
Jan 12, 2006, 15:21 UTC
Message-ID
<BAYC1-PASMTP07EE5172C7652A5DD3131DAE270@CEZ.ICE>
In-Reply-To
<BAYC1-PASMTP117A18814EAAFACFE0F31DAE270@CEZ.ICE>

On Thu, 12 Jan 2006 09:37:00 -0500 sean <seanlkml@sympatico.ca> wrote:

> Mostly just for comment to see if there is any support
> for this feature....
Sorry.  Slightly better version of the patch below:
---
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..163e2d7 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -219,14 +219,19 @@ t)
 	fi
 esac
 
-grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG |
-git-stripspace > "$GIT_DIR"/COMMIT_MSG
+grep -v '^#' < "$GIT_DIR"/COMMIT_EDITMSG | git-stripspace | 
+sed -e '1s/^[ \t]*from:.*//I' | git-stripspace > "$GIT_DIR"/COMMIT_MSG
 
 if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |
 	git-stripspace |
 	wc -l` &&
    test 0 -lt $cnt
 then
+	FROM=$(sed -ne '/^#/d;/^[ \t]*$/d;s/from:[ \t]*\(.*\)/\1/Ip;q' "$GIT_DIR"/COMMIT_EDITMSG)
+	if test -n "$FROM"; then
+		export GIT_AUTHOR_NAME=$(echo "$FROM" | sed -e 's/[ \t]*<.*//')
+		export GIT_AUTHOR_EMAIL=$(echo "$FROM" | sed -e 's/.*<\(.*\)>.*/\1/')
+	fi
 	tree=$(git-write-tree) &&
 	commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
 	git-update-ref HEAD $commit $current &&
Previous: seanNext: Junio C Hamano
Message 2 of 16 in “git-commit: allow From: line to be entered in commit message”
  1. seanJan 12, 2006
  2. seanJan 12, 2006
  3. Junio C HamanoJan 12, 2006
  4. Andreas EricssonJan 12, 2006
  5. Junio C HamanoJan 12, 2006
  6. seanJan 13, 2006
  7. seanJan 13, 2006
  8. Junio C HamanoJan 13, 2006
  9. seanJan 13, 2006
  10. Junio C HamanoJan 13, 2006
  11. seanJan 13, 2006
  12. Artem KhodushJan 13, 2006
  13. Junio C HamanoJan 13, 2006
  14. seanJan 13, 2006
  15. Junio C HamanoJan 13, 2006
  16. Johannes SchindelinJan 13, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.