]>
Commit | Line | Data |
---|---|---|
4950b2a2 DS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git for-each-repo builtin' | |
4 | ||
03267e86 | 5 | TEST_PASSES_SANITIZE_LEAK=true |
4950b2a2 DS |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'run based on configured value' ' | |
9 | git init one && | |
10 | git init two && | |
11 | git init three && | |
13d5bbdf | 12 | git init ~/four && |
4950b2a2 DS |
13 | git -C two commit --allow-empty -m "DID NOT RUN" && |
14 | git config run.key "$TRASH_DIRECTORY/one" && | |
15 | git config --add run.key "$TRASH_DIRECTORY/three" && | |
13d5bbdf | 16 | git config --add run.key "~/four" && |
4950b2a2 DS |
17 | git for-each-repo --config=run.key commit --allow-empty -m "ran" && |
18 | git -C one log -1 --pretty=format:%s >message && | |
19 | grep ran message && | |
20 | git -C two log -1 --pretty=format:%s >message && | |
21 | ! grep ran message && | |
22 | git -C three log -1 --pretty=format:%s >message && | |
23 | grep ran message && | |
13d5bbdf RP |
24 | git -C ~/four log -1 --pretty=format:%s >message && |
25 | grep ran message && | |
4950b2a2 DS |
26 | git for-each-repo --config=run.key -- commit --allow-empty -m "ran again" && |
27 | git -C one log -1 --pretty=format:%s >message && | |
28 | grep again message && | |
29 | git -C two log -1 --pretty=format:%s >message && | |
30 | ! grep again message && | |
31 | git -C three log -1 --pretty=format:%s >message && | |
13d5bbdf RP |
32 | grep again message && |
33 | git -C ~/four log -1 --pretty=format:%s >message && | |
4950b2a2 DS |
34 | grep again message |
35 | ' | |
36 | ||
6c62f015 DS |
37 | test_expect_success 'do nothing on empty config' ' |
38 | # the whole thing would fail if for-each-ref iterated even | |
39 | # once, because "git help --no-such-option" would fail | |
40 | git for-each-repo --config=bogus.config -- help --no-such-option | |
41 | ' | |
42 | ||
f7b2ff95 ÆAB |
43 | test_expect_success 'error on bad config keys' ' |
44 | test_expect_code 129 git for-each-repo --config=a && | |
45 | test_expect_code 129 git for-each-repo --config=a.b. && | |
46 | test_expect_code 129 git for-each-repo --config="'\''.b" | |
47 | ' | |
48 | ||
3611f746 ÆAB |
49 | test_expect_success 'error on NULL value for config keys' ' |
50 | cat >>.git/config <<-\EOF && | |
51 | [empty] | |
52 | key | |
53 | EOF | |
54 | cat >expect <<-\EOF && | |
55 | error: missing value for '\''empty.key'\'' | |
56 | EOF | |
57 | test_expect_code 129 git for-each-repo --config=empty.key 2>actual.raw && | |
58 | grep ^error actual.raw >actual && | |
59 | test_cmp expect actual | |
60 | ' | |
61 | ||
12c2ee5f JS |
62 | test_expect_success '--keep-going' ' |
63 | git config keep.going non-existing && | |
64 | git config --add keep.going . && | |
65 | ||
66 | test_must_fail git for-each-repo --config=keep.going \ | |
67 | -- branch >out 2>err && | |
68 | test_grep "cannot change to .*non-existing" err && | |
69 | test_must_be_empty out && | |
70 | ||
71 | test_must_fail git for-each-repo --config=keep.going --keep-going \ | |
72 | -- branch >out 2>err && | |
73 | test_grep "cannot change to .*non-existing" err && | |
74 | git branch >expect && | |
75 | test_cmp expect out | |
76 | ' | |
77 | ||
4950b2a2 | 78 | test_done |