mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-03 17:05:39 +02:00
filter-repo: ignore comment lines in --paths-from-file
Allow lines starting with '#' to be treated as a comment and be ignored. Update the documentation to note that both blank lines and comment lines are ignored, and mention how filenames starting with '#' can be matched (namely, the same way that filenames startwith with 'regex:', 'glob:', or 'literal:' can be -- by prefixing the filename with 'literal:'). Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
771404d656
commit
38e70b69e8
|
@ -129,7 +129,11 @@ Path shortcuts
|
|||
Specify several path filtering and renaming directives, one
|
||||
per line. Lines with `==>` in them specify path renames, and
|
||||
lines can begin with `literal:` (the default), `glob:`, or
|
||||
`regex:` to specify different matching styles
|
||||
`regex:` to specify different matching styles. Blank lines
|
||||
and lines starting with a `#` are ignored (if you have a
|
||||
filename that you want to filter on that starts with
|
||||
`literal:`, `#`, `glob:`, or `regex:`, then prefix the line
|
||||
with 'literal:').
|
||||
|
||||
--subdirectory-filter <directory>::
|
||||
Only look at history that touches the given subdirectory and
|
||||
|
@ -676,12 +680,22 @@ expressions to filter on, you can stick them in a file and use
|
|||
contents of
|
||||
|
||||
--------------------------------------------------
|
||||
# Blank lines and comment lines are ignored.
|
||||
# Examples similar to --path:
|
||||
README.md
|
||||
guides/
|
||||
tools/releases
|
||||
|
||||
# An example that is like --path-glob:
|
||||
glob:*.py
|
||||
|
||||
# An example that is like --path-regex:
|
||||
regex:^.*/.*/[0-9]{4}-[0-9]{2}-[0-9]{2}.txt$
|
||||
|
||||
# An example of renaming a path
|
||||
tools/==>scripts/
|
||||
|
||||
# An example of using a regex to rename a path
|
||||
regex:(.*)/([^/]*)/([^/]*)\.text$==>\2/\1/\3.txt
|
||||
--------------------------------------------------
|
||||
|
||||
|
|
|
@ -1807,7 +1807,8 @@ EXAMPLES
|
|||
help=_("Specify several path filtering and renaming directives, one "
|
||||
"per line. Lines with '==>' in them specify path renames, "
|
||||
"and lines can begin with 'literal:' (the default), 'glob:', "
|
||||
"or 'regex:' to specify different matching styles"))
|
||||
"or 'regex:' to specify different matching styles. Blank "
|
||||
"lines and lines starting with a '#' are ignored."))
|
||||
helpers.add_argument('--subdirectory-filter', metavar='DIRECTORY',
|
||||
action=FilteringOptions.HelperFilter, type=os.fsencode,
|
||||
help=_("Only look at history that touches the given subdirectory "
|
||||
|
@ -2123,6 +2124,9 @@ EXAMPLES
|
|||
# Skip blank lines
|
||||
if not line:
|
||||
continue
|
||||
# Skip comment lines
|
||||
if line.startswith(b'#'):
|
||||
continue
|
||||
|
||||
# Determine the replacement
|
||||
match_type, repl = 'literal', None
|
||||
|
|
|
@ -165,6 +165,7 @@ test_expect_success '--paths-from-file' '
|
|||
values/huge==>values/gargantuan
|
||||
glob:*rge
|
||||
|
||||
# Comments and blank lines are ignored
|
||||
regex:.*med.*
|
||||
regex:^([^/]*)/(.*)ge$==>\2/\1/ge
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue
Block a user