mirror of
https://github.com/git/git.git
synced 2024-12-11 10:54:21 +08:00
fetch --prune: Run prune before fetching
When we have a remote-tracking branch named "frotz/nitfol" from a previous fetch, and the upstream now has a branch named "frotz", fetch would fail to remove "frotz/nitfol" with a "git fetch --prune" from the upstream. git would inform the user to use "git remote prune" to fix the problem. Change the way "fetch --prune" works by moving the pruning operation before the fetching operation. This way, instead of warning the user of a conflict, it autmatically fixes it. Signed-off-by: Tom Miller <jackerran@gmail.com> Tested-by: Thomas Rast <tr@thomasrast.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4b3b33a747
commit
10a6cc8890
@ -863,11 +863,6 @@ static int do_fetch(struct transport *transport,
|
|||||||
|
|
||||||
if (tags == TAGS_DEFAULT && autotags)
|
if (tags == TAGS_DEFAULT && autotags)
|
||||||
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
|
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
|
||||||
if (fetch_refs(transport, ref_map)) {
|
|
||||||
free_refs(ref_map);
|
|
||||||
retcode = 1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (prune) {
|
if (prune) {
|
||||||
/*
|
/*
|
||||||
* We only prune based on refspecs specified
|
* We only prune based on refspecs specified
|
||||||
@ -883,6 +878,11 @@ static int do_fetch(struct transport *transport,
|
|||||||
transport->url);
|
transport->url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fetch_refs(transport, ref_map)) {
|
||||||
|
free_refs(ref_map);
|
||||||
|
retcode = 1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
free_refs(ref_map);
|
free_refs(ref_map);
|
||||||
|
|
||||||
/* if neither --no-tags nor --tags was specified, do automated tag
|
/* if neither --no-tags nor --tags was specified, do automated tag
|
||||||
|
@ -626,4 +626,18 @@ test_expect_success 'fetch --prune prints the remotes url' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'branchname D/F conflict resolved by --prune' '
|
||||||
|
git branch dir/file &&
|
||||||
|
git clone . prune-df-conflict &&
|
||||||
|
git branch -D dir/file &&
|
||||||
|
git branch dir &&
|
||||||
|
(
|
||||||
|
cd prune-df-conflict &&
|
||||||
|
git fetch --prune &&
|
||||||
|
git rev-parse origin/dir >../actual
|
||||||
|
) &&
|
||||||
|
git rev-parse dir >expect &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user