git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* modifying commit's author
@ 2007-01-22 20:37 J. Bruce Fields
  2007-01-22 20:48 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: J. Bruce Fields @ 2007-01-22 20:37 UTC (permalink / raw)
  To: git

If I got the author wrong on a commit, is there a quick way to fix it
(e.g. by passing the right arguments or environment variables to commit
--amend)?

--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:37 modifying commit's author J. Bruce Fields
@ 2007-01-22 20:48 ` Junio C Hamano
  2007-01-22 21:02   ` J. Bruce Fields
  2007-01-22 21:03   ` Junio C Hamano
  2007-01-22 20:50 ` Robin Rosenberg
  2007-01-23  7:38 ` Johannes Sixt
  2 siblings, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2007-01-22 20:48 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: git

"J. Bruce Fields" <bfields@fieldses.org> writes:

> If I got the author wrong on a commit, is there a quick way to fix it
> (e.g. by passing the right arguments or environment variables to commit
> --amend)?

I usually do "format-patch -$n; reset --hard HEAD~$n; edit
00??-*.patch; am 00??-*.patch" myself when I got into that
situation to rebuild the branch, and haven't personally felt
need for an option to --amend, but it might make sense to teach
git-commit --amend to allow --author option to override it; I
think it currently ignores --author when given without erroring
out.

It may become a question if we would want to allow updating the
timestamp as well, but when people asked for --author I did not
hear from anybody who wanted to have --authortime, so not being
able to do so probably is Ok.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:37 modifying commit's author J. Bruce Fields
  2007-01-22 20:48 ` Junio C Hamano
@ 2007-01-22 20:50 ` Robin Rosenberg
  2007-01-22 21:04   ` J. Bruce Fields
  2007-01-23  7:38 ` Johannes Sixt
  2 siblings, 1 reply; 7+ messages in thread
From: Robin Rosenberg @ 2007-01-22 20:50 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: git

måndag 22 januari 2007 21:37 skrev J. Bruce Fields:
> If I got the author wrong on a commit, is there a quick way to fix it
> (e.g. by passing the right arguments or environment variables to commit
> --amend)?

Set these:
GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL
GIT_COMMITTER_NAME

-- robin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:48 ` Junio C Hamano
@ 2007-01-22 21:02   ` J. Bruce Fields
  2007-01-22 21:03   ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: J. Bruce Fields @ 2007-01-22 21:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jan 22, 2007 at 12:48:27PM -0800, Junio C Hamano wrote:
> "J. Bruce Fields" <bfields@fieldses.org> writes:
> 
> > If I got the author wrong on a commit, is there a quick way to fix it
> > (e.g. by passing the right arguments or environment variables to commit
> > --amend)?
> 
> I usually do "format-patch -$n; reset --hard HEAD~$n; edit
> 00??-*.patch; am 00??-*.patch" myself when I got into that
> situation to rebuild the branch, and haven't personally felt
> need for an option to --amend, but it might make sense to teach
> git-commit --amend to allow --author option to override it; I
> think it currently ignores --author when given without erroring
> out.

That might be nice, but actually the git-am trick is more convenient
than I'd realized; thanks for the tip.

--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:48 ` Junio C Hamano
  2007-01-22 21:02   ` J. Bruce Fields
@ 2007-01-22 21:03   ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2007-01-22 21:03 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: git

Junio C Hamano <junkio@cox.net> writes:

> "J. Bruce Fields" <bfields@fieldses.org> writes:
>
>> If I got the author wrong on a commit, is there a quick way to fix it
>> (e.g. by passing the right arguments or environment variables to commit
>> --amend)?
>
> I usually do "format-patch -$n; reset --hard HEAD~$n; edit
> 00??-*.patch; am 00??-*.patch" myself when I got into that
> situation to rebuild the branch, and haven't personally felt
> need for an option to --amend, but it might make sense to teach
> git-commit --amend to allow --author option to override it; I
> think it currently ignores --author when given without erroring
> out.
>
> It may become a question if we would want to allow updating the
> timestamp as well, but when people asked for --author I did not
> hear from anybody who wanted to have --authortime, so not being
> able to do so probably is Ok.

Untested, but something along this line.

-- >8 --
[PATCH] honor --author even with --amend, -C, and -c.

Earlier code discarded GIT_AUTHOR_DATE taken from the base
commit when --author was specified.  This was often wrong as
that use is likely to fix the spelling of author's name.

---

diff --git a/git-commit.sh b/git-commit.sh
index e23918c..6f4dcdb 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -462,15 +462,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
 fi >>"$GIT_DIR"/COMMIT_EDITMSG
 
 # Author
-if test '' != "$force_author"
-then
-	GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` &&
-	GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` &&
-	test '' != "$GIT_AUTHOR_NAME" &&
-	test '' != "$GIT_AUTHOR_EMAIL" ||
-	die "malformed --author parameter"
-	export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
-elif test '' != "$use_commit"
+if test '' != "$use_commit"
 then
 	pick_author_script='
 	/^author /{
@@ -501,6 +493,15 @@ then
 	export GIT_AUTHOR_EMAIL
 	export GIT_AUTHOR_DATE
 fi
+if test '' != "$force_author"
+then
+	GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` &&
+	GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` &&
+	test '' != "$GIT_AUTHOR_NAME" &&
+	test '' != "$GIT_AUTHOR_EMAIL" ||
+	die "malformed --author parameter"
+	export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
+fi
 
 PARENTS="-p HEAD"
 if test -z "$initial_commit"

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:50 ` Robin Rosenberg
@ 2007-01-22 21:04   ` J. Bruce Fields
  0 siblings, 0 replies; 7+ messages in thread
From: J. Bruce Fields @ 2007-01-22 21:04 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

On Mon, Jan 22, 2007 at 09:50:16PM +0100, Robin Rosenberg wrote:
> måndag 22 januari 2007 21:37 skrev J. Bruce Fields:
> > If I got the author wrong on a commit, is there a quick way to fix it
> > (e.g. by passing the right arguments or environment variables to commit
> > --amend)?
> 
> Set these:
> GIT_AUTHOR_EMAIL
> GIT_AUTHOR_NAME
> GIT_COMMITTER_EMAIL
> GIT_COMMITTER_NAME

That doesn't seem to work in this case, since with the commands that
take an existing commit as a model (like commit --amend and commit -c),
the author information from the existing commit overrides those
environment variables.  Which is normally what you want.

--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: modifying commit's author
  2007-01-22 20:37 modifying commit's author J. Bruce Fields
  2007-01-22 20:48 ` Junio C Hamano
  2007-01-22 20:50 ` Robin Rosenberg
@ 2007-01-23  7:38 ` Johannes Sixt
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Sixt @ 2007-01-23  7:38 UTC (permalink / raw)
  To: git

"J. Bruce Fields" wrote:
> 
> If I got the author wrong on a commit, is there a quick way to fix it
> (e.g. by passing the right arguments or environment variables to commit
> --amend)?

Use cogito: cg commit --amend -e
You can edit the author name+email in the commit message.

-- Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-01-23  7:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-22 20:37 modifying commit's author J. Bruce Fields
2007-01-22 20:48 ` Junio C Hamano
2007-01-22 21:02   ` J. Bruce Fields
2007-01-22 21:03   ` Junio C Hamano
2007-01-22 20:50 ` Robin Rosenberg
2007-01-22 21:04   ` J. Bruce Fields
2007-01-23  7:38 ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).