]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/core-comment-string'
authorJunio C Hamano <gitster@pobox.com>
Fri, 5 Apr 2024 17:49:49 +0000 (10:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Apr 2024 17:49:49 +0000 (10:49 -0700)
core.commentChar used to be limited to a single byte, but has been
updated to allow an arbitrary multi-byte sequence.

* jk/core-comment-string:
  config: add core.commentString
  config: allow multi-byte core.commentChar
  environment: drop comment_line_char compatibility macro
  wt-status: drop custom comment-char stringification
  sequencer: handle multi-byte comment characters when writing todo list
  find multi-byte comment chars in unterminated buffers
  find multi-byte comment chars in NUL-terminated strings
  prefer comment_line_str to comment_line_char for printing
  strbuf: accept a comment string for strbuf_add_commented_lines()
  strbuf: accept a comment string for strbuf_commented_addf()
  strbuf: accept a comment string for strbuf_stripspace()
  environment: store comment_line_char as a string
  strbuf: avoid shadowing global comment_line_char name
  commit: refactor base-case of adjust_comment_line_char()
  strbuf: avoid static variables in strbuf_add_commented_lines()
  strbuf: simplify comment-handling in add_lines() helper
  config: forbid newline as core.commentChar

17 files changed:
1  2 
builtin/am.c
builtin/branch.c
builtin/commit.c
builtin/merge.c
builtin/rebase.c
builtin/tag.c
builtin/worktree.c
commit.c
config.c
environment.c
environment.h
sequencer.c
strbuf.c
strbuf.h
t/t7508-status.sh
trailer.c
wt-status.c

diff --cc builtin/am.c
Simple merge
Simple merge
index b27b56c8bef3ea0c968392095519017151709ca2,e04f1236e857f440988d6f231d93b5d771191909..7ba7201cfb9160dc062e50f64b875e59d0405c6a
@@@ -943,12 -945,12 +944,12 @@@ static int prepare_to_commit(const cha
  
                fprintf(s->fp, "\n");
                if (cleanup_mode == COMMIT_MSG_CLEANUP_ALL)
-                       status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_char);
+                       status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_all, comment_line_str);
                else if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS) {
 -                      if (whence == FROM_COMMIT && !merge_contains_scissors)
 -                              wt_status_add_cut_line(s->fp);
 +                      if (whence == FROM_COMMIT)
 +                              wt_status_add_cut_line(s);
                } else /* COMMIT_MSG_CLEANUP_SPACE, that is. */
-                       status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_char);
+                       status_printf(s, GIT_COLOR_NORMAL, hint_cleanup_space, comment_line_str);
  
                /*
                 * These should never fail because they come from our own
diff --cc builtin/merge.c
Simple merge
Simple merge
diff --cc builtin/tag.c
Simple merge
Simple merge
diff --cc commit.c
Simple merge
diff --cc config.c
Simple merge
diff --cc environment.c
Simple merge
diff --cc environment.h
Simple merge
diff --cc sequencer.c
Simple merge
diff --cc strbuf.c
Simple merge
diff --cc strbuf.h
Simple merge
Simple merge
diff --cc trailer.c
Simple merge
diff --cc wt-status.c
index 2db4bb3a1293bb69e081efcf98489a63ca2d812a,823e8e81b0664cccb43c9ac80f9225faf8ef3c0e..bdfc23e2ae7de8a9521c03420448e412d4262d84
@@@ -1090,14 -1090,11 +1090,14 @@@ size_t wt_status_locate_end(const char 
        const char *p;
        struct strbuf pattern = STRBUF_INIT;
  
-       strbuf_addf(&pattern, "\n%c %s", comment_line_char, cut_line);
+       strbuf_addf(&pattern, "\n%s %s", comment_line_str, cut_line);
        if (starts_with(s, pattern.buf + 1))
                len = 0;
 -      else if ((p = strstr(s, pattern.buf)))
 -              len = p - s + 1;
 +      else if ((p = strstr(s, pattern.buf))) {
 +              size_t newlen = p - s + 1;
 +              if (newlen < len)
 +                      len = newlen;
 +      }
        strbuf_release(&pattern);
        return len;
  }
@@@ -1106,11 -1103,11 +1106,11 @@@ void wt_status_append_cut_line(struct s
  {
        const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored.");
  
-       strbuf_commented_addf(buf, comment_line_char, "%s", cut_line);
-       strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_char);
+       strbuf_commented_addf(buf, comment_line_str, "%s", cut_line);
+       strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_str);
  }
  
 -void wt_status_add_cut_line(FILE *fp)
 +void wt_status_add_cut_line(struct wt_status *s)
  {
        struct strbuf buf = STRBUF_INIT;