Ilari Liusvaara | e9fcd1e | 2010-01-16 23:45:31 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='push with --set-upstream' |
| 4 | . ./test-lib.sh |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 5 | . "$TEST_DIRECTORY"/lib-terminal.sh |
Ilari Liusvaara | e9fcd1e | 2010-01-16 23:45:31 +0200 | [diff] [blame] | 6 | |
Tay Ray Chuan | 2d59ced | 2010-10-17 02:37:01 +0800 | [diff] [blame] | 7 | ensure_fresh_upstream() { |
| 8 | rm -rf parent && git init --bare parent |
| 9 | } |
| 10 | |
Ilari Liusvaara | e9fcd1e | 2010-01-16 23:45:31 +0200 | [diff] [blame] | 11 | test_expect_success 'setup bare parent' ' |
Tay Ray Chuan | 2d59ced | 2010-10-17 02:37:01 +0800 | [diff] [blame] | 12 | ensure_fresh_upstream && |
Ilari Liusvaara | e9fcd1e | 2010-01-16 23:45:31 +0200 | [diff] [blame] | 13 | git remote add upstream parent |
| 14 | ' |
| 15 | |
| 16 | test_expect_success 'setup local commit' ' |
| 17 | echo content >file && |
| 18 | git add file && |
| 19 | git commit -m one |
| 20 | ' |
| 21 | |
| 22 | check_config() { |
| 23 | (echo $2; echo $3) >expect.$1 |
| 24 | (git config branch.$1.remote |
| 25 | git config branch.$1.merge) >actual.$1 |
| 26 | test_cmp expect.$1 actual.$1 |
| 27 | } |
| 28 | |
| 29 | test_expect_success 'push -u master:master' ' |
| 30 | git push -u upstream master:master && |
| 31 | check_config master upstream refs/heads/master |
| 32 | ' |
| 33 | |
| 34 | test_expect_success 'push -u master:other' ' |
| 35 | git push -u upstream master:other && |
| 36 | check_config master upstream refs/heads/other |
| 37 | ' |
| 38 | |
| 39 | test_expect_success 'push -u --dry-run master:otherX' ' |
| 40 | git push -u --dry-run upstream master:otherX && |
| 41 | check_config master upstream refs/heads/other |
| 42 | ' |
| 43 | |
| 44 | test_expect_success 'push -u master2:master2' ' |
| 45 | git branch master2 && |
| 46 | git push -u upstream master2:master2 && |
| 47 | check_config master2 upstream refs/heads/master2 |
| 48 | ' |
| 49 | |
| 50 | test_expect_success 'push -u master2:other2' ' |
| 51 | git push -u upstream master2:other2 && |
| 52 | check_config master2 upstream refs/heads/other2 |
| 53 | ' |
| 54 | |
| 55 | test_expect_success 'push -u :master2' ' |
| 56 | git push -u upstream :master2 && |
| 57 | check_config master2 upstream refs/heads/other2 |
| 58 | ' |
| 59 | |
| 60 | test_expect_success 'push -u --all' ' |
| 61 | git branch all1 && |
| 62 | git branch all2 && |
| 63 | git push -u --all && |
| 64 | check_config all1 upstream refs/heads/all1 && |
| 65 | check_config all2 upstream refs/heads/all2 |
| 66 | ' |
| 67 | |
| 68 | test_expect_success 'push -u HEAD' ' |
| 69 | git checkout -b headbranch && |
| 70 | git push -u upstream HEAD && |
| 71 | check_config headbranch upstream refs/heads/headbranch |
| 72 | ' |
| 73 | |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 74 | test_expect_success TTY 'progress messages go to tty' ' |
| 75 | ensure_fresh_upstream && |
| 76 | |
| 77 | test_terminal git push -u upstream master >out 2>err && |
Vasco Almeida | 1edbaac | 2016-06-17 20:21:07 +0000 | [diff] [blame] | 78 | test_i18ngrep "Writing objects" err |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 79 | ' |
| 80 | |
Jeff King | d7c411b | 2010-10-17 02:37:03 +0800 | [diff] [blame] | 81 | test_expect_success 'progress messages do not go to non-tty' ' |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 82 | ensure_fresh_upstream && |
| 83 | |
| 84 | # skip progress messages, since stderr is non-tty |
| 85 | git push -u upstream master >out 2>err && |
Vasco Almeida | a1347dc | 2016-06-17 20:21:11 +0000 | [diff] [blame] | 86 | test_i18ngrep ! "Writing objects" err |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 87 | ' |
| 88 | |
Jeff King | d7c411b | 2010-10-17 02:37:03 +0800 | [diff] [blame] | 89 | test_expect_success 'progress messages go to non-tty (forced)' ' |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 90 | ensure_fresh_upstream && |
| 91 | |
| 92 | # force progress messages to stderr, even though it is non-tty |
| 93 | git push -u --progress upstream master >out 2>err && |
Vasco Almeida | 1edbaac | 2016-06-17 20:21:07 +0000 | [diff] [blame] | 94 | test_i18ngrep "Writing objects" err |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 95 | ' |
| 96 | |
| 97 | test_expect_success TTY 'push -q suppresses progress' ' |
| 98 | ensure_fresh_upstream && |
| 99 | |
| 100 | test_terminal git push -u -q upstream master >out 2>err && |
Vasco Almeida | a1347dc | 2016-06-17 20:21:11 +0000 | [diff] [blame] | 101 | test_i18ngrep ! "Writing objects" err |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 102 | ' |
| 103 | |
Clemens Buchacher | 01fdc21 | 2012-02-13 21:17:15 +0100 | [diff] [blame] | 104 | test_expect_success TTY 'push --no-progress suppresses progress' ' |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 105 | ensure_fresh_upstream && |
| 106 | |
| 107 | test_terminal git push -u --no-progress upstream master >out 2>err && |
Vasco Almeida | a1347dc | 2016-06-17 20:21:11 +0000 | [diff] [blame] | 108 | test_i18ngrep ! "Unpacking objects" err && |
| 109 | test_i18ngrep ! "Writing objects" err |
Tay Ray Chuan | 8ac3ed2 | 2010-10-17 02:37:02 +0800 | [diff] [blame] | 110 | ' |
| 111 | |
Clemens Buchacher | c207e34 | 2012-01-08 22:06:20 +0100 | [diff] [blame] | 112 | test_expect_success TTY 'quiet push' ' |
| 113 | ensure_fresh_upstream && |
| 114 | |
| 115 | test_terminal git push --quiet --no-progress upstream master 2>&1 | tee output && |
| 116 | test_cmp /dev/null output |
| 117 | ' |
| 118 | |
Ilari Liusvaara | e9fcd1e | 2010-01-16 23:45:31 +0200 | [diff] [blame] | 119 | test_done |