2

Using libgit2 I am trying to run git_checkout_tree on all files in my working tree while skipping some specific files. Filling the git_checkout_options checkout_opts like so

char* p[2]= {"*", "!myFile.dat"};
checkout_opts.paths.strings = p;
checkout_opts.paths.count = 2;

does still checkout myFile.dat (which is located in the repository root). I tried to stick to the .gitignore pattern syntax. I've compiled libgit2 and tried to get my head around the code base. I see that wildmatch.c defines a NEGATE_CLASS '!' and a NEGATE_CLASS '^'. Using ^myFile.dat doesn't work, unfortunately. Is pattern negation not supported in libgit2 or am I doing something wrong?

Sc4v
  • 348
  • 2
  • 10

1 Answers1

3

From issue 2263, a sparse-checkout is not yet supported with libgit2.

As a result, a git_checkout_tree might not support the recent wildmatch (replacing fnmatch in PR 5110 a year ago, June 2019).
No negative path is tested in tests/checkout/tree.c.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Indeed, there's no negation support in the paths for `checkout_opts`. This is by-design, though I can imagine that this could change to support sparse checkout style paths. – Edward Thomson Sep 15 '20 at 10:33
  • @EdwardThomson I can understand that, especially considering Git 2.28 revealed negative paths were broken (https://stackoverflow.com/a/21079437/6309) – VonC Sep 15 '20 at 12:34