From: Steffen Daode Nurpmeso <sdaoden@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: martin f krafft <madduck@madduck.net>,
Tay Ray Chuan <rctay89@gmail.com>,
git@vger.kernel.org, sdaoden@gmail.com
Subject: [PATCH] checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty())
Date: Sun, 28 Aug 2011 19:37:27 +0200 [thread overview]
Message-ID: <20110828173644.GA1553@sherwood.local> (raw)
In-Reply-To: <7vaaau9hso.fsf@alter.siamese.dyndns.org>
This commit adds support for the -v/--verbose pair of options,
and thus offers the possibility to be more specific in deciding
which purely informational feedback message is displayed or not.
Without any of --verbose and --quiet involved, the progress
reporting is now restricted to interactive sessions, i.e. only
shown if the output is send to a terminal.
Analyzed-by: Junio C Hamano <gitster@pobox.com>
Inspired-by: martin f krafft <madduck@madduck.net>
Signed-off-by: Steffen Daode Nurpmeso <sdaoden@gmail.com>
---
Well i was stepping down from my hill, actually singing my
sunday's song (was it Elvis..), but i didn't dare to implement the
behaviour Martin suggested. But isn't he right?
This thing here was also tested a bit.
Documentation/git-checkout.txt | 13 +++++++++----
builtin/checkout.c | 12 +++++++++---
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index c0a96e6..77ad4f3 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -8,9 +8,9 @@ git-checkout - Checkout a branch or paths to the working tree
SYNOPSIS
--------
[verse]
-'git checkout' [-q] [-f] [-m] [<branch>]
-'git checkout' [-q] [-f] [-m] [--detach] [<commit>]
-'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
+'git checkout' [-v] [-q] [-f] [-m] [<branch>]
+'git checkout' [-v] [-q] [-f] [-m] [--detach] [<commit>]
+'git checkout' [-v] [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]
'git checkout' [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>...
'git checkout' [-p|--patch] [<tree-ish>] [--] [<paths>...]
@@ -66,9 +66,14 @@ file can be discarded to re-create the original conflicted merge result.
OPTIONS
-------
+-v::
+--verbose::
+ Be verbose, force progress reporting.
+
-q::
--quiet::
- Quiet, suppress feedback messages.
+ Be quiet, suppress feedback messages and progress reporting.
+ Overrides "--verbose", if given.
-f::
--force::
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4eaedff..7297843 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -27,6 +27,7 @@ static const char * const checkout_usage[] = {
};
struct checkout_opts {
+ int verbose;
int quiet;
int merge;
int force;
@@ -325,7 +326,7 @@ static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
- opts.verbose_update = !o->quiet;
+ opts.verbose_update = o->verbose;
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
@@ -402,7 +403,7 @@ static int merge_working_tree(struct checkout_opts *opts,
topts.update = 1;
topts.merge = 1;
topts.gently = opts->merge && old->commit;
- topts.verbose_update = !opts->quiet;
+ topts.verbose_update = opts->verbose;
topts.fn = twoway_merge;
topts.dir = xcalloc(1, sizeof(*topts.dir));
topts.dir->flags |= DIR_SHOW_IGNORED;
@@ -927,7 +928,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
int patch_mode = 0;
int dwim_new_local_branch = 1;
struct option options[] = {
- OPT__QUIET(&opts.quiet, "suppress progress reporting"),
+ OPT__VERBOSE(&opts.verbose, "force progress reporting"),
+ OPT__QUIET(&opts.quiet, "suppress feedback reporting"),
OPT_STRING('b', NULL, &opts.new_branch, "branch",
"create and checkout a new branch"),
OPT_STRING('B', NULL, &opts.new_branch_force, "branch",
@@ -958,6 +960,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
gitmodules_config();
git_config(git_checkout_config, &opts);
+ if (opts.quiet)
+ opts.verbose = 0;
+ else if (!opts.verbose)
+ opts.verbose = isatty(2);
opts.track = BRANCH_TRACK_UNSPECIFIED;
argc = parse_options(argc, argv, prefix, options, checkout_usage,
--
1.7.7.rc0.dirty
next prev parent reply other threads:[~2011-08-28 17:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 14:40 [PATCH] progress: use \r as EOL only if isatty(stderr) is true Steffen Daode Nurpmeso
[not found] ` <BANLkTinRe=pA=_obCmPKBjJMXH_pDfwCtw@mail.gmail.com>
2011-06-28 16:51 ` Steffen Daode Nurpmeso
2011-06-28 18:04 ` Steffen Daode Nurpmeso
2011-06-28 18:33 ` Junio C Hamano
2011-06-28 18:48 ` Steffen Daode Nurpmeso
2011-06-28 18:55 ` Steffen Daode Nurpmeso
2011-06-28 22:45 ` Jeff King
2011-06-29 21:36 ` Junio C Hamano
2011-06-30 4:33 ` Miles Bader
2011-06-29 17:42 ` [PATCH/RFC] sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true) Steffen Daode Nurpmeso
2011-06-29 18:15 ` Nicolas Pitre
2011-06-30 21:13 ` Steffen Daode Nurpmeso
2011-07-01 3:46 ` Nicolas Pitre
2011-08-27 19:45 ` [PATCH] checkout: be quiet if not on isatty() Steffen Daode Nurpmeso
2011-08-27 19:45 ` Steffen Daode Nurpmeso
2011-08-28 6:22 ` Junio C Hamano
2011-08-28 6:28 ` martin f krafft
2011-08-28 17:37 ` Steffen Daode Nurpmeso [this message]
2011-08-29 20:14 ` [PATCH 0/2 RFC] Add update_progress(), divert checkout messages sdaoden
2011-08-29 20:17 ` [PATCH 1/2] progress: add update_progress() sdaoden
2011-08-29 20:17 ` [PATCH 2/2] unpack-trees: divert check_updates() output via update_progress() sdaoden
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110828173644.GA1553@sherwood.local \
--to=sdaoden@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=madduck@madduck.net \
--cc=rctay89@gmail.com \
--cc=sdaoden@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).