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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
stereoscott
  • 13,309
  • 4
  • 33
  • 34
  • 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 09 '09 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. – stereoscott Aug 09 '09 at 21:08
  • My bad - I was looking for the sample output and somehow skimmed right over it. – Cascabel Aug 09 '09 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 03 '17 at 15:52

2 Answers2

137
svn pg -R svn:ignore .

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

svn propget -R svn:ignore .
zb226
  • 9,586
  • 6
  • 49
  • 79
Martin v. Löwis
  • 124,830
  • 17
  • 198
  • 235
  • 11
    @Ram - That doesn't work recursively. Git, like SVN, allows you to [apply ignore patterns to subdirectories](http://www.kernel.org/pub/software/scm/git/docs/gitignore.html#_description) 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](http://blog.garlicsim.org/post/9583964892/a-git-users-first-and-hopefully-last-foray-into). I'm learning Git from Subversion, it's interesting to get a look at the other side of the fence!) – Kevin Vermeer Aug 30 '11 at 13:21
  • 2
    `git svn show-ignore | grep -ve '^#\|^[[:space:]]*$' > .gitignore` – Denis Denisov Dec 13 '14 at 03: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.

kayess
  • 3,384
  • 9
  • 28
  • 45