{"thread":{"id":"40698","subject":"[PATCH v6] checkout: add --progress option","startedAt":"2015-11-01T20:27:54Z","lastAt":"2015-11-01T21:12:10Z","messageCount":3,"participants":["Edmundo Carmona Antoranz","Eric Sunshine"],"isPatch":true,"patchVersion":6,"patchTotal":null},"messages":[{"id":"272704","messageId":"1446409674-17951-1-git-send-email-eantoranz@gmail.com","threadId":"40698","inReplyTo":null,"subject":"[PATCH v6] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T20:27:54Z","receivedAt":"2015-11-01T20:27:54Z","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\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n Documentation/git-checkout.txt |  6 ++++++\n builtin/checkout.c             | 14 ++++++++++++--\n 2 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\nindex e269fb1..c24c8ee 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+--[no-]progress::\n+\tProgress status is reported on the standard error stream\n+\tby default when it is attached to a terminal, unless --quiet\n+\tis specified. This flag enables progress reporting even if not\n+\tattached to a terminal, regardless of -q.\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..e346f52 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,13 @@ 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+\tif (opts.show_progress < 0) {\n+\t\tif (opts.quiet)\n+\t\t\topts.show_progress = 0;\n+\t\telse\n+\t\t\topts.show_progress = isatty(2);\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":"272706","messageId":"CAPig+cS1ajnRUiS7JXZ-jvtZV9k0hdnY7+R0nTnQU+kMk_zAqw@mail.gmail.com","threadId":"40698","inReplyTo":"1446409674-17951-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH v6] checkout: add --progress option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-01T21:06:18Z","receivedAt":"2015-11-01T21:06:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Nov 1, 2015 at 3:27 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> Under normal circumstances, and like other git commands,\n> git checkout will write progress info to stderr if\n> attached to a terminal. This option allows progress\n> to be forced even if not using a terminal. Also,\n> progress can be skipped if using option --no-progress.\n>\n> Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n> ---\n> diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt\n> @@ -107,6 +107,12 @@ OPTIONS\n>  --quiet::\n>         Quiet, suppress feedback messages.\n>\n> +--[no-]progress::\n> +       Progress status is reported on the standard error stream\n> +       by default when it is attached to a terminal, unless --quiet\n> +       is specified. This flag enables progress reporting even if not\n> +       attached to a terminal, regardless of -q.\n\nThe mix of -q and --quiet is inconsistent and potentially confusing. I\nsuspect that your intention was to hint that they are equivalent,\nhowever, the reader who is not familiar with -q as an alias of --quiet\nmay now be forced to look up both options, rather than just one, only\nto discover that they are the same, thus potentially requiring extra\neffort. It probably would be better to consistently use --quiet.\n\nAlso, quoting with backticks is recommended: `--quite`\n\nThe rest of the patch looks good.\n\n>  -f::\n>  --force::\n>         When switching branches, proceed even if the index or the\n> diff --git a/builtin/checkout.c b/builtin/checkout.c\n> @@ -37,6 +37,7 @@ struct checkout_opts {\n>         int overwrite_ignore;\n>         int ignore_skipworktree;\n>         int ignore_other_worktrees;\n> +       int show_progress;\n>\n>         const char *new_branch;\n>         const char *new_branch_force;\n> @@ -417,7 +418,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,\n>         opts.reset = 1;\n>         opts.merge = 1;\n>         opts.fn = oneway_merge;\n> -       opts.verbose_update = !o->quiet && isatty(2);\n> +       opts.verbose_update = o->show_progress;\n>         opts.src_index = &the_index;\n>         opts.dst_index = &the_index;\n>         parse_tree(tree);\n> @@ -501,7 +502,7 @@ static int merge_working_tree(const struct checkout_opts *opts,\n>                 topts.update = 1;\n>                 topts.merge = 1;\n>                 topts.gently = opts->merge && old->commit;\n> -               topts.verbose_update = !opts->quiet && isatty(2);\n> +               topts.verbose_update = opts->show_progress;\n>                 topts.fn = twoway_merge;\n>                 if (opts->overwrite_ignore) {\n>                         topts.dir = xcalloc(1, sizeof(*topts.dir));\n> @@ -1156,6 +1157,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n>                                 N_(\"second guess 'git checkout <no-such-branch>'\")),\n>                 OPT_BOOL(0, \"ignore-other-worktrees\", &opts.ignore_other_worktrees,\n>                          N_(\"do not check if another worktree is holding the given ref\")),\n> +               OPT_BOOL(0, \"progress\", &opts.show_progress, N_(\"force progress reporting\")),\n>                 OPT_END(),\n>         };\n>\n> @@ -1163,6 +1165,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n>         memset(&new, 0, sizeof(new));\n>         opts.overwrite_ignore = 1;\n>         opts.prefix = prefix;\n> +       opts.show_progress = -1;\n>\n>         gitmodules_config();\n>         git_config(git_checkout_config, &opts);\n> @@ -1172,6 +1175,13 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n>         argc = parse_options(argc, argv, prefix, options, checkout_usage,\n>                              PARSE_OPT_KEEP_DASHDASH);\n>\n> +       if (opts.show_progress < 0) {\n> +               if (opts.quiet)\n> +                       opts.show_progress = 0;\n> +               else\n> +                       opts.show_progress = isatty(2);\n> +       }\n> +\n>         if (conflict_style) {\n>                 opts.merge = 1; /* implied */\n>                 git_xmerge_config(\"merge.conflictstyle\", conflict_style, NULL);\n> --\n> 2.6.1\n"},{"id":"272707","messageId":"CAOc6etagi4C-9J-zS9z0YtvebQDOpyGMVWXi31uFT73gN7YHWg@mail.gmail.com","threadId":"40698","inReplyTo":"CAPig+cS1ajnRUiS7JXZ-jvtZV9k0hdnY7+R0nTnQU+kMk_zAqw@mail.gmail.com","subject":"Re: [PATCH v6] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T21:12:10Z","receivedAt":"2015-11-01T21:12:10Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Sun, Nov 1, 2015 at 3:06 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n>> +--[no-]progress::\n>> +       Progress status is reported on the standard error stream\n>> +       by default when it is attached to a terminal, unless --quiet\n>> +       is specified. This flag enables progress reporting even if not\n>> +       attached to a terminal, regardless of -q.\n>\n> The mix of -q and --quiet is inconsistent and potentially confusing. I\n> suspect that your intention was to hint that they are equivalent,\n> however, the reader who is not familiar with -q as an alias of --quiet\n> may now be forced to look up both options, rather than just one, only\n> to discover that they are the same, thus potentially requiring extra\n> effort. It probably would be better to consistently use --quiet.\n>\n> Also, quoting with backticks is recommended: `--quite`\n>\n> The rest of the patch looks good.\n\nGood! Going for v7.\n"}]}