[PATCH] checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty())

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Inspired-by: martin f krafft <madduck@xxxxxxxxxxx>
Signed-off-by: Steffen Daode Nurpmeso <sdaoden@xxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]