X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-push.c;h=b35aad68e9154bb755c51323106c738ab4fc61e9;hb=d88593fa0412a4f0a363860d879e97635c118616;hp=6d1da07c46704f3de837044652f0a1fd149327ad;hpb=9f4c4eb0e16d1e21eaaf5cab5591c3491456cd14;p=git.git diff --git a/builtin-push.c b/builtin-push.c index 6d1da07c4..b35aad68e 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -10,7 +10,7 @@ #include "parse-options.h" static const char * const push_usage[] = { - "git-push [--all] [--dry-run] [--tags] [--receive-pack=] [--repo=all] [-f | --force] [-v] [ ...]", + "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=] [--repo=all] [-f | --force] [-v] [ ...]", NULL, }; @@ -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) { @@ -81,7 +92,7 @@ static int do_push(const char *repo, int flags) if (!err) continue; - error("failed to push to '%s'", remote->url[i]); + error("failed to push some refs to '%s'", remote->url[i]); errs++; } return !!errs; @@ -91,15 +102,18 @@ int cmd_push(int argc, const char **argv, const char *prefix) { int flags = 0; int all = 0; + int mirror = 0; int dry_run = 0; int force = 0; int tags = 0; + int rc; const char *repo = NULL; /* default repository */ struct option options[] = { OPT__VERBOSE(&verbose), OPT_STRING( 0 , "repo", &repo, "repository", "repository"), OPT_BOOLEAN( 0 , "all", &all, "push all refs"), + OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"), OPT_BOOLEAN( 0 , "tags", &tags, "push tags"), OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"), OPT_BOOLEAN('f', "force", &force, "force updates"), @@ -121,13 +135,17 @@ int cmd_push(int argc, const char **argv, const char *prefix) add_refspec("refs/tags/*"); if (all) flags |= TRANSPORT_PUSH_ALL; + if (mirror) + flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE); if (argc > 0) { repo = argv[0]; set_refspecs(argv + 1, argc - 1); } - if ((flags & TRANSPORT_PUSH_ALL) && refspec) - usage_with_options(push_usage, options); - return do_push(repo, flags); + rc = do_push(repo, flags); + if (rc == -1) + usage_with_options(push_usage, options); + else + return rc; }