Unison's "ignorenot" parameter does not work - unison

I have the following instruction in my unison profile:
ignore = Path node_modules
ignorenot = Path node_modules/scaffold
Easy enough, right? Except that it doesn't work. It keeps on ignoring the node_modules/scaffold folder.
I even tried it with a regex:
ignorenot = Regex /node_modules/scaffold/.*
So what's going on here? I'm running unison 2.48.4

Apparently, when you ignore a directory, there is no way to un-ignore a descendant.
What you should do instead is ignore the directory's contents, and then un-ignore a specific child. This will work for example:
ignore = Path node_modules/*
ignorenot = Path node_modules/scaffold

Related

file system watcher doesn't work when used full filename as filter

I'm trying setup a file watcher for one specific file C:\test.json via workspace.createFileSystemWatcher
This is the code I use:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern("C:\\", "test.json"));
watcher.onDidChange(uri => console.log("change", uri));
watcher.onDidCreate(uri => console.log("create", uri));
watcher.onDidDelete(uri => console.log("delete", uri));
For some reason events are not triggered, unless I replace filter test.json with *.json - then it works just fine.
Any ideas why complete filename doesn't work?
I see your question(s) ;>} on github. I'll post there as well.
It is interesting that this works:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file("C:\\Testing"), "test.json"));
Note that test.json is in a folder Testing.
This does not work - when test.json is at the root of C:
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file("C:\\"), "test.json"));
So it looks like either vscode.Uri.file("C:\\") doesn't work properly at the drive root level or vscode.RelativePattern() doesn't work properly at the drive root level.
As we discussed on github (see API: createFileSystemWatcher() doesn't work when filter set to a specific file), the problem appears to be the trailing slash in C:\\. Since relative patterns like new vscode.RelativePattern(vscode.Uri.file("C:\\Testing"), "test.json") work and patterns like new vscode.RelativePattern(vscode.Uri.file("C:\\Testing\\"), "test.json") do not work.
But a backslash is required for a drive root level designation:
No, it doesn't. But it's because drive path requires trailing slash,
otherwise it's treated as relative path instead:
Use a backslash as required as part of volume names, for example, the
"C:" in "C:\path\file" or the "\server\share" in
"\server\share\path\file" for Universal Naming Convention (UNC)
names.
from your comment at https://github.com/microsoft/vscode/issues/162498#issuecomment-1295628237
so it does seem that vscode.RelativePattern() will not work at the drive root level because of the trailing slash (but the trailing slash is necessary and a simple vscode.workspace.createFileSystemWatcher(vscode.Uri.file("C:\\test.json")); does not work either).
We should update this answer with however the github issue is resolved - can your original new vscode.RelativePattern(vscode.Uri.file("C:\\"), "test.json") be made to work.

Exclude everything under folder *but* certain filetypes (at any nesting level)

Using version 2.51.2 (ocaml 4.04.0).
Trying to exclude a folder at the root (called build), but include any files ending in .err and .out at any depth underneath it.
Structure looks like
build/a/b/c/test/1.0/test.out
build/a/d/whatever/2.0/whatever.err
build/a/test.err
I tried
ignore = Path build
ignorenot = Regex·arnold-build\/(.*).(err|out)⬎
... this coughs up a "Malformed pattern" error. Also tried just to sync an entire subdir explicitly with this:
ignorenot = Path a/b/c/test/
But the "test" folder still doesn't sync.
How do I get just all the .err/.out files to sync, while ignoring everything else?
Unison's "ignorenot" preference is somewhat counterintuitive
https://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#ignore
If a directory is ignored, all its descendents are ignored too, everything below that tree will be ignored and not checked anymore.
Ignorenot only blocks ignores at the same level, so you must cover all the tree, up to the ignorenot you want to apply, with pairs of ignore and ignorenot. For example, in the case you cited above, if you want to ignore everything in build, except build/a/b/c/test, build/a/d/whatever, and everything inside them, your preferences profile should include:
ignore = Path build/*
ignorenot = Path build/a
ignore = Path build/a/*
ignorenot = Path build/a/b
ignorenot = Path build/a/d
ignore = Path build/a/b/*
ignore = Path build/a/d/*
ignorenot = Path build/a/b/c
ignorenot = Path build/a/d/whatever
ignore = Path build/a/b/c/*
ignorenot = Path build/a/b/c/test
This way Unison will ignore everything in the build folder, except for build/a/d/whatever and build/a/b/c/test

Why CMake doubles the path?

I am using UseLATEX, with commands
set(MainFile "Demo.tex")
set(InputFiles ${MainFile} Main.tex OtherFiles.tex)
then later I use it like
ADD_LATEX_DOCUMENT( ${MyFileName}
INPUTS "${InputFiles}" )
and everything works fine. If I change to
file(GLOB_RECURSE InputFiles src/*.tex)
then I receive messages with a list of files I wanted to put into InputFiles,
but preceeded with
"Could not find input file ${CMAKE_SOURCE_DIR}/${CMAKE_SOURCE_DIR}/OtherFiles.tex"
and of course that path does not exist. What is wrong?
Turning my comment into answer
Haven't worked with ADD_LATEX_DOCUMENT(), but it seems it appends the current directory itself and would need relative paths.
Just change your file(GLOB ...) command to output relative paths:
file(GLOB_RECURSE InputFiles RELATIVE "${CMAKE_SOURCE_DIR}" src/*.tex)

How do I tell if a file is contained in a directory?

What's the right way to tell if a file is contained within a given directory, or a subdirectory thereof?
I want something like:
if ([directoryPath contains: filePath]) {
// file is in directory, or in a subdirectory of directory.
}
Example:
ContainerPath: /Users/sfisher/Library/Application Support/iPhone Simulator/5.1/Applications/89A57CCB-250D-4D10-B913-EA456004B431/AppName.app
Not matching: /Users/sfisher/Library/Application Support/iPhone Simulator/5.1/Applications/89A57CCB-250D-4D10-B913-EA456004B431/Documents/db/Sample Data
Matching: /Users/sfisher/Library/Application Support/iPhone Simulator/5.1/Applications/89A57CCB-250D-4D10-B913-EA456004B431/AppName.app/Samples/1
I could convert everything to strings (including appending a "/" to the container directory) and check for a string match, but it seems there should be a built-in method for this.
In principle, your underlying desire is surprising impossible. A given file path may include through symbolic or hard links, making "containment" a very complicated question. These kinds of links are uncommon in iOS, but iOS is still Unix, and in Unix such things are legal.
So your real question is actually whether one path specifier (string) is contained in another. So checking the paths as strings is the correct approach.
I think a simple string match is the right way to do it:
if (![directoryPath hasSuffix:#"/"]) directoryPath = [directoryPath stringByAppendingString:#"/"];
if ([filePath hasPrefix:directoryPath]) {
// ...
}
Note that this doesn't deal with complications introduced by symlinks, or with relative paths.

msbuild -p:outputdir=c:\mydir being ignored

I'm running msbuild from the command line with the following:
msbuild mysolution.sln -p:outputdir=c:\mydir
When I run this, the outputdir is being ignored and the default specified in the csproj file is being used.
The MSDN doc for this tool says that I should be able to override the build directory using this parameter. What am I doing wrong?
You should use OutputPath and more important you should use the right syntax :
msbuild mysolution.sln /p:OutputPath=c:\mydir
Note that OutputPath is preferred over OutDir. The documentation used to be wrong about this, but I see that they've finally fixed it.
Beyond that, it's difficult to say exactly what the problem is, since you didn't show the exact path that you're passing as a parameter. There are two possible problems that I can imagine:
The OutputPath option specifies the path to the output directory relative to the project directory. That means you can't set it to a global path like C:\mydir. I assume it is unable to find the path you specified, and so it defaults to the one specified in your project file.
If the path that you're actually specifying as a parameter contains spaces, the command is likely to fail. I believe you need to wrap the path in quotes and append an extra backslash to the end of the path string.
I believe you should be using OutputPath.