{"thread":{"id":"6608","subject":"[PATCH 2/3] add a quiet option to git-checkout","startedAt":"2007-02-01T17:31:26Z","lastAt":"2007-02-01T17:31:26Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"33258","messageId":"Pine.LNX.4.64.0702011230320.3021@xanadu.home","threadId":"6608","inReplyTo":null,"subject":"[PATCH 2/3] add a quiet option to git-checkout","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-02-01T17:31:26Z","receivedAt":"2007-02-01T17:31:26Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Those new messages are certainly nice, but there might be cases where\nthey are simply unwelcome, like when git-commit is used within scripts.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n Documentation/git-checkout.txt |    5 ++++-\n git-checkout.sh                |   23 ++++++++++++++---------\n 2 files changed, 18 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex 4ea2b31..55c9289 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -8,7 +8,7 @@ git-checkout - Checkout and switch to a branch\n SYNOPSIS\n --------\n [verse]\n-'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>]\n+'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>]\n 'git-checkout' [<tree-ish>] <paths>...\n \n DESCRIPTION\n@@ -33,6 +33,9 @@ working tree.\n \n OPTIONS\n -------\n+-q::\n+\tQuiet, supress feedback messages.\n+\n -f::\n \tForce a re-read of everything.\n \ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex 97c26ad..99a81f5 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'\n+USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'\n SUBDIRECTORY_OK=Sometimes\n . git-sh-setup\n require_work_tree\n@@ -15,6 +15,7 @@ branch=\n newbranch=\n newbranch_log=\n merge=\n+quiet=\n LF='\n '\n while [ \"$#\" != \"0\" ]; do\n@@ -40,6 +41,9 @@ while [ \"$#\" != \"0\" ]; do\n \t-m)\n \t\tmerge=1\n \t\t;;\n+\t\"-q\")\n+\t\tquiet=1\n+\t\t;;\n \t--)\n \t\tbreak\n \t\t;;\n@@ -153,7 +157,7 @@ detach_warn=\n if test -z \"$branch$newbranch\" && test \"$new\" != \"$old\"\n then\n \tdetached=\"$new\"\n-\tif test -n \"$oldbranch\"\n+\tif test -n \"$oldbranch\" && test -z \"$quiet\"\n \tthen\n \t\tdetach_warn=\"Note: moving to \\\"$new_name\\\" which isn't a local branch\n If you want to create a new branch from this checkout, you may do so\n@@ -180,8 +184,11 @@ fi\n \n if [ \"X$old\" = X ]\n then\n-\techo >&2 \"warning: You appear to be on a branch yet to be born.\"\n-\techo >&2 \"warning: Forcing checkout of $new_name.\"\n+\tif test -z \"$quiet\"\n+\tthen\n+\t\techo >&2 \"warning: You appear to be on a branch yet to be born.\"\n+\t\techo >&2 \"warning: Forcing checkout of $new_name.\"\n+\tfi\n \tforce=1\n fi\n \n@@ -226,7 +233,7 @@ else\n \texit 0\n     )\n     saved_err=$?\n-    if test \"$saved_err\" = 0\n+    if test \"$saved_err\" = 0 && test -z \"$quiet\"\n     then\n \tgit diff-index --name-status \"$new\"\n     fi\n@@ -251,11 +258,9 @@ if [ \"$?\" -eq 0 ]; then\n \tif test -n \"$branch\"\n \tthen\n \t\tGIT_DIR=\"$GIT_DIR\" git-symbolic-ref HEAD \"refs/heads/$branch\"\n-\t\tif test -n \"$newbranch\"\n+\t\tif test -z \"$quiet\"\n \t\tthen\n-\t\t\techo >&2 \"Switched to a new branch \\\"$branch\\\"\"\n-\t\telse\n-\t\t\techo >&2 \"Switched to branch \\\"$branch\\\"\"\n+\t\t\techo >&2 \"Switched to${newbranch:+ a new} branch \\\"$branch\\\"\"\n \t\tfi\n \telif test -n \"$detached\"\n \tthen\n-- \n1.5.0.rc2.131.g4b01-dirty\n"}]}