All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] advice: Add advice.scissors to suppress "do not modify or remove this line"
Date: Sun, 25 Feb 2024 20:21:51 -0800	[thread overview]
Message-ID: <0a7b9172add0a0107e0765a59a798b92161788dd.1708921148.git.josh@joshtriplett.org> (raw)

The scissors line before the diff in a verbose commit, or above all the
comments when using --cleanup=scissors, has the following two lines of
explanation after it:

Do not modify or remove the line above.
Everything below it will be ignored.

This is useful advice for new users, but potentially redundant for
experienced users, who might instead appreciate seeing two more lines of
information in their editor.

Add advice.scissors to suppress that explanation.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
 Documentation/config/advice.txt | 5 +++++
 advice.c                        | 1 +
 advice.h                        | 1 +
 wt-status.c                     | 3 ++-
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt
index c7ea70f2e2..33ab688b6c 100644
--- a/Documentation/config/advice.txt
+++ b/Documentation/config/advice.txt
@@ -104,6 +104,11 @@ advice.*::
 	rmHints::
 		In case of failure in the output of linkgit:git-rm[1],
 		show directions on how to proceed from the current state.
+	scissors::
+		Advice shown by linkgit:git-commit[1] in the commit message
+		opened in an editor, after a scissors line (containing >8),
+		saying not to remove the line and that everything after the line
+		will be ignored.
 	sequencerInUse::
 		Advice shown when a sequencer command is already in progress.
 	skippedCherryPicks::
diff --git a/advice.c b/advice.c
index 6e9098ff08..0588012562 100644
--- a/advice.c
+++ b/advice.c
@@ -71,6 +71,7 @@ static struct {
 	[ADVICE_RESET_NO_REFRESH_WARNING]		= { "resetNoRefresh" },
 	[ADVICE_RESOLVE_CONFLICT]			= { "resolveConflict" },
 	[ADVICE_RM_HINTS]				= { "rmHints" },
+	[ADVICE_SCISSORS]				= { "scissors" },
 	[ADVICE_SEQUENCER_IN_USE]			= { "sequencerInUse" },
 	[ADVICE_SET_UPSTREAM_FAILURE]			= { "setUpstreamFailure" },
 	[ADVICE_SKIPPED_CHERRY_PICKS]			= { "skippedCherryPicks" },
diff --git a/advice.h b/advice.h
index 9d4f49ae38..9725aa4199 100644
--- a/advice.h
+++ b/advice.h
@@ -39,6 +39,7 @@ enum advice_type {
 	ADVICE_RESET_NO_REFRESH_WARNING,
 	ADVICE_RESOLVE_CONFLICT,
 	ADVICE_RM_HINTS,
+	ADVICE_SCISSORS,
 	ADVICE_SEQUENCER_IN_USE,
 	ADVICE_SET_UPSTREAM_FAILURE,
 	ADVICE_SKIPPED_CHERRY_PICKS,
diff --git a/wt-status.c b/wt-status.c
index 459d399baa..19d4986351 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1104,7 +1104,8 @@ void wt_status_append_cut_line(struct strbuf *buf)
 	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);
+	if (advice_enabled(ADVICE_SCISSORS))
+		strbuf_add_commented_lines(buf, explanation, strlen(explanation), comment_line_char);
 }
 
 void wt_status_add_cut_line(FILE *fp)
-- 
2.43.0


             reply	other threads:[~2024-02-26  4:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26  4:21 Josh Triplett [this message]
2024-04-16 19:11 ` [PATCH] advice: Add advice.scissors to suppress "do not modify or remove this line" Josh Triplett
2024-04-16 20:35   ` Junio C Hamano
2024-04-16 20:44     ` rsbecker
2024-04-16 22:31       ` Junio C Hamano
2024-04-16 22:52         ` rsbecker
2024-04-17  4:00         ` Dragan Simic
2024-04-16 20:28 ` Rubén Justo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a7b9172add0a0107e0765a59a798b92161788dd.1708921148.git.josh@joshtriplett.org \
    --to=josh@joshtriplett.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.