What does git mean equivalent to p4 "..." pattern?

When I used p4 (Perforce), I often used the "..." pattern, which is similar to "*", except that it crosses the file system hierarchy levels (that is: it also matches slashes). This was convenient for working with source files, which were several levels down the directory tree.

For instance:

p4 diff foo/.../*.py 

This will be the "p4 diff" of all Python files under the "foo" subtree.

Is there an easy way to get the same result with git? Now I have to do something like this:

 git diff $(find foo -name '*.py') 

which is not so convenient.

+4
source share
1 answer

git usually relies on the path extension provided by the shell, and this is true since path extension is not exactly the task of a version control system. Therefore, you should look at your choice wrapper to see if it supports something like path extension ... If you use bash, you can set the globstar option

 shopt -s globstar 

and then you can use a double asterisk to get the extension you need:

 git diff foo/**/*.py 

Please note that based on my tests, a double asterisk does not match partial path components. In other words, it should be followed and preceded by a slash for this pattern to match something like foo/bar/blah/baz.py If you try to write foo/ba**/*.py , it will match the same as foo/ba*/*.py .

+4
source

Source: https://habr.com/ru/post/1380667/


All Articles