git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] builtin rebase: show progress when connected to a terminal

From
Pratik Karki <predatoramigo@gmail.com>
Date
Aug 8, 2018, 15:36 UTC
Message-ID
<20180808153635.19944-5-predatoramigo@gmail.com>
In-Reply-To
<20180808153635.19944-1-predatoramigo@gmail.com>

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>
---
 builtin/rebase.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 1bb64e7cd7..04974dff6e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -98,6 +98,7 @@ struct rebase_options {
 	int allow_empty_message;
 	int rebase_merges, rebase_cousins;
 	char *strategy, *strategy_opts;
+	struct strbuf git_format_patch_opt;
 };
 
 static int is_interactive(struct rebase_options *opts)
@@ -379,6 +380,8 @@ static int run_specific_rebase(struct rebase_options *opts)
 	add_var(&script_snippet, "rebase_root", opts->root ? "t" : "");
 	add_var(&script_snippet, "squash_onto",
 		opts->squash_onto ? oid_to_hex(opts->squash_onto) : "");
+	add_var(&script_snippet, "git_format_patch_opt",
+		opts->git_format_patch_opt.buf);
 
 	switch (opts->type) {
 	case REBASE_AM:
@@ -667,6 +670,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		.git_am_opt = STRBUF_INIT,
 		.allow_rerere_autoupdate  = -1,
 		.allow_empty_message = 1,
+		.git_format_patch_opt = STRBUF_INIT,
 	};
 	const char *branch_name;
 	int ret, flags, total_argc, in_progress = 0;
@@ -1068,6 +1072,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (options.root && !options.onto_name)
 		imply_interactive(&options, "--root without --onto");
 
+	if (isatty(2) && options.flags & REBASE_NO_QUIET)
+		strbuf_addstr(&options.git_format_patch_opt, " --progress");
+
 	switch (options.type) {
 	case REBASE_MERGE:
 	case REBASE_INTERACTIVE:
-- 
2.18.0
Previous: Pratik KarkiNext: Pratik Karki
Message 5 of 7 in “builtin rebase rest”
  1. Pratik KarkiAug 8, 2018
  2. 1/6 builtin rebase: optionally auto-detect the upstreamPratik Karki, Aug 8, 2018
  3. 2/6 builtin rebase: optionally pass custom reflogs to reset_head()Pratik Karki, Aug 8, 2018
  4. 3/6 builtin rebase: fast-forward to onto if it is a proper descendantPratik Karki, Aug 8, 2018
  5. 4/6 builtin rebase: show progress when connected to a terminalPratik Karki, Aug 8, 2018
  6. 5/6 builtin rebase: use no-op editor when interactive is "implied"Pratik Karki, Aug 8, 2018
  7. 6/6 builtin rebase: error out on incompatible option/mode combinationsPratik Karki, Aug 8, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.