{"thread":{"id":"15870","subject":"[PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","startedAt":"2008-10-12T16:54:38Z","lastAt":"2008-10-13T21:44:41Z","messageCount":10,"participants":["Tuncer Ayaz","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"92855","messageId":"4ac8254d0810120954x2364054ahf2d49d6fbb7b0bb1@mail.gmail.com","threadId":"15870","inReplyTo":null,"subject":"[PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-12T16:54:38Z","receivedAt":"2008-10-12T16:54:38Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"After fixing clone -q I noticed that pull -q is 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 needs one or two adjustions\nanyway 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\nSigned-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n---\n Documentation/merge-options.txt |    8 ++++++\n builtin-fetch.c                 |    5 ++-\n builtin-merge.c                 |   52 +++++++++++++++++++++++---------------\n git-pull.sh                     |   10 +++++--\n 4 files changed, 49 insertions(+), 26 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..b5c2885 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url,\nconst char *remote_name,\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 ((verbose || !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(verbose || !quiet)\n+\t\t\t\tfprintf(stderr, \" %s\\n\", note);\n \t\t}\n \t}\n \tfclose(fp);\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 38266ba..1f601d4 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -44,6 +44,7 @@ static const char * const builtin_merge_usage[] = {\n static int show_diffstat = 1, option_log, squash;\n static int option_commit = 1, allow_fast_forward = 1;\n static int allow_trivial = 1, have_message;\n+static int quiet, verbose;\n static struct strbuf merge_msg;\n static struct commit_list *remoteheads;\n static unsigned char head[20], stash[20];\n@@ -101,7 +102,7 @@ static struct strategy *get_strategy(const char *name)\n \t\t\tstruct cmdname *ent = main_cmds.names[i];\n \t\t\tfor (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\n-\t\t\t\t\t\t&& !all_strategy[j].name[ent->len])\n+\t\t\t\t\t&& !all_strategy[j].name[ent->len])\n \t\t\t\t\tfound = 1;\n \t\t\tif (!found)\n \t\t\t\tadd_cmdname(&not_strategies, ent->name, ent->len);\n@@ -152,6 +153,8 @@ static int option_parse_n(const struct option *opt,\n }\n\n static struct option builtin_merge_options[] = {\n+\tOPT__QUIET(&quiet),\n+\tOPT__VERBOSE(&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@@ -250,7 +253,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(verbose || !quiet)\n+\t\tprintf(\"%s%s\\n\", squash ? \" (nothing to squash)\" : \"\", msg);\n \tdrop_save();\n }\n\n@@ -262,7 +266,8 @@ static void squash_message(void)\n \tstruct commit_list *j;\n \tint fd;\n\n-\tprintf(\"Squash commit -- not updating HEAD\\n\");\n+\tif(verbose || !quiet)\n+\t\tprintf(\"Squash commit -- not updating HEAD\\n\");\n \tfd = open(git_path(\"SQUASH_MSG\"), O_WRONLY | O_CREAT, 0666);\n \tif (fd < 0)\n \t\tdie(\"Could not write to %s\", git_path(\"SQUASH_MSG\"));\n@@ -282,18 +287,20 @@ static void squash_message(void)\n \tif (prepare_revision_walk(&rev))\n \t\tdie(\"revision walk setup failed\");\n\n-\tstrbuf_init(&out, 0);\n-\tstrbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n-\twhile ((commit = get_revision(&rev)) != NULL) {\n-\t\tstrbuf_addch(&out, '\\n');\n-\t\tstrbuf_addf(&out, \"commit %s\\n\",\n-\t\t\tsha1_to_hex(commit->object.sha1));\n-\t\tpretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n-\t\t\tNULL, NULL, rev.date_mode, 0);\n+\tif(verbose || !quiet) {\n+\t\tstrbuf_init(&out, 0);\n+\t\tstrbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n+\t\twhile ((commit = get_revision(&rev)) != NULL) {\n+\t\t\tstrbuf_addch(&out, '\\n');\n+\t\t\tstrbuf_addf(&out, \"commit %s\\n\",\n+\t\t\t\t\t\tsha1_to_hex(commit->object.sha1));\n+\t\t\tpretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n+\t\t\t\t\t\t\t\tNULL, NULL, rev.date_mode, 0);\n+\t\t}\n+\t\twrite(fd, out.buf, out.len);\n+\t\tclose(fd);\n+\t\tstrbuf_release(&out);\n \t}\n-\twrite(fd, out.buf, out.len);\n-\tclose(fd);\n-\tstrbuf_release(&out);\n }\n\n static int run_hook(const char *name)\n@@ -333,14 +340,15 @@ static void finish(const unsigned char\n*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(verbose || !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 ((verbose || !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@@ -877,6 +885,8 @@ int cmd_merge(int argc, const char **argv, const\nchar *prefix)\n\n \targc = parse_options(argc, argv, builtin_merge_options,\n \t\t\tbuiltin_merge_usage, 0);\n+\tif(!verbose && quiet)\n+\t\tshow_diffstat = 0;\n\n \tif (squash) {\n \t\tif (!allow_fast_forward)\n@@ -1019,11 +1029,11 @@ int cmd_merge(int argc, const char **argv,\nconst char *prefix)\n \t\tchar hex[41];\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(verbose || !quiet)\n+\t\t\tprintf(\"Updating %s..%s\\n\",\n+\t\t\t\t   hex,\n+\t\t\t\t   find_unique_abbrev(remoteheads->item->object.sha1,\n+\t\t\t\t\t\t\t\t\t  DEFAULT_ABBREV));\n \t\tstrbuf_init(&msg, 0);\n \t\tstrbuf_addstr(&msg, \"Fast forward\");\n \t\tif (have_message)\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 75c3610..d84ceb5 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -16,13 +16,17 @@ cd_to_toplevel\n test -z \"$(git ls-files -u)\" ||\n \tdie \"You are in the middle of a conflicted merge.\"\n\n-strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n+quiet= verbose= 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 rebase=$(git config --bool branch.$curr_branch_short.rebase)\n while :\n do\n \tcase \"$1\" in\n+\t-q|--quiet)\n+\t\tquiet=-q ;;\n+\t-v|--verbose)\n+\t\tverbose=-v ;;\n \t-n|--no-stat|--no-summary)\n \t\tno_stat=-n ;;\n \t--stat|--summary)\n@@ -121,7 +125,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 $verbose $quiet --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 +185,5 @@ merge_name=$(git fmt-merge-msg $log_arg\n<\"$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 $quiet $verbose $no_stat $no_commit $squash $no_ff\n$log_arg $strategy_args \\\n \t\"$merge_name\" HEAD $merge_head\n-- \n1.6.0.2.GIT\n"},{"id":"92869","messageId":"20081012200833.GC5255@spearce.org","threadId":"15870","inReplyTo":"4ac8254d0810120954x2364054ahf2d49d6fbb7b0bb1@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-12T20:08:33Z","receivedAt":"2008-10-12T20:08:33Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n> After fixing clone -q I noticed that pull -q is does not do what\n> it's supposed to do and implemented --quiet/--verbose by\n> adding it to builtin-merge and fixing two places in builtin-fetch.\n \n> diff --git a/builtin-merge.c b/builtin-merge.c\n> index 38266ba..1f601d4 100644\n> --- a/builtin-merge.c\n> +++ b/builtin-merge.c\n> @@ -101,7 +102,7 @@ static struct strategy *get_strategy(const char *name)\n>  \t\t\tstruct cmdname *ent = main_cmds.names[i];\n>  \t\t\tfor (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n>  \t\t\t\tif (!strncmp(ent->name, all_strategy[j].name, ent->len)\n> -\t\t\t\t\t\t&& !all_strategy[j].name[ent->len])\n> +\t\t\t\t\t&& !all_strategy[j].name[ent->len])\n\nThis hunk seems to just be whitespace formatting.  I'd rather not\nsee it in a patch that is otherwise about --quiet/--verbose changes.\nOne change per patch, please.  ;-)\n\n> @@ -282,18 +287,20 @@ static void squash_message(void)\n>  \tif (prepare_revision_walk(&rev))\n>  \t\tdie(\"revision walk setup failed\");\n> \n> -\tstrbuf_init(&out, 0);\n> -\tstrbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n> -\twhile ((commit = get_revision(&rev)) != NULL) {\n> -\t\tstrbuf_addch(&out, '\\n');\n> -\t\tstrbuf_addf(&out, \"commit %s\\n\",\n> -\t\t\tsha1_to_hex(commit->object.sha1));\n> -\t\tpretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n> -\t\t\tNULL, NULL, rev.date_mode, 0);\n> +\tif(verbose || !quiet) {\n> +\t\tstrbuf_init(&out, 0);\n> +\t\tstrbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n> +\t\twhile ((commit = get_revision(&rev)) != NULL) {\n> +\t\t\tstrbuf_addch(&out, '\\n');\n> +\t\t\tstrbuf_addf(&out, \"commit %s\\n\",\n> +\t\t\t\t\t\tsha1_to_hex(commit->object.sha1));\n> +\t\t\tpretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n> +\t\t\t\t\t\t\t\tNULL, NULL, rev.date_mode, 0);\n> +\t\t}\n> +\t\twrite(fd, out.buf, out.len);\n> +\t\tclose(fd);\n> +\t\tstrbuf_release(&out);\n>  \t}\n> -\twrite(fd, out.buf, out.len);\n> -\tclose(fd);\n> -\tstrbuf_release(&out);\n\nThis entire hunk strikes me as being completely wrong.  The fd\nwe are writing to is SQUASH_MSG.  It was opened earlier in the\nfunction and should be closed, even if we put nothing into the\nfile.  Your change causes --quiet to leak the file descriptor.\n\nBut even worse, I think your change causes SQUASH_MSG to lose its\nentire content, which makes \"git merge --quiet --squash\" behave\nvery differently from what it does today, where it at least gives\nyou a summary of the commits in the SQUASH_MSG file.\n\nIMHO this hunk shouldn't be here.\n\n> @@ -877,6 +885,8 @@ int cmd_merge(int argc, const char **argv, const\n> char *prefix)\n> \n>  \targc = parse_options(argc, argv, builtin_merge_options,\n>  \t\t\tbuiltin_merge_usage, 0);\n> +\tif(!verbose && quiet)\n> +\t\tshow_diffstat = 0;\n\nFormatting nit, use \"if (\".\n\n> @@ -1019,11 +1029,11 @@ int cmd_merge(int argc, const char **argv,\n> const char *prefix)\n>  \t\tchar hex[41];\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(verbose || !quiet)\n\nFormatting nit, use \"if (\".\n\n> diff --git a/git-pull.sh b/git-pull.sh\n> index 75c3610..d84ceb5 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -16,13 +16,17 @@ cd_to_toplevel\n>  test -z \"$(git ls-files -u)\" ||\n>  \tdie \"You are in the middle of a conflicted merge.\"\n> \n> -strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n> +quiet= verbose= strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n\nThis line got a little long, maybe put the two new ones on a new\nline so we don't overrun the 80 column margin and there's an easier\nto read diff?\n\n-- \nShawn.\n"},{"id":"92871","messageId":"4ac8254d0810121329r2227d214qd7e4691aabf2c965@mail.gmail.com","threadId":"15870","inReplyTo":"20081012200833.GC5255@spearce.org","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-12T20:29:37Z","receivedAt":"2008-10-12T20:29:37Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Sun, Oct 12, 2008 at 10:08 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n>> After fixing clone -q I noticed that pull -q is does not do what\n>> it's supposed to do and implemented --quiet/--verbose by\n>> adding it to builtin-merge and fixing two places in builtin-fetch.\n>\n>> diff --git a/builtin-merge.c b/builtin-merge.c\n>> index 38266ba..1f601d4 100644\n>> --- a/builtin-merge.c\n>> +++ b/builtin-merge.c\n>> @@ -101,7 +102,7 @@ static struct strategy *get_strategy(const char *name)\n>>                       struct cmdname *ent = main_cmds.names[i];\n>>                       for (j = 0; j < ARRAY_SIZE(all_strategy); j++)\n>>                               if (!strncmp(ent->name, all_strategy[j].name, ent->len)\n>> -                                             && !all_strategy[j].name[ent->len])\n>> +                                     && !all_strategy[j].name[ent->len])\n>\n> This hunk seems to just be whitespace formatting.  I'd rather not\n> see it in a patch that is otherwise about --quiet/--verbose changes.\n> One change per patch, please.  ;-)\n\nHi Shawn, thanks for the quick review.\n\nThis is a problem caused by my automagic editor\nconfiguration and an oversight. ACK.\n\n>> @@ -282,18 +287,20 @@ static void squash_message(void)\n>>       if (prepare_revision_walk(&rev))\n>>               die(\"revision walk setup failed\");\n>>\n>> -     strbuf_init(&out, 0);\n>> -     strbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n>> -     while ((commit = get_revision(&rev)) != NULL) {\n>> -             strbuf_addch(&out, '\\n');\n>> -             strbuf_addf(&out, \"commit %s\\n\",\n>> -                     sha1_to_hex(commit->object.sha1));\n>> -             pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n>> -                     NULL, NULL, rev.date_mode, 0);\n>> +     if(verbose || !quiet) {\n>> +             strbuf_init(&out, 0);\n>> +             strbuf_addstr(&out, \"Squashed commit of the following:\\n\");\n>> +             while ((commit = get_revision(&rev)) != NULL) {\n>> +                     strbuf_addch(&out, '\\n');\n>> +                     strbuf_addf(&out, \"commit %s\\n\",\n>> +                                             sha1_to_hex(commit->object.sha1));\n>> +                     pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,\n>> +                                                             NULL, NULL, rev.date_mode, 0);\n>> +             }\n>> +             write(fd, out.buf, out.len);\n>> +             close(fd);\n>> +             strbuf_release(&out);\n>>       }\n>> -     write(fd, out.buf, out.len);\n>> -     close(fd);\n>> -     strbuf_release(&out);\n>\n> This entire hunk strikes me as being completely wrong.  The fd\n> we are writing to is SQUASH_MSG.  It was opened earlier in the\n> function and should be closed, even if we put nothing into the\n> file.  Your change causes --quiet to leak the file descriptor.\n>\n> But even worse, I think your change causes SQUASH_MSG to lose its\n> entire content, which makes \"git merge --quiet --squash\" behave\n> very differently from what it does today, where it at least gives\n> you a summary of the commits in the SQUASH_MSG file.\n>\n> IMHO this hunk shouldn't be here.\n\nYou are right, I was not 100% sure whether the assembled\nmessage is only displayed or possibly also stored somewhere.\nWhat would be the right place to quieten this one?\nI should have tagged the mail as an RFC :-).\n\n>> @@ -877,6 +885,8 @@ int cmd_merge(int argc, const char **argv, const\n>> char *prefix)\n>>\n>>       argc = parse_options(argc, argv, builtin_merge_options,\n>>                       builtin_merge_usage, 0);\n>> +     if(!verbose && quiet)\n>> +             show_diffstat = 0;\n>\n> Formatting nit, use \"if (\".\n\nACK.\n\n>> @@ -1019,11 +1029,11 @@ int cmd_merge(int argc, const char **argv,\n>> const char *prefix)\n>>               char hex[41];\n>>\n>>               strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));\n>> -\n>> -             printf(\"Updating %s..%s\\n\",\n>> -                     hex,\n>> -                     find_unique_abbrev(remoteheads->item->object.sha1,\n>> -                     DEFAULT_ABBREV));\n>> +             if(verbose || !quiet)\n>\n> Formatting nit, use \"if (\".\n\nACK.\n\n>> diff --git a/git-pull.sh b/git-pull.sh\n>> index 75c3610..d84ceb5 100755\n>> --- a/git-pull.sh\n>> +++ b/git-pull.sh\n>> @@ -16,13 +16,17 @@ cd_to_toplevel\n>>  test -z \"$(git ls-files -u)\" ||\n>>       die \"You are in the middle of a conflicted merge.\"\n>>\n>> -strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n>> +quiet= verbose= strategy_args= no_stat= no_commit= squash= no_ff= log_arg=\n>\n> This line got a little long, maybe put the two new ones on a new\n> line so we don't overrun the 80 column margin and there's an easier\n> to read diff?\n\nACK.\n\nI will fix the obvious and see what I can come up with for the\npretty_print hunk.\n"},{"id":"92875","messageId":"4ac8254d0810121431v1a67afc8ua92842b3d8c39328@mail.gmail.com","threadId":"15870","inReplyTo":"20081012200833.GC5255@spearce.org","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-12T21:31:44Z","receivedAt":"2008-10-12T21:31:44Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Sun, Oct 12, 2008 at 10:08 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n\n<snip>\n\nI've incorporated all defects as noticed by Shawn and\nthanks to him found out that the changes in\nsquash_message() are definitely not needed and are\nmore of a left-over of my tryout/devel session.\nMoreover I've avoided further whitespace changes.\n\n---\n\n>From 31fd16eccf2df334aef8fb59d4e48cf97cca93eb Mon Sep 17 00:00:00 2001\nFrom: Tuncer Ayaz <tuncer.ayaz@gmail.com>\nDate: Sun, 12 Oct 2008 23:27:14 +0200\nSubject: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose\n\nSigned-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n---\n Documentation/merge-options.txt |    8 ++++++++\n builtin-fetch.c                 |    5 +++--\n builtin-merge.c                 |   22 +++++++++++++++-------\n git-pull.sh                     |   10 ++++++++--\n 4 files changed, 34 insertions(+), 11 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..287ce33 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url,\nconst char *remote_name,\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 ((verbose || !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 (verbose || !quiet)\n+\t\t\t\tfprintf(stderr, \" %s\\n\", note);\n \t\t}\n \t}\n \tfclose(fp);\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 38266ba..dc12a2a 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -44,6 +44,7 @@ static const char * const builtin_merge_usage[] = {\n static int show_diffstat = 1, option_log, squash;\n static int option_commit = 1, allow_fast_forward = 1;\n static int allow_trivial = 1, have_message;\n+static int quiet, verbose;\n static struct strbuf merge_msg;\n static struct commit_list *remoteheads;\n static unsigned char head[20], stash[20];\n@@ -152,6 +153,8 @@ static int option_parse_n(const struct option *opt,\n }\n\n static struct option builtin_merge_options[] = {\n+\tOPT__QUIET(&quiet),\n+\tOPT__VERBOSE(&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@@ -250,7 +253,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 (verbose || !quiet)\n+\t\tprintf(\"%s%s\\n\", squash ? \" (nothing to squash)\" : \"\", msg);\n \tdrop_save();\n }\n\n@@ -333,14 +337,15 @@ static void finish(const unsigned char\n*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 (verbose || !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 ((verbose || !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@@ -877,6 +882,8 @@ int cmd_merge(int argc, const char **argv, const\nchar *prefix)\n\n \targc = parse_options(argc, argv, builtin_merge_options,\n \t\t\tbuiltin_merge_usage, 0);\n+\tif (!verbose && quiet)\n+\t\tshow_diffstat = 0;\n\n \tif (squash) {\n \t\tif (!allow_fast_forward)\n@@ -1020,10 +1027,11 @@ int cmd_merge(int argc, const char **argv,\nconst 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 (verbose || !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_init(&msg, 0);\n \t\tstrbuf_addstr(&msg, \"Fast forward\");\n \t\tif (have_message)\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 75c3610..8e25d44 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+quiet= verbose=\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\tquiet=-q ;;\n+\t-v|--verbose)\n+\t\tverbose=-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 $verbose $quiet --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\n<\"$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 $quiet $verbose $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":"92877","messageId":"4ac8254d0810121436x6285d17ew631f04e768a6fb62@mail.gmail.com","threadId":"15870","inReplyTo":"4ac8254d0810121431v1a67afc8ua92842b3d8c39328@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-12T21:36:47Z","receivedAt":"2008-10-12T21:36:47Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Sun, Oct 12, 2008 at 11:31 PM, Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n> On Sun, Oct 12, 2008 at 10:08 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n>\n> <snip>\n>\n> I've incorporated all defects as noticed by Shawn and\n\nI did of course intend to write\ns/incorporated/repaired/ :-)\n\n> thanks to him found out that the changes in\n> squash_message() are definitely not needed and are\n> more of a left-over of my tryout/devel session.\n> Moreover I've avoided further whitespace changes.\n\n<snip>\n"},{"id":"92963","messageId":"4ac8254d0810131403i4c8c57d6r71531e34321e9b50@mail.gmail.com","threadId":"15870","inReplyTo":"4ac8254d0810121436x6285d17ew631f04e768a6fb62@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-13T21:03:05Z","receivedAt":"2008-10-13T21:03:05Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"Hi Shawn and list,\n\nI've updated the patch to current Junio master.\n\nSigned-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n---\n Documentation/merge-options.txt |    8 ++++++++\n builtin-fetch.c                 |    5 +++--\n builtin-merge.c                 |   22 +++++++++++++++-------\n git-pull.sh                     |   10 ++++++++--\n 4 files changed, 34 insertions(+), 11 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..287ce33 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -372,12 +372,13 @@ static int store_updated_refs(const char *url,\nconst char *remote_name,\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 ((verbose || !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 (verbose || !quiet)\n+\t\t\t\tfprintf(stderr, \" %s\\n\", note);\n \t\t}\n \t}\n \tfclose(fp);\ndiff --git a/builtin-merge.c b/builtin-merge.c\nindex 5e2b7f1..4f90501 100644\n--- a/builtin-merge.c\n+++ b/builtin-merge.c\n@@ -44,6 +44,7 @@ static const char * const builtin_merge_usage[] = {\n static int show_diffstat = 1, option_log, squash;\n static int option_commit = 1, allow_fast_forward = 1;\n static int allow_trivial = 1, have_message;\n+static int quiet, verbose;\n static struct strbuf merge_msg;\n static struct commit_list *remoteheads;\n static unsigned char head[20], stash[20];\n@@ -152,6 +153,8 @@ static int option_parse_n(const struct option *opt,\n }\n\n static struct option builtin_merge_options[] = {\n+\tOPT__QUIET(&quiet),\n+\tOPT__VERBOSE(&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 +252,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 (verbose || !quiet)\n+\t\tprintf(\"%s%s\\n\", squash ? \" (nothing to squash)\" : \"\", msg);\n \tdrop_save();\n }\n\n@@ -330,14 +334,15 @@ static void finish(const unsigned char\n*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 (verbose || !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 ((verbose || !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 +876,8 @@ int cmd_merge(int argc, const char **argv, const\nchar *prefix)\n\n \targc = parse_options(argc, argv, builtin_merge_options,\n \t\t\tbuiltin_merge_usage, 0);\n+\tif (!verbose && quiet)\n+\t\tshow_diffstat = 0;\n\n \tif (squash) {\n \t\tif (!allow_fast_forward)\n@@ -1012,10 +1019,11 @@ int cmd_merge(int argc, const char **argv,\nconst 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 (verbose || !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..8e25d44 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+quiet= verbose=\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\tquiet=-q ;;\n+\t-v|--verbose)\n+\t\tverbose=-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 $verbose $quiet --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\n<\"$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 $quiet $verbose $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":"92965","messageId":"20081013210607.GV4856@spearce.org","threadId":"15870","inReplyTo":"4ac8254d0810131403i4c8c57d6r71531e34321e9b50@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-13T21:06:07Z","receivedAt":"2008-10-13T21:06:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n> Hi Shawn and list,\n> \n> I've updated the patch to current Junio master.\n> \n> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n\nLooks good to me.\n\n-- \nShawn.\n"},{"id":"92975","messageId":"4ac8254d0810131412o34c01a4cla30eadc45e2e4e06@mail.gmail.com","threadId":"15870","inReplyTo":"20081013210607.GV4856@spearce.org","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-13T21:12:18Z","receivedAt":"2008-10-13T21:12:18Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n>> Hi Shawn and list,\n>>\n>> I've updated the patch to current Junio master.\n>>\n>> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n>\n> Looks good to me.\n\nGMail borked it by inserting some linebreaks :(\nis that a problem for this single diff or should\nI first resend it properly via SMTP?\n"},{"id":"92976","messageId":"20081013211327.GW4856@spearce.org","threadId":"15870","inReplyTo":"4ac8254d0810131412o34c01a4cla30eadc45e2e4e06@mail.gmail.com","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-13T21:13:27Z","receivedAt":"2008-10-13T21:13:27Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n> On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n> >> Hi Shawn and list,\n> >>\n> >> I've updated the patch to current Junio master.\n> >>\n> >> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n> >\n> > Looks good to me.\n> \n> GMail borked it by inserting some linebreaks :(\n> is that a problem for this single diff or should\n> I first resend it properly via SMTP?\n\nI would resend it.  For a one line diff its easy to hand apply,\nbut with multiple hunks like this you don't to waste Junio's time\nby trying to fix up the patch by hand.\n\n-- \nShawn.\n"},{"id":"92978","messageId":"4ac8254d0810131444l3a3f60aaqa86b1e6f5a4af76e@mail.gmail.com","threadId":"15870","inReplyTo":"20081013211327.GW4856@spearce.org","subject":"Re: [PATCH] Teach/Fix git-pull/git-merge --quiet and --verbose","fromName":"Tuncer Ayaz","fromEmail":"tuncer.ayaz@gmail.com","sentAt":"2008-10-13T21:44:41Z","receivedAt":"2008-10-13T21:44:41Z","isPatch":true,"sender":{"key":"tuncer.ayaz@gmail.com","avatar":null},"body":"On Mon, Oct 13, 2008 at 11:13 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n>> On Mon, Oct 13, 2008 at 11:06 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n>> > Tuncer Ayaz <tuncer.ayaz@gmail.com> wrote:\n>> >> Hi Shawn and list,\n>> >>\n>> >> I've updated the patch to current Junio master.\n>> >>\n>> >> Signed-off-by: Tuncer Ayaz <tuncer.ayaz@gmail.com>\n>> >\n>> > Looks good to me.\n>>\n>> GMail borked it by inserting some linebreaks :(\n>> is that a problem for this single diff or should\n>> I first resend it properly via SMTP?\n>\n> I would resend it.  For a one line diff its easy to hand apply,\n> but with multiple hunks like this you don't to waste Junio's time\n> by trying to fix up the patch by hand.\n\nOK, configured my local setup for send-email to work\nand used that.\n"}]}