Skip to content

Commit 0990248

Browse files
peffgitster
authored andcommitted
remote: deprecate --mirror
The configuration created by plain --mirror is dangerous and useless, and we now have --mirror=fetch and --mirror=push to replace it. Let's warn the user. One alternative to this is to try to guess which type the user wants. In a non-bare repository, a fetch mirror doesn't make much sense, since it would overwrite local commits. But in a bare repository, you might use either type, or even both (e.g., if you are acting as an intermediate drop-point across two disconnected networks). So rather than try for complex heuristics, let's keep it simple. The user knows what they're trying to do, so let them tell us. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a9f5a35 commit 0990248

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Documentation/git-remote.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ because a fetch would overwrite any local commits.
7575
+
7676
When a push mirror is created with `\--mirror=push`, then `git push`
7777
will always behave as if `\--mirror` was passed.
78-
+
79-
The option `\--mirror` (with no type) sets up both push and fetch
80-
mirror configuration. It is kept for historical purposes, and is
81-
probably not what you want.
8278

8379
'rename'::
8480

builtin/remote.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,19 @@ static int add_branch(const char *key, const char *branchname,
136136
return git_config_set_multivar(key, tmp->buf, "^$", 0);
137137
}
138138

139+
static const char mirror_advice[] =
140+
"--mirror is dangerous and deprecated; please\n"
141+
"\t use --mirror=fetch or --mirror=push instead";
142+
139143
static int parse_mirror_opt(const struct option *opt, const char *arg, int not)
140144
{
141145
unsigned *mirror = opt->value;
142146
if (not)
143147
*mirror = MIRROR_NONE;
144-
else if (!arg)
148+
else if (!arg) {
149+
warning("%s", mirror_advice);
145150
*mirror = MIRROR_BOTH;
151+
}
146152
else if (!strcmp(arg, "fetch"))
147153
*mirror = MIRROR_FETCH;
148154
else if (!strcmp(arg, "push"))

0 commit comments

Comments
 (0)