just-git 0.1.11 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +334 -326
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var rd=Object.defineProperty;var Zr=(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 ke=(e,t)=>()=>(e&&(t=e(e=0)),t);var sd=(e,t)=>{for(var n in t)rd(e,n,{get:t[n],enumerable:!0})};function ts(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function T(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":ts(t)}function xt(...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 ts(t||".")}function Ut(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 wr(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 st(e,t){let n=ts(e),r=ts(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,d=Math.min(o.length,s.length);for(;f<d&&o[f]===s[f];)f++;let l=o.length-f,u=s.slice(f),m=[];for(let h=0;h<l;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var ue=ke(()=>{"use strict"});function fd(e){let t={},n=null;for(let r of e.split(`
|
|
2
2
|
`)){let o=r.trim();if(!(!o||o.startsWith("#")||o.startsWith(";"))){if(o.startsWith("[")){let s=o.indexOf("]");if(s===-1)continue;n=o.slice(1,s).trim(),n in t||(t[n]={});continue}if(n!==null){let s=t[n];if(!s)continue;let i=o.indexOf("=");if(i===-1){let a=o.trim().toLowerCase();s[a]="true"}else{let a=o.slice(0,i).trim().toLowerCase(),c=o.slice(i+1).trim();s[a]=c}}}}return t}function wo(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 pe(e){let t=T(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return fd(n)}async function Ye(e,t){let n=T(e.gitDir,"config");await e.fs.writeFile(n,wo(t))}async function jt(e,t){let n=await pe(e),{section:r,key:o}=yo(t);return n[r]?.[o]}async function bo(e,t,n){let r=await pe(e),{section:o,key:s}=yo(t);r[o]||(r[o]={}),r[o][s]=n,await Ye(e,r)}async function _i(e,t){let n=await pe(e),{section:r,key:o}=yo(t);return n[r]?.[o]?(delete n[r][o],Object.keys(n[r]).length===0&&delete n[r],await Ye(e,n),!0):!1}function yo(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 Xe=ke(()=>{"use strict";ue()});function ns(e,t){return Fi(e,t,"author")}function br(e,t){return Fi(e,t,"committer")}async function Fi(e,t,n){let r=dd[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Ni(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await jt(e,"user.name")??o?.name,i=t.get(r.email)??await jt(e,"user.email")??o?.email;if(!s||!i)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
|
|
5
5
|
|
|
6
6
|
*** Please tell me who you are.
|
|
7
7
|
|
|
@@ -9,94 +9,94 @@ Run
|
|
|
9
9
|
|
|
10
10
|
git config user.email "you@example.com"
|
|
11
11
|
git config user.name "Your Name"
|
|
12
|
-
`);return{name:s,email:i,timestamp:Ni(t.get(r.date)),timezone:"+0000"}}async function _t(e,t){try{let n=await wr(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 Ni(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,ln=ye(()=>{"use strict";Xe();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 un(e){let t="";for(let n=0;n<20;n++)t+=Fi[e[n]];return t}function rs(e,t){let n="";for(let r=0;r<20;r++)n+=Fi[e[t+r]];return n}function Ct(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,Fi,at=ye(()=>{"use strict";J="0000000000000000000000000000000000000000",Fi=(()=>{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 Eo(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(Eo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Zr(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(Eo(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(Eo(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return un(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 Zn(e){return Ui().update(e).hex()}var md,Ui,mn,Dn=ye(()=>{"use strict";at();md=new TextEncoder;Ui=hd(),mn=Ui});async function q(e){let t=T(e.gitDir,"index");if(!await e.fs.exists(t))return{version:ko,entries:[]};let n=await e.fs.readFileBuffer(t);return pd(n)}async function ce(e,t){let n=T(e.gitDir,"index"),r=await gd(t);await e.fs.writeFile(n,r)}function ht(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(xo),{...e,entries:n}}function nt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function ss(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Pt(e){return e.entries.some(t=>t.stage>0)}function Ft(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function ve(e){return e.entries.filter(t=>t.stage===0)}function Wi(){return{version:ko,entries:[]}}function os(e){let t=[...e].sort(xo);return{version:ko,entries:t}}function xe(){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!==Bi)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},d=t.getUint32(n+24);n+=40;let u=e.subarray(n,n+20),l=un(u);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 b=n;for(;b<e.byteLength&&e[b]!==0;)b++;g=new TextDecoder().decode(e.subarray(n,b))}let w=62+g.length+1,k=Math.ceil(w/8)*8;n=c+k,i.push({path:g,mode:d,hash:l,stage:h,stat:f})}return{version:o,entries:i}}async function gd(e){let t=[...e.entries].sort(xo),n=12;for(let d of t){let u=62+d.path.length+1;n+=Math.ceil(u/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,Bi),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let d of t){let u=i;s.setUint32(i,d.stat.ctimeSeconds),s.setUint32(i+4,d.stat.ctimeNanoseconds),s.setUint32(i+8,d.stat.mtimeSeconds),s.setUint32(i+12,d.stat.mtimeNanoseconds),s.setUint32(i+16,d.stat.dev),s.setUint32(i+20,d.stat.ino),s.setUint32(i+24,d.mode),s.setUint32(i+28,d.stat.uid),s.setUint32(i+32,d.stat.gid),s.setUint32(i+36,d.stat.size),i+=40;let l=Ct(d.hash);o.set(l,i),i+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(d.path);o.set(p,i),i+=p.byteLength,o[i]=0,i+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;i=u+w}let a=o.subarray(0,i),c=await Zn(a),f=Ct(c);return o.set(f,i),o}function xo(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Bi,ko,Ee=ye(()=>{"use strict";at();de();Dn();Bi=1145655875,ko=2});function Co(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,Ki=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}});function wd(){try{let e=Zr(["node","zlib"].join(":"));if(typeof e.deflateSync=="function"&&typeof e.inflateSync=="function")return{deflate:t=>Promise.resolve(new Uint8Array(e.deflateSync(t))),inflate:t=>Promise.resolve(new Uint8Array(e.inflateSync(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 zi,Jn,Zt,is=ye(()=>{"use strict";zi=wd(),Jn=zi.deflate,Zt=zi.inflate});async function ta(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==as)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${as.toString(16)})`);let r=t.getUint32(4);if(r!==Ro)throw new Error(`Unsupported pack version: ${r}`);let o=t.getUint32(8),s=[],i=12;for(let c=0;c<o;c++){let f=await yd(e,i);s.push(f),i=f.nextOffset}return(await Ed(s)).map((c,f)=>({...c,offset:s[f].headerOffset,nextOffset:s[f].nextOffset}))}async function yd(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===br){let u=e[t++];for(a=u&127;u&128;)a+=1,u=e[t++],a=(a<<7)+(u&127);a=n-a}else o===$o&&(c=rs(e,t),t+=20);let{result:f,bytesConsumed:d}=await Cd(e,t,s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+d}}async function Ed(e){let t=new Map;for(let o=0;o<e.length;o++)t.set(e[o].headerOffset,o);let n=new Array(e.length).fill(null);async function r(o){let s=n[o];if(s)return s;let i=e[o];if(i.typeNum!==br&&i.typeNum!==$o){let u=bd[i.typeNum];if(!u)throw new Error(`Unknown object type: ${i.typeNum}`);let l={type:u,content:i.inflated,hash:await Yi(u,i.inflated)};return n[o]=l,l}let a;if(i.typeNum===br){if(a=t.get(i.baseOffset),a===void 0)throw new Error(`OFS_DELTA base not found at offset ${i.baseOffset}`)}else if(a=await kd(e,n,i.baseHash,r),a===void 0)throw new Error(`REF_DELTA base not found for hash ${i.baseHash}`);let c=await r(a),f=cs(c.content,i.inflated),d={type:c.type,content:f,hash:await Yi(c.type,f)};return n[o]=d,d}for(let o=0;o<e.length;o++)await r(o);return n}async function kd(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!==br&&s.typeNum!==$o&&(await r(o)).hash===n)return o}}function cs(e,t){let n=0,{value:r,newPos:o}=Vi(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:i}=Vi(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,u=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&&(u=t[n++]),f&32&&(u|=t[n++]<<8),f&64&&(u|=t[n++]<<16),u===0&&(u=65536),a.set(e.subarray(d,d+u),c),c+=u}else if(f>0)a.set(t.subarray(n,n+f),c),c+=f,n+=f;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==s)throw new Error(`Delta produced ${c} bytes, expected ${s}`);return a}async function fs(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,as),r.setUint32(4,Ro),r.setUint32(8,e.length),t.push(n);for(let d of e){let u=ea[d.type],l=await Jn(d.content),m=Po(u,d.content.byteLength);t.push(m),t.push(l)}let o=0;for(let d of t)o+=d.byteLength;o+=20;let s=new Uint8Array(o),i=0;for(let d of t)s.set(d,i),i+=d.byteLength;let a=mn();a.update(s.subarray(0,i));let c=await a.hex(),f=Ct(c);return s.set(f,i),s}async function na(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,as),o.setUint32(4,Ro),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let l of e){let m=s;n.set(l.hash,s);let h=l.delta&&l.deltaBaseHash?n.get(l.deltaBaseHash):void 0;if(l.delta&&h!==void 0){let p=Po(br,l.delta.byteLength),g=xd(s-h),w=await Jn(l.delta);t.push(p,g,w),s+=p.byteLength+g.byteLength+w.byteLength}else{let p=ea[l.type],g=Po(p,l.content.byteLength),w=await Jn(l.content);t.push(g,w),s+=g.byteLength+w.byteLength}i.push({hash:l.hash,offset:m,nextOffset:s})}let a=0;for(let l of t)a+=l.byteLength;a+=20;let c=new Uint8Array(a),f=0;for(let l of t)c.set(l,f),f+=l.byteLength;let d=mn();d.update(c.subarray(0,f));let u=await d.hex();return c.set(Ct(u),f),{data:c,entries:i}}function xd(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 Po(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 Vi(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 Cd(e,t,n){let r=e.subarray(t),o=await Zt(r);if(o.byteLength!==n)throw new Error(`Inflate size mismatch: got ${o.byteLength}, expected ${n}`);let s=2,i=r.byteLength;for(;s<i;){let a=s+i>>>1;try{(await Zt(r.subarray(0,a))).byteLength===n?i=a:s=a+1}catch{s=a+1}}return{result:o,bytesConsumed:s}}async function Yi(e,t){let n=Pd.encode(`${e} ${t.byteLength}\0`),r=mn();return r.update(n),r.update(t),r.hex()}var as,Ro,Xi,Zi,Ji,Qi,br,$o,bd,ea,Pd,yr=ye(()=>{"use strict";at();Dn();is();as=1346454347,Ro=2,Xi=1,Zi=2,Ji=3,Qi=4,br=6,$o=7,bd={[Xi]:"commit",[Zi]:"tree",[Ji]:"blob",[Qi]:"tag"},ea={commit:Xi,tree:Zi,blob:Ji,tag:Qi};Pd=new TextEncoder});async function oa(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,ra),c+=4,a.setUint32(c,sa),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(Ct(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|d++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let u=mn();u.update(i.subarray(0,c));let l=await u.hex();return i.set(Ct(l),c),i}async function ia(e){let n=(await ta(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Co(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return oa(n,r)}async function aa(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Co(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return oa(n,r)}var ra,sa,Mn,ds=ye(()=>{"use strict";at();Dn();Ki();yr();ra=4285812579,sa=2,Mn=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==ra)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==sa)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=Ct(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++){let r="",o=n*20;for(let s=0;s<20;s++){let i=this.hashes[o+s];r+=(i>>4).toString(16)+(i&15).toString(16)}t.push(r)}return t}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var Rd,$d,Id,Er,ca=ye(()=>{"use strict";at();ds();yr();is();Rd=6,$d=7,Id={1:"commit",2:"tree",3:"blob",4:"tag"},Er=class{constructor(t,n){this.data=t;this.index=new Mn(n)}index;hasObject(t){return this.index.has(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===Rd){let d=n[r++],u=d&127;for(;d&128;)u+=1,d=n[r++],u=(u<<7)+(d&127);let l=await Zt(n.subarray(r)),m=await this.readAt(t-u);return{type:m.type,content:cs(m.content,l)}}if(s===$d){let d=rs(n,r);r+=20;let u=await Zt(n.subarray(r)),l=this.index.lookup(d);if(l===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(l);return{type:m.type,content:cs(m.content,u)}}let c=Id[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await Zt(n.subarray(r));if(f.byteLength!==i)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${i}`);return{type:c,content:f}}}});function Oo(e,t){let n=Od.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Hd(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Td.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function Io(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var Od,Td,ls,fa=ye(()=>{"use strict";at();ds();ca();is();de();Dn();Od=new TextEncoder,Td=new TextDecoder;ls=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.hooks=r}packs=[];loadedPackNames=new Set;discoverPromise=null;async write(t,n){let r=Oo(t,n),o=await Zn(r),s=Io(this.gitDir,o);if(await this.fs.exists(s))return o;let i=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Jn(r)),this.hooks?.emit("object:write",{type:t,hash:o}),o}async read(t){let n=Io(this.gitDir,t);if(await this.fs.exists(n)){let r=await this.fs.readFileBuffer(n),o=await Zt(r);return Hd(t,o)}await this.discover();for(let r of this.packs){let o=await r.readObject(t);if(o)return o}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Io(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.hasObject(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=un(o),i=T(this.gitDir,"objects","pack");await this.fs.mkdir(i,{recursive:!0});let a=`pack-${s}`,c=T(i,`${a}.pack`);await this.fs.writeFile(c,t);let f=await ia(t),d=T(i,`${a}.idx`);return await this.fs.writeFile(d,f),this.loadedPackNames.add(a),this.packs.push(new Er(t,f)),r}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){let t=T(this.gitDir,"objects","pack");if(!await this.fs.exists(t))return;let n=await this.fs.readdir(t);for(let r of n){if(!r.endsWith(".idx"))continue;let o=r.slice(0,-4);if(this.loadedPackNames.has(o))continue;let s=T(t,`${o}.pack`);if(!await this.fs.exists(s))continue;let[i,a]=await Promise.all([this.fs.readFileBuffer(T(t,r)),this.fs.readFileBuffer(s)]);this.loadedPackNames.add(o),this.packs.push(new Er(a,i))}}}});function kr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function xr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var To=ye(()=>{"use strict"});function Ut(e){let t=Ad.decode(e),n=t.indexOf(`
|
|
12
|
+
`);return{name:s,email:i,timestamp:Ni(t.get(r.date)),timezone:"+0000"}}async function Bt(e,t){try{let n=await br(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 Ni(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 dd,ln=ke(()=>{"use strict";Xe();dd={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 un(e){let t="";for(let n=0;n<20;n++)t+=Ui[e[n]];return t}function rs(e,t){let n="";for(let r=0;r<20;r++)n+=Ui[e[t+r]];return n}function Ct(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,Ui,at=ke(()=>{"use strict";J="0000000000000000000000000000000000000000",Ui=(()=>{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 Eo(e){return typeof e=="string"?ld.encode(e):e}function ud(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(Eo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Zr(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(Eo(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(Eo(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return un(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 Qn(e){return Bi().update(e).hex()}var ld,Bi,mn,Dn=ke(()=>{"use strict";at();ld=new TextEncoder;Bi=ud(),mn=Bi});async function q(e){let t=T(e.gitDir,"index");if(!await e.fs.exists(t))return{version:ko,entries:[]};let n=await e.fs.readFileBuffer(t);return md(n)}async function re(e,t){let n=T(e.gitDir,"index"),r=await hd(t);await e.fs.writeFile(n,r)}function ht(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(xo),{...e,entries:n}}function nt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function ss(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Pt(e){return e.entries.some(t=>t.stage>0)}function Gt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function ve(e){return e.entries.filter(t=>t.stage===0)}function qi(){return{version:ko,entries:[]}}function os(e){let t=[...e].sort(xo);return{version:ko,entries:t}}function Pe(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function md(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Wi)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},d=t.getUint32(n+24);n+=40;let l=e.subarray(n,n+20),u=un(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 b=n;for(;b<e.byteLength&&e[b]!==0;)b++;g=new TextDecoder().decode(e.subarray(n,b))}let w=62+g.length+1,k=Math.ceil(w/8)*8;n=c+k,i.push({path:g,mode:d,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function hd(e){let t=[...e.entries].sort(xo),n=12;for(let d of t){let l=62+d.path.length+1;n+=Math.ceil(l/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,Wi),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let d of t){let l=i;s.setUint32(i,d.stat.ctimeSeconds),s.setUint32(i+4,d.stat.ctimeNanoseconds),s.setUint32(i+8,d.stat.mtimeSeconds),s.setUint32(i+12,d.stat.mtimeNanoseconds),s.setUint32(i+16,d.stat.dev),s.setUint32(i+20,d.stat.ino),s.setUint32(i+24,d.mode),s.setUint32(i+28,d.stat.uid),s.setUint32(i+32,d.stat.gid),s.setUint32(i+36,d.stat.size),i+=40;let u=Ct(d.hash);o.set(u,i),i+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(d.path);o.set(p,i),i+=p.byteLength,o[i]=0,i+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;i=l+w}let a=o.subarray(0,i),c=await Qn(a),f=Ct(c);return o.set(f,i),o}function xo(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Wi,ko,xe=ke(()=>{"use strict";at();ue();Dn();Wi=1145655875,ko=2});function Co(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Ki[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Ki,zi=ke(()=>{"use strict";Ki=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;Ki[e]=t}});function pd(){try{let e=Zr(["node","zlib"].join(":"));if(typeof e.deflateSync=="function"&&typeof e.inflateSync=="function")return{deflate:t=>Promise.resolve(new Uint8Array(e.deflateSync(t))),inflate:t=>Promise.resolve(new Uint8Array(e.inflateSync(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 Vi,er,Qt,is=ke(()=>{"use strict";Vi=pd(),er=Vi.deflate,Qt=Vi.inflate});async function na(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==as)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${as.toString(16)})`);let r=t.getUint32(4);if(r!==Ro)throw new Error(`Unsupported pack version: ${r}`);let o=t.getUint32(8),s=[],i=12;for(let c=0;c<o;c++){let f=await wd(e,i);s.push(f),i=f.nextOffset}return(await bd(s)).map((c,f)=>({...c,offset:s[f].headerOffset,nextOffset:s[f].nextOffset}))}async function wd(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===yr){let l=e[t++];for(a=l&127;l&128;)a+=1,l=e[t++],a=(a<<7)+(l&127);a=n-a}else o===$o&&(c=rs(e,t),t+=20);let{result:f,bytesConsumed:d}=await kd(e,t,s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+d}}async function bd(e){let t=new Map;for(let o=0;o<e.length;o++)t.set(e[o].headerOffset,o);let n=new Array(e.length).fill(null);async function r(o){let s=n[o];if(s)return s;let i=e[o];if(i.typeNum!==yr&&i.typeNum!==$o){let l=gd[i.typeNum];if(!l)throw new Error(`Unknown object type: ${i.typeNum}`);let u={type:l,content:i.inflated,hash:await Xi(l,i.inflated)};return n[o]=u,u}let a;if(i.typeNum===yr){if(a=t.get(i.baseOffset),a===void 0)throw new Error(`OFS_DELTA base not found at offset ${i.baseOffset}`)}else if(a=await yd(e,n,i.baseHash,r),a===void 0)throw new Error(`REF_DELTA base not found for hash ${i.baseHash}`);let c=await r(a),f=cs(c.content,i.inflated),d={type:c.type,content:f,hash:await Xi(c.type,f)};return n[o]=d,d}for(let o=0;o<e.length;o++)await r(o);return n}async function yd(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!==yr&&s.typeNum!==$o&&(await r(o)).hash===n)return o}}function cs(e,t){let n=0,{value:r,newPos:o}=Yi(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:i}=Yi(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,l=0;f&1&&(d=t[n++]),f&2&&(d|=t[n++]<<8),f&4&&(d|=t[n++]<<16),f&8&&(d|=t[n++]<<24),f&16&&(l=t[n++]),f&32&&(l|=t[n++]<<8),f&64&&(l|=t[n++]<<16),l===0&&(l=65536),a.set(e.subarray(d,d+l),c),c+=l}else if(f>0)a.set(t.subarray(n,n+f),c),c+=f,n+=f;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==s)throw new Error(`Delta produced ${c} bytes, expected ${s}`);return a}async function fs(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,as),r.setUint32(4,Ro),r.setUint32(8,e.length),t.push(n);for(let d of e){let l=ta[d.type],u=await er(d.content),m=Po(l,d.content.byteLength);t.push(m),t.push(u)}let o=0;for(let d of t)o+=d.byteLength;o+=20;let s=new Uint8Array(o),i=0;for(let d of t)s.set(d,i),i+=d.byteLength;let a=mn();a.update(s.subarray(0,i));let c=await a.hex(),f=Ct(c);return s.set(f,i),s}async function ra(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,as),o.setUint32(4,Ro),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let u of e){let m=s;n.set(u.hash,s);let h=u.delta&&u.deltaBaseHash?n.get(u.deltaBaseHash):void 0;if(u.delta&&h!==void 0){let p=Po(yr,u.delta.byteLength),g=Ed(s-h),w=await er(u.delta);t.push(p,g,w),s+=p.byteLength+g.byteLength+w.byteLength}else{let p=ta[u.type],g=Po(p,u.content.byteLength),w=await er(u.content);t.push(g,w),s+=g.byteLength+w.byteLength}i.push({hash:u.hash,offset:m,nextOffset:s})}let a=0;for(let u of t)a+=u.byteLength;a+=20;let c=new Uint8Array(a),f=0;for(let u of t)c.set(u,f),f+=u.byteLength;let d=mn();d.update(c.subarray(0,f));let l=await d.hex();return c.set(Ct(l),f),{data:c,entries:i}}function Ed(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 Po(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 Yi(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 kd(e,t,n){let r=e.subarray(t),o=await Qt(r);if(o.byteLength!==n)throw new Error(`Inflate size mismatch: got ${o.byteLength}, expected ${n}`);let s=2,i=r.byteLength;for(;s<i;){let a=s+i>>>1;try{(await Qt(r.subarray(0,a))).byteLength===n?i=a:s=a+1}catch{s=a+1}}return{result:o,bytesConsumed:s}}async function Xi(e,t){let n=xd.encode(`${e} ${t.byteLength}\0`),r=mn();return r.update(n),r.update(t),r.hex()}var as,Ro,Zi,Ji,Qi,ea,yr,$o,gd,ta,xd,Er=ke(()=>{"use strict";at();Dn();is();as=1346454347,Ro=2,Zi=1,Ji=2,Qi=3,ea=4,yr=6,$o=7,gd={[Zi]:"commit",[Ji]:"tree",[Qi]:"blob",[ea]:"tag"},ta={commit:Zi,tree:Ji,blob:Qi,tag:ea};xd=new TextEncoder});async function ia(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,sa),c+=4,a.setUint32(c,oa),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(Ct(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|d++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let l=mn();l.update(i.subarray(0,c));let u=await l.hex();return i.set(Ct(u),c),i}async function aa(e){let n=(await na(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Co(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ia(n,r)}async function ca(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Co(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ia(n,r)}var sa,oa,Mn,ds=ke(()=>{"use strict";at();Dn();zi();Er();sa=4285812579,oa=2,Mn=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==sa)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==oa)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=Ct(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++){let r="",o=n*20;for(let s=0;s<20;s++){let i=this.hashes[o+s];r+=(i>>4).toString(16)+(i&15).toString(16)}t.push(r)}return t}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var Cd,Pd,Rd,kr,fa=ke(()=>{"use strict";at();ds();Er();is();Cd=6,Pd=7,Rd={1:"commit",2:"tree",3:"blob",4:"tag"},kr=class{constructor(t,n){this.data=t;this.index=new Mn(n)}index;hasObject(t){return this.index.has(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===Cd){let d=n[r++],l=d&127;for(;d&128;)l+=1,d=n[r++],l=(l<<7)+(d&127);let u=await Qt(n.subarray(r)),m=await this.readAt(t-l);return{type:m.type,content:cs(m.content,u)}}if(s===Pd){let d=rs(n,r);r+=20;let l=await Qt(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:cs(m.content,l)}}let c=Rd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await Qt(n.subarray(r));if(f.byteLength!==i)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${i}`);return{type:c,content:f}}}});function Oo(e,t){let n=$d.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Od(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Id.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function Io(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var $d,Id,ls,da=ke(()=>{"use strict";at();ds();fa();is();ue();Dn();$d=new TextEncoder,Id=new TextDecoder;ls=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.hooks=r}packs=[];loadedPackNames=new Set;discoverPromise=null;async write(t,n){let r=Oo(t,n),o=await Qn(r),s=Io(this.gitDir,o);if(await this.fs.exists(s))return o;let i=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await er(r)),this.hooks?.emit("object:write",{type:t,hash:o}),o}async read(t){let n=Io(this.gitDir,t);if(await this.fs.exists(n)){let r=await this.fs.readFileBuffer(n),o=await Qt(r);return Od(t,o)}await this.discover();for(let r of this.packs){let o=await r.readObject(t);if(o)return o}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Io(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.hasObject(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=un(o),i=T(this.gitDir,"objects","pack");await this.fs.mkdir(i,{recursive:!0});let a=`pack-${s}`,c=T(i,`${a}.pack`);await this.fs.writeFile(c,t);let f=await aa(t),d=T(i,`${a}.idx`);return await this.fs.writeFile(d,f),this.loadedPackNames.add(a),this.packs.push(new kr(t,f)),r}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){let t=T(this.gitDir,"objects","pack");if(!await this.fs.exists(t))return;let n=await this.fs.readdir(t);for(let r of n){if(!r.endsWith(".idx"))continue;let o=r.slice(0,-4);if(this.loadedPackNames.has(o))continue;let s=T(t,`${o}.pack`);if(!await this.fs.exists(s))continue;let[i,a]=await Promise.all([this.fs.readFileBuffer(T(t,r)),this.fs.readFileBuffer(s)]);this.loadedPackNames.add(o),this.packs.push(new kr(a,i))}}}});function xr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function Cr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var To=ke(()=>{"use strict"});function Wt(e){let t=Hd.decode(e),n=t.indexOf(`
|
|
13
13
|
|
|
14
14
|
`),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i=[],a,c;for(let f of r.split(`
|
|
15
|
-
`)){let d=f.indexOf(" ");if(d===-1)continue;let
|
|
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":i.push(u);break;case"author":a=xr(u);break;case"committer":c=xr(u);break}}if(!s)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:i,author:a,committer:c,message:o}}function qt(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Cr(e.author)}`),t.push(`committer ${Cr(e.committer)}`),t.push(""),t.push(e.message),Td.encode(t.join(`
|
|
16
|
+
`))}var Td,Hd,en=ke(()=>{"use strict";To();Td=new TextEncoder,Hd=new TextDecoder});function tn(e){let t=vd.decode(e),n=t.indexOf(`
|
|
17
17
|
|
|
18
18
|
`),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i="commit",a="",c;for(let f of r.split(`
|
|
19
|
-
`)){let d=f.indexOf(" ");if(d===-1)continue;let
|
|
20
|
-
`))}var
|
|
21
|
-
`),e.hooks?.emit("ref:update",{ref:t,oldHash:r,newHash:n})}async function Fe(e,t,n){let r=
|
|
22
|
-
`)}async function
|
|
19
|
+
`)){let d=f.indexOf(" ");if(d===-1)continue;let l=f.slice(0,d),u=f.slice(d+1);switch(l){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=xr(u);break}}if(!s)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:i,name:a,tagger:c,message:o}}function la(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Cr(e.tagger)}`),t.push(""),t.push(e.message),Ad.encode(t.join(`
|
|
20
|
+
`))}var Ad,vd,Pr=ke(()=>{"use strict";To();Ad=new TextEncoder,vd=new TextDecoder});function us(e){if(e.objectStore)return e.objectStore;let t=new ls(e.fs,e.gitDir,e.hooks);return e.objectStore=t,t}async function pt(e,t){return Qn(Oo(e,t))}async function Re(e,t,n){return us(e).write(t,n)}async function ge(e,t){return us(e).read(t)}async function hn(e,t){return us(e).exists(t)}async function ms(e,t){return us(e).ingestPack(t)}function Ie(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 pn(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 se(e,t){let n=await ge(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Sd.decode(n.content)}async function gt(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 Wt(n.content)}async function ua(e,t){let n=await ge(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return tn(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=tn(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 Sd,oe=ke(()=>{"use strict";da();en();Pr();Dn();Sd=new TextDecoder});async function ma(e,t){let n=Rr(e,t);if(await e.fs.exists(n)){let s=(await e.fs.readFile(n)).trim();return s.startsWith(Ho)?{type:"symbolic",target:s.slice(Ho.length)}:{type:"direct",hash:s}}let o=(await ga(e)).get(t);return o?{type:"direct",hash:o}:null}async function N(e,t){let n=t;for(let r=0;r<Dd;r++){let o=await ma(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 ma(e,"HEAD")}async function X(e){return N(e,"HEAD")}async function Y(e,t,n){let r=e.hooks?await N(e,t):null,o=Rr(e,t);await tr(e.fs,o),await e.fs.writeFile(o,`${n}
|
|
21
|
+
`),e.hooks?.emit("ref:update",{ref:t,oldHash:r,newHash:n})}async function Fe(e,t,n){let r=Rr(e,t);await tr(e.fs,r),await e.fs.writeFile(r,`${Ho}${n}
|
|
22
|
+
`)}async function de(e,t){let n=e.hooks?await N(e,t):null,r=Rr(e,t);await e.fs.exists(r)&&await e.fs.rm(r),await Md(e,t),await $r(e,t),e.hooks&&n&&e.hooks.emit("ref:delete",{ref:t,oldHash:n})}async function we(e,t="refs"){let n=[],r=T(e.gitDir,t);await e.fs.exists(r)&&await wa(e,r,t,n);let o=await ga(e);if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}function be(e){return e.replace("refs/heads/","")}async function gn(e,t){let n=await Z(e);n&&n.type==="symbolic"?await Y(e,n.target,t):await Y(e,"HEAD",t)}async function Md(e,t){let n=T(e.gitDir,"packed-refs");if(!await e.fs.exists(n))return;let o=(await e.fs.readFile(n)).split(`
|
|
23
23
|
`),s=[],i=!1;for(let c of o){if(i&&c.startsWith("^")){i=!1;continue}if(i=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){i=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await e.fs.writeFile(n,s.join(`
|
|
24
|
-
`)):await e.fs.rm(n)}async function
|
|
24
|
+
`)):await e.fs.rm(n)}async function ha(e){let t=await we(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 i=tn(s.content).object;for(let a=0;a<100;a++){let c=await ge(e,i);if(c.type!=="tag")break;i=tn(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(T(e.gitDir,"packed-refs"),`${n.join(`
|
|
25
25
|
`)}
|
|
26
|
-
`);for(let o of t){let s=
|
|
27
|
-
`)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}function
|
|
28
|
-
`)){if(!s)continue;let i=
|
|
26
|
+
`);for(let o of t){let s=Rr(e,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await pa(e,T(e.gitDir,"refs"));let r=T(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(T(r,"heads"),{recursive:!0}),await e.fs.mkdir(T(r,"tags"),{recursive:!0})}async function pa(e,t){if(!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await pa(e,T(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}async function ga(e){let t=T(e.gitDir,"packed-refs");if(!await e.fs.exists(t))return new Map;let n=await e.fs.readFile(t),r=new Map;for(let o of n.split(`
|
|
27
|
+
`)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}function Rr(e,t){return T(e.gitDir,t)}async function wa(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=`${n}/${s}`,c=await e.fs.stat(i);if(c.isDirectory)await wa(e,i,a,r);else if(c.isFile){let f=await N(e,a);f&&r.push({name:a,hash:f})}}}var Ho,Dd,me=ke(()=>{"use strict";oe();Pr();ue();Ge();wn();Ho="ref: ",Dd=10});async function jn(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};if(await jd(e,n))return{fs:e,gitDir:n,workTree:null};let o=Gd(n);if(o===n)return null;n=o}}async function jd(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 hs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:T(t,".git"),i=r?null:t,a=T(s,"HEAD"),c=await e.exists(a);await e.mkdir(T(s,"objects"),{recursive:!0}),await e.mkdir(T(s,"refs","heads"),{recursive:!0}),await e.mkdir(T(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i};if(!c){await Fe(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"),wo(d))}return{ctx:f,reinit:c}}async function tr(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Gd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var wn=ke(()=>{"use strict";Xe();ue();me()});function ps(e,t){return T(e.gitDir,"logs",t)}function Ld(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),d=n.slice(a+1,c),l=n.slice(c+2),u=l.indexOf(" ");if(u<0)return null;let m=parseInt(l.slice(0,u),10),h=l.slice(u+1);return{oldHash:s,newHash:i,name:f,email:d,timestamp:m,tz:h,message:r}}async function ze(e,t){let n=ps(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
|
|
28
|
+
`)){if(!s)continue;let i=Ld(s);i&&o.push(i)}return o}function ba(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function bn(e,t,n){let r=ps(e,t);if(await tr(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(ba).join(`
|
|
29
29
|
`)}
|
|
30
|
-
`;await e.fs.writeFile(r,o)}async function Ue(e,t,n){let r=ps(e,t);await
|
|
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
|
|
32
|
-
`)){let s=ol(o,t);s&&r.push(s)}return{patterns:r,src:n}}function il(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Ia){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Gn(n,e,2)===0}function al(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Gn(r,a,2)===0}function jo(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&Oa&&!t)){if(s.flags&$a){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(il(r,s))return s;continue}if(al(e,s))return s}}return null}function Wt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=jo(t,n,o);if(s)return s.flags&bs?"not-ignored":"ignored"}if(e.excludeFile){let r=jo(t,n,e.excludeFile);if(r)return r.flags&bs?"not-ignored":"ignored"}if(e.globalExclude){let r=jo(t,n,e.globalExclude);if(r)return r.flags&bs?"not-ignored":"ignored"}return"undecided"}async function tr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=T(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Tr(r,"",n)}catch{}try{let r=await Dt(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Tr(o,"",r)}catch{}}catch{}return t}function Nn(e,t,n,r){let s=Tr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var $a,Ia,Oa,bs,Es=ye(()=>{"use strict";Xe();de();ws();$a=1,Ia=4,Oa=8,bs=16});async function Rt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=T(e.workTree,s.path),a;try{a=await ot(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await yn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await Ze(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>ke(s.path,i.path))}async function rt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await pe(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&&tn(t.mode)&&e.fs.symlink){await ot(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=fl.decode(n.content);await e.fs.symlink(i,r)}else{if(e.fs.lstat)try{(await e.fs.lstat(r)).isSymbolicLink&&await e.fs.rm(r,{force:!0})}catch{}await e.fs.writeFile(r,n.content)}}async function Ha(e,t){let n=await We(e,t);for(let r of n)await rt(e,r)}async function nn(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 ot(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=cl.encode(f),u=await Re(e,"blob",d),l={path:n,mode:40960,hash:u,stage:0,stat:{...xe(),size:d.byteLength}};return{index:ht(t,l),hash:u}}let s=await e.fs.readFileBuffer(r),i=await Re(e,"blob",s),a=o.mode!=null?dl(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...xe(),size:s.byteLength}};return{index:ht(t,c),hash:i}}async function Ze(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await tr(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);s=Nn(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,u=await ot(e.fs,f);if(u.isSymbolicLink){if(s&&Wt(s,d,!1)==="ignored")continue;i.push(d)}else if(u.isDirectory){if(s&&Wt(s,d,!0)==="ignored")continue;let l=await Ze(e,f,d,{skipIgnore:o,_ignore:s??void 0});i.push(...l)}else if(u.isFile){if(s&&Wt(s,d,!1)==="ignored")continue;i.push(d)}}return i}function dl(e){return e>511?e:e&73?33261:33188}async function _n(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),await _n(e,Nt(t),n))}var cl,fl,Je=ye(()=>{"use strict";te();Es();Ee();se();de();Ln();Ie();cl=new TextEncoder,fl=new TextDecoder});function Lo(e){return e.existsOnDisk&&e.indexHash===null}async function ll(e,t,n){let r=await Promise.all(t.map(h=>fe(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await Ze(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await Ze(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of i)f.has(h)||d.add(h);let u=Array.from(f).sort().concat(Array.from(d).sort()),l=(h,p)=>r[h]?.get(p),m=[];for(let h of u){let p=null,g=null,w=null,k=null,b=null;if(r.length===1){let G=l(0,h);w=G?.hash??null,b=G?.mode??null}else if(r.length===2){let G=l(0,h),L=l(1,h);g=G?.hash??null,k=G?.mode??null,w=L?.hash??null,b=L?.mode??null}else if(r.length>=3){let G=l(0,h),L=l(1,h),Y=l(2,h);p=G?.hash??null,g=L?.hash??null,k=L?.mode??null,w=Y?.hash??null,b=Y?.mode??null}let x=o.get(h)?.hash??null,C=s.has(h)?1:0,P=i.has(h),R,y=async()=>R!==void 0?R:P?(R=!(await c()).has(h),R):(R=!1,!1),$,v=async()=>{if($!==void 0)return $;if(!P||!e.workTree)return $=null,null;let G=T(e.workTree,h);try{$=await yn(e.fs,G)}catch{$=null}return $};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:x,indexStage:C,existsOnDisk:P,isIgnoredOnDisk:y,getWorktreeHash:v,headMode:k,remoteMode:b})}return m}function ks(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 xs(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 ul(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 ml(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=ul(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await hl(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function hl(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Lo(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 Lo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Lo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function pl(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let u=a.get(c);u&&(o.push(u),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:u.hash,mode:u.mode}));break}case"TAKE":{let u=f.takeFrom==="head"?d.headHash:d.remoteHash,l=f.takeFrom==="head"?d.headMode:d.remoteMode,m=l?Number.parseInt(l,8):33188;o.push({path:c,mode:m,hash:u,stage:0,stat:xe()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:u,mode:m});break}case"DELETE":{r.updateWorktree&&d.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>ke(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Cs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of gl){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
|
|
30
|
+
`;await e.fs.writeFile(r,o)}async function Ue(e,t,n){let r=ps(e,t);await tr(e.fs,r);let o=`${ba(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 $r(e,t){let n=ps(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function te(e,t,n,r,o,s,i=!1){let a=await Bt(e,t),c={oldHash:r??J,newHash:o,...a,message:s};await Ue(e,n,c),i&&n!=="HEAD"&&await Ue(e,"HEAD",c)}var Ge=ke(()=>{"use strict";at();ln();ue();wn();at()});function _d(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let a=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:a}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(i&&i[1]!==void 0&&i[2]!==void 0){let a=i[2]===""?1:parseInt(i[2],10);t.unshift({type:"caret",n:a}),n=i[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function Nd(e,t){let n=t.slice(0,2),r=t.slice(2),o=T(e.gitDir,"objects",n);if(!await e.fs.exists(o))return null;let i=(await e.fs.readdir(o)).filter(a=>a.startsWith(r));if(i.length===0)return null;if(i.length>1)throw new Ao(t);return`${n}${i[0]}`}async function Fd(e,t){if(t==="HEAD"||t==="@")return N(e,"HEAD");if(ya.includes(t))return N(e,t);if(/^[0-9a-f]{40}$/.test(t))return await hn(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Nd(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await N(e,t);if(s)return s}let n=await N(e,`refs/heads/${t}`);if(n)return n;let r=await N(e,`refs/tags/${t}`);if(r)return r;let o=await N(e,`refs/remotes/${t}`);return o||null}function Ud(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of ya)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Bd(e,t,n){let r=Ud(t),o=await ze(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function Be(e,t){let{base:n,reflogIndex:r,suffixes:o}=_d(t),s;if(r!==void 0?s=await Bd(e,n,r):s=await Fd(e,n),!s)return null;o.length>0&&(s=await _e(e,s));for(let i of o)if(i.type==="tilde")for(let a=0;a<i.n;a++){if(!s)return null;let c=await M(e,s);if(c.parents.length===0||(s=c.parents[0]??null,!s))return null}else{if(i.n===0)continue;if(!s)return null;let a=await M(e,s);if(i.n>a.parents.length||(s=a.parents[i.n-1]??null,!s))return null}return s}function Ea(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var ya,Ao,nn=ke(()=>{"use strict";oe();ue();Ge();me();ya=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Ao=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function ot(e,t){return e.lstat?e.lstat(t):e.stat(t)}function rn(e){return typeof e=="string"?e==="120000":e===40960}async function Ir(e,t){if((await ot(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Wd.encode(r)}return e.readFileBuffer(t)}async function yn(e,t){let n=await Ir(e,t);return pt("blob",n)}var Wd,Gn=ke(()=>{"use strict";oe();Wd=new TextEncoder});function En(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=ka.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=ka.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=un(a),f=o.padStart(6,"0");t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function xa(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=qd.encode(`${i} ${s.name}\0`),c=Ct(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var qd,ka,gs=ke(()=>{"use strict";at();qd=new TextEncoder,ka=new TextDecoder});var Or,Ca=ke(()=>{"use strict";Or={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function Se(e,t){return Pa(e,t,"")}async function Pa(e,t,n){let r=[],o=new Map;for(let i of t){let a=n?i.path.slice(n.length+1):i.path,c=a.indexOf("/");if(c===-1)r.push({mode:Kd(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await Pa(e,a,c);r.push({mode:Or.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Or.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Or.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=xa({type:"tree",entries:r});return Re(e,"tree",s)}async function We(e,t,n=""){let r=await ge(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=En(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Or.DIRECTORY){let c=await We(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function fe(e,t){if(!t)return new Map;let n=await We(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ne(e,t,n){let r=await fe(e,t),o=await fe(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Ce(i.path,a.path))}function Kd(e){return e.toString(8).padStart(6,"0")}var Oe=ke(()=>{"use strict";ne();oe();gs();Ca()});function Ra(e){return/^[a-zA-Z0-9]$/.test(e)}function zd(e){return/^[a-zA-Z]$/.test(e)}function Vd(e){return e>="0"&&e<="9"}function vo(e){return e>="A"&&e<="Z"}function So(e){return e>="a"&&e<="z"}function $a(e){return/^\s$/.test(e)}function Yd(e){return e===" "||e===" "}function Mo(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Xd(e){return Mo(e)&&!$a(e)}function Zd(e){return Mo(e)&&!Ra(e)&&e!==" "}function Jd(e){let t=e.charCodeAt(0);return t<32||t===127}function Qd(e){return/^[0-9a-fA-F]$/.test(e)}function Tr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Do(e,t,n,r,o){let s=(o&1)!==0,i=(o&2)!==0;for(;t<e.length;){let a=e[t];if(r>=n.length&&a!=="*")return-1;let c=r<n.length?n[r]:"";switch(a){case"\\":{if(t++,t>=e.length)return-1;if(!Tr(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(i&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let d=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((d-1<1||e[d-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&Do(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!i;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let d=n.indexOf("/",r);if(d===-1)return-1;r=d+1,t++;break}for(;!(r>=n.length);){if(!el(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=Do(e,t,n,r,o);if(d!==1){if(!f||d!==-2)return d}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let d=!1,l="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],Tr(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(So(c)){let g=c.toUpperCase();g>=h&&g<=p&&(d=!0)}else if(vo(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="[",Tr(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);tl(g,c,s)&&(d=!0),m=""}}else Tr(c,m,s)&&(d=!0);l=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!Tr(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function el(e){return e==="*"||e==="?"||e==="["||e==="\\"}function tl(e,t,n){switch(e){case"alnum":return Ra(t);case"alpha":return zd(t);case"blank":return Yd(t);case"cntrl":return Jd(t);case"digit":return Vd(t);case"graph":return Xd(t);case"lower":return So(t)||n&&vo(t);case"print":return Mo(t);case"punct":return Zd(t);case"space":return $a(t);case"upper":return vo(t)||n&&So(t);case"xdigit":return Qd(t);default:return!1}}function Ln(e,t,n=0){return Do(e,0,t,0,n)===0?0:1}var ws=ke(()=>{"use strict"});function Ha(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 nl(e){return Ha(e)===e.length}function rl(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|=bs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Ta);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Ia);let a=Math.min(Ha(o),s);return o[0]==="*"&&nl(o.slice(1))&&(r|=Oa),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function Hr(e,t,n){let r=[];for(let o of e.split(`
|
|
32
|
+
`)){let s=rl(o,t);s&&r.push(s)}return{patterns:r,src:n}}function sl(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Oa){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Ln(n,e,2)===0}function ol(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Ln(r,a,2)===0}function jo(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&Ta&&!t)){if(s.flags&Ia){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(sl(r,s))return s;continue}if(ol(e,s))return s}}return null}function Kt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=jo(t,n,o);if(s)return s.flags&bs?"not-ignored":"ignored"}if(e.excludeFile){let r=jo(t,n,e.excludeFile);if(r)return r.flags&bs?"not-ignored":"ignored"}if(e.globalExclude){let r=jo(t,n,e.globalExclude);if(r)return r.flags&bs?"not-ignored":"ignored"}return"undecided"}async function rr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=T(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Hr(r,"",n)}catch{}try{let r=await jt(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Hr(o,"",r)}catch{}}catch{}return t}function _n(e,t,n,r){let s=Hr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Ia,Oa,Ta,bs,Es=ke(()=>{"use strict";Xe();ue();ws();Ia=1,Oa=4,Ta=8,bs=16});async function Rt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=T(e.workTree,s.path),a;try{a=await ot(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await yn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await Ze(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ce(s.path,i.path))}async function rt(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&&rn(t.mode)&&e.fs.symlink){await ot(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=al.decode(n.content);await e.fs.symlink(i,r)}else{if(e.fs.lstat)try{(await e.fs.lstat(r)).isSymbolicLink&&await e.fs.rm(r,{force:!0})}catch{}await e.fs.writeFile(r,n.content)}}async function Aa(e,t){let n=await We(e,t);for(let r of n)await rt(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 ot(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=il.encode(f),l=await Re(e,"blob",d),u={path:n,mode:40960,hash:l,stage:0,stat:{...Pe(),size:d.byteLength}};return{index:ht(t,u),hash:l}}let s=await e.fs.readFileBuffer(r),i=await Re(e,"blob",s),a=o.mode!=null?cl(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Pe(),size:s.byteLength}};return{index:ht(t,c),hash:i}}async function Ze(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await rr(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);s=_n(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await ot(e.fs,f);if(l.isSymbolicLink){if(s&&Kt(s,d,!1)==="ignored")continue;i.push(d)}else if(l.isDirectory){if(s&&Kt(s,d,!0)==="ignored")continue;let u=await Ze(e,f,d,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(l.isFile){if(s&&Kt(s,d,!1)==="ignored")continue;i.push(d)}}return i}function cl(e){return e>511?e:e&73?33261:33188}async function Nn(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),await Nn(e,Ut(t),n))}var il,al,Je=ke(()=>{"use strict";ne();Es();xe();oe();ue();Gn();Oe();il=new TextEncoder,al=new TextDecoder});function Go(e){return e.existsOnDisk&&e.indexHash===null}async function fl(e,t,n){let r=await Promise.all(t.map(h=>fe(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await Ze(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await Ze(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of i)f.has(h)||d.add(h);let l=Array.from(f).sort().concat(Array.from(d).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of l){let p=null,g=null,w=null,k=null,b=null;if(r.length===1){let L=u(0,h);w=L?.hash??null,b=L?.mode??null}else if(r.length===2){let L=u(0,h),G=u(1,h);g=L?.hash??null,k=L?.mode??null,w=G?.hash??null,b=G?.mode??null}else if(r.length>=3){let L=u(0,h),G=u(1,h),V=u(2,h);p=L?.hash??null,g=G?.hash??null,k=G?.mode??null,w=V?.hash??null,b=V?.mode??null}let x=o.get(h)?.hash??null,P=s.has(h)?1:0,C=i.has(h),R,y=async()=>R!==void 0?R:C?(R=!(await c()).has(h),R):(R=!1,!1),$,A=async()=>{if($!==void 0)return $;if(!C||!e.workTree)return $=null,null;let L=T(e.workTree,h);try{$=await yn(e.fs,L)}catch{$=null}return $};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:x,indexStage:P,existsOnDisk:C,isIgnoredOnDisk:y,getWorktreeHash:A,headMode:k,remoteMode:b})}return m}function ks(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 xs(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 dl(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 ll(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=dl(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await ul(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function ul(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Go(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 Go(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Go(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function ml(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let l=a.get(c);l&&(o.push(l),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:l.hash,mode:l.mode}));break}case"TAKE":{let l=f.takeFrom==="head"?d.headHash:d.remoteHash,u=f.takeFrom==="head"?d.headMode:d.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:l,stage:0,stat:Pe()}),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)=>Ce(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Cs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of hl){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
|
|
33
33
|
`);r.push(`${i(t.operationName)}
|
|
34
34
|
${f}
|
|
35
35
|
${a(n)}
|
|
36
36
|
`)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
|
|
37
|
-
`:"",exitCode:t.errorExitCode}}async function Fn(e,t,n,r){let o=await
|
|
37
|
+
`:"",exitCode:t.errorExitCode}}async function Fn(e,t,n,r){let o=await fl(e,t,n),s=new Map(o.map(d=>[d.path,d])),i=new Map;for(let d of o){let l=r.mergeFn(d,r);i.set(d.path,l)}let a=await ll(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Cs(a,r)};let{newEntries:c,worktreeOps:f}=ml(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Te(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 ot(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await rt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await Nn(e.fs,Ut(o),n)}async function kn(e,t,n,r){return Fn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:xs,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function va(e,t,n,r){return Fn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:xs,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function sn(e,t,n){return Fn(e,[{label:"target",treeHash:t}],n,{mergeFn:ks,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ps(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:ve(n)},i=await Fn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:ks,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
|
|
38
38
|
`):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
|
|
39
|
-
`);return c.length>0&&(i.errorOutput=
|
|
40
|
-
`,128)),i}if(e.workTree&&o.size>0){let a=await fe(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var
|
|
41
|
-
`,exitCode:128}}function
|
|
42
|
-
`){return Pt(e)?
|
|
39
|
+
`);return c.length>0&&(i.errorOutput=_(c.join("")+`fatal: Could not reset index file to revision '${a}'.
|
|
40
|
+
`,128)),i}if(e.workTree&&o.size>0){let a=await fe(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var hl,Vt=ke(()=>{"use strict";ne();xe();ue();Gn();Oe();Je();hl=[{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 O(e){return{stdout:"",stderr:`fatal: ${e}
|
|
41
|
+
`,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function U(e,t,n){let r=await jn(e,t);return r?n?{...r,...n}:r:pl}function S(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function qe(e){return e.workTree?null:gl}async function Ke(e){let t=await X(e);return t||O("your current branch does not have any commits yet")}function on(e,t,n=`fatal: Exiting because of an unresolved conflict.
|
|
42
|
+
`){return Pt(e)?_(`error: ${t} is not possible because you have unmerged files.
|
|
43
43
|
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
|
|
44
44
|
hint: as appropriate to mark resolution and make a commit.
|
|
45
|
-
`+n,128):null}async function $t(e,t,n){let r=await Be(e,t);return r||O(n??`bad revision '${t}'`)}async function
|
|
46
|
-
`);return t===-1?e:e.slice(0,t)}function
|
|
45
|
+
`+n,128):null}async function $t(e,t,n){let r=await Be(e,t);return r||O(n??`bad revision '${t}'`)}async function He(e,t,n){let r=await Be(e,t);if(!r)return O(n??`bad revision '${t}'`);try{let o=await _e(e,r),s=await M(e,o);return{hash:o,commit:s}}catch{return O(n??`bad revision '${t}'`)}}async function Ve(e,t){try{return await br(e,t)}catch(n){return O(n.message)}}async function Yt(e,t){try{return await ns(e,t)}catch(n){return O(n.message)}}function sr(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 Ce(e,t){return e<t?-1:e>t?1:0}function ct(e,t){return e.workTree?st(e.workTree,t):""}function z(e){return e.slice(0,7)}function ie(e){let t=e.indexOf(`
|
|
46
|
+
`);return t===-1?e:e.slice(0,t)}function Lt(e){return O(`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 It(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${z(t)}] ${
|
|
49
|
-
`).filter(t=>!t.startsWith("#")).join(`
|
|
48
|
+
'git <command> [<revision>...] -- [<file>...]'`)}function It(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${z(t)}] ${ie(n)}`}async function xn(e,t,n){if(!await N(e,n.operationRef))return n.noOpError;let o=await N(e,"ORIG_HEAD")??await X(e);if(!o)return O(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),i=await M(e,o),a=await q(e),c=await Ps(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await gn(e,o),await re(e,{version:2,entries:c.newEntries}),await Te(e,c.worktreeOps),s&&((await Z(e))?.type==="symbolic"||s!==o)){let l=n.origHeadAsTargetRev?o:"HEAD";await te(e,t,"HEAD",s,o,`reset: moving to ${l}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function ft(e,t,n,r,o,s){let i=qt({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Re(e,"commit",i);return await gn(e,a),a}function Xt(e){return e.split(`
|
|
49
|
+
`).filter(t=>!t.startsWith("#")).map(t=>t.trimEnd()).join(`
|
|
50
50
|
`).replace(/\n+$/,`
|
|
51
51
|
`)}function Ot(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 q(s),
|
|
53
|
+
`}var pl,gl,ne=ke(()=>{"use strict";ln();xe();oe();en();ue();Ge();me();wn();nn();Vt();pl=O("not a git repository (or any of the parent directories): .git"),gl=O("this operation must be run in a work tree")});var ja={};sd(ja,{CommitHeap:()=>Bn,countAheadBehind:()=>Fo,findOrphanedCommits:()=>Uo,walkCommits:()=>Tt});async function*Tt(e,t,n){let r=await xl(e,n?.exclude),o=new Set(r),s=new Bn,i=Array.isArray(t)?t:[t];for(let a of i)o.has(a)||s.push(await Os(e,a));for(;s.size>0;){let a=s.pop();if(!o.has(a.hash)){o.add(a.hash),yield a;for(let c of a.commit.parents)o.has(c)||s.push(await Os(e,c))}}}async function Fo(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of Tt(e,t))r.add(a.hash);let o=new Set;for await(let a of Tt(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function Uo(e,t,n){let r=n?.maxCount??25,o=await we(e,"refs"),s=[];for(let d of o)try{s.push(await _e(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let d of Tt(e,s))i.add(d.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Bn;for(f.push(await Os(e,t));f.size>0&&a.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!i.has(d.hash))){a.push({hash:d.hash,subject:ie(d.commit.message)});for(let l of d.commit.parents)c.has(l)||f.push(await Os(e,l))}}return a}async function xl(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Tt(e,t))n.add(r.hash);return n}async function Os(e,t){return{hash:t,commit:await M(e,t)}}var Bn,Wn=ke(()=>{"use strict";ne();oe();me();Bn=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var uo=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 Hi(e){return new uo({_kind:"arg",type:e,required:!0})}function Ai(){return Hi("string")}function vi(){return Hi("number")}var Jr=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 mo=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 Si(e){return new mo({_kind:"option",type:e})}function Di(){return Si("string")}function Mi(){return Si("number")}var Q={string:Di,number:Mi};function H(){return new Jr}var B={string:Ai,number:vi};function od(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 ho(e){return e.map(od).join(`
|
|
54
|
+
`)}function id(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function Qr(e,t,n=3){return t.map(o=>({candidate:o,distance:id(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 ji(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=gr(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],d=0;for(;d<n.length;){let u=n[d];if(u==="--"){for(d++;d<n.length;)f.push(n[d]),d++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let E=s.get(h.slice(3));if(E&&E.def._kind==="flag"){a[E.key]=E.def.counted?0:!1,d++;continue}}let b=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Qr(h,b).map(E=>`--${E}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,d++;continue}let w=p??n[++d];if(w===void 0){o.push({type:"missing_value",name:g.key}),d++;continue}let k=pr(w,g.def.type,g.key,o);k!==void 0&&(a[g.key]=k),d++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let E=[];s.has(p)&&E.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:E});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),k=w.length>0?w:n[++d];if(k===void 0){o.push({type:"missing_value",name:g.key});break}let b=pr(k,g.def.type,g.key,o);b!==void 0&&(a[g.key]=b);break}d++;continue}c.push(u),d++}let l=0;for(let u=0;u<t.length;u++){let m=t[u],h=m.name??`arg${u}`;if(m.variadic){let p=c.slice(l);p.length>0?a[h]=p.map(g=>pr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?a[h]=m.default:a[h]=[],l=c.length}else{let p=c[l];p!==void 0?(a[h]=pr(p,m.type,h,o),l++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(l<c.length)for(let u=l;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,m]of Object.entries(e))if(a[u]===void 0){if(m._kind==="flag")a[u]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=pr(r[h.env],h.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(a[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function pr(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 gr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function po(e){let t=[],n=e.children.size>0;e.description?t.push(`${e.fullPath} - ${e.description}`):t.push(e.fullPath),t.push("");let r=[e.fullPath];n&&r.push("<command>"),Object.keys(e.options).length>0&&r.push("[options]");let o=e.args;for(let i of o){let a=i.name??"arg",c=i.variadic?`${a}...`:a;r.push(i.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let i=[];for(let[c,f]of e.children)i.push([c,f.description||""]);let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let i=[];for(let c of o){let f=c.name??"arg",d=c.variadic?`${f}...`:f,l=[];c.description&&l.push(c.description),c.required&&l.push("(required)"),c.default!==void 0&&l.push(`(default: ${JSON.stringify(c.default)})`),i.push([d,l.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let d=" ".repeat(a-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=ad(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
|
|
55
|
+
`)}function ad(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=gr(i);if(a._kind==="flag"){let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c}`);let l=[];f.description&&l.push(f.description),f.counted&&l.push("(counted)"),f.default!==void 0&&l.push(`(default: ${f.default})`),r.push([d.join(" "),l.join(" ")])}else{let f=a,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c} <${f.type}>`);let l=[];f.description&&l.push(f.description),f.required&&l.push("(required)"),f.default!==void 0&&l.push(`(default: ${JSON.stringify(f.default)})`),f.env&&l.push(`[env: ${f.env}]`),r.push([d.join(" "),l.join(" ")])}}let o=Math.max(...r.map(([i])=>i.length)),s=[];t&&s.push(t);for(let[i,a]of r)if(a){let c=" ".repeat(o-i.length+2);s.push(` ${i}${c}${a}`)}else s.push(` ${i}`);return s}function Gi(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Li(e){return e?e.map(t=>t._def):[]}var es=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,Gi(n.options),Li(n.args),n.examples??[],n.handler,n.transformArgs);return r.parent=this,this.children.set(t,r),r}get fullPath(){let t=[],n=this;for(;n;)t.unshift(n.name),n=n.parent;return t.join(" ")}toCommand(){return{name:this.name,execute:this.execute.bind(this)}}get allOptions(){return this.options}toTokens(t){let n=[],r=this.allOptions,o=t;for(let[s,i]of Object.entries(r)){let a=o[s],c=gr(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(cd(t))return{stdout:po(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=ji(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:ho(i.errors),exitCode:1};try{return await this.handler(i.args,n,{passthrough:i.passthrough})}catch(a){return{stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1}}}if(o&&!o.startsWith("-")){let s=Qr(o,[...this.children.keys()]);return{stdout:"",stderr:ho([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:po(this),stderr:"",exitCode:0}}};function go(e,t){return new es(e,t.description,Gi(t.options),Li(t.args),t.examples??[],t.handler,t.transformArgs)}function cd(e){return e.some(t=>t==="--help"||t==="-h")}ne();Es();xe();ue();ws();var $s=1,Lo=2,Rs=4,_o=8,Ar=16,Da=new Set(["*","?","[","\\"]),bl={glob:$s,literal:Lo,icase:Rs,top:_o,exclude:Ar};function Un(e){for(let t=0;t<e.length;t++)if(Da.has(e[t]))return!0;return!1}function yl(e){for(let t=0;t<e.length;t++)if(Da.has(e[t]))return t;return e.length}function Sa(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 Le(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=bl[d.trim()];l!==void 0&&(n|=l)}}}else r.startsWith(":/")?(n|=_o,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=Ar,r=r.slice(2));n&Lo&&n&$s&&(n&=~$s);let o;n&_o||t===""?o=Sa(r):o=Sa(`${t}/${r}`);let s=!!(n&Lo),i=s?!1:Un(o),a=s?o.length:yl(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function Is(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&Rs),c=a?n.toLowerCase():n,f=a?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let a=n.slice(0,s),c=t.slice(0,s);if(o&Rs){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&$s&&(i|=2),o&Rs&&(i|=1),Ln(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&Ar?Is(o,t)&&(r=!0):Is(o,t)&&(n=!0);return n&&!r}Je();function Ma(e,t){e.command("add",{description:"Add file contents to the index",args:[B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=qe(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await q(s);return p=await No(s,p,a,"",c),n["dry-run"]||await re(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 q(s),l=[],u=[];for(let p of f)Un(p)?u.push(p):l.push(p);let m=[];for(let p of l){let g=xt(r.cwd,p),w=st(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return O(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let E=d.entries.some(P=>P.path===w||P.path.startsWith(`${w}/`)),x=await kl(s,a,w,E);if(x){E&&((await r.fs.stat(g)).isDirectory?d=await No(s,d,g,w,c):d=(await zt(s,d,w)).index),m.push(x);continue}}if((await r.fs.stat(g)).isDirectory)d=await No(s,d,g,w,c);else{let E=d.entries.find(P=>P.path===w&&P.stage===0)?.hash,x=await zt(s,d,w);d=x.index,c.actions&&x.hash!==E&&c.actions.push(`add '${w}'
|
|
57
57
|
`)}}else if(d.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`))){if(c.actions)for(let E of d.entries)(E.path===w||E.path.startsWith(`${w}/`))&&c.actions.push(`remove '${E.path}'
|
|
58
|
-
`);d={...d,entries:d.entries.filter(E=>E.path!==w&&!E.path.startsWith(`${w}/`))}}else return O(`pathspec '${p}' did not match any files`)}if(m.length>0)return
|
|
58
|
+
`);d={...d,entries:d.entries.filter(E=>E.path!==w&&!E.path.startsWith(`${w}/`))}}else return O(`pathspec '${p}' did not match any files`)}if(m.length>0)return n["dry-run"]||await re(s,d),_(`The following paths are ignored by one of your .gitignore files:
|
|
59
59
|
${m.join(`
|
|
60
60
|
`)}
|
|
61
61
|
hint: Use -f if you really want to add them.
|
|
62
62
|
hint: Disable this message with "git config set advice.addIgnoredFile false"
|
|
63
|
-
`);if(
|
|
64
|
-
`)}else o?.actions&&o.actions.push(`remove '${
|
|
65
|
-
`),d.push(
|
|
66
|
-
`),n=(await
|
|
63
|
+
`);if(u.length>0){let p=await El(s,r.cwd,d,u,c);if(p.error)return p.error;d=p.index}return n["dry-run"]||await re(s,d),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function El(e,t,n,r,o){let s=e.workTree,i=ct(e,t),a=r.map(l=>Le(l,i)),c=new Array(a.length).fill(!1),f=l=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&Is(a[u],l)&&(c[u]=!0)},d=[];for(let l of n.entries){if(l.stage>0||!ye(a,l.path))continue;f(l.path);let u=T(s,l.path);if(await e.fs.exists(u)){let m=await zt(e,n,l.path);n=m.index,o?.actions&&m.hash!==l.hash&&o.actions.push(`add '${l.path}'
|
|
64
|
+
`)}else o?.actions&&o.actions.push(`remove '${l.path}'
|
|
65
|
+
`),d.push(l.path)}for(let l of d)n=nt(n,l);if(!o?.updateOnly){let l=new Set(n.entries.map(m=>m.path)),u=await Ze(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(l.has(m)||!ye(a,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
|
|
66
|
+
`),n=(await zt(e,n,m)).index}}for(let l=0;l<a.length;l++){let u=a[l];if(!c[l]&&!(u.magic&Ar))return{index:n,error:O(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function No(e,t,n,r,o){let s=r===""?"":`${r}/`,i=e.workTree,a=[],c=new Set;for(let f of t.entries){if(!(s===""||f.path.startsWith(s))||c.has(f.path))continue;c.add(f.path);let d=T(i,f.path);if(await e.fs.exists(d)){let l=f.stage>0,u=await 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
|
-
`),a.push(f.path)}for(let f of a)t=nt(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(
|
|
69
|
-
`),t=(await
|
|
70
|
-
`);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Ts(e){let t=(await
|
|
71
|
-
`)}async function Hs(e){let t=await
|
|
68
|
+
`),a.push(f.path)}for(let f of a)t=nt(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(l=>l.path)),d=await Ze(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 kl(e,t,n,r){let o=await rr(e);try{let i=await e.fs.readFile(T(t,".gitignore"));o=_n(o,i,"",T(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=T(t,a);if(Kt(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(T(c,".gitignore"));o=_n(o,f,a,T(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(T(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(Kt(o,n,i)==="ignored")return n}return null}ne();ne();Wn();oe();ue();me();async function Ee(e,t){let n=T(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function $e(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 vr(e){await de(e,"MERGE_HEAD"),await de(e,"ORIG_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}async function _t(e){await de(e,"CHERRY_PICK_HEAD"),await de(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function Ht(e){await de(e,"REVERT_HEAD"),await de(e,"ORIG_HEAD"),await he(e,"MERGE_MSG")}async function qn(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await de(e,t);await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"SQUASH_MSG")}var Bo="DETACH_POINT";async function Ga(e,t){await e.fs.writeFile(T(e.gitDir,Bo),t)}async function dt(e){let t=T(e.gitDir,Bo);await e.fs.exists(t)&&await e.fs.rm(t)}async function Sr(e){let t=T(e.gitDir,Bo);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}ue();me();async function wt(e){let t=await Ee(e,"BISECT_START");return t!=null&&t.trim().length>0}async function Dr(e){let t=await Ee(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
|
|
70
|
+
`);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Ts(e){let t=(await Ee(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await Dr(e),o=await N(e,`refs/bisect/${n}`),s=[],i=[],a=await we(e,"refs/bisect");for(let d of a)d.name.startsWith(`refs/bisect/${r}-`)?s.push(d.hash):d.name.startsWith("refs/bisect/skip-")&&i.push(d.hash);let c=await 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:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function bt(e,t){let n=await Ee(e,"BISECT_LOG")??"";await $e(e,"BISECT_LOG",n+t+`
|
|
71
|
+
`)}async function Hs(e){let t=await we(e,"refs/bisect");for(let r of t)await de(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 La(e,t,n,r,o){let s=[],i=new Map;for await(let g of Tt(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ie(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,k=[g.hash],b=0;for(;b<k.length;){let E=k[b++];if(w.has(E)||!c.has(E))continue;w.add(E);let x=i.get(E);if(x)for(let P of x)!w.has(P)&&c.has(P)&&k.push(P)}f.set(g.hash,w.size)}let d=s[0].hash,l=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,k=Math.abs(2*w-a);k<l&&(l=k,d=g.hash)}let u=!1;if(l===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,k=Math.abs(2*w-a);k<l&&(l=k,d=g.hash)}}let m=s.find(g=>g.hash===d),h=Cl(a),p=Pl(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function Cl(e){return Math.floor((e-1)/2)}function Pl(e){return e<=1?0:Math.ceil(Math.log2(e))}function _a(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
|
|
72
72
|
`:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
|
|
73
73
|
`:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
|
|
74
|
-
`}function
|
|
74
|
+
`}function Na(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
|
|
75
75
|
[${e.hash}] ${e.subject}
|
|
76
|
-
`}async function Fa(e,t){let n=await M(e,t),r=
|
|
76
|
+
`}async function Fa(e,t){let n=await M(e,t),r=ie(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
|
|
77
77
|
`;return i+=`commit ${t}
|
|
78
78
|
`,i+=`Author: ${n.author.name} <${n.author.email}>
|
|
79
79
|
`,i+=`Date: ${s}
|
|
80
80
|
`,i+=`
|
|
81
81
|
`,i+=` ${r}
|
|
82
82
|
`,i+=`
|
|
83
|
-
`,i}
|
|
83
|
+
`,i}ne();Wn();Xe();xe();oe();ue();Ge();me();ne();Wn();Xe();xe();oe();ue();oe();en();ue();function or(e){return T(e.gitDir,"rebase-merge")}async function At(e){return e.fs.exists(or(e))}async function lt(e){let t=or(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(T(t,"head-name")),r=await e.fs.readFile(T(t,"orig-head")),o=await e.fs.readFile(T(t,"onto")),s=Number.parseInt(await e.fs.readFile(T(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(T(t,"end")),10),a=await e.fs.exists(T(t,"git-rebase-todo"))?T(t,"git-rebase-todo"):T(t,"todo"),c=Ua(await e.fs.readFile(a)),f=await e.fs.exists(T(t,"done"))?await e.fs.readFile(T(t,"done")):"",d=Ua(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:d,msgnum:s,end:i}}async function Wo(e,t){let n=or(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(T(n,"head-name"),`${t.headName}
|
|
84
84
|
`),await e.fs.writeFile(T(n,"orig-head"),`${t.origHead}
|
|
85
85
|
`),await e.fs.writeFile(T(n,"onto"),`${t.onto}
|
|
86
86
|
`),await e.fs.writeFile(T(n,"msgnum"),`${String(t.msgnum)}
|
|
87
87
|
`),await e.fs.writeFile(T(n,"end"),`${String(t.end)}
|
|
88
|
-
`),await e.fs.writeFile(T(n,"git-rebase-todo"),
|
|
89
|
-
`),await e.fs.writeFile(T(t,"git-rebase-todo"),
|
|
88
|
+
`),await e.fs.writeFile(T(n,"git-rebase-todo"),vs(t.todo)),await e.fs.writeFile(T(n,"done"),vs(t.done)),await e.fs.writeFile(T(n,"interactive"),"")}async function qa(e){let t=or(e),n=await lt(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"),vs(n.todo)),await e.fs.writeFile(T(t,"done"),vs(n.done))}async function qo(e){let t=or(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Ss(e,t,n){let r=or(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 Ua(e){let t=[];for(let n of e.split(`
|
|
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
|
|
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 vs(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
|
|
95
95
|
`)}
|
|
96
|
-
`}async function Ka(e,t,n){let r=new Map,[o,s]=await Promise.all([Ba(e,t,r),Ba(e,n,r)]),i=new Set;for(let c of s)o.has(c)||i.add(c);let a=new Set;for(let c of o)s.has(c)||a.add(c);return{right:await Wa(e,r,n,i),left:await Wa(e,r,t,a)}}async function Ba(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await
|
|
97
|
-
`))d.push(
|
|
96
|
+
`}async function Ka(e,t,n){let r=new Map,[o,s]=await Promise.all([Ba(e,t,r),Ba(e,n,r)]),i=new Set;for(let c of s)o.has(c)||i.add(c);let a=new Set;for(let c of o)s.has(c)||a.add(c);return{right:await Wa(e,r,n,i),left:await Wa(e,r,t,a)}}async function Ba(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await As(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function Wa(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 As(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 As(e,f,t));s.sort((f,d)=>f.commit.committer.timestamp-d.commit.committer.timestamp);let i=s.map(f=>f.hash),a=[],c=new Set;for(;i.length>0;){let f=i.pop();if(!f||c.has(f))continue;c.add(f);let d=await As(e,f,t);d.commit.parents.length<=1&&a.push(d);for(let l of d.commit.parents)if(r.has(l)&&!c.has(l)){let u=(o.get(l)??0)-1;o.set(l,u),u<=0&&i.push(l)}}return a.reverse(),a}async function As(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:Wt(o.content)};return n.set(t,s),s}me();oe();function ir(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Rl(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=ir(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&ir(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var $l=50;async function Qe(e,t,n=$l){let r=new Map,o=[],s=[],i=[];for(let d of t)if(d.status==="deleted"&&d.oldHash){let l=r.get(d.oldHash)??[];l.push(d),r.set(d.oldHash,l),o.push(d)}else d.status==="added"&&d.newHash?s.push(d):i.push(d);let a=[],c=[];for(let d of s){let l=d.newHash;if(!l){c.push(d);continue}let u=r.get(l);if(u&&u.length>0){let m=Rl(u,d.path);m&&a.push({oldPath:m.path,newPath:d.path,oldHash:m.oldHash??l,newHash:l,similarity:100,oldMode:m.oldMode,newMode:d.newMode})}else c.push(d)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let d=await Il(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}if(f.length>0&&c.length>0){let d=await Hl(e,f,c,n);if(d.length>0){let l=new Set(d.map(m=>m.oldPath)),u=new Set(d.map(m=>m.newPath));f=f.filter(m=>!l.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...d)}}return{remaining:[...i,...f,...c],renames:a}}async function Il(e,t,n,r){let o=new Map;for(let a=0;a<t.length;a++){let c=t[a];if(!c)continue;let f=ir(c.path);o.has(f)?o.set(f,-1):o.set(f,a)}let s=new Map;for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let f=ir(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let d=t[c],l=n[f];if(!d?.oldHash||!l?.newHash||d.oldHash===l.newHash)continue;let u=await gt(e,d.oldHash),m=await gt(e,l.newHash),h=Tl(u,m);h<r||i.push({oldPath:d.path,newPath:l.path,oldHash:d.oldHash,newHash:l.newHash,similarity:h,oldMode:d.oldMode,newMode:l.newMode})}return i}var za=107927;function Ds(e){let t=new Map,n=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let f=(r+Math.imul(o,97))%za;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%za;t.set(i,(t.get(i)??0)+n)}let s=[];for(let[i,a]of t)s.push({hash:i,count:a});return s.sort((i,a)=>i.hash-a.hash),s}function Ol(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let i=e[o];if(!i)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=i.hash)break;r+=f.count,s++}let a=i.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===i.hash&&(c=f.count,s++)}a<c?(r+=c-a,n+=a):n+=c,o++}for(;s<t.length;){let i=t[s];i&&(r+=i.count),s++}return{srcCopied:n,literalAdded:r}}function Tl(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Va(e.length,Ds(e),t.length,Ds(t))}function Va(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Ol(t,r);return Math.floor(i*100/o)}async function Hl(e,t,n,r){let o=[];for(let d of t)if(d.oldHash){let l=await gt(e,d.oldHash);o.push({size:l.length,chunks:Ds(l)})}else o.push(null);let s=[];for(let d of n)if(d.newHash){let l=await gt(e,d.newHash);s.push({size:l.length,chunks:Ds(l)})}else s.push(null);let i=[];for(let d=0;d<t.length;d++){let l=t[d],u=o[d];if(!(!l||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=Va(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=ir(l.path)===ir(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}i.sort((d,l)=>l.similarity-d.similarity||l.nameScore-d.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:l,addIdx:u}of i){if(a.has(l)||c.has(u))continue;a.add(l),c.add(u);let m=t[l],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:d,oldMode:m.oldMode,newMode:h.newMode})}return f}function Cn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let d=Math.max(0,n-o-a),l=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+d),p=t.slice(o,o+l);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Oe();Je();async function et(e,t){let n=await Z(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=be(n.target):(s=!0,o="HEAD detached");let i=t?.index??await q(e),a=zo(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await Ko(e,c,i,a),l=await Rt(e,i),u=[],m=[];for(let g of l)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>Ce(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Vo(m,h);return Al(e,r,s,o,i,d,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Ya(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Al(e,t,n,r,o,s,i,a,c,f){let d=[],l=!1,u=await N(e,"CHERRY_PICK_HEAD"),m=await N(e,"REVERT_HEAD"),h=await N(e,"MERGE_HEAD"),p=!u&&!h,w=await At(e)?await lt(e):null;if(n&&w){let R=z(w.onto);d.push(`interactive rebase in progress; onto ${R}`)}else if(n){let R=await Sr(e);if(R){let y=t===R?"at":"from";d.push(`HEAD detached ${y} ${z(R)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let R=await pe(e),y=await an(e,R,r);if(y){let $=Kn(y,{abbreviated:f?.fromCommit});for(let A of $.trimEnd().split(`
|
|
97
|
+
`))d.push(A);l=!0}}if(l&&(w||u||m||h)&&d.push(""),w&&h)Ya(d,w),d.push(""),a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0;else if(w){let R=Pt(o),y=await e.fs.exists(T(e.gitDir,"MERGE_MSG"));Ya(d,w);let A=w.headName==="detached HEAD"?null:be(w.headName),L=z(w.onto),G=A?` branch '${A}' on '${L}'`:"";if(R)d.push(`You are currently rebasing${G}.`),d.push(' (fix conflicts and then run "git rebase --continue")'),d.push(' (use "git rebase --skip" to skip this patch)'),d.push(' (use "git rebase --abort" to check out the original branch)');else if(y)d.push(`You are currently rebasing${G}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let V=G?`You are currently editing a commit while rebasing${G}.`:"You are currently editing a commit during a rebase.";d.push(V),d.push(' (use "git commit --amend" to amend the current commit)'),d.push(' (use "git rebase --continue" once you are satisfied with your changes)')}l=!0}else u?(d.push(`You are currently cherry-picking commit ${z(u)}.`),a.length>0?d.push(' (fix conflicts and run "git cherry-pick --continue")'):d.push(' (all conflicts fixed: run "git cherry-pick --continue")'),d.push(' (use "git cherry-pick --skip" to skip this patch)'),d.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),l=!0):m?(d.push(`You are currently reverting commit ${z(m)}.`),a.length>0?d.push(' (fix conflicts and run "git revert --continue")'):d.push(' (all conflicts fixed: run "git revert --continue")'),d.push(' (use "git revert --skip" to skip this patch)'),d.push(' (use "git revert --abort" to cancel the revert operation)'),l=!0):h&&(a.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),l=!0);if(await wt(e)){let y=(await Ee(e,"BISECT_START"))?.trim()??"";d.push(`You are currently bisecting, started from branch '${y}'.`),d.push(' (use "git bisect reset" to get back to the original branch)'),l=!0}let k=f?.isInitial??!t;k&&(d.push(""),d.push(f?.fromCommit?"Initial commit":"No commits yet"),l=!0);let b=null;p&&(b=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let x=i.some(R=>R.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',P=!1;if(s.length>0){l&&d.push(""),d.push("Changes to be committed:"),b&&d.push(b);for(let R of s)d.push(` ${Xa(R.status,R.path,R.displayPath)}`);d.push(""),P=!0}if(a.length>0){!P&&l&&d.push(""),d.push("Unmerged paths:"),p&&(t?d.push(' (use "git restore --staged <file>..." to unstage)'):d.push(' (use "git rm --cached <file>..." to unstage)')),a.some(y=>y.status==="deleted by us"||y.status==="deleted by them"||y.status==="both deleted")?d.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):d.push(' (use "git add <file>..." to mark resolution)');for(let y of a)d.push(` ${vl(y.status,y.path)}`);d.push(""),P=!0}if(i.length>0){!P&&l&&d.push(""),d.push("Changes not staged for commit:"),d.push(x),d.push(' (use "git restore <file>..." to discard changes in working directory)');for(let R of i)d.push(` ${Xa(R.status,R.path)}`);d.push(""),P=!0}if(c.length>0){!P&&l&&d.push(""),d.push("Untracked files:"),d.push(' (use "git add <file>..." to include in what will be committed)');for(let R of c)d.push(` ${R}`);d.push(""),P=!0}let C=s.length>0||!!h&&a.length===0;return!P&&l&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!P&&l&&i.length===0&&a.length===0&&c.length===0&&d.push(""),i.length>0||a.length>0?d.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?d.push('nothing added to commit but untracked files present (use "git add" to track)'):k?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 Ko(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await M(e,t)).tree);let i=await fe(e,s),a=new Map(ve(n).map(m=>[m.path,m])),c=[];for(let[m,h]of a){if(o.has(m))continue;let p=i.get(m);p?p.hash!==h.hash&&c.push({path:m,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:m,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[m,h]of i)o.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await Qe(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)=>Ce(m.path,h.path))}function zo(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Ce(r.path,o.path))}function Vo(e,t){if(e.length===0)return[];let n=new Set;for(let o of t){let s=o.indexOf("/");for(;s!==-1;)n.add(o.slice(0,s+1)),s=o.indexOf("/",s+1)}let r=new Set;for(let o of e){let s=o.split("/");if(s.length===1){r.add(o);continue}let i=!1;for(let a=1;a<s.length;a++){let c=`${s.slice(0,a).join("/")}/`;if(!n.has(c)){r.add(c),i=!0;break}}i||r.add(o)}return[...r].sort()}function Xa(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function vl(e,t){return`${e}:`.padEnd(17)+t}async function an(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await N(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await N(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:d,behind:l}=await Fo(e,f,c);return{upstream:a,ahead:d,behind:l,gone:!1}}function Za(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 Kn(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
|
-
`}
|
|
110
|
-
`),await
|
|
111
|
-
`),await
|
|
112
|
-
`)}
|
|
113
|
-
`:""}function Pn(e){return e.entries.some(t=>t.stage>0)?{stdout:
|
|
114
|
-
`,exitCode:1}:null}async function js(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");if(r)return
|
|
115
|
-
`):
|
|
116
|
-
`);for(let a of i)await rt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function
|
|
117
|
-
`);for(let c of a){let f=o.get(c);f&&(await rt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=ht(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:
|
|
118
|
-
`);for(let f of c){let d=i.entries.find(m=>m.path===f&&m.stage===r),
|
|
119
|
-
`)}return{stdout:"",stderr:"",exitCode:0}}async function
|
|
120
|
-
`)}
|
|
121
|
-
`)}var Ja=5;function
|
|
109
|
+
`}Oe();Vt();Je();async function Ms(e){let t=await ze(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await N(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function cn(e){let t="";return await N(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
|
|
110
|
+
`),await N(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
|
|
111
|
+
`),await qn(e),t}function Sl(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
|
+
`)}
|
|
113
|
+
`:""}function Pn(e){return e.entries.some(t=>t.stage>0)?{stdout:Sl(e),stderr:`error: you need to resolve your current index first
|
|
114
|
+
`,exitCode:1}:null}async function js(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");if(r)return Dl(e,t,n,r);let o=await q(e),s=t.map(a=>Le(a,n)),i=o.entries.filter(a=>a.stage===0&&ye(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&ye(s,c.path))?_(`error: path '${t[0]}' is unmerged
|
|
115
|
+
`):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
116
|
+
`);for(let a of i)await rt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Dl(e,t,n,r){let o=await fe(e,r),s=await q(e),i=t.map(c=>Le(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
117
|
+
`);for(let c of a){let f=o.get(c);f&&(await rt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=ht(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Pe()}))}return await re(e,s),{stdout:"",stderr:"",exitCode:0}}async function Gs(e,t,n,r,o){if(!e.workTree)return O("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await q(e),a=t.map(f=>Le(f,n)),c=new Set;for(let f of i.entries)ye(a,f.path)&&c.add(f.path);if(c.size===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
118
|
+
`);for(let f of c){let d=i.entries.find(m=>m.path===f&&m.stage===r),l=!d&&i.entries.find(m=>m.path===f&&m.stage===0),u=d||l;if(u)await rt(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let m=T(e.workTree,f);await e.fs.exists(m)&&await e.fs.rm(m)}else if(i.entries.some(h=>h.path===f&&h.stage>0))return _(`error: path '${f}' does not have ${r===2?"our":"their"} version
|
|
119
|
+
`)}return{stdout:"",stderr:"",exitCode:0}}async function zn(e,t,n){if(!e.workTree)return"";let r=await We(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=T(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let l=await e.fs.readFileBuffer(f);i.set(c,await pt("blob",l))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let d=s.get(c);if(d===void 0){a.push(`D ${c}`);continue}let l=i.get(c);l===null?a.push(`D ${c}`):(d!==f||l!==void 0&&l!==f)&&a.push(`M ${c}`)}for(let[c]of s)o.has(c)||i.get(c)!=null&&a.push(`A ${c}`);return a.length===0?"":(a.sort((c,f)=>{let d=c.slice(2),l=f.slice(2);return d<l?-1:d>l?1:0}),`${a.join(`
|
|
120
|
+
`)}
|
|
121
|
+
`)}var Ja=5;function Ml(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Ja?Ja-1:t,i=e.slice(0,o).map(c=>` ${z(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
|
|
122
122
|
any of your branches:
|
|
123
123
|
|
|
124
124
|
${i.join(`
|
|
@@ -129,10 +129,10 @@ to do so with:
|
|
|
129
129
|
|
|
130
130
|
git branch <new-branch-name> ${z(e[0].hash)}
|
|
131
131
|
|
|
132
|
-
`}async function
|
|
133
|
-
`}async function
|
|
134
|
-
`,exitCode:0};let a=await q(e),c=Pn(a);if(c)return c;let f=await X(e),
|
|
135
|
-
${p}`,exitCode:0}}async function Rn(e,t,n,r,o){let s=await q(e),i=Pn(s);if(i)return i;let a=await X(e),c=await M(e,t),f=c.tree,d=null;if(a&&(d=(await M(e,a)).tree),d!==f){let b=await kn(e,d,f,s);if(!b.success)return b.errorOutput??
|
|
132
|
+
`}async function Yo(e,t){let n=await M(e,t);return`Previous HEAD position was ${z(t)} ${ie(n.message)}
|
|
133
|
+
`}async function Ls(e,t,n){let r=await Uo(e,t,{targetHash:n});return r.length>0?Ml(r):t!==n?Yo(e,t):""}async function ar(e,t,n,r,o,s){let i=await Z(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
|
|
134
|
+
`,exitCode:0};let a=await q(e),c=Pn(a);if(c)return c;let f=await X(e),l=(await M(e,r)).tree,u=null;if(f&&(u=(await M(e,f)).tree),u!==l){let b=await kn(e,u,l,a);if(!b.success)return b.errorOutput??_("error: checkout would overwrite local changes");a={version:2,entries:b.newEntries},await re(e,a),await Te(e,b.worktreeOps)}let m="";i?.type==="direct"&&f&&(m=await Ls(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??J;await Fe(e,"HEAD",n),await dt(e);let p=await cn(e);await te(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:r,isBranchCheckout:!0});let g=await zn(e,l,a),w=await pe(e),k=await an(e,w,t);return k&&(g+=Kn(k)),{stdout:g,stderr:`${m}Switched to branch '${t}'
|
|
135
|
+
${p}`,exitCode:0}}async function Rn(e,t,n,r,o){let s=await q(e),i=Pn(s);if(i)return i;let a=await X(e),c=await M(e,t),f=c.tree,d=null;if(a&&(d=(await M(e,a)).tree),d!==f){let b=await kn(e,d,f,s);if(!b.success)return b.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:b.newEntries},await re(e,s),await Te(e,b.worktreeOps)}let l=await Z(e),u=l?.type==="direct"&&a===t;if(await Y(e,"HEAD",t),!u){await Ga(e,t);let b=l?.type==="symbolic"?l.target.replace(/^refs\/heads\//,""):a??J;await te(e,n,"HEAD",a,t,`checkout: moving from ${b} to ${t}`)}let m=await cn(e);await r?.hooks?.emitPost("post-checkout",{prevHead:a,newHead:t,isBranchCheckout:!1});let h=z(t),p=ie(c.message),g=l?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Ls(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
|
|
136
136
|
`:w=`Note: switching to '${o.detachAdviceTarget}'.
|
|
137
137
|
|
|
138
138
|
You are in 'detached HEAD' state. You can look around, make experimental
|
|
@@ -151,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 i=r.rest??[],a=await U(o.fs,o.cwd,t);return S(a)?a:
|
|
157
|
-
`),await
|
|
154
|
+
`,w+=m,{stdout:await zn(e,f,s),stderr:w,exitCode:0}}oe();ue();me();nn();var Qa=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),jr={stdout:`You need to start by "git bisect start"
|
|
155
|
+
`,stderr:"",exitCode:1};async function Xo(e){let t=await Ee(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||O("no current commit")}function ec(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[B.string().name("subcommand").describe("Subcommand or custom term").optional(),B.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
|
|
156
|
+
`,exitCode:1};let i=r.rest??[],a=await U(o.fs,o.cwd,t);return S(a)?a:_l(a,o.env,t,s,i)}});jl(n,t),Gl(n,t),Nl(n,t),Fl(n,t),Bl(n,t),Wl(n,t),Kl(n,t),Vl(n,t),Yl(n,t)}function jl(e,t){e.command("start",{description:"Start bisecting",args:[B.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Q.string().describe("Alternate term for new/bad"),"term-bad":Q.string().describe("Alternate term for new/bad"),"term-old":Q.string().describe("Alternate term for old/good"),"term-good":Q.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=qe(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return Qa.has(a)?O(`'${a}' is not a valid term`):Qa.has(c)?O(`'${c}' is not a valid term`):a===c?O("'bad' and 'good' terms must be different"):tc(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function tc(e,t,n,r,o,s,i,a){await wt(e)&&await Hs(e);let c=await Z(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await $e(e,"BISECT_START",f+`
|
|
157
|
+
`),await $e(e,"BISECT_TERMS",`${o}
|
|
158
158
|
${s}
|
|
159
|
-
`),await
|
|
160
|
-
`),a&&await
|
|
161
|
-
`,exitCode:1}:Mr(e,t,n,r,s,o[0])}async function Mr(e,t,n,r,o,s){let i;if(s){let f=await $t(e,s);if(S(f))return f;i=f}else{let f=await
|
|
162
|
-
`,stderr:"",exitCode:0}}})}async function
|
|
163
|
-
`,exitCode:1}}})}function
|
|
164
|
-
`)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],d=c[2].trim(),
|
|
165
|
-
`;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let
|
|
166
|
-
`,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Ts(e),d=c===0?f.termGood:f.termBad,
|
|
167
|
-
`,{stdout:i,stderr:"",exitCode:0};if(
|
|
159
|
+
`),await $e(e,"BISECT_NAMES",`
|
|
160
|
+
`),a&&await $e(e,"BISECT_FIRST_PARENT",""),i){let u=await X(e);u&&await $e(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await $t(e,u);if(S(m))return m;await Y(e,`refs/bisect/${o}`,m);let h=await M(e,m);await bt(e,`# ${o}: [${m}] ${ie(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await $t(e,g);if(S(w))return w;await Y(e,`refs/bisect/${s}-${w}`,w);let k=await M(e,w);await bt(e,`# ${s}: [${w}] ${ie(k.message)}`)}}let d=r.map(u=>`'${u}'`),l=d.length>0?` ${d.join(" ")}`:"";return await bt(e,`git bisect start${l}`),Gr(e,t,n)}function Gl(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:[B.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);return S(s)?s:Ll(s,o.env,t,n,r.rev)}})}async function Ll(e,t,n,r,o){if(!await wt(e))return jr;let s=await Dr(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return Mr(e,t,n,i,s,o)}async function _l(e,t,n,r,o){if(!await wt(e))return jr;let s=await Dr(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
|
|
161
|
+
`,exitCode:1}:Mr(e,t,n,r,s,o[0])}async function Mr(e,t,n,r,o,s){let i;if(s){let f=await $t(e,s);if(S(f))return f;i=f}else{let f=await Xo(e);if(S(f))return f;i=f}let a=await M(e,i),c=ie(a.message);return r===o.termBad?await Y(e,`refs/bisect/${o.termBad}`,i):await Y(e,`refs/bisect/${o.termGood}-${i}`,i),await bt(e,`# ${r}: [${i}] ${c}`),await bt(e,`git bisect ${r} ${i}`),Gr(e,t,n)}function Nl(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[B.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return jr;let i=n.revs??[];if(i.length===0){let a=await Xo(s);if(S(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let d=await $t(s,a);if(S(d))return d;c=d}await Y(s,`refs/bisect/skip-${c}`,c);let f=await M(s,c);await bt(s,`# skip: [${c}] ${ie(f.message)}`),await bt(s,`git bisect skip ${c}`)}return Gr(s,r.env,t)}})}function Fl(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[B.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;return await wt(s)?Ul(s,r.env,t,n.commit):{stdout:`We are not bisecting.
|
|
162
|
+
`,stderr:"",exitCode:0}}})}async function Ul(e,t,n,r){let o=(await Ee(e,"BISECT_START"))?.trim()??"";if(await Hs(e),r){let s=await $t(e,r);return S(s)?s:Rn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await N(e,s);if(i)return ar(e,o,s,i,t,n);let a=await Be(e,o);if(a)return Rn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Bl(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;return await wt(s)?{stdout:await Ee(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
|
|
163
|
+
`,exitCode:1}}})}function Wl(e,t){e.command("replay",{description:"Replay a bisect log",args:[B.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:T(r.cwd,n.logfile);if(!await r.fs.exists(i))return O(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return ql(s,r.env,t,a)}})}async function ql(e,t,n,r){await wt(e)&&await Hs(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
|
|
164
|
+
`)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],d=c[2].trim(),l;if(f==="start"){let u=d?d.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];l=await tc(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")l=await Mr(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")l=await Mr(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 bt(e,`# skip: [${u}] ${ie(m.message)}`),await bt(e,`git bisect skip ${u}`)}l=await Gr(e,t,n)}else continue;if(l.exitCode!==0)return l;s+=l.stdout}return{stdout:s,stderr:"",exitCode:0}}function Kl(e,t){e.command("run",{description:"Bisect by running a command",args:[B.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return jr;if(!r.exec)return O("bisect run requires shell execution support");let i=n.cmd.join(" ");return zl(s,r.env,t,i,r.exec,r.cwd)}})}async function zl(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
|
|
165
|
+
`;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await Xo(e);if(S(u))return u;await Y(e,`refs/bisect/skip-${u}`,u);let m=await M(e,u);await bt(e,`# skip: [${u}] ${ie(m.message)}`),await bt(e,`git bisect skip ${u}`);let h=await Gr(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
|
|
166
|
+
`,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Ts(e),d=c===0?f.termGood:f.termBad,l=await Mr(e,t,n,d,f,void 0);if(i+=l.stdout,l.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
|
|
167
|
+
`,{stdout:i,stderr:"",exitCode:0};if(l.exitCode!==0)return{stdout:i,stderr:l.stderr,exitCode:l.exitCode}}}function Vl(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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return{stdout:"",stderr:`error: no terms defined
|
|
168
168
|
`,exitCode:1};let{termBad:i,termGood:a}=await Dr(s);return n["term-good"]?{stdout:`${a}
|
|
169
169
|
`,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
|
|
170
170
|
`,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
|
|
171
171
|
and ${i} for the new state.
|
|
172
|
-
`,stderr:"",exitCode:0}}})}function
|
|
173
|
-
`,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(
|
|
174
|
-
`;return{stdout:f,stderr:"",exitCode:0}}})}async function
|
|
172
|
+
`,stderr:"",exitCode:0}}})}function Yl(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 U(o.fs,o.cwd,t);if(S(s))return s;let i=s;if(!await wt(i))return jr;let a=await Ts(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
|
|
173
|
+
`,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(Wn(),ja)),f="";for await(let d of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${z(d.hash)} ${ie(d.commit.message)}
|
|
174
|
+
`;return{stdout:f,stderr:"",exitCode:0}}})}async function Gr(e,t,n){let r=await Ts(e);return!r.badHash||r.goodHashes.length===0?{stdout:_a(r),stderr:"",exitCode:0}:(await $e(e,"BISECT_ANCESTORS_OK",""),Xl(e,t,n,r))}async function Xl(e,t,n,r){let o=await La(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 Fa(e,o.hash);return await bt(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
|
|
176
176
|
The first bad commit could be any of:
|
|
177
177
|
`;for(let i of r.skipHashes)s+=i+`
|
|
178
178
|
`;return r.badHash&&(s+=r.badHash+`
|
|
179
179
|
`),s+=`We cannot bisect more!
|
|
180
|
-
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await
|
|
181
|
-
`),{stdout:
|
|
182
|
-
`);return t[t.length-1]===""&&t.pop(),t}function
|
|
183
|
-
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var
|
|
180
|
+
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await $e(e,"BISECT_HEAD",o.hash);else{let s=await Rn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await $e(e,"BISECT_EXPECTED_REV",o.hash+`
|
|
181
|
+
`),{stdout:Na(o),stderr:"",exitCode:0}}ne();oe();function vt(e){if(e.length===0)return[];let t=e.split(`
|
|
182
|
+
`);return t[t.length-1]===""&&t.pop(),t}function Nt(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 Zl=4,nc=1024,_s=100,Us=0,Ns=1,cr=2;function Jo(e){let t=1;for(;t*t<e;)t++;return t}function Jl(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let i=0;i<e.length;i++){let a=e[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,o[i]=c}for(let i=0;i<t.length;i++){let a=t[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,s[i]=c}return{classes1:o,classes2:s,classInfo:r}}function Ql(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let i=o,a=0,c=s-i;for(;a<c&&e[t-1-a]===n[r-1-a];)a++;return{dstart:i,dend1:t-a-1,dend2:r-a-1}}function rc(e,t,n,r){t-n>_s&&(n=t-_s),r-t>_s&&(r=t+_s);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Us)o++;else if(f===cr)s++;else break}if(o===0)return!1;let i=0,a=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===Us)i++;else if(f===cr)a++;else break}return i===0?!1:(i+=o,a+=s,a*Zl<a+i)}function eu(e,t,n,r,o,s,i,a,c,f){let d=new Uint8Array(t),l=new Uint8Array(r),u=Math.min(Jo(t),nc);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?d[g]=Us:w>=u?d[g]=cr:d[g]=Ns}let m=Math.min(Jo(r),nc);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?l[g]=Us:w>=m?l[g]=cr:l[g]=Ns}let h=[];for(let g=s;g<=i;g++)d[g]===Ns||d[g]===cr&&!rc(d,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)l[g]===Ns||l[g]===cr&&!rc(l,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var $n=20,sc=4,tu=256,nu=256,Fs=2147483647;function ut(e,t){return e[t]??0}function ru(e,t,n,r,o,s,i,a,c,f){let d=t-s,l=n-o,u=t-o,m=n-s,h=u-m&1,p=u,g=u,w=m,k=m;i[u]=t,a[m]=n;for(let b=1;;b++){let E=!1;p>d?i[--p-1]=-1:++p,g<l?i[++g+1]=-1:--g;for(let x=g;x>=p;x-=2){let P;ut(i,x-1)>=ut(i,x+1)?P=ut(i,x-1)+1:P=ut(i,x+1);let C=P,R=P-x;for(;P<n&&R<s&&e[P]===r[R];)P++,R++;if(P-C>$n&&(E=!0),i[x]=P,h&&w<=x&&x<=k&&ut(a,x)<=P)return{i1:P,i2:R,minLo:!0,minHi:!0}}w>d?a[--w-1]=Fs:++w,k<l?a[++k+1]=Fs:--k;for(let x=k;x>=w;x-=2){let P;ut(a,x-1)<ut(a,x+1)?P=ut(a,x-1):P=ut(a,x+1)-1;let C=P,R=P-x;for(;P>t&&R>o&&e[P-1]===r[R-1];)P--,R--;if(C-P>$n&&(E=!0),a[x]=P,!h&&p<=x&&x<=g&&P<=ut(i,x))return{i1:P,i2:R,minLo:!0,minHi:!0}}if(!c){if(E&&b>tu){let x=0,P=null;for(let C=g;C>=p;C-=2){let R=C>u?C-u:u-C,y=ut(i,C),$=y-C,A=y-t+($-o)-R;if(A>sc*b&&A>x&&t+$n<=y&&y<n&&o+$n<=$&&$<s){let L=!0;for(let G=1;G<=$n;G++)if(e[y-G]!==r[$-G]){L=!1;break}L&&(x=A,P={i1:y,i2:$,minLo:!0,minHi:!1})}}if(P)return P;x=0,P=null;for(let C=k;C>=w;C-=2){let R=C>m?C-m:m-C,y=ut(a,C),$=y-C,A=n-y+(s-$)-R;if(A>sc*b&&A>x&&t<y&&y<=n-$n&&o<$&&$<=s-$n){let L=!0;for(let G=0;G<$n;G++)if(e[y+G]!==r[$+G]){L=!1;break}L&&(x=A,P={i1:y,i2:$,minLo:!1,minHi:!0})}}if(P)return P}if(b>=f){let x=-1,P=-1;for(let y=g;y>=p;y-=2){let $=Math.min(ut(i,y),n),A=$-y;s<A&&($=s+y,A=s),x<$+A&&(x=$+A,P=$)}let C=Fs,R=Fs;for(let y=k;y>=w;y-=2){let $=Math.max(t,ut(a,y)),A=$-y;A<o&&($=o+y,A=o),$+A<C&&(C=$+A,R=$)}return n+s-C<x-(t+o)?{i1:P,i2:x-P,minLo:!0,minHi:!1}:{i1:R,i2:C-R,minLo:!1,minHi:!0}}}}}function Qo(e,t,n,r,o,s,i,a,c,f,d,l,u,m){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=ru(e,t,n,r,o,s,d,l,u,m);Qo(e,t,h.i1,r,o,h.i2,i,a,c,f,d,l,h.minLo,m),Qo(e,h.i1,n,r,h.i2,s,i,a,c,f,d,l,h.minHi,m)}}function su(e,t,n,r){let o=[],s=0,i=0,a=1,c=1;for(;s<e.length||i<t.length;){if(s<e.length&&i<t.length&&!n[s]&&!r[i]){o.push({type:"keep",line:e[s]??"",oldLineNo:a++,newLineNo:c++}),s++,i++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:a++,newLineNo:0}),s++;for(;i<t.length&&r[i];)o.push({type:"insert",line:t[i]??"",oldLineNo:0,newLineNo:c++}),i++}return o}var oc=200,ic=20,ac=100,ou=1,iu=21,au=-30,cu=6,fu=-4,du=10,lu=24,uu=17,mu=23,hu=17,pu=60;function Zo(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>=oc)return oc}return-1}function cc(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=Zo(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Zo(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===ic){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Zo(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===ic){r.postIndent=0;break}return r}function fc(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=ou),e.endOfFile&&(t.penalty+=iu);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=au*r,t.penalty+=cu*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?du:fu:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?uu:lu:t.penalty+=s?hu:mu))}function gu(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return pu*n+(e.penalty-t.penalty)}function dc(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let d=(l,u)=>t[l]===t[u];for(;;){if(a!==i){let l,u,m;do{for(l=a-i,u=-1;i>0&&d(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=a,f>c&&(u=a);!(a>=r||!d(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(l!==a-i);if(a!==m)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(a-l-1>g&&(g=a-l-1),a-ac>g&&(g=a-ac);g<=a;g++){let w={effectiveIndent:0,penalty:0},k=cc(n,r,g);fc(k,w);let b=cc(n,r,g-l);fc(b,w),(h===-1||gu(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function ei(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=Jl(e,t),{dstart:f,dend1:d,dend2:l}=Ql(i,n,a,r);if(f>d)for(let u=f;u<r-(n-1-d);u++)s[u]=1;else if(f>l)for(let u=f;u<n-(r-1-l);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=eu(i,n,a,r,c,f,d,l,o,s);if(m>0&&p>0){let g=new Array(m);for(let P=0;P<m;P++)g[P]=i[u[P]];let w=new Array(p);for(let P=0;P<p;P++)w[P]=a[h[P]];let k={},b={},E=m+p+3,x=Math.max(nu,Jo(E));Qo(g,0,m,w,0,p,o,s,u,h,k,b,!1,x)}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;dc(o,i,e,n,s,r),dc(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function it(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=ei(e,t);return su(e,t,o,s)}var wu=3;function bu(e,t=wu){if(e.length===0)return[];let n=[];for(let a=0;a<e.length;a++){let c=e[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),i=Math.min(e.length-1,r+t);for(let a=1;a<n.length;a++){let c=n[a]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=d}return o.push({start:s,end:i}),o.map(a=>yu(e,a.start,a.end))}function yu(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let d=t;d<=n;d++){let l=e[d];if(l)switch(l.type){case"keep":c||(r=l.oldLineNo,c=!0),f||(s=l.newLineNo,f=!0),o++,i++,a.push({type:"context",content:l.line});break;case"delete":c||(r=l.oldLineNo,c=!0),o++,a.push({type:"delete",content:l.line});break;case"insert":f||(s=l.newLineNo,f=!0),i++,a.push({type:"insert",content:l.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="insert"){r=l.newLineNo>1?l.newLineNo-1:0;break}}if(i===0)for(let d=t;d<=n;d++){let l=e[d];if(l&&l.type==="delete"){s=l.oldLineNo>1?l.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function Bs(e){return e?e.length<40?e:z(e):"0000000"}function lc(e,t,n,r,o,s){let{path:i,oldMode:a,newMode:c}=t;e.push(`diff --git a/${i} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${i}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(e.push(`old mode ${a}`),e.push(`new mode ${c}`))}function Eu(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,d=e.renameTo??r,l=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(lc(m,e,d,l,u,f),o!==s){if(a||c){let h=Bs(a),p=Bs(c);l||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${d} differ`):l?m.push(`Binary files /dev/null and b/${d} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${d} differ`)}return`${m.join(`
|
|
184
184
|
`)}
|
|
185
|
-
`}function yt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d
|
|
185
|
+
`}function yt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Ie(n),l=Ie(r);if(d||l)return Eu(e,d,l);let u=vt(n),m=vt(r),h=n.length>0&&n.endsWith(`
|
|
186
186
|
`),p=r.length>0&&r.endsWith(`
|
|
187
|
-
`),g="\0NOEOL",w=
|
|
187
|
+
`),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let k=m;!p&&m.length>0&&(k=m.slice(),k[k.length-1]+=g);let b=it(w,k);if(!h||!p)for(let A of b)A.line.includes(g)&&(A.line=A.line.replace(g,""));let E=bu(b);if(E.length===0&&!c)return"";let x=e.isNew??n==="",P=e.isDeleted??r==="",C=[];if(lc(C,e,f,x,P,c),E.length===0)return`${C.join(`
|
|
188
188
|
`)}
|
|
189
|
-
`;if(i||a){let
|
|
189
|
+
`;if(i||a){let A=Bs(i),L=Bs(a);x||P?C.push(`index ${A}..${L}`):c?C.push(`index ${A}..${L} ${o||"100644"}`):o&&s&&o!==s?C.push(`index ${A}..${L}`):C.push(`index ${A}..${L} ${o||"100644"}`)}let R=A=>A.includes(" ")?" ":"";x?(C.push("--- /dev/null"),C.push(`+++ b/${f}${R(f)}`)):P?(C.push(`--- a/${t}${R(t)}`),C.push("+++ /dev/null")):(C.push(`--- a/${t}${R(t)}`),C.push(`+++ b/${f}${R(f)}`));let y=u.length,$=m.length;for(let A of E){let L=A.oldCount===1?`${A.oldStart}`:`${A.oldStart},${A.oldCount}`,G=A.newCount===1?`${A.newStart}`:`${A.newStart},${A.newCount}`,V="";for(let v=A.oldStart-2;v>=0;v--){let W=u[v];if(W&&/^[a-zA-Z$_]/.test(W)){V=` ${W.trimEnd().slice(0,79)}`;break}}C.push(`@@ -${L} +${G} @@${V}`);let j=A.oldStart,I=A.newStart;for(let v of A.lines)switch(v.type){case"context":C.push(` ${v.content}`),(!h&&j===y||!p&&I===$)&&C.push("\"),j++,I++;break;case"delete":C.push(`-${v.content}`),!h&&j===y&&C.push("\"),j++;break;case"insert":C.push(`+${v.content}`),!p&&I===$&&C.push("\"),I++;break}}return`${C.join(`
|
|
190
190
|
`)}
|
|
191
|
-
`}
|
|
192
|
-
`)[0],boundary:i,previous:a}}
|
|
191
|
+
`}oe();Oe();async function In(e,t,n){return(await fe(e,t)).get(n)?.hash??null}async function uc(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:i}=await Qe(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function ku(e,t,n,r,o,s){let i=await In(e,(await M(e,t)).tree,n);if(!i){let p=new Map,g=await M(e,t);for(let w of r)p.set(w.finalIdx,On(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await se(e,i),c=vt(a),f=new Array(o.length),d=[...r],l=t,u=n,m=c;for(;d.length>0;){let p=await M(e,l);if(p.parents.length===0){for(let y of d)f[y.finalIdx]=On(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!0,void 0);break}let g=await In(e,p.tree,u),w=null,k=[];for(let y of p.parents){let $=await M(e,y),A=u,L=await In(e,$.tree,A);if(!L){let G=await uc(e,$.tree,p.tree,u);G&&(A=G,L=await In(e,$.tree,A))}if(L&&(k.push({hash:y,path:A,blobHash:L}),L===g)){w={hash:y,path:A};break}}if(w){l=w.hash,u=w.path;continue}if(k.length===0){for(let y of d)f[y.finalIdx]=On(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,void 0);break}let b=k[0],E=await se(e,b.blobHash),x=vt(E),P=it(x,m),C=new Map;for(let y of P)y.type==="keep"&&C.set(y.newLineNo,y.oldLineNo);let R=[];for(let y of d){let $=C.get(y.currentLine);$!==void 0?R.push({finalIdx:y.finalIdx,currentLine:$}):f[y.finalIdx]=On(l,u,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,{hash:b.hash,path:b.path})}d=R,l=b.hash,u=b.path,m=x}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function mc(e,t,n,r){let o=await M(e,t),s=await In(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await se(e,s),a=vt(i),c=r?.startLine??1,f=r?.endLine??a.length,d=a.slice(c-1,f),l=new Array(d.length),u=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await M(e,m);if(g.parents.length===0){for(let C of u)l[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await In(e,g.tree,h),k=[],b=null;for(let C of g.parents){let R=await M(e,C),y=h,$=await In(e,R.tree,y);if(!$){let A=await uc(e,R.tree,g.tree,h);A&&(y=A,$=await In(e,R.tree,y))}if($){let A={hash:C,path:y,blobHash:$};if(k.push(A),$===w){b=A;break}}}if(b){m=b.hash,h=b.path;continue}if(k.length===0){for(let C of u)l[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(k.length===1){let C=k[0],R=await se(e,C.blobHash),y=vt(R),$=it(y,p),A=new Map;for(let G of $)G.type==="keep"&&A.set(G.newLineNo,G.oldLineNo);let L=[];for(let G of u){let V=A.get(G.currentLine);V!==void 0?L.push({finalIdx:G.finalIdx,currentLine:V}):l[G.finalIdx]=On(m,h,G.currentLine,c+G.finalIdx,d[G.finalIdx],g,!1,{hash:C.hash,path:C.path})}u=L,m=C.hash,h=C.path,p=y;continue}let E=[];for(let C of k){let R=await se(e,C.blobHash),y=vt(R),$=it(y,p),A=new Map;for(let L of $)L.type==="keep"&&A.set(L.newLineNo,L.oldLineNo);E.push({info:C,newToOld:A})}let x=new Map;for(let C of u){let R=!1;for(let y=0;y<E.length;y++){let $=E[y],A=$.newToOld.get(C.currentLine);if(A!==void 0){let L=x.get(y);L||(L={info:$.info,lines:[]},x.set(y,L)),L.lines.push({finalIdx:C.finalIdx,currentLine:A}),R=!0;break}}R||(l[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:k[0].hash,path:k[0].path}))}let P=x.get(0);for(let[C,R]of x){if(C===0)continue;let y=await ku(e,R.info.hash,R.info.path,R.lines,d,c);for(let[$,A]of y)l[$]=A}if(P&&P.lines.length>0){u=P.lines,m=P.info.hash,h=P.info.path;let C=await se(e,P.info.blobHash);p=vt(C)}else break}return l}function On(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
|
|
192
|
+
`)[0],boundary:i,previous:a}}ne();oe();Oe();oe();ue();function xu(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 Cu(e,t){let n=xu(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),i=r.getUTCDate().toString().padStart(2,"0"),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${i} ${a}:${c}:${f} ${t}`}function Pu(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(l=>l.finalLine)),i=String(s).length,a=e.some(l=>l.origPath!==t),c=0;if(!o)for(let l of e){let u=r?`<${l.author.email}>`:l.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let l of e)l.origPath.length>f&&(f=l.origPath.length);let d=[];for(let l of e){let u;n?u=l.boundary?`^${l.hash.slice(0,39)}`:l.hash:u=l.boundary?`^${l.hash.slice(0,7)}`:l.hash.slice(0,8);let m=a?` ${l.origPath.padEnd(f)}`:"";if(o)d.push(`${u}${m} ${String(l.finalLine).padStart(i)}) ${l.content}`);else{let h=r?`<${l.author.email}>`:l.author.name,p=Cu(l.author.timestamp,l.author.timezone);d.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(l.finalLine).padStart(i)}) ${l.content}`)}}return`${d.join(`
|
|
193
193
|
`)}
|
|
194
|
-
`}function
|
|
194
|
+
`}function Ru(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 $u(e,t,n){if(e.startsWith("/"))return st(n,e);let r=st(n,t);return r===""||r==="."?e:`${r}/${e}`}function hc(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[B.string().name("args").variadic().optional()],options:{lineRange:Q.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s;if(!i.workTree)return O("this operation must be run in a work tree");let a=await Ke(i);if(S(a))return a;let c=n.args??[],f=o.passthrough??[],d=null,l=null;if(f.length>0?(l=f[f.length-1],c.length>0&&(d=c[0])):c.length===2?(d=c[0],l=c[1]):c.length===1&&(l=c[0]),!l)return O("no file specified");let u=$u(l,r.cwd,i.workTree),m;if(d){let P=await $t(i,d);if(S(P))return P;m=await _e(i,P)}else m=a;let h=await M(i,m),p=await fe(i,h.tree);if(!p.has(u))return O(`no such path ${u} in ${d??"HEAD"}`);let g=p.get(u).hash,w=await se(i,g);if(Ie(w))return O(`cannot blame binary file '${u}'`);let k,b;if(n.lineRange){let P=n.lineRange,C=P.match(/^(\d+),(\d+)$/);if(C)k=parseInt(C[1],10),b=parseInt(C[2],10);else return O(`invalid -L range: '${P}'`)}let E;try{E=await mc(i,m,u,{startLine:k,endLine:b})}catch(P){let C=P instanceof Error?P.message:String(P);return O(C)}let x;return n.porcelain||n.linePorcelain?x=Ru(E,!!n.linePorcelain):x=Pu(E,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:x,stderr:"",exitCode:0}}})}ne();Xe();ln();ne();var Iu=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ou=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function St(e,t){let n=Tu(t),r=new Date((e+n*60)*1e3),o=Iu[r.getUTCDay()],s=Ou[r.getUTCMonth()],i=r.getUTCDate(),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),d=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${d} ${t}`}function ti(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 Tu(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}oe();Oe();var Ws=new TextDecoder;function pc(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
|
|
197
197
|
`&&t++;return e[e.length-1]!==`
|
|
198
|
-
`&&t++,t}function
|
|
198
|
+
`&&t++,t}function fr(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 Lr(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await gt(e,a.newHash);pn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:pc(Ws.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await gt(e,a.oldHash);pn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:pc(Ws.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await gt(e,a.oldHash),f=await gt(e,a.newHash);if(pn(c)||pn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=Nt(Ws.decode(c)),l=Nt(Ws.decode(f)),u=it(d,l),m=0,h=0;for(let p of u)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:m,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=Cn(a.oldPath,a.newPath),f=0,d=0;if(a.similarity<100&&a.oldHash&&a.newHash){let l=await se(e,a.oldHash),u=await se(e,a.newHash);if(!Ie(l)&&!Ie(u)){let m=Nt(l),h=Nt(u),p=it(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:d})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=Cn(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function Zt(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${St(r.timestamp,r.timezone)}`),i)return a.join(`
|
|
199
199
|
`)+(a.length>0?`
|
|
200
|
-
`:"");let c=await
|
|
200
|
+
`:"");let c=await Ne(e,t,n),{remaining:f,renames:d}=await Qe(e,c),{fileStats:l,modeLines:u}=await Lr(e,f,d),m=0,h=0;for(let g of l)m+=g.insertions,h+=g.deletions;let p=fr(l.length,m,h);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
|
|
201
201
|
`)+(a.length>0?`
|
|
202
|
-
`:"")}var qs=80;function
|
|
202
|
+
`:"")}var qs=80;function Hu(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 _r(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)),i=n,a=s;if(a+o+6+i>qs){let h=Math.floor(qs*3/8)-o-6;i>h&&(i=Math.max(h,6));let p=qs-o-6-i;a>p?a=p:i=qs-o-6-a}for(let h of e)h.path=Hu(h.path,a);let c=a,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),k,b;if(n<=i)k=h.insertions,b=h.deletions;else{let P=y=>y===0?0:1+Math.floor(y*(i-1)/n),C=P(g),R=C<2&&h.insertions>0&&h.deletions>0?2:C;h.insertions<h.deletions?(k=P(h.insertions),b=R-k):(b=P(h.deletions),k=R-b)}let E="+".repeat(k)+"-".repeat(b),x=E?` ${E}`:"";f.push(` ${p} | ${w}${x}`)}let m=fr(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 Tn(e,t,n){let r=await
|
|
205
|
-
`;return c}Xe();
|
|
204
|
+
`}async function Tn(e,t,n){let r=await Ne(e,t,n),{remaining:o,renames:s}=await Qe(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await Lr(e,o,s);i.sort((f,d)=>f.sortKey<d.sortKey?-1:f.sortKey>d.sortKey?1:0);let c=_r(i);for(let f of a)c+=`${f}
|
|
205
|
+
`;return c}Xe();xe();oe();me();Vt();async function Au(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i=await M(e,s);for(let a of i.parents)n.has(a)||r.push(a)}return n}async function fn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a=await M(e,i);for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Dt(e,t,n){if(t===n)return[t];let r=await Au(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let d=await M(e,f);for(let l of d.parents)s.has(l)||i.push(l)}if(o.length<=1)return o;let c=[];for(let f of o){let d=!1;for(let l of o)if(l!==f&&await fn(e,f,l)){d=!0;break}d||c.push(f)}return c.length<=1?c:vu(e,t,n,c)}async function vu(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,d=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function l(u){let m=c.get(u);if(m!==void 0)return m;let h=(await M(e,u)).committer.timestamp;return c.set(u,h),h}for(;d.length>0;){let u=0,m=await l(d[0].hash);for(let k=1;k<d.length;k++){let b=d[k],E=await l(b.hash),x=d[u];(E>m||E===m&&b.seq<x.seq)&&(u=k,m=E)}let h=d.splice(u,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await M(e,h.hash);for(let k of w.parents)d.push({hash:k,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function Vn(e,t,n){let r=await jt(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
|
|
206
206
|
`:`Merge branch '${t}' into ${n}
|
|
207
207
|
`}async function Ks(e,t,n){let r=await M(e,t),o=await M(e,n),s=z(t),i=z(n),a=`Updating ${s}..${i}
|
|
208
|
-
`;if(e.workTree){let f=await q(e),d=await va(e,r.tree,o.tree,f);if(!d.success){let
|
|
209
|
-
${c}`,stderr:"",exitCode:0}}
|
|
210
|
-
`);let k=`refs/heads/${n.name}`,b=await
|
|
211
|
-
`);let E="";if(!f){let x=await X(s),
|
|
208
|
+
`;if(e.workTree){let f=await q(e),d=await va(e,r.tree,o.tree,f);if(!d.success){let l=d.errorOutput;return{stdout:a+l.stdout,stderr:l.stderr,exitCode:l.exitCode}}await re(e,{version:2,entries:d.newEntries}),await Te(e,d.worktreeOps)}await gn(e,n);let c=await Tn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
|
|
209
|
+
${c}`,stderr:"",exitCode:0}}oe();Ge();me();function gc(e,t){e.command("branch",{description:"List, create, or delete branches",args:[B.string().name("name").describe("Branch name").optional(),B.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:Q.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=await Z(s),a=i?.type==="symbolic"?be(i.target):null,c=!!n.forceMove;if(n.move||c){let w,k;if(n.newName)w=n.name,k=n.newName;else if(n.name){if(!a)return O("not on any branch");w=a,k=n.name}else return O("branch name required");let b=`refs/heads/${w}`,E=`refs/heads/${k}`,x=await N(s,b);if(!x)return O(`no branch named '${w}'`);if(await At(s)&&(await lt(s))?.headName===b)return O(`branch ${b} is being rebased at ${s.workTree}`);let P=await N(s,E);if(P&&!c)return O(`a branch named '${k}' already exists`);P&&await de(s,E);let C=await ze(s,b);await Y(s,E,x),await de(s,b),w===a&&await Fe(s,"HEAD",E),C.length>0&&await bn(s,E,C);let R=`Branch: renamed ${b} to ${E}`;if(await te(s,r.env,E,x,x,R),w===a){let A=await Bt(s,r.env);await Ue(s,"HEAD",{oldHash:x,newHash:J,...A,message:R}),await Ue(s,"HEAD",{oldHash:J,newHash:x,...A,message:R})}let y=await pe(s),$=`branch "${w}"`;return y[$]&&(y[`branch "${k}"`]=y[$],delete y[$],await Ye(s,y)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return O("branch name required");let w=n.name===a;if(!w&&!a&&await At(s)&&(await lt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
|
|
210
|
+
`);let k=`refs/heads/${n.name}`,b=await N(s,k);if(!b)return _(`error: branch '${n.name}' not found
|
|
211
|
+
`);let E="";if(!f){let x=await X(s),C=(await pe(s))[`branch "${n.name}"`],R=C?.remote,y=C?.merge,$=null,A=null;if(R&&y&&($=y.replace(/^refs\/heads\//,`refs/remotes/${R}/`),A=await N(s,$)),A&&$){if(!(b===A||await fn(s,b,A))){let j=x!=null&&(b===x||await fn(s,b,x))?`warning: not deleting branch '${n.name}' that is not yet merged to
|
|
212
212
|
'${$}', even though it is merged to HEAD
|
|
213
|
-
`:"";return
|
|
213
|
+
`:"";return _(`${j}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
|
-
`)}x!=null&&(b===x||await
|
|
216
|
+
`)}x!=null&&(b===x||await fn(s,b,x))||(E=`warning: deleting branch '${n.name}' that has been merged to
|
|
217
217
|
'${$}', but not yet merged to HEAD
|
|
218
|
-
`)}else if(x&&b!==x&&!await
|
|
218
|
+
`)}else if(x&&b!==x&&!await fn(s,b,x))return _(`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
|
|
222
|
-
`,stderr:E,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,k=n.name||a;if(!k)return O("could not set upstream of HEAD when it does not point to any branch.");if(!await
|
|
223
|
-
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,k;if(w){let
|
|
221
|
+
`)}return await de(s,k),{stdout:`Deleted branch ${n.name} (was ${z(b)}).
|
|
222
|
+
`,stderr:E,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,k=n.name||a;if(!k)return O("could not set upstream of HEAD when it does not point to any branch.");if(!await N(s,`refs/heads/${k}`))return O(`branch '${k}' does not exist`);let E=w.indexOf("/");if(E<0)return O(`the requested upstream branch '${w}' does not exist`);let x=w.slice(0,E),P=w.slice(E+1);if(!await N(s,`refs/remotes/${w}`))return O(`the requested upstream branch '${w}' does not exist`);let R=await pe(s),y=`branch "${k}"`;return R[y]||(R[y]={}),R[y].remote=x,R[y].merge=`refs/heads/${P}`,await Ye(s,R),{stdout:"",stderr:`branch '${k}' set up to track '${w}'.
|
|
223
|
+
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,k;if(w){let P=await He(s,w,`not a valid object name: '${w}'`);if(S(P))return P;k=P.hash}else if(k=await X(s),!k)return O("Not a valid object name: 'HEAD'.");let b=`refs/heads/${n.name}`;if(await N(s,b))return O(`a branch named '${n.name}' already exists`);await Y(s,b,k);let x=w??"HEAD";return await te(s,r.env,b,null,k,`branch: Created from ${x}`),{stdout:"",stderr:"",exitCode:0}}let d=n.verbose||0,l=!n.remotes||n.all,u=n.remotes||n.all,m=[];if(l&&!a){let w=await X(s);if(w){let k=await At(s),b;if(k){let E=await lt(s);if(E?.headName){let x=be(E.headName);if(x==="detached HEAD"){let P=await Sr(s);b=`(no branch, rebasing detached HEAD ${P?z(P):"(null)"})`}else b=`(no branch, rebasing ${x})`}else b="(no branch)"}else{let E=await Sr(s);E?b=`(HEAD detached ${w===E?"at":"from"} ${z(E)})`:b="(no branch)"}m.push({displayName:b,hash:w,isCurrent:!0,branchName:null})}}if(l){let w=await we(s,"refs/heads");for(let k of w){let b=be(k.name);m.push({displayName:b,hash:k.hash,isCurrent:b===a,branchName:b})}}if(u){let w=await we(s,"refs/remotes");for(let k of w){let b=k.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${b}`:b,hash:k.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(d===0)return{stdout:`${m.map(k=>k.isCurrent?`* ${k.displayName}`:` ${k.displayName}`).join(`
|
|
224
224
|
`)}
|
|
225
|
-
`,stderr:"",exitCode:0};let h=d>=1?await
|
|
225
|
+
`,stderr:"",exitCode:0};let h=d>=1?await pe(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let k=w.isCurrent?"* ":" ",b=w.displayName.padEnd(p),E=z(w.hash),x="";try{let C=await M(s,w.hash);x=ie(C.message)}catch{}let P="";if(h&&w.branchName){let C=await an(s,h,w.branchName);if(C){let R=Za(C,d>=2);R&&(P=` ${R}`)}}g.push(`${k}${b} ${E}${P} ${x}`)}return{stdout:`${g.join(`
|
|
226
226
|
`)}
|
|
227
|
-
`,stderr:"",exitCode:0}}})}
|
|
228
|
-
`)}})}async function
|
|
229
|
-
${d}`,exitCode:0}}async function
|
|
227
|
+
`,stderr:"",exitCode:0}}})}ne();Xe();xe();oe();Ge();me();nn();Je();function wc(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[B.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"),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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return O("--ours and --theirs are incompatible");if(o.passthrough.length>0){let l=ct(i,r.cwd),u=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return O("cannot specify both a revision and --ours/--theirs");let h=await He(i,a,`invalid reference: ${a}`);if(S(h))return h;m=h.commit.tree}return n.ours||n.theirs?Gs(i,u,l,n.theirs?3:2):js(i,u,l,m)}if(n.orphan)return n.branch?O("--orphan and -b are incompatible"):n.ours||n.theirs?O("--orphan and --ours/--theirs are incompatible"):a?Du(i,a,r.env,t):O("you must specify a branch to checkout");if(!a)return O("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Mu(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Su(i,r.env,t);let c=`refs/heads/${a}`,f=await N(i,c);if(f)return bc(i,a,c,f,r.env,t);let d=await Be(i,a);if(d){let l=await _e(i,d);return ju(i,a,l,r.env,t)}if(i.workTree){let l=await q(i),u=ss(l,a);if(u)return await rt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
|
|
228
|
+
`)}})}async function Su(e,t,n){let r=await Ms(e);return r?bc(e,r.name,r.refName,r.hash,t,n):O("no previous branch")}async function Du(e,t,n,r){let o=`refs/heads/${t}`;if(await N(e,o))return O(`a branch named '${t}' already exists`);let i=await q(e),a=Pn(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await M(e,c)).tree),await Fe(e,"HEAD",o),await dt(e);let d=await cn(e);await r?.hooks?.emitPost("post-checkout",{prevHead:c,newHead:J,isBranchCheckout:!0});let l="";return f&&(l=await zn(e,f,i)),{stdout:l,stderr:`Switched to a new branch '${t}'
|
|
229
|
+
${d}`,exitCode:0}}async function Mu(e,t,n,r,o=!1){if(r?.hooks){let p=await r.hooks.emitPre("pre-checkout",{target:t,mode:"create-branch"});if(p)return{stdout:"",stderr:p.message??"",exitCode:1}}let s=await Z(e),i=await X(e),a=`refs/heads/${t}`,c=await N(e,a);if(c&&!o)return O(`a branch named '${t}' already exists`);if(o){let p=await q(e),g=Pn(p);if(g)return g}i&&await Y(e,a,i),await Fe(e,"HEAD",a),await dt(e);let f=await cn(e),d=s?.type==="symbolic"?s.target.replace(/^refs\/heads\//,""):i??J;i&&(c?c!==i&&await te(e,n,a,c,i,"branch: Reset to HEAD"):await te(e,n,a,null,i,"branch: Created from HEAD")),await te(e,n,"HEAD",i,i??J,`checkout: moving from ${d} to ${t}`),await r?.hooks?.emitPost("post-checkout",{prevHead:i,newHead:i??J,isBranchCheckout:!0});let l="";if(o&&i){let p=await q(e),g=await M(e,i);l=await zn(e,g.tree,p)}let u=await pe(e),m=await an(e,u,t);m&&(l+=Kn(m));let h=c?`Switched to and reset branch '${t}'
|
|
230
230
|
`:`Switched to a new branch '${t}'
|
|
231
|
-
`;return{stdout:
|
|
231
|
+
`;return{stdout:l,stderr:`${h}${f}`,exitCode:0}}async function bc(e,t,n,r,o,s){if(s?.hooks){let i=await s.hooks.emitPre("pre-checkout",{target:t,mode:"switch"});if(i)return{stdout:"",stderr:i.message??"",exitCode:1}}return ar(e,t,n,r,o,s)}async function ju(e,t,n,r,o){if(o?.hooks){let s=await o.hooks.emitPre("pre-checkout",{target:t,mode:"detach"});if(s)return{stdout:"",stderr:s.message??"",exitCode:1}}return Rn(e,n,r,o,{detachAdviceTarget:t})}ne();xe();ne();function ni(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}=ei(e,t);return Gu(o,n,s,r)}function Gu(e,t,n,r){let o=[],s=0,i=0;for(;s<t||i<r;){for(;s<t&&i<r&&!e[s]&&!n[i];)s++,i++;if(s>=t&&i>=r)break;let a=s,c=i;for(;s<t&&e[s];)s++;for(;i<r&&n[i];)i++;(s>a||i>c)&&o.push({buffer1:[a,s-a],buffer2:[c,i-c]})}return o}function Lu(e,t,n){let r=[];for(let c of ni(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 ni(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,d=c.oStart+c.oLength,l=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>d)break;d=Math.max(d,u.oStart+u.oLength),l.push(u),a++}if(l.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of l){let k=w.oStart,b=k+w.oLength,E=w.abStart,x=E+w.abLength,P=u[w.ab];P.abMin=Math.min(E,P.abMin),P.abMax=Math.max(x,P.abMax),P.oMin=Math.min(k,P.oMin),P.oMax=Math.max(b,P.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(d-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(d-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,d),b:n.slice(p,g)})}s=d}return i(t.length),o}function _u(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Lu(e,t,n),i=[],a=[];function c(){a.length&&(i.push({type:"ok",lines:a}),a=[])}for(let f of s)f.stable?a.push(...f.content):o&&yc(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),Uu(Nu(i))}function Nr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,i="=".repeat(o),a=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,c=_u(e,t,n),f=!1,d=[];for(let l of c)l.type==="ok"?d.push(...l.lines):(f=!0,d.push(s,...l.a,i,...l.b,a));return{conflict:f,result:d}}function Nu(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Fu(n));return t}function Fu(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(yc(t,n))return[e];let r=ni(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+a.buffer1[1],l=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(a.buffer2[0],l)}),s=d}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function Uu(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function Yn(e,t,n,r){let o=Nr(Et(e),Et(t),Et(n),{a:r.a,b:r.b,markerSize:r.markerSize}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(ri);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
|
|
232
232
|
`)}
|
|
233
233
|
`:a.join(`
|
|
234
234
|
`)}function Et(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 ni(e){return e.endsWith("\0")?e.slice(0,-1):e}function Ec(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}Ee();se();Jt();de();Ln();Ie();Je();qt();var fr=new TextDecoder,Hn=new TextEncoder,kc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function St(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Ku(e,t,n,r),f=await Vu(e,s,i,a,c,o);return Yu(e,s,o,f)}async function Ur(e,t,n,r){let o=await At(e,t,n),s=await M(e,t),i=await M(e,n);if(o.length===0)return{...await St(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await St(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Hc(e,t,n,o,1);return{...await St(e,a,s.tree,i.tree,r),baseTree:a}}async function Ku(e,t,n,r){let o=await fe(e,t),s=await fe(e,n),i=await fe(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let d=o.get(f)??null,u=s.get(f)??null,l=i.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=u?{hash:u.hash,mode:u.mode}:null,p=l?{hash:l.hash,mode:l.mode}:null,g=(d?1:0)|(u?2:0)|(l?4:0),w=d?.hash??null,k=u?.hash??null,b=l?.hash??null,E=0;w!==null&&w===k&&(E|=3),w!==null&&w===b&&(E|=5),k!==null&&k===b&&(E|=6);let x={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:E,merged:{result:null,clean:!1},pathConflict:!1};if(zu(x)){c.set(f,x);continue}c.set(f,x)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function zu(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,i=r?.hash??null;return s===o&&i===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===i&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&i===null?(e.merged={result:null,clean:!0},!0):i===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&i!==o?(r?e.merged={result:{hash:i,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Vu(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[j,I]of n)r.has(j)||a.push({path:j,status:"deleted",oldHash:I.hash,oldMode:I.mode}),o.has(j)||c.push({path:j,status:"deleted",oldHash:I.hash,oldMode:I.mode});for(let[j,I]of r)n.has(j)||a.push({path:j,status:"added",newHash:I.hash,newMode:I.mode});for(let[j,I]of o)n.has(j)||c.push({path:j,status:"added",newHash:I.hash,newMode:I.mode});let f=await Qe(e,a),d=await Qe(e,c);if(f.renames.length===0&&d.renames.length===0)return i;let u=new Map,l=new Map;for(let j of f.renames)u.set(j.oldPath,j);for(let j of d.renames)l.set(j.oldPath,j);let m=new Set;for(let[j]of r)!n.has(j)&&o.has(j)&&m.add(j);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(j,I,A=0){i.msgBuf.push({sortKey:j,subOrder:A,text:I})}for(let j of[...n.keys()].sort()){let I=u.get(j),A=l.get(j);if(!I&&!A)continue;let W=n.get(j);if(h.add(j),I&&A)if(h.add(I.newPath),h.add(A.newPath),I.newPath===A.newPath){let F=r.get(I.newPath),D=o.get(A.newPath);if(F.hash===D.hash)i.entries.push(mt(I.newPath,F));else{let K=ri(t,I.newPath);K.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],K.pathnames=[j,I.newPath,A.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let F=r.get(I.newPath),D=o.get(A.newPath),K=await Tc(e,W,F,D,s);K.conflict&&w(j,`Auto-merging ${j}`,-1),i.conflicts.push({path:j,reason:"rename-rename",oursPath:I.newPath,theirsPath:A.newPath}),w(j,`CONFLICT (rename/rename): ${j} renamed to ${I.newPath} in ${p} and to ${A.newPath} in ${g}.`),i.entries.push(mt(j,W,1)),i.entries.push(tt(I.newPath,F.mode,K.hash,2)),i.entries.push(tt(A.newPath,D.mode,K.hash,3)),i.worktreeBlobs.set(I.newPath,{hash:K.hash,mode:F.mode}),i.worktreeBlobs.set(A.newPath,{hash:K.hash,mode:D.mode})}else if(I){h.add(I.newPath);let F=o.get(j),D=r.get(I.newPath),K=m.has(I.newPath);if(F)if(K)await Ic(e,i,I.newPath,j,W,D,F,r,o,!1,s);else if(F.hash===W.hash&&D.hash===W.hash)i.entries.push(mt(I.newPath,D));else if(F.hash===W.hash)i.entries.push(mt(I.newPath,D));else if(D.hash===W.hash)i.entries.push(tt(I.newPath,D.mode,F.hash));else{let ie=ri(t,I.newPath);ie.stages=[{hash:W.hash,mode:W.mode},{hash:D.hash,mode:D.mode},{hash:F.hash,mode:F.mode}],ie.pathnames=[j,I.newPath,j],ie.filemask=7,ie.merged={result:null,clean:!1}}else{let ie=o.get(I.newPath);if(i.conflicts.push({path:I.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:j}),w(I.newPath,`CONFLICT (rename/delete): ${j} renamed to ${I.newPath} in ${p}, but deleted in ${g}.`),ie){i.conflicts.push({path:I.newPath,reason:"add-add"}),w(I.newPath,`Auto-merging ${I.newPath}`,0),w(I.newPath,`CONFLICT (add/add): Merge conflict in ${I.newPath}`,1),i.entries.push(mt(I.newPath,D,2)),i.entries.push(mt(I.newPath,ie,3));let ee=await zs(e,D.hash,ie.hash,D.mode,s);i.worktreeBlobs.set(I.newPath,{hash:ee,mode:D.mode})}else i.entries.push(tt(I.newPath,W.mode,W.hash,1)),i.entries.push(mt(I.newPath,D,2)),i.worktreeBlobs.set(I.newPath,{hash:D.hash,mode:D.mode}),D.hash!==W.hash&&w(I.newPath,`CONFLICT (modify/delete): ${I.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${I.newPath} left in tree.`,1)}}else if(A){h.add(A.newPath);let F=r.get(j),D=o.get(A.newPath),K=m.has(A.newPath);if(F)if(K)await Ic(e,i,A.newPath,j,W,F,D,r,o,!0,s);else if(F.hash===W.hash&&D.hash===W.hash)i.entries.push(mt(A.newPath,D));else if(F.hash===W.hash)i.entries.push(mt(A.newPath,D));else if(D.hash===W.hash)i.entries.push(tt(A.newPath,D.mode,F.hash));else{let ie=ri(t,A.newPath);ie.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],ie.pathnames=[j,j,A.newPath],ie.filemask=7,ie.merged={result:null,clean:!1}}else{let ie=r.get(A.newPath);if(i.conflicts.push({path:A.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:j}),w(A.newPath,`CONFLICT (rename/delete): ${j} renamed to ${A.newPath} in ${g}, but deleted in ${p}.`),ie){i.conflicts.push({path:A.newPath,reason:"add-add"}),w(A.newPath,`Auto-merging ${A.newPath}`,0),w(A.newPath,`CONFLICT (add/add): Merge conflict in ${A.newPath}`,1),i.entries.push(mt(A.newPath,ie,2)),i.entries.push(mt(A.newPath,D,3));let ee=await zs(e,ie.hash,D.hash,ie.mode,s);i.worktreeBlobs.set(A.newPath,{hash:ee,mode:ie.mode})}else i.entries.push(tt(A.newPath,W.mode,W.hash,1)),i.entries.push(mt(A.newPath,D,3)),i.worktreeBlobs.set(A.newPath,{hash:D.hash,mode:D.mode}),D.hash!==W.hash&&w(A.newPath,`CONFLICT (modify/delete): ${A.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${A.newPath} left in tree.`,1)}}}let k=new Set(f.renames.map(j=>j.newPath)),b=new Set(d.renames.map(j=>j.newPath)),E=xc(n,r),x=xc(n,o),C=Cc(E,o,n),P=Cc(x,r,n),R=Pc(f.renames,C),y=Pc(d.renames,P),$=Rc(R),v=Rc(y);for(let j of[...$.keys()])v.has(j)&&($.delete(j),v.delete(j));let G=new Set($.keys()),L=new Set(v.keys());if(v.size>0)for(let j of a){if(j.status!=="added"||k.has(j.path))continue;let I=$c(j.path,v,G);if(!I)continue;if(t.has(I)||n.has(I)||r.has(I)||o.has(I)){if(r.has(I)){w(I,`CONFLICT (implicit dir rename): Existing file/dir at ${I} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let F=r.get(j.path),D=o.get(I)??n.get(I);i.entries.push(tt(I,F.mode,F.hash,2)),D&&i.entries.push(tt(I,D.mode,D.hash,3)),i.worktreeBlobs.set(I,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:I,reason:"add-add"}),w(I,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${I}.`,1);let K=t.get(j.path);K&&(K.merged={result:null,clean:!0}),h.add(j.path);continue}let A=r.get(j.path);i.entries.push(tt(I,A.mode,A.hash,2)),i.worktreeBlobs.set(I,{hash:A.hash,mode:A.mode}),i.conflicts.push({path:I,reason:"directory-rename"}),w(I,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${I}.`,1);let W=t.get(j.path);W&&(W.merged={result:null,clean:!0}),h.add(j.path)}if($.size>0)for(let j of c){if(j.status!=="added"||b.has(j.path))continue;let I=$c(j.path,$,L);if(!I)continue;if(t.has(I)||n.has(I)||r.has(I)||o.has(I)){if(o.has(I)){w(I,`CONFLICT (implicit dir rename): Existing file/dir at ${I} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let F=o.get(j.path),D=r.get(I)??n.get(I);D&&i.entries.push(tt(I,D.mode,D.hash,2)),i.entries.push(tt(I,F.mode,F.hash,3)),i.worktreeBlobs.set(I,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:I,reason:"add-add"}),w(I,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${I}.`,1);let K=t.get(j.path);K&&(K.merged={result:null,clean:!0}),h.add(j.path);continue}let A=o.get(j.path);i.entries.push(tt(I,A.mode,A.hash,3)),i.worktreeBlobs.set(I,{hash:A.hash,mode:A.mode}),i.conflicts.push({path:I,reason:"directory-rename"}),w(I,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${I}.`,1);let W=t.get(j.path);W&&(W.merged={result:null,clean:!0}),h.add(j.path)}let Y=new Set(i.entries.map(j=>j.path));for(let j of Y){let I=t.get(j);I&&(I.merged={result:null,clean:!0})}for(let j of h){if(Y.has(j))continue;let I=t.get(j);if(!I||I.merged.clean)continue;I.filemask===7&&!I.pathConflict||(I.merged={result:null,clean:!0})}return i}function xc(e,t){let n=new Set;for(let s of e.keys()){let i=kt(s);for(;i;)n.add(i),i=kt(i)}let r=new Set;for(let s of t.keys()){let i=kt(s);for(;i;)r.add(i),i=kt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Cc(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=kt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=kt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=kt(s)}return r}function Pc(e,t){let n=new Map;for(let r of e){let o=kt(r.oldPath),s=kt(r.newPath),i=!0;for(;;){if(!i){let a=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let a=n.get(o);a||(a=new Map,n.set(o,a)),a.set(s,(a.get(s)??0)+1)}if(i=!1,!o||!s)break;o=kt(o),s=kt(s)}}return n}function Rc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function $c(e,t,n){let r=kt(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let i=e.slice(r.length+1);return s?`${s}/${i}`:i}r=kt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function kt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Ic(e,t,n,r,o,s,i,a,c,f=!1,d){let u=f?a.get(n):c.get(n),l=f?i:s;if(u.hash===l.hash){t.entries.push(tt(n,u.mode,u.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Tc(e,o,s,i,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(u.hash===h.hash)t.entries.push(tt(n,u.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(mt(n,u,2)),t.entries.push(tt(n,i.mode,h.hash,3));let p=await zs(e,u.hash,h.hash,u.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:u.mode})}else{t.entries.push(tt(n,s.mode,h.hash,2)),t.entries.push(mt(n,u,3));let p=await zs(e,h.hash,u.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Tc(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(tn(t.mode)||tn(n.mode)||tn(r.mode))return{hash:n.hash,conflict:!0};let a=await re(e,t.hash),c=await re(e,n.hash),f=await re(e,r.hash);if($e(c)||$e(f)||$e(a))return{hash:n.hash,conflict:!0};let d=Et(a),u=Et(c),l=Et(f),m=_r(u,d,l);if(!m.conflict)return{hash:await oi(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,k=zn(c,a,f,{a:g,b:w,markerSize:i??7});return{hash:await Re(e,"blob",Hn.encode(k)),conflict:!0}}async function zs(e,t,n,r,o){let s=await re(e,t),i=await re(e,n),a=zn(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Re(e,"blob",Hn.encode(a))}function mt(e,t,n=0){return tt(e,t.mode,t.hash,n)}function tt(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:xe()}}async function Yu(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(He(m,h.merged.result.hash,h.merged.result.mode));continue}await Xu(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),d=[],u=new Set;for(let m of o)m.stage===0&&(d.push(m),u.add(m.path));for(let[m,h]of a)u.has(m)||d.push(He(m,h.hash,h.mode));d.sort((m,h)=>ke(m.path,h.path));let l=await Ae(e,d);return{entries:o,conflicts:s,messages:f,resultTree:l}}async function Xu(e,t,n,r,o,s,i){let a=t.path,[c,f,d]=t.stages,u=c?.hash??null,l=f?.hash??null,m=d?.hash??null;if(l===null&&m!==null&&u!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(He(a,u,c.mode,1)),r.push(He(a,m,d.mode,3)),i.set(a,{hash:m,mode:d.mode});return}if(m===null&&l!==null&&u!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(He(a,u,c.mode,1)),r.push(He(a,l,f.mode,2)),i.set(a,{hash:l,mode:f.mode});return}if(u===null&&l!==null&&m!==null){if(l===m){r.push(He(a,l,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await re(e,l),p=await re(e,m);if($e(h)||$e(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(He(a,l,f.mode,2)),r.push(He(a,m,d.mode,3)),i.set(a,{hash:l,mode:f.mode});return}let g=Et(""),w=Et(h),k=Et(p),b=_r(w,g,k,n);if(!b.conflict){let C=await oi(e,b.result);r.push(He(a,C,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(He(a,l,f.mode,2)),r.push(He(a,m,d.mode,3));let E=zn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),x=await Re(e,"blob",Hn.encode(E));i.set(a,{hash:x,mode:f.mode});return}if(u!==null&&l!==null&&m!==null){if(l===u){r.push(He(a,m,d.mode));return}if(m===u){r.push(He(a,l,f.mode));return}if(l===m){r.push(He(a,l,f.mode));return}if(s(a,`Auto-merging ${a}`,0),tn(c.mode)||tn(f.mode)||tn(d.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(He(a,u,c.mode,1)),r.push(He(a,l,f.mode,2)),r.push(He(a,m,d.mode,3)),i.set(a,{hash:l,mode:f.mode});return}let h=await re(e,u),p=await re(e,l),g=await re(e,m);if($e(p)||$e(g)||$e(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(He(a,u,c.mode,1)),r.push(He(a,l,f.mode,2)),r.push(He(a,m,d.mode,3)),i.set(a,{hash:l,mode:f.mode});return}let w=Et(h),k=Et(p),b=Et(g),E=_r(k,w,b,n);if(E.conflict){let x=t.pathnames[1],C=t.pathnames[2],P=x!==a||C!==a,R={path:a,reason:"content"};P&&(x!==a&&(R.oursOrigPath=x),C!==a&&(R.theirsOrigPath=C)),o.push(R),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(He(a,u,c.mode,1)),r.push(He(a,l,f.mode,2)),r.push(He(a,m,d.mode,3));let y=P?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",$=P?`${n?.b??"theirs"}:${C}`:n?.b??"theirs",v=zn(p,h,g,{a:y,b:$}),G=await Re(e,"blob",Hn.encode(v));i.set(a,{hash:G,mode:f.mode})}else{let x=await oi(e,E.result);r.push(He(a,x,f.mode))}return}}var Zu=200;async function Hc(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,u)=>d.timestamp-u.timestamp);let i=s.map(d=>d.hash),a=i[0],c=a,f=(await M(e,a)).tree;for(let d=1;d<i.length;d++){let u=i[d],l=(await M(e,u)).tree,m=null;if(o>=Zu)m=f;else{let g=await At(e,c,u);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await Hc(e,c,u,g,o+1)}let h=await St(e,m,f,l);f=await Ju(e,h,o);let p=Bt({type:"commit",tree:f,parents:[c,u],author:kc,committer:kc,message:"merged common ancestors"});c=await Re(e,"commit",p)}return f}async function Ju(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let d=s(a.path,1);if(d){r.push({...d,stage:0});continue}}if(a.reason==="rename-rename"){let d=a.oursPath??a.path,u=a.theirsPath??a.path,l=s(a.path,1),m=s(d,2),h=s(u,3);if(m&&h){let p=fr.decode((await pe(e,m.hash)).content),g=fr.decode((await pe(e,h.hash)).content),w=l?fr.decode((await pe(e,l.hash)).content):"",k=8+n*2,b=i.a??"Temporary merge branch 1",E=i.b??"Temporary merge branch 2",x=zn(p,w,g,{a:`${b}:${d}`,o:i.o,b:`${E}:${u}`,markerSize:k}),C=await Re(e,"blob",Hn.encode(x));r.push({path:d,mode:m.mode,hash:C,stage:0,stat:xe()}),r.push({path:u,mode:h.mode,hash:C,stage:0,stat:xe()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let d=fr.decode((await pe(e,c.hash)).content),u=fr.decode((await pe(e,f.hash)).content),l=a.reason==="content"?s(a.path,1):null,m=l?fr.decode((await pe(e,l.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,k=h?`${g}:${a.theirsOrigPath??a.path}`:g,b=zn(d,m,u,{a:w,o:i.o,b:k,markerSize:i.markerSize}),E=await Re(e,"blob",Hn.encode(b));r.push({path:a.path,mode:c.mode,hash:E,stage:0,stat:xe()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>ke(a.path,c.path)),Ae(e,r)}async function oi(e,t){let n=t.map(ni);if(n.length===0)return Re(e,"blob",Hn.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 ri(e){return e.endsWith("\0")?e.slice(0,-1):e}function yc(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}xe();oe();en();ue();Gn();Oe();Je();Vt();var dr=new TextDecoder,Hn=new TextEncoder,Ec={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Mt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Wu(e,t,n,r),f=await Ku(e,s,i,a,c,o);return zu(e,s,o,f)}async function Ur(e,t,n,r){let o=await Dt(e,t,n),s=await M(e,t),i=await M(e,n);if(o.length===0)return{...await Mt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await M(e,o[0]);return{...await Mt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Tc(e,t,n,o,1);return{...await Mt(e,a,s.tree,i.tree,r),baseTree:a}}async function Wu(e,t,n,r){let o=await fe(e,t),s=await fe(e,n),i=await fe(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let d=o.get(f)??null,l=s.get(f)??null,u=i.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=l?{hash:l.hash,mode:l.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(d?1:0)|(l?2:0)|(u?4:0),w=d?.hash??null,k=l?.hash??null,b=u?.hash??null,E=0;w!==null&&w===k&&(E|=3),w!==null&&w===b&&(E|=5),k!==null&&k===b&&(E|=6);let x={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:E,merged:{result:null,clean:!1},pathConflict:!1};if(qu(x)){c.set(f,x);continue}c.set(f,x)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function qu(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,i=r?.hash??null;return s===o&&i===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===i&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&i===null?(e.merged={result:null,clean:!0},!0):i===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&i!==o?(r?e.merged={result:{hash:i,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Ku(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[j,I]of n)r.has(j)||a.push({path:j,status:"deleted",oldHash:I.hash,oldMode:I.mode}),o.has(j)||c.push({path:j,status:"deleted",oldHash:I.hash,oldMode:I.mode});for(let[j,I]of r)n.has(j)||a.push({path:j,status:"added",newHash:I.hash,newMode:I.mode});for(let[j,I]of o)n.has(j)||c.push({path:j,status:"added",newHash:I.hash,newMode:I.mode});let f=await Qe(e,a),d=await Qe(e,c);if(f.renames.length===0&&d.renames.length===0)return i;let l=new Map,u=new Map;for(let j of f.renames)l.set(j.oldPath,j);for(let j of d.renames)u.set(j.oldPath,j);let m=new Set;for(let[j]of r)!n.has(j)&&o.has(j)&&m.add(j);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(j,I,v=0){i.msgBuf.push({sortKey:j,subOrder:v,text:I})}for(let j of[...n.keys()].sort()){let I=l.get(j),v=u.get(j);if(!I&&!v)continue;let W=n.get(j);if(h.add(j),I&&v)if(h.add(I.newPath),h.add(v.newPath),I.newPath===v.newPath){let F=r.get(I.newPath),D=o.get(v.newPath);if(F.hash===D.hash)i.entries.push(mt(I.newPath,F));else{let K=si(t,I.newPath);K.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],K.pathnames=[j,I.newPath,v.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let F=r.get(I.newPath),D=o.get(v.newPath),K=await Oc(e,W,F,D,s);K.conflict&&w(j,`Auto-merging ${j}`,-1),i.conflicts.push({path:j,reason:"rename-rename",oursPath:I.newPath,theirsPath:v.newPath}),w(j,`CONFLICT (rename/rename): ${j} renamed to ${I.newPath} in ${p} and to ${v.newPath} in ${g}.`),i.entries.push(mt(j,W,1)),i.entries.push(tt(I.newPath,F.mode,K.hash,2)),i.entries.push(tt(v.newPath,D.mode,K.hash,3)),i.worktreeBlobs.set(I.newPath,{hash:K.hash,mode:F.mode}),i.worktreeBlobs.set(v.newPath,{hash:K.hash,mode:D.mode})}else if(I){h.add(I.newPath);let F=o.get(j),D=r.get(I.newPath),K=m.has(I.newPath);if(F)if(K)await $c(e,i,I.newPath,j,W,D,F,r,o,!1,s);else if(F.hash===W.hash&&D.hash===W.hash)i.entries.push(mt(I.newPath,D));else if(F.hash===W.hash)i.entries.push(mt(I.newPath,D));else if(D.hash===W.hash)i.entries.push(tt(I.newPath,D.mode,F.hash));else{let ae=si(t,I.newPath);ae.stages=[{hash:W.hash,mode:W.mode},{hash:D.hash,mode:D.mode},{hash:F.hash,mode:F.mode}],ae.pathnames=[j,I.newPath,j],ae.filemask=7,ae.merged={result:null,clean:!1}}else{let ae=o.get(I.newPath);if(i.conflicts.push({path:I.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:j}),w(I.newPath,`CONFLICT (rename/delete): ${j} renamed to ${I.newPath} in ${p}, but deleted in ${g}.`),ae){i.conflicts.push({path:I.newPath,reason:"add-add"}),w(I.newPath,`Auto-merging ${I.newPath}`,0),w(I.newPath,`CONFLICT (add/add): Merge conflict in ${I.newPath}`,1),i.entries.push(mt(I.newPath,D,2)),i.entries.push(mt(I.newPath,ae,3));let ee=await zs(e,D.hash,ae.hash,D.mode,s);i.worktreeBlobs.set(I.newPath,{hash:ee,mode:D.mode})}else i.entries.push(tt(I.newPath,W.mode,W.hash,1)),i.entries.push(mt(I.newPath,D,2)),i.worktreeBlobs.set(I.newPath,{hash:D.hash,mode:D.mode}),D.hash!==W.hash&&w(I.newPath,`CONFLICT (modify/delete): ${I.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${I.newPath} left in tree.`,1)}}else if(v){h.add(v.newPath);let F=r.get(j),D=o.get(v.newPath),K=m.has(v.newPath);if(F)if(K)await $c(e,i,v.newPath,j,W,F,D,r,o,!0,s);else if(F.hash===W.hash&&D.hash===W.hash)i.entries.push(mt(v.newPath,D));else if(F.hash===W.hash)i.entries.push(mt(v.newPath,D));else if(D.hash===W.hash)i.entries.push(tt(v.newPath,D.mode,F.hash));else{let ae=si(t,v.newPath);ae.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:D.hash,mode:D.mode}],ae.pathnames=[j,j,v.newPath],ae.filemask=7,ae.merged={result:null,clean:!1}}else{let ae=r.get(v.newPath);if(i.conflicts.push({path:v.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:j}),w(v.newPath,`CONFLICT (rename/delete): ${j} renamed to ${v.newPath} in ${g}, but deleted in ${p}.`),ae){i.conflicts.push({path:v.newPath,reason:"add-add"}),w(v.newPath,`Auto-merging ${v.newPath}`,0),w(v.newPath,`CONFLICT (add/add): Merge conflict in ${v.newPath}`,1),i.entries.push(mt(v.newPath,ae,2)),i.entries.push(mt(v.newPath,D,3));let ee=await zs(e,ae.hash,D.hash,ae.mode,s);i.worktreeBlobs.set(v.newPath,{hash:ee,mode:ae.mode})}else i.entries.push(tt(v.newPath,W.mode,W.hash,1)),i.entries.push(mt(v.newPath,D,3)),i.worktreeBlobs.set(v.newPath,{hash:D.hash,mode:D.mode}),D.hash!==W.hash&&w(v.newPath,`CONFLICT (modify/delete): ${v.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${v.newPath} left in tree.`,1)}}}let k=new Set(f.renames.map(j=>j.newPath)),b=new Set(d.renames.map(j=>j.newPath)),E=kc(n,r),x=kc(n,o),P=xc(E,o,n),C=xc(x,r,n),R=Cc(f.renames,P),y=Cc(d.renames,C),$=Pc(R),A=Pc(y);for(let j of[...$.keys()])A.has(j)&&($.delete(j),A.delete(j));let L=new Set($.keys()),G=new Set(A.keys());if(A.size>0)for(let j of a){if(j.status!=="added"||k.has(j.path))continue;let I=Rc(j.path,A,L);if(!I)continue;if(t.has(I)||n.has(I)||r.has(I)||o.has(I)){if(r.has(I)){w(I,`CONFLICT (implicit dir rename): Existing file/dir at ${I} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let F=r.get(j.path),D=o.get(I)??n.get(I);i.entries.push(tt(I,F.mode,F.hash,2)),D&&i.entries.push(tt(I,D.mode,D.hash,3)),i.worktreeBlobs.set(I,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:I,reason:"add-add"}),w(I,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${I}.`,1);let K=t.get(j.path);K&&(K.merged={result:null,clean:!0}),h.add(j.path);continue}let v=r.get(j.path);i.entries.push(tt(I,v.mode,v.hash,2)),i.worktreeBlobs.set(I,{hash:v.hash,mode:v.mode}),i.conflicts.push({path:I,reason:"directory-rename"}),w(I,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${I}.`,1);let W=t.get(j.path);W&&(W.merged={result:null,clean:!0}),h.add(j.path)}if($.size>0)for(let j of c){if(j.status!=="added"||b.has(j.path))continue;let I=Rc(j.path,$,G);if(!I)continue;if(t.has(I)||n.has(I)||r.has(I)||o.has(I)){if(o.has(I)){w(I,`CONFLICT (implicit dir rename): Existing file/dir at ${I} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let F=o.get(j.path),D=r.get(I)??n.get(I);D&&i.entries.push(tt(I,D.mode,D.hash,2)),i.entries.push(tt(I,F.mode,F.hash,3)),i.worktreeBlobs.set(I,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:I,reason:"add-add"}),w(I,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${I}.`,1);let K=t.get(j.path);K&&(K.merged={result:null,clean:!0}),h.add(j.path);continue}let v=o.get(j.path);i.entries.push(tt(I,v.mode,v.hash,3)),i.worktreeBlobs.set(I,{hash:v.hash,mode:v.mode}),i.conflicts.push({path:I,reason:"directory-rename"}),w(I,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${I}.`,1);let W=t.get(j.path);W&&(W.merged={result:null,clean:!0}),h.add(j.path)}let V=new Set(i.entries.map(j=>j.path));for(let j of V){let I=t.get(j);I&&(I.merged={result:null,clean:!0})}for(let j of h){if(V.has(j))continue;let I=t.get(j);if(!I||I.merged.clean)continue;I.filemask===7&&!I.pathConflict||(I.merged={result:null,clean:!0})}return i}function kc(e,t){let n=new Set;for(let s of e.keys()){let i=kt(s);for(;i;)n.add(i),i=kt(i)}let r=new Set;for(let s of t.keys()){let i=kt(s);for(;i;)r.add(i),i=kt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function xc(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=kt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=kt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=kt(s)}return r}function Cc(e,t){let n=new Map;for(let r of e){let o=kt(r.oldPath),s=kt(r.newPath),i=!0;for(;;){if(!i){let a=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let a=n.get(o);a||(a=new Map,n.set(o,a)),a.set(s,(a.get(s)??0)+1)}if(i=!1,!o||!s)break;o=kt(o),s=kt(s)}}return n}function Pc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function Rc(e,t,n){let r=kt(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let i=e.slice(r.length+1);return s?`${s}/${i}`:i}r=kt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function kt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function $c(e,t,n,r,o,s,i,a,c,f=!1,d){let l=f?a.get(n):c.get(n),u=f?i:s;if(l.hash===u.hash){t.entries.push(tt(n,l.mode,l.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Oc(e,o,s,i,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(l.hash===h.hash)t.entries.push(tt(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(mt(n,l,2)),t.entries.push(tt(n,i.mode,h.hash,3));let p=await zs(e,l.hash,h.hash,l.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:l.mode})}else{t.entries.push(tt(n,s.mode,h.hash,2)),t.entries.push(mt(n,l,3));let p=await zs(e,h.hash,l.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Oc(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(rn(t.mode)||rn(n.mode)||rn(r.mode))return{hash:n.hash,conflict:!0};let a=await se(e,t.hash),c=await se(e,n.hash),f=await se(e,r.hash);if(Ie(c)||Ie(f)||Ie(a))return{hash:n.hash,conflict:!0};let d=Et(a),l=Et(c),u=Et(f),m=Nr(l,d,u);if(!m.conflict)return{hash:await ii(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,k=Yn(c,a,f,{a:g,b:w,markerSize:i??7});return{hash:await Re(e,"blob",Hn.encode(k)),conflict:!0}}async function zs(e,t,n,r,o){let s=await se(e,t),i=await se(e,n),a=Yn(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Re(e,"blob",Hn.encode(a))}function mt(e,t,n=0){return tt(e,t.mode,t.hash,n)}function tt(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Pe()}}async function zu(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(Ae(m,h.merged.result.hash,h.merged.result.mode));continue}await Vu(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),d=[],l=new Set;for(let m of o)m.stage===0&&(d.push(m),l.add(m.path));for(let[m,h]of a)l.has(m)||d.push(Ae(m,h.hash,h.mode));d.sort((m,h)=>Ce(m.path,h.path));let u=await Se(e,d);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function Vu(e,t,n,r,o,s,i){let a=t.path,[c,f,d]=t.stages,l=c?.hash??null,u=f?.hash??null,m=d?.hash??null;if(u===null&&m!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(Ae(a,l,c.mode,1)),r.push(Ae(a,m,d.mode,3)),i.set(a,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&l!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(Ae(a,l,c.mode,1)),r.push(Ae(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(l===null&&u!==null&&m!==null){if(u===m){r.push(Ae(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await se(e,u),p=await se(e,m);if(Ie(h)||Ie(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Ae(a,u,f.mode,2)),r.push(Ae(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=Et(""),w=Et(h),k=Et(p),b=Nr(w,g,k,n);if(!b.conflict){let P=await ii(e,b.result);r.push(Ae(a,P,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Ae(a,u,f.mode,2)),r.push(Ae(a,m,d.mode,3));let E=Yn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),x=await Re(e,"blob",Hn.encode(E));i.set(a,{hash:x,mode:f.mode});return}if(l!==null&&u!==null&&m!==null){if(u===l){r.push(Ae(a,m,d.mode));return}if(m===l){r.push(Ae(a,u,f.mode));return}if(u===m){r.push(Ae(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),rn(c.mode)||rn(f.mode)||rn(d.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ae(a,l,c.mode,1)),r.push(Ae(a,u,f.mode,2)),r.push(Ae(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await se(e,l),p=await se(e,u),g=await se(e,m);if(Ie(p)||Ie(g)||Ie(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ae(a,l,c.mode,1)),r.push(Ae(a,u,f.mode,2)),r.push(Ae(a,m,d.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=Et(h),k=Et(p),b=Et(g),E=Nr(k,w,b,n);if(E.conflict){let x=t.pathnames[1],P=t.pathnames[2],C=x!==a||P!==a,R={path:a,reason:"content"};C&&(x!==a&&(R.oursOrigPath=x),P!==a&&(R.theirsOrigPath=P)),o.push(R),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ae(a,l,c.mode,1)),r.push(Ae(a,u,f.mode,2)),r.push(Ae(a,m,d.mode,3));let y=C?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",$=C?`${n?.b??"theirs"}:${P}`:n?.b??"theirs",A=Yn(p,h,g,{a:y,b:$}),L=await Re(e,"blob",Hn.encode(A));i.set(a,{hash:L,mode:f.mode})}else{let x=await ii(e,E.result);r.push(Ae(a,x,f.mode))}return}}var Yu=200;async function Tc(e,t,n,r,o){let s=await Promise.all(r.map(async d=>({hash:d,timestamp:(await M(e,d)).committer.timestamp})));s.sort((d,l)=>d.timestamp-l.timestamp);let i=s.map(d=>d.hash),a=i[0],c=a,f=(await M(e,a)).tree;for(let d=1;d<i.length;d++){let l=i[d],u=(await M(e,l)).tree,m=null;if(o>=Yu)m=f;else{let g=await Dt(e,c,l);g.length===0?m=null:g.length===1?m=(await M(e,g[0])).tree:m=await Tc(e,c,l,g,o+1)}let h=await Mt(e,m,f,u);f=await Xu(e,h,o);let p=qt({type:"commit",tree:f,parents:[c,l],author:Ec,committer:Ec,message:"merged common ancestors"});c=await Re(e,"commit",p)}return f}async function Xu(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let d=s(a.path,1);if(d){r.push({...d,stage:0});continue}}if(a.reason==="rename-rename"){let d=a.oursPath??a.path,l=a.theirsPath??a.path,u=s(a.path,1),m=s(d,2),h=s(l,3);if(m&&h){let p=dr.decode((await ge(e,m.hash)).content),g=dr.decode((await ge(e,h.hash)).content),w=u?dr.decode((await ge(e,u.hash)).content):"",k=8+n*2,b=i.a??"Temporary merge branch 1",E=i.b??"Temporary merge branch 2",x=Yn(p,w,g,{a:`${b}:${d}`,o:i.o,b:`${E}:${l}`,markerSize:k}),P=await Re(e,"blob",Hn.encode(x));r.push({path:d,mode:m.mode,hash:P,stage:0,stat:Pe()}),r.push({path:l,mode:h.mode,hash:P,stage:0,stat:Pe()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let d=dr.decode((await ge(e,c.hash)).content),l=dr.decode((await ge(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?dr.decode((await ge(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,k=h?`${g}:${a.theirsOrigPath??a.path}`:g,b=Yn(d,m,l,{a:w,o:i.o,b:k,markerSize:i.markerSize}),E=await Re(e,"blob",Hn.encode(b));r.push({path:a.path,mode:c.mode,hash:E,stage:0,stat:Pe()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ce(a.path,c.path)),Se(e,r)}async function ii(e,t){let n=t.map(ri);if(n.length===0)return Re(e,"blob",Hn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
|
|
236
236
|
`):`${n.join(`
|
|
237
237
|
`)}
|
|
238
|
-
`;return Re(e,"blob",Hn.encode(s))}function
|
|
238
|
+
`;return Re(e,"blob",Hn.encode(s))}function Ae(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Pe()}}function si(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 Fr(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
|
|
239
239
|
${e.join(" ")}
|
|
240
240
|
Merge with strategy ort failed.
|
|
241
241
|
`;let c=e.map(d=>` ${d}`).join(`
|
|
@@ -250,7 +250,7 @@ ${i}
|
|
|
250
250
|
${a}
|
|
251
251
|
Aborting
|
|
252
252
|
fatal: ${n} failed
|
|
253
|
-
`}function
|
|
253
|
+
`}function Ic(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
|
|
254
254
|
`);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
|
|
255
255
|
${i}
|
|
256
256
|
Please commit your changes or stash them before you ${n}.
|
|
@@ -260,37 +260,37 @@ ${i}
|
|
|
260
260
|
Please move or remove them before you ${n}.
|
|
261
261
|
`)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
|
|
262
262
|
${s}
|
|
263
|
-
`}async function dn(e,t,n,r){let o=await q(e),s=await fe(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(ve(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let k=s.get(g);(!k||k.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
|
|
263
|
+
`}async function dn(e,t,n,r){let o=await q(e),s=await fe(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(ve(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let k=s.get(g);(!k||k.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 oi(e,o,s);let w=r.operationName??"merge",k=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Fr(g,w,k,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Fn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:ks,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await oi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(E=>E.error==="WOULD_OVERWRITE"||E.error==="NOT_UPTODATE_FILE").map(E=>E.path).sort(),k=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),b;return w.length>0&&k.length>0?b=Ic(w,k,p,g):k.length>0?b=Fr(k,p,g,"untracked","worktree"):b=Fr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Fn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:xs,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await oi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(x=>x.error==="WOULD_OVERWRITE"||x.error==="NOT_UPTODATE_FILE").map(x=>x.path).sort(),k=h.errors.filter(x=>x.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||x.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(x=>x.path).sort(),b=[];w.length>0&&b.push(Fr(w,p,g,"local","worktree")),k.length>0&&b.push(Fr(k,p,g,"untracked","worktree"));let E;return b.length>1?E=Ic(w,k,p,g):E=b[0]??"",{ok:!1,stdout:"",stderr:E,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Te(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...a,...f];d.sort((h,p)=>Ce(h.path,p.path)||h.stage-p.stage);let l={version:2,entries:d};await re(e,l);let u=d.filter(h=>h.stage===0),m=await Se(e,u);return{ok:!0,finalIndex:l,mergedTreeHash:m}}async function oi(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 rt(e,{path:r.path,hash:r.hash,mode:r.mode})}}oe();Ge();me();Oe();Vt();function Hc(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[B.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:Q.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let v=await t.hooks.emitPre("pre-cherry-pick",{mode:"abort",commit:null});if(v)return{stdout:"",stderr:v.message??"",exitCode:1}}let I=await Ju(s,r.env);return I.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"abort",commitHash:null,hadConflicts:!1}),I}if(n.continue){if(t?.hooks){let v=await t.hooks.emitPre("pre-cherry-pick",{mode:"continue",commit:null});if(v)return{stdout:"",stderr:v.message??"",exitCode:1}}let I=await Qu(s,r.env);return I.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"continue",commitHash:null,hadConflicts:!1}),I}if(n.skip)return Zu(s,r.env);let i=n.commit;if(!i)return O("you must specify a commit to cherry-pick");if(t?.hooks){let I=await t.hooks.emitPre("pre-cherry-pick",{mode:"pick",commit:i});if(I)return{stdout:"",stderr:I.message??"",exitCode:1}}let a=await He(s,i);if(S(a))return a;let c=a.hash,f=a.commit,d=await Ke(s);if(S(d))return d;let l=await q(s);if(n.noCommit){let I=l.entries.filter(v=>v.stage>0);if(I.length>0){let F=I.slice(0,10).map(K=>`${K.path}: unmerged (${K.hash})`).join(`
|
|
264
264
|
`),D=I.length>10?`
|
|
265
|
-
...`:"";return
|
|
265
|
+
...`:"";return _(`${F}${D}
|
|
266
266
|
error: your index file is unmerged.
|
|
267
267
|
fatal: cherry-pick failed
|
|
268
|
-
`,128)}}else{let I=
|
|
269
|
-
`);if(I)return I}let
|
|
268
|
+
`,128)}}else{let I=on(l,"Cherry-picking",`fatal: cherry-pick failed
|
|
269
|
+
`);if(I)return I}let u=await M(s,d),h=!!n["record-origin"]?em(f.message,c):f.message;if(s.workTree&&!n.noCommit){let I=await fe(s,u.tree);if(sr(l,I))return _(`error: your local changes would be overwritten by cherry-pick.
|
|
270
270
|
hint: commit your changes or stash them to proceed.
|
|
271
271
|
fatal: cherry-pick failed
|
|
272
|
-
`,128)}if(f.parents.length>1){if(!n.mainline)return
|
|
272
|
+
`,128)}if(f.parents.length>1){if(!n.mainline)return _(`error: commit ${c} is a merge but no -m option was given.
|
|
273
273
|
fatal: cherry-pick failed
|
|
274
|
-
`,128);let I=n.mainline-1;if(I<0||I>=f.parents.length)return
|
|
274
|
+
`,128);let I=n.mainline-1;if(I<0||I>=f.parents.length)return _(`error: commit ${c} does not have parent ${n.mainline}
|
|
275
275
|
fatal: cherry-pick failed
|
|
276
|
-
`,128)}else if(n.mainline)return
|
|
276
|
+
`,128)}else if(n.mainline)return _(`error: mainline was specified but commit is not a merge.
|
|
277
277
|
fatal: cherry-pick failed
|
|
278
|
-
`,128);let p;if(f.parents.length===0)p=await
|
|
278
|
+
`,128);let p;if(f.parents.length===0)p=await Se(s,[]);else{let I=f.parents.length>1?n.mainline-1:0,v=f.parents[I];if(!v)throw new Error("unreachable: parent must exist");p=(await M(s,v)).tree}let g=z(c),w=ie(f.message),k={a:"HEAD",b:w?`${g} (${w})`:g},b=await Mt(s,p,u.tree,f.tree,k);if(b.conflicts.length===0&&b.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await Y(s,"CHERRY_PICK_HEAD",c),await Y(s,"ORIG_HEAD",d),await $e(s,"MERGE_MSG",h);let I=b.messages.length>0?`${b.messages.join(`
|
|
279
279
|
`)}
|
|
280
|
-
`:"",
|
|
280
|
+
`:"",v=await et(s,{fromCommit:!0});return{stdout:`${I}${v}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
281
281
|
If you wish to commit it anyway, use:
|
|
282
282
|
|
|
283
283
|
git commit --allow-empty
|
|
284
284
|
|
|
285
285
|
Otherwise, please use 'git cherry-pick --skip'
|
|
286
|
-
`,exitCode:1}}let E=await dn(s,b,
|
|
286
|
+
`,exitCode:1}}let E=await dn(s,b,u.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(b.conflicts.length>0){let I=b.messages.join(`
|
|
287
287
|
`);return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:I?`${I}
|
|
288
|
-
`:"",stderr:`error: could not apply ${g}... ${
|
|
288
|
+
`:"",stderr:`error: could not apply ${g}... ${ie(f.message)}
|
|
289
289
|
hint: after resolving the conflicts, mark the corrected paths
|
|
290
290
|
hint: with 'git add <paths>' or 'git rm <paths>'
|
|
291
291
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
292
|
-
`,exitCode:1}:(await
|
|
293
|
-
`:"",stderr:`error: could not apply ${g}... ${
|
|
292
|
+
`,exitCode:1}:(await Y(s,"CHERRY_PICK_HEAD",c),await Y(s,"ORIG_HEAD",d),await $e(s,"MERGE_MSG",h),{stdout:I?`${I}
|
|
293
|
+
`:"",stderr:`error: could not apply ${g}... ${ie(f.message)}
|
|
294
294
|
hint: After resolving the conflicts, mark them with
|
|
295
295
|
hint: "git add/rm <pathspec>", then run
|
|
296
296
|
hint: "git cherry-pick --continue".
|
|
@@ -298,51 +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 x=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let
|
|
302
|
-
`)[0]??"",$=R?.type==="symbolic"?R.target:"HEAD";await
|
|
301
|
+
`,exitCode:1})}let x=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let P=await Ve(s,r.env);if(S(P))return P;let C=await ft(s,x,[d],f.author,P,h);await _t(s),await Ht(s);let R=await Z(s),y=h.split(`
|
|
302
|
+
`)[0]??"",$=R?.type==="symbolic"?R.target:"HEAD";await te(s,r.env,$,d,C,`cherry-pick: ${y}`,R?.type==="symbolic");let A=R?.type==="symbolic"?be(R.target):"detached HEAD",L=u.tree,G=await Zt(s,L,x,f.author,P,!0),V=It(A,C,h),j=b.messages.length>0?`${b.messages.join(`
|
|
303
303
|
`)}
|
|
304
|
-
`:"";return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:
|
|
305
|
-
${
|
|
304
|
+
`:"";return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${j}${V}
|
|
305
|
+
${G}`,stderr:"",exitCode:0}}})}async function Zu(e,t){if(!await N(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
|
|
306
306
|
fatal: cherry-pick failed
|
|
307
307
|
`,128);let r=await X(e);if(!r)return O("unable to resolve HEAD");let o=await M(e,r),s=await q(e),i=await Ps(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
|
|
308
308
|
fatal: cherry-pick failed
|
|
309
|
-
`}}return await
|
|
309
|
+
`}}return await re(e,{version:2,entries:i.newEntries}),await Te(e,i.worktreeOps),await te(e,t,"HEAD",r,r,`reset: moving to ${r}`),await _t(e),{stdout:"",stderr:"",exitCode:0}}async function Ju(e,t){return await N(e,"CHERRY_PICK_HEAD")?xn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
|
|
310
310
|
fatal: cherry-pick failed
|
|
311
|
-
`,128),operationName:"cherry-pick",clearState:
|
|
311
|
+
`,128),operationName:"cherry-pick",clearState:_t,origHeadAsTargetRev:!0}):await N(e,"REVERT_HEAD")?xn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
|
|
312
312
|
fatal: cherry-pick failed
|
|
313
|
-
`,128),operationName:"cherry-pick",clearState:
|
|
313
|
+
`,128),operationName:"cherry-pick",clearState:Ht,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
|
|
314
314
|
fatal: cherry-pick failed
|
|
315
|
-
`,128)}async function
|
|
315
|
+
`,128)}async function Qu(e,t){let n=await N(e,"CHERRY_PICK_HEAD");if(!n)return _(`error: no cherry-pick or revert in progress
|
|
316
316
|
fatal: cherry-pick failed
|
|
317
|
-
`,128);let r=await q(e),o=
|
|
318
|
-
|
|
317
|
+
`,128);let r=await q(e),o=on(r,"Committing");if(o)return o;let s=await M(e,n),i=await Ee(e,"MERGE_MSG");if(!i)return _(`Aborting commit due to empty commit message.
|
|
318
|
+
`,1);let a=await Ee(e,"SQUASH_MSG");a&&(i=a+i),i=Xt(i);let c=ve(r),f=await Se(e,c),d=await Ke(e);if(S(d))return d;let u=(await M(e,d)).tree,m=await Ve(e,t);if(S(m))return m;let h=Ot(i),p=await ft(e,f,[d],s.author,m,h);await _t(e),await Ht(e),await he(e,"SQUASH_MSG");let g=await Z(e),w=ie(h),k=g?.type==="symbolic"?g.target:"HEAD";await te(e,t,k,d,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let b=g?.type==="symbolic"?be(g.target):"detached HEAD",E=await Zt(e,u,f,s.author,m,!0);return{stdout:`${It(b,p,i)}
|
|
319
|
+
${E}`,stderr:"",exitCode:0}}function em(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
|
|
319
320
|
`),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
|
|
320
321
|
${n}
|
|
321
322
|
`:`${r}
|
|
322
323
|
|
|
323
324
|
${n}
|
|
324
|
-
`}
|
|
325
|
-
`)}
|
|
326
|
-
`:"";return await t?.hooks?.emitPost("post-clean",{removed:E.map(
|
|
327
|
-
`),d=
|
|
328
|
-
`)?t.slice(0,-1):t}var
|
|
329
|
-
`));for(let
|
|
330
|
-
`));a.push(
|
|
331
|
-
`));a.push(
|
|
332
|
-
`));let c=Zs(...a),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...
|
|
333
|
-
`));for(let h of f)a.push(
|
|
334
|
-
`));a.push(
|
|
325
|
+
`}ne();Xe();Es();xe();ue();function Ac(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[B.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:Q.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=qe(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,d=n.directories,l=n.removeIgnored,u=n.onlyIgnored;if(t?.hooks){let C=await t.hooks.emitPre("pre-clean",{dryRun:c,force:f,removeDirs:d,removeIgnored:l,onlyIgnored:u});if(C)return{stdout:"",stderr:C.message??"",exitCode:1}}if(!f&&!c&&await jt(s,"clean.requireForce")!=="false")return O("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let m=await q(s),h=new Set(m.entries.map(C=>C.path)),p=ct(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(C=>Le(C,p)):null,k=n.exclude?[n.exclude]:[],b=await vc(s,a,"",{trackedPaths:h,removeDirs:d,removeIgnored:l,onlyIgnored:u,extraExcludes:k}),E;w?E=b.filter(C=>ye(w,C.path)):E=b,E.sort((C,R)=>C.path<R.path?-1:C.path>R.path?1:0);let x=[];if(c)for(let C of E){let R=C.isDir?`Would remove ${C.path}/`:`Would remove ${C.path}`;x.push(R)}else for(let C of E){let R=T(a,C.path);C.isDir?(await r.fs.rm(R,{recursive:!0}),x.push(`Removing ${C.path}/`)):(await r.fs.rm(R),x.push(`Removing ${C.path}`))}let P=x.length>0?`${x.join(`
|
|
326
|
+
`)}
|
|
327
|
+
`:"";return await t?.hooks?.emitPost("post-clean",{removed:E.map(C=>C.path),dryRun:c}),{stdout:P,stderr:"",exitCode:0}}})}async function vc(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await rr(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);i=_n(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
|
|
328
|
+
`),d=Hr(f,"","<cli>");i={...i,dirPatterns:[d,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),d=n?`${n}/${c}`:c,l=await e.fs.stat(f);if(l.isDirectory){let u=i&&Kt(i,d,!0)==="ignored",m=tm(r.trackedPaths,d),h=()=>vc(e,f,d,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:d,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:d,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:d,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:d,isDir:!0})}}}else if(l.isFile){if(r.trackedPaths.has(d))continue;let u=i&&Kt(i,d,!1)==="ignored";r.onlyIgnored?u&&o.push({path:d,isDir:!1}):u&&s||o.push({path:d,isDir:!1})}}return o}function tm(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}ne();Xe();ln();xe();oe();ue();Ge();me();wn();Xe();wn();at();oe();Er();me();oe();en();Pr();gs();async function Vs(e,t,n){return Sc(e,t,n,!1)}async function Ys(e,t,n){return Sc(e,t,n,!0)}async function Sc(e,t,n,r){let o=new Set;for(let a of n)await Br(e,a,o);let s=[],i=new Set;for(let a of t)await Wr(e,a,o,i,s,r);return s}async function Br(e,t,n){if(n.has(t)||(n.add(t),!await hn(e,t)))return;let r=await ge(e,t);switch(r.type){case"commit":{let o=Wt(r.content);await Br(e,o.tree,n);for(let s of o.parents)await Br(e,s,n);break}case"tree":{let o=En(r.content);for(let s of o.entries)await Br(e,s.hash,n);break}case"tag":{let o=tn(r.content);await Br(e,o.object,n);break}case"blob":break}}async function Wr(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await ge(e,t);switch(o.push(s?{hash:t,type:i.type,content:i.content}:{hash:t,type:i.type}),i.type){case"commit":{let a=Wt(i.content);await Wr(e,a.tree,n,r,o,s);for(let c of a.parents)await Wr(e,c,n,r,o,s);break}case"tree":{let a=En(i.content);for(let c of a.entries)await Wr(e,c.hash,n,r,o,s);break}case"tag":{let a=tn(i.content);await Wr(e,a.object,n,r,o,s);break}case"blob":break}}var nm=new TextEncoder,Xs=new TextDecoder,Dc=65520,rm=new Uint8Array([48,48,48,48]);function Xn(e){let t=typeof e=="string"?nm.encode(e):e,n=4+t.byteLength;if(n>Dc)throw new Error(`pkt-line too long: ${n} bytes (max ${Dc})`);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 ai(){return rm.slice()}function Zs(...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 lr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=Xs.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 Js(e){if(e.type==="flush")return"";let t=Xs.decode(e.data);return t.endsWith(`
|
|
329
|
+
`)?t.slice(0,-1):t}var sm=1,om=2,im=3;function ci(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case sm:t.push(f),o+=f.byteLength;break;case om:n.push(Xs.decode(f));break;case im:r.push(Xs.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}at();function fi(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function di(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...fi(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let d=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(d))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=lr(c);return am(f,t)}function am(e,t){let n=0,r=e[n];r?.type==="data"&&Js(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),d;if(f!==-1){d=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else d=new TextDecoder().decode(c).replace(/\n$/,"");let l=d.indexOf(" ");if(l===-1)continue;let u=d.slice(0,l),m=d.slice(l+1);if(!(u===J&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=u);continue}o.push({name:m,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var cm=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag"];async function Mc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let i=Gc(r,cm),a=[];a.push(Xn(`want ${t[0]} ${i.join(" ")}
|
|
330
|
+
`));for(let u=1;u<t.length;u++)a.push(Xn(`want ${t[u]}
|
|
331
|
+
`));a.push(ai());for(let u of n)a.push(Xn(`have ${u}
|
|
332
|
+
`));a.push(Xn(`done
|
|
333
|
+
`));let c=Zs(...a),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...fi(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 fm(l,i.includes("side-band-64k"))}function fm(e,t){let n=lr(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=Js(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}=ci(s);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);return{packData:f,acks:r,progress:d}}let i=0;for(let f of s)f.type==="data"&&(i+=f.data.byteLength);let a=new Uint8Array(i),c=0;for(let f of s)f.type==="data"&&(a.set(f.data,c),c+=f.data.byteLength);return{packData:a,acks:r,progress:[]}}var dm=["report-status","side-band-64k","ofs-delta","delete-refs"];async function jc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=Gc(r,dm),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Xn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
|
|
334
|
+
`));for(let h of f)a.push(Xn(`${h.oldHash} ${h.newHash} ${h.refName}
|
|
335
|
+
`));a.push(ai());let d;if(n&&n.byteLength>0){let h=Zs(...a);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=Zs(...a);let l=e.replace(/\/+$/,""),u=await s(`${l}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...fi(o),"User-Agent":"just-git/1.0"},body:d});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${l}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?lm(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function lm(e,t){let n,r=[];if(t){let a=lr(e),{packData:c,progress:f,errors:d}=ci(a);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=lr(c)}else n=lr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=Js(a);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))i.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?i.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function Gc(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 li=class{queue=Promise.resolve();async acquire(){let t,n=new Promise(o=>{t=o}),r=this.queue;return this.queue=n,await r,t}},Lc=new WeakMap;function um(e){let t=Lc.get(e);return t||(t=new li,Lc.set(e,t)),t}var qr=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await we(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await N(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 Vs(this.remote,t,n);if(o.length===0)return{remoteRefs:r,objectCount:0};let s=[];for(let c of o){let f=await ge(this.remote,c.hash);s.push({type:f.type,content:f.content})}let i=await fs(s),a=await ms(this.local,i);return{remoteRefs:r,objectCount:a}}async push(t){let n=await um(this.remote.fs).acquire();try{return await this.pushInner(t)}finally{n()}}async pushInner(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 Vs(this.local,n,r);if(s.length>0){let i=[];for(let c of s){let f=await ge(this.local,c.hash);i.push({type:f.type,content:f.content})}let a=await fs(i);await ms(this.remote,a)}}let o=[];for(let s of t)try{if(s.newHash===J){await de(this.remote,s.name),o.push({...s,ok:!0});continue}let i=await N(this.remote,s.name);if(i&&!s.ok&&!await fn(this.remote,i,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}await Y(this.remote,s.name,s.newHash),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},Kr=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 di(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 di(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 Mc(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let i=await ms(this.local,s.packData);return{remoteRefs:o,objectCount:i}}async push(t){for(let d of t)if(d.oldHash&&d.oldHash!==J&&d.newHash!==J&&!d.ok&&!await fn(this.local,d.oldHash,d.newHash))return{updates:t.map(u=>u===d?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(d=>({oldHash:d.oldHash??J,newHash:d.newHash,refName:d.name})),o=[],s=[],i=!1;for(let d of t)d.newHash!==J&&(o.push(d.newHash),i=!0),d.oldHash&&d.oldHash!==J&&s.push(d.oldHash);let a=null;if(i){let d=await Vs(this.local,o,s),l=[];for(let u of d){let m=await ge(this.local,u.hash);l.push({type:m.type,content:m.content})}a=await fs(l)}let c=await jc(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(d=>{let l=c.refResults.find(h=>h.name===d.name),u=l?.ok??c.unpackOk,m=l?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...d,ok:u,error:m}})}}};async function mm(e,t){let r=(await pe(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function ui(e){return e.startsWith("http://")||e.startsWith("https://")}function _c(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(ui(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 Nc(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return hm(n)}async function Fc(e,t,n,r){if(ui(t)){let o=_c(t,e.networkPolicy);if(o)throw new Error(o);let s=await Nc(e,t,n);return new Kr(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 ur(e,t,n){let r=await mm(e,t);if(!r)return null;if(ui(r.url)){let s=_c(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await Nc(e,r.url,n):void 0;return{transport:new Kr(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await jn(e.fs,r.url);return o?{transport:new qr(e,o),config:r}:null}Oe();Je();function Uc(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[B.string().name("repository").describe("Repository to clone"),B.string().name("directory").describe("Target directory").optional()],options:{bare:H().describe("Create a bare clone"),branch:Q.string().alias("b").describe("Checkout this branch instead of HEAD")},handler:async(n,r)=>{let o=n.repository;if(!o)return O("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=s?o:xt(r.cwd,o),a=n.branch,c=n.directory;if(!c){let y=s?o.split("/").pop()??o:wr(i);y.endsWith(".git")&&(y=y.slice(0,-4)),c=y}let f=xt(r.cwd,c);if(t?.hooks){let y=await t.hooks.emitPre("pre-clone",{repository:o,targetPath:f,bare:n.bare,branch:a??null});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return O(`destination path '${c}' already exists and is not an empty directory.`)}catch{return O(`destination path '${c}' already exists and is not an empty directory.`)}let d=null;if(!s&&(t?.resolveRemote&&(d=await t.resolveRemote(i)),d||(d=await jn(r.fs,i)),!d))return O(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:l}=await hs(r.fs,f,{bare:n.bare}),u=t?{...l,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:l,m=await pe(u);m['remote "origin"']={url:i,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Ye(u,m);let h;try{h=await Fc(u,i,r.env,d??void 0)}catch(y){let $=y instanceof Error?y.message:"";return $.startsWith("network")?O($):O(`repository '${o}' does not exist`)}let p=await h.advertiseRefs();if(p.length===0)return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:a??null}),{stdout:"",stderr:`Cloning into '${c}'...
|
|
335
336
|
warning: You appear to have cloned an empty repository.
|
|
336
|
-
`,exitCode:0};let g=[],w=new Set;for(let y of p)y.name!=="HEAD"&&(w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));g.length>0&&await h.fetch(g,[]);let k=p.find(y=>y.name==="HEAD"),b=null,E=null,x=await
|
|
337
|
-
`,exitCode:0};if(b&&await Fe(
|
|
338
|
-
`,exitCode:0};return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),R}})}
|
|
337
|
+
`,exitCode:0};let g=[],w=new Set;for(let y of p)y.name!=="HEAD"&&(w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));g.length>0&&await h.fetch(g,[]);let k=p.find(y=>y.name==="HEAD"),b=null,E=null,x=await Bt(u,r.env),P=`clone: from ${i}`,C=h.headTarget;C?.startsWith("refs/heads/")&&p.some(y=>y.name===C)&&(b=C.slice(11),E=p.find(y=>y.name===C)?.hash??null);for(let y of p)if(y.name!=="HEAD"){if(y.name.startsWith("refs/heads/")){let $=y.name.slice(11),A=`refs/remotes/origin/${$}`;await Y(u,A,y.hash),await Ue(u,A,{oldHash:J,newHash:y.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:P}),!b&&k&&y.hash===k.hash&&(b=$,E=y.hash)}y.name.startsWith("refs/tags/")&&await Y(u,y.name,y.hash)}if(a){let y=p.find($=>$.name===`refs/heads/${a}`);if(!y)return O(`Remote branch '${a}' not found in upstream origin`);b=a,E=y.hash}if(!b){let y=p.find($=>$.name.startsWith("refs/heads/"));y&&(b=y.name.slice(11),E=y.hash)}if(n.bare)return b&&await Fe(u,"HEAD",`refs/heads/${b}`),await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
|
|
338
|
+
`,exitCode:0};if(b&&await Fe(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&E){await Y(u,`refs/heads/${b}`,E),await Fe(u,"HEAD",`refs/heads/${b}`);let y={oldHash:J,newHash:E,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:P};await Ue(u,`refs/heads/${b}`,y),await Ue(u,"HEAD",y);let $=await pe(u);$[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Ye(u,$);let A=await M(u,E);await Aa(u,A.tree);let L=await We(u,A.tree),G=os(L.map(V=>({path:V.path,mode:parseInt(V.mode,8),hash:V.hash,stage:0,stat:Pe()})));await re(u,G)}let R={stdout:"",stderr:`Cloning into '${c}'...
|
|
339
|
+
`,exitCode:0};return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),R}})}ne();xe();oe();en();ue();Ge();me();Oe();Je();function Bc(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Q.string().alias("m").describe("Commit message"),file:Q.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 O("options '-m' and '-F' cannot be used together");let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=await q(s);if(n.all){let ee=qe(s);if(ee)return ee;let le=await Rt(s,i);for(let De of le)De.status==="modified"?i=(await zt(s,i,De.path)).index:De.status==="deleted"&&(i=nt(i,De.path));let je=new Set(ve(i).map(De=>De.path)),Jt=new Set(i.entries.filter(De=>De.stage>0&&!je.has(De.path)).map(De=>De.path));for(let De of Jt){let Xr=T(s.workTree,De);await r.fs.exists(Xr)?i=(await zt(s,i,De)).index:i=nt(i,De)}}let a=await N(s,"MERGE_HEAD"),c=await N(s,"CHERRY_PICK_HEAD"),f=await N(s,"REVERT_HEAD"),l=await At(s)?await N(s,"REBASE_HEAD"):null,u=n.amend,m=await X(s);if(u){if(!m)return O("You have nothing yet to amend.");if(a)return O("You are in the middle of a merge -- cannot amend.");if(c)return O("You are in the middle of a cherry-pick -- cannot amend.")}if(Pt(i)){let ee=new Set,le=[];for(let je of i.entries)je.stage>0&&!ee.has(je.path)&&(ee.add(je.path),le.push(`U ${je.path}`));return le.sort(),{stdout:le.length>0?`${le.join(`
|
|
339
340
|
`)}
|
|
340
341
|
`:"",stderr:`error: Committing is not possible because you have unmerged files.
|
|
341
342
|
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
|
|
342
343
|
hint: as appropriate to mark resolution and make a commit.
|
|
343
344
|
fatal: Exiting because of an unresolved conflict.
|
|
344
|
-
`,exitCode:128}}let h=
|
|
345
|
-
`,stderr:"",exitCode:1}}if(!p&&
|
|
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 ee=n.file.startsWith("/")?n.file:T(r.cwd,n.file);if(!await r.fs.exists(ee))return O(`could not read log file '${n.file}': No such file or directory`);let le=await r.fs.readFile(ee);p=typeof le=="string"?le:new TextDecoder().decode(le)}if(p=Xt(p),!p)return{stdout:`Aborting commit due to empty commit message.
|
|
346
|
+
`,stderr:"",exitCode:1}}if(!p&&u&&h&&(p=h.message),!p&&(a||c||f||l)){let ee=await Ee(s,"SQUASH_MSG");if(ee)p=Xt(ee);else{let le=await Ee(s,"MERGE_MSG");le!==null&&(p=Xt(le))}}if(!p)return _("error: must provide a commit message with -m or -F");let g=ve(i),w=await Se(s,g);if(t?.hooks){let ee=await t.hooks.emitPre("pre-commit",{index:i,treeHash:w});if(ee)return _(ee.message??"")}let k=n.allowEmpty,b=null;if(u&&h){let ee=h.parents[0];ee?b=(await M(s,ee)).tree:b=await pt("tree",new Uint8Array(0))}else m&&(b=(await M(s,m)).tree);let E=u&&h&&h.parents.length>1;if(!k&&!a&&!E){if(!m&&!u&&g.length===0)return{stdout:await et(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1};if(b!==null&&b===w){if(u){let ee=h?.parents[0]??null;return{stdout:`${await et(s,{fromCommit:!0,compareHash:ee,noWarn:!0,index:i})}No changes
|
|
346
347
|
`,stderr:`You asked to amend the most recent commit, but doing so would make
|
|
347
348
|
it empty. You can repeat your command with --allow-empty, or you can
|
|
348
349
|
remove the commit entirely with "git reset HEAD^".
|
|
@@ -352,70 +353,70 @@ If you wish to commit it anyway, use:
|
|
|
352
353
|
git commit --allow-empty
|
|
353
354
|
|
|
354
355
|
Otherwise, please use 'git cherry-pick --skip'
|
|
355
|
-
`,exitCode:1}:{stdout:await et(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let x=await
|
|
356
|
-
${K}`,stderr:"",exitCode:0}}})}
|
|
357
|
-
`,stderr:"",exitCode:0}}async function
|
|
356
|
+
`,exitCode:1}:{stdout:await et(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let x=await Yt(s,r.env);if(S(x))return x;let P=await Ve(s,r.env);if(S(P))return P;u&&h&&(x.name=h.author.name,x.email=h.author.email,x.timestamp=h.author.timestamp,x.timezone=h.author.timezone),c&&(x=(await M(s,c)).author);let C=Ot(p);if(t?.hooks){let ee={message:C},le=await t.hooks.emitPre("commit-msg",ee);if(le)return _(le.message??"");C=ee.message}let R;u&&h?R=[...h.parents]:(R=m?[m]:[],a&&R.push(a));let y=qt({type:"commit",tree:w,parents:R,author:x,committer:P,message:C}),$=await Re(s,"commit",y);await re(s,i);let A=await Z(s);A&&A.type==="symbolic"?await Y(s,A.target,$):await Y(s,"HEAD",$);let L=ie(C),G;u?G="commit (amend)":a?G="commit (merge)":c?G="commit (cherry-pick)":m?G="commit":G="commit (initial)";let V=`${G}: ${L}`,j=A?.type==="symbolic"?A.target:"HEAD";await te(s,r.env,j,m,$,V,A?.type==="symbolic"),a&&await vr(s),c&&await _t(s),f&&await Ht(s),l&&await he(s,"MERGE_MSG"),await he(s,"SQUASH_MSG"),await t?.hooks?.emitPost("post-commit",{hash:$,message:C,branch:A?.type==="symbolic"?be(A.target):null,parents:R,author:x});let I=A?.type==="symbolic"?A.target:null,v=I?be(I):"detached HEAD",W;if(u&&h){let ee=h.parents[0];W=ee?(await M(s,ee)).tree:null}else W=m?(await M(s,m)).tree:null;let F=x.timestamp!==P.timestamp||x.timezone!==P.timezone,D=R.length>1,K=await Zt(s,W,w,x,P,F,D);return{stdout:`${It(v,$,p,R.length===0&&!u)}
|
|
357
|
+
${K}`,stderr:"",exitCode:0}}})}ne();Xe();function zr(e){let t=e.split(".");return t.length===2||t.length===3}function pm(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,i]of Object.entries(r)){let a=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${a}=${i}`)}}return t}function zc(e,t){e.command("config",{description:"Get and set repository options",args:[B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Kc(await pe(s));if(n.unset){let f=a;return f?zr(f)?qc(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return Kc(await pe(s));if(a==="get"){let f=i[1];return f?zr(f)?Wc(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],d=i[2];return!f||d===void 0?_("error: missing key and/or value",2):zr(f)?(await bo(s,f,d),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?zr(f)?qc(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!zr(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await bo(s,a,c),{stdout:"",stderr:"",exitCode:0}):Wc(s,a)}})}async function Wc(e,t){let n=await jt(e,t);return n===void 0?_(""):{stdout:`${n}
|
|
358
|
+
`,stderr:"",exitCode:0}}async function qc(e,t){return await _i(e,t)?{stdout:"",stderr:"",exitCode:0}:_("",5)}function Kc(e){let t=pm(e);return{stdout:t.length>0?`${t.join(`
|
|
358
359
|
`)}
|
|
359
|
-
`:"",stderr:"",exitCode:0}}
|
|
360
|
+
`:"",stderr:"",exitCode:0}}ne();function Qs(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(k=>k?z(k):"0000000"),c=o?z(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(k=>k===null),l=!f&&n.some(k=>k!==null);if(d&&s)i.push(`new file mode ${s}`);else if(l){let k=r.map(b=>b||"000000").join(",");i.push(`deleted file mode ${k}`)}else{let k=r.map(x=>x||"000000"),b=s||"000000";k.some(x=>x!==b)&&i.push(`mode ${k.join(",")}..${b}`)}let u=n.some(k=>k!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),l||d)return`${i.join(`
|
|
360
361
|
`)}
|
|
361
|
-
`;let m=e.parentContents.map(k=>k.length>0?vt(k):[]),h=e.resultContent.length>0?vt(e.resultContent):[],p=m.map(k=>it(k,h)),g=
|
|
362
|
+
`;let m=e.parentContents.map(k=>k.length>0?vt(k):[]),h=e.resultContent.length>0?vt(e.resultContent):[],p=m.map(k=>it(k,h)),g=gm(m,h,p),w=bm(g,m.length,h);if(w.length===0)return"";for(let k of w)i.push(k);return`${i.join(`
|
|
362
363
|
`)}
|
|
363
|
-
`}function
|
|
364
|
-
`);let c=i[0],f=await M(e,c),d=await
|
|
364
|
+
`}function gm(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let d of i)if(d.type==="keep")a[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")a[d.newLineNo-1]="insert",f=d.newLineNo;else if(d.type==="delete"){let l=c.get(f)??[];l.push({text:d.line,parentLineNo:d.oldLineNo}),c.set(f,l)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let d=o[f];a.push(d?.deletions.get(i)??[])}let c=wm(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],d=Array(r).fill(0);for(let l=0;l<r;l++){let m=o[l]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[l];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){d[l]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:d})}}return s}function wm(e,t){if(!e.some(o=>o.length>0))return[];if(t===2){let o=e[0]??[],s=e[1]??[];if(o.length===0)return s.map(d=>({columns:[" ","-"],text:d.text,resultLineNo:0,parentLineNos:[0,d.parentLineNo]}));if(s.length===0)return o.map(d=>({columns:["-"," "],text:d.text,resultLineNo:0,parentLineNos:[d.parentLineNo,0]}));let i=o.map(d=>d.text),a=s.map(d=>d.text),c=it(i,a),f=[];for(let d of c)if(d.type==="keep"){let l=o.find(m=>m.text===d.line&&m.parentLineNo===d.oldLineNo),u=s.find(m=>m.text===d.line&&m.parentLineNo===d.newLineNo);f.push({columns:["-","-"],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,u?.parentLineNo??0]})}else if(d.type==="delete"){let l=o.find(u=>u.parentLineNo===d.oldLineNo);f.push({columns:["-"," "],text:d.line,resultLineNo:0,parentLineNos:[l?.parentLineNo??0,0]})}else if(d.type==="insert"){let l=s.find(u=>u.parentLineNo===d.newLineNo);f.push({columns:[" ","-"],text:d.line,resultLineNo:0,parentLineNos:[0,l?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function bm(e,t,n){let o=[];for(let d=0;d<e.length;d++)e[d]?.columns.some(u=>u!==" ")&&o.push(d);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let d=1;d<o.length;d++){let l=o[d]??0,u=Math.max(0,l-3),m=Math.min(e.length-1,l+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let d of s){let l=e.slice(d.start,d.end+1),u=[];for(let E=0;E<t;E++){let x=l.filter(P=>(P.parentLineNos[E]??0)>0||P.columns[E]==="-");if(x.length===0)u.push({start:1,count:0});else{let C=x.find(R=>(R.parentLineNos[E]??0)>0)?.parentLineNos[E]??1;u.push({start:C,count:x.length})}}let m=l.filter(E=>E.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let E=p-2;E>=0;E--){let x=n[E];if(x&&/^[a-zA-Z$_]/.test(x)){w=` ${x.trimEnd().slice(0,79)}`;break}}let k=u.map(E=>`-${E.start},${E.count}`),b=`${"@".repeat(t+1)} ${k.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(b);for(let E of l)f.push(`${E.columns.join("")}${E.text}`)}return f}ne();xe();oe();ue();function eo(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}Gn();me();Oe();Je();var mi=new TextDecoder;function Zc(e){return"exitCode"in e}function mr(e){return e.toString(8).padStart(6,"0")}function Jc(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 Qc(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[B.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=ct(i,r.cwd),d=o.passthrough.length>0?o.passthrough.map(p=>Le(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?eo(c[0]):null;if(m){if(a)return O("too many arguments");m.type==="three-dot"?u=await xm(i,m.left,m.right,d):u=await Xc(i,m.left,m.right,d)}else if(c.length===2)u=await Xc(i,c[0],c[1],d);else{if(c.length>2)return O("too many arguments");a?u=await km(i,c.length===1?c[0]:null,d):c.length===1?u=await Cm(i,c[0],d):u=await ym(i,d)}if(Zc(u))return u;let h=await Pm(i,u.items,l);return u.stderr&&(h.stderr=u.stderr),h}})}async function ym(e,t){let n=qe(e);if(n)return n;let r=await q(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?i.set(d.path,d):d.stage===3&&a.set(d.path,d));let c=await Rt(e,r);c.sort((d,l)=>Ce(d.path,l.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!ye(t,d.path)||o.has(d.path))continue;let l=s.get(d.path);if(!l)continue;let u=mr(l.mode),m;if(d.status==="modified"&&e.workTree){let h=T(e.workTree,d.path),p=await e.fs.readFileBuffer(h);m=await pt("blob",p)}f.push({path:d.path,status:d.status==="deleted"?"D":"M",oldHash:l.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:d.status==="modified"})}for(let d of o){if(t&&!ye(t,d))continue;let l=i.get(d),u=a.get(d);await Em(f,e,d,l,u)}return f.sort((d,l)=>{let u=Ce(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 Em(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=mr(r.mode),a=mr(o.mode),{exists:c,hash:f}=await Vc(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),Yc(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=mr(r.mode),{exists:a,hash:c}=await Vc(t.fs,s,n);Yc(e,n,r.hash,i,a,c)}}async function Vc(e,t,n){let r=T(t,n);if(!await e.exists(r))return{exists:!1};let o=await Ir(e,r);return{exists:!0,hash:await pt("blob",o)}}function Yc(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 km(e,t,n){let r=null;if(t){let u=await He(e,t);if(S(u))return u;r=u.commit.tree}else{let u=await X(e);u&&(r=(await M(e,u)).tree)}let o=await fe(e,r),s=await q(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(ve(s).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(i.has(u))continue;let h=o.get(u);h?h.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:mr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:mr(m.mode)})}for(let[u,m]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await Qe(e,c),l=Jc(f,d);for(let u of i)l.push({path:u,status:"U"});return l.sort((u,m)=>Ce(u.path,m.path)),n?{items:l.filter(u=>ye(n,u.path))}:{items:l}}async function Xc(e,t,n,r){let o=await He(e,t);if(S(o))return o;let s=await He(e,n);if(S(s))return s;let i=await Ne(e,o.commit.tree,s.commit.tree);return ef(e,i,r)}async function xm(e,t,n,r){let o=await He(e,t);if(S(o))return o;let s=await He(e,n);if(S(s))return s;let i=await Dt(e,o.hash,s.hash);if(i.length===0)return O(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
|
|
365
|
+
`);let c=i[0],f=await M(e,c),d=await Ne(e,f.tree,s.commit.tree),l=await ef(e,d,r);return Zc(l)||a&&(l.stderr=a),l}async function ef(e,t,n){let{remaining:r,renames:o}=await Qe(e,t),s=Jc(r,o);return s.sort((i,a)=>Ce(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function Cm(e,t,n){let r=qe(e);if(r)return r;let o=await He(e,t);if(S(o))return o;let s=e.workTree,i=await fe(e,o.commit.tree),a=[];for(let[c,f]of i){if(n&&!ye(n,c))continue;let d=T(s,c);if(!await e.fs.exists(d)){a.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let l=await e.fs.readFileBuffer(d),u=await pt("blob",l);u!==f.hash&&a.push({path:c,status:"M",oldHash:f.hash,newHash:u,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return a.sort((c,f)=>Ce(c.path,f.path)),{items:a}}async function Pm(e,t,n){let r;switch(n){case"stat":r=await Hm(e,t);break;case"shortstat":r=await Am(e,t);break;case"numstat":r=await Tm(e,t);break;case"name-only":r=Im(t);break;case"name-status":r=Om(t);break;default:r=await Rm(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function Rm(e,t){let n="",r=new Set,o=await $m(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let i=await Promise.all(s.combinedParentHashes.map(async f=>f?await se(e,f):"")),a=await hi(e,s);if(i.some(f=>Ie(f))||Ie(a)){let f=s.combinedParentHashes.map(d=>d?z(d):"0000000");n+=`diff --cc ${s.path}
|
|
365
366
|
index ${f.join(",")}..0000000
|
|
366
367
|
Binary files differ
|
|
367
368
|
`,r.add(s.path)}else{let f=Qs({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:i,resultHash:null,resultMode:s.newMode??null,resultContent:a});f?(n+=f,r.add(s.path)):n+=`* Unmerged path ${s.path}
|
|
368
369
|
`}}else n+=`* Unmerged path ${s.path}
|
|
369
|
-
`;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await
|
|
370
|
-
`;return t}function
|
|
370
|
+
`;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await se(e,s.oldHash):"",a=await hi(e,s);s.status==="R"&&s.oldPath?n+=yt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:to(s.oldHash,o),newHash:to(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=yt({path:s.path,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:to(s.oldHash,o),newHash:to(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function $m(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=T(e.gitDir,"objects",a),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,d),d},s=async(a,c)=>{let f=a.slice(0,2),d=a.slice(2,c),l=await o(f),u=0;for(let m of l)if(m.startsWith(d)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function to(e,t){if(e)return e.length!==40?e:t.get(e)??z(e)}function Im(e){let t="";for(let n of e)t+=`${n.path}
|
|
371
|
+
`;return t}function Om(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}
|
|
371
372
|
`}else t+=`${n.status} ${n.path}
|
|
372
|
-
`;return t}async function
|
|
373
|
-
`;continue}let o=r.oldHash?await
|
|
373
|
+
`;return t}async function Tm(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 se(e,r.oldHash):"",s=await hi(e,r),i=Ie(o)||Ie(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:d}=tf(o,s);a=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=Cn(r.oldPath,r.path);n+=`${a} ${c} ${f}
|
|
374
375
|
`}else n+=`${a} ${c} ${r.path}
|
|
375
|
-
`}return n}async function
|
|
376
|
+
`}return n}async function Hm(e,t){let n=await nf(e,t);return _r(n)}async function Am(e,t){let n=await nf(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=fr(s,r,o);return i?`${i}
|
|
376
377
|
`:n.some(a=>a.isUnmerged)?` 0 files changed
|
|
377
|
-
`:""}async function
|
|
378
|
-
`);for(let y of k){let $=await
|
|
379
|
-
`)}}else{let
|
|
380
|
-
`)}}if(!n.tags)for(let y of
|
|
381
|
-
`))}if(n.prune){let y=`refs/remotes/${i}`,$=await
|
|
382
|
-
`))}}let
|
|
383
|
-
`)}let R={stdout:"",stderr:C.join(""),exitCode:0};return await t?.hooks?.emitPost("post-fetch",{remote:i,url:f.url,refsUpdated:k.length}),R}})}function ro(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}te();Ee();se();de();Le();ue();te();Ee();se();de();Le();ue();async function of(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await af(e,o,o,t);let s=await q(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await _(e,a);c&&t.add(c)}let i=[];for(let a of t)await hn(e,a)&&i.push(a);return i}async function af(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=await e.fs.stat(i);if(a.isDirectory)await af(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await ze(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}var oo=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]),jm=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]),so=64,Lm=4,hi=4096,cf=65536,Gm=127;function Nm(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=Fm(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let l=n*16-16;l>=0;l-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[l+h])^oo[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=l+16;else{a=m;let h=m&o;i.push({ptr:l+16,val:m}),s[h]++}}let c=new Map;for(let l of i){let m=l.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(l)}for(let[l,m]of c){if(m.length<=so)continue;let h=[],p=m.length/so;for(let g=0;g<so;g++)h.push(m[Math.floor(g*p)]);c.set(l,h),s[l]=so}let f=new Uint32Array(r+1),d=[],u=0;for(let l=0;l<r;l++){f[l]=u;let m=c.get(l);if(m){for(let h of m)d.push(h);u+=m.length}}return f[r]=u,{src:e,hashMask:o,buckets:f,entries:d}}function _m(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=df(i,a,r),a=df(i,a,o),c(18),a++;let f=0,d=0,u=Math.min(16,o);for(let p=0;p<u;p++)i[a++]=t[p],f=(f<<8|t[p])^oo[f>>>23],d++;f=f>>>0;let l=u,m=0,h=0;for(;l<o;){if(h<hi){f^=jm[t[l-16]],f=((f<<8|t[l])^oo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let k=g;k<w;k++){let b=e.entries[k];if(b.val!==f)continue;let E=b.ptr,x=s.byteLength-E,C=o-l;if(x>C&&(x=C),x<=h)break;let P=0;for(;P<x&&s[E+P]===t[l+P];)P++;if(P>h&&(h=P,m=E,h>=hi))break}}if(h<Lm)c(2),d===0&&a++,i[a++]=t[l++],d++,d===Gm&&(i[a-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[l-1];)if(h++,m--,l--,a--,!(--d>0)){a--,d=-1;break}d>0&&(i[a-d-1]=d),d=0}let p=h>cf?h-cf:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,l+=h,m+=h,h=p,m>4294967295&&(h=0),h<hi){f=0;for(let k=-16;k<0;k++)f=(f<<8|t[l+k])^oo[f>>>23];f=f>>>0}}if(n&&a>n)return null}return d>0&&(i[a-d-1]=d),n&&a>n?null:i.subarray(0,a)}var ff={blob:0,tree:1,commit:2,tag:3};function lf(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let u=ff[f.type]??99,l=ff[d.type]??99;return u!==l?u-l:d.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],u={hash:d.hash,type:d.type,content:d.content,depth:0},l=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 b=a[p-h]??null;if(!b)continue;let E=l?l.byteLength:d.content.byteLength/2|0;if(E<16)continue;let x=_m(b,d.content,E);x&&(!l||x.byteLength<l.byteLength)&&(l=x,m=g.hash)}if(l&&m){u.delta=l,u.deltaBase=m;let p=s.get(m);u.depth=(p?.depth??0)+1}s.set(d.hash,u),i.push(u),a.length>=n&&(a.shift(),c.shift()),a.push(Nm(d.content)),c.push(d.hash)}return i}function Fm(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 df(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}ds();yr();de();async function Um(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(T(r,i)),c=new Mn(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Ys(e,t,[]):(await Ys(e,t,[])).filter(s=>!n.has(s.hash))}async function pi(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,i=e.depth??50;if(r.length===0)return null;let a=e.all?await Ys(t,r,[]):await Um(t,r);if(a.length===0)return null;let c=a.length,f=lf(a,{window:s,depth:i}),d=f.filter(C=>C.delta).length,u=f.map(C=>({hash:C.hash,type:C.type,content:C.content,delta:C.delta,deltaBaseHash:C.deltaBase})),{data:l,entries:m}=await na(u),h=await aa(l,m),p=l.subarray(l.byteLength-20),g="";for(let C=0;C<20;C++){let P=p[C];g+=(P>>4).toString(16)+(P&15).toString(16)}let w=T(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let k=`pack-${g}`,b=T(w,`${k}.pack`),E=T(w,`${k}.idx`);await n.writeFile(b,l),await n.writeFile(E,h);let x=new Set(f.map(C=>C.hash));if(o){let C=await n.readdir(w);for(let y of C){if(!y.endsWith(".idx"))continue;let $=y.slice(0,-4);if($===k)continue;let v=T(w,`${$}.idx`),G=!0;try{let L=await n.readFileBuffer(v),Y=new Mn(L);for(let j of Y.allHashes())if(!x.has(j)){G=!1;break}}catch{G=!1}if(G){try{await n.rm(T(w,`${$}.pack`))}catch{}try{await n.rm(v)}catch{}}}let P=T(t.gitDir,"objects"),R;try{R=await n.readdir(P)}catch{R=[]}for(let y of R){if(y==="pack"||y==="info"||y.length!==2)continue;let $=T(P,y),v;try{v=await n.readdir($)}catch{continue}for(let G of v){let L=`${y}${G}`;x.has(L)&&await n.rm(T($,G))}try{(await n.readdir($)).length===0&&await n.rm($,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function gi(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(`
|
|
384
|
-
`)}function
|
|
378
|
+
`:""}async function hi(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path),r=await Ir(e.fs,n);return mi.decode(r)}return se(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 Ir(e.fs,n)}return gt(e,t.newHash)}function tf(e,t){let n=Nt(e),r=Nt(t),o=it(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function nf(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?Cn(r.oldPath,r.path):r.path,s=r.oldHash?await gt(e,r.oldHash):new Uint8Array(0),i=await vm(e,r);if(pn(s)||pn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=mi.decode(s),c=mi.decode(i),{ins:f,del:d}=tf(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}ne();ln();ue();Ge();me();function Zn(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 Sm(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 no(e,t){if(!Sm(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function rf(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[B.string().name("remote").describe("Remote to fetch from").optional(),B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.remote||"origin",a;try{a=await ur(s,i,r.env)}catch(y){let $=y instanceof Error?y.message:"";if($.startsWith("network"))return O($);throw y}if(!a)return O(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,d=n.refspec,l;if(d&&d.length>0?l=d.map(Zn):l=[Zn(f.fetchRefspec)],t?.hooks){let y=await t.hooks.emitPre("pre-fetch",{remote:i,url:f.url,refspecs:l.map($=>`${$.src}:${$.dst}`),prune:n.prune,tags:n.tags});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}let u=await c.advertiseRefs();if(u.length===0)return{stdout:"",stderr:"",exitCode:0};let h=(await we(s)).map(y=>y.hash),p=await N(s,"HEAD");p&&h.push(p);let g=[],w=new Set,k=[];for(let y of u)if(y.name!=="HEAD")for(let $ of l){let A=no($,y.name);if(A!==null){k.push({remote:y,localRef:A,force:$.force}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash));break}}if(n.tags)for(let y of u)y.name.startsWith("refs/tags/")&&(k.push({remote:y,localRef:y.name,force:!1}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));let b=new Set(h),E=g.filter(y=>!b.has(y));E.length>0&&await c.fetch(E,h);let x=await Bt(s,r.env),P=[];P.push(`From ${f.url}
|
|
379
|
+
`);for(let y of k){let $=await N(s,y.localRef);await Y(s,y.localRef,y.remote.hash),await Ue(s,y.localRef,{oldHash:$??J,newHash:y.remote.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:$?"fetch":"fetch: storing head"});let A=ro(y.remote.name),L=ro(y.localRef);if($){if($!==y.remote.hash){let G=z($),V=z(y.remote.hash);P.push(` ${G}..${V} ${A} -> ${L}
|
|
380
|
+
`)}}else{let V=y.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";P.push(`${V} ${A} -> ${L}
|
|
381
|
+
`)}}if(!n.tags)for(let y of u){if(!y.name.startsWith("refs/tags/")||w.has(y.hash))continue;let $=await N(s,y.name),A=y.peeledHash??y.hash;!$&&b.has(A)&&(await Y(s,y.name,y.hash),await Ue(s,y.name,{oldHash:J,newHash:y.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:"fetch: storing head"}),P.push(` * [new tag] ${ro(y.name)} -> ${ro(y.name)}
|
|
382
|
+
`))}if(n.prune){let y=`refs/remotes/${i}`,$=await we(s,y),A=new Set(u.filter(L=>L.name.startsWith("refs/heads/")).map(L=>L.name.slice(11)));for(let L of $){let G=L.name.slice(y.length+1);A.has(G)||(await de(s,L.name),P.push(` - [deleted] (none) -> ${i}/${G}
|
|
383
|
+
`))}}let C=u.find(y=>y.name==="HEAD");if(C){let y=T(s.gitDir,"FETCH_HEAD"),$=u.find(L=>L.name.startsWith("refs/heads/")&&L.hash===C.hash),A=$?`branch '${$.name.slice(11)}' of`:"of";await r.fs.writeFile(y,`${C.hash} ${A} ${f.url}
|
|
384
|
+
`)}let R={stdout:"",stderr:P.join(""),exitCode:0};return await t?.hooks?.emitPost("post-fetch",{remote:i,url:f.url,refsUpdated:k.length}),R}})}function ro(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}ne();xe();oe();ue();Ge();me();ne();xe();oe();ue();Ge();me();async function sf(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await we(e,"refs");for(let a of r)t.add(a.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await of(e,o,o,t);let s=await q(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await N(e,a);c&&t.add(c)}let i=[];for(let a of t)await hn(e,a)&&i.push(a);return i}async function of(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=await e.fs.stat(i);if(a.isDirectory)await of(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await ze(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}var oo=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]),so=64,Mm=4,pi=4096,af=65536,jm=127;function Gm(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=_m(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[u+h])^oo[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=u+16;else{a=m;let h=m&o;i.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of i){let m=u.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(u)}for(let[u,m]of c){if(m.length<=so)continue;let h=[],p=m.length/so;for(let g=0;g<so;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=so}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 Lm(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=ff(i,a,r),a=ff(i,a,o),c(18),a++;let f=0,d=0,l=Math.min(16,o);for(let p=0;p<l;p++)i[a++]=t[p],f=(f<<8|t[p])^oo[f>>>23],d++;f=f>>>0;let u=l,m=0,h=0;for(;u<o;){if(h<pi){f^=Dm[t[u-16]],f=((f<<8|t[u])^oo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let k=g;k<w;k++){let b=e.entries[k];if(b.val!==f)continue;let E=b.ptr,x=s.byteLength-E,P=o-u;if(x>P&&(x=P),x<=h)break;let C=0;for(;C<x&&s[E+C]===t[u+C];)C++;if(C>h&&(h=C,m=E,h>=pi))break}}if(h<Mm)c(2),d===0&&a++,i[a++]=t[u++],d++,d===jm&&(i[a-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--d>0)){a--,d=-1;break}d>0&&(i[a-d-1]=d),d=0}let p=h>af?h-af:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<pi){f=0;for(let k=-16;k<0;k++)f=(f<<8|t[u+k])^oo[f>>>23];f=f>>>0}}if(n&&a>n)return null}return d>0&&(i[a-d-1]=d),n&&a>n?null:i.subarray(0,a)}var cf={blob:0,tree:1,commit:2,tag:3};function df(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let l=cf[f.type]??99,u=cf[d.type]??99;return l!==u?l-u:d.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],l={hash:d.hash,type:d.type,content:d.content,depth:0},u=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==d.type||(s.get(g.hash)?.depth??0)>=r||d.content.byteLength<g.content.byteLength>>>5)continue;let b=a[p-h]??null;if(!b)continue;let E=u?u.byteLength:d.content.byteLength/2|0;if(E<16)continue;let x=Lm(b,d.content,E);x&&(!u||x.byteLength<u.byteLength)&&(u=x,m=g.hash)}if(u&&m){l.delta=u,l.deltaBase=m;let p=s.get(m);l.depth=(p?.depth??0)+1}s.set(d.hash,l),i.push(l),a.length>=n&&(a.shift(),c.shift()),a.push(Gm(d.content)),c.push(d.hash)}return i}function _m(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 ff(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}ds();Er();ue();async function Nm(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(T(r,i)),c=new Mn(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Ys(e,t,[]):(await Ys(e,t,[])).filter(s=>!n.has(s.hash))}async function gi(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,i=e.depth??50;if(r.length===0)return null;let a=e.all?await Ys(t,r,[]):await Nm(t,r);if(a.length===0)return null;let c=a.length,f=df(a,{window:s,depth:i}),d=f.filter(P=>P.delta).length,l=f.map(P=>({hash:P.hash,type:P.type,content:P.content,delta:P.delta,deltaBaseHash:P.deltaBase})),{data:u,entries:m}=await ra(l),h=await ca(u,m),p=u.subarray(u.byteLength-20),g="";for(let P=0;P<20;P++){let C=p[P];g+=(C>>4).toString(16)+(C&15).toString(16)}let w=T(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let k=`pack-${g}`,b=T(w,`${k}.pack`),E=T(w,`${k}.idx`);await n.writeFile(b,u),await n.writeFile(E,h);let x=new Set(f.map(P=>P.hash));if(o){let P=await n.readdir(w);for(let y of P){if(!y.endsWith(".idx"))continue;let $=y.slice(0,-4);if($===k)continue;let A=T(w,`${$}.idx`),L=!0;try{let G=await n.readFileBuffer(A),V=new Mn(G);for(let j of V.allHashes())if(!x.has(j)){L=!1;break}}catch{L=!1}if(L){try{await n.rm(T(w,`${$}.pack`))}catch{}try{await n.rm(A)}catch{}}}let C=T(t.gitDir,"objects"),R;try{R=await n.readdir(C)}catch{R=[]}for(let y of R){if(y==="pack"||y==="info"||y.length!==2)continue;let $=T(C,y),A;try{A=await n.readdir($)}catch{continue}for(let L of A){let G=`${y}${L}`;x.has(G)&&await n.rm(T($,L))}try{(await n.readdir($)).length===0&&await n.rm($,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function wi(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 lf(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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=await sf(s),a=await gi({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${wi(a.totalCount,a.deltaCount)}
|
|
385
386
|
`,exitCode:0}:{stdout:`Nothing new to pack.
|
|
386
|
-
`,stderr:"",exitCode:0}}})}function
|
|
387
|
-
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var
|
|
387
|
+
`,stderr:"",exitCode:0}}})}function uf(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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o;await ha(s),await dt(s);let i=await Um(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await gi({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await Bm(s.gitDir,r.fs),f)return{stdout:"",stderr:`${wi(f.totalCount,f.deltaCount,!0)}
|
|
388
|
+
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Fm=2160*60*60;async function Um(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await we(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Fm,i=T(e.gitDir,"logs");await e.fs.exists(i)&&await mf(e,i,i,s,t);let a=await q(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let d=await N(e,f);d&&t.add(d)}let c=[];for(let f of t)await hn(e,f)&&c.push(f);return c}async function mf(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=T(t,i),c=await e.fs.stat(a);if(c.isDirectory){await mf(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),d=await ze(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 bn(e,f,l);for(let u of l)u.newHash!==J&&o.add(u.newHash)}}}async function Bm(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{}}ue();wn();function hf(e){e.command("init",{description:"Initialize a new repository",args:[B.string().name("directory").describe("The directory to initialize").optional()],options:{bare:H().describe("Create a bare repository"),initialBranch:Q.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?xt(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:i}=await hs(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),a="";i&&r&&(a=`warning: re-init: ignored --initial-branch=${r}
|
|
388
389
|
`);let c=t.bare?"bare ":"";return{stdout:`${i?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
|
|
389
|
-
`,stderr:a,exitCode:0}}})}
|
|
390
|
-
`,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var
|
|
390
|
+
`,stderr:a,exitCode:0}}})}ne();Wn();ne();function pf(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let i=e[s+1];if(i===void 0){o+="%",s++;continue}if((i==="a"||i==="c")&&s+2<e.length){let a=e[s+2],c=i==="a"?r.author:r.committer;switch(a){case"n":o+=c.name,s+=3;continue;case"e":case"E":o+=c.email,s+=3;continue;case"t":o+=c.timestamp.toString(),s+=3;continue;case"I":o+=Xm(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Zm(c.timestamp,c.timezone),s+=3;continue;case"d":o+=St(c.timestamp,c.timezone),s+=3;continue;case"D":o+=Jm(c.timestamp,c.timezone),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(z).join(" "),s+=2;continue;case"s":o+=bi(r.message),s+=2;continue;case"b":o+=Wm(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
|
|
391
|
+
`,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var bi=ie;function Wm(e){let t=e.indexOf(`
|
|
391
392
|
|
|
392
|
-
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function
|
|
393
|
+
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function gf(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 wf(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?z(o):o,c=bi(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${bi(s.message)}`),a.join(`
|
|
393
394
|
`)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
|
|
394
395
|
`))a.push(` ${f}`);return a.join(`
|
|
395
|
-
`)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${
|
|
396
|
+
`)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${St(s.author.timestamp,s.author.timezone)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${St(s.committer.timestamp,s.committer.timezone)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
|
|
396
397
|
`))a.push(` ${f}`);return a.join(`
|
|
397
|
-
`)}default:return
|
|
398
|
+
`)}default:return qm(t,n)}}function qm(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(z).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${St(r.author.timestamp,r.author.timezone)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
|
|
398
399
|
`))s.push(` ${a}`);return s.join(`
|
|
399
|
-
`)}var
|
|
400
|
+
`)}var Km=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],zm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Vm(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 yi(e,t){let n=Vm(t);return new Date((e+n*60)*1e3)}function Ym(e){return`${e.slice(0,3)}:${e.slice(3)}`}function Xm(e,t){let n=yi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${i}:${a}:${c}${Ym(t)}`}function Zm(e,t){let n=yi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${i}:${a}:${c} ${t}`}function Jm(e,t){let n=yi(e,t),r=Km[n.getUTCDay()]?.slice(0,3),o=zm[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}oe();me();nn();Oe();function kf(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[B.string().name("revisions").variadic().optional()],options:{maxCount:Q.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:Q.string().describe("Filter by author (regex or substring)"),grep:Q.string().describe("Filter by commit message (regex or substring)"),since:Q.string().describe("Show commits after date"),after:Q.string().describe("Synonym for --since"),until:Q.string().describe("Show commits before date"),before:Q.string().describe("Synonym for --until"),decorate:H().describe("Show ref names next to commit hashes"),reverse:H().describe("Output commits in reverse order"),format:Q.string().describe("Pretty-print format string"),pretty:Q.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a,c,f=n.revisions,d=f&&f.length===1?eo(f[0]):null;if(d){let F=async le=>{let je=await Be(i,le);if(!je)return Lt(le);try{return await _e(i,je)}catch{return Lt(le)}},D=await F(d.left);if(typeof D=="object"&&"exitCode"in D)return D;let K=await F(d.right);if(typeof K=="object"&&"exitCode"in K)return K;let ae=D,ee=K;if(d.type==="two-dot")a=[ee],c=[ae];else{a=[ae,ee];let le=await Dt(i,ae,ee);c=le.length>0?le:void 0}if(n.all){let le=await we(i);for(let Jt of le)try{let De=await _e(i,Jt.hash);a.includes(De)||a.push(De)}catch{}let je=await X(i);je&&!a.includes(je)&&a.push(je)}}else if(n.all){let F=await we(i),D=new Set;for(let ae of F)try{D.add(await _e(i,ae.hash))}catch{}let K=await X(i);K&&D.add(K),a=[...D]}else if(f&&f.length>0){let F=[];for(let D of f){let K=await Be(i,D);if(!K)return Lt(D);try{F.push(await _e(i,K))}catch{return Lt(D)}}a=F}else{let F=await Ke(i);if(S(F))return F;a=[F]}if(a.length===0)return O("your current branch does not have any commits yet");let l=o.passthrough.length>0?o.passthrough.map(F=>Le(F,"")):null,u=n.author?bf(n.author):null,m=n.grep?bf(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?ti(h):null,w=p?ti(p):null,k=n.format??n.pretty,b=null,E=null,x=!1;if(n.oneline)E="oneline",x=!0;else if(k!==void 0){let F=gf(k);b=F.formatStr,E=F.preset}let P=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,R=n.decorate||b!=null&&(b.includes("%d")||b.includes("%D"))?await th(i):null,y=R?F=>yf(R,F):void 0,$=R?F=>{let D=yf(R,F);return D.startsWith("(")&&D.endsWith(")")?D.slice(1,-1):D}:void 0,A=n.maxCount,L=n.reverse,G=l?eh(i,a,l,c?await Qm(i,c):void 0):Tt(i,a,{exclude:c}),V=[];for await(let F of G){if(A!==void 0&&V.length>=A)break;let{commit:D}=F;if(!(w!==null&&D.committer.timestamp>w)&&!(g!==null&&D.committer.timestamp<=g)){if(u){let K=`${D.author.name} <${D.author.email}>`;if(!u(K))continue}m&&!m(D.message)||V.push(F)}}let j=L?V.reverse():V;if(b!==null){let F=[];for(let D of j){let K={hash:D.hash,commit:D.commit,decorations:y,decorationsRaw:$},ae=pf(b,K),ee=await Ef(i,D.commit,P);ee&&(ae+=`
|
|
400
401
|
|
|
401
|
-
${ee.replace(/\n$/,"")}`),F.push(
|
|
402
|
+
${ee.replace(/\n$/,"")}`),F.push(ae)}return{stdout:F.length>0?`${F.join(`
|
|
402
403
|
`)}
|
|
403
|
-
`:"",stderr:"",exitCode:0}}let I=E??"medium",
|
|
404
|
+
`:"",stderr:"",exitCode:0}}let I=E??"medium",v=I==="oneline",W=[];for(let F=0;F<j.length;F++){let D=j[F],K={hash:D.hash,commit:D.commit,decorations:y,decorationsRaw:$},ae=wf(I,K,F===0,x),ee=await Ef(i,D.commit,P);ee&&(ae+=`${v?`
|
|
404
405
|
`:`
|
|
405
406
|
|
|
406
|
-
`}${ee.replace(/\n$/,"")}`),W.push(
|
|
407
|
-
`)}
|
|
408
|
-
`:"",stderr:"",exitCode:0}}})}async function
|
|
409
|
-
`).join("")}function
|
|
410
|
-
`).join("")}async function
|
|
411
|
-
`:""}async function
|
|
412
|
-
`;else{let c=
|
|
413
|
-
`}}return o}async function
|
|
414
|
-
`,x=o.passthrough.length>0?o.passthrough.map(R=>{let y=r.cwd!==c?
|
|
415
|
-
Please, commit your changes before you merge.`);if(await
|
|
416
|
-
Please, commit your changes before you merge.`);let
|
|
417
|
-
`);let m=await
|
|
418
|
-
`,stderr:"",exitCode:0};if(n.noFf&&n.ffOnly)return O("--no-ff and --ff-only are incompatible");let g=p===a&&!n.noFf;if(n.ffOnly&&!g)return
|
|
407
|
+
`}${ee.replace(/\n$/,"")}`),W.push(ae)}return{stdout:W.length>0?`${W.join(`
|
|
408
|
+
`)}
|
|
409
|
+
`:"",stderr:"",exitCode:0}}})}async function Qm(e,t){let n=new Set;for await(let r of Tt(e,t))n.add(r.hash);return n}function bf(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*eh(e,t,n,r){let o=new Set(r),s=new Bn,i=async a=>{if(!o.has(a)){let c=await M(e,a);s.push({hash:a,commit:c})}};for(let a of t)await i(a);for(;s.size>0;){let a=s.pop();if(o.has(a.hash))continue;o.add(a.hash);let{commit:c}=a,f=c.parents;if(f.length===0){(await Ne(e,null,c.tree)).some(u=>ye(n,u.path))&&(yield a);continue}if(f.length===1){let l=f[0];if(l){let u=await M(e,l);(await Ne(e,u.tree,c.tree)).some(h=>ye(n,h.path))&&(yield a),await i(l)}continue}let d=[];for(let l of f){let u=await M(e,l);(await Ne(e,u.tree,c.tree)).some(h=>ye(n,h.path))||d.push(l)}if(d.length>0&&d[0])await i(d[0]);else{yield a;for(let l of f)await i(l)}}}async function th(e){let t=await Z(e),n=t?.type==="symbolic"?be(t.target):null,r=await X(e),o=new Map,s=(f,d,l)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:d,fullRef:l})},i=await we(e,"refs/heads");for(let f of i)s(f.hash,be(f.name),f.name);let a=await we(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await we(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 yf(e,t){let n=e.byHash.get(t),r=!e.headTarget&&e.headHash!==null&&e.headHash===t;if((!n||n.length===0)&&!r)return"";let o=[],s=e.headTarget&&n?n.find(a=>a.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let i=n?n.filter(a=>a!==s):[];i.sort((a,c)=>a.fullRef>c.fullRef?-1:a.fullRef<c.fullRef?1:0);for(let a of i)o.push(a.label);return o.length>0?`(${o.join(", ")})`:""}async function Ef(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:i}=await Qe(e,o);switch(n){case"name-only":return nh(s,i);case"name-status":return rh(s,i);case"stat":return sh(e,s,i);case"shortstat":return oh(e,s,i);case"numstat":return ih(e,s,i);case"patch":return ah(e,s,i)}}function nh(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 rh(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 sh(e,t,n){let{fileStats:r}=await Lr(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),_r(r)}async function oh(e,t,n){let{fileStats:r}=await Lr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=fr(r.length,o,s);return i?`${i}
|
|
412
|
+
`:""}async function ih(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:Cn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(Ie(i)||Ie(a))o+=`- - ${s.display}
|
|
413
|
+
`;else{let c=Nt(i),f=Nt(a),d=it(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 ah(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=yt({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=yt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}ne();xe();ue();Gn();Je();function Cf(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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=qe(i);if(a)return a;let c=i.workTree,f=n.cached,d=n.modified,l=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||d||l||u||m||(f=!0);let b=await q(i),E=g?"\0":`
|
|
415
|
+
`,x=o.passthrough.length>0?o.passthrough.map(R=>{let y=r.cwd!==c?ch(c,r.cwd):"";return Le(R,y)}):null,P=[];if(f)for(let R of b.entries){if(x&&!ye(x,R.path))continue;let y=w?R.stage>0?"M":"H":null;P.push(xf(R,h,y))}if(m&&!f)for(let R of b.entries)R.stage!==0&&(x&&!ye(x,R.path)||P.push(xf(R,!0,w?"M":null)));if(d||l){let R=await fh(i,c,b);for(let{path:y,status:$}of R){if($==="modified"&&!d||$==="deleted"&&!l||x&&!ye(x,y))continue;let A=w?$==="deleted"?"R":"C":null;P.push(A?`${A} ${y}`:y)}}if(u){let R=await dh(i,c,b,p);for(let y of R)x&&!ye(x,y)||P.push(w?`? ${y}`:y)}return{stdout:P.length>0?P.join(E)+E:"",stderr:"",exitCode:0}}})}function xf(e,t,n){if(t){let r=e.mode.toString(8).padStart(6,"0");return`${n?`${n} `:""}${r} ${e.hash} ${e.stage} ${e.path}`}return n?`${n} ${e.path}`:e.path}function ch(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function fh(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=T(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await ot(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await yn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function dh(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await Ze(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}ne();Wn();xe();oe();Ge();me();nn();Oe();function Pf(e,t){e.command("merge",{description:"Join two or more development histories together",args:[B.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:Q.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return ph(s,r.env);if(n.continue)return hh(s,r.env,t);let i=n.branch;if(!i)return O("you must specify a branch to merge");let a=await Ke(s);if(S(a))return a;let c=await q(s),f=on(c,"Merging");if(f)return f;if(await N(s,"MERGE_HEAD"))return O(`You have not concluded your merge (MERGE_HEAD exists).
|
|
416
|
+
Please, commit your changes before you merge.`);if(await N(s,"CHERRY_PICK_HEAD"))return O(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
|
|
417
|
+
Please, commit your changes before you merge.`);let u=await Be(s,i);if(!u)return _(`merge: ${i} - not something we can merge
|
|
418
|
+
`);let m=await _e(s,u),h=await Dt(s,a,m),p=h[0]??null;if(h.length===0)return O("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
|
+
`,stderr:"",exitCode:0};if(n.noFf&&n.ffOnly)return O("--no-ff and --ff-only are incompatible");let g=p===a&&!n.noFf;if(n.ffOnly&&!g)return _(`hint: Diverging branches can't be fast-forwarded, you need to either:
|
|
419
420
|
hint:
|
|
420
421
|
hint: git merge --no-ff
|
|
421
422
|
hint:
|
|
@@ -425,61 +426,67 @@ hint: git rebase
|
|
|
425
426
|
hint:
|
|
426
427
|
hint: Disable this message with "git config set advice.diverging false"
|
|
427
428
|
fatal: Not possible to fast-forward, aborting.
|
|
428
|
-
`,128);if(await
|
|
429
|
+
`,128);if(await N(s,"REVERT_HEAD")&&await Ht(s),g&&!n.squash){let b=await Z(s),E=await Ks(s,a,m);if(E.exitCode===0&&n.message&&(E.stdout=E.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),E.exitCode===0){await he(s,"MERGE_MSG");let x=b?.type==="symbolic"?b.target:"HEAD";await te(s,r.env,x,a,m,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,b?.type==="symbolic"),await t?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:m,strategy:"fast-forward",commitHash:null})}return E}let w=n.message,k=w?w.endsWith(`
|
|
429
430
|
`)?w:`${w}
|
|
430
|
-
`:void 0;return n.squash?
|
|
431
|
+
`:void 0;return n.squash?mh(s,a,m,i,r.env,t,k):lh(s,a,m,i,r.env,n.noFf,t,k)}})}async function lh(e,t,n,r,o,s=!1,i,a){let c=await M(e,t),f=await Z(e),d=f?.type==="symbolic"?be(f.target):"HEAD",l={a:"HEAD",b:r},u=await Ur(e,t,n,l),m=await dn(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 te(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 P=a??await Vn(e,r,d);if(i?.hooks){let y={message:P,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},$=await i.hooks.emitPre("merge-msg",y);if($)return{stdout:"",stderr:$.message??"",exitCode:1};P=y.message}let C=Gt({version:2,entries:u.entries}).sort();return P+=`
|
|
431
432
|
# Conflicts:
|
|
432
|
-
${
|
|
433
|
+
${C.map(y=>`# ${y}`).join(`
|
|
433
434
|
`)}
|
|
434
|
-
`,await
|
|
435
|
+
`,await $e(e,"MERGE_MSG",P),await $e(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
435
436
|
`)}
|
|
436
|
-
`,stderr:"",exitCode:1}}let h=m.mergedTreeHash,p=await
|
|
437
|
+
`,stderr:"",exitCode:1}}await he(e,"MERGE_MSG");let h=m.mergedTreeHash,p=await Yt(e,o);if(S(p))return p;let g=await Ve(e,o);if(S(g))return g;let w=a??await Vn(e,r,d);if(i?.hooks){let P={message:w,treeHash:h,headHash:t,theirsHash:n},C=await i.hooks.emitPre("merge-msg",P);if(C)return{stdout:"",stderr:C.message??"",exitCode:1};w=P.message}if(i?.hooks){let P=await i.hooks.emitPre("pre-merge-commit",{mergeMessage:w,treeHash:h,headHash:t,theirsHash:n});if(P)return{stdout:"",stderr:P.message??"",exitCode:1}}let k=await ft(e,h,[t,n],p,g,w),b=f?.type==="symbolic"?f.target:"HEAD";await te(e,o,b,t,k,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.emitPost("post-merge",{headHash:t,theirsHash:n,strategy:"three-way",commitHash:k});let E=await Tn(e,c.tree,h);return{stdout:`${u.messages.length>0?`${u.messages.join(`
|
|
437
438
|
`)}
|
|
438
439
|
`:""}Merge made by the 'ort' strategy.
|
|
439
|
-
${E}`,stderr:"",exitCode:0}}async function
|
|
440
|
-
|
|
440
|
+
${E}`,stderr:"",exitCode:0}}async function uh(e,t,n){let r=[];for await(let o of Tt(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: ${St(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
|
|
441
|
+
`))r.push(` ${i}`);r.push("")}return r.join(`
|
|
442
|
+
`)}async function mh(e,t,n,r,o,s,i){let a=await M(e,t),c=await Z(e),f={a:"HEAD",b:r},d=await Dt(e,t,n),l=d.length>0&&d[0]===t,u=l?`Updating ${z(t)}..${z(n)}
|
|
443
|
+
`:"",m=await Ur(e,t,n,f),h=await dn(e,m,a.tree,{labels:f,errorExitCode:l?1:2,operationName:"merge",skipStagedChangeCheck:l});if(!h.ok){await he(e,"MERGE_MSG"),!l&&h.failureKind==="staged"&&c?.type==="symbolic"&&await te(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=h;return u&&(E.stdout=u+E.stdout),E}let p;if(i?p=`Squashed commit of the following:
|
|
441
444
|
|
|
442
|
-
${
|
|
445
|
+
${i}`:p=`Squashed commit of the following:
|
|
446
|
+
|
|
447
|
+
${await uh(e,t,n)}`,await $e(e,"SQUASH_MSG",p),m.conflicts.length>0){let x=`
|
|
448
|
+
# Conflicts:
|
|
449
|
+
${Gt({version:2,entries:m.entries}).sort().map(R=>`# ${R}`).join(`
|
|
443
450
|
`)}
|
|
444
|
-
`,
|
|
451
|
+
`,P=await Ee(e,"MERGE_MSG");return await $e(e,"MERGE_MSG",(P??"")+x),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
445
452
|
`)}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
453
|
+
`,stderr:"",exitCode:1}}let g=h.mergedTreeHash,w=await Tn(e,a.tree,g),k=m.messages.length>0?`${m.messages.join(`
|
|
454
|
+
`)}
|
|
455
|
+
`:"";return{stdout:`${l?`${u}Fast-forward
|
|
449
456
|
`:""}${k}Squash commit -- not updating HEAD
|
|
450
457
|
${l?w:""}`,stderr:l?"":`Automatic merge went well; stopped before committing as requested
|
|
451
|
-
`,exitCode:0}}async function
|
|
452
|
-
${k}`,stderr:"",exitCode:0}}async function
|
|
453
|
-
`);let f=c[c.length-1],d=c.slice(0,-1),
|
|
454
|
-
`,128);let c=n.remote,f=n.branch;if(!c){let
|
|
458
|
+
`,exitCode:0}}async function hh(e,t,n){let r=await N(e,"MERGE_HEAD");if(!r)return O("There is no merge in progress (MERGE_HEAD missing).");let o=await q(e),s=on(o,"Committing");if(s)return s;let i=await Ke(e);if(S(i))return i;let a=await M(e,i),c=await Ee(e,"MERGE_MSG");if(c)c=Xt(c);else{let x=await Z(e),P=x?.type==="symbolic"?be(x.target):"HEAD";c=await Vn(e,"unknown",P)}let f=ve(o),d=await Se(e,f),l=await Yt(e,t);if(S(l))return l;let u=await Ve(e,t);if(S(u))return u;let m=Ot(c);if(n?.hooks){let x={message:m,treeHash:d,headHash:i,theirsHash:r},P=await n.hooks.emitPre("merge-msg",x);if(P)return{stdout:"",stderr:P.message??"",exitCode:1};m=x.message}if(n?.hooks){let x=await n.hooks.emitPre("pre-merge-commit",{mergeMessage:m,treeHash:d,headHash:i,theirsHash:r});if(x)return{stdout:"",stderr:x.message??"",exitCode:1}}let h=await ft(e,d,[i,r],l,u,m);await vr(e);let p=await Z(e),g=ie(m),w=p?.type==="symbolic"?p.target:"HEAD";await te(e,t,w,i,h,`commit (merge): ${g}`,p?.type==="symbolic"),await n?.hooks?.emitPost("post-merge",{headHash:i,theirsHash:r,strategy:"three-way",commitHash:h});let k=await Tn(e,a.tree,d),b=p?.type==="symbolic"?be(p.target):"detached HEAD";return{stdout:`${It(b,h,c)}
|
|
459
|
+
${k}`,stderr:"",exitCode:0}}async function ph(e,t){return xn(e,t,{operationRef:"MERGE_HEAD",noOpError:O("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:vr})}ne();xe();ue();Je();function Rf(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=qe(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
|
|
460
|
+
`);let f=c[c.length-1],d=c.slice(0,-1),l=xt(r.cwd,f),u=st(a,l);if(u.startsWith(".."))return O(`'${f}' is outside repository at '${a}'`);let m=await q(s),h=await r.fs.exists(l),p=h&&(await r.fs.stat(l)).isDirectory;if(d.length>1&&!p)return O(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of d){let k=xt(r.cwd,w),b=st(a,k);if(b.startsWith("..")){if(n.skip)continue;return O(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(k)){if(n.skip)continue;return O(`bad source, source=${b}, destination=${u}`)}let P=(await r.fs.stat(k)).isDirectory;if(!(P?m.entries.some(L=>L.path===b||L.path.startsWith(`${b}/`)):m.entries.some(L=>L.path===b&&L.stage===0))){let L=!P&&m.entries.some(G=>G.path===b&&G.stage>0);if(n.skip)continue;return O(L?`conflicted, source=${b}, destination=${u}`:`not under version control, source=${b}, destination=${u}`)}let R,y;if(p){let L=wr(b);R=u===""||u==="."?L:`${u}/${L}`,y=T(l,L)}else R=u,y=l;if(await r.fs.exists(y)&&!n.force)if((await r.fs.stat(y)).isDirectory){let G=wr(b);R=`${R}/${G}`,y=T(y,G)}else{if(n.skip)continue;return O(`destination exists, source=${b}, destination=${R}`)}if(b===R){if(n.skip)continue;return O(`can not move directory into itself, source=${b}, destination=${R}`)}let A=Ut(y);if(!await r.fs.exists(A)){if(n.skip)continue;return O(`renaming '${b}' failed: No such file or directory`)}if(P){let L=`${b}/`,G=m.entries.filter(V=>V.path.startsWith(L)&&V.stage===0);for(let V of G){let j=V.path.slice(b.length),I=R+j,v=y+j;g.push({srcRel:V.path,dstRel:I,srcAbs:T(a,V.path),dstAbs:v})}}else g.push({srcRel:b,dstRel:R,srcAbs:k,dstAbs:y})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let k=Ut(w.dstAbs);await r.fs.exists(k)||await r.fs.mkdir(k,{recursive:!0});let b=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,b),await r.fs.rm(w.srcAbs);let E=ss(m,w.srcRel,0);if(E){m=nt(m,w.srcRel);let x={...E,path:w.dstRel};m=ht(m,x)}}for(let w of g)await Nn(r.fs,Ut(w.srcAbs),a);return await re(s,m),{stdout:"",stderr:"",exitCode:0}}})}ne();Xe();ln();xe();oe();ue();at();Ge();me();function $f(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[B.string().name("remote").describe("Remote to pull from").optional(),B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=await Ke(s);if(S(i))return i;let a=await q(s);if(Pt(a))return _(`error: Pulling is not possible because you have unmerged files.
|
|
461
|
+
`,128);let c=n.remote,f=n.branch;if(!c){let ce=await Z(s);if(ce?.type==="symbolic"){let Me=ce.target.startsWith("refs/heads/")?ce.target.slice(11):ce.target,Jn=(await pe(s))[`branch "${Me}"`];Jn&&(c=Jn.remote||"origin",!f&&Jn.merge&&(f=Jn.merge.startsWith("refs/heads/")?Jn.merge.slice(11):Jn.merge))}}c=c||"origin";let d;try{d=await ur(s,c,r.env)}catch(ce){let Me=ce instanceof Error?ce.message:"";if(Me.startsWith("network"))return O(Me);throw ce}if(!d)return O(`'${c}' does not appear to be a git repository`);let{transport:l,config:u}=d,m=f??null;if(t?.hooks){let ce=await t.hooks.emitPre("pre-pull",{remote:c,branch:m});if(ce)return{stdout:"",stderr:ce.message??"",exitCode:1}}let h=Zn(u.fetchRefspec),p=await l.advertiseRefs();if(p.length===0)return O("Couldn't find remote ref HEAD");let w=(await we(s)).map(ce=>ce.hash),k=await N(s,"HEAD");k&&w.push(k);let b=[],E=new Set,x=[];for(let ce of p){if(ce.name==="HEAD")continue;let Me=no(h,ce.name);Me!==null&&(x.push({remote:ce,localRef:Me}),E.has(ce.hash)||(E.add(ce.hash),b.push(ce.hash)))}let P=new Set(w),C=b.filter(ce=>!P.has(ce));C.length>0&&await l.fetch(C,w);let R=await Bt(s,r.env);for(let ce of x){let Me=await N(s,ce.localRef);await Y(s,ce.localRef,ce.remote.hash),await Ue(s,ce.localRef,{oldHash:Me??J,newHash:ce.remote.hash,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:Me?"pull":"pull: storing head"})}let y=null;if(f){let ce=p.find(Me=>Me.name===`refs/heads/${f}`);if(ce)y=ce.hash;else return O(`Couldn't find remote ref refs/heads/${f}`)}else{let ce=p.find(Me=>Me.name==="HEAD");ce&&(y=ce.hash)}if(y&&await r.fs.writeFile(T(s.gitDir,"FETCH_HEAD"),`${y} ${u.url}
|
|
455
462
|
`),!y)return O("Could not determine remote HEAD");let $=y;if(i===$)return await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
456
|
-
`,stderr:"",exitCode:0};let
|
|
457
|
-
`,stderr:"",exitCode:0};let L
|
|
463
|
+
`,stderr:"",exitCode:0};let A=await Dt(s,i,$),L=A[0]??null;if(A.length===0)return O("refusing to merge unrelated histories");if(L===$)return await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
464
|
+
`,stderr:"",exitCode:0};let G=L===i;if(n.ffOnly&&!G)return O("Not possible to fast-forward, aborting.");if(G&&!n.noFf){let ce=await Ks(s,i,$),Me=await Z(s),Sn=Me?.type==="symbolic"?Me.target:"HEAD";return await Ue(s,Sn,{oldHash:i,newHash:$,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:"pull: Fast-forward"}),Me?.type==="symbolic"&&await Ue(s,"HEAD",{oldHash:i,newHash:$,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:"pull: Fast-forward"}),ce.exitCode===0&&(await t?.hooks?.emitPost("post-merge",{headHash:i,theirsHash:$,strategy:"fast-forward",commitHash:null}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"fast-forward",commitHash:null})),ce}let V=await Z(s),j=V?.type==="symbolic"?be(V.target):"HEAD",I=f||c||"FETCH_HEAD",v={a:"HEAD",b:I},W=await Ur(s,i,$,v),F=await M(s,i),D=await dn(s,W,F.tree,{labels:v,errorExitCode:2,operationName:"merge"});if(!D.ok)return D;if(W.conflicts.length>0){await Y(s,"MERGE_HEAD",$),await Y(s,"ORIG_HEAD",i);let ce=await Vn(s,I,j),Me=Gt({version:2,entries:W.entries}).sort();return ce+=`
|
|
458
465
|
# Conflicts:
|
|
459
|
-
${
|
|
466
|
+
${Me.map(Sn=>`# ${Sn}`).join(`
|
|
460
467
|
`)}
|
|
461
|
-
`,await
|
|
468
|
+
`,await $e(s,"MERGE_MSG",ce),{stdout:`${[...W.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
462
469
|
`)}
|
|
463
|
-
`,stderr:"",exitCode:1}}let K=D.mergedTreeHash,
|
|
470
|
+
`,stderr:"",exitCode:1}}let K=D.mergedTreeHash,ae=await Yt(s,r.env);if(S(ae))return ae;let ee=await Ve(s,r.env);if(S(ee))return ee;let le=await Vn(s,I,j);if(t?.hooks){let ce={message:le,treeHash:K,headHash:i,theirsHash:$},Me=await t.hooks.emitPre("merge-msg",ce);if(Me)return{stdout:"",stderr:Me.message??"",exitCode:1};le=ce.message;let Sn=await t.hooks.emitPre("pre-merge-commit",{mergeMessage:le,treeHash:K,headHash:i,theirsHash:$});if(Sn)return{stdout:"",stderr:Sn.message??"",exitCode:1}}let je=await ft(s,K,[i,$],ae,ee,le);await t?.hooks?.emitPost("post-merge",{headHash:i,theirsHash:$,strategy:"three-way",commitHash:je}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"three-way",commitHash:je});let Jt=V?.type==="symbolic"?V.target:"HEAD",De="pull: Merge made by the 'ort' strategy.";await Ue(s,Jt,{oldHash:i,newHash:je,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:De}),V?.type==="symbolic"&&await Ue(s,"HEAD",{oldHash:i,newHash:je,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:De});let Xr=await Tn(s,F.tree,K);return{stdout:`${W.messages.length>0?`${W.messages.join(`
|
|
464
471
|
`)}
|
|
465
472
|
`:""}Merge made by the 'ort' strategy.
|
|
466
|
-
${Xr}`,stderr:"",exitCode:0}}})}
|
|
467
|
-
`);m.push({name:x,oldHash:
|
|
468
|
-
`);let
|
|
469
|
-
`);let
|
|
470
|
-
`,stderr:"",exitCode:0};if(t?.hooks){let b=await t.hooks.emitPre("pre-push",{remote:i,url:f.url,refs:m.map(E=>({srcRef:E.newHash===J?null:E.name,srcHash:E.newHash===J?null:E.newHash,dstRef:E.name,dstHash:E.oldHash,force:!!E.ok,delete:E.newHash===J}))});if(b)return
|
|
473
|
+
${Xr}`,stderr:"",exitCode:0}}})}ne();Xe();at();me();function If(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[B.string().name("remote").describe("Remote to push to").optional(),B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.remote||"origin",a;try{a=await ur(s,i,r.env)}catch(b){let E=b instanceof Error?b.message:"";if(E.startsWith("network"))return O(E);throw b}if(!a)return O(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,d=n.force,l=await c.advertiseRefs(),u=new Map;for(let b of l)u.set(b.name,b.hash);let m=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return O("--delete requires a ref argument");for(let E of b){let x=E.startsWith("refs/")?E:`refs/heads/${E}`,P=u.get(x)??null;if(!P)return _(`error: unable to delete '${E}': remote ref does not exist
|
|
474
|
+
`);m.push({name:x,oldHash:P,newHash:J,ok:d})}}else if(n.all){let b=await we(s,"refs/heads");for(let E of b){let x=E.name,P=u.get(x)??null;m.push({name:x,oldHash:P,newHash:E.hash,ok:d})}}else if(n.tags){let b=await we(s,"refs/tags");for(let E of b){let x=u.get(E.name)??null;x!==E.hash&&m.push({name:E.name,oldHash:x,newHash:E.hash,ok:d})}}else if(h&&h.length>0)for(let b of h){let E=Zn(b),x=await gh(s,E.src);if(!x)return _(`error: src refspec '${E.src}' does not match any
|
|
475
|
+
`);let P=E.dst.startsWith("refs/")?E.dst:`refs/heads/${E.dst}`,C=u.get(P)??null;m.push({name:P,oldHash:C,newHash:x,ok:d||E.force})}else{let b=await Z(s);if(!b||b.type!=="symbolic")return O("You are not currently on a branch.");let E=b.target,x=await X(s);if(!x)return _(`error: src refspec does not match any
|
|
476
|
+
`);let P=u.get(E)??null;m.push({name:E,oldHash:P,newHash:x,ok:d})}if(m.length===0)return{stdout:`Everything up-to-date
|
|
477
|
+
`,stderr:"",exitCode:0};if(t?.hooks){let b=await t.hooks.emitPre("pre-push",{remote:i,url:f.url,refs:m.map(E=>({srcRef:E.newHash===J?null:E.name,srcHash:E.newHash===J?null:E.newHash,dstRef:E.name,dstHash:E.oldHash,force:!!E.ok,delete:E.newHash===J}))});if(b)return _(b.message??"")}let p=await c.push(m),g=[];g.push(`To ${f.url}
|
|
471
478
|
`);let w=!1;for(let b of p.updates){let E=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name;if(!b.ok)g.push(` ! [rejected] ${E} -> ${E} (${b.error??"failed"})
|
|
472
479
|
`),w=!0;else if(!b.oldHash)g.push(` * [new branch] ${E} -> ${E}
|
|
473
480
|
`);else if(b.newHash===J)g.push(` - [deleted] ${E}
|
|
474
|
-
`);else{let x=z(b.oldHash),
|
|
475
|
-
`)}}if(n["set-upstream"]&&!w){let b=await Z(s);if(b?.type==="symbolic"){let E=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,x=await
|
|
476
|
-
`)}}let k={stdout:"",stderr:g.join(""),exitCode:w?1:0};return w||await t?.hooks?.emitPost("post-push",{remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))}),k}})}async function
|
|
481
|
+
`);else{let x=z(b.oldHash),P=z(b.newHash);g.push(` ${x}..${P} ${E} -> ${E}
|
|
482
|
+
`)}}if(n["set-upstream"]&&!w){let b=await Z(s);if(b?.type==="symbolic"){let E=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,x=await pe(s);x[`branch "${E}"`]={remote:i,merge:`refs/heads/${E}`},await Ye(s,x),g.push(`branch '${E}' set up to track '${i}/${E}'.
|
|
483
|
+
`)}}let k={stdout:"",stderr:g.join(""),exitCode:w?1:0};return w||await t?.hooks?.emitPost("post-push",{remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))}),k}})}async function gh(e,t){if(t.startsWith("refs/"))return N(e,t);let n=await N(e,`refs/heads/${t}`);if(n)return n;let r=await N(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}ne();xe();oe();ne();oe();en();Dn();Oe();async function Ei(e,t){let n=await ge(e,t);if(n.type!=="commit")return null;let r=Wt(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ge(e,r.parents[0]);f.type==="commit"&&(o=Wt(f.content).tree)}let s=await Ne(e,o,r.tree);if(s.length===0)return null;let i=mn(),a=!1,c=[...s].sort((f,d)=>Ce(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=yt({path:f.path,oldContent:d,newContent:l,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
|
|
477
484
|
`)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
|
|
478
|
-
`),a=!0)}}return a?i.hex():null}
|
|
485
|
+
`),a=!0)}}return a?i.hex():null}Ge();me();Oe();Vt();Je();async function wh(e){let t=await Z(e);return t?.type==="symbolic"?be(t.target):"detached HEAD"}function Of(e){return e==="HEAD"?`HEAD is up to date.
|
|
479
486
|
`:`Current branch ${e} is up to date.
|
|
480
|
-
`}async function
|
|
481
|
-
`)}return null}async function
|
|
482
|
-
`,exitCode:128}:null}async function
|
|
487
|
+
`}async function bh(e,t,n){if(!e.workTree)return null;let r=await fe(e,t),o=new Map(ve(n).map(a=>[a.path,a])),s=new Set(await Ze(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=Cs(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
|
|
488
|
+
`)}return null}async function yh(e,t,n,r){if(!e.workTree)return null;let o=await fe(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await Ze(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${Cs(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
|
|
489
|
+
`,exitCode:128}:null}async function Tf(e,t,n){if(!e.workTree)return null;let r=new Map(ve(t).map(i=>[i.path,i])),o=new Set(await Ze(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function Hf(e,t){return`error: The following untracked working tree files would be overwritten by merge:
|
|
483
490
|
${e.map(r=>` ${r}`).join(`
|
|
484
491
|
`)}
|
|
485
492
|
Please move or remove them before you merge.
|
|
@@ -493,7 +500,7 @@ hint: edit the todo list first:
|
|
|
493
500
|
hint:
|
|
494
501
|
hint: git rebase --edit-todo
|
|
495
502
|
hint: git rebase --continue
|
|
496
|
-
`}async function
|
|
503
|
+
`}async function ki(e,t,n,r,o,s){await te(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await te(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await te(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function io(e,t,n,r){let o=await M(e,t),s=await bh(e,o.tree,n);if(s)return s;let i=await sn(e,o.tree,n);return i.success&&(await re(e,{version:2,entries:i.newEntries}),await Te(e,i.worktreeOps)),r!=="detached HEAD"?await Y(e,r,t):await Y(e,"HEAD",t),null}function Af(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[B.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Q.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return xh(s,r.env);if(n.continue)return Ch(s,r.env);if(n.skip)return Ph(s,r.env);let i=n.upstream;if(!i)return O("no upstream configured and no upstream argument given");if(await At(s))return O(`It seems that there is already a rebase-merge directory, and
|
|
497
504
|
I wonder if you are in the middle of another rebase. If that is the
|
|
498
505
|
case, please try
|
|
499
506
|
git rebase (--continue | --abort | --skip)
|
|
@@ -501,23 +508,23 @@ If that is not the case, please
|
|
|
501
508
|
rm -fr ".git/rebase-merge"
|
|
502
509
|
and run me again. I am stopping in case you still have something
|
|
503
510
|
valuable there.
|
|
504
|
-
`);let a=await Ke(s);if(S(a))return a;let c=await Z(s),f=c?.type==="symbolic"?c.target:"detached HEAD",d=c?.type==="symbolic"?
|
|
511
|
+
`);let a=await Ke(s);if(S(a))return a;let c=await Z(s),f=c?.type==="symbolic"?c.target:"detached HEAD",d=c?.type==="symbolic"?be(c.target):"HEAD",l=await He(s,i,`invalid upstream '${i}'`);if(S(l))return l;let u=l.hash,m,h=n.onto;if(h){let v=await He(s,h,`Does not point to a valid commit: '${h}'`);if(S(v))return v;m=v.hash}else m=u;let p=await q(s),g=Gt(p).sort();if(g.length>0)return{stdout:g.map(v=>`${v}: needs merge
|
|
505
512
|
`).join(""),stderr:`error: cannot rebase: You have unstaged changes.
|
|
506
513
|
error: additionally, your index contains uncommitted changes.
|
|
507
514
|
error: Please commit or stash them.
|
|
508
|
-
`,exitCode:1};let w=await M(s,a),k=await fe(s,w.tree);if(s.workTree){let
|
|
515
|
+
`,exitCode:1};let w=await M(s,a),k=await fe(s,w.tree);if(s.workTree){let v=sr(p,k),F=(await Rt(s,p)).some(D=>D.status==="modified"||D.status==="deleted");if(v||F){let D=[];return F&&D.push("error: cannot rebase: You have unstaged changes."),v&&(F?D.push("error: additionally, your index contains uncommitted changes."):D.push("error: cannot rebase: Your index contains uncommitted changes.")),D.push("error: Please commit or stash them."),_(`${D.join(`
|
|
509
516
|
`)}
|
|
510
|
-
`)}}if(t?.hooks){let
|
|
511
|
-
`,exitCode:0})}return{stdout:
|
|
517
|
+
`)}}if(t?.hooks){let v=await t.hooks.emitPre("pre-rebase",{upstream:i,branch:c?.type==="symbolic"?be(c.target):null});if(v)return{stdout:"",stderr:v.message??"",exitCode:1}}let b=await Ka(s,u,a),E=b.right;if(E.length===0){if(m!==a){let v=await io(s,m,p,f);return v||(await ki(s,r.env,a,m,f,i),{stdout:"",stderr:`Successfully rebased and updated ${f}.
|
|
518
|
+
`,exitCode:0})}return{stdout:Of(d),stderr:"",exitCode:0}}let x=[],P=b.left,C=new Set;for(let v of P){let W=await Ei(s,v.hash);W&&C.add(W)}let R=[];if(C.size>0)for(let v of E){let W=await Ei(s,v.hash);W&&C.has(W)?x.push(`warning: skipped previously applied commit ${z(v.hash)}`):R.push(v)}else R.push(...E);let y="";if(x.length>0&&(y=`${x.join(`
|
|
512
519
|
`)}
|
|
513
520
|
hint: use --reapply-cherry-picks to include skipped commits
|
|
514
521
|
hint: Disable this message with "git config set advice.skippedCherryPicks false"
|
|
515
|
-
`),R.length===0){if(m!==a){let
|
|
516
|
-
`,exitCode:0}}let $=R.map(
|
|
517
|
-
`,exitCode:0})}let
|
|
518
|
-
`};if(s&&s===a){let
|
|
519
|
-
`};let
|
|
520
|
-
`);return{conflict:!0,stdout:
|
|
522
|
+
`),R.length===0){if(m!==a){let v=await io(s,m,p,f);if(v)return v.stderr=y+v.stderr,v;await ki(s,r.env,a,m,f,i)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
|
|
523
|
+
`,exitCode:0}}let $=R.map(v=>({hash:v.hash,subject:ie(v.commit.message)})),A=m,L=0;for(let v of $){let W=await M(s,v.hash);if(W.parents.length>1||W.parents.length===0||W.parents[0]!==A)break;A=v.hash,L++}let G=$.splice(0,L);if($.length===0){if(A===a)return{stdout:Of(d),stderr:y,exitCode:0};let v=await io(s,A,p,f);return v?(v.stderr=y+v.stderr,v):(await ki(s,r.env,a,A,f,i),{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
|
|
524
|
+
`,exitCode:0})}let V=await io(s,A,p,"detached HEAD");if(V)return V.stderr=y+V.stderr,V;await de(s,"CHERRY_PICK_HEAD"),await de(s,"REVERT_HEAD"),await he(s,"MERGE_MSG"),await he(s,"MERGE_MODE"),await te(s,r.env,"HEAD",a,A,`rebase (start): checkout ${i}`);let j={headName:f,origHead:a,onto:m,todo:$,done:G,msgnum:L,end:L+$.length};await Wo(s,j),await Y(s,"ORIG_HEAD",a);let I=await xi(s,r.env);return y&&(I.stderr=y+I.stderr),I}})}async function xi(e,t){let n=[],r=[];for(;;){let o=await lt(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 qa(e);let i=await Eh(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await lt(e);a&&(a.todo=[s,...a.todo],await Wo(e,a))}return i.stdout&&r.push(i.stdout),n.push(i.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}i.stdout&&r.push(i.stdout),i.stderr&&n.push(i.stderr)}return kh(e,n,t)}async function Eh(e,t,n){let r=t.hash,o=await M(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await M(e,s):null,a=await X(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
|
|
525
|
+
`};if(s&&s===a){let G=await q(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
|
|
526
|
+
`};let V=await We(e,i.tree),j=await We(e,o.tree),I=new Map(V.map(D=>[D.path,D.hash])),v=new Map;for(let D of j){let K=I.get(D.path);(!K||K!==D.hash)&&v.set(D.path,D.hash)}let W=await Tf(e,G,v);if(W)return await Y(e,"REBASE_HEAD",r),await Ss(e,r,o.author),{conflict:!0,stdout:"",stderr:Hf(W,t),rescheduleCurrent:!0};let F=await sn(e,o.tree,G);return F.success&&(await re(e,{version:2,entries:F.newEntries}),await Te(e,F.worktreeOps)),await gn(e,r),await te(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await M(e,a),f=i?i.tree:null,d=z(r),l=ie(o.message),u={a:"HEAD",b:l?`${d} (${l})`:d},m=await Mt(e,f,c.tree,o.tree,u),h=await q(e),[p,g,w]=await Promise.all([We(e,c.tree),f?We(e,f):Promise.resolve([]),We(e,o.tree)]),k=new Set;for(let G of g)k.add(G.path);for(let G of p)k.add(G.path);for(let G of w)k.add(G.path);let b=h.entries.filter(G=>!k.has(G.path)),E=[...m.entries,...b];E.sort((G,V)=>Ce(G.path,V.path)||G.stage-V.stage);let x={version:2,entries:E},P=E.filter(G=>G.stage===0),C=await Se(e,P),R=new Map(p.map(G=>[G.path,G])),y=new Map;for(let G of P){let V=R.get(G.path);(!V||V.hash!==G.hash)&&y.set(G.path,G.hash)}for(let G of m.conflicts){if(G.reason==="content"||G.reason==="add-add"){y.set(G.path,null);continue}if(G.reason==="delete-modify"){let V=m.entries.filter(v=>v.path===G.path&&v.stage>0),j=V.find(v=>v.stage===2),I=V.find(v=>v.stage===3);I&&!j&&y.set(G.path,I.hash)}}let $=await Tf(e,h,y);if($)return await Y(e,"REBASE_HEAD",r),await Ss(e,r,o.author),{conflict:!0,stdout:"",stderr:Hf($,t),rescheduleCurrent:!0};if(await re(e,x),e.workTree){let G=await kn(e,c.tree,m.resultTree,h);G.success&&await Te(e,G.worktreeOps)}if(m.conflicts.length>0){await Y(e,"REBASE_HEAD",r),await Ss(e,r,o.author),await $e(e,"MERGE_MSG",o.message),await $e(e,"rebase-merge/message",o.message);let G=m.messages.join(`
|
|
527
|
+
`);return{conflict:!0,stdout:G?`${G}
|
|
521
528
|
`:"",stderr:`error: could not apply ${d}... ${t.subject}
|
|
522
529
|
hint: Resolve all conflicts manually, mark them as resolved with
|
|
523
530
|
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
|
|
@@ -525,13 +532,13 @@ hint: You can instead skip this commit: run "git rebase --skip".
|
|
|
525
532
|
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
|
|
526
533
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
527
534
|
Could not apply ${d}... # ${t.subject}
|
|
528
|
-
`}}if(
|
|
529
|
-
`};let
|
|
530
|
-
`;return await
|
|
535
|
+
`}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
|
|
536
|
+
`};let A=await Ve(e,n);if(S(A))return{conflict:!0,stdout:"",stderr:A.stderr};let L=await ft(e,C,[a],o.author,A,o.message);return await te(e,n,"HEAD",a,L,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function kh(e,t,n){let r=await lt(e);if(!r)return O("no rebase in progress");let o=await X(e);if(!o)return O("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Y(e,r.headName,o),await Fe(e,"HEAD",r.headName),await dt(e),await te(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await te(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
|
|
537
|
+
`;return await de(e,"REBASE_HEAD"),await qn(e),await qo(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function xh(e,t){let n=await lt(e);if(!n)return O("no rebase in progress");let r=await X(e),o=n.origHead,s=await M(e,o),i=await q(e),a=await yh(e,s.tree,i,o);if(a)return a;let c=await sn(e,s.tree,i);c.success&&(await re(e,{version:2,entries:c.newEntries}),await Te(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Y(e,n.headName,o),await Fe(e,"HEAD",n.headName),await dt(e)):await gn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await te(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await de(e,"REBASE_HEAD"),await qn(e),await qo(e),{stdout:"",stderr:"",exitCode:0}}async function Ch(e,t){let n="";if(!await lt(e))return O("no rebase in progress");let o=await q(e);if(Pt(o))return _(`error: Committing is not possible because you have unmerged files.
|
|
531
538
|
hint: Fix them up in the work tree, and then use 'git add <file>'
|
|
532
539
|
hint: as appropriate to mark resolution and make a commit.
|
|
533
540
|
fatal: Exiting because of an unresolved conflict.
|
|
534
|
-
`,128);let s=await
|
|
541
|
+
`,128);let s=await N(e,"REBASE_HEAD");if(s){let a=await X(e);if(!a)return O("Cannot read HEAD");let c=await M(e,a),f=ve(o),d=await Se(e,f),l=d!==c.tree,u=await Ee(e,"rebase-merge/message")!==null;if(l&&!u)return _(`error: you have staged changes in your working tree
|
|
535
542
|
If these changes are meant to be squashed into the previous commit, run:
|
|
536
543
|
|
|
537
544
|
git commit --amend
|
|
@@ -544,55 +551,55 @@ In both cases, once you're done, continue with:
|
|
|
544
551
|
|
|
545
552
|
git rebase --continue
|
|
546
553
|
|
|
547
|
-
`);if(
|
|
548
|
-
${
|
|
554
|
+
`);if(l){let m=await M(e,s),h=await N(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=Xt(g)),g||(g=m.message);let w=await Ve(e,t);if(S(w))return w;let k=Ot(g),b=[a],E=await N(e,"MERGE_HEAD");E&&b.push(E);let x=await ft(e,d,b,p.author,w,k);E&&(await de(e,"MERGE_HEAD"),await he(e,"MERGE_MODE"));let P=ie(k);await te(e,t,"HEAD",a,x,`rebase (continue): ${P}`);let C=await wh(e),R=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,y=await Zt(e,c.tree,d,p.author,w,R);n=`${It(C,x,k)}
|
|
555
|
+
${y}`}await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await he(e,"MERGE_MSG"),await he(e,"rebase-merge/message")}let i=await xi(e,t);return n&&(i.stdout=n+i.stdout),i}async function Ph(e,t){if(!await lt(e))return O("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
|
|
549
556
|
fatal: could not discard worktree changes
|
|
550
|
-
`,exitCode:128};let o=await M(e,r),s=await q(e),i=await
|
|
557
|
+
`,exitCode:128};let o=await M(e,r),s=await q(e),i=await sn(e,o.tree,s);return i.success&&(await re(e,{version:2,entries:i.newEntries}),await Te(e,i.worktreeOps)),await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await de(e,"MERGE_HEAD"),await he(e,"MERGE_MSG"),await he(e,"MERGE_MODE"),await he(e,"rebase-merge/message"),xi(e,t)}ne();ue();Ge();me();function Rh(e,t,n,r){return`${z(n)} ${e}@{${t}}: ${r}`}async function ao(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await N(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
|
|
551
558
|
Use '--' to separate paths from revisions, like this:
|
|
552
559
|
'git <command> [<revision>...] -- [<file>...]'
|
|
553
|
-
`,exitCode:128};let s=await ze(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<a;d--){let
|
|
560
|
+
`,exitCode:128};let s=await ze(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<a;d--){let l=s[d];if(!l)continue;let u=s.length-1-d;l.newHash!==J&&(i.push(Rh(t,u,l.newHash,l.message)),c++)}return{stdout:i.length>0?`${i.join(`
|
|
554
561
|
`)}
|
|
555
|
-
`:"",stderr:"",exitCode:0}}function
|
|
556
|
-
`,exitCode:128};let d=T(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(d)?0:1}}return ao(i,c,r.maxCount)}})}
|
|
562
|
+
`:"",stderr:"",exitCode:0}}function vf(e,t){return e.command("reflog",{description:"Manage reflog information",args:[B.string().name("args").variadic().optional()],options:{maxCount:Q.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=s,a=r.args;if(a.length===0)return ao(i,"HEAD",r.maxCount);let c=a[0];if(!c)return ao(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return ao(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
|
|
563
|
+
`,exitCode:128};let d=T(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(d)?0:1}}return ao(i,c,r.maxCount)}})}ne();Xe();Ge();me();function $h(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 Sf(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,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a),f=$h(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(`
|
|
557
564
|
`)}
|
|
558
565
|
`,stderr:"",exitCode:0}}return{stdout:`${f.join(`
|
|
559
566
|
`)}
|
|
560
|
-
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[B.string().name("name").describe("Remote name"),B.string().name("url").describe("Remote URL")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await
|
|
561
|
-
`,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Ye(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await
|
|
562
|
-
`,2)},o=[B.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:[B.string().name("old").describe("Current remote name"),B.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await
|
|
563
|
-
`,2);let d=c[f];return d&&(d.url=s.url),await Ye(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[B.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await
|
|
564
|
-
`,stderr:"",exitCode:0}:
|
|
565
|
-
`,2)}})}async function
|
|
566
|
-
`,2);let s=`remote "${r}"`;if(s in t)return O(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Ye(e,t);let a=`refs/remotes/${n}`,c=await
|
|
567
|
-
`)}
|
|
568
|
-
`}async function
|
|
569
|
-
`:"";return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:i}),{stdout:
|
|
570
|
-
`,exitCode:1};s=nt(s,f)}}return c?(await
|
|
571
|
-
`)}async function Ah(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");let o=await fe(e,r),s=t.map(f=>
|
|
572
|
-
`,exitCode:1};i.push(f)}if(i.length===0)return
|
|
573
|
-
`);for(let f of i){let d=o.get(f);if(d)await rt(e,{path:d.path,hash:d.hash,mode:d.mode});else{let
|
|
574
|
-
`);for(let f of a){let d=o.get(f);if(d)s=ht(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:
|
|
575
|
-
`,exitCode:1};s=nt(s,f);let
|
|
576
|
-
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return O("Needed a single revision");for(let E of o){if(a){let
|
|
577
|
-
`).join(""),stderr:"",exitCode:0}}})}function
|
|
578
|
-
`);if(
|
|
567
|
+
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[B.string().name("name").describe("Remote name"),B.string().name("url").describe("Remote URL")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?_(`error: remote ${s.name} already exists.
|
|
568
|
+
`,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Ye(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Oh(c,s.name),await Ye(a,c),await Th(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
|
|
569
|
+
`,2)},o=[B.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:[B.string().name("old").describe("Current remote name"),B.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a);return Ih(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[B.string().name("name").describe("Remote name"),B.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(!(f in c))return _(`error: No such remote '${s.name}'
|
|
570
|
+
`,2);let d=c[f];return d&&(d.url=s.url),await Ye(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[B.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await U(i.fs,i.cwd,t);if(S(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
|
|
571
|
+
`,stderr:"",exitCode:0}:_(`error: No such remote '${s.name}'
|
|
572
|
+
`,2)}})}async function Ih(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
|
|
573
|
+
`,2);let s=`remote "${r}"`;if(s in t)return O(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Ye(e,t);let a=`refs/remotes/${n}`,c=await we(e,a);for(let f of c){let d=f.name.replace(a,`refs/remotes/${r}`),l=await ze(e,f.name);await Y(e,d,f.hash),await de(e,f.name),l.length>0&&await bn(e,d,l)}return{stdout:"",stderr:"",exitCode:0}}function Oh(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 Th(e,t){let n=`refs/remotes/${t}`,r=await we(e,n);for(let o of r)await de(e,o.name)}ne();xe();oe();ue();Ge();me();nn();Oe();Vt();Je();function Mf(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[B.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return O("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,d=ct(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return Ci(i,o.passthrough,d,m,t)}if(!f&&a.length>0){let m=a[0],h=await Be(i,m);return a.length===1&&h?Df(i,m,"mixed",r.env,t):h?Ci(i,a.slice(1),d,m,t):Ci(i,a,d,void 0,t)}let l=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return Df(i,u,l,r.env,t)}})}async function Ci(e,t,n,r,o){if(o?.hooks){let d=await o.hooks.emitPre("pre-reset",{mode:"paths",target:r??null});if(d)return{stdout:"",stderr:d.message??"",exitCode:1}}let s=null;if(r){let d=await Be(e,r);if(!d)return Lt(r);let l=await _e(e,d);s=(await M(e,l)).tree}else{let d=await X(e);d&&(s=(await M(e,d)).tree)}let i=await fe(e,s??null),a=await q(e);if(t.some(Un)){let d=t.map(u=>Le(u,n)),l=new Set;for(let[u]of i)l.add(u);for(let u of a.entries)l.add(u.path);for(let u of l){if(!ye(d,u))continue;let m=i.get(u);m?a=ht(a,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:Pe()}):a=nt(a,u)}}else for(let d of t){let l=i.get(d);if(l)a=ht(a,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Pe()});else if(a.entries.some(m=>m.path===d))a=nt(a,d);else if(!(e.workTree&&await e.fs.exists(T(e.workTree,d))))return Lt(d)}await re(e,a);let f={stdout:await jf(e,a),stderr:"",exitCode:0};return await o?.hooks?.emitPost("post-reset",{mode:"paths",targetHash:null}),f}async function jf(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await Rt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
|
|
574
|
+
`)}
|
|
575
|
+
`}async function Df(e,t,n,r,o){if(o?.hooks){let u=await o.hooks.emitPre("pre-reset",{mode:n,target:t});if(u)return{stdout:"",stderr:u.message??"",exitCode:1}}let s=await Be(e,t);if(!s)return Lt(t);let i=await _e(e,s),a=await M(e,i);if(n==="soft"){let u=await N(e,"MERGE_HEAD"),m=await q(e);if(u||Pt(m))return O("Cannot do a soft reset in the middle of a merge.")}let c=await X(e),f=await Z(e);f?.type==="symbolic"?await Y(e,f.target,i):await Y(e,"HEAD",i);let d=`reset: moving to ${t}`;if(f?.type==="symbolic"&&c!==i?await te(e,r,f.target,c,i,d,!0):(f?.type==="symbolic"||c!==i)&&await te(e,r,"HEAD",c,i,d),await qn(e),n==="mixed"){let u=await We(e,a.tree),m=os(u.map(p=>({path:p.path,mode:parseInt(p.mode,8),hash:p.hash,stage:0,stat:Pe()})));await re(e,m);let h=await jf(e,m);if(h)return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:i}),{stdout:h,stderr:"",exitCode:0}}if(n==="hard"){let u=qe(e);if(u)return u;let m=await q(e),h=await sn(e,a.tree,m);await re(e,{version:2,entries:h.newEntries}),await Te(e,h.worktreeOps)}let l=n==="hard"?`HEAD is now at ${z(i)} ${ie(a.message)}
|
|
576
|
+
`:"";return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:i}),{stdout:l,stderr:"",exitCode:0}}ne();xe();oe();me();Oe();Je();function Gf(e,t){e.command("restore",{description:"Restore working tree files",args:[B.string().name("pathspec").variadic().optional()],options:{source:Q.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return O("you must specify path(s) to restore");if(n.ours&&n.theirs)return O("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,d=ct(i,r.cwd);if(n.ours||n.theirs)return n.source?O("cannot specify both --source and --ours/--theirs"):c?O("cannot use --ours/--theirs with --staged"):Gs(i,a,d,n.theirs?3:2,{deleteOnMissing:!0});let l=null;if(n.source){let u=await He(i,n.source,`could not resolve '${n.source}'`);if(S(u))return u;l=u.commit.tree}else if(c){let u=await X(i);u&&(l=(await M(i,u)).tree)}return c&&f?vh(i,a,d,l):c?Hh(i,a,d,l):l?Ah(i,a,d,l):js(i,a,d)}})}async function Hh(e,t,n,r){let o=await fe(e,r),s=await q(e),i=t.map(f=>Le(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!ye(i,f))continue;c=!0;let d=o.get(f);if(d)s=ht(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:Pe()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
577
|
+
`,exitCode:1};s=nt(s,f)}}return c?(await re(e,s),{stdout:"",stderr:"",exitCode:0}):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
578
|
+
`)}async function Ah(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");let o=await fe(e,r),s=t.map(f=>Le(f,n)),i=[],a=await q(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(l=>l.path===f&&l.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
579
|
+
`,exitCode:1};i.push(f)}if(i.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
580
|
+
`);for(let f of i){let d=o.get(f);if(d)await rt(e,{path:d.path,hash:d.hash,mode:d.mode});else{let l=`${e.workTree}/${f}`;await e.fs.exists(l)&&await e.fs.rm(l)}}return{stdout:"",stderr:"",exitCode:0}}async function vh(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");let o=await fe(e,r),s=await q(e),i=t.map(f=>Le(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)ye(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
581
|
+
`);for(let f of a){let d=o.get(f);if(d)s=ht(s,{path:d.path,mode:parseInt(d.mode,8),hash:d.hash,stage:0,stat:Pe()}),await rt(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=nt(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await re(e,s),{stdout:"",stderr:"",exitCode:0}}ne();ue();me();nn();function Lf(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[B.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(E=>E!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],d=n["git-dir"],l=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||d||l||u||m||h,g=await U(r.fs,r.cwd,t);if(S(g))return g;let w=g,k=[];if(f){if(!w.workTree)return O("this operation must be run in a work tree");k.push(w.workTree)}if(d&&k.push(w.gitDir),l&&k.push(w.workTree?"true":"false"),u&&k.push(w.workTree?"false":"true"),m){if(!w.workTree)return O("this operation must be run in a work tree");let E=st(w.workTree,r.cwd);k.push(E===""?"":`${E}/`)}if(h){if(!w.workTree)return O("this operation must be run in a work tree");let E=st(r.cwd,w.workTree);k.push(E===""?"":`${E}/`)}if(p&&o.length===0)return{stdout:k.map(x=>`${x}
|
|
583
|
+
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return O("Needed a single revision");for(let E of o){if(a){let P=await Sh(w,E);if(P===null)return Pi(E,s);k.push(P);continue}if(c){let P=await Dh(w,E);if(P===null)return Pi(E,s);k.push(P);continue}let x=await Be(w,E);if(!x)return Pi(E,s);k.push(i?z(x):x)}return{stdout:k.map(E=>`${E}
|
|
584
|
+
`).join(""),stderr:"",exitCode:0}}})}function Pi(e,t){return t?O("Needed a single revision"):Lt(e)}async function Sh(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 Be(e,t)?t:null}async function Dh(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Be(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 N(e,o))return o}return t}ne();xe();oe();Ge();me();Oe();function _f(e,t){e.command("revert",{description:"Revert some existing commits",args:[B.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:Q.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let W=await t.hooks.emitPre("pre-revert",{mode:"abort",commit:null});if(W)return{stdout:"",stderr:W.message??"",exitCode:1}}let v=await Mh(s,r.env);return v.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"abort",commitHash:null,hadConflicts:!1}),v}if(n.continue){if(t?.hooks){let W=await t.hooks.emitPre("pre-revert",{mode:"continue",commit:null});if(W)return{stdout:"",stderr:W.message??"",exitCode:1}}let v=await jh(s,r.env);return v.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"continue",commitHash:null,hadConflicts:!1}),v}let i=n.commit;if(!i)return O("you must specify a commit to revert");if(t?.hooks){let v=await t.hooks.emitPre("pre-revert",{mode:"revert",commit:i});if(v)return{stdout:"",stderr:v.message??"",exitCode:1}}let a=await He(s,i);if(S(a))return a;let c=a.hash,f=a.commit,d=await Ke(s);if(S(d))return d;let l=await q(s),u=on(l,"Reverting",`fatal: revert failed
|
|
585
|
+
`);if(u)return u;let m=await M(s,d);if(s.workTree){let v=await fe(s,m.tree);if(sr(l,v))return _(`error: your local changes would be overwritten by revert.
|
|
579
586
|
hint: commit your changes or stash them to proceed.
|
|
580
587
|
fatal: revert failed
|
|
581
|
-
`,128)}let h=n.mainline,p;if(f.parents.length>1){if(h===void 0)return
|
|
588
|
+
`,128)}let h=n.mainline,p;if(f.parents.length>1){if(h===void 0)return _(`error: commit ${c} is a merge but no -m option was given.
|
|
582
589
|
fatal: revert failed
|
|
583
|
-
`,128);if(h<1||h>f.parents.length)return
|
|
590
|
+
`,128);if(h<1||h>f.parents.length)return _(`error: commit ${c} does not have parent ${h}
|
|
584
591
|
fatal: revert failed
|
|
585
|
-
`,128);let
|
|
592
|
+
`,128);let v=f.parents[h-1];p=(await M(s,v)).tree}else if(f.parents.length===0)p=await Se(s,[]);else{let v=f.parents[0];p=(await M(s,v)).tree}let g=z(c),w=ie(f.message),k=Gh(f,c,h),b={a:"HEAD",b:w?`parent of ${g} (${w})`:`parent of ${g}`},E=await Mt(s,f.tree,m.tree,p,b);if(E.conflicts.length===0&&E.resultTree===m.tree){let v=E.messages.length>0?`${E.messages.join(`
|
|
586
593
|
`)}
|
|
587
|
-
`:"",W=await et(s,{fromCommit:!0}),F=await
|
|
594
|
+
`:"",W=await et(s,{fromCommit:!0}),F=await N(s,"CHERRY_PICK_HEAD");return{stdout:`${v}${W}`,stderr:F?`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
588
595
|
If you wish to commit it anyway, use:
|
|
589
596
|
|
|
590
597
|
git commit --allow-empty
|
|
591
598
|
|
|
592
599
|
Otherwise, please use 'git cherry-pick --skip'
|
|
593
|
-
`:"",exitCode:1}}let x=await dn(s,E,m.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!x.ok)return x;if(E.conflicts.length>0){await
|
|
594
|
-
`);return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:
|
|
595
|
-
`:"",stderr:`error: could not revert ${g}... ${
|
|
600
|
+
`:"",exitCode:1}}let x=await dn(s,E,m.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!x.ok)return x;if(E.conflicts.length>0){await Y(s,"REVERT_HEAD",c),await Y(s,"ORIG_HEAD",d),await $e(s,"MERGE_MSG",k);let v=E.messages.join(`
|
|
601
|
+
`);return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:v?`${v}
|
|
602
|
+
`:"",stderr:`error: could not revert ${g}... ${ie(f.message)}
|
|
596
603
|
hint: After resolving the conflicts, mark them with
|
|
597
604
|
hint: "git add/rm <pathspec>", then run
|
|
598
605
|
hint: "git revert --continue".
|
|
@@ -600,105 +607,106 @@ hint: You can instead skip this commit with "git revert --skip".
|
|
|
600
607
|
hint: To abort and get back to the state before "git revert",
|
|
601
608
|
hint: run "git revert --abort".
|
|
602
609
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
603
|
-
`,exitCode:1}}if(n["no-commit"])return await
|
|
610
|
+
`,exitCode:1}}if(n["no-commit"])return await Y(s,"REVERT_HEAD",c),await $e(s,"MERGE_MSG",k),{stdout:"",stderr:"",exitCode:0};let P=x.mergedTreeHash,C=await Yt(s,r.env);if(S(C))return C;let R=await Ve(s,r.env);if(S(R))return R;let y=await ft(s,P,[d],C,R,k);await Ht(s),await _t(s);let $=await Z(s),A=ie(k),L=$?.type==="symbolic"?$.target:"HEAD";await te(s,r.env,L,d,y,`revert: ${A}`,$?.type==="symbolic");let G=$?.type==="symbolic"?be($.target):"detached HEAD",V=await Zt(s,m.tree,P,C,R,C.timestamp!==R.timestamp||C.timezone!==R.timezone),j=It(G,y,k),I=E.messages.length>0?`${E.messages.join(`
|
|
604
611
|
`)}
|
|
605
612
|
`:"";return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:y,hadConflicts:!1}),{stdout:`${I}${j}
|
|
606
|
-
${
|
|
613
|
+
${V}`,stderr:"",exitCode:0}}})}async function Mh(e,t){return await N(e,"REVERT_HEAD")?xn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
|
|
607
614
|
fatal: revert failed
|
|
608
|
-
`,128),operationName:"revert",clearState:
|
|
615
|
+
`,128),operationName:"revert",clearState:Ht,origHeadAsTargetRev:!0}):await N(e,"CHERRY_PICK_HEAD")?xn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
|
|
609
616
|
fatal: revert failed
|
|
610
|
-
`,128),operationName:"revert",clearState:
|
|
617
|
+
`,128),operationName:"revert",clearState:_t,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
|
|
611
618
|
fatal: revert failed
|
|
612
|
-
`,128)}async function
|
|
619
|
+
`,128)}async function jh(e,t){if(!await N(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
|
|
613
620
|
fatal: revert failed
|
|
614
|
-
`,128);let r=await q(e),o=
|
|
615
|
-
|
|
621
|
+
`,128);let r=await q(e),o=on(r,"Committing");if(o)return o;let s=await Ee(e,"MERGE_MSG");if(!s)return _(`Aborting commit due to empty commit message.
|
|
622
|
+
`,1);let i=ve(r),a=await Se(e,i),c=await Ke(e);if(S(c))return c;let f=await M(e,c),d=await Yt(e,t);if(S(d))return d;let l=await Ve(e,t);if(S(l))return l;let u=await N(e,"CHERRY_PICK_HEAD");u&&(d=(await M(e,u)).author);let m=Ot(s),h=await ft(e,a,[c],d,l,m);await Ht(e),await _t(e);let p=await Z(e),g=ie(m),w=p?.type==="symbolic"?p.target:"HEAD";await te(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let k=p?.type==="symbolic"?be(p.target):"detached HEAD",b=await Zt(e,f.tree,a,d,l,d.timestamp!==l.timestamp||d.timezone!==l.timezone);return{stdout:`${It(k,h,s)}
|
|
623
|
+
${b}`,stderr:"",exitCode:0}}function Gh(e,t,n){let r=ie(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
|
|
616
624
|
|
|
617
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];a+=`, reversing
|
|
618
626
|
changes made to ${c}`}return a+=`.
|
|
619
|
-
`,a}
|
|
627
|
+
`,a}ne();xe();oe();ue();me();Gn();Oe();function Nf(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[B.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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=qe(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,d=n.recursive,l=n.force;if(t?.hooks){let w=await t.hooks.emitPre("pre-rm",{paths:c,cached:f,recursive:d,force:l});if(w)return{stdout:"",stderr:w.message??"",exitCode:1}}let u=await q(s),m=[],h=ct(s,r.cwd);for(let w of c){if(Un(w)){let x=[Le(w,h)],P=u.entries.filter(C=>ye(x,C.path));if(P.length===0)return O(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path);continue}let k=xt(r.cwd,w),b=st(a,k);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return O(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(k)&&!(await ot(r.fs,k)).isSymbolicLink&&(await ot(r.fs,k)).isDirectory){if(!d)return O(`not removing '${b}' recursively without -r`);let x=b===""?"":`${b}/`,P=u.entries.filter(C=>x===""||C.path.startsWith(x));if(P.length===0)return O(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path)}else{if(!u.entries.some(P=>P.path===b))return O(`pathspec '${w}' did not match any files`);m.push(b)}}if(!l){let w=await Lh(s,u,m,f);if(w)return w}if(n.dryRun){let w=m.map(b=>`rm '${b}'`);return{stdout:w.length>0?`${w.join(`
|
|
620
628
|
`)}
|
|
621
|
-
`:"",stderr:"",exitCode:0}}let p=[];for(let w of m){if(
|
|
629
|
+
`:"",stderr:"",exitCode:0}}let p=[];for(let w of m){if(u=nt(u,w),!f){let k=T(a,w);await ot(r.fs,k).then(()=>!0).catch(()=>!1)&&await r.fs.rm(k)}p.push(`rm '${w}'`)}await re(s,u);let g=p.length>0?`${p.join(`
|
|
622
630
|
`)}
|
|
623
|
-
`:"";return await t?.hooks?.emitPost("post-rm",{removedPaths:m,cached:f}),{stdout:g,stderr:"",exitCode:0}}})}async function
|
|
624
|
-
`),d=i.length===1?"the following file has":"the following files have";return
|
|
631
|
+
`:"";return await t?.hooks?.emitPost("post-rm",{removedPaths:m,cached:f}),{stdout:g,stderr:"",exitCode:0}}})}async function Lh(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await M(e,o),d=await We(e,f.tree);for(let l of d)s.set(l.path,l.hash)}let i=[],a=[],c=[];for(let f of n){let d=t.entries.find(h=>h.path===f&&h.stage===0);if(!d)continue;let u=s.get(f)!==d.hash,m=!1;if(e.workTree){let h=T(e.workTree,f),p=!1;try{await ot(e.fs,h),p=!0}catch{p=!1}p&&(m=await yn(e.fs,h)!==d.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(l=>` ${l}`).join(`
|
|
632
|
+
`),d=i.length===1?"the following file has":"the following files have";return _(`error: ${d} staged content different from both the
|
|
625
633
|
file and the HEAD:
|
|
626
634
|
${f}
|
|
627
635
|
(use -f to force removal)
|
|
628
|
-
`)}if(a.length>0){let f=a.map(
|
|
629
|
-
`),d=a.length===1?"the following file has":"the following files have";return
|
|
636
|
+
`)}if(a.length>0){let f=a.map(l=>` ${l}`).join(`
|
|
637
|
+
`),d=a.length===1?"the following file has":"the following files have";return _(`error: ${d} changes staged in the index:
|
|
630
638
|
${f}
|
|
631
639
|
(use --cached to keep the file, or -f to force removal)
|
|
632
|
-
`)}if(c.length>0){let f=c.map(
|
|
633
|
-
`),d=c.length===1?"the following file has":"the following files have";return
|
|
640
|
+
`)}if(c.length>0){let f=c.map(l=>` ${l}`).join(`
|
|
641
|
+
`),d=c.length===1?"the following file has":"the following files have";return _(`error: ${d} local modifications:
|
|
634
642
|
${f}
|
|
635
643
|
(use --cached to keep the file, or -f to force removal)
|
|
636
|
-
`)}return null}
|
|
637
|
-
`))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await M(e,n.parents[0])).tree:null,i=await
|
|
644
|
+
`)}return null}ne();oe();nn();gs();ue();Oe();var Ri=new TextDecoder;function Ff(e,t){e.command("show",{description:"Show various types of objects",args:[B.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.object[0]??"HEAD",c=Ea(a);if(c)return _h(s,c.rev,c.path);if(a==="HEAD"){let l=await Ke(s);if(S(l))return l}let f=await $t(s,a,`bad object '${a}'`);if(S(f))return f;let d=await ge(s,f);switch(d.type){case"commit":{let l=await M(s,f);return{stdout:await Uf(s,f,l),stderr:"",exitCode:0}}case"tag":{let l=await ua(s,f);return{stdout:await Nh(s,l),stderr:"",exitCode:0}}case"tree":{let l=En(d.content);return{stdout:Bf(l),stderr:"",exitCode:0}}case"blob":return{stdout:Ri.decode(d.content),stderr:"",exitCode:0}}}})}async function _h(e,t,n){let r=await He(e,t);if(S(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await fe(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let d=T(e.workTree,s);await e.fs.exists(d)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return O(f)}let c=await ge(e,a.hash);if(c.type==="blob")return{stdout:Ri.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=En(c.content);return{stdout:Bf(f),stderr:"",exitCode:0}}return{stdout:Ri.decode(c.content),stderr:"",exitCode:0}}async function Uf(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(i=>z(i)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${St(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,i=await Ne(e,s,n.tree),{remaining:a,renames:c}=await Qe(e,i),f=await Bh(e,a,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await Wh(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
|
|
638
646
|
`)}
|
|
639
|
-
`}async function
|
|
640
|
-
`))n.push(` ${o}`);if(t.objectType==="commit"){let o=await M(e,t.object),s=await
|
|
647
|
+
`}async function Nh(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${St(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 Uf(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
|
|
641
649
|
`)}
|
|
642
|
-
`}function
|
|
650
|
+
`}function Bf(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(`
|
|
643
651
|
`)}
|
|
644
|
-
`:""}async function Fh(e,t){let n=t.oldHash?await
|
|
645
|
-
`,
|
|
646
|
-
`,ee=
|
|
652
|
+
`:""}async function Fh(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return yt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function Uh(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return yt({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 Bh(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await Uh(e,s.entry):o+=await Fh(e,s.entry);return o}async function Wh(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await M(e,a);return fe(e,c.tree)})),r=await fe(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(l=>(l.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await qh(e,a,n,r);return i}async function qh(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(u=>u?.hash??null),f=s.map(u=>u?.mode??null),d=await Promise.all(c.map(async u=>u?await se(e,u):"")),l=i?await se(e,i):"";return Qs({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:i,resultMode:a,resultContent:l})}ne();xe();oe();me();ne();ln();xe();oe();en();ue();Ge();me();Oe();Vt();Je();var Ft="refs/stash";function Ii(e,t){return Ce(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Wf(e){let t=await ze(e,Ft),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 hr(e,t){let n=await ze(e,Ft);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 qf(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await M(e,s),a=await q(e),c=ve(a),f=await Se(e,c),d=await Ne(e,i.tree,f),l=new Map(c.map(D=>[D.path,D])),u=await Ze(e,o,"",{skipIgnore:!0}),m=!1;for(let D of u){let K=l.get(D);if(!K)continue;let ae=T(o,D),ee=await e.fs.readFileBuffer(ae);if(await pt("blob",ee)!==K.hash){m=!0;break}}if(!m)for(let[D]of l){let K=T(o,D);if(!await e.fs.exists(K)){m=!0;break}}let h=[];if(r?.includeUntracked){let D=await Ze(e,o,"");for(let K of D)l.has(K)||h.push(K)}if(d.length===0&&!m&&h.length===0)return null;let p=await ns(e,t),g=await br(e,t),w=await Z(e),k=w?.type==="symbolic"?be(w.target):"(no branch)",b=z(s),E=ie(i.message),x=`index on ${k}: ${b} ${E}
|
|
653
|
+
`,P=qt({type:"commit",tree:f,parents:[s],author:p,committer:g,message:x}),C=await Re(e,"commit",P),R=await fe(e,i.tree),y=[],$=new Set;for(let D of u){let K=l.get(D),ae=R.get(D);if(!K&&!ae)continue;let ee=T(o,D),le=await e.fs.readFileBuffer(ee),je=await Re(e,"blob",le),Jt=K?K.mode:parseInt(ae?.mode??"100644",8);y.push({path:D,mode:Jt,hash:je,stage:0,stat:Pe()}),$.add(D)}for(let[D,K]of l)$.has(D)||R.has(D)||y.push({path:D,mode:K.mode,hash:K.hash,stage:0,stat:Pe()});let A=await Se(e,y),L=null;if(r?.includeUntracked){let D=[];for(let le of h){let je=T(o,le),Jt=await e.fs.readFileBuffer(je),De=await Re(e,"blob",Jt);D.push({path:le,mode:33188,hash:De,stage:0,stat:Pe()})}let K=await Se(e,D),ae=`untracked files on ${k}: ${b} ${E}
|
|
654
|
+
`,ee=qt({type:"commit",tree:K,parents:[],author:p,committer:g,message:ae});L=await Re(e,"commit",ee)}let G=n?`On ${k}: ${n}`:`WIP on ${k}: ${b} ${E}`,V=[s,C];L&&V.push(L);let j=qt({type:"commit",tree:A,parents:V,author:p,committer:g,message:G}),I=await Re(e,"commit",j),v=await hr(e,0)??J;await Ue(e,Ft,{oldHash:v,newHash:I,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:G.trimEnd()}),await Y(e,Ft,I);let W=await sn(e,i.tree,a);await re(e,{version:2,entries:W.newEntries}),await Te(e,W.worktreeOps),(await Z(e))?.type==="symbolic"&&await te(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let D of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await de(e,D);for(let D of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let K=T(e.gitDir,D);await e.fs.exists(K)&&await e.fs.rm(K)}if(h.length>0)for(let D of h){if(R.has(D))continue;let K=T(o,D);await e.fs.exists(K)&&(await e.fs.rm(K),await Nn(e.fs,Ut(K),o))}return I}async function $i(e,t){let n=e.workTree,r=await M(e,t),o=await We(e,r.tree),s=[];for(let i of o){let a=T(n,i.path);await e.fs.exists(a)?s.push(i.path):await rt(e,i)}return s.length>0?(s.sort(Ii),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
|
|
647
655
|
`)}
|
|
648
656
|
error: could not restore untracked files from stash
|
|
649
|
-
`,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function
|
|
650
|
-
`,exitCode:128};let n=await
|
|
657
|
+
`,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Oi(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
|
|
658
|
+
`,exitCode:128};let n=await hr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
|
|
651
659
|
`,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
|
|
652
|
-
`,exitCode:1};let o=await q(e),s=
|
|
660
|
+
`,exitCode:1};let o=await q(e),s=Gt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(R=>`${R}: needs merge`).join(`
|
|
653
661
|
`)}
|
|
654
662
|
`,stderr:`error: could not write index
|
|
655
663
|
`,exitCode:1};let i=await M(e,n),a=i.parents[0];if(!a)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
|
|
656
|
-
`,exitCode:1};let c=await M(e,a),f=i.parents[2],d=ve(o),
|
|
664
|
+
`,exitCode:1};let c=await M(e,a),f=i.parents[2],d=ve(o),l=await Se(e,d),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let C=await $i(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 Mt(e,c.tree,l,i.tree,u),h=await fe(e,l),p=await fe(e,m.resultTree),g=[];for(let[C,R]of p){let y=h.get(C);(!y||y.hash!==R.hash)&&g.push({path:C,type:"checkout",hash:R.hash,mode:parseInt(R.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])),k=[],b=[];for(let C of g){let R=w.get(C.path),y=T(e.workTree,C.path);if(R){if(!await e.fs.exists(y))continue;let $=await e.fs.readFileBuffer(y);await pt("blob",$)!==R.hash&&k.push(C.path)}else C.type==="checkout"&&await e.fs.exists(y)&&b.push(C.path)}if(k.length>0||b.length>0){k.sort(Ii),b.sort(Ii);let C="";if(k.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
|
|
657
665
|
${k.map(R=>` ${R}`).join(`
|
|
658
666
|
`)}
|
|
659
667
|
Please commit your changes or stash them before you merge.
|
|
660
|
-
`),b.length>0&&(
|
|
668
|
+
`),b.length>0&&(C+=`error: The following untracked working tree files would be overwritten by merge:
|
|
661
669
|
${b.map(R=>` ${R}`).join(`
|
|
662
670
|
`)}
|
|
663
671
|
Please move or remove them before you merge.
|
|
664
|
-
`),
|
|
665
|
-
`,f){let R=await
|
|
666
|
-
`);let s=await q(e),i=
|
|
672
|
+
`),C+=`Aborting
|
|
673
|
+
`,f){let R=await $i(e,f);R.ok||(C+=R.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await Te(e,g);let E=new Set(m.conflicts.map(C=>C.path)),x=new Set;for(let C of m.entries)C.stage>0&&x.add(C.path);let P=E.size>0;if(P){let C=[];for(let[R,y]of p){if(E.has(R)||x.has(R))continue;let $=w.get(R);C.push({path:R,mode:parseInt(y.mode,8),hash:y.hash,stage:0,stat:$?.stat??Pe()})}for(let R of m.entries)R.stage>0&&C.push(R);C.sort((R,y)=>Ce(R.path,y.path)||R.stage-y.stage),await re(e,{version:2,entries:C})}else{let C=[...o.entries],R=new Set(C.map(y=>y.path));for(let[y,$]of p)h.has(y)||R.has(y)||C.push({path:y,mode:parseInt($.mode,8),hash:$.hash,stage:0,stat:Pe()});C.sort((y,$)=>Ce(y.path,$.path)||y.stage-$.stage),await re(e,{version:2,entries:C})}if(f){let C=await $i(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:P,messages:m.messages}}async function Ti(e,t=0){let n=await ze(e,Ft);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 de(e,Ft),await $r(e,Ft);else{await bn(e,Ft,n);let o=n[n.length-1];o&&await Y(e,Ft,o.newHash)}return null}async function Kf(e){await de(e,Ft),await $r(e,Ft)}Oe();function co(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 Kh(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return yt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function An(e,t,n){return e?.hooks?e.hooks.emitPre("pre-stash",{action:t,ref:n}):null}async function vn(e,t,n){await e?.hooks?.emitPost("post-stash",{action:t,ok:n})}function Vf(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Q.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=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"push",null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await zf(s,o.env,r.message,r["include-untracked"]);return await vn(t,"push",a.exitCode===0),a}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Q.string().alias("m").describe("Stash message"),"include-untracked":H().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"push",null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await zf(s,o.env,r.message,r["include-untracked"]);return await vn(t,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"pop",r.stash??null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await zh(s,r.stash);return await vn(t,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"apply",r.stash??null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Vh(s,r.stash);return await vn(t,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"list",null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Yh(s);return await vn(t,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"drop",r.stash??null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Xh(s,r.stash);return await vn(t,"drop",a.exitCode===0),a}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"show",r.stash??null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Zh(s,r.stash);return await vn(t,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let i=await An(t,"clear",null);if(i)return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Jh(s);return await vn(t,"clear",a.exitCode===0),a}})}async function zf(e,t,n,r){if(!await X(e))return _(`You do not have the initial commit yet
|
|
674
|
+
`);let s=await q(e),i=Gt(s).sort();if(i.length>0)return{stdout:`${i.map(d=>`${d}: needs merge`).join(`
|
|
667
675
|
`)}
|
|
668
676
|
`,stderr:`error: could not write index
|
|
669
|
-
`,exitCode:1};let a;try{a=await
|
|
677
|
+
`,exitCode:1};let a;try{a=await qf(e,t,n,{includeUntracked:r})}catch(d){return O(d.message)}return a?{stdout:`Saved working directory and index state ${(await M(e,a)).message.trim()}
|
|
670
678
|
`,stderr:"",exitCode:0}:{stdout:`No local changes to save
|
|
671
|
-
`,stderr:"",exitCode:0}}async function zh(e,t){let n=co(t);if(n<0)return
|
|
679
|
+
`,stderr:"",exitCode:0}}async function zh(e,t){let n=co(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await hr(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Oi(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
|
|
672
680
|
`)}
|
|
673
681
|
`:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
|
|
674
682
|
`,stderr:o.stderr,exitCode:o.exitCode};let d=await et(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
|
|
675
683
|
`,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
|
|
676
684
|
`)}
|
|
677
685
|
`:"",d=await et(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
|
|
678
|
-
`,stderr:"",exitCode:1}}let s=await
|
|
686
|
+
`,stderr:"",exitCode:1}}let s=await Ti(e,n);if(s)return _(s);let i=o.messages.length>0?`${o.messages.join(`
|
|
679
687
|
`)}
|
|
680
688
|
`:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await et(e);return{stdout:`${i}${c}Dropped ${a} (${r})
|
|
681
|
-
`,stderr:"",exitCode:0}}async function Vh(e,t){let n=co(t);if(n<0)return
|
|
689
|
+
`,stderr:"",exitCode:0}}async function Vh(e,t){let n=co(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Oi(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
|
|
682
690
|
`)}
|
|
683
691
|
`:"",c=r.stdout;return c||(c=await et(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
|
|
684
692
|
`)}
|
|
685
|
-
`:"",s=await et(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Yh(e){let t=await
|
|
693
|
+
`:"",s=await et(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Yh(e){let t=await Wf(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
|
|
686
694
|
`)}
|
|
687
|
-
`,stderr:"",exitCode:0}}async function Xh(e,t){let n=co(t);if(n<0)return
|
|
688
|
-
`,stderr:"",exitCode:0}}async function Zh(e,t){let n=co(t);if(n<0)return
|
|
695
|
+
`,stderr:"",exitCode:0}}async function Xh(e,t){let n=co(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await hr(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Ti(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
|
|
696
|
+
`,stderr:"",exitCode:0}}async function Zh(e,t){let n=co(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await hr(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await M(e,r),s=o.parents[0];if(!s)return _("error: invalid stash commit (no parent)");let i=await M(e,s),a=await Ne(e,i.tree,o.tree),c="";for(let f of a)c+=await Kh(e,f);return{stdout:c,stderr:"",exitCode:0}}async function Jh(e){return await Kf(e),{stdout:"",stderr:"",exitCode:0}}ne();xe();me();Je();function Yf(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 U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await et(s),stderr:"",exitCode:0};let i=await Z(s),a=await X(s),c;i&&i.type==="symbolic"?c=be(i.target):c="HEAD detached";let f=await q(s),d=zo(f),l=await Ko(s,a,f,d),u=await Rt(s,f),m=[],h=[];for(let k of u)k.status==="untracked"?h.push(k.path):m.push({path:k.path,status:k.status});m.sort((k,b)=>Ce(k.path,b.path));let p=new Set(f.entries.map(k=>k.path)),g=Vo(h,p);return{stdout:np(c,l,m,d,g,n.branch),stderr:"",exitCode:0}}})}var Qh={"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 ep(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function tp(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function np(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(u=>[u.path,u])),c=new Map(t.map(u=>[u.path,u])),f=new Map(n.map(u=>[u.path,u])),d=new Set;for(let u of r)d.add(u.path);for(let u of t)d.add(u.path);for(let u of n)d.add(u.path);let l=[...d].sort();for(let u of l){let m=a.get(u);if(m){let k=Qh[m.status]??"UU";i.push(`${k} ${Vr(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?ep(h.status):" ",w=p?tp(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let k=h.displayPath.indexOf(" -> "),b=h.displayPath.slice(0,k),E=h.displayPath.slice(k+4);i.push(`${g}${w} ${Vr(b)} -> ${Vr(E)}`)}else i.push(`${g}${w} ${Vr(u)}`)}for(let u of o)i.push(`?? ${Vr(u)}`);return i.length===0?"":`${i.join(`
|
|
689
697
|
`)}
|
|
690
|
-
`}function Vr(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}
|
|
691
|
-
Consider "git cherry-pick --quit" or "git worktree add".`):await
|
|
692
|
-
Consider "git merge --quit" or "git worktree add".`):await
|
|
693
|
-
Consider "git revert --quit" or "git worktree add".`):await
|
|
694
|
-
Consider "git rebase --quit" or "git worktree add".`):null}async function sp(e,t,n){let r=await Yr(e);if(r)return r;let o=await Ms(e);return o?
|
|
695
|
-
${
|
|
698
|
+
`}function Vr(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}ne();Xe();xe();oe();Ge();me();Oe();Vt();function rp(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??J}function Zf(e,t){e.command("switch",{description:"Switch branches",args:[B.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:Q.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Q.string().alias("C").describe("Create/reset and switch to a branch"),detach:H().alias("d").describe("Detach HEAD at named commit"),orphan:Q.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 U(r.fs,r.cwd,t);if(S(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?O("--orphan and -c/-C are incompatible"):n.detach?O("--orphan and --detach are incompatible"):ap(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return O("--detach and -c/-C are incompatible");let d=a??"HEAD",l=await He(i,d,`invalid reference: ${d}`);return S(l)?l:ip(i,d,l.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,l=a??(o.passthrough.length>0?o.passthrough[0]:void 0);return Xf(i,d,!!n.forceCreate,l,r.env,t)}if(!a)return O("missing branch or commit argument");if(a==="-")return sp(i,r.env,t);let c=`refs/heads/${a}`,f=await N(i,c);if(f)return Jf(i,a,c,f,r.env,t);if(n.guess!==!1){let d=await op(i,a);if(d)return Xf(i,a,!1,d.startPoint,r.env,t,d.trackingRef)}return O(`invalid reference: ${a}`)}})}async function Yr(e){return await Ee(e,"CHERRY_PICK_HEAD")?O(`cannot switch branch while cherry-picking
|
|
699
|
+
Consider "git cherry-pick --quit" or "git worktree add".`):await Ee(e,"MERGE_HEAD")?O(`cannot switch branch while merging
|
|
700
|
+
Consider "git merge --quit" or "git worktree add".`):await Ee(e,"REVERT_HEAD")?O(`cannot switch branch while reverting
|
|
701
|
+
Consider "git revert --quit" or "git worktree add".`):await At(e)?O(`cannot switch branch while rebasing
|
|
702
|
+
Consider "git rebase --quit" or "git worktree add".`):null}async function sp(e,t,n){let r=await Yr(e);if(r)return r;let o=await Ms(e);return o?Jf(e,o.name,o.refName,o.hash,t,n):O("no previous branch")}async function op(e,t){let n=await we(e,"refs/remotes"),r=[];for(let s of n){let i=s.name.replace(/^refs\/remotes\//,"").split("/"),a=i[0];i.length>=2&&a&&i.slice(1).join("/")===t&&r.push({remote:a,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function Xf(e,t,n,r,o,s,i){let a=`refs/heads/${t}`,c=await N(e,a);if(c&&!n)return O(`a branch named '${t}' already exists`);let f;if(r){let y=await He(e,r,`invalid reference: ${r}`);if(S(y))return y;f=y.hash}else{let y=await X(e);if(!y){let $=await Z(e),A=$?.type==="symbolic"?$.target.replace(/^refs\/heads\//,""):"";n&&c&&await de(e,a),await Fe(e,"HEAD",a),await dt(e);let L=await cn(e);return await te(e,o,"HEAD",null,J,`checkout: moving from ${A} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
|
|
703
|
+
${L}`,exitCode:0}}f=y}let d=await Yr(e);if(d)return d;let l=await X(e),u=await q(e);if(r){let y=Pn(u);if(y)return y}let m=await M(e,f);if(l&&l!==f){let y=await M(e,l);if(y.tree!==m.tree){let $=await kn(e,y.tree,m.tree,u);if(!$.success)return $.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:$.newEntries},await re(e,u),await Te(e,$.worktreeOps)}}let h=await Z(e),p="";h?.type==="direct"&&l&&(p=await Ls(e,l,f));let g=rp(h,l);await Y(e,a,f),await Fe(e,"HEAD",a),await dt(e);let w=await cn(e),k=r??"HEAD";n&&c?c!==f&&await te(e,o,a,c,f,`branch: Reset to ${k}`):await te(e,o,a,null,f,`branch: Created from ${k}`),await te(e,o,"HEAD",l,f,`checkout: moving from ${g} to ${t}`);let b=i?.replace(/^refs\/remotes\//,"").split("/");if(b){let y=b[0]??"",$=`refs/heads/${b.slice(1).join("/")}`,A=await pe(e);A[`branch "${t}"`]={...A[`branch "${t}"`],remote:y,merge:$},await Ye(e,A)}await s?.hooks?.emitPost("post-checkout",{prevHead:l,newHead:f,isBranchCheckout:!0});let E=n&&c?`Switched to and reset branch '${t}'
|
|
696
704
|
`:`Switched to a new branch '${t}'
|
|
697
705
|
`,x=p+E+w;if(b){let y=b.slice(1).join("/");x+=`branch '${t}' set up to track '${b[0]}/${y}'.
|
|
698
|
-
`}let
|
|
699
|
-
${
|
|
700
|
-
`,stderr:"",exitCode:0}):
|
|
701
|
-
`)}if(n.list!==void 0)return
|
|
706
|
+
`}let P="";r&&(P=await zn(e,m.tree,u));let C=await pe(e),R=await an(e,C,t);return R&&(P+=Kn(R)),{stdout:P,stderr:x,exitCode:0}}async function Jf(e,t,n,r,o,s){let i=await Yr(e);return i||ar(e,t,n,r,o,s)}async function ip(e,t,n,r,o){let s=await Yr(e);return s||Rn(e,n,r,o)}async function ap(e,t,n,r){let o=await Yr(e);if(o)return o;let s=`refs/heads/${t}`;if(await N(e,s))return O(`a branch named '${t}' already exists`);let a=await q(e),c=Pn(a);if(c)return c;let f=await X(e),d=await Z(e),l="";if(d?.type==="direct"&&f&&(l=await Yo(e,f)),e.workTree){let m=f?(await M(e,f)).tree:null,h=await Se(e,[]),p=await kn(e,m,h,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await Te(e,p.worktreeOps),await re(e,{version:2,entries:p.newEntries})}else await re(e,qi());await Fe(e,"HEAD",s),await dt(e);let u=await cn(e);return await r?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:J,isBranchCheckout:!0}),{stdout:"",stderr:`${l}Switched to a new branch '${t}'
|
|
707
|
+
${u}`,exitCode:0}}ne();oe();Pr();me();ws();function ed(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[B.string().name("name").describe("Tag name to create or delete").optional(),B.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:H().alias("a").describe("Make an annotated tag object"),message:Q.string().alias("m").describe("Tag message"),delete:H().alias("d").describe("Delete a tag"),force:H().alias("f").describe("Replace an existing tag"),list:Q.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.delete){if(!n.name)return O("tag name required");let i=`refs/tags/${n.name}`,a=await N(s,i);return a?(await de(s,i),{stdout:`Deleted tag '${n.name}' (was ${z(a)})
|
|
708
|
+
`,stderr:"",exitCode:0}):_(`error: tag '${n.name}' not found.
|
|
709
|
+
`)}if(n.list!==void 0)return Qf(s,n.list||void 0);if(n.name){let i=n.commit,a;if(i){let l=await $t(s,i,`Failed to resolve '${i}' as a valid ref.`);if(S(l))return l;a=l}else if(a=await X(s),!a)return O("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await N(s,c)&&!n.force)return O(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return O("no tag message specified (use -m)");let l=await Ve(s,r.env);if(S(l))return l;let u=Ot(n.message),m=la({type:"tag",object:a,objectType:"commit",name:n.name,tagger:l,message:u}),h=await Re(s,"tag",m);await Y(s,c,h)}else await Y(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Qf(s)}})}async function Qf(e,t){let n=await we(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=>Ln(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
|
|
702
710
|
`)}
|
|
703
|
-
`,stderr:"",exitCode:0}}var cp={init:e=>
|
|
704
|
-
`,exitCode:1}:s())}this.inner=
|
|
711
|
+
`,stderr:"",exitCode:0}}var cp={init:e=>hf(e),clone:(e,t)=>Uc(e,t),fetch:(e,t)=>rf(e,t),pull:(e,t)=>$f(e,t),push:(e,t)=>If(e,t),add:(e,t)=>Ma(e,t),blame:(e,t)=>hc(e,t),commit:(e,t)=>Bc(e,t),status:(e,t)=>Yf(e,t),log:(e,t)=>kf(e,t),branch:(e,t)=>gc(e,t),tag:(e,t)=>ed(e,t),checkout:(e,t)=>wc(e,t),diff:(e,t)=>Qc(e,t),reset:(e,t)=>Mf(e,t),merge:(e,t)=>Pf(e,t),"cherry-pick":(e,t)=>Hc(e,t),revert:(e,t)=>_f(e,t),rebase:(e,t)=>Af(e,t),mv:(e,t)=>Rf(e,t),rm:(e,t)=>Nf(e,t),remote:(e,t)=>Sf(e,t),config:(e,t)=>zc(e,t),show:(e,t)=>Ff(e,t),stash:(e,t)=>Vf(e,t),"rev-parse":(e,t)=>Lf(e,t),"ls-files":(e,t)=>Cf(e,t),clean:(e,t)=>Ac(e,t),switch:(e,t)=>Zf(e,t),restore:(e,t)=>Gf(e,t),reflog:(e,t)=>vf(e,t),repack:(e,t)=>lf(e,t),gc:(e,t)=>uf(e,t),bisect:(e,t)=>ec(e,t)};function td(e){let t=go("git",{description:"Git command"});for(let n of Object.values(cp))n(t,e);return t}var fo=class{listeners=new Map;onError=()=>{};on(t,n){let r=t,o=this.listeners.get(r);o||(o=[],this.listeners.set(r,o));let s=n;return o.push(s),()=>{let i=this.listeners.get(r);if(i){let a=i.indexOf(s);a!==-1&&i.splice(a,1)}}}async emitPre(t,n){let r=this.listeners.get(t);if(!r||r.length===0)return null;for(let o of r){let s=await o(n);if(s&&typeof s=="object"&&"abort"in s)return s}return null}async emitPost(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)await o(n)}emit(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)try{let s=o(n);s&&typeof s=="object"&&"then"in s&&s.catch(this.onError)}catch(s){this.onError(s)}}};var lo=class{name="git";hooks;middlewares=[];extensions;inner;constructor(t){this.hooks=new fo;let n=t?.network;if(this.extensions={hooks:this.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote},t?.disabled?.length){let r=new Set(t.disabled);this.use(async(o,s)=>o.command&&r.has(o.command)?{stdout:"",stderr:`git: '${o.command}' is not available in this environment
|
|
712
|
+
`,exitCode:1}:s())}this.inner=td(this.extensions).toCommand()}on(t,n){return this.hooks.on(t,n)}use(t){return this.middlewares.push(t),()=>{let n=this.middlewares.indexOf(t);n!==-1&&this.middlewares.splice(n,1)}}execute=async(t,n)=>{let r={command:t[0],rawArgs:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env,stdin:n.stdin,exec:n.exec,signal:n.signal};return this.runMiddleware(r,()=>this.inner.execute(t,n))};async runMiddleware(t,n){if(this.middlewares.length===0)return n();let r=0,o=async()=>{if(r>=this.middlewares.length)return n();let s=this.middlewares[r++];return s(t,o)};return o()}};function fp(e){return new lo(e)}wn();export{lo as Git,fp as createGit,jn as findGitDir};
|