just-git 1.2.0 → 1.2.3
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 +39 -206
- package/dist/{hooks-Boa35Qx_.d.ts → hooks-4DvkF2xT.d.ts} +141 -4
- package/dist/index.d.ts +25 -72
- package/dist/index.js +336 -336
- package/dist/repo/index.d.ts +27 -1
- package/dist/repo/index.js +4 -4
- package/dist/server/index.d.ts +54 -116
- package/dist/server/index.js +46 -29
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
`;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=u;break}i=!0,f+=2;continue}l(),r+=d,i=!0,f++}break}return{value:r,linesConsumed:a-n+1};function l(){for(;s>0;)r+=" ",s--}}function
|
|
3
|
-
`),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=
|
|
4
|
-
`),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=
|
|
5
|
-
`:n+="\\n";break;case" ":n+="\\t";break;case"\b":n+="\\b";break;default:n+=o}}return t?`"${n}"`:n}function
|
|
6
|
-
`)}
|
|
7
|
-
`}function
|
|
8
|
-
`),s=
|
|
9
|
-
`)}function
|
|
10
|
-
`),o=
|
|
11
|
-
`),found:!0})}async function
|
|
12
|
-
`),s=
|
|
13
|
-
`)}async function
|
|
1
|
+
var od=Object.defineProperty;var Es=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ee=(e,t)=>()=>(e&&(t=e(e=0)),t);var id=(e,t)=>{for(var n in t)od(e,n,{get:t[n],enumerable:!0})};function Cs(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 S(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Cs(t)}function Ot(...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 Cs(t||".")}function Zt(e){if(e==="")return".";if(e==="/")return"/";let t=e.length;for(;t>1&&e.charCodeAt(t-1)===47;)t--;let n=e.slice(0,t),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}function Ar(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 ct(e,t){let n=Cs(e),r=Cs(t);if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),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,l=Math.min(o.length,s.length);for(;f<l&&o[f]===s[f];)f++;let d=o.length-f,u=s.slice(f),m=[];for(let h=0;h<d;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var le=Ee(()=>{"use strict"});function No(e){let t=1,n="";for(;t<e.length;){let r=e[t];if(r==="]"||r===" "||r===" "||r==='"')break;if(r==="."){t++;let o="";for(;t<e.length&&e[t]!=="]";)o+=e[t],t++;return`${n.toLowerCase()} "${o.toLowerCase()}"`}n+=r,t++}if(n=n.toLowerCase(),!n)return null;for(;t<e.length&&(e[t]===" "||e[t]===" ");)t++;if(t<e.length&&e[t]==='"'){t++;let r="";for(;t<e.length&&e[t]!=='"';)e[t]==="\\"&&t+1<e.length?(r+=e[t+1],t+=2):(r+=e[t],t++);return`${n} "${r}"`}return n}function Ia(e,t,n){let r="",o=!1,s=0,i=!1,a=n,c=e,f=0;e:for(;;){for(;f<c.length;){let d=c[f];if(d==="\r"){f++;continue}if(!o&&(d==="#"||d===";"))break e;if(!o&&(d===" "||d===" ")){i&&s++,f++;continue}if(d==='"'){l(),o=!o,f++;continue}if(d==="\\"){if(f+1>=c.length){if(a++,a<t.length){c=t[a],f=0;continue}break e}let u=c[f+1];switch(l(),u){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
|
|
2
|
+
`;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=u;break}i=!0,f+=2;continue}l(),r+=d,i=!0,f++}break}return{value:r,linesConsumed:a-n+1};function l(){for(;s>0;)r+=" ",s--}}function dd(e){let t={},n=null,r=e.split(`
|
|
3
|
+
`),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=No(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1)a[i.toLowerCase()]="true",o++;else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=Ia(l,r,o);a[f]=d,o+=u}continue}o++}return t}function Fo(e){let t={},n=null,r=e.split(`
|
|
4
|
+
`),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=No(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1){let f=i.toLowerCase();f in a?a[f].push("true"):a[f]=["true"],o++}else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=Ia(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=u}continue}o++}return t}function Uo(e){let t=/[\n\t\b#;"]/.test(e)||e!==e.trim(),n="";for(let r=0;r<e.length;r++){let o=e[r];switch(o){case"\\":n+="\\\\";break;case'"':n+='\\"';break;case`
|
|
5
|
+
`:n+="\\n";break;case" ":n+="\\t";break;case"\b":n+="\\b";break;default:n+=o}}return t?`"${n}"`:n}function Bo(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} = ${Uo(s)}`)}return`${t.join(`
|
|
6
|
+
`)}
|
|
7
|
+
`}function Wo(e,t,n){let r=null,o=-1,s=-1,i=-1,a=-1,c=!1,f=0;for(;f<e.length;){let l=e[f].trim();if(!l||l.startsWith("#")||l.startsWith(";")){f++;continue}if(l.startsWith("[")){r=No(l),r===t&&(a=f,i=f,c=!1),f++;continue}let d=f;for(;d<e.length-1&&e[d].replace(/\r$/,"").endsWith("\\");)d++;if(r===t){let u=l.indexOf("=");(u===-1?l.toLowerCase():l.slice(0,u).trim().toLowerCase())===n?(o=f,s=d):c=!0,i=d}f=d+1}return{keyStart:o,keyEnd:s,insertAfter:i,sectionHeaderLine:a,sectionHasOtherKeys:c}}function ud(e,t,n,r){let o=e.split(`
|
|
8
|
+
`),s=Wo(o,t,n),i=` ${n} = ${Uo(r)}`;return s.keyStart!==-1?o.splice(s.keyStart,s.keyEnd-s.keyStart+1,i):s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
|
|
9
|
+
`)}function md(e,t,n){let r=e.split(`
|
|
10
|
+
`),o=Wo(r,t,n);return o.keyStart===-1?{text:e,found:!1}:(r.splice(o.keyStart,o.keyEnd-o.keyStart+1),!o.sectionHasOtherKeys&&o.sectionHeaderLine!==-1&&r.splice(o.sectionHeaderLine,1),{text:r.join(`
|
|
11
|
+
`),found:!0})}async function he(e){let t=S(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return dd(n)}async function Ps(e){let t=S(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Ye(e,t){let n=S(e.gitDir,"config");await e.fs.writeFile(n,Bo(t))}async function ke(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await he(e),{section:s,key:i}=Dr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function qo(e,t,n){let r=await Ps(e),{section:o,key:s}=Dr(t),i=ud(r,o,s,n),a=S(e.gitDir,"config");await e.fs.writeFile(a,i)}async function $a(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Ps(e);if(o){let i=Fo(o),{section:a,key:c}=Dr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function hd(e,t,n,r){let o=e.split(`
|
|
12
|
+
`),s=Wo(o,t,n),i=` ${n} = ${Uo(r)}`;return s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
|
|
13
|
+
`)}async function Sa(e,t,n){let r=await Ps(e),{section:o,key:s}=Dr(t),i=hd(r,o,s,n),a=S(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Ta(e,t){let n=await Ps(e),{section:r,key:o}=Dr(t),s=md(n,r,o);if(!s.found)return!1;let i=S(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Dr(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 Ne=Ee(()=>{"use strict";le()});function Os(e,t){return Ha(e,t,"author")}function Mr(e,t){return Ha(e,t,"committer")}async function Ha(e,t,n){let r=pd[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:va(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await ke(e,"user.name")??o?.name,i=t.get(r.email)??await ke(e,"user.email")??o?.email;if(!s||!i)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
|
|
14
14
|
|
|
15
15
|
*** Please tell me who you are.
|
|
16
16
|
|
|
@@ -18,94 +18,94 @@ Run
|
|
|
18
18
|
|
|
19
19
|
git config user.email "you@example.com"
|
|
20
20
|
git config user.name "Your Name"
|
|
21
|
-
`);return{name:s,email:i,timestamp:va(t.get(r.date)),timezone:"+0000"}}async function Jt(e,t){try{let n=await jr(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 va(e){if(e){let t=parseInt(e,10);if(!Number.isNaN(t))return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.floor(n/1e3)}return Math.floor(Date.now()/1e3)}var wd,Rn=ye(()=>{"use strict";Le();wd={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function xn(e){let t="";for(let n=0;n<20;n++)t+=Aa[e[n]];return t}function Ss(e,t){let n="";for(let r=0;r<20;r++)n+=Aa[e[t+r]];return n}function St(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 te,Aa,dt=ye(()=>{"use strict";te="0000000000000000000000000000000000000000",Aa=(()=>{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 qo(e){return typeof e=="string"?bd.encode(e):e}function yd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(qo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=ks(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(qo(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(qo(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 xn(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 dr(e){return Da().update(e).hex()}var bd,Da,qn,zn=ye(()=>{"use strict";dt();bd=new TextEncoder;Da=yd(),qn=Da});async function K(e){let t=$(e.gitDir,"index");if(!await e.fs.exists(t))return{version:zo,entries:[]};let n=await e.fs.readFileBuffer(t);return Ed(n)}async function ie(e,t){let n=$(e.gitDir,"index"),r=await kd(t);await e.fs.writeFile(n,r)}function bt(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(Ko),{...e,entries:n}}function it(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function $s(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function $t(e){return e.entries.some(t=>t.stage>0)}function Ut(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function je(e){return e.entries.filter(t=>t.stage===0)}function ja(){return{version:zo,entries:[]}}function Ts(e){let t=[...e].sort(Ko);return{version:zo,entries:t}}function Oe(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Ed(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Ma)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)},l=t.getUint32(n+24);n+=40;let d=e.subarray(n,n+20),u=xn(d);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let R=n;for(;R<e.byteLength&&e[R]!==0;)R++;g=new TextDecoder().decode(e.subarray(n,R))}let w=62+g.length+1,y=Math.ceil(w/8)*8;n=c+y,i.push({path:g,mode:l,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function kd(e){let t=[...e.entries].sort(Ko),n=12;for(let l of t){let d=62+l.path.length+1;n+=Math.ceil(d/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,Ma),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let l of t){let d=i;s.setUint32(i,l.stat.ctimeSeconds),s.setUint32(i+4,l.stat.ctimeNanoseconds),s.setUint32(i+8,l.stat.mtimeSeconds),s.setUint32(i+12,l.stat.mtimeNanoseconds),s.setUint32(i+16,l.stat.dev),s.setUint32(i+20,l.stat.ino),s.setUint32(i+24,l.mode),s.setUint32(i+28,l.stat.uid),s.setUint32(i+32,l.stat.gid),s.setUint32(i+36,l.stat.size),i+=40;let u=St(l.hash);o.set(u,i),i+=20;let m=Math.min(l.path.length,4095),h=(l.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(l.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=d+w}let a=o.subarray(0,i),c=await dr(a),f=St(c);return o.set(f,i),o}function Ko(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Ma,zo,xe=ye(()=>{"use strict";dt();le();zn();Ma=1145655875,zo=2});var Rd,vs,Ga=ye(()=>{"use strict";Rd=new Set(["tree","commit","tag"]),vs=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Rd.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function Vo(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=La[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var La,_a=ye(()=>{"use strict";La=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;La[e]=t}});function Va(e){let t=Ka(e);return za(e.subarray(t,-4),{i:2})}function Jo(e){let t=Ka(e),n={i:2},r=za(e.subarray(t),n),o=qa(n.p);return{result:r,bytesConsumed:t+o+4}}var Wt,ur,xd,Na,Fa,Cd,Ua,Ba,Pd,Zo,Gr,Lr,Wa,Od,Id,Yo,Bt,Xo,qa,Sd,Qt,za,Ka,Ya=ye(()=>{"use strict";Wt=Uint8Array,ur=Uint16Array,xd=Int32Array,Na=new Wt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fa=new Wt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Cd=new Wt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ua=(e,t)=>{let n=new ur(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new xd(n[30]);for(let o=1;o<30;++o)for(let s=n[o];s<n[o+1];++s)r[s]=s-n[o]<<5|o;return{b:n,r}},{b:Ba}=Ua(Na,2);Ba[28]=258;({b:Pd}=Ua(Fa,0)),Zo=new ur(32768);for(let e=0;e<32768;++e){let t=(e&43690)>>1|(e&21845)<<1;t=(t&52428)>>2|(t&13107)<<2,t=(t&61680)>>4|(t&3855)<<4,Zo[e]=((t&65280)>>8|(t&255)<<8)>>1}Gr=(e,t,n)=>{let r=e.length,o=0,s=new ur(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new ur(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new ur(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[Zo[d]>>c]=f}}else for(a=new ur(r),o=0;o<r;++o)e[o]&&(a[o]=Zo[i[e[o]-1]++]>>15-e[o]);return a},Lr=new Wt(288);for(let e=0;e<144;++e)Lr[e]=8;for(let e=144;e<256;++e)Lr[e]=9;for(let e=256;e<280;++e)Lr[e]=7;for(let e=280;e<288;++e)Lr[e]=8;Wa=new Wt(32);for(let e=0;e<32;++e)Wa[e]=5;Od=Gr(Lr,9,1),Id=Gr(Wa,5,1),Yo=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Bt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Xo=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qa=e=>(e+7)/8|0,Sd=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Wt(e.subarray(t,n))),Qt=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},za=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Wt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Wt(o*3));let f=y=>{let R=n.length;if(y>R){let b=new Wt(Math.max(R*2,y));b.set(n),n=b}},l=t.f||0,d=t.p||0,u=t.b||0,m=t.l,h=t.d,p=t.m,g=t.n,w=o*8;do{if(!m){l=Bt(e,d,1);let k=Bt(e,d+1,3);if(d+=3,k)if(k==1)m=Od,h=Id,p=9,g=5;else if(k==2){let E=Bt(e,d,31)+257,x=Bt(e,d+10,15)+4,P=E+Bt(e,d+5,31)+1;d+=14;let C=new Wt(P),T=new Wt(19);for(let S=0;S<x;++S)T[Cd[S]]=Bt(e,d+S*3,7);d+=x*3;let D=Yo(T),O=(1<<D)-1,H=Gr(T,D,1);for(let S=0;S<P;){let F=H[Bt(e,d,O)];d+=F&15;let B=F>>4;if(B<16)C[S++]=B;else{let q=0,j=0;for(B==16?(j=3+Bt(e,d,3),d+=2,q=C[S-1]):B==17?(j=3+Bt(e,d,7),d+=3):B==18&&(j=11+Bt(e,d,127),d+=7);j--;)C[S++]=q}}let G=C.subarray(0,E),A=C.subarray(E);p=Yo(G),g=Yo(A),m=Gr(G,p,1),h=Gr(A,g,1)}else Qt(1);else{let E=qa(d)+4,x=e[E-4]|e[E-3]<<8,P=E+x;if(P>o){c&&Qt(0);break}a&&f(u+x),n.set(e.subarray(E,P),u),t.b=u+=x,t.p=d=P*8,t.f=l;continue}if(d>w){c&&Qt(0);break}}a&&f(u+131072);let y=(1<<p)-1,R=(1<<g)-1,b=d;for(;;b=d){let k=m[Xo(e,d)&y],E=k>>4;if(d+=k&15,d>w){c&&Qt(0);break}if(k||Qt(2),E<256)n[u++]=E;else if(E==256){b=d,m=null;break}else{let x=E-254;if(E>264){let O=E-257,H=Na[O];x=Bt(e,d,(1<<H)-1)+Ba[O],d+=H}let P=h[Xo(e,d)&R],C=P>>4;P||Qt(3),d+=P&15;let T=Pd[C];if(C>3){let O=Fa[C];T+=Xo(e,d)&(1<<O)-1,d+=O}if(d>w){c&&Qt(0);break}a&&f(u+131072);let D=u+x;if(u<T){let O=s-T,H=Math.min(T,D);for(O+u<0&&Qt(3);u<H;++u)n[u]=r[O+u]}for(;u<D;++u)n[u]=n[u-T]}}t.l=m,t.p=b,t.b=u,t.f=l,m&&(l=1,t.m=p,t.d=h,t.n=g)}while(!l);return u!=n.length&&i?Sd(n,0,u):n.subarray(0,u)},Ka=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Qt(0,"invalid zlib data"),e[1]&32&&Qt(0,"zlib dictionaries are not supported"),2)});async function $d(){let e;if(!(typeof document<"u"))try{e=ks(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let r=null;try{let o=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});o?.engine&&typeof o.engine.bytesWritten=="number"&&(r=s=>{let i=e.inflateSync(s,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:o=>new Uint8Array(e.deflateSync(o)),inflateSync:o=>new Uint8Array(e.inflateSync(o)),inflateWithConsumed:r??Jo}}let n;return typeof globalThis.CompressionStream=="function"?n=async r=>{let o=new CompressionStream("deflate"),s=o.writable.getWriter();return s.write(r),s.close(),new Uint8Array(await new Response(o.readable).arrayBuffer())}:n=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:n,inflateSync:Va,inflateWithConsumed:Jo}}function Qo(){return Td??=$d()}async function _r(e){return await(await Qo()).deflateSync(e)}async function mr(e){return await(await Qo()).inflateSync(e)}async function Xa(e,t){let n=await Qo(),{result:r,bytesConsumed:o}=n.inflateWithConsumed(e);if(r.byteLength!==t)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${t}`);return{result:r,bytesConsumed:o}}var Td,Hs=ye(()=>{"use strict";Ya();Td=null});async function sc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==ti)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${ti.toString(16)})`);let o=n.getUint32(4);if(o!==Qa)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await Ad(e,a);i.push(l),a=l.nextOffset}return(await Dd(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function Ad(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===Nr){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===ni&&(c=Ss(e,t),t+=20);let{result:f,bytesConsumed:l}=await Xa(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function Dd(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s){let i=r[s];if(i)return i;let a=e[s];if(a.typeNum!==Nr&&a.typeNum!==ni){let u=vd[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let m={type:u,content:a.inflated,hash:await ei(u,a.inflated)};return r[s]=m,m}if(a.typeNum===Nr){let u=n.get(a.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`);let m=await o(u),h=Fr(m.content,a.inflated),p={type:m.type,content:h,hash:await ei(m.type,h)};return r[s]=p,p}let c=await Md(e,r,a.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(a.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let l=Fr(f.content,a.inflated),d={type:f.type,content:l,hash:await ei(f.type,l)};return r[s]=d,d}for(let s=0;s<e.length;s++)await o(s);return r}async function Md(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!==Nr&&s.typeNum!==ni&&(await r(o)).hash===n)return o}}function Fr(e,t){let n=0,{value:r,newPos:o}=Ja(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}=Ja(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let l=0,d=0;f&1&&(l=t[n++]),f&2&&(l|=t[n++]<<8),f&4&&(l|=t[n++]<<16),f&8&&(l|=t[n++]<<24),f&16&&(d=t[n++]),f&32&&(d|=t[n++]<<8),f&64&&(d|=t[n++]<<16),d===0&&(d=65536),a.set(e.subarray(l,l+d),c),c+=d}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 As(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,ti),o.setUint32(4,Qa),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let a of e){let c=s;n.set(a.hash,s);let f=a.delta&&a.deltaBaseHash?n.get(a.deltaBaseHash):void 0;if(a.delta&&f!==void 0){let l=Za(Nr,a.delta.byteLength),d=Gd(s-f),u=await _r(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=Hd[a.type],d=Za(l,a.content.byteLength),u=await _r(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await jd(t),entries:i}}async function jd(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=qn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(St(s),r),n}function Gd(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 Za(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 Ja(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 ei(e,t){let n=Ld.encode(`${e} ${t.byteLength}\0`),r=qn();return r.update(n),r.update(t),r.hex()}var ti,Qa,ec,tc,nc,rc,Nr,ni,vd,Hd,Ld,Ur=ye(()=>{"use strict";dt();zn();Hs();ti=1346454347,Qa=2,ec=1,tc=2,nc=3,rc=4,Nr=6,ni=7,vd={[ec]:"commit",[tc]:"tree",[nc]:"blob",[rc]:"tag"},Hd={commit:ec,tree:tc,blob:nc,tag:rc};Ld=new TextEncoder});async function ac(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,oc),c+=4,a.setUint32(c,ic),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(St(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let l=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|l++):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 d=qn();d.update(i.subarray(0,c));let u=await d.hex();return i.set(St(u),c),i}async function cc(e){let n=(await sc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Vo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ac(n,r)}async function fc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Vo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ac(n,r)}var oc,ic,qt,Ds=ye(()=>{"use strict";dt();zn();_a();Ur();oc=4285812579,ic=2,qt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==oc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==ic)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=St(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=St(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,m=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==m){l=!1;break}}l&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var _d,Nd,Fd,Br,lc=ye(()=>{"use strict";dt();Ds();Ur();Hs();_d=6,Nd=7,Fd={1:"commit",2:"tree",3:"blob",4:"tag"},Br=class{constructor(t,n){this.data=t;this.index=n instanceof qt?n:new qt(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===_d){let l=n[r++],d=l&127;for(;l&128;)d+=1,l=n[r++],d=(d<<7)+(l&127);let u=await mr(n.subarray(r)),m=await this.readAt(t-d);return{type:m.type,content:Fr(m.content,u)}}if(s===Nd){let l=Ss(n,r);r+=20;let d=await mr(n.subarray(r)),u=this.index.lookup(l);if(u===null)throw new Error(`REF_DELTA base ${l} not found in pack`);let m=await this.readAt(u);return{type:m.type,content:Fr(m.content,d)}}let c=Fd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await mr(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 si(e,t){let n=Ud.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Wd(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Bd.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 ri(e,t){return $(e,"objects",t.slice(0,2),t.slice(2))}var Ud,Bd,hr,oi=ye(()=>{"use strict";dt();Ga();Ds();lc();Hs();le();zn();Ud=new TextEncoder,Bd=new TextDecoder;hr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new vs(r),this.packDir=$(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=si(t,n),o=await dr(r),s=ri(this.gitDir,o);if(await this.fs.exists(s))return o;let i=$(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await _r(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=ri(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await mr(o),i=Wd(t,s);return this.cache.set(t,i),i}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(ri(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=xn(o);await this.fs.mkdir(this.packDir,{recursive:!0});let i=`pack-${s}`,a=$(this.packDir,`${i}.pack`);await this.fs.writeFile(a,t);let c=await cc(t),f=$(this.packDir,`${i}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(i);let l=new qt(c);return this.packs.push({name:i,index:l,reader:new Br(t,l)}),r}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=$(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=$(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Br(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=$(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer($(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new qt(s),reader:null})}}}});function Wr(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 qr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var ii=ye(()=>{"use strict"});function en(e){let t=zd.decode(e),n=t.indexOf(`
|
|
21
|
+
`);return{name:s,email:i,timestamp:va(t.get(r.date)),timezone:"+0000"}}async function Jt(e,t){try{let n=await Mr(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 va(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 pd,xn=Ee(()=>{"use strict";Ne();pd={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 Cn(e){let t="";for(let n=0;n<20;n++)t+=Aa[e[n]];return t}function Is(e,t){let n="";for(let r=0;r<20;r++)n+=Aa[e[t+r]];return n}function It(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 te,Aa,dt=Ee(()=>{"use strict";te="0000000000000000000000000000000000000000",Aa=(()=>{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 zo(e){return typeof e=="string"?gd.encode(e):e}function wd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(zo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Es(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(zo(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(zo(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 Cn(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 lr(e){return Da().update(e).hex()}var gd,Da,zn,Kn=Ee(()=>{"use strict";dt();gd=new TextEncoder;Da=wd(),zn=Da});async function K(e){let t=S(e.gitDir,"index");if(!await e.fs.exists(t))return{version:Ko,entries:[]};let n=await e.fs.readFileBuffer(t);return bd(n)}async function ie(e,t){let n=S(e.gitDir,"index"),r=await yd(t);await e.fs.writeFile(n,r)}function bt(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(Vo),{...e,entries:n}}function it(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function $s(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function $t(e){return e.entries.some(t=>t.stage>0)}function Ut(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function je(e){return e.entries.filter(t=>t.stage===0)}function ja(){return{version:Ko,entries:[]}}function Ss(e){let t=[...e].sort(Vo);return{version:Ko,entries:t}}function Ie(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function bd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Ma)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)},l=t.getUint32(n+24);n+=40;let d=e.subarray(n,n+20),u=Cn(d);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let x=n;for(;x<e.byteLength&&e[x]!==0;)x++;g=new TextDecoder().decode(e.subarray(n,x))}let w=62+g.length+1,y=Math.ceil(w/8)*8;n=c+y,i.push({path:g,mode:l,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function yd(e){let t=[...e.entries].sort(Vo),n=12;for(let l of t){let d=62+l.path.length+1;n+=Math.ceil(d/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),i=0;s.setUint32(i,Ma),i+=4,s.setUint32(i,e.version),i+=4,s.setUint32(i,t.length),i+=4;for(let l of t){let d=i;s.setUint32(i,l.stat.ctimeSeconds),s.setUint32(i+4,l.stat.ctimeNanoseconds),s.setUint32(i+8,l.stat.mtimeSeconds),s.setUint32(i+12,l.stat.mtimeNanoseconds),s.setUint32(i+16,l.stat.dev),s.setUint32(i+20,l.stat.ino),s.setUint32(i+24,l.mode),s.setUint32(i+28,l.stat.uid),s.setUint32(i+32,l.stat.gid),s.setUint32(i+36,l.stat.size),i+=40;let u=It(l.hash);o.set(u,i),i+=20;let m=Math.min(l.path.length,4095),h=(l.stage&3)<<12|m;s.setUint16(i,h),i+=2;let p=new TextEncoder().encode(l.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=d+w}let a=o.subarray(0,i),c=await lr(a),f=It(c);return o.set(f,i),o}function Vo(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Ma,Ko,Pe=Ee(()=>{"use strict";dt();le();Kn();Ma=1145655875,Ko=2});var Ed,Ts,Ga=Ee(()=>{"use strict";Ed=new Set(["tree","commit","tag"]),Ts=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Ed.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function Yo(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=La[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var La,_a=Ee(()=>{"use strict";La=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;La[e]=t}});function Va(e){let t=Ka(e);return za(e.subarray(t,-4),{i:2})}function Qo(e){let t=Ka(e),n={i:2},r=za(e.subarray(t),n),o=qa(n.p);return{result:r,bytesConsumed:t+o+4}}var Wt,dr,kd,Na,Fa,Rd,Ua,Ba,xd,Jo,jr,Gr,Wa,Cd,Pd,Xo,Bt,Zo,qa,Od,Qt,za,Ka,Ya=Ee(()=>{"use strict";Wt=Uint8Array,dr=Uint16Array,kd=Int32Array,Na=new Wt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fa=new Wt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Rd=new Wt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ua=(e,t)=>{let n=new dr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new kd(n[30]);for(let o=1;o<30;++o)for(let s=n[o];s<n[o+1];++s)r[s]=s-n[o]<<5|o;return{b:n,r}},{b:Ba}=Ua(Na,2);Ba[28]=258;({b:xd}=Ua(Fa,0)),Jo=new dr(32768);for(let e=0;e<32768;++e){let t=(e&43690)>>1|(e&21845)<<1;t=(t&52428)>>2|(t&13107)<<2,t=(t&61680)>>4|(t&3855)<<4,Jo[e]=((t&65280)>>8|(t&255)<<8)>>1}jr=(e,t,n)=>{let r=e.length,o=0,s=new dr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new dr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new dr(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[Jo[d]>>c]=f}}else for(a=new dr(r),o=0;o<r;++o)e[o]&&(a[o]=Jo[i[e[o]-1]++]>>15-e[o]);return a},Gr=new Wt(288);for(let e=0;e<144;++e)Gr[e]=8;for(let e=144;e<256;++e)Gr[e]=9;for(let e=256;e<280;++e)Gr[e]=7;for(let e=280;e<288;++e)Gr[e]=8;Wa=new Wt(32);for(let e=0;e<32;++e)Wa[e]=5;Cd=jr(Gr,9,1),Pd=jr(Wa,5,1),Xo=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Bt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Zo=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},qa=e=>(e+7)/8|0,Od=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Wt(e.subarray(t,n))),Qt=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},za=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Wt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Wt(o*3));let f=y=>{let x=n.length;if(y>x){let b=new Wt(Math.max(x*2,y));b.set(n),n=b}},l=t.f||0,d=t.p||0,u=t.b||0,m=t.l,h=t.d,p=t.m,g=t.n,w=o*8;do{if(!m){l=Bt(e,d,1);let k=Bt(e,d+1,3);if(d+=3,k)if(k==1)m=Cd,h=Pd,p=9,g=5;else if(k==2){let E=Bt(e,d,31)+257,R=Bt(e,d+10,15)+4,P=E+Bt(e,d+5,31)+1;d+=14;let C=new Wt(P),T=new Wt(19);for(let $=0;$<R;++$)T[Rd[$]]=Bt(e,d+$*3,7);d+=R*3;let D=Xo(T),O=(1<<D)-1,H=jr(T,D,1);for(let $=0;$<P;){let N=H[Bt(e,d,O)];d+=N&15;let B=N>>4;if(B<16)C[$++]=B;else{let z=0,_=0;for(B==16?(_=3+Bt(e,d,3),d+=2,z=C[$-1]):B==17?(_=3+Bt(e,d,7),d+=3):B==18&&(_=11+Bt(e,d,127),d+=7);_--;)C[$++]=z}}let G=C.subarray(0,E),A=C.subarray(E);p=Xo(G),g=Xo(A),m=jr(G,p,1),h=jr(A,g,1)}else Qt(1);else{let E=qa(d)+4,R=e[E-4]|e[E-3]<<8,P=E+R;if(P>o){c&&Qt(0);break}a&&f(u+R),n.set(e.subarray(E,P),u),t.b=u+=R,t.p=d=P*8,t.f=l;continue}if(d>w){c&&Qt(0);break}}a&&f(u+131072);let y=(1<<p)-1,x=(1<<g)-1,b=d;for(;;b=d){let k=m[Zo(e,d)&y],E=k>>4;if(d+=k&15,d>w){c&&Qt(0);break}if(k||Qt(2),E<256)n[u++]=E;else if(E==256){b=d,m=null;break}else{let R=E-254;if(E>264){let O=E-257,H=Na[O];R=Bt(e,d,(1<<H)-1)+Ba[O],d+=H}let P=h[Zo(e,d)&x],C=P>>4;P||Qt(3),d+=P&15;let T=xd[C];if(C>3){let O=Fa[C];T+=Zo(e,d)&(1<<O)-1,d+=O}if(d>w){c&&Qt(0);break}a&&f(u+131072);let D=u+R;if(u<T){let O=s-T,H=Math.min(T,D);for(O+u<0&&Qt(3);u<H;++u)n[u]=r[O+u]}for(;u<D;++u)n[u]=n[u-T]}}t.l=m,t.p=b,t.b=u,t.f=l,m&&(l=1,t.m=p,t.d=h,t.n=g)}while(!l);return u!=n.length&&i?Od(n,0,u):n.subarray(0,u)},Ka=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Qt(0,"invalid zlib data"),e[1]&32&&Qt(0,"zlib dictionaries are not supported"),2)});async function Id(){let e;if(!(typeof document<"u"))try{e=Es(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let r=null;try{let o=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});o?.engine&&typeof o.engine.bytesWritten=="number"&&(r=s=>{let i=e.inflateSync(s,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:o=>new Uint8Array(e.deflateSync(o)),inflateSync:o=>new Uint8Array(e.inflateSync(o)),inflateWithConsumed:r??Qo}}let n;return typeof globalThis.CompressionStream=="function"?n=async r=>{let o=new CompressionStream("deflate"),s=o.writable.getWriter();return s.write(r),s.close(),new Uint8Array(await new Response(o.readable).arrayBuffer())}:n=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:n,inflateSync:Va,inflateWithConsumed:Qo}}function ei(){return $d??=Id()}async function Lr(e){return await(await ei()).deflateSync(e)}async function ur(e){return await(await ei()).inflateSync(e)}async function Xa(e,t){let n=await ei(),{result:r,bytesConsumed:o}=n.inflateWithConsumed(e);if(r.byteLength!==t)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${t}`);return{result:r,bytesConsumed:o}}var $d,vs=Ee(()=>{"use strict";Ya();$d=null});async function sc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==ni)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${ni.toString(16)})`);let o=n.getUint32(4);if(o!==Qa)throw new Error(`Unsupported pack version: ${o}`);let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await vd(e,a);i.push(l),a=l.nextOffset}return(await Hd(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function vd(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===_r){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===ri&&(c=Is(e,t),t+=20);let{result:f,bytesConsumed:l}=await Xa(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function Hd(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s){let i=r[s];if(i)return i;let a=e[s];if(a.typeNum!==_r&&a.typeNum!==ri){let u=Sd[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let m={type:u,content:a.inflated,hash:await ti(u,a.inflated)};return r[s]=m,m}if(a.typeNum===_r){let u=n.get(a.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`);let m=await o(u),h=Nr(m.content,a.inflated),p={type:m.type,content:h,hash:await ti(m.type,h)};return r[s]=p,p}let c=await Ad(e,r,a.baseHash,o),f;if(c!==void 0)f=await o(c);else if(t){let u=await t(a.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let l=Nr(f.content,a.inflated),d={type:f.type,content:l,hash:await ti(f.type,l)};return r[s]=d,d}for(let s=0;s<e.length;s++)await o(s);return r}async function Ad(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!==_r&&s.typeNum!==ri&&(await r(o)).hash===n)return o}}function Nr(e,t){let n=0,{value:r,newPos:o}=Ja(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}=Ja(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let l=0,d=0;f&1&&(l=t[n++]),f&2&&(l|=t[n++]<<8),f&4&&(l|=t[n++]<<16),f&8&&(l|=t[n++]<<24),f&16&&(d=t[n++]),f&32&&(d|=t[n++]<<8),f&64&&(d|=t[n++]<<16),d===0&&(d=65536),a.set(e.subarray(l,l+d),c),c+=d}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 Hs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,ni),o.setUint32(4,Qa),o.setUint32(8,e.length),t.push(r);let s=12,i=[];for(let a of e){let c=s;n.set(a.hash,s);let f=a.delta&&a.deltaBaseHash?n.get(a.deltaBaseHash):void 0;if(a.delta&&f!==void 0){let l=Za(_r,a.delta.byteLength),d=Md(s-f),u=await Lr(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=Td[a.type],d=Za(l,a.content.byteLength),u=await Lr(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Dd(t),entries:i}}async function Dd(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=zn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(It(s),r),n}function Md(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 Za(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 Ja(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 ti(e,t){let n=jd.encode(`${e} ${t.byteLength}\0`),r=zn();return r.update(n),r.update(t),r.hex()}var ni,Qa,ec,tc,nc,rc,_r,ri,Sd,Td,jd,Fr=Ee(()=>{"use strict";dt();Kn();vs();ni=1346454347,Qa=2,ec=1,tc=2,nc=3,rc=4,_r=6,ri=7,Sd={[ec]:"commit",[tc]:"tree",[nc]:"blob",[rc]:"tag"},Td={commit:ec,tree:tc,blob:nc,tag:rc};jd=new TextEncoder});async function ac(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,oc),c+=4,a.setUint32(c,ic),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(It(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let l=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|l++):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 d=zn();d.update(i.subarray(0,c));let u=await d.hex();return i.set(It(u),c),i}async function cc(e){let n=(await sc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Yo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ac(n,r)}async function fc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Yo(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ac(n,r)}var oc,ic,qt,As=Ee(()=>{"use strict";dt();Kn();_a();Fr();oc=4285812579,ic=2,qt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==oc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==ic)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=It(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=It(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,m=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==m){l=!1;break}}l&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var Gd,Ld,_d,Ur,lc=Ee(()=>{"use strict";dt();As();Fr();vs();Gd=6,Ld=7,_d={1:"commit",2:"tree",3:"blob",4:"tag"},Ur=class{constructor(t,n){this.data=t;this.index=n instanceof qt?n:new qt(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,i=o&15,a=4;for(;o&128;)o=n[r++],i|=(o&127)<<a,a+=7;if(s===Gd){let l=n[r++],d=l&127;for(;l&128;)d+=1,l=n[r++],d=(d<<7)+(l&127);let u=await ur(n.subarray(r)),m=await this.readAt(t-d);return{type:m.type,content:Nr(m.content,u)}}if(s===Ld){let l=Is(n,r);r+=20;let d=await ur(n.subarray(r)),u=this.index.lookup(l);if(u===null)throw new Error(`REF_DELTA base ${l} not found in pack`);let m=await this.readAt(u);return{type:m.type,content:Nr(m.content,d)}}let c=_d[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await ur(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 oi(e,t){let n=Nd.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Ud(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Fd.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 si(e,t){return S(e,"objects",t.slice(0,2),t.slice(2))}var Nd,Fd,mr,ii=Ee(()=>{"use strict";dt();Ga();As();lc();vs();le();Kn();Nd=new TextEncoder,Fd=new TextDecoder;mr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ts(r),this.packDir=S(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=oi(t,n),o=await lr(r),s=si(this.gitDir,o);if(await this.fs.exists(s))return o;let i=S(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Lr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=si(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await ur(o),i=Ud(t,s);return this.cache.set(t,i),i}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(si(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=Cn(o);await this.fs.mkdir(this.packDir,{recursive:!0});let i=`pack-${s}`,a=S(this.packDir,`${i}.pack`);await this.fs.writeFile(a,t);let c=await cc(t),f=S(this.packDir,`${i}.idx`);await this.fs.writeFile(f,c),this.loadedPackNames.add(i);let l=new qt(c);return this.packs.push({name:i,index:l,reader:new Ur(t,l)}),r}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=S(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=S(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Ur(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=S(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(S(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new qt(s),reader:null})}}}});function Br(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 Wr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var ai=Ee(()=>{"use strict"});function en(e){let t=Wd.decode(e),n=t.indexOf(`
|
|
22
22
|
|
|
23
23
|
`),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(`
|
|
24
|
-
`)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=
|
|
25
|
-
`))}var
|
|
24
|
+
`)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=Br(u);break;case"committer":c=Br(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 tn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Wr(e.author)}`),t.push(`committer ${Wr(e.committer)}`),t.push(""),t.push(e.message),Bd.encode(t.join(`
|
|
25
|
+
`))}var Bd,Wd,dn=Ee(()=>{"use strict";ai();Bd=new TextEncoder,Wd=new TextDecoder});function un(e){let t=zd.decode(e),n=t.indexOf(`
|
|
26
26
|
|
|
27
27
|
`),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(`
|
|
28
|
-
`)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=
|
|
29
|
-
`))}var
|
|
28
|
+
`)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=Br(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 dc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Wr(e.tagger)}`),t.push(""),t.push(e.message),qd.encode(t.join(`
|
|
29
|
+
`))}var qd,zd,qr=Ee(()=>{"use strict";ai();qd=new TextEncoder,zd=new TextDecoder});async function yt(e,t){return lr(oi(e,t))}async function $e(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function we(e,t){return e.objectStore.read(t)}async function zt(e,t){return e.objectStore.exists(t)}async function Ds(e,t){return e.objectStore.ingestPack(t)}async function uc(e,t){return e.objectStore.findByPrefix(t)}function Ae(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 ae(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Kd.decode(n.content)}async function Et(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function j(e,t){let n=await we(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return en(n.content)}async function mc(e,t){let n=await we(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return un(n.content)}async function _e(e,t){let n=t;for(let r=0;r<100;r++){let o=await we(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=un(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 Kd,oe=Ee(()=>{"use strict";ii();dn();qr();Kn();Kd=new TextDecoder});function hc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var zr,ci=Ee(()=>{"use strict";zr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function gc(e,t){return e.refStore.readRef(t)}async function F(e,t){let n=t;for(let r=0;r<pc;r++){let o=await gc(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 J(e){return gc(e,"HEAD")}async function Z(e){return F(e,"HEAD")}async function X(e,t,n){let r=e.hooks?await F(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function ze(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function de(e,t){let n=e.hooks?await F(e,t):null;await e.refStore.deleteRef(t),await Vr(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function ge(e,t="refs"){return e.refStore.listRefs(t)}function Re(e){return e.replace("refs/heads/","")}async function In(e,t){let n=await J(e);n&&n.type==="symbolic"?await X(e,n.target,t):await X(e,"HEAD",t)}async function wc(e){if(e.refStore&&!(e.refStore instanceof On))return;let t=await ge(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await we(e,o.hash);if(s.type==="tag"){let i=un(s.content).object;for(let a=0;a<100;a++){let c=await we(e,i);if(c.type!=="tag")break;i=un(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(S(e.gitDir,"packed-refs"),`${n.join(`
|
|
30
30
|
`)}
|
|
31
|
-
`);for(let o of t){let s
|
|
31
|
+
`);for(let o of t){let s=S(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await bc(e,S(e.gitDir,"refs"));let r=S(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(S(r,"heads"),{recursive:!0}),await e.fs.mkdir(S(r,"tags"),{recursive:!0})}async function bc(e,t){if(e.refStore&&!(e.refStore instanceof On)||!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 bc(e,S(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var fi,pc,On,ue=Ee(()=>{"use strict";oe();qr();le();Fe();$n();ci();fi="ref: ",pc=10,On=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=S(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(fi)?{type:"symbolic",target:s.slice(fi.length)}:{type:"direct",hash:s}}let o=(await this.readPackedRefs()).get(t);return o?{type:"direct",hash:o}:null}async writeRef(t,n){let r=hc(n),o=S(this.gitDir,t);await Kr(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${fi}${r.target}
|
|
32
32
|
`):await this.fs.writeFile(o,`${r.hash}
|
|
33
|
-
`)}async deleteRef(t){let n
|
|
34
|
-
`)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n
|
|
33
|
+
`)}async deleteRef(t){let n=S(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=S(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}async compareAndSwapRef(t,n,r){let s=(this.casLocks.get(t)??Promise.resolve(!1)).then(()=>this.compareAndSwapUnsafe(t,n,r),()=>this.compareAndSwapUnsafe(t,n,r));this.casLocks.set(t,s);try{return await s}finally{this.casLocks.get(t)===s&&this.casLocks.delete(t)}}async compareAndSwapUnsafe(t,n,r){let o=await this.resolveRefInternal(t);if(n===null){if(await this.readRef(t)!==null)return!1}else if(o!==n)return!1;return r===null?await this.deleteRef(t):await this.writeRef(t,r),!0}async resolveRefInternal(t){let n=t;for(let r=0;r<pc;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=S(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
|
|
34
|
+
`)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=S(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
|
|
35
35
|
`),s=[],i=!1;for(let c of o){if(i&&c.startsWith("^")){i=!1;continue}if(i=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){i=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await this.fs.writeFile(n,s.join(`
|
|
36
|
-
`)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i
|
|
37
|
-
`)){if(!s)continue;let i=
|
|
36
|
+
`)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=S(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function Vn(e,t){let n=t;for(;;){let r=S(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new mr(e,r),refStore:new On(e,r)};if(await Vd(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new mr(e,n),refStore:new On(e,n)};let o=Yd(n);if(o===n)return null;n=o}}async function Vd(e,t){let n=S(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=S(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 Ms(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:S(t,".git"),i=r?null:t,a=S(s,"HEAD"),c=await e.exists(a);await e.mkdir(S(s,"objects"),{recursive:!0}),await e.mkdir(S(s,"refs","heads"),{recursive:!0}),await e.mkdir(S(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new mr(e,s),refStore:new On(e,s)};if(!c){await ze(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(S(s,"config"),Bo(l))}return{ctx:f,reinit:c}}async function Kr(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Yd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var $n=Ee(()=>{"use strict";Ne();ii();le();ue()});function js(e,t){return S(e.gitDir,"logs",t)}function Xd(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(),l=n.slice(a+1,c),d=n.slice(c+2),u=d.indexOf(" ");if(u<0)return null;let m=parseInt(d.slice(0,u),10),h=d.slice(u+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:m,tz:h,message:r}}async function Je(e,t){let n=js(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(`
|
|
37
|
+
`)){if(!s)continue;let i=Xd(s);i&&o.push(i)}return o}function yc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Sn(e,t,n){let r=js(e,t);if(await Kr(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(yc).join(`
|
|
38
38
|
`)}
|
|
39
|
-
`;await e.fs.writeFile(r,o)}async function
|
|
40
|
-
`;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
|
|
41
|
-
`)){let s=wu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function bu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Sc){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Yn(n,e,2)===0}function yu(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 Yn(r,a,2)===0}function hi(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&$c&&!t)){if(s.flags&Ic){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(bu(r,s))return s;continue}if(yu(e,s))return s}}return null}function nn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=hi(t,n,o);if(s)return s.flags&Ns?"not-ignored":"ignored"}if(e.excludeFile){let r=hi(t,n,e.excludeFile);if(r)return r.flags&Ns?"not-ignored":"ignored"}if(e.globalExclude){let r=hi(t,n,e.globalExclude);if(r)return r.flags&Ns?"not-ignored":"ignored"}return"undecided"}async function gr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=$(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Jr(r,"",n)}catch{}try{let r=await Ee(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Jr(o,"",r)}catch{}}catch{}return t}function Xn(e,t,n,r){let s=Jr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Ic,Sc,$c,Ns,Us=ye(()=>{"use strict";Le();le();_s();Ic=1,Sc=4,$c=8,Ns=16});async function Tt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=$(e.workTree,s.path),a;try{a=await ft(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 $n(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await et(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ce(s.path,i.path))}async function at(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=$(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&hn(t.mode)&&e.fs.symlink){await ft(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=ku.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 vc(e,t){let n=await Ve(e,t);for(let r of n)await at(e,r)}async function rn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=$(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await ft(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=Eu.encode(f),d=await Ie(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...Oe(),size:l.byteLength}};return{index:bt(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Ie(e,"blob",s),a=o.mode!=null?Ru(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Oe(),size:s.byteLength}};return{index:bt(t,c),hash:i}}async function et(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await gr(e);let c=$(t,".gitignore");try{let f=await e.fs.readFile(c);s=Xn(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,c),l=n?`${n}/${c}`:c,d=await ft(e.fs,f);if(d.isSymbolicLink){if(s&&nn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&nn(s,l,!0)==="ignored")continue;let u=await et(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(d.isFile){if(s&&nn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function Ru(e){return e>511?e:e&73?33261:33188}async function Zn(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await Zn(e,Zt(t),n))}var Eu,ku,tt=ye(()=>{"use strict";se();Us();xe();oe();le();Vn();Ae();Eu=new TextEncoder,ku=new TextDecoder});function pi(e){return e.existsOnDisk&&e.indexHash===null}async function xu(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 et(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await et(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of d){let p=null,g=null,w=null,y=null,R=null;if(r.length===1){let O=u(0,h);w=O?.hash??null,R=O?.mode??null}else if(r.length===2){let O=u(0,h),H=u(1,h);g=O?.hash??null,y=O?.mode??null,w=H?.hash??null,R=H?.mode??null}else if(r.length>=3){let O=u(0,h),H=u(1,h),G=u(2,h);p=O?.hash??null,g=H?.hash??null,y=H?.mode??null,w=G?.hash??null,R=G?.mode??null}let k=o.get(h)?.hash??null,E=s.has(h)?1:0,x=i.has(h),P,C=async()=>P!==void 0?P:x?(P=!(await c()).has(h),P):(P=!1,!1),T,D=async()=>{if(T!==void 0)return T;if(!x||!e.workTree)return T=null,null;let O=$(e.workTree,h);try{T=await $n(e.fs,O)}catch{T=null}return T};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:E,existsOnDisk:x,isIgnoredOnDisk:C,getWorktreeHash:D,headMode:y,remoteMode:R})}return m}function Bs(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 Ws(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 Cu(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 Pu(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=Cu(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await Ou(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function Ou(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":pi(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 pi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return pi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function Iu(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 l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:d,stage:0,stat:Oe()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:m});break}case"DELETE":{r.updateWorktree&&l.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 qs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Su){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(l=>` ${l}`).join(`
|
|
39
|
+
`;await e.fs.writeFile(r,o)}async function Ke(e,t,n){let r=js(e,t);await Kr(e.fs,r);let o=`${yc(n)}
|
|
40
|
+
`;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 Vr(e,t){let n=js(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function re(e,t,n,r,o,s,i=!1){let a=await Jt(e,t),c={oldHash:r??te,newHash:o,...a,message:s};await Ke(e,n,c),i&&n!=="HEAD"&&await Ke(e,"HEAD",c)}var Fe=Ee(()=>{"use strict";dt();xn();le();$n();dt()});function Zd(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let c=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:c}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^{([^}]*)}$/);if(i&&i[1]!==void 0&&i[2]!==void 0){t.unshift({type:"peel",target:i[2]}),n=i[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let c=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:c}),n=a[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function Jd(e,t){let n=await uc(e,t);if(n.length===0)return null;if(n.length>1)throw new li(t);return n[0]}async function Qd(e,t){if(t==="HEAD"||t==="@")return F(e,"HEAD");if(Ec.includes(t))return F(e,t);if(/^[0-9a-f]{40}$/.test(t))return await zt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Jd(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await F(e,t);if(s)return s}let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);if(r)return r;let o=await F(e,`refs/remotes/${t}`);return o||null}function eu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Ec)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function tu(e,t,n){let r=eu(t),o=await Je(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 nu(e,t,n){if(n===""||n==="commit")try{return await _e(e,t)}catch{return null}if(n==="tree"){let o;try{o=await _e(e,t)}catch{return null}return(await j(e,o)).tree}return(await we(e,t)).type!==n?null:t}async function Be(e,t){let{base:n,reflogIndex:r,suffixes:o}=Zd(t),s;if(r!==void 0?s=await tu(e,n,r):s=await Qd(e,n),!s)return null;o.some(a=>a.type==="tilde"||a.type==="caret")&&(s=await _e(e,s));for(let a of o)if(a.type==="peel"){if(!s)return null;s=await nu(e,s,a.target)}else if(a.type==="tilde")for(let c=0;c<a.n;c++){if(!s)return null;let f=await j(e,s);if(f.parents.length===0||(s=f.parents[0]??null,!s))return null}else{if(a.n===0)continue;if(!s)return null;let c=await j(e,s);if(a.n>c.parents.length||(s=c.parents[a.n-1]??null,!s))return null}return s}function Gs(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Ec,li,mn=Ee(()=>{"use strict";oe();Fe();ue();Ec=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];li=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function ft(e,t){return e.lstat?e.lstat(t):e.stat(t)}function hn(e){return typeof e=="string"?e==="120000":e===40960}async function Yr(e,t){if((await ft(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return ru.encode(r)}return e.readFileBuffer(t)}async function Tn(e,t){let n=await Yr(e,t);return yt("blob",n)}var ru,Yn=Ee(()=>{"use strict";oe();ru=new TextEncoder});function vn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=kc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=kc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=Cn(a),f=o.padStart(6,"0");t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Rc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=su.encode(`${i} ${s.name}\0`),c=It(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 su,kc,Ls=Ee(()=>{"use strict";dt();su=new TextEncoder,kc=new TextDecoder});async function Ge(e,t){return xc(e,t,"")}async function xc(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:ou(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),l=o.get(f);l||(l=[],o.set(f,l)),l.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await xc(e,a,c);r.push({mode:zr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===zr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===zr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Rc({type:"tree",entries:r});return $e(e,"tree",s)}async function Ve(e,t,n=""){let r=await we(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=vn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===zr.DIRECTORY){let c=await Ve(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function ce(e,t){if(!t)return new Map;let n=await Ve(e,t);return new Map(n.map(r=>[r.path,r]))}async function We(e,t,n){let r=await ce(e,t),o=await ce(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Oe(i.path,a.path))}function ou(e){return e.toString(8).padStart(6,"0")}var Te=Ee(()=>{"use strict";se();oe();Ls();ci()});function Cc(e){return/^[a-zA-Z0-9]$/.test(e)}function iu(e){return/^[a-zA-Z]$/.test(e)}function au(e){return e>="0"&&e<="9"}function di(e){return e>="A"&&e<="Z"}function ui(e){return e>="a"&&e<="z"}function Pc(e){return/^\s$/.test(e)}function cu(e){return e===" "||e===" "}function hi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function fu(e){return hi(e)&&!Pc(e)}function lu(e){return hi(e)&&!Cc(e)&&e!==" "}function du(e){let t=e.charCodeAt(0);return t<32||t===127}function uu(e){return/^[0-9a-fA-F]$/.test(e)}function Xr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function mi(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(!Xr(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 l=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((l-1<1||e[l-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&mi(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 l=n.indexOf("/",r);if(l===-1)return-1;r=l+1,t++;break}for(;!(r>=n.length);){if(!mu(e[t])){let d=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==d;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let l=mi(e,t,n,r,o);if(l!==1){if(!f||l!==-2)return l}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 l=!1,d="",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],Xr(c,m,s)&&(l=!0)}else if(m==="-"&&d&&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=d,p=m;if(c>=h&&c<=p&&(l=!0),s){if(ui(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(di(c)){let g=c.toLowerCase();g>=h&&g<=p&&(l=!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="[",Xr(c,m,s)&&(l=!0);else{let g=e.slice(h,h+p);hu(g,c,s)&&(l=!0),m=""}}else Xr(c,m,s)&&(l=!0);d=m,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!Xr(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function mu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function hu(e,t,n){switch(e){case"alnum":return Cc(t);case"alpha":return iu(t);case"blank":return cu(t);case"cntrl":return du(t);case"digit":return au(t);case"graph":return fu(t);case"lower":return ui(t)||n&&di(t);case"print":return hi(t);case"punct":return lu(t);case"space":return Pc(t);case"upper":return di(t)||n&&ui(t);case"xdigit":return uu(t);default:return!1}}function Xn(e,t,n=0){return mi(e,0,t,0,n)===0?0:1}var _s=Ee(()=>{"use strict"});function Sc(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 pu(e){return Sc(e)===e.length}function gu(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|=Ns,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=$c);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Oc);let a=Math.min(Sc(o),s);return o[0]==="*"&&pu(o.slice(1))&&(r|=Ic),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function Zr(e,t,n){let r=[];for(let o of e.split(`
|
|
41
|
+
`)){let s=gu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function wu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Ic){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return Xn(n,e,2)===0}function bu(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 Xn(r,a,2)===0}function pi(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&$c&&!t)){if(s.flags&Oc){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(wu(r,s))return s;continue}if(bu(e,s))return s}}return null}function nn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=pi(t,n,o);if(s)return s.flags&Ns?"not-ignored":"ignored"}if(e.excludeFile){let r=pi(t,n,e.excludeFile);if(r)return r.flags&Ns?"not-ignored":"ignored"}if(e.globalExclude){let r=pi(t,n,e.globalExclude);if(r)return r.flags&Ns?"not-ignored":"ignored"}return"undecided"}async function pr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=S(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Zr(r,"",n)}catch{}try{let r=await ke(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Zr(o,"",r)}catch{}}catch{}return t}function Zn(e,t,n,r){let s=Zr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Oc,Ic,$c,Ns,Us=Ee(()=>{"use strict";Ne();le();_s();Oc=1,Ic=4,$c=8,Ns=16});async function St(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=S(e.workTree,s.path),a;try{a=await ft(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 Tn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await et(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Oe(s.path,i.path))}async function at(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=S(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&hn(t.mode)&&e.fs.symlink){await ft(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let i=Eu.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 Tc(e,t){let n=await Ve(e,t);for(let r of n)await at(e,r)}async function rn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=S(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await ft(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=yu.encode(f),d=await $e(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...Ie(),size:l.byteLength}};return{index:bt(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await $e(e,"blob",s),a=o.mode!=null?ku(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Ie(),size:s.byteLength}};return{index:bt(t,c),hash:i}}async function et(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await pr(e);let c=S(t,".gitignore");try{let f=await e.fs.readFile(c);s=Zn(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=S(t,c),l=n?`${n}/${c}`:c,d=await ft(e.fs,f);if(d.isSymbolicLink){if(s&&nn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&nn(s,l,!0)==="ignored")continue;let u=await et(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(d.isFile){if(s&&nn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function ku(e){return e>511?e:e&73?33261:33188}async function Jn(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await Jn(e,Zt(t),n))}var yu,Eu,tt=Ee(()=>{"use strict";se();Us();Pe();oe();le();Yn();Te();yu=new TextEncoder,Eu=new TextDecoder});function gi(e){return e.existsOnDisk&&e.indexHash===null}async function Ru(e,t,n){let r=await Promise.all(t.map(h=>ce(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await et(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await et(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of d){let p=null,g=null,w=null,y=null,x=null;if(r.length===1){let O=u(0,h);w=O?.hash??null,x=O?.mode??null}else if(r.length===2){let O=u(0,h),H=u(1,h);g=O?.hash??null,y=O?.mode??null,w=H?.hash??null,x=H?.mode??null}else if(r.length>=3){let O=u(0,h),H=u(1,h),G=u(2,h);p=O?.hash??null,g=H?.hash??null,y=H?.mode??null,w=G?.hash??null,x=G?.mode??null}let k=o.get(h)?.hash??null,E=s.has(h)?1:0,R=i.has(h),P,C=async()=>P!==void 0?P:R?(P=!(await c()).has(h),P):(P=!1,!1),T,D=async()=>{if(T!==void 0)return T;if(!R||!e.workTree)return T=null,null;let O=S(e.workTree,h);try{T=await Tn(e.fs,O)}catch{T=null}return T};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:E,existsOnDisk:R,isIgnoredOnDisk:C,getWorktreeHash:D,headMode:y,remoteMode:x})}return m}function Bs(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 Ws(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 xu(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 Cu(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=xu(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await Pu(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function Pu(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":gi(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 gi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return gi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function Ou(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 l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:d,stage:0,stat:Ie()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:m});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Oe(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function qs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Iu){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(l=>` ${l}`).join(`
|
|
42
42
|
`);r.push(`${i(t.operationName)}
|
|
43
43
|
${f}
|
|
44
44
|
${a(n)}
|
|
45
45
|
`)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
|
|
46
|
-
`:"",exitCode:t.errorExitCode}}async function
|
|
46
|
+
`:"",exitCode:t.errorExitCode}}async function Qn(e,t,n,r){let o=await Ru(e,t,n),s=new Map(o.map(l=>[l.path,l])),i=new Map;for(let l of o){let d=r.mergeFn(l,r);i.set(l.path,d)}let a=await Cu(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:qs(a,r)};let{newEntries:c,worktreeOps:f}=Ou(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function De(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){let s=S(n,o.path);o.type==="delete"?await ft(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await at(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await Jn(e.fs,Zt(o),n)}async function Hn(e,t,n,r){return Qn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Ws,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function vc(e,t,n,r){return Qn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Ws,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function pn(e,t,n){return Qn(e,[{label:"target",treeHash:t}],n,{mergeFn:Bs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function zs(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:je(n)},i=await Qn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Bs,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.
|
|
47
47
|
`):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
|
|
48
|
-
`);return c.length>0&&(i.errorOutput=
|
|
49
|
-
`,128)),i}if(e.workTree&&o.size>0){let a=await
|
|
50
|
-
`,exitCode:128}}function
|
|
51
|
-
`){return $t(e)?
|
|
48
|
+
`);return c.length>0&&(i.errorOutput=L(c.join("")+`fatal: Could not reset index file to revision '${a}'.
|
|
49
|
+
`,128)),i}if(e.workTree&&o.size>0){let a=await ce(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var Iu,sn=Ee(()=>{"use strict";se();Pe();le();Yn();Te();tt();Iu=[{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 I(e){return{stdout:"",stderr:`fatal: ${e}
|
|
50
|
+
`,exitCode:128}}function L(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){let r=await Vn(e,t);return r?n?{...r,...n}:r:$u}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Xe(e){return e.workTree?null:Su}async function Ze(e){let t=await Z(e);return t||I("your current branch does not have any commits yet")}function gn(e,t,n=`fatal: Exiting because of an unresolved conflict.
|
|
51
|
+
`){return $t(e)?L(`error: ${t} is not possible because you have unmerged files.
|
|
52
52
|
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
|
|
53
53
|
hint: as appropriate to mark resolution and make a commit.
|
|
54
|
-
`+n,128):null}async function
|
|
54
|
+
`+n,128):null}async function Tt(e,t,n){let r=await Be(e,t);return r||I(n??`bad revision '${t}'`)}async function ve(e,t,n){let r=await Be(e,t);if(!r)return I(n??`bad revision '${t}'`);try{let o=await _e(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return I(n??`bad revision '${t}'`)}}async function Qe(e,t){try{return await Mr(e,t)}catch(n){return I(n.message)}}async function on(e,t){try{return await Os(e,t)}catch(n){return I(n.message)}}function gr(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 Oe(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?ct(e.workTree,t):""}function Y(e){return e.slice(0,7)}function fe(e){let t=e.indexOf(`
|
|
55
55
|
`);return t===-1?e:e.slice(0,t)}function Kt(e){return I(`ambiguous argument '${e}': unknown revision or path not in the working tree.
|
|
56
56
|
Use '--' to separate paths from revisions, like this:
|
|
57
|
-
'git <command> [<revision>...] -- [<file>...]'`)}function
|
|
57
|
+
'git <command> [<revision>...] -- [<file>...]'`)}function vt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${Y(t)}] ${fe(n)}`}async function An(e,t,n){if(!await F(e,n.operationRef))return n.noOpError;let o=await F(e,"ORIG_HEAD")??await Z(e);if(!o)return I(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Z(e),i=await j(e,o),a=await K(e),c=await zs(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await In(e,o),await ie(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps),s&&((await J(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await re(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function mt(e,t,n,r,o,s){let i=tn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await $e(e,"commit",i);return await In(e,a),a}function an(e){return e.split(`
|
|
58
58
|
`).filter(t=>!t.startsWith("#")).map(t=>t.trimEnd()).join(`
|
|
59
59
|
`).replace(/\n+$/,`
|
|
60
|
-
`)}function
|
|
60
|
+
`)}function Ht(e){return e.endsWith(`
|
|
61
61
|
`)?e:`${e}
|
|
62
|
-
`}var $u,
|
|
63
|
-
`)}function
|
|
64
|
-
`)}function
|
|
65
|
-
Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await K(s),d=[],u=[];for(let p of f)
|
|
62
|
+
`}var $u,Su,se=Ee(()=>{"use strict";xn();Pe();oe();dn();le();Fe();ue();$n();mn();sn();$u=I("not a git repository (or any of the parent directories): .git"),Su=I("this operation must be run in a work tree")});var jc={};id(jc,{CommitHeap:()=>Dn,countAheadBehind:()=>Ei,findOrphanedCommits:()=>ki,walkCommits:()=>At});async function*At(e,t,n){if(n?.topoOrder){yield*Mu(e,t,n);return}let r=await Mc(e,n?.exclude),o=new Set(r),s=new Dn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let c of a)o.has(c)||s.push(await wr(e,c));for(;s.size>0;){let c=s.pop();if(o.has(c.hash)||(o.add(c.hash),yield c,i?.has(c.hash)))continue;let f=n?.firstParent?c.commit.parents.slice(0,1):c.commit.parents;for(let l of f)if(!o.has(l))try{s.push(await wr(e,l))}catch{}}}async function*Mu(e,t,n){let r=await Mc(e,n?.exclude),o=new Set(r),s=new Dn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let m of a)o.has(m)||s.push(await wr(e,m));let c=[],f=new Map;for(;s.size>0;){let m=s.pop();if(o.has(m.hash)||(o.add(m.hash),f.set(m.hash,c.length),c.push(m),i?.has(m.hash)))continue;let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h)if(!o.has(p))try{s.push(await wr(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let m of c){let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let u=[];for(let m=l-1;m>=0;m--)d[m]===0&&u.push(m);for(;u.length>0;){let m=u.pop();yield c[m];let h=n?.firstParent?c[m].commit.parents.slice(0,1):c[m].commit.parents;for(let p of h){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&u.push(g)}}}}async function Ei(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of At(e,t))r.add(a.hash);let o=new Set;for await(let a of At(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function ki(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await _e(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of At(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Dn;for(f.push(await wr(e,t));f.size>0&&a.length<r;){let l=f.pop();if(!c.has(l.hash)&&(c.add(l.hash),!i.has(l.hash))){a.push({hash:l.hash,subject:fe(l.commit.message)});for(let d of l.commit.parents)c.has(d)||f.push(await wr(e,d))}}return a}async function Mc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}async function wr(e,t){return{hash:t,commit:await j(e,t)}}var Dn,tr=Ee(()=>{"use strict";se();oe();ue();Dn=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 Mo=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 ba(e){return new Mo({_kind:"arg",type:e,required:!0})}function ya(){return ba("string")}function Ea(){return ba("number")}var ks=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 jo=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 ka(e){return new jo({_kind:"option",type:e})}function Ra(){return ka("string")}function xa(){return ka("number")}var Q={string:Ra,number:xa};function v(){return new ks}var q={string:ya,number:Ea};function ad(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 Go(e){return e.map(ad).join(`
|
|
63
|
+
`)}function cd(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 Rs(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:cd(e,s)})).filter(s=>s.distance<=r&&s.distance>0).sort((s,i)=>s.distance-i.distance).slice(0,2).map(s=>s.candidate)}function Ca(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=Hr(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],l=0;for(;l<n.length;){let u=n[l];if(u==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,l++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Rs(h,x).map(b=>`--${b}`)}),l++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,l++;continue}let w=p??n[++l];if(w===void 0){o.push({type:"missing_value",name:g.key}),l++;continue}let y=vr(w,g.def.type,g.key,o);y!==void 0&&(a[g.key]=y),l++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),y=w.length>0?w:n[++l];if(y===void 0){o.push({type:"missing_value",name:g.key});break}let x=vr(y,g.def.type,g.key,o);x!==void 0&&(a[g.key]=x);break}l++;continue}c.push(u),l++}let d=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(d);p.length>0?a[h]=p.map(g=>vr(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]=[],d=c.length}else{let p=c[d];p!==void 0?(a[h]=vr(p,m.type,h,o),d++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(d<c.length)for(let u=d;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=vr(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 vr(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 Hr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Lo(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 l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${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",l=c.variadic?`${f}...`:f,d=[];c.description&&d.push(c.description),c.required&&d.push("(required)"),c.default!==void 0&&d.push(`(default: ${JSON.stringify(c.default)})`),i.push([l,d.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${f}`)}else t.push(` ${c}`);t.push("")}let s=fd(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(`
|
|
64
|
+
`)}function fd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Hr(i);if(a._kind==="flag"){let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c}`);let d=[];f.description&&d.push(f.description),f.counted&&d.push("(counted)"),f.default!==void 0&&d.push(`(default: ${f.default})`),r.push([l.join(" "),d.join(" ")])}else{let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c} <${f.type}>`);let d=[];f.description&&d.push(f.description),f.required&&d.push("(required)"),f.default!==void 0&&d.push(`(default: ${JSON.stringify(f.default)})`),f.env&&d.push(`[env: ${f.env}]`),r.push([l.join(" "),d.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 Pa(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Oa(e){return e?e.map(t=>t._def):[]}var xs=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,Pa(n.options),Oa(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=Hr(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(ld(t))return{stdout:Lo(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ca(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:Go(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=Rs(o,[...this.children.keys()]);return{stdout:"",stderr:Go([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:Lo(this),stderr:"",exitCode:0}}};function _o(e,t){return new xs(e,t.description,Pa(t.options),Oa(t.args),t.examples??[],t.handler,t.transformArgs)}function ld(e){return e.some(t=>t==="--help"||t==="-h")}se();Us();Pe();le();_s();var Vs=1,wi=2,Ks=4,bi=8,Jr=16,Ac=new Set(["*","?","[","\\"]),vu={glob:Vs,literal:wi,icase:Ks,top:bi,exclude:Jr};function er(e){for(let t=0;t<e.length;t++)if(Ac.has(e[t]))return!0;return!1}function Hu(e){for(let t=0;t<e.length;t++)if(Ac.has(e[t]))return t;return e.length}function Hc(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 Ue(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 l of f.split(",")){let d=vu[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=bi,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=Jr,r=r.slice(2));n&wi&&n&Vs&&(n&=~Vs);let o;n&bi||t===""?o=Hc(r):o=Hc(`${t}/${r}`);let s=!!(n&wi),i=s?!1:er(o),a=s?o.length:Hu(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function Ys(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&Ks),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&Ks){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&Vs&&(i|=2),o&Ks&&(i|=1),Xn(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&Jr?Ys(o,t)&&(r=!0):Ys(o,t)&&(n=!0);return n&&!r}tt();function Dc(e,t){e.command("add",{description:"Add file contents to the index",args:[q.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:v().alias("A").describe("Add changes from all tracked and untracked files"),force:v().alias("f").describe("Allow adding otherwise ignored files"),update:v().alias("u").describe("Update tracked files"),"dry-run":v().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await K(s);return p=await yi(s,p,a,"",c),n["dry-run"]||await ie(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
|
|
65
|
+
Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await K(s),d=[],u=[];for(let p of f)er(p)?u.push(p):d.push(p);let m=[];for(let p of d){let g=Ot(r.cwd,p),w=ct(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return I(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=l.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`)),k=await Du(s,a,w,b);if(k){b&&((await r.fs.stat(g)).isDirectory?l=await yi(s,l,g,w,c):l=(await rn(s,l,w)).index),m.push(k);continue}}if((await r.fs.stat(g)).isDirectory)l=await yi(s,l,g,w,c);else{let b=l.entries.find(E=>E.path===w&&E.stage===0)?.hash,k=await rn(s,l,w);l=k.index,c.actions&&k.hash!==b&&c.actions.push(`add '${w}'
|
|
66
66
|
`)}}else if(l.entries.some(b=>b.path===w||b.path.startsWith(`${w}/`))){if(c.actions)for(let b of l.entries)(b.path===w||b.path.startsWith(`${w}/`))&&c.actions.push(`remove '${b.path}'
|
|
67
|
-
`);l={...l,entries:l.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return I(`pathspec '${p}' did not match any files`)}if(m.length>0)return n["dry-run"]||await ie(s,l),
|
|
67
|
+
`);l={...l,entries:l.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return I(`pathspec '${p}' did not match any files`)}if(m.length>0)return n["dry-run"]||await ie(s,l),L(`The following paths are ignored by one of your .gitignore files:
|
|
68
68
|
${m.join(`
|
|
69
69
|
`)}
|
|
70
70
|
hint: Use -f if you really want to add them.
|
|
71
71
|
hint: Disable this message with "git config set advice.addIgnoredFile false"
|
|
72
|
-
`);if(u.length>0){let p=await
|
|
72
|
+
`);if(u.length>0){let p=await Au(s,r.cwd,l,u,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await ie(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function Au(e,t,n,r,o){let s=e.workTree,i=ut(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&Ys(a[u],d)&&(c[u]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!ye(a,d.path))continue;f(d.path);let u=S(s,d.path);if(await e.fs.exists(u)){let m=await rn(e,n,d.path);n=m.index,o?.actions&&m.hash!==d.hash&&o.actions.push(`add '${d.path}'
|
|
73
73
|
`)}else o?.actions&&o.actions.push(`remove '${d.path}'
|
|
74
|
-
`),l.push(d.path)}for(let d of l)n=it(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(m=>m.path)),u=await et(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(d.has(m)||!
|
|
75
|
-
`),n=(await rn(e,n,m)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&
|
|
74
|
+
`),l.push(d.path)}for(let d of l)n=it(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(m=>m.path)),u=await et(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(d.has(m)||!ye(a,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
|
|
75
|
+
`),n=(await rn(e,n,m)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&Jr))return{index:n,error:I(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function yi(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 l=S(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,u=await rn(e,t,f.path);t=u.index,o?.actions&&(d||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
|
|
76
76
|
`)}else o?.actions&&o.actions.push(`remove '${f.path}'
|
|
77
77
|
`),a.push(f.path)}for(let f of a)t=it(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await et(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
|
|
78
|
-
`),t=(await rn(e,t,d)).index}}return t}async function
|
|
79
|
-
`);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Xs(e){let t=(await
|
|
80
|
-
`)}async function Zs(e){let t=await
|
|
78
|
+
`),t=(await rn(e,t,d)).index}}return t}async function Du(e,t,n,r){let o=await pr(e);try{let i=await e.fs.readFile(S(t,".gitignore"));o=Zn(o,i,"",S(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=S(t,a);if(nn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(S(c,".gitignore"));o=Zn(o,f,a,S(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(S(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(nn(o,n,i)==="ignored")return n}return null}se();se();tr();oe();le();ue();async function Ce(e,t){let n=S(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Se(e,t,n){await e.fs.writeFile(S(e.gitDir,t),n)}async function pe(e,t){let n=S(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function Qr(e){await de(e,"MERGE_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"SQUASH_MSG")}async function Dt(e){await de(e,"CHERRY_PICK_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG")}async function Mt(e){await de(e,"REVERT_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG")}async function nr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await de(e,t);await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"SQUASH_MSG")}var Ri="DETACH_POINT";async function Gc(e,t){await e.fs.writeFile(S(e.gitDir,Ri),t)}async function ht(e){let t=S(e.gitDir,Ri);await e.fs.exists(t)&&await e.fs.rm(t)}async function es(e){let t=S(e.gitDir,Ri);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}le();ue();async function kt(e){let t=await Ce(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ts(e){let t=await Ce(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
|
|
79
|
+
`);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Xs(e){let t=(await Ce(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ts(e),o=await F(e,`refs/bisect/${n}`),s=[],i=[],a=await ge(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await Ce(e,"BISECT_HEAD")!=null||await e.fs.exists(S(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(S(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function Rt(e,t){let n=await Ce(e,"BISECT_LOG")??"";await Se(e,"BISECT_LOG",n+t+`
|
|
80
|
+
`)}async function Zs(e){let t=await ge(e,"refs/bisect");for(let r of t)await de(e,r.name);await pe(e,"BISECT_EXPECTED_REV"),await pe(e,"BISECT_ANCESTORS_OK"),await pe(e,"BISECT_LOG"),await pe(e,"BISECT_TERMS"),await pe(e,"BISECT_NAMES"),await pe(e,"BISECT_FIRST_PARENT"),await pe(e,"BISECT_HEAD"),await pe(e,"BISECT_START");let n=S(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Lc(e,t,n,r,o){let s=[],i=new Map;for await(let g of At(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:fe(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,y=[g.hash],x=0;for(;x<y.length;){let b=y[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let k=i.get(b);if(k)for(let E of k)!w.has(E)&&c.has(E)&&y.push(E)}f.set(g.hash,w.size)}let l=s[0].hash,d=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}let u=!1;if(d===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}}let m=s.find(g=>g.hash===l),h=ju(a),p=Gu(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function ju(e){return Math.floor((e-1)/2)}function Gu(e){return e<=1?0:Math.ceil(Math.log2(e))}function _c(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
|
|
81
81
|
`:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
|
|
82
82
|
`:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
|
|
83
|
-
`}function
|
|
83
|
+
`}function Nc(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
|
|
84
84
|
[${e.hash}] ${e.subject}
|
|
85
|
-
`}async function
|
|
85
|
+
`}async function Fc(e,t){let n=await j(e,t),r=fe(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
|
|
86
86
|
`;return i+=`commit ${t}
|
|
87
87
|
`,i+=`Author: ${n.author.name} <${n.author.email}>
|
|
88
88
|
`,i+=`Date: ${s}
|
|
89
89
|
`,i+=`
|
|
90
90
|
`,i+=` ${r}
|
|
91
91
|
`,i+=`
|
|
92
|
-
`,i}se();
|
|
93
|
-
`),await e.fs.writeFile(
|
|
94
|
-
`),await e.fs.writeFile(
|
|
95
|
-
`),await e.fs.writeFile(
|
|
96
|
-
`),await e.fs.writeFile(
|
|
97
|
-
`),await e.fs.writeFile(
|
|
98
|
-
`),await e.fs.writeFile(
|
|
92
|
+
`,i}se();tr();Ne();Pe();oe();le();Fe();ue();se();tr();Ne();Pe();oe();le();oe();dn();le();function br(e){return S(e.gitDir,"rebase-merge")}async function jt(e){return e.fs.exists(br(e))}async function pt(e){let t=br(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(S(t,"head-name")),r=await e.fs.readFile(S(t,"orig-head")),o=await e.fs.readFile(S(t,"onto")),s=Number.parseInt(await e.fs.readFile(S(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(S(t,"end")),10),a=await e.fs.exists(S(t,"git-rebase-todo"))?S(t,"git-rebase-todo"):S(t,"todo"),c=Uc(await e.fs.readFile(a)),f=await e.fs.exists(S(t,"done"))?await e.fs.readFile(S(t,"done")):"",l=Uc(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function xi(e,t){let n=br(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(S(n,"head-name"),`${t.headName}
|
|
93
|
+
`),await e.fs.writeFile(S(n,"orig-head"),`${t.origHead}
|
|
94
|
+
`),await e.fs.writeFile(S(n,"onto"),`${t.onto}
|
|
95
|
+
`),await e.fs.writeFile(S(n,"msgnum"),`${String(t.msgnum)}
|
|
96
|
+
`),await e.fs.writeFile(S(n,"end"),`${String(t.end)}
|
|
97
|
+
`),await e.fs.writeFile(S(n,"git-rebase-todo"),Qs(t.todo)),await e.fs.writeFile(S(n,"done"),Qs(t.done)),await e.fs.writeFile(S(n,"interactive"),"")}async function qc(e){let t=br(e),n=await pt(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(S(t,"msgnum"),`${String(n.msgnum)}
|
|
98
|
+
`),await e.fs.writeFile(S(t,"git-rebase-todo"),Qs(n.todo)),await e.fs.writeFile(S(t,"done"),Qs(n.done))}async function Ci(e){let t=br(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function eo(e,t,n){let r=br(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(S(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
|
|
99
99
|
GIT_AUTHOR_EMAIL='${n.email}'
|
|
100
100
|
GIT_AUTHOR_DATE='${o}'
|
|
101
|
-
`),await e.fs.writeFile(
|
|
102
|
-
`)}function
|
|
101
|
+
`),await e.fs.writeFile(S(r,"stopped-sha"),`${t}
|
|
102
|
+
`)}function Uc(e){let t=[];for(let n of e.split(`
|
|
103
103
|
`)){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 Qs(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
|
|
104
104
|
`)}
|
|
105
|
-
`}async function
|
|
106
|
-
`))l.push(D);d=!0}}if(d&&(w||u||m||h)&&l.push(""),w&&h)
|
|
105
|
+
`}async function zc(e,t,n){let r=new Map,[o,s]=await Promise.all([Bc(e,t,r),Bc(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 Wc(e,r,n,i),left:await Wc(e,r,t,a)}}async function Bc(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await Js(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function Wc(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 l=await Js(e,f,t);for(let d of l.commit.parents)r.has(d)&&o.set(d,(o.get(d)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await Js(e,f,t));s.sort((f,l)=>f.commit.committer.timestamp-l.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 l=await Js(e,f,t);l.commit.parents.length<=1&&a.push(l);for(let d of l.commit.parents)if(r.has(d)&&!c.has(d)){let u=(o.get(d)??0)-1;o.set(d,u),u<=0&&i.push(d)}}return a.reverse(),a}async function Js(e,t,n){let r=n.get(t);if(r)return r;let o=await we(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:en(o.content)};return n.set(t,s),s}ue();oe();function yr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Lu(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=yr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&yr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var _u=50;async function nt(e,t,n=_u){let r=new Map,o=[],s=[],i=[];for(let l of t)if(l.status==="deleted"&&l.oldHash){let d=r.get(l.oldHash)??[];d.push(l),r.set(l.oldHash,d),o.push(l)}else l.status==="added"&&l.newHash?s.push(l):i.push(l);let a=[],c=[];for(let l of s){let d=l.newHash;if(!d){c.push(l);continue}let u=r.get(d);if(u&&u.length>0){let m=Lu(u,l.path);m&&a.push({oldPath:m.path,newPath:l.path,oldHash:m.oldHash??d,newHash:d,similarity:100,oldMode:m.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await Nu(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await Bu(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function Nu(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=yr(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=yr(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 l=t[c],d=n[f];if(!l?.oldHash||!d?.newHash||l.oldHash===d.newHash)continue;let u=await Et(e,l.oldHash),m=await Et(e,d.newHash),h=Uu(u,m);h<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:h,oldMode:l.oldMode,newMode:d.newMode})}return i}var Kc=107927;function to(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))%Kc;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%Kc;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 Fu(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 Uu(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Vc(e.length,to(e),t.length,to(t))}function Vc(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Fu(t,r);return Math.floor(i*100/o)}async function Bu(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Et(e,l.oldHash);o.push({size:d.length,chunks:to(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Et(e,l.newHash);s.push({size:d.length,chunks:to(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],u=o[l];if(!(!d||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=Vc(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=yr(d.path)===yr(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:m})}}}i.sort((l,d)=>d.similarity-l.similarity||d.nameScore-l.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:l,delIdx:d,addIdx:u}of i){if(a.has(d)||c.has(u))continue;a.add(d),c.add(u);let m=t[d],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:l,oldMode:m.oldMode,newMode:h.newMode})}return f}function Mn(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 l=Math.max(0,n-o-a),d=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Te();tt();async function rt(e,t){let n=await J(e),r=await Z(e),o,s=!1;n&&n.type==="symbolic"?o=Re(n.target):(s=!0,o="HEAD detached");let i=t?.index??await K(e),a=Oi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Pi(e,c,i,a),d=await St(e,i),u=[],m=[];for(let g of d)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>Oe(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Ii(m,h);return Wu(e,r,s,o,i,l,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Yc(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 ${Y(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 ${Y(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Wu(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,u=await F(e,"CHERRY_PICK_HEAD"),m=await F(e,"REVERT_HEAD"),h=await F(e,"MERGE_HEAD"),p=!u&&!h,w=await jt(e)?await pt(e):null;if(n&&w){let P=Y(w.onto);l.push(`interactive rebase in progress; onto ${P}`)}else if(n){let P=await es(e);if(P){let C=t===P?"at":"from";l.push(`HEAD detached ${C} ${Y(P)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let P=await he(e),C=await wn(e,P,r);if(C){let T=rr(C,{abbreviated:f?.fromCommit});for(let D of T.trimEnd().split(`
|
|
106
|
+
`))l.push(D);d=!0}}if(d&&(w||u||m||h)&&l.push(""),w&&h)Yc(l,w),l.push(""),a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0;else if(w){let P=$t(o),C=await e.fs.exists(S(e.gitDir,"MERGE_MSG"));Yc(l,w);let D=w.headName==="detached HEAD"?null:Re(w.headName),O=Y(w.onto),H=D?` branch '${D}' on '${O}'`:"";if(P)l.push(`You are currently rebasing${H}.`),l.push(' (fix conflicts and then run "git rebase --continue")'),l.push(' (use "git rebase --skip" to skip this patch)'),l.push(' (use "git rebase --abort" to check out the original branch)');else if(C)l.push(`You are currently rebasing${H}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let G=H?`You are currently editing a commit while rebasing${H}.`:"You are currently editing a commit during a rebase.";l.push(G),l.push(' (use "git commit --amend" to amend the current commit)'),l.push(' (use "git rebase --continue" once you are satisfied with your changes)')}d=!0}else u?(l.push(`You are currently cherry-picking commit ${Y(u)}.`),a.length>0?l.push(' (fix conflicts and run "git cherry-pick --continue")'):l.push(' (all conflicts fixed: run "git cherry-pick --continue")'),l.push(' (use "git cherry-pick --skip" to skip this patch)'),l.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),d=!0):m?(l.push(`You are currently reverting commit ${Y(m)}.`),a.length>0?l.push(' (fix conflicts and run "git revert --continue")'):l.push(' (all conflicts fixed: run "git revert --continue")'),l.push(' (use "git revert --skip" to skip this patch)'),l.push(' (use "git revert --abort" to cancel the revert operation)'),d=!0):h&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await kt(e)){let C=(await Ce(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${C}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}let y=f?.isInitial??!t;y&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(P=>P.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',E=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),x&&l.push(x);for(let P of s)l.push(` ${Xc(P.status,P.path,P.displayPath)}`);l.push(""),E=!0}if(a.length>0){!E&&d&&l.push(""),l.push("Unmerged paths:"),p&&(t?l.push(' (use "git restore --staged <file>..." to unstage)'):l.push(' (use "git rm --cached <file>..." to unstage)')),a.some(C=>C.status==="deleted by us"||C.status==="deleted by them"||C.status==="both deleted")?l.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):l.push(' (use "git add <file>..." to mark resolution)');for(let C of a)l.push(` ${qu(C.status,C.path)}`);l.push(""),E=!0}if(i.length>0){!E&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(k),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let P of i)l.push(` ${Xc(P.status,P.path)}`);l.push(""),E=!0}if(c.length>0){!E&&d&&l.push(""),l.push("Untracked files:"),l.push(' (use "git add <file>..." to include in what will be committed)');for(let P of c)l.push(` ${P}`);l.push(""),E=!0}let R=s.length>0||!!h&&a.length===0;return!E&&d&&(f?.noWarn||R)&&l.push(""),!R&&!f?.noWarn&&(!E&&d&&i.length===0&&a.length===0&&c.length===0&&l.push(""),i.length>0||a.length>0?l.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?l.push('nothing added to commit but untracked files present (use "git add" to track)'):y?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
|
|
107
107
|
`)}
|
|
108
|
-
`}async function
|
|
108
|
+
`}async function Pi(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await ce(e,s),a=new Map(je(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:l}=await nt(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let m of f){let h=d[m.status];h&&u.push({path:m.path,status:h})}for(let m of l)u.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return u.sort((m,h)=>Oe(m.path,h.path))}function Oi(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)=>Oe(r.path,o.path))}function Ii(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 Xc(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function qu(e,t){return`${e}:`.padEnd(17)+t}async function wn(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 F(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await F(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:l,behind:d}=await Ei(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function Zc(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 rr(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
|
|
109
109
|
(use "git branch --unset-upstream" to fixup)
|
|
110
110
|
`;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
|
|
111
111
|
`;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}.
|
|
@@ -115,19 +115,19 @@ GIT_AUTHOR_DATE='${o}'
|
|
|
115
115
|
`}let n=`Your branch and '${e.upstream}' have diverged,
|
|
116
116
|
and have ${e.ahead} and ${e.behind} different commits each, respectively.
|
|
117
117
|
`;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
|
|
118
|
-
`}
|
|
119
|
-
`),await
|
|
120
|
-
`),await
|
|
121
|
-
`)}
|
|
122
|
-
`:""}function
|
|
123
|
-
`,exitCode:1}:null}async function ro(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");if(r)return
|
|
124
|
-
`):
|
|
125
|
-
`);for(let a of i)await at(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function
|
|
126
|
-
`);for(let c of a){let f=o.get(c);f&&(await at(e,{path:f.path,hash:f.hash,mode:f.mode}),s=bt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:
|
|
127
|
-
`);for(let f of c){let l=i.entries.find(m=>m.path===f&&m.stage===r),d=!l&&i.entries.find(m=>m.path===f&&m.stage===0),u=l||d;if(u)await at(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let m
|
|
128
|
-
`)}return{stdout:"",stderr:"",exitCode:0}}async function
|
|
129
|
-
`)}
|
|
130
|
-
`)}var
|
|
118
|
+
`}Te();sn();tt();async function no(e){let t=await Je(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 F(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function bn(e){let t="";return await F(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
|
|
119
|
+
`),await F(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
|
|
120
|
+
`),await nr(e),t}function zu(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(`
|
|
121
|
+
`)}
|
|
122
|
+
`:""}function jn(e){return e.entries.some(t=>t.stage>0)?{stdout:zu(e),stderr:`error: you need to resolve your current index first
|
|
123
|
+
`,exitCode:1}:null}async function ro(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");if(r)return Ku(e,t,n,r);let o=await K(e),s=t.map(a=>Ue(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))?L(`error: path '${t[0]}' is unmerged
|
|
124
|
+
`):L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
125
|
+
`);for(let a of i)await at(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Ku(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
126
|
+
`);for(let c of a){let f=o.get(c);f&&(await at(e,{path:f.path,hash:f.hash,mode:f.mode}),s=bt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Ie()}))}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}async function so(e,t,n,r,o){if(!e.workTree)return I("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await K(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)ye(a,f.path)&&c.add(f.path);if(c.size===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
127
|
+
`);for(let f of c){let l=i.entries.find(m=>m.path===f&&m.stage===r),d=!l&&i.entries.find(m=>m.path===f&&m.stage===0),u=l||d;if(u)await at(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let m=S(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 L(`error: path '${f}' does not have ${r===2?"our":"their"} version
|
|
128
|
+
`)}return{stdout:"",stderr:"",exitCode:0}}async function sr(e,t,n){if(!e.workTree)return"";let r=await Ve(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=S(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let d=await e.fs.readFileBuffer(f);i.set(c,await yt("blob",d))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let l=s.get(c);if(l===void 0){a.push(`D ${c}`);continue}let d=i.get(c);d===null?a.push(`D ${c}`):(l!==f||d!==void 0&&d!==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 l=c.slice(2),d=f.slice(2);return l<d?-1:l>d?1:0}),`${a.join(`
|
|
129
|
+
`)}
|
|
130
|
+
`)}var Jc=5;function Vu(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Jc?Jc-1:t,i=e.slice(0,o).map(c=>` ${Y(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
|
|
131
131
|
any of your branches:
|
|
132
132
|
|
|
133
133
|
${i.join(`
|
|
@@ -136,12 +136,12 @@ ${i.join(`
|
|
|
136
136
|
If you want to keep ${r} by creating a new branch, this may be a good time
|
|
137
137
|
to do so with:
|
|
138
138
|
|
|
139
|
-
git branch <new-branch-name> ${
|
|
139
|
+
git branch <new-branch-name> ${Y(e[0].hash)}
|
|
140
140
|
|
|
141
|
-
`}async function
|
|
142
|
-
`}async function oo(e,t,n){let r=await
|
|
143
|
-
`,exitCode:0};let a=await K(e),c=
|
|
144
|
-
${p}`,exitCode:0}}async function
|
|
141
|
+
`}async function $i(e,t){let n=await j(e,t);return`Previous HEAD position was ${Y(t)} ${fe(n.message)}
|
|
142
|
+
`}async function oo(e,t,n){let r=await ki(e,t,{targetHash:n});return r.length>0?Vu(r):t!==n?$i(e,t):""}async function or(e,t,n,r,o,s){let i=await J(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
|
|
143
|
+
`,exitCode:0};let a=await K(e),c=jn(a);if(c)return c;let f=await Z(e),d=(await j(e,r)).tree,u=null;if(f&&(u=(await j(e,f)).tree),u!==d){let x=await Hn(e,u,d,a);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await ie(e,a),await De(e,x.worktreeOps)}let m="";i?.type==="direct"&&f&&(m=await oo(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??te;await ze(e,"HEAD",n),await ht(e);let p=await bn(e);await re(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await sr(e,d,a),w=await he(e),y=await wn(e,w,t);return y&&(g+=rr(y)),{stdout:g,stderr:`${m}Switched to branch '${t}'
|
|
144
|
+
${p}`,exitCode:0}}async function Gn(e,t,n,r,o){let s=await K(e),i=jn(s);if(i)return i;let a=await Z(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Hn(e,l,f,s);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await ie(e,s),await De(e,x.worktreeOps)}let d=await J(e),u=d?.type==="direct"&&a===t;if(await X(e,"HEAD",t),!u){await Gc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??te;await re(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let m=await bn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=Y(t),p=fe(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await oo(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
|
|
145
145
|
`:w=`Note: switching to '${o.detachAdviceTarget}'.
|
|
146
146
|
|
|
147
147
|
You are in 'detached HEAD' state. You can look around, make experimental
|
|
@@ -160,93 +160,93 @@ Or undo this operation with:
|
|
|
160
160
|
Turn off this advice by setting config variable advice.detachedHead to false
|
|
161
161
|
|
|
162
162
|
HEAD is now at ${h} ${p}
|
|
163
|
-
`,w+=m,{stdout:await
|
|
164
|
-
`}async function ao(e,t){let n=await
|
|
165
|
-
`,stderr:"",exitCode:1};async function Si(e){let t=await
|
|
166
|
-
`,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:
|
|
163
|
+
`,w+=m,{stdout:await sr(e,f,s),stderr:w,exitCode:0}}async function Yu(e,t){if(t.startsWith("refs/remotes/")){if(!await F(e,t))return null;let s=t.slice(13).split("/");if(s.length<2)return null;let i=s[0],a=s.slice(1).join("/");return{remote:i,branch:a,ref:t}}let n=`refs/remotes/${t}`;if(await F(e,n)){let o=t.split("/");if(o.length<2)return null;let s=o[0],i=o.slice(1).join("/");return{remote:s,branch:i,ref:n}}return null}async function io(e,t,n){let r=await Yu(e,n);if(!r||await ke(e,"branch.autoSetupMerge")==="false")return"";let s=await he(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await Ye(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
|
|
164
|
+
`}async function ao(e,t){let n=await ge(e,"refs/remotes"),r=[];for(let o of n){let s=o.name.replace(/^refs\/remotes\//,"").split("/"),i=s[0];s.length>=2&&i&&s.slice(1).join("/")===t&&r.push({remote:i,ref:o.name})}if(r.length===1){let o=r[0];return{remote:o.remote,startPoint:o.ref,trackingRef:o.ref}}if(r.length>1){let o=await ke(e,"checkout.defaultRemote");if(o){let s=r.filter(i=>i.remote===o);if(s.length===1){let i=s[0];return{remote:i.remote,startPoint:i.ref,trackingRef:i.ref}}}}return null}oe();le();ue();mn();var Qc=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),rs={stdout:`You need to start by "git bisect start"
|
|
165
|
+
`,stderr:"",exitCode:1};async function Si(e){let t=await Ce(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Z(e);return n||I("no current commit")}function ef(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[q.string().name("subcommand").describe("Subcommand or custom term").optional(),q.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
|
|
166
|
+
`,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:Qu(a,o.env,t,s,i)}});Xu(n,t),Zu(n,t),em(n,t),tm(n,t),rm(n,t),sm(n,t),im(n,t),cm(n,t),fm(n,t)}function Xu(e,t){e.command("start",{description:"Start bisecting",args:[q.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":v().describe("Do not checkout the bisection commit"),"first-parent":v().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(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 Qc.has(a)?I(`'${a}' is not a valid term`):Qc.has(c)?I(`'${c}' is not a valid term`):a===c?I("'bad' and 'good' terms must be different"):tf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function tf(e,t,n,r,o,s,i,a){await kt(e)&&await Zs(e);let c=await J(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Z(e)??"HEAD",await Se(e,"BISECT_START",f+`
|
|
167
167
|
`),await Se(e,"BISECT_TERMS",`${o}
|
|
168
168
|
${s}
|
|
169
169
|
`),await Se(e,"BISECT_NAMES",`
|
|
170
|
-
`),a&&await Se(e,"BISECT_FIRST_PARENT",""),i){let u=await
|
|
171
|
-
`,exitCode:1}:
|
|
172
|
-
`,stderr:"",exitCode:0}}})}async function
|
|
173
|
-
`,exitCode:1}}})}function
|
|
174
|
-
`)){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],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];d=await
|
|
175
|
-
`;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await Si(e);if(M(u))return u;await
|
|
176
|
-
`,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Xs(e),l=c===0?f.termGood:f.termBad,d=await
|
|
177
|
-
`,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function
|
|
178
|
-
`,exitCode:1};let{termBad:i,termGood:a}=await
|
|
170
|
+
`),a&&await Se(e,"BISECT_FIRST_PARENT",""),i){let u=await Z(e);u&&await Se(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await Tt(e,u);if(M(m))return m;await X(e,`refs/bisect/${o}`,m);let h=await j(e,m);await Rt(e,`# ${o}: [${m}] ${fe(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await Tt(e,g);if(M(w))return w;await X(e,`refs/bisect/${s}-${w}`,w);let y=await j(e,w);await Rt(e,`# ${s}: [${w}] ${fe(y.message)}`)}}let l=r.map(u=>`'${u}'`),d=l.length>0?` ${l.join(" ")}`:"";return await Rt(e,`git bisect start${d}`),ss(e,t,n)}function Zu(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[q.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:Ju(s,o.env,t,n,r.rev)}})}async function Ju(e,t,n,r,o){if(!await kt(e))return rs;let s=await ts(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ns(e,t,n,i,s,o)}async function Qu(e,t,n,r,o){if(!await kt(e))return rs;let s=await ts(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
|
|
171
|
+
`,exitCode:1}:ns(e,t,n,r,s,o[0])}async function ns(e,t,n,r,o,s){let i;if(s){let f=await Tt(e,s);if(M(f))return f;i=f}else{let f=await Si(e);if(M(f))return f;i=f}let a=await j(e,i),c=fe(a.message);return r===o.termBad?await X(e,`refs/bisect/${o.termBad}`,i):await X(e,`refs/bisect/${o.termGood}-${i}`,i),await Rt(e,`# ${r}: [${i}] ${c}`),await Rt(e,`git bisect ${r} ${i}`),ss(e,t,n)}function em(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[q.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await kt(s))return rs;let i=n.revs??[];if(i.length===0){let a=await Si(s);if(M(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 l=await Tt(s,a);if(M(l))return l;c=l}await X(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await Rt(s,`# skip: [${c}] ${fe(f.message)}`),await Rt(s,`git bisect skip ${c}`)}return ss(s,r.env,t)}})}function tm(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[q.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await kt(s)?nm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
|
|
172
|
+
`,stderr:"",exitCode:0}}})}async function nm(e,t,n,r){let o=(await Ce(e,"BISECT_START"))?.trim()??"";if(await Zs(e),r){let s=await Tt(e,r);return M(s)?s:Gn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await F(e,s);if(i)return or(e,o,s,i,t,n);let a=await Be(e,o);if(a)return Gn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function rm(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await kt(s)?{stdout:await Ce(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
|
|
173
|
+
`,exitCode:1}}})}function sm(e,t){e.command("replay",{description:"Replay a bisect log",args:[q.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:S(r.cwd,n.logfile);if(!await r.fs.exists(i))return I(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return om(s,r.env,t,a)}})}async function om(e,t,n,r){await kt(e)&&await Zs(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
|
|
174
|
+
`)){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],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];d=await tf(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ns(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ns(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let u of l?l.split(/\s+/):[]){await X(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Rt(e,`# skip: [${u}] ${fe(m.message)}`),await Rt(e,`git bisect skip ${u}`)}d=await ss(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function im(e,t){e.command("run",{description:"Bisect by running a command",args:[q.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await kt(s))return rs;if(!r.exec)return I("bisect run requires shell execution support");let i=n.cmd.join(" ");return am(s,r.env,t,i,r.exec,r.cwd)}})}async function am(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
|
|
175
|
+
`;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await Si(e);if(M(u))return u;await X(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Rt(e,`# skip: [${u}] ${fe(m.message)}`),await Rt(e,`git bisect skip ${u}`);let h=await ss(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
|
|
176
|
+
`,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Xs(e),l=c===0?f.termGood:f.termBad,d=await ns(e,t,n,l,f,void 0);if(i+=d.stdout,d.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
|
|
177
|
+
`,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function cm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":v().describe("Show the term for the old state"),"term-bad":v().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await kt(s))return{stdout:"",stderr:`error: no terms defined
|
|
178
|
+
`,exitCode:1};let{termBad:i,termGood:a}=await ts(s);return n["term-good"]?{stdout:`${a}
|
|
179
179
|
`,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
|
|
180
180
|
`,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
|
|
181
181
|
and ${i} for the new state.
|
|
182
|
-
`,stderr:"",exitCode:0}}})}function
|
|
183
|
-
`,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(
|
|
184
|
-
`;return{stdout:f,stderr:"",exitCode:0}}})}async function
|
|
185
|
-
`,exitCode:1};if(o.found){let s=await
|
|
182
|
+
`,stderr:"",exitCode:0}}})}function fm(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 W(o.fs,o.cwd,t);if(M(s))return s;let i=s;if(!await kt(i))return rs;let a=await Xs(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
|
|
183
|
+
`,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(tr(),jc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${Y(l.hash)} ${fe(l.commit.message)}
|
|
184
|
+
`;return{stdout:f,stderr:"",exitCode:0}}})}async function ss(e,t,n){let r=await Xs(e);return!r.badHash||r.goodHashes.length===0?{stdout:_c(r),stderr:"",exitCode:0}:(await Se(e,"BISECT_ANCESTORS_OK",""),lm(e,t,n,r))}async function lm(e,t,n,r){let o=await Lc(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
|
|
185
|
+
`,exitCode:1};if(o.found){let s=await Fc(e,o.hash);return await Rt(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.
|
|
186
186
|
The first bad commit could be any of:
|
|
187
187
|
`;for(let i of r.skipHashes)s+=i+`
|
|
188
188
|
`;return r.badHash&&(s+=r.badHash+`
|
|
189
189
|
`),s+=`We cannot bisect more!
|
|
190
|
-
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Se(e,"BISECT_HEAD",o.hash);else{let s=await
|
|
191
|
-
`),{stdout:
|
|
190
|
+
`,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Se(e,"BISECT_HEAD",o.hash);else{let s=await Gn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Se(e,"BISECT_EXPECTED_REV",o.hash+`
|
|
191
|
+
`),{stdout:Nc(o),stderr:"",exitCode:0}}se();oe();function Gt(e){if(e.length===0)return[];let t=e.split(`
|
|
192
192
|
`);return t[t.length-1]===""&&t.pop(),t}function Vt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
|
|
193
|
-
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var
|
|
193
|
+
`&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var dm=4,nf=1024,co=100,uo=0,fo=1,Er=2;function vi(e){let t=1;for(;t*t<e;)t++;return t}function um(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 mm(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 rf(e,t,n,r){t-n>co&&(n=t-co),r-t>co&&(r=t+co);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===uo)o++;else if(f===Er)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===uo)i++;else if(f===Er)a++;else break}return i===0?!1:(i+=o,a+=s,a*dm<a+i)}function hm(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),u=Math.min(vi(t),nf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=uo:w>=u?l[g]=Er:l[g]=fo}let m=Math.min(vi(r),nf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=uo:w>=m?d[g]=Er:d[g]=fo}let h=[];for(let g=s;g<=i;g++)l[g]===fo||l[g]===Er&&!rf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===fo||d[g]===Er&&!rf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Ln=20,sf=4,pm=256,gm=256,lo=2147483647;function gt(e,t){return e[t]??0}function wm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,u=t-o,m=n-s,h=u-m&1,p=u,g=u,w=m,y=m;i[u]=t,a[m]=n;for(let x=1;;x++){let b=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let E;gt(i,k-1)>=gt(i,k+1)?E=gt(i,k-1)+1:E=gt(i,k+1);let R=E,P=E-k;for(;E<n&&P<s&&e[E]===r[P];)E++,P++;if(E-R>Ln&&(b=!0),i[k]=E,h&&w<=k&&k<=y&>(a,k)<=E)return{i1:E,i2:P,minLo:!0,minHi:!0}}w>l?a[--w-1]=lo:++w,y<d?a[++y+1]=lo:--y;for(let k=y;k>=w;k-=2){let E;gt(a,k-1)<gt(a,k+1)?E=gt(a,k-1):E=gt(a,k+1)-1;let R=E,P=E-k;for(;E>t&&P>o&&e[E-1]===r[P-1];)E--,P--;if(R-E>Ln&&(b=!0),a[k]=E,!h&&p<=k&&k<=g&&E<=gt(i,k))return{i1:E,i2:P,minLo:!0,minHi:!0}}if(!c){if(b&&x>pm){let k=0,E=null;for(let R=g;R>=p;R-=2){let P=R>u?R-u:u-R,C=gt(i,R),T=C-R,D=C-t+(T-o)-P;if(D>sf*x&&D>k&&t+Ln<=C&&C<n&&o+Ln<=T&&T<s){let O=!0;for(let H=1;H<=Ln;H++)if(e[C-H]!==r[T-H]){O=!1;break}O&&(k=D,E={i1:C,i2:T,minLo:!0,minHi:!1})}}if(E)return E;k=0,E=null;for(let R=y;R>=w;R-=2){let P=R>m?R-m:m-R,C=gt(a,R),T=C-R,D=n-C+(s-T)-P;if(D>sf*x&&D>k&&t<C&&C<=n-Ln&&o<T&&T<=s-Ln){let O=!0;for(let H=0;H<Ln;H++)if(e[C+H]!==r[T+H]){O=!1;break}O&&(k=D,E={i1:C,i2:T,minLo:!1,minHi:!0})}}if(E)return E}if(x>=f){let k=-1,E=-1;for(let C=g;C>=p;C-=2){let T=Math.min(gt(i,C),n),D=T-C;s<D&&(T=s+C,D=s),k<T+D&&(k=T+D,E=T)}let R=lo,P=lo;for(let C=y;C>=w;C-=2){let T=Math.max(t,gt(a,C)),D=T-C;D<o&&(T=o+C,D=o),T+D<R&&(R=T+D,P=T)}return n+s-R<k-(t+o)?{i1:E,i2:k-E,minLo:!0,minHi:!1}:{i1:P,i2:R-P,minLo:!1,minHi:!0}}}}}function Hi(e,t,n,r,o,s,i,a,c,f,l,d,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=wm(e,t,n,r,o,s,l,d,u,m);Hi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,m),Hi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,m)}}function bm(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 of=200,af=20,cf=100,ym=1,Em=21,km=-30,Rm=6,xm=-4,Cm=10,Pm=24,Om=17,Im=23,$m=17,Sm=60;function Ti(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>=of)return of}return-1}function ff(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=Ti(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Ti(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===af){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Ti(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===af){r.postIndent=0;break}return r}function lf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=ym),e.endOfFile&&(t.penalty+=Em);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=km*r,t.penalty+=Rm*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?Cm:xm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?Om:Pm:t.penalty+=s?$m:Im))}function Tm(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Sm*n+(e.penalty-t.penalty)}function df(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 l=(d,u)=>t[d]===t[u];for(;;){if(a!==i){let d,u,m;do{for(d=a-i,u=-1;i>0&&l(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||!l(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(d!==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-d-1>g&&(g=a-d-1),a-cf>g&&(g=a-cf);g<=a;g++){let w={effectiveIndent:0,penalty:0},y=ff(n,r,g);lf(y,w);let x=ff(n,r,g-d);lf(x,w),(h===-1||Tm(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 Ai(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}=um(e,t),{dstart:f,dend1:l,dend2:d}=mm(i,n,a,r);if(f>l)for(let u=f;u<r-(n-1-l);u++)s[u]=1;else if(f>d)for(let u=f;u<n-(r-1-d);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=hm(i,n,a,r,c,f,l,d,o,s);if(m>0&&p>0){let g=new Array(m);for(let E=0;E<m;E++)g[E]=i[u[E]];let w=new Array(p);for(let E=0;E<p;E++)w[E]=a[h[E]];let y={},x={},b=m+p+3,k=Math.max(gm,vi(b));Hi(g,0,m,w,0,p,o,s,u,h,y,x,!1,k)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[u[g]]=1;df(o,i,e,n,s,r),df(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function lt(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}=Ai(e,t);return bm(e,t,o,s)}var vm=3;function Hm(e,t=vm){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),l=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=l}return o.push({start:s,end:i}),o.map(a=>Am(e,a.start,a.end))}function Am(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let l=t;l<=n;l++){let d=e[l];if(d)switch(d.type){case"keep":c||(r=d.oldLineNo,c=!0),f||(s=d.newLineNo,f=!0),o++,i++,a.push({type:"context",content:d.line});break;case"delete":c||(r=d.oldLineNo,c=!0),o++,a.push({type:"delete",content:d.line});break;case"insert":f||(s=d.newLineNo,f=!0),i++,a.push({type:"insert",content:d.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="insert"){r=d.newLineNo>1?d.newLineNo-1:0;break}}if(i===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="delete"){s=d.oldLineNo>1?d.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function mo(e){return e?e.length<40?e:Y(e):"0000000"}function uf(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 Dm(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,l=e.renameTo??r,d=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(uf(m,e,l,d,u,f),o!==s){if(a||c){let h=mo(a),p=mo(c);d||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${l} differ`):d?m.push(`Binary files /dev/null and b/${l} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${l} differ`)}return`${m.join(`
|
|
194
194
|
`)}
|
|
195
|
-
`}function xt(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,l=
|
|
195
|
+
`}function xt(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,l=Ae(n),d=Ae(r);if(l||d)return Dm(e,l,d);let u=Gt(n),m=Gt(r),h=n.length>0&&n.endsWith(`
|
|
196
196
|
`),p=r.length>0&&r.endsWith(`
|
|
197
|
-
`),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let
|
|
197
|
+
`),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let x=lt(w,y);if(!h||!p)for(let D of x)D.line.includes(g)&&(D.line=D.line.replace(g,""));let b=Hm(x);if(b.length===0&&!c)return"";let k=e.isNew??n==="",E=e.isDeleted??r==="",R=[];if(uf(R,e,f,k,E,c),b.length===0)return`${R.join(`
|
|
198
198
|
`)}
|
|
199
|
-
`;if(i||a){let D=mo(i),O=mo(a);k||E?
|
|
199
|
+
`;if(i||a){let D=mo(i),O=mo(a);k||E?R.push(`index ${D}..${O}`):c?R.push(`index ${D}..${O} ${o||"100644"}`):o&&s&&o!==s?R.push(`index ${D}..${O}`):R.push(`index ${D}..${O} ${o||"100644"}`)}let P=D=>D.includes(" ")?" ":"";k?(R.push("--- /dev/null"),R.push(`+++ b/${f}${P(f)}`)):E?(R.push(`--- a/${t}${P(t)}`),R.push("+++ /dev/null")):(R.push(`--- a/${t}${P(t)}`),R.push(`+++ b/${f}${P(f)}`));let C=u.length,T=m.length;for(let D of b){let O=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,H=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,G="";for(let N=D.oldStart-2;N>=0;N--){let B=u[N];if(B&&/^[a-zA-Z$_]/.test(B)){G=` ${B.trimEnd().slice(0,79)}`;break}}R.push(`@@ -${O} +${H} @@${G}`);let A=D.oldStart,$=D.newStart;for(let N of D.lines)switch(N.type){case"context":R.push(` ${N.content}`),(!h&&A===C||!p&&$===T)&&R.push("\"),A++,$++;break;case"delete":R.push(`-${N.content}`),!h&&A===C&&R.push("\"),A++;break;case"insert":R.push(`+${N.content}`),!p&&$===T&&R.push("\"),$++;break}}return`${R.join(`
|
|
200
200
|
`)}
|
|
201
|
-
`}oe();
|
|
202
|
-
`)[0],boundary:i,previous:a}}se();oe();
|
|
201
|
+
`}oe();Te();async function _n(e,t,n){return(await ce(e,t)).get(n)?.hash??null}async function mf(e,t,n,r){let o=await We(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await nt(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function Mm(e,t,n,r,o,s){let i=await _n(e,(await j(e,t)).tree,n);if(!i){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,Nn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await ae(e,i),c=Gt(a),f=new Array(o.length),l=[...r],d=t,u=n,m=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let C of l)f[C.finalIdx]=Nn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!0,void 0);break}let g=await _n(e,p.tree,u),w=null,y=[];for(let C of p.parents){let T=await j(e,C),D=u,O=await _n(e,T.tree,D);if(!O){let H=await mf(e,T.tree,p.tree,u);H&&(D=H,O=await _n(e,T.tree,D))}if(O&&(y.push({hash:C,path:D,blobHash:O}),O===g)){w={hash:C,path:D};break}}if(w){d=w.hash,u=w.path;continue}if(y.length===0){for(let C of l)f[C.finalIdx]=Nn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!1,void 0);break}let x=y[0],b=await ae(e,x.blobHash),k=Gt(b),E=lt(k,m),R=new Map;for(let C of E)C.type==="keep"&&R.set(C.newLineNo,C.oldLineNo);let P=[];for(let C of l){let T=R.get(C.currentLine);T!==void 0?P.push({finalIdx:C.finalIdx,currentLine:T}):f[C.finalIdx]=Nn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!1,{hash:x.hash,path:x.path})}l=P,d=x.hash,u=x.path,m=k}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function hf(e,t,n,r){let o=await j(e,t),s=await _n(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await ae(e,s),a=Gt(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),u=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await j(e,m);if(g.parents.length===0){for(let R of u)d[R.finalIdx]=Nn(m,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!0,void 0);break}let w=await _n(e,g.tree,h),y=[],x=null;for(let R of g.parents){let P=await j(e,R),C=h,T=await _n(e,P.tree,C);if(!T){let D=await mf(e,P.tree,g.tree,h);D&&(C=D,T=await _n(e,P.tree,C))}if(T){let D={hash:R,path:C,blobHash:T};if(y.push(D),T===w){x=D;break}}}if(x){m=x.hash,h=x.path;continue}if(y.length===0){for(let R of u)d[R.finalIdx]=Nn(m,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,void 0);break}if(y.length===1){let R=y[0],P=await ae(e,R.blobHash),C=Gt(P),T=lt(C,p),D=new Map;for(let H of T)H.type==="keep"&&D.set(H.newLineNo,H.oldLineNo);let O=[];for(let H of u){let G=D.get(H.currentLine);G!==void 0?O.push({finalIdx:H.finalIdx,currentLine:G}):d[H.finalIdx]=Nn(m,h,H.currentLine,c+H.finalIdx,l[H.finalIdx],g,!1,{hash:R.hash,path:R.path})}u=O,m=R.hash,h=R.path,p=C;continue}let b=[];for(let R of y){let P=await ae(e,R.blobHash),C=Gt(P),T=lt(C,p),D=new Map;for(let O of T)O.type==="keep"&&D.set(O.newLineNo,O.oldLineNo);b.push({info:R,newToOld:D})}let k=new Map;for(let R of u){let P=!1;for(let C=0;C<b.length;C++){let T=b[C],D=T.newToOld.get(R.currentLine);if(D!==void 0){let O=k.get(C);O||(O={info:T.info,lines:[]},k.set(C,O)),O.lines.push({finalIdx:R.finalIdx,currentLine:D}),P=!0;break}}P||(d[R.finalIdx]=Nn(m,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,{hash:y[0].hash,path:y[0].path}))}let E=k.get(0);for(let[R,P]of k){if(R===0)continue;let C=await Mm(e,P.info.hash,P.info.path,P.lines,l,c);for(let[T,D]of C)d[T]=D}if(E&&E.lines.length>0){u=E.lines,m=E.info.hash,h=E.info.path;let R=await ae(e,E.info.blobHash);p=Gt(R)}else break}return d}function Nn(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(`
|
|
202
|
+
`)[0],boundary:i,previous:a}}se();oe();Te();oe();le();function jm(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 Gm(e,t){let n=jm(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 Lm(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),i=String(s).length,a=e.some(d=>d.origPath!==t),c=0;if(!o)for(let d of e){let u=r?`<${d.author.email}>`:d.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let d of e)d.origPath.length>f&&(f=d.origPath.length);let l=[];for(let d of e){let u;n?u=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:u=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let m=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${u}${m} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let h=r?`<${d.author.email}>`:d.author.name,p=Gm(d.author.timestamp,d.author.timezone);l.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
|
|
203
203
|
`)}
|
|
204
|
-
`}function
|
|
204
|
+
`}function _m(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(`
|
|
205
205
|
`)}
|
|
206
|
-
`}function
|
|
206
|
+
`}function Nm(e,t,n){if(e.startsWith("/"))return ct(n,e);let r=ct(n,t);return r===""||r==="."?e:`${r}/${e}`}function pf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[q.string().name("args").variadic().optional()],options:{lineRange:Q.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:v().alias("l").describe("Show long revision"),showEmail:v().alias("e").describe("Show author email instead of name"),suppress:v().alias("s").describe("Suppress author name and date"),porcelain:v().alias("p").describe("Show in machine-readable format"),linePorcelain:v().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return I("this operation must be run in a work tree");let a=await Ze(i);if(M(a))return a;let c=n.args??[],f=o.passthrough??[],l=null,d=null;if(f.length>0?(d=f[f.length-1],c.length>0&&(l=c[0])):c.length===2?(l=c[0],d=c[1]):c.length===1&&(d=c[0]),!d)return I("no file specified");let u=Nm(d,r.cwd,i.workTree),m;if(l){let E=await Tt(i,l);if(M(E))return E;m=await _e(i,E)}else m=a;let h=await j(i,m),p=await ce(i,h.tree);if(!p.has(u))return I(`no such path ${u} in ${l??"HEAD"}`);let g=p.get(u).hash,w=await ae(i,g);if(Ae(w))return I(`cannot blame binary file '${u}'`);let y,x;if(n.lineRange){let E=n.lineRange,R=E.match(/^(\d+),(\d+)$/);if(R)y=parseInt(R[1],10),x=parseInt(R[2],10);else return I(`invalid -L range: '${E}'`)}let b;try{b=await hf(i,m,u,{startLine:y,endLine:x})}catch(E){let R=E instanceof Error?E.message:String(E);return I(R)}let k;return n.porcelain||n.linePorcelain?k=_m(b,!!n.linePorcelain):k=Lm(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}se();Ne();xn();se();var Fm=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Um=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Lt(e,t){let n=Bm(t),r=new Date((e+n*60)*1e3),o=Fm[r.getUTCDay()],s=Um[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"),l=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${l} ${t}`}function Di(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 Bm(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();Te();var ho=new TextDecoder;function gf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
|
|
207
207
|
`&&t++;return e[e.length-1]!==`
|
|
208
|
-
`&&t++,t}function
|
|
208
|
+
`&&t++,t}function kr(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 os(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Et(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:gf(ho.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Et(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:gf(ho.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Et(e,a.oldHash),f=await Et(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 l=Vt(ho.decode(c)),d=Vt(ho.decode(f)),u=lt(l,d),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=Mn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await ae(e,a.oldHash),u=await ae(e,a.newHash);if(!Ae(d)&&!Ae(u)){let m=Vt(d),h=Vt(u),p=lt(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}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=Mn(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 cn(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: ${Lt(r.timestamp,r.timezone)}`),i)return a.join(`
|
|
209
209
|
`)+(a.length>0?`
|
|
210
|
-
`:"");let c=await
|
|
210
|
+
`:"");let c=await We(e,t,n),{remaining:f,renames:l}=await nt(e,c),{fileStats:d,modeLines:u}=await os(e,f,l),m=0,h=0;for(let g of d)m+=g.insertions,h+=g.deletions;let p=kr(d.length,m,h);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
|
|
211
211
|
`)+(a.length>0?`
|
|
212
|
-
`:"")}var
|
|
212
|
+
`:"")}var Wm=80;function qm(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 is(e,t=Wm){if(e.length===0)return"";let n=e.filter(p=>!p.isUnmerged),r=n.length>0?Math.max(...n.map(p=>p.insertions+p.deletions)):0,o=e.some(p=>p.isBinary),s=r>0?String(r).length:1;o&&s<3&&(s=3);let i=Math.max(...e.map(p=>p.path.length)),a=r,c=i;if(c+s+6+a>t){let p=Math.floor(t*3/8)-s-6;a>p&&(a=Math.max(p,6));let g=t-s-6-a;c>g?c=g:a=t-s-6-c}for(let p of e)p.path=qm(p.path,c);let f=c,l=[],d=0,u=0,m=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(m++,d+=p.insertions,u+=p.deletions,p.isBinary){let P=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${P}`);continue}let w=p.insertions+p.deletions,y=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let R=T=>T===0?0:1+Math.floor(T*(a-1)/r),P=R(w),C=P<2&&p.insertions>0&&p.deletions>0?2:P;p.insertions<p.deletions?(x=R(p.insertions),b=C-x):(b=R(p.deletions),x=C-b)}let k="+".repeat(x)+"-".repeat(b),E=k?` ${k}`:"";l.push(` ${g} | ${y}${E}`)}let h=kr(m,d,u);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
|
|
213
213
|
`)}
|
|
214
|
-
`}async function
|
|
215
|
-
`;return c}
|
|
214
|
+
`}async function Fn(e,t,n){let r=await We(e,t,n),{remaining:o,renames:s}=await nt(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await os(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=is(i);for(let f of a)c+=`${f}
|
|
215
|
+
`;return c}Ne();Pe();oe();ue();sn();async function zm(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;try{i=await j(e,s)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function yn(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;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function _t(e,t,n){if(t===n)return[t];let r=await zm(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 l;try{l=await j(e,f)}catch{continue}for(let d of l.parents)s.has(d)||i.push(d)}if(o.length<=1)return o;let c=[];for(let f of o){let l=!1;for(let d of o)if(d!==f&&await yn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:Km(e,t,n,c)}async function Km(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,l=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function d(u){let m=c.get(u);if(m!==void 0)return m;let h=(await j(e,u)).committer.timestamp;return c.set(u,h),h}for(;l.length>0;){let u=0,m=await d(l[0].hash);for(let y=1;y<l.length;y++){let x=l[y],b=await d(x.hash),k=l[u];(b>m||b===m&&x.seq<k.seq)&&(u=y,m=b)}let h=l.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 j(e,h.hash);for(let y of w.parents)l.push({hash:y,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function ir(e,t,n){let r=await ke(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
|
|
216
216
|
`:`Merge branch '${t}' into ${n}
|
|
217
|
-
`}async function po(e,t,n){let r=await
|
|
218
|
-
`;if(e.workTree){let f=await K(e),l=await
|
|
219
|
-
${c}`,stderr:"",exitCode:0}}oe();
|
|
220
|
-
`);let y=`refs/heads/${n.name}`,
|
|
221
|
-
`);let b="";if(!f){let k=await
|
|
217
|
+
`}async function po(e,t,n){let r=await j(e,t),o=await j(e,n),s=Y(t),i=Y(n),a=`Updating ${s}..${i}
|
|
218
|
+
`;if(e.workTree){let f=await K(e),l=await vc(e,r.tree,o.tree,f);if(!l.success){let d=l.errorOutput;return{stdout:a+d.stdout,stderr:d.stderr,exitCode:d.exitCode}}await ie(e,{version:2,entries:l.newEntries}),await De(e,l.worktreeOps)}await In(e,n);let c=await Fn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
|
|
219
|
+
${c}`,stderr:"",exitCode:0}}oe();Fe();ue();function wf(e,t){e.command("branch",{description:"List, create, or delete branches",args:[q.string().name("name").describe("Branch name").optional(),q.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:v().alias("d").describe("Delete a branch"),forceDelete:v().alias("D").describe("Force delete a branch"),move:v().alias("m").describe("Rename a branch"),forceMove:v().alias("M").describe("Force rename a branch"),remotes:v().alias("r").describe("List remote-tracking branches"),all:v().alias("a").describe("List all branches"),setUpstreamTo:Q.string().alias("u").describe("Set upstream tracking branch"),verbose:v().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await J(s),a=i?.type==="symbolic"?Re(i.target):null,c=!!n.forceMove;if(n.move||c){let w,y;if(n.newName)w=n.name,y=n.newName;else if(n.name){if(!a)return I("not on any branch");w=a,y=n.name}else return I("branch name required");let x=`refs/heads/${w}`,b=`refs/heads/${y}`,k=await F(s,x);if(!k)return I(`no branch named '${w}'`);if(await jt(s)&&(await pt(s))?.headName===x)return I(`branch ${x} is being rebased at ${s.workTree}`);let E=await F(s,b);if(E&&!c)return I(`a branch named '${y}' already exists`);E&&await de(s,b);let R=await Je(s,x);await X(s,b,k),await de(s,x),w===a&&await ze(s,"HEAD",b),R.length>0&&await Sn(s,b,R);let P=`Branch: renamed ${x} to ${b}`;if(await re(s,r.env,b,k,k,P),w===a){let D=await Jt(s,r.env);await Ke(s,"HEAD",{oldHash:k,newHash:te,...D,message:P}),await Ke(s,"HEAD",{oldHash:te,newHash:k,...D,message:P})}let C=await he(s),T=`branch "${w}"`;return C[T]&&(C[`branch "${y}"`]=C[T],delete C[T],await Ye(s,C)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return I("branch name required");let w=n.name===a;if(!w&&!a&&await jt(s)&&(await pt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return L(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
|
|
220
|
+
`);let y=`refs/heads/${n.name}`,x=await F(s,y);if(!x)return L(`error: branch '${n.name}' not found
|
|
221
|
+
`);let b="";if(!f){let k=await Z(s),R=(await he(s))[`branch "${n.name}"`],P=R?.remote,C=R?.merge,T=null,D=null;if(P&&C&&(T=C.replace(/^refs\/heads\//,`refs/remotes/${P}/`),D=await F(s,T)),D&&T){if(!(x===D||await yn(s,x,D))){let A=k!=null&&(x===k||await yn(s,x,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
|
|
222
222
|
'${T}', even though it is merged to HEAD
|
|
223
|
-
`:"";return
|
|
223
|
+
`:"";return L(`${A}error: the branch '${n.name}' is not fully merged
|
|
224
224
|
hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
|
|
225
225
|
hint: Disable this message with "git config set advice.forceDeleteBranch false"
|
|
226
|
-
`)}k!=null&&(
|
|
226
|
+
`)}k!=null&&(x===k||await yn(s,x,k))||(b=`warning: deleting branch '${n.name}' that has been merged to
|
|
227
227
|
'${T}', but not yet merged to HEAD
|
|
228
|
-
`)}else if(k&&
|
|
228
|
+
`)}else if(k&&x!==k&&!await yn(s,x,k))return L(`error: the branch '${n.name}' is not fully merged
|
|
229
229
|
hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
|
|
230
230
|
hint: Disable this message with "git config set advice.forceDeleteBranch false"
|
|
231
|
-
`)}return await de(s,y),{stdout:`Deleted branch ${n.name} (was ${
|
|
232
|
-
`,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||a;if(!y)return I("could not set upstream of HEAD when it does not point to any branch.");if(!await
|
|
233
|
-
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,y;if(w){let
|
|
231
|
+
`)}return await de(s,y),{stdout:`Deleted branch ${n.name} (was ${Y(x)}).
|
|
232
|
+
`,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||a;if(!y)return I("could not set upstream of HEAD when it does not point to any branch.");if(!await F(s,`refs/heads/${y}`))return I(`branch '${y}' does not exist`);let b=w.indexOf("/");if(b<0)return I(`the requested upstream branch '${w}' does not exist`);let k=w.slice(0,b),E=w.slice(b+1);if(!await F(s,`refs/remotes/${w}`))return I(`the requested upstream branch '${w}' does not exist`);let P=await he(s),C=`branch "${y}"`;return P[C]||(P[C]={}),P[C].remote=k,P[C].merge=`refs/heads/${E}`,await Ye(s,P),{stdout:"",stderr:`branch '${y}' set up to track '${w}'.
|
|
233
|
+
`,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,y;if(w){let R=await ve(s,w,`not a valid object name: '${w}'`);if(M(R))return R;y=R.hash}else if(y=await Z(s),!y)return I("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await F(s,x))return I(`a branch named '${n.name}' already exists`);await X(s,x,y);let k=w??"HEAD";await re(s,r.env,x,null,y,`branch: Created from ${k}`);let E="";return w&&(E=await io(s,n.name,w)),{stdout:"",stderr:E,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,u=n.remotes||n.all,m=[];if(d&&!a){let w=await Z(s);if(w){let y=await jt(s),x;if(y){let b=await pt(s);if(b?.headName){let k=Re(b.headName);if(k==="detached HEAD"){let E=await es(s);x=`(no branch, rebasing detached HEAD ${E?Y(E):"(null)"})`}else x=`(no branch, rebasing ${k})`}else x="(no branch)"}else{let b=await es(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${Y(b)})`:x="(no branch)"}m.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await ge(s,"refs/heads");for(let y of w){let x=Re(y.name);m.push({displayName:x,hash:y.hash,isCurrent:x===a,branchName:x})}}if(u){let w=await ge(s,"refs/remotes");for(let y of w){let x=y.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${x}`:x,hash:y.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${m.map(y=>y.isCurrent?`* ${y.displayName}`:` ${y.displayName}`).join(`
|
|
234
234
|
`)}
|
|
235
|
-
`,stderr:"",exitCode:0};let h=l>=1?await
|
|
235
|
+
`,stderr:"",exitCode:0};let h=l>=1?await he(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let y=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=Y(w.hash),k="";try{let R=await j(s,w.hash);k=fe(R.message)}catch{}let E="";if(h&&w.branchName){let R=await wn(s,h,w.branchName);if(R){let P=Zc(R,l>=2);P&&(E=` ${P}`)}}g.push(`${y}${x} ${b}${E} ${k}`)}return{stdout:`${g.join(`
|
|
236
236
|
`)}
|
|
237
|
-
`,stderr:"",exitCode:0}}})}function ee(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var
|
|
238
|
-
`)}})}async function
|
|
239
|
-
${l}`,exitCode:0}}async function
|
|
237
|
+
`,stderr:"",exitCode:0}}})}function ee(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Vm=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],Ym=["commitMsg","mergeMsg"],Xm=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],Zm=["onRefUpdate","onRefDelete","onObjectWrite"];function Jm(...e){let t=e.filter(r=>r!=null);if(t.length===0)return{};if(t.length===1)return t[0];let n={};for(let r of Vm){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of Ym){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of Xm){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o)try{await i(s)}catch{}})}for(let r of Zm){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}se();Ne();Pe();oe();Fe();ue();mn();tt();function yf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:v().alias("b").describe("Create and switch to a new branch"),forceBranch:v().alias("B").describe("Create/reset and switch to a new branch"),detach:v().alias("d").describe("Detach HEAD at named commit"),orphan:v().describe("Create a new orphan branch"),ours:v().describe("Checkout our version for unmerged files"),theirs:v().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return I("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return I(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let u=ut(i,r.cwd),m=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return I("cannot specify both a revision and --ours/--theirs");let p=await ve(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?so(i,m,u,n.theirs?3:2):ro(i,m,u,h)}if(n.orphan)return n.branch?I("--orphan and -b are incompatible"):n.ours||n.theirs?I("--orphan and --ours/--theirs are incompatible"):a?eh(i,a,r.env,t):I("you must specify a branch to checkout");if(n.detach){let u=a??"HEAD",m=await ve(i,u,`invalid reference: ${u}`);return M(m)?m:bf(i,u,m.hash,r.env,t)}if(!a)return I("you must specify a branch to checkout");if(n.branch||n.forceBranch)return th(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Qm(i,r.env,t);let c=`refs/heads/${a}`,f=await F(i,c);if(f)return Ef(i,a,c,f,r.env,t);let l=await ao(i,a);if(l)return nh(i,a,l.trackingRef,r.env,t);let d=await Be(i,a);if(d){let u=await _e(i,d);return bf(i,a,u,r.env,t)}if(i.workTree){let u=await K(i),m=$s(u,a);if(m)return await at(i,{path:m.path,hash:m.hash,mode:m.mode}),{stdout:"",stderr:"",exitCode:0}}return L(`error: pathspec '${a}' did not match any file(s) known to git
|
|
238
|
+
`)}})}async function Qm(e,t,n){let r=await no(e);return r?Ef(e,r.name,r.refName,r.hash,t,n):I("no previous branch")}async function eh(e,t,n,r){let o=`refs/heads/${t}`;if(await F(e,o))return I(`a branch named '${t}' already exists`);let i=await K(e),a=jn(i);if(a)return a;let c=await Z(e),f=null;c&&(f=(await j(e,c)).tree),await ze(e,"HEAD",o),await ht(e);let l=await bn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:te,isBranchCheckout:!0});let d="";return f&&(d=await sr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
|
|
239
|
+
${l}`,exitCode:0}}async function th(e,t,n,r,o=!1){let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await J(e),a=await Z(e),c=`refs/heads/${t}`,f=await F(e,c);if(f&&!o)return I(`a branch named '${t}' already exists`);if(o){let g=await K(e),w=jn(g);if(w)return w}a&&await X(e,c,a),await ze(e,"HEAD",c),await ht(e);let l=await bn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??te;a&&(f?f!==a&&await re(e,n,c,f,a,"branch: Reset to HEAD"):await re(e,n,c,null,a,"branch: Created from HEAD")),await re(e,n,"HEAD",a,a??te,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??te,isBranchCheckout:!0});let u="";if(o&&a){let g=await K(e),w=await j(e,a);u=await sr(e,w.tree,g)}let m=await he(e),h=await wn(e,m,t);h&&(u+=rr(h));let p=f?`Switched to and reset branch '${t}'
|
|
240
240
|
`:`Switched to a new branch '${t}'
|
|
241
|
-
`;return{stdout:u,stderr:`${p}${l}`,exitCode:0}}async function
|
|
242
|
-
${u.stderr}`,u}async function
|
|
241
|
+
`;return{stdout:u,stderr:`${p}${l}`,exitCode:0}}async function Ef(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return ee(i)?L(i.message??""):or(e,t,n,r,o,s)}async function nh(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await F(e,n);if(!i)return I(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await X(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await he(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await Ye(e,d),await re(e,r,a,null,i,`branch: Created from ${n}`);let u=await or(e,t,a,i,r,o),m=c.slice(1).join("/");return u.stderr=`branch '${t}' set up to track '${f}/${m}'.
|
|
242
|
+
${u.stderr}`,u}async function bf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return ee(s)?L(s.message??""):Gn(e,n,r,o,{detachAdviceTarget:t})}se();Ne();Pe();se();function Mi(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}=Ai(e,t);return rh(o,n,s,r)}function rh(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 sh(e,t,n){let r=[];for(let c of Mi(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 Mi(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,l=c.oStart+c.oLength,d=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>l)break;l=Math.max(l,u.oStart+u.oLength),d.push(u),a++}if(d.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 d){let y=w.oStart,x=y+w.oLength,b=w.abStart,k=b+w.abLength,E=u[w.ab];E.abMin=Math.min(b,E.abMin),E.abMax=Math.max(k,E.abMax),E.oMin=Math.min(y,E.oMin),E.oMax=Math.max(x,E.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(l-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(l-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function oh(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=sh(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&&Rf(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),r?.conflictStyle==="diff3"?kf(i):kf(ih(i))}function as(e,t,n,r){let o=r?.markerSize??7,s=r?.conflictStyle??"merge",i=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a=`${"|".repeat(o)}${r?.o?` ${r.o}`:""}`,c="=".repeat(o),f=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,l=oh(e,t,n,{conflictStyle:s}),d=!1,u=[];for(let m of l)m.type==="ok"?u.push(...m.lines):(d=!0,s==="diff3"?u.push(i,...m.a,a,...m.o,c,...m.b,f):u.push(i,...m.a,c,...m.b,f));return{conflict:d,result:u}}function ih(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...ah(n));return t}function ah(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Rf(t,n))return[e];let r=Mi(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 l=c+a.buffer1[1],d=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,l),o:[],b:n.slice(a.buffer2[0],d)}),s=l}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function kf(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 ar(e,t,n,r){let o=as(Ct(e),Ct(t),Ct(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(ji);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
|
|
243
243
|
`)}
|
|
244
244
|
`:a.join(`
|
|
245
245
|
`)}function Ct(e){if(e==="")return[];let t=e.split(`
|
|
246
|
-
`);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function Mi(e){return e.endsWith("\0")?e.slice(0,-1):e}function xf(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();dn();le();Vn();Ae();tt();sn();var xr=new TextDecoder,Fn=new TextEncoder,Cf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Ft(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await lh(e,t,n,r),f=await uh(e,s,i,a,c,o);return mh(e,s,o,f)}async function ls(e,t,n,r){let o=await Nt(e,t,n),s=await L(e,t),i=await L(e,n);if(o.length===0)return{...await Ft(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await L(e,o[0]);return{...await Ft(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Af(e,t,n,o,1);return{...await Ft(e,a,s.tree,i.tree,r),baseTree:a}}async function lh(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 l=o.get(f)??null,d=s.get(f)??null,u=i.get(f)??null,m=l?{hash:l.hash,mode:l.mode}:null,h=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,y=d?.hash??null,R=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===R&&(b|=5),y!==null&&y===R&&(b|=6);let k={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(dh(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function dh(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 uh(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,S]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode});for(let[A,S]of r)n.has(A)||a.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});for(let[A,S]of o)n.has(A)||c.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});let f=await nt(e,a),l=await nt(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,u=new Map;for(let A of f.renames)d.set(A.oldPath,A);for(let A of l.renames)u.set(A.oldPath,A);let m=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&m.add(A);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,S,F=0){i.msgBuf.push({sortKey:A,subOrder:F,text:S})}for(let A of[...n.keys()].sort()){let S=d.get(A),F=u.get(A);if(!S&&!F)continue;let B=n.get(A);if(h.add(A),S&&F)if(h.add(S.newPath),h.add(F.newPath),S.newPath===F.newPath){let q=r.get(S.newPath),j=o.get(F.newPath);if(q.hash===j.hash)i.entries.push(wt(S.newPath,q));else{let U=ji(t,S.newPath);U.stages=[{hash:B.hash,mode:B.mode},{hash:q.hash,mode:q.mode},{hash:j.hash,mode:j.mode}],U.pathnames=[A,S.newPath,F.newPath],U.filemask=7,U.merged={result:null,clean:!1}}}else{let q=r.get(S.newPath),j=o.get(F.newPath),U=await Hf(e,B,q,j,s);U.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:S.newPath,theirsPath:F.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${S.newPath} in ${p} and to ${F.newPath} in ${g}.`),i.entries.push(wt(A,B,1)),i.entries.push(st(S.newPath,q.mode,U.hash,2)),i.entries.push(st(F.newPath,j.mode,U.hash,3)),i.worktreeBlobs.set(S.newPath,{hash:U.hash,mode:q.mode}),i.worktreeBlobs.set(F.newPath,{hash:U.hash,mode:j.mode})}else if(S){h.add(S.newPath);let q=o.get(A),j=r.get(S.newPath),U=m.has(S.newPath);if(q)if(U)await Tf(e,i,S.newPath,A,B,j,q,r,o,!1,s);else if(q.hash===B.hash&&j.hash===B.hash)i.entries.push(wt(S.newPath,j));else if(q.hash===B.hash)i.entries.push(wt(S.newPath,j));else if(j.hash===B.hash)i.entries.push(st(S.newPath,j.mode,q.hash));else{let J=ji(t,S.newPath);J.stages=[{hash:B.hash,mode:B.mode},{hash:j.hash,mode:j.mode},{hash:q.hash,mode:q.mode}],J.pathnames=[A,S.newPath,A],J.filemask=7,J.merged={result:null,clean:!1}}else{let J=o.get(S.newPath);if(i.conflicts.push({path:S.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(S.newPath,`CONFLICT (rename/delete): ${A} renamed to ${S.newPath} in ${p}, but deleted in ${g}.`),J){i.conflicts.push({path:S.newPath,reason:"add-add"}),w(S.newPath,`Auto-merging ${S.newPath}`,0),w(S.newPath,`CONFLICT (add/add): Merge conflict in ${S.newPath}`,1),i.entries.push(wt(S.newPath,j,2)),i.entries.push(wt(S.newPath,J,3));let Pe=await go(e,j.hash,J.hash,j.mode,s);i.worktreeBlobs.set(S.newPath,{hash:Pe,mode:j.mode})}else i.entries.push(st(S.newPath,B.mode,B.hash,1)),i.entries.push(wt(S.newPath,j,2)),i.worktreeBlobs.set(S.newPath,{hash:j.hash,mode:j.mode}),j.hash!==B.hash&&w(S.newPath,`CONFLICT (modify/delete): ${S.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${S.newPath} left in tree.`,1)}}else if(F){h.add(F.newPath);let q=r.get(A),j=o.get(F.newPath),U=m.has(F.newPath);if(q)if(U)await Tf(e,i,F.newPath,A,B,q,j,r,o,!0,s);else if(q.hash===B.hash&&j.hash===B.hash)i.entries.push(wt(F.newPath,j));else if(q.hash===B.hash)i.entries.push(wt(F.newPath,j));else if(j.hash===B.hash)i.entries.push(st(F.newPath,j.mode,q.hash));else{let J=ji(t,F.newPath);J.stages=[{hash:B.hash,mode:B.mode},{hash:q.hash,mode:q.mode},{hash:j.hash,mode:j.mode}],J.pathnames=[A,A,F.newPath],J.filemask=7,J.merged={result:null,clean:!1}}else{let J=r.get(F.newPath);if(i.conflicts.push({path:F.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(F.newPath,`CONFLICT (rename/delete): ${A} renamed to ${F.newPath} in ${g}, but deleted in ${p}.`),J){i.conflicts.push({path:F.newPath,reason:"add-add"}),w(F.newPath,`Auto-merging ${F.newPath}`,0),w(F.newPath,`CONFLICT (add/add): Merge conflict in ${F.newPath}`,1),i.entries.push(wt(F.newPath,J,2)),i.entries.push(wt(F.newPath,j,3));let Pe=await go(e,J.hash,j.hash,J.mode,s);i.worktreeBlobs.set(F.newPath,{hash:Pe,mode:J.mode})}else i.entries.push(st(F.newPath,B.mode,B.hash,1)),i.entries.push(wt(F.newPath,j,3)),i.worktreeBlobs.set(F.newPath,{hash:j.hash,mode:j.mode}),j.hash!==B.hash&&w(F.newPath,`CONFLICT (modify/delete): ${F.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${F.newPath} left in tree.`,1)}}}let y=new Set(f.renames.map(A=>A.newPath)),R=new Set(l.renames.map(A=>A.newPath)),b=Pf(n,r),k=Pf(n,o),E=Of(b,o,n),x=Of(k,r,n),P=If(f.renames,E),C=If(l.renames,x),T=Sf(P),D=Sf(C);for(let A of[...T.keys()])D.has(A)&&(T.delete(A),D.delete(A));let O=new Set(T.keys()),H=new Set(D.keys());if(D.size>0)for(let A of a){if(A.status!=="added"||y.has(A.path))continue;let S=$f(A.path,D,O);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(r.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=r.get(A.path),j=o.get(S)??n.get(S);i.entries.push(st(S,q.mode,q.hash,2)),j&&i.entries.push(st(S,j.mode,j.hash,3)),i.worktreeBlobs.set(S,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let F=r.get(A.path);i.entries.push(st(S,F.mode,F.hash,2)),i.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}if(T.size>0)for(let A of c){if(A.status!=="added"||R.has(A.path))continue;let S=$f(A.path,T,H);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(o.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let q=o.get(A.path),j=r.get(S)??n.get(S);j&&i.entries.push(st(S,j.mode,j.hash,2)),i.entries.push(st(S,q.mode,q.hash,3)),i.worktreeBlobs.set(S,{hash:q.hash,mode:q.mode}),i.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let F=o.get(A.path);i.entries.push(st(S,F.mode,F.hash,3)),i.worktreeBlobs.set(S,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}let G=new Set(i.entries.map(A=>A.path));for(let A of G){let S=t.get(A);S&&(S.merged={result:null,clean:!0})}for(let A of h){if(G.has(A))continue;let S=t.get(A);if(!S||S.merged.clean)continue;S.filemask===7&&!S.pathConflict||(S.merged={result:null,clean:!0})}return i}function Pf(e,t){let n=new Set;for(let s of e.keys()){let i=Pt(s);for(;i;)n.add(i),i=Pt(i)}let r=new Set;for(let s of t.keys()){let i=Pt(s);for(;i;)r.add(i),i=Pt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Of(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=Pt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Pt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Pt(s)}return r}function If(e,t){let n=new Map;for(let r of e){let o=Pt(r.oldPath),s=Pt(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)),l=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==l)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=Pt(o),s=Pt(s)}}return n}function Sf(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 $f(e,t,n){let r=Pt(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=Pt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Pt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Tf(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),u=f?i:s;if(d.hash===u.hash){t.entries.push(st(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Hf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(st(n,d.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(wt(n,d,2)),t.entries.push(st(n,i.mode,h.hash,3));let p=await go(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(st(n,s.mode,h.hash,2)),t.entries.push(wt(n,d,3));let p=await go(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Hf(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(hn(t.mode)||hn(n.mode)||hn(r.mode))return{hash:n.hash,conflict:!0};let a=await ae(e,t.hash),c=await ae(e,n.hash),f=await ae(e,r.hash);if(He(c)||He(f)||He(a))return{hash:n.hash,conflict:!0};let l=Ct(a),d=Ct(c),u=Ct(f),m=o?.conflictStyle,h=cs(d,l,u,{conflictStyle:m});if(!h.conflict)return{hash:await Li(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,y=s?.theirsPath?`${g}:${s.theirsPath}`:g,R=ir(c,a,f,{a:w,b:y,markerSize:i??7,conflictStyle:m});return{hash:await Ie(e,"blob",Fn.encode(R)),conflict:!0}}async function go(e,t,n,r,o){let s=await ae(e,t),i=await ae(e,n),a=ir(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Ie(e,"blob",Fn.encode(a))}function wt(e,t,n=0){return st(e,t.mode,t.hash,n)}function st(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Oe()}}async function mh(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(Me(m,h.merged.result.hash,h.merged.result.mode));continue}await hh(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),l=[],d=new Set;for(let m of o)m.stage===0&&(l.push(m),d.add(m.path));for(let[m,h]of a)d.has(m)||l.push(Me(m,h.hash,h.mode));l.sort((m,h)=>Ce(m.path,h.path));let u=await Ge(e,l);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function hh(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,u=f?.hash??null,m=l?.hash??null;if(u===null&&m!==null&&d!==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(Me(a,d,c.mode,1)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:m,mode:l.mode});return}if(m===null&&u!==null&&d!==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(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(d===null&&u!==null&&m!==null){if(u===m){r.push(Me(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await ae(e,u),p=await ae(e,m);if(He(h)||He(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(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=Ct(""),w=Ct(h),y=Ct(p),R=cs(w,g,y,{conflictStyle:n?.conflictStyle});if(!R.conflict){let E=await Li(e,R.result);r.push(Me(a,E,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3));let b=ir(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),k=await Ie(e,"blob",Fn.encode(b));i.set(a,{hash:k,mode:f.mode});return}if(d!==null&&u!==null&&m!==null){if(u===d){r.push(Me(a,m,l.mode));return}if(m===d){r.push(Me(a,u,f.mode));return}if(u===m){r.push(Me(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),hn(c.mode)||hn(f.mode)||hn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await ae(e,d),p=await ae(e,u),g=await ae(e,m);if(He(p)||He(g)||He(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(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=Ct(h),y=Ct(p),R=Ct(g),b=cs(y,w,R,{conflictStyle:n?.conflictStyle});if(b.conflict){let k=t.pathnames[1],E=t.pathnames[2],x=k!==a||E!==a,P={path:a,reason:"content"};x&&(k!==a&&(P.oursOrigPath=k),E!==a&&(P.theirsOrigPath=E)),o.push(P),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3));let C=x?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",T=x?`${n?.b??"theirs"}:${E}`:n?.b??"theirs",D=ir(p,h,g,{a:C,b:T,conflictStyle:n?.conflictStyle}),O=await Ie(e,"blob",Fn.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let k=await Li(e,b.result);r.push(Me(a,k,f.mode))}return}}var ph=200;async function Af(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await L(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await L(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],u=(await L(e,d)).tree,m=null;if(o>=ph)m=f;else{let g=await Nt(e,c,d);g.length===0?m=null:g.length===1?m=(await L(e,g[0])).tree:m=await Af(e,c,d,g,o+1)}let h=await Ft(e,m,f,u);f=await gh(e,h,o);let p=tn({type:"commit",tree:f,parents:[c,d],author:Cf,committer:Cf,message:"merged common ancestors"});c=await Ie(e,"commit",p)}return f}async function gh(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 l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),m=s(l,2),h=s(d,3);if(m&&h){let p=xr.decode((await we(e,m.hash)).content),g=xr.decode((await we(e,h.hash)).content),w=u?xr.decode((await we(e,u.hash)).content):"",y=8+n*2,R=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",k=ir(p,w,g,{a:`${R}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:y}),E=await Ie(e,"blob",Fn.encode(k));r.push({path:l,mode:m.mode,hash:E,stage:0,stat:Oe()}),r.push({path:d,mode:h.mode,hash:E,stage:0,stat:Oe()});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 l=xr.decode((await we(e,c.hash)).content),d=xr.decode((await we(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?xr.decode((await we(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,y=h?`${g}:${a.theirsOrigPath??a.path}`:g,R=ir(l,m,d,{a:w,o:i.o,b:y,markerSize:i.markerSize}),b=await Ie(e,"blob",Fn.encode(R));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Oe()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ce(a.path,c.path)),Ge(e,r)}async function Li(e,t){let n=t.map(Mi);if(n.length===0)return Ie(e,"blob",Fn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
|
|
246
|
+
`);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ji(e){return e.endsWith("\0")?e.slice(0,-1):e}function Rf(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}Pe();oe();dn();le();Yn();Te();tt();sn();var Rr=new TextDecoder,Un=new TextEncoder,xf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Nt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await fh(e,t,n,r),f=await dh(e,s,i,a,c,o);return uh(e,s,o,f)}async function fs(e,t,n,r){let o=await _t(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Nt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Nt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Hf(e,t,n,o,1);return{...await Nt(e,a,s.tree,i.tree,r),baseTree:a}}async function fh(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),i=await ce(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let l=o.get(f)??null,d=s.get(f)??null,u=i.get(f)??null,m=l?{hash:l.hash,mode:l.mode}:null,h=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,y=d?.hash??null,x=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===x&&(b|=5),y!==null&&y===x&&(b|=6);let k={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(lh(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function lh(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 dh(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,$]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:$.hash,oldMode:$.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:$.hash,oldMode:$.mode});for(let[A,$]of r)n.has(A)||a.push({path:A,status:"added",newHash:$.hash,newMode:$.mode});for(let[A,$]of o)n.has(A)||c.push({path:A,status:"added",newHash:$.hash,newMode:$.mode});let f=await nt(e,a),l=await nt(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,u=new Map;for(let A of f.renames)d.set(A.oldPath,A);for(let A of l.renames)u.set(A.oldPath,A);let m=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&m.add(A);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,$,N=0){i.msgBuf.push({sortKey:A,subOrder:N,text:$})}for(let A of[...n.keys()].sort()){let $=d.get(A),N=u.get(A);if(!$&&!N)continue;let B=n.get(A);if(h.add(A),$&&N)if(h.add($.newPath),h.add(N.newPath),$.newPath===N.newPath){let z=r.get($.newPath),_=o.get(N.newPath);if(z.hash===_.hash)i.entries.push(wt($.newPath,z));else{let U=Gi(t,$.newPath);U.stages=[{hash:B.hash,mode:B.mode},{hash:z.hash,mode:z.mode},{hash:_.hash,mode:_.mode}],U.pathnames=[A,$.newPath,N.newPath],U.filemask=7,U.merged={result:null,clean:!1}}}else{let z=r.get($.newPath),_=o.get(N.newPath),U=await vf(e,B,z,_,s);U.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:$.newPath,theirsPath:N.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${$.newPath} in ${p} and to ${N.newPath} in ${g}.`),i.entries.push(wt(A,B,1)),i.entries.push(st($.newPath,z.mode,U.hash,2)),i.entries.push(st(N.newPath,_.mode,U.hash,3)),i.worktreeBlobs.set($.newPath,{hash:U.hash,mode:z.mode}),i.worktreeBlobs.set(N.newPath,{hash:U.hash,mode:_.mode})}else if($){h.add($.newPath);let z=o.get(A),_=r.get($.newPath),U=m.has($.newPath);if(z)if(U)await Sf(e,i,$.newPath,A,B,_,z,r,o,!1,s);else if(z.hash===B.hash&&_.hash===B.hash)i.entries.push(wt($.newPath,_));else if(z.hash===B.hash)i.entries.push(wt($.newPath,_));else if(_.hash===B.hash)i.entries.push(st($.newPath,_.mode,z.hash));else{let V=Gi(t,$.newPath);V.stages=[{hash:B.hash,mode:B.mode},{hash:_.hash,mode:_.mode},{hash:z.hash,mode:z.mode}],V.pathnames=[A,$.newPath,A],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=o.get($.newPath);if(i.conflicts.push({path:$.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w($.newPath,`CONFLICT (rename/delete): ${A} renamed to ${$.newPath} in ${p}, but deleted in ${g}.`),V){i.conflicts.push({path:$.newPath,reason:"add-add"}),w($.newPath,`Auto-merging ${$.newPath}`,0),w($.newPath,`CONFLICT (add/add): Merge conflict in ${$.newPath}`,1),i.entries.push(wt($.newPath,_,2)),i.entries.push(wt($.newPath,V,3));let be=await go(e,_.hash,V.hash,_.mode,s);i.worktreeBlobs.set($.newPath,{hash:be,mode:_.mode})}else i.entries.push(st($.newPath,B.mode,B.hash,1)),i.entries.push(wt($.newPath,_,2)),i.worktreeBlobs.set($.newPath,{hash:_.hash,mode:_.mode}),_.hash!==B.hash&&w($.newPath,`CONFLICT (modify/delete): ${$.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${$.newPath} left in tree.`,1)}}else if(N){h.add(N.newPath);let z=r.get(A),_=o.get(N.newPath),U=m.has(N.newPath);if(z)if(U)await Sf(e,i,N.newPath,A,B,z,_,r,o,!0,s);else if(z.hash===B.hash&&_.hash===B.hash)i.entries.push(wt(N.newPath,_));else if(z.hash===B.hash)i.entries.push(wt(N.newPath,_));else if(_.hash===B.hash)i.entries.push(st(N.newPath,_.mode,z.hash));else{let V=Gi(t,N.newPath);V.stages=[{hash:B.hash,mode:B.mode},{hash:z.hash,mode:z.mode},{hash:_.hash,mode:_.mode}],V.pathnames=[A,A,N.newPath],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=r.get(N.newPath);if(i.conflicts.push({path:N.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(N.newPath,`CONFLICT (rename/delete): ${A} renamed to ${N.newPath} in ${g}, but deleted in ${p}.`),V){i.conflicts.push({path:N.newPath,reason:"add-add"}),w(N.newPath,`Auto-merging ${N.newPath}`,0),w(N.newPath,`CONFLICT (add/add): Merge conflict in ${N.newPath}`,1),i.entries.push(wt(N.newPath,V,2)),i.entries.push(wt(N.newPath,_,3));let be=await go(e,V.hash,_.hash,V.mode,s);i.worktreeBlobs.set(N.newPath,{hash:be,mode:V.mode})}else i.entries.push(st(N.newPath,B.mode,B.hash,1)),i.entries.push(wt(N.newPath,_,3)),i.worktreeBlobs.set(N.newPath,{hash:_.hash,mode:_.mode}),_.hash!==B.hash&&w(N.newPath,`CONFLICT (modify/delete): ${N.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${N.newPath} left in tree.`,1)}}}let y=new Set(f.renames.map(A=>A.newPath)),x=new Set(l.renames.map(A=>A.newPath)),b=Cf(n,r),k=Cf(n,o),E=Pf(b,o,n),R=Pf(k,r,n),P=Of(f.renames,E),C=Of(l.renames,R),T=If(P),D=If(C);for(let A of[...T.keys()])D.has(A)&&(T.delete(A),D.delete(A));let O=new Set(T.keys()),H=new Set(D.keys());if(D.size>0)for(let A of a){if(A.status!=="added"||y.has(A.path))continue;let $=$f(A.path,D,O);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(r.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let z=r.get(A.path),_=o.get($)??n.get($);i.entries.push(st($,z.mode,z.hash,2)),_&&i.entries.push(st($,_.mode,_.hash,3)),i.worktreeBlobs.set($,{hash:z.hash,mode:z.mode}),i.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let N=r.get(A.path);i.entries.push(st($,N.mode,N.hash,2)),i.worktreeBlobs.set($,{hash:N.hash,mode:N.mode}),i.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}if(T.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let $=$f(A.path,T,H);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(o.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let z=o.get(A.path),_=r.get($)??n.get($);_&&i.entries.push(st($,_.mode,_.hash,2)),i.entries.push(st($,z.mode,z.hash,3)),i.worktreeBlobs.set($,{hash:z.hash,mode:z.mode}),i.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let N=o.get(A.path);i.entries.push(st($,N.mode,N.hash,3)),i.worktreeBlobs.set($,{hash:N.hash,mode:N.mode}),i.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}let G=new Set(i.entries.map(A=>A.path));for(let A of G){let $=t.get(A);$&&($.merged={result:null,clean:!0})}for(let A of h){if(G.has(A))continue;let $=t.get(A);if(!$||$.merged.clean)continue;$.filemask===7&&!$.pathConflict||($.merged={result:null,clean:!0})}return i}function Cf(e,t){let n=new Set;for(let s of e.keys()){let i=Pt(s);for(;i;)n.add(i),i=Pt(i)}let r=new Set;for(let s of t.keys()){let i=Pt(s);for(;i;)r.add(i),i=Pt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Pf(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=Pt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Pt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Pt(s)}return r}function Of(e,t){let n=new Map;for(let r of e){let o=Pt(r.oldPath),s=Pt(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)),l=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==l)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=Pt(o),s=Pt(s)}}return n}function If(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 $f(e,t,n){let r=Pt(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=Pt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Pt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Sf(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),u=f?i:s;if(d.hash===u.hash){t.entries.push(st(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await vf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(st(n,d.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(wt(n,d,2)),t.entries.push(st(n,i.mode,h.hash,3));let p=await go(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(st(n,s.mode,h.hash,2)),t.entries.push(wt(n,d,3));let p=await go(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function vf(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(hn(t.mode)||hn(n.mode)||hn(r.mode))return{hash:n.hash,conflict:!0};let a=await ae(e,t.hash),c=await ae(e,n.hash),f=await ae(e,r.hash);if(Ae(c)||Ae(f)||Ae(a))return{hash:n.hash,conflict:!0};let l=Ct(a),d=Ct(c),u=Ct(f),m=o?.conflictStyle,h=as(d,l,u,{conflictStyle:m});if(!h.conflict)return{hash:await _i(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,y=s?.theirsPath?`${g}:${s.theirsPath}`:g,x=ar(c,a,f,{a:w,b:y,markerSize:i??7,conflictStyle:m});return{hash:await $e(e,"blob",Un.encode(x)),conflict:!0}}async function go(e,t,n,r,o){let s=await ae(e,t),i=await ae(e,n),a=ar(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return $e(e,"blob",Un.encode(a))}function wt(e,t,n=0){return st(e,t.mode,t.hash,n)}function st(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Ie()}}async function uh(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(Me(m,h.merged.result.hash,h.merged.result.mode));continue}await mh(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),l=[],d=new Set;for(let m of o)m.stage===0&&(l.push(m),d.add(m.path));for(let[m,h]of a)d.has(m)||l.push(Me(m,h.hash,h.mode));l.sort((m,h)=>Oe(m.path,h.path));let u=await Ge(e,l);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function mh(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,u=f?.hash??null,m=l?.hash??null;if(u===null&&m!==null&&d!==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(Me(a,d,c.mode,1)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:m,mode:l.mode});return}if(m===null&&u!==null&&d!==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(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(d===null&&u!==null&&m!==null){if(u===m){r.push(Me(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await ae(e,u),p=await ae(e,m);if(Ae(h)||Ae(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(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=Ct(""),w=Ct(h),y=Ct(p),x=as(w,g,y,{conflictStyle:n?.conflictStyle});if(!x.conflict){let E=await _i(e,x.result);r.push(Me(a,E,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3));let b=ar(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),k=await $e(e,"blob",Un.encode(b));i.set(a,{hash:k,mode:f.mode});return}if(d!==null&&u!==null&&m!==null){if(u===d){r.push(Me(a,m,l.mode));return}if(m===d){r.push(Me(a,u,f.mode));return}if(u===m){r.push(Me(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),hn(c.mode)||hn(f.mode)||hn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await ae(e,d),p=await ae(e,u),g=await ae(e,m);if(Ae(p)||Ae(g)||Ae(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(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=Ct(h),y=Ct(p),x=Ct(g),b=as(y,w,x,{conflictStyle:n?.conflictStyle});if(b.conflict){let k=t.pathnames[1],E=t.pathnames[2],R=k!==a||E!==a,P={path:a,reason:"content"};R&&(k!==a&&(P.oursOrigPath=k),E!==a&&(P.theirsOrigPath=E)),o.push(P),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Me(a,d,c.mode,1)),r.push(Me(a,u,f.mode,2)),r.push(Me(a,m,l.mode,3));let C=R?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",T=R?`${n?.b??"theirs"}:${E}`:n?.b??"theirs",D=ar(p,h,g,{a:C,b:T,conflictStyle:n?.conflictStyle}),O=await $e(e,"blob",Un.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let k=await _i(e,b.result);r.push(Me(a,k,f.mode))}return}}var hh=200;async function Hf(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await j(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await j(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],u=(await j(e,d)).tree,m=null;if(o>=hh)m=f;else{let g=await _t(e,c,d);g.length===0?m=null:g.length===1?m=(await j(e,g[0])).tree:m=await Hf(e,c,d,g,o+1)}let h=await Nt(e,m,f,u);f=await ph(e,h,o);let p=tn({type:"commit",tree:f,parents:[c,d],author:xf,committer:xf,message:"merged common ancestors"});c=await $e(e,"commit",p)}return f}async function ph(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 l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),m=s(l,2),h=s(d,3);if(m&&h){let p=Rr.decode((await we(e,m.hash)).content),g=Rr.decode((await we(e,h.hash)).content),w=u?Rr.decode((await we(e,u.hash)).content):"",y=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",k=ar(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:y}),E=await $e(e,"blob",Un.encode(k));r.push({path:l,mode:m.mode,hash:E,stage:0,stat:Ie()}),r.push({path:d,mode:h.mode,hash:E,stage:0,stat:Ie()});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 l=Rr.decode((await we(e,c.hash)).content),d=Rr.decode((await we(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?Rr.decode((await we(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,y=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=ar(l,m,d,{a:w,o:i.o,b:y,markerSize:i.markerSize}),b=await $e(e,"blob",Un.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Ie()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Oe(a.path,c.path)),Ge(e,r)}async function _i(e,t){let n=t.map(ji);if(n.length===0)return $e(e,"blob",Un.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
|
|
247
247
|
`):`${n.join(`
|
|
248
248
|
`)}
|
|
249
|
-
`;return
|
|
249
|
+
`;return $e(e,"blob",Un.encode(s))}function Me(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Ie()}}function Gi(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 cs(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}
|
|
250
250
|
${e.join(" ")}
|
|
251
251
|
Merge with strategy ort failed.
|
|
252
252
|
`;let c=e.map(l=>` ${l}`).join(`
|
|
@@ -261,7 +261,7 @@ ${i}
|
|
|
261
261
|
${a}
|
|
262
262
|
Aborting
|
|
263
263
|
fatal: ${n} failed
|
|
264
|
-
`}function
|
|
264
|
+
`}function Tf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
|
|
265
265
|
`);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
|
|
266
266
|
${i}
|
|
267
267
|
Please commit your changes or stash them before you ${n}.
|
|
@@ -271,24 +271,24 @@ ${i}
|
|
|
271
271
|
Please move or remove them before you ${n}.
|
|
272
272
|
`)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
|
|
273
273
|
${s}
|
|
274
|
-
`}async function En(e,t,n,r){let o=await K(e),s=await
|
|
275
|
-
`),
|
|
276
|
-
...`:"";return
|
|
274
|
+
`}async function En(e,t,n,r){let o=await K(e),s=await ce(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(je(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let y=s.get(g);(!y||y.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await Li(e,o,s);let w=r.operationName??"merge",y=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:cs(g,w,y,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Qn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Bs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Li(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),y=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&y.length>0?x=Tf(w,y,p,g):y.length>0?x=cs(y,p,g,"untracked","worktree"):x=cs(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Qn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Ws,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Li(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),y=h.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),x=[];w.length>0&&x.push(cs(w,p,g,"local","worktree")),y.length>0&&x.push(cs(y,p,g,"untracked","worktree"));let b;return x.length>1?b=Tf(w,y,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await De(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)),l=[...a,...f];l.sort((h,p)=>Oe(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await ie(e,d);let u=l.filter(h=>h.stage===0),m=await Ge(e,u);return{ok:!0,finalIndex:d,mergedTreeHash:m}}async function Li(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=S(e.workTree,r.path);await e.fs.exists(o)||await at(e,{path:r.path,hash:r.hash,mode:r.mode})}}oe();Fe();ue();Te();sn();function Af(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[q.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:v().describe("Abort the current cherry-pick operation"),continue:v().describe("Continue the cherry-pick after conflict resolution"),skip:v().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":v().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:v().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let B=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commit:null});if(ee(B))return{stdout:"",stderr:B.message??"",exitCode:1};let z=await wh(s,r.env);return z.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),z}if(n.continue){let B=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commit:null});if(ee(B))return{stdout:"",stderr:B.message??"",exitCode:1};let z=await bh(s,r.env);return z.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),z}if(n.skip)return gh(s,r.env);let i=n.commit;if(!i)return I("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await ve(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Ze(s);if(M(d))return d;let u=await K(s);if(n.noCommit){let B=u.entries.filter(z=>z.stage>0);if(B.length>0){let U=B.slice(0,10).map(be=>`${be.path}: unmerged (${be.hash})`).join(`
|
|
275
|
+
`),V=B.length>10?`
|
|
276
|
+
...`:"";return L(`${U}${V}
|
|
277
277
|
error: your index file is unmerged.
|
|
278
278
|
fatal: cherry-pick failed
|
|
279
279
|
`,128)}}else{let B=gn(u,"Cherry-picking",`fatal: cherry-pick failed
|
|
280
|
-
`);if(B)return B}let m=await
|
|
280
|
+
`);if(B)return B}let m=await j(s,d),p=!!n["record-origin"]?yh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let B=await ce(s,m.tree);if(gr(u,B))return L(`error: your local changes would be overwritten by cherry-pick.
|
|
281
281
|
hint: commit your changes or stash them to proceed.
|
|
282
282
|
fatal: cherry-pick failed
|
|
283
|
-
`,128)}if(l.parents.length>1){if(!n.mainline)return
|
|
283
|
+
`,128)}if(l.parents.length>1){if(!n.mainline)return L(`error: commit ${f} is a merge but no -m option was given.
|
|
284
284
|
fatal: cherry-pick failed
|
|
285
|
-
`,128);let B=n.mainline-1;if(B<0||B>=l.parents.length)return
|
|
285
|
+
`,128);let B=n.mainline-1;if(B<0||B>=l.parents.length)return L(`error: commit ${f} does not have parent ${n.mainline}
|
|
286
286
|
fatal: cherry-pick failed
|
|
287
|
-
`,128)}else if(n.mainline)return
|
|
287
|
+
`,128)}else if(n.mainline)return L(`error: mainline was specified but commit is not a merge.
|
|
288
288
|
fatal: cherry-pick failed
|
|
289
|
-
`,128);let g;if(l.parents.length===0)g=await Ge(s,[]);else{let B=l.parents.length>1?n.mainline-1:0,
|
|
289
|
+
`,128);let g;if(l.parents.length===0)g=await Ge(s,[]);else{let B=l.parents.length>1?n.mainline-1:0,z=l.parents[B];if(!z)throw new Error("unreachable: parent must exist");g=(await j(s,z)).tree}let w=Y(f),y=fe(l.message),x=await ke(s,"merge.conflictstyle")??"merge",b={a:"HEAD",b:y?`${w} (${y})`:w,conflictStyle:x},k=await Nt(s,g,m.tree,l.tree,b);if(k.conflicts.length===0&&k.resultTree===m.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Se(s,"MERGE_MSG",p);let B=k.messages.length>0?`${k.messages.join(`
|
|
290
290
|
`)}
|
|
291
|
-
`:"",
|
|
291
|
+
`:"",z=await rt(s,{fromCommit:!0});return{stdout:`${B}${z}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
292
292
|
If you wish to commit it anyway, use:
|
|
293
293
|
|
|
294
294
|
git commit --allow-empty
|
|
@@ -296,12 +296,12 @@ If you wish to commit it anyway, use:
|
|
|
296
296
|
Otherwise, please use 'git cherry-pick --skip'
|
|
297
297
|
`,exitCode:1}}let E=await En(s,k,m.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(k.conflicts.length>0){let B=k.messages.join(`
|
|
298
298
|
`);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:B?`${B}
|
|
299
|
-
`:"",stderr:`error: could not apply ${w}... ${
|
|
299
|
+
`:"",stderr:`error: could not apply ${w}... ${fe(l.message)}
|
|
300
300
|
hint: after resolving the conflicts, mark the corrected paths
|
|
301
301
|
hint: with 'git add <paths>' or 'git rm <paths>'
|
|
302
302
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
303
|
-
`,exitCode:1}:(await
|
|
304
|
-
`:"",stderr:`error: could not apply ${w}... ${
|
|
303
|
+
`,exitCode:1}:(await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Se(s,"MERGE_MSG",p),{stdout:B?`${B}
|
|
304
|
+
`:"",stderr:`error: could not apply ${w}... ${fe(l.message)}
|
|
305
305
|
hint: After resolving the conflicts, mark them with
|
|
306
306
|
hint: "git add/rm <pathspec>", then run
|
|
307
307
|
hint: "git cherry-pick --continue".
|
|
@@ -309,57 +309,57 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
|
|
|
309
309
|
hint: To abort and get back to the state before "git cherry-pick",
|
|
310
310
|
hint: run "git cherry-pick --abort".
|
|
311
311
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
312
|
-
`,exitCode:1})}let
|
|
313
|
-
`)[0]??"",O=T?.type==="symbolic"?T.target:"HEAD";await re(s,r.env,O,d,C,`cherry-pick: ${D}`,T?.type==="symbolic");let H=T?.type==="symbolic"?
|
|
312
|
+
`,exitCode:1})}let R=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let P=await Qe(s,r.env);if(M(P))return P;let C=await mt(s,R,[d],l.author,P,p);await Dt(s),await Mt(s);let T=await J(s),D=p.split(`
|
|
313
|
+
`)[0]??"",O=T?.type==="symbolic"?T.target:"HEAD";await re(s,r.env,O,d,C,`cherry-pick: ${D}`,T?.type==="symbolic");let H=T?.type==="symbolic"?Re(T.target):"detached HEAD",G=m.tree,A=await cn(s,G,R,l.author,P,!0),$=vt(H,C,p),N=k.messages.length>0?`${k.messages.join(`
|
|
314
314
|
`)}
|
|
315
|
-
`:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${
|
|
316
|
-
${A}`,stderr:"",exitCode:0}}})}async function
|
|
315
|
+
`:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${N}${$}
|
|
316
|
+
${A}`,stderr:"",exitCode:0}}})}async function gh(e,t){if(!await F(e,"CHERRY_PICK_HEAD"))return L(`error: no cherry-pick in progress
|
|
317
317
|
fatal: cherry-pick failed
|
|
318
|
-
`,128);let r=await
|
|
318
|
+
`,128);let r=await Z(e);if(!r)return I("unable to resolve HEAD");let o=await j(e,r),s=await K(e),i=await zs(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
|
|
319
319
|
fatal: cherry-pick failed
|
|
320
|
-
`}}return await ie(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await
|
|
320
|
+
`}}return await ie(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Dt(e),{stdout:"",stderr:"",exitCode:0}}async function wh(e,t){return await F(e,"CHERRY_PICK_HEAD")?An(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
|
|
321
321
|
fatal: cherry-pick failed
|
|
322
|
-
`,128),operationName:"cherry-pick",clearState:
|
|
322
|
+
`,128),operationName:"cherry-pick",clearState:Dt,origHeadAsTargetRev:!0}):await F(e,"REVERT_HEAD")?An(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
|
|
323
323
|
fatal: cherry-pick failed
|
|
324
|
-
`,128),operationName:"cherry-pick",clearState:
|
|
324
|
+
`,128),operationName:"cherry-pick",clearState:Mt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
|
|
325
325
|
fatal: cherry-pick failed
|
|
326
|
-
`,128)}async function
|
|
326
|
+
`,128)}async function bh(e,t){let n=await F(e,"CHERRY_PICK_HEAD");if(!n)return L(`error: no cherry-pick or revert in progress
|
|
327
327
|
fatal: cherry-pick failed
|
|
328
|
-
`,128);let r=await K(e),o=gn(r,"Committing");if(o)return o;let s=await
|
|
329
|
-
`,1);let a=await
|
|
330
|
-
${b}`,stderr:"",exitCode:0}}function
|
|
328
|
+
`,128);let r=await K(e),o=gn(r,"Committing");if(o)return o;let s=await j(e,n),i=await Ce(e,"MERGE_MSG");if(!i)return L(`Aborting commit due to empty commit message.
|
|
329
|
+
`,1);let a=await Ce(e,"SQUASH_MSG");a&&(i=a+i),i=an(i);let c=je(r),f=await Ge(e,c),l=await Ze(e);if(M(l))return l;let u=(await j(e,l)).tree,m=await Qe(e,t);if(M(m))return m;let h=Ht(i),p=await mt(e,f,[l],s.author,m,h);await Dt(e),await Mt(e),await pe(e,"SQUASH_MSG");let g=await J(e),w=fe(h),y=g?.type==="symbolic"?g.target:"HEAD";await re(e,t,y,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Re(g.target):"detached HEAD",b=await cn(e,u,f,s.author,m,!0);return{stdout:`${vt(x,p,i)}
|
|
330
|
+
${b}`,stderr:"",exitCode:0}}function yh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
|
|
331
331
|
`),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
|
|
332
332
|
${n}
|
|
333
333
|
`:`${r}
|
|
334
334
|
|
|
335
335
|
${n}
|
|
336
|
-
`}se();
|
|
336
|
+
`}se();Ne();Us();Pe();le();function Df(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[q.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:v().alias("f").describe("Required to actually remove files"),"dry-run":v().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:v().alias("d").describe("Also remove untracked directories"),removeIgnored:v().alias("x").describe("Remove ignored files as well"),onlyIgnored:v().alias("X").describe("Remove only ignored files"),exclude:Q.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,u=n.onlyIgnored,m=await t?.hooks?.preClean?.({repo:s,dryRun:c,force:f,removeDirs:l,removeIgnored:d,onlyIgnored:u});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};if(!f&&!c&&await ke(s,"clean.requireForce")!=="false")return I("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await K(s),p=new Set(h.entries.map(P=>P.path)),g=ut(s,r.cwd),w=n.pathspec,y=w.length>0?w.map(P=>Ue(P,g)):null,x=n.exclude?[n.exclude]:[],b=await Mf(s,a,"",{trackedPaths:p,removeDirs:l,removeIgnored:d,onlyIgnored:u,extraExcludes:x}),k;y?k=b.filter(P=>ye(y,P.path)):k=b,k.sort((P,C)=>P.path<C.path?-1:P.path>C.path?1:0);let E=[];if(c)for(let P of k){let C=P.isDir?`Would remove ${P.path}/`:`Would remove ${P.path}`;E.push(C)}else for(let P of k){let C=S(a,P.path);P.isDir?(await r.fs.rm(C,{recursive:!0}),E.push(`Removing ${P.path}/`)):(await r.fs.rm(C),E.push(`Removing ${P.path}`))}let R=E.length>0?`${E.join(`
|
|
337
337
|
`)}
|
|
338
|
-
`:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(P=>P.path),dryRun:c}),{stdout:
|
|
339
|
-
`),l=
|
|
340
|
-
`)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function
|
|
338
|
+
`:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(P=>P.path),dryRun:c}),{stdout:R,stderr:"",exitCode:0}}})}async function Mf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await pr(e);let c=S(t,".gitignore");try{let f=await e.fs.readFile(c);i=Zn(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
|
|
339
|
+
`),l=Zr(f,"","<cli>");i={...i,dirPatterns:[l,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=S(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let u=i&&nn(i,l,!0)==="ignored",m=Eh(r.trackedPaths,l),h=()=>Mf(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:l,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:l,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let u=i&&nn(i,l,!1)==="ignored";r.onlyIgnored?u&&o.push({path:l,isDir:!1}):u&&s||o.push({path:l,isDir:!1})}}return o}function Eh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}se();Ne();xn();Pe();oe();le();Fe();ue();$n();oe();le();var ls=2147483647;async function xr(e){let t=S(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
|
|
340
|
+
`)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function kh(e,t){let n=S(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
|
|
341
341
|
`)+`
|
|
342
|
-
`)}async function ds(e){return(await ar(e)).size>0}async function cr(e,t,n){let r=n??await ar(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await Gf(e,r)}async function _i(e,t,n,r){if(n>=Cr)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await zt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await L(e,f)}catch{continue}for(let u of d.parents)!o.has(u)&&await zt(e,u)&&(o.set(u,l+1),s.push({hash:u,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}Le();In();dt();oe();var bo=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]),Rh=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]),wo=64,xh=4,Ni=4096,Lf=65536,Ch=127;function Ph(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=Ih(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])^bo[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<=wo)continue;let h=[],p=m.length/wo;for(let g=0;g<wo;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=wo}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let m=c.get(u);if(m){for(let h of m)l.push(h);d+=m.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function Oh(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=Nf(i,a,r),a=Nf(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^bo[f>>>23],l++;f=f>>>0;let u=d,m=0,h=0;for(;u<o;){if(h<Ni){f^=Rh[t[u-16]],f=((f<<8|t[u])^bo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let R=e.entries[y];if(R.val!==f)continue;let b=R.ptr,k=s.byteLength-b,E=o-u;if(k>E&&(k=E),k<=h)break;let x=0;for(;x<k&&s[b+x]===t[u+x];)x++;if(x>h&&(h=x,m=b,h>=Ni))break}}if(h<xh)c(2),l===0&&a++,i[a++]=t[u++],l++,l===Ch&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Lf?h-Lf: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<Ni){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^bo[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var _f={blob:0,tree:1,commit:2,tag:3};function yo(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=_f[f.type]??99,u=_f[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.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!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let R=a[p-h]??null;if(!R)continue;let b=u?u.byteLength:l.content.byteLength/2|0;if(b<16)continue;let k=Oh(R,l.content,b);k&&(!u||k.byteLength<u.byteLength)&&(u=k,m=g.hash)}if(u&&m){d.delta=u,d.deltaBase=m;let p=s.get(m);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(Ph(l.content)),c.push(l.hash)}return i}function Ih(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 Nf(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}Ur();ue();oe();dn();zr();Ls();async function Sh(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await us(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await L(e,l);for(let u of d.parents)i.has(u)||a.push(u)}catch{}let c=[],f=new Set;for(let l of a)await ms(e,l,i,f,c,r);return{count:c.length,objects:$h(c)}}async function Pr(e,t,n,r,o){let{count:s,objects:i}=await Sh(e,t,n,r,o);return{count:s,objects:Th(e,i)}}async function*$h(e){for(let t of e)yield t}async function*Th(e,t){for await(let n of t){let r=await we(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Or(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function us(e,t,n,r){if(n.has(t)||(n.add(t),!await zt(e,t)))return;let o=await we(e,t);switch(o.type){case"commit":{let s=en(o.content);if(await us(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await us(e,i,n,r);break}case"tree":{let s=Tn(o.content);for(let i of s.entries)await us(e,i.hash,n,r);break}case"tag":{let s=un(o.content);await us(e,s.object,n,r);break}case"blob":break}}async function ms(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await we(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=en(i.content);if(await ms(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await ms(e,c,n,r,o,s);break}case"tree":{let a=Tn(i.content);for(let c of a.entries)await ms(e,c.hash,n,r,o,s);break}case"tag":{let a=un(i.content);await ms(e,a.object,n,r,o,s);break}case"blob":break}}var vh=new TextEncoder,Eo=new TextDecoder,Ff=65520,Hh=new Uint8Array([48,48,48,48]);function kn(e){let t=typeof e=="string"?vh.encode(e):e,n=4+t.byteLength;if(n>Ff)throw new Error(`pkt-line too long: ${n} bytes (max ${Ff})`);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 Fi(){return Hh.slice()}function ko(...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 Ir(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=Eo.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Ro(e){if(e.type==="flush")return"";let t=Eo.decode(e.data);return t.endsWith(`
|
|
343
|
-
`)?t.slice(0,-1):t}var Ah=1,Dh=2,Mh=3;function Ui(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 Ah:t.push(f),o+=f.byteLength;break;case Dh:n.push(
|
|
342
|
+
`)}async function wo(e){return(await xr(e)).size>0}async function Cr(e,t,n){let r=n??await xr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await kh(e,r)}async function jf(e,t,n,r){if(n>=ls)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await zt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await j(e,f)}catch{continue}for(let u of d.parents)!o.has(u)&&await zt(e,u)&&(o.set(u,l+1),s.push({hash:u,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}Ne();$n();dt();oe();var yo=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]),Rh=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]),bo=64,xh=4,Ni=4096,Gf=65536,Ch=127;function Ph(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=Ih(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])^yo[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<=bo)continue;let h=[],p=m.length/bo;for(let g=0;g<bo;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=bo}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let m=c.get(u);if(m){for(let h of m)l.push(h);d+=m.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function Oh(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=_f(i,a,r),a=_f(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^yo[f>>>23],l++;f=f>>>0;let u=d,m=0,h=0;for(;u<o;){if(h<Ni){f^=Rh[t[u-16]],f=((f<<8|t[u])^yo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let x=e.entries[y];if(x.val!==f)continue;let b=x.ptr,k=s.byteLength-b,E=o-u;if(k>E&&(k=E),k<=h)break;let R=0;for(;R<k&&s[b+R]===t[u+R];)R++;if(R>h&&(h=R,m=b,h>=Ni))break}}if(h<xh)c(2),l===0&&a++,i[a++]=t[u++],l++,l===Ch&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Gf?h-Gf: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<Ni){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^yo[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var Lf={blob:0,tree:1,commit:2,tag:3};function Eo(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Lf[f.type]??99,u=Lf[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.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!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=u?u.byteLength:l.content.byteLength/2|0;if(b<16)continue;let k=Oh(x,l.content,b);k&&(!u||k.byteLength<u.byteLength)&&(u=k,m=g.hash)}if(u&&m){d.delta=u,d.deltaBase=m;let p=s.get(m);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(Ph(l.content)),c.push(l.hash)}return i}function Ih(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 _f(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}Fr();ue();oe();dn();qr();Ls();async function $h(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await ds(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let u of d.parents)i.has(u)||a.push(u)}catch{}let c=[],f=new Set;for(let l of a)await us(e,l,i,f,c,r);return{count:c.length,objects:Sh(c)}}async function Pr(e,t,n,r,o){let{count:s,objects:i}=await $h(e,t,n,r,o);return{count:s,objects:Th(e,i)}}async function*Sh(e){for(let t of e)yield t}async function*Th(e,t){for await(let n of t){let r=await we(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Or(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function ds(e,t,n,r){if(n.has(t)||(n.add(t),!await zt(e,t)))return;let o=await we(e,t);switch(o.type){case"commit":{let s=en(o.content);if(await ds(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await ds(e,i,n,r);break}case"tree":{let s=vn(o.content);for(let i of s.entries)await ds(e,i.hash,n,r);break}case"tag":{let s=un(o.content);await ds(e,s.object,n,r);break}case"blob":break}}async function us(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await we(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=en(i.content);if(await us(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await us(e,c,n,r,o,s);break}case"tree":{let a=vn(i.content);for(let c of a.entries)await us(e,c.hash,n,r,o,s);break}case"tag":{let a=un(i.content);await us(e,a.object,n,r,o,s);break}case"blob":break}}var vh=new TextEncoder,ko=new TextDecoder,Nf=65520,Hh=new Uint8Array([48,48,48,48]);function kn(e){let t=typeof e=="string"?vh.encode(e):e,n=4+t.byteLength;if(n>Nf)throw new Error(`pkt-line too long: ${n} bytes (max ${Nf})`);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 Fi(){return Hh.slice()}function Ro(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function Ir(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=ko.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 xo(e){if(e.type==="flush")return"";let t=ko.decode(e.data);return t.endsWith(`
|
|
343
|
+
`)?t.slice(0,-1):t}var Ah=1,Dh=2,Mh=3;function Ui(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 Ah:t.push(f),o+=f.byteLength;break;case Dh:n.push(ko.decode(f));break;case Mh:r.push(ko.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}dt();function Bi(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function Wi(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...Bi(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 l=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(l))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=Ir(c);return jh(f,t)}function jh(e,t){let n=0,r=e[n];r?.type==="data"&&xo(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),l;if(f!==-1){l=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 l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let u=l.slice(0,d),m=l.slice(d+1);if(!(u===te&&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 Gh=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function Ff(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=Bf(r,Gh),c=[];c.push(kn(`want ${t[0]} ${a.join(" ")}
|
|
344
344
|
`));for(let m=1;m<t.length;m++)c.push(kn(`want ${t[m]}
|
|
345
345
|
`));if(i?.existingShallows)for(let m of i.existingShallows)c.push(kn(`shallow ${m}
|
|
346
346
|
`));i?.depth!==void 0&&c.push(kn(`deepen ${i.depth}
|
|
347
347
|
`)),c.push(Fi());for(let m of n)c.push(kn(`have ${m}
|
|
348
348
|
`));c.push(kn(`done
|
|
349
|
-
`));let f=
|
|
349
|
+
`));let f=Ro(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...Bi(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let u=new Uint8Array(await d.arrayBuffer());return Lh(u,a.includes("side-band-64k"))}function Lh(e,t){let n=Ir(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let u=n[d];if(!u||u.type==="flush"){i=d+1;continue}if(u.type!=="data")continue;let m=xo(u);if(m.startsWith("shallow "))o.push(m.slice(8)),i=d+1;else if(m.startsWith("unshallow "))s.push(m.slice(10)),i=d+1;else if(m.startsWith("ACK ")||m==="NAK")r.push(m),i=d+1;else{i=d;break}}let a=n.slice(i);if(t){let{packData:d,progress:u,errors:m}=Ui(a);if(m.length>0)throw new Error(`Remote error: ${m.join("")}`);return{packData:d,acks:r,progress:u,shallowLines:o,unshallowLines:s}}let c=0;for(let d of a)d.type==="data"&&(c+=d.data.byteLength);let f=new Uint8Array(c),l=0;for(let d of a)d.type==="data"&&(f.set(d.data,l),l+=d.data.byteLength);return{packData:f,acks:r,progress:[],shallowLines:o,unshallowLines:s}}var _h=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Uf(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=Bf(r,_h),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(kn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
|
|
350
350
|
`));for(let h of f)a.push(kn(`${h.oldHash} ${h.newHash} ${h.refName}
|
|
351
|
-
`));a.push(Fi());let l;if(n&&n.byteLength>0){let h=
|
|
351
|
+
`));a.push(Fi());let l;if(n&&n.byteLength>0){let h=Ro(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=Ro(...a);let d=e.replace(/\/+$/,""),u=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...Bi(o),"User-Agent":"just-git/1.0"},body:l});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${d}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?Nh(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Nh(e,t){let n,r=[];if(t){let a=Ir(e),{packData:c,progress:f,errors:l}=Ui(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Ir(c)}else n=Ir(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=xo(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),l=f.indexOf(" ");l!==-1?i.push({name:f.slice(0,l),ok:!1,error:f.slice(l+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function Bf(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 ms=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await ge(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await F(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await J(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n,r){let o=await this.advertiseRefs();if(t.length===0)return{remoteRefs:o,objectCount:0};let s,i,a;if(r?.depth!==void 0){let l=r.existingShallows??new Set,d=await jf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await qi(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Ds(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==te&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await qi(this.local,n,r);s&&await Ds(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===te,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await yn(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},hs=class{constructor(t,n,r,o){this.local=t;this.url=n;this.auth=r;this.fetchFn=o}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await Wi(this.url,"git-upload-pack",this.auth,this.fetchFn);this.cachedFetchCaps=t.capabilities,this.cachedFetchRefs=t.refs;let n=t.symrefs.get("HEAD");return n&&(this.headTarget=n),t.refs}async ensureFetchDiscovery(){return(!this.cachedFetchCaps||!this.cachedFetchRefs)&&await this.advertiseRefs(),{caps:this.cachedFetchCaps,refs:this.cachedFetchRefs}}async ensurePushDiscovery(){if(!this.cachedPushCaps){let t=await Wi(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n,r){let{caps:o,refs:s}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:s,objectCount:0};let i=await Ff(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Ds(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==te&&l.newHash!==te&&!l.ok&&!await yn(this.local,l.oldHash,l.newHash))return{updates:t.map(u=>u===l?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(l=>({oldHash:l.oldHash??te,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==te&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==te&&s.push(l.oldHash);let a=null;i&&(a=await qi(this.local,o,s)??null);let c=await Uf(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(l=>{let d=c.refResults.find(h=>h.name===l.name),u=d?.ok??c.unpackOk,m=d?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...l,ok:u,error:m}})}}};async function qi(e,t,n,r,o){let s=await Pr(e,t,n,r,o);if(s.count===0)return;let i=await Or(s),c=Eo(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Hs(c);return f}async function Fh(e,t){let r=(await he(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function zi(e){return e.startsWith("http://")||e.startsWith("https://")}function Wf(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(zi(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 Uh(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 qf(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return Uh(n)}async function zf(e,t,n,r){if(zi(t)){let o=Wf(t,e.networkPolicy);if(o)throw new Error(o);let s=await qf(e,t,n);return new hs(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 ms(e,r)}async function $r(e,t,n){let r=await Fh(e,t);if(!r)return null;if(zi(r.url)){let s=Wf(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await qf(e,r.url,n):void 0;return{transport:new hs(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await Vn(e.fs,r.url);return o?{transport:new ms(e,o),config:r}:null}Te();tt();function Kf(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[q.string().name("repository").describe("Repository to clone"),q.string().name("directory").describe("Target directory").optional()],options:{bare:v().describe("Create a bare clone"),branch:Q.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Q.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return I("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=s?o:Ot(r.cwd,o),a=n.branch,c=n.directory;if(!c){let O=s?o.split("/").pop()??o:Ar(i);O.endsWith(".git")&&(O=O.slice(0,-4)),c=O}let f=Ot(r.cwd,c),l=await t?.hooks?.preClone?.({repository:o,targetPath:f,bare:n.bare,branch:a??null});if(ee(l))return L(l.message??"");if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return I(`destination path '${c}' already exists and is not an empty directory.`)}catch{return I(`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 Vn(r.fs,i)),!d))return I(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await Ms(r.fs,f,{bare:n.bare}),m=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:u,h=await he(m);h['remote "origin"']={url:i,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Ye(m,h);let p;try{p=await zf(m,i,r.env,d??void 0)}catch(O){let H=O instanceof Error?O.message:"";return H.startsWith("network")?I(H):I(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:f,bare:n.bare,branch:a??null}),{stdout:"",stderr:`Cloning into '${c}'...
|
|
352
352
|
warning: You appear to have cloned an empty repository.
|
|
353
|
-
`,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));let
|
|
354
|
-
`,exitCode:0};if(E&&await
|
|
355
|
-
`,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:E}),D}})}se();
|
|
353
|
+
`,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));let x=n.depth,b=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let O=await p.fetch(w,[],b);O.shallowUpdates&&await Cr(m,O.shallowUpdates)}let k=g.find(O=>O.name==="HEAD"),E=null,R=null,P=await Jt(m,r.env),C=`clone: from ${i}`,T=p.headTarget;T?.startsWith("refs/heads/")&&g.some(O=>O.name===T)&&(E=T.slice(11),R=g.find(O=>O.name===T)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let H=O.name.slice(11),G=`refs/remotes/origin/${H}`;await X(m,G,O.hash),await Ke(m,G,{oldHash:te,newHash:O.hash,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:C}),!E&&k&&O.hash===k.hash&&(E=H,R=O.hash)}O.name.startsWith("refs/tags/")&&await X(m,O.name,O.hash)}if(a){let O=g.find(H=>H.name===`refs/heads/${a}`);if(!O)return I(`Remote branch '${a}' not found in upstream origin`);E=a,R=O.hash}if(!E){let O=g.find(H=>H.name.startsWith("refs/heads/"));O&&(E=O.name.slice(11),R=O.hash)}if(n.bare)return E&&await ze(m,"HEAD",`refs/heads/${E}`),await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:E}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
|
|
354
|
+
`,exitCode:0};if(E&&await ze(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${E}`),E&&R){await X(m,`refs/heads/${E}`,R),await ze(m,"HEAD",`refs/heads/${E}`);let O={oldHash:te,newHash:R,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:C};await Ke(m,`refs/heads/${E}`,O),await Ke(m,"HEAD",O);let H=await he(m);H[`branch "${E}"`]={remote:"origin",merge:`refs/heads/${E}`},await Ye(m,H);let G=await j(m,R);await Tc(m,G.tree);let A=await Ve(m,G.tree),$=Ss(A.map(N=>({path:N.path,mode:parseInt(N.mode,8),hash:N.hash,stage:0,stat:Ie()})));await ie(m,$)}let D={stdout:"",stderr:`Cloning into '${c}'...
|
|
355
|
+
`,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:E}),D}})}se();Pe();oe();dn();le();Fe();ue();Te();tt();function Vf(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:v().describe("Allow creating an empty commit"),amend:v().describe("Amend the previous commit"),noEdit:v().describe("Use the previous commit message without editing"),all:v().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return I("options '-m' and '-F' cannot be used together");let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await K(s);if(n.all){let me=Xe(s);if(me)return me;let xe=await St(s,i);for(let qe of xe)qe.status==="modified"?i=(await rn(s,i,qe.path)).index:qe.status==="deleted"&&(i=it(i,qe.path));let Ft=new Set(je(i).map(qe=>qe.path)),Rn=new Set(i.entries.filter(qe=>qe.stage>0&&!Ft.has(qe.path)).map(qe=>qe.path));for(let qe of Rn){let fr=S(s.workTree,qe);await r.fs.exists(fr)?i=(await rn(s,i,qe)).index:i=it(i,qe)}}let a=await F(s,"MERGE_HEAD"),c=await F(s,"CHERRY_PICK_HEAD"),f=await F(s,"REVERT_HEAD"),d=await jt(s)?await F(s,"REBASE_HEAD"):null,u=n.amend,m=await Z(s);if(u){if(!m)return I("You have nothing yet to amend.");if(a)return I("You are in the middle of a merge -- cannot amend.");if(c)return I("You are in the middle of a cherry-pick -- cannot amend.")}if($t(i)){let me=new Set,xe=[];for(let Ft of i.entries)Ft.stage>0&&!me.has(Ft.path)&&(me.add(Ft.path),xe.push(`U ${Ft.path}`));return xe.sort(),{stdout:xe.length>0?`${xe.join(`
|
|
356
356
|
`)}
|
|
357
357
|
`:"",stderr:`error: Committing is not possible because you have unmerged files.
|
|
358
358
|
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
|
|
359
359
|
hint: as appropriate to mark resolution and make a commit.
|
|
360
360
|
fatal: Exiting because of an unresolved conflict.
|
|
361
|
-
`,exitCode:128}}let h=u&&m?await
|
|
362
|
-
`,stderr:"",exitCode:1}}if(!p&&u&&h&&(p=h.message),!p&&(a||c||f||d)){let
|
|
361
|
+
`,exitCode:128}}let h=u&&m?await j(s,m):null,p=n.message;if(!p&&n.file!==void 0){if(n.file==="-")p=r.stdin;else{let me=n.file.startsWith("/")?n.file:S(r.cwd,n.file);if(!await r.fs.exists(me))return I(`could not read log file '${n.file}': No such file or directory`);let xe=await r.fs.readFile(me);p=typeof xe=="string"?xe:new TextDecoder().decode(xe)}if(p=an(p),!p)return{stdout:`Aborting commit due to empty commit message.
|
|
362
|
+
`,stderr:"",exitCode:1}}if(!p&&u&&h&&(p=h.message),!p&&(a||c||f||d)){let me=await Ce(s,"SQUASH_MSG");if(me)p=an(me);else{let xe=await Ce(s,"MERGE_MSG");xe!==null&&(p=an(xe))}}if(!p)return L("error: must provide a commit message with -m or -F");let g=je(i),w=await Ge(s,g),y=await t?.hooks?.preCommit?.({repo:s,index:i,treeHash:w});if(ee(y))return L(y.message??"");let x=n.allowEmpty,b=null;if(u&&h){let me=h.parents[0];me?b=(await j(s,me)).tree:b=await yt("tree",new Uint8Array(0))}else m&&(b=(await j(s,m)).tree);let k=u&&h&&h.parents.length>1;if(!x&&!a&&!k){if(!m&&!u&&g.length===0)return{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1};if(b!==null&&b===w){if(u){let me=h?.parents[0]??null;return{stdout:`${await rt(s,{fromCommit:!0,compareHash:me,noWarn:!0,index:i})}No changes
|
|
363
363
|
`,stderr:`You asked to amend the most recent commit, but doing so would make
|
|
364
364
|
it empty. You can repeat your command with --allow-empty, or you can
|
|
365
365
|
remove the commit entirely with "git reset HEAD^".
|
|
@@ -369,76 +369,76 @@ If you wish to commit it anyway, use:
|
|
|
369
369
|
git commit --allow-empty
|
|
370
370
|
|
|
371
371
|
Otherwise, please use 'git cherry-pick --skip'
|
|
372
|
-
`,exitCode:1}:{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let E=await on(s,r.env);if(M(E))return E;let
|
|
373
|
-
${
|
|
374
|
-
`,stderr:"",exitCode:0}}async function
|
|
372
|
+
`,exitCode:1}:{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let E=await on(s,r.env);if(M(E))return E;let R=await Qe(s,r.env);if(M(R))return R;u&&h&&(E.name=h.author.name,E.email=h.author.email,E.timestamp=h.author.timestamp,E.timezone=h.author.timezone),c&&(E=(await j(s,c)).author);let P=Ht(p),C={repo:s,message:P},T=await t?.hooks?.commitMsg?.(C);if(ee(T))return L(T.message??"");P=C.message;let D;u&&h?D=[...h.parents]:(D=m?[m]:[],a&&D.push(a));let O=tn({type:"commit",tree:w,parents:D,author:E,committer:R,message:P}),H=await $e(s,"commit",O);await ie(s,i);let G=await J(s);G&&G.type==="symbolic"?await X(s,G.target,H):await X(s,"HEAD",H);let A=fe(P),$;u?$="commit (amend)":a?$="commit (merge)":c?$="commit (cherry-pick)":m?$="commit":$="commit (initial)";let N=`${$}: ${A}`,B=G?.type==="symbolic"?G.target:"HEAD";await re(s,r.env,B,m,H,N,G?.type==="symbolic"),a&&await Qr(s),c&&await Dt(s),f&&await Mt(s),d&&await pe(s,"MERGE_MSG"),await pe(s,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:s,hash:H,message:P,branch:G?.type==="symbolic"?Re(G.target):null,parents:D,author:E});let z=G?.type==="symbolic"?G.target:null,_=z?Re(z):"detached HEAD",U;if(u&&h){let me=h.parents[0];U=me?(await j(s,me)).tree:null}else U=m?(await j(s,m)).tree:null;let V=E.timestamp!==R.timestamp||E.timezone!==R.timezone,be=D.length>1,Le=await cn(s,U,w,E,R,V,be);return{stdout:`${vt(_,H,p,D.length===0&&!u)}
|
|
373
|
+
${Le}`,stderr:"",exitCode:0}}})}se();Ne();le();function Bn(e){let t=e.split(".");return t.length===2||t.length===3}function Bh(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}`;for(let c of i)t.push(`${a}=${c}`)}}return t}function Qf(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:v().alias("l").describe("List all config entries"),unset:v().describe("Remove a config key"),"get-all":v().describe("Get all values for a multi-valued key"),add:v().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Jf(s);if(n["get-all"]){let f=a;return f?Bn(f)?Xf(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?L("error: missing key and/or value",2):Bn(f)?(await Sa(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Bn(f)?Zf(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="list")return Jf(s);if(a==="get"){let f=i[1];return f?Bn(f)?Yf(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Bn(f)?Xf(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?L("error: missing key and/or value",2):Bn(f)?(await qo(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Bn(f)?Zf(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(!a)return L("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Bn(a))return L(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await qo(s,a,c),{stdout:"",stderr:"",exitCode:0}):Yf(s,a)}})}async function Yf(e,t){let n=await ke(e,t);return n===void 0?L(""):{stdout:`${n}
|
|
374
|
+
`,stderr:"",exitCode:0}}async function Xf(e,t){let n=await $a(e,t);return n.length===0?L(""):{stdout:`${n.join(`
|
|
375
375
|
`)}
|
|
376
|
-
`,stderr:"",exitCode:0}}async function
|
|
376
|
+
`,stderr:"",exitCode:0}}async function Zf(e,t){return await Ta(e,t)?{stdout:"",stderr:"",exitCode:0}:L("",5)}async function Jf(e){let t=S(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Fo(n),o=Bh(r);return{stdout:o.length>0?`${o.join(`
|
|
377
377
|
`)}
|
|
378
|
-
`:"",stderr:"",exitCode:0}}se();function
|
|
378
|
+
`:"",stderr:"",exitCode:0}}se();function Co(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(y=>y?Y(y):"0000000"),c=o?Y(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(y=>y===null),d=!f&&n.some(y=>y!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let y=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${y}`)}else{let y=r.map(k=>k||"000000"),x=s||"000000";y.some(k=>k!==x)&&i.push(`mode ${y.join(",")}..${x}`)}let u=n.some(y=>y!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
|
|
379
379
|
`)}
|
|
380
|
-
`;let m=e.parentContents.map(y=>y.length>0?
|
|
380
|
+
`;let m=e.parentContents.map(y=>y.length>0?Gt(y):[]),h=e.resultContent.length>0?Gt(e.resultContent):[],p=m.map(y=>lt(y,h)),g=Wh(m,h,p),w=zh(g,m.length,h);if(w.length===0)return"";for(let y of w)i.push(y);return`${i.join(`
|
|
381
381
|
`)}
|
|
382
|
-
`}function Wh(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let l of i)if(l.type==="keep")a[l.newLineNo-1]="keep",f=l.newLineNo;else if(l.type==="insert")a[l.newLineNo-1]="insert",f=l.newLineNo;else if(l.type==="delete"){let d=c.get(f)??[];d.push({text:l.line,parentLineNo:l.oldLineNo}),c.set(f,d)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let l=o[f];a.push(l?.deletions.get(i)??[])}let c=qh(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],l=Array(r).fill(0);for(let d=0;d<r;d++){let m=o[d]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[d];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function qh(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(l=>({columns:[" ","-"],text:l.text,resultLineNo:0,parentLineNos:[0,l.parentLineNo]}));if(s.length===0)return o.map(l=>({columns:["-"," "],text:l.text,resultLineNo:0,parentLineNos:[l.parentLineNo,0]}));let i=o.map(l=>l.text),a=s.map(l=>l.text),c=lt(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(m=>m.text===l.line&&m.parentLineNo===l.oldLineNo),u=s.find(m=>m.text===l.line&&m.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.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 zh(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);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 l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),m=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let b=0;b<t;b++){let k=d.filter(E=>(E.parentLineNos[b]??0)>0||E.columns[b]==="-");if(k.length===0)u.push({start:1,count:0});else{let
|
|
383
|
-
`);let c=i[0],f=await
|
|
382
|
+
`}function Wh(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let l of i)if(l.type==="keep")a[l.newLineNo-1]="keep",f=l.newLineNo;else if(l.type==="insert")a[l.newLineNo-1]="insert",f=l.newLineNo;else if(l.type==="delete"){let d=c.get(f)??[];d.push({text:l.line,parentLineNo:l.oldLineNo}),c.set(f,d)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let l=o[f];a.push(l?.deletions.get(i)??[])}let c=qh(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],l=Array(r).fill(0);for(let d=0;d<r;d++){let m=o[d]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[d];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function qh(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(l=>({columns:[" ","-"],text:l.text,resultLineNo:0,parentLineNos:[0,l.parentLineNo]}));if(s.length===0)return o.map(l=>({columns:["-"," "],text:l.text,resultLineNo:0,parentLineNos:[l.parentLineNo,0]}));let i=o.map(l=>l.text),a=s.map(l=>l.text),c=lt(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(m=>m.text===l.line&&m.parentLineNo===l.oldLineNo),u=s.find(m=>m.text===l.line&&m.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.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 zh(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);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 l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),m=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let b=0;b<t;b++){let k=d.filter(E=>(E.parentLineNos[b]??0)>0||E.columns[b]==="-");if(k.length===0)u.push({start:1,count:0});else{let R=k.find(P=>(P.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;u.push({start:R,count:k.length})}}let m=d.filter(b=>b.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let b=p-2;b>=0;b--){let k=n[b];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let y=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${y.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of d)f.push(`${b.columns.join("")}${b.text}`)}return f}se();Pe();oe();le();function Po(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}Yn();ue();Te();tt();var Ki=new TextDecoder;function rl(e){return"exitCode"in e}function Sr(e){return e.toString(8).padStart(6,"0")}function sl(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 ol(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[q.string().name("commits").variadic().optional()],options:{cached:v().describe("Show staged changes (index vs HEAD)"),staged:v().describe("Synonym for --cached"),stat:v().describe("Show diffstat summary"),nameOnly:v().describe("Show only names of changed files"),nameStatus:v().describe("Show names and status of changed files"),shortstat:v().describe("Show only the shortstat summary line"),numstat:v().describe("Machine-readable insertions/deletions per file")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=ut(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(p=>Ue(p,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,m=c.length===1?Po(c[0]):null;if(m){if(a)return I("too many arguments");m.type==="three-dot"?u=await Xh(i,m.left,m.right,l):u=await nl(i,m.left,m.right,l)}else if(c.length===2)u=await nl(i,c[0],c[1],l);else{if(c.length>2)return I("too many arguments");a?u=await Yh(i,c.length===1?c[0]:null,l):c.length===1?u=await Zh(i,c[0],l):u=await Kh(i,l)}if(rl(u))return u;let h=await Jh(i,u.items,d);return u.stderr&&(h.stderr=u.stderr),h}})}async function Kh(e,t){let n=Xe(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await St(e,r);c.sort((l,d)=>Oe(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!ye(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let u=Sr(d.mode),m;if(l.status==="modified"&&e.workTree){let h=S(e.workTree,l.path),p=await e.fs.readFileBuffer(h);m=await yt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!ye(t,l))continue;let d=i.get(l),u=a.get(l);await Vh(f,e,l,d,u)}return f.sort((l,d)=>{let u=Oe(l.path,d.path);return u!==0?u:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function Vh(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=Sr(r.mode),a=Sr(o.mode),{exists:c,hash:f}=await el(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),tl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=Sr(r.mode),{exists:a,hash:c}=await el(t.fs,s,n);tl(e,n,r.hash,i,a,c)}}async function el(e,t,n){let r=S(t,n);if(!await e.exists(r))return{exists:!1};let o=await Yr(e,r);return{exists:!0,hash:await yt("blob",o)}}function tl(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 Yh(e,t,n){let r=null;if(t){let u=await ve(e,t);if(M(u))return u;r=u.commit.tree}else{let u=await Z(e);u&&(r=(await j(e,u)).tree)}let o=await ce(e,r),s=await K(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(je(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:Sr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:Sr(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:l}=await nt(e,c),d=sl(f,l);for(let u of i)d.push({path:u,status:"U"});return d.sort((u,m)=>Oe(u.path,m.path)),n?{items:d.filter(u=>ye(n,u.path))}:{items:d}}async function nl(e,t,n,r){let o=await ve(e,t);if(M(o))return o;let s=await ve(e,n);if(M(s))return s;let i=await We(e,o.commit.tree,s.commit.tree);return il(e,i,r)}async function Xh(e,t,n,r){let o=await ve(e,t);if(M(o))return o;let s=await ve(e,n);if(M(s))return s;let i=await _t(e,o.hash,s.hash);if(i.length===0)return I(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
|
|
383
|
+
`);let c=i[0],f=await j(e,c),l=await We(e,f.tree,s.commit.tree),d=await il(e,l,r);return rl(d)||a&&(d.stderr=a),d}async function il(e,t,n){let{remaining:r,renames:o}=await nt(e,t),s=sl(r,o);return s.sort((i,a)=>Oe(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function Zh(e,t,n){let r=Xe(e);if(r)return r;let o=await ve(e,t);if(M(o))return o;let s=e.workTree,i=await ce(e,o.commit.tree),a=[];for(let[c,f]of i){if(n&&!ye(n,c))continue;let l=S(s,c);if(!await e.fs.exists(l)){a.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let d=await e.fs.readFileBuffer(l),u=await yt("blob",d);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)=>Oe(c.path,f.path)),{items:a}}async function Jh(e,t,n){let r;switch(n){case"stat":r=await sp(e,t);break;case"shortstat":r=await op(e,t);break;case"numstat":r=await rp(e,t);break;case"name-only":r=tp(t);break;case"name-status":r=np(t);break;default:r=await Qh(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function Qh(e,t){let n="",r=new Set,o=await ep(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 ae(e,f):"")),a=await Vi(e,s);if(i.some(f=>Ae(f))||Ae(a)){let f=s.combinedParentHashes.map(l=>l?Y(l):"0000000");n+=`diff --cc ${s.path}
|
|
384
384
|
index ${f.join(",")}..0000000
|
|
385
385
|
Binary files differ
|
|
386
|
-
`,r.add(s.path)}else{let f=
|
|
386
|
+
`,r.add(s.path)}else{let f=Co({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}
|
|
387
387
|
`}}else n+=`* Unmerged path ${s.path}
|
|
388
|
-
`;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await ae(e,s.oldHash):"",a=await Vi(e,s);s.status==="R"&&s.oldPath?n+=xt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:
|
|
388
|
+
`;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await ae(e,s.oldHash):"",a=await Vi(e,s);s.status==="R"&&s.oldPath?n+=xt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:Oo(s.oldHash,o),newHash:Oo(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=xt({path:s.path,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:Oo(s.oldHash,o),newHash:Oo(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function ep(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=S(e.gitDir,"objects",a),l=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,l),l},s=async(a,c)=>{let f=a.slice(0,2),l=a.slice(2,c),d=await o(f),u=0;for(let m of d)if(m.startsWith(l)&&(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 Oo(e,t){if(e)return e.length!==40?e:t.get(e)??Y(e)}function tp(e){let t="";for(let n of e)t+=`${n.path}
|
|
389
389
|
`;return t}function np(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}
|
|
390
390
|
`}else t+=`${n.status} ${n.path}
|
|
391
391
|
`;return t}async function rp(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
|
|
392
|
-
`;continue}let o=r.oldHash?await ae(e,r.oldHash):"",s=await Vi(e,r),i=
|
|
392
|
+
`;continue}let o=r.oldHash?await ae(e,r.oldHash):"",s=await Vi(e,r),i=Ae(o)||Ae(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=al(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=Mn(r.oldPath,r.path);n+=`${a} ${c} ${f}
|
|
393
393
|
`}else n+=`${a} ${c} ${r.path}
|
|
394
|
-
`}return n}async function sp(e,t){let n=await
|
|
394
|
+
`}return n}async function sp(e,t){let n=await cl(e,t);return is(n)}async function op(e,t){let n=await cl(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=kr(s,r,o);return i?`${i}
|
|
395
395
|
`:n.some(a=>a.isUnmerged)?` 0 files changed
|
|
396
|
-
`:""}async function Vi(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n
|
|
397
|
-
`);for(let H of
|
|
398
|
-
`)}}else{let B=H.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";T.push(`${B} ${A} -> ${
|
|
399
|
-
`)}}if(!o)for(let H of m){if(!H.name.startsWith("refs/tags/")||y.has(H.hash))continue;let G=await
|
|
400
|
-
`))}if(r){let H=`refs/remotes/${t}`,G=await
|
|
401
|
-
`))}}let D=m.find(H=>H.name==="HEAD");if(D){let H
|
|
402
|
-
`)}let O={stdout:"",stderr:T.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,refsUpdated:
|
|
403
|
-
`)}function
|
|
396
|
+
`:""}async function Vi(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=S(e.workTree,t.path),r=await Yr(e.fs,n);return Ki.decode(r)}return ae(e,t.newHash)}async function ip(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=S(e.workTree,t.path);return Yr(e.fs,n)}return Et(e,t.newHash)}function al(e,t){let n=Vt(e),r=Vt(t),o=lt(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 cl(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?Mn(r.oldPath,r.path):r.path,s=r.oldHash?await Et(e,r.oldHash):new Uint8Array(0),i=await ip(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=Ki.decode(s),c=Ki.decode(i),{ins:f,del:l}=al(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}se();Ne();xn();le();Fe();ue();function cr(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 ap(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 Io(e,t){if(!ap(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 ll(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[q.string().name("remote").describe("Remote to fetch from").optional(),q.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:v().describe("Fetch from all remotes"),prune:v().alias("p").describe("Remove stale remote-tracking refs"),tags:v().describe("Also fetch tags"),depth:Q.number().describe("Limit fetching to the specified number of commits"),unshallow:v().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await wo(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=ls),n.all){if(n.remote)return I("fetch --all does not take a remote argument");let c=await he(s),f=[];for(let u of Object.keys(c)){let m=u.match(/^remote "(.+)"$/);m?.[1]&&f.push(m[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let u of f){let m=await fl(s,u,void 0,n.prune,n.tags,r.env,t,i);m.stderr&&l.push(m.stderr),m.exitCode!==0&&(d=m.exitCode)}return{stdout:"",stderr:l.join(""),exitCode:d}}let a=n.remote||"origin";return fl(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function fl(e,t,n,r,o,s,i,a){let c;try{c=await $r(e,t,s)}catch(H){let G=H instanceof Error?H.message:"";if(G.startsWith("network"))return I(G);throw H}if(!c)return I(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d;n&&n.length>0?d=n.map(cr):d=[cr(l.fetchRefspec)];let u=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(H=>`${H.src}:${H.dst}`),prune:r,tags:o});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await f.advertiseRefs();if(m.length===0)return{stdout:"",stderr:"",exitCode:0};let p=(await ge(e)).map(H=>H.hash),g=await F(e,"HEAD");g&&p.push(g);let w=[],y=new Set,x=[];for(let H of m)if(H.name!=="HEAD")for(let G of d){let A=Io(G,H.name);if(A!==null){x.push({remote:H,localRef:A,force:G.force}),y.has(H.hash)||(y.add(H.hash),w.push(H.hash));break}}if(o)for(let H of m)H.name.startsWith("refs/tags/")&&(x.push({remote:H,localRef:H.name,force:!1}),y.has(H.hash)||(y.add(H.hash),w.push(H.hash)));let b=new Set(p),k=w.filter(H=>!b.has(H)),E,R=a!==void 0?await xr(e):void 0;a!==void 0&&(E={depth:a,existingShallows:R});let P=k.length>0?k:E?w:[];if(P.length>0){let H=await f.fetch(P,p,E);H.shallowUpdates&&await Cr(e,H.shallowUpdates,R)}let C=await Jt(e,s),T=[];T.push(`From ${l.url}
|
|
397
|
+
`);for(let H of x){let G=await F(e,H.localRef);await X(e,H.localRef,H.remote.hash),await Ke(e,H.localRef,{oldHash:G??te,newHash:H.remote.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:G?"fetch":"fetch: storing head"});let A=$o(H.remote.name),$=$o(H.localRef);if(G){if(G!==H.remote.hash){let N=Y(G),B=Y(H.remote.hash);T.push(` ${N}..${B} ${A} -> ${$}
|
|
398
|
+
`)}}else{let B=H.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";T.push(`${B} ${A} -> ${$}
|
|
399
|
+
`)}}if(!o)for(let H of m){if(!H.name.startsWith("refs/tags/")||y.has(H.hash))continue;let G=await F(e,H.name),A=H.peeledHash??H.hash;!G&&b.has(A)&&(await X(e,H.name,H.hash),await Ke(e,H.name,{oldHash:te,newHash:H.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:"fetch: storing head"}),T.push(` * [new tag] ${$o(H.name)} -> ${$o(H.name)}
|
|
400
|
+
`))}if(r){let H=`refs/remotes/${t}`,G=await ge(e,H),A=new Set(m.filter($=>$.name.startsWith("refs/heads/")).map($=>$.name.slice(11)));for(let $ of G){let N=$.name.slice(H.length+1);A.has(N)||(await de(e,$.name),T.push(` - [deleted] (none) -> ${t}/${N}
|
|
401
|
+
`))}}let D=m.find(H=>H.name==="HEAD");if(D){let H=S(e.gitDir,"FETCH_HEAD"),G=m.find($=>$.name.startsWith("refs/heads/")&&$.hash===D.hash),A=G?`branch '${G.name.slice(11)}' of`:"of";await e.fs.writeFile(H,`${D.hash} ${A} ${l.url}
|
|
402
|
+
`)}let O={stdout:"",stderr:T.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,refsUpdated:x.length}),O}function $o(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}se();Pe();oe();le();Fe();ue();se();Pe();oe();le();Fe();ue();async function dl(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=S(e.gitDir,"logs");await e.fs.exists(o)&&await ul(e,o,o,t);let s=await K(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await F(e,a);c&&t.add(c)}let i=[];for(let a of t)await zt(e,a)&&i.push(a);return i}async function ul(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=S(t,s),a=await e.fs.stat(i);if(a.isDirectory)await ul(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Je(e,c);for(let l of f)l.newHash!==te&&r.add(l.newHash)}}}As();Fr();le();async function cp(e,t){let n=new Set,r=S(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(S(r,i)),c=new qt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Or(await Pr(e,t,[])):(await Or(await Pr(e,t,[]))).filter(s=>!n.has(s.hash))}async function Yi(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 Or(await Pr(t,r,[])):await cp(t,r);if(a.length===0)return null;let c=a.length,f=Eo(a,{window:s,depth:i}),l=f.filter(E=>E.delta).length,d=f.map(E=>({hash:E.hash,type:E.type,content:E.content,delta:E.delta,deltaBaseHash:E.deltaBase})),{data:u,entries:m}=await Hs(d),h=await fc(u,m),p=u.subarray(u.byteLength-20),g="";for(let E=0;E<20;E++){let R=p[E];g+=(R>>4).toString(16)+(R&15).toString(16)}let w=S(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let y=`pack-${g}`,x=S(w,`${y}.pack`),b=S(w,`${y}.idx`);await n.writeFile(x,u),await n.writeFile(b,h);let k=new Set(f.map(E=>E.hash));if(t.objectStore.invalidatePacks?.(),o){let E=await n.readdir(w);for(let C of E){if(!C.endsWith(".idx"))continue;let T=C.slice(0,-4);if(T===y)continue;let D=S(w,`${T}.idx`),O=!0;try{let H=await n.readFileBuffer(D),G=new qt(H);for(let A of G.allHashes())if(!k.has(A)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(S(w,`${T}.pack`))}catch{}try{await n.rm(D)}catch{}}}let R=S(t.gitDir,"objects"),P;try{P=await n.readdir(R)}catch{P=[]}for(let C of P){if(C==="pack"||C==="info"||C.length!==2)continue;let T=S(R,C),D;try{D=await n.readdir(T)}catch{continue}for(let O of D){let H=`${C}${O}`;k.has(H)&&await n.rm(S(T,O))}try{(await n.readdir(T)).length===0&&await n.rm(T,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function Xi(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
|
|
403
|
+
`)}function ml(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:v().alias("a").describe("Pack all objects, including already-packed"),delete:v().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await dl(s),a=await Yi({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Xi(a.totalCount,a.deltaCount)}
|
|
404
404
|
`,exitCode:0}:{stdout:`Nothing new to pack.
|
|
405
|
-
`,stderr:"",exitCode:0}}})}function
|
|
406
|
-
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var fp=2160*60*60;async function lp(e){let t=new Set,n=await
|
|
405
|
+
`,stderr:"",exitCode:0}}})}function hl(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:v().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;await wc(s),await ht(s);let i=await lp(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await Yi({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await dp(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Xi(f.totalCount,f.deltaCount,!0)}
|
|
406
|
+
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var fp=2160*60*60;async function lp(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ge(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-fp,i=S(e.gitDir,"logs");await e.fs.exists(i)&&await pl(e,i,i,s,t);let a=await K(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let l=await F(e,f);l&&t.add(l)}let c=[];for(let f of t)await zt(e,f)&&c.push(f);return c}async function pl(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=S(t,i),c=await e.fs.stat(a);if(c.isDirectory){await pl(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),l=await Je(e,f);if(f==="refs/stash"){for(let u of l)u.newHash!==te&&o.add(u.newHash);continue}let d=l.filter(u=>u.timestamp>=r);await Sn(e,f,d);for(let u of d)u.newHash!==te&&o.add(u.newHash)}}}async function dp(e,t){let n=S(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(S(n,o),{recursive:!0})}catch{}}le();$n();function gl(e){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:v().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?Ot(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:i}=await Ms(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),a="";i&&r&&(a=`warning: re-init: ignored --initial-branch=${r}
|
|
407
407
|
`);let c=t.bare?"bare ":"";return{stdout:`${i?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
|
|
408
|
-
`,stderr:a,exitCode:0}}})}se();
|
|
409
|
-
`,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Zi=
|
|
408
|
+
`,stderr:a,exitCode:0}}})}se();tr();var So=class{hash=null;parents=[];nParents=0;state=0;prevState=0;commitIdx=0;prevCommitIdx=0;mergeLayout=0;edgesAdded=0;prevEdgesAdded=0;w=0;expRow=0;cols=[];nCols=0;newCols=[];nNewCols=0;map=[];oldMap=[];mapSize=0;get width(){return this.w}update(t,n){this.hash=t,this.parents=n,this.nParents=n.length,this.prevCommitIdx=this.commitIdx,this.updateColumns(),this.expRow=0,this.state!==0?this.state=1:this.needsPreCommit()?this.state=2:this.state=3}nextLine(){let t,n=!1;switch(this.state){case 0:t=this.outPadding();break;case 1:t=this.outSkip();break;case 2:t=this.outPreCommit();break;case 3:t=this.outCommit(),n=!0;break;case 4:t=this.outPostMerge();break;case 5:t=this.outCollapsing();break}return{prefix:wl(t,this.w),isCommitLine:n}}isFinished(){return this.state===0}paddingPrefix(){if(this.state!==3)return this.nextLine().prefix;let t="";for(let n=0;n<this.nCols;n++)t+="| ";return this.prevState=0,wl(t,this.w)}updateColumns(){let t=this.newCols,n=this.nNewCols;this.newCols=this.cols,this.nNewCols=0,this.cols=t,this.nCols=n;let r=this.nCols+this.nParents;this.map.length<2*r&&(this.map=new Array(2*r),this.oldMap=new Array(2*r)),this.mapSize=2*r,this.map.fill(-1,0,this.mapSize),this.w=0,this.prevEdgesAdded=this.edgesAdded,this.edgesAdded=0;let o=!1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(o)break;i=this.hash}else i=this.cols[s];if(i===this.hash){o=!0,this.commitIdx=s,this.mergeLayout=-1;for(let a of this.parents)this.insertNewCol(a,s);this.nParents===0&&(this.w+=2)}else this.insertNewCol(i,-1)}for(;this.mapSize>1&&this.map[this.mapSize-1]<0;)this.mapSize--}findNewCol(t){for(let n=0;n<this.nNewCols;n++)if(this.newCols[n]===t)return n;return-1}insertNewCol(t,n){let r=this.findNewCol(t);r<0&&(r=this.nNewCols++,this.newCols[r]=t);let o;if(this.nParents>1&&n>-1&&this.mergeLayout===-1){let s=n-r,i=s>1?2*s-3:1;this.mergeLayout=s>0?0:1,this.edgesAdded=this.nParents+this.mergeLayout-2,o=this.w+(this.mergeLayout-1)*i,this.w+=2*this.mergeLayout}else this.edgesAdded>0&&this.w>=2&&r===this.map[this.w-2]?(o=this.w-2,this.edgesAdded=-1):(o=this.w,this.w+=2);this.map[o]=r}setState(t){this.prevState=this.state,this.state=t}numDashedParents(){return this.nParents+this.mergeLayout-3}numExpansionRows(){return this.numDashedParents()*2}needsPreCommit(){return this.nParents>=3&&this.commitIdx<this.nCols-1&&this.expRow<this.numExpansionRows()}isMappingCorrect(){for(let t=0;t<this.mapSize;t++){let n=this.map[t];if(!(n<0)&&n!==t>>1)return!1}return!0}outPadding(){let t="";for(let n=0;n<this.nNewCols;n++)t+="| ";return t}outSkip(){return this.needsPreCommit()?this.setState(2):this.setState(3),"..."}outPreCommit(){let t="",n=!1;for(let r=0;r<this.nCols;r++)this.cols[r]===this.hash?(n=!0,t+="|",t+=" ".repeat(this.expRow)):n&&this.expRow===0?this.prevState===4&&this.prevCommitIdx<r?t+="\\":t+="|":n?t+="\\":t+="|",t+=" ";return this.expRow++,this.needsPreCommit()||this.setState(3),t}outCommit(){let t="",n=!1;for(let r=0;r<=this.nCols;r++){let o;if(r===this.nCols){if(n)break;o=this.hash}else o=this.cols[r];o===this.hash?(n=!0,t+="*",this.nParents>2&&(t+=this.drawOctopus())):n&&this.edgesAdded>1?t+="\\":n&&this.edgesAdded===1?this.prevState===4&&this.prevEdgesAdded>0&&this.prevCommitIdx<r?t+="\\":t+="|":this.prevState===5&&this.oldMap[2*r+1]===r&&this.map[2*r]<r?t+="/":t+="|",t+=" "}return this.nParents>1?this.setState(4):this.isMappingCorrect()?this.setState(0):this.setState(5),t}drawOctopus(){let t=this.numDashedParents(),n="";for(let r=0;r<t;r++)n+="-",n+=r===t-1?".":"-";return n}outPostMerge(){let t=["/","|","\\"],n="",r=!1,o=-1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(r)break;i=this.hash}else i=this.cols[s];if(i===this.hash){r=!0;let a=this.mergeLayout;for(let c=0;c<this.nParents;c++)n+=t[a],a===2?(this.edgesAdded>0||c<this.nParents-1)&&(n+=" "):a++;this.edgesAdded===0&&(n+=" ")}else r?(this.edgesAdded>0?n+="\\":n+="|",n+=" "):(n+="|",(this.mergeLayout!==0||s!==this.commitIdx-1)&&(o>=0?n+="_":n+=" "));i===this.parents[0]&&(o=s)}return this.isMappingCorrect()?this.setState(0):this.setState(5),n}outCollapsing(){let t=this.map;this.map=this.oldMap,this.oldMap=t,this.map.fill(-1,0,this.mapSize);let n=-1,r=-1;for(let i=0;i<this.mapSize;i++){let a=this.oldMap[i];if(!(a<0)){if(a*2===i)this.map[i]=a;else if(this.map[i-1]<0){if(this.map[i-1]=a,n===-1){n=i,r=a;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}else if(this.map[i-1]!==a){if(this.map[i-2]=a,n===-1){r=a,n=i-1;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}}}for(let i=0;i<this.mapSize;i++)this.oldMap[i]=this.map[i];this.mapSize>0&&this.map[this.mapSize-1]<0&&this.mapSize--;let o="",s=!1;for(let i=0;i<this.mapSize;i++){let a=this.map[i];a<0?o+=" ":a*2===i?o+="|":a===r&&i!==n-1?(i!==a*2+3&&(this.map[i]=-1),s=!0,o+="_"):(s&&i<n&&(this.map[i]=-1),o+="/")}return this.isMappingCorrect()&&this.setState(0),o}};function wl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}se();function Ji(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+=bp(c.timestamp,c.timezone),s+=3;continue;case"i":o+=yp(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Lt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=Ep(c.timestamp,c.timezone),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=Y(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=Y(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(Y).join(" "),s+=2;continue;case"s":o+=Zi(r.message),s+=2;continue;case"b":o+=up(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+=`
|
|
409
|
+
`,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Zi=fe;function up(e){let t=e.indexOf(`
|
|
410
410
|
|
|
411
|
-
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function
|
|
412
|
-
`)}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(
|
|
411
|
+
`);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function bl(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 Qi(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?Y(o):o,c=Zi(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(Y).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${Zi(s.message)}`),a.join(`
|
|
412
|
+
`)}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(Y).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(`
|
|
413
413
|
`))a.push(` ${f}`);return a.join(`
|
|
414
|
-
`)}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(
|
|
414
|
+
`)}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(Y).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Lt(s.author.timestamp,s.author.timezone)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Lt(s.committer.timestamp,s.committer.timezone)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
|
|
415
415
|
`))a.push(` ${f}`);return a.join(`
|
|
416
|
-
`)}default:return mp(t,n)}}function mp(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(
|
|
416
|
+
`)}default:return mp(t,n)}}function mp(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(Y).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Lt(r.author.timestamp,r.author.timezone)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
|
|
417
417
|
`))s.push(` ${a}`);return s.join(`
|
|
418
|
-
`)}var hp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pp=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function gp(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 ea(e,t){let n=gp(t);return new Date((e+n*60)*1e3)}function wp(e){return`${e.slice(0,3)}:${e.slice(3)}`}function bp(e,t){let n=ea(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}${wp(t)}`}function yp(e,t){let n=ea(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 Ep(e,t){let n=ea(e,t),r=hp[n.getUTCDay()]?.slice(0,3),o=pp[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();ue();mn();
|
|
418
|
+
`)}var hp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pp=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function gp(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 ea(e,t){let n=gp(t);return new Date((e+n*60)*1e3)}function wp(e){return`${e.slice(0,3)}:${e.slice(3)}`}function bp(e,t){let n=ea(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}${wp(t)}`}function yp(e,t){let n=ea(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 Ep(e,t){let n=ea(e,t),r=hp[n.getUTCDay()]?.slice(0,3),o=pp[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();ue();mn();Te();function kl(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[q.string().name("revisions").variadic().optional()],options:{maxCount:Q.number().alias("n").describe("Limit the number of commits to output"),oneline:v().describe("Condense each commit to a single line"),all:v().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:v().describe("Show ref names next to commit hashes"),reverse:v().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:v().alias("p").describe("Show diff in patch format"),stat:v().describe("Show diffstat summary"),nameStatus:v().describe("Show names and status of changed files"),nameOnly:v().describe("Show only names of changed files"),shortstat:v().describe("Show only the shortstat summary line"),numstat:v().describe("Machine-readable insertions/deletions per file"),graph:v().describe("Draw text-based graph of the commit history"),firstParent:v().describe("Follow only the first parent of merge commits")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Po(f[0]):null;if(l){let U=async me=>{let xe=await Be(i,me);if(!xe)return Kt(me);try{return await _e(i,xe)}catch{return Kt(me)}},V=await U(l.left);if(typeof V=="object"&&"exitCode"in V)return V;let be=await U(l.right);if(typeof be=="object"&&"exitCode"in be)return be;let Le=V,ot=be;if(l.type==="two-dot")a=[ot],c=[Le];else{a=[Le,ot];let me=await _t(i,Le,ot);c=me.length>0?me:void 0}if(n.all){let me=await ge(i);for(let Ft of me)try{let Rn=await _e(i,Ft.hash);a.includes(Rn)||a.push(Rn)}catch{}let xe=await Z(i);xe&&!a.includes(xe)&&a.push(xe)}}else if(n.all){let U=await ge(i),V=new Set;for(let Le of U)try{V.add(await _e(i,Le.hash))}catch{}let be=await Z(i);be&&V.add(be),a=[...V]}else if(f&&f.length>0){let U=[];for(let V of f){let be=await Be(i,V);if(!be)return Kt(V);try{U.push(await _e(i,be))}catch{return Kt(V)}}a=U}else{let U=await Ze(i);if(M(U))return U;a=[U]}if(a.length===0)return I("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(U=>Ue(U,"")):null,u=n.author?yl(n.author):null,m=n.grep?yl(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?Di(h):null,w=p?Di(p):null,y=n.format??n.pretty,x=null,b=null,k=!1;if(n.oneline)b="oneline",k=!0;else if(y!==void 0){let U=bl(y);x=U.formatStr,b=U.preset}let E=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,R=n.graph;if(R&&n.reverse)return I("options '--graph' and '--reverse' cannot be used together");let C=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await xp(i):null,T=C?U=>El(C,U):void 0,D=C?U=>{let V=El(C,U);return V.startsWith("(")&&V.endsWith(")")?V.slice(1,-1):V}:void 0,O=n.maxCount,H=n.reverse,G=n.firstParent,A=d?Rp(i,a,d,c?await kp(i,c):void 0,G):At(i,a,{exclude:c,topoOrder:R,firstParent:G}),$=[];for await(let U of A){if(O!==void 0&&$.length>=O)break;let{commit:V}=U;if(!(w!==null&&V.committer.timestamp>w)&&!(g!==null&&V.committer.timestamp<=g)){if(u){let be=`${V.author.name} <${V.author.email}>`;if(!u(be))continue}m&&!m(V.message)||$.push(U)}}let N=H?$.reverse():$;if(R)return Cp(N,i,x,b,k,E,T,D);if(x!==null){let U=[];for(let V of N){let be={hash:V.hash,commit:V.commit,decorations:T,decorationsRaw:D},Le=Ji(x,be),ot=await ta(i,V.commit,E);ot&&(Le+=`
|
|
419
419
|
|
|
420
|
-
${
|
|
420
|
+
${ot.replace(/\n$/,"")}`),U.push(Le)}return{stdout:U.length>0?`${U.join(`
|
|
421
421
|
`)}
|
|
422
|
-
`:"",stderr:"",exitCode:0}}let
|
|
422
|
+
`:"",stderr:"",exitCode:0}}let B=b??"medium",z=B==="oneline",_=[];for(let U=0;U<N.length;U++){let V=N[U],be={hash:V.hash,commit:V.commit,decorations:T,decorationsRaw:D},Le=Qi(B,be,U===0,k),ot=await ta(i,V.commit,E);ot&&(Le+=`${z?`
|
|
423
423
|
`:`
|
|
424
424
|
|
|
425
|
-
`}${
|
|
425
|
+
`}${ot.replace(/\n$/,"")}`),_.push(Le)}return{stdout:_.length>0?`${_.join(`
|
|
426
426
|
`)}
|
|
427
|
-
`:"",stderr:"",exitCode:0}}})}async function kp(e,t){let n=new Set;for await(let r of
|
|
428
|
-
`),w=0;for(;;){let{prefix:b,isCommitLine:k}=c.nextLine();if(k){d.push(b+(g[w++]??""));break}d.push(b)}for(;w<g.length;){let{prefix:b}=c.nextLine();d.push(b+g[w++])}for(;!c.isFinished();){let{prefix:b}=c.nextLine();d.push(b)}let y=80-c.width,
|
|
427
|
+
`:"",stderr:"",exitCode:0}}})}async function kp(e,t){let n=new Set;for await(let r of At(e,t))n.add(r.hash);return n}function yl(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Rp(e,t,n,r,o){let s=new Set(r),i=new Dn,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await We(e,null,f.tree)).some(m=>ye(n,m.path))&&(yield c);continue}if(l.length===1){let u=l[0];if(u){try{let m=await j(e,u);(await We(e,m.tree,f.tree)).some(p=>ye(n,p.path))&&(yield c)}catch{yield c}await a(u)}continue}let d=[];for(let u of l)try{let m=await j(e,u);(await We(e,m.tree,f.tree)).some(p=>ye(n,p.path))||d.push(u)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let u of l)await a(u)}}}async function xp(e){let t=await J(e),n=t?.type==="symbolic"?Re(t.target):null,r=await Z(e),o=new Map,s=(f,l,d)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:l,fullRef:d})},i=await ge(e,"refs/heads");for(let f of i)s(f.hash,Re(f.name),f.name);let a=await ge(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await ge(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await _e(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function El(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 Cp(e,t,n,r,o,s,i,a){let c=new So,f=r??"medium",l=f==="oneline",d=[];for(let u=0;u<e.length;u++){let m=e[u],h={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a},p;n!==null?p=Ji(n,h):p=Qi(f,h,!0,o),c.update(m.hash,m.commit.parents),u>0&&!l&&n===null&&d.push(c.paddingPrefix());let g=p.split(`
|
|
428
|
+
`),w=0;for(;;){let{prefix:b,isCommitLine:k}=c.nextLine();if(k){d.push(b+(g[w++]??""));break}d.push(b)}for(;w<g.length;){let{prefix:b}=c.nextLine();d.push(b+g[w++])}for(;!c.isFinished();){let{prefix:b}=c.nextLine();d.push(b)}let y=80-c.width,x=await ta(t,m.commit,s,y);if(x){let b=x.replace(/\n$/,"").split(`
|
|
429
429
|
`);if(l||n!==null)for(let k of b)d.push(c.paddingPrefix()+k);else{d.push(c.paddingPrefix());for(let k of b)d.push(c.paddingPrefix()+k)}}}return{stdout:d.length>0?`${d.join(`
|
|
430
430
|
`)}
|
|
431
|
-
`:"",stderr:"",exitCode:0}}async function ta(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await
|
|
431
|
+
`:"",stderr:"",exitCode:0}}async function ta(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await j(e,t.parents[0])).tree:null,s=await We(e,o,t.tree),{remaining:i,renames:a}=await nt(e,s);switch(n){case"name-only":return Pp(i,a);case"name-status":return Op(i,a);case"stat":return Ip(e,i,a,r);case"shortstat":return $p(e,i,a);case"numstat":return Sp(e,i,a);case"patch":return Tp(e,i,a)}}function Pp(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}
|
|
432
432
|
`).join("")}function Op(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}
|
|
433
|
-
`).join("")}async function Ip(e,t,n,r){let{fileStats:o}=await
|
|
434
|
-
`:""}async function
|
|
433
|
+
`).join("")}async function Ip(e,t,n,r){let{fileStats:o}=await os(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),is(o,r)}async function $p(e,t,n){let{fileStats:r}=await os(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=kr(r.length,o,s);return i?`${i}
|
|
434
|
+
`:""}async function Sp(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:Mn(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 ae(e,s.oldHash):"",a=s.newHash?await ae(e,s.newHash):"";if(Ae(i)||Ae(a))o+=`- - ${s.display}
|
|
435
435
|
`;else{let c=Vt(i),f=Vt(a),l=lt(c,f),d=0,u=0;for(let m of l)m.type==="insert"?d++:m.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
|
|
436
|
-
`}}return o}async function Tp(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 ae(e,i.oldHash):"",c=i.newHash?await ae(e,i.newHash):"";o+=xt({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 ae(e,i.oldHash):"",c=i.newHash?await ae(e,i.newHash):"";o+=xt({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}se();
|
|
437
|
-
`,k=o.passthrough.length>0?o.passthrough.map(P=>{let C=r.cwd!==c?vp(c,r.cwd):"";return
|
|
438
|
-
Please, commit your changes before you merge.`);if(await
|
|
439
|
-
Please, commit your changes before you merge.`);let u=await
|
|
440
|
-
`);let m=await
|
|
441
|
-
`,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let k=await
|
|
436
|
+
`}}return o}async function Tp(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 ae(e,i.oldHash):"",c=i.newHash?await ae(e,i.newHash):"";o+=xt({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 ae(e,i.oldHash):"",c=i.newHash?await ae(e,i.newHash):"";o+=xt({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}se();Pe();le();Yn();tt();function xl(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:v().alias("c").describe("Show cached files (default)"),modified:v().alias("m").describe("Show modified files"),deleted:v().alias("d").describe("Show deleted files"),others:v().alias("o").describe("Show other (untracked) files"),unmerged:v().alias("u").describe("Show unmerged files"),stage:v().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":v().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":v().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":v().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Xe(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||u||m||(f=!0);let x=await K(i),b=g?"\0":`
|
|
437
|
+
`,k=o.passthrough.length>0?o.passthrough.map(P=>{let C=r.cwd!==c?vp(c,r.cwd):"";return Ue(P,C)}):null,E=[];if(f)for(let P of x.entries){if(k&&!ye(k,P.path))continue;let C=w?P.stage>0?"M":"H":null;E.push(Rl(P,h,C))}if(m&&!f)for(let P of x.entries)P.stage!==0&&(k&&!ye(k,P.path)||E.push(Rl(P,!0,w?"M":null)));if(l||d){let P=await Hp(i,c,x);for(let{path:C,status:T}of P){if(T==="modified"&&!l||T==="deleted"&&!d||k&&!ye(k,C))continue;let D=w?T==="deleted"?"R":"C":null;E.push(D?`${D} ${C}`:C)}}if(u){let P=await Ap(i,c,x,p);for(let C of P)k&&!ye(k,C)||E.push(w?`? ${C}`:C)}return{stdout:E.length>0?E.join(b)+b:"",stderr:"",exitCode:0}}})}function Rl(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 vp(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Hp(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=S(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await ft(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Tn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Ap(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await et(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}se();tr();Ne();Pe();oe();Fe();ue();mn();Te();function Cl(e,t){e.command("merge",{description:"Join two or more development histories together",args:[q.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:v().describe("Abort the current in-progress merge"),continue:v().describe("Continue the merge after conflict resolution"),noFf:v().describe("Create a merge commit even when fast-forward is possible"),ffOnly:v().describe("Refuse to merge unless fast-forward is possible"),squash:v().describe("Apply merge result to worktree/index without creating a merge commit"),edit:v().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 W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Lp(s,r.env);if(n.continue)return Gp(s,r.env,t);let i=n.branch;if(!i)return I("you must specify a branch to merge");let a=await Ze(s);if(M(a))return a;let c=await K(s),f=gn(c,"Merging");if(f)return f;if(await F(s,"MERGE_HEAD"))return I(`You have not concluded your merge (MERGE_HEAD exists).
|
|
438
|
+
Please, commit your changes before you merge.`);if(await F(s,"CHERRY_PICK_HEAD"))return I(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
|
|
439
|
+
Please, commit your changes before you merge.`);let u=await Be(s,i);if(!u)return L(`merge: ${i} - not something we can merge
|
|
440
|
+
`);let m=await _e(s,u),h=await _t(s,a,m),p=h[0]??null;if(h.length===0)return I("refusing to merge unrelated histories");if(p===m)return await pe(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
|
|
441
|
+
`,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let k=await ke(s,"merge.ff");k==="false"?g=!0:k==="only"&&(w=!0)}if(g&&w)return I("--no-ff and --ff-only are incompatible");let y=p===a&&!g;if(w&&!y)return L(`hint: Diverging branches can't be fast-forwarded, you need to either:
|
|
442
442
|
hint:
|
|
443
443
|
hint: git merge --no-ff
|
|
444
444
|
hint:
|
|
@@ -448,21 +448,21 @@ hint: git rebase
|
|
|
448
448
|
hint:
|
|
449
449
|
hint: Disable this message with "git config set advice.diverging false"
|
|
450
450
|
fatal: Not possible to fast-forward, aborting.
|
|
451
|
-
`,128);if(await
|
|
452
|
-
`)?
|
|
453
|
-
`:void 0;return n.squash?jp(s,a,m,i,r.env,t,b):Dp(s,a,m,i,r.env,g,t,b)}})}async function Dp(e,t,n,r,o,s=!1,i,a){let c=await
|
|
451
|
+
`,128);if(await F(s,"REVERT_HEAD")&&await Mt(s),y&&!n.squash){let k=await J(s),E=await po(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 pe(s,"MERGE_MSG");let R=k?.type==="symbolic"?k.target:"HEAD";await re(s,r.env,R,a,m,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,k?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:m,strategy:"fast-forward",commitHash:null})}return E}let x=n.message,b=x?x.endsWith(`
|
|
452
|
+
`)?x:`${x}
|
|
453
|
+
`:void 0;return n.squash?jp(s,a,m,i,r.env,t,b):Dp(s,a,m,i,r.env,g,t,b)}})}async function Dp(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await J(e),l=f?.type==="symbolic"?Re(f.target):"HEAD",d=await ke(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:r,conflictStyle:d},m=await fs(e,t,n,u),h=await En(e,m,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!h.ok)return await pe(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(m.conflicts.length>0){await X(e,"MERGE_HEAD",n),await X(e,"ORIG_HEAD",t);let T=a??await ir(e,r,l),D={repo:e,message:T,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(D);if(ee(O))return{stdout:"",stderr:O.message??"",exitCode:1};T=D.message;let H=Ut({version:2,entries:m.entries}).sort();return T+=`
|
|
454
454
|
# Conflicts:
|
|
455
455
|
${H.map(A=>`# ${A}`).join(`
|
|
456
456
|
`)}
|
|
457
457
|
`,await Se(e,"MERGE_MSG",T),await Se(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...m.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
458
458
|
`)}
|
|
459
|
-
`,stderr:"",exitCode:1}}await
|
|
459
|
+
`,stderr:"",exitCode:1}}await pe(e,"MERGE_MSG");let p=h.mergedTreeHash,g=await on(e,o);if(M(g))return g;let w=await Qe(e,o);if(M(w))return w;let y=a??await ir(e,r,l),x={repo:e,message:y,treeHash:p,headHash:t,theirsHash:n},b=await i?.hooks?.mergeMsg?.(x);if(ee(b))return{stdout:"",stderr:b.message??"",exitCode:1};y=x.message;let k=await i?.hooks?.preMergeCommit?.({repo:e,mergeMessage:y,treeHash:p,headHash:t,theirsHash:n});if(ee(k))return{stdout:"",stderr:k.message??"",exitCode:1};let E=await mt(e,p,[t,n],g,w,y),R=f?.type==="symbolic"?f.target:"HEAD";await re(e,o,R,t,E,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:E});let P=await Fn(e,c.tree,p);return{stdout:`${m.messages.length>0?`${m.messages.join(`
|
|
460
460
|
`)}
|
|
461
461
|
`:""}Merge made by the 'ort' strategy.
|
|
462
|
-
${P}`,stderr:"",exitCode:0}}async function Mp(e,t,n){let r=[];for await(let o of
|
|
462
|
+
${P}`,stderr:"",exitCode:0}}async function Mp(e,t,n){let r=[];for await(let o of At(e,n,{exclude:[t]})){if(o.commit.parents.length>1)continue;r.push(`commit ${o.hash}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Lt(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
|
|
463
463
|
`))r.push(` ${i}`);r.push("")}return r.join(`
|
|
464
|
-
`)}async function jp(e,t,n,r,o,s,i){let a=await
|
|
465
|
-
`:"",h=await
|
|
464
|
+
`)}async function jp(e,t,n,r,o,s,i){let a=await j(e,t),c=await J(e),f=await ke(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await _t(e,t,n),u=d.length>0&&d[0]===t,m=u?`Updating ${Y(t)}..${Y(n)}
|
|
465
|
+
`:"",h=await fs(e,t,n,l),p=await En(e,h,a.tree,{labels:l,errorExitCode:u?1:2,operationName:"merge",skipStagedChangeCheck:u});if(!p.ok){await pe(e,"MERGE_MSG"),!u&&p.failureKind==="staged"&&c?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let k=p;return m&&(k.stdout=m+k.stdout),k}let g;if(i?g=`Squashed commit of the following:
|
|
466
466
|
|
|
467
467
|
${i}`:g=`Squashed commit of the following:
|
|
468
468
|
|
|
@@ -470,22 +470,22 @@ ${await Mp(e,t,n)}`,await Se(e,"SQUASH_MSG",g),h.conflicts.length>0){let E=`
|
|
|
470
470
|
# Conflicts:
|
|
471
471
|
${Ut({version:2,entries:h.entries}).sort().map(C=>`# ${C}`).join(`
|
|
472
472
|
`)}
|
|
473
|
-
`,
|
|
473
|
+
`,R=await Ce(e,"MERGE_MSG");return await Se(e,"MERGE_MSG",(R??"")+E),{stdout:`${[...h.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
474
474
|
`)}
|
|
475
|
-
`,stderr:"",exitCode:1}}let w=p.mergedTreeHash,y=await
|
|
475
|
+
`,stderr:"",exitCode:1}}let w=p.mergedTreeHash,y=await Fn(e,a.tree,w),x=h.messages.length>0?`${h.messages.join(`
|
|
476
476
|
`)}
|
|
477
477
|
`:"";return{stdout:`${u?`${m}Fast-forward
|
|
478
|
-
`:""}${
|
|
478
|
+
`:""}${x}Squash commit -- not updating HEAD
|
|
479
479
|
${u?y:""}`,stderr:u?"":`Automatic merge went well; stopped before committing as requested
|
|
480
|
-
`,exitCode:0}}async function Gp(e,t,n){let r=await
|
|
481
|
-
${k}`,stderr:"",exitCode:0}}async function Lp(e,t){return
|
|
482
|
-
`);let f=c[c.length-1],l=c.slice(0,-1),d=
|
|
480
|
+
`,exitCode:0}}async function Gp(e,t,n){let r=await F(e,"MERGE_HEAD");if(!r)return I("There is no merge in progress (MERGE_HEAD missing).");let o=await K(e),s=gn(o,"Committing");if(s)return s;let i=await Ze(e);if(M(i))return i;let a=await j(e,i),c=await Ce(e,"MERGE_MSG");if(c)c=an(c);else{let P=await J(e),C=P?.type==="symbolic"?Re(P.target):"HEAD";c=await ir(e,"unknown",C)}let f=je(o),l=await Ge(e,f),d=await on(e,t);if(M(d))return d;let u=await Qe(e,t);if(M(u))return u;let m=Ht(c),h={repo:e,message:m,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(ee(p))return{stdout:"",stderr:p.message??"",exitCode:1};m=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,mergeMessage:m,treeHash:l,headHash:i,theirsHash:r});if(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await mt(e,l,[i,r],d,u,m);await Qr(e);let y=await J(e),x=fe(m),b=y?.type==="symbolic"?y.target:"HEAD";await re(e,t,b,i,w,`commit (merge): ${x}`,y?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await Fn(e,a.tree,l),E=y?.type==="symbolic"?Re(y.target):"detached HEAD";return{stdout:`${vt(E,w,c)}
|
|
481
|
+
${k}`,stderr:"",exitCode:0}}async function Lp(e,t){return An(e,t,{operationRef:"MERGE_HEAD",noOpError:I("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:Qr})}se();Pe();le();tt();function Pl(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[q.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:v().alias("f").describe("Force renaming even if target exists"),"dry-run":v().alias("n").describe("Do nothing; only show what would happen"),skip:v().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return L(`usage: git mv [<options>] <source>... <destination>
|
|
482
|
+
`);let f=c[c.length-1],l=c.slice(0,-1),d=Ot(r.cwd,f),u=ct(a,d);if(u.startsWith(".."))return I(`'${f}' is outside repository at '${a}'`);let m=await K(s),h=await r.fs.exists(d),p=h&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return I(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let y=Ot(r.cwd,w),x=ct(a,y);if(x.startsWith("..")){if(n.skip)continue;return I(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(y)){if(n.skip)continue;return I(`bad source, source=${x}, destination=${u}`)}let E=(await r.fs.stat(y)).isDirectory;if(!(E?m.entries.some(O=>O.path===x||O.path.startsWith(`${x}/`)):m.entries.some(O=>O.path===x&&O.stage===0))){let O=!E&&m.entries.some(H=>H.path===x&&H.stage>0);if(n.skip)continue;return I(O?`conflicted, source=${x}, destination=${u}`:`not under version control, source=${x}, destination=${u}`)}let P,C;if(p){let O=Ar(x);P=u===""||u==="."?O:`${u}/${O}`,C=S(d,O)}else P=u,C=d;if(await r.fs.exists(C)&&!n.force)if((await r.fs.stat(C)).isDirectory){let H=Ar(x);P=`${P}/${H}`,C=S(C,H)}else{if(n.skip)continue;return I(`destination exists, source=${x}, destination=${P}`)}if(x===P){if(n.skip)continue;return I(`can not move directory into itself, source=${x}, destination=${P}`)}let D=Zt(C);if(!await r.fs.exists(D)){if(n.skip)continue;return I(`renaming '${x}' failed: No such file or directory`)}if(E){let O=`${x}/`,H=m.entries.filter(G=>G.path.startsWith(O)&&G.stage===0);for(let G of H){let A=G.path.slice(x.length),$=P+A,N=C+A;g.push({srcRel:G.path,dstRel:$,srcAbs:S(a,G.path),dstAbs:N})}}else g.push({srcRel:x,dstRel:P,srcAbs:y,dstAbs:C})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let y=Zt(w.dstAbs);await r.fs.exists(y)||await r.fs.mkdir(y,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=$s(m,w.srcRel,0);if(b){m=it(m,w.srcRel);let k={...b,path:w.dstRel};m=bt(m,k)}}for(let w of g)await Jn(r.fs,Zt(w.srcAbs),a);return await ie(s,m),{stdout:"",stderr:"",exitCode:0}}})}se();Ne();xn();Pe();oe();le();dt();Fe();ue();se();Ne();Pe();oe();se();oe();dn();Kn();Te();async function na(e,t){let n=await we(e,t);if(n.type!=="commit")return null;let r=en(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await we(e,r.parents[0]);f.type==="commit"&&(o=en(f.content).tree)}let s=await We(e,o,r.tree);if(s.length===0)return null;let i=zn(),a=!1,c=[...s].sort((f,l)=>Oe(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let m=await we(e,f.oldHash);l=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await we(e,f.newHash);d=new TextDecoder().decode(m.content)}catch{}let u=xt({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
|
|
483
483
|
`)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
|
|
484
|
-
`),a=!0)}}return a?i.hex():null}
|
|
484
|
+
`),a=!0)}}return a?i.hex():null}Fe();ue();Te();sn();tt();async function _p(e){let t=await J(e);return t?.type==="symbolic"?Re(t.target):"detached HEAD"}function Ol(e){return e==="HEAD"?`HEAD is up to date.
|
|
485
485
|
`:`Current branch ${e} is up to date.
|
|
486
|
-
`}async function Np(e,t,n){if(!e.workTree)return null;let r=await
|
|
487
|
-
`)}return null}async function Fp(e,t,n,r){if(!e.workTree)return null;let o=await
|
|
488
|
-
`,exitCode:128}:null}async function
|
|
486
|
+
`}async function Np(e,t,n){if(!e.workTree)return null;let r=await ce(e,t),o=new Map(je(n).map(a=>[a.path,a])),s=new Set(await et(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=qs(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return L(`${a.stderr}error: could not detach HEAD
|
|
487
|
+
`)}return null}async function Fp(e,t,n,r){if(!e.workTree)return null;let o=await ce(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await et(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${qs(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
|
|
488
|
+
`,exitCode:128}:null}async function Il(e,t,n){if(!e.workTree)return null;let r=new Map(je(t).map(i=>[i.path,i])),o=new Set(await et(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function $l(e,t){return`error: The following untracked working tree files would be overwritten by merge:
|
|
489
489
|
${e.map(r=>` ${r}`).join(`
|
|
490
490
|
`)}
|
|
491
491
|
Please move or remove them before you merge.
|
|
@@ -499,20 +499,20 @@ hint: edit the todo list first:
|
|
|
499
499
|
hint:
|
|
500
500
|
hint: git rebase --edit-todo
|
|
501
501
|
hint: git rebase --continue
|
|
502
|
-
`}async function ra(e,t,n,r,o,s){await re(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await re(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await re(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function
|
|
502
|
+
`}async function ra(e,t,n,r,o,s){await re(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await re(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await re(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function To(e,t,n,r){let o=await j(e,t),s=await Np(e,o.tree,n);if(s)return s;let i=await pn(e,o.tree,n);return i.success&&(await ie(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps)),r!=="detached HEAD"?await X(e,r,t):await X(e,"HEAD",t),null}async function sa(e,t,n,r,o,s,i,a){let c=r.startsWith("refs/heads/")?Re(r):"HEAD",f=await K(e),l=Ut(f).sort();if(l.length>0)return{stdout:l.map(O=>`${O}: needs merge
|
|
503
503
|
`).join(""),stderr:`error: cannot rebase: You have unstaged changes.
|
|
504
504
|
error: additionally, your index contains uncommitted changes.
|
|
505
505
|
error: Please commit or stash them.
|
|
506
|
-
`,exitCode:1};let d=await
|
|
506
|
+
`,exitCode:1};let d=await j(e,n),u=await ce(e,d.tree);if(e.workTree){let O=gr(f,u),G=(await St(e,f)).some(A=>A.status==="modified"||A.status==="deleted");if(O||G){let A=[];return G&&A.push("error: cannot rebase: You have unstaged changes."),O&&(G?A.push("error: additionally, your index contains uncommitted changes."):A.push("error: cannot rebase: Your index contains uncommitted changes.")),A.push("error: Please commit or stash them."),L(`${A.join(`
|
|
507
507
|
`)}
|
|
508
|
-
`)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await
|
|
509
|
-
`,exitCode:0})}return{stdout:
|
|
508
|
+
`)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await zc(e,o,n),p=h.right;if(p.length===0){if(s!==n){let O=await To(e,s,f,r);return O||(await ra(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
|
|
509
|
+
`,exitCode:0})}return{stdout:Ol(c),stderr:"",exitCode:0}}let g=[],w=h.left,y=new Set;for(let O of w){let H=await na(e,O.hash);H&&y.add(H)}let x=[];if(y.size>0)for(let O of p){let H=await na(e,O.hash);H&&y.has(H)?g.push(`warning: skipped previously applied commit ${Y(O.hash)}`):x.push(O)}else x.push(...p);let b="";if(g.length>0&&(b=`${g.join(`
|
|
510
510
|
`)}
|
|
511
511
|
hint: use --reapply-cherry-picks to include skipped commits
|
|
512
512
|
hint: Disable this message with "git config set advice.skippedCherryPicks false"
|
|
513
|
-
`),
|
|
514
|
-
`,exitCode:0}}let k=
|
|
515
|
-
`,exitCode:0})}let C=await
|
|
513
|
+
`),x.length===0){if(s!==n){let O=await To(e,s,f,r);if(O)return O.stderr=b+O.stderr,O;await ra(e,t,n,s,r,i)}return{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
|
|
514
|
+
`,exitCode:0}}let k=x.map(O=>({hash:O.hash,subject:fe(O.commit.message)})),E=s,R=0;for(let O of k){let H=await j(e,O.hash);if(H.parents.length>1||H.parents.length===0||H.parents[0]!==E)break;E=O.hash,R++}let P=k.splice(0,R);if(k.length===0){if(E===n)return{stdout:Ol(c),stderr:b,exitCode:0};let O=await To(e,E,f,r);return O?(O.stderr=b+O.stderr,O):(await ra(e,t,n,E,r,i),{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
|
|
515
|
+
`,exitCode:0})}let C=await To(e,E,f,"detached HEAD");if(C)return C.stderr=b+C.stderr,C;await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await re(e,t,"HEAD",n,E,`rebase (start): checkout ${i}`);let T={headName:r,origHead:n,onto:s,todo:k,done:P,msgnum:R,end:R+k.length};await xi(e,T),await X(e,"ORIG_HEAD",n);let D=await oa(e,t);return b&&(D.stderr=b+D.stderr),D}function Sl(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[q.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Q.string().describe("Starting point at which to create new commits"),abort:v().describe("Abort the current rebase operation"),continue:v().describe("Continue the rebase after conflict resolution"),skip:v().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Wp(s,r.env);if(n.continue)return qp(s,r.env);if(n.skip)return zp(s,r.env);let i=n.upstream;if(!i)return I("no upstream configured and no upstream argument given");if(await jt(s))return I(`It seems that there is already a rebase-merge directory, and
|
|
516
516
|
I wonder if you are in the middle of another rebase. If that is the
|
|
517
517
|
case, please try
|
|
518
518
|
git rebase (--continue | --abort | --skip)
|
|
@@ -520,9 +520,9 @@ If that is not the case, please
|
|
|
520
520
|
rm -fr ".git/rebase-merge"
|
|
521
521
|
and run me again. I am stopping in case you still have something
|
|
522
522
|
valuable there.
|
|
523
|
-
`);let a=await Ze(s);if(M(a))return a;let c=await
|
|
523
|
+
`);let a=await Ze(s);if(M(a))return a;let c=await J(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await ve(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,u,m=n.onto;if(m){let h=await ve(s,m,`Does not point to a valid commit: '${m}'`);if(M(h))return h;u=h.hash}else u=d;return sa(s,r.env,a,f,d,u,i,t)}})}async function oa(e,t){let n=[],r=[];for(;;){let o=await pt(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 qc(e);let i=await Up(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await pt(e);a&&(a.todo=[s,...a.todo],await xi(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 Bp(e,n,t)}async function Up(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await j(e,s):null,a=await Z(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
|
|
524
524
|
`};if(s&&s===a){let G=await K(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
|
|
525
|
-
`};let A=await Ve(e,i.tree)
|
|
525
|
+
`};let A=await Ve(e,i.tree),$=await Ve(e,o.tree),N=new Map(A.map(U=>[U.path,U.hash])),B=new Map;for(let U of $){let V=N.get(U.path);(!V||V!==U.hash)&&B.set(U.path,U.hash)}let z=await Il(e,G,B);if(z)return await X(e,"REBASE_HEAD",r),await eo(e,r,o.author),{conflict:!0,stdout:"",stderr:$l(z,t),rescheduleCurrent:!0};let _=await pn(e,o.tree,G);return _.success&&(await ie(e,{version:2,entries:_.newEntries}),await De(e,_.worktreeOps)),await In(e,r),await re(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await j(e,a),f=i?i.tree:null,l=Y(r),d=fe(o.message),u=await ke(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:u},h=await Nt(e,f,c.tree,o.tree,m),p=await K(e),[g,w,y]=await Promise.all([Ve(e,c.tree),f?Ve(e,f):Promise.resolve([]),Ve(e,o.tree)]),x=new Set;for(let G of w)x.add(G.path);for(let G of g)x.add(G.path);for(let G of y)x.add(G.path);let b=p.entries.filter(G=>!x.has(G.path)),k=[...h.entries,...b];k.sort((G,A)=>Oe(G.path,A.path)||G.stage-A.stage);let E={version:2,entries:k},R=k.filter(G=>G.stage===0),P=await Ge(e,R),C=new Map(g.map(G=>[G.path,G])),T=new Map;for(let G of R){let A=C.get(G.path);(!A||A.hash!==G.hash)&&T.set(G.path,G.hash)}for(let G of h.conflicts){if(G.reason==="content"||G.reason==="add-add"){T.set(G.path,null);continue}if(G.reason==="delete-modify"){let A=h.entries.filter(B=>B.path===G.path&&B.stage>0),$=A.find(B=>B.stage===2),N=A.find(B=>B.stage===3);N&&!$&&T.set(G.path,N.hash)}}let D=await Il(e,p,T);if(D)return await X(e,"REBASE_HEAD",r),await eo(e,r,o.author),{conflict:!0,stdout:"",stderr:$l(D,t),rescheduleCurrent:!0};if(await ie(e,E),e.workTree){let G=await Hn(e,c.tree,h.resultTree,p);G.success&&await De(e,G.worktreeOps)}if(h.conflicts.length>0){await X(e,"REBASE_HEAD",r),await eo(e,r,o.author),await Se(e,"MERGE_MSG",o.message),await Se(e,"rebase-merge/message",o.message);let G=h.messages.join(`
|
|
526
526
|
`);return{conflict:!0,stdout:G?`${G}
|
|
527
527
|
`:"",stderr:`error: could not apply ${l}... ${t.subject}
|
|
528
528
|
hint: Resolve all conflicts manually, mark them as resolved with
|
|
@@ -532,12 +532,12 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
|
|
|
532
532
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
533
533
|
Could not apply ${l}... # ${t.subject}
|
|
534
534
|
`}}if(P===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
|
|
535
|
-
`};let O=await Qe(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let H=await mt(e,P,[a],o.author,O,o.message);return await re(e,n,"HEAD",a,H,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Bp(e,t,n){let r=await pt(e);if(!r)return I("no rebase in progress");let o=await
|
|
536
|
-
`;return await de(e,"REBASE_HEAD"),await
|
|
535
|
+
`};let O=await Qe(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let H=await mt(e,P,[a],o.author,O,o.message);return await re(e,n,"HEAD",a,H,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Bp(e,t,n){let r=await pt(e);if(!r)return I("no rebase in progress");let o=await Z(e);if(!o)return I("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await X(e,r.headName,o),await ze(e,"HEAD",r.headName),await ht(e),await re(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await re(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
|
|
536
|
+
`;return await de(e,"REBASE_HEAD"),await nr(e),await Ci(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Wp(e,t){let n=await pt(e);if(!n)return I("no rebase in progress");let r=await Z(e),o=n.origHead,s=await j(e,o),i=await K(e),a=await Fp(e,s.tree,i,o);if(a)return a;let c=await pn(e,s.tree,i);c.success&&(await ie(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await X(e,n.headName,o),await ze(e,"HEAD",n.headName),await ht(e)):await In(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await re(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await de(e,"REBASE_HEAD"),await nr(e),await Ci(e),{stdout:"",stderr:"",exitCode:0}}async function qp(e,t){let n="";if(!await pt(e))return I("no rebase in progress");let o=await K(e);if($t(o))return L(`error: Committing is not possible because you have unmerged files.
|
|
537
537
|
hint: Fix them up in the work tree, and then use 'git add <file>'
|
|
538
538
|
hint: as appropriate to mark resolution and make a commit.
|
|
539
539
|
fatal: Exiting because of an unresolved conflict.
|
|
540
|
-
`,128);let s=await
|
|
540
|
+
`,128);let s=await F(e,"REBASE_HEAD");if(s){let a=await Z(e);if(!a)return I("Cannot read HEAD");let c=await j(e,a),f=je(o),l=await Ge(e,f),d=l!==c.tree,u=await Ce(e,"rebase-merge/message")!==null;if(d&&!u)return L(`error: you have staged changes in your working tree
|
|
541
541
|
If these changes are meant to be squashed into the previous commit, run:
|
|
542
542
|
|
|
543
543
|
git commit --amend
|
|
@@ -550,37 +550,37 @@ In both cases, once you're done, continue with:
|
|
|
550
550
|
|
|
551
551
|
git rebase --continue
|
|
552
552
|
|
|
553
|
-
`);if(d){let m=await
|
|
554
|
-
${C}`}await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await
|
|
553
|
+
`);if(d){let m=await j(e,s),h=await F(e,"CHERRY_PICK_HEAD"),p=h?await j(e,h):m,g;g=await Ce(e,"rebase-merge/message")??await Ce(e,"MERGE_MSG")??void 0,g&&(g=an(g)),g||(g=m.message);let w=await Qe(e,t);if(M(w))return w;let y=Ht(g),x=[a],b=await F(e,"MERGE_HEAD");b&&x.push(b);let k=await mt(e,l,x,p.author,w,y);b&&(await de(e,"MERGE_HEAD"),await pe(e,"MERGE_MODE"));let E=fe(y);await re(e,t,"HEAD",a,k,`rebase (continue): ${E}`);let R=await _p(e),P=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,C=await cn(e,c.tree,l,p.author,w,P);n=`${vt(R,k,y)}
|
|
554
|
+
${C}`}await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"rebase-merge/message")}let i=await oa(e,t);return n&&(i.stdout=n+i.stdout),i}async function zp(e,t){if(!await pt(e))return I("no rebase in progress");let r=await Z(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
|
|
555
555
|
fatal: could not discard worktree changes
|
|
556
|
-
`,exitCode:128};let o=await
|
|
557
|
-
`,128);let f=n.remote,l=n.branch;if(!f){let ne=await
|
|
558
|
-
`),!A)return I("Could not determine remote HEAD");let
|
|
559
|
-
`,stderr:"",exitCode:0};if(d){let ne=await
|
|
560
|
-
`,stderr:"",exitCode:0};let
|
|
556
|
+
`,exitCode:128};let o=await j(e,r),s=await K(e),i=await pn(e,o.tree,s);return i.success&&(await ie(e,{version:2,entries:i.newEntries}),await De(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 pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"rebase-merge/message"),oa(e,t)}function Tl(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[q.string().name("remote").describe("Remote to pull from").optional(),q.string().name("branch").describe("Remote branch").optional()],options:{rebase:v().alias("r").describe("Rebase instead of merge"),noRebase:v().describe("Merge instead of rebase"),ffOnly:v().describe("Only fast-forward"),noFf:v().describe("Create a merge commit even for fast-forwards"),depth:Q.number().describe("Limit fetching to the specified number of commits"),unshallow:v().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await wo(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=ls);let a=await Ze(s);if(M(a))return a;let c=await K(s);if($t(c))return L(`error: Pulling is not possible because you have unmerged files.
|
|
557
|
+
`,128);let f=n.remote,l=n.branch;if(!f){let ne=await J(s);if(ne?.type==="symbolic"){let He=ne.target.startsWith("refs/heads/")?ne.target.slice(11):ne.target,Xt=(await he(s))[`branch "${He}"`];Xt&&(f=Xt.remote||"origin",!l&&Xt.merge&&(l=Xt.merge.startsWith("refs/heads/")?Xt.merge.slice(11):Xt.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let ne=await J(s);if(ne?.type==="symbolic"){let He=ne.target.startsWith("refs/heads/")?ne.target.slice(11):ne.target,ln=await ke(s,`branch.${He}.rebase`);(ln==="true"||ln!=="false"&&await ke(s,"pull.rebase")==="true")&&(d=!0)}else await ke(s,"pull.rebase")==="true"&&(d=!0)}let u;try{u=await $r(s,f,r.env)}catch(ne){let He=ne instanceof Error?ne.message:"";if(He.startsWith("network"))return I(He);throw ne}if(!u)return I(`'${f}' does not appear to be a git repository`);let{transport:m,config:h}=u,p=l??null,g=await t?.hooks?.prePull?.({repo:s,remote:f,branch:p});if(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=cr(h.fetchRefspec),y=await m.advertiseRefs();if(y.length===0)return I("Couldn't find remote ref HEAD");let b=(await ge(s)).map(ne=>ne.hash),k=await F(s,"HEAD");k&&b.push(k);let E=[],R=new Set,P=[];for(let ne of y){if(ne.name==="HEAD")continue;let He=Io(w,ne.name);He!==null&&(P.push({remote:ne,localRef:He}),R.has(ne.hash)||(R.add(ne.hash),E.push(ne.hash)))}let C=new Set(b),T=E.filter(ne=>!C.has(ne)),D,O=i!==void 0?await xr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:O});let H=T.length>0?T:D?E:[];if(H.length>0){let ne=await m.fetch(H,b,D);ne.shallowUpdates&&await Cr(s,ne.shallowUpdates,O)}let G=await Jt(s,r.env);for(let ne of P){let He=await F(s,ne.localRef);await X(s,ne.localRef,ne.remote.hash),await Ke(s,ne.localRef,{oldHash:He??te,newHash:ne.remote.hash,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:He?"pull":"pull: storing head"})}let A=null;if(l){let ne=y.find(He=>He.name===`refs/heads/${l}`);if(ne)A=ne.hash;else return I(`Couldn't find remote ref refs/heads/${l}`)}else{let ne=y.find(He=>He.name==="HEAD");ne&&(A=ne.hash)}if(A&&await r.fs.writeFile(S(s.gitDir,"FETCH_HEAD"),`${A} ${h.url}
|
|
558
|
+
`),!A)return I("Could not determine remote HEAD");let $=A;if(a===$)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
559
|
+
`,stderr:"",exitCode:0};if(d){let ne=await J(s),He=ne?.type==="symbolic"?ne.target:"detached HEAD",ln=l?`${f}/${l}`:f,Xt=await sa(s,r.env,a,He,$,$,ln,t);return Xt.exitCode===0&&await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:null}),Xt}let N=await _t(s,a,$),B=N[0]??null;if(N.length===0)return I("refusing to merge unrelated histories");if(B===$)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
|
|
560
|
+
`,stderr:"",exitCode:0};let z=!!n.noFf,_=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let ne=await ke(s,"pull.ff");ne==="false"?z=!0:ne==="only"&&(_=!0)}let U=B===a;if(_&&!U)return I("Not possible to fast-forward, aborting.");if(U&&!z){let ne=await po(s,a,$),He=await J(s),ln=He?.type==="symbolic"?He.target:"HEAD";return await Ke(s,ln,{oldHash:a,newHash:$,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),He?.type==="symbolic"&&await Ke(s,"HEAD",{oldHash:a,newHash:$,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),ne.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:$,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:null})),ne}let V=await J(s),be=V?.type==="symbolic"?Re(V.target):"HEAD",Le=l||f||"FETCH_HEAD",ot=await ke(s,"merge.conflictstyle")??"merge",me={a:"HEAD",b:Le,conflictStyle:ot},xe=await fs(s,a,$,me),Ft=await j(s,a),Rn=await En(s,xe,Ft.tree,{labels:me,errorExitCode:2,operationName:"merge"});if(!Rn.ok)return Rn;if(xe.conflicts.length>0){await X(s,"MERGE_HEAD",$),await X(s,"ORIG_HEAD",a);let ne=await ir(s,Le,be),He=Ut({version:2,entries:xe.entries}).sort();return ne+=`
|
|
561
561
|
# Conflicts:
|
|
562
|
-
${
|
|
562
|
+
${He.map(ln=>`# ${ln}`).join(`
|
|
563
563
|
`)}
|
|
564
|
-
`,await Se(s,"MERGE_MSG",ne),{stdout:`${[
|
|
564
|
+
`,await Se(s,"MERGE_MSG",ne),{stdout:`${[...xe.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
|
|
565
565
|
`)}
|
|
566
|
-
`,stderr:"",exitCode:1}}let
|
|
566
|
+
`,stderr:"",exitCode:1}}let qe=Rn.mergedTreeHash,fr=await on(s,r.env);if(M(fr))return fr;let ws=await Qe(s,r.env);if(M(ws))return ws;let bs=await ir(s,Le,be),ha={repo:s,message:bs,treeHash:qe,headHash:a,theirsHash:$},pa=await t?.hooks?.mergeMsg?.(ha);if(ee(pa))return{stdout:"",stderr:pa.message??"",exitCode:1};bs=ha.message;let ga=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:bs,treeHash:qe,headHash:a,theirsHash:$});if(ee(ga))return{stdout:"",stderr:ga.message??"",exitCode:1};let ys=await mt(s,qe,[a,$],fr,ws,bs);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:$,strategy:"three-way",commitHash:ys}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:ys});let rd=V?.type==="symbolic"?V.target:"HEAD",wa="pull: Merge made by the 'ort' strategy.";await Ke(s,rd,{oldHash:a,newHash:ys,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:wa}),V?.type==="symbolic"&&await Ke(s,"HEAD",{oldHash:a,newHash:ys,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:wa});let sd=await Fn(s,Ft.tree,qe);return{stdout:`${xe.messages.length>0?`${xe.messages.join(`
|
|
567
567
|
`)}
|
|
568
568
|
`:""}Merge made by the 'ort' strategy.
|
|
569
|
-
${
|
|
570
|
-
`);m.push({name:E,oldHash:
|
|
571
|
-
`);let
|
|
572
|
-
`);let P=(await
|
|
573
|
-
`,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===te?null:b.name,srcHash:b.newHash===te?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===te}))});if(ee(p))return
|
|
569
|
+
${sd}`,stderr:"",exitCode:0}}})}se();Ne();dt();ue();function vl(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[q.string().name("remote").describe("Remote to push to").optional(),q.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:v().alias("f").describe("Force push"),"set-upstream":v().alias("u").describe("Set upstream tracking reference"),all:v().describe("Push all branches"),delete:v().alias("d").describe("Delete remote refs"),tags:v().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a;try{a=await $r(s,i,r.env)}catch(b){let k=b instanceof Error?b.message:"";if(k.startsWith("network"))return I(k);throw b}if(!a)return I(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,l=n.force,d=await c.advertiseRefs(),u=new Map;for(let b of d)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 I("--delete requires a ref argument");for(let k of b){let E=k.startsWith("refs/")?k:`refs/heads/${k}`,R=u.get(E)??null;if(!R)return L(`error: unable to delete '${k}': remote ref does not exist
|
|
570
|
+
`);m.push({name:E,oldHash:R,newHash:te,ok:l})}}else if(n.all){let b=await ge(s,"refs/heads");for(let k of b){let E=k.name,R=u.get(E)??null;m.push({name:E,oldHash:R,newHash:k.hash,ok:l})}}else if(n.tags){let b=await ge(s,"refs/tags");for(let k of b){let E=u.get(k.name)??null;E!==k.hash&&m.push({name:k.name,oldHash:E,newHash:k.hash,ok:l})}}else if(h&&h.length>0)for(let b of h){let k=cr(b),E=await Vp(s,k.src);if(!E)return L(`error: src refspec '${k.src}' does not match any
|
|
571
|
+
`);let R=k.dst.startsWith("refs/")?k.dst:`refs/heads/${k.dst}`,P=u.get(R)??null;m.push({name:R,oldHash:P,newHash:E,ok:l||k.force})}else{let b=await J(s);if(!b||b.type!=="symbolic")return I("You are not currently on a branch.");let k=b.target,E=k.startsWith("refs/heads/")?k.slice(11):k,R=await Z(s);if(!R)return L(`error: src refspec does not match any
|
|
572
|
+
`);let P=(await ke(s,"push.default"))?.toLowerCase()??"simple",C=await Kp(s,P,k,E,R,i,u,l);if("exitCode"in C)return C;m.push(C)}if(m.length===0)return{stdout:`Everything up-to-date
|
|
573
|
+
`,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===te?null:b.name,srcHash:b.newHash===te?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===te}))});if(ee(p))return L(p.message??"");let g=await c.push(m),w=[];w.push(`To ${f.url}
|
|
574
574
|
`);let y=!1;for(let b of g.updates){let k=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name;if(!b.ok)w.push(` ! [rejected] ${k} -> ${k} (${b.error??"failed"})
|
|
575
575
|
`),y=!0;else if(!b.oldHash)w.push(` * [new branch] ${k} -> ${k}
|
|
576
576
|
`);else if(b.newHash===te)w.push(` - [deleted] ${k}
|
|
577
|
-
`);else{let E=
|
|
578
|
-
`)}}if(n["set-upstream"]&&!y){let b=await
|
|
579
|
-
`)}}let
|
|
577
|
+
`);else{let E=Y(b.oldHash),R=Y(b.newHash);w.push(` ${E}..${R} ${k} -> ${k}
|
|
578
|
+
`)}}if(n["set-upstream"]&&!y){let b=await J(s);if(b?.type==="symbolic"){let k=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,E=await he(s);E[`branch "${k}"`]={remote:i,merge:`refs/heads/${k}`},await Ye(s,E),w.push(`branch '${k}' set up to track '${i}/${k}'.
|
|
579
|
+
`)}}let x={stdout:"",stderr:w.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===te?null:b.name,srcHash:b.newHash===te?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===te}))}),x}})}async function Kp(e,t,n,r,o,s,i,a){if(t==="nothing")return I(`You didn't specify any refspecs to push, and push.default is "nothing".`);if(t==="current")return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a};if(t==="upstream"){let d=(await he(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return I(`The current branch ${r} has no upstream branch.
|
|
580
580
|
To push the current branch and set the remote as upstream, use
|
|
581
581
|
|
|
582
582
|
git push --set-upstream ${s} ${r}
|
|
583
|
-
`);let u=d.merge;return{name:u,oldHash:i.get(u)??null,newHash:o,ok:a}}let f=(await
|
|
583
|
+
`);let u=d.merge;return{name:u,oldHash:i.get(u)??null,newHash:o,ok:a}}let f=(await he(e))[`branch "${r}"`];if(f?.remote&&f?.merge){let l=f.remote,d=f.merge;if(l===s)return(d.startsWith("refs/heads/")?d.slice(11):d)!==r?I(`The upstream branch of your current branch does not match
|
|
584
584
|
the name of your current branch. To push to the upstream branch
|
|
585
585
|
on the remote, use
|
|
586
586
|
|
|
@@ -589,52 +589,52 @@ on the remote, use
|
|
|
589
589
|
To push to the branch of the same name on the remote, use
|
|
590
590
|
|
|
591
591
|
git push ${s} HEAD
|
|
592
|
-
`):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}async function Vp(e,t){if(t.startsWith("refs/"))return
|
|
592
|
+
`):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}async function Vp(e,t){if(t.startsWith("refs/"))return F(e,t);let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);return r||(t==="HEAD"?Z(e):null)}se();le();Fe();ue();function Yp(e,t,n,r){return`${Y(n)} ${e}@{${t}}: ${r}`}async function vo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await F(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
|
|
593
593
|
Use '--' to separate paths from revisions, like this:
|
|
594
594
|
'git <command> [<revision>...] -- [<file>...]'
|
|
595
595
|
`,exitCode:128};let s=await Je(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let l=s.length-1;l>=0&&c<a;l--){let d=s[l];if(!d)continue;let u=s.length-1-l;d.newHash!==te&&(i.push(Yp(t,u,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
|
|
596
596
|
`)}
|
|
597
|
-
`:"",stderr:"",exitCode:0}}function
|
|
598
|
-
`,exitCode:128};let l
|
|
597
|
+
`:"",stderr:"",exitCode:0}}function Hl(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.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 W(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return vo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return vo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return vo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
|
|
598
|
+
`,exitCode:128};let l=S(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return vo(i,c,r.maxCount)}})}se();Ne();Fe();ue();function Xp(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 Al(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:v().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=Xp(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let m=c[`remote "${d}"`]?.url??"";l.push(`${d} ${m} (fetch)`),l.push(`${d} ${m} (push)`)}return{stdout:`${l.join(`
|
|
599
599
|
`)}
|
|
600
600
|
`,stderr:"",exitCode:0}}return{stdout:`${f.join(`
|
|
601
601
|
`)}
|
|
602
|
-
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[
|
|
603
|
-
`,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 W(i.fs,i.cwd,t);if(M(a))return a;let c=await
|
|
604
|
-
`,2)},o=[
|
|
605
|
-
`,2);let l=c[f];return l&&(l.url=s.url),await Ye(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[
|
|
606
|
-
`,stderr:"",exitCode:0}:
|
|
607
|
-
`,2)}})}async function Zp(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return
|
|
608
|
-
`,2);let s=`remote "${r}"`;if(s in t)return I(`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
|
|
609
|
-
`)}
|
|
610
|
-
`}async function
|
|
611
|
-
`:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}se();
|
|
612
|
-
`,exitCode:1};s=it(s,f)}}return c?(await ie(e,s),{stdout:"",stderr:"",exitCode:0}):
|
|
613
|
-
`)}async function tg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await
|
|
614
|
-
`,exitCode:1};i.push(f)}if(i.length===0)return
|
|
615
|
-
`);for(let f of i){let l=o.get(f);if(l)await at(e,{path:l.path,hash:l.hash,mode:l.mode});else{let d=`${e.workTree}/${f}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function ng(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await
|
|
616
|
-
`);for(let f of a){let l=o.get(f);if(l)s=bt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:
|
|
617
|
-
`,exitCode:1};s=it(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}se();le();ue();mn();function
|
|
618
|
-
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return I("Needed a single revision");for(let b of o){if(a){let
|
|
619
|
-
`).join(""),stderr:"",exitCode:0}}})}function aa(e,t){return t?I("Needed a single revision"):Kt(e)}async function rg(e,t){if(t==="HEAD"||t==="@"){let r=await
|
|
620
|
-
`);if(m)return m;let h=await
|
|
602
|
+
`,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?L(`error: remote ${s.name} already exists.
|
|
603
|
+
`,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 W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Jp(c,s.name),await Ye(a,c),await Qp(a,s.name),{stdout:"",stderr:"",exitCode:0}):L(`error: No such remote: '${s.name}'
|
|
604
|
+
`,2)},o=[q.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a);return Zp(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;if(!(f in c))return L(`error: No such remote '${s.name}'
|
|
605
|
+
`,2);let l=c[f];return l&&(l.url=s.url),await Ye(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
|
|
606
|
+
`,stderr:"",exitCode:0}:L(`error: No such remote '${s.name}'
|
|
607
|
+
`,2)}})}async function Zp(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return L(`error: No such remote: '${n}'
|
|
608
|
+
`,2);let s=`remote "${r}"`;if(s in t)return I(`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 ge(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await Je(e,f.name);await X(e,l,f.hash),await de(e,f.name),d.length>0&&await Sn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Jp(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 Qp(e,t){let n=`refs/remotes/${t}`,r=await ge(e,n);for(let o of r)await de(e,o.name)}se();Pe();oe();le();Fe();ue();mn();Te();sn();tt();function Ml(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:v().describe("Only move HEAD"),mixed:v().describe("Move HEAD and reset index (default)"),hard:v().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return I("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=ut(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return ia(i,o.passthrough,l,m,t)}if(!f&&a.length>0){let m=a[0],h=await Be(i,m);return a.length===1&&h?Dl(i,m,"mixed",r.env,t):h?ia(i,a.slice(1),l,m,t):ia(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return Dl(i,u,d,r.env,t)}})}async function ia(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",target:r??null});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await Be(e,r);if(!d)return Kt(r);let u=await _e(e,d);i=(await j(e,u)).tree}else{let d=await Z(e);d&&(i=(await j(e,d)).tree)}let a=await ce(e,i??null),c=await K(e);if(t.some(er)){let d=t.map(m=>Ue(m,n)),u=new Set;for(let[m]of a)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!ye(d,m))continue;let h=a.get(m);h?c=bt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Ie()}):c=it(c,m)}}else for(let d of t){let u=a.get(d);if(u)c=bt(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:Ie()});else if(c.entries.some(h=>h.path===d))c=it(c,d);else if(!(e.workTree&&await e.fs.exists(S(e.workTree,d))))return Kt(d)}await ie(e,c);let l={stdout:await jl(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function jl(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 St(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(`
|
|
609
|
+
`)}
|
|
610
|
+
`}async function Dl(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,target:t});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await Be(e,t);if(!i)return Kt(t);let a=await _e(e,i),c=await j(e,a);if(n==="soft"){let m=await F(e,"MERGE_HEAD"),h=await K(e);if(m||$t(h))return I("Cannot do a soft reset in the middle of a merge.")}let f=await Z(e),l=await J(e);l?.type==="symbolic"?await X(e,l.target,a):await X(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await re(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await re(e,r,"HEAD",f,a,d),await nr(e),n==="mixed"){let m=await Ve(e,c.tree),h=Ss(m.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Ie()})));await ie(e,h);let p=await jl(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=Xe(e);if(m)return m;let h=await K(e),p=await pn(e,c.tree,h);await ie(e,{version:2,entries:p.newEntries}),await De(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${Y(a)} ${fe(c.message)}
|
|
611
|
+
`:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}se();Pe();oe();ue();Te();tt();function Gl(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:Q.string().alias("s").describe("Restore from tree-ish"),staged:v().alias("S").describe("Restore the index"),worktree:v().alias("W").describe("Restore the working tree (default)"),ours:v().describe("Checkout our version for unmerged files"),theirs:v().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return I("you must specify path(s) to restore");if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=ut(i,r.cwd);if(n.ours||n.theirs)return n.source?I("cannot specify both --source and --ours/--theirs"):c?I("cannot use --ours/--theirs with --staged"):so(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let u=await ve(i,n.source,`could not resolve '${n.source}'`);if(M(u))return u;d=u.commit.tree}else if(c){let u=await Z(i);u&&(d=(await j(i,u)).tree)}return c&&f?ng(i,a,l,d):c?eg(i,a,l,d):d?tg(i,a,l,d):ro(i,a,l)}})}async function eg(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(f=>Ue(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 l=o.get(f);if(l)s=bt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Ie()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
612
|
+
`,exitCode:1};s=it(s,f)}}return c?(await ie(e,s),{stdout:"",stderr:"",exitCode:0}):L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
613
|
+
`)}async function tg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await ce(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
614
|
+
`,exitCode:1};i.push(f)}if(i.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
615
|
+
`);for(let f of i){let l=o.get(f);if(l)await at(e,{path:l.path,hash:l.hash,mode:l.mode});else{let d=`${e.workTree}/${f}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function ng(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await ce(e,r),s=await K(e),i=t.map(f=>Ue(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 L(`error: pathspec '${t[0]}' did not match any file(s) known to git
|
|
616
|
+
`);for(let f of a){let l=o.get(f);if(l)s=bt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Ie()}),await at(e,{path:l.path,hash:l.hash,mode:l.mode});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
|
|
617
|
+
`,exitCode:1};s=it(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}se();oe();le();ue();mn();Te();function Ll(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[q.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:v().describe("Verify that exactly one parameter is provided and resolves to an object"),short:v().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":v().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":v().describe("Output the full symbolic ref name"),"show-toplevel":v().describe("Show the absolute path of the top-level directory"),"git-dir":v().describe("Show the path to the .git directory"),"is-inside-work-tree":v().describe("Output whether cwd is inside the work tree"),"is-bare-repository":v().describe("Output whether the repository is bare"),"show-prefix":v().describe("Show path of cwd relative to top-level directory"),"show-cdup":v().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||l||d||u||m||h,g=await W(r.fs,r.cwd,t);if(M(g))return g;let w=g,y=[];if(f){if(!w.workTree)return I("this operation must be run in a work tree");y.push(w.workTree)}if(l&&y.push(w.gitDir),d&&y.push(w.workTree?"true":"false"),u&&y.push(w.workTree?"false":"true"),m){if(!w.workTree)return I("this operation must be run in a work tree");let b=ct(w.workTree,r.cwd);y.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return I("this operation must be run in a work tree");let b=ct(r.cwd,w.workTree);y.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:y.map(k=>`${k}
|
|
618
|
+
`).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return I("Needed a single revision");for(let b of o){if(a){let R=await rg(w,b);if(R===null)return aa(b,s);y.push(R);continue}if(c){let R=await sg(w,b);if(R===null)return aa(b,s);y.push(R);continue}let k=Gs(b);if(k){let R=await og(w,k.rev,k.path);if(R===null){let P=k.path.replace(/^\//,"");return I(`path '${P}' does not exist in '${k.rev}'`)}y.push(i?Y(R):R);continue}let E=await Be(w,b);if(!E)return aa(b,s);y.push(i?Y(E):E)}return{stdout:y.map(b=>`${b}
|
|
619
|
+
`).join(""),stderr:"",exitCode:0}}})}function aa(e,t){return t?I("Needed a single revision"):Kt(e)}async function rg(e,t){if(t==="HEAD"||t==="@"){let r=await J(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 sg(e,t){if(t==="HEAD"||t==="@"){let r=await J(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 F(e,o))return o}return t}async function og(e,t,n){let r=await Be(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await ce(e,o.tree)).get(s)?.hash??null}se();Ne();Pe();oe();Fe();ue();Te();function _l(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:v().describe("Abort the current revert operation"),continue:v().describe("Continue the revert after conflict resolution"),"no-commit":v().alias("n").describe("Apply changes without creating a commit"),"no-edit":v().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 W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let z=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(ee(z))return{stdout:"",stderr:z.message??"",exitCode:1};let _=await ig(s,r.env);return _.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),_}if(n.continue){let z=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(ee(z))return{stdout:"",stderr:z.message??"",exitCode:1};let _=await ag(s,r.env);return _.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),_}let i=n.commit;if(!i)return I("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await ve(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Ze(s);if(M(d))return d;let u=await K(s),m=gn(u,"Reverting",`fatal: revert failed
|
|
620
|
+
`);if(m)return m;let h=await j(s,d);if(s.workTree){let z=await ce(s,h.tree);if(gr(u,z))return L(`error: your local changes would be overwritten by revert.
|
|
621
621
|
hint: commit your changes or stash them to proceed.
|
|
622
622
|
fatal: revert failed
|
|
623
|
-
`,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return
|
|
623
|
+
`,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return L(`error: commit ${f} is a merge but no -m option was given.
|
|
624
624
|
fatal: revert failed
|
|
625
|
-
`,128);if(p<1||p>l.parents.length)return
|
|
625
|
+
`,128);if(p<1||p>l.parents.length)return L(`error: commit ${f} does not have parent ${p}
|
|
626
626
|
fatal: revert failed
|
|
627
|
-
`,128);let
|
|
627
|
+
`,128);let z=l.parents[p-1];g=(await j(s,z)).tree}else if(l.parents.length===0)g=await Ge(s,[]);else{let z=l.parents[0];g=(await j(s,z)).tree}let w=Y(f),y=fe(l.message),x=cg(l,f,p),b=await ke(s,"merge.conflictstyle")??"merge",k={a:"HEAD",b:y?`parent of ${w} (${y})`:`parent of ${w}`,conflictStyle:b},E=await Nt(s,l.tree,h.tree,g,k);if(E.conflicts.length===0&&E.resultTree===h.tree){let z=E.messages.length>0?`${E.messages.join(`
|
|
628
628
|
`)}
|
|
629
|
-
`:"",
|
|
629
|
+
`:"",_=await rt(s,{fromCommit:!0}),U=await F(s,"CHERRY_PICK_HEAD");return{stdout:`${z}${_}`,stderr:U?`The previous cherry-pick is now empty, possibly due to conflict resolution.
|
|
630
630
|
If you wish to commit it anyway, use:
|
|
631
631
|
|
|
632
632
|
git commit --allow-empty
|
|
633
633
|
|
|
634
634
|
Otherwise, please use 'git cherry-pick --skip'
|
|
635
|
-
`:"",exitCode:1}}let
|
|
636
|
-
`);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:
|
|
637
|
-
`:"",stderr:`error: could not revert ${w}... ${
|
|
635
|
+
`:"",exitCode:1}}let R=await En(s,E,h.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!R.ok)return R;if(E.conflicts.length>0){await X(s,"REVERT_HEAD",f),await X(s,"ORIG_HEAD",d),await Se(s,"MERGE_MSG",x);let z=E.messages.join(`
|
|
636
|
+
`);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:z?`${z}
|
|
637
|
+
`:"",stderr:`error: could not revert ${w}... ${fe(l.message)}
|
|
638
638
|
hint: After resolving the conflicts, mark them with
|
|
639
639
|
hint: "git add/rm <pathspec>", then run
|
|
640
640
|
hint: "git revert --continue".
|
|
@@ -642,106 +642,106 @@ hint: You can instead skip this commit with "git revert --skip".
|
|
|
642
642
|
hint: To abort and get back to the state before "git revert",
|
|
643
643
|
hint: run "git revert --abort".
|
|
644
644
|
hint: Disable this message with "git config set advice.mergeConflict false"
|
|
645
|
-
`,exitCode:1}}if(n["no-commit"])return await
|
|
645
|
+
`,exitCode:1}}if(n["no-commit"])return await X(s,"REVERT_HEAD",f),await Se(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let P=R.mergedTreeHash,C=await on(s,r.env);if(M(C))return C;let T=await Qe(s,r.env);if(M(T))return T;let D=await mt(s,P,[d],C,T,x);await Mt(s),await Dt(s);let O=await J(s),H=fe(x),G=O?.type==="symbolic"?O.target:"HEAD";await re(s,r.env,G,d,D,`revert: ${H}`,O?.type==="symbolic");let A=O?.type==="symbolic"?Re(O.target):"detached HEAD",$=await cn(s,h.tree,P,C,T,C.timestamp!==T.timestamp||C.timezone!==T.timezone),N=vt(A,D,x),B=E.messages.length>0?`${E.messages.join(`
|
|
646
646
|
`)}
|
|
647
|
-
`:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:D,hadConflicts:!1}),{stdout:`${B}${
|
|
648
|
-
${
|
|
647
|
+
`:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:D,hadConflicts:!1}),{stdout:`${B}${N}
|
|
648
|
+
${$}`,stderr:"",exitCode:0}}})}async function ig(e,t){return await F(e,"REVERT_HEAD")?An(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
|
|
649
649
|
fatal: revert failed
|
|
650
|
-
`,128),operationName:"revert",clearState:async o=>{await
|
|
650
|
+
`,128),operationName:"revert",clearState:async o=>{await Mt(o),await Dt(o)},origHeadAsTargetRev:!0}):await F(e,"CHERRY_PICK_HEAD")?An(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
|
|
651
651
|
fatal: revert failed
|
|
652
|
-
`,128),operationName:"revert",clearState:
|
|
652
|
+
`,128),operationName:"revert",clearState:Dt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
|
|
653
653
|
fatal: revert failed
|
|
654
|
-
`,128)}async function
|
|
654
|
+
`,128)}async function ag(e,t){if(!await F(e,"REVERT_HEAD"))return L(`error: no cherry-pick or revert in progress
|
|
655
655
|
fatal: revert failed
|
|
656
|
-
`,128);let r=await K(e),o=gn(r,"Committing");if(o)return o;let s=await
|
|
657
|
-
`,1);let i=je(r),a=await Ge(e,i),c=await Ze(e);if(M(c))return c;let f=await
|
|
658
|
-
${
|
|
656
|
+
`,128);let r=await K(e),o=gn(r,"Committing");if(o)return o;let s=await Ce(e,"MERGE_MSG");if(!s)return L(`Aborting commit due to empty commit message.
|
|
657
|
+
`,1);let i=je(r),a=await Ge(e,i),c=await Ze(e);if(M(c))return c;let f=await j(e,c),l=await on(e,t);if(M(l))return l;let d=await Qe(e,t);if(M(d))return d;let u=await F(e,"CHERRY_PICK_HEAD");u&&(l=(await j(e,u)).author);let m=Ht(s),h=await mt(e,a,[c],l,d,m);await Mt(e),await Dt(e);let p=await J(e),g=fe(m),w=p?.type==="symbolic"?p.target:"HEAD";await re(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let y=p?.type==="symbolic"?Re(p.target):"detached HEAD",x=await cn(e,f.tree,a,l,d,l.timestamp!==d.timestamp||l.timezone!==d.timezone);return{stdout:`${vt(y,h,s)}
|
|
658
|
+
${x}`,stderr:"",exitCode:0}}function cg(e,t,n){let r=fe(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
|
|
659
659
|
|
|
660
660
|
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
|
|
661
661
|
changes made to ${c}`}return a+=`.
|
|
662
|
-
`,a}se();
|
|
662
|
+
`,a}se();Pe();oe();le();ue();Yn();Te();function Nl(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[q.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:v().describe("Only remove from the index"),recursive:v().alias("r").describe("Allow recursive removal when a directory name is given"),force:v().alias("f").describe("Override the up-to-date check"),dryRun:v().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return L("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,u=await t?.hooks?.preRm?.({repo:s,paths:c,cached:f,recursive:l,force:d});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await K(s),h=[],p=ut(s,r.cwd);for(let y of c){if(er(y)){let E=[Ue(y,p)],R=m.entries.filter(P=>ye(E,P.path));if(R.length===0)return I(`pathspec '${y}' did not match any files`);for(let P of R)h.push(P.path);continue}let x=Ot(r.cwd,y),b=ct(a,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return I(`'${y}' is outside repository at '${a}'`);if(await r.fs.exists(x)&&!(await ft(r.fs,x)).isSymbolicLink&&(await ft(r.fs,x)).isDirectory){if(!l)return I(`not removing '${b}' recursively without -r`);let E=b===""?"":`${b}/`,R=m.entries.filter(P=>E===""||P.path.startsWith(E));if(R.length===0)return I(`pathspec '${y}' did not match any files`);for(let P of R)h.push(P.path)}else{if(!m.entries.some(R=>R.path===b))return I(`pathspec '${y}' did not match any files`);h.push(b)}}if(!d){let y=await fg(s,m,h,f);if(y)return y}if(n.dryRun){let y=h.map(b=>`rm '${b}'`);return{stdout:y.length>0?`${y.join(`
|
|
663
663
|
`)}
|
|
664
|
-
`:"",stderr:"",exitCode:0}}let g=[];for(let y of h){if(m=it(m,y),!f){let
|
|
664
|
+
`:"",stderr:"",exitCode:0}}let g=[];for(let y of h){if(m=it(m,y),!f){let x=S(a,y);await ft(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}g.push(`rm '${y}'`)}await ie(s,m);let w=g.length>0?`${g.join(`
|
|
665
665
|
`)}
|
|
666
|
-
`:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function
|
|
667
|
-
`),l=i.length===1?"the following file has":"the following files have";return
|
|
666
|
+
`:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function fg(e,t,n,r){let o=await Z(e),s=new Map;if(o){let f=await j(e,o),l=await Ve(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(h=>h.path===f&&h.stage===0);if(!l)continue;let u=s.get(f)!==l.hash,m=!1;if(e.workTree){let h=S(e.workTree,f),p=!1;try{await ft(e.fs,h),p=!0}catch{p=!1}p&&(m=await Tn(e.fs,h)!==l.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
|
|
667
|
+
`),l=i.length===1?"the following file has":"the following files have";return L(`error: ${l} staged content different from both the
|
|
668
668
|
file and the HEAD:
|
|
669
669
|
${f}
|
|
670
670
|
(use -f to force removal)
|
|
671
671
|
`)}if(a.length>0){let f=a.map(d=>` ${d}`).join(`
|
|
672
|
-
`),l=a.length===1?"the following file has":"the following files have";return
|
|
672
|
+
`),l=a.length===1?"the following file has":"the following files have";return L(`error: ${l} changes staged in the index:
|
|
673
673
|
${f}
|
|
674
674
|
(use --cached to keep the file, or -f to force removal)
|
|
675
675
|
`)}if(c.length>0){let f=c.map(d=>` ${d}`).join(`
|
|
676
|
-
`),l=c.length===1?"the following file has":"the following files have";return
|
|
676
|
+
`),l=c.length===1?"the following file has":"the following files have";return L(`error: ${l} local modifications:
|
|
677
677
|
${f}
|
|
678
678
|
(use --cached to keep the file, or -f to force removal)
|
|
679
|
-
`)}return null}se();oe();mn();Ls();le();
|
|
680
|
-
`))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await
|
|
679
|
+
`)}return null}se();oe();mn();Ls();le();Te();var ca=new TextDecoder;function Fl(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=Gs(a);if(c)return lg(s,c.rev,c.path);if(a==="HEAD"){let d=await Ze(s);if(M(d))return d}let f=await Tt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await we(s,f);switch(l.type){case"commit":{let d=await j(s,f);return{stdout:await Ul(s,f,d),stderr:"",exitCode:0}}case"tag":{let d=await mc(s,f);return{stdout:await dg(s,d),stderr:"",exitCode:0}}case"tree":{let d=vn(l.content);return{stdout:Bl(d),stderr:"",exitCode:0}}case"blob":return{stdout:ca.decode(l.content),stderr:"",exitCode:0}}}})}async function lg(e,t,n){let r=await ve(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await ce(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=S(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return I(f)}let c=await we(e,a.hash);if(c.type==="blob")return{stdout:ca.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=vn(c.content);return{stdout:Bl(f),stderr:"",exitCode:0}}return{stdout:ca.decode(c.content),stderr:"",exitCode:0}}async function Ul(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(i=>Y(i)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${Lt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
|
|
680
|
+
`))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await j(e,n.parents[0])).tree:null,i=await We(e,s,n.tree),{remaining:a,renames:c}=await nt(e,i),f=await hg(e,a,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await pg(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
|
|
681
681
|
`)}
|
|
682
|
-
`}async function
|
|
683
|
-
`))n.push(` ${o}`);if(t.objectType==="commit"){let o=await
|
|
682
|
+
`}async function dg(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${Lt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
|
|
683
|
+
`))n.push(` ${o}`);if(t.objectType==="commit"){let o=await j(e,t.object),s=await Ul(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
|
|
684
684
|
`)}
|
|
685
|
-
`}function
|
|
685
|
+
`}function Bl(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(`
|
|
686
686
|
`)}
|
|
687
|
-
`:""}async function
|
|
688
|
-
`,E=tn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),
|
|
689
|
-
`,
|
|
687
|
+
`:""}async function ug(e,t){let n=t.oldHash?await ae(e,t.oldHash):"",r=t.newHash?await ae(e,t.newHash):"";return xt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function mg(e,t){let n=t.oldHash?await ae(e,t.oldHash):"",r=t.newHash?await ae(e,t.newHash):"";return xt({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 hg(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 mg(e,s.entry):o+=await ug(e,s.entry);return o}async function pg(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await j(e,a);return ce(e,c.tree)})),r=await ce(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(d=>(d.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await gg(e,a,n,r);return i}async function gg(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),l=await Promise.all(c.map(async u=>u?await ae(e,u):"")),d=i?await ae(e,i):"";return Co({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}se();Pe();oe();ue();se();xn();Pe();oe();dn();le();Fe();ue();Te();sn();tt();var Yt="refs/stash";function la(e,t){return Oe(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Wl(e){let t=await Je(e,Yt),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 Tr(e,t){let n=await Je(e,Yt);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 ql(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Z(e);if(!s)return null;let i=await j(e,s),a=await K(e),c=je(a),f=await Ge(e,c),l=await We(e,i.tree,f),d=new Map(c.map(_=>[_.path,_])),u=await et(e,o,"",{skipIgnore:!0}),m=!1;for(let _ of u){let U=d.get(_);if(!U)continue;let V=S(o,_),be=await e.fs.readFileBuffer(V);if(await yt("blob",be)!==U.hash){m=!0;break}}if(!m)for(let[_]of d){let U=S(o,_);if(!await e.fs.exists(U)){m=!0;break}}let h=[];if(r?.includeUntracked){let _=await et(e,o,"");for(let U of _)d.has(U)||h.push(U)}if(l.length===0&&!m&&h.length===0)return null;let p=await Os(e,t),g=await Mr(e,t),w=await J(e),y=w?.type==="symbolic"?Re(w.target):"(no branch)",x=Y(s),b=fe(i.message),k=`index on ${y}: ${x} ${b}
|
|
688
|
+
`,E=tn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),R=await $e(e,"commit",E),P=await ce(e,i.tree),C=[],T=new Set;for(let _ of u){let U=d.get(_),V=P.get(_);if(!U&&!V)continue;let be=S(o,_),Le=await e.fs.readFileBuffer(be),ot=await $e(e,"blob",Le),me=U?U.mode:parseInt(V?.mode??"100644",8);C.push({path:_,mode:me,hash:ot,stage:0,stat:Ie()}),T.add(_)}for(let[_,U]of d)T.has(_)||P.has(_)||C.push({path:_,mode:U.mode,hash:U.hash,stage:0,stat:Ie()});let D=await Ge(e,C),O=null;if(r?.includeUntracked){let _=[];for(let Le of h){let ot=S(o,Le),me=await e.fs.readFileBuffer(ot),xe=await $e(e,"blob",me);_.push({path:Le,mode:33188,hash:xe,stage:0,stat:Ie()})}let U=await Ge(e,_),V=`untracked files on ${y}: ${x} ${b}
|
|
689
|
+
`,be=tn({type:"commit",tree:U,parents:[],author:p,committer:g,message:V});O=await $e(e,"commit",be)}let H=n?`On ${y}: ${n}`:`WIP on ${y}: ${x} ${b}`,G=[s,R];O&&G.push(O);let A=tn({type:"commit",tree:D,parents:G,author:p,committer:g,message:H}),$=await $e(e,"commit",A),N=await Tr(e,0)??te;await Ke(e,Yt,{oldHash:N,newHash:$,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:H.trimEnd()}),await X(e,Yt,$);let B=await pn(e,i.tree,a);await ie(e,{version:2,entries:B.newEntries}),await De(e,B.worktreeOps),(await J(e))?.type==="symbolic"&&await re(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let _ of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await de(e,_);for(let _ of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let U=S(e.gitDir,_);await e.fs.exists(U)&&await e.fs.rm(U)}if(h.length>0)for(let _ of h){if(P.has(_))continue;let U=S(o,_);await e.fs.exists(U)&&(await e.fs.rm(U),await Jn(e.fs,Zt(U),o))}return $}async function fa(e,t){let n=e.workTree,r=await j(e,t),o=await Ve(e,r.tree),s=[];for(let i of o){let a=S(n,i.path);await e.fs.exists(a)?s.push(i.path):await at(e,i)}return s.length>0?(s.sort(la),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
|
|
690
690
|
`)}
|
|
691
691
|
error: could not restore untracked files from stash
|
|
692
692
|
`,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function da(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
|
|
693
693
|
`,exitCode:128};let n=await Tr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
|
|
694
|
-
`,exitCode:1};if(!await
|
|
694
|
+
`,exitCode:1};if(!await Z(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
|
|
695
695
|
`,exitCode:1};let o=await K(e),s=Ut(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(P=>`${P}: needs merge`).join(`
|
|
696
696
|
`)}
|
|
697
697
|
`,stderr:`error: could not write index
|
|
698
|
-
`,exitCode:1};let i=await
|
|
699
|
-
`,exitCode:1};let c=await
|
|
698
|
+
`,exitCode:1};let i=await j(e,n),a=i.parents[0];if(!a)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
|
|
699
|
+
`,exitCode:1};let c=await j(e,a),f=i.parents[2],l=je(o),d=await Ge(e,l),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let R=await fa(e,f);if(!R.ok)return{...R,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await Nt(e,c.tree,d,i.tree,u),h=await ce(e,d),p=await ce(e,m.resultTree),g=[];for(let[R,P]of p){let C=h.get(R);(!C||C.hash!==P.hash)&&g.push({path:R,type:"checkout",hash:P.hash,mode:parseInt(P.mode,8)})}for(let[R]of h)p.has(R)||g.push({path:R,type:"delete"});let w=new Map(l.map(R=>[R.path,R])),y=[],x=[];for(let R of g){let P=w.get(R.path),C=S(e.workTree,R.path);if(P){if(!await e.fs.exists(C))continue;let T=await e.fs.readFileBuffer(C);await yt("blob",T)!==P.hash&&y.push(R.path)}else R.type==="checkout"&&await e.fs.exists(C)&&x.push(R.path)}if(y.length>0||x.length>0){y.sort(la),x.sort(la);let R="";if(y.length>0&&(R+=`error: Your local changes to the following files would be overwritten by merge:
|
|
700
700
|
${y.map(P=>` ${P}`).join(`
|
|
701
701
|
`)}
|
|
702
702
|
Please commit your changes or stash them before you merge.
|
|
703
|
-
`),
|
|
704
|
-
${
|
|
703
|
+
`),x.length>0&&(R+=`error: The following untracked working tree files would be overwritten by merge:
|
|
704
|
+
${x.map(P=>` ${P}`).join(`
|
|
705
705
|
`)}
|
|
706
706
|
Please move or remove them before you merge.
|
|
707
|
-
`),
|
|
708
|
-
`,f){let P=await fa(e,f);P.ok||(
|
|
707
|
+
`),R+=`Aborting
|
|
708
|
+
`,f){let P=await fa(e,f);P.ok||(R+=P.stderr)}return{ok:!1,stdout:"",stderr:R,exitCode:1}}await De(e,g);let b=new Set(m.conflicts.map(R=>R.path)),k=new Set;for(let R of m.entries)R.stage>0&&k.add(R.path);let E=b.size>0;if(E){let R=[];for(let[P,C]of p){if(b.has(P)||k.has(P))continue;let T=w.get(P);R.push({path:P,mode:parseInt(C.mode,8),hash:C.hash,stage:0,stat:T?.stat??Ie()})}for(let P of m.entries)P.stage>0&&R.push(P);R.sort((P,C)=>Oe(P.path,C.path)||P.stage-C.stage),await ie(e,{version:2,entries:R})}else{let R=[...o.entries],P=new Set(R.map(C=>C.path));for(let[C,T]of p)h.has(C)||P.has(C)||R.push({path:C,mode:parseInt(T.mode,8),hash:T.hash,stage:0,stat:Ie()});R.sort((C,T)=>Oe(C.path,T.path)||C.stage-T.stage),await ie(e,{version:2,entries:R})}if(f){let R=await fa(e,f);if(!R.ok)return{...R,messages:m.messages}}return{ok:!0,hasConflicts:E,messages:m.messages}}async function ua(e,t=0){let n=await Je(e,Yt);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,Yt),await Vr(e,Yt);else{await Sn(e,Yt,n);let o=n[n.length-1];o&&await X(e,Yt,o.newHash)}return null}async function zl(e){await de(e,Yt),await Vr(e,Yt)}Te();function Ho(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 wg(e,t){let n=t.oldHash?await ae(e,t.oldHash):"",r=t.newHash?await ae(e,t.newHash):"";return xt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Wn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function qn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function Vl(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":v().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 W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Kl(s,o.env,r.message,r["include-untracked"]);return await qn(t,s,"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":v().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Kl(s,o.env,r.message,r["include-untracked"]);return await qn(t,s,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"pop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await bg(s,r.stash);return await qn(t,s,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"apply",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await yg(s,r.stash);return await qn(t,s,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"list",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Eg(s);return await qn(t,s,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"drop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await kg(s,r.stash);return await qn(t,s,"drop",a.exitCode===0),a}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"show",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Rg(s,r.stash);return await qn(t,s,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Wn(t,s,"clear",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await xg(s);return await qn(t,s,"clear",a.exitCode===0),a}})}async function Kl(e,t,n,r){if(!await Z(e))return L(`You do not have the initial commit yet
|
|
709
709
|
`);let s=await K(e),i=Ut(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
|
|
710
710
|
`)}
|
|
711
711
|
`,stderr:`error: could not write index
|
|
712
|
-
`,exitCode:1};let a;try{a=await
|
|
712
|
+
`,exitCode:1};let a;try{a=await ql(e,t,n,{includeUntracked:r})}catch(l){return I(l.message)}return a?{stdout:`Saved working directory and index state ${(await j(e,a)).message.trim()}
|
|
713
713
|
`,stderr:"",exitCode:0}:{stdout:`No local changes to save
|
|
714
|
-
`,stderr:"",exitCode:0}}async function
|
|
714
|
+
`,stderr:"",exitCode:0}}async function bg(e,t){let n=Ho(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Tr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await da(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
|
|
715
715
|
`)}
|
|
716
716
|
`:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
|
|
717
717
|
`,stderr:o.stderr,exitCode:o.exitCode};let l=await rt(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
|
|
718
718
|
`,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
|
|
719
719
|
`)}
|
|
720
720
|
`:"",l=await rt(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
|
|
721
|
-
`,stderr:"",exitCode:1}}let s=await ua(e,n);if(s)return
|
|
721
|
+
`,stderr:"",exitCode:1}}let s=await ua(e,n);if(s)return L(s);let i=o.messages.length>0?`${o.messages.join(`
|
|
722
722
|
`)}
|
|
723
723
|
`:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await rt(e);return{stdout:`${i}${c}Dropped ${a} (${r})
|
|
724
|
-
`,stderr:"",exitCode:0}}async function
|
|
724
|
+
`,stderr:"",exitCode:0}}async function yg(e,t){let n=Ho(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await da(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
|
|
725
725
|
`)}
|
|
726
726
|
`:"",c=r.stdout;return c||(c=await rt(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
|
|
727
727
|
`)}
|
|
728
|
-
`:"",s=await rt(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function
|
|
728
|
+
`:"",s=await rt(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Eg(e){let t=await Wl(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
|
|
729
729
|
`)}
|
|
730
|
-
`,stderr:"",exitCode:0}}async function
|
|
731
|
-
`,stderr:"",exitCode:0}}async function
|
|
730
|
+
`,stderr:"",exitCode:0}}async function kg(e,t){let n=Ho(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Tr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await ua(e,n);return o?L(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
|
|
731
|
+
`,stderr:"",exitCode:0}}async function Rg(e,t){let n=Ho(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Tr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await j(e,r),s=o.parents[0];if(!s)return L("error: invalid stash commit (no parent)");let i=await j(e,s),a=await We(e,i.tree,o.tree),c="";for(let f of a)c+=await wg(e,f);return{stdout:c,stderr:"",exitCode:0}}async function xg(e){return await zl(e),{stdout:"",stderr:"",exitCode:0}}se();Pe();ue();tt();function Yl(e,t){e.command("status",{description:"Show the working tree status",options:{short:v().alias("s").describe("Give the output in the short-format"),porcelain:v().describe("Give the output in a machine-parseable format"),branch:v().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await rt(s),stderr:"",exitCode:0};let i=await J(s),a=await Z(s),c;i&&i.type==="symbolic"?c=Re(i.target):c="HEAD detached";let f=await K(s),l=Oi(f),d=await Pi(s,a,f,l),u=await St(s,f),m=[],h=[];for(let y of u)y.status==="untracked"?h.push(y.path):m.push({path:y.path,status:y.status});m.sort((y,x)=>Oe(y.path,x.path));let p=new Set(f.entries.map(y=>y.path)),g=Ii(h,p);return{stdout:Ig(c,d,m,l,g,n.branch),stderr:"",exitCode:0}}})}var Cg={"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 Pg(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Og(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function Ig(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])),l=new Set;for(let u of r)l.add(u.path);for(let u of t)l.add(u.path);for(let u of n)l.add(u.path);let d=[...l].sort();for(let u of d){let m=a.get(u);if(m){let y=Cg[m.status]??"UU";i.push(`${y} ${ps(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?Pg(h.status):" ",w=p?Og(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let y=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,y),b=h.displayPath.slice(y+4);i.push(`${g}${w} ${ps(x)} -> ${ps(b)}`)}else i.push(`${g}${w} ${ps(u)}`)}for(let u of o)i.push(`?? ${ps(u)}`);return i.length===0?"":`${i.join(`
|
|
732
732
|
`)}
|
|
733
|
-
`}function
|
|
734
|
-
Consider "git cherry-pick --quit" or "git worktree add".`):await
|
|
735
|
-
Consider "git merge --quit" or "git worktree add".`):await
|
|
736
|
-
Consider "git revert --quit" or "git worktree add".`):await
|
|
737
|
-
Consider "git rebase --quit" or "git worktree add".`):null}async function Sg(e,t,n){let r=await
|
|
738
|
-
${O}`,exitCode:0}}f=C}let l=await
|
|
739
|
-
`}else r&&(
|
|
733
|
+
`}function ps(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}se();Ne();Pe();oe();Fe();ue();Te();sn();function $g(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??te}function Zl(e,t){e.command("switch",{description:"Switch branches",args:[q.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create: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:v().alias("d").describe("Detach HEAD at named commit"),orphan:Q.string().describe("Create a new orphan branch"),guess:v().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?I("--orphan and -c/-C are incompatible"):n.detach?I("--orphan and --detach are incompatible"):vg(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return I("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await ve(i,l,`invalid reference: ${l}`);return M(d)?d:Tg(i,l,d.hash,r.env,t)}if(n.create||n.forceCreate){let l=n.create||n.forceCreate,d=a??(o.passthrough.length>0?o.passthrough[0]:void 0);return Xl(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return I("missing branch or commit argument");if(a==="-")return Sg(i,r.env,t);let c=`refs/heads/${a}`,f=await F(i,c);if(f)return Jl(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await ao(i,a);if(l)return Xl(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return I(`invalid reference: ${a}`)}})}async function gs(e){return await Ce(e,"CHERRY_PICK_HEAD")?I(`cannot switch branch while cherry-picking
|
|
734
|
+
Consider "git cherry-pick --quit" or "git worktree add".`):await Ce(e,"MERGE_HEAD")?I(`cannot switch branch while merging
|
|
735
|
+
Consider "git merge --quit" or "git worktree add".`):await Ce(e,"REVERT_HEAD")?I(`cannot switch branch while reverting
|
|
736
|
+
Consider "git revert --quit" or "git worktree add".`):await jt(e)?I(`cannot switch branch while rebasing
|
|
737
|
+
Consider "git rebase --quit" or "git worktree add".`):null}async function Sg(e,t,n){let r=await gs(e);if(r)return r;let o=await no(e);return o?Jl(e,o.name,o.refName,o.hash,t,n):I("no previous branch")}async function Xl(e,t,n,r,o,s,i){let a=`refs/heads/${t}`,c=await F(e,a);if(c&&!n)return I(`a branch named '${t}' already exists`);let f;if(r){let C=await ve(e,r,`invalid reference: ${r}`);if(M(C))return C;f=C.hash}else{let C=await Z(e);if(!C){let T=await J(e),D=T?.type==="symbolic"?T.target.replace(/^refs\/heads\//,""):"";n&&c&&await de(e,a),await ze(e,"HEAD",a),await ht(e);let O=await bn(e);return await re(e,o,"HEAD",null,te,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
|
|
738
|
+
${O}`,exitCode:0}}f=C}let l=await gs(e);if(l)return l;let d=await Z(e),u=await K(e);if(r){let C=jn(u);if(C)return C}let m=await j(e,f);if(d&&d!==f){let C=await j(e,d);if(C.tree!==m.tree){let T=await Hn(e,C.tree,m.tree,u);if(!T.success)return T.errorOutput??L("error: checkout would overwrite local changes");u={version:2,entries:T.newEntries},await ie(e,u),await De(e,T.worktreeOps)}}let h=await J(e),p="";h?.type==="direct"&&d&&(p=await oo(e,d,f));let g=$g(h,d);await X(e,a,f),await ze(e,"HEAD",a),await ht(e);let w=await bn(e),y=r??"HEAD";n&&c?c!==f&&await re(e,o,a,c,f,`branch: Reset to ${y}`):await re(e,o,a,null,f,`branch: Created from ${y}`),await re(e,o,"HEAD",d,f,`checkout: moving from ${g} to ${t}`);let x="";if(i){let C=i.replace(/^refs\/remotes\//,"").split("/"),T=C[0]??"",D=`refs/heads/${C.slice(1).join("/")}`,O=await he(e);O[`branch "${t}"`]={...O[`branch "${t}"`],remote:T,merge:D},await Ye(e,O),x=`branch '${t}' set up to track '${T}/${C.slice(1).join("/")}'.
|
|
739
|
+
`}else r&&(x=await io(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:d,newHead:f,isBranchCheckout:!0});let b=n&&c?`Switched to and reset branch '${t}'
|
|
740
740
|
`:`Switched to a new branch '${t}'
|
|
741
|
-
`,k=p+b+w+
|
|
742
|
-
${u}`,exitCode:0}}se();oe();
|
|
743
|
-
`,stderr:"",exitCode:0}):
|
|
744
|
-
`)}if(n.list!==void 0)return
|
|
741
|
+
`,k=p+b+w+x,E="";r&&(E=await sr(e,m.tree,u));let R=await he(e),P=await wn(e,R,t);return P&&(E+=rr(P)),{stdout:E,stderr:k,exitCode:0}}async function Jl(e,t,n,r,o,s){let i=await gs(e);return i||or(e,t,n,r,o,s)}async function Tg(e,t,n,r,o){let s=await gs(e);return s||Gn(e,n,r,o)}async function vg(e,t,n,r){let o=await gs(e);if(o)return o;let s=`refs/heads/${t}`;if(await F(e,s))return I(`a branch named '${t}' already exists`);let a=await K(e),c=jn(a);if(c)return c;let f=await Z(e),l=await J(e),d="";if(l?.type==="direct"&&f&&(d=await $i(e,f)),e.workTree){let m=f?(await j(e,f)).tree:null,h=await Ge(e,[]),p=await Hn(e,m,h,a);if(!p.success)return p.errorOutput??L("error: checkout would overwrite local changes");await De(e,p.worktreeOps),await ie(e,{version:2,entries:p.newEntries})}else await ie(e,ja());await ze(e,"HEAD",s),await ht(e);let u=await bn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:te,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
|
|
742
|
+
${u}`,exitCode:0}}se();oe();qr();ue();_s();function ed(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[q.string().name("name").describe("Tag name to create or delete").optional(),q.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:v().alias("a").describe("Make an annotated tag object"),message:Q.string().alias("m").describe("Tag message"),delete:v().alias("d").describe("Delete a tag"),force:v().alias("f").describe("Replace an existing tag"),list:Q.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.delete){if(!n.name)return I("tag name required");let i=`refs/tags/${n.name}`,a=await F(s,i);return a?(await de(s,i),{stdout:`Deleted tag '${n.name}' (was ${Y(a)})
|
|
743
|
+
`,stderr:"",exitCode:0}):L(`error: tag '${n.name}' not found.
|
|
744
|
+
`)}if(n.list!==void 0)return Ql(s,n.list||void 0);if(n.name){let i=n.commit,a;if(i){let d=await Tt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Z(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await F(s,c)&&!n.force)return I(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return I("no tag message specified (use -m)");let d=await Qe(s,r.env);if(M(d))return d;let u=Ht(n.message),m=dc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:u}),h=await $e(s,"tag",m);await X(s,c,h)}else await X(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Ql(s)}})}async function Ql(e,t){let n=await ge(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=>Xn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
|
|
745
745
|
`)}
|
|
746
|
-
`,stderr:"",exitCode:0}}var
|
|
747
|
-
`,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function
|
|
746
|
+
`,stderr:"",exitCode:0}}var Hg={init:e=>gl(e),clone:(e,t)=>Kf(e,t),fetch:(e,t)=>ll(e,t),pull:(e,t)=>Tl(e,t),push:(e,t)=>vl(e,t),add:(e,t)=>Dc(e,t),blame:(e,t)=>pf(e,t),commit:(e,t)=>Vf(e,t),status:(e,t)=>Yl(e,t),log:(e,t)=>kl(e,t),branch:(e,t)=>wf(e,t),tag:(e,t)=>ed(e,t),checkout:(e,t)=>yf(e,t),diff:(e,t)=>ol(e,t),reset:(e,t)=>Ml(e,t),merge:(e,t)=>Cl(e,t),"cherry-pick":(e,t)=>Af(e,t),revert:(e,t)=>_l(e,t),rebase:(e,t)=>Sl(e,t),mv:(e,t)=>Pl(e,t),rm:(e,t)=>Nl(e,t),remote:(e,t)=>Al(e,t),config:(e,t)=>Qf(e,t),show:(e,t)=>Fl(e,t),stash:(e,t)=>Vl(e,t),"rev-parse":(e,t)=>Ll(e,t),"ls-files":(e,t)=>xl(e,t),clean:(e,t)=>Df(e,t),switch:(e,t)=>Zl(e,t),restore:(e,t)=>Gl(e,t),reflog:(e,t)=>Hl(e,t),repack:(e,t)=>ml(e,t),gc:(e,t)=>hl(e,t),bisect:(e,t)=>ef(e,t)};function td(e){let t=_o("git",{description:"Git command"});for(let n of Object.values(Hg))n(t,e);return t}var Ao=class{name="git";blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.config?{configOverrides:t.config}:{}};this.inner=td(r).toCommand()}exec=async(t,n)=>{let r=Ag(t),o=new Map;if(n.env)for(let[s,i]of Object.entries(n.env))o.set(s,i);return this.execute(r,{fs:n.fs,cwd:n.cwd,env:o,stdin:n.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
|
|
747
|
+
`,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function Ag(e){let t=[],n="",r=0;for(;r<e.length;){let o=e[r];if(o==='"'){for(r++;r<e.length&&e[r]!=='"';){if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];if(s==='"'||s==="\\"){n+=s,r+=2;continue}}n+=e[r],r++}r++}else if(o==="'"){for(r++;r<e.length&&e[r]!=="'";)n+=e[r],r++;r++}else o===" "||o===" "?(n.length>0&&(t.push(n),n=""),r++):(n+=o,r++)}return n.length>0&&t.push(n),t.length>0&&t[0]==="git"&&t.shift(),t}function Dg(e){return new Ao(e)}var nd=new TextEncoder,Mg=new TextDecoder;function fn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function Do(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var ma=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=fn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?nd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=Do(t);n!=="/"&&(this.data.has(n)||(this.ensureParents(n),this.data.set(n,{type:"directory",mode:16877,mtime:new Date})))}resolve(t){let n="",r=new Set;for(let o of fn(t).slice(1).split("/")){n=`${n}/${o}`;let s=0,i=this.data.get(n);for(;i?.type==="symlink"&&s<40;){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);r.add(n);let a=i.target;n=a.startsWith("/")?fn(a):fn(Do(n)+"/"+a),i=this.data.get(n),s++}if(s>=40)throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`)}return n}resolveParent(t){let n=fn(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let o="",s=new Set;for(let i=0;i<r.length-1;i++){o=`${o}/${r[i]}`;let a=this.data.get(o),c=0;for(;a?.type==="symlink"&&c<40;){if(s.has(o))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);s.add(o);let f=a.target;o=f.startsWith("/")?fn(f):fn(Do(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Mg.decode(await this.readFileBuffer(t))}async readFileBuffer(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}async writeFile(t,n){let r=this.resolve(t);this.ensureParents(r),this.data.set(r,{type:"file",content:typeof n=="string"?nd.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=fn(t);if(this.data.has(r)){if(this.data.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let o=Do(r);if(o!=="/"&&!this.data.has(o))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:16877,mtime:new Date})}async readdir(t){let n=this.resolve(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let o=n==="/"?"/":`${n}/`,s=new Set;for(let i of this.data.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&s.add(c)}return[...s].sort()}async rm(t,n){let r=fn(t),o=this.data.get(r);if(!o){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(o.type==="directory"){if(!n?.recursive&&(await this.readdir(r)).length>0)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);let s=r==="/"?"/":`${r}/`;for(let i of[...this.data.keys()])i.startsWith(s)&&this.data.delete(i)}this.data.delete(r)}async readlink(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async symlink(t,n){let r=fn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};$n();export{Ao as Git,ma as MemoryFileSystem,Jm as composeGitHooks,Dg as createGit,Vn as findRepo,ee as isRejection};
|