summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a2d3f5)
raw | patch | inline | side by side (parent: 6a2d3f5)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Aug 2009 03:31:59 +0000 (22:31 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 5 Aug 2009 19:14:00 +0000 (12:14 -0700) |
It is not that uncommon to have mails with DOS line-ending, notably
Thunderbird and web mailers like Gmail (when saving what they call
"original" message). So modify mailsplit to convert CRLF line-endings to
just LF.
Since git-rebase is built on top of git-am, add an option to mailsplit to
be used by git-am when it is acting on behalf of git-rebase, to refrain
from doing this conversion.
And add a test to make sure that rebase still works.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thunderbird and web mailers like Gmail (when saving what they call
"original" message). So modify mailsplit to convert CRLF line-endings to
just LF.
Since git-rebase is built on top of git-am, add an option to mailsplit to
be used by git-am when it is acting on behalf of git-rebase, to refrain
from doing this conversion.
And add a test to make sure that rebase still works.
Signed-off-by: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-mailsplit.c | patch | blob | history | |
git-am.sh | patch | blob | history | |
t/t3400-rebase.sh | patch | blob | history |
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index d288fde2c2cef606a60507a7a56b81352ab5d06e..ee6ca0ebcd0a9ad63da79575f6bc26116b5606c2 100644 (file)
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
}
static struct strbuf buf = STRBUF_INIT;
+static int keep_cr;
/* Called with the first line (potentially partial)
* already in buf[] -- normally that should begin with
* "From " and having something that looks like a date format.
*/
for (;;) {
+ if (!keep_cr && buf.len > 1 && buf.buf[buf.len-1] == '\n' &&
+ buf.buf[buf.len-2] == '\r') {
+ strbuf_setlen(&buf, buf.len-2);
+ strbuf_addch(&buf, '\n');
+ }
+
if (fwrite(buf.buf, 1, buf.len, output) != buf.len)
die_errno("cannot write output");
nr = strtol(arg+2, NULL, 10);
} else if ( arg[1] == 'b' && !arg[2] ) {
allow_bare = 1;
+ } else if (!strcmp(arg, "--keep-cr")) {
+ keep_cr = 1;
} else if ( arg[1] == 'o' && arg[2] ) {
dir = arg+2;
} else if ( arg[1] == '-' && !arg[2] ) {
diff --git a/git-am.sh b/git-am.sh
index d64d9975358a6b9a18596c45b13434463903a344..985226bfecb8a208fda1f57cec80870c79e289dc 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
split_patches () {
case "$patch_format" in
mbox)
- git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||
+ case "$rebasing" in
+ '')
+ keep_cr= ;;
+ ?*)
+ keep_cr=--keep-cr ;;
+ esac
+ git mailsplit -d"$prec" -o"$dotest" -b $keep_cr -- "$@" > "$dotest/last" ||
clean_abort
;;
stgit-series)
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index c5c29ccc4f372723fc77c1af0d7cb7879b92729f..4e6a44b623c456dc85f9daa6c4b5b1f0789c93c5 100755 (executable)
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
# Copyright (c) 2005 Amos Waterland
#
-test_description='git rebase should not destroy author information
+test_description='git rebase assorted tests
-This test runs git rebase and checks that the author information is not lost.
+This test runs git rebase and checks that the author information is not lost
+among other things.
'
. ./test-lib.sh
test ! -s output.out
'
+q_to_cr () {
+ tr Q '\015'
+}
+
+test_expect_success 'Rebase a commit that sprinkles CRs in' '
+ (
+ echo "One"
+ echo "TwoQ"
+ echo "Three"
+ echo "FQur"
+ echo "Five"
+ ) | q_to_cr >CR &&
+ git add CR &&
+ test_tick &&
+ git commit -a -m "A file with a line with CR" &&
+ git tag file-with-cr &&
+ git checkout HEAD^0 &&
+ git rebase --onto HEAD^^ HEAD^ &&
+ git diff --exit-code file-with-cr:CR HEAD:CR
+'
+
test_done