Merge branch 'maint'

* maint:
  git-svn: fix find-rev error message when missing arg
  t0021: tr portability fix for Solaris
  launch_editor(): allow spaces in the filename
  git rebase --abort: always restore the right commit
This commit is contained in:
Junio C Hamano 2008-03-11 21:40:47 -07:00
commit b81a7b5887
4 changed files with 37 additions and 3 deletions

View file

@ -50,12 +50,15 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e
size_t len = strlen(editor);
int i = 0;
const char *args[6];
struct strbuf arg0;
strbuf_init(&arg0, 0);
if (strcspn(editor, "$ \t'") != len) {
/* there are specials */
strbuf_addf(&arg0, "%s \"$@\"", editor);
args[i++] = "sh";
args[i++] = "-c";
args[i++] = "$0 \"$@\"";
args[i++] = arg0.buf;
}
args[i++] = editor;
args[i++] = path;
@ -63,6 +66,7 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e
if (run_command_v_opt_cd_env(args, 0, NULL, env))
die("There was a problem with the editor %s.", editor);
strbuf_release(&arg0);
}
if (!buffer)

View file

@ -522,7 +522,8 @@ sub cmd_dcommit {
}
sub cmd_find_rev {
my $revision_or_hash = shift;
my $revision_or_hash = shift or die "SVN or git revision required ",
"as a command-line argument\n";
my $result;
if ($revision_or_hash =~ /^r\d+$/) {
my $head = shift;

View file

@ -5,7 +5,9 @@ test_description='blob conversion via gitattributes'
. ./test-lib.sh
cat <<\EOF >rot13.sh
tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
tr \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
EOF
chmod +x rot13.sh

View file

@ -89,6 +89,33 @@ do
'
done
test_expect_success 'editor with a space' '
if echo "echo space > \"\$1\"" > "e space.sh"
then
chmod a+x "e space.sh" &&
GIT_EDITOR="./e\ space.sh" git commit --amend &&
test space = "$(git show -s --pretty=format:%s)"
else
say "Skipping; FS does not support spaces in filenames"
fi
'
unset GIT_EDITOR
test_expect_success 'core.editor with a space' '
if test -f "e space.sh"
then
git config core.editor \"./e\ space.sh\" &&
git commit --amend &&
test space = "$(git show -s --pretty=format:%s)"
else
say "Skipping; FS does not support spaces in filenames"
fi
'
TERM="$OLD_TERM"
test_done