@statewalker/vcs-commands 0.3.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +19 -0
  2. package/dist/commands/add-command.d.ts +0 -6
  3. package/dist/commands/add-command.d.ts.map +1 -1
  4. package/dist/commands/blame-command.d.ts +14 -0
  5. package/dist/commands/blame-command.d.ts.map +1 -1
  6. package/dist/commands/branch-command.d.ts.map +1 -1
  7. package/dist/commands/checkout-command.d.ts +7 -24
  8. package/dist/commands/checkout-command.d.ts.map +1 -1
  9. package/dist/commands/clean-command.d.ts +34 -4
  10. package/dist/commands/clean-command.d.ts.map +1 -1
  11. package/dist/commands/clone-command.d.ts +61 -21
  12. package/dist/commands/clone-command.d.ts.map +1 -1
  13. package/dist/commands/core-config.d.ts +16 -0
  14. package/dist/commands/core-config.d.ts.map +1 -0
  15. package/dist/commands/fetch-command.d.ts +104 -37
  16. package/dist/commands/fetch-command.d.ts.map +1 -1
  17. package/dist/commands/index.d.ts +1 -0
  18. package/dist/commands/index.d.ts.map +1 -1
  19. package/dist/commands/index.js +2 -2
  20. package/dist/commands/init-command.d.ts.map +1 -1
  21. package/dist/commands/merge-command.d.ts +15 -2
  22. package/dist/commands/merge-command.d.ts.map +1 -1
  23. package/dist/commands/push-command.d.ts +58 -25
  24. package/dist/commands/push-command.d.ts.map +1 -1
  25. package/dist/commands/remote-command.d.ts +115 -6
  26. package/dist/commands/remote-command.d.ts.map +1 -1
  27. package/dist/commands/reset-command.d.ts.map +1 -1
  28. package/dist/commands/stash-apply-command.d.ts +35 -13
  29. package/dist/commands/stash-apply-command.d.ts.map +1 -1
  30. package/dist/commands/stash-create-command.d.ts +59 -25
  31. package/dist/commands/stash-create-command.d.ts.map +1 -1
  32. package/dist/commands/stash-drop-command.d.ts +8 -2
  33. package/dist/commands/stash-drop-command.d.ts.map +1 -1
  34. package/dist/commands/stash-list-command.d.ts +2 -4
  35. package/dist/commands/stash-list-command.d.ts.map +1 -1
  36. package/dist/commands/stash-working-tree.d.ts +72 -0
  37. package/dist/commands/stash-working-tree.d.ts.map +1 -0
  38. package/dist/commands/status-command.d.ts +29 -22
  39. package/dist/commands/status-command.d.ts.map +1 -1
  40. package/dist/commands/tag-command.d.ts.map +1 -1
  41. package/dist/commands/tree-restore.d.ts +52 -5
  42. package/dist/commands/tree-restore.d.ts.map +1 -1
  43. package/dist/commands/worktree-overwrite-checks.d.ts +64 -0
  44. package/dist/commands/worktree-overwrite-checks.d.ts.map +1 -0
  45. package/dist/{commands-COO4tJhv.js → commands-CsLNyvZ1.js} +3370 -1057
  46. package/dist/core-commands/add.command.impl.d.ts +0 -4
  47. package/dist/core-commands/add.command.impl.d.ts.map +1 -1
  48. package/dist/core-commands/index.d.ts +1 -3
  49. package/dist/core-commands/index.d.ts.map +1 -1
  50. package/dist/core-commands/store-worktree-file.d.ts +6 -0
  51. package/dist/core-commands/store-worktree-file.d.ts.map +1 -0
  52. package/dist/errors/checkout-errors.d.ts +13 -0
  53. package/dist/errors/checkout-errors.d.ts.map +1 -1
  54. package/dist/errors/index.js +18 -1
  55. package/dist/git-command.d.ts +10 -1
  56. package/dist/git-command.d.ts.map +1 -1
  57. package/dist/git.d.ts +21 -3
  58. package/dist/git.d.ts.map +1 -1
  59. package/dist/index.js +4 -4
  60. package/dist/remote-config/index.d.ts +1 -0
  61. package/dist/remote-config/index.d.ts.map +1 -1
  62. package/dist/remote-config/remote-config-store.d.ts +22 -0
  63. package/dist/remote-config/remote-config-store.d.ts.map +1 -1
  64. package/dist/remote-config/remote-refs.d.ts +37 -0
  65. package/dist/remote-config/remote-refs.d.ts.map +1 -0
  66. package/dist/results/clone-result.d.ts +6 -0
  67. package/dist/results/clone-result.d.ts.map +1 -1
  68. package/dist/results/diff-formatter.d.ts +14 -7
  69. package/dist/results/diff-formatter.d.ts.map +1 -1
  70. package/dist/results/fetch-result.d.ts +16 -1
  71. package/dist/results/fetch-result.d.ts.map +1 -1
  72. package/dist/results/index.js +28 -23
  73. package/dist/results/push-result.d.ts +9 -2
  74. package/dist/results/push-result.d.ts.map +1 -1
  75. package/dist/results/status-result.d.ts +91 -20
  76. package/dist/results/status-result.d.ts.map +1 -1
  77. package/dist/{status-result-BwAyxq6R.js → status-result-BpyUK1Sg.js} +115 -5
  78. package/dist/transport-command.d.ts +12 -0
  79. package/dist/transport-command.d.ts.map +1 -1
  80. package/package.json +14 -12
  81. package/src/commands/add-command.ts +23 -30
  82. package/src/commands/blame-command.ts +41 -0
  83. package/src/commands/branch-command.ts +2 -53
  84. package/src/commands/checkout-command.ts +205 -127
  85. package/src/commands/clean-command.ts +187 -81
  86. package/src/commands/clone-command.ts +334 -137
  87. package/src/commands/core-config.ts +41 -0
  88. package/src/commands/fetch-command.ts +536 -211
  89. package/src/commands/gc-command.ts +1 -1
  90. package/src/commands/index.ts +1 -0
  91. package/src/commands/init-command.ts +108 -11
  92. package/src/commands/merge-command.ts +60 -27
  93. package/src/commands/pack-refs-command.ts +2 -2
  94. package/src/commands/push-command.ts +242 -308
  95. package/src/commands/reflog-command.ts +2 -2
  96. package/src/commands/remote-command.ts +429 -19
  97. package/src/commands/reset-command.ts +18 -5
  98. package/src/commands/stash-apply-command.ts +632 -97
  99. package/src/commands/stash-create-command.ts +142 -62
  100. package/src/commands/stash-drop-command.ts +53 -5
  101. package/src/commands/stash-list-command.ts +10 -4
  102. package/src/commands/stash-working-tree.ts +243 -0
  103. package/src/commands/status-command.ts +197 -91
  104. package/src/commands/tag-command.ts +2 -53
  105. package/src/commands/tree-restore.ts +143 -18
  106. package/src/commands/worktree-overwrite-checks.ts +215 -0
  107. package/src/core-commands/add.command.impl.ts +15 -20
  108. package/src/core-commands/index.ts +1 -8
  109. package/src/core-commands/store-worktree-file.ts +5 -0
  110. package/src/errors/checkout-errors.ts +20 -0
  111. package/src/git-command.ts +42 -1
  112. package/src/git.ts +30 -2
  113. package/src/remote-config/index.ts +1 -0
  114. package/src/remote-config/remote-config-store.ts +95 -8
  115. package/src/remote-config/remote-refs.ts +103 -0
  116. package/src/results/clone-result.ts +6 -0
  117. package/src/results/diff-formatter.ts +31 -38
  118. package/src/results/fetch-result.ts +16 -1
  119. package/src/results/push-result.ts +9 -2
  120. package/src/results/status-result.ts +212 -29
  121. package/src/transport-command.ts +18 -0
  122. package/dist/core-commands/checkout.command.d.ts +0 -103
  123. package/dist/core-commands/checkout.command.d.ts.map +0 -1
  124. package/dist/core-commands/checkout.command.impl.d.ts +0 -114
  125. package/dist/core-commands/checkout.command.impl.d.ts.map +0 -1
  126. package/dist/pack-import/index.d.ts +0 -8
  127. package/dist/pack-import/index.d.ts.map +0 -1
  128. package/dist/pack-import/pack-import.d.ts +0 -11
  129. package/dist/pack-import/pack-import.d.ts.map +0 -1
  130. package/src/core-commands/checkout.command.impl.ts +0 -586
  131. package/src/core-commands/checkout.command.ts +0 -125
  132. package/src/pack-import/index.ts +0 -8
  133. package/src/pack-import/pack-import.ts +0 -24
@@ -1 +1 @@
1
- {"version":3,"file":"stash-create-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-create-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgC/C;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElC;;OAEG;IACH,cAAc,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEpC;;OAEG;IACH,gBAAgB,CAAC,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;IAEnD;;OAEG;IACH,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,kBAAmB,SAAQ,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;IACtE,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,uBAAuB,CAAmB;IAClD,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,mBAAmB,CAAC,CAA2B;IACvD,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAc;IAE7B;;;;;;;OAOG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrC;IAED;;;;OAIG;IACH,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhD;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAI/B;IAED;;;;OAIG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAInD;IAED;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAE7B;IAED;;;;OAIG;IACH,sBAAsB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAI/D;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAInC;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CA0G1C;IAED;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;YACW,oBAAoB;IASlC;;;;;OAKG;YACW,cAAc;CAI7B"}
1
+ {"version":3,"file":"stash-create-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-create-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI3F,OAAO,EAAE,UAA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CAAS;IAC/B,OAAO,CAAC,MAAM,CAAC,CAAc;IAE7B;;;;;;;OAOG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrC;IAED;;;;OAIG;IACH,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhD;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIhC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAI/B;IAED;;;;OAIG;IACH,mBAAmB,CAAC,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAInD;IAED;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAE7B;IAED;;;OAGG;IACH,iBAAiB,CAAC,cAAc,EAAE,OAAO,GAAG,IAAI,CAK/C;IAED;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAIrC;IAED;;;;OAIG;IACH,sBAAsB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAI/D;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAInC;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAM1C;YAEa,KAAK;IAsGnB,8EAA8E;IAC9E,OAAO,CAAC,eAAe;IAsBvB;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;YACW,oBAAoB;IASlC;;;;;OAKG;YACW,cAAc;CAgB7B"}
@@ -7,8 +7,9 @@ import { GitCommand } from "../git-command.js";
7
7
  *
8
8
  * Based on JGit's StashDropCommand.
9
9
  *
10
- * Note: Without reflog support in RefStore, only the most recent stash (index 0)
11
- * can be dropped. Dropping by index > 0 requires reflog support.
10
+ * With a ref store that keeps reflogs (`getReflog`, `deleteReflogEntry`), any
11
+ * `stash@{n}` can be dropped, as git drops it; otherwise only the most recent
12
+ * stash (index 0).
12
13
  *
13
14
  * @example
14
15
  * ```typescript
@@ -59,5 +60,10 @@ export declare class StashDropCommand extends GitCommand<ObjectId | undefined> {
59
60
  * @returns The new stash ref after drop, or undefined if no stashes remain
60
61
  */
61
62
  call(): Promise<ObjectId | undefined>;
63
+ /**
64
+ * Delete `refs/stash` and its reflog if it still holds `expected` (git's clear_stash).
65
+ * With `ignoreMismatch`, a ref another writer moved meanwhile is left alone.
66
+ */
67
+ private deleteStashRef;
62
68
  }
63
69
  //# sourceMappingURL=stash-drop-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stash-drop-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-drop-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;IACpE,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAS;IAExB;;;;;;;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAOlC;IAED;;OAEG;IACH,WAAW,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAIzB;IAED;;OAEG;IACH,MAAM,IAAI,OAAO,CAEhB;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CA6B1C;CACF"}
1
+ {"version":3,"file":"stash-drop-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-drop-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,QAAQ,GAAG,SAAS,CAAC;IACpE,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,OAAO,CAAS;IAExB;;;;;;;;OAQG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAOlC;IAED;;OAEG;IACH,WAAW,IAAI,MAAM,CAEpB;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAIzB;IAED;;OAEG;IACH,MAAM,IAAI,OAAO,CAEhB;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CA0D1C;IAED;;;OAGG;YACW,cAAc;CAa7B"}
@@ -28,10 +28,8 @@ export declare class StashListCommand extends GitCommand<StashEntry[]> {
28
28
  */
29
29
  call(): Promise<StashEntry[]>;
30
30
  /**
31
- * Get stash entries.
32
- *
33
- * Note: Without reflog support in the core RefStore interface,
34
- * this returns only the most recent stash (if any).
31
+ * Get stash entries: the reflog of `refs/stash`, newest first, as `git stash list`
32
+ * reads it. A store without reflogs gives only the current `refs/stash`.
35
33
  */
36
34
  private getStashReflog;
37
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"stash-list-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-list-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,UAAU,EAAE,CAAC;IAC5D;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAwBlC;IAED;;;;;OAKG;YACW,cAAc;IAmB5B;;OAEG;YACW,eAAe;CA6B9B"}
1
+ {"version":3,"file":"stash-list-command.d.ts","sourceRoot":"","sources":["../../src/commands/stash-list-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,SAAS,eAAe,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,UAAU,EAAE,CAAC;IAC5D;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAyBlC;IAED;;;OAGG;YACW,cAAc;IA0B5B;;OAEG;YACW,eAAe;CA6B9B"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The built-in working-tree side of `git stash push`, for a working copy with an index and
3
+ * a worktree: the stash trees (index, worktree, untracked) as git builds them, and the
4
+ * reset that follows (`git clean -fd` with `-u`, `git reset --hard`, and with
5
+ * `--keep-index` the index tree checked out again).
6
+ *
7
+ * The index is compared with the worktree once per stash ({@link scanIndex}); the check for
8
+ * changes, the worktree tree and the reset all use that one comparison, and the entries it
9
+ * could only prove clean by hashing get their fresh stat in the index the reset writes.
10
+ */
11
+ import { type Blobs, type ObjectId } from "@statewalker/vcs-core";
12
+ import { type Staging, type WorkingCopy, type Worktree } from "@statewalker/vcs-working-tree";
13
+ import type { CommandTrees } from "../git-command.js";
14
+ import type { StashResetOptions, StashWorkingTreeProvider } from "./stash-create-command.js";
15
+ /** What {@link WorkingCopyStashProvider} works on. */
16
+ export interface WorkingCopyStashContext {
17
+ workingCopy: WorkingCopy;
18
+ trees: CommandTrees;
19
+ blobs: Blobs;
20
+ staging: Staging;
21
+ worktree: Worktree;
22
+ /** HEAD's tree (undefined before the first commit) */
23
+ headTree: () => Promise<ObjectId | undefined>;
24
+ }
25
+ /**
26
+ * The stash working-tree provider `git.stashCreate()` uses when none is set and the working
27
+ * copy has an index and a worktree. One instance serves one stash: it compares the index
28
+ * with the worktree once and reuses that comparison.
29
+ */
30
+ export declare class WorkingCopyStashProvider implements StashWorkingTreeProvider {
31
+ private readonly context;
32
+ private scanned?;
33
+ constructor(context: WorkingCopyStashContext);
34
+ private get source();
35
+ /** The index compared with the worktree, once. */
36
+ private scan;
37
+ getIndexTree(): Promise<ObjectId>;
38
+ getWorkingTree(): Promise<ObjectId>;
39
+ getUntrackedTree(options?: {
40
+ includeIgnored?: boolean;
41
+ }): Promise<ObjectId | undefined>;
42
+ hasLocalChanges(options?: {
43
+ includeUntracked?: boolean;
44
+ includeIgnored?: boolean;
45
+ }): Promise<boolean>;
46
+ /**
47
+ * As `git stash push` after saving: with `includeUntracked` the untracked files go
48
+ * (`git clean -fd`, `-x` too with `includeIgnored`), then the index and the worktree's
49
+ * tracked files are reset to HEAD (`git reset --hard`); with `keepIndex` the index tree is
50
+ * then checked out again (`git checkout --no-overlay <index tree> -- :/`). Only paths
51
+ * that differ are written; untracked files are kept unless removed by the clean.
52
+ */
53
+ resetHard(options?: StashResetOptions): Promise<void>;
54
+ /**
55
+ * `git clean -fd` (`-x` with `ignored`): the untracked files, then the untracked
56
+ * directories left empty, deepest first. A directory is removed only when nothing at all
57
+ * is in it, so a nested repository (and, without `-x`, an ignored file) keeps its own.
58
+ */
59
+ private clean;
60
+ /**
61
+ * The index and the worktree's tracked files made to match HEAD, as `git reset --hard`:
62
+ * every path whose index entry or worktree file differs is written (or removed) and staged
63
+ * with its fresh stat; paths that already match are not touched, and those the scan only
64
+ * proved clean by hashing get their fresh stat.
65
+ */
66
+ private resetToHead;
67
+ /** `git checkout --no-overlay <tree> -- :/` after the reset: index and worktree at `to`. */
68
+ private checkoutTree;
69
+ /** Writes (or removes) the `stale` paths of the worktree and the index to `treeId`. */
70
+ private write;
71
+ }
72
+ //# sourceMappingURL=stash-working-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash-working-tree.d.ts","sourceR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AC;KAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnB;IAED;;;;;;OAMG;IACG,SAAS,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9D;IAED;;;;OAIG;YACW,KAAK;IAsBnB;;;;;OAKG;YACW,WAAW;IAczB,4FAA4F;YAC9E,YAAY;IAa1B,uFAAuF;YACzE,KAAK;CA+DpB"}
@@ -1,39 +1,36 @@
1
1
  import { GitCommand } from "../git-command.js";
2
2
  import { type Status } from "../results/status-result.js";
3
3
  /**
4
- * Shows the staging area status compared to HEAD.
4
+ * Shows the working tree status, as `git status`: the index against HEAD (staged changes),
5
+ * the worktree against the index (unstaged changes: modified, deleted, type changed),
6
+ * unmerged entries, untracked files and, on request, ignored ones.
5
7
  *
6
- * This is a simplified version for repositories without working trees,
7
- * focusing on staged changes and conflicts.
8
+ * Worktree files are compared with the index through the stat it recorded: a file whose
9
+ * size and modification time still match is not read, unless its entry is racily clean
10
+ * (modified at or after the index was written), which is re-hashed as git does. Links are
11
+ * compared as links (mode 120000), the executable bit only where `core.filemode` trusts it,
12
+ * and the ignore rules are read afresh for each status. Untracked files are listed one by
13
+ * one (`--untracked-files=all`). Renames are not detected.
8
14
  *
9
- * Equivalent to `git status` but only for staged changes.
15
+ * Without a worktree only the index is compared with HEAD.
10
16
  *
11
- * Based on JGit's StatusCommand (staged-only subset).
17
+ * Based on JGit's StatusCommand.
12
18
  *
13
19
  * @example
14
20
  * ```typescript
15
- * // Get repository status
16
21
  * const status = await git.status().call();
17
- *
18
- * // Check if clean
19
- * if (status.isClean()) {
20
- * console.log("Nothing to commit");
21
- * }
22
- *
23
- * // Check for changes
24
- * console.log("Added:", status.added);
25
- * console.log("Changed:", status.changed);
26
- * console.log("Removed:", status.removed);
27
- * console.log("Conflicting:", status.conflicting);
28
- *
29
- * // Filter by path
30
- * const subStatus = await git.status()
31
- * .addPath("src/")
32
- * .call();
22
+ * if (status.isClean()) console.log("nothing to commit, working tree clean");
23
+ * console.log("Staged:", status.added, status.changed, status.removed);
24
+ * console.log("Unstaged:", status.modified, status.missing);
25
+ * console.log("Untracked:", status.untracked);
26
+ * // the lines of `git status --porcelain`
27
+ * console.log(formatStatusPorcelain(status));
33
28
  * ```
34
29
  */
35
30
  export declare class StatusCommand extends GitCommand<Status> {
36
31
  private paths;
32
+ private showIgnored;
33
+ private showUntracked;
37
34
  /**
38
35
  * Add a path filter.
39
36
  *
@@ -42,7 +39,17 @@ export declare class StatusCommand extends GitCommand<Status> {
42
39
  * @param path Path prefix to filter by
43
40
  */
44
41
  addPath(path: string): this;
42
+ /**
43
+ * Whether to report the ignored files the index does not track (`--ignored`). Off by
44
+ * default.
45
+ */
46
+ setIgnored(ignored: boolean): this;
47
+ /**
48
+ * Whether to report untracked files (`--untracked-files=all`, the default, or `=no`).
49
+ */
50
+ setUntracked(untracked: boolean): this;
45
51
  call(): Promise<Status>;
52
+ private compute;
46
53
  /**
47
54
  * Check if a path matches the configured path filters.
48
55
  */
@@ -1 +1 @@
1
- {"version":3,"file":"status-command.d.ts","sourceRoot":"","sources":["../../src/commands/status-command.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,6BAA6B,CAAC;AAWtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,aAAc,SAAQ,UAAU,CAAC,MAAM,CAAC;IACnD,OAAO,CAAC,KAAK,CAAgB;IAE7B;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAI1B;IAEK,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAkE5B;IAED;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;YACW,kBAAkB;CAiBjC"}
1
+ {"version":3,"file":"status-command.d.ts","sourceRoot":"","sources":["../../src/commands/status-command.ts"],"names":[],"mappings":"AAcA,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;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAkB9B;CACF;AAED;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,UAAU,CAAC,GAAG,EAAE,CAAC;IACnD;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAgB3B;CACF"}
@@ -2,8 +2,8 @@
2
2
  * Writing a tree back into the working tree.
3
3
  *
4
4
  * Shared by the commands that make the working tree match a tree object -
5
- * `reset --hard` and `stash apply`. Both need the same two-phase shape: plan
6
- * and validate the whole restore first, then write. A tree that cannot be
5
+ * `reset --hard`, `stash apply` and the checkout of `clone`. All need the
6
+ * same two-phase shape: plan and validate the whole restore first, then write. A tree that cannot be
7
7
  * restored faithfully therefore fails with the working tree still intact,
8
8
  * rather than half-way through rewriting it.
9
9
  */
@@ -26,19 +26,57 @@ export interface TreeRestorePlan {
26
26
  * is one the target tree deletes.
27
27
  */
28
28
  paths: Set<string>;
29
+ /** The gitlinks (submodules) of the tree, which are not written. */
30
+ gitlinks: RestoreEntry[];
31
+ /**
32
+ * With `ignoreCase`: files whose paths differ only in case (`README`, `readme`). Both are
33
+ * written, the last one wins, as git checks them out with its "the following paths have
34
+ * collided" warning.
35
+ */
36
+ collided: string[];
37
+ }
38
+ /** Options of {@link planTreeRestore}. */
39
+ export interface TreeRestoreOptions {
40
+ /**
41
+ * Plan symlinks as entries to write (their blob is the link target), for a
42
+ * worktree that writes mode `0o120000` as a link or as a file holding the
43
+ * target, as git does. Without it a symlink fails the plan.
44
+ */
45
+ symlinks?: boolean;
46
+ /**
47
+ * Compare paths case-insensitively (`core.ignorecase`), as a case-folding filesystem
48
+ * would: a path beneath a file, link or submodule of another case (`A` a link, `a/x`)
49
+ * is refused, it would be written through the link; two files differing only in case
50
+ * are both planned (the last wins) and reported in `collided`, as git does.
51
+ */
52
+ ignoreCase?: boolean;
53
+ /** The worktree is on Windows (`capabilities.windowsPaths`): git's Windows path rules. */
54
+ windows?: boolean;
55
+ /** Top-level names the worktree's storage reserves (`capabilities.reservedNames`) */
56
+ reservedNames?: string[];
57
+ /**
58
+ * Only these paths will be written: the blobs of the others are not checked (every path
59
+ * is still validated). Absent: every blob is checked.
60
+ */
61
+ writing?: Set<string>;
29
62
  }
30
63
  /**
31
64
  * Walk a tree and plan which files to restore, validating as it goes.
32
65
  *
33
66
  * Throws on anything that cannot be restored faithfully, so the caller can
34
- * abort before mutating the working tree.
67
+ * abort before mutating the working tree: a path git's `verify_path` refuses
68
+ * (`.git` under any spelling, a symlinked `.gitmodules`), and two entries that
69
+ * collide - the same path twice, a file and a directory of one name, or a path
70
+ * beneath a planned file, symlink or submodule (which would write through the
71
+ * link), compared case-insensitively with `ignoreCase`.
35
72
  *
36
73
  * @param trees Tree storage to walk
37
74
  * @param blobs Blob storage, checked for the content of every planned file
38
75
  * @param treeId Tree to restore
39
76
  * @param operation Names the operation in failure messages, e.g. `reset --hard`
77
+ * @param options What else the worktree can restore
40
78
  */
41
- export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeId: ObjectId, operation: string): Promise<TreeRestorePlan>;
79
+ export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeId: ObjectId, operation: string, options?: TreeRestoreOptions): Promise<TreeRestorePlan>;
42
80
  /**
43
81
  * Execute a plan produced by {@link planTreeRestore}, writing every file.
44
82
  *
@@ -47,5 +85,14 @@ export declare function planTreeRestore(trees: CommandTrees, blobs: Blobs, treeI
47
85
  * @param plan The validated plan
48
86
  * @param operation Names the operation in failure messages
49
87
  */
50
- export declare function writeTreeRestorePlan(worktree: Worktree, blobs: Blobs, plan: TreeRestorePlan, operation: string): Promise<void>;
88
+ export declare function writeTreeRestorePlan(worktree: Worktree, blobs: Blobs, plan: TreeRestorePlan, operation: string, options?: TreeWriteOptions): Promise<void>;
89
+ /** Options of {@link writeTreeRestorePlan}. */
90
+ export interface TreeWriteOptions {
91
+ /** Write symlinks as links (default); false writes them as files holding the target. */
92
+ symlinks?: boolean;
93
+ /** A forced checkout: unlink a file or link standing where a directory must go. */
94
+ replaceInTheWay?: boolean;
95
+ /** Create an empty directory for each gitlink (submodule). */
96
+ gitlinks?: boolean;
97
+ }
51
98
  //# sourceMappingURL=tree-restore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-restore.d.ts","sourceRoot":"","sources":["../../src/commands/tree-restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,oEAAoE;AACpE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB;;;;OAIG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,QAAQ,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,CAI1B;AA2CD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAcf"}
1
+ {"version":3,"file":"tree-restore.d.ts","sourceRoot":"","sources":["../../src/commands/tree-restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,K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SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAIf;AA+BD,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mFAAmF;IACnF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * What a checkout or a stash apply must not overwrite, as git's unpack-trees checks it
3
+ * before writing anything: local changes (`verify_uptodate`), untracked files on a path or
4
+ * a leading component (`verify_absent`, `check_leading_path`), and untracked files in a
5
+ * directory a file replaces (`verify_clean_subdirectory`).
6
+ */
7
+ import { type ObjectId } from "@statewalker/vcs-core";
8
+ import type { Worktree, WorktreeModeTrust } from "@statewalker/vcs-working-tree";
9
+ /** An index or tree entry, with the index's stat where it has one. */
10
+ export interface CheckedEntry {
11
+ objectId: ObjectId;
12
+ mode: number;
13
+ size?: number;
14
+ mtime?: number;
15
+ ctime?: number;
16
+ }
17
+ /**
18
+ * Whether the worktree file at `path` no longer holds the index entry (git's
19
+ * `verify_uptodate`): changed content, type, or executable bit where the worktree shows it.
20
+ * A missing file is no local change.
21
+ */
22
+ export declare function worktreeDiffers(worktree: Worktree, path: string, entry: CheckedEntry, trust?: WorktreeModeTrust): Promise<boolean>;
23
+ /** What stands where an operation writes: untracked files, and directories with some. */
24
+ export interface InTheWay {
25
+ /** Untracked files or links on a written path, or on a leading component of one */
26
+ untracked: string[];
27
+ /**
28
+ * Directories a written file replaces that hold untracked files, or tracked files the
29
+ * operation does not remove (never replaced behind the index's back)
30
+ */
31
+ lostDirs: string[];
32
+ }
33
+ /**
34
+ * Finds what stands where `writes` (paths not in the index) are written, `removes` being
35
+ * the tracked paths the operation deletes first. Ignored files are expendable, as in git.
36
+ * With `ignoreCase`, a file that is one of `removes` in another case is no obstacle (a
37
+ * case-only rename on a case-folding worktree).
38
+ */
39
+ export declare function findInTheWay(worktree: Worktree, options: {
40
+ writes: string[];
41
+ removes: Set<string>;
42
+ index: Map<string, unknown>;
43
+ ignoreCase?: boolean;
44
+ }): Promise<InTheWay>;
45
+ /**
46
+ * Removes the directory at `dir` if it holds nothing at all, as git's `rmdir`: never a
47
+ * directory with a file, link, subdirectory, nested repository (`.git`) or FIFO in it, and
48
+ * never recursively. Returns whether it was removed.
49
+ */
50
+ export declare function removeDirectoryIfEmpty(worktree: Worktree, dir: string): Promise<boolean>;
51
+ /**
52
+ * Removes the directories a removal left empty, bottom-up to the worktree root, as git's
53
+ * `schedule_dir_for_removal`: each only if it is truly empty, stopping at the first that is
54
+ * not (a nested repository, an ignored or untracked file, a FIFO keeps its directory).
55
+ */
56
+ export declare function pruneEmptyParents(worktree: Worktree, path: string): Promise<void>;
57
+ /** git's refusal messages (unpack-trees), for `checkout` or `merge` (stash apply). */
58
+ export declare function overwriteMessage(action: "checkout" | "merge", found: {
59
+ local?: string[];
60
+ lostDirs?: string[];
61
+ untracked?: string[];
62
+ untrackedRemoved?: string[];
63
+ }): string | undefined;
64
+ //# sourceMappingURL=worktree-overwrite-checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-overwrite-checks.d.ts","sourceRoot":"","sources":["../../src/commands/worktree-overwrite-checks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GA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