just-git 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/dist/{hooks-jTfqkfs1.d.ts → hooks-1dcjVqc3.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +259 -259
- package/dist/repo/index.d.ts +11 -8
- package/dist/repo/index.js +7 -7
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.js +13 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var id=Object.defineProperty;var os=(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 ye=(e,t)=>()=>(e&&(t=e(e=0)),t);var ad=(e,t)=>{for(var n in t)id(e,n,{get:t[n],enumerable:!0})};function fs(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 a of r)a===""||a==="."||(a===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(a));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===""?".":fs(t)}function Pt(...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 fs(t||".")}function Kt(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 xr(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=fs(e),r=fs(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),a=n.charCodeAt(0)===47,i=r.charCodeAt(0)===47,f=a&&i?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=ye(()=>{"use strict"});function ud(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 a=o.indexOf("=");if(a===-1){let i=o.trim().toLowerCase();s[i]="true"}else{let i=o.slice(0,a).trim().toLowerCase(),c=o.slice(a+1).trim();s[i]=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
|
|
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 ud(n)}async function Je(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 Je(e,r)}async function qi(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 Je(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 Ve=ye(()=>{"use strict";de()});function ds(e,t){return zi(e,t,"author")}function Cr(e,t){return zi(e,t,"committer")}async function zi(e,t,n){let r=md[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Ki(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await _t(e,"user.name")??o?.name,a=t.get(r.email)??await _t(e,"user.email")??o?.email;if(!s||!a)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,66 +9,66 @@ 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:a,timestamp:zi(t.get(r.date)),timezone:"+0000"}}async function zt(e,t){try{let n=await Cr(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 zi(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 ud,pn=ye(()=>{"use strict";Je();ud={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 gn(e){let t="";for(let n=0;n<20;n++)t+=Yi[e[n]];return t}function ls(e,t){let n="";for(let r=0;r<20;r++)n+=Yi[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,Yi,dt=ye(()=>{"use strict";J="0000000000000000000000000000000000000000",Yi=(()=>{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"?md.encode(e):e}function hd(){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=os(["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 a of e)n+=a.byteLength;let r=new Uint8Array(n),o=0;for(let a of e)r.set(a,o),o+=a.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return gn(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 rr(e){return Xi().update(e).hex()}var md,Xi,Gn,Ln=ye(()=>{"use strict";dt();md=new TextEncoder;Xi=hd(),Gn=Xi});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 pd(n)}async function se(e,t){let n=T(e.gitDir,"index"),r=await gd(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 us(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function It(e){return e.entries.some(t=>t.stage>0)}function Nt(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 Ji(){return{version:Co,entries:[]}}function ms(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 pd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Zi)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 a=[];for(let i=0;i<s;i++){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=gn(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 R=n;for(;R<e.byteLength&&e[R]!==0;)R++;g=new TextDecoder().decode(e.subarray(n,R))}let w=62+g.length+1,y=Math.ceil(w/8)*8;n=c+y,a.push({path:g,mode:d,hash:u,stage:h,stat:f})}return{version:o,entries:a}}async function gd(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),a=0;s.setUint32(a,Zi),a+=4,s.setUint32(a,e.version),a+=4,s.setUint32(a,t.length),a+=4;for(let d of t){let l=a;s.setUint32(a,d.stat.ctimeSeconds),s.setUint32(a+4,d.stat.ctimeNanoseconds),s.setUint32(a+8,d.stat.mtimeSeconds),s.setUint32(a+12,d.stat.mtimeNanoseconds),s.setUint32(a+16,d.stat.dev),s.setUint32(a+20,d.stat.ino),s.setUint32(a+24,d.mode),s.setUint32(a+28,d.stat.uid),s.setUint32(a+32,d.stat.gid),s.setUint32(a+36,d.stat.size),a+=40;let u=Ot(d.hash);o.set(u,a),a+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(a,h),a+=2;let p=new TextEncoder().encode(d.path);o.set(p,a),a+=p.byteLength,o[a]=0,a+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;a=l+w}let i=o.subarray(0,a),c=await rr(i),f=Ot(c);return o.set(f,a),o}function Po(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Zi,Co,ke=ye(()=>{"use strict";dt();de();Ln();Zi=1145655875,Co=2});var wd,hs,Qi=ye(()=>{"use strict";wd=new Set(["tree","commit","tag"]),hs=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(!wd.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 Oo(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=ea[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var ea,ta=ye(()=>{"use strict";ea=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;ea[e]=t}});function bd(){try{let e=os(["node","zlib"].join(":"));if(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 Promise.resolve({result:new Uint8Array(o.buffer),bytesConsumed:o.engine.bytesWritten})})}catch{}return{deflate:n=>Promise.resolve(new Uint8Array(e.deflateSync(n))),inflate:n=>Promise.resolve(new Uint8Array(e.inflateSync(n))),inflateWithConsumed:t}}}catch{}if(typeof globalThis.CompressionStream=="function"&&typeof globalThis.DecompressionStream=="function")return{async deflate(e){let t=new CompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())},async inflate(e){let t=new DecompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())}};throw new Error("No zlib implementation available. Requires Bun, Node.js, Deno, or a browser with CompressionStream.")}var Io,Pr,rn,$o,ps=ye(()=>{"use strict";Io=bd(),Pr=Io.deflate,rn=Io.inflate,$o=Io.inflateWithConsumed});async function fa(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Ho)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Ho.toString(16)})`);let o=n.getUint32(4);if(o!==sa)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),a=[],i=12;for(let f=0;f<s;f++){let d=await kd(e,i);a.push(d),i=d.nextOffset}return(await Rd(a,t)).map((f,d)=>({...f,offset:a[d].headerOffset,nextOffset:a[d].nextOffset}))}async function kd(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,a=4;for(;r&128;)r=e[t++],s|=(r&127)<<a,a+=7;let i,c;if(o===Or){let l=e[t++];for(i=l&127;l&128;)i+=1,l=e[t++],i=(i<<7)+(l&127);i=n-i}else o===So&&(c=ls(e,t),t+=20);let{result:f,bytesConsumed:d}=await Od(e,t,s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:i,baseHash:c,nextOffset:t+d}}async function Rd(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 a=r[s];if(a)return a;let i=e[s];if(i.typeNum!==Or&&i.typeNum!==So){let u=yd[i.typeNum];if(!u)throw new Error(`Unknown object type: ${i.typeNum}`);let m={type:u,content:i.inflated,hash:await To(u,i.inflated)};return r[s]=m,m}if(i.typeNum===Or){let u=n.get(i.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${i.baseOffset}`);let m=await o(u),h=Ir(m.content,i.inflated),p={type:m.type,content:h,hash:await To(m.type,h)};return r[s]=p,p}let c=await xd(e,r,i.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(i.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${i.baseHash}`);let d=Ir(f.content,i.inflated),l={type:f.type,content:d,hash:await To(f.type,d)};return r[s]=l,l}for(let s=0;s<e.length;s++)await o(s);return r}async function xd(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 Ir(e,t){let n=0,{value:r,newPos:o}=ra(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:a}=ra(t,n);n=a;let i=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),i.set(e.subarray(d,d+l),c),c+=l}else if(f>0)i.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 i}async function gs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Ho),o.setUint32(4,sa),o.setUint32(8,e.length),t.push(r);let s=12,a=[];for(let i of e){let c=s;n.set(i.hash,s);let f=i.delta&&i.deltaBaseHash?n.get(i.deltaBaseHash):void 0;if(i.delta&&f!==void 0){let d=na(Or,i.delta.byteLength),l=Pd(s-f),u=await Pr(i.delta);t.push(d,l,u),s+=d.byteLength+l.byteLength+u.byteLength}else{let d=Ed[i.type],l=na(d,i.content.byteLength),u=await Pr(i.content);t.push(l,u),s+=l.byteLength+u.byteLength}a.push({hash:i.hash,offset:c,nextOffset:s})}return{data:await Cd(t),entries:a}}async function Cd(e){let t=0;for(let a of e)t+=a.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let a of e)n.set(a,r),r+=a.byteLength;let o=Gn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Ot(s),r),n}function Pd(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 na(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 ra(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 Od(e,t,n){let r=e.subarray(t);if($o){let{result:i,bytesConsumed:c}=await $o(r);if(i.byteLength!==n)throw new Error(`Inflate size mismatch: got ${i.byteLength}, expected ${n}`);return{result:i,bytesConsumed:c}}let o=await rn(r);if(o.byteLength!==n)throw new Error(`Inflate size mismatch: got ${o.byteLength}, expected ${n}`);let s=2,a=r.byteLength;for(;s<a;){let i=s+a>>>1;try{(await rn(r.subarray(0,i))).byteLength===n?a=i:s=i+1}catch{s=i+1}}return{result:o,bytesConsumed:s}}async function To(e,t){let n=Id.encode(`${e} ${t.byteLength}\0`),r=Gn();return r.update(n),r.update(t),r.hex()}var Ho,sa,oa,ia,aa,ca,Or,So,yd,Ed,Id,$r=ye(()=>{"use strict";dt();Ln();ps();Ho=1346454347,sa=2,oa=1,ia=2,aa=3,ca=4,Or=6,So=7,yd={[oa]:"commit",[ia]:"tree",[aa]:"blob",[ca]:"tag"},Ed={commit:oa,tree:ia,blob:aa,tag:ca};Id=new TextEncoder});async function ua(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,a=new Uint8Array(s),i=new DataView(a.buffer),c=0;i.setUint32(c,da),c+=4,i.setUint32(c,la),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++)i.setUint32(c,f[m]),c+=4;for(let m of n)a.set(Ot(m.hash),c),c+=20;for(let m of n)i.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?i.setUint32(c,2147483648|d++):i.setUint32(c,m.offset),c+=4;for(let m of o)i.setBigUint64(c,m),c+=8;a.set(t,c),c+=20;let l=Gn();l.update(a.subarray(0,c));let u=await l.hex();return a.set(Ot(u),c),a}async function ma(e){let n=(await fa(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Oo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ua(n,r)}async function ha(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Oo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ua(n,r)}var da,la,Ft,ws=ye(()=>{"use strict";dt();Ln();ta();$r();da=4285812579,la=2,Ft=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==da)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==la)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],a=o,i=s;for(;a<i;){let c=a+i>>>1,f=this.compareAt(c,n);if(f<0)a=c+1;else if(f>0)i=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")),a=t.length,i=[];for(let c=r;c<o;c++){let f=c*20,d=!0;for(let l=0;l<a;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&&i.push(this.hashAtSlot(c))}return i}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],a=n[o];if(s<a)return-1;if(s>a)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 $d,Td,Hd,Tr,pa=ye(()=>{"use strict";dt();ws();$r();ps();$d=6,Td=7,Hd={1:"commit",2:"tree",3:"blob",4:"tag"},Tr=class{constructor(t,n){this.data=t;this.index=n instanceof Ft?n:new Ft(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,a=o&15,i=4;for(;o&128;)o=n[r++],a|=(o&127)<<i,i+=7;if(s===$d){let d=n[r++],l=d&127;for(;d&128;)l+=1,d=n[r++],l=(l<<7)+(d&127);let u=await rn(n.subarray(r)),m=await this.readAt(t-l);return{type:m.type,content:Ir(m.content,u)}}if(s===Td){let d=ls(n,r);r+=20;let l=await rn(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:Ir(m.content,l)}}let c=Hd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await rn(n.subarray(r));if(f.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${a}`);return{type:c,content:f}}}});function Ao(e,t){let n=Sd.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Ad(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=vd.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),a=parseInt(r.slice(o+1),10),i=t.subarray(n+1);if(i.byteLength!==a)throw new Error(`Corrupt object ${e}: expected ${a} bytes, got ${i.byteLength}`);return{type:s,content:i}}function vo(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var Sd,vd,sr,Do=ye(()=>{"use strict";dt();Qi();ws();pa();ps();de();Ln();Sd=new TextEncoder,vd=new TextDecoder;sr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new hs(r),this.packDir=T(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=Ao(t,n),o=await rr(r),s=vo(this.gitDir,o);if(await this.fs.exists(s))return o;let a=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(a,{recursive:!0}),await this.fs.writeFile(s,await Pr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=vo(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await rn(o),a=Ad(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let a=await(await this.ensureReader(o)).readObject(t);if(a)return this.cache.set(t,a),a}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(vo(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=gn(o);await this.fs.mkdir(this.packDir,{recursive:!0});let a=`pack-${s}`,i=T(this.packDir,`${a}.pack`);await this.fs.writeFile(i,t);let c=await ma(t),f=T(this.packDir,`${a}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(a);let d=new Ft(c);return this.packs.push({name:a,index:d,reader:new Tr(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 a=await this.fs.readdir(o);for(let i of a)i.startsWith(r)&&s.push(`${n}${i}`)}await this.discover();for(let a of this.packs)for(let i of a.index.findByPrefix(t))s.includes(i)||s.push(i);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 Tr(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 Ft(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),[a="0",i="+0000"]=s.split(" "),c=parseInt(a,10);return{name:r,email:o,timestamp:c,timezone:i}}function Sr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Mo=ye(()=>{"use strict"});function Vt(e){let t=Md.decode(e),n=t.indexOf(`
|
|
12
|
+
`);return{name:s,email:a,timestamp:Ki(t.get(r.date)),timezone:"+0000"}}async function zt(e,t){try{let n=await Cr(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 Ki(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 md,hn=ye(()=>{"use strict";Ve();md={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+=Vi[e[n]];return t}function ls(e,t){let n="";for(let r=0;r<20;r++)n+=Vi[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,Vi,dt=ye(()=>{"use strict";J="0000000000000000000000000000000000000000",Vi=(()=>{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"?hd.encode(e):e}function pd(){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=os(["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 a of e)n+=a.byteLength;let r=new Uint8Array(n),o=0;for(let a of e)r.set(a,o),o+=a.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 Yi().update(e).hex()}var hd,Yi,jn,Gn=ye(()=>{"use strict";dt();hd=new TextEncoder;Yi=pd(),jn=Yi});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 gd(n)}async function se(e,t){let n=T(e.gitDir,"index"),r=await wd(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 us(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function It(e){return e.entries.some(t=>t.stage>0)}function Nt(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 Zi(){return{version:Co,entries:[]}}function ms(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 gd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Xi)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 a=[];for(let i=0;i<s;i++){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,y=Math.ceil(w/8)*8;n=c+y,a.push({path:g,mode:d,hash:u,stage:h,stat:f})}return{version:o,entries:a}}async function wd(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),a=0;s.setUint32(a,Xi),a+=4,s.setUint32(a,e.version),a+=4,s.setUint32(a,t.length),a+=4;for(let d of t){let l=a;s.setUint32(a,d.stat.ctimeSeconds),s.setUint32(a+4,d.stat.ctimeNanoseconds),s.setUint32(a+8,d.stat.mtimeSeconds),s.setUint32(a+12,d.stat.mtimeNanoseconds),s.setUint32(a+16,d.stat.dev),s.setUint32(a+20,d.stat.ino),s.setUint32(a+24,d.mode),s.setUint32(a+28,d.stat.uid),s.setUint32(a+32,d.stat.gid),s.setUint32(a+36,d.stat.size),a+=40;let u=Ot(d.hash);o.set(u,a),a+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(a,h),a+=2;let p=new TextEncoder().encode(d.path);o.set(p,a),a+=p.byteLength,o[a]=0,a+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;a=l+w}let i=o.subarray(0,a),c=await nr(i),f=Ot(c);return o.set(f,a),o}function Po(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Xi,Co,ke=ye(()=>{"use strict";dt();de();Gn();Xi=1145655875,Co=2});var bd,hs,Ji=ye(()=>{"use strict";bd=new Set(["tree","commit","tag"]),hs=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(!bd.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 Oo(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Qi[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Qi,ea=ye(()=>{"use strict";Qi=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;Qi[e]=t}});async function yd(){let e;try{e=os(["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 Io(){return Ed??=yd()}async function Pr(e){return await(await Io()).deflateSync(e)}async function rr(e){return await(await Io()).inflateSync(e)}async function ta(e,t){let n=await Io();if(n.inflateWithConsumed){let{result:a,bytesConsumed:i}=n.inflateWithConsumed(e);if(a.byteLength!==t)throw new Error(`Inflate size mismatch: got ${a.byteLength}, expected ${t}`);return{result:a,bytesConsumed:i}}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 a=o+s>>>1;try{(await n.inflateSync(e.subarray(0,a))).byteLength===t?s=a:o=a+1}catch{o=a+1}}return{result:r,bytesConsumed:o}}var Ed,ps=ye(()=>{"use strict";Ed=null});async function fa(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!==sa)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),a=[],i=12;for(let f=0;f<s;f++){let d=await xd(e,i);a.push(d),i=d.nextOffset}return(await Cd(a,t)).map((f,d)=>({...f,offset:a[d].headerOffset,nextOffset:a[d].nextOffset}))}async function xd(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,a=4;for(;r&128;)r=e[t++],s|=(r&127)<<a,a+=7;let i,c;if(o===Or){let l=e[t++];for(i=l&127;l&128;)i+=1,l=e[t++],i=(i<<7)+(l&127);i=n-i}else o===Ho&&(c=ls(e,t),t+=20);let{result:f,bytesConsumed:d}=await ta(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:i,baseHash:c,nextOffset:t+d}}async function Cd(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 a=r[s];if(a)return a;let i=e[s];if(i.typeNum!==Or&&i.typeNum!==Ho){let u=kd[i.typeNum];if(!u)throw new Error(`Unknown object type: ${i.typeNum}`);let m={type:u,content:i.inflated,hash:await $o(u,i.inflated)};return r[s]=m,m}if(i.typeNum===Or){let u=n.get(i.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${i.baseOffset}`);let m=await o(u),h=Ir(m.content,i.inflated),p={type:m.type,content:h,hash:await $o(m.type,h)};return r[s]=p,p}let c=await Pd(e,r,i.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(i.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${i.baseHash}`);let d=Ir(f.content,i.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 Pd(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!==Ho&&(await r(o)).hash===n)return o}}function Ir(e,t){let n=0,{value:r,newPos:o}=ra(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:a}=ra(t,n);n=a;let i=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),i.set(e.subarray(d,d+l),c),c+=l}else if(f>0)i.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 i}async function gs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,To),o.setUint32(4,sa),o.setUint32(8,e.length),t.push(r);let s=12,a=[];for(let i of e){let c=s;n.set(i.hash,s);let f=i.delta&&i.deltaBaseHash?n.get(i.deltaBaseHash):void 0;if(i.delta&&f!==void 0){let d=na(Or,i.delta.byteLength),l=Id(s-f),u=await Pr(i.delta);t.push(d,l,u),s+=d.byteLength+l.byteLength+u.byteLength}else{let d=Rd[i.type],l=na(d,i.content.byteLength),u=await Pr(i.content);t.push(l,u),s+=l.byteLength+u.byteLength}a.push({hash:i.hash,offset:c,nextOffset:s})}return{data:await Od(t),entries:a}}async function Od(e){let t=0;for(let a of e)t+=a.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let a of e)n.set(a,r),r+=a.byteLength;let o=jn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Ot(s),r),n}function Id(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 na(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 ra(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=$d.encode(`${e} ${t.byteLength}\0`),r=jn();return r.update(n),r.update(t),r.hex()}var To,sa,oa,ia,aa,ca,Or,Ho,kd,Rd,$d,$r=ye(()=>{"use strict";dt();Gn();ps();To=1346454347,sa=2,oa=1,ia=2,aa=3,ca=4,Or=6,Ho=7,kd={[oa]:"commit",[ia]:"tree",[aa]:"blob",[ca]:"tag"},Rd={commit:oa,tree:ia,blob:aa,tag:ca};$d=new TextEncoder});async function ua(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,a=new Uint8Array(s),i=new DataView(a.buffer),c=0;i.setUint32(c,da),c+=4,i.setUint32(c,la),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++)i.setUint32(c,f[m]),c+=4;for(let m of n)a.set(Ot(m.hash),c),c+=20;for(let m of n)i.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?i.setUint32(c,2147483648|d++):i.setUint32(c,m.offset),c+=4;for(let m of o)i.setBigUint64(c,m),c+=8;a.set(t,c),c+=20;let l=jn();l.update(a.subarray(0,c));let u=await l.hex();return a.set(Ot(u),c),a}async function ma(e){let n=(await fa(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Oo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ua(n,r)}async function ha(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Oo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ua(n,r)}var da,la,Ft,ws=ye(()=>{"use strict";dt();Gn();ea();$r();da=4285812579,la=2,Ft=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==da)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==la)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],a=o,i=s;for(;a<i;){let c=a+i>>>1,f=this.compareAt(c,n);if(f<0)a=c+1;else if(f>0)i=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")),a=t.length,i=[];for(let c=r;c<o;c++){let f=c*20,d=!0;for(let l=0;l<a;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&&i.push(this.hashAtSlot(c))}return i}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],a=n[o];if(s<a)return-1;if(s>a)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 Td,Hd,Sd,Tr,pa=ye(()=>{"use strict";dt();ws();$r();ps();Td=6,Hd=7,Sd={1:"commit",2:"tree",3:"blob",4:"tag"},Tr=class{constructor(t,n){this.data=t;this.index=n instanceof Ft?n:new Ft(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,a=o&15,i=4;for(;o&128;)o=n[r++],a|=(o&127)<<i,i+=7;if(s===Td){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:Ir(m.content,u)}}if(s===Hd){let d=ls(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:Ir(m.content,l)}}let c=Sd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await rr(n.subarray(r));if(f.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${a}`);return{type:c,content:f}}}});function vo(e,t){let n=vd.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Dd(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Ad.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),a=parseInt(r.slice(o+1),10),i=t.subarray(n+1);if(i.byteLength!==a)throw new Error(`Corrupt object ${e}: expected ${a} bytes, got ${i.byteLength}`);return{type:s,content:i}}function So(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var vd,Ad,sr,Ao=ye(()=>{"use strict";dt();Ji();ws();pa();ps();de();Gn();vd=new TextEncoder,Ad=new TextDecoder;sr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new hs(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=So(this.gitDir,o);if(await this.fs.exists(s))return o;let a=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(a,{recursive:!0}),await this.fs.writeFile(s,await Pr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=So(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await rr(o),a=Dd(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let a=await(await this.ensureReader(o)).readObject(t);if(a)return this.cache.set(t,a),a}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(So(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 a=`pack-${s}`,i=T(this.packDir,`${a}.pack`);await this.fs.writeFile(i,t);let c=await ma(t),f=T(this.packDir,`${a}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(a);let d=new Ft(c);return this.packs.push({name:a,index:d,reader:new Tr(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 a=await this.fs.readdir(o);for(let i of a)i.startsWith(r)&&s.push(`${n}${i}`)}await this.discover();for(let a of this.packs)for(let i of a.index.findByPrefix(t))s.includes(i)||s.push(i);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 Tr(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 Ft(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),[a="0",i="+0000"]=s.split(" "),c=parseInt(a,10);return{name:r,email:o,timestamp:c,timezone:i}}function Sr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Do=ye(()=>{"use strict"});function Vt(e){let t=jd.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="",a=[],i,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":a.push(u);break;case"author":i=Hr(u);break;case"committer":c=Hr(u);break}}if(!s)throw new Error("Commit missing tree field");if(!i)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:a,author:i,committer:c,message:o}}function Yt(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Sr(e.author)}`),t.push(`committer ${Sr(e.committer)}`),t.push(""),t.push(e.message),
|
|
16
|
-
`))}var
|
|
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":a.push(u);break;case"author":i=Hr(u);break;case"committer":c=Hr(u);break}}if(!s)throw new Error("Commit missing tree field");if(!i)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:a,author:i,committer:c,message:o}}function Yt(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Sr(e.author)}`),t.push(`committer ${Sr(e.committer)}`),t.push(""),t.push(e.message),Md.encode(t.join(`
|
|
16
|
+
`))}var Md,jd,rn=ye(()=>{"use strict";Do();Md=new TextEncoder,jd=new TextDecoder});function sn(e){let t=Ld.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="",a="commit",i="",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":a=u;break;case"tag":i=u;break;case"tagger":c=Hr(u);break}}if(!s)throw new Error("Tag missing object field");if(!i)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:a,name:i,tagger:c,message:o}}function ga(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Sr(e.tagger)}`),t.push(""),t.push(e.message),
|
|
20
|
-
`))}var
|
|
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":a=u;break;case"tag":i=u;break;case"tagger":c=Hr(u);break}}if(!s)throw new Error("Tag missing object field");if(!i)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:a,name:i,tagger:c,message:o}}function ga(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Sr(e.tagger)}`),t.push(""),t.push(e.message),Gd.encode(t.join(`
|
|
20
|
+
`))}var Gd,Ld,vr=ye(()=>{"use strict";Do();Gd=new TextEncoder,Ld=new TextDecoder});async function bt(e,t){return nr(vo(e,t))}async function Pe(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function ge(e,t){return e.objectStore.read(t)}async function gn(e,t){return e.objectStore.exists(t)}async function bs(e,t){return e.objectStore.ingestPack(t)}async function wa(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 ge(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return _d.decode(n.content)}async function yt(e,t){let n=await ge(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 ge(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return Vt(n.content)}async function ba(e,t){let n=await ge(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return sn(n.content)}async function _e(e,t){let n=t;for(let r=0;r<100;r++){let o=await ge(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 _d,ie=ye(()=>{"use strict";Ao();rn();vr();Gn();_d=new TextDecoder});async function Ea(e,t){return e.refStore.readRef(t)}async function U(e,t){let n=t;for(let r=0;r<ya;r++){let o=await Ea(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 Ea(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 Dr(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 we(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 ka(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 ge(e,o.hash);if(s.type==="tag"){let a=sn(s.content).object;for(let i=0;i<100;i++){let c=await ge(e,a);if(c.type!=="tag")break;a=sn(c.content).object}n.push(`^${a}`)}}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 Ra(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 Ra(e,t){if(e.refStore&&!(e.refStore instanceof
|
|
22
|
+
`);for(let o of t){let s=T(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Ra(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 Ra(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 Ra(e,T(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Mo,ya,bn,ue=ye(()=>{"use strict";ie();vr();de();je();En();Mo="ref: ",ya=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 Ar(this.fs,r),n.type==="symbolic"?await this.fs.writeFile(r,`${Mo}${n.target}
|
|
23
23
|
`):await this.fs.writeFile(r,`${n.hash}
|
|
24
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(i=>i.name)),a=`${t}/`;for(let[i,c]of o)i.startsWith(a)&&!s.has(i)&&n.push({name:i,hash:c})}return n.sort((s,a)=>s.name<a.name?-1:s.name>a.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<ya;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 a=o.slice(0,s),i=o.slice(s+1).trim();a.length===40&&i&&r.set(i,a)}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=[],a=!1;for(let c of o){if(a&&c.startsWith("^")){a=!1;continue}if(a=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){a=!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 a=T(t,s),i=`${n}/${s}`,c=await this.fs.stat(a);if(c.isDirectory)await this.walkRefs(a,i,r);else if(c.isFile){let f=await this.resolveRefInternal(i);f&&r.push({name:i,hash:f})}}}}});async function
|
|
28
|
-
`)){if(!s)continue;let a=
|
|
27
|
+
`)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let a=T(t,s),i=`${n}/${s}`,c=await this.fs.stat(a);if(c.isDirectory)await this.walkRefs(a,i,r);else if(c.isFile){let f=await this.resolveRefInternal(i);f&&r.push({name:i,hash:f})}}}}});async function Ln(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 Nd(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new sr(e,n),refStore:new bn(e,n)};let o=Fd(n);if(o===n)return null;n=o}}async function Nd(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 ys(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:T(t,".git"),a=r?null:t,i=T(s,"HEAD"),c=await e.exists(i);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:a,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 Ar(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Fd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var En=ye(()=>{"use strict";Ve();Ao();de();ue()});function Es(e,t){return T(e.gitDir,"logs",t)}function Ud(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],a=o[1];if(!s||!a)return null;let i=n.indexOf("<"),c=n.indexOf(">",i);if(i<0||c<0)return null;let f=n.slice(s.length+1+a.length+1,i).trim(),d=n.slice(i+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:a,name:f,email:d,timestamp:m,tz:h,message:r}}async function Ye(e,t){let n=Es(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 a=Ud(s);a&&o.push(a)}return o}function xa(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function kn(e,t,n){let r=Es(e,t);if(await Ar(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(xa).join(`
|
|
29
29
|
`)}
|
|
30
30
|
`;await e.fs.writeFile(r,o)}async function Be(e,t,n){let r=Es(e,t);await Ar(e.fs,r);let o=`${xa(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 Dr(e,t){let n=Es(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,a=!1){let i=await zt(e,t),c={oldHash:r??J,newHash:o,...i,message:s};await Be(e,n,c),a&&n!=="HEAD"&&await Be(e,"HEAD",c)}var je=ye(()=>{"use strict";dt();
|
|
32
|
-
`)){let s=il(o,t);s&&r.push(s)}return{patterns:r,src:n}}function al(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Aa){let a=n.slice(1);return e.length>=a.length&&e.endsWith(a)}return Fn(n,e,2)===0}function cl(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 a=n.length;if(a>0&&(e.length<a+1||e[a]!=="/"||!e.startsWith(n)))return!1;let i=a>0?e.slice(a+1):e,c=i.length;if(s>0){if(s>c||i.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Fn(r,i,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&Da&&!t)){if(s.flags&va){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(al(r,s))return s;continue}if(cl(e,s))return s}}return null}function Xt(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&xs?"not-ignored":"ignored"}if(e.excludeFile){let r=Uo(t,n,e.excludeFile);if(r)return r.flags&xs?"not-ignored":"ignored"}if(e.globalExclude){let r=Uo(t,n,e.globalExclude);if(r)return r.flags&xs?"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=Lr(r,"",n)}catch{}try{let r=await _t(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Lr(o,"",r)}catch{}}catch{}return t}function Un(e,t,n,r){let s=Lr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var va,Aa,Da,xs,Ps=ye(()=>{"use strict";Je();de();Rs();va=1,Aa=4,Da=8,xs=16});async function $t(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 a=T(e.workTree,s.path),i;try{i=await ct(e.fs,a)}catch{i=null}if(!i){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!i.isFile&&!i.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await xn(e.fs,a)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await Qe(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,a)=>Re(s.path,a.path))}async function it(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await ge(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&&cn(t.mode)&&e.fs.symlink){await ct(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let a=dl.decode(n.content);await e.fs.symlink(a,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 ja(e,t){let n=await qe(e,t);for(let r of n)await it(e,r)}async function Zt(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=fl.encode(f),l=await Pe(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),a=await Pe(e,"blob",s),i=o.mode!=null?ll(o.mode):33188,c={path:n,mode:i,hash:a,stage:0,stat:{...Ce(),size:s.byteLength}};return{index:wt(t,c),hash:a}}async function Qe(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 a=[],i=await e.fs.readdir(t);for(let c of i){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&&Xt(s,d,!1)==="ignored")continue;a.push(d)}else if(l.isDirectory){if(s&&Xt(s,d,!0)==="ignored")continue;let u=await Qe(e,f,d,{skipIgnore:o,_ignore:s??void 0});a.push(...u)}else if(l.isFile){if(s&&Xt(s,d,!1)==="ignored")continue;a.push(d)}}return a}function ll(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,Kt(t),n))}var fl,dl,et=ye(()=>{"use strict";re();Ps();ke();ie();de();Nn();He();fl=new TextEncoder,dl=new TextDecoder});function Bo(e){return e.existsOnDisk&&e.indexHash===null}async function ul(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 a=e.workTree?new Set(await Qe(e,e.workTree,"",{skipIgnore:!0})):new Set,i=null,c=async()=>(i===null&&(i=e.workTree?new Set(await Qe(e,e.workTree,"")):new Set),i),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 a)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,y=null,R=null;if(r.length===1){let G=u(0,h);w=G?.hash??null,R=G?.mode??null}else if(r.length===2){let G=u(0,h),j=u(1,h);g=G?.hash??null,y=G?.mode??null,w=j?.hash??null,R=j?.mode??null}else if(r.length>=3){let G=u(0,h),j=u(1,h),z=u(2,h);p=G?.hash??null,g=j?.hash??null,y=j?.mode??null,w=z?.hash??null,R=z?.mode??null}let E=o.get(h)?.hash??null,k=s.has(h)?1:0,C=a.has(h),O,x=async()=>O!==void 0?O:C?(O=!(await c()).has(h),O):(O=!1,!1),P,I=async()=>{if(P!==void 0)return P;if(!C||!e.workTree)return P=null,null;let G=T(e.workTree,h);try{P=await xn(e.fs,G)}catch{P=null}return P};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:E,indexStage:k,existsOnDisk:C,isIgnoredOnDisk:x,getWorktreeHash:I,headMode:y,remoteMode:R})}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 Is(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 ml(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 hl(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let a=t.get(o);if(!a)continue;let i=ml(s,a);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await pl(c,a,i);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function pl(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 gl(e,t,n,r){let o=[],s=[],a=new Set(e.keys()),i=new Map;for(let c of n.entries)a.has(c.path)||o.push(c),c.stage===0&&i.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let l=i.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)=>Re(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function $s(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:a,fix:i}of wl){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
|
|
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 Dr(e,t){let n=Es(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,a=!1){let i=await zt(e,t),c={oldHash:r??J,newHash:o,...i,message:s};await Be(e,n,c),a&&n!=="HEAD"&&await Be(e,"HEAD",c)}var je=ye(()=>{"use strict";dt();hn();de();En();dt()});function Bd(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 i=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:i}),n=s[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let i=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:i}),n=a[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 Wd(e,t){let n=await wa(e,t);if(n.length===0)return null;if(n.length>1)throw new jo(t);return n[0]}async function qd(e,t){if(t==="HEAD"||t==="@")return U(e,"HEAD");if(Ca.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 Wd(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 Kd(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Ca)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function zd(e,t,n){let r=Kd(t),o=await Ye(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let a=o[s];return a?a.newHash:null}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=Bd(t),s;if(r!==void 0?s=await zd(e,n,r):s=await qd(e,n),!s)return null;o.length>0&&(s=await _e(e,s));for(let a of o)if(a.type==="tilde")for(let i=0;i<a.n;i++){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(a.n===0)continue;if(!s)return null;let i=await M(e,s);if(a.n>i.parents.length||(s=i.parents[a.n-1]??null,!s))return null}return s}function Pa(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Ca,jo,on=ye(()=>{"use strict";ie();je();ue();Ca=["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 Mr(e,t){if((await ct(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Vd.encode(r)}return e.readFileBuffer(t)}async function Rn(e,t){let n=await Mr(e,t);return bt("blob",n)}var Vd,_n=ye(()=>{"use strict";ie();Vd=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=Oa.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let a=Oa.decode(e.subarray(r+1,s)),i=e.subarray(s+1,s+21),c=pn(i),f=o.padStart(6,"0");t.push({mode:f,name:a,hash:c}),n=s+21}return{type:"tree",entries:t}}function Ia(e){let t=[];for(let s of e.entries){let a=s.mode.replace(/^0+/,""),i=Yd.encode(`${a} ${s.name}\0`),c=Ot(s.hash);t.push(i),t.push(c)}let n=t.reduce((s,a)=>s+a.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Yd,Oa,ks=ye(()=>{"use strict";dt();Yd=new TextEncoder,Oa=new TextDecoder});var jr,$a=ye(()=>{"use strict";jr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function De(e,t){return Ta(e,t,"")}async function Ta(e,t,n){let r=[],o=new Map;for(let a of t){let i=n?a.path.slice(n.length+1):a.path,c=i.indexOf("/");if(c===-1)r.push({mode:Xd(a.mode),name:i,hash:a.hash});else{let f=i.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(a)}}for(let[a,i]of o){let c=n?`${n}/${a}`:a,f=await Ta(e,i,c);r.push({mode:jr.DIRECTORY,name:a,hash:f})}r.sort((a,i)=>{let c=a.mode===jr.DIRECTORY?`${a.name}/`:a.name,f=i.mode===jr.DIRECTORY?`${i.name}/`:i.name;return c<f?-1:c>f?1:0});let s=Ia({type:"tree",entries:r});return Pe(e,"tree",s)}async function qe(e,t,n=""){let r=await ge(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=xn(r.content),s=[];for(let a of o.entries){let i=n?`${n}/${a.name}`:a.name;if(a.mode===jr.DIRECTORY){let c=await qe(e,a.hash,i);s.push(...c)}else s.push({path:i,mode:a.mode,hash:a.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 Ne(e,t,n){let r=await ce(e,t),o=await ce(e,n),s=[];for(let[a,i]of r){let c=o.get(a);c?(i.hash!==c.hash||i.mode!==c.mode)&&s.push({path:a,status:"modified",oldHash:i.hash,newHash:c.hash,oldMode:i.mode,newMode:c.mode}):s.push({path:a,status:"deleted",oldHash:i.hash,oldMode:i.mode})}for(let[a,i]of o)r.has(a)||s.push({path:a,status:"added",newHash:i.hash,newMode:i.mode});return s.sort((a,i)=>Re(a.path,i.path))}function Xd(e){return e.toString(8).padStart(6,"0")}var He=ye(()=>{"use strict";re();ie();ks();$a()});function Ha(e){return/^[a-zA-Z0-9]$/.test(e)}function Zd(e){return/^[a-zA-Z]$/.test(e)}function Jd(e){return e>="0"&&e<="9"}function Go(e){return e>="A"&&e<="Z"}function Lo(e){return e>="a"&&e<="z"}function Sa(e){return/^\s$/.test(e)}function Qd(e){return e===" "||e===" "}function No(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function el(e){return No(e)&&!Sa(e)}function tl(e){return No(e)&&!Ha(e)&&e!==" "}function nl(e){let t=e.charCodeAt(0);return t<32||t===127}function rl(e){return/^[0-9a-fA-F]$/.test(e)}function Gr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function _o(e,t,n,r,o){let s=(o&1)!==0,a=(o&2)!==0;for(;t<e.length;){let i=e[t];if(r>=n.length&&i!=="*")return-1;let c=r<n.length?n[r]:"";switch(i){case"\\":{if(t++,t>=e.length)return-1;if(!Gr(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(a&&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(!a)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=!a;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(!sl(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(a&&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],Gr(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="[",Gr(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);ol(g,c,s)&&(d=!0),m=""}}else Gr(c,m,s)&&(d=!0);l=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!Gr(c,i,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function sl(e){return e==="*"||e==="?"||e==="["||e==="\\"}function ol(e,t,n){switch(e){case"alnum":return Ha(t);case"alpha":return Zd(t);case"blank":return Qd(t);case"cntrl":return nl(t);case"digit":return Jd(t);case"graph":return el(t);case"lower":return Lo(t)||n&&Go(t);case"print":return No(t);case"punct":return tl(t);case"space":return Sa(t);case"upper":return Go(t)||n&&Lo(t);case"xdigit":return rl(t);default:return!1}}function Nn(e,t,n=0){return _o(e,0,t,0,n)===0?0:1}var Rs=ye(()=>{"use strict"});function Ma(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 il(e){return Ma(e)===e.length}function al(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|=xs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Da);let a=!1;for(let c=0;c<s;c++)if(o[c]==="/"){a=!0;break}a||(r|=va);let i=Math.min(Ma(o),s);return o[0]==="*"&&il(o.slice(1))&&(r|=Aa),{pattern:o,patternLen:s,nowildcardLen:i,flags:r,base:t}}function Lr(e,t,n){let r=[];for(let o of e.split(`
|
|
32
|
+
`)){let s=al(o,t);s&&r.push(s)}return{patterns:r,src:n}}function cl(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Aa){let a=n.slice(1);return e.length>=a.length&&e.endsWith(a)}return Nn(n,e,2)===0}function fl(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 a=n.length;if(a>0&&(e.length<a+1||e[a]!=="/"||!e.startsWith(n)))return!1;let i=a>0?e.slice(a+1):e,c=i.length;if(s>0){if(s>c||i.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Nn(r,i,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&Da&&!t)){if(s.flags&va){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(cl(r,s))return s;continue}if(fl(e,s))return s}}return null}function Xt(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&xs?"not-ignored":"ignored"}if(e.excludeFile){let r=Fo(t,n,e.excludeFile);if(r)return r.flags&xs?"not-ignored":"ignored"}if(e.globalExclude){let r=Fo(t,n,e.globalExclude);if(r)return r.flags&xs?"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=Lr(r,"",n)}catch{}try{let r=await _t(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Lr(o,"",r)}catch{}}catch{}return t}function Fn(e,t,n,r){let s=Lr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var va,Aa,Da,xs,Ps=ye(()=>{"use strict";Ve();de();Rs();va=1,Aa=4,Da=8,xs=16});async function $t(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 a=T(e.workTree,s.path),i;try{i=await ct(e.fs,a)}catch{i=null}if(!i){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!i.isFile&&!i.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await Rn(e.fs,a)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await Qe(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,a)=>Re(s.path,a.path))}async function it(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await ge(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 a=ll.decode(n.content);await e.fs.symlink(a,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 ja(e,t){let n=await qe(e,t);for(let r of n)await it(e,r)}async function Zt(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=dl.encode(f),l=await Pe(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),a=await Pe(e,"blob",s),i=o.mode!=null?ul(o.mode):33188,c={path:n,mode:i,hash:a,stage:0,stat:{...Ce(),size:s.byteLength}};return{index:wt(t,c),hash:a}}async function Qe(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=Fn(s,f,n,c)}catch{}}let a=[],i=await e.fs.readdir(t);for(let c of i){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&&Xt(s,d,!1)==="ignored")continue;a.push(d)}else if(l.isDirectory){if(s&&Xt(s,d,!0)==="ignored")continue;let u=await Qe(e,f,d,{skipIgnore:o,_ignore:s??void 0});a.push(...u)}else if(l.isFile){if(s&&Xt(s,d,!1)==="ignored")continue;a.push(d)}}return a}function ul(e){return e>511?e:e&73?33261:33188}async function Un(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 Un(e,Kt(t),n))}var dl,ll,et=ye(()=>{"use strict";re();Ps();ke();ie();de();_n();He();dl=new TextEncoder,ll=new TextDecoder});function Uo(e){return e.existsOnDisk&&e.indexHash===null}async function ml(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 a=e.workTree?new Set(await Qe(e,e.workTree,"",{skipIgnore:!0})):new Set,i=null,c=async()=>(i===null&&(i=e.workTree?new Set(await Qe(e,e.workTree,"")):new Set),i),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 a)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,y=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,y=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),z=u(2,h);p=j?.hash??null,g=G?.hash??null,y=G?.mode??null,w=z?.hash??null,x=z?.mode??null}let k=o.get(h)?.hash??null,R=s.has(h)?1:0,C=a.has(h),P,E=async()=>P!==void 0?P:C?(P=!(await c()).has(h),P):(P=!1,!1),O,I=async()=>{if(O!==void 0)return O;if(!C||!e.workTree)return O=null,null;let j=T(e.workTree,h);try{O=await Rn(e.fs,j)}catch{O=null}return O};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:R,existsOnDisk:C,isIgnoredOnDisk:E,getWorktreeHash:I,headMode:y,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 Is(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 hl(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 pl(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let a=t.get(o);if(!a)continue;let i=hl(s,a);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await gl(c,a,i);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function gl(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 wl(e,t,n,r){let o=[],s=[],a=new Set(e.keys()),i=new Map;for(let c of n.entries)a.has(c.path)||o.push(c),c.stage===0&&i.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let l=i.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)=>Re(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function $s(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:a,fix:i}of bl){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(`${a(t.operationName)}
|
|
34
34
|
${f}
|
|
35
35
|
${i(n)}
|
|
36
36
|
`)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
|
|
37
|
-
`:"",exitCode:t.errorExitCode}}async function
|
|
37
|
+
`:"",exitCode:t.errorExitCode}}async function Bn(e,t,n,r){let o=await ml(e,t,n),s=new Map(o.map(d=>[d.path,d])),a=new Map;for(let d of o){let l=r.mergeFn(d,r);a.set(d.path,l)}let i=await pl(a,s,r);if(i.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:i,errorOutput:$s(i,r)};let{newEntries:c,worktreeOps:f}=wl(a,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Se(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 Un(e.fs,Kt(o),n)}async function Cn(e,t,n,r){return Bn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Is,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Ga(e,t,n,r){return Bn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Is,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function cn(e,t,n){return Bn(e,[{label:"target",treeHash:t}],n,{mergeFn:Os,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ts(e,t,n,r){let o=new Set;for(let i of n.entries)i.stage>0&&o.add(i.path);let s={version:n.version,entries:Ae(n)},a=await Bn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Os,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!a.success){let i=r??"HEAD",c=[];for(let f of a.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&&(a.errorOutput=N(c.join("")+`fatal: Could not reset index file to revision '${i}'.
|
|
40
|
-
`,128)),a}if(e.workTree&&o.size>0){let i=await ce(e,t),c=new Set(a.newEntries.map(f=>f.path));for(let f of o)!i.has(f)&&!c.has(f)&&a.worktreeOps.push({path:f,type:"delete"})}return a}var
|
|
41
|
-
`,exitCode:128}}function N(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function B(e,t,n){let r=await
|
|
40
|
+
`,128)),a}if(e.workTree&&o.size>0){let i=await ce(e,t),c=new Set(a.newEntries.map(f=>f.path));for(let f of o)!i.has(f)&&!c.has(f)&&a.worktreeOps.push({path:f,type:"delete"})}return a}var bl,Jt=ye(()=>{"use strict";re();ke();de();_n();He();et();bl=[{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 N(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function B(e,t,n){let r=await Ln(e,t);return r?n?{...r,...n}:r:yl}function v(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ke(e){return e.workTree?null:El}async function ze(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 It(e)?N(`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.
|
|
45
|
-
`+n,128):null}async function Tt(e,t,n){let r=await We(e,t);return r||$(n??`bad revision '${t}'`)}async function Ie(e,t,n){let r=await We(e,t);if(!r)return $(n??`bad revision '${t}'`);try{let o=await _e(e,r),s=await M(e,o);return{hash:o,commit:s}}catch{return $(n??`bad revision '${t}'`)}}async function
|
|
45
|
+
`+n,128):null}async function Tt(e,t,n){let r=await We(e,t);return r||$(n??`bad revision '${t}'`)}async function Ie(e,t,n){let r=await We(e,t);if(!r)return $(n??`bad revision '${t}'`);try{let o=await _e(e,r),s=await M(e,o);return{hash:o,commit:s}}catch{return $(n??`bad revision '${t}'`)}}async function Xe(e,t){try{return await Cr(e,t)}catch(n){return $(n.message)}}async function Qt(e,t){try{return await ds(e,t)}catch(n){return $(n.message)}}function ar(e,t){let n=new Map;for(let r of e.entries)r.stage===0&&n.set(r.path,r);for(let[r,o]of n){let s=t.get(r);if(!s||s.hash!==o.hash)return!0}for(let[r]of t)if(!n.has(r))return!0;return!1}function Re(e,t){return e<t?-1:e>t?1:0}function lt(e,t){return e.workTree?at(e.workTree,t):""}function V(e){return e.slice(0,7)}function ae(e){let t=e.indexOf(`
|
|
46
46
|
`);return t===-1?e:e.slice(0,t)}function Ut(e){return $(`ambiguous argument '${e}': unknown revision or path not in the working tree.
|
|
47
47
|
Use '--' to separate paths from revisions, like this:
|
|
48
|
-
'git <command> [<revision>...] -- [<file>...]'`)}function Ht(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${V(t)}] ${ae(n)}`}async function
|
|
48
|
+
'git <command> [<revision>...] -- [<file>...]'`)}function Ht(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${V(t)}] ${ae(n)}`}async function Pn(e,t,n){if(!await U(e,n.operationRef))return n.noOpError;let o=await U(e,"ORIG_HEAD")??await X(e);if(!o)return $(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),a=await M(e,o),i=await K(e),c=await Ts(e,a.tree,i,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await yn(e,o),await se(e,{version:2,entries:c.newEntries}),await Se(e,c.worktreeOps),s&&((await Z(e))?.type==="symbolic"||s!==o)){let l=n.origHeadAsTargetRev?o:"HEAD";await ne(e,t,"HEAD",s,o,`reset: moving to ${l}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function ut(e,t,n,r,o,s){let a=Yt({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),i=await Pe(e,"commit",a);return await yn(e,i),i}function en(e){return e.split(`
|
|
49
49
|
`).filter(t=>!t.startsWith("#")).map(t=>t.trimEnd()).join(`
|
|
50
50
|
`).replace(/\n+$/,`
|
|
51
51
|
`)}function St(e){return e.endsWith(`
|
|
52
52
|
`)?e:`${e}
|
|
53
|
-
`}var
|
|
54
|
-
`)}function
|
|
55
|
-
`)}function
|
|
56
|
-
Maybe you wanted to say 'git add .'?`,exitCode:0};let d=await K(s),l=[],u=[];for(let p of f)
|
|
53
|
+
`}var yl,El,re=ye(()=>{"use strict";hn();ke();ie();rn();de();je();ue();En();on();Jt();yl=$("not a git repository (or any of the parent directories): .git"),El=$("this operation must be run in a work tree")});var Fa={};ad(Fa,{CommitHeap:()=>qn,countAheadBehind:()=>Ko,findOrphanedCommits:()=>zo,walkCommits:()=>vt});async function*vt(e,t,n){let r=await Ol(e,n?.exclude),o=new Set(r),s=new qn,a=Array.isArray(t)?t:[t];for(let i of a)o.has(i)||s.push(await As(e,i));for(;s.size>0;){let i=s.pop();if(!o.has(i.hash)){o.add(i.hash),yield i;for(let c of i.commit.parents)o.has(c)||s.push(await As(e,c))}}}async function Ko(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let i of vt(e,t))r.add(i.hash);let o=new Set;for await(let i of vt(e,n))o.add(i.hash);let s=0;for(let i of r)o.has(i)||s++;let a=0;for(let i of o)r.has(i)||a++;return{ahead:s,behind:a}}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 _e(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let a=new Set;if(s.length>0)for await(let d of vt(e,s))a.add(d.hash);if(a.has(t))return[];let i=[],c=new Set,f=new qn;for(f.push(await As(e,t));f.size>0&&i.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!a.has(d.hash))){i.push({hash:d.hash,subject:ae(d.commit.message)});for(let l of d.commit.parents)c.has(l)||f.push(await As(e,l))}}return i}async function Ol(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of vt(e,t))n.add(r.hash);return n}async function As(e,t){return{hash:t,commit:await M(e,t)}}var qn,Kn=ye(()=>{"use strict";re();ie();ue();qn=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,a=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),a<r&&this.higher(n[a],n[o])&&(o=a),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 ji(e){return new po({_kind:"arg",type:e,required:!0})}function Gi(){return ji("string")}function Li(){return ji("number")}var is=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 _i(e){return new go({_kind:"option",type:e})}function Ni(){return _i("string")}function Fi(){return _i("number")}var ee={string:Ni,number:Fi};function H(){return new is}var q={string:Gi,number:Li};function cd(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(cd).join(`
|
|
54
|
+
`)}function fd(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 a=1;a<=r;a++){let i=e[s-1]===t[a-1]?0:1;o[s*(r+1)+a]=Math.min(o[(s-1)*(r+1)+a]+1,o[s*(r+1)+(a-1)]+1,o[(s-1)*(r+1)+(a-1)]+i)}return o[n*(r+1)+r]}function as(e,t,n=3){return t.map(o=>({candidate:o,distance:fd(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 Ui(e,t,n,r){let o=[],s=new Map,a=new Map;for(let[u,m]of Object.entries(e)){let h=Rr(u);s.set(h,{key:u,def:m}),m.short&&a.set(m.short,{key:u,def:m})}let i={},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"){i[b.key]=b.def.counted?0:!1,d++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:as(h,x).map(b=>`--${b}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?i[g.key]=(i[g.key]||0)+1:i[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 y=kr(w,g.def.type,g.key,o);y!==void 0&&(i[g.key]=y),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=a.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?i[g.key]=(i[g.key]||0)+1:i[g.key]=!0;continue}let w=m.slice(h+1),y=w.length>0?w:n[++d];if(y===void 0){o.push({type:"missing_value",name:g.key});break}let x=kr(y,g.def.type,g.key,o);x!==void 0&&(i[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?i[h]=p.map(g=>kr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?i[h]=m.default:i[h]=[],l=c.length}else{let p=c[l];p!==void 0?(i[h]=kr(p,m.type,h,o),l++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(i[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(i[u]===void 0){if(m._kind==="flag")i[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=kr(r[h.env],h.type,u,o);p!==void 0&&(i[u]=p)}i[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(i[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:i,passthrough:f}}function kr(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 Rr(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 a of o){let i=a.name??"arg",c=a.variadic?`${i}...`:i;r.push(a.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let a=[];for(let[c,f]of e.children)a.push([c,f.description||""]);let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let a=[];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)})`),a.push([d,l.join(" ")])}let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=dd(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let a of e.examples)t.push(` ${a}`);t.push("")}return t.join(`
|
|
55
|
+
`)}function dd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[a,i]of n){let c=Rr(a);if(i._kind==="flag"){let f=i,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=i,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(([a])=>a.length)),s=[];t&&s.push(t);for(let[a,i]of r)if(i){let c=" ".repeat(o-a.length+2);s.push(` ${a}${c}${i}`)}else s.push(` ${a}`);return s}function Bi(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Wi(e){return e?e.map(t=>t._def):[]}var cs=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,a,i){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=a,this.transformArgs=i}command(t,n){let r=new e(t,n.description,Bi(n.options),Wi(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,a]of Object.entries(r)){let i=o[s],c=Rr(s);if(a._kind==="flag")if(a.counted&&typeof i=="number"&&i>0)for(let f=0;f<i;f++)n.push(`--${c}`);else i===!0?n.push(`--${c}`):i===!1&&a.default===!0&&n.push(`--no-${c}`);else a._kind==="option"&&i!==void 0&&n.push(`--${c}`,String(i))}for(let s of this.args){let a=s.name??"arg",i=o[a];if(i!==void 0)if(s.variadic&&Array.isArray(i))for(let c of i)n.push(String(c));else n.push(String(i))}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,a]of Object.entries(o))if(r[s]===void 0){if(a._kind==="flag")r[s]=a.default??(a.counted?0:!1);else if(a._kind==="option"){if(a.default!==void 0)r[s]=a.default;else if(a.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let a=s.name??"arg";if(r[a]===void 0){if(s.default!==void 0)r[a]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${a}"`,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(ld(t))return{stdout:bo(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],a=Ui(this.allOptions,this.args,s,r);if(!a.ok)return{stdout:"",stderr:wo(a.errors),exitCode:1};try{return await this.handler(a.args,n,{passthrough:a.passthrough})}catch(i){return{stdout:"",stderr:i instanceof Error?i.message:String(i),exitCode:1}}}if(o&&!o.startsWith("-")){let s=as(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 cs(e,t.description,Bi(t.options),Wi(t.args),t.examples??[],t.handler,t.transformArgs)}function ld(e){return e.some(t=>t==="--help"||t==="-h")}re();Ps();ke();de();Rs();var Ss=1,Bo=2,Hs=4,Wo=8,_r=16,_a=new Set(["*","?","[","\\"]),Rl={glob:Ss,literal:Bo,icase:Hs,top:Wo,exclude:_r};function Wn(e){for(let t=0;t<e.length;t++)if(_a.has(e[t]))return!0;return!1}function xl(e){for(let t=0;t<e.length;t++)if(_a.has(e[t]))return t;return e.length}function La(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=Rl[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&Ss&&(n&=~Ss);let o;n&Wo||t===""?o=La(r):o=La(`${t}/${r}`);let s=!!(n&Bo),a=s?!1:Wn(o),i=s?o.length:xl(o);return{original:e,pattern:o,magic:n,hasWildcard:a,nowildcardLen:i}}function vs(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let i=!!(o&Hs),c=i?n.toLowerCase():n,f=i?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let i=n.slice(0,s),c=t.slice(0,s);if(o&Hs){if(i.toLowerCase()!==c.toLowerCase())return!1}else if(i!==c)return!1}let a=0;return o&Ss&&(a|=2),o&Hs&&(a|=1),Nn(n,t,a)===0}function be(e,t){let n=!1,r=!1;for(let o of e)o.magic&_r?vs(o,t)&&(r=!0):vs(o,t)&&(n=!0);return n&&!r}et();function Na(e,t){e.command("add",{description:"Add file contents to the index",args:[q.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:H().alias("A").describe("Add changes from all tracked and untracked files"),force:H().alias("f").describe("Allow adding otherwise ignored files"),update:H().alias("u").describe("Update tracked files"),"dry-run":H().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,a=Ke(s);if(a)return a;let i=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,i,"",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)Wn(p)?u.push(p):l.push(p);let m=[];for(let p of l){let g=Pt(r.cwd,p),w=at(i,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return $(`'${p}' is outside repository at '${i}'`);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 Pl(s,i,w,b);if(k){b&&((await r.fs.stat(g)).isDirectory?d=await qo(s,d,g,w,c):d=(await Zt(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 Zt(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),N(`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
|
|
63
|
+
`);if(u.length>0){let p=await Cl(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 Cl(e,t,n,r,o){let s=e.workTree,a=lt(e,t),i=r.map(l=>Ge(l,a)),c=new Array(i.length).fill(!1),f=l=>{for(let u=0;u<i.length;u++)i[u].hasWildcard&&vs(i[u],l)&&(c[u]=!0)},d=[];for(let l of n.entries){if(l.stage>0||!be(i,l.path))continue;f(l.path);let u=T(s,l.path);if(await e.fs.exists(u)){let m=await Zt(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 Qe(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(l.has(m)||!be(i,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
|
|
66
|
-
`),n=(await Zt(e,n,m)).index}}for(let l=0;l<i.length;l++){let u=i[l];if(!c[l]&&!(u.magic&_r))return{index:n,error:$(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function
|
|
66
|
+
`),n=(await Zt(e,n,m)).index}}for(let l=0;l<i.length;l++){let u=i[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}/`,a=e.workTree,i=[],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(a,f.path);if(await e.fs.exists(d)){let l=f.stage>0,u=await Zt(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
|
`),i.push(f.path)}for(let f of i)t=ot(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(l=>l.path)),d=await Qe(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 Zt(e,t,l)).index}}return t}async function
|
|
69
|
+
`),t=(await Zt(e,t,l)).index}}return t}async function Pl(e,t,n,r){let o=await ir(e);try{let a=await e.fs.readFile(T(t,".gitignore"));o=Fn(o,a,"",T(t,".gitignore"))}catch{}let s=n.split("/");for(let a=0;a<s.length-1;a++){let i=s.slice(0,a+1).join("/"),c=T(t,i);if(Xt(o,i,!0)==="ignored")return i;try{let f=await e.fs.readFile(T(c,".gitignore"));o=Fn(o,f,i,T(c,".gitignore"))}catch{}}if(!r){let a=await e.fs.stat(T(t,n)).then(i=>i.isDirectory).catch(()=>!1);if(Xt(o,n,a)==="ignored")return n}return null}re();re();Kn();ie();de();ue();async function Ee(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 Nr(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 Bt(e){await fe(e,"CHERRY_PICK_HEAD"),await fe(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function At(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 Ua(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 Fr(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 Ee(e,"BISECT_START");return t!=null&&t.trim().length>0}async function Ur(e){let t=await Ee(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 Ee(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await Ur(e),o=await U(e,`refs/bisect/${n}`),s=[],a=[],i=await pe(e,"refs/bisect");for(let d of i)d.name.startsWith(`refs/bisect/${r}-`)?s.push(d.hash):d.name.startsWith("refs/bisect/skip-")&&a.push(d.hash);let c=await Ee(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:a,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function kt(e,t){let n=await Ee(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
|
|
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 Ba(e,t,n,r,o){let s=[],a=new Map;for await(let g of vt(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)}),a.set(g.hash,w)}let i=s.length;if(i===0)return null;if(i===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,y=[g.hash],x=0;for(;x<y.length;){let b=y[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let k=a.get(b);if(k)for(let R of k)!w.has(R)&&c.has(R)&&y.push(R)}f.set(g.hash,w.size)}let d=s[0].hash,l=i;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,y=Math.abs(2*w-i);y<l&&(l=y,d=g.hash)}let u=!1;if(l===i){u=!0;for(let g of s){let w=f.get(g.hash)??0,y=Math.abs(2*w-i);y<l&&(l=y,d=g.hash)}}let m=s.find(g=>g.hash===d),h=Il(i),p=$l(i);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function Il(e){return Math.floor((e-1)/2)}function $l(e){return e<=1?0:Math.ceil(Math.log2(e))}function Wa(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
74
|
`}function qa(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
|
|
@@ -80,23 +80,23 @@ hint: Disable this message with "git config set advice.addIgnoredFile false"
|
|
|
80
80
|
`,a+=`
|
|
81
81
|
`,a+=` ${r}
|
|
82
82
|
`,a+=`
|
|
83
|
-
`,a}re();
|
|
83
|
+
`,a}re();Kn();Ve();ke();ie();de();je();ue();re();Kn();Ve();ke();ie();de();ie();rn();de();function cr(e){return T(e.gitDir,"rebase-merge")}async function Dt(e){return e.fs.exists(cr(e))}async function ht(e){let t=cr(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),a=Number.parseInt(await e.fs.readFile(T(t,"end")),10),i=await e.fs.exists(T(t,"git-rebase-todo"))?T(t,"git-rebase-todo"):T(t,"todo"),c=za(await e.fs.readFile(i)),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:a}}async function Yo(e,t){let n=cr(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
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 Xa(e){let t=cr(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
|
|
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=cr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Ls(e,t,n){let r=cr(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
93
|
`)}function za(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 Za(e,t,n){let r=new Map,[o,s]=await Promise.all([Va(e,t,r),Va(e,n,r)]),a=new Set;for(let c of s)o.has(c)||a.add(c);let i=new Set;for(let c of o)s.has(c)||i.add(c);return{right:await Ya(e,r,n,a),left:await Ya(e,r,t,i)}}async function Va(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let a=o[s++];if(r.has(a))continue;r.add(a);let i=await js(e,a,n);for(let c of i.commit.parents)r.has(c)||o.push(c)}return r}async function Ya(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 a=s.map(f=>f.hash),i=[],c=new Set;for(;a.length>0;){let f=a.pop();if(!f||c.has(f))continue;c.add(f);let d=await js(e,f,t);d.commit.parents.length<=1&&i.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&&a.push(l)}}return i.reverse(),i}async function js(e,t,n){let r=n.get(t);if(r)return r;let o=await ge(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Vt(o.content)};return n.set(t,s),s}
|
|
97
|
-
`))d.push(I);l=!0}}if(l&&(w||u||m||h)&&d.push(""),w&&h)ec(d,w),d.push(""),i.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
|
|
96
|
+
`}async function Za(e,t,n){let r=new Map,[o,s]=await Promise.all([Va(e,t,r),Va(e,n,r)]),a=new Set;for(let c of s)o.has(c)||a.add(c);let i=new Set;for(let c of o)s.has(c)||i.add(c);return{right:await Ya(e,r,n,a),left:await Ya(e,r,t,i)}}async function Va(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let a=o[s++];if(r.has(a))continue;r.add(a);let i=await js(e,a,n);for(let c of i.commit.parents)r.has(c)||o.push(c)}return r}async function Ya(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 a=s.map(f=>f.hash),i=[],c=new Set;for(;a.length>0;){let f=a.pop();if(!f||c.has(f))continue;c.add(f);let d=await js(e,f,t);d.commit.parents.length<=1&&i.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&&a.push(l)}}return i.reverse(),i}async function js(e,t,n){let r=n.get(t);if(r)return r;let o=await ge(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Vt(o.content)};return n.set(t,s),s}ue();ie();function fr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Tl(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=fr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&fr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Hl=50;async function tt(e,t,n=Hl){let r=new Map,o=[],s=[],a=[];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):a.push(d);let i=[],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=Tl(u,d.path);m&&i.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 Sl(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)),i.push(...d)}}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)),i.push(...d)}}return{remaining:[...a,...f,...c],renames:i}}async function Sl(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++){let c=t[i];if(!c)continue;let f=fr(c.path);o.has(f)?o.set(f,-1):o.set(f,i)}let s=new Map;for(let i=0;i<n.length;i++){let c=n[i];if(!c)continue;let f=fr(c.path);s.has(f)?s.set(f,-1):s.set(f,i)}let a=[];for(let[i,c]of o){if(c===-1)continue;let f=s.get(i);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=Al(u,m);h<r||a.push({oldPath:d.path,newPath:l.path,oldHash:d.oldHash,newHash:l.newHash,similarity:h,oldMode:d.oldMode,newMode:l.newMode})}return a}var Ja=107927;function _s(e){let t=new Map,n=0,r=0,o=0;for(let a=0;a<e.length;a++){let i=e[a],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+i>>>0,n++,n<64&&i!==10)continue;let f=(r+Math.imul(o,97))%Ja;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let a=(r+Math.imul(o,97))%Ja;t.set(a,(t.get(a)??0)+n)}let s=[];for(let[a,i]of t)s.push({hash:a,count:i});return s.sort((a,i)=>a.hash-i.hash),s}function vl(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let a=e[o];if(!a)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=a.hash)break;r+=f.count,s++}let i=a.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===a.hash&&(c=f.count,s++)}i<c?(r+=c-i,n+=i):n+=c,o++}for(;s<t.length;){let a=t[s];a&&(r+=a.count),s++}return{srcCopied:n,literalAdded:r}}function Al(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Qa(e.length,_s(e),t.length,_s(t))}function Qa(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:a}=vl(t,r);return Math.floor(a*100/o)}async function Dl(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:_s(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:_s(l)})}else s.push(null);let a=[];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=Qa(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=fr(l.path)===fr(h.path)?1:0;a.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}a.sort((d,l)=>l.similarity-d.similarity||l.nameScore-d.nameScore);let i=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:l,addIdx:u}of a){if(i.has(l)||c.has(u))continue;i.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 a=o>0?1:0,i=0,c=n,f=r;for(;o-a<=c&&o-a<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(i=n-c),c--,f--}let d=Math.max(0,n-o-i),l=Math.max(0,r-o-i),u=e.slice(0,o),m=e.slice(n-i),h=e.slice(o,o+d),p=t.slice(o,o+l);return o+i>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}He();et();async function nt(e,t){let n=await Z(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=we(n.target):(s=!0,o="HEAD detached");let a=t?.index??await K(e),i=Jo(a),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await Zo(e,c,a,i),l=await $t(e,a),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)=>Re(g.path,w.path));let h=new Set(a.entries.map(g=>g.path)),p=Qo(m,h);return Ml(e,r,s,o,a,d,u,i,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function ec(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 ${V(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 ${V(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Ml(e,t,n,r,o,s,a,i,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 Dt(e)?await ht(e):null;if(n&&w){let P=V(w.onto);d.push(`interactive rebase in progress; onto ${P}`)}else if(n){let P=await Fr(e);if(P){let E=t===P?"at":"from";d.push(`HEAD detached ${E} ${V(P)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let P=await le(e),E=await dn(e,P,r);if(E){let O=Vn(E,{abbreviated:f?.fromCommit});for(let I of O.trimEnd().split(`
|
|
97
|
+
`))d.push(I);l=!0}}if(l&&(w||u||m||h)&&d.push(""),w&&h)ec(d,w),d.push(""),i.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=It(o),E=await e.fs.exists(T(e.gitDir,"MERGE_MSG"));ec(d,w);let I=w.headName==="detached HEAD"?null:we(w.headName),j=V(w.onto),G=I?` branch '${I}' 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(E)d.push(`You are currently rebasing${G}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let z=G?`You are currently editing a commit while rebasing${G}.`:"You are currently editing a commit during a rebase.";d.push(z),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 ${V(u)}.`),i.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 ${V(m)}.`),i.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&&(i.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 E=(await Ee(e,"BISECT_START"))?.trim()??"";d.push(`You are currently bisecting, started from branch '${E}'.`),d.push(' (use "git bisect reset" to get back to the original branch)'),l=!0}let y=f?.isInitial??!t;y&&(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=a.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(` ${tc(P.status,P.path,P.displayPath)}`);d.push(""),R=!0}if(i.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)')),i.some(E=>E.status==="deleted by us"||E.status==="deleted by them"||E.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 E of i)d.push(` ${jl(E.status,E.path)}`);d.push(""),R=!0}if(a.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 a)d.push(` ${tc(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&&i.length===0;return!R&&l&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!R&&l&&a.length===0&&i.length===0&&c.length===0&&d.push(""),a.length>0||i.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)'):y?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
|
|
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 a=await ce(e,s),i=new Map(Ae(n).map(m=>[m.path,m])),c=[];for(let[m,h]of i){if(o.has(m))continue;let p=a.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 a)o.has(m)||i.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await tt(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)=>Re(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,a=o.has(1),i=o.has(2),c=o.has(3);i&&c?s=a?"both modified":"both added":a&&!i&&!c?s="both deleted":a&&c?s="deleted by us":a&&i?s="deleted by them":i&&!a&&!c?s="added by us":c&&!a&&!i?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Re(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 a=!1;for(let i=1;i<s.length;i++){let c=`${s.slice(0,i).join("/")}/`;if(!n.has(c)){r.add(c),a=!0;break}}a||r.add(o)}return[...r].sort()}function tc(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function jl(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,a=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),i=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await U(e,a);if(!c)return{upstream:i,ahead:0,behind:0,gone:!0};let f=await U(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:i,ahead:0,behind:0,gone:!1};let{ahead:d,behind:l}=await Ko(e,f,c);return{upstream:i,ahead:d,behind:l,gone:!1}}function nc(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}.
|
|
@@ -106,19 +106,19 @@ GIT_AUTHOR_DATE='${o}'
|
|
|
106
106
|
`}let n=`Your branch and '${e.upstream}' have diverged,
|
|
107
107
|
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
|
-
`}He();Jt();et();async function Ns(e){let t=await
|
|
109
|
+
`}He();Jt();et();async function Ns(e){let t=await Ye(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],a=`refs/heads/${s}`,i=await U(e,a);if(i)return{name:s,refName:a,hash:i}}}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
|
|
111
|
+
`),await zn(e),t}function Gl(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
|
|
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
|
|
113
|
+
`:""}function In(e){return e.entries.some(t=>t.stage>0)?{stdout:Gl(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 Ll(e,t,n,r);let o=await K(e),s=t.map(i=>Ge(i,n)),a=o.entries.filter(i=>i.stage===0&&be(s,i.path));if(a.length===0)return o.entries.some(c=>c.stage>0&&be(s,c.path))?N(`error: path '${t[0]}' is unmerged
|
|
115
115
|
`):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
116
|
-
`);for(let i of a)await it(e,{path:i.path,hash:i.hash,mode:i.mode});return{stdout:"",stderr:"",exitCode:0}}async function
|
|
116
|
+
`);for(let i of a)await it(e,{path:i.path,hash:i.hash,mode:i.mode});return{stdout:"",stderr:"",exitCode:0}}async function Ll(e,t,n,r){let o=await ce(e,r),s=await K(e),a=t.map(c=>Ge(c,n)),i=[];for(let[c]of o)be(a,c)&&i.push(c);if(i.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
117
117
|
`);for(let c of i){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,a=await K(e),i=t.map(f=>Ge(f,n)),c=new Set;for(let f of a.entries)be(i,f.path)&&c.add(f.path);if(c.size===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
118
118
|
`);for(let f of c){let d=a.entries.find(m=>m.path===f&&m.stage===r),l=!d&&a.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(a.entries.some(h=>h.path===f&&h.stage>0))return N(`error: path '${f}' does not have ${r===2?"our":"their"} version
|
|
119
|
-
`)}return{stdout:"",stderr:"",exitCode:0}}async function
|
|
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 a=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);a.set(c,await bt("blob",l))}}else a.set(c,null)}let i=[];for(let[c,f]of o){let d=s.get(c);if(d===void 0){i.push(`D ${c}`);continue}let l=a.get(c);l===null?i.push(`D ${c}`):(d!==f||l!==void 0&&l!==f)&&i.push(`M ${c}`)}for(let[c]of s)o.has(c)||a.get(c)!=null&&i.push(`A ${c}`);return i.length===0?"":(i.sort((c,f)=>{let d=c.slice(2),l=f.slice(2);return d<l?-1:d>l?1:0}),`${i.join(`
|
|
120
120
|
`)}
|
|
121
|
-
`)}var rc=5;function
|
|
121
|
+
`)}var rc=5;function _l(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>rc?rc-1:t,a=e.slice(0,o).map(c=>` ${V(c.hash)} ${c.subject}`),i=t-o;return i>0&&a.push(` ... and ${i} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
|
|
122
122
|
any of your branches:
|
|
123
123
|
|
|
124
124
|
${a.join(`
|
|
@@ -129,10 +129,10 @@ to do so with:
|
|
|
129
129
|
|
|
130
130
|
git branch <new-branch-name> ${V(e[0].hash)}
|
|
131
131
|
|
|
132
|
-
`}async function
|
|
133
|
-
`}async function Bs(e,t,n){let r=await
|
|
134
|
-
`,exitCode:0};let i=await K(e),c
|
|
135
|
-
${p}`,exitCode:0}}async function
|
|
132
|
+
`}async function ei(e,t){let n=await M(e,t);return`Previous HEAD position was ${V(t)} ${ae(n.message)}
|
|
133
|
+
`}async function Bs(e,t,n){let r=await zo(e,t,{targetHash:n});return r.length>0?_l(r):t!==n?ei(e,t):""}async function dr(e,t,n,r,o,s){let a=await Z(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
|
|
134
|
+
`,exitCode:0};let i=await K(e),c=In(i);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,i);if(!x.success)return x.errorOutput??N("error: checkout would overwrite local changes");i={version:2,entries:x.newEntries},await se(e,i),await Se(e,x.worktreeOps)}let m="";a?.type==="direct"&&f&&(m=await Bs(e,f,r));let h=a?.type==="symbolic"?a.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,i),w=await le(e),y=await dn(e,w,t);return y&&(g+=Vn(y)),{stdout:g,stderr:`${m}Switched to branch '${t}'
|
|
135
|
+
${p}`,exitCode:0}}async function $n(e,t,n,r,o){let s=await K(e),a=In(s);if(a)return a;let i=await X(e),c=await M(e,t),f=c.tree,d=null;if(i&&(d=(await M(e,i)).tree),d!==f){let x=await Cn(e,d,f,s);if(!x.success)return x.errorOutput??N("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await se(e,s),await Se(e,x.worktreeOps)}let l=await Z(e),u=l?.type==="direct"&&i===t;if(await Y(e,"HEAD",t),!u){await Ua(e,t);let x=l?.type==="symbolic"?l.target.replace(/^refs\/heads\//,""):i??J;await ne(e,n,"HEAD",i,t,`checkout: moving from ${x} to ${t}`)}let m=await ln(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:i,newHead:t,isBranchCheckout:!1});let h=V(t),p=ae(c.message),g=l?.type==="direct",w="";return g&&i&&i!==t&&(w+=await Bs(e,i,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,91 +151,91 @@ 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
|
|
155
|
-
`,stderr:"",exitCode:1};async function
|
|
156
|
-
`,exitCode:1};let a=r.rest??[],i=await B(o.fs,o.cwd,t);return v(i)?i:
|
|
154
|
+
`,w+=m,{stdout:await Yn(e,f,s),stderr:w,exitCode:0}}ie();de();ue();on();var sc=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),Wr={stdout:`You need to start by "git bisect start"
|
|
155
|
+
`,stderr:"",exitCode:1};async function ti(e){let t=await Ee(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||$("no current commit")}function oc(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[q.string().name("subcommand").describe("Subcommand or custom term").optional(),q.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 a=r.rest??[],i=await B(o.fs,o.cwd,t);return v(i)?i:Bl(i,o.env,t,s,a)}});Nl(n,t),Fl(n,t),Wl(n,t),ql(n,t),zl(n,t),Vl(n,t),Xl(n,t),Jl(n,t),Ql(n,t)}function Nl(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":ee.string().describe("Alternate term for new/bad"),"term-bad":ee.string().describe("Alternate term for new/bad"),"term-old":ee.string().describe("Alternate term for old/good"),"term-good":ee.string().describe("Alternate term for old/good"),"no-checkout":H().describe("Do not checkout the bisection commit"),"first-parent":H().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,a=Ke(s);if(a&&!n["no-checkout"])return a;let i=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return sc.has(i)?$(`'${i}' is not a valid term`):sc.has(c)?$(`'${c}' is not a valid term`):i===c?$("'bad' and 'good' terms must be different"):ic(s,r.env,t,n.revs??[],i,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function ic(e,t,n,r,o,s,a,i){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
|
-
`),i&&await Oe(e,"BISECT_FIRST_PARENT",""),a){let u=await X(e);u&&await Oe(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await Tt(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 Tt(e,g);if(v(w))return w;await Y(e,`refs/bisect/${s}-${w}`,w);let y=await M(e,w);await kt(e,`# ${s}: [${w}] ${ae(y.message)}`)}}let d=r.map(u=>`'${u}'`),l=d.length>0?` ${d.join(" ")}`:"";return await kt(e,`git bisect start${l}`),qr(e,t,n)}function
|
|
161
|
-
`,exitCode:1}:Br(e,t,n,r,s,o[0])}async function Br(e,t,n,r,o,s){let a;if(s){let f=await Tt(e,s);if(v(f))return f;a=f}else{let f=await
|
|
162
|
-
`,stderr:"",exitCode:0}}})}async function
|
|
163
|
-
`,exitCode:1}}})}function
|
|
164
|
-
`)){let i=a.trim();if(!i||i.startsWith("#"))continue;let c=i.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 ic(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")l=await Br(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")l=await Br(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 qr(e,t,n)}else continue;if(l.exitCode!==0)return l;s+=l.stdout}return{stdout:s,stderr:"",exitCode:0}}function
|
|
165
|
-
`;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await
|
|
160
|
+
`),i&&await Oe(e,"BISECT_FIRST_PARENT",""),a){let u=await X(e);u&&await Oe(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await Tt(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 Tt(e,g);if(v(w))return w;await Y(e,`refs/bisect/${s}-${w}`,w);let y=await M(e,w);await kt(e,`# ${s}: [${w}] ${ae(y.message)}`)}}let d=r.map(u=>`'${u}'`),l=d.length>0?` ${d.join(" ")}`:"";return await kt(e,`git bisect start${l}`),qr(e,t,n)}function Fl(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:[q.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:Ul(s,o.env,t,n,r.rev)}})}async function Ul(e,t,n,r,o){if(!await Et(e))return Wr;let s=await Ur(e),a=r==="bad"||r==="new"?s.termBad:s.termGood;return Br(e,t,n,a,s,o)}async function Bl(e,t,n,r,o){if(!await Et(e))return Wr;let s=await Ur(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
|
|
161
|
+
`,exitCode:1}:Br(e,t,n,r,s,o[0])}async function Br(e,t,n,r,o,s){let a;if(s){let f=await Tt(e,s);if(v(f))return f;a=f}else{let f=await ti(e);if(v(f))return f;a=f}let i=await M(e,a),c=ae(i.message);return r===o.termBad?await Y(e,`refs/bisect/${o.termBad}`,a):await Y(e,`refs/bisect/${o.termGood}-${a}`,a),await kt(e,`# ${r}: [${a}] ${c}`),await kt(e,`git bisect ${r} ${a}`),qr(e,t,n)}function Wl(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[q.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 Wr;let a=n.revs??[];if(a.length===0){let i=await ti(s);if(v(i))return i;a.push(i)}for(let i of a){let c;if(i.length===40&&/^[0-9a-f]+$/.test(i))c=i;else{let d=await Tt(s,i);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 qr(s,r.env,t)}})}function ql(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[q.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)?Kl(s,r.env,t,n.commit):{stdout:`We are not bisecting.
|
|
162
|
+
`,stderr:"",exitCode:0}}})}async function Kl(e,t,n,r){let o=(await Ee(e,"BISECT_START"))?.trim()??"";if(await Ms(e),r){let s=await Tt(e,r);return v(s)?s:$n(e,s,t,n)}if(o){let s=`refs/heads/${o}`,a=await U(e,s);if(a)return dr(e,o,s,a,t,n);let i=await We(e,o);if(i)return $n(e,i,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 Ee(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
|
|
163
|
+
`,exitCode:1}}})}function Vl(e,t){e.command("replay",{description:"Replay a bisect log",args:[q.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,a=n.logfile.startsWith("/")?n.logfile:T(r.cwd,n.logfile);if(!await r.fs.exists(a))return $(`cannot open '${n.logfile}': No such file or directory`);let i=await r.fs.readFile(a);return Yl(s,r.env,t,i)}})}async function Yl(e,t,n,r){await Et(e)&&await Ms(e);let o={termBad:"bad",termGood:"good"},s="";for(let a of r.split(`
|
|
164
|
+
`)){let i=a.trim();if(!i||i.startsWith("#"))continue;let c=i.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 ic(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")l=await Br(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")l=await Br(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 qr(e,t,n)}else continue;if(l.exitCode!==0)return l;s+=l.stdout}return{stdout:s,stderr:"",exitCode:0}}function Xl(e,t){e.command("run",{description:"Bisect by running a command",args:[q.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 Wr;if(!r.exec)return $("bisect run requires shell execution support");let a=n.cmd.join(" ");return Zl(s,r.env,t,a,r.exec,r.cwd)}})}async function Zl(e,t,n,r,o,s){let a="";for(;;){a+=`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 qr(e,t,n);if(a+=h.stdout,h.stdout.includes("is the first bad commit"))return a+=`bisect found first bad commit
|
|
166
166
|
`,{stdout:a,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:a,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Ds(e),d=c===0?f.termGood:f.termBad,l=await Br(e,t,n,d,f,void 0);if(a+=l.stdout,l.stdout.includes("is the first bad commit"))return a+=`bisect found first bad commit
|
|
167
|
-
`,{stdout:a,stderr:"",exitCode:0};if(l.exitCode!==0)return{stdout:a,stderr:l.stderr,exitCode:l.exitCode}}}function
|
|
167
|
+
`,{stdout:a,stderr:"",exitCode:0};if(l.exitCode!==0)return{stdout:a,stderr:l.stderr,exitCode:l.exitCode}}}function Jl(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":H().describe("Show the term for the old state"),"term-bad":H().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:a,termGood:i}=await Ur(s);return n["term-good"]?{stdout:`${i}
|
|
169
169
|
`,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${a}
|
|
170
170
|
`,stderr:"",exitCode:0}:{stdout:`Your current terms are ${i} for the old state
|
|
171
171
|
and ${a} for the new state.
|
|
172
|
-
`,stderr:"",exitCode:0}}})}function
|
|
173
|
-
`,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(
|
|
174
|
-
`;return{stdout:f,stderr:"",exitCode:0}}})}async function qr(e,t,n){let r=await Ds(e);return!r.badHash||r.goodHashes.length===0?{stdout:Wa(r),stderr:"",exitCode:0}:(await Oe(e,"BISECT_ANCESTORS_OK",""),
|
|
172
|
+
`,stderr:"",exitCode:0}}})}function Ql(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 a=s;if(!await Et(a))return Wr;let i=await Ds(a);if(!i.badHash||i.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(),Fa)),f="";for await(let d of c(a,i.badHash,{exclude:i.goodHashes}))f+=`${V(d.hash)} ${ae(d.commit.message)}
|
|
174
|
+
`;return{stdout:f,stderr:"",exitCode:0}}})}async function qr(e,t,n){let r=await Ds(e);return!r.badHash||r.goodHashes.length===0?{stdout:Wa(r),stderr:"",exitCode:0}:(await Oe(e,"BISECT_ANCESTORS_OK",""),eu(e,t,n,r))}async function eu(e,t,n,r){let o=await Ba(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
|
|
175
175
|
`,exitCode:1};if(o.found){let s=await Ka(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 a of r.skipHashes)s+=a+`
|
|
178
178
|
`;return r.badHash&&(s+=r.badHash+`
|
|
179
179
|
`),s+=`We cannot bisect more!
|
|
180
|
-
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Oe(e,"BISECT_HEAD",o.hash);else{let s=await
|
|
180
|
+
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Oe(e,"BISECT_HEAD",o.hash);else{let s=await $n(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Oe(e,"BISECT_EXPECTED_REV",o.hash+`
|
|
181
181
|
`),{stdout:qa(o),stderr:"",exitCode:0}}re();ie();function Mt(e){if(e.length===0)return[];let t=e.split(`
|
|
182
182
|
`);return t[t.length-1]===""&&t.pop(),t}function Wt(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
|
|
183
|
+
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var tu=4,ac=1024,Ws=100,zs=0,qs=1,lr=2;function ri(e){let t=1;for(;t*t<e;)t++;return t}function nu(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let a=0;a<e.length;a++){let i=e[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len1++,o[a]=c}for(let a=0;a<t.length;a++){let i=t[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len2++,s[a]=c}return{classes1:o,classes2:s,classInfo:r}}function ru(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let a=o,i=0,c=s-a;for(;i<c&&e[t-1-i]===n[r-1-i];)i++;return{dstart:a,dend1:t-i-1,dend2:r-i-1}}function cc(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===lr)s++;else break}if(o===0)return!1;let a=0,i=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===zs)a++;else if(f===lr)i++;else break}return a===0?!1:(a+=o,i+=s,i*tu<i+a)}function su(e,t,n,r,o,s,a,i,c,f){let d=new Uint8Array(t),l=new Uint8Array(r),u=Math.min(ri(t),ac);for(let g=s;g<=a;g++){let w=o[e[g]].len2;w===0?d[g]=zs:w>=u?d[g]=lr:d[g]=qs}let m=Math.min(ri(r),ac);for(let g=s;g<=i;g++){let w=o[n[g]].len1;w===0?l[g]=zs:w>=m?l[g]=lr:l[g]=qs}let h=[];for(let g=s;g<=a;g++)d[g]===qs||d[g]===lr&&!cc(d,g,s,a)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=i;g++)l[g]===qs||l[g]===lr&&!cc(l,g,s,i)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Tn=20,fc=4,ou=256,iu=256,Ks=2147483647;function pt(e,t){return e[t]??0}function au(e,t,n,r,o,s,a,i,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,y=m;a[u]=t,i[m]=n;for(let x=1;;x++){let b=!1;p>d?a[--p-1]=-1:++p,g<l?a[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let R;pt(a,k-1)>=pt(a,k+1)?R=pt(a,k-1)+1:R=pt(a,k+1);let C=R,P=R-k;for(;R<n&&P<s&&e[R]===r[P];)R++,P++;if(R-C>Tn&&(b=!0),a[k]=R,h&&w<=k&&k<=y&&pt(i,k)<=R)return{i1:R,i2:P,minLo:!0,minHi:!0}}w>d?i[--w-1]=Ks:++w,y<l?i[++y+1]=Ks:--y;for(let k=y;k>=w;k-=2){let R;pt(i,k-1)<pt(i,k+1)?R=pt(i,k-1):R=pt(i,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>Tn&&(b=!0),i[k]=R,!h&&p<=k&&k<=g&&R<=pt(a,k))return{i1:R,i2:P,minLo:!0,minHi:!0}}if(!c){if(b&&x>ou){let k=0,R=null;for(let C=g;C>=p;C-=2){let P=C>u?C-u:u-C,E=pt(a,C),O=E-C,I=E-t+(O-o)-P;if(I>fc*x&&I>k&&t+Tn<=E&&E<n&&o+Tn<=O&&O<s){let j=!0;for(let G=1;G<=Tn;G++)if(e[E-G]!==r[O-G]){j=!1;break}j&&(k=I,R={i1:E,i2:O,minLo:!0,minHi:!1})}}if(R)return R;k=0,R=null;for(let C=y;C>=w;C-=2){let P=C>m?C-m:m-C,E=pt(i,C),O=E-C,I=n-E+(s-O)-P;if(I>fc*x&&I>k&&t<E&&E<=n-Tn&&o<O&&O<=s-Tn){let j=!0;for(let G=0;G<Tn;G++)if(e[E+G]!==r[O+G]){j=!1;break}j&&(k=I,R={i1:E,i2:O,minLo:!1,minHi:!0})}}if(R)return R}if(x>=f){let k=-1,R=-1;for(let E=g;E>=p;E-=2){let O=Math.min(pt(a,E),n),I=O-E;s<I&&(O=s+E,I=s),k<O+I&&(k=O+I,R=O)}let C=Ks,P=Ks;for(let E=y;E>=w;E-=2){let O=Math.max(t,pt(i,E)),I=O-E;I<o&&(O=o+E,I=o),O+I<C&&(C=O+I,P=O)}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,a,i,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++)i[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)a[c[h]]=1;else{let h=au(e,t,n,r,o,s,d,l,u,m);si(e,t,h.i1,r,o,h.i2,a,i,c,f,d,l,h.minLo,m),si(e,h.i1,n,r,h.i2,s,a,i,c,f,d,l,h.minHi,m)}}function cu(e,t,n,r){let o=[],s=0,a=0,i=1,c=1;for(;s<e.length||a<t.length;){if(s<e.length&&a<t.length&&!n[s]&&!r[a]){o.push({type:"keep",line:e[s]??"",oldLineNo:i++,newLineNo:c++}),s++,a++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:i++,newLineNo:0}),s++;for(;a<t.length&&r[a];)o.push({type:"insert",line:t[a]??"",oldLineNo:0,newLineNo:c++}),a++}return o}var dc=200,lc=20,uc=100,fu=1,du=21,lu=-30,uu=6,mu=-4,hu=10,pu=24,gu=17,wu=23,bu=17,yu=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>=dc)return dc}return-1}function mc(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===lc){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===lc){r.postIndent=0;break}return r}function hc(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=fu),e.endOfFile&&(t.penalty+=du);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=lu*r,t.penalty+=uu*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?hu:mu:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?gu:pu:t.penalty+=s?bu:wu))}function Eu(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return yu*n+(e.penalty-t.penalty)}function pc(e,t,n,r,o,s){let a=0,i=0;for(;e[i];)i++;let c=0,f=0;for(;o[f];)f++;let d=(l,u)=>t[l]===t[u];for(;;){if(i!==a){let l,u,m;do{for(l=i-a,u=-1;a>0&&d(a-1,i-1);){for(e[--a]=1,e[--i]=0;e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=i,f>c&&(u=i);!(i>=r||!d(a,i));){for(e[a++]=0,e[i++]=1;e[i];)i++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=i)}}while(l!==i-a);if(i!==m)if(u!==-1)for(;f===c;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(i-l-1>g&&(g=i-l-1),i-uc>g&&(g=i-uc);g<=i;g++){let w={effectiveIndent:0,penalty:0},y=mc(n,r,g);hc(y,w);let x=mc(n,r,g-l);hc(x,w),(h===-1||Eu(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;i>h;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}}}if(i>=r)break;for(a=i+1,i=a;e[i];i++);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:a,classes2:i,classInfo:c}=nu(e,t),{dstart:f,dend1:d,dend2:l}=ru(a,n,i,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}=su(a,n,i,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]=a[u[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=i[h[R]];let y={},x={},b=m+p+3,k=Math.max(iu,ri(b));si(g,0,m,w,0,p,o,s,u,h,y,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;pc(o,a,e,n,s,r),pc(s,i,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((a,i)=>({type:"insert",line:a,oldLineNo:0,newLineNo:i+1}));if(r===0)return e.map((a,i)=>({type:"delete",line:a,oldLineNo:i+1,newLineNo:0}));let{changedOld:o,changedNew:s}=oi(e,t);return cu(e,t,o,s)}var ku=3;function Ru(e,t=ku){if(e.length===0)return[];let n=[];for(let i=0;i<e.length;i++){let c=e[i];c&&c.type!=="keep"&&n.push(i)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),a=Math.min(e.length-1,r+t);for(let i=1;i<n.length;i++){let c=n[i]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=a+1||(o.push({start:s,end:a}),s=f),a=d}return o.push({start:s,end:a}),o.map(i=>xu(e,i.start,i.end))}function xu(e,t,n){let r=0,o=0,s=0,a=0,i=[],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++,a++,i.push({type:"context",content:l.line});break;case"delete":c||(r=l.oldLineNo,c=!0),o++,i.push({type:"delete",content:l.line});break;case"insert":f||(s=l.newLineNo,f=!0),a++,i.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(a===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:a,lines:i}}function Vs(e){return e?e.length<40?e:V(e):"0000000"}function gc(e,t,n,r,o,s){let{path:a,oldMode:i,newMode:c}=t;e.push(`diff --git a/${a} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${a}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${i||"100644"}`):i&&c&&i!==c&&(e.push(`old mode ${i}`),e.push(`new mode ${c}`))}function Cu(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:a,oldHash:i,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(gc(m,e,d,l,u,f),o!==s){if(i||c){let h=Vs(i),p=Vs(c);l||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${a||"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:a,newHash:i}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Te(n),l=Te(r);if(d||l)return
|
|
185
|
+
`}function Rt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:a,newHash:i}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Te(n),l=Te(r);if(d||l)return Cu(e,d,l);let u=Mt(n),m=Mt(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 y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let
|
|
187
|
+
`),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let x=ft(w,y);if(!h||!p)for(let I of x)I.line.includes(g)&&(I.line=I.line.replace(g,""));let b=Ru(x);if(b.length===0&&!c)return"";let k=e.isNew??n==="",R=e.isDeleted??r==="",C=[];if(gc(C,e,f,k,R,c),b.length===0)return`${C.join(`
|
|
188
188
|
`)}
|
|
189
|
-
`;if(a||i){let I=Vs(a),
|
|
189
|
+
`;if(a||i){let I=Vs(a),j=Vs(i);k||R?C.push(`index ${I}..${j}`):c?C.push(`index ${I}..${j} ${o||"100644"}`):o&&s&&o!==s?C.push(`index ${I}..${j}`):C.push(`index ${I}..${j} ${o||"100644"}`)}let P=I=>I.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 E=u.length,O=m.length;for(let I of b){let j=I.oldCount===1?`${I.oldStart}`:`${I.oldStart},${I.oldCount}`,G=I.newCount===1?`${I.newStart}`:`${I.newStart},${I.newCount}`,z="";for(let L=I.oldStart-2;L>=0;L--){let _=u[L];if(_&&/^[a-zA-Z$_]/.test(_)){z=` ${_.trimEnd().slice(0,79)}`;break}}C.push(`@@ -${j} +${G} @@${z}`);let A=I.oldStart,S=I.newStart;for(let L of I.lines)switch(L.type){case"context":C.push(` ${L.content}`),(!h&&A===E||!p&&S===O)&&C.push("\"),A++,S++;break;case"delete":C.push(`-${L.content}`),!h&&A===E&&C.push("\"),A++;break;case"insert":C.push(`+${L.content}`),!p&&S===O&&C.push("\"),S++;break}}return`${C.join(`
|
|
190
190
|
`)}
|
|
191
|
-
`}ie();He();async function
|
|
192
|
-
`)[0],boundary:a,previous:i}}re();ie();He();ie();de();function
|
|
191
|
+
`}ie();He();async function Hn(e,t,n){return(await ce(e,t)).get(n)?.hash??null}async function wc(e,t,n,r){let o=await Ne(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:a}=await tt(e,o);return a.find(c=>c.newPath===r)?.oldPath??null}async function Pu(e,t,n,r,o,s){let a=await Hn(e,(await M(e,t)).tree,n);if(!a){let p=new Map,g=await M(e,t);for(let w of r)p.set(w.finalIdx,Sn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let i=await oe(e,a),c=Mt(i),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 E of d)f[E.finalIdx]=Sn(l,u,E.currentLine,s+E.finalIdx,o[E.finalIdx],p,!0,void 0);break}let g=await Hn(e,p.tree,u),w=null,y=[];for(let E of p.parents){let O=await M(e,E),I=u,j=await Hn(e,O.tree,I);if(!j){let G=await wc(e,O.tree,p.tree,u);G&&(I=G,j=await Hn(e,O.tree,I))}if(j&&(y.push({hash:E,path:I,blobHash:j}),j===g)){w={hash:E,path:I};break}}if(w){l=w.hash,u=w.path;continue}if(y.length===0){for(let E of d)f[E.finalIdx]=Sn(l,u,E.currentLine,s+E.finalIdx,o[E.finalIdx],p,!1,void 0);break}let x=y[0],b=await oe(e,x.blobHash),k=Mt(b),R=ft(k,m),C=new Map;for(let E of R)E.type==="keep"&&C.set(E.newLineNo,E.oldLineNo);let P=[];for(let E of d){let O=C.get(E.currentLine);O!==void 0?P.push({finalIdx:E.finalIdx,currentLine:O}):f[E.finalIdx]=Sn(l,u,E.currentLine,s+E.finalIdx,o[E.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 bc(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 a=await oe(e,s),i=Mt(a),c=r?.startLine??1,f=r?.endLine??i.length,d=i.slice(c-1,f),l=new Array(d.length),u=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=i;for(;u.length>0;){let g=await M(e,m);if(g.parents.length===0){for(let C of u)l[C.finalIdx]=Sn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await Hn(e,g.tree,h),y=[],x=null;for(let C of g.parents){let P=await M(e,C),E=h,O=await Hn(e,P.tree,E);if(!O){let I=await wc(e,P.tree,g.tree,h);I&&(E=I,O=await Hn(e,P.tree,E))}if(O){let I={hash:C,path:E,blobHash:O};if(y.push(I),O===w){x=I;break}}}if(x){m=x.hash,h=x.path;continue}if(y.length===0){for(let C of u)l[C.finalIdx]=Sn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(y.length===1){let C=y[0],P=await oe(e,C.blobHash),E=Mt(P),O=ft(E,p),I=new Map;for(let G of O)G.type==="keep"&&I.set(G.newLineNo,G.oldLineNo);let j=[];for(let G of u){let z=I.get(G.currentLine);z!==void 0?j.push({finalIdx:G.finalIdx,currentLine:z}):l[G.finalIdx]=Sn(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=E;continue}let b=[];for(let C of y){let P=await oe(e,C.blobHash),E=Mt(P),O=ft(E,p),I=new Map;for(let j of O)j.type==="keep"&&I.set(j.newLineNo,j.oldLineNo);b.push({info:C,newToOld:I})}let k=new Map;for(let C of u){let P=!1;for(let E=0;E<b.length;E++){let O=b[E],I=O.newToOld.get(C.currentLine);if(I!==void 0){let j=k.get(E);j||(j={info:O.info,lines:[]},k.set(E,j)),j.lines.push({finalIdx:C.finalIdx,currentLine:I}),P=!0;break}}P||(l[C.finalIdx]=Sn(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:y[0].hash,path:y[0].path}))}let R=k.get(0);for(let[C,P]of k){if(C===0)continue;let E=await Pu(e,P.info.hash,P.info.path,P.lines,d,c);for(let[O,I]of E)l[O]=I}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=Mt(C)}else break}return l}function Sn(e,t,n,r,o,s,a,i){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
|
|
192
|
+
`)[0],boundary:a,previous:i}}re();ie();He();ie();de();function Ou(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 Iu(e,t){let n=Ou(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),a=r.getUTCDate().toString().padStart(2,"0"),i=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${a} ${i}:${c}:${f} ${t}`}function $u(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(l=>l.finalLine)),a=String(s).length,i=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(i)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=i?` ${l.origPath.padEnd(f)}`:"";if(o)d.push(`${u}${m} ${String(l.finalLine).padStart(a)}) ${l.content}`);else{let h=r?`<${l.author.email}>`:l.author.name,p=Iu(l.author.timestamp,l.author.timezone);d.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(l.finalLine).padStart(a)}) ${l.content}`)}}return`${d.join(`
|
|
193
193
|
`)}
|
|
194
|
-
`}function
|
|
194
|
+
`}function Tu(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
|
|
196
|
+
`}function Hu(e,t,n){if(e.startsWith("/"))return at(n,e);let r=at(n,t);return r===""||r==="."?e:`${r}/${e}`}function yc(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[q.string().name("args").variadic().optional()],options:{lineRange:ee.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:H().alias("l").describe("Show long revision"),showEmail:H().alias("e").describe("Show author email instead of name"),suppress:H().alias("s").describe("Suppress author name and date"),porcelain:H().alias("p").describe("Show in machine-readable format"),linePorcelain:H().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 a=s;if(!a.workTree)return $("this operation must be run in a work tree");let i=await ze(a);if(v(i))return i;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=Hu(l,r.cwd,a.workTree),m;if(d){let R=await Tt(a,d);if(v(R))return R;m=await _e(a,R)}else m=i;let h=await M(a,m),p=await ce(a,h.tree);if(!p.has(u))return $(`no such path ${u} in ${d??"HEAD"}`);let g=p.get(u).hash,w=await oe(a,g);if(Te(w))return $(`cannot blame binary file '${u}'`);let y,x;if(n.lineRange){let R=n.lineRange,C=R.match(/^(\d+),(\d+)$/);if(C)y=parseInt(C[1],10),x=parseInt(C[2],10);else return $(`invalid -L range: '${R}'`)}let b;try{b=await bc(a,m,u,{startLine:y,endLine:x})}catch(R){let C=R instanceof Error?R.message:String(R);return $(C)}let k;return n.porcelain||n.linePorcelain?k=Tu(b,!!n.linePorcelain):k=$u(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}re();Ve();hn();re();var Su=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],vu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function jt(e,t){let n=Au(t),r=new Date((e+n*60)*1e3),o=Su[r.getUTCDay()],s=vu[r.getUTCMonth()],a=r.getUTCDate(),i=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} ${a} ${i}:${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 Au(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();He();var Ys=new TextDecoder;function Ec(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 ur(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 Kr(e,t,n){let r=[],o=[],s=[];for(let i of t)if(i.status==="added"&&i.newHash&&i.newMode){let c=await yt(e,i.newHash);
|
|
198
|
+
`&&t++,t}function ur(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 Kr(e,t,n){let r=[],o=[],s=[];for(let i of t)if(i.status==="added"&&i.newHash&&i.newMode){let c=await yt(e,i.newHash);wn(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:i.path,sortKey:i.path,insertions:Ec(Ys.decode(c)),deletions:0}),o.push({path:i.path,mode:i.newMode})}else if(i.status==="deleted"&&i.oldHash&&i.oldMode){let c=await yt(e,i.oldHash);wn(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:i.path,sortKey:i.path,insertions:0,deletions:Ec(Ys.decode(c))}),s.push({path:i.path,mode:i.oldMode})}else if(i.status==="modified"&&i.oldHash&&i.newHash){let c=await yt(e,i.oldHash),f=await yt(e,i.newHash);if(wn(c)||wn(f))r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=Wt(Ys.decode(c)),l=Wt(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:i.path,sortKey:i.path,insertions:m,deletions:h})}i.oldMode&&i.newMode&&i.oldMode!==i.newMode&&(s.push({path:i.path,mode:i.oldMode}),o.push({path:i.path,mode:i.newMode}))}for(let i of n){let c=On(i.oldPath,i.newPath),f=0,d=0;if(i.similarity<100&&i.oldHash&&i.newHash){let l=await oe(e,i.oldHash),u=await oe(e,i.newHash);if(!Te(l)&&!Te(u)){let m=Wt(l),h=Wt(u),p=ft(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:i.newPath,insertions:f,deletions:d})}let a=[];for(let{path:i,mode:c}of o)a.push({sortKey:i,text:` create mode ${c} ${i}`});for(let{path:i,mode:c}of s)a.push({sortKey:i,text:` delete mode ${c} ${i}`});for(let i of n){let c=On(i.oldPath,i.newPath);a.push({sortKey:i.newPath,text:` rename ${c} (${i.similarity}%)`})}return a.sort((i,c)=>i.sortKey<c.sortKey?-1:i.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:a.map(i=>i.text)}}async function tn(e,t,n,r,o,s=!1,a=!1){let i=[];if((r.name!==o.name||r.email!==o.email)&&i.push(` Author: ${r.name} <${r.email}>`),s&&i.push(` Date: ${jt(r.timestamp,r.timezone)}`),a)return i.join(`
|
|
199
199
|
`)+(i.length>0?`
|
|
200
200
|
`:"");let c=await Ne(e,t,n),{remaining:f,renames:d}=await tt(e,c),{fileStats:l,modeLines:u}=await Kr(e,f,d),m=0,h=0;for(let g of l)m+=g.insertions,h+=g.deletions;let p=ur(l.length,m,h);p&&i.push(p);for(let g of u)i.push(g);return i.join(`
|
|
201
201
|
`)+(i.length>0?`
|
|
202
|
-
`:"")}var Xs=80;function
|
|
202
|
+
`:"")}var Xs=80;function Du(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 zr(e){if(e.length===0)return"";let t=e.filter(h=>!h.isUnmerged),n=t.length>0?Math.max(...t.map(h=>h.insertions+h.deletions)):0,r=e.some(h=>h.isBinary),o=n>0?String(n).length:1;r&&o<3&&(o=3);let s=Math.max(...e.map(h=>h.path.length)),a=n,i=s;if(i+o+6+a>Xs){let h=Math.floor(Xs*3/8)-o-6;a>h&&(a=Math.max(h,6));let p=Xs-o-6-a;i>p?i=p:a=Xs-o-6-i}for(let h of e)h.path=Du(h.path,i);let c=i,f=[],d=0,l=0,u=0;for(let h of e){let p=h.path.padEnd(c);if(h.isUnmerged){f.push(` ${p} | Unmerged`);continue}if(u++,d+=h.insertions,l+=h.deletions,h.isBinary){let C=`${"Bin".padStart(o)} ${h.oldSize??0} -> ${h.newSize??0} bytes`;f.push(` ${p} | ${C}`);continue}let g=h.insertions+h.deletions,w=String(g).padStart(o),y,x;if(n<=a)y=h.insertions,x=h.deletions;else{let R=E=>E===0?0:1+Math.floor(E*(a-1)/n),C=R(g),P=C<2&&h.insertions>0&&h.deletions>0?2:C;h.insertions<h.deletions?(y=R(h.insertions),x=P-y):(x=R(h.deletions),y=P-x)}let b="+".repeat(y)+"-".repeat(x),k=b?` ${b}`:"";f.push(` ${p} | ${w}${k}`)}let m=ur(u,d,l);return m?f.push(m):e.some(h=>h.isUnmerged)&&f.push(" 0 files changed"),`${f.join(`
|
|
203
203
|
`)}
|
|
204
|
-
`}async function
|
|
205
|
-
`;return c}
|
|
204
|
+
`}async function vn(e,t,n){let r=await Ne(e,t,n),{remaining:o,renames:s}=await tt(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:a,modeLines:i}=await Kr(e,o,s);a.sort((f,d)=>f.sortKey<d.sortKey?-1:f.sortKey>d.sortKey?1:0);let c=zr(a);for(let f of i)c+=`${f}
|
|
205
|
+
`;return c}Ve();ke();ie();ue();Jt();async function Mu(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 a=await M(e,s);for(let i of a.parents)n.has(i)||r.push(i)}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 a=o[s++];if(a===t)return!0;if(r.has(a))continue;r.add(a);let i=await M(e,a);for(let c of i.parents)r.has(c)||o.push(c)}return!1}async function Gt(e,t,n){if(t===n)return[t];let r=await Mu(e,t),o=[],s=new Set,a=[n],i=0;for(;i<a.length;){let f=a[i++];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)||a.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:ju(e,t,n,c)}async function ju(e,t,n,r){let o=new Set(r),s=new Set,a=[],i=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 y=1;y<d.length;y++){let x=d[y],b=await l(x.hash),k=d[u];(b>m||b===m&&x.seq<k.seq)&&(u=y,m=b)}let h=d.splice(u,1)[0],p=i.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(i.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(a.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await M(e,h.hash);for(let y of w.parents)d.push({hash:y,mask:g,seq:f++})}for(let u of r)s.has(u)||a.push(u);return a}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 Zs(e,t,n){let r=await M(e,t),o=await M(e,n),s=V(t),a=V(n),i=`Updating ${s}..${a}
|
|
208
|
-
`;if(e.workTree){let f=await K(e),d=await Ga(e,r.tree,o.tree,f);if(!d.success){let l=d.errorOutput;return{stdout:i+l.stdout,stderr:l.stderr,exitCode:l.exitCode}}await se(e,{version:2,entries:d.newEntries}),await Se(e,d.worktreeOps)}await
|
|
209
|
-
${c}`,stderr:"",exitCode:0}}ie();je();
|
|
210
|
-
`);let y=`refs/heads/${n.name}`,
|
|
211
|
-
`);let b="";if(!f){let
|
|
212
|
-
'${
|
|
208
|
+
`;if(e.workTree){let f=await K(e),d=await Ga(e,r.tree,o.tree,f);if(!d.success){let l=d.errorOutput;return{stdout:i+l.stdout,stderr:l.stderr,exitCode:l.exitCode}}await se(e,{version:2,entries:d.newEntries}),await Se(e,d.worktreeOps)}await yn(e,n);let c=await vn(e,r.tree,o.tree);return{stdout:`${i}Fast-forward
|
|
209
|
+
${c}`,stderr:"",exitCode:0}}ie();je();ue();function kc(e,t){e.command("branch",{description:"List, create, or delete branches",args:[q.string().name("name").describe("Branch name").optional(),q.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:H().alias("d").describe("Delete a branch"),forceDelete:H().alias("D").describe("Force delete a branch"),move:H().alias("m").describe("Rename a branch"),forceMove:H().alias("M").describe("Force rename a branch"),remotes:H().alias("r").describe("List remote-tracking branches"),all:H().alias("a").describe("List all branches"),setUpstreamTo:ee.string().alias("u").describe("Set upstream tracking branch"),verbose:H().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,a=await Z(s),i=a?.type==="symbolic"?we(a.target):null,c=!!n.forceMove;if(n.move||c){let w,y;if(n.newName)w=n.name,y=n.newName;else if(n.name){if(!i)return $("not on any branch");w=i,y=n.name}else return $("branch name required");let x=`refs/heads/${w}`,b=`refs/heads/${y}`,k=await U(s,x);if(!k)return $(`no branch named '${w}'`);if(await Dt(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 '${y}' already exists`);R&&await fe(s,b);let C=await Ye(s,x);await Y(s,b,k),await fe(s,x),w===i&&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===i){let I=await zt(s,r.env);await Be(s,"HEAD",{oldHash:k,newHash:J,...I,message:P}),await Be(s,"HEAD",{oldHash:J,newHash:k,...I,message:P})}let E=await le(s),O=`branch "${w}"`;return E[O]&&(E[`branch "${y}"`]=E[O],delete E[O],await Je(s,E)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return $("branch name required");let w=n.name===i;if(!w&&!i&&await Dt(s)&&(await ht(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return N(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
|
|
210
|
+
`);let y=`refs/heads/${n.name}`,x=await U(s,y);if(!x)return N(`error: branch '${n.name}' not found
|
|
211
|
+
`);let b="";if(!f){let k=await X(s),C=(await le(s))[`branch "${n.name}"`],P=C?.remote,E=C?.merge,O=null,I=null;if(P&&E&&(O=E.replace(/^refs\/heads\//,`refs/remotes/${P}/`),I=await U(s,O)),I&&O){if(!(x===I||await un(s,x,I))){let A=k!=null&&(x===k||await un(s,x,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
|
|
212
|
+
'${O}', even though it is merged to HEAD
|
|
213
213
|
`:"";return N(`${A}error: the branch '${n.name}' is not fully merged
|
|
214
214
|
hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
|
|
215
215
|
hint: Disable this message with "git config set advice.forceDeleteBranch false"
|
|
216
|
-
`)}
|
|
217
|
-
'${
|
|
218
|
-
`)}else if(
|
|
216
|
+
`)}k!=null&&(x===k||await un(s,x,k))||(b=`warning: deleting branch '${n.name}' that has been merged to
|
|
217
|
+
'${O}', but not yet merged to HEAD
|
|
218
|
+
`)}else if(k&&x!==k&&!await un(s,x,k))return N(`error: the branch '${n.name}' is not fully merged
|
|
219
219
|
hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
|
|
220
220
|
hint: Disable this message with "git config set advice.forceDeleteBranch false"
|
|
221
|
-
`)}return await fe(s,y),{stdout:`Deleted branch ${n.name} (was ${V(
|
|
222
|
-
`,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||i;if(!y)return $("could not set upstream of HEAD when it does not point to any branch.");if(!await U(s,`refs/heads/${y}`))return $(`branch '${y}' does not exist`);let b=w.indexOf("/");if(b<0)return $(`the requested upstream branch '${w}' does not exist`);let
|
|
223
|
-
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,y;if(w){let
|
|
221
|
+
`)}return await fe(s,y),{stdout:`Deleted branch ${n.name} (was ${V(x)}).
|
|
222
|
+
`,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||i;if(!y)return $("could not set upstream of HEAD when it does not point to any branch.");if(!await U(s,`refs/heads/${y}`))return $(`branch '${y}' 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),E=`branch "${y}"`;return P[E]||(P[E]={}),P[E].remote=k,P[E].merge=`refs/heads/${R}`,await Je(s,P),{stdout:"",stderr:`branch '${y}' set up to track '${w}'.
|
|
223
|
+
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,y;if(w){let R=await Ie(s,w,`not a valid object name: '${w}'`);if(v(R))return R;y=R.hash}else if(y=await X(s),!y)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,y);let k=w??"HEAD";return await ne(s,r.env,x,null,y,`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&&!i){let w=await X(s);if(w){let y=await Dt(s),x;if(y){let b=await ht(s);if(b?.headName){let k=we(b.headName);if(k==="detached HEAD"){let R=await Fr(s);x=`(no branch, rebasing detached HEAD ${R?V(R):"(null)"})`}else x=`(no branch, rebasing ${k})`}else x="(no branch)"}else{let b=await Fr(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${V(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 y of w){let x=we(y.name);m.push({displayName:x,hash:y.hash,isCurrent:x===i,branchName:x})}}if(u){let w=await pe(s,"refs/remotes");for(let y of w){let x=y.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${x}`:x,hash:y.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(d===0)return{stdout:`${m.map(y=>y.isCurrent?`* ${y.displayName}`:` ${y.displayName}`).join(`
|
|
224
224
|
`)}
|
|
225
|
-
`,stderr:"",exitCode:0};let h=d>=1?await
|
|
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 y=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=V(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=nc(C,d>=2);P&&(R=` ${P}`)}}g.push(`${y}${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
|
|
228
|
-
`)}})}async function
|
|
229
|
-
${d}`,exitCode:0}}async function
|
|
227
|
+
`,stderr:"",exitCode:0}}})}function Q(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Gu=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],Lu=["commitMsg","mergeMsg"],_u=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],Nu=["onRefUpdate","onRefDelete","onObjectWrite"];function Fu(...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 Gu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let a of o){let i=await a(s);if(Q(i))return i}})}for(let r of Lu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let a of o){let i=await a(s);if(Q(i))return i}})}for(let r of _u){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let a of o)try{await a(s)}catch{}})}for(let r of Nu){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let a of o)try{a(s)}catch{}})}return n}re();Ve();ke();ie();je();ue();on();et();function xc(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:H().alias("b").describe("Create and switch to a new branch"),forceBranch:H().alias("B").describe("Create/reset and switch to a new branch"),detach:H().alias("d").describe("Detach HEAD at named commit"),orphan:H().describe("Create a new orphan branch"),ours:H().describe("Checkout our version for unmerged files"),theirs:H().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 a=s,i=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(a,r.cwd),u=o.passthrough,m=null;if(i){if(n.ours||n.theirs)return $("cannot specify both a revision and --ours/--theirs");let h=await Ie(a,i,`invalid reference: ${i}`);if(v(h))return h;m=h.commit.tree}return n.ours||n.theirs?Us(a,u,l,n.theirs?3:2):Fs(a,u,l,m)}if(n.orphan)return n.branch?$("--orphan and -b are incompatible"):n.ours||n.theirs?$("--orphan and --ours/--theirs are incompatible"):i?Bu(a,i,r.env,t):$("you must specify a branch to checkout");if(n.detach){let l=i??"HEAD",u=await Ie(a,l,`invalid reference: ${l}`);return v(u)?u:Rc(a,l,u.hash,r.env,t)}if(!i)return $("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Wu(a,i,r.env,t,!!n.forceBranch);if(i==="-")return Uu(a,r.env,t);let c=`refs/heads/${i}`,f=await U(a,c);if(f)return Cc(a,i,c,f,r.env,t);let d=await We(a,i);if(d){let l=await _e(a,d);return Rc(a,i,l,r.env,t)}if(a.workTree){let l=await K(a),u=us(l,i);if(u)return await it(a,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return N(`error: pathspec '${i}' did not match any file(s) known to git
|
|
228
|
+
`)}})}async function Uu(e,t,n){let r=await Ns(e);return r?Cc(e,r.name,r.refName,r.hash,t,n):$("no previous branch")}async function Bu(e,t,n,r){let o=`refs/heads/${t}`;if(await U(e,o))return $(`a branch named '${t}' already exists`);let a=await K(e),i=In(a);if(i)return i;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,a)),{stdout:l,stderr:`Switched to a new branch '${t}'
|
|
229
|
+
${d}`,exitCode:0}}async function Wu(e,t,n,r,o=!1){let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(Q(s))return N(s.message??"");let a=await Z(e),i=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=In(g);if(w)return w}i&&await Y(e,c,i),await Ue(e,"HEAD",c),await mt(e);let d=await ln(e),l=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):i??J;i&&(f?f!==i&&await ne(e,n,c,f,i,"branch: Reset to HEAD"):await ne(e,n,c,null,i,"branch: Created from HEAD")),await ne(e,n,"HEAD",i,i??J,`checkout: moving from ${l} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:i,newHead:i??J,isBranchCheckout:!0});let u="";if(o&&i){let g=await K(e),w=await M(e,i);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 Cc(e,t,n,r,o,s){let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return Q(a)?N(a.message??""):dr(e,t,n,r,o,s)}async function Rc(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return Q(s)?N(s.message??"")
|
|
231
|
+
`;return{stdout:u,stderr:`${p}${d}`,exitCode:0}}async function Cc(e,t,n,r,o,s){let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return Q(a)?N(a.message??""):dr(e,t,n,r,o,s)}async function Rc(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return Q(s)?N(s.message??""):$n(e,n,r,o,{detachAdviceTarget:t})}re();ke();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 qu(o,n,s,r)}function qu(e,t,n,r){let o=[],s=0,a=0;for(;s<t||a<r;){for(;s<t&&a<r&&!e[s]&&!n[a];)s++,a++;if(s>=t&&a>=r)break;let i=s,c=a;for(;s<t&&e[s];)s++;for(;a<r&&n[a];)a++;(s>i||a>c)&&o.push({buffer1:[i,s-i],buffer2:[c,a-c]})}return o}function Ku(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 a(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let i=0;for(;i<r.length;){let c=r[i++],f=c.oStart,d=c.oStart+c.oLength,l=[c];for(a(f);i<r.length;){let u=r[i];if(u.oStart>d)break;d=Math.max(d,u.oStart+u.oLength),l.push(u),i++}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 y=w.oStart,x=y+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(y,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 a(t.length),o}function zu(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Ku(e,t,n),a=[],i=[];function c(){i.length&&(a.push({type:"ok",lines:i}),i=[])}for(let f of s)f.stable?i.push(...f.content):o&&Pc(f.a,f.b)?i.push(...f.a):(c(),a.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),Xu(Vu(a))}function Vr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a="=".repeat(o),i=`${">".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,a,...l.b,i));return{conflict:f,result:d}}function Vu(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Yu(n));return t}function Yu(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Pc(t,n))return[e];let r=ai(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let i of r){let c=i.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+i.buffer1[1],l=i.buffer2[0]+i.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(i.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 Xu(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 a=t[r+1],i=o;i.a=[...o.a,...s.lines,...a.a],i.b=[...o.b,...s.lines,...a.b],i.o=[...o.o,...s.lines,...a.o],r++}else n.push(s)}return n}function Zn(e,t,n,r){let o=Vr(xt(e),xt(t),xt(n),{a:r.a,b:r.b,markerSize:r.markerSize}),a=(o.result[o.result.length-1]??"").endsWith("\0"),i=o.result.map(ci);return(i[i.length-1]??"").startsWith(">>>>>>>")||!a?`${i.join(`
|
|
232
232
|
`)}
|
|
233
233
|
`:i.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 fi(e){return e.endsWith("\0")?e.slice(0,-1):e}function Pc(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}ke();ie();sn();de();Nn();He();et();Jt();var mr=new TextDecoder,Dn=new TextEncoder,Oc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Lt(e,t,n,r,o){let{paths:s,baseMap:a,oursMap:i,theirsMap:c}=await Zu(e,t,n,r),f=await Qu(e,s,a,i,c,o);return em(e,s,o,f)}async function Xr(e,t,n,r){let o=await Gt(e,t,n),s=await M(e,t),a=await M(e,n);if(o.length===0)return{...await Lt(e,null,s.tree,a.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await Lt(e,f.tree,s.tree,a.tree,r),baseTree:f.tree}}let i=await Mc(e,t,n,o,1);return{...await Lt(e,i,s.tree,a.tree,r),baseTree:i}}async function Zu(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),a=await ce(e,r),i=new Set;for(let f of o.keys())i.add(f);for(let f of s.keys())i.add(f);for(let f of a.keys())i.add(f);let c=new Map;for(let f of i){let d=o.get(f)??null,l=s.get(f)??null,u=a.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,y=l?.hash??null,R=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===R&&(b|=5),y!==null&&y===R&&(b|=6);let E={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(Ju(E)){c.set(f,E);continue}c.set(f,E)}return{paths:c,baseMap:o,oursMap:s,theirsMap:a}}function Ju(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,a=r?.hash??null;return s===o&&a===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===a&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&a===null?(e.merged={result:null,clean:!0},!0):a===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&a!==o?(r?e.merged={result:{hash:a,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Qu(e,t,n,r,o,s){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},i=[],c=[];for(let[A,S]of n)r.has(A)||i.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode});for(let[A,S]of r)n.has(A)||i.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});for(let[A,S]of o)n.has(A)||c.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});let f=await tt(e,i),d=await tt(e,c);if(f.renames.length===0&&d.renames.length===0)return a;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,S,L=0){a.msgBuf.push({sortKey:A,subOrder:L,text:S})}for(let A of[...n.keys()].sort()){let S=l.get(A),L=u.get(A);if(!S&&!L)continue;let _=n.get(A);if(h.add(A),S&&L)if(h.add(S.newPath),h.add(L.newPath),S.newPath===L.newPath){let F=r.get(S.newPath),D=o.get(L.newPath);if(F.hash===D.hash)a.entries.push(gt(S.newPath,F));else{let W=di(t,S.newPath);W.stages=[{hash:_.hash,mode:_.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],W.pathnames=[A,S.newPath,L.newPath],W.filemask=7,W.merged={result:null,clean:!1}}}else{let F=r.get(S.newPath),D=o.get(L.newPath),W=await Dc(e,_,F,D,s);W.conflict&&w(A,`Auto-merging ${A}`,-1),a.conflicts.push({path:A,reason:"rename-rename",oursPath:S.newPath,theirsPath:L.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${S.newPath} in ${p} and to ${L.newPath} in ${g}.`),a.entries.push(gt(A,_,1)),a.entries.push(rt(S.newPath,F.mode,W.hash,2)),a.entries.push(rt(L.newPath,D.mode,W.hash,3)),a.worktreeBlobs.set(S.newPath,{hash:W.hash,mode:F.mode}),a.worktreeBlobs.set(L.newPath,{hash:W.hash,mode:D.mode})}else if(S){h.add(S.newPath);let F=o.get(A),D=r.get(S.newPath),W=m.has(S.newPath);if(F)if(W)await vc(e,a,S.newPath,A,_,D,F,r,o,!1,s);else if(F.hash===_.hash&&D.hash===_.hash)a.entries.push(gt(S.newPath,D));else if(F.hash===_.hash)a.entries.push(gt(S.newPath,D));else if(D.hash===_.hash)a.entries.push(rt(S.newPath,D.mode,F.hash));else{let te=di(t,S.newPath);te.stages=[{hash:_.hash,mode:_.mode},{hash:D.hash,mode:D.mode},{hash:F.hash,mode:F.mode}],te.pathnames=[A,S.newPath,A],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=o.get(S.newPath);if(a.conflicts.push({path:S.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(S.newPath,`CONFLICT (rename/delete): ${A} renamed to ${S.newPath} in ${p}, but deleted in ${g}.`),te){a.conflicts.push({path:S.newPath,reason:"add-add"}),w(S.newPath,`Auto-merging ${S.newPath}`,0),w(S.newPath,`CONFLICT (add/add): Merge conflict in ${S.newPath}`,1),a.entries.push(gt(S.newPath,D,2)),a.entries.push(gt(S.newPath,te,3));let $e=await Js(e,D.hash,te.hash,D.mode,s);a.worktreeBlobs.set(S.newPath,{hash:$e,mode:D.mode})}else a.entries.push(rt(S.newPath,_.mode,_.hash,1)),a.entries.push(gt(S.newPath,D,2)),a.worktreeBlobs.set(S.newPath,{hash:D.hash,mode:D.mode}),D.hash!==_.hash&&w(S.newPath,`CONFLICT (modify/delete): ${S.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${S.newPath} left in tree.`,1)}}else if(L){h.add(L.newPath);let F=r.get(A),D=o.get(L.newPath),W=m.has(L.newPath);if(F)if(W)await vc(e,a,L.newPath,A,_,F,D,r,o,!0,s);else if(F.hash===_.hash&&D.hash===_.hash)a.entries.push(gt(L.newPath,D));else if(F.hash===_.hash)a.entries.push(gt(L.newPath,D));else if(D.hash===_.hash)a.entries.push(rt(L.newPath,D.mode,F.hash));else{let te=di(t,L.newPath);te.stages=[{hash:_.hash,mode:_.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],te.pathnames=[A,A,L.newPath],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=r.get(L.newPath);if(a.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}.`),te){a.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),a.entries.push(gt(L.newPath,te,2)),a.entries.push(gt(L.newPath,D,3));let $e=await Js(e,te.hash,D.hash,te.mode,s);a.worktreeBlobs.set(L.newPath,{hash:$e,mode:te.mode})}else a.entries.push(rt(L.newPath,_.mode,_.hash,1)),a.entries.push(gt(L.newPath,D,3)),a.worktreeBlobs.set(L.newPath,{hash:D.hash,mode:D.mode}),D.hash!==_.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 y=new Set(f.renames.map(A=>A.newPath)),R=new Set(d.renames.map(A=>A.newPath)),b=Ic(n,r),E=Ic(n,o),k=$c(b,o,n),C=$c(E,r,n),O=Tc(f.renames,k),x=Tc(d.renames,C),P=Hc(O),I=Hc(x);for(let A of[...P.keys()])I.has(A)&&(P.delete(A),I.delete(A));let G=new Set(P.keys()),j=new Set(I.keys());if(I.size>0)for(let A of i){if(A.status!=="added"||y.has(A.path))continue;let S=Sc(A.path,I,G);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(r.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=r.get(A.path),D=o.get(S)??n.get(S);a.entries.push(rt(S,F.mode,F.hash,2)),D&&a.entries.push(rt(S,D.mode,D.hash,3)),a.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),h.add(A.path);continue}let L=r.get(A.path);a.entries.push(rt(S,L.mode,L.hash,2)),a.worktreeBlobs.set(S,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let _=t.get(A.path);_&&(_.merged={result:null,clean:!0}),h.add(A.path)}if(P.size>0)for(let A of c){if(A.status!=="added"||R.has(A.path))continue;let S=Sc(A.path,P,j);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(o.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=o.get(A.path),D=r.get(S)??n.get(S);D&&a.entries.push(rt(S,D.mode,D.hash,2)),a.entries.push(rt(S,F.mode,F.hash,3)),a.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),h.add(A.path);continue}let L=o.get(A.path);a.entries.push(rt(S,L.mode,L.hash,3)),a.worktreeBlobs.set(S,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let _=t.get(A.path);_&&(_.merged={result:null,clean:!0}),h.add(A.path)}let z=new Set(a.entries.map(A=>A.path));for(let A of z){let S=t.get(A);S&&(S.merged={result:null,clean:!0})}for(let A of h){if(z.has(A))continue;let S=t.get(A);if(!S||S.merged.clean)continue;S.filemask===7&&!S.pathConflict||(S.merged={result:null,clean:!0})}return a}function Ic(e,t){let n=new Set;for(let s of e.keys()){let a=Ct(s);for(;a;)n.add(a),a=Ct(a)}let r=new Set;for(let s of t.keys()){let a=Ct(s);for(;a;)r.add(a),a=Ct(a)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function $c(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 Tc(e,t){let n=new Map;for(let r of e){let o=Ct(r.oldPath),s=Ct(r.newPath),a=!0;for(;;){if(!a){let i=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(i,r.oldPath.indexOf("/",i)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let i=n.get(o);i||(i=new Map,n.set(o,i)),i.set(s,(i.get(s)??0)+1)}if(a=!1,!o||!s)break;o=Ct(o),s=Ct(s)}}return n}function Hc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,a=null;for(let[i,c]of r)c===o?s=o:c>o&&(o=c,a=i);o>0&&s!==o&&a!==null&&t.set(n,a)}return t}function Sc(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 a=e.slice(r.length+1);return s?`${s}/${a}`:a}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 vc(e,t,n,r,o,s,a,i,c,f=!1,d){let l=f?i.get(n):c.get(n),u=f?a:s;if(l.hash===u.hash){t.entries.push(rt(n,l.mode,l.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Dc(e,o,s,a,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(l.hash===h.hash)t.entries.push(rt(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(rt(n,a.mode,h.hash,3));let p=await Js(e,l.hash,h.hash,l.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:l.mode})}else{t.entries.push(rt(n,s.mode,h.hash,2)),t.entries.push(gt(n,l,3));let p=await Js(e,h.hash,l.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Dc(e,t,n,r,o,s,a){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(cn(t.mode)||cn(n.mode)||cn(r.mode))return{hash:n.hash,conflict:!0};let i=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(Te(c)||Te(f)||Te(i))return{hash:n.hash,conflict:!0};let d=xt(i),l=xt(c),u=xt(f),m=Vr(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,y=Jn(c,i,f,{a:g,b:w,markerSize:a??7});return{hash:await Pe(e,"blob",Dn.encode(y)),conflict:!0}}async function Js(e,t,n,r,o){let s=await oe(e,t),a=await oe(e,n),i=Jn(s,"",a,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Pe(e,"blob",Dn.encode(i))}function gt(e,t,n=0){return rt(e,t.mode,t.hash,n)}function rt(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Ce()}}async function em(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],a=[...r.msgBuf],i=new Map(r.worktreeBlobs);function c(m,h,p=0){a.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 tm(e,h,n,o,s,c,i)}a.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=a.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 i)l.has(m)||d.push(ve(m,h.hash,h.mode));d.sort((m,h)=>Re(m.path,h.path));let u=await De(e,d);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function tm(e,t,n,r,o,s,a){let i=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:i,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(ve(i,l,c.mode,1)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&l!==null){o.push({path:i,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),a.set(i,{hash:u,mode:f.mode});return}if(l===null&&u!==null&&m!==null){if(u===m){r.push(ve(i,u,f.mode));return}s(i,`Auto-merging ${i}`,0);let h=await oe(e,u),p=await oe(e,m);if(Te(h)||Te(p)){o.push({path:i,reason:"add-add"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:u,mode:f.mode});return}let g=xt(""),w=xt(h),y=xt(p),R=Vr(w,g,y,n);if(!R.conflict){let k=await ui(e,R.result);r.push(ve(i,k,f.mode));return}o.push({path:i,reason:"add-add"}),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3));let b=Jn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),E=await Pe(e,"blob",Dn.encode(b));a.set(i,{hash:E,mode:f.mode});return}if(l!==null&&u!==null&&m!==null){if(u===l){r.push(ve(i,m,d.mode));return}if(m===l){r.push(ve(i,u,f.mode));return}if(u===m){r.push(ve(i,u,f.mode));return}if(s(i,`Auto-merging ${i}`,0),cn(c.mode)||cn(f.mode)||cn(d.mode)){o.push({path:i,reason:"content"}),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{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:i,reason:"content"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:u,mode:f.mode});return}let w=xt(h),y=xt(p),R=xt(g),b=Vr(y,w,R,n);if(b.conflict){let E=t.pathnames[1],k=t.pathnames[2],C=E!==i||k!==i,O={path:i,reason:"content"};C&&(E!==i&&(O.oursOrigPath=E),k!==i&&(O.theirsOrigPath=k)),o.push(O),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3));let x=C?`${n?.a??"HEAD"}:${E}`:n?.a??"HEAD",P=C?`${n?.b??"theirs"}:${k}`:n?.b??"theirs",I=Jn(p,h,g,{a:x,b:P}),G=await Pe(e,"blob",Dn.encode(I));a.set(i,{hash:G,mode:f.mode})}else{let E=await ui(e,b.result);r.push(ve(i,E,f.mode))}return}}var nm=200;async function Mc(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 a=s.map(d=>d.hash),i=a[0],c=i,f=(await M(e,i)).tree;for(let d=1;d<a.length;d++){let l=a[d],u=(await M(e,l)).tree,m=null;if(o>=nm)m=f;else{let g=await Gt(e,c,l);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await Mc(e,c,l,g,o+1)}let h=await Lt(e,m,f,u);f=await rm(e,h,o);let p=Yt({type:"commit",tree:f,parents:[c,l],author:Oc,committer:Oc,message:"merged common ancestors"});c=await Pe(e,"commit",p)}return f}async function rm(e,t,n){let r=t.entries.filter(i=>i.stage===0),o=new Map;for(let i of t.entries)i.stage>0&&o.set(`${i.path}\0${i.stage}`,i);let s=(i,c)=>o.get(`${i}\0${c}`),a={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let i of t.conflicts){if(i.reason==="delete-modify"||i.reason==="rename-delete"){let d=s(i.path,1);if(d){r.push({...d,stage:0});continue}}if(i.reason==="rename-rename"){let d=i.oursPath??i.path,l=i.theirsPath??i.path,u=s(i.path,1),m=s(d,2),h=s(l,3);if(m&&h){let p=mr.decode((await ge(e,m.hash)).content),g=mr.decode((await ge(e,h.hash)).content),w=u?mr.decode((await ge(e,u.hash)).content):"",y=8+n*2,R=a.a??"Temporary merge branch 1",b=a.b??"Temporary merge branch 2",E=Jn(p,w,g,{a:`${R}:${d}`,o:a.o,b:`${b}:${l}`,markerSize:y}),k=await Pe(e,"blob",Dn.encode(E));r.push({path:d,mode:m.mode,hash:k,stage:0,stat:Ce()}),r.push({path:l,mode:h.mode,hash:k,stage:0,stat:Ce()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(i.path,2),f=s(i.path,3);if(c&&f&&(i.reason==="content"||i.reason==="add-add")){let d=mr.decode((await ge(e,c.hash)).content),l=mr.decode((await ge(e,f.hash)).content),u=i.reason==="content"?s(i.path,1):null,m=u?mr.decode((await ge(e,u.hash)).content):"",h=i.oursOrigPath||i.theirsOrigPath,p=a.a??"Temporary merge branch 1",g=a.b??"Temporary merge branch 2",w=h?`${p}:${i.oursOrigPath??i.path}`:p,y=h?`${g}:${i.theirsOrigPath??i.path}`:g,R=Jn(d,m,l,{a:w,o:a.o,b:y,markerSize:a.markerSize}),b=await Pe(e,"blob",Dn.encode(R));r.push({path:i.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((i,c)=>Re(i.path,c.path)),De(e,r)}async function ui(e,t){let n=t.map(fi);if(n.length===0)return Pe(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 ci(e){return e.endsWith("\0")?e.slice(0,-1):e}function Pc(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}ke();ie();rn();de();_n();He();et();Jt();var mr=new TextDecoder,An=new TextEncoder,Oc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Lt(e,t,n,r,o){let{paths:s,baseMap:a,oursMap:i,theirsMap:c}=await Ju(e,t,n,r),f=await em(e,s,a,i,c,o);return tm(e,s,o,f)}async function Xr(e,t,n,r){let o=await Gt(e,t,n),s=await M(e,t),a=await M(e,n);if(o.length===0)return{...await Lt(e,null,s.tree,a.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await Lt(e,f.tree,s.tree,a.tree,r),baseTree:f.tree}}let i=await Mc(e,t,n,o,1);return{...await Lt(e,i,s.tree,a.tree,r),baseTree:i}}async function Ju(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),a=await ce(e,r),i=new Set;for(let f of o.keys())i.add(f);for(let f of s.keys())i.add(f);for(let f of a.keys())i.add(f);let c=new Map;for(let f of i){let d=o.get(f)??null,l=s.get(f)??null,u=a.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,y=l?.hash??null,x=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===x&&(b|=5),y!==null&&y===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(Qu(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:a}}function Qu(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,a=r?.hash??null;return s===o&&a===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===a&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&a===null?(e.merged={result:null,clean:!0},!0):a===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&a!==o?(r?e.merged={result:{hash:a,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function em(e,t,n,r,o,s){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},i=[],c=[];for(let[A,S]of n)r.has(A)||i.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode});for(let[A,S]of r)n.has(A)||i.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});for(let[A,S]of o)n.has(A)||c.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});let f=await tt(e,i),d=await tt(e,c);if(f.renames.length===0&&d.renames.length===0)return a;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,S,L=0){a.msgBuf.push({sortKey:A,subOrder:L,text:S})}for(let A of[...n.keys()].sort()){let S=l.get(A),L=u.get(A);if(!S&&!L)continue;let _=n.get(A);if(h.add(A),S&&L)if(h.add(S.newPath),h.add(L.newPath),S.newPath===L.newPath){let F=r.get(S.newPath),D=o.get(L.newPath);if(F.hash===D.hash)a.entries.push(gt(S.newPath,F));else{let W=fi(t,S.newPath);W.stages=[{hash:_.hash,mode:_.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],W.pathnames=[A,S.newPath,L.newPath],W.filemask=7,W.merged={result:null,clean:!1}}}else{let F=r.get(S.newPath),D=o.get(L.newPath),W=await Dc(e,_,F,D,s);W.conflict&&w(A,`Auto-merging ${A}`,-1),a.conflicts.push({path:A,reason:"rename-rename",oursPath:S.newPath,theirsPath:L.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${S.newPath} in ${p} and to ${L.newPath} in ${g}.`),a.entries.push(gt(A,_,1)),a.entries.push(rt(S.newPath,F.mode,W.hash,2)),a.entries.push(rt(L.newPath,D.mode,W.hash,3)),a.worktreeBlobs.set(S.newPath,{hash:W.hash,mode:F.mode}),a.worktreeBlobs.set(L.newPath,{hash:W.hash,mode:D.mode})}else if(S){h.add(S.newPath);let F=o.get(A),D=r.get(S.newPath),W=m.has(S.newPath);if(F)if(W)await vc(e,a,S.newPath,A,_,D,F,r,o,!1,s);else if(F.hash===_.hash&&D.hash===_.hash)a.entries.push(gt(S.newPath,D));else if(F.hash===_.hash)a.entries.push(gt(S.newPath,D));else if(D.hash===_.hash)a.entries.push(rt(S.newPath,D.mode,F.hash));else{let te=fi(t,S.newPath);te.stages=[{hash:_.hash,mode:_.mode},{hash:D.hash,mode:D.mode},{hash:F.hash,mode:F.mode}],te.pathnames=[A,S.newPath,A],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=o.get(S.newPath);if(a.conflicts.push({path:S.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(S.newPath,`CONFLICT (rename/delete): ${A} renamed to ${S.newPath} in ${p}, but deleted in ${g}.`),te){a.conflicts.push({path:S.newPath,reason:"add-add"}),w(S.newPath,`Auto-merging ${S.newPath}`,0),w(S.newPath,`CONFLICT (add/add): Merge conflict in ${S.newPath}`,1),a.entries.push(gt(S.newPath,D,2)),a.entries.push(gt(S.newPath,te,3));let $e=await Js(e,D.hash,te.hash,D.mode,s);a.worktreeBlobs.set(S.newPath,{hash:$e,mode:D.mode})}else a.entries.push(rt(S.newPath,_.mode,_.hash,1)),a.entries.push(gt(S.newPath,D,2)),a.worktreeBlobs.set(S.newPath,{hash:D.hash,mode:D.mode}),D.hash!==_.hash&&w(S.newPath,`CONFLICT (modify/delete): ${S.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${S.newPath} left in tree.`,1)}}else if(L){h.add(L.newPath);let F=r.get(A),D=o.get(L.newPath),W=m.has(L.newPath);if(F)if(W)await vc(e,a,L.newPath,A,_,F,D,r,o,!0,s);else if(F.hash===_.hash&&D.hash===_.hash)a.entries.push(gt(L.newPath,D));else if(F.hash===_.hash)a.entries.push(gt(L.newPath,D));else if(D.hash===_.hash)a.entries.push(rt(L.newPath,D.mode,F.hash));else{let te=fi(t,L.newPath);te.stages=[{hash:_.hash,mode:_.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],te.pathnames=[A,A,L.newPath],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=r.get(L.newPath);if(a.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}.`),te){a.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),a.entries.push(gt(L.newPath,te,2)),a.entries.push(gt(L.newPath,D,3));let $e=await Js(e,te.hash,D.hash,te.mode,s);a.worktreeBlobs.set(L.newPath,{hash:$e,mode:te.mode})}else a.entries.push(rt(L.newPath,_.mode,_.hash,1)),a.entries.push(gt(L.newPath,D,3)),a.worktreeBlobs.set(L.newPath,{hash:D.hash,mode:D.mode}),D.hash!==_.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 y=new Set(f.renames.map(A=>A.newPath)),x=new Set(d.renames.map(A=>A.newPath)),b=Ic(n,r),k=Ic(n,o),R=$c(b,o,n),C=$c(k,r,n),P=Tc(f.renames,R),E=Tc(d.renames,C),O=Hc(P),I=Hc(E);for(let A of[...O.keys()])I.has(A)&&(O.delete(A),I.delete(A));let j=new Set(O.keys()),G=new Set(I.keys());if(I.size>0)for(let A of i){if(A.status!=="added"||y.has(A.path))continue;let S=Sc(A.path,I,j);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(r.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=r.get(A.path),D=o.get(S)??n.get(S);a.entries.push(rt(S,F.mode,F.hash,2)),D&&a.entries.push(rt(S,D.mode,D.hash,3)),a.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),h.add(A.path);continue}let L=r.get(A.path);a.entries.push(rt(S,L.mode,L.hash,2)),a.worktreeBlobs.set(S,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let _=t.get(A.path);_&&(_.merged={result:null,clean:!0}),h.add(A.path)}if(O.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let S=Sc(A.path,O,G);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(o.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=o.get(A.path),D=r.get(S)??n.get(S);D&&a.entries.push(rt(S,D.mode,D.hash,2)),a.entries.push(rt(S,F.mode,F.hash,3)),a.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),h.add(A.path);continue}let L=o.get(A.path);a.entries.push(rt(S,L.mode,L.hash,3)),a.worktreeBlobs.set(S,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let _=t.get(A.path);_&&(_.merged={result:null,clean:!0}),h.add(A.path)}let z=new Set(a.entries.map(A=>A.path));for(let A of z){let S=t.get(A);S&&(S.merged={result:null,clean:!0})}for(let A of h){if(z.has(A))continue;let S=t.get(A);if(!S||S.merged.clean)continue;S.filemask===7&&!S.pathConflict||(S.merged={result:null,clean:!0})}return a}function Ic(e,t){let n=new Set;for(let s of e.keys()){let a=Ct(s);for(;a;)n.add(a),a=Ct(a)}let r=new Set;for(let s of t.keys()){let a=Ct(s);for(;a;)r.add(a),a=Ct(a)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function $c(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 Tc(e,t){let n=new Map;for(let r of e){let o=Ct(r.oldPath),s=Ct(r.newPath),a=!0;for(;;){if(!a){let i=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(i,r.oldPath.indexOf("/",i)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let i=n.get(o);i||(i=new Map,n.set(o,i)),i.set(s,(i.get(s)??0)+1)}if(a=!1,!o||!s)break;o=Ct(o),s=Ct(s)}}return n}function Hc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,a=null;for(let[i,c]of r)c===o?s=o:c>o&&(o=c,a=i);o>0&&s!==o&&a!==null&&t.set(n,a)}return t}function Sc(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 a=e.slice(r.length+1);return s?`${s}/${a}`:a}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 vc(e,t,n,r,o,s,a,i,c,f=!1,d){let l=f?i.get(n):c.get(n),u=f?a:s;if(l.hash===u.hash){t.entries.push(rt(n,l.mode,l.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Dc(e,o,s,a,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(l.hash===h.hash)t.entries.push(rt(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(rt(n,a.mode,h.hash,3));let p=await Js(e,l.hash,h.hash,l.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:l.mode})}else{t.entries.push(rt(n,s.mode,h.hash,2)),t.entries.push(gt(n,l,3));let p=await Js(e,h.hash,l.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Dc(e,t,n,r,o,s,a){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 i=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(Te(c)||Te(f)||Te(i))return{hash:n.hash,conflict:!0};let d=xt(i),l=xt(c),u=xt(f),m=Vr(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,y=Zn(c,i,f,{a:g,b:w,markerSize:a??7});return{hash:await Pe(e,"blob",An.encode(y)),conflict:!0}}async function Js(e,t,n,r,o){let s=await oe(e,t),a=await oe(e,n),i=Zn(s,"",a,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Pe(e,"blob",An.encode(i))}function gt(e,t,n=0){return rt(e,t.mode,t.hash,n)}function rt(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Ce()}}async function tm(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],a=[...r.msgBuf],i=new Map(r.worktreeBlobs);function c(m,h,p=0){a.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 nm(e,h,n,o,s,c,i)}a.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=a.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 i)l.has(m)||d.push(ve(m,h.hash,h.mode));d.sort((m,h)=>Re(m.path,h.path));let u=await De(e,d);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function nm(e,t,n,r,o,s,a){let i=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:i,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(ve(i,l,c.mode,1)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&l!==null){o.push({path:i,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),a.set(i,{hash:u,mode:f.mode});return}if(l===null&&u!==null&&m!==null){if(u===m){r.push(ve(i,u,f.mode));return}s(i,`Auto-merging ${i}`,0);let h=await oe(e,u),p=await oe(e,m);if(Te(h)||Te(p)){o.push({path:i,reason:"add-add"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:u,mode:f.mode});return}let g=xt(""),w=xt(h),y=xt(p),x=Vr(w,g,y,n);if(!x.conflict){let R=await li(e,x.result);r.push(ve(i,R,f.mode));return}o.push({path:i,reason:"add-add"}),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3));let b=Zn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),k=await Pe(e,"blob",An.encode(b));a.set(i,{hash:k,mode:f.mode});return}if(l!==null&&u!==null&&m!==null){if(u===l){r.push(ve(i,m,d.mode));return}if(m===l){r.push(ve(i,u,f.mode));return}if(u===m){r.push(ve(i,u,f.mode));return}if(s(i,`Auto-merging ${i}`,0),an(c.mode)||an(f.mode)||an(d.mode)){o.push({path:i,reason:"content"}),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{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:i,reason:"content"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3)),a.set(i,{hash:u,mode:f.mode});return}let w=xt(h),y=xt(p),x=xt(g),b=Vr(y,w,x,n);if(b.conflict){let k=t.pathnames[1],R=t.pathnames[2],C=k!==i||R!==i,P={path:i,reason:"content"};C&&(k!==i&&(P.oursOrigPath=k),R!==i&&(P.theirsOrigPath=R)),o.push(P),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(ve(i,l,c.mode,1)),r.push(ve(i,u,f.mode,2)),r.push(ve(i,m,d.mode,3));let E=C?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",O=C?`${n?.b??"theirs"}:${R}`:n?.b??"theirs",I=Zn(p,h,g,{a:E,b:O}),j=await Pe(e,"blob",An.encode(I));a.set(i,{hash:j,mode:f.mode})}else{let k=await li(e,b.result);r.push(ve(i,k,f.mode))}return}}var rm=200;async function Mc(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 a=s.map(d=>d.hash),i=a[0],c=i,f=(await M(e,i)).tree;for(let d=1;d<a.length;d++){let l=a[d],u=(await M(e,l)).tree,m=null;if(o>=rm)m=f;else{let g=await Gt(e,c,l);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await Mc(e,c,l,g,o+1)}let h=await Lt(e,m,f,u);f=await sm(e,h,o);let p=Yt({type:"commit",tree:f,parents:[c,l],author:Oc,committer:Oc,message:"merged common ancestors"});c=await Pe(e,"commit",p)}return f}async function sm(e,t,n){let r=t.entries.filter(i=>i.stage===0),o=new Map;for(let i of t.entries)i.stage>0&&o.set(`${i.path}\0${i.stage}`,i);let s=(i,c)=>o.get(`${i}\0${c}`),a={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let i of t.conflicts){if(i.reason==="delete-modify"||i.reason==="rename-delete"){let d=s(i.path,1);if(d){r.push({...d,stage:0});continue}}if(i.reason==="rename-rename"){let d=i.oursPath??i.path,l=i.theirsPath??i.path,u=s(i.path,1),m=s(d,2),h=s(l,3);if(m&&h){let p=mr.decode((await ge(e,m.hash)).content),g=mr.decode((await ge(e,h.hash)).content),w=u?mr.decode((await ge(e,u.hash)).content):"",y=8+n*2,x=a.a??"Temporary merge branch 1",b=a.b??"Temporary merge branch 2",k=Zn(p,w,g,{a:`${x}:${d}`,o:a.o,b:`${b}:${l}`,markerSize:y}),R=await Pe(e,"blob",An.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(i.path,2),f=s(i.path,3);if(c&&f&&(i.reason==="content"||i.reason==="add-add")){let d=mr.decode((await ge(e,c.hash)).content),l=mr.decode((await ge(e,f.hash)).content),u=i.reason==="content"?s(i.path,1):null,m=u?mr.decode((await ge(e,u.hash)).content):"",h=i.oursOrigPath||i.theirsOrigPath,p=a.a??"Temporary merge branch 1",g=a.b??"Temporary merge branch 2",w=h?`${p}:${i.oursOrigPath??i.path}`:p,y=h?`${g}:${i.theirsOrigPath??i.path}`:g,x=Zn(d,m,l,{a:w,o:a.o,b:y,markerSize:a.markerSize}),b=await Pe(e,"blob",An.encode(x));r.push({path:i.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((i,c)=>Re(i.path,c.path)),De(e,r)}async function li(e,t){let n=t.map(ci);if(n.length===0)return Pe(e,"blob",An.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
|
|
236
236
|
`):`${n.join(`
|
|
237
237
|
`)}
|
|
238
|
-
`;return Pe(e,"blob",
|
|
238
|
+
`;return Pe(e,"blob",An.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 Yr(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(`
|
|
@@ -260,13 +260,13 @@ ${a}
|
|
|
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
|
|
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 y=s.get(g);(!y||y.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",y=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Yr(g,w,y,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Bn(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(),y=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&&y.length>0?x=Ac(w,y,p,g):y.length>0?x=Yr(y,p,g,"untracked","worktree"):x=Yr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Bn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Is,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(),y=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(Yr(w,p,g,"local","worktree")),y.length>0&&x.push(Yr(y,p,g,"untracked","worktree"));let b;return x.length>1?b=Ac(w,y,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Se(e,h.worktreeOps)}let a=new Set,i=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){a.add(p.path);continue}}h.push(p)}i=h}let c=new Set(i.map(h=>h.path));for(let h of s.keys())a.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...i,...f];d.sort((h,p)=>Re(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();He();Jt();function jc(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[q.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:H().describe("Abort the current cherry-pick operation"),continue:H().describe("Continue the cherry-pick after conflict resolution"),skip:H().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":H().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:ee.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:H().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 _=await im(s,r.env);return _.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),_}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 _=await am(s,r.env);return _.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),_}if(n.skip)return om(s,r.env);let a=n.commit;if(!a)return $("you must specify a commit to cherry-pick");let i=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:a});if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let c=await Ie(s,a);if(v(c))return c;let f=c.hash,d=c.commit,l=await ze(s);if(v(l))return l;let u=await K(s);if(n.noCommit){let L=u.entries.filter(_=>_.stage>0);if(L.length>0){let D=L.slice(0,10).map(te=>`${te.path}: unmerged (${te.hash})`).join(`
|
|
264
264
|
`),W=L.length>10?`
|
|
265
265
|
...`:"";return N(`${D}${W}
|
|
266
266
|
error: your index file is unmerged.
|
|
267
267
|
fatal: cherry-pick failed
|
|
268
|
-
`,128)}}else{let L=
|
|
269
|
-
`);if(L)return L}let m=await M(s,l),p=!!n["record-origin"]?
|
|
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"]?cm(d.message,f):d.message;if(s.workTree&&!n.noCommit){let L=await ce(s,m.tree);if(ar(u,L))return N(`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 N(`error: commit ${f} is a merge but no -m option was given.
|
|
@@ -275,7 +275,7 @@ fatal: cherry-pick failed
|
|
|
275
275
|
fatal: cherry-pick failed
|
|
276
276
|
`,128)}else if(n.mainline)return N(`error: mainline was specified but commit is not a merge.
|
|
277
277
|
fatal: cherry-pick failed
|
|
278
|
-
`,128);let g;if(d.parents.length===0)g=await De(s,[]);else{let L=d.parents.length>1?n.mainline-1:0,_=d.parents[L];if(!_)throw new Error("unreachable: parent must exist");g=(await M(s,_)).tree}let w=V(f),y=ae(d.message),
|
|
278
|
+
`,128);let g;if(d.parents.length===0)g=await De(s,[]);else{let L=d.parents.length>1?n.mainline-1:0,_=d.parents[L];if(!_)throw new Error("unreachable: parent must exist");g=(await M(s,_)).tree}let w=V(f),y=ae(d.message),x={a:"HEAD",b:y?`${w} (${y})`:w},b=await Lt(s,g,m.tree,d.tree,x);if(b.conflicts.length===0&&b.resultTree===m.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await Y(s,"CHERRY_PICK_HEAD",f),await Y(s,"ORIG_HEAD",l),await Oe(s,"MERGE_MSG",p);let L=b.messages.length>0?`${b.messages.join(`
|
|
279
279
|
`)}
|
|
280
280
|
`:"",_=await nt(s,{fromCommit:!0});return{stdout:`${L}${_}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
281
281
|
If you wish to commit it anyway, use:
|
|
@@ -283,7 +283,7 @@ If you wish to commit it anyway, use:
|
|
|
283
283
|
git commit --allow-empty
|
|
284
284
|
|
|
285
285
|
Otherwise, please use 'git cherry-pick --skip'
|
|
286
|
-
`,exitCode:1}}let
|
|
286
|
+
`,exitCode:1}}let k=await mn(s,b,m.tree,{labels:x,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!k.ok)return k;if(b.conflicts.length>0){let L=b.messages.join(`
|
|
287
287
|
`);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:L?`${L}
|
|
288
288
|
`:"",stderr:`error: could not apply ${w}... ${ae(d.message)}
|
|
289
289
|
hint: after resolving the conflicts, mark the corrected paths
|
|
@@ -298,52 +298,52 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
|
|
|
298
298
|
hint: To abort and get back to the state before "git cherry-pick",
|
|
299
299
|
hint: run "git cherry-pick --abort".
|
|
300
300
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
301
|
-
`,exitCode:1})}let k
|
|
302
|
-
`)[0]??"",I=
|
|
301
|
+
`,exitCode:1})}let R=k.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await Xe(s,r.env);if(v(C))return C;let P=await ut(s,R,[l],d.author,C,p);await Bt(s),await At(s);let E=await Z(s),O=p.split(`
|
|
302
|
+
`)[0]??"",I=E?.type==="symbolic"?E.target:"HEAD";await ne(s,r.env,I,l,P,`cherry-pick: ${O}`,E?.type==="symbolic");let j=E?.type==="symbolic"?we(E.target):"detached HEAD",G=m.tree,z=await tn(s,G,R,d.author,C,!0),A=Ht(j,P,p),S=b.messages.length>0?`${b.messages.join(`
|
|
303
303
|
`)}
|
|
304
|
-
`:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:
|
|
305
|
-
${z}`,stderr:"",exitCode:0}}})}async function
|
|
304
|
+
`:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${S}${A}
|
|
305
|
+
${z}`,stderr:"",exitCode:0}}})}async function om(e,t){if(!await U(e,"CHERRY_PICK_HEAD"))return N(`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),a=await Ts(e,o.tree,s,r);if(!a.success){let i=a.errorOutput;return{...i,stderr:i.stderr+`error: failed to skip the commit
|
|
308
308
|
fatal: cherry-pick failed
|
|
309
|
-
`}}return await se(e,{version:2,entries:a.newEntries}),await Se(e,a.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Bt(e),{stdout:"",stderr:"",exitCode:0}}async function
|
|
309
|
+
`}}return await se(e,{version:2,entries:a.newEntries}),await Se(e,a.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Bt(e),{stdout:"",stderr:"",exitCode:0}}async function im(e,t){return await U(e,"CHERRY_PICK_HEAD")?Pn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
|
|
310
310
|
fatal: cherry-pick failed
|
|
311
|
-
`,128),operationName:"cherry-pick",clearState:Bt,origHeadAsTargetRev:!0}):await U(e,"REVERT_HEAD")?
|
|
311
|
+
`,128),operationName:"cherry-pick",clearState:Bt,origHeadAsTargetRev:!0}):await U(e,"REVERT_HEAD")?Pn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
|
|
312
312
|
fatal: cherry-pick failed
|
|
313
313
|
`,128),operationName:"cherry-pick",clearState:At,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
|
|
314
314
|
fatal: cherry-pick failed
|
|
315
|
-
`,128)}async function
|
|
315
|
+
`,128)}async function am(e,t){let n=await U(e,"CHERRY_PICK_HEAD");if(!n)return N(`error: no cherry-pick or revert in progress
|
|
316
316
|
fatal: cherry-pick failed
|
|
317
|
-
`,128);let r=await K(e),o=
|
|
318
|
-
`,1);let i=await Ee(e,"SQUASH_MSG");i&&(a=i+a),a=en(a);let c=Ae(r),f=await De(e,c),d=await ze(e);if(v(d))return d;let u=(await M(e,d)).tree,m=await
|
|
319
|
-
${b}`,stderr:"",exitCode:0}}function
|
|
317
|
+
`,128);let r=await K(e),o=fn(r,"Committing");if(o)return o;let s=await M(e,n),a=await Ee(e,"MERGE_MSG");if(!a)return N(`Aborting commit due to empty commit message.
|
|
318
|
+
`,1);let i=await Ee(e,"SQUASH_MSG");i&&(a=i+a),a=en(a);let c=Ae(r),f=await De(e,c),d=await ze(e);if(v(d))return d;let u=(await M(e,d)).tree,m=await Xe(e,t);if(v(m))return m;let h=St(a),p=await ut(e,f,[d],s.author,m,h);await Bt(e),await At(e),await he(e,"SQUASH_MSG");let g=await Z(e),w=ae(h),y=g?.type==="symbolic"?g.target:"HEAD";await ne(e,t,y,d,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?we(g.target):"detached HEAD",b=await tn(e,u,f,s.author,m,!0);return{stdout:`${Ht(x,p,a)}
|
|
319
|
+
${b}`,stderr:"",exitCode:0}}function cm(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();
|
|
326
|
-
`)}
|
|
327
|
-
`:"";return await t?.hooks?.postClean?.({repo:s,removed:
|
|
328
|
-
`),d=Lr(f,"","<cli>");a={...a,dirPatterns:[d,...a.dirPatterns]}}}let i=await e.fs.readdir(t);for(let c of i){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=a&&Xt(a,d,!0)==="ignored",m=cm(r.trackedPaths,d),h=()=>Lc(e,f,d,{...r,_ignore:a??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=a&&Xt(a,d,!1)==="ignored";r.onlyIgnored?u&&o.push({path:d,isDir:!1}):u&&s||o.push({path:d,isDir:!1})}}return o}function cm(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}re();Je();pn();ke();ie();de();je();le();kn();Je();kn();dt();ie();var eo=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]),fm=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]),Qs=64,dm=4,mi=4096,_c=65536,lm=127;function um(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=hm(r);let o=r-1,s=new Uint32Array(r),a=[],i=-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])^eo[m>>>23];if(m=m>>>0,m===i)a[a.length-1].ptr=u+16;else{i=m;let h=m&o;a.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of a){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<=Qs)continue;let h=[],p=m.length/Qs;for(let g=0;g<Qs;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=Qs}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 mm(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,a=new Uint8Array(Math.max(o,1024)),i=0;function c(p){for(;i+p>a.length;){let g=new Uint8Array(a.length*2);g.set(a),a=g}}i=Fc(a,i,r),i=Fc(a,i,o),c(18),i++;let f=0,d=0,l=Math.min(16,o);for(let p=0;p<l;p++)a[i++]=t[p],f=(f<<8|t[p])^eo[f>>>23],d++;f=f>>>0;let u=l,m=0,h=0;for(;u<o;){if(h<mi){f^=fm[t[u-16]],f=((f<<8|t[u])^eo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let R=e.entries[y];if(R.val!==f)continue;let b=R.ptr,E=s.byteLength-b,k=o-u;if(E>k&&(E=k),E<=h)break;let C=0;for(;C<E&&s[b+C]===t[u+C];)C++;if(C>h&&(h=C,m=b,h>=mi))break}}if(h<dm)c(2),d===0&&i++,a[i++]=t[u++],d++,d===lm&&(a[i-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,i--,!(--d>0)){i--,d=-1;break}d>0&&(a[i-d-1]=d),d=0}let p=h>_c?h-_c:0;h-=p,c(8);let g=i++,w=128;if(m&255&&(a[i++]=m&255,w|=1),m&65280&&(a[i++]=m>>>8&255,w|=2),m&16711680&&(a[i++]=m>>>16&255,w|=4),m&4278190080&&(a[i++]=m>>>24&255,w|=8),h&255&&(a[i++]=h&255,w|=16),h&65280&&(a[i++]=h>>>8&255,w|=32),a[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<mi){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^eo[f>>>23];f=f>>>0}}if(n&&i>n)return null}return d>0&&(a[i-d-1]=d),n&&i>n?null:a.subarray(0,i)}var Nc={blob:0,tree:1,commit:2,tag:3};function to(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let l=Nc[f.type]??99,u=Nc[d.type]??99;return l!==u?l-u:d.content.byteLength-f.content.byteLength}),s=new Map,a=[],i=[],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 R=i[p-h]??null;if(!R)continue;let b=u?u.byteLength:d.content.byteLength/2|0;if(b<16)continue;let E=mm(R,d.content,b);E&&(!u||E.byteLength<u.byteLength)&&(u=E,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),a.push(l),i.length>=n&&(i.shift(),c.shift()),i.push(um(d.content)),c.push(d.hash)}return a}function hm(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 Fc(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}$r();le();ie();sn();vr();ks();async function pm(e,t,n){let r=new Set;for(let a of n)await Zr(e,a,r);let o=[],s=new Set;for(let a of t)await Jr(e,a,r,s,o);return{count:o.length,objects:gm(o)}}async function hr(e,t,n){let{count:r,objects:o}=await pm(e,t,n);return{count:r,objects:wm(e,o)}}async function*gm(e){for(let t of e)yield t}async function*wm(e,t){for await(let n of t){let r=await ge(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function pr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Zr(e,t,n){if(n.has(t)||(n.add(t),!await wn(e,t)))return;let r=await ge(e,t);switch(r.type){case"commit":{let o=Vt(r.content);await Zr(e,o.tree,n);for(let s of o.parents)await Zr(e,s,n);break}case"tree":{let o=Cn(r.content);for(let s of o.entries)await Zr(e,s.hash,n);break}case"tag":{let o=on(r.content);await Zr(e,o.object,n);break}case"blob":break}}async function Jr(e,t,n,r,o){if(r.has(t)||n.has(t))return;r.add(t);let s=await ge(e,t);switch(o.push({hash:t,type:s.type}),s.type){case"commit":{let a=Vt(s.content);await Jr(e,a.tree,n,r,o);for(let i of a.parents)await Jr(e,i,n,r,o);break}case"tree":{let a=Cn(s.content);for(let i of a.entries)await Jr(e,i.hash,n,r,o);break}case"tag":{let a=on(s.content);await Jr(e,a.object,n,r,o);break}case"blob":break}}var bm=new TextEncoder,no=new TextDecoder,Uc=65520,ym=new Uint8Array([48,48,48,48]);function Qn(e){let t=typeof e=="string"?bm.encode(e):e,n=4+t.byteLength;if(n>Uc)throw new Error(`pkt-line too long: ${n} bytes (max ${Uc})`);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 ym.slice()}function ro(...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 gr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=no.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 so(e){if(e.type==="flush")return"";let t=no.decode(e.data);return t.endsWith(`
|
|
329
|
-
`)?t.slice(0,-1):t}var
|
|
330
|
-
`));for(let u=1;u<t.length;u++)i.push(
|
|
331
|
-
`));i.push(
|
|
332
|
-
`));i.push(
|
|
333
|
-
`));let c=ro(...i),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...
|
|
334
|
-
`));for(let h of f)i.push(
|
|
335
|
-
`));i.push(
|
|
325
|
+
`}re();Ve();Ps();ke();de();function Gc(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[q.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:H().alias("f").describe("Required to actually remove files"),"dry-run":H().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:H().alias("d").describe("Also remove untracked directories"),removeIgnored:H().alias("x").describe("Remove ignored files as well"),onlyIgnored:H().alias("X").describe("Remove only ignored files"),exclude:ee.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,a=Ke(s);if(a)return a;let i=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,y=w.length>0?w.map(P=>Ge(P,g)):null,x=n.exclude?[n.exclude]:[],b=await Lc(s,i,"",{trackedPaths:p,removeDirs:d,removeIgnored:l,onlyIgnored:u,extraExcludes:x}),k;y?k=b.filter(P=>be(y,P.path)):k=b,k.sort((P,E)=>P.path<E.path?-1:P.path>E.path?1:0);let R=[];if(c)for(let P of k){let E=P.isDir?`Would remove ${P.path}/`:`Would remove ${P.path}`;R.push(E)}else for(let P of k){let E=T(i,P.path);P.isDir?(await r.fs.rm(E,{recursive:!0}),R.push(`Removing ${P.path}/`)):(await r.fs.rm(E),R.push(`Removing ${P.path}`))}let C=R.length>0?`${R.join(`
|
|
326
|
+
`)}
|
|
327
|
+
`:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(P=>P.path),dryRun:c}),{stdout:C,stderr:"",exitCode:0}}})}async function Lc(e,t,n,r){let o=[],s=!r.removeIgnored,a=null;if(s||r.onlyIgnored){a=r._ignore??await ir(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);a=Fn(a,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
|
|
328
|
+
`),d=Lr(f,"","<cli>");a={...a,dirPatterns:[d,...a.dirPatterns]}}}let i=await e.fs.readdir(t);for(let c of i){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=a&&Xt(a,d,!0)==="ignored",m=fm(r.trackedPaths,d),h=()=>Lc(e,f,d,{...r,_ignore:a??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=a&&Xt(a,d,!1)==="ignored";r.onlyIgnored?u&&o.push({path:d,isDir:!1}):u&&s||o.push({path:d,isDir:!1})}}return o}function fm(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}re();Ve();hn();ke();ie();de();je();ue();En();Ve();En();dt();ie();var eo=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]),dm=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]),Qs=64,lm=4,ui=4096,_c=65536,um=127;function mm(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=pm(r);let o=r-1,s=new Uint32Array(r),a=[],i=-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])^eo[m>>>23];if(m=m>>>0,m===i)a[a.length-1].ptr=u+16;else{i=m;let h=m&o;a.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of a){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<=Qs)continue;let h=[],p=m.length/Qs;for(let g=0;g<Qs;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=Qs}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 hm(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,a=new Uint8Array(Math.max(o,1024)),i=0;function c(p){for(;i+p>a.length;){let g=new Uint8Array(a.length*2);g.set(a),a=g}}i=Fc(a,i,r),i=Fc(a,i,o),c(18),i++;let f=0,d=0,l=Math.min(16,o);for(let p=0;p<l;p++)a[i++]=t[p],f=(f<<8|t[p])^eo[f>>>23],d++;f=f>>>0;let u=l,m=0,h=0;for(;u<o;){if(h<ui){f^=dm[t[u-16]],f=((f<<8|t[u])^eo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let x=e.entries[y];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<lm)c(2),d===0&&i++,a[i++]=t[u++],d++,d===um&&(a[i-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,i--,!(--d>0)){i--,d=-1;break}d>0&&(a[i-d-1]=d),d=0}let p=h>_c?h-_c:0;h-=p,c(8);let g=i++,w=128;if(m&255&&(a[i++]=m&255,w|=1),m&65280&&(a[i++]=m>>>8&255,w|=2),m&16711680&&(a[i++]=m>>>16&255,w|=4),m&4278190080&&(a[i++]=m>>>24&255,w|=8),h&255&&(a[i++]=h&255,w|=16),h&65280&&(a[i++]=h>>>8&255,w|=32),a[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<ui){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^eo[f>>>23];f=f>>>0}}if(n&&i>n)return null}return d>0&&(a[i-d-1]=d),n&&i>n?null:a.subarray(0,i)}var Nc={blob:0,tree:1,commit:2,tag:3};function to(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let l=Nc[f.type]??99,u=Nc[d.type]??99;return l!==u?l-u:d.content.byteLength-f.content.byteLength}),s=new Map,a=[],i=[],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=i[p-h]??null;if(!x)continue;let b=u?u.byteLength:d.content.byteLength/2|0;if(b<16)continue;let k=hm(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),a.push(l),i.length>=n&&(i.shift(),c.shift()),i.push(mm(d.content)),c.push(d.hash)}return a}function pm(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 Fc(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}$r();ue();ie();rn();vr();ks();async function gm(e,t,n){let r=new Set;for(let a of n)await Zr(e,a,r);let o=[],s=new Set;for(let a of t)await Jr(e,a,r,s,o);return{count:o.length,objects:wm(o)}}async function hr(e,t,n){let{count:r,objects:o}=await gm(e,t,n);return{count:r,objects:bm(e,o)}}async function*wm(e){for(let t of e)yield t}async function*bm(e,t){for await(let n of t){let r=await ge(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function pr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Zr(e,t,n){if(n.has(t)||(n.add(t),!await gn(e,t)))return;let r=await ge(e,t);switch(r.type){case"commit":{let o=Vt(r.content);await Zr(e,o.tree,n);for(let s of o.parents)await Zr(e,s,n);break}case"tree":{let o=xn(r.content);for(let s of o.entries)await Zr(e,s.hash,n);break}case"tag":{let o=sn(r.content);await Zr(e,o.object,n);break}case"blob":break}}async function Jr(e,t,n,r,o){if(r.has(t)||n.has(t))return;r.add(t);let s=await ge(e,t);switch(o.push({hash:t,type:s.type}),s.type){case"commit":{let a=Vt(s.content);await Jr(e,a.tree,n,r,o);for(let i of a.parents)await Jr(e,i,n,r,o);break}case"tree":{let a=xn(s.content);for(let i of a.entries)await Jr(e,i.hash,n,r,o);break}case"tag":{let a=sn(s.content);await Jr(e,a.object,n,r,o);break}case"blob":break}}var ym=new TextEncoder,no=new TextDecoder,Uc=65520,Em=new Uint8Array([48,48,48,48]);function Jn(e){let t=typeof e=="string"?ym.encode(e):e,n=4+t.byteLength;if(n>Uc)throw new Error(`pkt-line too long: ${n} bytes (max ${Uc})`);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 Em.slice()}function ro(...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 gr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=no.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 so(e){if(e.type==="flush")return"";let t=no.decode(e.data);return t.endsWith(`
|
|
329
|
+
`)?t.slice(0,-1):t}var km=1,Rm=2,xm=3;function hi(e){let t=[],n=[],r=[],o=0;for(let i of e){if(i.type==="flush"||i.data.byteLength===0)continue;let c=i.data[0];if(c===void 0)continue;let f=i.data.subarray(1);switch(c){case km:t.push(f),o+=f.byteLength;break;case Rm:n.push(no.decode(f));break;case xm:r.push(no.decode(f));break;default:break}}let s=new Uint8Array(o),a=0;for(let i of t)s.set(i,a),a+=i.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 a=s.headers.get("content-type")??"",i=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!a.startsWith(i)){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: ${a})`)}let f=gr(c);return Cm(f,t)}function Cm(e,t){let n=0,r=e[n];r?.type==="data"&&so(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],a=new Map;for(;n<e.length;n++){let i=e[n];if(!i||i.type==="flush")break;let c=i.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&&a.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:a}}var Pm=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag"];async function Bc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=qc(r,Pm),i=[];i.push(Jn(`want ${t[0]} ${a.join(" ")}
|
|
330
|
+
`));for(let u=1;u<t.length;u++)i.push(Jn(`want ${t[u]}
|
|
331
|
+
`));i.push(mi());for(let u of n)i.push(Jn(`have ${u}
|
|
332
|
+
`));i.push(Jn(`done
|
|
333
|
+
`));let c=ro(...i),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 Om(l,a.includes("side-band-64k"))}function Om(e,t){let n=gr(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=so(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 a=0;for(let f of s)f.type==="data"&&(a+=f.data.byteLength);let i=new Uint8Array(a),c=0;for(let f of s)f.type==="data"&&(i.set(f.data,c),c+=f.data.byteLength);return{packData:i,acks:r,progress:[]}}var Im=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Wc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let a=qc(r,Im),i=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");i.push(Jn(`${c.oldHash} ${c.newHash} ${c.refName}\0${a.join(" ")}
|
|
334
|
+
`));for(let h of f)i.push(Jn(`${h.oldHash} ${h.newHash} ${h.refName}
|
|
335
|
+
`));i.push(mi());let d;if(n&&n.byteLength>0){let h=ro(...i);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=ro(...i);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 a.includes("report-status")?$m(m,a.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function $m(e,t){let n,r=[];if(t){let i=gr(e),{packData:c,progress:f,errors:d}=hi(i);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=gr(c)}else n=gr(e);let o=!1,s,a=[];for(let i of n){if(i.type==="flush")break;let c=so(i);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))a.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?a.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):a.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:a,progress:r}}function qc(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 Qr=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 bs(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 bs(this.remote,s)}let o=[];for(let s of t)try{let a=s.newHash===J,i=s.oldHash??null;if(!a&&!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=a?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,i,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(a&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):a||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(a){o.push({...s,ok:!1,error:a instanceof Error?a.message:String(a)})}return{updates:o}}},es=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 Bc(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let a=await bs(this.local,s.packData);return{remoteRefs:o,objectCount:a}}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=[],a=!1;for(let d of t)d.newHash!==J&&(o.push(d.newHash),a=!0),d.oldHash&&d.oldHash!==J&&s.push(d.oldHash);let i=null;a&&(i=await wi(this.local,o,s)??null);let c=await Wc(this.url,r,i,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 hr(e,t,n);if(r.count===0)return;let o=await pr(r),a=to(o).map(c=>({hash:c.hash,type:c.type,content:c.content,delta:c.delta,deltaBaseHash:c.deltaBase})),{data:i}=await gs(a);return i}async function Tm(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 Kc(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 Hm(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 Hm(n)}async function Vc(e,t,n,r){if(bi(t)){let o=Kc(t,e.networkPolicy);if(o)throw new Error(o);let s=await zc(e,t,n);return new es(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 Qr(e,r)}async function wr(e,t,n){let r=await Tm(e,t);if(!r)return null;if(bi(r.url)){let s=Kc(r.url,e.networkPolicy);if(s)throw new Error(s);let a=n?await zc(e,r.url,n):void 0;return{transport:new es(e,r.url,a,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await Ln(e.fs,r.url);return o?{transport:new Qr(e,o),config:r}:null}He();et();function Yc(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[q.string().name("repository").describe("Repository to clone"),q.string().name("directory").describe("Target directory").optional()],options:{bare:H().describe("Create a bare clone"),branch:ee.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://"),a=s?o:Pt(r.cwd,o),i=n.branch,c=n.directory;if(!c){let O=s?o.split("/").pop()??o:xr(a);O.endsWith(".git")&&(O=O.slice(0,-4)),c=O}let f=Pt(r.cwd,c),d=await t?.hooks?.preClone?.({repository:o,targetPath:f,bare:n.bare,branch:i??null});if(Q(d))return N(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(a)),l||(l=await Ln(r.fs,a)),!l))return $(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await ys(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:a,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Je(m,h);let p;try{p=await Vc(m,a,r.env,l??void 0)}catch(O){let I=O instanceof Error?O.message:"";return I.startsWith("network")?$(I):$(`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:i??null}),{stdout:"",stderr:`Cloning into '${c}'...
|
|
336
336
|
warning: You appear to have cloned an empty repository.
|
|
337
|
-
`,exitCode:0};let w=[],y=new Set;for(let
|
|
338
|
-
`,exitCode:0};if(b&&await Ue(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&
|
|
339
|
-
`,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:b}),
|
|
337
|
+
`,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));w.length>0&&await p.fetch(w,[]);let x=g.find(O=>O.name==="HEAD"),b=null,k=null,R=await zt(m,r.env),C=`clone: from ${a}`,P=p.headTarget;P?.startsWith("refs/heads/")&&g.some(O=>O.name===P)&&(b=P.slice(11),k=g.find(O=>O.name===P)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let I=O.name.slice(11),j=`refs/remotes/origin/${I}`;await Y(m,j,O.hash),await Be(m,j,{oldHash:J,newHash:O.hash,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:C}),!b&&x&&O.hash===x.hash&&(b=I,k=O.hash)}O.name.startsWith("refs/tags/")&&await Y(m,O.name,O.hash)}if(i){let O=g.find(I=>I.name===`refs/heads/${i}`);if(!O)return $(`Remote branch '${i}' not found in upstream origin`);b=i,k=O.hash}if(!b){let O=g.find(I=>I.name.startsWith("refs/heads/"));O&&(b=O.name.slice(11),k=O.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 O={oldHash:J,newHash:k,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:C};await Be(m,`refs/heads/${b}`,O),await Be(m,"HEAD",O);let I=await le(m);I[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Je(m,I);let j=await M(m,k);await ja(m,j.tree);let G=await qe(m,j.tree),z=ms(G.map(A=>({path:A.path,mode:parseInt(A.mode,8),hash:A.hash,stage:0,stat:Ce()})));await se(m,z)}let E={stdout:"",stderr:`Cloning into '${c}'...
|
|
339
|
+
`,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:b}),E}})}re();ke();ie();rn();de();je();ue();He();et();function Xc(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:ee.string().alias("m").describe("Commit message"),file:ee.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:H().describe("Allow creating an empty commit"),amend:H().describe("Amend the previous commit"),noEdit:H().describe("Use the previous commit message without editing"),all:H().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,a=await K(s);if(n.all){let xe=Ke(s);if(xe)return xe;let Me=await $t(s,a);for(let Ze of Me)Ze.status==="modified"?a=(await Zt(s,a,Ze.path)).index:Ze.status==="deleted"&&(a=ot(a,Ze.path));let nn=new Set(Ae(a).map(Ze=>Ze.path)),er=new Set(a.entries.filter(Ze=>Ze.stage>0&&!nn.has(Ze.path)).map(Ze=>Ze.path));for(let Ze of er){let Er=T(s.workTree,Ze);await r.fs.exists(Er)?a=(await Zt(s,a,Ze)).index:a=ot(a,Ze)}}let i=await U(s,"MERGE_HEAD"),c=await U(s,"CHERRY_PICK_HEAD"),f=await U(s,"REVERT_HEAD"),l=await Dt(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(i)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(It(a)){let xe=new Set,Me=[];for(let nn of a.entries)nn.stage>0&&!xe.has(nn.path)&&(xe.add(nn.path),Me.push(`U ${nn.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>'
|
|
343
343
|
hint: as appropriate to mark resolution and make a commit.
|
|
344
344
|
fatal: Exiting because of an unresolved conflict.
|
|
345
345
|
`,exitCode:128}}let h=u&&m?await M(s,m):null,p=n.message;if(!p&&n.file!==void 0){if(n.file==="-")p=r.stdin;else{let xe=n.file.startsWith("/")?n.file:T(r.cwd,n.file);if(!await r.fs.exists(xe))return $(`could not read log file '${n.file}': No such file or directory`);let Me=await r.fs.readFile(xe);p=typeof Me=="string"?Me:new TextDecoder().decode(Me)}if(p=en(p),!p)return{stdout:`Aborting commit due to empty commit message.
|
|
346
|
-
`,stderr:"",exitCode:1}}if(!p&&u&&h&&(p=h.message),!p&&(i||c||f||l)){let xe=await Ee(s,"SQUASH_MSG");if(xe)p=en(xe);else{let Me=await Ee(s,"MERGE_MSG");Me!==null&&(p=en(Me))}}if(!p)return N("error: must provide a commit message with -m or -F");let g=Ae(a),w=await De(s,g),y=await t?.hooks?.preCommit?.({repo:s,index:a,treeHash:w});if(Q(y))return N(y.message??"");let
|
|
346
|
+
`,stderr:"",exitCode:1}}if(!p&&u&&h&&(p=h.message),!p&&(i||c||f||l)){let xe=await Ee(s,"SQUASH_MSG");if(xe)p=en(xe);else{let Me=await Ee(s,"MERGE_MSG");Me!==null&&(p=en(Me))}}if(!p)return N("error: must provide a commit message with -m or -F");let g=Ae(a),w=await De(s,g),y=await t?.hooks?.preCommit?.({repo:s,index:a,treeHash:w});if(Q(y))return N(y.message??"");let x=n.allowEmpty,b=null;if(u&&h){let xe=h.parents[0];xe?b=(await M(s,xe)).tree:b=await bt("tree",new Uint8Array(0))}else m&&(b=(await M(s,m)).tree);let k=u&&h&&h.parents.length>1;if(!x&&!i&&!k){if(!m&&!u&&g.length===0)return{stdout:await nt(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(b!==null&&b===w){if(u){let xe=h?.parents[0]??null;return{stdout:`${await nt(s,{fromCommit:!0,compareHash:xe,noWarn:!0,index:a})}No changes
|
|
347
347
|
`,stderr:`You asked to amend the most recent commit, but doing so would make
|
|
348
348
|
it empty. You can repeat your command with --allow-empty, or you can
|
|
349
349
|
remove the commit entirely with "git reset HEAD^".
|
|
@@ -353,69 +353,69 @@ If you wish to commit it anyway, use:
|
|
|
353
353
|
git commit --allow-empty
|
|
354
354
|
|
|
355
355
|
Otherwise, please use 'git cherry-pick --skip'
|
|
356
|
-
`,exitCode:1}:{stdout:await nt(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let
|
|
357
|
-
${Le}`,stderr:"",exitCode:0}}})}re();
|
|
358
|
-
`,stderr:"",exitCode:0}}async function Jc(e,t){return await
|
|
356
|
+
`,exitCode:1}:{stdout:await nt(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let R=await Qt(s,r.env);if(v(R))return R;let C=await Xe(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=St(p),E={repo:s,message:P},O=await t?.hooks?.commitMsg?.(E);if(Q(O))return N(O.message??"");P=E.message;let I;u&&h?I=[...h.parents]:(I=m?[m]:[],i&&I.push(i));let j=Yt({type:"commit",tree:w,parents:I,author:R,committer:C,message:P}),G=await Pe(s,"commit",j);await se(s,a);let z=await Z(s);z&&z.type==="symbolic"?await Y(s,z.target,G):await Y(s,"HEAD",G);let A=ae(P),S;u?S="commit (amend)":i?S="commit (merge)":c?S="commit (cherry-pick)":m?S="commit":S="commit (initial)";let L=`${S}: ${A}`,_=z?.type==="symbolic"?z.target:"HEAD";await ne(s,r.env,_,m,G,L,z?.type==="symbolic"),i&&await Nr(s),c&&await Bt(s),f&&await At(s),l&&await he(s,"MERGE_MSG"),await he(s,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:s,hash:G,message:P,branch:z?.type==="symbolic"?we(z.target):null,parents:I,author:R});let F=z?.type==="symbolic"?z.target:null,D=F?we(F):"detached HEAD",W;if(u&&h){let xe=h.parents[0];W=xe?(await M(s,xe)).tree:null}else W=m?(await M(s,m)).tree:null;let te=R.timestamp!==C.timestamp||R.timezone!==C.timezone,$e=I.length>1,Le=await tn(s,W,w,R,C,te,$e);return{stdout:`${Ht(D,G,p,I.length===0&&!u)}
|
|
357
|
+
${Le}`,stderr:"",exitCode:0}}})}re();Ve();function ts(e){let t=e.split(".");return t.length===2||t.length===3}function Sm(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,a]of Object.entries(r)){let i=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${i}=${a}`)}}return t}function ef(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:H().alias("l").describe("List all config entries"),unset:H().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,a=n.positionals,i=a[0];if(n.list)return Qc(await le(s));if(n.unset){let f=i;return f?ts(f)?Jc(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(i==="list")return Qc(await le(s));if(i==="get"){let f=a[1];return f?ts(f)?Zc(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(i==="set"){let f=a[1],d=a[2];return!f||d===void 0?N("error: missing key and/or value",2):ts(f)?(await ko(s,f,d),{stdout:"",stderr:"",exitCode:0}):N(`error: invalid key: ${f}`,2)}if(i==="unset"){let f=a[1];return f?ts(f)?Jc(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(!i)return N("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!ts(i))return N(`error: invalid key: ${i}`,2);let c=a[1];return c!==void 0?(await ko(s,i,c),{stdout:"",stderr:"",exitCode:0}):Zc(s,i)}})}async function Zc(e,t){let n=await _t(e,t);return n===void 0?N(""):{stdout:`${n}
|
|
358
|
+
`,stderr:"",exitCode:0}}async function Jc(e,t){return await qi(e,t)?{stdout:"",stderr:"",exitCode:0}:N("",5)}function Qc(e){let t=Sm(e);return{stdout:t.length>0?`${t.join(`
|
|
359
359
|
`)}
|
|
360
|
-
`:"",stderr:"",exitCode:0}}re();function oo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,a=[];a.push(`diff --cc ${t}`);let i=n.map(y=>y?V(y):"0000000"),c=o?V(o):"0000000";a.push(`index ${i.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(y=>y===null),l=!f&&n.some(y=>y!==null);if(d&&s)a.push(`new file mode ${s}`);else if(l){let y=r.map(
|
|
360
|
+
`:"",stderr:"",exitCode:0}}re();function oo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,a=[];a.push(`diff --cc ${t}`);let i=n.map(y=>y?V(y):"0000000"),c=o?V(o):"0000000";a.push(`index ${i.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(y=>y===null),l=!f&&n.some(y=>y!==null);if(d&&s)a.push(`new file mode ${s}`);else if(l){let y=r.map(x=>x||"000000").join(",");a.push(`deleted file mode ${y}`)}else{let y=r.map(k=>k||"000000"),x=s||"000000";y.some(k=>k!==x)&&a.push(`mode ${y.join(",")}..${x}`)}let u=n.some(y=>y!==null);if(a.push(u?`--- a/${t}`:"--- /dev/null"),a.push(f?`+++ b/${t}`:"+++ /dev/null"),l||d)return`${a.join(`
|
|
361
361
|
`)}
|
|
362
|
-
`;let m=e.parentContents.map(y=>y.length>0?Mt(y):[]),h=e.resultContent.length>0?Mt(e.resultContent):[],p=m.map(y=>ft(y,h)),g=
|
|
362
|
+
`;let m=e.parentContents.map(y=>y.length>0?Mt(y):[]),h=e.resultContent.length>0?Mt(e.resultContent):[],p=m.map(y=>ft(y,h)),g=vm(m,h,p),w=Dm(g,m.length,h);if(w.length===0)return"";for(let y of w)a.push(y);return`${a.join(`
|
|
363
363
|
`)}
|
|
364
|
-
`}function
|
|
365
|
-
`);let c=a[0],f=await M(e,c),d=await Ne(e,f.tree,s.commit.tree),l=await cf(e,d,r);return sf(l)||i&&(l.stderr=i),l}async function cf(e,t,n){let{remaining:r,renames:o}=await tt(e,t),s=of(r,o);return s.sort((a,i)=>Re(a.path,i.path)),n?{items:s.filter(a=>be(n,a.path))}:{items:s}}async function
|
|
364
|
+
`}function vm(e,t,n){let r=e.length,o=n.map(a=>{let i=[],c=new Map,f=0;for(let d of a)if(d.type==="keep")i[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")i[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:i,deletions:c}}),s=[];for(let a=0;a<=t.length;a++){let i=[];for(let f=0;f<r;f++){let d=o[f];i.push(d?.deletions.get(a)??[])}let c=Am(i,r);for(let f of c)s.push(f);if(a<t.length){let f=[],d=Array(r).fill(0);for(let l=0;l<r;l++){let m=o[l]?.resultStatus[a];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[l];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===a+1){d[l]=p.oldLineNo;break}}}}s.push({columns:f,text:t[a]??"",resultLineNo:a+1,parentLineNos:d})}}return s}function Am(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 a=o.map(d=>d.text),i=s.map(d=>d.text),c=ft(a,i),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 a of s){let i=Array(t).fill(" ");i[o]="-";let c=Array(t).fill(0);c[o]=a.parentLineNo,r.push({columns:i,text:a.text,resultLineNo:0,parentLineNos:c})}}return r}function Dm(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=[],a=o[0]??0,i=Math.max(0,a-3),c=Math.min(e.length-1,a+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:i,end:c}),i=u),c=m}s.push({start:i,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 y=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${y.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();ke();ie();de();function io(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();He();et();var yi=new TextDecoder;function sf(e){return"exitCode"in e}function br(e){return e.toString(8).padStart(6,"0")}function of(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 af(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[q.string().name("commits").variadic().optional()],options:{cached:H().describe("Show staged changes (index vs HEAD)"),staged:H().describe("Synonym for --cached"),stat:H().describe("Show diffstat summary"),nameOnly:H().describe("Show only names of changed files"),nameStatus:H().describe("Show names and status of changed files"),shortstat:H().describe("Show only the shortstat summary line"),numstat:H().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 a=s,i=n.cached||n.staged,c=n.commits,f=lt(a,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?io(c[0]):null;if(m){if(i)return $("too many arguments");m.type==="three-dot"?u=await Lm(a,m.left,m.right,d):u=await rf(a,m.left,m.right,d)}else if(c.length===2)u=await rf(a,c[0],c[1],d);else{if(c.length>2)return $("too many arguments");i?u=await Gm(a,c.length===1?c[0]:null,d):c.length===1?u=await _m(a,c[0],d):u=await Mm(a,d)}if(sf(u))return u;let h=await Nm(a,u.items,l);return u.stderr&&(h.stderr=u.stderr),h}})}async function Mm(e,t){let n=Ke(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,a=new Map,i=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?a.set(d.path,d):d.stage===3&&i.set(d.path,d));let c=await $t(e,r);c.sort((d,l)=>Re(d.path,l.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!be(t,d.path)||o.has(d.path))continue;let l=s.get(d.path);if(!l)continue;let u=br(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&&!be(t,d))continue;let l=a.get(d),u=i.get(d);await jm(f,e,d,l,u)}return f.sort((d,l)=>{let u=Re(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 jm(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let a=br(r.mode),i=br(o.mode),{exists:c,hash:f}=await tf(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:a,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[a,i]}),nf(e,n,r.hash,a,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let a=br(r.mode),{exists:i,hash:c}=await tf(t.fs,s,n);nf(e,n,r.hash,a,i,c)}}async function tf(e,t,n){let r=T(t,n);if(!await e.exists(r))return{exists:!1};let o=await Mr(e,r);return{exists:!0,hash:await bt("blob",o)}}function nf(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 Gm(e,t,n){let r=null;if(t){let u=await Ie(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),a=new Set;for(let u of s.entries)u.stage>0&&a.add(u.path);let i=new Map(Ae(s).map(u=>[u.path,u])),c=[];for(let[u,m]of i){if(a.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:br(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:br(m.mode)})}for(let[u,m]of o)a.has(u)||i.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await tt(e,c),l=of(f,d);for(let u of a)l.push({path:u,status:"U"});return l.sort((u,m)=>Re(u.path,m.path)),n?{items:l.filter(u=>be(n,u.path))}:{items:l}}async function rf(e,t,n,r){let o=await Ie(e,t);if(v(o))return o;let s=await Ie(e,n);if(v(s))return s;let a=await Ne(e,o.commit.tree,s.commit.tree);return cf(e,a,r)}async function Lm(e,t,n,r){let o=await Ie(e,t);if(v(o))return o;let s=await Ie(e,n);if(v(s))return s;let a=await Gt(e,o.hash,s.hash);if(a.length===0)return $(`${t}...${n}: no merge base`);let i;a.length>1&&(i=`warning: ${t}...${n}: multiple merge bases, using ${a[0]}
|
|
365
|
+
`);let c=a[0],f=await M(e,c),d=await Ne(e,f.tree,s.commit.tree),l=await cf(e,d,r);return sf(l)||i&&(l.stderr=i),l}async function cf(e,t,n){let{remaining:r,renames:o}=await tt(e,t),s=of(r,o);return s.sort((a,i)=>Re(a.path,i.path)),n?{items:s.filter(a=>be(n,a.path))}:{items:s}}async function _m(e,t,n){let r=Ke(e);if(r)return r;let o=await Ie(e,t);if(v(o))return o;let s=e.workTree,a=await ce(e,o.commit.tree),i=[];for(let[c,f]of a){if(n&&!be(n,c))continue;let d=T(s,c);if(!await e.fs.exists(d)){i.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&&i.push({path:c,status:"M",oldHash:f.hash,newHash:u,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return i.sort((c,f)=>Re(c.path,f.path)),{items:i}}async function Nm(e,t,n){let r;switch(n){case"stat":r=await Km(e,t);break;case"shortstat":r=await zm(e,t);break;case"numstat":r=await qm(e,t);break;case"name-only":r=Bm(t);break;case"name-status":r=Wm(t);break;default:r=await Fm(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function Fm(e,t){let n="",r=new Set,o=await Um(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let a=await Promise.all(s.combinedParentHashes.map(async f=>f?await oe(e,f):"")),i=await Ei(e,s);if(a.some(f=>Te(f))||Te(i)){let f=s.combinedParentHashes.map(d=>d?V(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=oo({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:s.newMode??null,resultContent:i});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 a=s.oldHash?await oe(e,s.oldHash):"",i=await
|
|
371
|
-
`;return t}function
|
|
370
|
+
`;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let a=s.oldHash?await oe(e,s.oldHash):"",i=await Ei(e,s);s.status==="R"&&s.oldPath?n+=Rt({path:s.oldPath,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:ao(s.oldHash,o),newHash:ao(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=Rt({path:s.path,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:ao(s.oldHash,o),newHash:ao(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function Um(e,t){let n=new Set;for(let i of t)i.oldHash&&i.oldHash.length===40&&n.add(i.oldHash),i.newHash&&i.newHash.length===40&&n.add(i.newHash);let r=new Map,o=async i=>{let c=r.get(i);if(c)return c;let f=T(e.gitDir,"objects",i),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(i,d),d},s=async(i,c)=>{let f=i.slice(0,2),d=i.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},a=new Map;for(let i of n){let c=7;for(;c<40&&!await s(i,c);)c++;a.set(i,i.slice(0,c))}return a}function ao(e,t){if(e)return e.length!==40?e:t.get(e)??V(e)}function Bm(e){let t="";for(let n of e)t+=`${n.path}
|
|
371
|
+
`;return t}function Wm(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
|
|
374
|
-
`;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await
|
|
373
|
+
`;return t}async function qm(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),a=Te(o)||Te(s),i,c;if(a)i="-",c="-";else{let{ins:f,del:d}=ff(o,s);i=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=On(r.oldPath,r.path);n+=`${i} ${c} ${f}
|
|
375
375
|
`}else n+=`${i} ${c} ${r.path}
|
|
376
|
-
`}return n}async function
|
|
376
|
+
`}return n}async function Km(e,t){let n=await df(e,t);return zr(n)}async function zm(e,t){let n=await df(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let i of n)i.isUnmerged||(s++,r+=i.insertions,o+=i.deletions);let a=ur(s,r,o);return a?`${a}
|
|
377
377
|
`:n.some(i=>i.isUnmerged)?` 0 files changed
|
|
378
|
-
`:""}async function
|
|
379
|
-
`);for(let
|
|
380
|
-
`)}}else{let
|
|
381
|
-
`)}}if(!
|
|
382
|
-
`))}if(
|
|
383
|
-
`))}}let
|
|
384
|
-
`)}let
|
|
385
|
-
`)}function
|
|
378
|
+
`:""}async function Ei(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path),r=await Mr(e.fs,n);return yi.decode(r)}return oe(e,t.newHash)}async function Vm(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path);return Mr(e.fs,n)}return yt(e,t.newHash)}function ff(e,t){let n=Wt(e),r=Wt(t),o=ft(n,r),s=0,a=0;for(let i of o)i.type==="insert"?s++:i.type==="delete"&&a++;return{ins:s,del:a}}async function df(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),a=await Vm(e,r);if(wn(s)||wn(a))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:a.byteLength});else{let i=yi.decode(s),c=yi.decode(a),{ins:f,del:d}=ff(i,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}re();Ve();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 Ym(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 co(e,t){if(!Ym(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),a=s.length>0?t.length-s.length:t.length,i=t.slice(o.length,a);return r===-1?e.dst:e.dst.slice(0,r)+i+e.dst.slice(r+1)}function uf(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[q.string().name("remote").describe("Remote to fetch from").optional(),q.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:H().describe("Fetch from all remotes"),prune:H().alias("p").describe("Remove stale remote-tracking refs"),tags:H().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 i=await le(s),c=[];for(let l of Object.keys(i)){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 lf(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 a=n.remote||"origin";return lf(s,a,n.refspec,n.prune,n.tags,r.env,t)}})}async function lf(e,t,n,r,o,s,a){let i;try{i=await wr(e,t,s)}catch(E){let O=E instanceof Error?E.message:"";if(O.startsWith("network"))return $(O);throw E}if(!i)return $(`'${t}' does not appear to be a git repository`);let{transport:c,config:f}=i,d;n&&n.length>0?d=n.map(Qn):d=[Qn(f.fetchRefspec)];let l=await a?.hooks?.preFetch?.({repo:e,remote:t,url:f.url,refspecs:d.map(E=>`${E.src}:${E.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(E=>E.hash),p=await U(e,"HEAD");p&&h.push(p);let g=[],w=new Set,y=[];for(let E of u)if(E.name!=="HEAD")for(let O of d){let I=co(O,E.name);if(I!==null){y.push({remote:E,localRef:I,force:O.force}),w.has(E.hash)||(w.add(E.hash),g.push(E.hash));break}}if(o)for(let E of u)E.name.startsWith("refs/tags/")&&(y.push({remote:E,localRef:E.name,force:!1}),w.has(E.hash)||(w.add(E.hash),g.push(E.hash)));let x=new Set(h),b=g.filter(E=>!x.has(E));b.length>0&&await c.fetch(b,h);let k=await zt(e,s),R=[];R.push(`From ${f.url}
|
|
379
|
+
`);for(let E of y){let O=await U(e,E.localRef);await Y(e,E.localRef,E.remote.hash),await Be(e,E.localRef,{oldHash:O??J,newHash:E.remote.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:O?"fetch":"fetch: storing head"});let I=fo(E.remote.name),j=fo(E.localRef);if(O){if(O!==E.remote.hash){let G=V(O),z=V(E.remote.hash);R.push(` ${G}..${z} ${I} -> ${j}
|
|
380
|
+
`)}}else{let z=E.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";R.push(`${z} ${I} -> ${j}
|
|
381
|
+
`)}}if(!o)for(let E of u){if(!E.name.startsWith("refs/tags/")||w.has(E.hash))continue;let O=await U(e,E.name),I=E.peeledHash??E.hash;!O&&x.has(I)&&(await Y(e,E.name,E.hash),await Be(e,E.name,{oldHash:J,newHash:E.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:"fetch: storing head"}),R.push(` * [new tag] ${fo(E.name)} -> ${fo(E.name)}
|
|
382
|
+
`))}if(r){let E=`refs/remotes/${t}`,O=await pe(e,E),I=new Set(u.filter(j=>j.name.startsWith("refs/heads/")).map(j=>j.name.slice(11)));for(let j of O){let G=j.name.slice(E.length+1);I.has(G)||(await fe(e,j.name),R.push(` - [deleted] (none) -> ${t}/${G}
|
|
383
|
+
`))}}let C=u.find(E=>E.name==="HEAD");if(C){let E=T(e.gitDir,"FETCH_HEAD"),O=u.find(j=>j.name.startsWith("refs/heads/")&&j.hash===C.hash),I=O?`branch '${O.name.slice(11)}' of`:"of";await e.fs.writeFile(E,`${C.hash} ${I} ${f.url}
|
|
384
|
+
`)}let P={stdout:"",stderr:R.join(""),exitCode:0};return await a?.hooks?.postFetch?.({repo:e,remote:t,url:f.url,refsUpdated:y.length}),P}function fo(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();ke();ie();de();je();ue();re();ke();ie();de();je();ue();async function mf(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await pe(e,"refs");for(let i of r)t.add(i.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await hf(e,o,o,t);let s=await K(e);for(let i of s.entries)t.add(i.hash);for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await U(e,i);c&&t.add(c)}let a=[];for(let i of t)await gn(e,i)&&a.push(i);return a}async function hf(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let a=T(t,s),i=await e.fs.stat(a);if(i.isDirectory)await hf(e,a,n,r);else if(i.isFile){let c=a.slice(n.length+1),f=await Ye(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}ws();$r();de();async function Xm(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let a of s){if(!a.endsWith(".idx"))continue;let i=await e.fs.readFileBuffer(T(r,a)),c=new Ft(i);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?pr(await hr(e,t,[])):(await pr(await hr(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,a=e.depth??50;if(r.length===0)return null;let i=e.all?await pr(await hr(t,r,[])):await Xm(t,r);if(i.length===0)return null;let c=i.length,f=to(i,{window:s,depth:a}),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 gs(l),h=await ha(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 y=`pack-${g}`,x=T(w,`${y}.pack`),b=T(w,`${y}.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 E of R){if(!E.endsWith(".idx"))continue;let O=E.slice(0,-4);if(O===y)continue;let I=T(w,`${O}.idx`),j=!0;try{let G=await n.readFileBuffer(I),z=new Ft(G);for(let A of z.allHashes())if(!k.has(A)){j=!1;break}}catch{j=!1}if(j){try{await n.rm(T(w,`${O}.pack`))}catch{}try{await n.rm(I)}catch{}}}let C=T(t.gitDir,"objects"),P;try{P=await n.readdir(C)}catch{P=[]}for(let E of P){if(E==="pack"||E==="info"||E.length!==2)continue;let O=T(C,E),I;try{I=await n.readdir(O)}catch{continue}for(let j of I){let G=`${E}${j}`;k.has(G)&&await n.rm(T(O,j))}try{(await n.readdir(O)).length===0&&await n.rm(O,{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 pf(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:H().alias("a").describe("Pack all objects, including already-packed"),delete:H().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,a=await mf(s),i=await ki({gitCtx:s,fs:r.fs,tips:a,cleanup:n.delete,all:n.all});return i?{stdout:"",stderr:`${Ri(i.totalCount,i.deltaCount)}
|
|
386
386
|
`,exitCode:0}:{stdout:`Nothing new to pack.
|
|
387
|
-
`,stderr:"",exitCode:0}}})}function
|
|
388
|
-
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var
|
|
387
|
+
`,stderr:"",exitCode:0}}})}function gf(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:H().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 ka(s),await mt(s);let a=await Jm(s);if(a.length>0){let i=n.aggressive?250:10,c=n.aggressive?250:50,f=await ki({gitCtx:s,fs:r.fs,tips:a,window:i,depth:c,cleanup:!0,all:!0});if(await Qm(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Ri(f.totalCount,f.deltaCount,!0)}
|
|
388
|
+
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Zm=2160*60*60;async function Jm(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)-Zm,a=T(e.gitDir,"logs");await e.fs.exists(a)&&await wf(e,a,a,s,t);let i=await K(e);for(let f of i.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 wf(e,t,n,r,o){let s=await e.fs.readdir(t);for(let a of s){let i=T(t,a),c=await e.fs.stat(i);if(c.isDirectory){await wf(e,i,n,r,o);try{(await e.fs.readdir(i)).length===0&&await e.fs.rm(i,{recursive:!0})}catch{}}else if(c.isFile){let f=i.slice(n.length+1),d=await Ye(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 Qm(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 bf(e){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:H().describe("Create a bare repository"),initialBranch:ee.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?Pt(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:a}=await ys(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),i="";a&&r&&(i=`warning: re-init: ignored --initial-branch=${r}
|
|
389
389
|
`);let c=t.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
|
|
390
|
-
`,stderr:i,exitCode:0}}})}re();
|
|
391
|
-
`,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${a}`,s+=2;continue}}o+=e[s],s++}return o}var
|
|
390
|
+
`,stderr:i,exitCode:0}}})}re();Kn();re();function yf(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let a=e[s+1];if(a===void 0){o+="%",s++;continue}if((a==="a"||a==="c")&&s+2<e.length){let i=e[s+2],c=a==="a"?r.author:r.committer;switch(i){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+=ih(c.timestamp,c.timezone),s+=3;continue;case"i":o+=ah(c.timestamp,c.timezone),s+=3;continue;case"d":o+=jt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=ch(c.timestamp,c.timezone),s+=3;continue}}switch(a){case"H":o+=n,s+=2;continue;case"h":o+=V(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=V(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(V).join(" "),s+=2;continue;case"s":o+=xi(r.message),s+=2;continue;case"b":o+=eh(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let i=t.decorations(n);o+=i?` ${i}`:""}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+=`%${a}`,s+=2;continue}}o+=e[s],s++}return o}var xi=ae;function eh(e){let t=e.indexOf(`
|
|
392
392
|
|
|
393
|
-
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function
|
|
393
|
+
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Ef(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 kf(e,t,n,r=!1){let{hash:o,commit:s}=t,a=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let i=r?V(o):o,c=xi(s.message);return a?`${i} ${a} ${c}`:`${i} ${c}`}case"short":{let i=[];return n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(V).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(""),i.push(` ${xi(s.message)}`),i.join(`
|
|
394
394
|
`)}case"full":{let i=[];n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(V).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(`Commit: ${s.committer.name} <${s.committer.email}>`),i.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
|
|
395
395
|
`))i.push(` ${f}`);return i.join(`
|
|
396
396
|
`)}case"fuller":{let i=[];n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(V).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(`AuthorDate: ${jt(s.author.timestamp,s.author.timezone)}`),i.push(`Commit: ${s.committer.name} <${s.committer.email}>`),i.push(`CommitDate: ${jt(s.committer.timestamp,s.committer.timezone)}`),i.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
|
|
397
397
|
`))i.push(` ${f}`);return i.join(`
|
|
398
|
-
`)}default:return
|
|
398
|
+
`)}default:return th(t,n)}}function th(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(V).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${jt(r.author.timestamp,r.author.timezone)}`),s.push("");let a=r.message.replace(/\n$/,"");for(let i of a.split(`
|
|
399
399
|
`))s.push(` ${i}`);return s.join(`
|
|
400
|
-
`)}var
|
|
400
|
+
`)}var nh=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],rh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function sh(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 Ci(e,t){let n=sh(t);return new Date((e+n*60)*1e3)}function oh(e){return`${e.slice(0,3)}:${e.slice(3)}`}function ih(e,t){let n=Ci(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${a}:${i}:${c}${oh(t)}`}function ah(e,t){let n=Ci(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${a}:${i}:${c} ${t}`}function ch(e,t){let n=Ci(e,t),r=nh[n.getUTCDay()]?.slice(0,3),o=rh[n.getUTCMonth()],s=n.getUTCDate(),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${a}:${i}:${c} ${t}`}ie();ue();on();He();function Pf(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[q.string().name("revisions").variadic().optional()],options:{maxCount:ee.number().alias("n").describe("Limit the number of commits to output"),oneline:H().describe("Condense each commit to a single line"),all:H().describe("Walk all refs, not just HEAD"),author:ee.string().describe("Filter by author (regex or substring)"),grep:ee.string().describe("Filter by commit message (regex or substring)"),since:ee.string().describe("Show commits after date"),after:ee.string().describe("Synonym for --since"),until:ee.string().describe("Show commits before date"),before:ee.string().describe("Synonym for --until"),decorate:H().describe("Show ref names next to commit hashes"),reverse:H().describe("Output commits in reverse order"),format:ee.string().describe("Pretty-print format string"),pretty:ee.string().describe("Pretty-print format or preset name"),patch:H().alias("p").describe("Show diff in patch format"),stat:H().describe("Show diffstat summary"),nameStatus:H().describe("Show names and status of changed files"),nameOnly:H().describe("Show only names of changed files"),shortstat:H().describe("Show only the shortstat summary line"),numstat:H().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 a=s,i,c,f=n.revisions,d=f&&f.length===1?io(f[0]):null;if(d){let F=async Le=>{let st=await We(a,Le);if(!st)return Ut(Le);try{return await _e(a,st)}catch{return Ut(Le)}},D=await F(d.left);if(typeof D=="object"&&"exitCode"in D)return D;let W=await F(d.right);if(typeof W=="object"&&"exitCode"in W)return W;let te=D,$e=W;if(d.type==="two-dot")i=[$e],c=[te];else{i=[te,$e];let Le=await Gt(a,te,$e);c=Le.length>0?Le:void 0}if(n.all){let Le=await pe(a);for(let xe of Le)try{let Me=await _e(a,xe.hash);i.includes(Me)||i.push(Me)}catch{}let st=await X(a);st&&!i.includes(st)&&i.push(st)}}else if(n.all){let F=await pe(a),D=new Set;for(let te of F)try{D.add(await _e(a,te.hash))}catch{}let W=await X(a);W&&D.add(W),i=[...D]}else if(f&&f.length>0){let F=[];for(let D of f){let W=await We(a,D);if(!W)return Ut(D);try{F.push(await _e(a,W))}catch{return Ut(D)}}i=F}else{let F=await ze(a);if(v(F))return F;i=[F]}if(i.length===0)return $("your current branch does not have any commits yet");let l=o.passthrough.length>0?o.passthrough.map(F=>Ge(F,"")):null,u=n.author?Rf(n.author):null,m=n.grep?Rf(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?ii(h):null,w=p?ii(p):null,y=n.format??n.pretty,x=null,b=null,k=!1;if(n.oneline)b="oneline",k=!0;else if(y!==void 0){let F=Ef(y);x=F.formatStr,b=F.preset}let R=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,P=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await lh(a):null,E=P?F=>xf(P,F):void 0,O=P?F=>{let D=xf(P,F);return D.startsWith("(")&&D.endsWith(")")?D.slice(1,-1):D}:void 0,I=n.maxCount,j=n.reverse,G=l?dh(a,i,l,c?await fh(a,c):void 0):vt(a,i,{exclude:c}),z=[];for await(let F of G){if(I!==void 0&&z.length>=I)break;let{commit:D}=F;if(!(w!==null&&D.committer.timestamp>w)&&!(g!==null&&D.committer.timestamp<=g)){if(u){let W=`${D.author.name} <${D.author.email}>`;if(!u(W))continue}m&&!m(D.message)||z.push(F)}}let A=j?z.reverse():z;if(x!==null){let F=[];for(let D of A){let W={hash:D.hash,commit:D.commit,decorations:E,decorationsRaw:O},te=yf(x,W),$e=await Cf(a,D.commit,R);$e&&(te+=`
|
|
401
401
|
|
|
402
402
|
${$e.replace(/\n$/,"")}`),F.push(te)}return{stdout:F.length>0?`${F.join(`
|
|
403
403
|
`)}
|
|
404
|
-
`:"",stderr:"",exitCode:0}}let S=b??"medium",L=S==="oneline",_=[];for(let F=0;F<A.length;F++){let D=A[F],W={hash:D.hash,commit:D.commit,decorations:
|
|
404
|
+
`:"",stderr:"",exitCode:0}}let S=b??"medium",L=S==="oneline",_=[];for(let F=0;F<A.length;F++){let D=A[F],W={hash:D.hash,commit:D.commit,decorations:E,decorationsRaw:O},te=kf(S,W,F===0,k),$e=await Cf(a,D.commit,R);$e&&(te+=`${L?`
|
|
405
405
|
`:`
|
|
406
406
|
|
|
407
407
|
`}${$e.replace(/\n$/,"")}`),_.push(te)}return{stdout:_.length>0?`${_.join(`
|
|
408
408
|
`)}
|
|
409
|
-
`:"",stderr:"",exitCode:0}}})}async function
|
|
410
|
-
`).join("")}function
|
|
411
|
-
`).join("")}async function
|
|
412
|
-
`:""}async function
|
|
409
|
+
`:"",stderr:"",exitCode:0}}})}async function fh(e,t){let n=new Set;for await(let r of vt(e,t))n.add(r.hash);return n}function Rf(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*dh(e,t,n,r){let o=new Set(r),s=new qn,a=async i=>{if(!o.has(i)){let c=await M(e,i);s.push({hash:i,commit:c})}};for(let i of t)await a(i);for(;s.size>0;){let i=s.pop();if(o.has(i.hash))continue;o.add(i.hash);let{commit:c}=i,f=c.parents;if(f.length===0){(await Ne(e,null,c.tree)).some(u=>be(n,u.path))&&(yield i);continue}if(f.length===1){let l=f[0];if(l){let u=await M(e,l);(await Ne(e,u.tree,c.tree)).some(h=>be(n,h.path))&&(yield i),await a(l)}continue}let d=[];for(let l of f){let u=await M(e,l);(await Ne(e,u.tree,c.tree)).some(h=>be(n,h.path))||d.push(l)}if(d.length>0&&d[0])await a(d[0]);else{yield i;for(let l of f)await a(l)}}}async function lh(e){let t=await Z(e),n=t?.type==="symbolic"?we(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})},a=await pe(e,"refs/heads");for(let f of a)s(f.hash,we(f.name),f.name);let i=await pe(e,"refs/remotes");for(let f of i)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 _e(e,f.hash)}catch{}s(d,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function xf(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(i=>i.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let a=n?n.filter(i=>i!==s):[];a.sort((i,c)=>i.fullRef>c.fullRef?-1:i.fullRef<c.fullRef?1:0);for(let i of a)o.push(i.label);return o.length>0?`(${o.join(", ")})`:""}async function Cf(e,t,n){if(!n||t.parents.length>=2)return"";let r=t.parents.length===1?(await M(e,t.parents[0])).tree:null,o=await Ne(e,r,t.tree),{remaining:s,renames:a}=await tt(e,o);switch(n){case"name-only":return uh(s,a);case"name-status":return mh(s,a);case"stat":return hh(e,s,a);case"shortstat":return ph(e,s,a);case"numstat":return gh(e,s,a);case"patch":return wh(e,s,a)}}function uh(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}
|
|
410
|
+
`).join("")}function mh(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}
|
|
411
|
+
`).join("")}async function hh(e,t,n){let{fileStats:r}=await Kr(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),zr(r)}async function ph(e,t,n){let{fileStats:r}=await Kr(e,t,n),o=0,s=0;for(let i of r)o+=i.insertions,s+=i.deletions;let a=ur(r.length,o,s);return a?`${a}
|
|
412
|
+
`:""}async function gh(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,a)=>s.key<a.key?-1:s.key>a.key?1:0);let o="";for(let s of r){let a=s.oldHash?await oe(e,s.oldHash):"",i=s.newHash?await oe(e,s.newHash):"";if(Te(a)||Te(i))o+=`- - ${s.display}
|
|
413
413
|
`;else{let c=Wt(a),f=Wt(i),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}
|
|
414
|
-
`}}return o}async function
|
|
415
|
-
`,
|
|
414
|
+
`}}return o}async function wh(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,a)=>{let i=s.type==="diff"?s.entry.path:s.entry.newPath,c=a.type==="diff"?a.entry.path:a.entry.newPath;return i<c?-1:i>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let a=s.entry,i=a.oldHash?await oe(e,a.oldHash):"",c=a.newHash?await oe(e,a.newHash):"";o+=Rt({path:a.oldPath,oldContent:i,newContent:c,oldMode:a.oldMode,newMode:a.newMode,oldHash:a.oldHash,newHash:a.newHash,renameTo:a.newPath,similarity:a.similarity})}else{let a=s.entry,i=a.oldHash?await oe(e,a.oldHash):"",c=a.newHash?await oe(e,a.newHash):"";o+=Rt({path:a.path,oldContent:i,newContent:c,oldMode:a.oldMode,newMode:a.newMode,oldHash:a.oldHash,newHash:a.newHash,isNew:a.status==="added",isDeleted:a.status==="deleted"})}return o}re();ke();de();_n();et();function If(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:H().alias("c").describe("Show cached files (default)"),modified:H().alias("m").describe("Show modified files"),deleted:H().alias("d").describe("Show deleted files"),others:H().alias("o").describe("Show other (untracked) files"),unmerged:H().alias("u").describe("Show unmerged files"),stage:H().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":H().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":H().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":H().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 a=s,i=Ke(a);if(i)return i;let c=a.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(a),b=g?"\0":`
|
|
415
|
+
`,k=o.passthrough.length>0?o.passthrough.map(P=>{let E=r.cwd!==c?bh(c,r.cwd):"";return Ge(P,E)}):null,R=[];if(f)for(let P of x.entries){if(k&&!be(k,P.path))continue;let E=w?P.stage>0?"M":"H":null;R.push(Of(P,h,E))}if(m&&!f)for(let P of x.entries)P.stage!==0&&(k&&!be(k,P.path)||R.push(Of(P,!0,w?"M":null)));if(d||l){let P=await yh(a,c,x);for(let{path:E,status:O}of P){if(O==="modified"&&!d||O==="deleted"&&!l||k&&!be(k,E))continue;let I=w?O==="deleted"?"R":"C":null;R.push(I?`${I} ${E}`:E)}}if(u){let P=await Eh(a,c,x,p);for(let E of P)k&&!be(k,E)||R.push(w?`? ${E}`:E)}return{stdout:R.length>0?R.join(b)+b:"",stderr:"",exitCode:0}}})}function Of(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 bh(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function yh(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 i=await ct(e.fs,s);if(!i.isFile&&!i.isSymbolicLink)continue;await Rn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Eh(e,t,n,r){let o=new Set(n.entries.map(a=>a.path));return(await Qe(e,t,"",{skipIgnore:!r})).filter(a=>!o.has(a))}re();Kn();ke();ie();je();ue();on();He();function $f(e,t){e.command("merge",{description:"Join two or more development histories together",args:[q.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:H().describe("Abort the current in-progress merge"),continue:H().describe("Continue the merge after conflict resolution"),noFf:H().describe("Create a merge commit even when fast-forward is possible"),ffOnly:H().describe("Refuse to merge unless fast-forward is possible"),squash:H().describe("Apply merge result to worktree/index without creating a merge commit"),edit:H().describe("Edit the merge message (no-op, accepted for compatibility)"),message:ee.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 Ph(s,r.env);if(n.continue)return Ch(s,r.env,t);let a=n.branch;if(!a)return $("you must specify a branch to merge");let i=await ze(s);if(v(i))return i;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).
|
|
416
416
|
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).
|
|
417
417
|
Please, commit your changes before you merge.`);let u=await We(s,a);if(!u)return N(`merge: ${a} - not something we can merge
|
|
418
|
-
`);let m=await _e(s,u),h=await Gt(s,i,m),p=h[0]??null;if(h.length===0)return $("refusing to merge unrelated histories");if(p===m)return await
|
|
418
|
+
`);let m=await _e(s,u),h=await Gt(s,i,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)":""}
|
|
419
419
|
`,stderr:"",exitCode:0};if(n.noFf&&n.ffOnly)return $("--no-ff and --ff-only are incompatible");let g=p===i&&!n.noFf;if(n.ffOnly&&!g)return N(`hint: Diverging branches can't be fast-forwarded, you need to either:
|
|
420
420
|
hint:
|
|
421
421
|
hint: git merge --no-ff
|
|
@@ -426,67 +426,67 @@ hint: git rebase
|
|
|
426
426
|
hint:
|
|
427
427
|
hint: Disable this message with "git config set advice.diverging false"
|
|
428
428
|
fatal: Not possible to fast-forward, aborting.
|
|
429
|
-
`,128);if(await U(s,"REVERT_HEAD")&&await At(s),g&&!n.squash){let
|
|
429
|
+
`,128);if(await U(s,"REVERT_HEAD")&&await At(s),g&&!n.squash){let x=await Z(s),b=await Zs(s,i,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,i,m,`merge ${a}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,x?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:i,theirsHash:m,strategy:"fast-forward",commitHash:null})}return b}let w=n.message,y=w?w.endsWith(`
|
|
430
430
|
`)?w:`${w}
|
|
431
|
-
`:void 0;return n.squash?
|
|
431
|
+
`:void 0;return n.squash?xh(s,i,m,a,r.env,t,y):kh(s,i,m,a,r.env,n.noFf,t,y)}})}async function kh(e,t,n,r,o,s=!1,a,i){let c=await M(e,t),f=await Z(e),d=f?.type==="symbolic"?we(f.target):"HEAD",l={a:"HEAD",b:r},u=await Xr(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 E=i??await Xn(e,r,d),O={repo:e,message:E,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},I=await a?.hooks?.mergeMsg?.(O);if(Q(I))return{stdout:"",stderr:I.message??"",exitCode:1};E=O.message;let j=Nt({version:2,entries:u.entries}).sort();return E+=`
|
|
432
432
|
# Conflicts:
|
|
433
|
-
${
|
|
433
|
+
${j.map(z=>`# ${z}`).join(`
|
|
434
434
|
`)}
|
|
435
|
-
`,await Oe(e,"MERGE_MSG",
|
|
435
|
+
`,await Oe(e,"MERGE_MSG",E),await Oe(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
436
436
|
`)}
|
|
437
|
-
`,stderr:"",exitCode:1}}await
|
|
437
|
+
`,stderr:"",exitCode:1}}await he(e,"MERGE_MSG");let h=m.mergedTreeHash,p=await Qt(e,o);if(v(p))return p;let g=await Xe(e,o);if(v(g))return g;let w=i??await Xn(e,r,d),y={repo:e,message:w,treeHash:h,headHash:t,theirsHash:n},x=await a?.hooks?.mergeMsg?.(y);if(Q(x))return{stdout:"",stderr:x.message??"",exitCode:1};w=y.message;let b=await a?.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 a?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:k});let C=await vn(e,c.tree,h);return{stdout:`${u.messages.length>0?`${u.messages.join(`
|
|
438
438
|
`)}
|
|
439
439
|
`:""}Merge made by the 'ort' strategy.
|
|
440
|
-
${C}`,stderr:"",exitCode:0}}async function
|
|
440
|
+
${C}`,stderr:"",exitCode:0}}async function Rh(e,t,n){let r=[];for await(let o of vt(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: ${jt(s.timestamp,s.timezone)}`),r.push("");for(let a of o.commit.message.replace(/\n+$/,"").split(`
|
|
441
441
|
`))r.push(` ${a}`);r.push("")}return r.join(`
|
|
442
|
-
`)}async function
|
|
443
|
-
`:"",m=await Xr(e,t,n,f),h=await
|
|
442
|
+
`)}async function xh(e,t,n,r,o,s,a){let i=await M(e,t),c=await Z(e),f={a:"HEAD",b:r},d=await Gt(e,t,n),l=d.length>0&&d[0]===t,u=l?`Updating ${V(t)}..${V(n)}
|
|
443
|
+
`:"",m=await Xr(e,t,n,f),h=await mn(e,m,i.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(a?p=`Squashed commit of the following:
|
|
444
444
|
|
|
445
445
|
${a}`:p=`Squashed commit of the following:
|
|
446
446
|
|
|
447
|
-
${await
|
|
447
|
+
${await Rh(e,t,n)}`,await Oe(e,"SQUASH_MSG",p),m.conflicts.length>0){let k=`
|
|
448
448
|
# Conflicts:
|
|
449
|
-
${Nt({version:2,entries:m.entries}).sort().map(
|
|
449
|
+
${Nt({version:2,entries:m.entries}).sort().map(P=>`# ${P}`).join(`
|
|
450
450
|
`)}
|
|
451
|
-
`,
|
|
451
|
+
`,R=await Ee(e,"MERGE_MSG");return await Oe(e,"MERGE_MSG",(R??"")+k),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
452
452
|
`)}
|
|
453
|
-
`,stderr:"",exitCode:1}}let g=h.mergedTreeHash,w=await
|
|
453
|
+
`,stderr:"",exitCode:1}}let g=h.mergedTreeHash,w=await vn(e,i.tree,g),y=m.messages.length>0?`${m.messages.join(`
|
|
454
454
|
`)}
|
|
455
455
|
`:"";return{stdout:`${l?`${u}Fast-forward
|
|
456
456
|
`:""}${y}Squash commit -- not updating HEAD
|
|
457
457
|
${l?w:""}`,stderr:l?"":`Automatic merge went well; stopped before committing as requested
|
|
458
|
-
`,exitCode:0}}async function
|
|
459
|
-
${
|
|
460
|
-
`);let f=c[c.length-1],d=c.slice(0,-1),l=Pt(r.cwd,f),u=at(i,l);if(u.startsWith(".."))return $(`'${f}' is outside repository at '${i}'`);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 y=Pt(r.cwd,w),
|
|
461
|
-
`,128);let c=n.remote,f=n.branch;if(!c){let
|
|
462
|
-
`),!
|
|
463
|
-
`,stderr:"",exitCode:0};let
|
|
464
|
-
`,stderr:"",exitCode:0};let z=
|
|
458
|
+
`,exitCode:0}}async function Ch(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 a=await ze(e);if(v(a))return a;let i=await M(e,a),c=await Ee(e,"MERGE_MSG");if(c)c=en(c);else{let P=await Z(e),E=P?.type==="symbolic"?we(P.target):"HEAD";c=await Xn(e,"unknown",E)}let f=Ae(o),d=await De(e,f),l=await Qt(e,t);if(v(l))return l;let u=await Xe(e,t);if(v(u))return u;let m=St(c),h={repo:e,message:m,treeHash:d,headHash:a,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:a,theirsHash:r});if(Q(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await ut(e,d,[a,r],l,u,m);await Nr(e);let y=await Z(e),x=ae(m),b=y?.type==="symbolic"?y.target:"HEAD";await ne(e,t,b,a,w,`commit (merge): ${x}`,y?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:a,theirsHash:r,strategy:"three-way",commitHash:w});let k=await vn(e,i.tree,d),R=y?.type==="symbolic"?we(y.target):"detached HEAD";return{stdout:`${Ht(R,w,c)}
|
|
459
|
+
${k}`,stderr:"",exitCode:0}}async function Ph(e,t){return Pn(e,t,{operationRef:"MERGE_HEAD",noOpError:$("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:Nr})}re();ke();de();et();function Tf(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[q.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:H().alias("f").describe("Force renaming even if target exists"),"dry-run":H().alias("n").describe("Do nothing; only show what would happen"),skip:H().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,a=Ke(s);if(a)return a;let i=s.workTree,c=n.sources;if(c.length<2)return N(`usage: git mv [<options>] <source>... <destination>
|
|
460
|
+
`);let f=c[c.length-1],d=c.slice(0,-1),l=Pt(r.cwd,f),u=at(i,l);if(u.startsWith(".."))return $(`'${f}' is outside repository at '${i}'`);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 y=Pt(r.cwd,w),x=at(i,y);if(x.startsWith("..")){if(n.skip)continue;return $(`'${w}' is outside repository at '${i}'`)}if(!await r.fs.exists(y)){if(n.skip)continue;return $(`bad source, source=${x}, destination=${u}`)}let R=(await r.fs.stat(y)).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,E;if(p){let j=xr(x);P=u===""||u==="."?j:`${u}/${j}`,E=T(l,j)}else P=u,E=l;if(await r.fs.exists(E)&&!n.force)if((await r.fs.stat(E)).isDirectory){let G=xr(x);P=`${P}/${G}`,E=T(E,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 I=Kt(E);if(!await r.fs.exists(I)){if(n.skip)continue;return $(`renaming '${x}' failed: No such file or directory`)}if(R){let j=`${x}/`,G=m.entries.filter(z=>z.path.startsWith(j)&&z.stage===0);for(let z of G){let A=z.path.slice(x.length),S=P+A,L=E+A;g.push({srcRel:z.path,dstRel:S,srcAbs:T(i,z.path),dstAbs:L})}}else g.push({srcRel:x,dstRel:P,srcAbs:y,dstAbs:E})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let y=Kt(w.dstAbs);await r.fs.exists(y)||await r.fs.mkdir(y,{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=us(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 Un(r.fs,Kt(w.srcAbs),i);return await se(s,m),{stdout:"",stderr:"",exitCode:0}}})}re();Ve();hn();ke();ie();de();dt();je();ue();function Hf(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[q.string().name("remote").describe("Remote to pull from").optional(),q.string().name("branch").describe("Remote branch").optional()],options:{rebase:H().alias("r").describe("Rebase instead of merge"),noRebase:H().describe("Merge instead of rebase"),ffOnly:H().describe("Only fast-forward"),noFf:H().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,a=await ze(s);if(v(a))return a;let i=await K(s);if(It(i))return N(`error: Pulling is not possible because you have unmerged files.
|
|
461
|
+
`,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 wr(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 y=(await pe(s)).map(me=>me.hash),x=await U(s,"HEAD");x&&y.push(x);let b=[],k=new Set,R=[];for(let me of g){if(me.name==="HEAD")continue;let Fe=co(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(y),P=b.filter(me=>!C.has(me));P.length>0&&await l.fetch(P,y);let E=await zt(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:E.name,email:E.email,timestamp:E.timestamp,tz:E.tz,message:Fe?"pull":"pull: storing head"})}let O=null;if(f){let me=g.find(Fe=>Fe.name===`refs/heads/${f}`);if(me)O=me.hash;else return $(`Couldn't find remote ref refs/heads/${f}`)}else{let me=g.find(Fe=>Fe.name==="HEAD");me&&(O=me.hash)}if(O&&await r.fs.writeFile(T(s.gitDir,"FETCH_HEAD"),`${O} ${u.url}
|
|
462
|
+
`),!O)return $("Could not determine remote HEAD");let I=O;if(a===I)return await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
463
|
+
`,stderr:"",exitCode:0};let j=await Gt(s,a,I),G=j[0]??null;if(j.length===0)return $("refusing to merge unrelated histories");if(G===I)return await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
464
|
+
`,stderr:"",exitCode:0};let z=G===a;if(n.ffOnly&&!z)return $("Not possible to fast-forward, aborting.");if(z&&!n.noFf){let me=await Zs(s,a,I),Fe=await Z(s),ss=Fe?.type==="symbolic"?Fe.target:"HEAD";return await Be(s,ss,{oldHash:a,newHash:I,name:E.name,email:E.email,timestamp:E.timestamp,tz:E.tz,message:"pull: Fast-forward"}),Fe?.type==="symbolic"&&await Be(s,"HEAD",{oldHash:a,newHash:I,name:E.name,email:E.email,timestamp:E.timestamp,tz:E.tz,message:"pull: Fast-forward"}),me.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:I,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"fast-forward",commitHash:null})),me}let A=await Z(s),S=A?.type==="symbolic"?we(A.target):"HEAD",L=f||c||"FETCH_HEAD",_={a:"HEAD",b:L},F=await Xr(s,a,I,_),D=await M(s,a),W=await mn(s,F,D.tree,{labels:_,errorExitCode:2,operationName:"merge"});if(!W.ok)return W;if(F.conflicts.length>0){await Y(s,"MERGE_HEAD",I),await Y(s,"ORIG_HEAD",a);let me=await Xn(s,L,S),Fe=Nt({version:2,entries:F.entries}).sort();return me+=`
|
|
465
465
|
# Conflicts:
|
|
466
466
|
${Fe.map(ss=>`# ${ss}`).join(`
|
|
467
467
|
`)}
|
|
468
|
-
`,await Oe(s,"MERGE_MSG",
|
|
468
|
+
`,await Oe(s,"MERGE_MSG",me),{stdout:`${[...F.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
469
469
|
`)}
|
|
470
|
-
`,stderr:"",exitCode:1}}let te=W.mergedTreeHash,$e=await Qt(s,r.env);if(v($e))return $e;let Le=await
|
|
470
|
+
`,stderr:"",exitCode:1}}let te=W.mergedTreeHash,$e=await Qt(s,r.env);if(v($e))return $e;let Le=await Xe(s,r.env);if(v(Le))return Le;let st=await Xn(s,L,S),xe={repo:s,message:st,treeHash:te,headHash:a,theirsHash:I},Me=await t?.hooks?.mergeMsg?.(xe);if(Q(Me))return{stdout:"",stderr:Me.message??"",exitCode:1};st=xe.message;let nn=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:st,treeHash:te,headHash:a,theirsHash:I});if(Q(nn))return{stdout:"",stderr:nn.message??"",exitCode:1};let er=await ut(s,te,[a,I],$e,Le,st);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:I,strategy:"three-way",commitHash:er}),await t?.hooks?.postPull?.({repo:s,remote:c,branch:m,strategy:"three-way",commitHash:er});let Ze=A?.type==="symbolic"?A.target:"HEAD",Er="pull: Merge made by the 'ort' strategy.";await Be(s,Ze,{oldHash:a,newHash:er,name:E.name,email:E.email,timestamp:E.timestamp,tz:E.tz,message:Er}),A?.type==="symbolic"&&await Be(s,"HEAD",{oldHash:a,newHash:er,name:E.name,email:E.email,timestamp:E.timestamp,tz:E.tz,message:Er});let Mi=await vn(s,D.tree,te);return{stdout:`${F.messages.length>0?`${F.messages.join(`
|
|
471
471
|
`)}
|
|
472
472
|
`:""}Merge made by the 'ort' strategy.
|
|
473
|
-
${
|
|
474
|
-
`);m.push({name:
|
|
475
|
-
`);let C=
|
|
476
|
-
`);let C=u.get(
|
|
473
|
+
${Mi}`,stderr:"",exitCode:0}}})}re();Ve();dt();ue();function Sf(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[q.string().name("remote").describe("Remote to push to").optional(),q.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:H().alias("f").describe("Force push"),"set-upstream":H().alias("u").describe("Set upstream tracking reference"),all:H().describe("Push all branches"),delete:H().alias("d").describe("Delete remote refs"),tags:H().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,a=n.remote||"origin",i;try{i=await wr(s,a,r.env)}catch(b){let k=b instanceof Error?b.message:"";if(k.startsWith("network"))return $(k);throw b}if(!i)return $(`'${a}' does not appear to be a git repository`);let{transport:c,config:f}=i,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 N(`error: unable to delete '${k}': remote ref does not exist
|
|
474
|
+
`);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 Oh(s,k.src);if(!R)return N(`error: src refspec '${k.src}' does not match any
|
|
475
|
+
`);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 N(`error: src refspec does not match any
|
|
476
|
+
`);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
|
|
477
477
|
`,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:a,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 N(p.message??"");let g=await c.push(m),w=[];w.push(`To ${f.url}
|
|
478
|
-
`);let y=!1;for(let b of g.updates){let
|
|
479
|
-
`),y=!0;else if(!b.oldHash)w.push(` * [new branch] ${
|
|
480
|
-
`);else if(b.newHash===J)w.push(` - [deleted] ${
|
|
481
|
-
`);else{let
|
|
482
|
-
`)}}if(n["set-upstream"]&&!y){let b=await Z(s);if(b?.type==="symbolic"){let
|
|
483
|
-
`)}}let
|
|
478
|
+
`);let y=!1;for(let b of g.updates){let k=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name;if(!b.ok)w.push(` ! [rejected] ${k} -> ${k} (${b.error??"failed"})
|
|
479
|
+
`),y=!0;else if(!b.oldHash)w.push(` * [new branch] ${k} -> ${k}
|
|
480
|
+
`);else if(b.newHash===J)w.push(` - [deleted] ${k}
|
|
481
|
+
`);else{let R=V(b.oldHash),C=V(b.newHash);w.push(` ${R}..${C} ${k} -> ${k}
|
|
482
|
+
`)}}if(n["set-upstream"]&&!y){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:a,merge:`refs/heads/${k}`},await Je(s,R),w.push(`branch '${k}' set up to track '${a}/${k}'.
|
|
483
|
+
`)}}let x={stdout:"",stderr:w.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:a,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 Oh(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();ke();ie();re();ie();rn();Gn();He();async function Pi(e,t){let n=await ge(e,t);if(n.type!=="commit")return null;let r=Vt(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ge(e,r.parents[0]);f.type==="commit"&&(o=Vt(f.content).tree)}let s=await Ne(e,o,r.tree);if(s.length===0)return null;let a=jn(),i=!1,c=[...s].sort((f,d)=>Re(f.path,d.path));for(let f of c){let d="",l="";if(f.oldHash)try{let m=await ge(e,f.oldHash);d=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await ge(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(`
|
|
484
484
|
`)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(a.update(p),a.update(`
|
|
485
|
-
`),i=!0)}}return i?a.hex():null}je();
|
|
485
|
+
`),i=!0)}}return i?a.hex():null}je();ue();He();Jt();et();async function Ih(e){let t=await Z(e);return t?.type==="symbolic"?we(t.target):"detached HEAD"}function vf(e){return e==="HEAD"?`HEAD is up to date.
|
|
486
486
|
`:`Current branch ${e} is up to date.
|
|
487
|
-
`}async function
|
|
488
|
-
`)}return null}async function
|
|
489
|
-
`,exitCode:128}:null}async function
|
|
487
|
+
`}async function $h(e,t,n){if(!e.workTree)return null;let r=await ce(e,t),o=new Map(Ae(n).map(i=>[i.path,i])),s=new Set(await Qe(e,e.workTree,"")),a=[];for(let[i]of r)o.has(i)||s.has(i)&&a.push({path:i,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(a.length>0){let i=$s(a,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return N(`${i.stderr}error: could not detach HEAD
|
|
488
|
+
`)}return null}async function Th(e,t,n,r){if(!e.workTree)return null;let o=await ce(e,t),s=new Set(n.entries.map(c=>c.path)),a=new Set(await Qe(e,e.workTree,"")),i=[];for(let[c]of o)!s.has(c)&&a.has(c)&&i.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return i.length>0?{stdout:"",stderr:`${$s(i,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
|
|
489
|
+
`,exitCode:128}:null}async function Af(e,t,n){if(!e.workTree)return null;let r=new Map(Ae(t).map(a=>[a.path,a])),o=new Set(await Qe(e,e.workTree,"")),s=[];for(let[a]of n)!r.has(a)&&o.has(a)&&s.push(a);return s.length>0?s:null}function Df(e,t){return`error: The following untracked working tree files would be overwritten by merge:
|
|
490
490
|
${e.map(r=>` ${r}`).join(`
|
|
491
491
|
`)}
|
|
492
492
|
Please move or remove them before you merge.
|
|
@@ -500,7 +500,7 @@ hint: edit the todo list first:
|
|
|
500
500
|
hint:
|
|
501
501
|
hint: git rebase --edit-todo
|
|
502
502
|
hint: git rebase --continue
|
|
503
|
-
`}async function
|
|
503
|
+
`}async function Oi(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 $h(e,o.tree,n);if(s)return s;let a=await cn(e,o.tree,n);return a.success&&(await se(e,{version:2,entries:a.newEntries}),await Se(e,a.worktreeOps)),r!=="detached HEAD"?await Y(e,r,t):await Y(e,"HEAD",t),null}function Mf(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[q.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:ee.string().describe("Starting point at which to create new commits"),abort:H().describe("Abort the current rebase operation"),continue:H().describe("Continue the rebase after conflict resolution"),skip:H().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 vh(s,r.env);if(n.continue)return Ah(s,r.env);if(n.skip)return Dh(s,r.env);let a=n.upstream;if(!a)return $("no upstream configured and no upstream argument given");if(await Dt(s))return $(`It seems that there is already a rebase-merge directory, and
|
|
504
504
|
I wonder if you are in the middle of another rebase. If that is the
|
|
505
505
|
case, please try
|
|
506
506
|
git rebase (--continue | --abort | --skip)
|
|
@@ -514,17 +514,17 @@ error: additionally, your index contains uncommitted changes.
|
|
|
514
514
|
error: Please commit or stash them.
|
|
515
515
|
`,exitCode:1};let w=await M(s,i),y=await ce(s,w.tree);if(s.workTree){let _=ar(p,y),D=(await $t(s,p)).some(W=>W.status==="modified"||W.status==="deleted");if(_||D){let W=[];return D&&W.push("error: cannot rebase: You have unstaged changes."),_&&(D?W.push("error: additionally, your index contains uncommitted changes."):W.push("error: cannot rebase: Your index contains uncommitted changes.")),W.push("error: Please commit or stash them."),N(`${W.join(`
|
|
516
516
|
`)}
|
|
517
|
-
`)}}let
|
|
518
|
-
`,exitCode:0})}return{stdout:
|
|
517
|
+
`)}}let x=await t?.hooks?.preRebase?.({repo:s,upstream:a,branch:c?.type==="symbolic"?we(c.target):null});if(Q(x))return{stdout:"",stderr:x.message??"",exitCode:1};let b=await Za(s,u,i),k=b.right;if(k.length===0){if(m!==i){let _=await lo(s,m,p,f);return _||(await Oi(s,r.env,i,m,f,a),{stdout:"",stderr:`Successfully rebased and updated ${f}.
|
|
518
|
+
`,exitCode:0})}return{stdout:vf(d),stderr:"",exitCode:0}}let R=[],C=b.left,P=new Set;for(let _ of C){let F=await Pi(s,_.hash);F&&P.add(F)}let E=[];if(P.size>0)for(let _ of k){let F=await Pi(s,_.hash);F&&P.has(F)?R.push(`warning: skipped previously applied commit ${V(_.hash)}`):E.push(_)}else E.push(...k);let O="";if(R.length>0&&(O=`${R.join(`
|
|
519
519
|
`)}
|
|
520
520
|
hint: use --reapply-cherry-picks to include skipped commits
|
|
521
521
|
hint: Disable this message with "git config set advice.skippedCherryPicks false"
|
|
522
|
-
`),
|
|
523
|
-
`,exitCode:0}}let I=
|
|
524
|
-
`,exitCode:0})}let A=await lo(s,
|
|
525
|
-
`};if(s&&s===i){let
|
|
526
|
-
`};let z=await qe(e,a.tree),A=await qe(e,o.tree),S=new Map(z.map(D=>[D.path,D.hash])),L=new Map;for(let D of A){let W=S.get(D.path);(!W||W!==D.hash)&&L.set(D.path,D.hash)}let _=await
|
|
527
|
-
`);return{conflict:!0,stdout:
|
|
522
|
+
`),E.length===0){if(m!==i){let _=await lo(s,m,p,f);if(_)return _.stderr=O+_.stderr,_;await Oi(s,r.env,i,m,f,a)}return{stdout:"",stderr:`${O}Successfully rebased and updated ${f}.
|
|
523
|
+
`,exitCode:0}}let I=E.map(_=>({hash:_.hash,subject:ae(_.commit.message)})),j=m,G=0;for(let _ of I){let F=await M(s,_.hash);if(F.parents.length>1||F.parents.length===0||F.parents[0]!==j)break;j=_.hash,G++}let z=I.splice(0,G);if(I.length===0){if(j===i)return{stdout:vf(d),stderr:O,exitCode:0};let _=await lo(s,j,p,f);return _?(_.stderr=O+_.stderr,_):(await Oi(s,r.env,i,j,f,a),{stdout:"",stderr:`${O}Successfully rebased and updated ${f}.
|
|
524
|
+
`,exitCode:0})}let A=await lo(s,j,p,"detached HEAD");if(A)return A.stderr=O+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",i,j,`rebase (start): checkout ${a}`);let S={headName:f,origHead:i,onto:m,todo:I,done:z,msgnum:G,end:G+I.length};await Yo(s,S),await Y(s,"ORIG_HEAD",i);let L=await Ii(s,r.env);return O&&(L.stderr=O+L.stderr),L}})}async function Ii(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 Xa(e);let a=await Hh(e,s,t);if(a.conflict){if(a.rescheduleCurrent){let i=await ht(e);i&&(i.todo=[s,...i.todo],await Yo(e,i))}return a.stdout&&r.push(a.stdout),n.push(a.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}a.stdout&&r.push(a.stdout),a.stderr&&n.push(a.stderr)}return Sh(e,n,t)}async function Hh(e,t,n){let r=t.hash,o=await M(e,r),s=o.parents.length>0?o.parents[0]:null,a=s?await M(e,s):null,i=await X(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
|
|
525
|
+
`};if(s&&s===i){let G=await K(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
|
|
526
|
+
`};let z=await qe(e,a.tree),A=await qe(e,o.tree),S=new Map(z.map(D=>[D.path,D.hash])),L=new Map;for(let D of A){let W=S.get(D.path);(!W||W!==D.hash)&&L.set(D.path,D.hash)}let _=await Af(e,G,L);if(_)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:Df(_,t),rescheduleCurrent:!0};let F=await cn(e,o.tree,G);return F.success&&(await se(e,{version:2,entries:F.newEntries}),await Se(e,F.worktreeOps)),await yn(e,r),await ne(e,n,"HEAD",i,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await M(e,i),f=a?a.tree:null,d=V(r),l=ae(o.message),u={a:"HEAD",b:l?`${d} (${l})`:d},m=await Lt(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)]),y=new Set;for(let G of g)y.add(G.path);for(let G of p)y.add(G.path);for(let G of w)y.add(G.path);let x=h.entries.filter(G=>!y.has(G.path)),b=[...m.entries,...x];b.sort((G,z)=>Re(G.path,z.path)||G.stage-z.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])),E=new Map;for(let G of R){let z=P.get(G.path);(!z||z.hash!==G.hash)&&E.set(G.path,G.hash)}for(let G of m.conflicts){if(G.reason==="content"||G.reason==="add-add"){E.set(G.path,null);continue}if(G.reason==="delete-modify"){let z=m.entries.filter(L=>L.path===G.path&&L.stage>0),A=z.find(L=>L.stage===2),S=z.find(L=>L.stage===3);S&&!A&&E.set(G.path,S.hash)}}let O=await Af(e,h,E);if(O)return await Y(e,"REBASE_HEAD",r),await Ls(e,r,o.author),{conflict:!0,stdout:"",stderr:Df(O,t),rescheduleCurrent:!0};if(await se(e,k),e.workTree){let G=await Cn(e,c.tree,m.resultTree,h);G.success&&await Se(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(`
|
|
527
|
+
`);return{conflict:!0,stdout:G?`${G}
|
|
528
528
|
`:"",stderr:`error: could not apply ${d}... ${t.subject}
|
|
529
529
|
hint: Resolve all conflicts manually, mark them as resolved with
|
|
530
530
|
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
|
|
@@ -533,8 +533,8 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
|
|
|
533
533
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
534
534
|
Could not apply ${d}... # ${t.subject}
|
|
535
535
|
`}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
|
|
536
|
-
`};let I=await
|
|
537
|
-
`;return await fe(e,"REBASE_HEAD"),await
|
|
536
|
+
`};let I=await Xe(e,n);if(v(I))return{conflict:!0,stdout:"",stderr:I.stderr};let j=await ut(e,C,[i],o.author,I,o.message);return await ne(e,n,"HEAD",i,j,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Sh(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 a=`Successfully rebased and updated ${r.headName}.
|
|
537
|
+
`;return await fe(e,"REBASE_HEAD"),await zn(e),await Xo(e),{stdout:"",stderr:t.join("")+a,exitCode:0}}async function vh(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),a=await K(e),i=await Th(e,s.tree,a,o);if(i)return i;let c=await cn(e,s.tree,a);c.success&&(await se(e,{version:2,entries:c.newEntries}),await Se(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 Ah(e,t){let n="";if(!await ht(e))return $("no rebase in progress");let o=await K(e);if(It(o))return N(`error: Committing is not possible because you have unmerged files.
|
|
538
538
|
hint: Fix them up in the work tree, and then use 'git add <file>'
|
|
539
539
|
hint: as appropriate to mark resolution and make a commit.
|
|
540
540
|
fatal: Exiting because of an unresolved conflict.
|
|
@@ -551,37 +551,37 @@ In both cases, once you're done, continue with:
|
|
|
551
551
|
|
|
552
552
|
git rebase --continue
|
|
553
553
|
|
|
554
|
-
`);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 Ee(e,"rebase-merge/message")??await Ee(e,"MERGE_MSG")??void 0,g&&(g=en(g)),g||(g=m.message);let w=await
|
|
555
|
-
${
|
|
554
|
+
`);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 Ee(e,"rebase-merge/message")??await Ee(e,"MERGE_MSG")??void 0,g&&(g=en(g)),g||(g=m.message);let w=await Xe(e,t);if(v(w))return w;let y=St(g),x=[i],b=await U(e,"MERGE_HEAD");b&&x.push(b);let k=await ut(e,d,x,p.author,w,y);b&&(await fe(e,"MERGE_HEAD"),await he(e,"MERGE_MODE"));let R=ae(y);await ne(e,t,"HEAD",i,k,`rebase (continue): ${R}`);let C=await Ih(e),P=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,E=await tn(e,c.tree,d,p.author,w,P);n=`${Ht(C,k,y)}
|
|
555
|
+
${E}`}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 a=await Ii(e,t);return n&&(a.stdout=n+a.stdout),a}async function Dh(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
|
|
556
556
|
fatal: could not discard worktree changes
|
|
557
|
-
`,exitCode:128};let o=await M(e,r),s=await K(e),a=await
|
|
557
|
+
`,exitCode:128};let o=await M(e,r),s=await K(e),a=await cn(e,o.tree,s);return a.success&&(await se(e,{version:2,entries:a.newEntries}),await Se(e,a.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"),Ii(e,t)}re();de();je();ue();function Mh(e,t,n,r){return`${V(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.
|
|
558
558
|
Use '--' to separate paths from revisions, like this:
|
|
559
559
|
'git <command> [<revision>...] -- [<file>...]'
|
|
560
|
-
`,exitCode:128};let s=await
|
|
560
|
+
`,exitCode:128};let s=await Ye(e,r),a=[],i=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<i;d--){let l=s[d];if(!l)continue;let u=s.length-1-d;l.newHash!==J&&(a.push(Mh(t,u,l.newHash,l.message)),c++)}return{stdout:a.length>0?`${a.join(`
|
|
561
561
|
`)}
|
|
562
|
-
`:"",stderr:"",exitCode:0}}function
|
|
563
|
-
`,exitCode:128};let d=T(a.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await a.fs.exists(d)?0:1}}return uo(a,c,r.maxCount)}})}re();
|
|
562
|
+
`:"",stderr:"",exitCode:0}}function jf(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:ee.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 a=s,i=r.args;if(i.length===0)return uo(a,"HEAD",r.maxCount);let c=i[0];if(!c)return uo(a,"HEAD",r.maxCount);if(c==="show"){let f=i[1]??"HEAD";return uo(a,f,r.maxCount)}if(c==="exists"){let f=i[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
|
|
563
|
+
`,exitCode:128};let d=T(a.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await a.fs.exists(d)?0:1}}return uo(a,c,r.maxCount)}})}re();Ve();je();ue();function jh(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 Gf(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:H().alias("v").describe("Show remote URLs")},handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i),f=jh(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(`
|
|
564
564
|
`)}
|
|
565
565
|
`,stderr:"",exitCode:0}}return{stdout:`${f.join(`
|
|
566
566
|
`)}
|
|
567
|
-
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await
|
|
568
|
-
`,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await
|
|
569
|
-
`,2)},o=[q.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:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await
|
|
570
|
-
`,2);let d=c[f];return d&&(d.url=s.url),await
|
|
567
|
+
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i),f=`remote "${s.name}"`;return f in c?N(`error: remote ${s.name} already exists.
|
|
568
|
+
`,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Je(i,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i),f=`remote "${s.name}"`;return f in c?(delete c[f],Lh(c,s.name),await Je(i,c),await _h(i,s.name),{stdout:"",stderr:"",exitCode:0}):N(`error: No such remote: '${s.name}'
|
|
569
|
+
`,2)},o=[q.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:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i);return Gh(i,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("New remote URL")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i),f=`remote "${s.name}"`;if(!(f in c))return N(`error: No such remote '${s.name}'
|
|
570
|
+
`,2);let d=c[f];return d&&(d.url=s.url),await Je(i,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(v(i))return i;let c=await le(i),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
|
|
571
571
|
`,stderr:"",exitCode:0}:N(`error: No such remote '${s.name}'
|
|
572
|
-
`,2)}})}async function
|
|
573
|
-
`,2);let s=`remote "${r}"`;if(s in t)return $(`remote ${r} already exists.`);let a={...t[o]};a.fetch&&(a.fetch=a.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=a,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await
|
|
572
|
+
`,2)}})}async function Gh(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return N(`error: No such remote: '${n}'
|
|
573
|
+
`,2);let s=`remote "${r}"`;if(s in t)return $(`remote ${r} already exists.`);let a={...t[o]};a.fetch&&(a.fetch=a.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=a,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Je(e,t);let i=`refs/remotes/${n}`,c=await pe(e,i);for(let f of c){let d=f.name.replace(i,`refs/remotes/${r}`),l=await Ye(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 Lh(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 _h(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await fe(e,o.name)}re();ke();ie();de();je();ue();on();He();Jt();et();function _f(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:H().describe("Only move HEAD"),mixed:H().describe("Move HEAD and reset index (default)"),hard:H().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 a=s,i=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(a,r.cwd);if(o.passthrough.length>0){let m=i.length>0?i[0]:void 0;return $i(a,o.passthrough,d,m,t)}if(!f&&i.length>0){let m=i[0],h=await We(a,m);return i.length===1&&h?Lf(a,m,"mixed",r.env,t):h?$i(a,i.slice(1),d,m,t):$i(a,i,d,void 0,t)}let l=n.soft?"soft":n.hard?"hard":"mixed",u=i.length>0?i[0]:"HEAD";return Lf(a,u,l,r.env,t)}})}async function $i(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 a=null;if(r){let l=await We(e,r);if(!l)return Ut(r);let u=await _e(e,l);a=(await M(e,u)).tree}else{let l=await X(e);l&&(a=(await M(e,l)).tree)}let i=await ce(e,a??null),c=await K(e);if(t.some(Wn)){let l=t.map(m=>Ge(m,n)),u=new Set;for(let[m]of i)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!be(l,m))continue;let h=i.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=i.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 Ut(l)}await se(e,c);let d={stdout:await Nf(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),d}async function Nf(e,t){if(!e.workTree)return"";let n=new Set;for(let a of t.entries)a.stage>0&&n.add(a.path);let o=(await $t(e,t)).filter(a=>a.status==="modified"||a.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let a of o){let i=a.status==="modified"?"M":"D";s.push(`${i} ${a.path}`)}for(let a of[...n].sort())s.push(`U ${a}`);return s.sort((a,i)=>{if(a==="Unstaged changes after reset:")return-1;if(i==="Unstaged changes after reset:")return 1;let c=a.slice(2),f=i.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
|
|
574
574
|
`)}
|
|
575
|
-
`}async function
|
|
576
|
-
`:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:i}),{stdout:u,stderr:"",exitCode:0}}re();ke();ie();
|
|
575
|
+
`}async function Lf(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 a=await We(e,t);if(!a)return Ut(t);let i=await _e(e,a),c=await M(e,i);if(n==="soft"){let m=await U(e,"MERGE_HEAD"),h=await K(e);if(m||It(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,i):await Y(e,"HEAD",i);let l=`reset: moving to ${t}`;if(d?.type==="symbolic"&&f!==i?await ne(e,r,d.target,f,i,l,!0):(d?.type==="symbolic"||f!==i)&&await ne(e,r,"HEAD",f,i,l),await zn(e),n==="mixed"){let m=await qe(e,c.tree),h=ms(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 Nf(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:i}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=Ke(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 Se(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${V(i)} ${ae(c.message)}
|
|
576
|
+
`:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:i}),{stdout:u,stderr:"",exitCode:0}}re();ke();ie();ue();He();et();function Ff(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:ee.string().alias("s").describe("Restore from tree-ish"),staged:H().alias("S").describe("Restore the index"),worktree:H().alias("W").describe("Restore the working tree (default)"),ours:H().describe("Checkout our version for unmerged files"),theirs:H().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 a=s,i=[...n.pathspec??[],...o.passthrough];if(i.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(a,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(a,i,d,n.theirs?3:2,{deleteOnMissing:!0});let l=null;if(n.source){let u=await Ie(a,n.source,`could not resolve '${n.source}'`);if(v(u))return u;l=u.commit.tree}else if(c){let u=await X(a);u&&(l=(await M(a,u)).tree)}return c&&f?Uh(a,i,d,l):c?Nh(a,i,d,l):l?Fh(a,i,d,l):Fs(a,i,d)}})}async function Nh(e,t,n,r){let o=await ce(e,r),s=await K(e),a=t.map(f=>Ge(f,n)),i=new Set;for(let[f]of o)i.add(f);for(let f of s.entries)i.add(f.path);let c=!1;for(let f of i){if(!be(a,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
|
|
577
577
|
`,exitCode:1};s=ot(s,f)}}return c?(await se(e,s),{stdout:"",stderr:"",exitCode:0}):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
578
|
-
`)}async function
|
|
578
|
+
`)}async function Fh(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)),a=[],i=await K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of i.entries)c.add(f.path);for(let f of c)if(be(s,f)){if(!o.has(f)&&i.entries.some(l=>l.path===f&&l.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
579
579
|
`,exitCode:1};a.push(f)}if(a.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
580
|
-
`);for(let f of a){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
|
|
580
|
+
`);for(let f of a){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 Uh(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),a=t.map(f=>Ge(f,n)),i=[],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)be(a,f)&&i.push(f);if(i.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
581
581
|
`);for(let f of i){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
|
|
582
|
-
`,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();
|
|
583
|
-
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return $("Needed a single revision");for(let b of o){if(i){let
|
|
584
|
-
`).join(""),stderr:"",exitCode:0}}})}function
|
|
582
|
+
`,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 Uf(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[q.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:H().describe("Verify that exactly one parameter is provided and resolves to an object"),short:H().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":H().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":H().describe("Output the full symbolic ref name"),"show-toplevel":H().describe("Show the absolute path of the top-level directory"),"git-dir":H().describe("Show the path to the .git directory"),"is-inside-work-tree":H().describe("Output whether cwd is inside the work tree"),"is-bare-repository":H().describe("Output whether the repository is bare"),"show-prefix":H().describe("Show path of cwd relative to top-level directory"),"show-cdup":H().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,a=n.short,i=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,y=[];if(f){if(!w.workTree)return $("this operation must be run in a work tree");y.push(w.workTree)}if(d&&y.push(w.gitDir),l&&y.push(w.workTree?"true":"false"),u&&y.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);y.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);y.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:y.map(k=>`${k}
|
|
583
|
+
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return $("Needed a single revision");for(let b of o){if(i){let R=await Bh(w,b);if(R===null)return Ti(b,s);y.push(R);continue}if(c){let R=await Wh(w,b);if(R===null)return Ti(b,s);y.push(R);continue}let k=await We(w,b);if(!k)return Ti(b,s);y.push(a?V(k):k)}return{stdout:y.map(b=>`${b}
|
|
584
|
+
`).join(""),stderr:"",exitCode:0}}})}function Ti(e,t){return t?$("Needed a single revision"):Ut(e)}async function Bh(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 Wh(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();ke();ie();je();ue();He();function Bf(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:H().describe("Abort the current revert operation"),continue:H().describe("Continue the revert after conflict resolution"),"no-commit":H().alias("n").describe("Apply changes without creating a commit"),"no-edit":H().describe("Do not edit the commit message"),mainline:ee.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 _=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(Q(_))return{stdout:"",stderr:_.message??"",exitCode:1};let F=await qh(s,r.env);return F.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),F}if(n.continue){let _=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(Q(_))return{stdout:"",stderr:_.message??"",exitCode:1};let F=await Kh(s,r.env);return F.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),F}let a=n.commit;if(!a)return $("you must specify a commit to revert");let i=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:a});if(Q(i))return{stdout:"",stderr:i.message??"",exitCode:1};let c=await Ie(s,a);if(v(c))return c;let f=c.hash,d=c.commit,l=await ze(s);if(v(l))return l;let u=await K(s),m=fn(u,"Reverting",`fatal: revert failed
|
|
585
585
|
`);if(m)return m;let h=await M(s,l);if(s.workTree){let _=await ce(s,h.tree);if(ar(u,_))return N(`error: your local changes would be overwritten by revert.
|
|
586
586
|
hint: commit your changes or stash them to proceed.
|
|
587
587
|
fatal: revert failed
|
|
@@ -589,7 +589,7 @@ fatal: revert failed
|
|
|
589
589
|
fatal: revert failed
|
|
590
590
|
`,128);if(p<1||p>d.parents.length)return N(`error: commit ${f} does not have parent ${p}
|
|
591
591
|
fatal: revert failed
|
|
592
|
-
`,128);let _=d.parents[p-1];g=(await M(s,_)).tree}else if(d.parents.length===0)g=await De(s,[]);else{let _=d.parents[0];g=(await M(s,_)).tree}let w=V(f),y=ae(d.message),
|
|
592
|
+
`,128);let _=d.parents[p-1];g=(await M(s,_)).tree}else if(d.parents.length===0)g=await De(s,[]);else{let _=d.parents[0];g=(await M(s,_)).tree}let w=V(f),y=ae(d.message),x=zh(d,f,p),b={a:"HEAD",b:y?`parent of ${w} (${y})`:`parent of ${w}`},k=await Lt(s,d.tree,h.tree,g,b);if(k.conflicts.length===0&&k.resultTree===h.tree){let _=k.messages.length>0?`${k.messages.join(`
|
|
593
593
|
`)}
|
|
594
594
|
`:"",F=await nt(s,{fromCommit:!0}),D=await U(s,"CHERRY_PICK_HEAD");return{stdout:`${_}${F}`,stderr:D?`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
595
595
|
If you wish to commit it anyway, use:
|
|
@@ -597,7 +597,7 @@ If you wish to commit it anyway, use:
|
|
|
597
597
|
git commit --allow-empty
|
|
598
598
|
|
|
599
599
|
Otherwise, please use 'git cherry-pick --skip'
|
|
600
|
-
`:"",exitCode:1}}let
|
|
600
|
+
`:"",exitCode:1}}let R=await mn(s,k,h.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!R.ok)return R;if(k.conflicts.length>0){await Y(s,"REVERT_HEAD",f),await Y(s,"ORIG_HEAD",l),await Oe(s,"MERGE_MSG",x);let _=k.messages.join(`
|
|
601
601
|
`);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:_?`${_}
|
|
602
602
|
`:"",stderr:`error: could not revert ${w}... ${ae(d.message)}
|
|
603
603
|
hint: After resolving the conflicts, mark them with
|
|
@@ -607,28 +607,28 @@ hint: You can instead skip this commit with "git revert --skip".
|
|
|
607
607
|
hint: To abort and get back to the state before "git revert",
|
|
608
608
|
hint: run "git revert --abort".
|
|
609
609
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
610
|
-
`,exitCode:1}}if(n["no-commit"])return await Y(s,"REVERT_HEAD",f),await Oe(s,"MERGE_MSG",
|
|
610
|
+
`,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 Qt(s,r.env);if(v(P))return P;let E=await Xe(s,r.env);if(v(E))return E;let O=await ut(s,C,[l],P,E,x);await At(s),await Bt(s);let I=await Z(s),j=ae(x),G=I?.type==="symbolic"?I.target:"HEAD";await ne(s,r.env,G,l,O,`revert: ${j}`,I?.type==="symbolic");let z=I?.type==="symbolic"?we(I.target):"detached HEAD",A=await tn(s,h.tree,C,P,E,P.timestamp!==E.timestamp||P.timezone!==E.timezone),S=Ht(z,O,x),L=k.messages.length>0?`${k.messages.join(`
|
|
611
611
|
`)}
|
|
612
|
-
`:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:
|
|
613
|
-
${A}`,stderr:"",exitCode:0}}})}async function
|
|
612
|
+
`:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:O,hadConflicts:!1}),{stdout:`${L}${S}
|
|
613
|
+
${A}`,stderr:"",exitCode:0}}})}async function qh(e,t){return await U(e,"REVERT_HEAD")?Pn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
|
|
614
614
|
fatal: revert failed
|
|
615
|
-
`,128),operationName:"revert",clearState:At,origHeadAsTargetRev:!0}):await U(e,"CHERRY_PICK_HEAD")?
|
|
615
|
+
`,128),operationName:"revert",clearState:At,origHeadAsTargetRev:!0}):await U(e,"CHERRY_PICK_HEAD")?Pn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
|
|
616
616
|
fatal: revert failed
|
|
617
617
|
`,128),operationName:"revert",clearState:Bt,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
|
|
618
618
|
fatal: revert failed
|
|
619
|
-
`,128)}async function
|
|
619
|
+
`,128)}async function Kh(e,t){if(!await U(e,"REVERT_HEAD"))return N(`error: no cherry-pick or revert in progress
|
|
620
620
|
fatal: revert failed
|
|
621
|
-
`,128);let r=await K(e),o=
|
|
622
|
-
`,1);let a=Ae(r),i=await De(e,a),c=await ze(e);if(v(c))return c;let f=await M(e,c),d=await Qt(e,t);if(v(d))return d;let l=await
|
|
623
|
-
${
|
|
621
|
+
`,128);let r=await K(e),o=fn(r,"Committing");if(o)return o;let s=await Ee(e,"MERGE_MSG");if(!s)return N(`Aborting commit due to empty commit message.
|
|
622
|
+
`,1);let a=Ae(r),i=await De(e,a),c=await ze(e);if(v(c))return c;let f=await M(e,c),d=await Qt(e,t);if(v(d))return d;let l=await Xe(e,t);if(v(l))return l;let u=await U(e,"CHERRY_PICK_HEAD");u&&(d=(await M(e,u)).author);let m=St(s),h=await ut(e,i,[c],d,l,m);await At(e),await Bt(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 y=p?.type==="symbolic"?we(p.target):"detached HEAD",x=await tn(e,f.tree,i,d,l,d.timestamp!==l.timestamp||d.timezone!==l.timezone);return{stdout:`${Ht(y,h,s)}
|
|
623
|
+
${x}`,stderr:"",exitCode:0}}function zh(e,t,n){let r=ae(e.message),o='Revert "',i=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
|
|
624
624
|
|
|
625
625
|
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];i+=`, reversing
|
|
626
626
|
changes made to ${c}`}return i+=`.
|
|
627
|
-
`,i}re();ke();ie();de();
|
|
627
|
+
`,i}re();ke();ie();de();ue();_n();He();function Wf(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[q.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:H().describe("Only remove from the index"),recursive:H().alias("r").describe("Allow recursive removal when a directory name is given"),force:H().alias("f").describe("Override the up-to-date check"),dryRun:H().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,a=Ke(s);if(a)return a;let i=s.workTree,c=n.paths;if(c.length===0)return N("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 y of c){if(Wn(y)){let R=[Ge(y,p)],C=m.entries.filter(P=>be(R,P.path));if(C.length===0)return $(`pathspec '${y}' did not match any files`);for(let P of C)h.push(P.path);continue}let x=Pt(r.cwd,y),b=at(i,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return $(`'${y}' is outside repository at '${i}'`);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 '${y}' 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 '${y}' did not match any files`);h.push(b)}}if(!l){let y=await Vh(s,m,h,f);if(y)return y}if(n.dryRun){let y=h.map(b=>`rm '${b}'`);return{stdout:y.length>0?`${y.join(`
|
|
628
628
|
`)}
|
|
629
|
-
`:"",stderr:"",exitCode:0}}let g=[];for(let y of h){if(m=ot(m,y),!f){let
|
|
629
|
+
`:"",stderr:"",exitCode:0}}let g=[];for(let y of h){if(m=ot(m,y),!f){let x=T(i,y);await ct(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}g.push(`rm '${y}'`)}await se(s,m);let w=g.length>0?`${g.join(`
|
|
630
630
|
`)}
|
|
631
|
-
`:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function
|
|
631
|
+
`:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function Vh(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 a=[],i=[],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?a.push(f):u&&!r?i.push(f):m&&!r&&c.push(f)}if(a.length>0){let f=a.map(l=>` ${l}`).join(`
|
|
632
632
|
`),d=a.length===1?"the following file has":"the following files have";return N(`error: ${d} staged content different from both the
|
|
633
633
|
file and the HEAD:
|
|
634
634
|
${f}
|
|
@@ -641,72 +641,72 @@ ${f}
|
|
|
641
641
|
`),d=c.length===1?"the following file has":"the following files have";return N(`error: ${d} local modifications:
|
|
642
642
|
${f}
|
|
643
643
|
(use --cached to keep the file, or -f to force removal)
|
|
644
|
-
`)}return null}re();ie();
|
|
645
|
-
`))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await M(e,n.parents[0])).tree:null,a=await Ne(e,s,n.tree),{remaining:i,renames:c}=await tt(e,a),f=await
|
|
644
|
+
`)}return null}re();ie();on();ks();de();He();var Hi=new TextDecoder;function qf(e,t){e.command("show",{description:"Show various types of objects",args:[q.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,i=n.object[0]??"HEAD",c=Pa(i);if(c)return Yh(s,c.rev,c.path);if(i==="HEAD"){let l=await ze(s);if(v(l))return l}let f=await Tt(s,i,`bad object '${i}'`);if(v(f))return f;let d=await ge(s,f);switch(d.type){case"commit":{let l=await M(s,f);return{stdout:await Kf(s,f,l),stderr:"",exitCode:0}}case"tag":{let l=await ba(s,f);return{stdout:await Xh(s,l),stderr:"",exitCode:0}}case"tree":{let l=xn(d.content);return{stdout:zf(l),stderr:"",exitCode:0}}case"blob":return{stdout:Hi.decode(d.content),stderr:"",exitCode:0}}}})}async function Yh(e,t,n){let r=await Ie(e,t);if(v(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),i=(await ce(e,o)).get(s);if(!i){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 ge(e,i.hash);if(c.type==="blob")return{stdout:Hi.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=xn(c.content);return{stdout:zf(f),stderr:"",exitCode:0}}return{stdout:Hi.decode(c.content),stderr:"",exitCode:0}}async function Kf(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(a=>V(a)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${jt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
|
|
645
|
+
`))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await M(e,n.parents[0])).tree:null,a=await Ne(e,s,n.tree),{remaining:i,renames:c}=await tt(e,a),f=await Qh(e,i,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await ep(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
|
|
646
646
|
`)}
|
|
647
|
-
`}async function
|
|
648
|
-
`))n.push(` ${o}`);if(t.objectType==="commit"){let o=await M(e,t.object),s=await
|
|
647
|
+
`}async function Xh(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${jt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
|
|
648
|
+
`))n.push(` ${o}`);if(t.objectType==="commit"){let o=await M(e,t.object),s=await Kf(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
|
|
649
649
|
`)}
|
|
650
|
-
`}function
|
|
650
|
+
`}function zf(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(`
|
|
651
651
|
`)}
|
|
652
|
-
`:""}async function
|
|
653
|
-
`,
|
|
654
|
-
`,$e=Yt({type:"commit",tree:W,parents:[],author:p,committer:g,message:te});
|
|
652
|
+
`:""}async function Zh(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 Jh(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 Qh(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,a)=>{let i=s.type==="diff"?s.entry.path:s.entry.newPath,c=a.type==="diff"?a.entry.path:a.entry.newPath;return i<c?-1:i>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await Jh(e,s.entry):o+=await Zh(e,s.entry);return o}async function ep(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async i=>{let c=await M(e,i);return ce(e,c.tree)})),r=await ce(e,t.tree),o=new Set;for(let i of n)for(let c of i.keys())o.add(c);for(let i of r.keys())o.add(i);let s=[];for(let i of o){let f=r.get(i)?.hash??null;n.every(l=>(l.get(i)?.hash??null)!==f)&&s.push(i)}if(s.sort(),s.length===0)return"";let a="";for(let i of s)a+=await tp(e,i,n,r);return a}async function tp(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),a=o?.hash??null,i=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=a?await oe(e,a):"";return oo({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:a,resultMode:i,resultContent:l})}re();ke();ie();ue();re();hn();ke();ie();rn();de();je();ue();He();Jt();et();var qt="refs/stash";function vi(e,t){return Re(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Vf(e){let t=await Ye(e,qt),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 yr(e,t){let n=await Ye(e,qt);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 Yf(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 a=await M(e,s),i=await K(e),c=Ae(i),f=await De(e,c),d=await Ne(e,a.tree,f),l=new Map(c.map(D=>[D.path,D])),u=await Qe(e,o,"",{skipIgnore:!0}),m=!1;for(let D of u){let W=l.get(D);if(!W)continue;let te=T(o,D),$e=await e.fs.readFileBuffer(te);if(await bt("blob",$e)!==W.hash){m=!0;break}}if(!m)for(let[D]of l){let W=T(o,D);if(!await e.fs.exists(W)){m=!0;break}}let h=[];if(r?.includeUntracked){let D=await Qe(e,o,"");for(let W of D)l.has(W)||h.push(W)}if(d.length===0&&!m&&h.length===0)return null;let p=await ds(e,t),g=await Cr(e,t),w=await Z(e),y=w?.type==="symbolic"?we(w.target):"(no branch)",x=V(s),b=ae(a.message),k=`index on ${y}: ${x} ${b}
|
|
653
|
+
`,R=Yt({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),C=await Pe(e,"commit",R),P=await ce(e,a.tree),E=[],O=new Set;for(let D of u){let W=l.get(D),te=P.get(D);if(!W&&!te)continue;let $e=T(o,D),Le=await e.fs.readFileBuffer($e),st=await Pe(e,"blob",Le),xe=W?W.mode:parseInt(te?.mode??"100644",8);E.push({path:D,mode:xe,hash:st,stage:0,stat:Ce()}),O.add(D)}for(let[D,W]of l)O.has(D)||P.has(D)||E.push({path:D,mode:W.mode,hash:W.hash,stage:0,stat:Ce()});let I=await De(e,E),j=null;if(r?.includeUntracked){let D=[];for(let Le of h){let st=T(o,Le),xe=await e.fs.readFileBuffer(st),Me=await Pe(e,"blob",xe);D.push({path:Le,mode:33188,hash:Me,stage:0,stat:Ce()})}let W=await De(e,D),te=`untracked files on ${y}: ${x} ${b}
|
|
654
|
+
`,$e=Yt({type:"commit",tree:W,parents:[],author:p,committer:g,message:te});j=await Pe(e,"commit",$e)}let G=n?`On ${y}: ${n}`:`WIP on ${y}: ${x} ${b}`,z=[s,C];j&&z.push(j);let A=Yt({type:"commit",tree:I,parents:z,author:p,committer:g,message:G}),S=await Pe(e,"commit",A),L=await yr(e,0)??J;await Be(e,qt,{oldHash:L,newHash:S,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:G.trimEnd()}),await Y(e,qt,S);let _=await cn(e,a.tree,i);await se(e,{version:2,entries:_.newEntries}),await Se(e,_.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 W=T(e.gitDir,D);await e.fs.exists(W)&&await e.fs.rm(W)}if(h.length>0)for(let D of h){if(P.has(D))continue;let W=T(o,D);await e.fs.exists(W)&&(await e.fs.rm(W),await Un(e.fs,Kt(W),o))}return S}async function Si(e,t){let n=e.workTree,r=await M(e,t),o=await qe(e,r.tree),s=[];for(let a of o){let i=T(n,a.path);await e.fs.exists(i)?s.push(a.path):await it(e,a)}return s.length>0?(s.sort(vi),{ok:!1,stdout:"",stderr:`${s.map(a=>`${a} already exists, no checkout`).join(`
|
|
655
655
|
`)}
|
|
656
656
|
error: could not restore untracked files from stash
|
|
657
|
-
`,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function
|
|
657
|
+
`,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ai(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
|
|
658
658
|
`,exitCode:128};let n=await yr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
|
|
659
659
|
`,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
|
|
660
|
-
`,exitCode:1};let o=await K(e),s=Nt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(
|
|
660
|
+
`,exitCode:1};let o=await K(e),s=Nt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(P=>`${P}: needs merge`).join(`
|
|
661
661
|
`)}
|
|
662
662
|
`,stderr:`error: could not write index
|
|
663
663
|
`,exitCode:1};let a=await M(e,n),i=a.parents[0];if(!i)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
|
|
664
|
-
`,exitCode:1};let c=await M(e,i),f=a.parents[2],d=Ae(o),l=await De(e,d),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===a.tree){if(f){let C=await
|
|
665
|
-
${y.map(
|
|
664
|
+
`,exitCode:1};let c=await M(e,i),f=a.parents[2],d=Ae(o),l=await De(e,d),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===a.tree){if(f){let C=await Si(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 Lt(e,c.tree,l,a.tree,u),h=await ce(e,l),p=await ce(e,m.resultTree),g=[];for(let[C,P]of p){let E=h.get(C);(!E||E.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])),y=[],x=[];for(let C of g){let P=w.get(C.path),E=T(e.workTree,C.path);if(P){if(!await e.fs.exists(E))continue;let O=await e.fs.readFileBuffer(E);await bt("blob",O)!==P.hash&&y.push(C.path)}else C.type==="checkout"&&await e.fs.exists(E)&&x.push(C.path)}if(y.length>0||x.length>0){y.sort(vi),x.sort(vi);let C="";if(y.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
|
|
665
|
+
${y.map(P=>` ${P}`).join(`
|
|
666
666
|
`)}
|
|
667
667
|
Please commit your changes or stash them before you merge.
|
|
668
|
-
`),
|
|
669
|
-
${
|
|
668
|
+
`),x.length>0&&(C+=`error: The following untracked working tree files would be overwritten by merge:
|
|
669
|
+
${x.map(P=>` ${P}`).join(`
|
|
670
670
|
`)}
|
|
671
671
|
Please move or remove them before you merge.
|
|
672
672
|
`),C+=`Aborting
|
|
673
|
-
`,f){let
|
|
673
|
+
`,f){let P=await Si(e,f);P.ok||(C+=P.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await Se(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,E]of p){if(b.has(P)||k.has(P))continue;let O=w.get(P);C.push({path:P,mode:parseInt(E.mode,8),hash:E.hash,stage:0,stat:O?.stat??Ce()})}for(let P of m.entries)P.stage>0&&C.push(P);C.sort((P,E)=>Re(P.path,E.path)||P.stage-E.stage),await se(e,{version:2,entries:C})}else{let C=[...o.entries],P=new Set(C.map(E=>E.path));for(let[E,O]of p)h.has(E)||P.has(E)||C.push({path:E,mode:parseInt(O.mode,8),hash:O.hash,stage:0,stat:Ce()});C.sort((E,O)=>Re(E.path,O.path)||E.stage-O.stage),await se(e,{version:2,entries:C})}if(f){let C=await Si(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:R,messages:m.messages}}async function Di(e,t=0){let n=await Ye(e,qt);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,qt),await Dr(e,qt);else{await kn(e,qt,n);let o=n[n.length-1];o&&await Y(e,qt,o.newHash)}return null}async function Xf(e){await fe(e,qt),await Dr(e,qt)}He();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 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})}async function Dn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function Mn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function Jf(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:ee.string().alias("m").describe("Stash message"),"include-untracked":H().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],a=[];for(let i of o)i.startsWith("-")?s.push(i):a.push(i);return a.length>0?[...s,"-m",a.join(" ")]:s},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(v(s))return s;let a=await Dn(t,s,"push",null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Zf(s,o.env,r.message,r["include-untracked"]);return await Mn(t,s,"push",i.exitCode===0),i}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:ee.string().alias("m").describe("Stash message"),"include-untracked":H().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 a=await Dn(t,s,"push",null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Zf(s,o.env,r.message,r["include-untracked"]);return await Mn(t,s,"push",i.exitCode===0),i}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.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 a=await Dn(t,s,"pop",r.stash??null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await rp(s,r.stash);return await Mn(t,s,"pop",i.exitCode===0),i}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.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 a=await Dn(t,s,"apply",r.stash??null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await sp(s,r.stash);return await Mn(t,s,"apply",i.exitCode===0),i}}),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 a=await Dn(t,s,"list",null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await op(s);return await Mn(t,s,"list",i.exitCode===0),i}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.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 a=await Dn(t,s,"drop",r.stash??null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await ip(s,r.stash);return await Mn(t,s,"drop",i.exitCode===0),i}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[q.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 a=await Dn(t,s,"show",r.stash??null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await ap(s,r.stash);return await Mn(t,s,"show",i.exitCode===0),i}}),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 a=await Dn(t,s,"clear",null);if(Q(a))return{stdout:"",stderr:a.message??"",exitCode:1};let i=await cp(s);return await Mn(t,s,"clear",i.exitCode===0),i}})}async function Zf(e,t,n,r){if(!await X(e))return N(`You do not have the initial commit yet
|
|
674
674
|
`);let s=await K(e),a=Nt(s).sort();if(a.length>0)return{stdout:`${a.map(d=>`${d}: needs merge`).join(`
|
|
675
675
|
`)}
|
|
676
676
|
`,stderr:`error: could not write index
|
|
677
|
-
`,exitCode:1};let i;try{i=await
|
|
677
|
+
`,exitCode:1};let i;try{i=await Yf(e,t,n,{includeUntracked:r})}catch(d){return $(d.message)}return i?{stdout:`Saved working directory and index state ${(await M(e,i)).message.trim()}
|
|
678
678
|
`,stderr:"",exitCode:0}:{stdout:`No local changes to save
|
|
679
|
-
`,stderr:"",exitCode:0}}async function
|
|
679
|
+
`,stderr:"",exitCode:0}}async function rp(e,t){let n=mo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await yr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await Ai(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
|
|
680
680
|
`)}
|
|
681
681
|
`:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
|
|
682
682
|
`,stderr:o.stderr,exitCode:o.exitCode};let d=await nt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
|
|
683
683
|
`,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
|
|
684
684
|
`)}
|
|
685
685
|
`:"",d=await nt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
|
|
686
|
-
`,stderr:"",exitCode:1}}let s=await
|
|
686
|
+
`,stderr:"",exitCode:1}}let s=await Di(e,n);if(s)return N(s);let a=o.messages.length>0?`${o.messages.join(`
|
|
687
687
|
`)}
|
|
688
688
|
`:"",i=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await nt(e);return{stdout:`${a}${c}Dropped ${i} (${r})
|
|
689
|
-
`,stderr:"",exitCode:0}}async function
|
|
689
|
+
`,stderr:"",exitCode:0}}async function sp(e,t){let n=mo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await Ai(e,n);if(!r.ok){let i=r.messages?.length?`${r.messages.join(`
|
|
690
690
|
`)}
|
|
691
691
|
`:"",c=r.stdout;return c||(c=await nt(e)),{stdout:`${i}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
|
|
692
692
|
`)}
|
|
693
|
-
`:"",s=await nt(e),a=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:a}}async function
|
|
693
|
+
`:"",s=await nt(e),a=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:a}}async function op(e){let t=await Vf(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
|
|
694
694
|
`)}
|
|
695
|
-
`,stderr:"",exitCode:0}}async function
|
|
696
|
-
`,stderr:"",exitCode:0}}async function
|
|
695
|
+
`,stderr:"",exitCode:0}}async function ip(e,t){let n=mo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await yr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await Di(e,n);return o?N(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
|
|
696
|
+
`,stderr:"",exitCode:0}}async function ap(e,t){let n=mo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await yr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await M(e,r),s=o.parents[0];if(!s)return N("error: invalid stash commit (no parent)");let a=await M(e,s),i=await Ne(e,a.tree,o.tree),c="";for(let f of i)c+=await np(e,f);return{stdout:c,stderr:"",exitCode:0}}async function cp(e){return await Xf(e),{stdout:"",stderr:"",exitCode:0}}re();ke();ue();et();function Qf(e,t){e.command("status",{description:"Show the working tree status",options:{short:H().alias("s").describe("Give the output in the short-format"),porcelain:H().describe("Give the output in a machine-parseable format"),branch:H().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 nt(s),stderr:"",exitCode:0};let a=await Z(s),i=await X(s),c;a&&a.type==="symbolic"?c=we(a.target):c="HEAD detached";let f=await K(s),d=Jo(f),l=await Zo(s,i,f,d),u=await $t(s,f),m=[],h=[];for(let y of u)y.status==="untracked"?h.push(y.path):m.push({path:y.path,status:y.status});m.sort((y,x)=>Re(y.path,x.path));let p=new Set(f.entries.map(y=>y.path)),g=Qo(h,p);return{stdout:up(c,l,m,d,g,n.branch),stderr:"",exitCode:0}}})}var fp={"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 dp(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function lp(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function up(e,t,n,r,o,s){let a=[];s&&(e==="HEAD detached"?a.push("## HEAD (no branch)"):a.push(`## ${e}`));let i=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=i.get(u);if(m){let y=fp[m.status]??"UU";a.push(`${y} ${ns(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?dp(h.status):" ",w=p?lp(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let y=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,y),b=h.displayPath.slice(y+4);a.push(`${g}${w} ${ns(x)} -> ${ns(b)}`)}else a.push(`${g}${w} ${ns(u)}`)}for(let u of o)a.push(`?? ${ns(u)}`);return a.length===0?"":`${a.join(`
|
|
697
697
|
`)}
|
|
698
|
-
`}function ns(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}re();
|
|
698
|
+
`}function ns(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}re();Ve();ke();ie();je();ue();He();Jt();function mp(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??J}function td(e,t){e.command("switch",{description:"Switch branches",args:[q.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:ee.string().alias("c").describe("Create and switch to a new branch"),forceCreate:ee.string().alias("C").describe("Create/reset and switch to a branch"),detach:H().alias("d").describe("Detach HEAD at named commit"),orphan:ee.string().describe("Create a new orphan branch"),guess:H().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 a=s,i=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"):wp(a,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return $("--detach and -c/-C are incompatible");let d=i??"HEAD",l=await Ie(a,d,`invalid reference: ${d}`);return v(l)?l:gp(a,d,l.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,l=i??(o.passthrough.length>0?o.passthrough[0]:void 0);return ed(a,d,!!n.forceCreate,l,r.env,t)}if(!i)return $("missing branch or commit argument");if(i==="-")return hp(a,r.env,t);let c=`refs/heads/${i}`,f=await U(a,c);if(f)return nd(a,i,c,f,r.env,t);if(n.guess!==!1){let d=await pp(a,i);if(d)return ed(a,i,!1,d.startPoint,r.env,t,d.trackingRef)}return $(`invalid reference: ${i}`)}})}async function rs(e){return await Ee(e,"CHERRY_PICK_HEAD")?$(`cannot switch branch while cherry-picking
|
|
699
699
|
Consider "git cherry-pick --quit" or "git worktree add".`):await Ee(e,"MERGE_HEAD")?$(`cannot switch branch while merging
|
|
700
700
|
Consider "git merge --quit" or "git worktree add".`):await Ee(e,"REVERT_HEAD")?$(`cannot switch branch while reverting
|
|
701
701
|
Consider "git revert --quit" or "git worktree add".`):await Dt(e)?$(`cannot switch branch while rebasing
|
|
702
|
-
Consider "git rebase --quit" or "git worktree add".`):null}async function
|
|
703
|
-
${
|
|
702
|
+
Consider "git rebase --quit" or "git worktree add".`):null}async function hp(e,t,n){let r=await rs(e);if(r)return r;let o=await Ns(e);return o?nd(e,o.name,o.refName,o.hash,t,n):$("no previous branch")}async function pp(e,t){let n=await pe(e,"refs/remotes"),r=[];for(let s of n){let a=s.name.replace(/^refs\/remotes\//,"").split("/"),i=a[0];a.length>=2&&i&&a.slice(1).join("/")===t&&r.push({remote:i,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function ed(e,t,n,r,o,s,a){let i=`refs/heads/${t}`,c=await U(e,i);if(c&&!n)return $(`a branch named '${t}' already exists`);let f;if(r){let E=await Ie(e,r,`invalid reference: ${r}`);if(v(E))return E;f=E.hash}else{let E=await X(e);if(!E){let O=await Z(e),I=O?.type==="symbolic"?O.target.replace(/^refs\/heads\//,""):"";n&&c&&await fe(e,i),await Ue(e,"HEAD",i),await mt(e);let j=await ln(e);return await ne(e,o,"HEAD",null,J,`checkout: moving from ${I} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
|
|
703
|
+
${j}`,exitCode:0}}f=E}let d=await rs(e);if(d)return d;let l=await X(e),u=await K(e);if(r){let E=In(u);if(E)return E}let m=await M(e,f);if(l&&l!==f){let E=await M(e,l);if(E.tree!==m.tree){let O=await Cn(e,E.tree,m.tree,u);if(!O.success)return O.errorOutput??N("error: checkout would overwrite local changes");u={version:2,entries:O.newEntries},await se(e,u),await Se(e,O.worktreeOps)}}let h=await Z(e),p="";h?.type==="direct"&&l&&(p=await Bs(e,l,f));let g=mp(h,l);await Y(e,i,f),await Ue(e,"HEAD",i),await mt(e);let w=await ln(e),y=r??"HEAD";n&&c?c!==f&&await ne(e,o,i,c,f,`branch: Reset to ${y}`):await ne(e,o,i,null,f,`branch: Created from ${y}`),await ne(e,o,"HEAD",l,f,`checkout: moving from ${g} to ${t}`);let x=a?.replace(/^refs\/remotes\//,"").split("/");if(x){let E=x[0]??"",O=`refs/heads/${x.slice(1).join("/")}`,I=await le(e);I[`branch "${t}"`]={...I[`branch "${t}"`],remote:E,merge:O},await Je(e,I)}await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:f,isBranchCheckout:!0});let b=n&&c?`Switched to and reset branch '${t}'
|
|
704
704
|
`:`Switched to a new branch '${t}'
|
|
705
|
-
`,
|
|
706
|
-
`}let
|
|
707
|
-
${u}`,exitCode:0}}re();ie();vr();
|
|
705
|
+
`,k=p+b+w;if(x){let E=x.slice(1).join("/");k+=`branch '${t}' set up to track '${x[0]}/${E}'.
|
|
706
|
+
`}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 nd(e,t,n,r,o,s){let a=await rs(e);return a||dr(e,t,n,r,o,s)}async function gp(e,t,n,r,o){let s=await rs(e);return s||$n(e,n,r,o)}async function wp(e,t,n,r){let o=await rs(e);if(o)return o;let s=`refs/heads/${t}`;if(await U(e,s))return $(`a branch named '${t}' already exists`);let i=await K(e),c=In(i);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,i);if(!p.success)return p.errorOutput??N("error: checkout would overwrite local changes");await Se(e,p.worktreeOps),await se(e,{version:2,entries:p.newEntries})}else await se(e,Zi());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}'
|
|
707
|
+
${u}`,exitCode:0}}re();ie();vr();ue();Rs();function sd(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[q.string().name("name").describe("Tag name to create or delete").optional(),q.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:H().alias("a").describe("Make an annotated tag object"),message:ee.string().alias("m").describe("Tag message"),delete:H().alias("d").describe("Delete a tag"),force:H().alias("f").describe("Replace an existing tag"),list:ee.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 a=`refs/tags/${n.name}`,i=await U(s,a);return i?(await fe(s,a),{stdout:`Deleted tag '${n.name}' (was ${V(i)})
|
|
708
708
|
`,stderr:"",exitCode:0}):N(`error: tag '${n.name}' not found.
|
|
709
|
-
`)}if(n.list!==void 0)return
|
|
709
|
+
`)}if(n.list!==void 0)return rd(s,n.list||void 0);if(n.name){let a=n.commit,i;if(a){let l=await Tt(s,a,`Failed to resolve '${a}' as a valid ref.`);if(v(l))return l;i=l}else if(i=await X(s),!i)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 Xe(s,r.env);if(v(l))return l;let u=St(n.message),m=ga({type:"tag",object:i,objectType:"commit",name:n.name,tagger:l,message:u}),h=await Pe(s,"tag",m);await Y(s,c,h)}else await Y(s,c,i);return{stdout:"",stderr:"",exitCode:0}}return rd(s)}})}async function rd(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=>Nn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
|
|
710
710
|
`)}
|
|
711
|
-
`,stderr:"",exitCode:0}}var
|
|
712
|
-
`,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
|
|
711
|
+
`,stderr:"",exitCode:0}}var bp={init:e=>bf(e),clone:(e,t)=>Yc(e,t),fetch:(e,t)=>uf(e,t),pull:(e,t)=>Hf(e,t),push:(e,t)=>Sf(e,t),add:(e,t)=>Na(e,t),blame:(e,t)=>yc(e,t),commit:(e,t)=>Xc(e,t),status:(e,t)=>Qf(e,t),log:(e,t)=>Pf(e,t),branch:(e,t)=>kc(e,t),tag:(e,t)=>sd(e,t),checkout:(e,t)=>xc(e,t),diff:(e,t)=>af(e,t),reset:(e,t)=>_f(e,t),merge:(e,t)=>$f(e,t),"cherry-pick":(e,t)=>jc(e,t),revert:(e,t)=>Bf(e,t),rebase:(e,t)=>Mf(e,t),mv:(e,t)=>Tf(e,t),rm:(e,t)=>Wf(e,t),remote:(e,t)=>Gf(e,t),config:(e,t)=>ef(e,t),show:(e,t)=>qf(e,t),stash:(e,t)=>Jf(e,t),"rev-parse":(e,t)=>Uf(e,t),"ls-files":(e,t)=>If(e,t),clean:(e,t)=>Gc(e,t),switch:(e,t)=>td(e,t),restore:(e,t)=>Ff(e,t),reflog:(e,t)=>jf(e,t),repack:(e,t)=>pf(e,t),gc:(e,t)=>gf(e,t),bisect:(e,t)=>oc(e,t)};function od(e){let t=yo("git",{description:"Git command"});for(let n of Object.values(bp))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=od(r).toCommand()}execute=async(t,n)=>{let r=t[0]??"";if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
|
|
712
|
+
`,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 yp(e){return new ho(e)}En();export{ho as Git,Fu as composeGitHooks,yp as createGit,Ln as findRepo,Q as isRejection};
|