Ben Hymers
Ben Hymers

Reputation: 26536

Git-p4 on a Perforce stream

I think I probably know the answer already, but perhaps someone can either help, or give a knowledgeable "no".

I've been using git-p4 to work on a Perforce depot (syncing, editing, submitting) for a long time, on the main branch. I now want to work in a stream. I tried using all the git-p4 options for branches (the docs don't mention streams but I'm trying to treat them the same). I also tried just doing a git p4 clone //depot/streamname but that tells me No changes to import! and quits instantly.

I found two projects that are forks of git-p4 to support streams, each a few years old, and each unable to submit back to the depot, so they're no good.

I can't change to use branches instead of streams, as the rest of the team want to use streams, and supporting my unusual workflow isn't a good reason to change (even if I am in charge!).

Is there really no option available other than actually using Perforce here? I hate it with a passion, and I would much much rather use git (or anything else!).

Upvotes: 2

Views: 1134

Answers (2)

Bob Lloyd
Bob Lloyd

Reputation: 21

My use-case was a little different, but very similar to the original question. My use-case was basically to take commits made to specific files in Perforce and push them to a Git repo. I attempted to use streams for this, to narrow the scope of the depot, but that didn't seem to work either.

This isn't as graceful, but I did workaround this issue. The root cause is that the git-p4 plugin uses the p4 files command to get files from the depot, and that command doesn't work on streams, only depot paths.

I worked around this by first creating a client that filtered the depot based on what my stream would have been. This isn't a 1:1 of what a stream would do, but it was functional for my use case. I then set the view of the client to mimic what my stream would do:

$ p4 client -o git_repo | sed "s#//depot/... //git-repo/...#//depot/main/test/gitfiles/....json //git-repo/....json#g" | p4 client -i
$ git p4 clone --use-client-spec //depot/main/test/gitfiles/...

This seemed to do the trick, and got me just the files I wanted, and I was able to move forward. Like I said, it's not graceful, and it's not a 1:1 of the stream functionality, but it might help someone struggling with how to use the git-p4 plugin.

https://www.perforce.com/manuals/cmdref/Content/CmdRef/p4_files.html

Upvotes: 0

P4Jen
P4Jen

Reputation: 1023

Not sure about git-p4, but you could use Git Fusion to enable you to work with the streams.

This is not a client side product like Git-P4, so if you have multiple Git Users who want to work with streams of depot paths, they can take advantage of it.

More details about using it with streams are here: https://www.perforce.com/perforce/doc.current/manuals/git-fusion/#Git-Fusion/section_j4q_gtx_nm.html%3FTocPath%3DSetting%2520up%2520repos%7C_____11

Upvotes: 1

Related Questions