pointbreak 0.6.0

Durable terminal code review for changes humans and coding agents collaborate on together
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
mod support;

use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

use serde_json::Value;
use support::git_repo::GitRepo;
use support::shore;

#[test]
fn revision_list_runs_at_top_level() {
    let repo = modified_repo();
    shore(["capture", "--repo", repo.path().to_str().unwrap()]);

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);

    assert!(
        output.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let json = parse_json(&output.stdout);
    assert_eq!(json["schema"], "pointbreak.review-revision-list");
}

#[test]
fn revision_list_object_filter_resolves_a_short_id() {
    let repo = modified_repo();
    shore(["capture", "--repo", repo.path().to_str().unwrap()]);
    let path = repo.path().to_str().unwrap();

    let listed = parse_json(&shore(["revision", "list", "--repo", path]).stdout);
    let object_id = listed["entries"][0]["objectId"]
        .as_str()
        .unwrap()
        .to_owned();
    // object_id = "obj:sha256:<hex>"; form the prefixed short id from the digest.
    let digest = object_id.rsplit_once("sha256:").unwrap().1;
    let prefixed_short = format!("obj:{}", &digest[..8]);

    let filtered = shore([
        "revision",
        "list",
        "--repo",
        path,
        "--object",
        &prefixed_short,
    ]);
    assert!(
        filtered.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&filtered.stderr)
    );
    let json = parse_json(&filtered.stdout);
    assert_eq!(json["revisionCount"], 1);
    // The listing lens filtered on the resolved FULL object id.
    assert_eq!(json["entries"][0]["objectId"], object_id);
}

#[test]
fn revision_list_emits_v1_json_with_freshness_metadata() {
    let repo = modified_repo();
    let capture = parse_json(&shore(["capture", "--repo", repo.path().to_str().unwrap()]).stdout);

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);

    assert!(
        output.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let json = parse_json(&output.stdout);

    assert_eq!(json["schema"], "pointbreak.review-revision-list");
    assert_eq!(json["version"], 1);
    assert!(
        json["eventSetHash"]
            .as_str()
            .unwrap()
            .starts_with("sha256:")
    );
    assert_eq!(json["eventCount"], 2);
    assert_eq!(json["revisionCount"], 1);

    let entry = &json["entries"][0];
    assert_eq!(entry["revisionId"], capture["revision"]["id"]);
    assert!(!entry["capturedAt"].as_str().unwrap().is_empty());
    assert!(entry["revisionId"].as_str().unwrap().starts_with("rev:"));
    assert!(entry["objectId"].as_str().unwrap().starts_with("obj:"));
    assert!(entry["source"].is_object());
    assert!(entry["base"].is_object());
    assert!(entry["target"].is_object());
    assert!(
        entry["objectArtifactContentHash"]
            .as_str()
            .unwrap()
            .starts_with("sha256:")
    );
}

#[test]
fn revision_list_does_not_expose_storage_paths() {
    let repo = modified_repo();
    shore(["capture", "--repo", repo.path().to_str().unwrap()]);

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);
    let stdout = String::from_utf8_lossy(&output.stdout);
    let json = parse_json(&output.stdout);

    assert!(!stdout.contains(".shore/data/events"));
    assert!(!stdout.contains("artifacts/"));
    assert!(json.get("statePath").is_none());
    assert!(json["entries"][0].get("payloadHash").is_none());
    assert!(json["entries"][0].get("eventId").is_none());
}

#[test]
fn revision_list_json_pretty_prints() {
    let repo = modified_repo();
    shore(["capture", "--repo", repo.path().to_str().unwrap()]);

    let output = shore([
        "revision",
        "list",
        "--repo",
        repo.path().to_str().unwrap(),
        "--format",
        "json-pretty",
    ]);

    assert!(String::from_utf8_lossy(&output.stdout).starts_with("{\n"));
}

#[test]
fn revision_list_returns_multiple_entries_in_capture_order() {
    let repo = modified_repo();
    let first = parse_json(&shore(["capture", "--repo", repo.path().to_str().unwrap()]).stdout);
    repo.write("src/lib.rs", "pub fn value() -> u32 { 3 }\n");
    let second = parse_json(&shore(["capture", "--repo", repo.path().to_str().unwrap()]).stdout);

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);
    let json = parse_json(&output.stdout);
    let entries = json["entries"].as_array().unwrap();

    assert_ne!(first["revision"]["id"], second["revision"]["id"]);
    assert_eq!(json["revisionCount"], 2);
    assert_eq!(entries.len(), 2);
    let ids: Vec<&str> = entries
        .iter()
        .map(|entry| entry["revisionId"].as_str().unwrap())
        .collect();
    assert!(ids.contains(&first["revision"]["id"].as_str().unwrap()));
    assert!(ids.contains(&second["revision"]["id"].as_str().unwrap()));
    assert!(
        entries[0]["capturedAt"].as_str().unwrap() <= entries[1]["capturedAt"].as_str().unwrap()
    );
}

#[test]
fn revision_list_succeeds_without_events() {
    let repo = GitRepo::new();

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);
    let json = parse_json(&output.stdout);

    assert!(output.status.success());
    assert_eq!(json["eventCount"], 0);
    assert_eq!(json["revisionCount"], 0);
    assert!(json["entries"].as_array().unwrap().is_empty());
}

#[test]
fn revision_list_reads_capture_from_the_shared_store_after_seed_worktree_removed() {
    let fixture = CloneWorktreeFixture::new();
    fs::write(fixture.seed.join("README.md"), "changed in seed\n").unwrap();
    let capture = parse_json(&shore(["capture", "--repo", fixture.seed.to_str().unwrap()]).stdout);

    // The capture wrote through to the shared common-dir store; removing the seed
    // worktree cannot strand the record. No `store link` step.
    run_git_os(
        fixture.main.path(),
        [
            OsString::from("worktree"),
            OsString::from("remove"),
            OsString::from("--force"),
            fixture.seed.as_os_str().to_owned(),
        ],
    );
    let reader = fixture.add_worktree("reader");
    assert!(!reader.join(".shore/data/events").exists());

    let output = shore(["revision", "list", "--repo", reader.to_str().unwrap()]);
    assert!(
        output.status.success(),
        "list stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let stdout = String::from_utf8(output.stdout).unwrap();
    let json = parse_json(stdout.as_bytes());

    assert_eq!(json["eventCount"], 2);
    assert_eq!(json["revisionCount"], 1);
    assert_eq!(json["entries"][0]["revisionId"], capture["revision"]["id"]);
    assert!(json["diagnostics"].as_array().unwrap().is_empty());
    assert!(!stdout.contains(".git"));
    assert!(!stdout.contains(".shore/data"));
}

#[test]
fn revision_list_omits_ambient_ambiguous_current_diagnostic_from_shared_store() {
    let fixture = CloneWorktreeFixture::new();
    fs::write(fixture.seed.join("README.md"), "changed once\n").unwrap();
    let first = parse_json(&shore(["capture", "--repo", fixture.seed.to_str().unwrap()]).stdout);
    fs::write(fixture.seed.join("README.md"), "changed twice\n").unwrap();
    let second = parse_json(&shore(["capture", "--repo", fixture.seed.to_str().unwrap()]).stdout);

    // Both captures wrote through to the shared common-dir store; a sibling reader
    // sees them with no `store link` step.
    let reader = fixture.add_worktree("reader");

    let output = shore(["revision", "list", "--repo", reader.to_str().unwrap()]);
    assert!(
        output.status.success(),
        "list stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let json = parse_json(&output.stdout);
    let ids = json["entries"]
        .as_array()
        .unwrap()
        .iter()
        .map(|entry| entry["revisionId"].as_str().unwrap())
        .collect::<Vec<_>>();

    assert_ne!(first["revision"]["id"], second["revision"]["id"]);
    assert_eq!(json["eventCount"], 4);
    assert_eq!(json["revisionCount"], 2);
    assert!(ids.contains(&first["revision"]["id"].as_str().unwrap()));
    assert!(ids.contains(&second["revision"]["id"].as_str().unwrap()));
    assert!(
        !json["diagnostics"]
            .as_array()
            .unwrap()
            .iter()
            .any(|diagnostic| {
                diagnostic["code"].as_str() == Some("ambiguous_current_revision")
            }),
        "routine Revision list should not emit ambient current ambiguity diagnostics"
    );
}

#[test]
fn unit_list_renders_commit_range_source_without_paths() {
    let repo = support::committed_repo();
    shore([
        "capture",
        "--repo",
        repo.path().to_str().unwrap(),
        "--base",
        "HEAD~1",
    ]);

    let output = shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]);
    assert!(
        output.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    let stdout = String::from_utf8_lossy(&output.stdout);
    let json = parse_json(&output.stdout);

    let entry = &json["entries"][0];
    assert_eq!(entry["source"]["kind"], "git_commit_range");
    assert_eq!(entry["source"]["mode"], "base_tree_to_target_tree");
    assert_eq!(entry["base"]["kind"], "git_commit");
    assert_eq!(entry["target"]["kind"], "git_commit");
    assert!(
        !stdout.contains("worktreeRoot"),
        "range capture unit list must not expose a worktree path"
    );
}

#[test]
fn unit_list_hides_orphans_by_default_and_surfaces_with_flags() {
    let repo = GitRepo::new();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 1 }\n");
    repo.commit_all("base");

    // A range capture anchored to a commit on a soon-deleted branch → orphan.
    repo.git(["checkout", "-b", "feature"]);
    repo.write("src/lib.rs", "pub fn value() -> u32 { 2 }\n");
    repo.commit_all("feature work");
    let orphan = parse_json(
        &shore([
            "capture",
            "--repo",
            repo.path().to_str().unwrap(),
            "--base",
            "main",
        ])
        .stdout,
    );
    let orphan_id = orphan["revision"]["id"].as_str().unwrap().to_owned();
    repo.git(["checkout", "main"]);
    repo.git(["branch", "-D", "feature"]);

    // A floating worktree capture on main → never hidden.
    repo.write("src/lib.rs", "pub fn value() -> u32 { 3 }\n");
    let floating = parse_json(&shore(["capture", "--repo", repo.path().to_str().unwrap()]).stdout);
    let floating_id = floating["revision"]["id"].as_str().unwrap().to_owned();
    assert_ne!(orphan_id, floating_id);

    // Default: the orphan is hidden, the floating capture remains.
    let default_ids = unit_list_ids(&repo, &[]);
    assert!(default_ids.contains(&floating_id));
    assert!(!default_ids.contains(&orphan_id));

    // --all surfaces both.
    let all_ids = unit_list_ids(&repo, &["--all"]);
    assert!(all_ids.contains(&orphan_id));
    assert!(all_ids.contains(&floating_id));

    // --orphans surfaces only the orphan.
    assert_eq!(
        unit_list_ids(&repo, &["--orphans"]),
        vec![orphan_id.clone()]
    );

    // --orphans takes precedence over --all.
    assert_eq!(
        unit_list_ids(&repo, &["--orphans", "--all"]),
        vec![orphan_id]
    );
}

#[test]
fn unit_list_attaches_merge_status_and_accepts_integration_and_worktree_flags() {
    let repo = GitRepo::new();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 1 }\n");
    repo.commit_all("base");
    repo.write("src/lib.rs", "pub fn value() -> u32 { 2 }\n");
    repo.commit_all("second");
    let repo_arg = repo.path().to_str().unwrap();

    // A range capture anchored to HEAD — the default branch's tip — reads
    // "merged": with no explicit --integration-ref the list narrows to the
    // repository's detected default branch, the same default `revision show`
    // applies, and tip equality counts as landed (#466).
    let range = parse_json(&shore(["capture", "--repo", repo_arg, "--base", "HEAD~1"]).stdout);
    let range_id = range["revision"]["id"].as_str().unwrap().to_owned();

    // A floating worktree capture reads "unknown"; its worktree path lets it
    // survive the worktree-identity scope.
    repo.write("src/lib.rs", "pub fn value() -> u32 { 3 }\n");
    let worktree = parse_json(&shore(["capture", "--repo", repo_arg]).stdout);
    let worktree_id = worktree["revision"]["id"].as_str().unwrap().to_owned();

    // Default list: each entry carries a structural merge-status.
    let default = parse_json(&shore(["revision", "list", "--repo", repo_arg]).stdout);
    let status_for = |id: &str| -> String {
        default["entries"]
            .as_array()
            .unwrap()
            .iter()
            .find(|entry| entry["revisionId"] == id)
            .unwrap()["mergeStatus"]
            .as_str()
            .unwrap()
            .to_owned()
    };
    assert_eq!(status_for(&range_id), "merged");
    assert_eq!(status_for(&worktree_id), "unknown");

    // --integration-ref and --worktree parse; the worktree-identity scope keeps
    // the worktree capture.
    let scoped = shore([
        "revision",
        "list",
        "--repo",
        repo_arg,
        "--integration-ref",
        "refs/heads/main",
        "--worktree",
        repo_arg,
    ]);
    assert!(
        scoped.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&scoped.stderr)
    );
    let scoped_ids: Vec<String> = parse_json(&scoped.stdout)["entries"]
        .as_array()
        .unwrap()
        .iter()
        .map(|entry| entry["revisionId"].as_str().unwrap().to_owned())
        .collect();
    assert!(scoped_ids.contains(&worktree_id));
}

/// The merge-status `revision list` reports for `revision_id`.
fn unit_list_merge_status(repo: &GitRepo, revision_id: &str) -> String {
    let listed =
        parse_json(&shore(["revision", "list", "--repo", repo.path().to_str().unwrap()]).stdout);
    listed["entries"]
        .as_array()
        .unwrap()
        .iter()
        .find(|entry| entry["revisionId"] == revision_id)
        .unwrap_or_else(|| panic!("revision {revision_id} not listed: {listed}"))["mergeStatus"]
        .as_str()
        .unwrap()
        .to_owned()
}

#[test]
fn unit_list_reads_merged_for_landed_capture_with_deleted_source_branch() {
    let repo = GitRepo::new();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 1 }\n");
    repo.commit_all("base");
    let repo_arg = repo.path().to_str().unwrap();

    // Capture a committed range on a feature branch.
    repo.git(["checkout", "-b", "feature"]);
    repo.write("src/lib.rs", "pub fn value() -> u32 { 2 }\n");
    repo.commit_all("change");
    let captured = parse_json(&shore(["capture", "--repo", repo_arg, "--base", "main"]).stdout);
    let revision_id = captured["revision"]["id"].as_str().unwrap().to_owned();

    // Land it: a follow-up commit, fast-forward main to the branch tip, record
    // the landed commit on the same revision, delete the source branch. The
    // associated commit IS main's tip and no other ref contains it — the most
    // recently landed revision, which broad reachability misreads as a live tip.
    repo.write("src/lib.rs", "pub fn value() -> u32 { 3 }\n");
    repo.commit_all("follow-up");
    repo.git(["checkout", "main"]);
    repo.git(["merge", "--ff-only", "feature"]);
    let record = shore([
        "association",
        "record",
        "--repo",
        repo_arg,
        "--track",
        "agent:codex",
        "--revision",
        &revision_id,
        "--commit",
        "HEAD",
    ]);
    assert!(
        record.status.success(),
        "association record failed: {}",
        String::from_utf8_lossy(&record.stderr)
    );
    repo.git(["branch", "-D", "feature"]);

    // The default list narrows to the detected default branch, so the landed
    // tip reads "merged" — agreeing with `revision show`'s liveness headline.
    assert_eq!(unit_list_merge_status(&repo, &revision_id), "merged");

    // A live unmerged branch still reads "open" under the narrow default.
    repo.git(["checkout", "-b", "unmerged"]);
    repo.write("src/lib.rs", "pub fn value() -> u32 { 4 }\n");
    repo.commit_all("unmerged change");
    let open = parse_json(&shore(["capture", "--repo", repo_arg, "--base", "main"]).stdout);
    let open_id = open["revision"]["id"].as_str().unwrap().to_owned();
    assert_eq!(unit_list_merge_status(&repo, &open_id), "open");
}

#[test]
fn unit_list_keeps_broad_merge_status_without_a_detectable_default_branch() {
    let repo = support::committed_repo();
    // No origin/HEAD and neither `main` nor `master` exists: there is no
    // detectable default branch, so merge-status keeps broad reachability.
    repo.git(["branch", "-m", "main", "trunk"]);
    let repo_arg = repo.path().to_str().unwrap();

    let range = parse_json(&shore(["capture", "--repo", repo_arg, "--base", "HEAD~1"]).stdout);
    let range_id = range["revision"]["id"].as_str().unwrap().to_owned();

    // The trunk tip is live and no other ref contains it → broad reads "open".
    assert_eq!(unit_list_merge_status(&repo, &range_id), "open");
}

#[test]
fn unit_list_reads_side_branch_only_landing_as_orphaned_but_still_shown() {
    // A commit landed only onto a NON-default live branch: orphan visibility
    // stays broad (reachable from develop → the entry is shown), while the
    // narrow default integration ref classifies it off the default branch —
    // the same answer `revision show` gives. Locks the intended semantics.
    let repo = GitRepo::new();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 1 }\n");
    repo.commit_all("base");
    let repo_arg = repo.path().to_str().unwrap();

    // Capture commit C at develop's tip, then advance develop past C so C is
    // interior: reachable from develop, not from main, and not itself a tip.
    repo.git(["checkout", "-b", "develop"]);
    repo.write("src/lib.rs", "pub fn value() -> u32 { 2 }\n");
    repo.commit_all("change");
    let captured = parse_json(&shore(["capture", "--repo", repo_arg, "--base", "main"]).stdout);
    let revision_id = captured["revision"]["id"].as_str().unwrap().to_owned();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 3 }\n");
    repo.commit_all("develop advance");
    repo.git(["checkout", "main"]);

    // Shown by the default list (the helper panics when the entry is absent),
    // with the narrow merge-status.
    assert_eq!(unit_list_merge_status(&repo, &revision_id), "orphaned");

    // Not a broad orphan: `--orphans` (broad reachability) excludes it.
    assert!(!unit_list_ids(&repo, &["--orphans"]).contains(&revision_id));
}

/// Run `revision list` with extra flags and return the entry ids in order.
fn unit_list_ids(repo: &GitRepo, extra: &[&str]) -> Vec<String> {
    let mut args: Vec<String> = vec![
        "revision".to_owned(),
        "list".to_owned(),
        "--repo".to_owned(),
        repo.path().to_str().unwrap().to_owned(),
    ];
    args.extend(extra.iter().map(|flag| (*flag).to_owned()));
    let output = shore(args);
    assert!(
        output.status.success(),
        "stderr:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );
    parse_json(&output.stdout)["entries"]
        .as_array()
        .unwrap()
        .iter()
        .map(|entry| entry["revisionId"].as_str().unwrap().to_owned())
        .collect()
}

fn parse_json(bytes: &[u8]) -> Value {
    serde_json::from_slice(bytes).expect("parse CLI JSON")
}

fn modified_repo() -> GitRepo {
    let repo = GitRepo::new();
    repo.write("src/lib.rs", "pub fn value() -> u32 { 1 }\n");
    repo.commit_all("base");
    repo.write("src/lib.rs", "pub fn value() -> u32 { 2 }\n");
    repo
}

struct CloneWorktreeFixture {
    main: GitRepo,
    _worktree_parent: tempfile::TempDir,
    seed: PathBuf,
}

impl CloneWorktreeFixture {
    fn new() -> Self {
        let main = GitRepo::new();
        main.write("README.md", "base\n");
        main.commit_all("base");

        let worktree_parent = tempfile::tempdir().expect("create worktree parent");
        let seed = worktree_parent.path().join("seed");
        add_worktree(main.path(), &seed, "seed");

        Self {
            main,
            _worktree_parent: worktree_parent,
            seed,
        }
    }

    fn add_worktree(&self, branch: &str) -> PathBuf {
        let path = self._worktree_parent.path().join(branch);
        add_worktree(self.main.path(), &path, branch);
        path
    }
}

fn add_worktree(repo: &Path, path: &Path, branch: &str) {
    run_git_os(
        repo,
        [
            OsString::from("worktree"),
            OsString::from("add"),
            OsString::from("-b"),
            OsString::from(branch),
            path.as_os_str().to_owned(),
        ],
    );
}

fn run_git_os<I>(cwd: &Path, args: I)
where
    I: IntoIterator<Item = OsString>,
{
    let output = Command::new("git")
        .args(args)
        .current_dir(cwd)
        .output()
        .unwrap_or_else(|error| panic!("run git in {}: {error}", cwd.display()));
    assert!(
        output.status.success(),
        "git failed in {}\nstdout:\n{}\nstderr:\n{}",
        cwd.display(),
        String::from_utf8_lossy(&output.stdout),
        String::from_utf8_lossy(&output.stderr)
    );
}