git-p4: move to toplevel
Subsystems (2)
cover git-p4: move to toplevel
The git-p4 code is in a single python script down in contrib/fast-import now. I'd like to move it up to the top-level source directory of git to make it easier to build and distribute. Git-p4 already takes advantage of the git infrastructure for documentation and testing, as well as the community support (Junio, many reviewers).
Users install git-p4 currently by copying the git-p4 script from contrib/fast-import into a local or personal bin directory, and setting up an alias for "git p4" to invoke it. If it is part of the install, the command will be available automatically. Also, distributions may be more likely to pick it up either as part of a core git package, or as a separate add-on. Getting support for python and git-p4 in msysgit is something I'd like to see happen too.
While I considered taking this opportunity to split up git-p4 into more modular components across multiple files, it seems best now just to do the script move intact. That effort could come later. If anyone has a strong preference to do this now, we could.
Developer note: Like all scripts in git, the source file is git-p4.py, which is built with "make" to git-p4, substituting the specified path for python in the first line. Be sure to edit the source file, and to build before running tests. This is sort of a pain for existing developers, but hopefully we can get used to it.
Pete Wyckoff (3):
git-p4: move to toplevel
git p4: update name in script
git p4: use "git p4" directly in tests
.gitignore | 1 + Documentation/git-p4.txt | 23 +++------ INSTALL | 3 + Makefile | 1 + contrib/fast-import/git-p4.README | 13 +++++ contrib/fast-import/git-p4.bat | 1 - contrib/fast-import/git-p4 => git-p4.py | 14 +++--- t/lib-git-p4.sh | 8 +-- t/t9800-git-p4-basic.sh | 84 +++++++++++++++--------------- t/t9801-git-p4-branch.sh | 32 ++++++------ t/t9802-git-p4-filetype.sh | 10 ++-- t/t9803-git-p4-shell-metachars.sh | 12 ++-- t/t9804-git-p4-label.sh | 6 +- t/t9805-git-p4-skip-submit-edit.sh | 22 ++++---- t/t9806-git-p4-options.sh | 28 +++++----- t/t9807-git-p4-submit.sh | 22 ++++---- t/t9808-git-p4-chdir.sh | 6 +- t/t9809-git-p4-client-view.sh | 64 ++++++++++++------------ 18 files changed, 179 insertions(+), 171 deletions(-) create mode 100644 contrib/fast-import/git-p4.README delete mode 100644 contrib/fast-import/git-p4.bat rename contrib/fast-import/git-p4 => git-p4.py (99%)
Signature · 1 line
1.7.9.192.ga1d4b
RFC PATCH 1/3 git-p4: move to toplevel
Move git-p4 out of contrib/fast-import into the main code base, aside other foreign SCM tools.
--- .gitignore | 1 + Documentation/git-p4.txt | 23 ++++++++--------------- INSTALL | 3 +++ Makefile | 1 + contrib/fast-import/git-p4.README | 13 +++++++++++++ contrib/fast-import/git-p4.bat | 1 - contrib/fast-import/git-p4 => git-p4.py | 0 t/lib-git-p4.sh | 2 +- 8 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 contrib/fast-import/git-p4.README delete mode 100644 contrib/fast-import/git-p4.bat rename contrib/fast-import/git-p4 => git-p4.py (100%)
.gitignore +1 -0
@@ -92,6 +92,7 @@ /git-name-rev /git-mv /git-notes +/git-p4 /git-pack-redundant /git-pack-objects /git-pack-refs
Documentation/git-p4.txt +8 -15
@@ -3,7 +3,7 @@ git-p4(1) NAME ---- -git-p4 - Import from and submit to Perforce repositories +'git p4' - Import from and submit to Perforce repositories SYNOPSIS
@@ -31,13 +31,6 @@ the updated p4 remote branch. EXAMPLE ------- -* Create an alias for 'git p4', using the full path to the 'git-p4' - script if needed: -+ ------------- -$ git config --global alias.p4 '!git-p4' ------------- - * Clone a repository: + ------------
@@ -303,23 +296,23 @@ CLIENT SPEC ----------- The p4 client specification is maintained with the 'p4 client' command and contains among other fields, a View that specifies how the depot -is mapped into the client repository. Git-p4 can consult the client +is mapped into the client repository. 'Git p4' can consult the client spec when given the '--use-client-spec' option or useClientSpec variable. -The full syntax for a p4 view is documented in 'p4 help views'. Git-p4 +The full syntax for a p4 view is documented in 'p4 help views'. 'Git p4' knows only a subset of the view syntax. It understands multi-line mappings, overlays with '+', exclusions with '-' and double-quotes -around whitespace. Of the possible wildcards, git-p4 only handles -'...', and only when it is at the end of the path. Git-p4 will complain +around whitespace. Of the possible wildcards, 'git p4' only handles +'...', and only when it is at the end of the path. 'Git p4' will complain if it encounters an unhandled wildcard. Bugs in the implementation of overlap mappings exist. If multiple depot paths map through overlays to the same location in the repository, -git-p4 can choose the wrong one. This is hard to solve without -dedicating a client spec just for git-p4. +'git p4' can choose the wrong one. This is hard to solve without +dedicating a client spec just for 'git p4'. -The name of the client can be given to git-p4 in multiple ways. The +The name of the client can be given to 'git p4' in multiple ways. The variable 'git-p4.client' takes precedence if it exists. Otherwise, normal p4 mechanisms of determining the client are used: environment variable P4CLIENT, a file referenced by P4CONFIG, or the local host name.
INSTALL +3 -0
@@ -122,6 +122,9 @@ Issues of note: use English. Under autoconf the configure script will do this automatically if it can't find libintl on the system. + - Python version 2.6 or later is needed to use the git-p4 + interface to Perforce. + - Some platform specific issues are dealt with Makefile rules, but depending on your specific installation, you may not have all the libraries/tools needed, or you may have
Makefile +1 -0
@@ -436,6 +436,7 @@ SCRIPT_PERL += git-send-email.perl SCRIPT_PERL += git-svn.perl SCRIPT_PYTHON += git-remote-testgit.py +SCRIPT_PYTHON += git-p4.py SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \
contrib/fast-import/git-p4.README new file +13 -0
@@ -0,0 +1,13 @@ +The git-p4 script moved to the top-level of the git source directory. + +Invoke it as any other git command, like "git p4 clone", for instance. + +Note that the top-level git-p4.py script is now the source. It is +built using make to git-p4, which will be installed. + +Windows users can copy the git-p4.py source script directly, possibly +invoking it through a batch file called "git-p4.bat" in the same folder. +It should contain just one line: + + @python "%~d0%~p0git-p4.py" %* +
contrib/fast-import/git-p4.bat deleted +0 -1
@@ -1 +0,0 @@ -@python "%~d0%~p0git-p4" %*
git-p4.py renamed from contrib/fast-import/git-p4 +0 -0
t/lib-git-p4.sh +1 -1
@@ -13,7 +13,7 @@ fi test_done } -GITP4="$GIT_BUILD_DIR/contrib/fast-import/git-p4" +GITP4="$GIT_BUILD_DIR/git-p4" # Try to pick a unique port: guess a large number, then hope # no more than one of each test is running.
Signature · 1 line
1.7.9.192.ga1d4b
RFC PATCH 2/3 git p4: update name in script
In reply to Pete WyckoffIn messages to the user and comments, change "git-p4" to "git p4".
--- git-p4.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
git-p4.py +7 -7
@@ -988,12 +988,12 @@ class P4Submit(Command, P4UserMap): print "The following files should be scheduled for deletion with p4 delete:" print " ".join(filesToDelete) die("Please resolve and submit the conflict manually and " - + "continue afterwards with git-p4 submit --continue") + + "continue afterwards with git p4 submit --continue") elif response == "w": system(diffcmd + " > patch.txt") print "Patch saved to patch.txt in %s !" % self.clientPath die("Please resolve and submit the conflict manually and " - "continue afterwards with git-p4 submit --continue") + "continue afterwards with git p4 submit --continue") system(applyPatchCmd)
@@ -1037,8 +1037,8 @@ class P4Submit(Command, P4UserMap): if self.checkAuthorship and not self.p4UserIsMe(p4User): submitTemplate += "######## git author %s does not match your p4 account.\n" % gitEmail - submitTemplate += "######## Use git-p4 option --preserve-user to modify authorship\n" - submitTemplate += "######## Use git-p4 config git-p4.skipUserNameCheck hides this message.\n" + submitTemplate += "######## Use option --preserve-user to modify authorship.\n" + submitTemplate += "######## Variable git-p4.skipUserNameCheck hides this message.\n" separatorLine = "######## everything below this line is just the diff #######\n"
@@ -2106,7 +2106,7 @@ class P4Sync(Command, P4UserMap): details["change"] = newestRevision - # Use time from top-most change so that all git-p4 clones of + # Use time from top-most change so that all git p4 clones of # the same p4 repo have the same commit SHA1s. res = p4CmdList("describe -s %d" % newestRevision) newestTime = None
@@ -2349,8 +2349,8 @@ class P4Sync(Command, P4UserMap): changes.sort() else: - # catch "git-p4 sync" with no new branches, in a repo that - # does not have any existing git-p4 branches + # catch "git p4 sync" with no new branches, in a repo that + # does not have any existing p4 branches if len(args) == 0 and not self.p4BranchesInGit: die("No remote p4 branches. Perhaps you never did \"git p4 clone\" in here."); if self.verbose:
Signature · 1 line
1.7.9.192.ga1d4b
RFC PATCH 3/3 git p4: use "git p4" directly in tests
In reply to Pete WyckoffDrop the $GITP4 variable that was used to specify the script in contrib/fast-import/. The command is called "git p4" now, not "git-p4". Variables will remain in a section called "git-p4".
--- t/lib-git-p4.sh | 8 +-- t/t9800-git-p4-basic.sh | 84 ++++++++++++++++++------------------ t/t9801-git-p4-branch.sh | 32 +++++++------- t/t9802-git-p4-filetype.sh | 10 ++-- t/t9803-git-p4-shell-metachars.sh | 12 +++--- t/t9804-git-p4-label.sh | 6 +- t/t9805-git-p4-skip-submit-edit.sh | 22 +++++----- t/t9806-git-p4-options.sh | 28 ++++++------ t/t9807-git-p4-submit.sh | 22 +++++----- t/t9808-git-p4-chdir.sh | 6 +- t/t9809-git-p4-client-view.sh | 64 ++++++++++++++-------------- 11 files changed, 146 insertions(+), 148 deletions(-)
t/lib-git-p4.sh +3 -5
@@ -1,20 +1,18 @@ # -# Library code for git-p4 tests +# Library code for git p4 tests # . ./test-lib.sh if ! test_have_prereq PYTHON; then - skip_all='skipping git-p4 tests; python not available' + skip_all='skipping git p4 tests; python not available' test_done fi ( p4 -h && p4d -h ) >/dev/null 2>&1 || { - skip_all='skipping git-p4 tests; no p4 or p4d' + skip_all='skipping git p4 tests; no p4 or p4d' test_done } -GITP4="$GIT_BUILD_DIR/git-p4" - # Try to pick a unique port: guess a large number, then hope # no more than one of each test is running. #
t/t9800-git-p4-basic.sh +42 -42
302 lines not on this page · raw message
t/t9801-git-p4-branch.sh +16 -16
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 p4 branching tests' +test_description='git p4 tests for p4 branches' . ./lib-git-p4.sh
@@ -63,7 +63,7 @@ test_expect_success 'basic p4 branches' ' test_expect_success 'import main, no branch detection' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot/main@all && + git p4 clone --dest="$git" //depot/main@all && ( cd "$git" && git log --oneline --graph --decorate --all &&
@@ -74,7 +74,7 @@ test_expect_success 'import main, no branch detection' ' test_expect_success 'import branch1, no branch detection' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot/branch1@all && + git p4 clone --dest="$git" //depot/branch1@all && ( cd "$git" && git log --oneline --graph --decorate --all &&
@@ -85,7 +85,7 @@ test_expect_success 'import branch1, no branch detection' ' test_expect_success 'import branch2, no branch detection' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot/branch2@all && + git p4 clone --dest="$git" //depot/branch2@all && ( cd "$git" && git log --oneline --graph --decorate --all &&
@@ -96,7 +96,7 @@ test_expect_success 'import branch2, no branch detection' ' test_expect_success 'import depot, no branch detection' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot@all && + git p4 clone --dest="$git" //depot@all && ( cd "$git" && git log --oneline --graph --decorate --all &&
@@ -107,7 +107,7 @@ test_expect_success 'import depot, no branch detection' ' test_expect_success 'import depot, branch detection' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" --detect-branches //depot@all && + git p4 clone --dest="$git" --detect-branches //depot@all && ( cd "$git" &&
@@ -132,7 +132,7 @@ test_expect_success 'import depot, branch detection, branchList branch definitio ( cd "$git" && git config git-p4.branchList main:branch1 && - "$GITP4" clone --dest=. --detect-branches //depot@all && + git p4 clone --dest=. --detect-branches //depot@all && git log --oneline --graph --decorate --all &&
@@ -189,15 +189,15 @@ test_expect_success 'add simple p4 branches' ' # Configure branches through git-config and clone them. # All files are tested to make sure branches were cloned correctly. # Finally, make an update to branch1 on P4 side to check if it is imported -# correctly by git-p4. -test_expect_success 'git-p4 clone simple branches' ' +# correctly by git p4. +test_expect_success 'git p4 clone simple branches' ' test_when_finished cleanup_git && test_create_repo "$git" && ( cd "$git" && git config git-p4.branchList branch1:branch2 && git config --add git-p4.branchList branch1:branch3 && - "$GITP4" clone --dest=. --detect-branches //depot@all && + git p4 clone --dest=. --detect-branches //depot@all && git log --all --graph --decorate --stat && git reset --hard p4/depot/branch1 && test -f file1 &&
@@ -221,13 +221,13 @@ test_expect_success 'git-p4 clone simple branches' ' p4 submit -d "update file2 in branch3" && cd "$git" && git reset --hard p4/depot/branch1 && - "$GITP4" rebase && + git p4 rebase && grep file2_ file2 ) ' # Create a complex branch structure in P4 depot to check if they are correctly -# cloned. The branches are created from older changelists to check if git-p4 is +# cloned. The branches are created from older changelists to check if git p4 is # able to correctly detect them. # The final expected structure is: # `branch1
@@ -248,7 +248,7 @@ test_expect_success 'git-p4 clone simple branches' ' # `- file1 # `- file2 # `- file3 -test_expect_success 'git-p4 add complex branches' ' +test_expect_success 'git p4 add complex branches' ' test_when_finished cleanup_git && test_create_repo "$git" && (
@@ -263,10 +263,10 @@ test_expect_success 'git-p4 add complex branches' ' ) ' -# Configure branches through git-config and clone them. git-p4 will only be able +# Configure branches through git-config and clone them. git p4 will only be able # to clone the original structure if it is able to detect the origin changelist # of each branch. -test_expect_success 'git-p4 clone complex branches' ' +test_expect_success 'git p4 clone complex branches' ' test_when_finished cleanup_git && test_create_repo "$git" && (
@@ -275,7 +275,7 @@ test_expect_success 'git-p4 clone complex branches' ' git config --add git-p4.branchList branch1:branch3 && git config --add git-p4.branchList branch1:branch4 && git config --add git-p4.branchList branch1:branch5 && - "$GITP4" clone --dest=. --detect-branches //depot@all && + git p4 clone --dest=. --detect-branches //depot@all && git log --all --graph --decorate --stat && git reset --hard p4/depot/branch1 && test_path_is_file file1 &&
t/t9802-git-p4-filetype.sh +5 -5
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 p4 filetype tests' +test_description='git p4 filetype tests' . ./lib-git-p4.sh
@@ -37,7 +37,7 @@ test_expect_success 'utf-16 file create' ' test_expect_success 'utf-16 file test' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot@all && + git p4 clone --dest="$git" //depot@all && ( cd "$git" &&
@@ -84,7 +84,7 @@ test_expect_success 'keyword file test' ' build_smush && test_when_finished rm -f k_smush.py ko_smush.py && test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot@all && + git p4 clone --dest="$git" //depot@all && ( cd "$git" &&
@@ -94,7 +94,7 @@ test_expect_success 'keyword file test' ' "$PYTHON_PATH" "$TRASH_DIRECTORY/ko_smush.py" <"$cli/k-text-ko" >cli-k-text-ko-smush && test_cmp cli-k-text-ko-smush k-text-ko && - # utf16, even though p4 expands keywords, git-p4 does not + # utf16, even though p4 expands keywords, git p4 does not # try to undo that test_cmp "$cli/k-utf16-k" k-utf16-k && test_cmp "$cli/k-utf16-ko" k-utf16-ko
@@ -125,7 +125,7 @@ test_expect_success 'ignore apple' ' p4 submit -d appledouble ) && test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot@all && + git p4 clone --dest="$git" //depot@all && ( cd "$git" && test ! -f double.png
t/t9803-git-p4-shell-metachars.sh +6 -6
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 transparency to shell metachars in filenames' +test_description='git p4 transparency to shell metachars in filenames' . ./lib-git-p4.sh
@@ -18,7 +18,7 @@ test_expect_success 'init depot' ' ' test_expect_success 'shell metachars in filenames' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" &&
@@ -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 "$GITP4" submit + P4EDITOR=touch git p4 submit ) && ( cd "$cli" &&
@@ -39,7 +39,7 @@ test_expect_success 'shell metachars in filenames' ' ' test_expect_success 'deleting with shell metachars' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" &&
@@ -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 "$GITP4" submit + P4EDITOR=touch git p4 submit ) && ( cd "$cli" &&
@@ -97,7 +97,7 @@ test_expect_success 'branch with shell char' ' cd "$git" && git config git-p4.branchList main:branch\$3 && - "$GITP4" clone --dest=. --detect-branches //depot@all && + git p4 clone --dest=. --detect-branches //depot@all && git log --all --graph --decorate --stat && git reset --hard p4/depot/branch\$3 && test -f shell_char_branch_file &&
t/t9804-git-p4-label.sh +3 -3
@@ -1,4 +1,4 @@ -test_description='git-p4 p4 label tests' +test_description='git p4 label tests' . ./lib-git-p4.sh
@@ -48,7 +48,7 @@ test_expect_success 'basic p4 labels' ' p4 labels ... && - "$GITP4" clone --dest="$git" --detect-labels //depot@all && + git p4 clone --dest="$git" --detect-labels //depot@all && cd "$git" && git tag &&
@@ -87,7 +87,7 @@ test_expect_failure 'two labels on the same changelist' ' p4 labels ... && - "$GITP4" clone --dest="$git" --detect-labels //depot@all && + git p4 clone --dest="$git" --detect-labels //depot@all && cd "$git" && git tag | grep tag_f1 &&
t/t9805-git-p4-skip-submit-edit.sh +11 -11
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 skipSubmitEdit config variables' +test_description='git p4 skipSubmitEdit config variables' . ./lib-git-p4.sh
@@ -19,33 +19,33 @@ test_expect_success 'init depot' ' # this works because EDITOR is set to : test_expect_success 'no config, unedited, say yes' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" && echo line >>file1 && git commit -a -m "change 2" && - echo y | "$GITP4" submit && + echo y | git p4 submit && p4 changes //depot/... >wc && test_line_count = 2 wc ) ' test_expect_success 'no config, unedited, say no' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" && echo line >>file1 && git commit -a -m "change 3 (not really)" && - printf "bad response\nn\n" | "$GITP4" submit && + printf "bad response\nn\n" | git p4 submit && p4 changes //depot/... >wc && test_line_count = 2 wc ) ' test_expect_success 'skipSubmitEdit' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" &&
@@ -54,21 +54,21 @@ test_expect_success 'skipSubmitEdit' ' git config core.editor /bin/false && echo line >>file1 && git commit -a -m "change 3" && - "$GITP4" submit && + git p4 submit && p4 changes //depot/... >wc && test_line_count = 3 wc ) ' test_expect_success 'skipSubmitEditCheck' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" && git config git-p4.skipSubmitEditCheck true && echo line >>file1 && git commit -a -m "change 4" && - "$GITP4" submit && + git p4 submit && p4 changes //depot/... >wc && test_line_count = 4 wc )
@@ -76,7 +76,7 @@ test_expect_success 'skipSubmitEditCheck' ' # check the normal case, where the template really is edited test_expect_success 'no config, edited' ' - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && test_when_finished cleanup_git && ed="$TRASH_DIRECTORY/ed.sh" && test_when_finished "rm \"$ed\"" &&
@@ -91,7 +91,7 @@ test_expect_success 'no config, edited' ' cd "$git" && echo line >>file1 && git commit -a -m "change 5" && - EDITOR="\"$ed\"" "$GITP4" submit && + EDITOR="\"$ed\"" git p4 submit && p4 changes //depot/... >wc && test_line_count = 5 wc )
t/t9806-git-p4-options.sh +14 -14
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 options' +test_description='git p4 options' . ./lib-git-p4.sh
@@ -24,11 +24,11 @@ test_expect_success 'init depot' ' ' test_expect_success 'clone no --git-dir' ' - test_must_fail "$GITP4" clone --git-dir=xx //depot + test_must_fail git p4 clone --git-dir=xx //depot ' test_expect_success 'clone --branch' ' - "$GITP4" clone --branch=refs/remotes/p4/sb --dest="$git" //depot && + git p4 clone --branch=refs/remotes/p4/sb --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" &&
@@ -42,7 +42,7 @@ test_expect_success 'clone --changesfile' ' cf="$TRASH_DIRECTORY/cf" && test_when_finished "rm \"$cf\"" && printf "1\n3\n" >"$cf" && - "$GITP4" clone --changesfile="$cf" --dest="$git" //depot && + git p4 clone --changesfile="$cf" --dest="$git" //depot && test_when_finished cleanup_git && ( cd "$git" &&
@@ -58,14 +58,14 @@ test_expect_success 'clone --changesfile, @all' ' cf="$TRASH_DIRECTORY/cf" && test_when_finished "rm \"$cf\"" && printf "1\n3\n" >"$cf" && - test_must_fail "$GITP4" clone --changesfile="$cf" --dest="$git" //depot@all + test_must_fail git p4 clone --changesfile="$cf" --dest="$git" //depot@all ' # imports both master and p4/master in refs/heads # requires --import-local on sync to find p4 refs/heads # does not update master on sync, just p4/master test_expect_success 'clone/sync --import-local' ' - "$GITP4" clone --import-local --dest="$git" //depot@1,2 && + git p4 clone --import-local --dest="$git" //depot@1,2 && test_when_finished cleanup_git && ( cd "$git" &&
@@ -73,9 +73,9 @@ test_expect_success 'clone/sync --import-local' ' test_line_count = 2 lines && git log --oneline refs/heads/p4/master >lines && test_line_count = 2 lines && - test_must_fail "$GITP4" sync && + test_must_fail git p4 sync && - "$GITP4" sync --import-local && + git p4 sync --import-local && git log --oneline refs/heads/master >lines && test_line_count = 2 lines && git log --oneline refs/heads/p4/master >lines &&
@@ -84,7 +84,7 @@ test_expect_success 'clone/sync --import-local' ' ' test_expect_success 'clone --max-changes' ' - "$GITP4" clone --dest="$git" --max-changes 2 //depot@all && + git p4 clone --dest="$git" --max-changes 2 //depot@all && test_when_finished cleanup_git && ( cd "$git" &&
@@ -101,7 +101,7 @@ test_expect_success 'clone --keep-path' ' p4 add sub/dir/f4 && p4 submit -d "change 4" ) && - "$GITP4" clone --dest="$git" --keep-path //depot/sub/dir@all && + git p4 clone --dest="$git" --keep-path //depot/sub/dir@all && test_when_finished cleanup_git && ( cd "$git" &&
@@ -109,7 +109,7 @@ test_expect_success 'clone --keep-path' ' test_path_is_file sub/dir/f4 ) && cleanup_git && - "$GITP4" clone --dest="$git" //depot/sub/dir@all && + git p4 clone --dest="$git" //depot/sub/dir@all && ( cd "$git" && test_path_is_file f4 &&
@@ -126,7 +126,7 @@ test_expect_success 'clone --use-client-spec' ' ( # big usage message exec >/dev/null && - test_must_fail "$GITP4" clone --dest="$git" --use-client-spec + test_must_fail git p4 clone --dest="$git" --use-client-spec ) && cli2="$TRASH_DIRECTORY/cli2" && mkdir -p "$cli2" &&
@@ -142,7 +142,7 @@ test_expect_success 'clone --use-client-spec' ' ) && P4CLIENT=client2 && test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" --use-client-spec //depot/... && + git p4 clone --dest="$git" --use-client-spec //depot/... && ( cd "$git" && test_path_is_file bus/dir/f4 &&
@@ -156,7 +156,7 @@ test_expect_success 'clone --use-client-spec' ' cd "$git" && git init && git config git-p4.useClientSpec true && - "$GITP4" sync //depot/... && + git p4 sync //depot/... && git checkout -b master p4/master && test_path_is_file bus/dir/f4 && test_path_is_missing file1
t/t9807-git-p4-submit.sh +11 -11
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 submit' +test_description='git p4 submit' . ./lib-git-p4.sh
@@ -19,7 +19,7 @@ test_expect_success 'init depot' ' test_expect_success 'submit with no client dir' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && ( cd "$git" && echo file2 >file2 &&
@@ -27,20 +27,20 @@ test_expect_success 'submit with no client dir' ' git commit -m "git commit 2" && rm -rf "$cli" && git config git-p4.skipSubmitEdit true && - "$GITP4" submit + git p4 submit ) ' # make two commits, but tell it to apply only from HEAD^ test_expect_success 'submit --origin' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && ( cd "$git" && test_commit "file3" && test_commit "file4" && git config git-p4.skipSubmitEdit true && - "$GITP4" submit --origin=HEAD^ + git p4 submit --origin=HEAD^ ) && ( cd "$cli" &&
@@ -52,30 +52,30 @@ test_expect_success 'submit --origin' ' test_expect_success 'submit with allowSubmit' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && ( cd "$git" && test_commit "file5" && git config git-p4.skipSubmitEdit true && git config git-p4.allowSubmit "nobranch" && - test_must_fail "$GITP4" submit && + test_must_fail git p4 submit && git config git-p4.allowSubmit "nobranch,master" && - "$GITP4" submit + git p4 submit ) ' test_expect_success 'submit with master branch name from argv' ' test_when_finished cleanup_git && - "$GITP4" clone --dest="$git" //depot && + git p4 clone --dest="$git" //depot && ( cd "$git" && test_commit "file6" && git config git-p4.skipSubmitEdit true && - test_must_fail "$GITP4" submit nobranch && + test_must_fail git p4 submit nobranch && git branch otherbranch && git reset --hard HEAD^ && test_commit "file7" && - "$GITP4" submit otherbranch + git p4 submit otherbranch ) && ( cd "$cli" &&
t/t9808-git-p4-chdir.sh +3 -3
@@ -1,6 +1,6 @@ #!/bin/sh -test_description='git-p4 relative chdir' +test_description='git p4 relative chdir' . ./lib-git-p4.sh
@@ -26,7 +26,7 @@ test_expect_success 'P4CONFIG and absolute dir clone' ' ( P4CONFIG=p4config && export P4CONFIG && unset P4PORT P4CLIENT && - "$GITP4" clone --verbose --dest="$git" //depot + git p4 clone --verbose --dest="$git" //depot ) '
@@ -38,7 +38,7 @@ test_expect_success 'P4CONFIG and relative dir clone' ' ( P4CONFIG=p4config && export P4CONFIG && unset P4PORT P4CLIENT && - "$GITP4" clone --verbose --dest="git" //depot + git p4 clone --verbose --dest="git" //depot ) '
t/t9809-git-p4-client-view.sh +32 -32
252 lines not on this page · raw message
Signature · 1 line
1.7.9.192.ga1d4b
Quoted 6 lines · Pete Wyckoff
The git-p4 code is in a single python script down in contrib/fast-import now. I'd like to move it up to the top-level source directory of git to make it easier to build and distribute. Git-p4 already takes advantage of the git infrastructure for documentation and testing, as well as the community support (Junio, many reviewers).
About time this was done. There's still a few oddities around but far fewer than there used to be. I don't know if Junio has some rules on what a command needs before it graduates from contrib though.
<snip>
Quoted 3 lines
a core git package, or as a separate add-on. Getting support for python and git-p4 in msysgit is something I'd like to see happen too.
Not sure about msysgit, but last time I tried on Windows it didn't work at all well.
Quoted 5 lines
While I considered taking this opportunity to split up git-p4 into more modular components across multiple files, it seems best now just to do the script move intact. That effort could come later. If anyone has a strong preference to do this now, we could.
Regards!
Luke
Quoted 11 lines · Luke Diamand
Quoted 6 lines · Pete Wyckoff
The git-p4 code is in a single python script down in contrib/fast-import now. I'd like to move it up to the top-level source directory of git to make it easier to build and distribute. Git-p4 already takes advantage of the git infrastructure for documentation and testing, as well as the community support (Junio, many reviewers).
About time this was done. There's still a few oddities around but far fewer than there used to be. I don't know if Junio has some rules on what a command needs before it graduates from contrib though.
I try not to play a dictator around here. The primary thing I hesitated so far about git-p4 is that it is useless if you live in the open source only world, iow without proprietary software.
[email protected] wrote on Sun, 12 Feb 2012 22:17 -0800:
Quoted 10 lines
Quoted 8 lines · Luke Diamand
Quoted 6 lines · Pete Wyckoff
The git-p4 code is in a single python script down in contrib/fast-import now. I'd like to move it up to the top-level source directory of git to make it easier to build and distribute. Git-p4 already takes advantage of the git infrastructure for documentation and testing, as well as the community support (Junio, many reviewers).
Quoted 7 lines
Quoted 3 lines
About time this was done. There's still a few oddities around but far fewer than there used to be. I don't know if Junio has some rules on what a command needs before it graduates from contrib though.
I try not to play a dictator around here. The primary thing I hesitated so far about git-p4 is that it is useless if you live in the open source only world, iow without proprietary software.
Yes, sad. Git-p4 at least helps people who have no choice but to use p4, e.g., when working in a corporate environment.
It's been a big help developing git-p4 inside the git source tree already. Having git-p4 be an installed component would make it easier on users. "make install" puts the script where it goes. Or better, they get it through their OS distribution.
-- Pete
Quoted 3 lines · Pete Wyckoff
Users install git-p4 currently by copying the git-p4 script from contrib/fast-import into a local or personal bin directory, and setting up an alias for "git p4" to invoke it.
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
Quoted 8 lines · Junio C Hamano
Quoted 3 lines · Pete Wyckoff
Users install git-p4 currently by copying the git-p4 script from contrib/fast-import into a local or personal bin directory, and setting up an alias for "git p4" to invoke it.
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
With recent git versions, this has stopped working. I was told it is a feature that git only looks in exec-path now. Maybe I should not have believed that?
Clemens
Quoted 4 lines · Clemens Buchacher
Quoted 2 lines
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
With recent git versions, this has stopped working.
Erm, I am confused.
$ git --exec-path /home/junio/g/Debian-6.X-x86_64/git-jch/libexec/git-core $ type git-hello bash: type: git-hello: not found $ cat >~/bin/common/git-hello <<EOF #!/bin/sh echo hello world EOF $ chmod +x ~/bin/common/git-hello $ type git-hello git-hello is /home/junio/bin/common/git-hello $ git hello hello world
What am I missing???
[email protected] wrote on Mon, 13 Feb 2012 13:20 -0800:
Quoted 23 lines
Quoted 4 lines · Clemens Buchacher
Quoted 2 lines
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
With recent git versions, this has stopped working.
Erm, I am confused.
$ git --exec-path /home/junio/g/Debian-6.X-x86_64/git-jch/libexec/git-core $ type git-hello bash: type: git-hello: not found $ cat >~/bin/common/git-hello <<EOF #!/bin/sh echo hello world EOF $ chmod +x ~/bin/common/git-hello $ type git-hello git-hello is /home/junio/bin/common/git-hello $ git hello hello world
Quoted 1 line
What am I missing???
Neat. I never knew this worked. That lets me remove quite a few aliases. Apparently this has been possible since the conversion from git.sh to git.c.
I tried to find where in the documentation this is talked about, or where it should go. This doesn't feel like the best spot, though.
------------8<-----------
Quoted 1 line
From
574669898aa891ffe3e785b280ac36177116658eMon Sep 17 00:00:00 2001
From: Pete Wyckoff <[email protected]>
Date: Mon, 13 Feb 2012 18:17:10 -0500
Subject: [PATCH] document git-<command> can be found in PATH
Explain up front to users that arbitrary git "commands" can be found anywhere in the PATH. For example, ~/bin/git-hello will be invoked by "git hello".
--- Documentation/git.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Documentation/git.txt +2 -0
@@ -30,6 +30,8 @@ introduction. The '<command>' is either a name of a Git command (see below) or an alias as defined in the configuration file (see linkgit:git-config[1]). +A '<command>' can also refer to an executable with the name git-'<command>' +anywhere in your PATH. Formatted and hyperlinked version of the latest git documentation can be viewed at
Signature · 1 line
1.7.9.193.g1d4a5.dirty
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Clemens Buchacher
Quoted 2 lines
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
With recent git versions, this has stopped working.
Erm, I am confused.
Looks like in my case it did not work because I had a PATH entry with a '~' in it. It probably stopped working for me because I moved some executables around.
It's not a regression (I just tried with 1.6.0 and I get the same result). And dash does not apply tilde expansion to PATH either. So maybe it's not even a bug.
Quoted 8 lines · Clemens Buchacher
Quoted 7 lines · Junio C Hamano
Quoted 4 lines · Clemens Buchacher
Quoted 2 lines
Erm,... do you really need the alias if you add git-p4 in a directory on your $PATH?
With recent git versions, this has stopped working.
Quoted 8 lines
Quoted 1 line
Erm, I am confused.
Looks like in my case it did not work because I had a PATH entry with a '~' in it. It probably stopped working for me because I moved some executables around.
It's not a regression (I just tried with 1.6.0 and I get the same result). And dash does not apply tilde expansion to PATH either.
I do not think tilde in $PATH is expanded by exec*p family to begin with, so it is not "dash" but POSIX, I would think. It is bash that is harming other programs, by trying to be more helpful, encouraging this user mistake to add ~ literally on the PATH.
You can see it in action below.
$ cd /var/tmp $ cat >execlptest.c <<\EOF #include <unistd.h> #include <errno.h> #include <string.h> #include <stdio.h>
int main(int ac, const char **av)
{
int status = execlp("xyzzy", "xyzzy", NULL);
printf("execlp returned %d (errno = %d, %s)\n",
status, errno, strerror(errno));
return 0;
}
EOF
$ gcc -o execlptest execlptest.c
$ cat >/home/junio/junk/xyzzy <<\EOF
#!/bin/sh
exec lp test
EOF
$ chmod +x /home/junio/junk/xyzzy
$ PATH=/usr/bin:/bin
$ export PATH
$ /var/tmp/execlptest
execlp returned -1 (errno = 2, No such file or directory)
: notice the sq pair around the value on the next line
$ PATH='/usr/bin:/bin:~/junk'; export PATH; echo "$PATH"
/usr/bin:/bin:~/junk
$ /var/tmp/execlptest
execlp returned -1 (errno = 2, No such file or directory)
$ xyzzy
exec lp test
$ echo $BASH_VERSION
4.1.5(1)-releaseQuoted 4 lines · Junio C Hamano
I do not think tilde in $PATH is expanded by exec*p family to begin with, so it is not "dash" but POSIX, I would think. It is bash that is harming other programs, by trying to be more helpful, encouraging this user mistake to add ~ literally on the PATH.
Hmm. There is an interesting ramification for run-command's "use_shell" optimization. Typically, git runs all of the user-provided commands given to it via the shell. But if the command contains no meta-characters, we skip the shell invocation as an optimization, since the shell should simply be word-splitting and calling exec, and the behavior will be identical.
But if your shell handles PATH entries differently, then there is a difference. I.e., doing this:
mkdir junk
ln -s /usr/bin/vi junk/my-editor
export PATH=~/junk:$PATH
export GIT_EDITOR=my-editor
git commit
might work without the optimization, but not with.
We could check PATH and disable the optimization in that case, but I suspect it is not worth it, as:
1. People who put a literal "~" in their PATH get what they deserve
anyway. :)
2. We explicitly run "sh" in such situations, not SHELL_PATH. Even if "sh" is bash, I believe it should look at its own argv[0] and put itself into a more POSIX-y mode (but I didn't test).
-Peff
Quoted 4 lines · Jeff King
2. We explicitly run "sh" in such situations, not
SHELL_PATH. Even if "sh" is bash, I believe it should look at its own argv[0] and put itself into a more POSIX-y mode (but I didn't test).
Indeed it does.
Quoted 11 lines · Jeff King
Quoted 4 lines · Junio C Hamano
I do not think tilde in $PATH is expanded by exec*p family to begin with, so it is not "dash" but POSIX, I would think. It is bash that is harming other programs, by trying to be more helpful, encouraging this user mistake to add ~ literally on the PATH.
Hmm. There is an interesting ramification for run-command's "
use_shell" optimization....
But if your shell handles PATH entries differently, then there is a difference.
Yeah, I agree; that is exactly what I meant by bash harming users by trying to be more helpful.