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

View File

@ -522,7 +522,8 @@ sub cmd_dcommit {
} }
sub cmd_find_rev { 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; my $result;
if ($revision_or_hash =~ /^r\d+$/) { if ($revision_or_hash =~ /^r\d+$/) {
my $head = shift; my $head = shift;

View File

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

View File

@ -89,6 +89,33 @@ do
' '
done 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" TERM="$OLD_TERM"
test_done test_done