From: Edmundo Carmona Antoranz <eantoranz@gmail.com>
To: git@vger.kernel.org
Cc: peff@peff.net, Edmundo Carmona Antoranz <eantoranz@gmail.com>
Subject: [PATCH] checkout: add --progress option
Date: Thu, 29 Oct 2015 19:23:06 -0600 [thread overview]
Message-ID: <1446168186-4730-1-git-send-email-eantoranz@gmail.com> (raw)
Under normal circumstances, and like other git commands,
git checkout will write progress info to stderr if
attached to a terminal. This option allows progress
to be forced even if not using a terminal. Also,
progress can be skipped if using option --no-progress.
Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
Documentation/git-checkout.txt | 6 ++++++
builtin/checkout.c | 17 ++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index e269fb1..93ba35a 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -107,6 +107,12 @@ OPTIONS
--quiet::
Quiet, suppress feedback messages.
+--progress::
+ Progress status is reported on the standard error stream
+ by default when it is attached to a terminal, unless -q
+ is specified. This flag forces progress status even if the
+ standard error stream is not directed to a terminal.
+
-f::
--force::
When switching branches, proceed even if the index or the
diff --git a/builtin/checkout.c b/builtin/checkout.c
index bc703c0..e28c36b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -27,6 +27,8 @@ static const char * const checkout_usage[] = {
NULL,
};
+static int option_progress = -1;
+
struct checkout_opts {
int patch_mode;
int quiet;
@@ -417,7 +419,19 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
- opts.verbose_update = !o->quiet && isatty(2);
+ /**
+ * Rules to display progress:
+ * -q is selected
+ * no verbiage
+ * -q is _not_ selected and --no-progress _is_ selected,
+ * progress will be skipped
+ * -q is _not_ selected and --progress _is_ selected,
+ * progress will be printed to stderr
+ * -q is _not_ selected and --progress is 'undefined'
+ * progress will be printed to stderr _if_ working on a terminal
+ */
+ opts.verbose_update = !o->quiet && (option_progress > 0 ||
+ (option_progress < 0 && isatty(2)));
opts.src_index = &the_index;
opts.dst_index = &the_index;
parse_tree(tree);
@@ -1156,6 +1170,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
N_("second guess 'git checkout <no-such-branch>'")),
OPT_BOOL(0, "ignore-other-worktrees", &opts.ignore_other_worktrees,
N_("do not check if another worktree is holding the given ref")),
+ OPT_BOOL(0, "progress", &option_progress, N_("force progress reporting")),
OPT_END(),
};
--
2.6.1
next reply other threads:[~2015-10-30 1:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 1:23 Edmundo Carmona Antoranz [this message]
2015-10-30 17:04 ` [PATCH] checkout: add --progress option Junio C Hamano
2015-10-30 18:12 ` Eric Sunshine
2015-10-30 18:48 ` Junio C Hamano
2015-10-30 19:04 ` Eric Sunshine
2015-10-30 19:31 ` Jeff King
2015-10-30 19:37 ` Junio C Hamano
2015-10-31 0:58 ` Edmundo Carmona Antoranz
2015-10-31 1:08 ` Edmundo Carmona Antoranz
2015-10-31 2:11 ` Edmundo Carmona Antoranz
2015-10-31 17:37 ` Junio C Hamano
2015-10-31 17:42 ` Edmundo Carmona Antoranz
2015-10-31 18:14 ` Edmundo Carmona Antoranz
2015-10-31 20:07 ` Jeff King
2015-11-01 0:45 ` Eric Sunshine
2015-11-01 16:50 ` Edmundo Carmona Antoranz
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=1446168186-4730-1-git-send-email-eantoranz@gmail.com \
--to=eantoranz@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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).