diff --git a/Documentation/git-filter-repo.txt b/Documentation/git-filter-repo.txt index ff21ff8..c5fb050 100644 --- a/Documentation/git-filter-repo.txt +++ b/Documentation/git-filter-repo.txt @@ -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 :: 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 -------------------------------------------------- diff --git a/git-filter-repo b/git-filter-repo index 39cdd85..d1580c5 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -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 diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index d2a2612..8f9d099 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -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