| 1 | #!/bin/sh |
| 2 | # Copyright (c) 2006 Karl Hasselström |
| 3 | test_description='Test the import command' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_expect_success \ |
| 7 | 'Initialize the StGIT repository' \ |
| 8 | ' |
| 9 | for x in {do,di,da}{be,bi,bo}{dam,dim,dum}; do |
| 10 | echo $x |
| 11 | done > foo.txt && |
| 12 | git add foo.txt && |
| 13 | git commit -a -m "initial version" && |
| 14 | stg init |
| 15 | ' |
| 16 | |
| 17 | test_expect_success \ |
| 18 | 'Apply a patch created with "git diff"' \ |
| 19 | ' |
| 20 | stg import ../t1800-import/git-diff && |
| 21 | [ $(git cat-file -p $(stg id) \ |
| 22 | | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] && |
| 23 | stg delete .. |
| 24 | ' |
| 25 | |
| 26 | test_expect_success \ |
| 27 | 'Apply a patch created with GNU diff' \ |
| 28 | ' |
| 29 | stg import ../t1800-import/gnu-diff && |
| 30 | [ $(git cat-file -p $(stg id) \ |
| 31 | | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] && |
| 32 | stg delete .. |
| 33 | ' |
| 34 | |
| 35 | test_expect_success \ |
| 36 | 'Apply a patch created with "stg export"' \ |
| 37 | ' |
| 38 | stg import ../t1800-import/stg-export && |
| 39 | [ $(git cat-file -p $(stg id) \ |
| 40 | | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] && |
| 41 | stg delete .. |
| 42 | ' |
| 43 | |
| 44 | test_expect_success \ |
| 45 | 'Apply a patch from an 8bit-encoded e-mail' \ |
| 46 | ' |
| 47 | stg import -m ../t1800-import/email-8bit && |
| 48 | [ $(git cat-file -p $(stg id) \ |
| 49 | | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") == 1 ] && |
| 50 | [ $(git cat-file -p $(stg id) \ |
| 51 | | grep -c "author Inge Ström <inge@power.com>") == 1 ] && |
| 52 | stg delete .. |
| 53 | ' |
| 54 | |
| 55 | test_expect_success \ |
| 56 | 'Apply a patch from a QP-encoded e-mail' \ |
| 57 | ' |
| 58 | stg import -m ../t1800-import/email-qp && |
| 59 | [ $(git cat-file -p $(stg id) \ |
| 60 | | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") == 1 ] && |
| 61 | [ $(git cat-file -p $(stg id) \ |
| 62 | | grep -c "author Inge Ström <inge@power.com>") == 1 ] && |
| 63 | stg delete .. |
| 64 | ' |
| 65 | |
| 66 | test_expect_success \ |
| 67 | 'Apply several patches from an mbox file' \ |
| 68 | ' |
| 69 | stg import -M ../t1800-import/email-mbox && |
| 70 | [ $(git cat-file -p $(stg id change-1) \ |
| 71 | | grep -c "tree 401bef82cd9fb403aba18f480a63844416a2e023") == 1 ] && |
| 72 | [ $(git cat-file -p $(stg id change-1) \ |
| 73 | | grep -c "author Inge Ström <inge@power.com>") == 1 ] && |
| 74 | [ $(git cat-file -p $(stg id change-2) \ |
| 75 | | grep -c "tree e49dbce010ec7f441015a8c64bce0b99108af4cc") == 1 ] && |
| 76 | [ $(git cat-file -p $(stg id change-2) \ |
| 77 | | grep -c "author Inge Ström <inge@power.com>") == 1 ] && |
| 78 | [ $(git cat-file -p $(stg id change-3) \ |
| 79 | | grep -c "tree 166bbaf27a44aee21ba78c98822a741e6f7d78f5") == 1 ] && |
| 80 | [ $(git cat-file -p $(stg id change-3) \ |
| 81 | | grep -c "author Inge Ström <inge@power.com>") == 1 ] && |
| 82 | stg delete .. |
| 83 | ' |
| 84 | |
| 85 | test_done |