From c300d84a64601b09abcf0f2d2e6d492b4578770d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 3 Jul 2014 07:54:26 +0200 Subject: [PATCH] remote: don't DWIM refspecs unnecessarily We can only DWIM when we've connected to the remote and have the list of the remote's references. Adding or setting the refspecs should not trigger an attempt to DWIM the refspecs as we typically cannot do it, and even if we did, we would not use them for the current fetch. --- src/remote.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/remote.c b/src/remote.c index 8cf8c0353..b3e968e2e 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1669,27 +1669,14 @@ void git_remote_clear_refspecs(git_remote *remote) git_vector_clear(&remote->refspecs); } -static int add_and_dwim(git_remote *remote, const char *str, int push) -{ - git_refspec *spec; - git_vector *vec; - - if (add_refspec(remote, str, !push) < 0) - return -1; - - vec = &remote->refspecs; - spec = git_vector_get(vec, vec->length - 1); - return git_refspec__dwim_one(&remote->active_refspecs, spec, &remote->refs); -} - int git_remote_add_fetch(git_remote *remote, const char *refspec) { - return add_and_dwim(remote, refspec, false); + return add_refspec(remote, refspec, true); } int git_remote_add_push(git_remote *remote, const char *refspec) { - return add_and_dwim(remote, refspec, true); + return add_refspec(remote, refspec, false); } static int set_refspecs(git_remote *remote, git_strarray *array, int push) @@ -1717,10 +1704,7 @@ static int set_refspecs(git_remote *remote, git_strarray *array, int push) return -1; } - free_refspecs(&remote->active_refspecs); - git_vector_clear(&remote->active_refspecs); - - return dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs); + return 0; } int git_remote_set_fetch_refspecs(git_remote *remote, git_strarray *array)