mirror of
https://github.com/git/git.git
synced 2024-09-24 00:51:44 +02:00
fetch --prune: exit with error if pruning fails
When pruning refs fails, we print an error to stderr, but still
exit 0 from 'git fetch'. Since this is a genuine error, fetch
should be exiting with some non-zero exit code. Make it so.
The --prune option was introduced in f360d844de
("builtin-fetch: add
--prune option", 2009-11-10). Unfortunately it's unclear from that
commit whether ignoring the exit code was an oversight or
intentional, but it feels like an oversight.
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4c53a8c20f
commit
c9e04d905e
@ -1609,12 +1609,14 @@ static int do_fetch(struct transport *transport,
|
|||||||
* don't care whether --tags was specified.
|
* don't care whether --tags was specified.
|
||||||
*/
|
*/
|
||||||
if (rs->nr) {
|
if (rs->nr) {
|
||||||
prune_refs(rs, ref_map, transport->url);
|
retcode = prune_refs(rs, ref_map, transport->url);
|
||||||
} else {
|
} else {
|
||||||
prune_refs(&transport->remote->fetch,
|
retcode = prune_refs(&transport->remote->fetch,
|
||||||
ref_map,
|
ref_map,
|
||||||
transport->url);
|
transport->url);
|
||||||
}
|
}
|
||||||
|
if (retcode != 0)
|
||||||
|
retcode = 1;
|
||||||
}
|
}
|
||||||
if (fetch_and_consume_refs(transport, ref_map, worktrees)) {
|
if (fetch_and_consume_refs(transport, ref_map, worktrees)) {
|
||||||
free_refs(ref_map);
|
free_refs(ref_map);
|
||||||
|
@ -164,6 +164,17 @@ test_expect_success 'fetch --prune --tags with refspec prunes based on refspec'
|
|||||||
git rev-parse sometag
|
git rev-parse sometag
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success REFFILES 'fetch --prune fails to delete branches' '
|
||||||
|
cd "$D" &&
|
||||||
|
git clone . prune-fail &&
|
||||||
|
cd prune-fail &&
|
||||||
|
git update-ref refs/remotes/origin/extrabranch main &&
|
||||||
|
: this will prevent --prune from locking packed-refs for deleting refs, but adding loose refs still succeeds &&
|
||||||
|
>.git/packed-refs.new &&
|
||||||
|
|
||||||
|
test_must_fail git fetch --prune origin
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'fetch --atomic works with a single branch' '
|
test_expect_success 'fetch --atomic works with a single branch' '
|
||||||
test_when_finished "rm -rf \"$D\"/atomic" &&
|
test_when_finished "rm -rf \"$D\"/atomic" &&
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user