Show context without attaching every file
Use a separate tree filter when the recipient needs a project map but only a small amount of source content. This page starts with the following independent fixture:
In a new folder named demo, create the following files with a text editor. The text after each filename is its content; use a line break for each ↵. Use sample values only. Open a terminal in demo. Do not reuse a folder containing an existing .onesourcerc.
README.md: # Demosrc/main.rs: fn main() {}src/legacy/old.rs: fn old() {}tests/smoke.rs: #[test] ↵ fn smoke() {}.gitignore: notes.txtnotes.txt: Local notes
OneSource must already be available as onesource. If it is not, follow Installation. All commands on this page start in this folder unless a step explicitly says otherwise.
1. Observe default inheritance
Select only src/main.rs. With no tree-specific options, the tree inherits the content include:
onesource --no-config -i "src/main.rs" --dry-rundemo/
└── src/
└── main.rsExpect one content file. The src directory is added as an ancestor even though the include names a file. README, tests and legacy do not appear. Now override the tree include with an empty string:
onesource --no-config -i "src/main.rs" --tree-include="" --dry-rundemo/
├── README.md
├── src/
│ ├── legacy/
│ │ └── old.rs
│ └── main.rs
└── tests/
└── smoke.rsThe tree expands, but the expected content remains only src/main.rs. --tree-include changes tree selection, not content. Its alias is --ti. The empty string means no tree include restriction; it still honors ignore and blacklist.
Tree include/exclude fall back individually to content include/exclude. An explicit empty string is an override that disables that tree filter. tree_no_ignore falls back to resolved no_ignore; explicit false overrides inherited true. no_blacklist affects both; no_tree disables tree generation entirely.
2. Override excludes and ignore separately
Suppose you want all Rust content except legacy code, while still showing that legacy directory in the project map. Content exclude normally propagates to tree; override it independently:
onesource --no-config -i "*.rs" -x "src/legacy/" --ti "" --tx "" --dry-runExpect main.rs and tests/smoke.rs as content. The expanded tree still contains legacy/old.rs. --tx "" cancels the inherited exclude; to hide tests from the map instead, use --tx "tests/". It replaces the tree’s inherited exclude rather than adding to it.
For ignore rules, try including notes in content but keeping it out of the tree:
onesource --no-config --no-ignore --tree-no-ignore=false --dry-runExpect notes.txt as content, absent from the tree. no-ignore is true for content, but the explicit false restores the tree’s ignore behavior. Use --no-tree when no map is needed:
onesource --no-config -i "src/main.rs" --no-tree --dry-runExpect a file preview and statistics without any tree. no-tree does not disable attached content.
3. Verify tree and content as separate results
Write a small bundle that has a broad map but only one file’s content:
onesource --no-config -i "src/main.rs" --ti "" -o map.onesourceOpen map.onesource. Compare tree entries with file-block paths: only src/main.rs should have a block. Do not infer attachment from the map. If a tree entry has no content unexpectedly, diagnose that path:
onesource explain README.md --no-config -i "src/main.rs" --ti ""Content:
Result: not included by include
Rule: include = src/main.rs
Tree:
Result: includedThe excerpt explains the intentional difference: README matches the tree but not content. Size and binary detection can produce the same visible difference for another reason. Read Content first, then Tree.
The tree is sorted by name and inserts ancestors of matching paths. It does not inspect size, NUL bytes or content readability: a binary or oversized file may appear in the tree without a file block. Symlink directories are not recursively followed. A symlink outside root may appear in the tree but its content is skipped. Content candidates are sorted by relative path.