summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-11-23 19:23:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-11-23 19:23:17 (GMT)
commitbd53f38d52b87340ad791290d700c5c7e8587f23 (patch)
treeecff6137224ddcd8d0e20a9a7c68fec94f056841
parent48e9ad5ef3afd39168e2fb72d0ce7ac5f7124d31 (diff)
parent882cd23777f8984e433e0c0addae5e9d70de75e8 (diff)
downloadgit-bd53f38d52b87340ad791290d700c5c7e8587f23.zip
git-bd53f38d52b87340ad791290d700c5c7e8587f23.tar.gz
git-bd53f38d52b87340ad791290d700c5c7e8587f23.tar.bz2
Merge branch 'js/rebase-i-commentchar-fix'
"git rebase -i" did not work well with core.commentchar configuration variable for two reasons, both of which have been fixed. * js/rebase-i-commentchar-fix: rebase -i: handle core.commentChar=auto stripspace: respect repository config rebase -i: highlight problems with core.commentchar
-rw-r--r--builtin/stripspace.c4
-rw-r--r--git-rebase--interactive.sh13
-rwxr-xr-xt/t0030-stripspace.sh9
-rwxr-xr-xt/t3404-rebase-interactive.sh11
4 files changed, 34 insertions, 3 deletions
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index 15e716e..1e62a00 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -44,8 +44,10 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
if (argc)
usage_with_options(stripspace_usage, options);
- if (mode == STRIP_COMMENTS || mode == COMMENT_LINES)
+ if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
+ setup_git_directory_gently(NULL);
git_config(git_default_config, NULL);
+ }
if (strbuf_read(&buf, 0, 1024) < 0)
die_errno("could not read the input");
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index ca994c5..41fd374 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -93,8 +93,17 @@ eval '
GIT_CHERRY_PICK_HELP="$resolvemsg"
export GIT_CHERRY_PICK_HELP
-comment_char=$(git config --get core.commentchar 2>/dev/null | cut -c1)
-: ${comment_char:=#}
+comment_char=$(git config --get core.commentchar 2>/dev/null)
+case "$comment_char" in
+'' | auto)
+ comment_char="#"
+ ;;
+?)
+ ;;
+*)
+ comment_char=$(echo "$comment_char" | cut -c1)
+ ;;
+esac
warn () {
printf '%s\n' "$*" >&2
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index 29e91d8..bbf3e39 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -432,6 +432,15 @@ test_expect_success '-c with changed comment char' '
test_cmp expect actual
'
+test_expect_success '-c with comment char defined in .git/config' '
+ test_config core.commentchar = &&
+ printf "= foo\n" >expect &&
+ printf "foo" | (
+ mkdir sub && cd sub && git stripspace -c
+ ) >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'avoid SP-HT sequence in commented line' '
printf "#\tone\n#\n# two\n" >expect &&
printf "\tone\n\ntwo\n" | git stripspace -c >actual &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index e38e296..c896a4c 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -976,6 +976,17 @@ test_expect_success 'rebase -i respects core.commentchar' '
test B = $(git cat-file commit HEAD^ | sed -ne \$p)
'
+test_expect_success 'rebase -i respects core.commentchar=auto' '
+ test_config core.commentchar auto &&
+ write_script copy-edit-script.sh <<-\EOF &&
+ cp "$1" edit-script
+ EOF
+ test_set_editor "$(pwd)/copy-edit-script.sh" &&
+ test_when_finished "git rebase --abort || :" &&
+ git rebase -i HEAD^ &&
+ test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
+'
+
test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
test_when_finished "git branch -D torebase" &&
git checkout -b torebase branch1 &&