ack3 icon indicating copy to clipboard operation
ack3 copied to clipboard

Docs: git|ack -x as alternative to handling .gitignore

Open petdance opened this issue 6 years ago • 5 comments

petdance avatar Apr 04 '19 15:04 petdance

Specific example is git ls-files * | ack3 --files-from=- string which is even more awesome than either interpreting .gitignore or using find because it's looking exactly at the member files. Example edge case: if .gitignore was overridden with git add -f because this one ignorable file is indeed in the project, ack will see that one instead of ignoring it, this is good.

(It may result in ack3 looking at some .gif's though?)

I might add a git-ack shell script to my ~/bin to do exactly this ...

I have also used ack --output or cut to grab just the names of changed files from a git diff --stat to pipe into ack -x (and if i make git-ack, it will take a --diff flag to do that instead of ls-files )

n1vux avatar Apr 05 '19 19:04 n1vux

(It may result in ack3 looking at some .gif's though?)

Yes, it would. If you feed ack files in -x, then it does no filtering on them.

petdance avatar Apr 05 '19 19:04 petdance

someone pointed out that my perl/cut idiom ripping the filenames only from git diff --stat is silly, it's built in already:

git diff --name-only | ack -x -w create

Happy ... wish I'd seen it sooner ...

n1vux avatar Apr 19 '19 04:04 n1vux

See also #40

petdance avatar May 13 '19 02:05 petdance

Yes, it would. If you feed ack files in -x, then it does no filtering on them.

Perhaps ack -x --perl or ack --files-from FN --no-json should filter as explicitly request. (And if not, it really ought to error or at least warn that filter --perl is ignored with files specified by -x and likewise "on command line" "by --files-from" etc)

Being able to apply our named filters as a filter on a list of files would be a value-added feature.

Would this require a major re-arch because filtering is delegated to File::Next which we basically can't use with a provided list? (Unless File::Next got a new constructor that takes a --files-from or -x stream and uses that instead of tree walking ...)

n1vux avatar Jun 22 '21 22:06 n1vux