Alex Riesen | 6fa92bf | 2007-11-12 22:38:23 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='tracking branch update checks for git push' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | test_expect_success 'setup' ' |
| 8 | echo 1 >file && |
| 9 | git add file && |
| 10 | git commit -m 1 && |
| 11 | git branch b1 && |
| 12 | git branch b2 && |
Jeff King | 0b294c0 | 2008-07-08 00:08:02 -0400 | [diff] [blame] | 13 | git branch b3 && |
Alex Riesen | 6fa92bf | 2007-11-12 22:38:23 +0100 | [diff] [blame] | 14 | git clone . aa && |
| 15 | git checkout b1 && |
| 16 | echo b1 >>file && |
| 17 | git commit -a -m b1 && |
| 18 | git checkout b2 && |
| 19 | echo b2 >>file && |
| 20 | git commit -a -m b2 |
| 21 | ' |
| 22 | |
Jeff King | 8736a84 | 2007-11-17 07:54:27 -0500 | [diff] [blame] | 23 | test_expect_success 'prepare pushable branches' ' |
Alex Riesen | 6fa92bf | 2007-11-12 22:38:23 +0100 | [diff] [blame] | 24 | cd aa && |
| 25 | b1=$(git rev-parse origin/b1) && |
| 26 | b2=$(git rev-parse origin/b2) && |
| 27 | git checkout -b b1 origin/b1 && |
| 28 | echo aa-b1 >>file && |
| 29 | git commit -a -m aa-b1 && |
| 30 | git checkout -b b2 origin/b2 && |
| 31 | echo aa-b2 >>file && |
| 32 | git commit -a -m aa-b2 && |
| 33 | git checkout master && |
| 34 | echo aa-master >>file && |
Jeff King | 8736a84 | 2007-11-17 07:54:27 -0500 | [diff] [blame] | 35 | git commit -a -m aa-master |
| 36 | ' |
| 37 | |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 38 | test_expect_success 'mixed-success push returns error' ' |
Junio C Hamano | 2f9ae5f | 2013-01-04 16:04:22 -0800 | [diff] [blame] | 39 | test_must_fail git push origin : |
Stephan Beyer | d492b31 | 2008-07-12 17:47:52 +0200 | [diff] [blame] | 40 | ' |
Jeff King | 8736a84 | 2007-11-17 07:54:27 -0500 | [diff] [blame] | 41 | |
| 42 | test_expect_success 'check tracking branches updated correctly after push' ' |
| 43 | test "$(git rev-parse origin/master)" = "$(git rev-parse master)" |
| 44 | ' |
| 45 | |
| 46 | test_expect_success 'check tracking branches not updated for failed refs' ' |
Alex Riesen | 6fa92bf | 2007-11-12 22:38:23 +0100 | [diff] [blame] | 47 | test "$(git rev-parse origin/b1)" = "$b1" && |
| 48 | test "$(git rev-parse origin/b2)" = "$b2" |
| 49 | ' |
| 50 | |
Jeff King | 1f0e2a1 | 2007-11-17 07:55:15 -0500 | [diff] [blame] | 51 | test_expect_success 'deleted branches have their tracking branches removed' ' |
| 52 | git push origin :b1 && |
| 53 | test "$(git rev-parse origin/b1)" = "origin/b1" |
| 54 | ' |
| 55 | |
Jeff King | 0b294c0 | 2008-07-08 00:08:02 -0400 | [diff] [blame] | 56 | test_expect_success 'already deleted tracking branches ignored' ' |
| 57 | git branch -d -r origin/b3 && |
| 58 | git push origin :b3 >output 2>&1 && |
| 59 | ! grep error output |
| 60 | ' |
| 61 | |
Alex Riesen | 6fa92bf | 2007-11-12 22:38:23 +0100 | [diff] [blame] | 62 | test_done |