summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ba464d5521..fe2b26c74a 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1,7 +1,10 @@
/*
* "git fetch"
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
@@ -665,7 +668,7 @@ static int s_update_ref(const char *action,
*/
if (!transaction) {
transaction = our_transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
- &err);
+ 0, &err);
if (!transaction) {
ret = STORE_REF_ERROR_OTHER;
goto out;
@@ -1688,6 +1691,21 @@ cleanup:
return result;
}
+static int uses_remote_tracking(struct transport *transport, struct refspec *rs)
+{
+ if (!remote_is_configured(transport->remote, 0))
+ return 0;
+
+ if (!rs->nr)
+ rs = &transport->remote->fetch;
+
+ for (int i = 0; i < rs->nr; i++)
+ if (rs->items[i].dst)
+ return 1;
+
+ return 0;
+}
+
static int do_fetch(struct transport *transport,
struct refspec *rs,
const struct fetch_config *config)
@@ -1757,7 +1775,10 @@ static int do_fetch(struct transport *transport,
"refs/tags/");
}
- strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ if (uses_remote_tracking(transport, rs)) {
+ must_list_refs = 1;
+ strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ }
if (must_list_refs) {
trace2_region_enter("fetch", "remote_refs", the_repository);
@@ -1783,7 +1804,7 @@ static int do_fetch(struct transport *transport,
if (atomic_fetch) {
transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
- &err);
+ 0, &err);
if (!transaction) {
retcode = -1;
goto cleanup;