OXYGENHUB

Partial commits: a chosen addition hunk carries the new node's content, so a new file is never committed empty d8c086ca3eb2

Author
Andy McCall @andymccall <[email protected]>
When
· 2026-09-27 15:47 UTC
Signature
✔ signed by Andy McCall
Hash
d8c086ca3eb21f1c4e721408bb9c05cbc98085ddbe200b7492e895c11f3f2d15
Depends on
957fee30826e 982864068a59
Depended on by
75167672ebcd
In bookmarks
agents-in-readme bare-hashes carried-not-removed carry-identical doctor-trust identical-sides keyless-tags main merge-remote-bookmark only-help-103 paths-for-resolutions-and-amend push-notes show-stat subrepo-pin-state switch-says
In tags
v0.1.0 v0.10.0 v0.11.0 v0.2.0 v0.3.0 v0.3.1 v0.4.0 v0.4.1 v0.4.2 v0.4.3 v0.4.4 v0.4.5 v0.4.6 v0.5.0 v0.5.1 v0.6.0 v0.7.0 v0.8.0 v0.9.0
Edits
4 atoms, 0 tree operations, 2 files

Browse the tree at this change

modified crates/oxy-core/src/repo/snapshot.rs +9 −1
…
491 unchanged lines
492 492
            if !ops_sel[i] {
493 493
                continue;
494 494
            }
495 -
            if let TreeOp::AddNode { parent, .. } = &wc.tree_ops[i] {
495 +
            if let TreeOp::AddNode { node, parent, .. } = &wc.tree_ops[i] {
496 496
                if let Some(&p) = add_index.get(parent) {
497 497
                    if !ops_sel[p] {
498 498
                        ops_sel[p] = true;
499 499
                        changed = true;
500 500
                    }
501 501
                }
502 +
                // A new node's content belongs with its addition: nobody
503 +
                // wants an empty file committed apart from its lines.
504 +
                for (j, e) in wc.edits.iter().enumerate() {
505 +
                    if e.node() == *node && !edits_sel[j] {
506 +
                        edits_sel[j] = true;
507 +
                        changed = true;
508 +
                    }
509 +
                }
502 510
            }
503 511
        }
504 512
        for j in 0..wc.edits.len() {
…
604 unchanged lines
modified crates/oxy-core/src/repo/tests.rs +8 −0
…
2356 unchanged lines
2357 2357
    assert_eq!(c3.tree_ops.len(), 2, "{:?}", c3.tree_ops);
2358 2358
    let files = repo.load_state(&[h3]).unwrap().materialize().files;
2359 2359
    assert!(files.contains_key("d/e.txt") && !files.contains_key("c.txt"));
2360 +
    // Choosing a new file's addition hunk brings its content along.
2361 +
    write(root, "f/g.txt", b"g\n");
2362 +
    let (_, hunks) = repo.hunks().unwrap();
2363 +
    let g_add = hunks.iter().find(|h| h.path == "f/g.txt" && h.text.starts_with("A ")).unwrap().index;
2364 +
    let h4 = repo.commit_selection("g by addition", &[], &Selection::Hunks(vec![g_add])).unwrap();
2365 +
    let files = repo.load_state(&[h4]).unwrap().materialize().files;
2366 +
    assert!(matches!(&files["f/g.txt"].content, FileContent::Text { bytes, .. } if bytes == b"g\n"));
2367 +
    assert!(!repo.snapshot("status").unwrap().statuses.iter().any(|s| s.path == "f/g.txt"));
2360 2368
    // Everything left commits normally; the working copy is then clean.
2361 2369
    repo.commit("the rest", &[]).unwrap();
2362 2370
    assert!(!repo.snapshot("status").unwrap().changed);
…
93 unchanged lines