Skip to content

Commit 13fc2c1

Browse files
peffgitster
authored andcommitted
remote: disallow some nonsensical option combinations
It doesn't make sense to use "-m" on a mirror, since "-m" sets up the HEAD symref in the remotes namespace, but with mirror, we are by definition not using a remotes namespace. Similarly, it does not make much sense to specify refspecs with --mirror. For a mirror you plan to push to, those refspecs will be ignored. For a mirror you are fetching from, there is no point in mirroring, since the refspec specifies everything you want to grab. There is one case where "--mirror -t <X>" would be useful. Because <X> is used as-is in the refspec, and because we append it to to refs/, you could mirror a subset of the hierarchy by doing: git remote add --mirror -t 'tags/*' But using anything besides a single branch as an argument to "-t" is not documented and only happens to work, so closing it off is not a serious regression. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90cff96 commit 13fc2c1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

builtin/remote.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ static int add(int argc, const char **argv)
161161
if (argc < 2)
162162
usage_with_options(builtin_remote_add_usage, options);
163163

164+
if (mirror && master)
165+
die("specifying a master branch makes no sense with --mirror");
166+
if (mirror && track.nr)
167+
die("specifying branches to track makes no sense with --mirror");
168+
164169
name = argv[0];
165170
url = argv[1];
166171

0 commit comments

Comments
 (0)