2007-11-25 08:48:04 +01:00
|
|
|
directory listing API
|
|
|
|
=====================
|
|
|
|
|
|
|
|
The directory listing API is used to enumerate paths in the work tree,
|
|
|
|
optionally taking `.git/info/exclude` and `.gitignore` files per
|
|
|
|
directory into account.
|
|
|
|
|
|
|
|
Data structure
|
|
|
|
--------------
|
|
|
|
|
|
|
|
`struct dir_struct` structure is used to pass directory traversal
|
2012-12-27 03:32:21 +01:00
|
|
|
options to the library and to record the paths discovered. A single
|
|
|
|
`struct dir_struct` is used regardless of whether or not the traversal
|
|
|
|
recursively descends into subdirectories.
|
|
|
|
|
|
|
|
The notable options are:
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
`exclude_per_dir`::
|
|
|
|
|
|
|
|
The name of the file to be read in each directory for excluded
|
|
|
|
files (typically `.gitignore`).
|
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
`flags`::
|
2007-11-25 08:48:04 +01:00
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
A bit-field of options:
|
2007-11-25 08:48:04 +01:00
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
`DIR_SHOW_IGNORED`:::
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
The traversal is for finding just ignored files, not unignored
|
|
|
|
files.
|
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
`DIR_SHOW_OTHER_DIRECTORIES`:::
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
Include a directory that is not tracked.
|
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
`DIR_HIDE_EMPTY_DIRECTORIES`:::
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
Do not include a directory that is not tracked and is empty.
|
|
|
|
|
2012-12-27 03:32:20 +01:00
|
|
|
`DIR_NO_GITLINKS`:::
|
2007-11-25 08:48:04 +01:00
|
|
|
|
2013-01-21 20:17:53 +01:00
|
|
|
If set, recurse into a directory that looks like a Git
|
2007-11-25 08:48:04 +01:00
|
|
|
directory. Otherwise it is shown as a directory.
|
|
|
|
|
2012-12-27 03:32:21 +01:00
|
|
|
The result of the enumeration is left in these fields:
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
`entries[]`::
|
|
|
|
|
|
|
|
An array of `struct dir_entry`, each element of which describes
|
|
|
|
a path.
|
|
|
|
|
|
|
|
`nr`::
|
|
|
|
|
|
|
|
The number of members in `entries[]` array.
|
|
|
|
|
|
|
|
`alloc`::
|
|
|
|
|
|
|
|
Internal use; keeps track of allocation of `entries[]` array.
|
|
|
|
|
|
|
|
|
|
|
|
Calling sequence
|
|
|
|
----------------
|
|
|
|
|
2009-08-20 15:47:01 +02:00
|
|
|
Note: index may be looked at for .gitignore files that are CE_SKIP_WORKTREE
|
|
|
|
marked. If you to exclude files, make sure you have loaded index first.
|
|
|
|
|
2007-11-25 08:48:04 +01:00
|
|
|
* Prepare `struct dir_struct dir` and clear it with `memset(&dir, 0,
|
|
|
|
sizeof(dir))`.
|
|
|
|
|
2013-01-06 17:58:03 +01:00
|
|
|
* To add single exclude pattern, call `add_exclude_list()` and then
|
|
|
|
`add_exclude()`.
|
|
|
|
|
|
|
|
* To add patterns from a file (e.g. `.git/info/exclude`), call
|
|
|
|
`add_excludes_from_file()` , and/or set `dir.exclude_per_dir`. A
|
|
|
|
short-hand function `setup_standard_excludes()` can be used to set
|
|
|
|
up the standard set of exclude settings.
|
2007-11-25 08:48:04 +01:00
|
|
|
|
|
|
|
* Set options described in the Data Structure section above.
|
|
|
|
|
|
|
|
* Call `read_directory()`.
|
|
|
|
|
|
|
|
* Use `dir.entries[]`.
|
|
|
|
|
2013-01-06 17:58:13 +01:00
|
|
|
* Call `clear_directory()` when none of the contained elements are no longer in use.
|
2013-01-06 17:58:05 +01:00
|
|
|
|
2007-11-25 08:48:04 +01:00
|
|
|
(JC)
|