@matheusbsbs / matheus-bagliano / commits / ca6b91d29b
Fork 0

format-patch let -k override a config-specified format.numbered

Let a command-line --keep-subject (-k) override a config-specified format.numbered (--numbered (-n)), rather than provoking the "-n and -k are mutually exclusive" failure. * t4021-format-patch-numbered.sh: Test for the above Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jim Meyering committed May 9, 2009 at 10:12 UTC ca6b91d29b7ea937b71f62bf00ba7750f3e594ce
2 files changed +20 -1
builtin-log.c
+13 -1
@@ -755,6 +755,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
755 int cover_letter = 0;
756 int boundary_count = 0;
757 int no_binary_diff = 0;
758 + int numbered_cmdline_opt = 0;
759 struct commit *origin = NULL, *head = NULL;
760 const char *in_reply_to = NULL;
761 struct patch_ids ids;
@@ -786,8 +787,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
787 if (!strcmp(argv[i], "--stdout"))
788 use_stdout = 1;
789 else if (!strcmp(argv[i], "-n") ||
789 - !strcmp(argv[i], "--numbered"))
790 + !strcmp(argv[i], "--numbered")) {
791 numbered = 1;
792 + numbered_cmdline_opt = 1;
793 + }
794 else if (!strcmp(argv[i], "-N") ||
795 !strcmp(argv[i], "--no-numbered")) {
796 numbered = 0;
@@ -918,6 +921,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
921
922 if (start_number < 0)
923 start_number = 1;
924 +
925 + /*
926 + * If numbered is set solely due to format.numbered in config,
927 + * and it would conflict with --keep-subject (-k) from the
928 + * command line, reset "numbered".
929 + */
930 + if (numbered && keep_subject && !numbered_cmdline_opt)
931 + numbered = 0;
932 +
933 if (numbered && keep_subject)
934 die ("-n and -k are mutually exclusive.");
935 if (keep_subject && subject_prefix)
t/t4021-format-patch-numbered.sh
+7
@@ -86,6 +86,13 @@ test_expect_success 'format.numbered && --no-numbered' '
86
87 '
88
89 +test_expect_success 'format.numbered && --keep-subject' '
90 +
91 + git format-patch --keep-subject --stdout HEAD^ >patch4a &&
92 + grep "^Subject: Third" patch4a
93 +
94 +'
95 +
96 test_expect_success 'format.numbered = auto' '
97
98 git config format.numbered auto