@matheusbsbs / matheus-bagliano / commits / 77b258f436
Fork 0

t3404: fix "fake-editor"

Here-text to create fake-editor did not use <<\EOF but <<EOF, but there was no point doing so, as it quoted all the variables anyway. Simplify it. Also futureproof the special mode to edit COMMIT_EDITMSG file; it is interested in editing the COMMIT_EDITMSG file in any GIT_DIR; GIT_DIR may be given as an absolute path. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 11, 2007 at 14:08 UTC 77b258f436874bdd1caecd4b3c9c63e3d49bd147
1 file changed +19 -17
t/t3404-rebase-interactive.sh
+19 -17
@@ -61,29 +61,31 @@ test_expect_success 'setup' '
61 git tag I
62 '
63
64 -cat > fake-editor.sh << EOF
64 +cat > fake-editor.sh <<\EOF
65 #!/bin/sh
66 -test "\$1" = .git/COMMIT_EDITMSG && {
67 - test -z "\$FAKE_COMMIT_MESSAGE" || echo "\$FAKE_COMMIT_MESSAGE" > "\$1"
68 - test -z "\$FAKE_COMMIT_AMEND" || echo "\$FAKE_COMMIT_AMEND" >> "\$1"
66 +case "$1" in
67 +*/COMMIT_EDITMSG)
68 + test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
69 + test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
70 exit
70 -}
71 -test -z "\$EXPECT_COUNT" ||
72 - test "\$EXPECT_COUNT" = \$(grep -ve "^#" -e "^$" < "\$1" | wc -l) ||
71 + ;;
72 +esac
73 +test -z "$EXPECT_COUNT" ||
74 + test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
75 exit
74 -test -z "\$FAKE_LINES" && exit
75 -grep -v "^#" < "\$1" > "\$1".tmp
76 -rm "\$1"
77 -cat "\$1".tmp
76 +test -z "$FAKE_LINES" && exit
77 +grep -v '^#' < "$1" > "$1".tmp
78 +rm -f "$1"
79 +cat "$1".tmp
80 action=pick
79 -for line in \$FAKE_LINES; do
80 - case \$line in
81 +for line in $FAKE_LINES; do
82 + case $line in
83 squash)
82 - action="\$line";;
84 + action="$line";;
85 *)
84 - echo sed -n "\${line}s/^pick/\$action/p"
85 - sed -n "\${line}p" < "\$1".tmp
86 - sed -n "\${line}s/^pick/\$action/p" < "\$1".tmp >> "\$1"
86 + echo sed -n "${line}s/^pick/$action/p"
87 + sed -n "${line}p" < "$1".tmp
88 + sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
89 action=pick;;
90 esac
91 done