summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2005-11-06 00:09:59 -0800
committerLibravatar Junio C Hamano <junkio@cox.net>2005-11-06 00:26:21 -0800
commit9e5d2b40967059dd5f35d02fba323751ef22ac4e (patch)
tree9cc3928769f8f4e3597fa446321112c0568514df
parentDocumentation: pull/clone ref mapping clarification. (diff)
downloadtgif-9e5d2b40967059dd5f35d02fba323751ef22ac4e.tar.xz
git-fetch: fail if specified refspec does not match remote.
'git-fetch remote no-such-ref' succeeded without fetching any ref from the remote. Detect such case and report an error. Note that this makes 'git-fetch remote master master' to fail, because the remote branch 'master' matches the first refspec, and the second refspec is left unmatched, which is detected by the error checking logic. This is somewhat unintuitive, but giving the same refspec more than once to git-fetch is useless in any case so it should not be much of a problem. I'd accept a patch to change this if somebody cares enough, though. Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--fetch-pack.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index cb2171523c..6565982660 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -458,5 +458,19 @@ int main(int argc, char **argv)
close(fd[0]);
close(fd[1]);
finish_connect(pid);
+
+ if (!ret && nr_heads) {
+ /* If the heads to pull were given, we should have
+ * consumed all of them by matching the remote.
+ * Otherwise, 'git-fetch remote no-such-ref' would
+ * silently succeed without issuing an error.
+ */
+ for (i = 0; i < nr_heads; i++)
+ if (heads[i] && heads[i][0]) {
+ error("no such remote ref %s", heads[i]);
+ ret = 1;
+ }
+ }
+
return ret;
}