@@ -61,11 +61,10 @@ test_expect_success 'fetch compact output' '
61
61
test_cmp expect actual
62
62
'
63
63
64
- test_expect_success ' fetch porcelain output' '
65
- test_when_finished "rm -rf porcelain" &&
66
-
64
+ test_expect_success ' setup for fetch porcelain output' '
67
65
# Set up a bunch of references that we can use to demonstrate different
68
66
# kinds of flag symbols in the output format.
67
+ test_commit commit-for-porcelain-output &&
69
68
MAIN_OLD=$(git rev-parse HEAD) &&
70
69
git branch "fast-forward" &&
71
70
git branch "deleted-branch" &&
@@ -74,15 +73,10 @@ test_expect_success 'fetch porcelain output' '
74
73
FORCE_UPDATED_OLD=$(git rev-parse HEAD) &&
75
74
git checkout main &&
76
75
77
- # Clone and pre-seed the repositories. We fetch references into two
78
- # namespaces so that we can test that rejected and force-updated
79
- # references are reported properly.
80
- refspecs="refs/heads/*:refs/unforced/* +refs/heads/*:refs/forced/*" &&
81
- git clone . porcelain &&
82
- git -C porcelain fetch origin $refspecs &&
76
+ # Backup to preseed.git
77
+ git clone --mirror . preseed.git &&
83
78
84
- # Now that we have set up the client repositories we can change our
85
- # local references.
79
+ # Continue changing our local references.
86
80
git branch new-branch &&
87
81
git branch -d deleted-branch &&
88
82
git checkout fast-forward &&
@@ -91,36 +85,61 @@ test_expect_success 'fetch porcelain output' '
91
85
git checkout force-updated &&
92
86
git reset --hard HEAD~ &&
93
87
test_commit --no-tag force-update-new &&
94
- FORCE_UPDATED_NEW=$(git rev-parse HEAD) &&
95
-
96
- cat >expect <<-EOF &&
97
- - $MAIN_OLD $ZERO_OID refs/forced/deleted-branch
98
- - $MAIN_OLD $ZERO_OID refs/unforced/deleted-branch
99
- $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward
100
- ! $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/unforced/force-updated
101
- * $ZERO_OID $MAIN_OLD refs/unforced/new-branch
102
- $MAIN_OLD $FAST_FORWARD_NEW refs/forced/fast-forward
103
- + $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated
104
- * $ZERO_OID $MAIN_OLD refs/forced/new-branch
105
- $MAIN_OLD $FAST_FORWARD_NEW refs/remotes/origin/fast-forward
106
- + $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated
107
- * $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch
108
- EOF
109
-
110
- # Execute a dry-run fetch first. We do this to assert that the dry-run
111
- # and non-dry-run fetches produces the same output. Execution of the
112
- # fetch is expected to fail as we have a rejected reference update.
113
- test_must_fail git -C porcelain fetch \
114
- --porcelain --dry-run --prune origin $refspecs >actual &&
115
- test_cmp expect actual &&
116
-
117
- # And now we perform a non-dry-run fetch.
118
- test_must_fail git -C porcelain fetch \
119
- --porcelain --prune origin $refspecs >actual 2>stderr &&
120
- test_cmp expect actual &&
121
- test_must_be_empty stderr
88
+ FORCE_UPDATED_NEW=$(git rev-parse HEAD)
122
89
'
123
90
91
+ for opt in off on
92
+ do
93
+ case $opt in
94
+ on)
95
+ opt=--atomic
96
+ ;;
97
+ off)
98
+ opt=
99
+ ;;
100
+ esac
101
+ test_expect_success " fetch porcelain output ${opt: +(atomic)} " '
102
+ test_when_finished "rm -rf porcelain" &&
103
+
104
+ # Clone and pre-seed the repositories. We fetch references into two
105
+ # namespaces so that we can test that rejected and force-updated
106
+ # references are reported properly.
107
+ refspecs="refs/heads/*:refs/unforced/* +refs/heads/*:refs/forced/*" &&
108
+ git clone preseed.git porcelain &&
109
+ git -C porcelain fetch origin $opt $refspecs &&
110
+
111
+ cat >expect <<-EOF &&
112
+ - $MAIN_OLD $ZERO_OID refs/forced/deleted-branch
113
+ - $MAIN_OLD $ZERO_OID refs/unforced/deleted-branch
114
+ $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward
115
+ ! $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/unforced/force-updated
116
+ * $ZERO_OID $MAIN_OLD refs/unforced/new-branch
117
+ $MAIN_OLD $FAST_FORWARD_NEW refs/forced/fast-forward
118
+ + $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated
119
+ * $ZERO_OID $MAIN_OLD refs/forced/new-branch
120
+ $MAIN_OLD $FAST_FORWARD_NEW refs/remotes/origin/fast-forward
121
+ + $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated
122
+ * $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch
123
+ EOF
124
+
125
+ # Change the URL of the repository to fetch different references.
126
+ git -C porcelain remote set-url origin .. &&
127
+
128
+ # Execute a dry-run fetch first. We do this to assert that the dry-run
129
+ # and non-dry-run fetches produces the same output. Execution of the
130
+ # fetch is expected to fail as we have a rejected reference update.
131
+ test_must_fail git -C porcelain fetch $opt \
132
+ --porcelain --dry-run --prune origin $refspecs >actual &&
133
+ test_cmp expect actual &&
134
+
135
+ # And now we perform a non-dry-run fetch.
136
+ test_must_fail git -C porcelain fetch $opt \
137
+ --porcelain --prune origin $refspecs >actual 2>stderr &&
138
+ test_cmp expect actual &&
139
+ test_must_be_empty stderr
140
+ '
141
+ done
142
+
124
143
test_expect_success ' fetch porcelain with multiple remotes' '
125
144
test_when_finished "rm -rf porcelain" &&
126
145
0 commit comments