67

I see it is possible to view a list of properties set on every directory within an SVN repository using proplist and the -R flag (recursive) and -v flag (verbose):

svn proplist -Rv

This shows me all properties, such as svn:mime-type or svn:executable. I'm looking to filter this to just svn:ignore properties. I'm sure there is some way to pipe the result from this command through a shell command that would only show me the lines I'm interested in, but I can't figure out how to do it. As an example of the type of thing that would be most useful is some type of command like this (but this one doesn't work!).

svn proplist -Rv | grep "^  svn:ignore" | awk "{print \$1}"

I just don't know enough about shell commands like grep and awk to make this work for me. This just shows "svn:ignore" over and over again, but it doesn't print out the directory path or contents of the svn:ignore property. Here is an example of the output from "svn proplist -Rv" that I'd like to grab, where 'cache' is the path and '*' is the value of the property.

Properties on 'cache':
  svn:ignore
    *

How can the above command be made to work and/or is there a better way to view all svn:ignore properties in my repository?

4
  • 1
    A couple of tips on awk: it's common to use single quotes for the inline script, so you don't have to escape the $, and it can actually do the regular expression matching for you too: `awk '/pattern/ {print $1}'. I don't know svn - is the data you're trying to see on the same line as 'svn:ignore'? If not, your problem is a little trickier. If so, do you just want the second field?
    – Cascabel
    Aug 9, 2009 at 21:05
  • The data I'm trying to see unfortunately is not on the same line as svn:ignore. It's the content directly above and directly below it. In the example in my question, I'd like to grab the path "cache" and also the "*", as the * signifies everything in "cache" is being ignored. Thanks for your tips on awk. Aug 9, 2009 at 21:08
  • My bad - I was looking for the sample output and somehow skimmed right over it.
    – Cascabel
    Aug 9, 2009 at 21:11
  • Your original command line was almost OK it needed only a small addition (and some removal :))) like this: svn proplist -Rv| grep -A2 svn:ignore This would list the next two lines from the input: ` svn:ignore autosave ` If you would like to see the dir name on which the prop is set: svn proplist -Rv| grep -A2 -B1 svn:ignore this outputs something like: Properties on 'foo/bar/baz': svn:ignore autosave
    – Tylla
    Jan 3, 2017 at 15:52

2 Answers 2

137
svn pg -R svn:ignore .

...with pg being a shorthand notation for propget, so this is equal to...

svn propget -R svn:ignore .
2
  • 11
    @Ram - That doesn't work recursively. Git, like SVN, allows you to apply ignore patterns to subdirectories instead of just a root .gitignore. You want cat `find -name .gitignore` | less or find -name .gitignore -exec cat {} \; | less, neither as pretty as using a -R switch IMO. (That said, I enjoyed your blog post. I'm learning Git from Subversion, it's interesting to get a look at the other side of the fence!) Aug 30, 2011 at 13:21
  • 2
    git svn show-ignore | grep -ve '^#\|^[[:space:]]*$' > .gitignore Dec 13, 2014 at 3:18
3

Sorry to jump in here late, but there is a simple solution here.

Just grep.

svn proplist -Rv | grep svn:ignore -B1 -A1

Show one line before, and one line after the match.

1
  • Elegant! And if you want to suppress the svn:ignore lines, just add another pipe to grep -v svn:ignore May 30, 2019 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.