Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Perforce ignore file syntax differ from gitignore syntax?

What fraction of .gitignore file syntax Perforce was able to implement?

The Perforce documentation for P4IGNORE shows basic ignores and un-ignores with patterns: http://www.perforce.com/perforce/r12.1/manuals/cmdref/env.P4IGNORE.html

As best I can tell, Perforce does not support:

# Ignore file.txt, but not subdir/file.txt
/file.txt

# Ignore directories named foo, but not files named foo
foo/

Are there any other differences in the ignore file processing?

like image 478
Ben Martin Avatar asked Aug 14 '13 19:08

Ben Martin


People also ask

How do I ignore a text file in Gitignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

What is the purpose of a Git ignore file?

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached.

Why is file in Gitignore not ignored?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.

Is Gitignore ignored?

Some times, even if you haven't added some files to the repository, git seems to monitor them even after you add them to the . gitignore file. This is a caching issue that can occur and to fix it, you need to clear your cache.


2 Answers

Also, as far as I can tell (the P4IGNORE mechanism is incompletely documented):

P4IGNORE seems to have no way to escape # (the hash sign, a character that I really want to have in P4IGNORE since EMACS creates backup files named #filename#.

It looks like # in P4IGNORE is a comment character, but only if the first character on a line.

So

*#*

seems to ignore all files with # in them. i.e. it seems to be the equivalent of Perl regexp qr{^.#.$}.

This is a bit scary, since if # was the normal comment character in most systems, the pattern # would be a * followed by a comment #*, and would ignore all files. But it seems to work.

(Git's handling of # is a bit special as well.)

P4IGNORE does not seem to handle patterns such as

# matches any single character filename    
?

a single character

[seq] 

matches any character in set

etc.,

so to ignore a filename with a single letter like 'a', I had to list all 62 possibilities [a-zA-Z0-9]. (I have a habit of creating tmp files like 'a', 'b' ...).

I have not yet grokked Perforce's handling of periods in filenames.
I know for sure that to ignore a filename like '.#more-crap' you have to do

.#*

in addition to

*#*

but this may just be normal dot file hiding.

However, there have been several cases where a pattern like

tmp-*

was not catching 'tmp-foo.txt'

that I fixed by adding

tmp-*.*

(Note: most recently I have been using bzr and hg, with fully powerful regexps, so may be looking for stuff more powerful than git provides)

like image 101
Krazy Glew Avatar answered Sep 26 '22 00:09

Krazy Glew


I had a similar question and then found this article where I learned that Perforce does accept .gitignore files.

In fact, you can specify more than one filename in P4IGNORE. In reality, my P4IGNORE looks like this (this is a new feature in 2015.2):

P4IGNORE=$home/.p4ignore;.gitignore;.p4ignore;

like image 43
J Hache Avatar answered Sep 25 '22 00:09

J Hache