Skip to content

Commit

Permalink
merge: enable progress reporting for rename detection
Browse files Browse the repository at this point in the history
The user can enable or disable it explicitly with the new
--progress, but it defaults to checking isatty(2).

This works only with merge-recursive and subtree. In theory
we could pass a progress flag to other strategies, but none
of them support progress at this point, so let's wait until
they grow such a feature before worrying about propagating
it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 21, 2011
1 parent 3ac942d commit 99bfc66
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Documentation/merge-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@ option can be used to override --squash.
ifndef::git-pull[]
-q::
--quiet::
Operate quietly.
Operate quietly. Implies --no-progress.

-v::
--verbose::
Be verbose.

--progress::
--no-progress::
Turn progress on/off explicitly. If neither is specified,
progress is shown if standard error is connected to a terminal.
Note that not all merge strategies may support progress
reporting.

endif::git-pull[]
7 changes: 7 additions & 0 deletions builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static int option_renormalize;
static int verbosity;
static int allow_rerere_auto;
static int abort_current_merge;
static int show_progress = -1;

static struct strategy all_strategy[] = {
{ "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
Expand Down Expand Up @@ -200,6 +201,7 @@ static struct option builtin_merge_options[] = {
OPT__VERBOSITY(&verbosity),
OPT_BOOLEAN(0, "abort", &abort_current_merge,
"abort the current in-progress merge"),
OPT_SET_INT(0, "progress", &show_progress, "force progress reporting", 1),
OPT_END()
};

Expand Down Expand Up @@ -659,6 +661,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
o.subtree_shift = "";

o.renormalize = option_renormalize;
o.show_rename_progress =
show_progress == -1 ? isatty(2) : show_progress;

for (x = 0; x < xopts_nr; x++)
if (parse_merge_opt(&o, xopts[x]))
Expand Down Expand Up @@ -944,6 +948,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, builtin_merge_options,
builtin_merge_usage, 0);

if (verbosity < 0 && show_progress == -1)
show_progress = 0;

if (abort_current_merge) {
int nargc = 2;
const char *nargv[] = {"reset", "--merge", NULL};
Expand Down
1 change: 1 addition & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ static struct string_list *get_renames(struct merge_options *o,
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
1000;
opts.rename_score = o->rename_score;
opts.show_rename_progress = o->show_rename_progress;
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
if (diff_setup_done(&opts) < 0)
die("diff setup failed");
Expand Down
1 change: 1 addition & 0 deletions merge-recursive.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct merge_options {
int merge_rename_limit;
int rename_score;
int needed_rename_limit;
int show_rename_progress;
int call_depth;
struct strbuf obuf;
struct string_list current_file_set;
Expand Down

0 comments on commit 99bfc66

Please sign in to comment.