Make git-send-pack exit with error when some refs couldn't be pushed out
In case some refs couldn't be pushed out due to an error (mostly the not-a-proper-subset error), make git-send-pack exit with non-zero status after the push is over (that is, it still tries to push out the rest of the refs). [jc: I adjusted a test for this change.] Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
Petr Baudis committed
Dec 14, 2005 at 01:45 UTC
ed24928e122bad83e62d161087f806fa21c46a59
2 files changed
+14
-2
send-pack.c
+5
-1
@@ -179,6 +179,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
179
{
180
struct ref *ref;
181
int new_refs;
182
+ int ret = 0;
183
184
/* No funny business with the matcher */
185
remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1);
@@ -232,6 +233,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
233
error("remote '%s' object %s does not "
234
"exist on local",
235
ref->name, sha1_to_hex(ref->old_sha1));
236
+ ret = -2;
237
continue;
238
}
239
@@ -245,12 +247,14 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
247
error("remote ref '%s' is not a strict "
248
"subset of local ref '%s'.", ref->name,
249
ref->peer_ref->name);
250
+ ret = -2;
251
continue;
252
}
253
}
254
memcpy(ref->new_sha1, ref->peer_ref->new_sha1, 20);
255
if (is_zero_sha1(ref->new_sha1)) {
256
error("cannot happen anymore");
257
+ ret = -3;
258
continue;
259
}
260
new_refs++;
@@ -267,7 +271,7 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
271
if (new_refs)
272
pack_objects(out, remote_refs);
273
close(out);
270
- return 0;
274
+ return ret;
275
}
276
277
t/t5400-send-pack.sh
+9
-1
@@ -43,7 +43,15 @@ test_expect_success setup '
43
test_expect_success \
44
'pushing rewound head should not barf but require --force' '
45
# should not fail but refuse to update.
46
- git-send-pack ./victim/.git/ master &&
46
+ if git-send-pack ./victim/.git/ master
47
+ then
48
+ # now it should fail with Pasky patch
49
+ echo >&2 Gaah, it should have failed.
50
+ false
51
+ else
52
+ echo >&2 Thanks, it correctly failed.
53
+ true
54
+ fi &&
55
if cmp victim/.git/refs/heads/master .git/refs/heads/master
56
then
57
# should have been left as it was!