From: Andrei Rybak <rybak.a.v@gmail.com>
To: git@vger.kernel.org
Cc: Andrei Rybak <rybak.a.v@gmail.com>
Subject: [PATCH] mailinfo: support Unicode scissors
Date: Mon, 1 Apr 2019 00:01:04 +0200 [thread overview]
Message-ID: <20190331220104.31628-1-rybak.a.v@gmail.com> (raw)
'git am --scissors' allows cutting a patch from an email at a scissors
line. Such a line should contain perforation, i.e. hyphens, and a
scissors symbol. Only ASCII graphics scissors '8<' '>8' '%<' '>%' are
recognized by 'git am --scissors' command at the moment.
Unicode character 'BLACK SCISSORS' (U+2702) has been a part of Unicode
since version 1.0.0 [1]. Since then 'BLACK SCISSORS' also became part
of character set Emoji 1.0, published in 2015 [2]. With its adoption as
an emoji, availability of this character on keyboards has increased.
Support UTF-8 encoding of '✂' in function is_scissors_line, for 'git am
--scissors' to be able to cut at Unicode perforation lines in emails.
Note, that Unicode character '✂' is three bytes in UTF-8 encoding.
1. https://www.unicode.org/versions/Unicode1.0.0/CodeCharts1.pdf
https://www.unicode.org/Public/reconstructed/1.0.0/UnicodeData.txt
2. https://unicode.org/Public/emoji/1.0/emoji-data.txt
Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
---
This applies on top of ar/t4150-remove-cruft merged into next in
commit a0106a8d5c, which also edited the test setup in t4150.
mailinfo.c | 7 +++++++
t/t4150-am.sh | 26 +++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/mailinfo.c b/mailinfo.c
index b395adbdf2..4ef6cdee85 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -701,6 +701,13 @@ static int is_scissors_line(const char *line)
c++;
continue;
}
+ if (!memcmp(c, "✂", 3)) {
+ in_perforation = 1;
+ perforation += 3;
+ scissors += 3;
+ c++;
+ continue;
+ }
in_perforation = 0;
}
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 3f7f750cc8..3ea8e8a2cf 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -77,12 +77,20 @@ test_expect_success 'setup: messages' '
printf "Subject: " >subject-prefix &&
- cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF
+ cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF &&
This line should not be included in the commit message with --scissors enabled.
- - >8 - - remove everything above this line - - >8 - -
EOF
+
+ cat - subject-prefix msg-without-scissors-line >msg-with-unicode-scissors <<-\EOF
+ Lines above unicode scissors line should not be included in the commit
+ message with --scissors enabled.
+
+ - - - ✂ - - - ✂ - - -
+
+ EOF
'
test_expect_success setup '
@@ -161,6 +169,12 @@ test_expect_success setup '
git format-patch --stdout expected-for-no-scissors^ >patch-with-scissors-line.eml &&
git reset --hard HEAD^ &&
+ echo file >file &&
+ git add file &&
+ git commit -F msg-with-unicode-scissors &&
+ git format-patch --stdout HEAD^ >patch-with-unicode-scissors.eml &&
+ git reset --hard HEAD^ &&
+
sed -n -e "3,\$p" msg >file &&
git add file &&
test_tick &&
@@ -421,6 +435,16 @@ test_expect_success 'am --scissors cuts the message at the scissors line' '
test_cmp_rev expected-for-scissors HEAD
'
+test_expect_success 'am --scissors cuts the message at the unicode scissors line' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout second &&
+ git am --scissors patch-with-unicode-scissors.eml &&
+ test_path_is_missing .git/rebase-apply &&
+ git diff --exit-code expected-for-scissors &&
+ test_cmp_rev expected-for-scissors HEAD
+'
+
test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
rm -fr .git/rebase-apply &&
git reset --hard &&
--
2.21.0
next reply other threads:[~2019-03-31 22:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-31 22:01 Andrei Rybak [this message]
2019-03-31 23:09 ` [PATCH] mailinfo: support Unicode scissors SZEDER Gábor
2019-04-01 9:07 ` Junio C Hamano
2019-04-01 10:11 ` Jeff King
2019-04-01 9:27 ` Duy Nguyen
2019-04-01 21:54 ` Andrei Rybak
2019-04-01 21:53 ` [PATCH v2 1/2] mailinfo: use starts_with() for clarity Andrei Rybak
2019-04-01 21:53 ` [PATCH v2 2/2] mailinfo: support Unicode scissors Andrei Rybak
2019-04-02 14:36 ` Jeff King
2019-04-03 6:47 ` Junio C Hamano
2019-04-02 14:28 ` [PATCH v2 1/2] mailinfo: use starts_with() for clarity Jeff King
2021-06-08 20:48 ` [PATCH] mailinfo: use starts_with() when checking scissors Andrei Rybak
2021-06-08 21:57 ` Jeff King
2021-06-09 2:22 ` Junio C Hamano
2021-06-09 3:59 ` Jeff King
2021-06-09 5:11 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190331220104.31628-1-rybak.a.v@gmail.com \
--to=rybak.a.v@gmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).