aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--git-rediff.c8
-rw-r--r--t/common.sh4
-rwxr-xr-xt/interactive-redraw33
4 files changed, 46 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 1093f64..9a604f3 100644
--- a/Makefile
+++ b/Makefile
@@ -223,6 +223,7 @@ TEST =\
t/interactive-skip\
t/interactive-edit\
t/interactive-help\
+ t/interactive-redraw\
t/interactive-multiple-commands\
t/interactive-two-files
diff --git a/git-rediff.c b/git-rediff.c
index 36a5134..586daec 100644
--- a/git-rediff.c
+++ b/git-rediff.c
@@ -24,6 +24,7 @@ enum interactive_command {
INTERACTIVE_ERROR,
INTERACTIVE_REDIFF,
INTERACTIVE_EDIT,
+ INTERACTIVE_REDRAW,
INTERACTIVE_SKIP_FILE
};
@@ -642,6 +643,8 @@ again:
}
if (c != '\n')
dprintf(ttyfd_out, "\n");
+ if (c == 'L' - '@')
+ return INTERACTIVE_REDRAW;
#ifndef TEST
if (c == 'Z' - '@') {
if (tcsetattr(ttyfd, TCSANOW, &tty_settings))
@@ -941,10 +944,15 @@ rediff_file(struct text *text_out, const struct text *text_in, size_t conflict_m
hunk.nsubs = (size_t)subhunk + 1U;
if (command != INTERACTIVE_SKIP_FILE) {
hunkno++;
+ reprompt:
display_hunk(text_in, (size_t)(hunk.subs[0].head - text_in->lines), i, &hunk, conflict_marker_size);
command = get_command(hunk.nsubs, hunkno, nhunks);
if (command == INTERACTIVE_ERROR)
goto error;
+ if (command == INTERACTIVE_REDRAW) {
+ dprintf(ttyfd_out, "\033[H\033[2J");
+ goto reprompt;
+ }
}
if (command == INTERACTIVE_EDIT)
r = manual_edit(text_out, &hunk, &text_in->lines[i], conflict_marker_size);
diff --git a/t/common.sh b/t/common.sh
index 38d2845..bb1bd83 100644
--- a/t/common.sh
+++ b/t/common.sh
@@ -144,6 +144,10 @@ interactive_prompt () {
printf '\e[1;34m(%s/%s) Resolve this conflict [h,t,b,m,y,r,e,s,d,q,?]? \e[0m\n' "$1" "$2"
}
+interactive_clear_screen () {
+ printf '\e[H\e[2J'
+}
+
interactive_help () {
test $# = 1
printf '\e[1;31m'
diff --git a/t/interactive-redraw b/t/interactive-redraw
new file mode 100755
index 0000000..71fdca6
--- /dev/null
+++ b/t/interactive-redraw
@@ -0,0 +1,33 @@
+#!/bin/sh -e
+. t/common.sh
+interactive
+
+printf '%s\n' > file \
+ "${HEAD} ours" \
+ head \
+ "${TAIL}" \
+ tail \
+ "${END} theirs"
+
+printf '%s\n' > file.expected \
+ head
+
+(
+ interactive_marker "${HEAD} ours"
+ interactive_side head
+ interactive_marker "${TAIL}"
+ interactive_side tail
+ interactive_marker "${END} theirs"
+ interactive_prompt 1 1
+ interactive_clear_screen
+ interactive_marker "${HEAD} ours"
+ interactive_side head
+ interactive_marker "${TAIL}"
+ interactive_side tail
+ interactive_marker "${END} theirs"
+ interactive_prompt 1 1
+) > output.expected
+
+printf '\fh' > input
+normal --interactive file 8<input 9>output
+diff -u -- output.expected output >&2