File tree Expand file tree Collapse file tree 3 files changed +34
-22
lines changed Expand file tree Collapse file tree 3 files changed +34
-22
lines changed Original file line number Diff line number Diff line change @@ -131,3 +131,32 @@ stop_httpd() {
131
131
" $LIB_HTTPD_PATH " -d " $HTTPD_ROOT_PATH " \
132
132
-f " $TEST_PATH /apache.conf" $HTTPD_PARA -k stop
133
133
}
134
+
135
+ test_http_push_nonff () {
136
+ REMOTE_REPO=$1
137
+ LOCAL_REPO=$2
138
+ BRANCH=$3
139
+
140
+ test_expect_success ' non-fast-forward push fails' '
141
+ cd "$REMOTE_REPO" &&
142
+ HEAD=$(git rev-parse --verify HEAD) &&
143
+
144
+ cd "$LOCAL_REPO" &&
145
+ git checkout $BRANCH &&
146
+ echo "changed" > path2 &&
147
+ git commit -a -m path2 --amend &&
148
+
149
+ !(git push -v origin >output 2>&1) &&
150
+ (cd "$REMOTE_REPO" &&
151
+ test $HEAD = $(git rev-parse --verify HEAD))
152
+ '
153
+
154
+ test_expect_success ' non-fast-forward push show ref status' '
155
+ grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output
156
+ '
157
+
158
+ test_expect_success ' non-fast-forward push shows help message' '
159
+ grep "To prevent you from losing history, non-fast-forward updates were rejected" \
160
+ output
161
+ '
162
+ }
Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
137
137
138
138
'
139
139
140
+ test_http_push_nonff " $HTTPD_DOCUMENT_ROOT_PATH " /test_repo.git \
141
+ " $ROOT_PATH " /test_repo_clone master
142
+
140
143
stop_httpd
141
144
142
145
test_done
Original file line number Diff line number Diff line change @@ -88,28 +88,8 @@ test_expect_success 'used receive-pack service' '
88
88
test_cmp exp act
89
89
'
90
90
91
- test_expect_success ' non-fast-forward push fails' '
92
- cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
93
- HEAD=$(git rev-parse --verify HEAD) &&
94
-
95
- cd "$ROOT_PATH"/test_repo_clone &&
96
- git checkout master &&
97
- echo "changed" > path2 &&
98
- git commit -a -m path2 --amend &&
99
-
100
- !(git push -v origin >output 2>&1) &&
101
- (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
102
- test $HEAD = $(git rev-parse --verify HEAD))
103
- '
104
-
105
- test_expect_success ' non-fast-forward push show ref status' '
106
- grep "^ ! \[rejected\][ ]*master -> master (non-fast-forward)$" output
107
- '
108
-
109
- test_expect_success ' non-fast-forward push shows help message' '
110
- grep "To prevent you from losing history, non-fast-forward updates were rejected" \
111
- output
112
- '
91
+ test_http_push_nonff " $HTTPD_DOCUMENT_ROOT_PATH " /test_repo.git \
92
+ " $ROOT_PATH " /test_repo_clone master
113
93
114
94
test_expect_success ' push fails for non-fast-forward refs unmatched by remote helper' '
115
95
# create a dissimilarly-named remote ref so that git is unable to match the
You can’t perform that action at this time.
0 commit comments