Giter Club home page Giter Club logo

git-find's Introduction

git-find - Find files anywhere in a Git repository

SYNOPSIS

git find [SWITCHES] [REVS] [--] [EXPRESSION]

This command searches for files satisfying the EXPRESSION, a la find(1), anywhere in a Git repo. Unlike find(1), the search scope is the whole repo (for the REVS you specify) regardless of the current directory.

For more help, run git find --help or git find --man.

NOTE: most of this is not yet implemented :) . Contributions welcome!

OPTIONS AND ARGUMENTS

Quick reference:

  • Switches:

    Basic: Help (-?, --usage; -h, --help; --man); Version (-V, --version); Verbosity (-v); Warnings (-W).

    Search scope: Git directory (--git-dir), Working directory (--wd), Unrestricted search (-u).

  • Revs:

    Anything accepted by git-rev-parse(1).

    A git ref (under .git/refs/) is also a rev in the sense of git-rev-parse(1) and gitrevisions(7). The terms "ref" and "rev" are used interchangeably by git-find.

  • Expression:

    Anything accepted by find(1), plus -ref/-rev

DESCRIPTION

Switches

These are options controlling the overall behaviour of git-find. They may not be interleaved in with the "Expression", if one is given.

  • --git-dir <dir>

    Use <dir> as the .git directory. Not yet implemented.

  • -h, --help

    Print basic help

  • --man

    Show full help (equivalent to man git-find)

  • -u

    Unrestricted search. Normally, git-find does not search ignored files. When this option is given, it does search those files. However, it still skips .git/ directories.

  • --usage, -?

    Print a brief usage reminder

  • -v

    Increase verbosity. May be given multiple times.

  • -V, --version

    Print version information and exit

  • --wd <dir>

    Use <dir> as the working directory. Not yet implemented.

  • -W, -Wname

    Enable warning name, or all warnings if no name is given.

Operators

In the "Revs" or "Expression", you can specify multiple items joined by logical operators. They are listed below in order of descending precedence. Each operator must be separated by whitespace from any adjacent parameters. Operators short-circuit.

  • ( ), [ ]

    Grouping. Parentheses and brackets are interchangeable.

  • -not, --not, !, ^

    Logical negation.

  • -a, --a, -and, --and, &&

    Logical and. This is the default operator between terms if no operator is given.

  • -o, --o, -or, --or, ||

    Logical or

  • , (a single comma)

    Sequence: separates items to be evaluated separately. The return value is that of the last item in the sequence.

Revs

By default, git-find searches the current index (cache). This is the same as the default for git-ls-files(1). You can specify one or more revs to search using any of the forms described in gitrevisions(7).

You can specify the special value ]] (a double right bracket) to search the working tree that is currently checked out. (Mnemonic: search right here.) If you have an actual rev called "]]", git-find won't be able to help you. Sorry!

TODO? You can specify multiple ranges of revs separated by C<-o> (or its
equivalent forms given in L</Operators>) or C<,>.  Comma is treated as
equivalent to C<-o> when separating revs.

Expression

The expression includes one or more elements separated by "Operators". Elements can be options, tests, or operators.

Elements of expressions can be specified in a form similar to find(1). Long elements (e.g., -name) can start with a single or a double dash.

Tests are of two types:

  • Index tests

    These are tests that only require information from the git index, such as the name of the file and whether it is executable. They are (at least on Unix-like systems):

    -cmin, -cnewer, -ctime, -empty, -executable, -false, -gid, -group, -ilname, -iname, -inum, -ipath, -iregex, -iwholename, -level, -mmin, -mtime, -name, -nogroup, -nouser, -path, -readable, -regex, -size, -true, -type, -uid, -user, -wholename, -writeable

      TODO also -links, -lname, -perm, -samefile, -xtype?
    
  • Detailed tests

    All tests other than index tests may require checking out a worktree with one or more of the given revs. Therefore, they may be much slower than name-only tests. However, if the only rev given is ]] (working directory), detailed tests can be executed without checking out a worktree, so the slowdown is not as bad.

DIFFERENCES FROM FIND(1)

In git-find but not in find(1): -ref, -rev

In find(1) but not in git-find: find switches; TODO -xtype, -context?

WARNINGS

If the -W option is given, warnings are enabled. Possible warnings are:

  • -Wdetailed

    Warn if a detailed test is used on a search scope other than ]] (the current working tree).

AUTHOR

Christopher White, <cxw at cpan.org>

BUGS

Please report any bugs or feature requests through the GitHub interface at https://github.com/cxw42/git-find/issues. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc App::GitFind

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2019 Christopher White. Portions copyright 2019 D3 Engineering, LLC.

This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

git-find's People

Contributors

cxw42 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

git-find's Issues

Investigate and implement one-argument detailed tests

Find out if the following are detailed or index tests, and implement them. Requires design discussion.

    links lname     # Actually index tests?
    perm            # Actually index test?
    ref rev         # Maybe not detailed tests - TODO investigate this
    samefile        # Actually index test?

Add no-argument tests

In App::GitFind::Actions, add functions do_empty, do_executable, do_readable, do_writeable.

Bonus points: add do_nogroup, do_nouser.

Create test framework in t/ and t/TestKit.pm for testing expressions

We need to be able to test operations on Git repos. Minilla might be good as a source of ideas (but not code), since it has the same need.

  • Make a hierarchy under t/data that has various directories, subdirectories, ...
    • ? Add a submodule for purposes of author testing?
  • Add functions to t/TestKit.pm to make it easier to run tests against the repo when checked out, and to skip those tests if we're running make test in an extracted tarball (as opposed to a clone).
  • Add functional tests! E.g., does -print actually print the filenames we expect?

Process commit message as if it were a file

When searching repos (not ]]), add an entry for the commit message. Perhaps filename #, since the commit message is a comment? Permit all types of processing as if it were a real file.

Add one-argument index tests

In App::GitFind::Actions, add do_foo() for any or all of the following foo:

    cmin cnewer ctime
    gid group ilname iname inum ipath iregex iwholename level
    mmin mtime name
    path
    regex
    size type uid
    user wholename

install

What is the correct way to install this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.