How to escape @ characters in Subversion managed file names?

后端 未结 11 1313
不知归路
不知归路 2020-11-28 01:49

For many Subversion operations, appending the \'@\' symbol to the end of a file or URL argument allows you to target a specific revision of that file. For example, \"svn in

相关标签:
11条回答
  • From the SVN book (emphasis added):

    The perceptive reader is probably wondering at this point whether the peg revision syntax causes problems for working copy paths or URLs that actually have at signs in them. After all, how does svn know whether news@11 is the name of a directory in my tree or just a syntax for “revision 11 of news”? Thankfully, while svn will always assume the latter, there is a trivial workaround. You need only append an at sign to the end of the path, such as news@11@. svn cares only about the last at sign in the argument, and it is not considered illegal to omit a literal peg revision specifier after that at sign. This workaround even applies to paths that end in an at sign—you would use filename@@ to talk about a file named filename@.

    0 讨论(0)
  • 2020-11-28 01:57

    Solution for adding multiple files in different sub-folders:

    for file in $(find ./ -type f -name "*@*.png"); do svn add $file@; done
    

    Just replace the "png" in "@.png" to the kind of files you want to add.

    0 讨论(0)
  • 2020-11-28 01:57

    to add the following file : image@2x.png do the following: svn add image\@2x.png@

    0 讨论(0)
  • 2020-11-28 02:07

    I had the problem today with filenames generated from email addresses (not a very good idea!).

    Solution, using printf options of find, and shell expansion

     svn add  $(find . -name "*@*.png" -printf "%p@ ")
    
    0 讨论(0)
  • 2020-11-28 02:10

    Simply add

    @

    at the of the file you need to use, no matter what SVN command it is, e.g.:

    file@2x.jpg
    

    to

    file@2x.jpg@
    
    0 讨论(0)
  • 2020-11-28 02:12

    The original answer is correct, but perhaps not explicit enough. The particular unix command line options are as follows:

    svn info 'image@2x.png@'
    

    or

    svn info "image@2x.png@"
    

    or

    svn info image\@2x.png\@
    

    I just tested all three.

    0 讨论(0)
提交回复
热议问题