{"thread":{"id":"31489","subject":"[PATCH] Makefile: quiet shell commands when \"make --silent\"","startedAt":"2012-09-09T23:09:21Z","lastAt":"2012-09-10T12:16:51Z","messageCount":3,"participants":["Pete Wyckoff","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"198653","messageId":"20120909230921.GA23806@padd.com","threadId":"31489","inReplyTo":null,"subject":"[PATCH] Makefile: quiet shell commands when \"make --silent\"","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-09-09T23:09:21Z","receivedAt":"2012-09-09T23:09:21Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Option \"--silent\", \"--quiet\" or \"-s\" to make prevents\nechoing of commands as they are executed.  However, there\nare some explicit \"echo\" commands in the Makefile and in\nthe two GIT-VERSION-GEN scripts that always echo.\n\nQuiet the explicit \"echo\"s in Makefile when MAKEFLAG \"s\"\nis set.  Pass this information into both GIT-VERSION-GEN\nhelpers so that they can run silently too.\n\nBefore:\n\n    $ echo >>git.c\n    $ make -s\n    GIT_VERSION = 1.7.12.378.gaeb1945.dirty\n\t* new script parameters\n    GITGUI_VERSION = 0.16.GITGUI-dirty\n    $\n\nAfter:\n\n    $ echo >>git.c\n    $ make -s\n    $\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n\nMake should be silent when given \"--silent\".\n\nThis may help tools that post-process make output, like the\n\"check-docs\" command.  Peff noticed in 5fafce0 (check-docs: get\ndocumented command list from Makefile, 2012-08-08) that:\n\n> ... make will print extra cruft like\n> \"GIT-VERSION-FILE is up to date\" to stdout.\n\nThey now can use \"make -s\" to avoid filtering out the cruft.\n\n\t\t-- Pete\n\n GIT-VERSION-GEN         | 11 ++++++++++-\n Makefile                | 13 ++++++++-----\n git-gui/GIT-VERSION-GEN | 11 ++++++++++-\n 3 files changed, 28 insertions(+), 7 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex d2d2d69..97f0825 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -6,6 +6,12 @@ DEF_VER=v1.7.12.GIT\n LF='\n '\n \n+silent=\n+if test \"${1:-}\" = \"#\"\n+then\n+\tsilent=1\n+fi\n+\n # First see if there is a version file (included in release tarballs),\n # then try git-describe, then default.\n if test -f version\n@@ -35,7 +41,10 @@ else\n \tVC=unset\n fi\n test \"$VN\" = \"$VC\" || {\n-\techo >&2 \"GIT_VERSION = $VN\"\n+\tif test -z \"$silent\"\n+\tthen\n+\t\techo >&2 \"GIT_VERSION = $VN\"\n+\tfi\n \techo \"GIT_VERSION = $VN\" >$GVF\n }\n \ndiff --git a/Makefile b/Makefile\nindex 66e8216..dac5aab 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -305,7 +305,7 @@ all::\n # \"git help\" is called without a parameter specifying the format.\n \n GIT-VERSION-FILE: FORCE\n-\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n+\t@$(SHELL_PATH) ./GIT-VERSION-GEN \"$(SILENT_SH_ECHO)\"\n -include GIT-VERSION-FILE\n \n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n@@ -1850,6 +1850,9 @@ ifndef V\n \texport QUIET_GEN\n \texport QUIET_BUILT_IN\n endif\n+else\n+# in --silent mode, suppress echo command in shell commands\n+SILENT_SH_ECHO = \\#\n endif\n \n ifdef NO_INSTALL_HARDLINKS\n@@ -2074,7 +2077,7 @@ endef\n GIT-SCRIPT-DEFINES: FORCE\n \t@FLAGS='$(SCRIPT_DEFINES)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat $@ 2>/dev/null`\" ; then \\\n-\t\techo 1>&2 \"    * new script parameters\"; \\\n+\t\t$(SILENT_SH_ECHO)echo 1>&2 \"    * new script parameters\"; \\\n \t\techo \"$$FLAGS\" >$@; \\\n             fi\n \n@@ -2451,7 +2454,7 @@ TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\\\n GIT-PREFIX: FORCE\n \t@FLAGS='$(TRACK_PREFIX)'; \\\n \tif test x\"$$FLAGS\" != x\"`cat GIT-PREFIX 2>/dev/null`\" ; then \\\n-\t\techo 1>&2 \"    * new prefix flags\"; \\\n+\t\t$(SILENT_SH_ECHO)echo 1>&2 \"    * new prefix flags\"; \\\n \t\techo \"$$FLAGS\" >GIT-PREFIX; \\\n \tfi\n \n@@ -2460,7 +2463,7 @@ TRACK_CFLAGS = $(CC):$(subst ','\\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)\n GIT-CFLAGS: FORCE\n \t@FLAGS='$(TRACK_CFLAGS)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat GIT-CFLAGS 2>/dev/null`\" ; then \\\n-\t\techo 1>&2 \"    * new build flags\"; \\\n+\t\t$(SILENT_SH_ECHO)echo 1>&2 \"    * new build flags\"; \\\n \t\techo \"$$FLAGS\" >GIT-CFLAGS; \\\n             fi\n \n@@ -2469,7 +2472,7 @@ TRACK_LDFLAGS = $(subst ','\\'',$(ALL_LDFLAGS))\n GIT-LDFLAGS: FORCE\n \t@FLAGS='$(TRACK_LDFLAGS)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat GIT-LDFLAGS 2>/dev/null`\" ; then \\\n-\t\techo 1>&2 \"    * new link flags\"; \\\n+\t\t$(SILENT_SH_ECHO)echo 1>&2 \"    * new link flags\"; \\\n \t\techo \"$$FLAGS\" >GIT-LDFLAGS; \\\n             fi\n \ndiff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN\nindex 6570943..ba17163 100755\n--- a/git-gui/GIT-VERSION-GEN\n+++ b/git-gui/GIT-VERSION-GEN\n@@ -6,6 +6,12 @@ DEF_VER=0.16.GITGUI\n LF='\n '\n \n+silent=\n+if test \"${1:-}\" = \"#\"\n+then\n+\tsilent=1\n+fi\n+\n tree_search ()\n {\n \thead=$1\n@@ -75,6 +81,9 @@ else\n \tVC=unset\n fi\n test \"$VN\" = \"$VC\" || {\n-\techo >&2 \"GITGUI_VERSION = $VN\"\n+\tif test -z \"$silent\"\n+\tthen\n+\t\techo >&2 \"GITGUI_VERSION = $VN\"\n+\tfi\n \techo \"GITGUI_VERSION = $VN\" >$GVF\n }\n-- \n1.7.12.378.gaeb1945.dirty\n"},{"id":"198656","messageId":"7voblepvdv.fsf@alter.siamese.dyndns.org","threadId":"31489","inReplyTo":"20120909230921.GA23806@padd.com","subject":"Re: [PATCH] Makefile: quiet shell commands when \"make --silent\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-10T00:35:40Z","receivedAt":"2012-09-10T00:35:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pete Wyckoff <pw@padd.com> writes:\n\n> Option \"--silent\", \"--quiet\" or \"-s\" to make prevents\n> echoing of commands as they are executed.  However, there\n> are some explicit \"echo\" commands in the Makefile and in\n> the two GIT-VERSION-GEN scripts that always echo.\n\n\"make -s clean\"?\n\nI am not very enthused, especially if the primary motivation is\nabout \"check-docs\".  Such a script must be prepared to filter out\ncruft from the output of $(MAKE) and to pick out the bits that\ninterests it and that has been the way of life with $(MAKE) way\nbefore Git started as a project ;-).\n\nIn order to make it more robust, targets like \"print-man1\" can (and\nshould) arrange their output in such a way that interesting parts\nare easily findable.\n"},{"id":"198669","messageId":"20120910121651.GA26218@padd.com","threadId":"31489","inReplyTo":"7voblepvdv.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Makefile: quiet shell commands when \"make --silent\"","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-09-10T12:16:51Z","receivedAt":"2012-09-10T12:16:51Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"gitster@pobox.com wrote on Sun, 09 Sep 2012 17:35 -0700:\n> Pete Wyckoff <pw@padd.com> writes:\n> \n> > Option \"--silent\", \"--quiet\" or \"-s\" to make prevents\n> > echoing of commands as they are executed.  However, there\n> > are some explicit \"echo\" commands in the Makefile and in\n> > the two GIT-VERSION-GEN scripts that always echo.\n> \n> \"make -s clean\"?\n\nFixed here.\n\n> I am not very enthused, especially if the primary motivation is\n> about \"check-docs\".  Such a script must be prepared to filter out\n> cruft from the output of $(MAKE) and to pick out the bits that\n> interests it and that has been the way of life with $(MAKE) way\n> before Git started as a project ;-).\n\nMy motivation was to quiet output from a script I use\nto test bisectability.  I sent it out because I noticed\nsomeone else found the verbosity annoying too.\n\nAgreed that \"fixing\" check-docs is not important; that's\nwhy I didn't bother in this patch.\n\n\t\t-- Pete\n"}]}