summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f43c97f)
raw | patch | inline | side by side (parent: f43c97f)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 27 Aug 2009 04:36:05 +0000 (21:36 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 27 Aug 2009 05:22:22 +0000 (22:22 -0700) |
You can enable it by giving --scissors to "git am".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-am.txt | patch | blob | history | |
Documentation/git-mailinfo.txt | patch | blob | history | |
builtin-mailinfo.c | patch | blob | history | |
git-am.sh | patch | blob | history | |
t/t5100-mailinfo.sh | patch | blob | history | |
t/t5100/info0014 | patch | blob | history | |
t/t5100/info0014--scissors | [new file with mode: 0644] | patch | blob |
t/t5100/msg0014 | patch | blob | history | |
t/t5100/msg0014--scissors | [new file with mode: 0644] | patch | blob |
t/t5100/patch0014--scissors | [new file with mode: 0644] | patch | blob |
index e6ab3dfa577e36f50d4aa59864f827babcd8f84e..87781f4a7789c8cc9be03e77b0cfe37b13c6e9c0 100644 (file)
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
[--3way] [--interactive] [--committer-date-is-author-date]
[--ignore-date] [--ignore-space-change | --ignore-whitespace]
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
- [--reject] [-q | --quiet]
+ [--reject] [-q | --quiet] [--scissors]
[<mbox> | <Maildir>...]
'git am' (--skip | --resolved | --abort)
--keep::
Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
+-c::
+--scissors::
+ Remove everything in body before a scissors line (see
+ linkgit:git-mailinfo[1]).
+
-q::
--quiet::
Be quiet. Only print error messages.
The "Subject: " line is supposed to concisely describe what the
commit is about in one line of text.
-A line that mainly consists of scissors (either ">8" or "8<") and
-perforation (dash "-") marks is called a scissors line, and is used to
-request the reader to cut the message at that line. If such a line
-appears in the body of the message before the patch, everything before it
-(including the scissors line itself) is ignored. This is useful if you
-want to begin your message in a discussion thread with comments and
-suggestions on the message you are responding to, and to conclude it with
-a patch submission, separating the discussion and the beginning of the
-proposed commit log message with a scissors line.
-
"From: " and "Subject: " lines starting the body override the respective
commit author name and title values taken from the headers.
index 8d95aaa30441c36a019e9d3d78ec451fbd40fdaf..823ab82b5e88c76d359db600b0d0f506758fca0c 100644 (file)
SYNOPSIS
--------
-'git mailinfo' [-k] [-u | --encoding=<encoding> | -n] <msg> <patch>
+'git mailinfo' [-k] [-u | --encoding=<encoding> | -n] [--scissors] <msg> <patch>
DESCRIPTION
-n::
Disable all charset re-coding of the metadata.
+--scissors::
+ Remove everything in body before a scissors line. A line that
+ mainly consists of scissors (either ">8" or "8<") and perforation
+ (dash "-") marks is called a scissors line, and is used to request
+ the reader to cut the message at that line. If such a line
+ appears in the body of the message before the patch, everything
+ before it (including the scissors line itself) is ignored when
+ this option is used.
++
+This is useful if you want to begin your message in a discussion thread
+with comments and suggestions on the message you are responding to, and to
+conclude it with a patch submission, separating the discussion and the
+beginning of the proposed commit log message with a scissors line.
+
<msg>::
The commit log message extracted from e-mail, usually
except the title line which comes from e-mail Subject.
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index a6f6b123b46e35b468d91342368c9cd9385c8bd1..1c14d381d23074d1c6b2a2180c25629974e3b5c4 100644 (file)
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
static struct strbuf charset = STRBUF_INIT;
static int patch_lines;
static struct strbuf **p_hdr_data, **s_hdr_data;
+static int use_scissors;
#define MAX_HDR_PARSED 10
#define MAX_BOUNDARIES 5
if (metainfo_charset)
convert_to_utf8(line, charset.buf);
- if (is_scissors_line(line)) {
+ if (use_scissors && is_scissors_line(line)) {
int i;
rewind(cmitmsg);
ftruncate(fileno(cmitmsg), 0);
metainfo_charset = NULL;
else if (!prefixcmp(argv[1], "--encoding="))
metainfo_charset = argv[1] + 11;
+ else if (!strcmp(argv[1], "--scissors"))
+ use_scissors = 1;
+ else if (!strcmp(argv[1], "--no-scissors"))
+ use_scissors = 0;
else
usage(mailinfo_usage);
argc--; argv++;
diff --git a/git-am.sh b/git-am.sh
index 3c03f3e0df96f7b993db1c3822d3f3dab8741a4b..26ffe702e04e990113eb287f01be815d4ac8ad0a 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default)
k,keep pass -k flag to git-mailinfo
+c,scissors strip everything before a scissors line
whitespace= pass it through git-apply
ignore-space-change pass it through git-apply
ignore-whitespace pass it through git-apply
prec=4
dotest="$GIT_DIR/rebase-apply"
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
-resolvemsg= resume=
+resolvemsg= resume= scissors=
git_apply_opt=
committer_date_is_author_date=
ignore_date=
utf8= ;;
-k|--keep)
keep=t ;;
+ -c|--scissors)
+ scissors=t ;;
+ --no-scissors)
+ scissors=f ;;
-r|--resolved)
resolved=t ;;
--skip)
--abort)
abort=t ;;
--rebasing)
- rebasing=t threeway=t keep=t ;;
+ rebasing=t threeway=t keep=t scissors=f ;;
-d|--dotest)
die "-d option is no longer supported. Do not use."
;;
split_patches "$@"
- # -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept
- # for the resuming session after a patch failure.
- # -i can and must be given when resuming.
+ # -i can and must be given when resuming; everything
+ # else is kept
echo " $git_apply_opt" >"$dotest/apply-opt"
echo "$threeway" >"$dotest/threeway"
echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
+ echo "$scissors" >"$dotest/scissors"
echo "$GIT_QUIET" >"$dotest/quiet"
echo 1 >"$dotest/next"
if test -n "$rebasing"
then
keep=-k
fi
+case "$(cat "$dotest/scissors")" in
+t)
+ scissors=--scissors ;;
+f)
+ scissors=--no-scissors ;;
+esac
if test "$(cat "$dotest/quiet")" = t
then
GIT_QUIET=t
# by the user, or the user can tell us to do so by --resolved flag.
case "$resume" in
'')
- git mailinfo $keep $utf8 "$dotest/msg" "$dotest/patch" \
+ git mailinfo $keep $scissors $utf8 "$dotest/msg" "$dotest/patch" \
<"$dotest/$msgnum" >"$dotest/info" ||
stop_here $this
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index e84855665972d39f01f9eb37e1331b4a13142058..0279d07c83b1eb6cbcf2add5fc1afd8a27d63fbd 100755 (executable)
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
echo total is $last &&
test `cat last` = 14'
+check_mailinfo () {
+ mail=$1 opt=$2
+ mo="$mail$opt"
+ git mailinfo -u $opt msg$mo patch$mo <$mail >info$mo &&
+ test_cmp "$TEST_DIRECTORY"/t5100/msg$mo msg$mo &&
+ test_cmp "$TEST_DIRECTORY"/t5100/patch$mo patch$mo &&
+ test_cmp "$TEST_DIRECTORY"/t5100/info$mo info$mo
+}
+
+
for mail in `echo 00*`
do
test_expect_success "mailinfo $mail" '
- git mailinfo -u msg$mail patch$mail <$mail >info$mail &&
- echo msg &&
- test_cmp "$TEST_DIRECTORY"/t5100/msg$mail msg$mail &&
- echo patch &&
- test_cmp "$TEST_DIRECTORY"/t5100/patch$mail patch$mail &&
- echo info &&
- test_cmp "$TEST_DIRECTORY"/t5100/info$mail info$mail
+ check_mailinfo $mail "" &&
+ if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors
+ then
+ check_mailinfo $mail --scissors
+ fi
'
done
diff --git a/t/t5100/info0014 b/t/t5100/info0014
index ab9c8d09059417b7fab87af0dfee2cd20212d8d9..08566b34b978d090c710ce54357b2457590a55dc 100644 (file)
--- a/t/t5100/info0014
+++ b/t/t5100/info0014
-Author: Junio C Hamano
-Email: gitster@pobox.com
-Subject: Teach mailinfo to ignore everything before -- >8 -- mark
+Author: Junio Hamano
+Email: junkio@cox.net
+Subject: BLAH ONE
Date: Thu, 20 Aug 2009 17:18:22 -0700
diff --git a/t/t5100/info0014--scissors b/t/t5100/info0014--scissors
--- /dev/null
@@ -0,0 +1,5 @@
+Author: Junio C Hamano
+Email: gitster@pobox.com
+Subject: Teach mailinfo to ignore everything before -- >8 -- mark
+Date: Thu, 20 Aug 2009 17:18:22 -0700
+
diff --git a/t/t5100/msg0014 b/t/t5100/msg0014
index 259c6a46d26a636c9fa7a09546c12b83b4c139c4..62e5cd2ecd1e2828ef873fcdeb653d9466dbabf7 100644 (file)
--- a/t/t5100/msg0014
+++ b/t/t5100/msg0014
+In real life, we will see a discussion that inspired this patch
+discussing related and unrelated things around >8 scissors mark
+in this part of the message.
+
+Subject: [PATCH] BLAH TWO
+
+And then we will see the scissors.
+
+ This line is not a scissors mark -- >8 -- but talks about it.
+ - - >8 - - please remove everything above this line - - >8 - -
+
+Subject: [PATCH] Teach mailinfo to ignore everything before -- >8 -- mark
+From: Junio C Hamano <gitster@pobox.com>
+
This teaches mailinfo the scissors -- >8 -- mark; the command ignores
everything before it in the message body.
diff --git a/t/t5100/msg0014--scissors b/t/t5100/msg0014--scissors
--- /dev/null
@@ -0,0 +1,4 @@
+This teaches mailinfo the scissors -- >8 -- mark; the command ignores
+everything before it in the message body.
+
+Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/t/t5100/patch0014--scissors b/t/t5100/patch0014--scissors
--- /dev/null
@@ -0,0 +1,64 @@
+---
+ builtin-mailinfo.c | 37 ++++++++++++++++++++++++++++++++++++-
+ 1 files changed, 36 insertions(+), 1 deletions(-)
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index b0b5d8f..461c47e 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -712,6 +712,34 @@ static inline int patchbreak(const struct strbuf *line)
+ return 0;
+ }
+
++static int scissors(const struct strbuf *line)
++{
++ size_t i, len = line->len;
++ int scissors_dashes_seen = 0;
++ const char *buf = line->buf;
++
++ for (i = 0; i < len; i++) {
++ if (isspace(buf[i]))
++ continue;
++ if (buf[i] == '-') {
++ scissors_dashes_seen |= 02;
++ continue;
++ }
++ if (i + 1 < len && !memcmp(buf + i, ">8", 2)) {
++ scissors_dashes_seen |= 01;
++ i++;
++ continue;
++ }
++ if (i + 7 < len && !memcmp(buf + i, "cut here", 8)) {
++ i += 7;
++ continue;
++ }
++ /* everything else --- not scissors */
++ break;
++ }
++ return scissors_dashes_seen == 03;
++}
++
+ static int handle_commit_msg(struct strbuf *line)
+ {
+ static int still_looking = 1;
+@@ -723,10 +751,17 @@ static int handle_commit_msg(struct strbuf *line)
+ strbuf_ltrim(line);
+ if (!line->len)
+ return 0;
+- if ((still_looking = check_header(line, s_hdr_data, 0)) != 0)
++ still_looking = check_header(line, s_hdr_data, 0);
++ if (still_looking)
+ return 0;
+ }
+
++ if (scissors(line)) {
++ fseek(cmitmsg, 0L, SEEK_SET);
++ still_looking = 1;
++ return 0;
++ }
++
+ /* normalize the log message to UTF-8. */
+ if (metainfo_charset)
+ convert_to_utf8(line, charset.buf);
+--
+1.6.4.1