add a function for worktree file listings specifically

This introduces `gix` to the codebase and uses it selectively
to traverse a worktree while respecting git excludes.
This commit is contained in:
Sebastian Thiel 2024-04-20 08:15:42 +02:00
parent 863494d997
commit cf81401b5a
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B
4 changed files with 773 additions and 31 deletions

782
Cargo.lock generated
View File

@ -105,6 +105,12 @@ dependencies = [
"backtrace",
]
[[package]]
name = "arc-swap"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
name = "arrayvec"
version = "0.7.4"
@ -136,11 +142,10 @@ dependencies = [
[[package]]
name = "async-executor"
version = "1.9.1"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10b3e585719c2358d2660232671ca8ca4ddb4be4ce8a1842d6c2dc8685303316"
checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a"
dependencies = [
"async-lock 3.3.0",
"async-task",
"concurrent-queue",
"fastrand 2.0.2",
@ -325,7 +330,7 @@ dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -674,7 +679,7 @@ checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
dependencies = [
"glib-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -770,6 +775,12 @@ dependencies = [
"inout",
]
[[package]]
name = "clru"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8191fa7302e03607ff0e237d4246cc043ff5b3cb9409d995172ba3bea16b807"
[[package]]
name = "cocoa"
version = "0.24.1"
@ -1501,6 +1512,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "faster-hex"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183"
[[package]]
name = "fastrand"
version = "1.9.0"
@ -1848,7 +1865,7 @@ dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -1865,7 +1882,7 @@ dependencies = [
"libc",
"pango-sys",
"pkg-config",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -1879,7 +1896,7 @@ dependencies = [
"gobject-sys",
"libc",
"pkg-config",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -1891,7 +1908,7 @@ dependencies = [
"gdk-sys",
"glib-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
"x11",
]
@ -1983,7 +2000,7 @@ dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
"winapi 0.3.9",
]
@ -2054,6 +2071,7 @@ dependencies = [
"git2-hooks",
"gitbutler-git",
"gitbutler-testsupport",
"gix",
"itertools 0.12.1",
"lazy_static",
"log",
@ -2177,6 +2195,662 @@ dependencies = [
"tracing",
]
[[package]]
name = "gix"
version = "0.62.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5631c64fb4cd48eee767bf98a3cbc5c9318ef3bb71074d4c099a2371510282b6"
dependencies = [
"gix-actor",
"gix-attributes",
"gix-command",
"gix-commitgraph",
"gix-config",
"gix-date",
"gix-diff",
"gix-dir",
"gix-discover",
"gix-features",
"gix-filter",
"gix-fs",
"gix-glob",
"gix-hash",
"gix-hashtable",
"gix-ignore",
"gix-index",
"gix-lock",
"gix-macros",
"gix-object",
"gix-odb",
"gix-pack",
"gix-path",
"gix-pathspec",
"gix-ref",
"gix-refspec",
"gix-revision",
"gix-revwalk",
"gix-sec",
"gix-submodule",
"gix-tempfile",
"gix-trace",
"gix-traverse",
"gix-url",
"gix-utils",
"gix-validate",
"gix-worktree",
"once_cell",
"parking_lot 0.12.1",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-actor"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45c3a3bde455ad2ee8ba8a195745241ce0b770a8a26faae59fcf409d01b28c46"
dependencies = [
"bstr 1.9.1",
"gix-date",
"gix-utils",
"itoa 1.0.11",
"thiserror",
"winnow 0.6.5",
]
[[package]]
name = "gix-attributes"
version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eefb48f42eac136a4a0023f49a54ec31be1c7a9589ed762c45dcb9b953f7ecc8"
dependencies = [
"bstr 1.9.1",
"gix-glob",
"gix-path",
"gix-quote",
"gix-trace",
"kstring",
"smallvec",
"thiserror",
"unicode-bom",
]
[[package]]
name = "gix-bitmap"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a371db66cbd4e13f0ed9dc4c0fea712d7276805fccc877f77e96374d317e87ae"
dependencies = [
"thiserror",
]
[[package]]
name = "gix-chunk"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45c8751169961ba7640b513c3b24af61aa962c967aaf04116734975cd5af0c52"
dependencies = [
"thiserror",
]
[[package]]
name = "gix-command"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f90009020dc4b3de47beed28e1334706e0a330ddd17f5cfeb097df3b15a54b77"
dependencies = [
"bstr 1.9.1",
"gix-path",
"gix-trace",
"shell-words",
]
[[package]]
name = "gix-commitgraph"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7b102311085da4af18823413b5176d7c500fb2272eaf391cfa8635d8bcb12c4"
dependencies = [
"bstr 1.9.1",
"gix-chunk",
"gix-features",
"gix-hash",
"memmap2",
"thiserror",
]
[[package]]
name = "gix-config"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7580e05996e893347ad04e1eaceb92e1c0e6a3ffe517171af99bf6b6df0ca6e5"
dependencies = [
"bstr 1.9.1",
"gix-config-value",
"gix-features",
"gix-glob",
"gix-path",
"gix-ref",
"gix-sec",
"memchr",
"once_cell",
"smallvec",
"thiserror",
"unicode-bom",
"winnow 0.6.5",
]
[[package]]
name = "gix-config-value"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbd06203b1a9b33a78c88252a625031b094d9e1b647260070c25b09910c0a804"
dependencies = [
"bitflags 2.5.0",
"bstr 1.9.1",
"gix-path",
"libc",
"thiserror",
]
[[package]]
name = "gix-date"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180b130a4a41870edfbd36ce4169c7090bca70e195da783dea088dd973daa59c"
dependencies = [
"bstr 1.9.1",
"itoa 1.0.11",
"thiserror",
"time",
]
[[package]]
name = "gix-diff"
version = "0.43.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5fbc24115b957346cd23fb0f47d830eb799c46c89cdcf2f5acc9bf2938c2d01"
dependencies = [
"bstr 1.9.1",
"gix-hash",
"gix-object",
"thiserror",
]
[[package]]
name = "gix-dir"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fcd56ffa1133f35525af890226ad0d3b2e607b4490360c94b1869e278eba3"
dependencies = [
"bstr 1.9.1",
"gix-discover",
"gix-fs",
"gix-ignore",
"gix-index",
"gix-object",
"gix-path",
"gix-pathspec",
"gix-trace",
"gix-utils",
"gix-worktree",
"thiserror",
]
[[package]]
name = "gix-discover"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64bab49087ed3710caf77e473dc0efc54ca33d8ccc6441359725f121211482b1"
dependencies = [
"bstr 1.9.1",
"dunce",
"gix-fs",
"gix-hash",
"gix-path",
"gix-ref",
"gix-sec",
"thiserror",
]
[[package]]
name = "gix-features"
version = "0.38.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db4254037d20a247a0367aa79333750146a369719f0c6617fec4f5752cc62b37"
dependencies = [
"crc32fast",
"flate2",
"gix-hash",
"gix-trace",
"gix-utils",
"libc",
"once_cell",
"prodash",
"sha1_smol",
"thiserror",
"walkdir",
]
[[package]]
name = "gix-filter"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c0d1f01af62bfd2fb3dd291acc2b29d4ab3e96ad52a679174626508ce98ef12"
dependencies = [
"bstr 1.9.1",
"encoding_rs",
"gix-attributes",
"gix-command",
"gix-hash",
"gix-object",
"gix-packetline-blocking",
"gix-path",
"gix-quote",
"gix-trace",
"gix-utils",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-fs"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2184c40e7910529677831c8b481acf788ffd92427ed21fad65b6aa637e631b8"
dependencies = [
"gix-features",
"gix-utils",
]
[[package]]
name = "gix-glob"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "682bdc43cb3c00dbedfcc366de2a849b582efd8d886215dbad2ea662ec156bb5"
dependencies = [
"bitflags 2.5.0",
"bstr 1.9.1",
"gix-features",
"gix-path",
]
[[package]]
name = "gix-hash"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e"
dependencies = [
"faster-hex",
"thiserror",
]
[[package]]
name = "gix-hashtable"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ddf80e16f3c19ac06ce415a38b8591993d3f73aede049cb561becb5b3a8e242"
dependencies = [
"gix-hash",
"hashbrown 0.14.3",
"parking_lot 0.12.1",
]
[[package]]
name = "gix-ignore"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "640dbeb4f5829f9fc14d31f654a34a0350e43a24e32d551ad130d99bf01f63f1"
dependencies = [
"bstr 1.9.1",
"gix-glob",
"gix-path",
"gix-trace",
"unicode-bom",
]
[[package]]
name = "gix-index"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "881ab3b1fa57f497601a5add8289e72a7ae09471fc0b9bbe483b628ae8e418a1"
dependencies = [
"bitflags 2.5.0",
"bstr 1.9.1",
"filetime",
"fnv",
"gix-bitmap",
"gix-features",
"gix-fs",
"gix-hash",
"gix-lock",
"gix-object",
"gix-traverse",
"gix-utils",
"hashbrown 0.14.3",
"itoa 1.0.11",
"libc",
"memmap2",
"rustix 0.38.32",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-lock"
version = "13.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7c359f81f01b8352063319bcb39789b7ea0887b406406381106e38c4a34d049"
dependencies = [
"gix-tempfile",
"gix-utils",
"thiserror",
]
[[package]]
name = "gix-macros"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dff438f14e67e7713ab9332f5fd18c8f20eb7eb249494f6c2bf170522224032"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.58",
]
[[package]]
name = "gix-object"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d4f8efae72030df1c4a81d02dbe2348e748d9b9a11e108ed6efbd846326e051"
dependencies = [
"bstr 1.9.1",
"gix-actor",
"gix-date",
"gix-features",
"gix-hash",
"gix-utils",
"gix-validate",
"itoa 1.0.11",
"smallvec",
"thiserror",
"winnow 0.6.5",
]
[[package]]
name = "gix-odb"
version = "0.60.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8bbb43d2fefdc4701ffdf9224844d05b136ae1b9a73c2f90710c8dd27a93503"
dependencies = [
"arc-swap",
"gix-date",
"gix-features",
"gix-fs",
"gix-hash",
"gix-object",
"gix-pack",
"gix-path",
"gix-quote",
"parking_lot 0.12.1",
"tempfile",
"thiserror",
]
[[package]]
name = "gix-pack"
version = "0.50.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b58bad27c7677fa6b587aab3a1aca0b6c97373bd371a0a4290677c838c9bcaf1"
dependencies = [
"clru",
"gix-chunk",
"gix-features",
"gix-hash",
"gix-hashtable",
"gix-object",
"gix-path",
"gix-tempfile",
"memmap2",
"parking_lot 0.12.1",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-packetline-blocking"
version = "0.17.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c31d42378a3d284732e4d589979930d0d253360eccf7ec7a80332e5ccb77e14a"
dependencies = [
"bstr 1.9.1",
"faster-hex",
"gix-trace",
"thiserror",
]
[[package]]
name = "gix-path"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23623cf0f475691a6d943f898c4d0b89f5c1a2a64d0f92bce0e0322ee6528783"
dependencies = [
"bstr 1.9.1",
"gix-trace",
"home",
"once_cell",
"thiserror",
]
[[package]]
name = "gix-pathspec"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea9f934a111e0efdf93ae06e3648427e60e783099fbebd6a53a7a2ffb10a1e65"
dependencies = [
"bitflags 2.5.0",
"bstr 1.9.1",
"gix-attributes",
"gix-config-value",
"gix-glob",
"gix-path",
"thiserror",
]
[[package]]
name = "gix-quote"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbff4f9b9ea3fa7a25a70ee62f545143abef624ac6aa5884344e70c8b0a1d9ff"
dependencies = [
"bstr 1.9.1",
"gix-utils",
"thiserror",
]
[[package]]
name = "gix-ref"
version = "0.43.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd4aba68b925101cb45d6df328979af0681364579db889098a0de75b36c77b65"
dependencies = [
"gix-actor",
"gix-date",
"gix-features",
"gix-fs",
"gix-hash",
"gix-lock",
"gix-object",
"gix-path",
"gix-tempfile",
"gix-utils",
"gix-validate",
"memmap2",
"thiserror",
"winnow 0.6.5",
]
[[package]]
name = "gix-refspec"
version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dde848865834a54fe4d9b4573f15d0e9a68eaf3d061b42d3ed52b4b8acf880b2"
dependencies = [
"bstr 1.9.1",
"gix-hash",
"gix-revision",
"gix-validate",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-revision"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e34196e1969bd5d36e2fbc4467d893999132219d503e23474a8ad2b221cb1e8"
dependencies = [
"bstr 1.9.1",
"gix-date",
"gix-hash",
"gix-hashtable",
"gix-object",
"gix-revwalk",
"gix-trace",
"thiserror",
]
[[package]]
name = "gix-revwalk"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7d393ae814eeaae41a333c0ff684b243121cc61ccdc5bbe9897094588047d"
dependencies = [
"gix-commitgraph",
"gix-date",
"gix-hash",
"gix-hashtable",
"gix-object",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-sec"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fddc27984a643b20dd03e97790555804f98cf07404e0e552c0ad8133266a79a1"
dependencies = [
"bitflags 2.5.0",
"gix-path",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "gix-submodule"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb7ea05666362472fecd44c1fc35fe48a5b9b841b431cc4f85b95e6f20c23ec"
dependencies = [
"bstr 1.9.1",
"gix-config",
"gix-path",
"gix-pathspec",
"gix-refspec",
"gix-url",
"thiserror",
]
[[package]]
name = "gix-tempfile"
version = "13.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a761d76594f4443b675e85928e4902dec333273836bd386906f01e7e346a0d11"
dependencies = [
"gix-fs",
"libc",
"once_cell",
"parking_lot 0.12.1",
"tempfile",
]
[[package]]
name = "gix-trace"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f924267408915fddcd558e3f37295cc7d6a3e50f8bd8b606cee0808c3915157e"
[[package]]
name = "gix-traverse"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4029ec209b0cc480d209da3837a42c63801dd8548f09c1f4502c60accb62aeb"
dependencies = [
"bitflags 2.5.0",
"gix-commitgraph",
"gix-date",
"gix-hash",
"gix-hashtable",
"gix-object",
"gix-revwalk",
"smallvec",
"thiserror",
]
[[package]]
name = "gix-url"
version = "0.27.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0db829ebdca6180fbe32be7aed393591df6db4a72dbbc0b8369162390954d1cf"
dependencies = [
"bstr 1.9.1",
"gix-features",
"gix-path",
"home",
"thiserror",
"url",
]
[[package]]
name = "gix-utils"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35192df7fd0fa112263bad8021e2df7167df4cc2a6e6d15892e1e55621d3d4dc"
dependencies = [
"bstr 1.9.1",
"fastrand 2.0.2",
"unicode-normalization",
]
[[package]]
name = "gix-validate"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e39fc6e06044985eac19dd34d474909e517307582e462b2eb4c8fa51b6241545"
dependencies = [
"bstr 1.9.1",
"thiserror",
]
[[package]]
name = "gix-worktree"
version = "0.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f06ca5dd164678914fc9280ba9d1ffeb66499ccc16ab1278c513828beee88401"
dependencies = [
"bstr 1.9.1",
"gix-attributes",
"gix-features",
"gix-fs",
"gix-glob",
"gix-hash",
"gix-ignore",
"gix-index",
"gix-object",
"gix-path",
]
[[package]]
name = "glib"
version = "0.15.12"
@ -2219,7 +2893,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
dependencies = [
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -2249,7 +2923,7 @@ checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
dependencies = [
"glib-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -2321,7 +2995,7 @@ dependencies = [
"gobject-sys",
"libc",
"pango-sys",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -2442,12 +3116,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.9"
@ -2469,6 +3137,15 @@ dependencies = [
"digest",
]
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "hostname"
version = "0.3.1"
@ -2990,6 +3667,15 @@ dependencies = [
"libc",
]
[[package]]
name = "kstring"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3066350882a1cd6d950d055997f379ac37fd39f81cd4d8ed186032eb3c5747"
dependencies = [
"static_assertions",
]
[[package]]
name = "kuchikiki"
version = "0.8.2"
@ -3046,12 +3732,13 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libredox"
version = "0.1.3"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
dependencies = [
"bitflags 2.5.0",
"libc",
"redox_syscall 0.4.1",
]
[[package]]
@ -3211,6 +3898,15 @@ version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memmap2"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322"
dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.7.1"
@ -3724,7 +4420,7 @@ dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]
@ -4200,6 +4896,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "prodash"
version = "28.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79"
[[package]]
name = "prost"
version = "0.12.3"
@ -4458,9 +5160,9 @@ dependencies = [
[[package]]
name = "redox_users"
version = "0.4.5"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4"
dependencies = [
"getrandom 0.2.12",
"libredox",
@ -5202,6 +5904,12 @@ dependencies = [
"digest",
]
[[package]]
name = "sha1_smol"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "sha2"
version = "0.10.8"
@ -5222,6 +5930,12 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shellexpand"
version = "3.1.0"
@ -5608,15 +6322,15 @@ dependencies = [
[[package]]
name = "system-deps"
version = "6.2.2"
version = "6.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
checksum = "2a2d580ff6a20c55dfb86be5f9c238f67835d0e81cbdea8bf5680e0897320331"
dependencies = [
"cfg-expr 0.15.7",
"heck 0.5.0",
"heck 0.4.1",
"pkg-config",
"toml 0.8.12",
"version-compare 0.2.0",
"version-compare 0.1.1",
]
[[package]]
@ -6422,6 +7136,12 @@ version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-bom"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217"
[[package]]
name = "unicode-ident"
version = "1.0.12"
@ -6523,9 +7243,9 @@ checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b"
[[package]]
name = "version-compare"
version = "0.2.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
[[package]]
name = "version_check"
@ -6723,7 +7443,7 @@ dependencies = [
"pango-sys",
"pkg-config",
"soup2-sys",
"system-deps 6.2.2",
"system-deps 6.2.0",
]
[[package]]

View File

@ -11,6 +11,7 @@ members = [
resolver = "2"
[workspace.dependencies]
gix = { version = "0.62.0", default-features = false, features = [] } # add performance features here as needed
git2 = { version = "0.18.3", features = ["vendored-openssl", "vendored-libgit2"] }
uuid = { version = "1.8.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }

View File

@ -23,6 +23,7 @@ fslock = "0.2.1"
futures = "0.3"
git2.workspace = true
git2-hooks = "0.3"
gix = { workspace = true, features = ["dirwalk"] }
itertools = "0.12"
lazy_static = "1.4.0"
md5 = "0.7.0"

View File

@ -1,6 +1,8 @@
use std::path::{Path, PathBuf};
use anyhow::Result;
use bstr::BString;
use gix::dir::walk::EmissionMode;
use walkdir::WalkDir;
// Returns an ordered list of relative paths for files inside a directory recursively.
@ -28,3 +30,21 @@ pub fn list_files<P: AsRef<Path>>(dir_path: P, ignore_prefixes: &[P]) -> Result<
files.sort();
Ok(files)
}
// Return an iterator of worktree-relative slash-separated paths for files inside the `worktree_dir`, recursively.
// Fails if the `worktree_dir` isn't a valid git repository.
pub fn iter_worktree_files(
worktree_dir: impl AsRef<Path>,
) -> Result<impl Iterator<Item = BString>> {
let repo = gix::open(worktree_dir.as_ref())?;
let index = repo.index_or_empty()?;
let disabled_interrupt_handling = Default::default();
let options = repo
.dirwalk_options()?
.emit_tracked(true)
.emit_untracked(EmissionMode::Matching);
Ok(repo
.dirwalk_iter(index, None::<&str>, disabled_interrupt_handling, options)?
.filter_map(Result::ok)
.map(|e| e.entry.rela_path))
}