git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Add configuration variable for sign-off to format-patch
Date: Tue, 31 Mar 2009 20:50:19 +0200	[thread overview]
Message-ID: <20090331185018.GD72569@macbook.lan> (raw)

If you regularly create patches which require a Signed-off: line you may
want to make it your default to add that line. It also helps you not to forget
to add the -s/--signoff switch.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---

Because it happened to me twice already that I forgot to add the switch.

 Documentation/config.txt           |    4 ++++
 Documentation/git-format-patch.txt |    1 +
 builtin-log.c                      |   23 ++++++++++++++++-------
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ad22cb8..ed85536 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -715,6 +715,10 @@ format.thread::
 	A true boolean value is the same as `shallow`, and a false
 	value disables threading.
 
+format.signoff::
+	This lets you enable the -s/--signoff option of format-patch by
+	default. It takes a boolean value.
+
 gc.aggressiveWindow::
 	The window size parameter used in the delta compression
 	algorithm used by 'git-gc --aggressive'.  This defaults
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index c2eb5fa..c25ea10 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -197,6 +197,7 @@ more than one.
 	numbered = auto
 	cc = <email>
 	attach [ = mime-boundary-string ]
+	signoff = true
 ------------
 
 
diff --git a/builtin-log.c b/builtin-log.c
index c7a5772..d77b7fb 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -465,6 +465,7 @@ static void add_header(const char *value)
 #define THREAD_SHALLOW 1
 #define THREAD_DEEP 2
 static int thread = 0;
+static int do_signoff = 0;
 
 static int git_format_config(const char *var, const char *value, void *cb)
 {
@@ -514,6 +515,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
 		thread = git_config_bool(var, value) && THREAD_SHALLOW;
 		return 0;
 	}
+	if (!strcmp(var, "format.signoff")) {
+		do_signoff = git_config_bool(var, value);
+		return 0;
+	}
 
 	return git_log_config(var, value, cb);
 }
@@ -865,13 +870,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 		}
 		else if (!strcmp(argv[i], "--signoff") ||
 			 !strcmp(argv[i], "-s")) {
-			const char *committer;
-			const char *endpos;
-			committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
-			endpos = strchr(committer, '>');
-			if (!endpos)
-				die("bogus committer info %s", committer);
-			add_signoff = xmemdupz(committer, endpos - committer + 1);
+			do_signoff = 1;
 		}
 		else if (!strcmp(argv[i], "--attach")) {
 			rev.mime_boundary = git_version_string;
@@ -923,6 +922,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	}
 	argc = j;
 
+	if(do_signoff) {
+		const char *committer;
+		const char *endpos;
+		committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
+		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[i]);
 		strbuf_addch(&buf, '\n');
-- 
1.6.2.1.424.g0b27.dirty

             reply	other threads:[~2009-03-31 18:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-31 18:50 Heiko Voigt [this message]
2009-03-31 19:47 ` [PATCH] Add configuration variable for sign-off to format-patch Andreas Ericsson
2009-04-01 17:53   ` Heiko Voigt
2009-03-31 20:04 ` Jeff King
2009-03-31 20:43   ` Heiko Voigt
2009-04-01 10:26     ` Jeff King
2009-04-01 17:51       ` [PATCH v2] " Heiko Voigt
2009-04-01 17:55         ` Sverre Rabbelier
2009-04-06  8:14         ` Junio C Hamano
2009-04-06 10:58           ` Andreas Ericsson
2009-04-06 11:36             ` Matthieu Moy
2009-04-06 18:09               ` Heiko Voigt
2009-04-07  7:23             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090331185018.GD72569@macbook.lan \
    --to=hvoigt@hvoigt.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).