summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2019-06-27 13:42:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-06-27 19:58:20 (GMT)
commitd7d90885e0aeb50eb4acc221ee43301b2a43aa3e (patch)
treefcfb9b5376b9bd78ad86850c989cbfca2fe02935 /sequencer.c
parentcd1096b2820d64d5fcb5da20613d5af290e42929 (diff)
downloadgit-d7d90885e0aeb50eb4acc221ee43301b2a43aa3e.zip
git-d7d90885e0aeb50eb4acc221ee43301b2a43aa3e.tar.gz
git-d7d90885e0aeb50eb4acc221ee43301b2a43aa3e.tar.bz2
rebase: fix garbled progress display with '-x'
When running a command with the 'exec' instruction during an interactive rebase session, or for a range of commits using 'git rebase -x', the output can be a bit garbled when the name of the command is short enough: $ git rebase -x true HEAD~5 Executing: true Executing: true Executing: true Executing: true Executing: true) Successfully rebased and updated refs/heads/master. Note the ')' at the end of the last line. It gets more garbled as the range of commits increases: $ git rebase -x true HEAD~50 Executing: true) [ repeated 3 more times ] Executing: true0) [ repeated 44 more times ] Executing: true00) Successfully rebased and updated refs/heads/master. Those extra numbers and ')' are remnants of the previously displayed "Rebasing (N/M)" progress lines that are usually completely overwritten by the "Executing: <cmd>" lines, unless 'cmd' is short and the "N/M" part is long. Make sure that the previously displayed "Rebasing (N/M)" line is cleared by using the term_clear_line() helper function added in the previous patch. Do so only when not being '--verbose', because in that case these "Rebasing (N/M)" lines are not printed as progress (i.e. as lines with '\r' at the end), but as "regular" output (with '\n' at the end). A couple of other rebase commands print similar messages, e.g. "Stopped at <abbrev-oid>... <subject>" for the 'edit' or 'break' commands, or the "Successfully rebased and updated <full-ref>." at the very end. These are so long that they practically always overwrite that "Rebasing (N/M)" progress line, but let's be prudent, and clear the last line before printing these, too. In 't3420-rebase-autostash.sh' two helper functions prepare the expected output of four tests that check the full output of 'git rebase' and thus are affected by this change, so adjust their expectations to account for the new line clearing. Note that this patch doesn't completely eliminate the possibility of similar garbled outputs, e.g. some error messages from rebase or the "Auto-merging <file>" message from within the depths of the merge machinery might not be long enough to completely cover the last "Rebasing (N/M)" line. This patch doesn't do anything about them, because dealing with them individually would result in way too much churn, while having a catch-all term_clear_line() call in the common code path of pick_commits() would hide the "Rebasing (N/M)" line way too soon, and it would either flicker or be invisible. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sequencer.c b/sequencer.c
index f88a97f..63b09cf 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3731,8 +3731,11 @@ static int pick_commits(struct repository *r,
unlink(git_path_merge_head(the_repository));
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
- if (item->command == TODO_BREAK)
+ if (item->command == TODO_BREAK) {
+ if (!opts->verbose)
+ term_clear_line();
return stopped_at_head(r);
+ }
}
if (item->command <= TODO_SQUASH) {
if (is_rebase_i(opts))
@@ -3754,11 +3757,14 @@ static int pick_commits(struct repository *r,
}
if (item->command == TODO_EDIT) {
struct commit *commit = item->commit;
- if (!res)
+ if (!res) {
+ if (!opts->verbose)
+ term_clear_line();
fprintf(stderr,
_("Stopped at %s... %.*s\n"),
short_commit_name(commit),
item->arg_len, arg);
+ }
return error_with_patch(r, commit,
arg, item->arg_len, opts, res, !res);
}
@@ -3796,6 +3802,8 @@ static int pick_commits(struct repository *r,
int saved = *end_of_arg;
struct stat st;
+ if (!opts->verbose)
+ term_clear_line();
*end_of_arg = '\0';
res = do_exec(r, arg);
*end_of_arg = saved;
@@ -3954,10 +3962,13 @@ cleanup_head_ref:
}
apply_autostash(opts);
- if (!opts->quiet)
+ if (!opts->quiet) {
+ if (!opts->verbose)
+ term_clear_line();
fprintf(stderr,
"Successfully rebased and updated %s.\n",
head_ref.buf);
+ }
strbuf_release(&buf);
strbuf_release(&head_ref);