зеркало из https://github.com/microsoft/git.git
fetch --prune: always print header url
If "fetch --prune" is run with no new refs to fetch, but it has refs to prune. Then, the header url is not printed as it would if there were new refs to fetch. Output before this patch: $ git fetch --prune remote-with-no-new-refs x [deleted] (none) -> origin/world Output after this patch: $ git fetch --prune remote-with-no-new-refs From https://github.com/git/git x [deleted] (none) -> origin/test Signed-off-by: Tom Miller <jackerran@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
7794a680e6
Коммит
4b3b33a747
|
@ -44,6 +44,7 @@ static struct transport *gtransport;
|
|||
static struct transport *gsecondary;
|
||||
static const char *submodule_prefix = "";
|
||||
static const char *recurse_submodules_default;
|
||||
static int shown_url = 0;
|
||||
|
||||
static int option_parse_recurse_submodules(const struct option *opt,
|
||||
const char *arg, int unset)
|
||||
|
@ -535,7 +536,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||
{
|
||||
FILE *fp;
|
||||
struct commit *commit;
|
||||
int url_len, i, shown_url = 0, rc = 0;
|
||||
int url_len, i, rc = 0;
|
||||
struct strbuf note = STRBUF_INIT;
|
||||
const char *what, *kind;
|
||||
struct ref *rm;
|
||||
|
@ -708,17 +709,36 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
|
||||
static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
|
||||
const char *raw_url)
|
||||
{
|
||||
int result = 0;
|
||||
int url_len, i, result = 0;
|
||||
struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
|
||||
char *url;
|
||||
const char *dangling_msg = dry_run
|
||||
? _(" (%s will become dangling)")
|
||||
: _(" (%s has become dangling)");
|
||||
|
||||
if (raw_url)
|
||||
url = transport_anonymize_url(raw_url);
|
||||
else
|
||||
url = xstrdup("foreign");
|
||||
|
||||
url_len = strlen(url);
|
||||
for (i = url_len - 1; url[i] == '/' && 0 <= i; i--)
|
||||
;
|
||||
|
||||
url_len = i + 1;
|
||||
if (4 < i && !strncmp(".git", url + i - 3, 4))
|
||||
url_len = i - 3;
|
||||
|
||||
for (ref = stale_refs; ref; ref = ref->next) {
|
||||
if (!dry_run)
|
||||
result |= delete_ref(ref->name, NULL, 0);
|
||||
if (verbosity >= 0 && !shown_url) {
|
||||
fprintf(stderr, _("From %.*s\n"), url_len, url);
|
||||
shown_url = 1;
|
||||
}
|
||||
if (verbosity >= 0) {
|
||||
fprintf(stderr, " x %-*s %-*s -> %s\n",
|
||||
TRANSPORT_SUMMARY(_("[deleted]")),
|
||||
|
@ -726,6 +746,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
|
|||
warn_dangling_symref(stderr, dangling_msg, ref->name);
|
||||
}
|
||||
}
|
||||
free(url);
|
||||
free_refs(stale_refs);
|
||||
return result;
|
||||
}
|
||||
|
@ -854,11 +875,12 @@ static int do_fetch(struct transport *transport,
|
|||
* don't care whether --tags was specified.
|
||||
*/
|
||||
if (ref_count) {
|
||||
prune_refs(refs, ref_count, ref_map);
|
||||
prune_refs(refs, ref_count, ref_map, transport->url);
|
||||
} else {
|
||||
prune_refs(transport->remote->fetch,
|
||||
transport->remote->fetch_refspec_nr,
|
||||
ref_map);
|
||||
ref_map,
|
||||
transport->url);
|
||||
}
|
||||
}
|
||||
free_refs(ref_map);
|
||||
|
|
|
@ -614,4 +614,16 @@ test_expect_success 'all boundary commits are excluded' '
|
|||
test_bundle_object_count .git/objects/pack/pack-${pack##pack }.pack 3
|
||||
'
|
||||
|
||||
test_expect_success 'fetch --prune prints the remotes url' '
|
||||
git branch goodbye &&
|
||||
git clone . only-prunes &&
|
||||
git branch -D goodbye &&
|
||||
(
|
||||
cd only-prunes &&
|
||||
git fetch --prune origin 2>&1 | head -n1 >../actual
|
||||
) &&
|
||||
echo "From ${D}/." >expect &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче