+3
-1
index 0be43104dc..8f4da4cfac 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
static int mark_tags;
static struct string_list extra_refs = STRING_LIST_INIT_DUP;
static struct string_list tag_refs = STRING_LIST_INIT_DUP;
-static struct refspec refspecs = REFSPEC_INIT_FETCH;
+static struct refspec refspecs;
static int anonymize;
static struct hashmap anonymized_seeds;
static struct revision_sources revision_sources;
/* we handle encodings */
repo_config(the_repository, git_default_config, NULL);
+ refspec_init_fetch(&refspecs, the_hash_algo);
+
repo_init_revisions(the_repository, &revs, prefix);
init_revision_sources(&revision_sources);
revs.topo_order = 1;
+4
-2
index 1d4a129039..6e1a224553 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
static struct strbuf default_rla = STRBUF_INIT;
static struct transport *gtransport;
static struct transport *gsecondary;
-static struct refspec refmap = REFSPEC_INIT_FETCH;
+static struct refspec refmap;
static struct string_list server_options = STRING_LIST_INIT_DUP;
static struct string_list negotiation_restrict = STRING_LIST_INIT_NODUP;
static struct string_list negotiation_include = STRING_LIST_INIT_NODUP;
const struct fetch_config *config,
struct list_objects_filter_options *filter_options)
{
- struct refspec rs = REFSPEC_INIT_FETCH;
+ struct refspec rs = REFSPEC_INIT_FETCH(the_hash_algo);
int i;
int exit_code;
int maybe_prune_tags;
filter_options.allow_auto_filter = 1;
+ refspec_init_fetch(&refmap, the_hash_algo);
+
packet_trace_identity("fetch");
/* Record the command line for the reflog */
+4
-2
index 1b2ad3b8df..8ccdb07c40 100644
--- a/builtin/push.c
+++ b/builtin/push.c
static struct push_cas_option cas;
-static struct refspec rs = REFSPEC_INIT_PUSH;
+static struct refspec rs;
static struct string_list push_options_config = STRING_LIST_INIT_DUP;
: &push_options_config);
set_push_cert_flags(&flags, push_cert);
+ refspec_init_push(&rs, the_hash_algo);
+
die_for_incompatible_opt4(deleterefs, "--delete",
tags, "--tags",
flags & TRANSPORT_PUSH_ALL, "--all/--branches",
}
refspec_clear(&rs);
- rs = (struct refspec) REFSPEC_INIT_PUSH;
+ rs = (struct refspec) REFSPEC_INIT_PUSH(the_hash_algo);
if (tags)
refspec_append(&rs, "refs/tags/*");
+4
-1
index 1412b49bc8..d6cdbae472 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
const char *prefix,
struct repository *repo)
{
- struct refspec rs = REFSPEC_INIT_PUSH;
+ struct refspec rs;
const char *remote_name = NULL;
struct remote *remote = NULL;
const char *dest = NULL;
repo_config(repo, send_pack_config, NULL);
argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0);
+
+ refspec_init_push(&rs, repo->hash_algo);
+
if (argc > 0) {
dest = argv[0];
refspec_appendn(&rs, argv + 1, argc - 1);
builtin/submodule--helper.c
+1
-1
index 1cc82a134d..c396b826ba 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
if (argc > 2) {
int i;
struct ref *local_refs = get_local_heads();
- struct refspec refspec = REFSPEC_INIT_PUSH;
+ struct refspec refspec = REFSPEC_INIT_PUSH(the_hash_algo);
refspec_appendn(&refspec, argv + 2, argc - 2);
+1
-1
index 3c23cbba27..969d984cb9 100644
--- a/http-push.c
+++ b/http-push.c
{
struct transfer_request *request;
struct transfer_request *next_request;
- struct refspec rs = REFSPEC_INIT_PUSH;
+ struct refspec rs = REFSPEC_INIT_PUSH(the_hash_algo);
struct remote_lock *ref_lock = NULL;
struct remote_lock *info_ref_lock = NULL;
int delete_branch = 0;
+6
-7
index 33a6fb8e45..7cb479983b 100644
--- a/refspec.c
+++ b/refspec.c
-#define USE_THE_REPOSITORY_VARIABLE
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
item->exact_sha1 = 0;
}
-void refspec_init_fetch(struct refspec *rs)
+void refspec_init_fetch(struct refspec *rs, const struct git_hash_algo *algo)
{
- struct refspec blank = REFSPEC_INIT_FETCH;
+ struct refspec blank = REFSPEC_INIT_FETCH(algo);
memcpy(rs, &blank, sizeof(*rs));
}
-void refspec_init_push(struct refspec *rs)
+void refspec_init_push(struct refspec *rs, const struct git_hash_algo *algo)
{
- struct refspec blank = REFSPEC_INIT_PUSH;
+ struct refspec blank = REFSPEC_INIT_PUSH(algo);
memcpy(rs, &blank, sizeof(*rs));
}
int ret;
if (rs->fetch)
- ret = refspec_item_init_fetch(&item, refspec, the_hash_algo);
+ ret = refspec_item_init_fetch(&item, refspec, rs->hash_algo);
else
- ret = refspec_item_init_push(&item, refspec, the_hash_algo);
+ ret = refspec_item_init_push(&item, refspec, rs->hash_algo);
if (!ret)
die(_("invalid refspec '%s'"), refspec);
+12
-5
index e482b720a8..fadef67933 100644
--- a/refspec.h
+++ b/refspec.h
int alloc;
int nr;
+ const struct git_hash_algo *hash_algo;
unsigned fetch : 1;
};
-#define REFSPEC_INIT_FETCH { .fetch = 1 }
-#define REFSPEC_INIT_PUSH { .fetch = 0 }
-
-void refspec_init_fetch(struct refspec *rs);
-void refspec_init_push(struct refspec *rs);
+#define REFSPEC_INIT_FETCH(algo) { \
+ .fetch = 1, \
+ .hash_algo = (algo), \
+}
+#define REFSPEC_INIT_PUSH(algo) { \
+ .fetch = 0, \
+ .hash_algo = (algo), \
+}
+
+void refspec_init_fetch(struct refspec *rs, const struct git_hash_algo *hash_algo);
+void refspec_init_push(struct refspec *rs, const struct git_hash_algo *hash_algo);
void refspec_clear(struct refspec *rs);
void refspec_append(struct refspec *rs, const char *refspec);
+2
-2
index b4dff1e5f9..d151b1f9d9 100644
--- a/remote.c
+++ b/remote.c
ret->prune = -1; /* unspecified */
ret->prune_tags = -1; /* unspecified */
ret->name = xstrndup(name, len);
- refspec_init_push(&ret->push);
- refspec_init_fetch(&ret->fetch);
+ refspec_init_push(&ret->push, the_hash_algo);
+ refspec_init_fetch(&ret->fetch, the_hash_algo);
string_list_init_dup(&ret->server_options);
string_list_init_dup(&ret->negotiation_restrict);
string_list_init_dup(&ret->negotiation_include);
+1
-1
index 80f90eb7ba..8a25707b03 100644
--- a/transport-helper.c
+++ b/transport-helper.c
data->helper = helper;
data->no_disconnect_req = 0;
- refspec_init_fetch(&data->rs);
+ refspec_init_fetch(&data->rs, the_hash_algo);
/*
* Open the output as FILE* so strbuf_getline_*() family of