summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2015-10-01 08:18:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-06 05:39:56 (GMT)
commit1db168ee971a6a61ce72480e1db9ddfd3629bfcf (patch)
tree277aea9e0571f98073e7e7aecb22ccd19901b8b2 /t
parent31bff64100d0864741b57cc44e01a19359573e99 (diff)
downloadgit-1db168ee971a6a61ce72480e1db9ddfd3629bfcf.zip
git-1db168ee971a6a61ce72480e1db9ddfd3629bfcf.tar.gz
git-1db168ee971a6a61ce72480e1db9ddfd3629bfcf.tar.bz2
rebase-i: loosen over-eager check_bad_cmd check
804098bb (git rebase -i: add static check for commands and SHA-1, 2015-06-29) tried to check all insns before running any in the todo list, but it did so by implementing its own parser that is a lot stricter than necessary. We used to allow lines that are indented (including comment lines), and we used to allow a whitespace between the insn and the commit object name to be HT, among other things, that are flagged as an invalid line by mistake. Fix this by using the same tokenizer that is used to parse the todo list file in the new check. Whether it's a good thing to accept indented comments is debatable (other commands like "git commit" do not accept them), but we already accepted them in the past, and some people and scripts rely on this behavior. Also, a line starting with space followed by a '#' cannot have any meaning other than being a comment, hence it doesn't harm to accept them as comments. Largely based on patch by: Junio C Hamano <gitster@pobox.com> [jc: updated test with quickfix from Torsten Bögershausen] Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3404-rebase-interactive.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index ebdab4b..88d7d53 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1206,6 +1206,21 @@ test_expect_success 'static check of bad command' '
test C = $(git cat-file commit HEAD^ | sed -ne \$p)
'
+test_expect_success 'tabs and spaces are accepted in the todolist' '
+ rebase_setup_and_clean indented-comment &&
+ write_script add-indent.sh <<-\EOF &&
+ (
+ # Turn single spaces into space/tab mix
+ sed "1s/ / /g; 2s/ / /g; 3s/ / /g" "$1"
+ printf "\n\t# comment\n #more\n\t # comment\n"
+ ) >$1.new
+ mv "$1.new" "$1"
+ EOF
+ test_set_editor "$(pwd)/add-indent.sh" &&
+ git rebase -i HEAD^^^ &&
+ test E = $(git cat-file commit HEAD | sed -ne \$p)
+'
+
cat >expect <<EOF
Warning: the SHA-1 is missing or isn't a commit in the following line:
- edit XXXXXXX False commit