@scolladon/tsgit 2.0.1 → 3.1.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.
- package/README.md +14 -2
- package/dist/cjs/adapters/browser/index.cjs +1 -2
- package/dist/cjs/adapters/memory/index.cjs +1 -2
- package/dist/cjs/adapters/node/index.cjs +1 -2
- package/dist/cjs/chunks/adapter-detect-DW9fsw9d.cjs +1 -0
- package/dist/cjs/chunks/browser-http-transport-DGwW5YL7.cjs +1 -0
- package/dist/cjs/chunks/context-BcoAzPuU.cjs +0 -1
- package/dist/cjs/chunks/error-CfLWDui_.cjs +1 -0
- package/dist/cjs/chunks/index-Cy44GVR6.cjs +1 -0
- package/dist/cjs/chunks/inflate-CmCtM4-w.cjs +1 -0
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs +0 -1
- package/dist/cjs/chunks/memory-http-transport-CGriODcQ.cjs +1 -0
- package/dist/cjs/chunks/node-ssh-transport-PFu3ijfp.cjs +1 -0
- package/dist/cjs/chunks/{progress-CxU62NC1.cjs → progress-D8Dqbftk.cjs} +1 -2
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +0 -1
- package/dist/cjs/chunks/repository-Ci-BBxk0.cjs +1 -0
- package/dist/cjs/chunks/write-sparse-checkout-C1dsHCAD.cjs +1 -0
- package/dist/cjs/commands/index.cjs +1 -2
- package/dist/cjs/index.browser.cjs +1 -2
- package/dist/cjs/index.cjs +1 -2
- package/dist/cjs/index.default.cjs +1 -2
- package/dist/cjs/index.node.cjs +1 -2
- package/dist/cjs/operators/index.cjs +0 -1
- package/dist/cjs/primitives/index.cjs +1 -2
- package/dist/cjs/transport/index.cjs +0 -1
- package/dist/esm/adapters/browser/index.js +1 -2
- package/dist/esm/adapters/memory/index.js +1 -2
- package/dist/esm/adapters/node/index.js +1 -2
- package/dist/esm/chunks/adapter-detect-BkCMnjrI.js +1 -0
- package/dist/esm/chunks/browser-http-transport-CSxAte5h.js +1 -0
- package/dist/esm/chunks/context-CumKOV7K.js +0 -1
- package/dist/esm/chunks/error-BotOd-nD.js +1 -0
- package/dist/esm/chunks/index-DsvINN8n.js +1 -0
- package/dist/esm/chunks/inflate-BCIXqeeE.js +1 -0
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js +0 -1
- package/dist/esm/chunks/memory-http-transport-caqmMGR1.js +1 -0
- package/dist/esm/chunks/node-ssh-transport-BgSv2IhT.js +1 -0
- package/dist/esm/chunks/{progress-BZobfl7p.js → progress-B_AJnOHx.js} +1 -2
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js +0 -1
- package/dist/esm/chunks/repository-DyxknzvE.js +1 -0
- package/dist/esm/chunks/write-sparse-checkout-BwHbNKNS.js +1 -0
- package/dist/esm/commands/index.js +1 -2
- package/dist/esm/index.browser.js +1 -2
- package/dist/esm/index.default.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.node.js +1 -2
- package/dist/esm/operators/index.js +0 -1
- package/dist/esm/primitives/index.js +1 -2
- package/dist/esm/transport/index.js +0 -1
- package/dist/types/adapters/browser/index.d.cts +5 -3
- package/dist/types/adapters/browser/index.d.ts +5 -3
- package/dist/types/adapters/memory/index.d.cts +31 -4
- package/dist/types/adapters/memory/index.d.ts +31 -4
- package/dist/types/adapters/node/index.d.cts +146 -40
- package/dist/types/adapters/node/index.d.ts +146 -40
- package/dist/types/chunks/{context-YDw6qicq.d.cts → context-CF1YF2S8.d.cts} +165 -6
- package/dist/types/chunks/{context-CCL0_F8R.d.ts → context-sIhhtk2u.d.ts} +165 -6
- package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
- package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
- package/dist/types/chunks/index-B5Dps3fg.d.ts +2468 -0
- package/dist/types/chunks/index-B_A8VLaf.d.ts +1221 -0
- package/dist/types/chunks/index-Dfh8cvEs.d.cts +2468 -0
- package/dist/types/chunks/index-Dqxddhav.d.cts +1221 -0
- package/dist/types/chunks/progress-BjAKfkam.d.ts +1217 -0
- package/dist/types/chunks/progress-Ldnfb8st.d.cts +1217 -0
- package/dist/types/chunks/reflog-entry-Cqh3QrPH.d.ts +697 -0
- package/dist/types/chunks/reflog-entry-Dy-O27Dd.d.cts +697 -0
- package/dist/types/chunks/{repository-FoS_Laoy.d.ts → repository-D8QBTkEz.d.ts} +58 -20
- package/dist/types/chunks/{repository-BeifCqp0.d.cts → repository-D9YrVhcH.d.cts} +58 -20
- package/dist/types/commands/index.d.cts +4 -1259
- package/dist/types/commands/index.d.ts +4 -1259
- package/dist/types/index.browser.d.cts +7 -8
- package/dist/types/index.browser.d.ts +7 -8
- package/dist/types/index.d.cts +61 -124
- package/dist/types/index.d.ts +61 -124
- package/dist/types/index.default.d.cts +7 -8
- package/dist/types/index.default.d.ts +7 -8
- package/dist/types/index.node.d.cts +7 -8
- package/dist/types/index.node.d.ts +7 -8
- package/dist/types/primitives/index.d.cts +4 -692
- package/dist/types/primitives/index.d.ts +4 -692
- package/dist/types/transport/index.d.cts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/package.json +94 -28
- package/dist/cjs/adapters/browser/index.cjs.map +0 -1
- package/dist/cjs/adapters/memory/index.cjs.map +0 -1
- package/dist/cjs/adapters/node/index.cjs.map +0 -1
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs +0 -2
- package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +0 -1
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs +0 -2
- package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +0 -1
- package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +0 -1
- package/dist/cjs/chunks/error-CfjFO3x_.cjs +0 -2
- package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +0 -1
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs +0 -2
- package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +0 -1
- package/dist/cjs/chunks/lru-cache-1OU7JhD8.cjs.map +0 -1
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +0 -2
- package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +0 -1
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +0 -2
- package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +0 -1
- package/dist/cjs/chunks/progress-CxU62NC1.cjs.map +0 -1
- package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +0 -1
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs +0 -2
- package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +0 -1
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +0 -2
- package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs.map +0 -1
- package/dist/cjs/commands/index.cjs.map +0 -1
- package/dist/cjs/index.browser.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.default.cjs.map +0 -1
- package/dist/cjs/index.node.cjs.map +0 -1
- package/dist/cjs/operators/index.cjs.map +0 -1
- package/dist/cjs/primitives/index.cjs.map +0 -1
- package/dist/cjs/transport/index.cjs.map +0 -1
- package/dist/esm/adapters/browser/index.js.map +0 -1
- package/dist/esm/adapters/memory/index.js.map +0 -1
- package/dist/esm/adapters/node/index.js.map +0 -1
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js +0 -2
- package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +0 -1
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js +0 -2
- package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +0 -1
- package/dist/esm/chunks/context-CumKOV7K.js.map +0 -1
- package/dist/esm/chunks/error-Dc-SRSJK.js +0 -2
- package/dist/esm/chunks/error-Dc-SRSJK.js.map +0 -1
- package/dist/esm/chunks/index-jH0UMhh-.js +0 -2
- package/dist/esm/chunks/index-jH0UMhh-.js.map +0 -1
- package/dist/esm/chunks/lru-cache-Cy7C7Lx2.js.map +0 -1
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +0 -2
- package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +0 -1
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +0 -2
- package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +0 -1
- package/dist/esm/chunks/progress-BZobfl7p.js.map +0 -1
- package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +0 -1
- package/dist/esm/chunks/repository-DF6ePd1x.js +0 -2
- package/dist/esm/chunks/repository-DF6ePd1x.js.map +0 -1
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +0 -2
- package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js.map +0 -1
- package/dist/esm/commands/index.js.map +0 -1
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.default.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.node.js.map +0 -1
- package/dist/esm/operators/index.js.map +0 -1
- package/dist/esm/primitives/index.js.map +0 -1
- package/dist/esm/transport/index.js.map +0 -1
- package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +0 -47
- package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +0 -47
- package/dist/types/chunks/progress-7KKiXXfX.d.ts +0 -405
- package/dist/types/chunks/progress-By8yFaUE.d.cts +0 -405
- package/dist/types/chunks/reflog-entry-BbNnXCTC.d.cts +0 -368
- package/dist/types/chunks/reflog-entry-CSzjnZd4.d.ts +0 -368
- package/dist/types/chunks/write-tree-C3oNxOlX.d.cts +0 -196
- package/dist/types/chunks/write-tree-DRI-LzSr.d.ts +0 -196
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("./error-CfjFO3x_.cjs"),t=require("./walk-submodules-D2Sp7JEB.cjs"),a=require("../transport/index.cjs"),r=require("./readable-stream-MTA6D0Zh.cjs");const n=t=>new e.TsgitError({code:"INVALID_DIFF_INPUT",reason:t}),o=/[ \t\v\f\r]+$/,i=e=>{const t=e.indexOf("\n");return-1===t?e:e.slice(0,t)};function s(e){const t=[];return void 0!==e.baseId&&void 0!==e.baseMode&&t.push({id:e.baseId,mode:e.baseMode,stage:1}),void 0!==e.ourId&&void 0!==e.ourMode&&t.push({id:e.ourId,mode:e.ourMode,stage:2}),void 0!==e.theirId&&void 0!==e.theirMode&&t.push({id:e.theirId,mode:e.theirMode,stage:3}),t}function c(e,a,r){const n=r(a.mode);return{ctimeSeconds:n.ctimeSeconds,ctimeNanoseconds:n.ctimeNanoseconds,mtimeSeconds:n.mtimeSeconds,mtimeNanoseconds:n.mtimeNanoseconds,dev:n.dev,ino:n.ino,mode:a.mode,uid:n.uid,gid:n.gid,fileSize:n.fileSize,id:a.id,flags:{...t.STAGE0_FLAGS,stage:a.stage},path:e}}function d(e,a){const r=new Set;for(const t of e){if(r.has(t.path))throw n("duplicate conflict path");r.add(t.path)}const o=[];for(const t of e)for(const e of s(t))o.push(c(t.path,e,a));return o.sort((e,a)=>{const r=t.comparePaths(e.path,a.path);return 0!==r?r:e.flags.stage-a.flags.stage}),o}const f=1e5;function l(e){const t=[];let a=0;for(let r=0;r<e.length;r++)10===e[r]&&(t.push(e.subarray(a,r+1)),a=r+1);return a<e.length&&t.push(e.subarray(a)),t}function u(e){return function(e){const t=Math.min(e.length,8e3);for(let a=0;a<t;a++)if(0===e[a])return!0;return!1}(e)||function(e){let t=0,a=0;for(let r=0;r<e.length;r++){if(t++,t>=65536)return!0;if(10===e[r]){if(a++,a>=f)return!0;t=0}}return t>0&&(a++,a>=f)}(e)}function w(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==t[a])return!1;return!0}function m(e,t,a,r){return r===-a||e[r-1+t]<e[r+1+t]}function p(e,t,a,r,n,o){let i=m(a,r,n,o)?a[o+1+r]:a[o-1+r]+1,s=i-o;for(;i<e.length&&s<t.length&&w(e[i],t[s]);)i++,s++;return{x:i,y:s}}function h(e){const t=[];let a=0,r=0,n=0;for(;n<e.length;){const o=e[n],i=a,s=r;for(;e[n]===o;)"equal"===o?(a++,r++):"delete"===o?a++:r++,n++;t.push({kind:"equal"===o?"common":"delete"===o?"ours-only":"theirs-only",oursStart:i,oursEnd:a,theirsStart:s,theirsEnd:r})}return t}function g(e,t){const a=l(e),r=l(t),n=a.length,o=r.length;if(0===n&&0===o)return{hunks:[{kind:"common",oursStart:0,oursEnd:0,theirsStart:0,theirsEnd:0}],oursLines:a,theirsLines:r,degraded:!1};const i=function(e,t){const a=e.length,r=t.length;if(a+r>5e4)return;const n=a+r,o=n,i=new Array(2*n+1).fill(0),s=[],c=1e3*n;let d=0;for(let n=0;;n++){const f=2*n+1,l=new Array(f);for(let e=0;e<f;e++)l[e]=i[o-n+e];s.push(l);for(let f=-n;f<=n;f+=2){if(d++,d>c)return;const l=p(e,t,i,o,n,f);if(i[f+o]=l.x,l.x>=a&&l.y>=r)return{trace:s,totalD:n}}}}(a,r);return void 0===i?function(e,t){const a=[];return e.length>0&&a.push({kind:"ours-only",oursStart:0,oursEnd:e.length,theirsStart:0,theirsEnd:0}),t.length>0&&a.push({kind:"theirs-only",oursStart:e.length,oursEnd:e.length,theirsStart:0,theirsEnd:t.length}),{hunks:a,oursLines:e,theirsLines:t,degraded:!0}}(a,r):{hunks:h(function(e,t,a){const r=[];let n=e,o=t;for(let e=a.length-1;e>0;e--){const t=a[e],i=e,s=n-o,c=m(t,i,e,s)?s+1:s-1,d=t[c+i],f=d-c;for(;n>d&&o>f;)r.push("equal"),n--,o--;r.push(n===d?"insert":"delete"),n===d?o--:n--}for(;n>0;)r.push("equal"),n--;return r.reverse(),r}(n,o,i.trace)),oursLines:a,theirsLines:r,degraded:!1}}const y="0000000",v={old:"a/",new:"b/"},k="\",b=new TextDecoder("utf-8",{fatal:!1});function x(e,t){for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);if(10===r||13===r||0===r)throw n(`${e} contains control character (code ${r}) at index ${a}`)}}function $(e,t){if(x("pathPrefix.old",t.old),x("pathPrefix.new",t.new),"rename"===e.type)return x("oldPath",e.oldPath),void x("newPath",e.newPath);"add"!==e.type?"delete"!==e.type?x("path",e.path):x("oldPath",e.oldPath):x("newPath",e.newPath)}function I(e){return void 0===e||0===e.length?{lines:[],hasTrailingNewline:!0}:{lines:l(e).map(R),hasTrailingNewline:10===e[e.length-1]}}function R(e){return b.decode(e.subarray(0,e.length>0&&10===e[e.length-1]?e.length-1:e.length))}function E(e){return e.slice(0,7)}function T(e,t,a){return`diff --git ${a.old}${e} ${a.new}${t}`}function S(e,t,a,r){return`@@ -${1===t?`${e}`:`${e},${t}`} +${1===r?`${a}`:`${a},${r}`} @@`}function O(e,t,a){return"common"===e.kind?function(e,t){const a=[];for(let r=e.oursStart;r<e.oursEnd;r++)a.push({kind:"context",oldIndex:r,newIndex:e.theirsStart+(r-e.oursStart),text:t[r]});return a}(e,t):"ours-only"===e.kind?function(e,t){const a=[];for(let r=e.oursStart;r<e.oursEnd;r++)a.push({kind:"delete",oldIndex:r,newIndex:e.theirsStart,text:t[r]});return a}(e,t):function(e,t){const a=[];for(let r=e.theirsStart;r<e.theirsEnd;r++)a.push({kind:"insert",oldIndex:e.oursEnd,newIndex:r,text:t[r]});return a}(e,a)}function N(e,t){const a="insert"!==e.kind&&e.oldIndex===t.lastOldIdx&&t.lastOldIdx===t.oldTotal-1,r="delete"!==e.kind&&e.newIndex===t.lastNewIdx&&t.lastNewIdx===t.newTotal-1;return"context"===e.kind?a&&!t.oldHasTrailingNewline||r&&!t.newHasTrailingNewline:"delete"===e.kind?a&&!t.oldHasTrailingNewline:r&&!t.newHasTrailingNewline}function D(e){return"context"===e?" ":"delete"===e?"-":"+"}function M(e){const t=[];for(const a of e)t.push(`${D(a.kind)}${a.text}`),a.trailingNoNewline&&t.push(k);return t}function C(e,t,a,r,n){const o=I(a),i=I(r),s=function(e,t,a,r){const n=g(a,r),o=[];for(const a of n.hunks)for(const r of O(a,e,t))o.push(r);return o}(o.lines,i.lines,a,r),c=function(e,t,a){if(0===e.length)return[];const r=function(e,t){const a=[];return e.forEach((e,r)=>{if("context"===e.kind)return;const n=a[a.length-1];void 0!==n&&r-n.last<=t?a[a.length-1]={first:n.first,last:r}:a.push({first:r,last:r})}),a}(e,2*t+1);return 0===r.length?[]:r.map(r=>function(e,t,a,r){const n=Math.max(0,e.first-a),o=Math.min(t.length,e.last+a+1),i=t.slice(n,o),s=function(e){let t=0,a=0,r=0,n=0,o=!1,i=!1,s=-1,c=-1;for(const d of e)"insert"!==d.kind&&(o||(t=d.oldIndex+1,o=!0),r++,s=d.oldIndex),"delete"!==d.kind&&(i||(a=d.newIndex+1,i=!0),n++,c=d.newIndex);return 0===r&&(t=e[0].oldIndex),0===n&&(a=e[0].newIndex),{oldStart:t,oldLen:r,newStart:a,newLen:n,lastOldIdx:s,lastNewIdx:c}}(i),c={...r,lastOldIdx:s.lastOldIdx,lastNewIdx:s.lastNewIdx},d=i.map(e=>({kind:e.kind,text:e.text,trailingNoNewline:N(e,c)}));return{oldStart:s.oldStart,oldLen:s.oldLen,newStart:s.newStart,newLen:s.newLen,body:d}}(r,e,t,a))}(s,n,{oldTotal:o.lines.length,newTotal:i.lines.length,oldHasTrailingNewline:o.hasTrailingNewline,newHasTrailingNewline:i.hasTrailingNewline}),d=[];d.push(`--- ${t.old}${e.path}`),d.push(`+++ ${t.new}${e.path}`);for(const e of c){d.push(S(e.oldStart,e.oldLen,e.newStart,e.newLen));for(const t of M(e.body))d.push(t)}return d}function A(e,t,a){const r=e.change;return"add"===r.type?u(e.newContent??new Uint8Array(0))?function(e,t){return[T(e.newPath,e.newPath,t),`new file mode ${e.newMode}`,`index ${y}..${E(e.newId)}`,`Binary files /dev/null and ${t.new}${e.newPath} differ`]}(r,t):function(e,t,a){const r=I(t),n=[];if(n.push(T(e.newPath,e.newPath,a)),n.push(`new file mode ${e.newMode}`),n.push(`index ${y}..${E(e.newId)}`),n.push("--- /dev/null"),n.push(`+++ ${a.new}${e.newPath}`),0===r.lines.length)return n;n.push(S(0,0,1,r.lines.length));for(const e of r.lines)n.push(`+${e}`);return r.hasTrailingNewline||n.push(k),n}(r,e.newContent,t):"delete"===r.type?u(e.oldContent??new Uint8Array(0))?function(e,t){return[T(e.oldPath,e.oldPath,t),`deleted file mode ${e.oldMode}`,`index ${E(e.oldId)}..${y}`,`Binary files ${t.old}${e.oldPath} and /dev/null differ`]}(r,t):function(e,t,a){const r=I(t),n=[];if(n.push(T(e.oldPath,e.oldPath,a)),n.push(`deleted file mode ${e.oldMode}`),n.push(`index ${E(e.oldId)}..${y}`),n.push(`--- ${a.old}${e.oldPath}`),n.push("+++ /dev/null"),0===r.lines.length)return n;n.push(S(1,r.lines.length,0,0));for(const e of r.lines)n.push(`-${e}`);return r.hasTrailingNewline||n.push(k),n}(r,e.oldContent,t):"rename"===r.type?function(e,t){return[T(e.oldPath,e.newPath,t),"similarity index 100%",`rename from ${e.oldPath}`,`rename to ${e.newPath}`]}(r,t):function(e,t,a,r,n){return function(e,t,a,r,n){const o=[];o.push(T(e.path,e.path,t));for(const t of function(e){return e.oldMode===e.newMode?[`index ${E(e.oldId)}..${E(e.newId)} ${e.newMode}`]:[`old mode ${e.oldMode}`,`new mode ${e.newMode}`,`index ${E(e.oldId)}..${E(e.newId)}`]}(e))o.push(t);if(e.oldId===e.newId)return o;if(u(a)||u(r)){for(const n of function(e,t,a,r){return[`Binary files ${0===a.length?"/dev/null":`${t.old}${e.path}`} and ${0===r.length?"/dev/null":`${t.new}${e.path}`} differ`]}(e,t,a,r))o.push(n);return o}for(const i of C(e,t,a,r,n))o.push(i);return o}(function(e){return{path:e.path,oldId:e.oldId,newId:e.newId,oldMode:e.oldMode,newMode:e.newMode}}(e),r,t,a,n)}(r,e.oldContent??new Uint8Array(0),e.newContent??new Uint8Array(0),t,a)}function H(e,t){const a=function(e){if(void 0===e)return 3;if(!Number.isInteger(e)||e<0)throw n(`contextLines must be a non-negative integer; got ${e}`);return e}(t?.contextLines);if(0===e.length)return"";const r=t?.pathPrefix??v;for(const t of e)$(t.change,r);const o=[];for(const t of e){const e=A(t,r,a);for(const t of e)o.push(t)}return o.push(""),o.join("\n")}const P=e=>{const a=e.startsWith("!"),r=a?e.slice(1):e;return t.containsGlob(r)?{pattern:e,body:r,negated:a,isLiteral:!1,compiled:t.compileGlob(r,{anchored:r.includes("/")})}:{pattern:e,body:r,negated:a,isLiteral:!0,compiled:t.compileGlob(r,{anchored:!0,withDirSuffix:!0})}},L=(e,t)=>{let a=!1;for(const r of e)r.compiled.test(t)&&(a=!r.negated);return a},U=t=>new e.TsgitError({code:"INVALID_MERGE_TREE",reason:t}),_=t=>new e.TsgitError({code:"INVALID_MERGE_INPUT",reason:t}),B=268435456,F=["<<<<<<<","=======",">>>>>>>","|||||||"],j=new TextEncoder;function W(e){return e<=31||e>=127&&e<=159}function q(e){return e>=8234&&e<=8238||e>=8294&&e<=8297||8203===e||8204===e||8205===e||8288===e||65279===e}function z(e,t){if(e.length>255)throw _(`conflict marker ${t} label exceeds maximum length`);if(""===e.trim())throw _(`conflict marker ${t} label is empty or whitespace-only`);if(function(e){for(let t=0;t<e.length;t++){const a=e.charCodeAt(t);if(W(a)||q(a))return!0}return!1}(e))throw _(`conflict marker ${t} label contains forbidden control character`);if(function(e){for(const t of F)if(e.includes(t))return!0;return!1}(e))throw _(`conflict marker ${t} label contains forbidden marker substring`)}function G(e){let t=0;for(const a of e)t+=a.length;return t}function V(e){if(0===e.length)return new Uint8Array(0);const t=G(e),a=e[e.length-1],r=0===a.length||10!==a[a.length-1],n=new Uint8Array(t+(r?1:0));let o=0;for(const t of e)n.set(t,o),o+=t.length;return r&&(n[o]=10),n}function X(e,t,a={}){if("diff3"===a.conflictStyle)throw _("diff3 conflict style requires base lines — not supported in v1");const r=a.labels?.ours??"ours",n=a.labels?.theirs??"theirs";if(z(r,"ours"),z(n,"theirs"),void 0!==a.labels?.base&&z(a.labels.base,"base"),G(e)+G(t)>B)throw _("conflict output exceeds MAX_CONFLICT_OUTPUT_BYTES");const o=j.encode(`<<<<<<< ${r}\n`),i=j.encode("=======\n"),s=j.encode(`>>>>>>> ${n}\n`),c=V(e),d=V(t),f=new Uint8Array(o.length+c.length+i.length+d.length+s.length);let l=0;return f.set(o,l),l+=o.length,f.set(c,l),l+=c.length,f.set(i,l),l+=i.length,f.set(d,l),l+=d.length,f.set(s,l),f}function Y(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==t[a])return!1;return!0}function K(e,t){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(!Y(e[a],t[a]))return!1;return!0}function Z(e){let t=0;for(const a of e)t+=a.length;const a=new Uint8Array(t);let r=0;for(const t of e)a.set(t,r),r+=t.length;return a}function J(e,t){const a=[];let r;const n=()=>{void 0!==r&&(a.push({baseStart:r.baseStart,baseEnd:r.baseEnd,replacement:r.replacement}),r=void 0)};for(const a of e)if("common"!==a.kind)if(void 0===r&&(r={baseStart:a.oursStart,baseEnd:a.oursStart,replacement:[]}),"ours-only"===a.kind)r.baseEnd=Math.max(r.baseEnd,a.oursEnd);else for(let e=a.theirsStart;e<a.theirsEnd;e++)r.replacement.push(t[e]);else n();return n(),a}function Q(e,t){return e.baseStart===e.baseEnd?t.baseStart===t.baseEnd?e.baseStart===t.baseStart:e.baseStart>=t.baseStart&&e.baseStart<t.baseEnd:t.baseStart===t.baseEnd?t.baseStart>=e.baseStart&&t.baseStart<e.baseEnd:e.baseStart<t.baseEnd&&t.baseStart<e.baseEnd}function ee(e,t){for(const a of t)if(a.baseStart===e.baseStart&&a.baseEnd===e.baseEnd&&K(a.replacement,e.replacement))return a}function te(e,t){for(const a of t)if(Q(e,a))return!0;return!1}function ae(e,t,a){return{status:"conflict",conflictType:"content",markedBytes:X(e,t,a)}}function re(e,t,a,r={}){if(u(t)||u(a)||void 0!==e&&u(e))return{status:"conflict",conflictType:"binary",markedBytes:t};if(void 0===e)return Y(t,a)?{status:"clean",bytes:t}:ae(l(t),l(a),r);if(Y(t,e))return{status:"clean",bytes:a};if(Y(a,e))return{status:"clean",bytes:t};if(Y(t,a))return{status:"clean",bytes:t};const n=g(e,t),o=g(e,a);if(n.degraded||o.degraded)return ae(l(t),l(a),r);const i=function(e,t){const a=[],r=new Set;for(const n of e){const e=ee(n,t);if(void 0===e){if(te(n,t))return;a.push(n)}else r.add(e),a.push(n)}for(const e of t)r.has(e)||a.push(e);return a.sort((e,t)=>e.baseStart-t.baseStart),{changes:a}}(J(n.hunks,n.theirsLines),J(o.hunks,o.theirsLines));if(void 0===i)return ae(l(t),l(a),r);const s=function(e,t){const a=[];let r=0;for(const n of t.changes){for(let t=r;t<n.baseStart;t++)a.push(e[t]);for(const e of n.replacement)a.push(e);r=n.baseEnd}for(let t=r;t<e.length;t++)a.push(e[t]);return a}(n.oursLines,i);return{status:"clean",bytes:Z(s)}}function ne(e,t){return e.id===t.id&&e.mode===t.mode}function oe(e,a){if(void 0!==e&&e.entries.size>t.MAX_FLAT_TREE_ENTRIES)throw U(`${a} FlatTree exceeds MAX_FLAT_TREE_ENTRIES`)}function ie(e){return{status:"conflict",conflict:e}}function se(e,t,a,r){return ie({type:"modify-delete",path:e,baseId:t.id,baseMode:t.mode,...void 0===a?{}:{ourId:a.id,ourMode:a.mode},...void 0===r?{}:{theirId:r.id,theirMode:r.mode}})}function ce(e,t,a,r){return void 0===t?{status:"resolved-known",path:e,id:a.id,mode:a.mode}:ne(t,a)?{status:"resolved-deleted",path:e}:"our"===r?se(e,t,a,void 0):se(e,t,void 0,a)}function de(e,a,r,n,o){return void 0===r&&void 0===n?{status:"resolved-deleted",path:e}:void 0===r?ce(e,a,n,"their"):void 0===n?ce(e,a,r,"our"):void 0===a?function(e,t,a){return ne(t,a)?{status:"resolved-known",path:e,id:t.id,mode:t.mode}:function(e,t,a){return ie({type:"add-add",path:e,ourId:t.id,theirId:a.id,ourMode:t.mode,theirMode:a.mode})}(e,t,a)}(e,r,n):async function(e,a,r,n,o){const i=ne(a,r),s=ne(a,n);if(i&&s)return{status:"unchanged",path:e,id:a.id,mode:a.mode};if(i)return{status:"resolved-known",path:e,id:n.id,mode:n.mode};if(s)return{status:"resolved-known",path:e,id:r.id,mode:r.mode};if(ne(r,n))return{status:"resolved-known",path:e,id:r.id,mode:r.mode};if(!t.isSameKind(r.mode,n.mode)||!t.isSameKind(a.mode,r.mode))return function(e,t,a,r){return ie({type:"type-change",path:e,baseId:t.id,ourId:a.id,theirId:r.id,baseMode:t.mode,ourMode:a.mode,theirMode:r.mode})}(e,a,r,n);const c=function(e,t,a){return t.mode===a.mode?t.mode:t.mode===e.mode?a.mode:t.mode}(a,r,n);return function(e){return e===t.FILE_MODE.GITLINK}(c)?function(e,t,a,r){return ie({type:"gitlink",path:e,baseId:t.id,ourId:a.id,theirId:r.id,baseMode:t.mode,ourMode:a.mode,theirMode:r.mode})}(e,a,r,n):async function(e,t,a,r,n,o){const i={path:e,baseId:t.id,ourId:a.id,theirId:r.id,baseMode:t.mode,ourMode:a.mode,theirMode:r.mode},s=await o(i,void 0,new Uint8Array(0),new Uint8Array(0));if("clean"===s.status){if(s.bytes.length>B)throw _("contentMerger returned oversize clean bytes");return void 0!==s.id?{status:"resolved-known",path:e,id:s.id,mode:n}:{status:"resolved-merged",path:e,bytes:s.bytes,mode:n}}if(s.markedBytes.length>B)throw _("contentMerger returned oversize marked bytes");return ie({type:s.conflictType,path:e,baseId:t.id,ourId:a.id,theirId:r.id,baseMode:t.mode,ourMode:a.mode,theirMode:r.mode,conflictContent:s.markedBytes})}(e,a,r,n,c,o)}(e,a,r,n,o)}async function fe(e,a,r,n){oe(e,"base"),oe(a,"ours"),oe(r,"theirs");const o=function(e,a,r){const n=new Set;for(const t of[e,a,r])if(void 0!==t)for(const e of t.entries.keys())n.add(e);if(n.size>t.MAX_FLAT_TREE_ENTRIES)throw U("union FlatTree exceeds MAX_FLAT_TREE_ENTRIES");return n}(e,a,r),i=t.sortByPath([...o],e=>e),s=[];for(const t of i){const o=de(t,e?.entries.get(t),a?.entries.get(t),r?.entries.get(t),n),i=o instanceof Promise?await o:o;s.push(i)}const c=function(e){const t=[];for(const a of e)"conflict"===a.status&&t.push(a.conflict);return t}(s);return{outcomes:s,conflicts:c,cleanMerge:0===c.length}}const le="blob:limit=",ue="tree:",we=/^(\d+)([kmg])?$/i,me=/^\d+$/,pe=e=>{if(""===e)throw t.invalidFilterSpec(e,"empty");if("blob:none"===e)return{kind:"blob-none"};if(e.startsWith(le))return(e=>{const a=e.slice(11).match(we);if(null===a)throw t.invalidFilterSpec(e,"bad-blob-limit");const r=Number(a[1])*(e=>{switch(e?.toLowerCase()){case"k":return 1024;case"m":return 1048576;case"g":return 1073741824;default:return 1}})(a[2]);if(!Number.isSafeInteger(r))throw t.invalidFilterSpec(e,"bad-blob-limit");return{kind:"blob-limit",bytes:r}})(e);if(e.startsWith(ue))return(e=>{const a=e.slice(5);if(!me.test(a))throw t.invalidFilterSpec(e,"bad-tree-depth");const r=Number(a);if(!Number.isSafeInteger(r))throw t.invalidFilterSpec(e,"bad-tree-depth");return{kind:"tree-depth",depth:r}})(e);throw t.invalidFilterSpec(e,"unknown-kind")},he=e=>{switch(e.kind){case"blob-none":return"blob:none";case"blob-limit":return`${le}${e.bytes}`;case"tree-depth":return`${ue}${e.depth}`}},ge=new TextDecoder("utf-8",{fatal:!1}),ye=new TextEncoder,ve=e=>e.endsWith("\n")?e.slice(0,-1):e,ke=e=>{if(e.startsWith("ok "))return{name:e.slice(3),accepted:!0};if(e.startsWith("ng ")){const a=e.slice(3),r=a.indexOf(" ");if(r<0)throw t.invalidReportStatus(e);return{name:a.slice(0,r),accepted:!1,reason:a.slice(r+1)}}throw t.invalidReportStatus(e)},be=async e=>{const a=await(async e=>{const t=[];for await(const a of e){if("data"!==a.kind)return t;t.push(ve(ge.decode(a.payload)))}return t})(e);if(0===a.length)throw t.invalidReportStatus("");const[r,...n]=a,o=(e=>{if("unpack ok"===e)return{ok:!0};if(e.startsWith("unpack "))return{ok:!1,error:e.slice(7)};throw t.invalidReportStatus(e)})(r);return o.ok?{unpackOk:!0,refUpdates:n.map(ke)}:{unpackOk:!1,unpackError:o.error,refUpdates:[]}},xe={second:1,minute:60,hour:3600,day:86400,week:604800,month:2592e3,year:31536e3},$e=/^(\d{4})-(\d{2})-(\d{2})(?: (\d{2}):(\d{2}):(\d{2}))?$/,Ie=/^(\d+)[ .]([a-z]+?)s?(?:[ .]ago)?$/;function Re(e,t){const a=e.trim().toLowerCase();return"now"===a?t:"yesterday"===a?t-86400:function(e){const t=$e.exec(e);if(null===t)return;const[,a,r,n,o,i,s]=t,c=Number(a),d=Number(r),f=Number(n),l=void 0===o?0:Number(o),u=void 0===i?0:Number(i),w=void 0===s?0:Number(s);if(d<1||d>12)return;if(f<1||f>function(e,t){return 2===t&&function(e){return e%4==0&&e%100!=0||e%400==0}(e)?29:Ee[t-1]}(c,d))return;if(l>23)return;if(u>59)return;if(w>59)return;const m=new Date(c,d-1,f,l,u,w);return m.setFullYear(c),Math.floor(m.getTime()/1e3)}(a)??function(e,t){const a=Ie.exec(e);if(null===a)return;const[,r,n]=a,o=xe[n];return void 0===o?void 0:t-Number(r)*o}(a,t)}const Ee=[31,28,31,30,31,30,31,31,30,31,30,31],Te=e=>[e,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],Se=e=>`${e.layout.gitDir}/MERGE_HEAD`,Oe=e=>`${e.layout.gitDir}/MERGE_MSG`,Ne=e=>`${e.layout.gitDir}/ORIG_HEAD`,De=async(e,t)=>{await e.fs.writeUtf8(Oe(e),t)},Me=async(e,t)=>{await e.fs.writeUtf8(Ne(e),`${t}\n`)},Ce=async e=>{const a=Se(e);if(!await e.fs.exists(a))return;const r=(await e.fs.readUtf8(a)).trim();return 0!==r.length?t.ObjectId.from(r):void 0},Ae=async e=>{const t=Oe(e);if(await e.fs.exists(t))return e.fs.readUtf8(t)},He=async e=>{for(const t of[Se(e),Oe(e)])await e.fs.exists(t)&&await e.fs.rm(t)},Pe=async e=>{const t=Oe(e);await e.fs.exists(t)&&await e.fs.rm(t)},Le=async(e,a)=>{const r=await t.loadSparseMatcher(e),n=await t.readObject(e,a);if("commit"!==n.type)throw t.unexpectedObjectType("commit",n.type,a);const o=await t.acquireIndexLock(e);try{const a=await t.readIndex(e),i=await t.materializeTree(e,{targetTree:n.data.tree,currentIndex:a,force:!0,forceRewriteAll:!0,...void 0!==r?{sparse:r}:{}});await o.commit(i.newIndexEntries)}finally{await o.release()}},Ue=t.validateWorkingTreePath,_e=(e,t)=>`${e.layout.workDir}/${t}`,Be=async(t,a)=>{const r=Ue(a),n=_e(t,r);let o;try{o=await t.fs.lstat(n)}catch{throw e.checkoutOverwriteDirty([r])}if(!o.isFile&&!o.isSymbolicLink)throw e.checkoutOverwriteDirty([r]);await t.fs.rm(n)},Fe=async(e,t,a)=>{const r=Ue(t),n=Ue(a);await je(e,_e(e,r),_e(e,n))},je=async(t,a,r)=>{const n=await t.fs.lstat(a);if(!n.isDirectory||n.isSymbolicLink)await t.fs.mkdir(e.dirname(r)),await t.fs.rename(a,r);else{for(const e of await t.fs.readdir(a))await je(t,`${a}/${e.name}`,`${r}/${e.name}`);await t.fs.rmRecursive(a)}},We=new TextEncoder,qe=e=>{for(const t of e){const e=t.startsWith("!")?t.slice(1):t;Ue(e),ze(t)}const t=(e=>e.map(P))(e),a=t.filter(Xe).map(e=>Ke(e)),r=t.some(Ye);return{matcher:t,literalMustMatch:a,hasGlob:r}},ze=t=>{if(We.encode(t).byteLength>256)throw e.invalidOption("paths","pattern exceeds max length 256 bytes");if(Ge(t)>4)throw e.invalidOption("paths","pattern exceeds max **-token count 4")},Ge=e=>{let t=0,a=0;for(;a<e.length;)"*"!==e[a]||"*"!==e[a+1]?a+=1:(t+=1,a+=2);return t},Ve=(t,a)=>{if(0===t.length)return;const r=new Set(a);for(const n of t)if(!r.has(n)&&!a.some(e=>e.startsWith(`${n}/`)))throw e.pathspecNoMatch(n)},Xe=e=>!e.negated&&e.isLiteral,Ye=e=>!e.negated&&!e.isLiteral,Ke=e=>e.body,Ze=new Set(["FILE_NOT_FOUND","INVALID_INDEX_HEADER","INVALID_INDEX_ENTRY"]),Je=async(a,r,n)=>{const o=await t.acquireIndexLock(a,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const t=await nt(a),n=new Map(t),i=[],s=[];for(const o of r){const r=await ot(a,o);if("missing"===r)throw e.pathspecNoMatch(o);const c=t.get(o);n.set(o,r),void 0===c?i.push(o):c.id===r.id&&c.mode===r.mode||s.push(o)}return await o.commit(Array.from(n.values())),{added:i,modified:s,removed:[]}}finally{await o.release()}},Qe=async(e,t)=>{if(0===t.length)return!1;for(const a of t){const t=await e.fs.lstat(`${e.layout.workDir}/${a}`).catch(()=>{});if(void 0===t)return!1;if(t.isDirectory&&!t.isSymbolicLink)return!1}return!0},et=async(e,a,r,n)=>{const o=await t.buildRepoIgnorePredicate(e),i=async(e,t)=>!!await o(e,t)||!t&&!L(a,e),s=await t.acquireIndexLock(e,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const a=await nt(e),n=new Map(a),o=[],c=[],d=[],f=new Set;for await(const r of t.walkWorkingTree(e,{ignore:i})){const t=await rt(e,r,a,f);void 0!==t&&(o.push(t.path),n.set(t.path,t.entry),"added"===t.kind?c.push(t.path):"modified"===t.kind&&d.push(t.path))}return Ve(r,o),c.sort(),d.sort(),await s.commit(Array.from(n.values())),{added:c,modified:d,removed:[]}}finally{await s.release()}},tt=async(e,t,a)=>{const r=[];for(const[n,o]of e)t.has(n)||o.flags.skipWorktree||await at(n,a)||r.push(n);return r},at=async(e,t)=>{if(await t(e,!1))return!0;const a=e.split("/");for(let e=1;e<a.length;e+=1){const r=a.slice(0,e).join("/");if(await t(r,!0))return!0}return!1},rt=async(a,r,n,o)=>{const{path:i,stat:s}=r;if(o.add(i),s.size>t.MAX_WORKING_TREE_BLOB_BYTES)throw e.workingTreeFileTooLarge(i,s.size,t.MAX_WORKING_TREE_BLOB_BYTES);const c=await it(a,i,s),d=n.get(i);return void 0===d?{kind:"added",path:i,entry:c}:d.id!==c.id||d.mode!==c.mode?{kind:"modified",path:i,entry:c}:{kind:"unchanged",path:i,entry:c}},nt=async a=>{try{const e=await t.readIndex(a),r=new Map;for(const t of e.entries)r.set(t.path,t);return r}catch(t){if(t instanceof e.TsgitError&&Ze.has(t.data.code))return new Map;throw t}},ot=async(e,t)=>{const a=await e.fs.lstat(`${e.layout.workDir}/${t}`).catch(()=>{});return void 0===a?"missing":it(e,t,a)},it=async(a,r,n)=>{const o=await a.fs.lstat(`${a.layout.workDir}/${r}`);if(o.isSymbolicLink!==n.isSymbolicLink||o.isDirectory!==n.isDirectory||o.isFile!==n.isFile)throw e.operationAborted();if(o.size>t.MAX_WORKING_TREE_BLOB_BYTES)throw e.workingTreeFileTooLarge(r,o.size,t.MAX_WORKING_TREE_BLOB_BYTES);const i=t.deriveWorkingMode(o),s=await st(a,r,o),c=await t.writeObject(a,{type:"blob",id:"",content:s});return ct(o,i,c,r)},st=async(a,r,n)=>{if(n.isSymbolicLink){const n=(new TextEncoder).encode(await a.fs.readlink(`${a.layout.workDir}/${r}`));if(n.byteLength>t.MAX_WORKING_TREE_BLOB_BYTES)throw e.workingTreeFileTooLarge(r,n.byteLength,t.MAX_WORKING_TREE_BLOB_BYTES);return n}return(async(e,t)=>{const a=Ue(t);return e.fs.read(_e(e,a))})(a,r)},ct=(e,a,r,n)=>({ctimeSeconds:Math.floor(e.ctimeMs/1e3),ctimeNanoseconds:0,mtimeSeconds:Math.floor(e.mtimeMs/1e3),mtimeNanoseconds:0,dev:e.dev,ino:e.ino,mode:a,uid:e.uid,gid:e.gid,fileSize:e.size,id:r,flags:t.STAGE0_FLAGS,path:n}),dt="refs/heads/",ft=async e=>{await t.assertRepository(e);const a=`${e.layout.gitDir}/refs/heads`;if(!await e.fs.exists(a))return{branches:[]};const r=await t.readHeadRaw(e),n="symbolic"===r.kind&&r.target.startsWith(dt)?r.target:void 0,o=await e.fs.readdir(a),i=[];for(const a of o){if(!a.isFile)continue;const r=`${dt}${a.name}`,o=await t.resolveRef(e,r);i.push({name:r,id:o,current:r===n})}return i.sort((e,t)=>lt(e.name,t.name)),{branches:i}},lt=(e,t)=>e<t?-1:e>t?1:0,ut=async(a,r)=>{await t.assertRepository(a);const n=t.validateRefName(`${dt}${r.name}`),o=r.startPoint??"HEAD",i=await pt(a,o),s=`branch: Created from ${o}`;try{await t.updateRef(a,n,i,!0===r.force?{reflogMessage:s}:{expected:"absent",reflogMessage:s})}catch(t){if(t instanceof e.TsgitError&&"REF_UPDATE_CONFLICT"===t.data.code)throw e.branchExists(n);throw t}return{name:n,id:i}},wt=async(a,r)=>{await t.assertRepository(a);const n=t.validateRefName(`${dt}${r.name}`),o=await t.readHeadRaw(a);if("symbolic"===o.kind&&o.target===n)throw e.cannotDeleteCheckedOutBranch(n);if(!await a.fs.exists(`${a.layout.gitDir}/${n}`))throw e.branchNotFound(n);return await t.updateRef(a,n,t.ZERO_OID,{delete:!0}),{name:n}},mt=async(a,r)=>{await t.assertRepository(a);const n=t.validateRefName(`${dt}${r.from}`),o=t.validateRefName(`${dt}${r.to}`),i=await t.resolveRef(a,n),s=`branch: renamed ${n} to ${o}`,c=await t.readReflog(a,n);try{await t.updateRef(a,o,i,!0===r.force?{reflogMessage:s}:{expected:"absent",reflogMessage:s})}catch(t){if(t instanceof e.TsgitError&&"REF_UPDATE_CONFLICT"===t.data.code)throw e.branchExists(o);throw t}c.length>0&&await t.writeReflog(a,o,[...c,...await t.readReflog(a,o)]),await t.updateRef(a,n,t.ZERO_OID,{delete:!0});const d=await t.readHeadRaw(a);return"symbolic"===d.kind&&d.target===n&&await t.writeSymbolicRef(a,"HEAD",o),{from:n,to:o}},pt=async(a,r)=>{if(/^[0-9a-f]{40}$/.test(r))return r;const n="HEAD"===r?["HEAD"]:[`${dt}${r}`,r];for(const e of n)try{return await t.resolveRef(a,e)}catch{}throw e.branchNotFound(r)},ht=e=>"string"==typeof e?t.ObjectId.from(e):e,gt="refs/heads/",yt="checkout:materialize",vt=async(e,a)=>{if("HEAD"===a){const a=await t.resolveRef(e,"HEAD");return(await t.readTree(e,a)).id}return(await t.readTree(e,a)).id},kt=e=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:e,uid:0,gid:0,fileSize:0}),bt=(e,a,r)=>({...kt(r),id:a,flags:t.STAGE0_FLAGS,path:e}),xt=async(e,t,a)=>{const r=`${e.layout.workDir}/${t}`,n=(e=>{const t=e.lastIndexOf("/");if(!(t<=0))return e.slice(0,t)})(r);void 0!==n&&await e.fs.mkdir(n),await e.fs.write(r,a)},$t=async(e,t)=>{const a=`${e.layout.workDir}/${t}`;await e.fs.exists(a)&&await e.fs.rm(a)},It=new Set(["rename-rename","gitlink"]),Rt=e=>async a=>{const[r,n,o]=await Promise.all([t.readBlob(e,a.ourId,{maxBytes:B}),t.readBlob(e,a.theirId,{maxBytes:B}),void 0!==a.baseId?t.readBlob(e,a.baseId,{maxBytes:B}):Promise.resolve(void 0)]);return re(o?.content,r.content,n.content)},Et=(e,t)=>{if("unchanged"===e.status)return!1;if("resolved-known"===e.status){const a=t.get(e.path);return void 0===a||a.id!==e.id||a.mode!==e.mode}return"resolved-merged"===e.status||"resolved-deleted"===e.status&&t.has(e.path)},Tt=async(e,a)=>{const r=[];for(const n of a)if("resolved-deleted"!==n.status&&"conflict"!==n.status){if("resolved-merged"===n.status){const a=await t.writeObject(e,{type:"blob",content:n.bytes,id:""});r.push(bt(n.path,a,n.mode));continue}r.push(bt(n.path,n.id,n.mode))}return t.synthesizeTreeFromIndex(e,r)},St=async(e,a)=>{if("content"===a.type&&void 0!==a.conflictContent)return a.conflictContent;if("modify-delete"===a.type){const r=a.ourId??a.theirId;return void 0!==r?(await t.readBlob(e,r,{maxBytes:B})).content:void 0}return void 0!==a.ourId?(await t.readBlob(e,a.ourId,{maxBytes:B})).content:void 0},Ot=(e,t)=>{const a=[];for(const t of e)"unchanged"!==t.status&&"resolved-known"!==t.status||a.push(bt(t.path,t.id,t.mode));const r=[...a,...d(t,kt)];return r.sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:e.flags.stage-t.flags.stage),r},Nt=async(a,r)=>{const[n,o,i]=await Promise.all([void 0!==r.baseTree?t.flattenTree(a,r.baseTree):Promise.resolve(void 0),t.flattenTree(a,r.oursTree),t.flattenTree(a,r.theirsTree)]),s=await fe(n,o,i,Rt(a));s.cleanMerge||(t=>{for(const a of t)if(It.has(a.type))throw e.unsupportedOperation("apply-merge",`conflict type '${a.type}' not supported (path=${a.path})`)})(s.conflicts);const c=((e,t,a)=>{const r=new Set;for(const t of e)"conflict"!==t.status&&Et(t,a)&&r.add(t.path);for(const e of t)r.add(e.path);return r})(s.outcomes,s.conflicts,o.entries),d=await(async(e,a,r)=>{const n=new Map;for(const e of r.entries)0===e.flags.stage&&n.set(e.path,e);const o=[];for(const r of a){const a=n.get(r);void 0!==a?"modified"===await t.compareWorkingTreeEntry(e,a)&&o.push(r):await e.fs.exists(`${e.layout.workDir}/${r}`)&&o.push(r)}return o})(a,c,r.currentIndex);if(d.length>0)return{kind:"would-overwrite",paths:d};if(s.cleanMerge){const e=await Tt(a,s.outcomes);return{kind:"clean",mergedTree:e,result:await t.materializeTree(a,{targetTree:e,currentIndex:r.currentIndex,force:!0})}}return await(async(e,a,r,n)=>{for(const r of a)if("conflict"!==r.status&&n.has(r.path))if("resolved-deleted"!==r.status)if("resolved-merged"!==r.status){if("resolved-known"===r.status){const a=await t.readBlob(e,r.id,{maxBytes:B});await xt(e,r.path,a.content)}}else await xt(e,r.path,r.bytes);else await $t(e,r.path);for(const t of r){const a=await St(e,t);void 0!==a&&await xt(e,t.path,a)}})(a,s.outcomes,s.conflicts,c),{kind:"conflict",conflicts:s.conflicts,indexEntries:Ot(s.outcomes,s.conflicts)}},Dt=/^(pick|revert) (\S+) (.*)$/,Mt=/^[0-9a-f]{40}$/,Ct=/^[0-9a-f]{4,39}$/,At=/^[0-9a-f]{38}$/,Ht=async(e,a)=>{const r=t.objectsDir(e.layout.gitDir,a.slice(0,2));if(!await e.fs.exists(r))return[];const n=a.slice(2),o=[];for(const t of await e.fs.readdir(r))t.isFile&&At.test(t.name)&&t.name.startsWith(n)&&o.push(a.slice(0,2)+t.name);return o},Pt=async(e,a)=>{const r=await t.getPackRegistry(e).all(),n=[];for(const e of r)for(const r of t.findByPrefix(e.index,a))n.push(r);return n},Lt=async(t,a)=>{if(Mt.test(a))return a;if(!Ct.test(a))return;const[r,n]=await Promise.all([Ht(t,a),Pt(t,a)]),o=[...new Set([...r,...n])];if(0!==o.length){if(1===o.length)return o[0];throw e.ambiguousOidPrefix(a,o.slice(0,16))}},Ut=async(e,a)=>{if(!await e.fs.exists(a))return;const r=(await e.fs.readUtf8(a)).trim();return 0!==r.length?t.ObjectId.from(r):void 0},_t=e=>`${e.layout.gitDir}/sequencer`,Bt=e=>`${_t(e)}/head`,Ft=e=>`${_t(e)}/todo`,jt=e=>`${_t(e)}/opts`,Wt=(e,t)=>e.fs.writeUtf8(Bt(e),`${t}\n`),qt=e=>Ut(e,Bt(e)),zt=(e,t)=>e.fs.writeUtf8((e=>`${_t(e)}/abort-safety`)(e),`${t}\n`),Gt=(e,t)=>e.fs.writeUtf8(Ft(e),(e=>e.map(e=>`${e.command} ${e.oid} ${e.subject}\n`).join(""))(t)),Vt=async t=>{const a=Ft(t);if(!await t.fs.exists(a))return;const r=(t=>{const a=[];for(const r of t.split("\n")){if(""===r||r.startsWith("#"))continue;const t=Dt.exec(r);if(null===t)throw e.invalidSequencerTodo(r);a.push({command:t[1],oid:t[2],subject:t[3]})}return a})(await t.fs.readUtf8(a)),n=[];for(const a of r){const r=await Lt(t,a.oid);if(void 0===r)throw e.invalidSequencerTodo(`cannot resolve commit ${a.oid}`);n.push({command:a.command,oid:r,subject:a.subject})}return n},Xt=async(e,t)=>{(t.noCommit||t.recordOrigin||t.allowEmpty)&&await e.fs.writeUtf8(jt(e),(e=>{let t="[options]\n";return e.noCommit&&(t+="\tno-commit = true\n"),e.recordOrigin&&(t+="\trecord-origin = true\n"),e.allowEmpty&&(t+="\tallow-empty = true\n"),t})(t))},Yt=(e,t)=>e.some(e=>"options"===e.section.toLowerCase()&&e.entries.some(e=>e.key.toLowerCase()===t&&"true"===e.value.toLowerCase())),Kt=async e=>{const t=_t(e);await e.fs.exists(t)&&await e.fs.rmRecursive(t)},Zt=async(e,a)=>{await Le(e,a.target),await t.updateRef(e,a.branch,a.target,{reflogMessage:`reset: moving to ${a.target}`}),await a.clearHead(e),await Pe(e),await Kt(e)},Jt=e=>`${e.layout.gitDir}/CHERRY_PICK_HEAD`,Qt=e=>Ut(e,Jt(e)),ea=async e=>{const t=Jt(e);await e.fs.exists(t)&&await e.fs.rm(t)},ta=(e,t)=>`${e.replace(/\s+$/,"")}\n\n# Conflicts:\n${t.map(e=>`#\t${e}\n`).join("")}`,aa=async(e,a,r)=>{const n=await t.flattenTree(e,r),o=new Set(a.map(e=>e.path)),i=[];for(const e of a){const t=n.entries.get(e.path);void 0!==t&&t.id===e.id&&t.mode===e.mode||i.push(e.path)}for(const e of n.entries.keys())o.has(e)||i.push(e);return i},ra=async(e,a)=>{const r=[];for(const n of a)n.flags.skipWorktree||"unchanged"!==await t.compareWorkingTreeEntry(e,n)&&r.push(n.path);return r},na=async(a,r)=>{const{stage0:n,unmerged:o}=(e=>{const t=[],a=[];for(const r of e)0===r.flags.stage?t.push(r):a.push(r.path);return{stage0:t,unmerged:a}})((await t.readIndex(a)).entries),i=new Set([...o,...await aa(a,n,r),...await ra(a,n)]);if(i.size>0)throw e.workingTreeDirty([...i])},oa=async(e,a)=>{if(/^[0-9a-f]{40}$/.test(a))return a;for(const r of Te(a))try{return await t.resolveRef(e,r,{peel:!0})}catch{}const r=await Lt(e,a);if(void 0!==r)return r;throw t.refNotFound(a)},ia=t=>{if(void 0!==t.explicit)return t.explicit;if(void 0!==t.configUser)return t.configUser;throw e.authorUnconfigured()},sa=t=>{if(void 0!==t.explicit)return t.explicit;if(void 0!==t.author)return t.author;if(void 0!==t.configUser)return t.configUser;throw e.authorUnconfigured()},ca=(t,a)=>{const r=(e=>{const t=[];for(const a of e.split("\n")){const e=a.replace(o,"");(""!==e||0!==t.length&&""!==t[t.length-1])&&t.push(e)}return""===t[t.length-1]&&t.pop(),0===t.length?"":`${t.join("\n")}\n`})(t);if(""===r&&!a.allowEmpty)throw e.emptyCommitMessage();return r},da=e=>e.split("\n").filter(e=>!e.startsWith("#")).join("\n"),fa=async e=>{const a=(await t.readConfig(e)).user,r=void 0!==a?{name:a.name,email:a.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}:void 0;return sa(void 0!==r?{configUser:r}:{})},la=async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);return r.data},ua=async(e,t)=>(await la(e,t)).tree,wa=async(a,r)=>{const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.unsupportedOperation(r,"cannot run with detached HEAD");return n.target},ma=new Set(["commit","tree","blob","tag"]),pa=/^:(\d):(.+)$/,ha=/^[0-9a-f]{1,3}$/,ga=t=>{throw e.revparseUnresolved(t)},ya=/^\d+$/,va=e=>{for(let t=0;t<e.length;t+=1){const a=e[t];if("~"===a||"^"===a)return t}return-1},ka=(e,t)=>{const a=[];let r=t;for(;r<e.length;){const t=e[r];if("~"===t){const t=ba(e,r);a.push(t.op),r=t.next}else if("^"===t){const t=xa(e,r);a.push(t.op),r=t.next}else ga(e)}return a},ba=(e,t)=>{let a=t+1;for(;a<e.length&&$a(e.charCodeAt(a));)a+=1;return a===t+1&&ga(e),{op:{kind:"ancestor",n:Number(e.slice(t+1,a))},next:a}},xa=(e,t)=>{if("{"===e[t+1]){const a=e.indexOf("}",t+2);-1===a&&ga(e);const r=e.slice(t+2,a);return ma.has(r)||ga(e),{op:{kind:"peel",target:r},next:a+1}}let a=t+1;for(;a<e.length&&$a(e.charCodeAt(a));)a+=1;const r=e.slice(t+1,a);return{op:{kind:"parent",n:""===r?1:Number(r)},next:a}},$a=e=>e>=48&&e<=57,Ia=async(e,a)=>{await t.assertRepository(e);const r=(""===(n=a)&&ga(n),n.startsWith(":")?(e=>{const t=pa.exec(e);null===t&&ga(e);const a=t[2],r=Number(t[1]);return r>3&&ga(e),{kind:"index-stage",stage:r,path:a}})(n):n.includes("@{")?(e=>{const t=e.indexOf("@{"),a=e.indexOf("}",t+2),r=e.slice(0,t),n=e.slice(t+2,a);return""===n&&ga(e),{kind:"ref-or-hex",base:r,reflog:ya.test(n)?{kind:"index",n:Number(n)}:{kind:"date",raw:n},operations:ka(e.slice(a+1),0)}})(n):(e=>{const t=va(e),a=-1===t?e:e.slice(0,t);return""===a&&ga(e),ha.test(a)&&-1===t&&ga(e),{kind:"ref-or-hex",base:a,operations:-1===t?[]:ka(e,t)}})(n));var n;return Ra(e,r,a)},Ra=async(e,t,a)=>{if("index-stage"===t.kind)return La(e,t);const r=Math.floor(Date.now()/1e3);let n=void 0!==t.reflog?await Ta(e,t.base,t.reflog,r,a):await Ea(e,t.base);for(const a of t.operations)n=await Aa(e,n,a);return n},Ea=async(e,a)=>{if(/^[0-9a-f]{40}$/.test(a))return t.ObjectId.from(a);for(const r of Te(a))try{return await t.resolveRef(e,r)}catch{}const r=await Lt(e,a);if(void 0!==r)return r;throw t.objectNotFound(a)},Ta=async(a,r,n,o,i)=>{const s=""===r?await Sa(a):await Oa(a,r),c=await t.readReflog(a,s);if(0===c.length)throw e.revparseUnresolved(i);return"index"===n.kind?Ma(c,n.n,s):Ca(c,n.raw,o,i)},Sa=async e=>{const a=await t.getRefStore(e).resolveDirect("HEAD");return"symbolic"===a.kind?a.target:"HEAD"},Oa=async(e,a)=>{const r=Na(a),n=Te(r);for(const a of n)if(await t.reflogExists(e,a))return a;for(const t of n)if(await Da(e,t))return t;return r},Na=a=>{try{return t.validateRefName(a)}catch{throw e.revparseUnresolved(a)}},Da=async(e,a)=>{try{return await t.resolveRef(e,a),!0}catch{return!1}},Ma=(e,a,r)=>{const n=e[e.length-1-a];if(void 0===n)throw t.reflogEntryOutOfRange(r,a,e.length);return n.newId},Ca=(t,a,r,n)=>{const o=Re(a,r);if(void 0===o)throw e.revparseUnresolved(n);for(let e=t.length-1;e>=0;e-=1){const a=t[e];if(a.identity.timestamp<=o)return a.newId}return t[0].oldId},Aa=async(e,t,a)=>{if("parent"===a.kind)return Ha(e,t,a.n);if("ancestor"===a.kind){let r=t;for(let t=0;t<a.n;t+=1)r=await Ha(e,r,1);return r}return Pa(e,t,a.target)},Ha=async(e,a,r)=>{const n=await t.readObject(e,a);if("commit"!==n.type)throw t.objectNotFound(a);const o=n.data.parents[r-1];if(void 0===o)throw t.objectNotFound(a);return o},Pa=async(e,a,r)=>{let n=a;for(let a=0;a<5;a+=1){const a=await t.readObject(e,n);if(a.type===r)return n;if("tag"!==a.type){if("tree"===r&&"commit"===a.type)return a.data.tree;throw t.objectNotFound(n)}n=a.data.object}throw t.objectNotFound(n)},La=async(e,a)=>{const r=await t.readIndex(e);for(const e of r.entries)if(e.path===a.path&&e.flags.stage===a.stage)return e.id;throw t.objectNotFound(`${a.stage}:${a.path}`)},Ua=e=>e.parents.length>=2,_a=e=>e.map(e=>({path:e.path,type:e.type})),Ba=/^(.+)\.\.(.+)$/,Fa=async(e,a,r)=>{const n=new Set;for await(const r of t.walkCommits(e,{from:[a]}))n.add(r.id);const o=[];for await(const a of t.walkCommits(e,{from:[r],until:[...n]}))o.push(a.id);return o.reverse()},ja=async(e,t,a,r,n)=>{await Wt(e,t.sequenceHead),await Gt(e,await(async(e,t)=>{const a=[];for(const r of t){const t=await la(e,r);a.push({command:"pick",oid:r,subject:i(t.message)})}return a})(e,a)),await zt(e,r),await Xt(e,{recordOrigin:n.recordOrigin,allowEmpty:n.allowEmpty,noCommit:!1})},Wa=async(t,a,r,n,o,i)=>{let s=n;const c=[];for(let n=0;n<a.length;n+=1){const d=a[n],f=await la(t,d);if(Ua(f))throw i.multiPick&&await ja(t,i,a.slice(n),s,o),e.cherryPickMergeNoMainline(d);const l=await za(t,d,f,r,s,o);if("committed"===l.kind){c.push({source:d,created:l.id}),s=l.id;continue}await Ga(t,d,f,"conflict"===l.kind?l.conflicts:void 0,o),i.multiPick&&await ja(t,i,a.slice(n),s,o);const u=a.length-(n+1);return"conflict"===l.kind?{kind:"conflict",commit:d,conflicts:_a(l.conflicts),remaining:u}:{kind:"empty",commit:d,remaining:u}}return await Kt(t),{kind:"picked",commits:c}},qa=(e,t,a)=>a?((e,t)=>`${e.replace(/\s+$/,"")}\n\n(cherry picked from commit ${t})`)(e,t):e,za=async(a,r,n,o,s,c)=>{const d=n.parents[0],f=void 0!==d?await ua(a,d):void 0,l=await ua(a,s),u=await t.acquireIndexLock(a);try{const d=await t.readIndex(a),w=await Nt(a,{baseTree:f,oursTree:l,theirsTree:n.tree,currentIndex:d});if("would-overwrite"===w.kind)throw e.workingTreeDirty(w.paths);if("conflict"===w.kind)return await u.commit(w.indexEntries),{kind:"conflict",conflicts:w.conflicts};if(w.mergedTree===l&&!c.allowEmpty)return{kind:"empty"};await u.commit(w.result.newIndexEntries);const m=await(async(e,a,r,n,o,i)=>{const s=await fa(e);return t.createCommit(e,{tree:o,parents:[n],author:r.author,committer:s,message:ca(qa(r.message,a,i.recordOrigin),{allowEmpty:!1}),extraHeaders:[]})})(a,r,n,s,w.mergedTree,c);return await t.updateRef(a,o,m,{expected:s,reflogMessage:`cherry-pick: ${i(n.message)}`}),{kind:"committed",id:m}}finally{await u.release()}},Ga=async(e,t,a,r,n)=>{await(async(e,t)=>{await e.fs.writeUtf8(Jt(e),`${t}\n`)})(e,t);const o=qa(a.message,t,n.recordOrigin),i=void 0!==r&&r.length>0?ta(o,r.map(e=>e.path)):o;await De(e,i)},Va=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"cherry-pick"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.unsupportedOperation("cherry-pick","cannot cherry-pick with detached HEAD");const o=await(async(a,r)=>{try{return await t.resolveRef(a,r)}catch(t){if(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code)throw e.noInitialCommit();throw t}})(a,n.target),i=await(async(t,a)=>{const r=[];for(const n of a){if(n.includes("...")||n.includes("^"))throw e.invalidOption("commits",`unsupported revision form '${n}' (use a commit-ish or A..B)`);const a=Ba.exec(n);if(null===a){r.push(await oa(t,n));continue}const o=await Ia(t,a[1]),i=await Ia(t,a[2]);r.push(...await Fa(t,o,i))}return r})(a,r.commits);return await na(a,await ua(a,o)),!0===r.noCommit?(async(a,r)=>{const n=await t.acquireIndexLock(a);try{let o=await t.readIndex(a);for(let i=0;i<r.length;i+=1){const s=r[i],c=await la(a,s);if(Ua(c))throw e.cherryPickMergeNoMainline(s);const d=c.parents[0],f=void 0!==d?await ua(a,d):void 0,l=await t.synthesizeTreeFromIndex(a,o.entries),u=await Nt(a,{baseTree:f,oursTree:l,theirsTree:c.tree,currentIndex:o});if("would-overwrite"===u.kind)throw e.workingTreeDirty(u.paths);if("conflict"===u.kind)return await n.commit(u.indexEntries),{kind:"conflict",commit:s,conflicts:_a(u.conflicts),remaining:r.length-(i+1)};o={...o,entries:u.result.newIndexEntries}}return await n.commit(o.entries),{kind:"no-commit",sources:r}}finally{await n.release()}})(a,i):Wa(a,i,n.target,o,{recordOrigin:r.recordOrigin??!1,allowEmpty:r.allowEmpty??!1},{multiPick:i.length>1,sequenceHead:o})},Xa=async(e,a)=>{if(void 0!==await qt(e)){const a=await(async e=>{const a=jt(e);if(!await e.fs.exists(a))return{recordOrigin:!1,allowEmpty:!1,noCommit:!1};const r=t.parseIniSections(await e.fs.readUtf8(a));return{noCommit:Yt(r,"no-commit"),recordOrigin:Yt(r,"record-origin"),allowEmpty:Yt(r,"allow-empty")}})(e);return{recordOrigin:a.recordOrigin,allowEmpty:a.allowEmpty}}return{recordOrigin:!1,allowEmpty:a.allowEmpty??!1}},Ya=async(a,r={})=>{await t.assertRepository(a),await t.assertNotBare(a,"cherry-pick --continue");const n=await Qt(a),o=await Vt(a);if(void 0===n&&(void 0===o||0===o.length))throw e.noOperationInProgress("cherry-pick");const s=await t.readHeadRaw(a);if("symbolic"!==s.kind)throw e.unsupportedOperation("cherry-pick --continue","cannot continue with detached HEAD");const c=await Xa(a,r);let d=await t.resolveRef(a,s.target);const f=[];if(void 0!==n){const r=void 0!==o?o.length-1:0,l=await(async(a,r,n,o,s)=>{const c=await t.readIndex(a);(t=>{const a=new Set;for(const e of t)0!==e.flags.stage&&a.add(e.path);if(a.size>0)throw e.mergeHasConflicts(a.size,[...a])})(c.entries);const d=await t.synthesizeTreeFromIndex(a,c.entries);if(d===await ua(a,o)&&!s.allowEmpty)return{empty:!0};const f=await(async(e,a,r,n,o)=>{const s=await la(e,a),c=await fa(e),d=ca(da(await Ae(e)??""),{allowEmpty:!1}),f=await t.createCommit(e,{tree:o,parents:[r],author:s.author,committer:c,message:d,extraHeaders:[]});return await t.updateRef(e,n,f,{expected:r,reflogMessage:`commit (cherry-pick): ${i(d)}`}),f})(a,r,o,n,d);return await ea(a),await Pe(a),{created:f}})(a,n,s.target,d,c);if("empty"in l)return{kind:"empty",commit:n,remaining:r};f.push({source:n,created:l.created}),d=l.created}const l=(o??[]).slice(void 0!==n?1:0).map(e=>e.oid);if(0===l.length)return await Kt(a),{kind:"picked",commits:f};const u=await qt(a)??d,w=await Wa(a,l,s.target,d,c,{multiPick:!0,sequenceHead:u});return"picked"===w.kind?{kind:"picked",commits:[...f,...w.commits]}:w},Ka=async(a,r={})=>{await t.assertRepository(a),await t.assertNotBare(a,"cherry-pick --skip");const n=await Qt(a),o=await Vt(a);if(void 0===n&&(void 0===o||0===o.length))throw e.noOperationInProgress("cherry-pick");const i=await wa(a,"cherry-pick --skip"),s=await t.resolveRef(a,i),c=await Xa(a,r);await Le(a,s),await ea(a),await Pe(a);const d=(o??[]).slice(1).map(e=>e.oid);if(0===d.length)return await Kt(a),{kind:"picked",commits:[]};const f=await qt(a)??s;return Wa(a,d,i,s,c,{multiPick:!0,sequenceHead:f})},Za=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"cherry-pick --abort");const r=await Qt(a),n=await qt(a);if(void 0===r&&void 0===n)throw e.noOperationInProgress("cherry-pick");const o=await wa(a,"cherry-pick --abort"),i=n??await t.resolveRef(a,o);return await Zt(a,{branch:o,target:i,clearHead:ea}),{head:i,branch:o}},Ja=async(e,a)=>{const r=t.validateRefName(a.initialBranch),n=e.layout.gitDir;try{await e.fs.mkdir(n),await e.fs.writeUtf8(`${n}/HEAD`,`ref: refs/heads/${r}\n`),await e.fs.writeUtf8(`${n}/config`,(o=a.bare,`[core]\n\trepositoryformatversion = 0\n\tfilemode = true\n\tbare = ${o?"true":"false"}\n`)),await e.fs.mkdir(`${n}/refs/heads`),await e.fs.mkdir(`${n}/refs/tags`),await e.fs.mkdir(`${n}/objects/info`),await e.fs.mkdir(`${n}/objects/pack`),await e.fs.writeUtf8(`${n}/info/exclude`,"# git ls-files --others --exclude-from=.git/info/exclude\n# Lines that start with '#' are comments.\n# For a project mostly in C, the following would be a good set of\n# exclude patterns (uncomment them if you want to use them):\n# *.[oa]\n# *~\n"),await e.fs.writeUtf8(`${n}/description`,"Unnamed repository; edit this file 'description' to name the repository.\n")}catch(t){throw await e.fs.rmRecursive(n).catch(()=>{}),t}var o;return{gitDir:n,initialBranch:r,bare:a.bare}},Qa={attempts:3,backoff:"exponential",baseMs:250,maxDelayMs:5e3},er=(e,t={})=>{const r=void 0!==t.logger?tr(t.logger):void 0;let n=e.transport;return n=a.withRetry(t.retry??Qa)(n),void 0!==t.auth&&(n=a.withAuth(t.auth)(n)),void 0!==r&&(n=a.withLogging({logger:r})(n)),n},tr=e=>({log:t=>e.log(ar(t))}),ar=e=>"request"===e.kind||"response"===e.kind?{...e,url:nr(e.url),headers:rr(e.headers)}:{...e,url:nr(e.url),errorMessage:nr(e.errorMessage)},rr=e=>{const t={};for(const[a,r]of Object.entries(e))t[a]=nr(r);return t},nr=e=>{let t="";for(let a=0;a<e.length;a+=1){const r=e.charCodeAt(a);t+=9===r||10===r?e[a]:r<32||r>126?`\\x${r.toString(16).padStart(2,"0").toUpperCase()}`:e[a]}return t},or={"git-upload-pack":"application/x-git-upload-pack-advertisement","git-receive-pack":"application/x-git-receive-pack-advertisement"},ir=async(a,n,o,i)=>{const s=t.buildDiscoveryUrl(o,i),c=await n.request({url:s,method:"GET",headers:{accept:or[i]},...void 0!==a.signal?{signal:a.signal}:{}});if(200!==c.statusCode)throw e.httpError(c.statusCode,`${i} discovery returned ${c.statusCode}`);const d=t.decodePktStream(r.readableStreamToAsyncIterable(c.body));return t.parseAdvertisedRefs(d,i)},sr=async(e,t,a)=>ir(e,t,a,"git-upload-pack"),cr=e=>{const a=t.CLIENT_CAPABILITIES_FETCH.filter(e=>"multi_ack_detailed"!==e&&"thin-pack"!==e&&"no-progress"!==e&&e!==t.AGENT);return[...t.negotiateCapabilities(e,a),t.AGENT]},dr=e=>{const t=new Set,a=[];for(const r of e)t.has(r.id)||(t.add(r.id),a.push(r.id));return a},fr=e=>e.includes("filter"),lr=async(e,t)=>{ur(e);const a=wr(e);mr(a,t.allowInsecure??!1),pr(a);const r=await t.resolver(a.hostname);return{url:e,pinnedAddress:hr(r,t.allowPrivateNetworks??!1)}},ur=t=>{for(let a=0;a<t.length;a+=1){const r=t.charCodeAt(a);if(10===r||13===r)throw e.invalidUrl("contains forbidden control character")}},wr=t=>{try{return new URL(t)}catch{throw e.invalidUrl("not a valid URL")}},mr=(t,a)=>{const r=t.protocol;if("https:"!==r&&("http:"!==r||!a))throw e.unsupportedScheme(r.replace(":",""))},pr=t=>{if(""!==t.hash)throw e.invalidUrl("URL fragment is not allowed")},hr=(t,a)=>{for(const e of t)if(a||!gr(e))return e;if(0===t.length)throw e.blockedHost("<unresolved>","no DNS records returned");throw e.blockedHost(t[0],"all resolved addresses are in a blocked range")},gr=e=>e.includes(":")?vr(e):yr(e),yr=e=>{const t=(e=>{const t=e.split(".");if(4!==t.length)return;const a=[];for(const e of t){if(!/^\d{1,3}$/.test(e))return;const t=Number(e);if(t>255)return;a.push(t)}return a})(e);if(void 0===t)return!1;const[a,r]=t;return 0===a||10===a||100===a&&r>=64&&r<=127||127===a||169===a&&254===r||172===a&&r>=16&&r<=31||192===a&&168===r||a>=224},vr=e=>{const t=e.toLowerCase(),a=t.match(/::ffff:(?:0:)?(\d+\.\d+\.\d+\.\d+)$/);if(void 0!==a?.[1])return yr(a[1]);const r=t.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);if(void 0!==r?.[1]&&void 0!==r[2]){const e=parseInt(r[1],16),t=parseInt(r[2],16);return yr(`${e>>8}.${255&e}.${t>>8}.${255&t}`)}return!!("::1"===t||"::"===t||t.startsWith("fe80:")||t.startsWith("fe80::")||t.startsWith("ff")||t.startsWith("fc")||t.startsWith("fd"))},kr="clone:discover",br=async(e,a,r,n)=>{await t.updateConfigEntries(e,[{section:"remote",subsection:"origin",key:"url",value:a},{section:"remote",subsection:"origin",key:"fetch",value:"+refs/heads/*:refs/remotes/origin/*"},...void 0!==r?[{section:"branch",subsection:r,key:"remote",value:"origin"},{section:"branch",subsection:r,key:"merge",value:`refs/heads/${r}`}]:[],...void 0!==n?[{section:"core",key:"repositoryformatversion",value:"1"},{section:"remote",subsection:"origin",key:"promisor",value:"true"},{section:"remote",subsection:"origin",key:"partialclonefilter",value:n},{section:"extensions",key:"partialClone",value:"origin"}]:[]])},xr=async(e,t,a)=>{const r=Ir(t),n=[];for(const o of t.refs)if("HEAD"!==o.name){if(o.name.startsWith("refs/heads/")){const t=o.name.slice(11),i=`refs/remotes/origin/${t}`;if(await $r(e,i,o.id,a),n.push({name:i,id:o.id}),void 0!==r&&t===r){const t=o.name;await $r(e,t,o.id,a),n.push({name:t,id:o.id})}continue}if(o.name.startsWith("refs/tags/")){const t=o.name;await $r(e,t,o.id,a),n.push({name:t,id:o.id});continue}e.logger?.debug?.("clone: skipping unsupported ref namespace",{name:o.name})}return n},$r=async(e,a,r,n)=>{const o=`${e.layout.gitDir}/${a}`;await e.fs.writeUtf8(o,`${r}\n`),await t.recordRefUpdate(e,a,t.ZERO_OID,r,`clone: from ${n}`)},Ir=e=>{const t=e.capabilities.find(e=>e.startsWith("symref=HEAD:refs/heads/"));if(void 0!==t)return t.slice(23)},Rr=async(e,t,a)=>{const r=Ir(t),n=t.head?.id;if(void 0!==r){const t=`refs/heads/${r}`;return await e.fs.writeUtf8(`${e.layout.gitDir}/HEAD`,`ref: ${t}\n`),await Er(e,n,a),t}if(void 0!==t.head)return await e.fs.writeUtf8(`${e.layout.gitDir}/HEAD`,`${t.head.id}\n`),void await Er(e,n,a)},Er=async(e,a,r)=>{void 0!==a&&await t.recordRefUpdate(e,"HEAD",t.ZERO_OID,a,`clone: from ${r}`)},Tr=e=>`${e.layout.gitDir}/REVERT_HEAD`,Sr=e=>Ut(e,Tr(e)),Or=async e=>{const t=Tr(e);await e.fs.exists(t)&&await e.fs.rm(t)},Nr=(e,t)=>{return`Revert ${a=i(e.message),`"${a.replace(/([\\"])/g,"\\$1")}"`}\n\nThis reverts commit ${t}.\n`;var a},Dr=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"commit");const n=await Mr(a),{mergeHead:o,cherryPickHead:i,revertHead:s}=n,c=Cr(n);await t.assertNoPendingOperation(a,void 0!==c?{except:c}:{});const d=r.noVerify??!1;await(async(e,a)=>{a||await t.runHook(e,"pre-commit")})(a,d);const f=await Hr(a,r,void 0!==o||void 0!==i||void 0!==s),l=await t.readConfig(a),u=_r(l.user),w=ia(Br(r.author,u)),m=sa(Fr(r.committer,w,u)),p=await t.readIndex(a);Ur(p.entries);const h=await qr(a,p.entries),g=await t.readHeadRaw(a),y="symbolic"===g.kind?await jr(a,g.target):g.id,v=Lr(y,o);if(!r.allowEmpty&&void 0!==y&&void 0===o&&await Wr(a,y)===h)throw e.nothingToCommit();const k=await(async(e,a,r)=>{if(r.noVerify||void 0===e.hooks)return a;const n=`${e.layout.gitDir}/COMMIT_EDITMSG`;await e.fs.writeUtf8(n,a),await t.runHook(e,"commit-msg",{args:[n]});const o=await e.fs.readUtf8(n);return ca(o,{allowEmpty:r.allowEmptyMessage})})(a,f,{noVerify:d,allowEmptyMessage:r.allowEmptyMessage??!1}),b={tree:h,parents:v,author:w,committer:m,message:k,extraHeaders:[]},x=await t.createCommit(a,b),$="symbolic"===g.kind?g.target:void 0,I=Pr(k,y,o,i);return void 0!==$?await t.updateRef(a,$,x,void 0!==y?{expected:y,reflogMessage:I}:{reflogMessage:I}):(await a.fs.writeUtf8(`${a.layout.gitDir}/HEAD`,`${x}\n`),await t.recordRefUpdate(a,"HEAD",y??t.ZERO_OID,x,I)),await Ar(a,n),{id:x,tree:h,branch:$,parents:v}},Mr=async e=>({mergeHead:await Ce(e),cherryPickHead:await Qt(e),revertHead:await Sr(e)}),Cr=e=>void 0!==e.mergeHead?"merge":void 0!==e.cherryPickHead?"cherry-pick":void 0!==e.revertHead?"revert":void 0,Ar=async(e,t)=>{if(void 0===t.mergeHead)return void 0!==t.cherryPickHead?(await ea(e),void await Pe(e)):void(void 0!==t.revertHead&&(await Or(e),await Pe(e)));await He(e)},Hr=async(e,t,a)=>{if(t.message.length>0||!a)return ca(t.message,{allowEmpty:t.allowEmptyMessage??!1});const r=await Ae(e);return ca(da(r??""),{allowEmpty:t.allowEmptyMessage??!1})},Pr=(e,t,a,r)=>{const n=i(e);return void 0===t?`commit (initial): ${n}`:void 0!==a?`commit (merge): ${n}`:void 0!==r?`commit (cherry-pick): ${n}`:`commit: ${n}`},Lr=(e,t)=>{const a=[];return void 0!==e&&a.push(e),void 0!==t&&a.push(t),a},Ur=t=>{const a=new Set;for(const e of t)0!==e.flags.stage&&a.add(e.path);if(a.size>0)throw e.mergeHasConflicts(a.size,[...a])},_r=e=>{if(void 0!==e)return{name:e.name,email:e.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}},Br=(e,t)=>{const a={};return void 0!==e&&(a.explicit=e),void 0!==t&&(a.configUser=t),a},Fr=(e,t,a)=>{const r={};return void 0!==e&&(r.explicit=e),void 0!==t&&(r.author=t),void 0!==a&&(r.configUser=a),r},jr=async(e,a)=>{try{return await t.resolveRef(e,a)}catch{return}},Wr=async(e,a)=>{const r=await t.readObject(e,a);return"commit"!==r.type?t.ZERO_OID:r.data.tree},qr=async(e,t)=>{const a={files:new Map,subdirs:new Map};for(const e of t)zr(a,e.path.split("/"),e);return Gr(e,a)},zr=(e,t,a)=>{if(1===t.length)return void e.files.set(t[0],{id:a.id,mode:a.mode});const[r,...n]=t,o=r;let i=e.subdirs.get(o);void 0===i&&(i={files:new Map,subdirs:new Map},e.subdirs.set(o,i)),zr(i,n,a)},Gr=async(e,a)=>{const r=[];for(const[e,t]of a.files)r.push({mode:t.mode,name:e,id:t.id});const n=await Promise.all(Array.from(a.subdirs).map(async([t,a])=>({name:t,id:await Gr(e,a)})));for(const{name:e,id:t}of n)r.push({mode:"40000",name:e,id:t});return t.writeTree(e,r)},Vr=e=>e,Xr=async(e,a)=>(await t.assertRepository(e),void 0===a.scope?await t.getConfigValue({ctx:e,key:a.key}):await t.getConfigValue({ctx:e,key:a.key,scope:a.scope})),Yr=async(e,a)=>(await t.assertRepository(e),void 0===a.scope?await t.getAllConfigValues({ctx:e,key:a.key}):await t.getAllConfigValues({ctx:e,key:a.key,scope:a.scope})),Kr=async(e,a)=>{await t.assertRepository(e);const r=void 0===a.scope?await t.readConfigSections({ctx:e}):await t.readConfigSections({ctx:e,scope:a.scope}),n=[];for(const{scope:e,section:o}of r)for(const r of o.entries){const i=t.qualifyKey(o,r.key);a.keyPattern.test(i)&&(void 0===a.valuePattern||a.valuePattern.test(r.value))&&n.push({key:Vr(i),value:r.value,scope:e})}return{entries:n}},Zr=async(e,a)=>{await t.assertRepository(e);const r=void 0===a?.scope?await t.readConfigSections({ctx:e}):await t.readConfigSections({ctx:e,scope:a.scope}),n=[];for(const{scope:e,section:a}of r)for(const r of a.entries){const o=t.qualifyKey(a,r.key);n.push({key:Vr(o),value:r.value,scope:e})}return{entries:n}},Jr=async(a,r)=>{await t.assertRepository(a);const n=r.scope??"local",o=await t.getAllConfigValues({ctx:a,key:r.key,scope:n});if(o.values.length>1)throw e.configMultipleValues(r.key,o.values.length,"overwrite",n);return await t.setConfigEntry({ctx:a,key:r.key,value:r.value,scope:n}),{key:r.key,value:r.value,scope:n}},Qr=async(a,r)=>{await t.assertRepository(a);const n=r.scope??"local",o=await t.getAllConfigValues({ctx:a,key:r.key,scope:n});if(0===o.values.length)return{key:r.key,scope:n,removed:!1};if(o.values.length>1)throw e.configMultipleValues(r.key,o.values.length,"remove",n);const[i]=o.values;return await t.unsetConfigEntry({ctx:a,key:r.key,scope:n}),{key:r.key,scope:n,removed:!0,previousValue:i.value}},en=async(e,a)=>{await t.assertRepository(e);const r=a.scope??"local",n=await t.getAllConfigValues({ctx:e,key:a.key,scope:r});return 0===n.values.length?{key:a.key,scope:r,removed:0}:(await t.unsetAllConfigEntries({ctx:e,key:a.key,scope:r}),{key:a.key,scope:r,removed:n.values.length})},tn=async(e,a)=>{await t.assertRepository(e);const r=a.scope??"local";return await t.renameConfigSection({ctx:e,oldName:a.oldName,newName:a.newName,scope:r}),{oldName:a.oldName,newName:a.newName,scope:r}},an=async(e,a)=>{await t.assertRepository(e);const r=a.scope??"local";return await t.removeConfigSection({ctx:e,sectionName:a.name,scope:r}),{name:a.name,scope:r}};async function rn(e,t){const a=new Array(t.length);let r=0;const n=async()=>{for(;r<t.length;){const n=r++,o=t[n];a[n]=await nn(e,o)}},o=Math.min(32,t.length),i=[];for(let e=0;e<o;e++)i.push(n());return await Promise.all(i),a.map(e=>e)}async function nn(e,a){if("add"===a.type)return{change:a,newContent:(await t.readBlob(e,a.newId)).content};if("delete"===a.type)return{change:a,oldContent:(await t.readBlob(e,a.oldId)).content};if("rename"===a.type)return{change:a};if(a.oldId===a.newId){const r=await t.readBlob(e,a.oldId);return{change:a,oldContent:r.content,newContent:r.content}}const[r,n]=await Promise.all([t.readBlob(e,a.oldId),t.readBlob(e,a.newId)]);return{change:a,oldContent:r.content,newContent:n.content}}const on=async(e,a)=>{const r=/^[0-9a-f]{40}$/.test(a)?a:await t.resolveRef(e,t.validateRefName(a)),n=await t.readObject(e,r);return"commit"===n.type?n.data.tree:r},sn="fetch:negotiate",cn=async(a,r={})=>{await t.assertRepository(a);const n=r.remote??"origin",{url:o,filter:i}=await dn(a,n);a.progress.start(sn);try{const s=er(a,void 0!==a.config?.auth?{auth:a.config.auth}:{}),c=await sr(a,s,o);if(0===c.refs.length)throw e.remoteAdvertisesNoRefs();if(void 0!==i&&!fr(c.capabilities))throw t.remoteFilterUnsupported();const d=cr(c.capabilities),f=dr(c.refs),l=await fn(a,n),u=await t.fetchPack(a,s,{wants:f,haves:l,capabilities:d,url:o,progressOp:"fetch:write-objects",...void 0!==r.depth?{depth:r.depth}:{},...void 0!==i?{filter:i,promisor:!0}:{}});(u.shallow.length>0||u.unshallow.length>0)&&await t.updateShallow(a,{shallow:u.shallow,unshallow:u.unshallow});return{remote:n,url:o,updatedRefs:await pn(a,n,c),prunedRefs:!0===r.prune?await vn(a,n,c):[],shallow:u.shallow,unshallow:u.unshallow}}finally{a.progress.end(sn)}},dn=async(a,r)=>{const n=await t.readConfig(a),o=n.remote?.get(r);if(void 0===o?.url||""===o.url)throw e.remoteNotConfigured(r);const i=void 0!==o.partialCloneFilter?he(pe(o.partialCloneFilter)):void 0;return{url:o.url,filter:i}},fn=async(e,a)=>{const r=await ln(e,a);if(0===r.length)return[];const n=new Set,o=[];for(const e of r)if(!n.has(e)&&(n.add(e),o.push(e),o.length>=t.MAX_HAVES))return o;const i=r.slice(0,t.MAX_WALK_SEEDS);for await(const a of t.walkCommits(e,{from:i,ignoreMissing:!0,verifyHash:!1}))if(!n.has(a.id)&&(n.add(a.id),o.push(a.id),o.length>=t.MAX_HAVES))break;return o},ln=async(e,a)=>{const r=[],n=[`refs/remotes/${a}`,"refs/tags"];for(const t of n){const a=`${e.layout.gitDir}/${t}`;await e.fs.exists(a)&&await un(e,a,r)}const o=`refs/remotes/${a}/`,i=await t.getRefStore(e).getPackedRefs();for(const e of i.entries)(e.name.startsWith(o)||e.name.startsWith("refs/tags/"))&&r.push(e.id);return r},un=async(e,t,a)=>{const r=await e.fs.readdir(t);for(const n of r){const r=`${t}/${n.name}`;if(n.isDirectory){await un(e,r,a);continue}const o=(await e.fs.readUtf8(r)).trim();mn(o)&&a.push(o)}},wn=/^[0-9a-f]{40}([0-9a-f]{24})?$/i,mn=e=>wn.test(e),pn=async(e,a,r)=>{const n=[];for(const o of r.refs){const r=hn(a,o);if(void 0===r)continue;const i=await yn(e,r);i!==o.id?(await t.updateRef(e,r,o.id,{reflogMessage:`fetch ${a}: storing head`}),n.push({name:r,oldId:i,newId:o.id})):n.push({name:r,oldId:i,newId:o.id})}return n},hn=(e,t)=>{if("HEAD"!==t.name&&gn(t.name)){if(t.name.startsWith("refs/heads/")){const a=`refs/remotes/${e}/${t.name.slice(11)}`;if(!gn(a))return;return a}return t.name.startsWith("refs/tags/")?t.name:void 0}},gn=e=>{try{return t.validateRefName(e),!0}catch{return!1}},yn=async(e,a)=>{t.validateRefName(a);const r=`${e.layout.gitDir}/${a}`;if(!await e.fs.exists(r))return;const n=(await e.fs.readUtf8(r)).trim();return mn(n)?n:void 0},vn=async(e,t,a)=>{const r=new Set(a.refs.filter(e=>e.name.startsWith("refs/heads/")).map(e=>e.name.slice(11))),n=`${e.layout.gitDir}/refs/remotes/${t}`;if(!await e.fs.exists(n))return[];const o=[];return await kn(e,n,"",r,t,o),o},kn=async(e,a,r,n,o,i)=>{const s=await e.fs.readdir(a);for(const c of s){const s=`${a}/${c.name}`,d=""===r?c.name:`${r}/${c.name}`;if(c.isDirectory){await kn(e,s,d,n,o,i);continue}if(n.has(d))continue;const f=`refs/remotes/${o}/${d}`;if(!gn(f)){e.logger?.warn?.("fetch.prune: skipping unsafe ref name",{name:f});continue}const l=f;try{await t.updateRef(e,l,t.ZERO_OID,{delete:!0})}catch(t){if(bn(t)){e.logger?.warn?.("fetch.prune: skipping packed-only ref",{name:l});continue}throw t}i.push(l)}},bn=t=>t instanceof e.TsgitError&&"UNSUPPORTED_OPERATION"===t.data.code&&"delete-packed-ref"===t.data.operation,xn=async(e,a,r)=>!!await e.fs.exists(t.looseObjectPath(e.layout.gitDir,r))||void 0!==await a.lookup(r),$n=async(a,r)=>{await t.assertRepository(a);const n=await t.readConfig(a),o=n.extensions?.partialClone;if(void 0===o)return{kind:"no-promisor"};const i=n.remote?.get(o)?.url;if(void 0===i||""===i)throw e.remoteNotConfigured(o);const s=await(async(e,a)=>{const r=t.createPackRegistry(e),n=new Set,o=[];for(const t of a)n.has(t)||(n.add(t),await xn(e,r,t)||o.push(t));return o})(a,r);if(0===s.length)return{kind:"fetched",remote:o,requested:r.length,fetched:0};const c=er(a,void 0!==a.config?.auth?{auth:a.config.auth}:{}),d=await sr(a,c,i),f=cr(d.capabilities);try{await t.fetchPack(a,c,{wants:s,haves:[],capabilities:f,url:i,progressOp:"fetch-missing:write-objects",promisor:!0})}catch(t){if(!(t=>t instanceof e.TsgitError&&"FILE_EXISTS"===t.data.code)(t))throw t}return{kind:"fetched",remote:o,requested:r.length,fetched:s.length}},In=e=>`'${e.replaceAll("'","'\\''")}'`,Rn=(e,a)=>{const r=`${a}=`,n=e.find(e=>e.startsWith(r));if(void 0===n)throw t.invalidIdentity(a,"missing author-script key");const o=n.slice(r.length);if(o.length<2||!o.startsWith("'")||!o.endsWith("'"))throw t.invalidIdentity(n,"author-script value is not single-quoted");return(e=>e.slice(1,-1).replaceAll("'\\''","'"))(o)},En=e=>e.replace(/\n+$/,""),Tn=(e,t)=>{return 0===t?`# This is the 1st commit message:\n\n${En(e.message)}\n`:!0===e.skip?`\n# The commit message #${t+1} will be skipped:\n\n${a=e.message,En(a).split("\n").map(e=>""===e?"#":`# ${e}`).join("\n")}\n`:`\n# This is the commit message #${t+1}:\n\n${En(e.message)}\n`;var a},Sn=e=>{const t=e.length;let a=`# This is a combination of ${t} ${1===t?"commit":"commits"}.\n`;for(let r=0;r<t;r+=1)a+=Tn(e[r],r);return a},On=/^(pick|reword|edit|squash|fixup|drop) (\S+) # (.*)$/,Nn=e=>e.map(e=>`${e.action} ${e.oid} # ${e.subject}\n`).join(""),Dn=t=>{const a=[];for(const r of t.split("\n")){if(""===r||r.startsWith("#"))continue;const t=On.exec(r);if(null===t)throw e.invalidSequencerTodo(r);a.push({action:t[1],oid:t[2],subject:t[3]})}return a},Mn=new TextEncoder,Cn=new Uint8Array,An=async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);return r.data},Hn=async(e,a)=>{const r=await An(e,a),n=r.parents[0],o=void 0!==n?(await An(e,n)).tree:void 0,i=await t.diffTrees(e,o,r.tree),s=await rn(e,i.changes),c=H(s,{contextLines:3,pathPrefix:{old:"a/",new:"b/"}}),d=s.filter(e=>u(e.oldContent??Cn)||u(e.newContent??Cn)).map(e=>{return`${"oldId"in(t=e.change)?t.oldId:""}${"newId"in t&&void 0!==t.newId?t.newId:""}`;var t}).join("");return e.hash.hashHex(Mn.encode(c.split("\n").filter(e=>!e.startsWith("@@ ")&&!e.startsWith("index ")).map(e=>e.replace(/\s/g,"")).join("")+d))},Pn=e=>`${e.layout.gitDir}/rebase-merge`,Ln=(e,t)=>`${Pn(e)}/${t}`,Un=e=>`${e.layout.gitDir}/REBASE_HEAD`,_n=async(e,t)=>{const a=[...t.done,...t.remaining],r=(t,a)=>e.fs.writeUtf8(Ln(e,t),a);var n,o;await r("head-name",`${t.headName}\n`),await r("onto",`${t.onto}\n`),await r("orig-head",`${t.origHead}\n`),await r("git-rebase-todo",Nn(t.remaining)),void 0!==t.backupHeader&&await r("git-rebase-todo.backup",((e,t)=>{const a=e.length,r=`# Rebase ${t.shortUpstream}..${t.shortOrigHead} onto ${t.shortOnto} (${a} ${1===a?"command":"commands"})\n`;return`${Nn(e)}\n${r}#\n# Commands:\n# p, pick <commit> = use commit\n# r, reword <commit> = use commit, but edit the commit message\n# e, edit <commit> = use commit, but stop for amending\n# s, squash <commit> = use commit, but meld into previous commit\n# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous\n# commit's log message, unless -C is used, in which case\n# keep only this commit's message; -c is same as -C but\n# opens the editor\n# x, exec <command> = run command (the rest of the line) using shell\n# b, break = stop here (continue rebase later with 'git rebase --continue')\n# d, drop <commit> = remove commit\n# l, label <label> = label current HEAD with a name\n# t, reset <label> = reset HEAD to a label\n# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n# create a merge commit using the original merge commit's\n# message (or the oneline, if no original merge commit was\n# specified); use -c <commit> to reword the commit message\n# u, update-ref <ref> = track a placeholder for the <ref> to be updated\n# to this position in the new commits. The <ref> is\n# updated at the end of the rebase\n#\n# These lines can be re-ordered; they are executed from top to bottom.\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n#\n# However, if you remove everything, the rebase will be aborted.\n#\n`})(a,t.backupHeader)),await r("done",Nn(t.done)),await r("message",t.message),await r("author-script",(n=t.stoppedAuthor,`GIT_AUTHOR_NAME=${In(n.name)}\nGIT_AUTHOR_EMAIL=${In(n.email)}\nGIT_AUTHOR_DATE=${In(`@${n.timestamp} ${n.timezoneOffset}`)}\n`)),await r("end",`${a.length}\n`),await r("msgnum",`${t.done.length}\n`),await r("interactive",""),await r("rewritten-list",(o=t.rewritten,o.map(([e,t])=>`${e} ${t}\n`).join(""))),await r("patch",t.patch),await r("drop_redundant_commits",""),await r("no-reschedule-failed-exec",""),await r("stopped-sha",`${t.stoppedSha}\n`),void 0!==t.amend&&await r("amend",`${t.amend}\n`),void 0!==t.currentFixups&&await r("current-fixups",t.currentFixups.map(e=>`${e.action} ${e.oid}\n`).join("")),void 0!==t.rewrittenPending&&await r("rewritten-pending",t.rewrittenPending.map(e=>`${e}\n`).join("")),void 0!==t.messageSquash&&await r("message-squash",t.messageSquash),await e.fs.writeUtf8(Un(e),`${t.stoppedSha}\n`)},Bn=e=>Ut(e,Un(e)),Fn=async(t,a)=>{const r=[];for(const n of a){const a=await Lt(t,n.oid);if(void 0===a)throw e.invalidSequencerTodo(`cannot resolve commit ${n.oid}`);r.push({action:n.action,oid:a,subject:n.subject})}return r},jn=async e=>{if(!await(e=>e.fs.exists(Pn(e)))(e))return;const a=(await e.fs.readUtf8(Ln(e,"head-name"))).trimEnd(),r=await Ut(e,Ln(e,"onto")),n=await Ut(e,Ln(e,"orig-head")),o=await Fn(e,Dn(await e.fs.readUtf8(Ln(e,"done")))),i=await Fn(e,Dn(await e.fs.readUtf8(Ln(e,"git-rebase-todo")))),s=(e=>{const a=e.split("\n"),r=Rn(a,"GIT_AUTHOR_NAME"),n=Rn(a,"GIT_AUTHOR_EMAIL"),o=Rn(a,"GIT_AUTHOR_DATE");if(!o.startsWith("@"))throw t.invalidIdentity(o,"author-script date lacks the `@` prefix");const[i,s]=o.slice(1).split(" "),c=Number(i);if(!Number.isSafeInteger(c))throw t.invalidIdentity(o,"invalid author-script timestamp");if(void 0===s||!/^[+-]\d{4}$/.test(s))throw t.invalidIdentity(o,"invalid author-script timezone offset");return{name:r,email:n,timestamp:c,timezoneOffset:s}})(await e.fs.readUtf8(Ln(e,"author-script"))),c=await e.fs.readUtf8(Ln(e,"message")),d=await Ut(e,Ln(e,"amend")),f=await Wn(e),l=await qn(e);return{headName:a,onto:r,origHead:n,done:o,remaining:i,stoppedSha:await Bn(e),author:s,message:c,...void 0!==d?{amend:d}:{},...void 0!==f?{currentFixups:f}:{},...void 0!==l?{rewrittenPending:l}:{}}},Wn=async e=>{const t=Ln(e,"current-fixups");if(!await e.fs.exists(t))return;const a=[];for(const r of(await e.fs.readUtf8(t)).split("\n")){const[e,t]=r.split(" ");"squash"!==e&&"fixup"!==e||void 0===t||a.push({action:e,oid:t})}return a},qn=async e=>{const t=Ln(e,"rewritten-pending");if(!await e.fs.exists(t))return;const a=[];for(const r of(await e.fs.readUtf8(t)).split("\n"))""!==r&&a.push(r);return a},zn=async e=>{const t=Ln(e,"rewritten-list");if(!await e.fs.exists(t))return[];const a=[];for(const r of(await e.fs.readUtf8(t)).split("\n")){if(""===r)continue;const[e,t]=r.split(" ");void 0!==e&&void 0!==t&&a.push([e,t])}return a},Gn=async e=>{await e.fs.exists(Pn(e))&&await e.fs.rmRecursive(Pn(e)),await e.fs.exists(Un(e))&&await e.fs.rm(Un(e))},Vn="HEAD",Xn=e=>e.slice(0,7),Yn=async(e,a,r)=>{const n=new Set;if(void 0!==a)for await(const r of t.walkCommits(e,{from:[a]}))n.add(r.id);const o=[];for await(const a of t.walkCommits(e,{from:[r],until:[...n]}))o.push(a.id);return o.reverse()},Kn=async(a,r,n)=>{const o=r.parents[0],i=void 0!==o?await ua(a,o):void 0,s=await ua(a,n),c=await t.acquireIndexLock(a);try{const n=await t.readIndex(a),o=await Nt(a,{baseTree:i,oursTree:s,theirsTree:r.tree,currentIndex:n});if("would-overwrite"===o.kind)throw e.workingTreeDirty(o.paths);return"conflict"===o.kind?(await c.commit(o.indexEntries),{kind:"conflict",conflicts:o.conflicts}):(await c.commit(o.result.newIndexEntries),{kind:"clean",mergedTree:o.mergedTree,oursTree:s})}finally{await c.release()}},Zn=async(e,a,r)=>{const n=await Kn(e,a,r);if("conflict"===n.kind)return{kind:"conflict",conflicts:n.conflicts};if(n.mergedTree===n.oursTree)return{kind:"empty"};const o=await fa(e),s=await t.createCommit(e,{tree:n.mergedTree,parents:[r],author:a.author,committer:o,message:a.message,extraHeaders:[]});return await t.updateRef(e,Vn,s,{expected:r,reflogMessage:`rebase (pick): ${i(a.message)}`}),{kind:"committed",id:s}},Jn=async(e,a)=>{const r=a.parents[0],n=void 0!==r?await ua(e,r):void 0,o=await t.diffTrees(e,n,a.tree);return H(await rn(e,o.changes),{contextLines:3,pathPrefix:{old:"a/",new:"b/"}})},Qn=async(e,t,a,r,n,o)=>{const i={headName:t.branch??"detached HEAD",onto:t.onto,origHead:t.origHead,done:[...t.doneBefore,...t.todo.slice(0,a+1)],remaining:t.todo.slice(a+1),stoppedSha:t.todo[a].oid,stoppedAuthor:r.author,message:ta(r.message,n.map(e=>e.path)),rewritten:o,patch:await Jn(e,r),...void 0!==t.backupHeader?{backupHeader:t.backupHeader}:{}};await _n(e,i)},eo=async(e,a,r,n,o)=>{void 0!==a&&(await t.updateRef(e,a,n,{expected:r,reflogMessage:`rebase (finish): ${a} onto ${o}`}),await t.writeSymbolicRef(e,Vn,a),await t.recordRefUpdate(e,Vn,n,n,`rebase (finish): returning to ${a}`))},to=async(e,t,a,r)=>{let n=a;const o=[...r.applied],i=[...r.rewritten];for(let a=0;a<t.todo.length;a+=1){const r=t.todo[a].oid,s=await la(e,r),c=await Zn(e,s,n);if("committed"!==c.kind){if("empty"!==c.kind)return await Qn(e,t,a,s,c.conflicts,i),{kind:"conflict",commit:r,conflicts:c.conflicts.map(e=>({path:e.path,type:e.type})),remaining:t.todo.length-(a+1)}}else o.push({source:r,created:c.id}),i.push([r,c.id]),n=c.id}return await eo(e,t.branch,t.origHead,n,t.onto),await Gn(e),{kind:"rebased",commits:o}},ao=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"rebase"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a),o="symbolic"===n.kind?await(async(a,r)=>{try{return await t.resolveRef(a,r)}catch(t){if(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code)throw e.noInitialCommit();throw t}})(a,n.target):n.id,s="symbolic"===n.kind?n.target:void 0,c=await oa(a,r.upstream),d=void 0!==r.onto?await oa(a,r.onto):c,f=r.onto??r.upstream;await na(a,await ua(a,o));const[l]=await t.mergeBase(a,[c,o]);if(void 0!==r.interactive)return go(a,{instructions:r.interactive,branch:s,headCommit:o,upstream:c,onto:d,ontoName:f,base:l});if(d===l)return{kind:"up-to-date"};const u=await Yn(a,l,o),w=await(async(e,t,a,r)=>{const n=await Yn(e,a,r),o=new Set;for(const t of n)o.add(await Hn(e,t));const i=[];for(const a of t)o.has(await Hn(e,a))||i.push(a);return i})(a,u,l,c),m=await(async(e,t)=>{const a=[];for(const r of t)a.push({action:"pick",oid:r,subject:i((await la(e,r)).message)});return a})(a,w);await Me(a,o),await(async(e,a,r,n)=>{await t.getRefStore(e).writeLoose(Vn,r),await t.recordRefUpdate(e,Vn,a,r,`rebase (start): checkout ${n}`),await Le(e,r)})(a,o,d,f);const p={branch:s,onto:d,origHead:o,doneBefore:[],todo:m,backupHeader:{shortUpstream:Xn(c),shortOrigHead:Xn(o),shortOnto:Xn(d)}};return to(a,p,d,{applied:[],rewritten:[]})},ro=e=>"detached HEAD"===e?void 0:e,no=t=>{const a=new Set;for(const e of t)0!==e.flags.stage&&a.add(e.path);if(a.size>0)throw e.mergeHasConflicts(a.size,[...a])},oo=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"rebase --continue");const r=await jn(a);if(void 0===r)throw e.noOperationInProgress("rebase");if(yo(r))return vo(a,r);const n=await t.readIndex(a);no(n.entries);const o=r.done[r.done.length-1],s=await t.resolveRef(a,Vn),c=await t.synthesizeTreeFromIndex(a,n.entries),d=await fa(a),f=ca(da(r.message),{allowEmpty:!1}),l=await t.createCommit(a,{tree:c,parents:[s],author:r.author,committer:d,message:f,extraHeaders:[]});await t.updateRef(a,Vn,l,{expected:s,reflogMessage:`rebase (continue): ${i(f)}`});const u=[...await zn(a),[o.oid,l]],w={branch:ro(r.headName),onto:r.onto,origHead:r.origHead,doneBefore:r.done,todo:r.remaining};return to(a,w,l,{applied:[{source:o.oid,created:l}],rewritten:u})},io=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"rebase --skip");const r=await jn(a);if(void 0===r)throw e.noOperationInProgress("rebase");if(yo(r))return ko(a,r);const n=await t.resolveRef(a,Vn);await Le(a,n);const o={branch:ro(r.headName),onto:r.onto,origHead:r.origHead,doneBefore:r.done,todo:r.remaining};return to(a,o,n,{applied:[],rewritten:await zn(a)})},so=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"rebase --abort");const r=await jn(a);if(void 0===r)throw e.noOperationInProgress("rebase");const n=ro(r.headName),o=await t.resolveRef(a,Vn);return await Le(a,r.origHead),void 0!==n?(await t.writeSymbolicRef(a,Vn,n),await t.recordRefUpdate(a,Vn,o,r.origHead,`rebase (abort): returning to ${n}`)):(await t.getRefStore(a).writeLoose(Vn,r.origHead),await t.recordRefUpdate(a,Vn,o,r.origHead,`rebase (abort): returning to ${r.origHead}`)),await Gn(a),{head:r.origHead,headName:r.headName}},co=async(e,a)=>{const r=await fa(e),n=await t.createCommit(e,{tree:a.tree,parents:[a.parent],author:a.author,committer:r,message:a.message,extraHeaders:[]});return await t.updateRef(e,Vn,n,{expected:a.expected,reflogMessage:a.reflog}),n},fo=async(e,a,r,n,o)=>{if(r.parents[0]===n)return await(async(e,a)=>{const r=await t.resolveRef(e,Vn);await t.getRefStore(e).writeLoose(Vn,a),await t.recordRefUpdate(e,Vn,r,a,"rebase: fast-forward"),await Le(e,a)})(e,a.oid),{kind:"committed",created:a.oid};const i=await Kn(e,r,n);return"conflict"===i.kind?{kind:"conflict",conflicts:i.conflicts}:{kind:"committed",created:await co(e,{tree:i.mergedTree,parent:n,expected:n,author:r.author,message:r.message,reflog:o})}},lo=(e,t,a,r)=>"reword"===t.action?(async(e,t,a,r)=>{const n=ca(t.message??a.message,{allowEmpty:!1}),o=await fo(e,t,a,r,`rebase (reword): ${i(a.message)}`);if("conflict"===o.kind)return{kind:"conflict",conflicts:o.conflicts};const s=await la(e,o.created);return{kind:"advanced",created:await co(e,{tree:s.tree,parent:s.parents[0],expected:o.created,author:s.author,message:n,reflog:`rebase (reword): ${i(n)}`})}})(e,t,a,r):"edit"===t.action?(async(e,t,a,r)=>{const n=await fo(e,t,a,r,`rebase (edit): ${i(a.message)}`);return"conflict"===n.kind?{kind:"conflict",conflicts:n.conflicts}:{kind:"edit-stop",created:n.created}})(e,t,a,r):(async(e,t,a,r)=>{const n=await fo(e,t,a,r,`rebase (pick): ${i(a.message)}`);return"conflict"===n.kind?{kind:"conflict",conflicts:n.conflicts}:{kind:"advanced",created:n.created}})(e,t,a,r),uo=async(e,t,a,r)=>{await _n(e,{headName:t.branch??"detached HEAD",onto:t.onto,origHead:t.origHead,done:[...t.doneBefore,...t.todo.slice(0,a+1)],remaining:t.todo.slice(a+1),stoppedSha:r.stoppedSha,stoppedAuthor:r.author,message:r.message,rewritten:r.rewritten,patch:r.patch,...void 0!==t.backupHeader?{backupHeader:t.backupHeader}:{},...void 0!==r.amend?{amend:r.amend}:{},...void 0!==r.currentFixups?{currentFixups:r.currentFixups}:{},...void 0!==r.rewrittenPending?{rewrittenPending:r.rewrittenPending}:{},...void 0!==r.messageSquash?{messageSquash:r.messageSquash}:{}})},wo=(e,t)=>{const a=e[t+1];return void 0!==a&&("squash"===a.action||"fixup"===a.action)},mo=(e,t,a)=>({kind:"conflict",commit:e,conflicts:t.map(e=>({path:e.path,type:e.type})),remaining:a}),po=async(e,t,a,r,n,o)=>{const s=await la(e,r),c=await Kn(e,a,r);if("conflict"===c.kind)return{kind:"conflict",conflicts:c.conflicts};n.members.push({message:a.message,skip:"fixup"===t.action}),n.fixups.push({action:t.action,oid:t.oid}),n.pending.push(t.oid),"squash"===t.action&&void 0!==t.message&&(n.inline=t.message);const d=Sn([{message:n.baseMessage},...n.members]),f=o?ca(n.inline??da(d),{allowEmpty:!1}):d;return{kind:"committed",created:await co(e,{tree:c.mergedTree,parent:s.parents[0],expected:r,author:s.author,message:f,reflog:`rebase (${t.action}): ${i(f)}`}),message:f}},ho=async(e,t,a,r)=>{let n=a;const o=[...r.applied],i=[...r.rewritten],s={baseMessage:(await la(e,a)).message,members:[],fixups:[],pending:[a],inline:void 0};for(let a=0;a<t.todo.length;a+=1){const r=t.todo[a];if("drop"===r.action)continue;const c=await la(e,r.oid),d=await Jn(e,c);if("squash"===r.action||"fixup"===r.action){const f=await po(e,r,c,n,s,!wo(t.todo,a));if("conflict"===f.kind){const n=Sn([{message:s.baseMessage},...s.members,{message:c.message,skip:"fixup"===r.action}]);return await uo(e,t,a,{stoppedSha:r.oid,author:c.author,message:ta(n,f.conflicts.map(e=>e.path)),patch:d,rewritten:i,currentFixups:[...s.fixups,{action:r.action,oid:r.oid}],rewrittenPending:[...s.pending],messageSquash:n}),mo(r.oid,f.conflicts,t.todo.length-(a+1))}o.push({source:r.oid,created:f.created}),i.push([r.oid,f.created]),n=f.created;continue}const f=await lo(e,r,c,n);if("conflict"===f.kind)return await uo(e,t,a,{stoppedSha:r.oid,author:c.author,message:ta(c.message,f.conflicts.map(e=>e.path)),patch:d,rewritten:i}),mo(r.oid,f.conflicts,t.todo.length-(a+1));if("edit-stop"===f.kind)return await uo(e,t,a,{stoppedSha:f.created,author:c.author,message:c.message,patch:d,rewritten:i,amend:f.created}),{kind:"stopped",commit:r.oid,remaining:t.todo.length-(a+1)};o.push({source:r.oid,created:f.created}),i.push([r.oid,f.created]),n=f.created,s.baseMessage=(await la(e,f.created)).message,s.members=[],s.fixups=[],s.pending=[f.created],s.inline=void 0}return await eo(e,t.branch,t.origHead,n,t.onto),await Gn(e),{kind:"rebased",commits:o}},go=async(a,r)=>{const n=await(async(t,a,r,n)=>{if(a.every(e=>"drop"===e.action))throw e.invalidOption("interactive","nothing to do (every instruction drops a commit)");const o=a.find(e=>"drop"!==e.action);if("squash"===o?.action||"fixup"===o?.action)throw e.invalidOption("interactive",`cannot '${o.action}' without a previous commit`);const s=new Set(await Yn(t,r,n)),c=[];for(const r of a){if("reword"===r.action&&void 0===r.message)throw e.invalidOption("interactive","reword requires a message (no editor in a library)");if(("reword"===r.action||"squash"===r.action)&&void 0!==r.message&&""===ca(r.message,{allowEmpty:!0}))throw e.invalidOption("interactive",`${r.action} message must not be empty`);const a=await oa(t,r.oid);if(!s.has(a))throw e.invalidOption("interactive",`commit ${a} is not in the list of commits to be rebased`);const n=i((await la(t,a)).message);c.push({action:r.action,oid:a,subject:n,...void 0!==r.message?{message:r.message}:{}})}return c})(a,r.instructions,r.base,r.headCommit),o=await(async(e,t,a)=>{let r=a,n=0;for(;n<t.length&&"pick"===t[n].action&&(await la(e,t[n].oid)).parents[0]===r;)r=t[n].oid,n+=1;return n})(a,n,r.onto),s=o>0?n[o-1].oid:r.onto;await Me(a,r.headCommit),await(async(e,a,r,n)=>{await t.getRefStore(e).writeLoose(Vn,n),await t.recordRefUpdate(e,Vn,a,n,`rebase (start): checkout ${r}`),await Le(e,n)})(a,r.headCommit,r.ontoName,s);const c=n.slice(0,o),d={branch:r.branch,onto:r.onto,origHead:r.headCommit,doneBefore:c,todo:n.slice(o),backupHeader:{shortUpstream:Xn(r.upstream),shortOrigHead:Xn(r.headCommit),shortOnto:Xn(r.onto)}},f={applied:c.map(e=>({source:e.oid,created:e.oid})),rewritten:[]};return ho(a,d,s,f)},yo=e=>[...e.done,...e.remaining].some(e=>"pick"!==e.action),vo=async(e,a)=>{const r={branch:ro(a.headName),onto:a.onto,origHead:a.origHead,doneBefore:a.done,todo:a.remaining},n=[...await zn(e)],o=await t.readIndex(e);no(o.entries);const s=await t.synthesizeTreeFromIndex(e,o.entries),c=await t.resolveRef(e,Vn),d=a.done[a.done.length-1].oid;let f;if(void 0!==a.currentFixups){const t=await la(e,c),r=ca(da(a.message),{allowEmpty:!1});f=await co(e,{tree:s,parent:t.parents[0],expected:c,author:t.author,message:r,reflog:`rebase (continue): ${i(r)}`}),n.push([d,f])}else if(void 0!==a.amend){const t=await la(e,a.amend);s===t.tree?f=c:(f=await co(e,{tree:s,parent:t.parents[0],expected:c,author:a.author,message:t.message,reflog:`rebase (continue): ${i(t.message)}`}),n.push([d,f]))}else{const t=ca(da(a.message),{allowEmpty:!1});f=await co(e,{tree:s,parent:c,expected:c,author:a.author,message:t,reflog:`rebase (continue): ${i(t)}`}),n.push([d,f])}return ho(e,r,f,{applied:[],rewritten:n})},ko=async(e,a)=>{const r=await t.resolveRef(e,Vn),n=void 0!==a.amend?(await la(e,a.amend)).parents[0]:r;await t.getRefStore(e).writeLoose(Vn,n),await Le(e,n);const o={branch:ro(a.headName),onto:a.onto,origHead:a.origHead,doneBefore:a.done,todo:a.remaining};return ho(e,o,n,{applied:[],rewritten:await zn(e)})},bo=e=>"HEAD"===e||e.includes("/")?e:`refs/heads/${e}`,xo=e=>{if(""===e)throw t.refspecInvalid(e,"refspec must not be empty");let a=e,r="normal";if(a.startsWith("+")&&(r="force",a=a.slice(1)),""===a)throw t.refspecInvalid(e,"refspec must not be empty after force prefix");const n=$o(a,":");if(n>1)throw t.refspecInvalid(e,"refspec must contain at most one colon");if(0===n){const e=bo(a);return{force:r,src:e,dst:e,isDelete:!1}}const o=a.indexOf(":"),i=a.slice(0,o),s=a.slice(o+1);if(""===s)throw t.refspecInvalid(e,"destination must not be empty");const c=bo(s);if("HEAD"===c)throw t.refspecInvalid(e,"destination must not be HEAD");return""===i?{force:r,src:"",dst:c,isDelete:!0}:{force:r,src:bo(i),dst:c,isDelete:!1}},$o=(e,t)=>{let a=0;for(let r=0;r<e.length;r+=1)e[r]===t&&(a+=1);return a},Io=/[\n\r\t\0"\\\]/]/,Ro=t=>{if(""===t)throw e.remoteNameInvalid(t,"name must not be empty");if(Io.test(t))throw e.remoteNameInvalid(t,"name must not contain a newline, tab, NUL, slash, bracket, quote, or backslash");return t},Eo=(e,t)=>{if(void 0===e.branch)return[];const a=[];for(const[r,n]of e.branch)n.remote===t&&a.push({branch:r,ref:`refs/heads/${r}`,merge:n.merge});return a},To=/[\n\r\0]/,So=t=>{if(To.test(t))throw e.invalidOption("remote.url","url must not contain a newline or NUL")},Oo=(e,t)=>({name:e,url:t?.url??"",pushUrl:t?.pushUrl,fetchRefspecs:t?.fetch??[]}),No=async e=>{await t.assertRepository(e);const a=await t.readConfig(e);if(void 0===a.remote)return{remotes:[]};const r=[];for(const[e,t]of a.remote)r.push(Oo(e,t));return r.sort((e,t)=>e.name<t.name?-1:1),{remotes:r}},Do=async(a,r)=>{await t.assertRepository(a),Ro(r.name),So(r.url);const n=await t.readConfig(a);if(!0===n.remote?.has(r.name))throw e.remoteExists(r.name);const o=r.fetch??`+refs/heads/*:refs/remotes/${r.name}/*`;xo(o);const i=[{kind:"set",section:"remote",subsection:r.name,key:"url",value:r.url},{kind:"set",section:"remote",subsection:r.name,key:"fetch",value:o}];return await t.updateConfigOperations(a,i),{remote:{name:r.name,url:r.url,pushUrl:void 0,fetchRefspecs:[o]}}},Mo=async(e,a)=>{const r=`refs/remotes/${a}/`;return(await t.enumerateRefs(e)).filter(e=>e.startsWith(r))},Co=async(a,r)=>{await t.assertRepository(a),Ro(r.name);const n=await t.readConfig(a);if(!0!==n.remote?.has(r.name))throw e.remoteNotConfigured(r.name);const o=await Mo(a,r.name),i=Eo(n,r.name);for(const e of o)await t.updateRef(a,e,t.ZERO_OID,{delete:!0});const s=[{kind:"removeSection",section:"remote",subsection:r.name}];for(const e of i)s.push({kind:"removeEntry",section:"branch",subsection:e.branch,key:"remote"},{kind:"removeEntry",section:"branch",subsection:e.branch,key:"merge"});return await t.updateConfigOperations(a,s),{name:r.name,removedTrackingRefs:o,clearedBranches:i.map(e=>e.ref)}},Ao=async(a,r,n,o)=>{const i=t.getRefStore(a),s=await i.resolveDirect(r);if("direct"===s.kind){if(!await i.isLoose(r))throw e.unsupportedOperation("rename-packed-tracking-ref",`cannot rename packed-only ref ${r} — run \`git pack-refs --unpack\` and retry`);await t.updateRef(a,n,s.id,{expected:"absent",reflogMessage:o}),await t.updateRef(a,r,t.ZERO_OID,{delete:!0})}},Ho=async(a,r)=>{if(await t.assertRepository(a),Ro(r.from),Ro(r.to),r.from===r.to)throw e.invalidOption("remote.rename","from and to must differ");const n=await t.readConfig(a),o=n.remote?.get(r.from);if(void 0===o)throw e.remoteNotConfigured(r.from);if(!0===n.remote?.has(r.to))throw e.remoteExists(r.to);const i=await Mo(a,r.from),s=Eo(n,r.from),c=`remote: renamed ${r.from} to ${r.to}`,d=[];for(const e of i){const t=e.slice(`refs/remotes/${r.from}/`.length),n=`refs/remotes/${r.to}/${t}`;await Ao(a,e,n,c),d.push(n)}const f=((e,t,a)=>{const r=`+refs/heads/*:refs/remotes/${t}/*`,n=`+refs/heads/*:refs/remotes/${a}/*`;return e.map(e=>e===r?n:e)})(o.fetch??[],r.from,r.to),l=[{kind:"renameSection",section:"remote",from:r.from,to:r.to}];if(f.length>0){l.push({kind:"removeEntry",section:"remote",subsection:r.to,key:"fetch"});for(const e of f)l.push({kind:"appendEntry",section:"remote",subsection:r.to,key:"fetch",value:e})}for(const e of s)l.push({kind:"set",section:"branch",subsection:e.branch,key:"remote",value:r.to});return await t.updateConfigOperations(a,l),{from:r.from,to:r.to,movedTrackingRefs:d,rewrittenBranches:s.map(e=>e.ref)}},Po=async(a,r)=>{await t.assertRepository(a),Ro(r.name),So(r.url);const n=await t.readConfig(a);if(!0!==n.remote?.has(r.name))throw e.remoteNotConfigured(r.name);const o=!0===r.push?"pushurl":"url";await t.updateConfigOperations(a,[{kind:"set",section:"remote",subsection:r.name,key:o,value:r.url}]);const i=(await t.readConfig(a)).remote?.get(r.name);return{remote:Oo(r.name,i)}},Lo=async(a,r)=>{await t.assertRepository(a),Ro(r.name);const n=await t.readConfig(a),o=n.remote?.get(r.name);if(void 0===o)throw e.remoteNotConfigured(r.name);const i=await Mo(a,r.name),s=t.getRefStore(a),c=new Map;for(const e of i){const t=await s.resolveDirect(e);"direct"===t.kind&&c.set(e,t.id)}const d=Eo(n,r.name);return{remote:{...Oo(r.name,o),trackingRefs:c,trackedBy:d.map(e=>({branch:e.ref,merge:e.merge}))}}},Uo=e=>e.parents.length>=2,_o=e=>e.map(e=>({path:e.path,type:e.type})),Bo=e=>t.writeTree(e,[]),Fo=async(a,r,n,o,s)=>{const c=n.parents[0],d=void 0!==c?await ua(a,c):await Bo(a),f=await ua(a,s),l=await t.acquireIndexLock(a);try{const c=await t.readIndex(a),u=await Nt(a,{baseTree:n.tree,oursTree:f,theirsTree:d,currentIndex:c});if("would-overwrite"===u.kind)throw e.workingTreeDirty(u.paths);if("conflict"===u.kind)return await l.commit(u.indexEntries),{kind:"conflict",conflicts:u.conflicts};if(u.mergedTree===f)return{kind:"empty"};await l.commit(u.result.newIndexEntries);const{id:w,subject:m}=await(async(e,a,r,n,o)=>{const s=await fa(e),c=ca(Nr(r,a),{allowEmpty:!1});return{id:await t.createCommit(e,{tree:o,parents:[n],author:s,committer:s,message:c,extraHeaders:[]}),subject:i(c)}})(a,r,n,s,u.mergedTree);return await t.updateRef(a,o,w,{expected:s,reflogMessage:`revert: ${m}`}),{kind:"committed",id:w}}finally{await l.release()}},jo=async(e,t,a,r)=>{await Wt(e,t.sequenceHead),await Gt(e,await(async(e,t)=>{const a=[];for(const r of t){const t=await la(e,r);a.push({command:"revert",oid:r,subject:i(t.message)})}return a})(e,a)),await zt(e,r),await Xt(e,{recordOrigin:!1,allowEmpty:!1,noCommit:!1})},Wo=async(e,t,a)=>{"conflict"===t.kind&&await(async(e,t,a,r)=>{await(async(e,t)=>{await e.fs.writeUtf8(Tr(e),`${t}\n`)})(e,t),await De(e,ta(Nr(a,t),r.map(e=>e.path)))})(e,a.source,a.cData,t.conflicts),a.seq.multiPick&&await jo(e,a.seq,a.remaining,a.currentHead);const r=a.remaining.length-1;return"conflict"===t.kind?{kind:"conflict",commit:a.source,conflicts:_o(t.conflicts),remaining:r}:{kind:"empty",commit:a.source,remaining:r}},qo=async(t,a,r,n,o)=>{let i=n;const s=[];for(let n=0;n<a.length;n+=1){const c=a[n],d=await la(t,c);if(Uo(d))throw o.multiPick&&await jo(t,o,a.slice(n),i),e.revertMergeNoMainline(c);const f=await Fo(t,c,d,r,i);if("committed"!==f.kind){if("empty"!==f.kind||"drop"!==o.onEmpty||0!==n)return Wo(t,f,{seq:o,source:c,cData:d,remaining:a.slice(n),currentHead:i})}else s.push({source:c,created:f.id}),i=f.id}return await Kt(t),{kind:"reverted",commits:s}},zo=/^(.+)\.\.(.+)$/,Go=async(e,a,r)=>{const n=new Set;for await(const r of t.walkCommits(e,{from:[a]}))n.add(r.id);const o=[];for await(const a of t.walkCommits(e,{from:[r],until:[...n]}))o.push(a.id);return o},Vo=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"revert"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.unsupportedOperation("revert","cannot revert with detached HEAD");const o=await(async(a,r)=>{try{return await t.resolveRef(a,r)}catch(t){if(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code)throw e.noInitialCommit();throw t}})(a,n.target),i=await(async(t,a)=>{const r=[];for(const n of a){if(n.includes("...")||n.includes("^"))throw e.invalidOption("commits",`unsupported revision form '${n}' (use a commit-ish or A..B)`);const a=zo.exec(n);if(null===a){r.push(await oa(t,n));continue}const o=await Ia(t,a[1]),i=await Ia(t,a[2]);r.push(...await Go(t,o,i))}return r})(a,r.commits);return await na(a,await ua(a,o)),!0===r.noCommit?(async(a,r)=>{const n=await t.acquireIndexLock(a);try{let o=await t.readIndex(a);for(let i=0;i<r.length;i+=1){const s=r[i],c=await la(a,s);if(Uo(c))throw e.revertMergeNoMainline(s);const d=c.parents[0],f=void 0!==d?await ua(a,d):await Bo(a),l=await t.synthesizeTreeFromIndex(a,o.entries),u=await Nt(a,{baseTree:c.tree,oursTree:l,theirsTree:f,currentIndex:o});if("would-overwrite"===u.kind)throw e.workingTreeDirty(u.paths);if("conflict"===u.kind)return await n.commit(u.indexEntries),{kind:"conflict",commit:s,conflicts:_o(u.conflicts),remaining:r.length-(i+1)};o={...o,entries:u.result.newIndexEntries}}return await n.commit(o.entries),{kind:"no-commit",sources:r}}finally{await n.release()}})(a,i):qo(a,i,n.target,o,{multiPick:i.length>1,sequenceHead:o,onEmpty:"stop"})},Xo=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"revert --continue");const r=await Sr(a),n=await Vt(a);if(void 0===r&&(void 0===n||0===n.length))throw e.noOperationInProgress("revert");const o=await t.readHeadRaw(a);if("symbolic"!==o.kind)throw e.unsupportedOperation("revert --continue","cannot continue with detached HEAD");let s=await t.resolveRef(a,o.target);const c=[];if(void 0!==r){const d=void 0!==n?n.length-1:0,f=await(async(a,r,n)=>{const o=await t.readIndex(a);(t=>{const a=new Set;for(const e of t)0!==e.flags.stage&&a.add(e.path);if(a.size>0)throw e.mergeHasConflicts(a.size,[...a])})(o.entries);const s=await t.synthesizeTreeFromIndex(a,o.entries);if(s===await ua(a,n))return{empty:!0};const c=await(async(e,a,r,n)=>{const o=await fa(e),s=ca(da(await Ae(e)??""),{allowEmpty:!1}),c=await t.createCommit(e,{tree:n,parents:[a],author:o,committer:o,message:s,extraHeaders:[]});return await t.updateRef(e,r,c,{expected:a,reflogMessage:`commit: ${i(s)}`}),c})(a,n,r,s);return await Or(a),await Pe(a),{created:c}})(a,o.target,s);if("empty"in f)return{kind:"empty",commit:r,remaining:d};c.push({source:r,created:f.created}),s=f.created}const d=(n??[]).slice(void 0!==r?1:0).map(e=>e.oid),f=await qt(a)??s,l=void 0===r?"drop":"stop",u=await qo(a,d,o.target,s,{multiPick:!0,sequenceHead:f,onEmpty:l});return"reverted"===u.kind?{kind:"reverted",commits:[...c,...u.commits]}:u},Yo=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"revert --skip");const r=await Sr(a),n=await Vt(a);if(void 0===r&&(void 0===n||0===n.length))throw e.noOperationInProgress("revert");const o=await wa(a,"revert --skip"),i=await t.resolveRef(a,o);await Le(a,i),await Or(a),await Pe(a);const s=(n??[]).slice(1).map(e=>e.oid),c=await qt(a)??i;return qo(a,s,o,i,{multiPick:!0,sequenceHead:c,onEmpty:"stop"})},Ko=async a=>{await t.assertRepository(a),await t.assertNotBare(a,"revert --abort");const r=await Sr(a),n=await qt(a);if(void 0===r&&void 0===n)throw e.noOperationInProgress("revert");const o=await wa(a,"revert --abort"),i=n??await t.resolveRef(a,o);return await Zt(a,{branch:o,target:i,clearHead:Or}),{head:i,branch:o}},Zo=(e,t)=>`${e}/${t}`,Jo=(e,t)=>void 0===e||e(t),Qo=e=>({kind:"delete",path:e.path,mode:e.mode,id:void 0,previousId:e.id,previousMode:e.mode}),ei=e=>({kind:"add",path:e.path,mode:e.mode,id:e.id,previousId:void 0,previousMode:void 0}),ti=e=>({kind:"noop",path:e.path,mode:e.mode,id:e.id,previousId:e.id,previousMode:e.mode}),ai={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,fileSize:0},ri=e=>({...ai,mode:e.mode,id:e.id,flags:{...t.STAGE0_FLAGS,skipWorktree:!0},path:e.path}),ni=e=>e.flags.skipWorktree?{...e,flags:{...e.flags,skipWorktree:!1}}:e,oi=async(e,a)=>{const r=e.layout.workDir,n=await t.acquireIndexLock(e);try{const o=(await t.readIndex(e)).entries.filter(e=>0===e.flags.stage),i=await(async(e,a,r,n)=>{const o=[],i=[],s=[];for(const c of r){if(Jo(n.matcher,c.path)){o.push(c);continue}const r=Zo(a,c.path),d=await e.fs.exists(r);d&&await t.isWorkingTreeDirty(e,r,c.id)&&!0!==n.force?s.push(c):i.push({entry:c,present:d})}return{included:o,removable:i,retained:s}})(e,r,o,a),s=await(async(e,t,a)=>{const r=[];for(const{entry:e,present:t}of a.removable)r.push(t?Qo(e):ti(e));for(const n of a.included){const a=await e.fs.exists(Zo(t,n.path));r.push(a?ti(n):ei(n))}const n={add:0,update:0,delete:0,noop:0};for(const e of r)n[e.kind]+=1;return{entries:r,stats:n}})(e,r,i),c=await t.applyChangeset(e,{changeset:s,force:!0,workdir:r}),d=((e,t)=>{const a=new Map;for(const e of t)a.set(e.path,e);const r=[];for(const t of e.included)r.push(a.get(t.path)??ni(t));for(const{entry:t}of e.removable)r.push(ri(t));for(const t of e.retained)r.push(ni(t));return r})(i,c.writtenEntries);return await n.commit(d),{materialized:c.written,removed:c.deleted,retained:i.retained.map(e=>e.path)}}finally{await n.release()}},ii=async e=>{await t.assertRepository(e),await t.assertNotBare(e,"sparse-checkout"),await t.assertNoPendingOperation(e)},si=async e=>{await ii(e);const a=await t.readConfig(e);if(!0!==a.core?.sparseCheckout)return{cone:!1,patterns:[]};const r=!0===a.core.sparseCheckoutCone,n=await t.readSparsePatternText(e)??"";return"cone"===(o=t.parseSparseCheckout(n,r).spec).mode?{cone:!0,patterns:[...o.recursive].sort()}:{cone:!1,patterns:o.rules.map(e=>e.source)};var o},ci=(e,t)=>void 0===t?{matcher:e}:{matcher:e,force:t},di=async(e,a,r,n)=>{const o=await oi(e,ci(t.buildSparseMatcher(a),n));return await t.writeSparsePatternText(e,r),await t.updateCoreConfig(e,{sparseCheckout:"true",sparseCheckoutCone:"cone"===a.mode?"true":"false"}),hi("cone"===a.mode,o)},fi=async(a,r)=>{if(await ii(a),0===r.patterns.length)throw e.invalidOption("patterns","set requires at least one pattern");const n=await t.readConfig(a),o=r.cone??n.core?.sparseCheckoutCone??!0,{spec:i,text:s}=mi(o,r.patterns);return di(a,i,s,r.force)},li=async(a,r)=>{if(await ii(a),0===r.patterns.length)throw e.invalidOption("patterns","add requires at least one pattern");const n=await t.readConfig(a);if(!0!==n.core?.sparseCheckout)throw e.invalidOption("action","add requires sparse checkout to be enabled");const o=!0===n.core.sparseCheckoutCone,i=await t.readSparsePatternText(a)??"",{spec:s,text:c}=pi(o,i,r.patterns);return di(a,s,c,r.force)},ui=async(a,r)=>{await ii(a);const n=await t.loadSparseMatcher(a);if(void 0===n)throw e.invalidOption("action","reapply requires sparse checkout to be enabled");const o=await t.readConfig(a),i=await oi(a,ci(n,r?.force));return hi(!0===o.core?.sparseCheckoutCone,i)},wi=async(e,a)=>{await ii(e);const r=await oi(e,ci(void 0,a?.force));return await t.updateCoreConfig(e,{sparseCheckout:"false"}),hi(!1,r)},mi=(e,a)=>{if(e){const e=t.buildConeSpec(a);return{spec:e,text:t.serializeCone(e)}}const r=a.join("\n");return{spec:t.parseSparseCheckout(r,!1).spec,text:r}},pi=(e,a,r)=>{if(e){const e=t.parseSparseCheckout(a,!0).spec,n="cone"===e.mode?[...e.recursive,...r]:r,o=t.buildConeSpec(n);return{spec:o,text:t.serializeCone(o)}}const n=(""===a?r:[a,...r]).join("\n");return{spec:t.parseSparseCheckout(n,!1).spec,text:n}},hi=(e,t)=>({cone:e,materialized:t.materialized,removed:t.removed,retained:t.retained}),gi="refs/stash",yi=new TextEncoder,vi=(e,a)=>t.atomicWriteRef(e,gi,t.looseRefPath(e.layout.gitDir,gi),yi.encode(`${a}\n`)),ki=async e=>{const a=await t.readReflog(e,gi),r=a.length-1;return a.map((e,t)=>{const n=a[r-t];return{index:t,selector:`stash@{${t}}`,stash:n.newId,message:n.message}})},bi=async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);return r.data.tree},xi=async(e,a,r)=>{const n=`${e.layout.workDir}/${a}`,o=r.isSymbolicLink?(new TextEncoder).encode(await e.fs.readlink(n)):await e.fs.read(n);return{id:await t.hashBlob(e,o,{write:!0}),mode:t.deriveWorkingMode(r)}},$i=async(a,r={})=>{await t.assertRepository(a),await t.assertNotBare(a,"stash"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a),o=await(async(a,r)=>{const n=await(async(a,r)=>{if("direct"===r.kind)return r.id;try{return await t.resolveRef(a,r.target)}catch(t){if(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code)throw e.noInitialCommit();throw t}})(a,r),o=await t.readObject(a,n);if("commit"!==o.type)throw t.unexpectedObjectType("commit",o.type,n);return{b:n,bTree:o.data.tree,branchRef:"symbolic"===r.kind?r.target:void 0,subject:i(o.data.message)}})(a,n),s=await t.acquireIndexLock(a);try{const e=await t.readIndex(a),n=await t.synthesizeTreeFromIndex(a,e.entries),i=await(async(e,a)=>{const r=[];let n=!1;for(const o of a.entries){if(0!==o.flags.stage)continue;if(o.flags.skipWorktree){r.push(o);continue}const a=await t.compareWorkingTreeEntry(e,o);if("absent"===a){n=!0;continue}if("unchanged"===a){r.push(o);continue}n=!0;const i=await e.fs.lstat(`${e.layout.workDir}/${o.path}`),{id:s,mode:c}=await xi(e,o.path,i);r.push(bt(o.path,s,c))}return{entries:r,dirty:n}})(a,e),c=r.includeUntracked?await(async(e,a)=>{const r=new Set(a.entries.map(e=>e.path)),n=await t.buildRepoIgnorePredicate(e),o=[],i=[];for await(const{path:a,stat:s}of t.walkWorkingTree(e,{ignore:n})){if(r.has(a))continue;const{id:t,mode:n}=await xi(e,a,s);i.push(bt(a,t,n)),o.push(a)}return{paths:o,entries:i}})(a,e):{paths:[],entries:[]};if(!(n!==o.bTree||i.dirty||c.paths.length>0))return{kind:"no-local-changes"};const d=await Ii(a,{base:o,iTree:n,working:i,untracked:c,opts:r});return await(async(e,a,r)=>{const n=await(async e=>{const a=await t.getRefStore(e).resolveDirect(gi);return"direct"===a.kind?a.id:t.ZERO_OID})(e);await vi(e,a);const o=await t.resolveReflogIdentity(e);await t.appendReflog(e,gi,{oldId:n,newId:a,identity:o,message:t.sanitizeReflogMessage(r)})})(a,d.stash,d.message),await Ti(a,s,{base:o,iTree:n,untracked:c,opts:r}),{kind:"saved",stash:d.stash,message:d.message}}finally{await s.release()}},Ii=async(e,a)=>{const{base:r,iTree:n,working:o,untracked:i,opts:s}=a,c=await t.resolveReflogIdentity(e),d=void 0!==(f=r.branchRef)&&f.startsWith("refs/heads/")?f.slice(11):"(no branch)";var f;const l=r.b.slice(0,7),u=r.subject,w=void 0!==s.message?((e,t)=>`On ${e}: ${t}`)(d,s.message):((e,t,a)=>`WIP on ${e}: ${t} ${a}`)(d,l,u),m=(a,r,n)=>t.createCommit(e,{tree:a,parents:r,author:c,committer:c,message:n,extraHeaders:[]}),p=await m(n,[r.b],((e,t,a)=>`index on ${e}: ${t} ${a}`)(d,l,u)),h=await t.synthesizeTreeFromIndex(e,o.entries);if(0===i.paths.length)return{stash:await m(h,[r.b,p],w),message:w};const g=await t.synthesizeTreeFromIndex(e,i.entries),y=await m(g,[],((e,t,a)=>`untracked files on ${e}: ${t} ${a}`)(d,l,u));return{stash:await m(h,[r.b,p,y],w),message:w}},Ri=async e=>(await t.assertRepository(e),{entries:await ki(e)}),Ei=async(a,r={})=>(await t.assertRepository(a),await t.assertNotBare(a,"stash drop"),(async(a,r)=>{const n=await t.readReflog(a,gi),o=n.length-1-r,i=n[o];if(void 0===i)throw e.stashNotFound(r,n.length);const s=n[o+1],c=n.filter((e,t)=>t!==o).map(e=>e===s?{...e,oldId:i.oldId}:e);if(0===c.length)return await t.getRefStore(a).removeLoose(gi),await t.deleteReflog(a,gi),{dropped:i.newId,remaining:0};const d=c[c.length-1];return await vi(a,d.newId),await t.writeReflog(a,gi,c),{dropped:i.newId,remaining:c.length}})(a,r.index??0)),Ti=async(e,a,r)=>{const{base:n,iTree:o,untracked:i,opts:s}=r,c=await t.readIndex(e),d=!0===s.keepIndex?o:n.bTree,f=await t.materializeTree(e,{targetTree:d,currentIndex:c,force:!0,forceRewriteAll:!0});if(await a.commit(f.newIndexEntries),!0===s.includeUntracked)for(const t of i.paths)await $t(e,t)},Si=async(a,r={})=>{await t.assertRepository(a),await t.assertNotBare(a,"stash apply"),await t.assertNoPendingOperation(a);const n=await(async(a,r)=>{const n=await t.readReflog(a,gi),o=n[n.length-1-r];if(void 0===o)throw e.stashNotFound(r,n.length);return o.newId})(a,r.index??0),o=await(async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);const[n,o,i]=r.data.parents;if(void 0===n||void 0===o)throw t.invalidCommit("ref does not point at a stash commit");return{base:n,indexParent:o,untrackedParent:i,wTree:r.data.tree}})(a,n),i=await bi(a,o.base),s=void 0!==o.untrackedParent?await bi(a,o.untrackedParent):void 0,c=await t.acquireIndexLock(a);try{const d=await t.readIndex(a),f=await t.synthesizeTreeFromIndex(a,d.entries);if(void 0!==s){const r=await(async(e,a)=>{const r=await t.flattenTree(e,a),n=[];for(const t of r.entries.keys())await e.fs.exists(`${e.layout.workDir}/${t}`)&&n.push(t);return n})(a,s);if(r.length>0)throw e.stashApplyWouldOverwrite(r)}const l=await Nt(a,{baseTree:i,oursTree:f,theirsTree:o.wTree,currentIndex:d});if("would-overwrite"===l.kind)throw e.stashApplyWouldOverwrite(l.paths);return"conflict"===l.kind?(await c.commit(l.indexEntries),{kind:"conflict",conflicts:l.conflicts.map(e=>({path:e.path,type:e.type}))}):(!0===r.restoreIndex&&await(async(e,a,r)=>{const n=await bi(e,r.indexParent),o=await(async(e,a)=>{const[r,n,o]=await Promise.all([void 0!==a.baseTree?t.flattenTree(e,a.baseTree):Promise.resolve(void 0),t.flattenTree(e,a.oursTree),t.flattenTree(e,a.theirsTree)]),i=await fe(r,n,o,Rt(e));return i.cleanMerge?{kind:"clean",mergedTree:await Tt(e,i.outcomes)}:{kind:"conflict",conflicts:i.conflicts}})(e,{baseTree:r.bTree,oursTree:r.cTree,theirsTree:n});if("clean"!==o.kind)return;const i=await t.buildIndexFromTree(e,{targetTree:o.mergedTree,currentIndex:r.currentIndex});await a.commit(i)})(a,c,{bTree:i,cTree:f,indexParent:o.indexParent,currentIndex:d}),void 0!==s&&await(async(e,a)=>{const r=await t.flattenTree(e,a);for(const[a,n]of r.entries){const r=await t.readBlob(e,n.id,{maxBytes:t.MAX_WORKING_TREE_BLOB_BYTES});await xt(e,a,r.content)}})(a,s),{kind:"applied",stash:n})}finally{await c.release()}},Oi=async(e,t={})=>{const a=await Si(e,t);if("conflict"===a.kind)return a;const r=await Ei(e,{index:t.index??0});return{kind:"applied",stash:a.stash,dropped:r.dropped}},Ni="refs/tags/",Di=async e=>{await t.assertRepository(e);const a=`${e.layout.gitDir}/refs/tags`;if(!await e.fs.exists(a))return{tags:[]};const r=await e.fs.readdir(a),n=[];for(const a of r){if(!a.isFile)continue;const r=`${Ni}${a.name}`,o=await t.resolveRef(e,r);n.push({name:r,id:o})}return n.sort((e,t)=>e.name<t.name?-1:1),{tags:n}},Mi=async(a,r)=>{await t.assertRepository(a);const n=t.validateRefName(`${Ni}${r.name}`),o=void 0!==r.target?r.target:await Ai(a),i=/^[0-9a-f]{40}$/.test(o)?o:await t.resolveRef(a,o),s=`tag: ${r.name}`;try{await t.updateRef(a,n,i,!0===r.force?{reflogMessage:s}:{expected:"absent",reflogMessage:s})}catch(t){if(t instanceof e.TsgitError&&"REF_UPDATE_CONFLICT"===t.data.code)throw e.tagExists(n);throw t}return{name:n,id:i}},Ci=async(a,r)=>{await t.assertRepository(a);const n=t.validateRefName(`${Ni}${r.name}`);if(!await a.fs.exists(`${a.layout.gitDir}/${n}`))throw e.tagNotFound(n);return await t.updateRef(a,n,t.ZERO_OID,{delete:!0}),{name:n}},Ai=async e=>{const a=await t.readHeadRaw(e);return"direct"===a.kind?a.id:t.resolveRef(e,a.target)},Hi=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"merge"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.unsupportedOperation("merge","cannot merge with detached HEAD");const o=await t.resolveRef(a,n.target),i=await oa(a,r.target);if(o===i)return{kind:"up-to-date",id:o};const[s]=await t.mergeBase(a,[o,i]);if(s===i)return{kind:"up-to-date",id:o};if(s===o&&!0!==r.noFastForward)return await t.updateRef(a,n.target,i,{expected:o,reflogMessage:`${r.reflogLabel??`merge ${r.target}`}: Fast-forward`}),{kind:"fast-forward",id:i,branch:n.target};if(!0===r.fastForwardOnly)throw e.nonFastForward(n.target,o,i);return Ui(a,r,n.target,o,i,s)},Pi="merge:write-files",Li=new Set(["rename-rename","gitlink"]),Ui=async(e,t,a,r,n,o)=>{e.progress.start(Pi);try{const i=await Bi(e,r,n,o);return"conflict"===i.kind?qi(e,t,i,r,n):_i(e,t,a,r,n,i.tree)}finally{e.progress.end(Pi)}},_i=async(e,a,r,n,o,i)=>{const s=await rs(e,a),c={tree:i,parents:[n,o],author:s,committer:ns(a,s),message:ca(a.message??`Merge ${a.target}`,{allowEmpty:!1}),extraHeaders:[]},d=await t.createCommit(e,c);return await t.updateRef(e,r,d,{expected:n,reflogMessage:`${a.reflogLabel??`merge ${a.target}`}: Merge made by the 'tsgit' strategy.`}),{kind:"merge",id:d,branch:r,parents:[n,o]}},Bi=async(e,a,r,n)=>{const o=await os(e,a),i=await os(e,r),s=void 0!==n?await os(e,n):void 0,[c,d,f]=await Promise.all([t.flattenTree(e,o),t.flattenTree(e,i),void 0!==s?t.flattenTree(e,s):Promise.resolve(void 0)]),l=Fi(e),u=await fe(f,c,d,l);return u.cleanMerge?{kind:"clean",tree:await ji(e,u.outcomes)}:{kind:"conflict",outcomes:u.outcomes,conflicts:u.conflicts}},Fi=e=>async(a,r,n,o)=>{const[i,s,c]=await Promise.all([t.readBlob(e,a.ourId,{maxBytes:B}),t.readBlob(e,a.theirId,{maxBytes:B}),void 0!==a.baseId?t.readBlob(e,a.baseId,{maxBytes:B}):Promise.resolve(void 0)]);return re(c?.content,i.content,s.content)},ji=async(e,a)=>{const r=await(async(e,a)=>{const r=[];for(const n of a)if("resolved-deleted"!==n.status&&"conflict"!==n.status){if("resolved-merged"===n.status){const a=await t.writeObject(e,{type:"blob",content:n.bytes,id:""});r.push({path:n.path,id:a,mode:n.mode});continue}r.push({path:n.path,id:n.id,mode:n.mode})}return r})(e,a);return Wi(e,r)},Wi=async(e,a,r=0)=>{if(r>4096)throw t.treeDepthExceeded(r);const{files:n,subdirs:o}=(e=>{const t=[],a=new Map;for(const r of e){const e=r.path.indexOf("/");if(-1===e){t.push(r);continue}const n=r.path.slice(0,e),o={path:r.path.slice(e+1),id:r.id,mode:r.mode},i=a.get(n);void 0===i?a.set(n,[o]):i.push(o)}return{files:t,subdirs:a}})(a),i=await Promise.all(Array.from(o,async([a,n])=>({name:a,id:await Wi(e,n,r+1),mode:t.FILE_MODE.DIRECTORY}))),s=n.map(e=>({name:e.path,id:e.id,mode:e.mode}));return t.writeTree(e,[...s,...i])},qi=async(e,a,r,n,o)=>{zi(r.conflicts);const i=await t.loadSparseMatcher(e),s=await t.acquireIndexLock(e);try{await Vi(e,r.outcomes,r.conflicts,i),await Me(e,n),await(async(e,t)=>{await e.fs.writeUtf8(Se(e),`${t}\n`)})(e,o);const t=ca(a.message??`Merge ${a.target}`,{allowEmpty:!1});await De(e,t);const c=as(r.outcomes,r.conflicts,i);await s.commit(c)}finally{await s.release()}return{kind:"conflict",conflicts:r.conflicts.map(e=>({path:e.path,type:e.type})),mergeHead:o,origHead:n}},zi=t=>{for(const a of t)if(Li.has(a.type))throw e.unsupportedOperation("merge",`conflict type '${a.type}' not supported in v1 (path=${a.path})`)},Gi=(e,t)=>void 0!==e&&!e(t),Vi=async(e,t,a,r)=>{await Xi(t,32,t=>Yi(e,t,r)),await Xi(a,32,t=>Ki(e,t))},Xi=async(e,t,a)=>{let r=0;const n=[],o=async()=>{for(;r<e.length;){const t=e[r++];if(void 0===t)break;await a(t)}},i=Math.min(t,e.length);for(let e=0;e<i;e++)n.push(o());await Promise.all(n)},Yi=async(e,a,r)=>{if("unchanged"===a.status||"resolved-known"===a.status){if(Gi(r,a.path))return;const n=await t.readBlob(e,a.id,{maxBytes:B});return void await Ji(e,a.path,n.content)}"resolved-merged"!==a.status?"resolved-deleted"===a.status&&await Qi(e,a.path):await Ji(e,a.path,a.bytes)},Ki=async(e,t)=>{const a=await Zi(e,t);void 0!==a&&await Ji(e,t.path,a)},Zi=async(e,a)=>{if("content"===a.type&&void 0!==a.conflictContent)return a.conflictContent;if("binary"===a.type&&void 0!==a.ourId)return(await t.readBlob(e,a.ourId,{maxBytes:B})).content;if(("add-add"===a.type||"type-change"===a.type)&&void 0!==a.ourId)return(await t.readBlob(e,a.ourId,{maxBytes:B})).content;if("modify-delete"===a.type){const r=a.ourId??a.theirId;if(void 0!==r)return(await t.readBlob(e,r,{maxBytes:B})).content}if("content"===a.type&&void 0!==a.ourId&&void 0!==a.theirId){const[r,n]=await Promise.all([t.readBlob(e,a.ourId,{maxBytes:B}),t.readBlob(e,a.theirId,{maxBytes:B})]);return X([r.content],[n.content])}},Ji=async(e,t,a)=>{const r=`${e.layout.workDir}/${t}`,n=es(r);void 0!==n&&await e.fs.mkdir(n),await e.fs.write(r,a)},Qi=async(e,t)=>{const a=`${e.layout.workDir}/${t}`;await e.fs.exists(a)&&await e.fs.rm(a)},es=e=>{const t=e.lastIndexOf("/");if(!(t<=0))return e.slice(0,t)},ts=e=>({ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:e,uid:0,gid:0,fileSize:0}),as=(e,a,r)=>{const n=[];for(const a of e)"unchanged"!==a.status&&"resolved-known"!==a.status||n.push(Gi(r,a.path)?t.skipWorktreeEntry({path:a.path,id:a.id,mode:a.mode}):{...ts(a.mode),id:a.id,flags:t.STAGE0_FLAGS,path:a.path});const o=d(a,ts),i=[...n,...o];return i.sort((e,t)=>e.path<t.path?-1:e.path>t.path?1:e.flags.stage-t.flags.stage),i},rs=async(e,a)=>{const r=await t.readConfig(e),n=r.user?{name:r.user.name,email:r.user.email,timestamp:Math.floor(Date.now()/1e3),timezoneOffset:"+0000"}:void 0,o={};return void 0!==a.author&&(o.explicit=a.author),void 0!==n&&(o.configUser=n),ia(o)},ns=(e,t)=>{const a={author:t};return void 0!==e.committer&&(a.explicit=e.committer),sa(a)},os=async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);return r.data.tree},is=async(t,a,r,n,o)=>{const i=ss(a,r);if("untracked"===i.kind)return{skip:"source-not-tracked"};if(!await cs(t,r,i.kind))return{skip:"bad-source"};if(n===r||n.startsWith(`${r}/`))return{skip:"into-self"};const s=e.dirname(n);if(""!==s&&!await ms(t,s))throw e.mvDestinationDirectoryMissing(r,n);return await ds(t,a,n,i.kind,!0===o.force)?{kind:i.kind,entries:i.entries}:{skip:"destination-exists"}},ss=(e,t)=>{const a=e.get(t);if(void 0!==a)return{kind:"file",entries:[a]};const r=`${t}/`,n=Array.from(e.values()).filter(e=>e.path.startsWith(r));return n.length>0?{kind:"directory",entries:n}:{kind:"untracked"}},cs=async(e,t,a)=>{const r=await ws(e,t);return void 0!==r&&("directory"===a?r.isDirectory&&!r.isSymbolicLink:r.isFile||r.isSymbolicLink)},ds=async(e,t,a,r,n)=>!(t.has(a)||void 0!==await ws(e,a))||"file"===r&&n,fs=(e,t,a)=>`${a}${e.path.slice(t.length)}`,ls=(t,a,r)=>{switch(t){case"source-not-tracked":return e.mvSourceNotTracked(a,r);case"bad-source":return e.mvBadSource(a,r);case"destination-exists":return e.mvDestinationExists(a,r);case"into-self":return e.mvIntoSelf(a,r)}},us=(e,t)=>`${e}/${t}`,ws=async(e,t)=>e.fs.lstat(((e,t)=>`${e.layout.workDir}/${t}`)(e,t)).catch(()=>{}),ms=async(e,t)=>{const a=await ws(e,t);return!0===a?.isDirectory&&!0!==a.isSymbolicLink},ps="refs/heads/",hs="push:enumerate-objects",gs="push:upload",ys=t.ObjectId.from("0".repeat(40)),vs="refs/heads/",ks=new Set(["side-band-64k","side-band"]),bs=e=>`${e.parsed.isDelete?"(delete)":e.parsed.src} ${e.localOid} ${e.parsed.dst} ${e.remoteOid}\n`,xs=/^[A-Za-z0-9._-]+$/,$s=e=>{const t=new Map;for(const a of e)t.set(a.name,a.id);return t},Is=async(a,r,n,o,i)=>{const s=n.get(r.dst)??ys;if(r.isDelete){if(s===ys)throw e.invalidOption("refspecs",`delete target ${r.dst} is not advertised`);return{parsed:r,localOid:ys,remoteOid:s}}const c=await t.resolveRef(a,r.src);return await Rs(a,r,c,s,o,i),{parsed:r,localOid:c,remoteOid:s}},Rs=async(t,a,r,n,o,i)=>{const s=await Es(t,a,o,i);if(void 0===s){if("force"!==a.force&&!0!==i.force&&n!==ys&&!await Ts(t,n,r))throw e.nonFastForward(a.dst,r,n)}else if(s!==n)throw e.pushRejected(a.dst,"lease-mismatch",Ss())},Es=async(a,r,n,o)=>{if(void 0===o.forceWithLease)return;if("auto"!==o.forceWithLease)return o.forceWithLease;if(!r.dst.startsWith(vs))throw e.invalidOption("forceWithLease","lease-on-non-branch");const i=r.dst.slice(11);return t.resolveRef(a,`refs/remotes/${n}/${i}`)},Ts=async(e,a,r)=>{for await(const n of t.walkCommits(e,{from:[r],ignoreMissing:!0}))if(n.id===a)return!0;return!1},Ss=()=>({unpackOk:!0,refUpdates:[]}),Os=async(a,r,n,o,i,s)=>{const c=i.filter(e=>!e.parsed.isDelete).map(e=>e.localOid),d=o.refs.map(e=>e.id),f=await Ns(a,c,d),l=await t.buildPack(a,{oids:f}),u=(e=>{const a=t.CLIENT_CAPABILITIES_PUSH.filter(e=>e!==t.AGENT);return[...t.negotiateCapabilities(e,a),t.AGENT]})(o.capabilities),w=(e=>{if(0===e.updates.length)throw t.emptyReceiveUpdates();const a=e.updates.map((t,a)=>((e,t)=>{const a=0===t.length?"":`\0${t.join(" ")}`;return ye.encode(`${e.oldId} ${e.newId} ${e.name}${a}\n`)})(t,0===a?e.capabilities:[])),r=t.encodePktStream(a),n=new Uint8Array(r.byteLength+e.packfile.byteLength);return n.set(r,0),n.set(e.packfile,r.byteLength),n})({updates:i.map(Ds),capabilities:u,packfile:l.bytes}),m=await Ms(a,r,n,w),p=await As(a,m,u);if(!p.unpackOk)throw e.pushRejected(i[0]?.parsed.dst,p.unpackError??"unpack failed",p);return await Ps(a,i,p.refUpdates,s)},Ns=async(e,a,r)=>{if(0===a.length)return[];const n=[];for await(const o of t.enumeratePushObjects(e,{wants:a,haves:r}))n.push(o);return n},Ds=e=>({name:e.parsed.dst,oldId:e.remoteOid,newId:e.localOid}),Ms=async(t,a,r,n)=>{t.progress.start(gs);try{const o=Cs(r),i=await a.request({url:o,method:"POST",headers:{"content-type":"application/x-git-receive-pack-request",accept:"application/x-git-receive-pack-result"},body:n,...void 0!==t.signal?{signal:t.signal}:{}});if(200!==i.statusCode)throw e.httpError(i.statusCode,`git-receive-pack returned ${i.statusCode}`);return i}finally{t.progress.end(gs)}},Cs=e=>{let a;try{a=new URL(e)}catch{throw t.invalidBaseUrl("invalid URL")}if(""!==a.hash)throw t.invalidBaseUrl("fragment must not be set");const r=a.pathname.endsWith("/")?a.pathname.slice(0,-1):a.pathname;return`${a.protocol}//${a.host}${r}/git-receive-pack${a.search}`},As=async(a,n,o)=>{const i=r.readableStreamToAsyncIterable(n.body),s=t.decodePktStream(i);if(Hs(o)){const r=t.parseSideBand(s,{onProgress:t=>a.progress.update(gs,0,void 0,e.sanitize(t))});return be(t.decodePktStream(r))}return be(s)},Hs=e=>e.some(e=>ks.has(e)),Ps=async(e,t,a,r)=>{const n=new Map;for(const e of a)n.set(e.name,e);const o=[];for(const a of t){const t=n.get(a.parsed.dst),i=!0===t?.accepted;i&&await Ls(e,a,r),o.push({name:a.parsed.dst,oldId:a.remoteOid,newId:a.localOid,status:i?"ok":"rejected",...void 0!==t?.reason?{reason:t.reason}:{}})}return o},Ls=async(e,a,r)=>{if(!a.parsed.dst.startsWith(vs))return;if(a.parsed.isDelete)return;const n=`refs/remotes/${r}/${a.parsed.dst.slice(11)}`;Us(n)&&await t.updateRef(e,n,a.localOid,{reflogMessage:"update by push"})},Us=e=>{try{return t.validateRefName(e),!0}catch{return!1}},_s=e=>t.validateRefName(e),Bs=(e,t,a)=>{const r=e[t],n=e[t+1];return e.filter((e,a)=>a!==t).map(e=>a&&e===n?{...e,oldId:r.oldId}:e)},Fs=(t,a)=>{const r=Re(t,a);if(void 0===r)throw e.revparseUnresolved(t);return r},js=(e,t,a,r)=>{const n=t.has(e.newId)?a:r;return e.identity.timestamp>=n},Ws=async e=>{const a=await qs(e),r=new Set;if(0===a.length)return r;for await(const n of t.walkCommits(e,{from:a,ignoreMissing:!0}))r.add(n.id);return r},qs=async e=>{const a=new Set;for(const r of await t.enumerateRefs(e)){const t=await zs(e,r);void 0!==t&&a.add(t)}return[...a]},zs=async(a,r)=>{try{return await t.resolveRef(a,r)}catch(t){if(t instanceof e.TsgitError)return;throw t}},Gs=(e,t)=>{const a=e.get(t.path);return void 0===a||a.id!==t.id||a.mode!==t.mode},Vs=async a=>{const r=await t.resolveRef(a,"HEAD").catch(t=>{if(!(t instanceof e.TsgitError&&"REF_NOT_FOUND"===t.data.code))throw t});if(void 0===r)return new Map;const n=await t.readObject(a,r);if("commit"!==n.type)throw t.unexpectedObjectType("commit",n.type,r);return(await t.flattenTree(a,n.data.tree)).entries},Xs="status:scan",Ys=(e,t)=>e.path<t.path?-1:1;exports.abortMerge=async a=>{if(await t.assertRepository(a),await t.assertNotBare(a,"merge --abort"),void 0===await Ce(a))throw e.noOperationInProgress("merge");const r=await(async e=>{const a=Ne(e);if(!await e.fs.exists(a))return;const r=(await e.fs.readUtf8(a)).trim();return 0!==r.length?t.ObjectId.from(r):void 0})(a);if(void 0===r)throw e.noOperationInProgress("merge");const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.unsupportedOperation("merge --abort","cannot abort with detached HEAD");return await Le(a,r),await t.updateRef(a,n.target,r,{reflogMessage:"reset: moving to HEAD"}),await He(a),{origHead:r,branch:n.target}},exports.add=async(a,r,n={})=>{if(await t.assertRepository(a),await t.assertNotBare(a,"add"),await t.assertNoPendingOperation(a,{except:["merge","cherry-pick","revert","rebase"]}),!0===n.all){if(0!==r.length)throw e.invalidOption("all","pathspec must be empty when all=true");return(async(e,a)=>{const r=await t.buildRepoIgnorePredicate(e),n=await t.acquireIndexLock(e,void 0!==a.breakStaleLockMs?{breakStaleLockMs:a.breakStaleLockMs}:{});try{const a=await nt(e),o=new Map(a),i=new Set,s=[],c=[];for await(const n of t.walkWorkingTree(e,{ignore:r})){const t=await rt(e,n,a,i);void 0!==t&&(o.set(t.path,t.entry),"added"===t.kind?s.push(t.path):"modified"===t.kind&&c.push(t.path))}const d=await tt(a,i,r);for(const e of d)o.delete(e);return s.sort(),c.sort(),d.sort(),await n.commit(Array.from(o.values())),{added:s,modified:c,removed:d}}finally{await n.release()}})(a,n)}if(0===r.length)throw e.emptyPathspec();return(async(e,t,a)=>{const{matcher:r,literalMustMatch:n,hasGlob:o}=qe(t);return!o&&await Qe(e,n)?Je(e,n,a):et(e,r,n,a)})(a,r,n)},exports.bindBranchNamespace=(e,t)=>Object.freeze({list:()=>(t(),ft(e)),create:a=>(t(),ut(e,a)),delete:a=>(t(),wt(e,a)),rename:a=>(t(),mt(e,a))}),exports.bindCherryPickNamespace=(e,t)=>Object.freeze({run:a=>(t(),Va(e,a)),continue:a=>(t(),Ya(e,a)),skip:a=>(t(),Ka(e,a)),abort:()=>(t(),Za(e))}),exports.bindConfigNamespace=(e,t)=>Object.freeze({get:a=>(t(),Xr(e,a)),getAll:a=>(t(),Yr(e,a)),getRegexp:a=>(t(),Kr(e,a)),list:a=>(t(),Zr(e,a)),set:a=>(t(),Jr(e,a)),unset:a=>(t(),Qr(e,a)),unsetAll:a=>(t(),en(e,a)),renameSection:a=>(t(),tn(e,a)),removeSection:a=>(t(),an(e,a))}),exports.bindRebaseNamespace=(e,t)=>Object.freeze({run:a=>(t(),ao(e,a)),continue:()=>(t(),oo(e)),skip:()=>(t(),io(e)),abort:()=>(t(),so(e))}),exports.bindRemoteNamespace=(e,t)=>Object.freeze({list:()=>(t(),No(e)),add:a=>(t(),Do(e,a)),remove:a=>(t(),Co(e,a)),rename:a=>(t(),Ho(e,a)),setUrl:a=>(t(),Po(e,a)),show:a=>(t(),Lo(e,a))}),exports.bindRevertNamespace=(e,t)=>Object.freeze({run:a=>(t(),Vo(e,a)),continue:()=>(t(),Xo(e)),skip:()=>(t(),Yo(e)),abort:()=>(t(),Ko(e))}),exports.bindSparseCheckoutNamespace=(e,t)=>Object.freeze({list:()=>(t(),si(e)),set:a=>(t(),fi(e,a)),add:a=>(t(),li(e,a)),reapply:a=>(t(),ui(e,a)),disable:a=>(t(),wi(e,a))}),exports.bindStashNamespace=(e,t)=>Object.freeze({push:a=>(t(),$i(e,a)),list:()=>(t(),Ri(e)),apply:a=>(t(),Si(e,a)),pop:a=>(t(),Oi(e,a)),drop:a=>(t(),Ei(e,a))}),exports.bindTagNamespace=(e,t)=>Object.freeze({list:()=>(t(),Di(e)),create:a=>(t(),Mi(e,a)),delete:a=>(t(),Ci(e,a))}),exports.branchCreate=ut,exports.branchDelete=wt,exports.branchList=ft,exports.branchRename=mt,exports.catFile=async(e,a)=>{await t.assertRepository(e);const r=a.ids.map(ht),n=void 0===a.maxBytes?void 0:{maxBytes:a.maxBytes},o=[];for await(const a of t.catFileBatch(e,r,n))o.push(a);return{kind:"batch",entries:o}},exports.checkout=async(a,r)=>{await t.assertRepository(a),await t.assertNotBare(a,"checkout"),await t.assertNoPendingOperation(a);const n=(e=>"target"in e&&void 0!==e.target)(r),o=(e=>"paths"in e&&void 0!==e.paths)(r);if(n&&o)throw e.invalidOption("paths","cannot be combined with target");if(!n&&!o)throw e.invalidOption("target","either target or paths must be provided");a.progress.start(yt);try{return o?await(async(a,r)=>{if(0===r.paths.length)throw e.invalidOption("paths","must not be empty");const n=r.source??"index",{matcher:o,literalMustMatch:i}=qe(r.paths),s=(await(async(e,a)=>{if("index"===a)return(await t.readIndex(e)).entries.map(e=>e.path);const r=await vt(e,a),n=[];for await(const a of t.walkTree(e,r))a.mode!==t.FILE_MODE.DIRECTORY&&n.push(a.path);return n})(a,n)).filter(e=>L(o,e));Ve(i,s);const c=new Set(s);if(0===c.size)return{branch:void 0,id:await t.resolveRef(a,"HEAD"),detached:!1,changedPaths:0};const d="index"===n?await(async(e,a)=>{const r=await t.readIndex(e),n=await t.synthesizeTreeFromIndex(e,r.entries);return t.materializeTree(e,{targetTree:n,currentIndex:r,force:!0,forceRewriteAll:!0,paths:a})})(a,c):await(async(e,a,r)=>{const n=await t.acquireIndexLock(e);try{const o=await t.readIndex(e),i=await t.materializeTree(e,{targetTree:a,currentIndex:o,force:!0,forceRewriteAll:!0,paths:r});return await n.commit(i.newIndexEntries),i}finally{await n.release()}})(a,await vt(a,n),c);return{branch:void 0,id:await t.resolveRef(a,"HEAD"),detached:!1,changedPaths:d.written+d.deleted}})(a,r):await(async(a,r)=>{const n=!0===r.detach||/^[0-9a-f]{40}$/.test(r.target),o=await t.readHeadRaw(a),i=await t.resolveRef(a,"HEAD");let s,c;if(n)c=await(async(e,a)=>/^[0-9a-f]{40}$/.test(a)?a:t.resolveRef(e,a))(a,r.target);else{if(s=t.validateRefName(`${gt}${r.target}`),!await a.fs.exists(`${a.layout.gitDir}/${s}`))throw e.branchNotFound(s);c=await t.resolveRef(a,s)}const d=await t.readTree(a,c),f=await t.loadSparseMatcher(a),l=await t.acquireIndexLock(a);let u;try{const e=await t.readIndex(a);u=await t.materializeTree(a,{targetTree:d.id,currentIndex:e,force:r.force??!1,...void 0!==f?{sparse:f}:{}}),await l.commit(u.newIndexEntries)}finally{await l.release()}const w=(e=>{if("symbolic"!==e.kind)return e.id.slice(0,7);if(e.target.startsWith(gt))return e.target.slice(11);const t=e.target.lastIndexOf("/");return-1===t?e.target:e.target.slice(t+1)})(o);return n?(await a.fs.writeUtf8(`${a.layout.gitDir}/HEAD`,`${c}\n`),await t.recordRefUpdate(a,"HEAD",i,c,`checkout: moving from ${w} to ${c.slice(0,7)}`),{branch:void 0,id:c,detached:!0,changedPaths:u.written+u.deleted}):(await t.writeSymbolicRef(a,"HEAD",s),await t.recordRefUpdate(a,"HEAD",i,c,`checkout: moving from ${w} to ${r.target}`),{branch:s,id:c,detached:!1,changedPaths:u.written+u.deleted})})(a,r)}finally{a.progress.end(yt)}},exports.cherryPickAbort=Za,exports.cherryPickContinue=Ya,exports.cherryPickRun=Va,exports.cherryPickSkip=Ka,exports.clone=async(a,r)=>{if(await a.fs.exists(`${a.layout.gitDir}/HEAD`))throw e.targetDirectoryNotEmpty(a.layout.workDir);if(""===r.url)throw e.remoteAdvertisesNoRefs();const n=void 0!==r.filter?he(pe(r.filter)):void 0;a.progress.start(kr);try{void 0!==r.resolver&&await lr(r.url,{resolver:r.resolver,...void 0!==r.allowInsecure?{allowInsecure:r.allowInsecure}:{},...void 0!==r.allowPrivateNetworks?{allowPrivateNetworks:r.allowPrivateNetworks}:{}});const o=await Ja(a,{initialBranch:r.initialBranch??"main",bare:r.bare??!1});try{return await(async(a,r,n,o)=>{const i=er(a,{...void 0!==a.config?.auth?{auth:a.config.auth}:{}}),s=await sr(a,i,r.url);if(0===s.refs.length)throw e.remoteAdvertisesNoRefs();if(void 0!==o&&!fr(s.capabilities))throw t.remoteFilterUnsupported();const c=cr(s.capabilities),d=dr(s.refs),f=await t.fetchPack(a,i,{wants:d,haves:[],capabilities:c,url:r.url,progressOp:"clone:write-objects",...void 0!==r.depth?{depth:r.depth}:{},...void 0!==o?{filter:o,promisor:!0}:{}});f.shallow.length>0&&await t.updateShallow(a,{shallow:f.shallow,unshallow:f.unshallow});const l=await xr(a,s,r.url),u=await Rr(a,s,r.url);return await br(a,r.url,Ir(s),o),{path:n,head:u,fetchedRefs:l}})(a,r,o.gitDir,n)}catch(e){throw await a.fs.rmRecursive(a.layout.gitDir).catch(()=>{}),e}}finally{a.progress.end(kr)}},exports.commit=Dr,exports.configGet=Xr,exports.configGetAll=Yr,exports.configGetRegexp=Kr,exports.configList=Zr,exports.configRemoveSection=an,exports.configRenameSection=tn,exports.configSet=Jr,exports.configUnset=Qr,exports.configUnsetAll=en,exports.continueMerge=async(a,r={})=>{if(await t.assertRepository(a),await t.assertNotBare(a,"merge --continue"),void 0===await Ce(a))throw e.noOperationInProgress("merge");return Dr(a,(e=>({message:e.message??"",...void 0!==e.author&&{author:e.author},...void 0!==e.committer&&{committer:e.committer},...void 0!==e.noVerify&&{noVerify:e.noVerify}}))(r))},exports.createPromisorRemote=e=>({fetch:async t=>{const a=await $n(e,t);return"no-promisor"===a.kind?{attempted:!1,requested:t.length,fetched:0}:{attempted:!0,requested:a.requested,fetched:a.fetched}}}),exports.diff=async function(e,a={}){await t.assertRepository(e);const r=await on(e,a.from??"HEAD"),n=void 0!==a.to?await on(e,a.to):void 0,o=await t.diffTrees(e,r,n,!0===a.detectRenames?{detectRenames:!0}:{});return"patch"!==a.format?o:{format:"patch",text:H(await rn(e,o.changes),function(e){const t={};return void 0!==e.contextLines&&(t.contextLines=e.contextLines),void 0!==e.pathPrefix&&(t.pathPrefix=e.pathPrefix),t}(a)),diff:o}},exports.fetch=cn,exports.fetchMissing=async(t,a)=>{const r=await $n(t,a.oids);if("no-promisor"===r.kind)throw e.noPromisorRemote();return{remote:r.remote,requested:r.requested,fetched:r.fetched}},exports.init=async(e,a={})=>{const r=a.initialBranch??"main",n=a.bare??!1;if(await e.fs.exists(`${e.layout.gitDir}/HEAD`))throw t.alreadyInitialized(e.layout.gitDir);const o=await Ja(e,{initialBranch:r,bare:n});return{path:o.gitDir,initialBranch:o.initialBranch,bare:o.bare}},exports.log=async(e,a={})=>{await t.assertRepository(e);const r=await(async(e,a)=>{if(/^[0-9a-f]{40}$/.test(a))return a;const r=[a,`refs/heads/${a}`,`refs/tags/${a}`];for(const a of r)try{return await t.resolveRef(e,t.validateRefName(a))}catch{}return t.resolveRef(e,t.validateRefName(a))})(e,a.from??"HEAD"),n=await(async(e,a)=>{const r=[];for(const n of a)if(/^[0-9a-f]{40}$/.test(n))r.push(n);else try{r.push(await t.resolveRef(e,t.validateRefName(n)))}catch{}return r})(e,a.excluding??[]),o=a.before,i=[];let s=0;for await(const c of t.walkCommits(e,{from:[r],until:n,order:"first-parent"}))if(!(void 0!==o&&c.data.committer.timestamp>=o.getTime()/1e3)&&(i.push({id:c.id,tree:c.data.tree,parents:c.data.parents,author:c.data.author,committer:c.data.committer,message:c.data.message}),s+=1,void 0!==a.limit&&s>=a.limit))break;return i},exports.matchesPathspec=L,exports.merge=Hi,exports.mv=async(a,r,n,o={})=>{await t.assertRepository(a),await t.assertNotBare(a,"mv"),await t.assertNoPendingOperation(a);const i=r.map(e=>Ue(e)),[s]=i;if(void 0===s)throw e.emptyPathspec();(t=>{for(const a of t)for(const r of t)if(r!==a&&r.startsWith(`${a}/`))throw e.mvOverlappingSources(r,a)})(i);const c=Ue((f=n).endsWith("/")?f.slice(0,-1):f),d=await t.acquireIndexLock(a,void 0!==o.breakStaleLockMs?{breakStaleLockMs:o.breakStaleLockMs}:{});var f;try{const r=await(async a=>{const r=await t.readIndex(a).catch(t=>{if(t instanceof e.TsgitError&&("FILE_NOT_FOUND"===(a=t.data.code)||"INVALID_INDEX_HEADER"===a||"INVALID_INDEX_ENTRY"===a))return{entries:[]};var a;throw t}),n=new Map;for(const e of r.entries)n.set(e.path,e);return n})(a),f=await(async(t,a,r,n)=>{const o=await ws(t,n);if(!0===o?.isDirectory&&!0!==o.isSymbolicLink)return{kind:"into-dir",destDir:n};if(r.endsWith("/"))throw e.mvDestinationDirectoryMissing(a,r);return{kind:"rename",target:n}})(a,s,n,c);if("rename"===f.kind&&i.length>1)throw e.mvDestinationNotDirectory(s,f.target);const{planned:l,skipped:u}=await(async(t,a,r,n,o)=>{const i=[],s=[];for(const c of r){const r="rename"===n.kind?n.target:us(n.destDir,e.basename(c)),d=await is(t,a,c,r,o);if("skip"in d){if(!0===o.skipErrors){s.push({source:c,reason:d.skip});continue}throw ls(d.skip,c,r)}i.push({source:c,target:r,entries:d.entries})}return{planned:i,skipped:s}})(a,r,i,f,o);(t=>{const a=new Set;for(const r of t){if(a.has(r.target))throw e.mvMultipleSourcesSameTarget(r.source,r.target);a.add(r.target)}})(l);const w=(e=>{const t=[];for(const a of e)for(const e of a.entries)t.push({from:e.path,to:fs(e,a.source,a.target)});return t.sort((e,t)=>e.from<t.from?-1:e.from>t.from?1:0)})(l);if(!0===o.dryRun)return{moved:w,skipped:u};((e,t)=>{for(const a of t)for(const t of a.entries){const r=fs(t,a.source,a.target);e.delete(t.path),e.set(r,{...t,path:r})}})(r,l);for(const e of l)await Fe(a,e.source,e.target);return await d.commit(Array.from(r.values())),{moved:w,skipped:u}}finally{await d.release()}},exports.pull=async(a,r={})=>{await t.assertRepository(a),await t.assertNotBare(a,"pull"),await t.assertNoPendingOperation(a);const n=await t.readHeadRaw(a),o="symbolic"===n.kind?(i=n.target).startsWith(ps)?i.slice(11):i:void 0;var i;const s="symbolic"===n.kind?n.target:t.RefName.from("HEAD"),{remote:c,branch:d}=await(async(a,r,n,o)=>{const i=await t.readConfig(a),s=void 0!==r?i.branch?.get(r):void 0,c=n.remote??s?.remote??"origin",d=n.branch??(e=>{if(void 0!==e)return e.startsWith(ps)?e.slice(11):e})(s?.merge);if(void 0===d)throw e.noUpstreamConfigured(o);return{remote:c,branch:d}})(a,o,r,s),f=await cn(a,{remote:c,...void 0!==r.prune?{prune:r.prune}:{},...void 0!==r.depth?{depth:r.depth}:{}}),l=await t.resolveRef(a,`refs/remotes/${c}/${d}`);return{fetch:f,merge:await Hi(a,{target:l,message:r.message??`Merge branch '${d}' of ${f.url}`,reflogLabel:"pull",...void 0!==r.fastForwardOnly?{fastForwardOnly:r.fastForwardOnly}:{},...void 0!==r.noFastForward?{noFastForward:r.noFastForward}:{},...void 0!==r.author?{author:r.author}:{},...void 0!==r.committer?{committer:r.committer}:{}})}},exports.push=async(a,r={})=>{await t.assertRepository(a),a.progress.start(hs);try{const n=r.remote??"origin",o=await(async(a,r)=>{if(!xs.test(r))throw e.invalidOption("remote",`invalid remote name: ${r}`);const n=await t.readConfig(a),o=n.remote?.get(r),i=o?.pushUrl??o?.url;if(void 0===i)throw e.remoteNotConfigured(r);return i})(a,n),i=await(async(a,r)=>{if(void 0!==r&&r.length>0)return r.map(xo);const n=await t.readHeadRaw(a);if("symbolic"!==n.kind)throw e.invalidOption("refspecs","no-default-refspec (HEAD is detached)");const o=n.target;return[xo(`${o}:${o}`)]})(a,r.refspecs),s=er(a,void 0!==a.config?.auth?{auth:a.config.auth}:{}),c=await(async(e,t,a)=>ir(e,t,a,"git-receive-pack"))(a,s,o),d=(await(async(e,t,a,r,n)=>{const o=$s(a.refs),i=[];for(const a of t)i.push(await Is(e,a,o,r,n));return i})(a,i,c,n,r)).filter(e=>e.localOid!==e.remoteOid);return 0===d.length?{remote:n,url:o,pushedRefs:[]}:(await(async(e,a,r,n,o)=>{if(a)return;const i=o.map(bs).join("");await t.runHook(e,"pre-push",{args:[r,n],stdin:i})})(a,r.noVerify??!1,n,o,d),{remote:n,url:o,pushedRefs:await Os(a,s,o,c,d,n)})}finally{a.progress.end(hs)}},exports.rebaseAbort=so,exports.rebaseContinue=oo,exports.rebaseRun=ao,exports.rebaseSkip=io,exports.reflog=async(e,a={})=>(await t.assertRepository(e),"exists"===a.action?(async(e,a)=>({kind:"exists",exists:await t.reflogExists(e,_s(a))}))(e,a.ref):"delete"===a.action?(async(e,a)=>{const r=_s(a.ref);if(!await t.reflogExists(e,r))throw t.reflogNotFound(r);const n=await t.readReflog(e,r);if(!Number.isInteger(a.index)||a.index<0)throw t.reflogEntryOutOfRange(r,a.index,n.length);const o=n.length-1-a.index;if(o<0)throw t.reflogEntryOutOfRange(r,a.index,n.length);const i=n[o],s=Bs(n,o,!0===a.rewrite);return await t.writeReflog(e,r,s),{kind:"delete",removed:i}})(e,a):"expire"===a.action?(async(e,a)=>{const r=Math.floor(Date.now()/1e3),n=Fs(a.expire??"90.days.ago",r),o=Fs(a.expireUnreachable??"30.days.ago",r),i=await Ws(e),s=!0===a.all?await t.listReflogs(e):[_s(a.ref??"HEAD")];let c=0,d=0;for(const a of s){const r=await t.readReflog(e,a),s=r.filter(e=>js(e,i,n,o));c+=r.length-s.length,d+=s.length,s.length!==r.length&&await t.writeReflog(e,a,s)}return{kind:"expire",removed:c,kept:d}})(e,a):(async(e,a)=>{const r=_s(a),n=await t.readReflog(e,r),o=n.length-1,i=n.map((e,t)=>({index:t,selector:`${r}@{${t}}`,entry:n[o-t]}));return{kind:"show",ref:r,entries:i}})(e,a.ref??"HEAD")),exports.remoteAdd=Do,exports.remoteList=No,exports.remoteRemove=Co,exports.remoteRename=Ho,exports.remoteSetUrl=Po,exports.remoteShow=Lo,exports.reset=async(a,r)=>{await t.assertRepository(a),"hard"===r.mode&&await t.assertNotBare(a,"reset --hard"),await t.assertNoPendingOperation(a);const n=await(async(a,r)=>{if(/^[0-9a-f]{40}$/.test(r))return r;const n="HEAD"===r?["HEAD"]:[r,`refs/heads/${r}`,`refs/tags/${r}`];for(const e of n)try{return await t.resolveRef(a,e)}catch{}throw e.revparseUnresolved(r)})(a,r.target);"mixed"===r.mode?await(async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);const n=await t.loadSparseMatcher(e),o=await t.acquireIndexLock(e);try{const a=await t.readIndex(e),i=await t.buildIndexFromTree(e,{targetTree:r.data.tree,currentIndex:a,...void 0!==n?{sparse:n}:{}});await o.commit(i)}finally{await o.release()}})(a,n):"hard"===r.mode&&await(async(e,a)=>{const r=await t.readObject(e,a);if("commit"!==r.type)throw t.unexpectedObjectType("commit",r.type,a);const n=await t.loadSparseMatcher(e),o=await t.acquireIndexLock(e);try{const a=await t.readIndex(e),i=await t.materializeTree(e,{targetTree:r.data.tree,currentIndex:a,force:!0,forceRewriteAll:!0,...void 0!==n?{sparse:n}:{}});(i.written>0||i.deleted>0||void 0!==n)&&await o.commit(i.newIndexEntries)}finally{await o.release()}})(a,n);const o=await t.readHeadRaw(a),i="symbolic"===o.kind?o.target:void 0;return await t.updateRef(a,i??"HEAD",n,{reflogMessage:`reset: moving to ${r.target}`}),{mode:r.mode,id:n,branch:i}},exports.revParse=Ia,exports.revertAbort=Ko,exports.revertContinue=Xo,exports.revertRun=Vo,exports.revertSkip=Yo,exports.rm=async(a,r,n={})=>{if(await t.assertRepository(a),await t.assertNotBare(a,"rm"),await t.assertNoPendingOperation(a),0===r.length)throw e.emptyPathspec();const{matcher:o,literalMustMatch:i}=qe(r),s=await t.acquireIndexLock(a,void 0!==n.breakStaleLockMs?{breakStaleLockMs:n.breakStaleLockMs}:{});try{const r=await t.readIndex(a).catch(t=>{if(t instanceof e.TsgitError&&("FILE_NOT_FOUND"===(a=t.data.code)||"INVALID_INDEX_HEADER"===a||"INVALID_INDEX_ENTRY"===a))return{entries:[]};var a;throw t}),c=new Map;for(const e of r.entries)c.set(e.path,e);const d=[],f=[];for(const[e,t]of c)L(o,e)&&(d.push(e),f.push(t));Ve(i,d),!0!==n.force&&await(async(a,r,n)=>{const o=await Vs(a),i=[],s=[],c=[];for(const e of r){const r=await t.compareWorkingTreeEntry(a,e);if("absent"===r)continue;const d="modified"===r,f=Gs(o,e);f&&d?i.push(e.path):f&&!n?s.push(e.path):d&&!n&&c.push(e.path)}if(i.length>0)throw e.rmStagedAndLocalChanges(i);if(s.length>0)throw e.rmStagedChanges(s);if(c.length>0)throw e.rmLocalModifications(c)})(a,f,!0===n.cached);for(const e of d)c.delete(e);if(!n.cached)for(const t of d)await Be(a,t).catch(t=>{if(!(t instanceof e.TsgitError&&"FILE_NOT_FOUND"===t.data.code))throw t});return await s.commit(Array.from(c.values())),{removed:d}}finally{await s.release()}},exports.sparseCheckoutAdd=li,exports.sparseCheckoutDisable=wi,exports.sparseCheckoutList=si,exports.sparseCheckoutReapply=ui,exports.sparseCheckoutSet=fi,exports.stashApply=Si,exports.stashDrop=Ei,exports.stashList=Ri,exports.stashPop=Oi,exports.stashPush=$i,exports.status=async e=>{await t.assertRepository(e);const a=await t.readHeadRaw(e),r="symbolic"===a.kind?a.target:void 0,n="direct"===a.kind,o=await t.readIndex(e).catch(()=>({entries:[]})),i=new Map;for(const e of o.entries)i.set(e.path,e);e.progress.start(Xs);try{const a=((e,t)=>{let a=0,r=0;return{tick:()=>{a+=1;const n=Math.floor(a/100);n>r&&(r=n,e.update(t,a))}}})(e.progress,Xs),o=(await Promise.all(Array.from(i.values()).map(async r=>{const n=await(async(e,a)=>{if(a.flags.skipWorktree)return;const r=await t.compareWorkingTreeEntry(e,a);return"absent"===r?{kind:"deleted",path:a.path}:"modified"===r?{kind:"modified",path:a.path}:void 0})(e,r);return a.tick(),n}))).filter(e=>void 0!==e),s=await t.buildRepoIgnorePredicate(e),c=[];for await(const{path:a}of t.walkWorkingTree(e,{ignore:s}))i.has(a)||c.push({kind:"untracked",path:a});c.sort(Ys);const d=[...o,...c];return{branch:r,detached:n,indexChanges:[],workingTreeChanges:d,clean:0===d.length}}finally{e.progress.end(Xs)}},exports.submodules=async(e,a={})=>{await t.assertRepository(e);const r=(e=>t.looksLikeObjectId(e)?t.ObjectId.from(e):t.validateRefName(e))(a.ref??"HEAD"),n=!0===a.recursive,o=[];for await(const i of t.walkSubmodules(e,{ref:r,recursive:n,...void 0!==a.maxDepth?{maxDepth:a.maxDepth}:{}}))o.push(i);return{kind:"list",entries:o}},exports.tagCreate=Mi,exports.tagDelete=Ci,exports.tagList=Di,exports.validateUrl=lr;
|
|
2
|
-
//# sourceMappingURL=index-BWCq_5BJ.cjs.map
|