thisisdog
thisisdog

Reputation: 948

How do I get the perforce root directory from command line?

How do I get the perforce root directory from the command line? I've tried p4 info but I'd rather not have to filter this to get at the root. I'm sure there's a way, but I couldn't find it.

Is there a way to get the root in a context sensitive way? For example if I have two workspaces with a hierarchy like A/.../script vs B/.../script I'd expect that the script would return either A or B depending on where it was run from.

Upvotes: 14

Views: 17248

Answers (3)

Franklin Yu
Franklin Yu

Reputation: 9938

From OP’s description, they probably want p4 where. For example, if the client root is /perforce/projects, then

p4 where //depot/project-1/module-2

will give /perforce/projects/project-1/module-2. Credit from Bryan’s comment.

Upvotes: 1

parag_88
parag_88

Reputation: 56

For older versions before 2014.1 use the command

p4 info | grep 'Client root:' | cut -d ' ' -f 3-

Upvotes: 1

Matt
Matt

Reputation: 4850

If you want your client root in one command run:

p4 -F %clientRoot% -ztag info

You will need the 2014.1 later version of p4 to use this flag.

Upvotes: 17

Related Questions