1

The goal is to set the following svn property in a .bat file:

Properties on 'logs':
  svn:ignore
    *

The command should be svn propset svn:ignore * logs but the asterisk needs to be escaped somehow. I don't want to add the current list of files I really want to ignore all files in the logs directory without ignoring the logs directory itself.

However I can't figure out how to properly escape the asterisk to get a literal asterisk in the svn property.

  • '*' results in the string '*' (with the quotes) to be set as the value which does not ignore any files at all
  • "*" or ^* still expands the asterisk causing svn to set a property (with the name of a file in the current directory) on all directories.
  • \* or "\*" causes SVN to look for a (or all?) files in the root of the C: drive for some reason
  • %* results in a value of %*

I can't think of any other way to escape a character in a bat file.

Bram
  • 819
  • 1
  • 9
  • 24
  • Don't know for the specific mix of windows and svn, sorry. more things to try \052 - the octal for *. Some use of -- to ensure the argument is not treated as a filename - like filenames and branches are distinguished. – Gem Taylor Feb 18 '20 at 11:09
  • Maybe [How do I ignore files in Subversion?](https://stackoverflow.com/questions/86049/) – JosefZ Feb 18 '20 at 11:11
  • @JosefZ Doubtful, as that is more to do with auto-commit. But worth mentioning :-) – Gem Taylor Feb 18 '20 at 11:23
  • @JosefZ: that is what I am trying to do here but I need to pass a literal asterisk instead of a filename. Note that e.g. `"*.txt"` has the desired effect but not `"*"` – Bram Feb 18 '20 at 12:51
  • Sorry I can't comprehend meaning of *literal asterisk* in `svn` context. If `"*.txt"` works then try `"*.*"`… – JosefZ Feb 18 '20 at 15:43
  • @JosefZ: `svn propset svn:ignore "*.*" logs` also adds the name of file(s) from the current directory to the svn:ignore proerties of all directories. I must have missed something earlier because I cannot reproduce getting "*.txt"to work. Apologies for the confusion. – Bram Feb 18 '20 at 16:46

2 Answers2

1

I've come across the same problem you described.
I am on Windows (using TortoiseSVN) and I needed to set a rule in svn:ignore so that all files belonging to certain directories would be ignored.
I used the following command:

svn propset svn:ignore '*' dirname

And then In File Explorer, went to dirname and then: Right Click>Properties>Subversion>Properties...
I saw that the value set for property svn:ignore was '*' which didn't worked at all.
I also tried different combinations of asterisks (as you said) but without success.
Then, I tried to use a file-based approach: I created a simple svn.txt file with just one line:

*

Then, after execution of the command:

svn propset svn:ignore -F svn.text dirname

I went to the same menu described before, and now the svn:ignore property for the folder correctly shows the value: *.
Of course, after committing the svn:ignore property modification, every file which is put under dirname is correctly ignored.

aldoalpha
  • 163
  • 10
0

I can think of two other ways to try but sadly I cannot verify them myself without further ado...

  1. Maybe it is a double caret ^^*

  2. You can try to fix it by passing the asterisk as variable inside of your batch file. Example:

@echo off
[...]
set asterisk=*
call svn propset svn:ignore %asterisk% logs
[...]

This should prevent the expansion of the asterisk since the variable %asterisk% must already be expanded and there is no second expansion pass unless you activated ENABLEDELAYEDEXPANSION somewhere in your command session (with cmd.exe /V:ON or SETLOCAL).

Remark to your attempt with \*: This behavior seems totally legit to me, since \ stands for the root directory of the current drive in UNIX/LINUX. And svn interprets wildcards as implemented in fnmatch on such systems [see redbook on svn:ignore]. This essentially works in Windows also this way. cd \ will bring you to the first level of the drive and a dir \*.* will list the files on the first level no matter where you are in the sub directories.

Hope this helps. Good luck with your project :)

GuestCoder
  • 71
  • 1
  • 2