2

I want to retrieve a list of paths, permissions, and content hashes for files for revision in a set of paths, excluding some paths.

git ls-tree seems perfect. For example, in the Git repo,

$ git ls-tree -r v2.2.2 -- Documentation ':!Documentation/RelNotes'
100644 blob ddb030137d54ef3fb0ee01d973ec5cee4bb2b2b3    Documentation/.gitattributes
100644 blob 2c8b2d612ee0d6c1f687bfa062bb7fe6471d9280    Documentation/.gitignore
100644 blob 894546dd75416fcf09542096a67b2f22a7d0de7a    Documentation/CodingGuidelines
100644 blob 2f6b6aabd74a24abdb3ac189118095fcee19f8d2    Documentation/Makefile
100644 blob fa71b5f0b62f43483d02c24d809e6282fa49576a    Documentation/SubmittingPatches
100644 blob 2c16c536ba830ec12bbf335d09f689d23e325197    Documentation/asciidoc.conf
100644 blob 0cebc4f6927211ffbc013de9368f03f480dba65d    Documentation/blame-options.txt
100755 blob ba4205e0302a267a5da6bef504f3e69eb0c4aa6d    Documentation/build-docdep.perl
100755 blob 87437f8a95768595e040b8c4c1d48e5c29ada087    Documentation/cat-texi.perl

But this was removed in 2.3.0, with the message

ls-tree: disable negative pathspec because it's not supported

Well that's circular ;)


What is the new, "correct" way to do this in git 2.3.0 and later?

Paul Draper
  • 78,542
  • 46
  • 206
  • 285
  • (I read "supported" in that message in the sense of "a feature for which anyone is willing to fix bugs and maintain codepaths", which leaves it a bit less circular than might otherwise be the case). – Charles Duffy Sep 09 '15 at 03:45
  • ...indeed, the changelog indicates that to be the case: Negative pathspecs were accepted by the parser, but didn't actually work. – Charles Duffy Sep 09 '15 at 03:48
  • @CharlesDuffy, they did work, or at least the one I gave as an example for the git repo works. – Paul Draper Sep 09 '15 at 04:28
  • And yet the person who first implemented them says they don't. Speaking of which -- the mailing list is public; why not inquire there? – Charles Duffy Sep 09 '15 at 04:30
  • @CharlesDuffy, I did. "Delivery to the following recipient failed permanently: git@vger.kernel.org" – Paul Draper Sep 09 '15 at 04:58

1 Answers1

1

Piping through

awk '$4 !~ /Documentation\/RelNotes/ { print }'

...is the obvious approach. To make this a bit more generic:

s='Documentation/RelNotes'
awk -v exclusion_re="$s" '$4 !~ exclusion_re { print }
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441