Skip to content

Commit 1d1876e

Browse files
hvoigtgitster
authored andcommitted
Add configuration variable for sign-off to format-patch
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43acdf2 commit 1d1876e

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Documentation/config.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,13 @@ format.thread::
715715
A true boolean value is the same as `shallow`, and a false
716716
value disables threading.
717717

718+
format.signoff::
719+
A boolean value which lets you enable the `-s/--signoff` option of
720+
format-patch by default. *Note:* Adding the Signed-off-by: line to a
721+
patch should be a conscious act and means that you certify you have
722+
the rights to submit this work under the same open source license.
723+
Please see the 'SubmittingPatches' document for further discussion.
724+
718725
gc.aggressiveWindow::
719726
The window size parameter used in the delta compression
720727
algorithm used by 'git-gc --aggressive'. This defaults

Documentation/git-format-patch.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ more than one.
205205
numbered = auto
206206
cc = <email>
207207
attach [ = mime-boundary-string ]
208+
signoff = true
208209
------------
209210

210211

builtin-log.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ static void add_header(const char *value)
465465
#define THREAD_SHALLOW 1
466466
#define THREAD_DEEP 2
467467
static int thread = 0;
468+
static int do_signoff = 0;
468469

469470
static int git_format_config(const char *var, const char *value, void *cb)
470471
{
@@ -514,6 +515,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
514515
thread = git_config_bool(var, value) && THREAD_SHALLOW;
515516
return 0;
516517
}
518+
if (!strcmp(var, "format.signoff")) {
519+
do_signoff = git_config_bool(var, value);
520+
return 0;
521+
}
517522

518523
return git_log_config(var, value, cb);
519524
}
@@ -865,13 +870,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
865870
}
866871
else if (!strcmp(argv[i], "--signoff") ||
867872
!strcmp(argv[i], "-s")) {
868-
const char *committer;
869-
const char *endpos;
870-
committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
871-
endpos = strchr(committer, '>');
872-
if (!endpos)
873-
die("bogus committer info %s", committer);
874-
add_signoff = xmemdupz(committer, endpos - committer + 1);
873+
do_signoff = 1;
875874
}
876875
else if (!strcmp(argv[i], "--attach")) {
877876
rev.mime_boundary = git_version_string;
@@ -925,6 +924,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
925924
}
926925
argc = j;
927926

927+
if (do_signoff) {
928+
const char *committer;
929+
const char *endpos;
930+
committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
931+
endpos = strchr(committer, '>');
932+
if (!endpos)
933+
die("bogus committer info %s", committer);
934+
add_signoff = xmemdupz(committer, endpos - committer + 1);
935+
}
936+
928937
for (i = 0; i < extra_hdr_nr; i++) {
929938
strbuf_addstr(&buf, extra_hdr[i]);
930939
strbuf_addch(&buf, '\n');

0 commit comments

Comments
 (0)