зеркало из https://github.com/microsoft/git.git
Merge branch 'ld/p4-editor-multi-words'
Unlike "$EDITOR" and "$GIT_EDITOR" that can hold the path to the command and initial options (e.g. "/path/to/emacs -nw"), 'git p4' did not let the shell interpolate the contents of the environment variable that name the editor "$P4EDITOR" (and "$EDITOR", too). Make it in line with the rest of Git, as well as with Perforce. * ld/p4-editor-multi-words: git-p4: tests: use test-chmtime in place of touch git-p4: fix handling of multi-word P4EDITOR git-p4: add failing test for P4EDITOR handling
This commit is contained in:
Коммит
9fb0a798a7
|
@ -1248,7 +1248,7 @@ class P4Submit(Command, P4UserMap):
|
|||
editor = os.environ.get("P4EDITOR")
|
||||
else:
|
||||
editor = read_pipe("git var GIT_EDITOR").strip()
|
||||
system([editor, template_file])
|
||||
system(["sh", "-c", ('%s "$@"' % editor), editor, template_file])
|
||||
|
||||
# If the file was not saved, prompt to see if this patch should
|
||||
# be skipped. But skip this verification step if configured so.
|
||||
|
|
|
@ -28,7 +28,7 @@ test_expect_success 'shell metachars in filenames' '
|
|||
echo f2 >"file with spaces" &&
|
||||
git add "file with spaces" &&
|
||||
git commit -m "add files" &&
|
||||
P4EDITOR=touch git p4 submit
|
||||
P4EDITOR="test-chmtime +5" git p4 submit
|
||||
) &&
|
||||
(
|
||||
cd "$cli" &&
|
||||
|
@ -47,7 +47,7 @@ test_expect_success 'deleting with shell metachars' '
|
|||
git rm foo\$bar &&
|
||||
git rm file\ with\ spaces &&
|
||||
git commit -m "remove files" &&
|
||||
P4EDITOR=touch git p4 submit
|
||||
P4EDITOR="test-chmtime +5" git p4 submit
|
||||
) &&
|
||||
(
|
||||
cd "$cli" &&
|
||||
|
|
|
@ -90,7 +90,7 @@ test_expect_success 'no config, edited' '
|
|||
cd "$git" &&
|
||||
echo line >>file1 &&
|
||||
git commit -a -m "change 5" &&
|
||||
P4EDITOR="$TRASH_DIRECTORY/ed.sh" &&
|
||||
P4EDITOR="\"$TRASH_DIRECTORY/ed.sh\"" &&
|
||||
export P4EDITOR &&
|
||||
git p4 submit &&
|
||||
p4 changes //depot/... >wc &&
|
||||
|
|
|
@ -53,7 +53,9 @@ test_expect_success 'preserve users' '
|
|||
git commit --author "Alice <alice@example.com>" -m "a change by alice" file1 &&
|
||||
git commit --author "Bob <bob@example.com>" -m "a change by bob" file2 &&
|
||||
git config git-p4.skipSubmitEditCheck true &&
|
||||
P4EDITOR=touch P4USER=alice P4PASSWD=secret git p4 commit --preserve-user &&
|
||||
P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret &&
|
||||
export P4EDITOR P4USER P4PASSWD &&
|
||||
git p4 commit --preserve-user &&
|
||||
p4_check_commit_author file1 alice &&
|
||||
p4_check_commit_author file2 bob
|
||||
)
|
||||
|
@ -69,7 +71,7 @@ test_expect_success 'refuse to preserve users without perms' '
|
|||
git config git-p4.skipSubmitEditCheck true &&
|
||||
echo "username-noperms: a change by alice" >>file1 &&
|
||||
git commit --author "Alice <alice@example.com>" -m "perms: a change by alice" file1 &&
|
||||
P4EDITOR=touch P4USER=bob P4PASSWD=secret &&
|
||||
P4EDITOR="test-chmtime +5" P4USER=bob P4PASSWD=secret &&
|
||||
export P4EDITOR P4USER P4PASSWD &&
|
||||
test_must_fail git p4 commit --preserve-user &&
|
||||
! git diff --exit-code HEAD..p4/master
|
||||
|
@ -87,7 +89,7 @@ test_expect_success 'preserve user where author is unknown to p4' '
|
|||
git commit --author "Bob <bob@example.com>" -m "preserve: a change by bob" file1 &&
|
||||
echo "username-unknown: a change by charlie" >>file1 &&
|
||||
git commit --author "Charlie <charlie@example.com>" -m "preserve: a change by charlie" file1 &&
|
||||
P4EDITOR=touch P4USER=alice P4PASSWD=secret &&
|
||||
P4EDITOR="test-chmtime +5" P4USER=alice P4PASSWD=secret &&
|
||||
export P4EDITOR P4USER P4PASSWD &&
|
||||
test_must_fail git p4 commit --preserve-user &&
|
||||
! git diff --exit-code HEAD..p4/master &&
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
test_description='git p4 handling of EDITOR'
|
||||
|
||||
. ./lib-git-p4.sh
|
||||
|
||||
test_expect_success 'start p4d' '
|
||||
start_p4d
|
||||
'
|
||||
|
||||
test_expect_success 'init depot' '
|
||||
(
|
||||
cd "$cli" &&
|
||||
echo file1 >file1 &&
|
||||
p4 add file1 &&
|
||||
p4 submit -d "file1"
|
||||
)
|
||||
'
|
||||
|
||||
# Check that the P4EDITOR argument can be given command-line
|
||||
# options, which git-p4 will then pass through to the shell.
|
||||
test_expect_success 'EDITOR with options' '
|
||||
git p4 clone --dest="$git" //depot &&
|
||||
test_when_finished cleanup_git &&
|
||||
(
|
||||
cd "$git" &&
|
||||
echo change >file1 &&
|
||||
git commit -m "change" file1 &&
|
||||
P4EDITOR=": >\"$git/touched\" && test-chmtime +5" git p4 submit &&
|
||||
test_path_is_file "$git/touched"
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'kill p4d' '
|
||||
kill_p4d
|
||||
'
|
||||
|
||||
test_done
|
Загрузка…
Ссылка в новой задаче