diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-06-22 09:45:22 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-22 09:45:22 -0700 |
commit | 6bead0c3203431ca63a6b1e7cf47c659f1a7021d (patch) | |
tree | 4d5d44220f9922186cc9132b483ccfbdfd5c42ea | |
parent | 223a923c37f76ee91eb6a9cb77ce6d31dcf939cc (diff) | |
parent | d8e1e5df950f2c514a01696a0a0ff53fb1a07651 (diff) | |
download | git-6bead0c3203431ca63a6b1e7cf47c659f1a7021d.tar.gz git-6bead0c3203431ca63a6b1e7cf47c659f1a7021d.tar.xz |
Merge branch 'sb/format-patch-signature'
* sb/format-patch-signature:
completion: Add --signature and format.signature
format-patch: Add a signature option (--signature)
-rw-r--r-- | Documentation/config.txt | 6 | ||||
-rw-r--r-- | Documentation/git-format-patch.txt | 7 | ||||
-rw-r--r-- | builtin/log.c | 18 | ||||
-rwxr-xr-x | contrib/completion/git-completion.bash | 3 | ||||
-rw-r--r-- | t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ | 3 | ||||
-rwxr-xr-x | t/t4014-format-patch.sh | 52 |
6 files changed, 85 insertions, 4 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt index 9f1c785b7..4c491045c 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -889,6 +889,12 @@ format.subjectprefix:: The default for format-patch is to output files with the '[PATCH]' subject prefix. Use this variable to change that prefix. +format.signature:: + The default for format-patch is to output a signature containing + the git version number. Use this variable to change that default. + Set this variable to the empty string ("") to suppress + signature generation. + format.suffix:: The default for format-patch is to output files with the suffix `.patch`. Use this variable to change that suffix (make sure to diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 835fb7135..c8c81e843 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -13,6 +13,7 @@ SYNOPSIS [--no-thread | --thread[=<style>]] [(--attach|--inline)[=<boundary>] | --no-attach] [-s | --signoff] + [--signature=<signature> | --no-signature] [-n | --numbered | -N | --no-numbered] [--start-number <n>] [--numbered-files] [--in-reply-to=Message-Id] [--suffix=.<sfx>] @@ -180,6 +181,12 @@ will want to ensure that threading is disabled for `git send-email`. containing the shortlog and the overall diffstat. You can fill in a description in the file before sending it out. +--[no]-signature=<signature>:: + Add a signature to each message produced. Per RFC 3676 the signature + is separated from the body by a line with '-- ' on it. If the + signature option is omitted the signature defaults to the git version + number. + --suffix=.<sfx>:: Instead of using `.patch` as the suffix for generated filenames, use specified suffix. A common alternative is diff --git a/builtin/log.c b/builtin/log.c index 976e16f9f..f06858361 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -549,8 +549,9 @@ 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 thread; +static int do_signoff; +static const char *signature = git_version_string; static int git_format_config(const char *var, const char *value, void *cb) { @@ -609,6 +610,8 @@ static int git_format_config(const char *var, const char *value, void *cb) do_signoff = git_config_bool(var, value); return 0; } + if (!strcmp(var, "format.signature")) + return git_config_string(&signature, var, value); return git_log_config(var, value, cb); } @@ -703,6 +706,12 @@ static void gen_message_id(struct rev_info *info, char *base) info->message_id = strbuf_detach(&buf, NULL); } +static void print_signature(void) +{ + if (signature && *signature) + printf("-- \n%s\n\n", signature); +} + static void make_cover_letter(struct rev_info *rev, int use_stdout, int numbered, int numbered_files, struct commit *origin, @@ -796,6 +805,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, diff_flush(&opts); printf("\n"); + print_signature(); } static const char *clean_message_id(const char *msg_id) @@ -1035,6 +1045,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) { OPTION_CALLBACK, 0, "thread", &thread, "style", "enable message threading, styles: shallow, deep", PARSE_OPT_OPTARG, thread_callback }, + OPT_STRING(0, "signature", &signature, "signature", + "add a signature"), OPT_END() }; @@ -1313,7 +1325,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) mime_boundary_leader, rev.mime_boundary); else - printf("-- \n%s\n\n", git_version_string); + print_signature(); } if (!use_stdout) fclose(stdout); diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index aebb0b689..14874377a 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1052,7 +1052,7 @@ _git_format_patch () --numbered --start-number --numbered-files --keep-subject - --signoff + --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all @@ -1726,6 +1726,7 @@ _git_config () format.headers format.numbered format.pretty + format.signature format.signoff format.subjectprefix format.suffix diff --git a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ index 8dab4bf93..1f0f9ad44 100644 --- a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ +++ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ @@ -18,6 +18,9 @@ A U Thor (2): create mode 100644 file1 delete mode 100644 file2 +-- +g-i-t--v-e-r-s-i-o-n + From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001 From: A U Thor <author@example.com> Date: Mon, 26 Jun 2006 00:01:00 +0000 diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index d21c37f3a..f87434b9f 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -613,4 +613,56 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' git format-patch --ignore-if-in-upstream HEAD ' +test_expect_success 'format-patch --signature' ' + git format-patch --stdout --signature="my sig" -1 >output && + grep "my sig" output +' + +test_expect_success 'format-patch with format.signature config' ' + git config format.signature "config sig" && + git format-patch --stdout -1 >output && + grep "config sig" output +' + +test_expect_success 'format-patch --signature overrides format.signature' ' + git config format.signature "config sig" && + git format-patch --stdout --signature="overrides" -1 >output && + ! grep "config sig" output && + grep "overrides" output +' + +test_expect_success 'format-patch --no-signature ignores format.signature' ' + git config format.signature "config sig" && + git format-patch --stdout --signature="my sig" --no-signature \ + -1 >output && + ! grep "config sig" output && + ! grep "my sig" output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --signature --cover-letter' ' + git config --unset-all format.signature && + git format-patch --stdout --signature="my sig" --cover-letter \ + -1 >output && + grep "my sig" output && + test 2 = $(grep "my sig" output | wc -l) +' + +test_expect_success 'format.signature="" supresses signatures' ' + git config format.signature "" && + git format-patch --stdout -1 >output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --no-signature supresses signatures' ' + git config --unset-all format.signature && + git format-patch --stdout --no-signature -1 >output && + ! grep "^-- \$" output +' + +test_expect_success 'format-patch --signature="" supresses signatures' ' + git format-patch --signature="" -1 >output && + ! grep "^-- \$" output +' + test_done |