X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fpush.c;h=f4358b9d230f6d8d7a9a67fdfbc60279c5ec71ee;hb=ddb27a5a6b5ed74c70d56c96592b32eed415d72b;hp=5633f0ade49f7c845665b7aab202be18a8cc9d8d;hpb=81b50f3ce40bfdd66e5d967bf82be001039a9a98;p=git.git diff --git a/builtin/push.c b/builtin/push.c index 5633f0ade..f4358b9d2 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -10,13 +10,15 @@ #include "parse-options.h" static const char * const push_usage[] = { - "git push [] [ ...]", + "git push [] [ [...]]", NULL, }; static int thin; static int deleterefs; static const char *receivepack; +static int verbosity; +static int progress; static const char **refspec; static int refspec_nr; @@ -68,7 +70,7 @@ static void setup_push_tracking(void) struct branch *branch = branch_get(NULL); if (!branch) die("You are not currently on a branch."); - if (!branch->merge_nr) + if (!branch->merge_nr || !branch->merge) die("The current branch %s is not tracking anything.", branch->name); if (branch->merge_nr != 1) @@ -105,13 +107,16 @@ static int push_with_options(struct transport *transport, int flags) { int err; int nonfastforward; + + transport_set_verbosity(transport, verbosity, progress); + if (receivepack) transport_set_option(transport, TRANS_OPT_RECEIVEPACK, receivepack); if (thin) transport_set_option(transport, TRANS_OPT_THIN, "yes"); - if (flags & TRANSPORT_PUSH_VERBOSE) + if (verbosity > 0) fprintf(stderr, "Pushing to %s\n", transport->url); err = transport_push(transport, refspec_nr, refspec, flags, &nonfastforward); @@ -124,9 +129,9 @@ static int push_with_options(struct transport *transport, int flags) return 0; if (nonfastforward && advice_push_nonfastforward) { - printf("To prevent you from losing history, non-fast-forward updates were rejected\n" - "Merge the remote changes before pushing again. See the 'Note about\n" - "fast-forwards' section of 'git push --help' for details.\n"); + fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n" + "Merge the remote changes before pushing again. See the 'Note about\n" + "fast-forwards' section of 'git push --help' for details.\n"); } return 1; @@ -204,8 +209,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) int rc; const char *repo = NULL; /* default repository */ struct option options[] = { - OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET), - OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE), + OPT__VERBOSITY(&verbosity), OPT_STRING( 0 , "repo", &repo, "repository", "repository"), OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL), OPT_BIT( 0 , "mirror", &flags, "mirror all refs", @@ -220,6 +224,7 @@ int cmd_push(int argc, const char **argv, const char *prefix) OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"), OPT_BIT('u', "set-upstream", &flags, "set upstream for git pull/status", TRANSPORT_PUSH_SET_UPSTREAM), + OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"), OPT_END() };