diff options
author | Junio C Hamano <junkio@cox.net> | 2006-08-16 17:55:29 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-17 01:23:08 -0700 |
commit | 57dc397cff09bfabd79ddbc38b704cdd0c2bc6e3 (patch) | |
tree | cfcfc11f7699b2e3b355c8ffb98648e9dbe072b7 /t | |
parent | 2cda1a214e9d2e362242027b4b622ecb3d9260de (diff) | |
download | git-57dc397cff09bfabd79ddbc38b704cdd0c2bc6e3.tar.gz git-57dc397cff09bfabd79ddbc38b704cdd0c2bc6e3.tar.xz |
git-apply --reject
With the new flag "--reject", hunks that do not apply are sent to
the standard output, and the usable hunks are applied. The command
itself exits with non-zero status when this happens, so that the
user or wrapper can take notice and sort the remaining mess out.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4117-apply-reject.sh | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh new file mode 100755 index 000000000..3362819c3 --- /dev/null +++ b/t/t4117-apply-reject.sh @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-apply with rejects + +' + +. ./test-lib.sh + +test_expect_success setup ' + for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 + do + echo $i + done >file1 && + cat file1 >saved.file1 && + git update-index --add file1 && + git commit -m initial && + + for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21 + do + echo $i + done >file1 && + git diff >patch.1 && + + mv file1 file2 && + git update-index --add --remove file1 file2 && + git diff -M HEAD >patch.2 && + + rm -f file1 file2 && + mv saved.file1 file1 && + git update-index --add --remove file1 file2 && + + for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21 + do + echo $i + done >file1 && + + cat file1 >saved.file1 +' + +test_expect_success 'apply without --reject should fail' ' + + if git apply patch.1 + then + echo "Eh? Why?" + exit 1 + fi + + diff -u file1 saved.file1 +' + +test_expect_success 'apply with --reject should fail but update the file' ' + + cat saved.file1 >file1 + + if git apply --reject patch.1 >rejects + then + echo "succeeds with --reject?" + exit 1 + fi + cat rejects + for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21 + do + echo $i + done >expected.file1 && + + diff -u file1 expected.file1 +' + +test_expect_success 'apply with --reject should fail but update the file' ' + + cat saved.file1 >file1 + + if git apply --reject patch.2 >rejects + then + echo "succeeds with --reject?" + exit 1 + fi + + cat rejects + + for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21 + do + echo $i + done >expected.file2 && + + test -f file1 && { + echo "file1 still exists?" + exit 1 + } + diff -u file2 expected.file2 +' + +test_done |