Re: [PATCH 4/8] revert: change help_msg() to take no argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King wrote:

> You cc'd me, which I guess means you git-blame'd the line in question.
> But you really need to parent-blame about five steps back

Worse, I used ‘git log -- builtin-revert.c’ and stopped reading when
it seemed you must know be current maintainer for that line.  Sorry
about that.

> we could actually make it stash the
> original authorship information somewhere (in addition to the commit
> message template) and then pull it out automatically.

I think that can wait for cherry-pick --continue.

Here’s an ugly patch to use --author.  I call it ugly because the
relevant part of t3507-cherry-pick-conflict.sh output looks like
this:

| Automatic cherry-pick failed.  After resolving the conflicts,
| mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
| and commit the result with: 
| 
|         git commit --author='A U Thor <author@xxxxxxxxxxx>' \
|                     --date='1112912113 -0700'

In other words, the command is long and the date human-unfriendly.

Anyway, given that cherry-pick --continue is just around the corner, I
withdraw my complaint about the ‘commit -c’ version.

Thanks for the pointer.

diff --git a/builtin/revert.c b/builtin/revert.c
index bbafc41..9b8e7d6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -252,9 +252,16 @@ static char *help_msg(void)
 		"and commit the result");
 
 	if (action == CHERRY_PICK) {
+		const char *ident = git_author_info(IDENT_ERROR_ON_NO_NAME);
+		const char *ident_end = ident ? strchr(ident, '>') : NULL;
+		if (!ident_end || ident_end[1] != ' ')
+			die("git_author_info returned nonsense");
 		strbuf_addf(&helpbuf, " with: \n"
 			"\n"
-			"        git commit\n");
+			"        git commit --author='%.*s' \\\n"
+			"                    --date='%s'\n",
+			(int) (ident_end + 1 - ident), ident,
+			ident_end + 2);
 	}
 	else
 		strbuf_addch(&helpbuf, '.');
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]