Git Explorer
src/core/patch.ts +6 -3
[1] Status UNSTAGED CHANGES
main ↑1 @@ -1,27 +1,30 @@
1 staged 3 changed 1 new 1 import { parseHunks } from "./parse"; 1 import { parseHunks } from "./parse";
2 import type { Mode } from "./types"; 2 import type { Mode } from "./types";
[2] Files Worktrees Submodules 1/5 3 import { buildPatch, emptyPlan, headerF 3 import { buildPatch, emptyPlan, headerF
.M src/core/patch.ts +6 -3 or, keepSide, renderHunk } from "./plan or, keepSide, renderHunk } from "./plan
.M src/core/rebase.ts +4 -1 "; ";
A. src/lib/cells.ts +11 4 4
.M src/ui/App.tsx +3 5 /** Minimal patch for the selected 5 /** Minimal patch for the selected
.? notes.md +2 6 * hunks or lines. */ 6 * hunks or lines. */
7 export function buildSelection( 7 export function buildSelection(
8 file: string, 8 file: string,
9 patch: string, 9 patch: string,
[3] Branches Remotes Tags 10 mode: Mode, 10 mode: Mode,
* main ↑1 4 days ago 11 ) { 11 ) {
12 const hunks = parseHunks(patch); 12 const hunks = parseHunks(patch);
13 - if (!hunks.length) return null; 13 + if (!hunks.length) {
14 + return emptyPlan(file);
15 + }
16 + const keep = keepSide(mode);
14 17
[4] Commits Reflog 15 const picked = hunks.filter( 18 const picked = hunks.filter(
5a20078 ○ move commit up/down in th. 16 (hunk) => hunk.selected, 19 (hunk) => hunk.selected,
b36d19b ○ parity trio: a select-all. 17 ); 20 );
1bd0580 ○ rebase menu + B mark for . 18 if (!picked.length) { 21 if (!picked.length) {
c7dd0bf ○ ci: embed fff on Linux 19 throw new Error("nothing picked"); 22 throw new Error("nothing picked");
20 } 23 }
21 24
22 const header = headerFor(file, mode); 25 const header = headerFor(file, mode);
23 const texts = picked.map((hunk) => 26 const texts = picked.map((hunk) =>
[5] Stash 24 - renderHunk(hunk, mode), 27 + renderHunk(hunk, keep),
On main: wip: grep worker 25 ); 28 );
26 - return hunks.join("\n"); 29 + return buildPatch(header, texts);
27 } 30 }
space stage/unstage · a toggle all · d discard · s stash · enter edit hunks · ctrl+v view file · ]/[ tab