зеркало из https://github.com/microsoft/git.git
fetch-pack: move code to report unmatched refs to a function
Prepare to reuse this code in transport.c for "git fetch". While we're here, internationalize the existing error message. Signed-off-by: Matt McCutchen <matt@mattmccutchen.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
3b9e3c2ced
Коммит
e860d96bf8
|
@ -219,12 +219,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
||||||
* remote no-such-ref' would silently succeed without issuing
|
* remote no-such-ref' would silently succeed without issuing
|
||||||
* an error.
|
* an error.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < nr_sought; i++) {
|
ret |= report_unmatched_refs(sought, nr_sought);
|
||||||
if (!sought[i] || sought[i]->matched)
|
|
||||||
continue;
|
|
||||||
error("no such remote ref %s", sought[i]->name);
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ref) {
|
while (ref) {
|
||||||
printf("%s %s\n",
|
printf("%s %s\n",
|
||||||
|
|
13
fetch-pack.c
13
fetch-pack.c
|
@ -1094,3 +1094,16 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
|
||||||
clear_shallow_info(&si);
|
clear_shallow_info(&si);
|
||||||
return ref_cpy;
|
return ref_cpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int report_unmatched_refs(struct ref **sought, int nr_sought)
|
||||||
|
{
|
||||||
|
int i, ret = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < nr_sought; i++) {
|
||||||
|
if (!sought[i] || sought[i]->matched)
|
||||||
|
continue;
|
||||||
|
error(_("no such remote ref %s"), sought[i]->name);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -45,4 +45,10 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
|
||||||
struct sha1_array *shallow,
|
struct sha1_array *shallow,
|
||||||
char **pack_lockfile);
|
char **pack_lockfile);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print an appropriate error message for each sought ref that wasn't
|
||||||
|
* matched. Return 0 if all sought refs were matched, otherwise 1.
|
||||||
|
*/
|
||||||
|
int report_unmatched_refs(struct ref **sought, int nr_sought);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -484,7 +484,7 @@ test_expect_success 'test lonely missing ref' '
|
||||||
cd client &&
|
cd client &&
|
||||||
test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy
|
test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy
|
||||||
) >/dev/null 2>error-m &&
|
) >/dev/null 2>error-m &&
|
||||||
test_cmp expect-error error-m
|
test_i18ncmp expect-error error-m
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'test missing ref after existing' '
|
test_expect_success 'test missing ref after existing' '
|
||||||
|
@ -492,7 +492,7 @@ test_expect_success 'test missing ref after existing' '
|
||||||
cd client &&
|
cd client &&
|
||||||
test_must_fail git fetch-pack --no-progress .. refs/heads/A refs/heads/xyzzy
|
test_must_fail git fetch-pack --no-progress .. refs/heads/A refs/heads/xyzzy
|
||||||
) >/dev/null 2>error-em &&
|
) >/dev/null 2>error-em &&
|
||||||
test_cmp expect-error error-em
|
test_i18ncmp expect-error error-em
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'test missing ref before existing' '
|
test_expect_success 'test missing ref before existing' '
|
||||||
|
@ -500,7 +500,7 @@ test_expect_success 'test missing ref before existing' '
|
||||||
cd client &&
|
cd client &&
|
||||||
test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy refs/heads/A
|
test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy refs/heads/A
|
||||||
) >/dev/null 2>error-me &&
|
) >/dev/null 2>error-me &&
|
||||||
test_cmp expect-error error-me
|
test_i18ncmp expect-error error-me
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'test --all, --depth, and explicit head' '
|
test_expect_success 'test --all, --depth, and explicit head' '
|
||||||
|
|
Загрузка…
Ссылка в новой задаче