{"thread":{"id":"12597","subject":"Improve git pull --quiet behaviour","startedAt":"2008-03-08T23:52:34Z","lastAt":"2008-03-09T22:31:11Z","messageCount":7,"participants":["Iustin Pop","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"71480","messageId":"1205020356-6682-1-git-send-email-iusty@k1024.org","threadId":"12597","inReplyTo":null,"subject":"Improve git pull --quiet behaviour","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-08T23:52:34Z","receivedAt":"2008-03-08T23:52:34Z","isPatch":false,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"While trying to cleanup some cron jobs that do \"git pull\", I found out\nthat \"-q\" doesn't behave as expected. The following two small patches\nimprove the handling of this option.\n\nMy tests show that now 'git pull -q' when there are no changes is silent\nas expected and plain 'git pull' has the previous behaviour. I hope that\nI followed the code style correctly while modifying the files.\n\nOverall diff stats:\n Documentation/git-merge.txt     |    2 +-\n Documentation/merge-options.txt |    4 ++++\n git-merge.sh                    |   19 +++++++++++++------\n git-pull.sh                     |    8 +++++---\n 4 files changed, 23 insertions(+), 10 deletions(-)\n\nregards,\niustin\n"},{"id":"71481","messageId":"1205020356-6682-2-git-send-email-iusty@k1024.org","threadId":"12597","inReplyTo":"1205020356-6682-1-git-send-email-iusty@k1024.org","subject":"[PATCH 1/2] Add a quiet option to git merge","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-08T23:52:35Z","receivedAt":"2008-03-08T23:52:35Z","isPatch":true,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"Currently it's not possible to do quiet merges in case of no changes\nbecause git merge always outputs the 'Already up to date' message.\n\nThis small patch adds a quiet option to git merge that in this case will\nskip the output of this message.\n---\n Documentation/git-merge.txt     |    2 +-\n Documentation/merge-options.txt |    4 ++++\n git-merge.sh                    |   19 +++++++++++++------\n 3 files changed, 18 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt\nindex c136b10..0c4cd19 100644\n--- a/Documentation/git-merge.txt\n+++ b/Documentation/git-merge.txt\n@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together\n SYNOPSIS\n --------\n [verse]\n-'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...\n+'git-merge' [-n] [-q] [--summary] [--no-commit] [--squash] [-s <strategy>]...\n \t[-m <msg>] <remote> <remote>...\n 'git-merge' <msg> HEAD <remote>...\n \ndiff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt\nindex 9f1fc82..dbedf40 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -5,6 +5,10 @@\n -n, \\--no-summary::\n \tDo not show diffstat at the end of the merge.\n \n+-q, \\--quiet::\n+\tSupress the 'Already up to date' message if no merge is\n+\tneeded.\n+\n --no-commit::\n \tPerform the merge but pretend the merge failed and do\n \tnot autocommit, to give the user a chance to inspect and\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 7dbbb1d..625457e 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -15,6 +15,7 @@ commit               perform a commit if the merge sucesses (default)\n ff                   allow fast forward (default)\n s,strategy=          merge strategy to use\n m,message=           message to be used for the merge commit (if any)\n+q,quiet              suppress some default messages\n \"\n \n SUBDIRECTORY_OK=Yes\n@@ -38,6 +39,7 @@ use_strategies=\n allow_fast_forward=t\n allow_trivial_merge=t\n squash= no_commit=\n+quiet=\n \n dropsave() {\n \trm -f -- \"$GIT_DIR/MERGE_HEAD\" \"$GIT_DIR/MERGE_MSG\" \\\n@@ -59,12 +61,15 @@ restorestate() {\n }\n \n finish_up_to_date () {\n-\tcase \"$squash\" in\n-\tt)\n-\t\techo \"$1 (nothing to squash)\" ;;\n-\t'')\n-\t\techo \"$1\" ;;\n-\tesac\n+\tif test -z \"$quiet\"\n+\tthen\n+\t\tcase \"$squash\" in\n+\t\tt)\n+\t\t\techo \"$1 (nothing to squash)\" ;;\n+\t\t'')\n+\t\t\techo \"$1\" ;;\n+\t\tesac\n+\tfi\n \tdropsave\n }\n \n@@ -182,6 +187,8 @@ parse_config () {\n \t\t\tmerge_msg=\"$1\"\n \t\t\thave_message=t\n \t\t\t;;\n+\t\t-q|--quiet)\n+\t\t\tquiet=t ;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak ;;\n-- \n1.5.4.3\n\n"},{"id":"71482","messageId":"1205020356-6682-3-git-send-email-iusty@k1024.org","threadId":"12597","inReplyTo":"1205020356-6682-1-git-send-email-iusty@k1024.org","subject":"[PATCH 2/2] Fix git pull handling of the quiet option","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-08T23:52:36Z","receivedAt":"2008-03-08T23:52:36Z","isPatch":true,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"Although git pull has a documented quiet option, currently it doesn't\nhandle this option at all, and this results in it terminating the\nhandling of command line options when this particular option is met.\n\nMore exactly, it will cause the following invocation:\n  git pull --quiet --no-commit\nto fail with:\n  error: unknown option `no-commit'\n  usage: git-fetch [options] [<repository> <refspec>...]\nbecause it will not look at anything after quiet (and no-commit and\nother options should not be passed to git fetch).\n\nThis patch adds the handling of this option, and passes it correctly to\nboth git fetch and git merge (and therefore needs to be applied on top\nof patched git merge).\n---\n git-pull.sh |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 3ce32b5..2201ca0 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -16,7 +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-strategy_args= no_summary= no_commit= squash= no_ff=\n+strategy_args= no_summary= no_commit= squash= no_ff= quiet=\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@@ -61,6 +61,8 @@ do\n \t--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)\n \t\trebase=false\n \t\t;;\n+\t-q|--q|--qui|--quie|--quiet)\n+\t\tquiet=--quiet ;;\n \t-h|--h|--he|--hel|--help)\n \t\tusage\n \t\t;;\n@@ -116,7 +118,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 $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@@ -177,4 +179,4 @@ test true = \"$rebase\" &&\n \texec git-rebase $strategy_args --onto $merge_head \\\n \t${oldremoteref:-$merge_head}\n exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \\\n-\t\"$merge_name\" HEAD $merge_head\n+\t$quiet \"$merge_name\" HEAD $merge_head\n-- \n1.5.4.3\n\n"},{"id":"71489","messageId":"7v8x0ssfud.fsf@gitster.siamese.dyndns.org","threadId":"12597","inReplyTo":"1205020356-6682-3-git-send-email-iusty@k1024.org","subject":"Re: [PATCH 2/2] Fix git pull handling of the quiet option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-09T04:04:26Z","receivedAt":"2008-03-09T04:04:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Iustin Pop <iusty@k1024.org> writes:\n\n> Although git pull has a documented quiet option,...\n\nI think that is a documentation bug.  pull accepts all options for fetch\nfor the sole purpose of passing them intact to underlying fetch, and some\noptions to fetch does not even make much sense in the context of pull.\n\nAlso options to pull needs to come first; the options pull does not know\nabout is a signal for pull that the rest is for consumption of underlying\nfetch.\n\nIf you want to teach --quiet to pull, however, your patch is the right\napproach.  pull would eat --quiet and make a note for itself, and passes\nthat to underlying fetch (and perhaps merge).\n\nYou also need to sign-off your patch and add tests to make sure that other\npeople will not break your enhancement in the future.\n"},{"id":"71503","messageId":"20080309103135.GF32019@teal.hq.k1024.org","threadId":"12597","inReplyTo":"7v8x0ssfud.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2] Fix git pull handling of the quiet option","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-09T10:31:35Z","receivedAt":"2008-03-09T10:31:35Z","isPatch":true,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"On Sat, Mar 08, 2008 at 08:04:26PM -0800, Junio C Hamano wrote:\n> Iustin Pop <iusty@k1024.org> writes:\n> \n> > Although git pull has a documented quiet option,...\n> \n> I think that is a documentation bug.  pull accepts all options for fetch\n> for the sole purpose of passing them intact to underlying fetch, and some\n> options to fetch does not even make much sense in the context of pull.\n> \n> Also options to pull needs to come first; the options pull does not know\n> about is a signal for pull that the rest is for consumption of underlying\n> fetch.\nAh, I see. This is indeed not clear from the documentation.\n\n> If you want to teach --quiet to pull, however, your patch is the right\n> approach.  pull would eat --quiet and make a note for itself, and passes\n> that to underlying fetch (and perhaps merge).\n> \n> You also need to sign-off your patch and add tests to make sure that other\n> people will not break your enhancement in the future.\nThanks, so the approach would be:\n  - resend git merge patch including tests\n  - and then resend git pull patch, again including tests.\n\nThanks for the feedback, I will try to see how the unittests are written\nand hopefully come back with some more patches.\n\niustin\n"},{"id":"71511","messageId":"20080309121822.GA25890@teal.hq.k1024.org","threadId":"12597","inReplyTo":"1205020356-6682-2-git-send-email-iusty@k1024.org","subject":"[PATCH] Add a quiet option to git merge","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-09T12:18:22Z","receivedAt":"2008-03-09T12:18:22Z","isPatch":true,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"Currently it's not possible to do quiet merges in case of no changes\nbecause git merge always outputs the 'Already up to date' message.\n\nThis small patch adds a quiet option to git merge that in this case will\nskip the output of this message. It also adds a test for this new\noption.\n\nSigned-off-by: Iustin Pop <iusty@k1024.org>\n---\n This new version has a test too for this option but I'm not sure if\n it's the right place to add it.\n\n Documentation/git-merge.txt     |    2 +-\n Documentation/merge-options.txt |    4 ++++\n git-merge.sh                    |   19 +++++++++++++------\n t/t7600-merge.sh                |    5 +++++\n 4 files changed, 23 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt\nindex c136b10..0c4cd19 100644\n--- a/Documentation/git-merge.txt\n+++ b/Documentation/git-merge.txt\n@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together\n SYNOPSIS\n --------\n [verse]\n-'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...\n+'git-merge' [-n] [-q] [--summary] [--no-commit] [--squash] [-s <strategy>]...\n \t[-m <msg>] <remote> <remote>...\n 'git-merge' <msg> HEAD <remote>...\n \ndiff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt\nindex 9f1fc82..dbedf40 100644\n--- a/Documentation/merge-options.txt\n+++ b/Documentation/merge-options.txt\n@@ -5,6 +5,10 @@\n -n, \\--no-summary::\n \tDo not show diffstat at the end of the merge.\n \n+-q, \\--quiet::\n+\tSupress the 'Already up to date' message if no merge is\n+\tneeded.\n+\n --no-commit::\n \tPerform the merge but pretend the merge failed and do\n \tnot autocommit, to give the user a chance to inspect and\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 7dbbb1d..625457e 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -15,6 +15,7 @@ commit               perform a commit if the merge sucesses (default)\n ff                   allow fast forward (default)\n s,strategy=          merge strategy to use\n m,message=           message to be used for the merge commit (if any)\n+q,quiet              suppress some default messages\n \"\n \n SUBDIRECTORY_OK=Yes\n@@ -38,6 +39,7 @@ use_strategies=\n allow_fast_forward=t\n allow_trivial_merge=t\n squash= no_commit=\n+quiet=\n \n dropsave() {\n \trm -f -- \"$GIT_DIR/MERGE_HEAD\" \"$GIT_DIR/MERGE_MSG\" \\\n@@ -59,12 +61,15 @@ restorestate() {\n }\n \n finish_up_to_date () {\n-\tcase \"$squash\" in\n-\tt)\n-\t\techo \"$1 (nothing to squash)\" ;;\n-\t'')\n-\t\techo \"$1\" ;;\n-\tesac\n+\tif test -z \"$quiet\"\n+\tthen\n+\t\tcase \"$squash\" in\n+\t\tt)\n+\t\t\techo \"$1 (nothing to squash)\" ;;\n+\t\t'')\n+\t\t\techo \"$1\" ;;\n+\t\tesac\n+\tfi\n \tdropsave\n }\n \n@@ -182,6 +187,8 @@ parse_config () {\n \t\t\tmerge_msg=\"$1\"\n \t\t\thave_message=t\n \t\t\t;;\n+\t\t-q|--quiet)\n+\t\t\tquiet=t ;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak ;;\ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex 5d16628..cb7e2e4 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -247,6 +247,11 @@ test_expect_success 'test option parsing' '\n \tthen\n \t\techo \"[OOPS] missing commit references accepted\"\n \t\tfalse\n+\tfi &&\n+\tif ! git merge --quiet c1\n+\tthen\n+\t\techo \"[OOPS] quiet not accepted\"\n+\t\tfalse\n \tfi\n '\n \n-- \n1.5.4.3\n"},{"id":"71531","messageId":"20080309223111.GA16360@teal.hq.k1024.org","threadId":"12597","inReplyTo":"7v8x0ssfud.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Fix git pull handling of the quiet option","fromName":"Iustin Pop","fromEmail":"iusty@k1024.org","sentAt":"2008-03-09T22:31:11Z","receivedAt":"2008-03-09T22:31:11Z","isPatch":true,"sender":{"key":"iusty@k1024.org","avatar":"https://gravatar.com/avatar/1ac09cc70e5882c6f3a189aa2289395499c2e25b8335208b79028b8dad5d2125?d=mp&s=160"},"body":"Although git pull has a documented quiet option, currently it doesn't\nhandle this option at all, and this results in it terminating the\nhandling of command line options when this particular option is met.\n\nMore exactly, it will cause the following invocation:\n  git pull --quiet --no-commit\nto fail with:\n  error: unknown option `no-commit'\n  usage: git-fetch [options] [<repository> <refspec>...]\nbecause it will not look at anything after quiet (and no-commit and\nother options should not be passed to git fetch).\n\nThis patch adds the handling of this option, and passes it correctly to\nboth git fetch and git merge (and therefore needs to be applied on top\nof patched git merge).\n\nThe patch also adds a small test for making sure that the quiet option\nworks.\n\nSigned-off-by: Iustin Pop <iusty@k1024.org>\n---\n This is an updated version which includes a small test for the quiet option.\n\n git-pull.sh     |    8 +++++---\n t/t5520-pull.sh |    8 ++++++++\n 2 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 3ce32b5..2201ca0 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -16,7 +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-strategy_args= no_summary= no_commit= squash= no_ff=\n+strategy_args= no_summary= no_commit= squash= no_ff= quiet=\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@@ -61,6 +61,8 @@ do\n \t--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)\n \t\trebase=false\n \t\t;;\n+\t-q|--q|--qui|--quie|--quiet)\n+\t\tquiet=--quiet ;;\n \t-h|--h|--he|--hel|--help)\n \t\tusage\n \t\t;;\n@@ -116,7 +118,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 $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@@ -177,4 +179,4 @@ test true = \"$rebase\" &&\n \texec git-rebase $strategy_args --onto $merge_head \\\n \t${oldremoteref:-$merge_head}\n exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \\\n-\t\"$merge_name\" HEAD $merge_head\n+\t$quiet \"$merge_name\" HEAD $merge_head\ndiff --git a/t/t5520-pull.sh b/t/t5520-pull.sh\nindex 9484129..6e36c00 100755\n--- a/t/t5520-pull.sh\n+++ b/t/t5520-pull.sh\n@@ -21,6 +21,14 @@ test_expect_success 'pulling into void' '\n \tgit pull ..\n '\n \n+test_expect_success 'quiet pull' '\n+\tgit pull --quiet .. &&\n+\tif test -n \"`git pull --quiet ..`\"; then\n+\t\techo \"[OOPS] quiet pull is not quiet\"\n+\t\tfalse\n+\tfi\n+'\n+\n cd \"$D\"\n \n test_expect_success 'checking the results' '\n-- \n1.5.4.3\n"}]}