Skip to content

Allow extracting git-ignored code: add --no-gitignore opt-out #1971

Closed

Description

@JensD-git

Summary

Since ignore files below the scan root are read live during the walk (#1206) and .gitignore is merged into the ignore logic (#1363), graphify extract now honors every .gitignore it encounters anywhere under the scan root. That is usually correct — but there is no way to turn it off, and it silently removes source files that are deliberately git-ignored yet are exactly what we want in the graph.

Concretely: a large body of transpiled/generated C# code lives in generated/ directories that the project's .gitignore excludes (generated output is conventionally not committed). That code is the behavior we analyze. On a version that only read the scan root's own ignore files this code was extracted; after upgrading, all of it disappears — no error, no warning, the files simply don't appear in the graph, so the loss is easy to miss.

Environment

  • graphifyy: a version that did not read nested .gitignore vs. current that does (0.9.13 → 0.9.18 in our case)
  • Windows 11, Python 3.14, C# corpus (nodes are _origin: ast)

Minimal reproduction (verified on 0.9.18)

mkdir -p root/proj/deep/generated
printf 'namespace N { public class Real { public void M(){} } }\n' > root/proj/Real.cs
printf 'namespace N { public class Keep { public void M(){} } }\n' > root/proj/deep/Keep.cs
printf 'namespace N { public class Gen  { public void M(){} } }\n' > root/proj/deep/generated/Gen.cs
printf 'generated/\n' > root/proj/.gitignore        # nested, BELOW the scan root

graphify extract root --out out                     # exits 0, no warning

Inspect source_file on the nodes in out/graphify-out/graph.json.

Observed (actual): only proj/Real.cs and proj/deep/Keep.cs are present.
proj/deep/generated/Gen.cs is absent — silently pruned because proj/.gitignore excludes generated/.

Desired: a supported way to include Gen.cs despite the .gitignore exclusion (see request below).

On a real transpiled graph the aggregate impact is large: distinct .cs files 1200 → 936 (−264, all under generated/); AST nodes −13%; edges −29%.

What we ruled out while diagnosing

  • Not the parser: identical tree-sitter (0.25.2) / tree-sitter-c-sharp (0.23.5); the dropped files parse fine in isolation (extract_csharp(path) returns 45 nodes, no error).
  • Not dedup, not a file-size cap, not _SKIP_DIRS (there is no generated literal in the skip set).
  • Confirmed mechanism: detect._load_dir_own_ignore(proj) reads proj/.gitignore during the walk and returns the generated/ pattern, which prunes the directory. This function/behavior is only present in the newer version.

Only workaround we could find (verified on 0.9.18)

Place a .graphifyignore containing both !generated/ and !generated/** in the same directory as the offending .gitignore (root/proj/.graphifyignore). Re-running the repro then includes proj/deep/generated/Gen.cs.

  • This works because per-directory .graphifyignore is read after .gitignore (_load_dir_own_ignore), so the ! negation wins via last-match-wins and the directory is not pruned.
  • A re-include placed at the scan root does not work: the nested .gitignore is loaded later during the walk and wins. So the escape hatch must be co-located with each offending .gitignore, which is non-obvious and awkward to automate.

Questions / requests

  1. Is there an existing flag or config to disable honoring .gitignore (and $GIT_DIR/info/exclude) during extraction? We could not find one.
  2. If not, would you consider a --no-gitignore / --ignore-vcs-ignores opt-out? Honoring .gitignore is a sensible default, but generated/transpiled code that is git-ignored yet analysis-relevant is a real case (build output, codegen, transpiler targets), and there is currently no clean escape hatch.
  3. If the intended answer is "use a co-located .graphifyignore re-include", could the precedence (a nested .gitignore beats a scan-root .graphifyignore; only a co-located ! wins) be documented? It is currently surprising.

Either way, this project is great, and I'd like to thank everyone who's actively contributing to it. Have a great weekend. <3

Activity

  1. Mzt00 commented on Jul 17, 2026

    @Mzt00
    Contributor

    There is currently no flag or configuration to disable .gitignore or $GIT_DIR/info/exclude.

    A co-located .graphifyignore re-include works because it is evaluated after that directory’s .gitignore. A scan root re-include cannot override a nested .gitignore, since the nested rules are loaded later.

    I'd be happy to work on the issue!

  2. safishamsi commented on Jul 18, 2026

    @safishamsi
    Member

    Fixed on v8 (ships in 0.9.19) via #1979 (f17e2c5) + persistence follow-up (caa6f9e), thanks @mzt006. --no-gitignore indexes git-ignored code (keeping .graphifyignore and the secret screens), and the setting persists across flag-less re-extracts.

  3. added a commit that references this issue on Jul 18, 2026
  4. safishamsi commented on Jul 18, 2026

    @safishamsi
    Member

    Apologies @MZT006 — wrong ping, that was my mistake. The fix (#1979) was authored by @Mzt00 and the report by @JensD-git; I mistyped the handle. Corrected in the changelog and the 0.9.19 release notes. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions