{"thread":{"id":"40687","subject":"[PATCH] checkout: refactor of --progress option","startedAt":"2015-10-31T16:57:49Z","lastAt":"2015-10-31T18:45:49Z","messageCount":4,"participants":["Edmundo Carmona Antoranz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"272619","messageId":"1446310669-9790-1-git-send-email-eantoranz@gmail.com","threadId":"40687","inReplyTo":null,"subject":"[PATCH] checkout: refactor of --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-10-31T16:57:49Z","receivedAt":"2015-10-31T16:57:49Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"- removed static variable show_progress\n- processing if progress will be shown or not right\n  after running parse_options()\n\nSigned-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>\n---\n builtin/checkout.c | 32 +++++++++++++++-----------------\n 1 file changed, 15 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex e28c36b..10e2b42 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -27,8 +27,6 @@ static const char * const checkout_usage[] = {\n \tNULL,\n };\n \n-static int option_progress = -1;\n-\n struct checkout_opts {\n \tint patch_mode;\n \tint quiet;\n@@ -39,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@@ -419,19 +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-\t/**\n-\t * Rules to display progress:\n-\t * -q is selected\n-\t *      no verbiage\n-\t * -q is _not_ selected and --no-progress _is_ selected,\n-\t *      progress will be skipped\n-\t * -q is _not_ selected and --progress _is_ selected,\n-\t *      progress will be printed to stderr\n-\t * -q is _not_ selected and --progress is 'undefined'\n-\t *      progress will be printed to stderr _if_ working on a terminal\n-\t */\n-\topts.verbose_update = !o->quiet && (option_progress > 0 ||\n-\t\t\t\t\t   (option_progress < 0 && 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@@ -515,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@@ -1170,7 +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\", &option_progress, N_(\"force progress reporting\")),\n+\t\tOPT_BOOL(0, \"progress\", &opts.show_progress, N_(\"force progress reporting\")),\n \t\tOPT_END(),\n \t};\n \n@@ -1178,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@@ -1187,6 +1175,16 @@ 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 * Any of these 3 conditions will make progress output be skipped:\n+\t * - selected --quiet\n+\t * - selected --no-progress\n+\t * - didn't select --progress and not working on a terminal\n+\t */\n+\topts.show_progress = !opts.quiet && opts.show_progress &&\n+\t\t\t     (opts.show_progress > 0 || isatty(2));\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":"272620","messageId":"CAOc6etasvk6f0XhJumwXtYiC7h_ufQUAyN1BktQ=qdd4_f0hSQ@mail.gmail.com","threadId":"40687","inReplyTo":"1446310669-9790-1-git-send-email-eantoranz@gmail.com","subject":"Re: [PATCH] checkout: refactor of --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-10-31T17:10:59Z","receivedAt":"2015-10-31T17:10:59Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Sat, Oct 31, 2015 at 10:57 AM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> +       /*\n> +        * Final processing of show_progress\n> +        * Any of these 3 conditions will make progress output be skipped:\n> +        * - selected --quiet\n> +        * - selected --no-progress\n> +        * - didn't select --progress and not working on a terminal\n> +        */\n> +       opts.show_progress = !opts.quiet && opts.show_progress &&\n> +                            (opts.show_progress > 0 || isatty(2));\n> +\n\nI did a very small adjustment there from what I had sent yesterday.\n\nIt was (opts.show_progress >= 0 || isatty(2))\n\nIt was unnecessary to include the case of a 0 because it was discarded\nby the second item on the outer short-circuited if:\nopts_show_progress.\n\nLet me know of your feedback and thanks.\n"},{"id":"272621","messageId":"CAOc6etb+Fom9t=2R=opR-fKYDkR1X6FFA=OGyQqo8HWycgqUVw@mail.gmail.com","threadId":"40687","inReplyTo":"CAOc6etasvk6f0XhJumwXtYiC7h_ufQUAyN1BktQ=qdd4_f0hSQ@mail.gmail.com","subject":"Re: [PATCH] checkout: refactor of --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-10-31T17:13:18Z","receivedAt":"2015-10-31T17:13:18Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Sat, Oct 31, 2015 at 11:10 AM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> by the second item on the outer short-circuited if:\n\nI meant: ...short-circuited _and operator_, sorry.\n"},{"id":"272635","messageId":"CAOc6etah_GFgQNKLKRtWDLzUd0UV2SDTCjq6t3y5B8hGJb1eoQ@mail.gmail.com","threadId":"40687","inReplyTo":"CAOc6etb+Fom9t=2R=opR-fKYDkR1X6FFA=OGyQqo8HWycgqUVw@mail.gmail.com","subject":"Re: [PATCH] checkout: refactor of --progress option","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2015-10-31T18:45:49Z","receivedAt":"2015-10-31T18:45:49Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Disregard this patch.\n"}]}