{"thread":{"id":"40696","subject":"[PATCH v5] checkout: add --progress option","startedAt":"2015-11-01T18:03:59Z","lastAt":"2015-11-01T19:17:45Z","messageCount":3,"participants":["Edmundo Carmona Antoranz","Eric Sunshine"],"isPatch":true,"patchVersion":5,"patchTotal":null},"messages":[{"id":"272682","messageId":"1446401039-13848-1-git-send-email-eantoranz@gmail.com","threadId":"40696","inReplyTo":null,"subject":"[PATCH v5] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T18:03:59Z","receivedAt":"2015-11-01T18:03:59Z","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             | 25 +++++++++++++++++++++++--\n 2 files changed, 29 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..65b8b90 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,24 @@ 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 didn't specify --[no-]progress */\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":"272691","messageId":"CAPig+cTE=vhFf-wf9qd4EMt8agi5SneQ3efKi1DCrArEsii5GA@mail.gmail.com","threadId":"40696","inReplyTo":"1446401039-13848-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH v5] checkout: add --progress option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-11-01T19:13:05Z","receivedAt":"2015-11-01T19:13:05Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Nov 1, 2015 at 1:03 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> +       /*\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 didn't specify --[no-]progress */\n> +               if (opts.quiet)\n> +                       opts.show_progress = 0;\n> +               else\n> +                       opts.show_progress = isatty(2);\n> +       }\n\nStyle-wise this looks better.\n\nI'll assume that you simply overlooked the remainder of my v4 review\ncomments, so I'll merely provide a reference to them[1] rather than\nrepeating myself. If that assumption is incorrect, please do have the\ncourtesy to state that you disagree with review comments and to\nexplain your position, otherwise reviewers will feel that their\nefforts are wasted.\n\nThanks.\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/280641\n"},{"id":"272692","messageId":"CAOc6etbNryps20wK1LNpb7UKfhwEWdS2FWwopgzusrb+ULf2kw@mail.gmail.com","threadId":"40696","inReplyTo":"CAPig+cTE=vhFf-wf9qd4EMt8agi5SneQ3efKi1DCrArEsii5GA@mail.gmail.com","subject":"Re: [PATCH v5] checkout: add --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-11-01T19:17:45Z","receivedAt":"2015-11-01T19:17:45Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Oh, man... I'm sorry... I didn't notice them. Let me go over them to\nsee what we can do.\n\nOn Sun, Nov 1, 2015 at 1:13 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> I'll assume that you simply overlooked the remainder of my v4 review\n> comments, so I'll merely provide a reference to them[1] rather than\n> repeating myself. If that assumption is incorrect, please do have the\n> courtesy to state that you disagree with review comments and to\n> explain your position, otherwise reviewers will feel that their\n> efforts are wasted.\n"}]}