just-git 1.1.8 → 1.1.10

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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var fd=Object.defineProperty;var is=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ee=(e,t)=>()=>(e&&(t=e(e=0)),t);var dd=(e,t)=>{for(var n in t)fd(e,n,{get:t[n],enumerable:!0})};function ds(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function T(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":ds(t)}function It(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return ds(t||".")}function zt(e){if(e==="")return".";if(e==="/")return"/";let t=e.length;for(;t>1&&e.charCodeAt(t-1)===47;)t--;let n=e.slice(0,t),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}function Cr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function at(e,t){let n=ds(e),r=ds(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,d=Math.min(o.length,s.length);for(;f<d&&o[f]===s[f];)f++;let l=o.length-f,u=s.slice(f),m=[];for(let h=0;h<l;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var de=Ee(()=>{"use strict"});function pd(e){let t={},n=null;for(let r of e.split(`
1
+ var dd=Object.defineProperty;var is=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ee=(e,t)=>()=>(e&&(t=e(e=0)),t);var ld=(e,t)=>{for(var n in t)dd(e,n,{get:t[n],enumerable:!0})};function ds(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function T(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":ds(t)}function It(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return ds(t||".")}function zt(e){if(e==="")return".";if(e==="/")return"/";let t=e.length;for(;t>1&&e.charCodeAt(t-1)===47;)t--;let n=e.slice(0,t),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}function Cr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function at(e,t){let n=ds(e),r=ds(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,d=Math.min(o.length,s.length);for(;f<d&&o[f]===s[f];)f++;let l=o.length-f,u=s.slice(f),m=[];for(let h=0;h<l;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var de=Ee(()=>{"use strict"});function gd(e){let t={},n=null;for(let r of e.split(`
2
2
  `)){let o=r.trim();if(!(!o||o.startsWith("#")||o.startsWith(";"))){if(o.startsWith("[")){let s=o.indexOf("]");if(s===-1)continue;n=o.slice(1,s).trim(),n in t||(t[n]={});continue}if(n!==null){let s=t[n];if(!s)continue;let i=o.indexOf("=");if(i===-1){let a=o.trim().toLowerCase();s[a]="true"}else{let a=o.slice(0,i).trim().toLowerCase(),c=o.slice(i+1).trim();s[a]=c}}}}return t}function Eo(e){let t=[];for(let[n,r]of Object.entries(e)){t.push(`[${n}]`);for(let[o,s]of Object.entries(r))t.push(` ${o} = ${s}`)}return`${t.join(`
3
3
  `)}
4
- `}async function le(e){let t=T(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return pd(n)}async function Qe(e,t){let n=T(e.gitDir,"config");await e.fs.writeFile(n,Eo(t))}async function _t(e,t){let n=await le(e),{section:r,key:o}=Ro(t);return n[r]?.[o]}async function ko(e,t,n){let r=await le(e),{section:o,key:s}=Ro(t);r[o]||(r[o]={}),r[o][s]=n,await Qe(e,r)}async function Vi(e,t){let n=await le(e),{section:r,key:o}=Ro(t);return n[r]?.[o]?(delete n[r][o],Object.keys(n[r]).length===0&&delete n[r],await Qe(e,n),!0):!1}function Ro(e){let t=e.split(".");if(t.length===2){let[n="",r=""]=t;return{section:n,key:r.toLowerCase()}}if(t.length===3){let[n="",r="",o=""]=t;return{section:`${n} "${r}"`,key:o.toLowerCase()}}throw new Error(`Invalid config key: "${e}"`)}var Ye=Ee(()=>{"use strict";de()});function ls(e,t){return Xi(e,t,"author")}function Pr(e,t){return Xi(e,t,"committer")}async function Xi(e,t,n){let r=gd[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Yi(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await _t(e,"user.name")??o?.name,i=t.get(r.email)??await _t(e,"user.email")??o?.email;if(!s||!i)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
4
+ `}async function le(e){let t=T(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return gd(n)}async function Qe(e,t){let n=T(e.gitDir,"config");await e.fs.writeFile(n,Eo(t))}async function _t(e,t){let n=await le(e),{section:r,key:o}=Ro(t);return n[r]?.[o]}async function ko(e,t,n){let r=await le(e),{section:o,key:s}=Ro(t);r[o]||(r[o]={}),r[o][s]=n,await Qe(e,r)}async function Yi(e,t){let n=await le(e),{section:r,key:o}=Ro(t);return n[r]?.[o]?(delete n[r][o],Object.keys(n[r]).length===0&&delete n[r],await Qe(e,n),!0):!1}function Ro(e){let t=e.split(".");if(t.length===2){let[n="",r=""]=t;return{section:n,key:r.toLowerCase()}}if(t.length===3){let[n="",r="",o=""]=t;return{section:`${n} "${r}"`,key:o.toLowerCase()}}throw new Error(`Invalid config key: "${e}"`)}var Ye=Ee(()=>{"use strict";de()});function ls(e,t){return Zi(e,t,"author")}function Pr(e,t){return Zi(e,t,"committer")}async function Zi(e,t,n){let r=wd[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Xi(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await _t(e,"user.name")??o?.name,i=t.get(r.email)??await _t(e,"user.email")??o?.email;if(!s||!i)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
5
5
 
6
6
  *** Please tell me who you are.
7
7
 
@@ -9,36 +9,36 @@ Run
9
9
 
10
10
  git config user.email "you@example.com"
11
11
  git config user.name "Your Name"
12
- `);return{name:s,email:i,timestamp:Yi(t.get(r.date)),timezone:"+0000"}}async function Vt(e,t){try{let n=await Pr(e,t);return{name:n.name,email:n.email,timestamp:n.timestamp,tz:n.timezone}}catch{return{name:t.get("GIT_COMMITTER_NAME")??"",email:t.get("GIT_COMMITTER_EMAIL")??"",timestamp:Math.floor(Date.now()/1e3),tz:"+0000"}}}function Yi(e){if(e){let t=parseInt(e,10);if(!Number.isNaN(t))return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.floor(n/1e3)}return Math.floor(Date.now()/1e3)}var gd,hn=Ee(()=>{"use strict";Ye();gd={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function pn(e){let t="";for(let n=0;n<20;n++)t+=Zi[e[n]];return t}function us(e,t){let n="";for(let r=0;r<20;r++)n+=Zi[e[t+r]];return n}function Ot(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var J,Zi,dt=Ee(()=>{"use strict";J="0000000000000000000000000000000000000000",Zi=(()=>{let e=new Array(256);for(let t=0;t<256;t++)e[t]=(t>>4).toString(16)+(t&15).toString(16);return e})()});function xo(e){return typeof e=="string"?wd.encode(e):e}function bd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(xo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=is(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(xo(r)),n},hex:()=>Promise.resolve(t.digest("hex"))};return n}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let e=[],t={update(n){return e.push(xo(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return pn(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}async function nr(e){return Ji().update(e).hex()}var wd,Ji,Gn,Ln=Ee(()=>{"use strict";dt();wd=new TextEncoder;Ji=bd(),Gn=Ji});async function K(e){let t=T(e.gitDir,"index");if(!await e.fs.exists(t))return{version:Co,entries:[]};let n=await e.fs.readFileBuffer(t);return yd(n)}async function se(e,t){let n=T(e.gitDir,"index"),r=await Ed(t);await e.fs.writeFile(n,r)}function wt(e,t){let n;return t.stage===0?n=e.entries.filter(r=>r.path!==t.path):n=e.entries.filter(r=>!(r.path===t.path&&r.stage===t.stage)),n.push(t),n.sort(Po),{...e,entries:n}}function ot(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function ms(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function $t(e){return e.entries.some(t=>t.stage>0)}function Ft(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ae(e){return e.entries.filter(t=>t.stage===0)}function ea(){return{version:Co,entries:[]}}function hs(e){let t=[...e].sort(Po);return{version:Co,entries:t}}function Ce(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function yd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Qi)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},d=t.getUint32(n+24);n+=40;let l=e.subarray(n,n+20),u=pn(l);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let x=n;for(;x<e.byteLength&&e[x]!==0;)x++;g=new TextDecoder().decode(e.subarray(n,x))}let w=62+g.length+1,E=Math.ceil(w/8)*8;n=c+E,i.push({path:g,mode:d,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function Ed(e){let t=[...e.entries].sort(Po),n=12;for(let d of t){let l=62+d.path.length+1;n+=Math.ceil(l/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,Qi),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let d of t){let l=i;s.setUint32(i,d.stat.ctimeSeconds),s.setUint32(i+4,d.stat.ctimeNanoseconds),s.setUint32(i+8,d.stat.mtimeSeconds),s.setUint32(i+12,d.stat.mtimeNanoseconds),s.setUint32(i+16,d.stat.dev),s.setUint32(i+20,d.stat.ino),s.setUint32(i+24,d.mode),s.setUint32(i+28,d.stat.uid),s.setUint32(i+32,d.stat.gid),s.setUint32(i+36,d.stat.size),i+=40;let u=Ot(d.hash);o.set(u,i),i+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(d.path);o.set(p,i),i+=p.byteLength,o[i]=0,i+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;i=l+w}let a=o.subarray(0,i),c=await nr(a),f=Ot(c);return o.set(f,i),o}function Po(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Qi,Co,Re=Ee(()=>{"use strict";dt();de();Ln();Qi=1145655875,Co=2});var kd,ps,ta=Ee(()=>{"use strict";kd=new Set(["tree","commit","tag"]),ps=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!kd.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function Io(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=na[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var na,ra=Ee(()=>{"use strict";na=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;na[e]=t}});async function Rd(){let e;try{e=is(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let t;try{let n=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});n?.engine&&typeof n.engine.bytesWritten=="number"&&(t=r=>{let o=e.inflateSync(r,{info:!0});return{result:new Uint8Array(o.buffer),bytesConsumed:o.engine.bytesWritten}})}catch{}return{deflateSync:n=>new Uint8Array(e.deflateSync(n)),inflateSync:n=>new Uint8Array(e.inflateSync(n)),inflateWithConsumed:t}}if(typeof globalThis.CompressionStream=="function"&&typeof globalThis.DecompressionStream=="function")return{async deflateSync(t){let n=new CompressionStream("deflate"),r=n.writable.getWriter();return r.write(t),r.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())},async inflateSync(t){let n=new DecompressionStream("deflate"),r=n.writable.getWriter();return r.write(t),r.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}};throw new Error("No zlib implementation available. Requires Bun, Node.js, Deno, or a browser with CompressionStream.")}function Oo(){return xd??=Rd()}async function Ir(e){return await(await Oo()).deflateSync(e)}async function rr(e){return await(await Oo()).inflateSync(e)}async function sa(e,t){let n=await Oo();if(n.inflateWithConsumed){let{result:i,bytesConsumed:a}=n.inflateWithConsumed(e);if(i.byteLength!==t)throw new Error(`Inflate size mismatch: got ${i.byteLength}, expected ${t}`);return{result:i,bytesConsumed:a}}let r=await n.inflateSync(e);if(r.byteLength!==t)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${t}`);let o=2,s=e.byteLength;for(;o<s;){let i=o+s>>>1;try{(await n.inflateSync(e.subarray(0,i))).byteLength===t?s=i:o=i+1}catch{o=i+1}}return{result:r,bytesConsumed:o}}var xd,gs=Ee(()=>{"use strict";xd=null});async function ua(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==To)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${To.toString(16)})`);let o=n.getUint32(4);if(o!==aa)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let d=await Id(e,a);i.push(d),a=d.nextOffset}return(await Od(i,t)).map((f,d)=>({...f,offset:i[d].headerOffset,nextOffset:i[d].nextOffset}))}async function Id(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===Or){let l=e[t++];for(a=l&127;l&128;)a+=1,l=e[t++],a=(a<<7)+(l&127);a=n-a}else o===So&&(c=us(e,t),t+=20);let{result:f,bytesConsumed:d}=await sa(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+d}}async function Od(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s){let i=r[s];if(i)return i;let a=e[s];if(a.typeNum!==Or&&a.typeNum!==So){let u=Cd[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let m={type:u,content:a.inflated,hash:await $o(u,a.inflated)};return r[s]=m,m}if(a.typeNum===Or){let u=n.get(a.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`);let m=await o(u),h=$r(m.content,a.inflated),p={type:m.type,content:h,hash:await $o(m.type,h)};return r[s]=p,p}let c=await $d(e,r,a.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(a.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let d=$r(f.content,a.inflated),l={type:f.type,content:d,hash:await $o(f.type,d)};return r[s]=l,l}for(let s=0;s<e.length;s++)await o(s);return r}async function $d(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==Or&&s.typeNum!==So&&(await r(o)).hash===n)return o}}function $r(e,t){let n=0,{value:r,newPos:o}=ia(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:i}=ia(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,l=0;f&1&&(d=t[n++]),f&2&&(d|=t[n++]<<8),f&4&&(d|=t[n++]<<16),f&8&&(d|=t[n++]<<24),f&16&&(l=t[n++]),f&32&&(l|=t[n++]<<8),f&64&&(l|=t[n++]<<16),l===0&&(l=65536),a.set(e.subarray(d,d+l),c),c+=l}else if(f>0)a.set(t.subarray(n,n+f),c),c+=f,n+=f;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==s)throw new Error(`Delta produced ${c} bytes, expected ${s}`);return a}async function ws(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,To),o.setUint32(4,aa),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let a of e){let c=s;n.set(a.hash,s);let f=a.delta&&a.deltaBaseHash?n.get(a.deltaBaseHash):void 0;if(a.delta&&f!==void 0){let d=oa(Or,a.delta.byteLength),l=Sd(s-f),u=await Ir(a.delta);t.push(d,l,u),s+=d.byteLength+l.byteLength+u.byteLength}else{let d=Pd[a.type],l=oa(d,a.content.byteLength),u=await Ir(a.content);t.push(l,u),s+=l.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Td(t),entries:i}}async function Td(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=Gn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Ot(s),r),n}function Sd(e){let t=[];t.push(e&127);let n=e>>>7;for(;n>0;)t.unshift(128|--n&127),n>>>=7;return new Uint8Array(t)}function oa(e,t){let n=[],r=e<<4|t&15;for(t>>=4;t>0;)n.push(r|128),r=t&127,t>>=7;return n.push(r),new Uint8Array(n)}function ia(e,t){let n=0,r=0,o;do o=e[t++],n|=(o&127)<<r,r+=7;while(o&128);return{value:n,newPos:t}}async function $o(e,t){let n=Hd.encode(`${e} ${t.byteLength}\0`),r=Gn();return r.update(n),r.update(t),r.hex()}var To,aa,ca,fa,da,la,Or,So,Cd,Pd,Hd,Tr=Ee(()=>{"use strict";dt();Ln();gs();To=1346454347,aa=2,ca=1,fa=2,da=3,la=4,Or=6,So=7,Cd={[ca]:"commit",[fa]:"tree",[da]:"blob",[la]:"tag"},Pd={commit:ca,tree:fa,blob:da,tag:la};Hd=new TextEncoder});async function pa(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,ma),c+=4,a.setUint32(c,ha),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(Ot(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|d++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let l=Gn();l.update(i.subarray(0,c));let u=await l.hex();return i.set(Ot(u),c),i}async function ga(e){let n=(await ua(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Io(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return pa(n,r)}async function wa(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Io(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return pa(n,r)}var ma,ha,Ut,bs=Ee(()=>{"use strict";dt();Ln();ra();Tr();ma=4285812579,ha=2,Ut=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==ma)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==ha)throw new Error(`Unsupported pack index version: ${n.getUint32(4)}`);this.fanout=new Uint32Array(256);let r=8;for(let s=0;s<256;s++)this.fanout[s]=n.getUint32(r),r+=4;this.count=this.fanout[255],this.hashes=new Uint8Array(t.buffer,t.byteOffset+r,this.count*20),r+=this.count*20,r+=this.count*4,this.offsets=new Uint32Array(this.count);for(let s=0;s<this.count;s++)this.offsets[s]=n.getUint32(r),r+=4;let o=!1;for(let s=0;s<this.count;s++)if(this.offsets[s]&2147483648){o=!0;break}this.largeOffsets=o?new DataView(t.buffer,t.byteOffset+r):null}lookup(t){let n=Ot(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=Ot(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,d=!0;for(let l=0;l<i;l++){let u=l%2===0?this.hashes[f+(l>>1)]>>4&15:this.hashes[f+(l>>1)]&15,m=l%2===0?s[l>>1]>>4&15:s[l>>1]&15;if(u!==m){d=!1;break}}d&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var vd,Ad,Dd,Sr,ba=Ee(()=>{"use strict";dt();bs();Tr();gs();vd=6,Ad=7,Dd={1:"commit",2:"tree",3:"blob",4:"tag"},Sr=class{constructor(t,n){this.data=t;this.index=n instanceof Ut?n:new Ut(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===vd){let d=n[r++],l=d&127;for(;d&128;)l+=1,d=n[r++],l=(l<<7)+(d&127);let u=await rr(n.subarray(r)),m=await this.readAt(t-l);return{type:m.type,content:$r(m.content,u)}}if(s===Ad){let d=us(n,r);r+=20;let l=await rr(n.subarray(r)),u=this.index.lookup(d);if(u===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(u);return{type:m.type,content:$r(m.content,l)}}let c=Dd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await rr(n.subarray(r));if(f.byteLength!==i)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${i}`);return{type:c,content:f}}}});function vo(e,t){let n=Md.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Gd(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=jd.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function Ho(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var Md,jd,sr,Ao=Ee(()=>{"use strict";dt();ta();bs();ba();gs();de();Ln();Md=new TextEncoder,jd=new TextDecoder;sr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new ps(r),this.packDir=T(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=vo(t,n),o=await nr(r),s=Ho(this.gitDir,o);if(await this.fs.exists(s))return o;let i=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Ir(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Ho(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await rr(o),i=Gd(t,s);return this.cache.set(t,i),i}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Ho(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=pn(o);await this.fs.mkdir(this.packDir,{recursive:!0});let i=`pack-${s}`,a=T(this.packDir,`${i}.pack`);await this.fs.writeFile(a,t);let c=await ga(t),f=T(this.packDir,`${i}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(i);let d=new Ut(c);return this.packs.push({name:i,index:d,reader:new Sr(t,d)}),r}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=T(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=T(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Sr(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=T(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(T(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Ut(s),reader:null})}}}});function Hr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function vr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Do=Ee(()=>{"use strict"});function Yt(e){let t=Nd.decode(e),n=t.indexOf(`
12
+ `);return{name:s,email:i,timestamp:Xi(t.get(r.date)),timezone:"+0000"}}async function Vt(e,t){try{let n=await Pr(e,t);return{name:n.name,email:n.email,timestamp:n.timestamp,tz:n.timezone}}catch{return{name:t.get("GIT_COMMITTER_NAME")??"",email:t.get("GIT_COMMITTER_EMAIL")??"",timestamp:Math.floor(Date.now()/1e3),tz:"+0000"}}}function Xi(e){if(e){let t=parseInt(e,10);if(!Number.isNaN(t))return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.floor(n/1e3)}return Math.floor(Date.now()/1e3)}var wd,hn=Ee(()=>{"use strict";Ye();wd={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function pn(e){let t="";for(let n=0;n<20;n++)t+=Ji[e[n]];return t}function us(e,t){let n="";for(let r=0;r<20;r++)n+=Ji[e[t+r]];return n}function Ot(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var J,Ji,dt=Ee(()=>{"use strict";J="0000000000000000000000000000000000000000",Ji=(()=>{let e=new Array(256);for(let t=0;t<256;t++)e[t]=(t>>4).toString(16)+(t&15).toString(16);return e})()});function xo(e){return typeof e=="string"?bd.encode(e):e}function yd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(xo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=is(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(xo(r)),n},hex:()=>Promise.resolve(t.digest("hex"))};return n}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let e=[],t={update(n){return e.push(xo(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return pn(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}async function nr(e){return Qi().update(e).hex()}var bd,Qi,Gn,Ln=Ee(()=>{"use strict";dt();bd=new TextEncoder;Qi=yd(),Gn=Qi});async function K(e){let t=T(e.gitDir,"index");if(!await e.fs.exists(t))return{version:Co,entries:[]};let n=await e.fs.readFileBuffer(t);return Ed(n)}async function se(e,t){let n=T(e.gitDir,"index"),r=await kd(t);await e.fs.writeFile(n,r)}function wt(e,t){let n;return t.stage===0?n=e.entries.filter(r=>r.path!==t.path):n=e.entries.filter(r=>!(r.path===t.path&&r.stage===t.stage)),n.push(t),n.sort(Po),{...e,entries:n}}function ot(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function ms(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function $t(e){return e.entries.some(t=>t.stage>0)}function Ft(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ae(e){return e.entries.filter(t=>t.stage===0)}function ta(){return{version:Co,entries:[]}}function hs(e){let t=[...e].sort(Po);return{version:Co,entries:t}}function Ce(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Ed(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==ea)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},d=t.getUint32(n+24);n+=40;let l=e.subarray(n,n+20),u=pn(l);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let x=n;for(;x<e.byteLength&&e[x]!==0;)x++;g=new TextDecoder().decode(e.subarray(n,x))}let w=62+g.length+1,E=Math.ceil(w/8)*8;n=c+E,i.push({path:g,mode:d,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function kd(e){let t=[...e.entries].sort(Po),n=12;for(let d of t){let l=62+d.path.length+1;n+=Math.ceil(l/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,ea),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let d of t){let l=i;s.setUint32(i,d.stat.ctimeSeconds),s.setUint32(i+4,d.stat.ctimeNanoseconds),s.setUint32(i+8,d.stat.mtimeSeconds),s.setUint32(i+12,d.stat.mtimeNanoseconds),s.setUint32(i+16,d.stat.dev),s.setUint32(i+20,d.stat.ino),s.setUint32(i+24,d.mode),s.setUint32(i+28,d.stat.uid),s.setUint32(i+32,d.stat.gid),s.setUint32(i+36,d.stat.size),i+=40;let u=Ot(d.hash);o.set(u,i),i+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(d.path);o.set(p,i),i+=p.byteLength,o[i]=0,i+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;i=l+w}let a=o.subarray(0,i),c=await nr(a),f=Ot(c);return o.set(f,i),o}function Po(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var ea,Co,Re=Ee(()=>{"use strict";dt();de();Ln();ea=1145655875,Co=2});var Rd,ps,na=Ee(()=>{"use strict";Rd=new Set(["tree","commit","tag"]),ps=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Rd.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function Io(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=ra[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var ra,sa=Ee(()=>{"use strict";ra=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;ra[e]=t}});async function xd(){let e;try{e=is(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let t;try{let n=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});n?.engine&&typeof n.engine.bytesWritten=="number"&&(t=r=>{let o=e.inflateSync(r,{info:!0});return{result:new Uint8Array(o.buffer),bytesConsumed:o.engine.bytesWritten}})}catch{}return{deflateSync:n=>new Uint8Array(e.deflateSync(n)),inflateSync:n=>new Uint8Array(e.inflateSync(n)),inflateWithConsumed:t}}if(typeof globalThis.CompressionStream=="function"&&typeof globalThis.DecompressionStream=="function")return{async deflateSync(t){let n=new CompressionStream("deflate"),r=n.writable.getWriter();return r.write(t),r.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())},async inflateSync(t){let n=new DecompressionStream("deflate"),r=n.writable.getWriter();return r.write(t),r.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}};throw new Error("No zlib implementation available. Requires Bun, Node.js, Deno, or a browser with CompressionStream.")}function Oo(){return Cd??=xd()}async function Ir(e){return await(await Oo()).deflateSync(e)}async function rr(e){return await(await Oo()).inflateSync(e)}async function oa(e,t){let n=await Oo();if(n.inflateWithConsumed){let{result:i,bytesConsumed:a}=n.inflateWithConsumed(e);if(i.byteLength!==t)throw new Error(`Inflate size mismatch: got ${i.byteLength}, expected ${t}`);return{result:i,bytesConsumed:a}}let r=await n.inflateSync(e);if(r.byteLength!==t)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${t}`);let o=2,s=e.byteLength;for(;o<s;){let i=o+s>>>1;try{(await n.inflateSync(e.subarray(0,i))).byteLength===t?s=i:o=i+1}catch{o=i+1}}return{result:r,bytesConsumed:o}}var Cd,gs=Ee(()=>{"use strict";Cd=null});async function ma(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==To)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${To.toString(16)})`);let o=n.getUint32(4);if(o!==ca)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let d=await Od(e,a);i.push(d),a=d.nextOffset}return(await $d(i,t)).map((f,d)=>({...f,offset:i[d].headerOffset,nextOffset:i[d].nextOffset}))}async function Od(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===Or){let l=e[t++];for(a=l&127;l&128;)a+=1,l=e[t++],a=(a<<7)+(l&127);a=n-a}else o===So&&(c=us(e,t),t+=20);let{result:f,bytesConsumed:d}=await oa(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+d}}async function $d(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s){let i=r[s];if(i)return i;let a=e[s];if(a.typeNum!==Or&&a.typeNum!==So){let u=Pd[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let m={type:u,content:a.inflated,hash:await $o(u,a.inflated)};return r[s]=m,m}if(a.typeNum===Or){let u=n.get(a.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`);let m=await o(u),h=$r(m.content,a.inflated),p={type:m.type,content:h,hash:await $o(m.type,h)};return r[s]=p,p}let c=await Td(e,r,a.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(a.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let d=$r(f.content,a.inflated),l={type:f.type,content:d,hash:await $o(f.type,d)};return r[s]=l,l}for(let s=0;s<e.length;s++)await o(s);return r}async function Td(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==Or&&s.typeNum!==So&&(await r(o)).hash===n)return o}}function $r(e,t){let n=0,{value:r,newPos:o}=aa(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:i}=aa(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,l=0;f&1&&(d=t[n++]),f&2&&(d|=t[n++]<<8),f&4&&(d|=t[n++]<<16),f&8&&(d|=t[n++]<<24),f&16&&(l=t[n++]),f&32&&(l|=t[n++]<<8),f&64&&(l|=t[n++]<<16),l===0&&(l=65536),a.set(e.subarray(d,d+l),c),c+=l}else if(f>0)a.set(t.subarray(n,n+f),c),c+=f,n+=f;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==s)throw new Error(`Delta produced ${c} bytes, expected ${s}`);return a}async function ws(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,To),o.setUint32(4,ca),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let a of e){let c=s;n.set(a.hash,s);let f=a.delta&&a.deltaBaseHash?n.get(a.deltaBaseHash):void 0;if(a.delta&&f!==void 0){let d=ia(Or,a.delta.byteLength),l=Hd(s-f),u=await Ir(a.delta);t.push(d,l,u),s+=d.byteLength+l.byteLength+u.byteLength}else{let d=Id[a.type],l=ia(d,a.content.byteLength),u=await Ir(a.content);t.push(l,u),s+=l.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Sd(t),entries:i}}async function Sd(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=Gn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Ot(s),r),n}function Hd(e){let t=[];t.push(e&127);let n=e>>>7;for(;n>0;)t.unshift(128|--n&127),n>>>=7;return new Uint8Array(t)}function ia(e,t){let n=[],r=e<<4|t&15;for(t>>=4;t>0;)n.push(r|128),r=t&127,t>>=7;return n.push(r),new Uint8Array(n)}function aa(e,t){let n=0,r=0,o;do o=e[t++],n|=(o&127)<<r,r+=7;while(o&128);return{value:n,newPos:t}}async function $o(e,t){let n=vd.encode(`${e} ${t.byteLength}\0`),r=Gn();return r.update(n),r.update(t),r.hex()}var To,ca,fa,da,la,ua,Or,So,Pd,Id,vd,Tr=Ee(()=>{"use strict";dt();Ln();gs();To=1346454347,ca=2,fa=1,da=2,la=3,ua=4,Or=6,So=7,Pd={[fa]:"commit",[da]:"tree",[la]:"blob",[ua]:"tag"},Id={commit:fa,tree:da,blob:la,tag:ua};vd=new TextEncoder});async function ga(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,ha),c+=4,a.setUint32(c,pa),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(Ot(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|d++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let l=Gn();l.update(i.subarray(0,c));let u=await l.hex();return i.set(Ot(u),c),i}async function wa(e){let n=(await ma(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Io(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ga(n,r)}async function ba(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Io(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ga(n,r)}var ha,pa,Ut,bs=Ee(()=>{"use strict";dt();Ln();sa();Tr();ha=4285812579,pa=2,Ut=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==ha)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==pa)throw new Error(`Unsupported pack index version: ${n.getUint32(4)}`);this.fanout=new Uint32Array(256);let r=8;for(let s=0;s<256;s++)this.fanout[s]=n.getUint32(r),r+=4;this.count=this.fanout[255],this.hashes=new Uint8Array(t.buffer,t.byteOffset+r,this.count*20),r+=this.count*20,r+=this.count*4,this.offsets=new Uint32Array(this.count);for(let s=0;s<this.count;s++)this.offsets[s]=n.getUint32(r),r+=4;let o=!1;for(let s=0;s<this.count;s++)if(this.offsets[s]&2147483648){o=!0;break}this.largeOffsets=o?new DataView(t.buffer,t.byteOffset+r):null}lookup(t){let n=Ot(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=Ot(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,d=!0;for(let l=0;l<i;l++){let u=l%2===0?this.hashes[f+(l>>1)]>>4&15:this.hashes[f+(l>>1)]&15,m=l%2===0?s[l>>1]>>4&15:s[l>>1]&15;if(u!==m){d=!1;break}}d&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var Ad,Dd,Md,Sr,ya=Ee(()=>{"use strict";dt();bs();Tr();gs();Ad=6,Dd=7,Md={1:"commit",2:"tree",3:"blob",4:"tag"},Sr=class{constructor(t,n){this.data=t;this.index=n instanceof Ut?n:new Ut(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===Ad){let d=n[r++],l=d&127;for(;d&128;)l+=1,d=n[r++],l=(l<<7)+(d&127);let u=await rr(n.subarray(r)),m=await this.readAt(t-l);return{type:m.type,content:$r(m.content,u)}}if(s===Dd){let d=us(n,r);r+=20;let l=await rr(n.subarray(r)),u=this.index.lookup(d);if(u===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(u);return{type:m.type,content:$r(m.content,l)}}let c=Md[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await rr(n.subarray(r));if(f.byteLength!==i)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${i}`);return{type:c,content:f}}}});function vo(e,t){let n=jd.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Ld(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Gd.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function Ho(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var jd,Gd,sr,Ao=Ee(()=>{"use strict";dt();na();bs();ya();gs();de();Ln();jd=new TextEncoder,Gd=new TextDecoder;sr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new ps(r),this.packDir=T(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=vo(t,n),o=await nr(r),s=Ho(this.gitDir,o);if(await this.fs.exists(s))return o;let i=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Ir(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Ho(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await rr(o),i=Ld(t,s);return this.cache.set(t,i),i}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Ho(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=pn(o);await this.fs.mkdir(this.packDir,{recursive:!0});let i=`pack-${s}`,a=T(this.packDir,`${i}.pack`);await this.fs.writeFile(a,t);let c=await wa(t),f=T(this.packDir,`${i}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(i);let d=new Ut(c);return this.packs.push({name:i,index:d,reader:new Sr(t,d)}),r}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=T(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=T(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Sr(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=T(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(T(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Ut(s),reader:null})}}}});function Hr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function vr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Do=Ee(()=>{"use strict"});function Yt(e){let t=_d.decode(e),n=t.indexOf(`
13
13
 
14
14
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i=[],a,c;for(let f of r.split(`
15
- `)){let d=f.indexOf(" ");if(d===-1)continue;let l=f.slice(0,d),u=f.slice(d+1);switch(l){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=Hr(u);break;case"committer":c=Hr(u);break}}if(!s)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:i,author:a,committer:c,message:o}}function Xt(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${vr(e.author)}`),t.push(`committer ${vr(e.committer)}`),t.push(""),t.push(e.message),Ld.encode(t.join(`
16
- `))}var Ld,Nd,rn=Ee(()=>{"use strict";Do();Ld=new TextEncoder,Nd=new TextDecoder});function sn(e){let t=Fd.decode(e),n=t.indexOf(`
15
+ `)){let d=f.indexOf(" ");if(d===-1)continue;let l=f.slice(0,d),u=f.slice(d+1);switch(l){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=Hr(u);break;case"committer":c=Hr(u);break}}if(!s)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:i,author:a,committer:c,message:o}}function Xt(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${vr(e.author)}`),t.push(`committer ${vr(e.committer)}`),t.push(""),t.push(e.message),Nd.encode(t.join(`
16
+ `))}var Nd,_d,rn=Ee(()=>{"use strict";Do();Nd=new TextEncoder,_d=new TextDecoder});function sn(e){let t=Ud.decode(e),n=t.indexOf(`
17
17
 
18
18
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i="commit",a="",c;for(let f of r.split(`
19
- `)){let d=f.indexOf(" ");if(d===-1)continue;let l=f.slice(0,d),u=f.slice(d+1);switch(l){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=Hr(u);break}}if(!s)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:i,name:a,tagger:c,message:o}}function ya(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${vr(e.tagger)}`),t.push(""),t.push(e.message),_d.encode(t.join(`
20
- `))}var _d,Fd,Ar=Ee(()=>{"use strict";Do();_d=new TextEncoder,Fd=new TextDecoder});async function bt(e,t){return nr(vo(e,t))}async function Ie(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function we(e,t){return e.objectStore.read(t)}async function gn(e,t){return e.objectStore.exists(t)}async function ys(e,t){return e.objectStore.ingestPack(t)}async function Ea(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function wn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function oe(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Ud.decode(n.content)}async function yt(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function M(e,t){let n=await we(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return Yt(n.content)}async function ka(e,t){let n=await we(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return sn(n.content)}async function Ne(e,t){let n=t;for(let r=0;r<100;r++){let o=await we(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=sn(o.content).object;continue}throw new Error(`Cannot peel ${o.type} object ${t} to commit`)}throw new Error(`Tag chain too deep for ${t}`)}var Ud,ie=Ee(()=>{"use strict";Ao();rn();Ar();Ln();Ud=new TextDecoder});async function xa(e,t){return e.refStore.readRef(t)}async function U(e,t){let n=t;for(let r=0;r<Ra;r++){let o=await xa(e,n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async function Z(e){return xa(e,"HEAD")}async function X(e){return U(e,"HEAD")}async function Y(e,t,n){let r=e.hooks?await U(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function Ue(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function fe(e,t){let n=e.hooks?await U(e,t):null;await e.refStore.deleteRef(t),await Mr(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function pe(e,t="refs"){return e.refStore.listRefs(t)}function be(e){return e.replace("refs/heads/","")}async function yn(e,t){let n=await Z(e);n&&n.type==="symbolic"?await Y(e,n.target,t):await Y(e,"HEAD",t)}async function Ca(e){if(e.refStore&&!(e.refStore instanceof bn))return;let t=await pe(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await we(e,o.hash);if(s.type==="tag"){let i=sn(s.content).object;for(let a=0;a<100;a++){let c=await we(e,i);if(c.type!=="tag")break;i=sn(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(T(e.gitDir,"packed-refs"),`${n.join(`
19
+ `)){let d=f.indexOf(" ");if(d===-1)continue;let l=f.slice(0,d),u=f.slice(d+1);switch(l){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=Hr(u);break}}if(!s)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:i,name:a,tagger:c,message:o}}function Ea(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${vr(e.tagger)}`),t.push(""),t.push(e.message),Fd.encode(t.join(`
20
+ `))}var Fd,Ud,Ar=Ee(()=>{"use strict";Do();Fd=new TextEncoder,Ud=new TextDecoder});async function bt(e,t){return nr(vo(e,t))}async function Ie(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function we(e,t){return e.objectStore.read(t)}async function gn(e,t){return e.objectStore.exists(t)}async function ys(e,t){return e.objectStore.ingestPack(t)}async function ka(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function wn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function oe(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Bd.decode(n.content)}async function yt(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function M(e,t){let n=await we(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return Yt(n.content)}async function Ra(e,t){let n=await we(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return sn(n.content)}async function Ne(e,t){let n=t;for(let r=0;r<100;r++){let o=await we(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=sn(o.content).object;continue}throw new Error(`Cannot peel ${o.type} object ${t} to commit`)}throw new Error(`Tag chain too deep for ${t}`)}var Bd,ie=Ee(()=>{"use strict";Ao();rn();Ar();Ln();Bd=new TextDecoder});function xa(e){return typeof e=="string"?{type:"direct",hash:e}:e}var Dr,Mo=Ee(()=>{"use strict";Dr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function Pa(e,t){return e.refStore.readRef(t)}async function U(e,t){let n=t;for(let r=0;r<Ca;r++){let o=await Pa(e,n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async function Z(e){return Pa(e,"HEAD")}async function X(e){return U(e,"HEAD")}async function Y(e,t,n){let r=e.hooks?await U(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function Ue(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function fe(e,t){let n=e.hooks?await U(e,t):null;await e.refStore.deleteRef(t),await jr(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function pe(e,t="refs"){return e.refStore.listRefs(t)}function be(e){return e.replace("refs/heads/","")}async function yn(e,t){let n=await Z(e);n&&n.type==="symbolic"?await Y(e,n.target,t):await Y(e,"HEAD",t)}async function Ia(e){if(e.refStore&&!(e.refStore instanceof bn))return;let t=await pe(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await we(e,o.hash);if(s.type==="tag"){let i=sn(s.content).object;for(let a=0;a<100;a++){let c=await we(e,i);if(c.type!=="tag")break;i=sn(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(T(e.gitDir,"packed-refs"),`${n.join(`
21
21
  `)}
22
- `);for(let o of t){let s=T(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Pa(e,T(e.gitDir,"refs"));let r=T(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(T(r,"heads"),{recursive:!0}),await e.fs.mkdir(T(r,"tags"),{recursive:!0})}async function Pa(e,t){if(e.refStore&&!(e.refStore instanceof bn)||!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await Pa(e,T(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Mo,Ra,bn,ue=Ee(()=>{"use strict";ie();Ar();de();je();En();Mo="ref: ",Ra=10,bn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=T(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Mo)?{type:"symbolic",target:s.slice(Mo.length)}:{type:"direct",hash:s}}let o=(await this.readPackedRefs()).get(t);return o?{type:"direct",hash:o}:null}async writeRef(t,n){let r=T(this.gitDir,t);await Dr(this.fs,r),n.type==="symbolic"?await this.fs.writeFile(r,`${Mo}${n.target}
23
- `):await this.fs.writeFile(r,`${n.hash}
24
- `)}async deleteRef(t){let n=T(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=T(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}async compareAndSwapRef(t,n,r){let s=(this.casLocks.get(t)??Promise.resolve(!1)).then(()=>this.compareAndSwapUnsafe(t,n,r),()=>this.compareAndSwapUnsafe(t,n,r));this.casLocks.set(t,s);try{return await s}finally{this.casLocks.get(t)===s&&this.casLocks.delete(t)}}async compareAndSwapUnsafe(t,n,r){let o=await this.resolveRefInternal(t);if(n===null){if(await this.readRef(t)!==null)return!1}else if(o!==n)return!1;return r===null?await this.deleteRef(t):await this.writeRef(t,r),!0}async resolveRefInternal(t){let n=t;for(let r=0;r<Ra;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=T(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
22
+ `);for(let o of t){let s=T(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Oa(e,T(e.gitDir,"refs"));let r=T(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(T(r,"heads"),{recursive:!0}),await e.fs.mkdir(T(r,"tags"),{recursive:!0})}async function Oa(e,t){if(e.refStore&&!(e.refStore instanceof bn)||!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await Oa(e,T(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var jo,Ca,bn,ue=Ee(()=>{"use strict";ie();Ar();de();je();En();Mo();jo="ref: ",Ca=10,bn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=T(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(jo)?{type:"symbolic",target:s.slice(jo.length)}:{type:"direct",hash:s}}let o=(await this.readPackedRefs()).get(t);return o?{type:"direct",hash:o}:null}async writeRef(t,n){let r=xa(n),o=T(this.gitDir,t);await Mr(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${jo}${r.target}
23
+ `):await this.fs.writeFile(o,`${r.hash}
24
+ `)}async deleteRef(t){let n=T(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=T(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}async compareAndSwapRef(t,n,r){let s=(this.casLocks.get(t)??Promise.resolve(!1)).then(()=>this.compareAndSwapUnsafe(t,n,r),()=>this.compareAndSwapUnsafe(t,n,r));this.casLocks.set(t,s);try{return await s}finally{this.casLocks.get(t)===s&&this.casLocks.delete(t)}}async compareAndSwapUnsafe(t,n,r){let o=await this.resolveRefInternal(t);if(n===null){if(await this.readRef(t)!==null)return!1}else if(o!==n)return!1;return r===null?await this.deleteRef(t):await this.writeRef(t,r),!0}async resolveRefInternal(t){let n=t;for(let r=0;r<Ca;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=T(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
25
25
  `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=T(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
26
26
  `),s=[],i=!1;for(let c of o){if(i&&c.startsWith("^")){i=!1;continue}if(i=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){i=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await this.fs.writeFile(n,s.join(`
27
- `)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=T(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function Nn(e,t){let n=t;for(;;){let r=T(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new sr(e,r),refStore:new bn(e,r)};if(await Bd(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new sr(e,n),refStore:new bn(e,n)};let o=Wd(n);if(o===n)return null;n=o}}async function Bd(e,t){let n=T(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=T(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function Es(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:T(t,".git"),i=r?null:t,a=T(s,"HEAD"),c=await e.exists(a);await e.mkdir(T(s,"objects"),{recursive:!0}),await e.mkdir(T(s,"refs","heads"),{recursive:!0}),await e.mkdir(T(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new sr(e,s),refStore:new bn(e,s)};if(!c){await Ue(f,"HEAD",`refs/heads/${o}`);let d={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(T(s,"config"),Eo(d))}return{ctx:f,reinit:c}}async function Dr(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Wd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var En=Ee(()=>{"use strict";Ye();Ao();de();ue()});function ks(e,t){return T(e.gitDir,"logs",t)}function qd(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),d=n.slice(a+1,c),l=n.slice(c+2),u=l.indexOf(" ");if(u<0)return null;let m=parseInt(l.slice(0,u),10),h=l.slice(u+1);return{oldHash:s,newHash:i,name:f,email:d,timestamp:m,tz:h,message:r}}async function Xe(e,t){let n=ks(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
28
- `)){if(!s)continue;let i=qd(s);i&&o.push(i)}return o}function Ia(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function kn(e,t,n){let r=ks(e,t);if(await Dr(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Ia).join(`
27
+ `)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=T(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function Nn(e,t){let n=t;for(;;){let r=T(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new sr(e,r),refStore:new bn(e,r)};if(await Wd(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new sr(e,n),refStore:new bn(e,n)};let o=qd(n);if(o===n)return null;n=o}}async function Wd(e,t){let n=T(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=T(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function Es(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:T(t,".git"),i=r?null:t,a=T(s,"HEAD"),c=await e.exists(a);await e.mkdir(T(s,"objects"),{recursive:!0}),await e.mkdir(T(s,"refs","heads"),{recursive:!0}),await e.mkdir(T(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new sr(e,s),refStore:new bn(e,s)};if(!c){await Ue(f,"HEAD",`refs/heads/${o}`);let d={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(T(s,"config"),Eo(d))}return{ctx:f,reinit:c}}async function Mr(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function qd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var En=Ee(()=>{"use strict";Ye();Ao();de();ue()});function ks(e,t){return T(e.gitDir,"logs",t)}function Kd(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),d=n.slice(a+1,c),l=n.slice(c+2),u=l.indexOf(" ");if(u<0)return null;let m=parseInt(l.slice(0,u),10),h=l.slice(u+1);return{oldHash:s,newHash:i,name:f,email:d,timestamp:m,tz:h,message:r}}async function Xe(e,t){let n=ks(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
28
+ `)){if(!s)continue;let i=Kd(s);i&&o.push(i)}return o}function $a(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function kn(e,t,n){let r=ks(e,t);if(await Mr(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map($a).join(`
29
29
  `)}
30
- `;await e.fs.writeFile(r,o)}async function Be(e,t,n){let r=ks(e,t);await Dr(e.fs,r);let o=`${Ia(n)}
31
- `;if(await e.fs.exists(r)){let s=await e.fs.readFile(r);await e.fs.writeFile(r,s+o)}else await e.fs.writeFile(r,o)}async function Mr(e,t){let n=ks(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,i=!1){let a=await Vt(e,t),c={oldHash:r??J,newHash:o,...a,message:s};await Be(e,n,c),i&&n!=="HEAD"&&await Be(e,"HEAD",c)}var je=Ee(()=>{"use strict";dt();hn();de();En();dt()});function Kd(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let a=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:a}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(i&&i[1]!==void 0&&i[2]!==void 0){let a=i[2]===""?1:parseInt(i[2],10);t.unshift({type:"caret",n:a}),n=i[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function zd(e,t){let n=await Ea(e,t);if(n.length===0)return null;if(n.length>1)throw new jo(t);return n[0]}async function Vd(e,t){if(t==="HEAD"||t==="@")return U(e,"HEAD");if(Oa.includes(t))return U(e,t);if(/^[0-9a-f]{40}$/.test(t))return await gn(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await zd(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await U(e,t);if(s)return s}let n=await U(e,`refs/heads/${t}`);if(n)return n;let r=await U(e,`refs/tags/${t}`);if(r)return r;let o=await U(e,`refs/remotes/${t}`);return o||null}function Yd(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Oa)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Xd(e,t,n){let r=Yd(t),o=await Xe(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=Kd(t),s;if(r!==void 0?s=await Xd(e,n,r):s=await Vd(e,n),!s)return null;o.length>0&&(s=await Ne(e,s));for(let i of o)if(i.type==="tilde")for(let a=0;a<i.n;a++){if(!s)return null;let c=await M(e,s);if(c.parents.length===0||(s=c.parents[0]??null,!s))return null}else{if(i.n===0)continue;if(!s)return null;let a=await M(e,s);if(i.n>a.parents.length||(s=a.parents[i.n-1]??null,!s))return null}return s}function $a(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Oa,jo,on=Ee(()=>{"use strict";ie();je();ue();Oa=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];jo=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function ct(e,t){return e.lstat?e.lstat(t):e.stat(t)}function an(e){return typeof e=="string"?e==="120000":e===40960}async function jr(e,t){if((await ct(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Zd.encode(r)}return e.readFileBuffer(t)}async function Rn(e,t){let n=await jr(e,t);return bt("blob",n)}var Zd,_n=Ee(()=>{"use strict";ie();Zd=new TextEncoder});function xn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Ta.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Ta.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=pn(a),f=o.padStart(6,"0");t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Sa(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Jd.encode(`${i} ${s.name}\0`),c=Ot(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Jd,Ta,Rs=Ee(()=>{"use strict";dt();Jd=new TextEncoder,Ta=new TextDecoder});var Gr,Ha=Ee(()=>{"use strict";Gr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function De(e,t){return va(e,t,"")}async function va(e,t,n){let r=[],o=new Map;for(let i of t){let a=n?i.path.slice(n.length+1):i.path,c=a.indexOf("/");if(c===-1)r.push({mode:Qd(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await va(e,a,c);r.push({mode:Gr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Gr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Gr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Sa({type:"tree",entries:r});return Ie(e,"tree",s)}async function qe(e,t,n=""){let r=await we(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=xn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Gr.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function ce(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function _e(e,t,n){let r=await ce(e,t),o=await ce(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>xe(i.path,a.path))}function Qd(e){return e.toString(8).padStart(6,"0")}var Se=Ee(()=>{"use strict";re();ie();Rs();Ha()});function Aa(e){return/^[a-zA-Z0-9]$/.test(e)}function el(e){return/^[a-zA-Z]$/.test(e)}function tl(e){return e>="0"&&e<="9"}function Go(e){return e>="A"&&e<="Z"}function Lo(e){return e>="a"&&e<="z"}function Da(e){return/^\s$/.test(e)}function nl(e){return e===" "||e===" "}function _o(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function rl(e){return _o(e)&&!Da(e)}function sl(e){return _o(e)&&!Aa(e)&&e!==" "}function ol(e){let t=e.charCodeAt(0);return t<32||t===127}function il(e){return/^[0-9a-fA-F]$/.test(e)}function Lr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function No(e,t,n,r,o){let s=(o&1)!==0,i=(o&2)!==0;for(;t<e.length;){let a=e[t];if(r>=n.length&&a!=="*")return-1;let c=r<n.length?n[r]:"";switch(a){case"\\":{if(t++,t>=e.length)return-1;if(!Lr(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(i&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let d=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((d-1<1||e[d-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&No(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!i;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let d=n.indexOf("/",r);if(d===-1)return-1;r=d+1,t++;break}for(;!(r>=n.length);){if(!al(e[t])){let l=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==l;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let d=No(e,t,n,r,o);if(d!==1){if(!f||d!==-2)return d}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let d=!1,l="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],Lr(c,m,s)&&(d=!0)}else if(m==="-"&&l&&t+1<e.length&&e[t+1]!=="]"){if(t++,m=e[t],m==="\\"){if(t++,t>=e.length)return-1;m=e[t]}let h=l,p=m;if(c>=h&&c<=p&&(d=!0),s){if(Lo(c)){let g=c.toUpperCase();g>=h&&g<=p&&(d=!0)}else if(Go(c)){let g=c.toLowerCase();g>=h&&g<=p&&(d=!0)}}m=""}else if(m==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let h=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-h-1;if(p<0||e[t-1]!==":")t=h-2,m="[",Lr(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);cl(g,c,s)&&(d=!0),m=""}}else Lr(c,m,s)&&(d=!0);l=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!Lr(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function al(e){return e==="*"||e==="?"||e==="["||e==="\\"}function cl(e,t,n){switch(e){case"alnum":return Aa(t);case"alpha":return el(t);case"blank":return nl(t);case"cntrl":return ol(t);case"digit":return tl(t);case"graph":return rl(t);case"lower":return Lo(t)||n&&Go(t);case"print":return _o(t);case"punct":return sl(t);case"space":return Da(t);case"upper":return Go(t)||n&&Lo(t);case"xdigit":return il(t);default:return!1}}function Fn(e,t,n=0){return No(e,0,t,0,n)===0?0:1}var xs=Ee(()=>{"use strict"});function La(e){for(let t=0;t<e.length;t++){let n=e[t];if(n==="\\"){t++;continue}if(n==="*"||n==="?"||n==="[")return t}return e.length}function fl(e){return La(e)===e.length}function dl(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=Cs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Ga);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Ma);let a=Math.min(La(o),s);return o[0]==="*"&&fl(o.slice(1))&&(r|=ja),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function Nr(e,t,n){let r=[];for(let o of e.split(`
32
- `)){let s=dl(o,t);s&&r.push(s)}return{patterns:r,src:n}}function ll(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&ja){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Fn(n,e,2)===0}function ul(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Fn(r,a,2)===0}function Fo(e,t,n){let r=e.lastIndexOf("/")>=0?e.slice(e.lastIndexOf("/")+1):e;for(let o=n.patterns.length-1;o>=0;o--){let s=n.patterns[o];if(s&&!(s.flags&Ga&&!t)){if(s.flags&Ma){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(ll(r,s))return s;continue}if(ul(e,s))return s}}return null}function Zt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Fo(t,n,o);if(s)return s.flags&Cs?"not-ignored":"ignored"}if(e.excludeFile){let r=Fo(t,n,e.excludeFile);if(r)return r.flags&Cs?"not-ignored":"ignored"}if(e.globalExclude){let r=Fo(t,n,e.globalExclude);if(r)return r.flags&Cs?"not-ignored":"ignored"}return"undecided"}async function ir(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=T(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Nr(r,"",n)}catch{}try{let r=await _t(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Nr(o,"",r)}catch{}}catch{}return t}function Un(e,t,n,r){let s=Nr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Ma,ja,Ga,Cs,Is=Ee(()=>{"use strict";Ye();de();xs();Ma=1,ja=4,Ga=8,Cs=16});async function Tt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=T(e.workTree,s.path),a;try{a=await ct(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await Rn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await et(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>xe(s.path,i.path))}async function it(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=T(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&an(t.mode)&&e.fs.symlink){await ct(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=hl.decode(n.content);await e.fs.symlink(i,r)}else{if(e.fs.lstat)try{(await e.fs.lstat(r)).isSymbolicLink&&await e.fs.rm(r,{force:!0})}catch{}await e.fs.writeFile(r,n.content)}}async function Na(e,t){let n=await qe(e,t);for(let r of n)await it(e,r)}async function Jt(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=T(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await ct(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=ml.encode(f),l=await Ie(e,"blob",d),u={path:n,mode:40960,hash:l,stage:0,stat:{...Ce(),size:d.byteLength}};return{index:wt(t,u),hash:l}}let s=await e.fs.readFileBuffer(r),i=await Ie(e,"blob",s),a=o.mode!=null?pl(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Ce(),size:s.byteLength}};return{index:wt(t,c),hash:i}}async function et(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await ir(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);s=Un(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await ct(e.fs,f);if(l.isSymbolicLink){if(s&&Zt(s,d,!1)==="ignored")continue;i.push(d)}else if(l.isDirectory){if(s&&Zt(s,d,!0)==="ignored")continue;let u=await et(e,f,d,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(l.isFile){if(s&&Zt(s,d,!1)==="ignored")continue;i.push(d)}}return i}function pl(e){return e>511?e:e&73?33261:33188}async function Bn(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await Bn(e,zt(t),n))}var ml,hl,tt=Ee(()=>{"use strict";re();Is();Re();ie();de();_n();Se();ml=new TextEncoder,hl=new TextDecoder});function Uo(e){return e.existsOnDisk&&e.indexHash===null}async function gl(e,t,n){let r=await Promise.all(t.map(h=>ce(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await et(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await et(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of i)f.has(h)||d.add(h);let l=Array.from(f).sort().concat(Array.from(d).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of l){let p=null,g=null,w=null,E=null,x=null;if(r.length===1){let j=u(0,h);w=j?.hash??null,x=j?.mode??null}else if(r.length===2){let j=u(0,h),G=u(1,h);g=j?.hash??null,E=j?.mode??null,w=G?.hash??null,x=G?.mode??null}else if(r.length>=3){let j=u(0,h),G=u(1,h),V=u(2,h);p=j?.hash??null,g=G?.hash??null,E=G?.mode??null,w=V?.hash??null,x=V?.mode??null}let k=o.get(h)?.hash??null,R=s.has(h)?1:0,C=i.has(h),P,y=async()=>P!==void 0?P:C?(P=!(await c()).has(h),P):(P=!1,!1),I,O=async()=>{if(I!==void 0)return I;if(!C||!e.workTree)return I=null,null;let j=T(e.workTree,h);try{I=await Rn(e.fs,j)}catch{I=null}return I};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:R,existsOnDisk:C,isIgnoredOnDisk:y,getWorktreeHash:O,headMode:E,remoteMode:x})}return m}function Os(e,t){let n=e.remoteHash;return n===null?e.indexHash===null&&e.indexStage===0?{action:"SKIP",requirements:[]}:{action:"DELETE",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}:e.indexHash===n?{action:"KEEP",requirements:[]}:e.indexHash===null?{action:"TAKE",takeFrom:"remote",requirements:t.reset||!!t.strippedConflictPaths?.has(e.path)?[]:["NO_UNTRACKED"]}:{action:"TAKE",takeFrom:"remote",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}}function $s(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function wl(e,t){switch(e.action){case"TAKE":return e.takeFrom==="head"?t.headHash:e.takeFrom==="remote"?t.remoteHash:e.takeFrom==="base"?t.baseHash:null;case"DELETE":return null;case"KEEP":return t.indexHash;default:return null}}async function bl(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=wl(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await yl(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function yl(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Uo(t)?"WOULD_LOSE_UNTRACKED_REMOVED":null;case"INDEX_MUST_MATCH_HEAD":return t.indexHash!==t.headHash?"WOULD_OVERWRITE":null;case"INDEX_MUST_MATCH_RESULT":return t.indexHash!==null&&t.indexHash!==n?"WOULD_OVERWRITE":null;case"WORKTREE_MUST_BE_UPTODATE":{if(!t.existsOnDisk)return null;let o=await t.getWorktreeHash();return o!==t.indexHash?r?.allowContentEscapeHatch&&(n!==null&&o===n||o===null&&n===null)?null:"NOT_UPTODATE_FILE":null}case"NO_UNTRACKED":return Uo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Uo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function El(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let l=a.get(c);l&&(o.push(l),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:l.hash,mode:l.mode}));break}case"TAKE":{let l=f.takeFrom==="head"?d.headHash:d.remoteHash,u=f.takeFrom==="head"?d.headMode:d.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:l,stage:0,stat:Ce()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:l,mode:m});break}case"DELETE":{r.updateWorktree&&d.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>xe(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Ts(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of kl){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
30
+ `;await e.fs.writeFile(r,o)}async function Be(e,t,n){let r=ks(e,t);await Mr(e.fs,r);let o=`${$a(n)}
31
+ `;if(await e.fs.exists(r)){let s=await e.fs.readFile(r);await e.fs.writeFile(r,s+o)}else await e.fs.writeFile(r,o)}async function jr(e,t){let n=ks(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,i=!1){let a=await Vt(e,t),c={oldHash:r??J,newHash:o,...a,message:s};await Be(e,n,c),i&&n!=="HEAD"&&await Be(e,"HEAD",c)}var je=Ee(()=>{"use strict";dt();hn();de();En();dt()});function zd(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let a=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:a}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(i&&i[1]!==void 0&&i[2]!==void 0){let a=i[2]===""?1:parseInt(i[2],10);t.unshift({type:"caret",n:a}),n=i[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function Vd(e,t){let n=await ka(e,t);if(n.length===0)return null;if(n.length>1)throw new Go(t);return n[0]}async function Yd(e,t){if(t==="HEAD"||t==="@")return U(e,"HEAD");if(Ta.includes(t))return U(e,t);if(/^[0-9a-f]{40}$/.test(t))return await gn(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Vd(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await U(e,t);if(s)return s}let n=await U(e,`refs/heads/${t}`);if(n)return n;let r=await U(e,`refs/tags/${t}`);if(r)return r;let o=await U(e,`refs/remotes/${t}`);return o||null}function Xd(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Ta)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Zd(e,t,n){let r=Xd(t),o=await Xe(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=zd(t),s;if(r!==void 0?s=await Zd(e,n,r):s=await Yd(e,n),!s)return null;o.length>0&&(s=await Ne(e,s));for(let i of o)if(i.type==="tilde")for(let a=0;a<i.n;a++){if(!s)return null;let c=await M(e,s);if(c.parents.length===0||(s=c.parents[0]??null,!s))return null}else{if(i.n===0)continue;if(!s)return null;let a=await M(e,s);if(i.n>a.parents.length||(s=a.parents[i.n-1]??null,!s))return null}return s}function Sa(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Ta,Go,on=Ee(()=>{"use strict";ie();je();ue();Ta=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Go=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function ct(e,t){return e.lstat?e.lstat(t):e.stat(t)}function an(e){return typeof e=="string"?e==="120000":e===40960}async function Gr(e,t){if((await ct(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Jd.encode(r)}return e.readFileBuffer(t)}async function Rn(e,t){let n=await Gr(e,t);return bt("blob",n)}var Jd,_n=Ee(()=>{"use strict";ie();Jd=new TextEncoder});function xn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Ha.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Ha.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=pn(a),f=o.padStart(6,"0");t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function va(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Qd.encode(`${i} ${s.name}\0`),c=Ot(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Qd,Ha,Rs=Ee(()=>{"use strict";dt();Qd=new TextEncoder,Ha=new TextDecoder});async function De(e,t){return Aa(e,t,"")}async function Aa(e,t,n){let r=[],o=new Map;for(let i of t){let a=n?i.path.slice(n.length+1):i.path,c=a.indexOf("/");if(c===-1)r.push({mode:el(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await Aa(e,a,c);r.push({mode:Dr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Dr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Dr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=va({type:"tree",entries:r});return Ie(e,"tree",s)}async function qe(e,t,n=""){let r=await we(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=xn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Dr.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function ce(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function _e(e,t,n){let r=await ce(e,t),o=await ce(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>xe(i.path,a.path))}function el(e){return e.toString(8).padStart(6,"0")}var Se=Ee(()=>{"use strict";re();ie();Rs();Mo()});function Da(e){return/^[a-zA-Z0-9]$/.test(e)}function tl(e){return/^[a-zA-Z]$/.test(e)}function nl(e){return e>="0"&&e<="9"}function Lo(e){return e>="A"&&e<="Z"}function No(e){return e>="a"&&e<="z"}function Ma(e){return/^\s$/.test(e)}function rl(e){return e===" "||e===" "}function Fo(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function sl(e){return Fo(e)&&!Ma(e)}function ol(e){return Fo(e)&&!Da(e)&&e!==" "}function il(e){let t=e.charCodeAt(0);return t<32||t===127}function al(e){return/^[0-9a-fA-F]$/.test(e)}function Lr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function _o(e,t,n,r,o){let s=(o&1)!==0,i=(o&2)!==0;for(;t<e.length;){let a=e[t];if(r>=n.length&&a!=="*")return-1;let c=r<n.length?n[r]:"";switch(a){case"\\":{if(t++,t>=e.length)return-1;if(!Lr(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(i&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let d=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((d-1<1||e[d-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&_o(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!i;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let d=n.indexOf("/",r);if(d===-1)return-1;r=d+1,t++;break}for(;!(r>=n.length);){if(!cl(e[t])){let l=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==l;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let d=_o(e,t,n,r,o);if(d!==1){if(!f||d!==-2)return d}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let d=!1,l="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],Lr(c,m,s)&&(d=!0)}else if(m==="-"&&l&&t+1<e.length&&e[t+1]!=="]"){if(t++,m=e[t],m==="\\"){if(t++,t>=e.length)return-1;m=e[t]}let h=l,p=m;if(c>=h&&c<=p&&(d=!0),s){if(No(c)){let g=c.toUpperCase();g>=h&&g<=p&&(d=!0)}else if(Lo(c)){let g=c.toLowerCase();g>=h&&g<=p&&(d=!0)}}m=""}else if(m==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let h=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-h-1;if(p<0||e[t-1]!==":")t=h-2,m="[",Lr(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);fl(g,c,s)&&(d=!0),m=""}}else Lr(c,m,s)&&(d=!0);l=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!Lr(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function cl(e){return e==="*"||e==="?"||e==="["||e==="\\"}function fl(e,t,n){switch(e){case"alnum":return Da(t);case"alpha":return tl(t);case"blank":return rl(t);case"cntrl":return il(t);case"digit":return nl(t);case"graph":return sl(t);case"lower":return No(t)||n&&Lo(t);case"print":return Fo(t);case"punct":return ol(t);case"space":return Ma(t);case"upper":return Lo(t)||n&&No(t);case"xdigit":return al(t);default:return!1}}function Fn(e,t,n=0){return _o(e,0,t,0,n)===0?0:1}var xs=Ee(()=>{"use strict"});function Na(e){for(let t=0;t<e.length;t++){let n=e[t];if(n==="\\"){t++;continue}if(n==="*"||n==="?"||n==="[")return t}return e.length}function dl(e){return Na(e)===e.length}function ll(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=Cs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=La);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=ja);let a=Math.min(Na(o),s);return o[0]==="*"&&dl(o.slice(1))&&(r|=Ga),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function Nr(e,t,n){let r=[];for(let o of e.split(`
32
+ `)){let s=ll(o,t);s&&r.push(s)}return{patterns:r,src:n}}function ul(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Ga){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Fn(n,e,2)===0}function ml(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Fn(r,a,2)===0}function Uo(e,t,n){let r=e.lastIndexOf("/")>=0?e.slice(e.lastIndexOf("/")+1):e;for(let o=n.patterns.length-1;o>=0;o--){let s=n.patterns[o];if(s&&!(s.flags&La&&!t)){if(s.flags&ja){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(ul(r,s))return s;continue}if(ml(e,s))return s}}return null}function Zt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Uo(t,n,o);if(s)return s.flags&Cs?"not-ignored":"ignored"}if(e.excludeFile){let r=Uo(t,n,e.excludeFile);if(r)return r.flags&Cs?"not-ignored":"ignored"}if(e.globalExclude){let r=Uo(t,n,e.globalExclude);if(r)return r.flags&Cs?"not-ignored":"ignored"}return"undecided"}async function ir(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=T(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Nr(r,"",n)}catch{}try{let r=await _t(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Nr(o,"",r)}catch{}}catch{}return t}function Un(e,t,n,r){let s=Nr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var ja,Ga,La,Cs,Is=Ee(()=>{"use strict";Ye();de();xs();ja=1,Ga=4,La=8,Cs=16});async function Tt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=T(e.workTree,s.path),a;try{a=await ct(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await Rn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await et(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>xe(s.path,i.path))}async function it(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=T(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&an(t.mode)&&e.fs.symlink){await ct(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=pl.decode(n.content);await e.fs.symlink(i,r)}else{if(e.fs.lstat)try{(await e.fs.lstat(r)).isSymbolicLink&&await e.fs.rm(r,{force:!0})}catch{}await e.fs.writeFile(r,n.content)}}async function _a(e,t){let n=await qe(e,t);for(let r of n)await it(e,r)}async function Jt(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=T(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await ct(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=hl.encode(f),l=await Ie(e,"blob",d),u={path:n,mode:40960,hash:l,stage:0,stat:{...Ce(),size:d.byteLength}};return{index:wt(t,u),hash:l}}let s=await e.fs.readFileBuffer(r),i=await Ie(e,"blob",s),a=o.mode!=null?gl(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Ce(),size:s.byteLength}};return{index:wt(t,c),hash:i}}async function et(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await ir(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);s=Un(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await ct(e.fs,f);if(l.isSymbolicLink){if(s&&Zt(s,d,!1)==="ignored")continue;i.push(d)}else if(l.isDirectory){if(s&&Zt(s,d,!0)==="ignored")continue;let u=await et(e,f,d,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(l.isFile){if(s&&Zt(s,d,!1)==="ignored")continue;i.push(d)}}return i}function gl(e){return e>511?e:e&73?33261:33188}async function Bn(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await Bn(e,zt(t),n))}var hl,pl,tt=Ee(()=>{"use strict";re();Is();Re();ie();de();_n();Se();hl=new TextEncoder,pl=new TextDecoder});function Bo(e){return e.existsOnDisk&&e.indexHash===null}async function wl(e,t,n){let r=await Promise.all(t.map(h=>ce(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await et(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await et(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of i)f.has(h)||d.add(h);let l=Array.from(f).sort().concat(Array.from(d).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of l){let p=null,g=null,w=null,E=null,x=null;if(r.length===1){let j=u(0,h);w=j?.hash??null,x=j?.mode??null}else if(r.length===2){let j=u(0,h),G=u(1,h);g=j?.hash??null,E=j?.mode??null,w=G?.hash??null,x=G?.mode??null}else if(r.length>=3){let j=u(0,h),G=u(1,h),V=u(2,h);p=j?.hash??null,g=G?.hash??null,E=G?.mode??null,w=V?.hash??null,x=V?.mode??null}let k=o.get(h)?.hash??null,R=s.has(h)?1:0,C=i.has(h),P,y=async()=>P!==void 0?P:C?(P=!(await c()).has(h),P):(P=!1,!1),I,O=async()=>{if(I!==void 0)return I;if(!C||!e.workTree)return I=null,null;let j=T(e.workTree,h);try{I=await Rn(e.fs,j)}catch{I=null}return I};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:R,existsOnDisk:C,isIgnoredOnDisk:y,getWorktreeHash:O,headMode:E,remoteMode:x})}return m}function Os(e,t){let n=e.remoteHash;return n===null?e.indexHash===null&&e.indexStage===0?{action:"SKIP",requirements:[]}:{action:"DELETE",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}:e.indexHash===n?{action:"KEEP",requirements:[]}:e.indexHash===null?{action:"TAKE",takeFrom:"remote",requirements:t.reset||!!t.strippedConflictPaths?.has(e.path)?[]:["NO_UNTRACKED"]}:{action:"TAKE",takeFrom:"remote",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}}function $s(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function bl(e,t){switch(e.action){case"TAKE":return e.takeFrom==="head"?t.headHash:e.takeFrom==="remote"?t.remoteHash:e.takeFrom==="base"?t.baseHash:null;case"DELETE":return null;case"KEEP":return t.indexHash;default:return null}}async function yl(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=bl(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await El(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function El(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Bo(t)?"WOULD_LOSE_UNTRACKED_REMOVED":null;case"INDEX_MUST_MATCH_HEAD":return t.indexHash!==t.headHash?"WOULD_OVERWRITE":null;case"INDEX_MUST_MATCH_RESULT":return t.indexHash!==null&&t.indexHash!==n?"WOULD_OVERWRITE":null;case"WORKTREE_MUST_BE_UPTODATE":{if(!t.existsOnDisk)return null;let o=await t.getWorktreeHash();return o!==t.indexHash?r?.allowContentEscapeHatch&&(n!==null&&o===n||o===null&&n===null)?null:"NOT_UPTODATE_FILE":null}case"NO_UNTRACKED":return Bo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Bo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function kl(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let l=a.get(c);l&&(o.push(l),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:l.hash,mode:l.mode}));break}case"TAKE":{let l=f.takeFrom==="head"?d.headHash:d.remoteHash,u=f.takeFrom==="head"?d.headMode:d.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:l,stage:0,stat:Ce()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:l,mode:m});break}case"DELETE":{r.updateWorktree&&d.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>xe(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Ts(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Rl){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
33
33
  `);r.push(`${i(t.operationName)}
34
34
  ${f}
35
35
  ${a(n)}
36
36
  `)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
37
- `:"",exitCode:t.errorExitCode}}async function Wn(e,t,n,r){let o=await gl(e,t,n),s=new Map(o.map(d=>[d.path,d])),i=new Map;for(let d of o){let l=r.mergeFn(d,r);i.set(d.path,l)}let a=await bl(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Ts(a,r)};let{newEntries:c,worktreeOps:f}=El(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function He(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){let s=T(n,o.path);o.type==="delete"?await ct(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await it(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await Bn(e.fs,zt(o),n)}async function Cn(e,t,n,r){return Wn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function _a(e,t,n,r){return Wn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function cn(e,t,n){return Wn(e,[{label:"target",treeHash:t}],n,{mergeFn:Os,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ss(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:Ae(n)},i=await Wn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Os,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
37
+ `:"",exitCode:t.errorExitCode}}async function Wn(e,t,n,r){let o=await wl(e,t,n),s=new Map(o.map(d=>[d.path,d])),i=new Map;for(let d of o){let l=r.mergeFn(d,r);i.set(d.path,l)}let a=await yl(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Ts(a,r)};let{newEntries:c,worktreeOps:f}=kl(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function He(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){let s=T(n,o.path);o.type==="delete"?await ct(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await it(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await Bn(e.fs,zt(o),n)}async function Cn(e,t,n,r){return Wn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Fa(e,t,n,r){return Wn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function cn(e,t,n){return Wn(e,[{label:"target",treeHash:t}],n,{mergeFn:Os,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ss(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:Ae(n)},i=await Wn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Os,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
38
38
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
39
39
  `);return c.length>0&&(i.errorOutput=_(c.join("")+`fatal: Could not reset index file to revision '${a}'.
40
- `,128)),i}if(e.workTree&&o.size>0){let a=await ce(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var kl,Qt=Ee(()=>{"use strict";re();Re();de();_n();Se();tt();kl=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function $(e){return{stdout:"",stderr:`fatal: ${e}
41
- `,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function B(e,t,n){let r=await Nn(e,t);return r?n?{...r,...n}:r:Rl}function v(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function ze(e){return e.workTree?null:xl}async function Ve(e){let t=await X(e);return t||$("your current branch does not have any commits yet")}function fn(e,t,n=`fatal: Exiting because of an unresolved conflict.
40
+ `,128)),i}if(e.workTree&&o.size>0){let a=await ce(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var Rl,Qt=Ee(()=>{"use strict";re();Re();de();_n();Se();tt();Rl=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function $(e){return{stdout:"",stderr:`fatal: ${e}
41
+ `,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function B(e,t,n){let r=await Nn(e,t);return r?n?{...r,...n}:r:xl}function v(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function ze(e){return e.workTree?null:Cl}async function Ve(e){let t=await X(e);return t||$("your current branch does not have any commits yet")}function fn(e,t,n=`fatal: Exiting because of an unresolved conflict.
42
42
  `){return $t(e)?_(`error: ${t} is not possible because you have unmerged files.
43
43
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
44
44
  hint: as appropriate to mark resolution and make a commit.
@@ -50,53 +50,53 @@ Use '--' to separate paths from revisions, like this:
50
50
  `).replace(/\n+$/,`
51
51
  `)}function vt(e){return e.endsWith(`
52
52
  `)?e:`${e}
53
- `}var Rl,xl,re=Ee(()=>{"use strict";hn();Re();ie();rn();de();je();ue();En();on();Qt();Rl=$("not a git repository (or any of the parent directories): .git"),xl=$("this operation must be run in a work tree")});var qa={};dd(qa,{CommitHeap:()=>In,countAheadBehind:()=>Ko,findOrphanedCommits:()=>zo,walkCommits:()=>At});async function*At(e,t,n){if(n?.topoOrder){yield*Tl(e,t,n);return}let r=await Wa(e,n?.exclude),o=new Set(r),s=new In,i=Array.isArray(t)?t:[t];for(let a of i)o.has(a)||s.push(await cr(e,a));for(;s.size>0;){let a=s.pop();if(!o.has(a.hash)){o.add(a.hash),yield a;for(let c of a.commit.parents)o.has(c)||s.push(await cr(e,c))}}}async function*Tl(e,t,n){let r=await Wa(e,n?.exclude),o=new Set(r),s=new In,i=Array.isArray(t)?t:[t];for(let u of i)o.has(u)||s.push(await cr(e,u));let a=[],c=new Map;for(;s.size>0;){let u=s.pop();if(!o.has(u.hash)){o.add(u.hash),c.set(u.hash,a.length),a.push(u);for(let m of u.commit.parents)o.has(m)||s.push(await cr(e,m))}}let f=a.length;if(f===0)return;let d=new Int32Array(f);for(let u of a)for(let m of u.commit.parents){let h=c.get(m);h!==void 0&&(d[h]=(d[h]??0)+1)}let l=[];for(let u=f-1;u>=0;u--)d[u]===0&&l.push(u);for(;l.length>0;){let u=l.pop();yield a[u];for(let m of a[u].commit.parents){let h=c.get(m);if(h!==void 0){let p=(d[h]??0)-1;d[h]=p,p===0&&l.push(h)}}}}async function Ko(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of At(e,t))r.add(a.hash);let o=new Set;for await(let a of At(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function zo(e,t,n){let r=n?.maxCount??25,o=await pe(e,"refs"),s=[];for(let d of o)try{s.push(await Ne(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let d of At(e,s))i.add(d.hash);if(i.has(t))return[];let a=[],c=new Set,f=new In;for(f.push(await cr(e,t));f.size>0&&a.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!i.has(d.hash))){a.push({hash:d.hash,subject:ae(d.commit.message)});for(let l of d.commit.parents)c.has(l)||f.push(await cr(e,l))}}return a}async function Wa(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}async function cr(e,t){return{hash:t,commit:await M(e,t)}}var In,Kn=Ee(()=>{"use strict";re();ie();ue();In=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var po=class e{_def;constructor(t){this._def=t}name(t){return new e({...this._def,name:t})}describe(t){return new e({...this._def,description:t})}optional(){return new e({...this._def,required:!1})}variadic(){return new e({...this._def,variadic:!0})}default(t){return new e({...this._def,required:!1,default:t})}};function Ni(e){return new po({_kind:"arg",type:e,required:!0})}function _i(){return Ni("string")}function Fi(){return Ni("number")}var as=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var go=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}};function Ui(e){return new go({_kind:"option",type:e})}function Bi(){return Ui("string")}function Wi(){return Ui("number")}var te={string:Bi,number:Wi};function S(){return new as}var W={string:_i,number:Fi};function ld(e){switch(e.type){case"unknown_option":{let t=`Unknown option "${e.name}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`Unknown command "${e.path}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}}}function wo(e){return e.map(ld).join(`
54
- `)}function ud(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function cs(e,t,n=3){return t.map(o=>({candidate:o,distance:ud(e,o)})).filter(o=>o.distance<=n&&o.distance>0).sort((o,s)=>o.distance-s.distance).slice(0,2).map(o=>o.candidate)}function qi(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=xr(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],d=0;for(;d<n.length;){let u=n[d];if(u==="--"){for(d++;d<n.length;)f.push(n[d]),d++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,d++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:cs(h,x).map(b=>`--${b}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,d++;continue}let w=p??n[++d];if(w===void 0){o.push({type:"missing_value",name:g.key}),d++;continue}let E=Rr(w,g.def.type,g.key,o);E!==void 0&&(a[g.key]=E),d++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),E=w.length>0?w:n[++d];if(E===void 0){o.push({type:"missing_value",name:g.key});break}let x=Rr(E,g.def.type,g.key,o);x!==void 0&&(a[g.key]=x);break}d++;continue}c.push(u),d++}let l=0;for(let u=0;u<t.length;u++){let m=t[u],h=m.name??`arg${u}`;if(m.variadic){let p=c.slice(l);p.length>0?a[h]=p.map(g=>Rr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?a[h]=m.default:a[h]=[],l=c.length}else{let p=c[l];p!==void 0?(a[h]=Rr(p,m.type,h,o),l++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(l<c.length)for(let u=l;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,m]of Object.entries(e))if(a[u]===void 0){if(m._kind==="flag")a[u]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=Rr(r[h.env],h.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(a[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Rr(e,t,n,r){switch(t){case"string":return e;case"number":{let o=Number(e);if(Number.isNaN(o)){r.push({type:"invalid_type",name:n,expected:"number",received:e});return}return o}case"boolean":{if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;r.push({type:"invalid_type",name:n,expected:"boolean",received:e});return}default:return e}}function xr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function bo(e){let t=[],n=e.children.size>0;e.description?t.push(`${e.fullPath} - ${e.description}`):t.push(e.fullPath),t.push("");let r=[e.fullPath];n&&r.push("<command>"),Object.keys(e.options).length>0&&r.push("[options]");let o=e.args;for(let i of o){let a=i.name??"arg",c=i.variadic?`${a}...`:a;r.push(i.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let i=[];for(let[c,f]of e.children)i.push([c,f.description||""]);let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let i=[];for(let c of o){let f=c.name??"arg",d=c.variadic?`${f}...`:f,l=[];c.description&&l.push(c.description),c.required&&l.push("(required)"),c.default!==void 0&&l.push(`(default: ${JSON.stringify(c.default)})`),i.push([d,l.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=md(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
55
- `)}function md(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=xr(i);if(a._kind==="flag"){let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c}`);let l=[];f.description&&l.push(f.description),f.counted&&l.push("(counted)"),f.default!==void 0&&l.push(`(default: ${f.default})`),r.push([d.join(" "),l.join(" ")])}else{let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c} <${f.type}>`);let l=[];f.description&&l.push(f.description),f.required&&l.push("(required)"),f.default!==void 0&&l.push(`(default: ${JSON.stringify(f.default)})`),f.env&&l.push(`[env: ${f.env}]`),r.push([d.join(" "),l.join(" ")])}}let o=Math.max(...r.map(([i])=>i.length)),s=[];t&&s.push(t);for(let[i,a]of r)if(a){let c=" ".repeat(o-i.length+2);s.push(` ${i}${c}${a}`)}else s.push(` ${i}`);return s}function Ki(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function zi(e){return e?e.map(t=>t._def):[]}var fs=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,Ki(n.options),zi(n.args),n.examples??[],n.handler,n.transformArgs);return r.parent=this,this.children.set(t,r),r}get fullPath(){let t=[],n=this;for(;n;)t.unshift(n.name),n=n.parent;return t.join(" ")}toCommand(){return{name:this.name,execute:this.execute.bind(this)}}get allOptions(){return this.options}toTokens(t){let n=[],r=this.allOptions,o=t;for(let[s,i]of Object.entries(r)){let a=o[s],c=xr(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(hd(t))return{stdout:bo(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=qi(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:wo(i.errors),exitCode:1};try{return await this.handler(i.args,n,{passthrough:i.passthrough})}catch(a){return{stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1}}}if(o&&!o.startsWith("-")){let s=cs(o,[...this.children.keys()]);return{stdout:"",stderr:wo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:bo(this),stderr:"",exitCode:0}}};function yo(e,t){return new fs(e,t.description,Ki(t.options),zi(t.args),t.examples??[],t.handler,t.transformArgs)}function hd(e){return e.some(t=>t==="--help"||t==="-h")}re();Is();Re();de();xs();var vs=1,Bo=2,Hs=4,Wo=8,_r=16,Ua=new Set(["*","?","[","\\"]),Pl={glob:vs,literal:Bo,icase:Hs,top:Wo,exclude:_r};function qn(e){for(let t=0;t<e.length;t++)if(Ua.has(e[t]))return!0;return!1}function Il(e){for(let t=0;t<e.length;t++)if(Ua.has(e[t]))return t;return e.length}function Fa(e){let t=e.split("/"),n=[];for(let r of t)if(!(r===""||r===".")){if(r===".."){n.length>0&&n[n.length-1]!==".."&&n.pop();continue}n.push(r)}return n.join("/")}function Ge(e,t){let n=0,r=e;if(r.startsWith(":(")){let c=r.indexOf(")");if(c!==-1){let f=r.slice(2,c);r=r.slice(c+1);for(let d of f.split(",")){let l=Pl[d.trim()];l!==void 0&&(n|=l)}}}else r.startsWith(":/")?(n|=Wo,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=_r,r=r.slice(2));n&Bo&&n&vs&&(n&=~vs);let o;n&Wo||t===""?o=Fa(r):o=Fa(`${t}/${r}`);let s=!!(n&Bo),i=s?!1:qn(o),a=s?o.length:Il(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function As(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&Hs),c=a?n.toLowerCase():n,f=a?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let a=n.slice(0,s),c=t.slice(0,s);if(o&Hs){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&vs&&(i|=2),o&Hs&&(i|=1),Fn(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&_r?As(o,t)&&(r=!0):As(o,t)&&(n=!0);return n&&!r}tt();function Ba(e,t){e.command("add",{description:"Add file contents to the index",args:[W.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:S().alias("A").describe("Add changes from all tracked and untracked files"),force:S().alias("f").describe("Allow adding otherwise ignored files"),update:S().alias("u").describe("Update tracked files"),"dry-run":S().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await K(s);return p=await qo(s,p,a,"",c),n["dry-run"]||await se(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
56
- Maybe you wanted to say 'git add .'?`,exitCode:0};let d=await K(s),l=[],u=[];for(let p of f)qn(p)?u.push(p):l.push(p);let m=[];for(let p of l){let g=It(r.cwd,p),w=at(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return $(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=d.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`)),k=await $l(s,a,w,b);if(k){b&&((await r.fs.stat(g)).isDirectory?d=await qo(s,d,g,w,c):d=(await Jt(s,d,w)).index),m.push(k);continue}}if((await r.fs.stat(g)).isDirectory)d=await qo(s,d,g,w,c);else{let b=d.entries.find(R=>R.path===w&&R.stage===0)?.hash,k=await Jt(s,d,w);d=k.index,c.actions&&k.hash!==b&&c.actions.push(`add '${w}'
53
+ `}var xl,Cl,re=Ee(()=>{"use strict";hn();Re();ie();rn();de();je();ue();En();on();Qt();xl=$("not a git repository (or any of the parent directories): .git"),Cl=$("this operation must be run in a work tree")});var Ka={};ld(Ka,{CommitHeap:()=>In,countAheadBehind:()=>zo,findOrphanedCommits:()=>Vo,walkCommits:()=>At});async function*At(e,t,n){if(n?.topoOrder){yield*Sl(e,t,n);return}let r=await qa(e,n?.exclude),o=new Set(r),s=new In,i=Array.isArray(t)?t:[t];for(let a of i)o.has(a)||s.push(await cr(e,a));for(;s.size>0;){let a=s.pop();if(!o.has(a.hash)){o.add(a.hash),yield a;for(let c of a.commit.parents)o.has(c)||s.push(await cr(e,c))}}}async function*Sl(e,t,n){let r=await qa(e,n?.exclude),o=new Set(r),s=new In,i=Array.isArray(t)?t:[t];for(let u of i)o.has(u)||s.push(await cr(e,u));let a=[],c=new Map;for(;s.size>0;){let u=s.pop();if(!o.has(u.hash)){o.add(u.hash),c.set(u.hash,a.length),a.push(u);for(let m of u.commit.parents)o.has(m)||s.push(await cr(e,m))}}let f=a.length;if(f===0)return;let d=new Int32Array(f);for(let u of a)for(let m of u.commit.parents){let h=c.get(m);h!==void 0&&(d[h]=(d[h]??0)+1)}let l=[];for(let u=f-1;u>=0;u--)d[u]===0&&l.push(u);for(;l.length>0;){let u=l.pop();yield a[u];for(let m of a[u].commit.parents){let h=c.get(m);if(h!==void 0){let p=(d[h]??0)-1;d[h]=p,p===0&&l.push(h)}}}}async function zo(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of At(e,t))r.add(a.hash);let o=new Set;for await(let a of At(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function Vo(e,t,n){let r=n?.maxCount??25,o=await pe(e,"refs"),s=[];for(let d of o)try{s.push(await Ne(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let d of At(e,s))i.add(d.hash);if(i.has(t))return[];let a=[],c=new Set,f=new In;for(f.push(await cr(e,t));f.size>0&&a.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!i.has(d.hash))){a.push({hash:d.hash,subject:ae(d.commit.message)});for(let l of d.commit.parents)c.has(l)||f.push(await cr(e,l))}}return a}async function qa(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}async function cr(e,t){return{hash:t,commit:await M(e,t)}}var In,Kn=Ee(()=>{"use strict";re();ie();ue();In=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var po=class e{_def;constructor(t){this._def=t}name(t){return new e({...this._def,name:t})}describe(t){return new e({...this._def,description:t})}optional(){return new e({...this._def,required:!1})}variadic(){return new e({...this._def,variadic:!0})}default(t){return new e({...this._def,required:!1,default:t})}};function _i(e){return new po({_kind:"arg",type:e,required:!0})}function Fi(){return _i("string")}function Ui(){return _i("number")}var as=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var go=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}};function Bi(e){return new go({_kind:"option",type:e})}function Wi(){return Bi("string")}function qi(){return Bi("number")}var te={string:Wi,number:qi};function S(){return new as}var W={string:Fi,number:Ui};function ud(e){switch(e.type){case"unknown_option":{let t=`Unknown option "${e.name}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`Unknown command "${e.path}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}}}function wo(e){return e.map(ud).join(`
54
+ `)}function md(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function cs(e,t,n=3){return t.map(o=>({candidate:o,distance:md(e,o)})).filter(o=>o.distance<=n&&o.distance>0).sort((o,s)=>o.distance-s.distance).slice(0,2).map(o=>o.candidate)}function Ki(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=xr(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],d=0;for(;d<n.length;){let u=n[d];if(u==="--"){for(d++;d<n.length;)f.push(n[d]),d++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,d++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:cs(h,x).map(b=>`--${b}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,d++;continue}let w=p??n[++d];if(w===void 0){o.push({type:"missing_value",name:g.key}),d++;continue}let E=Rr(w,g.def.type,g.key,o);E!==void 0&&(a[g.key]=E),d++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),E=w.length>0?w:n[++d];if(E===void 0){o.push({type:"missing_value",name:g.key});break}let x=Rr(E,g.def.type,g.key,o);x!==void 0&&(a[g.key]=x);break}d++;continue}c.push(u),d++}let l=0;for(let u=0;u<t.length;u++){let m=t[u],h=m.name??`arg${u}`;if(m.variadic){let p=c.slice(l);p.length>0?a[h]=p.map(g=>Rr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?a[h]=m.default:a[h]=[],l=c.length}else{let p=c[l];p!==void 0?(a[h]=Rr(p,m.type,h,o),l++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(l<c.length)for(let u=l;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,m]of Object.entries(e))if(a[u]===void 0){if(m._kind==="flag")a[u]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=Rr(r[h.env],h.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(a[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Rr(e,t,n,r){switch(t){case"string":return e;case"number":{let o=Number(e);if(Number.isNaN(o)){r.push({type:"invalid_type",name:n,expected:"number",received:e});return}return o}case"boolean":{if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;r.push({type:"invalid_type",name:n,expected:"boolean",received:e});return}default:return e}}function xr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function bo(e){let t=[],n=e.children.size>0;e.description?t.push(`${e.fullPath} - ${e.description}`):t.push(e.fullPath),t.push("");let r=[e.fullPath];n&&r.push("<command>"),Object.keys(e.options).length>0&&r.push("[options]");let o=e.args;for(let i of o){let a=i.name??"arg",c=i.variadic?`${a}...`:a;r.push(i.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let i=[];for(let[c,f]of e.children)i.push([c,f.description||""]);let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let i=[];for(let c of o){let f=c.name??"arg",d=c.variadic?`${f}...`:f,l=[];c.description&&l.push(c.description),c.required&&l.push("(required)"),c.default!==void 0&&l.push(`(default: ${JSON.stringify(c.default)})`),i.push([d,l.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=hd(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
55
+ `)}function hd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=xr(i);if(a._kind==="flag"){let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c}`);let l=[];f.description&&l.push(f.description),f.counted&&l.push("(counted)"),f.default!==void 0&&l.push(`(default: ${f.default})`),r.push([d.join(" "),l.join(" ")])}else{let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c} <${f.type}>`);let l=[];f.description&&l.push(f.description),f.required&&l.push("(required)"),f.default!==void 0&&l.push(`(default: ${JSON.stringify(f.default)})`),f.env&&l.push(`[env: ${f.env}]`),r.push([d.join(" "),l.join(" ")])}}let o=Math.max(...r.map(([i])=>i.length)),s=[];t&&s.push(t);for(let[i,a]of r)if(a){let c=" ".repeat(o-i.length+2);s.push(` ${i}${c}${a}`)}else s.push(` ${i}`);return s}function zi(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Vi(e){return e?e.map(t=>t._def):[]}var fs=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,zi(n.options),Vi(n.args),n.examples??[],n.handler,n.transformArgs);return r.parent=this,this.children.set(t,r),r}get fullPath(){let t=[],n=this;for(;n;)t.unshift(n.name),n=n.parent;return t.join(" ")}toCommand(){return{name:this.name,execute:this.execute.bind(this)}}get allOptions(){return this.options}toTokens(t){let n=[],r=this.allOptions,o=t;for(let[s,i]of Object.entries(r)){let a=o[s],c=xr(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(pd(t))return{stdout:bo(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ki(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:wo(i.errors),exitCode:1};try{return await this.handler(i.args,n,{passthrough:i.passthrough})}catch(a){return{stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1}}}if(o&&!o.startsWith("-")){let s=cs(o,[...this.children.keys()]);return{stdout:"",stderr:wo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:bo(this),stderr:"",exitCode:0}}};function yo(e,t){return new fs(e,t.description,zi(t.options),Vi(t.args),t.examples??[],t.handler,t.transformArgs)}function pd(e){return e.some(t=>t==="--help"||t==="-h")}re();Is();Re();de();xs();var vs=1,Wo=2,Hs=4,qo=8,_r=16,Ba=new Set(["*","?","[","\\"]),Il={glob:vs,literal:Wo,icase:Hs,top:qo,exclude:_r};function qn(e){for(let t=0;t<e.length;t++)if(Ba.has(e[t]))return!0;return!1}function Ol(e){for(let t=0;t<e.length;t++)if(Ba.has(e[t]))return t;return e.length}function Ua(e){let t=e.split("/"),n=[];for(let r of t)if(!(r===""||r===".")){if(r===".."){n.length>0&&n[n.length-1]!==".."&&n.pop();continue}n.push(r)}return n.join("/")}function Ge(e,t){let n=0,r=e;if(r.startsWith(":(")){let c=r.indexOf(")");if(c!==-1){let f=r.slice(2,c);r=r.slice(c+1);for(let d of f.split(",")){let l=Il[d.trim()];l!==void 0&&(n|=l)}}}else r.startsWith(":/")?(n|=qo,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=_r,r=r.slice(2));n&Wo&&n&vs&&(n&=~vs);let o;n&qo||t===""?o=Ua(r):o=Ua(`${t}/${r}`);let s=!!(n&Wo),i=s?!1:qn(o),a=s?o.length:Ol(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function As(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&Hs),c=a?n.toLowerCase():n,f=a?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let a=n.slice(0,s),c=t.slice(0,s);if(o&Hs){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&vs&&(i|=2),o&Hs&&(i|=1),Fn(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&_r?As(o,t)&&(r=!0):As(o,t)&&(n=!0);return n&&!r}tt();function Wa(e,t){e.command("add",{description:"Add file contents to the index",args:[W.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:S().alias("A").describe("Add changes from all tracked and untracked files"),force:S().alias("f").describe("Allow adding otherwise ignored files"),update:S().alias("u").describe("Update tracked files"),"dry-run":S().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await K(s);return p=await Ko(s,p,a,"",c),n["dry-run"]||await se(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
56
+ Maybe you wanted to say 'git add .'?`,exitCode:0};let d=await K(s),l=[],u=[];for(let p of f)qn(p)?u.push(p):l.push(p);let m=[];for(let p of l){let g=It(r.cwd,p),w=at(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return $(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=d.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`)),k=await Tl(s,a,w,b);if(k){b&&((await r.fs.stat(g)).isDirectory?d=await Ko(s,d,g,w,c):d=(await Jt(s,d,w)).index),m.push(k);continue}}if((await r.fs.stat(g)).isDirectory)d=await Ko(s,d,g,w,c);else{let b=d.entries.find(R=>R.path===w&&R.stage===0)?.hash,k=await Jt(s,d,w);d=k.index,c.actions&&k.hash!==b&&c.actions.push(`add '${w}'
57
57
  `)}}else if(d.entries.some(b=>b.path===w||b.path.startsWith(`${w}/`))){if(c.actions)for(let b of d.entries)(b.path===w||b.path.startsWith(`${w}/`))&&c.actions.push(`remove '${b.path}'
58
58
  `);d={...d,entries:d.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return $(`pathspec '${p}' did not match any files`)}if(m.length>0)return n["dry-run"]||await se(s,d),_(`The following paths are ignored by one of your .gitignore files:
59
59
  ${m.join(`
60
60
  `)}
61
61
  hint: Use -f if you really want to add them.
62
62
  hint: Disable this message with "git config set advice.addIgnoredFile false"
63
- `);if(u.length>0){let p=await Ol(s,r.cwd,d,u,c);if(p.error)return p.error;d=p.index}return n["dry-run"]||await se(s,d),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function Ol(e,t,n,r,o){let s=e.workTree,i=lt(e,t),a=r.map(l=>Ge(l,i)),c=new Array(a.length).fill(!1),f=l=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&As(a[u],l)&&(c[u]=!0)},d=[];for(let l of n.entries){if(l.stage>0||!ye(a,l.path))continue;f(l.path);let u=T(s,l.path);if(await e.fs.exists(u)){let m=await Jt(e,n,l.path);n=m.index,o?.actions&&m.hash!==l.hash&&o.actions.push(`add '${l.path}'
63
+ `);if(u.length>0){let p=await $l(s,r.cwd,d,u,c);if(p.error)return p.error;d=p.index}return n["dry-run"]||await se(s,d),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function $l(e,t,n,r,o){let s=e.workTree,i=lt(e,t),a=r.map(l=>Ge(l,i)),c=new Array(a.length).fill(!1),f=l=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&As(a[u],l)&&(c[u]=!0)},d=[];for(let l of n.entries){if(l.stage>0||!ye(a,l.path))continue;f(l.path);let u=T(s,l.path);if(await e.fs.exists(u)){let m=await Jt(e,n,l.path);n=m.index,o?.actions&&m.hash!==l.hash&&o.actions.push(`add '${l.path}'
64
64
  `)}else o?.actions&&o.actions.push(`remove '${l.path}'
65
65
  `),d.push(l.path)}for(let l of d)n=ot(n,l);if(!o?.updateOnly){let l=new Set(n.entries.map(m=>m.path)),u=await et(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(l.has(m)||!ye(a,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
66
- `),n=(await Jt(e,n,m)).index}}for(let l=0;l<a.length;l++){let u=a[l];if(!c[l]&&!(u.magic&_r))return{index:n,error:$(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function qo(e,t,n,r,o){let s=r===""?"":`${r}/`,i=e.workTree,a=[],c=new Set;for(let f of t.entries){if(!(s===""||f.path.startsWith(s))||c.has(f.path))continue;c.add(f.path);let d=T(i,f.path);if(await e.fs.exists(d)){let l=f.stage>0,u=await Jt(e,t,f.path);t=u.index,o?.actions&&(l||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
66
+ `),n=(await Jt(e,n,m)).index}}for(let l=0;l<a.length;l++){let u=a[l];if(!c[l]&&!(u.magic&_r))return{index:n,error:$(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function Ko(e,t,n,r,o){let s=r===""?"":`${r}/`,i=e.workTree,a=[],c=new Set;for(let f of t.entries){if(!(s===""||f.path.startsWith(s))||c.has(f.path))continue;c.add(f.path);let d=T(i,f.path);if(await e.fs.exists(d)){let l=f.stage>0,u=await Jt(e,t,f.path);t=u.index,o?.actions&&(l||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
67
67
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
68
68
  `),a.push(f.path)}for(let f of a)t=ot(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(l=>l.path)),d=await et(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let l of d){if(f.has(l))continue;o?.actions&&o.actions.push(`add '${l}'
69
- `),t=(await Jt(e,t,l)).index}}return t}async function $l(e,t,n,r){let o=await ir(e);try{let i=await e.fs.readFile(T(t,".gitignore"));o=Un(o,i,"",T(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=T(t,a);if(Zt(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(T(c,".gitignore"));o=Un(o,f,a,T(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(T(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(Zt(o,n,i)==="ignored")return n}return null}re();re();Kn();ie();de();ue();async function ke(e,t){let n=T(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Oe(e,t,n){await e.fs.writeFile(T(e.gitDir,t),n)}async function he(e,t){let n=T(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function Fr(e){await fe(e,"MERGE_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}async function Wt(e){await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function Dt(e){await fe(e,"REVERT_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function zn(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await fe(e,t);await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}var Vo="DETACH_POINT";async function Ka(e,t){await e.fs.writeFile(T(e.gitDir,Vo),t)}async function mt(e){let t=T(e.gitDir,Vo);await e.fs.exists(t)&&await e.fs.rm(t)}async function Ur(e){let t=T(e.gitDir,Vo);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}de();ue();async function Et(e){let t=await ke(e,"BISECT_START");return t!=null&&t.trim().length>0}async function Br(e){let t=await ke(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
69
+ `),t=(await Jt(e,t,l)).index}}return t}async function Tl(e,t,n,r){let o=await ir(e);try{let i=await e.fs.readFile(T(t,".gitignore"));o=Un(o,i,"",T(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=T(t,a);if(Zt(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(T(c,".gitignore"));o=Un(o,f,a,T(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(T(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(Zt(o,n,i)==="ignored")return n}return null}re();re();Kn();ie();de();ue();async function ke(e,t){let n=T(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Oe(e,t,n){await e.fs.writeFile(T(e.gitDir,t),n)}async function he(e,t){let n=T(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function Fr(e){await fe(e,"MERGE_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}async function Wt(e){await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function Dt(e){await fe(e,"REVERT_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function zn(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await fe(e,t);await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}var Yo="DETACH_POINT";async function za(e,t){await e.fs.writeFile(T(e.gitDir,Yo),t)}async function mt(e){let t=T(e.gitDir,Yo);await e.fs.exists(t)&&await e.fs.rm(t)}async function Ur(e){let t=T(e.gitDir,Yo);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}de();ue();async function Et(e){let t=await ke(e,"BISECT_START");return t!=null&&t.trim().length>0}async function Br(e){let t=await ke(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
70
70
  `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Ds(e){let t=(await ke(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await Br(e),o=await U(e,`refs/bisect/${n}`),s=[],i=[],a=await pe(e,"refs/bisect");for(let d of a)d.name.startsWith(`refs/bisect/${r}-`)?s.push(d.hash):d.name.startsWith("refs/bisect/skip-")&&i.push(d.hash);let c=await ke(e,"BISECT_HEAD")!=null||await e.fs.exists(T(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(T(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function kt(e,t){let n=await ke(e,"BISECT_LOG")??"";await Oe(e,"BISECT_LOG",n+t+`
71
- `)}async function Ms(e){let t=await pe(e,"refs/bisect");for(let r of t)await fe(e,r.name);await he(e,"BISECT_EXPECTED_REV"),await he(e,"BISECT_ANCESTORS_OK"),await he(e,"BISECT_LOG"),await he(e,"BISECT_TERMS"),await he(e,"BISECT_NAMES"),await he(e,"BISECT_FIRST_PARENT"),await he(e,"BISECT_HEAD"),await he(e,"BISECT_START");let n=T(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function za(e,t,n,r,o){let s=[],i=new Map;for await(let g of At(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ae(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,E=[g.hash],x=0;for(;x<E.length;){let b=E[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let k=i.get(b);if(k)for(let R of k)!w.has(R)&&c.has(R)&&E.push(R)}f.set(g.hash,w.size)}let d=s[0].hash,l=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,E=Math.abs(2*w-a);E<l&&(l=E,d=g.hash)}let u=!1;if(l===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,E=Math.abs(2*w-a);E<l&&(l=E,d=g.hash)}}let m=s.find(g=>g.hash===d),h=Sl(a),p=Hl(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function Sl(e){return Math.floor((e-1)/2)}function Hl(e){return e<=1?0:Math.ceil(Math.log2(e))}function Va(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
71
+ `)}async function Ms(e){let t=await pe(e,"refs/bisect");for(let r of t)await fe(e,r.name);await he(e,"BISECT_EXPECTED_REV"),await he(e,"BISECT_ANCESTORS_OK"),await he(e,"BISECT_LOG"),await he(e,"BISECT_TERMS"),await he(e,"BISECT_NAMES"),await he(e,"BISECT_FIRST_PARENT"),await he(e,"BISECT_HEAD"),await he(e,"BISECT_START");let n=T(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Va(e,t,n,r,o){let s=[],i=new Map;for await(let g of At(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ae(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,E=[g.hash],x=0;for(;x<E.length;){let b=E[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let k=i.get(b);if(k)for(let R of k)!w.has(R)&&c.has(R)&&E.push(R)}f.set(g.hash,w.size)}let d=s[0].hash,l=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,E=Math.abs(2*w-a);E<l&&(l=E,d=g.hash)}let u=!1;if(l===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,E=Math.abs(2*w-a);E<l&&(l=E,d=g.hash)}}let m=s.find(g=>g.hash===d),h=Hl(a),p=vl(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function Hl(e){return Math.floor((e-1)/2)}function vl(e){return e<=1?0:Math.ceil(Math.log2(e))}function Ya(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
72
72
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
73
73
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
74
- `}function Ya(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
74
+ `}function Xa(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
75
75
  [${e.hash}] ${e.subject}
76
- `}async function Xa(e,t){let n=await M(e,t),r=ae(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
76
+ `}async function Za(e,t){let n=await M(e,t),r=ae(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
77
77
  `;return i+=`commit ${t}
78
78
  `,i+=`Author: ${n.author.name} <${n.author.email}>
79
79
  `,i+=`Date: ${s}
80
80
  `,i+=`
81
81
  `,i+=` ${r}
82
82
  `,i+=`
83
- `,i}re();Kn();Ye();Re();ie();de();je();ue();re();Kn();Ye();Re();ie();de();ie();rn();de();function fr(e){return T(e.gitDir,"rebase-merge")}async function Mt(e){return e.fs.exists(fr(e))}async function ht(e){let t=fr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(T(t,"head-name")),r=await e.fs.readFile(T(t,"orig-head")),o=await e.fs.readFile(T(t,"onto")),s=Number.parseInt(await e.fs.readFile(T(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(T(t,"end")),10),a=await e.fs.exists(T(t,"git-rebase-todo"))?T(t,"git-rebase-todo"):T(t,"todo"),c=Za(await e.fs.readFile(a)),f=await e.fs.exists(T(t,"done"))?await e.fs.readFile(T(t,"done")):"",d=Za(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:d,msgnum:s,end:i}}async function Yo(e,t){let n=fr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(T(n,"head-name"),`${t.headName}
83
+ `,i}re();Kn();Ye();Re();ie();de();je();ue();re();Kn();Ye();Re();ie();de();ie();rn();de();function fr(e){return T(e.gitDir,"rebase-merge")}async function Mt(e){return e.fs.exists(fr(e))}async function ht(e){let t=fr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(T(t,"head-name")),r=await e.fs.readFile(T(t,"orig-head")),o=await e.fs.readFile(T(t,"onto")),s=Number.parseInt(await e.fs.readFile(T(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(T(t,"end")),10),a=await e.fs.exists(T(t,"git-rebase-todo"))?T(t,"git-rebase-todo"):T(t,"todo"),c=Ja(await e.fs.readFile(a)),f=await e.fs.exists(T(t,"done"))?await e.fs.readFile(T(t,"done")):"",d=Ja(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:d,msgnum:s,end:i}}async function Xo(e,t){let n=fr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(T(n,"head-name"),`${t.headName}
84
84
  `),await e.fs.writeFile(T(n,"orig-head"),`${t.origHead}
85
85
  `),await e.fs.writeFile(T(n,"onto"),`${t.onto}
86
86
  `),await e.fs.writeFile(T(n,"msgnum"),`${String(t.msgnum)}
87
87
  `),await e.fs.writeFile(T(n,"end"),`${String(t.end)}
88
- `),await e.fs.writeFile(T(n,"git-rebase-todo"),Gs(t.todo)),await e.fs.writeFile(T(n,"done"),Gs(t.done)),await e.fs.writeFile(T(n,"interactive"),"")}async function ec(e){let t=fr(e),n=await ht(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(T(t,"msgnum"),`${String(n.msgnum)}
89
- `),await e.fs.writeFile(T(t,"git-rebase-todo"),Gs(n.todo)),await e.fs.writeFile(T(t,"done"),Gs(n.done))}async function Xo(e){let t=fr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Ls(e,t,n){let r=fr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(T(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
88
+ `),await e.fs.writeFile(T(n,"git-rebase-todo"),Gs(t.todo)),await e.fs.writeFile(T(n,"done"),Gs(t.done)),await e.fs.writeFile(T(n,"interactive"),"")}async function tc(e){let t=fr(e),n=await ht(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(T(t,"msgnum"),`${String(n.msgnum)}
89
+ `),await e.fs.writeFile(T(t,"git-rebase-todo"),Gs(n.todo)),await e.fs.writeFile(T(t,"done"),Gs(n.done))}async function Zo(e){let t=fr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Ls(e,t,n){let r=fr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(T(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
90
90
  GIT_AUTHOR_EMAIL='${n.email}'
91
91
  GIT_AUTHOR_DATE='${o}'
92
92
  `),await e.fs.writeFile(T(r,"stopped-sha"),`${t}
93
- `)}function Za(e){let t=[];for(let n of e.split(`
93
+ `)}function Ja(e){let t=[];for(let n of e.split(`
94
94
  `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^pick\s+([0-9a-f]+)\s+(.*)/);if(o?.[1]&&o[2]){let s=o[2].startsWith("# ")?o[2].slice(2):o[2];t.push({hash:o[1],subject:s})}}return t}function Gs(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
95
95
  `)}
96
- `}async function tc(e,t,n){let r=new Map,[o,s]=await Promise.all([Ja(e,t,r),Ja(e,n,r)]),i=new Set;for(let c of s)o.has(c)||i.add(c);let a=new Set;for(let c of o)s.has(c)||a.add(c);return{right:await Qa(e,r,n,i),left:await Qa(e,r,t,a)}}async function Ja(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await js(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function Qa(e,t,n,r){if(r.size===0)return[];let o=new Map;for(let f of r)o.set(f,0);for(let f of r){let d=await js(e,f,t);for(let l of d.commit.parents)r.has(l)&&o.set(l,(o.get(l)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await js(e,f,t));s.sort((f,d)=>f.commit.committer.timestamp-d.commit.committer.timestamp);let i=s.map(f=>f.hash),a=[],c=new Set;for(;i.length>0;){let f=i.pop();if(!f||c.has(f))continue;c.add(f);let d=await js(e,f,t);d.commit.parents.length<=1&&a.push(d);for(let l of d.commit.parents)if(r.has(l)&&!c.has(l)){let u=(o.get(l)??0)-1;o.set(l,u),u<=0&&i.push(l)}}return a.reverse(),a}async function js(e,t,n){let r=n.get(t);if(r)return r;let o=await we(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Yt(o.content)};return n.set(t,s),s}ue();ie();function dr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function vl(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=dr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&dr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Al=50;async function nt(e,t,n=Al){let r=new Map,o=[],s=[],i=[];for(let d of t)if(d.status==="deleted"&&d.oldHash){let l=r.get(d.oldHash)??[];l.push(d),r.set(d.oldHash,l),o.push(d)}else d.status==="added"&&d.newHash?s.push(d):i.push(d);let a=[],c=[];for(let d of s){let l=d.newHash;if(!l){c.push(d);continue}let u=r.get(l);if(u&&u.length>0){let m=vl(u,d.path);m&&a.push({oldPath:m.path,newPath:d.path,oldHash:m.oldHash??l,newHash:l,similarity:100,oldMode:m.oldMode,newMode:d.newMode})}else c.push(d)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let d=await Dl(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}if(f.length>0&&c.length>0){let d=await Gl(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}return{remaining:[...i,...f,...c],renames:a}}async function Dl(e,t,n,r){let o=new Map;for(let a=0;a<t.length;a++){let c=t[a];if(!c)continue;let f=dr(c.path);o.has(f)?o.set(f,-1):o.set(f,a)}let s=new Map;for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let f=dr(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let d=t[c],l=n[f];if(!d?.oldHash||!l?.newHash||d.oldHash===l.newHash)continue;let u=await yt(e,d.oldHash),m=await yt(e,l.newHash),h=jl(u,m);h<r||i.push({oldPath:d.path,newPath:l.path,oldHash:d.oldHash,newHash:l.newHash,similarity:h,oldMode:d.oldMode,newMode:l.newMode})}return i}var nc=107927;function Ns(e){let t=new Map,n=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let f=(r+Math.imul(o,97))%nc;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%nc;t.set(i,(t.get(i)??0)+n)}let s=[];for(let[i,a]of t)s.push({hash:i,count:a});return s.sort((i,a)=>i.hash-a.hash),s}function Ml(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let i=e[o];if(!i)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=i.hash)break;r+=f.count,s++}let a=i.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===i.hash&&(c=f.count,s++)}a<c?(r+=c-a,n+=a):n+=c,o++}for(;s<t.length;){let i=t[s];i&&(r+=i.count),s++}return{srcCopied:n,literalAdded:r}}function jl(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:rc(e.length,Ns(e),t.length,Ns(t))}function rc(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Ml(t,r);return Math.floor(i*100/o)}async function Gl(e,t,n,r){let o=[];for(let d of t)if(d.oldHash){let l=await yt(e,d.oldHash);o.push({size:l.length,chunks:Ns(l)})}else o.push(null);let s=[];for(let d of n)if(d.newHash){let l=await yt(e,d.newHash);s.push({size:l.length,chunks:Ns(l)})}else s.push(null);let i=[];for(let d=0;d<t.length;d++){let l=t[d],u=o[d];if(!(!l||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=rc(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=dr(l.path)===dr(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}i.sort((d,l)=>l.similarity-d.similarity||l.nameScore-d.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:l,addIdx:u}of i){if(a.has(l)||c.has(u))continue;a.add(l),c.add(u);let m=t[l],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:d,oldMode:m.oldMode,newMode:h.newMode})}return f}function On(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let d=Math.max(0,n-o-a),l=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+d),p=t.slice(o,o+l);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Se();tt();async function rt(e,t){let n=await Z(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=be(n.target):(s=!0,o="HEAD detached");let i=t?.index??await K(e),a=Jo(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await Zo(e,c,i,a),l=await Tt(e,i),u=[],m=[];for(let g of l)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>xe(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Qo(m,h);return Ll(e,r,s,o,i,d,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function sc(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Ll(e,t,n,r,o,s,i,a,c,f){let d=[],l=!1,u=await U(e,"CHERRY_PICK_HEAD"),m=await U(e,"REVERT_HEAD"),h=await U(e,"MERGE_HEAD"),p=!u&&!h,w=await Mt(e)?await ht(e):null;if(n&&w){let P=z(w.onto);d.push(`interactive rebase in progress; onto ${P}`)}else if(n){let P=await Ur(e);if(P){let y=t===P?"at":"from";d.push(`HEAD detached ${y} ${z(P)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let P=await le(e),y=await dn(e,P,r);if(y){let I=Vn(y,{abbreviated:f?.fromCommit});for(let O of I.trimEnd().split(`
97
- `))d.push(O);l=!0}}if(l&&(w||u||m||h)&&d.push(""),w&&h)sc(d,w),d.push(""),a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0;else if(w){let P=$t(o),y=await e.fs.exists(T(e.gitDir,"MERGE_MSG"));sc(d,w);let O=w.headName==="detached HEAD"?null:be(w.headName),j=z(w.onto),G=O?` branch '${O}' on '${j}'`:"";if(P)d.push(`You are currently rebasing${G}.`),d.push(' (fix conflicts and then run "git rebase --continue")'),d.push(' (use "git rebase --skip" to skip this patch)'),d.push(' (use "git rebase --abort" to check out the original branch)');else if(y)d.push(`You are currently rebasing${G}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let V=G?`You are currently editing a commit while rebasing${G}.`:"You are currently editing a commit during a rebase.";d.push(V),d.push(' (use "git commit --amend" to amend the current commit)'),d.push(' (use "git rebase --continue" once you are satisfied with your changes)')}l=!0}else u?(d.push(`You are currently cherry-picking commit ${z(u)}.`),a.length>0?d.push(' (fix conflicts and run "git cherry-pick --continue")'):d.push(' (all conflicts fixed: run "git cherry-pick --continue")'),d.push(' (use "git cherry-pick --skip" to skip this patch)'),d.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),l=!0):m?(d.push(`You are currently reverting commit ${z(m)}.`),a.length>0?d.push(' (fix conflicts and run "git revert --continue")'):d.push(' (all conflicts fixed: run "git revert --continue")'),d.push(' (use "git revert --skip" to skip this patch)'),d.push(' (use "git revert --abort" to cancel the revert operation)'),l=!0):h&&(a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0);if(await Et(e)){let y=(await ke(e,"BISECT_START"))?.trim()??"";d.push(`You are currently bisecting, started from branch '${y}'.`),d.push(' (use "git bisect reset" to get back to the original branch)'),l=!0}let E=f?.isInitial??!t;E&&(d.push(""),d.push(f?.fromCommit?"Initial commit":"No commits yet"),l=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(P=>P.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',R=!1;if(s.length>0){l&&d.push(""),d.push("Changes to be committed:"),x&&d.push(x);for(let P of s)d.push(` ${oc(P.status,P.path,P.displayPath)}`);d.push(""),R=!0}if(a.length>0){!R&&l&&d.push(""),d.push("Unmerged paths:"),p&&(t?d.push(' (use "git restore --staged <file>..." to unstage)'):d.push(' (use "git rm --cached <file>..." to unstage)')),a.some(y=>y.status==="deleted by us"||y.status==="deleted by them"||y.status==="both deleted")?d.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):d.push(' (use "git add <file>..." to mark resolution)');for(let y of a)d.push(` ${Nl(y.status,y.path)}`);d.push(""),R=!0}if(i.length>0){!R&&l&&d.push(""),d.push("Changes not staged for commit:"),d.push(k),d.push(' (use "git restore <file>..." to discard changes in working directory)');for(let P of i)d.push(` ${oc(P.status,P.path)}`);d.push(""),R=!0}if(c.length>0){!R&&l&&d.push(""),d.push("Untracked files:"),d.push(' (use "git add <file>..." to include in what will be committed)');for(let P of c)d.push(` ${P}`);d.push(""),R=!0}let C=s.length>0||!!h&&a.length===0;return!R&&l&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!R&&l&&i.length===0&&a.length===0&&c.length===0&&d.push(""),i.length>0||a.length>0?d.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?d.push('nothing added to commit but untracked files present (use "git add" to track)'):E?d.push('nothing to commit (create/copy files and use "git add" to track)'):d.push("nothing to commit, working tree clean")),`${d.join(`
96
+ `}async function nc(e,t,n){let r=new Map,[o,s]=await Promise.all([Qa(e,t,r),Qa(e,n,r)]),i=new Set;for(let c of s)o.has(c)||i.add(c);let a=new Set;for(let c of o)s.has(c)||a.add(c);return{right:await ec(e,r,n,i),left:await ec(e,r,t,a)}}async function Qa(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await js(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function ec(e,t,n,r){if(r.size===0)return[];let o=new Map;for(let f of r)o.set(f,0);for(let f of r){let d=await js(e,f,t);for(let l of d.commit.parents)r.has(l)&&o.set(l,(o.get(l)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await js(e,f,t));s.sort((f,d)=>f.commit.committer.timestamp-d.commit.committer.timestamp);let i=s.map(f=>f.hash),a=[],c=new Set;for(;i.length>0;){let f=i.pop();if(!f||c.has(f))continue;c.add(f);let d=await js(e,f,t);d.commit.parents.length<=1&&a.push(d);for(let l of d.commit.parents)if(r.has(l)&&!c.has(l)){let u=(o.get(l)??0)-1;o.set(l,u),u<=0&&i.push(l)}}return a.reverse(),a}async function js(e,t,n){let r=n.get(t);if(r)return r;let o=await we(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Yt(o.content)};return n.set(t,s),s}ue();ie();function dr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Al(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=dr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&dr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Dl=50;async function nt(e,t,n=Dl){let r=new Map,o=[],s=[],i=[];for(let d of t)if(d.status==="deleted"&&d.oldHash){let l=r.get(d.oldHash)??[];l.push(d),r.set(d.oldHash,l),o.push(d)}else d.status==="added"&&d.newHash?s.push(d):i.push(d);let a=[],c=[];for(let d of s){let l=d.newHash;if(!l){c.push(d);continue}let u=r.get(l);if(u&&u.length>0){let m=Al(u,d.path);m&&a.push({oldPath:m.path,newPath:d.path,oldHash:m.oldHash??l,newHash:l,similarity:100,oldMode:m.oldMode,newMode:d.newMode})}else c.push(d)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let d=await Ml(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}if(f.length>0&&c.length>0){let d=await Ll(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}return{remaining:[...i,...f,...c],renames:a}}async function Ml(e,t,n,r){let o=new Map;for(let a=0;a<t.length;a++){let c=t[a];if(!c)continue;let f=dr(c.path);o.has(f)?o.set(f,-1):o.set(f,a)}let s=new Map;for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let f=dr(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let d=t[c],l=n[f];if(!d?.oldHash||!l?.newHash||d.oldHash===l.newHash)continue;let u=await yt(e,d.oldHash),m=await yt(e,l.newHash),h=Gl(u,m);h<r||i.push({oldPath:d.path,newPath:l.path,oldHash:d.oldHash,newHash:l.newHash,similarity:h,oldMode:d.oldMode,newMode:l.newMode})}return i}var rc=107927;function Ns(e){let t=new Map,n=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let f=(r+Math.imul(o,97))%rc;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%rc;t.set(i,(t.get(i)??0)+n)}let s=[];for(let[i,a]of t)s.push({hash:i,count:a});return s.sort((i,a)=>i.hash-a.hash),s}function jl(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let i=e[o];if(!i)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=i.hash)break;r+=f.count,s++}let a=i.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===i.hash&&(c=f.count,s++)}a<c?(r+=c-a,n+=a):n+=c,o++}for(;s<t.length;){let i=t[s];i&&(r+=i.count),s++}return{srcCopied:n,literalAdded:r}}function Gl(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:sc(e.length,Ns(e),t.length,Ns(t))}function sc(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=jl(t,r);return Math.floor(i*100/o)}async function Ll(e,t,n,r){let o=[];for(let d of t)if(d.oldHash){let l=await yt(e,d.oldHash);o.push({size:l.length,chunks:Ns(l)})}else o.push(null);let s=[];for(let d of n)if(d.newHash){let l=await yt(e,d.newHash);s.push({size:l.length,chunks:Ns(l)})}else s.push(null);let i=[];for(let d=0;d<t.length;d++){let l=t[d],u=o[d];if(!(!l||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=sc(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=dr(l.path)===dr(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}i.sort((d,l)=>l.similarity-d.similarity||l.nameScore-d.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:l,addIdx:u}of i){if(a.has(l)||c.has(u))continue;a.add(l),c.add(u);let m=t[l],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:d,oldMode:m.oldMode,newMode:h.newMode})}return f}function On(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let d=Math.max(0,n-o-a),l=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+d),p=t.slice(o,o+l);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Se();tt();async function rt(e,t){let n=await Z(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=be(n.target):(s=!0,o="HEAD detached");let i=t?.index??await K(e),a=Qo(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await Jo(e,c,i,a),l=await Tt(e,i),u=[],m=[];for(let g of l)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>xe(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=ei(m,h);return Nl(e,r,s,o,i,d,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function oc(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Nl(e,t,n,r,o,s,i,a,c,f){let d=[],l=!1,u=await U(e,"CHERRY_PICK_HEAD"),m=await U(e,"REVERT_HEAD"),h=await U(e,"MERGE_HEAD"),p=!u&&!h,w=await Mt(e)?await ht(e):null;if(n&&w){let P=z(w.onto);d.push(`interactive rebase in progress; onto ${P}`)}else if(n){let P=await Ur(e);if(P){let y=t===P?"at":"from";d.push(`HEAD detached ${y} ${z(P)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let P=await le(e),y=await dn(e,P,r);if(y){let I=Vn(y,{abbreviated:f?.fromCommit});for(let O of I.trimEnd().split(`
97
+ `))d.push(O);l=!0}}if(l&&(w||u||m||h)&&d.push(""),w&&h)oc(d,w),d.push(""),a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0;else if(w){let P=$t(o),y=await e.fs.exists(T(e.gitDir,"MERGE_MSG"));oc(d,w);let O=w.headName==="detached HEAD"?null:be(w.headName),j=z(w.onto),G=O?` branch '${O}' on '${j}'`:"";if(P)d.push(`You are currently rebasing${G}.`),d.push(' (fix conflicts and then run "git rebase --continue")'),d.push(' (use "git rebase --skip" to skip this patch)'),d.push(' (use "git rebase --abort" to check out the original branch)');else if(y)d.push(`You are currently rebasing${G}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let V=G?`You are currently editing a commit while rebasing${G}.`:"You are currently editing a commit during a rebase.";d.push(V),d.push(' (use "git commit --amend" to amend the current commit)'),d.push(' (use "git rebase --continue" once you are satisfied with your changes)')}l=!0}else u?(d.push(`You are currently cherry-picking commit ${z(u)}.`),a.length>0?d.push(' (fix conflicts and run "git cherry-pick --continue")'):d.push(' (all conflicts fixed: run "git cherry-pick --continue")'),d.push(' (use "git cherry-pick --skip" to skip this patch)'),d.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),l=!0):m?(d.push(`You are currently reverting commit ${z(m)}.`),a.length>0?d.push(' (fix conflicts and run "git revert --continue")'):d.push(' (all conflicts fixed: run "git revert --continue")'),d.push(' (use "git revert --skip" to skip this patch)'),d.push(' (use "git revert --abort" to cancel the revert operation)'),l=!0):h&&(a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0);if(await Et(e)){let y=(await ke(e,"BISECT_START"))?.trim()??"";d.push(`You are currently bisecting, started from branch '${y}'.`),d.push(' (use "git bisect reset" to get back to the original branch)'),l=!0}let E=f?.isInitial??!t;E&&(d.push(""),d.push(f?.fromCommit?"Initial commit":"No commits yet"),l=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(P=>P.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',R=!1;if(s.length>0){l&&d.push(""),d.push("Changes to be committed:"),x&&d.push(x);for(let P of s)d.push(` ${ic(P.status,P.path,P.displayPath)}`);d.push(""),R=!0}if(a.length>0){!R&&l&&d.push(""),d.push("Unmerged paths:"),p&&(t?d.push(' (use "git restore --staged <file>..." to unstage)'):d.push(' (use "git rm --cached <file>..." to unstage)')),a.some(y=>y.status==="deleted by us"||y.status==="deleted by them"||y.status==="both deleted")?d.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):d.push(' (use "git add <file>..." to mark resolution)');for(let y of a)d.push(` ${_l(y.status,y.path)}`);d.push(""),R=!0}if(i.length>0){!R&&l&&d.push(""),d.push("Changes not staged for commit:"),d.push(k),d.push(' (use "git restore <file>..." to discard changes in working directory)');for(let P of i)d.push(` ${ic(P.status,P.path)}`);d.push(""),R=!0}if(c.length>0){!R&&l&&d.push(""),d.push("Untracked files:"),d.push(' (use "git add <file>..." to include in what will be committed)');for(let P of c)d.push(` ${P}`);d.push(""),R=!0}let C=s.length>0||!!h&&a.length===0;return!R&&l&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!R&&l&&i.length===0&&a.length===0&&c.length===0&&d.push(""),i.length>0||a.length>0?d.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?d.push('nothing added to commit but untracked files present (use "git add" to track)'):E?d.push('nothing to commit (create/copy files and use "git add" to track)'):d.push("nothing to commit, working tree clean")),`${d.join(`
98
98
  `)}
99
- `}async function Zo(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await M(e,t)).tree);let i=await ce(e,s),a=new Map(Ae(n).map(m=>[m.path,m])),c=[];for(let[m,h]of a){if(o.has(m))continue;let p=i.get(m);p?p.hash!==h.hash&&c.push({path:m,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:m,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[m,h]of i)o.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await nt(e,c),l={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let m of f){let h=l[m.status];h&&u.push({path:m.path,status:h})}for(let m of d)u.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return u.sort((m,h)=>xe(m.path,h.path))}function Jo(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>xe(r.path,o.path))}function Qo(e,t){if(e.length===0)return[];let n=new Set;for(let o of t){let s=o.indexOf("/");for(;s!==-1;)n.add(o.slice(0,s+1)),s=o.indexOf("/",s+1)}let r=new Set;for(let o of e){let s=o.split("/");if(s.length===1){r.add(o);continue}let i=!1;for(let a=1;a<s.length;a++){let c=`${s.slice(0,a).join("/")}/`;if(!n.has(c)){r.add(c),i=!0;break}}i||r.add(o)}return[...r].sort()}function oc(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Nl(e,t){return`${e}:`.padEnd(17)+t}async function dn(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await U(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await U(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:d,behind:l}=await Ko(e,f,c);return{upstream:a,ahead:d,behind:l,gone:!1}}function ic(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function Vn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
99
+ `}async function Jo(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await M(e,t)).tree);let i=await ce(e,s),a=new Map(Ae(n).map(m=>[m.path,m])),c=[];for(let[m,h]of a){if(o.has(m))continue;let p=i.get(m);p?p.hash!==h.hash&&c.push({path:m,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:m,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[m,h]of i)o.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await nt(e,c),l={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let m of f){let h=l[m.status];h&&u.push({path:m.path,status:h})}for(let m of d)u.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return u.sort((m,h)=>xe(m.path,h.path))}function Qo(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>xe(r.path,o.path))}function ei(e,t){if(e.length===0)return[];let n=new Set;for(let o of t){let s=o.indexOf("/");for(;s!==-1;)n.add(o.slice(0,s+1)),s=o.indexOf("/",s+1)}let r=new Set;for(let o of e){let s=o.split("/");if(s.length===1){r.add(o);continue}let i=!1;for(let a=1;a<s.length;a++){let c=`${s.slice(0,a).join("/")}/`;if(!n.has(c)){r.add(c),i=!0;break}}i||r.add(o)}return[...r].sort()}function ic(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function _l(e,t){return`${e}:`.padEnd(17)+t}async function dn(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await U(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await U(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:d,behind:l}=await zo(e,f,c);return{upstream:a,ahead:d,behind:l,gone:!1}}function ac(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function Vn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
100
100
  (use "git branch --unset-upstream" to fixup)
101
101
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
102
102
  `;if(e.ahead>0&&e.behind===0){let r=e.ahead===1?"commit":"commits";return`Your branch is ahead of '${e.upstream}' by ${e.ahead} ${r}.
@@ -108,17 +108,17 @@ and have ${e.ahead} and ${e.behind} different commits each, respectively.
108
108
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
109
109
  `}Se();Qt();tt();async function _s(e){let t=await Xe(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await U(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function ln(e){let t="";return await U(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
110
110
  `),await U(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
111
- `),await zn(e),t}function _l(e){let t=new Set,n=[];for(let r of e.entries)r.stage>0&&!t.has(r.path)&&(t.add(r.path),n.push(`${r.path}: needs merge`));return n.sort(),n.length>0?`${n.join(`
111
+ `),await zn(e),t}function Fl(e){let t=new Set,n=[];for(let r of e.entries)r.stage>0&&!t.has(r.path)&&(t.add(r.path),n.push(`${r.path}: needs merge`));return n.sort(),n.length>0?`${n.join(`
112
112
  `)}
113
- `:""}function $n(e){return e.entries.some(t=>t.stage>0)?{stdout:_l(e),stderr:`error: you need to resolve your current index first
114
- `,exitCode:1}:null}async function Fs(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");if(r)return Fl(e,t,n,r);let o=await K(e),s=t.map(a=>Ge(a,n)),i=o.entries.filter(a=>a.stage===0&&ye(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&ye(s,c.path))?_(`error: path '${t[0]}' is unmerged
113
+ `:""}function $n(e){return e.entries.some(t=>t.stage>0)?{stdout:Fl(e),stderr:`error: you need to resolve your current index first
114
+ `,exitCode:1}:null}async function Fs(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");if(r)return Ul(e,t,n,r);let o=await K(e),s=t.map(a=>Ge(a,n)),i=o.entries.filter(a=>a.stage===0&&ye(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&ye(s,c.path))?_(`error: path '${t[0]}' is unmerged
115
115
  `):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
116
- `);for(let a of i)await it(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Fl(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(c=>Ge(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
116
+ `);for(let a of i)await it(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Ul(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(c=>Ge(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
117
117
  `);for(let c of a){let f=o.get(c);f&&(await it(e,{path:f.path,hash:f.hash,mode:f.mode}),s=wt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Ce()}))}return await se(e,s),{stdout:"",stderr:"",exitCode:0}}async function Us(e,t,n,r,o){if(!e.workTree)return $("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await K(e),a=t.map(f=>Ge(f,n)),c=new Set;for(let f of i.entries)ye(a,f.path)&&c.add(f.path);if(c.size===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
118
118
  `);for(let f of c){let d=i.entries.find(m=>m.path===f&&m.stage===r),l=!d&&i.entries.find(m=>m.path===f&&m.stage===0),u=d||l;if(u)await it(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let m=T(e.workTree,f);await e.fs.exists(m)&&await e.fs.rm(m)}else if(i.entries.some(h=>h.path===f&&h.stage>0))return _(`error: path '${f}' does not have ${r===2?"our":"their"} version
119
119
  `)}return{stdout:"",stderr:"",exitCode:0}}async function Yn(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=T(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let l=await e.fs.readFileBuffer(f);i.set(c,await bt("blob",l))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let d=s.get(c);if(d===void 0){a.push(`D ${c}`);continue}let l=i.get(c);l===null?a.push(`D ${c}`):(d!==f||l!==void 0&&l!==f)&&a.push(`M ${c}`)}for(let[c]of s)o.has(c)||i.get(c)!=null&&a.push(`A ${c}`);return a.length===0?"":(a.sort((c,f)=>{let d=c.slice(2),l=f.slice(2);return d<l?-1:d>l?1:0}),`${a.join(`
120
120
  `)}
121
- `)}var ac=5;function Ul(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>ac?ac-1:t,i=e.slice(0,o).map(c=>` ${z(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
121
+ `)}var cc=5;function Bl(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>cc?cc-1:t,i=e.slice(0,o).map(c=>` ${z(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
122
122
  any of your branches:
123
123
 
124
124
  ${i.join(`
@@ -129,10 +129,10 @@ to do so with:
129
129
 
130
130
  git branch <new-branch-name> ${z(e[0].hash)}
131
131
 
132
- `}async function ei(e,t){let n=await M(e,t);return`Previous HEAD position was ${z(t)} ${ae(n.message)}
133
- `}async function Bs(e,t,n){let r=await zo(e,t,{targetHash:n});return r.length>0?Ul(r):t!==n?ei(e,t):""}async function lr(e,t,n,r,o,s){let i=await Z(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
132
+ `}async function ti(e,t){let n=await M(e,t);return`Previous HEAD position was ${z(t)} ${ae(n.message)}
133
+ `}async function Bs(e,t,n){let r=await Vo(e,t,{targetHash:n});return r.length>0?Bl(r):t!==n?ti(e,t):""}async function lr(e,t,n,r,o,s){let i=await Z(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
134
134
  `,exitCode:0};let a=await K(e),c=$n(a);if(c)return c;let f=await X(e),l=(await M(e,r)).tree,u=null;if(f&&(u=(await M(e,f)).tree),u!==l){let x=await Cn(e,u,l,a);if(!x.success)return x.errorOutput??_("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await se(e,a),await He(e,x.worktreeOps)}let m="";i?.type==="direct"&&f&&(m=await Bs(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??J;await Ue(e,"HEAD",n),await mt(e);let p=await ln(e);await ne(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await Yn(e,l,a),w=await le(e),E=await dn(e,w,t);return E&&(g+=Vn(E)),{stdout:g,stderr:`${m}Switched to branch '${t}'
135
- ${p}`,exitCode:0}}async function Tn(e,t,n,r,o){let s=await K(e),i=$n(s);if(i)return i;let a=await X(e),c=await M(e,t),f=c.tree,d=null;if(a&&(d=(await M(e,a)).tree),d!==f){let x=await Cn(e,d,f,s);if(!x.success)return x.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await se(e,s),await He(e,x.worktreeOps)}let l=await Z(e),u=l?.type==="direct"&&a===t;if(await Y(e,"HEAD",t),!u){await Ka(e,t);let x=l?.type==="symbolic"?l.target.replace(/^refs\/heads\//,""):a??J;await ne(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let m=await ln(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=z(t),p=ae(c.message),g=l?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Bs(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
135
+ ${p}`,exitCode:0}}async function Tn(e,t,n,r,o){let s=await K(e),i=$n(s);if(i)return i;let a=await X(e),c=await M(e,t),f=c.tree,d=null;if(a&&(d=(await M(e,a)).tree),d!==f){let x=await Cn(e,d,f,s);if(!x.success)return x.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await se(e,s),await He(e,x.worktreeOps)}let l=await Z(e),u=l?.type==="direct"&&a===t;if(await Y(e,"HEAD",t),!u){await za(e,t);let x=l?.type==="symbolic"?l.target.replace(/^refs\/heads\//,""):a??J;await ne(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let m=await ln(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=z(t),p=ae(c.message),g=l?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Bs(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
136
136
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
137
137
 
138
138
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -151,62 +151,62 @@ Or undo this operation with:
151
151
  Turn off this advice by setting config variable advice.detachedHead to false
152
152
 
153
153
  HEAD is now at ${h} ${p}
154
- `,w+=m,{stdout:await Yn(e,f,s),stderr:w,exitCode:0}}ie();de();ue();on();var cc=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),qr={stdout:`You need to start by "git bisect start"
155
- `,stderr:"",exitCode:1};async function ti(e){let t=await ke(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||$("no current commit")}function fc(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[W.string().name("subcommand").describe("Subcommand or custom term").optional(),W.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
156
- `,exitCode:1};let i=r.rest??[],a=await B(o.fs,o.cwd,t);return v(a)?a:Kl(a,o.env,t,s,i)}});Bl(n,t),Wl(n,t),zl(n,t),Vl(n,t),Xl(n,t),Zl(n,t),Ql(n,t),tu(n,t),nu(n,t)}function Bl(e,t){e.command("start",{description:"Start bisecting",args:[W.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":te.string().describe("Alternate term for new/bad"),"term-bad":te.string().describe("Alternate term for new/bad"),"term-old":te.string().describe("Alternate term for old/good"),"term-good":te.string().describe("Alternate term for old/good"),"no-checkout":S().describe("Do not checkout the bisection commit"),"first-parent":S().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return cc.has(a)?$(`'${a}' is not a valid term`):cc.has(c)?$(`'${c}' is not a valid term`):a===c?$("'bad' and 'good' terms must be different"):dc(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function dc(e,t,n,r,o,s,i,a){await Et(e)&&await Ms(e);let c=await Z(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await Oe(e,"BISECT_START",f+`
154
+ `,w+=m,{stdout:await Yn(e,f,s),stderr:w,exitCode:0}}ie();de();ue();on();var fc=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),qr={stdout:`You need to start by "git bisect start"
155
+ `,stderr:"",exitCode:1};async function ni(e){let t=await ke(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||$("no current commit")}function dc(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[W.string().name("subcommand").describe("Subcommand or custom term").optional(),W.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
156
+ `,exitCode:1};let i=r.rest??[],a=await B(o.fs,o.cwd,t);return v(a)?a:zl(a,o.env,t,s,i)}});Wl(n,t),ql(n,t),Vl(n,t),Yl(n,t),Zl(n,t),Jl(n,t),eu(n,t),nu(n,t),ru(n,t)}function Wl(e,t){e.command("start",{description:"Start bisecting",args:[W.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":te.string().describe("Alternate term for new/bad"),"term-bad":te.string().describe("Alternate term for new/bad"),"term-old":te.string().describe("Alternate term for old/good"),"term-good":te.string().describe("Alternate term for old/good"),"no-checkout":S().describe("Do not checkout the bisection commit"),"first-parent":S().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return fc.has(a)?$(`'${a}' is not a valid term`):fc.has(c)?$(`'${c}' is not a valid term`):a===c?$("'bad' and 'good' terms must be different"):lc(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function lc(e,t,n,r,o,s,i,a){await Et(e)&&await Ms(e);let c=await Z(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await Oe(e,"BISECT_START",f+`
157
157
  `),await Oe(e,"BISECT_TERMS",`${o}
158
158
  ${s}
159
159
  `),await Oe(e,"BISECT_NAMES",`
160
- `),a&&await Oe(e,"BISECT_FIRST_PARENT",""),i){let u=await X(e);u&&await Oe(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await St(e,u);if(v(m))return m;await Y(e,`refs/bisect/${o}`,m);let h=await M(e,m);await kt(e,`# ${o}: [${m}] ${ae(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await St(e,g);if(v(w))return w;await Y(e,`refs/bisect/${s}-${w}`,w);let E=await M(e,w);await kt(e,`# ${s}: [${w}] ${ae(E.message)}`)}}let d=r.map(u=>`'${u}'`),l=d.length>0?` ${d.join(" ")}`:"";return await kt(e,`git bisect start${l}`),Kr(e,t,n)}function Wl(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[W.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);return v(s)?s:ql(s,o.env,t,n,r.rev)}})}async function ql(e,t,n,r,o){if(!await Et(e))return qr;let s=await Br(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return Wr(e,t,n,i,s,o)}async function Kl(e,t,n,r,o){if(!await Et(e))return qr;let s=await Br(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
161
- `,exitCode:1}:Wr(e,t,n,r,s,o[0])}async function Wr(e,t,n,r,o,s){let i;if(s){let f=await St(e,s);if(v(f))return f;i=f}else{let f=await ti(e);if(v(f))return f;i=f}let a=await M(e,i),c=ae(a.message);return r===o.termBad?await Y(e,`refs/bisect/${o.termBad}`,i):await Y(e,`refs/bisect/${o.termGood}-${i}`,i),await kt(e,`# ${r}: [${i}] ${c}`),await kt(e,`git bisect ${r} ${i}`),Kr(e,t,n)}function zl(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[W.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return qr;let i=n.revs??[];if(i.length===0){let a=await ti(s);if(v(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let d=await St(s,a);if(v(d))return d;c=d}await Y(s,`refs/bisect/skip-${c}`,c);let f=await M(s,c);await kt(s,`# skip: [${c}] ${ae(f.message)}`),await kt(s,`git bisect skip ${c}`)}return Kr(s,r.env,t)}})}function Vl(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[W.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;return await Et(s)?Yl(s,r.env,t,n.commit):{stdout:`We are not bisecting.
162
- `,stderr:"",exitCode:0}}})}async function Yl(e,t,n,r){let o=(await ke(e,"BISECT_START"))?.trim()??"";if(await Ms(e),r){let s=await St(e,r);return v(s)?s:Tn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await U(e,s);if(i)return lr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Tn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Xl(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;return await Et(s)?{stdout:await ke(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
163
- `,exitCode:1}}})}function Zl(e,t){e.command("replay",{description:"Replay a bisect log",args:[W.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:T(r.cwd,n.logfile);if(!await r.fs.exists(i))return $(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Jl(s,r.env,t,a)}})}async function Jl(e,t,n,r){await Et(e)&&await Ms(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
164
- `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],d=c[2].trim(),l;if(f==="start"){let u=d?d.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];l=await dc(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")l=await Wr(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")l=await Wr(e,t,n,"good",o,d||void 0);else if(f==="skip"){for(let u of d?d.split(/\s+/):[]){await Y(e,`refs/bisect/skip-${u}`,u);let m=await M(e,u);await kt(e,`# skip: [${u}] ${ae(m.message)}`),await kt(e,`git bisect skip ${u}`)}l=await Kr(e,t,n)}else continue;if(l.exitCode!==0)return l;s+=l.stdout}return{stdout:s,stderr:"",exitCode:0}}function Ql(e,t){e.command("run",{description:"Bisect by running a command",args:[W.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return qr;if(!r.exec)return $("bisect run requires shell execution support");let i=n.cmd.join(" ");return eu(s,r.env,t,i,r.exec,r.cwd)}})}async function eu(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
165
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await ti(e);if(v(u))return u;await Y(e,`refs/bisect/skip-${u}`,u);let m=await M(e,u);await kt(e,`# skip: [${u}] ${ae(m.message)}`),await kt(e,`git bisect skip ${u}`);let h=await Kr(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
160
+ `),a&&await Oe(e,"BISECT_FIRST_PARENT",""),i){let u=await X(e);u&&await Oe(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await St(e,u);if(v(m))return m;await Y(e,`refs/bisect/${o}`,m);let h=await M(e,m);await kt(e,`# ${o}: [${m}] ${ae(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await St(e,g);if(v(w))return w;await Y(e,`refs/bisect/${s}-${w}`,w);let E=await M(e,w);await kt(e,`# ${s}: [${w}] ${ae(E.message)}`)}}let d=r.map(u=>`'${u}'`),l=d.length>0?` ${d.join(" ")}`:"";return await kt(e,`git bisect start${l}`),Kr(e,t,n)}function ql(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[W.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);return v(s)?s:Kl(s,o.env,t,n,r.rev)}})}async function Kl(e,t,n,r,o){if(!await Et(e))return qr;let s=await Br(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return Wr(e,t,n,i,s,o)}async function zl(e,t,n,r,o){if(!await Et(e))return qr;let s=await Br(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
161
+ `,exitCode:1}:Wr(e,t,n,r,s,o[0])}async function Wr(e,t,n,r,o,s){let i;if(s){let f=await St(e,s);if(v(f))return f;i=f}else{let f=await ni(e);if(v(f))return f;i=f}let a=await M(e,i),c=ae(a.message);return r===o.termBad?await Y(e,`refs/bisect/${o.termBad}`,i):await Y(e,`refs/bisect/${o.termGood}-${i}`,i),await kt(e,`# ${r}: [${i}] ${c}`),await kt(e,`git bisect ${r} ${i}`),Kr(e,t,n)}function Vl(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[W.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return qr;let i=n.revs??[];if(i.length===0){let a=await ni(s);if(v(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let d=await St(s,a);if(v(d))return d;c=d}await Y(s,`refs/bisect/skip-${c}`,c);let f=await M(s,c);await kt(s,`# skip: [${c}] ${ae(f.message)}`),await kt(s,`git bisect skip ${c}`)}return Kr(s,r.env,t)}})}function Yl(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[W.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;return await Et(s)?Xl(s,r.env,t,n.commit):{stdout:`We are not bisecting.
162
+ `,stderr:"",exitCode:0}}})}async function Xl(e,t,n,r){let o=(await ke(e,"BISECT_START"))?.trim()??"";if(await Ms(e),r){let s=await St(e,r);return v(s)?s:Tn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await U(e,s);if(i)return lr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Tn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Zl(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;return await Et(s)?{stdout:await ke(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
163
+ `,exitCode:1}}})}function Jl(e,t){e.command("replay",{description:"Replay a bisect log",args:[W.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:T(r.cwd,n.logfile);if(!await r.fs.exists(i))return $(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Ql(s,r.env,t,a)}})}async function Ql(e,t,n,r){await Et(e)&&await Ms(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
164
+ `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],d=c[2].trim(),l;if(f==="start"){let u=d?d.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];l=await lc(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")l=await Wr(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")l=await Wr(e,t,n,"good",o,d||void 0);else if(f==="skip"){for(let u of d?d.split(/\s+/):[]){await Y(e,`refs/bisect/skip-${u}`,u);let m=await M(e,u);await kt(e,`# skip: [${u}] ${ae(m.message)}`),await kt(e,`git bisect skip ${u}`)}l=await Kr(e,t,n)}else continue;if(l.exitCode!==0)return l;s+=l.stdout}return{stdout:s,stderr:"",exitCode:0}}function eu(e,t){e.command("run",{description:"Bisect by running a command",args:[W.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return qr;if(!r.exec)return $("bisect run requires shell execution support");let i=n.cmd.join(" ");return tu(s,r.env,t,i,r.exec,r.cwd)}})}async function tu(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
165
+ `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await ni(e);if(v(u))return u;await Y(e,`refs/bisect/skip-${u}`,u);let m=await M(e,u);await kt(e,`# skip: [${u}] ${ae(m.message)}`),await kt(e,`git bisect skip ${u}`);let h=await Kr(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
166
166
  `,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Ds(e),d=c===0?f.termGood:f.termBad,l=await Wr(e,t,n,d,f,void 0);if(i+=l.stdout,l.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
167
- `,{stdout:i,stderr:"",exitCode:0};if(l.exitCode!==0)return{stdout:i,stderr:l.stderr,exitCode:l.exitCode}}}function tu(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":S().describe("Show the term for the old state"),"term-bad":S().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return{stdout:"",stderr:`error: no terms defined
167
+ `,{stdout:i,stderr:"",exitCode:0};if(l.exitCode!==0)return{stdout:i,stderr:l.stderr,exitCode:l.exitCode}}}function nu(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":S().describe("Show the term for the old state"),"term-bad":S().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!await Et(s))return{stdout:"",stderr:`error: no terms defined
168
168
  `,exitCode:1};let{termBad:i,termGood:a}=await Br(s);return n["term-good"]?{stdout:`${a}
169
169
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
170
170
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
171
171
  and ${i} for the new state.
172
- `,stderr:"",exitCode:0}}})}function nu(e,t){for(let n of["visualize","view"])e.command(n,{description:"Show remaining suspects in git log",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=s;if(!await Et(i))return qr;let a=await Ds(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
173
- `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(Kn(),qa)),f="";for await(let d of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${z(d.hash)} ${ae(d.commit.message)}
174
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function Kr(e,t,n){let r=await Ds(e);return!r.badHash||r.goodHashes.length===0?{stdout:Va(r),stderr:"",exitCode:0}:(await Oe(e,"BISECT_ANCESTORS_OK",""),ru(e,t,n,r))}async function ru(e,t,n,r){let o=await za(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
175
- `,exitCode:1};if(o.found){let s=await Xa(e,o.hash);return await kt(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
172
+ `,stderr:"",exitCode:0}}})}function ru(e,t){for(let n of["visualize","view"])e.command(n,{description:"Show remaining suspects in git log",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=s;if(!await Et(i))return qr;let a=await Ds(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
173
+ `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(Kn(),Ka)),f="";for await(let d of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${z(d.hash)} ${ae(d.commit.message)}
174
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function Kr(e,t,n){let r=await Ds(e);return!r.badHash||r.goodHashes.length===0?{stdout:Ya(r),stderr:"",exitCode:0}:(await Oe(e,"BISECT_ANCESTORS_OK",""),su(e,t,n,r))}async function su(e,t,n,r){let o=await Va(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
175
+ `,exitCode:1};if(o.found){let s=await Za(e,o.hash);return await kt(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
176
176
  The first bad commit could be any of:
177
177
  `;for(let i of r.skipHashes)s+=i+`
178
178
  `;return r.badHash&&(s+=r.badHash+`
179
179
  `),s+=`We cannot bisect more!
180
180
  `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Oe(e,"BISECT_HEAD",o.hash);else{let s=await Tn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Oe(e,"BISECT_EXPECTED_REV",o.hash+`
181
- `),{stdout:Ya(o),stderr:"",exitCode:0}}re();ie();function jt(e){if(e.length===0)return[];let t=e.split(`
181
+ `),{stdout:Xa(o),stderr:"",exitCode:0}}re();ie();function jt(e){if(e.length===0)return[];let t=e.split(`
182
182
  `);return t[t.length-1]===""&&t.pop(),t}function qt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
183
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var su=4,lc=1024,Ws=100,zs=0,qs=1,ur=2;function ri(e){let t=1;for(;t*t<e;)t++;return t}function ou(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let i=0;i<e.length;i++){let a=e[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,o[i]=c}for(let i=0;i<t.length;i++){let a=t[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,s[i]=c}return{classes1:o,classes2:s,classInfo:r}}function iu(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let i=o,a=0,c=s-i;for(;a<c&&e[t-1-a]===n[r-1-a];)a++;return{dstart:i,dend1:t-a-1,dend2:r-a-1}}function uc(e,t,n,r){t-n>Ws&&(n=t-Ws),r-t>Ws&&(r=t+Ws);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===zs)o++;else if(f===ur)s++;else break}if(o===0)return!1;let i=0,a=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===zs)i++;else if(f===ur)a++;else break}return i===0?!1:(i+=o,a+=s,a*su<a+i)}function au(e,t,n,r,o,s,i,a,c,f){let d=new Uint8Array(t),l=new Uint8Array(r),u=Math.min(ri(t),lc);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?d[g]=zs:w>=u?d[g]=ur:d[g]=qs}let m=Math.min(ri(r),lc);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?l[g]=zs:w>=m?l[g]=ur:l[g]=qs}let h=[];for(let g=s;g<=i;g++)d[g]===qs||d[g]===ur&&!uc(d,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)l[g]===qs||l[g]===ur&&!uc(l,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Sn=20,mc=4,cu=256,fu=256,Ks=2147483647;function pt(e,t){return e[t]??0}function du(e,t,n,r,o,s,i,a,c,f){let d=t-s,l=n-o,u=t-o,m=n-s,h=u-m&1,p=u,g=u,w=m,E=m;i[u]=t,a[m]=n;for(let x=1;;x++){let b=!1;p>d?i[--p-1]=-1:++p,g<l?i[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let R;pt(i,k-1)>=pt(i,k+1)?R=pt(i,k-1)+1:R=pt(i,k+1);let C=R,P=R-k;for(;R<n&&P<s&&e[R]===r[P];)R++,P++;if(R-C>Sn&&(b=!0),i[k]=R,h&&w<=k&&k<=E&&pt(a,k)<=R)return{i1:R,i2:P,minLo:!0,minHi:!0}}w>d?a[--w-1]=Ks:++w,E<l?a[++E+1]=Ks:--E;for(let k=E;k>=w;k-=2){let R;pt(a,k-1)<pt(a,k+1)?R=pt(a,k-1):R=pt(a,k+1)-1;let C=R,P=R-k;for(;R>t&&P>o&&e[R-1]===r[P-1];)R--,P--;if(C-R>Sn&&(b=!0),a[k]=R,!h&&p<=k&&k<=g&&R<=pt(i,k))return{i1:R,i2:P,minLo:!0,minHi:!0}}if(!c){if(b&&x>cu){let k=0,R=null;for(let C=g;C>=p;C-=2){let P=C>u?C-u:u-C,y=pt(i,C),I=y-C,O=y-t+(I-o)-P;if(O>mc*x&&O>k&&t+Sn<=y&&y<n&&o+Sn<=I&&I<s){let j=!0;for(let G=1;G<=Sn;G++)if(e[y-G]!==r[I-G]){j=!1;break}j&&(k=O,R={i1:y,i2:I,minLo:!0,minHi:!1})}}if(R)return R;k=0,R=null;for(let C=E;C>=w;C-=2){let P=C>m?C-m:m-C,y=pt(a,C),I=y-C,O=n-y+(s-I)-P;if(O>mc*x&&O>k&&t<y&&y<=n-Sn&&o<I&&I<=s-Sn){let j=!0;for(let G=0;G<Sn;G++)if(e[y+G]!==r[I+G]){j=!1;break}j&&(k=O,R={i1:y,i2:I,minLo:!1,minHi:!0})}}if(R)return R}if(x>=f){let k=-1,R=-1;for(let y=g;y>=p;y-=2){let I=Math.min(pt(i,y),n),O=I-y;s<O&&(I=s+y,O=s),k<I+O&&(k=I+O,R=I)}let C=Ks,P=Ks;for(let y=E;y>=w;y-=2){let I=Math.max(t,pt(a,y)),O=I-y;O<o&&(I=o+y,O=o),I+O<C&&(C=I+O,P=I)}return n+s-C<k-(t+o)?{i1:R,i2:k-R,minLo:!0,minHi:!1}:{i1:P,i2:C-P,minLo:!1,minHi:!0}}}}}function si(e,t,n,r,o,s,i,a,c,f,d,l,u,m){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=du(e,t,n,r,o,s,d,l,u,m);si(e,t,h.i1,r,o,h.i2,i,a,c,f,d,l,h.minLo,m),si(e,h.i1,n,r,h.i2,s,i,a,c,f,d,l,h.minHi,m)}}function lu(e,t,n,r){let o=[],s=0,i=0,a=1,c=1;for(;s<e.length||i<t.length;){if(s<e.length&&i<t.length&&!n[s]&&!r[i]){o.push({type:"keep",line:e[s]??"",oldLineNo:a++,newLineNo:c++}),s++,i++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:a++,newLineNo:0}),s++;for(;i<t.length&&r[i];)o.push({type:"insert",line:t[i]??"",oldLineNo:0,newLineNo:c++}),i++}return o}var hc=200,pc=20,gc=100,uu=1,mu=21,hu=-30,pu=6,gu=-4,wu=10,bu=24,yu=17,Eu=23,ku=17,Ru=60;function ni(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===32)t+=1;else if(r===9)t+=8-t%8;else if(!(r===10||r===13||r===11||r===12))return t;if(t>=hc)return hc}return-1}function wc(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=ni(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ni(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===pc){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ni(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===pc){r.postIndent=0;break}return r}function bc(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=uu),e.endOfFile&&(t.penalty+=mu);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=hu*r,t.penalty+=pu*n;let o=e.indent!==-1?e.indent:e.postIndent,s=r!==0;t.effectiveIndent+=o,o===-1||e.preIndent===-1||(o>e.preIndent?t.penalty+=s?wu:gu:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?yu:bu:t.penalty+=s?ku:Eu))}function xu(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Ru*n+(e.penalty-t.penalty)}function yc(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let d=(l,u)=>t[l]===t[u];for(;;){if(a!==i){let l,u,m;do{for(l=a-i,u=-1;i>0&&d(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=a,f>c&&(u=a);!(a>=r||!d(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(l!==a-i);if(a!==m)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(a-l-1>g&&(g=a-l-1),a-gc>g&&(g=a-gc);g<=a;g++){let w={effectiveIndent:0,penalty:0},E=wc(n,r,g);bc(E,w);let x=wc(n,r,g-l);bc(x,w),(h===-1||xu(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function oi(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=ou(e,t),{dstart:f,dend1:d,dend2:l}=iu(i,n,a,r);if(f>d)for(let u=f;u<r-(n-1-d);u++)s[u]=1;else if(f>l)for(let u=f;u<n-(r-1-l);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=au(i,n,a,r,c,f,d,l,o,s);if(m>0&&p>0){let g=new Array(m);for(let R=0;R<m;R++)g[R]=i[u[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=a[h[R]];let E={},x={},b=m+p+3,k=Math.max(fu,ri(b));si(g,0,m,w,0,p,o,s,u,h,E,x,!1,k)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[u[g]]=1;yc(o,i,e,n,s,r),yc(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function ft(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=oi(e,t);return lu(e,t,o,s)}var Cu=3;function Pu(e,t=Cu){if(e.length===0)return[];let n=[];for(let a=0;a<e.length;a++){let c=e[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),i=Math.min(e.length-1,r+t);for(let a=1;a<n.length;a++){let c=n[a]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=d}return o.push({start:s,end:i}),o.map(a=>Iu(e,a.start,a.end))}function Iu(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let d=t;d<=n;d++){let l=e[d];if(l)switch(l.type){case"keep":c||(r=l.oldLineNo,c=!0),f||(s=l.newLineNo,f=!0),o++,i++,a.push({type:"context",content:l.line});break;case"delete":c||(r=l.oldLineNo,c=!0),o++,a.push({type:"delete",content:l.line});break;case"insert":f||(s=l.newLineNo,f=!0),i++,a.push({type:"insert",content:l.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="insert"){r=l.newLineNo>1?l.newLineNo-1:0;break}}if(i===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="delete"){s=l.oldLineNo>1?l.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function Vs(e){return e?e.length<40?e:z(e):"0000000"}function Ec(e,t,n,r,o,s){let{path:i,oldMode:a,newMode:c}=t;e.push(`diff --git a/${i} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${i}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(e.push(`old mode ${a}`),e.push(`new mode ${c}`))}function Ou(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,d=e.renameTo??r,l=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(Ec(m,e,d,l,u,f),o!==s){if(a||c){let h=Vs(a),p=Vs(c);l||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${d} differ`):l?m.push(`Binary files /dev/null and b/${d} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${d} differ`)}return`${m.join(`
183
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var ou=4,uc=1024,Ws=100,zs=0,qs=1,ur=2;function si(e){let t=1;for(;t*t<e;)t++;return t}function iu(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let i=0;i<e.length;i++){let a=e[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,o[i]=c}for(let i=0;i<t.length;i++){let a=t[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,s[i]=c}return{classes1:o,classes2:s,classInfo:r}}function au(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let i=o,a=0,c=s-i;for(;a<c&&e[t-1-a]===n[r-1-a];)a++;return{dstart:i,dend1:t-a-1,dend2:r-a-1}}function mc(e,t,n,r){t-n>Ws&&(n=t-Ws),r-t>Ws&&(r=t+Ws);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===zs)o++;else if(f===ur)s++;else break}if(o===0)return!1;let i=0,a=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===zs)i++;else if(f===ur)a++;else break}return i===0?!1:(i+=o,a+=s,a*ou<a+i)}function cu(e,t,n,r,o,s,i,a,c,f){let d=new Uint8Array(t),l=new Uint8Array(r),u=Math.min(si(t),uc);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?d[g]=zs:w>=u?d[g]=ur:d[g]=qs}let m=Math.min(si(r),uc);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?l[g]=zs:w>=m?l[g]=ur:l[g]=qs}let h=[];for(let g=s;g<=i;g++)d[g]===qs||d[g]===ur&&!mc(d,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)l[g]===qs||l[g]===ur&&!mc(l,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Sn=20,hc=4,fu=256,du=256,Ks=2147483647;function pt(e,t){return e[t]??0}function lu(e,t,n,r,o,s,i,a,c,f){let d=t-s,l=n-o,u=t-o,m=n-s,h=u-m&1,p=u,g=u,w=m,E=m;i[u]=t,a[m]=n;for(let x=1;;x++){let b=!1;p>d?i[--p-1]=-1:++p,g<l?i[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let R;pt(i,k-1)>=pt(i,k+1)?R=pt(i,k-1)+1:R=pt(i,k+1);let C=R,P=R-k;for(;R<n&&P<s&&e[R]===r[P];)R++,P++;if(R-C>Sn&&(b=!0),i[k]=R,h&&w<=k&&k<=E&&pt(a,k)<=R)return{i1:R,i2:P,minLo:!0,minHi:!0}}w>d?a[--w-1]=Ks:++w,E<l?a[++E+1]=Ks:--E;for(let k=E;k>=w;k-=2){let R;pt(a,k-1)<pt(a,k+1)?R=pt(a,k-1):R=pt(a,k+1)-1;let C=R,P=R-k;for(;R>t&&P>o&&e[R-1]===r[P-1];)R--,P--;if(C-R>Sn&&(b=!0),a[k]=R,!h&&p<=k&&k<=g&&R<=pt(i,k))return{i1:R,i2:P,minLo:!0,minHi:!0}}if(!c){if(b&&x>fu){let k=0,R=null;for(let C=g;C>=p;C-=2){let P=C>u?C-u:u-C,y=pt(i,C),I=y-C,O=y-t+(I-o)-P;if(O>hc*x&&O>k&&t+Sn<=y&&y<n&&o+Sn<=I&&I<s){let j=!0;for(let G=1;G<=Sn;G++)if(e[y-G]!==r[I-G]){j=!1;break}j&&(k=O,R={i1:y,i2:I,minLo:!0,minHi:!1})}}if(R)return R;k=0,R=null;for(let C=E;C>=w;C-=2){let P=C>m?C-m:m-C,y=pt(a,C),I=y-C,O=n-y+(s-I)-P;if(O>hc*x&&O>k&&t<y&&y<=n-Sn&&o<I&&I<=s-Sn){let j=!0;for(let G=0;G<Sn;G++)if(e[y+G]!==r[I+G]){j=!1;break}j&&(k=O,R={i1:y,i2:I,minLo:!1,minHi:!0})}}if(R)return R}if(x>=f){let k=-1,R=-1;for(let y=g;y>=p;y-=2){let I=Math.min(pt(i,y),n),O=I-y;s<O&&(I=s+y,O=s),k<I+O&&(k=I+O,R=I)}let C=Ks,P=Ks;for(let y=E;y>=w;y-=2){let I=Math.max(t,pt(a,y)),O=I-y;O<o&&(I=o+y,O=o),I+O<C&&(C=I+O,P=I)}return n+s-C<k-(t+o)?{i1:R,i2:k-R,minLo:!0,minHi:!1}:{i1:P,i2:C-P,minLo:!1,minHi:!0}}}}}function oi(e,t,n,r,o,s,i,a,c,f,d,l,u,m){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=lu(e,t,n,r,o,s,d,l,u,m);oi(e,t,h.i1,r,o,h.i2,i,a,c,f,d,l,h.minLo,m),oi(e,h.i1,n,r,h.i2,s,i,a,c,f,d,l,h.minHi,m)}}function uu(e,t,n,r){let o=[],s=0,i=0,a=1,c=1;for(;s<e.length||i<t.length;){if(s<e.length&&i<t.length&&!n[s]&&!r[i]){o.push({type:"keep",line:e[s]??"",oldLineNo:a++,newLineNo:c++}),s++,i++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:a++,newLineNo:0}),s++;for(;i<t.length&&r[i];)o.push({type:"insert",line:t[i]??"",oldLineNo:0,newLineNo:c++}),i++}return o}var pc=200,gc=20,wc=100,mu=1,hu=21,pu=-30,gu=6,wu=-4,bu=10,yu=24,Eu=17,ku=23,Ru=17,xu=60;function ri(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===32)t+=1;else if(r===9)t+=8-t%8;else if(!(r===10||r===13||r===11||r===12))return t;if(t>=pc)return pc}return-1}function bc(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=ri(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ri(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===gc){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ri(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===gc){r.postIndent=0;break}return r}function yc(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=mu),e.endOfFile&&(t.penalty+=hu);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=pu*r,t.penalty+=gu*n;let o=e.indent!==-1?e.indent:e.postIndent,s=r!==0;t.effectiveIndent+=o,o===-1||e.preIndent===-1||(o>e.preIndent?t.penalty+=s?bu:wu:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?Eu:yu:t.penalty+=s?Ru:ku))}function Cu(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return xu*n+(e.penalty-t.penalty)}function Ec(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let d=(l,u)=>t[l]===t[u];for(;;){if(a!==i){let l,u,m;do{for(l=a-i,u=-1;i>0&&d(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=a,f>c&&(u=a);!(a>=r||!d(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(l!==a-i);if(a!==m)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(a-l-1>g&&(g=a-l-1),a-wc>g&&(g=a-wc);g<=a;g++){let w={effectiveIndent:0,penalty:0},E=bc(n,r,g);yc(E,w);let x=bc(n,r,g-l);yc(x,w),(h===-1||Cu(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function ii(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=iu(e,t),{dstart:f,dend1:d,dend2:l}=au(i,n,a,r);if(f>d)for(let u=f;u<r-(n-1-d);u++)s[u]=1;else if(f>l)for(let u=f;u<n-(r-1-l);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=cu(i,n,a,r,c,f,d,l,o,s);if(m>0&&p>0){let g=new Array(m);for(let R=0;R<m;R++)g[R]=i[u[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=a[h[R]];let E={},x={},b=m+p+3,k=Math.max(du,si(b));oi(g,0,m,w,0,p,o,s,u,h,E,x,!1,k)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[u[g]]=1;Ec(o,i,e,n,s,r),Ec(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function ft(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=ii(e,t);return uu(e,t,o,s)}var Pu=3;function Iu(e,t=Pu){if(e.length===0)return[];let n=[];for(let a=0;a<e.length;a++){let c=e[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),i=Math.min(e.length-1,r+t);for(let a=1;a<n.length;a++){let c=n[a]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=d}return o.push({start:s,end:i}),o.map(a=>Ou(e,a.start,a.end))}function Ou(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let d=t;d<=n;d++){let l=e[d];if(l)switch(l.type){case"keep":c||(r=l.oldLineNo,c=!0),f||(s=l.newLineNo,f=!0),o++,i++,a.push({type:"context",content:l.line});break;case"delete":c||(r=l.oldLineNo,c=!0),o++,a.push({type:"delete",content:l.line});break;case"insert":f||(s=l.newLineNo,f=!0),i++,a.push({type:"insert",content:l.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="insert"){r=l.newLineNo>1?l.newLineNo-1:0;break}}if(i===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="delete"){s=l.oldLineNo>1?l.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function Vs(e){return e?e.length<40?e:z(e):"0000000"}function kc(e,t,n,r,o,s){let{path:i,oldMode:a,newMode:c}=t;e.push(`diff --git a/${i} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${i}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(e.push(`old mode ${a}`),e.push(`new mode ${c}`))}function $u(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,d=e.renameTo??r,l=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(kc(m,e,d,l,u,f),o!==s){if(a||c){let h=Vs(a),p=Vs(c);l||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${d} differ`):l?m.push(`Binary files /dev/null and b/${d} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${d} differ`)}return`${m.join(`
184
184
  `)}
185
- `}function Rt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Te(n),l=Te(r);if(d||l)return Ou(e,d,l);let u=jt(n),m=jt(r),h=n.length>0&&n.endsWith(`
185
+ `}function Rt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Te(n),l=Te(r);if(d||l)return $u(e,d,l);let u=jt(n),m=jt(r),h=n.length>0&&n.endsWith(`
186
186
  `),p=r.length>0&&r.endsWith(`
187
- `),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let E=m;!p&&m.length>0&&(E=m.slice(),E[E.length-1]+=g);let x=ft(w,E);if(!h||!p)for(let O of x)O.line.includes(g)&&(O.line=O.line.replace(g,""));let b=Pu(x);if(b.length===0&&!c)return"";let k=e.isNew??n==="",R=e.isDeleted??r==="",C=[];if(Ec(C,e,f,k,R,c),b.length===0)return`${C.join(`
187
+ `),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let E=m;!p&&m.length>0&&(E=m.slice(),E[E.length-1]+=g);let x=ft(w,E);if(!h||!p)for(let O of x)O.line.includes(g)&&(O.line=O.line.replace(g,""));let b=Iu(x);if(b.length===0&&!c)return"";let k=e.isNew??n==="",R=e.isDeleted??r==="",C=[];if(kc(C,e,f,k,R,c),b.length===0)return`${C.join(`
188
188
  `)}
189
189
  `;if(i||a){let O=Vs(i),j=Vs(a);k||R?C.push(`index ${O}..${j}`):c?C.push(`index ${O}..${j} ${o||"100644"}`):o&&s&&o!==s?C.push(`index ${O}..${j}`):C.push(`index ${O}..${j} ${o||"100644"}`)}let P=O=>O.includes(" ")?" ":"";k?(C.push("--- /dev/null"),C.push(`+++ b/${f}${P(f)}`)):R?(C.push(`--- a/${t}${P(t)}`),C.push("+++ /dev/null")):(C.push(`--- a/${t}${P(t)}`),C.push(`+++ b/${f}${P(f)}`));let y=u.length,I=m.length;for(let O of b){let j=O.oldCount===1?`${O.oldStart}`:`${O.oldStart},${O.oldCount}`,G=O.newCount===1?`${O.newStart}`:`${O.newStart},${O.newCount}`,V="";for(let L=O.oldStart-2;L>=0;L--){let N=u[L];if(N&&/^[a-zA-Z$_]/.test(N)){V=` ${N.trimEnd().slice(0,79)}`;break}}C.push(`@@ -${j} +${G} @@${V}`);let A=O.oldStart,H=O.newStart;for(let L of O.lines)switch(L.type){case"context":C.push(` ${L.content}`),(!h&&A===y||!p&&H===I)&&C.push("\"),A++,H++;break;case"delete":C.push(`-${L.content}`),!h&&A===y&&C.push("\"),A++;break;case"insert":C.push(`+${L.content}`),!p&&H===I&&C.push("\"),H++;break}}return`${C.join(`
190
190
  `)}
191
- `}ie();Se();async function Hn(e,t,n){return(await ce(e,t)).get(n)?.hash??null}async function kc(e,t,n,r){let o=await _e(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await nt(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function $u(e,t,n,r,o,s){let i=await Hn(e,(await M(e,t)).tree,n);if(!i){let p=new Map,g=await M(e,t);for(let w of r)p.set(w.finalIdx,vn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=jt(a),f=new Array(o.length),d=[...r],l=t,u=n,m=c;for(;d.length>0;){let p=await M(e,l);if(p.parents.length===0){for(let y of d)f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!0,void 0);break}let g=await Hn(e,p.tree,u),w=null,E=[];for(let y of p.parents){let I=await M(e,y),O=u,j=await Hn(e,I.tree,O);if(!j){let G=await kc(e,I.tree,p.tree,u);G&&(O=G,j=await Hn(e,I.tree,O))}if(j&&(E.push({hash:y,path:O,blobHash:j}),j===g)){w={hash:y,path:O};break}}if(w){l=w.hash,u=w.path;continue}if(E.length===0){for(let y of d)f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,void 0);break}let x=E[0],b=await oe(e,x.blobHash),k=jt(b),R=ft(k,m),C=new Map;for(let y of R)y.type==="keep"&&C.set(y.newLineNo,y.oldLineNo);let P=[];for(let y of d){let I=C.get(y.currentLine);I!==void 0?P.push({finalIdx:y.finalIdx,currentLine:I}):f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,{hash:x.hash,path:x.path})}d=P,l=x.hash,u=x.path,m=k}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function Rc(e,t,n,r){let o=await M(e,t),s=await Hn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=jt(i),c=r?.startLine??1,f=r?.endLine??a.length,d=a.slice(c-1,f),l=new Array(d.length),u=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await M(e,m);if(g.parents.length===0){for(let C of u)l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await Hn(e,g.tree,h),E=[],x=null;for(let C of g.parents){let P=await M(e,C),y=h,I=await Hn(e,P.tree,y);if(!I){let O=await kc(e,P.tree,g.tree,h);O&&(y=O,I=await Hn(e,P.tree,y))}if(I){let O={hash:C,path:y,blobHash:I};if(E.push(O),I===w){x=O;break}}}if(x){m=x.hash,h=x.path;continue}if(E.length===0){for(let C of u)l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(E.length===1){let C=E[0],P=await oe(e,C.blobHash),y=jt(P),I=ft(y,p),O=new Map;for(let G of I)G.type==="keep"&&O.set(G.newLineNo,G.oldLineNo);let j=[];for(let G of u){let V=O.get(G.currentLine);V!==void 0?j.push({finalIdx:G.finalIdx,currentLine:V}):l[G.finalIdx]=vn(m,h,G.currentLine,c+G.finalIdx,d[G.finalIdx],g,!1,{hash:C.hash,path:C.path})}u=j,m=C.hash,h=C.path,p=y;continue}let b=[];for(let C of E){let P=await oe(e,C.blobHash),y=jt(P),I=ft(y,p),O=new Map;for(let j of I)j.type==="keep"&&O.set(j.newLineNo,j.oldLineNo);b.push({info:C,newToOld:O})}let k=new Map;for(let C of u){let P=!1;for(let y=0;y<b.length;y++){let I=b[y],O=I.newToOld.get(C.currentLine);if(O!==void 0){let j=k.get(y);j||(j={info:I.info,lines:[]},k.set(y,j)),j.lines.push({finalIdx:C.finalIdx,currentLine:O}),P=!0;break}}P||(l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:E[0].hash,path:E[0].path}))}let R=k.get(0);for(let[C,P]of k){if(C===0)continue;let y=await $u(e,P.info.hash,P.info.path,P.lines,d,c);for(let[I,O]of y)l[I]=O}if(R&&R.lines.length>0){u=R.lines,m=R.info.hash,h=R.info.path;let C=await oe(e,R.info.blobHash);p=jt(C)}else break}return l}function vn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
192
- `)[0],boundary:i,previous:a}}re();ie();Se();ie();de();function Tu(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function Su(e,t){let n=Tu(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),i=r.getUTCDate().toString().padStart(2,"0"),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${i} ${a}:${c}:${f} ${t}`}function Hu(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(l=>l.finalLine)),i=String(s).length,a=e.some(l=>l.origPath!==t),c=0;if(!o)for(let l of e){let u=r?`<${l.author.email}>`:l.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let l of e)l.origPath.length>f&&(f=l.origPath.length);let d=[];for(let l of e){let u;n?u=l.boundary?`^${l.hash.slice(0,39)}`:l.hash:u=l.boundary?`^${l.hash.slice(0,7)}`:l.hash.slice(0,8);let m=a?` ${l.origPath.padEnd(f)}`:"";if(o)d.push(`${u}${m} ${String(l.finalLine).padStart(i)}) ${l.content}`);else{let h=r?`<${l.author.email}>`:l.author.name,p=Su(l.author.timestamp,l.author.timezone);d.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(l.finalLine).padStart(i)}) ${l.content}`)}}return`${d.join(`
191
+ `}ie();Se();async function Hn(e,t,n){return(await ce(e,t)).get(n)?.hash??null}async function Rc(e,t,n,r){let o=await _e(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await nt(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function Tu(e,t,n,r,o,s){let i=await Hn(e,(await M(e,t)).tree,n);if(!i){let p=new Map,g=await M(e,t);for(let w of r)p.set(w.finalIdx,vn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=jt(a),f=new Array(o.length),d=[...r],l=t,u=n,m=c;for(;d.length>0;){let p=await M(e,l);if(p.parents.length===0){for(let y of d)f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!0,void 0);break}let g=await Hn(e,p.tree,u),w=null,E=[];for(let y of p.parents){let I=await M(e,y),O=u,j=await Hn(e,I.tree,O);if(!j){let G=await Rc(e,I.tree,p.tree,u);G&&(O=G,j=await Hn(e,I.tree,O))}if(j&&(E.push({hash:y,path:O,blobHash:j}),j===g)){w={hash:y,path:O};break}}if(w){l=w.hash,u=w.path;continue}if(E.length===0){for(let y of d)f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,void 0);break}let x=E[0],b=await oe(e,x.blobHash),k=jt(b),R=ft(k,m),C=new Map;for(let y of R)y.type==="keep"&&C.set(y.newLineNo,y.oldLineNo);let P=[];for(let y of d){let I=C.get(y.currentLine);I!==void 0?P.push({finalIdx:y.finalIdx,currentLine:I}):f[y.finalIdx]=vn(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,{hash:x.hash,path:x.path})}d=P,l=x.hash,u=x.path,m=k}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function xc(e,t,n,r){let o=await M(e,t),s=await Hn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=jt(i),c=r?.startLine??1,f=r?.endLine??a.length,d=a.slice(c-1,f),l=new Array(d.length),u=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await M(e,m);if(g.parents.length===0){for(let C of u)l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await Hn(e,g.tree,h),E=[],x=null;for(let C of g.parents){let P=await M(e,C),y=h,I=await Hn(e,P.tree,y);if(!I){let O=await Rc(e,P.tree,g.tree,h);O&&(y=O,I=await Hn(e,P.tree,y))}if(I){let O={hash:C,path:y,blobHash:I};if(E.push(O),I===w){x=O;break}}}if(x){m=x.hash,h=x.path;continue}if(E.length===0){for(let C of u)l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(E.length===1){let C=E[0],P=await oe(e,C.blobHash),y=jt(P),I=ft(y,p),O=new Map;for(let G of I)G.type==="keep"&&O.set(G.newLineNo,G.oldLineNo);let j=[];for(let G of u){let V=O.get(G.currentLine);V!==void 0?j.push({finalIdx:G.finalIdx,currentLine:V}):l[G.finalIdx]=vn(m,h,G.currentLine,c+G.finalIdx,d[G.finalIdx],g,!1,{hash:C.hash,path:C.path})}u=j,m=C.hash,h=C.path,p=y;continue}let b=[];for(let C of E){let P=await oe(e,C.blobHash),y=jt(P),I=ft(y,p),O=new Map;for(let j of I)j.type==="keep"&&O.set(j.newLineNo,j.oldLineNo);b.push({info:C,newToOld:O})}let k=new Map;for(let C of u){let P=!1;for(let y=0;y<b.length;y++){let I=b[y],O=I.newToOld.get(C.currentLine);if(O!==void 0){let j=k.get(y);j||(j={info:I.info,lines:[]},k.set(y,j)),j.lines.push({finalIdx:C.finalIdx,currentLine:O}),P=!0;break}}P||(l[C.finalIdx]=vn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:E[0].hash,path:E[0].path}))}let R=k.get(0);for(let[C,P]of k){if(C===0)continue;let y=await Tu(e,P.info.hash,P.info.path,P.lines,d,c);for(let[I,O]of y)l[I]=O}if(R&&R.lines.length>0){u=R.lines,m=R.info.hash,h=R.info.path;let C=await oe(e,R.info.blobHash);p=jt(C)}else break}return l}function vn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
192
+ `)[0],boundary:i,previous:a}}re();ie();Se();ie();de();function Su(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function Hu(e,t){let n=Su(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),i=r.getUTCDate().toString().padStart(2,"0"),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${i} ${a}:${c}:${f} ${t}`}function vu(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(l=>l.finalLine)),i=String(s).length,a=e.some(l=>l.origPath!==t),c=0;if(!o)for(let l of e){let u=r?`<${l.author.email}>`:l.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let l of e)l.origPath.length>f&&(f=l.origPath.length);let d=[];for(let l of e){let u;n?u=l.boundary?`^${l.hash.slice(0,39)}`:l.hash:u=l.boundary?`^${l.hash.slice(0,7)}`:l.hash.slice(0,8);let m=a?` ${l.origPath.padEnd(f)}`:"";if(o)d.push(`${u}${m} ${String(l.finalLine).padStart(i)}) ${l.content}`);else{let h=r?`<${l.author.email}>`:l.author.name,p=Hu(l.author.timestamp,l.author.timezone);d.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(l.finalLine).padStart(i)}) ${l.content}`)}}return`${d.join(`
193
193
  `)}
194
- `}function vu(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
194
+ `}function Au(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
195
195
  `)}
196
- `}function Au(e,t,n){if(e.startsWith("/"))return at(n,e);let r=at(n,t);return r===""||r==="."?e:`${r}/${e}`}function xc(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[W.string().name("args").variadic().optional()],options:{lineRange:te.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:S().alias("l").describe("Show long revision"),showEmail:S().alias("e").describe("Show author email instead of name"),suppress:S().alias("s").describe("Suppress author name and date"),porcelain:S().alias("p").describe("Show in machine-readable format"),linePorcelain:S().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s;if(!i.workTree)return $("this operation must be run in a work tree");let a=await Ve(i);if(v(a))return a;let c=n.args??[],f=o.passthrough??[],d=null,l=null;if(f.length>0?(l=f[f.length-1],c.length>0&&(d=c[0])):c.length===2?(d=c[0],l=c[1]):c.length===1&&(l=c[0]),!l)return $("no file specified");let u=Au(l,r.cwd,i.workTree),m;if(d){let R=await St(i,d);if(v(R))return R;m=await Ne(i,R)}else m=a;let h=await M(i,m),p=await ce(i,h.tree);if(!p.has(u))return $(`no such path ${u} in ${d??"HEAD"}`);let g=p.get(u).hash,w=await oe(i,g);if(Te(w))return $(`cannot blame binary file '${u}'`);let E,x;if(n.lineRange){let R=n.lineRange,C=R.match(/^(\d+),(\d+)$/);if(C)E=parseInt(C[1],10),x=parseInt(C[2],10);else return $(`invalid -L range: '${R}'`)}let b;try{b=await Rc(i,m,u,{startLine:E,endLine:x})}catch(R){let C=R instanceof Error?R.message:String(R);return $(C)}let k;return n.porcelain||n.linePorcelain?k=vu(b,!!n.linePorcelain):k=Hu(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}re();Ye();hn();re();var Du=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Mu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Gt(e,t){let n=ju(t),r=new Date((e+n*60)*1e3),o=Du[r.getUTCDay()],s=Mu[r.getUTCMonth()],i=r.getUTCDate(),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),d=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${d} ${t}`}function ii(e){let t=e.trim();if(/^\d+$/.test(t))return parseInt(t,10);let n=Date.parse(t);return Number.isNaN(n)?null:Math.floor(n/1e3)}function ju(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}ie();Se();var Ys=new TextDecoder;function Cc(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
196
+ `}function Du(e,t,n){if(e.startsWith("/"))return at(n,e);let r=at(n,t);return r===""||r==="."?e:`${r}/${e}`}function Cc(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[W.string().name("args").variadic().optional()],options:{lineRange:te.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:S().alias("l").describe("Show long revision"),showEmail:S().alias("e").describe("Show author email instead of name"),suppress:S().alias("s").describe("Suppress author name and date"),porcelain:S().alias("p").describe("Show in machine-readable format"),linePorcelain:S().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s;if(!i.workTree)return $("this operation must be run in a work tree");let a=await Ve(i);if(v(a))return a;let c=n.args??[],f=o.passthrough??[],d=null,l=null;if(f.length>0?(l=f[f.length-1],c.length>0&&(d=c[0])):c.length===2?(d=c[0],l=c[1]):c.length===1&&(l=c[0]),!l)return $("no file specified");let u=Du(l,r.cwd,i.workTree),m;if(d){let R=await St(i,d);if(v(R))return R;m=await Ne(i,R)}else m=a;let h=await M(i,m),p=await ce(i,h.tree);if(!p.has(u))return $(`no such path ${u} in ${d??"HEAD"}`);let g=p.get(u).hash,w=await oe(i,g);if(Te(w))return $(`cannot blame binary file '${u}'`);let E,x;if(n.lineRange){let R=n.lineRange,C=R.match(/^(\d+),(\d+)$/);if(C)E=parseInt(C[1],10),x=parseInt(C[2],10);else return $(`invalid -L range: '${R}'`)}let b;try{b=await xc(i,m,u,{startLine:E,endLine:x})}catch(R){let C=R instanceof Error?R.message:String(R);return $(C)}let k;return n.porcelain||n.linePorcelain?k=Au(b,!!n.linePorcelain):k=vu(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}re();Ye();hn();re();var Mu=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ju=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Gt(e,t){let n=Gu(t),r=new Date((e+n*60)*1e3),o=Mu[r.getUTCDay()],s=ju[r.getUTCMonth()],i=r.getUTCDate(),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),d=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${d} ${t}`}function ai(e){let t=e.trim();if(/^\d+$/.test(t))return parseInt(t,10);let n=Date.parse(t);return Number.isNaN(n)?null:Math.floor(n/1e3)}function Gu(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}ie();Se();var Ys=new TextDecoder;function Pc(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
197
197
  `&&t++;return e[e.length-1]!==`
198
- `&&t++,t}function mr(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function zr(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await yt(e,a.newHash);wn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:Cc(Ys.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await yt(e,a.oldHash);wn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:Cc(Ys.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await yt(e,a.oldHash),f=await yt(e,a.newHash);if(wn(c)||wn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=qt(Ys.decode(c)),l=qt(Ys.decode(f)),u=ft(d,l),m=0,h=0;for(let p of u)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:m,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=On(a.oldPath,a.newPath),f=0,d=0;if(a.similarity<100&&a.oldHash&&a.newHash){let l=await oe(e,a.oldHash),u=await oe(e,a.newHash);if(!Te(l)&&!Te(u)){let m=qt(l),h=qt(u),p=ft(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:d})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=On(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function nn(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${Gt(r.timestamp,r.timezone)}`),i)return a.join(`
198
+ `&&t++,t}function mr(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function zr(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await yt(e,a.newHash);wn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:Pc(Ys.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await yt(e,a.oldHash);wn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:Pc(Ys.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await yt(e,a.oldHash),f=await yt(e,a.newHash);if(wn(c)||wn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=qt(Ys.decode(c)),l=qt(Ys.decode(f)),u=ft(d,l),m=0,h=0;for(let p of u)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:m,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=On(a.oldPath,a.newPath),f=0,d=0;if(a.similarity<100&&a.oldHash&&a.newHash){let l=await oe(e,a.oldHash),u=await oe(e,a.newHash);if(!Te(l)&&!Te(u)){let m=qt(l),h=qt(u),p=ft(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:d})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=On(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function nn(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${Gt(r.timestamp,r.timezone)}`),i)return a.join(`
199
199
  `)+(a.length>0?`
200
200
  `:"");let c=await _e(e,t,n),{remaining:f,renames:d}=await nt(e,c),{fileStats:l,modeLines:u}=await zr(e,f,d),m=0,h=0;for(let g of l)m+=g.insertions,h+=g.deletions;let p=mr(l.length,m,h);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
201
201
  `)+(a.length>0?`
202
- `:"")}var Gu=80;function Lu(e,t){if(e.length<=t)return e;let n=e;for(;n.length+4>t;){let o=n.indexOf("/");if(o===-1)break;n=n.slice(o+1)}let r=`.../${n}`;return r.length<=t?r:`...${e.slice(e.length-(t-3))}`}function Vr(e,t=Gu){if(e.length===0)return"";let n=e.filter(p=>!p.isUnmerged),r=n.length>0?Math.max(...n.map(p=>p.insertions+p.deletions)):0,o=e.some(p=>p.isBinary),s=r>0?String(r).length:1;o&&s<3&&(s=3);let i=Math.max(...e.map(p=>p.path.length)),a=r,c=i;if(c+s+6+a>t){let p=Math.floor(t*3/8)-s-6;a>p&&(a=Math.max(p,6));let g=t-s-6-a;c>g?c=g:a=t-s-6-c}for(let p of e)p.path=Lu(p.path,c);let f=c,d=[],l=0,u=0,m=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){d.push(` ${g} | Unmerged`);continue}if(m++,l+=p.insertions,u+=p.deletions,p.isBinary){let P=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;d.push(` ${g} | ${P}`);continue}let w=p.insertions+p.deletions,E=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let C=I=>I===0?0:1+Math.floor(I*(a-1)/r),P=C(w),y=P<2&&p.insertions>0&&p.deletions>0?2:P;p.insertions<p.deletions?(x=C(p.insertions),b=y-x):(b=C(p.deletions),x=y-b)}let k="+".repeat(x)+"-".repeat(b),R=k?` ${k}`:"";d.push(` ${g} | ${E}${R}`)}let h=mr(m,l,u);return h?d.push(h):e.some(p=>p.isUnmerged)&&d.push(" 0 files changed"),`${d.join(`
202
+ `:"")}var Lu=80;function Nu(e,t){if(e.length<=t)return e;let n=e;for(;n.length+4>t;){let o=n.indexOf("/");if(o===-1)break;n=n.slice(o+1)}let r=`.../${n}`;return r.length<=t?r:`...${e.slice(e.length-(t-3))}`}function Vr(e,t=Lu){if(e.length===0)return"";let n=e.filter(p=>!p.isUnmerged),r=n.length>0?Math.max(...n.map(p=>p.insertions+p.deletions)):0,o=e.some(p=>p.isBinary),s=r>0?String(r).length:1;o&&s<3&&(s=3);let i=Math.max(...e.map(p=>p.path.length)),a=r,c=i;if(c+s+6+a>t){let p=Math.floor(t*3/8)-s-6;a>p&&(a=Math.max(p,6));let g=t-s-6-a;c>g?c=g:a=t-s-6-c}for(let p of e)p.path=Nu(p.path,c);let f=c,d=[],l=0,u=0,m=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){d.push(` ${g} | Unmerged`);continue}if(m++,l+=p.insertions,u+=p.deletions,p.isBinary){let P=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;d.push(` ${g} | ${P}`);continue}let w=p.insertions+p.deletions,E=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let C=I=>I===0?0:1+Math.floor(I*(a-1)/r),P=C(w),y=P<2&&p.insertions>0&&p.deletions>0?2:P;p.insertions<p.deletions?(x=C(p.insertions),b=y-x):(b=C(p.deletions),x=y-b)}let k="+".repeat(x)+"-".repeat(b),R=k?` ${k}`:"";d.push(` ${g} | ${E}${R}`)}let h=mr(m,l,u);return h?d.push(h):e.some(p=>p.isUnmerged)&&d.push(" 0 files changed"),`${d.join(`
203
203
  `)}
204
204
  `}async function An(e,t,n){let r=await _e(e,t,n),{remaining:o,renames:s}=await nt(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await zr(e,o,s);i.sort((f,d)=>f.sortKey<d.sortKey?-1:f.sortKey>d.sortKey?1:0);let c=Vr(i);for(let f of a)c+=`${f}
205
- `;return c}Ye();Re();ie();ue();Qt();async function Nu(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i=await M(e,s);for(let a of i.parents)n.has(a)||r.push(a)}return n}async function un(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a=await M(e,i);for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Lt(e,t,n){if(t===n)return[t];let r=await Nu(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let d=await M(e,f);for(let l of d.parents)s.has(l)||i.push(l)}if(o.length<=1)return o;let c=[];for(let f of o){let d=!1;for(let l of o)if(l!==f&&await un(e,f,l)){d=!0;break}d||c.push(f)}return c.length<=1?c:_u(e,t,n,c)}async function _u(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,d=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function l(u){let m=c.get(u);if(m!==void 0)return m;let h=(await M(e,u)).committer.timestamp;return c.set(u,h),h}for(;d.length>0;){let u=0,m=await l(d[0].hash);for(let E=1;E<d.length;E++){let x=d[E],b=await l(x.hash),k=d[u];(b>m||b===m&&x.seq<k.seq)&&(u=E,m=b)}let h=d.splice(u,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await M(e,h.hash);for(let E of w.parents)d.push({hash:E,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function Xn(e,t,n){let r=await _t(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
205
+ `;return c}Ye();Re();ie();ue();Qt();async function _u(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i=await M(e,s);for(let a of i.parents)n.has(a)||r.push(a)}return n}async function un(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a=await M(e,i);for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Lt(e,t,n){if(t===n)return[t];let r=await _u(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let d=await M(e,f);for(let l of d.parents)s.has(l)||i.push(l)}if(o.length<=1)return o;let c=[];for(let f of o){let d=!1;for(let l of o)if(l!==f&&await un(e,f,l)){d=!0;break}d||c.push(f)}return c.length<=1?c:Fu(e,t,n,c)}async function Fu(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,d=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function l(u){let m=c.get(u);if(m!==void 0)return m;let h=(await M(e,u)).committer.timestamp;return c.set(u,h),h}for(;d.length>0;){let u=0,m=await l(d[0].hash);for(let E=1;E<d.length;E++){let x=d[E],b=await l(x.hash),k=d[u];(b>m||b===m&&x.seq<k.seq)&&(u=E,m=b)}let h=d.splice(u,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await M(e,h.hash);for(let E of w.parents)d.push({hash:E,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function Xn(e,t,n){let r=await _t(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
206
206
  `:`Merge branch '${t}' into ${n}
207
207
  `}async function Xs(e,t,n){let r=await M(e,t),o=await M(e,n),s=z(t),i=z(n),a=`Updating ${s}..${i}
208
- `;if(e.workTree){let f=await K(e),d=await _a(e,r.tree,o.tree,f);if(!d.success){let l=d.errorOutput;return{stdout:a+l.stdout,stderr:l.stderr,exitCode:l.exitCode}}await se(e,{version:2,entries:d.newEntries}),await He(e,d.worktreeOps)}await yn(e,n);let c=await An(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
209
- ${c}`,stderr:"",exitCode:0}}ie();je();ue();function Pc(e,t){e.command("branch",{description:"List, create, or delete branches",args:[W.string().name("name").describe("Branch name").optional(),W.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:S().alias("d").describe("Delete a branch"),forceDelete:S().alias("D").describe("Force delete a branch"),move:S().alias("m").describe("Rename a branch"),forceMove:S().alias("M").describe("Force rename a branch"),remotes:S().alias("r").describe("List remote-tracking branches"),all:S().alias("a").describe("List all branches"),setUpstreamTo:te.string().alias("u").describe("Set upstream tracking branch"),verbose:S().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await Z(s),a=i?.type==="symbolic"?be(i.target):null,c=!!n.forceMove;if(n.move||c){let w,E;if(n.newName)w=n.name,E=n.newName;else if(n.name){if(!a)return $("not on any branch");w=a,E=n.name}else return $("branch name required");let x=`refs/heads/${w}`,b=`refs/heads/${E}`,k=await U(s,x);if(!k)return $(`no branch named '${w}'`);if(await Mt(s)&&(await ht(s))?.headName===x)return $(`branch ${x} is being rebased at ${s.workTree}`);let R=await U(s,b);if(R&&!c)return $(`a branch named '${E}' already exists`);R&&await fe(s,b);let C=await Xe(s,x);await Y(s,b,k),await fe(s,x),w===a&&await Ue(s,"HEAD",b),C.length>0&&await kn(s,b,C);let P=`Branch: renamed ${x} to ${b}`;if(await ne(s,r.env,b,k,k,P),w===a){let O=await Vt(s,r.env);await Be(s,"HEAD",{oldHash:k,newHash:J,...O,message:P}),await Be(s,"HEAD",{oldHash:J,newHash:k,...O,message:P})}let y=await le(s),I=`branch "${w}"`;return y[I]&&(y[`branch "${E}"`]=y[I],delete y[I],await Qe(s,y)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return $("branch name required");let w=n.name===a;if(!w&&!a&&await Mt(s)&&(await ht(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
208
+ `;if(e.workTree){let f=await K(e),d=await Fa(e,r.tree,o.tree,f);if(!d.success){let l=d.errorOutput;return{stdout:a+l.stdout,stderr:l.stderr,exitCode:l.exitCode}}await se(e,{version:2,entries:d.newEntries}),await He(e,d.worktreeOps)}await yn(e,n);let c=await An(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
209
+ ${c}`,stderr:"",exitCode:0}}ie();je();ue();function Ic(e,t){e.command("branch",{description:"List, create, or delete branches",args:[W.string().name("name").describe("Branch name").optional(),W.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:S().alias("d").describe("Delete a branch"),forceDelete:S().alias("D").describe("Force delete a branch"),move:S().alias("m").describe("Rename a branch"),forceMove:S().alias("M").describe("Force rename a branch"),remotes:S().alias("r").describe("List remote-tracking branches"),all:S().alias("a").describe("List all branches"),setUpstreamTo:te.string().alias("u").describe("Set upstream tracking branch"),verbose:S().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await Z(s),a=i?.type==="symbolic"?be(i.target):null,c=!!n.forceMove;if(n.move||c){let w,E;if(n.newName)w=n.name,E=n.newName;else if(n.name){if(!a)return $("not on any branch");w=a,E=n.name}else return $("branch name required");let x=`refs/heads/${w}`,b=`refs/heads/${E}`,k=await U(s,x);if(!k)return $(`no branch named '${w}'`);if(await Mt(s)&&(await ht(s))?.headName===x)return $(`branch ${x} is being rebased at ${s.workTree}`);let R=await U(s,b);if(R&&!c)return $(`a branch named '${E}' already exists`);R&&await fe(s,b);let C=await Xe(s,x);await Y(s,b,k),await fe(s,x),w===a&&await Ue(s,"HEAD",b),C.length>0&&await kn(s,b,C);let P=`Branch: renamed ${x} to ${b}`;if(await ne(s,r.env,b,k,k,P),w===a){let O=await Vt(s,r.env);await Be(s,"HEAD",{oldHash:k,newHash:J,...O,message:P}),await Be(s,"HEAD",{oldHash:J,newHash:k,...O,message:P})}let y=await le(s),I=`branch "${w}"`;return y[I]&&(y[`branch "${E}"`]=y[I],delete y[I],await Qe(s,y)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return $("branch name required");let w=n.name===a;if(!w&&!a&&await Mt(s)&&(await ht(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
210
210
  `);let E=`refs/heads/${n.name}`,x=await U(s,E);if(!x)return _(`error: branch '${n.name}' not found
211
211
  `);let b="";if(!f){let k=await X(s),C=(await le(s))[`branch "${n.name}"`],P=C?.remote,y=C?.merge,I=null,O=null;if(P&&y&&(I=y.replace(/^refs\/heads\//,`refs/remotes/${P}/`),O=await U(s,I)),O&&I){if(!(x===O||await un(s,x,O))){let A=k!=null&&(x===k||await un(s,x,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
212
212
  '${I}', even though it is merged to HEAD
@@ -222,20 +222,20 @@ hint: Disable this message with "git config set advice.forceDeleteBranch false"
222
222
  `,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,E=n.name||a;if(!E)return $("could not set upstream of HEAD when it does not point to any branch.");if(!await U(s,`refs/heads/${E}`))return $(`branch '${E}' does not exist`);let b=w.indexOf("/");if(b<0)return $(`the requested upstream branch '${w}' does not exist`);let k=w.slice(0,b),R=w.slice(b+1);if(!await U(s,`refs/remotes/${w}`))return $(`the requested upstream branch '${w}' does not exist`);let P=await le(s),y=`branch "${E}"`;return P[y]||(P[y]={}),P[y].remote=k,P[y].merge=`refs/heads/${R}`,await Qe(s,P),{stdout:"",stderr:`branch '${E}' set up to track '${w}'.
223
223
  `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,E;if(w){let R=await $e(s,w,`not a valid object name: '${w}'`);if(v(R))return R;E=R.hash}else if(E=await X(s),!E)return $("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await U(s,x))return $(`a branch named '${n.name}' already exists`);await Y(s,x,E);let k=w??"HEAD";return await ne(s,r.env,x,null,E,`branch: Created from ${k}`),{stdout:"",stderr:"",exitCode:0}}let d=n.verbose||0,l=!n.remotes||n.all,u=n.remotes||n.all,m=[];if(l&&!a){let w=await X(s);if(w){let E=await Mt(s),x;if(E){let b=await ht(s);if(b?.headName){let k=be(b.headName);if(k==="detached HEAD"){let R=await Ur(s);x=`(no branch, rebasing detached HEAD ${R?z(R):"(null)"})`}else x=`(no branch, rebasing ${k})`}else x="(no branch)"}else{let b=await Ur(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${z(b)})`:x="(no branch)"}m.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(l){let w=await pe(s,"refs/heads");for(let E of w){let x=be(E.name);m.push({displayName:x,hash:E.hash,isCurrent:x===a,branchName:x})}}if(u){let w=await pe(s,"refs/remotes");for(let E of w){let x=E.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${x}`:x,hash:E.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(d===0)return{stdout:`${m.map(E=>E.isCurrent?`* ${E.displayName}`:` ${E.displayName}`).join(`
224
224
  `)}
225
- `,stderr:"",exitCode:0};let h=d>=1?await le(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let E=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=z(w.hash),k="";try{let C=await M(s,w.hash);k=ae(C.message)}catch{}let R="";if(h&&w.branchName){let C=await dn(s,h,w.branchName);if(C){let P=ic(C,d>=2);P&&(R=` ${P}`)}}g.push(`${E}${x} ${b}${R} ${k}`)}return{stdout:`${g.join(`
225
+ `,stderr:"",exitCode:0};let h=d>=1?await le(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let E=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=z(w.hash),k="";try{let C=await M(s,w.hash);k=ae(C.message)}catch{}let R="";if(h&&w.branchName){let C=await dn(s,h,w.branchName);if(C){let P=ac(C,d>=2);P&&(R=` ${P}`)}}g.push(`${E}${x} ${b}${R} ${k}`)}return{stdout:`${g.join(`
226
226
  `)}
227
- `,stderr:"",exitCode:0}}})}function Q(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Fu=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],Uu=["commitMsg","mergeMsg"],Bu=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],Wu=["onRefUpdate","onRefDelete","onObjectWrite"];function qu(...e){let t=e.filter(r=>r!=null);if(t.length===0)return{};if(t.length===1)return t[0];let n={};for(let r of Fu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(Q(a))return a}})}for(let r of Uu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(Q(a))return a}})}for(let r of Bu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o)try{await i(s)}catch{}})}for(let r of Wu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}re();Ye();Re();ie();je();ue();on();tt();function Oc(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[W.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:S().alias("b").describe("Create and switch to a new branch"),forceBranch:S().alias("B").describe("Create/reset and switch to a new branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:S().describe("Create a new orphan branch"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return $("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return $(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let l=lt(i,r.cwd),u=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return $("cannot specify both a revision and --ours/--theirs");let h=await $e(i,a,`invalid reference: ${a}`);if(v(h))return h;m=h.commit.tree}return n.ours||n.theirs?Us(i,u,l,n.theirs?3:2):Fs(i,u,l,m)}if(n.orphan)return n.branch?$("--orphan and -b are incompatible"):n.ours||n.theirs?$("--orphan and --ours/--theirs are incompatible"):a?zu(i,a,r.env,t):$("you must specify a branch to checkout");if(n.detach){let l=a??"HEAD",u=await $e(i,l,`invalid reference: ${l}`);return v(u)?u:Ic(i,l,u.hash,r.env,t)}if(!a)return $("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Vu(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Ku(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return $c(i,a,c,f,r.env,t);let d=await We(i,a);if(d){let l=await Ne(i,d);return Ic(i,a,l,r.env,t)}if(i.workTree){let l=await K(i),u=ms(l,a);if(u)return await it(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
228
- `)}})}async function Ku(e,t,n){let r=await _s(e);return r?$c(e,r.name,r.refName,r.hash,t,n):$("no previous branch")}async function zu(e,t,n,r){let o=`refs/heads/${t}`;if(await U(e,o))return $(`a branch named '${t}' already exists`);let i=await K(e),a=$n(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await M(e,c)).tree),await Ue(e,"HEAD",o),await mt(e);let d=await ln(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:J,isBranchCheckout:!0});let l="";return f&&(l=await Yn(e,f,i)),{stdout:l,stderr:`Switched to a new branch '${t}'
229
- ${d}`,exitCode:0}}async function Vu(e,t,n,r,o=!1){let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(Q(s))return _(s.message??"");let i=await Z(e),a=await X(e),c=`refs/heads/${t}`,f=await U(e,c);if(f&&!o)return $(`a branch named '${t}' already exists`);if(o){let g=await K(e),w=$n(g);if(w)return w}a&&await Y(e,c,a),await Ue(e,"HEAD",c),await mt(e);let d=await ln(e),l=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??J;a&&(f?f!==a&&await ne(e,n,c,f,a,"branch: Reset to HEAD"):await ne(e,n,c,null,a,"branch: Created from HEAD")),await ne(e,n,"HEAD",a,a??J,`checkout: moving from ${l} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??J,isBranchCheckout:!0});let u="";if(o&&a){let g=await K(e),w=await M(e,a);u=await Yn(e,w.tree,g)}let m=await le(e),h=await dn(e,m,t);h&&(u+=Vn(h));let p=f?`Switched to and reset branch '${t}'
227
+ `,stderr:"",exitCode:0}}})}function Q(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Uu=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],Bu=["commitMsg","mergeMsg"],Wu=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],qu=["onRefUpdate","onRefDelete","onObjectWrite"];function Ku(...e){let t=e.filter(r=>r!=null);if(t.length===0)return{};if(t.length===1)return t[0];let n={};for(let r of Uu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(Q(a))return a}})}for(let r of Bu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(Q(a))return a}})}for(let r of Wu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o)try{await i(s)}catch{}})}for(let r of qu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}re();Ye();Re();ie();je();ue();on();tt();function $c(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[W.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:S().alias("b").describe("Create and switch to a new branch"),forceBranch:S().alias("B").describe("Create/reset and switch to a new branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:S().describe("Create a new orphan branch"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return $("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return $(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let l=lt(i,r.cwd),u=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return $("cannot specify both a revision and --ours/--theirs");let h=await $e(i,a,`invalid reference: ${a}`);if(v(h))return h;m=h.commit.tree}return n.ours||n.theirs?Us(i,u,l,n.theirs?3:2):Fs(i,u,l,m)}if(n.orphan)return n.branch?$("--orphan and -b are incompatible"):n.ours||n.theirs?$("--orphan and --ours/--theirs are incompatible"):a?Vu(i,a,r.env,t):$("you must specify a branch to checkout");if(n.detach){let l=a??"HEAD",u=await $e(i,l,`invalid reference: ${l}`);return v(u)?u:Oc(i,l,u.hash,r.env,t)}if(!a)return $("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Yu(i,a,r.env,t,!!n.forceBranch);if(a==="-")return zu(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return Tc(i,a,c,f,r.env,t);let d=await We(i,a);if(d){let l=await Ne(i,d);return Oc(i,a,l,r.env,t)}if(i.workTree){let l=await K(i),u=ms(l,a);if(u)return await it(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
228
+ `)}})}async function zu(e,t,n){let r=await _s(e);return r?Tc(e,r.name,r.refName,r.hash,t,n):$("no previous branch")}async function Vu(e,t,n,r){let o=`refs/heads/${t}`;if(await U(e,o))return $(`a branch named '${t}' already exists`);let i=await K(e),a=$n(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await M(e,c)).tree),await Ue(e,"HEAD",o),await mt(e);let d=await ln(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:J,isBranchCheckout:!0});let l="";return f&&(l=await Yn(e,f,i)),{stdout:l,stderr:`Switched to a new branch '${t}'
229
+ ${d}`,exitCode:0}}async function Yu(e,t,n,r,o=!1){let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(Q(s))return _(s.message??"");let i=await Z(e),a=await X(e),c=`refs/heads/${t}`,f=await U(e,c);if(f&&!o)return $(`a branch named '${t}' already exists`);if(o){let g=await K(e),w=$n(g);if(w)return w}a&&await Y(e,c,a),await Ue(e,"HEAD",c),await mt(e);let d=await ln(e),l=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??J;a&&(f?f!==a&&await ne(e,n,c,f,a,"branch: Reset to HEAD"):await ne(e,n,c,null,a,"branch: Created from HEAD")),await ne(e,n,"HEAD",a,a??J,`checkout: moving from ${l} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??J,isBranchCheckout:!0});let u="";if(o&&a){let g=await K(e),w=await M(e,a);u=await Yn(e,w.tree,g)}let m=await le(e),h=await dn(e,m,t);h&&(u+=Vn(h));let p=f?`Switched to and reset branch '${t}'
230
230
  `:`Switched to a new branch '${t}'
231
- `;return{stdout:u,stderr:`${p}${d}`,exitCode:0}}async function $c(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return Q(i)?_(i.message??""):lr(e,t,n,r,o,s)}async function Ic(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return Q(s)?_(s.message??""):Tn(e,n,r,o,{detachAdviceTarget:t})}re();Re();re();function ai(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{buffer1:[0,0],buffer2:[0,r]}];if(r===0)return[{buffer1:[0,n],buffer2:[0,0]}];let{changedOld:o,changedNew:s}=oi(e,t);return Yu(o,n,s,r)}function Yu(e,t,n,r){let o=[],s=0,i=0;for(;s<t||i<r;){for(;s<t&&i<r&&!e[s]&&!n[i];)s++,i++;if(s>=t&&i>=r)break;let a=s,c=i;for(;s<t&&e[s];)s++;for(;i<r&&n[i];)i++;(s>a||i>c)&&o.push({buffer1:[a,s-a],buffer2:[c,i-c]})}return o}function Xu(e,t,n){let r=[];for(let c of ai(t,e))r.push({ab:"a",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});for(let c of ai(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,d=c.oStart+c.oLength,l=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>d)break;d=Math.max(d,u.oStart+u.oLength),l.push(u),a++}if(l.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of l){let E=w.oStart,x=E+w.oLength,b=w.abStart,k=b+w.abLength,R=u[w.ab];R.abMin=Math.min(b,R.abMin),R.abMax=Math.max(k,R.abMax),R.oMin=Math.min(E,R.oMin),R.oMax=Math.max(x,R.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(d-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(d-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,d),b:n.slice(p,g)})}s=d}return i(t.length),o}function Zu(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Xu(e,t,n),i=[],a=[];function c(){a.length&&(i.push({type:"ok",lines:a}),a=[])}for(let f of s)f.stable?a.push(...f.content):o&&Tc(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),em(Ju(i))}function Yr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,i="=".repeat(o),a=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,c=Zu(e,t,n),f=!1,d=[];for(let l of c)l.type==="ok"?d.push(...l.lines):(f=!0,d.push(s,...l.a,i,...l.b,a));return{conflict:f,result:d}}function Ju(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Qu(n));return t}function Qu(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Tc(t,n))return[e];let r=ai(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+a.buffer1[1],l=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(a.buffer2[0],l)}),s=d}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function em(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function Zn(e,t,n,r){let o=Yr(xt(e),xt(t),xt(n),{a:r.a,b:r.b,markerSize:r.markerSize}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(ci);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
231
+ `;return{stdout:u,stderr:`${p}${d}`,exitCode:0}}async function Tc(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return Q(i)?_(i.message??""):lr(e,t,n,r,o,s)}async function Oc(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return Q(s)?_(s.message??""):Tn(e,n,r,o,{detachAdviceTarget:t})}re();Re();re();function ci(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{buffer1:[0,0],buffer2:[0,r]}];if(r===0)return[{buffer1:[0,n],buffer2:[0,0]}];let{changedOld:o,changedNew:s}=ii(e,t);return Xu(o,n,s,r)}function Xu(e,t,n,r){let o=[],s=0,i=0;for(;s<t||i<r;){for(;s<t&&i<r&&!e[s]&&!n[i];)s++,i++;if(s>=t&&i>=r)break;let a=s,c=i;for(;s<t&&e[s];)s++;for(;i<r&&n[i];)i++;(s>a||i>c)&&o.push({buffer1:[a,s-a],buffer2:[c,i-c]})}return o}function Zu(e,t,n){let r=[];for(let c of ci(t,e))r.push({ab:"a",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});for(let c of ci(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,d=c.oStart+c.oLength,l=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>d)break;d=Math.max(d,u.oStart+u.oLength),l.push(u),a++}if(l.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of l){let E=w.oStart,x=E+w.oLength,b=w.abStart,k=b+w.abLength,R=u[w.ab];R.abMin=Math.min(b,R.abMin),R.abMax=Math.max(k,R.abMax),R.oMin=Math.min(E,R.oMin),R.oMax=Math.max(x,R.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(d-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(d-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,d),b:n.slice(p,g)})}s=d}return i(t.length),o}function Ju(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Zu(e,t,n),i=[],a=[];function c(){a.length&&(i.push({type:"ok",lines:a}),a=[])}for(let f of s)f.stable?a.push(...f.content):o&&Sc(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),tm(Qu(i))}function Yr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,i="=".repeat(o),a=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,c=Ju(e,t,n),f=!1,d=[];for(let l of c)l.type==="ok"?d.push(...l.lines):(f=!0,d.push(s,...l.a,i,...l.b,a));return{conflict:f,result:d}}function Qu(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...em(n));return t}function em(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Sc(t,n))return[e];let r=ci(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+a.buffer1[1],l=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(a.buffer2[0],l)}),s=d}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function tm(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function Zn(e,t,n,r){let o=Yr(xt(e),xt(t),xt(n),{a:r.a,b:r.b,markerSize:r.markerSize}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(fi);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
232
232
  `)}
233
233
  `:a.join(`
234
234
  `)}function xt(e){if(e==="")return[];let t=e.split(`
235
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ci(e){return e.endsWith("\0")?e.slice(0,-1):e}function Tc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Re();ie();rn();de();_n();Se();tt();Qt();var hr=new TextDecoder,Dn=new TextEncoder,Sc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Nt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await nm(e,t,n,r),f=await sm(e,s,i,a,c,o);return om(e,s,o,f)}async function Zr(e,t,n,r){let o=await Lt(e,t,n),s=await M(e,t),i=await M(e,n);if(o.length===0)return{...await Nt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await Nt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Nc(e,t,n,o,1);return{...await Nt(e,a,s.tree,i.tree,r),baseTree:a}}async function nm(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),i=await ce(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let d=o.get(f)??null,l=s.get(f)??null,u=i.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=l?{hash:l.hash,mode:l.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(d?1:0)|(l?2:0)|(u?4:0),w=d?.hash??null,E=l?.hash??null,x=u?.hash??null,b=0;w!==null&&w===E&&(b|=3),w!==null&&w===x&&(b|=5),E!==null&&E===x&&(b|=6);let k={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(rm(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function rm(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,i=r?.hash??null;return s===o&&i===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===i&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&i===null?(e.merged={result:null,clean:!0},!0):i===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&i!==o?(r?e.merged={result:{hash:i,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function sm(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,H]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:H.hash,oldMode:H.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:H.hash,oldMode:H.mode});for(let[A,H]of r)n.has(A)||a.push({path:A,status:"added",newHash:H.hash,newMode:H.mode});for(let[A,H]of o)n.has(A)||c.push({path:A,status:"added",newHash:H.hash,newMode:H.mode});let f=await nt(e,a),d=await nt(e,c);if(f.renames.length===0&&d.renames.length===0)return i;let l=new Map,u=new Map;for(let A of f.renames)l.set(A.oldPath,A);for(let A of d.renames)u.set(A.oldPath,A);let m=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&m.add(A);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,H,L=0){i.msgBuf.push({sortKey:A,subOrder:L,text:H})}for(let A of[...n.keys()].sort()){let H=l.get(A),L=u.get(A);if(!H&&!L)continue;let N=n.get(A);if(h.add(A),H&&L)if(h.add(H.newPath),h.add(L.newPath),H.newPath===L.newPath){let q=r.get(H.newPath),D=o.get(L.newPath);if(q.hash===D.hash)i.entries.push(gt(H.newPath,q));else{let F=fi(t,H.newPath);F.stages=[{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode},{hash:D.hash,mode:D.mode}],F.pathnames=[A,H.newPath,L.newPath],F.filemask=7,F.merged={result:null,clean:!1}}}else{let q=r.get(H.newPath),D=o.get(L.newPath),F=await Lc(e,N,q,D,s);F.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:H.newPath,theirsPath:L.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${H.newPath} in ${p} and to ${L.newPath} in ${g}.`),i.entries.push(gt(A,N,1)),i.entries.push(st(H.newPath,q.mode,F.hash,2)),i.entries.push(st(L.newPath,D.mode,F.hash,3)),i.worktreeBlobs.set(H.newPath,{hash:F.hash,mode:q.mode}),i.worktreeBlobs.set(L.newPath,{hash:F.hash,mode:D.mode})}else if(H){h.add(H.newPath);let q=o.get(A),D=r.get(H.newPath),F=m.has(H.newPath);if(q)if(F)await jc(e,i,H.newPath,A,N,D,q,r,o,!1,s);else if(q.hash===N.hash&&D.hash===N.hash)i.entries.push(gt(H.newPath,D));else if(q.hash===N.hash)i.entries.push(gt(H.newPath,D));else if(D.hash===N.hash)i.entries.push(st(H.newPath,D.mode,q.hash));else{let ee=fi(t,H.newPath);ee.stages=[{hash:N.hash,mode:N.mode},{hash:D.hash,mode:D.mode},{hash:q.hash,mode:q.mode}],ee.pathnames=[A,H.newPath,A],ee.filemask=7,ee.merged={result:null,clean:!1}}else{let ee=o.get(H.newPath);if(i.conflicts.push({path:H.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(H.newPath,`CONFLICT (rename/delete): ${A} renamed to ${H.newPath} in ${p}, but deleted in ${g}.`),ee){i.conflicts.push({path:H.newPath,reason:"add-add"}),w(H.newPath,`Auto-merging ${H.newPath}`,0),w(H.newPath,`CONFLICT (add/add): Merge conflict in ${H.newPath}`,1),i.entries.push(gt(H.newPath,D,2)),i.entries.push(gt(H.newPath,ee,3));let Pe=await Zs(e,D.hash,ee.hash,D.mode,s);i.worktreeBlobs.set(H.newPath,{hash:Pe,mode:D.mode})}else i.entries.push(st(H.newPath,N.mode,N.hash,1)),i.entries.push(gt(H.newPath,D,2)),i.worktreeBlobs.set(H.newPath,{hash:D.hash,mode:D.mode}),D.hash!==N.hash&&w(H.newPath,`CONFLICT (modify/delete): ${H.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${H.newPath} left in tree.`,1)}}else if(L){h.add(L.newPath);let q=r.get(A),D=o.get(L.newPath),F=m.has(L.newPath);if(q)if(F)await jc(e,i,L.newPath,A,N,q,D,r,o,!0,s);else if(q.hash===N.hash&&D.hash===N.hash)i.entries.push(gt(L.newPath,D));else if(q.hash===N.hash)i.entries.push(gt(L.newPath,D));else if(D.hash===N.hash)i.entries.push(st(L.newPath,D.mode,q.hash));else{let ee=fi(t,L.newPath);ee.stages=[{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode},{hash:D.hash,mode:D.mode}],ee.pathnames=[A,A,L.newPath],ee.filemask=7,ee.merged={result:null,clean:!1}}else{let ee=r.get(L.newPath);if(i.conflicts.push({path:L.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(L.newPath,`CONFLICT (rename/delete): ${A} renamed to ${L.newPath} in ${g}, but deleted in ${p}.`),ee){i.conflicts.push({path:L.newPath,reason:"add-add"}),w(L.newPath,`Auto-merging ${L.newPath}`,0),w(L.newPath,`CONFLICT (add/add): Merge conflict in ${L.newPath}`,1),i.entries.push(gt(L.newPath,ee,2)),i.entries.push(gt(L.newPath,D,3));let Pe=await Zs(e,ee.hash,D.hash,ee.mode,s);i.worktreeBlobs.set(L.newPath,{hash:Pe,mode:ee.mode})}else i.entries.push(st(L.newPath,N.mode,N.hash,1)),i.entries.push(gt(L.newPath,D,3)),i.worktreeBlobs.set(L.newPath,{hash:D.hash,mode:D.mode}),D.hash!==N.hash&&w(L.newPath,`CONFLICT (modify/delete): ${L.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${L.newPath} left in tree.`,1)}}}let E=new Set(f.renames.map(A=>A.newPath)),x=new Set(d.renames.map(A=>A.newPath)),b=Hc(n,r),k=Hc(n,o),R=vc(b,o,n),C=vc(k,r,n),P=Ac(f.renames,R),y=Ac(d.renames,C),I=Dc(P),O=Dc(y);for(let A of[...I.keys()])O.has(A)&&(I.delete(A),O.delete(A));let j=new Set(I.keys()),G=new Set(O.keys());if(O.size>0)for(let A of a){if(A.status!=="added"||E.has(A.path))continue;let H=Mc(A.path,O,j);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(r.has(H)){w(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=r.get(A.path),D=o.get(H)??n.get(H);i.entries.push(st(H,q.mode,q.hash,2)),D&&i.entries.push(st(H,D.mode,D.hash,3)),i.worktreeBlobs.set(H,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:H,reason:"add-add"}),w(H,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path);continue}let L=r.get(A.path);i.entries.push(st(H,L.mode,L.hash,2)),i.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),i.conflicts.push({path:H,reason:"directory-rename"}),w(H,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let N=t.get(A.path);N&&(N.merged={result:null,clean:!0}),h.add(A.path)}if(I.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let H=Mc(A.path,I,G);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(o.has(H)){w(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=o.get(A.path),D=r.get(H)??n.get(H);D&&i.entries.push(st(H,D.mode,D.hash,2)),i.entries.push(st(H,q.mode,q.hash,3)),i.worktreeBlobs.set(H,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:H,reason:"add-add"}),w(H,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path);continue}let L=o.get(A.path);i.entries.push(st(H,L.mode,L.hash,3)),i.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),i.conflicts.push({path:H,reason:"directory-rename"}),w(H,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${H}.`,1);let N=t.get(A.path);N&&(N.merged={result:null,clean:!0}),h.add(A.path)}let V=new Set(i.entries.map(A=>A.path));for(let A of V){let H=t.get(A);H&&(H.merged={result:null,clean:!0})}for(let A of h){if(V.has(A))continue;let H=t.get(A);if(!H||H.merged.clean)continue;H.filemask===7&&!H.pathConflict||(H.merged={result:null,clean:!0})}return i}function Hc(e,t){let n=new Set;for(let s of e.keys()){let i=Ct(s);for(;i;)n.add(i),i=Ct(i)}let r=new Set;for(let s of t.keys()){let i=Ct(s);for(;i;)r.add(i),i=Ct(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function vc(e,t,n){if(e.size===0)return e;let r=new Set;for(let o of t.keys()){if(n.has(o))continue;let s=Ct(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Ct(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Ct(s)}return r}function Ac(e,t){let n=new Map;for(let r of e){let o=Ct(r.oldPath),s=Ct(r.newPath),i=!0;for(;;){if(!i){let a=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let a=n.get(o);a||(a=new Map,n.set(o,a)),a.set(s,(a.get(s)??0)+1)}if(i=!1,!o||!s)break;o=Ct(o),s=Ct(s)}}return n}function Dc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function Mc(e,t,n){let r=Ct(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let i=e.slice(r.length+1);return s?`${s}/${i}`:i}r=Ct(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Ct(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function jc(e,t,n,r,o,s,i,a,c,f=!1,d){let l=f?a.get(n):c.get(n),u=f?i:s;if(l.hash===u.hash){t.entries.push(st(n,l.mode,l.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Lc(e,o,s,i,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(l.hash===h.hash)t.entries.push(st(n,l.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(gt(n,l,2)),t.entries.push(st(n,i.mode,h.hash,3));let p=await Zs(e,l.hash,h.hash,l.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:l.mode})}else{t.entries.push(st(n,s.mode,h.hash,2)),t.entries.push(gt(n,l,3));let p=await Zs(e,h.hash,l.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Lc(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(an(t.mode)||an(n.mode)||an(r.mode))return{hash:n.hash,conflict:!0};let a=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let d=xt(a),l=xt(c),u=xt(f),m=Yr(l,d,u);if(!m.conflict)return{hash:await li(e,m.result),conflict:!1};let h=o?.a??"HEAD",p=o?.b??"theirs",g=s?.oursPath?`${h}:${s.oursPath}`:h,w=s?.theirsPath?`${p}:${s.theirsPath}`:p,E=Zn(c,a,f,{a:g,b:w,markerSize:i??7});return{hash:await Ie(e,"blob",Dn.encode(E)),conflict:!0}}async function Zs(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=Zn(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Ie(e,"blob",Dn.encode(a))}function gt(e,t,n=0){return st(e,t.mode,t.hash,n)}function st(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Ce()}}async function om(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(ve(m,h.merged.result.hash,h.merged.result.mode));continue}await im(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),d=[],l=new Set;for(let m of o)m.stage===0&&(d.push(m),l.add(m.path));for(let[m,h]of a)l.has(m)||d.push(ve(m,h.hash,h.mode));d.sort((m,h)=>xe(m.path,h.path));let u=await De(e,d);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function im(e,t,n,r,o,s,i){let a=t.path,[c,f,d]=t.stages,l=c?.hash??null,u=f?.hash??null,m=d?.hash??null;if(u===null&&m!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(ve(a,l,c.mode,1)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(l===null&&u!==null&&m!==null){if(u===m){r.push(ve(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await oe(e,u),p=await oe(e,m);if(Te(h)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=xt(""),w=xt(h),E=xt(p),x=Yr(w,g,E,n);if(!x.conflict){let R=await li(e,x.result);r.push(ve(a,R,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3));let b=Zn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),k=await Ie(e,"blob",Dn.encode(b));i.set(a,{hash:k,mode:f.mode});return}if(l!==null&&u!==null&&m!==null){if(u===l){r.push(ve(a,m,d.mode));return}if(m===l){r.push(ve(a,u,f.mode));return}if(u===m){r.push(ve(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),an(c.mode)||an(f.mode)||an(d.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await oe(e,l),p=await oe(e,u),g=await oe(e,m);if(Te(p)||Te(g)||Te(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=xt(h),E=xt(p),x=xt(g),b=Yr(E,w,x,n);if(b.conflict){let k=t.pathnames[1],R=t.pathnames[2],C=k!==a||R!==a,P={path:a,reason:"content"};C&&(k!==a&&(P.oursOrigPath=k),R!==a&&(P.theirsOrigPath=R)),o.push(P),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3));let y=C?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",I=C?`${n?.b??"theirs"}:${R}`:n?.b??"theirs",O=Zn(p,h,g,{a:y,b:I}),j=await Ie(e,"blob",Dn.encode(O));i.set(a,{hash:j,mode:f.mode})}else{let k=await li(e,b.result);r.push(ve(a,k,f.mode))}return}}var am=200;async function Nc(e,t,n,r,o){let s=await Promise.all(r.map(async d=>({hash:d,timestamp:(await M(e,d)).committer.timestamp})));s.sort((d,l)=>d.timestamp-l.timestamp);let i=s.map(d=>d.hash),a=i[0],c=a,f=(await M(e,a)).tree;for(let d=1;d<i.length;d++){let l=i[d],u=(await M(e,l)).tree,m=null;if(o>=am)m=f;else{let g=await Lt(e,c,l);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await Nc(e,c,l,g,o+1)}let h=await Nt(e,m,f,u);f=await cm(e,h,o);let p=Xt({type:"commit",tree:f,parents:[c,l],author:Sc,committer:Sc,message:"merged common ancestors"});c=await Ie(e,"commit",p)}return f}async function cm(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let d=s(a.path,1);if(d){r.push({...d,stage:0});continue}}if(a.reason==="rename-rename"){let d=a.oursPath??a.path,l=a.theirsPath??a.path,u=s(a.path,1),m=s(d,2),h=s(l,3);if(m&&h){let p=hr.decode((await we(e,m.hash)).content),g=hr.decode((await we(e,h.hash)).content),w=u?hr.decode((await we(e,u.hash)).content):"",E=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",k=Zn(p,w,g,{a:`${x}:${d}`,o:i.o,b:`${b}:${l}`,markerSize:E}),R=await Ie(e,"blob",Dn.encode(k));r.push({path:d,mode:m.mode,hash:R,stage:0,stat:Ce()}),r.push({path:l,mode:h.mode,hash:R,stage:0,stat:Ce()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let d=hr.decode((await we(e,c.hash)).content),l=hr.decode((await we(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?hr.decode((await we(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,E=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=Zn(d,m,l,{a:w,o:i.o,b:E,markerSize:i.markerSize}),b=await Ie(e,"blob",Dn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Ce()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>xe(a.path,c.path)),De(e,r)}async function li(e,t){let n=t.map(ci);if(n.length===0)return Ie(e,"blob",Dn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
235
+ `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function fi(e){return e.endsWith("\0")?e.slice(0,-1):e}function Sc(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Re();ie();rn();de();_n();Se();tt();Qt();var hr=new TextDecoder,Dn=new TextEncoder,Hc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Nt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await rm(e,t,n,r),f=await om(e,s,i,a,c,o);return im(e,s,o,f)}async function Zr(e,t,n,r){let o=await Lt(e,t,n),s=await M(e,t),i=await M(e,n);if(o.length===0)return{...await Nt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await Nt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await _c(e,t,n,o,1);return{...await Nt(e,a,s.tree,i.tree,r),baseTree:a}}async function rm(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),i=await ce(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let d=o.get(f)??null,l=s.get(f)??null,u=i.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=l?{hash:l.hash,mode:l.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(d?1:0)|(l?2:0)|(u?4:0),w=d?.hash??null,E=l?.hash??null,x=u?.hash??null,b=0;w!==null&&w===E&&(b|=3),w!==null&&w===x&&(b|=5),E!==null&&E===x&&(b|=6);let k={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(sm(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function sm(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,i=r?.hash??null;return s===o&&i===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===i&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&i===null?(e.merged={result:null,clean:!0},!0):i===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&i!==o?(r?e.merged={result:{hash:i,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function om(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,H]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:H.hash,oldMode:H.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:H.hash,oldMode:H.mode});for(let[A,H]of r)n.has(A)||a.push({path:A,status:"added",newHash:H.hash,newMode:H.mode});for(let[A,H]of o)n.has(A)||c.push({path:A,status:"added",newHash:H.hash,newMode:H.mode});let f=await nt(e,a),d=await nt(e,c);if(f.renames.length===0&&d.renames.length===0)return i;let l=new Map,u=new Map;for(let A of f.renames)l.set(A.oldPath,A);for(let A of d.renames)u.set(A.oldPath,A);let m=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&m.add(A);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,H,L=0){i.msgBuf.push({sortKey:A,subOrder:L,text:H})}for(let A of[...n.keys()].sort()){let H=l.get(A),L=u.get(A);if(!H&&!L)continue;let N=n.get(A);if(h.add(A),H&&L)if(h.add(H.newPath),h.add(L.newPath),H.newPath===L.newPath){let q=r.get(H.newPath),D=o.get(L.newPath);if(q.hash===D.hash)i.entries.push(gt(H.newPath,q));else{let F=di(t,H.newPath);F.stages=[{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode},{hash:D.hash,mode:D.mode}],F.pathnames=[A,H.newPath,L.newPath],F.filemask=7,F.merged={result:null,clean:!1}}}else{let q=r.get(H.newPath),D=o.get(L.newPath),F=await Nc(e,N,q,D,s);F.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:H.newPath,theirsPath:L.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${H.newPath} in ${p} and to ${L.newPath} in ${g}.`),i.entries.push(gt(A,N,1)),i.entries.push(st(H.newPath,q.mode,F.hash,2)),i.entries.push(st(L.newPath,D.mode,F.hash,3)),i.worktreeBlobs.set(H.newPath,{hash:F.hash,mode:q.mode}),i.worktreeBlobs.set(L.newPath,{hash:F.hash,mode:D.mode})}else if(H){h.add(H.newPath);let q=o.get(A),D=r.get(H.newPath),F=m.has(H.newPath);if(q)if(F)await Gc(e,i,H.newPath,A,N,D,q,r,o,!1,s);else if(q.hash===N.hash&&D.hash===N.hash)i.entries.push(gt(H.newPath,D));else if(q.hash===N.hash)i.entries.push(gt(H.newPath,D));else if(D.hash===N.hash)i.entries.push(st(H.newPath,D.mode,q.hash));else{let ee=di(t,H.newPath);ee.stages=[{hash:N.hash,mode:N.mode},{hash:D.hash,mode:D.mode},{hash:q.hash,mode:q.mode}],ee.pathnames=[A,H.newPath,A],ee.filemask=7,ee.merged={result:null,clean:!1}}else{let ee=o.get(H.newPath);if(i.conflicts.push({path:H.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(H.newPath,`CONFLICT (rename/delete): ${A} renamed to ${H.newPath} in ${p}, but deleted in ${g}.`),ee){i.conflicts.push({path:H.newPath,reason:"add-add"}),w(H.newPath,`Auto-merging ${H.newPath}`,0),w(H.newPath,`CONFLICT (add/add): Merge conflict in ${H.newPath}`,1),i.entries.push(gt(H.newPath,D,2)),i.entries.push(gt(H.newPath,ee,3));let Pe=await Zs(e,D.hash,ee.hash,D.mode,s);i.worktreeBlobs.set(H.newPath,{hash:Pe,mode:D.mode})}else i.entries.push(st(H.newPath,N.mode,N.hash,1)),i.entries.push(gt(H.newPath,D,2)),i.worktreeBlobs.set(H.newPath,{hash:D.hash,mode:D.mode}),D.hash!==N.hash&&w(H.newPath,`CONFLICT (modify/delete): ${H.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${H.newPath} left in tree.`,1)}}else if(L){h.add(L.newPath);let q=r.get(A),D=o.get(L.newPath),F=m.has(L.newPath);if(q)if(F)await Gc(e,i,L.newPath,A,N,q,D,r,o,!0,s);else if(q.hash===N.hash&&D.hash===N.hash)i.entries.push(gt(L.newPath,D));else if(q.hash===N.hash)i.entries.push(gt(L.newPath,D));else if(D.hash===N.hash)i.entries.push(st(L.newPath,D.mode,q.hash));else{let ee=di(t,L.newPath);ee.stages=[{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode},{hash:D.hash,mode:D.mode}],ee.pathnames=[A,A,L.newPath],ee.filemask=7,ee.merged={result:null,clean:!1}}else{let ee=r.get(L.newPath);if(i.conflicts.push({path:L.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(L.newPath,`CONFLICT (rename/delete): ${A} renamed to ${L.newPath} in ${g}, but deleted in ${p}.`),ee){i.conflicts.push({path:L.newPath,reason:"add-add"}),w(L.newPath,`Auto-merging ${L.newPath}`,0),w(L.newPath,`CONFLICT (add/add): Merge conflict in ${L.newPath}`,1),i.entries.push(gt(L.newPath,ee,2)),i.entries.push(gt(L.newPath,D,3));let Pe=await Zs(e,ee.hash,D.hash,ee.mode,s);i.worktreeBlobs.set(L.newPath,{hash:Pe,mode:ee.mode})}else i.entries.push(st(L.newPath,N.mode,N.hash,1)),i.entries.push(gt(L.newPath,D,3)),i.worktreeBlobs.set(L.newPath,{hash:D.hash,mode:D.mode}),D.hash!==N.hash&&w(L.newPath,`CONFLICT (modify/delete): ${L.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${L.newPath} left in tree.`,1)}}}let E=new Set(f.renames.map(A=>A.newPath)),x=new Set(d.renames.map(A=>A.newPath)),b=vc(n,r),k=vc(n,o),R=Ac(b,o,n),C=Ac(k,r,n),P=Dc(f.renames,R),y=Dc(d.renames,C),I=Mc(P),O=Mc(y);for(let A of[...I.keys()])O.has(A)&&(I.delete(A),O.delete(A));let j=new Set(I.keys()),G=new Set(O.keys());if(O.size>0)for(let A of a){if(A.status!=="added"||E.has(A.path))continue;let H=jc(A.path,O,j);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(r.has(H)){w(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=r.get(A.path),D=o.get(H)??n.get(H);i.entries.push(st(H,q.mode,q.hash,2)),D&&i.entries.push(st(H,D.mode,D.hash,3)),i.worktreeBlobs.set(H,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:H,reason:"add-add"}),w(H,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path);continue}let L=r.get(A.path);i.entries.push(st(H,L.mode,L.hash,2)),i.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),i.conflicts.push({path:H,reason:"directory-rename"}),w(H,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let N=t.get(A.path);N&&(N.merged={result:null,clean:!0}),h.add(A.path)}if(I.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let H=jc(A.path,I,G);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(o.has(H)){w(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=o.get(A.path),D=r.get(H)??n.get(H);D&&i.entries.push(st(H,D.mode,D.hash,2)),i.entries.push(st(H,q.mode,q.hash,3)),i.worktreeBlobs.set(H,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:H,reason:"add-add"}),w(H,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path);continue}let L=o.get(A.path);i.entries.push(st(H,L.mode,L.hash,3)),i.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),i.conflicts.push({path:H,reason:"directory-rename"}),w(H,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${H}.`,1);let N=t.get(A.path);N&&(N.merged={result:null,clean:!0}),h.add(A.path)}let V=new Set(i.entries.map(A=>A.path));for(let A of V){let H=t.get(A);H&&(H.merged={result:null,clean:!0})}for(let A of h){if(V.has(A))continue;let H=t.get(A);if(!H||H.merged.clean)continue;H.filemask===7&&!H.pathConflict||(H.merged={result:null,clean:!0})}return i}function vc(e,t){let n=new Set;for(let s of e.keys()){let i=Ct(s);for(;i;)n.add(i),i=Ct(i)}let r=new Set;for(let s of t.keys()){let i=Ct(s);for(;i;)r.add(i),i=Ct(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Ac(e,t,n){if(e.size===0)return e;let r=new Set;for(let o of t.keys()){if(n.has(o))continue;let s=Ct(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Ct(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Ct(s)}return r}function Dc(e,t){let n=new Map;for(let r of e){let o=Ct(r.oldPath),s=Ct(r.newPath),i=!0;for(;;){if(!i){let a=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let a=n.get(o);a||(a=new Map,n.set(o,a)),a.set(s,(a.get(s)??0)+1)}if(i=!1,!o||!s)break;o=Ct(o),s=Ct(s)}}return n}function Mc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function jc(e,t,n){let r=Ct(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let i=e.slice(r.length+1);return s?`${s}/${i}`:i}r=Ct(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Ct(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Gc(e,t,n,r,o,s,i,a,c,f=!1,d){let l=f?a.get(n):c.get(n),u=f?i:s;if(l.hash===u.hash){t.entries.push(st(n,l.mode,l.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Nc(e,o,s,i,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(l.hash===h.hash)t.entries.push(st(n,l.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(gt(n,l,2)),t.entries.push(st(n,i.mode,h.hash,3));let p=await Zs(e,l.hash,h.hash,l.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:l.mode})}else{t.entries.push(st(n,s.mode,h.hash,2)),t.entries.push(gt(n,l,3));let p=await Zs(e,h.hash,l.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Nc(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(an(t.mode)||an(n.mode)||an(r.mode))return{hash:n.hash,conflict:!0};let a=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let d=xt(a),l=xt(c),u=xt(f),m=Yr(l,d,u);if(!m.conflict)return{hash:await ui(e,m.result),conflict:!1};let h=o?.a??"HEAD",p=o?.b??"theirs",g=s?.oursPath?`${h}:${s.oursPath}`:h,w=s?.theirsPath?`${p}:${s.theirsPath}`:p,E=Zn(c,a,f,{a:g,b:w,markerSize:i??7});return{hash:await Ie(e,"blob",Dn.encode(E)),conflict:!0}}async function Zs(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=Zn(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Ie(e,"blob",Dn.encode(a))}function gt(e,t,n=0){return st(e,t.mode,t.hash,n)}function st(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Ce()}}async function im(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(ve(m,h.merged.result.hash,h.merged.result.mode));continue}await am(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),d=[],l=new Set;for(let m of o)m.stage===0&&(d.push(m),l.add(m.path));for(let[m,h]of a)l.has(m)||d.push(ve(m,h.hash,h.mode));d.sort((m,h)=>xe(m.path,h.path));let u=await De(e,d);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function am(e,t,n,r,o,s,i){let a=t.path,[c,f,d]=t.stages,l=c?.hash??null,u=f?.hash??null,m=d?.hash??null;if(u===null&&m!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(ve(a,l,c.mode,1)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(l===null&&u!==null&&m!==null){if(u===m){r.push(ve(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await oe(e,u),p=await oe(e,m);if(Te(h)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=xt(""),w=xt(h),E=xt(p),x=Yr(w,g,E,n);if(!x.conflict){let R=await ui(e,x.result);r.push(ve(a,R,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3));let b=Zn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),k=await Ie(e,"blob",Dn.encode(b));i.set(a,{hash:k,mode:f.mode});return}if(l!==null&&u!==null&&m!==null){if(u===l){r.push(ve(a,m,d.mode));return}if(m===l){r.push(ve(a,u,f.mode));return}if(u===m){r.push(ve(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),an(c.mode)||an(f.mode)||an(d.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await oe(e,l),p=await oe(e,u),g=await oe(e,m);if(Te(p)||Te(g)||Te(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=xt(h),E=xt(p),x=xt(g),b=Yr(E,w,x,n);if(b.conflict){let k=t.pathnames[1],R=t.pathnames[2],C=k!==a||R!==a,P={path:a,reason:"content"};C&&(k!==a&&(P.oursOrigPath=k),R!==a&&(P.theirsOrigPath=R)),o.push(P),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(ve(a,l,c.mode,1)),r.push(ve(a,u,f.mode,2)),r.push(ve(a,m,d.mode,3));let y=C?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",I=C?`${n?.b??"theirs"}:${R}`:n?.b??"theirs",O=Zn(p,h,g,{a:y,b:I}),j=await Ie(e,"blob",Dn.encode(O));i.set(a,{hash:j,mode:f.mode})}else{let k=await ui(e,b.result);r.push(ve(a,k,f.mode))}return}}var cm=200;async function _c(e,t,n,r,o){let s=await Promise.all(r.map(async d=>({hash:d,timestamp:(await M(e,d)).committer.timestamp})));s.sort((d,l)=>d.timestamp-l.timestamp);let i=s.map(d=>d.hash),a=i[0],c=a,f=(await M(e,a)).tree;for(let d=1;d<i.length;d++){let l=i[d],u=(await M(e,l)).tree,m=null;if(o>=cm)m=f;else{let g=await Lt(e,c,l);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await _c(e,c,l,g,o+1)}let h=await Nt(e,m,f,u);f=await fm(e,h,o);let p=Xt({type:"commit",tree:f,parents:[c,l],author:Hc,committer:Hc,message:"merged common ancestors"});c=await Ie(e,"commit",p)}return f}async function fm(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let d=s(a.path,1);if(d){r.push({...d,stage:0});continue}}if(a.reason==="rename-rename"){let d=a.oursPath??a.path,l=a.theirsPath??a.path,u=s(a.path,1),m=s(d,2),h=s(l,3);if(m&&h){let p=hr.decode((await we(e,m.hash)).content),g=hr.decode((await we(e,h.hash)).content),w=u?hr.decode((await we(e,u.hash)).content):"",E=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",k=Zn(p,w,g,{a:`${x}:${d}`,o:i.o,b:`${b}:${l}`,markerSize:E}),R=await Ie(e,"blob",Dn.encode(k));r.push({path:d,mode:m.mode,hash:R,stage:0,stat:Ce()}),r.push({path:l,mode:h.mode,hash:R,stage:0,stat:Ce()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let d=hr.decode((await we(e,c.hash)).content),l=hr.decode((await we(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?hr.decode((await we(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,E=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=Zn(d,m,l,{a:w,o:i.o,b:E,markerSize:i.markerSize}),b=await Ie(e,"blob",Dn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Ce()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>xe(a.path,c.path)),De(e,r)}async function ui(e,t){let n=t.map(fi);if(n.length===0)return Ie(e,"blob",Dn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
236
236
  `):`${n.join(`
237
237
  `)}
238
- `;return Ie(e,"blob",Dn.encode(s))}function ve(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Ce()}}function fi(e,t){let n=e.get(t);return n||(n={path:t,stages:[null,null,null],pathnames:[t,t,t],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},e.set(t,n)),n}function Xr(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
238
+ `;return Ie(e,"blob",Dn.encode(s))}function ve(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Ce()}}function di(e,t){let n=e.get(t);return n||(n={path:t,stages:[null,null,null],pathnames:[t,t,t],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},e.set(t,n)),n}function Xr(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
239
239
  ${e.join(" ")}
240
240
  Merge with strategy ort failed.
241
241
  `;let c=e.map(d=>` ${d}`).join(`
@@ -250,7 +250,7 @@ ${i}
250
250
  ${a}
251
251
  Aborting
252
252
  fatal: ${n} failed
253
- `}function Gc(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
253
+ `}function Lc(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
254
254
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
255
255
  ${i}
256
256
  Please commit your changes or stash them before you ${n}.
@@ -260,13 +260,13 @@ ${i}
260
260
  Please move or remove them before you ${n}.
261
261
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
262
262
  ${s}
263
- `}async function mn(e,t,n,r){let o=await K(e),s=await ce(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Ae(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let E=s.get(g);(!E||E.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await di(e,o,s);let w=r.operationName??"merge",E=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Xr(g,w,E,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Wn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Os,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await di(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),E=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&E.length>0?x=Gc(w,E,p,g):E.length>0?x=Xr(E,p,g,"untracked","worktree"):x=Xr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Wn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await di(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),E=h.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),x=[];w.length>0&&x.push(Xr(w,p,g,"local","worktree")),E.length>0&&x.push(Xr(E,p,g,"untracked","worktree"));let b;return x.length>1?b=Gc(w,E,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await He(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...a,...f];d.sort((h,p)=>xe(h.path,p.path)||h.stage-p.stage);let l={version:2,entries:d};await se(e,l);let u=d.filter(h=>h.stage===0),m=await De(e,u);return{ok:!0,finalIndex:l,mergedTreeHash:m}}async function di(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=T(e.workTree,r.path);await e.fs.exists(o)||await it(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();je();ue();Se();Qt();function _c(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[W.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:S().describe("Abort the current cherry-pick operation"),continue:S().describe("Continue the cherry-pick after conflict resolution"),skip:S().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":S().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:te.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:S().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commit:null});if(Q(L))return{stdout:"",stderr:L.message??"",exitCode:1};let N=await dm(s,r.env);return N.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),N}if(n.continue){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commit:null});if(Q(L))return{stdout:"",stderr:L.message??"",exitCode:1};let N=await lm(s,r.env);return N.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),N}if(n.skip)return fm(s,r.env);let i=n.commit;if(!i)return $("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:i});if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await $e(s,i);if(v(c))return c;let f=c.hash,d=c.commit,l=await Ve(s);if(v(l))return l;let u=await K(s);if(n.noCommit){let L=u.entries.filter(N=>N.stage>0);if(L.length>0){let D=L.slice(0,10).map(ee=>`${ee.path}: unmerged (${ee.hash})`).join(`
263
+ `}async function mn(e,t,n,r){let o=await K(e),s=await ce(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Ae(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let E=s.get(g);(!E||E.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await li(e,o,s);let w=r.operationName??"merge",E=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Xr(g,w,E,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Wn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Os,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await li(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),E=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&E.length>0?x=Lc(w,E,p,g):E.length>0?x=Xr(E,p,g,"untracked","worktree"):x=Xr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Wn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:$s,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await li(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),E=h.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),x=[];w.length>0&&x.push(Xr(w,p,g,"local","worktree")),E.length>0&&x.push(Xr(E,p,g,"untracked","worktree"));let b;return x.length>1?b=Lc(w,E,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await He(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...a,...f];d.sort((h,p)=>xe(h.path,p.path)||h.stage-p.stage);let l={version:2,entries:d};await se(e,l);let u=d.filter(h=>h.stage===0),m=await De(e,u);return{ok:!0,finalIndex:l,mergedTreeHash:m}}async function li(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=T(e.workTree,r.path);await e.fs.exists(o)||await it(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();je();ue();Se();Qt();function Fc(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[W.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:S().describe("Abort the current cherry-pick operation"),continue:S().describe("Continue the cherry-pick after conflict resolution"),skip:S().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":S().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:te.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:S().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commit:null});if(Q(L))return{stdout:"",stderr:L.message??"",exitCode:1};let N=await lm(s,r.env);return N.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),N}if(n.continue){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commit:null});if(Q(L))return{stdout:"",stderr:L.message??"",exitCode:1};let N=await um(s,r.env);return N.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),N}if(n.skip)return dm(s,r.env);let i=n.commit;if(!i)return $("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:i});if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await $e(s,i);if(v(c))return c;let f=c.hash,d=c.commit,l=await Ve(s);if(v(l))return l;let u=await K(s);if(n.noCommit){let L=u.entries.filter(N=>N.stage>0);if(L.length>0){let D=L.slice(0,10).map(ee=>`${ee.path}: unmerged (${ee.hash})`).join(`
264
264
  `),F=L.length>10?`
265
265
  ...`:"";return _(`${D}${F}
266
266
  error: your index file is unmerged.
267
267
  fatal: cherry-pick failed
268
268
  `,128)}}else{let L=fn(u,"Cherry-picking",`fatal: cherry-pick failed
269
- `);if(L)return L}let m=await M(s,l),p=!!n["record-origin"]?um(d.message,f):d.message;if(s.workTree&&!n.noCommit){let L=await ce(s,m.tree);if(ar(u,L))return _(`error: your local changes would be overwritten by cherry-pick.
269
+ `);if(L)return L}let m=await M(s,l),p=!!n["record-origin"]?mm(d.message,f):d.message;if(s.workTree&&!n.noCommit){let L=await ce(s,m.tree);if(ar(u,L))return _(`error: your local changes would be overwritten by cherry-pick.
270
270
  hint: commit your changes or stash them to proceed.
271
271
  fatal: cherry-pick failed
272
272
  `,128)}if(d.parents.length>1){if(!n.mainline)return _(`error: commit ${f} is a merge but no -m option was given.
@@ -302,41 +302,41 @@ hint: Disable this message with "git config set advice.mergeConflict false"
302
302
  `)[0]??"",O=y?.type==="symbolic"?y.target:"HEAD";await ne(s,r.env,O,l,P,`cherry-pick: ${I}`,y?.type==="symbolic");let j=y?.type==="symbolic"?be(y.target):"detached HEAD",G=m.tree,V=await nn(s,G,R,d.author,C,!0),A=Ht(j,P,p),H=b.messages.length>0?`${b.messages.join(`
303
303
  `)}
304
304
  `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${H}${A}
305
- ${V}`,stderr:"",exitCode:0}}})}async function fm(e,t){if(!await U(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
305
+ ${V}`,stderr:"",exitCode:0}}})}async function dm(e,t){if(!await U(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
306
306
  fatal: cherry-pick failed
307
307
  `,128);let r=await X(e);if(!r)return $("unable to resolve HEAD");let o=await M(e,r),s=await K(e),i=await Ss(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
308
308
  fatal: cherry-pick failed
309
- `}}return await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Wt(e),{stdout:"",stderr:"",exitCode:0}}async function dm(e,t){return await U(e,"CHERRY_PICK_HEAD")?Pn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
309
+ `}}return await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Wt(e),{stdout:"",stderr:"",exitCode:0}}async function lm(e,t){return await U(e,"CHERRY_PICK_HEAD")?Pn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
310
310
  fatal: cherry-pick failed
311
311
  `,128),operationName:"cherry-pick",clearState:Wt,origHeadAsTargetRev:!0}):await U(e,"REVERT_HEAD")?Pn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
312
312
  fatal: cherry-pick failed
313
313
  `,128),operationName:"cherry-pick",clearState:Dt,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
314
314
  fatal: cherry-pick failed
315
- `,128)}async function lm(e,t){let n=await U(e,"CHERRY_PICK_HEAD");if(!n)return _(`error: no cherry-pick or revert in progress
315
+ `,128)}async function um(e,t){let n=await U(e,"CHERRY_PICK_HEAD");if(!n)return _(`error: no cherry-pick or revert in progress
316
316
  fatal: cherry-pick failed
317
317
  `,128);let r=await K(e),o=fn(r,"Committing");if(o)return o;let s=await M(e,n),i=await ke(e,"MERGE_MSG");if(!i)return _(`Aborting commit due to empty commit message.
318
318
  `,1);let a=await ke(e,"SQUASH_MSG");a&&(i=a+i),i=tn(i);let c=Ae(r),f=await De(e,c),d=await Ve(e);if(v(d))return d;let u=(await M(e,d)).tree,m=await Ze(e,t);if(v(m))return m;let h=vt(i),p=await ut(e,f,[d],s.author,m,h);await Wt(e),await Dt(e),await he(e,"SQUASH_MSG");let g=await Z(e),w=ae(h),E=g?.type==="symbolic"?g.target:"HEAD";await ne(e,t,E,d,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?be(g.target):"detached HEAD",b=await nn(e,u,f,s.author,m,!0);return{stdout:`${Ht(x,p,i)}
319
- ${b}`,stderr:"",exitCode:0}}function um(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
319
+ ${b}`,stderr:"",exitCode:0}}function mm(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
320
320
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
321
321
  ${n}
322
322
  `:`${r}
323
323
 
324
324
  ${n}
325
- `}re();Ye();Is();Re();de();function Fc(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[W.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:S().alias("f").describe("Required to actually remove files"),"dry-run":S().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:S().alias("d").describe("Also remove untracked directories"),removeIgnored:S().alias("x").describe("Remove ignored files as well"),onlyIgnored:S().alias("X").describe("Remove only ignored files"),exclude:te.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,d=n.directories,l=n.removeIgnored,u=n.onlyIgnored,m=await t?.hooks?.preClean?.({repo:s,dryRun:c,force:f,removeDirs:d,removeIgnored:l,onlyIgnored:u});if(Q(m))return{stdout:"",stderr:m.message??"",exitCode:1};if(!f&&!c&&await _t(s,"clean.requireForce")!=="false")return $("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await K(s),p=new Set(h.entries.map(P=>P.path)),g=lt(s,r.cwd),w=n.pathspec,E=w.length>0?w.map(P=>Ge(P,g)):null,x=n.exclude?[n.exclude]:[],b=await Uc(s,a,"",{trackedPaths:p,removeDirs:d,removeIgnored:l,onlyIgnored:u,extraExcludes:x}),k;E?k=b.filter(P=>ye(E,P.path)):k=b,k.sort((P,y)=>P.path<y.path?-1:P.path>y.path?1:0);let R=[];if(c)for(let P of k){let y=P.isDir?`Would remove ${P.path}/`:`Would remove ${P.path}`;R.push(y)}else for(let P of k){let y=T(a,P.path);P.isDir?(await r.fs.rm(y,{recursive:!0}),R.push(`Removing ${P.path}/`)):(await r.fs.rm(y),R.push(`Removing ${P.path}`))}let C=R.length>0?`${R.join(`
325
+ `}re();Ye();Is();Re();de();function Uc(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[W.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:S().alias("f").describe("Required to actually remove files"),"dry-run":S().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:S().alias("d").describe("Also remove untracked directories"),removeIgnored:S().alias("x").describe("Remove ignored files as well"),onlyIgnored:S().alias("X").describe("Remove only ignored files"),exclude:te.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,d=n.directories,l=n.removeIgnored,u=n.onlyIgnored,m=await t?.hooks?.preClean?.({repo:s,dryRun:c,force:f,removeDirs:d,removeIgnored:l,onlyIgnored:u});if(Q(m))return{stdout:"",stderr:m.message??"",exitCode:1};if(!f&&!c&&await _t(s,"clean.requireForce")!=="false")return $("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await K(s),p=new Set(h.entries.map(P=>P.path)),g=lt(s,r.cwd),w=n.pathspec,E=w.length>0?w.map(P=>Ge(P,g)):null,x=n.exclude?[n.exclude]:[],b=await Bc(s,a,"",{trackedPaths:p,removeDirs:d,removeIgnored:l,onlyIgnored:u,extraExcludes:x}),k;E?k=b.filter(P=>ye(E,P.path)):k=b,k.sort((P,y)=>P.path<y.path?-1:P.path>y.path?1:0);let R=[];if(c)for(let P of k){let y=P.isDir?`Would remove ${P.path}/`:`Would remove ${P.path}`;R.push(y)}else for(let P of k){let y=T(a,P.path);P.isDir?(await r.fs.rm(y,{recursive:!0}),R.push(`Removing ${P.path}/`)):(await r.fs.rm(y),R.push(`Removing ${P.path}`))}let C=R.length>0?`${R.join(`
326
326
  `)}
327
- `:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(P=>P.path),dryRun:c}),{stdout:C,stderr:"",exitCode:0}}})}async function Uc(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await ir(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);i=Un(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
328
- `),d=Nr(f,"","<cli>");i={...i,dirPatterns:[d,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await e.fs.stat(f);if(l.isDirectory){let u=i&&Zt(i,d,!0)==="ignored",m=mm(r.trackedPaths,d),h=()=>Uc(e,f,d,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:d,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:d,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:d,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:d,isDir:!0})}}}else if(l.isFile){if(r.trackedPaths.has(d))continue;let u=i&&Zt(i,d,!1)==="ignored";r.onlyIgnored?u&&o.push({path:d,isDir:!1}):u&&s||o.push({path:d,isDir:!1})}}return o}function mm(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}re();Ye();hn();Re();ie();de();je();ue();En();Ye();En();dt();ie();var Qs=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),hm=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Js=64,pm=4,ui=4096,Bc=65536,gm=127;function wm(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=ym(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[u+h])^Qs[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=u+16;else{a=m;let h=m&o;i.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of i){let m=u.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(u)}for(let[u,m]of c){if(m.length<=Js)continue;let h=[],p=m.length/Js;for(let g=0;g<Js;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=Js}let f=new Uint32Array(r+1),d=[],l=0;for(let u=0;u<r;u++){f[u]=l;let m=c.get(u);if(m){for(let h of m)d.push(h);l+=m.length}}return f[r]=l,{src:e,hashMask:o,buckets:f,entries:d}}function bm(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=qc(i,a,r),a=qc(i,a,o),c(18),a++;let f=0,d=0,l=Math.min(16,o);for(let p=0;p<l;p++)i[a++]=t[p],f=(f<<8|t[p])^Qs[f>>>23],d++;f=f>>>0;let u=l,m=0,h=0;for(;u<o;){if(h<ui){f^=hm[t[u-16]],f=((f<<8|t[u])^Qs[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let E=g;E<w;E++){let x=e.entries[E];if(x.val!==f)continue;let b=x.ptr,k=s.byteLength-b,R=o-u;if(k>R&&(k=R),k<=h)break;let C=0;for(;C<k&&s[b+C]===t[u+C];)C++;if(C>h&&(h=C,m=b,h>=ui))break}}if(h<pm)c(2),d===0&&a++,i[a++]=t[u++],d++,d===gm&&(i[a-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--d>0)){a--,d=-1;break}d>0&&(i[a-d-1]=d),d=0}let p=h>Bc?h-Bc:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<ui){f=0;for(let E=-16;E<0;E++)f=(f<<8|t[u+E])^Qs[f>>>23];f=f>>>0}}if(n&&a>n)return null}return d>0&&(i[a-d-1]=d),n&&a>n?null:i.subarray(0,a)}var Wc={blob:0,tree:1,commit:2,tag:3};function eo(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let l=Wc[f.type]??99,u=Wc[d.type]??99;return l!==u?l-u:d.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],l={hash:d.hash,type:d.type,content:d.content,depth:0},u=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==d.type||(s.get(g.hash)?.depth??0)>=r||d.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=u?u.byteLength:d.content.byteLength/2|0;if(b<16)continue;let k=bm(x,d.content,b);k&&(!u||k.byteLength<u.byteLength)&&(u=k,m=g.hash)}if(u&&m){l.delta=u,l.deltaBase=m;let p=s.get(m);l.depth=(p?.depth??0)+1}s.set(d.hash,l),i.push(l),a.length>=n&&(a.shift(),c.shift()),a.push(wm(d.content)),c.push(d.hash)}return i}function ym(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function qc(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}Tr();ue();ie();rn();Ar();Rs();async function Em(e,t,n){let r=new Set;for(let i of n)await Jr(e,i,r);let o=[],s=new Set;for(let i of t)await Qr(e,i,r,s,o);return{count:o.length,objects:km(o)}}async function pr(e,t,n){let{count:r,objects:o}=await Em(e,t,n);return{count:r,objects:Rm(e,o)}}async function*km(e){for(let t of e)yield t}async function*Rm(e,t){for await(let n of t){let r=await we(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function gr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Jr(e,t,n){if(n.has(t)||(n.add(t),!await gn(e,t)))return;let r=await we(e,t);switch(r.type){case"commit":{let o=Yt(r.content);await Jr(e,o.tree,n);for(let s of o.parents)await Jr(e,s,n);break}case"tree":{let o=xn(r.content);for(let s of o.entries)await Jr(e,s.hash,n);break}case"tag":{let o=sn(r.content);await Jr(e,o.object,n);break}case"blob":break}}async function Qr(e,t,n,r,o){if(r.has(t)||n.has(t))return;r.add(t);let s=await we(e,t);switch(o.push({hash:t,type:s.type}),s.type){case"commit":{let i=Yt(s.content);await Qr(e,i.tree,n,r,o);for(let a of i.parents)await Qr(e,a,n,r,o);break}case"tree":{let i=xn(s.content);for(let a of i.entries)await Qr(e,a.hash,n,r,o);break}case"tag":{let i=sn(s.content);await Qr(e,i.object,n,r,o);break}case"blob":break}}var xm=new TextEncoder,to=new TextDecoder,Kc=65520,Cm=new Uint8Array([48,48,48,48]);function Jn(e){let t=typeof e=="string"?xm.encode(e):e,n=4+t.byteLength;if(n>Kc)throw new Error(`pkt-line too long: ${n} bytes (max ${Kc})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function mi(){return Cm.slice()}function no(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function wr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=to.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function ro(e){if(e.type==="flush")return"";let t=to.decode(e.data);return t.endsWith(`
329
- `)?t.slice(0,-1):t}var Pm=1,Im=2,Om=3;function hi(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case Pm:t.push(f),o+=f.byteLength;break;case Im:n.push(to.decode(f));break;case Om:r.push(to.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}dt();function pi(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function gi(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...pi(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let d=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(d))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=wr(c);return $m(f,t)}function $m(e,t){let n=0,r=e[n];r?.type==="data"&&ro(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),d;if(f!==-1){d=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else d=new TextDecoder().decode(c).replace(/\n$/,"");let l=d.indexOf(" ");if(l===-1)continue;let u=d.slice(0,l),m=d.slice(l+1);if(!(u===J&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=u);continue}o.push({name:m,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var Tm=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag"];async function zc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let i=Yc(r,Tm),a=[];a.push(Jn(`want ${t[0]} ${i.join(" ")}
327
+ `:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(P=>P.path),dryRun:c}),{stdout:C,stderr:"",exitCode:0}}})}async function Bc(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await ir(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);i=Un(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
328
+ `),d=Nr(f,"","<cli>");i={...i,dirPatterns:[d,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await e.fs.stat(f);if(l.isDirectory){let u=i&&Zt(i,d,!0)==="ignored",m=hm(r.trackedPaths,d),h=()=>Bc(e,f,d,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:d,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:d,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:d,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:d,isDir:!0})}}}else if(l.isFile){if(r.trackedPaths.has(d))continue;let u=i&&Zt(i,d,!1)==="ignored";r.onlyIgnored?u&&o.push({path:d,isDir:!1}):u&&s||o.push({path:d,isDir:!1})}}return o}function hm(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}re();Ye();hn();Re();ie();de();je();ue();En();Ye();En();dt();ie();var Qs=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),pm=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Js=64,gm=4,mi=4096,Wc=65536,wm=127;function bm(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=Em(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[u+h])^Qs[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=u+16;else{a=m;let h=m&o;i.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of i){let m=u.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(u)}for(let[u,m]of c){if(m.length<=Js)continue;let h=[],p=m.length/Js;for(let g=0;g<Js;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=Js}let f=new Uint32Array(r+1),d=[],l=0;for(let u=0;u<r;u++){f[u]=l;let m=c.get(u);if(m){for(let h of m)d.push(h);l+=m.length}}return f[r]=l,{src:e,hashMask:o,buckets:f,entries:d}}function ym(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=Kc(i,a,r),a=Kc(i,a,o),c(18),a++;let f=0,d=0,l=Math.min(16,o);for(let p=0;p<l;p++)i[a++]=t[p],f=(f<<8|t[p])^Qs[f>>>23],d++;f=f>>>0;let u=l,m=0,h=0;for(;u<o;){if(h<mi){f^=pm[t[u-16]],f=((f<<8|t[u])^Qs[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let E=g;E<w;E++){let x=e.entries[E];if(x.val!==f)continue;let b=x.ptr,k=s.byteLength-b,R=o-u;if(k>R&&(k=R),k<=h)break;let C=0;for(;C<k&&s[b+C]===t[u+C];)C++;if(C>h&&(h=C,m=b,h>=mi))break}}if(h<gm)c(2),d===0&&a++,i[a++]=t[u++],d++,d===wm&&(i[a-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--d>0)){a--,d=-1;break}d>0&&(i[a-d-1]=d),d=0}let p=h>Wc?h-Wc:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<mi){f=0;for(let E=-16;E<0;E++)f=(f<<8|t[u+E])^Qs[f>>>23];f=f>>>0}}if(n&&a>n)return null}return d>0&&(i[a-d-1]=d),n&&a>n?null:i.subarray(0,a)}var qc={blob:0,tree:1,commit:2,tag:3};function eo(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let l=qc[f.type]??99,u=qc[d.type]??99;return l!==u?l-u:d.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],l={hash:d.hash,type:d.type,content:d.content,depth:0},u=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==d.type||(s.get(g.hash)?.depth??0)>=r||d.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=u?u.byteLength:d.content.byteLength/2|0;if(b<16)continue;let k=ym(x,d.content,b);k&&(!u||k.byteLength<u.byteLength)&&(u=k,m=g.hash)}if(u&&m){l.delta=u,l.deltaBase=m;let p=s.get(m);l.depth=(p?.depth??0)+1}s.set(d.hash,l),i.push(l),a.length>=n&&(a.shift(),c.shift()),a.push(bm(d.content)),c.push(d.hash)}return i}function Em(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function Kc(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}Tr();ue();ie();rn();Ar();Rs();async function km(e,t,n){let r=new Set;for(let i of n)await Jr(e,i,r);let o=[],s=new Set;for(let i of t)await Qr(e,i,r,s,o);return{count:o.length,objects:Rm(o)}}async function pr(e,t,n){let{count:r,objects:o}=await km(e,t,n);return{count:r,objects:xm(e,o)}}async function*Rm(e){for(let t of e)yield t}async function*xm(e,t){for await(let n of t){let r=await we(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function gr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Jr(e,t,n){if(n.has(t)||(n.add(t),!await gn(e,t)))return;let r=await we(e,t);switch(r.type){case"commit":{let o=Yt(r.content);await Jr(e,o.tree,n);for(let s of o.parents)await Jr(e,s,n);break}case"tree":{let o=xn(r.content);for(let s of o.entries)await Jr(e,s.hash,n);break}case"tag":{let o=sn(r.content);await Jr(e,o.object,n);break}case"blob":break}}async function Qr(e,t,n,r,o){if(r.has(t)||n.has(t))return;r.add(t);let s=await we(e,t);switch(o.push({hash:t,type:s.type}),s.type){case"commit":{let i=Yt(s.content);await Qr(e,i.tree,n,r,o);for(let a of i.parents)await Qr(e,a,n,r,o);break}case"tree":{let i=xn(s.content);for(let a of i.entries)await Qr(e,a.hash,n,r,o);break}case"tag":{let i=sn(s.content);await Qr(e,i.object,n,r,o);break}case"blob":break}}var Cm=new TextEncoder,to=new TextDecoder,zc=65520,Pm=new Uint8Array([48,48,48,48]);function Jn(e){let t=typeof e=="string"?Cm.encode(e):e,n=4+t.byteLength;if(n>zc)throw new Error(`pkt-line too long: ${n} bytes (max ${zc})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function hi(){return Pm.slice()}function no(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function wr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=to.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function ro(e){if(e.type==="flush")return"";let t=to.decode(e.data);return t.endsWith(`
329
+ `)?t.slice(0,-1):t}var Im=1,Om=2,$m=3;function pi(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case Im:t.push(f),o+=f.byteLength;break;case Om:n.push(to.decode(f));break;case $m:r.push(to.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}dt();function gi(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function wi(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...gi(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let d=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(d))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=wr(c);return Tm(f,t)}function Tm(e,t){let n=0,r=e[n];r?.type==="data"&&ro(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),d;if(f!==-1){d=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else d=new TextDecoder().decode(c).replace(/\n$/,"");let l=d.indexOf(" ");if(l===-1)continue;let u=d.slice(0,l),m=d.slice(l+1);if(!(u===J&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=u);continue}o.push({name:m,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var Sm=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag"];async function Vc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let i=Xc(r,Sm),a=[];a.push(Jn(`want ${t[0]} ${i.join(" ")}
330
330
  `));for(let u=1;u<t.length;u++)a.push(Jn(`want ${t[u]}
331
- `));a.push(mi());for(let u of n)a.push(Jn(`have ${u}
331
+ `));a.push(hi());for(let u of n)a.push(Jn(`have ${u}
332
332
  `));a.push(Jn(`done
333
- `));let c=no(...a),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...pi(o),"User-Agent":"just-git/1.0"},body:c});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${f}`);let l=new Uint8Array(await d.arrayBuffer());return Sm(l,i.includes("side-band-64k"))}function Sm(e,t){let n=wr(e),r=[],o=0;for(let f=0;f<n.length;f++){let d=n[f];if(!d||d.type==="flush"){o=f+1;continue}if(d.type!=="data")continue;let l=ro(d);if(l.startsWith("ACK ")||l==="NAK")r.push(l),o=f+1;else{o=f;break}}let s=n.slice(o);if(t){let{packData:f,progress:d,errors:l}=hi(s);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);return{packData:f,acks:r,progress:d}}let i=0;for(let f of s)f.type==="data"&&(i+=f.data.byteLength);let a=new Uint8Array(i),c=0;for(let f of s)f.type==="data"&&(a.set(f.data,c),c+=f.data.byteLength);return{packData:a,acks:r,progress:[]}}var Hm=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Vc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=Yc(r,Hm),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Jn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
333
+ `));let c=no(...a),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...gi(o),"User-Agent":"just-git/1.0"},body:c});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${f}`);let l=new Uint8Array(await d.arrayBuffer());return Hm(l,i.includes("side-band-64k"))}function Hm(e,t){let n=wr(e),r=[],o=0;for(let f=0;f<n.length;f++){let d=n[f];if(!d||d.type==="flush"){o=f+1;continue}if(d.type!=="data")continue;let l=ro(d);if(l.startsWith("ACK ")||l==="NAK")r.push(l),o=f+1;else{o=f;break}}let s=n.slice(o);if(t){let{packData:f,progress:d,errors:l}=pi(s);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);return{packData:f,acks:r,progress:d}}let i=0;for(let f of s)f.type==="data"&&(i+=f.data.byteLength);let a=new Uint8Array(i),c=0;for(let f of s)f.type==="data"&&(a.set(f.data,c),c+=f.data.byteLength);return{packData:a,acks:r,progress:[]}}var vm=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Yc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=Xc(r,vm),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Jn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
334
334
  `));for(let h of f)a.push(Jn(`${h.oldHash} ${h.newHash} ${h.refName}
335
- `));a.push(mi());let d;if(n&&n.byteLength>0){let h=no(...a);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=no(...a);let l=e.replace(/\/+$/,""),u=await s(`${l}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...pi(o),"User-Agent":"just-git/1.0"},body:d});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${l}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?vm(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function vm(e,t){let n,r=[];if(t){let a=wr(e),{packData:c,progress:f,errors:d}=hi(a);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=wr(c)}else n=wr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=ro(a);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))i.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?i.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function Yc(e,t){let n=new Set(e.map(o=>o.split("=",1)[0]??o)),r=[];for(let o of t)n.has(o)&&r.push(o);return r.push("agent=just-git/1.0"),r}var es=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await pe(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await U(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Z(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n){let r=await this.advertiseRefs();if(t.length===0)return{remoteRefs:r,objectCount:0};let o=await wi(this.remote,t,n);if(!o)return{remoteRefs:r,objectCount:0};let s=await ys(this.local,o);return{remoteRefs:r,objectCount:s}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==J&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await wi(this.local,n,r);s&&await ys(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===J,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await un(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},ts=class{constructor(t,n,r,o){this.local=t;this.url=n;this.auth=r;this.fetchFn=o}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await gi(this.url,"git-upload-pack",this.auth,this.fetchFn);this.cachedFetchCaps=t.capabilities,this.cachedFetchRefs=t.refs;let n=t.symrefs.get("HEAD");return n&&(this.headTarget=n),t.refs}async ensureFetchDiscovery(){return(!this.cachedFetchCaps||!this.cachedFetchRefs)&&await this.advertiseRefs(),{caps:this.cachedFetchCaps,refs:this.cachedFetchRefs}}async ensurePushDiscovery(){if(!this.cachedPushCaps){let t=await gi(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n){let{caps:r,refs:o}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:o,objectCount:0};let s=await zc(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let i=await ys(this.local,s.packData);return{remoteRefs:o,objectCount:i}}async push(t){for(let d of t)if(d.oldHash&&d.oldHash!==J&&d.newHash!==J&&!d.ok&&!await un(this.local,d.oldHash,d.newHash))return{updates:t.map(u=>u===d?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(d=>({oldHash:d.oldHash??J,newHash:d.newHash,refName:d.name})),o=[],s=[],i=!1;for(let d of t)d.newHash!==J&&(o.push(d.newHash),i=!0),d.oldHash&&d.oldHash!==J&&s.push(d.oldHash);let a=null;i&&(a=await wi(this.local,o,s)??null);let c=await Vc(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(d=>{let l=c.refResults.find(h=>h.name===d.name),u=l?.ok??c.unpackOk,m=l?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...d,ok:u,error:m}})}}};async function wi(e,t,n){let r=await pr(e,t,n);if(r.count===0)return;let o=await gr(r),i=eo(o).map(c=>({hash:c.hash,type:c.type,content:c.content,delta:c.delta,deltaBaseHash:c.deltaBase})),{data:a}=await ws(i);return a}async function Am(e,t){let r=(await le(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function bi(e){return e.startsWith("http://")||e.startsWith("https://")}function Xc(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(bi(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function Dm(e){let t=e.get("GIT_HTTP_BEARER_TOKEN");if(t)return{type:"bearer",token:t};let n=e.get("GIT_HTTP_USER"),r=e.get("GIT_HTTP_PASSWORD");if(n&&r)return{type:"basic",username:n,password:r}}async function Zc(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return Dm(n)}async function Jc(e,t,n,r){if(bi(t)){let o=Xc(t,e.networkPolicy);if(o)throw new Error(o);let s=await Zc(e,t,n);return new ts(e,t,s,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(t)??void 0),!r)throw new Error(`'${t}' does not appear to be a git repository`);return new es(e,r)}async function br(e,t,n){let r=await Am(e,t);if(!r)return null;if(bi(r.url)){let s=Xc(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await Zc(e,r.url,n):void 0;return{transport:new ts(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await Nn(e.fs,r.url);return o?{transport:new es(e,o),config:r}:null}Se();tt();function Qc(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[W.string().name("repository").describe("Repository to clone"),W.string().name("directory").describe("Target directory").optional()],options:{bare:S().describe("Create a bare clone"),branch:te.string().alias("b").describe("Checkout this branch instead of HEAD")},handler:async(n,r)=>{let o=n.repository;if(!o)return $("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=s?o:It(r.cwd,o),a=n.branch,c=n.directory;if(!c){let I=s?o.split("/").pop()??o:Cr(i);I.endsWith(".git")&&(I=I.slice(0,-4)),c=I}let f=It(r.cwd,c),d=await t?.hooks?.preClone?.({repository:o,targetPath:f,bare:n.bare,branch:a??null});if(Q(d))return _(d.message??"");if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return $(`destination path '${c}' already exists and is not an empty directory.`)}catch{return $(`destination path '${c}' already exists and is not an empty directory.`)}let l=null;if(!s&&(t?.resolveRemote&&(l=await t.resolveRemote(i)),l||(l=await Nn(r.fs,i)),!l))return $(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await Es(r.fs,f,{bare:n.bare}),m=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:u,h=await le(m);h['remote "origin"']={url:i,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Qe(m,h);let p;try{p=await Jc(m,i,r.env,l??void 0)}catch(I){let O=I instanceof Error?I.message:"";return O.startsWith("network")?$(O):$(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:f,bare:n.bare,branch:a??null}),{stdout:"",stderr:`Cloning into '${c}'...
335
+ `));a.push(hi());let d;if(n&&n.byteLength>0){let h=no(...a);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=no(...a);let l=e.replace(/\/+$/,""),u=await s(`${l}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...gi(o),"User-Agent":"just-git/1.0"},body:d});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${l}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?Am(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Am(e,t){let n,r=[];if(t){let a=wr(e),{packData:c,progress:f,errors:d}=pi(a);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=wr(c)}else n=wr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=ro(a);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))i.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?i.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function Xc(e,t){let n=new Set(e.map(o=>o.split("=",1)[0]??o)),r=[];for(let o of t)n.has(o)&&r.push(o);return r.push("agent=just-git/1.0"),r}var es=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await pe(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await U(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Z(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n){let r=await this.advertiseRefs();if(t.length===0)return{remoteRefs:r,objectCount:0};let o=await bi(this.remote,t,n);if(!o)return{remoteRefs:r,objectCount:0};let s=await ys(this.local,o);return{remoteRefs:r,objectCount:s}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==J&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await bi(this.local,n,r);s&&await ys(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===J,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await un(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},ts=class{constructor(t,n,r,o){this.local=t;this.url=n;this.auth=r;this.fetchFn=o}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await wi(this.url,"git-upload-pack",this.auth,this.fetchFn);this.cachedFetchCaps=t.capabilities,this.cachedFetchRefs=t.refs;let n=t.symrefs.get("HEAD");return n&&(this.headTarget=n),t.refs}async ensureFetchDiscovery(){return(!this.cachedFetchCaps||!this.cachedFetchRefs)&&await this.advertiseRefs(),{caps:this.cachedFetchCaps,refs:this.cachedFetchRefs}}async ensurePushDiscovery(){if(!this.cachedPushCaps){let t=await wi(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n){let{caps:r,refs:o}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:o,objectCount:0};let s=await Vc(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let i=await ys(this.local,s.packData);return{remoteRefs:o,objectCount:i}}async push(t){for(let d of t)if(d.oldHash&&d.oldHash!==J&&d.newHash!==J&&!d.ok&&!await un(this.local,d.oldHash,d.newHash))return{updates:t.map(u=>u===d?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(d=>({oldHash:d.oldHash??J,newHash:d.newHash,refName:d.name})),o=[],s=[],i=!1;for(let d of t)d.newHash!==J&&(o.push(d.newHash),i=!0),d.oldHash&&d.oldHash!==J&&s.push(d.oldHash);let a=null;i&&(a=await bi(this.local,o,s)??null);let c=await Yc(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(d=>{let l=c.refResults.find(h=>h.name===d.name),u=l?.ok??c.unpackOk,m=l?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...d,ok:u,error:m}})}}};async function bi(e,t,n){let r=await pr(e,t,n);if(r.count===0)return;let o=await gr(r),i=eo(o).map(c=>({hash:c.hash,type:c.type,content:c.content,delta:c.delta,deltaBaseHash:c.deltaBase})),{data:a}=await ws(i);return a}async function Dm(e,t){let r=(await le(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function yi(e){return e.startsWith("http://")||e.startsWith("https://")}function Zc(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(yi(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function Mm(e){let t=e.get("GIT_HTTP_BEARER_TOKEN");if(t)return{type:"bearer",token:t};let n=e.get("GIT_HTTP_USER"),r=e.get("GIT_HTTP_PASSWORD");if(n&&r)return{type:"basic",username:n,password:r}}async function Jc(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return Mm(n)}async function Qc(e,t,n,r){if(yi(t)){let o=Zc(t,e.networkPolicy);if(o)throw new Error(o);let s=await Jc(e,t,n);return new ts(e,t,s,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(t)??void 0),!r)throw new Error(`'${t}' does not appear to be a git repository`);return new es(e,r)}async function br(e,t,n){let r=await Dm(e,t);if(!r)return null;if(yi(r.url)){let s=Zc(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await Jc(e,r.url,n):void 0;return{transport:new ts(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await Nn(e.fs,r.url);return o?{transport:new es(e,o),config:r}:null}Se();tt();function ef(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[W.string().name("repository").describe("Repository to clone"),W.string().name("directory").describe("Target directory").optional()],options:{bare:S().describe("Create a bare clone"),branch:te.string().alias("b").describe("Checkout this branch instead of HEAD")},handler:async(n,r)=>{let o=n.repository;if(!o)return $("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=s?o:It(r.cwd,o),a=n.branch,c=n.directory;if(!c){let I=s?o.split("/").pop()??o:Cr(i);I.endsWith(".git")&&(I=I.slice(0,-4)),c=I}let f=It(r.cwd,c),d=await t?.hooks?.preClone?.({repository:o,targetPath:f,bare:n.bare,branch:a??null});if(Q(d))return _(d.message??"");if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return $(`destination path '${c}' already exists and is not an empty directory.`)}catch{return $(`destination path '${c}' already exists and is not an empty directory.`)}let l=null;if(!s&&(t?.resolveRemote&&(l=await t.resolveRemote(i)),l||(l=await Nn(r.fs,i)),!l))return $(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await Es(r.fs,f,{bare:n.bare}),m=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:u,h=await le(m);h['remote "origin"']={url:i,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Qe(m,h);let p;try{p=await Qc(m,i,r.env,l??void 0)}catch(I){let O=I instanceof Error?I.message:"";return O.startsWith("network")?$(O):$(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:f,bare:n.bare,branch:a??null}),{stdout:"",stderr:`Cloning into '${c}'...
336
336
  warning: You appear to have cloned an empty repository.
337
337
  `,exitCode:0};let w=[],E=new Set;for(let I of g)I.name!=="HEAD"&&(E.has(I.hash)||(E.add(I.hash),w.push(I.hash)));w.length>0&&await p.fetch(w,[]);let x=g.find(I=>I.name==="HEAD"),b=null,k=null,R=await Vt(m,r.env),C=`clone: from ${i}`,P=p.headTarget;P?.startsWith("refs/heads/")&&g.some(I=>I.name===P)&&(b=P.slice(11),k=g.find(I=>I.name===P)?.hash??null);for(let I of g)if(I.name!=="HEAD"){if(I.name.startsWith("refs/heads/")){let O=I.name.slice(11),j=`refs/remotes/origin/${O}`;await Y(m,j,I.hash),await Be(m,j,{oldHash:J,newHash:I.hash,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:C}),!b&&x&&I.hash===x.hash&&(b=O,k=I.hash)}I.name.startsWith("refs/tags/")&&await Y(m,I.name,I.hash)}if(a){let I=g.find(O=>O.name===`refs/heads/${a}`);if(!I)return $(`Remote branch '${a}' not found in upstream origin`);b=a,k=I.hash}if(!b){let I=g.find(O=>O.name.startsWith("refs/heads/"));I&&(b=I.name.slice(11),k=I.hash)}if(n.bare)return b&&await Ue(m,"HEAD",`refs/heads/${b}`),await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:b}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
338
- `,exitCode:0};if(b&&await Ue(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&k){await Y(m,`refs/heads/${b}`,k),await Ue(m,"HEAD",`refs/heads/${b}`);let I={oldHash:J,newHash:k,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:C};await Be(m,`refs/heads/${b}`,I),await Be(m,"HEAD",I);let O=await le(m);O[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Qe(m,O);let j=await M(m,k);await Na(m,j.tree);let G=await qe(m,j.tree),V=hs(G.map(A=>({path:A.path,mode:parseInt(A.mode,8),hash:A.hash,stage:0,stat:Ce()})));await se(m,V)}let y={stdout:"",stderr:`Cloning into '${c}'...
339
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:b}),y}})}re();Re();ie();rn();de();je();ue();Se();tt();function ef(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:te.string().alias("m").describe("Commit message"),file:te.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:S().describe("Allow creating an empty commit"),amend:S().describe("Amend the previous commit"),noEdit:S().describe("Use the previous commit message without editing"),all:S().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return $("options '-m' and '-F' cannot be used together");let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await K(s);if(n.all){let ge=ze(s);if(ge)return ge;let Me=await Tt(s,i);for(let Je of Me)Je.status==="modified"?i=(await Jt(s,i,Je.path)).index:Je.status==="deleted"&&(i=ot(i,Je.path));let Pt=new Set(Ae(i).map(Je=>Je.path)),er=new Set(i.entries.filter(Je=>Je.stage>0&&!Pt.has(Je.path)).map(Je=>Je.path));for(let Je of er){let kr=T(s.workTree,Je);await r.fs.exists(kr)?i=(await Jt(s,i,Je)).index:i=ot(i,Je)}}let a=await U(s,"MERGE_HEAD"),c=await U(s,"CHERRY_PICK_HEAD"),f=await U(s,"REVERT_HEAD"),l=await Mt(s)?await U(s,"REBASE_HEAD"):null,u=n.amend,m=await X(s);if(u){if(!m)return $("You have nothing yet to amend.");if(a)return $("You are in the middle of a merge -- cannot amend.");if(c)return $("You are in the middle of a cherry-pick -- cannot amend.")}if($t(i)){let ge=new Set,Me=[];for(let Pt of i.entries)Pt.stage>0&&!ge.has(Pt.path)&&(ge.add(Pt.path),Me.push(`U ${Pt.path}`));return Me.sort(),{stdout:Me.length>0?`${Me.join(`
338
+ `,exitCode:0};if(b&&await Ue(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&k){await Y(m,`refs/heads/${b}`,k),await Ue(m,"HEAD",`refs/heads/${b}`);let I={oldHash:J,newHash:k,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:C};await Be(m,`refs/heads/${b}`,I),await Be(m,"HEAD",I);let O=await le(m);O[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Qe(m,O);let j=await M(m,k);await _a(m,j.tree);let G=await qe(m,j.tree),V=hs(G.map(A=>({path:A.path,mode:parseInt(A.mode,8),hash:A.hash,stage:0,stat:Ce()})));await se(m,V)}let y={stdout:"",stderr:`Cloning into '${c}'...
339
+ `,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:b}),y}})}re();Re();ie();rn();de();je();ue();Se();tt();function tf(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:te.string().alias("m").describe("Commit message"),file:te.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:S().describe("Allow creating an empty commit"),amend:S().describe("Amend the previous commit"),noEdit:S().describe("Use the previous commit message without editing"),all:S().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return $("options '-m' and '-F' cannot be used together");let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await K(s);if(n.all){let ge=ze(s);if(ge)return ge;let Me=await Tt(s,i);for(let Je of Me)Je.status==="modified"?i=(await Jt(s,i,Je.path)).index:Je.status==="deleted"&&(i=ot(i,Je.path));let Pt=new Set(Ae(i).map(Je=>Je.path)),er=new Set(i.entries.filter(Je=>Je.stage>0&&!Pt.has(Je.path)).map(Je=>Je.path));for(let Je of er){let kr=T(s.workTree,Je);await r.fs.exists(kr)?i=(await Jt(s,i,Je)).index:i=ot(i,Je)}}let a=await U(s,"MERGE_HEAD"),c=await U(s,"CHERRY_PICK_HEAD"),f=await U(s,"REVERT_HEAD"),l=await Mt(s)?await U(s,"REBASE_HEAD"):null,u=n.amend,m=await X(s);if(u){if(!m)return $("You have nothing yet to amend.");if(a)return $("You are in the middle of a merge -- cannot amend.");if(c)return $("You are in the middle of a cherry-pick -- cannot amend.")}if($t(i)){let ge=new Set,Me=[];for(let Pt of i.entries)Pt.stage>0&&!ge.has(Pt.path)&&(ge.add(Pt.path),Me.push(`U ${Pt.path}`));return Me.sort(),{stdout:Me.length>0?`${Me.join(`
340
340
  `)}
341
341
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
342
342
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
@@ -354,69 +354,69 @@ If you wish to commit it anyway, use:
354
354
 
355
355
  Otherwise, please use 'git cherry-pick --skip'
356
356
  `,exitCode:1}:{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let R=await en(s,r.env);if(v(R))return R;let C=await Ze(s,r.env);if(v(C))return C;u&&h&&(R.name=h.author.name,R.email=h.author.email,R.timestamp=h.author.timestamp,R.timezone=h.author.timezone),c&&(R=(await M(s,c)).author);let P=vt(p),y={repo:s,message:P},I=await t?.hooks?.commitMsg?.(y);if(Q(I))return _(I.message??"");P=y.message;let O;u&&h?O=[...h.parents]:(O=m?[m]:[],a&&O.push(a));let j=Xt({type:"commit",tree:w,parents:O,author:R,committer:C,message:P}),G=await Ie(s,"commit",j);await se(s,i);let V=await Z(s);V&&V.type==="symbolic"?await Y(s,V.target,G):await Y(s,"HEAD",G);let A=ae(P),H;u?H="commit (amend)":a?H="commit (merge)":c?H="commit (cherry-pick)":m?H="commit":H="commit (initial)";let L=`${H}: ${A}`,N=V?.type==="symbolic"?V.target:"HEAD";await ne(s,r.env,N,m,G,L,V?.type==="symbolic"),a&&await Fr(s),c&&await Wt(s),f&&await Dt(s),l&&await he(s,"MERGE_MSG"),await he(s,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:s,hash:G,message:P,branch:V?.type==="symbolic"?be(V.target):null,parents:O,author:R});let q=V?.type==="symbolic"?V.target:null,D=q?be(q):"detached HEAD",F;if(u&&h){let ge=h.parents[0];F=ge?(await M(s,ge)).tree:null}else F=m?(await M(s,m)).tree:null;let ee=R.timestamp!==C.timestamp||R.timezone!==C.timezone,Pe=O.length>1,Le=await nn(s,F,w,R,C,ee,Pe);return{stdout:`${Ht(D,G,p,O.length===0&&!u)}
357
- ${Le}`,stderr:"",exitCode:0}}})}re();Ye();function ns(e){let t=e.split(".");return t.length===2||t.length===3}function Mm(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,i]of Object.entries(r)){let a=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${a}=${i}`)}}return t}function sf(e,t){e.command("config",{description:"Get and set repository options",args:[W.string().name("positionals").variadic().optional()],options:{list:S().alias("l").describe("List all config entries"),unset:S().describe("Remove a config key")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return rf(await le(s));if(n.unset){let f=a;return f?ns(f)?nf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return rf(await le(s));if(a==="get"){let f=i[1];return f?ns(f)?tf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],d=i[2];return!f||d===void 0?_("error: missing key and/or value",2):ns(f)?(await ko(s,f,d),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?ns(f)?nf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!ns(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ko(s,a,c),{stdout:"",stderr:"",exitCode:0}):tf(s,a)}})}async function tf(e,t){let n=await _t(e,t);return n===void 0?_(""):{stdout:`${n}
358
- `,stderr:"",exitCode:0}}async function nf(e,t){return await Vi(e,t)?{stdout:"",stderr:"",exitCode:0}:_("",5)}function rf(e){let t=Mm(e);return{stdout:t.length>0?`${t.join(`
357
+ ${Le}`,stderr:"",exitCode:0}}})}re();Ye();function ns(e){let t=e.split(".");return t.length===2||t.length===3}function jm(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,i]of Object.entries(r)){let a=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${a}=${i}`)}}return t}function of(e,t){e.command("config",{description:"Get and set repository options",args:[W.string().name("positionals").variadic().optional()],options:{list:S().alias("l").describe("List all config entries"),unset:S().describe("Remove a config key")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return sf(await le(s));if(n.unset){let f=a;return f?ns(f)?rf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return sf(await le(s));if(a==="get"){let f=i[1];return f?ns(f)?nf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],d=i[2];return!f||d===void 0?_("error: missing key and/or value",2):ns(f)?(await ko(s,f,d),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?ns(f)?rf(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!ns(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ko(s,a,c),{stdout:"",stderr:"",exitCode:0}):nf(s,a)}})}async function nf(e,t){let n=await _t(e,t);return n===void 0?_(""):{stdout:`${n}
358
+ `,stderr:"",exitCode:0}}async function rf(e,t){return await Yi(e,t)?{stdout:"",stderr:"",exitCode:0}:_("",5)}function sf(e){let t=jm(e);return{stdout:t.length>0?`${t.join(`
359
359
  `)}
360
360
  `:"",stderr:"",exitCode:0}}re();function so(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(E=>E?z(E):"0000000"),c=o?z(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(E=>E===null),l=!f&&n.some(E=>E!==null);if(d&&s)i.push(`new file mode ${s}`);else if(l){let E=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${E}`)}else{let E=r.map(k=>k||"000000"),x=s||"000000";E.some(k=>k!==x)&&i.push(`mode ${E.join(",")}..${x}`)}let u=n.some(E=>E!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),l||d)return`${i.join(`
361
361
  `)}
362
- `;let m=e.parentContents.map(E=>E.length>0?jt(E):[]),h=e.resultContent.length>0?jt(e.resultContent):[],p=m.map(E=>ft(E,h)),g=jm(m,h,p),w=Lm(g,m.length,h);if(w.length===0)return"";for(let E of w)i.push(E);return`${i.join(`
362
+ `;let m=e.parentContents.map(E=>E.length>0?jt(E):[]),h=e.resultContent.length>0?jt(e.resultContent):[],p=m.map(E=>ft(E,h)),g=Gm(m,h,p),w=Nm(g,m.length,h);if(w.length===0)return"";for(let E of w)i.push(E);return`${i.join(`
363
363
  `)}
364
- `}function jm(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let d of i)if(d.type==="keep")a[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")a[d.newLineNo-1]="insert",f=d.newLineNo;else if(d.type==="delete"){let l=c.get(f)??[];l.push({text:d.line,parentLineNo:d.oldLineNo}),c.set(f,l)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let d=o[f];a.push(d?.deletions.get(i)??[])}let c=Gm(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],d=Array(r).fill(0);for(let l=0;l<r;l++){let m=o[l]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[l];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){d[l]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:d})}}return s}function Gm(e,t){if(!e.some(o=>o.length>0))return[];if(t===2){let o=e[0]??[],s=e[1]??[];if(o.length===0)return s.map(d=>({columns:[" ","-"],text:d.text,resultLineNo:0,parentLineNos:[0,d.parentLineNo]}));if(s.length===0)return o.map(d=>({columns:["-"," "],text:d.text,resultLineNo:0,parentLineNos:[d.parentLineNo,0]}));let i=o.map(d=>d.text),a=s.map(d=>d.text),c=ft(i,a),f=[];for(let d of c)if(d.type==="keep"){let l=o.find(m=>m.text===d.line&&m.parentLineNo===d.oldLineNo),u=s.find(m=>m.text===d.line&&m.parentLineNo===d.newLineNo);f.push({columns:["-","-"],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,u?.parentLineNo??0]})}else if(d.type==="delete"){let l=o.find(u=>u.parentLineNo===d.oldLineNo);f.push({columns:["-"," "],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,0]})}else if(d.type==="insert"){let l=s.find(u=>u.parentLineNo===d.newLineNo);f.push({columns:[" ","-"],text:d.line,resultLineNo:0,parentLineNos:[0,l?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function Lm(e,t,n){let o=[];for(let d=0;d<e.length;d++)e[d]?.columns.some(u=>u!==" ")&&o.push(d);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let d=1;d<o.length;d++){let l=o[d]??0,u=Math.max(0,l-3),m=Math.min(e.length-1,l+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let d of s){let l=e.slice(d.start,d.end+1),u=[];for(let b=0;b<t;b++){let k=l.filter(R=>(R.parentLineNos[b]??0)>0||R.columns[b]==="-");if(k.length===0)u.push({start:1,count:0});else{let C=k.find(P=>(P.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;u.push({start:C,count:k.length})}}let m=l.filter(b=>b.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let b=p-2;b>=0;b--){let k=n[b];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let E=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${E.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of l)f.push(`${b.columns.join("")}${b.text}`)}return f}re();Re();ie();de();function oo(e){let t=e.indexOf("...");if(t>=0)return{type:"three-dot",left:e.slice(0,t)||"HEAD",right:e.slice(t+3)||"HEAD"};let n=e.indexOf("..");return n>=0?{type:"two-dot",left:e.slice(0,n)||"HEAD",right:e.slice(n+2)||"HEAD"}:null}_n();ue();Se();tt();var yi=new TextDecoder;function ff(e){return"exitCode"in e}function yr(e){return e.toString(8).padStart(6,"0")}function df(e,t){let n=[];for(let r of e)n.push({path:r.path,status:r.status==="added"?"A":r.status==="deleted"?"D":"M",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode});for(let r of t)n.push({path:r.newPath,status:"R",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode,oldPath:r.oldPath,similarity:r.similarity});return n}function lf(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[W.string().name("commits").variadic().optional()],options:{cached:S().describe("Show staged changes (index vs HEAD)"),staged:S().describe("Synonym for --cached"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=lt(i,r.cwd),d=o.passthrough.length>0?o.passthrough.map(p=>Ge(p,f)):null,l=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,m=c.length===1?oo(c[0]):null;if(m){if(a)return $("too many arguments");m.type==="three-dot"?u=await Um(i,m.left,m.right,d):u=await cf(i,m.left,m.right,d)}else if(c.length===2)u=await cf(i,c[0],c[1],d);else{if(c.length>2)return $("too many arguments");a?u=await Fm(i,c.length===1?c[0]:null,d):c.length===1?u=await Bm(i,c[0],d):u=await Nm(i,d)}if(ff(u))return u;let h=await Wm(i,u.items,l);return u.stderr&&(h.stderr=u.stderr),h}})}async function Nm(e,t){let n=ze(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?i.set(d.path,d):d.stage===3&&a.set(d.path,d));let c=await Tt(e,r);c.sort((d,l)=>xe(d.path,l.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!ye(t,d.path)||o.has(d.path))continue;let l=s.get(d.path);if(!l)continue;let u=yr(l.mode),m;if(d.status==="modified"&&e.workTree){let h=T(e.workTree,d.path),p=await e.fs.readFileBuffer(h);m=await bt("blob",p)}f.push({path:d.path,status:d.status==="deleted"?"D":"M",oldHash:l.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:d.status==="modified"})}for(let d of o){if(t&&!ye(t,d))continue;let l=i.get(d),u=a.get(d);await _m(f,e,d,l,u)}return f.sort((d,l)=>{let u=xe(d.path,l.path);return u!==0?u:d.status==="U"&&l.status!=="U"?-1:d.status!=="U"&&l.status==="U"?1:0}),{items:f}}async function _m(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=yr(r.mode),a=yr(o.mode),{exists:c,hash:f}=await of(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),af(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=yr(r.mode),{exists:a,hash:c}=await of(t.fs,s,n);af(e,n,r.hash,i,a,c)}}async function of(e,t,n){let r=T(t,n);if(!await e.exists(r))return{exists:!1};let o=await jr(e,r);return{exists:!0,hash:await bt("blob",o)}}function af(e,t,n,r,o,s){o&&s&&s!==n?e.push({path:t,status:"M",oldHash:n,newHash:s,oldMode:r,newMode:r,newFromWorkTree:!0}):o||e.push({path:t,status:"D",oldHash:n,oldMode:r})}async function Fm(e,t,n){let r=null;if(t){let u=await $e(e,t);if(v(u))return u;r=u.commit.tree}else{let u=await X(e);u&&(r=(await M(e,u)).tree)}let o=await ce(e,r),s=await K(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(Ae(s).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(i.has(u))continue;let h=o.get(u);h?h.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:yr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:yr(m.mode)})}for(let[u,m]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await nt(e,c),l=df(f,d);for(let u of i)l.push({path:u,status:"U"});return l.sort((u,m)=>xe(u.path,m.path)),n?{items:l.filter(u=>ye(n,u.path))}:{items:l}}async function cf(e,t,n,r){let o=await $e(e,t);if(v(o))return o;let s=await $e(e,n);if(v(s))return s;let i=await _e(e,o.commit.tree,s.commit.tree);return uf(e,i,r)}async function Um(e,t,n,r){let o=await $e(e,t);if(v(o))return o;let s=await $e(e,n);if(v(s))return s;let i=await Lt(e,o.hash,s.hash);if(i.length===0)return $(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
365
- `);let c=i[0],f=await M(e,c),d=await _e(e,f.tree,s.commit.tree),l=await uf(e,d,r);return ff(l)||a&&(l.stderr=a),l}async function uf(e,t,n){let{remaining:r,renames:o}=await nt(e,t),s=df(r,o);return s.sort((i,a)=>xe(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function Bm(e,t,n){let r=ze(e);if(r)return r;let o=await $e(e,t);if(v(o))return o;let s=e.workTree,i=await ce(e,o.commit.tree),a=[];for(let[c,f]of i){if(n&&!ye(n,c))continue;let d=T(s,c);if(!await e.fs.exists(d)){a.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let l=await e.fs.readFileBuffer(d),u=await bt("blob",l);u!==f.hash&&a.push({path:c,status:"M",oldHash:f.hash,newHash:u,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return a.sort((c,f)=>xe(c.path,f.path)),{items:a}}async function Wm(e,t,n){let r;switch(n){case"stat":r=await Xm(e,t);break;case"shortstat":r=await Zm(e,t);break;case"numstat":r=await Ym(e,t);break;case"name-only":r=zm(t);break;case"name-status":r=Vm(t);break;default:r=await qm(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function qm(e,t){let n="",r=new Set,o=await Km(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let i=await Promise.all(s.combinedParentHashes.map(async f=>f?await oe(e,f):"")),a=await Ei(e,s);if(i.some(f=>Te(f))||Te(a)){let f=s.combinedParentHashes.map(d=>d?z(d):"0000000");n+=`diff --cc ${s.path}
364
+ `}function Gm(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let d of i)if(d.type==="keep")a[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")a[d.newLineNo-1]="insert",f=d.newLineNo;else if(d.type==="delete"){let l=c.get(f)??[];l.push({text:d.line,parentLineNo:d.oldLineNo}),c.set(f,l)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let d=o[f];a.push(d?.deletions.get(i)??[])}let c=Lm(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],d=Array(r).fill(0);for(let l=0;l<r;l++){let m=o[l]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[l];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){d[l]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:d})}}return s}function Lm(e,t){if(!e.some(o=>o.length>0))return[];if(t===2){let o=e[0]??[],s=e[1]??[];if(o.length===0)return s.map(d=>({columns:[" ","-"],text:d.text,resultLineNo:0,parentLineNos:[0,d.parentLineNo]}));if(s.length===0)return o.map(d=>({columns:["-"," "],text:d.text,resultLineNo:0,parentLineNos:[d.parentLineNo,0]}));let i=o.map(d=>d.text),a=s.map(d=>d.text),c=ft(i,a),f=[];for(let d of c)if(d.type==="keep"){let l=o.find(m=>m.text===d.line&&m.parentLineNo===d.oldLineNo),u=s.find(m=>m.text===d.line&&m.parentLineNo===d.newLineNo);f.push({columns:["-","-"],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,u?.parentLineNo??0]})}else if(d.type==="delete"){let l=o.find(u=>u.parentLineNo===d.oldLineNo);f.push({columns:["-"," "],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,0]})}else if(d.type==="insert"){let l=s.find(u=>u.parentLineNo===d.newLineNo);f.push({columns:[" ","-"],text:d.line,resultLineNo:0,parentLineNos:[0,l?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function Nm(e,t,n){let o=[];for(let d=0;d<e.length;d++)e[d]?.columns.some(u=>u!==" ")&&o.push(d);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let d=1;d<o.length;d++){let l=o[d]??0,u=Math.max(0,l-3),m=Math.min(e.length-1,l+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let d of s){let l=e.slice(d.start,d.end+1),u=[];for(let b=0;b<t;b++){let k=l.filter(R=>(R.parentLineNos[b]??0)>0||R.columns[b]==="-");if(k.length===0)u.push({start:1,count:0});else{let C=k.find(P=>(P.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;u.push({start:C,count:k.length})}}let m=l.filter(b=>b.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let b=p-2;b>=0;b--){let k=n[b];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let E=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${E.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of l)f.push(`${b.columns.join("")}${b.text}`)}return f}re();Re();ie();de();function oo(e){let t=e.indexOf("...");if(t>=0)return{type:"three-dot",left:e.slice(0,t)||"HEAD",right:e.slice(t+3)||"HEAD"};let n=e.indexOf("..");return n>=0?{type:"two-dot",left:e.slice(0,n)||"HEAD",right:e.slice(n+2)||"HEAD"}:null}_n();ue();Se();tt();var Ei=new TextDecoder;function df(e){return"exitCode"in e}function yr(e){return e.toString(8).padStart(6,"0")}function lf(e,t){let n=[];for(let r of e)n.push({path:r.path,status:r.status==="added"?"A":r.status==="deleted"?"D":"M",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode});for(let r of t)n.push({path:r.newPath,status:"R",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode,oldPath:r.oldPath,similarity:r.similarity});return n}function uf(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[W.string().name("commits").variadic().optional()],options:{cached:S().describe("Show staged changes (index vs HEAD)"),staged:S().describe("Synonym for --cached"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=lt(i,r.cwd),d=o.passthrough.length>0?o.passthrough.map(p=>Ge(p,f)):null,l=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,m=c.length===1?oo(c[0]):null;if(m){if(a)return $("too many arguments");m.type==="three-dot"?u=await Bm(i,m.left,m.right,d):u=await ff(i,m.left,m.right,d)}else if(c.length===2)u=await ff(i,c[0],c[1],d);else{if(c.length>2)return $("too many arguments");a?u=await Um(i,c.length===1?c[0]:null,d):c.length===1?u=await Wm(i,c[0],d):u=await _m(i,d)}if(df(u))return u;let h=await qm(i,u.items,l);return u.stderr&&(h.stderr=u.stderr),h}})}async function _m(e,t){let n=ze(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?i.set(d.path,d):d.stage===3&&a.set(d.path,d));let c=await Tt(e,r);c.sort((d,l)=>xe(d.path,l.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!ye(t,d.path)||o.has(d.path))continue;let l=s.get(d.path);if(!l)continue;let u=yr(l.mode),m;if(d.status==="modified"&&e.workTree){let h=T(e.workTree,d.path),p=await e.fs.readFileBuffer(h);m=await bt("blob",p)}f.push({path:d.path,status:d.status==="deleted"?"D":"M",oldHash:l.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:d.status==="modified"})}for(let d of o){if(t&&!ye(t,d))continue;let l=i.get(d),u=a.get(d);await Fm(f,e,d,l,u)}return f.sort((d,l)=>{let u=xe(d.path,l.path);return u!==0?u:d.status==="U"&&l.status!=="U"?-1:d.status!=="U"&&l.status==="U"?1:0}),{items:f}}async function Fm(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=yr(r.mode),a=yr(o.mode),{exists:c,hash:f}=await af(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),cf(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=yr(r.mode),{exists:a,hash:c}=await af(t.fs,s,n);cf(e,n,r.hash,i,a,c)}}async function af(e,t,n){let r=T(t,n);if(!await e.exists(r))return{exists:!1};let o=await Gr(e,r);return{exists:!0,hash:await bt("blob",o)}}function cf(e,t,n,r,o,s){o&&s&&s!==n?e.push({path:t,status:"M",oldHash:n,newHash:s,oldMode:r,newMode:r,newFromWorkTree:!0}):o||e.push({path:t,status:"D",oldHash:n,oldMode:r})}async function Um(e,t,n){let r=null;if(t){let u=await $e(e,t);if(v(u))return u;r=u.commit.tree}else{let u=await X(e);u&&(r=(await M(e,u)).tree)}let o=await ce(e,r),s=await K(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(Ae(s).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(i.has(u))continue;let h=o.get(u);h?h.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:yr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:yr(m.mode)})}for(let[u,m]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await nt(e,c),l=lf(f,d);for(let u of i)l.push({path:u,status:"U"});return l.sort((u,m)=>xe(u.path,m.path)),n?{items:l.filter(u=>ye(n,u.path))}:{items:l}}async function ff(e,t,n,r){let o=await $e(e,t);if(v(o))return o;let s=await $e(e,n);if(v(s))return s;let i=await _e(e,o.commit.tree,s.commit.tree);return mf(e,i,r)}async function Bm(e,t,n,r){let o=await $e(e,t);if(v(o))return o;let s=await $e(e,n);if(v(s))return s;let i=await Lt(e,o.hash,s.hash);if(i.length===0)return $(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
365
+ `);let c=i[0],f=await M(e,c),d=await _e(e,f.tree,s.commit.tree),l=await mf(e,d,r);return df(l)||a&&(l.stderr=a),l}async function mf(e,t,n){let{remaining:r,renames:o}=await nt(e,t),s=lf(r,o);return s.sort((i,a)=>xe(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function Wm(e,t,n){let r=ze(e);if(r)return r;let o=await $e(e,t);if(v(o))return o;let s=e.workTree,i=await ce(e,o.commit.tree),a=[];for(let[c,f]of i){if(n&&!ye(n,c))continue;let d=T(s,c);if(!await e.fs.exists(d)){a.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let l=await e.fs.readFileBuffer(d),u=await bt("blob",l);u!==f.hash&&a.push({path:c,status:"M",oldHash:f.hash,newHash:u,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return a.sort((c,f)=>xe(c.path,f.path)),{items:a}}async function qm(e,t,n){let r;switch(n){case"stat":r=await Zm(e,t);break;case"shortstat":r=await Jm(e,t);break;case"numstat":r=await Xm(e,t);break;case"name-only":r=Vm(t);break;case"name-status":r=Ym(t);break;default:r=await Km(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function Km(e,t){let n="",r=new Set,o=await zm(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let i=await Promise.all(s.combinedParentHashes.map(async f=>f?await oe(e,f):"")),a=await ki(e,s);if(i.some(f=>Te(f))||Te(a)){let f=s.combinedParentHashes.map(d=>d?z(d):"0000000");n+=`diff --cc ${s.path}
366
366
  index ${f.join(",")}..0000000
367
367
  Binary files differ
368
368
  `,r.add(s.path)}else{let f=so({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:i,resultHash:null,resultMode:s.newMode??null,resultContent:a});f?(n+=f,r.add(s.path)):n+=`* Unmerged path ${s.path}
369
369
  `}}else n+=`* Unmerged path ${s.path}
370
- `;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await oe(e,s.oldHash):"",a=await Ei(e,s);s.status==="R"&&s.oldPath?n+=Rt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:io(s.oldHash,o),newHash:io(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=Rt({path:s.path,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:io(s.oldHash,o),newHash:io(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function Km(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=T(e.gitDir,"objects",a),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,d),d},s=async(a,c)=>{let f=a.slice(0,2),d=a.slice(2,c),l=await o(f),u=0;for(let m of l)if(m.startsWith(d)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function io(e,t){if(e)return e.length!==40?e:t.get(e)??z(e)}function zm(e){let t="";for(let n of e)t+=`${n.path}
371
- `;return t}function Vm(e){let t="";for(let n of e)if(n.status==="R"){let r=String(n.similarity??100).padStart(3,"0");t+=`R${r} ${n.oldPath} ${n.path}
370
+ `;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await oe(e,s.oldHash):"",a=await ki(e,s);s.status==="R"&&s.oldPath?n+=Rt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:io(s.oldHash,o),newHash:io(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=Rt({path:s.path,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:io(s.oldHash,o),newHash:io(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function zm(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=T(e.gitDir,"objects",a),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,d),d},s=async(a,c)=>{let f=a.slice(0,2),d=a.slice(2,c),l=await o(f),u=0;for(let m of l)if(m.startsWith(d)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function io(e,t){if(e)return e.length!==40?e:t.get(e)??z(e)}function Vm(e){let t="";for(let n of e)t+=`${n.path}
371
+ `;return t}function Ym(e){let t="";for(let n of e)if(n.status==="R"){let r=String(n.similarity??100).padStart(3,"0");t+=`R${r} ${n.oldPath} ${n.path}
372
372
  `}else t+=`${n.status} ${n.path}
373
- `;return t}async function Ym(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
374
- `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await Ei(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:d}=mf(o,s);a=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=On(r.oldPath,r.path);n+=`${a} ${c} ${f}
373
+ `;return t}async function Xm(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
374
+ `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await ki(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:d}=hf(o,s);a=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=On(r.oldPath,r.path);n+=`${a} ${c} ${f}
375
375
  `}else n+=`${a} ${c} ${r.path}
376
- `}return n}async function Xm(e,t){let n=await hf(e,t);return Vr(n)}async function Zm(e,t){let n=await hf(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=mr(s,r,o);return i?`${i}
376
+ `}return n}async function Zm(e,t){let n=await pf(e,t);return Vr(n)}async function Jm(e,t){let n=await pf(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=mr(s,r,o);return i?`${i}
377
377
  `:n.some(a=>a.isUnmerged)?` 0 files changed
378
- `:""}async function Ei(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path),r=await jr(e.fs,n);return yi.decode(r)}return oe(e,t.newHash)}async function Jm(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path);return jr(e.fs,n)}return yt(e,t.newHash)}function mf(e,t){let n=qt(e),r=qt(t),o=ft(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function hf(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?On(r.oldPath,r.path):r.path,s=r.oldHash?await yt(e,r.oldHash):new Uint8Array(0),i=await Jm(e,r);if(wn(s)||wn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=yi.decode(s),c=yi.decode(i),{ins:f,del:d}=mf(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}re();Ye();hn();de();je();ue();function Qn(e){let t=e,n=!1;t.startsWith("+")&&(n=!0,t=t.slice(1));let r=t.indexOf(":");return r===-1?{force:n,src:t,dst:t}:{force:n,src:t.slice(0,r),dst:t.slice(r+1)}}function Qm(e,t){let n=e.indexOf("*");if(n===-1)return e===t;let r=e.slice(0,n),o=e.slice(n+1);return t.startsWith(r)&&t.endsWith(o)&&t.length>=r.length+o.length}function ao(e,t){if(!Qm(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function gf(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[W.string().name("remote").describe("Remote to fetch from").optional(),W.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:S().describe("Fetch from all remotes"),prune:S().alias("p").describe("Remove stale remote-tracking refs"),tags:S().describe("Also fetch tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.all){if(n.remote)return $("fetch --all does not take a remote argument");let a=await le(s),c=[];for(let l of Object.keys(a)){let u=l.match(/^remote "(.+)"$/);u?.[1]&&c.push(u[1])}if(c.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],d=0;for(let l of c){let u=await pf(s,l,void 0,n.prune,n.tags,r.env,t);u.stderr&&f.push(u.stderr),u.exitCode!==0&&(d=u.exitCode)}return{stdout:"",stderr:f.join(""),exitCode:d}}let i=n.remote||"origin";return pf(s,i,n.refspec,n.prune,n.tags,r.env,t)}})}async function pf(e,t,n,r,o,s,i){let a;try{a=await br(e,t,s)}catch(y){let I=y instanceof Error?y.message:"";if(I.startsWith("network"))return $(I);throw y}if(!a)return $(`'${t}' does not appear to be a git repository`);let{transport:c,config:f}=a,d;n&&n.length>0?d=n.map(Qn):d=[Qn(f.fetchRefspec)];let l=await i?.hooks?.preFetch?.({repo:e,remote:t,url:f.url,refspecs:d.map(y=>`${y.src}:${y.dst}`),prune:r,tags:o});if(Q(l))return{stdout:"",stderr:l.message??"",exitCode:1};let u=await c.advertiseRefs();if(u.length===0)return{stdout:"",stderr:"",exitCode:0};let h=(await pe(e)).map(y=>y.hash),p=await U(e,"HEAD");p&&h.push(p);let g=[],w=new Set,E=[];for(let y of u)if(y.name!=="HEAD")for(let I of d){let O=ao(I,y.name);if(O!==null){E.push({remote:y,localRef:O,force:I.force}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash));break}}if(o)for(let y of u)y.name.startsWith("refs/tags/")&&(E.push({remote:y,localRef:y.name,force:!1}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));let x=new Set(h),b=g.filter(y=>!x.has(y));b.length>0&&await c.fetch(b,h);let k=await Vt(e,s),R=[];R.push(`From ${f.url}
378
+ `:""}async function ki(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path),r=await Gr(e.fs,n);return Ei.decode(r)}return oe(e,t.newHash)}async function Qm(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path);return Gr(e.fs,n)}return yt(e,t.newHash)}function hf(e,t){let n=qt(e),r=qt(t),o=ft(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function pf(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?On(r.oldPath,r.path):r.path,s=r.oldHash?await yt(e,r.oldHash):new Uint8Array(0),i=await Qm(e,r);if(wn(s)||wn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=Ei.decode(s),c=Ei.decode(i),{ins:f,del:d}=hf(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}re();Ye();hn();de();je();ue();function Qn(e){let t=e,n=!1;t.startsWith("+")&&(n=!0,t=t.slice(1));let r=t.indexOf(":");return r===-1?{force:n,src:t,dst:t}:{force:n,src:t.slice(0,r),dst:t.slice(r+1)}}function eh(e,t){let n=e.indexOf("*");if(n===-1)return e===t;let r=e.slice(0,n),o=e.slice(n+1);return t.startsWith(r)&&t.endsWith(o)&&t.length>=r.length+o.length}function ao(e,t){if(!eh(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function wf(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[W.string().name("remote").describe("Remote to fetch from").optional(),W.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:S().describe("Fetch from all remotes"),prune:S().alias("p").describe("Remove stale remote-tracking refs"),tags:S().describe("Also fetch tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.all){if(n.remote)return $("fetch --all does not take a remote argument");let a=await le(s),c=[];for(let l of Object.keys(a)){let u=l.match(/^remote "(.+)"$/);u?.[1]&&c.push(u[1])}if(c.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],d=0;for(let l of c){let u=await gf(s,l,void 0,n.prune,n.tags,r.env,t);u.stderr&&f.push(u.stderr),u.exitCode!==0&&(d=u.exitCode)}return{stdout:"",stderr:f.join(""),exitCode:d}}let i=n.remote||"origin";return gf(s,i,n.refspec,n.prune,n.tags,r.env,t)}})}async function gf(e,t,n,r,o,s,i){let a;try{a=await br(e,t,s)}catch(y){let I=y instanceof Error?y.message:"";if(I.startsWith("network"))return $(I);throw y}if(!a)return $(`'${t}' does not appear to be a git repository`);let{transport:c,config:f}=a,d;n&&n.length>0?d=n.map(Qn):d=[Qn(f.fetchRefspec)];let l=await i?.hooks?.preFetch?.({repo:e,remote:t,url:f.url,refspecs:d.map(y=>`${y.src}:${y.dst}`),prune:r,tags:o});if(Q(l))return{stdout:"",stderr:l.message??"",exitCode:1};let u=await c.advertiseRefs();if(u.length===0)return{stdout:"",stderr:"",exitCode:0};let h=(await pe(e)).map(y=>y.hash),p=await U(e,"HEAD");p&&h.push(p);let g=[],w=new Set,E=[];for(let y of u)if(y.name!=="HEAD")for(let I of d){let O=ao(I,y.name);if(O!==null){E.push({remote:y,localRef:O,force:I.force}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash));break}}if(o)for(let y of u)y.name.startsWith("refs/tags/")&&(E.push({remote:y,localRef:y.name,force:!1}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));let x=new Set(h),b=g.filter(y=>!x.has(y));b.length>0&&await c.fetch(b,h);let k=await Vt(e,s),R=[];R.push(`From ${f.url}
379
379
  `);for(let y of E){let I=await U(e,y.localRef);await Y(e,y.localRef,y.remote.hash),await Be(e,y.localRef,{oldHash:I??J,newHash:y.remote.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:I?"fetch":"fetch: storing head"});let O=co(y.remote.name),j=co(y.localRef);if(I){if(I!==y.remote.hash){let G=z(I),V=z(y.remote.hash);R.push(` ${G}..${V} ${O} -> ${j}
380
380
  `)}}else{let V=y.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";R.push(`${V} ${O} -> ${j}
381
381
  `)}}if(!o)for(let y of u){if(!y.name.startsWith("refs/tags/")||w.has(y.hash))continue;let I=await U(e,y.name),O=y.peeledHash??y.hash;!I&&x.has(O)&&(await Y(e,y.name,y.hash),await Be(e,y.name,{oldHash:J,newHash:y.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:"fetch: storing head"}),R.push(` * [new tag] ${co(y.name)} -> ${co(y.name)}
382
382
  `))}if(r){let y=`refs/remotes/${t}`,I=await pe(e,y),O=new Set(u.filter(j=>j.name.startsWith("refs/heads/")).map(j=>j.name.slice(11)));for(let j of I){let G=j.name.slice(y.length+1);O.has(G)||(await fe(e,j.name),R.push(` - [deleted] (none) -> ${t}/${G}
383
383
  `))}}let C=u.find(y=>y.name==="HEAD");if(C){let y=T(e.gitDir,"FETCH_HEAD"),I=u.find(j=>j.name.startsWith("refs/heads/")&&j.hash===C.hash),O=I?`branch '${I.name.slice(11)}' of`:"of";await e.fs.writeFile(y,`${C.hash} ${O} ${f.url}
384
- `)}let P={stdout:"",stderr:R.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:f.url,refsUpdated:E.length}),P}function co(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}re();Re();ie();de();je();ue();re();Re();ie();de();je();ue();async function wf(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await pe(e,"refs");for(let a of r)t.add(a.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await bf(e,o,o,t);let s=await K(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await U(e,a);c&&t.add(c)}let i=[];for(let a of t)await gn(e,a)&&i.push(a);return i}async function bf(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=await e.fs.stat(i);if(a.isDirectory)await bf(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Xe(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}bs();Tr();de();async function eh(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(T(r,i)),c=new Ut(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?gr(await pr(e,t,[])):(await gr(await pr(e,t,[]))).filter(s=>!n.has(s.hash))}async function ki(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,i=e.depth??50;if(r.length===0)return null;let a=e.all?await gr(await pr(t,r,[])):await eh(t,r);if(a.length===0)return null;let c=a.length,f=eo(a,{window:s,depth:i}),d=f.filter(R=>R.delta).length,l=f.map(R=>({hash:R.hash,type:R.type,content:R.content,delta:R.delta,deltaBaseHash:R.deltaBase})),{data:u,entries:m}=await ws(l),h=await wa(u,m),p=u.subarray(u.byteLength-20),g="";for(let R=0;R<20;R++){let C=p[R];g+=(C>>4).toString(16)+(C&15).toString(16)}let w=T(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let E=`pack-${g}`,x=T(w,`${E}.pack`),b=T(w,`${E}.idx`);await n.writeFile(x,u),await n.writeFile(b,h);let k=new Set(f.map(R=>R.hash));if(t.objectStore.invalidatePacks?.(),o){let R=await n.readdir(w);for(let y of R){if(!y.endsWith(".idx"))continue;let I=y.slice(0,-4);if(I===E)continue;let O=T(w,`${I}.idx`),j=!0;try{let G=await n.readFileBuffer(O),V=new Ut(G);for(let A of V.allHashes())if(!k.has(A)){j=!1;break}}catch{j=!1}if(j){try{await n.rm(T(w,`${I}.pack`))}catch{}try{await n.rm(O)}catch{}}}let C=T(t.gitDir,"objects"),P;try{P=await n.readdir(C)}catch{P=[]}for(let y of P){if(y==="pack"||y==="info"||y.length!==2)continue;let I=T(C,y),O;try{O=await n.readdir(I)}catch{continue}for(let j of O){let G=`${y}${j}`;k.has(G)&&await n.rm(T(I,j))}try{(await n.readdir(I)).length===0&&await n.rm(I,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function Ri(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
385
- `)}function yf(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:S().alias("a").describe("Pack all objects, including already-packed"),delete:S().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await wf(s),a=await ki({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Ri(a.totalCount,a.deltaCount)}
384
+ `)}let P={stdout:"",stderr:R.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:f.url,refsUpdated:E.length}),P}function co(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}re();Re();ie();de();je();ue();re();Re();ie();de();je();ue();async function bf(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await pe(e,"refs");for(let a of r)t.add(a.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await yf(e,o,o,t);let s=await K(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await U(e,a);c&&t.add(c)}let i=[];for(let a of t)await gn(e,a)&&i.push(a);return i}async function yf(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=await e.fs.stat(i);if(a.isDirectory)await yf(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Xe(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}bs();Tr();de();async function th(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(T(r,i)),c=new Ut(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?gr(await pr(e,t,[])):(await gr(await pr(e,t,[]))).filter(s=>!n.has(s.hash))}async function Ri(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,i=e.depth??50;if(r.length===0)return null;let a=e.all?await gr(await pr(t,r,[])):await th(t,r);if(a.length===0)return null;let c=a.length,f=eo(a,{window:s,depth:i}),d=f.filter(R=>R.delta).length,l=f.map(R=>({hash:R.hash,type:R.type,content:R.content,delta:R.delta,deltaBaseHash:R.deltaBase})),{data:u,entries:m}=await ws(l),h=await ba(u,m),p=u.subarray(u.byteLength-20),g="";for(let R=0;R<20;R++){let C=p[R];g+=(C>>4).toString(16)+(C&15).toString(16)}let w=T(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let E=`pack-${g}`,x=T(w,`${E}.pack`),b=T(w,`${E}.idx`);await n.writeFile(x,u),await n.writeFile(b,h);let k=new Set(f.map(R=>R.hash));if(t.objectStore.invalidatePacks?.(),o){let R=await n.readdir(w);for(let y of R){if(!y.endsWith(".idx"))continue;let I=y.slice(0,-4);if(I===E)continue;let O=T(w,`${I}.idx`),j=!0;try{let G=await n.readFileBuffer(O),V=new Ut(G);for(let A of V.allHashes())if(!k.has(A)){j=!1;break}}catch{j=!1}if(j){try{await n.rm(T(w,`${I}.pack`))}catch{}try{await n.rm(O)}catch{}}}let C=T(t.gitDir,"objects"),P;try{P=await n.readdir(C)}catch{P=[]}for(let y of P){if(y==="pack"||y==="info"||y.length!==2)continue;let I=T(C,y),O;try{O=await n.readdir(I)}catch{continue}for(let j of O){let G=`${y}${j}`;k.has(G)&&await n.rm(T(I,j))}try{(await n.readdir(I)).length===0&&await n.rm(I,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function xi(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
385
+ `)}function Ef(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:S().alias("a").describe("Pack all objects, including already-packed"),delete:S().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await bf(s),a=await Ri({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${xi(a.totalCount,a.deltaCount)}
386
386
  `,exitCode:0}:{stdout:`Nothing new to pack.
387
- `,stderr:"",exitCode:0}}})}function Ef(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:S().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;await Ca(s),await mt(s);let i=await nh(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await ki({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await rh(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Ri(f.totalCount,f.deltaCount,!0)}
388
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var th=2160*60*60;async function nh(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await pe(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-th,i=T(e.gitDir,"logs");await e.fs.exists(i)&&await kf(e,i,i,s,t);let a=await K(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let d=await U(e,f);d&&t.add(d)}let c=[];for(let f of t)await gn(e,f)&&c.push(f);return c}async function kf(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=T(t,i),c=await e.fs.stat(a);if(c.isDirectory){await kf(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),d=await Xe(e,f);if(f==="refs/stash"){for(let u of d)u.newHash!==J&&o.add(u.newHash);continue}let l=d.filter(u=>u.timestamp>=r);await kn(e,f,l);for(let u of l)u.newHash!==J&&o.add(u.newHash)}}}async function rh(e,t){let n=T(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(T(n,o),{recursive:!0})}catch{}}de();En();function Rf(e){e.command("init",{description:"Initialize a new repository",args:[W.string().name("directory").describe("The directory to initialize").optional()],options:{bare:S().describe("Create a bare repository"),initialBranch:te.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(t,n)=>{let r=t.initialBranch,o=t.directory?It(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:i}=await Es(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),a="";i&&r&&(a=`warning: re-init: ignored --initial-branch=${r}
387
+ `,stderr:"",exitCode:0}}})}function kf(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:S().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;await Ia(s),await mt(s);let i=await rh(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await Ri({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await sh(s.gitDir,r.fs),f)return{stdout:"",stderr:`${xi(f.totalCount,f.deltaCount,!0)}
388
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var nh=2160*60*60;async function rh(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await pe(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-nh,i=T(e.gitDir,"logs");await e.fs.exists(i)&&await Rf(e,i,i,s,t);let a=await K(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let d=await U(e,f);d&&t.add(d)}let c=[];for(let f of t)await gn(e,f)&&c.push(f);return c}async function Rf(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=T(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Rf(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),d=await Xe(e,f);if(f==="refs/stash"){for(let u of d)u.newHash!==J&&o.add(u.newHash);continue}let l=d.filter(u=>u.timestamp>=r);await kn(e,f,l);for(let u of l)u.newHash!==J&&o.add(u.newHash)}}}async function sh(e,t){let n=T(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(T(n,o),{recursive:!0})}catch{}}de();En();function xf(e){e.command("init",{description:"Initialize a new repository",args:[W.string().name("directory").describe("The directory to initialize").optional()],options:{bare:S().describe("Create a bare repository"),initialBranch:te.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(t,n)=>{let r=t.initialBranch,o=t.directory?It(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:i}=await Es(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),a="";i&&r&&(a=`warning: re-init: ignored --initial-branch=${r}
389
389
  `);let c=t.bare?"bare ":"";return{stdout:`${i?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
390
- `,stderr:a,exitCode:0}}})}re();Kn();var fo=class{hash=null;parents=[];nParents=0;state=0;prevState=0;commitIdx=0;prevCommitIdx=0;mergeLayout=0;edgesAdded=0;prevEdgesAdded=0;w=0;expRow=0;cols=[];nCols=0;newCols=[];nNewCols=0;map=[];oldMap=[];mapSize=0;get width(){return this.w}update(t,n){this.hash=t,this.parents=n,this.nParents=n.length,this.prevCommitIdx=this.commitIdx,this.updateColumns(),this.expRow=0,this.state!==0?this.state=1:this.needsPreCommit()?this.state=2:this.state=3}nextLine(){let t,n=!1;switch(this.state){case 0:t=this.outPadding();break;case 1:t=this.outSkip();break;case 2:t=this.outPreCommit();break;case 3:t=this.outCommit(),n=!0;break;case 4:t=this.outPostMerge();break;case 5:t=this.outCollapsing();break}return{prefix:xf(t,this.w),isCommitLine:n}}isFinished(){return this.state===0}paddingPrefix(){if(this.state!==3)return this.nextLine().prefix;let t="";for(let n=0;n<this.nCols;n++)t+="| ";return this.prevState=0,xf(t,this.w)}updateColumns(){let t=this.newCols,n=this.nNewCols;this.newCols=this.cols,this.nNewCols=0,this.cols=t,this.nCols=n;let r=this.nCols+this.nParents;this.map.length<2*r&&(this.map=new Array(2*r),this.oldMap=new Array(2*r)),this.mapSize=2*r,this.map.fill(-1,0,this.mapSize),this.w=0,this.prevEdgesAdded=this.edgesAdded,this.edgesAdded=0;let o=!1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(o)break;i=this.hash}else i=this.cols[s];if(i===this.hash){o=!0,this.commitIdx=s,this.mergeLayout=-1;for(let a of this.parents)this.insertNewCol(a,s);this.nParents===0&&(this.w+=2)}else this.insertNewCol(i,-1)}for(;this.mapSize>1&&this.map[this.mapSize-1]<0;)this.mapSize--}findNewCol(t){for(let n=0;n<this.nNewCols;n++)if(this.newCols[n]===t)return n;return-1}insertNewCol(t,n){let r=this.findNewCol(t);r<0&&(r=this.nNewCols++,this.newCols[r]=t);let o;if(this.nParents>1&&n>-1&&this.mergeLayout===-1){let s=n-r,i=s>1?2*s-3:1;this.mergeLayout=s>0?0:1,this.edgesAdded=this.nParents+this.mergeLayout-2,o=this.w+(this.mergeLayout-1)*i,this.w+=2*this.mergeLayout}else this.edgesAdded>0&&this.w>=2&&r===this.map[this.w-2]?(o=this.w-2,this.edgesAdded=-1):(o=this.w,this.w+=2);this.map[o]=r}setState(t){this.prevState=this.state,this.state=t}numDashedParents(){return this.nParents+this.mergeLayout-3}numExpansionRows(){return this.numDashedParents()*2}needsPreCommit(){return this.nParents>=3&&this.commitIdx<this.nCols-1&&this.expRow<this.numExpansionRows()}isMappingCorrect(){for(let t=0;t<this.mapSize;t++){let n=this.map[t];if(!(n<0)&&n!==t>>1)return!1}return!0}outPadding(){let t="";for(let n=0;n<this.nNewCols;n++)t+="| ";return t}outSkip(){return this.needsPreCommit()?this.setState(2):this.setState(3),"..."}outPreCommit(){let t="",n=!1;for(let r=0;r<this.nCols;r++)this.cols[r]===this.hash?(n=!0,t+="|",t+=" ".repeat(this.expRow)):n&&this.expRow===0?this.prevState===4&&this.prevCommitIdx<r?t+="\\":t+="|":n?t+="\\":t+="|",t+=" ";return this.expRow++,this.needsPreCommit()||this.setState(3),t}outCommit(){let t="",n=!1;for(let r=0;r<=this.nCols;r++){let o;if(r===this.nCols){if(n)break;o=this.hash}else o=this.cols[r];o===this.hash?(n=!0,t+="*",this.nParents>2&&(t+=this.drawOctopus())):n&&this.edgesAdded>1?t+="\\":n&&this.edgesAdded===1?this.prevState===4&&this.prevEdgesAdded>0&&this.prevCommitIdx<r?t+="\\":t+="|":this.prevState===5&&this.oldMap[2*r+1]===r&&this.map[2*r]<r?t+="/":t+="|",t+=" "}return this.nParents>1?this.setState(4):this.isMappingCorrect()?this.setState(0):this.setState(5),t}drawOctopus(){let t=this.numDashedParents(),n="";for(let r=0;r<t;r++)n+="-",n+=r===t-1?".":"-";return n}outPostMerge(){let t=["/","|","\\"],n="",r=!1,o=-1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(r)break;i=this.hash}else i=this.cols[s];if(i===this.hash){r=!0;let a=this.mergeLayout;for(let c=0;c<this.nParents;c++)n+=t[a],a===2?(this.edgesAdded>0||c<this.nParents-1)&&(n+=" "):a++;this.edgesAdded===0&&(n+=" ")}else r?(this.edgesAdded>0?n+="\\":n+="|",n+=" "):(n+="|",(this.mergeLayout!==0||s!==this.commitIdx-1)&&(o>=0?n+="_":n+=" "));i===this.parents[0]&&(o=s)}return this.isMappingCorrect()?this.setState(0):this.setState(5),n}outCollapsing(){let t=this.map;this.map=this.oldMap,this.oldMap=t,this.map.fill(-1,0,this.mapSize);let n=-1,r=-1;for(let i=0;i<this.mapSize;i++){let a=this.oldMap[i];if(!(a<0)){if(a*2===i)this.map[i]=a;else if(this.map[i-1]<0){if(this.map[i-1]=a,n===-1){n=i,r=a;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}else if(this.map[i-1]!==a){if(this.map[i-2]=a,n===-1){r=a,n=i-1;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}}}for(let i=0;i<this.mapSize;i++)this.oldMap[i]=this.map[i];this.mapSize>0&&this.map[this.mapSize-1]<0&&this.mapSize--;let o="",s=!1;for(let i=0;i<this.mapSize;i++){let a=this.map[i];a<0?o+=" ":a*2===i?o+="|":a===r&&i!==n-1?(i!==a*2+3&&(this.map[i]=-1),s=!0,o+="_"):(s&&i<n&&(this.map[i]=-1),o+="/")}return this.isMappingCorrect()&&this.setState(0),o}};function xf(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}re();function Ci(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let i=e[s+1];if(i===void 0){o+="%",s++;continue}if((i==="a"||i==="c")&&s+2<e.length){let a=e[s+2],c=i==="a"?r.author:r.committer;switch(a){case"n":o+=c.name,s+=3;continue;case"e":case"E":o+=c.email,s+=3;continue;case"t":o+=c.timestamp.toString(),s+=3;continue;case"I":o+=dh(c.timestamp,c.timezone),s+=3;continue;case"i":o+=lh(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Gt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=uh(c.timestamp,c.timezone),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(z).join(" "),s+=2;continue;case"s":o+=xi(r.message),s+=2;continue;case"b":o+=sh(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
391
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var xi=ae;function sh(e){let t=e.indexOf(`
390
+ `,stderr:a,exitCode:0}}})}re();Kn();var fo=class{hash=null;parents=[];nParents=0;state=0;prevState=0;commitIdx=0;prevCommitIdx=0;mergeLayout=0;edgesAdded=0;prevEdgesAdded=0;w=0;expRow=0;cols=[];nCols=0;newCols=[];nNewCols=0;map=[];oldMap=[];mapSize=0;get width(){return this.w}update(t,n){this.hash=t,this.parents=n,this.nParents=n.length,this.prevCommitIdx=this.commitIdx,this.updateColumns(),this.expRow=0,this.state!==0?this.state=1:this.needsPreCommit()?this.state=2:this.state=3}nextLine(){let t,n=!1;switch(this.state){case 0:t=this.outPadding();break;case 1:t=this.outSkip();break;case 2:t=this.outPreCommit();break;case 3:t=this.outCommit(),n=!0;break;case 4:t=this.outPostMerge();break;case 5:t=this.outCollapsing();break}return{prefix:Cf(t,this.w),isCommitLine:n}}isFinished(){return this.state===0}paddingPrefix(){if(this.state!==3)return this.nextLine().prefix;let t="";for(let n=0;n<this.nCols;n++)t+="| ";return this.prevState=0,Cf(t,this.w)}updateColumns(){let t=this.newCols,n=this.nNewCols;this.newCols=this.cols,this.nNewCols=0,this.cols=t,this.nCols=n;let r=this.nCols+this.nParents;this.map.length<2*r&&(this.map=new Array(2*r),this.oldMap=new Array(2*r)),this.mapSize=2*r,this.map.fill(-1,0,this.mapSize),this.w=0,this.prevEdgesAdded=this.edgesAdded,this.edgesAdded=0;let o=!1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(o)break;i=this.hash}else i=this.cols[s];if(i===this.hash){o=!0,this.commitIdx=s,this.mergeLayout=-1;for(let a of this.parents)this.insertNewCol(a,s);this.nParents===0&&(this.w+=2)}else this.insertNewCol(i,-1)}for(;this.mapSize>1&&this.map[this.mapSize-1]<0;)this.mapSize--}findNewCol(t){for(let n=0;n<this.nNewCols;n++)if(this.newCols[n]===t)return n;return-1}insertNewCol(t,n){let r=this.findNewCol(t);r<0&&(r=this.nNewCols++,this.newCols[r]=t);let o;if(this.nParents>1&&n>-1&&this.mergeLayout===-1){let s=n-r,i=s>1?2*s-3:1;this.mergeLayout=s>0?0:1,this.edgesAdded=this.nParents+this.mergeLayout-2,o=this.w+(this.mergeLayout-1)*i,this.w+=2*this.mergeLayout}else this.edgesAdded>0&&this.w>=2&&r===this.map[this.w-2]?(o=this.w-2,this.edgesAdded=-1):(o=this.w,this.w+=2);this.map[o]=r}setState(t){this.prevState=this.state,this.state=t}numDashedParents(){return this.nParents+this.mergeLayout-3}numExpansionRows(){return this.numDashedParents()*2}needsPreCommit(){return this.nParents>=3&&this.commitIdx<this.nCols-1&&this.expRow<this.numExpansionRows()}isMappingCorrect(){for(let t=0;t<this.mapSize;t++){let n=this.map[t];if(!(n<0)&&n!==t>>1)return!1}return!0}outPadding(){let t="";for(let n=0;n<this.nNewCols;n++)t+="| ";return t}outSkip(){return this.needsPreCommit()?this.setState(2):this.setState(3),"..."}outPreCommit(){let t="",n=!1;for(let r=0;r<this.nCols;r++)this.cols[r]===this.hash?(n=!0,t+="|",t+=" ".repeat(this.expRow)):n&&this.expRow===0?this.prevState===4&&this.prevCommitIdx<r?t+="\\":t+="|":n?t+="\\":t+="|",t+=" ";return this.expRow++,this.needsPreCommit()||this.setState(3),t}outCommit(){let t="",n=!1;for(let r=0;r<=this.nCols;r++){let o;if(r===this.nCols){if(n)break;o=this.hash}else o=this.cols[r];o===this.hash?(n=!0,t+="*",this.nParents>2&&(t+=this.drawOctopus())):n&&this.edgesAdded>1?t+="\\":n&&this.edgesAdded===1?this.prevState===4&&this.prevEdgesAdded>0&&this.prevCommitIdx<r?t+="\\":t+="|":this.prevState===5&&this.oldMap[2*r+1]===r&&this.map[2*r]<r?t+="/":t+="|",t+=" "}return this.nParents>1?this.setState(4):this.isMappingCorrect()?this.setState(0):this.setState(5),t}drawOctopus(){let t=this.numDashedParents(),n="";for(let r=0;r<t;r++)n+="-",n+=r===t-1?".":"-";return n}outPostMerge(){let t=["/","|","\\"],n="",r=!1,o=-1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(r)break;i=this.hash}else i=this.cols[s];if(i===this.hash){r=!0;let a=this.mergeLayout;for(let c=0;c<this.nParents;c++)n+=t[a],a===2?(this.edgesAdded>0||c<this.nParents-1)&&(n+=" "):a++;this.edgesAdded===0&&(n+=" ")}else r?(this.edgesAdded>0?n+="\\":n+="|",n+=" "):(n+="|",(this.mergeLayout!==0||s!==this.commitIdx-1)&&(o>=0?n+="_":n+=" "));i===this.parents[0]&&(o=s)}return this.isMappingCorrect()?this.setState(0):this.setState(5),n}outCollapsing(){let t=this.map;this.map=this.oldMap,this.oldMap=t,this.map.fill(-1,0,this.mapSize);let n=-1,r=-1;for(let i=0;i<this.mapSize;i++){let a=this.oldMap[i];if(!(a<0)){if(a*2===i)this.map[i]=a;else if(this.map[i-1]<0){if(this.map[i-1]=a,n===-1){n=i,r=a;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}else if(this.map[i-1]!==a){if(this.map[i-2]=a,n===-1){r=a,n=i-1;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}}}for(let i=0;i<this.mapSize;i++)this.oldMap[i]=this.map[i];this.mapSize>0&&this.map[this.mapSize-1]<0&&this.mapSize--;let o="",s=!1;for(let i=0;i<this.mapSize;i++){let a=this.map[i];a<0?o+=" ":a*2===i?o+="|":a===r&&i!==n-1?(i!==a*2+3&&(this.map[i]=-1),s=!0,o+="_"):(s&&i<n&&(this.map[i]=-1),o+="/")}return this.isMappingCorrect()&&this.setState(0),o}};function Cf(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}re();function Pi(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let i=e[s+1];if(i===void 0){o+="%",s++;continue}if((i==="a"||i==="c")&&s+2<e.length){let a=e[s+2],c=i==="a"?r.author:r.committer;switch(a){case"n":o+=c.name,s+=3;continue;case"e":case"E":o+=c.email,s+=3;continue;case"t":o+=c.timestamp.toString(),s+=3;continue;case"I":o+=lh(c.timestamp,c.timezone),s+=3;continue;case"i":o+=uh(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Gt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=mh(c.timestamp,c.timezone),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(z).join(" "),s+=2;continue;case"s":o+=Ci(r.message),s+=2;continue;case"b":o+=oh(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
391
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Ci=ae;function oh(e){let t=e.indexOf(`
392
392
 
393
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Cf(e){return e.startsWith("format:")?{formatStr:e.slice(7),preset:null}:e.startsWith("tformat:")?{formatStr:e.slice(8),preset:null}:["oneline","short","medium","full","fuller"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function Pi(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?z(o):o,c=xi(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${xi(s.message)}`),a.join(`
393
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Pf(e){return e.startsWith("format:")?{formatStr:e.slice(7),preset:null}:e.startsWith("tformat:")?{formatStr:e.slice(8),preset:null}:["oneline","short","medium","full","fuller"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function Ii(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?z(o):o,c=Ci(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${Ci(s.message)}`),a.join(`
394
394
  `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
395
395
  `))a.push(` ${f}`);return a.join(`
396
396
  `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Gt(s.author.timestamp,s.author.timezone)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Gt(s.committer.timestamp,s.committer.timezone)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
397
397
  `))a.push(` ${f}`);return a.join(`
398
- `)}default:return oh(t,n)}}function oh(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(z).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Gt(r.author.timestamp,r.author.timezone)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
398
+ `)}default:return ih(t,n)}}function ih(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(z).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Gt(r.author.timestamp,r.author.timezone)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
399
399
  `))s.push(` ${a}`);return s.join(`
400
- `)}var ih=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ah=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ch(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function Ii(e,t){let n=ch(t);return new Date((e+n*60)*1e3)}function fh(e){return`${e.slice(0,3)}:${e.slice(3)}`}function dh(e,t){let n=Ii(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${i}:${a}:${c}${fh(t)}`}function lh(e,t){let n=Ii(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${i}:${a}:${c} ${t}`}function uh(e,t){let n=Ii(e,t),r=ih[n.getUTCDay()]?.slice(0,3),o=ah[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}ie();ue();on();Se();function Of(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[W.string().name("revisions").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of commits to output"),oneline:S().describe("Condense each commit to a single line"),all:S().describe("Walk all refs, not just HEAD"),author:te.string().describe("Filter by author (regex or substring)"),grep:te.string().describe("Filter by commit message (regex or substring)"),since:te.string().describe("Show commits after date"),after:te.string().describe("Synonym for --since"),until:te.string().describe("Show commits before date"),before:te.string().describe("Synonym for --until"),decorate:S().describe("Show ref names next to commit hashes"),reverse:S().describe("Output commits in reverse order"),format:te.string().describe("Pretty-print format string"),pretty:te.string().describe("Pretty-print format or preset name"),patch:S().alias("p").describe("Show diff in patch format"),stat:S().describe("Show diffstat summary"),nameStatus:S().describe("Show names and status of changed files"),nameOnly:S().describe("Show only names of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),graph:S().describe("Draw text-based graph of the commit history")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a,c,f=n.revisions,d=f&&f.length===1?oo(f[0]):null;if(d){let D=async Ke=>{let ge=await We(i,Ke);if(!ge)return Bt(Ke);try{return await Ne(i,ge)}catch{return Bt(Ke)}},F=await D(d.left);if(typeof F=="object"&&"exitCode"in F)return F;let ee=await D(d.right);if(typeof ee=="object"&&"exitCode"in ee)return ee;let Pe=F,Le=ee;if(d.type==="two-dot")a=[Le],c=[Pe];else{a=[Pe,Le];let Ke=await Lt(i,Pe,Le);c=Ke.length>0?Ke:void 0}if(n.all){let Ke=await pe(i);for(let Me of Ke)try{let Pt=await Ne(i,Me.hash);a.includes(Pt)||a.push(Pt)}catch{}let ge=await X(i);ge&&!a.includes(ge)&&a.push(ge)}}else if(n.all){let D=await pe(i),F=new Set;for(let Pe of D)try{F.add(await Ne(i,Pe.hash))}catch{}let ee=await X(i);ee&&F.add(ee),a=[...F]}else if(f&&f.length>0){let D=[];for(let F of f){let ee=await We(i,F);if(!ee)return Bt(F);try{D.push(await Ne(i,ee))}catch{return Bt(F)}}a=D}else{let D=await Ve(i);if(v(D))return D;a=[D]}if(a.length===0)return $("your current branch does not have any commits yet");let l=o.passthrough.length>0?o.passthrough.map(D=>Ge(D,"")):null,u=n.author?Pf(n.author):null,m=n.grep?Pf(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?ii(h):null,w=p?ii(p):null,E=n.format??n.pretty,x=null,b=null,k=!1;if(n.oneline)b="oneline",k=!0;else if(E!==void 0){let D=Cf(E);x=D.formatStr,b=D.preset}let R=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,C=n.graph;if(C&&n.reverse)return $("options '--graph' and '--reverse' cannot be used together");let y=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await ph(i):null,I=y?D=>If(y,D):void 0,O=y?D=>{let F=If(y,D);return F.startsWith("(")&&F.endsWith(")")?F.slice(1,-1):F}:void 0,j=n.maxCount,G=n.reverse,V=l?hh(i,a,l,c?await mh(i,c):void 0):At(i,a,{exclude:c,topoOrder:C}),A=[];for await(let D of V){if(j!==void 0&&A.length>=j)break;let{commit:F}=D;if(!(w!==null&&F.committer.timestamp>w)&&!(g!==null&&F.committer.timestamp<=g)){if(u){let ee=`${F.author.name} <${F.author.email}>`;if(!u(ee))continue}m&&!m(F.message)||A.push(D)}}let H=G?A.reverse():A;if(C)return gh(H,i,x,b,k,R,I,O);if(x!==null){let D=[];for(let F of H){let ee={hash:F.hash,commit:F.commit,decorations:I,decorationsRaw:O},Pe=Ci(x,ee),Le=await Oi(i,F.commit,R);Le&&(Pe+=`
400
+ `)}var ah=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ch=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function fh(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function Oi(e,t){let n=fh(t);return new Date((e+n*60)*1e3)}function dh(e){return`${e.slice(0,3)}:${e.slice(3)}`}function lh(e,t){let n=Oi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${i}:${a}:${c}${dh(t)}`}function uh(e,t){let n=Oi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${i}:${a}:${c} ${t}`}function mh(e,t){let n=Oi(e,t),r=ah[n.getUTCDay()]?.slice(0,3),o=ch[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}ie();ue();on();Se();function $f(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[W.string().name("revisions").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of commits to output"),oneline:S().describe("Condense each commit to a single line"),all:S().describe("Walk all refs, not just HEAD"),author:te.string().describe("Filter by author (regex or substring)"),grep:te.string().describe("Filter by commit message (regex or substring)"),since:te.string().describe("Show commits after date"),after:te.string().describe("Synonym for --since"),until:te.string().describe("Show commits before date"),before:te.string().describe("Synonym for --until"),decorate:S().describe("Show ref names next to commit hashes"),reverse:S().describe("Output commits in reverse order"),format:te.string().describe("Pretty-print format string"),pretty:te.string().describe("Pretty-print format or preset name"),patch:S().alias("p").describe("Show diff in patch format"),stat:S().describe("Show diffstat summary"),nameStatus:S().describe("Show names and status of changed files"),nameOnly:S().describe("Show only names of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),graph:S().describe("Draw text-based graph of the commit history")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a,c,f=n.revisions,d=f&&f.length===1?oo(f[0]):null;if(d){let D=async Ke=>{let ge=await We(i,Ke);if(!ge)return Bt(Ke);try{return await Ne(i,ge)}catch{return Bt(Ke)}},F=await D(d.left);if(typeof F=="object"&&"exitCode"in F)return F;let ee=await D(d.right);if(typeof ee=="object"&&"exitCode"in ee)return ee;let Pe=F,Le=ee;if(d.type==="two-dot")a=[Le],c=[Pe];else{a=[Pe,Le];let Ke=await Lt(i,Pe,Le);c=Ke.length>0?Ke:void 0}if(n.all){let Ke=await pe(i);for(let Me of Ke)try{let Pt=await Ne(i,Me.hash);a.includes(Pt)||a.push(Pt)}catch{}let ge=await X(i);ge&&!a.includes(ge)&&a.push(ge)}}else if(n.all){let D=await pe(i),F=new Set;for(let Pe of D)try{F.add(await Ne(i,Pe.hash))}catch{}let ee=await X(i);ee&&F.add(ee),a=[...F]}else if(f&&f.length>0){let D=[];for(let F of f){let ee=await We(i,F);if(!ee)return Bt(F);try{D.push(await Ne(i,ee))}catch{return Bt(F)}}a=D}else{let D=await Ve(i);if(v(D))return D;a=[D]}if(a.length===0)return $("your current branch does not have any commits yet");let l=o.passthrough.length>0?o.passthrough.map(D=>Ge(D,"")):null,u=n.author?If(n.author):null,m=n.grep?If(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?ai(h):null,w=p?ai(p):null,E=n.format??n.pretty,x=null,b=null,k=!1;if(n.oneline)b="oneline",k=!0;else if(E!==void 0){let D=Pf(E);x=D.formatStr,b=D.preset}let R=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,C=n.graph;if(C&&n.reverse)return $("options '--graph' and '--reverse' cannot be used together");let y=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await gh(i):null,I=y?D=>Of(y,D):void 0,O=y?D=>{let F=Of(y,D);return F.startsWith("(")&&F.endsWith(")")?F.slice(1,-1):F}:void 0,j=n.maxCount,G=n.reverse,V=l?ph(i,a,l,c?await hh(i,c):void 0):At(i,a,{exclude:c,topoOrder:C}),A=[];for await(let D of V){if(j!==void 0&&A.length>=j)break;let{commit:F}=D;if(!(w!==null&&F.committer.timestamp>w)&&!(g!==null&&F.committer.timestamp<=g)){if(u){let ee=`${F.author.name} <${F.author.email}>`;if(!u(ee))continue}m&&!m(F.message)||A.push(D)}}let H=G?A.reverse():A;if(C)return wh(H,i,x,b,k,R,I,O);if(x!==null){let D=[];for(let F of H){let ee={hash:F.hash,commit:F.commit,decorations:I,decorationsRaw:O},Pe=Pi(x,ee),Le=await $i(i,F.commit,R);Le&&(Pe+=`
401
401
 
402
402
  ${Le.replace(/\n$/,"")}`),D.push(Pe)}return{stdout:D.length>0?`${D.join(`
403
403
  `)}
404
- `:"",stderr:"",exitCode:0}}let L=b??"medium",N=L==="oneline",q=[];for(let D=0;D<H.length;D++){let F=H[D],ee={hash:F.hash,commit:F.commit,decorations:I,decorationsRaw:O},Pe=Pi(L,ee,D===0,k),Le=await Oi(i,F.commit,R);Le&&(Pe+=`${N?`
404
+ `:"",stderr:"",exitCode:0}}let L=b??"medium",N=L==="oneline",q=[];for(let D=0;D<H.length;D++){let F=H[D],ee={hash:F.hash,commit:F.commit,decorations:I,decorationsRaw:O},Pe=Ii(L,ee,D===0,k),Le=await $i(i,F.commit,R);Le&&(Pe+=`${N?`
405
405
  `:`
406
406
 
407
407
  `}${Le.replace(/\n$/,"")}`),q.push(Pe)}return{stdout:q.length>0?`${q.join(`
408
408
  `)}
409
- `:"",stderr:"",exitCode:0}}})}async function mh(e,t){let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}function Pf(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*hh(e,t,n,r){let o=new Set(r),s=new In,i=async a=>{if(!o.has(a)){let c=await M(e,a);s.push({hash:a,commit:c})}};for(let a of t)await i(a);for(;s.size>0;){let a=s.pop();if(o.has(a.hash))continue;o.add(a.hash);let{commit:c}=a,f=c.parents;if(f.length===0){(await _e(e,null,c.tree)).some(u=>ye(n,u.path))&&(yield a);continue}if(f.length===1){let l=f[0];if(l){let u=await M(e,l);(await _e(e,u.tree,c.tree)).some(h=>ye(n,h.path))&&(yield a),await i(l)}continue}let d=[];for(let l of f){let u=await M(e,l);(await _e(e,u.tree,c.tree)).some(h=>ye(n,h.path))||d.push(l)}if(d.length>0&&d[0])await i(d[0]);else{yield a;for(let l of f)await i(l)}}}async function ph(e){let t=await Z(e),n=t?.type==="symbolic"?be(t.target):null,r=await X(e),o=new Map,s=(f,d,l)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:d,fullRef:l})},i=await pe(e,"refs/heads");for(let f of i)s(f.hash,be(f.name),f.name);let a=await pe(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await pe(e,"refs/tags");for(let f of c){let d=f.hash;try{d=await Ne(e,f.hash)}catch{}s(d,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function If(e,t){let n=e.byHash.get(t),r=!e.headTarget&&e.headHash!==null&&e.headHash===t;if((!n||n.length===0)&&!r)return"";let o=[],s=e.headTarget&&n?n.find(a=>a.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let i=n?n.filter(a=>a!==s):[];i.sort((a,c)=>a.fullRef>c.fullRef?-1:a.fullRef<c.fullRef?1:0);for(let a of i)o.push(a.label);return o.length>0?`(${o.join(", ")})`:""}async function gh(e,t,n,r,o,s,i,a){let c=new fo,f=r??"medium",d=f==="oneline",l=[];for(let u=0;u<e.length;u++){let m=e[u],h={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a},p;n!==null?p=Ci(n,h):p=Pi(f,h,!0,o),c.update(m.hash,m.commit.parents),u>0&&!d&&n===null&&l.push(c.paddingPrefix());let g=p.split(`
410
- `),w=0;for(;;){let{prefix:b,isCommitLine:k}=c.nextLine();if(k){l.push(b+(g[w++]??""));break}l.push(b)}for(;w<g.length;){let{prefix:b}=c.nextLine();l.push(b+g[w++])}for(;!c.isFinished();){let{prefix:b}=c.nextLine();l.push(b)}let E=80-c.width,x=await Oi(t,m.commit,s,E);if(x){let b=x.replace(/\n$/,"").split(`
409
+ `:"",stderr:"",exitCode:0}}})}async function hh(e,t){let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}function If(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*ph(e,t,n,r){let o=new Set(r),s=new In,i=async a=>{if(!o.has(a)){let c=await M(e,a);s.push({hash:a,commit:c})}};for(let a of t)await i(a);for(;s.size>0;){let a=s.pop();if(o.has(a.hash))continue;o.add(a.hash);let{commit:c}=a,f=c.parents;if(f.length===0){(await _e(e,null,c.tree)).some(u=>ye(n,u.path))&&(yield a);continue}if(f.length===1){let l=f[0];if(l){let u=await M(e,l);(await _e(e,u.tree,c.tree)).some(h=>ye(n,h.path))&&(yield a),await i(l)}continue}let d=[];for(let l of f){let u=await M(e,l);(await _e(e,u.tree,c.tree)).some(h=>ye(n,h.path))||d.push(l)}if(d.length>0&&d[0])await i(d[0]);else{yield a;for(let l of f)await i(l)}}}async function gh(e){let t=await Z(e),n=t?.type==="symbolic"?be(t.target):null,r=await X(e),o=new Map,s=(f,d,l)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:d,fullRef:l})},i=await pe(e,"refs/heads");for(let f of i)s(f.hash,be(f.name),f.name);let a=await pe(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await pe(e,"refs/tags");for(let f of c){let d=f.hash;try{d=await Ne(e,f.hash)}catch{}s(d,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function Of(e,t){let n=e.byHash.get(t),r=!e.headTarget&&e.headHash!==null&&e.headHash===t;if((!n||n.length===0)&&!r)return"";let o=[],s=e.headTarget&&n?n.find(a=>a.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let i=n?n.filter(a=>a!==s):[];i.sort((a,c)=>a.fullRef>c.fullRef?-1:a.fullRef<c.fullRef?1:0);for(let a of i)o.push(a.label);return o.length>0?`(${o.join(", ")})`:""}async function wh(e,t,n,r,o,s,i,a){let c=new fo,f=r??"medium",d=f==="oneline",l=[];for(let u=0;u<e.length;u++){let m=e[u],h={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a},p;n!==null?p=Pi(n,h):p=Ii(f,h,!0,o),c.update(m.hash,m.commit.parents),u>0&&!d&&n===null&&l.push(c.paddingPrefix());let g=p.split(`
410
+ `),w=0;for(;;){let{prefix:b,isCommitLine:k}=c.nextLine();if(k){l.push(b+(g[w++]??""));break}l.push(b)}for(;w<g.length;){let{prefix:b}=c.nextLine();l.push(b+g[w++])}for(;!c.isFinished();){let{prefix:b}=c.nextLine();l.push(b)}let E=80-c.width,x=await $i(t,m.commit,s,E);if(x){let b=x.replace(/\n$/,"").split(`
411
411
  `);if(d||n!==null)for(let k of b)l.push(c.paddingPrefix()+k);else{l.push(c.paddingPrefix());for(let k of b)l.push(c.paddingPrefix()+k)}}}return{stdout:l.length>0?`${l.join(`
412
412
  `)}
413
- `:"",stderr:"",exitCode:0}}async function Oi(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await M(e,t.parents[0])).tree:null,s=await _e(e,o,t.tree),{remaining:i,renames:a}=await nt(e,s);switch(n){case"name-only":return wh(i,a);case"name-status":return bh(i,a);case"stat":return yh(e,i,a,r);case"shortstat":return Eh(e,i,a);case"numstat":return kh(e,i,a);case"patch":return Rh(e,i,a)}}function wh(e,t){let n=[];for(let r of e)n.push({key:r.path,line:r.path});for(let r of t)n.push({key:r.newPath,line:r.newPath});return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
414
- `).join("")}function bh(e,t){let n=[];for(let r of e){let o=r.status==="added"?"A":r.status==="deleted"?"D":"M";n.push({key:r.path,line:`${o} ${r.path}`})}for(let r of t){let o=String(r.similarity??100).padStart(3,"0");n.push({key:r.newPath,line:`R${o} ${r.oldPath} ${r.newPath}`})}return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
415
- `).join("")}async function yh(e,t,n,r){let{fileStats:o}=await zr(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),Vr(o,r)}async function Eh(e,t,n){let{fileStats:r}=await zr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=mr(r.length,o,s);return i?`${i}
416
- `:""}async function kh(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:On(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
413
+ `:"",stderr:"",exitCode:0}}async function $i(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await M(e,t.parents[0])).tree:null,s=await _e(e,o,t.tree),{remaining:i,renames:a}=await nt(e,s);switch(n){case"name-only":return bh(i,a);case"name-status":return yh(i,a);case"stat":return Eh(e,i,a,r);case"shortstat":return kh(e,i,a);case"numstat":return Rh(e,i,a);case"patch":return xh(e,i,a)}}function bh(e,t){let n=[];for(let r of e)n.push({key:r.path,line:r.path});for(let r of t)n.push({key:r.newPath,line:r.newPath});return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
414
+ `).join("")}function yh(e,t){let n=[];for(let r of e){let o=r.status==="added"?"A":r.status==="deleted"?"D":"M";n.push({key:r.path,line:`${o} ${r.path}`})}for(let r of t){let o=String(r.similarity??100).padStart(3,"0");n.push({key:r.newPath,line:`R${o} ${r.oldPath} ${r.newPath}`})}return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
415
+ `).join("")}async function Eh(e,t,n,r){let{fileStats:o}=await zr(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),Vr(o,r)}async function kh(e,t,n){let{fileStats:r}=await zr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=mr(r.length,o,s);return i?`${i}
416
+ `:""}async function Rh(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:On(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
417
417
  `;else{let c=qt(i),f=qt(a),d=ft(c,f),l=0,u=0;for(let m of d)m.type==="insert"?l++:m.type==="delete"&&u++;o+=`${l} ${u} ${s.display}
418
- `}}return o}async function Rh(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Rt({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Rt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}re();Re();de();_n();tt();function Tf(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:S().alias("c").describe("Show cached files (default)"),modified:S().alias("m").describe("Show modified files"),deleted:S().alias("d").describe("Show deleted files"),others:S().alias("o").describe("Show other (untracked) files"),unmerged:S().alias("u").describe("Show unmerged files"),stage:S().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":S().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":S().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":S().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=ze(i);if(a)return a;let c=i.workTree,f=n.cached,d=n.modified,l=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||d||l||u||m||(f=!0);let x=await K(i),b=g?"\0":`
419
- `,k=o.passthrough.length>0?o.passthrough.map(P=>{let y=r.cwd!==c?xh(c,r.cwd):"";return Ge(P,y)}):null,R=[];if(f)for(let P of x.entries){if(k&&!ye(k,P.path))continue;let y=w?P.stage>0?"M":"H":null;R.push($f(P,h,y))}if(m&&!f)for(let P of x.entries)P.stage!==0&&(k&&!ye(k,P.path)||R.push($f(P,!0,w?"M":null)));if(d||l){let P=await Ch(i,c,x);for(let{path:y,status:I}of P){if(I==="modified"&&!d||I==="deleted"&&!l||k&&!ye(k,y))continue;let O=w?I==="deleted"?"R":"C":null;R.push(O?`${O} ${y}`:y)}}if(u){let P=await Ph(i,c,x,p);for(let y of P)k&&!ye(k,y)||R.push(w?`? ${y}`:y)}return{stdout:R.length>0?R.join(b)+b:"",stderr:"",exitCode:0}}})}function $f(e,t,n){if(t){let r=e.mode.toString(8).padStart(6,"0");return`${n?`${n} `:""}${r} ${e.hash} ${e.stage} ${e.path}`}return n?`${n} ${e.path}`:e.path}function xh(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Ch(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=T(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await ct(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Rn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Ph(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await et(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}re();Kn();Re();ie();je();ue();on();Se();function Sf(e,t){e.command("merge",{description:"Join two or more development histories together",args:[W.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:S().describe("Abort the current in-progress merge"),continue:S().describe("Continue the merge after conflict resolution"),noFf:S().describe("Create a merge commit even when fast-forward is possible"),ffOnly:S().describe("Refuse to merge unless fast-forward is possible"),squash:S().describe("Apply merge result to worktree/index without creating a merge commit"),edit:S().describe("Edit the merge message (no-op, accepted for compatibility)"),message:te.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort)return Sh(s,r.env);if(n.continue)return Th(s,r.env,t);let i=n.branch;if(!i)return $("you must specify a branch to merge");let a=await Ve(s);if(v(a))return a;let c=await K(s),f=fn(c,"Merging");if(f)return f;if(await U(s,"MERGE_HEAD"))return $(`You have not concluded your merge (MERGE_HEAD exists).
418
+ `}}return o}async function xh(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Rt({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Rt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}re();Re();de();_n();tt();function Sf(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:S().alias("c").describe("Show cached files (default)"),modified:S().alias("m").describe("Show modified files"),deleted:S().alias("d").describe("Show deleted files"),others:S().alias("o").describe("Show other (untracked) files"),unmerged:S().alias("u").describe("Show unmerged files"),stage:S().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":S().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":S().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":S().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=ze(i);if(a)return a;let c=i.workTree,f=n.cached,d=n.modified,l=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||d||l||u||m||(f=!0);let x=await K(i),b=g?"\0":`
419
+ `,k=o.passthrough.length>0?o.passthrough.map(P=>{let y=r.cwd!==c?Ch(c,r.cwd):"";return Ge(P,y)}):null,R=[];if(f)for(let P of x.entries){if(k&&!ye(k,P.path))continue;let y=w?P.stage>0?"M":"H":null;R.push(Tf(P,h,y))}if(m&&!f)for(let P of x.entries)P.stage!==0&&(k&&!ye(k,P.path)||R.push(Tf(P,!0,w?"M":null)));if(d||l){let P=await Ph(i,c,x);for(let{path:y,status:I}of P){if(I==="modified"&&!d||I==="deleted"&&!l||k&&!ye(k,y))continue;let O=w?I==="deleted"?"R":"C":null;R.push(O?`${O} ${y}`:y)}}if(u){let P=await Ih(i,c,x,p);for(let y of P)k&&!ye(k,y)||R.push(w?`? ${y}`:y)}return{stdout:R.length>0?R.join(b)+b:"",stderr:"",exitCode:0}}})}function Tf(e,t,n){if(t){let r=e.mode.toString(8).padStart(6,"0");return`${n?`${n} `:""}${r} ${e.hash} ${e.stage} ${e.path}`}return n?`${n} ${e.path}`:e.path}function Ch(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Ph(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=T(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await ct(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Rn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Ih(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await et(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}re();Kn();Re();ie();je();ue();on();Se();function Hf(e,t){e.command("merge",{description:"Join two or more development histories together",args:[W.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:S().describe("Abort the current in-progress merge"),continue:S().describe("Continue the merge after conflict resolution"),noFf:S().describe("Create a merge commit even when fast-forward is possible"),ffOnly:S().describe("Refuse to merge unless fast-forward is possible"),squash:S().describe("Apply merge result to worktree/index without creating a merge commit"),edit:S().describe("Edit the merge message (no-op, accepted for compatibility)"),message:te.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort)return Hh(s,r.env);if(n.continue)return Sh(s,r.env,t);let i=n.branch;if(!i)return $("you must specify a branch to merge");let a=await Ve(s);if(v(a))return a;let c=await K(s),f=fn(c,"Merging");if(f)return f;if(await U(s,"MERGE_HEAD"))return $(`You have not concluded your merge (MERGE_HEAD exists).
420
420
  Please, commit your changes before you merge.`);if(await U(s,"CHERRY_PICK_HEAD"))return $(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
421
421
  Please, commit your changes before you merge.`);let u=await We(s,i);if(!u)return _(`merge: ${i} - not something we can merge
422
422
  `);let m=await Ne(s,u),h=await Lt(s,a,m),p=h[0]??null;if(h.length===0)return $("refusing to merge unrelated histories");if(p===m)return await he(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
@@ -432,7 +432,7 @@ hint: Disable this message with "git config set advice.diverging false"
432
432
  fatal: Not possible to fast-forward, aborting.
433
433
  `,128);if(await U(s,"REVERT_HEAD")&&await Dt(s),g&&!n.squash){let x=await Z(s),b=await Xs(s,a,m);if(b.exitCode===0&&n.message&&(b.stdout=b.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),b.exitCode===0){await he(s,"MERGE_MSG");let k=x?.type==="symbolic"?x.target:"HEAD";await ne(s,r.env,k,a,m,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,x?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:m,strategy:"fast-forward",commitHash:null})}return b}let w=n.message,E=w?w.endsWith(`
434
434
  `)?w:`${w}
435
- `:void 0;return n.squash?$h(s,a,m,i,r.env,t,E):Ih(s,a,m,i,r.env,n.noFf,t,E)}})}async function Ih(e,t,n,r,o,s=!1,i,a){let c=await M(e,t),f=await Z(e),d=f?.type==="symbolic"?be(f.target):"HEAD",l={a:"HEAD",b:r},u=await Zr(e,t,n,l),m=await mn(e,u,c.tree,{labels:l,errorExitCode:2,operationName:"merge"});if(!m.ok)return await he(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(u.conflicts.length>0){await Y(e,"MERGE_HEAD",n),await Y(e,"ORIG_HEAD",t);let y=a??await Xn(e,r,d),I={repo:e,message:y,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(I);if(Q(O))return{stdout:"",stderr:O.message??"",exitCode:1};y=I.message;let j=Ft({version:2,entries:u.entries}).sort();return y+=`
435
+ `:void 0;return n.squash?Th(s,a,m,i,r.env,t,E):Oh(s,a,m,i,r.env,n.noFf,t,E)}})}async function Oh(e,t,n,r,o,s=!1,i,a){let c=await M(e,t),f=await Z(e),d=f?.type==="symbolic"?be(f.target):"HEAD",l={a:"HEAD",b:r},u=await Zr(e,t,n,l),m=await mn(e,u,c.tree,{labels:l,errorExitCode:2,operationName:"merge"});if(!m.ok)return await he(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(u.conflicts.length>0){await Y(e,"MERGE_HEAD",n),await Y(e,"ORIG_HEAD",t);let y=a??await Xn(e,r,d),I={repo:e,message:y,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(I);if(Q(O))return{stdout:"",stderr:O.message??"",exitCode:1};y=I.message;let j=Ft({version:2,entries:u.entries}).sort();return y+=`
436
436
  # Conflicts:
437
437
  ${j.map(V=>`# ${V}`).join(`
438
438
  `)}
@@ -441,14 +441,14 @@ ${j.map(V=>`# ${V}`).join(`
441
441
  `,stderr:"",exitCode:1}}await he(e,"MERGE_MSG");let h=m.mergedTreeHash,p=await en(e,o);if(v(p))return p;let g=await Ze(e,o);if(v(g))return g;let w=a??await Xn(e,r,d),E={repo:e,message:w,treeHash:h,headHash:t,theirsHash:n},x=await i?.hooks?.mergeMsg?.(E);if(Q(x))return{stdout:"",stderr:x.message??"",exitCode:1};w=E.message;let b=await i?.hooks?.preMergeCommit?.({repo:e,mergeMessage:w,treeHash:h,headHash:t,theirsHash:n});if(Q(b))return{stdout:"",stderr:b.message??"",exitCode:1};let k=await ut(e,h,[t,n],p,g,w),R=f?.type==="symbolic"?f.target:"HEAD";await ne(e,o,R,t,k,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:k});let C=await An(e,c.tree,h);return{stdout:`${u.messages.length>0?`${u.messages.join(`
442
442
  `)}
443
443
  `:""}Merge made by the 'ort' strategy.
444
- ${C}`,stderr:"",exitCode:0}}async function Oh(e,t,n){let r=[];for await(let o of At(e,n,{exclude:[t]})){if(o.commit.parents.length>1)continue;r.push(`commit ${o.hash}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Gt(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
444
+ ${C}`,stderr:"",exitCode:0}}async function $h(e,t,n){let r=[];for await(let o of At(e,n,{exclude:[t]})){if(o.commit.parents.length>1)continue;r.push(`commit ${o.hash}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Gt(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
445
445
  `))r.push(` ${i}`);r.push("")}return r.join(`
446
- `)}async function $h(e,t,n,r,o,s,i){let a=await M(e,t),c=await Z(e),f={a:"HEAD",b:r},d=await Lt(e,t,n),l=d.length>0&&d[0]===t,u=l?`Updating ${z(t)}..${z(n)}
446
+ `)}async function Th(e,t,n,r,o,s,i){let a=await M(e,t),c=await Z(e),f={a:"HEAD",b:r},d=await Lt(e,t,n),l=d.length>0&&d[0]===t,u=l?`Updating ${z(t)}..${z(n)}
447
447
  `:"",m=await Zr(e,t,n,f),h=await mn(e,m,a.tree,{labels:f,errorExitCode:l?1:2,operationName:"merge",skipStagedChangeCheck:l});if(!h.ok){await he(e,"MERGE_MSG"),!l&&h.failureKind==="staged"&&c?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let b=h;return u&&(b.stdout=u+b.stdout),b}let p;if(i?p=`Squashed commit of the following:
448
448
 
449
449
  ${i}`:p=`Squashed commit of the following:
450
450
 
451
- ${await Oh(e,t,n)}`,await Oe(e,"SQUASH_MSG",p),m.conflicts.length>0){let k=`
451
+ ${await $h(e,t,n)}`,await Oe(e,"SQUASH_MSG",p),m.conflicts.length>0){let k=`
452
452
  # Conflicts:
453
453
  ${Ft({version:2,entries:m.entries}).sort().map(P=>`# ${P}`).join(`
454
454
  `)}
@@ -459,9 +459,9 @@ ${Ft({version:2,entries:m.entries}).sort().map(P=>`# ${P}`).join(`
459
459
  `:"";return{stdout:`${l?`${u}Fast-forward
460
460
  `:""}${E}Squash commit -- not updating HEAD
461
461
  ${l?w:""}`,stderr:l?"":`Automatic merge went well; stopped before committing as requested
462
- `,exitCode:0}}async function Th(e,t,n){let r=await U(e,"MERGE_HEAD");if(!r)return $("There is no merge in progress (MERGE_HEAD missing).");let o=await K(e),s=fn(o,"Committing");if(s)return s;let i=await Ve(e);if(v(i))return i;let a=await M(e,i),c=await ke(e,"MERGE_MSG");if(c)c=tn(c);else{let P=await Z(e),y=P?.type==="symbolic"?be(P.target):"HEAD";c=await Xn(e,"unknown",y)}let f=Ae(o),d=await De(e,f),l=await en(e,t);if(v(l))return l;let u=await Ze(e,t);if(v(u))return u;let m=vt(c),h={repo:e,message:m,treeHash:d,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(Q(p))return{stdout:"",stderr:p.message??"",exitCode:1};m=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,mergeMessage:m,treeHash:d,headHash:i,theirsHash:r});if(Q(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await ut(e,d,[i,r],l,u,m);await Fr(e);let E=await Z(e),x=ae(m),b=E?.type==="symbolic"?E.target:"HEAD";await ne(e,t,b,i,w,`commit (merge): ${x}`,E?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await An(e,a.tree,d),R=E?.type==="symbolic"?be(E.target):"detached HEAD";return{stdout:`${Ht(R,w,c)}
463
- ${k}`,stderr:"",exitCode:0}}async function Sh(e,t){return Pn(e,t,{operationRef:"MERGE_HEAD",noOpError:$("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:Fr})}re();Re();de();tt();function Hf(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[W.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:S().alias("f").describe("Force renaming even if target exists"),"dry-run":S().alias("n").describe("Do nothing; only show what would happen"),skip:S().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
464
- `);let f=c[c.length-1],d=c.slice(0,-1),l=It(r.cwd,f),u=at(a,l);if(u.startsWith(".."))return $(`'${f}' is outside repository at '${a}'`);let m=await K(s),h=await r.fs.exists(l),p=h&&(await r.fs.stat(l)).isDirectory;if(d.length>1&&!p)return $(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of d){let E=It(r.cwd,w),x=at(a,E);if(x.startsWith("..")){if(n.skip)continue;return $(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(E)){if(n.skip)continue;return $(`bad source, source=${x}, destination=${u}`)}let R=(await r.fs.stat(E)).isDirectory;if(!(R?m.entries.some(j=>j.path===x||j.path.startsWith(`${x}/`)):m.entries.some(j=>j.path===x&&j.stage===0))){let j=!R&&m.entries.some(G=>G.path===x&&G.stage>0);if(n.skip)continue;return $(j?`conflicted, source=${x}, destination=${u}`:`not under version control, source=${x}, destination=${u}`)}let P,y;if(p){let j=Cr(x);P=u===""||u==="."?j:`${u}/${j}`,y=T(l,j)}else P=u,y=l;if(await r.fs.exists(y)&&!n.force)if((await r.fs.stat(y)).isDirectory){let G=Cr(x);P=`${P}/${G}`,y=T(y,G)}else{if(n.skip)continue;return $(`destination exists, source=${x}, destination=${P}`)}if(x===P){if(n.skip)continue;return $(`can not move directory into itself, source=${x}, destination=${P}`)}let O=zt(y);if(!await r.fs.exists(O)){if(n.skip)continue;return $(`renaming '${x}' failed: No such file or directory`)}if(R){let j=`${x}/`,G=m.entries.filter(V=>V.path.startsWith(j)&&V.stage===0);for(let V of G){let A=V.path.slice(x.length),H=P+A,L=y+A;g.push({srcRel:V.path,dstRel:H,srcAbs:T(a,V.path),dstAbs:L})}}else g.push({srcRel:x,dstRel:P,srcAbs:E,dstAbs:y})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let E=zt(w.dstAbs);await r.fs.exists(E)||await r.fs.mkdir(E,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=ms(m,w.srcRel,0);if(b){m=ot(m,w.srcRel);let k={...b,path:w.dstRel};m=wt(m,k)}}for(let w of g)await Bn(r.fs,zt(w.srcAbs),a);return await se(s,m),{stdout:"",stderr:"",exitCode:0}}})}re();Ye();hn();Re();ie();de();dt();je();ue();function vf(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[W.string().name("remote").describe("Remote to pull from").optional(),W.string().name("branch").describe("Remote branch").optional()],options:{rebase:S().alias("r").describe("Rebase instead of merge"),noRebase:S().describe("Merge instead of rebase"),ffOnly:S().describe("Only fast-forward"),noFf:S().describe("Create a merge commit even for fast-forwards")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await Ve(s);if(v(i))return i;let a=await K(s);if($t(a))return _(`error: Pulling is not possible because you have unmerged files.
462
+ `,exitCode:0}}async function Sh(e,t,n){let r=await U(e,"MERGE_HEAD");if(!r)return $("There is no merge in progress (MERGE_HEAD missing).");let o=await K(e),s=fn(o,"Committing");if(s)return s;let i=await Ve(e);if(v(i))return i;let a=await M(e,i),c=await ke(e,"MERGE_MSG");if(c)c=tn(c);else{let P=await Z(e),y=P?.type==="symbolic"?be(P.target):"HEAD";c=await Xn(e,"unknown",y)}let f=Ae(o),d=await De(e,f),l=await en(e,t);if(v(l))return l;let u=await Ze(e,t);if(v(u))return u;let m=vt(c),h={repo:e,message:m,treeHash:d,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(Q(p))return{stdout:"",stderr:p.message??"",exitCode:1};m=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,mergeMessage:m,treeHash:d,headHash:i,theirsHash:r});if(Q(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await ut(e,d,[i,r],l,u,m);await Fr(e);let E=await Z(e),x=ae(m),b=E?.type==="symbolic"?E.target:"HEAD";await ne(e,t,b,i,w,`commit (merge): ${x}`,E?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await An(e,a.tree,d),R=E?.type==="symbolic"?be(E.target):"detached HEAD";return{stdout:`${Ht(R,w,c)}
463
+ ${k}`,stderr:"",exitCode:0}}async function Hh(e,t){return Pn(e,t,{operationRef:"MERGE_HEAD",noOpError:$("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:Fr})}re();Re();de();tt();function vf(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[W.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:S().alias("f").describe("Force renaming even if target exists"),"dry-run":S().alias("n").describe("Do nothing; only show what would happen"),skip:S().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
464
+ `);let f=c[c.length-1],d=c.slice(0,-1),l=It(r.cwd,f),u=at(a,l);if(u.startsWith(".."))return $(`'${f}' is outside repository at '${a}'`);let m=await K(s),h=await r.fs.exists(l),p=h&&(await r.fs.stat(l)).isDirectory;if(d.length>1&&!p)return $(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of d){let E=It(r.cwd,w),x=at(a,E);if(x.startsWith("..")){if(n.skip)continue;return $(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(E)){if(n.skip)continue;return $(`bad source, source=${x}, destination=${u}`)}let R=(await r.fs.stat(E)).isDirectory;if(!(R?m.entries.some(j=>j.path===x||j.path.startsWith(`${x}/`)):m.entries.some(j=>j.path===x&&j.stage===0))){let j=!R&&m.entries.some(G=>G.path===x&&G.stage>0);if(n.skip)continue;return $(j?`conflicted, source=${x}, destination=${u}`:`not under version control, source=${x}, destination=${u}`)}let P,y;if(p){let j=Cr(x);P=u===""||u==="."?j:`${u}/${j}`,y=T(l,j)}else P=u,y=l;if(await r.fs.exists(y)&&!n.force)if((await r.fs.stat(y)).isDirectory){let G=Cr(x);P=`${P}/${G}`,y=T(y,G)}else{if(n.skip)continue;return $(`destination exists, source=${x}, destination=${P}`)}if(x===P){if(n.skip)continue;return $(`can not move directory into itself, source=${x}, destination=${P}`)}let O=zt(y);if(!await r.fs.exists(O)){if(n.skip)continue;return $(`renaming '${x}' failed: No such file or directory`)}if(R){let j=`${x}/`,G=m.entries.filter(V=>V.path.startsWith(j)&&V.stage===0);for(let V of G){let A=V.path.slice(x.length),H=P+A,L=y+A;g.push({srcRel:V.path,dstRel:H,srcAbs:T(a,V.path),dstAbs:L})}}else g.push({srcRel:x,dstRel:P,srcAbs:E,dstAbs:y})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let E=zt(w.dstAbs);await r.fs.exists(E)||await r.fs.mkdir(E,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=ms(m,w.srcRel,0);if(b){m=ot(m,w.srcRel);let k={...b,path:w.dstRel};m=wt(m,k)}}for(let w of g)await Bn(r.fs,zt(w.srcAbs),a);return await se(s,m),{stdout:"",stderr:"",exitCode:0}}})}re();Ye();hn();Re();ie();de();dt();je();ue();function Af(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[W.string().name("remote").describe("Remote to pull from").optional(),W.string().name("branch").describe("Remote branch").optional()],options:{rebase:S().alias("r").describe("Rebase instead of merge"),noRebase:S().describe("Merge instead of rebase"),ffOnly:S().describe("Only fast-forward"),noFf:S().describe("Create a merge commit even for fast-forwards")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=await Ve(s);if(v(i))return i;let a=await K(s);if($t(a))return _(`error: Pulling is not possible because you have unmerged files.
465
465
  `,128);let c=n.remote,f=n.branch;if(!c){let me=await Z(s);if(me?.type==="symbolic"){let Fe=me.target.startsWith("refs/heads/")?me.target.slice(11):me.target,tr=(await le(s))[`branch "${Fe}"`];tr&&(c=tr.remote||"origin",!f&&tr.merge&&(f=tr.merge.startsWith("refs/heads/")?tr.merge.slice(11):tr.merge))}}c=c||"origin";let d;try{d=await br(s,c,r.env)}catch(me){let Fe=me instanceof Error?me.message:"";if(Fe.startsWith("network"))return $(Fe);throw me}if(!d)return $(`'${c}' does not appear to be a git repository`);let{transport:l,config:u}=d,m=f??null,h=await t?.hooks?.prePull?.({repo:s,remote:c,branch:m});if(Q(h))return{stdout:"",stderr:h.message??"",exitCode:1};let p=Qn(u.fetchRefspec),g=await l.advertiseRefs();if(g.length===0)return $("Couldn't find remote ref HEAD");let E=(await pe(s)).map(me=>me.hash),x=await U(s,"HEAD");x&&E.push(x);let b=[],k=new Set,R=[];for(let me of g){if(me.name==="HEAD")continue;let Fe=ao(p,me.name);Fe!==null&&(R.push({remote:me,localRef:Fe}),k.has(me.hash)||(k.add(me.hash),b.push(me.hash)))}let C=new Set(E),P=b.filter(me=>!C.has(me));P.length>0&&await l.fetch(P,E);let y=await Vt(s,r.env);for(let me of R){let Fe=await U(s,me.localRef);await Y(s,me.localRef,me.remote.hash),await Be(s,me.localRef,{oldHash:Fe??J,newHash:me.remote.hash,name:y.name,email:y.email,timestamp:y.timestamp,tz:y.tz,message:Fe?"pull":"pull: storing head"})}let I=null;if(f){let me=g.find(Fe=>Fe.name===`refs/heads/${f}`);if(me)I=me.hash;else return $(`Couldn't find remote ref refs/heads/${f}`)}else{let me=g.find(Fe=>Fe.name==="HEAD");me&&(I=me.hash)}if(I&&await r.fs.writeFile(T(s.gitDir,"FETCH_HEAD"),`${I} ${u.url}
466
466
  `),!I)return $("Could not determine remote HEAD");let O=I;if(i===O)return await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
467
467
  `,stderr:"",exitCode:0};let j=await Lt(s,i,O),G=j[0]??null;if(j.length===0)return $("refusing to merge unrelated histories");if(G===O)return await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
@@ -471,11 +471,11 @@ ${Fe.map(os=>`# ${os}`).join(`
471
471
  `)}
472
472
  `,await Oe(s,"MERGE_MSG",me),{stdout:`${[...q.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
473
473
  `)}
474
- `,stderr:"",exitCode:1}}let ee=F.mergedTreeHash,Pe=await en(s,r.env);if(v(Pe))return Pe;let Le=await Ze(s,r.env);if(v(Le))return Le;let Ke=await Xn(s,L,H),ge={repo:s,message:Ke,treeHash:ee,headHash:i,theirsHash:O},Me=await t?.hooks?.mergeMsg?.(ge);if(Q(Me))return{stdout:"",stderr:Me.message??"",exitCode:1};Ke=ge.message;let Pt=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:Ke,treeHash:ee,headHash:i,theirsHash:O});if(Q(Pt))return{stdout:"",stderr:Pt.message??"",exitCode:1};let er=await ut(s,ee,[i,O],Pe,Le,Ke);await t?.hooks?.postMerge?.({repo:s,headHash:i,theirsHash:O,strategy:"three-way",commitHash:er}),await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"three-way",commitHash:er});let Je=A?.type==="symbolic"?A.target:"HEAD",kr="pull: Merge made by the 'ort' strategy.";await Be(s,Je,{oldHash:i,newHash:er,name:y.name,email:y.email,timestamp:y.timestamp,tz:y.tz,message:kr}),A?.type==="symbolic"&&await Be(s,"HEAD",{oldHash:i,newHash:er,name:y.name,email:y.email,timestamp:y.timestamp,tz:y.tz,message:kr});let Li=await An(s,D.tree,ee);return{stdout:`${q.messages.length>0?`${q.messages.join(`
474
+ `,stderr:"",exitCode:1}}let ee=F.mergedTreeHash,Pe=await en(s,r.env);if(v(Pe))return Pe;let Le=await Ze(s,r.env);if(v(Le))return Le;let Ke=await Xn(s,L,H),ge={repo:s,message:Ke,treeHash:ee,headHash:i,theirsHash:O},Me=await t?.hooks?.mergeMsg?.(ge);if(Q(Me))return{stdout:"",stderr:Me.message??"",exitCode:1};Ke=ge.message;let Pt=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:Ke,treeHash:ee,headHash:i,theirsHash:O});if(Q(Pt))return{stdout:"",stderr:Pt.message??"",exitCode:1};let er=await ut(s,ee,[i,O],Pe,Le,Ke);await t?.hooks?.postMerge?.({repo:s,headHash:i,theirsHash:O,strategy:"three-way",commitHash:er}),await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"three-way",commitHash:er});let Je=A?.type==="symbolic"?A.target:"HEAD",kr="pull: Merge made by the 'ort' strategy.";await Be(s,Je,{oldHash:i,newHash:er,name:y.name,email:y.email,timestamp:y.timestamp,tz:y.tz,message:kr}),A?.type==="symbolic"&&await Be(s,"HEAD",{oldHash:i,newHash:er,name:y.name,email:y.email,timestamp:y.timestamp,tz:y.tz,message:kr});let Ni=await An(s,D.tree,ee);return{stdout:`${q.messages.length>0?`${q.messages.join(`
475
475
  `)}
476
476
  `:""}Merge made by the 'ort' strategy.
477
- ${Li}`,stderr:"",exitCode:0}}})}re();Ye();dt();ue();function Af(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[W.string().name("remote").describe("Remote to push to").optional(),W.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:S().alias("f").describe("Force push"),"set-upstream":S().alias("u").describe("Set upstream tracking reference"),all:S().describe("Push all branches"),delete:S().alias("d").describe("Delete remote refs"),tags:S().describe("Push all tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.remote||"origin",a;try{a=await br(s,i,r.env)}catch(b){let k=b instanceof Error?b.message:"";if(k.startsWith("network"))return $(k);throw b}if(!a)return $(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,d=n.force,l=await c.advertiseRefs(),u=new Map;for(let b of l)u.set(b.name,b.hash);let m=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return $("--delete requires a ref argument");for(let k of b){let R=k.startsWith("refs/")?k:`refs/heads/${k}`,C=u.get(R)??null;if(!C)return _(`error: unable to delete '${k}': remote ref does not exist
478
- `);m.push({name:R,oldHash:C,newHash:J,ok:d})}}else if(n.all){let b=await pe(s,"refs/heads");for(let k of b){let R=k.name,C=u.get(R)??null;m.push({name:R,oldHash:C,newHash:k.hash,ok:d})}}else if(n.tags){let b=await pe(s,"refs/tags");for(let k of b){let R=u.get(k.name)??null;R!==k.hash&&m.push({name:k.name,oldHash:R,newHash:k.hash,ok:d})}}else if(h&&h.length>0)for(let b of h){let k=Qn(b),R=await Hh(s,k.src);if(!R)return _(`error: src refspec '${k.src}' does not match any
477
+ ${Ni}`,stderr:"",exitCode:0}}})}re();Ye();dt();ue();function Df(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[W.string().name("remote").describe("Remote to push to").optional(),W.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:S().alias("f").describe("Force push"),"set-upstream":S().alias("u").describe("Set upstream tracking reference"),all:S().describe("Push all branches"),delete:S().alias("d").describe("Delete remote refs"),tags:S().describe("Push all tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=n.remote||"origin",a;try{a=await br(s,i,r.env)}catch(b){let k=b instanceof Error?b.message:"";if(k.startsWith("network"))return $(k);throw b}if(!a)return $(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,d=n.force,l=await c.advertiseRefs(),u=new Map;for(let b of l)u.set(b.name,b.hash);let m=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return $("--delete requires a ref argument");for(let k of b){let R=k.startsWith("refs/")?k:`refs/heads/${k}`,C=u.get(R)??null;if(!C)return _(`error: unable to delete '${k}': remote ref does not exist
478
+ `);m.push({name:R,oldHash:C,newHash:J,ok:d})}}else if(n.all){let b=await pe(s,"refs/heads");for(let k of b){let R=k.name,C=u.get(R)??null;m.push({name:R,oldHash:C,newHash:k.hash,ok:d})}}else if(n.tags){let b=await pe(s,"refs/tags");for(let k of b){let R=u.get(k.name)??null;R!==k.hash&&m.push({name:k.name,oldHash:R,newHash:k.hash,ok:d})}}else if(h&&h.length>0)for(let b of h){let k=Qn(b),R=await vh(s,k.src);if(!R)return _(`error: src refspec '${k.src}' does not match any
479
479
  `);let C=k.dst.startsWith("refs/")?k.dst:`refs/heads/${k.dst}`,P=u.get(C)??null;m.push({name:C,oldHash:P,newHash:R,ok:d||k.force})}else{let b=await Z(s);if(!b||b.type!=="symbolic")return $("You are not currently on a branch.");let k=b.target,R=await X(s);if(!R)return _(`error: src refspec does not match any
480
480
  `);let C=u.get(k)??null;m.push({name:k,oldHash:C,newHash:R,ok:d})}if(m.length===0)return{stdout:`Everything up-to-date
481
481
  `,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))});if(Q(p))return _(p.message??"");let g=await c.push(m),w=[];w.push(`To ${f.url}
@@ -484,13 +484,13 @@ ${Li}`,stderr:"",exitCode:0}}})}re();Ye();dt();ue();function Af(e,t){e.command("
484
484
  `);else if(b.newHash===J)w.push(` - [deleted] ${k}
485
485
  `);else{let R=z(b.oldHash),C=z(b.newHash);w.push(` ${R}..${C} ${k} -> ${k}
486
486
  `)}}if(n["set-upstream"]&&!E){let b=await Z(s);if(b?.type==="symbolic"){let k=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,R=await le(s);R[`branch "${k}"`]={remote:i,merge:`refs/heads/${k}`},await Qe(s,R),w.push(`branch '${k}' set up to track '${i}/${k}'.
487
- `)}}let x={stdout:"",stderr:w.join(""),exitCode:E?1:0};return E||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))}),x}})}async function Hh(e,t){if(t.startsWith("refs/"))return U(e,t);let n=await U(e,`refs/heads/${t}`);if(n)return n;let r=await U(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}re();Re();ie();re();ie();rn();Ln();Se();async function $i(e,t){let n=await we(e,t);if(n.type!=="commit")return null;let r=Yt(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await we(e,r.parents[0]);f.type==="commit"&&(o=Yt(f.content).tree)}let s=await _e(e,o,r.tree);if(s.length===0)return null;let i=Gn(),a=!1,c=[...s].sort((f,d)=>xe(f.path,d.path));for(let f of c){let d="",l="";if(f.oldHash)try{let m=await we(e,f.oldHash);d=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await we(e,f.newHash);l=new TextDecoder().decode(m.content)}catch{}let u=Rt({path:f.path,oldContent:d,newContent:l,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
487
+ `)}}let x={stdout:"",stderr:w.join(""),exitCode:E?1:0};return E||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))}),x}})}async function vh(e,t){if(t.startsWith("refs/"))return U(e,t);let n=await U(e,`refs/heads/${t}`);if(n)return n;let r=await U(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}re();Re();ie();re();ie();rn();Ln();Se();async function Ti(e,t){let n=await we(e,t);if(n.type!=="commit")return null;let r=Yt(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await we(e,r.parents[0]);f.type==="commit"&&(o=Yt(f.content).tree)}let s=await _e(e,o,r.tree);if(s.length===0)return null;let i=Gn(),a=!1,c=[...s].sort((f,d)=>xe(f.path,d.path));for(let f of c){let d="",l="";if(f.oldHash)try{let m=await we(e,f.oldHash);d=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await we(e,f.newHash);l=new TextDecoder().decode(m.content)}catch{}let u=Rt({path:f.path,oldContent:d,newContent:l,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
488
488
  `)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
489
- `),a=!0)}}return a?i.hex():null}je();ue();Se();Qt();tt();async function vh(e){let t=await Z(e);return t?.type==="symbolic"?be(t.target):"detached HEAD"}function Df(e){return e==="HEAD"?`HEAD is up to date.
489
+ `),a=!0)}}return a?i.hex():null}je();ue();Se();Qt();tt();async function Ah(e){let t=await Z(e);return t?.type==="symbolic"?be(t.target):"detached HEAD"}function Mf(e){return e==="HEAD"?`HEAD is up to date.
490
490
  `:`Current branch ${e} is up to date.
491
- `}async function Ah(e,t,n){if(!e.workTree)return null;let r=await ce(e,t),o=new Map(Ae(n).map(a=>[a.path,a])),s=new Set(await et(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=Ts(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
492
- `)}return null}async function Dh(e,t,n,r){if(!e.workTree)return null;let o=await ce(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await et(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${Ts(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
493
- `,exitCode:128}:null}async function Mf(e,t,n){if(!e.workTree)return null;let r=new Map(Ae(t).map(i=>[i.path,i])),o=new Set(await et(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function jf(e,t){return`error: The following untracked working tree files would be overwritten by merge:
491
+ `}async function Dh(e,t,n){if(!e.workTree)return null;let r=await ce(e,t),o=new Map(Ae(n).map(a=>[a.path,a])),s=new Set(await et(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=Ts(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
492
+ `)}return null}async function Mh(e,t,n,r){if(!e.workTree)return null;let o=await ce(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await et(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${Ts(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
493
+ `,exitCode:128}:null}async function jf(e,t,n){if(!e.workTree)return null;let r=new Map(Ae(t).map(i=>[i.path,i])),o=new Set(await et(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function Gf(e,t){return`error: The following untracked working tree files would be overwritten by merge:
494
494
  ${e.map(r=>` ${r}`).join(`
495
495
  `)}
496
496
  Please move or remove them before you merge.
@@ -504,7 +504,7 @@ hint: edit the todo list first:
504
504
  hint:
505
505
  hint: git rebase --edit-todo
506
506
  hint: git rebase --continue
507
- `}async function Ti(e,t,n,r,o,s){await ne(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ne(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ne(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function lo(e,t,n,r){let o=await M(e,t),s=await Ah(e,o.tree,n);if(s)return s;let i=await cn(e,o.tree,n);return i.success&&(await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps)),r!=="detached HEAD"?await Y(e,r,t):await Y(e,"HEAD",t),null}function Gf(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[W.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:te.string().describe("Starting point at which to create new commits"),abort:S().describe("Abort the current rebase operation"),continue:S().describe("Continue the rebase after conflict resolution"),skip:S().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort)return Gh(s,r.env);if(n.continue)return Lh(s,r.env);if(n.skip)return Nh(s,r.env);let i=n.upstream;if(!i)return $("no upstream configured and no upstream argument given");if(await Mt(s))return $(`It seems that there is already a rebase-merge directory, and
507
+ `}async function Si(e,t,n,r,o,s){await ne(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ne(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ne(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function lo(e,t,n,r){let o=await M(e,t),s=await Dh(e,o.tree,n);if(s)return s;let i=await cn(e,o.tree,n);return i.success&&(await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps)),r!=="detached HEAD"?await Y(e,r,t):await Y(e,"HEAD",t),null}function Lf(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[W.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:te.string().describe("Starting point at which to create new commits"),abort:S().describe("Abort the current rebase operation"),continue:S().describe("Continue the rebase after conflict resolution"),skip:S().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort)return Lh(s,r.env);if(n.continue)return Nh(s,r.env);if(n.skip)return _h(s,r.env);let i=n.upstream;if(!i)return $("no upstream configured and no upstream argument given");if(await Mt(s))return $(`It seems that there is already a rebase-merge directory, and
508
508
  I wonder if you are in the middle of another rebase. If that is the
509
509
  case, please try
510
510
  git rebase (--continue | --abort | --skip)
@@ -518,16 +518,16 @@ error: additionally, your index contains uncommitted changes.
518
518
  error: Please commit or stash them.
519
519
  `,exitCode:1};let w=await M(s,a),E=await ce(s,w.tree);if(s.workTree){let N=ar(p,E),D=(await Tt(s,p)).some(F=>F.status==="modified"||F.status==="deleted");if(N||D){let F=[];return D&&F.push("error: cannot rebase: You have unstaged changes."),N&&(D?F.push("error: additionally, your index contains uncommitted changes."):F.push("error: cannot rebase: Your index contains uncommitted changes.")),F.push("error: Please commit or stash them."),_(`${F.join(`
520
520
  `)}
521
- `)}}let x=await t?.hooks?.preRebase?.({repo:s,upstream:i,branch:c?.type==="symbolic"?be(c.target):null});if(Q(x))return{stdout:"",stderr:x.message??"",exitCode:1};let b=await tc(s,u,a),k=b.right;if(k.length===0){if(m!==a){let N=await lo(s,m,p,f);return N||(await Ti(s,r.env,a,m,f,i),{stdout:"",stderr:`Successfully rebased and updated ${f}.
522
- `,exitCode:0})}return{stdout:Df(d),stderr:"",exitCode:0}}let R=[],C=b.left,P=new Set;for(let N of C){let q=await $i(s,N.hash);q&&P.add(q)}let y=[];if(P.size>0)for(let N of k){let q=await $i(s,N.hash);q&&P.has(q)?R.push(`warning: skipped previously applied commit ${z(N.hash)}`):y.push(N)}else y.push(...k);let I="";if(R.length>0&&(I=`${R.join(`
521
+ `)}}let x=await t?.hooks?.preRebase?.({repo:s,upstream:i,branch:c?.type==="symbolic"?be(c.target):null});if(Q(x))return{stdout:"",stderr:x.message??"",exitCode:1};let b=await nc(s,u,a),k=b.right;if(k.length===0){if(m!==a){let N=await lo(s,m,p,f);return N||(await Si(s,r.env,a,m,f,i),{stdout:"",stderr:`Successfully rebased and updated ${f}.
522
+ `,exitCode:0})}return{stdout:Mf(d),stderr:"",exitCode:0}}let R=[],C=b.left,P=new Set;for(let N of C){let q=await Ti(s,N.hash);q&&P.add(q)}let y=[];if(P.size>0)for(let N of k){let q=await Ti(s,N.hash);q&&P.has(q)?R.push(`warning: skipped previously applied commit ${z(N.hash)}`):y.push(N)}else y.push(...k);let I="";if(R.length>0&&(I=`${R.join(`
523
523
  `)}
524
524
  hint: use --reapply-cherry-picks to include skipped commits
525
525
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
526
- `),y.length===0){if(m!==a){let N=await lo(s,m,p,f);if(N)return N.stderr=I+N.stderr,N;await Ti(s,r.env,a,m,f,i)}return{stdout:"",stderr:`${I}Successfully rebased and updated ${f}.
527
- `,exitCode:0}}let O=y.map(N=>({hash:N.hash,subject:ae(N.commit.message)})),j=m,G=0;for(let N of O){let q=await M(s,N.hash);if(q.parents.length>1||q.parents.length===0||q.parents[0]!==j)break;j=N.hash,G++}let V=O.splice(0,G);if(O.length===0){if(j===a)return{stdout:Df(d),stderr:I,exitCode:0};let N=await lo(s,j,p,f);return N?(N.stderr=I+N.stderr,N):(await Ti(s,r.env,a,j,f,i),{stdout:"",stderr:`${I}Successfully rebased and updated ${f}.
528
- `,exitCode:0})}let A=await lo(s,j,p,"detached HEAD");if(A)return A.stderr=I+A.stderr,A;await fe(s,"CHERRY_PICK_HEAD"),await fe(s,"REVERT_HEAD"),await he(s,"MERGE_MSG"),await he(s,"MERGE_MODE"),await ne(s,r.env,"HEAD",a,j,`rebase (start): checkout ${i}`);let H={headName:f,origHead:a,onto:m,todo:O,done:V,msgnum:G,end:G+O.length};await Yo(s,H),await Y(s,"ORIG_HEAD",a);let L=await Si(s,r.env);return I&&(L.stderr=I+L.stderr),L}})}async function Si(e,t){let n=[],r=[];for(;;){let o=await ht(e);if(!o||o.todo.length===0)break;let s=o.todo[0];if(!s)break;n.push(`Rebasing (${o.msgnum+1}/${o.end})\r`),await ec(e);let i=await Mh(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await ht(e);a&&(a.todo=[s,...a.todo],await Yo(e,a))}return i.stdout&&r.push(i.stdout),n.push(i.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}i.stdout&&r.push(i.stdout),i.stderr&&n.push(i.stderr)}return jh(e,n,t)}async function Mh(e,t,n){let r=t.hash,o=await M(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await M(e,s):null,a=await X(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
526
+ `),y.length===0){if(m!==a){let N=await lo(s,m,p,f);if(N)return N.stderr=I+N.stderr,N;await Si(s,r.env,a,m,f,i)}return{stdout:"",stderr:`${I}Successfully rebased and updated ${f}.
527
+ `,exitCode:0}}let O=y.map(N=>({hash:N.hash,subject:ae(N.commit.message)})),j=m,G=0;for(let N of O){let q=await M(s,N.hash);if(q.parents.length>1||q.parents.length===0||q.parents[0]!==j)break;j=N.hash,G++}let V=O.splice(0,G);if(O.length===0){if(j===a)return{stdout:Mf(d),stderr:I,exitCode:0};let N=await lo(s,j,p,f);return N?(N.stderr=I+N.stderr,N):(await Si(s,r.env,a,j,f,i),{stdout:"",stderr:`${I}Successfully rebased and updated ${f}.
528
+ `,exitCode:0})}let A=await lo(s,j,p,"detached HEAD");if(A)return A.stderr=I+A.stderr,A;await fe(s,"CHERRY_PICK_HEAD"),await fe(s,"REVERT_HEAD"),await he(s,"MERGE_MSG"),await he(s,"MERGE_MODE"),await ne(s,r.env,"HEAD",a,j,`rebase (start): checkout ${i}`);let H={headName:f,origHead:a,onto:m,todo:O,done:V,msgnum:G,end:G+O.length};await Xo(s,H),await Y(s,"ORIG_HEAD",a);let L=await Hi(s,r.env);return I&&(L.stderr=I+L.stderr),L}})}async function Hi(e,t){let n=[],r=[];for(;;){let o=await ht(e);if(!o||o.todo.length===0)break;let s=o.todo[0];if(!s)break;n.push(`Rebasing (${o.msgnum+1}/${o.end})\r`),await tc(e);let i=await jh(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await ht(e);a&&(a.todo=[s,...a.todo],await Xo(e,a))}return i.stdout&&r.push(i.stdout),n.push(i.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}i.stdout&&r.push(i.stdout),i.stderr&&n.push(i.stderr)}return Gh(e,n,t)}async function jh(e,t,n){let r=t.hash,o=await M(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await M(e,s):null,a=await X(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
529
529
  `};if(s&&s===a){let G=await K(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
530
- `};let V=await qe(e,i.tree),A=await qe(e,o.tree),H=new Map(V.map(D=>[D.path,D.hash])),L=new Map;for(let D of A){let F=H.get(D.path);(!F||F!==D.hash)&&L.set(D.path,D.hash)}let N=await Mf(e,G,L);if(N)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:jf(N,t),rescheduleCurrent:!0};let q=await cn(e,o.tree,G);return q.success&&(await se(e,{version:2,entries:q.newEntries}),await He(e,q.worktreeOps)),await yn(e,r),await ne(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await M(e,a),f=i?i.tree:null,d=z(r),l=ae(o.message),u={a:"HEAD",b:l?`${d} (${l})`:d},m=await Nt(e,f,c.tree,o.tree,u),h=await K(e),[p,g,w]=await Promise.all([qe(e,c.tree),f?qe(e,f):Promise.resolve([]),qe(e,o.tree)]),E=new Set;for(let G of g)E.add(G.path);for(let G of p)E.add(G.path);for(let G of w)E.add(G.path);let x=h.entries.filter(G=>!E.has(G.path)),b=[...m.entries,...x];b.sort((G,V)=>xe(G.path,V.path)||G.stage-V.stage);let k={version:2,entries:b},R=b.filter(G=>G.stage===0),C=await De(e,R),P=new Map(p.map(G=>[G.path,G])),y=new Map;for(let G of R){let V=P.get(G.path);(!V||V.hash!==G.hash)&&y.set(G.path,G.hash)}for(let G of m.conflicts){if(G.reason==="content"||G.reason==="add-add"){y.set(G.path,null);continue}if(G.reason==="delete-modify"){let V=m.entries.filter(L=>L.path===G.path&&L.stage>0),A=V.find(L=>L.stage===2),H=V.find(L=>L.stage===3);H&&!A&&y.set(G.path,H.hash)}}let I=await Mf(e,h,y);if(I)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:jf(I,t),rescheduleCurrent:!0};if(await se(e,k),e.workTree){let G=await Cn(e,c.tree,m.resultTree,h);G.success&&await He(e,G.worktreeOps)}if(m.conflicts.length>0){await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),await Oe(e,"MERGE_MSG",o.message),await Oe(e,"rebase-merge/message",o.message);let G=m.messages.join(`
530
+ `};let V=await qe(e,i.tree),A=await qe(e,o.tree),H=new Map(V.map(D=>[D.path,D.hash])),L=new Map;for(let D of A){let F=H.get(D.path);(!F||F!==D.hash)&&L.set(D.path,D.hash)}let N=await jf(e,G,L);if(N)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:Gf(N,t),rescheduleCurrent:!0};let q=await cn(e,o.tree,G);return q.success&&(await se(e,{version:2,entries:q.newEntries}),await He(e,q.worktreeOps)),await yn(e,r),await ne(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await M(e,a),f=i?i.tree:null,d=z(r),l=ae(o.message),u={a:"HEAD",b:l?`${d} (${l})`:d},m=await Nt(e,f,c.tree,o.tree,u),h=await K(e),[p,g,w]=await Promise.all([qe(e,c.tree),f?qe(e,f):Promise.resolve([]),qe(e,o.tree)]),E=new Set;for(let G of g)E.add(G.path);for(let G of p)E.add(G.path);for(let G of w)E.add(G.path);let x=h.entries.filter(G=>!E.has(G.path)),b=[...m.entries,...x];b.sort((G,V)=>xe(G.path,V.path)||G.stage-V.stage);let k={version:2,entries:b},R=b.filter(G=>G.stage===0),C=await De(e,R),P=new Map(p.map(G=>[G.path,G])),y=new Map;for(let G of R){let V=P.get(G.path);(!V||V.hash!==G.hash)&&y.set(G.path,G.hash)}for(let G of m.conflicts){if(G.reason==="content"||G.reason==="add-add"){y.set(G.path,null);continue}if(G.reason==="delete-modify"){let V=m.entries.filter(L=>L.path===G.path&&L.stage>0),A=V.find(L=>L.stage===2),H=V.find(L=>L.stage===3);H&&!A&&y.set(G.path,H.hash)}}let I=await jf(e,h,y);if(I)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:Gf(I,t),rescheduleCurrent:!0};if(await se(e,k),e.workTree){let G=await Cn(e,c.tree,m.resultTree,h);G.success&&await He(e,G.worktreeOps)}if(m.conflicts.length>0){await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),await Oe(e,"MERGE_MSG",o.message),await Oe(e,"rebase-merge/message",o.message);let G=m.messages.join(`
531
531
  `);return{conflict:!0,stdout:G?`${G}
532
532
  `:"",stderr:`error: could not apply ${d}... ${t.subject}
533
533
  hint: Resolve all conflicts manually, mark them as resolved with
@@ -537,8 +537,8 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
537
537
  hint: Disable this message with "git config set advice.mergeConflict false"
538
538
  Could not apply ${d}... # ${t.subject}
539
539
  `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
540
- `};let O=await Ze(e,n);if(v(O))return{conflict:!0,stdout:"",stderr:O.stderr};let j=await ut(e,C,[a],o.author,O,o.message);return await ne(e,n,"HEAD",a,j,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function jh(e,t,n){let r=await ht(e);if(!r)return $("no rebase in progress");let o=await X(e);if(!o)return $("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Y(e,r.headName,o),await Ue(e,"HEAD",r.headName),await mt(e),await ne(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ne(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
541
- `;return await fe(e,"REBASE_HEAD"),await zn(e),await Xo(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Gh(e,t){let n=await ht(e);if(!n)return $("no rebase in progress");let r=await X(e),o=n.origHead,s=await M(e,o),i=await K(e),a=await Dh(e,s.tree,i,o);if(a)return a;let c=await cn(e,s.tree,i);c.success&&(await se(e,{version:2,entries:c.newEntries}),await He(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Y(e,n.headName,o),await Ue(e,"HEAD",n.headName),await mt(e)):await yn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ne(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await fe(e,"REBASE_HEAD"),await zn(e),await Xo(e),{stdout:"",stderr:"",exitCode:0}}async function Lh(e,t){let n="";if(!await ht(e))return $("no rebase in progress");let o=await K(e);if($t(o))return _(`error: Committing is not possible because you have unmerged files.
540
+ `};let O=await Ze(e,n);if(v(O))return{conflict:!0,stdout:"",stderr:O.stderr};let j=await ut(e,C,[a],o.author,O,o.message);return await ne(e,n,"HEAD",a,j,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Gh(e,t,n){let r=await ht(e);if(!r)return $("no rebase in progress");let o=await X(e);if(!o)return $("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Y(e,r.headName,o),await Ue(e,"HEAD",r.headName),await mt(e),await ne(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ne(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
541
+ `;return await fe(e,"REBASE_HEAD"),await zn(e),await Zo(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Lh(e,t){let n=await ht(e);if(!n)return $("no rebase in progress");let r=await X(e),o=n.origHead,s=await M(e,o),i=await K(e),a=await Mh(e,s.tree,i,o);if(a)return a;let c=await cn(e,s.tree,i);c.success&&(await se(e,{version:2,entries:c.newEntries}),await He(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Y(e,n.headName,o),await Ue(e,"HEAD",n.headName),await mt(e)):await yn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ne(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await fe(e,"REBASE_HEAD"),await zn(e),await Zo(e),{stdout:"",stderr:"",exitCode:0}}async function Nh(e,t){let n="";if(!await ht(e))return $("no rebase in progress");let o=await K(e);if($t(o))return _(`error: Committing is not possible because you have unmerged files.
542
542
  hint: Fix them up in the work tree, and then use 'git add <file>'
543
543
  hint: as appropriate to mark resolution and make a commit.
544
544
  fatal: Exiting because of an unresolved conflict.
@@ -555,37 +555,37 @@ In both cases, once you're done, continue with:
555
555
 
556
556
  git rebase --continue
557
557
 
558
- `);if(l){let m=await M(e,s),h=await U(e,"CHERRY_PICK_HEAD"),p=h?await M(e,h):m,g;g=await ke(e,"rebase-merge/message")??await ke(e,"MERGE_MSG")??void 0,g&&(g=tn(g)),g||(g=m.message);let w=await Ze(e,t);if(v(w))return w;let E=vt(g),x=[a],b=await U(e,"MERGE_HEAD");b&&x.push(b);let k=await ut(e,d,x,p.author,w,E);b&&(await fe(e,"MERGE_HEAD"),await he(e,"MERGE_MODE"));let R=ae(E);await ne(e,t,"HEAD",a,k,`rebase (continue): ${R}`);let C=await vh(e),P=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,y=await nn(e,c.tree,d,p.author,w,P);n=`${Ht(C,k,E)}
559
- ${y}`}await fe(e,"REBASE_HEAD"),await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"REVERT_HEAD"),await he(e,"MERGE_MSG"),await he(e,"rebase-merge/message")}let i=await Si(e,t);return n&&(i.stdout=n+i.stdout),i}async function Nh(e,t){if(!await ht(e))return $("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
558
+ `);if(l){let m=await M(e,s),h=await U(e,"CHERRY_PICK_HEAD"),p=h?await M(e,h):m,g;g=await ke(e,"rebase-merge/message")??await ke(e,"MERGE_MSG")??void 0,g&&(g=tn(g)),g||(g=m.message);let w=await Ze(e,t);if(v(w))return w;let E=vt(g),x=[a],b=await U(e,"MERGE_HEAD");b&&x.push(b);let k=await ut(e,d,x,p.author,w,E);b&&(await fe(e,"MERGE_HEAD"),await he(e,"MERGE_MODE"));let R=ae(E);await ne(e,t,"HEAD",a,k,`rebase (continue): ${R}`);let C=await Ah(e),P=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,y=await nn(e,c.tree,d,p.author,w,P);n=`${Ht(C,k,E)}
559
+ ${y}`}await fe(e,"REBASE_HEAD"),await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"REVERT_HEAD"),await he(e,"MERGE_MSG"),await he(e,"rebase-merge/message")}let i=await Hi(e,t);return n&&(i.stdout=n+i.stdout),i}async function _h(e,t){if(!await ht(e))return $("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
560
560
  fatal: could not discard worktree changes
561
- `,exitCode:128};let o=await M(e,r),s=await K(e),i=await cn(e,o.tree,s);return i.success&&(await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps)),await fe(e,"REBASE_HEAD"),await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"REVERT_HEAD"),await fe(e,"MERGE_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"rebase-merge/message"),Si(e,t)}re();de();je();ue();function _h(e,t,n,r){return`${z(n)} ${e}@{${t}}: ${r}`}async function uo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await U(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
561
+ `,exitCode:128};let o=await M(e,r),s=await K(e),i=await cn(e,o.tree,s);return i.success&&(await se(e,{version:2,entries:i.newEntries}),await He(e,i.worktreeOps)),await fe(e,"REBASE_HEAD"),await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"REVERT_HEAD"),await fe(e,"MERGE_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"rebase-merge/message"),Hi(e,t)}re();de();je();ue();function Fh(e,t,n,r){return`${z(n)} ${e}@{${t}}: ${r}`}async function uo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await U(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
562
562
  Use '--' to separate paths from revisions, like this:
563
563
  'git <command> [<revision>...] -- [<file>...]'
564
- `,exitCode:128};let s=await Xe(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<a;d--){let l=s[d];if(!l)continue;let u=s.length-1-d;l.newHash!==J&&(i.push(_h(t,u,l.newHash,l.message)),c++)}return{stdout:i.length>0?`${i.join(`
564
+ `,exitCode:128};let s=await Xe(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<a;d--){let l=s[d];if(!l)continue;let u=s.length-1-d;l.newHash!==J&&(i.push(Fh(t,u,l.newHash,l.message)),c++)}return{stdout:i.length>0?`${i.join(`
565
565
  `)}
566
- `:"",stderr:"",exitCode:0}}function Lf(e,t){return e.command("reflog",{description:"Manage reflog information",args:[W.string().name("args").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=s,a=r.args;if(a.length===0)return uo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return uo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return uo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
567
- `,exitCode:128};let d=T(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(d)?0:1}}return uo(i,c,r.maxCount)}})}re();Ye();je();ue();function Fh(e){let t=[];for(let n of Object.keys(e)){let r=n.match(/^remote "(.+)"$/);r?.[1]&&t.push(r[1])}return t.sort()}function Nf(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:S().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=Fh(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let d=[];for(let l of f){let m=c[`remote "${l}"`]?.url??"";d.push(`${l} ${m} (fetch)`),d.push(`${l} ${m} (push)`)}return{stdout:`${d.join(`
566
+ `:"",stderr:"",exitCode:0}}function Nf(e,t){return e.command("reflog",{description:"Manage reflog information",args:[W.string().name("args").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=s,a=r.args;if(a.length===0)return uo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return uo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return uo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
567
+ `,exitCode:128};let d=T(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(d)?0:1}}return uo(i,c,r.maxCount)}})}re();Ye();je();ue();function Uh(e){let t=[];for(let n of Object.keys(e)){let r=n.match(/^remote "(.+)"$/);r?.[1]&&t.push(r[1])}return t.sort()}function _f(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:S().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=Uh(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let d=[];for(let l of f){let m=c[`remote "${l}"`]?.url??"";d.push(`${l} ${m} (fetch)`),d.push(`${l} ${m} (push)`)}return{stdout:`${d.join(`
568
568
  `)}
569
569
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
570
570
  `)}
571
571
  `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[W.string().name("name").describe("Remote name"),W.string().name("url").describe("Remote URL")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;return f in c?_(`error: remote ${s.name} already exists.
572
- `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Qe(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Bh(c,s.name),await Qe(a,c),await Wh(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
573
- `,2)},o=[W.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[W.string().name("old").describe("Current remote name"),W.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a);return Uh(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[W.string().name("name").describe("Remote name"),W.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;if(!(f in c))return _(`error: No such remote '${s.name}'
572
+ `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Qe(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Wh(c,s.name),await Qe(a,c),await qh(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
573
+ `,2)},o=[W.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[W.string().name("old").describe("Current remote name"),W.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a);return Bh(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[W.string().name("name").describe("Remote name"),W.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;if(!(f in c))return _(`error: No such remote '${s.name}'
574
574
  `,2);let d=c[f];return d&&(d.url=s.url),await Qe(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[W.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await B(i.fs,i.cwd,t);if(v(a))return a;let c=await le(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
575
575
  `,stderr:"",exitCode:0}:_(`error: No such remote '${s.name}'
576
- `,2)}})}async function Uh(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
577
- `,2);let s=`remote "${r}"`;if(s in t)return $(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Qe(e,t);let a=`refs/remotes/${n}`,c=await pe(e,a);for(let f of c){let d=f.name.replace(a,`refs/remotes/${r}`),l=await Xe(e,f.name);await Y(e,d,f.hash),await fe(e,f.name),l.length>0&&await kn(e,d,l)}return{stdout:"",stderr:"",exitCode:0}}function Bh(e,t){for(let n of Object.keys(e))n.match(/^branch "(.+)"$/)&&e[n]?.remote===t&&(delete e[n].remote,delete e[n].merge,Object.keys(e[n]).length===0&&delete e[n])}async function Wh(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await fe(e,o.name)}re();Re();ie();de();je();ue();on();Se();Qt();tt();function Ff(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[W.string().name("args").variadic().optional()],options:{soft:S().describe("Only move HEAD"),mixed:S().describe("Move HEAD and reset index (default)"),hard:S().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return $("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,d=lt(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return Hi(i,o.passthrough,d,m,t)}if(!f&&a.length>0){let m=a[0],h=await We(i,m);return a.length===1&&h?_f(i,m,"mixed",r.env,t):h?Hi(i,a.slice(1),d,m,t):Hi(i,a,d,void 0,t)}let l=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return _f(i,u,l,r.env,t)}})}async function Hi(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",target:r??null});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let l=await We(e,r);if(!l)return Bt(r);let u=await Ne(e,l);i=(await M(e,u)).tree}else{let l=await X(e);l&&(i=(await M(e,l)).tree)}let a=await ce(e,i??null),c=await K(e);if(t.some(qn)){let l=t.map(m=>Ge(m,n)),u=new Set;for(let[m]of a)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!ye(l,m))continue;let h=a.get(m);h?c=wt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Ce()}):c=ot(c,m)}}else for(let l of t){let u=a.get(l);if(u)c=wt(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:Ce()});else if(c.entries.some(h=>h.path===l))c=ot(c,l);else if(!(e.workTree&&await e.fs.exists(T(e.workTree,l))))return Bt(l)}await se(e,c);let d={stdout:await Uf(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),d}async function Uf(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await Tt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
576
+ `,2)}})}async function Bh(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
577
+ `,2);let s=`remote "${r}"`;if(s in t)return $(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Qe(e,t);let a=`refs/remotes/${n}`,c=await pe(e,a);for(let f of c){let d=f.name.replace(a,`refs/remotes/${r}`),l=await Xe(e,f.name);await Y(e,d,f.hash),await fe(e,f.name),l.length>0&&await kn(e,d,l)}return{stdout:"",stderr:"",exitCode:0}}function Wh(e,t){for(let n of Object.keys(e))n.match(/^branch "(.+)"$/)&&e[n]?.remote===t&&(delete e[n].remote,delete e[n].merge,Object.keys(e[n]).length===0&&delete e[n])}async function qh(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await fe(e,o.name)}re();Re();ie();de();je();ue();on();Se();Qt();tt();function Uf(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[W.string().name("args").variadic().optional()],options:{soft:S().describe("Only move HEAD"),mixed:S().describe("Move HEAD and reset index (default)"),hard:S().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return $("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,d=lt(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return vi(i,o.passthrough,d,m,t)}if(!f&&a.length>0){let m=a[0],h=await We(i,m);return a.length===1&&h?Ff(i,m,"mixed",r.env,t):h?vi(i,a.slice(1),d,m,t):vi(i,a,d,void 0,t)}let l=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return Ff(i,u,l,r.env,t)}})}async function vi(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",target:r??null});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let l=await We(e,r);if(!l)return Bt(r);let u=await Ne(e,l);i=(await M(e,u)).tree}else{let l=await X(e);l&&(i=(await M(e,l)).tree)}let a=await ce(e,i??null),c=await K(e);if(t.some(qn)){let l=t.map(m=>Ge(m,n)),u=new Set;for(let[m]of a)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!ye(l,m))continue;let h=a.get(m);h?c=wt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Ce()}):c=ot(c,m)}}else for(let l of t){let u=a.get(l);if(u)c=wt(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:Ce()});else if(c.entries.some(h=>h.path===l))c=ot(c,l);else if(!(e.workTree&&await e.fs.exists(T(e.workTree,l))))return Bt(l)}await se(e,c);let d={stdout:await Bf(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),d}async function Bf(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await Tt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
578
578
  `)}
579
- `}async function _f(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,target:t});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Bt(t);let a=await Ne(e,i),c=await M(e,a);if(n==="soft"){let m=await U(e,"MERGE_HEAD"),h=await K(e);if(m||$t(h))return $("Cannot do a soft reset in the middle of a merge.")}let f=await X(e),d=await Z(e);d?.type==="symbolic"?await Y(e,d.target,a):await Y(e,"HEAD",a);let l=`reset: moving to ${t}`;if(d?.type==="symbolic"&&f!==a?await ne(e,r,d.target,f,a,l,!0):(d?.type==="symbolic"||f!==a)&&await ne(e,r,"HEAD",f,a,l),await zn(e),n==="mixed"){let m=await qe(e,c.tree),h=hs(m.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Ce()})));await se(e,h);let p=await Uf(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=ze(e);if(m)return m;let h=await K(e),p=await cn(e,c.tree,h);await se(e,{version:2,entries:p.newEntries}),await He(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${z(a)} ${ae(c.message)}
580
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}re();Re();ie();ue();Se();tt();function Bf(e,t){e.command("restore",{description:"Restore working tree files",args:[W.string().name("pathspec").variadic().optional()],options:{source:te.string().alias("s").describe("Restore from tree-ish"),staged:S().alias("S").describe("Restore the index"),worktree:S().alias("W").describe("Restore the working tree (default)"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return $("you must specify path(s) to restore");if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,d=lt(i,r.cwd);if(n.ours||n.theirs)return n.source?$("cannot specify both --source and --ours/--theirs"):c?$("cannot use --ours/--theirs with --staged"):Us(i,a,d,n.theirs?3:2,{deleteOnMissing:!0});let l=null;if(n.source){let u=await $e(i,n.source,`could not resolve '${n.source}'`);if(v(u))return u;l=u.commit.tree}else if(c){let u=await X(i);u&&(l=(await M(i,u)).tree)}return c&&f?zh(i,a,d,l):c?qh(i,a,d,l):l?Kh(i,a,d,l):Fs(i,a,d)}})}async function qh(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(f=>Ge(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!ye(i,f))continue;c=!0;let d=o.get(f);if(d)s=wt(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:Ce()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
579
+ `}async function Ff(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,target:t});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Bt(t);let a=await Ne(e,i),c=await M(e,a);if(n==="soft"){let m=await U(e,"MERGE_HEAD"),h=await K(e);if(m||$t(h))return $("Cannot do a soft reset in the middle of a merge.")}let f=await X(e),d=await Z(e);d?.type==="symbolic"?await Y(e,d.target,a):await Y(e,"HEAD",a);let l=`reset: moving to ${t}`;if(d?.type==="symbolic"&&f!==a?await ne(e,r,d.target,f,a,l,!0):(d?.type==="symbolic"||f!==a)&&await ne(e,r,"HEAD",f,a,l),await zn(e),n==="mixed"){let m=await qe(e,c.tree),h=hs(m.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Ce()})));await se(e,h);let p=await Bf(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=ze(e);if(m)return m;let h=await K(e),p=await cn(e,c.tree,h);await se(e,{version:2,entries:p.newEntries}),await He(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${z(a)} ${ae(c.message)}
580
+ `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}re();Re();ie();ue();Se();tt();function Wf(e,t){e.command("restore",{description:"Restore working tree files",args:[W.string().name("pathspec").variadic().optional()],options:{source:te.string().alias("s").describe("Restore from tree-ish"),staged:S().alias("S").describe("Restore the index"),worktree:S().alias("W").describe("Restore the working tree (default)"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return $("you must specify path(s) to restore");if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,d=lt(i,r.cwd);if(n.ours||n.theirs)return n.source?$("cannot specify both --source and --ours/--theirs"):c?$("cannot use --ours/--theirs with --staged"):Us(i,a,d,n.theirs?3:2,{deleteOnMissing:!0});let l=null;if(n.source){let u=await $e(i,n.source,`could not resolve '${n.source}'`);if(v(u))return u;l=u.commit.tree}else if(c){let u=await X(i);u&&(l=(await M(i,u)).tree)}return c&&f?Vh(i,a,d,l):c?Kh(i,a,d,l):l?zh(i,a,d,l):Fs(i,a,d)}})}async function Kh(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(f=>Ge(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!ye(i,f))continue;c=!0;let d=o.get(f);if(d)s=wt(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:Ce()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
581
581
  `,exitCode:1};s=ot(s,f)}}return c?(await se(e,s),{stdout:"",stderr:"",exitCode:0}):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
582
- `)}async function Kh(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=t.map(f=>Ge(f,n)),i=[],a=await K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(l=>l.path===f&&l.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
582
+ `)}async function zh(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=t.map(f=>Ge(f,n)),i=[],a=await K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(l=>l.path===f&&l.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
583
583
  `,exitCode:1};i.push(f)}if(i.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
584
- `);for(let f of i){let d=o.get(f);if(d)await it(e,{path:d.path,hash:d.hash,mode:d.mode});else{let l=`${e.workTree}/${f}`;await e.fs.exists(l)&&await e.fs.rm(l)}}return{stdout:"",stderr:"",exitCode:0}}async function zh(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=await K(e),i=t.map(f=>Ge(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)ye(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
584
+ `);for(let f of i){let d=o.get(f);if(d)await it(e,{path:d.path,hash:d.hash,mode:d.mode});else{let l=`${e.workTree}/${f}`;await e.fs.exists(l)&&await e.fs.rm(l)}}return{stdout:"",stderr:"",exitCode:0}}async function Vh(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=await K(e),i=t.map(f=>Ge(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)ye(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
585
585
  `);for(let f of a){let d=o.get(f);if(d)s=wt(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:Ce()}),await it(e,{path:d.path,hash:d.hash,mode:d.mode});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
586
- `,exitCode:1};s=ot(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await se(e,s),{stdout:"",stderr:"",exitCode:0}}re();de();ue();on();function Wf(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[W.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:S().describe("Verify that exactly one parameter is provided and resolves to an object"),short:S().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":S().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":S().describe("Output the full symbolic ref name"),"show-toplevel":S().describe("Show the absolute path of the top-level directory"),"git-dir":S().describe("Show the path to the .git directory"),"is-inside-work-tree":S().describe("Output whether cwd is inside the work tree"),"is-bare-repository":S().describe("Output whether the repository is bare"),"show-prefix":S().describe("Show path of cwd relative to top-level directory"),"show-cdup":S().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],d=n["git-dir"],l=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||d||l||u||m||h,g=await B(r.fs,r.cwd,t);if(v(g))return g;let w=g,E=[];if(f){if(!w.workTree)return $("this operation must be run in a work tree");E.push(w.workTree)}if(d&&E.push(w.gitDir),l&&E.push(w.workTree?"true":"false"),u&&E.push(w.workTree?"false":"true"),m){if(!w.workTree)return $("this operation must be run in a work tree");let b=at(w.workTree,r.cwd);E.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return $("this operation must be run in a work tree");let b=at(r.cwd,w.workTree);E.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:E.map(k=>`${k}
587
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return $("Needed a single revision");for(let b of o){if(a){let R=await Vh(w,b);if(R===null)return vi(b,s);E.push(R);continue}if(c){let R=await Yh(w,b);if(R===null)return vi(b,s);E.push(R);continue}let k=await We(w,b);if(!k)return vi(b,s);E.push(i?z(k):k)}return{stdout:E.map(b=>`${b}
588
- `).join(""),stderr:"",exitCode:0}}})}function vi(e,t){return t?$("Needed a single revision"):Bt(e)}async function Vh(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function Yh(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await U(e,o))return o}return t}re();Re();ie();je();ue();Se();function qf(e,t){e.command("revert",{description:"Revert some existing commits",args:[W.string().name("commit").describe("The commit to revert").optional()],options:{abort:S().describe("Abort the current revert operation"),continue:S().describe("Continue the revert after conflict resolution"),"no-commit":S().alias("n").describe("Apply changes without creating a commit"),"no-edit":S().describe("Do not edit the commit message"),mainline:te.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort){let N=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(Q(N))return{stdout:"",stderr:N.message??"",exitCode:1};let q=await Xh(s,r.env);return q.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),q}if(n.continue){let N=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(Q(N))return{stdout:"",stderr:N.message??"",exitCode:1};let q=await Zh(s,r.env);return q.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),q}let i=n.commit;if(!i)return $("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:i});if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await $e(s,i);if(v(c))return c;let f=c.hash,d=c.commit,l=await Ve(s);if(v(l))return l;let u=await K(s),m=fn(u,"Reverting",`fatal: revert failed
586
+ `,exitCode:1};s=ot(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await se(e,s),{stdout:"",stderr:"",exitCode:0}}re();de();ue();on();function qf(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[W.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:S().describe("Verify that exactly one parameter is provided and resolves to an object"),short:S().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":S().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":S().describe("Output the full symbolic ref name"),"show-toplevel":S().describe("Show the absolute path of the top-level directory"),"git-dir":S().describe("Show the path to the .git directory"),"is-inside-work-tree":S().describe("Output whether cwd is inside the work tree"),"is-bare-repository":S().describe("Output whether the repository is bare"),"show-prefix":S().describe("Show path of cwd relative to top-level directory"),"show-cdup":S().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],d=n["git-dir"],l=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||d||l||u||m||h,g=await B(r.fs,r.cwd,t);if(v(g))return g;let w=g,E=[];if(f){if(!w.workTree)return $("this operation must be run in a work tree");E.push(w.workTree)}if(d&&E.push(w.gitDir),l&&E.push(w.workTree?"true":"false"),u&&E.push(w.workTree?"false":"true"),m){if(!w.workTree)return $("this operation must be run in a work tree");let b=at(w.workTree,r.cwd);E.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return $("this operation must be run in a work tree");let b=at(r.cwd,w.workTree);E.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:E.map(k=>`${k}
587
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return $("Needed a single revision");for(let b of o){if(a){let R=await Yh(w,b);if(R===null)return Ai(b,s);E.push(R);continue}if(c){let R=await Xh(w,b);if(R===null)return Ai(b,s);E.push(R);continue}let k=await We(w,b);if(!k)return Ai(b,s);E.push(i?z(k):k)}return{stdout:E.map(b=>`${b}
588
+ `).join(""),stderr:"",exitCode:0}}})}function Ai(e,t){return t?$("Needed a single revision"):Bt(e)}async function Yh(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function Xh(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await U(e,o))return o}return t}re();Re();ie();je();ue();Se();function Kf(e,t){e.command("revert",{description:"Revert some existing commits",args:[W.string().name("commit").describe("The commit to revert").optional()],options:{abort:S().describe("Abort the current revert operation"),continue:S().describe("Continue the revert after conflict resolution"),"no-commit":S().alias("n").describe("Apply changes without creating a commit"),"no-edit":S().describe("Do not edit the commit message"),mainline:te.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.abort){let N=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(Q(N))return{stdout:"",stderr:N.message??"",exitCode:1};let q=await Zh(s,r.env);return q.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),q}if(n.continue){let N=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(Q(N))return{stdout:"",stderr:N.message??"",exitCode:1};let q=await Jh(s,r.env);return q.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),q}let i=n.commit;if(!i)return $("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:i});if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await $e(s,i);if(v(c))return c;let f=c.hash,d=c.commit,l=await Ve(s);if(v(l))return l;let u=await K(s),m=fn(u,"Reverting",`fatal: revert failed
589
589
  `);if(m)return m;let h=await M(s,l);if(s.workTree){let N=await ce(s,h.tree);if(ar(u,N))return _(`error: your local changes would be overwritten by revert.
590
590
  hint: commit your changes or stash them to proceed.
591
591
  fatal: revert failed
@@ -593,7 +593,7 @@ fatal: revert failed
593
593
  fatal: revert failed
594
594
  `,128);if(p<1||p>d.parents.length)return _(`error: commit ${f} does not have parent ${p}
595
595
  fatal: revert failed
596
- `,128);let N=d.parents[p-1];g=(await M(s,N)).tree}else if(d.parents.length===0)g=await De(s,[]);else{let N=d.parents[0];g=(await M(s,N)).tree}let w=z(f),E=ae(d.message),x=Jh(d,f,p),b={a:"HEAD",b:E?`parent of ${w} (${E})`:`parent of ${w}`},k=await Nt(s,d.tree,h.tree,g,b);if(k.conflicts.length===0&&k.resultTree===h.tree){let N=k.messages.length>0?`${k.messages.join(`
596
+ `,128);let N=d.parents[p-1];g=(await M(s,N)).tree}else if(d.parents.length===0)g=await De(s,[]);else{let N=d.parents[0];g=(await M(s,N)).tree}let w=z(f),E=ae(d.message),x=Qh(d,f,p),b={a:"HEAD",b:E?`parent of ${w} (${E})`:`parent of ${w}`},k=await Nt(s,d.tree,h.tree,g,b);if(k.conflicts.length===0&&k.resultTree===h.tree){let N=k.messages.length>0?`${k.messages.join(`
597
597
  `)}
598
598
  `:"",q=await rt(s,{fromCommit:!0}),D=await U(s,"CHERRY_PICK_HEAD");return{stdout:`${N}${q}`,stderr:D?`The previous cherry-pick is now empty, possibly due to conflict resolution.
599
599
  If you wish to commit it anyway, use:
@@ -614,25 +614,25 @@ hint: Disable this message with "git config set advice.mergeConflict false"
614
614
  `,exitCode:1}}if(n["no-commit"])return await Y(s,"REVERT_HEAD",f),await Oe(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let C=R.mergedTreeHash,P=await en(s,r.env);if(v(P))return P;let y=await Ze(s,r.env);if(v(y))return y;let I=await ut(s,C,[l],P,y,x);await Dt(s),await Wt(s);let O=await Z(s),j=ae(x),G=O?.type==="symbolic"?O.target:"HEAD";await ne(s,r.env,G,l,I,`revert: ${j}`,O?.type==="symbolic");let V=O?.type==="symbolic"?be(O.target):"detached HEAD",A=await nn(s,h.tree,C,P,y,P.timestamp!==y.timestamp||P.timezone!==y.timezone),H=Ht(V,I,x),L=k.messages.length>0?`${k.messages.join(`
615
615
  `)}
616
616
  `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:I,hadConflicts:!1}),{stdout:`${L}${H}
617
- ${A}`,stderr:"",exitCode:0}}})}async function Xh(e,t){return await U(e,"REVERT_HEAD")?Pn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
617
+ ${A}`,stderr:"",exitCode:0}}})}async function Zh(e,t){return await U(e,"REVERT_HEAD")?Pn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
618
618
  fatal: revert failed
619
619
  `,128),operationName:"revert",clearState:Dt,origHeadAsTargetRev:!0}):await U(e,"CHERRY_PICK_HEAD")?Pn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
620
620
  fatal: revert failed
621
621
  `,128),operationName:"revert",clearState:Wt,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
622
622
  fatal: revert failed
623
- `,128)}async function Zh(e,t){if(!await U(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
623
+ `,128)}async function Jh(e,t){if(!await U(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
624
624
  fatal: revert failed
625
625
  `,128);let r=await K(e),o=fn(r,"Committing");if(o)return o;let s=await ke(e,"MERGE_MSG");if(!s)return _(`Aborting commit due to empty commit message.
626
626
  `,1);let i=Ae(r),a=await De(e,i),c=await Ve(e);if(v(c))return c;let f=await M(e,c),d=await en(e,t);if(v(d))return d;let l=await Ze(e,t);if(v(l))return l;let u=await U(e,"CHERRY_PICK_HEAD");u&&(d=(await M(e,u)).author);let m=vt(s),h=await ut(e,a,[c],d,l,m);await Dt(e),await Wt(e);let p=await Z(e),g=ae(m),w=p?.type==="symbolic"?p.target:"HEAD";await ne(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let E=p?.type==="symbolic"?be(p.target):"detached HEAD",x=await nn(e,f.tree,a,d,l,d.timestamp!==l.timestamp||d.timezone!==l.timezone);return{stdout:`${Ht(E,h,s)}
627
- ${x}`,stderr:"",exitCode:0}}function Jh(e,t,n){let r=ae(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
627
+ ${x}`,stderr:"",exitCode:0}}function Qh(e,t,n){let r=ae(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
628
628
 
629
629
  This reverts commit ${t}`;if(n!==void 0&&e.parents.length>1&&n>=1){let c=e.parents[n===1?1:0]??e.parents[0];a+=`, reversing
630
630
  changes made to ${c}`}return a+=`.
631
- `,a}re();Re();ie();de();ue();_n();Se();function Kf(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[W.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:S().describe("Only remove from the index"),recursive:S().alias("r").describe("Allow recursive removal when a directory name is given"),force:S().alias("f").describe("Override the up-to-date check"),dryRun:S().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,d=n.recursive,l=n.force,u=await t?.hooks?.preRm?.({repo:s,paths:c,cached:f,recursive:d,force:l});if(Q(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await K(s),h=[],p=lt(s,r.cwd);for(let E of c){if(qn(E)){let R=[Ge(E,p)],C=m.entries.filter(P=>ye(R,P.path));if(C.length===0)return $(`pathspec '${E}' did not match any files`);for(let P of C)h.push(P.path);continue}let x=It(r.cwd,E),b=at(a,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return $(`'${E}' is outside repository at '${a}'`);if(await r.fs.exists(x)&&!(await ct(r.fs,x)).isSymbolicLink&&(await ct(r.fs,x)).isDirectory){if(!d)return $(`not removing '${b}' recursively without -r`);let R=b===""?"":`${b}/`,C=m.entries.filter(P=>R===""||P.path.startsWith(R));if(C.length===0)return $(`pathspec '${E}' did not match any files`);for(let P of C)h.push(P.path)}else{if(!m.entries.some(C=>C.path===b))return $(`pathspec '${E}' did not match any files`);h.push(b)}}if(!l){let E=await Qh(s,m,h,f);if(E)return E}if(n.dryRun){let E=h.map(b=>`rm '${b}'`);return{stdout:E.length>0?`${E.join(`
631
+ `,a}re();Re();ie();de();ue();_n();Se();function zf(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[W.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:S().describe("Only remove from the index"),recursive:S().alias("r").describe("Allow recursive removal when a directory name is given"),force:S().alias("f").describe("Override the up-to-date check"),dryRun:S().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,i=ze(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,d=n.recursive,l=n.force,u=await t?.hooks?.preRm?.({repo:s,paths:c,cached:f,recursive:d,force:l});if(Q(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await K(s),h=[],p=lt(s,r.cwd);for(let E of c){if(qn(E)){let R=[Ge(E,p)],C=m.entries.filter(P=>ye(R,P.path));if(C.length===0)return $(`pathspec '${E}' did not match any files`);for(let P of C)h.push(P.path);continue}let x=It(r.cwd,E),b=at(a,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return $(`'${E}' is outside repository at '${a}'`);if(await r.fs.exists(x)&&!(await ct(r.fs,x)).isSymbolicLink&&(await ct(r.fs,x)).isDirectory){if(!d)return $(`not removing '${b}' recursively without -r`);let R=b===""?"":`${b}/`,C=m.entries.filter(P=>R===""||P.path.startsWith(R));if(C.length===0)return $(`pathspec '${E}' did not match any files`);for(let P of C)h.push(P.path)}else{if(!m.entries.some(C=>C.path===b))return $(`pathspec '${E}' did not match any files`);h.push(b)}}if(!l){let E=await ep(s,m,h,f);if(E)return E}if(n.dryRun){let E=h.map(b=>`rm '${b}'`);return{stdout:E.length>0?`${E.join(`
632
632
  `)}
633
633
  `:"",stderr:"",exitCode:0}}let g=[];for(let E of h){if(m=ot(m,E),!f){let x=T(a,E);await ct(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}g.push(`rm '${E}'`)}await se(s,m);let w=g.length>0?`${g.join(`
634
634
  `)}
635
- `:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function Qh(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await M(e,o),d=await qe(e,f.tree);for(let l of d)s.set(l.path,l.hash)}let i=[],a=[],c=[];for(let f of n){let d=t.entries.find(h=>h.path===f&&h.stage===0);if(!d)continue;let u=s.get(f)!==d.hash,m=!1;if(e.workTree){let h=T(e.workTree,f),p=!1;try{await ct(e.fs,h),p=!0}catch{p=!1}p&&(m=await Rn(e.fs,h)!==d.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(l=>` ${l}`).join(`
635
+ `:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function ep(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await M(e,o),d=await qe(e,f.tree);for(let l of d)s.set(l.path,l.hash)}let i=[],a=[],c=[];for(let f of n){let d=t.entries.find(h=>h.path===f&&h.stage===0);if(!d)continue;let u=s.get(f)!==d.hash,m=!1;if(e.workTree){let h=T(e.workTree,f),p=!1;try{await ct(e.fs,h),p=!0}catch{p=!1}p&&(m=await Rn(e.fs,h)!==d.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(l=>` ${l}`).join(`
636
636
  `),d=i.length===1?"the following file has":"the following files have";return _(`error: ${d} staged content different from both the
637
637
  file and the HEAD:
638
638
  ${f}
@@ -645,27 +645,27 @@ ${f}
645
645
  `),d=c.length===1?"the following file has":"the following files have";return _(`error: ${d} local modifications:
646
646
  ${f}
647
647
  (use --cached to keep the file, or -f to force removal)
648
- `)}return null}re();ie();on();Rs();de();Se();var Ai=new TextDecoder;function zf(e,t){e.command("show",{description:"Show various types of objects",args:[W.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,a=n.object[0]??"HEAD",c=$a(a);if(c)return ep(s,c.rev,c.path);if(a==="HEAD"){let l=await Ve(s);if(v(l))return l}let f=await St(s,a,`bad object '${a}'`);if(v(f))return f;let d=await we(s,f);switch(d.type){case"commit":{let l=await M(s,f);return{stdout:await Vf(s,f,l),stderr:"",exitCode:0}}case"tag":{let l=await ka(s,f);return{stdout:await tp(s,l),stderr:"",exitCode:0}}case"tree":{let l=xn(d.content);return{stdout:Yf(l),stderr:"",exitCode:0}}case"blob":return{stdout:Ai.decode(d.content),stderr:"",exitCode:0}}}})}async function ep(e,t,n){let r=await $e(e,t);if(v(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await ce(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let d=T(e.workTree,s);await e.fs.exists(d)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return $(f)}let c=await we(e,a.hash);if(c.type==="blob")return{stdout:Ai.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=xn(c.content);return{stdout:Yf(f),stderr:"",exitCode:0}}return{stdout:Ai.decode(c.content),stderr:"",exitCode:0}}async function Vf(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(i=>z(i)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${Gt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
649
- `))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await M(e,n.parents[0])).tree:null,i=await _e(e,s,n.tree),{remaining:a,renames:c}=await nt(e,i),f=await sp(e,a,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await op(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
648
+ `)}return null}re();ie();on();Rs();de();Se();var Di=new TextDecoder;function Vf(e,t){e.command("show",{description:"Show various types of objects",args:[W.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o,a=n.object[0]??"HEAD",c=Sa(a);if(c)return tp(s,c.rev,c.path);if(a==="HEAD"){let l=await Ve(s);if(v(l))return l}let f=await St(s,a,`bad object '${a}'`);if(v(f))return f;let d=await we(s,f);switch(d.type){case"commit":{let l=await M(s,f);return{stdout:await Yf(s,f,l),stderr:"",exitCode:0}}case"tag":{let l=await Ra(s,f);return{stdout:await np(s,l),stderr:"",exitCode:0}}case"tree":{let l=xn(d.content);return{stdout:Xf(l),stderr:"",exitCode:0}}case"blob":return{stdout:Di.decode(d.content),stderr:"",exitCode:0}}}})}async function tp(e,t,n){let r=await $e(e,t);if(v(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await ce(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let d=T(e.workTree,s);await e.fs.exists(d)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return $(f)}let c=await we(e,a.hash);if(c.type==="blob")return{stdout:Di.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=xn(c.content);return{stdout:Xf(f),stderr:"",exitCode:0}}return{stdout:Di.decode(c.content),stderr:"",exitCode:0}}async function Yf(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(i=>z(i)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${Gt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
649
+ `))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await M(e,n.parents[0])).tree:null,i=await _e(e,s,n.tree),{remaining:a,renames:c}=await nt(e,i),f=await op(e,a,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await ip(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
650
650
  `)}
651
- `}async function tp(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${Gt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
652
- `))n.push(` ${o}`);if(t.objectType==="commit"){let o=await M(e,t.object),s=await Vf(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
651
+ `}async function np(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${Gt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
652
+ `))n.push(` ${o}`);if(t.objectType==="commit"){let o=await M(e,t.object),s=await Yf(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
653
653
  `)}
654
- `}function Yf(e){let t=[];for(let n of e.entries){let r=n.mode==="040000"?"tree":"blob";t.push(`${n.mode} ${r} ${n.hash} ${n.name}`)}return t.length>0?`${t.join(`
654
+ `}function Xf(e){let t=[];for(let n of e.entries){let r=n.mode==="040000"?"tree":"blob";t.push(`${n.mode} ${r} ${n.hash} ${n.name}`)}return t.length>0?`${t.join(`
655
655
  `)}
656
- `:""}async function np(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function rp(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.oldPath,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash,renameTo:t.newPath,similarity:t.similarity})}async function sp(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await rp(e,s.entry):o+=await np(e,s.entry);return o}async function op(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await M(e,a);return ce(e,c.tree)})),r=await ce(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(l=>(l.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await ip(e,a,n,r);return i}async function ip(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(u=>u?.hash??null),f=s.map(u=>u?.mode??null),d=await Promise.all(c.map(async u=>u?await oe(e,u):"")),l=i?await oe(e,i):"";return so({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:i,resultMode:a,resultContent:l})}re();Re();ie();ue();re();hn();Re();ie();rn();de();je();ue();Se();Qt();tt();var Kt="refs/stash";function Mi(e,t){return xe(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Xf(e){let t=await Xe(e,Kt),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function Er(e,t){let n=await Xe(e,Kt);if(n.length===0)return null;let r=n.length-1-t;return r<0||r>=n.length?null:n[r]?.newHash??null}async function Zf(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await M(e,s),a=await K(e),c=Ae(a),f=await De(e,c),d=await _e(e,i.tree,f),l=new Map(c.map(D=>[D.path,D])),u=await et(e,o,"",{skipIgnore:!0}),m=!1;for(let D of u){let F=l.get(D);if(!F)continue;let ee=T(o,D),Pe=await e.fs.readFileBuffer(ee);if(await bt("blob",Pe)!==F.hash){m=!0;break}}if(!m)for(let[D]of l){let F=T(o,D);if(!await e.fs.exists(F)){m=!0;break}}let h=[];if(r?.includeUntracked){let D=await et(e,o,"");for(let F of D)l.has(F)||h.push(F)}if(d.length===0&&!m&&h.length===0)return null;let p=await ls(e,t),g=await Pr(e,t),w=await Z(e),E=w?.type==="symbolic"?be(w.target):"(no branch)",x=z(s),b=ae(i.message),k=`index on ${E}: ${x} ${b}
656
+ `:""}async function rp(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function sp(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.oldPath,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash,renameTo:t.newPath,similarity:t.similarity})}async function op(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await sp(e,s.entry):o+=await rp(e,s.entry);return o}async function ip(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await M(e,a);return ce(e,c.tree)})),r=await ce(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(l=>(l.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await ap(e,a,n,r);return i}async function ap(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(u=>u?.hash??null),f=s.map(u=>u?.mode??null),d=await Promise.all(c.map(async u=>u?await oe(e,u):"")),l=i?await oe(e,i):"";return so({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:i,resultMode:a,resultContent:l})}re();Re();ie();ue();re();hn();Re();ie();rn();de();je();ue();Se();Qt();tt();var Kt="refs/stash";function ji(e,t){return xe(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Zf(e){let t=await Xe(e,Kt),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function Er(e,t){let n=await Xe(e,Kt);if(n.length===0)return null;let r=n.length-1-t;return r<0||r>=n.length?null:n[r]?.newHash??null}async function Jf(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await M(e,s),a=await K(e),c=Ae(a),f=await De(e,c),d=await _e(e,i.tree,f),l=new Map(c.map(D=>[D.path,D])),u=await et(e,o,"",{skipIgnore:!0}),m=!1;for(let D of u){let F=l.get(D);if(!F)continue;let ee=T(o,D),Pe=await e.fs.readFileBuffer(ee);if(await bt("blob",Pe)!==F.hash){m=!0;break}}if(!m)for(let[D]of l){let F=T(o,D);if(!await e.fs.exists(F)){m=!0;break}}let h=[];if(r?.includeUntracked){let D=await et(e,o,"");for(let F of D)l.has(F)||h.push(F)}if(d.length===0&&!m&&h.length===0)return null;let p=await ls(e,t),g=await Pr(e,t),w=await Z(e),E=w?.type==="symbolic"?be(w.target):"(no branch)",x=z(s),b=ae(i.message),k=`index on ${E}: ${x} ${b}
657
657
  `,R=Xt({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),C=await Ie(e,"commit",R),P=await ce(e,i.tree),y=[],I=new Set;for(let D of u){let F=l.get(D),ee=P.get(D);if(!F&&!ee)continue;let Pe=T(o,D),Le=await e.fs.readFileBuffer(Pe),Ke=await Ie(e,"blob",Le),ge=F?F.mode:parseInt(ee?.mode??"100644",8);y.push({path:D,mode:ge,hash:Ke,stage:0,stat:Ce()}),I.add(D)}for(let[D,F]of l)I.has(D)||P.has(D)||y.push({path:D,mode:F.mode,hash:F.hash,stage:0,stat:Ce()});let O=await De(e,y),j=null;if(r?.includeUntracked){let D=[];for(let Le of h){let Ke=T(o,Le),ge=await e.fs.readFileBuffer(Ke),Me=await Ie(e,"blob",ge);D.push({path:Le,mode:33188,hash:Me,stage:0,stat:Ce()})}let F=await De(e,D),ee=`untracked files on ${E}: ${x} ${b}
658
- `,Pe=Xt({type:"commit",tree:F,parents:[],author:p,committer:g,message:ee});j=await Ie(e,"commit",Pe)}let G=n?`On ${E}: ${n}`:`WIP on ${E}: ${x} ${b}`,V=[s,C];j&&V.push(j);let A=Xt({type:"commit",tree:O,parents:V,author:p,committer:g,message:G}),H=await Ie(e,"commit",A),L=await Er(e,0)??J;await Be(e,Kt,{oldHash:L,newHash:H,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:G.trimEnd()}),await Y(e,Kt,H);let N=await cn(e,i.tree,a);await se(e,{version:2,entries:N.newEntries}),await He(e,N.worktreeOps),(await Z(e))?.type==="symbolic"&&await ne(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let D of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await fe(e,D);for(let D of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let F=T(e.gitDir,D);await e.fs.exists(F)&&await e.fs.rm(F)}if(h.length>0)for(let D of h){if(P.has(D))continue;let F=T(o,D);await e.fs.exists(F)&&(await e.fs.rm(F),await Bn(e.fs,zt(F),o))}return H}async function Di(e,t){let n=e.workTree,r=await M(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=T(n,i.path);await e.fs.exists(a)?s.push(i.path):await it(e,i)}return s.length>0?(s.sort(Mi),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
658
+ `,Pe=Xt({type:"commit",tree:F,parents:[],author:p,committer:g,message:ee});j=await Ie(e,"commit",Pe)}let G=n?`On ${E}: ${n}`:`WIP on ${E}: ${x} ${b}`,V=[s,C];j&&V.push(j);let A=Xt({type:"commit",tree:O,parents:V,author:p,committer:g,message:G}),H=await Ie(e,"commit",A),L=await Er(e,0)??J;await Be(e,Kt,{oldHash:L,newHash:H,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:G.trimEnd()}),await Y(e,Kt,H);let N=await cn(e,i.tree,a);await se(e,{version:2,entries:N.newEntries}),await He(e,N.worktreeOps),(await Z(e))?.type==="symbolic"&&await ne(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let D of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await fe(e,D);for(let D of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let F=T(e.gitDir,D);await e.fs.exists(F)&&await e.fs.rm(F)}if(h.length>0)for(let D of h){if(P.has(D))continue;let F=T(o,D);await e.fs.exists(F)&&(await e.fs.rm(F),await Bn(e.fs,zt(F),o))}return H}async function Mi(e,t){let n=e.workTree,r=await M(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=T(n,i.path);await e.fs.exists(a)?s.push(i.path):await it(e,i)}return s.length>0?(s.sort(ji),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
659
659
  `)}
660
660
  error: could not restore untracked files from stash
661
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function ji(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
661
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Gi(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
662
662
  `,exitCode:128};let n=await Er(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
663
663
  `,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
664
664
  `,exitCode:1};let o=await K(e),s=Ft(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(P=>`${P}: needs merge`).join(`
665
665
  `)}
666
666
  `,stderr:`error: could not write index
667
667
  `,exitCode:1};let i=await M(e,n),a=i.parents[0];if(!a)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
668
- `,exitCode:1};let c=await M(e,a),f=i.parents[2],d=Ae(o),l=await De(e,d),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let C=await Di(e,f);if(!C.ok)return{...C,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await Nt(e,c.tree,l,i.tree,u),h=await ce(e,l),p=await ce(e,m.resultTree),g=[];for(let[C,P]of p){let y=h.get(C);(!y||y.hash!==P.hash)&&g.push({path:C,type:"checkout",hash:P.hash,mode:parseInt(P.mode,8)})}for(let[C]of h)p.has(C)||g.push({path:C,type:"delete"});let w=new Map(d.map(C=>[C.path,C])),E=[],x=[];for(let C of g){let P=w.get(C.path),y=T(e.workTree,C.path);if(P){if(!await e.fs.exists(y))continue;let I=await e.fs.readFileBuffer(y);await bt("blob",I)!==P.hash&&E.push(C.path)}else C.type==="checkout"&&await e.fs.exists(y)&&x.push(C.path)}if(E.length>0||x.length>0){E.sort(Mi),x.sort(Mi);let C="";if(E.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
668
+ `,exitCode:1};let c=await M(e,a),f=i.parents[2],d=Ae(o),l=await De(e,d),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let C=await Mi(e,f);if(!C.ok)return{...C,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await Nt(e,c.tree,l,i.tree,u),h=await ce(e,l),p=await ce(e,m.resultTree),g=[];for(let[C,P]of p){let y=h.get(C);(!y||y.hash!==P.hash)&&g.push({path:C,type:"checkout",hash:P.hash,mode:parseInt(P.mode,8)})}for(let[C]of h)p.has(C)||g.push({path:C,type:"delete"});let w=new Map(d.map(C=>[C.path,C])),E=[],x=[];for(let C of g){let P=w.get(C.path),y=T(e.workTree,C.path);if(P){if(!await e.fs.exists(y))continue;let I=await e.fs.readFileBuffer(y);await bt("blob",I)!==P.hash&&E.push(C.path)}else C.type==="checkout"&&await e.fs.exists(y)&&x.push(C.path)}if(E.length>0||x.length>0){E.sort(ji),x.sort(ji);let C="";if(E.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
669
669
  ${E.map(P=>` ${P}`).join(`
670
670
  `)}
671
671
  Please commit your changes or stash them before you merge.
@@ -674,43 +674,43 @@ ${x.map(P=>` ${P}`).join(`
674
674
  `)}
675
675
  Please move or remove them before you merge.
676
676
  `),C+=`Aborting
677
- `,f){let P=await Di(e,f);P.ok||(C+=P.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await He(e,g);let b=new Set(m.conflicts.map(C=>C.path)),k=new Set;for(let C of m.entries)C.stage>0&&k.add(C.path);let R=b.size>0;if(R){let C=[];for(let[P,y]of p){if(b.has(P)||k.has(P))continue;let I=w.get(P);C.push({path:P,mode:parseInt(y.mode,8),hash:y.hash,stage:0,stat:I?.stat??Ce()})}for(let P of m.entries)P.stage>0&&C.push(P);C.sort((P,y)=>xe(P.path,y.path)||P.stage-y.stage),await se(e,{version:2,entries:C})}else{let C=[...o.entries],P=new Set(C.map(y=>y.path));for(let[y,I]of p)h.has(y)||P.has(y)||C.push({path:y,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:Ce()});C.sort((y,I)=>xe(y.path,I.path)||y.stage-I.stage),await se(e,{version:2,entries:C})}if(f){let C=await Di(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:R,messages:m.messages}}async function Gi(e,t=0){let n=await Xe(e,Kt);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await fe(e,Kt),await Mr(e,Kt);else{await kn(e,Kt,n);let o=n[n.length-1];o&&await Y(e,Kt,o.newHash)}return null}async function Jf(e){await fe(e,Kt),await Mr(e,Kt)}Se();function mo(e){if(e===void 0)return 0;let t=e.match(/^(?:stash@\{)?(\d+)\}?$/);if(t?.[1]!==void 0)return parseInt(t[1],10);let n=parseInt(e,10);return!Number.isNaN(n)&&n>=0?n:-1}async function ap(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Mn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function jn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function ed(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"push",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Qf(s,o.env,r.message,r["include-untracked"]);return await jn(t,s,"push",a.exitCode===0),a}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"push",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Qf(s,o.env,r.message,r["include-untracked"]);return await jn(t,s,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"pop",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await cp(s,r.stash);return await jn(t,s,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"apply",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await fp(s,r.stash);return await jn(t,s,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"list",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await dp(s);return await jn(t,s,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"drop",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await lp(s,r.stash);return await jn(t,s,"drop",a.exitCode===0),a}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"show",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await up(s,r.stash);return await jn(t,s,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"clear",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await mp(s);return await jn(t,s,"clear",a.exitCode===0),a}})}async function Qf(e,t,n,r){if(!await X(e))return _(`You do not have the initial commit yet
677
+ `,f){let P=await Mi(e,f);P.ok||(C+=P.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await He(e,g);let b=new Set(m.conflicts.map(C=>C.path)),k=new Set;for(let C of m.entries)C.stage>0&&k.add(C.path);let R=b.size>0;if(R){let C=[];for(let[P,y]of p){if(b.has(P)||k.has(P))continue;let I=w.get(P);C.push({path:P,mode:parseInt(y.mode,8),hash:y.hash,stage:0,stat:I?.stat??Ce()})}for(let P of m.entries)P.stage>0&&C.push(P);C.sort((P,y)=>xe(P.path,y.path)||P.stage-y.stage),await se(e,{version:2,entries:C})}else{let C=[...o.entries],P=new Set(C.map(y=>y.path));for(let[y,I]of p)h.has(y)||P.has(y)||C.push({path:y,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:Ce()});C.sort((y,I)=>xe(y.path,I.path)||y.stage-I.stage),await se(e,{version:2,entries:C})}if(f){let C=await Mi(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:R,messages:m.messages}}async function Li(e,t=0){let n=await Xe(e,Kt);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await fe(e,Kt),await jr(e,Kt);else{await kn(e,Kt,n);let o=n[n.length-1];o&&await Y(e,Kt,o.newHash)}return null}async function Qf(e){await fe(e,Kt),await jr(e,Kt)}Se();function mo(e){if(e===void 0)return 0;let t=e.match(/^(?:stash@\{)?(\d+)\}?$/);if(t?.[1]!==void 0)return parseInt(t[1],10);let n=parseInt(e,10);return!Number.isNaN(n)&&n>=0?n:-1}async function cp(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Rt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Mn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function jn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function td(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"push",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await ed(s,o.env,r.message,r["include-untracked"]);return await jn(t,s,"push",a.exitCode===0),a}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"push",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await ed(s,o.env,r.message,r["include-untracked"]);return await jn(t,s,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"pop",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await fp(s,r.stash);return await jn(t,s,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"apply",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await dp(s,r.stash);return await jn(t,s,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"list",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await lp(s);return await jn(t,s,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"drop",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await up(s,r.stash);return await jn(t,s,"drop",a.exitCode===0),a}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"show",r.stash??null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await mp(s,r.stash);return await jn(t,s,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let i=await Mn(t,s,"clear",null);if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await hp(s);return await jn(t,s,"clear",a.exitCode===0),a}})}async function ed(e,t,n,r){if(!await X(e))return _(`You do not have the initial commit yet
678
678
  `);let s=await K(e),i=Ft(s).sort();if(i.length>0)return{stdout:`${i.map(d=>`${d}: needs merge`).join(`
679
679
  `)}
680
680
  `,stderr:`error: could not write index
681
- `,exitCode:1};let a;try{a=await Zf(e,t,n,{includeUntracked:r})}catch(d){return $(d.message)}return a?{stdout:`Saved working directory and index state ${(await M(e,a)).message.trim()}
681
+ `,exitCode:1};let a;try{a=await Jf(e,t,n,{includeUntracked:r})}catch(d){return $(d.message)}return a?{stdout:`Saved working directory and index state ${(await M(e,a)).message.trim()}
682
682
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
683
- `,stderr:"",exitCode:0}}async function cp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await ji(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
683
+ `,stderr:"",exitCode:0}}async function fp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Gi(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
684
684
  `)}
685
685
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
686
686
  `,stderr:o.stderr,exitCode:o.exitCode};let d=await rt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
687
687
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
688
688
  `)}
689
689
  `:"",d=await rt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
690
- `,stderr:"",exitCode:1}}let s=await Gi(e,n);if(s)return _(s);let i=o.messages.length>0?`${o.messages.join(`
690
+ `,stderr:"",exitCode:1}}let s=await Li(e,n);if(s)return _(s);let i=o.messages.length>0?`${o.messages.join(`
691
691
  `)}
692
692
  `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await rt(e);return{stdout:`${i}${c}Dropped ${a} (${r})
693
- `,stderr:"",exitCode:0}}async function fp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await ji(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
693
+ `,stderr:"",exitCode:0}}async function dp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Gi(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
694
694
  `)}
695
695
  `:"",c=r.stdout;return c||(c=await rt(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
696
696
  `)}
697
- `:"",s=await rt(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function dp(e){let t=await Xf(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
697
+ `:"",s=await rt(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function lp(e){let t=await Zf(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
698
698
  `)}
699
- `,stderr:"",exitCode:0}}async function lp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Gi(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
700
- `,stderr:"",exitCode:0}}async function up(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await M(e,r),s=o.parents[0];if(!s)return _("error: invalid stash commit (no parent)");let i=await M(e,s),a=await _e(e,i.tree,o.tree),c="";for(let f of a)c+=await ap(e,f);return{stdout:c,stderr:"",exitCode:0}}async function mp(e){return await Jf(e),{stdout:"",stderr:"",exitCode:0}}re();Re();ue();tt();function td(e,t){e.command("status",{description:"Show the working tree status",options:{short:S().alias("s").describe("Give the output in the short-format"),porcelain:S().describe("Give the output in a machine-parseable format"),branch:S().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await rt(s),stderr:"",exitCode:0};let i=await Z(s),a=await X(s),c;i&&i.type==="symbolic"?c=be(i.target):c="HEAD detached";let f=await K(s),d=Jo(f),l=await Zo(s,a,f,d),u=await Tt(s,f),m=[],h=[];for(let E of u)E.status==="untracked"?h.push(E.path):m.push({path:E.path,status:E.status});m.sort((E,x)=>xe(E.path,x.path));let p=new Set(f.entries.map(E=>E.path)),g=Qo(h,p);return{stdout:wp(c,l,m,d,g,n.branch),stderr:"",exitCode:0}}})}var hp={"both modified":"UU","both added":"AA","both deleted":"DD","deleted by us":"DU","deleted by them":"UD","added by us":"AU","added by them":"UA",unmerged:"UU"};function pp(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function gp(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function wp(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(u=>[u.path,u])),c=new Map(t.map(u=>[u.path,u])),f=new Map(n.map(u=>[u.path,u])),d=new Set;for(let u of r)d.add(u.path);for(let u of t)d.add(u.path);for(let u of n)d.add(u.path);let l=[...d].sort();for(let u of l){let m=a.get(u);if(m){let E=hp[m.status]??"UU";i.push(`${E} ${rs(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?pp(h.status):" ",w=p?gp(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let E=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,E),b=h.displayPath.slice(E+4);i.push(`${g}${w} ${rs(x)} -> ${rs(b)}`)}else i.push(`${g}${w} ${rs(u)}`)}for(let u of o)i.push(`?? ${rs(u)}`);return i.length===0?"":`${i.join(`
699
+ `,stderr:"",exitCode:0}}async function up(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Li(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
700
+ `,stderr:"",exitCode:0}}async function mp(e,t){let n=mo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Er(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await M(e,r),s=o.parents[0];if(!s)return _("error: invalid stash commit (no parent)");let i=await M(e,s),a=await _e(e,i.tree,o.tree),c="";for(let f of a)c+=await cp(e,f);return{stdout:c,stderr:"",exitCode:0}}async function hp(e){return await Qf(e),{stdout:"",stderr:"",exitCode:0}}re();Re();ue();tt();function nd(e,t){e.command("status",{description:"Show the working tree status",options:{short:S().alias("s").describe("Give the output in the short-format"),porcelain:S().describe("Give the output in a machine-parseable format"),branch:S().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await rt(s),stderr:"",exitCode:0};let i=await Z(s),a=await X(s),c;i&&i.type==="symbolic"?c=be(i.target):c="HEAD detached";let f=await K(s),d=Qo(f),l=await Jo(s,a,f,d),u=await Tt(s,f),m=[],h=[];for(let E of u)E.status==="untracked"?h.push(E.path):m.push({path:E.path,status:E.status});m.sort((E,x)=>xe(E.path,x.path));let p=new Set(f.entries.map(E=>E.path)),g=ei(h,p);return{stdout:bp(c,l,m,d,g,n.branch),stderr:"",exitCode:0}}})}var pp={"both modified":"UU","both added":"AA","both deleted":"DD","deleted by us":"DU","deleted by them":"UD","added by us":"AU","added by them":"UA",unmerged:"UU"};function gp(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function wp(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function bp(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(u=>[u.path,u])),c=new Map(t.map(u=>[u.path,u])),f=new Map(n.map(u=>[u.path,u])),d=new Set;for(let u of r)d.add(u.path);for(let u of t)d.add(u.path);for(let u of n)d.add(u.path);let l=[...d].sort();for(let u of l){let m=a.get(u);if(m){let E=pp[m.status]??"UU";i.push(`${E} ${rs(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?gp(h.status):" ",w=p?wp(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let E=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,E),b=h.displayPath.slice(E+4);i.push(`${g}${w} ${rs(x)} -> ${rs(b)}`)}else i.push(`${g}${w} ${rs(u)}`)}for(let u of o)i.push(`?? ${rs(u)}`);return i.length===0?"":`${i.join(`
701
701
  `)}
702
- `}function rs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}re();Ye();Re();ie();je();ue();Se();Qt();function bp(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??J}function rd(e,t){e.command("switch",{description:"Switch branches",args:[W.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:te.string().alias("c").describe("Create and switch to a new branch"),forceCreate:te.string().alias("C").describe("Create/reset and switch to a branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:te.string().describe("Create a new orphan branch"),guess:S().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?$("--orphan and -c/-C are incompatible"):n.detach?$("--orphan and --detach are incompatible"):Rp(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return $("--detach and -c/-C are incompatible");let d=a??"HEAD",l=await $e(i,d,`invalid reference: ${d}`);return v(l)?l:kp(i,d,l.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,l=a??(o.passthrough.length>0?o.passthrough[0]:void 0);return nd(i,d,!!n.forceCreate,l,r.env,t)}if(!a)return $("missing branch or commit argument");if(a==="-")return yp(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return sd(i,a,c,f,r.env,t);if(n.guess!==!1){let d=await Ep(i,a);if(d)return nd(i,a,!1,d.startPoint,r.env,t,d.trackingRef)}return $(`invalid reference: ${a}`)}})}async function ss(e){return await ke(e,"CHERRY_PICK_HEAD")?$(`cannot switch branch while cherry-picking
702
+ `}function rs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}re();Ye();Re();ie();je();ue();Se();Qt();function yp(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??J}function sd(e,t){e.command("switch",{description:"Switch branches",args:[W.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:te.string().alias("c").describe("Create and switch to a new branch"),forceCreate:te.string().alias("C").describe("Create/reset and switch to a branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:te.string().describe("Create a new orphan branch"),guess:S().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(v(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?$("--orphan and -c/-C are incompatible"):n.detach?$("--orphan and --detach are incompatible"):xp(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return $("--detach and -c/-C are incompatible");let d=a??"HEAD",l=await $e(i,d,`invalid reference: ${d}`);return v(l)?l:Rp(i,d,l.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,l=a??(o.passthrough.length>0?o.passthrough[0]:void 0);return rd(i,d,!!n.forceCreate,l,r.env,t)}if(!a)return $("missing branch or commit argument");if(a==="-")return Ep(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return od(i,a,c,f,r.env,t);if(n.guess!==!1){let d=await kp(i,a);if(d)return rd(i,a,!1,d.startPoint,r.env,t,d.trackingRef)}return $(`invalid reference: ${a}`)}})}async function ss(e){return await ke(e,"CHERRY_PICK_HEAD")?$(`cannot switch branch while cherry-picking
703
703
  Consider "git cherry-pick --quit" or "git worktree add".`):await ke(e,"MERGE_HEAD")?$(`cannot switch branch while merging
704
704
  Consider "git merge --quit" or "git worktree add".`):await ke(e,"REVERT_HEAD")?$(`cannot switch branch while reverting
705
705
  Consider "git revert --quit" or "git worktree add".`):await Mt(e)?$(`cannot switch branch while rebasing
706
- Consider "git rebase --quit" or "git worktree add".`):null}async function yp(e,t,n){let r=await ss(e);if(r)return r;let o=await _s(e);return o?sd(e,o.name,o.refName,o.hash,t,n):$("no previous branch")}async function Ep(e,t){let n=await pe(e,"refs/remotes"),r=[];for(let s of n){let i=s.name.replace(/^refs\/remotes\//,"").split("/"),a=i[0];i.length>=2&&a&&i.slice(1).join("/")===t&&r.push({remote:a,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function nd(e,t,n,r,o,s,i){let a=`refs/heads/${t}`,c=await U(e,a);if(c&&!n)return $(`a branch named '${t}' already exists`);let f;if(r){let y=await $e(e,r,`invalid reference: ${r}`);if(v(y))return y;f=y.hash}else{let y=await X(e);if(!y){let I=await Z(e),O=I?.type==="symbolic"?I.target.replace(/^refs\/heads\//,""):"";n&&c&&await fe(e,a),await Ue(e,"HEAD",a),await mt(e);let j=await ln(e);return await ne(e,o,"HEAD",null,J,`checkout: moving from ${O} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
707
- ${j}`,exitCode:0}}f=y}let d=await ss(e);if(d)return d;let l=await X(e),u=await K(e);if(r){let y=$n(u);if(y)return y}let m=await M(e,f);if(l&&l!==f){let y=await M(e,l);if(y.tree!==m.tree){let I=await Cn(e,y.tree,m.tree,u);if(!I.success)return I.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:I.newEntries},await se(e,u),await He(e,I.worktreeOps)}}let h=await Z(e),p="";h?.type==="direct"&&l&&(p=await Bs(e,l,f));let g=bp(h,l);await Y(e,a,f),await Ue(e,"HEAD",a),await mt(e);let w=await ln(e),E=r??"HEAD";n&&c?c!==f&&await ne(e,o,a,c,f,`branch: Reset to ${E}`):await ne(e,o,a,null,f,`branch: Created from ${E}`),await ne(e,o,"HEAD",l,f,`checkout: moving from ${g} to ${t}`);let x=i?.replace(/^refs\/remotes\//,"").split("/");if(x){let y=x[0]??"",I=`refs/heads/${x.slice(1).join("/")}`,O=await le(e);O[`branch "${t}"`]={...O[`branch "${t}"`],remote:y,merge:I},await Qe(e,O)}await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:f,isBranchCheckout:!0});let b=n&&c?`Switched to and reset branch '${t}'
706
+ Consider "git rebase --quit" or "git worktree add".`):null}async function Ep(e,t,n){let r=await ss(e);if(r)return r;let o=await _s(e);return o?od(e,o.name,o.refName,o.hash,t,n):$("no previous branch")}async function kp(e,t){let n=await pe(e,"refs/remotes"),r=[];for(let s of n){let i=s.name.replace(/^refs\/remotes\//,"").split("/"),a=i[0];i.length>=2&&a&&i.slice(1).join("/")===t&&r.push({remote:a,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function rd(e,t,n,r,o,s,i){let a=`refs/heads/${t}`,c=await U(e,a);if(c&&!n)return $(`a branch named '${t}' already exists`);let f;if(r){let y=await $e(e,r,`invalid reference: ${r}`);if(v(y))return y;f=y.hash}else{let y=await X(e);if(!y){let I=await Z(e),O=I?.type==="symbolic"?I.target.replace(/^refs\/heads\//,""):"";n&&c&&await fe(e,a),await Ue(e,"HEAD",a),await mt(e);let j=await ln(e);return await ne(e,o,"HEAD",null,J,`checkout: moving from ${O} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
707
+ ${j}`,exitCode:0}}f=y}let d=await ss(e);if(d)return d;let l=await X(e),u=await K(e);if(r){let y=$n(u);if(y)return y}let m=await M(e,f);if(l&&l!==f){let y=await M(e,l);if(y.tree!==m.tree){let I=await Cn(e,y.tree,m.tree,u);if(!I.success)return I.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:I.newEntries},await se(e,u),await He(e,I.worktreeOps)}}let h=await Z(e),p="";h?.type==="direct"&&l&&(p=await Bs(e,l,f));let g=yp(h,l);await Y(e,a,f),await Ue(e,"HEAD",a),await mt(e);let w=await ln(e),E=r??"HEAD";n&&c?c!==f&&await ne(e,o,a,c,f,`branch: Reset to ${E}`):await ne(e,o,a,null,f,`branch: Created from ${E}`),await ne(e,o,"HEAD",l,f,`checkout: moving from ${g} to ${t}`);let x=i?.replace(/^refs\/remotes\//,"").split("/");if(x){let y=x[0]??"",I=`refs/heads/${x.slice(1).join("/")}`,O=await le(e);O[`branch "${t}"`]={...O[`branch "${t}"`],remote:y,merge:I},await Qe(e,O)}await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:f,isBranchCheckout:!0});let b=n&&c?`Switched to and reset branch '${t}'
708
708
  `:`Switched to a new branch '${t}'
709
709
  `,k=p+b+w;if(x){let y=x.slice(1).join("/");k+=`branch '${t}' set up to track '${x[0]}/${y}'.
710
- `}let R="";r&&(R=await Yn(e,m.tree,u));let C=await le(e),P=await dn(e,C,t);return P&&(R+=Vn(P)),{stdout:R,stderr:k,exitCode:0}}async function sd(e,t,n,r,o,s){let i=await ss(e);return i||lr(e,t,n,r,o,s)}async function kp(e,t,n,r,o){let s=await ss(e);return s||Tn(e,n,r,o)}async function Rp(e,t,n,r){let o=await ss(e);if(o)return o;let s=`refs/heads/${t}`;if(await U(e,s))return $(`a branch named '${t}' already exists`);let a=await K(e),c=$n(a);if(c)return c;let f=await X(e),d=await Z(e),l="";if(d?.type==="direct"&&f&&(l=await ei(e,f)),e.workTree){let m=f?(await M(e,f)).tree:null,h=await De(e,[]),p=await Cn(e,m,h,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await He(e,p.worktreeOps),await se(e,{version:2,entries:p.newEntries})}else await se(e,ea());await Ue(e,"HEAD",s),await mt(e);let u=await ln(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:J,isBranchCheckout:!0}),{stdout:"",stderr:`${l}Switched to a new branch '${t}'
711
- ${u}`,exitCode:0}}re();ie();Ar();ue();xs();function id(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[W.string().name("name").describe("Tag name to create or delete").optional(),W.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:S().alias("a").describe("Make an annotated tag object"),message:te.string().alias("m").describe("Tag message"),delete:S().alias("d").describe("Delete a tag"),force:S().alias("f").describe("Replace an existing tag"),list:te.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.delete){if(!n.name)return $("tag name required");let i=`refs/tags/${n.name}`,a=await U(s,i);return a?(await fe(s,i),{stdout:`Deleted tag '${n.name}' (was ${z(a)})
710
+ `}let R="";r&&(R=await Yn(e,m.tree,u));let C=await le(e),P=await dn(e,C,t);return P&&(R+=Vn(P)),{stdout:R,stderr:k,exitCode:0}}async function od(e,t,n,r,o,s){let i=await ss(e);return i||lr(e,t,n,r,o,s)}async function Rp(e,t,n,r,o){let s=await ss(e);return s||Tn(e,n,r,o)}async function xp(e,t,n,r){let o=await ss(e);if(o)return o;let s=`refs/heads/${t}`;if(await U(e,s))return $(`a branch named '${t}' already exists`);let a=await K(e),c=$n(a);if(c)return c;let f=await X(e),d=await Z(e),l="";if(d?.type==="direct"&&f&&(l=await ti(e,f)),e.workTree){let m=f?(await M(e,f)).tree:null,h=await De(e,[]),p=await Cn(e,m,h,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await He(e,p.worktreeOps),await se(e,{version:2,entries:p.newEntries})}else await se(e,ta());await Ue(e,"HEAD",s),await mt(e);let u=await ln(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:J,isBranchCheckout:!0}),{stdout:"",stderr:`${l}Switched to a new branch '${t}'
711
+ ${u}`,exitCode:0}}re();ie();Ar();ue();xs();function ad(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[W.string().name("name").describe("Tag name to create or delete").optional(),W.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:S().alias("a").describe("Make an annotated tag object"),message:te.string().alias("m").describe("Tag message"),delete:S().alias("d").describe("Delete a tag"),force:S().alias("f").describe("Replace an existing tag"),list:te.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(v(o))return o;let s=o;if(n.delete){if(!n.name)return $("tag name required");let i=`refs/tags/${n.name}`,a=await U(s,i);return a?(await fe(s,i),{stdout:`Deleted tag '${n.name}' (was ${z(a)})
712
712
  `,stderr:"",exitCode:0}):_(`error: tag '${n.name}' not found.
713
- `)}if(n.list!==void 0)return od(s,n.list||void 0);if(n.name){let i=n.commit,a;if(i){let l=await St(s,i,`Failed to resolve '${i}' as a valid ref.`);if(v(l))return l;a=l}else if(a=await X(s),!a)return $("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await U(s,c)&&!n.force)return $(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return $("no tag message specified (use -m)");let l=await Ze(s,r.env);if(v(l))return l;let u=vt(n.message),m=ya({type:"tag",object:a,objectType:"commit",name:n.name,tagger:l,message:u}),h=await Ie(s,"tag",m);await Y(s,c,h)}else await Y(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return od(s)}})}async function od(e,t){let n=await pe(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>Fn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
713
+ `)}if(n.list!==void 0)return id(s,n.list||void 0);if(n.name){let i=n.commit,a;if(i){let l=await St(s,i,`Failed to resolve '${i}' as a valid ref.`);if(v(l))return l;a=l}else if(a=await X(s),!a)return $("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await U(s,c)&&!n.force)return $(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return $("no tag message specified (use -m)");let l=await Ze(s,r.env);if(v(l))return l;let u=vt(n.message),m=Ea({type:"tag",object:a,objectType:"commit",name:n.name,tagger:l,message:u}),h=await Ie(s,"tag",m);await Y(s,c,h)}else await Y(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return id(s)}})}async function id(e,t){let n=await pe(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>Fn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
714
714
  `)}
715
- `,stderr:"",exitCode:0}}var xp={init:e=>Rf(e),clone:(e,t)=>Qc(e,t),fetch:(e,t)=>gf(e,t),pull:(e,t)=>vf(e,t),push:(e,t)=>Af(e,t),add:(e,t)=>Ba(e,t),blame:(e,t)=>xc(e,t),commit:(e,t)=>ef(e,t),status:(e,t)=>td(e,t),log:(e,t)=>Of(e,t),branch:(e,t)=>Pc(e,t),tag:(e,t)=>id(e,t),checkout:(e,t)=>Oc(e,t),diff:(e,t)=>lf(e,t),reset:(e,t)=>Ff(e,t),merge:(e,t)=>Sf(e,t),"cherry-pick":(e,t)=>_c(e,t),revert:(e,t)=>qf(e,t),rebase:(e,t)=>Gf(e,t),mv:(e,t)=>Hf(e,t),rm:(e,t)=>Kf(e,t),remote:(e,t)=>Nf(e,t),config:(e,t)=>sf(e,t),show:(e,t)=>zf(e,t),stash:(e,t)=>ed(e,t),"rev-parse":(e,t)=>Wf(e,t),"ls-files":(e,t)=>Tf(e,t),clean:(e,t)=>Fc(e,t),switch:(e,t)=>rd(e,t),restore:(e,t)=>Bf(e,t),reflog:(e,t)=>Lf(e,t),repack:(e,t)=>yf(e,t),gc:(e,t)=>Ef(e,t),bisect:(e,t)=>fc(e,t)};function ad(e){let t=yo("git",{description:"Git command"});for(let n of Object.values(xp))n(t,e);return t}var ho=class{name="git";blocked;hooks;inner;constructor(t){this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{}};this.inner=ad(r).toCommand()}exec=async(t,n)=>{let r=cd(t),o=new Map;if(n.env)for(let[s,i]of Object.entries(n.env))o.set(s,i);return this.execute(r,{fs:n.fs,cwd:n.cwd,env:o,stdin:n.stdin??""})};execute=async(t,n)=>{let r=t[0]??"";if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
716
- `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o}};function cd(e){let t=[],n="",r=0;for(;r<e.length;){let o=e[r];if(o==='"'){for(r++;r<e.length&&e[r]!=='"';){if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];if(s==='"'||s==="\\"){n+=s,r+=2;continue}}n+=e[r],r++}r++}else if(o==="'"){for(r++;r<e.length&&e[r]!=="'";)n+=e[r],r++;r++}else o===" "||o===" "?(n.length>0&&(t.push(n),n=""),r++):(n+=o,r++)}return n.length>0&&t.push(n),t.length>0&&t[0]==="git"&&t.shift(),t}function Cp(e){return new ho(e)}En();export{ho as Git,qu as composeGitHooks,Cp as createGit,Nn as findRepo,Q as isRejection,cd as tokenizeCommand};
715
+ `,stderr:"",exitCode:0}}var Cp={init:e=>xf(e),clone:(e,t)=>ef(e,t),fetch:(e,t)=>wf(e,t),pull:(e,t)=>Af(e,t),push:(e,t)=>Df(e,t),add:(e,t)=>Wa(e,t),blame:(e,t)=>Cc(e,t),commit:(e,t)=>tf(e,t),status:(e,t)=>nd(e,t),log:(e,t)=>$f(e,t),branch:(e,t)=>Ic(e,t),tag:(e,t)=>ad(e,t),checkout:(e,t)=>$c(e,t),diff:(e,t)=>uf(e,t),reset:(e,t)=>Uf(e,t),merge:(e,t)=>Hf(e,t),"cherry-pick":(e,t)=>Fc(e,t),revert:(e,t)=>Kf(e,t),rebase:(e,t)=>Lf(e,t),mv:(e,t)=>vf(e,t),rm:(e,t)=>zf(e,t),remote:(e,t)=>_f(e,t),config:(e,t)=>of(e,t),show:(e,t)=>Vf(e,t),stash:(e,t)=>td(e,t),"rev-parse":(e,t)=>qf(e,t),"ls-files":(e,t)=>Sf(e,t),clean:(e,t)=>Uc(e,t),switch:(e,t)=>sd(e,t),restore:(e,t)=>Wf(e,t),reflog:(e,t)=>Nf(e,t),repack:(e,t)=>Ef(e,t),gc:(e,t)=>kf(e,t),bisect:(e,t)=>dc(e,t)};function cd(e){let t=yo("git",{description:"Git command"});for(let n of Object.values(Cp))n(t,e);return t}var ho=class{name="git";blocked;hooks;inner;constructor(t){this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{}};this.inner=cd(r).toCommand()}exec=async(t,n)=>{let r=fd(t),o=new Map;if(n.env)for(let[s,i]of Object.entries(n.env))o.set(s,i);return this.execute(r,{fs:n.fs,cwd:n.cwd,env:o,stdin:n.stdin??""})};execute=async(t,n)=>{let r=t[0]??"";if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
716
+ `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(Q(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o}};function fd(e){let t=[],n="",r=0;for(;r<e.length;){let o=e[r];if(o==='"'){for(r++;r<e.length&&e[r]!=='"';){if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];if(s==='"'||s==="\\"){n+=s,r+=2;continue}}n+=e[r],r++}r++}else if(o==="'"){for(r++;r<e.length&&e[r]!=="'";)n+=e[r],r++;r++}else o===" "||o===" "?(n.length>0&&(t.push(n),n=""),r++):(n+=o,r++)}return n.length>0&&t.push(n),t.length>0&&t[0]==="git"&&t.shift(),t}function Pp(e){return new ho(e)}En();export{ho as Git,Ku as composeGitHooks,Pp as createGit,Nn as findRepo,Q as isRejection,fd as tokenizeCommand};