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
This commit is contained in:
Junio C Hamano 2016-11-23 11:23:17 -08:00
commit bd53f38d52
4 changed files with 34 additions and 3 deletions

View File

@ -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");

View File

@ -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

View File

@ -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 &&

View File

@ -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 &&