summaryrefslogtreecommitdiff
path: root/builtin-push.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2008-04-17 13:17:20 +0200
committerJunio C Hamano <gitster@pobox.com>2008-04-20 18:49:22 -0700
commit84bb2dfd9f4873c9ca19537efe62219b09ec03bf (patch)
tree4490819e5489268b9fc9b9eec3da8ec87c8774fa /builtin-push.c
parent5909ca92d8b2c6a0534597f52f7733ff61a64d63 (diff)
downloadgit-84bb2dfd9f4873c9ca19537efe62219b09ec03bf.tar.gz
Add a remote.*.mirror configuration option
This patch adds a remote.*.mirror configuration option that, when set, automatically puts git-push in --mirror mode for that remote. Furthermore, the option is set automatically by `git remote add --mirror'. The code in remote.c to parse remote.*.skipdefaultupdate had a subtle problem: a comment in the code indicated that special care was needed for boolean options, but this care was not used in parsing the option. Since I was touching related code, I did this fix too. [jc: and I further fixed up the "ignore boolean" code.] Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-push.c')
-rw-r--r--builtin-push.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/builtin-push.c b/builtin-push.c
index b68c6813b8..b35aad68e9 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -56,6 +56,17 @@ static int do_push(const char *repo, int flags)
if (!remote)
die("bad repository '%s'", repo);
+ if (remote->mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
+ return -1;
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ return error("--all and --mirror are incompatible");
+ }
+
if (!refspec
&& !(flags & TRANSPORT_PUSH_ALL)
&& remote->push_refspec_nr) {
@@ -95,6 +106,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
int dry_run = 0;
int force = 0;
int tags = 0;
+ int rc;
const char *repo = NULL; /* default repository */
struct option options[] = {
@@ -130,14 +142,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
- usage_with_options(push_usage, options);
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
- (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
- error("--all and --mirror are incompatible");
+ rc = do_push(repo, flags);
+ if (rc == -1)
usage_with_options(push_usage, options);
- }
-
- return do_push(repo, flags);
+ else
+ return rc;
}