You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

doc.go 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Package gitignore implements matching file system paths to gitignore patterns that
  2. // can be automatically read from a git repository tree in the order of definition
  3. // priorities. It support all pattern formats as specified in the original gitignore
  4. // documentation, copied below:
  5. //
  6. // Pattern format
  7. // ==============
  8. //
  9. // - A blank line matches no files, so it can serve as a separator for readability.
  10. //
  11. // - A line starting with # serves as a comment. Put a backslash ("\") in front of
  12. // the first hash for patterns that begin with a hash.
  13. //
  14. // - Trailing spaces are ignored unless they are quoted with backslash ("\").
  15. //
  16. // - An optional prefix "!" which negates the pattern; any matching file excluded
  17. // by a previous pattern will become included again. It is not possible to
  18. // re-include a file if a parent directory of that file is excluded.
  19. // Git doesn’t list excluded directories for performance reasons, so
  20. // any patterns on contained files have no effect, no matter where they are
  21. // defined. Put a backslash ("\") in front of the first "!" for patterns
  22. // that begin with a literal "!", for example, "\!important!.txt".
  23. //
  24. // - If the pattern ends with a slash, it is removed for the purpose of the
  25. // following description, but it would only find a match with a directory.
  26. // In other words, foo/ will match a directory foo and paths underneath it,
  27. // but will not match a regular file or a symbolic link foo (this is consistent
  28. // with the way how pathspec works in general in Git).
  29. //
  30. // - If the pattern does not contain a slash /, Git treats it as a shell glob
  31. // pattern and checks for a match against the pathname relative to the location
  32. // of the .gitignore file (relative to the toplevel of the work tree if not
  33. // from a .gitignore file).
  34. //
  35. // - Otherwise, Git treats the pattern as a shell glob suitable for consumption
  36. // by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will
  37. // not match a / in the pathname. For example, "Documentation/*.html" matches
  38. // "Documentation/git.html" but not "Documentation/ppc/ppc.html" or
  39. // "tools/perf/Documentation/perf.html".
  40. //
  41. // - A leading slash matches the beginning of the pathname. For example,
  42. // "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
  43. //
  44. // Two consecutive asterisks ("**") in patterns matched against full pathname
  45. // may have special meaning:
  46. //
  47. // - A leading "**" followed by a slash means match in all directories.
  48. // For example, "**/foo" matches file or directory "foo" anywhere, the same as
  49. // pattern "foo". "**/foo/bar" matches file or directory "bar"
  50. // anywhere that is directly under directory "foo".
  51. //
  52. // - A trailing "/**" matches everything inside. For example, "abc/**" matches
  53. // all files inside directory "abc", relative to the location of the
  54. // .gitignore file, with infinite depth.
  55. //
  56. // - A slash followed by two consecutive asterisks then a slash matches
  57. // zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b",
  58. // "a/x/y/b" and so on.
  59. //
  60. // - Other consecutive asterisks are considered invalid.
  61. //
  62. // Copyright and license
  63. // =====================
  64. //
  65. // Copyright (c) Oleg Sklyar, Silvertern and source{d}
  66. //
  67. // The package code was donated to source{d} to include, modify and develop
  68. // further as a part of the `go-git` project, release it on the license of
  69. // the whole project or delete it from the project.
  70. package gitignore