just-git 1.5.7 → 1.5.8

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,16 +1,16 @@
1
- var Ad=Object.defineProperty;var Ss=(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 Hd=(e,t)=>{for(var n in t)Ad(e,n,{get:t[n],enumerable:!0})};function Hs(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 H(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Hs(t)}function Ht(...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 Hs(t||".")}function tn(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 Br(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function st(e,t){let n=Hs(e),r=Hs(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,m=s.slice(f),u=[];for(let h=0;h<d;h++)u.push("..");for(let h of m)u.push(h);return u.join("/")||"."}var me=Re(()=>{"use strict"});function Jo(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 La(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 m=c[f+1];switch(l(),m){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
2
- `;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=m;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 Ld(e){let t={},n=null,r=e.split(`
3
- `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=Jo(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:m}=La(l,r,o);a[f]=d,o+=m}continue}o++}return t}function Qo(e){let t={},n=null,r=e.split(`
4
- `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=Jo(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:m}=La(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=m}continue}o++}return t}function ei(e){let t=/[\n\t\b#;"]/.test(e)||e!==e.trim(),n="";for(let r=0;r<e.length;r++){let o=e[r];switch(o){case"\\":n+="\\\\";break;case'"':n+='\\"';break;case`
5
- `:n+="\\n";break;case" ":n+="\\t";break;case"\b":n+="\\b";break;default:n+=o}}return t?`"${n}"`:n}function ti(e){let t=[];for(let[n,r]of Object.entries(e)){t.push(`[${n}]`);for(let[o,s]of Object.entries(r))t.push(` ${o} = ${ei(s)}`)}return`${t.join(`
6
- `)}
7
- `}function ni(e,t,n){let r=null,o=-1,s=-1,i=-1,a=-1,c=!1,f=0;for(;f<e.length;){let l=e[f].trim();if(!l||l.startsWith("#")||l.startsWith(";")){f++;continue}if(l.startsWith("[")){r=Jo(l),r===t&&(a=f,i=f,c=!1),f++;continue}let d=f;for(;d<e.length-1&&e[d].replace(/\r$/,"").endsWith("\\");)d++;if(r===t){let m=l.indexOf("=");(m===-1?l.toLowerCase():l.slice(0,m).trim().toLowerCase())===n?(o=f,s=d):c=!0,i=d}f=d+1}return{keyStart:o,keyEnd:s,insertAfter:i,sectionHeaderLine:a,sectionHasOtherKeys:c}}function Nd(e,t,n,r){let o=e.split(`
8
- `),s=ni(o,t,n),i=` ${n} = ${ei(r)}`;return s.keyStart!==-1?o.splice(s.keyStart,s.keyEnd-s.keyStart+1,i):s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
9
- `)}function _d(e,t,n){let r=e.split(`
10
- `),o=ni(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 pe(e){let t=H(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Ld(n)}async function Ds(e){let t=H(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Je(e,t){let n=H(e.gitDir,"config");await e.fs.writeFile(n,ti(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}=Wr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function ri(e,t,n){let r=await Ds(e),{section:o,key:s}=Wr(t),i=Nd(r,o,s,n),a=H(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Na(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Ds(e);if(o){let i=Qo(o),{section:a,key:c}=Wr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function Fd(e,t,n,r){let o=e.split(`
12
- `),s=ni(o,t,n),i=` ${n} = ${ei(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 _a(e,t,n){let r=await Ds(e),{section:o,key:s}=Wr(t),i=Fd(r,o,s,n),a=H(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Fa(e,t){let n=await Ds(e),{section:r,key:o}=Wr(t),s=_d(n,r,o);if(!s.found)return!1;let i=H(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Wr(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 Ms(e,t){return Ua(e,t,"author")}function qr(e,t){return Ua(e,t,"committer")}async function Ua(e,t,n){let r=Ud[n],o=e.identityOverride,{timestamp:s,timezone:i}=Bd(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
1
+ var qd=Object.defineProperty;var Hs=(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)qd(e,n,{get:t[n],enumerable:!0})};function js(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===""?".":js(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 js(t||".")}function nn(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 qr(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=js(e),r=js(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 ai(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 Ya(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
+ `;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 Zd(e){let t={},n=null,r=e.split(`
3
+ `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=ai(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}=Ya(l,r,o);a[f]=d,o+=h}continue}o++}return t}function ci(e){let t={},n=null,r=e.split(`
4
+ `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=ai(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}=Ya(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=h}continue}o++}return t}function fi(e){let t=/[\n\t\b#;"]/.test(e)||e!==e.trim(),n="";for(let r=0;r<e.length;r++){let o=e[r];switch(o){case"\\":n+="\\\\";break;case'"':n+='\\"';break;case`
5
+ `:n+="\\n";break;case" ":n+="\\t";break;case"\b":n+="\\b";break;default:n+=o}}return t?`"${n}"`:n}function li(e){let t=[];for(let[n,r]of Object.entries(e)){t.push(`[${n}]`);for(let[o,s]of Object.entries(r))t.push(` ${o} = ${fi(s)}`)}return`${t.join(`
6
+ `)}
7
+ `}function di(e,t,n){let r=null,o=-1,s=-1,i=-1,a=-1,c=!1,f=0;for(;f<e.length;){let l=e[f].trim();if(!l||l.startsWith("#")||l.startsWith(";")){f++;continue}if(l.startsWith("[")){r=ai(l),r===t&&(a=f,i=f,c=!1),f++;continue}let d=f;for(;d<e.length-1&&e[d].replace(/\r$/,"").endsWith("\\");)d++;if(r===t){let h=l.indexOf("=");(h===-1?l.toLowerCase():l.slice(0,h).trim().toLowerCase())===n?(o=f,s=d):c=!0,i=d}f=d+1}return{keyStart:o,keyEnd:s,insertAfter:i,sectionHeaderLine:a,sectionHasOtherKeys:c}}function Jd(e,t,n,r){let o=e.split(`
8
+ `),s=di(o,t,n),i=` ${n} = ${fi(r)}`;return s.keyStart!==-1?o.splice(s.keyStart,s.keyEnd-s.keyStart+1,i):s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
9
+ `)}function Qd(e,t,n){let r=e.split(`
10
+ `),o=di(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 Zd(n)}async function Gs(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,li(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}=zr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function ui(e,t,n){let r=await Gs(e),{section:o,key:s}=zr(t),i=Jd(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Xa(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Gs(e);if(o){let i=ci(o),{section:a,key:c}=zr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function eu(e,t,n,r){let o=e.split(`
12
+ `),s=di(o,t,n),i=` ${n} = ${fi(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 Za(e,t,n){let r=await Gs(e),{section:o,key:s}=zr(t),i=eu(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Ja(e,t){let n=await Gs(e),{section:r,key:o}=zr(t),s=Qd(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function zr(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 Ls(e,t){return Qa(e,t,"author")}function Kr(e,t){return Qa(e,t,"committer")}async function Qa(e,t,n){let r=tu[n],o=e.identityOverride,{timestamp:s,timezone:i}=nu(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,97 +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 nn(e,t){try{let n=await qr(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 Bd(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:Wd(n)}}function Wd(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 Ud,Tn=Re(()=>{"use strict";Be();Ud={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function vn(e){let t="";for(let n=0;n<20;n++)t+=Ba[e[n]];return t}function zr(e,t){let n="";for(let r=0;r<20;r++)n+=Ba[e[t+r]];return n}function Dt(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 ee,Ba,ht=Re(()=>{"use strict";ee="0000000000000000000000000000000000000000",Ba=(()=>{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 Wa(e){return e.length===4&&e.toLowerCase()===".git"}function Qn(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===".."||Wa(n))return!1;return!0}function js(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function qa(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||Wa(n))return!1;return!0}var Gs=Re(()=>{"use strict"});function si(e){return typeof e=="string"?qd.encode(e):e}function zd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(si(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Ss(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(si(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(si(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 vn(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 Hn(e){return za().update(e).hex()}var qd,za,An,er=Re(()=>{"use strict";ht();qd=new TextEncoder;za=zd(),An=za});async function z(e){let t=H(e.gitDir,"index");if(!await e.fs.exists(t))return{version:oi,entries:[]};let n=await e.fs.readFileBuffer(t);return Kd(n)}async function fe(e,t){let n=H(e.gitDir,"index"),r=await Vd(t);await e.fs.writeFile(n,r)}function Ct(e,t){if(!Qn(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(ii),{...e,entries:n}}function lt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Ls(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Mt(e){return e.entries.some(t=>t.stage>0)}function Wt(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 Va(){return{version:oi,entries:[]}}function Ns(e){let t=[...e].sort(ii);return{version:oi,entries:t}}function Se(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Kd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Ka)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),m=vn(d);n+=20;let u=t.getUint16(n);n+=2;let h=u>>12&3,p=u&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let b=n;for(;b<e.byteLength&&e[b]!==0;)b++;w=new TextDecoder().decode(e.subarray(n,b)),g=b-n}let R=62+g+1,x=Math.ceil(R/8)*8;n=c+x,i.push({path:w,mode:l,hash:m,stage:h,stat:f})}return{version:o,entries:i}}async function Vd(e){let t=new TextEncoder,n=[...e.entries].sort(ii),r=[],o=12;for(let m of n){let u=t.encode(m.path);r.push(u);let h=62+u.byteLength+1;o+=Math.ceil(h/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,Ka),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let m=0;m<n.length;m++){let u=n[m],h=r[m],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=Dt(u.hash);i.set(g,c),c+=20;let w=Math.min(h.byteLength,4095),R=(u.stage&3)<<12|w;a.setUint16(c,R),c+=2,i.set(h,c),c+=h.byteLength,i[c]=0,c+=1;let x=62+h.byteLength+1,b=Math.ceil(x/8)*8;c=p+b}let f=i.subarray(0,c),l=await Hn(f),d=Dt(l);return i.set(d,c),i}function ii(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Ka,oi,Ce=Re(()=>{"use strict";ht();Gs();me();er();Ka=1145655875,oi=2});var Yd,_s,Ya=Re(()=>{"use strict";Yd=new Set(["tree","commit","tag"]),_s=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(!Yd.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 ai(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Xa[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Xa,Za=Re(()=>{"use strict";Xa=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;Xa[e]=t}});function ic(e){let t=oc(e);return sc(e.subarray(t,-4),{i:2})}function di(e){let t=oc(e),n={i:2},r=sc(e.subarray(t),n),o=rc(n.p);return{result:r,bytesConsumed:t+o+4}}var zt,Er,Xd,Ja,Qa,Zd,ec,tc,Jd,li,Kr,Vr,nc,Qd,eu,ci,qt,fi,rc,tu,rn,sc,oc,ac=Re(()=>{"use strict";zt=Uint8Array,Er=Uint16Array,Xd=Int32Array,Ja=new zt([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]),Qa=new zt([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]),Zd=new zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ec=(e,t)=>{let n=new Er(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new Xd(n[30]);for(let o=1;o<30;++o)for(let s=n[o];s<n[o+1];++s)r[s]=s-n[o]<<5|o;return{b:n,r}},{b:tc}=ec(Ja,2);tc[28]=258;({b:Jd}=ec(Qa,0)),li=new Er(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,li[e]=((t&65280)>>8|(t&255)<<8)>>1}Kr=(e,t,n)=>{let r=e.length,o=0,s=new Er(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new Er(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new Er(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 m=d|(1<<l)-1;d<=m;++d)a[li[d]>>c]=f}}else for(a=new Er(r),o=0;o<r;++o)e[o]&&(a[o]=li[i[e[o]-1]++]>>15-e[o]);return a},Vr=new zt(288);for(let e=0;e<144;++e)Vr[e]=8;for(let e=144;e<256;++e)Vr[e]=9;for(let e=256;e<280;++e)Vr[e]=7;for(let e=280;e<288;++e)Vr[e]=8;nc=new zt(32);for(let e=0;e<32;++e)nc[e]=5;Qd=Kr(Vr,9,1),eu=Kr(nc,5,1),ci=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},qt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},fi=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},rc=e=>(e+7)/8|0,tu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new zt(e.subarray(t,n))),rn=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},sc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new zt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new zt(o*3));let f=R=>{let x=n.length;if(R>x){let b=new zt(Math.max(x*2,R));b.set(n),n=b}},l=t.f||0,d=t.p||0,m=t.b||0,u=t.l,h=t.d,p=t.m,g=t.n,w=o*8;do{if(!u){l=qt(e,d,1);let y=qt(e,d+1,3);if(d+=3,y)if(y==1)u=Qd,h=eu,p=9,g=5;else if(y==2){let E=qt(e,d,31)+257,k=qt(e,d+10,15)+4,C=E+qt(e,d+5,31)+1;d+=14;let P=new zt(C),I=new zt(19);for(let D=0;D<k;++D)I[Zd[D]]=qt(e,d+D*3,7);d+=k*3;let v=ci(I),T=(1<<v)-1,N=Kr(I,v,1);for(let D=0;D<C;){let _=N[qt(e,d,T)];d+=_&15;let F=_>>4;if(F<16)P[D++]=F;else{let U=0,L=0;for(F==16?(L=3+qt(e,d,3),d+=2,U=P[D-1]):F==17?(L=3+qt(e,d,7),d+=3):F==18&&(L=11+qt(e,d,127),d+=7);L--;)P[D++]=U}}let S=P.subarray(0,E),A=P.subarray(E);p=ci(S),g=ci(A),u=Kr(S,p,1),h=Kr(A,g,1)}else rn(1);else{let E=rc(d)+4,k=e[E-4]|e[E-3]<<8,C=E+k;if(C>o){c&&rn(0);break}a&&f(m+k),n.set(e.subarray(E,C),m),t.b=m+=k,t.p=d=C*8,t.f=l;continue}if(d>w){c&&rn(0);break}}a&&f(m+131072);let R=(1<<p)-1,x=(1<<g)-1,b=d;for(;;b=d){let y=u[fi(e,d)&R],E=y>>4;if(d+=y&15,d>w){c&&rn(0);break}if(y||rn(2),E<256)n[m++]=E;else if(E==256){b=d,u=null;break}else{let k=E-254;if(E>264){let T=E-257,N=Ja[T];k=qt(e,d,(1<<N)-1)+tc[T],d+=N}let C=h[fi(e,d)&x],P=C>>4;C||rn(3),d+=C&15;let I=Jd[P];if(P>3){let T=Qa[P];I+=fi(e,d)&(1<<T)-1,d+=T}if(d>w){c&&rn(0);break}a&&f(m+131072);let v=m+k;if(m<I){let T=s-I,N=Math.min(I,v);for(T+m<0&&rn(3);m<N;++m)n[m]=r[T+m]}for(;m<v;++m)n[m]=n[m-I]}}t.l=u,t.p=b,t.b=m,t.f=l,u&&(l=1,t.m=p,t.d=h,t.n=g)}while(!l);return m!=n.length&&i?tu(n,0,m):n.subarray(0,m)},oc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&rn(0,"invalid zlib data"),e[1]&32&&rn(0,"zlib dictionaries are not supported"),2)});async function nu(){let e;if(!(typeof document<"u"))try{e=Ss(["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??di}}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:ic,inflateWithConsumed:di}}function ui(){return ru??=nu()}async function kr(e){return await(await ui()).deflateSync(e)}async function Rr(e){return await(await ui()).inflateSync(e)}async function cc(e,t){let n=await ui(),{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 ru,Fs=Re(()=>{"use strict";ac();ru=null});async function gc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Us)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Us.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=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 ou(e,a);i.push(l),a=l.nextOffset}return(await iu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function ou(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===Yr){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===gi&&(c=zr(e,t),t+=20);let{result:f,bytesConsumed:l}=await cc(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function iu(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>fc)throw new Error(`delta chain depth ${i} exceeds limit of ${fc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==Yr&&c.typeNum!==gi){let u=su[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let h={type:u,content:c.inflated,hash:await mi(u,c.inflated)};return r[s]=h,h}if(c.typeNum===Yr){let u=n.get(c.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let h=await o(u,i+1),p=Xr(h.content,c.inflated),g={type:h.type,content:p,hash:await mi(h.type,p)};return r[s]=g,g}let f=await au(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=Xr(l.content,c.inflated),m={type:l.type,content:d,hash:await mi(l.type,d)};return r[s]=m,m}for(let s=0;s<e.length;s++)await o(s);return r}async function au(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==Yr&&s.typeNum!==gi&&(await r(o)).hash===n)return o}}function Xr(e,t){let n=0,{value:r,newPos:o}=lc(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}=lc(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 wc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Us),r.setUint32(4,pi),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=pc[o.type],i=await kr(o.content);t.push(hi(s,o.content.byteLength)),t.push(i)}return bc(t)}async function Bs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Us),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=hi(Yr,a.delta.byteLength),d=cu(s-f),m=await kr(a.delta);t.push(l,d,m),s+=l.byteLength+d.byteLength+m.byteLength}else{let l=pc[a.type],d=hi(l,a.content.byteLength),m=await kr(a.content);t.push(d,m),s+=d.byteLength+m.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await bc(t),entries:i}}async function bc(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(Dt(s),r),n}function cu(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 hi(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 lc(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 mi(e,t){let n=fu.encode(`${e} ${t.byteLength}\0`),r=An();return r.update(n),r.update(t),r.hex()}var Us,pi,dc,uc,mc,hc,Yr,gi,su,pc,fc,fu,xr=Re(()=>{"use strict";ht();er();Fs();Us=1346454347,pi=2,dc=1,uc=2,mc=3,hc=4,Yr=6,gi=7,su={[dc]:"commit",[uc]:"tree",[mc]:"blob",[hc]:"tag"},pc={commit:dc,tree:uc,blob:mc,tag:hc};fc=50;fu=new TextEncoder});async function kc(e,t){let n=[...e].sort((u,h)=>u.hash<h.hash?-1:u.hash>h.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,yc),c+=4,a.setUint32(c,Ec),c+=4;let f=new Uint32Array(256);for(let u of n){let h=parseInt(u.hash.slice(0,2),16);for(let p=h;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(Dt(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 m=await d.hex();return i.set(Dt(m),c),i}async function Rc(e){let n=(await gc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:ai(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return kc(n,r)}async function xc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:ai(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return kc(n,r)}var yc,Ec,Kt,Ws=Re(()=>{"use strict";ht();er();Za();xr();yc=4285812579,Ec=2,Kt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==yc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==Ec)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=Dt(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=Dt(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 m=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(m!==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 lu,du,uu,Cc,Zr,Pc=Re(()=>{"use strict";ht();Ws();xr();Fs();lu=6,du=7,uu={1:"commit",2:"tree",3:"blob",4:"tag"},Cc=50,Zr=class{constructor(t,n){this.data=t;this.index=n instanceof Kt?n:new Kt(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>Cc)throw new Error(`delta chain depth ${n} exceeds limit of ${Cc}`);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===lu){let d=r[o++],m=d&127;for(;d&128;)m+=1,d=r[o++],m=(m<<7)+(d&127);let u=await Rr(r.subarray(o)),h=await this.readAt(t-m,n+1);return{type:h.type,content:Xr(h.content,u)}}if(i===du){let d=zr(r,o);o+=20;let m=await Rr(r.subarray(o)),u=this.index.lookup(d);if(u===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let h=await this.readAt(u,n+1);return{type:h.type,content:Xr(h.content,m)}}let f=uu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Rr(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 bi(e,t){let n=mu.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function pu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=hu.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 wi(e,t){return H(e,"objects",t.slice(0,2),t.slice(2))}var mu,hu,Cr,yi=Re(()=>{"use strict";ht();Ya();Ws();Pc();xr();Fs();me();er();mu=new TextEncoder,hu=new TextDecoder;Cr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new _s(r),this.packDir=H(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=bi(t,n),o=await Hn(r),s=wi(this.gitDir,o);if(await this.fs.exists(s))return o;let i=H(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await kr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=wi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Rr(o),i=await Hn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=pu(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(wi(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=vn(i),c=await Hn(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=H(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await Rc(t),m=H(this.packDir,`${f}.idx`);await this.fs.writeFile(m,d),this.loadedPackNames.add(f);let u=new Kt(d);return this.packs.push({name:f,index:u,reader:new Zr(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 wc(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=H(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=H(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Zr(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=H(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(H(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Kt(s),reader:null})}}}});function Jr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function Qr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Ei=Re(()=>{"use strict"});function sn(e){let t=wu.decode(e),n=t.indexOf(`
21
+ `);return{name:a,email:c,timestamp:s,timezone:i}}async function rn(e,t){try{let n=await Kr(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 nu(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:ru(n)}}function ru(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 tu,Tn=Re(()=>{"use strict";Be();tu={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 vn(e){let t="";for(let n=0;n<20;n++)t+=ec[e[n]];return t}function Vr(e,t){let n="";for(let r=0;r<20;r++)n+=ec[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 ee,ec,pt=Re(()=>{"use strict";ee="0000000000000000000000000000000000000000",ec=(()=>{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 tc(e){return e.length===4&&e.toLowerCase()===".git"}function tr(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===".."||tc(n))return!1;return!0}function Ns(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function nc(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||tc(n))return!1;return!0}var _s=Re(()=>{"use strict"});function hi(e){return typeof e=="string"?su.encode(e):e}function ou(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(hi(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Hs(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(hi(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(hi(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 vn(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 An(e){return rc().update(e).hex()}var su,rc,Hn,nr=Re(()=>{"use strict";pt();su=new TextEncoder;rc=ou(),Hn=rc});async function K(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:mi,entries:[]};let n=await e.fs.readFileBuffer(t);return iu(n)}async function ae(e,t){let n=v(e.gitDir,"index"),r=await au(t);await e.fs.writeFile(n,r)}function Pt(e,t){if(!tr(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(pi),{...e,entries:n}}function ft(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Fs(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 Le(e){return e.entries.filter(t=>t.stage===0)}function oc(){return{version:mi,entries:[]}}function Us(e){let t=[...e].sort(pi);return{version:mi,entries:t}}function Se(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function iu(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==sc)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=vn(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,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 au(e){let t=new TextEncoder,n=[...e.entries].sort(pi),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,sc),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,R=Math.ceil(y/8)*8;c=p+R}let f=i.subarray(0,c),l=await An(f),d=jt(l);return i.set(d,c),i}function pi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var sc,mi,Ce=Re(()=>{"use strict";pt();_s();pe();nr();sc=1145655875,mi=2});var cu,Bs,ic=Re(()=>{"use strict";cu=new Set(["tree","commit","tag"]),Bs=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(!cu.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 gi(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=ac[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var ac,cc=Re(()=>{"use strict";ac=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;ac[e]=t}});function wc(e){let t=gc(e);return pc(e.subarray(t,-4),{i:2})}function Ei(e){let t=gc(e),n={i:2},r=pc(e.subarray(t),n),o=mc(n.p);return{result:r,bytesConsumed:t+o+4}}var Yt,kr,fu,fc,lc,lu,dc,uc,du,yi,Yr,Xr,hc,uu,hu,wi,Vt,bi,mc,mu,sn,pc,gc,bc=Re(()=>{"use strict";Yt=Uint8Array,kr=Uint16Array,fu=Int32Array,fc=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]),lc=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]),lu=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dc=(e,t)=>{let n=new kr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new fu(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:uc}=dc(fc,2);uc[28]=258;({b:du}=dc(lc,0)),yi=new kr(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,yi[e]=((t&65280)>>8|(t&255)<<8)>>1}Yr=(e,t,n)=>{let r=e.length,o=0,s=new kr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new kr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new kr(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[yi[d]>>c]=f}}else for(a=new kr(r),o=0;o<r;++o)e[o]&&(a[o]=yi[i[e[o]-1]++]>>15-e[o]);return a},Xr=new Yt(288);for(let e=0;e<144;++e)Xr[e]=8;for(let e=144;e<256;++e)Xr[e]=9;for(let e=256;e<280;++e)Xr[e]=7;for(let e=280;e<288;++e)Xr[e]=8;hc=new Yt(32);for(let e=0;e<32;++e)hc[e]=5;uu=Yr(Xr,9,1),hu=Yr(hc,5,1),wi=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},bi=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},mc=e=>(e+7)/8|0,mu=(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")},pc=(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 R=new Yt(Math.max(y*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 x=Vt(e,d+1,3);if(d+=3,x)if(x==1)u=uu,m=hu,p=9,g=5;else if(x==2){let k=Vt(e,d,31)+257,E=Vt(e,d+10,15)+4,C=k+Vt(e,d+5,31)+1;d+=14;let $=new Yt(C),H=new Yt(19);for(let O=0;O<E;++O)H[lu[O]]=Vt(e,d+O*3,7);d+=E*3;let P=wi(H),I=(1<<P)-1,D=Yr(H,P,1);for(let O=0;O<C;){let _=D[Vt(e,d,I)];d+=_&15;let U=_>>4;if(U<16)$[O++]=U;else{let F=0,L=0;for(U==16?(L=3+Vt(e,d,3),d+=2,F=$[O-1]):U==17?(L=3+Vt(e,d,7),d+=3):U==18&&(L=11+Vt(e,d,127),d+=7);L--;)$[O++]=F}}let G=$.subarray(0,k),A=$.subarray(k);p=wi(G),g=wi(A),u=Yr(G,p,1),m=Yr(A,g,1)}else sn(1);else{let k=mc(d)+4,E=e[k-4]|e[k-3]<<8,C=k+E;if(C>o){c&&sn(0);break}a&&f(h+E),n.set(e.subarray(k,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,R=d;for(;;R=d){let x=u[bi(e,d)&b],k=x>>4;if(d+=x&15,d>w){c&&sn(0);break}if(x||sn(2),k<256)n[h++]=k;else if(k==256){R=d,u=null;break}else{let E=k-254;if(k>264){let I=k-257,D=fc[I];E=Vt(e,d,(1<<D)-1)+uc[I],d+=D}let C=m[bi(e,d)&y],$=C>>4;C||sn(3),d+=C&15;let H=du[$];if($>3){let I=lc[$];H+=bi(e,d)&(1<<I)-1,d+=I}if(d>w){c&&sn(0);break}a&&f(h+131072);let P=h+E;if(h<H){let I=s-H,D=Math.min(H,P);for(I+h<0&&sn(3);h<D;++h)n[h]=r[I+h]}for(;h<P;++h)n[h]=n[h-H]}}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?mu(n,0,h):n.subarray(0,h)},gc=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 pu(){let e;if(!(typeof document<"u"))try{e=Hs(["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??Ei}}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:wc,inflateWithConsumed:Ei}}function ki(){return gu??=pu()}async function Rr(e){return await(await ki()).deflateSync(e)}async function xr(e){return await(await ki()).inflateSync(e)}async function yc(e,t){let n=await ki(),{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 gu,Ws=Re(()=>{"use strict";bc();gu=null});async function Oc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==qs)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${qs.toString(16)})`);let o=n.getUint32(4);if(o!==Ci)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Vr(e,e.byteLength-20),l=Hn();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 bu(e,a);i.push(l),a=l.nextOffset}return(await yu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function bu(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===Zr){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===Pi&&(c=Vr(e,t),t+=20);let{result:f,bytesConsumed:l}=await yc(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function yu(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>Ec)throw new Error(`delta chain depth ${i} exceeds limit of ${Ec}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==Zr&&c.typeNum!==Pi){let u=wu[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:u,content:c.inflated,hash:await Ri(u,c.inflated)};return r[s]=m,m}if(c.typeNum===Zr){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=Jr(m.content,c.inflated),g={type:m.type,content:p,hash:await Ri(m.type,p)};return r[s]=g,g}let f=await Eu(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=Jr(l.content,c.inflated),h={type:l.type,content:d,hash:await Ri(l.type,d)};return r[s]=h,h}for(let s=0;s<e.length;s++)await o(s);return r}async function Eu(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!==Zr&&s.typeNum!==Pi&&(await r(o)).hash===n)return o}}function Jr(e,t){let n=0,{value:r,newPos:o}=kc(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}=kc(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 Ic(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,qs),r.setUint32(4,Ci),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=$c[o.type],i=await Rr(o.content);t.push(xi(s,o.content.byteLength)),t.push(i)}return Sc(t)}async function zs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,qs),o.setUint32(4,Ci),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=xi(Zr,a.delta.byteLength),d=ku(s-f),h=await Rr(a.delta);t.push(l,d,h),s+=l.byteLength+d.byteLength+h.byteLength}else{let l=$c[a.type],d=xi(l,a.content.byteLength),h=await Rr(a.content);t.push(d,h),s+=d.byteLength+h.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Sc(t),entries:i}}async function Sc(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=Hn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(jt(s),r),n}function ku(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 xi(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 kc(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 Ri(e,t){let n=Ru.encode(`${e} ${t.byteLength}\0`),r=Hn();return r.update(n),r.update(t),r.hex()}var qs,Ci,Rc,xc,Cc,Pc,Zr,Pi,wu,$c,Ec,Ru,Cr=Re(()=>{"use strict";pt();nr();Ws();qs=1346454347,Ci=2,Rc=1,xc=2,Cc=3,Pc=4,Zr=6,Pi=7,wu={[Rc]:"commit",[xc]:"tree",[Cc]:"blob",[Pc]:"tag"},$c={commit:Rc,tree:xc,blob:Cc,tag:Pc};Ec=50;Ru=new TextEncoder});async function Hc(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,Tc),c+=4,a.setUint32(c,vc),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=Hn();d.update(i.subarray(0,c));let h=await d.hex();return i.set(jt(h),c),i}async function Ac(e){let n=(await Oc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:gi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Hc(n,r)}async function Dc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:gi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Hc(n,r)}var Tc,vc,Xt,Ks=Re(()=>{"use strict";pt();nr();cc();Cr();Tc=4285812579,vc=2,Xt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==Tc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==vc)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 xu,Cu,Pu,Mc,Qr,jc=Re(()=>{"use strict";pt();Ks();Cr();Ws();xu=6,Cu=7,Pu={1:"commit",2:"tree",3:"blob",4:"tag"},Mc=50,Qr=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>Mc)throw new Error(`delta chain depth ${n} exceeds limit of ${Mc}`);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===xu){let d=r[o++],h=d&127;for(;d&128;)h+=1,d=r[o++],h=(h<<7)+(d&127);let u=await xr(r.subarray(o)),m=await this.readAt(t-h,n+1);return{type:m.type,content:Jr(m.content,u)}}if(i===Cu){let d=Vr(r,o);o+=20;let h=await xr(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:Jr(m.content,h)}}let f=Pu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await xr(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 Oi(e,t){let n=$u.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Iu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Ou.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 $i(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var $u,Ou,Pr,Ii=Re(()=>{"use strict";pt();ic();Ks();jc();Cr();Ws();pe();nr();$u=new TextEncoder,Ou=new TextDecoder;Pr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Bs(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=Oi(t,n),o=await An(r),s=$i(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 Rr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=$i(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await xr(o),i=await An(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=Iu(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($i(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=vn(i),c=await An(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 Ac(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 Qr(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 Ic(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 Qr(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 es(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 ts(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Si=Re(()=>{"use strict"});function on(e){let t=Tu.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),m=f.slice(l+1);switch(d){case"tree":s=m;break;case"parent":i.push(m);break;case"author":a=Jr(m);break;case"committer":c=Jr(m);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 on(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Qr(e.author)}`),t.push(`committer ${Qr(e.committer)}`),t.push(""),t.push(e.message),gu.encode(t.join(`
25
- `))}var gu,wu,wn=Re(()=>{"use strict";Ei();gu=new TextEncoder,wu=new TextDecoder});function Vt(e){let t=yu.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=es(h);break;case"committer":c=es(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 ${ts(e.author)}`),t.push(`committer ${ts(e.committer)}`),t.push(""),t.push(e.message),Su.encode(t.join(`
25
+ `))}var Su,Tu,wn=Re(()=>{"use strict";Si();Su=new TextEncoder,Tu=new TextDecoder});function Zt(e){let t=Hu.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),m=f.slice(l+1);switch(d){case"object":s=m;break;case"type":i=m;break;case"tag":a=m;break;case"tagger":c=Jr(m);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 $c(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Qr(e.tagger)}`),t.push(""),t.push(e.message),bu.encode(t.join(`
29
- `))}var bu,yu,Pr=Re(()=>{"use strict";Ei();bu=new TextEncoder,yu=new TextDecoder});async function pt(e,t){return Hn(bi(e,t))}async function He(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 Yt(e,t){return e.objectStore.exists(t)}async function qs(e,t){return e.objectStore.ingestPack(t)}async function Oc(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function Dn(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 Eu.decode(n.content)}async function Pt(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 sn(n.content)}async function Ic(e,t){let n=await ye(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Vt(n.content)}async function ve(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=Vt(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 Eu,ce=Re(()=>{"use strict";yi();wn();Pr();er();Eu=new TextDecoder});function Sc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var es,ki=Re(()=>{"use strict";es={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function Ru(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?ku[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>=Ri.length&&e.slice(s-Ri.length,s)===Ri?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function ts(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}=Ru(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 bn(e){return!e||e.startsWith("-")?!1:ts(`refs/heads/${e}`,0)}function Tc(e){return e?ts(`refs/tags/${e}`,0):!1}async function Ac(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<vc;r++){let o=await Ac(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 Ac(e,"HEAD")}async function Y(e){return B(e,"HEAD")}async function Z(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 Xe(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function he(e,t){let n=e.hooks?await B(e,t):null;await e.refStore.deleteRef(t),await rs(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/","")}async function jn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await Z(e,n.target,t):await Z(e,"HEAD",t)}async function Hc(e){if(e.refStore&&!(e.refStore instanceof Mn))return;let t=await ge(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await ye(e,o.hash);if(s.type==="tag"){let i=Vt(s.content).object;for(let a=0;a<100;a++){let c=await ye(e,i);if(c.type!=="tag")break;i=Vt(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(H(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=es(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 Gc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${ts(e.tagger)}`),t.push(""),t.push(e.message),vu.encode(t.join(`
29
+ `))}var vu,Hu,$r=Re(()=>{"use strict";Si();vu=new TextEncoder,Hu=new TextDecoder});async function gt(e,t){return An(Oi(e,t))}async function De(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 Vs(e,t){return e.objectStore.ingestPack(t)}async function Lc(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function Dn(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 Au.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 on(n.content)}async function Nc(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 ve(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 Au,ie=Re(()=>{"use strict";Ii();wn();$r();nr();Au=new TextDecoder});function _c(e){return typeof e=="string"?{type:"direct",hash:e}:e}var bn,Ti=Re(()=>{"use strict";bn={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function Mu(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?Du[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>=vi.length&&e.slice(s-vi.length,s)===vi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function ns(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}=Mu(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:ns(`refs/heads/${e}`,0)}function Fc(e){return e?ns(`refs/tags/${e}`,0):!1}async function Bc(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Uc;r++){let o=await Bc(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 Bc(e,"HEAD")}async function Y(e){return B(e,"HEAD")}async function Z(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 Ys(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 ss(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 jn(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 Gn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await Z(e,n.target,t):await Z(e,"HEAD",t)}async function Wc(e){if(e.refStore&&!(e.refStore instanceof Mn))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 o of t){let s=H(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Dc(e,H(e.gitDir,"refs"));let r=H(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(H(r,"heads"),{recursive:!0}),await e.fs.mkdir(H(r,"tags"),{recursive:!0})}async function Dc(e,t){if(e.refStore&&!(e.refStore instanceof Mn)||!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 Dc(e,H(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Ri,ku,xi,vc,Mn,we=Re(()=>{"use strict";ce();Pr();me();ze();Gn();ki();Ri=".lock",ku=[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];xi="ref: ",vc=10,Mn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=H(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(xi)?{type:"symbolic",target:s.slice(xi.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=Sc(n),o=H(this.gitDir,t);await ns(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${xi}${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 qc(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 qc(e,t){if(e.refStore&&!(e.refStore instanceof Mn)||!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 qc(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var vi,Du,Hi,Uc,Mn,we=Re(()=>{"use strict";ie();$r();pe();ze();Ln();Ti();vi=".lock",Du=[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];Hi="ref: ",Uc=10,Mn=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(Hi)?{type:"symbolic",target:s.slice(Hi.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=_c(n),o=v(this.gitDir,t);await rs(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Hi}${r.target}
32
32
  `):await this.fs.writeFile(o,`${r.hash}
33
- `)}async deleteRef(t){let n=H(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=H(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<vc;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=H(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
34
- `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=H(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
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<Uc;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
+ `)){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=H(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 tr(e,t){let n=t;for(;;){let r=H(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Cr(e,r),refStore:new Mn(e,r)};if(await xu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Cr(e,n),refStore:new Mn(e,n)};let o=Cu(n);if(o===n)return null;n=o}}async function xu(e,t){let n=H(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=H(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 zs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:H(t,".git"),i=r?null:t,a=H(s,"HEAD"),c=await e.exists(a);await e.mkdir(H(s,"objects"),{recursive:!0}),await e.mkdir(H(s,"refs","heads"),{recursive:!0}),await e.mkdir(H(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Cr(e,s),refStore:new Mn(e,s)};if(!c){await Xe(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(H(s,"config"),ti(l))}return{ctx:f,reinit:c}}async function ns(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Cu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Gn=Re(()=>{"use strict";Be();yi();me();we()});function Ks(e,t){return H(e.gitDir,"logs",t)}function Pu(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),m=d.indexOf(" ");if(m<0)return null;let u=parseInt(d.slice(0,m),10),h=d.slice(m+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:u,tz:h,message:r}}async function et(e,t){let n=Ks(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
37
- `)){if(!s)continue;let i=Pu(s);i&&o.push(i)}return o}function Mc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Ln(e,t,n){let r=Ks(e,t);if(await ns(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Mc).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 rr(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 Pr(e,r),refStore:new Mn(e,r)};if(await ju(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Pr(e,n),refStore:new Mn(e,n)};let o=Gu(n);if(o===n)return null;n=o}}async function ju(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 Xs(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 Pr(e,s),refStore:new Mn(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"),li(l))}return{ctx:f,reinit:c}}async function rs(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Gu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ln=Re(()=>{"use strict";Be();Ii();pe();we()});function Zs(e,t){return v(e.gitDir,"logs",t)}function Lu(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=Zs(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=Lu(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 Nn(e,t,n){let r=Zs(e,t);if(await rs(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 Ze(e,t,n){let r=Ks(e,t);await ns(e.fs,r);let o=`${Mc(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 rs(e,t){let n=Ks(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function oe(e,t,n,r,o,s,i=!1){let a=await nn(e,t),c={oldHash:r??ee,newHash:o,...a,message:s};await Ze(e,n,c),i&&n!=="HEAD"&&await Ze(e,"HEAD",c)}var ze=Re(()=>{"use strict";ht();Tn();me();Gn();ht()});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 Ou(e,t){let n=await Oc(e,t);if(n.length===0)return null;if(n.length>1)throw new Ci(t);return n[0]}async function Iu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(jc.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Yt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Ou(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 Su(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of jc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Tu(e,t,n){let r=Su(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 vu(e,t,n){if(n===""||n==="commit")try{return await ve(e,t)}catch{return null}if(n==="tree"){let o;try{o=await ve(e,t)}catch{return null}return(await j(e,o)).tree}return(await ye(e,t)).type!==n?null:t}async function Au(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await ve(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await vu(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 Tu(e,n,r):s=await Iu(e,n),s?Au(e,s,o):null}function Vs(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var jc,Ci,an=Re(()=>{"use strict";ce();ze();we();jc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Ci=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 yn(e){return typeof e=="string"?e==="120000":e===40960}async function ss(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Hu.encode(r)}return e.readFileBuffer(t)}async function Nn(e,t){let n=await ss(e,t);return pt("blob",n)}var Hu,nr=Re(()=>{"use strict";ce();Hu=new TextEncoder});function ju(e){return e.length===4&&e.toLowerCase()===".git"}function Gu(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(ju(e))throw new Error(`invalid tree entry: '${e}'`);if(!Mu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function _n(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Gc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Gc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=vn(a),f=o.padStart(6,"0");Gu(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Lc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Du.encode(`${i} ${s.name}\0`),c=Dt(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 Du,Gc,Mu,Ys=Re(()=>{"use strict";ht();Du=new TextEncoder,Gc=new TextDecoder,Mu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Nc(e,t,"")}async function Nc(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:Lu(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 Nc(e,a,c);r.push({mode:es.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===es.DIRECTORY?`${i.name}/`:i.name,f=a.mode===es.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Lc({type:"tree",entries:r});return He(e,"tree",s)}async function Ke(e,t,n=""){let r=await ye(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=_n(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===es.DIRECTORY){let c=await Ke(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function le(e,t){if(!t)return new Map;let n=await Ke(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){let r=await le(e,t),o=await le(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Ie(i.path,a.path))}function Lu(e){return e.toString(8).padStart(6,"0")}var Ae=Re(()=>{"use strict";ie();ce();Ys();ki()});function _c(e){return/^[a-zA-Z0-9]$/.test(e)}function Nu(e){return/^[a-zA-Z]$/.test(e)}function _u(e){return e>="0"&&e<="9"}function Pi(e){return e>="A"&&e<="Z"}function $i(e){return e>="a"&&e<="z"}function Fc(e){return/^\s$/.test(e)}function Fu(e){return e===" "||e===" "}function Ii(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Uu(e){return Ii(e)&&!Fc(e)}function Bu(e){return Ii(e)&&!_c(e)&&e!==" "}function Wu(e){let t=e.charCodeAt(0);return t<32||t===127}function qu(e){return/^[0-9a-fA-F]$/.test(e)}function os(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Oi(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(!os(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]==="/"&&Oi(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(!zu(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=Oi(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="",m=!0;for(;t<e.length&&(m||e[t]!=="]");){m=!1;let u=e[t];if(u==="\\"){if(t++,t>=e.length)return-1;u=e[t],os(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 h=d,p=u;if(c>=h&&c<=p&&(l=!0),s){if($i(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(Pi(c)){let g=c.toLowerCase();g>=h&&g<=p&&(l=!0)}}u=""}else if(u==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let h=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-h-1;if(p<0||e[t-1]!==":")t=h-2,u="[",os(c,u,s)&&(l=!0);else{let g=e.slice(h,h+p);Ku(g,c,s)&&(l=!0),u=""}}else os(c,u,s)&&(l=!0);d=u,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!os(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function zu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Ku(e,t,n){switch(e){case"alnum":return _c(t);case"alpha":return Nu(t);case"blank":return Fu(t);case"cntrl":return Wu(t);case"digit":return _u(t);case"graph":return Uu(t);case"lower":return $i(t)||n&&Pi(t);case"print":return Ii(t);case"punct":return Bu(t);case"space":return Fc(t);case"upper":return Pi(t)||n&&$i(t);case"xdigit":return qu(t);default:return!1}}function cn(e,t,n=0){return Oi(e,0,t,0,n)===0?0:1}var is=Re(()=>{"use strict"});function qc(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 Vu(e){return qc(e)===e.length}function Yu(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=Xs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Wc);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Uc);let a=Math.min(qc(o),s);return o[0]==="*"&&Vu(o.slice(1))&&(r|=Bc),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function as(e,t,n){let r=[];for(let o of e.split(`
41
- `)){let s=Yu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function Xu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Bc){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return cn(n,e,2)===0}function Zu(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 cn(r,a,2)===0}function Si(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&Wc&&!t)){if(s.flags&Uc){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(Xu(r,s))return s;continue}if(Zu(e,s))return s}}return null}function fn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Si(t,n,o);if(s)return s.flags&Xs?"not-ignored":"ignored"}if(e.excludeFile){let r=Si(t,n,e.excludeFile);if(r)return r.flags&Xs?"not-ignored":"ignored"}if(e.globalExclude){let r=Si(t,n,e.globalExclude);if(r)return r.flags&Xs?"not-ignored":"ignored"}return"undecided"}async function $r(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=H(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=as(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=as(o,"",r)}catch{}}catch{}return t}function rr(e,t,n,r){let s=as(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Uc,Bc,Wc,Xs,Js=Re(()=>{"use strict";Be();me();is();Uc=1,Bc=4,Wc=8,Xs=16});async function gt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=H(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 Nn(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 ot(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ie(s.path,i.path))}async function dt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!Qn(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);let n=await ye(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=H(e.workTree,t.path);if(!js(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&&yn(t.mode)&&e.fs.symlink){let s=Qu.decode(n.content);if(!qa(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 zc(e,t){let n=await Ke(e,t);for(let r of n)await dt(e,r)}async function ln(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!Qn(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=H(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=Ju.encode(f),d=await He(e,"blob",l),m={path:n,mode:40960,hash:d,stage:0,stat:{...Se(),size:l.byteLength}};return{index:Ct(t,m),hash:d}}let s=await e.fs.readFileBuffer(r),i=await He(e,"blob",s),a=o.mode!=null?em(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Se(),size:s.byteLength}};return{index:Ct(t,c),hash:i}}async function ot(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await $r(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);s=rr(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=H(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&fn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&fn(s,l,!0)==="ignored")continue;let m=await ot(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...m)}else if(d.isFile){if(s&&fn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function em(e){return e>511?e:e&73?33261:33188}async function sr(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 sr(e,tn(t),n))}var Ju,Qu,tt=Re(()=>{"use strict";ie();Js();Ce();ce();Gs();me();nr();Ae();Ju=new TextEncoder,Qu=new TextDecoder});function Ti(e){return e.existsOnDisk&&e.indexHash===null}async function tm(e,t,n){let r=await Promise.all(t.map(h=>le(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await ot(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await ot(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),m=(h,p)=>r[h]?.get(p),u=[];for(let h of d){let p=null,g=null,w=null,R=null,x=null;if(r.length===1){let T=m(0,h);w=T?.hash??null,x=T?.mode??null}else if(r.length===2){let T=m(0,h),N=m(1,h);g=T?.hash??null,R=T?.mode??null,w=N?.hash??null,x=N?.mode??null}else if(r.length>=3){let T=m(0,h),N=m(1,h),S=m(2,h);p=T?.hash??null,g=N?.hash??null,R=N?.mode??null,w=S?.hash??null,x=S?.mode??null}let y=o.get(h)?.hash??null,E=s.has(h)?1:0,k=i.has(h),C,P=async()=>C!==void 0?C:k?(C=!(await c()).has(h),C):(C=!1,!1),I,v=async()=>{if(I!==void 0)return I;if(!k||!e.workTree)return I=null,null;let T=H(e.workTree,h);try{I=await Nn(e.fs,T)}catch{I=null}return I};u.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:y,indexStage:E,existsOnDisk:k,isIgnoredOnDisk:P,getWorktreeHash:v,headMode:R,remoteMode:x})}return u}function Qs(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 eo(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 nm(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 rm(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=nm(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await sm(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function sm(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Ti(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 Ti(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Ti(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function om(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,m=f.takeFrom==="head"?l.headMode:l.remoteMode,u=m?Number.parseInt(m,8):33188;o.push({path:c,mode:u,hash:d,stage:0,stat:Se()}),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)=>Ie(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function to(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of im){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 Je(e,t,n){let r=Zs(e,t);await rs(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 ss(e,t){let n=Zs(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 rn(e,t),c={oldHash:r??ee,newHash:o,...a,message:s};await Je(e,n,c),i&&n!=="HEAD"&&await Je(e,"HEAD",c)}var ze=Re(()=>{"use strict";pt();Tn();pe();Ln();pt()});function Nu(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 _u(e,t){let n=await Lc(e,t);if(n.length===0)return null;if(n.length>1)throw new Ai(t);return n[0]}async function Fu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Kc.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 _u(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 Uu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Kc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Bu(e,t,n){let r=Uu(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 Wu(e,t,n){if(n===""||n==="commit")try{return await ve(e,t)}catch{return null}if(n==="tree"){let o;try{o=await ve(e,t)}catch{return null}return(await j(e,o)).tree}return(await ye(e,t)).type!==n?null:t}async function qu(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await ve(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await Wu(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}=Nu(t),s;return r!==void 0?s=await Bu(e,n,r):s=await Fu(e,n),s?qu(e,s,o):null}function Js(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Kc,Ai,cn=Re(()=>{"use strict";ie();ze();we();Kc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Ai=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function ht(e,t){return e.lstat?e.lstat(t):e.stat(t)}function En(e){return typeof e=="string"?e==="120000":e===40960}async function os(e,t){if((await ht(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return zu.encode(r)}return e.readFileBuffer(t)}async function _n(e,t){let n=await os(e,t);return gt("blob",n)}var zu,sr=Re(()=>{"use strict";ie();zu=new TextEncoder});function Yu(e){return e.length===4&&e.toLowerCase()===".git"}function Xu(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(Yu(e))throw new Error(`invalid tree entry: '${e}'`);if(!Vu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function kn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Vc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Vc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=vn(a),f=o.padStart(6,"0");Xu(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Yc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Ku.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 Ku,Vc,Vu,Qs=Re(()=>{"use strict";pt();Ku=new TextEncoder,Vc=new TextDecoder,Vu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Zc(e,t,"")}async function Zc(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:Zu(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 Zc(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=Yc({type:"tree",entries:r});return De(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=kn(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 Ke(e,t,n){if(t===n)return[];let r=[];return await Jc(e,t,n,"",r),r.sort((o,s)=>Ie(o.path,s.path))}async function Xc(e,t){let n=await ye(e,t);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return kn(n.content).entries}async function Jc(e,t,n,r,o){if(t===n)return;let s=t?await Xc(e,t):[],i=n?await Xc(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 Jc(e,d.hash,h.hash,u,o):m?(await eo(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 eo(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 eo(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 eo(e,m.hash,u,"added",o):o.push({path:u,status:"added",newHash:m.hash,newMode:m.mode})}}}async function eo(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 Zu(e){return e.toString(8).padStart(6,"0")}var He=Re(()=>{"use strict";oe();ie();Qs();Ti()});function Qc(e){return/^[a-zA-Z0-9]$/.test(e)}function Ju(e){return/^[a-zA-Z]$/.test(e)}function Qu(e){return e>="0"&&e<="9"}function Di(e){return e>="A"&&e<="Z"}function Mi(e){return e>="a"&&e<="z"}function ef(e){return/^\s$/.test(e)}function eh(e){return e===" "||e===" "}function Gi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function th(e){return Gi(e)&&!ef(e)}function nh(e){return Gi(e)&&!Qc(e)&&e!==" "}function rh(e){let t=e.charCodeAt(0);return t<32||t===127}function sh(e){return/^[0-9a-fA-F]$/.test(e)}function is(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function ji(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(!is(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]==="/"&&ji(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(!oh(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=ji(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],is(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(Mi(c)){let g=c.toUpperCase();g>=m&&g<=p&&(l=!0)}else if(Di(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="[",is(c,u,s)&&(l=!0);else{let g=e.slice(m,m+p);ih(g,c,s)&&(l=!0),u=""}}else is(c,u,s)&&(l=!0);d=u,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!is(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function oh(e){return e==="*"||e==="?"||e==="["||e==="\\"}function ih(e,t,n){switch(e){case"alnum":return Qc(t);case"alpha":return Ju(t);case"blank":return eh(t);case"cntrl":return rh(t);case"digit":return Qu(t);case"graph":return th(t);case"lower":return Mi(t)||n&&Di(t);case"print":return Gi(t);case"punct":return nh(t);case"space":return ef(t);case"upper":return Di(t)||n&&Mi(t);case"xdigit":return sh(t);default:return!1}}function fn(e,t,n=0){return ji(e,0,t,0,n)===0?0:1}var as=Re(()=>{"use strict"});function sf(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 ah(e){return sf(e)===e.length}function ch(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|=to,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=rf);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=tf);let a=Math.min(sf(o),s);return o[0]==="*"&&ah(o.slice(1))&&(r|=nf),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function cs(e,t,n){let r=[];for(let o of e.split(`
41
+ `)){let s=ch(o,t);s&&r.push(s)}return{patterns:r,src:n}}function fh(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&nf){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return fn(n,e,2)===0}function lh(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 Li(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&rf&&!t)){if(s.flags&tf){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(fh(r,s))return s;continue}if(lh(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=Li(t,n,o);if(s)return s.flags&to?"not-ignored":"ignored"}if(e.excludeFile){let r=Li(t,n,e.excludeFile);if(r)return r.flags&to?"not-ignored":"ignored"}if(e.globalExclude){let r=Li(t,n,e.globalExclude);if(r)return r.flags&to?"not-ignored":"ignored"}return"undecided"}async function Or(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=cs(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=cs(o,"",r)}catch{}}catch{}return t}function or(e,t,n,r){let s=cs(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var tf,nf,rf,to,ro=Re(()=>{"use strict";Be();pe();as();tf=1,nf=4,rf=8,to=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)continue;let i=v(e.workTree,s.path),a;try{a=await ht(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await _n(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await st(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ie(s.path,i.path))}async function lt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!tr(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);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(!Ns(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=uh.decode(n.content);if(!nc(s))throw new Error(`refusing to create symlink with unsafe target '${s}'`);await ht(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 of(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(!tr(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 ht(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=dh.encode(f),d=await De(e,"blob",l),h={path:n,mode:40960,hash:d,stage:0,stat:{...Se(),size:l.byteLength}};return{index:Pt(t,h),hash:d}}let s=await e.fs.readFileBuffer(r),i=await De(e,"blob",s),a=o.mode!=null?hh(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Se(),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 Or(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=or(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 ht(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 st(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 hh(e){return e>511?e:e&73?33261:33188}async function ir(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 ir(e,nn(t),n))}var dh,uh,tt=Re(()=>{"use strict";oe();ro();Ce();ie();_s();pe();sr();He();dh=new TextEncoder,uh=new TextDecoder});function Ni(e){return e.existsOnDisk&&e.indexHash===null}async function mh(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,y=null;if(r.length===1){let I=h(0,m);w=I?.hash??null,y=I?.mode??null}else if(r.length===2){let I=h(0,m),D=h(1,m);g=I?.hash??null,b=I?.mode??null,w=D?.hash??null,y=D?.mode??null}else if(r.length>=3){let I=h(0,m),D=h(1,m),G=h(2,m);p=I?.hash??null,g=D?.hash??null,b=D?.mode??null,w=G?.hash??null,y=G?.mode??null}let x=o.get(m)?.hash??null,k=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),H,P=async()=>{if(H!==void 0)return H;if(!E||!e.workTree)return H=null,null;let I=v(e.workTree,m);try{H=await _n(e.fs,I)}catch{H=null}return H};u.push({path:m,baseHash:p,headHash:g,remoteHash:w,indexHash:x,indexStage:k,existsOnDisk:E,isIgnoredOnDisk:$,getWorktreeHash:P,headMode:b,remoteMode:y})}return u}function so(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 oo(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 ph(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 gh(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=ph(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await wh(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function wh(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Ni(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 Ni(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Ni(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function bh(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:Se()}),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)=>Ie(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function io(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of yh){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 or(e,t,n,r){let o=await tm(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 rm(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:to(a,r)};let{newEntries:c,worktreeOps:f}=om(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function De(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!Qn(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=H(n,o.path);if(!js(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 dt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await sr(e.fs,tn(o),n)}async function Fn(e,t,n,r){return or(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:eo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Kc(e,t,n,r){return or(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:eo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function kn(e,t,n){return or(e,[{label:"target",treeHash:t}],n,{mergeFn:Qs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Or(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 or(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Qs,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 ar(e,t,n,r){let o=await mh(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 gh(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:io(a,r)};let{newEntries:c,worktreeOps:f}=bh(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Me(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!tr(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!Ns(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await ht(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 ir(e.fs,nn(o),n)}async function Fn(e,t,n,r){return ar(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:oo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function af(e,t,n,r){return ar(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:oo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function xn(e,t,n){return ar(e,[{label:"target",treeHash:t}],n,{mergeFn:so,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ir(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:Le(n)},i=await ar(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:so,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
47
47
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
48
- `);return c.length>0&&(i.errorOutput=G(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
- `,128)),i}if(e.workTree&&o.size>0){let a=await le(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 im,Xt=Re(()=>{"use strict";ie();Ce();Gs();me();nr();Ae();tt();im=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function O(e){return{stdout:"",stderr:`fatal: ${e}
50
- `,exitCode:128}}function G(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 tr(e,t);return r?n?{...r,...n}:r:am}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:cm}async function Qe(e){let t=await Y(e);return t||O("your current branch does not have any commits yet")}function Rn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
- `){return Mt(e)?G(`error: ${t} is not possible because you have unmerged files.
48
+ `);return c.length>0&&(i.errorOutput=N(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 yh,Jt=Re(()=>{"use strict";oe();Ce();_s();pe();sr();He();tt();yh=[{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 N(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 rr(e,t);return r?n?{...r,...n}:r:Eh}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ve(e){return e.workTree?null:kh}async function Qe(e){let t=await Y(e);return t||T("your current branch does not have any commits yet")}function Cn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
+ `){return Gt(e)?N(`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 wt(e,t,n){let r=await We(e,t);return r||O(n??`bad revision '${t}'`)}async function je(e,t,n){let r=await We(e,t);if(!r)return O(n??`bad revision '${t}'`);try{let o=await ve(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return O(n??`bad revision '${t}'`)}}async function nt(e,t){try{return await qr(e,t)}catch(n){return O(n.message)}}async function dn(e,t){try{return await Ms(e,t)}catch(n){return O(n.message)}}function Un(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 Ie(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?st(e.workTree,t):""}function X(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
- `);return t===-1?e:e.slice(0,t)}function Zt(e){return O(`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||T(n??`bad revision '${t}'`)}async function Ge(e,t,n){let r=await We(e,t);if(!r)return T(n??`bad revision '${t}'`);try{let o=await ve(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 Kr(e,t)}catch(n){return T(n.message)}}async function un(e,t){try{return await Ls(e,t)}catch(n){return T(n.message)}}function Un(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 Ie(e,t){return e<t?-1:e>t?1:0}function dt(e,t){return e.workTree?rt(e.workTree,t):""}function X(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.
56
56
  Use '--' to separate paths from revisions, like this:
57
- 'git <command> [<revision>...] -- [<file>...]'`)}function jt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${X(t)}] ${ue(n)}`}async function Bn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await Y(e);if(!o)return O(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Y(e),i=await j(e,o),a=await z(e),c=await Or(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await jn(e,o),await fe(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await oe(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function bt(e,t,n,r,o,s){let i=on({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await He(e,"commit",i);return await jn(e,a),a}function $t(e){let t=e.split(`
57
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Lt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${X(t)}] ${ue(n)}`}async function Bn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await Y(e);if(!o)return T(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Y(e),i=await j(e,o),a=await K(e),c=await Ir(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Gn(e,o),await ae(e,{version:2,entries:c.newEntries}),await Me(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=an({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await De(e,"commit",i);return await Gn(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
- `}function Gt(e){return e.endsWith(`
60
+ `}function Nt(e){return e.endsWith(`
61
61
  `)?e:`${e}
62
- `}var am,cm,ie=Re(()=>{"use strict";Tn();Ce();ce();wn();me();ze();we();Gn();an();Xt();am=O("not a git repository (or any of the parent directories): .git"),cm=O("this operation must be run in a work tree")});var Jc={};Hd(Jc,{CommitHeap:()=>Wn,countAheadBehind:()=>Di,findOrphanedCommits:()=>Mi,walkCommits:()=>Lt});async function*Lt(e,t,n){if(n?.topoOrder){yield*hm(e,t,n);return}let r=await Zc(e,n?.exclude),o=new Set(r),s=new Wn,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 Ir(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 m of d)if(!o.has(m))try{s.push(await Ir(e,m))}catch{}}}async function*hm(e,t,n){let r=await Zc(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Ir(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 h=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of h)if(!o.has(p))try{s.push(await Ir(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let u of c){let h=n?.firstParent?u.commit.parents.slice(0,1):u.commit.parents;for(let p of h){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let m=[];for(let u=l-1;u>=0;u--)d[u]===0&&m.push(u);for(;m.length>0;){let u=m.pop();yield c[u];let h=n?.firstParent?c[u].commit.parents.slice(0,1):c[u].commit.parents;for(let p of h){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&m.push(g)}}}}async function Di(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of Lt(e,t))r.add(a.hash);let o=new Set;for await(let a of Lt(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 Mi(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await ve(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of Lt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Wn;for(f.push(await Ir(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 Ir(e,d))}}return a}async function Zc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Lt(e,t))n.add(r.hash);return n}async function Ir(e,t){return{hash:t,commit:await j(e,t)}}var Wn,ar=Re(()=>{"use strict";ie();ce();we();Wn=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 Vo=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 Sa(e){return new Vo({_kind:"arg",type:e,required:!0})}function Ta(){return Sa("string")}function va(){return Sa("number")}var Ts=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 Yo=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 Aa(e){return new Yo({_kind:"option",type:e})}function Ha(){return Aa("string")}function Da(){return Aa("number")}var V={string:Ha,number:Da};function $(){return new Ts}var q={string:Ta,number:va};function Dd(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+=`
62
+ `}function Sr(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
+ `;let a=o>0?s.from.padEnd(o):s.from,c=s.suffix?` ${s.suffix}`:"";return`${i}${a} -> ${s.to}${c}
64
+ `}).join("")}function ao(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 Eh,kh,oe=Re(()=>{"use strict";Tn();Ce();ie();wn();pe();ze();we();Ln();cn();Jt();Eh=T("not a git repository (or any of the parent directories): .git"),kh=T("this operation must be run in a work tree")});var uf={};zd(uf,{CommitHeap:()=>Wn,countAheadBehind:()=>Bi,findOrphanedCommits:()=>Wi,walkCommits:()=>_t});async function*_t(e,t,n){if(n?.topoOrder){yield*Oh(e,t,n);return}let r=await df(e,n?.exclude),o=new Set(r),s=new Wn,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 Tr(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 Tr(e,h))}catch{}}}async function*Oh(e,t,n){let r=await df(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Tr(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 Tr(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 Bi(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 Wi(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await ve(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 Wn;for(f.push(await Tr(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 Tr(e,d))}}return a}async function df(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 Tr(e,t){return{hash:t,commit:await j(e,t)}}var Wn,fr=Re(()=>{"use strict";oe();ie();we();Wn=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 ri=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 _a(e){return new ri({_kind:"arg",type:e,required:!0})}function Fa(){return _a("string")}function Ua(){return _a("number")}var As=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var si=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 Ba(e){return new si({_kind:"option",type:e})}function Wa(){return Ba("string")}function qa(){return Ba("number")}var V={string:Wa,number:qa};function S(){return new As}var z={string:Fa,number:Ua};function Kd(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+=`
63
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+=`
64
- Run 'git help' for available commands.`,t}}}function Xo(e){return e.map(Dd).join(`
66
+ Run 'git help' for available commands.`,t}}}function oi(e){return e.map(Kd).join(`
65
67
  `)+`
66
- `}function Md(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function vs(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Md(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 Ma(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[m,u]of Object.entries(e)){let h=Ur(m);s.set(h,{key:m,def:u}),u.short&&i.set(u.short,{key:m,def:u})}let a={},c=[],f=[],l=0;for(;l<n.length;){let m=n[l];if(m==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(m.startsWith("--")){let u=m.indexOf("="),h,p;u!==-1?(h=m.slice(2,u),p=m.slice(u+1)):h=m.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,l++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:vs(h,x).map(b=>`--${b}`)}),l++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,l++;continue}let w=p??n[++l];if(w===void 0){o.push({type:"missing_value",name:g.key}),l++;continue}let R=Fr(w,g.def.type,g.key,o);R!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(R)):a[g.key]=R),l++;continue}if(m.startsWith("-")&&m.length>1){let u=m.slice(1);for(let h=0;h<u.length;h++){let p=u[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=u.slice(h+1),R=w.length>0?w:n[++l];if(R===void 0){o.push({type:"missing_value",name:g.key});break}let x=Fr(R,g.def.type,g.key,o);x!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(x)):a[g.key]=x);break}l++;continue}c.push(m),l++}let d=0;for(let m=0;m<t.length;m++){let u=t[m],h=u.name??`arg${m}`;if(u.variadic){let p=c.slice(d);p.length>0?a[h]=p.map(g=>Fr(g,u.type,h,o)):u.required?o.push({type:"missing_required",name:h,kind:"arg"}):u.default!==void 0?a[h]=u.default:a[h]=[],d=c.length}else{let p=c[d];p!==void 0?(a[h]=Fr(p,u.type,h,o),d++):u.required?o.push({type:"missing_required",name:h,kind:"arg"}):u.default!==void 0&&(a[h]=u.default)}}if(d<c.length)for(let m=d;m<c.length;m++)o.push({type:"unexpected_positional",value:c[m],maxPositionals:t.length});for(let[m,u]of Object.entries(e))if(a[m]===void 0){if(u._kind==="flag")a[m]=u.default??(u.counted?0:!1);else if(u._kind==="option"){let h=u;if(h.env&&r?.[h.env]!==void 0){let p=Fr(r[h.env],h.type,m,o);p!==void 0&&(a[m]=p)}a[m]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:m,kind:"option"}):h.default!==void 0&&(a[m]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Fr(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 Ur(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function yr(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=jd(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(`
67
- `)}function jd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Ur(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 ja(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Ga(e){return e?e.map(t=>t._def):[]}var As=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,ja(n.options),Ga(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=Ur(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=vs(o,[...this.children.keys()]);return{stdout:"",stderr:Xo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Gd(t))return{stdout:yr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ma(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:Xo(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:yr(this),stderr:"",exitCode:0}}};function Zo(e,t){return new As(e,t.description,ja(t.options),Ga(t.args),t.examples??[],t.handler,t.transformArgs)}function Gd(e){return e.some(t=>t==="--help")}ie();Js();Ce();me();is();var ro=1,vi=2,no=4,Ai=8,cs=16,Yc=new Set(["*","?","[","\\"]),lm={glob:ro,literal:vi,icase:no,top:Ai,exclude:cs};function ir(e){for(let t=0;t<e.length;t++)if(Yc.has(e[t]))return!0;return!1}function dm(e){for(let t=0;t<e.length;t++)if(Yc.has(e[t]))return t;return e.length}function Vc(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=lm[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Ai,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=cs,r=r.slice(2));n&vi&&n&ro&&(n&=~ro);let o;n&Ai||t===""?o=Vc(r):o=Vc(`${t}/${r}`);let s=!!(n&vi),i=s?!1:ir(o),a=s?o.length:dm(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function so(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&no),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&no){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&ro&&(i|=2),o&no&&(i|=1),cn(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&cs?so(o,t)&&(r=!0):so(o,t)&&(n=!0);return n&&!r}tt();function Xc(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:$().alias("A").describe("Add changes from all tracked and untracked files"),force:$().alias("f").describe("Allow adding otherwise ignored files"),update:$().alias("u").describe("Update tracked files"),"dry-run":$().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=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 Hi(s,p,a,"",c),n["dry-run"]||await fe(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
68
- Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],m=[];for(let p of f)ir(p)?m.push(p):d.push(p);let u=[];for(let p of d){let g=Ht(r.cwd,p),w=st(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return O(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=l.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`)),y=await mm(s,a,w,b);if(y){b&&((await r.fs.stat(g)).isDirectory?l=await Hi(s,l,g,w,c):l=(await ln(s,l,w)).index),u.push(y);continue}}if((await r.fs.stat(g)).isDirectory)l=await Hi(s,l,g,w,c);else{let b=l.entries.find(E=>E.path===w&&E.stage===0)?.hash,y=await ln(s,l,w);l=y.index,c.actions&&y.hash!==b&&c.actions.push(`add '${w}'
69
- `)}}else if(l.entries.some(b=>b.path===w||b.path.startsWith(`${w}/`))){if(c.actions)for(let b of l.entries)(b.path===w||b.path.startsWith(`${w}/`))&&c.actions.push(`remove '${b.path}'
70
- `);l={...l,entries:l.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return O(`pathspec '${p}' did not match any files`)}if(u.length>0)return n["dry-run"]||await fe(s,l),G(`The following paths are ignored by one of your .gitignore files:
68
+ `}function Vd(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 Ds(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Vd(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=Wr(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 y=[...s.keys()];o.push({type:"unknown_option",name:`--${m}`,suggestions:Ds(m,y).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=Br(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 y=Br(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=>Br(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]=Br(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=Br(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 Br(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 Wr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Er(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=Yd(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 Yd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Wr(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 Ka(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Va(e){return e?e.map(t=>t._def):[]}var Ms=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,Ka(n.options),Va(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=Wr(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=Ds(o,[...this.children.keys()]);return{stdout:"",stderr:oi([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Xd(t))return{stdout:Er(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:oi(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:Er(this),stderr:"",exitCode:0}}};function ii(e,t){return new Ms(e,t.description,Ka(t.options),Va(t.args),t.examples??[],t.handler,t.transformArgs)}function Xd(e){return e.some(t=>t==="--help")}oe();ro();Ce();pe();as();var fo=1,_i=2,co=4,Fi=8,fs=16,ff=new Set(["*","?","[","\\"]),xh={glob:fo,literal:_i,icase:co,top:Fi,exclude:fs};function cr(e){for(let t=0;t<e.length;t++)if(ff.has(e[t]))return!0;return!1}function Ch(e){for(let t=0;t<e.length;t++)if(ff.has(e[t]))return t;return e.length}function cf(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=xh[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Fi,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=fs,r=r.slice(2));n&_i&&n&fo&&(n&=~fo);let o;n&Fi||t===""?o=cf(r):o=cf(`${t}/${r}`);let s=!!(n&_i),i=s?!1:cr(o),a=s?o.length:Ch(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function lo(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&co),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&co){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&fo&&(i|=2),o&co&&(i|=1),fn(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&fs?lo(o,t)&&(r=!0):lo(o,t)&&(n=!0);return n&&!r}tt();function lf(e,t){e.command("add",{description:"Add file contents to the index",args:[z.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 q(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 K(s);return p=await Ui(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 K(s),d=[],h=[];for(let p of f)cr(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(k=>k.path===w||k.path.startsWith(`${w}/`)),x=await $h(s,a,w,R);if(x){R&&((await r.fs.stat(g)).isDirectory?l=await Ui(s,l,g,w,c):l=(await dn(s,l,w)).index),u.push(x);continue}}if((await r.fs.stat(g)).isDirectory)l=await Ui(s,l,g,w,c);else{let R=l.entries.find(k=>k.path===w&&k.stage===0)?.hash,x=await dn(s,l,w);l=x.index,c.actions&&x.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),N(`The following paths are ignored by one of your .gitignore files:
71
73
  ${u.join(`
72
74
  `)}
73
75
  hint: Use -f if you really want to add them.
74
76
  hint: Disable this message with "git config set advice.addIgnoredFile false"
75
- `);if(m.length>0){let p=await um(s,r.cwd,l,m,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await fe(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function um(e,t,n,r,o){let s=e.workTree,i=ut(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let m=0;m<a.length;m++)a[m].hasWildcard&&so(a[m],d)&&(c[m]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!Ee(a,d.path))continue;f(d.path);let m=H(s,d.path);if(await e.fs.exists(m)){let u=await ln(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 Ph(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 Ph(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&&lo(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}'
76
78
  `)}else o?.actions&&o.actions.push(`remove '${d.path}'
77
- `),l.push(d.path)}for(let d of l)n=lt(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(u=>u.path)),m=await ot(e,s,"",{skipIgnore:o?.skipIgnore});for(let u of m){if(d.has(u)||!Ee(a,u))continue;f(u),o?.actions&&o.actions.push(`add '${u}'
78
- `),n=(await ln(e,n,u)).index}}for(let d=0;d<a.length;d++){let m=a[d];if(!c[d]&&!(m.magic&cs))return{index:n,error:O(`pathspec '${m.original}' did not match any files`)}}return{index:n}}async function Hi(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=H(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,m=await ln(e,t,f.path);t=m.index,o?.actions&&(d||m.hash!==f.hash)&&o.actions.push(`add '${f.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 dn(e,n,u)).index}}for(let d=0;d<a.length;d++){let h=a[d];if(!c[d]&&!(h.magic&fs))return{index:n,error:T(`pathspec '${h.original}' did not match any files`)}}return{index:n}}async function Ui(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}'
79
81
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
80
- `),a.push(f.path)}for(let f of a)t=lt(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await ot(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
81
- `),t=(await ln(e,t,d)).index}}return t}async function mm(e,t,n,r){let o=await $r(e);try{let i=await e.fs.readFile(H(t,".gitignore"));o=rr(o,i,"",H(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=H(t,a);if(fn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(H(c,".gitignore"));o=rr(o,f,a,H(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(H(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(fn(o,n,i)==="ignored")return n}return null}ie();ie();ar();ce();me();we();async function $e(e,t){let n=H(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Me(e,t,n){await e.fs.writeFile(H(e.gitDir,t),n)}async function be(e,t){let n=H(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function fs(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 Nt(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG")}async function Ot(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG")}async function cr(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 ji="DETACH_POINT";async function Qc(e,t){await e.fs.writeFile(H(e.gitDir,ji),t)}async function yt(e){let t=H(e.gitDir,ji);await e.fs.exists(t)&&await e.fs.rm(t)}async function ls(e){let t=H(e.gitDir,ji);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();we();async function It(e){let t=await $e(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ds(e){let t=await $e(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
82
- `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function oo(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ds(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(H(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(H(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function St(e,t){let n=await $e(e,"BISECT_LOG")??"";await Me(e,"BISECT_LOG",n+t+`
83
- `)}async function io(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=H(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function ef(e,t,n,r,o){let s=[],i=new Map;for await(let g of Lt(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,R=[g.hash],x=0;for(;x<R.length;){let b=R[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let y=i.get(b);if(y)for(let E of y)!w.has(E)&&c.has(E)&&R.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,R=Math.abs(2*w-a);R<d&&(d=R,l=g.hash)}let m=!1;if(d===a){m=!0;for(let g of s){let w=f.get(g.hash)??0,R=Math.abs(2*w-a);R<d&&(d=R,l=g.hash)}}let u=s.find(g=>g.hash===l),h=pm(a),p=gm(a);return{hash:u.hash,subject:u.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:m}}function pm(e){return Math.floor((e-1)/2)}function gm(e){return e<=1?0:Math.ceil(Math.log2(e))}function tf(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=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 dn(e,t,d)).index}}return t}async function $h(e,t,n,r){let o=await Or(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=or(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=or(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();fr();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 Ae(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 ls(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 lr(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 qi="DETACH_POINT";async function hf(e,t){await e.fs.writeFile(v(e.gitDir,qi),t)}async function Et(e){let t=v(e.gitDir,qi);await e.fs.exists(t)&&await e.fs.rm(t)}async function ds(e){let t=v(e.gitDir,qi);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 us(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 uo(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await us(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 Ae(e,"BISECT_LOG",n+t+`
85
+ `)}async function ho(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 mf(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 R=b[y++];if(w.has(R)||!c.has(R))continue;w.add(R);let x=i.get(R);if(x)for(let k of x)!w.has(k)&&c.has(k)&&b.push(k)}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=Ih(a),p=Sh(a);return{hash:u.hash,subject:u.subject,remaining:m,steps:p,found:!1,onlySkippedLeft:h}}function Ih(e){return Math.floor((e-1)/2)}function Sh(e){return e<=1?0:Math.ceil(Math.log2(e))}function pf(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
84
86
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
85
87
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
86
- `}function nf(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
88
+ `}function gf(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
87
89
  [${e.hash}] ${e.subject}
88
- `}async function rf(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 wf(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
89
91
  `;return i+=`commit ${t}
90
92
  `,i+=`Author: ${n.author.name} <${n.author.email}>
91
93
  `,i+=`Date: ${s}
92
94
  `,i+=`
93
95
  `,i+=` ${r}
94
96
  `,i+=`
95
- `,i}ie();ar();Be();Ce();ce();me();ze();we();ie();ar();Be();Ce();ce();me();ce();wn();me();function Sr(e){return H(e.gitDir,"rebase-merge")}async function _t(e){return e.fs.exists(Sr(e))}async function Et(e){let t=Sr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(H(t,"head-name")),r=await e.fs.readFile(H(t,"orig-head")),o=await e.fs.readFile(H(t,"onto")),s=Number.parseInt(await e.fs.readFile(H(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(H(t,"end")),10),a=await e.fs.exists(H(t,"git-rebase-todo"))?H(t,"git-rebase-todo"):H(t,"todo"),c=sf(await e.fs.readFile(a)),f=await e.fs.exists(H(t,"done"))?await e.fs.readFile(H(t,"done")):"",l=sf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Gi(e,t){let n=Sr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(H(n,"head-name"),`${t.headName}
96
- `),await e.fs.writeFile(H(n,"orig-head"),`${t.origHead}
97
- `),await e.fs.writeFile(H(n,"onto"),`${t.onto}
98
- `),await e.fs.writeFile(H(n,"msgnum"),`${String(t.msgnum)}
99
- `),await e.fs.writeFile(H(n,"end"),`${String(t.end)}
100
- `),await e.fs.writeFile(H(n,"git-rebase-todo"),co(t.todo)),await e.fs.writeFile(H(n,"done"),co(t.done)),await e.fs.writeFile(H(n,"interactive"),"")}async function cf(e){let t=Sr(e),n=await Et(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(H(t,"msgnum"),`${String(n.msgnum)}
101
- `),await e.fs.writeFile(H(t,"git-rebase-todo"),co(n.todo)),await e.fs.writeFile(H(t,"done"),co(n.done))}async function Li(e){let t=Sr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function fo(e,t,n){let r=Sr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(H(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
97
+ `,i}oe();fr();Be();Ce();ie();pe();ze();we();oe();fr();Be();Ce();ie();pe();ie();wn();pe();function vr(e){return v(e.gitDir,"rebase-merge")}async function Ut(e){return e.fs.exists(vr(e))}async function kt(e){let t=vr(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=bf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=bf(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=vr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
98
+ `),await e.fs.writeFile(v(n,"orig-head"),`${t.origHead}
99
+ `),await e.fs.writeFile(v(n,"onto"),`${t.onto}
100
+ `),await e.fs.writeFile(v(n,"msgnum"),`${String(t.msgnum)}
101
+ `),await e.fs.writeFile(v(n,"end"),`${String(t.end)}
102
+ `),await e.fs.writeFile(v(n,"git-rebase-todo"),po(t.todo)),await e.fs.writeFile(v(n,"done"),po(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function kf(e){let t=vr(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"),po(n.todo)),await e.fs.writeFile(v(t,"done"),po(n.done))}async function Ki(e){let t=vr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function go(e,t,n){let r=vr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
102
104
  GIT_AUTHOR_EMAIL='${n.email}'
103
105
  GIT_AUTHOR_DATE='${o}'
104
- `),await e.fs.writeFile(H(r,"stopped-sha"),`${t}
105
- `)}function sf(e){let t=[];for(let n of e.split(`
106
- `)){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 co(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
106
+ `),await e.fs.writeFile(v(r,"stopped-sha"),`${t}
107
+ `)}function bf(e){let t=[];for(let n of e.split(`
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 po(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
107
109
  `)}
108
- `}async function ff(e,t,n){let r=new Map,[o,s]=await Promise.all([of(e,t,r),of(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 af(e,r,n,i),left:await af(e,r,t,a)}}async function of(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 ao(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function af(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 ao(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 ao(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 ao(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 m=(o.get(d)??0)-1;o.set(d,m),m<=0&&i.push(d)}}return a.reverse(),a}async function ao(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:sn(o.content)};return n.set(t,s),s}we();ce();function Tr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function wm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Tr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Tr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var bm=50;async function it(e,t,n=bm){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 m=r.get(d);if(m&&m.length>0){let u=wm(m,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 ym(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),m=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!m.has(u.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await Rm(e,f,c,n);if(l.length>0){let d=new Set(l.map(u=>u.oldPath)),m=new Set(l.map(u=>u.newPath));f=f.filter(u=>!d.has(u.path)),c=c.filter(u=>!m.has(u.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function ym(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=Tr(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=Tr(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 m=await Pt(e,l.oldHash),u=await Pt(e,d.newHash),h=km(m,u);h<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:h,oldMode:l.oldMode,newMode:d.newMode})}return i}var lf=107927;function lo(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))%lf;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%lf;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 Em(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 km(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:df(e.length,lo(e),t.length,lo(t))}function df(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Em(t,r);return Math.floor(i*100/o)}async function Rm(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Pt(e,l.oldHash);o.push({size:d.length,chunks:lo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Pt(e,l.newHash);s.push({size:d.length,chunks:lo(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],m=o[l];if(!(!d||!m))for(let u=0;u<n.length;u++){let h=n[u],p=s[u];if(!h||!p)continue;let g=df(m.size,m.chunks,p.size,p.chunks);if(g>=r){let w=Tr(d.path)===Tr(h.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:m}of i){if(a.has(d)||c.has(m))continue;a.add(d),c.add(m);let u=t[d],h=n[m];!u||!h||f.push({oldPath:u.path,newPath:h.path,oldHash:u.oldHash??"",newHash:h.newHash??"",similarity:l,oldMode:u.oldMode,newMode:h.newMode})}return f}function un(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),m=e.slice(0,o),u=e.slice(n-a),h=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${m}{${h} => ${p}}${u}`:`${e} => ${t}`}Ae();tt();async function at(e,t){let n=await Q(e),r=await Y(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=_i(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Ni(e,c,i,a),d=await gt(e,i),m=[],u=[];for(let g of d)g.status==="untracked"?u.push(g.path):m.push({path:g.path,status:g.status});m.sort((g,w)=>Ie(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Fi(u,h);return xm(e,r,s,o,i,l,m,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function uf(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 ${X(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 ${X(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function xm(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,m=await B(e,"CHERRY_PICK_HEAD"),u=await B(e,"REVERT_HEAD"),h=await B(e,"MERGE_HEAD"),p=!m&&!h,w=await _t(e)?await Et(e):null;if(n&&w){let C=X(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await ls(e);if(C){let P=t===C?"at":"from";l.push(`HEAD detached ${P} ${X(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await pe(e),P=await Jt(e,C,r);if(P){let I=fr(P,{abbreviated:f?.fromCommit});for(let v of I.trimEnd().split(`
109
- `))l.push(v);d=!0}}if(d&&(w||m||u||h)&&l.push(""),w&&h)uf(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=Mt(o),P=await e.fs.exists(H(e.gitDir,"MERGE_MSG"));uf(l,w);let v=w.headName==="detached HEAD"?null:Pe(w.headName),T=X(w.onto),N=v?` branch '${v}' on '${T}'`:"";if(C)l.push(`You are currently rebasing${N}.`),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(P)l.push(`You are currently rebasing${N}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let S=N?`You are currently editing a commit while rebasing${N}.`:"You are currently editing a commit during a rebase.";l.push(S),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 m?(l.push(`You are currently cherry-picking commit ${X(m)}.`),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 ${X(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):h&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await It(e)){let P=(await $e(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${P}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}let R=f?.isInitial??!t;R&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let y=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)',E=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),x&&l.push(x);for(let C of s)l.push(` ${mf(C.status,C.path,C.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(P=>P.status==="deleted by us"||P.status==="deleted by them"||P.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 P of a)l.push(` ${Cm(P.status,P.path)}`);l.push(""),E=!0}if(i.length>0){!E&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(y),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${mf(C.status,C.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 C of c)l.push(` ${C}`);l.push(""),E=!0}let k=s.length>0||!!h&&a.length===0;return!E&&d&&(f?.noWarn||k)&&l.push(""),!k&&!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)'):R?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 Rf(e,t,n){let r=new Map,[o,s]=await Promise.all([yf(e,t,r),yf(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 Ef(e,r,n,i),left:await Ef(e,r,t,a)}}async function yf(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 mo(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function Ef(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 mo(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 mo(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 mo(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 mo(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 Hr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Th(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Hr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Hr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var vh=50;async function ot(e,t,n=vh){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=Th(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 Hh(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 Mh(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 Hh(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=Hr(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=Hr(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=Dh(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 xf=107927;function wo(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))%xf;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%xf;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 Ah(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 Dh(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Cf(e.length,wo(e),t.length,wo(t))}function Cf(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Ah(t,r);return Math.floor(i*100/o)}async function Mh(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:wo(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:wo(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=Cf(h.size,h.chunks,p.size,p.chunks);if(g>=r){let w=Hr(d.path)===Hr(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}`}He();tt();async function it(e,t){let n=await Q(e),r=await Y(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await K(e),a=Yi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Vi(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)=>Ie(g.path,w.path));let m=new Set(i.entries.map(g=>g.path)),p=Xi(u,m);return jh(e,r,s,o,i,l,h,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Pf(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 ${X(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 ${X(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function jh(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=X(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await ds(e);if(C){let $=t===C?"at":"from";l.push(`HEAD detached ${$} ${X(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await he(e),$=await Bt(e,C,r);if($){let H=qn($,{abbreviated:f?.fromCommit});for(let P of H.trimEnd().split(`
111
+ `))l.push(P);d=!0}}if(d&&(w||h||u||m)&&l.push(""),w&&m)Pf(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"));Pf(l,w);let P=w.headName==="detached HEAD"?null:Pe(w.headName),I=X(w.onto),D=P?` branch '${P}' on '${I}'`:"";if(C)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 G=D?`You are currently editing a commit while rebasing${D}.`:"You are currently editing a commit during a rebase.";l.push(G),l.push(' (use "git commit --amend" to amend the current commit)'),l.push(' (use "git rebase --continue" once you are satisfied with your changes)')}d=!0}else h?(l.push(`You are currently cherry-picking commit ${X(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 ${X(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}let b=f?.isInitial??!t;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 x=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)',k=!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(` ${$f(C.status,C.path,C.displayPath)}`);l.push(""),k=!0}if(a.length>0){!k&&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(` ${Gh($.status,$.path)}`);l.push(""),k=!0}if(i.length>0){!k&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(x),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${$f(C.status,C.path)}`);l.push(""),k=!0}if(c.length>0){!k&&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(""),k=!0}let E=s.length>0||!!m&&a.length===0;return!k&&d&&(f?.noWarn||E)&&l.push(""),!E&&!f?.noWarn&&(!k&&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
112
  `)}
111
- `}async function Ni(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 le(e,s),a=new Map(Ne(n).map(u=>[u.path,u])),c=[];for(let[u,h]of a){if(o.has(u))continue;let p=i.get(u);p?p.hash!==h.hash&&c.push({path:u,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:u,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[u,h]of i)o.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:l}=await it(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},m=[];for(let u of f){let h=d[u.status];h&&m.push({path:u.path,status:h})}for(let u of l)m.push({path:u.newPath,status:"renamed",displayPath:`${u.oldPath} -> ${u.newPath}`});return m.sort((u,h)=>Ie(u.path,h.path))}function _i(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)=>Ie(r.path,o.path))}function Fi(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 mf(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Cm(e,t){return`${e}:`.padEnd(17)+t}async function Jt(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 Di(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function uo(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 fr(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
113
+ `}async function Vi(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(Le(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)=>Ie(u.path,m.path))}function Yi(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)=>Ie(r.path,o.path))}function Xi(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 $f(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Gh(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 Bi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function bo(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 qn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
112
114
  (use "git branch --unset-upstream" to fixup)
113
115
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
114
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}.
@@ -118,19 +120,19 @@ GIT_AUTHOR_DATE='${o}'
118
120
  `}let n=`Your branch and '${e.upstream}' have diverged,
119
121
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
120
122
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
121
- `}Ae();Xt();tt();async function mo(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 xn(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
123
+ `}He();Jt();tt();async function yo(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 Pn(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
122
124
  `),await B(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
123
- `),await cr(e),t}function Pm(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(`
125
+ `),await lr(e),t}function Lh(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(`
124
126
  `)}
125
- `:""}function qn(e){return e.entries.some(t=>t.stage>0)?{stdout:Pm(e),stderr:`error: you need to resolve your current index first
126
- `,exitCode:1}:null}async function ho(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");if(r)return $m(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))?G(`error: path '${t[0]}' is unmerged
127
- `):G(`error: pathspec '${t[0]}' did not match any file(s) known to git
128
- `);for(let a of i)await dt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function $m(e,t,n,r){let o=await le(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 G(`error: pathspec '${t[0]}' did not match any file(s) known to git
129
- `);for(let c of a){let f=o.get(c);f&&(await dt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Ct(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Se()}))}return await fe(e,s),{stdout:"",stderr:"",exitCode:0}}async function po(e,t,n,r,o){if(!e.workTree)return O("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await 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 G(`error: pathspec '${t[0]}' did not match any file(s) known to git
130
- `);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),m=l||d;if(m)await dt(e,{path:m.path,hash:m.hash,mode:m.mode});else if(s){let u=H(e.workTree,f);await e.fs.exists(u)&&await e.fs.rm(u)}else if(i.entries.some(h=>h.path===f&&h.stage>0))return G(`error: path '${f}' does not have ${r===2?"our":"their"} version
131
- `)}return{stdout:"",stderr:"",exitCode:0}}async function lr(e,t,n){if(!e.workTree)return"";let r=await Ke(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=H(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 pt("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(`
127
+ `:""}function zn(e){return e.entries.some(t=>t.stage>0)?{stdout:Lh(e),stderr:`error: you need to resolve your current index first
128
+ `,exitCode:1}:null}async function Eo(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");if(r)return Nh(e,t,n,r);let o=await K(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))?N(`error: path '${t[0]}' is unmerged
129
+ `):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
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 Nh(e,t,n,r){let o=await de(e,r),s=await K(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 N(`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:Se()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function ko(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 K(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 N(`error: pathspec '${t[0]}' did not match any file(s) known to git
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 N(`error: path '${f}' does not have ${r===2?"our":"their"} version
133
+ `)}return{stdout:"",stderr:"",exitCode:0}}async function dr(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=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(`
132
134
  `)}
133
- `)}var hf=5;function Om(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>hf?hf-1:t,i=e.slice(0,o).map(c=>` ${X(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
135
+ `)}var Of=5;function _h(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Of?Of-1:t,i=e.slice(0,o).map(c=>` ${X(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
134
136
  any of your branches:
135
137
 
136
138
  ${i.join(`
@@ -141,10 +143,10 @@ to do so with:
141
143
 
142
144
  git branch <new-branch-name> ${X(e[0].hash)}
143
145
 
144
- `}async function Ui(e,t){let n=await j(e,t);return`Previous HEAD position was ${X(t)} ${ue(n.message)}
145
- `}async function go(e,t,n){let r=await Mi(e,t,{targetHash:n});return r.length>0?Om(r):t!==n?Ui(e,t):""}async function dr(e,t,n,r,o,s){let i=await Q(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
146
- `,exitCode:0};let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),d=(await j(e,r)).tree,m=null;if(f&&(m=(await j(e,f)).tree),m!==d){let x=await Fn(e,m,d,a);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await fe(e,a),await De(e,x.worktreeOps)}let u="";i?.type==="direct"&&f&&(u=await go(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??ee;await Xe(e,"HEAD",n),await yt(e);let p=await xn(e);await oe(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await lr(e,d,a),w=await pe(e),R=await Jt(e,w,t);return R&&(g+=fr(R)),{stdout:g,stderr:`${u}Switched to branch '${t}'
147
- ${p}`,exitCode:0}}async function zn(e,t,n,r,o){let s=await z(e),i=qn(s);if(i)return i;let a=await Y(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Fn(e,l,f,s);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await fe(e,s),await De(e,x.worktreeOps)}let d=await Q(e),m=d?.type==="direct"&&a===t;if(await Z(e,"HEAD",t),!m){await Qc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ee;await oe(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let u=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=X(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await go(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
146
+ `}async function Zi(e,t){let n=await j(e,t);return`Previous HEAD position was ${X(t)} ${ue(n.message)}
147
+ `}async function Ro(e,t,n){let r=await Wi(e,t,{targetHash:n});return r.length>0?_h(r):t!==n?Zi(e,t):""}async function ur(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 K(e),f=zn(c);if(f)return f;let l=await Y(e),h=(await j(e,r)).tree,u=null;if(l&&(u=(await j(e,l)).tree),u!==h){let R=await Fn(e,u,h,c);if(!R.success)return R.errorOutput??N("error: checkout would overwrite local changes");c={version:2,entries:R.newEntries},await ae(e,c),await Me(e,R.worktreeOps)}let m="";a?.type==="direct"&&l&&(m=await Ro(e,l,r));let p=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):l??ee;await Ze(e,"HEAD",n),await Et(e);let g=await Pn(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 dr(e,h,c),b=await he(e),y=await Bt(e,b,t);return y&&(w+=qn(y)),{stdout:w,stderr:`${m}Switched to ${i?.isNew?"a new ":""}branch '${t}'
149
+ ${g}`,exitCode:0}}async function Kn(e,t,n,r,o){let s=await K(e),i=zn(s);if(i)return i;let a=await Y(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let y=await Fn(e,l,f,s);if(!y.success)return y.errorOutput??N("error: checkout would overwrite local changes");s={version:2,entries:y.newEntries},await ae(e,s),await Me(e,y.worktreeOps)}let d=await Q(e),h=d?.type==="direct"&&a===t;if(await Z(e,"HEAD",t),!h){await hf(e,t);let y=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ee;await se(e,n,"HEAD",a,t,`checkout: moving from ${y} to ${t}`)}let u=await Pn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let m=X(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Ro(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${m} ${p}
148
150
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
149
151
 
150
152
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -162,94 +164,94 @@ Or undo this operation with:
162
164
 
163
165
  Turn off this advice by setting config variable advice.detachedHead to false
164
166
 
165
- HEAD is now at ${h} ${p}
166
- `,w+=u,{stdout:await lr(e,f,s),stderr:w,exitCode:0}}async function Im(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 wo(e,t,n){let r=await Im(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 Je(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
167
- `}async function bo(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}ce();me();we();an();var pf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ms={stdout:`You need to start by "git bisect start"
168
- `,stderr:"",exitCode:1};async function Bi(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Y(e);return n||O("no current commit")}function gf(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]
169
- `,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:Am(a,o.env,t,s,i)}});Sm(n,t),Tm(n,t),Hm(n,t),Dm(n,t),jm(n,t),Gm(n,t),Nm(n,t),Fm(n,t),Um(n,t)}function Sm(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":V.string().describe("Alternate term for new/bad"),"term-bad":V.string().describe("Alternate term for new/bad"),"term-old":V.string().describe("Alternate term for old/good"),"term-good":V.string().describe("Alternate term for old/good"),"no-checkout":$().describe("Do not checkout the bisection commit"),"first-parent":$().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=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 pf.has(a)?O(`'${a}' is not a valid term`):pf.has(c)?O(`'${c}' is not a valid term`):a===c?O("'bad' and 'good' terms must be different"):wf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function wf(e,t,n,r,o,s,i,a){await It(e)&&await io(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Y(e)??"HEAD",await Me(e,"BISECT_START",f+`
170
- `),await Me(e,"BISECT_TERMS",`${o}
167
+ HEAD is now at ${m} ${p}
168
+ `,w+=u,{stdout:await dr(e,f,s),stderr:w,exitCode:0}}async function Fh(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 xo(e,t,n){let r=await Fh(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 Co(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();cn();var If=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ms={stdout:`You need to start by "git bisect start"
170
+ `,stderr:"",exitCode:1};async function Ji(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Y(e);return n||T("no current commit")}function Sf(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[z.string().name("subcommand").describe("Subcommand or custom term").optional(),z.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 M(a)?a:qh(a,o.env,t,s,i)}});Uh(n,t),Bh(n,t),zh(n,t),Kh(n,t),Yh(n,t),Xh(n,t),Jh(n,t),em(n,t),tm(n,t)}function Uh(e,t){e.command("start",{description:"Start bisecting",args:[z.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":V.string().describe("Alternate term for new/bad"),"term-bad":V.string().describe("Alternate term for new/bad"),"term-old":V.string().describe("Alternate term for old/good"),"term-good":V.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 q(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 If.has(a)?T(`'${a}' is not a valid term`):If.has(c)?T(`'${c}' is not a valid term`):a===c?T("'bad' and 'good' terms must be different"):Tf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function Tf(e,t,n,r,o,s,i,a){await Tt(e)&&await ho(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Y(e)??"HEAD",await Ae(e,"BISECT_START",f+`
172
+ `),await Ae(e,"BISECT_TERMS",`${o}
171
173
  ${s}
172
- `),await Me(e,"BISECT_NAMES",`
173
- `),a&&await Me(e,"BISECT_FIRST_PARENT",""),i){let m=await Y(e);m&&await Me(e,"BISECT_HEAD",m)}if(r.length>0){let m=r[0],u=await wt(e,m);if(M(u))return u;await Z(e,`refs/bisect/${o}`,u);let h=await j(e,u);await St(e,`# ${o}: [${u}] ${ue(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await wt(e,g);if(M(w))return w;await Z(e,`refs/bisect/${s}-${w}`,w);let R=await j(e,w);await St(e,`# ${s}: [${w}] ${ue(R.message)}`)}}let l=r.map(m=>`'${m}'`),d=l.length>0?` ${l.join(" ")}`:"";return await St(e,`git bisect start${d}`),hs(e,t,n)}function Tm(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:vm(s,o.env,t,n,r.rev)}})}async function vm(e,t,n,r,o){if(!await It(e))return ms;let s=await ds(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return us(e,t,n,i,s,o)}async function Am(e,t,n,r,o){if(!await It(e))return ms;let s=await ds(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
174
- `,exitCode:1}:us(e,t,n,r,s,o[0])}async function us(e,t,n,r,o,s){let i;if(s){let f=await wt(e,s);if(M(f))return f;i=f}else{let f=await Bi(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await Z(e,`refs/bisect/${o.termBad}`,i):await Z(e,`refs/bisect/${o.termGood}-${i}`,i),await St(e,`# ${r}: [${i}] ${c}`),await St(e,`git bisect ${r} ${i}`),hs(e,t,n)}function Hm(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 It(s))return ms;let i=n.revs??[];if(i.length===0){let a=await Bi(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 wt(s,a);if(M(l))return l;c=l}await Z(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await St(s,`# skip: [${c}] ${ue(f.message)}`),await St(s,`git bisect skip ${c}`)}return hs(s,r.env,t)}})}function Dm(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 It(s)?Mm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
175
- `,stderr:"",exitCode:0}}})}async function Mm(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await io(e),r){let s=await wt(e,r);return M(s)?s:zn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return dr(e,o,s,i,t,n);let a=await We(e,o);if(a)return zn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function jm(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 It(s)?{stdout:await $e(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
176
- `,exitCode:1}}})}function Gm(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:H(r.cwd,n.logfile);if(!await r.fs.exists(i))return O(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Lm(s,r.env,t,a)}})}async function Lm(e,t,n,r){await It(e)&&await io(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
177
- `)){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 m=l?l.split(/\s+/).map(u=>u.replace(/^'|'$/g,"")):[];d=await wf(e,t,n,m,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await us(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await us(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let m of l?l.split(/\s+/):[]){await Z(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await St(e,`# skip: [${m}] ${ue(u.message)}`),await St(e,`git bisect skip ${m}`)}d=await hs(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Nm(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 It(s))return ms;if(!r.exec)return O("bisect run requires shell execution support");let i=n.cmd.join(" ");return _m(s,r.env,t,i,r.exec,r.cwd)}})}async function _m(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
178
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let m=await Bi(e);if(M(m))return m;await Z(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await St(e,`# skip: [${m}] ${ue(u.message)}`),await St(e,`git bisect skip ${m}`);let h=await hs(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
179
- `,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await oo(e),l=c===0?f.termGood:f.termBad,d=await us(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
180
- `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function Fm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":$().describe("Show the term for the old state"),"term-bad":$().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 It(s))return{stdout:"",stderr:`error: no terms defined
181
- `,exitCode:1};let{termBad:i,termGood:a}=await ds(s);return n["term-good"]?{stdout:`${a}
174
+ `),await Ae(e,"BISECT_NAMES",`
175
+ `),a&&await Ae(e,"BISECT_FIRST_PARENT",""),i){let h=await Y(e);h&&await Ae(e,"BISECT_HEAD",h)}if(r.length>0){let h=r[0],u=await bt(e,h);if(M(u))return u;await Z(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 Z(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}`),ps(e,t,n)}function Bh(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:[z.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Wh(s,o.env,t,n,r.rev)}})}async function Wh(e,t,n,r,o){if(!await Tt(e))return ms;let s=await us(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return hs(e,t,n,i,s,o)}async function qh(e,t,n,r,o){if(!await Tt(e))return ms;let s=await us(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
176
+ `,exitCode:1}:hs(e,t,n,r,s,o[0])}async function hs(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 Ji(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await Z(e,`refs/bisect/${o.termBad}`,i):await Z(e,`refs/bisect/${o.termGood}-${i}`,i),await vt(e,`# ${r}: [${i}] ${c}`),await vt(e,`git bisect ${r} ${i}`),ps(e,t,n)}function zh(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[z.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return ms;let i=n.revs??[];if(i.length===0){let a=await Ji(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 Z(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 ps(s,r.env,t)}})}function Kh(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[z.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await Tt(s)?Vh(s,r.env,t,n.commit):{stdout:`We are not bisecting.
177
+ `,stderr:"",exitCode:0}}})}async function Vh(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await ho(e),r){let s=await bt(e,r);return M(s)?s:Kn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return ur(e,o,s,i,t,n);let a=await We(e,o);if(a)return Kn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Yh(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await q(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 Xh(e,t){e.command("replay",{description:"Replay a bisect log",args:[z.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await q(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 Zh(s,r.env,t,a)}})}async function Zh(e,t,n,r){await Tt(e)&&await ho(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 Tf(e,t,n,h,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await hs(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await hs(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let h of l?l.split(/\s+/):[]){await Z(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 ps(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Jh(e,t){e.command("run",{description:"Bisect by running a command",args:[z.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return ms;if(!r.exec)return T("bisect run requires shell execution support");let i=n.cmd.join(" ");return Qh(s,r.env,t,i,r.exec,r.cwd)}})}async function Qh(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 Ji(e);if(M(h))return h;await Z(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 ps(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 uo(e),l=c===0?f.termGood:f.termBad,d=await hs(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 em(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 q(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 us(s);return n["term-good"]?{stdout:`${a}
182
184
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
183
185
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
184
186
  and ${i} for the new state.
185
- `,stderr:"",exitCode:0}}})}function Um(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 It(i))return ms;let a=await oo(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
186
- `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(ar(),Jc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${X(l.hash)} ${ue(l.commit.message)}
187
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function hs(e,t,n){let r=await oo(e);return!r.badHash||r.goodHashes.length===0?{stdout:tf(r),stderr:"",exitCode:0}:(await Me(e,"BISECT_ANCESTORS_OK",""),Bm(e,t,n,r))}async function Bm(e,t,n,r){let o=await ef(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
188
- `,exitCode:1};if(o.found){let s=await rf(e,o.hash);return await St(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.
187
+ `,stderr:"",exitCode:0}}})}function tm(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(M(s))return s;let i=s;if(!await Tt(i))return ms;let a=await uo(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
188
+ `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(fr(),uf)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${X(l.hash)} ${ue(l.commit.message)}
189
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function ps(e,t,n){let r=await uo(e);return!r.badHash||r.goodHashes.length===0?{stdout:pf(r),stderr:"",exitCode:0}:(await Ae(e,"BISECT_ANCESTORS_OK",""),nm(e,t,n,r))}async function nm(e,t,n,r){let o=await mf(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
190
+ `,exitCode:1};if(o.found){let s=await wf(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.
189
191
  The first bad commit could be any of:
190
192
  `;for(let i of r.skipHashes)s+=i+`
191
193
  `;return r.badHash&&(s+=r.badHash+`
192
194
  `),s+=`We cannot bisect more!
193
- `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Me(e,"BISECT_HEAD",o.hash);else{let s=await zn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Me(e,"BISECT_EXPECTED_REV",o.hash+`
194
- `),{stdout:nf(o),stderr:"",exitCode:0}}ie();ce();function Ft(e){if(e.length===0)return[];let t=e.split(`
195
- `);return t[t.length-1]===""&&t.pop(),t}function Rt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
196
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Wm=4,bf=1024,yo=100,Ro=0,Eo=1,vr=2;function qi(e){let t=1;for(;t*t<e;)t++;return t}function qm(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 zm(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 yf(e,t,n,r){t-n>yo&&(n=t-yo),r-t>yo&&(r=t+yo);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Ro)o++;else if(f===vr)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===Ro)i++;else if(f===vr)a++;else break}return i===0?!1:(i+=o,a+=s,a*Wm<a+i)}function Km(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),m=Math.min(qi(t),bf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Ro:w>=m?l[g]=vr:l[g]=Eo}let u=Math.min(qi(r),bf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Ro:w>=u?d[g]=vr:d[g]=Eo}let h=[];for(let g=s;g<=i;g++)l[g]===Eo||l[g]===vr&&!yf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===Eo||d[g]===vr&&!yf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Kn=20,Ef=4,Vm=256,Ym=256,ko=2147483647;function kt(e,t){return e[t]??0}function Xm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,m=t-o,u=n-s,h=m-u&1,p=m,g=m,w=u,R=u;i[m]=t,a[u]=n;for(let x=1;;x++){let b=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let y=g;y>=p;y-=2){let E;kt(i,y-1)>=kt(i,y+1)?E=kt(i,y-1)+1:E=kt(i,y+1);let k=E,C=E-y;for(;E<n&&C<s&&e[E]===r[C];)E++,C++;if(E-k>Kn&&(b=!0),i[y]=E,h&&w<=y&&y<=R&&kt(a,y)<=E)return{i1:E,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=ko:++w,R<d?a[++R+1]=ko:--R;for(let y=R;y>=w;y-=2){let E;kt(a,y-1)<kt(a,y+1)?E=kt(a,y-1):E=kt(a,y+1)-1;let k=E,C=E-y;for(;E>t&&C>o&&e[E-1]===r[C-1];)E--,C--;if(k-E>Kn&&(b=!0),a[y]=E,!h&&p<=y&&y<=g&&E<=kt(i,y))return{i1:E,i2:C,minLo:!0,minHi:!0}}if(!c){if(b&&x>Vm){let y=0,E=null;for(let k=g;k>=p;k-=2){let C=k>m?k-m:m-k,P=kt(i,k),I=P-k,v=P-t+(I-o)-C;if(v>Ef*x&&v>y&&t+Kn<=P&&P<n&&o+Kn<=I&&I<s){let T=!0;for(let N=1;N<=Kn;N++)if(e[P-N]!==r[I-N]){T=!1;break}T&&(y=v,E={i1:P,i2:I,minLo:!0,minHi:!1})}}if(E)return E;y=0,E=null;for(let k=R;k>=w;k-=2){let C=k>u?k-u:u-k,P=kt(a,k),I=P-k,v=n-P+(s-I)-C;if(v>Ef*x&&v>y&&t<P&&P<=n-Kn&&o<I&&I<=s-Kn){let T=!0;for(let N=0;N<Kn;N++)if(e[P+N]!==r[I+N]){T=!1;break}T&&(y=v,E={i1:P,i2:I,minLo:!1,minHi:!0})}}if(E)return E}if(x>=f){let y=-1,E=-1;for(let P=g;P>=p;P-=2){let I=Math.min(kt(i,P),n),v=I-P;s<v&&(I=s+P,v=s),y<I+v&&(y=I+v,E=I)}let k=ko,C=ko;for(let P=R;P>=w;P-=2){let I=Math.max(t,kt(a,P)),v=I-P;v<o&&(I=o+P,v=o),I+v<k&&(k=I+v,C=I)}return n+s-k<y-(t+o)?{i1:E,i2:y-E,minLo:!0,minHi:!1}:{i1:C,i2:k-C,minLo:!1,minHi:!0}}}}}function zi(e,t,n,r,o,s,i,a,c,f,l,d,m,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 h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=Xm(e,t,n,r,o,s,l,d,m,u);zi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,u),zi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,u)}}function Zm(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 kf=200,Rf=20,xf=100,Jm=1,Qm=21,eh=-30,th=6,nh=-4,rh=10,sh=24,oh=17,ih=23,ah=17,ch=60;function Wi(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>=kf)return kf}return-1}function Cf(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=Wi(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Wi(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Rf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Wi(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Rf){r.postIndent=0;break}return r}function Pf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Jm),e.endOfFile&&(t.penalty+=Qm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=eh*r,t.penalty+=th*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?rh:nh:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?oh:sh:t.penalty+=s?ah:ih))}function fh(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return ch*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,m)=>t[d]===t[m];for(;;){if(a!==i){let d,m,u;do{for(d=a-i,m=-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&&(m=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&&(m=a)}}while(d!==a-i);if(a!==u)if(m!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=u;for(a-d-1>g&&(g=a-d-1),a-xf>g&&(g=a-xf);g<=a;g++){let w={effectiveIndent:0,penalty:0},R=Cf(n,r,g);Pf(R,w);let x=Cf(n,r,g-d);Pf(x,w),(h===-1||fh(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function Ki(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}=qm(e,t),{dstart:f,dend1:l,dend2:d}=zm(i,n,a,r);if(f>l)for(let m=f;m<r-(n-1-l);m++)s[m]=1;else if(f>d)for(let m=f;m<n-(r-1-d);m++)o[m]=1;else{let{refIndex1:m,nreff1:u,refIndex2:h,nreff2:p}=Km(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[m[E]];let w=new Array(p);for(let E=0;E<p;E++)w[E]=a[h[E]];let R={},x={},b=u+p+3,y=Math.max(Ym,qi(b));zi(g,0,u,w,0,p,o,s,m,h,R,x,!1,y)}else if(u===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<u;g++)o[m[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 ct(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}=Ki(e,t);return Zm(e,t,o,s)}var lh=3;function dh(e,t=lh){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=>uh(e,a.start,a.end))}function uh(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 xo(e){return e?e.length<40?e:X(e):"0000000"}function Of(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 mh(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==="",m=e.isDeleted??s==="";if(o===s&&!f)return"";let u=[];if(Of(u,e,l,d,m,f),o!==s){if(a||c){let h=xo(a),p=xo(c);d||m||f?u.push(`index ${h}..${p}`):u.push(`index ${h}..${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`):m?u.push(`Binary files a/${r} and /dev/null differ`):u.push(`Binary files a/${r} and b/${l} differ`)}return`${u.join(`
195
+ `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Ae(e,"BISECT_HEAD",o.hash);else{let s=await Kn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Ae(e,"BISECT_EXPECTED_REV",o.hash+`
196
+ `),{stdout:gf(o),stderr:"",exitCode:0}}oe();ie();function Wt(e){if(e.length===0)return[];let t=e.split(`
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 rm=4,vf=1024,Po=100,Io=0,$o=1,Ar=2;function ea(e){let t=1;for(;t*t<e;)t++;return t}function sm(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 om(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 Hf(e,t,n,r){t-n>Po&&(n=t-Po),r-t>Po&&(r=t+Po);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Io)o++;else if(f===Ar)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===Io)i++;else if(f===Ar)a++;else break}return i===0?!1:(i+=o,a+=s,a*rm<a+i)}function im(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),h=Math.min(ea(t),vf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Io:w>=h?l[g]=Ar:l[g]=$o}let u=Math.min(ea(r),vf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Io:w>=u?d[g]=Ar:d[g]=$o}let m=[];for(let g=s;g<=i;g++)l[g]===$o||l[g]===Ar&&!Hf(l,g,s,i)?m.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===$o||d[g]===Ar&&!Hf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:m,nreff1:m.length,refIndex2:p,nreff2:p.length}}var Vn=20,Af=4,am=256,cm=256,Oo=2147483647;function Rt(e,t){return e[t]??0}function fm(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 R=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let x=g;x>=p;x-=2){let k;Rt(i,x-1)>=Rt(i,x+1)?k=Rt(i,x-1)+1:k=Rt(i,x+1);let E=k,C=k-x;for(;k<n&&C<s&&e[k]===r[C];)k++,C++;if(k-E>Vn&&(R=!0),i[x]=k,m&&w<=x&&x<=b&&Rt(a,x)<=k)return{i1:k,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=Oo:++w,b<d?a[++b+1]=Oo:--b;for(let x=b;x>=w;x-=2){let k;Rt(a,x-1)<Rt(a,x+1)?k=Rt(a,x-1):k=Rt(a,x+1)-1;let E=k,C=k-x;for(;k>t&&C>o&&e[k-1]===r[C-1];)k--,C--;if(E-k>Vn&&(R=!0),a[x]=k,!m&&p<=x&&x<=g&&k<=Rt(i,x))return{i1:k,i2:C,minLo:!0,minHi:!0}}if(!c){if(R&&y>am){let x=0,k=null;for(let E=g;E>=p;E-=2){let C=E>h?E-h:h-E,$=Rt(i,E),H=$-E,P=$-t+(H-o)-C;if(P>Af*y&&P>x&&t+Vn<=$&&$<n&&o+Vn<=H&&H<s){let I=!0;for(let D=1;D<=Vn;D++)if(e[$-D]!==r[H-D]){I=!1;break}I&&(x=P,k={i1:$,i2:H,minLo:!0,minHi:!1})}}if(k)return k;x=0,k=null;for(let E=b;E>=w;E-=2){let C=E>u?E-u:u-E,$=Rt(a,E),H=$-E,P=n-$+(s-H)-C;if(P>Af*y&&P>x&&t<$&&$<=n-Vn&&o<H&&H<=s-Vn){let I=!0;for(let D=0;D<Vn;D++)if(e[$+D]!==r[H+D]){I=!1;break}I&&(x=P,k={i1:$,i2:H,minLo:!1,minHi:!0})}}if(k)return k}if(y>=f){let x=-1,k=-1;for(let $=g;$>=p;$-=2){let H=Math.min(Rt(i,$),n),P=H-$;s<P&&(H=s+$,P=s),x<H+P&&(x=H+P,k=H)}let E=Oo,C=Oo;for(let $=b;$>=w;$-=2){let H=Math.max(t,Rt(a,$)),P=H-$;P<o&&(H=o+$,P=o),H+P<E&&(E=H+P,C=H)}return n+s-E<x-(t+o)?{i1:k,i2:x-k,minLo:!0,minHi:!1}:{i1:C,i2:E-C,minLo:!1,minHi:!0}}}}}function ta(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=fm(e,t,n,r,o,s,l,d,h,u);ta(e,t,m.i1,r,o,m.i2,i,a,c,f,l,d,m.minLo,u),ta(e,m.i1,n,r,m.i2,s,i,a,c,f,l,d,m.minHi,u)}}function lm(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 Df=200,Mf=20,jf=100,dm=1,um=21,hm=-30,mm=6,pm=-4,gm=10,wm=24,bm=17,ym=23,Em=17,km=60;function Qi(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>=Df)return Df}return-1}function Gf(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=Qi(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Qi(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Mf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Qi(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Mf){r.postIndent=0;break}return r}function Lf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=dm),e.endOfFile&&(t.penalty+=um);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=hm*r,t.penalty+=mm*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?gm:pm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?bm:wm:t.penalty+=s?Em:ym))}function Rm(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return km*n+(e.penalty-t.penalty)}function Nf(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-jf>g&&(g=a-jf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Gf(n,r,g);Lf(b,w);let y=Gf(n,r,g-d);Lf(y,w),(m===-1||Rm(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 na(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}=sm(e,t),{dstart:f,dend1:l,dend2:d}=om(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}=im(i,n,a,r,c,f,l,d,o,s);if(u>0&&p>0){let g=new Array(u);for(let k=0;k<u;k++)g[k]=i[h[k]];let w=new Array(p);for(let k=0;k<p;k++)w[k]=a[m[k]];let b={},y={},R=u+p+3,x=Math.max(cm,ea(R));ta(g,0,u,w,0,p,o,s,h,m,b,y,!1,x)}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;Nf(o,i,e,n,s,r),Nf(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}=na(e,t);return lm(e,t,o,s)}var xm=3;function Cm(e,t=xm){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=>Pm(e,a.start,a.end))}function Pm(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 So(e){return e?e.length<40?e:X(e):"0000000"}function _f(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 $m(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(_f(u,e,l,d,h,f),o!==s){if(a||c){let m=So(a),p=So(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(`
197
199
  `)}
198
- `}function Tt(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=Te(n),d=Te(r);if(l||d)return mh(e,l,d);let m=Ft(n),u=Ft(r),h=n.length>0&&n.endsWith(`
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=Te(n),d=Te(r);if(l||d)return $m(e,l,d);let h=Wt(n),u=Wt(r),m=n.length>0&&n.endsWith(`
199
201
  `),p=r.length>0&&r.endsWith(`
200
- `),g="\0NOEOL",w=m;!h&&m.length>0&&(w=m.slice(),w[w.length-1]+=g);let R=u;!p&&u.length>0&&(R=u.slice(),R[R.length-1]+=g);let x=ct(w,R);if(!h||!p)for(let v of x)v.line.includes(g)&&(v.line=v.line.replace(g,""));let b=dh(x,e.contextLines);if(b.length===0&&!c)return"";let y=e.isNew??n==="",E=e.isDeleted??r==="",k=[];if(Of(k,e,f,y,E,c),b.length===0)return`${k.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=at(w,b);if(!m||!p)for(let P of y)P.line.includes(g)&&(P.line=P.line.replace(g,""));let R=Cm(y,e.contextLines);if(R.length===0&&!c)return"";let x=e.isNew??n==="",k=e.isDeleted??r==="",E=[];if(_f(E,e,f,x,k,c),R.length===0)return`${E.join(`
201
203
  `)}
202
- `;if(i||a){let v=xo(i),T=xo(a);y||E?k.push(`index ${v}..${T}`):c?k.push(`index ${v}..${T} ${o||"100644"}`):o&&s&&o!==s?k.push(`index ${v}..${T}`):k.push(`index ${v}..${T} ${o||"100644"}`)}let C=v=>v.includes(" ")?" ":"";y?(k.push("--- /dev/null"),k.push(`+++ b/${f}${C(f)}`)):E?(k.push(`--- a/${t}${C(t)}`),k.push("+++ /dev/null")):(k.push(`--- a/${t}${C(t)}`),k.push(`+++ b/${f}${C(f)}`));let P=m.length,I=u.length;for(let v of b){let T=v.oldCount===1?`${v.oldStart}`:`${v.oldStart},${v.oldCount}`,N=v.newCount===1?`${v.newStart}`:`${v.newStart},${v.newCount}`,S="",A=v.oldCount===0?v.oldStart-1:v.oldStart-2;for(let F=A;F>=0;F--){let U=m[F];if(U&&/^[a-zA-Z$_]/.test(U)){S=` ${U.trimEnd().slice(0,79)}`;break}}k.push(`@@ -${T} +${N} @@${S}`);let D=v.oldStart,_=v.newStart;for(let F of v.lines)switch(F.type){case"context":k.push(` ${F.content}`),(!h&&D===P||!p&&_===I)&&k.push("\"),D++,_++;break;case"delete":k.push(`-${F.content}`),!h&&D===P&&k.push("\"),D++;break;case"insert":k.push(`+${F.content}`),!p&&_===I&&k.push("\"),_++;break}}return`${k.join(`
204
+ `;if(i||a){let P=So(i),I=So(a);x||k?E.push(`index ${P}..${I}`):c?E.push(`index ${P}..${I} ${o||"100644"}`):o&&s&&o!==s?E.push(`index ${P}..${I}`):E.push(`index ${P}..${I} ${o||"100644"}`)}let C=P=>P.includes(" ")?" ":"";x?(E.push("--- /dev/null"),E.push(`+++ b/${f}${C(f)}`)):k?(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,H=u.length;for(let P of R){let I=P.oldCount===1?`${P.oldStart}`:`${P.oldStart},${P.oldCount}`,D=P.newCount===1?`${P.newStart}`:`${P.newStart},${P.newCount}`,G="",A=P.oldCount===0?P.oldStart-1:P.oldStart-2;for(let U=A;U>=0;U--){let F=h[U];if(F&&/^[a-zA-Z$_]/.test(F)){G=` ${F.trimEnd().slice(0,79)}`;break}}E.push(`@@ -${I} +${D} @@${G}`);let O=P.oldStart,_=P.newStart;for(let U of P.lines)switch(U.type){case"context":E.push(` ${U.content}`),(!m&&O===$||!p&&_===H)&&E.push("\"),O++,_++;break;case"delete":E.push(`-${U.content}`),!m&&O===$&&E.push("\"),O++;break;case"insert":E.push(`+${U.content}`),!p&&_===H&&E.push("\"),_++;break}}return`${E.join(`
203
205
  `)}
204
- `}ce();Ae();async function Vn(e,t,n){return(await le(e,t)).get(n)?.hash??null}async function If(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 it(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function hh(e,t,n,r,o,s){let i=await Vn(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,Yn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await se(e,i),c=Ft(a),f=new Array(o.length),l=[...r],d=t,m=n,u=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let P of l)f[P.finalIdx]=Yn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!0,void 0);break}let g=await Vn(e,p.tree,m),w=null,R=[];for(let P of p.parents){let I=await j(e,P),v=m,T=await Vn(e,I.tree,v);if(!T){let N=await If(e,I.tree,p.tree,m);N&&(v=N,T=await Vn(e,I.tree,v))}if(T&&(R.push({hash:P,path:v,blobHash:T}),T===g)){w={hash:P,path:v};break}}if(w){d=w.hash,m=w.path;continue}if(R.length===0){for(let P of l)f[P.finalIdx]=Yn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,void 0);break}let x=R[0],b=await se(e,x.blobHash),y=Ft(b),E=ct(y,u),k=new Map;for(let P of E)P.type==="keep"&&k.set(P.newLineNo,P.oldLineNo);let C=[];for(let P of l){let I=k.get(P.currentLine);I!==void 0?C.push({finalIdx:P.finalIdx,currentLine:I}):f[P.finalIdx]=Yn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,{hash:x.hash,path:x.path})}l=C,d=x.hash,m=x.path,u=y}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function Sf(e,t,n,r){let o=await j(e,t),s=await Vn(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=Ft(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),m=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),u=t,h=n,p=a;for(;m.length>0;){let g=await j(e,u);if(g.parents.length===0){for(let k of m)d[k.finalIdx]=Yn(u,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!0,void 0);break}let w=await Vn(e,g.tree,h),R=[],x=null;for(let k of g.parents){let C=await j(e,k),P=h,I=await Vn(e,C.tree,P);if(!I){let v=await If(e,C.tree,g.tree,h);v&&(P=v,I=await Vn(e,C.tree,P))}if(I){let v={hash:k,path:P,blobHash:I};if(R.push(v),I===w){x=v;break}}}if(x){u=x.hash,h=x.path;continue}if(R.length===0){for(let k of m)d[k.finalIdx]=Yn(u,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,void 0);break}if(R.length===1){let k=R[0],C=await se(e,k.blobHash),P=Ft(C),I=ct(P,p),v=new Map;for(let N of I)N.type==="keep"&&v.set(N.newLineNo,N.oldLineNo);let T=[];for(let N of m){let S=v.get(N.currentLine);S!==void 0?T.push({finalIdx:N.finalIdx,currentLine:S}):d[N.finalIdx]=Yn(u,h,N.currentLine,c+N.finalIdx,l[N.finalIdx],g,!1,{hash:k.hash,path:k.path})}m=T,u=k.hash,h=k.path,p=P;continue}let b=[];for(let k of R){let C=await se(e,k.blobHash),P=Ft(C),I=ct(P,p),v=new Map;for(let T of I)T.type==="keep"&&v.set(T.newLineNo,T.oldLineNo);b.push({info:k,newToOld:v})}let y=new Map;for(let k of m){let C=!1;for(let P=0;P<b.length;P++){let I=b[P],v=I.newToOld.get(k.currentLine);if(v!==void 0){let T=y.get(P);T||(T={info:I.info,lines:[]},y.set(P,T)),T.lines.push({finalIdx:k.finalIdx,currentLine:v}),C=!0;break}}C||(d[k.finalIdx]=Yn(u,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,{hash:R[0].hash,path:R[0].path}))}let E=y.get(0);for(let[k,C]of y){if(k===0)continue;let P=await hh(e,C.info.hash,C.info.path,C.lines,l,c);for(let[I,v]of P)d[I]=v}if(E&&E.lines.length>0){m=E.lines,u=E.info.hash,h=E.info.path;let k=await se(e,E.info.blobHash);p=Ft(k)}else break}return d}function Yn(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(`
205
- `)[0],boundary:i,previous:a}}ie();ce();Ae();ce();me();function ph(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 gh(e,t){let n=ph(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 wh(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 m=r?`<${d.author.email}>`:d.author.name;m.length>c&&(c=m.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 m;n?m=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:m=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let u=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${m}${u} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let h=r?`<${d.author.email}>`:d.author.name,p=gh(d.author.timestamp,d.author.timezone);l.push(`${m}${u} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
206
+ `}ie();He();async function Yn(e,t,n){return(await de(e,t)).get(n)?.hash??null}async function Ff(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 Om(e,t,n,r,o,s){let i=await Yn(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,Xn(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]=Xn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!0,void 0);break}let g=await Yn(e,p.tree,h),w=null,b=[];for(let $ of p.parents){let H=await j(e,$),P=h,I=await Yn(e,H.tree,P);if(!I){let D=await Ff(e,H.tree,p.tree,h);D&&(P=D,I=await Yn(e,H.tree,P))}if(I&&(b.push({hash:$,path:P,blobHash:I}),I===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]=Xn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,void 0);break}let y=b[0],R=await re(e,y.blobHash),x=Wt(R),k=at(x,u),E=new Map;for(let $ of k)$.type==="keep"&&E.set($.newLineNo,$.oldLineNo);let C=[];for(let $ of l){let H=E.get($.currentLine);H!==void 0?C.push({finalIdx:$.finalIdx,currentLine:H}):f[$.finalIdx]=Xn(d,h,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,{hash:y.hash,path:y.path})}l=C,d=y.hash,h=y.path,u=x}let m=new Map;for(let p of r)f[p.finalIdx]&&m.set(p.finalIdx,f[p.finalIdx]);return m}async function Uf(e,t,n,r){let o=await j(e,t),s=await Yn(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 E of h)d[E.finalIdx]=Xn(u,m,E.currentLine,c+E.finalIdx,l[E.finalIdx],g,!0,void 0);break}let w=await Yn(e,g.tree,m),b=[],y=null;for(let E of g.parents){let C=await j(e,E),$=m,H=await Yn(e,C.tree,$);if(!H){let P=await Ff(e,C.tree,g.tree,m);P&&($=P,H=await Yn(e,C.tree,$))}if(H){let P={hash:E,path:$,blobHash:H};if(b.push(P),H===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]=Xn(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 re(e,E.blobHash),$=Wt(C),H=at($,p),P=new Map;for(let D of H)D.type==="keep"&&P.set(D.newLineNo,D.oldLineNo);let I=[];for(let D of h){let G=P.get(D.currentLine);G!==void 0?I.push({finalIdx:D.finalIdx,currentLine:G}):d[D.finalIdx]=Xn(u,m,D.currentLine,c+D.finalIdx,l[D.finalIdx],g,!1,{hash:E.hash,path:E.path})}h=I,u=E.hash,m=E.path,p=$;continue}let R=[];for(let E of b){let C=await re(e,E.blobHash),$=Wt(C),H=at($,p),P=new Map;for(let I of H)I.type==="keep"&&P.set(I.newLineNo,I.oldLineNo);R.push({info:E,newToOld:P})}let x=new Map;for(let E of h){let C=!1;for(let $=0;$<R.length;$++){let H=R[$],P=H.newToOld.get(E.currentLine);if(P!==void 0){let I=x.get($);I||(I={info:H.info,lines:[]},x.set($,I)),I.lines.push({finalIdx:E.finalIdx,currentLine:P}),C=!0;break}}C||(d[E.finalIdx]=Xn(u,m,E.currentLine,c+E.finalIdx,l[E.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let k=x.get(0);for(let[E,C]of x){if(E===0)continue;let $=await Om(e,C.info.hash,C.info.path,C.lines,l,c);for(let[H,P]of $)d[H]=P}if(k&&k.lines.length>0){h=k.lines,u=k.info.hash,m=k.info.path;let E=await re(e,k.info.blobHash);p=Wt(E)}else break}return d}function Xn(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();He();ie();pe();function Im(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 Sm(e,t){let n=Im(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 Tm(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=Sm(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
208
  `)}
207
- `}function bh(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(`
209
+ `}function vm(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(`
208
210
  `)}
209
- `}function yh(e,t,n){if(e.startsWith("/"))return st(n,e);let r=st(n,t);return r===""||r==="."?e:`${r}/${e}`}function Tf(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:V.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:$().alias("l").describe("Show long revision"),showEmail:$().alias("e").describe("Show author email instead of name"),suppress:$().alias("s").describe("Suppress author name and date"),porcelain:$().alias("p").describe("Show in machine-readable format"),linePorcelain:$().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 O("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 O("no file specified");let m=yh(d,r.cwd,i.workTree),u;if(l){let E=await wt(i,l);if(M(E))return E;u=await ve(i,E)}else u=a;let h=await j(i,u),p=await le(i,h.tree);if(!p.has(m))return O(`no such path ${m} in ${l??"HEAD"}`);let g=p.get(m).hash,w=await se(i,g);if(Te(w))return O(`cannot blame binary file '${m}'`);let R,x;if(n.lineRange){let E=n.lineRange,k=E.match(/^(\d+),(\d+)$/);if(k)R=parseInt(k[1],10),x=parseInt(k[2],10);else return O(`invalid -L range: '${E}'`)}let b;try{b=await Sf(i,u,m,{startLine:R,endLine:x})}catch(E){let k=E instanceof Error?E.message:String(E);return O(k)}let y;return n.porcelain||n.linePorcelain?y=bh(b,!!n.linePorcelain):y=wh(b,m,!!n.long,!!n.showEmail,!!n.suppress),{stdout:y,stderr:"",exitCode:0}}})}ie();Be();Tn();ie();var Eh=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],kh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Cn(e,t){let n=Rh(t),r=new Date((e+n*60)*1e3),o=Eh[r.getUTCDay()],s=kh[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 Vi(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 Rh(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)}ce();Ae();var Co=new TextDecoder;function vf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
211
+ `}function Hm(e,t,n){if(e.startsWith("/"))return rt(n,e);let r=rt(n,t);return r===""||r==="."?e:`${r}/${e}`}function Bf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[z.string().name("args").variadic().optional()],options:{lineRange:V.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 q(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=Hm(d,r.cwd,i.workTree),u;if(l){let k=await bt(i,l);if(M(k))return k;u=await ve(i,k)}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(Te(w))return T(`cannot blame binary file '${h}'`);let b,y;if(n.lineRange){let k=n.lineRange,E=k.match(/^(\d+),(\d+)$/);if(E)b=parseInt(E[1],10),y=parseInt(E[2],10);else return T(`invalid -L range: '${k}'`)}let R;try{R=await Uf(i,u,h,{startLine:b,endLine:y})}catch(k){let E=k instanceof Error?k.message:String(k);return T(E)}let x;return n.porcelain||n.linePorcelain?x=vm(R,!!n.linePorcelain):x=Tm(R,h,!!n.long,!!n.showEmail,!!n.suppress),{stdout:x,stderr:"",exitCode:0}}})}oe();Be();Tn();oe();var Am=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Dm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function $n(e,t){let n=Mm(t),r=new Date((e+n*60)*1e3),o=Am[r.getUTCDay()],s=Dm[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 ra(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 Mm(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}ie();He();var To=new TextDecoder;function Wf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
210
212
  `&&t++;return e[e.length-1]!==`
211
- `&&t++,t}function Xn(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 Zn(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Pt(e,a.newHash);Dn(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:vf(Co.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Pt(e,a.oldHash);Dn(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:vf(Co.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Pt(e,a.oldHash),f=await Pt(e,a.newHash);if(Dn(c)||Dn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=Rt(Co.decode(c)),d=Rt(Co.decode(f)),m=ct(l,d),u=0,h=0;for(let p of m)p.type==="insert"?u++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:u,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=un(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await se(e,a.oldHash),m=await se(e,a.newHash);if(!Te(d)&&!Te(m)){let u=Rt(d),h=Rt(m),p=ct(u,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=un(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: ${Cn(r.timestamp,r.timezone)}`),i)return a.join(`
213
+ `&&t++,t}function Zn(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 Jn(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);Dn(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:Wf(To.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);Dn(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:Wf(To.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(Dn(c)||Dn(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(To.decode(c)),d=xt(To.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=hn(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(!Te(d)&&!Te(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=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: ${$n(r.timestamp,r.timezone)}`),i)return a.join(`
212
214
  `)+(a.length>0?`
213
- `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await it(e,c),{fileStats:d,modeLines:m}=await Zn(e,f,l),u=0,h=0;for(let g of d)u+=g.insertions,h+=g.deletions;let p=Xn(d.length,u,h);p&&a.push(p);for(let g of m)a.push(g);return a.join(`
215
+ `:"");let c=await Ke(e,t,n),{remaining:f,renames:l}=await ot(e,c),{fileStats:d,modeLines:h}=await Jn(e,f,l),u=0,m=0;for(let g of d)u+=g.insertions,m+=g.deletions;let p=Zn(d.length,u,m);p&&a.push(p);for(let g of h)a.push(g);return a.join(`
214
216
  `)+(a.length>0?`
215
- `:"")}var xh=80;function Ch(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 ur(e,t=xh){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=Ch(p.path,c);let f=c,l=[],d=0,m=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,m+=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,R=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let k=I=>I===0?0:1+Math.floor(I*(a-1)/r),C=k(w),P=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(x=k(p.insertions),b=P-x):(b=k(p.deletions),x=P-b)}let y="+".repeat(x)+"-".repeat(b),E=y?` ${y}`:"";l.push(` ${g} | ${R}${E}`)}let h=Xn(u,d,m);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
216
- `)}
217
- `}async function hn(e,t,n){let r=await Ve(e,t,n),{remaining:o,renames:s}=await it(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await Zn(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=ur(i);for(let f of a)c+=`${f}
218
- `;return c}Be();Ce();ce();we();Xt();async function Ph(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 Pn(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 Ut(e,t,n){if(t===n)return[t];let r=await Ph(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 Pn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:$h(e,t,n,c)}async function $h(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(m){let u=c.get(m);if(u!==void 0)return u;let h=(await j(e,m)).committer.timestamp;return c.set(m,h),h}for(;l.length>0;){let m=0,u=await d(l[0].hash);for(let R=1;R<l.length;R++){let x=l[R],b=await d(x.hash),y=l[m];(b>u||b===u&&x.seq<y.seq)&&(m=R,u=b)}let h=l.splice(m,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await j(e,h.hash);for(let R of w.parents)l.push({hash:R,mask:g,seq:f++})}for(let m of r)s.has(m)||i.push(m);return i}async function mr(e,t,n){let r=await xe(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
219
- `:`Merge branch '${t}' into ${n}
220
- `}async function Po(e,t,n){let r=await j(e,t),o=await j(e,n),s=X(t),i=X(n),a=`Updating ${s}..${i}
221
- `;if(e.workTree){let f=await z(e),l=await Kc(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 fe(e,{version:2,entries:l.newEntries}),await De(e,l.worktreeOps)}await jn(e,n);let c=await hn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
222
- ${c}`,stderr:"",exitCode:0}}ce();ze();we();function Af(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:$().alias("d").describe("Delete a branch"),forceDelete:$().alias("D").describe("Force delete a branch"),move:$().alias("m").describe("Rename a branch"),forceMove:$().alias("M").describe("Force rename a branch"),remotes:$().alias("r").describe("List remote-tracking branches"),all:$().alias("a").describe("List all branches"),setUpstreamTo:V.string().alias("u").describe("Set upstream tracking branch"),verbose:$().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,R;if(n.newName)w=n.name,R=n.newName;else if(n.name){if(!a)return O("not on any branch");w=a,R=n.name}else return O("branch name required");if(!bn(R))return O(`'${R}' is not a valid branch name`);let x=`refs/heads/${w}`,b=`refs/heads/${R}`,y=await B(s,x);if(!y)return O(`no branch named '${w}'`);if(await _t(s)&&(await Et(s))?.headName===x)return O(`branch ${x} is being rebased at ${s.workTree}`);let E=await B(s,b);if(E&&!c)return O(`a branch named '${R}' already exists`);E&&await he(s,b);let k=await et(s,x);await Z(s,b,y),await he(s,x),w===a&&await Xe(s,"HEAD",b),k.length>0&&await Ln(s,b,k);let C=`Branch: renamed ${x} to ${b}`;if(await oe(s,r.env,b,y,y,C),w===a){let v=await nn(s,r.env);await Ze(s,"HEAD",{oldHash:y,newHash:ee,...v,message:C}),await Ze(s,"HEAD",{oldHash:ee,newHash:y,...v,message:C})}let P=await pe(s),I=`branch "${w}"`;return P[I]&&(P[`branch "${R}"`]=P[I],delete P[I],await Je(s,P)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return O("branch name required");let w=n.name===a;if(!w&&!a&&await _t(s)&&(await Et(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return G(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
223
- `);let R=`refs/heads/${n.name}`,x=await B(s,R);if(!x)return G(`error: branch '${n.name}' not found
224
- `);let b="";if(!f){let y=await Y(s),k=(await pe(s))[`branch "${n.name}"`],C=k?.remote,P=k?.merge,I=null,v=null;if(C&&P&&(I=P.replace(/^refs\/heads\//,`refs/remotes/${C}/`),v=await B(s,I)),v&&I){if(!(x===v||await Pn(s,x,v))){let A=y!=null&&(x===y||await Pn(s,x,y))?`warning: not deleting branch '${n.name}' that is not yet merged to
225
- '${I}', even though it is merged to HEAD
226
- `:"";return G(`${A}error: the branch '${n.name}' is not fully merged
217
+ `:"")}var jm=80;function Gm(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 hr(e,t=jm){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=Gm(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,R;if(r<=a)y=p.insertions,R=p.deletions;else{let E=H=>H===0?0:1+Math.floor(H*(a-1)/r),C=E(w),$=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(y=E(p.insertions),R=$-y):(R=E(p.deletions),y=$-R)}let x="+".repeat(y)+"-".repeat(R),k=x?` ${x}`:"";l.push(` ${g} | ${b}${k}`)}let m=Zn(u,d,h);return m?l.push(m):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
218
+ `)}
219
+ `}async function pn(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 Jn(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=hr(i);for(let f of a)c+=`${f}
220
+ `;return c}Be();Ce();ie();we();Jt();async function Lm(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 Lm(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:Nm(e,t,n,c)}async function Nm(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 y=l[b],R=await d(y.hash),x=l[h];(R>u||R===u&&y.seq<x.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 mr(e,t,n,r){let o=await xe(e,"init.defaultBranch")??"main",s=r?` of ${r}`:"";return n===o?`Merge branch '${t}'${s}
221
+ `:`Merge branch '${t}'${s} into ${n}
222
+ `}async function vo(e,t,n){let r=await j(e,t),o=await j(e,n),s=X(t),i=X(n),a=`Updating ${s}..${i}
223
+ `;if(e.workTree){let f=await K(e),l=await af(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 Me(e,l.worktreeOps)}await Gn(e,n);let c=await pn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
224
+ ${c}`,stderr:"",exitCode:0}}ie();ze();we();function qf(e,t){e.command("branch",{description:"List, create, or delete branches",args:[z.string().name("name").describe("Branch name").optional(),z.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:V.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 q(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(!yn(b))return T(`'${b}' is not a valid branch name`);let y=`refs/heads/${w}`,R=`refs/heads/${b}`,x=await B(s,y);if(!x)return T(`no branch named '${w}'`);if(await Ut(s)&&(await kt(s))?.headName===y)return T(`branch ${y} is being rebased at ${s.workTree}`);let k=await B(s,R);if(k&&!c)return T(`a branch named '${b}' already exists`);k&&await me(s,R);let E=await et(s,y);await Z(s,R,x),await me(s,y),w===a&&await Ze(s,"HEAD",R),E.length>0&&await Nn(s,R,E);let C=`Branch: renamed ${y} to ${R}`;if(await se(s,r.env,R,x,x,C),w===a){let P=await rn(s,r.env);await Je(s,"HEAD",{oldHash:x,newHash:ee,...P,message:C}),await Je(s,"HEAD",{oldHash:ee,newHash:x,...P,message:C})}let $=await he(s),H=`branch "${w}"`;return $[H]&&($[`branch "${b}"`]=$[H],delete $[H],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 N(`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 N(`error: branch '${n.name}' not found
226
+ `);let R="";if(!f){let x=await Y(s),E=(await he(s))[`branch "${n.name}"`],C=E?.remote,$=E?.merge,H=null,P=null;if(C&&$&&(H=$.replace(/^refs\/heads\//,`refs/remotes/${C}/`),P=await B(s,H)),P&&H){if(!(y===P||await en(s,y,P))){let A=x!=null&&(y===x||await en(s,y,x))?`warning: not deleting branch '${n.name}' that is not yet merged to
227
+ '${H}', even though it is merged to HEAD
228
+ `:"";return N(`${A}error: the branch '${n.name}' is not fully merged
227
229
  hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
228
230
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
229
- `)}y!=null&&(x===y||await Pn(s,x,y))||(b=`warning: deleting branch '${n.name}' that has been merged to
230
- '${I}', but not yet merged to HEAD
231
- `)}else if(y&&x!==y&&!await Pn(s,x,y))return G(`error: the branch '${n.name}' is not fully merged
231
+ `)}x!=null&&(y===x||await en(s,y,x))||(R=`warning: deleting branch '${n.name}' that has been merged to
232
+ '${H}', but not yet merged to HEAD
233
+ `)}else if(x&&y!==x&&!await en(s,y,x))return N(`error: the branch '${n.name}' is not fully merged
232
234
  hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
233
235
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
234
- `)}return await he(s,R),{stdout:`Deleted branch ${n.name} (was ${X(x)}).
235
- `,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,R=n.name||a;if(!R)return O("could not set upstream of HEAD when it does not point to any branch.");if(!await B(s,`refs/heads/${R}`))return O(`branch '${R}' does not exist`);let b=w.indexOf("/");if(b<0)return O(`the requested upstream branch '${w}' does not exist`);let y=w.slice(0,b),E=w.slice(b+1);if(!await B(s,`refs/remotes/${w}`))return O(`the requested upstream branch '${w}' does not exist`);let C=await pe(s),P=`branch "${R}"`;return C[P]||(C[P]={}),C[P].remote=y,C[P].merge=`refs/heads/${E}`,await Je(s,C),{stdout:"",stderr:`branch '${R}' set up to track '${w}'.
236
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!bn(n.name))return O(`'${n.name}' is not a valid branch name`);let w=n.newName,R;if(w){let k=await je(s,w,`not a valid object name: '${w}'`);if(M(k))return k;R=k.hash}else if(R=await Y(s),!R)return O("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await B(s,x))return O(`a branch named '${n.name}' already exists`);await Z(s,x,R);let y=w??"HEAD";await oe(s,r.env,x,null,R,`branch: Created from ${y}`);let E="";return w&&(E=await wo(s,n.name,w)),{stdout:"",stderr:E,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,m=n.remotes||n.all,u=[];if(d&&!a){let w=await Y(s);if(w){let R=await _t(s),x;if(R){let b=await Et(s);if(b?.headName){let y=Pe(b.headName);if(y==="detached HEAD"){let E=await ls(s);x=`(no branch, rebasing detached HEAD ${E?X(E):"(null)"})`}else x=`(no branch, rebasing ${y})`}else x="(no branch)"}else{let b=await ls(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${X(b)})`:x="(no branch)"}u.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await ge(s,"refs/heads");for(let R of w){let x=Pe(R.name);u.push({displayName:x,hash:R.hash,isCurrent:x===a,branchName:x})}}if(m){let w=await ge(s,"refs/remotes");for(let R of w){let x=R.name.replace("refs/remotes/","");u.push({displayName:n.all?`remotes/${x}`:x,hash:R.hash,isCurrent:!1,branchName:null})}}if(u.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${u.map(R=>R.isCurrent?`* ${R.displayName}`:` ${R.displayName}`).join(`
236
+ `)}return await me(s,b),{stdout:`Deleted branch ${n.name} (was ${X(y)}).
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 x=w.slice(0,R),k=w.slice(R+1);if(!await B(s,`refs/remotes/${w}`))return T(`the requested upstream branch '${w}' does not exist`);let C=await he(s),$=`branch "${b}"`;return C[$]||(C[$]={}),C[$].remote=x,C[$].merge=`refs/heads/${k}`,await Xe(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 T(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let E=await Ge(s,w,`not a valid object name: '${w}'`);if(M(E))return E;b=E.hash}else if(b=await Y(s),!b)return T("Not a valid object name: 'HEAD'.");let y=`refs/heads/${n.name}`;if(await B(s,y))return T(`a branch named '${n.name}' already exists`);await Z(s,y,b);let x=w??"HEAD";await se(s,r.env,y,null,b,`branch: Created from ${x}`);let k="";return w&&(k=await xo(s,n.name,w)),{stdout:"",stderr:k,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,h=n.remotes||n.all,u=[];if(d&&!a){let w=await Y(s);if(w){let b=await Ut(s),y;if(b){let R=await kt(s);if(R?.headName){let x=Pe(R.headName);if(x==="detached HEAD"){let k=await ds(s);y=`(no branch, rebasing detached HEAD ${k?X(k):"(null)"})`}else y=`(no branch, rebasing ${x})`}else y="(no branch)"}else{let R=await ds(s);R?y=`(HEAD detached ${w===R?"at":"from"} ${X(R)})`: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/",""),R=null,x=await s.refStore.readRef(b.name);x?.type==="symbolic"&&(R=x.target.replace("refs/remotes/",""));let k=R?n.all?`remotes/${y} -> ${R}`:`${y} -> ${R}`:n.all?`remotes/${y}`:y;u.push({displayName:k,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(`
237
239
  `)}
238
- `,stderr:"",exitCode:0};let h=l>=1?await pe(s):null,p=Math.max(...u.map(w=>w.displayName.length)),g=[];for(let w of u){let R=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=X(w.hash),y="";try{let k=await j(s,w.hash);y=ue(k.message)}catch{}let E="";if(h&&w.branchName){let k=await Jt(s,h,w.branchName);if(k){let C=uo(k,l>=2);C&&(E=` ${C}`)}}g.push(`${R}${x} ${b}${E} ${y}`)}return{stdout:`${g.join(`
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?"* ":" ",y=w.displayName.padEnd(p),R=X(w.hash),x="";try{let E=await j(s,w.hash);x=ue(E.message)}catch{}let k="";if(m&&w.branchName){let E=await Bt(s,m,w.branchName);if(E){let C=bo(E,l>=2);C&&(k=` ${C}`)}}g.push(`${b}${y} ${R}${k} ${x}`)}return{stdout:`${g.join(`
239
241
  `)}
240
- `,stderr:"",exitCode:0}}})}function de(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Oh=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Ih=["commitMsg","mergeMsg"],Sh=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Th=["onRefUpdate","onRefDelete","onObjectWrite"];function vh(...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 Oh){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(de(a))return a}})}for(let r of Ih){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(de(a))return a}})}for(let r of Sh){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 Th){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}ie();Be();Ce();ce();ze();we();an();tt();function Df(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:$().alias("b").describe("Create and switch to a new branch"),forceBranch:$().alias("B").describe("Create/reset and switch to a new branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:$().describe("Create a new orphan branch"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().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 O("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return O("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return O(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let m=ut(i,r.cwd),u=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return O("cannot specify both a revision and --ours/--theirs");let p=await je(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?po(i,u,m,n.theirs?3:2):ho(i,u,m,h)}if(n.orphan)return n.branch?O("--orphan and -b are incompatible"):n.ours||n.theirs?O("--orphan and --ours/--theirs are incompatible"):a?Hh(i,a,r.env,t):O("you must specify a branch to checkout");if(n.detach){let m=a??"HEAD",u=await je(i,m,`invalid reference: ${m}`);return M(u)?u:Hf(i,m,u.hash,r.env,t)}if(!a)return O("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Dh(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Ah(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Mf(i,a,c,f,r.env,t);let l=await bo(i,a);if(l)return Mh(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let m=await ve(i,d);return Hf(i,a,m,r.env,t)}if(i.workTree){let m=await z(i),u=Ls(m,a);if(u)return await dt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return G(`error: pathspec '${a}' did not match any file(s) known to git
241
- `)}})}async function Ah(e,t,n){let r=await mo(e);return r?Mf(e,r.name,r.refName,r.hash,t,n):O("no previous branch")}async function Hh(e,t,n,r){if(!bn(t))return O(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return O(`a branch named '${t}' already exists`);let i=await z(e),a=qn(i);if(a)return a;let c=await Y(e),f=null;c&&(f=(await j(e,c)).tree),await Xe(e,"HEAD",o),await yt(e);let l=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ee,isBranchCheckout:!0});let d="";return f&&(d=await lr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
242
- ${l}`,exitCode:0}}async function Dh(e,t,n,r,o=!1){if(!bn(t))return O(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(s))return G(s.message??"");let i=await Q(e),a=await Y(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return O(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=qn(g);if(w)return w}a&&await Z(e,c,a),await Xe(e,"HEAD",c),await yt(e);let l=await xn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??ee;a&&(f?f!==a&&await oe(e,n,c,f,a,"branch: Reset to HEAD"):await oe(e,n,c,null,a,"branch: Created from HEAD")),await oe(e,n,"HEAD",a,a??ee,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??ee,isBranchCheckout:!0});let m="";if(o&&a){let g=await z(e),w=await j(e,a);m=await lr(e,w.tree,g)}let u=await pe(e),h=await Jt(e,u,t);h&&(m+=fr(h));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 _m=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Fm=["commitMsg","mergeMsg"],Um=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Bm=["onRefUpdate","onRefDelete","onObjectWrite"];function Wm(...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 _m){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 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)try{await i(s)}catch{}})}for(let r of Bm){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();cn();tt();function Kf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[z.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 q(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 Ge(i,a,`invalid reference: ${a}`);if(M(p))return p;m=p.commit.tree}return n.ours||n.theirs?ko(i,u,h,n.theirs?3:2):Eo(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?zm(i,a,r.env,t):T("you must specify a branch to checkout");if(n.detach){let h=a??"HEAD",u=await Ge(i,h,`invalid reference: ${h}`);return M(u)?u:zf(i,h,u.hash,r.env,t)}if(!a)return T("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Km(i,a,r.env,t,!!n.forceBranch);if(a==="-")return qm(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Vf(i,a,c,f,r.env,t);let l=await Co(i,a);if(l)return Vm(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let h=await ve(i,d);return zf(i,a,h,r.env,t)}if(i.workTree){let h=await K(i),u=Fs(h,a);if(u)return await lt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return N(`error: pathspec '${a}' did not match any file(s) known to git
243
+ `)}})}async function qm(e,t,n){let r=await yo(e);return r?Vf(e,r.name,r.refName,r.hash,t,n):T("no previous branch")}async function zm(e,t,n,r){if(!yn(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 K(e),a=zn(i);if(a)return a;let c=await Y(e),f=null;c&&(f=(await j(e,c)).tree),await Ze(e,"HEAD",o),await Et(e);let l=await Pn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ee,isBranchCheckout:!0});let d="";return f&&(d=await dr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
244
+ ${l}`,exitCode:0}}async function Km(e,t,n,r,o=!1){if(!yn(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 N(s.message??"");let i=await Q(e),a=await Y(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 K(e),w=zn(g);if(w)return w}a&&await Z(e,c,a),await Ze(e,"HEAD",c),await Et(e);let l=await Pn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??ee;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??ee,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??ee,isBranchCheckout:!0});let h="";if(o&&a){let g=await K(e),w=await j(e,a);h=await dr(e,w.tree,g)}let u=await he(e),m=await Bt(e,u,t);m&&(h+=qn(m));let p=f?`Switched to and reset branch '${t}'
243
245
  `:`Switched to a new branch '${t}'
244
- `;return{stdout:m,stderr:`${p}${l}`,exitCode:0}}async function Mf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return de(i)?G(i.message??""):dr(e,t,n,r,o,s)}async function Mh(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(s))return G(s.message??"");let i=await B(e,n);if(!i)return O(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await Z(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 Je(e,d),await oe(e,r,a,null,i,`branch: Created from ${n}`);let m=await dr(e,t,a,i,r,o),u=c.slice(1).join("/");return m.stderr=`branch '${t}' set up to track '${f}/${u}'.
245
- ${m.stderr}`,m}async function Hf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return de(s)?G(s.message??""):zn(e,n,r,o,{detachAdviceTarget:t})}ie();Be();Ce();ie();function Yi(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}=Ki(e,t);return jh(o,n,s,r)}function jh(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 Gh(e,t,n){let r=[];for(let c of Yi(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 Yi(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 m=r[a];if(m.oStart>l)break;l=Math.max(l,m.oStart+m.oLength),d.push(m),a++}if(d.length===1){if(c.abLength>0){let m=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:m.slice(c.abStart,c.abStart+c.abLength)})}}else{let m={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 R=w.oStart,x=R+w.oLength,b=w.abStart,y=b+w.abLength,E=m[w.ab];E.abMin=Math.min(b,E.abMin),E.abMax=Math.max(y,E.abMax),E.oMin=Math.min(R,E.oMin),E.oMax=Math.max(x,E.oMax)}let u=m.a.abMin+(f-m.a.oMin),h=m.a.abMax+(l-m.a.oMax),p=m.b.abMin+(f-m.b.oMin),g=m.b.abMax+(l-m.b.oMax);o.push({stable:!1,a:e.slice(u,h),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function Lh(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Gh(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&&Gf(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"?jf(i):jf(Nh(i))}function ps(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=Lh(e,t,n,{conflictStyle:s}),d=!1,m=[];for(let u of l)u.type==="ok"?m.push(...u.lines):(d=!0,s==="diff3"?m.push(i,...u.a,a,...u.o,c,...u.b,f):m.push(i,...u.a,c,...u.b,f));return{conflict:d,result:m}}function Nh(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(..._h(n));return t}function _h(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Gf(t,n))return[e];let r=Yi(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 jf(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 hr(e,t,n,r){let o=ps(vt(e),vt(t),vt(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(Xi);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
246
+ `;return{stdout:h,stderr:`${p}${l}`,exitCode:0}}async function Vf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(i)?N(i.message??""):ur(e,t,n,r,o,s)}async function Vm(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return N(s.message??"");let i=await B(e,n);if(!i)return T(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await Z(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 ur(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)?N(s.message??""):Kn(e,n,r,o,{detachAdviceTarget:t})}oe();Be();Ce();oe();function sa(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}=na(e,t);return Ym(o,n,s,r)}function Ym(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 Xm(e,t,n){let r=[];for(let c of sa(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 sa(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,R=w.abStart,x=R+w.abLength,k=h[w.ab];k.abMin=Math.min(R,k.abMin),k.abMax=Math.max(x,k.abMax),k.oMin=Math.min(b,k.oMin),k.oMax=Math.max(y,k.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 Zm(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Xm(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&&Xf(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"?Yf(i):Yf(Jm(i))}function gs(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=Zm(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 Jm(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Qm(n));return t}function Qm(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Xf(t,n))return[e];let r=sa(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 Yf(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 pr(e,t,n,r){let o=gs(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(oa);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
246
248
  `)}
247
249
  `:a.join(`
248
- `)}function vt(e){if(e==="")return[];let t=e.split(`
249
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function Xi(e){return e.endsWith("\0")?e.slice(0,-1):e}function Gf(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();ce();wn();me();nr();Ae();tt();Xt();var Ar=new TextDecoder,Jn=new TextEncoder,Lf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Bt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Uh(e,t,n,r),f=await Wh(e,s,i,a,c,o);return qh(e,s,o,f)}async function ws(e,t,n,r){let o=await Ut(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Bt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Bt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Kf(e,t,n,o,1);return{...await Bt(e,a,s.tree,i.tree,r),baseTree:a}}async function Uh(e,t,n,r){let o=await le(e,t),s=await le(e,n),i=await le(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,m=i.get(f)??null,u=l?{hash:l.hash,mode:l.mode}:null,h=d?{hash:d.hash,mode:d.mode}:null,p=m?{hash:m.hash,mode:m.mode}:null,g=(l?1:0)|(d?2:0)|(m?4:0),w=l?.hash??null,R=d?.hash??null,x=m?.hash??null,b=0;w!==null&&w===R&&(b|=3),w!==null&&w===x&&(b|=5),R!==null&&R===x&&(b|=6);let y={path:f,stages:[u,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(Bh(y)){c.set(f,y);continue}c.set(f,y)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Bh(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 Wh(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,D]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:D.hash,oldMode:D.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:D.hash,oldMode:D.mode});for(let[A,D]of r)n.has(A)||a.push({path:A,status:"added",newHash:D.hash,newMode:D.mode});for(let[A,D]of o)n.has(A)||c.push({path:A,status:"added",newHash:D.hash,newMode:D.mode});let f=await it(e,a),l=await it(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,m=new Map;for(let A of f.renames)d.set(A.oldPath,A);for(let A of l.renames)m.set(A.oldPath,A);let u=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&u.add(A);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,D,_=0){i.msgBuf.push({sortKey:A,subOrder:_,text:D})}for(let A of[...n.keys()].sort()){let D=d.get(A),_=m.get(A);if(!D&&!_)continue;let F=n.get(A);if(h.add(A),D&&_)if(h.add(D.newPath),h.add(_.newPath),D.newPath===_.newPath){let U=r.get(D.newPath),L=o.get(_.newPath);if(U.hash===L.hash)i.entries.push(xt(D.newPath,U));else{let K=Zi(t,D.newPath);K.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],K.pathnames=[A,D.newPath,_.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let U=r.get(D.newPath),L=o.get(_.newPath),K=await zf(e,F,U,L,s);K.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:D.newPath,theirsPath:_.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${D.newPath} in ${p} and to ${_.newPath} in ${g}.`),i.entries.push(xt(A,F,1)),i.entries.push(ft(D.newPath,U.mode,K.hash,2)),i.entries.push(ft(_.newPath,L.mode,K.hash,3)),i.worktreeBlobs.set(D.newPath,{hash:K.hash,mode:U.mode}),i.worktreeBlobs.set(_.newPath,{hash:K.hash,mode:L.mode})}else if(D){h.add(D.newPath);let U=o.get(A),L=r.get(D.newPath),K=u.has(D.newPath);if(U)if(K)await Wf(e,i,D.newPath,A,F,L,U,r,o,!1,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(D.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(D.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(D.newPath,L.mode,U.hash));else{let te=Zi(t,D.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:L.hash,mode:L.mode},{hash:U.hash,mode:U.mode}],te.pathnames=[A,D.newPath,A],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=o.get(D.newPath);if(i.conflicts.push({path:D.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(D.newPath,`CONFLICT (rename/delete): ${A} renamed to ${D.newPath} in ${p}, but deleted in ${g}.`),te){i.conflicts.push({path:D.newPath,reason:"add-add"}),w(D.newPath,`Auto-merging ${D.newPath}`,0),w(D.newPath,`CONFLICT (add/add): Merge conflict in ${D.newPath}`,1),i.entries.push(xt(D.newPath,L,2)),i.entries.push(xt(D.newPath,te,3));let J=await $o(e,L.hash,te.hash,L.mode,s);i.worktreeBlobs.set(D.newPath,{hash:J,mode:L.mode})}else i.entries.push(ft(D.newPath,F.mode,F.hash,1)),i.entries.push(xt(D.newPath,L,2)),i.worktreeBlobs.set(D.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(D.newPath,`CONFLICT (modify/delete): ${D.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${D.newPath} left in tree.`,1)}}else if(_){h.add(_.newPath);let U=r.get(A),L=o.get(_.newPath),K=u.has(_.newPath);if(U)if(K)await Wf(e,i,_.newPath,A,F,U,L,r,o,!0,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(_.newPath,L.mode,U.hash));else{let te=Zi(t,_.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],te.pathnames=[A,A,_.newPath],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=r.get(_.newPath);if(i.conflicts.push({path:_.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(_.newPath,`CONFLICT (rename/delete): ${A} renamed to ${_.newPath} in ${g}, but deleted in ${p}.`),te){i.conflicts.push({path:_.newPath,reason:"add-add"}),w(_.newPath,`Auto-merging ${_.newPath}`,0),w(_.newPath,`CONFLICT (add/add): Merge conflict in ${_.newPath}`,1),i.entries.push(xt(_.newPath,te,2)),i.entries.push(xt(_.newPath,L,3));let J=await $o(e,te.hash,L.hash,te.mode,s);i.worktreeBlobs.set(_.newPath,{hash:J,mode:te.mode})}else i.entries.push(ft(_.newPath,F.mode,F.hash,1)),i.entries.push(xt(_.newPath,L,3)),i.worktreeBlobs.set(_.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(_.newPath,`CONFLICT (modify/delete): ${_.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${_.newPath} left in tree.`,1)}}}let R=new Set(f.renames.map(A=>A.newPath)),x=new Set(l.renames.map(A=>A.newPath)),b=Nf(n,r),y=Nf(n,o),E=_f(b,o,n),k=_f(y,r,n),C=Ff(f.renames,E),P=Ff(l.renames,k),I=Uf(C),v=Uf(P);for(let A of[...I.keys()])v.has(A)&&(I.delete(A),v.delete(A));let T=new Set(I.keys()),N=new Set(v.keys());if(v.size>0)for(let A of a){if(A.status!=="added"||R.has(A.path))continue;let D=Bf(A.path,v,T);if(!D)continue;if(t.has(D)||n.has(D)||r.has(D)||o.has(D)){if(r.has(D)){w(D,`CONFLICT (implicit dir rename): Existing file/dir at ${D} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let U=r.get(A.path),L=o.get(D)??n.get(D);i.entries.push(ft(D,U.mode,U.hash,2)),L&&i.entries.push(ft(D,L.mode,L.hash,3)),i.worktreeBlobs.set(D,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:D,reason:"add-add"}),w(D,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${D}.`,1);let K=t.get(A.path);K&&(K.merged={result:null,clean:!0}),h.add(A.path);continue}let _=r.get(A.path);i.entries.push(ft(D,_.mode,_.hash,2)),i.worktreeBlobs.set(D,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:D,reason:"directory-rename"}),w(D,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${D}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path)}if(I.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let D=Bf(A.path,I,N);if(!D)continue;if(t.has(D)||n.has(D)||r.has(D)||o.has(D)){if(o.has(D)){w(D,`CONFLICT (implicit dir rename): Existing file/dir at ${D} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let U=o.get(A.path),L=r.get(D)??n.get(D);L&&i.entries.push(ft(D,L.mode,L.hash,2)),i.entries.push(ft(D,U.mode,U.hash,3)),i.worktreeBlobs.set(D,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:D,reason:"add-add"}),w(D,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${D}.`,1);let K=t.get(A.path);K&&(K.merged={result:null,clean:!0}),h.add(A.path);continue}let _=o.get(A.path);i.entries.push(ft(D,_.mode,_.hash,3)),i.worktreeBlobs.set(D,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:D,reason:"directory-rename"}),w(D,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${D}.`,1);let F=t.get(A.path);F&&(F.merged={result:null,clean:!0}),h.add(A.path)}let S=new Set(i.entries.map(A=>A.path));for(let A of S){let D=t.get(A);D&&(D.merged={result:null,clean:!0})}for(let A of h){if(S.has(A))continue;let D=t.get(A);if(!D||D.merged.clean)continue;D.filemask===7&&!D.pathConflict||(D.merged={result:null,clean:!0})}return i}function Nf(e,t){let n=new Set;for(let s of e.keys()){let i=At(s);for(;i;)n.add(i),i=At(i)}let r=new Set;for(let s of t.keys()){let i=At(s);for(;i;)r.add(i),i=At(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function _f(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=At(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=At(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=At(s)}return r}function Ff(e,t){let n=new Map;for(let r of e){let o=At(r.oldPath),s=At(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=At(o),s=At(s)}}return n}function Uf(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 Bf(e,t,n){let r=At(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=At(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function At(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Wf(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),m=f?i:s;if(d.hash===m.hash){t.entries.push(ft(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await zf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(ft(n,d.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(xt(n,d,2)),t.entries.push(ft(n,i.mode,h.hash,3));let p=await $o(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(ft(n,s.mode,h.hash,2)),t.entries.push(xt(n,d,3));let p=await $o(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function zf(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(yn(t.mode)||yn(n.mode)||yn(r.mode))return{hash:n.hash,conflict:!0};let a=await se(e,t.hash),c=await se(e,n.hash),f=await se(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let l=vt(a),d=vt(c),m=vt(f),u=o?.conflictStyle,h=ps(d,l,m,{conflictStyle:u});if(!h.conflict)return{hash:await Qi(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,R=s?.theirsPath?`${g}:${s.theirsPath}`:g,x=hr(c,a,f,{a:w,b:R,markerSize:i??7,conflictStyle:u});return{hash:await He(e,"blob",Jn.encode(x)),conflict:!0}}async function $o(e,t,n,r,o){let s=await se(e,t),i=await se(e,n),a=hr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return He(e,"blob",Jn.encode(a))}function xt(e,t,n=0){return ft(e,t.mode,t.hash,n)}function ft(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Se()}}async function qh(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(u,h,p=0){i.push({sortKey:u,subOrder:p,text:h})}for(let u of[...t.keys()].sort()){let h=t.get(u);if(h.merged.clean){h.merged.result?.hash&&o.push(_e(u,h.merged.result.hash,h.merged.result.mode));continue}await zh(e,h,n,o,s,c,a)}i.sort((u,h)=>(u.sortKey<h.sortKey?-1:u.sortKey>h.sortKey?1:0)||u.subOrder-h.subOrder);let f=i.map(u=>u.text),l=[],d=new Set;for(let u of o)u.stage===0&&(l.push(u),d.add(u.path));for(let[u,h]of a)d.has(u)||l.push(_e(u,h.hash,h.mode));l.sort((u,h)=>Ie(u.path,h.path));let m=await Fe(e,l);return{entries:o,conflicts:s,messages:f,resultTree:m}}async function zh(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,m=f?.hash??null,u=l?.hash??null;if(m===null&&u!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,l.mode,3)),i.set(a,{hash:u,mode:l.mode});return}if(u===null&&m!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,f.mode,2)),i.set(a,{hash:m,mode:f.mode});return}if(d===null&&m!==null&&u!==null){if(m===u){r.push(_e(a,m,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await se(e,m),p=await se(e,u);if(Te(h)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,m,f.mode,2)),r.push(_e(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let g=vt(""),w=vt(h),R=vt(p),x=ps(w,g,R,{conflictStyle:n?.conflictStyle});if(!x.conflict){let E=await Qi(e,x.result);r.push(_e(a,E,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,m,f.mode,2)),r.push(_e(a,u,l.mode,3));let b=hr(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),y=await He(e,"blob",Jn.encode(b));i.set(a,{hash:y,mode:f.mode});return}if(d!==null&&m!==null&&u!==null){if(m===d){r.push(_e(a,u,l.mode));return}if(u===d){r.push(_e(a,m,f.mode));return}if(m===u){r.push(_e(a,m,f.mode));return}if(s(a,`Auto-merging ${a}`,0),yn(c.mode)||yn(f.mode)||yn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,f.mode,2)),r.push(_e(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let h=await se(e,d),p=await se(e,m),g=await se(e,u);if(Te(p)||Te(g)||Te(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,f.mode,2)),r.push(_e(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let w=vt(h),R=vt(p),x=vt(g),b=ps(R,w,x,{conflictStyle:n?.conflictStyle});if(b.conflict){let y=t.pathnames[1],E=t.pathnames[2],k=y!==a||E!==a,C={path:a,reason:"content"};k&&(y!==a&&(C.oursOrigPath=y),E!==a&&(C.theirsOrigPath=E)),o.push(C),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,f.mode,2)),r.push(_e(a,u,l.mode,3));let P=k?`${n?.a??"HEAD"}:${y}`:n?.a??"HEAD",I=k?`${n?.b??"theirs"}:${E}`:n?.b??"theirs",v=hr(p,h,g,{a:P,b:I,conflictStyle:n?.conflictStyle}),T=await He(e,"blob",Jn.encode(v));i.set(a,{hash:T,mode:f.mode})}else{let y=await Qi(e,b.result);r.push(_e(a,y,f.mode))}return}}var Kh=200;async function Kf(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await j(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await j(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],m=(await j(e,d)).tree,u=null;if(o>=Kh)u=f;else{let g=await Ut(e,c,d);g.length===0?u=null:g.length===1?u=(await j(e,g[0])).tree:u=await Kf(e,c,d,g,o+1)}let h=await Bt(e,u,f,m);f=await Vh(e,h,o);let p=on({type:"commit",tree:f,parents:[c,d],author:Lf,committer:Lf,message:"merged common ancestors"});c=await He(e,"commit",p)}return f}async function Vh(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,m=s(a.path,1),u=s(l,2),h=s(d,3);if(u&&h){let p=Ar.decode((await ye(e,u.hash)).content),g=Ar.decode((await ye(e,h.hash)).content),w=m?Ar.decode((await ye(e,m.hash)).content):"",R=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",y=hr(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:R}),E=await He(e,"blob",Jn.encode(y));r.push({path:l,mode:u.mode,hash:E,stage:0,stat:Se()}),r.push({path:d,mode:h.mode,hash:E,stage:0,stat:Se()});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=Ar.decode((await ye(e,c.hash)).content),d=Ar.decode((await ye(e,f.hash)).content),m=a.reason==="content"?s(a.path,1):null,u=m?Ar.decode((await ye(e,m.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,R=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=hr(l,u,d,{a:w,o:i.o,b:R,markerSize:i.markerSize}),b=await He(e,"blob",Jn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Se()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ie(a.path,c.path)),Fe(e,r)}async function Qi(e,t){let n=t.map(Xi);if(n.length===0)return He(e,"blob",Jn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
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 oa(e){return e.endsWith("\0")?e.slice(0,-1):e}function Xf(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Ce();ie();wn();pe();sr();He();tt();Jt();var Dr=new TextDecoder,Qn=new TextEncoder,Zf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function zt(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await tp(e,t,n,r),f=await rp(e,s,i,a,c,o);return sp(e,s,o,f)}async function bs(e,t,n,r){let o=await qt(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await zt(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await zt(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await il(e,t,n,o,1);return{...await zt(e,a,s.tree,i.tree,r),baseTree:a}}async function tp(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,R=0;w!==null&&w===b&&(R|=3),w!==null&&w===y&&(R|=5),b!==null&&b===y&&(R|=6);let x={path:f,stages:[u,m,p],pathnames:[f,f,f],filemask:g,matchMask:R,merged:{result:null,clean:!1},pathConflict:!1};if(np(x)){c.set(f,x);continue}c.set(f,x)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function np(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 rp(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,O]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:O.hash,oldMode:O.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:O.hash,oldMode:O.mode});for(let[A,O]of r)n.has(A)||a.push({path:A,status:"added",newHash:O.hash,newMode:O.mode});for(let[A,O]of o)n.has(A)||c.push({path:A,status:"added",newHash:O.hash,newMode:O.mode});let f=await ot(e,a),l=await ot(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,h=new Map;for(let A of f.renames)d.set(A.oldPath,A);for(let A of l.renames)h.set(A.oldPath,A);let u=new Set;for(let[A]of r)!n.has(A)&&o.has(A)&&u.add(A);let m=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(A,O,_=0){i.msgBuf.push({sortKey:A,subOrder:_,text:O})}for(let A of[...n.keys()].sort()){let O=d.get(A),_=h.get(A);if(!O&&!_)continue;let U=n.get(A);if(m.add(A),O&&_)if(m.add(O.newPath),m.add(_.newPath),O.newPath===_.newPath){let F=r.get(O.newPath),L=o.get(_.newPath);if(F.hash===L.hash)i.entries.push(Ct(O.newPath,F));else{let W=ia(t,O.newPath);W.stages=[{hash:U.hash,mode:U.mode},{hash:F.hash,mode:F.mode},{hash:L.hash,mode:L.mode}],W.pathnames=[A,O.newPath,_.newPath],W.filemask=7,W.merged={result:null,clean:!1}}}else{let F=r.get(O.newPath),L=o.get(_.newPath),W=await ol(e,U,F,L,s);W.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:O.newPath,theirsPath:_.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${O.newPath} in ${p} and to ${_.newPath} in ${g}.`),i.entries.push(Ct(A,U,1)),i.entries.push(ct(O.newPath,F.mode,W.hash,2)),i.entries.push(ct(_.newPath,L.mode,W.hash,3)),i.worktreeBlobs.set(O.newPath,{hash:W.hash,mode:F.mode}),i.worktreeBlobs.set(_.newPath,{hash:W.hash,mode:L.mode})}else if(O){m.add(O.newPath);let F=o.get(A),L=r.get(O.newPath),W=u.has(O.newPath);if(F)if(W)await rl(e,i,O.newPath,A,U,L,F,r,o,!1,s);else if(F.hash===U.hash&&L.hash===U.hash)i.entries.push(Ct(O.newPath,L));else if(F.hash===U.hash)i.entries.push(Ct(O.newPath,L));else if(L.hash===U.hash)i.entries.push(ct(O.newPath,L.mode,F.hash));else{let ne=ia(t,O.newPath);ne.stages=[{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode},{hash:F.hash,mode:F.mode}],ne.pathnames=[A,O.newPath,A],ne.filemask=7,ne.merged={result:null,clean:!1}}else{let ne=o.get(O.newPath);if(i.conflicts.push({path:O.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(O.newPath,`CONFLICT (rename/delete): ${A} renamed to ${O.newPath} in ${p}, but deleted in ${g}.`),ne){i.conflicts.push({path:O.newPath,reason:"add-add"}),w(O.newPath,`Auto-merging ${O.newPath}`,0),w(O.newPath,`CONFLICT (add/add): Merge conflict in ${O.newPath}`,1),i.entries.push(Ct(O.newPath,L,2)),i.entries.push(Ct(O.newPath,ne,3));let J=await Ho(e,L.hash,ne.hash,L.mode,s);i.worktreeBlobs.set(O.newPath,{hash:J,mode:L.mode})}else i.entries.push(ct(O.newPath,U.mode,U.hash,1)),i.entries.push(Ct(O.newPath,L,2)),i.worktreeBlobs.set(O.newPath,{hash:L.hash,mode:L.mode}),L.hash!==U.hash&&w(O.newPath,`CONFLICT (modify/delete): ${O.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${O.newPath} left in tree.`,1)}}else if(_){m.add(_.newPath);let F=r.get(A),L=o.get(_.newPath),W=u.has(_.newPath);if(F)if(W)await rl(e,i,_.newPath,A,U,F,L,r,o,!0,s);else if(F.hash===U.hash&&L.hash===U.hash)i.entries.push(Ct(_.newPath,L));else if(F.hash===U.hash)i.entries.push(Ct(_.newPath,L));else if(L.hash===U.hash)i.entries.push(ct(_.newPath,L.mode,F.hash));else{let ne=ia(t,_.newPath);ne.stages=[{hash:U.hash,mode:U.mode},{hash:F.hash,mode:F.mode},{hash:L.hash,mode:L.mode}],ne.pathnames=[A,A,_.newPath],ne.filemask=7,ne.merged={result:null,clean:!1}}else{let ne=r.get(_.newPath);if(i.conflicts.push({path:_.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:A}),w(_.newPath,`CONFLICT (rename/delete): ${A} renamed to ${_.newPath} in ${g}, but deleted in ${p}.`),ne){i.conflicts.push({path:_.newPath,reason:"add-add"}),w(_.newPath,`Auto-merging ${_.newPath}`,0),w(_.newPath,`CONFLICT (add/add): Merge conflict in ${_.newPath}`,1),i.entries.push(Ct(_.newPath,ne,2)),i.entries.push(Ct(_.newPath,L,3));let J=await Ho(e,ne.hash,L.hash,ne.mode,s);i.worktreeBlobs.set(_.newPath,{hash:J,mode:ne.mode})}else i.entries.push(ct(_.newPath,U.mode,U.hash,1)),i.entries.push(Ct(_.newPath,L,3)),i.worktreeBlobs.set(_.newPath,{hash:L.hash,mode:L.mode}),L.hash!==U.hash&&w(_.newPath,`CONFLICT (modify/delete): ${_.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${_.newPath} left in tree.`,1)}}}let b=new Set(f.renames.map(A=>A.newPath)),y=new Set(l.renames.map(A=>A.newPath)),R=Jf(n,r),x=Jf(n,o),k=Qf(R,o,n),E=Qf(x,r,n),C=el(f.renames,k),$=el(l.renames,E),H=tl(C),P=tl($);for(let A of[...H.keys()])P.has(A)&&(H.delete(A),P.delete(A));let I=new Set(H.keys()),D=new Set(P.keys());if(P.size>0)for(let A of a){if(A.status!=="added"||b.has(A.path))continue;let O=nl(A.path,P,I);if(!O)continue;if(t.has(O)||n.has(O)||r.has(O)||o.has(O)){if(r.has(O)){w(O,`CONFLICT (implicit dir rename): Existing file/dir at ${O} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=r.get(A.path),L=o.get(O)??n.get(O);i.entries.push(ct(O,F.mode,F.hash,2)),L&&i.entries.push(ct(O,L.mode,L.hash,3)),i.worktreeBlobs.set(O,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:O,reason:"add-add"}),w(O,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${O}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),m.add(A.path);continue}let _=r.get(A.path);i.entries.push(ct(O,_.mode,_.hash,2)),i.worktreeBlobs.set(O,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:O,reason:"directory-rename"}),w(O,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${O}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),m.add(A.path)}if(H.size>0)for(let A of c){if(A.status!=="added"||y.has(A.path))continue;let O=nl(A.path,H,D);if(!O)continue;if(t.has(O)||n.has(O)||r.has(O)||o.has(O)){if(o.has(O)){w(O,`CONFLICT (implicit dir rename): Existing file/dir at ${O} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let F=o.get(A.path),L=r.get(O)??n.get(O);L&&i.entries.push(ct(O,L.mode,L.hash,2)),i.entries.push(ct(O,F.mode,F.hash,3)),i.worktreeBlobs.set(O,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:O,reason:"add-add"}),w(O,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${O}.`,1);let W=t.get(A.path);W&&(W.merged={result:null,clean:!0}),m.add(A.path);continue}let _=o.get(A.path);i.entries.push(ct(O,_.mode,_.hash,3)),i.worktreeBlobs.set(O,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:O,reason:"directory-rename"}),w(O,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${O}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),m.add(A.path)}let G=new Set(i.entries.map(A=>A.path));for(let A of G){let O=t.get(A);O&&(O.merged={result:null,clean:!0})}for(let A of m){if(G.has(A))continue;let O=t.get(A);if(!O||O.merged.clean)continue;O.filemask===7&&!O.pathConflict||(O.merged={result:null,clean:!0})}return i}function Jf(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 Qf(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 el(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 tl(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 nl(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 rl(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),h=f?i:s;if(d.hash===h.hash){t.entries.push(ct(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let m=await ol(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===m.hash)t.entries.push(ct(n,d.mode,m.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,d,2)),t.entries.push(ct(n,i.mode,m.hash,3));let p=await Ho(e,d.hash,m.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(ct(n,s.mode,m.hash,2)),t.entries.push(Ct(n,d,3));let p=await Ho(e,m.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function ol(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(En(t.mode)||En(n.mode)||En(r.mode))return{hash:n.hash,conflict:!0};let a=await re(e,t.hash),c=await re(e,n.hash),f=await re(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let l=At(a),d=At(c),h=At(f),u=o?.conflictStyle,m=gs(d,l,h,{conflictStyle:u});if(!m.conflict)return{hash:await ca(e,m.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,b=s?.theirsPath?`${g}:${s.theirsPath}`:g,y=pr(c,a,f,{a:w,b,markerSize:i??7,conflictStyle:u});return{hash:await De(e,"blob",Qn.encode(y)),conflict:!0}}async function Ho(e,t,n,r,o){let s=await re(e,t),i=await re(e,n),a=pr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return De(e,"blob",Qn.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:Se()}}async function sp(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(u,m,p=0){i.push({sortKey:u,subOrder:p,text:m})}for(let u of[...t.keys()].sort()){let m=t.get(u);if(m.merged.clean){m.merged.result?.hash&&o.push(Ne(u,m.merged.result.hash,m.merged.result.mode));continue}await op(e,m,n,o,s,c,a)}i.sort((u,m)=>(u.sortKey<m.sortKey?-1:u.sortKey>m.sortKey?1:0)||u.subOrder-m.subOrder);let f=i.map(u=>u.text),l=[],d=new Set;for(let u of o)u.stage===0&&(l.push(u),d.add(u.path));for(let[u,m]of a)d.has(u)||l.push(Ne(u,m.hash,m.mode));l.sort((u,m)=>Ie(u.path,m.path));let h=await Fe(e,l);return{entries:o,conflicts:s,messages:f,resultTree:h}}async function op(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,h=f?.hash??null,u=l?.hash??null;if(h===null&&u!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let m=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(Ne(a,d,c.mode,1)),r.push(Ne(a,u,l.mode,3)),i.set(a,{hash:u,mode:l.mode});return}if(u===null&&h!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let m=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(Ne(a,d,c.mode,1)),r.push(Ne(a,h,f.mode,2)),i.set(a,{hash:h,mode:f.mode});return}if(d===null&&h!==null&&u!==null){if(h===u){r.push(Ne(a,h,f.mode));return}s(a,`Auto-merging ${a}`,0);let m=await re(e,h),p=await re(e,u);if(Te(m)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Ne(a,h,f.mode,2)),r.push(Ne(a,u,l.mode,3)),i.set(a,{hash:h,mode:f.mode});return}let g=At(""),w=At(m),b=At(p),y=gs(w,g,b,{conflictStyle:n?.conflictStyle});if(!y.conflict){let k=await ca(e,y.result);r.push(Ne(a,k,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(Ne(a,h,f.mode,2)),r.push(Ne(a,u,l.mode,3));let R=pr(m,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),x=await De(e,"blob",Qn.encode(R));i.set(a,{hash:x,mode:f.mode});return}if(d!==null&&h!==null&&u!==null){if(h===d){r.push(Ne(a,u,l.mode));return}if(u===d){r.push(Ne(a,h,f.mode));return}if(h===u){r.push(Ne(a,h,f.mode));return}if(s(a,`Auto-merging ${a}`,0),En(c.mode)||En(f.mode)||En(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ne(a,d,c.mode,1)),r.push(Ne(a,h,f.mode,2)),r.push(Ne(a,u,l.mode,3)),i.set(a,{hash:h,mode:f.mode});return}let m=await re(e,d),p=await re(e,h),g=await re(e,u);if(Te(p)||Te(g)||Te(m)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ne(a,d,c.mode,1)),r.push(Ne(a,h,f.mode,2)),r.push(Ne(a,u,l.mode,3)),i.set(a,{hash:h,mode:f.mode});return}let w=At(m),b=At(p),y=At(g),R=gs(b,w,y,{conflictStyle:n?.conflictStyle});if(R.conflict){let x=t.pathnames[1],k=t.pathnames[2],E=x!==a||k!==a,C={path:a,reason:"content"};E&&(x!==a&&(C.oursOrigPath=x),k!==a&&(C.theirsOrigPath=k)),o.push(C),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(Ne(a,d,c.mode,1)),r.push(Ne(a,h,f.mode,2)),r.push(Ne(a,u,l.mode,3));let $=E?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",H=E?`${n?.b??"theirs"}:${k}`:n?.b??"theirs",P=pr(p,m,g,{a:$,b:H,conflictStyle:n?.conflictStyle}),I=await De(e,"blob",Qn.encode(P));i.set(a,{hash:I,mode:f.mode})}else{let x=await ca(e,R.result);r.push(Ne(a,x,f.mode))}return}}var ip=200;async function il(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await j(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await j(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],h=(await j(e,d)).tree,u=null;if(o>=ip)u=f;else{let g=await qt(e,c,d);g.length===0?u=null:g.length===1?u=(await j(e,g[0])).tree:u=await il(e,c,d,g,o+1)}let m=await zt(e,u,f,h);f=await ap(e,m,o);let p=an({type:"commit",tree:f,parents:[c,d],author:Zf,committer:Zf,message:"merged common ancestors"});c=await De(e,"commit",p)}return f}async function ap(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=Dr.decode((await ye(e,u.hash)).content),g=Dr.decode((await ye(e,m.hash)).content),w=h?Dr.decode((await ye(e,h.hash)).content):"",b=8+n*2,y=i.a??"Temporary merge branch 1",R=i.b??"Temporary merge branch 2",x=pr(p,w,g,{a:`${y}:${l}`,o:i.o,b:`${R}:${d}`,markerSize:b}),k=await De(e,"blob",Qn.encode(x));r.push({path:l,mode:u.mode,hash:k,stage:0,stat:Se()}),r.push({path:d,mode:m.mode,hash:k,stage:0,stat:Se()});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=Dr.decode((await ye(e,c.hash)).content),d=Dr.decode((await ye(e,f.hash)).content),h=a.reason==="content"?s(a.path,1):null,u=h?Dr.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=pr(l,u,d,{a:w,o:i.o,b,markerSize:i.markerSize}),R=await De(e,"blob",Qn.encode(y));r.push({path:a.path,mode:c.mode,hash:R,stage:0,stat:Se()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ie(a.path,c.path)),Fe(e,r)}async function ca(e,t){let n=t.map(oa);if(n.length===0)return De(e,"blob",Qn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
250
252
  `):`${n.join(`
251
253
  `)}
252
- `;return He(e,"blob",Jn.encode(s))}function _e(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Se()}}function Zi(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 gs(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 De(e,"blob",Qn.encode(s))}function Ne(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Se()}}function ia(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 ws(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}
253
255
  ${e.join(" ")}
254
256
  Merge with strategy ort failed.
255
257
  `;let c=e.map(l=>` ${l}`).join(`
@@ -264,7 +266,7 @@ ${i}
264
266
  ${a}
265
267
  Aborting
266
268
  fatal: ${n} failed
267
- `}function qf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
269
+ `}function sl(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
268
270
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
269
271
  ${i}
270
272
  Please commit your changes or stash them before you ${n}.
@@ -274,36 +276,36 @@ ${i}
274
276
  Please move or remove them before you ${n}.
275
277
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
276
278
  ${s}
277
- `}async function $n(e,t,n,r){let o=await z(e),s=await le(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Ne(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let R=s.get(g);(!R||R.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await Ji(e,o,s);let w=r.operationName??"merge",R=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:gs(g,w,R,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await or(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Qs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Ji(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),R=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&R.length>0?x=qf(w,R,p,g):R.length>0?x=gs(R,p,g,"untracked","worktree"):x=gs(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await or(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:eo,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Ji(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(y=>y.error==="WOULD_OVERWRITE"||y.error==="NOT_UPTODATE_FILE").map(y=>y.path).sort(),R=h.errors.filter(y=>y.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||y.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(y=>y.path).sort(),x=[];w.length>0&&x.push(gs(w,p,g,"local","worktree")),R.length>0&&x.push(gs(R,p,g,"untracked","worktree"));let b;return x.length>1?b=qf(w,R,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await De(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),l=[...a,...f];l.sort((h,p)=>Ie(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await fe(e,d);let m=l.filter(h=>h.stage===0),u=await Fe(e,m);return{ok:!0,finalIndex:d,mergedTreeHash:u}}async function Ji(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=H(e.workTree,r.path);await e.fs.exists(o)||await dt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ce();ze();we();Ae();Xt();function Vf(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:$().describe("Abort the current cherry-pick operation"),continue:$().describe("Continue the cherry-pick after conflict resolution"),skip:$().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":$().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:V.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:$().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 F=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(de(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Xh(s,r.env);return U.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let F=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(de(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Zh(s,r.env);if(U.exitCode===0){let L=await Y(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:L,hadConflicts:!1})}return U}if(n.skip)return Yh(s,r.env);let i=n.commit;if(!i)return O("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(de(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await je(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let m=await z(s);if(n.noCommit){let F=m.entries.filter(U=>U.stage>0);if(F.length>0){let K=F.slice(0,10).map(J=>`${J.path}: unmerged (${J.hash})`).join(`
278
- `),te=F.length>10?`
279
- ...`:"";return G(`${K}${te}
279
+ `}async function On(e,t,n,r){let o=await K(e),s=await de(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let m=new Map(Le(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 aa(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ws(g,w,b,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let m=await ar(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:so,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!m.success){await aa(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(),y;return w.length>0&&b.length>0?y=sl(w,b,p,g):b.length>0?y=ws(b,p,g,"untracked","worktree"):y=ws(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:y,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let m=await ar(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:oo,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!m.success){await aa(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=[];w.length>0&&y.push(ws(w,p,g,"local","worktree")),b.length>0&&y.push(ws(b,p,g,"untracked","worktree"));let R;return y.length>1?R=sl(w,b,p,g):R=y[0]??"",{ok:!1,stdout:"",stderr:R,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Me(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)=>Ie(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 aa(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();He();Jt();function al(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[z.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:V.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 q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let U=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(fe(U))return{stdout:"",stderr:U.message??"",exitCode:1};let F=await fp(s,r.env);return F.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),F}if(n.continue){let U=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(fe(U))return{stdout:"",stderr:U.message??"",exitCode:1};let F=await lp(s,r.env);if(F.exitCode===0){let L=await Y(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:L,hadConflicts:!1})}return F}if(n.skip)return cp(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 Ge(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 K(s);if(n.noCommit){let U=h.entries.filter(F=>F.stage>0);if(U.length>0){let W=U.slice(0,10).map(J=>`${J.path}: unmerged (${J.hash})`).join(`
280
+ `),ne=U.length>10?`
281
+ ...`:"";return N(`${W}${ne}
280
282
  error: your index file is unmerged.
281
283
  fatal: cherry-pick failed
282
- `,128)}}else{let F=Rn(m,"Cherry-picking",`fatal: cherry-pick failed
283
- `);if(F)return F}let u=await j(s,d),p=!!n["record-origin"]?Jh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let F=await le(s,u.tree);if(Un(m,F))return G(`error: your local changes would be overwritten by cherry-pick.
284
+ `,128)}}else{let U=Cn(h,"Cherry-picking",`fatal: cherry-pick failed
285
+ `);if(U)return U}let u=await j(s,d),p=!!n["record-origin"]?dp(l.message,f):l.message;if(s.workTree&&!n.noCommit){let U=await de(s,u.tree);if(Un(h,U))return N(`error: your local changes would be overwritten by cherry-pick.
284
286
  hint: commit your changes or stash them to proceed.
285
287
  fatal: cherry-pick failed
286
- `,128)}if(l.parents.length>1){if(!n.mainline)return G(`error: commit ${f} is a merge but no -m option was given.
288
+ `,128)}if(l.parents.length>1){if(!n.mainline)return N(`error: commit ${f} is a merge but no -m option was given.
287
289
  fatal: cherry-pick failed
288
- `,128);let F=n.mainline-1;if(F<0||F>=l.parents.length)return G(`error: commit ${f} does not have parent ${n.mainline}
290
+ `,128);let U=n.mainline-1;if(U<0||U>=l.parents.length)return N(`error: commit ${f} does not have parent ${n.mainline}
289
291
  fatal: cherry-pick failed
290
- `,128)}else if(n.mainline)return G(`error: mainline was specified but commit is not a merge.
292
+ `,128)}else if(n.mainline)return N(`error: mainline was specified but commit is not a merge.
291
293
  fatal: cherry-pick failed
292
- `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let F=l.parents.length>1?n.mainline-1:0,U=l.parents[F];if(!U)throw new Error("unreachable: parent must exist");g=(await j(s,U)).tree}let w=X(f),R=ue(l.message),x=await xe(s,"merge.conflictstyle")??"merge",b={a:"HEAD",b:R?`${w} (${R})`:w,conflictStyle:x},y=await Bt(s,g,u.tree,l.tree,b);if(y.conflicts.length===0&&y.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await Z(s,"CHERRY_PICK_HEAD",f),await Z(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p);let F=y.messages.length>0?`${y.messages.join(`
294
+ `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let U=l.parents.length>1?n.mainline-1:0,F=l.parents[U];if(!F)throw new Error("unreachable: parent must exist");g=(await j(s,F)).tree}let w=X(f),b=ue(l.message),y=await xe(s,"merge.conflictstyle")??"merge",R={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:y},x=await zt(s,g,u.tree,l.tree,R);if(x.conflicts.length===0&&x.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await Z(s,"CHERRY_PICK_HEAD",f),await Z(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",p);let U=x.messages.length>0?`${x.messages.join(`
293
295
  `)}
294
- `:"",U=await at(s,{fromCommit:!0});return{stdout:`${F}${U}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
296
+ `:"",F=await it(s,{fromCommit:!0});return{stdout:`${U}${F}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
295
297
  If you wish to commit it anyway, use:
296
298
 
297
299
  git commit --allow-empty
298
300
 
299
301
  Otherwise, please use 'git cherry-pick --skip'
300
- `,exitCode:1}}let E=await $n(s,y,u.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(y.conflicts.length>0){let F=y.messages.join(`
301
- `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:F?`${F}
302
+ `,exitCode:1}}let k=await On(s,x,u.tree,{labels:R,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!k.ok)return k;if(x.conflicts.length>0){let U=x.messages.join(`
303
+ `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:U?`${U}
302
304
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
303
305
  hint: after resolving the conflicts, mark the corrected paths
304
306
  hint: with 'git add <paths>' or 'git rm <paths>'
305
307
  hint: Disable this message with "git config set advice.mergeConflict false"
306
- `,exitCode:1}:(await Z(s,"CHERRY_PICK_HEAD",f),await Z(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p),{stdout:F?`${F}
308
+ `,exitCode:1}:(await Z(s,"CHERRY_PICK_HEAD",f),await Z(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",p),{stdout:U?`${U}
307
309
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
308
310
  hint: After resolving the conflicts, mark them with
309
311
  hint: "git add/rm <pathspec>", then run
@@ -312,153 +314,150 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
312
314
  hint: To abort and get back to the state before "git cherry-pick",
313
315
  hint: run "git cherry-pick --abort".
314
316
  hint: Disable this message with "git config set advice.mergeConflict false"
315
- `,exitCode:1})}let k=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await nt(s,r.env);if(M(C))return C;let P=await bt(s,k,[d],l.author,C,p);await Nt(s),await Ot(s);let I=await Q(s),v=p.split(`
316
- `)[0]??"",T=I?.type==="symbolic"?I.target:"HEAD";await oe(s,r.env,T,d,P,`cherry-pick: ${v}`,I?.type==="symbolic");let N=I?.type==="symbolic"?Pe(I.target):"detached HEAD",S=u.tree,A=await mn(s,S,k,l.author,C,!0),D=jt(N,P,p),_=y.messages.length>0?`${y.messages.join(`
317
+ `,exitCode:1})}let E=k.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await nt(s,r.env);if(M(C))return C;let $=await yt(s,E,[d],l.author,C,p);await Ft(s),await St(s);let H=await Q(s),P=p.split(`
318
+ `)[0]??"",I=H?.type==="symbolic"?H.target:"HEAD";await se(s,r.env,I,d,$,`cherry-pick: ${P}`,H?.type==="symbolic");let D=H?.type==="symbolic"?Pe(H.target):"detached HEAD",G=u.tree,A=await mn(s,G,E,l.author,C,!0),O=Lt(D,$,p),_=x.messages.length>0?`${x.messages.join(`
317
319
  `)}
318
- `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${_}${D}
319
- ${A}`,stderr:"",exitCode:0}}})}async function Yh(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return G(`error: no cherry-pick in progress
320
+ `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:$,hadConflicts:!1}),{stdout:`${_}${O}
321
+ ${A}`,stderr:"",exitCode:0}}})}async function cp(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return N(`error: no cherry-pick in progress
320
322
  fatal: cherry-pick failed
321
- `,128);let r=await Y(e);if(!r)return O("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Or(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 Y(e);if(!r)return T("unable to resolve HEAD");let o=await j(e,r),s=await K(e),i=await Ir(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
322
324
  fatal: cherry-pick failed
323
- `}}return await fe(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await oe(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Nt(e),{stdout:"",stderr:"",exitCode:0}}async function Xh(e,t){return await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
325
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps),await se(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Ft(e),{stdout:"",stderr:"",exitCode:0}}async function fp(e,t){return await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
324
326
  fatal: cherry-pick failed
325
- `,128),operationName:"cherry-pick",clearState:Nt,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
327
+ `,128),operationName:"cherry-pick",clearState:Ft,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
326
328
  fatal: cherry-pick failed
327
- `,128),operationName:"cherry-pick",clearState:Ot,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
329
+ `,128),operationName:"cherry-pick",clearState:St,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
328
330
  fatal: cherry-pick failed
329
- `,128)}async function Zh(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return G(`error: no cherry-pick or revert in progress
331
+ `,128)}async function lp(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return N(`error: no cherry-pick or revert in progress
330
332
  fatal: cherry-pick failed
331
- `,128);let r=await z(e),o=Rn(r,"Committing");if(o)return o;let s=await j(e,n),i=await $e(e,"MERGE_MSG");if(!i)return G(`Aborting commit due to empty commit message.
332
- `,1);let a=await $e(e,"SQUASH_MSG");a&&(i=a+i),i=$t(i);let c=Ne(r),f=await Fe(e,c),l=await Qe(e);if(M(l))return l;let m=(await j(e,l)).tree,u=await nt(e,t);if(M(u))return u;let h=Gt(i),p=await bt(e,f,[l],s.author,u,h);await Nt(e),await Ot(e),await be(e,"SQUASH_MSG");let g=await Q(e),w=ue(h),R=g?.type==="symbolic"?g.target:"HEAD";await oe(e,t,R,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Pe(g.target):"detached HEAD",b=await mn(e,m,f,s.author,u,!0);return{stdout:`${jt(x,p,i)}
333
- ${b}`,stderr:"",exitCode:0}}function Jh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
333
+ `,128);let r=await K(e),o=Cn(r,"Committing");if(o)return o;let s=await j(e,n),i=await $e(e,"MERGE_MSG");if(!i)return N(`Aborting commit due to empty commit message.
334
+ `,1);let a=await $e(e,"SQUASH_MSG");if(a&&(i=a+i),i=It(i),!i)return N(`Aborting commit due to empty commit message.
335
+ `,1);let c=Le(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 y=g?.type==="symbolic"?Pe(g.target):"detached HEAD",R=await mn(e,h,f,s.author,u,!0);return{stdout:`${Lt(y,p,i)}
336
+ ${R}`,stderr:"",exitCode:0}}function dp(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
334
337
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
335
338
  ${n}
336
339
  `:`${r}
337
340
 
338
341
  ${n}
339
- `}ie();Be();Js();Ce();me();function Yf(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:$().alias("f").describe("Required to actually remove files"),"dry-run":$().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:$().alias("d").describe("Also remove untracked directories"),removeIgnored:$().alias("x").describe("Remove ignored files as well"),onlyIgnored:$().alias("X").describe("Remove only ignored files"),exclude:V.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=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,m=n.onlyIgnored;if(!f&&!c&&await xe(s,"clean.requireForce")!=="false")return O("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let u=await z(s),h=new Set(u.entries.map(k=>k.path)),p=ut(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(k=>Ue(k,p)):null,R=n.exclude?[n.exclude]:[],x=await Xf(s,a,"",{trackedPaths:h,removeDirs:l,removeIgnored:d,onlyIgnored:m,extraExcludes:R}),b;w?b=x.filter(k=>Ee(w,k.path)):b=x,b.sort((k,C)=>k.path<C.path?-1:k.path>C.path?1:0);let y=[];if(c)for(let k of b){let C=k.isDir?`Would remove ${k.path}/`:`Would remove ${k.path}`;y.push(C)}else for(let k of b){let C=H(a,k.path);k.isDir?(await r.fs.rm(C,{recursive:!0}),y.push(`Removing ${k.path}/`)):(await r.fs.rm(C),y.push(`Removing ${k.path}`))}return{stdout:y.length>0?`${y.join(`
342
+ `}oe();Be();ro();Ce();pe();function cl(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[z.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:V.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await q(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 K(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 fl(s,a,"",{trackedPaths:m,removeDirs:l,removeIgnored:d,onlyIgnored:h,extraExcludes:b}),R;w?R=y.filter(E=>Ee(w,E.path)):R=y,R.sort((E,C)=>E.path<C.path?-1:E.path>C.path?1:0);let x=[];if(c)for(let E of R){let C=E.isDir?`Would remove ${E.path}/`:`Would remove ${E.path}`;x.push(C)}else for(let E of R){let C=v(a,E.path);E.isDir?(await r.fs.rm(C,{recursive:!0}),x.push(`Removing ${E.path}/`)):(await r.fs.rm(C),x.push(`Removing ${E.path}`))}return{stdout:x.length>0?`${x.join(`
340
343
  `)}
341
- `:"",stderr:"",exitCode:0}}})}async function Xf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await $r(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);i=rr(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
342
- `),l=as(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=H(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let m=i&&fn(i,l,!0)==="ignored",u=Qh(r.trackedPaths,l),h=()=>Xf(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(m&&!u){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await h();!u&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(u){let p=await h();o.push(...p)}else if(!(m&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let m=i&&fn(i,l,!1)==="ignored";r.onlyIgnored?m&&o.push({path:l,isDir:!1}):m&&s||o.push({path:l,isDir:!1})}}return o}function Qh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}ie();Be();Tn();Ce();ce();me();ze();we();Gn();ce();me();var bs=2147483647;async function Hr(e){let t=H(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
343
- `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function ep(e,t){let n=H(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(`
344
+ `:"",stderr:"",exitCode:0}}})}async function fl(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Or(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=or(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
345
+ `),l=cs(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=up(r.trackedPaths,l),m=()=>fl(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 up(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}oe();Be();Tn();Ce();ie();pe();ze();we();Ln();ie();pe();var ys=2147483647;async function Mr(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
+ `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function hp(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(`
344
347
  `)+`
345
- `)}async function Oo(e){return(await Hr(e)).size>0}async function Dr(e,t,n){let r=n??await Hr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await ep(e,r)}async function Zf(e,t,n,r){if(n>=bs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Yt(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 m of d.parents)!o.has(m)&&await Yt(e,m)&&(o.set(m,l+1),s.push({hash:m,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();Gn();ht();ce();var So=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]),tp=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]),Io=64,np=4,ea=4096,Jf=65536,rp=127;function sp(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=ip(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let m=n*16-16;m>=0;m-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|e[m+h])^So[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=m+16;else{a=u;let h=u&o;i.push({ptr:m+16,val:u}),s[h]++}}let c=new Map;for(let m of i){let u=m.val&o,h=c.get(u);h||(h=[],c.set(u,h)),h.push(m)}for(let[m,u]of c){if(u.length<=Io)continue;let h=[],p=u.length/Io;for(let g=0;g<Io;g++)h.push(u[Math.floor(g*p)]);c.set(m,h),s[m]=Io}let f=new Uint32Array(r+1),l=[],d=0;for(let m=0;m<r;m++){f[m]=d;let u=c.get(m);if(u){for(let h of u)l.push(h);d+=u.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function op(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=el(i,a,r),a=el(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])^So[f>>>23],l++;f=f>>>0;let m=d,u=0,h=0;for(;m<o;){if(h<ea){f^=tp[t[m-16]],f=((f<<8|t[m])^So[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let R=g;R<w;R++){let x=e.entries[R];if(x.val!==f)continue;let b=x.ptr,y=s.byteLength-b,E=o-m;if(y>E&&(y=E),y<=h)break;let k=0;for(;k<y&&s[b+k]===t[m+k];)k++;if(k>h&&(h=k,u=b,h>=ea))break}}if(h<np)c(2),l===0&&a++,i[a++]=t[m++],l++,l===rp&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&s[u-1]===t[m-1];)if(h++,u--,m--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Jf?h-Jf:0;h-=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),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,m+=h,u+=h,h=p,u>4294967295&&(h=0),h<ea){f=0;for(let R=-16;R<0;R++)f=(f<<8|t[m+R])^So[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 Qf={blob:0,tree:1,commit:2,tag:3};function To(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Qf[f.type]??99,m=Qf[l.type]??99;return d!==m?d-m: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},m=null,u=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=m?m.byteLength:l.content.byteLength/2|0;if(b<16)continue;let y=op(x,l.content,b);y&&(!m||y.byteLength<m.byteLength)&&(m=y,u=g.hash)}if(m&&u){d.delta=m,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(sp(l.content)),c.push(l.hash)}return i}function ip(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 el(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}xr();we();ce();wn();Pr();Ys();async function ap(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await ys(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let m of d.parents)i.has(m)||a.push(m)}catch{}let c=[],f=new Set;for(let l of a)await Es(e,l,i,f,c,r);return{count:c.length,objects:cp(c)}}async function Mr(e,t,n,r,o){let{count:s,objects:i}=await ap(e,t,n,r,o);return{count:s,objects:fp(e,i)}}async function*cp(e){for(let t of e)yield t}async function*fp(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 jr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function ys(e,t,n,r){if(n.has(t)||(n.add(t),!await Yt(e,t)))return;let o=await ye(e,t);switch(o.type){case"commit":{let s=sn(o.content);if(await ys(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await ys(e,i,n,r);break}case"tree":{let s=_n(o.content);for(let i of s.entries)await ys(e,i.hash,n,r);break}case"tag":{let s=Vt(o.content);await ys(e,s.object,n,r);break}case"blob":break}}async function Es(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=sn(i.content);if(await Es(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Es(e,c,n,r,o,s);break}case"tree":{let a=_n(i.content);for(let c of a.entries)await Es(e,c.hash,n,r,o,s);break}case"tag":{let a=Vt(i.content);await Es(e,a.object,n,r,o,s);break}case"blob":break}}var lp=new TextEncoder,vo=new TextDecoder,tl=65520,dp=new Uint8Array([48,48,48,48]),IR=new Uint8Array([48,48,48,49]),SR=new Uint8Array([48,48,48,50]);function On(e){let t=typeof e=="string"?lp.encode(e):e,n=4+t.byteLength;if(n>tl)throw new Error(`pkt-line too long: ${n} bytes (max ${tl})`);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 ta(){return dp.slice()}function Ao(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function Gr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=vo.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 Ho(e){if(e.type!=="data")return"";let t=vo.decode(e.data);return t.endsWith(`
346
- `)?t.slice(0,-1):t}var up=1,mp=2,hp=3;function na(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 up:t.push(f),o+=f.byteLength;break;case mp:n.push(vo.decode(f));break;case hp:r.push(vo.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}}ht();function ra(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function sa(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ra(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=Gr(c);return pp(f,t)}function pp(e,t){let n=0,r=e[n];r?.type==="data"&&Ho(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 m=l.slice(0,d),u=l.slice(d+1);if(!(m===ee&&u==="capabilities^{}")){if(u.endsWith("^{}")){let h=u.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=m);continue}o.push({name:u,hash:m})}}return{refs:o,capabilities:s,symrefs:i}}var gp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function nl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=sl(r,gp),c=[];c.push(On(`want ${t[0]} ${a.join(" ")}
347
- `));for(let u=1;u<t.length;u++)c.push(On(`want ${t[u]}
348
- `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(On(`shallow ${u}
349
- `));i?.depth!==void 0&&c.push(On(`deepen ${i.depth}
350
- `)),c.push(ta());for(let u of n)c.push(On(`have ${u}
351
- `));c.push(On(`done
352
- `));let f=Ao(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ra(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let m=new Uint8Array(await d.arrayBuffer());return wp(m,a.includes("side-band-64k"))}function wp(e,t){let n=Gr(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let m=n[d];if(!m||m.type==="flush"){i=d+1;continue}if(m.type!=="data")continue;let u=Ho(m);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:m,errors:u}=na(a);if(u.length>0)throw new Error(`Remote error: ${u.join("")}`);return{packData:d,acks:r,progress:m,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 bp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function rl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=sl(r,bp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(On(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
353
- `));for(let h of f)a.push(On(`${h.oldHash} ${h.newHash} ${h.refName}
354
- `));a.push(ta());let l;if(n&&n.byteLength>0){let h=Ao(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=Ao(...a);let d=e.replace(/\/+$/,""),m=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ra(o),"User-Agent":"just-git/1.0"},body:l});if(!m.ok)throw new Error(`HTTP ${m.status} pushing to ${d}`);let u=new Uint8Array(await m.arrayBuffer());return i.includes("report-status")?yp(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function yp(e,t){let n,r=[];if(t){let a=Gr(e),{packData:c,progress:f,errors:l}=na(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Gr(c)}else n=Gr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=Ho(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 sl(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 ks=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 Zf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await oa(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await qs(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ee&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await oa(this.local,n,r);s&&await qs(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ee,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await Pn(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}}},Rs=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 sa(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 sa(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 nl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await qs(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==ee&&l.newHash!==ee&&!l.ok&&!await Pn(this.local,l.oldHash,l.newHash))return{updates:t.map(m=>m===l?{...m,ok:!1,error:"non-fast-forward"}:{...m,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(l=>({oldHash:l.oldHash??ee,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==ee&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==ee&&s.push(l.oldHash);let a=null;i&&(a=await oa(this.local,o,s)??null);let c=await rl(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(l=>{let d=c.refResults.find(h=>h.name===l.name),m=d?.ok??c.unpackOk,u=d?.error??(!m&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...l,ok:m,error:u}})}}};async function oa(e,t,n,r,o){let s=await Mr(e,t,n,r,o);if(s.count===0)return;let i=await jr(s),c=To(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Bs(c);return f}function Ep(e){if(!Do(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 pr(e,t){let n=Ep(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function kp(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 Do(e){return e.startsWith("http://")||e.startsWith("https://")}function ol(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function il(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(Do(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 Rp(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 al(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=Rp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function cl(e,t,n,r){let o=pr(t,e.credentialCache).url;if(Do(o)){let s=il(o,e.networkPolicy);if(s)throw new Error(s);let i=await al(e,o,n);return new Rs(e,o,i,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw ol(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 ks(e,r)}async function Lr(e,t,n){let r=await kp(e,t);if(!r)return null;let o=pr(r.url,e.credentialCache).url;if(Do(o)){let i=il(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await al(e,o,n):void 0;return{transport:new Rs(e,o,a,e.fetchFn),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await tr(e.fs,o);if(!s){if(ol(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new ks(e,s),config:{...r,url:o}}}Ae();tt();function fl(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:$().describe("Create a bare clone"),branch:V.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:V.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return O("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=pr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Ht(r.cwd,o),a=await tr(r.fs,c)),!a)return O(`repository '${o}' does not exist`);let f=n.directory;if(!f){let T;s||o.includes("://")?T=c.split("/").pop()??c:T=Br(c),T.endsWith(".git")&&(T=T.slice(0,-4)),f=T}let l=Ht(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(de(d))return G(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return O(`destination path '${f}' already exists and is not an empty directory.`)}catch{return O(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:m}=await zs(r.fs,l,{bare:n.bare}),u=t?{...m,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote,credentialCache:t.credentialCache}:m,h=await pe(u);h['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Je(u,h);let p;try{p=await cl(u,c,r.env,a??void 0)}catch(T){let N=T instanceof Error?T.message:"";return N.startsWith("network")?O(N):O(`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 Ao(e){return(await Mr(e)).size>0}async function jr(e,t,n){let r=n??await Mr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await hp(e,r)}async function ll(e,t,n,r){if(n>=ys)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();Ln();pt();ie();var Mo=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]),mp=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]),Do=64,pp=4,fa=4096,dl=65536,gp=127;function wp(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=yp(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])^Mo[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<=Do)continue;let m=[],p=u.length/Do;for(let g=0;g<Do;g++)m.push(u[Math.floor(g*p)]);c.set(h,m),s[h]=Do}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 bp(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=hl(i,a,r),a=hl(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])^Mo[f>>>23],l++;f=f>>>0;let h=d,u=0,m=0;for(;h<o;){if(m<fa){f^=mp[t[h-16]],f=((f<<8|t[h])^Mo[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 R=y.ptr,x=s.byteLength-R,k=o-h;if(x>k&&(x=k),x<=m)break;let E=0;for(;E<x&&s[R+E]===t[h+E];)E++;if(E>m&&(m=E,u=R,m>=fa))break}}if(m<pp)c(2),l===0&&a++,i[a++]=t[h++],l++,l===gp&&(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>dl?m-dl: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<fa){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[h+b])^Mo[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 ul={blob:0,tree:1,commit:2,tag:3};function jo(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=ul[f.type]??99,h=ul[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 R=h?h.byteLength:l.content.byteLength/2|0;if(R<16)continue;let x=bp(y,l.content,R);x&&(!h||x.byteLength<h.byteLength)&&(h=x,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(wp(l.content)),c.push(l.hash)}return i}function yp(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 hl(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}Cr();we();ie();wn();$r();Qs();async function Ep(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await Es(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 ks(e,l,i,f,c,r);return{count:c.length,objects:kp(c)}}async function Gr(e,t,n,r,o){let{count:s,objects:i}=await Ep(e,t,n,r,o);return{count:s,objects:Rp(e,i)}}async function*kp(e){for(let t of e)yield t}async function*Rp(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 Lr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Es(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 Es(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await Es(e,i,n,r);break}case"tree":{let s=kn(o.content);for(let i of s.entries)await Es(e,i.hash,n,r);break}case"tag":{let s=Zt(o.content);await Es(e,s.object,n,r);break}case"blob":break}}async function ks(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 ks(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await ks(e,c,n,r,o,s);break}case"tree":{let a=kn(i.content);for(let c of a.entries)await ks(e,c.hash,n,r,o,s);break}case"tag":{let a=Zt(i.content);await ks(e,a.object,n,r,o,s);break}case"blob":break}}var xp=new TextEncoder,Go=new TextDecoder,ml=65520,Cp=new Uint8Array([48,48,48,48]),BR=new Uint8Array([48,48,48,49]),WR=new Uint8Array([48,48,48,50]);function In(e){let t=typeof e=="string"?xp.encode(e):e,n=4+t.byteLength;if(n>ml)throw new Error(`pkt-line too long: ${n} bytes (max ${ml})`);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 la(){return Cp.slice()}function Lo(...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 Nr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=Go.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 No(e){if(e.type!=="data")return"";let t=Go.decode(e.data);return t.endsWith(`
349
+ `)?t.slice(0,-1):t}var Pp=1,$p=2,Op=3;function da(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 Pp:t.push(f),o+=f.byteLength;break;case $p:n.push(Go.decode(f));break;case Op:r.push(Go.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 ua(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ha(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ua(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=Nr(c);return Ip(f,t)}function Ip(e,t){let n=0,r=e[n];r?.type==="data"&&No(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===ee&&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 Sp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function pl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=wl(r,Sp),c=[];c.push(In(`want ${t[0]} ${a.join(" ")}
350
+ `));for(let u=1;u<t.length;u++)c.push(In(`want ${t[u]}
351
+ `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(In(`shallow ${u}
352
+ `));i?.depth!==void 0&&c.push(In(`deepen ${i.depth}
353
+ `)),c.push(la());for(let u of n)c.push(In(`have ${u}
354
+ `));c.push(In(`done
355
+ `));let f=Lo(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ua(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 Tp(h,a.includes("side-band-64k"))}function Tp(e,t){let n=Nr(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=No(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}=da(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 vp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function gl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=wl(r,vp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(In(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
356
+ `));for(let m of f)a.push(In(`${m.oldHash} ${m.newHash} ${m.refName}
357
+ `));a.push(la());let l;if(n&&n.byteLength>0){let m=Lo(...a);l=new Uint8Array(m.byteLength+n.byteLength),l.set(m,0),l.set(n,m.byteLength)}else l=Lo(...a);let d=e.replace(/\/+$/,""),h=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ua(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")?Hp(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Hp(e,t){let n,r=[];if(t){let a=Nr(e),{packData:c,progress:f,errors:l}=da(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Nr(c)}else n=Nr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=No(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 wl(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 Rs=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 ll(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await ma(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Vs(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ee&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await ma(this.local,n,r);s&&await Vs(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ee,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}}},xs=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 ha(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 ha(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 pl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Vs(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!==ee&&u.newHash!==ee&&!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??ee,newHash:u.newHash,refName:u.name})),a=[],c=[],f=!1;for(let u of o)u.newHash!==ee&&(a.push(u.newHash),f=!0),u.oldHash&&u.oldHash!==ee&&c.push(u.oldHash);let l=null;f&&(l=await ma(this.local,a,c)??null);let d=await gl(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 ma(e,t,n,r,o){let s=await Gr(e,t,n,r,o);if(s.count===0)return;let i=await Lr(s),c=jo(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await zs(c);return f}function Ap(e){if(!_o(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 gr(e,t){let n=Ap(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function Dp(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 _o(e){return e.startsWith("http://")||e.startsWith("https://")}function bl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function yl(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(_o(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 Mp(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 El(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=Mp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function kl(e,t,n,r){let o=gr(t,e.credentialCache).url;if(_o(o)){let s=yl(o,e.networkPolicy);if(s)throw new Error(s);let i=await El(e,o,n);return new xs(e,o,i,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw bl(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 Rs(e,r)}async function _r(e,t,n){let r=await Dp(e,t);if(!r)return null;let o=gr(r.url,e.credentialCache).url;if(_o(o)){let i=yl(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await El(e,o,n):void 0;return{transport:new xs(e,o,a,e.fetchFn),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await rr(e.fs,o);if(!s){if(bl(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new Rs(e,s),config:{...r,url:o}}}He();tt();function Rl(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[z.string().name("repository").describe("Repository to clone"),z.string().name("directory").describe("Target directory").optional()],options:{bare:S().describe("Create a bare clone"),branch:V.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:V.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=gr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Mt(r.cwd,o),a=await rr(r.fs,c)),!a)return T(`repository '${o}' does not exist`);let f=n.directory;if(!f){let I;s||o.includes("://")?I=c.split("/").pop()??c:I=qr(c),I.endsWith(".git")&&(I=I.slice(0,-4)),f=I}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 N(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 Xs(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 kl(u,c,r.env,a??void 0)}catch(I){let D=I instanceof Error?I.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}'...
355
358
  warning: You appear to have cloned an empty repository.
356
- `,exitCode:0};let w=[],R=new Set;for(let T of g)T.name!=="HEAD"&&(R.has(T.hash)||(R.add(T.hash),w.push(T.hash)));let x=n.depth,b=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let T=await p.fetch(w,[],b);T.shallowUpdates&&await Dr(u,T.shallowUpdates)}let y=g.find(T=>T.name==="HEAD"),E=null,k=null,C=await nn(u,r.env),P=`clone: from ${c}`,I=p.headTarget;I?.startsWith("refs/heads/")&&g.some(T=>T.name===I)&&(E=I.slice(11),k=g.find(T=>T.name===I)?.hash??null);for(let T of g)if(T.name!=="HEAD"){if(T.name.startsWith("refs/heads/")){let N=T.name.slice(11),S=`refs/remotes/origin/${N}`;await Z(u,S,T.hash),await Ze(u,S,{oldHash:ee,newHash:T.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P}),!E&&y&&T.hash===y.hash&&(E=N,k=T.hash)}T.name.startsWith("refs/tags/")&&await Z(u,T.name,T.hash)}if(i){let T=g.find(N=>N.name===`refs/heads/${i}`);if(!T)return O(`Remote branch '${i}' not found in upstream origin`);E=i,k=T.hash}if(!E){let T=g.find(N=>N.name.startsWith("refs/heads/"));T&&(E=T.name.slice(11),k=T.hash)}if(n.bare)return E&&await Xe(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}'...
357
- `,exitCode:0};if(E&&await Xe(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${E}`),E&&k){await Z(u,`refs/heads/${E}`,k),await Xe(u,"HEAD",`refs/heads/${E}`);let T={oldHash:ee,newHash:k,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P};await Ze(u,`refs/heads/${E}`,T),await Ze(u,"HEAD",T);let N=await pe(u);N[`branch "${E}"`]={remote:"origin",merge:`refs/heads/${E}`},await Je(u,N);let S=await j(u,k);await zc(u,S.tree);let A=await Ke(u,S.tree),D=Ns(A.map(_=>({path:_.path,mode:parseInt(_.mode,8),hash:_.hash,stage:0,stat:Se()})));await fe(u,D)}let v={stdout:"",stderr:`Cloning into '${f}'...
358
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:u,repository:c,targetPath:l,bare:n.bare,branch:E}),v}})}ie();ce();Ce();we();an();Ae();tt();is();Pr();function dl(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:$().describe("Use any tag, not just annotated"),always:$().describe("Show abbreviated hash as fallback"),long:$().describe("Always output long format"),abbrev:V.number().describe("Abbreviation length"),dirty:V.string().describe("Append dirty marker if worktree has changes"),match:V.string().describe("Only consider tags matching glob"),exclude:V.string().describe("Exclude tags matching glob"),exactMatch:$().alias("exact-match").describe("Only output exact matches"),firstParent:$().alias("first-parent").describe("Only follow first parent"),candidates:V.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,m=n.match,u=n.exclude,h=n.exactMatch,p=n.firstParent,g;if(i){let C=await We(s,i);if(!C)return O(`Not a valid object name ${i}`);try{g=await ve(s,C)}catch{return O(`Not a valid object name ${i}`)}}else g=await Y(s);if(!g)return O("your current branch does not have any commits yet");let w=await xp(s,a,m,u),R=new Map,x=!1;for(let C of w){C.timestamp===0&&(x=!0);let P=R.get(C.commitHash);P||(P=[],R.set(C.commitHash,P)),P.push(C)}let b=await Cp(s,g,R,p,h?0:void 0);if(!b){if(h)return O(`no tag exactly matches '${g}'`);if(c){let P=g.slice(0,Math.max(l,1));return d&&await ll(s)&&(P+=d),{stdout:P+`
359
- `,stderr:"",exitCode:0}}let C;return!a&&x?C=`fatal: No annotated tags can describe '${g}'.
359
+ `,exitCode:0};let w=[],b=new Set;for(let I of g)I.name!=="HEAD"&&(b.has(I.hash)||(b.add(I.hash),w.push(I.hash)));let y=n.depth,R=y!==void 0&&y>0?{depth:y}:void 0;if(w.length>0){let I=await p.fetch(w,[],R);I.shallowUpdates&&await jr(u,I.shallowUpdates)}let x=g.find(I=>I.name==="HEAD"),k=null,E=null,C=await rn(u,r.env),$=`clone: from ${c}`,H=p.headTarget;H?.startsWith("refs/heads/")&&g.some(I=>I.name===H)&&(k=H.slice(11),E=g.find(I=>I.name===H)?.hash??null);for(let I of g)if(I.name!=="HEAD"){if(I.name.startsWith("refs/heads/")){let D=I.name.slice(11),G=`refs/remotes/origin/${D}`;await Z(u,G,I.hash),await Je(u,G,{oldHash:ee,newHash:I.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:$}),!k&&x&&I.hash===x.hash&&(k=D,E=I.hash)}I.name.startsWith("refs/tags/")&&await Z(u,I.name,I.hash)}if(i){let I=g.find(D=>D.name===`refs/heads/${i}`);if(!I)return T(`Remote branch '${i}' not found in upstream origin`);k=i,E=I.hash}if(!k){let I=g.find(D=>D.name.startsWith("refs/heads/"));I&&(k=I.name.slice(11),E=I.hash)}if(n.bare)return 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(k&&await Ze(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${k}`),k&&E){await Z(u,`refs/heads/${k}`,E),await Ze(u,"HEAD",`refs/heads/${k}`);let I={oldHash:ee,newHash:E,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:$};await Je(u,`refs/heads/${k}`,I),await Je(u,"HEAD",I);let D=await he(u);D[`branch "${k}"`]={remote:"origin",merge:`refs/heads/${k}`},await Xe(u,D);let G=await j(u,E);await of(u,G.tree);let A=await qe(u,G.tree),O=Us(A.map(_=>({path:_.path,mode:parseInt(_.mode,8),hash:_.hash,stage:0,stat:Se()})));await ae(u,O)}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:k}),P}})}oe();ie();Ce();we();cn();He();tt();as();$r();function Cl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[z.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:V.number().describe("Abbreviation length"),dirty:V.string().describe("Append dirty marker if worktree has changes"),match:V.string().describe("Only consider tags matching glob"),exclude:V.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:V.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(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 C=await We(s,i);if(!C)return T(`Not a valid object name ${i}`);try{g=await ve(s,C)}catch{return T(`Not a valid object name ${i}`)}}else g=await Y(s);if(!g)return T("your current branch does not have any commits yet");let w=await jp(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 R=await Gp(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 xl(s)&&($+=d),{stdout:$+`
362
+ `,stderr:"",exitCode:0}}let C;return!a&&y?C=`fatal: No annotated tags can describe '${g}'.
360
363
  However, there were unannotated tags: try --tags.
361
364
  `:w.length===0&&!a&&(await ge(s,"refs/tags")).length>0?C=`fatal: No annotated tags can describe '${g}'.
362
365
  However, there were unannotated tags: try --tags.
363
366
  `:C=`fatal: No names found, cannot describe anything.
364
- `,{stdout:"",stderr:C,exitCode:128}}let{tag:y,depth:E}=b,k;if(E===0&&!f)k=y.name;else if(l===0)k=y.name;else{let C=g.slice(0,Math.max(l,1));k=`${y.name}-${E}-g${C}`}return d&&await ll(s)&&(k+=d),{stdout:k+`
365
- `,stderr:"",exitCode:0}}})}async function xp(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&&cn(n,a,0)!==0||r&&cn(r,a,0)===0)continue;let c=await ye(e,i.hash);if(c.type==="tag"){let f=Vt(c.content),l;try{l=await ve(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 Cp(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:Pp(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 Pp(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function ll(e){if(Ye(e))return!1;let n=await Y(e);if(!n)return!1;let r=await j(e,n),o=await le(e,r.tree),s=await z(e);return Un(s,o)?!0:(await gt(e,s)).length>0}ie();Ce();ce();wn();me();ze();we();Ae();tt();function ul(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:V.string().alias("m").repeatable().describe("Commit message"),file:V.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:$().describe("Allow creating an empty commit"),amend:$().describe("Amend the previous commit"),noEdit:$().describe("Use the previous commit message without editing"),all:$().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 O("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 ae=Ye(i);if(ae)return ae;let Oe=await gt(i,a);for(let qe of Oe)qe.status==="modified"?a=(await ln(i,a,qe.path)).index:qe.status==="deleted"&&(a=lt(a,qe.path));let rt=new Set(Ne(a).map(qe=>qe.path)),Sn=new Set(a.entries.filter(qe=>qe.stage>0&&!rt.has(qe.path)).map(qe=>qe.path));for(let qe of Sn){let br=H(i.workTree,qe);await r.fs.exists(br)?a=(await ln(i,a,qe)).index:a=lt(a,qe)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),m=await _t(i)?await B(i,"REBASE_HEAD"):null,u=n.amend,h=await Y(i);if(u){if(!h)return O("You have nothing yet to amend.");if(c)return O("You are in the middle of a merge -- cannot amend.");if(f)return O("You are in the middle of a cherry-pick -- cannot amend.")}if(Mt(a)){let ae=new Set,Oe=[];for(let rt of a.entries)rt.stage>0&&!ae.has(rt.path)&&(ae.add(rt.path),Oe.push(`U ${rt.path}`));return Oe.sort(),{stdout:Oe.length>0?`${Oe.join(`
367
+ `,{stdout:"",stderr:C,exitCode:128}}let{tag:x,depth:k}=R,E;if(k===0&&!f)E=x.name;else if(l===0)E=x.name;else{let C=g.slice(0,Math.max(l,1));E=`${x.name}-${k}-g${C}`}return d&&await xl(s)&&(E+=d),{stdout:E+`
368
+ `,stderr:"",exitCode:0}}})}async function jp(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 ve(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 Gp(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:Lp(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 Lp(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function xl(e){if(Ve(e))return!1;let n=await Y(e);if(!n)return!1;let r=await j(e,n),o=await de(e,r.tree),s=await K(e);return Un(s,o)?!0:(await wt(e,s)).length>0}oe();Ce();ie();wn();pe();ze();we();He();tt();function Pl(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:V.string().alias("m").repeatable().describe("Commit message"),file:V.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 q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await K(i);if(n.all){let ce=Ve(i);if(ce)return ce;let Oe=await wt(i,a);for(let Ye of Oe)Ye.status==="modified"?a=(await dn(i,a,Ye.path)).index:Ye.status==="deleted"&&(a=ft(a,Ye.path));let ut=new Set(Le(a).map(Ye=>Ye.path)),yr=new Set(a.entries.filter(Ye=>Ye.stage>0&&!ut.has(Ye.path)).map(Ye=>Ye.path));for(let Ye of yr){let Ur=v(i.workTree,Ye);await r.fs.exists(Ur)?a=(await dn(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 Y(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,Oe=[];for(let ut of a.entries)ut.stage>0&&!ce.has(ut.path)&&(ce.add(ut.path),Oe.push(`U ${ut.path}`));return Oe.sort(),{stdout:Oe.length>0?`${Oe.join(`
366
369
  `)}
367
370
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
368
371
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
369
372
  hint: as appropriate to mark resolution and make a commit.
370
373
  fatal: Exiting because of an unresolved conflict.
371
- `,exitCode:128}}let p=u&&h?await j(i,h):null,g=o.length>0?o.join(`
374
+ `,exitCode:128}}let p=u&&m?await j(i,m):null,g=o.length>0?o.join(`
372
375
 
373
- `):void 0;if(g!==void 0&&(g=$t(g),!g))return{stdout:`Aborting commit due to empty commit message.
374
- `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ae=n.file.startsWith("/")?n.file:H(r.cwd,n.file);if(!await r.fs.exists(ae))return O(`could not read log file '${n.file}': No such file or directory`);let Oe=await r.fs.readFile(ae);g=typeof Oe=="string"?Oe:new TextDecoder().decode(Oe)}if(g=$t(g),!g)return{stdout:`Aborting commit due to empty commit message.
375
- `,stderr:"",exitCode:1}}if(!g&&u&&p&&(g=p.message),!g&&(c||f||l||m)){let ae=await $e(i,"SQUASH_MSG");if(ae)g=$t(ae);else{let Oe=await $e(i,"MERGE_MSG");Oe!==null&&(g=$t(Oe))}}if(!g)return G("error: must provide a commit message with -m or -F");let w=Ne(a),R=await Fe(i,w),x=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:R});if(de(x))return G(x.message??"");let b=n.allowEmpty,y=null;if(u&&p){let ae=p.parents[0];ae?y=(await j(i,ae)).tree:y=await pt("tree",new Uint8Array(0))}else h&&(y=(await j(i,h)).tree);let E=u&&p&&p.parents.length>1;if(!b&&!c&&!E){if(!h&&!u&&w.length===0)return{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(y!==null&&y===R){if(u){let ae=p?.parents[0]??null;return{stdout:`${await at(i,{fromCommit:!0,compareHash:ae,noWarn:!0,index:a})}No changes
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 Oe=await r.fs.readFile(ce);g=typeof Oe=="string"?Oe:new TextDecoder().decode(Oe)}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 Oe=await $e(i,"MERGE_MSG");Oe!==null&&(g=It(Oe))}}if(!g)return N("error: must provide a commit message with -m or -F");let w=Le(a),b=await Fe(i,w),y=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(fe(y))return N(y.message??"");let R=n.allowEmpty,x=null;if(u&&p){let ce=p.parents[0];ce?x=(await j(i,ce)).tree:x=await gt("tree",new Uint8Array(0))}else m&&(x=(await j(i,m)).tree);let k=u&&p&&p.parents.length>1;if(!R&&!c&&!k){if(!m&&!u&&w.length===0)return{stdout:await it(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(x!==null&&x===b){if(u){let ce=p?.parents[0]??null;return{stdout:`${await it(i,{fromCommit:!0,compareHash:ce,noWarn:!0,index:a})}No changes
376
379
  `,stderr:`You asked to amend the most recent commit, but doing so would make
377
380
  it empty. You can repeat your command with --allow-empty, or you can
378
381
  remove the commit entirely with "git reset HEAD^".
379
- `,exitCode:1}}return f?{stdout:await at(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 it(i,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
380
383
  If you wish to commit it anyway, use:
381
384
 
382
385
  git commit --allow-empty
383
386
 
384
387
  Otherwise, please use 'git cherry-pick --skip'
385
- `,exitCode:1}:{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let k=await dn(i,r.env);if(M(k))return k;let C=await nt(i,r.env);if(M(C))return C;u&&p&&(k.name=p.author.name,k.email=p.author.email,k.timestamp=p.author.timestamp,k.timezone=p.author.timezone),f&&(k=(await j(i,f)).author);let P=Gt(g),I={repo:i,message:P},v=await t?.hooks?.commitMsg?.(I);if(de(v))return G(v.message??"");P=I.message;let T;u&&p?T=[...p.parents]:(T=h?[h]:[],c&&T.push(c));let N=on({type:"commit",tree:R,parents:T,author:k,committer:C,message:P}),S=await He(i,"commit",N);await fe(i,a);let A=await Q(i);A&&A.type==="symbolic"?await Z(i,A.target,S):await Z(i,"HEAD",S);let D=ue(P),_;u?_="commit (amend)":c?_="commit (merge)":f?_="commit (cherry-pick)":h?_="commit":_="commit (initial)";let F=`${_}: ${D}`,U=A?.type==="symbolic"?A.target:"HEAD";await oe(i,r.env,U,h,S,F,A?.type==="symbolic"),c&&await fs(i),f&&await Nt(i),l&&await Ot(i),m&&await be(i,"MERGE_MSG"),await be(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:S,message:P,branch:A?.type==="symbolic"?Pe(A.target):null,parents:T,author:k});let L=A?.type==="symbolic"?A.target:null,K=L?Pe(L):"detached HEAD",te;if(u&&p){let ae=p.parents[0];te=ae?(await j(i,ae)).tree:null}else te=h?(await j(i,h)).tree:null;let J=k.timestamp!==C.timestamp||k.timezone!==C.timezone,ne=T.length>1,ke=await mn(i,te,R,k,C,J,ne);return{stdout:`${jt(K,S,g,T.length===0&&!u)}
386
- ${ke}`,stderr:"",exitCode:0}}})}ie();Be();me();function In(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 gl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:$().alias("l").describe("List all config entries"),get:$().describe("Get the value for a given key"),unset:$().describe("Remove a config key"),"get-all":$().describe("Get all values for a multi-valued key"),add:$().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 pl(s);if(n.get){let f=a;return f?In(f)?ia(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n["get-all"]){let f=a;return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await _a(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?In(f)?hl(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="list")return pl(s);if(a==="get"){let f=i[1];return f?In(f)?ia(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await ri(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?In(f)?hl(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(!a)return G("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!In(a))return G(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ri(s,a,c),{stdout:"",stderr:"",exitCode:0}):ia(s,a)}})}async function ia(e,t){let n=await xe(e,t);return n===void 0?G(""):{stdout:`${n}
387
- `,stderr:"",exitCode:0}}async function ml(e,t){let n=await Na(e,t);return n.length===0?G(""):{stdout:`${n.join(`
388
+ `,exitCode:1}:{stdout:await it(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let E=await un(i,r.env);if(M(E))return E;let C=await nt(i,r.env);if(M(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 j(i,f)).author);let $=Nt(g),H={repo:i,message:$},P=await t?.hooks?.commitMsg?.(H);if(fe(P))return N(P.message??"");$=H.message;let I;u&&p?I=[...p.parents]:(I=m?[m]:[],c&&I.push(c));let D=an({type:"commit",tree:b,parents:I,author:E,committer:C,message:$}),G=await De(i,"commit",D);await ae(i,a);let A=await Q(i);A&&A.type==="symbolic"?await Z(i,A.target,G):await Z(i,"HEAD",G);let O=ue($),_;u?_="commit (amend)":c?_="commit (merge)":f?_="commit (cherry-pick)":m?_="commit":_="commit (initial)";let U=`${_}: ${O}`,F=A?.type==="symbolic"?A.target:"HEAD";await se(i,r.env,F,m,G,U,A?.type==="symbolic"),c&&await ls(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:G,message:$,branch:A?.type==="symbolic"?Pe(A.target):null,parents:I,author:E});let L=A?.type==="symbolic"?A.target:null,W=L?Pe(L):"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 J=E.timestamp!==C.timestamp||E.timezone!==C.timezone,te=I.length>1,ke=await mn(i,ne,b,E,C,J,te);return{stdout:`${Lt(W,G,g,I.length===0&&!u)}
389
+ ${ke}`,stderr:"",exitCode:0}}})}oe();Be();pe();function Sn(e){let t=e.split(".");return t.length===2||t.length===3}function Np(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 Sl(e,t){e.command("config",{description:"Get and set repository options",args:[z.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 q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Il(s);if(n.get){let f=a;return f?Sn(f)?pa(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(n["get-all"]){let f=a;return f?Sn(f)?$l(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?N("error: missing key and/or value",2):Sn(f)?(await Za(s,f,l),{stdout:"",stderr:"",exitCode:0}):N(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Sn(f)?Ol(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="list")return Il(s);if(a==="get"){let f=i[1];return f?Sn(f)?pa(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Sn(f)?$l(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?N("error: missing key and/or value",2):Sn(f)?(await ui(s,f,l),{stdout:"",stderr:"",exitCode:0}):N(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Sn(f)?Ol(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(!a)return N("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Sn(a))return N(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ui(s,a,c),{stdout:"",stderr:"",exitCode:0}):pa(s,a)}})}async function pa(e,t){let n=await xe(e,t);return n===void 0?N(""):{stdout:`${n}
390
+ `,stderr:"",exitCode:0}}async function $l(e,t){let n=await Xa(e,t);return n.length===0?N(""):{stdout:`${n.join(`
388
391
  `)}
389
- `,stderr:"",exitCode:0}}async function hl(e,t){return await Fa(e,t)?{stdout:"",stderr:"",exitCode:0}:G("",5)}async function pl(e){let t=H(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Qo(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(`
392
+ `,stderr:"",exitCode:0}}async function Ol(e,t){return await Ja(e,t)?{stdout:"",stderr:"",exitCode:0}:N("",5)}async function Il(e){let t=v(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=ci(n),o=Np(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(`
390
393
  `)}
391
- `:"",stderr:"",exitCode:0}}ie();function Mo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(R=>R?X(R):"0000000"),c=o?X(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(R=>R===null),d=!f&&n.some(R=>R!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let R=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${R}`)}else{let R=r.map(y=>y||"000000"),x=s||"000000";R.some(y=>y!==x)&&i.push(`mode ${R.join(",")}..${x}`)}let m=n.some(R=>R!==null);if(i.push(m?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
394
+ `:"",stderr:"",exitCode:0}}oe();function Fo(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?X(b):"0000000"),c=o?X(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(x=>x||"000000"),y=s||"000000";b.some(x=>x!==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(`
392
395
  `)}
393
- `;let u=e.parentContents.map(R=>R.length>0?Ft(R):[]),h=e.resultContent.length>0?Ft(e.resultContent):[],p=u.map(R=>ct(R,h)),g=Op(u,h,p),w=Sp(g,u.length,h);if(w.length===0)return"";for(let R of w)i.push(R);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=>at(b,m)),g=_p(u,m,p),w=Up(g,u.length,m);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
394
397
  `)}
395
- `}function Op(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=Ip(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 h=n[d];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function Ip(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=ct(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),m=s.find(u=>u.text===l.line&&u.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,m?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(m=>m.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(m=>m.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 Sp(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(m=>m!==" ")&&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,m=Math.max(0,d-3),u=Math.min(e.length-1,d+3);m<=c+1||(s.push({start:a,end:c}),a=m),c=u}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),m=[];for(let b=0;b<t;b++){let y=d.filter(E=>(E.parentLineNos[b]??0)>0||E.columns[b]==="-");if(y.length===0)m.push({start:1,count:0});else{let k=y.find(C=>(C.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;m.push({start:k,count:y.length})}}let u=d.filter(b=>b.resultLineNo>0),h=u[0],p=h?h.resultLineNo:1,g=u.length,w="";for(let b=p-2;b>=0;b--){let y=n[b];if(y&&/^[a-zA-Z$_]/.test(y)){w=` ${y.trimEnd().slice(0,79)}`;break}}let R=m.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${R.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of d)f.push(`${b.columns.join("")}${b.text}`)}return f}ie();Ce();ce();me();function jo(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}nr();we();Ae();tt();var aa=new TextDecoder;function El(e){return"exitCode"in e}function gr(e){return e.toString(8).padStart(6,"0")}function kl(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 Rl(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:$().describe("Show staged changes (index vs HEAD)"),staged:$().describe("Synonym for --cached"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),unified:V.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:$().alias("M").describe("Detect renames (enabled by default)"),findCopies:$().alias("C").describe("Detect copies (accepted for compatibility)"),color:$().describe("Show colored diff (accepted for compatibility)"),noColor:$().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=ut(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",m,u=c.length===1?jo(c[0]):null;if(u){if(a)return O("too many arguments");u.type==="three-dot"?m=await Hp(i,u.left,u.right,l):m=await yl(i,u.left,u.right,l)}else if(c.length===2)m=await yl(i,c[0],c[1],l);else{if(c.length>2)return O("too many arguments");a?m=await Ap(i,c.length===1?c[0]:null,l):c.length===1?m=await Dp(i,c[0],l):m=await Tp(i,l)}if(El(m))return m;let h=n.unified,p=await Mp(i,m.items,d,h);return m.stderr&&(p.stderr=m.stderr),p}})}async function Tp(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 gt(e,r);c.sort((l,d)=>Ie(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 m=gr(d.mode),u;if(l.status==="modified"&&e.workTree){let h=H(e.workTree,l.path),p=await e.fs.readFileBuffer(h);u=await pt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:u,oldMode:m,newMode:m,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),m=a.get(l);await vp(f,e,l,d,m)}return f.sort((l,d)=>{let m=Ie(l.path,d.path);return m!==0?m:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function vp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=gr(r.mode),a=gr(o.mode),{exists:c,hash:f}=await wl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),bl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=gr(r.mode),{exists:a,hash:c}=await wl(t.fs,s,n);bl(e,n,r.hash,i,a,c)}}async function wl(e,t,n){let r=H(t,n);if(!await e.exists(r))return{exists:!1};let o=await ss(e,r);return{exists:!0,hash:await pt("blob",o)}}function bl(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 Ap(e,t,n){let r=null;if(t){let m=await je(e,t);if(M(m))return m;r=m.commit.tree}else{let m=await Y(e);m&&(r=(await j(e,m)).tree)}let o=await le(e,r),s=await z(e),i=new Set;for(let m of s.entries)m.stage>0&&i.add(m.path);let a=new Map(Ne(s).map(m=>[m.path,m])),c=[];for(let[m,u]of a){if(i.has(m))continue;let h=o.get(m);h?h.hash!==u.hash&&c.push({path:m,status:"modified",oldHash:h.hash,newHash:u.hash,oldMode:h.mode,newMode:gr(u.mode)}):c.push({path:m,status:"added",newHash:u.hash,newMode:gr(u.mode)})}for(let[m,u]of o)i.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:u.hash,oldMode:u.mode});let{remaining:f,renames:l}=await it(e,c),d=kl(f,l);for(let m of i)d.push({path:m,status:"U"});return d.sort((m,u)=>Ie(m.path,u.path)),n?{items:d.filter(m=>Ee(n,m.path))}:{items:d}}async function yl(e,t,n,r){let o=await je(e,t);if(M(o))return o;let s=await je(e,n);if(M(s))return s;let i=await Ve(e,o.commit.tree,s.commit.tree);return xl(e,i,r)}async function Hp(e,t,n,r){let o=await je(e,t);if(M(o))return o;let s=await je(e,n);if(M(s))return s;let i=await Ut(e,o.hash,s.hash);if(i.length===0)return O(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
396
- `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await xl(e,l,r);return El(d)||a&&(d.stderr=a),d}async function xl(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=kl(r,o);return s.sort((i,a)=>Ie(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Dp(e,t,n){let r=Ye(e);if(r)return r;let o=await je(e,t);if(M(o))return o;let s=e.workTree,i=await le(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 m=H(s,l);if(!await e.fs.exists(m)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let u=await e.fs.readFileBuffer(m),h=await pt("blob",u);h!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:h,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let m=H(s,l);if(!await e.fs.exists(m))continue;let u=await e.fs.readFileBuffer(m),h=await pt("blob",u);f.push({path:l,status:"A",newHash:h,newMode:gr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Ie(l.path,d.path)),{items:f}}async function Mp(e,t,n,r){let o;switch(n){case"stat":o=await Fp(e,t);break;case"shortstat":o=await Up(e,t);break;case"numstat":o=await _p(e,t);break;case"name-only":o=Lp(t);break;case"name-status":o=Np(t);break;default:o=await jp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function jp(e,t,n){let r="",o=new Set,s=await Gp(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 ca(e,i);if(a.some(l=>Te(l))||Te(c)){let l=i.combinedParentHashes.map(d=>d?X(d):"0000000");r+=`diff --cc ${i.path}
398
+ `}function _p(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=Fp(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 Fp(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 Up(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 x=d.filter(k=>(k.parentLineNos[R]??0)>0||k.columns[R]==="-");if(x.length===0)h.push({start:1,count:0});else{let E=x.find(C=>(C.parentLineNos[R]??0)>0)?.parentLineNos[R]??1;h.push({start:E,count:x.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 x=n[R];if(x&&/^[a-zA-Z$_]/.test(x)){w=` ${x.trimEnd().slice(0,79)}`;break}}let b=h.map(R=>`-${R.start},${R.count}`),y=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(y);for(let R of d)f.push(`${R.columns.join("")}${R.text}`)}return f}oe();Ce();ie();pe();function Uo(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}sr();we();He();tt();var ga=new TextDecoder;function Al(e){return"exitCode"in e}function wr(e){return e.toString(8).padStart(6,"0")}function Dl(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 Ml(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:[z.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:V.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 q(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?Uo(c[0]):null;if(u){if(a)return T("too many arguments");u.type==="three-dot"?h=await zp(i,u.left,u.right,l):h=await Hl(i,u.left,u.right,l)}else if(c.length===2)h=await Hl(i,c[0],c[1],l);else{if(c.length>2)return T("too many arguments");a?h=await qp(i,c.length===1?c[0]:null,l):c.length===1?h=await Kp(i,c[0],l):h=await Bp(i,l)}if(Al(h))return h;let m=n.unified,p=await Vp(i,h.items,d,m);return h.stderr&&(p.stderr=h.stderr),p}})}async function Bp(e,t){let n=Ve(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await wt(e,r);c.sort((l,d)=>Ie(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=wr(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 Wp(f,e,l,d,h)}return f.sort((l,d)=>{let h=Ie(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 Wp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=wr(r.mode),a=wr(o.mode),{exists:c,hash:f}=await Tl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),vl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=wr(r.mode),{exists:a,hash:c}=await Tl(t.fs,s,n);vl(e,n,r.hash,i,a,c)}}async function Tl(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await os(e,r);return{exists:!0,hash:await gt("blob",o)}}function vl(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 qp(e,t,n){let r=null;if(t){let h=await Ge(e,t);if(M(h))return h;r=h.commit.tree}else{let h=await Y(e);h&&(r=(await j(e,h)).tree)}let o=await de(e,r),s=await K(e),i=new Set;for(let h of s.entries)h.stage>0&&i.add(h.path);let a=new Map(Le(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:wr(u.mode)}):c.push({path:h,status:"added",newHash:u.hash,newMode:wr(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=Dl(f,l);for(let h of i)d.push({path:h,status:"U"});return d.sort((h,u)=>Ie(h.path,u.path)),n?{items:d.filter(h=>Ee(n,h.path))}:{items:d}}async function Hl(e,t,n,r){let o=await Ge(e,t);if(M(o))return o;let s=await Ge(e,n);if(M(s))return s;let i=await Ke(e,o.commit.tree,s.commit.tree);return jl(e,i,r)}async function zp(e,t,n,r){let o=await Ge(e,t);if(M(o))return o;let s=await Ge(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 jl(e,l,r);return Al(d)||a&&(d.stderr=a),d}async function jl(e,t,n){let{remaining:r,renames:o}=await ot(e,t),s=Dl(r,o);return s.sort((i,a)=>Ie(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Kp(e,t,n){let r=Ve(e);if(r)return r;let o=await Ge(e,t);if(M(o))return o;let s=e.workTree,i=await de(e,o.commit.tree),a=await K(e),c=new Map(Le(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:wr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Ie(l.path,d.path)),{items:f}}async function Vp(e,t,n,r){let o;switch(n){case"stat":o=await eg(e,t);break;case"shortstat":o=await tg(e,t);break;case"numstat":o=await Qp(e,t);break;case"name-only":o=Zp(t);break;case"name-status":o=Jp(t);break;default:o=await Yp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Yp(e,t,n){let r="",o=new Set,s=await Xp(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 wa(e,i);if(a.some(l=>Te(l))||Te(c)){let l=i.combinedParentHashes.map(d=>d?X(d):"0000000");r+=`diff --cc ${i.path}
397
400
  index ${l.join(",")}..0000000
398
401
  Binary files differ
399
- `,o.add(i.path)}else{let l=Mo({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}
402
+ `,o.add(i.path)}else{let l=Fo({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}
400
403
  `}}else r+=`* Unmerged path ${i.path}
401
- `;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 ca(e,i);i.status==="R"&&i.oldPath?r+=Tt({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Go(i.oldHash,s),newHash:Go(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=Tt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Go(i.oldHash,s),newHash:Go(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Gp(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=H(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),m=0;for(let u of d)if(u.startsWith(l)&&(m++,m>1))return!1;return m===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 Go(e,t){if(e)return e.length!==40?e:t.get(e)??X(e)}function Lp(e){let t="";for(let n of e)t+=`${n.path}
402
- `;return t}function Np(e){let t="";for(let n of e)if(n.status==="R"){let r=String(n.similarity??100).padStart(3,"0");t+=`R${r} ${n.oldPath} ${n.path}
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 wa(e,i);i.status==="R"&&i.oldPath?r+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Bo(i.oldHash,s),newHash:Bo(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:Bo(i.oldHash,s),newHash:Bo(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Xp(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 Bo(e,t){if(e)return e.length!==40?e:t.get(e)??X(e)}function Zp(e){let t="";for(let n of e)t+=`${n.path}
405
+ `;return t}function Jp(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}
403
406
  `}else t+=`${n.status} ${n.path}
404
- `;return t}async function _p(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
405
- `;continue}let o=r.oldHash?await se(e,r.oldHash):"",s=await ca(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Cl(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=un(r.oldPath,r.path);n+=`${a} ${c} ${f}
407
+ `;return t}async function Qp(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 wa(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Gl(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}
406
409
  `}else n+=`${a} ${c} ${r.path}
407
- `}return n}async function Fp(e,t){let n=await Pl(e,t);return ur(n)}async function Up(e,t){let n=await Pl(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=Xn(s,r,o);return i?`${i}
410
+ `}return n}async function eg(e,t){let n=await Ll(e,t);return hr(n)}async function tg(e,t){let n=await Ll(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=Zn(s,r,o);return i?`${i}
408
411
  `:n.some(a=>a.isUnmerged)?` 0 files changed
409
- `:""}async function ca(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path),r=await ss(e.fs,n);return aa.decode(r)}return se(e,t.newHash)}async function Bp(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path);return ss(e.fs,n)}return Pt(e,t.newHash)}function Cl(e,t){let n=Rt(e),r=Rt(t),o=ct(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 Pl(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?un(r.oldPath,r.path):r.path,s=r.oldHash?await Pt(e,r.oldHash):new Uint8Array(0),i=await Bp(e,r);if(Dn(s)||Dn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=aa.decode(s),c=aa.decode(i),{ins:f,del:l}=Cl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}ie();Be();Tn();me();ze();we();function wr(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 Wp(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 xs(e,t){if(!Wp(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 Ol(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:$().describe("Fetch from all remotes"),prune:$().alias("p").describe("Remove stale remote-tracking refs"),tags:$().describe("Also fetch tags"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().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 O("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Oo(s))return O("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=bs),n.all){if(n.remote)return O("fetch --all does not take a remote argument");let c=await pe(s),f=[];for(let m of Object.keys(c)){let u=m.match(/^remote "(.+)"$/);u?.[1]&&f.push(u[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let m of f){let u=await $l(s,m,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 Lr(e,t,s)}catch(S){let A=S instanceof Error?S.message:"";if(A.startsWith("network"))return O(A);throw S}if(!c)return O(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,m=wr(l.fetchRefspec);n&&n.length>0?d=n.map(S=>{let A=wr(S);if(S.includes(":"))return A;for(let D of[A.src,`refs/heads/${A.src}`,`refs/tags/${A.src}`]){let _=xs(m,D);if(_!==null)return{force:A.force||m.force,src:D,dst:_}}return A}):d=[m];let u=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(S=>`${S.src}:${S.dst}`),prune:r,tags:o});if(de(u))return{stdout:"",stderr:u.message??"",exitCode:1};let h=await f.advertiseRefs();if(h.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await ge(e)).map(S=>S.hash),w=await B(e,"HEAD");w&&g.push(w);let R=[],x=new Set,b=[];for(let S of h)if(S.name!=="HEAD")for(let A of d){let D=xs(A,S.name);if(D!==null){b.push({remote:S,localRef:D,force:A.force}),x.has(S.hash)||(x.add(S.hash),R.push(S.hash));break}}if(o)for(let S of h)S.name.startsWith("refs/tags/")&&(b.push({remote:S,localRef:S.name,force:!1}),x.has(S.hash)||(x.add(S.hash),R.push(S.hash)));let y=new Set(g),E=R.filter(S=>!y.has(S)),k,C=a!==void 0?await Hr(e):void 0;a!==void 0&&(k={depth:a,existingShallows:C});let P=E.length>0?E:k?R:[];if(P.length>0){let S=await f.fetch(P,g,k);S.shallowUpdates&&await Dr(e,S.shallowUpdates,C)}let I=await nn(e,s),v=[];v.push(`From ${l.url}
410
- `);for(let S of b){let A=await B(e,S.localRef);await Z(e,S.localRef,S.remote.hash),await Ze(e,S.localRef,{oldHash:A??ee,newHash:S.remote.hash,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:A?"fetch":"fetch: storing head"});let D=Lo(S.remote.name),_=Lo(S.localRef);if(A){if(A!==S.remote.hash){let F=X(A),U=X(S.remote.hash);v.push(` ${F}..${U} ${D} -> ${_}
411
- `)}}else{let U=S.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";v.push(`${U} ${D} -> ${_}
412
- `)}}if(!o)for(let S of h){if(!S.name.startsWith("refs/tags/")||x.has(S.hash))continue;let A=await B(e,S.name),D=S.peeledHash??S.hash;!A&&y.has(D)&&(await Z(e,S.name,S.hash),await Ze(e,S.name,{oldHash:ee,newHash:S.hash,name:I.name,email:I.email,timestamp:I.timestamp,tz:I.tz,message:"fetch: storing head"}),v.push(` * [new tag] ${Lo(S.name)} -> ${Lo(S.name)}
413
- `))}if(r){let S=`refs/remotes/${t}`,A=await ge(e,S),D=new Set(h.filter(_=>_.name.startsWith("refs/heads/")).map(_=>_.name.slice(11)));for(let _ of A){let F=_.name.slice(S.length+1);D.has(F)||(await he(e,_.name),v.push(` - [deleted] (none) -> ${t}/${F}
414
- `))}}let T=h.find(S=>S.name==="HEAD");if(T){let S=H(e.gitDir,"FETCH_HEAD"),A=h.find(_=>_.name.startsWith("refs/heads/")&&_.hash===T.hash),D=A?`branch '${A.name.slice(11)}' of`:"of";await e.fs.writeFile(S,`${T.hash} ${D} ${l.url}
415
- `)}let N={stdout:"",stderr:v.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:b.length}),N}function Lo(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}ie();Ce();ce();me();ze();we();ie();Ce();ce();me();ze();we();async function Il(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=H(e.gitDir,"logs");await e.fs.exists(o)&&await Sl(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 Yt(e,a)&&i.push(a);return i}async function Sl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=H(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Sl(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!==ee&&r.add(l.newHash)}}}Ws();xr();me();async function qp(e,t){let n=new Set,r=H(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(H(r,i)),c=new Kt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?jr(await Mr(e,t,[])):(await jr(await Mr(e,t,[]))).filter(s=>!n.has(s.hash))}async function fa(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 jr(await Mr(t,r,[])):await qp(t,r);if(a.length===0)return null;let c=a.length,f=To(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:m,entries:u}=await Bs(d),h=await xc(m,u),p=m.subarray(m.byteLength-20),g="";for(let E=0;E<20;E++){let k=p[E];g+=(k>>4).toString(16)+(k&15).toString(16)}let w=H(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let R=`pack-${g}`,x=H(w,`${R}.pack`),b=H(w,`${R}.idx`);await n.writeFile(x,m),await n.writeFile(b,h);let y=new Set(f.map(E=>E.hash));if(t.objectStore.invalidatePacks?.(),o){let E=await n.readdir(w);for(let P of E){if(!P.endsWith(".idx"))continue;let I=P.slice(0,-4);if(I===R)continue;let v=H(w,`${I}.idx`),T=!0;try{let N=await n.readFileBuffer(v),S=new Kt(N);for(let A of S.allHashes())if(!y.has(A)){T=!1;break}}catch{T=!1}if(T){try{await n.rm(H(w,`${I}.pack`))}catch{}try{await n.rm(v)}catch{}}}let k=H(t.gitDir,"objects"),C;try{C=await n.readdir(k)}catch{C=[]}for(let P of C){if(P==="pack"||P==="info"||P.length!==2)continue;let I=H(k,P),v;try{v=await n.readdir(I)}catch{continue}for(let T of v){let N=`${P}${T}`;y.has(N)&&await n.rm(H(I,T))}try{(await n.readdir(I)).length===0&&await n.rm(I,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function la(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(`
416
- `)}function Tl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:$().alias("a").describe("Pack all objects, including already-packed"),delete:$().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 Il(s),a=await fa({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${la(a.totalCount,a.deltaCount)}
412
+ `:""}async function wa(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await os(e.fs,n);return ga.decode(r)}return re(e,t.newHash)}async function ng(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return os(e.fs,n)}return Ot(e,t.newHash)}function Gl(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 Ll(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 ng(e,r);if(Dn(s)||Dn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=ga.decode(s),c=ga.decode(i),{ins:f,del:l}=Gl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}oe();Be();Tn();pe();ze();we();function br(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 rg(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 Cs(e,t){if(!rg(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 _l(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[z.string().name("remote").describe("Remote to fetch from").optional(),z.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:V.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 q(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 Ao(s))return T("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=ys),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 Nl(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 Nl(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function Nl(e,t,n,r,o,s,i,a){let c;try{c=await _r(e,t,s)}catch(O){let _=O instanceof Error?O.message:"";if(_.startsWith("network"))return T(_);throw O}if(!c)return T(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,h=br(l.fetchRefspec);n&&n.length>0?d=n.map(O=>{let _=br(O);if(O.includes(":"))return _;for(let U of[_.src,`refs/heads/${_.src}`,`refs/tags/${_.src}`]){let F=Cs(h,U);if(F!==null)return{force:_.force||h.force,src:U,dst:F}}return _}):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,R=[];for(let O of m)if(O.name!=="HEAD")for(let _ of d){let U=Cs(_,O.name);if(U!==null){R.push({remote:O,localRef:U,force:_.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/")&&(R.push({remote:O,localRef:O.name,force:!1}),y.has(O.hash)||(y.add(O.hash),b.push(O.hash)));let x=new Set(g),k=b.filter(O=>!x.has(O)),E,C=a!==void 0?await Mr(e):void 0;a!==void 0&&(E={depth:a,existingShallows:C});let $=k.length>0?k:E?b:[];if($.length>0){let O=await f.fetch($,g,E);O.shallowUpdates&&await jr(e,O.shallowUpdates,C)}let H=await rn(e,s),P=[],I=[];for(let O of R){let _=await B(e,O.localRef);I.push(_),await Z(e,O.localRef,O.remote.hash),await Je(e,O.localRef,{oldHash:_??ee,newHash:O.remote.hash,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:_?"fetch":"fetch: storing head"})}if(P.push(...ao(R.map((O,_)=>({...O,oldHash:I[_]})),jn,X)),!o)for(let O of m){if(!O.name.startsWith("refs/tags/")||y.has(O.hash))continue;let _=await B(e,O.name),U=O.peeledHash??O.hash;!_&&x.has(U)&&(await Z(e,O.name,O.hash),await Je(e,O.name,{oldHash:ee,newHash:O.hash,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:"fetch: storing head"}),P.push({prefix:" * [new tag]",from:jn(O.name),to:jn(O.name)}))}if(r){let O=`refs/remotes/${t}`,_=await ge(e,O),U=new Set(m.filter(F=>F.name.startsWith("refs/heads/")).map(F=>F.name.slice(11)));for(let F of _){if((await e.refStore.readRef(F.name))?.type==="symbolic")continue;let W=F.name.slice(O.length+1);W!=="HEAD"&&(U.has(W)||(await me(e,F.name),P.push({prefix:" - [deleted]",from:"(none)",to:`${t}/${W}`})))}}let D=m.find(O=>O.name==="HEAD");if(D){let O=v(e.gitDir,"FETCH_HEAD"),_=m.find(F=>F.name.startsWith("refs/heads/")&&F.hash===D.hash),U=_?`branch '${_.name.slice(11)}' of`:"of";await e.fs.writeFile(O,`${D.hash} ${U} ${l.url}
413
+ `),await Ys(e,t,m,f.headTarget)}let A={stdout:"",stderr:P.length>0?`From ${l.url}
414
+ ${Sr(P,10)}`:"",exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:R.length}),A}oe();Ce();ie();pe();ze();we();oe();Ce();ie();pe();ze();we();async function Fl(e){let t=new Set,n=await Y(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 Ul(e,o,o,t);let s=await K(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await 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 Ul(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 Ul(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!==ee&&r.add(l.newHash)}}}Ks();Cr();pe();async function sg(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?Lr(await Gr(e,t,[])):(await Lr(await Gr(e,t,[]))).filter(s=>!n.has(s.hash))}async function ba(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 Lr(await Gr(t,r,[])):await sg(t,r);if(a.length===0)return null;let c=a.length,f=jo(a,{window:s,depth:i}),l=f.filter(k=>k.delta).length,d=f.map(k=>({hash:k.hash,type:k.type,content:k.content,delta:k.delta,deltaBaseHash:k.deltaBase})),{data:h,entries:u}=await zs(d),m=await Dc(h,u),p=h.subarray(h.byteLength-20),g="";for(let k=0;k<20;k++){let E=p[k];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`),R=v(w,`${b}.idx`);await n.writeFile(y,h),await n.writeFile(R,m);let x=new Set(f.map(k=>k.hash));if(t.objectStore.invalidatePacks?.(),o){let k=await n.readdir(w);for(let $ of k){if(!$.endsWith(".idx"))continue;let H=$.slice(0,-4);if(H===b)continue;let P=v(w,`${H}.idx`),I=!0;try{let D=await n.readFileBuffer(P),G=new Xt(D);for(let A of G.allHashes())if(!x.has(A)){I=!1;break}}catch{I=!1}if(I){try{await n.rm(v(w,`${H}.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 H=v(E,$),P;try{P=await n.readdir(H)}catch{continue}for(let I of P){let D=`${$}${I}`;x.has(D)&&await n.rm(v(H,I))}try{(await n.readdir(H)).length===0&&await n.rm(H,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function ya(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 Bl(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 q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Fl(s),a=await ba({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${ya(a.totalCount,a.deltaCount)}
417
416
  `,exitCode:0}:{stdout:`Nothing new to pack.
418
- `,stderr:"",exitCode:0}}})}function vl(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:$().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 Hc(s),await yt(s);let i=await Kp(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await fa({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await Vp(s.gitDir,r.fs),f)return{stdout:"",stderr:`${la(f.totalCount,f.deltaCount,!0)}
419
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var zp=2160*60*60;async function Kp(e){let t=new Set,n=await Y(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)-zp,i=H(e.gitDir,"logs");await e.fs.exists(i)&&await Al(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 Yt(e,f)&&c.push(f);return c}async function Al(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=H(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Al(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 m of l)m.newHash!==ee&&o.add(m.newHash);continue}let d=l.filter(m=>m.timestamp>=r);await Ln(e,f,d);for(let m of d)m.newHash!==ee&&o.add(m.newHash)}}}async function Vp(e,t){let n=H(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(H(n,o),{recursive:!0})}catch{}}ie();function Yp(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 Hl(e,t,n,r){if(Yp(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
420
- `);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 Xp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dl(e,t){let n=t?.fixed?Xp(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ce();me();Ae();async function Zp(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=H(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function Jp(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 Qp(e,t){return(await Ke(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>se(e,r.hash)}))}function eg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function tg(e,t,n){return n||t===""?e:st(t,e)}function Ml(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[q.string().name("args").variadic().optional()],options:{cached:$().describe("Search blobs registered in the index"),lineNumber:$().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:$().alias("l").describe("Show only filenames"),filesWithoutMatch:$().alias("L").describe("Show only filenames without matches"),count:$().alias("c").describe("Show count of matching lines per file"),ignoreCase:$().alias("i").describe("Case insensitive matching"),wordRegexp:$().alias("w").describe("Match whole words only"),invertMatch:$().alias("v").describe("Invert the sense of matching"),fixedStrings:$().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:$().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:$().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:$().alias("h").describe("Suppress filename prefix"),forceFilename:$().alias("H").describe("Force filename prefix"),fullName:$().describe("Force paths to be output relative to project top"),quiet:$().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:$().describe("Require all patterns to match in a file"),maxDepth:V.number().describe("Descend at most <n> levels of directories"),maxCount:V.number().alias("m").describe("Maximum number of matches per file"),afterContext:V.number().alias("A").describe("Show <n> lines after match"),beforeContext:V.number().alias("B").describe("Show <n> lines before match"),context:V.number().alias("C").describe("Show <n> lines before and after match"),heading:$().describe("Show filename above matches"),break:$().describe("Print empty line between results from different files"),pattern:V.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 O("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let m=[];for(let U of f){let L=Dl(U,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!L)return O(`command line, '${U}': invalid regular expression`);m.push(L)}let u=[];if(l.length>0)for(let U of l){let L=await wt(i,U);if(M(L))return L;let K;try{K=await ve(i,L)}catch{return O(`bad revision '${U}'`)}let te=await j(i,K),J=await Qp(i,te.tree);u.push({prefix:`${U}:`,files:J})}else if(n.cached)u.push({prefix:"",files:await Jp(i)});else{if(!i.workTree)return O("this operation must be run in a work tree");u.push({prefix:"",files:await Zp(i)})}let h=ut(i,r.cwd),p=null;c.length>0&&(p=c.map(U=>Ue(U,h)));let g=n.maxDepth,w=n.maxCount,R=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),x=!!n.filesWithMatches,b=!!n.filesWithoutMatch,y=!!n.count,E=!!n.quiet,k=!!n.heading,C=!!n.break,P=!!n.suppressFilename,I=!!n.invertMatch,v=!!n.allMatch,T=n.context??n.afterContext??0,N=n.context??n.beforeContext??0,S=T>0||N>0,A=[],D=!1,_=!0;for(let U of u){let L=U.files.slice().sort((K,te)=>K.path<te.path?-1:K.path>te.path?1:0);for(let K of L){if(p&&!Ee(p,K.path)||g!==void 0&&eg(K.path)>g)continue;let te=await K.getContent(),J=Hl(te,m,v,I),ne=tg(K.path,h,!!n.fullName),ke=U.prefix;if(J.binary){if(D=!0,E)return{stdout:"",stderr:"",exitCode:0};x?A.push(`${ke}${ne}`):!b&&!y&&A.push(`Binary file ${ke}${ne} matches`);continue}if(J.matches.length===0){b&&A.push(`${ke}${ne}`);continue}if(D=!0,E)return{stdout:"",stderr:"",exitCode:0};if(b)continue;if(x){A.push(`${ke}${ne}`);continue}if(y){let ae=w!==void 0?Math.min(J.matches.length,w):J.matches.length;A.push(`${ke}${ne}:${ae}`);continue}let Ge=J.matches;if(w!==void 0&&(Ge=Ge.slice(0,w)),S)ng(A,te,Ge,ke,ne,P,N,T,k,C,_);else if(k){!_&&C&&A.push(""),A.push(`${ke}${ne}`);for(let ae of Ge)R?A.push(`${ae.lineNo}:${ae.line}`):A.push(ae.line)}else{!_&&C&&A.push("");for(let ae of Ge){let Oe=P?"":`${ke}${ne}:`;R?A.push(`${Oe}${ae.lineNo}:${ae.line}`):A.push(`${Oe}${ae.line}`)}}_=!1}}return E?{stdout:"",stderr:"",exitCode:D?0:1}:{stdout:A.length>0?`${A.join(`
417
+ `,stderr:"",exitCode:0}}})}function Wl(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 q(r.fs,r.cwd,t);if(M(o))return o;let s=o;await Wc(s),await Et(s);let i=await ig(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await ba({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await ag(s.gitDir,r.fs),f)return{stdout:"",stderr:`${ya(f.totalCount,f.deltaCount,!0)}
418
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var og=2160*60*60;async function ig(e){let t=new Set,n=await Y(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)-og,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await ql(e,i,i,s,t);let a=await K(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let l=await 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 ql(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 ql(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!==ee&&o.add(h.newHash);continue}let d=l.filter(h=>h.timestamp>=r);await Nn(e,f,d);for(let h of d)h.newHash!==ee&&o.add(h.newHash)}}}async function ag(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 cg(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(cg(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 fg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kl(e,t){let n=t?.fixed?fg(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();He();async function lg(e){let t=await K(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 dg(e){let t=await K(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 ug(e,t){return(await qe(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>re(e,r.hash)}))}function hg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function mg(e,t,n){return n||t===""?e:rt(t,e)}function Vl(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[z.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:V.number().describe("Descend at most <n> levels of directories"),maxCount:V.number().alias("m").describe("Maximum number of matches per file"),afterContext:V.number().alias("A").describe("Show <n> lines after match"),beforeContext:V.number().alias("B").describe("Show <n> lines before match"),context:V.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:V.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await q(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 L=Kl(F,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!L)return T(`command line, '${F}': invalid regular expression`);h.push(L)}let u=[];if(l.length>0)for(let F of l){let L=await bt(i,F);if(M(L))return L;let W;try{W=await ve(i,L)}catch{return T(`bad revision '${F}'`)}let ne=await j(i,W),J=await ug(i,ne.tree);u.push({prefix:`${F}:`,files:J})}else if(n.cached)u.push({prefix:"",files:await dg(i)});else{if(!i.workTree)return T("this operation must be run in a work tree");u.push({prefix:"",files:await lg(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,R=!!n.filesWithoutMatch,x=!!n.count,k=!!n.quiet,E=!!n.heading,C=!!n.break,$=!!n.suppressFilename,H=!!n.invertMatch,P=!!n.allMatch,I=n.context??n.afterContext??0,D=n.context??n.beforeContext??0,G=I>0||D>0,A=[],O=!1,_=!0;for(let F of u){let L=F.files.slice().sort((W,ne)=>W.path<ne.path?-1:W.path>ne.path?1:0);for(let W of L){if(p&&!Ee(p,W.path)||g!==void 0&&hg(W.path)>g)continue;let ne=await W.getContent(),J=zl(ne,h,P,H),te=mg(W.path,m,!!n.fullName),ke=F.prefix;if(J.binary){if(O=!0,k)return{stdout:"",stderr:"",exitCode:0};y?A.push(`${ke}${te}`):!R&&!x&&A.push(`Binary file ${ke}${te} matches`);continue}if(J.matches.length===0){R&&A.push(`${ke}${te}`);continue}if(O=!0,k)return{stdout:"",stderr:"",exitCode:0};if(R)continue;if(y){A.push(`${ke}${te}`);continue}if(x){let ce=w!==void 0?Math.min(J.matches.length,w):J.matches.length;A.push(`${ke}${te}:${ce}`);continue}let _e=J.matches;if(w!==void 0&&(_e=_e.slice(0,w)),G)pg(A,ne,_e,ke,te,$,D,I,E,C,_);else if(E){!_&&C&&A.push(""),A.push(`${ke}${te}`);for(let ce of _e)b?A.push(`${ce.lineNo}:${ce.line}`):A.push(ce.line)}else{!_&&C&&A.push("");for(let ce of _e){let Oe=$?"":`${ke}${te}:`;b?A.push(`${Oe}${ce.lineNo}:${ce.line}`):A.push(`${Oe}${ce.line}`)}}_=!1}}return k?{stdout:"",stderr:"",exitCode:O?0:1}:{stdout:A.length>0?`${A.join(`
421
420
  `)}
422
- `:"",stderr:"",exitCode:D?0:1}}})}function ng(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
423
- `);d.length>0&&d[d.length-1]===""&&d.pop();let m=new Set(n.map(g=>g.lineNo)),u=[];for(let g of n){let w=Math.max(1,g.lineNo-i),R=Math.min(d.length,g.lineNo+a);u.push([w,R])}let h=[];for(let[g,w]of u)h.length>0&&g<=h[h.length-1][1]+1?h[h.length-1][1]=Math.max(h[h.length-1][1],w):h.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<h.length;g++){g>0&&e.push("--");let[w,R]=h[g];for(let x=w;x<=R;x++){let b=d[x-1],E=m.has(x)?":":"-";c?e.push(`${x}${E}${b}`):e.push(`${p}${E}${x}${E}${b}`)}}}me();Gn();function jl(e,t){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:$().describe("Create a bare repository"),initialBranch:V.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?Ht(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await zs(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 pg(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 R=d[y-1],k=h.has(y)?":":"-";c?e.push(`${y}${k}${R}`):e.push(`${p}${k}${y}${k}${R}`)}}}pe();Ln();function Yl(e,t){e.command("init",{description:"Initialize a new repository",args:[z.string().name("directory").describe("The directory to initialize").optional()],options:{bare:S().describe("Create a bare repository"),initialBranch:V.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 Xs(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
424
423
  `);let f=n.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${f}Git repository in ${i.gitDir}/
425
- `,stderr:c,exitCode:0}}})}ie();ar();var No=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:Gl(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,Gl(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 Gl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}ie();function Cs(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+=_l(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Fl(c.timestamp,c.timezone),s+=3;continue;case"d":o+=_o(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=Bl(c.timestamp,c.timezone),s+=3;continue;case"r":o+=Ul(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=X(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=X(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(X).join(" "),s+=2;continue;case"s":o+=da(r.message),s+=2;continue;case"b":o+=rg(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+=`
426
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var da=ue;function rg(e){let t=e.indexOf(`
424
+ `,stderr:c,exitCode:0}}})}oe();fr();var Wo=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:Xl(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,Xl(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 Xl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}oe();function Ps(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+=Ql(c.timestamp,c.timezone),s+=3;continue;case"i":o+=ed(c.timestamp,c.timezone),s+=3;continue;case"d":o+=qo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=nd(c.timestamp,c.timezone),s+=3;continue;case"r":o+=td(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=X(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=X(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(X).join(" "),s+=2;continue;case"s":o+=Ea(r.message),s+=2;continue;case"b":o+=gg(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
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Ea=ue;function gg(e){let t=e.indexOf(`
427
426
 
428
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Fo(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 Ps(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?X(o):o,c=da(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(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${da(s.message)}`),a.join(`
427
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function zo(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 $s(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?X(o):o,c=Ea(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(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${Ea(s.message)}`),a.join(`
429
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(X).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(`
430
429
  `))a.push(` ${f}`);return a.join(`
431
- `)}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(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${_o(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${_o(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
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(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${qo(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${qo(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
432
431
  `))a.push(` ${f}`);return a.join(`
433
- `)}case"raw":return sg(t,n);default:return og(t,n)}}function sg(e,t){let{hash:n,commit:r}=e,o=[];t||o.push(""),o.push(`commit ${n}`),o.push(`tree ${r.tree}`);for(let i of r.parents)o.push(`parent ${i}`);o.push(`author ${r.author.name} <${r.author.email}> ${r.author.timestamp} ${r.author.timezone}`),o.push(`committer ${r.committer.name} <${r.committer.email}> ${r.committer.timestamp} ${r.committer.timezone}`),o.push("");let s=r.message.replace(/\n$/,"");for(let i of s.split(`
432
+ `)}case"raw":return wg(t,n);default:return bg(t,n)}}function wg(e,t){let{hash:n,commit:r}=e,o=[];t||o.push(""),o.push(`commit ${n}`),o.push(`tree ${r.tree}`);for(let i of r.parents)o.push(`parent ${i}`);o.push(`author ${r.author.name} <${r.author.email}> ${r.author.timestamp} ${r.author.timezone}`),o.push(`committer ${r.committer.name} <${r.committer.email}> ${r.committer.timestamp} ${r.committer.timezone}`),o.push("");let s=r.message.replace(/\n$/,"");for(let i of s.split(`
434
433
  `))o.push(` ${i}`);return o.join(`
435
- `)}function og(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(X).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${_o(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
434
+ `)}function bg(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(X).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${qo(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
436
435
  `))s.push(` ${a}`);return s.join(`
437
- `)}var Ll=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Nl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ig(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 Uo(e,t){let n=ig(t);return new Date((e+n*60)*1e3)}function ag(e){return`${e.slice(0,3)}:${e.slice(3)}`}function _l(e,t){let n=Uo(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":ag(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function Fl(e,t){let n=Uo(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 Ul(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 cg(e,t){let n=Uo(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 fg(e,t){return`${e} ${t}`}function lg(e){return e.toString()}function dg(e,t){let n=new Date(e*1e3),r=Ll[n.getDay()]?.slice(0,3),o=Nl[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 _o(e,t,n){switch(n){case"short":return cg(e,t);case"iso":return Fl(e,t);case"iso-strict":return _l(e,t);case"relative":case"human":return Ul(e);case"rfc":return Bl(e,t);case"raw":return fg(e,t);case"unix":return lg(e);case"local":return dg(e,t);default:return Cn(e,t)}}function Bl(e,t){let n=Uo(e,t),r=Ll[n.getUTCDay()]?.slice(0,3),o=Nl[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}`}ce();we();an();Ae();function zl(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:V.number().alias("n").describe("Limit the number of commits to output"),oneline:$().describe("Condense each commit to a single line"),all:$().describe("Walk all refs, not just HEAD"),author:V.string().describe("Filter by author (regex or substring)"),grep:V.string().describe("Filter by commit message (regex or substring)"),since:V.string().describe("Show commits after date"),after:V.string().describe("Synonym for --since"),until:V.string().describe("Show commits before date"),before:V.string().describe("Synonym for --until"),decorate:$().describe("Show ref names next to commit hashes"),reverse:$().describe("Output commits in reverse order"),format:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name"),patch:$().alias("p").describe("Show diff in patch format"),stat:$().describe("Show diffstat summary"),nameStatus:$().describe("Show names and status of changed files"),nameOnly:$().describe("Show only names of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),graph:$().describe("Draw text-based graph of the commit history"),firstParent:$().describe("Follow only the first parent of merge commits"),date:V.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?jo(f[0]):null;if(l){let J=async Oe=>{let rt=await We(i,Oe);if(!rt)return Zt(Oe);try{return await ve(i,rt)}catch{return Zt(Oe)}},ne=await J(l.left);if(typeof ne=="object"&&"exitCode"in ne)return ne;let ke=await J(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let Ge=ne,ae=ke;if(l.type==="two-dot")a=[ae],c=[Ge];else{a=[Ge,ae];let Oe=await Ut(i,Ge,ae);c=Oe.length>0?Oe:void 0}if(n.all){let Oe=await ge(i);for(let Sn of Oe)try{let qe=await ve(i,Sn.hash);a.includes(qe)||a.push(qe)}catch{}let rt=await Y(i);rt&&!a.includes(rt)&&a.push(rt)}}else if(n.all){let J=await ge(i),ne=new Set;for(let Ge of J)try{ne.add(await ve(i,Ge.hash))}catch{}let ke=await Y(i);ke&&ne.add(ke),a=[...ne]}else if(f&&f.length>0){let J=[];for(let ne of f){let ke=await We(i,ne);if(!ke)return Zt(ne);try{J.push(await ve(i,ke))}catch{return Zt(ne)}}a=J}else{let J=await Qe(i);if(M(J))return J;a=[J]}if(a.length===0)return O("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(J=>Ue(J,"")):null,m=n.author?Wl(n.author):null,u=n.grep?Wl(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?Vi(h):null,w=p?Vi(p):null,R=n.format??n.pretty,x=null,b=null,y=!1;if(n.oneline)b="oneline",y=!0;else if(R!==void 0){let J=Fo(R);x=J.formatStr,b=J.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}
438
- `,exitCode:128};let k=n.date,C=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,P=n.graph;if(P&&n.reverse)return O("options '--graph' and '--reverse' cannot be used together");let v=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await hg(i):null,T=v?J=>ql(v,J):void 0,N=v?J=>{let ne=ql(v,J);return ne.startsWith("(")&&ne.endsWith(")")?ne.slice(1,-1):ne}:void 0,S=n.maxCount,A=n.reverse,D=n.firstParent,_=d?mg(i,a,d,c?await ug(i,c):void 0,D):Lt(i,a,{exclude:c,topoOrder:P,firstParent:D}),F=[];for await(let J of _){if(S!==void 0&&F.length>=S)break;let{commit:ne}=J;if(!(w!==null&&ne.committer.timestamp>w)&&!(g!==null&&ne.committer.timestamp<=g)){if(m){let ke=`${ne.author.name} <${ne.author.email}>`;if(!m(ke))continue}u&&!u(ne.message)||F.push(J)}}let U=A?F.reverse():F;if(P)return pg(U,i,x,b,y,C,T,N,k);if(x!==null){let J=[];for(let ne of U){let ke={hash:ne.hash,commit:ne.commit,decorations:T,decorationsRaw:N,dateMode:k},Ge=Cs(x,ke),ae=await ua(i,ne.commit,C);ae&&(Ge+=`
436
+ `)}var Zl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Jl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function yg(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 Ko(e,t){let n=yg(t);return new Date((e+n*60)*1e3)}function Eg(e){return`${e.slice(0,3)}:${e.slice(3)}`}function Ql(e,t){let n=Ko(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":Eg(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function ed(e,t){let n=Ko(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 td(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 kg(e,t){let n=Ko(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 Rg(e,t){return`${e} ${t}`}function xg(e){return e.toString()}function Cg(e,t){let n=new Date(e*1e3),r=Zl[n.getDay()]?.slice(0,3),o=Jl[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 qo(e,t,n){switch(n){case"short":return kg(e,t);case"iso":return ed(e,t);case"iso-strict":return Ql(e,t);case"relative":case"human":return td(e);case"rfc":return nd(e,t);case"raw":return Rg(e,t);case"unix":return xg(e);case"local":return Cg(e,t);default:return $n(e,t)}}function nd(e,t){let n=Ko(e,t),r=Zl[n.getUTCDay()]?.slice(0,3),o=Jl[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();He();function od(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[z.string().name("revisions").variadic().optional()],options:{maxCount:V.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:V.string().describe("Filter by author (regex or substring)"),grep:V.string().describe("Filter by commit message (regex or substring)"),since:V.string().describe("Show commits after date"),after:V.string().describe("Synonym for --since"),until:V.string().describe("Show commits before date"),before:V.string().describe("Synonym for --until"),decorate:S().describe("Show ref names next to commit hashes"),reverse:S().describe("Output commits in reverse order"),format:V.string().describe("Pretty-print format string"),pretty:V.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:V.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(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Uo(f[0]):null;if(l){let J=async Oe=>{let ut=await We(i,Oe);if(!ut)return Qt(Oe);try{return await ve(i,ut)}catch{return Qt(Oe)}},te=await J(l.left);if(typeof te=="object"&&"exitCode"in te)return te;let ke=await J(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let _e=te,ce=ke;if(l.type==="two-dot")a=[ce],c=[_e];else{a=[_e,ce];let Oe=await qt(i,_e,ce);c=Oe.length>0?Oe:void 0}if(n.all){let Oe=await ge(i);for(let yr of Oe)try{let Ye=await ve(i,yr.hash);a.includes(Ye)||a.push(Ye)}catch{}let ut=await Y(i);ut&&!a.includes(ut)&&a.push(ut)}}else if(n.all){let J=await ge(i),te=new Set;for(let _e of J)try{te.add(await ve(i,_e.hash))}catch{}let ke=await Y(i);ke&&te.add(ke),a=[...te]}else if(f&&f.length>0){let J=[];for(let te of f){let ke=await We(i,te);if(!ke)return Qt(te);try{J.push(await ve(i,ke))}catch{return Qt(te)}}a=J}else{let J=await Qe(i);if(M(J))return J;a=[J]}if(a.length===0)return T("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(J=>Ue(J,"")):null,h=n.author?rd(n.author):null,u=n.grep?rd(n.grep):null,m=n.since??n.after,p=n.until??n.before,g=m?ra(m):null,w=p?ra(p):null,b=n.format??n.pretty,y=null,R=null,x=!1;if(n.oneline)R="oneline",x=!0;else if(b!==void 0){let J=zo(b);y=J.formatStr,R=J.preset}let k=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!k.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 T("options '--graph' and '--reverse' cannot be used together");let P=n.decorate||y!=null&&(y.includes("%d")||y.includes("%D"))?await Og(i):null,I=P?J=>sd(P,J):void 0,D=P?J=>{let te=sd(P,J);return te.startsWith("(")&&te.endsWith(")")?te.slice(1,-1):te}:void 0,G=n.maxCount,A=n.reverse,O=n.firstParent,_=d?$g(i,a,d,c?await Pg(i,c):void 0,O):_t(i,a,{exclude:c,topoOrder:$,firstParent:O}),U=[];for await(let J of _){if(G!==void 0&&U.length>=G)break;let{commit:te}=J;if(!(w!==null&&te.committer.timestamp>w)&&!(g!==null&&te.committer.timestamp<=g)){if(h){let ke=`${te.author.name} <${te.author.email}>`;if(!h(ke))continue}u&&!u(te.message)||U.push(J)}}let F=A?U.reverse():U;if($)return Ig(F,i,y,R,x,C,I,D,E);if(y!==null){let J=[];for(let te of F){let ke={hash:te.hash,commit:te.commit,decorations:I,decorationsRaw:D,dateMode:E},_e=Ps(y,ke),ce=await ka(i,te.commit,C);ce&&(_e+=`
439
438
 
440
- ${ae.replace(/\n$/,"")}`),J.push(Ge)}return{stdout:J.length>0?`${J.join(`
439
+ ${ce.replace(/\n$/,"")}`),J.push(_e)}return{stdout:J.length>0?`${J.join(`
441
440
  `)}
442
- `:"",stderr:"",exitCode:0}}let L=b??"medium",K=L==="oneline",te=[];for(let J=0;J<U.length;J++){let ne=U[J],ke={hash:ne.hash,commit:ne.commit,decorations:T,decorationsRaw:N,dateMode:k},Ge=Ps(L,ke,J===0,y),ae=await ua(i,ne.commit,C);ae&&(Ge+=`${K?`
441
+ `:"",stderr:"",exitCode:0}}let L=R??"medium",W=L==="oneline",ne=[];for(let J=0;J<F.length;J++){let te=F[J],ke={hash:te.hash,commit:te.commit,decorations:I,decorationsRaw:D,dateMode:E},_e=$s(L,ke,J===0,x),ce=await ka(i,te.commit,C);ce&&(_e+=`${W?`
443
442
  `:`
444
443
 
445
- `}${ae.replace(/\n$/,"")}`),te.push(Ge)}return{stdout:te.length>0?`${te.join(`
446
- `)}
447
- `:"",stderr:"",exitCode:0}}})}async function ug(e,t){let n=new Set;for await(let r of Lt(e,t))n.add(r.hash);return n}function Wl(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*mg(e,t,n,r,o){let s=new Set(r),i=new Wn,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 Ve(e,null,f.tree)).some(u=>Ee(n,u.path))&&(yield c);continue}if(l.length===1){let m=l[0];if(m){try{let u=await j(e,m);(await Ve(e,u.tree,f.tree)).some(p=>Ee(n,p.path))&&(yield c)}catch{yield c}await a(m)}continue}let d=[];for(let m of l)try{let u=await j(e,m);(await Ve(e,u.tree,f.tree)).some(p=>Ee(n,p.path))||d.push(m)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let m of l)await a(m)}}}async function hg(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await Y(e),o=new Map,s=(f,l,d)=>{let m=o.get(f);m||(m=[],o.set(f,m)),m.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 ve(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function ql(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 pg(e,t,n,r,o,s,i,a,c){let f=new No,l=r??"medium",d=l==="oneline",m=[];for(let u=0;u<e.length;u++){let h=e[u],p={hash:h.hash,commit:h.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=Cs(n,p):g=Ps(l,p,!0,o),f.update(h.hash,h.commit.parents),u>0&&!d&&n===null&&m.push(f.paddingPrefix());let w=g.split(`
448
- `),R=0;for(;;){let{prefix:y,isCommitLine:E}=f.nextLine();if(E){m.push(y+(w[R++]??""));break}m.push(y)}for(;R<w.length;){let{prefix:y}=f.nextLine();m.push(y+w[R++])}for(;!f.isFinished();){let{prefix:y}=f.nextLine();m.push(y)}let x=80-f.width,b=await ua(t,h.commit,s,x);if(b){let y=b.replace(/\n$/,"").split(`
449
- `);if(d||n!==null)for(let E of y)m.push(f.paddingPrefix()+E);else{m.push(f.paddingPrefix());for(let E of y)m.push(f.paddingPrefix()+E)}}}return{stdout:m.length>0?`${m.join(`
450
- `)}
451
- `:"",stderr:"",exitCode:0}}async function ua(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 Ve(e,o,t.tree),{remaining:i,renames:a}=await it(e,s);switch(n){case"name-only":return gg(i,a);case"name-status":return wg(i,a);case"stat":return bg(e,i,a,r);case"shortstat":return yg(e,i,a);case"numstat":return Eg(e,i,a);case"patch":return kg(e,i,a)}}function gg(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}
452
- `).join("")}function wg(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}
453
- `).join("")}async function bg(e,t,n,r){let{fileStats:o}=await Zn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),ur(o,r)}async function yg(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
454
- `:""}async function Eg(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:un(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(Te(i)||Te(a))o+=`- - ${s.display}
455
- `;else{let c=Rt(i),f=Rt(a),l=ct(c,f),d=0,m=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&m++;o+=`${d} ${m} ${s.display}
456
- `}}return o}async function kg(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+=Tt({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+=Tt({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}ie();Ce();me();nr();tt();function Vl(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:$().alias("c").describe("Show cached files (default)"),modified:$().alias("m").describe("Show modified files"),deleted:$().alias("d").describe("Show deleted files"),others:$().alias("o").describe("Show other (untracked) files"),unmerged:$().alias("u").describe("Show unmerged files"),stage:$().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":$().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":$().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":$().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=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,m=n.others,u=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||m||u||(f=!0);let x=await z(i),b=g?"\0":`
457
- `,y=o.passthrough.length>0?o.passthrough.map(C=>{let P=r.cwd!==c?Rg(c,r.cwd):"";return Ue(C,P)}):null,E=[];if(f)for(let C of x.entries){if(y&&!Ee(y,C.path))continue;let P=w?C.stage>0?"M":"H":null;E.push(Kl(C,h,P))}if(u&&!f)for(let C of x.entries)C.stage!==0&&(y&&!Ee(y,C.path)||E.push(Kl(C,!0,w?"M":null)));if(l||d){let C=await xg(i,c,x);for(let{path:P,status:I}of C){if(I==="modified"&&!l||I==="deleted"&&!d||y&&!Ee(y,P))continue;let v=w?I==="deleted"?"R":"C":null;E.push(v?`${v} ${P}`:P)}}if(m){let C=await Cg(i,c,x,p);for(let P of C)y&&!Ee(y,P)||E.push(w?`? ${P}`:P)}return{stdout:E.length>0?E.join(b)+b:"",stderr:"",exitCode:0}}})}function Kl(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 Rg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function xg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=H(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 Nn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Cg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await ot(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}ie();ar();Be();Ce();ce();ze();we();an();Ae();function Yl(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:$().describe("Abort the current in-progress merge"),continue:$().describe("Continue the merge after conflict resolution"),noFf:$().describe("Create a merge commit even when fast-forward is possible"),ffOnly:$().describe("Refuse to merge unless fast-forward is possible"),squash:$().describe("Apply merge result to worktree/index without creating a merge commit"),edit:$().describe("Edit the merge message (no-op, accepted for compatibility)"),message:V.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 Sg(s,r.env);if(n.continue)return Ig(s,r.env,t);let i=n.branch;if(!i)return O("you must specify a branch to merge");let a=await Qe(s);if(M(a))return a;let c=await z(s),f=Rn(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return O(`You have not concluded your merge (MERGE_HEAD exists).
458
- Please, commit your changes before you merge.`);if(await B(s,"CHERRY_PICK_HEAD"))return O(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
459
- Please, commit your changes before you merge.`);let m=await We(s,i);if(!m)return G(`merge: ${i} - not something we can merge
460
- `);let u=await ve(s,m),h=await Ut(s,a,u),p=h[0]??null;if(h.length===0)return O("refusing to merge unrelated histories");if(p===u)return await be(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
461
- `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let y=await xe(s,"merge.ff");y==="false"?g=!0:y==="only"&&(w=!0)}if(g&&w)return O("--no-ff and --ff-only are incompatible");let R=p===a&&!g;if(w&&!R)return G(`hint: Diverging branches can't be fast-forwarded, you need to either:
444
+ `}${ce.replace(/\n$/,"")}`),ne.push(_e)}return{stdout:ne.length>0?`${ne.join(`
445
+ `)}
446
+ `:"",stderr:"",exitCode:0}}})}async function Pg(e,t){let n=new Set;for await(let r of _t(e,t))n.add(r.hash);return n}function rd(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*$g(e,t,n,r,o){let s=new Set(r),i=new Wn,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 Og(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await Y(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 ve(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function sd(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 Ig(e,t,n,r,o,s,i,a,c){let f=new Wo,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=Ps(n,p):g=$s(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:x,isCommitLine:k}=f.nextLine();if(k){h.push(x+(w[b++]??""));break}h.push(x)}for(;b<w.length;){let{prefix:x}=f.nextLine();h.push(x+w[b++])}for(;!f.isFinished();){let{prefix:x}=f.nextLine();h.push(x)}let y=80-f.width,R=await ka(t,m.commit,s,y);if(R){let x=R.replace(/\n$/,"").split(`
448
+ `);if(d||n!==null)for(let k of x)h.push(f.paddingPrefix()+k);else{h.push(f.paddingPrefix());for(let k of x)h.push(f.paddingPrefix()+k)}}}return{stdout:h.length>0?`${h.join(`
449
+ `)}
450
+ `:"",stderr:"",exitCode:0}}async function ka(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 Sg(i,a);case"name-status":return Tg(i,a);case"stat":return vg(e,i,a,r);case"shortstat":return Hg(e,i,a);case"numstat":return Ag(e,i,a);case"patch":return Dg(e,i,a)}}function Sg(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
+ `).join("")}function Tg(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 vg(e,t,n,r){let{fileStats:o}=await Jn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),hr(o,r)}async function Hg(e,t,n){let{fileStats:r}=await Jn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Zn(r.length,o,s);return i?`${i}
453
+ `:""}async function Ag(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 re(e,s.oldHash):"",a=s.newHash?await re(e,s.newHash):"";if(Te(i)||Te(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 Dg(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();sr();tt();function ad(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 q(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 y=await K(i),R=g?"\0":`
456
+ `,x=o.passthrough.length>0?o.passthrough.map(C=>{let $=r.cwd!==c?Mg(c,r.cwd):"";return Ue(C,$)}):null,k=[];if(f)for(let C of y.entries){if(x&&!Ee(x,C.path))continue;let $=w?C.stage>0?"M":"H":null;k.push(id(C,m,$))}if(u&&!f)for(let C of y.entries)C.stage!==0&&(x&&!Ee(x,C.path)||k.push(id(C,!0,w?"M":null)));if(l||d){let C=await jg(i,c,y);for(let{path:$,status:H}of C){if(H==="modified"&&!l||H==="deleted"&&!d||x&&!Ee(x,$))continue;let P=w?H==="deleted"?"R":"C":null;k.push(P?`${P} ${$}`:$)}}if(h){let C=await Gg(i,c,y,p);for(let $ of C)x&&!Ee(x,$)||k.push(w?`? ${$}`:$)}return{stdout:k.length>0?k.join(R)+R:"",stderr:"",exitCode:0}}})}function id(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 Mg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function jg(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 ht(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await _n(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Gg(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();fr();Be();Ce();ie();ze();we();cn();He();function cd(e,t){e.command("merge",{description:"Join two or more development histories together",args:[z.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:V.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(M(o))return o;let s=o;if(n.abort)return Ug(s,r.env);if(n.continue)return Fg(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 K(s),f=Cn(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).
458
+ Please, commit your changes before you merge.`);let h=await We(s,i);if(!h)return N(`merge: ${i} - not something we can merge
459
+ `);let u=await ve(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 x=await xe(s,"merge.ff");x==="false"?g=!0:x==="only"&&(w=!0)}if(g&&w)return T("--no-ff and --ff-only are incompatible");let b=p===a&&!g;if(w&&!b)return N(`hint: Diverging branches can't be fast-forwarded, you need to either:
462
461
  hint:
463
462
  hint: git merge --no-ff
464
463
  hint:
@@ -468,44 +467,44 @@ hint: git rebase
468
467
  hint:
469
468
  hint: Disable this message with "git config set advice.diverging false"
470
469
  fatal: Not possible to fast-forward, aborting.
471
- `,128);if(await B(s,"REVERT_HEAD")&&await Ot(s),R&&!n.squash){let y=await Q(s),E=await Po(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 k=y?.type==="symbolic"?y.target:"HEAD";await oe(s,r.env,k,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,y?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return E}let x=n.message,b=x?x.endsWith(`
472
- `)?x:`${x}
473
- `:void 0;return n.squash?Og(s,a,u,i,r.env,t,b):Pg(s,a,u,i,r.env,g,t,b)}})}async function Pg(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",m={a:"HEAD",b:r,conflictStyle:d},u=await ws(e,t,n,m),h=await $n(e,u,c.tree,{labels:m,errorExitCode:2,operationName:"merge"});if(!h.ok)return await be(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await oe(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(u.conflicts.length>0){await Z(e,"MERGE_HEAD",n),await Z(e,"ORIG_HEAD",t);let I=a??await mr(e,r,l),v={repo:e,message:I,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},T=await i?.hooks?.mergeMsg?.(v);if(de(T))return{stdout:"",stderr:T.message??"",exitCode:1};I=v.message;let N=Wt({version:2,entries:u.entries}).sort();return I+=`
470
+ `,128);if(await B(s,"REVERT_HEAD")&&await St(s),b&&!n.squash){let x=await Q(s),k=await vo(s,a,u);if(k.exitCode===0&&n.message&&(k.stdout=k.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),k.exitCode===0){await be(s,"MERGE_MSG");let E=x?.type==="symbolic"?x.target:"HEAD";await se(s,r.env,E,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,x?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return k}let y=n.message,R=y?y.endsWith(`
471
+ `)?y:`${y}
472
+ `:void 0;return n.squash?_g(s,a,u,i,r.env,t,R):Lg(s,a,u,i,r.env,g,t,R)}})}async function Lg(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 bs(e,t,n,h),m=await On(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 Z(e,"MERGE_HEAD",n),await Z(e,"ORIG_HEAD",t);let H=a??await mr(e,r,l),P={repo:e,message:H,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},I=await i?.hooks?.mergeMsg?.(P);if(fe(I))return{stdout:"",stderr:I.message??"",exitCode:1};H=P.message;let D=Kt({version:2,entries:u.entries}).sort();return H+=`
474
473
  # Conflicts:
475
- ${N.map(A=>`# ${A}`).join(`
474
+ ${D.map(A=>`# ${A}`).join(`
476
475
  `)}
477
- `,await Me(e,"MERGE_MSG",I),await Me(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
476
+ `,await Ae(e,"MERGE_MSG",H),await Ae(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
478
477
  `)}
479
- `,stderr:"",exitCode:1}}await be(e,"MERGE_MSG");let p=h.mergedTreeHash,g=await dn(e,o);if(M(g))return g;let w=await nt(e,o);if(M(w))return w;let R=a??await mr(e,r,l),x={repo:e,message:R,treeHash:p,headHash:t,theirsHash:n},b=await i?.hooks?.mergeMsg?.(x);if(de(b))return{stdout:"",stderr:b.message??"",exitCode:1};R=x.message;let y=await i?.hooks?.preMergeCommit?.({repo:e,message:R,treeHash:p,headHash:t,theirsHash:n});if(de(y))return{stdout:"",stderr:y.message??"",exitCode:1};let E=await bt(e,p,[t,n],g,w,R),k=f?.type==="symbolic"?f.target:"HEAD";await oe(e,o,k,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 C=await hn(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(M(g))return g;let w=await nt(e,o);if(M(w))return w;let b=a??await mr(e,r,l),y={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},R=await i?.hooks?.mergeMsg?.(y);if(fe(R))return{stdout:"",stderr:R.message??"",exitCode:1};b=y.message;let x=await i?.hooks?.preMergeCommit?.({repo:e,message:b,treeHash:p,headHash:t,theirsHash:n});if(fe(x))return{stdout:"",stderr:x.message??"",exitCode:1};let k=await yt(e,p,[t,n],g,w,b),E=f?.type==="symbolic"?f.target:"HEAD";await se(e,o,E,t,k,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:k});let C=await pn(e,c.tree,p);return{stdout:`${u.messages.length>0?`${u.messages.join(`
480
479
  `)}
481
480
  `:""}Merge made by the 'ort' strategy.
482
- ${C}`,stderr:"",exitCode:0}}async function $g(e,t,n){let r=[];for await(let o of Lt(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: ${Cn(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
481
+ ${C}`,stderr:"",exitCode:0}}async function Ng(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: ${$n(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
483
482
  `))r.push(` ${i}`);r.push("")}return r.join(`
484
- `)}async function Og(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 Ut(e,t,n),m=d.length>0&&d[0]===t,u=m?`Updating ${X(t)}..${X(n)}
485
- `:"",h=await ws(e,t,n,l),p=await $n(e,h,a.tree,{labels:l,errorExitCode:m?1:2,operationName:"merge",skipStagedChangeCheck:m});if(!p.ok){await be(e,"MERGE_MSG"),!m&&p.failureKind==="staged"&&c?.type==="symbolic"&&await oe(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=p;return m&&(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 _g(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 ${X(t)}..${X(n)}
484
+ `:"",m=await bs(e,t,n,l),p=await On(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 k=p;return h&&(k.stderr=k.stderr.replace(/Merge with strategy ort failed\.\n$/,"")),u&&(k.stdout=u+k.stdout),k}let g;if(i?g=`Squashed commit of the following:
486
485
 
487
486
  ${i}`:g=`Squashed commit of the following:
488
487
 
489
- ${await $g(e,t,n)}`,await Me(e,"SQUASH_MSG",g),h.conflicts.length>0){let k=`
488
+ ${await Ng(e,t,n)}`,await Ae(e,"SQUASH_MSG",g),m.conflicts.length>0){let E=`
490
489
  # Conflicts:
491
- ${Wt({version:2,entries:h.entries}).sort().map(I=>`# ${I}`).join(`
490
+ ${Kt({version:2,entries:m.entries}).sort().map(H=>`# ${H}`).join(`
492
491
  `)}
493
- `,C=await $e(e,"MERGE_MSG");return await Me(e,"MERGE_MSG",(C??"")+k),{stdout:`${[...h.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 Ae(e,"MERGE_MSG",(C??"")+E),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
494
493
  `)}
495
- `,stderr:"",exitCode:1}}let w=p.mergedTreeHash,R=await hn(e,a.tree,w),x=h.messages.length>0?`${h.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(`
496
495
  `)}
497
- `:"";return{stdout:`${m?`${u}${i?"Fast-forward (no commit created; -m option ignored)":"Fast-forward"}
498
- `:""}${x}Squash commit -- not updating HEAD
499
- ${m?R:""}`,stderr:m?"":`Automatic merge went well; stopped before committing as requested
500
- `,exitCode:0}}async function Ig(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return O("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=Rn(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=$t(c);else{let C=await Q(e),P=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await mr(e,"unknown",P)}let f=Ne(o),l=await Fe(e,f),d=await dn(e,t);if(M(d))return d;let m=await nt(e,t);if(M(m))return m;let u=Gt(c),h={repo:e,message:u,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(de(p))return{stdout:"",stderr:p.message??"",exitCode:1};u=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:u,treeHash:l,headHash:i,theirsHash:r});if(de(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await bt(e,l,[i,r],d,m,u);await fs(e);let R=await Q(e),x=ue(u),b=R?.type==="symbolic"?R.target:"HEAD";await oe(e,t,b,i,w,`commit (merge): ${x}`,R?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let y=await hn(e,a.tree,l),E=R?.type==="symbolic"?Pe(R.target):"detached HEAD";return{stdout:`${jt(E,w,c)}
501
- ${y}`,stderr:"",exitCode:0}}async function Sg(e,t){return Bn(e,t,{operationRef:"MERGE_HEAD",noOpError:O("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:fs})}ie();Ce();me();tt();function Xl(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:$().alias("f").describe("Force renaming even if target exists"),"dry-run":$().alias("n").describe("Do nothing; only show what would happen"),skip:$().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=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return G(`usage: git mv [<options>] <source>... <destination>
502
- `);let f=c[c.length-1],l=c.slice(0,-1),d=Ht(r.cwd,f),m=st(a,d);if(m.startsWith(".."))return O(`'${f}' is outside repository at '${a}'`);let u=await z(s),h=await r.fs.exists(d),p=h&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return O(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let R=Ht(r.cwd,w),x=st(a,R);if(x.startsWith("..")){if(n.skip)continue;return O(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(R)){if(n.skip)continue;return O(`bad source, source=${x}, destination=${m}`)}let E=(await r.fs.stat(R)).isDirectory;if(!(E?u.entries.some(T=>T.path===x||T.path.startsWith(`${x}/`)):u.entries.some(T=>T.path===x&&T.stage===0))){let T=!E&&u.entries.some(N=>N.path===x&&N.stage>0);if(n.skip)continue;return O(T?`conflicted, source=${x}, destination=${m}`:`not under version control, source=${x}, destination=${m}`)}let C,P;if(p){let T=Br(x);C=m===""||m==="."?T:`${m}/${T}`,P=H(d,T)}else C=m,P=d;if(await r.fs.exists(P)&&!n.force)if((await r.fs.stat(P)).isDirectory){let N=Br(x);C=`${C}/${N}`,P=H(P,N)}else{if(n.skip)continue;return O(`destination exists, source=${x}, destination=${C}`)}if(x===C){if(n.skip)continue;return O(`can not move directory into itself, source=${x}, destination=${C}`)}let v=tn(P);if(!await r.fs.exists(v)){if(n.skip)continue;return O(`renaming '${x}' failed: No such file or directory`)}if(E){let T=`${x}/`,N=u.entries.filter(S=>S.path.startsWith(T)&&S.stage===0);for(let S of N){let A=S.path.slice(x.length),D=C+A,_=P+A;g.push({srcRel:S.path,dstRel:D,srcAbs:H(a,S.path),dstAbs:_})}}else g.push({srcRel:x,dstRel:C,srcAbs:R,dstAbs:P})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let R=tn(w.dstAbs);await r.fs.exists(R)||await r.fs.mkdir(R,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=Ls(u,w.srcRel,0);if(b){u=lt(u,w.srcRel);let y={...b,path:w.dstRel};u=Ct(u,y)}}for(let w of g)await sr(r.fs,tn(w.srcAbs),a);return await fe(s,u),{stdout:"",stderr:"",exitCode:0}}})}ie();Be();Tn();Ce();ce();me();ht();ze();we();ie();Be();Ce();ce();ie();ce();wn();er();Ae();async function ma(e,t){let n=await ye(e,t);if(n.type!=="commit")return null;let r=sn(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ye(e,r.parents[0]);f.type==="commit"&&(o=sn(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)=>Ie(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 m=Tt({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(m)for(let u of m.split(`
496
+ `:"";return{stdout:`${h?`${u}${i?"Fast-forward (no commit created; -m option ignored)":"Fast-forward"}
497
+ `:""}${y}Squash commit -- not updating HEAD
498
+ ${h?b:""}`,stderr:h?"":`Automatic merge went well; stopped before committing as requested
499
+ `,exitCode:0}}async function Fg(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 K(e),s=Cn(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 C=await Q(e),$=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await mr(e,"unknown",$)}let f=Le(o),l=await Fe(e,f),d=await un(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 ls(e);let b=await Q(e),y=ue(u),R=b?.type==="symbolic"?b.target:"HEAD";await se(e,t,R,i,w,`commit (merge): ${y}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let x=await pn(e,a.tree,l),k=b?.type==="symbolic"?Pe(b.target):"detached HEAD";return{stdout:`${Lt(k,w,c)}
500
+ ${x}`,stderr:"",exitCode:0}}async function Ug(e,t){return Bn(e,t,{operationRef:"MERGE_HEAD",noOpError:T("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:ls})}oe();Ce();pe();tt();function fd(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[z.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 q(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 N(`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 K(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),y=rt(a,b);if(y.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=${y}, destination=${h}`)}let k=(await r.fs.stat(b)).isDirectory;if(!(k?u.entries.some(I=>I.path===y||I.path.startsWith(`${y}/`)):u.entries.some(I=>I.path===y&&I.stage===0))){let I=!k&&u.entries.some(D=>D.path===y&&D.stage>0);if(n.skip)continue;return T(I?`conflicted, source=${y}, destination=${h}`:`not under version control, source=${y}, destination=${h}`)}let C,$;if(p){let I=qr(y);C=h===""||h==="."?I:`${h}/${I}`,$=v(d,I)}else C=h,$=d;if(await r.fs.exists($)&&!n.force)if((await r.fs.stat($)).isDirectory){let D=qr(y);C=`${C}/${D}`,$=v($,D)}else{if(n.skip)continue;return T(`destination exists, source=${y}, destination=${C}`)}if(y===C){if(n.skip)continue;return T(`can not move directory into itself, source=${y}, destination=${C}`)}let P=nn($);if(!await r.fs.exists(P)){if(n.skip)continue;return T(`renaming '${y}' failed: No such file or directory`)}if(k){let I=`${y}/`,D=u.entries.filter(G=>G.path.startsWith(I)&&G.stage===0);for(let G of D){let A=G.path.slice(y.length),O=C+A,_=$+A;g.push({srcRel:G.path,dstRel:O,srcAbs:v(a,G.path),dstAbs:_})}}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=nn(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 R=Fs(u,w.srcRel,0);if(R){u=ft(u,w.srcRel);let x={...R,path:w.dstRel};u=Pt(u,x)}}for(let w of g)await ir(r.fs,nn(w.srcAbs),a);return await ae(s,u),{stdout:"",stderr:"",exitCode:0}}})}oe();Be();Tn();Ce();ie();pe();pt();ze();we();oe();Be();Ce();ie();oe();ie();wn();nr();He();async function Ra(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 Ke(e,o,r.tree);if(s.length===0)return null;let i=Hn(),a=!1,c=[...s].sort((f,l)=>Ie(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(`
503
502
  `)){if(!u||u.startsWith("index "))continue;let p=(u.startsWith("@@")?u.replace(/^@@ [^@]* @@/,"@@ @@"):u).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
504
- `),a=!0)}}return a?i.hex():null}ze();we();Ae();Xt();tt();async function Tg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function Zl(e){return e==="HEAD"?`HEAD is up to date.
503
+ `),a=!0)}}return a?i.hex():null}ze();we();He();Jt();tt();async function Bg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function ld(e){return e==="HEAD"?`HEAD is up to date.
505
504
  `:`Current branch ${e} is up to date.
506
- `}async function vg(e,t,n){if(!e.workTree)return null;let r=await le(e,t),o=new Map(Ne(n).map(a=>[a.path,a])),s=new Set(await ot(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=to(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return G(`${a.stderr}error: could not detach HEAD
507
- `)}return null}async function Ag(e,t,n,r){if(!e.workTree)return null;let o=await le(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await ot(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:`${to(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
508
- `,exitCode:128}:null}async function Jl(e,t,n){if(!e.workTree)return null;let r=new Map(Ne(t).map(i=>[i.path,i])),o=new Set(await ot(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 Ql(e,t){return`error: The following untracked working tree files would be overwritten by merge:
505
+ `}async function Wg(e,t,n){if(!e.workTree)return null;let r=await de(e,t),o=new Map(Le(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=io(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return N(`${a.stderr}error: could not detach HEAD
506
+ `)}return null}async function qg(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:`${io(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
507
+ `,exitCode:128}:null}async function dd(e,t,n){if(!e.workTree)return null;let r=new Map(Le(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 ud(e,t){return`error: The following untracked working tree files would be overwritten by merge:
509
508
  ${e.map(r=>` ${r}`).join(`
510
509
  `)}
511
510
  Please move or remove them before you merge.
@@ -519,20 +518,20 @@ hint: edit the todo list first:
519
518
  hint:
520
519
  hint: git rebase --edit-todo
521
520
  hint: git rebase --continue
522
- `}async function ha(e,t,n,r,o,s){await oe(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await oe(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await oe(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Bo(e,t,n,r){let o=await j(e,t),s=await vg(e,o.tree,n);if(s)return s;let i=await kn(e,o.tree,n);return i.success&&(await fe(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps)),r!=="detached HEAD"?await Z(e,r,t):await Z(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=Wt(l).sort();if(d.length>0)return{stdout:d.map(v=>`${v}: needs merge
521
+ `}async function xa(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 Vo(e,t,n,r){let o=await j(e,t),s=await Wg(e,o.tree,n);if(s)return s;let i=await xn(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps)),r!=="detached HEAD"?await Z(e,r,t):await Z(e,"HEAD",t),null}async function Ca(e,t,n,r,o,s,i,a,c){let f=r.startsWith("refs/heads/")?Pe(r):"HEAD",l=await K(e),d=Kt(l).sort();if(d.length>0)return{stdout:d.map(P=>`${P}: needs merge
523
522
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
524
523
  error: additionally, your index contains uncommitted changes.
525
524
  error: Please commit or stash them.
526
- `,exitCode:1};let m=await j(e,n),u=await le(e,m.tree);if(e.workTree){let v=Un(l,u),N=(await gt(e,l)).some(S=>S.status==="modified"||S.status==="deleted");if(v||N){let S=[];return N&&S.push("error: cannot rebase: You have unstaged changes."),v&&(N?S.push("error: additionally, your index contains uncommitted changes."):S.push("error: cannot rebase: Your index contains uncommitted changes.")),S.push("error: Please commit or stash them."),G(`${S.join(`
525
+ `,exitCode:1};let h=await j(e,n),u=await de(e,h.tree);if(e.workTree){let P=Un(l,u),D=(await wt(e,l)).some(G=>G.status==="modified"||G.status==="deleted");if(P||D){let G=[];return D&&G.push("error: cannot rebase: You have unstaged changes."),P&&(D?G.push("error: additionally, your index contains uncommitted changes."):G.push("error: cannot rebase: Your index contains uncommitted changes.")),G.push("error: Please commit or stash them."),N(`${G.join(`
527
526
  `)}
528
- `)}}let h=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?f:null});if(de(h))return{stdout:"",stderr:h.message??"",exitCode:1};let p=await ff(e,o,n),g=p.right;if(g.length===0){if(s!==n){let v=await Bo(e,s,l,r);return v||(await ha(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
529
- `,exitCode:0})}return{stdout:Zl(f),stderr:"",exitCode:0}}let w=[],R=[];if(c?.reapplyCherryPicks)R.push(...g);else{let v=p.left,T=new Set;for(let N of v){let S=await ma(e,N.hash);S&&T.add(S)}if(T.size>0)for(let N of g){let S=await ma(e,N.hash);S&&T.has(S)?w.push(`warning: skipped previously applied commit ${X(N.hash)}`):R.push(N)}else R.push(...g)}let x="";if(w.length>0&&(x=`${w.join(`
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 Rf(e,o,n),g=p.right;if(g.length===0){if(s!==n){let P=await Vo(e,s,l,r);return P||(await xa(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
528
+ `,exitCode:0})}return{stdout:ld(f),stderr:"",exitCode:0}}let w=[],b=[];if(c?.reapplyCherryPicks)b.push(...g);else{let P=p.left,I=new Set;for(let D of P){let G=await Ra(e,D.hash);G&&I.add(G)}if(I.size>0)for(let D of g){let G=await Ra(e,D.hash);G&&I.has(G)?w.push(`warning: skipped previously applied commit ${X(D.hash)}`):b.push(D)}else b.push(...g)}let y="";if(w.length>0&&(y=`${w.join(`
530
529
  `)}
531
530
  hint: use --reapply-cherry-picks to include skipped commits
532
531
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
533
- `),R.length===0){if(s!==n){let v=await Bo(e,s,l,r);if(v)return v.stderr=x+v.stderr,v;await ha(e,t,n,s,r,i)}return{stdout:"",stderr:`${x}Successfully rebased and updated ${r}.
534
- `,exitCode:0}}let b=R.map(v=>({hash:v.hash,subject:ue(v.commit.message)})),y=s,E=0;for(let v of b){let T=await j(e,v.hash);if(T.parents.length>1||T.parents.length===0||T.parents[0]!==y)break;y=v.hash,E++}let k=b.splice(0,E);if(b.length===0){if(y===n)return{stdout:Zl(f),stderr:x,exitCode:0};let v=await Bo(e,y,l,r);return v?(v.stderr=x+v.stderr,v):(await ha(e,t,n,y,r,i),{stdout:"",stderr:`${x}Successfully rebased and updated ${r}.
535
- `,exitCode:0})}let C=await Bo(e,y,l,"detached HEAD");if(C)return C.stderr=x+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 oe(e,t,"HEAD",n,y,`rebase (start): checkout ${i}`);let P={headName:r,origHead:n,onto:s,todo:b,done:k,msgnum:E,end:E+b.length};await Gi(e,P),await Z(e,"ORIG_HEAD",n);let I=await ga(e,t);return x&&(I.stderr=x+I.stderr),I}function ed(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:V.string().describe("Starting point at which to create new commits"),abort:$().describe("Abort the current rebase operation"),continue:$().describe("Continue the rebase after conflict resolution"),skip:$().describe("Skip the current patch and continue"),"reapply-cherry-picks":$().describe("Do not skip commits that are cherry-pick equivalents"),"no-reapply-cherry-picks":$().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 Mg(s,r.env);if(n.continue)return jg(s,r.env);if(n.skip)return Gg(s,r.env);let i=n.upstream;if(!i)return O("no upstream configured and no upstream argument given");if(await _t(s))return O(`It seems that there is already a rebase-merge directory, and
532
+ `),b.length===0){if(s!==n){let P=await Vo(e,s,l,r);if(P)return P.stderr=y+P.stderr,P;await xa(e,t,n,s,r,i)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
533
+ `,exitCode:0}}let R=b.map(P=>({hash:P.hash,subject:ue(P.commit.message)})),x=s,k=0;for(let P of R){let I=await j(e,P.hash);if(I.parents.length>1||I.parents.length===0||I.parents[0]!==x)break;x=P.hash,k++}let E=R.splice(0,k);if(R.length===0){if(x===n)return{stdout:ld(f),stderr:y,exitCode:0};let P=await Vo(e,x,l,r);return P?(P.stderr=y+P.stderr,P):(await xa(e,t,n,x,r,i),{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
534
+ `,exitCode:0})}let C=await Vo(e,x,l,"detached HEAD");if(C)return C.stderr=y+C.stderr,C;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,x,`rebase (start): checkout ${i}`);let $={headName:r,origHead:n,onto:s,todo:R,done:E,msgnum:k,end:k+R.length};await zi(e,$),await Z(e,"ORIG_HEAD",n);let H=await Pa(e,t);return y&&(H.stderr=y+H.stderr),H}function hd(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[z.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:V.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 q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Vg(s,r.env);if(n.continue)return Yg(s,r.env);if(n.skip)return Xg(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
536
535
  I wonder if you are in the middle of another rebase. If that is the
537
536
  case, please try
538
537
  git rebase (--continue | --abort | --skip)
@@ -540,10 +539,10 @@ If that is not the case, please
540
539
  rm -fr ".git/rebase-merge"
541
540
  and run me again. I am stopping in case you still have something
542
541
  valuable there.
543
- `);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 je(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,m,u=n.onto;if(u){let p=await je(s,u,`Does not point to a valid commit: '${u}'`);if(M(p))return p;m=p.hash}else m=d;let h=!!n["reapply-cherry-picks"];return pa(s,r.env,a,f,d,m,i,t,h?{reapplyCherryPicks:!0}:void 0)}})}async function ga(e,t){let n=[],r=[];for(;;){let o=await Et(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 cf(e);let i=await Hg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await Et(e);a&&(a.todo=[s,...a.todo],await Gi(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 Dg(e,n,t)}async function Hg(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 Y(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
544
- `};if(s&&s===a){let S=await z(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
545
- `};let A=await Ke(e,i.tree),D=await Ke(e,o.tree),_=new Map(A.map(K=>[K.path,K.hash])),F=new Map;for(let K of D){let te=_.get(K.path);(!te||te!==K.hash)&&F.set(K.path,K.hash)}let U=await Jl(e,S,F);if(U)return await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),{conflict:!0,stdout:"",stderr:Ql(U,t),rescheduleCurrent:!0};let L=await kn(e,o.tree,S);return L.success&&(await fe(e,{version:2,entries:L.newEntries}),await De(e,L.worktreeOps)),await jn(e,r),await oe(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=X(r),d=ue(o.message),m=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:m},h=await Bt(e,f,c.tree,o.tree,u),p=await z(e),[g,w,R]=await Promise.all([Ke(e,c.tree),f?Ke(e,f):Promise.resolve([]),Ke(e,o.tree)]),x=new Set;for(let S of w)x.add(S.path);for(let S of g)x.add(S.path);for(let S of R)x.add(S.path);let b=p.entries.filter(S=>!x.has(S.path)),y=[...h.entries,...b];y.sort((S,A)=>Ie(S.path,A.path)||S.stage-A.stage);let E={version:2,entries:y},k=y.filter(S=>S.stage===0),C=await Fe(e,k),P=new Map(g.map(S=>[S.path,S])),I=new Map;for(let S of k){let A=P.get(S.path);(!A||A.hash!==S.hash)&&I.set(S.path,S.hash)}for(let S of h.conflicts){if(S.reason==="content"||S.reason==="add-add"){I.set(S.path,null);continue}if(S.reason==="delete-modify"){let A=h.entries.filter(F=>F.path===S.path&&F.stage>0),D=A.find(F=>F.stage===2),_=A.find(F=>F.stage===3);_&&!D&&I.set(S.path,_.hash)}}let v=await Jl(e,p,I);if(v)return await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),{conflict:!0,stdout:"",stderr:Ql(v,t),rescheduleCurrent:!0};if(await fe(e,E),e.workTree){let S=await Fn(e,c.tree,h.resultTree,p);S.success&&await De(e,S.worktreeOps)}if(h.conflicts.length>0){await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),await Me(e,"MERGE_MSG",o.message),await Me(e,"rebase-merge/message",o.message);let S=h.messages.join(`
546
- `);return{conflict:!0,stdout:S?`${S}
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 Ge(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,h,u=n.onto;if(u){let p=await Ge(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 Ca(s,r.env,a,f,d,h,i,t,m?{reapplyCherryPicks:!0}:void 0)}})}async function Pa(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 kf(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 Kg(e,n,t)}async function zg(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 Y(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
543
+ `};if(s&&s===a){let G=await K(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
544
+ `};let A=await qe(e,i.tree),O=await qe(e,o.tree),_=new Map(A.map(W=>[W.path,W.hash])),U=new Map;for(let W of O){let ne=_.get(W.path);(!ne||ne!==W.hash)&&U.set(W.path,W.hash)}let F=await dd(e,G,U);if(F)return await Z(e,"REBASE_HEAD",r),await go(e,r,o.author),{conflict:!0,stdout:"",stderr:ud(F,t),rescheduleCurrent:!0};let L=await xn(e,o.tree,G);return L.success&&(await ae(e,{version:2,entries:L.newEntries}),await Me(e,L.worktreeOps)),await Gn(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=X(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 K(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 G of w)y.add(G.path);for(let G of g)y.add(G.path);for(let G of b)y.add(G.path);let R=p.entries.filter(G=>!y.has(G.path)),x=[...m.entries,...R];x.sort((G,A)=>Ie(G.path,A.path)||G.stage-A.stage);let k={version:2,entries:x},E=x.filter(G=>G.stage===0),C=await Fe(e,E),$=new Map(g.map(G=>[G.path,G])),H=new Map;for(let G of E){let A=$.get(G.path);(!A||A.hash!==G.hash)&&H.set(G.path,G.hash)}for(let G of m.conflicts){if(G.reason==="content"||G.reason==="add-add"){H.set(G.path,null);continue}if(G.reason==="delete-modify"){let A=m.entries.filter(U=>U.path===G.path&&U.stage>0),O=A.find(U=>U.stage===2),_=A.find(U=>U.stage===3);_&&!O&&H.set(G.path,_.hash)}}let P=await dd(e,p,H);if(P)return await Z(e,"REBASE_HEAD",r),await go(e,r,o.author),{conflict:!0,stdout:"",stderr:ud(P,t),rescheduleCurrent:!0};if(await ae(e,k),e.workTree){let G=await Fn(e,c.tree,m.resultTree,p);G.success&&await Me(e,G.worktreeOps)}if(m.conflicts.length>0){await Z(e,"REBASE_HEAD",r),await go(e,r,o.author),await Ae(e,"MERGE_MSG",o.message),await Ae(e,"rebase-merge/message",o.message);let G=m.messages.join(`
545
+ `);return{conflict:!0,stdout:G?`${G}
547
546
  `:"",stderr:`error: could not apply ${l}... ${t.subject}
548
547
  hint: Resolve all conflicts manually, mark them as resolved with
549
548
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
@@ -552,12 +551,12 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
552
551
  hint: Disable this message with "git config set advice.mergeConflict false"
553
552
  Could not apply ${l}... # ${t.subject}
554
553
  `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
555
- `};let T=await nt(e,n);if(M(T))return{conflict:!0,stdout:"",stderr:T.stderr};let N=await bt(e,C,[a],o.author,T,o.message);return await oe(e,n,"HEAD",a,N,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Dg(e,t,n){let r=await Et(e);if(!r)return O("no rebase in progress");let o=await Y(e);if(!o)return O("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Z(e,r.headName,o),await Xe(e,"HEAD",r.headName),await yt(e),await oe(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await oe(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
556
- `;return await he(e,"REBASE_HEAD"),await cr(e),await Li(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Mg(e,t){let n=await Et(e);if(!n)return O("no rebase in progress");let r=await Y(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await Ag(e,s.tree,i,o);if(a)return a;let c=await kn(e,s.tree,i);c.success&&(await fe(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Z(e,n.headName,o),await Xe(e,"HEAD",n.headName),await yt(e)):await jn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await oe(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await he(e,"REBASE_HEAD"),await cr(e),await Li(e),{stdout:"",stderr:"",exitCode:0}}async function jg(e,t){let n="";if(!await Et(e))return O("no rebase in progress");let o=await z(e);if(Mt(o))return G(`error: Committing is not possible because you have unmerged files.
554
+ `};let I=await nt(e,n);if(M(I))return{conflict:!0,stdout:"",stderr:I.stderr};let D=await yt(e,C,[a],o.author,I,o.message);return await se(e,n,"HEAD",a,D,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Kg(e,t,n){let r=await kt(e);if(!r)return T("no rebase in progress");let o=await Y(e);if(!o)return T("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Z(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 lr(e),await Ki(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Vg(e,t){let n=await kt(e);if(!n)return T("no rebase in progress");let r=await Y(e),o=n.origHead,s=await j(e,o),i=await K(e),a=await qg(e,s.tree,i,o);if(a)return a;let c=await xn(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await Me(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Z(e,n.headName,o),await Ze(e,"HEAD",n.headName),await Et(e)):await Gn(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 lr(e),await Ki(e),{stdout:"",stderr:"",exitCode:0}}async function Yg(e,t){let n="";if(!await kt(e))return T("no rebase in progress");let o=await K(e);if(Gt(o))return N(`error: Committing is not possible because you have unmerged files.
557
556
  hint: Fix them up in the work tree, and then use 'git add <file>'
558
557
  hint: as appropriate to mark resolution and make a commit.
559
558
  fatal: Exiting because of an unresolved conflict.
560
- `,128);let s=await B(e,"REBASE_HEAD");if(s){let a=await Y(e);if(!a)return O("Cannot read HEAD");let c=await j(e,a),f=Ne(o),l=await Fe(e,f),d=l!==c.tree,m=await $e(e,"rebase-merge/message")!==null;if(d&&!m)return G(`error: you have staged changes in your working tree
559
+ `,128);let s=await B(e,"REBASE_HEAD");if(s){let a=await Y(e);if(!a)return T("Cannot read HEAD");let c=await j(e,a),f=Le(o),l=await Fe(e,f),d=l!==c.tree,h=await $e(e,"rebase-merge/message")!==null;if(d&&!h)return N(`error: you have staged changes in your working tree
561
560
  If these changes are meant to be squashed into the previous commit, run:
562
561
 
563
562
  git commit --amend
@@ -570,90 +569,183 @@ In both cases, once you're done, continue with:
570
569
 
571
570
  git rebase --continue
572
571
 
573
- `);if(d){let u=await j(e,s),h=await B(e,"CHERRY_PICK_HEAD"),p=h?await j(e,h):u,g;g=await $e(e,"rebase-merge/message")??await $e(e,"MERGE_MSG")??void 0,g&&(g=$t(g)),g||(g=u.message);let w=await nt(e,t);if(M(w))return w;let R=Gt(g),x=[a],b=await B(e,"MERGE_HEAD");b&&x.push(b);let y=await bt(e,l,x,p.author,w,R);b&&(await he(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let E=ue(R);await oe(e,t,"HEAD",a,y,`rebase (continue): ${E}`);let k=await Tg(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,P=await mn(e,c.tree,l,p.author,w,C);n=`${jt(k,y,R)}
574
- ${P}`}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 ga(e,t);return n&&(i.stdout=n+i.stdout),i}async function Gg(e,t){if(!await Et(e))return O("no rebase in progress");let r=await Y(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
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),y=[a],R=await B(e,"MERGE_HEAD");R&&y.push(R);let x=await yt(e,l,y,p.author,w,b);R&&(await me(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let k=ue(b);await se(e,t,"HEAD",a,x,`rebase (continue): ${k}`);let E=await Bg(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,x,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 Pa(e,t);return n&&(i.stdout=n+i.stdout),i}async function Xg(e,t){if(!await kt(e))return T("no rebase in progress");let r=await Y(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
575
574
  fatal: could not discard worktree changes
576
- `,exitCode:128};let o=await j(e,r),s=await z(e),i=await kn(e,o.tree,s);return i.success&&(await fe(e,{version:2,entries:i.newEntries}),await De(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"),ga(e,t)}function td(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:$().alias("r").describe("Rebase instead of merge"),noRebase:$().describe("Merge instead of rebase"),ffOnly:$().describe("Only fast-forward"),noFf:$().describe("Create a merge commit even for fast-forwards"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().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 O("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Oo(s))return O("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=bs);let a=await Qe(s);if(M(a))return a;let c=await z(s);if(Mt(c))return G(`error: Pulling is not possible because you have unmerged files.
577
- `,128);let f=n.remote,l=n.branch;if(!f){let re=await Q(s);if(re?.type==="symbolic"){let Le=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,en=(await pe(s))[`branch "${Le}"`];en&&(f=en.remote||"origin",!l&&en.merge&&(l=en.merge.startsWith("refs/heads/")?en.merge.slice(11):en.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let re=await Q(s);if(re?.type==="symbolic"){let Le=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,gn=await xe(s,`branch.${Le}.rebase`);(gn==="true"||gn!=="false"&&await xe(s,"pull.rebase")==="true")&&(d=!0)}else await xe(s,"pull.rebase")==="true"&&(d=!0)}let m;try{m=await Lr(s,f,r.env)}catch(re){let Le=re instanceof Error?re.message:"";if(Le.startsWith("network"))return O(Le);throw re}if(!m)return O(`'${f}' does not appear to be a git repository`);let{transport:u,config:h}=m,p=l??null,g=await t?.hooks?.prePull?.({repo:s,remote:f,branch:p});if(de(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=wr(h.fetchRefspec),R=await u.advertiseRefs();if(R.length===0)return O("Couldn't find remote ref HEAD");let b=(await ge(s)).map(re=>re.hash),y=await B(s,"HEAD");y&&b.push(y);let E=[],k=new Set,C=[];for(let re of R){if(re.name==="HEAD")continue;let Le=xs(w,re.name);Le!==null&&(C.push({remote:re,localRef:Le}),k.has(re.hash)||(k.add(re.hash),E.push(re.hash)))}let P=new Set(b),I=E.filter(re=>!P.has(re)),v,T=i!==void 0?await Hr(s):void 0;i!==void 0&&(v={depth:i,existingShallows:T});let N=I.length>0?I:v?E:[];if(N.length>0){let re=await u.fetch(N,b,v);re.shallowUpdates&&await Dr(s,re.shallowUpdates,T)}let S=await nn(s,r.env);for(let re of C){let Le=await B(s,re.localRef);await Z(s,re.localRef,re.remote.hash),await Ze(s,re.localRef,{oldHash:Le??ee,newHash:re.remote.hash,name:S.name,email:S.email,timestamp:S.timestamp,tz:S.tz,message:Le?"pull":"pull: storing head"})}let A=null;if(l){let re=R.find(Le=>Le.name===`refs/heads/${l}`);if(re)A=re.hash;else return O(`Couldn't find remote ref refs/heads/${l}`)}else{let re=R.find(Le=>Le.name==="HEAD");re&&(A=re.hash)}if(A&&await r.fs.writeFile(H(s.gitDir,"FETCH_HEAD"),`${A} ${h.url}
578
- `),!A)return O("Could not determine remote HEAD");let D=A;if(a===D)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
579
- `,stderr:"",exitCode:0};if(d){let re=await Q(s),Le=re?.type==="symbolic"?re.target:"detached HEAD",gn=l?`${f}/${l}`:f,en=await pa(s,r.env,a,Le,D,D,gn,t);if(en.exitCode===0){let vd=await Y(s);await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:vd})}return en}let _=await Ut(s,a,D),F=_[0]??null;if(_.length===0)return O("refusing to merge unrelated histories");if(F===D)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
580
- `,stderr:"",exitCode:0};let U=!!n.noFf,L=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let re=await xe(s,"pull.ff");re==="false"?U=!0:re==="only"&&(L=!0)}let K=F===a;if(L&&!K)return O("Not possible to fast-forward, aborting.");if(K&&!U){let re=await Po(s,a,D),Le=await Q(s),gn=Le?.type==="symbolic"?Le.target:"HEAD";return await Ze(s,gn,{oldHash:a,newHash:D,name:S.name,email:S.email,timestamp:S.timestamp,tz:S.tz,message:"pull: Fast-forward"}),Le?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:D,name:S.name,email:S.email,timestamp:S.timestamp,tz:S.tz,message:"pull: Fast-forward"}),re.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:D,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:D})),re}let te=await Q(s),J=te?.type==="symbolic"?Pe(te.target):"HEAD",ne=l||f||"FETCH_HEAD",ke=await xe(s,"merge.conflictstyle")??"merge",Ge={a:"HEAD",b:ne,conflictStyle:ke},ae=await ws(s,a,D,Ge),Oe=await j(s,a),rt=await $n(s,ae,Oe.tree,{labels:Ge,errorExitCode:2,operationName:"merge"});if(!rt.ok)return rt;if(ae.conflicts.length>0){await Z(s,"MERGE_HEAD",D),await Z(s,"ORIG_HEAD",a);let re=await mr(s,ne,J),Le=Wt({version:2,entries:ae.entries}).sort();return re+=`
575
+ `,exitCode:128};let o=await j(e,r),s=await K(e),i=await xn(e,o.tree,s);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await Me(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"),Pa(e,t)}function md(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[z.string().name("remote").describe("Remote to pull from").optional(),z.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:V.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 q(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 Ao(s))return T("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=ys);let a=await Qe(s);if(M(a))return a;let c=await Q(s),f=await K(s);if(Gt(f))return{stdout:"",stderr:`error: Pulling is not possible because you have unmerged files.
576
+ hint: Fix them up in the work tree, and then use 'git add/rm <file>'
577
+ hint: as appropriate to mark resolution and make a commit.
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,mt=(await he(s))[`branch "${le}"`];mt?(l=mt.remote||"origin",!d&&mt.merge&&(d=mt.merge.startsWith("refs/heads/")?mt.merge.slice(11):mt.merge)):d||(h=le)}l=l||"origin";let u=await Zg(s,n,c),m;try{m=await _r(s,l,r.env)}catch(le){let je=le instanceof Error?le.message:"";if(je.startsWith("network"))return{stdout:"",stderr:`fatal: ${je}
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 y=br(g.fetchRefspec),R=await p.advertiseRefs(),k=(await ge(s)).map(le=>le.hash),E=await B(s,"HEAD");E&&k.push(E);let C=[],$=new Set,H=[];for(let le of R){if(le.name==="HEAD")continue;let je=Cs(y,le.name);je!==null&&(H.push({remote:le,localRef:je}),$.has(le.hash)||($.add(le.hash),C.push(le.hash)))}let P=new Set(k),I=C.filter(le=>!P.has(le)),D,G=i!==void 0?await Mr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:G});let A=I.length>0?I:D?C:[];if(A.length>0){let le=await p.fetch(A,k,D);le.shallowUpdates&&await jr(s,le.shallowUpdates,G)}let O=await rn(s,r.env),_=[];for(let le of H){let je=await B(s,le.localRef);_.push(je),await Z(s,le.localRef,le.remote.hash),await Je(s,le.localRef,{oldHash:je??ee,newHash:le.remote.hash,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:je?"pull":"pull: storing head"})}let U=ao(H.map((le,je)=>({...le,oldHash:_[je]})),jn,X),F=U.length>0?`From ${g.url}
582
+ ${Sr(U,10)}`:"";if(await Ys(s,l,R,p.headTarget),c?.type!=="symbolic"&&!d)return{stdout:"",stderr:F+`You are not currently on a branch.
583
+ Please specify which branch you want to merge with.
584
+ See git-pull(1) for details.
585
+
586
+ git pull <remote> <branch>
587
+
588
+ `,exitCode:1};if(h){let le=await he(s),je=[];for(let ni of Object.keys(le)){let Na=ni.match(/^remote "(.+)"$/);Na?.[1]&&je.push(Na[1])}let mt=je.length===1?je[0]:"<remote>";return{stdout:"",stderr:F+`There is no tracking information for the current branch.
589
+ Please specify which branch you want to merge with.
590
+ See git-pull(1) for details.
591
+
592
+ git pull <remote> <branch>
593
+
594
+ If you wish to set tracking information for this branch you can do so with:
595
+
596
+ git branch --set-upstream-to=${mt}/<branch> ${h}
597
+
598
+ `,exitCode:1}}let L=null;if(d){let le=R.find(je=>je.name===`refs/heads/${d}`);if(le)L=le.hash;else return{stdout:"",stderr:F+`Your configuration specifies to merge with the ref 'refs/heads/${d}'
599
+ from the remote, but no such ref was fetched.
600
+ `,exitCode:1}}else{let le=R.find(je=>je.name==="HEAD");le&&(L=le.hash)}if(L&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${L} ${g.url}
601
+ `),!L)return T("Could not determine remote HEAD");let W=L;if(await be(s,"MERGE_MSG"),a===W)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",je=d?`${l}/${d}`:l,mt=await Ca(s,r.env,a,le,W,W,je,t);if(mt.exitCode===0){let ni=await Y(s);await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"rebase",commitHash:ni})}return{...mt,stderr:F+mt.stderr}}let ne=await qt(s,a,W),J=ne[0]??null;if(J===W)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
603
+ `,stderr:F,exitCode:0};let{noFf:te,ffOnly:ke,configured:_e}=u,ce=J===a;if(ke&&!ce)return{stdout:"",stderr:F+`hint: Diverging branches can't be fast-forwarded, you need to either:
604
+ hint:
605
+ hint: git merge --no-ff
606
+ hint:
607
+ hint: or:
608
+ hint:
609
+ hint: git rebase
610
+ hint:
611
+ hint: Disable this message with "git config set advice.diverging false"
612
+ fatal: Not possible to fast-forward, aborting.
613
+ `,exitCode:128};if(!ce&&!_e)return{stdout:"",stderr:F+`hint: You have divergent branches and need to specify how to reconcile them.
614
+ hint: You can do so by running one of the following commands sometime before
615
+ hint: your next pull:
616
+ hint:
617
+ hint: git config pull.rebase false # merge
618
+ hint: git config pull.rebase true # rebase
619
+ hint: git config pull.ff only # fast-forward only
620
+ hint:
621
+ hint: You can replace "git config" with "git config --global" to set a default
622
+ hint: preference for all repositories. You can also pass --rebase, --no-rebase,
623
+ hint: or --ff-only on the command line to override the configured default per
624
+ hint: invocation.
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&&!te){let le=await vo(s,a,W);if(le.exitCode===0){let je=c?.type==="symbolic"?c.target:"HEAD";await Je(s,je,{oldHash:a,newHash:W,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:"pull: Fast-forward"}),c?.type==="symbolic"&&await Je(s,"HEAD",{oldHash:a,newHash:W,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:"pull: Fast-forward"}),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:W,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"fast-forward",commitHash:W})}return{...le,stderr:F+le.stderr}}let Oe=c?.type==="symbolic"?Pe(c.target):"HEAD",ut=W,yr=d||"HEAD",Ye=await xe(s,"merge.conflictstyle")??"merge",Ur={a:"HEAD",b:ut,conflictStyle:Ye},er=await bs(s,a,W,Ur),Da=await j(s,a),Qo=await On(s,er,Da.tree,{labels:Ur,errorExitCode:2,operationName:"merge"});if(!Qo.ok)return Qo;if(er.conflicts.length>0){await Z(s,"MERGE_HEAD",W),await Z(s,"ORIG_HEAD",a);let le=await mr(s,yr,Oe,g.url),je=Kt({version:2,entries:er.entries}).sort();return le+=`
581
628
  # Conflicts:
582
- ${Le.map(gn=>`# ${gn}`).join(`
629
+ ${je.map(mt=>`# ${mt}`).join(`
583
630
  `)}
584
- `,await Me(s,"MERGE_MSG",re),{stdout:`${[...ae.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
631
+ `,await Ae(s,"MERGE_MSG",le),await Ae(s,"MERGE_MODE",te?"no-ff":""),{stdout:`${[...er.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
585
632
  `)}
586
- `,stderr:"",exitCode:1}}let Sn=rt.mergedTreeHash,qe=await dn(s,r.env);if(M(qe))return qe;let br=await nt(s,r.env);if(M(br))return br;let _r=await mr(s,ne,J),Pa={repo:s,message:_r,treeHash:Sn,headHash:a,theirsHash:D},$a=await t?.hooks?.mergeMsg?.(Pa);if(de($a))return{stdout:"",stderr:$a.message??"",exitCode:1};_r=Pa.message;let Oa=await t?.hooks?.preMergeCommit?.({repo:s,message:_r,treeHash:Sn,headHash:a,theirsHash:D});if(de(Oa))return{stdout:"",stderr:Oa.message??"",exitCode:1};let Is=await bt(s,Sn,[a,D],qe,br,_r);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:D,strategy:"three-way",commitHash:Is}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:Is});let Sd=te?.type==="symbolic"?te.target:"HEAD",Ia="pull: Merge made by the 'ort' strategy.";await Ze(s,Sd,{oldHash:a,newHash:Is,name:S.name,email:S.email,timestamp:S.timestamp,tz:S.tz,message:Ia}),te?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:Is,name:S.name,email:S.email,timestamp:S.timestamp,tz:S.tz,message:Ia});let Td=await hn(s,Oe.tree,Sn);return{stdout:`${ae.messages.length>0?`${ae.messages.join(`
633
+ `,stderr:F,exitCode:1}}let Ss=Qo.mergedTreeHash,ei=await un(s,r.env);if(M(ei))return ei;let ti=await nt(s,r.env);if(M(ti))return ti;let Ts=await mr(s,yr,Oe,g.url),Ma={repo:s,message:Ts,treeHash:Ss,headHash:a,theirsHash:W},ja=await t?.hooks?.mergeMsg?.(Ma);if(fe(ja))return{stdout:"",stderr:ja.message??"",exitCode:1};Ts=Ma.message;let Ga=await t?.hooks?.preMergeCommit?.({repo:s,message:Ts,treeHash:Ss,headHash:a,theirsHash:W});if(fe(Ga))return{stdout:"",stderr:Ga.message??"",exitCode:1};let vs=await yt(s,Ss,[a,W],ei,ti,Ts);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:W,strategy:"three-way",commitHash:vs}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"three-way",commitHash:vs});let Bd=c?.type==="symbolic"?c.target:"HEAD",La=`pull${te?" --no-ff":""}: Merge made by the 'ort' strategy.`;await Je(s,Bd,{oldHash:a,newHash:vs,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:La}),c?.type==="symbolic"&&await Je(s,"HEAD",{oldHash:a,newHash:vs,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:La});let Wd=await pn(s,Da.tree,Ss);return{stdout:`${er.messages.length>0?`${er.messages.join(`
587
634
  `)}
588
635
  `:""}Merge made by the 'ort' strategy.
589
- ${Td}`,stderr:"",exitCode:0}}})}ie();Be();ht();we();function nd(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:$().alias("f").describe("Force push"),"set-upstream":$().alias("u").describe("Set upstream tracking reference"),all:$().describe("Push all branches"),delete:$().alias("d").describe("Delete remote refs"),tags:$().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a;try{a=await Lr(s,i,r.env)}catch(b){let y=b instanceof Error?b.message:"";if(y.startsWith("network"))return O(y);throw b}if(!a)return O(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,l=n.force,d=await c.advertiseRefs(),m=new Map;for(let b of d)m.set(b.name,b.hash);if(n.tags&&n.all)return O("options '--tags' and '--all/--branches' cannot be used together");if(n.tags&&n.delete)return O("options '--delete' and '--tags' cannot be used together");let u=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return O("--delete requires a ref argument");for(let y of b){let E=y.startsWith("refs/")?y:`refs/heads/${y}`,k=m.get(E)??null;if(!k)return G(`error: unable to delete '${y}': remote ref does not exist
590
- `);u.push({name:E,oldHash:k,newHash:ee,ok:l})}}else if(n.all){let b=await ge(s,"refs/heads");for(let y of b){let E=y.name,k=m.get(E)??null;u.push({name:E,oldHash:k,newHash:y.hash,ok:l})}}else if(h&&h.length>0)for(let b of h){let y=wr(b),E=await Ng(s,y.src);if(!E)return G(`error: src refspec '${y.src}' does not match any
591
- `);let k=y.dst.startsWith("refs/")?y.dst:`refs/heads/${y.dst}`,C=m.get(k)??null;u.push({name:k,oldHash:C,newHash:E,ok:l||y.force})}else if(!n.tags){let b=await Q(s);if(!b||b.type!=="symbolic")return O("You are not currently on a branch.");let y=b.target,E=y.startsWith("refs/heads/")?y.slice(11):y,k=await Y(s);if(!k)return G(`error: src refspec does not match any
592
- `);let C=(await xe(s,"push.default"))?.toLowerCase()??"simple",P=await Lg(s,C,y,E,k,i,m,l);if("exitCode"in P)return P;u.push(P)}if(n.tags){let b=await ge(s,"refs/tags");for(let y of b){let E=m.get(y.name)??null;E!==y.hash&&(u.some(k=>k.name===y.name)||u.push({name:y.name,oldHash:E,newHash:y.hash,ok:l}))}}if(u.length===0)return{stdout:`Everything up-to-date
593
- `,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:u.map(b=>({srcRef:b.newHash===ee?null:b.name,srcHash:b.newHash===ee?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===ee}))});if(de(p))return G(p.message??"");let g=await c.push(u),w=[];w.push(`To ${f.url}
594
- `);let R=!1;for(let b of g.updates){let y=b.name.startsWith("refs/tags/"),E=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name.startsWith("refs/tags/")?b.name.slice(10):b.name;if(!b.ok)w.push(` ! [rejected] ${E} -> ${E} (${b.error??"failed"})
595
- `),R=!0;else if(b.oldHash)if(b.newHash===ee)w.push(` - [deleted] ${E}
596
- `);else{let k=X(b.oldHash),C=X(b.newHash);w.push(` ${k}..${C} ${E} -> ${E}
597
- `)}else{let k=y?"[new tag]":"[new branch]";w.push(` * ${k} ${E} -> ${E}
598
- `)}}if(n["set-upstream"]&&!R){let b=await Q(s);if(b?.type==="symbolic"){let y=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,E=await pe(s);E[`branch "${y}"`]={remote:i,merge:`refs/heads/${y}`},await Je(s,E),w.push(`branch '${y}' set up to track '${i}/${y}'.
599
- `)}}let x={stdout:"",stderr:w.join(""),exitCode:R?1:0};return R||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:u.map(b=>({srcRef:b.newHash===ee?null:b.name,srcHash:b.newHash===ee?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===ee}))}),x}})}async function Lg(e,t,n,r,o,s,i,a){if(t==="nothing")return O(`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 O(`The current branch ${r} has no upstream branch.
636
+ ${Wd}`,stderr:F,exitCode:0}}})}async function Zg(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 gd(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[z.string().name("remote").describe("Remote to push to").optional(),z.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 q(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.
637
+ To push the history leading to the current (detached HEAD)
638
+ state now, use
639
+
640
+ git push origin HEAD:<name-of-remote-branch>
641
+ `)}let c;try{c=await _r(s,i,r.env)}catch(P){let I=P instanceof Error?P.message:"";if(I.startsWith("network"))return T(I);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 I=[];for(let D of P){let G=D.startsWith("refs/")?D:`refs/heads/${D}`,A=u.get(G)??null;if(!A){I.push(`error: unable to delete '${D}': remote ref does not exist
642
+ `);continue}m.push({name:G,oldHash:A,newHash:ee,ok:d})}if(I.length>0&&m.length===0)return N(I.join("")+`error: failed to push some refs to '${l.url}'
643
+ `)}else if(n.all){let P=await ge(s,"refs/heads");for(let I of P){let D=I.name,G=u.get(D)??null;m.push({name:D,oldHash:G,newHash:I.hash,ok:d})}}else if(a&&a.length>0)for(let P of a){let I=br(P),D=P.replace(/^\+/,"").includes(":"),G=I.dst;if(!D&&I.src==="HEAD"){let U=await Q(s);if(U?.type==="symbolic")G=U.target.startsWith("refs/heads/")?U.target.slice(11):U.target;else return{stdout:"",stderr:`error: The destination you provided is not a full refname (i.e.,
644
+ starting with "refs/"). We tried to guess what you meant by:
645
+
646
+ - Looking for a ref that matches 'HEAD' on the remote side.
647
+ - Checking if the <src> being pushed ('HEAD')
648
+ is a ref in "refs/{heads,tags}/". If so we add a corresponding
649
+ refs/{heads,tags}/ prefix on the remote side.
650
+
651
+ Neither worked, so we gave up. You must fully qualify the ref.
652
+ hint: The <src> part of the refspec is a commit object.
653
+ hint: Did you mean to create a new branch by pushing to
654
+ hint: 'HEAD:refs/heads/HEAD'?
655
+ error: failed to push some refs to '${l.url}'
656
+ `,exitCode:1}}let A=await Qg(s,I.src);if(!A)return N(`error: src refspec ${I.src} does not match any
657
+ error: failed to push some refs to '${l.url}'
658
+ `);let O=G.startsWith("refs/")?G:`refs/heads/${G}`,_=u.get(O)??null;m.push({name:O,oldHash:_,newHash:A,ok:d||I.force})}else if(!n.tags){let P=await Q(s);if(!P||P.type!=="symbolic")return T(`You are not currently on a branch.
659
+ To push the history leading to the current (detached HEAD)
660
+ state now, use
661
+
662
+ git push origin HEAD:<name-of-remote-branch>
663
+ `);let I=P.target,D=I.startsWith("refs/heads/")?I.slice(11):I,G=await Y(s);if(!G)return N(`error: src refspec does not match any
664
+ `);let A=(await xe(s,"push.default"))?.toLowerCase()??"simple",O=await Jg(s,A,I,D,G,i,u,d);if("exitCode"in O)return O;m.push(O)}if(n.tags){let P=await ge(s,"refs/tags");for(let I of P){let D=u.get(I.name)??null;D!==I.hash&&(m.some(G=>G.name===I.name)||m.push({name:I.name,oldHash:D,newHash:I.hash,ok:d}))}}let p=m.filter(P=>P.oldHash!==P.newHash);if(p.length===0){let P="";if(n["set-upstream"]){let I=await Q(s);if(I?.type==="symbolic"){let D=I.target.startsWith("refs/heads/")?I.target.slice(11):I.target,G=await he(s);G[`branch "${D}"`]={remote:i,merge:`refs/heads/${D}`},await Xe(s,G),P=`branch '${D}' set up to track '${i}/${D}'.
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===ee?null:P.name,srcHash:P.newHash===ee?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===ee}))});if(fe(g))return N(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!==ee&&w.has(P.name)),R=await Promise.all(y.map(P=>en(s,P.oldHash,P.newHash))),x=new Set;y.forEach((P,I)=>{R[I]||x.add(P.name)});let k=[],E=!1;for(let P of b.updates){let I=P.name.startsWith("refs/tags/"),D=jn(P.name);if(P.ok)if(P.oldHash)if(P.newHash===ee)k.push({prefix:" - [deleted]",from:D,to:""});else{let G=X(P.oldHash),A=X(P.newHash);x.has(P.name)?k.push({prefix:` + ${G}...${A}`,from:D,to:D,suffix:"(forced update)"}):k.push({prefix:` ${G}..${A}`,from:D,to:D})}else{let G=I?"[new tag]":"[new branch]";k.push({prefix:` * ${G}`,from:D,to:D})}else{let G=P.error?.includes("fetch first"),A=P.error?.includes("non-fast-forward"),O=G?"fetch first":A?"non-fast-forward":P.error??"failed";k.push({prefix:" ! [rejected]",from:D,to:D,suffix:`(${O})`}),E=!0}}k.sort((P,I)=>pd(P)-pd(I));let C=[];if(C.push(`To ${l.url}
667
+ `),C.push(Sr(k,0,!1)),E){C.push(`error: failed to push some refs to '${l.url}'
668
+ `);let P=b.updates.some(D=>!D.ok&&D.error?.includes("fetch first")),I=b.updates.some(D=>!D.ok&&D.error?.includes("non-fast-forward"));P?C.push(`hint: Updates were rejected because the remote contains work that you do not
669
+ hint: have locally. This is usually caused by another repository pushing to
670
+ hint: the same ref. If you want to integrate the remote changes, use
671
+ hint: 'git pull' before pushing again.
672
+ hint: See the 'Note about fast-forwards' in 'git push --help' for details.
673
+ `):I&&C.push(`hint: Updates were rejected because the tip of your current branch is behind
674
+ hint: its remote counterpart. If you want to integrate the remote changes,
675
+ hint: use 'git pull' before pushing again.
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 I=`refs/remotes/${i}/${P.name.slice(11)}`;P.newHash===ee?await me(s,I):await Z(s,I,P.newHash)}if(n["set-upstream"]&&!E){let P=await Q(s);if(P?.type==="symbolic"){let I=P.target.startsWith("refs/heads/")?P.target.slice(11):P.target,D=await he(s);D[`branch "${I}"`]={remote:i,merge:`refs/heads/${I}`},await Xe(s,D),$=`branch '${I}' set up to track '${i}/${I}'.
678
+ `}}let H={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===ee?null:P.name,srcHash:P.newHash===ee?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===ee}))}),H}})}async function Jg(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.
600
679
  To push the current branch and set the remote as upstream, use
601
680
 
602
681
  git push --set-upstream ${s} ${r}
603
- `);let m=d.merge;return{name:m,oldHash:i.get(m)??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)return(d.startsWith("refs/heads/")?d.slice(11):d)!==r?O(`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 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
604
683
  the name of your current branch. To push to the upstream branch
605
684
  on the remote, use
606
685
 
607
- git push ${s} HEAD:${d}
686
+ git push ${s} HEAD:${h}
608
687
 
609
688
  To push to the branch of the same name on the remote, use
610
689
 
611
690
  git push ${s} HEAD
612
- `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}async function Ng(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"?Y(e):null)}ie();me();ze();we();function _g(e,t,n,r){return`${X(n)} ${e}@{${t}}: ${r}`}async function Wo(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.
691
+
692
+ To choose either option permanently, see push.default in 'git help config'.
693
+
694
+ To avoid automatically configuring an upstream branch when its name
695
+ won't match the local branch, see option 'simple' of branch.autoSetupMerge
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.
698
+ To push the current branch and set the remote as upstream, use
699
+
700
+ git push --set-upstream ${s} ${r}
701
+
702
+ To have this happen automatically for branches without a tracking
703
+ upstream, see 'push.autoSetupRemote' in 'git help config'.
704
+ `)}function pd(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 Qg(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"?Y(e):null)}oe();pe();ze();we();function ew(e,t,n,r){return`${X(n)} ${e}@{${t}}: ${r}`}async function Yo(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.
613
705
  Use '--' to separate paths from revisions, like this:
614
706
  'git <command> [<revision>...] -- [<file>...]'
615
- `,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 m=s.length-1-l;d.newHash!==ee&&(i.push(_g(t,m,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
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!==ee&&(i.push(ew(t,h,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
616
708
  `)}
617
- `:"",stderr:"",exitCode:0}}function rd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:V.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 Wo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Wo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Wo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
618
- `,exitCode:128};let l=H(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Wo(i,c,r.maxCount)}})}ie();Be();ze();we();function Fg(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 sd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:$().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 pe(a),f=Fg(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 wd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[z.string().name("args").variadic().optional()],options:{maxCount:V.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(M(s))return s;let i=s,a=r.args;if(a.length===0)return Yo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Yo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Yo(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 Yo(i,c,r.maxCount)}})}oe();Be();ze();we();function tw(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 bd(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 q(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=tw(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(`
619
711
  `)}
620
712
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
621
713
  `)}
622
- `,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(!ts(`refs/remotes/${s.name}`,0))return O(`'${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 pe(a),f=`remote "${s.name}"`;if(f in c)return G(`error: remote ${s.name} already exists.
623
- `,3);let l=pr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Je(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 pe(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Bg(c,s.name),await Je(a,c),await Wg(a,s.name),{stdout:"",stderr:"",exitCode:0}):G(`error: No such remote: '${s.name}'
624
- `,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 pe(a);return Ug(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 pe(a),f=`remote "${s.name}"`;if(!(f in c))return G(`error: No such remote '${s.name}'
625
- `,2);let l=pr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await Je(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 pe(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
626
- `,stderr:"",exitCode:0}:G(`error: No such remote '${s.name}'
627
- `,2)}})}async function Ug(e,t,n,r){if(!ts(`refs/remotes/${r}`,0))return O(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return G(`error: No such remote: '${n}'
628
- `,2);let s=`remote "${r}"`;if(s in t)return O(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Je(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 Z(e,l,f.hash),await he(e,f.name),d.length>0&&await Ln(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Bg(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 Wg(e,t){let n=`refs/remotes/${t}`,r=await ge(e,n);for(let o of r)await he(e,o.name)}ie();Ce();ce();me();ze();we();an();Ae();Xt();tt();function id(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:$().describe("Only move HEAD"),mixed:$().describe("Move HEAD and reset index (default)"),hard:$().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 O("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=ut(i,r.cwd);if(o.passthrough.length>0){let u=a.length>0?a[0]:void 0;return wa(i,o.passthrough,l,u,t)}if(!f&&a.length>0){let u=a[0],h=await We(i,u);return a.length===1&&h?od(i,u,"mixed",r.env,t):h?wa(i,a.slice(1),l,u,t):wa(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",m=a.length>0?a[0]:"HEAD";return od(i,m,d,r.env,t)}})}async function wa(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(de(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await We(e,r);if(!d)return Zt(r);let m=await ve(e,d);i=(await j(e,m)).tree}else{let d=await Y(e);d&&(i=(await j(e,d)).tree)}let a=await le(e,i??null),c=await z(e);if(t.some(ir)){let d=t.map(u=>Ue(u,n)),m=new Set;for(let[u]of a)m.add(u);for(let u of c.entries)m.add(u.path);for(let u of m){if(!Ee(d,u))continue;let h=a.get(u);h?c=Ct(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Se()}):c=lt(c,u)}}else for(let d of t){let m=a.get(d);if(m)c=Ct(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:Se()});else if(c.entries.some(h=>h.path===d))c=lt(c,d);else if(!(e.workTree&&await e.fs.exists(H(e.workTree,d))))return Zt(d)}await fe(e,c);let l={stdout:await ad(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function ad(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 gt(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(`
629
- `)}
630
- `}async function od(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(de(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Zt(t);let a=await ve(e,i),c=await j(e,a);if(n==="soft"){let u=await B(e,"MERGE_HEAD"),h=await z(e);if(u||Mt(h))return O("Cannot do a soft reset in the middle of a merge.")}let f=await Y(e),l=await Q(e);l?.type==="symbolic"?await Z(e,l.target,a):await Z(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await oe(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await oe(e,r,"HEAD",f,a,d),await cr(e),n==="mixed"){let u=await Ke(e,c.tree),h=Ns(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Se()})));await fe(e,h);let p=await ad(e,h);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 h=await z(e),p=await kn(e,c.tree,h);await fe(e,{version:2,entries:p.newEntries}),await De(e,p.worktreeOps)}let m=n==="hard"?`HEAD is now at ${X(a)} ${ue(c.message)}
631
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:m,stderr:"",exitCode:0}}ie();Ce();ce();we();Ae();tt();function cd(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:V.string().alias("s").describe("Restore from tree-ish"),staged:$().alias("S").describe("Restore the index"),worktree:$().alias("W").describe("Restore the working tree (default)"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().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 O("you must specify path(s) to restore");if(n.ours&&n.theirs)return O("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=ut(i,r.cwd);if(n.ours||n.theirs)return n.source?O("cannot specify both --source and --ours/--theirs"):c?O("cannot use --ours/--theirs with --staged"):po(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let m=await je(i,n.source,`could not resolve '${n.source}'`);if(M(m))return m;d=m.commit.tree}else if(c){let m=await Y(i);m&&(d=(await j(i,m)).tree)}return c&&f?Kg(i,a,l,d):c?qg(i,a,l,d):d?zg(i,a,l,d):ho(i,a,l)}})}async function qg(e,t,n,r){let o=await le(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=Ct(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Se()});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
632
- `,exitCode:1};s=lt(s,f)}}return c?(await fe(e,s),{stdout:"",stderr:"",exitCode:0}):G(`error: pathspec '${t[0]}' did not match any file(s) known to git
633
- `)}async function zg(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");let o=await le(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
634
- `,exitCode:1};i.push(f)}if(i.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
635
- `);for(let f of i){let l=o.get(f);if(l)await dt(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 Kg(e,t,n,r){if(!e.workTree)return O("this operation must be run in a work tree");let o=await le(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 G(`error: pathspec '${t[0]}' did not match any file(s) known to git
636
- `);for(let f of a){let l=o.get(f);if(l)s=Ct(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Se()}),await dt(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
637
- `,exitCode:1};s=lt(s,f);let m=`${e.workTree}/${f}`;await e.fs.exists(m)&&await e.fs.rm(m)}}return await fe(e,s),{stdout:"",stderr:"",exitCode:0}}ie();ce();me();we();an();Ae();function fd(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:$().describe("Verify that exactly one parameter is provided and resolves to an object"),short:$().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":$().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":$().describe("Output the full symbolic ref name"),"show-toplevel":$().describe("Show the absolute path of the top-level directory"),"git-dir":$().describe("Show the path to the .git directory"),"is-inside-work-tree":$().describe("Output whether cwd is inside the work tree"),"is-bare-repository":$().describe("Output whether the repository is bare"),"show-prefix":$().describe("Show path of cwd relative to top-level directory"),"show-cdup":$().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],m=n["is-bare-repository"],u=n["show-prefix"],h=n["show-cdup"],p=f||l||d||m||u||h,g=await W(r.fs,r.cwd,t);if(M(g))return g;let w=g,R=[];if(f){if(!w.workTree)return O("this operation must be run in a work tree");R.push(w.workTree)}if(l&&R.push(w.gitDir),d&&R.push(w.workTree?"true":"false"),m&&R.push(w.workTree?"false":"true"),u){if(!w.workTree)return O("this operation must be run in a work tree");let b=st(w.workTree,r.cwd);R.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return O("this operation must be run in a work tree");let b=st(r.cwd,w.workTree);R.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:R.map(y=>`${y}
638
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return O("Needed a single revision");for(let b of o){if(a){let k=await Vg(w,b);if(k===null)return ba(b,s);R.push(k);continue}if(c){let k=await Yg(w,b);if(k===null)return ba(b,s);R.push(k);continue}let y=Vs(b);if(y){let k=await Xg(w,y.rev,y.path);if(k===null){let C=y.path.replace(/^\//,"");return O(`path '${C}' does not exist in '${y.rev}'`)}R.push(i?X(k):k);continue}let E=await We(w,b);if(!E)return ba(b,s);R.push(i?X(E):E)}return{stdout:R.map(b=>`${b}
639
- `).join(""),stderr:"",exitCode:0}}})}function ba(e,t){return t?O("Needed a single revision"):Zt(e)}async function Vg(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 Yg(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 Xg(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 le(e,o.tree)).get(s)?.hash??null}ie();Be();Ce();ce();ze();we();Ae();Xt();function ld(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:$().describe("Abort the current revert operation"),continue:$().describe("Continue the revert after conflict resolution"),skip:$().describe("Skip the current commit and continue"),"no-commit":$().alias("n").describe("Apply changes without creating a commit"),"no-edit":$().describe("Do not edit the commit message"),mainline:V.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 U=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(de(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Zg(s,r.env);return L.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),L}if(n.continue){let U=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(de(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Qg(s,r.env);if(L.exitCode===0){let K=await Y(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:K,hadConflicts:!1})}return L}if(n.skip)return Jg(s,r.env);let i=n.commit;if(!i)return O("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commitRef:i});if(de(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await je(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let m=await z(s),u=Rn(m,"Reverting",`fatal: revert failed
640
- `);if(u)return u;let h=await j(s,d);if(s.workTree){let U=await le(s,h.tree);if(Un(m,U))return G(`error: your local changes would be overwritten by revert.
714
+ `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[z.string().name("name").describe("Remote name"),z.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!ns(`refs/remotes/${s.name}`,0))return T(`'${s.name}' is not a valid remote name`);let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;if(f in c)return N(`error: remote ${s.name} already exists.
715
+ `,3);let l=gr(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 q(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],rw(c,s.name),await Xe(a,c),await sw(a,s.name),{stdout:"",stderr:"",exitCode:0}):N(`error: No such remote: '${s.name}'
716
+ `,2)},o=[z.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:[z.string().name("old").describe("Current remote name"),z.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a);return nw(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[z.string().name("name").describe("Remote name"),z.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;if(!(f in c))return N(`error: No such remote '${s.name}'
717
+ `,2);let l=gr(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:[z.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await q(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??""}
718
+ `,stderr:"",exitCode:0}:N(`error: No such remote '${s.name}'
719
+ `,2)}})}async function nw(e,t,n,r){if(!ns(`refs/remotes/${r}`,0))return T(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return N(`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 Z(e,l,f.hash),await me(e,f.name),d.length>0&&await Nn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function rw(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 sw(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();cn();He();Jt();tt();function Ed(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[z.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 q(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 $a(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?yd(i,u,"mixed",r.env,t):m?$a(i,a.slice(1),l,u,t):$a(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",h=a.length>0?a[0]:"HEAD";return yd(i,h,d,r.env,t)}})}async function $a(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 ve(e,d);i=(await j(e,h)).tree}else{let d=await Y(e);d&&(i=(await j(e,d)).tree)}let a=await de(e,i??null),c=await K(e);if(t.some(cr)){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:Se()}):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:Se()});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 kd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function kd(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
+ `)}
722
+ `}async function yd(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 ve(e,i),c=await j(e,a);if(n==="soft"){let u=await B(e,"MERGE_HEAD"),m=await K(e);if(u||Gt(m))return T("Cannot do a soft reset in the middle of a merge.")}let f=await Y(e),l=await Q(e);l?.type==="symbolic"?await Z(e,l.target,a):await Z(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 lr(e),n==="mixed"){let u=await qe(e,c.tree),m=Us(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Se()})));await ae(e,m);let p=await kd(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 K(e),p=await xn(e,c.tree,m);await ae(e,{version:2,entries:p.newEntries}),await Me(e,p.worktreeOps)}let h=n==="hard"?`HEAD is now at ${X(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();He();tt();function Rd(e,t){e.command("restore",{description:"Restore working tree files",args:[z.string().name("pathspec").variadic().optional()],options:{source:V.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 q(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"):ko(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let h=await Ge(i,n.source,`could not resolve '${n.source}'`);if(M(h))return h;d=h.commit.tree}else if(c){let h=await Y(i);h&&(d=(await j(i,h)).tree)}return c&&f?aw(i,a,l,d):c?ow(i,a,l,d):d?iw(i,a,l,d):Eo(i,a,l)}})}async function ow(e,t,n,r){let o=await de(e,r),s=await K(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!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:Se()});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}):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
725
+ `)}async function iw(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 K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(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
+ `,exitCode:1};i.push(f)}if(i.length===0)return N(`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 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=await K(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)Ee(i,f)&&a.push(f);if(a.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
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:Se()}),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();cn();He();function xd(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[z.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 q(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(x=>`${x}
730
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return T("Needed a single revision");for(let R of o){if(a){let E=await cw(w,R);if(E===null)return Oa(R,s);b.push(E);continue}if(c){let E=await fw(w,R);if(E===null)return Oa(R,s);b.push(E);continue}let x=Js(R);if(x){let E=await lw(w,x.rev,x.path);if(E===null){let C=x.path.replace(/^\//,"");return T(`path '${C}' does not exist in '${x.rev}'`)}b.push(i?X(E):E);continue}let k=await We(w,R);if(!k)return Oa(R,s);b.push(i?X(k):k)}return{stdout:b.map(R=>`${R}
731
+ `).join(""),stderr:"",exitCode:0}}})}function Oa(e,t){return t?T("Needed a single revision"):Qt(e)}async function cw(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 fw(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 lw(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();He();Jt();function Cd(e,t){e.command("revert",{description:"Revert some existing commits",args:[z.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:V.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(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 L=await dw(s,r.env);return L.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),L}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 L=await hw(s,r.env);if(L.exitCode===0){let W=await Y(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:W,hadConflicts:!1})}return L}if(n.skip)return uw(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 Ge(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 K(s),u=Cn(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(Un(h,F))return N(`error: your local changes would be overwritten by revert.
641
733
  hint: commit your changes or stash them to proceed.
642
734
  fatal: revert failed
643
- `,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return G(`error: commit ${f} is a merge but no -m option was given.
735
+ `,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return N(`error: commit ${f} is a merge but no -m option was given.
644
736
  fatal: revert failed
645
- `,128);if(p<1||p>l.parents.length)return G(`error: commit ${f} does not have parent ${p}
737
+ `,128);if(p<1||p>l.parents.length)return N(`error: commit ${f} does not have parent ${p}
646
738
  fatal: revert failed
647
- `,128);let U=l.parents[p-1];g=(await j(s,U)).tree}else if(l.parents.length===0)g=await Fe(s,[]);else{let U=l.parents[0];g=(await j(s,U)).tree}let w=X(f),R=ue(l.message),x=ew(l,f,p),b=await xe(s,"merge.conflictstyle")??"merge",y={a:"HEAD",b:R?`parent of ${w} (${R})`:`parent of ${w}`,conflictStyle:b},E=await Bt(s,l.tree,h.tree,g,y);if(E.conflicts.length===0&&E.resultTree===h.tree){let U=E.messages.length>0?`${E.messages.join(`
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=X(f),b=ue(l.message),y=mw(l,f,p),R=await xe(s,"merge.conflictstyle")??"merge",x={a:"HEAD",b:b?`parent of ${w} (${b})`:`parent of ${w}`,conflictStyle:R},k=await zt(s,l.tree,m.tree,g,x);if(k.conflicts.length===0&&k.resultTree===m.tree){let F=k.messages.length>0?`${k.messages.join(`
648
740
  `)}
649
- `:"",L=await at(s,{fromCommit:!0}),K=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${U}${L}`,stderr:K?`The previous cherry-pick is now empty, possibly due to conflict resolution.
741
+ `:"",L=await it(s,{fromCommit:!0}),W=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${F}${L}`,stderr:W?`The previous cherry-pick is now empty, possibly due to conflict resolution.
650
742
  If you wish to commit it anyway, use:
651
743
 
652
744
  git commit --allow-empty
653
745
 
654
746
  Otherwise, please use 'git cherry-pick --skip'
655
- `:"",exitCode:1}}let k=await $n(s,E,h.tree,{labels:y,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!k.ok)return k;if(E.conflicts.length>0){await Z(s,"REVERT_HEAD",f),await Z(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",x);let U=E.messages.join(`
656
- `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:U?`${U}
747
+ `:"",exitCode:1}}let E=await On(s,k,m.tree,{labels:x,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!E.ok)return E;if(k.conflicts.length>0){await Z(s,"REVERT_HEAD",f),await Z(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",y);let F=k.messages.join(`
748
+ `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:F?`${F}
657
749
  `:"",stderr:`error: could not revert ${w}... ${ue(l.message)}
658
750
  hint: After resolving the conflicts, mark them with
659
751
  hint: "git add/rm <pathspec>", then run
@@ -662,125 +754,126 @@ hint: You can instead skip this commit with "git revert --skip".
662
754
  hint: To abort and get back to the state before "git revert",
663
755
  hint: run "git revert --abort".
664
756
  hint: Disable this message with "git config set advice.mergeConflict false"
665
- `,exitCode:1}}if(n["no-commit"])return await Z(s,"REVERT_HEAD",f),await Me(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let C=k.mergedTreeHash,P=await dn(s,r.env);if(M(P))return P;let I=await nt(s,r.env);if(M(I))return I;let v=await bt(s,C,[d],P,I,x);await Ot(s),await Nt(s);let T=await Q(s),N=ue(x),S=T?.type==="symbolic"?T.target:"HEAD";await oe(s,r.env,S,d,v,`revert: ${N}`,T?.type==="symbolic");let A=T?.type==="symbolic"?Pe(T.target):"detached HEAD",D=await mn(s,h.tree,C,P,I,P.timestamp!==I.timestamp||P.timezone!==I.timezone),_=jt(A,v,x),F=E.messages.length>0?`${E.messages.join(`
757
+ `,exitCode:1}}if(n["no-commit"])return await Z(s,"REVERT_HEAD",f),await Ae(s,"MERGE_MSG",y),{stdout:"",stderr:"",exitCode:0};let C=E.mergedTreeHash,$=await un(s,r.env);if(M($))return $;let H=await nt(s,r.env);if(M(H))return H;let P=await yt(s,C,[d],$,H,y);await St(s),await Ft(s);let I=await Q(s),D=ue(y),G=I?.type==="symbolic"?I.target:"HEAD";await se(s,r.env,G,d,P,`revert: ${D}`,I?.type==="symbolic");let A=I?.type==="symbolic"?Pe(I.target):"detached HEAD",O=await mn(s,m.tree,C,$,H,$.timestamp!==H.timestamp||$.timezone!==H.timezone),_=Lt(A,P,y),U=k.messages.length>0?`${k.messages.join(`
666
758
  `)}
667
- `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:v,hadConflicts:!1}),{stdout:`${F}${_}
668
- ${D}`,stderr:"",exitCode:0}}})}async function Zg(e,t){return await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
759
+ `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:P,hadConflicts:!1}),{stdout:`${U}${_}
760
+ ${O}`,stderr:"",exitCode:0}}})}async function dw(e,t){return await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
669
761
  fatal: revert failed
670
- `,128),operationName:"revert",clearState:async o=>{await Ot(o),await Nt(o)},origHeadAsTargetRev:!0}):await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`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")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
671
763
  fatal: revert failed
672
- `,128),operationName:"revert",clearState:Nt,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
764
+ `,128),operationName:"revert",clearState:Ft,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
673
765
  fatal: revert failed
674
- `,128)}async function Jg(e,t){if(!await B(e,"REVERT_HEAD"))return G(`error: no revert in progress
766
+ `,128)}async function uw(e,t){if(!await B(e,"REVERT_HEAD"))return N(`error: no revert in progress
675
767
  fatal: revert failed
676
- `,128);let r=await Y(e);if(!r)return O("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Or(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 Y(e);if(!r)return T("unable to resolve HEAD");let o=await j(e,r),s=await K(e),i=await Ir(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
677
769
  fatal: revert failed
678
- `}}return await fe(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await oe(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Ot(e),{stdout:"",stderr:"",exitCode:0}}async function Qg(e,t){if(!await B(e,"REVERT_HEAD"))return G(`error: no cherry-pick or revert in progress
770
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps),await se(e,t,"HEAD",r,r,`reset: moving to ${r}`),await St(e),{stdout:"",stderr:"",exitCode:0}}async function hw(e,t){if(!await B(e,"REVERT_HEAD"))return N(`error: no cherry-pick or revert in progress
679
771
  fatal: revert failed
680
- `,128);let r=await z(e),o=Rn(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return G(`Aborting commit due to empty commit message.
681
- `,1);let i=await $e(e,"SQUASH_MSG");i&&(s=i+s),s=$t(s);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 dn(e,t);if(M(d))return d;let m=await nt(e,t);if(M(m))return m;let u=await B(e,"CHERRY_PICK_HEAD");u&&(d=(await j(e,u)).author);let h=Gt(s),p=await bt(e,c,[f],d,m,h);await Ot(e),await Nt(e),await be(e,"SQUASH_MSG");let g=await Q(e),w=ue(h),R=g?.type==="symbolic"?g.target:"HEAD";await oe(e,t,R,f,p,`commit: ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Pe(g.target):"detached HEAD",b=await mn(e,l.tree,c,d,m,d.timestamp!==m.timestamp||d.timezone!==m.timezone);return{stdout:`${jt(x,p,s)}
682
- ${b}`,stderr:"",exitCode:0}}function ew(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
772
+ `,128);let r=await K(e),o=Cn(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return N(`Aborting commit due to empty commit message.
773
+ `,1);let i=await $e(e,"SQUASH_MSG");if(i&&(s=i+s),s=It(s),!s)return N(`Aborting commit due to empty commit message.
774
+ `,1);let a=Le(r),c=await Fe(e,a),f=await Qe(e);if(M(f))return f;let l=await j(e,f),d=await un(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 y=g?.type==="symbolic"?Pe(g.target):"detached HEAD",R=await mn(e,l.tree,c,d,h,d.timestamp!==h.timestamp||d.timezone!==h.timezone);return{stdout:`${Lt(y,p,s)}
775
+ ${R}`,stderr:"",exitCode:0}}function mw(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
683
776
 
684
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
685
778
  changes made to ${c}`}return a+=`.
686
- `,a}ie();Ce();ce();me();we();nr();Ae();function dd(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:$().describe("Only remove from the index"),recursive:$().alias("r").describe("Allow recursive removal when a directory name is given"),force:$().alias("f").describe("Override the up-to-date check"),dryRun:$().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=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return G("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,m=await z(s),u=[],h=ut(s,r.cwd);for(let w of c){if(ir(w)){let y=[Ue(w,h)],E=m.entries.filter(k=>Ee(y,k.path));if(E.length===0)return O(`pathspec '${w}' did not match any files`);for(let k of E)u.push(k.path);continue}let R=Ht(r.cwd,w),x=st(a,R);if((x==="."||x==="")&&(x=""),x.startsWith(".."))return O(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(R)&&!(await mt(r.fs,R)).isSymbolicLink&&(await mt(r.fs,R)).isDirectory){if(!l)return O(`not removing '${x}' recursively without -r`);let y=x===""?"":`${x}/`,E=m.entries.filter(k=>y===""||k.path.startsWith(y));if(E.length===0)return O(`pathspec '${w}' did not match any files`);for(let k of E)u.push(k.path)}else{if(!m.entries.some(E=>E.path===x))return O(`pathspec '${w}' did not match any files`);u.push(x)}}if(!d){let w=await tw(s,m,u,f);if(w)return w}if(n.dryRun){let w=u.map(x=>`rm '${x}'`);return{stdout:w.length>0?`${w.join(`
779
+ `,a}oe();Ce();ie();pe();we();sr();He();function Pd(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[z.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 q(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 N("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,h=await K(s),u=[],m=dt(s,r.cwd);for(let w of c){if(cr(w)){let x=[Ue(w,m)],k=h.entries.filter(E=>Ee(x,E.path));if(k.length===0)return T(`pathspec '${w}' did not match any files`);for(let E of k)u.push(E.path);continue}let b=Mt(r.cwd,w),y=rt(a,b);if((y==="."||y==="")&&(y=""),y.startsWith(".."))return T(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(b)&&!(await ht(r.fs,b)).isSymbolicLink&&(await ht(r.fs,b)).isDirectory){if(!l)return T(`not removing '${y}' recursively without -r`);let x=y===""?"":`${y}/`,k=h.entries.filter(E=>x===""||E.path.startsWith(x));if(k.length===0)return T(`pathspec '${w}' did not match any files`);for(let E of k)u.push(E.path)}else{if(!h.entries.some(k=>k.path===y))return T(`pathspec '${w}' did not match any files`);u.push(y)}}if(!d){let w=await pw(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(`
687
780
  `)}
688
- `:"",stderr:"",exitCode:0}}let p=[];for(let w of u){if(m=lt(m,w),!f){let R=H(a,w);await mt(r.fs,R).then(()=>!0).catch(()=>!1)&&await r.fs.rm(R)}p.push(`rm '${w}'`)}return await fe(s,m),{stdout:p.length>0?`${p.join(`
781
+ `:"",stderr:"",exitCode:0}}let p=[];for(let w of u){if(h=ft(h,w),!f){let b=v(a,w);await ht(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(`
689
782
  `)}
690
- `:"",stderr:"",exitCode:0}}})}async function tw(e,t,n,r){let o=await Y(e),s=new Map;if(o){let f=await j(e,o),l=await Ke(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(h=>h.path===f&&h.stage===0);if(!l)continue;let m=s.get(f)!==l.hash,u=!1;if(e.workTree){let h=H(e.workTree,f),p=!1;try{await mt(e.fs,h),p=!0}catch{p=!1}p&&(u=await Nn(e.fs,h)!==l.hash)}m&&u?i.push(f):m&&!r?a.push(f):u&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
691
- `),l=i.length===1?"the following file has":"the following files have";return G(`error: ${l} staged content different from both the
783
+ `:"",stderr:"",exitCode:0}}})}async function pw(e,t,n,r){let o=await Y(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 ht(e.fs,m),p=!0}catch{p=!1}p&&(u=await _n(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
+ `),l=i.length===1?"the following file has":"the following files have";return N(`error: ${l} staged content different from both the
692
785
  file and the HEAD:
693
786
  ${f}
694
787
  (use -f to force removal)
695
788
  `)}if(a.length>0){let f=a.map(d=>` ${d}`).join(`
696
- `),l=a.length===1?"the following file has":"the following files have";return G(`error: ${l} changes staged in the index:
789
+ `),l=a.length===1?"the following file has":"the following files have";return N(`error: ${l} changes staged in the index:
697
790
  ${f}
698
791
  (use --cached to keep the file, or -f to force removal)
699
792
  `)}if(c.length>0){let f=c.map(d=>` ${d}`).join(`
700
- `),l=c.length===1?"the following file has":"the following files have";return G(`error: ${l} local modifications:
793
+ `),l=c.length===1?"the following file has":"the following files have";return N(`error: ${l} local modifications:
701
794
  ${f}
702
795
  (use --cached to keep the file, or -f to force removal)
703
- `)}return null}ie();ce();an();Ys();me();Ae();var ya=new TextDecoder;function ud(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:$().alias("p").describe("Show diff in patch format"),noPatch:$().describe("Suppress diff output"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),format:V.string().describe("Pretty-print format string"),pretty:V.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=Vs(a);if(c)return nw(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await wt(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 m=n.format??n.pretty,u=null,h=null;if(m!==void 0){let p=Fo(m);u=p.formatStr,h=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await md(s,f,p,d,u,h),stderr:"",exitCode:0}}case"tag":{let p=await Ic(s,f);return{stdout:await rw(s,p,d,u,h),stderr:"",exitCode:0}}case"tree":{let p=_n(l.content);return{stdout:hd(p),stderr:"",exitCode:0}}case"blob":return{stdout:ya.decode(l.content),stderr:"",exitCode:0}}}})}async function nw(e,t,n){let r=await je(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await le(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=H(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return O(f)}let c=await ye(e,a.hash);if(c.type==="blob")return{stdout:ya.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=_n(c.content);return{stdout:hd(f),stderr:"",exitCode:0}}return{stdout:ya.decode(c.content),stderr:"",exitCode:0}}async function md(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Cs(o,{hash:t,commit:n});else if(s!==null)i=Ps(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=>X(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Cn(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();Qs();pe();He();var Ia=new TextDecoder;function $d(e,t){e.command("show",{description:"Show various types of objects",args:[z.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:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=Js(a);if(c)return gw(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=zo(h);u=p.formatStr,m=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await Od(s,f,p,d,u,m),stderr:"",exitCode:0}}case"tag":{let p=await Nc(s,f);return{stdout:await ww(s,p,d,u,m),stderr:"",exitCode:0}}case"tree":{let p=kn(l.content);return{stdout:Id(p),stderr:"",exitCode:0}}case"blob":return{stdout:Ia.decode(l.content),stderr:"",exitCode:0}}}})}async function gw(e,t,n){let r=await Ge(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:Ia.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=kn(c.content);return{stdout:Id(f),stderr:"",exitCode:0}}return{stdout:Ia.decode(c.content),stderr:"",exitCode:0}}async function Od(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Ps(o,{hash:t,commit:n});else if(s!==null)i=$s(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=>X(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${$n(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
704
797
  `))c.push(` ${l}`);i=c.join(`
705
798
  `)}if(!r)return`${i}
706
- `;let a="";if(n.parents.length<=1){let c=n.parents.length===1?(await j(e,n.parents[0])).tree:null,f=await Ve(e,c,n.tree),{remaining:l,renames:d}=await it(e,f);a=await sw(e,l,d,r)}else r==="patch"&&(a=await mw(e,n)??"");return a?`${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 bw(e,l,d,r)}else r==="patch"&&(a=await Ow(e,n)??"");return a?`${i}
707
800
 
708
801
  ${a.replace(/\n$/,"")}
709
802
  `:n.parents.length>=2?`${i}
710
803
 
711
804
  `:`${i}
712
- `}async function rw(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: ${Cn(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
713
- `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await md(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
805
+ `}async function ww(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: ${$n(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 Od(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
714
807
  `)}
715
- `}function hd(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(`
808
+ `}function Id(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(`
716
809
  `)}
717
- `:""}async function sw(e,t,n,r){switch(r){case"patch":return uw(e,t,n);case"stat":return aw(e,t,n);case"shortstat":return cw(e,t,n);case"numstat":return fw(e,t,n);case"name-only":return ow(t,n);case"name-status":return iw(t,n);default:return""}}function ow(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(`
810
+ `:""}async function bw(e,t,n,r){switch(r){case"patch":return $w(e,t,n);case"stat":return kw(e,t,n);case"shortstat":return Rw(e,t,n);case"numstat":return xw(e,t,n);case"name-only":return yw(t,n);case"name-status":return Ew(t,n);default:return""}}function yw(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(`
718
811
  `)}
719
- `:""}function iw(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}
720
- `).join(""):""}async function aw(e,t,n){let{fileStats:r}=await Zn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),ur(r)}async function cw(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
721
- `:""}async function fw(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:un(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(Te(i)||Te(a))o+=`- - ${s.display}
722
- `;else{let c=Rt(i),f=Rt(a),l=ct(c,f),d=0,m=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&m++;o+=`${d} ${m} ${s.display}
723
- `}}return o}async function lw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Tt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function dw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Tt({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 uw(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 dw(e,s.entry):o+=await lw(e,s.entry);return o}async function mw(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 le(e,c.tree)})),r=await le(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 hw(e,a,n,r);return i}async function hw(e,t,n,r){let o=r.get(t),s=n.map(m=>m.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(m=>m?.hash??null),f=s.map(m=>m?.mode??null),l=await Promise.all(c.map(async m=>m?await se(e,m):"")),d=i?await se(e,i):"";return Mo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}ie();Ce();ce();we();ie();Tn();Ce();ce();wn();me();ze();we();Ae();Xt();tt();var Qt="refs/stash";function ka(e,t){return Ie(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function pd(e){let t=await et(e,Qt),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function Nr(e,t){let n=await et(e,Qt);if(n.length===0)return null;let r=n.length-1-t;return r<0||r>=n.length?null:n[r]?.newHash??null}async function gd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Y(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 Ve(e,i.tree,f),d=new Map(c.map(L=>[L.path,L])),m=await ot(e,o,"",{skipIgnore:!0}),u=!1;for(let L of m){let K=d.get(L);if(!K)continue;let te=H(o,L),J=await e.fs.readFileBuffer(te);if(await pt("blob",J)!==K.hash){u=!0;break}}if(!u)for(let[L]of d){let K=H(o,L);if(!await e.fs.exists(K)){u=!0;break}}let h=[];if(r?.includeUntracked){let L=await ot(e,o,"");for(let K of L)d.has(K)||h.push(K)}if(l.length===0&&!u&&h.length===0)return null;let p=await Ms(e,t),g=await qr(e,t),w=await Q(e),R=w?.type==="symbolic"?Pe(w.target):"(no branch)",x=X(s),b=ue(i.message),y=`index on ${R}: ${x} ${b}
724
- `,E=on({type:"commit",tree:f,parents:[s],author:p,committer:g,message:y}),k=await He(e,"commit",E),C=await le(e,i.tree),P=[],I=new Set;for(let L of m){let K=d.get(L),te=C.get(L);if(!K&&!te)continue;let J=H(o,L),ne=await e.fs.readFileBuffer(J),ke=await He(e,"blob",ne),Ge=K?K.mode:parseInt(te?.mode??"100644",8);P.push({path:L,mode:Ge,hash:ke,stage:0,stat:Se()}),I.add(L)}for(let[L,K]of d)I.has(L)||C.has(L)||P.push({path:L,mode:K.mode,hash:K.hash,stage:0,stat:Se()});let v=await Fe(e,P),T=null;if(r?.includeUntracked){let L=[];for(let ne of h){let ke=H(o,ne),Ge=await e.fs.readFileBuffer(ke),ae=await He(e,"blob",Ge);L.push({path:ne,mode:33188,hash:ae,stage:0,stat:Se()})}let K=await Fe(e,L),te=`untracked files on ${R}: ${x} ${b}
725
- `,J=on({type:"commit",tree:K,parents:[],author:p,committer:g,message:te});T=await He(e,"commit",J)}let N=n?`On ${R}: ${n}`:`WIP on ${R}: ${x} ${b}`,S=[s,k];T&&S.push(T);let A=on({type:"commit",tree:v,parents:S,author:p,committer:g,message:N}),D=await He(e,"commit",A),_=await Nr(e,0)??ee;await Ze(e,Qt,{oldHash:_,newHash:D,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:N.trimEnd()}),await Z(e,Qt,D);let F=await kn(e,i.tree,a);await fe(e,{version:2,entries:F.newEntries}),await De(e,F.worktreeOps),(await Q(e))?.type==="symbolic"&&await oe(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let L of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,L);for(let L of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let K=H(e.gitDir,L);await e.fs.exists(K)&&await e.fs.rm(K)}if(h.length>0)for(let L of h){if(C.has(L))continue;let K=H(o,L);await e.fs.exists(K)&&(await e.fs.rm(K),await sr(e.fs,tn(K),o))}return D}async function Ea(e,t){let n=e.workTree,r=await j(e,t),o=await Ke(e,r.tree),s=[];for(let i of o){let a=H(n,i.path);await e.fs.exists(a)?s.push(i.path):await dt(e,i)}return s.length>0?(s.sort(ka),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
812
+ `:""}function Ew(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 kw(e,t,n){let{fileStats:r}=await Jn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),hr(r)}async function Rw(e,t,n){let{fileStats:r}=await Jn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Zn(r.length,o,s);return i?`${i}
814
+ `:""}async function xw(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 re(e,s.oldHash):"",a=s.newHash?await re(e,s.newHash):"";if(Te(i)||Te(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 Cw(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 Pw(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 $w(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 Pw(e,s.entry):o+=await Cw(e,s.entry);return o}async function Ow(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 Iw(e,a,n,r);return i}async function Iw(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 Fo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}oe();Ce();ie();we();oe();Tn();Ce();ie();wn();pe();ze();we();He();Jt();tt();var tn="refs/stash";function Ta(e,t){return Ie(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Sd(e){let t=await et(e,tn),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 Fr(e,t){let n=await et(e,tn);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 Td(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Y(e);if(!s)return null;let i=await j(e,s),a=await K(e),c=Le(a),f=await Fe(e,c),l=await Ke(e,i.tree,f),d=new Map(c.map(L=>[L.path,L])),h=await st(e,o,"",{skipIgnore:!0}),u=!1;for(let L of h){let W=d.get(L);if(!W)continue;let ne=v(o,L),J=await e.fs.readFileBuffer(ne);if(await gt("blob",J)!==W.hash){u=!0;break}}if(!u)for(let[L]of d){let W=v(o,L);if(!await e.fs.exists(W)){u=!0;break}}let m=[];if(r?.includeUntracked){let L=await st(e,o,"");for(let W of L)d.has(W)||m.push(W)}if(l.length===0&&!u&&m.length===0)return null;let p=await Ls(e,t),g=await Kr(e,t),w=await Q(e),b=w?.type==="symbolic"?Pe(w.target):"(no branch)",y=X(s),R=ue(i.message),x=`index on ${b}: ${y} ${R}
817
+ `,k=an({type:"commit",tree:f,parents:[s],author:p,committer:g,message:x}),E=await De(e,"commit",k),C=await de(e,i.tree),$=[],H=new Set;for(let L of h){let W=d.get(L),ne=C.get(L);if(!W&&!ne)continue;let J=v(o,L),te=await e.fs.readFileBuffer(J),ke=await De(e,"blob",te),_e=W?W.mode:parseInt(ne?.mode??"100644",8);$.push({path:L,mode:_e,hash:ke,stage:0,stat:Se()}),H.add(L)}for(let[L,W]of d)H.has(L)||C.has(L)||$.push({path:L,mode:W.mode,hash:W.hash,stage:0,stat:Se()});let P=await Fe(e,$),I=null;if(r?.includeUntracked){let L=[];for(let te of m){let ke=v(o,te),_e=await e.fs.readFileBuffer(ke),ce=await De(e,"blob",_e);L.push({path:te,mode:33188,hash:ce,stage:0,stat:Se()})}let W=await Fe(e,L),ne=`untracked files on ${b}: ${y} ${R}
818
+ `,J=an({type:"commit",tree:W,parents:[],author:p,committer:g,message:ne});I=await De(e,"commit",J)}let D=n?`On ${b}: ${n}`:`WIP on ${b}: ${y} ${R}`,G=[s,E];I&&G.push(I);let A=an({type:"commit",tree:P,parents:G,author:p,committer:g,message:D}),O=await De(e,"commit",A),_=await Fr(e,0)??ee;await Je(e,tn,{oldHash:_,newHash:O,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:D.trimEnd()}),await Z(e,tn,O);let U=await xn(e,i.tree,a);await ae(e,{version:2,entries:U.newEntries}),await Me(e,U.worktreeOps),(await Q(e))?.type==="symbolic"&&await se(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let L of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await me(e,L);for(let L of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let W=v(e.gitDir,L);await e.fs.exists(W)&&await e.fs.rm(W)}if(m.length>0)for(let L of m){if(C.has(L))continue;let W=v(o,L);await e.fs.exists(W)&&(await e.fs.rm(W),await ir(e.fs,nn(W),o))}return O}async function Sa(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(Ta),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
726
819
  `)}
727
820
  error: could not restore untracked files from stash
728
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ra(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
729
- `,exitCode:128};let n=await Nr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
821
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function va(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 Fr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
730
823
  `,exitCode:1};if(!await Y(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
731
- `,exitCode:1};let o=await z(e),s=Wt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
824
+ `,exitCode:1};let o=await K(e),s=Kt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
732
825
  `)}
733
826
  `,stderr:`error: could not write index
734
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)
735
- `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Ne(o),d=await Fe(e,l),m={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let k=await Ea(e,f);if(!k.ok)return{...k,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let u=await Bt(e,c.tree,d,i.tree,m),h=await le(e,d),p=await le(e,u.resultTree),g=[];for(let[k,C]of p){let P=h.get(k);(!P||P.hash!==C.hash)&&g.push({path:k,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[k]of h)p.has(k)||g.push({path:k,type:"delete"});let w=new Map(l.map(k=>[k.path,k])),R=[],x=[];for(let k of g){let C=w.get(k.path),P=H(e.workTree,k.path);if(C){if(!await e.fs.exists(P))continue;let I=await e.fs.readFileBuffer(P);await pt("blob",I)!==C.hash&&R.push(k.path)}else k.type==="checkout"&&await e.fs.exists(P)&&x.push(k.path)}if(R.length>0||x.length>0){R.sort(ka),x.sort(ka);let k="";if(R.length>0&&(k+=`error: Your local changes to the following files would be overwritten by merge:
736
- ${R.map(C=>` ${C}`).join(`
828
+ `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Le(o),d=await Fe(e,l),h={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let E=await Sa(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 zt(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(!await e.fs.exists($))continue;let H=await e.fs.readFileBuffer($);await gt("blob",H)!==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(Ta),y.sort(Ta);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(`
737
830
  `)}
738
831
  Please commit your changes or stash them before you merge.
739
- `),x.length>0&&(k+=`error: The following untracked working tree files would be overwritten by merge:
740
- ${x.map(C=>` ${C}`).join(`
832
+ `),y.length>0&&(E+=`error: The following untracked working tree files would be overwritten by merge:
833
+ ${y.map(C=>` ${C}`).join(`
741
834
  `)}
742
835
  Please move or remove them before you merge.
743
- `),k+=`Aborting
744
- `,f){let C=await Ea(e,f);C.ok||(k+=C.stderr)}return{ok:!1,stdout:"",stderr:k,exitCode:1}}await De(e,g);let b=new Set(u.conflicts.map(k=>k.path)),y=new Set;for(let k of u.entries)k.stage>0&&y.add(k.path);let E=b.size>0;if(E){let k=[];for(let[C,P]of p){if(b.has(C)||y.has(C))continue;let I=w.get(C);k.push({path:C,mode:parseInt(P.mode,8),hash:P.hash,stage:0,stat:I?.stat??Se()})}for(let C of u.entries)C.stage>0&&k.push(C);k.sort((C,P)=>Ie(C.path,P.path)||C.stage-P.stage),await fe(e,{version:2,entries:k})}else{let k=[...o.entries],C=new Set(k.map(P=>P.path));for(let[P,I]of p)h.has(P)||C.has(P)||k.push({path:P,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:Se()});k.sort((P,I)=>Ie(P.path,I.path)||P.stage-I.stage),await fe(e,{version:2,entries:k})}if(f){let k=await Ea(e,f);if(!k.ok)return{...k,messages:u.messages}}return{ok:!0,hasConflicts:E,messages:u.messages}}async function xa(e,t=0){let n=await et(e,Qt);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await he(e,Qt),await rs(e,Qt);else{await Ln(e,Qt,n);let o=n[n.length-1];o&&await Z(e,Qt,o.newHash)}return null}async function wd(e){await he(e,Qt),await rs(e,Qt)}Ae();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 pw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return Tt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function yd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":$().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:bd(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:bd(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:gw(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:ww(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:bw(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:yw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:$().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:Ew(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:kw(s)}})}async function bd(e,t,n,r){if(!await Y(e))return G(`You do not have the initial commit yet
745
- `);let s=await z(e),i=Wt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
836
+ `),E+=`Aborting
837
+ `,f){let C=await Sa(e,f);C.ok||(E+=C.stderr)}return{ok:!1,stdout:"",stderr:E,exitCode:1}}await Me(e,g);let R=new Set(u.conflicts.map(E=>E.path)),x=new Set;for(let E of u.entries)E.stage>0&&x.add(E.path);let k=R.size>0;if(k){let E=[];for(let[C,$]of p){if(R.has(C)||x.has(C))continue;let H=w.get(C);E.push({path:C,mode:parseInt($.mode,8),hash:$.hash,stage:0,stat:H?.stat??Se()})}for(let C of u.entries)C.stage>0&&E.push(C);E.sort((C,$)=>Ie(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[$,H]of p)m.has($)||C.has($)||E.push({path:$,mode:parseInt(H.mode,8),hash:H.hash,stage:0,stat:Se()});E.sort(($,H)=>Ie($.path,H.path)||$.stage-H.stage),await ae(e,{version:2,entries:E})}if(f){let E=await Sa(e,f);if(!E.ok)return{...E,messages:u.messages}}return{ok:!0,hasConflicts:k,messages:u.messages}}async function Ha(e,t=0){let n=await et(e,tn);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,tn),await ss(e,tn);else{await Nn(e,tn,n);let o=n[n.length-1];o&&await Z(e,tn,o.newHash)}return null}async function vd(e){await me(e,tn),await ss(e,tn)}He();function Xo(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 Sw(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 Ad(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:V.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 q(o.fs,o.cwd,t);return M(s)?s:Hd(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Hd(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:[z.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 M(s)?s:Tw(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[z.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 M(s)?s:vw(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 M(s)?s:Hw(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[z.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 M(s)?s:Aw(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:[z.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 M(s)?s:Dw(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 M(s)?s:Mw(s)}})}async function Hd(e,t,n,r){if(!await Y(e))return N(`You do not have the initial commit yet
838
+ `);let s=await K(e),i=Kt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
746
839
  `)}
747
840
  `,stderr:`error: could not write index
748
- `,exitCode:1};let a;try{a=await gd(e,t,n,{includeUntracked:r})}catch(l){return O(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 Td(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()}
749
842
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
750
- `,stderr:"",exitCode:0}}async function gw(e,t){let n=qo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Nr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await Ra(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
843
+ `,stderr:"",exitCode:0}}async function Tw(e,t){let n=Xo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await Fr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await va(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
751
844
  `)}
752
845
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
753
- `,stderr:o.stderr,exitCode:o.exitCode};let l=await at(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 it(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
754
847
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
755
848
  `)}
756
- `:"",l=await at(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
757
- `,stderr:"",exitCode:1}}let s=await xa(e,n);if(s)return G(s);let i=o.messages.length>0?`${o.messages.join(`
849
+ `:"",l=await it(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
850
+ `,stderr:"",exitCode:1}}let s=await Ha(e,n);if(s)return N(s);let i=o.messages.length>0?`${o.messages.join(`
758
851
  `)}
759
- `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await at(e);return{stdout:`${i}${c}Dropped ${a} (${r})
760
- `,stderr:"",exitCode:0}}async function ww(e,t){let n=qo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Ra(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
852
+ `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await it(e);return{stdout:`${i}${c}Dropped ${a} (${r})
853
+ `,stderr:"",exitCode:0}}async function vw(e,t){let n=Xo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await va(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
761
854
  `)}
762
- `:"",c=r.stdout;return c||(c=await at(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 it(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
763
856
  `)}
764
- `:"",s=await at(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function bw(e){let t=await pd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
857
+ `:"",s=await it(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Hw(e){let t=await Sd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
765
858
  `)}
766
- `,stderr:"",exitCode:0}}async function yw(e,t){let n=qo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Nr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await xa(e,n);return o?G(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
767
- `,stderr:"",exitCode:0}}async function Ew(e,t,n){let r=qo(t);if(r<0)return G(`error: '${t}' is not a valid stash reference`);let o=await Nr(e,r);if(!o)return G(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return G("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await pw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await hn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function kw(e){return await wd(e),{stdout:"",stderr:"",exitCode:0}}ie();Be();Ce();we();tt();function Ed(e,t){e.command("status",{description:"Show the working tree status",options:{short:$().alias("s").describe("Give the output in the short-format"),porcelain:$().describe("Give the output in a machine-parseable format"),branch:$().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 at(s),stderr:"",exitCode:0};let i=await Q(s),a=await Y(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let x=await pe(s),b=await Jt(s,x,c);f=$w(c,b)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await z(s),d=_i(l),m=await Ni(s,a,l,d),u=await gt(s,l),h=[],p=[];for(let x of u)x.status==="untracked"?p.push(x.path):h.push({path:x.path,status:x.status});h.sort((x,b)=>Ie(x.path,b.path));let g=new Set(l.entries.map(x=>x.path)),w=Fi(p,g);return{stdout:Pw(f,m,h,d,w),stderr:"",exitCode:0}}})}var Rw={"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 xw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Cw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function Pw(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 m=i.get(d);if(m){let w=Rw[m.status]??"UU";s.push(`${w} ${$s(d)}`);continue}let u=a.get(d),h=c.get(d),p=u?xw(u.status):" ",g=h?Cw(h.status):" ";if(u?.status==="renamed"&&u.displayPath){let w=u.displayPath.indexOf(" -> "),R=u.displayPath.slice(0,w),x=u.displayPath.slice(w+4);s.push(`${p}${g} ${$s(R)} -> ${$s(x)}`)}else s.push(`${p}${g} ${$s(d)}`)}for(let d of o)s.push(`?? ${$s(d)}`);return s.length===0?"":`${s.join(`
859
+ `,stderr:"",exitCode:0}}async function Aw(e,t){let n=Xo(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await Fr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await Ha(e,n);return o?N(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
860
+ `,stderr:"",exitCode:0}}async function Dw(e,t,n){let r=Xo(t);if(r<0)return N(`error: '${t}' is not a valid stash reference`);let o=await Fr(e,r);if(!o)return N(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return N("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 Sw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await pn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function Mw(e){return await vd(e),{stdout:"",stderr:"",exitCode:0}}oe();Be();Ce();we();tt();function Dd(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 q(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 Y(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let y=await he(s),R=await Bt(s,y,c);f=_w(c,R)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await K(s),d=Yi(l),h=await Vi(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,R)=>Ie(y.path,R.path));let g=new Set(l.entries.map(y=>y.path)),w=Xi(p,g);return{stdout:Nw(f,h,m,d,w),stderr:"",exitCode:0}}})}var jw={"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 Gw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Lw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function Nw(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=jw[h.status]??"UU";s.push(`${w} ${Os(d)}`);continue}let u=a.get(d),m=c.get(d),p=u?Gw(u.status):" ",g=m?Lw(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} ${Os(b)} -> ${Os(y)}`)}else s.push(`${p}${g} ${Os(d)}`)}for(let d of o)s.push(`?? ${Os(d)}`);return s.length===0?"":`${s.join(`
768
861
  `)}
769
- `}function $w(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=uo(t,!1);return r?`${n} ${r}`:n}function $s(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}ie();Be();Ce();ce();ze();we();Ae();Xt();function Ow(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ee}function Rd(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:V.string().alias("c").describe("Create and switch to a new branch"),forceCreate:V.string().alias("C").describe("Create/reset and switch to a branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:V.string().describe("Create a new orphan branch"),guess:$().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?O("--orphan and -c/-C are incompatible"):n.detach?O("--orphan and --detach are incompatible"):Tw(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return O("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await je(i,l,`invalid reference: ${l}`);return M(d)?d:Sw(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 kd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return O("missing branch or commit argument");if(a==="-")return Iw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return xd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await bo(i,a);if(l)return kd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return O(`invalid reference: ${a}`)}})}async function Os(e){return await $e(e,"CHERRY_PICK_HEAD")?O(`cannot switch branch while cherry-picking
770
- Consider "git cherry-pick --quit" or "git worktree add".`):await $e(e,"MERGE_HEAD")?O(`cannot switch branch while merging
771
- Consider "git merge --quit" or "git worktree add".`):await $e(e,"REVERT_HEAD")?O(`cannot switch branch while reverting
772
- Consider "git revert --quit" or "git worktree add".`):await _t(e)?O(`cannot switch branch while rebasing
773
- Consider "git rebase --quit" or "git worktree add".`):null}async function Iw(e,t,n){let r=await Os(e);if(r)return r;let o=await mo(e);return o?xd(e,o.name,o.refName,o.hash,t,n):O("no previous branch")}async function kd(e,t,n,r,o,s,i){if(!bn(t))return O(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return O(`a branch named '${t}' already exists`);let f;if(r){let I=await je(e,r,`invalid reference: ${r}`);if(M(I))return I;f=I.hash}else{let I=await Y(e);if(!I){let v=await Q(e),T=v?.type==="symbolic"?v.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Xe(e,"HEAD",a),await yt(e);let N=await xn(e);return await oe(e,o,"HEAD",null,ee,`checkout: moving from ${T} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
774
- ${N}`,exitCode:0}}f=I}let l=await Os(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(d))return{stdout:"",stderr:d.message??"",exitCode:1};let m=await Y(e),u=await z(e);if(r){let I=qn(u);if(I)return I}let h=await j(e,f);if(m&&m!==f){let I=await j(e,m);if(I.tree!==h.tree){let v=await Fn(e,I.tree,h.tree,u);if(!v.success)return v.errorOutput??G("error: checkout would overwrite local changes");u={version:2,entries:v.newEntries},await fe(e,u),await De(e,v.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&m&&(g=await go(e,m,f));let w=Ow(p,m);await Z(e,a,f),await Xe(e,"HEAD",a),await yt(e);let R=await xn(e),x=r??"HEAD";n&&c?c!==f&&await oe(e,o,a,c,f,`branch: Reset to ${x}`):await oe(e,o,a,null,f,`branch: Created from ${x}`),await oe(e,o,"HEAD",m,f,`checkout: moving from ${w} to ${t}`);let b="";if(i){let I=i.replace(/^refs\/remotes\//,"").split("/"),v=I[0]??"",T=`refs/heads/${I.slice(1).join("/")}`,N=await pe(e);N[`branch "${t}"`]={...N[`branch "${t}"`],remote:v,merge:T},await Je(e,N),b=`branch '${t}' set up to track '${v}/${I.slice(1).join("/")}'.
775
- `}else r&&(b=await wo(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:m,newHead:f,isBranchCheckout:!0});let y=n&&c?`Switched to and reset branch '${t}'
862
+ `}function _w(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=bo(t,!1);return r?`${n} ${r}`:n}function Os(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();He();Jt();function Fw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ee}function jd(e,t){e.command("switch",{description:"Switch branches",args:[z.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:V.string().alias("c").describe("Create and switch to a new branch"),forceCreate:V.string().alias("C").describe("Create/reset and switch to a branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:V.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 q(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"):Ww(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 Ge(i,l,`invalid reference: ${l}`);return M(d)?d:Bw(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 Md(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return T("missing branch or commit argument");if(a==="-")return Uw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Gd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await Co(i,a);if(l)return Md(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return T(`invalid reference: ${a}`)}})}async function Is(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 Uw(e,t,n){let r=await Is(e);if(r)return r;let o=await yo(e);return o?Gd(e,o.name,o.refName,o.hash,t,n):T("no previous branch")}async function Md(e,t,n,r,o,s,i){if(!yn(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 C=await Ge(e,r,`invalid reference: ${r}`);if(M(C))return C;f=C.hash}else{let C=await Y(e);if(!C){let $=await Q(e),H=$?.type==="symbolic"?$.target.replace(/^refs\/heads\//,""):"";n&&c&&await me(e,a),await Ze(e,"HEAD",a),await Et(e);let P=await Pn(e);return await se(e,o,"HEAD",null,ee,`checkout: moving from ${H} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
867
+ ${P}`,exitCode:0}}f=C}let l=await Is(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 Y(e),u=await K(e);if(r){let C=zn(u);if(C)return C}let m=await j(e,f);if(h&&h!==f){let C=await j(e,h);if(C.tree!==m.tree){let $=await Fn(e,C.tree,m.tree,u);if(!$.success)return $.errorOutput??N("error: checkout would overwrite local changes");u={version:2,entries:$.newEntries},await ae(e,u),await Me(e,$.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&h&&(g=await Ro(e,h,f));let w=Fw(p,h);await Z(e,a,f),await Ze(e,"HEAD",a),await Et(e);let b=await Pn(e),y=r??"HEAD";n&&c?c!==f&&await se(e,o,a,c,f,`branch: Reset to ${y}`):await se(e,o,a,null,f,`branch: Created from ${y}`),await se(e,o,"HEAD",h,f,`checkout: moving from ${w} to ${t}`);let R="";if(i){let C=i.replace(/^refs\/remotes\//,"").split("/"),$=C[0]??"",H=`refs/heads/${C.slice(1).join("/")}`,P=await he(e);P[`branch "${t}"`]={...P[`branch "${t}"`],remote:$,merge:H},await Xe(e,P),R=`branch '${t}' set up to track '${$}/${C.slice(1).join("/")}'.
868
+ `}else r&&(R=await xo(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:h,newHead:f,isBranchCheckout:!0});let x=n&&c?`Switched to and reset branch '${t}'
776
869
  `:`Switched to a new branch '${t}'
777
- `,E=g+y+R+b,k="";r&&(k=await lr(e,h.tree,u));let C=await pe(e),P=await Jt(e,C,t);return P&&(k+=fr(P)),{stdout:k,stderr:E,exitCode:0}}async function xd(e,t,n,r,o,s){let i=await Os(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return de(a)?{stdout:"",stderr:a.message??"",exitCode:1}:dr(e,t,n,r,o,s)}async function Sw(e,t,n,r,o){let s=await Os(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return de(i)?{stdout:"",stderr:i.message??"",exitCode:1}:zn(e,n,r,o)}async function Tw(e,t,n,r){if(!bn(t))return O(`'${t}' is not a valid branch name`);let o=await Os(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return O(`a branch named '${t}' already exists`);let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Ui(e,f)),e.workTree){let u=f?(await j(e,f)).tree:null,h=await Fe(e,[]),p=await Fn(e,u,h,a);if(!p.success)return p.errorOutput??G("error: checkout would overwrite local changes");await De(e,p.worktreeOps),await fe(e,{version:2,entries:p.newEntries})}else await fe(e,Va());await Xe(e,"HEAD",s),await yt(e);let m=await xn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ee,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
778
- ${m}`,exitCode:0}}ie();ce();Pr();we();is();function Pd(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:$().alias("a").describe("Make an annotated tag object"),message:V.string().alias("m").describe("Tag message"),delete:$().alias("d").describe("Delete a tag"),force:$().alias("f").describe("Replace an existing tag"),list:$().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 O("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 ${X(a)})
779
- `,stderr:"",exitCode:0}):G(`error: tag '${n.name}' not found.
780
- `)}if(n.list)return Cd(s,n.name||void 0);if(n.name){if(!Tc(n.name))return O(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await wt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Y(s),!a)return O("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return O(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return O("no tag message specified (use -m)");let d=await nt(s,r.env);if(M(d))return d;let m=Gt(n.message),u=$c({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:m}),h=await He(s,"tag",u);await Z(s,c,h)}else await Z(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Cd(s)}})}async function Cd(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=>cn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
870
+ `,k=g+x+b,E="";if(R)E=R;else if(r){E=await dr(e,m.tree,u);let C=await he(e),$=await Bt(e,C,t);$&&(E+=qn($))}else if(n&&c){let C=await he(e),$=await Bt(e,C,t);$&&(E=qn($))}return{stdout:E,stderr:k,exitCode:0}}async function Gd(e,t,n,r,o,s){let i=await Is(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}:ur(e,t,n,r,o,s)}async function Bw(e,t,n,r,o){let s=await Is(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}:Kn(e,n,r,o)}async function Ww(e,t,n,r){if(!yn(t))return T(`'${t}' is not a valid branch name`);let o=await Is(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 K(e),c=zn(a);if(c)return c;let f=await Y(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Zi(e,f)),e.workTree){let u=f?(await j(e,f)).tree:null,m=await Fe(e,[]),p=await Fn(e,u,m,a);if(!p.success)return p.errorOutput??N("error: checkout would overwrite local changes");await Me(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,oc());await Ze(e,"HEAD",s),await Et(e);let h=await Pn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ee,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
871
+ ${h}`,exitCode:0}}oe();ie();$r();we();as();function Nd(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[z.string().name("name").describe("Tag name to create or delete").optional(),z.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:S().alias("a").describe("Make an annotated tag object"),message:V.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 q(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 ${X(a)})
872
+ `,stderr:"",exitCode:0}):N(`error: tag '${n.name}' not found.
873
+ `)}if(n.list)return Ld(s,n.name||void 0);if(n.name){if(!Fc(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 Y(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=Gc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:h}),m=await De(s,"tag",u);await Z(s,c,m)}else await Z(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Ld(s)}})}async function Ld(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(`
781
874
  `)}
782
- `,stderr:"",exitCode:0}}var $d=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"]),vw={init:(e,t)=>jl(e,t),clone:(e,t)=>fl(e,t),describe:(e,t)=>dl(e,t),fetch:(e,t)=>Ol(e,t),pull:(e,t)=>td(e,t),push:(e,t)=>nd(e,t),add:(e,t)=>Xc(e,t),blame:(e,t)=>Tf(e,t),commit:(e,t)=>ul(e,t),status:(e,t)=>Ed(e,t),log:(e,t)=>zl(e,t),branch:(e,t)=>Af(e,t),tag:(e,t)=>Pd(e,t),checkout:(e,t)=>Df(e,t),diff:(e,t)=>Rl(e,t),reset:(e,t)=>id(e,t),merge:(e,t)=>Yl(e,t),"cherry-pick":(e,t)=>Vf(e,t),revert:(e,t)=>ld(e,t),rebase:(e,t)=>ed(e,t),mv:(e,t)=>Xl(e,t),rm:(e,t)=>dd(e,t),remote:(e,t)=>sd(e,t),config:(e,t)=>gl(e,t),show:(e,t)=>ud(e,t),stash:(e,t)=>yd(e,t),"rev-parse":(e,t)=>fd(e,t),"ls-files":(e,t)=>Vl(e,t),clean:(e,t)=>Yf(e,t),switch:(e,t)=>Rd(e,t),restore:(e,t)=>cd(e,t),reflog:(e,t)=>rd(e,t),repack:(e,t)=>Tl(e,t),gc:(e,t)=>vl(e,t),bisect:(e,t)=>gf(e,t),grep:(e,t)=>Ml(e,t)};function Od(e){let t=Zo("git",{description:"Git command"});for(let n of Object.values(vw))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:yr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:yr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
783
- `,exitCode:1}}}),t}var Aw="1.5.7";function Hw(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 zo=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=Hw(t?.identity,t?.config),o={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}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Od(o).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=Dw(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 ${Aw} (virtual git implementation)
875
+ `,stderr:"",exitCode:0}}var _d=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"]),qw={init:(e,t)=>Yl(e,t),clone:(e,t)=>Rl(e,t),describe:(e,t)=>Cl(e,t),fetch:(e,t)=>_l(e,t),pull:(e,t)=>md(e,t),push:(e,t)=>gd(e,t),add:(e,t)=>lf(e,t),blame:(e,t)=>Bf(e,t),commit:(e,t)=>Pl(e,t),status:(e,t)=>Dd(e,t),log:(e,t)=>od(e,t),branch:(e,t)=>qf(e,t),tag:(e,t)=>Nd(e,t),checkout:(e,t)=>Kf(e,t),diff:(e,t)=>Ml(e,t),reset:(e,t)=>Ed(e,t),merge:(e,t)=>cd(e,t),"cherry-pick":(e,t)=>al(e,t),revert:(e,t)=>Cd(e,t),rebase:(e,t)=>hd(e,t),mv:(e,t)=>fd(e,t),rm:(e,t)=>Pd(e,t),remote:(e,t)=>bd(e,t),config:(e,t)=>Sl(e,t),show:(e,t)=>$d(e,t),stash:(e,t)=>Ad(e,t),"rev-parse":(e,t)=>xd(e,t),"ls-files":(e,t)=>ad(e,t),clean:(e,t)=>cl(e,t),switch:(e,t)=>jd(e,t),restore:(e,t)=>Rd(e,t),reflog:(e,t)=>wd(e,t),repack:(e,t)=>Bl(e,t),gc:(e,t)=>Wl(e,t),bisect:(e,t)=>Sf(e,t),grep:(e,t)=>Vl(e,t)};function Fd(e){let t=ii("git",{description:"Git command"});for(let n of Object.values(qw))n(t,e);return t.command("help",{description:"Display help information",args:[z.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Er(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Er(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
876
+ `,exitCode:1}}}),t}var zw="1.5.8";function Kw(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 Zo=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=Kw(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=Fd(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=Vw(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)
784
877
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
785
- `,exitCode:1};if(r&&$d.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
786
- `,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(de(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 Dw(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 Mw(e){return new zo(e)}var Id=new TextEncoder,jw=new TextDecoder;function pn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function Ko(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ca=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=pn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Id.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=Ko(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 pn(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("/")?pn(a):pn(Ko(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=pn(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("/")?pn(f):pn(Ko(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return jw.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"?Id.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=pn(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=Ko(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=pn(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=pn(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})}};Gn();export{zo as Git,Ca as MemoryFileSystem,vh as composeGitHooks,Mw as createGit,tr as findRepo,de as isRejection};
878
+ `,exitCode:1};if(r&&_d.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 Vw(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 Yw(e){return new Zo(e)}var Ud=new TextEncoder,Xw=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 Jo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Aa=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"?Ud.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=Jo(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(Jo(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(Jo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Xw.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"?Ud.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=Jo(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})}};Ln();export{Zo as Git,Aa as MemoryFileSystem,Wm as composeGitHooks,Yw as createGit,rr as findRepo,fe as isRejection};