Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Perforce on Unix, how do you add a directory that is a symbolic link?

Tags:

perforce

p4v

I have created a symbolic link directory in Unix and I would like to add it to perforce.

(this question relates to symlinks on Unix. Windows symbolic links can have very different behaviour from Unix.)

  • ../blah/dir1 is the source directory, which contains files that are already in Perforce
  • dir2 is the symlink to the source directory that I want to check in
ln -s ../blah/dir1 dir2

If I right-click on "dir2" in the p4v GUI, it will add every file under ../blah/dir1 as a new file (even if these files are already in Perforce) and fubar everything.

If I do a "p4 add dir2" from the command line, it will add every file under ../blah/dir1 as a new file (even if these files are already in Perforce) and fubar everything.

What is the correct syntax?

like image 463
engtech Avatar asked Feb 07 '11 15:02

engtech


People also ask

How do you create a symbolic link to a directory in Unix?

Ln Command to Create Symbolic Links Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to.

Can you make a symbolic link to a directory?

Symlink, also known as a symbolic link in Linux, creates a link to a file or a directory for easier access. To put it in another way, symlinks are links that points to another file or folder in your system, quite similar to the shortcuts in Windows.

How does symbolic links work in Unix?

A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.

How do I copy a directory symbolic link in Linux?

Use cp -P (capital P) to never traverse any symbolic link and copy the symbolic link instead. This can be combined with other options such as -R to copy a directory hierarchy — cp -RL traverses all symbolic links to directories, cp -RP copies all symbolic links as such.


2 Answers

Perforce is able to detect symlinks itself and no special options need to be added in the command. Just regular command like following suffices the need

p4 add <sym link filename> 
like image 115
Varun Bhatia Avatar answered Oct 05 '22 15:10

Varun Bhatia


Add the symbolic link from the shell using the -t option to set the symlink type.

p4 add -t symlink dir2
like image 22
engtech Avatar answered Oct 05 '22 14:10

engtech