tags:

views:

106

answers:

1

My p4 repository has a structure similar to:

//depot/project/branch1
//depot/project/branch2
//depot/project/branch3
... etc

However, when I use git-p4 to clone "project", all 3 branches are not considered as branches and all get cloned into the single master branch.

This is how I'm invoking git-p4:

git-p4 clone --detect-branches //depot/project

I was expecting git-p4 to create a git database for "project" with three branches, and the root of the project would be mapped to the portion of the path after the branch name (for example: if //depot/project/branch1 has a subdirectory called "lib" (//depot/project/branch1/lib) then my local file system should be something like /git_project/lib with 3 git branches).

Is what I'm expecting wrong? Am I invoking git-p4 incorrectly?

A: 

If you look at git-p4 code (also originally here), you see:

if self.detectBranches:
  branches = self.splitFilesIntoBranches(description)
  for branch in branches.keys():
    ## HACK  --hwn
    branchPrefix = self.depotPaths[0] + branch + "/"

with splitFilesIntoBranches exploring the p4 repo for branches.

So maybe git-p4 clone //depot/project@all --detect-branches would be fine (with the @all as in this SO answer, and the --detect-branches option after the repo path)?

That being said, if the script is not smart enough to manage that, may be a simpler solution is to run it 3 times, one per branch and import the result in one Git repo.

VonC
I gave the "@all" a try. However, perhaps it's not working because of parenthesis within other parts of the depot? The branch mentioned in the output below does not reside within the part of the depot I'm trying to clone (it is higher up). (I've masked out project names and user names with "PROJECT" and "USER")
Michael Brennan
Initialized empty Git repository in /cygdrive/c/projects/PROJECT/.git//bin/sh: -c: line 0: syntax error near unexpected token `('/bin/sh: -c: line 0: `p4 -G branch -o dev_OtherProject(ASP.Net)_USER'Importing revision 181332 (0%) Importing new branch PROJECT/Main/dotNet Resuming with change 181332fatal: Invalid ref name or SHA1 expression: refs/remotes/p4/PROJECT/Delivery/dotNetfast-import: dumping crash report to .git/fast_import_crash_1832Wouldn't running it 3 times, one per branch, create 3 git repositories? I thought git-p4 clone always made a new repository.
Michael Brennan