path: root/builtin/remote.c
diff options
authorJeff King <>2011-05-26 15:11:00 (GMT)
committerJunio C Hamano <>2011-05-26 18:38:18 (GMT)
commit3eafdc961fa6c44d40382be6a55b62b7e6edb248 (patch)
treeb7aefcbc339e7c30191155ba8a34091607e62c80 /builtin/remote.c
parent099024861021830f9d4c7db4c64c844bf9d5ebd9 (diff)
remote: allow "-t" with fetch mirrors
Commit 13fc2c1 (remote: disallow some nonsensical option combinations, 2011-03-30) made it impossible to use "remote add -t foo --mirror". The argument was that specifying specific branches is useless because: 1. Push mirrors do not want a refspec at all. 2. The point of fetch mirroring is to use a broad refspec like "refs/*", but using "-t" overrides that. Point (1) is valid; "-t" with push mirrors is useless. But point (2) ignored another side effect of using --mirror: it fetches the refs directly into the refs/ namespace as they are found upstream, instead of placing them in a separate-remote layout. So 13fc2c1 was overly constrictive, and disallowed reasonable specific-branch mirroring, like: git remote add -t heads/foo -t heads/bar --mirror=fetch which makes the local "foo" and "bar" branches direct mirrors of the remote, but does not fetch anything else. This patch restores the original behavior, but only for fetch mirrors. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/remote.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index eb1229d..aa71118 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -193,8 +193,8 @@ static int add(int argc, const char **argv)
if (mirror && master)
die("specifying a master branch makes no sense with --mirror");
- if (mirror &&
- die("specifying branches to track makes no sense with --mirror");
+ if (mirror && !(mirror & MIRROR_FETCH) &&
+ die("specifying branches to track makes sense only with fetch mirrors");
name = argv[0];
url = argv[1];