{"thread":{"id":"15969","subject":"Re: [PATCH] Teach/Fix pull/fetch -q/-v options","startedAt":"2008-10-19T19:48:11Z","lastAt":"2008-10-21T16:25:36Z","messageCount":5,"participants":["Junio C Hamano","Tuncer Ayaz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"93462","messageId":"1224445691-1366-1-git-send-email-tuncer.ayaz@gmail.com","threadId":"15969","inReplyTo":null,"subject":"[PATCH] Teach/Fix pull/fetch -q/-v options","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-19T19:48:11Z","receivedAt":"2008-10-19T19:48:11Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"After fixing clone -q I noticed that pull -q does not do what\nit's supposed to do and implemented --quiet/--verbose by\nadding it to builtin-merge and fixing two places in builtin-fetch.\n\nI have not touched/adjusted contrib/completion/git-completion.bash\nbut can take a look if wanted. I think it already needs one or two\nadjustments caused by recent --OPTIONS changes in master.\n\nI've tested the following invocations with the below changes applied:\n$ git pull\n$ git pull -q\n$ git pull -v\n\nThis is the next attempt trying to incorporate Junio's\nsuggestions and I'm not sure about the following:\n1) having the same option callback function in both modules\n2) my adaption of the following two lines from\nbuiltin-fetch.c to the new verbosity option:\n    if (verbosity == VERBOSE)\n        transport->verbose = 1;\n    if (verbosity == QUIET)\n        transport->verbose = -1;\n3) my usage of OPTION_CALLBACK\n4) my support for overriding -q or -v\nas implemented in git-pull.sh by appending\n-q or -v as it is passed to the script\n\ntherefore please correct me if I did it wrong or my\ncb fun has an obvious defect. it may very well\nhave one :)\n\nThis revision does actually override verbosity\nbased on what was supplied later in argv (-q or -v).\n\nSigned-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n---\n Documentation/merge-options.txt |    8 +++++++\n builtin-fetch.c                 |   39 ++++++++++++++++++++++++++++---------\n builtin-merge.c                 |   40 ++++++++++++++++++++++++++++++++------\n git-pull.sh                     |   10 +++++++-\n 4 files changed, 78 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt\nindex 007909a..427cdef 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -1,3 +1,11 @@\n+-q::\n+--quiet::\n+\tOperate quietly.\n+\n+-v::\n+--verbose::\n+\tBe verbose.\n+\n --stat::\n \tShow a diffstat at the end of the merge. The diffstat is also\n \tcontrolled by the configuration option merge.stat.\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex ee93d3a..2596aee 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -22,16 +22,35 @@ enum {\n \tTAGS_SET = 2\n };\n \n-static int append, force, keep, update_head_ok, verbose, quiet;\n+static int append, force, keep, update_head_ok;\n static int tags = TAGS_DEFAULT;\n static const char *depth;\n static const char *upload_pack;\n static struct strbuf default_rla = STRBUF_INIT;\n static struct transport *transport;\n+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;\n+\n+static int option_parse_quiet(const struct option *opt,\n+\t\t\t  const char *arg, int unset)\n+{\n+\tverbosity = QUIET;\n+\treturn 0;\n+}\n+\n+static int option_parse_verbose(const struct option *opt,\n+\t\t\t  const char *arg, int unset)\n+{\n+\tverbosity = VERBOSE;\n+\treturn 0;\n+}\n \n static struct option builtin_fetch_options[] = {\n-\tOPT__QUIET(&quiet),\n-\tOPT__VERBOSE(&verbose),\n+\t{ OPTION_CALLBACK, 'q', \"quiet\", NULL, NULL,\n+\t\t\"operate quietly\",\n+\t\tPARSE_OPT_NOARG, option_parse_quiet },\n+\t{ OPTION_CALLBACK, 'v', \"verbose\", NULL, NULL,\n+\t\t\"be verbose\",\n+\t\tPARSE_OPT_NOARG, option_parse_verbose },\n \tOPT_BOOLEAN('a', \"append\", &append,\n \t\t    \"append to .git/FETCH_HEAD instead of overwriting\"),\n \tOPT_STRING(0, \"upload-pack\", &upload_pack, \"PATH\",\n@@ -192,7 +211,6 @@ static int s_update_ref(const char *action,\n \n static int update_local_ref(struct ref *ref,\n \t\t\t    const char *remote,\n-\t\t\t    int verbose,\n \t\t\t    char *display)\n {\n \tstruct commit *current = NULL, *updated;\n@@ -210,7 +228,7 @@ static int update_local_ref(struct ref *ref,\n \t\tdie(\"object %s not found\", sha1_to_hex(ref->new_sha1));\n \n \tif (!hashcmp(ref->old_sha1, ref->new_sha1)) {\n-\t\tif (verbose)\n+\t\tif (verbosity == VERBOSE)\n \t\t\tsprintf(display, \"= %-*s %-*s -> %s\", SUMMARY_WIDTH,\n \t\t\t\t\"[up to date]\", REFCOL_WIDTH, remote,\n \t\t\t\tpretty_ref);\n@@ -366,18 +384,19 @@ static int store_updated_refs(const char *url, const char *remote_name,\n \t\t\tnote);\n \n \t\tif (ref)\n-\t\t\trc |= update_local_ref(ref, what, verbose, note);\n+\t\t\trc |= update_local_ref(ref, what, note);\n \t\telse\n \t\t\tsprintf(note, \"* %-*s %-*s -> FETCH_HEAD\",\n \t\t\t\tSUMMARY_WIDTH, *kind ? kind : \"branch\",\n \t\t\t\t REFCOL_WIDTH, *what ? what : \"HEAD\");\n \t\tif (*note) {\n-\t\t\tif (!shown_url) {\n+\t\t\tif (verbosity > QUIET && !shown_url) {\n \t\t\t\tfprintf(stderr, \"From %.*s\\n\",\n \t\t\t\t\t\turl_len, url);\n \t\t\t\tshown_url = 1;\n \t\t\t}\n-\t\t\tfprintf(stderr, \" %s\\n\", note);\n+\t\t\tif (verbosity > QUIET)\n+\t\t\t\tfprintf(stderr, \" %s\\n\", note);\n \t\t}\n \t}\n \tfclose(fp);\n@@ -622,9 +641,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)\n \t\tremote = remote_get(argv[0]);\n \n \ttransport = transport_get(remote, remote->url[0]);\n-\tif (verbose >= 2)\n+\tif (verbosity == VERBOSE)\n \t\ttransport->verbose = 1;\n-\tif (quiet)\n+\tif (verbosity == QUIET)\n \t\ttransport->verbose = -1;\n \tif (upload_pack)\n \t\tset_option(TRANS_OPT_UPLOADPACK, upload_pack);\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 5e2b7f1..8259acb 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -50,6 +50,7 @@ static unsigned char head[20], stash[20];\n static struct strategy **use_strategies;\n static size_t use_strategies_nr, use_strategies_alloc;\n static const char *branch;\n+static enum { QUIET, NORMAL, VERBOSE } verbosity = NORMAL;\n \n static struct strategy all_strategy[] = {\n \t{ \"recursive\",  DEFAULT_TWOHEAD | NO_TRIVIAL },\n@@ -151,7 +152,27 @@ static int option_parse_n(const struct option *opt,\n \treturn 0;\n }\n \n+static int option_parse_quiet(const struct option *opt,\n+\t\t\t  const char *arg, int unset)\n+{\n+\tverbosity = QUIET;\n+\treturn 0;\n+}\n+\n+static int option_parse_verbose(const struct option *opt,\n+\t\t\t  const char *arg, int unset)\n+{\n+\tverbosity = VERBOSE;\n+\treturn 0;\n+}\n+\n static struct option builtin_merge_options[] = {\n+\t{ OPTION_CALLBACK, 'q', \"quiet\", NULL, NULL,\n+\t\t\"operate quietly\",\n+\t\tPARSE_OPT_NOARG, option_parse_quiet },\n+\t{ OPTION_CALLBACK, 'v', \"verbose\", NULL, NULL,\n+\t\t\"be verbose\",\n+\t\tPARSE_OPT_NOARG, option_parse_verbose },\n \t{ OPTION_CALLBACK, 'n', NULL, NULL, NULL,\n \t\t\"do not show a diffstat at the end of the merge\",\n \t\tPARSE_OPT_NOARG, option_parse_n },\n@@ -249,7 +270,8 @@ static void restore_state(void)\n /* This is called when no merge was necessary. */\n static void finish_up_to_date(const char *msg)\n {\n-\tprintf(\"%s%s\\n\", squash ? \" (nothing to squash)\" : \"\", msg);\n+\tif (verbosity > QUIET)\n+\t\tprintf(\"%s%s\\n\", squash ? \" (nothing to squash)\" : \"\", msg);\n \tdrop_save();\n }\n \n@@ -330,14 +352,15 @@ static void finish(const unsigned char *new_head, const char *msg)\n \tif (!msg)\n \t\tstrbuf_addstr(&reflog_message, getenv(\"GIT_REFLOG_ACTION\"));\n \telse {\n-\t\tprintf(\"%s\\n\", msg);\n+\t\tif (verbosity > QUIET)\n+\t\t\tprintf(\"%s\\n\", msg);\n \t\tstrbuf_addf(&reflog_message, \"%s: %s\",\n \t\t\tgetenv(\"GIT_REFLOG_ACTION\"), msg);\n \t}\n \tif (squash) {\n \t\tsquash_message();\n \t} else {\n-\t\tif (!merge_msg.len)\n+\t\tif (verbosity > QUIET && !merge_msg.len)\n \t\t\tprintf(\"No merge message -- not updating HEAD\\n\");\n \t\telse {\n \t\t\tconst char *argv_gc_auto[] = { \"gc\", \"--auto\", NULL };\n@@ -871,6 +894,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \n \targc = parse_options(argc, argv, builtin_merge_options,\n \t\t\tbuiltin_merge_usage, 0);\n+\tif (verbosity > QUIET)\n+\t\tshow_diffstat = 0;\n \n \tif (squash) {\n \t\tif (!allow_fast_forward)\n@@ -1012,10 +1037,11 @@ int cmd_merge(int argc, const char **argv, const char *prefix)\n \n \t\tstrcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));\n \n-\t\tprintf(\"Updating %s..%s\\n\",\n-\t\t\thex,\n-\t\t\tfind_unique_abbrev(remoteheads->item->object.sha1,\n-\t\t\tDEFAULT_ABBREV));\n+\t\tif (verbosity > QUIET)\n+\t\t\tprintf(\"Updating %s..%s\\n\",\n+\t\t\t\thex,\n+\t\t\t\tfind_unique_abbrev(remoteheads->item->object.sha1,\n+\t\t\t\tDEFAULT_ABBREV));\n \t\tstrbuf_addstr(&msg, \"Fast forward\");\n \t\tif (have_message)\n \t\t\tstrbuf_addstr(&msg,\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 75c3610..dc613db 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -16,6 +16,7 @@ cd_to_toplevel\n test -z \"$(git ls-files -u)\" ||\n \tdie \"You are in the middle of a conflicted merge.\"\n \n+verbosity=\n strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n curr_branch=$(git symbolic-ref -q HEAD)\n curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n@@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)\n while :\n do\n \tcase \"$1\" in\n+\t-q|--quiet)\n+\t\tverbosity=\"$verbosity -q\" ;;\n+\t-v|--verbose)\n+\t\tverbosity=\"$verbosity -v\" ;;\n \t-n|--no-stat|--no-summary)\n \t\tno_stat=-n ;;\n \t--stat|--summary)\n@@ -121,7 +126,7 @@ test true = \"$rebase\" && {\n \t\t\"refs/remotes/$origin/$reflist\" 2>/dev/null)\"\n }\n orig_head=$(git rev-parse --verify HEAD 2>/dev/null)\n-git fetch --update-head-ok \"$@\" || exit 1\n+git fetch $verbosity --update-head-ok \"$@\" || exit 1\n \n curr_head=$(git rev-parse --verify HEAD 2>/dev/null)\n if test \"$curr_head\" != \"$orig_head\"\n@@ -181,5 +186,6 @@ merge_name=$(git fmt-merge-msg $log_arg <\"$GIT_DIR/FETCH_HEAD\") || exit\n test true = \"$rebase\" &&\n \texec git-rebase $strategy_args --onto $merge_head \\\n \t${oldremoteref:-$merge_head}\n-exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \\\n+exec git-merge $verbosity $no_stat $no_commit \\\n+\t$squash $no_ff $log_arg $strategy_args \\\n \t\"$merge_name\" HEAD $merge_head\n-- \n1.6.0.2.GIT\n"},{"id":"93452","messageId":"7vy70k5las.fsf@gitster.siamese.dyndns.org","threadId":"15969","inReplyTo":"1224445691-1366-1-git-send-email-tuncer.ayaz@gmail.com","subject":"Re: [PATCH] Teach/Fix pull/fetch -q/-v options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-19T21:26:03Z","receivedAt":"2008-10-19T21:26:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tuncer Ayaz <tuncer.ayaz@gmail.com> writes:\n\n> 2) my adaption of the following two lines from\n> builtin-fetch.c to the new verbosity option:\n>     if (verbosity == VERBOSE)\n>         transport->verbose = 1;\n>     if (verbosity == QUIET)\n>         transport->verbose = -1;\n\nHmm, what's wrong with it?  Looks Ok to me...\n\n>  static struct option builtin_fetch_options[] = {\n> -\tOPT__QUIET(&quiet),\n> -\tOPT__VERBOSE(&verbose),\n> +\t{ OPTION_CALLBACK, 'q', \"quiet\", NULL, NULL,\n> +\t\t\"operate quietly\",\n> +\t\tPARSE_OPT_NOARG, option_parse_quiet },\n> +\t{ OPTION_CALLBACK, 'v', \"verbose\", NULL, NULL,\n> +\t\t\"be verbose\",\n> +\t\tPARSE_OPT_NOARG, option_parse_verbose },\n\nIsn't there a OPTION_FOO that assigns a constant to the given variable?\n\n> @@ -192,7 +211,6 @@ static int s_update_ref(const char *action,\n>  \n>  static int update_local_ref(struct ref *ref,\n>  \t\t\t    const char *remote,\n> -\t\t\t    int verbose,\n>  \t\t\t    char *display)\n>  {\n>  \tstruct commit *current = NULL, *updated;\n> ...\n> @@ -366,18 +384,19 @@ static int store_updated_refs(const char *url, const char *remote_name,\n>  \t\t\tnote);\n>  \n>  \t\tif (ref)\n> -\t\t\trc |= update_local_ref(ref, what, verbose, note);\n> +\t\t\trc |= update_local_ref(ref, what, note);\n\nHmph, in the existing code, do_fetch()->fetch_refs()->store_updated_refs()\ncallchain relies on the \"verbose\" to be global anyway, so losing the\nability to call update_local_ref() with verbosity as parameter is not a\nhuge deal.\n\nI however think it would be more beneficial in the longer term to keep\n\"verbosity\" as parameter so the caller can tweak what the callee does, and\nmaking large part of what cmd_fetch() does callable from outside.  That\nwould involve making the builtin_fetch_options[] on-stack, and passing\nverbosity (and possibly other variables currently used as file-scope\nglobal) as parameters, which is outside of the scope of your patch, but it\nis something to keep in mind.\n\n> diff --git a/git-pull.sh b/git-pull.sh\n> index 75c3610..dc613db 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -16,6 +16,7 @@ cd_to_toplevel\n>  test -z \"$(git ls-files -u)\" ||\n>  \tdie \"You are in the middle of a conflicted merge.\"\n>  \n> +verbosity=\n>  strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n>  curr_branch=$(git symbolic-ref -q HEAD)\n>  curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n\nIt would fit at the end of the next line just fine, wouldn't it?\n\n> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)\n>  while :\n>  do\n>  \tcase \"$1\" in\n> +\t-q|--quiet)\n> +\t\tverbosity=\"$verbosity -q\" ;;\n> +\t-v|--verbose)\n> +\t\tverbosity=\"$verbosity -v\" ;;\n\nYou know verbosity flags (-q and -v) are \"the last one wins\", so I do not\nsee much point in this concatenation.\n"},{"id":"93527","messageId":"4ac8254d0810200935sf7ad873tea53c0fb53bbe1c0@mail.gmail.com","threadId":"15969","inReplyTo":"7vy70k5las.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Teach/Fix pull/fetch -q/-v options","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-20T16:35:33Z","receivedAt":"2008-10-20T16:35:33Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Sun, Oct 19, 2008 at 11:26 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Tuncer Ayaz <tuncer.ayaz@gmail.com> writes:\n>\n>> 2) my adaption of the following two lines from\n>> builtin-fetch.c to the new verbosity option:\n>>     if (verbosity == VERBOSE)\n>>         transport->verbose = 1;\n>>     if (verbosity == QUIET)\n>>         transport->verbose = -1;\n>\n> Hmm, what's wrong with it?  Looks Ok to me...\n\nJust wanted to be sure it's correct, that's all.\n\nActually I think the old code:\nif (verbose >= 2)\n    transport->verbose = 1;\nis wrong and probably a leftover from old days\nas Shawn confirmed.\n\n>>  static struct option builtin_fetch_options[] = {\n>> -     OPT__QUIET(&quiet),\n>> -     OPT__VERBOSE(&verbose),\n>> +     { OPTION_CALLBACK, 'q', \"quiet\", NULL, NULL,\n>> +             \"operate quietly\",\n>> +             PARSE_OPT_NOARG, option_parse_quiet },\n>> +     { OPTION_CALLBACK, 'v', \"verbose\", NULL, NULL,\n>> +             \"be verbose\",\n>> +             PARSE_OPT_NOARG, option_parse_verbose },\n>\n> Isn't there a OPTION_FOO that assigns a constant to the given variable?\n\nYes, there is - OPT_SET_INT and I've used that in my next patch.\n\n>> @@ -192,7 +211,6 @@ static int s_update_ref(const char *action,\n>>\n>>  static int update_local_ref(struct ref *ref,\n>>                           const char *remote,\n>> -                         int verbose,\n>>                           char *display)\n>>  {\n>>       struct commit *current = NULL, *updated;\n>> ...\n>> @@ -366,18 +384,19 @@ static int store_updated_refs(const char *url, const char\n>> *remote_name,\n>>                       note);\n>>\n>>               if (ref)\n>> -                     rc |= update_local_ref(ref, what, verbose, note);\n>> +                     rc |= update_local_ref(ref, what, note);\n>\n> Hmph, in the existing code, do_fetch()->fetch_refs()->store_updated_refs()\n> callchain relies on the \"verbose\" to be global anyway, so losing the\n> ability to call update_local_ref() with verbosity as parameter is not a\n> huge deal.\n\nOK, I've kept the removal of the verbose param in the next patch.\n\n> I however think it would be more beneficial in the longer term to keep\n> \"verbosity\" as parameter so the caller can tweak what the callee does, and\n> making large part of what cmd_fetch() does callable from outside.  That\n> would involve making the builtin_fetch_options[] on-stack, and passing\n> verbosity (and possibly other variables currently used as file-scope\n> global) as parameters, which is outside of the scope of your patch, but it\n> is something to keep in mind.\n>\n>> diff --git a/git-pull.sh b/git-pull.sh\n>> index 75c3610..dc613db 100755\n>> --- a/git-pull.sh\n>> +++ b/git-pull.sh\n>> @@ -16,6 +16,7 @@ cd_to_toplevel\n>>  test -z \"$(git ls-files -u)\" ||\n>>       die \"You are in the middle of a conflicted merge.\"\n>>\n>> +verbosity=\n>>  strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n>>  curr_branch=$(git symbolic-ref -q HEAD)\n>>  curr_branch_short=$(echo \"$curr_branch\" | sed \"s|refs/heads/||\")\n>\n> It would fit at the end of the next line just fine, wouldn't it?\n>\n>> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)\n>>  while :\n>>  do\n>>       case \"$1\" in\n>> +     -q|--quiet)\n>> +             verbosity=\"$verbosity -q\" ;;\n>> +     -v|--verbose)\n>> +             verbosity=\"$verbosity -v\" ;;\n>\n> You know verbosity flags (-q and -v) are \"the last one wins\", so I do not\n> see much point in this concatenation.\n\nWithout concatenation I would need to analyze the content\nof the variable each time the option is passed to the shell\nscript. Do you know of a simpler/better way still keeping the\nfunctionality that\n$ git pull -q -v --quiet --verbose --quiet gives verbosity=QUIET\nand\n$ git pull -q -v --quiet --verbose --quiet -v yields verbosity=VERBOSE\n?\n"},{"id":"93566","messageId":"7vwsg22568.fsf@gitster.siamese.dyndns.org","threadId":"15969","inReplyTo":"4ac8254d0810200935sf7ad873tea53c0fb53bbe1c0@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix pull/fetch -q/-v options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-20T23:54:55Z","receivedAt":"2008-10-20T23:54:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Tuncer Ayaz\" <tuncer.ayaz@gmail.com> writes:\n\n> On Sun, Oct 19, 2008 at 11:26 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> ...\n>>> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)\n>>>  while :\n>>>  do\n>>>       case \"$1\" in\n>>> +     -q|--quiet)\n>>> +             verbosity=\"$verbosity -q\" ;;\n>>> +     -v|--verbose)\n>>> +             verbosity=\"$verbosity -v\" ;;\n>>\n>> You know verbosity flags (-q and -v) are \"the last one wins\", so I do not\n>> see much point in this concatenation.\n>\n> Without concatenation I would need to analyze the content\n> of the variable each time the option is passed to the shell\n> script. Do you know of a simpler/better way still keeping the\n> functionality that\n> $ git pull -q -v --quiet --verbose --quiet gives verbosity=QUIET\n> and\n> $ git pull -q -v --quiet --verbose --quiet -v yields verbosity=VERBOSE\n> ?\n\nWouldn't\n\n\tverbosity=\n\twhile :\n        do\n        \tcase \"$1\" in\n                -q|--quiet) verbosity=-q ;;\n                -v|--verbose) verbosity=-v ;;\n\t\t... others ...\n                esac\n                shift\n\tdone\n        git pull $verbosity other options\n\ngive the -q for the former and -v for the latter to \"git pull\"?\n"},{"id":"93610","messageId":"4ac8254d0810210925l11b8b471p27cc06206c7b24ca@mail.gmail.com","threadId":"15969","inReplyTo":"7vwsg22568.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Teach/Fix pull/fetch -q/-v options","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-21T16:25:36Z","receivedAt":"2008-10-21T16:25:36Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Tue, Oct 21, 2008 at 1:54 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Tuncer Ayaz\" <tuncer.ayaz@gmail.com> writes:\n>\n>> On Sun, Oct 19, 2008 at 11:26 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> ...\n>>>> @@ -23,6 +24,10 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase)\n>>>>  while :\n>>>>  do\n>>>>       case \"$1\" in\n>>>> +     -q|--quiet)\n>>>> +             verbosity=\"$verbosity -q\" ;;\n>>>> +     -v|--verbose)\n>>>> +             verbosity=\"$verbosity -v\" ;;\n>>>\n>>> You know verbosity flags (-q and -v) are \"the last one wins\", so I do not\n>>> see much point in this concatenation.\n>>\n>> Without concatenation I would need to analyze the content\n>> of the variable each time the option is passed to the shell\n>> script. Do you know of a simpler/better way still keeping the\n>> functionality that\n>> $ git pull -q -v --quiet --verbose --quiet gives verbosity=QUIET\n>> and\n>> $ git pull -q -v --quiet --verbose --quiet -v yields verbosity=VERBOSE\n>> ?\n>\n> Wouldn't\n>\n>        verbosity=\n>        while :\n>        do\n>                case \"$1\" in\n>                -q|--quiet) verbosity=-q ;;\n>                -v|--verbose) verbosity=-v ;;\n>                ... others ...\n>                esac\n>                shift\n>        done\n>        git pull $verbosity other options\n>\n> give the -q for the former and -v for the latter to \"git pull\"?\n\nYes that is much simpler and works :). Thanks.\nPlease see my next patch in a few minutes.\nI might not reply before the weekend as I'm pretty busy, btw.\n"}]}