mirror of
https://github.com/git/git.git
synced 2024-06-08 13:36:15 +02:00
remote.h: replace struct extra_have_objects with struct sha1_array
The latter can do everything the former can and is used in many more places. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
75f8cbab2a
commit
13eb4626c4
|
@ -10,6 +10,7 @@
|
||||||
#include "quote.h"
|
#include "quote.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "sha1-array.h"
|
||||||
|
|
||||||
static const char send_pack_usage[] =
|
static const char send_pack_usage[] =
|
||||||
"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
|
"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
|
||||||
|
@ -99,7 +100,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
|
||||||
const char *dest = NULL;
|
const char *dest = NULL;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
struct child_process *conn;
|
struct child_process *conn;
|
||||||
struct extra_have_objects extra_have;
|
struct sha1_array extra_have = SHA1_ARRAY_INIT;
|
||||||
struct ref *remote_refs, *local_refs;
|
struct ref *remote_refs, *local_refs;
|
||||||
int ret;
|
int ret;
|
||||||
int helper_status = 0;
|
int helper_status = 0;
|
||||||
|
@ -228,8 +229,6 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
|
||||||
args.verbose ? CONNECT_VERBOSE : 0);
|
args.verbose ? CONNECT_VERBOSE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&extra_have, 0, sizeof(extra_have));
|
|
||||||
|
|
||||||
get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have);
|
get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have);
|
||||||
|
|
||||||
transport_verify_remote_names(nr_refspecs, refspecs);
|
transport_verify_remote_names(nr_refspecs, refspecs);
|
||||||
|
|
12
connect.c
12
connect.c
|
@ -8,6 +8,7 @@
|
||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
|
#include "sha1-array.h"
|
||||||
|
|
||||||
static char *server_capabilities;
|
static char *server_capabilities;
|
||||||
static const char *parse_feature_value(const char *, const char *, int *);
|
static const char *parse_feature_value(const char *, const char *, int *);
|
||||||
|
@ -45,13 +46,6 @@ int check_ref_type(const struct ref *ref, int flags)
|
||||||
return check_ref(ref->name, strlen(ref->name), flags);
|
return check_ref(ref->name, strlen(ref->name), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_extra_have(struct extra_have_objects *extra, unsigned char *sha1)
|
|
||||||
{
|
|
||||||
ALLOC_GROW(extra->array, extra->nr + 1, extra->alloc);
|
|
||||||
hashcpy(&(extra->array[extra->nr][0]), sha1);
|
|
||||||
extra->nr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void die_initial_contact(int got_at_least_one_head)
|
static void die_initial_contact(int got_at_least_one_head)
|
||||||
{
|
{
|
||||||
if (got_at_least_one_head)
|
if (got_at_least_one_head)
|
||||||
|
@ -122,7 +116,7 @@ static void annotate_refs_with_symref_info(struct ref *ref)
|
||||||
*/
|
*/
|
||||||
struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
||||||
struct ref **list, unsigned int flags,
|
struct ref **list, unsigned int flags,
|
||||||
struct extra_have_objects *extra_have)
|
struct sha1_array *extra_have)
|
||||||
{
|
{
|
||||||
struct ref **orig_list = list;
|
struct ref **orig_list = list;
|
||||||
int got_at_least_one_head = 0;
|
int got_at_least_one_head = 0;
|
||||||
|
@ -160,7 +154,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
||||||
|
|
||||||
if (extra_have &&
|
if (extra_have &&
|
||||||
name_len == 5 && !memcmp(".have", name, 5)) {
|
name_len == 5 && !memcmp(".have", name, 5)) {
|
||||||
add_extra_have(extra_have, old_sha1);
|
sha1_array_append(extra_have, old_sha1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
remote.h
7
remote.h
|
@ -137,13 +137,10 @@ int check_ref_type(const struct ref *ref, int flags);
|
||||||
*/
|
*/
|
||||||
void free_refs(struct ref *ref);
|
void free_refs(struct ref *ref);
|
||||||
|
|
||||||
struct extra_have_objects {
|
struct sha1_array;
|
||||||
int nr, alloc;
|
|
||||||
unsigned char (*array)[20];
|
|
||||||
};
|
|
||||||
extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
|
||||||
struct ref **list, unsigned int flags,
|
struct ref **list, unsigned int flags,
|
||||||
struct extra_have_objects *);
|
struct sha1_array *extra_have);
|
||||||
|
|
||||||
int resolve_remote_symref(struct ref *ref, struct ref *list);
|
int resolve_remote_symref(struct ref *ref, struct ref *list);
|
||||||
int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
|
int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "quote.h"
|
#include "quote.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "sha1-array.h"
|
||||||
|
|
||||||
static int feed_object(const unsigned char *sha1, int fd, int negative)
|
static int feed_object(const unsigned char *sha1, int fd, int negative)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +29,7 @@ static int feed_object(const unsigned char *sha1, int fd, int negative)
|
||||||
/*
|
/*
|
||||||
* Make a pack stream and spit it out into file descriptor fd
|
* Make a pack stream and spit it out into file descriptor fd
|
||||||
*/
|
*/
|
||||||
static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra, struct send_pack_args *args)
|
static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, struct send_pack_args *args)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The child becomes pack-objects --revs; we feed
|
* The child becomes pack-objects --revs; we feed
|
||||||
|
@ -71,7 +72,7 @@ static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *ext
|
||||||
* parameters by writing to the pipe.
|
* parameters by writing to the pipe.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < extra->nr; i++)
|
for (i = 0; i < extra->nr; i++)
|
||||||
if (!feed_object(extra->array[i], po.in, 1))
|
if (!feed_object(extra->sha1[i], po.in, 1))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while (refs) {
|
while (refs) {
|
||||||
|
@ -177,7 +178,7 @@ static int sideband_demux(int in, int out, void *data)
|
||||||
int send_pack(struct send_pack_args *args,
|
int send_pack(struct send_pack_args *args,
|
||||||
int fd[], struct child_process *conn,
|
int fd[], struct child_process *conn,
|
||||||
struct ref *remote_refs,
|
struct ref *remote_refs,
|
||||||
struct extra_have_objects *extra_have)
|
struct sha1_array *extra_have)
|
||||||
{
|
{
|
||||||
int in = fd[0];
|
int in = fd[0];
|
||||||
int out = fd[1];
|
int out = fd[1];
|
||||||
|
|
|
@ -16,6 +16,6 @@ struct send_pack_args {
|
||||||
|
|
||||||
int send_pack(struct send_pack_args *args,
|
int send_pack(struct send_pack_args *args,
|
||||||
int fd[], struct child_process *conn,
|
int fd[], struct child_process *conn,
|
||||||
struct ref *remote_refs, struct extra_have_objects *extra_have);
|
struct ref *remote_refs, struct sha1_array *extra_have);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "submodule.h"
|
#include "submodule.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
|
#include "sha1-array.h"
|
||||||
|
|
||||||
/* rsync support */
|
/* rsync support */
|
||||||
|
|
||||||
|
@ -454,7 +455,7 @@ struct git_transport_data {
|
||||||
struct child_process *conn;
|
struct child_process *conn;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
unsigned got_remote_heads : 1;
|
unsigned got_remote_heads : 1;
|
||||||
struct extra_have_objects extra_have;
|
struct sha1_array extra_have;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int set_git_option(struct git_transport_options *opts,
|
static int set_git_option(struct git_transport_options *opts,
|
||||||
|
|
Loading…
Reference in New Issue