Skip to contentSkip to conversation

Unify appending signoff in format-patch, commit and sequencer

PATCH In review Nguyễn Thái Ngọc Duy 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Unify appending signoff in format-patch, commit and sequencer

There are two implementations of append_signoff in log-tree.c and sequencer.c, which do more or less the same thing. This patch

- teaches sequencer.c's append_signoff() not to append the signoff if it's already there but not at the bottom

- removes log-tree.c's

- make sure "Signed-off-by: foo" in the middle of a line is not counted as a sign off

---
Interestingly this patch triggers the fault that it fixes. I was surprised that there was no blank line before my S-o-b and thought I broke something. It turns out I used unmodified format-patch and it mistook the S-o-b quote as true S-o-b line. The modified one puts the blank line back.

 builtin/log.c | 13 +--------
 log-tree.c    | 92 ++++-------------------------------------------------------
 revision.h    |  2 +-
 sequencer.c   | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 88 insertions(+), 105 deletions(-)
builtin/log.c +1 -12
index e7b7db1..bb48344 100644
@@ -1058,7 +1058,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	struct commit *origin = NULL, *head = NULL;
 	const char *in_reply_to = NULL;
 	struct patch_ids ids;
-	char *add_signoff = NULL;
 	struct strbuf buf = STRBUF_INIT;
 	int use_patch_format = 0;
 	int quiet = 0;
@@ -1154,16 +1153,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |
 			     PARSE_OPT_KEEP_DASHDASH);
 
-	if (do_signoff) {
-		const char *committer;
-		const char *endpos;
-		committer = git_committer_info(IDENT_STRICT);
-		endpos = strchr(committer, '>');
-		if (!endpos)
-			die(_("bogus committer info %s"), committer);
-		add_signoff = xmemdupz(committer, endpos - committer + 1);
-	}
-
 	for (i = 0; i < extra_hdr.nr; i++) {
 		strbuf_addstr(&buf, extra_hdr.items[i].string);
 		strbuf_addch(&buf, '\n');
@@ -1354,7 +1343,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		total++;
 		start_number--;
 	}
-	rev.add_signoff = add_signoff;
+	rev.add_signoff = do_signoff;
 	while (0 <= --nr) {
 		int shown;
 		commit = list[nr];
log-tree.c +6 -86

116 lines not on this page · raw message

revision.h +1 -1
index a95bd0b..af35325 100644
@@ -136,7 +136,7 @@ struct rev_info {
 	int		numbered_files;
 	char		*message_id;
 	struct string_list *ref_message_ids;
-	const char	*add_signoff;
+	int              add_signoff;
 	const char	*extra_headers;
 	const char	*log_reencode;
 	const char	*subject_prefix;
sequencer.c +80 -6

101 lines not on this page · raw message

Signature · 1 line
1.8.0.151.g12dbe03
#1 lore raw
Quoted 11 lines · Nguyễn Thái Ngọc Duy

There are two implementations of append_signoff in log-tree.c and sequencer.c, which do more or less the same thing. This patch

- teaches sequencer.c's append_signoff() not to append the signoff if it's already there but not at the bottom

- removes log-tree.c's

- make sure "Signed-off-by: foo" in the middle of a line is not counted as a sign off

Quoted 7 lines

---
Interestingly this patch triggers the fault that it fixes. I was surprised that there was no blank line before my S-o-b and thought I broke something. It turns out I used unmodified format-patch and it mistook the S-o-b quote as true S-o-b line. The modified one puts the blank line back.

Heh, yeah I noticed this bug yesterday when I submitted my changes affecting the same area of code (sequence.c). Glad I didn't waste too much time fixing it.

Have you looked at this:

http://thread.gmane.org/gmane.comp.version-control.git/209781

That series doesn't duplicate your work, but the two series's should be resolved.

-Brandon

#2 lore raw
Quoted 10 lines · Brandon Casey
Quoted 5 lines

Interestingly this patch triggers the fault that it fixes. I was surprised that there was no blank line before my S-o-b and thought I broke something. It turns out I used unmodified format-patch and it mistook the S-o-b quote as true S-o-b line. The modified one puts the blank line back.

Heh, yeah I noticed this bug yesterday when I submitted my changes affecting the same area of code (sequence.c). Glad I didn't waste too much time fixing it.

Quoted 6 lines

Have you looked at this:

   http://thread.gmane.org/gmane.comp.version-control.git/209781

That series doesn't duplicate your work, but the two series's should be resolved.

Thanks I'm watching that discussion now and probably will rebase on top of yours once it's finalized. I actually wrote this patch a while ago, just waiting for nd/builtin-to-libgit to graduate because of some linking issues this patch causes. I can wait a bit longer until yours graduates.

Signature · 1 line
Duy