|
| 1 | +--- |
| 2 | +marp: true |
| 3 | +theme: gaia |
| 4 | +_class: lead |
| 5 | +paginate: false |
| 6 | +backgroundColor: white |
| 7 | +--- |
| 8 | + |
| 9 | +<style> |
| 10 | + :root { |
| 11 | + --color-foreground: #333; |
| 12 | + --color-highlight: #dea584; |
| 13 | + } |
| 14 | + a { |
| 15 | + --color-highlight: #aaa; |
| 16 | + } |
| 17 | +</style> |
| 18 | + |
| 19 | +# **Gitoxide** |
| 20 | + |
| 21 | +**What it is, and isn't** |
| 22 | + |
| 23 | +https://github.com/Byron/gitoxide |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +# Terms |
| 30 | + |
| 31 | +* `git2` - A Rust crate wrapping `libgit2` |
| 32 | +* `libgit2` |
| 33 | + - needs no introduction 🙇♂️ |
| 34 | +* Git - the mothership :ship: |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +<!-- _class: "lead" --> |
| 39 | + |
| 40 | +# **Gitoxide** |
| 41 | +### **is** |
| 42 | + |
| 43 | +**the high-performance Rust crate that acts like Git would** |
| 44 | + |
| 45 | +<!-- benefits clients, no need to re-implement stuff users expect from you --> |
| 46 | +<!-- respect configuration, but allow overrides --> |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +<!-- _class: "lead" --> |
| 51 | + |
| 52 | +# **Gitoxide** |
| 53 | +### **is** |
| 54 | + |
| 55 | +**the binaries `gix` and `ein`** |
| 56 | + |
| 57 | +<!-- `gix` dev tool, `ein` client + tooling --> |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +<!-- _class: "lead" --> |
| 62 | + |
| 63 | +# **`Gi`to`x`ide** |
| 64 | +### **isn't** |
| 65 | + |
| 66 | +**a Git replica** |
| 67 | + |
| 68 | +<!-- `gix` will never be `git`, never stable, won't mimmick it --> |
| 69 | +<!-- But `gitoxide` should be versatile enough to implement the majority of Git --> |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +<!-- _class: "lead" --> |
| 74 | + |
| 75 | +# **Gitoxide** |
| 76 | +### **isn't** |
| 77 | + |
| 78 | +**always quite as easy-to-use as `git2`** |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +<!-- _class: "lead" --> |
| 83 | + |
| 84 | +# **Gitoxide** |
| 85 | +### **isn't** |
| 86 | + |
| 87 | +**usable from any other language but Rust** |
| 88 | + |
| 89 | +<!-- in great contrast to `git2` --> |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +<!-- _class: "lead" --> |
| 94 | + |
| 95 | +# **Gitoxide** |
| 96 | +### **isn't** |
| 97 | + |
| 98 | +**stable (yet)** |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +# Aspirations of **Gitoxide** :star: |
| 103 | + |
| 104 | +* be the go-to Git library for anyone, usable from any language |
| 105 | +* be the best choice for large monorepos |
| 106 | +* power an entire Git forge |
| 107 | + * most-efficient on server |
| 108 | +* be the first with new (experimental) Git features |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +# Why would you use **Gitoxide** :question: |
| 113 | + |
| 114 | +- new project with Git integration, `gitoxide` features suffice |
| 115 | + * or you want to contribute what's missing |
| 116 | + * and you can figure out how to use it (`gix::Repository`) |
| 117 | +* need Git-level repository compatbility |
| 118 | +* need to read from untrusted repositories |
| 119 | +* need next-level performance and fearless concurrency |
| 120 | +* you deal with massive monorepos |
| 121 | + |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +# **Gitoxide** includes |
| 126 | + |
| 127 | +- read & write thread-safe & lock-free object database |
| 128 | + * decode and encode all object types |
| 129 | + * *also step-wise* |
| 130 | +* read + write ref-database |
| 131 | +* lossless git-config reading and writing |
| 132 | +* read and write index |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +# **Gitoxide** includes |
| 137 | + |
| 138 | +- .gitignore (with *precious* files) & .gitattributes |
| 139 | +* pathspecs: `/**hello.*` |
| 140 | +* revspecs: `@~1` |
| 141 | +* refspecs: `refs/heads/*:refs/remotes/origin/*` |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +# **Gitoxide** includes |
| 146 | + |
| 147 | +- read commit-graphs and use them for traversals |
| 148 | + * describe commit |
| 149 | + * find merge-base |
| 150 | + * perform fetch negotiations |
| 151 | +* rev-parse |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +# **Gitoxide** includes |
| 156 | + |
| 157 | +- diff |
| 158 | + - tree-tree |
| 159 | + - index-worktree |
| 160 | + - (*missing*: tree-index) |
| 161 | +* find untracked files/classify worktree |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +# **Gitoxide** includes |
| 166 | + |
| 167 | +- (shallow) fetch |
| 168 | + - ssh |
| 169 | + - http/https |
| 170 | + - git-native |
| 171 | +* first checkout after fetch |
| 172 | + - with built-in filters |
| 173 | + - with custom filters (all protocols) |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +# **Gitoxide** lacks |
| 182 | + |
| 183 | +- *full* status (tree-index diff missing) |
| 184 | +* commit (index-add, index-to-tree) |
| 185 | +* merge (*WIP*) |
| 186 | +* push (but can build packs by object-copy) |
| 187 | +* rebase |
| 188 | +* cherry-pick |
| 189 | +* reset/checkout |
| 190 | +* blame (but [WIP](https://github.com/Byron/gitoxide/pull/1453)) |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +# Principles during Development |
| 195 | + |
| 196 | +## **Correctness** |
| 197 | + |
| 198 | +* baseline tests with Git where possible |
| 199 | +* fence-post tests (at least) |
| 200 | +* leave notes and TODOs if corners were cut |
| 201 | +* fuzzing of parsers |
| 202 | + |
| 203 | +--- |
| 204 | +# Principles during Development |
| 205 | + |
| 206 | +## **Performance** |
| 207 | + |
| 208 | +* be mindful about allocations |
| 209 | +* stepwise computation when feasible |
| 210 | +* optional multi-threading where possible |
| 211 | + |
| 212 | +--- |
| 213 | + |
| 214 | +# Principles during Development |
| 215 | + |
| 216 | +## **Everything Else** |
| 217 | + |
| 218 | +- progress-reporting and are interrupt-handling |
| 219 | +* easy-to-use API without hiding any knob |
| 220 | +* `async`-support for networked IO |
| 221 | +* [exhaustive docs](https://docs.rs/gix/latest/gix/) |
| 222 | +* **Security** |
| 223 | + - by Eliah Kagan (and sponsored by the **Radicle Foundation**) |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +## Bonus Round: API still needs improvements |
| 228 | + |
| 229 | +Real world code written by a readl API user, courtesy of GitButler. |
| 230 | + |
| 231 | +--- |
| 232 | + |
| 233 | +## Bonus Round: API still needs improvements |
| 234 | + |
| 235 | +### **git2** |
| 236 | +```Rust |
| 237 | +#[tauri::command(async)] |
| 238 | +pub fn git_clone_repository(repository_url: &str, target_dir: &Path) -> Result<(), Error> { |
| 239 | + git2::Repository::clone(repository_url, target_dir).context("Cloning failed")?; |
| 240 | + Ok(()) |
| 241 | +} |
| 242 | +``` |
| 243 | + |
| 244 | +--- |
| 245 | + |
| 246 | +## Bonus Round: API still needs improvements |
| 247 | + |
| 248 | +### **Gitoxide** |
| 249 | + |
| 250 | +```Rust |
| 251 | +#[tauri::command(async)] |
| 252 | +pub fn git_clone_repository(repository_url: &str, target_dir: &Path) -> Result<(), Error> { |
| 253 | + let url = |
| 254 | + gix::url::parse(repository_url.into()).context("Failed to parse repository URL")?; |
| 255 | + let should_interrupt = AtomicBool::new(false); |
| 256 | + let mut prepared_clone = |
| 257 | + gix::prepare_clone(url, target_dir).context("Failed to prepare clone")?; |
| 258 | + let (mut prepared_checkout, _) = prepared_clone |
| 259 | + .fetch_then_checkout(Discard, &should_interrupt) |
| 260 | + .context("Failed to fetch")?; |
| 261 | + let should_interrupt = AtomicBool::new(false); |
| 262 | + prepared_checkout |
| 263 | + .main_worktree(Discard, &should_interrupt) |
| 264 | + .context("Failed to checkout main worktree")?; |
| 265 | + Ok(()) |
| 266 | +} |
| 267 | +``` |
| 268 | + |
| 269 | +--- |
| 270 | + |
| 271 | +## Bonus Round: API still needs improvements |
| 272 | + |
| 273 | +### **Gitoxide** - less noisy |
| 274 | + |
| 275 | +```Rust |
| 276 | +#[tauri::command(async)] |
| 277 | +pub fn git_clone_repository(repository_url: &str, target_dir: &Path) -> Result<(), Error> { |
| 278 | + let url = gix::url::parse(repository_url.into()).map_err(anyhow::Error::from)?; |
| 279 | + let should_interrupt = AtomicBool::new(false); |
| 280 | + |
| 281 | + let (mut checkout, _outcome) = gix::prepare_clone(url, target_dir) |
| 282 | + .map_err(anyhow::Error::from)? |
| 283 | + .fetch_then_checkout(Discard, &should_interrupt) |
| 284 | + .map_err(anyhow::Error::from)?; |
| 285 | + checkout |
| 286 | + .main_worktree(Discard, &should_interrupt) |
| 287 | + .map_err(anyhow::Error::from)?; |
| 288 | + Ok(()) |
| 289 | +} |
| 290 | +``` |
| 291 | +--- |
| 292 | + |
| 293 | +## Bonus Round: API still needs improvements |
| 294 | + |
| 295 | +### **Gitoxide** - *even* less noisy |
| 296 | + |
| 297 | +```Rust |
| 298 | +#[tauri::command(async)] |
| 299 | +pub fn git_clone_repository(repository_url: &str, target_dir: &Path) -> Result<(), UnmarkedError> { |
| 300 | + let should_interrupt = AtomicBool::new(false); |
| 301 | + |
| 302 | + gix::prepare_clone(repository_url, target_dir)? |
| 303 | + .fetch_then_checkout(gix::progress::Discard, &should_interrupt) |
| 304 | + .map(|(checkout, _outcome)| checkout)? |
| 305 | + .main_worktree(gix::progress::Discard, &should_interrupt)?; |
| 306 | + Ok(()) |
| 307 | +} |
| 308 | + |
| 309 | +```` |
0 commit comments