From: "Alessio Attilio via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Alessio Attilio <attilio.alessio@protonmail.com>,
Alessio Attilio <attilio.alessio@protonmail.com>
Subject: [PATCH 4/4] rebase: test whitespace fixes with the merge backend
Date: Mon, 30 Nov 2026 00:01:25 +0000 [thread overview]
Message-ID: <e462455723a5bb021093bae98603ab32e5cf49c8.1795996885.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2511.git.git.1795996885.gitgitgadget@gmail.com>
From: Alessio Attilio <attilio.alessio@protonmail.com>
Exercise whitespace=fix while replaying commits with the merge backend,
including interactive use, attribute rules, existing whitespace in the
base, added files, and whitespace at end of file. Also check that the
option remains rejected with the merge backend for actions it does not
support.
These tests cover the user-visible behavior across both backend
selection and merge replay, guarding against fixing unchanged context or
regressing the apply backend.
Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
---
t/t3417-rebase-whitespace-fix.sh | 163 +++++++++++++++++++++++++++++++
1 file changed, 163 insertions(+)
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
index 96f2cf22fa..c65b5c1e37 100755
--- a/t/t3417-rebase-whitespace-fix.sh
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -94,6 +94,169 @@ test_expect_success 'same, but do not remove trailing spaces' '
test_cmp file third
'
+test_expect_success 'interactive rebase fixes whitespace' '
+ git config core.whitespace blank-at-eol &&
+ git checkout -b interactive-whitespace HEAD^ &&
+ test_write_lines "clean" >file &&
+ git commit -am clean &&
+ test_write_lines "trailing " >>file &&
+ git commit -am "add whitespace errors" &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor git rebase -i --whitespace=fix HEAD^^ &&
+ test_write_lines clean "trailing" >expect &&
+ test_cmp expect file
+'
+
+test_expect_success 'interactive rebase fixes whitespace in upstream context' '
+ test_create_repo context &&
+ (
+ cd context &&
+ test_write_lines one "two " three >file &&
+ git add file && git commit -m base &&
+ git checkout -b topic &&
+ test_write_lines one two THREE >file &&
+ git commit -am topic &&
+ git checkout -b upstream HEAD^ &&
+ test_write_lines one two three >file &&
+ git commit -am whitespace &&
+ git checkout topic &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix upstream &&
+ test_write_lines one two THREE >expect &&
+ test_cmp expect file
+ )
+'
+
+test_expect_success 'interactive rebase preserves other whitespace changes' '
+ test_create_repo preserve &&
+ (
+ cd preserve &&
+ git config core.whitespace blank-at-eol &&
+ test_write_lines one "two " three >file &&
+ git add file && git commit -m base &&
+ git checkout -b topic &&
+ printf " one\ntwo \nthree \n" >file &&
+ git commit -am topic &&
+ git checkout -b upstream HEAD^ &&
+ printf "one\ntwo\nthree\n" >file &&
+ git commit -am whitespace &&
+ git checkout topic &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix upstream &&
+ printf " one\ntwo\nthree\n" >expect &&
+ test_cmp expect file
+ )
+'
+
+test_expect_success 'interactive rebase rejects unsupported whitespace actions' '
+ test_create_repo unsupported &&
+ (
+ cd unsupported &&
+ test_write_lines base >file &&
+ git add file && git commit -m base &&
+ test_write_lines change >>file &&
+ git commit -am change &&
+ test_must_fail env GIT_SEQUENCE_EDITOR=: \
+ git rebase -i --whitespace=warn HEAD^
+ )
+'
+
+test_expect_success 'interactive rebase fixes blank-at-eof' '
+ test_create_repo eof &&
+ (
+ cd eof &&
+ test_write_lines one >file &&
+ git add file && git commit -m base &&
+ test_write_lines one two >file &&
+ printf "\n\n" >>file &&
+ git commit -am whitespace &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix HEAD^ &&
+ test_write_lines one two >expect &&
+ test_cmp expect file
+ )
+'
+
+test_expect_success 'interactive rebase handles upstream blank-at-eof fixes' '
+ test_create_repo eof-context &&
+ (
+ cd eof-context &&
+ test_write_lines one >file &&
+ printf "\n\n" >>file &&
+ git add file && git commit -m base &&
+ git checkout -b topic &&
+ test_write_lines one two >file &&
+ printf "\n\n" >>file &&
+ git commit -am topic &&
+ git checkout -b upstream HEAD^ &&
+ test_write_lines one >file &&
+ git commit -am whitespace &&
+ git checkout topic &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix upstream &&
+ test_write_lines one two >expect &&
+ test_cmp expect file
+ )
+'
+
+test_expect_success 'interactive rebase honors path whitespace rules' '
+ test_create_repo attr &&
+ (
+ cd attr &&
+ echo "file whitespace=-blank-at-eol" >.gitattributes &&
+ test_write_lines one >file &&
+ git add .gitattributes file && git commit -m base &&
+ printf "one \n" >file &&
+ git commit -am whitespace &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix HEAD^ &&
+ printf "one \n" >expect &&
+ test_cmp expect file
+ )
+'
+
+test_expect_success 'interactive rebase fixes whitespace in added files' '
+ test_create_repo added &&
+ (
+ cd added &&
+ test_write_lines base >file &&
+ git add file && git commit -m base &&
+ printf "new file with whitespace \n" >new-file &&
+ git add new-file && git commit -m add &&
+ write_script sequence-editor <<-\EOF &&
+ sed -e "s/^pick/pick/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ GIT_SEQUENCE_EDITOR=./sequence-editor \
+ git rebase -i --whitespace=fix HEAD^ &&
+ printf "new file with whitespace\n" >expect &&
+ test_cmp expect new-file
+ )
+'
+
sed -e's/Z//' >beginning <<EOF
a
Z
--
gitgitgadget
prev parent reply other threads:[~2026-11-30 0:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 0:01 [PATCH 0/4] rebase: support --whitespace=fix with --interactive Alessio Attilio via GitGitGadget
2026-11-30 0:01 ` [PATCH 1/4] xdiff: support transformed records in merge matching Alessio Attilio via GitGitGadget
2026-11-30 0:01 ` [PATCH 2/4] merge-ort: fix whitespace in replayed changes Alessio Attilio via GitGitGadget
2026-11-30 0:01 ` [PATCH 3/4] rebase: route whitespace fixes through the selected backend Alessio Attilio via GitGitGadget
2026-11-30 0:01 ` Alessio Attilio via GitGitGadget [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e462455723a5bb021093bae98603ab32e5cf49c8.1795996885.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=attilio.alessio@protonmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox