summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Michael Haggerty <mhagger@alum.mit.edu>2012-09-09 08:19:42 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-09-12 11:46:31 -0700
commit4c58f13ba67f9dbe67a351de61703a2db20712cc (patch)
tree7dcf43f563e5291d4fef6f9a38a8de56933d0b17 /builtin
parentfilter_refs(): do not check the same sought_pos twice (diff)
downloadtgif-4c58f13ba67f9dbe67a351de61703a2db20712cc.tar.xz
fetch_pack(): update sought->nr to reflect number of unique entries
fetch_pack() removes duplicates from the "sought" list, thereby shrinking the list. But previously, the caller was not informed about the shrinkage. This would cause a spurious error message to be emitted by cmd_fetch_pack() if "git fetch-pack" is called with duplicate refnames. Instead, remove duplicates using string_list_remove_duplicates(), which adjusts sought->nr to reflect the new length of the list. The last test of t5500 inexplicably *required* "git fetch-pack" to fail when fetching a list of references that contains duplicates; i.e., it insisted on the buggy behavior. So change the test to expect the correct behavior. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/fetch-pack.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 63d455ffef..6cd734a9cb 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -858,19 +858,6 @@ static struct ref *do_fetch_pack(int fd[2],
return ref;
}
-static int remove_duplicates(struct string_list *sought)
-{
- int src, dst;
-
- if (!sought->nr)
- return 0;
-
- for (src = dst = 1; src < sought->nr; src++)
- if (strcmp(sought->items[src].string, sought->items[dst-1].string))
- sought->items[dst++] = sought->items[src];
- return dst;
-}
-
static int fetch_pack_config(const char *var, const char *value, void *cb)
{
if (strcmp(var, "fetch.unpacklimit") == 0) {
@@ -1090,7 +1077,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
if (sought->nr) {
sort_string_list(sought);
- remove_duplicates(sought);
+ string_list_remove_duplicates(sought, 0);
}
if (!ref) {