builtin rebase: show progress when connected to a terminal
In this commit, we pass `--progress` to the `format-patch` command if stderr is connected to an interactive terminal, unless we're in quiet mode. This `--progress` option will be used in `format-patch` to show progress reports on stderr as patches are generated. Signed-off-by: Pratik Karki <predatoramigo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pratik Karki committed
Aug 8, 2018 at 21:21 UTC
cda614e489a4da3a4824af2f2e17379131e1f048
1 file changed
+7
builtin/rebase.c
+7
@@ -98,6 +98,7 @@ struct rebase_options {
98
int allow_empty_message;
99
int rebase_merges, rebase_cousins;
100
char *strategy, *strategy_opts;
101
+ struct strbuf git_format_patch_opt;
102
};
103
104
static int is_interactive(struct rebase_options *opts)
@@ -379,6 +380,8 @@ static int run_specific_rebase(struct rebase_options *opts)
380
add_var(&script_snippet, "rebase_root", opts->root ? "t" : "");
381
add_var(&script_snippet, "squash_onto",
382
opts->squash_onto ? oid_to_hex(opts->squash_onto) : "");
383
+ add_var(&script_snippet, "git_format_patch_opt",
384
+ opts->git_format_patch_opt.buf);
385
386
switch (opts->type) {
387
case REBASE_AM:
@@ -667,6 +670,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
670
.git_am_opt = STRBUF_INIT,
671
.allow_rerere_autoupdate = -1,
672
.allow_empty_message = 1,
673
+ .git_format_patch_opt = STRBUF_INIT,
674
};
675
const char *branch_name;
676
int ret, flags, total_argc, in_progress = 0;
@@ -1069,6 +1073,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1073
if (options.root && !options.onto_name)
1074
imply_interactive(&options, "--root without --onto");
1075
1076
+ if (isatty(2) && options.flags & REBASE_NO_QUIET)
1077
+ strbuf_addstr(&options.git_format_patch_opt, " --progress");
1078
+
1079
switch (options.type) {
1080
case REBASE_MERGE:
1081
case REBASE_INTERACTIVE: