{"thread":{"id":"40694","subject":"[PATCH v3] checkout: add --progress option","startedAt":"2015-11-01T17:22:25Z","lastAt":"2015-11-01T17:43:42Z","messageCount":2,"participants":["Edmundo Carmona Antoranz"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"272674","messageId":"1446398545-8245-1-git-send-email-eantoranz@gmail.com","threadId":"40694","inReplyTo":null,"subject":"[PATCH v3] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T17:22:25Z","receivedAt":"2015-11-01T17:22:25Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Under normal circumstances, and like other git commands,\ngit checkout will write progress info to stderr if\nattached to a terminal. This option allows progress\nto be forced even if not using a terminal. Also,\nprogress can be skipped if using option --no-progress.\n---\n Documentation/git-checkout.txt |  6 ++++++\n builtin/checkout.c             | 26 ++++++++++++++++++++++++--\n 2 files changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex e269fb1..93ba35a 100644\n--- a/Documentation/git-checkout.txt\n+++ b/Documentation/git-checkout.txt\n@@ -107,6 +107,12 @@ OPTIONS\n --quiet::\n \tQuiet, suppress feedback messages.\n \n+--progress::\n+\tProgress status is reported on the standard error stream\n+\tby default when it is attached to a terminal, unless -q\n+\tis specified. This flag forces progress status even if the\n+\tstandard error stream is not directed to a terminal.\n+\n -f::\n --force::\n \tWhen switching branches, proceed even if the index or the\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex bc703c0..1bc4efe 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -37,6 +37,7 @@ struct checkout_opts {\n \tint overwrite_ignore;\n \tint ignore_skipworktree;\n \tint ignore_other_worktrees;\n+\tint show_progress;\n \n \tconst char *new_branch;\n \tconst char *new_branch_force;\n@@ -417,7 +418,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,\n \topts.reset = 1;\n \topts.merge = 1;\n \topts.fn = oneway_merge;\n-\topts.verbose_update = !o->quiet && isatty(2);\n+\topts.verbose_update = o->show_progress;\n \topts.src_index = &the_index;\n \topts.dst_index = &the_index;\n \tparse_tree(tree);\n@@ -501,7 +502,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n \t\ttopts.update = 1;\n \t\ttopts.merge = 1;\n \t\ttopts.gently = opts->merge && old->commit;\n-\t\ttopts.verbose_update = !opts->quiet && isatty(2);\n+\t\ttopts.verbose_update = opts->show_progress;\n \t\ttopts.fn = twoway_merge;\n \t\tif (opts->overwrite_ignore) {\n \t\t\ttopts.dir = xcalloc(1, sizeof(*topts.dir));\n@@ -1156,6 +1157,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t\tN_(\"second guess 'git checkout <no-such-branch>'\")),\n \t\tOPT_BOOL(0, \"ignore-other-worktrees\", &opts.ignore_other_worktrees,\n \t\t\t N_(\"do not check if another worktree is holding the given ref\")),\n+\t\tOPT_BOOL(0, \"progress\", &opts.show_progress, N_(\"force progress reporting\")),\n \t\tOPT_END(),\n \t};\n \n@@ -1163,6 +1165,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tmemset(&new, 0, sizeof(new));\n \topts.overwrite_ignore = 1;\n \topts.prefix = prefix;\n+\topts.show_progress = -1;\n \n \tgitmodules_config();\n \tgit_config(git_checkout_config, &opts);\n@@ -1172,6 +1175,25 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, options, checkout_usage,\n \t\t\t     PARSE_OPT_KEEP_DASHDASH);\n \n+\t/*\n+\t * Final processing of show_progress\n+\t * - User selected --progress: show progress\n+\t * - user selected --no-progress: skip progress\n+\t * - User didn't specify:\n+\t *     (check rules in order till finding the first matching one)\n+\t *     - user selected --quiet: skip progress\n+\t *     - stderr is connected to a terminal: show progress\n+\t *     - fallback: skip progress\n+\t */\n+\tif (opts.show_progress < 0) {\n+\t\t/* user selected --progress or didn't specify */\n+\t\tif (opts.quiet) {\n+\t\t\topts.show_progress = 0;\n+\t\t} else {\n+\t\t\topts.show_progress = isatty(2);\n+\t\t}\n+\t}\n+\n \tif (conflict_style) {\n \t\topts.merge = 1; /* implied */\n \t\tgit_xmerge_config(\"merge.conflictstyle\", conflict_style, NULL);\n-- \n2.6.1\n"},{"id":"272675","messageId":"CAOc6etZ7Vcd-Gq6bV6VuzJQY2om7k0gWfGYsSmQ8xYtGvOWBxQ@mail.gmail.com","threadId":"40694","inReplyTo":"1446398545-8245-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH v3] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T17:43:42Z","receivedAt":"2015-11-01T17:43:42Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Sun, Nov 1, 2015 at 11:22 AM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> +       /*\n> +        * Final processing of show_progress\n> +        * - User selected --progress: show progress\n> +        * - user selected --no-progress: skip progress\n> +        * - User didn't specify:\n> +        *     (check rules in order till finding the first matching one)\n> +        *     - user selected --quiet: skip progress\n> +        *     - stderr is connected to a terminal: show progress\n> +        *     - fallback: skip progress\n> +        */\n> +       if (opts.show_progress < 0) {\n> +               /* user selected --progress or didn't specify */\n> +               if (opts.quiet) {\n> +                       opts.show_progress = 0;\n> +               } else {\n> +                       opts.show_progress = isatty(2);\n> +               }\n> +       }\n> +\n\n\n/* user selected --progress or didn't specify */\nThis comment is not correct. Disregard this patch.\n"}]}