Skip to content

Commit 2709a19

Browse files
committed
Merge branch 'pw/3.0-commentchar-auto-deprecation' into jch
Proposes to deprecate "core.commentChar=auto" that attempts to dynamically pick a suitable comment character, as it is too much trouble to support for little benefit. Comments? * pw/3.0-commentchar-auto-deprecation: commit: print advice when core.commentString=auto config: warn on core.commentString=auto breaking-changes: deprecate support for core.commentString=auto
2 parents a1ea9d1 + 3f188a0 commit 2709a19

14 files changed

+424
-13
lines changed

Documentation/BreakingChanges.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ These features will be removed.
239239
+
240240
The command will be removed.
241241

242+
* Support for `core.commentString=auto` has been deprecated and will
243+
be removed in Git 3.0.
244+
+
245+
246+
242247
== Superseded features that will not be deprecated
243248

244249
Some features have gained newer replacements that aim to improve the design in

Documentation/config/core.adoc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,25 @@ core.commentString::
531531
commented, and removes them after the editor returns
532532
(default '#').
533533
+
534-
If set to "auto", `git-commit` would select a character that is not
534+
ifndef::with-breaking-changes[]
535+
If set to "auto", `git-commit` will select a character that is not
535536
the beginning character of any line in existing commit messages.
536-
+
537+
Support for this value is deprecated and will be removed in Git 3.0
538+
due to the following limitations:
539+
+
540+
--
541+
* It is incompatible with adding comments in a commit message
542+
template. This includes the conflicts comments added to
543+
the commit message by `cherry-pick`, `merge`, `rebase` and
544+
`revert`.
545+
* It is incompatible with adding comments to the commit message
546+
in the `prepare-commit-msg` hook.
547+
* It is incompatible with the `fixup` and `squash` commands when
548+
rebasing,
549+
* It is not respected by `git notes`
550+
--
551+
+
552+
endif::with-breaking-changes[]
537553
Note that these two variables are aliases of each other, and in modern
538554
versions of Git you are free to use a string (e.g., `//` or `⁑⁕⁑`) with
539555
`commentChar`. Versions of Git prior to v2.45.0 will ignore

builtin/commit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ static int author_date_is_interesting(void)
695695
return author_message || force_date;
696696
}
697697

698+
#ifndef WITH_BREAKING_CHANGES
698699
static void adjust_comment_line_char(const struct strbuf *sb)
699700
{
700701
char candidates[] = "#;@!$%^&|:";
@@ -732,6 +733,7 @@ static void adjust_comment_line_char(const struct strbuf *sb)
732733
free(comment_line_str_to_free);
733734
comment_line_str = comment_line_str_to_free = xstrfmt("%c", *p);
734735
}
736+
#endif /* !WITH_BREAKING_CHANGES */
735737

736738
static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
737739
struct pretty_print_context *ctx)
@@ -928,8 +930,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
928930
if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
929931
die_errno(_("could not write commit template"));
930932

933+
#ifndef WITH_BREAKING_CHANGES
931934
if (auto_comment_line_char)
932935
adjust_comment_line_char(&sb);
936+
#endif /* !WITH_BREAKING_CHANGES */
933937
strbuf_release(&sb);
934938

935939
/* This checks if committer ident is explicitly given */
@@ -1793,6 +1797,9 @@ int cmd_commit(int argc,
17931797
show_usage_with_options_if_asked(argc, argv,
17941798
builtin_commit_usage, builtin_commit_options);
17951799

1800+
#ifndef WITH_BREAKING_CHANGES
1801+
warn_on_auto_comment_char = true;
1802+
#endif /* !WITH_BREAKING_CHANGES */
17961803
prepare_repo_settings(the_repository);
17971804
the_repository->settings.command_requires_full_index = 0;
17981805

builtin/merge.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,9 @@ int cmd_merge(int argc,
13781378
show_usage_with_options_if_asked(argc, argv,
13791379
builtin_merge_usage, builtin_merge_options);
13801380

1381+
#ifndef WITH_BREAKING_CHANGES
1382+
warn_on_auto_comment_char = true;
1383+
#endif /* !WITH_BREAKING_CHANGES */
13811384
prepare_repo_settings(the_repository);
13821385
the_repository->settings.command_requires_full_index = 0;
13831386

builtin/rebase.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,9 @@ int cmd_rebase(int argc,
12421242
builtin_rebase_usage,
12431243
builtin_rebase_options);
12441244

1245+
#ifndef WITH_BREAKING_CHANGES
1246+
warn_on_auto_comment_char = true;
1247+
#endif /* !WITH_BREAKING_CHANGES */
12451248
prepare_repo_settings(the_repository);
12461249
the_repository->settings.command_requires_full_index = 0;
12471250

builtin/revert.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "builtin.h"
55
#include "parse-options.h"
66
#include "diff.h"
7+
#include "environment.h"
78
#include "gettext.h"
89
#include "revision.h"
910
#include "rerere.h"
@@ -285,6 +286,9 @@ int cmd_revert(int argc,
285286
struct replay_opts opts = REPLAY_OPTS_INIT;
286287
int res;
287288

289+
#ifndef WITH_BREAKING_CHANGES
290+
warn_on_auto_comment_char = true;
291+
#endif /* !WITH_BREAKING_CHANGES */
288292
opts.action = REPLAY_REVERT;
289293
sequencer_init_config(&opts);
290294
res = run_sequencer(argc, argv, prefix, &opts);
@@ -302,6 +306,9 @@ struct repository *repo UNUSED)
302306
struct replay_opts opts = REPLAY_OPTS_INIT;
303307
int res;
304308

309+
#ifndef WITH_BREAKING_CHANGES
310+
warn_on_auto_comment_char = true;
311+
#endif /* !WITH_BREAKING_CHANGES */
305312
opts.action = REPLAY_PICK;
306313
sequencer_init_config(&opts);
307314
res = run_sequencer(argc, argv, prefix, &opts);

0 commit comments

Comments
 (0)