Merge branch 'jk/filter-branch-use-of-sed-on-incomplete-line' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2015 22:22:39 +0000 (15:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Oct 2015 22:22:39 +0000 (15:22 -0700)
A recent "filter-branch --msg-filter" broke skipping of the commit
object header, which is fixed.

* jk/filter-branch-use-of-sed-on-incomplete-line:
filter-branch: remove multi-line headers in msg filter

git-filter-branch.sh
t/t7003-filter-branch.sh
index 5b3f63d8bbc65e80d1f4278e1ec6e27df604dc9a..fff8093d4f301b96a455a74dc062f7f645b15eed 100755 (executable)
@@ -347,7 +347,7 @@ while read commit parents; do
        fi
 
        {
-               while read -r header_line && test -n "$header_line"
+               while IFS='' read -r header_line && test -n "$header_line"
                do
                        # skip header lines...
                        :;
index 855afda80a1b0dea6d74aa18a96018f59cb2e50b..377c648e04f55359eefa87cdf2ad0c06be0df171 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='git filter-branch'
 . ./test-lib.sh
+. "$TEST_DIRECTORY/lib-gpg.sh"
 
 test_expect_success 'setup' '
        test_commit A &&
@@ -292,6 +293,19 @@ test_expect_success 'Tag name filtering strips gpg signature' '
        test_cmp expect actual
 '
 
+test_expect_success GPG 'Filtering retains message of gpg signed commit' '
+       mkdir gpg &&
+       touch gpg/foo &&
+       git add gpg &&
+       test_tick &&
+       git commit -S -m "Adding gpg" &&
+
+       git log -1 --format="%s" > expect &&
+       git filter-branch -f --msg-filter "cat" &&
+       git log -1 --format="%s" > actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'Tag name filtering allows slashes in tag names' '
        git tag -m tag-with-slash X/1 &&
        git cat-file tag X/1 | sed -e s,X/1,X/2, > expect &&