just-git 1.5.9 → 1.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var zd=Object.defineProperty;var Ms=(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 Re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Kd=(e,t)=>{for(var n in t)zd(e,n,{get:t[n],enumerable:!0})};function Ns(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 v(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Ns(t)}function Mt(...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 Ns(t||".")}function rn(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 Vr(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 rt(e,t){let n=Ns(e),r=Ns(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,h=s.slice(f),u=[];for(let m=0;m<d;m++)u.push("..");for(let m of h)u.push(m);return u.join("/")||"."}var pe=Re(()=>{"use strict"});function ci(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 Xa(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 h=c[f+1];switch(l(),h){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
1
+ var Kd=Object.defineProperty;var js=(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 Re=(e,t)=>()=>(e&&(t=e(e=0)),t);var zd=(e,t)=>{for(var n in t)Kd(e,n,{get:t[n],enumerable:!0})};function _s(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 v(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":_s(t)}function Mt(...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 _s(t||".")}function rn(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 Yr(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 nt(e,t){let n=_s(e),r=_s(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,h=s.slice(f),u=[];for(let m=0;m<d;m++)u.push("..");for(let m of h)u.push(m);return u.join("/")||"."}var me=Re(()=>{"use strict"});function ci(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 Xa(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 h=c[f+1];switch(l(),h){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
2
2
  `;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=h;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 Jd(e){let t={},n=null,r=e.split(`
3
3
  `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=ci(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:h}=Xa(l,r,o);a[f]=d,o+=h}continue}o++}return t}function fi(e){let t={},n=null,r=e.split(`
4
4
  `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=ci(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:h}=Xa(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=h}continue}o++}return t}function li(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`
@@ -8,9 +8,9 @@ var zd=Object.defineProperty;var Ms=(e=>typeof require<"u"?require:typeof Proxy<
8
8
  `),s=ui(o,t,n),i=` ${n} = ${li(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
9
  `)}function eu(e,t,n){let r=e.split(`
10
10
  `),o=ui(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=v(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Jd(n)}async function _s(e){let t=v(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Xe(e,t){let n=v(e.gitDir,"config");await e.fs.writeFile(n,di(t))}async function xe(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}=Yr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function hi(e,t,n){let r=await _s(e),{section:o,key:s}=Yr(t),i=Qd(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Za(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await _s(e);if(o){let i=fi(o),{section:a,key:c}=Yr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function tu(e,t,n,r){let o=e.split(`
11
+ `),found:!0})}async function pe(e){let t=v(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Jd(n)}async function Fs(e){let t=v(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function ze(e,t){let n=v(e.gitDir,"config");await e.fs.writeFile(n,di(t))}async function xe(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await pe(e),{section:s,key:i}=Xr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function hi(e,t,n){let r=await Fs(e),{section:o,key:s}=Xr(t),i=Qd(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Za(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Fs(e);if(o){let i=fi(o),{section:a,key:c}=Xr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function tu(e,t,n,r){let o=e.split(`
12
12
  `),s=ui(o,t,n),i=` ${n} = ${li(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 Ja(e,t,n){let r=await _s(e),{section:o,key:s}=Yr(t),i=tu(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Qa(e,t){let n=await _s(e),{section:r,key:o}=Yr(t),s=eu(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Yr(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 Be=Re(()=>{"use strict";pe()});function Fs(e,t){return ec(e,t,"author")}function Xr(e,t){return ec(e,t,"committer")}async function ec(e,t,n){let r=nu[n],o=e.identityOverride,{timestamp:s,timezone:i}=ru(t.get(r.date));if(o?.locked)return{name:o.name,email:o.email,timestamp:s,timezone:i};let a=t.get(r.name)??await xe(e,"user.name")??o?.name,c=t.get(r.email)??await xe(e,"user.email")??o?.email;if(!a||!c)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
13
+ `)}async function Ja(e,t,n){let r=await Fs(e),{section:o,key:s}=Xr(t),i=tu(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Qa(e,t){let n=await Fs(e),{section:r,key:o}=Xr(t),s=eu(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Xr(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 Be=Re(()=>{"use strict";me()});function Us(e,t){return ec(e,t,"author")}function Zr(e,t){return ec(e,t,"committer")}async function ec(e,t,n){let r=nu[n],o=e.identityOverride,{timestamp:s,timezone:i}=ru(t.get(r.date));if(o?.locked)return{name:o.name,email:o.email,timestamp:s,timezone:i};let a=t.get(r.name)??await xe(e,"user.name")??o?.name,c=t.get(r.email)??await xe(e,"user.email")??o?.email;if(!a||!c)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,99 +18,99 @@ Run
18
18
 
19
19
  git config user.email "you@example.com"
20
20
  git config user.name "Your Name"
21
- `);return{name:a,email:c,timestamp:s,timezone:i}}async function sn(e,t){try{let n=await Xr(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 ru(e){let t={timestamp:Math.floor(Date.now()/1e3),timezone:"+0000"};if(!e)return t;let n=e.trim();if(!n)return t;if(n.startsWith("@")){let s=n.slice(1).trim(),i=parseInt(s,10);if(!Number.isNaN(i))return{timestamp:i,timezone:"+0000"}}if(/^\d+$/.test(n))return{timestamp:parseInt(n,10),timezone:"+0000"};let r=n.match(/^(\d+)\s+([+-]\d{4})$/);if(r)return{timestamp:parseInt(r[1],10),timezone:r[2]};let o=Date.parse(n);return Number.isNaN(o)?t:{timestamp:Math.floor(o/1e3),timezone:su(n)}}function su(e){if(/Z$/i.test(e))return"+0000";let t=e.match(/([+-])(\d{2}):(\d{2})$/);if(t)return`${t[1]}${t[2]}${t[3]}`;let n=e.match(/([+-]\d{4})$/);return n?n[1]:"+0000"}var nu,Hn=Re(()=>{"use strict";Be();nu={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 An(e){let t="";for(let n=0;n<20;n++)t+=tc[e[n]];return t}function Zr(e,t){let n="";for(let r=0;r<20;r++)n+=tc[e[t+r]];return n}function jt(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,tc,pt=Re(()=>{"use strict";te="0000000000000000000000000000000000000000",tc=(()=>{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 nc(e){return e.length===4&&e.toLowerCase()===".git"}function rr(e){if(e.length===0||e.includes("\0")||e.charCodeAt(0)===47||e.charCodeAt(e.length-1)===47)return!1;let t=e.split("/");for(let n of t)if(n.length===0||n==="."||n===".."||nc(n))return!1;return!0}function Us(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function rc(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||nc(n))return!1;return!0}var Bs=Re(()=>{"use strict"});function mi(e){return typeof e=="string"?ou.encode(e):e}function iu(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(mi(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Ms(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(mi(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(mi(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 An(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 Mn(e){return sc().update(e).hex()}var ou,sc,Dn,sr=Re(()=>{"use strict";pt();ou=new TextEncoder;sc=iu(),Dn=sc});async function z(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:pi,entries:[]};let n=await e.fs.readFileBuffer(t);return au(n)}async function ae(e,t){let n=v(e.gitDir,"index"),r=await cu(t);await e.fs.writeFile(n,r)}function Pt(e,t){if(!rr(t.path))throw new Error(`refusing to add unsafe path to index: '${t.path}'`);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(gi),{...e,entries:n}}function ft(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Ws(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Gt(e){return e.entries.some(t=>t.stage>0)}function Kt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ne(e){return e.entries.filter(t=>t.stage===0)}function ic(){return{version:pi,entries:[]}}function qs(e){let t=[...e].sort(gi);return{version:pi,entries:t}}function ve(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function au(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==oc)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),h=An(d);n+=20;let u=t.getUint16(n);n+=2;let m=u>>12&3,p=u&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let R=n;for(;R<e.byteLength&&e[R]!==0;)R++;w=new TextDecoder().decode(e.subarray(n,R)),g=R-n}let b=62+g+1,k=Math.ceil(b/8)*8;n=c+k,i.push({path:w,mode:l,hash:h,stage:m,stat:f})}return{version:o,entries:i}}async function cu(e){let t=new TextEncoder,n=[...e.entries].sort(gi),r=[],o=12;for(let h of n){let u=t.encode(h.path);r.push(u);let m=62+u.byteLength+1;o+=Math.ceil(m/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,oc),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let h=0;h<n.length;h++){let u=n[h],m=r[h],p=c;a.setUint32(c,u.stat.ctimeSeconds),a.setUint32(c+4,u.stat.ctimeNanoseconds),a.setUint32(c+8,u.stat.mtimeSeconds),a.setUint32(c+12,u.stat.mtimeNanoseconds),a.setUint32(c+16,u.stat.dev),a.setUint32(c+20,u.stat.ino),a.setUint32(c+24,u.mode),a.setUint32(c+28,u.stat.uid),a.setUint32(c+32,u.stat.gid),a.setUint32(c+36,u.stat.size),c+=40;let g=jt(u.hash);i.set(g,c),c+=20;let w=Math.min(m.byteLength,4095),b=(u.stage&3)<<12|w;a.setUint16(c,b),c+=2,i.set(m,c),c+=m.byteLength,i[c]=0,c+=1;let k=62+m.byteLength+1,R=Math.ceil(k/8)*8;c=p+R}let f=i.subarray(0,c),l=await Mn(f),d=jt(l);return i.set(d,c),i}function gi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var oc,pi,Ce=Re(()=>{"use strict";pt();Bs();pe();sr();oc=1145655875,pi=2});var fu,zs,ac=Re(()=>{"use strict";fu=new Set(["tree","commit","tag"]),zs=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(!fu.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 wi(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=cc[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var cc,fc=Re(()=>{"use strict";cc=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;cc[e]=t}});function bc(e){let t=wc(e);return gc(e.subarray(t,-4),{i:2})}function ki(e){let t=wc(e),n={i:2},r=gc(e.subarray(t),n),o=pc(n.p);return{result:r,bytesConsumed:t+o+4}}var Yt,xr,lu,lc,dc,du,uc,hc,uu,Ei,Jr,Qr,mc,hu,mu,bi,Vt,yi,pc,pu,on,gc,wc,yc=Re(()=>{"use strict";Yt=Uint8Array,xr=Uint16Array,lu=Int32Array,lc=new Yt([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]),dc=new Yt([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]),du=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uc=(e,t)=>{let n=new xr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new lu(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:hc}=uc(lc,2);hc[28]=258;({b:uu}=uc(dc,0)),Ei=new xr(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,Ei[e]=((t&65280)>>8|(t&255)<<8)>>1}Jr=(e,t,n)=>{let r=e.length,o=0,s=new xr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new xr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new xr(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 h=d|(1<<l)-1;d<=h;++d)a[Ei[d]>>c]=f}}else for(a=new xr(r),o=0;o<r;++o)e[o]&&(a[o]=Ei[i[e[o]-1]++]>>15-e[o]);return a},Qr=new Yt(288);for(let e=0;e<144;++e)Qr[e]=8;for(let e=144;e<256;++e)Qr[e]=9;for(let e=256;e<280;++e)Qr[e]=7;for(let e=280;e<288;++e)Qr[e]=8;mc=new Yt(32);for(let e=0;e<32;++e)mc[e]=5;hu=Jr(Qr,9,1),mu=Jr(mc,5,1),bi=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Vt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},yi=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},pc=e=>(e+7)/8|0,pu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Yt(e.subarray(t,n))),on=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},gc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Yt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Yt(o*3));let f=b=>{let k=n.length;if(b>k){let R=new Yt(Math.max(k*2,b));R.set(n),n=R}},l=t.f||0,d=t.p||0,h=t.b||0,u=t.l,m=t.d,p=t.m,g=t.n,w=o*8;do{if(!u){l=Vt(e,d,1);let C=Vt(e,d+1,3);if(d+=3,C)if(C==1)u=hu,m=mu,p=9,g=5;else if(C==2){let E=Vt(e,d,31)+257,y=Vt(e,d+10,15)+4,x=E+Vt(e,d+5,31)+1;d+=14;let $=new Yt(x),A=new Yt(19);for(let I=0;I<y;++I)A[du[I]]=Vt(e,d+I*3,7);d+=y*3;let P=bi(A),O=(1<<P)-1,D=Jr(A,P,1);for(let I=0;I<x;){let H=D[Vt(e,d,O)];d+=H&15;let G=H>>4;if(G<16)$[I++]=G;else{let F=0,U=0;for(G==16?(U=3+Vt(e,d,3),d+=2,F=$[I-1]):G==17?(U=3+Vt(e,d,7),d+=3):G==18&&(U=11+Vt(e,d,127),d+=7);U--;)$[I++]=F}}let L=$.subarray(0,E),K=$.subarray(E);p=bi(L),g=bi(K),u=Jr(L,p,1),m=Jr(K,g,1)}else on(1);else{let E=pc(d)+4,y=e[E-4]|e[E-3]<<8,x=E+y;if(x>o){c&&on(0);break}a&&f(h+y),n.set(e.subarray(E,x),h),t.b=h+=y,t.p=d=x*8,t.f=l;continue}if(d>w){c&&on(0);break}}a&&f(h+131072);let b=(1<<p)-1,k=(1<<g)-1,R=d;for(;;R=d){let C=u[yi(e,d)&b],E=C>>4;if(d+=C&15,d>w){c&&on(0);break}if(C||on(2),E<256)n[h++]=E;else if(E==256){R=d,u=null;break}else{let y=E-254;if(E>264){let O=E-257,D=lc[O];y=Vt(e,d,(1<<D)-1)+hc[O],d+=D}let x=m[yi(e,d)&k],$=x>>4;x||on(3),d+=x&15;let A=uu[$];if($>3){let O=dc[$];A+=yi(e,d)&(1<<O)-1,d+=O}if(d>w){c&&on(0);break}a&&f(h+131072);let P=h+y;if(h<A){let O=s-A,D=Math.min(A,P);for(O+h<0&&on(3);h<D;++h)n[h]=r[O+h]}for(;h<P;++h)n[h]=n[h-A]}}t.l=u,t.p=R,t.b=h,t.f=l,u&&(l=1,t.m=p,t.d=m,t.n=g)}while(!l);return h!=n.length&&i?pu(n,0,h):n.subarray(0,h)},wc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&on(0,"invalid zlib data"),e[1]&32&&on(0,"zlib dictionaries are not supported"),2)});async function gu(){let e;if(!(typeof document<"u"))try{e=Ms(["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??ki}}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:bc,inflateWithConsumed:ki}}function Ri(){return wu??=gu()}async function Cr(e){return await(await Ri()).deflateSync(e)}async function Pr(e){return await(await Ri()).inflateSync(e)}async function Ec(e,t){let n=await Ri(),{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 wu,Ks=Re(()=>{"use strict";yc();wu=null});async function Ic(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Vs)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Vs.toString(16)})`);let o=n.getUint32(4);if(o!==Pi)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Zr(e,e.byteLength-20),l=Dn();l.update(e.subarray(0,e.byteLength-20));let d=await l.hex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await yu(e,a);i.push(l),a=l.nextOffset}return(await Eu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function yu(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===es){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===$i&&(c=Zr(e,t),t+=20);let{result:f,bytesConsumed:l}=await Ec(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function Eu(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,i=0){if(i>kc)throw new Error(`delta chain depth ${i} exceeds limit of ${kc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==es&&c.typeNum!==$i){let u=bu[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:u,content:c.inflated,hash:await xi(u,c.inflated)};return r[s]=m,m}if(c.typeNum===es){let u=n.get(c.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await o(u,i+1),p=ts(m.content,c.inflated),g={type:m.type,content:p,hash:await xi(m.type,p)};return r[s]=g,g}let f=await ku(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let u=await t(c.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=ts(l.content,c.inflated),h={type:l.type,content:d,hash:await xi(l.type,d)};return r[s]=h,h}for(let s=0;s<e.length;s++)await o(s);return r}async function ku(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!==es&&s.typeNum!==$i&&(await r(o)).hash===n)return o}}function ts(e,t){let n=0,{value:r,newPos:o}=Rc(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}=Rc(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 Sc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Vs),r.setUint32(4,Pi),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=Oc[o.type],i=await Cr(o.content);t.push(Ci(s,o.content.byteLength)),t.push(i)}return Tc(t)}async function Ys(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Vs),o.setUint32(4,Pi),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=Ci(es,a.delta.byteLength),d=Ru(s-f),h=await Cr(a.delta);t.push(l,d,h),s+=l.byteLength+d.byteLength+h.byteLength}else{let l=Oc[a.type],d=Ci(l,a.content.byteLength),h=await Cr(a.content);t.push(d,h),s+=d.byteLength+h.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Tc(t),entries:i}}async function Tc(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=Dn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(jt(s),r),n}function Ru(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 Ci(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 Rc(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 xi(e,t){let n=xu.encode(`${e} ${t.byteLength}\0`),r=Dn();return r.update(n),r.update(t),r.hex()}var Vs,Pi,xc,Cc,Pc,$c,es,$i,bu,Oc,kc,xu,$r=Re(()=>{"use strict";pt();sr();Ks();Vs=1346454347,Pi=2,xc=1,Cc=2,Pc=3,$c=4,es=6,$i=7,bu={[xc]:"commit",[Cc]:"tree",[Pc]:"blob",[$c]:"tag"},Oc={commit:xc,tree:Cc,blob:Pc,tag:$c};kc=50;xu=new TextEncoder});async function Ac(e,t){let n=[...e].sort((u,m)=>u.hash<m.hash?-1:u.hash>m.hash?1:0),r=n.length,o=[];for(let u of n)u.offset>=2147483648&&o.push(BigInt(u.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,vc),c+=4,a.setUint32(c,Hc),c+=4;let f=new Uint32Array(256);for(let u of n){let m=parseInt(u.hash.slice(0,2),16);for(let p=m;p<256;p++)f[p]++}for(let u=0;u<256;u++)a.setUint32(c,f[u]),c+=4;for(let u of n)i.set(jt(u.hash),c),c+=20;for(let u of n)a.setUint32(c,u.crc),c+=4;let l=0;for(let u of n)u.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,u.offset),c+=4;for(let u of o)a.setBigUint64(c,u),c+=8;i.set(t,c),c+=20;let d=Dn();d.update(i.subarray(0,c));let h=await d.hex();return i.set(jt(h),c),i}async function Dc(e){let n=(await Ic(e)).map(o=>({hash:o.hash,offset:o.offset,crc:wi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ac(n,r)}async function Mc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:wi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ac(n,r)}var vc,Hc,Xt,Xs=Re(()=>{"use strict";pt();sr();fc();$r();vc=4285812579,Hc=2,Xt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==vc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==Hc)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=jt(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=jt(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 h=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,u=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(h!==u){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 Cu,Pu,$u,jc,ns,Gc=Re(()=>{"use strict";pt();Xs();$r();Ks();Cu=6,Pu=7,$u={1:"commit",2:"tree",3:"blob",4:"tag"},jc=50,ns=class{constructor(t,n){this.data=t;this.index=n instanceof Xt?n:new Xt(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,0)}get objectCount(){return this.index.objectCount}async readAt(t,n){if(n>jc)throw new Error(`delta chain depth ${n} exceeds limit of ${jc}`);let r=this.data,o=t,s=r[o++],i=s>>4&7,a=s&15,c=4;for(;s&128;)s=r[o++],a|=(s&127)<<c,c+=7;if(i===Cu){let d=r[o++],h=d&127;for(;d&128;)h+=1,d=r[o++],h=(h<<7)+(d&127);let u=await Pr(r.subarray(o)),m=await this.readAt(t-h,n+1);return{type:m.type,content:ts(m.content,u)}}if(i===Pu){let d=Zr(r,o);o+=20;let h=await Pr(r.subarray(o)),u=this.index.lookup(d);if(u===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(u,n+1);return{type:m.type,content:ts(m.content,h)}}let f=$u[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Pr(r.subarray(o));if(l.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${l.byteLength}, expected ${a}`);return{type:f,content:l}}}});function Ii(e,t){let n=Ou.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Su(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Iu.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 Oi(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var Ou,Iu,Or,Si=Re(()=>{"use strict";pt();ac();Xs();Gc();$r();Ks();pe();sr();Ou=new TextEncoder,Iu=new TextDecoder;Or=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new zs(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=Ii(t,n),o=await Mn(r),s=Oi(this.gitDir,o);if(await this.fs.exists(s))return o;let i=v(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Cr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Oi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Pr(o),i=await Mn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=Su(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let 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(Oi(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 n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let o=n.getUint32(4);if(o!==2)throw new Error(`unsupported pack version: ${o}`);let s=n.getUint32(8);if(s===0)return 0;let i=t.subarray(t.byteLength-20),a=An(i),c=await Mn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=v(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await Dc(t),h=v(this.packDir,`${f}.idx`);await this.fs.writeFile(h,d),this.loadedPackNames.add(f);let u=new Xt(d);return this.packs.push({name:f,index:u,reader:new ns(t,u)}),s}async ingestPackStream(t){let n=[];for await(let o of t)n.push(o);if(n.length===0)return 0;let r=await Sc(n);return this.ingestPack(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=v(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=v(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new ns(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=v(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(v(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Xt(s),reader:null})}}}});function rs(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 ss(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Ti=Re(()=>{"use strict"});function an(e){let t=vu.decode(e),n=t.indexOf(`
21
+ `);return{name:a,email:c,timestamp:s,timezone:i}}async function vn(e,t){try{let n=await Zr(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 ru(e){let t={timestamp:Math.floor(Date.now()/1e3),timezone:"+0000"};if(!e)return t;let n=e.trim();if(!n)return t;if(n.startsWith("@")){let s=n.slice(1).trim(),i=parseInt(s,10);if(!Number.isNaN(i))return{timestamp:i,timezone:"+0000"}}if(/^\d+$/.test(n))return{timestamp:parseInt(n,10),timezone:"+0000"};let r=n.match(/^(\d+)\s+([+-]\d{4})$/);if(r)return{timestamp:parseInt(r[1],10),timezone:r[2]};let o=Date.parse(n);return Number.isNaN(o)?t:{timestamp:Math.floor(o/1e3),timezone:su(n)}}function su(e){if(/Z$/i.test(e))return"+0000";let t=e.match(/([+-])(\d{2}):(\d{2})$/);if(t)return`${t[1]}${t[2]}${t[3]}`;let n=e.match(/([+-]\d{4})$/);return n?n[1]:"+0000"}var nu,nr=Re(()=>{"use strict";Be();nu={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 Hn(e){let t="";for(let n=0;n<20;n++)t+=tc[e[n]];return t}function Jr(e,t){let n="";for(let r=0;r<20;r++)n+=tc[e[t+r]];return n}function jt(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,tc,pt=Re(()=>{"use strict";te="0000000000000000000000000000000000000000",tc=(()=>{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 nc(e){return e.length===4&&e.toLowerCase()===".git"}function rr(e){if(e.length===0||e.includes("\0")||e.charCodeAt(0)===47||e.charCodeAt(e.length-1)===47)return!1;let t=e.split("/");for(let n of t)if(n.length===0||n==="."||n===".."||nc(n))return!1;return!0}function Bs(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function rc(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||nc(n))return!1;return!0}var Ws=Re(()=>{"use strict"});function mi(e){return typeof e=="string"?ou.encode(e):e}function iu(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(mi(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=js(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(mi(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(mi(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 Hn(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 Dn(e){return sc().update(e).hex()}var ou,sc,An,sr=Re(()=>{"use strict";pt();ou=new TextEncoder;sc=iu(),An=sc});async function z(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:pi,entries:[]};let n=await e.fs.readFileBuffer(t);return au(n)}async function ae(e,t){let n=v(e.gitDir,"index"),r=await cu(t);await e.fs.writeFile(n,r)}function Pt(e,t){if(!rr(t.path))throw new Error(`refusing to add unsafe path to index: '${t.path}'`);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(gi),{...e,entries:n}}function ct(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function qs(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Gt(e){return e.entries.some(t=>t.stage>0)}function zt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ne(e){return e.entries.filter(t=>t.stage===0)}function ic(){return{version:pi,entries:[]}}function Ks(e){let t=[...e].sort(gi);return{version:pi,entries:t}}function ve(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function au(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==oc)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),h=Hn(d);n+=20;let u=t.getUint16(n);n+=2;let m=u>>12&3,p=u&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let x=n;for(;x<e.byteLength&&e[x]!==0;)x++;w=new TextDecoder().decode(e.subarray(n,x)),g=x-n}let b=62+g+1,y=Math.ceil(b/8)*8;n=c+y,i.push({path:w,mode:l,hash:h,stage:m,stat:f})}return{version:o,entries:i}}async function cu(e){let t=new TextEncoder,n=[...e.entries].sort(gi),r=[],o=12;for(let h of n){let u=t.encode(h.path);r.push(u);let m=62+u.byteLength+1;o+=Math.ceil(m/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,oc),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let h=0;h<n.length;h++){let u=n[h],m=r[h],p=c;a.setUint32(c,u.stat.ctimeSeconds),a.setUint32(c+4,u.stat.ctimeNanoseconds),a.setUint32(c+8,u.stat.mtimeSeconds),a.setUint32(c+12,u.stat.mtimeNanoseconds),a.setUint32(c+16,u.stat.dev),a.setUint32(c+20,u.stat.ino),a.setUint32(c+24,u.mode),a.setUint32(c+28,u.stat.uid),a.setUint32(c+32,u.stat.gid),a.setUint32(c+36,u.stat.size),c+=40;let g=jt(u.hash);i.set(g,c),c+=20;let w=Math.min(m.byteLength,4095),b=(u.stage&3)<<12|w;a.setUint16(c,b),c+=2,i.set(m,c),c+=m.byteLength,i[c]=0,c+=1;let y=62+m.byteLength+1,x=Math.ceil(y/8)*8;c=p+x}let f=i.subarray(0,c),l=await Dn(f),d=jt(l);return i.set(d,c),i}function gi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var oc,pi,Ce=Re(()=>{"use strict";pt();Ws();me();sr();oc=1145655875,pi=2});var fu,zs,ac=Re(()=>{"use strict";fu=new Set(["tree","commit","tag"]),zs=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(!fu.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 wi(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=cc[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var cc,fc=Re(()=>{"use strict";cc=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;cc[e]=t}});function bc(e){let t=wc(e);return gc(e.subarray(t,-4),{i:2})}function ki(e){let t=wc(e),n={i:2},r=gc(e.subarray(t),n),o=pc(n.p);return{result:r,bytesConsumed:t+o+4}}var Yt,xr,lu,lc,dc,du,uc,hc,uu,Ei,Qr,es,mc,hu,mu,bi,Vt,yi,pc,pu,sn,gc,wc,yc=Re(()=>{"use strict";Yt=Uint8Array,xr=Uint16Array,lu=Int32Array,lc=new Yt([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]),dc=new Yt([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]),du=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uc=(e,t)=>{let n=new xr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new lu(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:hc}=uc(lc,2);hc[28]=258;({b:uu}=uc(dc,0)),Ei=new xr(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,Ei[e]=((t&65280)>>8|(t&255)<<8)>>1}Qr=(e,t,n)=>{let r=e.length,o=0,s=new xr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new xr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new xr(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 h=d|(1<<l)-1;d<=h;++d)a[Ei[d]>>c]=f}}else for(a=new xr(r),o=0;o<r;++o)e[o]&&(a[o]=Ei[i[e[o]-1]++]>>15-e[o]);return a},es=new Yt(288);for(let e=0;e<144;++e)es[e]=8;for(let e=144;e<256;++e)es[e]=9;for(let e=256;e<280;++e)es[e]=7;for(let e=280;e<288;++e)es[e]=8;mc=new Yt(32);for(let e=0;e<32;++e)mc[e]=5;hu=Qr(es,9,1),mu=Qr(mc,5,1),bi=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Vt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},yi=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},pc=e=>(e+7)/8|0,pu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Yt(e.subarray(t,n))),sn=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},gc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Yt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Yt(o*3));let f=b=>{let y=n.length;if(b>y){let x=new Yt(Math.max(y*2,b));x.set(n),n=x}},l=t.f||0,d=t.p||0,h=t.b||0,u=t.l,m=t.d,p=t.m,g=t.n,w=o*8;do{if(!u){l=Vt(e,d,1);let k=Vt(e,d+1,3);if(d+=3,k)if(k==1)u=hu,m=mu,p=9,g=5;else if(k==2){let R=Vt(e,d,31)+257,E=Vt(e,d+10,15)+4,C=R+Vt(e,d+5,31)+1;d+=14;let $=new Yt(C),D=new Yt(19);for(let O=0;O<E;++O)D[du[O]]=Vt(e,d+O*3,7);d+=E*3;let P=bi(D),T=(1<<P)-1,H=Qr(D,P,1);for(let O=0;O<C;){let A=H[Vt(e,d,T)];d+=A&15;let L=A>>4;if(L<16)$[O++]=L;else{let F=0,U=0;for(L==16?(U=3+Vt(e,d,3),d+=2,F=$[O-1]):L==17?(U=3+Vt(e,d,7),d+=3):L==18&&(U=11+Vt(e,d,127),d+=7);U--;)$[O++]=F}}let M=$.subarray(0,R),W=$.subarray(R);p=bi(M),g=bi(W),u=Qr(M,p,1),m=Qr(W,g,1)}else sn(1);else{let R=pc(d)+4,E=e[R-4]|e[R-3]<<8,C=R+E;if(C>o){c&&sn(0);break}a&&f(h+E),n.set(e.subarray(R,C),h),t.b=h+=E,t.p=d=C*8,t.f=l;continue}if(d>w){c&&sn(0);break}}a&&f(h+131072);let b=(1<<p)-1,y=(1<<g)-1,x=d;for(;;x=d){let k=u[yi(e,d)&b],R=k>>4;if(d+=k&15,d>w){c&&sn(0);break}if(k||sn(2),R<256)n[h++]=R;else if(R==256){x=d,u=null;break}else{let E=R-254;if(R>264){let T=R-257,H=lc[T];E=Vt(e,d,(1<<H)-1)+hc[T],d+=H}let C=m[yi(e,d)&y],$=C>>4;C||sn(3),d+=C&15;let D=uu[$];if($>3){let T=dc[$];D+=yi(e,d)&(1<<T)-1,d+=T}if(d>w){c&&sn(0);break}a&&f(h+131072);let P=h+E;if(h<D){let T=s-D,H=Math.min(D,P);for(T+h<0&&sn(3);h<H;++h)n[h]=r[T+h]}for(;h<P;++h)n[h]=n[h-D]}}t.l=u,t.p=x,t.b=h,t.f=l,u&&(l=1,t.m=p,t.d=m,t.n=g)}while(!l);return h!=n.length&&i?pu(n,0,h):n.subarray(0,h)},wc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&sn(0,"invalid zlib data"),e[1]&32&&sn(0,"zlib dictionaries are not supported"),2)});async function gu(){let e;if(!(typeof document<"u"))try{e=js(["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??ki}}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:bc,inflateWithConsumed:ki}}function Ri(){return wu??=gu()}async function Cr(e){return await(await Ri()).deflateSync(e)}async function Pr(e){return await(await Ri()).inflateSync(e)}async function Ec(e,t){let n=await Ri(),{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 wu,Vs=Re(()=>{"use strict";yc();wu=null});async function Ic(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Ys)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Ys.toString(16)})`);let o=n.getUint32(4);if(o!==Pi)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Jr(e,e.byteLength-20),l=An();l.update(e.subarray(0,e.byteLength-20));let d=await l.hex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await yu(e,a);i.push(l),a=l.nextOffset}return(await Eu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function yu(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===ts){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===$i&&(c=Jr(e,t),t+=20);let{result:f,bytesConsumed:l}=await Ec(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function Eu(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,i=0){if(i>kc)throw new Error(`delta chain depth ${i} exceeds limit of ${kc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==ts&&c.typeNum!==$i){let u=bu[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:u,content:c.inflated,hash:await xi(u,c.inflated)};return r[s]=m,m}if(c.typeNum===ts){let u=n.get(c.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await o(u,i+1),p=ns(m.content,c.inflated),g={type:m.type,content:p,hash:await xi(m.type,p)};return r[s]=g,g}let f=await ku(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let u=await t(c.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=ns(l.content,c.inflated),h={type:l.type,content:d,hash:await xi(l.type,d)};return r[s]=h,h}for(let s=0;s<e.length;s++)await o(s);return r}async function ku(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!==ts&&s.typeNum!==$i&&(await r(o)).hash===n)return o}}function ns(e,t){let n=0,{value:r,newPos:o}=Rc(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}=Rc(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 Sc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Ys),r.setUint32(4,Pi),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=Oc[o.type],i=await Cr(o.content);t.push(Ci(s,o.content.byteLength)),t.push(i)}return Tc(t)}async function Xs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Ys),o.setUint32(4,Pi),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=Ci(ts,a.delta.byteLength),d=Ru(s-f),h=await Cr(a.delta);t.push(l,d,h),s+=l.byteLength+d.byteLength+h.byteLength}else{let l=Oc[a.type],d=Ci(l,a.content.byteLength),h=await Cr(a.content);t.push(d,h),s+=d.byteLength+h.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Tc(t),entries:i}}async function Tc(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=An();o.update(n.subarray(0,r));let s=await o.hex();return n.set(jt(s),r),n}function Ru(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 Ci(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 Rc(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 xi(e,t){let n=xu.encode(`${e} ${t.byteLength}\0`),r=An();return r.update(n),r.update(t),r.hex()}var Ys,Pi,xc,Cc,Pc,$c,ts,$i,bu,Oc,kc,xu,$r=Re(()=>{"use strict";pt();sr();Vs();Ys=1346454347,Pi=2,xc=1,Cc=2,Pc=3,$c=4,ts=6,$i=7,bu={[xc]:"commit",[Cc]:"tree",[Pc]:"blob",[$c]:"tag"},Oc={commit:xc,tree:Cc,blob:Pc,tag:$c};kc=50;xu=new TextEncoder});async function Ac(e,t){let n=[...e].sort((u,m)=>u.hash<m.hash?-1:u.hash>m.hash?1:0),r=n.length,o=[];for(let u of n)u.offset>=2147483648&&o.push(BigInt(u.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,vc),c+=4,a.setUint32(c,Hc),c+=4;let f=new Uint32Array(256);for(let u of n){let m=parseInt(u.hash.slice(0,2),16);for(let p=m;p<256;p++)f[p]++}for(let u=0;u<256;u++)a.setUint32(c,f[u]),c+=4;for(let u of n)i.set(jt(u.hash),c),c+=20;for(let u of n)a.setUint32(c,u.crc),c+=4;let l=0;for(let u of n)u.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,u.offset),c+=4;for(let u of o)a.setBigUint64(c,u),c+=8;i.set(t,c),c+=20;let d=An();d.update(i.subarray(0,c));let h=await d.hex();return i.set(jt(h),c),i}async function Dc(e){let n=(await Ic(e)).map(o=>({hash:o.hash,offset:o.offset,crc:wi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ac(n,r)}async function Mc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:wi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ac(n,r)}var vc,Hc,Xt,Zs=Re(()=>{"use strict";pt();sr();fc();$r();vc=4285812579,Hc=2,Xt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==vc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==Hc)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=jt(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=jt(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 h=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,u=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(h!==u){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 Cu,Pu,$u,jc,rs,Gc=Re(()=>{"use strict";pt();Zs();$r();Vs();Cu=6,Pu=7,$u={1:"commit",2:"tree",3:"blob",4:"tag"},jc=50,rs=class{constructor(t,n){this.data=t;this.index=n instanceof Xt?n:new Xt(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,0)}get objectCount(){return this.index.objectCount}async readAt(t,n){if(n>jc)throw new Error(`delta chain depth ${n} exceeds limit of ${jc}`);let r=this.data,o=t,s=r[o++],i=s>>4&7,a=s&15,c=4;for(;s&128;)s=r[o++],a|=(s&127)<<c,c+=7;if(i===Cu){let d=r[o++],h=d&127;for(;d&128;)h+=1,d=r[o++],h=(h<<7)+(d&127);let u=await Pr(r.subarray(o)),m=await this.readAt(t-h,n+1);return{type:m.type,content:ns(m.content,u)}}if(i===Pu){let d=Jr(r,o);o+=20;let h=await Pr(r.subarray(o)),u=this.index.lookup(d);if(u===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(u,n+1);return{type:m.type,content:ns(m.content,h)}}let f=$u[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Pr(r.subarray(o));if(l.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${l.byteLength}, expected ${a}`);return{type:f,content:l}}}});function Ii(e,t){let n=Ou.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Su(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Iu.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 Oi(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var Ou,Iu,Or,Si=Re(()=>{"use strict";pt();ac();Zs();Gc();$r();Vs();me();sr();Ou=new TextEncoder,Iu=new TextDecoder;Or=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new zs(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=Ii(t,n),o=await Dn(r),s=Oi(this.gitDir,o);if(await this.fs.exists(s))return o;let i=v(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Cr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Oi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Pr(o),i=await Dn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=Su(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let 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(Oi(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 n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let o=n.getUint32(4);if(o!==2)throw new Error(`unsupported pack version: ${o}`);let s=n.getUint32(8);if(s===0)return 0;let i=t.subarray(t.byteLength-20),a=Hn(i),c=await Dn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=v(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await Dc(t),h=v(this.packDir,`${f}.idx`);await this.fs.writeFile(h,d),this.loadedPackNames.add(f);let u=new Xt(d);return this.packs.push({name:f,index:u,reader:new rs(t,u)}),s}async ingestPackStream(t){let n=[];for await(let o of t)n.push(o);if(n.length===0)return 0;let r=await Sc(n);return this.ingestPack(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=v(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=v(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new rs(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=v(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(v(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Xt(s),reader:null})}}}});function ss(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 os(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Ti=Re(()=>{"use strict"});function on(e){let t=vu.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),h=f.slice(l+1);switch(d){case"tree":s=h;break;case"parent":i.push(h);break;case"author":a=rs(h);break;case"committer":c=rs(h);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 cn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${ss(e.author)}`),t.push(`committer ${ss(e.committer)}`),t.push(""),t.push(e.message),Tu.encode(t.join(`
25
- `))}var Tu,vu,bn=Re(()=>{"use strict";Ti();Tu=new TextEncoder,vu=new TextDecoder});function Zt(e){let t=Au.decode(e),n=t.indexOf(`
24
+ `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),h=f.slice(l+1);switch(d){case"tree":s=h;break;case"parent":i.push(h);break;case"author":a=ss(h);break;case"committer":c=ss(h);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 an(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${os(e.author)}`),t.push(`committer ${os(e.committer)}`),t.push(""),t.push(e.message),Tu.encode(t.join(`
25
+ `))}var Tu,vu,wn=Re(()=>{"use strict";Ti();Tu=new TextEncoder,vu=new TextDecoder});function Zt(e){let t=Au.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),h=f.slice(l+1);switch(d){case"object":s=h;break;case"type":i=h;break;case"tag":a=h;break;case"tagger":c=rs(h);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 Lc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${ss(e.tagger)}`),t.push(""),t.push(e.message),Hu.encode(t.join(`
29
- `))}var Hu,Au,Ir=Re(()=>{"use strict";Ti();Hu=new TextEncoder,Au=new TextDecoder});async function gt(e,t){return Mn(Ii(e,t))}async function Se(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function ye(e,t){return e.objectStore.read(t)}async function $t(e,t){return e.objectStore.exists(t)}async function Zs(e,t){return e.objectStore.ingestPack(t)}async function Nc(e,t){return e.objectStore.findByPrefix(t)}function He(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 jn(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 re(e,t){let n=await ye(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Du.decode(n.content)}async function Ot(e,t){let n=await ye(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 ye(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return an(n.content)}async function _c(e,t){let n=await ye(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Zt(n.content)}async function Ae(e,t){let n=t;for(let r=0;r<100;r++){let o=await ye(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Zt(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 Du,ie=Re(()=>{"use strict";Si();bn();Ir();sr();Du=new TextDecoder});function Fc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var yn,vi=Re(()=>{"use strict";yn={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function ju(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?Mu[a]:0){case 1:break;case 2:if(r===46)return{len:-1,starConsumed:o};r=a;continue;case 3:if(r===64)return{len:-1,starConsumed:o};r=a;continue;case 4:return{len:-1,starConsumed:o};case 5:if(!n)return{len:-1,starConsumed:o};o=!0,r=a;continue;default:r=a;continue}break}let i=s-t;return i===0?{len:0,starConsumed:o}:e.charCodeAt(t)===46?{len:-1,starConsumed:o}:i>=Hi.length&&e.slice(s-Hi.length,s)===Hi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function os(e,t=0){if(e==="@"||e.length===0)return!1;let n=0,r=0,o=!!(t&2);for(;n<=e.length;){let{len:s,starConsumed:i}=ju(e,n,o);if(s<0||s===0)return!1;i&&(o=!1),r++,n+=s+1}return!(e.charCodeAt(e.length-1)===46||!(t&1)&&r<2)}function En(e){return!e||e.startsWith("-")?!1:os(`refs/heads/${e}`,0)}function Uc(e){return e?os(`refs/tags/${e}`,0):!1}async function Wc(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Bc;r++){let o=await Wc(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 Q(e){return Wc(e,"HEAD")}async function X(e){return B(e,"HEAD")}async function J(e,t,n){let r=e.hooks?await B(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 Js(e,t,n,r){let o=n.find(f=>f.name==="HEAD");if(!o)return;let s;if(r?.startsWith("refs/heads/"))s=r.slice(11);else{let f=n.find(l=>l.name.startsWith("refs/heads/")&&l.hash===o.hash);if(!f)return;s=f.name.slice(11)}let i=`refs/remotes/${t}/HEAD`;if(await e.refStore.readRef(i))return;let c=`refs/remotes/${t}/${s}`;await e.refStore.writeRef(i,{type:"symbolic",target:c})}async function me(e,t){let n=e.hooks?await B(e,t):null;await e.refStore.deleteRef(t),await as(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 Pe(e){return e.replace("refs/heads/","")}function Ln(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}async function Nn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await J(e,n.target,t):await J(e,"HEAD",t)}async function qc(e){if(e.refStore&&!(e.refStore instanceof Gn))return;let t=await ge(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"],r=[];for(let s of t){let i=v(e.gitDir,s.name);if(!(await e.fs.exists(i)&&(await e.fs.readFile(i)).trim().startsWith("ref: "))&&(r.push(s.name),n.push(`${s.hash} ${s.name}`),s.name.startsWith("refs/tags/")))try{let a=await ye(e,s.hash);if(a.type==="tag"){let c=Zt(a.content).object;for(let f=0;f<100;f++){let l=await ye(e,c);if(l.type!=="tag")break;c=Zt(l.content).object}n.push(`^${c}`)}}catch{}}await e.fs.writeFile(v(e.gitDir,"packed-refs"),`${n.join(`
28
+ `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),h=f.slice(l+1);switch(d){case"object":s=h;break;case"type":i=h;break;case"tag":a=h;break;case"tagger":c=ss(h);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 Lc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${os(e.tagger)}`),t.push(""),t.push(e.message),Hu.encode(t.join(`
29
+ `))}var Hu,Au,Ir=Re(()=>{"use strict";Ti();Hu=new TextEncoder,Au=new TextDecoder});async function gt(e,t){return Dn(Ii(e,t))}async function Se(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function ye(e,t){return e.objectStore.read(t)}async function $t(e,t){return e.objectStore.exists(t)}async function Js(e,t){return e.objectStore.ingestPack(t)}async function Nc(e,t){return e.objectStore.findByPrefix(t)}function He(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 Mn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function se(e,t){let n=await ye(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Du.decode(n.content)}async function Ot(e,t){let n=await ye(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function G(e,t){let n=await ye(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return on(n.content)}async function _c(e,t){let n=await ye(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Zt(n.content)}async function Ae(e,t){let n=t;for(let r=0;r<100;r++){let o=await ye(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Zt(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 Du,ie=Re(()=>{"use strict";Si();wn();Ir();sr();Du=new TextDecoder});function Fc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var bn,vi=Re(()=>{"use strict";bn={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function ju(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?Mu[a]:0){case 1:break;case 2:if(r===46)return{len:-1,starConsumed:o};r=a;continue;case 3:if(r===64)return{len:-1,starConsumed:o};r=a;continue;case 4:return{len:-1,starConsumed:o};case 5:if(!n)return{len:-1,starConsumed:o};o=!0,r=a;continue;default:r=a;continue}break}let i=s-t;return i===0?{len:0,starConsumed:o}:e.charCodeAt(t)===46?{len:-1,starConsumed:o}:i>=Hi.length&&e.slice(s-Hi.length,s)===Hi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function is(e,t=0){if(e==="@"||e.length===0)return!1;let n=0,r=0,o=!!(t&2);for(;n<=e.length;){let{len:s,starConsumed:i}=ju(e,n,o);if(s<0||s===0)return!1;i&&(o=!1),r++,n+=s+1}return!(e.charCodeAt(e.length-1)===46||!(t&1)&&r<2)}function yn(e){return!e||e.startsWith("-")?!1:is(`refs/heads/${e}`,0)}function Uc(e){return e?is(`refs/tags/${e}`,0):!1}async function Wc(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Bc;r++){let o=await Wc(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 Q(e){return Wc(e,"HEAD")}async function X(e){return B(e,"HEAD")}async function J(e,t,n){let r=e.hooks?await B(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 Sr(e,t,n,r){let o=n.find(f=>f.name==="HEAD");if(!o)return;let s;if(r?.startsWith("refs/heads/"))s=r.slice(11);else{let f=n.find(l=>l.name.startsWith("refs/heads/")&&l.hash===o.hash);if(!f)return;s=f.name.slice(11)}let i=`refs/remotes/${t}/HEAD`;if(await e.refStore.readRef(i))return;let c=`refs/remotes/${t}/${s}`;await e.refStore.writeRef(i,{type:"symbolic",target:c})}async function he(e,t){let n=e.hooks?await B(e,t):null;await e.refStore.deleteRef(t),await cs(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 Pe(e){return e.replace("refs/heads/","")}function Gn(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}async function Ln(e,t){let n=await Q(e);n&&n.type==="symbolic"?await J(e,n.target,t):await J(e,"HEAD",t)}async function qc(e){if(e.refStore&&!(e.refStore instanceof jn))return;let t=await ge(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"],r=[];for(let s of t){let i=v(e.gitDir,s.name);if(!(await e.fs.exists(i)&&(await e.fs.readFile(i)).trim().startsWith("ref: "))&&(r.push(s.name),n.push(`${s.hash} ${s.name}`),s.name.startsWith("refs/tags/")))try{let a=await ye(e,s.hash);if(a.type==="tag"){let c=Zt(a.content).object;for(let f=0;f<100;f++){let l=await ye(e,c);if(l.type!=="tag")break;c=Zt(l.content).object}n.push(`^${c}`)}}catch{}}await e.fs.writeFile(v(e.gitDir,"packed-refs"),`${n.join(`
30
30
  `)}
31
- `);for(let s of r){let i=v(e.gitDir,s);await e.fs.exists(i)&&await e.fs.rm(i)}await zc(e,v(e.gitDir,"refs"));let o=v(e.gitDir,"refs");await e.fs.mkdir(o,{recursive:!0}),await e.fs.mkdir(v(o,"heads"),{recursive:!0}),await e.fs.mkdir(v(o,"tags"),{recursive:!0})}async function zc(e,t){if(e.refStore&&!(e.refStore instanceof Gn)||!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 zc(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Hi,Mu,Ai,Bc,Gn,we=Re(()=>{"use strict";ie();Ir();pe();ze();_n();vi();Hi=".lock",Mu=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];Ai="ref: ",Bc=10,Gn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=v(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Ai)?{type:"symbolic",target:s.slice(Ai.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=Fc(n),o=v(this.gitDir,t);await is(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Ai}${r.target}
31
+ `);for(let s of r){let i=v(e.gitDir,s);await e.fs.exists(i)&&await e.fs.rm(i)}await Kc(e,v(e.gitDir,"refs"));let o=v(e.gitDir,"refs");await e.fs.mkdir(o,{recursive:!0}),await e.fs.mkdir(v(o,"heads"),{recursive:!0}),await e.fs.mkdir(v(o,"tags"),{recursive:!0})}async function Kc(e,t){if(e.refStore&&!(e.refStore instanceof jn)||!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 Kc(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Hi,Mu,Ai,Bc,jn,we=Re(()=>{"use strict";ie();Ir();me();Ke();Nn();vi();Hi=".lock",Mu=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];Ai="ref: ",Bc=10,jn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=v(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Ai)?{type:"symbolic",target:s.slice(Ai.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=Fc(n),o=v(this.gitDir,t);await as(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Ai}${r.target}
32
32
  `):await this.fs.writeFile(o,`${r.hash}
33
33
  `)}async deleteRef(t){let n=v(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=v(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<Bc;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=v(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
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=v(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=v(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 or(e,t){let n=t;for(;;){let r=v(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Or(e,r),refStore:new Gn(e,r)};if(await Gu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Or(e,n),refStore:new Gn(e,n)};let o=Lu(n);if(o===n)return null;n=o}}async function Gu(e,t){let n=v(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=v(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 Qs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:v(t,".git"),i=r?null:t,a=v(s,"HEAD"),c=await e.exists(a);await e.mkdir(v(s,"objects"),{recursive:!0}),await e.mkdir(v(s,"refs","heads"),{recursive:!0}),await e.mkdir(v(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Or(e,s),refStore:new Gn(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(v(s,"config"),di(l))}return{ctx:f,reinit:c}}async function is(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Lu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var _n=Re(()=>{"use strict";Be();Si();pe();we()});function eo(e,t){return v(e.gitDir,"logs",t)}function Nu(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),h=d.indexOf(" ");if(h<0)return null;let u=parseInt(d.slice(0,h),10),m=d.slice(h+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:u,tz:m,message:r}}async function et(e,t){let n=eo(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=Nu(s);i&&o.push(i)}return o}function Kc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Fn(e,t,n){let r=eo(e,t);if(await is(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Kc).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=v(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 or(e,t){let n=t;for(;;){let r=v(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Or(e,r),refStore:new jn(e,r)};if(await Gu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Or(e,n),refStore:new jn(e,n)};let o=Lu(n);if(o===n)return null;n=o}}async function Gu(e,t){let n=v(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=v(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 Qs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:v(t,".git"),i=r?null:t,a=v(s,"HEAD"),c=await e.exists(a);await e.mkdir(v(s,"objects"),{recursive:!0}),await e.mkdir(v(s,"refs","heads"),{recursive:!0}),await e.mkdir(v(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Or(e,s),refStore:new jn(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(v(s,"config"),di(l))}return{ctx:f,reinit:c}}async function as(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Lu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Nn=Re(()=>{"use strict";Be();Si();me();we()});function eo(e,t){return v(e.gitDir,"logs",t)}function Nu(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),h=d.indexOf(" ");if(h<0)return null;let u=parseInt(d.slice(0,h),10),m=d.slice(h+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:u,tz:m,message:r}}async function Qe(e,t){let n=eo(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=Nu(s);i&&o.push(i)}return o}function zc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function _n(e,t,n){let r=eo(e,t);if(await as(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(zc).join(`
38
38
  `)}
39
- `;await e.fs.writeFile(r,o)}async function Je(e,t,n){let r=eo(e,t);await is(e.fs,r);let o=`${Kc(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 as(e,t){let n=eo(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function se(e,t,n,r,o,s,i=!1){let a=await sn(e,t),c={oldHash:r??te,newHash:o,...a,message:s};await Je(e,n,c),i&&n!=="HEAD"&&await Je(e,"HEAD",c)}var ze=Re(()=>{"use strict";pt();Hn();pe();_n();pt()});function _u(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 Fu(e,t){let n=await Nc(e,t);if(n.length===0)return null;if(n.length>1)throw new Di(t);return n[0]}async function Uu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Vc.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await $t(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Fu(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await B(e,t);if(s)return s}let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);if(r)return r;let o=await B(e,`refs/remotes/${t}`);return o||null}function Bu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Vc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Wu(e,t,n){let r=Bu(t),o=await et(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 qu(e,t,n){if(n===""||n==="commit")try{return await Ae(e,t)}catch{return null}if(n==="tree"){let o;try{o=await Ae(e,t)}catch{return null}return(await j(e,o)).tree}return(await ye(e,t)).type!==n?null:t}async function zu(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await Ae(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await qu(e,r,s.target)}else if(s.type==="tilde")for(let i=0;i<s.n;i++){if(!r)return null;let a=await j(e,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(s.n===0)continue;if(!r)return null;let i=await j(e,r);if(s.n>i.parents.length||(r=i.parents[s.n-1]??null,!r))return null}return r}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=_u(t),s;return r!==void 0?s=await Wu(e,n,r):s=await Uu(e,n),s?zu(e,s,o):null}function to(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Vc,Di,fn=Re(()=>{"use strict";ie();ze();we();Vc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Di=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function mt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function kn(e){return typeof e=="string"?e==="120000":e===40960}function Un(e){return typeof e=="string"?e==="160000":e===57344}async function cs(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Ku.encode(r)}return e.readFileBuffer(t)}async function Bn(e,t){let n=await cs(e,t);return gt("blob",n)}var Ku,Rn=Re(()=>{"use strict";ie();Ku=new TextEncoder});function Xu(e){return e.length===4&&e.toLowerCase()===".git"}function Zu(e,t){if(e.length===0)throw new Error("invalid tree entry: empty name");if(e.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${e}'`);if(e.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(e==="."||e==="..")throw new Error(`invalid tree entry: '${e}'`);if(Xu(e))throw new Error(`invalid tree entry: '${e}'`);if(!Yu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function xn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Yc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Yc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=An(a),f=o.padStart(6,"0");Zu(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Xc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Vu.encode(`${i} ${s.name}\0`),c=jt(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 Vu,Yc,Yu,no=Re(()=>{"use strict";pt();Vu=new TextEncoder,Yc=new TextDecoder,Yu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Jc(e,t,"")}async function Jc(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:Ju(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 Jc(e,a,c);r.push({mode:yn.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===yn.DIRECTORY?`${i.name}/`:i.name,f=a.mode===yn.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Xc({type:"tree",entries:r});return Se(e,"tree",s)}async function qe(e,t,n=""){let r=await ye(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=xn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===yn.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function de(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ke(e,t,n){if(t===n)return[];let r=[];return await Qc(e,t,n,"",r),r.sort((o,s)=>Te(o.path,s.path))}async function Zc(e,t){let n=await ye(e,t);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return xn(n.content).entries}async function Qc(e,t,n,r,o){if(t===n)return;let s=t?await Zc(e,t):[],i=n?await Zc(e,n):[],a=new Map;for(let l of s)a.set(l.name,l);let c=new Map;for(let l of i)c.set(l.name,l);let f=new Set;for(let l of s)f.add(l.name);for(let l of i)f.add(l.name);for(let l of f){let d=a.get(l),h=c.get(l),u=r?`${r}/${l}`:l;if(d&&h){if(d.hash===h.hash&&d.mode===h.mode)continue;let m=d.mode===yn.DIRECTORY,p=h.mode===yn.DIRECTORY;m&&p?await Qc(e,d.hash,h.hash,u,o):m?(await ro(e,d.hash,u,"deleted",o),o.push({path:u,status:"added",newHash:h.hash,newMode:h.mode})):p?(o.push({path:u,status:"deleted",oldHash:d.hash,oldMode:d.mode}),await ro(e,h.hash,u,"added",o)):o.push({path:u,status:"modified",oldHash:d.hash,newHash:h.hash,oldMode:d.mode,newMode:h.mode})}else if(d)d.mode===yn.DIRECTORY?await ro(e,d.hash,u,"deleted",o):o.push({path:u,status:"deleted",oldHash:d.hash,oldMode:d.mode});else{let m=h;m.mode===yn.DIRECTORY?await ro(e,m.hash,u,"added",o):o.push({path:u,status:"added",newHash:m.hash,newMode:m.mode})}}}async function ro(e,t,n,r,o){let s=await qe(e,t,n);for(let i of s)r==="added"?o.push({path:i.path,status:"added",newHash:i.hash,newMode:i.mode}):o.push({path:i.path,status:"deleted",oldHash:i.hash,oldMode:i.mode})}function Ju(e){return e.toString(8).padStart(6,"0")}var De=Re(()=>{"use strict";oe();ie();no();vi()});function ef(e){return/^[a-zA-Z0-9]$/.test(e)}function Qu(e){return/^[a-zA-Z]$/.test(e)}function eh(e){return e>="0"&&e<="9"}function Mi(e){return e>="A"&&e<="Z"}function ji(e){return e>="a"&&e<="z"}function tf(e){return/^\s$/.test(e)}function th(e){return e===" "||e===" "}function Li(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function nh(e){return Li(e)&&!tf(e)}function rh(e){return Li(e)&&!ef(e)&&e!==" "}function sh(e){let t=e.charCodeAt(0);return t<32||t===127}function oh(e){return/^[0-9a-fA-F]$/.test(e)}function fs(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Gi(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(!fs(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]==="/"&&Gi(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(!ih(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=Gi(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="",h=!0;for(;t<e.length&&(h||e[t]!=="]");){h=!1;let u=e[t];if(u==="\\"){if(t++,t>=e.length)return-1;u=e[t],fs(c,u,s)&&(l=!0)}else if(u==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,u=e[t],u==="\\"){if(t++,t>=e.length)return-1;u=e[t]}let m=d,p=u;if(c>=m&&c<=p&&(l=!0),s){if(ji(c)){let g=c.toUpperCase();g>=m&&g<=p&&(l=!0)}else if(Mi(c)){let g=c.toLowerCase();g>=m&&g<=p&&(l=!0)}}u=""}else if(u==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let m=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-m-1;if(p<0||e[t-1]!==":")t=m-2,u="[",fs(c,u,s)&&(l=!0);else{let g=e.slice(m,m+p);ah(g,c,s)&&(l=!0),u=""}}else fs(c,u,s)&&(l=!0);d=u,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!fs(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function ih(e){return e==="*"||e==="?"||e==="["||e==="\\"}function ah(e,t,n){switch(e){case"alnum":return ef(t);case"alpha":return Qu(t);case"blank":return th(t);case"cntrl":return sh(t);case"digit":return eh(t);case"graph":return nh(t);case"lower":return ji(t)||n&&Mi(t);case"print":return Li(t);case"punct":return rh(t);case"space":return tf(t);case"upper":return Mi(t)||n&&ji(t);case"xdigit":return oh(t);default:return!1}}function ln(e,t,n=0){return Gi(e,0,t,0,n)===0?0:1}var ls=Re(()=>{"use strict"});function of(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 ch(e){return of(e)===e.length}function fh(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|=so,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=sf);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=nf);let a=Math.min(of(o),s);return o[0]==="*"&&ch(o.slice(1))&&(r|=rf),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function ds(e,t,n){let r=[];for(let o of e.split(`
41
- `)){let s=fh(o,t);s&&r.push(s)}return{patterns:r,src:n}}function lh(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&rf){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return ln(n,e,2)===0}function dh(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return ln(r,a,2)===0}function Ni(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&sf&&!t)){if(s.flags&nf){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(lh(r,s))return s;continue}if(dh(e,s))return s}}return null}function dn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Ni(t,n,o);if(s)return s.flags&so?"not-ignored":"ignored"}if(e.excludeFile){let r=Ni(t,n,e.excludeFile);if(r)return r.flags&so?"not-ignored":"ignored"}if(e.globalExclude){let r=Ni(t,n,e.globalExclude);if(r)return r.flags&so?"not-ignored":"ignored"}return"undecided"}async function Sr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=ds(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=ds(o,"",r)}catch{}}catch{}return t}function ir(e,t,n,r){let s=ds(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var nf,rf,sf,so,io=Re(()=>{"use strict";Be();pe();ls();nf=1,rf=4,sf=8,so=16});async function wt(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||Un(s.mode))continue;let i=v(e.workTree,s.path),a;try{a=await mt(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 Bn(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 st(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Te(s.path,i.path))}async function lt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!rr(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);if(t.mode!=null&&Un(t.mode)){let s=v(e.workTree,t.path);await e.fs.mkdir(s,{recursive:!0});return}let n=await ye(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=v(e.workTree,t.path);if(!Us(e.workTree,r))throw new Error(`refusing to check out path outside worktree: '${t.path}'`);let o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&kn(t.mode)&&e.fs.symlink){let s=hh.decode(n.content);if(!rc(s))throw new Error(`refusing to create symlink with unsafe target '${s}'`);await mt(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0}),await e.fs.symlink(s,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 af(e,t){let n=await qe(e,t);for(let r of n)await lt(e,r)}async function un(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!rr(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=v(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await mt(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=uh.encode(f),d=await Se(e,"blob",l),h={path:n,mode:40960,hash:d,stage:0,stat:{...ve(),size:l.byteLength}};return{index:Pt(t,h),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Se(e,"blob",s),a=o.mode!=null?mh(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...ve(),size:s.byteLength}};return{index:Pt(t,c),hash:i}}async function st(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Sr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=ir(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=v(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&dn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&dn(s,l,!0)==="ignored")continue;let h=await st(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...h)}else if(d.isFile){if(s&&dn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function mh(e){return e>511?e:e&73?33261:33188}async function ar(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 ar(e,rn(t),n))}var uh,hh,tt=Re(()=>{"use strict";oe();io();Ce();ie();Bs();pe();Rn();De();uh=new TextEncoder,hh=new TextDecoder});function _i(e){return e.existsOnDisk&&e.indexHash===null}async function ph(e,t,n){let r=await Promise.all(t.map(m=>de(e,m.treeHash))),o=new Map,s=new Set;for(let m of n.entries)m.stage===0?o.set(m.path,m):s.add(m.path);let i=e.workTree?new Set(await st(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await st(e,e.workTree,"")):new Set),a),f=new Set;for(let m of r)for(let p of m.keys())f.add(p);let l=new Set;for(let m of n.entries)f.has(m.path)||l.add(m.path);for(let m of i)f.has(m)||l.add(m);let d=Array.from(f).sort().concat(Array.from(l).sort()),h=(m,p)=>r[m]?.get(p),u=[];for(let m of d){let p=null,g=null,w=null,b=null,k=null;if(r.length===1){let O=h(0,m);w=O?.hash??null,k=O?.mode??null}else if(r.length===2){let O=h(0,m),D=h(1,m);g=O?.hash??null,b=O?.mode??null,w=D?.hash??null,k=D?.mode??null}else if(r.length>=3){let O=h(0,m),D=h(1,m),L=h(2,m);p=O?.hash??null,g=D?.hash??null,b=D?.mode??null,w=L?.hash??null,k=L?.mode??null}let C=o.get(m)?.hash??null,E=s.has(m)?1:0,y=i.has(m),x,$=async()=>x!==void 0?x:y?(x=!(await c()).has(m),x):(x=!1,!1),A,P=async()=>{if(A!==void 0)return A;if(!y||!e.workTree)return A=null,null;let O=v(e.workTree,m);try{A=await Bn(e.fs,O)}catch{A=null}return A};u.push({path:m,baseHash:p,headHash:g,remoteHash:w,indexHash:C,indexStage:E,existsOnDisk:y,isIgnoredOnDisk:$,getWorktreeHash:P,headMode:b,remoteMode:k})}return u}function ao(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 co(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 gh(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 wh(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=gh(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await bh(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function bh(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":_i(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 _i(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return _i(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function yh(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,h=f.takeFrom==="head"?l.headMode:l.remoteMode,u=h?Number.parseInt(h,8):33188;o.push({path:c,mode:u,hash:d,stage:0,stat:ve()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:u});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Te(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function fo(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Eh){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 ft(e,t,n){let r=eo(e,t);await as(e.fs,r);let o=`${zc(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 cs(e,t){let n=eo(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,i=!1){let a=await vn(e,t),c={oldHash:r??te,newHash:o,...a,message:s};await ft(e,n,c),i&&n!=="HEAD"&&await ft(e,"HEAD",c)}var Ke=Re(()=>{"use strict";pt();nr();me();Nn();pt()});function _u(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 Fu(e,t){let n=await Nc(e,t);if(n.length===0)return null;if(n.length>1)throw new Di(t);return n[0]}async function Uu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Vc.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await $t(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Fu(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await B(e,t);if(s)return s}let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);if(r)return r;let o=await B(e,`refs/remotes/${t}`);return o||null}function Bu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Vc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Wu(e,t,n){let r=Bu(t),o=await Qe(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 qu(e,t,n){if(n===""||n==="commit")try{return await Ae(e,t)}catch{return null}if(n==="tree"){let o;try{o=await Ae(e,t)}catch{return null}return(await G(e,o)).tree}return(await ye(e,t)).type!==n?null:t}async function Ku(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await Ae(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await qu(e,r,s.target)}else if(s.type==="tilde")for(let i=0;i<s.n;i++){if(!r)return null;let a=await G(e,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(s.n===0)continue;if(!r)return null;let i=await G(e,r);if(s.n>i.parents.length||(r=i.parents[s.n-1]??null,!r))return null}return r}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=_u(t),s;return r!==void 0?s=await Wu(e,n,r):s=await Uu(e,n),s?Ku(e,s,o):null}function to(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Vc,Di,cn=Re(()=>{"use strict";ie();Ke();we();Vc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Di=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function mt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function En(e){return typeof e=="string"?e==="120000":e===40960}function Fn(e){return typeof e=="string"?e==="160000":e===57344}async function fs(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return zu.encode(r)}return e.readFileBuffer(t)}async function Un(e,t){let n=await fs(e,t);return gt("blob",n)}var zu,kn=Re(()=>{"use strict";ie();zu=new TextEncoder});function Xu(e){return e.length===4&&e.toLowerCase()===".git"}function Zu(e,t){if(e.length===0)throw new Error("invalid tree entry: empty name");if(e.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${e}'`);if(e.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(e==="."||e==="..")throw new Error(`invalid tree entry: '${e}'`);if(Xu(e))throw new Error(`invalid tree entry: '${e}'`);if(!Yu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function Rn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Yc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Yc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=Hn(a),f=o.padStart(6,"0");Zu(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Xc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Vu.encode(`${i} ${s.name}\0`),c=jt(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 Vu,Yc,Yu,no=Re(()=>{"use strict";pt();Vu=new TextEncoder,Yc=new TextDecoder,Yu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Jc(e,t,"")}async function Jc(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:Ju(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 Jc(e,a,c);r.push({mode:bn.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===bn.DIRECTORY?`${i.name}/`:i.name,f=a.mode===bn.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Xc({type:"tree",entries:r});return Se(e,"tree",s)}async function qe(e,t,n=""){let r=await ye(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=Rn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===bn.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function de(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){if(t===n)return[];let r=[];return await Qc(e,t,n,"",r),r.sort((o,s)=>Te(o.path,s.path))}async function Zc(e,t){let n=await ye(e,t);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return Rn(n.content).entries}async function Qc(e,t,n,r,o){if(t===n)return;let s=t?await Zc(e,t):[],i=n?await Zc(e,n):[],a=new Map;for(let l of s)a.set(l.name,l);let c=new Map;for(let l of i)c.set(l.name,l);let f=new Set;for(let l of s)f.add(l.name);for(let l of i)f.add(l.name);for(let l of f){let d=a.get(l),h=c.get(l),u=r?`${r}/${l}`:l;if(d&&h){if(d.hash===h.hash&&d.mode===h.mode)continue;let m=d.mode===bn.DIRECTORY,p=h.mode===bn.DIRECTORY;m&&p?await Qc(e,d.hash,h.hash,u,o):m?(await ro(e,d.hash,u,"deleted",o),o.push({path:u,status:"added",newHash:h.hash,newMode:h.mode})):p?(o.push({path:u,status:"deleted",oldHash:d.hash,oldMode:d.mode}),await ro(e,h.hash,u,"added",o)):o.push({path:u,status:"modified",oldHash:d.hash,newHash:h.hash,oldMode:d.mode,newMode:h.mode})}else if(d)d.mode===bn.DIRECTORY?await ro(e,d.hash,u,"deleted",o):o.push({path:u,status:"deleted",oldHash:d.hash,oldMode:d.mode});else{let m=h;m.mode===bn.DIRECTORY?await ro(e,m.hash,u,"added",o):o.push({path:u,status:"added",newHash:m.hash,newMode:m.mode})}}}async function ro(e,t,n,r,o){let s=await qe(e,t,n);for(let i of s)r==="added"?o.push({path:i.path,status:"added",newHash:i.hash,newMode:i.mode}):o.push({path:i.path,status:"deleted",oldHash:i.hash,oldMode:i.mode})}function Ju(e){return e.toString(8).padStart(6,"0")}var De=Re(()=>{"use strict";oe();ie();no();vi()});function ef(e){return/^[a-zA-Z0-9]$/.test(e)}function Qu(e){return/^[a-zA-Z]$/.test(e)}function eh(e){return e>="0"&&e<="9"}function Mi(e){return e>="A"&&e<="Z"}function ji(e){return e>="a"&&e<="z"}function tf(e){return/^\s$/.test(e)}function th(e){return e===" "||e===" "}function Li(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function nh(e){return Li(e)&&!tf(e)}function rh(e){return Li(e)&&!ef(e)&&e!==" "}function sh(e){let t=e.charCodeAt(0);return t<32||t===127}function oh(e){return/^[0-9a-fA-F]$/.test(e)}function ls(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Gi(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(!ls(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]==="/"&&Gi(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(!ih(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=Gi(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="",h=!0;for(;t<e.length&&(h||e[t]!=="]");){h=!1;let u=e[t];if(u==="\\"){if(t++,t>=e.length)return-1;u=e[t],ls(c,u,s)&&(l=!0)}else if(u==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,u=e[t],u==="\\"){if(t++,t>=e.length)return-1;u=e[t]}let m=d,p=u;if(c>=m&&c<=p&&(l=!0),s){if(ji(c)){let g=c.toUpperCase();g>=m&&g<=p&&(l=!0)}else if(Mi(c)){let g=c.toLowerCase();g>=m&&g<=p&&(l=!0)}}u=""}else if(u==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let m=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-m-1;if(p<0||e[t-1]!==":")t=m-2,u="[",ls(c,u,s)&&(l=!0);else{let g=e.slice(m,m+p);ah(g,c,s)&&(l=!0),u=""}}else ls(c,u,s)&&(l=!0);d=u,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!ls(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function ih(e){return e==="*"||e==="?"||e==="["||e==="\\"}function ah(e,t,n){switch(e){case"alnum":return ef(t);case"alpha":return Qu(t);case"blank":return th(t);case"cntrl":return sh(t);case"digit":return eh(t);case"graph":return nh(t);case"lower":return ji(t)||n&&Mi(t);case"print":return Li(t);case"punct":return rh(t);case"space":return tf(t);case"upper":return Mi(t)||n&&ji(t);case"xdigit":return oh(t);default:return!1}}function fn(e,t,n=0){return Gi(e,0,t,0,n)===0?0:1}var ds=Re(()=>{"use strict"});function of(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 ch(e){return of(e)===e.length}function fh(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|=so,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=sf);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=nf);let a=Math.min(of(o),s);return o[0]==="*"&&ch(o.slice(1))&&(r|=rf),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function us(e,t,n){let r=[];for(let o of e.split(`
41
+ `)){let s=fh(o,t);s&&r.push(s)}return{patterns:r,src:n}}function lh(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&rf){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return fn(n,e,2)===0}function dh(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return fn(r,a,2)===0}function Ni(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&sf&&!t)){if(s.flags&nf){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(lh(r,s))return s;continue}if(dh(e,s))return s}}return null}function ln(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Ni(t,n,o);if(s)return s.flags&so?"not-ignored":"ignored"}if(e.excludeFile){let r=Ni(t,n,e.excludeFile);if(r)return r.flags&so?"not-ignored":"ignored"}if(e.globalExclude){let r=Ni(t,n,e.globalExclude);if(r)return r.flags&so?"not-ignored":"ignored"}return"undecided"}async function Tr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=us(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=us(o,"",r)}catch{}}catch{}return t}function ir(e,t,n,r){let s=us(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var nf,rf,sf,so,io=Re(()=>{"use strict";Be();me();ds();nf=1,rf=4,sf=8,so=16});async function wt(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||Fn(s.mode))continue;let i=v(e.workTree,s.path),a;try{a=await mt(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 Un(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 rt(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Te(s.path,i.path))}async function lt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!rr(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);if(t.mode!=null&&Fn(t.mode)){let s=v(e.workTree,t.path);await e.fs.mkdir(s,{recursive:!0});return}let n=await ye(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=v(e.workTree,t.path);if(!Bs(e.workTree,r))throw new Error(`refusing to check out path outside worktree: '${t.path}'`);let o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&En(t.mode)&&e.fs.symlink){let s=hh.decode(n.content);if(!rc(s))throw new Error(`refusing to create symlink with unsafe target '${s}'`);await mt(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0}),await e.fs.symlink(s,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 af(e,t){let n=await qe(e,t);for(let r of n)await lt(e,r)}async function dn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!rr(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=v(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await mt(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=uh.encode(f),d=await Se(e,"blob",l),h={path:n,mode:40960,hash:d,stage:0,stat:{...ve(),size:l.byteLength}};return{index:Pt(t,h),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Se(e,"blob",s),a=o.mode!=null?mh(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...ve(),size:s.byteLength}};return{index:Pt(t,c),hash:i}}async function rt(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Tr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=ir(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=v(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&ln(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&ln(s,l,!0)==="ignored")continue;let h=await rt(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...h)}else if(d.isFile){if(s&&ln(s,l,!1)==="ignored")continue;i.push(l)}}return i}function mh(e){return e>511?e:e&73?33261:33188}async function ar(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 ar(e,rn(t),n))}var uh,hh,et=Re(()=>{"use strict";oe();io();Ce();ie();Ws();me();kn();De();uh=new TextEncoder,hh=new TextDecoder});function _i(e){return e.existsOnDisk&&e.indexHash===null}async function ph(e,t,n){let r=await Promise.all(t.map(m=>de(e,m.treeHash))),o=new Map,s=new Set;for(let m of n.entries)m.stage===0?o.set(m.path,m):s.add(m.path);let i=e.workTree?new Set(await rt(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await rt(e,e.workTree,"")):new Set),a),f=new Set;for(let m of r)for(let p of m.keys())f.add(p);let l=new Set;for(let m of n.entries)f.has(m.path)||l.add(m.path);for(let m of i)f.has(m)||l.add(m);let d=Array.from(f).sort().concat(Array.from(l).sort()),h=(m,p)=>r[m]?.get(p),u=[];for(let m of d){let p=null,g=null,w=null,b=null,y=null;if(r.length===1){let T=h(0,m);w=T?.hash??null,y=T?.mode??null}else if(r.length===2){let T=h(0,m),H=h(1,m);g=T?.hash??null,b=T?.mode??null,w=H?.hash??null,y=H?.mode??null}else if(r.length>=3){let T=h(0,m),H=h(1,m),M=h(2,m);p=T?.hash??null,g=H?.hash??null,b=H?.mode??null,w=M?.hash??null,y=M?.mode??null}let k=o.get(m)?.hash??null,R=s.has(m)?1:0,E=i.has(m),C,$=async()=>C!==void 0?C:E?(C=!(await c()).has(m),C):(C=!1,!1),D,P=async()=>{if(D!==void 0)return D;if(!E||!e.workTree)return D=null,null;let T=v(e.workTree,m);try{D=await Un(e.fs,T)}catch{D=null}return D};u.push({path:m,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:R,existsOnDisk:E,isIgnoredOnDisk:$,getWorktreeHash:P,headMode:b,remoteMode:y})}return u}function ao(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 co(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 gh(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 wh(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=gh(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await bh(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function bh(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":_i(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 _i(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return _i(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function yh(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,h=f.takeFrom==="head"?l.headMode:l.remoteMode,u=h?Number.parseInt(h,8):33188;o.push({path:c,mode:u,hash:d,stage:0,stat:ve()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:u});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Te(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function fo(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Eh){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 cr(e,t,n,r){let o=await ph(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 wh(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:fo(a,r)};let{newEntries:c,worktreeOps:f}=yh(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function je(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!rr(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!Us(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await lt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await ar(e.fs,rn(o),n)}async function Wn(e,t,n,r){return cr(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function cf(e,t,n,r){return cr(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function Pn(e,t,n){return cr(e,[{label:"target",treeHash:t}],n,{mergeFn:ao,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Tr(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:Ne(n)},i=await cr(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:ao,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.
46
+ `:"",exitCode:t.errorExitCode}}async function cr(e,t,n,r){let o=await ph(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 wh(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:fo(a,r)};let{newEntries:c,worktreeOps:f}=yh(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function je(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!rr(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!Bs(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await lt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await ar(e.fs,rn(o),n)}async function Bn(e,t,n,r){return cr(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function cf(e,t,n,r){return cr(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function Cn(e,t,n){return cr(e,[{label:"target",treeHash:t}],n,{mergeFn:ao,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function vr(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:Ne(n)},i=await cr(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:ao,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
48
  `);return c.length>0&&(i.errorOutput=_(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
- `,128)),i}if(e.workTree&&o.size>0){let a=await de(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 Eh,Jt=Re(()=>{"use strict";oe();Ce();Bs();pe();Rn();De();tt();Eh=[{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 T(e){return{stdout:"",stderr:`fatal: ${e}
50
- `,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await or(e,t);return r?n?{...r,...n}:r:kh}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ve(e){return e.workTree?null:Rh}async function Qe(e){let t=await X(e);return t||T("your current branch does not have any commits yet")}function $n(e,t,n=`fatal: Exiting because of an unresolved conflict.
49
+ `,128)),i}if(e.workTree&&o.size>0){let a=await de(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 Eh,Jt=Re(()=>{"use strict";oe();Ce();Ws();me();kn();De();et();Eh=[{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 S(e){return{stdout:"",stderr:`fatal: ${e}
50
+ `,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function q(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await or(e,t);return r?n?{...r,...n}:r:kh}function j(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:Rh}async function Je(e){let t=await X(e);return t||S("your current branch does not have any commits yet")}function Pn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
51
  `){return Gt(e)?_(`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 bt(e,t,n){let r=await We(e,t);return r||T(n??`bad revision '${t}'`)}async function Le(e,t,n){let r=await We(e,t);if(!r)return T(n??`bad revision '${t}'`);try{let o=await Ae(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return T(n??`bad revision '${t}'`)}}async function nt(e,t){try{return await Xr(e,t)}catch(n){return T(n.message)}}async function hn(e,t){try{return await Fs(e,t)}catch(n){return T(n.message)}}function qn(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 Te(e,t){return e<t?-1:e>t?1:0}function dt(e,t){return e.workTree?rt(e.workTree,t):""}function Z(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
- `);return t===-1?e:e.slice(0,t)}function Qt(e){return T(`ambiguous argument '${e}': unknown revision or path not in the working tree.
54
+ `+n,128):null}async function bt(e,t,n){let r=await We(e,t);return r||S(n??`bad revision '${t}'`)}async function Le(e,t,n){let r=await We(e,t);if(!r)return S(n??`bad revision '${t}'`);try{let o=await Ae(e,r),s=await G(e,o);return{hash:o,commit:s}}catch{return S(n??`bad revision '${t}'`)}}async function tt(e,t){try{return await Zr(e,t)}catch(n){return S(n.message)}}async function un(e,t){try{return await Us(e,t)}catch(n){return S(n.message)}}function Wn(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 Te(e,t){return e<t?-1:e>t?1:0}function dt(e,t){return e.workTree?nt(e.workTree,t):""}function Z(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
+ `);return t===-1?e:e.slice(0,t)}function Qt(e){return S(`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 Lt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${Z(t)}] ${ue(n)}`}async function zn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await X(e);if(!o)return T(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),i=await j(e,o),a=await z(e),c=await Tr(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Nn(e,o),await ae(e,{version:2,entries:c.newEntries}),await je(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await se(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function yt(e,t,n,r,o,s){let i=cn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Se(e,"commit",i);return await Nn(e,a),a}function It(e){let t=e.split(`
57
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Lt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${Z(t)}] ${ue(n)}`}async function qn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await X(e);if(!o)return S(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),i=await G(e,o),a=await z(e),c=await vr(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Ln(e,o),await ae(e,{version:2,entries:c.newEntries}),await je(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await ne(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function yt(e,t,n,r,o,s){let i=an({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Se(e,"commit",i);return await Ln(e,a),a}function It(e){let t=e.split(`
58
58
  `).filter(o=>!o.startsWith("#")).map(o=>o.trimEnd());for(;t.length>0&&t[0]==="";)t.shift();for(;t.length>0&&t[t.length-1]==="";)t.pop();if(t.length===0)return"";let n=[],r=!1;for(let o of t)o===""?(r||n.push(o),r=!0):(n.push(o),r=!1);return n.join(`
59
59
  `)+`
60
60
  `}function Nt(e){return e.endsWith(`
61
61
  `)?e:`${e}
62
- `}function vr(e,t=0,n=!0){let o=n?Math.max(t,...e.map(s=>s.from.length)):0;return e.map(s=>{let i=s.prefix.padEnd(21);if(!s.to)return`${i}${s.from}
62
+ `}function Hr(e,t=0,n=!0){let o=n?Math.max(t,...e.map(s=>s.from.length)):0;return e.map(s=>{let i=s.prefix.padEnd(21);if(!s.to)return`${i}${s.from}
63
63
  `;let a=o>0?s.from.padEnd(o):s.from,c=s.suffix?` ${s.suffix}`:"";return`${i}${a} -> ${s.to}${c}
64
- `}).join("")}function lo(e,t,n){let r=[];for(let o of e){let s=t(o.remote.name),i=t(o.localRef);if(o.oldHash){if(o.oldHash!==o.remote.hash){let a=n(o.oldHash),c=n(o.remote.hash);r.push({prefix:` ${a}..${c}`,from:s,to:i})}}else{let c=o.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";r.push({prefix:c,from:s,to:i})}}return r}var kh,Rh,oe=Re(()=>{"use strict";Hn();Ce();ie();bn();pe();ze();we();_n();fn();Jt();kh=T("not a git repository (or any of the parent directories): .git"),Rh=T("this operation must be run in a work tree")});var hf={};Kd(hf,{CommitHeap:()=>Kn,countAheadBehind:()=>Wi,findOrphanedCommits:()=>qi,walkCommits:()=>_t});async function*_t(e,t,n){if(n?.topoOrder){yield*Ih(e,t,n);return}let r=await uf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=n?.limit,c=0,f=Array.isArray(t)?t:[t];for(let l of f)o.has(l)||s.push(await Hr(e,l));for(;s.size>0;){let l=s.pop();if(o.has(l.hash))continue;if(o.add(l.hash),yield l,a!==void 0&&++c>=a)return;if(i?.has(l.hash))continue;let d=n?.firstParent?l.commit.parents.slice(0,1):l.commit.parents;for(let h of d)if(!o.has(h))try{s.push(await Hr(e,h))}catch{}}}async function*Ih(e,t,n){let r=await uf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Hr(e,u));let c=[],f=new Map;for(;s.size>0;){let u=s.pop();if(o.has(u.hash)||(o.add(u.hash),f.set(u.hash,c.length),c.push(u),i?.has(u.hash)))continue;let m=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of m)if(!o.has(p))try{s.push(await Hr(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let u of c){let m=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of m){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let h=[];for(let u=l-1;u>=0;u--)d[u]===0&&h.push(u);for(;h.length>0;){let u=h.pop();yield c[u];let m=n?.firstParent?c[u].commit.parents.slice(0,1):c[u].commit.parents;for(let p of m){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&h.push(g)}}}}async function Wi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of _t(e,t))r.add(a.hash);let o=new Set;for await(let a of _t(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 qi(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await Ae(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of _t(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Kn;for(f.push(await Hr(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:ue(l.commit.message)});for(let d of l.commit.parents)c.has(d)||f.push(await Hr(e,d))}}return a}async function uf(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of _t(e,t))n.add(r.hash);return n}async function Hr(e,t){return{hash:t,commit:await j(e,t)}}var Kn,lr=Re(()=>{"use strict";oe();ie();we();Kn=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 si=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 Fa(e){return new si({_kind:"arg",type:e,required:!0})}function Ua(){return Fa("string")}function Ba(){return Fa("number")}var js=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 oi=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})}repeatable(){return new e({...this._def,repeatable:!0,default:[]})}};function Wa(e){return new oi({_kind:"option",type:e})}function qa(){return Wa("string")}function za(){return Wa("number")}var Y={string:qa,number:za};function S(){return new js}var q={string:Ua,number:Ba};function Vd(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+=`
64
+ `}).join("")}function lo(e,t,n){let r=[];for(let o of e){let s=t(o.remote.name),i=t(o.localRef);if(o.oldHash){if(o.oldHash!==o.remote.hash){let a=n(o.oldHash),c=n(o.remote.hash);r.push({prefix:` ${a}..${c}`,from:s,to:i})}}else{let c=o.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";r.push({prefix:c,from:s,to:i})}}return r}var kh,Rh,oe=Re(()=>{"use strict";nr();Ce();ie();wn();me();Ke();we();Nn();cn();Jt();kh=S("not a git repository (or any of the parent directories): .git"),Rh=S("this operation must be run in a work tree")});var hf={};zd(hf,{CommitHeap:()=>Kn,countAheadBehind:()=>Wi,findOrphanedCommits:()=>qi,walkCommits:()=>_t});async function*_t(e,t,n){if(n?.topoOrder){yield*Ih(e,t,n);return}let r=await uf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=n?.limit,c=0,f=Array.isArray(t)?t:[t];for(let l of f)o.has(l)||s.push(await Ar(e,l));for(;s.size>0;){let l=s.pop();if(o.has(l.hash))continue;if(o.add(l.hash),yield l,a!==void 0&&++c>=a)return;if(i?.has(l.hash))continue;let d=n?.firstParent?l.commit.parents.slice(0,1):l.commit.parents;for(let h of d)if(!o.has(h))try{s.push(await Ar(e,h))}catch{}}}async function*Ih(e,t,n){let r=await uf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Ar(e,u));let c=[],f=new Map;for(;s.size>0;){let u=s.pop();if(o.has(u.hash)||(o.add(u.hash),f.set(u.hash,c.length),c.push(u),i?.has(u.hash)))continue;let m=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of m)if(!o.has(p))try{s.push(await Ar(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let u of c){let m=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of m){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let h=[];for(let u=l-1;u>=0;u--)d[u]===0&&h.push(u);for(;h.length>0;){let u=h.pop();yield c[u];let m=n?.firstParent?c[u].commit.parents.slice(0,1):c[u].commit.parents;for(let p of m){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&h.push(g)}}}}async function Wi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of _t(e,t))r.add(a.hash);let o=new Set;for await(let a of _t(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 qi(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await Ae(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of _t(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Kn;for(f.push(await Ar(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:ue(l.commit.message)});for(let d of l.commit.parents)c.has(d)||f.push(await Ar(e,d))}}return a}async function uf(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of _t(e,t))n.add(r.hash);return n}async function Ar(e,t){return{hash:t,commit:await G(e,t)}}var Kn,lr=Re(()=>{"use strict";oe();ie();we();Kn=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 si=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 Fa(e){return new si({_kind:"arg",type:e,required:!0})}function Ua(){return Fa("string")}function Ba(){return Fa("number")}var Gs=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 oi=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})}repeatable(){return new e({...this._def,repeatable:!0,default:[]})}};function Wa(e){return new oi({_kind:"option",type:e})}function qa(){return Wa("string")}function Ka(){return Wa("number")}var Y={string:qa,number:Ka};function I(){return new Gs}var K={string:Ua,number:Ba};function Vd(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+=`
65
65
  Not all git options are supported. Run 'git <command> --help' for available options.`,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=`git: '${e.path.replace(/^git /,"")}' is not a git command.`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
66
66
  Run 'git help' for available commands.`,t}}}function ii(e){return e.map(Vd).join(`
67
67
  `)+`
68
- `}function Yd(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 Gs(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Yd(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 Ka(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[h,u]of Object.entries(e)){let m=Kr(h);s.set(m,{key:h,def:u}),u.short&&i.set(u.short,{key:h,def:u})}let a={},c=[],f=[],l=0;for(;l<n.length;){let h=n[l];if(h==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(h.startsWith("--")){let u=h.indexOf("="),m,p;u!==-1?(m=h.slice(2,u),p=h.slice(u+1)):m=h.slice(2);let g=s.get(m);if(!g){if(m.startsWith("no-")){let R=s.get(m.slice(3));if(R&&R.def._kind==="flag"){a[R.key]=R.def.counted?0:!1,l++;continue}}let k=[...s.keys()];o.push({type:"unknown_option",name:`--${m}`,suggestions:Gs(m,k).map(R=>`--${R}`)}),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 b=zr(w,g.def.type,g.key,o);b!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(b)):a[g.key]=b),l++;continue}if(h.startsWith("-")&&h.length>1){let u=h.slice(1);for(let m=0;m<u.length;m++){let p=u[m],g=i.get(p);if(!g){let R=[];s.has(p)&&R.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:R});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=u.slice(m+1),b=w.length>0?w:n[++l];if(b===void 0){o.push({type:"missing_value",name:g.key});break}let k=zr(b,g.def.type,g.key,o);k!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(k)):a[g.key]=k);break}l++;continue}c.push(h),l++}let d=0;for(let h=0;h<t.length;h++){let u=t[h],m=u.name??`arg${h}`;if(u.variadic){let p=c.slice(d);p.length>0?a[m]=p.map(g=>zr(g,u.type,m,o)):u.required?o.push({type:"missing_required",name:m,kind:"arg"}):u.default!==void 0?a[m]=u.default:a[m]=[],d=c.length}else{let p=c[d];p!==void 0?(a[m]=zr(p,u.type,m,o),d++):u.required?o.push({type:"missing_required",name:m,kind:"arg"}):u.default!==void 0&&(a[m]=u.default)}}if(d<c.length)for(let h=d;h<c.length;h++)o.push({type:"unexpected_positional",value:c[h],maxPositionals:t.length});for(let[h,u]of Object.entries(e))if(a[h]===void 0){if(u._kind==="flag")a[h]=u.default??(u.counted?0:!1);else if(u._kind==="option"){let m=u;if(m.env&&r?.[m.env]!==void 0){let p=zr(r[m.env],m.type,h,o);p!==void 0&&(a[h]=p)}a[h]===void 0&&(m.required&&m.default===void 0?o.push({type:"missing_required",name:h,kind:"option"}):m.default!==void 0&&(a[h]=m.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function zr(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 Kr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Rr(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=Xd(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(`
69
- `)}function Xd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Kr(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.repeatable&&d.push("(repeatable)"),f.required&&d.push("(required)"),f.default!==void 0&&!f.repeatable&&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 Va(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Ya(e){return e?e.map(t=>t._def):[]}var Ls=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,Va(n.options),Ya(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=Kr(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(!this.handler&&o&&!o.startsWith("-")){let s=Gs(o,[...this.children.keys()]);return{stdout:"",stderr:ii([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Zd(t))return{stdout:Rr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ka(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:ii(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}}}return{stdout:Rr(this),stderr:"",exitCode:0}}};function ai(e,t){return new Ls(e,t.description,Va(t.options),Ya(t.args),t.examples??[],t.handler,t.transformArgs)}function Zd(e){return e.some(t=>t==="--help")}oe();io();Ce();pe();ls();var ho=1,Fi=2,uo=4,Ui=8,us=16,lf=new Set(["*","?","[","\\"]),Ch={glob:ho,literal:Fi,icase:uo,top:Ui,exclude:us};function fr(e){for(let t=0;t<e.length;t++)if(lf.has(e[t]))return!0;return!1}function Ph(e){for(let t=0;t<e.length;t++)if(lf.has(e[t]))return t;return e.length}function ff(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=Ch[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Ui,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=us,r=r.slice(2));n&Fi&&n&ho&&(n&=~ho);let o;n&Ui||t===""?o=ff(r):o=ff(`${t}/${r}`);let s=!!(n&Fi),i=s?!1:fr(o),a=s?o.length:Ph(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function mo(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&uo),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&uo){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&ho&&(i|=2),o&uo&&(i|=1),ln(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&us?mo(o,t)&&(r=!0):mo(o,t)&&(n=!0);return n&&!r}tt();function df(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:S().alias("A").describe("Add changes from all tracked and untracked files"),force:S().alias("f").describe("Allow adding otherwise ignored files"),update:S().alias("u").describe("Update tracked files"),"dry-run":S().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ve(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 z(s);return p=await Bi(s,p,a,"",c),n["dry-run"]||await ae(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
70
- Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],h=[];for(let p of f)fr(p)?h.push(p):d.push(p);let u=[];for(let p of d){let g=Mt(r.cwd,p),w=rt(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return T(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let R=l.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`)),C=await Oh(s,a,w,R);if(C){R&&((await r.fs.stat(g)).isDirectory?l=await Bi(s,l,g,w,c):l=(await un(s,l,w)).index),u.push(C);continue}}if((await r.fs.stat(g)).isDirectory)l=await Bi(s,l,g,w,c);else{let R=l.entries.find(E=>E.path===w&&E.stage===0)?.hash,C=await un(s,l,w);l=C.index,c.actions&&C.hash!==R&&c.actions.push(`add '${w}'
71
- `)}}else if(l.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`))){if(c.actions)for(let R of l.entries)(R.path===w||R.path.startsWith(`${w}/`))&&c.actions.push(`remove '${R.path}'
72
- `);l={...l,entries:l.entries.filter(R=>R.path!==w&&!R.path.startsWith(`${w}/`))}}else return T(`pathspec '${p}' did not match any files`)}if(u.length>0)return n["dry-run"]||await ae(s,l),_(`The following paths are ignored by one of your .gitignore files:
68
+ `}function Yd(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 Ls(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Yd(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 za(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[h,u]of Object.entries(e)){let m=Vr(h);s.set(m,{key:h,def:u}),u.short&&i.set(u.short,{key:h,def:u})}let a={},c=[],f=[],l=0;for(;l<n.length;){let h=n[l];if(h==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(h.startsWith("--")){let u=h.indexOf("="),m,p;u!==-1?(m=h.slice(2,u),p=h.slice(u+1)):m=h.slice(2);let g=s.get(m);if(!g){if(m.startsWith("no-")){let x=s.get(m.slice(3));if(x&&x.def._kind==="flag"){a[x.key]=x.def.counted?0:!1,l++;continue}}let y=[...s.keys()];o.push({type:"unknown_option",name:`--${m}`,suggestions:Ls(m,y).map(x=>`--${x}`)}),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 b=zr(w,g.def.type,g.key,o);b!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(b)):a[g.key]=b),l++;continue}if(h.startsWith("-")&&h.length>1){let u=h.slice(1);for(let m=0;m<u.length;m++){let p=u[m],g=i.get(p);if(!g){let x=[];s.has(p)&&x.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:x});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=u.slice(m+1),b=w.length>0?w:n[++l];if(b===void 0){o.push({type:"missing_value",name:g.key});break}let y=zr(b,g.def.type,g.key,o);y!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(y)):a[g.key]=y);break}l++;continue}c.push(h),l++}let d=0;for(let h=0;h<t.length;h++){let u=t[h],m=u.name??`arg${h}`;if(u.variadic){let p=c.slice(d);p.length>0?a[m]=p.map(g=>zr(g,u.type,m,o)):u.required?o.push({type:"missing_required",name:m,kind:"arg"}):u.default!==void 0?a[m]=u.default:a[m]=[],d=c.length}else{let p=c[d];p!==void 0?(a[m]=zr(p,u.type,m,o),d++):u.required?o.push({type:"missing_required",name:m,kind:"arg"}):u.default!==void 0&&(a[m]=u.default)}}if(d<c.length)for(let h=d;h<c.length;h++)o.push({type:"unexpected_positional",value:c[h],maxPositionals:t.length});for(let[h,u]of Object.entries(e))if(a[h]===void 0){if(u._kind==="flag")a[h]=u.default??(u.counted?0:!1);else if(u._kind==="option"){let m=u;if(m.env&&r?.[m.env]!==void 0){let p=zr(r[m.env],m.type,h,o);p!==void 0&&(a[h]=p)}a[h]===void 0&&(m.required&&m.default===void 0?o.push({type:"missing_required",name:h,kind:"option"}):m.default!==void 0&&(a[h]=m.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function zr(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 Vr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Rr(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=Xd(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(`
69
+ `)}function Xd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Vr(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.repeatable&&d.push("(repeatable)"),f.required&&d.push("(required)"),f.default!==void 0&&!f.repeatable&&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 Va(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Ya(e){return e?e.map(t=>t._def):[]}var Ns=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,Va(n.options),Ya(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=Vr(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(!this.handler&&o&&!o.startsWith("-")){let s=Ls(o,[...this.children.keys()]);return{stdout:"",stderr:ii([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Zd(t))return{stdout:Rr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=za(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:ii(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}}}return{stdout:Rr(this),stderr:"",exitCode:0}}};function ai(e,t){return new Ns(e,t.description,Va(t.options),Ya(t.args),t.examples??[],t.handler,t.transformArgs)}function Zd(e){return e.some(t=>t==="--help")}oe();io();Ce();me();ds();var ho=1,Fi=2,uo=4,Ui=8,hs=16,lf=new Set(["*","?","[","\\"]),Ch={glob:ho,literal:Fi,icase:uo,top:Ui,exclude:hs};function fr(e){for(let t=0;t<e.length;t++)if(lf.has(e[t]))return!0;return!1}function Ph(e){for(let t=0;t<e.length;t++)if(lf.has(e[t]))return t;return e.length}function ff(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=Ch[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Ui,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=hs,r=r.slice(2));n&Fi&&n&ho&&(n&=~ho);let o;n&Ui||t===""?o=ff(r):o=ff(`${t}/${r}`);let s=!!(n&Fi),i=s?!1:fr(o),a=s?o.length:Ph(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function mo(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&uo),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&uo){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&ho&&(i|=2),o&uo&&(i|=1),fn(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&hs?mo(o,t)&&(r=!0):mo(o,t)&&(n=!0);return n&&!r}et();function df(e,t){e.command("add",{description:"Add file contents to the index",args:[K.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:I().alias("A").describe("Add changes from all tracked and untracked files"),force:I().alias("f").describe("Allow adding otherwise ignored files"),update:I().alias("u").describe("Update tracked files"),"dry-run":I().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=Ye(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 z(s);return p=await Bi(s,p,a,"",c),n["dry-run"]||await ae(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
70
+ Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],h=[];for(let p of f)fr(p)?h.push(p):d.push(p);let u=[];for(let p of d){let g=Mt(r.cwd,p),w=nt(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return S(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let x=l.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`)),k=await Oh(s,a,w,x);if(k){x&&((await r.fs.stat(g)).isDirectory?l=await Bi(s,l,g,w,c):l=(await dn(s,l,w)).index),u.push(k);continue}}if((await r.fs.stat(g)).isDirectory)l=await Bi(s,l,g,w,c);else{let x=l.entries.find(R=>R.path===w&&R.stage===0)?.hash,k=await dn(s,l,w);l=k.index,c.actions&&k.hash!==x&&c.actions.push(`add '${w}'
71
+ `)}}else if(l.entries.some(x=>x.path===w||x.path.startsWith(`${w}/`))){if(c.actions)for(let x of l.entries)(x.path===w||x.path.startsWith(`${w}/`))&&c.actions.push(`remove '${x.path}'
72
+ `);l={...l,entries:l.entries.filter(x=>x.path!==w&&!x.path.startsWith(`${w}/`))}}else return S(`pathspec '${p}' did not match any files`)}if(u.length>0)return n["dry-run"]||await ae(s,l),_(`The following paths are ignored by one of your .gitignore files:
73
73
  ${u.join(`
74
74
  `)}
75
75
  hint: Use -f if you really want to add them.
76
76
  hint: Disable this message with "git config set advice.addIgnoredFile false"
77
- `);if(h.length>0){let p=await $h(s,r.cwd,l,h,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await ae(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function $h(e,t,n,r,o){let s=e.workTree,i=dt(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let h=0;h<a.length;h++)a[h].hasWildcard&&mo(a[h],d)&&(c[h]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!Ee(a,d.path))continue;f(d.path);let h=v(s,d.path);if(await e.fs.exists(h)){let u=await un(e,n,d.path);n=u.index,o?.actions&&u.hash!==d.hash&&o.actions.push(`add '${d.path}'
77
+ `);if(h.length>0){let p=await $h(s,r.cwd,l,h,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await ae(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function $h(e,t,n,r,o){let s=e.workTree,i=dt(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let h=0;h<a.length;h++)a[h].hasWildcard&&mo(a[h],d)&&(c[h]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!Ee(a,d.path))continue;f(d.path);let h=v(s,d.path);if(await e.fs.exists(h)){let u=await dn(e,n,d.path);n=u.index,o?.actions&&u.hash!==d.hash&&o.actions.push(`add '${d.path}'
78
78
  `)}else o?.actions&&o.actions.push(`remove '${d.path}'
79
- `),l.push(d.path)}for(let d of l)n=ft(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(u=>u.path)),h=await st(e,s,"",{skipIgnore:o?.skipIgnore});for(let u of h){if(d.has(u)||!Ee(a,u))continue;f(u),o?.actions&&o.actions.push(`add '${u}'
80
- `),n=(await un(e,n,u)).index}}for(let d=0;d<a.length;d++){let h=a[d];if(!c[d]&&!(h.magic&us))return{index:n,error:T(`pathspec '${h.original}' did not match any files`)}}return{index:n}}async function Bi(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=v(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,h=await un(e,t,f.path);t=h.index,o?.actions&&(d||h.hash!==f.hash)&&o.actions.push(`add '${f.path}'
79
+ `),l.push(d.path)}for(let d of l)n=ct(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(u=>u.path)),h=await rt(e,s,"",{skipIgnore:o?.skipIgnore});for(let u of h){if(d.has(u)||!Ee(a,u))continue;f(u),o?.actions&&o.actions.push(`add '${u}'
80
+ `),n=(await dn(e,n,u)).index}}for(let d=0;d<a.length;d++){let h=a[d];if(!c[d]&&!(h.magic&hs))return{index:n,error:S(`pathspec '${h.original}' did not match any files`)}}return{index:n}}async function Bi(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=v(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,h=await dn(e,t,f.path);t=h.index,o?.actions&&(d||h.hash!==f.hash)&&o.actions.push(`add '${f.path}'
81
81
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
82
- `),a.push(f.path)}for(let f of a)t=ft(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await st(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
83
- `),t=(await un(e,t,d)).index}}return t}async function Oh(e,t,n,r){let o=await Sr(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=ir(o,i,"",v(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=v(t,a);if(dn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(v(c,".gitignore"));o=ir(o,f,a,v(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(v(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(dn(o,n,i)==="ignored")return n}return null}oe();oe();lr();ie();pe();we();async function $e(e,t){let n=v(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Me(e,t,n){await e.fs.writeFile(v(e.gitDir,t),n)}async function be(e,t){let n=v(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function hs(e){await me(e,"MERGE_HEAD"),await me(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}async function Ft(e){await me(e,"CHERRY_PICK_HEAD"),await me(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function St(e){await me(e,"REVERT_HEAD"),await me(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function dr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await me(e,t);await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}var zi="DETACH_POINT";async function mf(e,t){await e.fs.writeFile(v(e.gitDir,zi),t)}async function Et(e){let t=v(e.gitDir,zi);await e.fs.exists(t)&&await e.fs.rm(t)}async function ms(e){let t=v(e.gitDir,zi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}pe();we();async function Tt(e){let t=await $e(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ps(e){let t=await $e(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
84
- `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function po(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ps(e),o=await B(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 $e(e,"BISECT_HEAD")!=null||await e.fs.exists(v(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(v(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function vt(e,t){let n=await $e(e,"BISECT_LOG")??"";await Me(e,"BISECT_LOG",n+t+`
85
- `)}async function go(e){let t=await ge(e,"refs/bisect");for(let r of t)await me(e,r.name);await be(e,"BISECT_EXPECTED_REV"),await be(e,"BISECT_ANCESTORS_OK"),await be(e,"BISECT_LOG"),await be(e,"BISECT_TERMS"),await be(e,"BISECT_NAMES"),await be(e,"BISECT_FIRST_PARENT"),await be(e,"BISECT_HEAD"),await be(e,"BISECT_START");let n=v(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function pf(e,t,n,r,o){let s=[],i=new Map;for await(let g of _t(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ue(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,b=[g.hash],k=0;for(;k<b.length;){let R=b[k++];if(w.has(R)||!c.has(R))continue;w.add(R);let C=i.get(R);if(C)for(let E of C)!w.has(E)&&c.has(E)&&b.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,b=Math.abs(2*w-a);b<d&&(d=b,l=g.hash)}let h=!1;if(d===a){h=!0;for(let g of s){let w=f.get(g.hash)??0,b=Math.abs(2*w-a);b<d&&(d=b,l=g.hash)}}let u=s.find(g=>g.hash===l),m=Sh(a),p=Th(a);return{hash:u.hash,subject:u.subject,remaining:m,steps:p,found:!1,onlySkippedLeft:h}}function Sh(e){return Math.floor((e-1)/2)}function Th(e){return e<=1?0:Math.ceil(Math.log2(e))}function gf(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
82
+ `),a.push(f.path)}for(let f of a)t=ct(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await rt(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
83
+ `),t=(await dn(e,t,d)).index}}return t}async function Oh(e,t,n,r){let o=await Tr(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=ir(o,i,"",v(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=v(t,a);if(ln(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(v(c,".gitignore"));o=ir(o,f,a,v(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(v(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(ln(o,n,i)==="ignored")return n}return null}oe();oe();lr();ie();me();we();async function $e(e,t){let n=v(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Me(e,t,n){await e.fs.writeFile(v(e.gitDir,t),n)}async function be(e,t){let n=v(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ms(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}async function Ft(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function St(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function dr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await he(e,t);await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}var Ki="DETACH_POINT";async function mf(e,t){await e.fs.writeFile(v(e.gitDir,Ki),t)}async function Et(e){let t=v(e.gitDir,Ki);await e.fs.exists(t)&&await e.fs.rm(t)}async function ps(e){let t=v(e.gitDir,Ki);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();we();async function Tt(e){let t=await $e(e,"BISECT_START");return t!=null&&t.trim().length>0}async function gs(e){let t=await $e(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
84
+ `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function po(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await gs(e),o=await B(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 $e(e,"BISECT_HEAD")!=null||await e.fs.exists(v(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(v(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function vt(e,t){let n=await $e(e,"BISECT_LOG")??"";await Me(e,"BISECT_LOG",n+t+`
85
+ `)}async function go(e){let t=await ge(e,"refs/bisect");for(let r of t)await he(e,r.name);await be(e,"BISECT_EXPECTED_REV"),await be(e,"BISECT_ANCESTORS_OK"),await be(e,"BISECT_LOG"),await be(e,"BISECT_TERMS"),await be(e,"BISECT_NAMES"),await be(e,"BISECT_FIRST_PARENT"),await be(e,"BISECT_HEAD"),await be(e,"BISECT_START");let n=v(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function pf(e,t,n,r,o){let s=[],i=new Map;for await(let g of _t(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ue(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,b=[g.hash],y=0;for(;y<b.length;){let x=b[y++];if(w.has(x)||!c.has(x))continue;w.add(x);let k=i.get(x);if(k)for(let R of k)!w.has(R)&&c.has(R)&&b.push(R)}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,b=Math.abs(2*w-a);b<d&&(d=b,l=g.hash)}let h=!1;if(d===a){h=!0;for(let g of s){let w=f.get(g.hash)??0,b=Math.abs(2*w-a);b<d&&(d=b,l=g.hash)}}let u=s.find(g=>g.hash===l),m=Sh(a),p=Th(a);return{hash:u.hash,subject:u.subject,remaining:m,steps:p,found:!1,onlySkippedLeft:h}}function Sh(e){return Math.floor((e-1)/2)}function Th(e){return e<=1?0:Math.ceil(Math.log2(e))}function gf(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
86
86
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
87
87
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
88
88
  `}function wf(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
89
89
  [${e.hash}] ${e.subject}
90
- `}async function bf(e,t){let n=await j(e,t),r=ue(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
90
+ `}async function bf(e,t){let n=await G(e,t),r=ue(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
91
91
  `;return i+=`commit ${t}
92
92
  `,i+=`Author: ${n.author.name} <${n.author.email}>
93
93
  `,i+=`Date: ${s}
94
94
  `,i+=`
95
95
  `,i+=` ${r}
96
96
  `,i+=`
97
- `,i}oe();lr();Be();Ce();ie();pe();ze();we();oe();lr();Be();Ce();ie();pe();ie();bn();pe();function Ar(e){return v(e.gitDir,"rebase-merge")}async function Ut(e){return e.fs.exists(Ar(e))}async function kt(e){let t=Ar(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(v(t,"head-name")),r=await e.fs.readFile(v(t,"orig-head")),o=await e.fs.readFile(v(t,"onto")),s=Number.parseInt(await e.fs.readFile(v(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(v(t,"end")),10),a=await e.fs.exists(v(t,"git-rebase-todo"))?v(t,"git-rebase-todo"):v(t,"todo"),c=yf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=yf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Ki(e,t){let n=Ar(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
97
+ `,i}oe();lr();Be();Ce();ie();me();Ke();we();oe();lr();Be();Ce();ie();me();ie();wn();me();function Dr(e){return v(e.gitDir,"rebase-merge")}async function Ut(e){return e.fs.exists(Dr(e))}async function kt(e){let t=Dr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(v(t,"head-name")),r=await e.fs.readFile(v(t,"orig-head")),o=await e.fs.readFile(v(t,"onto")),s=Number.parseInt(await e.fs.readFile(v(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(v(t,"end")),10),a=await e.fs.exists(v(t,"git-rebase-todo"))?v(t,"git-rebase-todo"):v(t,"todo"),c=yf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=yf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function zi(e,t){let n=Dr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
98
98
  `),await e.fs.writeFile(v(n,"orig-head"),`${t.origHead}
99
99
  `),await e.fs.writeFile(v(n,"onto"),`${t.onto}
100
100
  `),await e.fs.writeFile(v(n,"msgnum"),`${String(t.msgnum)}
101
101
  `),await e.fs.writeFile(v(n,"end"),`${String(t.end)}
102
- `),await e.fs.writeFile(v(n,"git-rebase-todo"),bo(t.todo)),await e.fs.writeFile(v(n,"done"),bo(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function Rf(e){let t=Ar(e),n=await kt(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(v(t,"msgnum"),`${String(n.msgnum)}
103
- `),await e.fs.writeFile(v(t,"git-rebase-todo"),bo(n.todo)),await e.fs.writeFile(v(t,"done"),bo(n.done))}async function Vi(e){let t=Ar(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function yo(e,t,n){let r=Ar(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
102
+ `),await e.fs.writeFile(v(n,"git-rebase-todo"),bo(t.todo)),await e.fs.writeFile(v(n,"done"),bo(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function Rf(e){let t=Dr(e),n=await kt(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(v(t,"msgnum"),`${String(n.msgnum)}
103
+ `),await e.fs.writeFile(v(t,"git-rebase-todo"),bo(n.todo)),await e.fs.writeFile(v(t,"done"),bo(n.done))}async function Vi(e){let t=Dr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function yo(e,t,n){let r=Dr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
104
104
  GIT_AUTHOR_EMAIL='${n.email}'
105
105
  GIT_AUTHOR_DATE='${o}'
106
106
  `),await e.fs.writeFile(v(r,"stopped-sha"),`${t}
107
107
  `)}function yf(e){let t=[];for(let n of e.split(`
108
108
  `)){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 bo(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
109
109
  `)}
110
- `}async function xf(e,t,n){let r=new Map,[o,s]=await Promise.all([Ef(e,t,r),Ef(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 kf(e,r,n,i),left:await kf(e,r,t,a)}}async function Ef(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 wo(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function kf(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 wo(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 wo(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 wo(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 h=(o.get(d)??0)-1;o.set(d,h),h<=0&&i.push(d)}}return a.reverse(),a}async function wo(e,t,n){let r=n.get(t);if(r)return r;let o=await ye(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:an(o.content)};return n.set(t,s),s}we();ie();function Dr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function vh(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Dr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Dr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Hh=50;async function ot(e,t,n=Hh){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 h=r.get(d);if(h&&h.length>0){let u=vh(h,l.path);u&&a.push({oldPath:u.path,newPath:l.path,oldHash:u.oldHash??d,newHash:d,similarity:100,oldMode:u.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await Ah(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),h=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!h.has(u.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await jh(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),h=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!h.has(u.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function Ah(e,t,n,r){let o=new Map;for(let a=0;a<t.length;a++){let c=t[a];if(!c)continue;let f=Dr(c.path);o.has(f)?o.set(f,-1):o.set(f,a)}let s=new Map;for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let f=Dr(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let l=t[c],d=n[f];if(!l?.oldHash||!d?.newHash||l.oldHash===d.newHash)continue;let h=await Ot(e,l.oldHash),u=await Ot(e,d.newHash),m=Mh(h,u);m<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:m,oldMode:l.oldMode,newMode:d.newMode})}return i}var Cf=107927;function Eo(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))%Cf;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%Cf;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 Dh(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 Mh(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Pf(e.length,Eo(e),t.length,Eo(t))}function Pf(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Dh(t,r);return Math.floor(i*100/o)}async function jh(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Ot(e,l.oldHash);o.push({size:d.length,chunks:Eo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Ot(e,l.newHash);s.push({size:d.length,chunks:Eo(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],h=o[l];if(!(!d||!h))for(let u=0;u<n.length;u++){let m=n[u],p=s[u];if(!m||!p)continue;let g=Pf(h.size,h.chunks,p.size,p.chunks);if(g>=r){let w=Dr(d.path)===Dr(m.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:u})}}}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:h}of i){if(a.has(d)||c.has(h))continue;a.add(d),c.add(h);let u=t[d],m=n[h];!u||!m||f.push({oldPath:u.path,newPath:m.path,oldHash:u.oldHash??"",newHash:m.newHash??"",similarity:l,oldMode:u.oldMode,newMode:m.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),h=e.slice(0,o),u=e.slice(n-a),m=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${h}{${m} => ${p}}${u}`:`${e} => ${t}`}De();tt();async function it(e,t){let n=await Q(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Xi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Yi(e,c,i,a),d=await wt(e,i),h=[],u=[];for(let g of d)g.status==="untracked"?u.push(g.path):h.push({path:g.path,status:g.status});h.sort((g,w)=>Te(g.path,w.path));let m=new Set(i.entries.map(g=>g.path)),p=Zi(u,m);return Gh(e,r,s,o,i,l,h,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function $f(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Gh(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,h=await B(e,"CHERRY_PICK_HEAD"),u=await B(e,"REVERT_HEAD"),m=await B(e,"MERGE_HEAD"),p=!h&&!m,w=await Ut(e)?await kt(e):null;if(n&&w){let x=Z(w.onto);l.push(`interactive rebase in progress; onto ${x}`)}else if(n){let x=await ms(e);if(x){let $=t===x?"at":"from";l.push(`HEAD detached ${$} ${Z(x)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);let b=f?.isInitial??!t;if(!n&&!w&&!b){let x=await he(e),$=await Bt(e,x,r);if($){let A=Vn($,{abbreviated:f?.fromCommit});for(let P of A.trimEnd().split(`
111
- `))l.push(P);d=!0}}if(d&&(w||h||u||m)&&l.push(""),w&&m)$f(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 x=Gt(o),$=await e.fs.exists(v(e.gitDir,"MERGE_MSG"));$f(l,w);let P=w.headName==="detached HEAD"?null:Pe(w.headName),O=Z(w.onto),D=P?` branch '${P}' on '${O}'`:"";if(x)l.push(`You are currently rebasing${D}.`),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($)l.push(`You are currently rebasing${D}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let L=D?`You are currently editing a commit while rebasing${D}.`:"You are currently editing a commit during a rebase.";l.push(L),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 h?(l.push(`You are currently cherry-picking commit ${Z(h)}.`),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):u?(l.push(`You are currently reverting commit ${Z(u)}.`),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):m&&(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 Tt(e)){let $=(await $e(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${$}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}b&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let k=null;p&&(k=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let C=i.some(x=>x.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:"),k&&l.push(k);for(let x of s)l.push(` ${Of(x.status,x.path,x.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($=>$.status==="deleted by us"||$.status==="deleted by them"||$.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 $ of a)l.push(` ${Lh($.status,$.path)}`);l.push(""),E=!0}if(i.length>0){!E&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(C),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let x of i)l.push(` ${Of(x.status,x.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 x of c)l.push(` ${x}`);l.push(""),E=!0}let y=s.length>0||!!m&&a.length===0;return!E&&d&&(f?.noWarn||y)&&l.push(""),!y&&!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)'):b?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
110
+ `}async function xf(e,t,n){let r=new Map,[o,s]=await Promise.all([Ef(e,t,r),Ef(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 kf(e,r,n,i),left:await kf(e,r,t,a)}}async function Ef(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 wo(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function kf(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 wo(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 wo(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 wo(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 h=(o.get(d)??0)-1;o.set(d,h),h<=0&&i.push(d)}}return a.reverse(),a}async function wo(e,t,n){let r=n.get(t);if(r)return r;let o=await ye(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:on(o.content)};return n.set(t,s),s}we();ie();function Mr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function vh(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Mr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Mr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Hh=50;async function st(e,t,n=Hh){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 h=r.get(d);if(h&&h.length>0){let u=vh(h,l.path);u&&a.push({oldPath:u.path,newPath:l.path,oldHash:u.oldHash??d,newHash:d,similarity:100,oldMode:u.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await Ah(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),h=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!h.has(u.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await jh(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),h=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!h.has(u.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function Ah(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=Mr(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=Mr(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 h=await Ot(e,l.oldHash),u=await Ot(e,d.newHash),m=Mh(h,u);m<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:m,oldMode:l.oldMode,newMode:d.newMode})}return i}var Cf=107927;function Eo(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))%Cf;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%Cf;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 Dh(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 Mh(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Pf(e.length,Eo(e),t.length,Eo(t))}function Pf(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Dh(t,r);return Math.floor(i*100/o)}async function jh(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Ot(e,l.oldHash);o.push({size:d.length,chunks:Eo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Ot(e,l.newHash);s.push({size:d.length,chunks:Eo(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],h=o[l];if(!(!d||!h))for(let u=0;u<n.length;u++){let m=n[u],p=s[u];if(!m||!p)continue;let g=Pf(h.size,h.chunks,p.size,p.chunks);if(g>=r){let w=Mr(d.path)===Mr(m.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:u})}}}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:h}of i){if(a.has(d)||c.has(h))continue;a.add(d),c.add(h);let u=t[d],m=n[h];!u||!m||f.push({oldPath:u.path,newPath:m.path,oldHash:u.oldHash??"",newHash:m.newHash??"",similarity:l,oldMode:u.oldMode,newMode:m.newMode})}return f}function hn(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),h=e.slice(0,o),u=e.slice(n-a),m=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${h}{${m} => ${p}}${u}`:`${e} => ${t}`}De();et();async function ot(e,t){let n=await Q(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Xi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Yi(e,c,i,a),d=await wt(e,i),h=[],u=[];for(let g of d)g.status==="untracked"?u.push(g.path):h.push({path:g.path,status:g.status});h.sort((g,w)=>Te(g.path,w.path));let m=new Set(i.entries.map(g=>g.path)),p=Zi(u,m);return Gh(e,r,s,o,i,l,h,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function $f(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Gh(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,h=await B(e,"CHERRY_PICK_HEAD"),u=await B(e,"REVERT_HEAD"),m=await B(e,"MERGE_HEAD"),p=!h&&!m,w=await Ut(e)?await kt(e):null;if(n&&w){let C=Z(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await ps(e);if(C){let $=t===C?"at":"from";l.push(`HEAD detached ${$} ${Z(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);let b=f?.isInitial??!t;if(!n&&!w&&!b){let C=await pe(e),$=await Bt(e,C,r);if($){let D=zn($,{abbreviated:f?.fromCommit});for(let P of D.trimEnd().split(`
111
+ `))l.push(P);d=!0}}if(d&&(w||h||u||m)&&l.push(""),w&&m)$f(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 C=Gt(o),$=await e.fs.exists(v(e.gitDir,"MERGE_MSG"));$f(l,w);let P=w.headName==="detached HEAD"?null:Pe(w.headName),T=Z(w.onto),H=P?` branch '${P}' on '${T}'`:"";if(C)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($)l.push(`You are currently rebasing${H}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let M=H?`You are currently editing a commit while rebasing${H}.`:"You are currently editing a commit during a rebase.";l.push(M),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 h?(l.push(`You are currently cherry-picking commit ${Z(h)}.`),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):u?(l.push(`You are currently reverting commit ${Z(u)}.`),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):m&&(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 Tt(e)){let $=(await $e(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${$}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}b&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let y=null;p&&(y=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(C=>C.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',R=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),y&&l.push(y);for(let C of s)l.push(` ${Of(C.status,C.path,C.displayPath)}`);l.push(""),R=!0}if(a.length>0){!R&&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($=>$.status==="deleted by us"||$.status==="deleted by them"||$.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 $ of a)l.push(` ${Lh($.status,$.path)}`);l.push(""),R=!0}if(i.length>0){!R&&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 C of i)l.push(` ${Of(C.status,C.path)}`);l.push(""),R=!0}if(c.length>0){!R&&d&&l.push(""),l.push("Untracked files:"),l.push(' (use "git add <file>..." to include in what will be committed)');for(let C of c)l.push(` ${C}`);l.push(""),R=!0}let E=s.length>0||!!m&&a.length===0;return!R&&d&&(f?.noWarn||E)&&l.push(""),!E&&!f?.noWarn&&(!R&&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)'):b?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
112
112
  `)}
113
- `}async function Yi(e,t,n,r){let o=new Set(r?.map(u=>u.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await de(e,s),a=new Map(Ne(n).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(o.has(u))continue;let p=i.get(u);p?p.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:p.hash,newHash:m.hash,oldMode:p.mode,newMode:m.mode.toString(8).padStart(6,"0")}):c.push({path:u,status:"added",newHash:m.hash,newMode:m.mode.toString(8).padStart(6,"0")})}for(let[u,m]of i)o.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await ot(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},h=[];for(let u of f){let m=d[u.status];m&&h.push({path:u.path,status:m})}for(let u of l)h.push({path:u.newPath,status:"renamed",displayPath:`${u.oldPath} -> ${u.newPath}`});return h.sort((u,m)=>Te(u.path,m.path))}function Xi(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)=>Te(r.path,o.path))}function Zi(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 Of(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Lh(e,t){return`${e}:`.padEnd(17)+t}async function Bt(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 B(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await B(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 Wi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function ko(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function Vn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
113
+ `}async function Yi(e,t,n,r){let o=new Set(r?.map(u=>u.path)),s=null;t&&(s=(await G(e,t)).tree);let i=await de(e,s),a=new Map(Ne(n).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(o.has(u))continue;let p=i.get(u);p?p.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:p.hash,newHash:m.hash,oldMode:p.mode,newMode:m.mode.toString(8).padStart(6,"0")}):c.push({path:u,status:"added",newHash:m.hash,newMode:m.mode.toString(8).padStart(6,"0")})}for(let[u,m]of i)o.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await st(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},h=[];for(let u of f){let m=d[u.status];m&&h.push({path:u.path,status:m})}for(let u of l)h.push({path:u.newPath,status:"renamed",displayPath:`${u.oldPath} -> ${u.newPath}`});return h.sort((u,m)=>Te(u.path,m.path))}function Xi(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)=>Te(r.path,o.path))}function Zi(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 Of(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Lh(e,t){return`${e}:`.padEnd(17)+t}async function Bt(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 B(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await B(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 Wi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function ko(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 zn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
114
114
  (use "git branch --unset-upstream" to fixup)
115
115
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
116
116
  `;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}.
@@ -120,17 +120,17 @@ GIT_AUTHOR_DATE='${o}'
120
120
  `}let n=`Your branch and '${e.upstream}' have diverged,
121
121
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
122
122
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
123
- `}Rn();De();Jt();tt();async function Ro(e){let t=await et(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 B(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function On(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
123
+ `}kn();De();Jt();et();async function Ro(e){let t=await Qe(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 B(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function $n(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
124
124
  `),await B(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
125
125
  `),await dr(e),t}function Nh(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(`
126
126
  `)}
127
- `:""}function Yn(e){return e.entries.some(t=>t.stage>0)?{stdout:Nh(e),stderr:`error: you need to resolve your current index first
128
- `,exitCode:1}:null}async function xo(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");if(r)return _h(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?_(`error: path '${t[0]}' is unmerged
127
+ `:""}function Vn(e){return e.entries.some(t=>t.stage>0)?{stdout:Nh(e),stderr:`error: you need to resolve your current index first
128
+ `,exitCode:1}:null}async function xo(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");if(r)return _h(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?_(`error: path '${t[0]}' is unmerged
129
129
  `):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
130
130
  `);for(let a of i)await lt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function _h(e,t,n,r){let o=await de(e,r),s=await z(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)Ee(i,c)&&a.push(c);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
131
- `);for(let c of a){let f=o.get(c);f&&(await lt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Pt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:ve()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function Co(e,t,n,r,o){if(!e.workTree)return T("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await z(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)Ee(a,f.path)&&c.add(f.path);if(c.size===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
131
+ `);for(let c of a){let f=o.get(c);f&&(await lt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Pt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:ve()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function Co(e,t,n,r,o){if(!e.workTree)return S("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await z(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)Ee(a,f.path)&&c.add(f.path);if(c.size===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
132
132
  `);for(let f of c){let l=i.entries.find(u=>u.path===f&&u.stage===r),d=!l&&i.entries.find(u=>u.path===f&&u.stage===0),h=l||d;if(h)await lt(e,{path:h.path,hash:h.hash,mode:h.mode});else if(s){let u=v(e.workTree,f);await e.fs.exists(u)&&await e.fs.rm(u)}else if(i.entries.some(m=>m.path===f&&m.stage>0))return _(`error: path '${f}' does not have ${r===2?"our":"their"} version
133
- `)}return{stdout:"",stderr:"",exitCode:0}}async function ur(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)Un(c.mode)||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=v(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 gt("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(`
133
+ `)}return{stdout:"",stderr:"",exitCode:0}}async function ur(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)Fn(c.mode)||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=v(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 gt("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(`
134
134
  `)}
135
135
  `)}var If=5;function Fh(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>If?If-1:t,i=e.slice(0,o).map(c=>` ${Z(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
136
136
  any of your branches:
@@ -143,10 +143,10 @@ to do so with:
143
143
 
144
144
  git branch <new-branch-name> ${Z(e[0].hash)}
145
145
 
146
- `}async function Ji(e,t){let n=await j(e,t);return`Previous HEAD position was ${Z(t)} ${ue(n.message)}
146
+ `}async function Ji(e,t){let n=await G(e,t);return`Previous HEAD position was ${Z(t)} ${ue(n.message)}
147
147
  `}async function Po(e,t,n){let r=await qi(e,t,{targetHash:n});return r.length>0?Fh(r):t!==n?Ji(e,t):""}async function hr(e,t,n,r,o,s,i){let a=await Q(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
148
- `,exitCode:0};let c=await z(e),f=Yn(c);if(f)return f;let l=await X(e),h=(await j(e,r)).tree,u=null;if(l&&(u=(await j(e,l)).tree),u!==h){let R=await Wn(e,u,h,c);if(!R.success)return R.errorOutput??_("error: checkout would overwrite local changes");c={version:2,entries:R.newEntries},await ae(e,c),await je(e,R.worktreeOps)}let m="";a?.type==="direct"&&l&&(m=await Po(e,l,r));let p=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):l??te;await Ze(e,"HEAD",n),await Et(e);let g=await On(e);await se(e,o,"HEAD",l,r,`checkout: moving from ${p} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:r,isBranchCheckout:!0});let w=await ur(e,h,c),b=await he(e),k=await Bt(e,b,t);return k&&(w+=Vn(k)),{stdout:w,stderr:`${m}Switched to ${i?.isNew?"a new ":""}branch '${t}'
149
- ${g}`,exitCode:0}}async function Xn(e,t,n,r,o){let s=await z(e),i=Yn(s);if(i)return i;let a=await X(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let k=await Wn(e,l,f,s);if(!k.success)return k.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:k.newEntries},await ae(e,s),await je(e,k.worktreeOps)}let d=await Q(e),h=d?.type==="direct"&&a===t;if(await J(e,"HEAD",t),!h){await mf(e,t);let k=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??te;await se(e,n,"HEAD",a,t,`checkout: moving from ${k} to ${t}`)}let u=await On(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let m=Z(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Po(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${m} ${p}
148
+ `,exitCode:0};let c=await z(e),f=Vn(c);if(f)return f;let l=await X(e),h=(await G(e,r)).tree,u=null;if(l&&(u=(await G(e,l)).tree),u!==h){let x=await Bn(e,u,h,c);if(!x.success)return x.errorOutput??_("error: checkout would overwrite local changes");c={version:2,entries:x.newEntries},await ae(e,c),await je(e,x.worktreeOps)}let m="";a?.type==="direct"&&l&&(m=await Po(e,l,r));let p=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):l??te;await Ze(e,"HEAD",n),await Et(e);let g=await $n(e);await ne(e,o,"HEAD",l,r,`checkout: moving from ${p} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:r,isBranchCheckout:!0});let w=await ur(e,h,c),b=await pe(e),y=await Bt(e,b,t);return y&&(w+=zn(y)),{stdout:w,stderr:`${m}Switched to ${i?.isNew?"a new ":""}branch '${t}'
149
+ ${g}`,exitCode:0}}async function Yn(e,t,n,r,o){let s=await z(e),i=Vn(s);if(i)return i;let a=await X(e),c=await G(e,t),f=c.tree,l=null;if(a&&(l=(await G(e,a)).tree),l!==f){let y=await Bn(e,l,f,s);if(!y.success)return y.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:y.newEntries},await ae(e,s),await je(e,y.worktreeOps)}let d=await Q(e),h=d?.type==="direct"&&a===t;if(await J(e,"HEAD",t),!h){await mf(e,t);let y=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??te;await ne(e,n,"HEAD",a,t,`checkout: moving from ${y} to ${t}`)}let u=await $n(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let m=Z(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Po(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${m} ${p}
150
150
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
151
151
 
152
152
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -165,93 +165,93 @@ Or undo this operation with:
165
165
  Turn off this advice by setting config variable advice.detachedHead to false
166
166
 
167
167
  HEAD is now at ${m} ${p}
168
- `,w+=u,{stdout:await ur(e,f,s),stderr:w,exitCode:0}}async function Uh(e,t){if(t.startsWith("refs/remotes/")){if(!await B(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 B(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 $o(e,t,n){let r=await Uh(e,n);if(!r||await xe(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 Xe(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
169
- `}async function Oo(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 xe(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}ie();pe();we();fn();var Sf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ws={stdout:`You need to start by "git bisect start"
170
- `,stderr:"",exitCode:1};async function Qi(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||T("no current commit")}function Tf(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]
171
- `,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:zh(a,o.env,t,s,i)}});Bh(n,t),Wh(n,t),Kh(n,t),Vh(n,t),Xh(n,t),Zh(n,t),Qh(n,t),tm(n,t),nm(n,t)}function Bh(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Y.string().describe("Alternate term for new/bad"),"term-bad":Y.string().describe("Alternate term for new/bad"),"term-old":Y.string().describe("Alternate term for old/good"),"term-good":Y.string().describe("Alternate term for old/good"),"no-checkout":S().describe("Do not checkout the bisection commit"),"first-parent":S().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ve(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 Sf.has(a)?T(`'${a}' is not a valid term`):Sf.has(c)?T(`'${c}' is not a valid term`):a===c?T("'bad' and 'good' terms must be different"):vf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function vf(e,t,n,r,o,s,i,a){await Tt(e)&&await go(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await Me(e,"BISECT_START",f+`
168
+ `,w+=u,{stdout:await ur(e,f,s),stderr:w,exitCode:0}}async function Uh(e,t){if(t.startsWith("refs/remotes/")){if(!await B(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 B(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 $o(e,t,n){let r=await Uh(e,n);if(!r||await xe(e,"branch.autoSetupMerge")==="false")return"";let s=await pe(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await ze(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
169
+ `}async function Oo(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 xe(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}ie();me();we();cn();var Sf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),bs={stdout:`You need to start by "git bisect start"
170
+ `,stderr:"",exitCode:1};async function Qi(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||S("no current commit")}function Tf(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[K.string().name("subcommand").describe("Subcommand or custom term").optional(),K.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]
171
+ `,exitCode:1};let i=r.rest??[],a=await q(o.fs,o.cwd,t);return j(a)?a:Kh(a,o.env,t,s,i)}});Bh(n,t),Wh(n,t),zh(n,t),Vh(n,t),Xh(n,t),Zh(n,t),Qh(n,t),tm(n,t),nm(n,t)}function Bh(e,t){e.command("start",{description:"Start bisecting",args:[K.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Y.string().describe("Alternate term for new/bad"),"term-bad":Y.string().describe("Alternate term for new/bad"),"term-old":Y.string().describe("Alternate term for old/good"),"term-good":Y.string().describe("Alternate term for old/good"),"no-checkout":I().describe("Do not checkout the bisection commit"),"first-parent":I().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=Ye(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 Sf.has(a)?S(`'${a}' is not a valid term`):Sf.has(c)?S(`'${c}' is not a valid term`):a===c?S("'bad' and 'good' terms must be different"):vf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function vf(e,t,n,r,o,s,i,a){await Tt(e)&&await go(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await Me(e,"BISECT_START",f+`
172
172
  `),await Me(e,"BISECT_TERMS",`${o}
173
173
  ${s}
174
174
  `),await Me(e,"BISECT_NAMES",`
175
- `),a&&await Me(e,"BISECT_FIRST_PARENT",""),i){let h=await X(e);h&&await Me(e,"BISECT_HEAD",h)}if(r.length>0){let h=r[0],u=await bt(e,h);if(M(u))return u;await J(e,`refs/bisect/${o}`,u);let m=await j(e,u);await vt(e,`# ${o}: [${u}] ${ue(m.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await bt(e,g);if(M(w))return w;await J(e,`refs/bisect/${s}-${w}`,w);let b=await j(e,w);await vt(e,`# ${s}: [${w}] ${ue(b.message)}`)}}let l=r.map(h=>`'${h}'`),d=l.length>0?` ${l.join(" ")}`:"";return await vt(e,`git bisect start${d}`),bs(e,t,n)}function Wh(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:qh(s,o.env,t,n,r.rev)}})}async function qh(e,t,n,r,o){if(!await Tt(e))return ws;let s=await ps(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return gs(e,t,n,i,s,o)}async function zh(e,t,n,r,o){if(!await Tt(e))return ws;let s=await ps(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
176
- `,exitCode:1}:gs(e,t,n,r,s,o[0])}async function gs(e,t,n,r,o,s){let i;if(s){let f=await bt(e,s);if(M(f))return f;i=f}else{let f=await Qi(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await J(e,`refs/bisect/${o.termBad}`,i):await J(e,`refs/bisect/${o.termGood}-${i}`,i),await vt(e,`# ${r}: [${i}] ${c}`),await vt(e,`git bisect ${r} ${i}`),bs(e,t,n)}function Kh(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 Tt(s))return ws;let i=n.revs??[];if(i.length===0){let a=await Qi(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 bt(s,a);if(M(l))return l;c=l}await J(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await vt(s,`# skip: [${c}] ${ue(f.message)}`),await vt(s,`git bisect skip ${c}`)}return bs(s,r.env,t)}})}function Vh(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 Tt(s)?Yh(s,r.env,t,n.commit):{stdout:`We are not bisecting.
177
- `,stderr:"",exitCode:0}}})}async function Yh(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await go(e),r){let s=await bt(e,r);return M(s)?s:Xn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return hr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Xn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Xh(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 Tt(s)?{stdout:await $e(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
178
- `,exitCode:1}}})}function Zh(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:v(r.cwd,n.logfile);if(!await r.fs.exists(i))return T(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Jh(s,r.env,t,a)}})}async function Jh(e,t,n,r){await Tt(e)&&await go(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
179
- `)){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 h=l?l.split(/\s+/).map(u=>u.replace(/^'|'$/g,"")):[];d=await vf(e,t,n,h,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await gs(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await gs(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let h of l?l.split(/\s+/):[]){await J(e,`refs/bisect/skip-${h}`,h);let u=await j(e,h);await vt(e,`# skip: [${h}] ${ue(u.message)}`),await vt(e,`git bisect skip ${h}`)}d=await bs(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Qh(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 Tt(s))return ws;if(!r.exec)return T("bisect run requires shell execution support");let i=n.cmd.join(" ");return em(s,r.env,t,i,r.exec,r.cwd)}})}async function em(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
180
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let h=await Qi(e);if(M(h))return h;await J(e,`refs/bisect/skip-${h}`,h);let u=await j(e,h);await vt(e,`# skip: [${h}] ${ue(u.message)}`),await vt(e,`git bisect skip ${h}`);let m=await bs(e,t,n);if(i+=m.stdout,m.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
181
- `,{stdout:i,stderr:"",exitCode:0};if(m.exitCode!==0)return{stdout:i,stderr:m.stderr,exitCode:m.exitCode};continue}let f=await po(e),l=c===0?f.termGood:f.termBad,d=await gs(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
182
- `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function tm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":S().describe("Show the term for the old state"),"term-bad":S().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return{stdout:"",stderr:`error: no terms defined
183
- `,exitCode:1};let{termBad:i,termGood:a}=await ps(s);return n["term-good"]?{stdout:`${a}
175
+ `),a&&await Me(e,"BISECT_FIRST_PARENT",""),i){let h=await X(e);h&&await Me(e,"BISECT_HEAD",h)}if(r.length>0){let h=r[0],u=await bt(e,h);if(j(u))return u;await J(e,`refs/bisect/${o}`,u);let m=await G(e,u);await vt(e,`# ${o}: [${u}] ${ue(m.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await bt(e,g);if(j(w))return w;await J(e,`refs/bisect/${s}-${w}`,w);let b=await G(e,w);await vt(e,`# ${s}: [${w}] ${ue(b.message)}`)}}let l=r.map(h=>`'${h}'`),d=l.length>0?` ${l.join(" ")}`:"";return await vt(e,`git bisect start${d}`),ys(e,t,n)}function Wh(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:[K.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:qh(s,o.env,t,n,r.rev)}})}async function qh(e,t,n,r,o){if(!await Tt(e))return bs;let s=await gs(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ws(e,t,n,i,s,o)}async function Kh(e,t,n,r,o){if(!await Tt(e))return bs;let s=await gs(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
176
+ `,exitCode:1}:ws(e,t,n,r,s,o[0])}async function ws(e,t,n,r,o,s){let i;if(s){let f=await bt(e,s);if(j(f))return f;i=f}else{let f=await Qi(e);if(j(f))return f;i=f}let a=await G(e,i),c=ue(a.message);return r===o.termBad?await J(e,`refs/bisect/${o.termBad}`,i):await J(e,`refs/bisect/${o.termGood}-${i}`,i),await vt(e,`# ${r}: [${i}] ${c}`),await vt(e,`git bisect ${r} ${i}`),ys(e,t,n)}function zh(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[K.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(!await Tt(s))return bs;let i=n.revs??[];if(i.length===0){let a=await Qi(s);if(j(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 bt(s,a);if(j(l))return l;c=l}await J(s,`refs/bisect/skip-${c}`,c);let f=await G(s,c);await vt(s,`# skip: [${c}] ${ue(f.message)}`),await vt(s,`git bisect skip ${c}`)}return ys(s,r.env,t)}})}function Vh(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[K.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;return await Tt(s)?Yh(s,r.env,t,n.commit):{stdout:`We are not bisecting.
177
+ `,stderr:"",exitCode:0}}})}async function Yh(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await go(e),r){let s=await bt(e,r);return j(s)?s:Yn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return hr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Yn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Xh(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;return await Tt(s)?{stdout:await $e(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
178
+ `,exitCode:1}}})}function Zh(e,t){e.command("replay",{description:"Replay a bisect log",args:[K.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:v(r.cwd,n.logfile);if(!await r.fs.exists(i))return S(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Jh(s,r.env,t,a)}})}async function Jh(e,t,n,r){await Tt(e)&&await go(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
179
+ `)){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 h=l?l.split(/\s+/).map(u=>u.replace(/^'|'$/g,"")):[];d=await vf(e,t,n,h,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ws(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ws(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let h of l?l.split(/\s+/):[]){await J(e,`refs/bisect/skip-${h}`,h);let u=await G(e,h);await vt(e,`# skip: [${h}] ${ue(u.message)}`),await vt(e,`git bisect skip ${h}`)}d=await ys(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Qh(e,t){e.command("run",{description:"Bisect by running a command",args:[K.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(!await Tt(s))return bs;if(!r.exec)return S("bisect run requires shell execution support");let i=n.cmd.join(" ");return em(s,r.env,t,i,r.exec,r.cwd)}})}async function em(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
180
+ `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let h=await Qi(e);if(j(h))return h;await J(e,`refs/bisect/skip-${h}`,h);let u=await G(e,h);await vt(e,`# skip: [${h}] ${ue(u.message)}`),await vt(e,`git bisect skip ${h}`);let m=await ys(e,t,n);if(i+=m.stdout,m.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
181
+ `,{stdout:i,stderr:"",exitCode:0};if(m.exitCode!==0)return{stdout:i,stderr:m.stderr,exitCode:m.exitCode};continue}let f=await po(e),l=c===0?f.termGood:f.termBad,d=await ws(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
182
+ `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function tm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":I().describe("Show the term for the old state"),"term-bad":I().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(!await Tt(s))return{stdout:"",stderr:`error: no terms defined
183
+ `,exitCode:1};let{termBad:i,termGood:a}=await gs(s);return n["term-good"]?{stdout:`${a}
184
184
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
185
185
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
186
186
  and ${i} for the new state.
187
- `,stderr:"",exitCode:0}}})}function nm(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 Tt(i))return ws;let a=await po(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
187
+ `,stderr:"",exitCode:0}}})}function nm(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 q(o.fs,o.cwd,t);if(j(s))return s;let i=s;if(!await Tt(i))return bs;let a=await po(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
188
188
  `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(lr(),hf)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${Z(l.hash)} ${ue(l.commit.message)}
189
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function bs(e,t,n){let r=await po(e);return!r.badHash||r.goodHashes.length===0?{stdout:gf(r),stderr:"",exitCode:0}:(await Me(e,"BISECT_ANCESTORS_OK",""),rm(e,t,n,r))}async function rm(e,t,n,r){let o=await pf(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
189
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function ys(e,t,n){let r=await po(e);return!r.badHash||r.goodHashes.length===0?{stdout:gf(r),stderr:"",exitCode:0}:(await Me(e,"BISECT_ANCESTORS_OK",""),rm(e,t,n,r))}async function rm(e,t,n,r){let o=await pf(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
190
190
  `,exitCode:1};if(o.found){let s=await bf(e,o.hash);return await vt(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.
191
191
  The first bad commit could be any of:
192
192
  `;for(let i of r.skipHashes)s+=i+`
193
193
  `;return r.badHash&&(s+=r.badHash+`
194
194
  `),s+=`We cannot bisect more!
195
- `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Me(e,"BISECT_HEAD",o.hash);else{let s=await Xn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Me(e,"BISECT_EXPECTED_REV",o.hash+`
195
+ `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Me(e,"BISECT_HEAD",o.hash);else{let s=await Yn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Me(e,"BISECT_EXPECTED_REV",o.hash+`
196
196
  `),{stdout:wf(o),stderr:"",exitCode:0}}oe();ie();function Wt(e){if(e.length===0)return[];let t=e.split(`
197
197
  `);return t[t.length-1]===""&&t.pop(),t}function xt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
198
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var sm=4,Hf=1024,Io=100,vo=0,So=1,Mr=2;function ta(e){let t=1;for(;t*t<e;)t++;return t}function om(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 im(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 Af(e,t,n,r){t-n>Io&&(n=t-Io),r-t>Io&&(r=t+Io);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===vo)o++;else if(f===Mr)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===vo)i++;else if(f===Mr)a++;else break}return i===0?!1:(i+=o,a+=s,a*sm<a+i)}function am(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),h=Math.min(ta(t),Hf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=vo:w>=h?l[g]=Mr:l[g]=So}let u=Math.min(ta(r),Hf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=vo:w>=u?d[g]=Mr:d[g]=So}let m=[];for(let g=s;g<=i;g++)l[g]===So||l[g]===Mr&&!Af(l,g,s,i)?m.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===So||d[g]===Mr&&!Af(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:m,nreff1:m.length,refIndex2:p,nreff2:p.length}}var Zn=20,Df=4,cm=256,fm=256,To=2147483647;function Rt(e,t){return e[t]??0}function lm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,h=t-o,u=n-s,m=h-u&1,p=h,g=h,w=u,b=u;i[h]=t,a[u]=n;for(let k=1;;k++){let R=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let C=g;C>=p;C-=2){let E;Rt(i,C-1)>=Rt(i,C+1)?E=Rt(i,C-1)+1:E=Rt(i,C+1);let y=E,x=E-C;for(;E<n&&x<s&&e[E]===r[x];)E++,x++;if(E-y>Zn&&(R=!0),i[C]=E,m&&w<=C&&C<=b&&Rt(a,C)<=E)return{i1:E,i2:x,minLo:!0,minHi:!0}}w>l?a[--w-1]=To:++w,b<d?a[++b+1]=To:--b;for(let C=b;C>=w;C-=2){let E;Rt(a,C-1)<Rt(a,C+1)?E=Rt(a,C-1):E=Rt(a,C+1)-1;let y=E,x=E-C;for(;E>t&&x>o&&e[E-1]===r[x-1];)E--,x--;if(y-E>Zn&&(R=!0),a[C]=E,!m&&p<=C&&C<=g&&E<=Rt(i,C))return{i1:E,i2:x,minLo:!0,minHi:!0}}if(!c){if(R&&k>cm){let C=0,E=null;for(let y=g;y>=p;y-=2){let x=y>h?y-h:h-y,$=Rt(i,y),A=$-y,P=$-t+(A-o)-x;if(P>Df*k&&P>C&&t+Zn<=$&&$<n&&o+Zn<=A&&A<s){let O=!0;for(let D=1;D<=Zn;D++)if(e[$-D]!==r[A-D]){O=!1;break}O&&(C=P,E={i1:$,i2:A,minLo:!0,minHi:!1})}}if(E)return E;C=0,E=null;for(let y=b;y>=w;y-=2){let x=y>u?y-u:u-y,$=Rt(a,y),A=$-y,P=n-$+(s-A)-x;if(P>Df*k&&P>C&&t<$&&$<=n-Zn&&o<A&&A<=s-Zn){let O=!0;for(let D=0;D<Zn;D++)if(e[$+D]!==r[A+D]){O=!1;break}O&&(C=P,E={i1:$,i2:A,minLo:!1,minHi:!0})}}if(E)return E}if(k>=f){let C=-1,E=-1;for(let $=g;$>=p;$-=2){let A=Math.min(Rt(i,$),n),P=A-$;s<P&&(A=s+$,P=s),C<A+P&&(C=A+P,E=A)}let y=To,x=To;for(let $=b;$>=w;$-=2){let A=Math.max(t,Rt(a,$)),P=A-$;P<o&&(A=o+$,P=o),A+P<y&&(y=A+P,x=A)}return n+s-y<C-(t+o)?{i1:E,i2:C-E,minLo:!0,minHi:!1}:{i1:x,i2:y-x,minLo:!1,minHi:!0}}}}}function na(e,t,n,r,o,s,i,a,c,f,l,d,h,u){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 m=o;m<s;m++)a[f[m]]=1;else if(o===s)for(let m=t;m<n;m++)i[c[m]]=1;else{let m=lm(e,t,n,r,o,s,l,d,h,u);na(e,t,m.i1,r,o,m.i2,i,a,c,f,l,d,m.minLo,u),na(e,m.i1,n,r,m.i2,s,i,a,c,f,l,d,m.minHi,u)}}function dm(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 Mf=200,jf=20,Gf=100,um=1,hm=21,mm=-30,pm=6,gm=-4,wm=10,bm=24,ym=17,Em=23,km=17,Rm=60;function ea(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>=Mf)return Mf}return-1}function Lf(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=ea(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ea(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===jf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ea(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===jf){r.postIndent=0;break}return r}function Nf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=um),e.endOfFile&&(t.penalty+=hm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=mm*r,t.penalty+=pm*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?wm:gm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?ym:bm:t.penalty+=s?km:Em))}function xm(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Rm*n+(e.penalty-t.penalty)}function _f(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,h)=>t[d]===t[h];for(;;){if(a!==i){let d,h,u;do{for(d=a-i,h=-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(u=a,f>c&&(h=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&&(h=a)}}while(d!==a-i);if(a!==u)if(h!==-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 m=-1,p={effectiveIndent:0,penalty:0},g=u;for(a-d-1>g&&(g=a-d-1),a-Gf>g&&(g=a-Gf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Lf(n,r,g);Nf(b,w);let k=Lf(n,r,g-d);Nf(k,w),(m===-1||xm(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},m=g)}for(;a>m;){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 ra(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}=om(e,t),{dstart:f,dend1:l,dend2:d}=im(i,n,a,r);if(f>l)for(let h=f;h<r-(n-1-l);h++)s[h]=1;else if(f>d)for(let h=f;h<n-(r-1-d);h++)o[h]=1;else{let{refIndex1:h,nreff1:u,refIndex2:m,nreff2:p}=am(i,n,a,r,c,f,l,d,o,s);if(u>0&&p>0){let g=new Array(u);for(let E=0;E<u;E++)g[E]=i[h[E]];let w=new Array(p);for(let E=0;E<p;E++)w[E]=a[m[E]];let b={},k={},R=u+p+3,C=Math.max(fm,ta(R));na(g,0,u,w,0,p,o,s,h,m,b,k,!1,C)}else if(u===0)for(let g=0;g<p;g++)s[m[g]]=1;else for(let g=0;g<u;g++)o[h[g]]=1;_f(o,i,e,n,s,r),_f(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function at(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}=ra(e,t);return dm(e,t,o,s)}var Cm=3;function Pm(e,t=Cm){if(t=Math.max(0,t),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=>$m(e,a.start,a.end))}function $m(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 Ho(e){return e?e.length<40?e:Z(e):"0000000"}function Ff(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 Om(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==="",h=e.isDeleted??s==="";if(o===s&&!f)return"";let u=[];if(Ff(u,e,l,d,h,f),o!==s){if(a||c){let m=Ho(a),p=Ho(c);d||h||f?u.push(`index ${m}..${p}`):u.push(`index ${m}..${p} ${i||"100644"}`)}t&&n?u.push(`Binary files a/${r} and b/${l} differ`):d?u.push(`Binary files /dev/null and b/${l} differ`):h?u.push(`Binary files a/${r} and /dev/null differ`):u.push(`Binary files a/${r} and b/${l} differ`)}return`${u.join(`
198
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var sm=4,Hf=1024,Io=100,vo=0,So=1,jr=2;function ta(e){let t=1;for(;t*t<e;)t++;return t}function om(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 im(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 Af(e,t,n,r){t-n>Io&&(n=t-Io),r-t>Io&&(r=t+Io);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===vo)o++;else if(f===jr)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===vo)i++;else if(f===jr)a++;else break}return i===0?!1:(i+=o,a+=s,a*sm<a+i)}function am(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),h=Math.min(ta(t),Hf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=vo:w>=h?l[g]=jr:l[g]=So}let u=Math.min(ta(r),Hf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=vo:w>=u?d[g]=jr:d[g]=So}let m=[];for(let g=s;g<=i;g++)l[g]===So||l[g]===jr&&!Af(l,g,s,i)?m.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===So||d[g]===jr&&!Af(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:m,nreff1:m.length,refIndex2:p,nreff2:p.length}}var Xn=20,Df=4,cm=256,fm=256,To=2147483647;function Rt(e,t){return e[t]??0}function lm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,h=t-o,u=n-s,m=h-u&1,p=h,g=h,w=u,b=u;i[h]=t,a[u]=n;for(let y=1;;y++){let x=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let R;Rt(i,k-1)>=Rt(i,k+1)?R=Rt(i,k-1)+1:R=Rt(i,k+1);let E=R,C=R-k;for(;R<n&&C<s&&e[R]===r[C];)R++,C++;if(R-E>Xn&&(x=!0),i[k]=R,m&&w<=k&&k<=b&&Rt(a,k)<=R)return{i1:R,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=To:++w,b<d?a[++b+1]=To:--b;for(let k=b;k>=w;k-=2){let R;Rt(a,k-1)<Rt(a,k+1)?R=Rt(a,k-1):R=Rt(a,k+1)-1;let E=R,C=R-k;for(;R>t&&C>o&&e[R-1]===r[C-1];)R--,C--;if(E-R>Xn&&(x=!0),a[k]=R,!m&&p<=k&&k<=g&&R<=Rt(i,k))return{i1:R,i2:C,minLo:!0,minHi:!0}}if(!c){if(x&&y>cm){let k=0,R=null;for(let E=g;E>=p;E-=2){let C=E>h?E-h:h-E,$=Rt(i,E),D=$-E,P=$-t+(D-o)-C;if(P>Df*y&&P>k&&t+Xn<=$&&$<n&&o+Xn<=D&&D<s){let T=!0;for(let H=1;H<=Xn;H++)if(e[$-H]!==r[D-H]){T=!1;break}T&&(k=P,R={i1:$,i2:D,minLo:!0,minHi:!1})}}if(R)return R;k=0,R=null;for(let E=b;E>=w;E-=2){let C=E>u?E-u:u-E,$=Rt(a,E),D=$-E,P=n-$+(s-D)-C;if(P>Df*y&&P>k&&t<$&&$<=n-Xn&&o<D&&D<=s-Xn){let T=!0;for(let H=0;H<Xn;H++)if(e[$+H]!==r[D+H]){T=!1;break}T&&(k=P,R={i1:$,i2:D,minLo:!1,minHi:!0})}}if(R)return R}if(y>=f){let k=-1,R=-1;for(let $=g;$>=p;$-=2){let D=Math.min(Rt(i,$),n),P=D-$;s<P&&(D=s+$,P=s),k<D+P&&(k=D+P,R=D)}let E=To,C=To;for(let $=b;$>=w;$-=2){let D=Math.max(t,Rt(a,$)),P=D-$;P<o&&(D=o+$,P=o),D+P<E&&(E=D+P,C=D)}return n+s-E<k-(t+o)?{i1:R,i2:k-R,minLo:!0,minHi:!1}:{i1:C,i2:E-C,minLo:!1,minHi:!0}}}}}function na(e,t,n,r,o,s,i,a,c,f,l,d,h,u){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 m=o;m<s;m++)a[f[m]]=1;else if(o===s)for(let m=t;m<n;m++)i[c[m]]=1;else{let m=lm(e,t,n,r,o,s,l,d,h,u);na(e,t,m.i1,r,o,m.i2,i,a,c,f,l,d,m.minLo,u),na(e,m.i1,n,r,m.i2,s,i,a,c,f,l,d,m.minHi,u)}}function dm(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 Mf=200,jf=20,Gf=100,um=1,hm=21,mm=-30,pm=6,gm=-4,wm=10,bm=24,ym=17,Em=23,km=17,Rm=60;function ea(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>=Mf)return Mf}return-1}function Lf(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=ea(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ea(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===jf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ea(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===jf){r.postIndent=0;break}return r}function Nf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=um),e.endOfFile&&(t.penalty+=hm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=mm*r,t.penalty+=pm*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?wm:gm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?ym:bm:t.penalty+=s?km:Em))}function xm(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Rm*n+(e.penalty-t.penalty)}function _f(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,h)=>t[d]===t[h];for(;;){if(a!==i){let d,h,u;do{for(d=a-i,h=-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(u=a,f>c&&(h=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&&(h=a)}}while(d!==a-i);if(a!==u)if(h!==-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 m=-1,p={effectiveIndent:0,penalty:0},g=u;for(a-d-1>g&&(g=a-d-1),a-Gf>g&&(g=a-Gf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Lf(n,r,g);Nf(b,w);let y=Lf(n,r,g-d);Nf(y,w),(m===-1||xm(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},m=g)}for(;a>m;){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 ra(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}=om(e,t),{dstart:f,dend1:l,dend2:d}=im(i,n,a,r);if(f>l)for(let h=f;h<r-(n-1-l);h++)s[h]=1;else if(f>d)for(let h=f;h<n-(r-1-d);h++)o[h]=1;else{let{refIndex1:h,nreff1:u,refIndex2:m,nreff2:p}=am(i,n,a,r,c,f,l,d,o,s);if(u>0&&p>0){let g=new Array(u);for(let R=0;R<u;R++)g[R]=i[h[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=a[m[R]];let b={},y={},x=u+p+3,k=Math.max(fm,ta(x));na(g,0,u,w,0,p,o,s,h,m,b,y,!1,k)}else if(u===0)for(let g=0;g<p;g++)s[m[g]]=1;else for(let g=0;g<u;g++)o[h[g]]=1;_f(o,i,e,n,s,r),_f(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function it(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=ra(e,t);return dm(e,t,o,s)}var Cm=3;function Pm(e,t=Cm){if(t=Math.max(0,t),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=>$m(e,a.start,a.end))}function $m(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 Ho(e){return e?e.length<40?e:Z(e):"0000000"}function Ff(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 Om(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==="",h=e.isDeleted??s==="";if(o===s&&!f)return"";let u=[];if(Ff(u,e,l,d,h,f),o!==s){if(a||c){let m=Ho(a),p=Ho(c);d||h||f?u.push(`index ${m}..${p}`):u.push(`index ${m}..${p} ${i||"100644"}`)}t&&n?u.push(`Binary files a/${r} and b/${l} differ`):d?u.push(`Binary files /dev/null and b/${l} differ`):h?u.push(`Binary files a/${r} and /dev/null differ`):u.push(`Binary files a/${r} and b/${l} differ`)}return`${u.join(`
199
199
  `)}
200
200
  `}function Ht(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=He(n),d=He(r);if(l||d)return Om(e,l,d);let h=Wt(n),u=Wt(r),m=n.length>0&&n.endsWith(`
201
201
  `),p=r.length>0&&r.endsWith(`
202
- `),g="\0NOEOL",w=h;!m&&h.length>0&&(w=h.slice(),w[w.length-1]+=g);let b=u;!p&&u.length>0&&(b=u.slice(),b[b.length-1]+=g);let k=at(w,b);if(!m||!p)for(let P of k)P.line.includes(g)&&(P.line=P.line.replace(g,""));let R=Pm(k,e.contextLines);if(R.length===0&&!c)return"";let C=e.isNew??n==="",E=e.isDeleted??r==="",y=[];if(Ff(y,e,f,C,E,c),R.length===0)return`${y.join(`
202
+ `),g="\0NOEOL",w=h;!m&&h.length>0&&(w=h.slice(),w[w.length-1]+=g);let b=u;!p&&u.length>0&&(b=u.slice(),b[b.length-1]+=g);let y=it(w,b);if(!m||!p)for(let P of y)P.line.includes(g)&&(P.line=P.line.replace(g,""));let x=Pm(y,e.contextLines);if(x.length===0&&!c)return"";let k=e.isNew??n==="",R=e.isDeleted??r==="",E=[];if(Ff(E,e,f,k,R,c),x.length===0)return`${E.join(`
203
203
  `)}
204
- `;if(i||a){let P=Ho(i),O=Ho(a);C||E?y.push(`index ${P}..${O}`):c?y.push(`index ${P}..${O} ${o||"100644"}`):o&&s&&o!==s?y.push(`index ${P}..${O}`):y.push(`index ${P}..${O} ${o||"100644"}`)}let x=P=>P.includes(" ")?" ":"";C?(y.push("--- /dev/null"),y.push(`+++ b/${f}${x(f)}`)):E?(y.push(`--- a/${t}${x(t)}`),y.push("+++ /dev/null")):(y.push(`--- a/${t}${x(t)}`),y.push(`+++ b/${f}${x(f)}`));let $=h.length,A=u.length;for(let P of R){let O=P.oldCount===1?`${P.oldStart}`:`${P.oldStart},${P.oldCount}`,D=P.newCount===1?`${P.newStart}`:`${P.newStart},${P.newCount}`,L="",K=P.oldCount===0?P.oldStart-1:P.oldStart-2;for(let G=K;G>=0;G--){let F=h[G];if(F&&/^[a-zA-Z$_]/.test(F)){L=` ${F.trimEnd().slice(0,79)}`;break}}y.push(`@@ -${O} +${D} @@${L}`);let I=P.oldStart,H=P.newStart;for(let G of P.lines)switch(G.type){case"context":y.push(` ${G.content}`),(!m&&I===$||!p&&H===A)&&y.push("\"),I++,H++;break;case"delete":y.push(`-${G.content}`),!m&&I===$&&y.push("\"),I++;break;case"insert":y.push(`+${G.content}`),!p&&H===A&&y.push("\"),H++;break}}return`${y.join(`
204
+ `;if(i||a){let P=Ho(i),T=Ho(a);k||R?E.push(`index ${P}..${T}`):c?E.push(`index ${P}..${T} ${o||"100644"}`):o&&s&&o!==s?E.push(`index ${P}..${T}`):E.push(`index ${P}..${T} ${o||"100644"}`)}let C=P=>P.includes(" ")?" ":"";k?(E.push("--- /dev/null"),E.push(`+++ b/${f}${C(f)}`)):R?(E.push(`--- a/${t}${C(t)}`),E.push("+++ /dev/null")):(E.push(`--- a/${t}${C(t)}`),E.push(`+++ b/${f}${C(f)}`));let $=h.length,D=u.length;for(let P of x){let T=P.oldCount===1?`${P.oldStart}`:`${P.oldStart},${P.oldCount}`,H=P.newCount===1?`${P.newStart}`:`${P.newStart},${P.newCount}`,M="",W=P.oldCount===0?P.oldStart-1:P.oldStart-2;for(let L=W;L>=0;L--){let F=h[L];if(F&&/^[a-zA-Z$_]/.test(F)){M=` ${F.trimEnd().slice(0,79)}`;break}}E.push(`@@ -${T} +${H} @@${M}`);let O=P.oldStart,A=P.newStart;for(let L of P.lines)switch(L.type){case"context":E.push(` ${L.content}`),(!m&&O===$||!p&&A===D)&&E.push("\"),O++,A++;break;case"delete":E.push(`-${L.content}`),!m&&O===$&&E.push("\"),O++;break;case"insert":E.push(`+${L.content}`),!p&&A===D&&E.push("\"),A++;break}}return`${E.join(`
205
205
  `)}
206
- `}ie();De();async function Jn(e,t,n){return(await de(e,t)).get(n)?.hash??null}async function Uf(e,t,n,r){let o=await Ke(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await ot(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function Im(e,t,n,r,o,s){let i=await Jn(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,Qn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await re(e,i),c=Wt(a),f=new Array(o.length),l=[...r],d=t,h=n,u=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let $ of l)f[$.finalIdx]=Qn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!0,void 0);break}let g=await Jn(e,p.tree,h),w=null,b=[];for(let $ of p.parents){let A=await j(e,$),P=h,O=await Jn(e,A.tree,P);if(!O){let D=await Uf(e,A.tree,p.tree,h);D&&(P=D,O=await Jn(e,A.tree,P))}if(O&&(b.push({hash:$,path:P,blobHash:O}),O===g)){w={hash:$,path:P};break}}if(w){d=w.hash,h=w.path;continue}if(b.length===0){for(let $ of l)f[$.finalIdx]=Qn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,void 0);break}let k=b[0],R=await re(e,k.blobHash),C=Wt(R),E=at(C,u),y=new Map;for(let $ of E)$.type==="keep"&&y.set($.newLineNo,$.oldLineNo);let x=[];for(let $ of l){let A=y.get($.currentLine);A!==void 0?x.push({finalIdx:$.finalIdx,currentLine:A}):f[$.finalIdx]=Qn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,{hash:k.hash,path:k.path})}l=x,d=k.hash,h=k.path,u=C}let m=new Map;for(let p of r)f[p.finalIdx]&&m.set(p.finalIdx,f[p.finalIdx]);return m}async function Bf(e,t,n,r){let o=await j(e,t),s=await Jn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await re(e,s),a=Wt(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),h=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),u=t,m=n,p=a;for(;h.length>0;){let g=await j(e,u);if(g.parents.length===0){for(let y of h)d[y.finalIdx]=Qn(u,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!0,void 0);break}let w=await Jn(e,g.tree,m),b=[],k=null;for(let y of g.parents){let x=await j(e,y),$=m,A=await Jn(e,x.tree,$);if(!A){let P=await Uf(e,x.tree,g.tree,m);P&&($=P,A=await Jn(e,x.tree,$))}if(A){let P={hash:y,path:$,blobHash:A};if(b.push(P),A===w){k=P;break}}}if(k){u=k.hash,m=k.path;continue}if(b.length===0){for(let y of h)d[y.finalIdx]=Qn(u,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,void 0);break}if(b.length===1){let y=b[0],x=await re(e,y.blobHash),$=Wt(x),A=at($,p),P=new Map;for(let D of A)D.type==="keep"&&P.set(D.newLineNo,D.oldLineNo);let O=[];for(let D of h){let L=P.get(D.currentLine);L!==void 0?O.push({finalIdx:D.finalIdx,currentLine:L}):d[D.finalIdx]=Qn(u,m,D.currentLine,c+D.finalIdx,l[D.finalIdx],g,!1,{hash:y.hash,path:y.path})}h=O,u=y.hash,m=y.path,p=$;continue}let R=[];for(let y of b){let x=await re(e,y.blobHash),$=Wt(x),A=at($,p),P=new Map;for(let O of A)O.type==="keep"&&P.set(O.newLineNo,O.oldLineNo);R.push({info:y,newToOld:P})}let C=new Map;for(let y of h){let x=!1;for(let $=0;$<R.length;$++){let A=R[$],P=A.newToOld.get(y.currentLine);if(P!==void 0){let O=C.get($);O||(O={info:A.info,lines:[]},C.set($,O)),O.lines.push({finalIdx:y.finalIdx,currentLine:P}),x=!0;break}}x||(d[y.finalIdx]=Qn(u,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let E=C.get(0);for(let[y,x]of C){if(y===0)continue;let $=await Im(e,x.info.hash,x.info.path,x.lines,l,c);for(let[A,P]of $)d[A]=P}if(E&&E.lines.length>0){h=E.lines,u=E.info.hash,m=E.info.path;let y=await re(e,E.info.blobHash);p=Wt(y)}else break}return d}function Qn(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(`
207
- `)[0],boundary:i,previous:a}}oe();ie();De();ie();pe();function Sm(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 Tm(e,t){let n=Sm(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 vm(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 h=r?`<${d.author.email}>`:d.author.name;h.length>c&&(c=h.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 h;n?h=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:h=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let u=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${h}${u} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,p=Tm(d.author.timestamp,d.author.timezone);l.push(`${h}${u} (${m.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
206
+ `}ie();De();async function Zn(e,t,n){return(await de(e,t)).get(n)?.hash??null}async function Uf(e,t,n,r){let o=await Ve(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await st(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function Im(e,t,n,r,o,s){let i=await Zn(e,(await G(e,t)).tree,n);if(!i){let p=new Map,g=await G(e,t);for(let w of r)p.set(w.finalIdx,Jn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await se(e,i),c=Wt(a),f=new Array(o.length),l=[...r],d=t,h=n,u=c;for(;l.length>0;){let p=await G(e,d);if(p.parents.length===0){for(let $ of l)f[$.finalIdx]=Jn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!0,void 0);break}let g=await Zn(e,p.tree,h),w=null,b=[];for(let $ of p.parents){let D=await G(e,$),P=h,T=await Zn(e,D.tree,P);if(!T){let H=await Uf(e,D.tree,p.tree,h);H&&(P=H,T=await Zn(e,D.tree,P))}if(T&&(b.push({hash:$,path:P,blobHash:T}),T===g)){w={hash:$,path:P};break}}if(w){d=w.hash,h=w.path;continue}if(b.length===0){for(let $ of l)f[$.finalIdx]=Jn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,void 0);break}let y=b[0],x=await se(e,y.blobHash),k=Wt(x),R=it(k,u),E=new Map;for(let $ of R)$.type==="keep"&&E.set($.newLineNo,$.oldLineNo);let C=[];for(let $ of l){let D=E.get($.currentLine);D!==void 0?C.push({finalIdx:$.finalIdx,currentLine:D}):f[$.finalIdx]=Jn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,{hash:y.hash,path:y.path})}l=C,d=y.hash,h=y.path,u=k}let m=new Map;for(let p of r)f[p.finalIdx]&&m.set(p.finalIdx,f[p.finalIdx]);return m}async function Bf(e,t,n,r){let o=await G(e,t),s=await Zn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await se(e,s),a=Wt(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),h=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),u=t,m=n,p=a;for(;h.length>0;){let g=await G(e,u);if(g.parents.length===0){for(let E of h)d[E.finalIdx]=Jn(u,m,E.currentLine,c+E.finalIdx,l[E.finalIdx],g,!0,void 0);break}let w=await Zn(e,g.tree,m),b=[],y=null;for(let E of g.parents){let C=await G(e,E),$=m,D=await Zn(e,C.tree,$);if(!D){let P=await Uf(e,C.tree,g.tree,m);P&&($=P,D=await Zn(e,C.tree,$))}if(D){let P={hash:E,path:$,blobHash:D};if(b.push(P),D===w){y=P;break}}}if(y){u=y.hash,m=y.path;continue}if(b.length===0){for(let E of h)d[E.finalIdx]=Jn(u,m,E.currentLine,c+E.finalIdx,l[E.finalIdx],g,!1,void 0);break}if(b.length===1){let E=b[0],C=await se(e,E.blobHash),$=Wt(C),D=it($,p),P=new Map;for(let H of D)H.type==="keep"&&P.set(H.newLineNo,H.oldLineNo);let T=[];for(let H of h){let M=P.get(H.currentLine);M!==void 0?T.push({finalIdx:H.finalIdx,currentLine:M}):d[H.finalIdx]=Jn(u,m,H.currentLine,c+H.finalIdx,l[H.finalIdx],g,!1,{hash:E.hash,path:E.path})}h=T,u=E.hash,m=E.path,p=$;continue}let x=[];for(let E of b){let C=await se(e,E.blobHash),$=Wt(C),D=it($,p),P=new Map;for(let T of D)T.type==="keep"&&P.set(T.newLineNo,T.oldLineNo);x.push({info:E,newToOld:P})}let k=new Map;for(let E of h){let C=!1;for(let $=0;$<x.length;$++){let D=x[$],P=D.newToOld.get(E.currentLine);if(P!==void 0){let T=k.get($);T||(T={info:D.info,lines:[]},k.set($,T)),T.lines.push({finalIdx:E.finalIdx,currentLine:P}),C=!0;break}}C||(d[E.finalIdx]=Jn(u,m,E.currentLine,c+E.finalIdx,l[E.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let R=k.get(0);for(let[E,C]of k){if(E===0)continue;let $=await Im(e,C.info.hash,C.info.path,C.lines,l,c);for(let[D,P]of $)d[D]=P}if(R&&R.lines.length>0){h=R.lines,u=R.info.hash,m=R.info.path;let E=await se(e,R.info.blobHash);p=Wt(E)}else break}return d}function Jn(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(`
207
+ `)[0],boundary:i,previous:a}}oe();ie();De();ie();me();function Sm(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 Tm(e,t){let n=Sm(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 vm(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 h=r?`<${d.author.email}>`:d.author.name;h.length>c&&(c=h.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 h;n?h=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:h=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let u=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${h}${u} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,p=Tm(d.author.timestamp,d.author.timezone);l.push(`${h}${u} (${m.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
208
208
  `)}
209
209
  `}function Hm(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(`
210
210
  `)}
211
- `}function Am(e,t,n){if(e.startsWith("/"))return rt(n,e);let r=rt(n,t);return r===""||r==="."?e:`${r}/${e}`}function Wf(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:Y.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:S().alias("l").describe("Show long revision"),showEmail:S().alias("e").describe("Show author email instead of name"),suppress:S().alias("s").describe("Suppress author name and date"),porcelain:S().alias("p").describe("Show in machine-readable format"),linePorcelain:S().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return T("this operation must be run in a work tree");let a=await Qe(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 T("no file specified");let h=Am(d,r.cwd,i.workTree),u;if(l){let E=await bt(i,l);if(M(E))return E;u=await Ae(i,E)}else u=a;let m=await j(i,u),p=await de(i,m.tree);if(!p.has(h))return T(`no such path ${h} in ${l??"HEAD"}`);let g=p.get(h).hash,w=await re(i,g);if(He(w))return T(`cannot blame binary file '${h}'`);let b,k;if(n.lineRange){let E=n.lineRange,y=E.match(/^(\d+),(\d+)$/);if(y)b=parseInt(y[1],10),k=parseInt(y[2],10);else return T(`invalid -L range: '${E}'`)}let R;try{R=await Bf(i,u,h,{startLine:b,endLine:k})}catch(E){let y=E instanceof Error?E.message:String(E);return T(y)}let C;return n.porcelain||n.linePorcelain?C=Hm(R,!!n.linePorcelain):C=vm(R,h,!!n.long,!!n.showEmail,!!n.suppress),{stdout:C,stderr:"",exitCode:0}}})}oe();Be();Hn();oe();var Dm=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Mm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function In(e,t){let n=jm(t),r=new Date((e+n*60)*1e3),o=Dm[r.getUTCDay()],s=Mm[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 sa(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 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)}ie();De();var Ao=new TextDecoder;function qf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
211
+ `}function Am(e,t,n){if(e.startsWith("/"))return nt(n,e);let r=nt(n,t);return r===""||r==="."?e:`${r}/${e}`}function Wf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[K.string().name("args").variadic().optional()],options:{lineRange:Y.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:I().alias("l").describe("Show long revision"),showEmail:I().alias("e").describe("Show author email instead of name"),suppress:I().alias("s").describe("Suppress author name and date"),porcelain:I().alias("p").describe("Show in machine-readable format"),linePorcelain:I().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s;if(!i.workTree)return S("this operation must be run in a work tree");let a=await Je(i);if(j(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 S("no file specified");let h=Am(d,r.cwd,i.workTree),u;if(l){let R=await bt(i,l);if(j(R))return R;u=await Ae(i,R)}else u=a;let m=await G(i,u),p=await de(i,m.tree);if(!p.has(h))return S(`no such path ${h} in ${l??"HEAD"}`);let g=p.get(h).hash,w=await se(i,g);if(He(w))return S(`cannot blame binary file '${h}'`);let b,y;if(n.lineRange){let R=n.lineRange,E=R.match(/^(\d+),(\d+)$/);if(E)b=parseInt(E[1],10),y=parseInt(E[2],10);else return S(`invalid -L range: '${R}'`)}let x;try{x=await Bf(i,u,h,{startLine:b,endLine:y})}catch(R){let E=R instanceof Error?R.message:String(R);return S(E)}let k;return n.porcelain||n.linePorcelain?k=Hm(x,!!n.linePorcelain):k=vm(x,h,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}oe();Be();nr();oe();var Dm=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Mm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function On(e,t){let n=jm(t),r=new Date((e+n*60)*1e3),o=Dm[r.getUTCDay()],s=Mm[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 sa(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 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)}ie();De();var Ao=new TextDecoder;function qf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
212
212
  `&&t++;return e[e.length-1]!==`
213
- `&&t++,t}function er(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 tr(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Ot(e,a.newHash);jn(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:qf(Ao.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Ot(e,a.oldHash);jn(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:qf(Ao.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Ot(e,a.oldHash),f=await Ot(e,a.newHash);if(jn(c)||jn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=xt(Ao.decode(c)),d=xt(Ao.decode(f)),h=at(l,d),u=0,m=0;for(let p of h)p.type==="insert"?u++:p.type==="delete"&&m++;r.push({path:a.path,sortKey:a.path,insertions:u,deletions:m})}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 re(e,a.oldHash),h=await re(e,a.newHash);if(!He(d)&&!He(h)){let u=xt(d),m=xt(h),p=at(u,m);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 pn(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: ${In(r.timestamp,r.timezone)}`),i)return a.join(`
213
+ `&&t++,t}function Qn(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 er(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Ot(e,a.newHash);Mn(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:qf(Ao.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Ot(e,a.oldHash);Mn(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:qf(Ao.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Ot(e,a.oldHash),f=await Ot(e,a.newHash);if(Mn(c)||Mn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=xt(Ao.decode(c)),d=xt(Ao.decode(f)),h=it(l,d),u=0,m=0;for(let p of h)p.type==="insert"?u++:p.type==="delete"&&m++;r.push({path:a.path,sortKey:a.path,insertions:u,deletions:m})}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=hn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await se(e,a.oldHash),h=await se(e,a.newHash);if(!He(d)&&!He(h)){let u=xt(d),m=xt(h),p=it(u,m);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=hn(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 mn(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: ${On(r.timestamp,r.timezone)}`),i)return a.join(`
214
214
  `)+(a.length>0?`
215
- `:"");let c=await Ke(e,t,n),{remaining:f,renames:l}=await ot(e,c),{fileStats:d,modeLines:h}=await tr(e,f,l),u=0,m=0;for(let g of d)u+=g.insertions,m+=g.deletions;let p=er(d.length,u,m);p&&a.push(p);for(let g of h)a.push(g);return a.join(`
215
+ `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await st(e,c),{fileStats:d,modeLines:h}=await er(e,f,l),u=0,m=0;for(let g of d)u+=g.insertions,m+=g.deletions;let p=Qn(d.length,u,m);p&&a.push(p);for(let g of h)a.push(g);return a.join(`
216
216
  `)+(a.length>0?`
217
- `:"")}var Gm=80;function Lm(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 mr(e,t=Gm){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=Lm(p.path,c);let f=c,l=[],d=0,h=0,u=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(u++,d+=p.insertions,h+=p.deletions,p.isBinary){let x=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${x}`);continue}let w=p.insertions+p.deletions,b=String(w).padStart(s),k,R;if(r<=a)k=p.insertions,R=p.deletions;else{let y=A=>A===0?0:1+Math.floor(A*(a-1)/r),x=y(w),$=x<2&&p.insertions>0&&p.deletions>0?2:x;p.insertions<p.deletions?(k=y(p.insertions),R=$-k):(R=y(p.deletions),k=$-R)}let C="+".repeat(k)+"-".repeat(R),E=C?` ${C}`:"";l.push(` ${g} | ${b}${E}`)}let m=er(u,d,h);return m?l.push(m):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
217
+ `:"")}var Gm=80;function Lm(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 mr(e,t=Gm){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=Lm(p.path,c);let f=c,l=[],d=0,h=0,u=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(u++,d+=p.insertions,h+=p.deletions,p.isBinary){let C=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${C}`);continue}let w=p.insertions+p.deletions,b=String(w).padStart(s),y,x;if(r<=a)y=p.insertions,x=p.deletions;else{let E=D=>D===0?0:1+Math.floor(D*(a-1)/r),C=E(w),$=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(y=E(p.insertions),x=$-y):(x=E(p.deletions),y=$-x)}let k="+".repeat(y)+"-".repeat(x),R=k?` ${k}`:"";l.push(` ${g} | ${b}${R}`)}let m=Qn(u,d,h);return m?l.push(m):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
218
218
  `)}
219
- `}async function gn(e,t,n){let r=await Ke(e,t,n),{remaining:o,renames:s}=await ot(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await tr(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=mr(i);for(let f of a)c+=`${f}
220
- `;return c}Be();Ce();ie();we();Jt();async function Nm(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 en(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 qt(e,t,n){if(t===n)return[t];let r=await Nm(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 en(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:_m(e,t,n,c)}async function _m(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(h){let u=c.get(h);if(u!==void 0)return u;let m=(await j(e,h)).committer.timestamp;return c.set(h,m),m}for(;l.length>0;){let h=0,u=await d(l[0].hash);for(let b=1;b<l.length;b++){let k=l[b],R=await d(k.hash),C=l[h];(R>u||R===u&&k.seq<C.seq)&&(h=b,u=R)}let m=l.splice(h,1)[0],p=a.get(m.hash)??0,g=p|m.mask;if(g===p)continue;if(a.set(m.hash,g),g===3&&o.has(m.hash)&&!s.has(m.hash)&&(i.push(m.hash),s.add(m.hash),s.size===o.size))break;let w=await j(e,m.hash);for(let b of w.parents)l.push({hash:b,mask:g,seq:f++})}for(let h of r)s.has(h)||i.push(h);return i}async function pr(e,t,n,r){let o=await xe(e,"init.defaultBranch")??"main",s=r?` of ${r}`:"";return n===o?`Merge branch '${t}'${s}
219
+ `}async function pn(e,t,n){let r=await Ve(e,t,n),{remaining:o,renames:s}=await st(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await er(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=mr(i);for(let f of a)c+=`${f}
220
+ `;return c}Be();Ce();ie();we();Jt();async function Nm(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 G(e,s)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function en(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 G(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function qt(e,t,n){if(t===n)return[t];let r=await Nm(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 G(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 en(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:_m(e,t,n,c)}async function _m(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(h){let u=c.get(h);if(u!==void 0)return u;let m=(await G(e,h)).committer.timestamp;return c.set(h,m),m}for(;l.length>0;){let h=0,u=await d(l[0].hash);for(let b=1;b<l.length;b++){let y=l[b],x=await d(y.hash),k=l[h];(x>u||x===u&&y.seq<k.seq)&&(h=b,u=x)}let m=l.splice(h,1)[0],p=a.get(m.hash)??0,g=p|m.mask;if(g===p)continue;if(a.set(m.hash,g),g===3&&o.has(m.hash)&&!s.has(m.hash)&&(i.push(m.hash),s.add(m.hash),s.size===o.size))break;let w=await G(e,m.hash);for(let b of w.parents)l.push({hash:b,mask:g,seq:f++})}for(let h of r)s.has(h)||i.push(h);return i}async function pr(e,t,n,r){let o=await xe(e,"init.defaultBranch")??"main",s=r?` of ${r}`:"";return n===o?`Merge branch '${t}'${s}
221
221
  `:`Merge branch '${t}'${s} into ${n}
222
- `}async function Do(e,t,n){let r=await j(e,t),o=await j(e,n),s=Z(t),i=Z(n),a=`Updating ${s}..${i}
223
- `;if(e.workTree){let f=await z(e),l=await cf(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 ae(e,{version:2,entries:l.newEntries}),await je(e,l.worktreeOps)}await Nn(e,n);let c=await gn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
224
- ${c}`,stderr:"",exitCode:0}}ie();ze();we();function zf(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:S().alias("d").describe("Delete a branch"),forceDelete:S().alias("D").describe("Force delete a branch"),move:S().alias("m").describe("Rename a branch"),forceMove:S().alias("M").describe("Force rename a branch"),remotes:S().alias("r").describe("List remote-tracking branches"),all:S().alias("a").describe("List all branches"),setUpstreamTo:Y.string().alias("u").describe("Set upstream tracking branch"),verbose:S().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Pe(i.target):null,c=!!n.forceMove;if(n.move||c){let w,b;if(n.newName)w=n.name,b=n.newName;else if(n.name){if(!a)return T("not on any branch");w=a,b=n.name}else return T("branch name required");if(!En(b))return T(`'${b}' is not a valid branch name`);let k=`refs/heads/${w}`,R=`refs/heads/${b}`,C=await B(s,k);if(!C)return T(`no branch named '${w}'`);if(await Ut(s)&&(await kt(s))?.headName===k)return T(`branch ${k} is being rebased at ${s.workTree}`);let E=await B(s,R);if(E&&!c)return T(`a branch named '${b}' already exists`);E&&await me(s,R);let y=await et(s,k);await J(s,R,C),await me(s,k),w===a&&await Ze(s,"HEAD",R),y.length>0&&await Fn(s,R,y);let x=`Branch: renamed ${k} to ${R}`;if(await se(s,r.env,R,C,C,x),w===a){let P=await sn(s,r.env);await Je(s,"HEAD",{oldHash:C,newHash:te,...P,message:x}),await Je(s,"HEAD",{oldHash:te,newHash:C,...P,message:x})}let $=await he(s),A=`branch "${w}"`;return $[A]&&($[`branch "${b}"`]=$[A],delete $[A],await Xe(s,$)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return T("branch name required");let w=n.name===a;if(!w&&!a&&await Ut(s)&&(await kt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
225
- `);let b=`refs/heads/${n.name}`,k=await B(s,b);if(!k)return _(`error: branch '${n.name}' not found
226
- `);let R="";if(!f){let C=await X(s),y=(await he(s))[`branch "${n.name}"`],x=y?.remote,$=y?.merge,A=null,P=null;if(x&&$&&(A=$.replace(/^refs\/heads\//,`refs/remotes/${x}/`),P=await B(s,A)),P&&A){if(!(k===P||await en(s,k,P))){let K=C!=null&&(k===C||await en(s,k,C))?`warning: not deleting branch '${n.name}' that is not yet merged to
227
- '${A}', even though it is merged to HEAD
228
- `:"";return _(`${K}error: the branch '${n.name}' is not fully merged
222
+ `}async function Do(e,t,n){let r=await G(e,t),o=await G(e,n),s=Z(t),i=Z(n),a=`Updating ${s}..${i}
223
+ `;if(e.workTree){let f=await z(e),l=await cf(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 ae(e,{version:2,entries:l.newEntries}),await je(e,l.worktreeOps)}await Ln(e,n);let c=await pn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
224
+ ${c}`,stderr:"",exitCode:0}}ie();Ke();we();function Kf(e,t){e.command("branch",{description:"List, create, or delete branches",args:[K.string().name("name").describe("Branch name").optional(),K.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:I().alias("d").describe("Delete a branch"),forceDelete:I().alias("D").describe("Force delete a branch"),move:I().alias("m").describe("Rename a branch"),forceMove:I().alias("M").describe("Force rename a branch"),remotes:I().alias("r").describe("List remote-tracking branches"),all:I().alias("a").describe("List all branches"),setUpstreamTo:Y.string().alias("u").describe("Set upstream tracking branch"),verbose:I().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Pe(i.target):null,c=!!n.forceMove;if(n.move||c){let w,b;if(n.newName)w=n.name,b=n.newName;else if(n.name){if(!a)return S("not on any branch");w=a,b=n.name}else return S("branch name required");if(!yn(b))return S(`'${b}' is not a valid branch name`);let y=`refs/heads/${w}`,x=`refs/heads/${b}`,k=await B(s,y);if(!k)return S(`no branch named '${w}'`);if(await Ut(s)&&(await kt(s))?.headName===y)return S(`branch ${y} is being rebased at ${s.workTree}`);let R=await B(s,x);if(R&&!c)return S(`a branch named '${b}' already exists`);R&&await he(s,x);let E=await Qe(s,y);await J(s,x,k),await he(s,y),w===a&&await Ze(s,"HEAD",x),E.length>0&&await _n(s,x,E);let C=`Branch: renamed ${y} to ${x}`;if(await ne(s,r.env,x,k,k,C),w===a){let P=await vn(s,r.env);await ft(s,"HEAD",{oldHash:k,newHash:te,...P,message:C}),await ft(s,"HEAD",{oldHash:te,newHash:k,...P,message:C})}let $=await pe(s),D=`branch "${w}"`;return $[D]&&($[`branch "${b}"`]=$[D],delete $[D],await ze(s,$)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return S("branch name required");let w=n.name===a;if(!w&&!a&&await Ut(s)&&(await kt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
225
+ `);let b=`refs/heads/${n.name}`,y=await B(s,b);if(!y)return _(`error: branch '${n.name}' not found
226
+ `);let x="";if(!f){let k=await X(s),E=(await pe(s))[`branch "${n.name}"`],C=E?.remote,$=E?.merge,D=null,P=null;if(C&&$&&(D=$.replace(/^refs\/heads\//,`refs/remotes/${C}/`),P=await B(s,D)),P&&D){if(!(y===P||await en(s,y,P))){let W=k!=null&&(y===k||await en(s,y,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
227
+ '${D}', even though it is merged to HEAD
228
+ `:"";return _(`${W}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
- `)}C!=null&&(k===C||await en(s,k,C))||(R=`warning: deleting branch '${n.name}' that has been merged to
232
- '${A}', but not yet merged to HEAD
233
- `)}else if(C&&k!==C&&!await en(s,k,C))return _(`error: the branch '${n.name}' is not fully merged
231
+ `)}k!=null&&(y===k||await en(s,y,k))||(x=`warning: deleting branch '${n.name}' that has been merged to
232
+ '${D}', but not yet merged to HEAD
233
+ `)}else if(k&&y!==k&&!await en(s,y,k))return _(`error: the branch '${n.name}' is not fully merged
234
234
  hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
235
235
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
236
- `)}return await me(s,b),{stdout:`Deleted branch ${n.name} (was ${Z(k)}).
237
- `,stderr:R,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,b=n.name||a;if(!b)return T("could not set upstream of HEAD when it does not point to any branch.");if(!await B(s,`refs/heads/${b}`))return T(`branch '${b}' does not exist`);let R=w.indexOf("/");if(R<0)return T(`the requested upstream branch '${w}' does not exist`);let C=w.slice(0,R),E=w.slice(R+1);if(!await B(s,`refs/remotes/${w}`))return T(`the requested upstream branch '${w}' does not exist`);let x=await he(s),$=`branch "${b}"`;return x[$]||(x[$]={}),x[$].remote=C,x[$].merge=`refs/heads/${E}`,await Xe(s,x),{stdout:"",stderr:`branch '${b}' set up to track '${w}'.
238
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!En(n.name))return T(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let y=await Le(s,w,`not a valid object name: '${w}'`);if(M(y))return y;b=y.hash}else if(b=await X(s),!b)return T("Not a valid object name: 'HEAD'.");let k=`refs/heads/${n.name}`;if(await B(s,k))return T(`a branch named '${n.name}' already exists`);await J(s,k,b);let C=w??"HEAD";await se(s,r.env,k,null,b,`branch: Created from ${C}`);let E="";return w&&(E=await $o(s,n.name,w)),{stdout:"",stderr:E,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,h=n.remotes||n.all,u=[];if(d&&!a){let w=await X(s);if(w){let b=await Ut(s),k;if(b){let R=await kt(s);if(R?.headName){let C=Pe(R.headName);if(C==="detached HEAD"){let E=await ms(s);k=`(no branch, rebasing detached HEAD ${E?Z(E):"(null)"})`}else k=`(no branch, rebasing ${C})`}else k="(no branch)"}else{let R=await ms(s);R?k=`(HEAD detached ${w===R?"at":"from"} ${Z(R)})`:k="(no branch)"}u.push({displayName:k,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await ge(s,"refs/heads");for(let b of w){let k=Pe(b.name);u.push({displayName:k,hash:b.hash,isCurrent:k===a,branchName:k})}}if(h){let w=await ge(s,"refs/remotes");for(let b of w){let k=b.name.replace("refs/remotes/",""),R=null,C=await s.refStore.readRef(b.name);C?.type==="symbolic"&&(R=C.target.replace("refs/remotes/",""));let E=R?n.all?`remotes/${k} -> ${R}`:`${k} -> ${R}`:n.all?`remotes/${k}`:k;u.push({displayName:E,hash:b.hash,isCurrent:!1,branchName:null})}}if(u.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${u.map(b=>b.isCurrent?`* ${b.displayName}`:` ${b.displayName}`).join(`
236
+ `)}return await he(s,b),{stdout:`Deleted branch ${n.name} (was ${Z(y)}).
237
+ `,stderr:x,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,b=n.name||a;if(!b)return S("could not set upstream of HEAD when it does not point to any branch.");if(!await B(s,`refs/heads/${b}`))return S(`branch '${b}' does not exist`);let x=w.indexOf("/");if(x<0)return S(`the requested upstream branch '${w}' does not exist`);let k=w.slice(0,x),R=w.slice(x+1);if(!await B(s,`refs/remotes/${w}`))return S(`the requested upstream branch '${w}' does not exist`);let C=await pe(s),$=`branch "${b}"`;return C[$]||(C[$]={}),C[$].remote=k,C[$].merge=`refs/heads/${R}`,await ze(s,C),{stdout:"",stderr:`branch '${b}' set up to track '${w}'.
238
+ `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!yn(n.name))return S(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let E=await Le(s,w,`not a valid object name: '${w}'`);if(j(E))return E;b=E.hash}else if(b=await X(s),!b)return S("Not a valid object name: 'HEAD'.");let y=`refs/heads/${n.name}`;if(await B(s,y))return S(`a branch named '${n.name}' already exists`);await J(s,y,b);let k=w??"HEAD";await ne(s,r.env,y,null,b,`branch: Created from ${k}`);let R="";return w&&(R=await $o(s,n.name,w)),{stdout:"",stderr:R,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,h=n.remotes||n.all,u=[];if(d&&!a){let w=await X(s);if(w){let b=await Ut(s),y;if(b){let x=await kt(s);if(x?.headName){let k=Pe(x.headName);if(k==="detached HEAD"){let R=await ps(s);y=`(no branch, rebasing detached HEAD ${R?Z(R):"(null)"})`}else y=`(no branch, rebasing ${k})`}else y="(no branch)"}else{let x=await ps(s);x?y=`(HEAD detached ${w===x?"at":"from"} ${Z(x)})`:y="(no branch)"}u.push({displayName:y,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await ge(s,"refs/heads");for(let b of w){let y=Pe(b.name);u.push({displayName:y,hash:b.hash,isCurrent:y===a,branchName:y})}}if(h){let w=await ge(s,"refs/remotes");for(let b of w){let y=b.name.replace("refs/remotes/",""),x=null,k=await s.refStore.readRef(b.name);k?.type==="symbolic"&&(x=k.target.replace("refs/remotes/",""));let R=x?n.all?`remotes/${y} -> ${x}`:`${y} -> ${x}`:n.all?`remotes/${y}`:y;u.push({displayName:R,hash:b.hash,isCurrent:!1,branchName:null})}}if(u.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${u.map(b=>b.isCurrent?`* ${b.displayName}`:` ${b.displayName}`).join(`
239
239
  `)}
240
- `,stderr:"",exitCode:0};let m=l>=1?await he(s):null,p=Math.max(...u.map(w=>w.displayName.length)),g=[];for(let w of u){let b=w.isCurrent?"* ":" ",k=w.displayName.padEnd(p),R=Z(w.hash),C="";try{let y=await j(s,w.hash);C=ue(y.message)}catch{}let E="";if(m&&w.branchName){let y=await Bt(s,m,w.branchName);if(y){let x=ko(y,l>=2);x&&(E=` ${x}`)}}g.push(`${b}${k} ${R}${E} ${C}`)}return{stdout:`${g.join(`
240
+ `,stderr:"",exitCode:0};let m=l>=1?await pe(s):null,p=Math.max(...u.map(w=>w.displayName.length)),g=[];for(let w of u){let b=w.isCurrent?"* ":" ",y=w.displayName.padEnd(p),x=Z(w.hash),k="";try{let E=await G(s,w.hash);k=ue(E.message)}catch{}let R="";if(m&&w.branchName){let E=await Bt(s,m,w.branchName);if(E){let C=ko(E,l>=2);C&&(R=` ${C}`)}}g.push(`${b}${y} ${x}${R} ${k}`)}return{stdout:`${g.join(`
241
241
  `)}
242
- `,stderr:"",exitCode:0}}})}function fe(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Fm=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Um=["commitMsg","mergeMsg"],Bm=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Wm=["onRefUpdate","onRefDelete","onObjectWrite"];function qm(...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 Fm){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(fe(a))return a}})}for(let r of Um){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(fe(a))return a}})}for(let r of Bm){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 Wm){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}oe();Be();Ce();ie();ze();we();fn();tt();function Vf(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:S().alias("b").describe("Create and switch to a new branch"),forceBranch:S().alias("B").describe("Create/reset and switch to a new branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:S().describe("Create a new orphan branch"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return T("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return T(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let h=dt(i,r.cwd),u=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return T("cannot specify both a revision and --ours/--theirs");let p=await Le(i,a,`invalid reference: ${a}`);if(M(p))return p;m=p.commit.tree}return n.ours||n.theirs?Co(i,u,h,n.theirs?3:2):xo(i,u,h,m)}if(n.orphan)return n.branch?T("--orphan and -b are incompatible"):n.ours||n.theirs?T("--orphan and --ours/--theirs are incompatible"):a?Km(i,a,r.env,t):T("you must specify a branch to checkout");if(n.detach){let h=a??"HEAD",u=await Le(i,h,`invalid reference: ${h}`);return M(u)?u:Kf(i,h,u.hash,r.env,t)}if(!a)return T("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Vm(i,a,r.env,t,!!n.forceBranch);if(a==="-")return zm(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Yf(i,a,c,f,r.env,t);let l=await Oo(i,a);if(l)return Ym(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let h=await Ae(i,d);return Kf(i,a,h,r.env,t)}if(i.workTree){let h=await z(i),u=Ws(h,a);if(u)return await lt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
243
- `)}})}async function zm(e,t,n){let r=await Ro(e);return r?Yf(e,r.name,r.refName,r.hash,t,n):T("no previous branch")}async function Km(e,t,n,r){if(!En(t))return T(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return T(`a branch named '${t}' already exists`);let i=await z(e),a=Yn(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await j(e,c)).tree),await Ze(e,"HEAD",o),await Et(e);let l=await On(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:te,isBranchCheckout:!0});let d="";return f&&(d=await ur(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
244
- ${l}`,exitCode:0}}async function Vm(e,t,n,r,o=!1){if(!En(t))return T(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return _(s.message??"");let i=await Q(e),a=await X(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return T(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=Yn(g);if(w)return w}a&&await J(e,c,a),await Ze(e,"HEAD",c),await Et(e);let l=await On(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??te;a&&(f?f!==a&&await se(e,n,c,f,a,"branch: Reset to HEAD"):await se(e,n,c,null,a,"branch: Created from HEAD")),await se(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 h="";if(o&&a){let g=await z(e),w=await j(e,a);h=await ur(e,w.tree,g)}let u=await he(e),m=await Bt(e,u,t);m&&(h+=Vn(m));let p=f?`Switched to and reset branch '${t}'
242
+ `,stderr:"",exitCode:0}}})}function fe(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Fm=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Um=["commitMsg","mergeMsg"],Bm=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Wm=["onRefUpdate","onRefDelete","onObjectWrite"];function qm(...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 Fm){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(fe(a))return a}})}for(let r of Um){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(fe(a))return a}})}for(let r of Bm){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 Wm){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}oe();Be();Ce();ie();Ke();we();cn();et();function Vf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[K.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:I().alias("b").describe("Create and switch to a new branch"),forceBranch:I().alias("B").describe("Create/reset and switch to a new branch"),detach:I().alias("d").describe("Detach HEAD at named commit"),orphan:I().describe("Create a new orphan branch"),ours:I().describe("Checkout our version for unmerged files"),theirs:I().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return S("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return S("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return S(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let h=dt(i,r.cwd),u=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return S("cannot specify both a revision and --ours/--theirs");let p=await Le(i,a,`invalid reference: ${a}`);if(j(p))return p;m=p.commit.tree}return n.ours||n.theirs?Co(i,u,h,n.theirs?3:2):xo(i,u,h,m)}if(n.orphan)return n.branch?S("--orphan and -b are incompatible"):n.ours||n.theirs?S("--orphan and --ours/--theirs are incompatible"):a?zm(i,a,r.env,t):S("you must specify a branch to checkout");if(n.detach){let h=a??"HEAD",u=await Le(i,h,`invalid reference: ${h}`);return j(u)?u:zf(i,h,u.hash,r.env,t)}if(!a)return S("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Vm(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Km(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Yf(i,a,c,f,r.env,t);let l=await Oo(i,a);if(l)return Ym(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let h=await Ae(i,d);return zf(i,a,h,r.env,t)}if(i.workTree){let h=await z(i),u=qs(h,a);if(u)return await lt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
243
+ `)}})}async function Km(e,t,n){let r=await Ro(e);return r?Yf(e,r.name,r.refName,r.hash,t,n):S("no previous branch")}async function zm(e,t,n,r){if(!yn(t))return S(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return S(`a branch named '${t}' already exists`);let i=await z(e),a=Vn(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await G(e,c)).tree),await Ze(e,"HEAD",o),await Et(e);let l=await $n(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:te,isBranchCheckout:!0});let d="";return f&&(d=await ur(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
244
+ ${l}`,exitCode:0}}async function Vm(e,t,n,r,o=!1){if(!yn(t))return S(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return _(s.message??"");let i=await Q(e),a=await X(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return S(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=Vn(g);if(w)return w}a&&await J(e,c,a),await Ze(e,"HEAD",c),await Et(e);let l=await $n(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??te;a&&(f?f!==a&&await ne(e,n,c,f,a,"branch: Reset to HEAD"):await ne(e,n,c,null,a,"branch: Created from HEAD")),await ne(e,n,"HEAD",a,a??te,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??te,isBranchCheckout:!0});let h="";if(o&&a){let g=await z(e),w=await G(e,a);h=await ur(e,w.tree,g)}let u=await pe(e),m=await Bt(e,u,t);m&&(h+=zn(m));let p=f?`Switched to and reset branch '${t}'
245
245
  `:`Switched to a new branch '${t}'
246
- `;return{stdout:h,stderr:`${p}${l}`,exitCode:0}}async function Yf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(i)?_(i.message??""):hr(e,t,n,r,o,s)}async function Ym(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return _(s.message??"");let i=await B(e,n);if(!i)return T(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await J(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 Xe(e,d),await se(e,r,a,null,i,`branch: Created from ${n}`);let h=await hr(e,t,a,i,r,o,{isNew:!0}),u=c.slice(1).join("/");return h.stdout=`branch '${t}' set up to track '${f}/${u}'.
247
- `,h}async function Kf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(s)?_(s.message??""):Xn(e,n,r,o,{detachAdviceTarget:t})}oe();Be();Ce();oe();function oa(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}=ra(e,t);return Xm(o,n,s,r)}function Xm(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 Zm(e,t,n){let r=[];for(let c of oa(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 oa(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 h=r[a];if(h.oStart>l)break;l=Math.max(l,h.oStart+h.oLength),d.push(h),a++}if(d.length===1){if(c.abLength>0){let h=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:h.slice(c.abStart,c.abStart+c.abLength)})}}else{let h={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 b=w.oStart,k=b+w.oLength,R=w.abStart,C=R+w.abLength,E=h[w.ab];E.abMin=Math.min(R,E.abMin),E.abMax=Math.max(C,E.abMax),E.oMin=Math.min(b,E.oMin),E.oMax=Math.max(k,E.oMax)}let u=h.a.abMin+(f-h.a.oMin),m=h.a.abMax+(l-h.a.oMax),p=h.b.abMin+(f-h.b.oMin),g=h.b.abMax+(l-h.b.oMax);o.push({stable:!1,a:e.slice(u,m),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function Jm(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Zm(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&&Zf(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"?Xf(i):Xf(Qm(i))}function ys(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=Jm(e,t,n,{conflictStyle:s}),d=!1,h=[];for(let u of l)u.type==="ok"?h.push(...u.lines):(d=!0,s==="diff3"?h.push(i,...u.a,a,...u.o,c,...u.b,f):h.push(i,...u.a,c,...u.b,f));return{conflict:d,result:h}}function Qm(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...ep(n));return t}function ep(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Zf(t,n))return[e];let r=oa(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 Xf(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 gr(e,t,n,r){let o=ys(At(e),At(t),At(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(ia);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
246
+ `;return{stdout:h,stderr:`${p}${l}`,exitCode:0}}async function Yf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(i)?_(i.message??""):hr(e,t,n,r,o,s)}async function Ym(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return _(s.message??"");let i=await B(e,n);if(!i)return S(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await J(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await pe(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await ze(e,d),await ne(e,r,a,null,i,`branch: Created from ${n}`);let h=await hr(e,t,a,i,r,o,{isNew:!0}),u=c.slice(1).join("/");return h.stdout=`branch '${t}' set up to track '${f}/${u}'.
247
+ `,h}async function zf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(s)?_(s.message??""):Yn(e,n,r,o,{detachAdviceTarget:t})}oe();Be();Ce();oe();function oa(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}=ra(e,t);return Xm(o,n,s,r)}function Xm(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 Zm(e,t,n){let r=[];for(let c of oa(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 oa(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 h=r[a];if(h.oStart>l)break;l=Math.max(l,h.oStart+h.oLength),d.push(h),a++}if(d.length===1){if(c.abLength>0){let h=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:h.slice(c.abStart,c.abStart+c.abLength)})}}else{let h={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 b=w.oStart,y=b+w.oLength,x=w.abStart,k=x+w.abLength,R=h[w.ab];R.abMin=Math.min(x,R.abMin),R.abMax=Math.max(k,R.abMax),R.oMin=Math.min(b,R.oMin),R.oMax=Math.max(y,R.oMax)}let u=h.a.abMin+(f-h.a.oMin),m=h.a.abMax+(l-h.a.oMax),p=h.b.abMin+(f-h.b.oMin),g=h.b.abMax+(l-h.b.oMax);o.push({stable:!1,a:e.slice(u,m),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function Jm(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Zm(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&&Zf(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"?Xf(i):Xf(Qm(i))}function Es(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=Jm(e,t,n,{conflictStyle:s}),d=!1,h=[];for(let u of l)u.type==="ok"?h.push(...u.lines):(d=!0,s==="diff3"?h.push(i,...u.a,a,...u.o,c,...u.b,f):h.push(i,...u.a,c,...u.b,f));return{conflict:d,result:h}}function Qm(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...ep(n));return t}function ep(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Zf(t,n))return[e];let r=oa(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 Xf(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 gr(e,t,n,r){let o=Es(At(e),At(t),At(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(ia);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
248
248
  `)}
249
249
  `:a.join(`
250
250
  `)}function At(e){if(e==="")return[];let t=e.split(`
251
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ia(e){return e.endsWith("\0")?e.slice(0,-1):e}function Zf(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}Ce();ie();bn();pe();Rn();De();tt();Jt();var jr=new TextDecoder,tn=new TextEncoder,Jf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function zt(e,t,n,r,o,s){let{paths:i,baseMap:a,oursMap:c,theirsMap:f}=await np(e,t,n,r),l=await sp(e,i,a,c,f,o,s);return op(e,i,o,l,s)}async function ks(e,t,n,r,o){let s=await qt(e,t,n),i=await j(e,t),a=await j(e,n);if(s.length===0)return{...await zt(e,null,i.tree,a.tree,r,o),baseTree:null};if(s.length===1){let l=await j(e,s[0]);return{...await zt(e,l.tree,i.tree,a.tree,r,o),baseTree:l.tree}}let c=await al(e,t,n,s,1,o);return{...await zt(e,c,i.tree,a.tree,r,o),baseTree:c}}async function np(e,t,n,r){let o=await de(e,t),s=await de(e,n),i=await de(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,h=i.get(f)??null,u=l?{hash:l.hash,mode:l.mode}:null,m=d?{hash:d.hash,mode:d.mode}:null,p=h?{hash:h.hash,mode:h.mode}:null,g=(l?1:0)|(d?2:0)|(h?4:0),w=l?.hash??null,b=d?.hash??null,k=h?.hash??null,R=0;w!==null&&w===b&&(R|=3),w!==null&&w===k&&(R|=5),b!==null&&b===k&&(R|=6);let C={path:f,stages:[u,m,p],pathnames:[f,f,f],filemask:g,matchMask:R,merged:{result:null,clean:!1},pathConflict:!1};if(rp(C)){c.set(f,C);continue}c.set(f,C)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function rp(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 sp(e,t,n,r,o,s,i){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},c=[],f=[];for(let[I,H]of n)r.has(I)||c.push({path:I,status:"deleted",oldHash:H.hash,oldMode:H.mode}),o.has(I)||f.push({path:I,status:"deleted",oldHash:H.hash,oldMode:H.mode});for(let[I,H]of r)n.has(I)||c.push({path:I,status:"added",newHash:H.hash,newMode:H.mode});for(let[I,H]of o)n.has(I)||f.push({path:I,status:"added",newHash:H.hash,newMode:H.mode});let l=await ot(e,c),d=await ot(e,f);if(l.renames.length===0&&d.renames.length===0)return a;let h=new Map,u=new Map;for(let I of l.renames)h.set(I.oldPath,I);for(let I of d.renames)u.set(I.oldPath,I);let m=new Set;for(let[I]of r)!n.has(I)&&o.has(I)&&m.add(I);let p=new Set,g=s?.a??"HEAD",w=s?.b??"theirs";function b(I,H,G=0){a.msgBuf.push({sortKey:I,subOrder:G,text:H})}for(let I of[...n.keys()].sort()){let H=h.get(I),G=u.get(I);if(!H&&!G)continue;let F=n.get(I);if(p.add(I),H&&G)if(p.add(H.newPath),p.add(G.newPath),H.newPath===G.newPath){let U=r.get(H.newPath),N=o.get(G.newPath);if(U.hash===N.hash)a.entries.push(Ct(H.newPath,U));else{let ne=aa(t,H.newPath);ne.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],ne.pathnames=[I,H.newPath,G.newPath],ne.filemask=7,ne.merged={result:null,clean:!1}}}else{let U=r.get(H.newPath),N=o.get(G.newPath),ne=await il(e,F,U,N,s,void 0,void 0,i);ne.conflict&&b(I,`Auto-merging ${I}`,-1),a.conflicts.push({path:I,reason:"rename-rename",oursPath:H.newPath,theirsPath:G.newPath}),b(I,`CONFLICT (rename/rename): ${I} renamed to ${H.newPath} in ${g} and to ${G.newPath} in ${w}.`),a.entries.push(Ct(I,F,1)),a.entries.push(ct(H.newPath,U.mode,ne.hash,2)),a.entries.push(ct(G.newPath,N.mode,ne.hash,3)),a.worktreeBlobs.set(H.newPath,{hash:ne.hash,mode:U.mode}),a.worktreeBlobs.set(G.newPath,{hash:ne.hash,mode:N.mode})}else if(H){p.add(H.newPath);let U=o.get(I),N=r.get(H.newPath),ne=m.has(H.newPath);if(U)if(ne)await sl(e,a,H.newPath,I,F,N,U,r,o,!1,s,i);else if(U.hash===F.hash&&N.hash===F.hash)a.entries.push(Ct(H.newPath,N));else if(U.hash===F.hash)a.entries.push(Ct(H.newPath,N));else if(N.hash===F.hash)a.entries.push(ct(H.newPath,N.mode,U.hash));else{let V=aa(t,H.newPath);V.stages=[{hash:F.hash,mode:F.mode},{hash:N.hash,mode:N.mode},{hash:U.hash,mode:U.mode}],V.pathnames=[I,H.newPath,I],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=o.get(H.newPath);if(a.conflicts.push({path:H.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:I}),b(H.newPath,`CONFLICT (rename/delete): ${I} renamed to ${H.newPath} in ${g}, but deleted in ${w}.`),V){a.conflicts.push({path:H.newPath,reason:"add-add"}),b(H.newPath,`Auto-merging ${H.newPath}`,0),b(H.newPath,`CONFLICT (add/add): Merge conflict in ${H.newPath}`,1),a.entries.push(Ct(H.newPath,N,2)),a.entries.push(Ct(H.newPath,V,3));let ee=await Mo(e,N.hash,V.hash,N.mode,s);a.worktreeBlobs.set(H.newPath,{hash:ee,mode:N.mode})}else a.entries.push(ct(H.newPath,F.mode,F.hash,1)),a.entries.push(Ct(H.newPath,N,2)),a.worktreeBlobs.set(H.newPath,{hash:N.hash,mode:N.mode}),N.hash!==F.hash&&b(H.newPath,`CONFLICT (modify/delete): ${H.newPath} deleted in ${w} and modified in ${g}. Version ${g} of ${H.newPath} left in tree.`,1)}}else if(G){p.add(G.newPath);let U=r.get(I),N=o.get(G.newPath),ne=m.has(G.newPath);if(U)if(ne)await sl(e,a,G.newPath,I,F,U,N,r,o,!0,s,i);else if(U.hash===F.hash&&N.hash===F.hash)a.entries.push(Ct(G.newPath,N));else if(U.hash===F.hash)a.entries.push(Ct(G.newPath,N));else if(N.hash===F.hash)a.entries.push(ct(G.newPath,N.mode,U.hash));else{let V=aa(t,G.newPath);V.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],V.pathnames=[I,I,G.newPath],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=r.get(G.newPath);if(a.conflicts.push({path:G.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:I}),b(G.newPath,`CONFLICT (rename/delete): ${I} renamed to ${G.newPath} in ${w}, but deleted in ${g}.`),V){a.conflicts.push({path:G.newPath,reason:"add-add"}),b(G.newPath,`Auto-merging ${G.newPath}`,0),b(G.newPath,`CONFLICT (add/add): Merge conflict in ${G.newPath}`,1),a.entries.push(Ct(G.newPath,V,2)),a.entries.push(Ct(G.newPath,N,3));let ee=await Mo(e,V.hash,N.hash,V.mode,s);a.worktreeBlobs.set(G.newPath,{hash:ee,mode:V.mode})}else a.entries.push(ct(G.newPath,F.mode,F.hash,1)),a.entries.push(Ct(G.newPath,N,3)),a.worktreeBlobs.set(G.newPath,{hash:N.hash,mode:N.mode}),N.hash!==F.hash&&b(G.newPath,`CONFLICT (modify/delete): ${G.newPath} deleted in ${g} and modified in ${w}. Version ${w} of ${G.newPath} left in tree.`,1)}}}let k=new Set(l.renames.map(I=>I.newPath)),R=new Set(d.renames.map(I=>I.newPath)),C=Qf(n,r),E=Qf(n,o),y=el(C,o,n),x=el(E,r,n),$=tl(l.renames,y),A=tl(d.renames,x),P=nl($),O=nl(A);for(let I of[...P.keys()])O.has(I)&&(P.delete(I),O.delete(I));let D=new Set(P.keys()),L=new Set(O.keys());if(O.size>0)for(let I of c){if(I.status!=="added"||k.has(I.path))continue;let H=rl(I.path,O,D);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(r.has(H)){b(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let U=r.get(I.path),N=o.get(H)??n.get(H);a.entries.push(ct(H,U.mode,U.hash,2)),N&&a.entries.push(ct(H,N.mode,N.hash,3)),a.worktreeBlobs.set(H,{hash:U.hash,mode:U.mode}),a.conflicts.push({path:H,reason:"add-add"}),b(H,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${H}.`,1);let ne=t.get(I.path);ne&&(ne.merged={result:null,clean:!0}),p.add(I.path);continue}let G=r.get(I.path);a.entries.push(ct(H,G.mode,G.hash,2)),a.worktreeBlobs.set(H,{hash:G.hash,mode:G.mode}),a.conflicts.push({path:H,reason:"directory-rename"}),b(H,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(I.path);F&&(F.merged={result:null,clean:!0}),p.add(I.path)}if(P.size>0)for(let I of f){if(I.status!=="added"||R.has(I.path))continue;let H=rl(I.path,P,L);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(o.has(H)){b(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let U=o.get(I.path),N=r.get(H)??n.get(H);N&&a.entries.push(ct(H,N.mode,N.hash,2)),a.entries.push(ct(H,U.mode,U.hash,3)),a.worktreeBlobs.set(H,{hash:U.hash,mode:U.mode}),a.conflicts.push({path:H,reason:"add-add"}),b(H,`CONFLICT (file location): ${I.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let ne=t.get(I.path);ne&&(ne.merged={result:null,clean:!0}),p.add(I.path);continue}let G=o.get(I.path);a.entries.push(ct(H,G.mode,G.hash,3)),a.worktreeBlobs.set(H,{hash:G.hash,mode:G.mode}),a.conflicts.push({path:H,reason:"directory-rename"}),b(H,`CONFLICT (file location): ${I.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let F=t.get(I.path);F&&(F.merged={result:null,clean:!0}),p.add(I.path)}let K=new Set(a.entries.map(I=>I.path));for(let I of K){let H=t.get(I);H&&(H.merged={result:null,clean:!0})}for(let I of p){if(K.has(I))continue;let H=t.get(I);if(!H||H.merged.clean)continue;H.filemask===7&&!H.pathConflict||(H.merged={result:null,clean:!0})}return a}function Qf(e,t){let n=new Set;for(let s of e.keys()){let i=Dt(s);for(;i;)n.add(i),i=Dt(i)}let r=new Set;for(let s of t.keys()){let i=Dt(s);for(;i;)r.add(i),i=Dt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function el(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=Dt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Dt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Dt(s)}return r}function tl(e,t){let n=new Map;for(let r of e){let o=Dt(r.oldPath),s=Dt(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=Dt(o),s=Dt(s)}}return n}function nl(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 rl(e,t,n){let r=Dt(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=Dt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Dt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function sl(e,t,n,r,o,s,i,a,c,f=!1,l,d){let h=f?a.get(n):c.get(n),u=f?i:s;if(h.hash===u.hash){t.entries.push(ct(n,h.mode,h.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let p=await il(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8,d);if(h.hash===p.hash)t.entries.push(ct(n,h.mode,p.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(Ct(n,h,2)),t.entries.push(ct(n,i.mode,p.hash,3));let g=await Mo(e,h.hash,p.hash,h.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:h.mode})}else{t.entries.push(ct(n,s.mode,p.hash,2)),t.entries.push(Ct(n,h,3));let g=await Mo(e,p.hash,h.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:s.mode})}}async function il(e,t,n,r,o,s,i,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(kn(t.mode)||kn(n.mode)||kn(r.mode))return{hash:n.hash,conflict:!0};let c=await re(e,t.hash),f=await re(e,n.hash),l=await re(e,r.hash);if(He(f)||He(l)||He(c))return{hash:n.hash,conflict:!0};if(a){let E=await a({path:t.path??n.path??r.path??"",base:c,ours:f,theirs:l});if(E!==null)return{hash:await Se(e,"blob",tn.encode(E.content)),conflict:E.conflict}}let d=At(c),h=At(f),u=At(l),m=o?.conflictStyle,p=ys(h,d,u,{conflictStyle:m});if(!p.conflict)return{hash:await fa(e,p.result),conflict:!1};let g=o?.a??"HEAD",w=o?.b??"theirs",b=s?.oursPath?`${g}:${s.oursPath}`:g,k=s?.theirsPath?`${w}:${s.theirsPath}`:w,R=gr(f,c,l,{a:b,b:k,markerSize:i??7,conflictStyle:m});return{hash:await Se(e,"blob",tn.encode(R)),conflict:!0}}async function Mo(e,t,n,r,o){let s=await re(e,t),i=await re(e,n),a=gr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Se(e,"blob",tn.encode(a))}function Ct(e,t,n=0){return ct(e,t.mode,t.hash,n)}function ct(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:ve()}}async function op(e,t,n,r,o){let s=[...r.entries],i=[...r.conflicts],a=[...r.msgBuf],c=new Map(r.worktreeBlobs);function f(m,p,g=0){a.push({sortKey:m,subOrder:g,text:p})}for(let m of[...t.keys()].sort()){let p=t.get(m);if(p.merged.clean){p.merged.result?.hash&&s.push(Oe(m,p.merged.result.hash,p.merged.result.mode));continue}await ip(e,p,n,s,i,f,c,o)}a.sort((m,p)=>(m.sortKey<p.sortKey?-1:m.sortKey>p.sortKey?1:0)||m.subOrder-p.subOrder);let l=a.map(m=>m.text),d=[],h=new Set;for(let m of s)m.stage===0&&(d.push(m),h.add(m.path));for(let[m,p]of c)h.has(m)||d.push(Oe(m,p.hash,p.mode));d.sort((m,p)=>Te(m.path,p.path));let u=await Fe(e,d);return{entries:s,conflicts:i,messages:l,resultTree:u}}async function ip(e,t,n,r,o,s,i,a){let c=t.path,[f,l,d]=t.stages,h=f?.hash??null,u=l?.hash??null,m=d?.hash??null;if(u===null&&m!==null&&h!==null){o.push({path:c,reason:"delete-modify",deletedBy:"ours"});let p=n?.a??"HEAD",g=n?.b??"theirs";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&h!==null){o.push({path:c,reason:"delete-modify",deletedBy:"theirs"});let p=n?.b??"theirs",g=n?.a??"HEAD";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),i.set(c,{hash:u,mode:l.mode});return}if(h===null&&u!==null&&m!==null){if(u===m){r.push(Oe(c,u,l.mode));return}s(c,`Auto-merging ${c}`,0);let p=await re(e,u),g=await re(e,m);if(He(p)||He(g)){o.push({path:c,reason:"add-add"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}if(a){let y=await a({path:c,base:null,ours:p,theirs:g});if(y!==null){let x=await Se(e,"blob",tn.encode(y.content));if(!y.conflict){r.push(Oe(c,x,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:x,mode:l.mode});return}}let w=At(""),b=At(p),k=At(g),R=ys(b,w,k,{conflictStyle:n?.conflictStyle});if(!R.conflict){let y=await fa(e,R.result);r.push(Oe(c,y,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3));let C=gr(p,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),E=await Se(e,"blob",tn.encode(C));i.set(c,{hash:E,mode:l.mode});return}if(h!==null&&u!==null&&m!==null){if(u===h){r.push(Oe(c,m,d.mode));return}if(m===h){r.push(Oe(c,u,l.mode));return}if(u===m){r.push(Oe(c,u,l.mode));return}if(s(c,`Auto-merging ${c}`,0),kn(f.mode)||kn(l.mode)||kn(d.mode)){o.push({path:c,reason:"content"}),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}let p=await re(e,h),g=await re(e,u),w=await re(e,m);if(He(g)||He(w)||He(p)){o.push({path:c,reason:"content"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}if(a){let E=await a({path:c,base:p,ours:g,theirs:w});if(E!==null){let y=await Se(e,"blob",tn.encode(E.content));if(!E.conflict){r.push(Oe(c,y,l.mode));return}let x=t.pathnames[1],$=t.pathnames[2],A=x!==c||$!==c,P={path:c,reason:"content"};A&&(x!==c&&(P.oursOrigPath=x),$!==c&&(P.theirsOrigPath=$)),o.push(P),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:y,mode:l.mode});return}}let b=At(p),k=At(g),R=At(w),C=ys(k,b,R,{conflictStyle:n?.conflictStyle});if(C.conflict){let E=t.pathnames[1],y=t.pathnames[2],x=E!==c||y!==c,$={path:c,reason:"content"};x&&(E!==c&&($.oursOrigPath=E),y!==c&&($.theirsOrigPath=y)),o.push($),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3));let A=x?`${n?.a??"HEAD"}:${E}`:n?.a??"HEAD",P=x?`${n?.b??"theirs"}:${y}`:n?.b??"theirs",O=gr(g,p,w,{a:A,b:P,conflictStyle:n?.conflictStyle}),D=await Se(e,"blob",tn.encode(O));i.set(c,{hash:D,mode:l.mode})}else{let E=await fa(e,C.result);r.push(Oe(c,E,l.mode))}return}}var ap=200;async function al(e,t,n,r,o,s){let i=await Promise.all(r.map(async d=>({hash:d,timestamp:(await j(e,d)).committer.timestamp})));i.sort((d,h)=>d.timestamp-h.timestamp);let a=i.map(d=>d.hash),c=a[0],f=c,l=(await j(e,c)).tree;for(let d=1;d<a.length;d++){let h=a[d],u=(await j(e,h)).tree,m=null;if(o>=ap)m=l;else{let w=await qt(e,f,h);w.length===0?m=null:w.length===1?m=(await j(e,w[0])).tree:m=await al(e,f,h,w,o+1,s)}let p=await zt(e,m,l,u,void 0,s);l=await cp(e,p,o);let g=cn({type:"commit",tree:l,parents:[f,h],author:Jf,committer:Jf,message:"merged common ancestors"});f=await Se(e,"commit",g)}return l}async function cp(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,h=s(a.path,1),u=s(l,2),m=s(d,3);if(u&&m){let p=jr.decode((await ye(e,u.hash)).content),g=jr.decode((await ye(e,m.hash)).content),w=h?jr.decode((await ye(e,h.hash)).content):"",b=8+n*2,k=i.a??"Temporary merge branch 1",R=i.b??"Temporary merge branch 2",C=gr(p,w,g,{a:`${k}:${l}`,o:i.o,b:`${R}:${d}`,markerSize:b}),E=await Se(e,"blob",tn.encode(C));r.push({path:l,mode:u.mode,hash:E,stage:0,stat:ve()}),r.push({path:d,mode:m.mode,hash:E,stage:0,stat:ve()});continue}else if(u){r.push({...u,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=jr.decode((await ye(e,c.hash)).content),d=jr.decode((await ye(e,f.hash)).content),h=a.reason==="content"?s(a.path,1):null,u=h?jr.decode((await ye(e,h.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=m?`${p}:${a.oursOrigPath??a.path}`:p,b=m?`${g}:${a.theirsOrigPath??a.path}`:g,k=gr(l,u,d,{a:w,o:i.o,b,markerSize:i.markerSize}),R=await Se(e,"blob",tn.encode(k));r.push({path:a.path,mode:c.mode,hash:R,stage:0,stat:ve()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Te(a.path,c.path)),Fe(e,r)}async function fa(e,t){let n=t.map(ia);if(n.length===0)return Se(e,"blob",tn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
251
+ `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ia(e){return e.endsWith("\0")?e.slice(0,-1):e}function Zf(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}Ce();ie();wn();me();kn();De();et();Jt();var Gr=new TextDecoder,tn=new TextEncoder,Jf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Kt(e,t,n,r,o,s){let{paths:i,baseMap:a,oursMap:c,theirsMap:f}=await np(e,t,n,r),l=await sp(e,i,a,c,f,o,s);return op(e,i,o,l,s)}async function Rs(e,t,n,r,o){let s=await qt(e,t,n),i=await G(e,t),a=await G(e,n);if(s.length===0)return{...await Kt(e,null,i.tree,a.tree,r,o),baseTree:null};if(s.length===1){let l=await G(e,s[0]);return{...await Kt(e,l.tree,i.tree,a.tree,r,o),baseTree:l.tree}}let c=await al(e,t,n,s,1,o);return{...await Kt(e,c,i.tree,a.tree,r,o),baseTree:c}}async function np(e,t,n,r){let o=await de(e,t),s=await de(e,n),i=await de(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,h=i.get(f)??null,u=l?{hash:l.hash,mode:l.mode}:null,m=d?{hash:d.hash,mode:d.mode}:null,p=h?{hash:h.hash,mode:h.mode}:null,g=(l?1:0)|(d?2:0)|(h?4:0),w=l?.hash??null,b=d?.hash??null,y=h?.hash??null,x=0;w!==null&&w===b&&(x|=3),w!==null&&w===y&&(x|=5),b!==null&&b===y&&(x|=6);let k={path:f,stages:[u,m,p],pathnames:[f,f,f],filemask:g,matchMask:x,merged:{result:null,clean:!1},pathConflict:!1};if(rp(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function rp(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 sp(e,t,n,r,o,s,i){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},c=[],f=[];for(let[O,A]of n)r.has(O)||c.push({path:O,status:"deleted",oldHash:A.hash,oldMode:A.mode}),o.has(O)||f.push({path:O,status:"deleted",oldHash:A.hash,oldMode:A.mode});for(let[O,A]of r)n.has(O)||c.push({path:O,status:"added",newHash:A.hash,newMode:A.mode});for(let[O,A]of o)n.has(O)||f.push({path:O,status:"added",newHash:A.hash,newMode:A.mode});let l=await st(e,c),d=await st(e,f);if(l.renames.length===0&&d.renames.length===0)return a;let h=new Map,u=new Map;for(let O of l.renames)h.set(O.oldPath,O);for(let O of d.renames)u.set(O.oldPath,O);let m=new Set;for(let[O]of r)!n.has(O)&&o.has(O)&&m.add(O);let p=new Set,g=s?.a??"HEAD",w=s?.b??"theirs";function b(O,A,L=0){a.msgBuf.push({sortKey:O,subOrder:L,text:A})}for(let O of[...n.keys()].sort()){let A=h.get(O),L=u.get(O);if(!A&&!L)continue;let F=n.get(O);if(p.add(O),A&&L)if(p.add(A.newPath),p.add(L.newPath),A.newPath===L.newPath){let U=r.get(A.newPath),N=o.get(L.newPath);if(U.hash===N.hash)a.entries.push(Ct(A.newPath,U));else{let re=aa(t,A.newPath);re.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],re.pathnames=[O,A.newPath,L.newPath],re.filemask=7,re.merged={result:null,clean:!1}}}else{let U=r.get(A.newPath),N=o.get(L.newPath),re=await il(e,F,U,N,s,void 0,void 0,i);re.conflict&&b(O,`Auto-merging ${O}`,-1),a.conflicts.push({path:O,reason:"rename-rename",oursPath:A.newPath,theirsPath:L.newPath}),b(O,`CONFLICT (rename/rename): ${O} renamed to ${A.newPath} in ${g} and to ${L.newPath} in ${w}.`),a.entries.push(Ct(O,F,1)),a.entries.push(at(A.newPath,U.mode,re.hash,2)),a.entries.push(at(L.newPath,N.mode,re.hash,3)),a.worktreeBlobs.set(A.newPath,{hash:re.hash,mode:U.mode}),a.worktreeBlobs.set(L.newPath,{hash:re.hash,mode:N.mode})}else if(A){p.add(A.newPath);let U=o.get(O),N=r.get(A.newPath),re=m.has(A.newPath);if(U)if(re)await sl(e,a,A.newPath,O,F,N,U,r,o,!1,s,i);else if(U.hash===F.hash&&N.hash===F.hash)a.entries.push(Ct(A.newPath,N));else if(U.hash===F.hash)a.entries.push(Ct(A.newPath,N));else if(N.hash===F.hash)a.entries.push(at(A.newPath,N.mode,U.hash));else{let V=aa(t,A.newPath);V.stages=[{hash:F.hash,mode:F.mode},{hash:N.hash,mode:N.mode},{hash:U.hash,mode:U.mode}],V.pathnames=[O,A.newPath,O],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=o.get(A.newPath);if(a.conflicts.push({path:A.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:O}),b(A.newPath,`CONFLICT (rename/delete): ${O} renamed to ${A.newPath} in ${g}, but deleted in ${w}.`),V){a.conflicts.push({path:A.newPath,reason:"add-add"}),b(A.newPath,`Auto-merging ${A.newPath}`,0),b(A.newPath,`CONFLICT (add/add): Merge conflict in ${A.newPath}`,1),a.entries.push(Ct(A.newPath,N,2)),a.entries.push(Ct(A.newPath,V,3));let ee=await Mo(e,N.hash,V.hash,N.mode,s);a.worktreeBlobs.set(A.newPath,{hash:ee,mode:N.mode})}else a.entries.push(at(A.newPath,F.mode,F.hash,1)),a.entries.push(Ct(A.newPath,N,2)),a.worktreeBlobs.set(A.newPath,{hash:N.hash,mode:N.mode}),N.hash!==F.hash&&b(A.newPath,`CONFLICT (modify/delete): ${A.newPath} deleted in ${w} and modified in ${g}. Version ${g} of ${A.newPath} left in tree.`,1)}}else if(L){p.add(L.newPath);let U=r.get(O),N=o.get(L.newPath),re=m.has(L.newPath);if(U)if(re)await sl(e,a,L.newPath,O,F,U,N,r,o,!0,s,i);else if(U.hash===F.hash&&N.hash===F.hash)a.entries.push(Ct(L.newPath,N));else if(U.hash===F.hash)a.entries.push(Ct(L.newPath,N));else if(N.hash===F.hash)a.entries.push(at(L.newPath,N.mode,U.hash));else{let V=aa(t,L.newPath);V.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],V.pathnames=[O,O,L.newPath],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=r.get(L.newPath);if(a.conflicts.push({path:L.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:O}),b(L.newPath,`CONFLICT (rename/delete): ${O} renamed to ${L.newPath} in ${w}, but deleted in ${g}.`),V){a.conflicts.push({path:L.newPath,reason:"add-add"}),b(L.newPath,`Auto-merging ${L.newPath}`,0),b(L.newPath,`CONFLICT (add/add): Merge conflict in ${L.newPath}`,1),a.entries.push(Ct(L.newPath,V,2)),a.entries.push(Ct(L.newPath,N,3));let ee=await Mo(e,V.hash,N.hash,V.mode,s);a.worktreeBlobs.set(L.newPath,{hash:ee,mode:V.mode})}else a.entries.push(at(L.newPath,F.mode,F.hash,1)),a.entries.push(Ct(L.newPath,N,3)),a.worktreeBlobs.set(L.newPath,{hash:N.hash,mode:N.mode}),N.hash!==F.hash&&b(L.newPath,`CONFLICT (modify/delete): ${L.newPath} deleted in ${g} and modified in ${w}. Version ${w} of ${L.newPath} left in tree.`,1)}}}let y=new Set(l.renames.map(O=>O.newPath)),x=new Set(d.renames.map(O=>O.newPath)),k=Qf(n,r),R=Qf(n,o),E=el(k,o,n),C=el(R,r,n),$=tl(l.renames,E),D=tl(d.renames,C),P=nl($),T=nl(D);for(let O of[...P.keys()])T.has(O)&&(P.delete(O),T.delete(O));let H=new Set(P.keys()),M=new Set(T.keys());if(T.size>0)for(let O of c){if(O.status!=="added"||y.has(O.path))continue;let A=rl(O.path,T,H);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(r.has(A)){b(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${O.path}.`,1);continue}let U=r.get(O.path),N=o.get(A)??n.get(A);a.entries.push(at(A,U.mode,U.hash,2)),N&&a.entries.push(at(A,N.mode,N.hash,3)),a.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),a.conflicts.push({path:A,reason:"add-add"}),b(A,`CONFLICT (file location): ${O.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${A}.`,1);let re=t.get(O.path);re&&(re.merged={result:null,clean:!0}),p.add(O.path);continue}let L=r.get(O.path);a.entries.push(at(A,L.mode,L.hash,2)),a.worktreeBlobs.set(A,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:A,reason:"directory-rename"}),b(A,`CONFLICT (file location): ${O.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(O.path);F&&(F.merged={result:null,clean:!0}),p.add(O.path)}if(P.size>0)for(let O of f){if(O.status!=="added"||x.has(O.path))continue;let A=rl(O.path,P,M);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(o.has(A)){b(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${O.path}.`,1);continue}let U=o.get(O.path),N=r.get(A)??n.get(A);N&&a.entries.push(at(A,N.mode,N.hash,2)),a.entries.push(at(A,U.mode,U.hash,3)),a.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),a.conflicts.push({path:A,reason:"add-add"}),b(A,`CONFLICT (file location): ${O.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let re=t.get(O.path);re&&(re.merged={result:null,clean:!0}),p.add(O.path);continue}let L=o.get(O.path);a.entries.push(at(A,L.mode,L.hash,3)),a.worktreeBlobs.set(A,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:A,reason:"directory-rename"}),b(A,`CONFLICT (file location): ${O.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(O.path);F&&(F.merged={result:null,clean:!0}),p.add(O.path)}let W=new Set(a.entries.map(O=>O.path));for(let O of W){let A=t.get(O);A&&(A.merged={result:null,clean:!0})}for(let O of p){if(W.has(O))continue;let A=t.get(O);if(!A||A.merged.clean)continue;A.filemask===7&&!A.pathConflict||(A.merged={result:null,clean:!0})}return a}function Qf(e,t){let n=new Set;for(let s of e.keys()){let i=Dt(s);for(;i;)n.add(i),i=Dt(i)}let r=new Set;for(let s of t.keys()){let i=Dt(s);for(;i;)r.add(i),i=Dt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function el(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=Dt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Dt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Dt(s)}return r}function tl(e,t){let n=new Map;for(let r of e){let o=Dt(r.oldPath),s=Dt(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=Dt(o),s=Dt(s)}}return n}function nl(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 rl(e,t,n){let r=Dt(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=Dt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Dt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function sl(e,t,n,r,o,s,i,a,c,f=!1,l,d){let h=f?a.get(n):c.get(n),u=f?i:s;if(h.hash===u.hash){t.entries.push(at(n,h.mode,h.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let p=await il(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8,d);if(h.hash===p.hash)t.entries.push(at(n,h.mode,p.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(Ct(n,h,2)),t.entries.push(at(n,i.mode,p.hash,3));let g=await Mo(e,h.hash,p.hash,h.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:h.mode})}else{t.entries.push(at(n,s.mode,p.hash,2)),t.entries.push(Ct(n,h,3));let g=await Mo(e,p.hash,h.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:s.mode})}}async function il(e,t,n,r,o,s,i,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(En(t.mode)||En(n.mode)||En(r.mode))return{hash:n.hash,conflict:!0};let c=await se(e,t.hash),f=await se(e,n.hash),l=await se(e,r.hash);if(He(f)||He(l)||He(c))return{hash:n.hash,conflict:!0};if(a){let R=await a({path:t.path??n.path??r.path??"",base:c,ours:f,theirs:l});if(R!==null)return{hash:await Se(e,"blob",tn.encode(R.content)),conflict:R.conflict}}let d=At(c),h=At(f),u=At(l),m=o?.conflictStyle,p=Es(h,d,u,{conflictStyle:m});if(!p.conflict)return{hash:await fa(e,p.result),conflict:!1};let g=o?.a??"HEAD",w=o?.b??"theirs",b=s?.oursPath?`${g}:${s.oursPath}`:g,y=s?.theirsPath?`${w}:${s.theirsPath}`:w,x=gr(f,c,l,{a:b,b:y,markerSize:i??7,conflictStyle:m});return{hash:await Se(e,"blob",tn.encode(x)),conflict:!0}}async function Mo(e,t,n,r,o){let s=await se(e,t),i=await se(e,n),a=gr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Se(e,"blob",tn.encode(a))}function Ct(e,t,n=0){return at(e,t.mode,t.hash,n)}function at(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:ve()}}async function op(e,t,n,r,o){let s=[...r.entries],i=[...r.conflicts],a=[...r.msgBuf],c=new Map(r.worktreeBlobs);function f(m,p,g=0){a.push({sortKey:m,subOrder:g,text:p})}for(let m of[...t.keys()].sort()){let p=t.get(m);if(p.merged.clean){p.merged.result?.hash&&s.push(Oe(m,p.merged.result.hash,p.merged.result.mode));continue}await ip(e,p,n,s,i,f,c,o)}a.sort((m,p)=>(m.sortKey<p.sortKey?-1:m.sortKey>p.sortKey?1:0)||m.subOrder-p.subOrder);let l=a.map(m=>m.text),d=[],h=new Set;for(let m of s)m.stage===0&&(d.push(m),h.add(m.path));for(let[m,p]of c)h.has(m)||d.push(Oe(m,p.hash,p.mode));d.sort((m,p)=>Te(m.path,p.path));let u=await Fe(e,d);return{entries:s,conflicts:i,messages:l,resultTree:u}}async function ip(e,t,n,r,o,s,i,a){let c=t.path,[f,l,d]=t.stages,h=f?.hash??null,u=l?.hash??null,m=d?.hash??null;if(u===null&&m!==null&&h!==null){o.push({path:c,reason:"delete-modify",deletedBy:"ours"});let p=n?.a??"HEAD",g=n?.b??"theirs";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:m,mode:d.mode});return}if(m===null&&u!==null&&h!==null){o.push({path:c,reason:"delete-modify",deletedBy:"theirs"});let p=n?.b??"theirs",g=n?.a??"HEAD";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),i.set(c,{hash:u,mode:l.mode});return}if(h===null&&u!==null&&m!==null){if(u===m){r.push(Oe(c,u,l.mode));return}s(c,`Auto-merging ${c}`,0);let p=await se(e,u),g=await se(e,m);if(He(p)||He(g)){o.push({path:c,reason:"add-add"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}if(a){let E=await a({path:c,base:null,ours:p,theirs:g});if(E!==null){let C=await Se(e,"blob",tn.encode(E.content));if(!E.conflict){r.push(Oe(c,C,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:C,mode:l.mode});return}}let w=At(""),b=At(p),y=At(g),x=Es(b,w,y,{conflictStyle:n?.conflictStyle});if(!x.conflict){let E=await fa(e,x.result);r.push(Oe(c,E,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3));let k=gr(p,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),R=await Se(e,"blob",tn.encode(k));i.set(c,{hash:R,mode:l.mode});return}if(h!==null&&u!==null&&m!==null){if(u===h){r.push(Oe(c,m,d.mode));return}if(m===h){r.push(Oe(c,u,l.mode));return}if(u===m){r.push(Oe(c,u,l.mode));return}if(s(c,`Auto-merging ${c}`,0),En(f.mode)||En(l.mode)||En(d.mode)){o.push({path:c,reason:"content"}),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}let p=await se(e,h),g=await se(e,u),w=await se(e,m);if(He(g)||He(w)||He(p)){o.push({path:c,reason:"content"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:u,mode:l.mode});return}if(a){let R=await a({path:c,base:p,ours:g,theirs:w});if(R!==null){let E=await Se(e,"blob",tn.encode(R.content));if(!R.conflict){r.push(Oe(c,E,l.mode));return}let C=t.pathnames[1],$=t.pathnames[2],D=C!==c||$!==c,P={path:c,reason:"content"};D&&(C!==c&&(P.oursOrigPath=C),$!==c&&(P.theirsOrigPath=$)),o.push(P),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:E,mode:l.mode});return}}let b=At(p),y=At(g),x=At(w),k=Es(y,b,x,{conflictStyle:n?.conflictStyle});if(k.conflict){let R=t.pathnames[1],E=t.pathnames[2],C=R!==c||E!==c,$={path:c,reason:"content"};C&&(R!==c&&($.oursOrigPath=R),E!==c&&($.theirsOrigPath=E)),o.push($),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,h,f.mode,1)),r.push(Oe(c,u,l.mode,2)),r.push(Oe(c,m,d.mode,3));let D=C?`${n?.a??"HEAD"}:${R}`:n?.a??"HEAD",P=C?`${n?.b??"theirs"}:${E}`:n?.b??"theirs",T=gr(g,p,w,{a:D,b:P,conflictStyle:n?.conflictStyle}),H=await Se(e,"blob",tn.encode(T));i.set(c,{hash:H,mode:l.mode})}else{let R=await fa(e,k.result);r.push(Oe(c,R,l.mode))}return}}var ap=200;async function al(e,t,n,r,o,s){let i=await Promise.all(r.map(async d=>({hash:d,timestamp:(await G(e,d)).committer.timestamp})));i.sort((d,h)=>d.timestamp-h.timestamp);let a=i.map(d=>d.hash),c=a[0],f=c,l=(await G(e,c)).tree;for(let d=1;d<a.length;d++){let h=a[d],u=(await G(e,h)).tree,m=null;if(o>=ap)m=l;else{let w=await qt(e,f,h);w.length===0?m=null:w.length===1?m=(await G(e,w[0])).tree:m=await al(e,f,h,w,o+1,s)}let p=await Kt(e,m,l,u,void 0,s);l=await cp(e,p,o);let g=an({type:"commit",tree:l,parents:[f,h],author:Jf,committer:Jf,message:"merged common ancestors"});f=await Se(e,"commit",g)}return l}async function cp(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,h=s(a.path,1),u=s(l,2),m=s(d,3);if(u&&m){let p=Gr.decode((await ye(e,u.hash)).content),g=Gr.decode((await ye(e,m.hash)).content),w=h?Gr.decode((await ye(e,h.hash)).content):"",b=8+n*2,y=i.a??"Temporary merge branch 1",x=i.b??"Temporary merge branch 2",k=gr(p,w,g,{a:`${y}:${l}`,o:i.o,b:`${x}:${d}`,markerSize:b}),R=await Se(e,"blob",tn.encode(k));r.push({path:l,mode:u.mode,hash:R,stage:0,stat:ve()}),r.push({path:d,mode:m.mode,hash:R,stage:0,stat:ve()});continue}else if(u){r.push({...u,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=Gr.decode((await ye(e,c.hash)).content),d=Gr.decode((await ye(e,f.hash)).content),h=a.reason==="content"?s(a.path,1):null,u=h?Gr.decode((await ye(e,h.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=m?`${p}:${a.oursOrigPath??a.path}`:p,b=m?`${g}:${a.theirsOrigPath??a.path}`:g,y=gr(l,u,d,{a:w,o:i.o,b,markerSize:i.markerSize}),x=await Se(e,"blob",tn.encode(y));r.push({path:a.path,mode:c.mode,hash:x,stage:0,stat:ve()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Te(a.path,c.path)),Fe(e,r)}async function fa(e,t){let n=t.map(ia);if(n.length===0)return Se(e,"blob",tn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
252
252
  `):`${n.join(`
253
253
  `)}
254
- `;return Se(e,"blob",tn.encode(s))}function Oe(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:ve()}}function aa(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 Es(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}
254
+ `;return Se(e,"blob",tn.encode(s))}function Oe(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:ve()}}function aa(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 ks(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}
255
255
  ${e.join(" ")}
256
256
  Merge with strategy ort failed.
257
257
  `;let c=e.map(l=>` ${l}`).join(`
@@ -276,36 +276,36 @@ ${i}
276
276
  Please move or remove them before you ${n}.
277
277
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
278
278
  ${s}
279
- `}async function Sn(e,t,n,r){let o=await z(e),s=await de(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let m=new Map(Ne(o).map(g=>[g.path,g])),p=[];for(let[g,w]of m){let b=s.get(g);(!b||b.hash!==w.hash)&&p.push(g)}for(let[g]of s)m.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await ca(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Es(g,w,b,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let m=await cr(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:ao,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!m.success){await ca(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(R=>R.error==="WOULD_OVERWRITE"||R.error==="NOT_UPTODATE_FILE").map(R=>R.path).sort(),b=m.errors.filter(R=>R.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||R.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(R=>R.path).sort(),k;return w.length>0&&b.length>0?k=ol(w,b,p,g):b.length>0?k=Es(b,p,g,"untracked","worktree"):k=Es(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:k,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let m=await cr(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!m.success){await ca(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(C=>C.error==="WOULD_OVERWRITE"||C.error==="NOT_UPTODATE_FILE").map(C=>C.path).sort(),b=m.errors.filter(C=>C.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||C.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(C=>C.path).sort(),k=[];w.length>0&&k.push(Es(w,p,g,"local","worktree")),b.length>0&&k.push(Es(b,p,g,"untracked","worktree"));let R;return k.length>1?R=ol(w,b,p,g):R=k[0]??"",{ok:!1,stdout:"",stderr:R,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await je(e,m.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let m=[];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}}m.push(p)}a=m}let c=new Set(a.map(m=>m.path));for(let m of s.keys())i.has(m)||c.add(m);let f=o.entries.filter(m=>!c.has(m.path)),l=[...a,...f];l.sort((m,p)=>Te(m.path,p.path)||m.stage-p.stage);let d={version:2,entries:l};await ae(e,d);let h=l.filter(m=>m.stage===0),u=await Fe(e,h);return{ok:!0,finalIndex:d,mergedTreeHash:u}}async function ca(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=v(e.workTree,r.path);await e.fs.exists(o)||await lt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();ze();we();De();Jt();function cl(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:S().describe("Abort the current cherry-pick operation"),continue:S().describe("Continue the cherry-pick after conflict resolution"),skip:S().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":S().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:Y.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:S().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let G=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(fe(G))return{stdout:"",stderr:G.message??"",exitCode:1};let F=await lp(s,r.env);return F.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),F}if(n.continue){let G=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(fe(G))return{stdout:"",stderr:G.message??"",exitCode:1};let F=await dp(s,r.env);if(F.exitCode===0){let U=await X(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:U,hadConflicts:!1})}return F}if(n.skip)return fp(s,r.env);let i=n.commit;if(!i)return T("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Le(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let h=await z(s);if(n.noCommit){let G=h.entries.filter(F=>F.stage>0);if(G.length>0){let N=G.slice(0,10).map(V=>`${V.path}: unmerged (${V.hash})`).join(`
280
- `),ne=G.length>10?`
281
- ...`:"";return _(`${N}${ne}
279
+ `}async function In(e,t,n,r){let o=await z(e),s=await de(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let m=new Map(Ne(o).map(g=>[g.path,g])),p=[];for(let[g,w]of m){let b=s.get(g);(!b||b.hash!==w.hash)&&p.push(g)}for(let[g]of s)m.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await ca(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ks(g,w,b,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let m=await cr(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:ao,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!m.success){await ca(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(x=>x.error==="WOULD_OVERWRITE"||x.error==="NOT_UPTODATE_FILE").map(x=>x.path).sort(),b=m.errors.filter(x=>x.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||x.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(x=>x.path).sort(),y;return w.length>0&&b.length>0?y=ol(w,b,p,g):b.length>0?y=ks(b,p,g,"untracked","worktree"):y=ks(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:y,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let m=await cr(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!m.success){await ca(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),b=m.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),y=[];w.length>0&&y.push(ks(w,p,g,"local","worktree")),b.length>0&&y.push(ks(b,p,g,"untracked","worktree"));let x;return y.length>1?x=ol(w,b,p,g):x=y[0]??"",{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await je(e,m.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let m=[];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}}m.push(p)}a=m}let c=new Set(a.map(m=>m.path));for(let m of s.keys())i.has(m)||c.add(m);let f=o.entries.filter(m=>!c.has(m.path)),l=[...a,...f];l.sort((m,p)=>Te(m.path,p.path)||m.stage-p.stage);let d={version:2,entries:l};await ae(e,d);let h=l.filter(m=>m.stage===0),u=await Fe(e,h);return{ok:!0,finalIndex:d,mergedTreeHash:u}}async function ca(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=v(e.workTree,r.path);await e.fs.exists(o)||await lt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();Ke();we();De();Jt();function cl(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[K.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:I().describe("Abort the current cherry-pick operation"),continue:I().describe("Continue the cherry-pick after conflict resolution"),skip:I().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":I().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:Y.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:I().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.abort){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(fe(L))return{stdout:"",stderr:L.message??"",exitCode:1};let F=await lp(s,r.env);return F.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),F}if(n.continue){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(fe(L))return{stdout:"",stderr:L.message??"",exitCode:1};let F=await dp(s,r.env);if(F.exitCode===0){let U=await X(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:U,hadConflicts:!1})}return F}if(n.skip)return fp(s,r.env);let i=n.commit;if(!i)return S("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Le(s,i);if(j(c))return c;let f=c.hash,l=c.commit,d=await Je(s);if(j(d))return d;let h=await z(s);if(n.noCommit){let L=h.entries.filter(F=>F.stage>0);if(L.length>0){let N=L.slice(0,10).map(V=>`${V.path}: unmerged (${V.hash})`).join(`
280
+ `),re=L.length>10?`
281
+ ...`:"";return _(`${N}${re}
282
282
  error: your index file is unmerged.
283
283
  fatal: cherry-pick failed
284
- `,128)}}else{let G=$n(h,"Cherry-picking",`fatal: cherry-pick failed
285
- `);if(G)return G}let u=await j(s,d),p=!!n["record-origin"]?up(l.message,f):l.message;if(s.workTree&&!n.noCommit){let G=await de(s,u.tree);if(qn(h,G))return _(`error: your local changes would be overwritten by cherry-pick.
284
+ `,128)}}else{let L=Pn(h,"Cherry-picking",`fatal: cherry-pick failed
285
+ `);if(L)return L}let u=await G(s,d),p=!!n["record-origin"]?up(l.message,f):l.message;if(s.workTree&&!n.noCommit){let L=await de(s,u.tree);if(Wn(h,L))return _(`error: your local changes would be overwritten by cherry-pick.
286
286
  hint: commit your changes or stash them to proceed.
287
287
  fatal: cherry-pick failed
288
288
  `,128)}if(l.parents.length>1){if(!n.mainline)return _(`error: commit ${f} is a merge but no -m option was given.
289
289
  fatal: cherry-pick failed
290
- `,128);let G=n.mainline-1;if(G<0||G>=l.parents.length)return _(`error: commit ${f} does not have parent ${n.mainline}
290
+ `,128);let L=n.mainline-1;if(L<0||L>=l.parents.length)return _(`error: commit ${f} does not have parent ${n.mainline}
291
291
  fatal: cherry-pick failed
292
292
  `,128)}else if(n.mainline)return _(`error: mainline was specified but commit is not a merge.
293
293
  fatal: cherry-pick failed
294
- `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let G=l.parents.length>1?n.mainline-1:0,F=l.parents[G];if(!F)throw new Error("unreachable: parent must exist");g=(await j(s,F)).tree}let w=Z(f),b=ue(l.message),k=await xe(s,"merge.conflictstyle")??"merge",R={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:k},C=await zt(s,g,u.tree,l.tree,R);if(C.conflicts.length===0&&C.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p);let G=C.messages.length>0?`${C.messages.join(`
294
+ `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let L=l.parents.length>1?n.mainline-1:0,F=l.parents[L];if(!F)throw new Error("unreachable: parent must exist");g=(await G(s,F)).tree}let w=Z(f),b=ue(l.message),y=await xe(s,"merge.conflictstyle")??"merge",x={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:y},k=await Kt(s,g,u.tree,l.tree,x);if(k.conflicts.length===0&&k.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p);let L=k.messages.length>0?`${k.messages.join(`
295
295
  `)}
296
- `:"",F=await it(s,{fromCommit:!0});return{stdout:`${G}${F}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
296
+ `:"",F=await ot(s,{fromCommit:!0});return{stdout:`${L}${F}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
297
297
  If you wish to commit it anyway, use:
298
298
 
299
299
  git commit --allow-empty
300
300
 
301
301
  Otherwise, please use 'git cherry-pick --skip'
302
- `,exitCode:1}}let E=await Sn(s,C,u.tree,{labels:R,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(C.conflicts.length>0){let G=C.messages.join(`
303
- `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:G?`${G}
302
+ `,exitCode:1}}let R=await In(s,k,u.tree,{labels:x,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!R.ok)return R;if(k.conflicts.length>0){let L=k.messages.join(`
303
+ `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:L?`${L}
304
304
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
305
305
  hint: after resolving the conflicts, mark the corrected paths
306
306
  hint: with 'git add <paths>' or 'git rm <paths>'
307
307
  hint: Disable this message with "git config set advice.mergeConflict false"
308
- `,exitCode:1}:(await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p),{stdout:G?`${G}
308
+ `,exitCode:1}:(await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p),{stdout:L?`${L}
309
309
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
310
310
  hint: After resolving the conflicts, mark them with
311
311
  hint: "git add/rm <pathspec>", then run
@@ -314,117 +314,117 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
314
314
  hint: To abort and get back to the state before "git cherry-pick",
315
315
  hint: run "git cherry-pick --abort".
316
316
  hint: Disable this message with "git config set advice.mergeConflict false"
317
- `,exitCode:1})}let y=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let x=await nt(s,r.env);if(M(x))return x;let $=await yt(s,y,[d],l.author,x,p);await Ft(s),await St(s);let A=await Q(s),P=p.split(`
318
- `)[0]??"",O=A?.type==="symbolic"?A.target:"HEAD";await se(s,r.env,O,d,$,`cherry-pick: ${P}`,A?.type==="symbolic");let D=A?.type==="symbolic"?Pe(A.target):"detached HEAD",L=u.tree,K=await pn(s,L,y,l.author,x,!0),I=Lt(D,$,p),H=C.messages.length>0?`${C.messages.join(`
317
+ `,exitCode:1})}let E=R.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await tt(s,r.env);if(j(C))return C;let $=await yt(s,E,[d],l.author,C,p);await Ft(s),await St(s);let D=await Q(s),P=p.split(`
318
+ `)[0]??"",T=D?.type==="symbolic"?D.target:"HEAD";await ne(s,r.env,T,d,$,`cherry-pick: ${P}`,D?.type==="symbolic");let H=D?.type==="symbolic"?Pe(D.target):"detached HEAD",M=u.tree,W=await mn(s,M,E,l.author,C,!0),O=Lt(H,$,p),A=k.messages.length>0?`${k.messages.join(`
319
319
  `)}
320
- `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:$,hadConflicts:!1}),{stdout:`${H}${I}
321
- ${K}`,stderr:"",exitCode:0}}})}async function fp(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
320
+ `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:$,hadConflicts:!1}),{stdout:`${A}${O}
321
+ ${W}`,stderr:"",exitCode:0}}})}async function fp(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
322
322
  fatal: cherry-pick failed
323
- `,128);let r=await X(e);if(!r)return T("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Tr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
323
+ `,128);let r=await X(e);if(!r)return S("unable to resolve HEAD");let o=await G(e,r),s=await z(e),i=await vr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
324
324
  fatal: cherry-pick failed
325
- `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await se(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Ft(e),{stdout:"",stderr:"",exitCode:0}}async function lp(e,t){return await B(e,"CHERRY_PICK_HEAD")?zn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
325
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Ft(e),{stdout:"",stderr:"",exitCode:0}}async function lp(e,t){return await B(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
326
326
  fatal: cherry-pick failed
327
- `,128),operationName:"cherry-pick",clearState:Ft,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?zn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
327
+ `,128),operationName:"cherry-pick",clearState:Ft,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
328
328
  fatal: cherry-pick failed
329
329
  `,128),operationName:"cherry-pick",clearState:St,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
330
330
  fatal: cherry-pick failed
331
331
  `,128)}async function dp(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return _(`error: no cherry-pick or revert in progress
332
332
  fatal: cherry-pick failed
333
- `,128);let r=await z(e),o=$n(r,"Committing");if(o)return o;let s=await j(e,n),i=await $e(e,"MERGE_MSG");if(!i)return _(`Aborting commit due to empty commit message.
333
+ `,128);let r=await z(e),o=Pn(r,"Committing");if(o)return o;let s=await G(e,n),i=await $e(e,"MERGE_MSG");if(!i)return _(`Aborting commit due to empty commit message.
334
334
  `,1);let a=await $e(e,"SQUASH_MSG");if(a&&(i=a+i),i=It(i),!i)return _(`Aborting commit due to empty commit message.
335
- `,1);let c=Ne(r),f=await Fe(e,c),l=await Qe(e);if(M(l))return l;let h=(await j(e,l)).tree,u=await nt(e,t);if(M(u))return u;let m=Nt(i),p=await yt(e,f,[l],s.author,u,m);await Ft(e),await St(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await se(e,t,b,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let k=g?.type==="symbolic"?Pe(g.target):"detached HEAD",R=await pn(e,h,f,s.author,u,!0);return{stdout:`${Lt(k,p,i)}
336
- ${R}`,stderr:"",exitCode:0}}function up(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
335
+ `,1);let c=Ne(r),f=await Fe(e,c),l=await Je(e);if(j(l))return l;let h=(await G(e,l)).tree,u=await tt(e,t);if(j(u))return u;let m=Nt(i),p=await yt(e,f,[l],s.author,u,m);await Ft(e),await St(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await ne(e,t,b,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let y=g?.type==="symbolic"?Pe(g.target):"detached HEAD",x=await mn(e,h,f,s.author,u,!0);return{stdout:`${Lt(y,p,i)}
336
+ ${x}`,stderr:"",exitCode:0}}function up(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
337
337
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
338
338
  ${n}
339
339
  `:`${r}
340
340
 
341
341
  ${n}
342
- `}oe();Be();io();Ce();pe();function fl(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:S().alias("f").describe("Required to actually remove files"),"dry-run":S().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:S().alias("d").describe("Also remove untracked directories"),removeIgnored:S().alias("x").describe("Remove ignored files as well"),onlyIgnored:S().alias("X").describe("Remove only ignored files"),exclude:Y.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=Ve(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,h=n.onlyIgnored;if(!f&&!c&&await xe(s,"clean.requireForce")!=="false")return T("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let u=await z(s),m=new Set(u.entries.map(y=>y.path)),p=dt(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(y=>Ue(y,p)):null,b=n.exclude?[n.exclude]:[],k=await ll(s,a,"",{trackedPaths:m,removeDirs:l,removeIgnored:d,onlyIgnored:h,extraExcludes:b}),R;w?R=k.filter(y=>Ee(w,y.path)):R=k,R.sort((y,x)=>y.path<x.path?-1:y.path>x.path?1:0);let C=[];if(c)for(let y of R){let x=y.isDir?`Would remove ${y.path}/`:`Would remove ${y.path}`;C.push(x)}else for(let y of R){let x=v(a,y.path);y.isDir?(await r.fs.rm(x,{recursive:!0}),C.push(`Removing ${y.path}/`)):(await r.fs.rm(x),C.push(`Removing ${y.path}`))}return{stdout:C.length>0?`${C.join(`
342
+ `}oe();Be();io();Ce();me();function fl(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[K.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:I().alias("f").describe("Required to actually remove files"),"dry-run":I().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:I().alias("d").describe("Also remove untracked directories"),removeIgnored:I().alias("x").describe("Remove ignored files as well"),onlyIgnored:I().alias("X").describe("Remove only ignored files"),exclude:Y.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,h=n.onlyIgnored;if(!f&&!c&&await xe(s,"clean.requireForce")!=="false")return S("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let u=await z(s),m=new Set(u.entries.map(E=>E.path)),p=dt(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(E=>Ue(E,p)):null,b=n.exclude?[n.exclude]:[],y=await ll(s,a,"",{trackedPaths:m,removeDirs:l,removeIgnored:d,onlyIgnored:h,extraExcludes:b}),x;w?x=y.filter(E=>Ee(w,E.path)):x=y,x.sort((E,C)=>E.path<C.path?-1:E.path>C.path?1:0);let k=[];if(c)for(let E of x){let C=E.isDir?`Would remove ${E.path}/`:`Would remove ${E.path}`;k.push(C)}else for(let E of x){let C=v(a,E.path);E.isDir?(await r.fs.rm(C,{recursive:!0}),k.push(`Removing ${E.path}/`)):(await r.fs.rm(C),k.push(`Removing ${E.path}`))}return{stdout:k.length>0?`${k.join(`
343
343
  `)}
344
- `:"",stderr:"",exitCode:0}}})}async function ll(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Sr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=ir(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
345
- `),l=ds(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=v(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let h=i&&dn(i,l,!0)==="ignored",u=hp(r.trackedPaths,l),m=()=>ll(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(h&&!u){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await m();!u&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(u){let p=await m();o.push(...p)}else if(!(h&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await m(),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 h=i&&dn(i,l,!1)==="ignored";r.onlyIgnored?h&&o.push({path:l,isDir:!1}):h&&s||o.push({path:l,isDir:!1})}}return o}function hp(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}oe();Be();Hn();Ce();ie();pe();ze();we();_n();ie();pe();var Rs=2147483647;async function Gr(e){let t=v(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
344
+ `:"",stderr:"",exitCode:0}}})}async function ll(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Tr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=ir(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
345
+ `),l=us(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=v(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let h=i&&ln(i,l,!0)==="ignored",u=hp(r.trackedPaths,l),m=()=>ll(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(h&&!u){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await m();!u&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(u){let p=await m();o.push(...p)}else if(!(h&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await m(),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 h=i&&ln(i,l,!1)==="ignored";r.onlyIgnored?h&&o.push({path:l,isDir:!1}):h&&s||o.push({path:l,isDir:!1})}}return o}function hp(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}oe();Be();Ce();ie();me();Ke();we();Nn();ie();me();var xs=2147483647;async function Lr(e){let t=v(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
346
346
  `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function mp(e,t){let n=v(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(`
347
347
  `)+`
348
- `)}async function jo(e){return(await Gr(e)).size>0}async function Lr(e,t,n){let r=n??await Gr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await mp(e,r)}async function dl(e,t,n,r){if(n>=Rs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await $t(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 h of d.parents)!o.has(h)&&await $t(e,h)&&(o.set(h,l+1),s.push({hash:h,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}}Be();_n();pt();ie();var Lo=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]),pp=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]),Go=64,gp=4,la=4096,ul=65536,wp=127;function bp(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=Ep(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let h=n*16-16;h>=0;h-=16){let u=0;for(let m=1;m<=16;m++)u=(u<<8|e[h+m])^Lo[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=h+16;else{a=u;let m=u&o;i.push({ptr:h+16,val:u}),s[m]++}}let c=new Map;for(let h of i){let u=h.val&o,m=c.get(u);m||(m=[],c.set(u,m)),m.push(h)}for(let[h,u]of c){if(u.length<=Go)continue;let m=[],p=u.length/Go;for(let g=0;g<Go;g++)m.push(u[Math.floor(g*p)]);c.set(h,m),s[h]=Go}let f=new Uint32Array(r+1),l=[],d=0;for(let h=0;h<r;h++){f[h]=d;let u=c.get(h);if(u){for(let m of u)l.push(m);d+=u.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function yp(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=ml(i,a,r),a=ml(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])^Lo[f>>>23],l++;f=f>>>0;let h=d,u=0,m=0;for(;h<o;){if(m<la){f^=pp[t[h-16]],f=((f<<8|t[h])^Lo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let b=g;b<w;b++){let k=e.entries[b];if(k.val!==f)continue;let R=k.ptr,C=s.byteLength-R,E=o-h;if(C>E&&(C=E),C<=m)break;let y=0;for(;y<C&&s[R+y]===t[h+y];)y++;if(y>m&&(m=y,u=R,m>=la))break}}if(m<gp)c(2),l===0&&a++,i[a++]=t[h++],l++,l===wp&&(i[a-l-1]=l,l=0),m=0;else{if(l>0){for(;u>0&&s[u-1]===t[h-1];)if(m++,u--,h--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=m>ul?m-ul:0;m-=p,c(8);let g=a++,w=128;if(u&255&&(i[a++]=u&255,w|=1),u&65280&&(i[a++]=u>>>8&255,w|=2),u&16711680&&(i[a++]=u>>>16&255,w|=4),u&4278190080&&(i[a++]=u>>>24&255,w|=8),m&255&&(i[a++]=m&255,w|=16),m&65280&&(i[a++]=m>>>8&255,w|=32),i[g]=w,h+=m,u+=m,m=p,u>4294967295&&(m=0),m<la){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[h+b])^Lo[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 hl={blob:0,tree:1,commit:2,tag:3};function No(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=hl[f.type]??99,h=hl[l.type]??99;return d!==h?d-h: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},h=null,u=null,m=Math.max(0,f-n);for(let p=f-1;p>=m;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 k=a[p-m]??null;if(!k)continue;let R=h?h.byteLength:l.content.byteLength/2|0;if(R<16)continue;let C=yp(k,l.content,R);C&&(!h||C.byteLength<h.byteLength)&&(h=C,u=g.hash)}if(h&&u){d.delta=h,d.deltaBase=u;let p=s.get(u);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(bp(l.content)),c.push(l.hash)}return i}function Ep(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 ml(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}$r();we();ie();bn();Ir();no();async function kp(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await xs(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let h of d.parents)i.has(h)||a.push(h)}catch{}let c=[],f=new Set;for(let l of a)await Cs(e,l,i,f,c,r);return{count:c.length,objects:Rp(c)}}async function Nr(e,t,n,r,o){let{count:s,objects:i}=await kp(e,t,n,r,o);return{count:s,objects:xp(e,i)}}async function*Rp(e){for(let t of e)yield t}async function*xp(e,t){for await(let n of t){let r=await ye(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function _r(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function xs(e,t,n,r){if(n.has(t)||(n.add(t),!await $t(e,t)))return;let o=await ye(e,t);switch(o.type){case"commit":{let s=an(o.content);if(await xs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await xs(e,i,n,r);break}case"tree":{let s=xn(o.content);for(let i of s.entries)await xs(e,i.hash,n,r);break}case"tag":{let s=Zt(o.content);await xs(e,s.object,n,r);break}case"blob":break}}async function Cs(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await ye(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=an(i.content);if(await Cs(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Cs(e,c,n,r,o,s);break}case"tree":{let a=xn(i.content);for(let c of a.entries)await Cs(e,c.hash,n,r,o,s);break}case"tag":{let a=Zt(i.content);await Cs(e,a.object,n,r,o,s);break}case"blob":break}}var Cp=new TextEncoder,_o=new TextDecoder,pl=65520,Pp=new Uint8Array([48,48,48,48]),qR=new Uint8Array([48,48,48,49]),zR=new Uint8Array([48,48,48,50]);function Tn(e){let t=typeof e=="string"?Cp.encode(e):e,n=4+t.byteLength;if(n>pl)throw new Error(`pkt-line too long: ${n} bytes (max ${pl})`);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 da(){return Pp.slice()}function Fo(...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 Fr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=_o.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===1){t.push({type:"delim"}),n+=4;continue}if(o===2){t.push({type:"response-end"}),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 Uo(e){if(e.type!=="data")return"";let t=_o.decode(e.data);return t.endsWith(`
349
- `)?t.slice(0,-1):t}var $p=1,Op=2,Ip=3;function ua(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case $p:t.push(f),o+=f.byteLength;break;case Op:n.push(_o.decode(f));break;case Ip:r.push(_o.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}}pt();function ha(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ma(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ha(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=Fr(c);return Sp(f,t)}function Sp(e,t){let n=0,r=e[n];r?.type==="data"&&Uo(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;if(a.type!=="data")continue;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 h=l.slice(0,d),u=l.slice(d+1);if(!(h===te&&u==="capabilities^{}")){if(u.endsWith("^{}")){let m=u.slice(0,-3),p=o.find(g=>g.name===m);p&&(p.peeledHash=h);continue}o.push({name:u,hash:h})}}return{refs:o,capabilities:s,symrefs:i}}var Tp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function gl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=bl(r,Tp),c=[];c.push(Tn(`want ${t[0]} ${a.join(" ")}
350
- `));for(let u=1;u<t.length;u++)c.push(Tn(`want ${t[u]}
351
- `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(Tn(`shallow ${u}
352
- `));i?.depth!==void 0&&c.push(Tn(`deepen ${i.depth}
353
- `)),c.push(da());for(let u of n)c.push(Tn(`have ${u}
354
- `));c.push(Tn(`done
355
- `));let f=Fo(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ha(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let h=new Uint8Array(await d.arrayBuffer());return vp(h,a.includes("side-band-64k"))}function vp(e,t){let n=Fr(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let h=n[d];if(!h||h.type==="flush"){i=d+1;continue}if(h.type!=="data")continue;let u=Uo(h);if(u.startsWith("shallow "))o.push(u.slice(8)),i=d+1;else if(u.startsWith("unshallow "))s.push(u.slice(10)),i=d+1;else if(u.startsWith("ACK ")||u==="NAK")r.push(u),i=d+1;else{i=d;break}}let a=n.slice(i);if(t){let{packData:d,progress:h,errors:u}=ua(a);if(u.length>0)throw new Error(`Remote error: ${u.join("")}`);return{packData:d,acks:r,progress:h,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 Hp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function wl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=bl(r,Hp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Tn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
356
- `));for(let m of f)a.push(Tn(`${m.oldHash} ${m.newHash} ${m.refName}
357
- `));a.push(da());let l;if(n&&n.byteLength>0){let m=Fo(...a);l=new Uint8Array(m.byteLength+n.byteLength),l.set(m,0),l.set(n,m.byteLength)}else l=Fo(...a);let d=e.replace(/\/+$/,""),h=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ha(o),"User-Agent":"just-git/1.0"},body:l});if(!h.ok)throw new Error(`HTTP ${h.status} pushing to ${d}`);let u=new Uint8Array(await h.arrayBuffer());return i.includes("report-status")?Ap(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Ap(e,t){let n,r=[];if(t){let a=Fr(e),{packData:c,progress:f,errors:l}=ua(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Fr(c)}else n=Fr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=Uo(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 bl(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 Ps=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 B(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Q(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 dl(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await pa(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Zs(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 pa(this.local,n,r);s&&await Zs(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 en(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}}},$s=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 ma(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 ma(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 gl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Zs(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){let n=new Set,r=[];for(let u of t)if(u.oldHash&&u.oldHash!==te&&u.newHash!==te&&!u.ok&&!await en(this.local,u.oldHash,u.newHash)){let g=await $t(this.local,u.oldHash)?"non-fast-forward":"fetch first";n.add(u.name),r.push({...u,ok:!1,error:g})}let o=t.filter(u=>!n.has(u.name));if(o.length===0)return{updates:r};let s=await this.ensurePushDiscovery(),i=o.map(u=>({oldHash:u.oldHash??te,newHash:u.newHash,refName:u.name})),a=[],c=[],f=!1;for(let u of o)u.newHash!==te&&(a.push(u.newHash),f=!0),u.oldHash&&u.oldHash!==te&&c.push(u.oldHash);let l=null;f&&(l=await pa(this.local,a,c)??null);let d=await wl(this.url,i,l,s,this.auth,this.fetchFn);return{updates:[...o.map(u=>{let m=d.refResults.find(w=>w.name===u.name),p=m?.ok??d.unpackOk,g=m?.error??(!p&&d.unpackError?`unpack failed: ${d.unpackError}`:void 0);return{...u,ok:p,error:g}}),...r]}}};async function pa(e,t,n,r,o){let s=await Nr(e,t,n,r,o);if(s.count===0)return;let i=await _r(s),c=No(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Ys(c);return f}function Dp(e){if(!Bo(e))return{url:e};try{let t=new URL(e);if(!t.username&&!t.password)return{url:e};let n={type:"basic",username:decodeURIComponent(t.username),password:decodeURIComponent(t.password)};return t.username="",t.password="",{url:t.href,embeddedAuth:n}}catch{return{url:e}}}function wr(e,t){let n=Dp(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function Mp(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 Bo(e){return e.startsWith("http://")||e.startsWith("https://")}function yl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function El(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(Bo(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 jp(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 kl(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=jp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function Rl(e,t,n,r){let o=wr(t,e.credentialCache).url;if(Bo(o)){let s=El(o,e.networkPolicy);if(s)throw new Error(s);let i=await kl(e,o,n);return new $s(e,o,i,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw yl(o)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`):new Error(`'${o}' does not appear to be a git repository`);return new Ps(e,r)}async function Ur(e,t,n){let r=await Mp(e,t);if(!r)return null;let o=wr(r.url,e.credentialCache).url;if(Bo(o)){let i=El(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await kl(e,o,n):void 0;return{transport:new $s(e,o,a,e.fetchFn),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await or(e.fs,o);if(!s){if(yl(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new Ps(e,s),config:{...r,url:o}}}De();tt();function xl(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:S().describe("Create a bare clone"),branch:Y.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Y.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return T("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=wr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Mt(r.cwd,o),a=await or(r.fs,c)),!a)return T(`repository '${o}' does not exist`);let f=n.directory;if(!f){let O;s||o.includes("://")?O=c.split("/").pop()??c:O=Vr(c),O.endsWith(".git")&&(O=O.slice(0,-4)),f=O}let l=Mt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(fe(d))return _(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return T(`destination path '${f}' already exists and is not an empty directory.`)}catch{return T(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:h}=await Qs(r.fs,l,{bare:n.bare}),u=t?{...h,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote,credentialCache:t.credentialCache}:h,m=await he(u);m['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Xe(u,m);let p;try{p=await Rl(u,c,r.env,a??void 0)}catch(O){let D=O instanceof Error?O.message:"";return D.startsWith("network")?T(D):T(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
348
+ `)}async function jo(e){return(await Lr(e)).size>0}async function Nr(e,t,n){let r=n??await Lr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await mp(e,r)}async function dl(e,t,n,r){if(n>=xs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await $t(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 G(e,f)}catch{continue}for(let h of d.parents)!o.has(h)&&await $t(e,h)&&(o.set(h,l+1),s.push({hash:h,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}}Be();Nn();pt();ie();var Lo=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]),pp=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]),Go=64,gp=4,la=4096,ul=65536,wp=127;function bp(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=Ep(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let h=n*16-16;h>=0;h-=16){let u=0;for(let m=1;m<=16;m++)u=(u<<8|e[h+m])^Lo[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=h+16;else{a=u;let m=u&o;i.push({ptr:h+16,val:u}),s[m]++}}let c=new Map;for(let h of i){let u=h.val&o,m=c.get(u);m||(m=[],c.set(u,m)),m.push(h)}for(let[h,u]of c){if(u.length<=Go)continue;let m=[],p=u.length/Go;for(let g=0;g<Go;g++)m.push(u[Math.floor(g*p)]);c.set(h,m),s[h]=Go}let f=new Uint32Array(r+1),l=[],d=0;for(let h=0;h<r;h++){f[h]=d;let u=c.get(h);if(u){for(let m of u)l.push(m);d+=u.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function yp(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=ml(i,a,r),a=ml(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])^Lo[f>>>23],l++;f=f>>>0;let h=d,u=0,m=0;for(;h<o;){if(m<la){f^=pp[t[h-16]],f=((f<<8|t[h])^Lo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let b=g;b<w;b++){let y=e.entries[b];if(y.val!==f)continue;let x=y.ptr,k=s.byteLength-x,R=o-h;if(k>R&&(k=R),k<=m)break;let E=0;for(;E<k&&s[x+E]===t[h+E];)E++;if(E>m&&(m=E,u=x,m>=la))break}}if(m<gp)c(2),l===0&&a++,i[a++]=t[h++],l++,l===wp&&(i[a-l-1]=l,l=0),m=0;else{if(l>0){for(;u>0&&s[u-1]===t[h-1];)if(m++,u--,h--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=m>ul?m-ul:0;m-=p,c(8);let g=a++,w=128;if(u&255&&(i[a++]=u&255,w|=1),u&65280&&(i[a++]=u>>>8&255,w|=2),u&16711680&&(i[a++]=u>>>16&255,w|=4),u&4278190080&&(i[a++]=u>>>24&255,w|=8),m&255&&(i[a++]=m&255,w|=16),m&65280&&(i[a++]=m>>>8&255,w|=32),i[g]=w,h+=m,u+=m,m=p,u>4294967295&&(m=0),m<la){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[h+b])^Lo[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 hl={blob:0,tree:1,commit:2,tag:3};function No(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=hl[f.type]??99,h=hl[l.type]??99;return d!==h?d-h: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},h=null,u=null,m=Math.max(0,f-n);for(let p=f-1;p>=m;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 y=a[p-m]??null;if(!y)continue;let x=h?h.byteLength:l.content.byteLength/2|0;if(x<16)continue;let k=yp(y,l.content,x);k&&(!h||k.byteLength<h.byteLength)&&(h=k,u=g.hash)}if(h&&u){d.delta=h,d.deltaBase=u;let p=s.get(u);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(bp(l.content)),c.push(l.hash)}return i}function Ep(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 ml(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}$r();we();ie();wn();Ir();no();async function kp(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await Cs(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await G(e,l);for(let h of d.parents)i.has(h)||a.push(h)}catch{}let c=[],f=new Set;for(let l of a)await Ps(e,l,i,f,c,r);return{count:c.length,objects:Rp(c)}}async function _r(e,t,n,r,o){let{count:s,objects:i}=await kp(e,t,n,r,o);return{count:s,objects:xp(e,i)}}async function*Rp(e){for(let t of e)yield t}async function*xp(e,t){for await(let n of t){let r=await ye(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Fr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Cs(e,t,n,r){if(n.has(t)||(n.add(t),!await $t(e,t)))return;let o=await ye(e,t);switch(o.type){case"commit":{let s=on(o.content);if(await Cs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await Cs(e,i,n,r);break}case"tree":{let s=Rn(o.content);for(let i of s.entries)await Cs(e,i.hash,n,r);break}case"tag":{let s=Zt(o.content);await Cs(e,s.object,n,r);break}case"blob":break}}async function Ps(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await ye(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=on(i.content);if(await Ps(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Ps(e,c,n,r,o,s);break}case"tree":{let a=Rn(i.content);for(let c of a.entries)await Ps(e,c.hash,n,r,o,s);break}case"tag":{let a=Zt(i.content);await Ps(e,a.object,n,r,o,s);break}case"blob":break}}var Cp=new TextEncoder,_o=new TextDecoder,pl=65520,Pp=new Uint8Array([48,48,48,48]),qR=new Uint8Array([48,48,48,49]),KR=new Uint8Array([48,48,48,50]);function Sn(e){let t=typeof e=="string"?Cp.encode(e):e,n=4+t.byteLength;if(n>pl)throw new Error(`pkt-line too long: ${n} bytes (max ${pl})`);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 da(){return Pp.slice()}function Fo(...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 Ur(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=_o.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===1){t.push({type:"delim"}),n+=4;continue}if(o===2){t.push({type:"response-end"}),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 Uo(e){if(e.type!=="data")return"";let t=_o.decode(e.data);return t.endsWith(`
349
+ `)?t.slice(0,-1):t}var $p=1,Op=2,Ip=3;function ua(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case $p:t.push(f),o+=f.byteLength;break;case Op:n.push(_o.decode(f));break;case Ip:r.push(_o.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}}pt();function ha(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ma(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ha(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=Ur(c);return Sp(f,t)}function Sp(e,t){let n=0,r=e[n];r?.type==="data"&&Uo(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;if(a.type!=="data")continue;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 h=l.slice(0,d),u=l.slice(d+1);if(!(h===te&&u==="capabilities^{}")){if(u.endsWith("^{}")){let m=u.slice(0,-3),p=o.find(g=>g.name===m);p&&(p.peeledHash=h);continue}o.push({name:u,hash:h})}}return{refs:o,capabilities:s,symrefs:i}}var Tp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function gl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=bl(r,Tp),c=[];c.push(Sn(`want ${t[0]} ${a.join(" ")}
350
+ `));for(let u=1;u<t.length;u++)c.push(Sn(`want ${t[u]}
351
+ `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(Sn(`shallow ${u}
352
+ `));i?.depth!==void 0&&c.push(Sn(`deepen ${i.depth}
353
+ `)),c.push(da());for(let u of n)c.push(Sn(`have ${u}
354
+ `));c.push(Sn(`done
355
+ `));let f=Fo(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ha(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let h=new Uint8Array(await d.arrayBuffer());return vp(h,a.includes("side-band-64k"))}function vp(e,t){let n=Ur(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let h=n[d];if(!h||h.type==="flush"){i=d+1;continue}if(h.type!=="data")continue;let u=Uo(h);if(u.startsWith("shallow "))o.push(u.slice(8)),i=d+1;else if(u.startsWith("unshallow "))s.push(u.slice(10)),i=d+1;else if(u.startsWith("ACK ")||u==="NAK")r.push(u),i=d+1;else{i=d;break}}let a=n.slice(i);if(t){let{packData:d,progress:h,errors:u}=ua(a);if(u.length>0)throw new Error(`Remote error: ${u.join("")}`);return{packData:d,acks:r,progress:h,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 Hp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function wl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=bl(r,Hp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Sn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
356
+ `));for(let m of f)a.push(Sn(`${m.oldHash} ${m.newHash} ${m.refName}
357
+ `));a.push(da());let l;if(n&&n.byteLength>0){let m=Fo(...a);l=new Uint8Array(m.byteLength+n.byteLength),l.set(m,0),l.set(n,m.byteLength)}else l=Fo(...a);let d=e.replace(/\/+$/,""),h=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ha(o),"User-Agent":"just-git/1.0"},body:l});if(!h.ok)throw new Error(`HTTP ${h.status} pushing to ${d}`);let u=new Uint8Array(await h.arrayBuffer());return i.includes("report-status")?Ap(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Ap(e,t){let n,r=[];if(t){let a=Ur(e),{packData:c,progress:f,errors:l}=ua(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Ur(c)}else n=Ur(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=Uo(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 bl(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 $s=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 B(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Q(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 dl(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await pa(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Js(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 pa(this.local,n,r);s&&await Js(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 en(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}}},Os=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 ma(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 ma(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 gl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Js(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){let n=new Set,r=[];for(let u of t)if(u.oldHash&&u.oldHash!==te&&u.newHash!==te&&!u.ok&&!await en(this.local,u.oldHash,u.newHash)){let g=await $t(this.local,u.oldHash)?"non-fast-forward":"fetch first";n.add(u.name),r.push({...u,ok:!1,error:g})}let o=t.filter(u=>!n.has(u.name));if(o.length===0)return{updates:r};let s=await this.ensurePushDiscovery(),i=o.map(u=>({oldHash:u.oldHash??te,newHash:u.newHash,refName:u.name})),a=[],c=[],f=!1;for(let u of o)u.newHash!==te&&(a.push(u.newHash),f=!0),u.oldHash&&u.oldHash!==te&&c.push(u.oldHash);let l=null;f&&(l=await pa(this.local,a,c)??null);let d=await wl(this.url,i,l,s,this.auth,this.fetchFn);return{updates:[...o.map(u=>{let m=d.refResults.find(w=>w.name===u.name),p=m?.ok??d.unpackOk,g=m?.error??(!p&&d.unpackError?`unpack failed: ${d.unpackError}`:void 0);return{...u,ok:p,error:g}}),...r]}}};async function pa(e,t,n,r,o){let s=await _r(e,t,n,r,o);if(s.count===0)return;let i=await Fr(s),c=No(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Xs(c);return f}function Dp(e){if(!Bo(e))return{url:e};try{let t=new URL(e);if(!t.username&&!t.password)return{url:e};let n={type:"basic",username:decodeURIComponent(t.username),password:decodeURIComponent(t.password)};return t.username="",t.password="",{url:t.href,embeddedAuth:n}}catch{return{url:e}}}function wr(e,t){let n=Dp(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function Mp(e,t){let r=(await pe(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function Bo(e){return e.startsWith("http://")||e.startsWith("https://")}function yl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function El(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(Bo(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 jp(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 kl(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=jp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function Rl(e,t,n,r){let o=wr(t,e.credentialCache).url;if(Bo(o)){let s=El(o,e.networkPolicy);if(s)throw new Error(s);let i=await kl(e,o,n);return new Os(e,o,i,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw yl(o)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`):new Error(`'${o}' does not appear to be a git repository`);return new $s(e,r)}async function Br(e,t,n){let r=await Mp(e,t);if(!r)return null;let o=wr(r.url,e.credentialCache).url;if(Bo(o)){let i=El(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await kl(e,o,n):void 0;return{transport:new Os(e,o,a,e.fetchFn),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await or(e.fs,o);if(!s){if(yl(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new $s(e,s),config:{...r,url:o}}}De();et();function xl(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[K.string().name("repository").describe("Repository to clone"),K.string().name("directory").describe("Target directory").optional()],options:{bare:I().describe("Create a bare clone"),branch:Y.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Y.number().describe("Create a shallow clone with history truncated to N commits"),singleBranch:I().describe("Clone only the history of the specified or default branch"),noSingleBranch:I().describe("Clone all branches even with --depth"),noTags:I().describe("Don't clone any tags"),noCheckout:I().alias("n").describe("Don't create a checkout")},handler:async(n,r)=>{let o=n.repository;if(!o)return S("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=wr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Mt(r.cwd,o),a=await or(r.fs,c)),!a)return S(`repository '${o}' does not exist`);let f=n.directory;if(!f){let H;s||o.includes("://")?H=c.split("/").pop()??c:H=Yr(c),H.endsWith(".git")&&(H=H.slice(0,-4)),f=H}let l=Mt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(fe(d))return _(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return S(`destination path '${f}' already exists and is not an empty directory.`)}catch{return S(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:h}=await Qs(r.fs,l,{bare:n.bare}),u=t?{...h,...t}:h,m=n.depth,p=n.singleBranch||m!==void 0&&!n.noSingleBranch,g=n.noTags||p,w=n.noCheckout,b=await pe(u),y;try{y=await Rl(u,c,r.env,a??void 0)}catch(H){let M=H instanceof Error?H.message:"";return M.startsWith("network")?S(M):S(`repository '${o}' does not exist`)}let x=await y.advertiseRefs();if(x.length===0)return b['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await ze(u,b),await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
358
358
  warning: You appear to have cloned an empty repository.
359
- `,exitCode:0};let w=[],b=new Set;for(let O of g)O.name!=="HEAD"&&(!O.name.startsWith("refs/heads/")&&!O.name.startsWith("refs/tags/")||b.has(O.hash)||(b.add(O.hash),w.push(O.hash)));let k=n.depth,R=k!==void 0&&k>0?{depth:k}:void 0;if(w.length>0){let O=await p.fetch(w,[],R);O.shallowUpdates&&await Lr(u,O.shallowUpdates)}let C=g.find(O=>O.name==="HEAD"),E=null,y=null,x=await sn(u,r.env),$=`clone: from ${c}`,A=p.headTarget;A?.startsWith("refs/heads/")&&g.some(O=>O.name===A)&&(E=A.slice(11),y=g.find(O=>O.name===A)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let D=O.name.slice(11),L=`refs/remotes/origin/${D}`;await J(u,L,O.hash),await Je(u,L,{oldHash:te,newHash:O.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:$}),!E&&C&&O.hash===C.hash&&(E=D,y=O.hash)}O.name.startsWith("refs/tags/")&&await J(u,O.name,O.hash)}if(i){let O=g.find(D=>D.name===`refs/heads/${i}`);if(!O)return T(`Remote branch '${i}' not found in upstream origin`);E=i,y=O.hash}if(!E){let O=g.find(D=>D.name.startsWith("refs/heads/"));O&&(E=O.name.slice(11),y=O.hash)}if(n.bare)return E&&await Ze(u,"HEAD",`refs/heads/${E}`),await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:E}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
360
- `,exitCode:0};if(E&&await Ze(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${E}`),E&&y){await J(u,`refs/heads/${E}`,y),await Ze(u,"HEAD",`refs/heads/${E}`);let O={oldHash:te,newHash:y,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:$};await Je(u,`refs/heads/${E}`,O),await Je(u,"HEAD",O);let D=await he(u);D[`branch "${E}"`]={remote:"origin",merge:`refs/heads/${E}`},await Xe(u,D);let L=await j(u,y);await af(u,L.tree);let K=await qe(u,L.tree),I=qs(K.map(H=>({path:H.path,mode:parseInt(H.mode,8),hash:H.hash,stage:0,stat:ve()})));await ae(u,I)}let P={stdout:"",stderr:`Cloning into '${f}'...
361
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:E}),P}})}oe();ie();Ce();we();fn();De();tt();ls();Ir();function Pl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[q.string().name("committish").describe("Commit to describe").optional()],options:{tags:S().describe("Use any tag, not just annotated"),always:S().describe("Show abbreviated hash as fallback"),long:S().describe("Always output long format"),abbrev:Y.number().describe("Abbreviation length"),dirty:Y.string().describe("Append dirty marker if worktree has changes"),match:Y.string().describe("Only consider tags matching glob"),exclude:Y.string().describe("Exclude tags matching glob"),exactMatch:S().alias("exact-match").describe("Only output exact matches"),firstParent:S().alias("first-parent").describe("Only follow first parent"),candidates:Y.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,h=n.match,u=n.exclude,m=n.exactMatch,p=n.firstParent,g;if(i){let x=await We(s,i);if(!x)return T(`Not a valid object name ${i}`);try{g=await Ae(s,x)}catch{return T(`Not a valid object name ${i}`)}}else g=await X(s);if(!g)return T("your current branch does not have any commits yet");let w=await Gp(s,a,h,u),b=new Map,k=!1;for(let x of w){x.timestamp===0&&(k=!0);let $=b.get(x.commitHash);$||($=[],b.set(x.commitHash,$)),$.push(x)}let R=await Lp(s,g,b,p,m?0:void 0);if(!R){if(m)return T(`no tag exactly matches '${g}'`);if(c){let $=g.slice(0,Math.max(l,1));return d&&await Cl(s)&&($+=d),{stdout:$+`
362
- `,stderr:"",exitCode:0}}let x;return!a&&k?x=`fatal: No annotated tags can describe '${g}'.
359
+ `,exitCode:0};let k=null,R=null;if(i){let H=x.find(M=>M.name===`refs/heads/${i}`);if(!H)return S(`Remote branch '${i}' not found in upstream origin`);k=i,R=H.hash}else{let H=y.headTarget;if(H?.startsWith("refs/heads/")&&x.some(M=>M.name===H)&&(k=H.slice(11),R=x.find(M=>M.name===H)?.hash??null),!k){let M=x.find(W=>W.name==="HEAD");if(M){let W=x.find(O=>O.name.startsWith("refs/heads/")&&O.hash===M.hash);W&&(k=W.name.slice(11),R=W.hash)}}if(!k){let M=x.find(W=>W.name.startsWith("refs/heads/"));M&&(k=M.name.slice(11),R=M.hash)}}let E={url:c,fetch:p&&k?`+refs/heads/${k}:refs/remotes/origin/${k}`:"+refs/heads/*:refs/remotes/origin/*"};g&&(E.tagOpt="--no-tags"),b['remote "origin"']=E;let C=[],$=new Set;for(let H of x)if(H.name!=="HEAD"){if(H.name.startsWith("refs/heads/")){if(p&&k&&H.name!==`refs/heads/${k}`)continue}else if(H.name.startsWith("refs/tags/")){if(g)continue}else continue;$.has(H.hash)||($.add(H.hash),C.push(H.hash))}let D=m!==void 0&&m>0?{depth:m}:void 0;if(C.length>0){let H=await y.fetch(C,[],D);H.shallowUpdates&&await Nr(u,H.shallowUpdates)}let P=`clone: from ${c}`;for(let H of x)if(H.name!=="HEAD"){if(H.name.startsWith("refs/heads/")){if(p&&k&&H.name!==`refs/heads/${k}`)continue;let M=`refs/remotes/origin/${H.name.slice(11)}`;await J(u,M,H.hash),await ne(u,r.env,M,null,H.hash,P)}H.name.startsWith("refs/tags/")&&(g||await J(u,H.name,H.hash))}if(n.bare)return await ze(u,b),k&&await Ze(u,"HEAD",`refs/heads/${k}`),await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:k}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
360
+ `,exitCode:0};if(await Sr(u,"origin",x,y.headTarget),k&&R&&(await J(u,`refs/heads/${k}`,R),await Ze(u,"HEAD",`refs/heads/${k}`),await ne(u,r.env,`refs/heads/${k}`,null,R,P,!0),b[`branch "${k}"`]={remote:"origin",merge:`refs/heads/${k}`},!w)){let H=await G(u,R);await af(u,H.tree);let M=await qe(u,H.tree),W=Ks(M.map(O=>({path:O.path,mode:parseInt(O.mode,8),hash:O.hash,stage:0,stat:ve()})));await ae(u,W)}await ze(u,b);let T={stdout:"",stderr:`Cloning into '${f}'...
361
+ `,exitCode:0};return await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:k}),T}})}oe();ie();Ce();we();cn();De();et();ds();Ir();function Pl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[K.string().name("committish").describe("Commit to describe").optional()],options:{tags:I().describe("Use any tag, not just annotated"),always:I().describe("Show abbreviated hash as fallback"),long:I().describe("Always output long format"),abbrev:Y.number().describe("Abbreviation length"),dirty:Y.string().describe("Append dirty marker if worktree has changes"),match:Y.string().describe("Only consider tags matching glob"),exclude:Y.string().describe("Exclude tags matching glob"),exactMatch:I().alias("exact-match").describe("Only output exact matches"),firstParent:I().alias("first-parent").describe("Only follow first parent"),candidates:Y.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,h=n.match,u=n.exclude,m=n.exactMatch,p=n.firstParent,g;if(i){let C=await We(s,i);if(!C)return S(`Not a valid object name ${i}`);try{g=await Ae(s,C)}catch{return S(`Not a valid object name ${i}`)}}else g=await X(s);if(!g)return S("your current branch does not have any commits yet");let w=await Gp(s,a,h,u),b=new Map,y=!1;for(let C of w){C.timestamp===0&&(y=!0);let $=b.get(C.commitHash);$||($=[],b.set(C.commitHash,$)),$.push(C)}let x=await Lp(s,g,b,p,m?0:void 0);if(!x){if(m)return S(`no tag exactly matches '${g}'`);if(c){let $=g.slice(0,Math.max(l,1));return d&&await Cl(s)&&($+=d),{stdout:$+`
362
+ `,stderr:"",exitCode:0}}let C;return!a&&y?C=`fatal: No annotated tags can describe '${g}'.
363
363
  However, there were unannotated tags: try --tags.
364
- `:w.length===0&&!a&&(await ge(s,"refs/tags")).length>0?x=`fatal: No annotated tags can describe '${g}'.
364
+ `:w.length===0&&!a&&(await ge(s,"refs/tags")).length>0?C=`fatal: No annotated tags can describe '${g}'.
365
365
  However, there were unannotated tags: try --tags.
366
- `:x=`fatal: No names found, cannot describe anything.
367
- `,{stdout:"",stderr:x,exitCode:128}}let{tag:C,depth:E}=R,y;if(E===0&&!f)y=C.name;else if(l===0)y=C.name;else{let x=g.slice(0,Math.max(l,1));y=`${C.name}-${E}-g${x}`}return d&&await Cl(s)&&(y+=d),{stdout:y+`
368
- `,stderr:"",exitCode:0}}})}async function Gp(e,t,n,r){let o=await ge(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&ln(n,a,0)!==0||r&&ln(r,a,0)===0)continue;let c=await ye(e,i.hash);if(c.type==="tag"){let f=Zt(c.content),l;try{l=await Ae(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function Lp(e,t,n,r,o){let s=new Set,i=[{hash:t,depth:0}];for(;i.length>0;){let{hash:a,depth:c}=i.shift();if(s.has(a)||(s.add(a),o!==void 0&&c>o))continue;let f=n.get(a);if(f&&f.length>0)return{tag:Np(f),depth:c};let l;try{l=await j(e,a)}catch{continue}if(r)l.parents.length>0&&!s.has(l.parents[0])&&i.push({hash:l.parents[0],depth:c+1});else for(let d of l.parents)s.has(d)||i.push({hash:d,depth:c+1})}return null}function Np(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function Cl(e){if(Ve(e))return!1;let n=await X(e);if(!n)return!1;let r=await j(e,n),o=await de(e,r.tree),s=await z(e);return qn(s,o)?!0:(await wt(e,s)).length>0}oe();Ce();ie();bn();pe();ze();we();De();tt();function $l(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Y.string().alias("m").repeatable().describe("Commit message"),file:Y.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:S().describe("Allow creating an empty commit"),amend:S().describe("Amend the previous commit"),noEdit:S().describe("Use the previous commit message without editing"),all:S().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{let o=n.message;if(o.length>0&&n.file!==void 0)return T("options '-m' and '-F' cannot be used together");let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await z(i);if(n.all){let ce=Ve(i);if(ce)return ce;let Ie=await wt(i,a);for(let Ye of Ie)Ye.status==="modified"?a=(await un(i,a,Ye.path)).index:Ye.status==="deleted"&&(a=ft(a,Ye.path));let ut=new Set(Ne(a).map(Ye=>Ye.path)),Er=new Set(a.entries.filter(Ye=>Ye.stage>0&&!ut.has(Ye.path)).map(Ye=>Ye.path));for(let Ye of Er){let Wr=v(i.workTree,Ye);await r.fs.exists(Wr)?a=(await un(i,a,Ye)).index:a=ft(a,Ye)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),h=await Ut(i)?await B(i,"REBASE_HEAD"):null,u=n.amend,m=await X(i);if(u){if(!m)return T("You have nothing yet to amend.");if(c)return T("You are in the middle of a merge -- cannot amend.");if(f)return T("You are in the middle of a cherry-pick -- cannot amend.")}if(Gt(a)){let ce=new Set,Ie=[];for(let ut of a.entries)ut.stage>0&&!ce.has(ut.path)&&(ce.add(ut.path),Ie.push(`U ${ut.path}`));return Ie.sort(),{stdout:Ie.length>0?`${Ie.join(`
366
+ `:C=`fatal: No names found, cannot describe anything.
367
+ `,{stdout:"",stderr:C,exitCode:128}}let{tag:k,depth:R}=x,E;if(R===0&&!f)E=k.name;else if(l===0)E=k.name;else{let C=g.slice(0,Math.max(l,1));E=`${k.name}-${R}-g${C}`}return d&&await Cl(s)&&(E+=d),{stdout:E+`
368
+ `,stderr:"",exitCode:0}}})}async function Gp(e,t,n,r){let o=await ge(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&fn(n,a,0)!==0||r&&fn(r,a,0)===0)continue;let c=await ye(e,i.hash);if(c.type==="tag"){let f=Zt(c.content),l;try{l=await Ae(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function Lp(e,t,n,r,o){let s=new Set,i=[{hash:t,depth:0}];for(;i.length>0;){let{hash:a,depth:c}=i.shift();if(s.has(a)||(s.add(a),o!==void 0&&c>o))continue;let f=n.get(a);if(f&&f.length>0)return{tag:Np(f),depth:c};let l;try{l=await G(e,a)}catch{continue}if(r)l.parents.length>0&&!s.has(l.parents[0])&&i.push({hash:l.parents[0],depth:c+1});else for(let d of l.parents)s.has(d)||i.push({hash:d,depth:c+1})}return null}function Np(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function Cl(e){if(Ye(e))return!1;let n=await X(e);if(!n)return!1;let r=await G(e,n),o=await de(e,r.tree),s=await z(e);return Wn(s,o)?!0:(await wt(e,s)).length>0}oe();Ce();ie();wn();me();Ke();we();De();et();function $l(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Y.string().alias("m").repeatable().describe("Commit message"),file:Y.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:I().describe("Allow creating an empty commit"),amend:I().describe("Amend the previous commit"),noEdit:I().describe("Use the previous commit message without editing"),all:I().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{let o=n.message;if(o.length>0&&n.file!==void 0)return S("options '-m' and '-F' cannot be used together");let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=await z(i);if(n.all){let ce=Ye(i);if(ce)return ce;let Ie=await wt(i,a);for(let Xe of Ie)Xe.status==="modified"?a=(await dn(i,a,Xe.path)).index:Xe.status==="deleted"&&(a=ct(a,Xe.path));let ut=new Set(Ne(a).map(Xe=>Xe.path)),Er=new Set(a.entries.filter(Xe=>Xe.stage>0&&!ut.has(Xe.path)).map(Xe=>Xe.path));for(let Xe of Er){let qr=v(i.workTree,Xe);await r.fs.exists(qr)?a=(await dn(i,a,Xe)).index:a=ct(a,Xe)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),h=await Ut(i)?await B(i,"REBASE_HEAD"):null,u=n.amend,m=await X(i);if(u){if(!m)return S("You have nothing yet to amend.");if(c)return S("You are in the middle of a merge -- cannot amend.");if(f)return S("You are in the middle of a cherry-pick -- cannot amend.")}if(Gt(a)){let ce=new Set,Ie=[];for(let ut of a.entries)ut.stage>0&&!ce.has(ut.path)&&(ce.add(ut.path),Ie.push(`U ${ut.path}`));return Ie.sort(),{stdout:Ie.length>0?`${Ie.join(`
369
369
  `)}
370
370
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
371
371
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
372
372
  hint: as appropriate to mark resolution and make a commit.
373
373
  fatal: Exiting because of an unresolved conflict.
374
- `,exitCode:128}}let p=u&&m?await j(i,m):null,g=o.length>0?o.join(`
374
+ `,exitCode:128}}let p=u&&m?await G(i,m):null,g=o.length>0?o.join(`
375
375
 
376
376
  `):void 0;if(g!==void 0&&(g=It(g),!g))return{stdout:`Aborting commit due to empty commit message.
377
- `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ce=n.file.startsWith("/")?n.file:v(r.cwd,n.file);if(!await r.fs.exists(ce))return T(`could not read log file '${n.file}': No such file or directory`);let Ie=await r.fs.readFile(ce);g=typeof Ie=="string"?Ie:new TextDecoder().decode(Ie)}if(g=It(g),!g)return{stdout:`Aborting commit due to empty commit message.
378
- `,stderr:"",exitCode:1}}if(!g&&u&&p&&(g=p.message),!g&&(c||f||l||h)){let ce=await $e(i,"SQUASH_MSG");if(ce)g=It(ce);else{let Ie=await $e(i,"MERGE_MSG");Ie!==null&&(g=It(Ie))}}if(!g)return _("error: must provide a commit message with -m or -F");let w=Ne(a),b=await Fe(i,w),k=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(fe(k))return _(k.message??"");let R=n.allowEmpty,C=null;if(u&&p){let ce=p.parents[0];ce?C=(await j(i,ce)).tree:C=await gt("tree",new Uint8Array(0))}else m&&(C=(await j(i,m)).tree);let E=u&&p&&p.parents.length>1;if(!R&&!c&&!E){if(!m&&!u&&w.length===0)return{stdout:await it(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(C!==null&&C===b){if(u){let ce=p?.parents[0]??null;return{stdout:`${await it(i,{fromCommit:!0,compareHash:ce,noWarn:!0,index:a})}No changes
377
+ `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ce=n.file.startsWith("/")?n.file:v(r.cwd,n.file);if(!await r.fs.exists(ce))return S(`could not read log file '${n.file}': No such file or directory`);let Ie=await r.fs.readFile(ce);g=typeof Ie=="string"?Ie:new TextDecoder().decode(Ie)}if(g=It(g),!g)return{stdout:`Aborting commit due to empty commit message.
378
+ `,stderr:"",exitCode:1}}if(!g&&u&&p&&(g=p.message),!g&&(c||f||l||h)){let ce=await $e(i,"SQUASH_MSG");if(ce)g=It(ce);else{let Ie=await $e(i,"MERGE_MSG");Ie!==null&&(g=It(Ie))}}if(!g)return _("error: must provide a commit message with -m or -F");let w=Ne(a),b=await Fe(i,w),y=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(fe(y))return _(y.message??"");let x=n.allowEmpty,k=null;if(u&&p){let ce=p.parents[0];ce?k=(await G(i,ce)).tree:k=await gt("tree",new Uint8Array(0))}else m&&(k=(await G(i,m)).tree);let R=u&&p&&p.parents.length>1;if(!x&&!c&&!R){if(!m&&!u&&w.length===0)return{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(k!==null&&k===b){if(u){let ce=p?.parents[0]??null;return{stdout:`${await ot(i,{fromCommit:!0,compareHash:ce,noWarn:!0,index:a})}No changes
379
379
  `,stderr:`You asked to amend the most recent commit, but doing so would make
380
380
  it empty. You can repeat your command with --allow-empty, or you can
381
381
  remove the commit entirely with "git reset HEAD^".
382
- `,exitCode:1}}return f?{stdout:await it(i,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
382
+ `,exitCode:1}}return f?{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
383
383
  If you wish to commit it anyway, use:
384
384
 
385
385
  git commit --allow-empty
386
386
 
387
387
  Otherwise, please use 'git cherry-pick --skip'
388
- `,exitCode:1}:{stdout:await it(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let y=await hn(i,r.env);if(M(y))return y;let x=await nt(i,r.env);if(M(x))return x;u&&p&&(y.name=p.author.name,y.email=p.author.email,y.timestamp=p.author.timestamp,y.timezone=p.author.timezone),f&&(y=(await j(i,f)).author);let $=Nt(g),A={repo:i,message:$},P=await t?.hooks?.commitMsg?.(A);if(fe(P))return _(P.message??"");$=A.message;let O;u&&p?O=[...p.parents]:(O=m?[m]:[],c&&O.push(c));let D=cn({type:"commit",tree:b,parents:O,author:y,committer:x,message:$}),L=await Se(i,"commit",D);await ae(i,a);let K=await Q(i);K&&K.type==="symbolic"?await J(i,K.target,L):await J(i,"HEAD",L);let I=ue($),H;u?H="commit (amend)":c?H="commit (merge)":f?H="commit (cherry-pick)":m?H="commit":H="commit (initial)";let G=`${H}: ${I}`,F=K?.type==="symbolic"?K.target:"HEAD";await se(i,r.env,F,m,L,G,K?.type==="symbolic"),c&&await hs(i),f&&await Ft(i),l&&await St(i),h&&await be(i,"MERGE_MSG"),await be(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:L,message:$,branch:K?.type==="symbolic"?Pe(K.target):null,parents:O,author:y});let U=K?.type==="symbolic"?K.target:null,N=U?Pe(U):"detached HEAD",ne;if(u&&p){let ce=p.parents[0];ne=ce?(await j(i,ce)).tree:null}else ne=m?(await j(i,m)).tree:null;let V=y.timestamp!==x.timestamp||y.timezone!==x.timezone,ee=O.length>1,ke=await pn(i,ne,b,y,x,V,ee);return{stdout:`${Lt(N,L,g,O.length===0&&!u)}
389
- ${ke}`,stderr:"",exitCode:0}}})}oe();Be();pe();function vn(e){let t=e.split(".");return t.length===2||t.length===3}function _p(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 Tl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:S().alias("l").describe("List all config entries"),get:S().describe("Get the value for a given key"),unset:S().describe("Remove a config key"),"get-all":S().describe("Get all values for a multi-valued key"),add:S().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 Sl(s);if(n.get){let f=a;return f?vn(f)?ga(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n["get-all"]){let f=a;return f?vn(f)?Ol(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?_("error: missing key and/or value",2):vn(f)?(await Ja(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?vn(f)?Il(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return Sl(s);if(a==="get"){let f=i[1];return f?vn(f)?ga(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?vn(f)?Ol(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?_("error: missing key and/or value",2):vn(f)?(await hi(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?vn(f)?Il(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!vn(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await hi(s,a,c),{stdout:"",stderr:"",exitCode:0}):ga(s,a)}})}async function ga(e,t){let n=await xe(e,t);return n===void 0?_(""):{stdout:`${n}
388
+ `,exitCode:1}:{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let E=await un(i,r.env);if(j(E))return E;let C=await tt(i,r.env);if(j(C))return C;u&&p&&(E.name=p.author.name,E.email=p.author.email,E.timestamp=p.author.timestamp,E.timezone=p.author.timezone),f&&(E=(await G(i,f)).author);let $=Nt(g),D={repo:i,message:$},P=await t?.hooks?.commitMsg?.(D);if(fe(P))return _(P.message??"");$=D.message;let T;u&&p?T=[...p.parents]:(T=m?[m]:[],c&&T.push(c));let H=an({type:"commit",tree:b,parents:T,author:E,committer:C,message:$}),M=await Se(i,"commit",H);await ae(i,a);let W=await Q(i);W&&W.type==="symbolic"?await J(i,W.target,M):await J(i,"HEAD",M);let O=ue($),A;u?A="commit (amend)":c?A="commit (merge)":f?A="commit (cherry-pick)":m?A="commit":A="commit (initial)";let L=`${A}: ${O}`,F=W?.type==="symbolic"?W.target:"HEAD";await ne(i,r.env,F,m,M,L,W?.type==="symbolic"),c&&await ms(i),f&&await Ft(i),l&&await St(i),h&&await be(i,"MERGE_MSG"),await be(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:M,message:$,branch:W?.type==="symbolic"?Pe(W.target):null,parents:T,author:E});let U=W?.type==="symbolic"?W.target:null,N=U?Pe(U):"detached HEAD",re;if(u&&p){let ce=p.parents[0];re=ce?(await G(i,ce)).tree:null}else re=m?(await G(i,m)).tree:null;let V=E.timestamp!==C.timestamp||E.timezone!==C.timezone,ee=T.length>1,ke=await mn(i,re,b,E,C,V,ee);return{stdout:`${Lt(N,M,g,T.length===0&&!u)}
389
+ ${ke}`,stderr:"",exitCode:0}}})}oe();Be();me();function Tn(e){let t=e.split(".");return t.length===2||t.length===3}function _p(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 Tl(e,t){e.command("config",{description:"Get and set repository options",args:[K.string().name("positionals").variadic().optional()],options:{list:I().alias("l").describe("List all config entries"),get:I().describe("Get the value for a given key"),unset:I().describe("Remove a config key"),"get-all":I().describe("Get all values for a multi-valued key"),add:I().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Sl(s);if(n.get){let f=a;return f?Tn(f)?ga(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n["get-all"]){let f=a;return f?Tn(f)?Ol(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?_("error: missing key and/or value",2):Tn(f)?(await Ja(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Tn(f)?Il(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return Sl(s);if(a==="get"){let f=i[1];return f?Tn(f)?ga(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Tn(f)?Ol(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?_("error: missing key and/or value",2):Tn(f)?(await hi(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Tn(f)?Il(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Tn(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await hi(s,a,c),{stdout:"",stderr:"",exitCode:0}):ga(s,a)}})}async function ga(e,t){let n=await xe(e,t);return n===void 0?_(""):{stdout:`${n}
390
390
  `,stderr:"",exitCode:0}}async function Ol(e,t){let n=await Za(e,t);return n.length===0?_(""):{stdout:`${n.join(`
391
391
  `)}
392
392
  `,stderr:"",exitCode:0}}async function Il(e,t){return await Qa(e,t)?{stdout:"",stderr:"",exitCode:0}:_("",5)}async function Sl(e){let t=v(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=fi(n),o=_p(r),s=new Set(o.map(c=>c.split("=")[0])),i=e.configOverrides?.defaults;if(i)for(let[c,f]of Object.entries(i))s.has(c)||(o.push(`${c}=${f}`),s.add(c));let a=e.configOverrides?.locked;if(a)for(let[c,f]of Object.entries(a))s.has(c)||o.push(`${c}=${f}`);return{stdout:o.length>0?`${o.join(`
393
393
  `)}
394
- `:"",stderr:"",exitCode:0}}oe();function Wo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(b=>b?Z(b):"0000000"),c=o?Z(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(b=>b===null),d=!f&&n.some(b=>b!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let b=r.map(k=>k||"000000").join(",");i.push(`deleted file mode ${b}`)}else{let b=r.map(C=>C||"000000"),k=s||"000000";b.some(C=>C!==k)&&i.push(`mode ${b.join(",")}..${k}`)}let h=n.some(b=>b!==null);if(i.push(h?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
394
+ `:"",stderr:"",exitCode:0}}oe();function Wo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(b=>b?Z(b):"0000000"),c=o?Z(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(b=>b===null),d=!f&&n.some(b=>b!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let b=r.map(y=>y||"000000").join(",");i.push(`deleted file mode ${b}`)}else{let b=r.map(k=>k||"000000"),y=s||"000000";b.some(k=>k!==y)&&i.push(`mode ${b.join(",")}..${y}`)}let h=n.some(b=>b!==null);if(i.push(h?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
395
395
  `)}
396
- `;let u=e.parentContents.map(b=>b.length>0?Wt(b):[]),m=e.resultContent.length>0?Wt(e.resultContent):[],p=u.map(b=>at(b,m)),g=Fp(u,m,p),w=Bp(g,u.length,m);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
396
+ `;let u=e.parentContents.map(b=>b.length>0?Wt(b):[]),m=e.resultContent.length>0?Wt(e.resultContent):[],p=u.map(b=>it(b,m)),g=Fp(u,m,p),w=Bp(g,u.length,m);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
397
397
  `)}
398
- `}function Fp(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=Up(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 u=o[d]?.resultStatus[i];if(f.push(u==="insert"?"+":" "),u==="keep"){let m=n[d];if(m){for(let p of m)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 Up(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=at(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(u=>u.text===l.line&&u.parentLineNo===l.oldLineNo),h=s.find(u=>u.text===l.line&&u.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,h?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(h=>h.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(h=>h.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 Bp(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(h=>h!==" ")&&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,h=Math.max(0,d-3),u=Math.min(e.length-1,d+3);h<=c+1||(s.push({start:a,end:c}),a=h),c=u}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),h=[];for(let R=0;R<t;R++){let C=d.filter(E=>(E.parentLineNos[R]??0)>0||E.columns[R]==="-");if(C.length===0)h.push({start:1,count:0});else{let y=C.find(x=>(x.parentLineNos[R]??0)>0)?.parentLineNos[R]??1;h.push({start:y,count:C.length})}}let u=d.filter(R=>R.resultLineNo>0),m=u[0],p=m?m.resultLineNo:1,g=u.length,w="";for(let R=p-2;R>=0;R--){let C=n[R];if(C&&/^[a-zA-Z$_]/.test(C)){w=` ${C.trimEnd().slice(0,79)}`;break}}let b=h.map(R=>`-${R.start},${R.count}`),k=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(k);for(let R of d)f.push(`${R.columns.join("")}${R.text}`)}return f}oe();Ce();ie();pe();function qo(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}Rn();we();De();tt();var wa=new TextDecoder;function Dl(e){return"exitCode"in e}function br(e){return e.toString(8).padStart(6,"0")}function Ml(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 jl(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",transformArgs:n=>n.map(r=>{let o=/^-U(\d+)$/.exec(r);return o?`--unified=${o[1]}`:r}),args:[q.string().name("commits").variadic().optional()],options:{cached:S().describe("Show staged changes (index vs HEAD)"),staged:S().describe("Synonym for --cached"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),unified:Y.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:S().alias("M").describe("Detect renames (enabled by default)"),findCopies:S().alias("C").describe("Detect copies (accepted for compatibility)"),color:S().describe("Show colored diff (accepted for compatibility)"),noColor:S().describe("Turn off colored diff (accepted for compatibility)")},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=dt(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(g=>Ue(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",h,u=c.length===1?qo(c[0]):null;if(u){if(a)return T("too many arguments");u.type==="three-dot"?h=await Kp(i,u.left,u.right,l):h=await Al(i,u.left,u.right,l)}else if(c.length===2)h=await Al(i,c[0],c[1],l);else{if(c.length>2)return T("too many arguments");a?h=await zp(i,c.length===1?c[0]:null,l):c.length===1?h=await Vp(i,c[0],l):h=await Wp(i,l)}if(Dl(h))return h;let m=n.unified,p=await Yp(i,h.items,d,m);return h.stderr&&(p.stderr=h.stderr),p}})}async function Wp(e,t){let n=Ve(e);if(n)return n;let r=await z(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 wt(e,r);c.sort((l,d)=>Te(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let h=br(d.mode),u;if(l.status==="modified"&&e.workTree){let m=v(e.workTree,l.path),p=await e.fs.readFileBuffer(m);u=await gt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:u,oldMode:h,newMode:h,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),h=a.get(l);await qp(f,e,l,d,h)}return f.sort((l,d)=>{let h=Te(l.path,d.path);return h!==0?h:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function qp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=br(r.mode),a=br(o.mode),{exists:c,hash:f}=await vl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),Hl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=br(r.mode),{exists:a,hash:c}=await vl(t.fs,s,n);Hl(e,n,r.hash,i,a,c)}}async function vl(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await cs(e,r);return{exists:!0,hash:await gt("blob",o)}}function Hl(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 zp(e,t,n){let r=null;if(t){let h=await Le(e,t);if(M(h))return h;r=h.commit.tree}else{let h=await X(e);h&&(r=(await j(e,h)).tree)}let o=await de(e,r),s=await z(e),i=new Set;for(let h of s.entries)h.stage>0&&i.add(h.path);let a=new Map(Ne(s).map(h=>[h.path,h])),c=[];for(let[h,u]of a){if(i.has(h))continue;let m=o.get(h);m?m.hash!==u.hash&&c.push({path:h,status:"modified",oldHash:m.hash,newHash:u.hash,oldMode:m.mode,newMode:br(u.mode)}):c.push({path:h,status:"added",newHash:u.hash,newMode:br(u.mode)})}for(let[h,u]of o)i.has(h)||a.has(h)||c.push({path:h,status:"deleted",oldHash:u.hash,oldMode:u.mode});let{remaining:f,renames:l}=await ot(e,c),d=Ml(f,l);for(let h of i)d.push({path:h,status:"U"});return d.sort((h,u)=>Te(h.path,u.path)),n?{items:d.filter(h=>Ee(n,h.path))}:{items:d}}async function Al(e,t,n,r){let o=await Le(e,t);if(M(o))return o;let s=await Le(e,n);if(M(s))return s;let i=await Ke(e,o.commit.tree,s.commit.tree);return Gl(e,i,r)}async function Kp(e,t,n,r){let o=await Le(e,t);if(M(o))return o;let s=await Le(e,n);if(M(s))return s;let i=await qt(e,o.hash,s.hash);if(i.length===0)return T(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
399
- `);let c=i[0],f=await j(e,c),l=await Ke(e,f.tree,s.commit.tree),d=await Gl(e,l,r);return Dl(d)||a&&(d.stderr=a),d}async function Gl(e,t,n){let{remaining:r,renames:o}=await ot(e,t),s=Ml(r,o);return s.sort((i,a)=>Te(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Vp(e,t,n){let r=Ve(e);if(r)return r;let o=await Le(e,t);if(M(o))return o;let s=e.workTree,i=await de(e,o.commit.tree),a=await z(e),c=new Map(Ne(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let h=v(s,l);if(!await e.fs.exists(h)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let u=await e.fs.readFileBuffer(h),m=await gt("blob",u);m!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:m,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let h=v(s,l);if(!await e.fs.exists(h))continue;let u=await e.fs.readFileBuffer(h),m=await gt("blob",u);f.push({path:l,status:"A",newHash:m,newMode:br(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Te(l.path,d.path)),{items:f}}async function Yp(e,t,n,r){let o;switch(n){case"stat":o=await tg(e,t);break;case"shortstat":o=await ng(e,t);break;case"numstat":o=await eg(e,t);break;case"name-only":o=Jp(t);break;case"name-status":o=Qp(t);break;default:o=await Xp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Xp(e,t,n){let r="",o=new Set,s=await Zp(e,t);for(let i of t)if(i.status==="U")if(i.combinedParentHashes){let a=await Promise.all(i.combinedParentHashes.map(async l=>l?await re(e,l):"")),c=await ba(e,i);if(a.some(l=>He(l))||He(c)){let l=i.combinedParentHashes.map(d=>d?Z(d):"0000000");r+=`diff --cc ${i.path}
398
+ `}function Fp(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=Up(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 u=o[d]?.resultStatus[i];if(f.push(u==="insert"?"+":" "),u==="keep"){let m=n[d];if(m){for(let p of m)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 Up(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=it(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(u=>u.text===l.line&&u.parentLineNo===l.oldLineNo),h=s.find(u=>u.text===l.line&&u.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,h?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(h=>h.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(h=>h.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 Bp(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(h=>h!==" ")&&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,h=Math.max(0,d-3),u=Math.min(e.length-1,d+3);h<=c+1||(s.push({start:a,end:c}),a=h),c=u}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),h=[];for(let x=0;x<t;x++){let k=d.filter(R=>(R.parentLineNos[x]??0)>0||R.columns[x]==="-");if(k.length===0)h.push({start:1,count:0});else{let E=k.find(C=>(C.parentLineNos[x]??0)>0)?.parentLineNos[x]??1;h.push({start:E,count:k.length})}}let u=d.filter(x=>x.resultLineNo>0),m=u[0],p=m?m.resultLineNo:1,g=u.length,w="";for(let x=p-2;x>=0;x--){let k=n[x];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let b=h.map(x=>`-${x.start},${x.count}`),y=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(y);for(let x of d)f.push(`${x.columns.join("")}${x.text}`)}return f}oe();Ce();ie();me();function qo(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}kn();we();De();et();var wa=new TextDecoder;function Dl(e){return"exitCode"in e}function br(e){return e.toString(8).padStart(6,"0")}function Ml(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 jl(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",transformArgs:n=>n.map(r=>{let o=/^-U(\d+)$/.exec(r);return o?`--unified=${o[1]}`:r}),args:[K.string().name("commits").variadic().optional()],options:{cached:I().describe("Show staged changes (index vs HEAD)"),staged:I().describe("Synonym for --cached"),stat:I().describe("Show diffstat summary"),nameOnly:I().describe("Show only names of changed files"),nameStatus:I().describe("Show names and status of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file"),unified:Y.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:I().alias("M").describe("Detect renames (enabled by default)"),findCopies:I().alias("C").describe("Detect copies (accepted for compatibility)"),color:I().describe("Show colored diff (accepted for compatibility)"),noColor:I().describe("Turn off colored diff (accepted for compatibility)")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=dt(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(g=>Ue(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",h,u=c.length===1?qo(c[0]):null;if(u){if(a)return S("too many arguments");u.type==="three-dot"?h=await zp(i,u.left,u.right,l):h=await Al(i,u.left,u.right,l)}else if(c.length===2)h=await Al(i,c[0],c[1],l);else{if(c.length>2)return S("too many arguments");a?h=await Kp(i,c.length===1?c[0]:null,l):c.length===1?h=await Vp(i,c[0],l):h=await Wp(i,l)}if(Dl(h))return h;let m=n.unified,p=await Yp(i,h.items,d,m);return h.stderr&&(p.stderr=h.stderr),p}})}async function Wp(e,t){let n=Ye(e);if(n)return n;let r=await z(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 wt(e,r);c.sort((l,d)=>Te(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let h=br(d.mode),u;if(l.status==="modified"&&e.workTree){let m=v(e.workTree,l.path),p=await e.fs.readFileBuffer(m);u=await gt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:u,oldMode:h,newMode:h,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),h=a.get(l);await qp(f,e,l,d,h)}return f.sort((l,d)=>{let h=Te(l.path,d.path);return h!==0?h:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function qp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=br(r.mode),a=br(o.mode),{exists:c,hash:f}=await vl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),Hl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=br(r.mode),{exists:a,hash:c}=await vl(t.fs,s,n);Hl(e,n,r.hash,i,a,c)}}async function vl(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await fs(e,r);return{exists:!0,hash:await gt("blob",o)}}function Hl(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 Kp(e,t,n){let r=null;if(t){let h=await Le(e,t);if(j(h))return h;r=h.commit.tree}else{let h=await X(e);h&&(r=(await G(e,h)).tree)}let o=await de(e,r),s=await z(e),i=new Set;for(let h of s.entries)h.stage>0&&i.add(h.path);let a=new Map(Ne(s).map(h=>[h.path,h])),c=[];for(let[h,u]of a){if(i.has(h))continue;let m=o.get(h);m?m.hash!==u.hash&&c.push({path:h,status:"modified",oldHash:m.hash,newHash:u.hash,oldMode:m.mode,newMode:br(u.mode)}):c.push({path:h,status:"added",newHash:u.hash,newMode:br(u.mode)})}for(let[h,u]of o)i.has(h)||a.has(h)||c.push({path:h,status:"deleted",oldHash:u.hash,oldMode:u.mode});let{remaining:f,renames:l}=await st(e,c),d=Ml(f,l);for(let h of i)d.push({path:h,status:"U"});return d.sort((h,u)=>Te(h.path,u.path)),n?{items:d.filter(h=>Ee(n,h.path))}:{items:d}}async function Al(e,t,n,r){let o=await Le(e,t);if(j(o))return o;let s=await Le(e,n);if(j(s))return s;let i=await Ve(e,o.commit.tree,s.commit.tree);return Gl(e,i,r)}async function zp(e,t,n,r){let o=await Le(e,t);if(j(o))return o;let s=await Le(e,n);if(j(s))return s;let i=await qt(e,o.hash,s.hash);if(i.length===0)return S(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
399
+ `);let c=i[0],f=await G(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await Gl(e,l,r);return Dl(d)||a&&(d.stderr=a),d}async function Gl(e,t,n){let{remaining:r,renames:o}=await st(e,t),s=Ml(r,o);return s.sort((i,a)=>Te(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Vp(e,t,n){let r=Ye(e);if(r)return r;let o=await Le(e,t);if(j(o))return o;let s=e.workTree,i=await de(e,o.commit.tree),a=await z(e),c=new Map(Ne(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let h=v(s,l);if(!await e.fs.exists(h)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let u=await e.fs.readFileBuffer(h),m=await gt("blob",u);m!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:m,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let h=v(s,l);if(!await e.fs.exists(h))continue;let u=await e.fs.readFileBuffer(h),m=await gt("blob",u);f.push({path:l,status:"A",newHash:m,newMode:br(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Te(l.path,d.path)),{items:f}}async function Yp(e,t,n,r){let o;switch(n){case"stat":o=await tg(e,t);break;case"shortstat":o=await ng(e,t);break;case"numstat":o=await eg(e,t);break;case"name-only":o=Jp(t);break;case"name-status":o=Qp(t);break;default:o=await Xp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Xp(e,t,n){let r="",o=new Set,s=await Zp(e,t);for(let i of t)if(i.status==="U")if(i.combinedParentHashes){let a=await Promise.all(i.combinedParentHashes.map(async l=>l?await se(e,l):"")),c=await ba(e,i);if(a.some(l=>He(l))||He(c)){let l=i.combinedParentHashes.map(d=>d?Z(d):"0000000");r+=`diff --cc ${i.path}
400
400
  index ${l.join(",")}..0000000
401
401
  Binary files differ
402
402
  `,o.add(i.path)}else{let l=Wo({path:i.path,parentHashes:i.combinedParentHashes,parentModes:i.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:i.newMode??null,resultContent:c});l?(r+=l,o.add(i.path)):r+=`* Unmerged path ${i.path}
403
403
  `}}else r+=`* Unmerged path ${i.path}
404
- `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await re(e,i.oldHash):"",c=await ba(e,i);i.status==="R"&&i.oldPath?r+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:zo(i.oldHash,s),newHash:zo(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=Ht({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:zo(i.oldHash,s),newHash:zo(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Zp(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=v(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),h=0;for(let u of d)if(u.startsWith(l)&&(h++,h>1))return!1;return h===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 zo(e,t){if(e)return e.length!==40?e:t.get(e)??Z(e)}function Jp(e){let t="";for(let n of e)t+=`${n.path}
404
+ `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await se(e,i.oldHash):"",c=await ba(e,i);i.status==="R"&&i.oldPath?r+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Ko(i.oldHash,s),newHash:Ko(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=Ht({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Ko(i.oldHash,s),newHash:Ko(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Zp(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=v(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),h=0;for(let u of d)if(u.startsWith(l)&&(h++,h>1))return!1;return h===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 Ko(e,t){if(e)return e.length!==40?e:t.get(e)??Z(e)}function Jp(e){let t="";for(let n of e)t+=`${n.path}
405
405
  `;return t}function Qp(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}
406
406
  `}else t+=`${n.status} ${n.path}
407
407
  `;return t}async function eg(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
408
- `;continue}let o=r.oldHash?await re(e,r.oldHash):"",s=await ba(e,r),i=He(o)||He(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Ll(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}
408
+ `;continue}let o=r.oldHash?await se(e,r.oldHash):"",s=await ba(e,r),i=He(o)||He(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Ll(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=hn(r.oldPath,r.path);n+=`${a} ${c} ${f}
409
409
  `}else n+=`${a} ${c} ${r.path}
410
- `}return n}async function tg(e,t){let n=await Nl(e,t);return mr(n)}async function ng(e,t){let n=await Nl(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=er(s,r,o);return i?`${i}
410
+ `}return n}async function tg(e,t){let n=await Nl(e,t);return mr(n)}async function ng(e,t){let n=await Nl(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=Qn(s,r,o);return i?`${i}
411
411
  `:n.some(a=>a.isUnmerged)?` 0 files changed
412
- `:""}async function ba(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await cs(e.fs,n);return wa.decode(r)}return re(e,t.newHash)}async function rg(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return cs(e.fs,n)}return Ot(e,t.newHash)}function Ll(e,t){let n=xt(e),r=xt(t),o=at(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 Nl(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 Ot(e,r.oldHash):new Uint8Array(0),i=await rg(e,r);if(jn(s)||jn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=wa.decode(s),c=wa.decode(i),{ins:f,del:l}=Ll(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}oe();Be();Hn();pe();ze();we();function yr(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 sg(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 Os(e,t){if(!sg(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 Fl(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:S().describe("Fetch from all remotes"),prune:S().alias("p").describe("Remove stale remote-tracking refs"),tags:S().describe("Also fetch tags"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:S().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 T("--depth and --unshallow cannot be used together");if(n.unshallow&&!await jo(s))return T("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=Rs),n.all){if(n.remote)return T("fetch --all does not take a remote argument");let c=await he(s),f=[];for(let h of Object.keys(c)){let u=h.match(/^remote "(.+)"$/);u?.[1]&&f.push(u[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let h of f){let u=await _l(s,h,void 0,n.prune,n.tags,r.env,t,i);u.stderr&&l.push(u.stderr),u.exitCode!==0&&(d=u.exitCode)}return{stdout:"",stderr:l.join(""),exitCode:d}}let a=n.remote||"origin";return _l(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function _l(e,t,n,r,o,s,i,a){let c;try{c=await Ur(e,t,s)}catch(I){let H=I instanceof Error?I.message:"";if(H.startsWith("network"))return T(H);throw I}if(!c)return T(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,h=yr(l.fetchRefspec);n&&n.length>0?d=n.map(I=>{let H=yr(I);if(I.includes(":"))return H;for(let G of[H.src,`refs/heads/${H.src}`,`refs/tags/${H.src}`]){let F=Os(h,G);if(F!==null)return{force:H.force||h.force,src:G,dst:F}}return H}):d=[h];let u=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(I=>`${I.src}:${I.dst}`),prune:r,tags:o});if(fe(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await f.advertiseRefs();if(m.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await ge(e)).map(I=>I.hash),w=await B(e,"HEAD");w&&g.push(w);let b=[],k=new Set,R=[];for(let I of m)if(I.name!=="HEAD")for(let H of d){let G=Os(H,I.name);if(G!==null){R.push({remote:I,localRef:G,force:H.force}),k.has(I.hash)||(k.add(I.hash),b.push(I.hash));break}}if(o)for(let I of m)I.name.startsWith("refs/tags/")&&(R.push({remote:I,localRef:I.name,force:!1}),k.has(I.hash)||(k.add(I.hash),b.push(I.hash)));let C=new Set(g),E=b.filter(I=>!C.has(I)),y,x=a!==void 0?await Gr(e):void 0;a!==void 0&&(y={depth:a,existingShallows:x});let $=E.length>0?E:y?b:[];if($.length>0){let I=await f.fetch($,g,y);I.shallowUpdates&&await Lr(e,I.shallowUpdates,x)}let A=await sn(e,s),P=[],O=[];for(let I of R){let H=await B(e,I.localRef);O.push(H),await J(e,I.localRef,I.remote.hash),await Je(e,I.localRef,{oldHash:H??te,newHash:I.remote.hash,name:A.name,email:A.email,timestamp:A.timestamp,tz:A.tz,message:H?"fetch":"fetch: storing head"})}if(P.push(...lo(R.map((I,H)=>({...I,oldHash:O[H]})),Ln,Z)),!o)for(let I of m){if(!I.name.startsWith("refs/tags/")||k.has(I.hash))continue;let H=await B(e,I.name),G=I.peeledHash??I.hash;!H&&C.has(G)&&(await J(e,I.name,I.hash),await Je(e,I.name,{oldHash:te,newHash:I.hash,name:A.name,email:A.email,timestamp:A.timestamp,tz:A.tz,message:"fetch: storing head"}),P.push({prefix:" * [new tag]",from:Ln(I.name),to:Ln(I.name)}))}if(r){let I=`refs/remotes/${t}`,H=await ge(e,I),G=new Set(m.filter(F=>F.name.startsWith("refs/heads/")).map(F=>F.name.slice(11)));for(let F of H){if((await e.refStore.readRef(F.name))?.type==="symbolic")continue;let N=F.name.slice(I.length+1);N!=="HEAD"&&(G.has(N)||(await me(e,F.name),P.push({prefix:" - [deleted]",from:"(none)",to:`${t}/${N}`})))}}let D=m.find(I=>I.name==="HEAD");if(D){let I=v(e.gitDir,"FETCH_HEAD"),H=m.find(F=>F.name.startsWith("refs/heads/")&&F.hash===D.hash),G=H?`branch '${H.name.slice(11)}' of`:"of";await e.fs.writeFile(I,`${D.hash} ${G} ${l.url}
413
- `),await Js(e,t,m,f.headTarget)}let K={stdout:"",stderr:P.length>0?`From ${l.url}
414
- ${vr(P,10)}`:"",exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:R.length}),K}oe();Ce();ie();pe();ze();we();oe();Ce();ie();pe();ze();we();async function Ul(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=v(e.gitDir,"logs");await e.fs.exists(o)&&await Bl(e,o,o,t);let s=await z(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 B(e,a);c&&t.add(c)}let i=[];for(let a of t)await $t(e,a)&&i.push(a);return i}async function Bl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=v(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Bl(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await et(e,c);for(let l of f)l.newHash!==te&&r.add(l.newHash)}}}Xs();$r();pe();async function og(e,t){let n=new Set,r=v(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(v(r,i)),c=new Xt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?_r(await Nr(e,t,[])):(await _r(await Nr(e,t,[]))).filter(s=>!n.has(s.hash))}async function ya(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 _r(await Nr(t,r,[])):await og(t,r);if(a.length===0)return null;let c=a.length,f=No(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:h,entries:u}=await Ys(d),m=await Mc(h,u),p=h.subarray(h.byteLength-20),g="";for(let E=0;E<20;E++){let y=p[E];g+=(y>>4).toString(16)+(y&15).toString(16)}let w=v(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let b=`pack-${g}`,k=v(w,`${b}.pack`),R=v(w,`${b}.idx`);await n.writeFile(k,h),await n.writeFile(R,m);let C=new Set(f.map(E=>E.hash));if(t.objectStore.invalidatePacks?.(),o){let E=await n.readdir(w);for(let $ of E){if(!$.endsWith(".idx"))continue;let A=$.slice(0,-4);if(A===b)continue;let P=v(w,`${A}.idx`),O=!0;try{let D=await n.readFileBuffer(P),L=new Xt(D);for(let K of L.allHashes())if(!C.has(K)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(v(w,`${A}.pack`))}catch{}try{await n.rm(P)}catch{}}}let y=v(t.gitDir,"objects"),x;try{x=await n.readdir(y)}catch{x=[]}for(let $ of x){if($==="pack"||$==="info"||$.length!==2)continue;let A=v(y,$),P;try{P=await n.readdir(A)}catch{continue}for(let O of P){let D=`${$}${O}`;C.has(D)&&await n.rm(v(A,O))}try{(await n.readdir(A)).length===0&&await n.rm(A,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function Ea(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(`
415
- `)}function Wl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:S().alias("a").describe("Pack all objects, including already-packed"),delete:S().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Ul(s),a=await ya({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Ea(a.totalCount,a.deltaCount)}
412
+ `:""}async function ba(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await fs(e.fs,n);return wa.decode(r)}return se(e,t.newHash)}async function rg(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return fs(e.fs,n)}return Ot(e,t.newHash)}function Ll(e,t){let n=xt(e),r=xt(t),o=it(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function Nl(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?hn(r.oldPath,r.path):r.path,s=r.oldHash?await Ot(e,r.oldHash):new Uint8Array(0),i=await rg(e,r);if(Mn(s)||Mn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=wa.decode(s),c=wa.decode(i),{ins:f,del:l}=Ll(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}oe();Be();nr();me();Ke();we();function yr(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 sg(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 Is(e,t){if(!sg(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 Fl(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[K.string().name("remote").describe("Remote to fetch from").optional(),K.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:I().describe("Fetch from all remotes"),prune:I().alias("p").describe("Remove stale remote-tracking refs"),tags:I().describe("Also fetch tags"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:I().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return S("--depth and --unshallow cannot be used together");if(n.unshallow&&!await jo(s))return S("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=xs),n.all){if(n.remote)return S("fetch --all does not take a remote argument");let c=await pe(s),f=[];for(let h of Object.keys(c)){let u=h.match(/^remote "(.+)"$/);u?.[1]&&f.push(u[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let h of f){let u=await _l(s,h,void 0,n.prune,n.tags,r.env,t,i);u.stderr&&l.push(u.stderr),u.exitCode!==0&&(d=u.exitCode)}return{stdout:"",stderr:l.join(""),exitCode:d}}let a=n.remote||"origin";return _l(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function _l(e,t,n,r,o,s,i,a){let c;try{c=await Br(e,t,s)}catch(O){let A=O instanceof Error?O.message:"";if(A.startsWith("network"))return S(A);throw O}if(!c)return S(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,h=yr(l.fetchRefspec);n&&n.length>0?d=n.map(O=>{let A=yr(O);if(O.includes(":"))return A;for(let L of[A.src,`refs/heads/${A.src}`,`refs/tags/${A.src}`]){let F=Is(h,L);if(F!==null)return{force:A.force||h.force,src:L,dst:F}}return A}):d=[h];let u=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(O=>`${O.src}:${O.dst}`),prune:r,tags:o});if(fe(u))return{stdout:"",stderr:u.message??"",exitCode:1};let m=await f.advertiseRefs();if(m.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await ge(e)).map(O=>O.hash),w=await B(e,"HEAD");w&&g.push(w);let b=[],y=new Set,x=[];for(let O of m)if(O.name!=="HEAD")for(let A of d){let L=Is(A,O.name);if(L!==null){x.push({remote:O,localRef:L,force:A.force}),y.has(O.hash)||(y.add(O.hash),b.push(O.hash));break}}if(o)for(let O of m)O.name.startsWith("refs/tags/")&&(x.push({remote:O,localRef:O.name,force:!1}),y.has(O.hash)||(y.add(O.hash),b.push(O.hash)));let k=new Set(g),R=b.filter(O=>!k.has(O)),E,C=a!==void 0?await Lr(e):void 0;a!==void 0&&(E={depth:a,existingShallows:C});let $=R.length>0?R:E?b:[];if($.length>0){let O=await f.fetch($,g,E);O.shallowUpdates&&await Nr(e,O.shallowUpdates,C)}let D=await vn(e,s),P=[],T=[];for(let O of x){let A=await B(e,O.localRef);T.push(A),await J(e,O.localRef,O.remote.hash),await ft(e,O.localRef,{oldHash:A??te,newHash:O.remote.hash,name:D.name,email:D.email,timestamp:D.timestamp,tz:D.tz,message:A?"fetch":"fetch: storing head"})}if(P.push(...lo(x.map((O,A)=>({...O,oldHash:T[A]})),Gn,Z)),!o)for(let O of m){if(!O.name.startsWith("refs/tags/")||y.has(O.hash))continue;let A=await B(e,O.name),L=O.peeledHash??O.hash;!A&&k.has(L)&&(await J(e,O.name,O.hash),await ft(e,O.name,{oldHash:te,newHash:O.hash,name:D.name,email:D.email,timestamp:D.timestamp,tz:D.tz,message:"fetch: storing head"}),P.push({prefix:" * [new tag]",from:Gn(O.name),to:Gn(O.name)}))}if(r){let O=`refs/remotes/${t}`,A=await ge(e,O),L=new Set(m.filter(F=>F.name.startsWith("refs/heads/")).map(F=>F.name.slice(11)));for(let F of A){if((await e.refStore.readRef(F.name))?.type==="symbolic")continue;let N=F.name.slice(O.length+1);N!=="HEAD"&&(L.has(N)||(await he(e,F.name),P.push({prefix:" - [deleted]",from:"(none)",to:`${t}/${N}`})))}}let H=m.find(O=>O.name==="HEAD");if(H){let O=v(e.gitDir,"FETCH_HEAD"),A=m.find(F=>F.name.startsWith("refs/heads/")&&F.hash===H.hash),L=A?`branch '${A.name.slice(11)}' of`:"of";await e.fs.writeFile(O,`${H.hash} ${L} ${l.url}
413
+ `),await Sr(e,t,m,f.headTarget)}let W={stdout:"",stderr:P.length>0?`From ${l.url}
414
+ ${Hr(P,10)}`:"",exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:x.length}),W}oe();Ce();ie();me();Ke();we();oe();Ce();ie();me();Ke();we();async function Ul(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=v(e.gitDir,"logs");await e.fs.exists(o)&&await Bl(e,o,o,t);let s=await z(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 B(e,a);c&&t.add(c)}let i=[];for(let a of t)await $t(e,a)&&i.push(a);return i}async function Bl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=v(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Bl(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Qe(e,c);for(let l of f)l.newHash!==te&&r.add(l.newHash)}}}Zs();$r();me();async function og(e,t){let n=new Set,r=v(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(v(r,i)),c=new Xt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Fr(await _r(e,t,[])):(await Fr(await _r(e,t,[]))).filter(s=>!n.has(s.hash))}async function ya(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 Fr(await _r(t,r,[])):await og(t,r);if(a.length===0)return null;let c=a.length,f=No(a,{window:s,depth:i}),l=f.filter(R=>R.delta).length,d=f.map(R=>({hash:R.hash,type:R.type,content:R.content,delta:R.delta,deltaBaseHash:R.deltaBase})),{data:h,entries:u}=await Xs(d),m=await Mc(h,u),p=h.subarray(h.byteLength-20),g="";for(let R=0;R<20;R++){let E=p[R];g+=(E>>4).toString(16)+(E&15).toString(16)}let w=v(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let b=`pack-${g}`,y=v(w,`${b}.pack`),x=v(w,`${b}.idx`);await n.writeFile(y,h),await n.writeFile(x,m);let k=new Set(f.map(R=>R.hash));if(t.objectStore.invalidatePacks?.(),o){let R=await n.readdir(w);for(let $ of R){if(!$.endsWith(".idx"))continue;let D=$.slice(0,-4);if(D===b)continue;let P=v(w,`${D}.idx`),T=!0;try{let H=await n.readFileBuffer(P),M=new Xt(H);for(let W of M.allHashes())if(!k.has(W)){T=!1;break}}catch{T=!1}if(T){try{await n.rm(v(w,`${D}.pack`))}catch{}try{await n.rm(P)}catch{}}}let E=v(t.gitDir,"objects"),C;try{C=await n.readdir(E)}catch{C=[]}for(let $ of C){if($==="pack"||$==="info"||$.length!==2)continue;let D=v(E,$),P;try{P=await n.readdir(D)}catch{continue}for(let T of P){let H=`${$}${T}`;k.has(H)&&await n.rm(v(D,T))}try{(await n.readdir(D)).length===0&&await n.rm(D,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function Ea(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(`
415
+ `)}function Wl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:I().alias("a").describe("Pack all objects, including already-packed"),delete:I().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=await Ul(s),a=await ya({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Ea(a.totalCount,a.deltaCount)}
416
416
  `,exitCode:0}:{stdout:`Nothing new to pack.
417
- `,stderr:"",exitCode:0}}})}function ql(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:S().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;await qc(s),await Et(s);let i=await ag(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await ya({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await cg(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Ea(f.totalCount,f.deltaCount,!0)}
418
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var ig=2160*60*60;async function ag(e){let t=new Set,n=await X(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)-ig,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await zl(e,i,i,s,t);let a=await z(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 B(e,f);l&&t.add(l)}let c=[];for(let f of t)await $t(e,f)&&c.push(f);return c}async function zl(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=v(t,i),c=await e.fs.stat(a);if(c.isDirectory){await zl(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 et(e,f);if(f==="refs/stash"){for(let h of l)h.newHash!==te&&o.add(h.newHash);continue}let d=l.filter(h=>h.timestamp>=r);await Fn(e,f,d);for(let h of d)h.newHash!==te&&o.add(h.newHash)}}}async function cg(e,t){let n=v(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(v(n,o),{recursive:!0})}catch{}}oe();function fg(e){let t=Math.min(e.length,8e3),n=0;for(let r=0;r<t;r++)e.charCodeAt(r)===0&&n++;return n>t*.01}function Kl(e,t,n,r){if(fg(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
419
- `);if(o.length>0&&o[o.length-1]===""&&o.pop(),n&&t.length>1&&!t.every(a=>o.some(c=>a.test(c))))return{matches:[],binary:!1};let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.some(f=>f.test(a));(r?!c:c)&&s.push({lineNo:i+1,line:a})}return{matches:s,binary:!1}}function lg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vl(e,t){let n=t?.fixed?lg(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ie();pe();De();async function dg(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=v(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function ug(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=o.hash;r.push({path:o.path,getContent:()=>re(e,s)})}return r}async function hg(e,t){return(await qe(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>re(e,r.hash)}))}function mg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function pg(e,t,n){return n||t===""?e:rt(t,e)}function Yl(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[q.string().name("args").variadic().optional()],options:{cached:S().describe("Search blobs registered in the index"),lineNumber:S().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:S().alias("l").describe("Show only filenames"),filesWithoutMatch:S().alias("L").describe("Show only filenames without matches"),count:S().alias("c").describe("Show count of matching lines per file"),ignoreCase:S().alias("i").describe("Case insensitive matching"),wordRegexp:S().alias("w").describe("Match whole words only"),invertMatch:S().alias("v").describe("Invert the sense of matching"),fixedStrings:S().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:S().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:S().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:S().alias("h").describe("Suppress filename prefix"),forceFilename:S().alias("H").describe("Force filename prefix"),fullName:S().describe("Force paths to be output relative to project top"),quiet:S().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:S().describe("Require all patterns to match in a file"),maxDepth:Y.number().describe("Descend at most <n> levels of directories"),maxCount:Y.number().alias("m").describe("Maximum number of matches per file"),afterContext:Y.number().alias("A").describe("Show <n> lines after match"),beforeContext:Y.number().alias("B").describe("Show <n> lines before match"),context:Y.number().alias("C").describe("Show <n> lines before and after match"),heading:S().describe("Show filename above matches"),break:S().describe("Print empty line between results from different files"),pattern:Y.string().alias("e").repeatable().describe("Match <pattern>")},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??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return T("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let h=[];for(let F of f){let U=Vl(F,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!U)return T(`command line, '${F}': invalid regular expression`);h.push(U)}let u=[];if(l.length>0)for(let F of l){let U=await bt(i,F);if(M(U))return U;let N;try{N=await Ae(i,U)}catch{return T(`bad revision '${F}'`)}let ne=await j(i,N),V=await hg(i,ne.tree);u.push({prefix:`${F}:`,files:V})}else if(n.cached)u.push({prefix:"",files:await ug(i)});else{if(!i.workTree)return T("this operation must be run in a work tree");u.push({prefix:"",files:await dg(i)})}let m=dt(i,r.cwd),p=null;c.length>0&&(p=c.map(F=>Ue(F,m)));let g=n.maxDepth,w=n.maxCount,b=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),k=!!n.filesWithMatches,R=!!n.filesWithoutMatch,C=!!n.count,E=!!n.quiet,y=!!n.heading,x=!!n.break,$=!!n.suppressFilename,A=!!n.invertMatch,P=!!n.allMatch,O=n.context??n.afterContext??0,D=n.context??n.beforeContext??0,L=O>0||D>0,K=[],I=!1,H=!0;for(let F of u){let U=F.files.slice().sort((N,ne)=>N.path<ne.path?-1:N.path>ne.path?1:0);for(let N of U){if(p&&!Ee(p,N.path)||g!==void 0&&mg(N.path)>g)continue;let ne=await N.getContent(),V=Kl(ne,h,P,A),ee=pg(N.path,m,!!n.fullName),ke=F.prefix;if(V.binary){if(I=!0,E)return{stdout:"",stderr:"",exitCode:0};k?K.push(`${ke}${ee}`):!R&&!C&&K.push(`Binary file ${ke}${ee} matches`);continue}if(V.matches.length===0){R&&K.push(`${ke}${ee}`);continue}if(I=!0,E)return{stdout:"",stderr:"",exitCode:0};if(R)continue;if(k){K.push(`${ke}${ee}`);continue}if(C){let ce=w!==void 0?Math.min(V.matches.length,w):V.matches.length;K.push(`${ke}${ee}:${ce}`);continue}let _e=V.matches;if(w!==void 0&&(_e=_e.slice(0,w)),L)gg(K,ne,_e,ke,ee,$,D,O,y,x,H);else if(y){!H&&x&&K.push(""),K.push(`${ke}${ee}`);for(let ce of _e)b?K.push(`${ce.lineNo}:${ce.line}`):K.push(ce.line)}else{!H&&x&&K.push("");for(let ce of _e){let Ie=$?"":`${ke}${ee}:`;b?K.push(`${Ie}${ce.lineNo}:${ce.line}`):K.push(`${Ie}${ce.line}`)}}H=!1}}return E?{stdout:"",stderr:"",exitCode:I?0:1}:{stdout:K.length>0?`${K.join(`
417
+ `,stderr:"",exitCode:0}}})}function ql(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:I().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;await qc(s),await Et(s);let i=await ag(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await ya({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await cg(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Ea(f.totalCount,f.deltaCount,!0)}
418
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var ig=2160*60*60;async function ag(e){let t=new Set,n=await X(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)-ig,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await Kl(e,i,i,s,t);let a=await z(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 B(e,f);l&&t.add(l)}let c=[];for(let f of t)await $t(e,f)&&c.push(f);return c}async function Kl(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=v(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Kl(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 Qe(e,f);if(f==="refs/stash"){for(let h of l)h.newHash!==te&&o.add(h.newHash);continue}let d=l.filter(h=>h.timestamp>=r);await _n(e,f,d);for(let h of d)h.newHash!==te&&o.add(h.newHash)}}}async function cg(e,t){let n=v(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(v(n,o),{recursive:!0})}catch{}}oe();function fg(e){let t=Math.min(e.length,8e3),n=0;for(let r=0;r<t;r++)e.charCodeAt(r)===0&&n++;return n>t*.01}function zl(e,t,n,r){if(fg(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
419
+ `);if(o.length>0&&o[o.length-1]===""&&o.pop(),n&&t.length>1&&!t.every(a=>o.some(c=>a.test(c))))return{matches:[],binary:!1};let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.some(f=>f.test(a));(r?!c:c)&&s.push({lineNo:i+1,line:a})}return{matches:s,binary:!1}}function lg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vl(e,t){let n=t?.fixed?lg(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ie();me();De();async function dg(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=v(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function ug(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=o.hash;r.push({path:o.path,getContent:()=>se(e,s)})}return r}async function hg(e,t){return(await qe(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>se(e,r.hash)}))}function mg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function pg(e,t,n){return n||t===""?e:nt(t,e)}function Yl(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[K.string().name("args").variadic().optional()],options:{cached:I().describe("Search blobs registered in the index"),lineNumber:I().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:I().alias("l").describe("Show only filenames"),filesWithoutMatch:I().alias("L").describe("Show only filenames without matches"),count:I().alias("c").describe("Show count of matching lines per file"),ignoreCase:I().alias("i").describe("Case insensitive matching"),wordRegexp:I().alias("w").describe("Match whole words only"),invertMatch:I().alias("v").describe("Invert the sense of matching"),fixedStrings:I().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:I().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:I().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:I().alias("h").describe("Suppress filename prefix"),forceFilename:I().alias("H").describe("Force filename prefix"),fullName:I().describe("Force paths to be output relative to project top"),quiet:I().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:I().describe("Require all patterns to match in a file"),maxDepth:Y.number().describe("Descend at most <n> levels of directories"),maxCount:Y.number().alias("m").describe("Maximum number of matches per file"),afterContext:Y.number().alias("A").describe("Show <n> lines after match"),beforeContext:Y.number().alias("B").describe("Show <n> lines before match"),context:Y.number().alias("C").describe("Show <n> lines before and after match"),heading:I().describe("Show filename above matches"),break:I().describe("Print empty line between results from different files"),pattern:Y.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=n.args??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return S("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let h=[];for(let F of f){let U=Vl(F,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!U)return S(`command line, '${F}': invalid regular expression`);h.push(U)}let u=[];if(l.length>0)for(let F of l){let U=await bt(i,F);if(j(U))return U;let N;try{N=await Ae(i,U)}catch{return S(`bad revision '${F}'`)}let re=await G(i,N),V=await hg(i,re.tree);u.push({prefix:`${F}:`,files:V})}else if(n.cached)u.push({prefix:"",files:await ug(i)});else{if(!i.workTree)return S("this operation must be run in a work tree");u.push({prefix:"",files:await dg(i)})}let m=dt(i,r.cwd),p=null;c.length>0&&(p=c.map(F=>Ue(F,m)));let g=n.maxDepth,w=n.maxCount,b=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),y=!!n.filesWithMatches,x=!!n.filesWithoutMatch,k=!!n.count,R=!!n.quiet,E=!!n.heading,C=!!n.break,$=!!n.suppressFilename,D=!!n.invertMatch,P=!!n.allMatch,T=n.context??n.afterContext??0,H=n.context??n.beforeContext??0,M=T>0||H>0,W=[],O=!1,A=!0;for(let F of u){let U=F.files.slice().sort((N,re)=>N.path<re.path?-1:N.path>re.path?1:0);for(let N of U){if(p&&!Ee(p,N.path)||g!==void 0&&mg(N.path)>g)continue;let re=await N.getContent(),V=zl(re,h,P,D),ee=pg(N.path,m,!!n.fullName),ke=F.prefix;if(V.binary){if(O=!0,R)return{stdout:"",stderr:"",exitCode:0};y?W.push(`${ke}${ee}`):!x&&!k&&W.push(`Binary file ${ke}${ee} matches`);continue}if(V.matches.length===0){x&&W.push(`${ke}${ee}`);continue}if(O=!0,R)return{stdout:"",stderr:"",exitCode:0};if(x)continue;if(y){W.push(`${ke}${ee}`);continue}if(k){let ce=w!==void 0?Math.min(V.matches.length,w):V.matches.length;W.push(`${ke}${ee}:${ce}`);continue}let _e=V.matches;if(w!==void 0&&(_e=_e.slice(0,w)),M)gg(W,re,_e,ke,ee,$,H,T,E,C,A);else if(E){!A&&C&&W.push(""),W.push(`${ke}${ee}`);for(let ce of _e)b?W.push(`${ce.lineNo}:${ce.line}`):W.push(ce.line)}else{!A&&C&&W.push("");for(let ce of _e){let Ie=$?"":`${ke}${ee}:`;b?W.push(`${Ie}${ce.lineNo}:${ce.line}`):W.push(`${Ie}${ce.line}`)}}A=!1}}return R?{stdout:"",stderr:"",exitCode:O?0:1}:{stdout:W.length>0?`${W.join(`
420
420
  `)}
421
- `:"",stderr:"",exitCode:I?0:1}}})}function gg(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
422
- `);d.length>0&&d[d.length-1]===""&&d.pop();let h=new Set(n.map(g=>g.lineNo)),u=[];for(let g of n){let w=Math.max(1,g.lineNo-i),b=Math.min(d.length,g.lineNo+a);u.push([w,b])}let m=[];for(let[g,w]of u)m.length>0&&g<=m[m.length-1][1]+1?m[m.length-1][1]=Math.max(m[m.length-1][1],w):m.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<m.length;g++){g>0&&e.push("--");let[w,b]=m[g];for(let k=w;k<=b;k++){let R=d[k-1],E=h.has(k)?":":"-";c?e.push(`${k}${E}${R}`):e.push(`${p}${E}${k}${E}${R}`)}}}pe();_n();function Xl(e,t){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:S().describe("Create a bare repository"),initialBranch:Y.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?Mt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await Qs(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
421
+ `:"",stderr:"",exitCode:O?0:1}}})}function gg(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
422
+ `);d.length>0&&d[d.length-1]===""&&d.pop();let h=new Set(n.map(g=>g.lineNo)),u=[];for(let g of n){let w=Math.max(1,g.lineNo-i),b=Math.min(d.length,g.lineNo+a);u.push([w,b])}let m=[];for(let[g,w]of u)m.length>0&&g<=m[m.length-1][1]+1?m[m.length-1][1]=Math.max(m[m.length-1][1],w):m.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<m.length;g++){g>0&&e.push("--");let[w,b]=m[g];for(let y=w;y<=b;y++){let x=d[y-1],R=h.has(y)?":":"-";c?e.push(`${y}${R}${x}`):e.push(`${p}${R}${y}${R}${x}`)}}}me();Nn();function Xl(e,t){e.command("init",{description:"Initialize a new repository",args:[K.string().name("directory").describe("The directory to initialize").optional()],options:{bare:I().describe("Create a bare repository"),initialBranch:Y.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?Mt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await Qs(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
423
423
  `);let f=n.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${f}Git repository in ${i.gitDir}/
424
- `,stderr:c,exitCode:0}}})}oe();lr();var Ko=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:Zl(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,Zl(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 Zl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}oe();function Is(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+=ed(c.timestamp,c.timezone),s+=3;continue;case"i":o+=td(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Vo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=rd(c.timestamp,c.timezone),s+=3;continue;case"r":o+=nd(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=Z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=Z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(Z).join(" "),s+=2;continue;case"s":o+=ka(r.message),s+=2;continue;case"b":o+=wg(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+=`
424
+ `,stderr:c,exitCode:0}}})}oe();lr();var zo=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:Zl(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,Zl(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 Zl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}oe();function Ss(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+=ed(c.timestamp,c.timezone),s+=3;continue;case"i":o+=td(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Vo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=rd(c.timestamp,c.timezone),s+=3;continue;case"r":o+=nd(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=Z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=Z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(Z).join(" "),s+=2;continue;case"s":o+=ka(r.message),s+=2;continue;case"b":o+=wg(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+=`
425
425
  `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var ka=ue;function wg(e){let t=e.indexOf(`
426
426
 
427
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Yo(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","raw"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function Ss(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?Z(o):o,c=ka(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${ka(s.message)}`),a.join(`
427
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Yo(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","raw"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function Ts(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?Z(o):o,c=ka(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${ka(s.message)}`),a.join(`
428
428
  `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
429
429
  `))a.push(` ${f}`);return a.join(`
430
430
  `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Vo(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Vo(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
@@ -433,31 +433,31 @@ ${vr(P,10)}`:"",exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,
433
433
  `))o.push(` ${i}`);return o.join(`
434
434
  `)}function yg(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(Z).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Vo(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
435
435
  `))s.push(` ${a}`);return s.join(`
436
- `)}var Jl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ql=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Eg(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 Xo(e,t){let n=Eg(t);return new Date((e+n*60)*1e3)}function kg(e){return`${e.slice(0,3)}:${e.slice(3)}`}function ed(e,t){let n=Xo(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"),f=t==="+0000"||t==="-0000"?"Z":kg(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function td(e,t){let n=Xo(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 nd(e){let n=Math.floor(Date.now()/1e3)-e;if(n<0&&(n=0),n<90)return n===1?"1 second ago":`${n} seconds ago`;if(n=Math.round(n/60),n<90)return n===1?"1 minute ago":`${n} minutes ago`;if(n=Math.round(n/60),n<36)return n===1?"1 hour ago":`${n} hours ago`;if(n=Math.round(n/24),n<14)return n===1?"1 day ago":`${n} days ago`;if(n<70){let s=Math.round(n/7);return s===1?"1 week ago":`${s} weeks ago`}if(n<365){let s=Math.round(n/30);return s===1?"1 month ago":`${s} months ago`}let r=Math.floor(n/365),o=Math.round((n-r*365)/30);if(o>0){let s=r===1?"1 year":`${r} years`,i=o===1?"1 month":`${o} months`;return`${s}, ${i} ago`}return r===1?"1 year ago":`${r} years ago`}function Rg(e,t){let n=Xo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0");return`${r}-${o}-${s}`}function xg(e,t){return`${e} ${t}`}function Cg(e){return e.toString()}function Pg(e,t){let n=new Date(e*1e3),r=Jl[n.getDay()]?.slice(0,3),o=Ql[n.getMonth()],s=n.getDate(),i=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0"),f=n.getFullYear();return`${r} ${o} ${s} ${i}:${a}:${c} ${f}`}function Vo(e,t,n){switch(n){case"short":return Rg(e,t);case"iso":return td(e,t);case"iso-strict":return ed(e,t);case"relative":case"human":return nd(e);case"rfc":return rd(e,t);case"raw":return xg(e,t);case"unix":return Cg(e);case"local":return Pg(e,t);default:return In(e,t)}}function rd(e,t){let n=Xo(e,t),r=Jl[n.getUTCDay()]?.slice(0,3),o=Ql[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}ie();we();fn();De();function id(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:Y.number().alias("n").describe("Limit the number of commits to output"),oneline:S().describe("Condense each commit to a single line"),all:S().describe("Walk all refs, not just HEAD"),author:Y.string().describe("Filter by author (regex or substring)"),grep:Y.string().describe("Filter by commit message (regex or substring)"),since:Y.string().describe("Show commits after date"),after:Y.string().describe("Synonym for --since"),until:Y.string().describe("Show commits before date"),before:Y.string().describe("Synonym for --until"),decorate:S().describe("Show ref names next to commit hashes"),reverse:S().describe("Output commits in reverse order"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name"),patch:S().alias("p").describe("Show diff in patch format"),stat:S().describe("Show diffstat summary"),nameStatus:S().describe("Show names and status of changed files"),nameOnly:S().describe("Show only names of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),graph:S().describe("Draw text-based graph of the commit history"),firstParent:S().describe("Follow only the first parent of merge commits"),date:Y.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},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?qo(f[0]):null;if(l){let V=async Ie=>{let ut=await We(i,Ie);if(!ut)return Qt(Ie);try{return await Ae(i,ut)}catch{return Qt(Ie)}},ee=await V(l.left);if(typeof ee=="object"&&"exitCode"in ee)return ee;let ke=await V(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let _e=ee,ce=ke;if(l.type==="two-dot")a=[ce],c=[_e];else{a=[_e,ce];let Ie=await qt(i,_e,ce);c=Ie.length>0?Ie:void 0}if(n.all){let Ie=await ge(i);for(let Er of Ie)try{let Ye=await Ae(i,Er.hash);a.includes(Ye)||a.push(Ye)}catch{}let ut=await X(i);ut&&!a.includes(ut)&&a.push(ut)}}else if(n.all){let V=await ge(i),ee=new Set;for(let _e of V)try{ee.add(await Ae(i,_e.hash))}catch{}let ke=await X(i);ke&&ee.add(ke),a=[...ee]}else if(f&&f.length>0){let V=[];for(let ee of f){let ke=await We(i,ee);if(!ke)return Qt(ee);try{V.push(await Ae(i,ke))}catch{return Qt(ee)}}a=V}else{let V=await Qe(i);if(M(V))return V;a=[V]}if(a.length===0)return T("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(V=>Ue(V,"")):null,h=n.author?sd(n.author):null,u=n.grep?sd(n.grep):null,m=n.since??n.after,p=n.until??n.before,g=m?sa(m):null,w=p?sa(p):null,b=n.format??n.pretty,k=null,R=null,C=!1;if(n.oneline)R="oneline",C=!0;else if(b!==void 0){let V=Yo(b);k=V.formatStr,R=V.preset}let E=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!E.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
437
- `,exitCode:128};let y=n.date,x=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,$=n.graph;if($&&n.reverse)return T("options '--graph' and '--reverse' cannot be used together");let P=n.decorate||k!=null&&(k.includes("%d")||k.includes("%D"))?await Ig(i):null,O=P?V=>od(P,V):void 0,D=P?V=>{let ee=od(P,V);return ee.startsWith("(")&&ee.endsWith(")")?ee.slice(1,-1):ee}:void 0,L=n.maxCount,K=n.reverse,I=n.firstParent,H=d?Og(i,a,d,c?await $g(i,c):void 0,I):_t(i,a,{exclude:c,topoOrder:$,firstParent:I}),G=[];for await(let V of H){if(L!==void 0&&G.length>=L)break;let{commit:ee}=V;if(!(w!==null&&ee.committer.timestamp>w)&&!(g!==null&&ee.committer.timestamp<=g)){if(h){let ke=`${ee.author.name} <${ee.author.email}>`;if(!h(ke))continue}u&&!u(ee.message)||G.push(V)}}let F=K?G.reverse():G;if($)return Sg(F,i,k,R,C,x,O,D,y);if(k!==null){let V=[];for(let ee of F){let ke={hash:ee.hash,commit:ee.commit,decorations:O,decorationsRaw:D,dateMode:y},_e=Is(k,ke),ce=await Ra(i,ee.commit,x);ce&&(_e+=`
436
+ `)}var Jl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ql=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Eg(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 Xo(e,t){let n=Eg(t);return new Date((e+n*60)*1e3)}function kg(e){return`${e.slice(0,3)}:${e.slice(3)}`}function ed(e,t){let n=Xo(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"),f=t==="+0000"||t==="-0000"?"Z":kg(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function td(e,t){let n=Xo(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 nd(e){let n=Math.floor(Date.now()/1e3)-e;if(n<0&&(n=0),n<90)return n===1?"1 second ago":`${n} seconds ago`;if(n=Math.round(n/60),n<90)return n===1?"1 minute ago":`${n} minutes ago`;if(n=Math.round(n/60),n<36)return n===1?"1 hour ago":`${n} hours ago`;if(n=Math.round(n/24),n<14)return n===1?"1 day ago":`${n} days ago`;if(n<70){let s=Math.round(n/7);return s===1?"1 week ago":`${s} weeks ago`}if(n<365){let s=Math.round(n/30);return s===1?"1 month ago":`${s} months ago`}let r=Math.floor(n/365),o=Math.round((n-r*365)/30);if(o>0){let s=r===1?"1 year":`${r} years`,i=o===1?"1 month":`${o} months`;return`${s}, ${i} ago`}return r===1?"1 year ago":`${r} years ago`}function Rg(e,t){let n=Xo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0");return`${r}-${o}-${s}`}function xg(e,t){return`${e} ${t}`}function Cg(e){return e.toString()}function Pg(e,t){let n=new Date(e*1e3),r=Jl[n.getDay()]?.slice(0,3),o=Ql[n.getMonth()],s=n.getDate(),i=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0"),f=n.getFullYear();return`${r} ${o} ${s} ${i}:${a}:${c} ${f}`}function Vo(e,t,n){switch(n){case"short":return Rg(e,t);case"iso":return td(e,t);case"iso-strict":return ed(e,t);case"relative":case"human":return nd(e);case"rfc":return rd(e,t);case"raw":return xg(e,t);case"unix":return Cg(e);case"local":return Pg(e,t);default:return On(e,t)}}function rd(e,t){let n=Xo(e,t),r=Jl[n.getUTCDay()]?.slice(0,3),o=Ql[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}ie();we();cn();De();function id(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[K.string().name("revisions").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of commits to output"),oneline:I().describe("Condense each commit to a single line"),all:I().describe("Walk all refs, not just HEAD"),author:Y.string().describe("Filter by author (regex or substring)"),grep:Y.string().describe("Filter by commit message (regex or substring)"),since:Y.string().describe("Show commits after date"),after:Y.string().describe("Synonym for --since"),until:Y.string().describe("Show commits before date"),before:Y.string().describe("Synonym for --until"),decorate:I().describe("Show ref names next to commit hashes"),reverse:I().describe("Output commits in reverse order"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name"),patch:I().alias("p").describe("Show diff in patch format"),stat:I().describe("Show diffstat summary"),nameStatus:I().describe("Show names and status of changed files"),nameOnly:I().describe("Show only names of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file"),graph:I().describe("Draw text-based graph of the commit history"),firstParent:I().describe("Follow only the first parent of merge commits"),date:Y.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?qo(f[0]):null;if(l){let V=async Ie=>{let ut=await We(i,Ie);if(!ut)return Qt(Ie);try{return await Ae(i,ut)}catch{return Qt(Ie)}},ee=await V(l.left);if(typeof ee=="object"&&"exitCode"in ee)return ee;let ke=await V(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let _e=ee,ce=ke;if(l.type==="two-dot")a=[ce],c=[_e];else{a=[_e,ce];let Ie=await qt(i,_e,ce);c=Ie.length>0?Ie:void 0}if(n.all){let Ie=await ge(i);for(let Er of Ie)try{let Xe=await Ae(i,Er.hash);a.includes(Xe)||a.push(Xe)}catch{}let ut=await X(i);ut&&!a.includes(ut)&&a.push(ut)}}else if(n.all){let V=await ge(i),ee=new Set;for(let _e of V)try{ee.add(await Ae(i,_e.hash))}catch{}let ke=await X(i);ke&&ee.add(ke),a=[...ee]}else if(f&&f.length>0){let V=[];for(let ee of f){let ke=await We(i,ee);if(!ke)return Qt(ee);try{V.push(await Ae(i,ke))}catch{return Qt(ee)}}a=V}else{let V=await Je(i);if(j(V))return V;a=[V]}if(a.length===0)return S("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(V=>Ue(V,"")):null,h=n.author?sd(n.author):null,u=n.grep?sd(n.grep):null,m=n.since??n.after,p=n.until??n.before,g=m?sa(m):null,w=p?sa(p):null,b=n.format??n.pretty,y=null,x=null,k=!1;if(n.oneline)x="oneline",k=!0;else if(b!==void 0){let V=Yo(b);y=V.formatStr,x=V.preset}let R=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!R.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
437
+ `,exitCode:128};let E=n.date,C=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,$=n.graph;if($&&n.reverse)return S("options '--graph' and '--reverse' cannot be used together");let P=n.decorate||y!=null&&(y.includes("%d")||y.includes("%D"))?await Ig(i):null,T=P?V=>od(P,V):void 0,H=P?V=>{let ee=od(P,V);return ee.startsWith("(")&&ee.endsWith(")")?ee.slice(1,-1):ee}:void 0,M=n.maxCount,W=n.reverse,O=n.firstParent,A=d?Og(i,a,d,c?await $g(i,c):void 0,O):_t(i,a,{exclude:c,topoOrder:$,firstParent:O}),L=[];for await(let V of A){if(M!==void 0&&L.length>=M)break;let{commit:ee}=V;if(!(w!==null&&ee.committer.timestamp>w)&&!(g!==null&&ee.committer.timestamp<=g)){if(h){let ke=`${ee.author.name} <${ee.author.email}>`;if(!h(ke))continue}u&&!u(ee.message)||L.push(V)}}let F=W?L.reverse():L;if($)return Sg(F,i,y,x,k,C,T,H,E);if(y!==null){let V=[];for(let ee of F){let ke={hash:ee.hash,commit:ee.commit,decorations:T,decorationsRaw:H,dateMode:E},_e=Ss(y,ke),ce=await Ra(i,ee.commit,C);ce&&(_e+=`
438
438
 
439
439
  ${ce.replace(/\n$/,"")}`),V.push(_e)}return{stdout:V.length>0?`${V.join(`
440
440
  `)}
441
- `:"",stderr:"",exitCode:0}}let U=R??"medium",N=U==="oneline",ne=[];for(let V=0;V<F.length;V++){let ee=F[V],ke={hash:ee.hash,commit:ee.commit,decorations:O,decorationsRaw:D,dateMode:y},_e=Ss(U,ke,V===0,C),ce=await Ra(i,ee.commit,x);ce&&(_e+=`${N?`
441
+ `:"",stderr:"",exitCode:0}}let U=x??"medium",N=U==="oneline",re=[];for(let V=0;V<F.length;V++){let ee=F[V],ke={hash:ee.hash,commit:ee.commit,decorations:T,decorationsRaw:H,dateMode:E},_e=Ts(U,ke,V===0,k),ce=await Ra(i,ee.commit,C);ce&&(_e+=`${N?`
442
442
  `:`
443
443
 
444
- `}${ce.replace(/\n$/,"")}`),ne.push(_e)}return{stdout:ne.length>0?`${ne.join(`
444
+ `}${ce.replace(/\n$/,"")}`),re.push(_e)}return{stdout:re.length>0?`${re.join(`
445
445
  `)}
446
- `:"",stderr:"",exitCode:0}}})}async function $g(e,t){let n=new Set;for await(let r of _t(e,t))n.add(r.hash);return n}function sd(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Og(e,t,n,r,o){let s=new Set(r),i=new Kn,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 Ke(e,null,f.tree)).some(u=>Ee(n,u.path))&&(yield c);continue}if(l.length===1){let h=l[0];if(h){try{let u=await j(e,h);(await Ke(e,u.tree,f.tree)).some(p=>Ee(n,p.path))&&(yield c)}catch{yield c}await a(h)}continue}let d=[];for(let h of l)try{let u=await j(e,h);(await Ke(e,u.tree,f.tree)).some(p=>Ee(n,p.path))||d.push(h)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let h of l)await a(h)}}}async function Ig(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await X(e),o=new Map,s=(f,l,d)=>{let h=o.get(f);h||(h=[],o.set(f,h)),h.push({label:l,fullRef:d})},i=await ge(e,"refs/heads");for(let f of i)s(f.hash,Pe(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 Ae(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function od(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 Sg(e,t,n,r,o,s,i,a,c){let f=new Ko,l=r??"medium",d=l==="oneline",h=[];for(let u=0;u<e.length;u++){let m=e[u],p={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=Is(n,p):g=Ss(l,p,!0,o),f.update(m.hash,m.commit.parents),u>0&&!d&&n===null&&h.push(f.paddingPrefix());let w=g.split(`
447
- `),b=0;for(;;){let{prefix:C,isCommitLine:E}=f.nextLine();if(E){h.push(C+(w[b++]??""));break}h.push(C)}for(;b<w.length;){let{prefix:C}=f.nextLine();h.push(C+w[b++])}for(;!f.isFinished();){let{prefix:C}=f.nextLine();h.push(C)}let k=80-f.width,R=await Ra(t,m.commit,s,k);if(R){let C=R.replace(/\n$/,"").split(`
448
- `);if(d||n!==null)for(let E of C)h.push(f.paddingPrefix()+E);else{h.push(f.paddingPrefix());for(let E of C)h.push(f.paddingPrefix()+E)}}}return{stdout:h.length>0?`${h.join(`
446
+ `:"",stderr:"",exitCode:0}}})}async function $g(e,t){let n=new Set;for await(let r of _t(e,t))n.add(r.hash);return n}function sd(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Og(e,t,n,r,o){let s=new Set(r),i=new Kn,a=async c=>{if(!s.has(c))try{let f=await G(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 Ve(e,null,f.tree)).some(u=>Ee(n,u.path))&&(yield c);continue}if(l.length===1){let h=l[0];if(h){try{let u=await G(e,h);(await Ve(e,u.tree,f.tree)).some(p=>Ee(n,p.path))&&(yield c)}catch{yield c}await a(h)}continue}let d=[];for(let h of l)try{let u=await G(e,h);(await Ve(e,u.tree,f.tree)).some(p=>Ee(n,p.path))||d.push(h)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let h of l)await a(h)}}}async function Ig(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await X(e),o=new Map,s=(f,l,d)=>{let h=o.get(f);h||(h=[],o.set(f,h)),h.push({label:l,fullRef:d})},i=await ge(e,"refs/heads");for(let f of i)s(f.hash,Pe(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 Ae(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function od(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 Sg(e,t,n,r,o,s,i,a,c){let f=new zo,l=r??"medium",d=l==="oneline",h=[];for(let u=0;u<e.length;u++){let m=e[u],p={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=Ss(n,p):g=Ts(l,p,!0,o),f.update(m.hash,m.commit.parents),u>0&&!d&&n===null&&h.push(f.paddingPrefix());let w=g.split(`
447
+ `),b=0;for(;;){let{prefix:k,isCommitLine:R}=f.nextLine();if(R){h.push(k+(w[b++]??""));break}h.push(k)}for(;b<w.length;){let{prefix:k}=f.nextLine();h.push(k+w[b++])}for(;!f.isFinished();){let{prefix:k}=f.nextLine();h.push(k)}let y=80-f.width,x=await Ra(t,m.commit,s,y);if(x){let k=x.replace(/\n$/,"").split(`
448
+ `);if(d||n!==null)for(let R of k)h.push(f.paddingPrefix()+R);else{h.push(f.paddingPrefix());for(let R of k)h.push(f.paddingPrefix()+R)}}}return{stdout:h.length>0?`${h.join(`
449
449
  `)}
450
- `:"",stderr:"",exitCode:0}}async function Ra(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 Ke(e,o,t.tree),{remaining:i,renames:a}=await ot(e,s);switch(n){case"name-only":return Tg(i,a);case"name-status":return vg(i,a);case"stat":return Hg(e,i,a,r);case"shortstat":return Ag(e,i,a);case"numstat":return Dg(e,i,a);case"patch":return Mg(e,i,a)}}function Tg(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}
450
+ `:"",stderr:"",exitCode:0}}async function Ra(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await G(e,t.parents[0])).tree:null,s=await Ve(e,o,t.tree),{remaining:i,renames:a}=await st(e,s);switch(n){case"name-only":return Tg(i,a);case"name-status":return vg(i,a);case"stat":return Hg(e,i,a,r);case"shortstat":return Ag(e,i,a);case"numstat":return Dg(e,i,a);case"patch":return Mg(e,i,a)}}function Tg(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}
451
451
  `).join("")}function vg(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}
452
- `).join("")}async function Hg(e,t,n,r){let{fileStats:o}=await tr(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),mr(o,r)}async function Ag(e,t,n){let{fileStats:r}=await tr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=er(r.length,o,s);return i?`${i}
453
- `:""}async function Dg(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 re(e,s.oldHash):"",a=s.newHash?await re(e,s.newHash):"";if(He(i)||He(a))o+=`- - ${s.display}
454
- `;else{let c=xt(i),f=xt(a),l=at(c,f),d=0,h=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&h++;o+=`${d} ${h} ${s.display}
455
- `}}return o}async function Mg(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 re(e,i.oldHash):"",c=i.newHash?await re(e,i.newHash):"";o+=Ht({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 re(e,i.oldHash):"",c=i.newHash?await re(e,i.newHash):"";o+=Ht({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}oe();Ce();pe();Rn();tt();function cd(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:S().alias("c").describe("Show cached files (default)"),modified:S().alias("m").describe("Show modified files"),deleted:S().alias("d").describe("Show deleted files"),others:S().alias("o").describe("Show other (untracked) files"),unmerged:S().alias("u").describe("Show unmerged files"),stage:S().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":S().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":S().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":S().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Ve(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,h=n.others,u=n.unmerged,m=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||h||u||(f=!0);let k=await z(i),R=g?"\0":`
456
- `,C=o.passthrough.length>0?o.passthrough.map(x=>{let $=r.cwd!==c?jg(c,r.cwd):"";return Ue(x,$)}):null,E=[];if(f)for(let x of k.entries){if(C&&!Ee(C,x.path))continue;let $=w?x.stage>0?"M":"H":null;E.push(ad(x,m,$))}if(u&&!f)for(let x of k.entries)x.stage!==0&&(C&&!Ee(C,x.path)||E.push(ad(x,!0,w?"M":null)));if(l||d){let x=await Gg(i,c,k);for(let{path:$,status:A}of x){if(A==="modified"&&!l||A==="deleted"&&!d||C&&!Ee(C,$))continue;let P=w?A==="deleted"?"R":"C":null;E.push(P?`${P} ${$}`:$)}}if(h){let x=await Lg(i,c,k,p);for(let $ of x)C&&!Ee(C,$)||E.push(w?`? ${$}`:$)}return{stdout:E.length>0?E.join(R)+R:"",stderr:"",exitCode:0}}})}function ad(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 jg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Gg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=v(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await mt(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Bn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Lg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await st(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}oe();lr();Be();Ce();ie();ze();we();fn();De();function fd(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:S().describe("Abort the current in-progress merge"),continue:S().describe("Continue the merge after conflict resolution"),noFf:S().describe("Create a merge commit even when fast-forward is possible"),ffOnly:S().describe("Refuse to merge unless fast-forward is possible"),squash:S().describe("Apply merge result to worktree/index without creating a merge commit"),edit:S().describe("Edit the merge message (no-op, accepted for compatibility)"),message:Y.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 Bg(s,r.env);if(n.continue)return Ug(s,r.env,t);let i=n.branch;if(!i)return T("you must specify a branch to merge");let a=await Qe(s);if(M(a))return a;let c=await z(s),f=$n(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return T(`You have not concluded your merge (MERGE_HEAD exists).
457
- Please, commit your changes before you merge.`);if(await B(s,"CHERRY_PICK_HEAD"))return T(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
452
+ `).join("")}async function Hg(e,t,n,r){let{fileStats:o}=await er(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),mr(o,r)}async function Ag(e,t,n){let{fileStats:r}=await er(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Qn(r.length,o,s);return i?`${i}
453
+ `:""}async function Dg(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:hn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(He(i)||He(a))o+=`- - ${s.display}
454
+ `;else{let c=xt(i),f=xt(a),l=it(c,f),d=0,h=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&h++;o+=`${d} ${h} ${s.display}
455
+ `}}return o}async function Mg(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=Ht({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}oe();Ce();me();kn();et();function cd(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:I().alias("c").describe("Show cached files (default)"),modified:I().alias("m").describe("Show modified files"),deleted:I().alias("d").describe("Show deleted files"),others:I().alias("o").describe("Show other (untracked) files"),unmerged:I().alias("u").describe("Show unmerged files"),stage:I().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":I().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":I().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":I().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,h=n.others,u=n.unmerged,m=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||h||u||(f=!0);let y=await z(i),x=g?"\0":`
456
+ `,k=o.passthrough.length>0?o.passthrough.map(C=>{let $=r.cwd!==c?jg(c,r.cwd):"";return Ue(C,$)}):null,R=[];if(f)for(let C of y.entries){if(k&&!Ee(k,C.path))continue;let $=w?C.stage>0?"M":"H":null;R.push(ad(C,m,$))}if(u&&!f)for(let C of y.entries)C.stage!==0&&(k&&!Ee(k,C.path)||R.push(ad(C,!0,w?"M":null)));if(l||d){let C=await Gg(i,c,y);for(let{path:$,status:D}of C){if(D==="modified"&&!l||D==="deleted"&&!d||k&&!Ee(k,$))continue;let P=w?D==="deleted"?"R":"C":null;R.push(P?`${P} ${$}`:$)}}if(h){let C=await Lg(i,c,y,p);for(let $ of C)k&&!Ee(k,$)||R.push(w?`? ${$}`:$)}return{stdout:R.length>0?R.join(x)+x:"",stderr:"",exitCode:0}}})}function ad(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 jg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Gg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=v(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await mt(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Un(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Lg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await rt(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}oe();lr();Be();Ce();ie();Ke();we();cn();De();function fd(e,t){e.command("merge",{description:"Join two or more development histories together",args:[K.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:I().describe("Abort the current in-progress merge"),continue:I().describe("Continue the merge after conflict resolution"),noFf:I().describe("Create a merge commit even when fast-forward is possible"),ffOnly:I().describe("Refuse to merge unless fast-forward is possible"),squash:I().describe("Apply merge result to worktree/index without creating a merge commit"),edit:I().describe("Edit the merge message (no-op, accepted for compatibility)"),message:Y.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.abort)return Bg(s,r.env);if(n.continue)return Ug(s,r.env,t);let i=n.branch;if(!i)return S("you must specify a branch to merge");let a=await Je(s);if(j(a))return a;let c=await z(s),f=Pn(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return S(`You have not concluded your merge (MERGE_HEAD exists).
457
+ Please, commit your changes before you merge.`);if(await B(s,"CHERRY_PICK_HEAD"))return S(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
458
458
  Please, commit your changes before you merge.`);let h=await We(s,i);if(!h)return _(`merge: ${i} - not something we can merge
459
- `);let u=await Ae(s,h),m=await qt(s,a,u),p=m[0]??null;if(m.length===0)return T("refusing to merge unrelated histories");if(p===u)return await be(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
460
- `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let C=await xe(s,"merge.ff");C==="false"?g=!0:C==="only"&&(w=!0)}if(g&&w)return T("--no-ff and --ff-only are incompatible");let b=p===a&&!g;if(w&&!b)return _(`hint: Diverging branches can't be fast-forwarded, you need to either:
459
+ `);let u=await Ae(s,h),m=await qt(s,a,u),p=m[0]??null;if(m.length===0)return S("refusing to merge unrelated histories");if(p===u)return await be(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
460
+ `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let k=await xe(s,"merge.ff");k==="false"?g=!0:k==="only"&&(w=!0)}if(g&&w)return S("--no-ff and --ff-only are incompatible");let b=p===a&&!g;if(w&&!b)return _(`hint: Diverging branches can't be fast-forwarded, you need to either:
461
461
  hint:
462
462
  hint: git merge --no-ff
463
463
  hint:
@@ -467,44 +467,44 @@ hint: git rebase
467
467
  hint:
468
468
  hint: Disable this message with "git config set advice.diverging false"
469
469
  fatal: Not possible to fast-forward, aborting.
470
- `,128);if(await B(s,"REVERT_HEAD")&&await St(s),b&&!n.squash){let C=await Q(s),E=await Do(s,a,u);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 be(s,"MERGE_MSG");let y=C?.type==="symbolic"?C.target:"HEAD";await se(s,r.env,y,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,C?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return E}let k=n.message,R=k?k.endsWith(`
471
- `)?k:`${k}
472
- `:void 0;return n.squash?Fg(s,a,u,i,r.env,t,R):Ng(s,a,u,i,r.env,g,t,R)}})}async function Ng(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await Q(e),l=f?.type==="symbolic"?Pe(f.target):"HEAD",d=await xe(e,"merge.conflictstyle")??"merge",h={a:"HEAD",b:r,conflictStyle:d},u=await ks(e,t,n,h),m=await Sn(e,u,c.tree,{labels:h,errorExitCode:2,operationName:"merge"});if(!m.ok)return await be(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await se(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(u.conflicts.length>0){await J(e,"MERGE_HEAD",n),await J(e,"ORIG_HEAD",t);let A=a??await pr(e,r,l),P={repo:e,message:A,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(P);if(fe(O))return{stdout:"",stderr:O.message??"",exitCode:1};A=P.message;let D=Kt({version:2,entries:u.entries}).sort();return A+=`
470
+ `,128);if(await B(s,"REVERT_HEAD")&&await St(s),b&&!n.squash){let k=await Q(s),R=await Do(s,a,u);if(R.exitCode===0&&n.message&&(R.stdout=R.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),R.exitCode===0){await be(s,"MERGE_MSG");let E=k?.type==="symbolic"?k.target:"HEAD";await ne(s,r.env,E,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,k?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return R}let y=n.message,x=y?y.endsWith(`
471
+ `)?y:`${y}
472
+ `:void 0;return n.squash?Fg(s,a,u,i,r.env,t,x):Ng(s,a,u,i,r.env,g,t,x)}})}async function Ng(e,t,n,r,o,s=!1,i,a){let c=await G(e,t),f=await Q(e),l=f?.type==="symbolic"?Pe(f.target):"HEAD",d=await xe(e,"merge.conflictstyle")??"merge",h={a:"HEAD",b:r,conflictStyle:d},u=await Rs(e,t,n,h),m=await In(e,u,c.tree,{labels:h,errorExitCode:2,operationName:"merge"});if(!m.ok)return await be(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(u.conflicts.length>0){await J(e,"MERGE_HEAD",n),await J(e,"ORIG_HEAD",t);let D=a??await pr(e,r,l),P={repo:e,message:D,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},T=await i?.hooks?.mergeMsg?.(P);if(fe(T))return{stdout:"",stderr:T.message??"",exitCode:1};D=P.message;let H=zt({version:2,entries:u.entries}).sort();return D+=`
473
473
  # Conflicts:
474
- ${D.map(K=>`# ${K}`).join(`
474
+ ${H.map(W=>`# ${W}`).join(`
475
475
  `)}
476
- `,await Me(e,"MERGE_MSG",A),await Me(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
476
+ `,await Me(e,"MERGE_MSG",D),await Me(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
477
477
  `)}
478
- `,stderr:"",exitCode:1}}await be(e,"MERGE_MSG");let p=m.mergedTreeHash,g=await hn(e,o);if(M(g))return g;let w=await nt(e,o);if(M(w))return w;let b=a??await pr(e,r,l),k={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},R=await i?.hooks?.mergeMsg?.(k);if(fe(R))return{stdout:"",stderr:R.message??"",exitCode:1};b=k.message;let C=await i?.hooks?.preMergeCommit?.({repo:e,message:b,treeHash:p,headHash:t,theirsHash:n});if(fe(C))return{stdout:"",stderr:C.message??"",exitCode:1};let E=await yt(e,p,[t,n],g,w,b),y=f?.type==="symbolic"?f.target:"HEAD";await se(e,o,y,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 x=await gn(e,c.tree,p);return{stdout:`${u.messages.length>0?`${u.messages.join(`
478
+ `,stderr:"",exitCode:1}}await be(e,"MERGE_MSG");let p=m.mergedTreeHash,g=await un(e,o);if(j(g))return g;let w=await tt(e,o);if(j(w))return w;let b=a??await pr(e,r,l),y={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},x=await i?.hooks?.mergeMsg?.(y);if(fe(x))return{stdout:"",stderr:x.message??"",exitCode:1};b=y.message;let k=await i?.hooks?.preMergeCommit?.({repo:e,message:b,treeHash:p,headHash:t,theirsHash:n});if(fe(k))return{stdout:"",stderr:k.message??"",exitCode:1};let R=await yt(e,p,[t,n],g,w,b),E=f?.type==="symbolic"?f.target:"HEAD";await ne(e,o,E,t,R,`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:R});let C=await pn(e,c.tree,p);return{stdout:`${u.messages.length>0?`${u.messages.join(`
479
479
  `)}
480
480
  `:""}Merge made by the 'ort' strategy.
481
- ${x}`,stderr:"",exitCode:0}}async function _g(e,t,n){let r=[];for await(let o of _t(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: ${In(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
481
+ ${C}`,stderr:"",exitCode:0}}async function _g(e,t,n){let r=[];for await(let o of _t(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: ${On(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
482
482
  `))r.push(` ${i}`);r.push("")}return r.join(`
483
- `)}async function Fg(e,t,n,r,o,s,i){let a=await j(e,t),c=await Q(e),f=await xe(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await qt(e,t,n),h=d.length>0&&d[0]===t,u=h?`Updating ${Z(t)}..${Z(n)}
484
- `:"",m=await ks(e,t,n,l),p=await Sn(e,m,a.tree,{labels:l,errorExitCode:h?1:2,operationName:"merge",skipStagedChangeCheck:h});if(!p.ok){await be(e,"MERGE_MSG"),!h&&p.failureKind==="staged"&&c?.type==="symbolic"&&await se(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=p;return h&&(E.stderr=E.stderr.replace(/Merge with strategy ort failed\.\n$/,"")),u&&(E.stdout=u+E.stdout),E}let g;if(i?g=`Squashed commit of the following:
483
+ `)}async function Fg(e,t,n,r,o,s,i){let a=await G(e,t),c=await Q(e),f=await xe(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await qt(e,t,n),h=d.length>0&&d[0]===t,u=h?`Updating ${Z(t)}..${Z(n)}
484
+ `:"",m=await Rs(e,t,n,l),p=await In(e,m,a.tree,{labels:l,errorExitCode:h?1:2,operationName:"merge",skipStagedChangeCheck:h});if(!p.ok){await be(e,"MERGE_MSG"),!h&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let R=p;return h&&(R.stderr=R.stderr.replace(/Merge with strategy ort failed\.\n$/,"")),u&&(R.stdout=u+R.stdout),R}let g;if(i?g=`Squashed commit of the following:
485
485
 
486
486
  ${i}`:g=`Squashed commit of the following:
487
487
 
488
- ${await _g(e,t,n)}`,await Me(e,"SQUASH_MSG",g),m.conflicts.length>0){let y=`
488
+ ${await _g(e,t,n)}`,await Me(e,"SQUASH_MSG",g),m.conflicts.length>0){let E=`
489
489
  # Conflicts:
490
- ${Kt({version:2,entries:m.entries}).sort().map(A=>`# ${A}`).join(`
490
+ ${zt({version:2,entries:m.entries}).sort().map(D=>`# ${D}`).join(`
491
491
  `)}
492
- `,x=await $e(e,"MERGE_MSG");return await Me(e,"MERGE_MSG",(x??"")+y),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
492
+ `,C=await $e(e,"MERGE_MSG");return await Me(e,"MERGE_MSG",(C??"")+E),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
493
493
  `)}
494
- `,stderr:"",exitCode:1}}let w=p.mergedTreeHash,b=await gn(e,a.tree,w),k=m.messages.length>0?`${m.messages.join(`
494
+ `,stderr:"",exitCode:1}}let w=p.mergedTreeHash,b=await pn(e,a.tree,w),y=m.messages.length>0?`${m.messages.join(`
495
495
  `)}
496
496
  `:"";return{stdout:`${h?`${u}${i?"Fast-forward (no commit created; -m option ignored)":"Fast-forward"}
497
- `:""}${k}Squash commit -- not updating HEAD
497
+ `:""}${y}Squash commit -- not updating HEAD
498
498
  ${h?b:""}`,stderr:h?"":`Automatic merge went well; stopped before committing as requested
499
- `,exitCode:0}}async function Ug(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return T("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=$n(o,"Committing");if(s)return s;let i=await Qe(e);if(M(i))return i;let a=await j(e,i),c=await $e(e,"MERGE_MSG");if(c)c=It(c);else{let x=await Q(e),$=x?.type==="symbolic"?Pe(x.target):"HEAD";c=await pr(e,"unknown",$)}let f=Ne(o),l=await Fe(e,f),d=await hn(e,t);if(M(d))return d;let h=await nt(e,t);if(M(h))return h;let u=Nt(c),m={repo:e,message:u,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(m);if(fe(p))return{stdout:"",stderr:p.message??"",exitCode:1};u=m.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:u,treeHash:l,headHash:i,theirsHash:r});if(fe(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await yt(e,l,[i,r],d,h,u);await hs(e);let b=await Q(e),k=ue(u),R=b?.type==="symbolic"?b.target:"HEAD";await se(e,t,R,i,w,`commit (merge): ${k}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let C=await gn(e,a.tree,l),E=b?.type==="symbolic"?Pe(b.target):"detached HEAD";return{stdout:`${Lt(E,w,c)}
500
- ${C}`,stderr:"",exitCode:0}}async function Bg(e,t){return zn(e,t,{operationRef:"MERGE_HEAD",noOpError:T("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:hs})}oe();Ce();pe();tt();function ld(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:S().alias("f").describe("Force renaming even if target exists"),"dry-run":S().alias("n").describe("Do nothing; only show what would happen"),skip:S().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ve(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
501
- `);let f=c[c.length-1],l=c.slice(0,-1),d=Mt(r.cwd,f),h=rt(a,d);if(h.startsWith(".."))return T(`'${f}' is outside repository at '${a}'`);let u=await z(s),m=await r.fs.exists(d),p=m&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return T(m?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let b=Mt(r.cwd,w),k=rt(a,b);if(k.startsWith("..")){if(n.skip)continue;return T(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(b)){if(n.skip)continue;return T(`bad source, source=${k}, destination=${h}`)}let E=(await r.fs.stat(b)).isDirectory;if(!(E?u.entries.some(O=>O.path===k||O.path.startsWith(`${k}/`)):u.entries.some(O=>O.path===k&&O.stage===0))){let O=!E&&u.entries.some(D=>D.path===k&&D.stage>0);if(n.skip)continue;return T(O?`conflicted, source=${k}, destination=${h}`:`not under version control, source=${k}, destination=${h}`)}let x,$;if(p){let O=Vr(k);x=h===""||h==="."?O:`${h}/${O}`,$=v(d,O)}else x=h,$=d;if(await r.fs.exists($)&&!n.force)if((await r.fs.stat($)).isDirectory){let D=Vr(k);x=`${x}/${D}`,$=v($,D)}else{if(n.skip)continue;return T(`destination exists, source=${k}, destination=${x}`)}if(k===x){if(n.skip)continue;return T(`can not move directory into itself, source=${k}, destination=${x}`)}let P=rn($);if(!await r.fs.exists(P)){if(n.skip)continue;return T(`renaming '${k}' failed: No such file or directory`)}if(E){let O=`${k}/`,D=u.entries.filter(L=>L.path.startsWith(O)&&L.stage===0);for(let L of D){let K=L.path.slice(k.length),I=x+K,H=$+K;g.push({srcRel:L.path,dstRel:I,srcAbs:v(a,L.path),dstAbs:H})}}else g.push({srcRel:k,dstRel:x,srcAbs:b,dstAbs:$})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let b=rn(w.dstAbs);await r.fs.exists(b)||await r.fs.mkdir(b,{recursive:!0});let k=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,k),await r.fs.rm(w.srcAbs);let R=Ws(u,w.srcRel,0);if(R){u=ft(u,w.srcRel);let C={...R,path:w.dstRel};u=Pt(u,C)}}for(let w of g)await ar(r.fs,rn(w.srcAbs),a);return await ae(s,u),{stdout:"",stderr:"",exitCode:0}}})}oe();Be();Hn();Ce();ie();pe();pt();ze();we();oe();Be();Ce();ie();oe();ie();bn();sr();De();async function xa(e,t){let n=await ye(e,t);if(n.type!=="commit")return null;let r=an(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ye(e,r.parents[0]);f.type==="commit"&&(o=an(f.content).tree)}let s=await Ke(e,o,r.tree);if(s.length===0)return null;let i=Dn(),a=!1,c=[...s].sort((f,l)=>Te(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let u=await ye(e,f.oldHash);l=new TextDecoder().decode(u.content)}catch{}if(f.newHash)try{let u=await ye(e,f.newHash);d=new TextDecoder().decode(u.content)}catch{}let h=Ht({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(h)for(let u of h.split(`
499
+ `,exitCode:0}}async function Ug(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return S("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=Pn(o,"Committing");if(s)return s;let i=await Je(e);if(j(i))return i;let a=await G(e,i),c=await $e(e,"MERGE_MSG");if(c)c=It(c);else{let C=await Q(e),$=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await pr(e,"unknown",$)}let f=Ne(o),l=await Fe(e,f),d=await un(e,t);if(j(d))return d;let h=await tt(e,t);if(j(h))return h;let u=Nt(c),m={repo:e,message:u,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(m);if(fe(p))return{stdout:"",stderr:p.message??"",exitCode:1};u=m.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:u,treeHash:l,headHash:i,theirsHash:r});if(fe(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await yt(e,l,[i,r],d,h,u);await ms(e);let b=await Q(e),y=ue(u),x=b?.type==="symbolic"?b.target:"HEAD";await ne(e,t,x,i,w,`commit (merge): ${y}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await pn(e,a.tree,l),R=b?.type==="symbolic"?Pe(b.target):"detached HEAD";return{stdout:`${Lt(R,w,c)}
500
+ ${k}`,stderr:"",exitCode:0}}async function Bg(e,t){return qn(e,t,{operationRef:"MERGE_HEAD",noOpError:S("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:ms})}oe();Ce();me();et();function ld(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[K.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:I().alias("f").describe("Force renaming even if target exists"),"dry-run":I().alias("n").describe("Do nothing; only show what would happen"),skip:I().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
501
+ `);let f=c[c.length-1],l=c.slice(0,-1),d=Mt(r.cwd,f),h=nt(a,d);if(h.startsWith(".."))return S(`'${f}' is outside repository at '${a}'`);let u=await z(s),m=await r.fs.exists(d),p=m&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return S(m?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let b=Mt(r.cwd,w),y=nt(a,b);if(y.startsWith("..")){if(n.skip)continue;return S(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(b)){if(n.skip)continue;return S(`bad source, source=${y}, destination=${h}`)}let R=(await r.fs.stat(b)).isDirectory;if(!(R?u.entries.some(T=>T.path===y||T.path.startsWith(`${y}/`)):u.entries.some(T=>T.path===y&&T.stage===0))){let T=!R&&u.entries.some(H=>H.path===y&&H.stage>0);if(n.skip)continue;return S(T?`conflicted, source=${y}, destination=${h}`:`not under version control, source=${y}, destination=${h}`)}let C,$;if(p){let T=Yr(y);C=h===""||h==="."?T:`${h}/${T}`,$=v(d,T)}else C=h,$=d;if(await r.fs.exists($)&&!n.force)if((await r.fs.stat($)).isDirectory){let H=Yr(y);C=`${C}/${H}`,$=v($,H)}else{if(n.skip)continue;return S(`destination exists, source=${y}, destination=${C}`)}if(y===C){if(n.skip)continue;return S(`can not move directory into itself, source=${y}, destination=${C}`)}let P=rn($);if(!await r.fs.exists(P)){if(n.skip)continue;return S(`renaming '${y}' failed: No such file or directory`)}if(R){let T=`${y}/`,H=u.entries.filter(M=>M.path.startsWith(T)&&M.stage===0);for(let M of H){let W=M.path.slice(y.length),O=C+W,A=$+W;g.push({srcRel:M.path,dstRel:O,srcAbs:v(a,M.path),dstAbs:A})}}else g.push({srcRel:y,dstRel:C,srcAbs:b,dstAbs:$})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let b=rn(w.dstAbs);await r.fs.exists(b)||await r.fs.mkdir(b,{recursive:!0});let y=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,y),await r.fs.rm(w.srcAbs);let x=qs(u,w.srcRel,0);if(x){u=ct(u,w.srcRel);let k={...x,path:w.dstRel};u=Pt(u,k)}}for(let w of g)await ar(r.fs,rn(w.srcAbs),a);return await ae(s,u),{stdout:"",stderr:"",exitCode:0}}})}oe();Be();nr();Ce();ie();me();pt();Ke();we();oe();Be();Ce();ie();oe();ie();wn();sr();De();async function xa(e,t){let n=await ye(e,t);if(n.type!=="commit")return null;let r=on(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ye(e,r.parents[0]);f.type==="commit"&&(o=on(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=An(),a=!1,c=[...s].sort((f,l)=>Te(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let u=await ye(e,f.oldHash);l=new TextDecoder().decode(u.content)}catch{}if(f.newHash)try{let u=await ye(e,f.newHash);d=new TextDecoder().decode(u.content)}catch{}let h=Ht({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(h)for(let u of h.split(`
502
502
  `)){if(!u||u.startsWith("index "))continue;let p=(u.startsWith("@@")?u.replace(/^@@ [^@]* @@/,"@@ @@"):u).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
503
- `),a=!0)}}return a?i.hex():null}ze();we();De();Jt();tt();async function Wg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function dd(e){return e==="HEAD"?`HEAD is up to date.
503
+ `),a=!0)}}return a?i.hex():null}Ke();we();De();Jt();et();async function Wg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function dd(e){return e==="HEAD"?`HEAD is up to date.
504
504
  `:`Current branch ${e} is up to date.
505
- `}async function qg(e,t,n){if(!e.workTree)return null;let r=await de(e,t),o=new Map(Ne(n).map(a=>[a.path,a])),s=new Set(await st(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=fo(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
506
- `)}return null}async function zg(e,t,n,r){if(!e.workTree)return null;let o=await de(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await st(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:`${fo(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
507
- `,exitCode:128}:null}async function ud(e,t,n){if(!e.workTree)return null;let r=new Map(Ne(t).map(i=>[i.path,i])),o=new Set(await st(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 hd(e,t){return`error: The following untracked working tree files would be overwritten by merge:
505
+ `}async function qg(e,t,n){if(!e.workTree)return null;let r=await de(e,t),o=new Map(Ne(n).map(a=>[a.path,a])),s=new Set(await rt(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=fo(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
506
+ `)}return null}async function Kg(e,t,n,r){if(!e.workTree)return null;let o=await de(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await rt(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:`${fo(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
507
+ `,exitCode:128}:null}async function ud(e,t,n){if(!e.workTree)return null;let r=new Map(Ne(t).map(i=>[i.path,i])),o=new Set(await rt(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 hd(e,t){return`error: The following untracked working tree files would be overwritten by merge:
508
508
  ${e.map(r=>` ${r}`).join(`
509
509
  `)}
510
510
  Please move or remove them before you merge.
@@ -518,20 +518,20 @@ hint: edit the todo list first:
518
518
  hint:
519
519
  hint: git rebase --edit-todo
520
520
  hint: git rebase --continue
521
- `}async function Ca(e,t,n,r,o,s){await se(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await se(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await se(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Zo(e,t,n,r){let o=await j(e,t),s=await qg(e,o.tree,n);if(s)return s;let i=await Pn(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps)),r!=="detached HEAD"?await J(e,r,t):await J(e,"HEAD",t),null}async function Pa(e,t,n,r,o,s,i,a,c){let f=r.startsWith("refs/heads/")?Pe(r):"HEAD",l=await z(e),d=Kt(l).sort();if(d.length>0)return{stdout:d.map(P=>`${P}: needs merge
521
+ `}async function Ca(e,t,n,r,o,s){await ne(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ne(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ne(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Zo(e,t,n,r){let o=await G(e,t),s=await qg(e,o.tree,n);if(s)return s;let i=await Cn(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps)),r!=="detached HEAD"?await J(e,r,t):await J(e,"HEAD",t),null}async function Pa(e,t,n,r,o,s,i,a,c){let f=r.startsWith("refs/heads/")?Pe(r):"HEAD",l=await z(e),d=zt(l).sort();if(d.length>0)return{stdout:d.map(P=>`${P}: needs merge
522
522
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
523
523
  error: additionally, your index contains uncommitted changes.
524
524
  error: Please commit or stash them.
525
- `,exitCode:1};let h=await j(e,n),u=await de(e,h.tree);if(e.workTree){let P=qn(l,u),D=(await wt(e,l)).some(L=>L.status==="modified"||L.status==="deleted");if(P||D){let L=[];return D&&L.push("error: cannot rebase: You have unstaged changes."),P&&(D?L.push("error: additionally, your index contains uncommitted changes."):L.push("error: cannot rebase: Your index contains uncommitted changes.")),L.push("error: Please commit or stash them."),_(`${L.join(`
525
+ `,exitCode:1};let h=await G(e,n),u=await de(e,h.tree);if(e.workTree){let P=Wn(l,u),H=(await wt(e,l)).some(M=>M.status==="modified"||M.status==="deleted");if(P||H){let M=[];return H&&M.push("error: cannot rebase: You have unstaged changes."),P&&(H?M.push("error: additionally, your index contains uncommitted changes."):M.push("error: cannot rebase: Your index contains uncommitted changes.")),M.push("error: Please commit or stash them."),_(`${M.join(`
526
526
  `)}
527
527
  `)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?f:null});if(fe(m))return{stdout:"",stderr:m.message??"",exitCode:1};let p=await xf(e,o,n),g=p.right;if(g.length===0){if(s!==n){let P=await Zo(e,s,l,r);return P||(await Ca(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
528
- `,exitCode:0})}return{stdout:dd(f),stderr:"",exitCode:0}}let w=[],b=[];if(c?.reapplyCherryPicks)b.push(...g);else{let P=p.left,O=new Set;for(let D of P){let L=await xa(e,D.hash);L&&O.add(L)}if(O.size>0)for(let D of g){let L=await xa(e,D.hash);L&&O.has(L)?w.push(`warning: skipped previously applied commit ${Z(D.hash)}`):b.push(D)}else b.push(...g)}let k="";if(w.length>0&&(k=`${w.join(`
528
+ `,exitCode:0})}return{stdout:dd(f),stderr:"",exitCode:0}}let w=[],b=[];if(c?.reapplyCherryPicks)b.push(...g);else{let P=p.left,T=new Set;for(let H of P){let M=await xa(e,H.hash);M&&T.add(M)}if(T.size>0)for(let H of g){let M=await xa(e,H.hash);M&&T.has(M)?w.push(`warning: skipped previously applied commit ${Z(H.hash)}`):b.push(H)}else b.push(...g)}let y="";if(w.length>0&&(y=`${w.join(`
529
529
  `)}
530
530
  hint: use --reapply-cherry-picks to include skipped commits
531
531
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
532
- `),b.length===0){if(s!==n){let P=await Zo(e,s,l,r);if(P)return P.stderr=k+P.stderr,P;await Ca(e,t,n,s,r,i)}return{stdout:"",stderr:`${k}Successfully rebased and updated ${r}.
533
- `,exitCode:0}}let R=b.map(P=>({hash:P.hash,subject:ue(P.commit.message)})),C=s,E=0;for(let P of R){let O=await j(e,P.hash);if(O.parents.length>1||O.parents.length===0||O.parents[0]!==C)break;C=P.hash,E++}let y=R.splice(0,E);if(R.length===0){if(C===n)return{stdout:dd(f),stderr:k,exitCode:0};let P=await Zo(e,C,l,r);return P?(P.stderr=k+P.stderr,P):(await Ca(e,t,n,C,r,i),{stdout:"",stderr:`${k}Successfully rebased and updated ${r}.
534
- `,exitCode:0})}let x=await Zo(e,C,l,"detached HEAD");if(x)return x.stderr=k+x.stderr,x;await me(e,"CHERRY_PICK_HEAD"),await me(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await se(e,t,"HEAD",n,C,`rebase (start): checkout ${i}`);let $={headName:r,origHead:n,onto:s,todo:R,done:y,msgnum:E,end:E+R.length};await Ki(e,$),await J(e,"ORIG_HEAD",n);let A=await $a(e,t);return k&&(A.stderr=k+A.stderr),A}function md(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:Y.string().describe("Starting point at which to create new commits"),abort:S().describe("Abort the current rebase operation"),continue:S().describe("Continue the rebase after conflict resolution"),skip:S().describe("Skip the current patch and continue"),"reapply-cherry-picks":S().describe("Do not skip commits that are cherry-pick equivalents"),"no-reapply-cherry-picks":S().describe("Skip commits that are cherry-pick equivalents (default)")},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 Yg(s,r.env);if(n.continue)return Xg(s,r.env);if(n.skip)return Zg(s,r.env);let i=n.upstream;if(!i)return T("no upstream configured and no upstream argument given");if(await Ut(s))return T(`It seems that there is already a rebase-merge directory, and
532
+ `),b.length===0){if(s!==n){let P=await Zo(e,s,l,r);if(P)return P.stderr=y+P.stderr,P;await Ca(e,t,n,s,r,i)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
533
+ `,exitCode:0}}let x=b.map(P=>({hash:P.hash,subject:ue(P.commit.message)})),k=s,R=0;for(let P of x){let T=await G(e,P.hash);if(T.parents.length>1||T.parents.length===0||T.parents[0]!==k)break;k=P.hash,R++}let E=x.splice(0,R);if(x.length===0){if(k===n)return{stdout:dd(f),stderr:y,exitCode:0};let P=await Zo(e,k,l,r);return P?(P.stderr=y+P.stderr,P):(await Ca(e,t,n,k,r,i),{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
534
+ `,exitCode:0})}let C=await Zo(e,k,l,"detached HEAD");if(C)return C.stderr=y+C.stderr,C;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await ne(e,t,"HEAD",n,k,`rebase (start): checkout ${i}`);let $={headName:r,origHead:n,onto:s,todo:x,done:E,msgnum:R,end:R+x.length};await zi(e,$),await J(e,"ORIG_HEAD",n);let D=await $a(e,t);return y&&(D.stderr=y+D.stderr),D}function md(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[K.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Y.string().describe("Starting point at which to create new commits"),abort:I().describe("Abort the current rebase operation"),continue:I().describe("Continue the rebase after conflict resolution"),skip:I().describe("Skip the current patch and continue"),"reapply-cherry-picks":I().describe("Do not skip commits that are cherry-pick equivalents"),"no-reapply-cherry-picks":I().describe("Skip commits that are cherry-pick equivalents (default)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.abort)return Yg(s,r.env);if(n.continue)return Xg(s,r.env);if(n.skip)return Zg(s,r.env);let i=n.upstream;if(!i)return S("no upstream configured and no upstream argument given");if(await Ut(s))return S(`It seems that there is already a rebase-merge directory, and
535
535
  I wonder if you are in the middle of another rebase. If that is the
536
536
  case, please try
537
537
  git rebase (--continue | --abort | --skip)
@@ -539,10 +539,10 @@ If that is not the case, please
539
539
  rm -fr ".git/rebase-merge"
540
540
  and run me again. I am stopping in case you still have something
541
541
  valuable there.
542
- `);let a=await Qe(s);if(M(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Le(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,h,u=n.onto;if(u){let p=await Le(s,u,`Does not point to a valid commit: '${u}'`);if(M(p))return p;h=p.hash}else h=d;let m=!!n["reapply-cherry-picks"];return Pa(s,r.env,a,f,d,h,i,t,m?{reapplyCherryPicks:!0}:void 0)}})}async function $a(e,t){let n=[],r=[];for(;;){let o=await kt(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 Rf(e);let i=await Kg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await kt(e);a&&(a.todo=[s,...a.todo],await Ki(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 Vg(e,n,t)}async function Kg(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 X(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
543
- `};if(s&&s===a){let L=await z(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
544
- `};let K=await qe(e,i.tree),I=await qe(e,o.tree),H=new Map(K.map(N=>[N.path,N.hash])),G=new Map;for(let N of I){let ne=H.get(N.path);(!ne||ne!==N.hash)&&G.set(N.path,N.hash)}let F=await ud(e,L,G);if(F)return await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),{conflict:!0,stdout:"",stderr:hd(F,t),rescheduleCurrent:!0};let U=await Pn(e,o.tree,L);return U.success&&(await ae(e,{version:2,entries:U.newEntries}),await je(e,U.worktreeOps)),await Nn(e,r),await se(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=Z(r),d=ue(o.message),h=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:h},m=await zt(e,f,c.tree,o.tree,u),p=await z(e),[g,w,b]=await Promise.all([qe(e,c.tree),f?qe(e,f):Promise.resolve([]),qe(e,o.tree)]),k=new Set;for(let L of w)k.add(L.path);for(let L of g)k.add(L.path);for(let L of b)k.add(L.path);let R=p.entries.filter(L=>!k.has(L.path)),C=[...m.entries,...R];C.sort((L,K)=>Te(L.path,K.path)||L.stage-K.stage);let E={version:2,entries:C},y=C.filter(L=>L.stage===0),x=await Fe(e,y),$=new Map(g.map(L=>[L.path,L])),A=new Map;for(let L of y){let K=$.get(L.path);(!K||K.hash!==L.hash)&&A.set(L.path,L.hash)}for(let L of m.conflicts){if(L.reason==="content"||L.reason==="add-add"){A.set(L.path,null);continue}if(L.reason==="delete-modify"){let K=m.entries.filter(G=>G.path===L.path&&G.stage>0),I=K.find(G=>G.stage===2),H=K.find(G=>G.stage===3);H&&!I&&A.set(L.path,H.hash)}}let P=await ud(e,p,A);if(P)return await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),{conflict:!0,stdout:"",stderr:hd(P,t),rescheduleCurrent:!0};if(await ae(e,E),e.workTree){let L=await Wn(e,c.tree,m.resultTree,p);L.success&&await je(e,L.worktreeOps)}if(m.conflicts.length>0){await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),await Me(e,"MERGE_MSG",o.message),await Me(e,"rebase-merge/message",o.message);let L=m.messages.join(`
545
- `);return{conflict:!0,stdout:L?`${L}
542
+ `);let a=await Je(s);if(j(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Le(s,i,`invalid upstream '${i}'`);if(j(l))return l;let d=l.hash,h,u=n.onto;if(u){let p=await Le(s,u,`Does not point to a valid commit: '${u}'`);if(j(p))return p;h=p.hash}else h=d;let m=!!n["reapply-cherry-picks"];return Pa(s,r.env,a,f,d,h,i,t,m?{reapplyCherryPicks:!0}:void 0)}})}async function $a(e,t){let n=[],r=[];for(;;){let o=await kt(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 Rf(e);let i=await zg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await kt(e);a&&(a.todo=[s,...a.todo],await zi(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 Vg(e,n,t)}async function zg(e,t,n){let r=t.hash,o=await G(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await G(e,s):null,a=await X(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
543
+ `};if(s&&s===a){let M=await z(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
544
+ `};let W=await qe(e,i.tree),O=await qe(e,o.tree),A=new Map(W.map(N=>[N.path,N.hash])),L=new Map;for(let N of O){let re=A.get(N.path);(!re||re!==N.hash)&&L.set(N.path,N.hash)}let F=await ud(e,M,L);if(F)return await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),{conflict:!0,stdout:"",stderr:hd(F,t),rescheduleCurrent:!0};let U=await Cn(e,o.tree,M);return U.success&&(await ae(e,{version:2,entries:U.newEntries}),await je(e,U.worktreeOps)),await Ln(e,r),await ne(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await G(e,a),f=i?i.tree:null,l=Z(r),d=ue(o.message),h=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:h},m=await Kt(e,f,c.tree,o.tree,u),p=await z(e),[g,w,b]=await Promise.all([qe(e,c.tree),f?qe(e,f):Promise.resolve([]),qe(e,o.tree)]),y=new Set;for(let M of w)y.add(M.path);for(let M of g)y.add(M.path);for(let M of b)y.add(M.path);let x=p.entries.filter(M=>!y.has(M.path)),k=[...m.entries,...x];k.sort((M,W)=>Te(M.path,W.path)||M.stage-W.stage);let R={version:2,entries:k},E=k.filter(M=>M.stage===0),C=await Fe(e,E),$=new Map(g.map(M=>[M.path,M])),D=new Map;for(let M of E){let W=$.get(M.path);(!W||W.hash!==M.hash)&&D.set(M.path,M.hash)}for(let M of m.conflicts){if(M.reason==="content"||M.reason==="add-add"){D.set(M.path,null);continue}if(M.reason==="delete-modify"){let W=m.entries.filter(L=>L.path===M.path&&L.stage>0),O=W.find(L=>L.stage===2),A=W.find(L=>L.stage===3);A&&!O&&D.set(M.path,A.hash)}}let P=await ud(e,p,D);if(P)return await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),{conflict:!0,stdout:"",stderr:hd(P,t),rescheduleCurrent:!0};if(await ae(e,R),e.workTree){let M=await Bn(e,c.tree,m.resultTree,p);M.success&&await je(e,M.worktreeOps)}if(m.conflicts.length>0){await J(e,"REBASE_HEAD",r),await yo(e,r,o.author),await Me(e,"MERGE_MSG",o.message),await Me(e,"rebase-merge/message",o.message);let M=m.messages.join(`
545
+ `);return{conflict:!0,stdout:M?`${M}
546
546
  `:"",stderr:`error: could not apply ${l}... ${t.subject}
547
547
  hint: Resolve all conflicts manually, mark them as resolved with
548
548
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
@@ -550,13 +550,13 @@ hint: You can instead skip this commit: run "git rebase --skip".
550
550
  hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
551
551
  hint: Disable this message with "git config set advice.mergeConflict false"
552
552
  Could not apply ${l}... # ${t.subject}
553
- `}}if(x===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
554
- `};let O=await nt(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let D=await yt(e,x,[a],o.author,O,o.message);return await se(e,n,"HEAD",a,D,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Vg(e,t,n){let r=await kt(e);if(!r)return T("no rebase in progress");let o=await X(e);if(!o)return T("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await J(e,r.headName,o),await Ze(e,"HEAD",r.headName),await Et(e),await se(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await se(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
555
- `;return await me(e,"REBASE_HEAD"),await dr(e),await Vi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Yg(e,t){let n=await kt(e);if(!n)return T("no rebase in progress");let r=await X(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await zg(e,s.tree,i,o);if(a)return a;let c=await Pn(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await je(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await J(e,n.headName,o),await Ze(e,"HEAD",n.headName),await Et(e)):await Nn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await se(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await me(e,"REBASE_HEAD"),await dr(e),await Vi(e),{stdout:"",stderr:"",exitCode:0}}async function Xg(e,t){let n="";if(!await kt(e))return T("no rebase in progress");let o=await z(e);if(Gt(o))return _(`error: Committing is not possible because you have unmerged files.
553
+ `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
554
+ `};let T=await tt(e,n);if(j(T))return{conflict:!0,stdout:"",stderr:T.stderr};let H=await yt(e,C,[a],o.author,T,o.message);return await ne(e,n,"HEAD",a,H,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Vg(e,t,n){let r=await kt(e);if(!r)return S("no rebase in progress");let o=await X(e);if(!o)return S("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await J(e,r.headName,o),await Ze(e,"HEAD",r.headName),await Et(e),await ne(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ne(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
555
+ `;return await he(e,"REBASE_HEAD"),await dr(e),await Vi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Yg(e,t){let n=await kt(e);if(!n)return S("no rebase in progress");let r=await X(e),o=n.origHead,s=await G(e,o),i=await z(e),a=await Kg(e,s.tree,i,o);if(a)return a;let c=await Cn(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await je(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await J(e,n.headName,o),await Ze(e,"HEAD",n.headName),await Et(e)):await Ln(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ne(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await he(e,"REBASE_HEAD"),await dr(e),await Vi(e),{stdout:"",stderr:"",exitCode:0}}async function Xg(e,t){let n="";if(!await kt(e))return S("no rebase in progress");let o=await z(e);if(Gt(o))return _(`error: Committing is not possible because you have unmerged files.
556
556
  hint: Fix them up in the work tree, and then use 'git add <file>'
557
557
  hint: as appropriate to mark resolution and make a commit.
558
558
  fatal: Exiting because of an unresolved conflict.
559
- `,128);let s=await B(e,"REBASE_HEAD");if(s){let a=await X(e);if(!a)return T("Cannot read HEAD");let c=await j(e,a),f=Ne(o),l=await Fe(e,f),d=l!==c.tree,h=await $e(e,"rebase-merge/message")!==null;if(d&&!h)return _(`error: you have staged changes in your working tree
559
+ `,128);let s=await B(e,"REBASE_HEAD");if(s){let a=await X(e);if(!a)return S("Cannot read HEAD");let c=await G(e,a),f=Ne(o),l=await Fe(e,f),d=l!==c.tree,h=await $e(e,"rebase-merge/message")!==null;if(d&&!h)return _(`error: you have staged changes in your working tree
560
560
  If these changes are meant to be squashed into the previous commit, run:
561
561
 
562
562
  git commit --amend
@@ -569,23 +569,23 @@ In both cases, once you're done, continue with:
569
569
 
570
570
  git rebase --continue
571
571
 
572
- `);if(d){let u=await j(e,s),m=await B(e,"CHERRY_PICK_HEAD"),p=m?await j(e,m):u,g;g=await $e(e,"rebase-merge/message")??await $e(e,"MERGE_MSG")??void 0,g&&(g=It(g)),g||(g=u.message);let w=await nt(e,t);if(M(w))return w;let b=Nt(g),k=[a],R=await B(e,"MERGE_HEAD");R&&k.push(R);let C=await yt(e,l,k,p.author,w,b);R&&(await me(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let E=ue(b);await se(e,t,"HEAD",a,C,`rebase (continue): ${E}`);let y=await Wg(e),x=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,$=await pn(e,c.tree,l,p.author,w,x);n=`${Lt(y,C,b)}
573
- ${$}`}await me(e,"REBASE_HEAD"),await me(e,"CHERRY_PICK_HEAD"),await me(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"rebase-merge/message")}let i=await $a(e,t);return n&&(i.stdout=n+i.stdout),i}async function Zg(e,t){if(!await kt(e))return T("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
572
+ `);if(d){let u=await G(e,s),m=await B(e,"CHERRY_PICK_HEAD"),p=m?await G(e,m):u,g;g=await $e(e,"rebase-merge/message")??await $e(e,"MERGE_MSG")??void 0,g&&(g=It(g)),g||(g=u.message);let w=await tt(e,t);if(j(w))return w;let b=Nt(g),y=[a],x=await B(e,"MERGE_HEAD");x&&y.push(x);let k=await yt(e,l,y,p.author,w,b);x&&(await he(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let R=ue(b);await ne(e,t,"HEAD",a,k,`rebase (continue): ${R}`);let E=await Wg(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,$=await mn(e,c.tree,l,p.author,w,C);n=`${Lt(E,k,b)}
573
+ ${$}`}await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"rebase-merge/message")}let i=await $a(e,t);return n&&(i.stdout=n+i.stdout),i}async function Zg(e,t){if(!await kt(e))return S("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
574
574
  fatal: could not discard worktree changes
575
- `,exitCode:128};let o=await j(e,r),s=await z(e),i=await Pn(e,o.tree,s);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps)),await me(e,"REBASE_HEAD"),await me(e,"CHERRY_PICK_HEAD"),await me(e,"REVERT_HEAD"),await me(e,"MERGE_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"rebase-merge/message"),$a(e,t)}function pd(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:S().alias("r").describe("Rebase instead of merge"),noRebase:S().describe("Merge instead of rebase"),ffOnly:S().describe("Only fast-forward"),noFf:S().describe("Create a merge commit even for fast-forwards"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:S().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 T("--depth and --unshallow cannot be used together");if(n.unshallow&&!await jo(s))return T("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=Rs);let a=await Qe(s);if(M(a))return a;let c=await Q(s),f=await z(s);if(Gt(f))return{stdout:"",stderr:`error: Pulling is not possible because you have unmerged files.
575
+ `,exitCode:128};let o=await G(e,r),s=await z(e),i=await Cn(e,o.tree,s);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps)),await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await he(e,"MERGE_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"rebase-merge/message"),$a(e,t)}function pd(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[K.string().name("remote").describe("Remote to pull from").optional(),K.string().name("branch").describe("Remote branch").optional()],options:{rebase:I().alias("r").describe("Rebase instead of merge"),noRebase:I().describe("Merge instead of rebase"),ffOnly:I().describe("Only fast-forward"),noFf:I().describe("Create a merge commit even for fast-forwards"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:I().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return S("--depth and --unshallow cannot be used together");if(n.unshallow&&!await jo(s))return S("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=xs);let a=await Je(s);if(j(a))return a;let c=await Q(s),f=await z(s);if(Gt(f))return{stdout:"",stderr:`error: Pulling is not possible because you have unmerged files.
576
576
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
577
577
  hint: as appropriate to mark resolution and make a commit.
578
578
  fatal: Exiting because of an unresolved conflict.
579
- `,exitCode:128};let l=n.remote,d=n.branch,h=null;if(!l&&c?.type==="symbolic"){let le=c.target.startsWith("refs/heads/")?c.target.slice(11):c.target,ht=(await he(s))[`branch "${le}"`];ht?(l=ht.remote||"origin",!d&&ht.merge&&(d=ht.merge.startsWith("refs/heads/")?ht.merge.slice(11):ht.merge)):d||(h=le)}l=l||"origin";let u=await Jg(s,n,c),m;try{m=await Ur(s,l,r.env)}catch(le){let Ge=le instanceof Error?le.message:"";if(Ge.startsWith("network"))return{stdout:"",stderr:`fatal: ${Ge}
579
+ `,exitCode:128};let l=n.remote,d=n.branch,h=null;if(!l&&c?.type==="symbolic"){let le=c.target.startsWith("refs/heads/")?c.target.slice(11):c.target,ht=(await pe(s))[`branch "${le}"`];ht?(l=ht.remote||"origin",!d&&ht.merge&&(d=ht.merge.startsWith("refs/heads/")?ht.merge.slice(11):ht.merge)):d||(h=le)}l=l||"origin";let u=await Jg(s,n,c),m;try{m=await Br(s,l,r.env)}catch(le){let Ge=le instanceof Error?le.message:"";if(Ge.startsWith("network"))return{stdout:"",stderr:`fatal: ${Ge}
580
580
  `,exitCode:1};throw le}if(!m)return{stdout:"",stderr:`fatal: '${l}' does not appear to be a git repository
581
- `,exitCode:1};let{transport:p,config:g}=m,w=d??null,b=await t?.hooks?.prePull?.({repo:s,remote:l,branch:w});if(fe(b))return{stdout:"",stderr:b.message??"",exitCode:1};let k=yr(g.fetchRefspec),R=await p.advertiseRefs(),E=(await ge(s)).map(le=>le.hash),y=await B(s,"HEAD");y&&E.push(y);let x=[],$=new Set,A=[];for(let le of R){if(le.name==="HEAD")continue;let Ge=Os(k,le.name);Ge!==null&&(A.push({remote:le,localRef:Ge}),$.has(le.hash)||($.add(le.hash),x.push(le.hash)))}let P=new Set(E),O=x.filter(le=>!P.has(le)),D,L=i!==void 0?await Gr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:L});let K=O.length>0?O:D?x:[];if(K.length>0){let le=await p.fetch(K,E,D);le.shallowUpdates&&await Lr(s,le.shallowUpdates,L)}let I=await sn(s,r.env),H=[];for(let le of A){let Ge=await B(s,le.localRef);H.push(Ge),await J(s,le.localRef,le.remote.hash),await Je(s,le.localRef,{oldHash:Ge??te,newHash:le.remote.hash,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:Ge?"pull":"pull: storing head"})}let G=lo(A.map((le,Ge)=>({...le,oldHash:H[Ge]})),Ln,Z),F=G.length>0?`From ${g.url}
582
- ${vr(G,10)}`:"";if(await Js(s,l,R,p.headTarget),c?.type!=="symbolic"&&!d)return{stdout:"",stderr:F+`You are not currently on a branch.
581
+ `,exitCode:1};let{transport:p,config:g}=m,w=d??null,b=await t?.hooks?.prePull?.({repo:s,remote:l,branch:w});if(fe(b))return{stdout:"",stderr:b.message??"",exitCode:1};let y=yr(g.fetchRefspec),x=await p.advertiseRefs(),R=(await ge(s)).map(le=>le.hash),E=await B(s,"HEAD");E&&R.push(E);let C=[],$=new Set,D=[];for(let le of x){if(le.name==="HEAD")continue;let Ge=Is(y,le.name);Ge!==null&&(D.push({remote:le,localRef:Ge}),$.has(le.hash)||($.add(le.hash),C.push(le.hash)))}let P=new Set(R),T=C.filter(le=>!P.has(le)),H,M=i!==void 0?await Lr(s):void 0;i!==void 0&&(H={depth:i,existingShallows:M});let W=T.length>0?T:H?C:[];if(W.length>0){let le=await p.fetch(W,R,H);le.shallowUpdates&&await Nr(s,le.shallowUpdates,M)}let O=await vn(s,r.env),A=[];for(let le of D){let Ge=await B(s,le.localRef);A.push(Ge),await J(s,le.localRef,le.remote.hash),await ft(s,le.localRef,{oldHash:Ge??te,newHash:le.remote.hash,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Ge?"pull":"pull: storing head"})}let L=lo(D.map((le,Ge)=>({...le,oldHash:A[Ge]})),Gn,Z),F=L.length>0?`From ${g.url}
582
+ ${Hr(L,10)}`:"";if(await Sr(s,l,x,p.headTarget),c?.type!=="symbolic"&&!d)return{stdout:"",stderr:F+`You are not currently on a branch.
583
583
  Please specify which branch you want to merge with.
584
584
  See git-pull(1) for details.
585
585
 
586
586
  git pull <remote> <branch>
587
587
 
588
- `,exitCode:1};if(h){let le=await he(s),Ge=[];for(let kr of Object.keys(le)){let _a=kr.match(/^remote "(.+)"$/);_a?.[1]&&Ge.push(_a[1])}let ht=Ge.length===1?Ge[0]:"<remote>";return{stdout:"",stderr:F+`There is no tracking information for the current branch.
588
+ `,exitCode:1};if(h){let le=await pe(s),Ge=[];for(let kr of Object.keys(le)){let _a=kr.match(/^remote "(.+)"$/);_a?.[1]&&Ge.push(_a[1])}let ht=Ge.length===1?Ge[0]:"<remote>";return{stdout:"",stderr:F+`There is no tracking information for the current branch.
589
589
  Please specify which branch you want to merge with.
590
590
  See git-pull(1) for details.
591
591
 
@@ -595,11 +595,11 @@ If you wish to set tracking information for this branch you can do so with:
595
595
 
596
596
  git branch --set-upstream-to=${ht}/<branch> ${h}
597
597
 
598
- `,exitCode:1}}let U=null;if(d){let le=R.find(Ge=>Ge.name===`refs/heads/${d}`);if(le)U=le.hash;else return{stdout:"",stderr:F+`Your configuration specifies to merge with the ref 'refs/heads/${d}'
598
+ `,exitCode:1}}let U=null;if(d){let le=x.find(Ge=>Ge.name===`refs/heads/${d}`);if(le)U=le.hash;else return{stdout:"",stderr:F+`Your configuration specifies to merge with the ref 'refs/heads/${d}'
599
599
  from the remote, but no such ref was fetched.
600
- `,exitCode:1}}else{let le=R.find(Ge=>Ge.name==="HEAD");le&&(U=le.hash)}if(U&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${U} ${g.url}
601
- `),!U)return T("Could not determine remote HEAD");let N=U;if(await be(s,"MERGE_MSG"),a===N)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
602
- `,stderr:F,exitCode:0};if(u.useRebase){let le=c?.type==="symbolic"?c.target:"detached HEAD",Ge=d?`${l}/${d}`:l,ht=await Pa(s,r.env,a,le,N,N,Ge,t);if(ht.exitCode===0){let kr=await X(s);await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"rebase",commitHash:kr})}return{...ht,stderr:F+ht.stderr}}let ne=await qt(s,a,N),V=ne[0]??null;if(V===N)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
600
+ `,exitCode:1}}else{let le=x.find(Ge=>Ge.name==="HEAD");le&&(U=le.hash)}if(U&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${U} ${g.url}
601
+ `),!U)return S("Could not determine remote HEAD");let N=U;if(await be(s,"MERGE_MSG"),a===N)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
602
+ `,stderr:F,exitCode:0};if(u.useRebase){let le=c?.type==="symbolic"?c.target:"detached HEAD",Ge=d?`${l}/${d}`:l,ht=await Pa(s,r.env,a,le,N,N,Ge,t);if(ht.exitCode===0){let kr=await X(s);await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"rebase",commitHash:kr})}return{...ht,stderr:F+ht.stderr}}let re=await qt(s,a,N),V=re[0]??null;if(V===N)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
603
603
  `,stderr:F,exitCode:0};let{noFf:ee,ffOnly:ke,configured:_e}=u,ce=V===a;if(ke&&!ce)return{stdout:"",stderr:F+`hint: Diverging branches can't be fast-forwarded, you need to either:
604
604
  hint:
605
605
  hint: git merge --no-ff
@@ -623,24 +623,24 @@ hint: preference for all repositories. You can also pass --rebase, --no-rebase,
623
623
  hint: or --ff-only on the command line to override the configured default per
624
624
  hint: invocation.
625
625
  fatal: Need to specify how to reconcile divergent branches.
626
- `,exitCode:128};if(ne.length===0)return{stdout:"",stderr:F+`fatal: refusing to merge unrelated histories
627
- `,exitCode:128};if(ce&&!ee){let le=await Do(s,a,N);if(le.exitCode===0){let Ge=c?.type==="symbolic"?c.target:"HEAD",kr=`pull${ke?" --ff-only":""}: Fast-forward`;await Je(s,Ge,{oldHash:a,newHash:N,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:kr}),c?.type==="symbolic"&&await Je(s,"HEAD",{oldHash:a,newHash:N,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:kr}),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:N,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"fast-forward",commitHash:N})}return{...le,stderr:F+le.stderr}}let Ie=c?.type==="symbolic"?Pe(c.target):"HEAD",ut=N,Er=d||"HEAD",Ye=await xe(s,"merge.conflictstyle")??"merge",Wr={a:"HEAD",b:ut,conflictStyle:Ye},nr=await ks(s,a,N,Wr),Ma=await j(s,a),qr=await Sn(s,nr,Ma.tree,{labels:Wr,errorExitCode:2,operationName:"merge"});if(!qr.ok)return{stdout:qr.stdout,stderr:F+qr.stderr,exitCode:qr.exitCode};if(nr.conflicts.length>0){await J(s,"MERGE_HEAD",N),await J(s,"ORIG_HEAD",a);let le=await pr(s,Er,Ie,g.url),Ge=Kt({version:2,entries:nr.entries}).sort();return le+=`
626
+ `,exitCode:128};if(re.length===0)return{stdout:"",stderr:F+`fatal: refusing to merge unrelated histories
627
+ `,exitCode:128};if(ce&&!ee){let le=await Do(s,a,N);if(le.exitCode===0){let Ge=c?.type==="symbolic"?c.target:"HEAD",kr=`pull${ke?" --ff-only":""}: Fast-forward`;await ft(s,Ge,{oldHash:a,newHash:N,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:kr}),c?.type==="symbolic"&&await ft(s,"HEAD",{oldHash:a,newHash:N,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:kr}),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:N,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"fast-forward",commitHash:N})}return{...le,stderr:F+le.stderr}}let Ie=c?.type==="symbolic"?Pe(c.target):"HEAD",ut=N,Er=d||"HEAD",Xe=await xe(s,"merge.conflictstyle")??"merge",qr={a:"HEAD",b:ut,conflictStyle:Xe},tr=await Rs(s,a,N,qr),Ma=await G(s,a),Kr=await In(s,tr,Ma.tree,{labels:qr,errorExitCode:2,operationName:"merge"});if(!Kr.ok)return{stdout:Kr.stdout,stderr:F+Kr.stderr,exitCode:Kr.exitCode};if(tr.conflicts.length>0){await J(s,"MERGE_HEAD",N),await J(s,"ORIG_HEAD",a);let le=await pr(s,Er,Ie,g.url),Ge=zt({version:2,entries:tr.entries}).sort();return le+=`
628
628
  # Conflicts:
629
629
  ${Ge.map(ht=>`# ${ht}`).join(`
630
630
  `)}
631
- `,await Me(s,"MERGE_MSG",le),await Me(s,"MERGE_MODE",ee?"no-ff":""),{stdout:`${[...nr.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
631
+ `,await Me(s,"MERGE_MSG",le),await Me(s,"MERGE_MODE",ee?"no-ff":""),{stdout:`${[...tr.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
632
632
  `)}
633
- `,stderr:F,exitCode:1}}let Hs=qr.mergedTreeHash,ni=await hn(s,r.env);if(M(ni))return ni;let ri=await nt(s,r.env);if(M(ri))return ri;let As=await pr(s,Er,Ie,g.url),ja={repo:s,message:As,treeHash:Hs,headHash:a,theirsHash:N},Ga=await t?.hooks?.mergeMsg?.(ja);if(fe(Ga))return{stdout:"",stderr:Ga.message??"",exitCode:1};As=ja.message;let La=await t?.hooks?.preMergeCommit?.({repo:s,message:As,treeHash:Hs,headHash:a,theirsHash:N});if(fe(La))return{stdout:"",stderr:La.message??"",exitCode:1};let Ds=await yt(s,Hs,[a,N],ni,ri,As);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:N,strategy:"three-way",commitHash:Ds}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"three-way",commitHash:Ds});let Wd=c?.type==="symbolic"?c.target:"HEAD",Na=`pull${ee?" --no-ff":""}: Merge made by the 'ort' strategy.`;await Je(s,Wd,{oldHash:a,newHash:Ds,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:Na}),c?.type==="symbolic"&&await Je(s,"HEAD",{oldHash:a,newHash:Ds,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:Na});let qd=await gn(s,Ma.tree,Hs);return{stdout:`${nr.messages.length>0?`${nr.messages.join(`
633
+ `,stderr:F,exitCode:1}}let As=Kr.mergedTreeHash,ni=await un(s,r.env);if(j(ni))return ni;let ri=await tt(s,r.env);if(j(ri))return ri;let Ds=await pr(s,Er,Ie,g.url),ja={repo:s,message:Ds,treeHash:As,headHash:a,theirsHash:N},Ga=await t?.hooks?.mergeMsg?.(ja);if(fe(Ga))return{stdout:"",stderr:Ga.message??"",exitCode:1};Ds=ja.message;let La=await t?.hooks?.preMergeCommit?.({repo:s,message:Ds,treeHash:As,headHash:a,theirsHash:N});if(fe(La))return{stdout:"",stderr:La.message??"",exitCode:1};let Ms=await yt(s,As,[a,N],ni,ri,Ds);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:N,strategy:"three-way",commitHash:Ms}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"three-way",commitHash:Ms});let Wd=c?.type==="symbolic"?c.target:"HEAD",Na=`pull${ee?" --no-ff":""}: Merge made by the 'ort' strategy.`;await ft(s,Wd,{oldHash:a,newHash:Ms,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Na}),c?.type==="symbolic"&&await ft(s,"HEAD",{oldHash:a,newHash:Ms,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Na});let qd=await pn(s,Ma.tree,As);return{stdout:`${tr.messages.length>0?`${tr.messages.join(`
634
634
  `)}
635
635
  `:""}Merge made by the 'ort' strategy.
636
- ${qd}`,stderr:F,exitCode:0}}})}async function Jg(e,t,n){let r=!!t.noFf,o=!!t.ffOnly,s=!!t.rebase||!!t.noRebase||!!t.noFf||!!t.ffOnly,i=!1;if(t.rebase)i=!0;else if(!t.noRebase)if(n?.type==="symbolic"){let a=n.target.startsWith("refs/heads/")?n.target.slice(11):n.target,c=await xe(e,`branch.${a}.rebase`);c==="true"?(i=!0,s=!0):c==="false"?s=!0:await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0)}else await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0);if(!t.noFf&&!t.ffOnly){let a=await xe(e,"pull.ff");a==="false"?(r=!0,s=!0):a==="only"&&(o=!0,s=!0)}return{useRebase:i,noFf:r,ffOnly:o,configured:s}}oe();Be();pt();we();function wd(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:S().alias("f").describe("Force push"),"set-upstream":S().alias("u").describe("Set upstream tracking reference"),all:S().describe("Push all branches"),delete:S().alias("d").describe("Delete remote refs"),tags:S().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a=n.refspec;if(!n.delete&&!n.all&&!n.tags&&(!a||a.length===0)){let P=await Q(s);if(!P||P.type!=="symbolic")return T(`You are not currently on a branch.
636
+ ${qd}`,stderr:F,exitCode:0}}})}async function Jg(e,t,n){let r=!!t.noFf,o=!!t.ffOnly,s=!!t.rebase||!!t.noRebase||!!t.noFf||!!t.ffOnly,i=!1;if(t.rebase)i=!0;else if(!t.noRebase)if(n?.type==="symbolic"){let a=n.target.startsWith("refs/heads/")?n.target.slice(11):n.target,c=await xe(e,`branch.${a}.rebase`);c==="true"?(i=!0,s=!0):c==="false"?s=!0:await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0)}else await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0);if(!t.noFf&&!t.ffOnly){let a=await xe(e,"pull.ff");a==="false"?(r=!0,s=!0):a==="only"&&(o=!0,s=!0)}return{useRebase:i,noFf:r,ffOnly:o,configured:s}}oe();Be();pt();we();function wd(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[K.string().name("remote").describe("Remote to push to").optional(),K.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:I().alias("f").describe("Force push"),"set-upstream":I().alias("u").describe("Set upstream tracking reference"),all:I().describe("Push all branches"),delete:I().alias("d").describe("Delete remote refs"),tags:I().describe("Push all tags")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=n.remote||"origin",a=n.refspec;if(!n.delete&&!n.all&&!n.tags&&(!a||a.length===0)){let P=await Q(s);if(!P||P.type!=="symbolic")return S(`You are not currently on a branch.
637
637
  To push the history leading to the current (detached HEAD)
638
638
  state now, use
639
639
 
640
640
  git push origin HEAD:<name-of-remote-branch>
641
- `)}let c;try{c=await Ur(s,i,r.env)}catch(P){let O=P instanceof Error?P.message:"";if(O.startsWith("network"))return T(O);throw P}if(!c)return T(`'${i}' does not appear to be a git repository`);let{transport:f,config:l}=c,d=n.force,h=await f.advertiseRefs(),u=new Map;for(let P of h)u.set(P.name,P.hash);if(n.tags&&n.all)return T("options '--tags' and '--all/--branches' cannot be used together");if(n.tags&&n.delete)return T("options '--delete' and '--tags' cannot be used together");let m=[];if(n.delete){let P=a&&a.length>0?a:[];if(P.length===0)return T("--delete requires a ref argument");let O=[];for(let D of P){let L=D.startsWith("refs/")?D:`refs/heads/${D}`,K=u.get(L)??null;if(!K){O.push(`error: unable to delete '${D}': remote ref does not exist
642
- `);continue}m.push({name:L,oldHash:K,newHash:te,ok:d})}if(O.length>0&&m.length===0)return _(O.join("")+`error: failed to push some refs to '${l.url}'
643
- `)}else if(n.all){let P=await ge(s,"refs/heads");for(let O of P){let D=O.name,L=u.get(D)??null;m.push({name:D,oldHash:L,newHash:O.hash,ok:d})}}else if(a&&a.length>0)for(let P of a){let O=yr(P),D=P.replace(/^\+/,"").includes(":"),L=O.dst;if(!D&&O.src==="HEAD"){let G=await Q(s);if(G?.type==="symbolic")L=G.target.startsWith("refs/heads/")?G.target.slice(11):G.target;else return{stdout:"",stderr:`error: The destination you provided is not a full refname (i.e.,
641
+ `)}let c;try{c=await Br(s,i,r.env)}catch(P){let T=P instanceof Error?P.message:"";if(T.startsWith("network"))return S(T);throw P}if(!c)return S(`'${i}' does not appear to be a git repository`);let{transport:f,config:l}=c,d=n.force,h=await f.advertiseRefs(),u=new Map;for(let P of h)u.set(P.name,P.hash);if(n.tags&&n.all)return S("options '--tags' and '--all/--branches' cannot be used together");if(n.tags&&n.delete)return S("options '--delete' and '--tags' cannot be used together");let m=[];if(n.delete){let P=a&&a.length>0?a:[];if(P.length===0)return S("--delete requires a ref argument");let T=[];for(let H of P){let M=H.startsWith("refs/")?H:`refs/heads/${H}`,W=u.get(M)??null;if(!W){T.push(`error: unable to delete '${H}': remote ref does not exist
642
+ `);continue}m.push({name:M,oldHash:W,newHash:te,ok:d})}if(T.length>0&&m.length===0)return _(T.join("")+`error: failed to push some refs to '${l.url}'
643
+ `)}else if(n.all){let P=await ge(s,"refs/heads");for(let T of P){let H=T.name,M=u.get(H)??null;m.push({name:H,oldHash:M,newHash:T.hash,ok:d})}}else if(a&&a.length>0)for(let P of a){let T=yr(P),H=P.replace(/^\+/,"").includes(":"),M=T.dst;if(!H&&T.src==="HEAD"){let L=await Q(s);if(L?.type==="symbolic")M=L.target.startsWith("refs/heads/")?L.target.slice(11):L.target;else return{stdout:"",stderr:`error: The destination you provided is not a full refname (i.e.,
644
644
  starting with "refs/"). We tried to guess what you meant by:
645
645
 
646
646
  - Looking for a ref that matches 'HEAD' on the remote side.
@@ -653,33 +653,33 @@ hint: The <src> part of the refspec is a commit object.
653
653
  hint: Did you mean to create a new branch by pushing to
654
654
  hint: 'HEAD:refs/heads/HEAD'?
655
655
  error: failed to push some refs to '${l.url}'
656
- `,exitCode:1}}let K=await ew(s,O.src);if(!K)return _(`error: src refspec ${O.src} does not match any
656
+ `,exitCode:1}}let W=await ew(s,T.src);if(!W)return _(`error: src refspec ${T.src} does not match any
657
657
  error: failed to push some refs to '${l.url}'
658
- `);let I=L.startsWith("refs/")?L:`refs/heads/${L}`,H=u.get(I)??null;m.push({name:I,oldHash:H,newHash:K,ok:d||O.force})}else if(!n.tags){let P=await Q(s);if(!P||P.type!=="symbolic")return T(`You are not currently on a branch.
658
+ `);let O=M.startsWith("refs/")?M:`refs/heads/${M}`,A=u.get(O)??null;m.push({name:O,oldHash:A,newHash:W,ok:d||T.force})}else if(!n.tags){let P=await Q(s);if(!P||P.type!=="symbolic")return S(`You are not currently on a branch.
659
659
  To push the history leading to the current (detached HEAD)
660
660
  state now, use
661
661
 
662
662
  git push origin HEAD:<name-of-remote-branch>
663
- `);let O=P.target,D=O.startsWith("refs/heads/")?O.slice(11):O,L=await X(s);if(!L)return _(`error: src refspec does not match any
664
- `);let K=(await xe(s,"push.default"))?.toLowerCase()??"simple",I=await Qg(s,K,O,D,L,i,u,d);if("exitCode"in I)return I;m.push(I)}if(n.tags){let P=await ge(s,"refs/tags");for(let O of P){let D=u.get(O.name)??null;D!==O.hash&&(m.some(L=>L.name===O.name)||m.push({name:O.name,oldHash:D,newHash:O.hash,ok:d}))}}let p=m.filter(P=>P.oldHash!==P.newHash);if(p.length===0){let P="";if(n["set-upstream"]){let O=await Q(s);if(O?.type==="symbolic"){let D=O.target.startsWith("refs/heads/")?O.target.slice(11):O.target,L=await he(s);L[`branch "${D}"`]={remote:i,merge:`refs/heads/${D}`},await Xe(s,L),P=`branch '${D}' set up to track '${i}/${D}'.
663
+ `);let T=P.target,H=T.startsWith("refs/heads/")?T.slice(11):T,M=await X(s);if(!M)return _(`error: src refspec does not match any
664
+ `);let W=(await xe(s,"push.default"))?.toLowerCase()??"simple",O=await Qg(s,W,T,H,M,i,u,d);if("exitCode"in O)return O;m.push(O)}if(n.tags){let P=await ge(s,"refs/tags");for(let T of P){let H=u.get(T.name)??null;H!==T.hash&&(m.some(M=>M.name===T.name)||m.push({name:T.name,oldHash:H,newHash:T.hash,ok:d}))}}let p=m.filter(P=>P.oldHash!==P.newHash);if(p.length===0){let P="";if(n["set-upstream"]){let T=await Q(s);if(T?.type==="symbolic"){let H=T.target.startsWith("refs/heads/")?T.target.slice(11):T.target,M=await pe(s);M[`branch "${H}"`]={remote:i,merge:`refs/heads/${H}`},await ze(s,M),P=`branch '${H}' set up to track '${i}/${H}'.
665
665
  `}}return{stdout:P,stderr:`Everything up-to-date
666
- `,exitCode:0}}let g=await t?.hooks?.prePush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===te?null:P.name,srcHash:P.newHash===te?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===te}))});if(fe(g))return _(g.message??"");let w=new Set(p.filter(P=>P.ok).map(P=>P.name)),b=await f.push(p),k=b.updates.filter(P=>P.ok&&P.oldHash&&P.newHash!==te&&w.has(P.name)),R=await Promise.all(k.map(P=>en(s,P.oldHash,P.newHash))),C=new Set;k.forEach((P,O)=>{R[O]||C.add(P.name)});let E=[],y=!1;for(let P of b.updates){let O=P.name.startsWith("refs/tags/"),D=Ln(P.name);if(P.ok)if(P.oldHash)if(P.newHash===te)E.push({prefix:" - [deleted]",from:D,to:""});else{let L=Z(P.oldHash),K=Z(P.newHash);C.has(P.name)?E.push({prefix:` + ${L}...${K}`,from:D,to:D,suffix:"(forced update)"}):E.push({prefix:` ${L}..${K}`,from:D,to:D})}else{let L=O?"[new tag]":"[new branch]";E.push({prefix:` * ${L}`,from:D,to:D})}else{let L=P.error?.includes("fetch first"),K=P.error?.includes("non-fast-forward"),I=L?"fetch first":K?"non-fast-forward":P.error??"failed";E.push({prefix:" ! [rejected]",from:D,to:D,suffix:`(${I})`}),y=!0}}E.sort((P,O)=>gd(P)-gd(O));let x=[];if(x.push(`To ${l.url}
667
- `),x.push(vr(E,0,!1)),y){x.push(`error: failed to push some refs to '${l.url}'
668
- `);let P=b.updates.some(D=>!D.ok&&D.error?.includes("fetch first")),O=b.updates.some(D=>!D.ok&&D.error?.includes("non-fast-forward"));P?x.push(`hint: Updates were rejected because the remote contains work that you do not
666
+ `,exitCode:0}}let g=await t?.hooks?.prePush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===te?null:P.name,srcHash:P.newHash===te?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===te}))});if(fe(g))return _(g.message??"");let w=new Set(p.filter(P=>P.ok).map(P=>P.name)),b=await f.push(p),y=b.updates.filter(P=>P.ok&&P.oldHash&&P.newHash!==te&&w.has(P.name)),x=await Promise.all(y.map(P=>en(s,P.oldHash,P.newHash))),k=new Set;y.forEach((P,T)=>{x[T]||k.add(P.name)});let R=[],E=!1;for(let P of b.updates){let T=P.name.startsWith("refs/tags/"),H=Gn(P.name);if(P.ok)if(P.oldHash)if(P.newHash===te)R.push({prefix:" - [deleted]",from:H,to:""});else{let M=Z(P.oldHash),W=Z(P.newHash);k.has(P.name)?R.push({prefix:` + ${M}...${W}`,from:H,to:H,suffix:"(forced update)"}):R.push({prefix:` ${M}..${W}`,from:H,to:H})}else{let M=T?"[new tag]":"[new branch]";R.push({prefix:` * ${M}`,from:H,to:H})}else{let M=P.error?.includes("fetch first"),W=P.error?.includes("non-fast-forward"),O=M?"fetch first":W?"non-fast-forward":P.error??"failed";R.push({prefix:" ! [rejected]",from:H,to:H,suffix:`(${O})`}),E=!0}}R.sort((P,T)=>gd(P)-gd(T));let C=[];if(C.push(`To ${l.url}
667
+ `),C.push(Hr(R,0,!1)),E){C.push(`error: failed to push some refs to '${l.url}'
668
+ `);let P=b.updates.some(H=>!H.ok&&H.error?.includes("fetch first")),T=b.updates.some(H=>!H.ok&&H.error?.includes("non-fast-forward"));P?C.push(`hint: Updates were rejected because the remote contains work that you do not
669
669
  hint: have locally. This is usually caused by another repository pushing to
670
670
  hint: the same ref. If you want to integrate the remote changes, use
671
671
  hint: 'git pull' before pushing again.
672
672
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
673
- `):O&&x.push(`hint: Updates were rejected because the tip of your current branch is behind
673
+ `):T&&C.push(`hint: Updates were rejected because the tip of your current branch is behind
674
674
  hint: its remote counterpart. If you want to integrate the remote changes,
675
675
  hint: use 'git pull' before pushing again.
676
676
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
677
- `)}let $="";for(let P of b.updates){if(!P.ok||!P.name.startsWith("refs/heads/"))continue;let O=`refs/remotes/${i}/${P.name.slice(11)}`;P.newHash===te?await me(s,O):await J(s,O,P.newHash)}if(n["set-upstream"]&&!y){let P=await Q(s);if(P?.type==="symbolic"){let O=P.target.startsWith("refs/heads/")?P.target.slice(11):P.target,D=await he(s);D[`branch "${O}"`]={remote:i,merge:`refs/heads/${O}`},await Xe(s,D),$=`branch '${O}' set up to track '${i}/${O}'.
678
- `}}let A={stdout:$,stderr:x.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===te?null:P.name,srcHash:P.newHash===te?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===te}))}),A}})}async function Qg(e,t,n,r,o,s,i,a){if(t==="nothing")return T(`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 T(`The current branch ${r} has no upstream branch.
677
+ `)}let $="";for(let P of b.updates){if(!P.ok||!P.name.startsWith("refs/heads/"))continue;let T=`refs/remotes/${i}/${P.name.slice(11)}`;P.newHash===te?await he(s,T):await J(s,T,P.newHash)}if(n["set-upstream"]&&!E){let P=await Q(s);if(P?.type==="symbolic"){let T=P.target.startsWith("refs/heads/")?P.target.slice(11):P.target,H=await pe(s);H[`branch "${T}"`]={remote:i,merge:`refs/heads/${T}`},await ze(s,H),$=`branch '${T}' set up to track '${i}/${T}'.
678
+ `}}let D={stdout:$,stderr:C.join(""),exitCode:E?1:0};return E||await t?.hooks?.postPush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===te?null:P.name,srcHash:P.newHash===te?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===te}))}),D}})}async function Qg(e,t,n,r,o,s,i,a){if(t==="nothing")return S(`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 pe(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return S(`The current branch ${r} has no upstream branch.
679
679
  To push the current branch and set the remote as upstream, use
680
680
 
681
681
  git push --set-upstream ${s} ${r}
682
- `);let h=d.merge;return{name:h,oldHash:i.get(h)??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){let h=d.startsWith("refs/heads/")?d.slice(11):d;return h!==r?T(`The upstream branch of your current branch does not match
682
+ `);let h=d.merge;return{name:h,oldHash:i.get(h)??null,newHash:o,ok:a}}let f=(await pe(e))[`branch "${r}"`];if(f?.remote&&f?.merge){let l=f.remote,d=f.merge;if(l===s){let h=d.startsWith("refs/heads/")?d.slice(11):d;return h!==r?S(`The upstream branch of your current branch does not match
683
683
  the name of your current branch. To push to the upstream branch
684
684
  on the remote, use
685
685
 
@@ -694,57 +694,57 @@ To choose either option permanently, see push.default in 'git help config'.
694
694
  To avoid automatically configuring an upstream branch when its name
695
695
  won't match the local branch, see option 'simple' of branch.autoSetupMerge
696
696
  in 'git help config'.
697
- `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}return T(`The current branch ${r} has no upstream branch.
697
+ `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}return S(`The current branch ${r} has no upstream branch.
698
698
  To push the current branch and set the remote as upstream, use
699
699
 
700
700
  git push --set-upstream ${s} ${r}
701
701
 
702
702
  To have this happen automatically for branches without a tracking
703
703
  upstream, see 'push.autoSetupRemote' in 'git help config'.
704
- `)}function gd(e){return e.prefix.startsWith(" ")||e.prefix.startsWith(" + ")?0:e.prefix.includes("[new ")?1:e.prefix.includes("[deleted]")?2:e.prefix.includes("[rejected]")?3:4}async function ew(e,t){if(t.startsWith("refs/"))return B(e,t);let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}oe();pe();ze();we();function tw(e,t,n,r){return`${Z(n)} ${e}@{${t}}: ${r}`}async function Jo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await B(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
704
+ `)}function gd(e){return e.prefix.startsWith(" ")||e.prefix.startsWith(" + ")?0:e.prefix.includes("[new ")?1:e.prefix.includes("[deleted]")?2:e.prefix.includes("[rejected]")?3:4}async function ew(e,t){if(t.startsWith("refs/"))return B(e,t);let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}oe();me();Ke();we();function tw(e,t,n,r){return`${Z(n)} ${e}@{${t}}: ${r}`}async function Jo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await B(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
705
705
  Use '--' to separate paths from revisions, like this:
706
706
  'git <command> [<revision>...] -- [<file>...]'
707
- `,exitCode:128};let s=await et(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 h=s.length-1-l;d.newHash!==te&&(i.push(tw(t,h,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
707
+ `,exitCode:128};let s=await Qe(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 h=s.length-1-l;d.newHash!==te&&(i.push(tw(t,h,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
708
708
  `)}
709
- `:"",stderr:"",exitCode:0}}function bd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:Y.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 Jo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Jo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Jo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
710
- `,exitCode:128};let l=v(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Jo(i,c,r.maxCount)}})}oe();Be();ze();we();function nw(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 yd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:S().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=nw(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let u=c[`remote "${d}"`]?.url??"";l.push(`${d} ${u} (fetch)`),l.push(`${d} ${u} (push)`)}return{stdout:`${l.join(`
709
+ `:"",stderr:"",exitCode:0}}function bd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[K.string().name("args").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);if(j(s))return s;let i=s,a=r.args;if(a.length===0)return Jo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Jo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Jo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
710
+ `,exitCode:128};let l=v(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Jo(i,c,r.maxCount)}})}oe();Be();Ke();we();function nw(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 yd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:I().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a),f=nw(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let u=c[`remote "${d}"`]?.url??"";l.push(`${d} ${u} (fetch)`),l.push(`${d} ${u} (push)`)}return{stdout:`${l.join(`
711
711
  `)}
712
712
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
713
713
  `)}
714
- `,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)=>{if(!os(`refs/remotes/${s.name}`,0))return T(`'${s.name}' is not a valid remote name`);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 _(`error: remote ${s.name} already exists.
715
- `,3);let l=wr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Xe(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],sw(c,s.name),await Xe(a,c),await ow(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
716
- `,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 rw(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 _(`error: No such remote '${s.name}'
717
- `,2);let l=wr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await Xe(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??""}
714
+ `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[K.string().name("name").describe("Remote name"),K.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!is(`refs/remotes/${s.name}`,0))return S(`'${s.name}' is not a valid remote name`);let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(f in c)return _(`error: remote ${s.name} already exists.
715
+ `,3);let l=wr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await ze(a,c),{stdout:"",stderr:"",exitCode:0}}});let r=async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?(delete c[f],sw(c,s.name),await ze(a,c),await ow(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
716
+ `,2)},o=[K.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:[K.string().name("old").describe("Current remote name"),K.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a);return rw(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[K.string().name("name").describe("Remote name"),K.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(!(f in c))return _(`error: No such remote '${s.name}'
717
+ `,2);let l=wr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await ze(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[K.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(j(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
718
718
  `,stderr:"",exitCode:0}:_(`error: No such remote '${s.name}'
719
- `,2)}})}async function rw(e,t,n,r){if(!os(`refs/remotes/${r}`,0))return T(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
720
- `,2);let s=`remote "${r}"`;if(s in t)return T(`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 Xe(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 et(e,f.name);await J(e,l,f.hash),await me(e,f.name),d.length>0&&await Fn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function sw(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 ow(e,t){let n=`refs/remotes/${t}`,r=await ge(e,n);for(let o of r)await me(e,o.name)}oe();Ce();ie();pe();ze();we();fn();De();Jt();tt();function kd(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:S().describe("Only move HEAD"),mixed:S().describe("Move HEAD and reset index (default)"),hard:S().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await 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 T("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=dt(i,r.cwd);if(o.passthrough.length>0){let u=a.length>0?a[0]:void 0;return Oa(i,o.passthrough,l,u,t)}if(!f&&a.length>0){let u=a[0],m=await We(i,u);return a.length===1&&m?Ed(i,u,"mixed",r.env,t):m?Oa(i,a.slice(1),l,u,t):Oa(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",h=a.length>0?a[0]:"HEAD";return Ed(i,h,d,r.env,t)}})}async function Oa(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await We(e,r);if(!d)return Qt(r);let h=await Ae(e,d);i=(await j(e,h)).tree}else{let d=await X(e);d&&(i=(await j(e,d)).tree)}let a=await de(e,i??null),c=await z(e);if(t.some(fr)){let d=t.map(u=>Ue(u,n)),h=new Set;for(let[u]of a)h.add(u);for(let u of c.entries)h.add(u.path);for(let u of h){if(!Ee(d,u))continue;let m=a.get(u);m?c=Pt(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:ve()}):c=ft(c,u)}}else for(let d of t){let h=a.get(d);if(h)c=Pt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:ve()});else if(c.entries.some(m=>m.path===d))c=ft(c,d);else if(!(e.workTree&&await e.fs.exists(v(e.workTree,d))))return Qt(d)}await ae(e,c);let l={stdout:await Rd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function Rd(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 wt(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(`
719
+ `,2)}})}async function rw(e,t,n,r){if(!is(`refs/remotes/${r}`,0))return S(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
720
+ `,2);let s=`remote "${r}"`;if(s in t)return S(`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 ze(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 Qe(e,f.name);await J(e,l,f.hash),await he(e,f.name),d.length>0&&await _n(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function sw(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 ow(e,t){let n=`refs/remotes/${t}`,r=await ge(e,n);for(let o of r)await he(e,o.name)}oe();Ce();ie();me();Ke();we();cn();De();Jt();et();function kd(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[K.string().name("args").variadic().optional()],options:{soft:I().describe("Only move HEAD"),mixed:I().describe("Move HEAD and reset index (default)"),hard:I().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return S("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=dt(i,r.cwd);if(o.passthrough.length>0){let u=a.length>0?a[0]:void 0;return Oa(i,o.passthrough,l,u,t)}if(!f&&a.length>0){let u=a[0],m=await We(i,u);return a.length===1&&m?Ed(i,u,"mixed",r.env,t):m?Oa(i,a.slice(1),l,u,t):Oa(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",h=a.length>0?a[0]:"HEAD";return Ed(i,h,d,r.env,t)}})}async function Oa(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await We(e,r);if(!d)return Qt(r);let h=await Ae(e,d);i=(await G(e,h)).tree}else{let d=await X(e);d&&(i=(await G(e,d)).tree)}let a=await de(e,i??null),c=await z(e);if(t.some(fr)){let d=t.map(u=>Ue(u,n)),h=new Set;for(let[u]of a)h.add(u);for(let u of c.entries)h.add(u.path);for(let u of h){if(!Ee(d,u))continue;let m=a.get(u);m?c=Pt(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:ve()}):c=ct(c,u)}}else for(let d of t){let h=a.get(d);if(h)c=Pt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:ve()});else if(c.entries.some(m=>m.path===d))c=ct(c,d);else if(!(e.workTree&&await e.fs.exists(v(e.workTree,d))))return Qt(d)}await ae(e,c);let l={stdout:await Rd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function Rd(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 wt(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(`
721
721
  `)}
722
- `}async function Ed(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Qt(t);let a=await Ae(e,i),c=await j(e,a);if(n==="soft"){let u=await B(e,"MERGE_HEAD"),m=await z(e);if(u||Gt(m))return T("Cannot do a soft reset in the middle of a merge.")}let f=await X(e),l=await Q(e);l?.type==="symbolic"?await J(e,l.target,a):await J(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await se(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await se(e,r,"HEAD",f,a,d),await dr(e),n==="mixed"){let u=await qe(e,c.tree),m=qs(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:ve()})));await ae(e,m);let p=await Rd(e,m);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let u=Ve(e);if(u)return u;let m=await z(e),p=await Pn(e,c.tree,m);await ae(e,{version:2,entries:p.newEntries}),await je(e,p.worktreeOps)}let h=n==="hard"?`HEAD is now at ${Z(a)} ${ue(c.message)}
723
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:h,stderr:"",exitCode:0}}oe();Ce();ie();we();De();tt();function xd(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:Y.string().alias("s").describe("Restore from tree-ish"),staged:S().alias("S").describe("Restore the index"),worktree:S().alias("W").describe("Restore the working tree (default)"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return T("you must specify path(s) to restore");if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=dt(i,r.cwd);if(n.ours||n.theirs)return n.source?T("cannot specify both --source and --ours/--theirs"):c?T("cannot use --ours/--theirs with --staged"):Co(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let h=await Le(i,n.source,`could not resolve '${n.source}'`);if(M(h))return h;d=h.commit.tree}else if(c){let h=await X(i);h&&(d=(await j(i,h)).tree)}return c&&f?cw(i,a,l,d):c?iw(i,a,l,d):d?aw(i,a,l,d):xo(i,a,l)}})}async function iw(e,t,n,r){let o=await de(e,r),s=await z(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(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:ve()});else{if(s.entries.some(h=>h.path===f&&h.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
724
- `,exitCode:1};s=ft(s,f)}}return c?(await ae(e,s),{stdout:"",stderr:"",exitCode:0}):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
725
- `)}async function aw(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await de(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await z(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(Ee(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
722
+ `}async function Ed(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Qt(t);let a=await Ae(e,i),c=await G(e,a);if(n==="soft"){let u=await B(e,"MERGE_HEAD"),m=await z(e);if(u||Gt(m))return S("Cannot do a soft reset in the middle of a merge.")}let f=await X(e),l=await Q(e);l?.type==="symbolic"?await J(e,l.target,a):await J(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await ne(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await ne(e,r,"HEAD",f,a,d),await dr(e),n==="mixed"){let u=await qe(e,c.tree),m=Ks(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:ve()})));await ae(e,m);let p=await Rd(e,m);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let u=Ye(e);if(u)return u;let m=await z(e),p=await Cn(e,c.tree,m);await ae(e,{version:2,entries:p.newEntries}),await je(e,p.worktreeOps)}let h=n==="hard"?`HEAD is now at ${Z(a)} ${ue(c.message)}
723
+ `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:h,stderr:"",exitCode:0}}oe();Ce();ie();we();De();et();function xd(e,t){e.command("restore",{description:"Restore working tree files",args:[K.string().name("pathspec").variadic().optional()],options:{source:Y.string().alias("s").describe("Restore from tree-ish"),staged:I().alias("S").describe("Restore the index"),worktree:I().alias("W").describe("Restore the working tree (default)"),ours:I().describe("Checkout our version for unmerged files"),theirs:I().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return S("you must specify path(s) to restore");if(n.ours&&n.theirs)return S("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=dt(i,r.cwd);if(n.ours||n.theirs)return n.source?S("cannot specify both --source and --ours/--theirs"):c?S("cannot use --ours/--theirs with --staged"):Co(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let h=await Le(i,n.source,`could not resolve '${n.source}'`);if(j(h))return h;d=h.commit.tree}else if(c){let h=await X(i);h&&(d=(await G(i,h)).tree)}return c&&f?cw(i,a,l,d):c?iw(i,a,l,d):d?aw(i,a,l,d):xo(i,a,l)}})}async function iw(e,t,n,r){let o=await de(e,r),s=await z(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(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:ve()});else{if(s.entries.some(h=>h.path===f&&h.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
724
+ `,exitCode:1};s=ct(s,f)}}return c?(await ae(e,s),{stdout:"",stderr:"",exitCode:0}):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
725
+ `)}async function aw(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await de(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await z(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(Ee(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
726
726
  `,exitCode:1};i.push(f)}if(i.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
727
- `);for(let f of i){let l=o.get(f);if(l)await lt(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 cw(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await de(e,r),s=await z(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)Ee(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
727
+ `);for(let f of i){let l=o.get(f);if(l)await lt(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 cw(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await de(e,r),s=await z(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)Ee(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
728
728
  `);for(let f of a){let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:ve()}),await lt(e,{path:l.path,hash:l.hash,mode:l.mode});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
729
- `,exitCode:1};s=ft(s,f);let h=`${e.workTree}/${f}`;await e.fs.exists(h)&&await e.fs.rm(h)}}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}oe();ie();pe();we();fn();De();function Cd(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:S().describe("Verify that exactly one parameter is provided and resolves to an object"),short:S().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":S().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":S().describe("Output the full symbolic ref name"),"show-toplevel":S().describe("Show the absolute path of the top-level directory"),"git-dir":S().describe("Show the path to the .git directory"),"is-inside-work-tree":S().describe("Output whether cwd is inside the work tree"),"is-bare-repository":S().describe("Output whether the repository is bare"),"show-prefix":S().describe("Show path of cwd relative to top-level directory"),"show-cdup":S().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(R=>R!==""),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"],h=n["is-bare-repository"],u=n["show-prefix"],m=n["show-cdup"],p=f||l||d||h||u||m,g=await W(r.fs,r.cwd,t);if(M(g))return g;let w=g,b=[];if(f){if(!w.workTree)return T("this operation must be run in a work tree");b.push(w.workTree)}if(l&&b.push(w.gitDir),d&&b.push(w.workTree?"true":"false"),h&&b.push(w.workTree?"false":"true"),u){if(!w.workTree)return T("this operation must be run in a work tree");let R=rt(w.workTree,r.cwd);b.push(R===""?"":`${R}/`)}if(m){if(!w.workTree)return T("this operation must be run in a work tree");let R=rt(r.cwd,w.workTree);b.push(R===""?"":`${R}/`)}if(p&&o.length===0)return{stdout:b.map(C=>`${C}
730
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return T("Needed a single revision");for(let R of o){if(a){let y=await fw(w,R);if(y===null)return Ia(R,s);b.push(y);continue}if(c){let y=await lw(w,R);if(y===null)return Ia(R,s);b.push(y);continue}let C=to(R);if(C){let y=await dw(w,C.rev,C.path);if(y===null){let x=C.path.replace(/^\//,"");return T(`path '${x}' does not exist in '${C.rev}'`)}b.push(i?Z(y):y);continue}let E=await We(w,R);if(!E)return Ia(R,s);b.push(i?Z(E):E)}return{stdout:b.map(R=>`${R}
731
- `).join(""),stderr:"",exitCode:0}}})}function Ia(e,t){return t?T("Needed a single revision"):Qt(e)}async function fw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function lw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await B(e,o))return o}return t}async function dw(e,t,n){let r=await We(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await de(e,o.tree)).get(s)?.hash??null}oe();Be();Ce();ie();ze();we();De();Jt();function Pd(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:S().describe("Abort the current revert operation"),continue:S().describe("Continue the revert after conflict resolution"),skip:S().describe("Skip the current commit and continue"),"no-commit":S().alias("n").describe("Apply changes without creating a commit"),"no-edit":S().describe("Do not edit the commit message"),mainline:Y.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 F=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(fe(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await uw(s,r.env);return U.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let F=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(fe(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await mw(s,r.env);if(U.exitCode===0){let N=await X(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:N,hadConflicts:!1})}return U}if(n.skip)return hw(s,r.env);let i=n.commit;if(!i)return T("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Le(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let h=await z(s),u=$n(h,"Reverting",`fatal: revert failed
732
- `);if(u)return u;let m=await j(s,d);if(s.workTree){let F=await de(s,m.tree);if(qn(h,F))return _(`error: your local changes would be overwritten by revert.
729
+ `,exitCode:1};s=ct(s,f);let h=`${e.workTree}/${f}`;await e.fs.exists(h)&&await e.fs.rm(h)}}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}oe();ie();me();we();cn();De();function Cd(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[K.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:I().describe("Verify that exactly one parameter is provided and resolves to an object"),short:I().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":I().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":I().describe("Output the full symbolic ref name"),"show-toplevel":I().describe("Show the absolute path of the top-level directory"),"git-dir":I().describe("Show the path to the .git directory"),"is-inside-work-tree":I().describe("Output whether cwd is inside the work tree"),"is-bare-repository":I().describe("Output whether the repository is bare"),"show-prefix":I().describe("Show path of cwd relative to top-level directory"),"show-cdup":I().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(x=>x!==""),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"],h=n["is-bare-repository"],u=n["show-prefix"],m=n["show-cdup"],p=f||l||d||h||u||m,g=await q(r.fs,r.cwd,t);if(j(g))return g;let w=g,b=[];if(f){if(!w.workTree)return S("this operation must be run in a work tree");b.push(w.workTree)}if(l&&b.push(w.gitDir),d&&b.push(w.workTree?"true":"false"),h&&b.push(w.workTree?"false":"true"),u){if(!w.workTree)return S("this operation must be run in a work tree");let x=nt(w.workTree,r.cwd);b.push(x===""?"":`${x}/`)}if(m){if(!w.workTree)return S("this operation must be run in a work tree");let x=nt(r.cwd,w.workTree);b.push(x===""?"":`${x}/`)}if(p&&o.length===0)return{stdout:b.map(k=>`${k}
730
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return S("Needed a single revision");for(let x of o){if(a){let E=await fw(w,x);if(E===null)return Ia(x,s);b.push(E);continue}if(c){let E=await lw(w,x);if(E===null)return Ia(x,s);b.push(E);continue}let k=to(x);if(k){let E=await dw(w,k.rev,k.path);if(E===null){let C=k.path.replace(/^\//,"");return S(`path '${C}' does not exist in '${k.rev}'`)}b.push(i?Z(E):E);continue}let R=await We(w,x);if(!R)return Ia(x,s);b.push(i?Z(R):R)}return{stdout:b.map(x=>`${x}
731
+ `).join(""),stderr:"",exitCode:0}}})}function Ia(e,t){return t?S("Needed a single revision"):Qt(e)}async function fw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function lw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await B(e,o))return o}return t}async function dw(e,t,n){let r=await We(e,t);if(!r)return null;let o=await G(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await de(e,o.tree)).get(s)?.hash??null}oe();Be();Ce();ie();Ke();we();De();Jt();function Pd(e,t){e.command("revert",{description:"Revert some existing commits",args:[K.string().name("commit").describe("The commit to revert").optional()],options:{abort:I().describe("Abort the current revert operation"),continue:I().describe("Continue the revert after conflict resolution"),skip:I().describe("Skip the current commit and continue"),"no-commit":I().alias("n").describe("Apply changes without creating a commit"),"no-edit":I().describe("Do not edit the commit message"),mainline:Y.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.abort){let F=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(fe(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await uw(s,r.env);return U.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let F=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(fe(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await mw(s,r.env);if(U.exitCode===0){let N=await X(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:N,hadConflicts:!1})}return U}if(n.skip)return hw(s,r.env);let i=n.commit;if(!i)return S("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Le(s,i);if(j(c))return c;let f=c.hash,l=c.commit,d=await Je(s);if(j(d))return d;let h=await z(s),u=Pn(h,"Reverting",`fatal: revert failed
732
+ `);if(u)return u;let m=await G(s,d);if(s.workTree){let F=await de(s,m.tree);if(Wn(h,F))return _(`error: your local changes would be overwritten by revert.
733
733
  hint: commit your changes or stash them to proceed.
734
734
  fatal: revert failed
735
735
  `,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return _(`error: commit ${f} is a merge but no -m option was given.
736
736
  fatal: revert failed
737
737
  `,128);if(p<1||p>l.parents.length)return _(`error: commit ${f} does not have parent ${p}
738
738
  fatal: revert failed
739
- `,128);let F=l.parents[p-1];g=(await j(s,F)).tree}else if(l.parents.length===0)g=await Fe(s,[]);else{let F=l.parents[0];g=(await j(s,F)).tree}let w=Z(f),b=ue(l.message),k=pw(l,f,p),R=await xe(s,"merge.conflictstyle")??"merge",C={a:"HEAD",b:b?`parent of ${w} (${b})`:`parent of ${w}`,conflictStyle:R},E=await zt(s,l.tree,m.tree,g,C);if(E.conflicts.length===0&&E.resultTree===m.tree){let F=E.messages.length>0?`${E.messages.join(`
739
+ `,128);let F=l.parents[p-1];g=(await G(s,F)).tree}else if(l.parents.length===0)g=await Fe(s,[]);else{let F=l.parents[0];g=(await G(s,F)).tree}let w=Z(f),b=ue(l.message),y=pw(l,f,p),x=await xe(s,"merge.conflictstyle")??"merge",k={a:"HEAD",b:b?`parent of ${w} (${b})`:`parent of ${w}`,conflictStyle:x},R=await Kt(s,l.tree,m.tree,g,k);if(R.conflicts.length===0&&R.resultTree===m.tree){let F=R.messages.length>0?`${R.messages.join(`
740
740
  `)}
741
- `:"",U=await it(s,{fromCommit:!0}),N=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${F}${U}`,stderr:N?`The previous cherry-pick is now empty, possibly due to conflict resolution.
741
+ `:"",U=await ot(s,{fromCommit:!0}),N=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${F}${U}`,stderr:N?`The previous cherry-pick is now empty, possibly due to conflict resolution.
742
742
  If you wish to commit it anyway, use:
743
743
 
744
744
  git commit --allow-empty
745
745
 
746
746
  Otherwise, please use 'git cherry-pick --skip'
747
- `:"",exitCode:1}}let y=await Sn(s,E,m.tree,{labels:C,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!y.ok)return y;if(E.conflicts.length>0){await J(s,"REVERT_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",k);let F=E.messages.join(`
747
+ `:"",exitCode:1}}let E=await In(s,R,m.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!E.ok)return E;if(R.conflicts.length>0){await J(s,"REVERT_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",y);let F=R.messages.join(`
748
748
  `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:F?`${F}
749
749
  `:"",stderr:`error: could not revert ${w}... ${ue(l.message)}
750
750
  hint: After resolving the conflicts, mark them with
@@ -754,33 +754,33 @@ hint: You can instead skip this commit with "git revert --skip".
754
754
  hint: To abort and get back to the state before "git revert",
755
755
  hint: run "git revert --abort".
756
756
  hint: Disable this message with "git config set advice.mergeConflict false"
757
- `,exitCode:1}}if(n["no-commit"])return await J(s,"REVERT_HEAD",f),await Me(s,"MERGE_MSG",k),{stdout:"",stderr:"",exitCode:0};let x=y.mergedTreeHash,$=await hn(s,r.env);if(M($))return $;let A=await nt(s,r.env);if(M(A))return A;let P=await yt(s,x,[d],$,A,k);await St(s),await Ft(s);let O=await Q(s),D=ue(k),L=O?.type==="symbolic"?O.target:"HEAD";await se(s,r.env,L,d,P,`revert: ${D}`,O?.type==="symbolic");let K=O?.type==="symbolic"?Pe(O.target):"detached HEAD",I=await pn(s,m.tree,x,$,A,$.timestamp!==A.timestamp||$.timezone!==A.timezone),H=Lt(K,P,k),G=E.messages.length>0?`${E.messages.join(`
757
+ `,exitCode:1}}if(n["no-commit"])return await J(s,"REVERT_HEAD",f),await Me(s,"MERGE_MSG",y),{stdout:"",stderr:"",exitCode:0};let C=E.mergedTreeHash,$=await un(s,r.env);if(j($))return $;let D=await tt(s,r.env);if(j(D))return D;let P=await yt(s,C,[d],$,D,y);await St(s),await Ft(s);let T=await Q(s),H=ue(y),M=T?.type==="symbolic"?T.target:"HEAD";await ne(s,r.env,M,d,P,`revert: ${H}`,T?.type==="symbolic");let W=T?.type==="symbolic"?Pe(T.target):"detached HEAD",O=await mn(s,m.tree,C,$,D,$.timestamp!==D.timestamp||$.timezone!==D.timezone),A=Lt(W,P,y),L=R.messages.length>0?`${R.messages.join(`
758
758
  `)}
759
- `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:P,hadConflicts:!1}),{stdout:`${G}${H}
760
- ${I}`,stderr:"",exitCode:0}}})}async function uw(e,t){return await B(e,"REVERT_HEAD")?zn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
759
+ `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:P,hadConflicts:!1}),{stdout:`${L}${A}
760
+ ${O}`,stderr:"",exitCode:0}}})}async function uw(e,t){return await B(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
761
761
  fatal: revert failed
762
- `,128),operationName:"revert",clearState:async o=>{await St(o),await Ft(o)},origHeadAsTargetRev:!0}):await B(e,"CHERRY_PICK_HEAD")?zn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
762
+ `,128),operationName:"revert",clearState:async o=>{await St(o),await Ft(o)},origHeadAsTargetRev:!0}):await B(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
763
763
  fatal: revert failed
764
764
  `,128),operationName:"revert",clearState:Ft,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
765
765
  fatal: revert failed
766
766
  `,128)}async function hw(e,t){if(!await B(e,"REVERT_HEAD"))return _(`error: no revert in progress
767
767
  fatal: revert failed
768
- `,128);let r=await X(e);if(!r)return T("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Tr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
768
+ `,128);let r=await X(e);if(!r)return S("unable to resolve HEAD");let o=await G(e,r),s=await z(e),i=await vr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
769
769
  fatal: revert failed
770
- `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await se(e,t,"HEAD",r,r,`reset: moving to ${r}`),await St(e),{stdout:"",stderr:"",exitCode:0}}async function mw(e,t){if(!await B(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
770
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await St(e),{stdout:"",stderr:"",exitCode:0}}async function mw(e,t){if(!await B(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
771
771
  fatal: revert failed
772
- `,128);let r=await z(e),o=$n(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return _(`Aborting commit due to empty commit message.
772
+ `,128);let r=await z(e),o=Pn(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return _(`Aborting commit due to empty commit message.
773
773
  `,1);let i=await $e(e,"SQUASH_MSG");if(i&&(s=i+s),s=It(s),!s)return _(`Aborting commit due to empty commit message.
774
- `,1);let a=Ne(r),c=await Fe(e,a),f=await Qe(e);if(M(f))return f;let l=await j(e,f),d=await hn(e,t);if(M(d))return d;let h=await nt(e,t);if(M(h))return h;let u=await B(e,"CHERRY_PICK_HEAD");u&&(d=(await j(e,u)).author);let m=Nt(s),p=await yt(e,c,[f],d,h,m);await St(e),await Ft(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await se(e,t,b,f,p,`commit: ${w}`,g?.type==="symbolic");let k=g?.type==="symbolic"?Pe(g.target):"detached HEAD",R=await pn(e,l.tree,c,d,h,d.timestamp!==h.timestamp||d.timezone!==h.timezone);return{stdout:`${Lt(k,p,s)}
775
- ${R}`,stderr:"",exitCode:0}}function pw(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
774
+ `,1);let a=Ne(r),c=await Fe(e,a),f=await Je(e);if(j(f))return f;let l=await G(e,f),d=await un(e,t);if(j(d))return d;let h=await tt(e,t);if(j(h))return h;let u=await B(e,"CHERRY_PICK_HEAD");u&&(d=(await G(e,u)).author);let m=Nt(s),p=await yt(e,c,[f],d,h,m);await St(e),await Ft(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await ne(e,t,b,f,p,`commit: ${w}`,g?.type==="symbolic");let y=g?.type==="symbolic"?Pe(g.target):"detached HEAD",x=await mn(e,l.tree,c,d,h,d.timestamp!==h.timestamp||d.timezone!==h.timezone);return{stdout:`${Lt(y,p,s)}
775
+ ${x}`,stderr:"",exitCode:0}}function pw(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
776
776
 
777
777
  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
778
778
  changes made to ${c}`}return a+=`.
779
- `,a}oe();Ce();ie();pe();we();Rn();De();function $d(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:S().describe("Only remove from the index"),recursive:S().alias("r").describe("Allow recursive removal when a directory name is given"),force:S().alias("f").describe("Override the up-to-date check"),dryRun:S().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ve(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,h=await z(s),u=[],m=dt(s,r.cwd);for(let w of c){if(fr(w)){let C=[Ue(w,m)],E=h.entries.filter(y=>Ee(C,y.path));if(E.length===0)return T(`pathspec '${w}' did not match any files`);for(let y of E)u.push(y.path);continue}let b=Mt(r.cwd,w),k=rt(a,b);if((k==="."||k==="")&&(k=""),k.startsWith(".."))return T(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(b)&&!(await mt(r.fs,b)).isSymbolicLink&&(await mt(r.fs,b)).isDirectory){if(!l)return T(`not removing '${k}' recursively without -r`);let C=k===""?"":`${k}/`,E=h.entries.filter(y=>C===""||y.path.startsWith(C));if(E.length===0)return T(`pathspec '${w}' did not match any files`);for(let y of E)u.push(y.path)}else{if(!h.entries.some(E=>E.path===k))return T(`pathspec '${w}' did not match any files`);u.push(k)}}if(!d){let w=await gw(s,h,u,f);if(w)return w}if(n.dryRun){let w=u.map(k=>`rm '${k}'`);return{stdout:w.length>0?`${w.join(`
779
+ `,a}oe();Ce();ie();me();we();kn();De();function $d(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[K.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:I().describe("Only remove from the index"),recursive:I().alias("r").describe("Allow recursive removal when a directory name is given"),force:I().alias("f").describe("Override the up-to-date check"),dryRun:I().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,h=await z(s),u=[],m=dt(s,r.cwd);for(let w of c){if(fr(w)){let k=[Ue(w,m)],R=h.entries.filter(E=>Ee(k,E.path));if(R.length===0)return S(`pathspec '${w}' did not match any files`);for(let E of R)u.push(E.path);continue}let b=Mt(r.cwd,w),y=nt(a,b);if((y==="."||y==="")&&(y=""),y.startsWith(".."))return S(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(b)&&!(await mt(r.fs,b)).isSymbolicLink&&(await mt(r.fs,b)).isDirectory){if(!l)return S(`not removing '${y}' recursively without -r`);let k=y===""?"":`${y}/`,R=h.entries.filter(E=>k===""||E.path.startsWith(k));if(R.length===0)return S(`pathspec '${w}' did not match any files`);for(let E of R)u.push(E.path)}else{if(!h.entries.some(R=>R.path===y))return S(`pathspec '${w}' did not match any files`);u.push(y)}}if(!d){let w=await gw(s,h,u,f);if(w)return w}if(n.dryRun){let w=u.map(y=>`rm '${y}'`);return{stdout:w.length>0?`${w.join(`
780
780
  `)}
781
- `:"",stderr:"",exitCode:0}}let p=[];for(let w of u){if(h=ft(h,w),!f){let b=v(a,w);await mt(r.fs,b).then(()=>!0).catch(()=>!1)&&await r.fs.rm(b)}p.push(`rm '${w}'`)}return await ae(s,h),{stdout:p.length>0?`${p.join(`
781
+ `:"",stderr:"",exitCode:0}}let p=[];for(let w of u){if(h=ct(h,w),!f){let b=v(a,w);await mt(r.fs,b).then(()=>!0).catch(()=>!1)&&await r.fs.rm(b)}p.push(`rm '${w}'`)}return await ae(s,h),{stdout:p.length>0?`${p.join(`
782
782
  `)}
783
- `:"",stderr:"",exitCode:0}}})}async function gw(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await j(e,o),l=await qe(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(m=>m.path===f&&m.stage===0);if(!l)continue;let h=s.get(f)!==l.hash,u=!1;if(e.workTree){let m=v(e.workTree,f),p=!1;try{await mt(e.fs,m),p=!0}catch{p=!1}p&&(u=await Bn(e.fs,m)!==l.hash)}h&&u?i.push(f):h&&!r?a.push(f):u&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
783
+ `:"",stderr:"",exitCode:0}}})}async function gw(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await G(e,o),l=await qe(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(m=>m.path===f&&m.stage===0);if(!l)continue;let h=s.get(f)!==l.hash,u=!1;if(e.workTree){let m=v(e.workTree,f),p=!1;try{await mt(e.fs,m),p=!0}catch{p=!1}p&&(u=await Un(e.fs,m)!==l.hash)}h&&u?i.push(f):h&&!r?a.push(f):u&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
784
784
  `),l=i.length===1?"the following file has":"the following files have";return _(`error: ${l} staged content different from both the
785
785
  file and the HEAD:
786
786
  ${f}
@@ -793,87 +793,87 @@ ${f}
793
793
  `),l=c.length===1?"the following file has":"the following files have";return _(`error: ${l} local modifications:
794
794
  ${f}
795
795
  (use --cached to keep the file, or -f to force removal)
796
- `)}return null}oe();ie();fn();no();pe();De();var Sa=new TextDecoder;function Od(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:S().alias("p").describe("Show diff in patch format"),noPatch:S().describe("Suppress diff output"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name")},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=to(a);if(c)return ww(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await bt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await ye(s,f),d;n.noPatch?d=null:n.stat?d="stat":n.nameOnly?d="name-only":n.nameStatus?d="name-status":n.shortstat?d="shortstat":n.numstat?d="numstat":d="patch";let h=n.format??n.pretty,u=null,m=null;if(h!==void 0){let p=Yo(h);u=p.formatStr,m=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await Id(s,f,p,d,u,m),stderr:"",exitCode:0}}case"tag":{let p=await _c(s,f);return{stdout:await bw(s,p,d,u,m),stderr:"",exitCode:0}}case"tree":{let p=xn(l.content);return{stdout:Sd(p),stderr:"",exitCode:0}}case"blob":return{stdout:Sa.decode(l.content),stderr:"",exitCode:0}}}})}async function ww(e,t,n){let r=await Le(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await de(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=v(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return T(f)}let c=await ye(e,a.hash);if(c.type==="blob")return{stdout:Sa.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=xn(c.content);return{stdout:Sd(f),stderr:"",exitCode:0}}return{stdout:Sa.decode(c.content),stderr:"",exitCode:0}}async function Id(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Is(o,{hash:t,commit:n});else if(s!==null)i=Ss(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>Z(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${In(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
796
+ `)}return null}oe();ie();cn();no();me();De();var Sa=new TextDecoder;function Od(e,t){e.command("show",{description:"Show various types of objects",args:[K.string().name("object").variadic().optional()],options:{patch:I().alias("p").describe("Show diff in patch format"),noPatch:I().describe("Suppress diff output"),stat:I().describe("Show diffstat summary"),nameOnly:I().describe("Show only names of changed files"),nameStatus:I().describe("Show names and status of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o,a=n.object[0]??"HEAD",c=to(a);if(c)return ww(s,c.rev,c.path);if(a==="HEAD"){let p=await Je(s);if(j(p))return p}let f=await bt(s,a,`bad object '${a}'`);if(j(f))return f;let l=await ye(s,f),d;n.noPatch?d=null:n.stat?d="stat":n.nameOnly?d="name-only":n.nameStatus?d="name-status":n.shortstat?d="shortstat":n.numstat?d="numstat":d="patch";let h=n.format??n.pretty,u=null,m=null;if(h!==void 0){let p=Yo(h);u=p.formatStr,m=p.preset}switch(l.type){case"commit":{let p=await G(s,f);return{stdout:await Id(s,f,p,d,u,m),stderr:"",exitCode:0}}case"tag":{let p=await _c(s,f);return{stdout:await bw(s,p,d,u,m),stderr:"",exitCode:0}}case"tree":{let p=Rn(l.content);return{stdout:Sd(p),stderr:"",exitCode:0}}case"blob":return{stdout:Sa.decode(l.content),stderr:"",exitCode:0}}}})}async function ww(e,t,n){let r=await Le(e,t);if(j(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await de(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=v(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return S(f)}let c=await ye(e,a.hash);if(c.type==="blob")return{stdout:Sa.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=Rn(c.content);return{stdout:Sd(f),stderr:"",exitCode:0}}return{stdout:Sa.decode(c.content),stderr:"",exitCode:0}}async function Id(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Ss(o,{hash:t,commit:n});else if(s!==null)i=Ts(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>Z(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${On(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
797
797
  `))c.push(` ${l}`);i=c.join(`
798
798
  `)}if(!r)return`${i}
799
- `;let a="";if(n.parents.length<=1){let c=n.parents.length===1?(await j(e,n.parents[0])).tree:null,f=await Ke(e,c,n.tree),{remaining:l,renames:d}=await ot(e,f);a=await yw(e,l,d,r)}else r==="patch"&&(a=await Iw(e,n)??"");return a?`${i}
799
+ `;let a="";if(n.parents.length<=1){let c=n.parents.length===1?(await G(e,n.parents[0])).tree:null,f=await Ve(e,c,n.tree),{remaining:l,renames:d}=await st(e,f);a=await yw(e,l,d,r)}else r==="patch"&&(a=await Iw(e,n)??"");return a?`${i}
800
800
 
801
801
  ${a.replace(/\n$/,"")}
802
802
  `:n.parents.length>=2?`${i}
803
803
 
804
804
  `:`${i}
805
- `}async function bw(e,t,n="patch",r=null,o=null){let s=[];s.push(`tag ${t.name}`),s.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),s.push(`Date: ${In(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
806
- `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await Id(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
805
+ `}async function bw(e,t,n="patch",r=null,o=null){let s=[];s.push(`tag ${t.name}`),s.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),s.push(`Date: ${On(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
806
+ `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await G(e,t.object),c=await Id(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
807
807
  `)}
808
808
  `}function Sd(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(`
809
809
  `)}
810
810
  `:""}async function yw(e,t,n,r){switch(r){case"patch":return Ow(e,t,n);case"stat":return Rw(e,t,n);case"shortstat":return xw(e,t,n);case"numstat":return Cw(e,t,n);case"name-only":return Ew(t,n);case"name-status":return kw(t,n);default:return""}}function Ew(e,t){let n=[];for(let r of e)n.push(r.path);for(let r of t)n.push(r.newPath);return n.sort(),n.length>0?`${n.join(`
811
811
  `)}
812
812
  `:""}function kw(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.length>0?n.map(r=>`${r.line}
813
- `).join(""):""}async function Rw(e,t,n){let{fileStats:r}=await tr(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),mr(r)}async function xw(e,t,n){let{fileStats:r}=await tr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=er(r.length,o,s);return i?`${i}
814
- `:""}async function Cw(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 re(e,s.oldHash):"",a=s.newHash?await re(e,s.newHash):"";if(He(i)||He(a))o+=`- - ${s.display}
815
- `;else{let c=xt(i),f=xt(a),l=at(c,f),d=0,h=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&h++;o+=`${d} ${h} ${s.display}
816
- `}}return o}async function Pw(e,t){let n=t.oldHash?await re(e,t.oldHash):"",r=t.newHash?await re(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function $w(e,t){let n=t.oldHash?await re(e,t.oldHash):"",r=t.newHash?await re(e,t.newHash):"";return Ht({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 Ow(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 $w(e,s.entry):o+=await Pw(e,s.entry);return o}async function Iw(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 de(e,c.tree)})),r=await de(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 Sw(e,a,n,r);return i}async function Sw(e,t,n,r){let o=r.get(t),s=n.map(h=>h.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(h=>h?.hash??null),f=s.map(h=>h?.mode??null),l=await Promise.all(c.map(async h=>h?await re(e,h):"")),d=i?await re(e,i):"";return Wo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}oe();Ce();ie();we();oe();Hn();Ce();ie();bn();pe();ze();we();Rn();De();Jt();tt();var nn="refs/stash";function va(e,t){return Te(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Td(e){let t=await et(e,nn),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 Br(e,t){let n=await et(e,nn);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 vd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await j(e,s),a=await z(e),c=Ne(a),f=await Fe(e,c),l=await Ke(e,i.tree,f),d=new Map(c.map(U=>[U.path,U])),h=await st(e,o,"",{skipIgnore:!0}),u=!1;for(let U of h){let N=d.get(U);if(!N)continue;let ne=v(o,U),V=await e.fs.readFileBuffer(ne);if(await gt("blob",V)!==N.hash){u=!0;break}}if(!u)for(let[U]of d){let N=v(o,U);if(!await e.fs.exists(N)){u=!0;break}}let m=[];if(r?.includeUntracked){let U=await st(e,o,"");for(let N of U)d.has(N)||m.push(N)}if(l.length===0&&!u&&m.length===0)return null;let p=await Fs(e,t),g=await Xr(e,t),w=await Q(e),b=w?.type==="symbolic"?Pe(w.target):"(no branch)",k=Z(s),R=ue(i.message),C=`index on ${b}: ${k} ${R}
817
- `,E=cn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:C}),y=await Se(e,"commit",E),x=await de(e,i.tree),$=[],A=new Set;for(let U of h){let N=d.get(U),ne=x.get(U);if(!N&&!ne)continue;let V=v(o,U),ee=await e.fs.readFileBuffer(V),ke=await Se(e,"blob",ee),_e=N?N.mode:parseInt(ne?.mode??"100644",8);$.push({path:U,mode:_e,hash:ke,stage:0,stat:ve()}),A.add(U)}for(let[U,N]of d)if(!A.has(U)){if(Un(N.mode)){$.push({path:U,mode:N.mode,hash:N.hash,stage:0,stat:ve()});continue}x.has(U)||$.push({path:U,mode:N.mode,hash:N.hash,stage:0,stat:ve()})}let P=await Fe(e,$),O=null;if(r?.includeUntracked){let U=[];for(let ee of m){let ke=v(o,ee),_e=await e.fs.readFileBuffer(ke),ce=await Se(e,"blob",_e);U.push({path:ee,mode:33188,hash:ce,stage:0,stat:ve()})}let N=await Fe(e,U),ne=`untracked files on ${b}: ${k} ${R}
818
- `,V=cn({type:"commit",tree:N,parents:[],author:p,committer:g,message:ne});O=await Se(e,"commit",V)}let D=n?`On ${b}: ${n}`:`WIP on ${b}: ${k} ${R}`,L=[s,y];O&&L.push(O);let K=cn({type:"commit",tree:P,parents:L,author:p,committer:g,message:D}),I=await Se(e,"commit",K),H=await Br(e,0)??te;await Je(e,nn,{oldHash:H,newHash:I,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:D.trimEnd()}),await J(e,nn,I);let G=await Pn(e,i.tree,a);await ae(e,{version:2,entries:G.newEntries}),await je(e,G.worktreeOps),(await Q(e))?.type==="symbolic"&&await se(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let U of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await me(e,U);for(let U of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let N=v(e.gitDir,U);await e.fs.exists(N)&&await e.fs.rm(N)}if(m.length>0)for(let U of m){if(x.has(U))continue;let N=v(o,U);await e.fs.exists(N)&&(await e.fs.rm(N),await ar(e.fs,rn(N),o))}return I}async function Ta(e,t){let n=e.workTree,r=await j(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=v(n,i.path);await e.fs.exists(a)?s.push(i.path):await lt(e,i)}return s.length>0?(s.sort(va),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
813
+ `).join(""):""}async function Rw(e,t,n){let{fileStats:r}=await er(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),mr(r)}async function xw(e,t,n){let{fileStats:r}=await er(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Qn(r.length,o,s);return i?`${i}
814
+ `:""}async function Cw(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:hn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(He(i)||He(a))o+=`- - ${s.display}
815
+ `;else{let c=xt(i),f=xt(a),l=it(c,f),d=0,h=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&h++;o+=`${d} ${h} ${s.display}
816
+ `}}return o}async function Pw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function $w(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Ht({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 Ow(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 $w(e,s.entry):o+=await Pw(e,s.entry);return o}async function Iw(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await G(e,a);return de(e,c.tree)})),r=await de(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 Sw(e,a,n,r);return i}async function Sw(e,t,n,r){let o=r.get(t),s=n.map(h=>h.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(h=>h?.hash??null),f=s.map(h=>h?.mode??null),l=await Promise.all(c.map(async h=>h?await se(e,h):"")),d=i?await se(e,i):"";return Wo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}oe();Ce();ie();we();oe();nr();Ce();ie();wn();me();Ke();we();kn();De();Jt();et();var nn="refs/stash";function va(e,t){return Te(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Td(e){let t=await Qe(e,nn),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 Wr(e,t){let n=await Qe(e,nn);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 vd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await G(e,s),a=await z(e),c=Ne(a),f=await Fe(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(U=>[U.path,U])),h=await rt(e,o,"",{skipIgnore:!0}),u=!1;for(let U of h){let N=d.get(U);if(!N)continue;let re=v(o,U),V=await e.fs.readFileBuffer(re);if(await gt("blob",V)!==N.hash){u=!0;break}}if(!u)for(let[U]of d){let N=v(o,U);if(!await e.fs.exists(N)){u=!0;break}}let m=[];if(r?.includeUntracked){let U=await rt(e,o,"");for(let N of U)d.has(N)||m.push(N)}if(l.length===0&&!u&&m.length===0)return null;let p=await Us(e,t),g=await Zr(e,t),w=await Q(e),b=w?.type==="symbolic"?Pe(w.target):"(no branch)",y=Z(s),x=ue(i.message),k=`index on ${b}: ${y} ${x}
817
+ `,R=an({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),E=await Se(e,"commit",R),C=await de(e,i.tree),$=[],D=new Set;for(let U of h){let N=d.get(U),re=C.get(U);if(!N&&!re)continue;let V=v(o,U),ee=await e.fs.readFileBuffer(V),ke=await Se(e,"blob",ee),_e=N?N.mode:parseInt(re?.mode??"100644",8);$.push({path:U,mode:_e,hash:ke,stage:0,stat:ve()}),D.add(U)}for(let[U,N]of d)if(!D.has(U)){if(Fn(N.mode)){$.push({path:U,mode:N.mode,hash:N.hash,stage:0,stat:ve()});continue}C.has(U)||$.push({path:U,mode:N.mode,hash:N.hash,stage:0,stat:ve()})}let P=await Fe(e,$),T=null;if(r?.includeUntracked){let U=[];for(let ee of m){let ke=v(o,ee),_e=await e.fs.readFileBuffer(ke),ce=await Se(e,"blob",_e);U.push({path:ee,mode:33188,hash:ce,stage:0,stat:ve()})}let N=await Fe(e,U),re=`untracked files on ${b}: ${y} ${x}
818
+ `,V=an({type:"commit",tree:N,parents:[],author:p,committer:g,message:re});T=await Se(e,"commit",V)}let H=n?`On ${b}: ${n}`:`WIP on ${b}: ${y} ${x}`,M=[s,E];T&&M.push(T);let W=an({type:"commit",tree:P,parents:M,author:p,committer:g,message:H}),O=await Se(e,"commit",W),A=await Wr(e,0)??te;await ft(e,nn,{oldHash:A,newHash:O,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:H.trimEnd()}),await J(e,nn,O);let L=await Cn(e,i.tree,a);await ae(e,{version:2,entries:L.newEntries}),await je(e,L.worktreeOps),(await Q(e))?.type==="symbolic"&&await ne(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let U of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,U);for(let U of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let N=v(e.gitDir,U);await e.fs.exists(N)&&await e.fs.rm(N)}if(m.length>0)for(let U of m){if(C.has(U))continue;let N=v(o,U);await e.fs.exists(N)&&(await e.fs.rm(N),await ar(e.fs,rn(N),o))}return O}async function Ta(e,t){let n=e.workTree,r=await G(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=v(n,i.path);await e.fs.exists(a)?s.push(i.path):await lt(e,i)}return s.length>0?(s.sort(va),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
819
819
  `)}
820
820
  error: could not restore untracked files from stash
821
821
  `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ha(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
822
- `,exitCode:128};let n=await Br(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
822
+ `,exitCode:128};let n=await Wr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
823
823
  `,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
824
- `,exitCode:1};let o=await z(e),s=Kt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(x=>`${x}: needs merge`).join(`
824
+ `,exitCode:1};let o=await z(e),s=zt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
825
825
  `)}
826
826
  `,stderr:`error: could not write index
827
- `,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)
828
- `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Ne(o),d=await Fe(e,l),h={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let y=await Ta(e,f);if(!y.ok)return{...y,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let u=await zt(e,c.tree,d,i.tree,h),m=await de(e,d),p=await de(e,u.resultTree),g=[];for(let[y,x]of p){let $=m.get(y);(!$||$.hash!==x.hash)&&g.push({path:y,type:"checkout",hash:x.hash,mode:parseInt(x.mode,8)})}for(let[y]of m)p.has(y)||g.push({path:y,type:"delete"});let w=new Map(l.map(y=>[y.path,y])),b=[],k=[];for(let y of g){let x=w.get(y.path),$=v(e.workTree,y.path);if(x){if(Un(x.mode)||!await e.fs.exists($))continue;let A=await e.fs.readFileBuffer($);await gt("blob",A)!==x.hash&&b.push(y.path)}else y.type==="checkout"&&await e.fs.exists($)&&k.push(y.path)}if(b.length>0||k.length>0){b.sort(va),k.sort(va);let y="";if(b.length>0&&(y+=`error: Your local changes to the following files would be overwritten by merge:
829
- ${b.map(x=>` ${x}`).join(`
827
+ `,exitCode:1};let i=await G(e,n),a=i.parents[0];if(!a)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
828
+ `,exitCode:1};let c=await G(e,a),f=i.parents[2],l=Ne(o),d=await Fe(e,l),h={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let E=await Ta(e,f);if(!E.ok)return{...E,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let u=await Kt(e,c.tree,d,i.tree,h),m=await de(e,d),p=await de(e,u.resultTree),g=[];for(let[E,C]of p){let $=m.get(E);(!$||$.hash!==C.hash)&&g.push({path:E,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[E]of m)p.has(E)||g.push({path:E,type:"delete"});let w=new Map(l.map(E=>[E.path,E])),b=[],y=[];for(let E of g){let C=w.get(E.path),$=v(e.workTree,E.path);if(C){if(Fn(C.mode)||!await e.fs.exists($))continue;let D=await e.fs.readFileBuffer($);await gt("blob",D)!==C.hash&&b.push(E.path)}else E.type==="checkout"&&await e.fs.exists($)&&y.push(E.path)}if(b.length>0||y.length>0){b.sort(va),y.sort(va);let E="";if(b.length>0&&(E+=`error: Your local changes to the following files would be overwritten by merge:
829
+ ${b.map(C=>` ${C}`).join(`
830
830
  `)}
831
831
  Please commit your changes or stash them before you merge.
832
- `),k.length>0&&(y+=`error: The following untracked working tree files would be overwritten by merge:
833
- ${k.map(x=>` ${x}`).join(`
832
+ `),y.length>0&&(E+=`error: The following untracked working tree files would be overwritten by merge:
833
+ ${y.map(C=>` ${C}`).join(`
834
834
  `)}
835
835
  Please move or remove them before you merge.
836
- `),y+=`Aborting
837
- `,f){let x=await Ta(e,f);x.ok||(y+=x.stderr)}return{ok:!1,stdout:"",stderr:y,exitCode:1}}await je(e,g);let R=new Set(u.conflicts.map(y=>y.path)),C=new Set;for(let y of u.entries)y.stage>0&&C.add(y.path);let E=R.size>0;if(E){let y=[];for(let[x,$]of p){if(R.has(x)||C.has(x))continue;let A=w.get(x);y.push({path:x,mode:parseInt($.mode,8),hash:$.hash,stage:0,stat:A?.stat??ve()})}for(let x of u.entries)x.stage>0&&y.push(x);y.sort((x,$)=>Te(x.path,$.path)||x.stage-$.stage),await ae(e,{version:2,entries:y})}else{let y=[...o.entries],x=new Set(y.map($=>$.path));for(let[$,A]of p)m.has($)||x.has($)||y.push({path:$,mode:parseInt(A.mode,8),hash:A.hash,stage:0,stat:ve()});y.sort(($,A)=>Te($.path,A.path)||$.stage-A.stage),await ae(e,{version:2,entries:y})}if(f){let y=await Ta(e,f);if(!y.ok)return{...y,messages:u.messages}}return{ok:!0,hasConflicts:E,messages:u.messages}}async function Aa(e,t=0){let n=await et(e,nn);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 me(e,nn),await as(e,nn);else{await Fn(e,nn,n);let o=n[n.length-1];o&&await J(e,nn,o.newHash)}return null}async function Hd(e){await me(e,nn),await as(e,nn)}De();function Qo(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 Tw(e,t){let n=t.oldHash?await re(e,t.oldHash):"",r=t.newHash?await re(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function Dd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:Ad(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:Ad(s,o.env,r.message,r["include-untracked"])}}),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);return M(s)?s:vw(s,r.stash)}}),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);return M(s)?s:Hw(s,r.stash)}}),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);return M(s)?s:Aw(s)}}),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);return M(s)?s:Dw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:S().alias("p").describe("Show full diff (default is --stat)")},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);return M(s)?s:Mw(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:jw(s)}})}async function Ad(e,t,n,r){if(!await X(e))return _(`You do not have the initial commit yet
838
- `);let s=await z(e),i=Kt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
836
+ `),E+=`Aborting
837
+ `,f){let C=await Ta(e,f);C.ok||(E+=C.stderr)}return{ok:!1,stdout:"",stderr:E,exitCode:1}}await je(e,g);let x=new Set(u.conflicts.map(E=>E.path)),k=new Set;for(let E of u.entries)E.stage>0&&k.add(E.path);let R=x.size>0;if(R){let E=[];for(let[C,$]of p){if(x.has(C)||k.has(C))continue;let D=w.get(C);E.push({path:C,mode:parseInt($.mode,8),hash:$.hash,stage:0,stat:D?.stat??ve()})}for(let C of u.entries)C.stage>0&&E.push(C);E.sort((C,$)=>Te(C.path,$.path)||C.stage-$.stage),await ae(e,{version:2,entries:E})}else{let E=[...o.entries],C=new Set(E.map($=>$.path));for(let[$,D]of p)m.has($)||C.has($)||E.push({path:$,mode:parseInt(D.mode,8),hash:D.hash,stage:0,stat:ve()});E.sort(($,D)=>Te($.path,D.path)||$.stage-D.stage),await ae(e,{version:2,entries:E})}if(f){let E=await Ta(e,f);if(!E.ok)return{...E,messages:u.messages}}return{ok:!0,hasConflicts:R,messages:u.messages}}async function Aa(e,t=0){let n=await Qe(e,nn);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 he(e,nn),await cs(e,nn);else{await _n(e,nn,n);let o=n[n.length-1];o&&await J(e,nn,o.newHash)}return null}async function Hd(e){await he(e,nn),await cs(e,nn)}De();function Qo(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 Tw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function Dd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":I().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 q(o.fs,o.cwd,t);return j(s)?s:Ad(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":I().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:Ad(s,o.env,r.message,r["include-untracked"])}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:vw(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:Hw(s,r.stash)}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:Aw(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:Dw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:I().alias("p").describe("Show full diff (default is --stat)")},args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:Mw(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return j(s)?s:jw(s)}})}async function Ad(e,t,n,r){if(!await X(e))return _(`You do not have the initial commit yet
838
+ `);let s=await z(e),i=zt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
839
839
  `)}
840
840
  `,stderr:`error: could not write index
841
- `,exitCode:1};let a;try{a=await vd(e,t,n,{includeUntracked:r})}catch(l){return T(l.message)}return a?{stdout:`Saved working directory and index state ${(await j(e,a)).message.trim()}
841
+ `,exitCode:1};let a;try{a=await vd(e,t,n,{includeUntracked:r})}catch(l){return S(l.message)}return a?{stdout:`Saved working directory and index state ${(await G(e,a)).message.trim()}
842
842
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
843
- `,stderr:"",exitCode:0}}async function vw(e,t){let n=Qo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Br(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Ha(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
843
+ `,stderr:"",exitCode:0}}async function vw(e,t){let n=Qo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Wr(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Ha(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
844
844
  `)}
845
845
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
846
- `,stderr:o.stderr,exitCode:o.exitCode};let l=await it(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
846
+ `,stderr:o.stderr,exitCode:o.exitCode};let l=await ot(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
847
847
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
848
848
  `)}
849
- `:"",l=await it(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
849
+ `:"",l=await ot(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
850
850
  `,stderr:"",exitCode:1}}let s=await Aa(e,n);if(s)return _(s);let i=o.messages.length>0?`${o.messages.join(`
851
851
  `)}
852
- `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await it(e);return{stdout:`${i}${c}Dropped ${a} (${r})
852
+ `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await ot(e);return{stdout:`${i}${c}Dropped ${a} (${r})
853
853
  `,stderr:"",exitCode:0}}async function Hw(e,t){let n=Qo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Ha(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
854
854
  `)}
855
- `:"",c=r.stdout;return c||(c=await it(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
855
+ `:"",c=r.stdout;return c||(c=await ot(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
856
856
  `)}
857
- `:"",s=await it(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Aw(e){let t=await Td(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
857
+ `:"",s=await ot(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Aw(e){let t=await Td(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
858
858
  `)}
859
- `,stderr:"",exitCode:0}}async function Dw(e,t){let n=Qo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Br(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Aa(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
860
- `,stderr:"",exitCode:0}}async function Mw(e,t,n){let r=Qo(t);if(r<0)return _(`error: '${t}' is not a valid stash reference`);let o=await Br(e,r);if(!o)return _(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return _("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ke(e,a.tree,s.tree),l="";for(let d of f)l+=await Tw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await gn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function jw(e){return await Hd(e),{stdout:"",stderr:"",exitCode:0}}oe();Be();Ce();we();tt();function Md(e,t){e.command("status",{description:"Show the working tree status",options:{short:S().alias("s").describe("Give the output in the short-format"),porcelain:S().describe("Give the output in a machine-parseable format"),branch:S().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await it(s),stderr:"",exitCode:0};let i=await Q(s),a=await X(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let k=await he(s),R=await Bt(s,k,c);f=Fw(c,R)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await z(s),d=Xi(l),h=await Yi(s,a,l,d),u=await wt(s,l),m=[],p=[];for(let k of u)k.status==="untracked"?p.push(k.path):m.push({path:k.path,status:k.status});m.sort((k,R)=>Te(k.path,R.path));let g=new Set(l.entries.map(k=>k.path)),w=Zi(p,g);return{stdout:_w(f,h,m,d,w),stderr:"",exitCode:0}}})}var Gw={"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 Lw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Nw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function _w(e,t,n,r,o){let s=[];e&&s.push(e);let i=new Map(r.map(d=>[d.path,d])),a=new Map(t.map(d=>[d.path,d])),c=new Map(n.map(d=>[d.path,d])),f=new Set;for(let d of r)f.add(d.path);for(let d of t)f.add(d.path);for(let d of n)f.add(d.path);let l=[...f].sort();for(let d of l){let h=i.get(d);if(h){let w=Gw[h.status]??"UU";s.push(`${w} ${Ts(d)}`);continue}let u=a.get(d),m=c.get(d),p=u?Lw(u.status):" ",g=m?Nw(m.status):" ";if(u?.status==="renamed"&&u.displayPath){let w=u.displayPath.indexOf(" -> "),b=u.displayPath.slice(0,w),k=u.displayPath.slice(w+4);s.push(`${p}${g} ${Ts(b)} -> ${Ts(k)}`)}else s.push(`${p}${g} ${Ts(d)}`)}for(let d of o)s.push(`?? ${Ts(d)}`);return s.length===0?"":`${s.join(`
859
+ `,stderr:"",exitCode:0}}async function Dw(e,t){let n=Qo(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Wr(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Aa(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
860
+ `,stderr:"",exitCode:0}}async function Mw(e,t,n){let r=Qo(t);if(r<0)return _(`error: '${t}' is not a valid stash reference`);let o=await Wr(e,r);if(!o)return _(`error: stash@{${r}} is not a valid reference`);let s=await G(e,o),i=s.parents[0];if(!i)return _("error: invalid stash commit (no parent)");let a=await G(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await Tw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await pn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function jw(e){return await Hd(e),{stdout:"",stderr:"",exitCode:0}}oe();Be();Ce();we();et();function Md(e,t){e.command("status",{description:"Show the working tree status",options:{short:I().alias("s").describe("Give the output in the short-format"),porcelain:I().describe("Give the output in a machine-parseable format"),branch:I().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await ot(s),stderr:"",exitCode:0};let i=await Q(s),a=await X(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let y=await pe(s),x=await Bt(s,y,c);f=Fw(c,x)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await z(s),d=Xi(l),h=await Yi(s,a,l,d),u=await wt(s,l),m=[],p=[];for(let y of u)y.status==="untracked"?p.push(y.path):m.push({path:y.path,status:y.status});m.sort((y,x)=>Te(y.path,x.path));let g=new Set(l.entries.map(y=>y.path)),w=Zi(p,g);return{stdout:_w(f,h,m,d,w),stderr:"",exitCode:0}}})}var Gw={"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 Lw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Nw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function _w(e,t,n,r,o){let s=[];e&&s.push(e);let i=new Map(r.map(d=>[d.path,d])),a=new Map(t.map(d=>[d.path,d])),c=new Map(n.map(d=>[d.path,d])),f=new Set;for(let d of r)f.add(d.path);for(let d of t)f.add(d.path);for(let d of n)f.add(d.path);let l=[...f].sort();for(let d of l){let h=i.get(d);if(h){let w=Gw[h.status]??"UU";s.push(`${w} ${vs(d)}`);continue}let u=a.get(d),m=c.get(d),p=u?Lw(u.status):" ",g=m?Nw(m.status):" ";if(u?.status==="renamed"&&u.displayPath){let w=u.displayPath.indexOf(" -> "),b=u.displayPath.slice(0,w),y=u.displayPath.slice(w+4);s.push(`${p}${g} ${vs(b)} -> ${vs(y)}`)}else s.push(`${p}${g} ${vs(d)}`)}for(let d of o)s.push(`?? ${vs(d)}`);return s.length===0?"":`${s.join(`
861
861
  `)}
862
- `}function Fw(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=ko(t,!1);return r?`${n} ${r}`:n}function Ts(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}oe();Be();Ce();ie();ze();we();De();Jt();function Uw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??te}function Gd(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:Y.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Y.string().alias("C").describe("Create/reset and switch to a branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:Y.string().describe("Create a new orphan branch"),guess:S().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await 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?T("--orphan and -c/-C are incompatible"):n.detach?T("--orphan and --detach are incompatible"):qw(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return T("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await Le(i,l,`invalid reference: ${l}`);return M(d)?d:Ww(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 jd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return T("missing branch or commit argument");if(a==="-")return Bw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Ld(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await Oo(i,a);if(l)return jd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return T(`invalid reference: ${a}`)}})}async function vs(e){return await $e(e,"CHERRY_PICK_HEAD")?T(`cannot switch branch while cherry-picking
863
- Consider "git cherry-pick --quit" or "git worktree add".`):await $e(e,"MERGE_HEAD")?T(`cannot switch branch while merging
864
- Consider "git merge --quit" or "git worktree add".`):await $e(e,"REVERT_HEAD")?T(`cannot switch branch while reverting
865
- Consider "git revert --quit" or "git worktree add".`):await Ut(e)?T(`cannot switch branch while rebasing
866
- Consider "git rebase --quit" or "git worktree add".`):null}async function Bw(e,t,n){let r=await vs(e);if(r)return r;let o=await Ro(e);return o?Ld(e,o.name,o.refName,o.hash,t,n):T("no previous branch")}async function jd(e,t,n,r,o,s,i){if(!En(t))return T(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return T(`a branch named '${t}' already exists`);let f;if(r){let x=await Le(e,r,`invalid reference: ${r}`);if(M(x))return x;f=x.hash}else{let x=await X(e);if(!x){let $=await Q(e),A=$?.type==="symbolic"?$.target.replace(/^refs\/heads\//,""):"";n&&c&&await me(e,a),await Ze(e,"HEAD",a),await Et(e);let P=await On(e);return await se(e,o,"HEAD",null,te,`checkout: moving from ${A} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
867
- ${P}`,exitCode:0}}f=x}let l=await vs(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(d))return{stdout:"",stderr:d.message??"",exitCode:1};let h=await X(e),u=await z(e);if(r){let x=Yn(u);if(x)return x}let m=await j(e,f);if(h&&h!==f){let x=await j(e,h);if(x.tree!==m.tree){let $=await Wn(e,x.tree,m.tree,u);if(!$.success)return $.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:$.newEntries},await ae(e,u),await je(e,$.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&h&&(g=await Po(e,h,f));let w=Uw(p,h);await J(e,a,f),await Ze(e,"HEAD",a),await Et(e);let b=await On(e),k=r??"HEAD";n&&c?c!==f&&await se(e,o,a,c,f,`branch: Reset to ${k}`):await se(e,o,a,null,f,`branch: Created from ${k}`),await se(e,o,"HEAD",h,f,`checkout: moving from ${w} to ${t}`);let R="";if(i){let x=i.replace(/^refs\/remotes\//,"").split("/"),$=x[0]??"",A=`refs/heads/${x.slice(1).join("/")}`,P=await he(e);P[`branch "${t}"`]={...P[`branch "${t}"`],remote:$,merge:A},await Xe(e,P),R=`branch '${t}' set up to track '${$}/${x.slice(1).join("/")}'.
868
- `}else r&&(R=await $o(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:h,newHead:f,isBranchCheckout:!0});let C=n&&c?`Switched to and reset branch '${t}'
862
+ `}function Fw(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=ko(t,!1);return r?`${n} ${r}`:n}function vs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}oe();Be();Ce();ie();Ke();we();De();Jt();function Uw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??te}function Gd(e,t){e.command("switch",{description:"Switch branches",args:[K.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:Y.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Y.string().alias("C").describe("Create/reset and switch to a branch"),detach:I().alias("d").describe("Detach HEAD at named commit"),orphan:Y.string().describe("Create a new orphan branch"),guess:I().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(j(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?S("--orphan and -c/-C are incompatible"):n.detach?S("--orphan and --detach are incompatible"):qw(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return S("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await Le(i,l,`invalid reference: ${l}`);return j(d)?d:Ww(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 jd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return S("missing branch or commit argument");if(a==="-")return Bw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Ld(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await Oo(i,a);if(l)return jd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return S(`invalid reference: ${a}`)}})}async function Hs(e){return await $e(e,"CHERRY_PICK_HEAD")?S(`cannot switch branch while cherry-picking
863
+ Consider "git cherry-pick --quit" or "git worktree add".`):await $e(e,"MERGE_HEAD")?S(`cannot switch branch while merging
864
+ Consider "git merge --quit" or "git worktree add".`):await $e(e,"REVERT_HEAD")?S(`cannot switch branch while reverting
865
+ Consider "git revert --quit" or "git worktree add".`):await Ut(e)?S(`cannot switch branch while rebasing
866
+ Consider "git rebase --quit" or "git worktree add".`):null}async function Bw(e,t,n){let r=await Hs(e);if(r)return r;let o=await Ro(e);return o?Ld(e,o.name,o.refName,o.hash,t,n):S("no previous branch")}async function jd(e,t,n,r,o,s,i){if(!yn(t))return S(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return S(`a branch named '${t}' already exists`);let f;if(r){let C=await Le(e,r,`invalid reference: ${r}`);if(j(C))return C;f=C.hash}else{let C=await X(e);if(!C){let $=await Q(e),D=$?.type==="symbolic"?$.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Ze(e,"HEAD",a),await Et(e);let P=await $n(e);return await ne(e,o,"HEAD",null,te,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
867
+ ${P}`,exitCode:0}}f=C}let l=await Hs(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(d))return{stdout:"",stderr:d.message??"",exitCode:1};let h=await X(e),u=await z(e);if(r){let C=Vn(u);if(C)return C}let m=await G(e,f);if(h&&h!==f){let C=await G(e,h);if(C.tree!==m.tree){let $=await Bn(e,C.tree,m.tree,u);if(!$.success)return $.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:$.newEntries},await ae(e,u),await je(e,$.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&h&&(g=await Po(e,h,f));let w=Uw(p,h);await J(e,a,f),await Ze(e,"HEAD",a),await Et(e);let b=await $n(e),y=r??"HEAD";n&&c?c!==f&&await ne(e,o,a,c,f,`branch: Reset to ${y}`):await ne(e,o,a,null,f,`branch: Created from ${y}`),await ne(e,o,"HEAD",h,f,`checkout: moving from ${w} to ${t}`);let x="";if(i){let C=i.replace(/^refs\/remotes\//,"").split("/"),$=C[0]??"",D=`refs/heads/${C.slice(1).join("/")}`,P=await pe(e);P[`branch "${t}"`]={...P[`branch "${t}"`],remote:$,merge:D},await ze(e,P),x=`branch '${t}' set up to track '${$}/${C.slice(1).join("/")}'.
868
+ `}else r&&(x=await $o(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:h,newHead:f,isBranchCheckout:!0});let k=n&&c?`Switched to and reset branch '${t}'
869
869
  `:`Switched to a new branch '${t}'
870
- `,E=g+C+b,y="";if(R)y=R;else if(r){y=await ur(e,m.tree,u);let x=await he(e),$=await Bt(e,x,t);$&&(y+=Vn($))}else if(n&&c){let x=await he(e),$=await Bt(e,x,t);$&&(y=Vn($))}return{stdout:y,stderr:E,exitCode:0}}async function Ld(e,t,n,r,o,s){let i=await vs(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(a)?{stdout:"",stderr:a.message??"",exitCode:1}:hr(e,t,n,r,o,s)}async function Ww(e,t,n,r,o){let s=await vs(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(i)?{stdout:"",stderr:i.message??"",exitCode:1}:Xn(e,n,r,o)}async function qw(e,t,n,r){if(!En(t))return T(`'${t}' is not a valid branch name`);let o=await vs(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return T(`a branch named '${t}' already exists`);let a=await z(e),c=Yn(a);if(c)return c;let f=await X(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Ji(e,f)),e.workTree){let u=f?(await j(e,f)).tree:null,m=await Fe(e,[]),p=await Wn(e,u,m,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await je(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,ic());await Ze(e,"HEAD",s),await Et(e);let h=await On(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:te,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
871
- ${h}`,exitCode:0}}oe();ie();Ir();we();ls();function _d(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:S().alias("a").describe("Make an annotated tag object"),message:Y.string().alias("m").describe("Tag message"),delete:S().alias("d").describe("Delete a tag"),force:S().alias("f").describe("Replace an existing tag"),list:S().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 T("tag name required");let i=`refs/tags/${n.name}`,a=await B(s,i);return a?(await me(s,i),{stdout:`Deleted tag '${n.name}' (was ${Z(a)})
870
+ `,R=g+k+b,E="";if(x)E=x;else if(r){E=await ur(e,m.tree,u);let C=await pe(e),$=await Bt(e,C,t);$&&(E+=zn($))}else if(n&&c){let C=await pe(e),$=await Bt(e,C,t);$&&(E=zn($))}return{stdout:E,stderr:R,exitCode:0}}async function Ld(e,t,n,r,o,s){let i=await Hs(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(a)?{stdout:"",stderr:a.message??"",exitCode:1}:hr(e,t,n,r,o,s)}async function Ww(e,t,n,r,o){let s=await Hs(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(i)?{stdout:"",stderr:i.message??"",exitCode:1}:Yn(e,n,r,o)}async function qw(e,t,n,r){if(!yn(t))return S(`'${t}' is not a valid branch name`);let o=await Hs(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return S(`a branch named '${t}' already exists`);let a=await z(e),c=Vn(a);if(c)return c;let f=await X(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Ji(e,f)),e.workTree){let u=f?(await G(e,f)).tree:null,m=await Fe(e,[]),p=await Bn(e,u,m,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await je(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,ic());await Ze(e,"HEAD",s),await Et(e);let h=await $n(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:te,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
871
+ ${h}`,exitCode:0}}oe();ie();Ir();we();ds();function _d(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[K.string().name("name").describe("Tag name to create or delete").optional(),K.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:I().alias("a").describe("Make an annotated tag object"),message:Y.string().alias("m").describe("Tag message"),delete:I().alias("d").describe("Delete a tag"),force:I().alias("f").describe("Replace an existing tag"),list:I().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(j(o))return o;let s=o;if(n.delete){if(!n.name)return S("tag name required");let i=`refs/tags/${n.name}`,a=await B(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${Z(a)})
872
872
  `,stderr:"",exitCode:0}):_(`error: tag '${n.name}' not found.
873
- `)}if(n.list)return Nd(s,n.name||void 0);if(n.name){if(!Uc(n.name))return T(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await bt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await X(s),!a)return T("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return T(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return T("no tag message specified (use -m)");let d=await nt(s,r.env);if(M(d))return d;let h=Nt(n.message),u=Lc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:h}),m=await Se(s,"tag",u);await J(s,c,m)}else await J(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Nd(s)}})}async function Nd(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=>ln(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
873
+ `)}if(n.list)return Nd(s,n.name||void 0);if(n.name){if(!Uc(n.name))return S(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await bt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(j(d))return d;a=d}else if(a=await X(s),!a)return S("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return S(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return S("no tag message specified (use -m)");let d=await tt(s,r.env);if(j(d))return d;let h=Nt(n.message),u=Lc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:h}),m=await Se(s,"tag",u);await J(s,c,m)}else await J(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Nd(s)}})}async function Nd(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=>fn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
874
874
  `)}
875
- `,stderr:"",exitCode:0}}var Fd=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),zw={init:(e,t)=>Xl(e,t),clone:(e,t)=>xl(e,t),describe:(e,t)=>Pl(e,t),fetch:(e,t)=>Fl(e,t),pull:(e,t)=>pd(e,t),push:(e,t)=>wd(e,t),add:(e,t)=>df(e,t),blame:(e,t)=>Wf(e,t),commit:(e,t)=>$l(e,t),status:(e,t)=>Md(e,t),log:(e,t)=>id(e,t),branch:(e,t)=>zf(e,t),tag:(e,t)=>_d(e,t),checkout:(e,t)=>Vf(e,t),diff:(e,t)=>jl(e,t),reset:(e,t)=>kd(e,t),merge:(e,t)=>fd(e,t),"cherry-pick":(e,t)=>cl(e,t),revert:(e,t)=>Pd(e,t),rebase:(e,t)=>md(e,t),mv:(e,t)=>ld(e,t),rm:(e,t)=>$d(e,t),remote:(e,t)=>yd(e,t),config:(e,t)=>Tl(e,t),show:(e,t)=>Od(e,t),stash:(e,t)=>Dd(e,t),"rev-parse":(e,t)=>Cd(e,t),"ls-files":(e,t)=>cd(e,t),clean:(e,t)=>fl(e,t),switch:(e,t)=>Gd(e,t),restore:(e,t)=>xd(e,t),reflog:(e,t)=>bd(e,t),repack:(e,t)=>Wl(e,t),gc:(e,t)=>ql(e,t),bisect:(e,t)=>Tf(e,t),grep:(e,t)=>Yl(e,t)};function Ud(e){let t=ai("git",{description:"Git command"});for(let n of Object.values(zw))n(t,e);return t.command("help",{description:"Display help information",args:[q.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Rr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Rr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
876
- `,exitCode:1}}}),t}var Kw="1.5.9";function Vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var ei=class{name="git";defaultFs;defaultCwd;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.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=Vw(t?.identity,t?.config),o=t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},s={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,credentialCache:new Map,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...o,...r?{configOverrides:r}:{}};this.inner=Ud(s).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Yw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${Kw} (virtual git implementation)
875
+ `,stderr:"",exitCode:0}}var Fd=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),Kw={init:(e,t)=>Xl(e,t),clone:(e,t)=>xl(e,t),describe:(e,t)=>Pl(e,t),fetch:(e,t)=>Fl(e,t),pull:(e,t)=>pd(e,t),push:(e,t)=>wd(e,t),add:(e,t)=>df(e,t),blame:(e,t)=>Wf(e,t),commit:(e,t)=>$l(e,t),status:(e,t)=>Md(e,t),log:(e,t)=>id(e,t),branch:(e,t)=>Kf(e,t),tag:(e,t)=>_d(e,t),checkout:(e,t)=>Vf(e,t),diff:(e,t)=>jl(e,t),reset:(e,t)=>kd(e,t),merge:(e,t)=>fd(e,t),"cherry-pick":(e,t)=>cl(e,t),revert:(e,t)=>Pd(e,t),rebase:(e,t)=>md(e,t),mv:(e,t)=>ld(e,t),rm:(e,t)=>$d(e,t),remote:(e,t)=>yd(e,t),config:(e,t)=>Tl(e,t),show:(e,t)=>Od(e,t),stash:(e,t)=>Dd(e,t),"rev-parse":(e,t)=>Cd(e,t),"ls-files":(e,t)=>cd(e,t),clean:(e,t)=>fl(e,t),switch:(e,t)=>Gd(e,t),restore:(e,t)=>xd(e,t),reflog:(e,t)=>bd(e,t),repack:(e,t)=>Wl(e,t),gc:(e,t)=>ql(e,t),bisect:(e,t)=>Tf(e,t),grep:(e,t)=>Yl(e,t)};function Ud(e){let t=ai("git",{description:"Git command"});for(let n of Object.values(Kw))n(t,e);return t.command("help",{description:"Display help information",args:[K.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Rr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Rr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
876
+ `,exitCode:1}}}),t}var zw="1.5.11";function Vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var ei=class{name="git";defaultFs;defaultCwd;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.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=Vw(t?.identity,t?.config),o=t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},s={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,credentialCache:new Map,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...o,...r?{configOverrides:r}:{}};this.inner=Ud(s).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Yw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${zw} (virtual git implementation)
877
877
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
878
878
  `,exitCode:1};if(r&&Fd.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
879
- `,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(fe(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 Yw(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 Xw(e){return new ei(e)}var Bd=new TextEncoder,Zw=new TextDecoder;function wn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function ti(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Da=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=wn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Bd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=ti(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 wn(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("/")?wn(a):wn(ti(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=wn(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("/")?wn(f):wn(ti(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Zw.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"?Bd.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=wn(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=ti(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=wn(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=wn(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{ei as Git,Da as MemoryFileSystem,qm as composeGitHooks,Xw as createGit,or as findRepo,fe as isRejection};
879
+ `,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(fe(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 Yw(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 Xw(e){return new ei(e)}var Bd=new TextEncoder,Zw=new TextDecoder;function gn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function ti(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Da=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=gn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Bd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=ti(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 gn(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("/")?gn(a):gn(ti(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=gn(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("/")?gn(f):gn(ti(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Zw.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"?Bd.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=gn(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=ti(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=gn(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=gn(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})}};Nn();export{ei as Git,Da as MemoryFileSystem,qm as composeGitHooks,Xw as createGit,or as findRepo,fe as isRejection};