just-git 1.2.11 → 1.2.13

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 wd=Object.defineProperty;var $s=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ee=(e,t)=>()=>(e&&(t=e(e=0)),t);var bd=(e,t)=>{for(var n in t)wd(e,n,{get:t[n],enumerable:!0})};function vs(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function T(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":vs(t)}function $t(...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 vs(t||".")}function Jt(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 Lr(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 ft(e,t){let n=vs(e),r=vs(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 le=Ee(()=>{"use strict"});function Vo(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 Ma(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 xd(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=Vo(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}=Ma(l,r,o);a[f]=d,o+=m}continue}o++}return t}function Yo(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=Vo(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}=Ma(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=m}continue}o++}return t}function Xo(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 Zo(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} = ${Xo(s)}`)}return`${t.join(`
6
- `)}
7
- `}function Jo(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=Vo(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 Pd(e,t,n,r){let o=e.split(`
8
- `),s=Jo(o,t,n),i=` ${n} = ${Xo(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 Cd(e,t,n){let r=e.split(`
10
- `),o=Jo(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=T(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return xd(n)}async function Hs(e){let t=T(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Ye(e,t){let n=T(e.gitDir,"config");await e.fs.writeFile(n,Zo(t))}async function ke(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await he(e),{section:s,key:i}=Nr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function Qo(e,t,n){let r=await Hs(e),{section:o,key:s}=Nr(t),i=Pd(r,o,s,n),a=T(e.gitDir,"config");await e.fs.writeFile(a,i)}async function ja(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Hs(e);if(o){let i=Yo(o),{section:a,key:c}=Nr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function Od(e,t,n,r){let o=e.split(`
12
- `),s=Jo(o,t,n),i=` ${n} = ${Xo(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 Ga(e,t,n){let r=await Hs(e),{section:o,key:s}=Nr(t),i=Od(r,o,s,n),a=T(e.gitDir,"config");await e.fs.writeFile(a,i)}async function La(e,t){let n=await Hs(e),{section:r,key:o}=Nr(t),s=Cd(n,r,o);if(!s.found)return!1;let i=T(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Nr(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 _e=Ee(()=>{"use strict";le()});function As(e,t){return Na(e,t,"author")}function _r(e,t){return Na(e,t,"committer")}async function Na(e,t,n){let r=$d[n],o=e.identityOverride,{timestamp:s,timezone:i}=Id(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 ke(e,"user.name")??o?.name,c=t.get(r.email)??await ke(e,"user.email")??o?.email;if(!a||!c)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
1
+ var Od=Object.defineProperty;var Os=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Sd=(e,t)=>{for(var n in t)Od(e,n,{get:t[n],enumerable:!0})};function Ts(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function I(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Ts(t)}function vt(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return Ts(t||".")}function Jt(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 _r(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=Ts(e),r=Ts(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 Xo(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 ja(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 Ad(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=Xo(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}=ja(l,r,o);a[f]=d,o+=m}continue}o++}return t}function Zo(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=Xo(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}=ja(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=m}continue}o++}return t}function Jo(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 Qo(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} = ${Jo(s)}`)}return`${t.join(`
6
+ `)}
7
+ `}function ei(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=Xo(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 Dd(e,t,n,r){let o=e.split(`
8
+ `),s=ei(o,t,n),i=` ${n} = ${Jo(r)}`;return s.keyStart!==-1?o.splice(s.keyStart,s.keyEnd-s.keyStart+1,i):s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
9
+ `)}function Md(e,t,n){let r=e.split(`
10
+ `),o=ei(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 ge(e){let t=I(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Ad(n)}async function Hs(e){let t=I(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Ze(e,t){let n=I(e.gitDir,"config");await e.fs.writeFile(n,Qo(t))}async function xe(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await ge(e),{section:s,key:i}=Fr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function ti(e,t,n){let r=await Hs(e),{section:o,key:s}=Fr(t),i=Dd(r,o,s,n),a=I(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Ga(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Hs(e);if(o){let i=Zo(o),{section:a,key:c}=Fr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function jd(e,t,n,r){let o=e.split(`
12
+ `),s=ei(o,t,n),i=` ${n} = ${Jo(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 La(e,t,n){let r=await Hs(e),{section:o,key:s}=Fr(t),i=jd(r,o,s,n),a=I(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Na(e,t){let n=await Hs(e),{section:r,key:o}=Fr(t),s=Md(n,r,o);if(!s.found)return!1;let i=I(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Fr(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 We=Re(()=>{"use strict";me()});function As(e,t){return _a(e,t,"author")}function Ur(e,t){return _a(e,t,"committer")}async function _a(e,t,n){let r=Gd[n],o=e.identityOverride,{timestamp:s,timezone:i}=Ld(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,95 +18,97 @@ 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 Qt(e,t){try{let n=await _r(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 Id(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:Sd(n)}}function Sd(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 $d,$n=Ee(()=>{"use strict";_e();$d={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 In(e){let t="";for(let n=0;n<20;n++)t+=_a[e[n]];return t}function Fr(e,t){let n="";for(let r=0;r<20;r++)n+=_a[e[t+r]];return n}function It(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var te,_a,dt=Ee(()=>{"use strict";te="0000000000000000000000000000000000000000",_a=(()=>{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 Fa(e){return e.length===4&&e.toLowerCase()===".git"}function Zn(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===".."||Fa(n))return!1;return!0}function Ds(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function Ua(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||Fa(n))return!1;return!0}var Ms=Ee(()=>{"use strict"});function ei(e){return typeof e=="string"?Td.encode(e):e}function vd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(ei(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=$s(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(ei(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(ei(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 In(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 Tn(e){return Ba().update(e).hex()}var Td,Ba,Sn,Jn=Ee(()=>{"use strict";dt();Td=new TextEncoder;Ba=vd(),Sn=Ba});async function K(e){let t=T(e.gitDir,"index");if(!await e.fs.exists(t))return{version:ti,entries:[]};let n=await e.fs.readFileBuffer(t);return Hd(n)}async function ae(e,t){let n=T(e.gitDir,"index"),r=await Ad(t);await e.fs.writeFile(n,r)}function Et(e,t){if(!Zn(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(ni),{...e,entries:n}}function at(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function js(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function St(e){return e.entries.some(t=>t.stage>0)}function Bt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function De(e){return e.entries.filter(t=>t.stage===0)}function qa(){return{version:ti,entries:[]}}function Gs(e){let t=[...e].sort(ni);return{version:ti,entries:t}}function $e(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Hd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Wa)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=In(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 y=62+g+1,x=Math.ceil(y/8)*8;n=c+x,i.push({path:w,mode:l,hash:m,stage:h,stat:f})}return{version:o,entries:i}}async function Ad(e){let t=new TextEncoder,n=[...e.entries].sort(ni),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,Wa),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=It(u.hash);i.set(g,c),c+=20;let w=Math.min(h.byteLength,4095),y=(u.stage&3)<<12|w;a.setUint16(c,y),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 Tn(f),d=It(l);return i.set(d,c),i}function ni(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Wa,ti,Ce=Ee(()=>{"use strict";dt();Ms();le();Jn();Wa=1145655875,ti=2});var Dd,Ls,za=Ee(()=>{"use strict";Dd=new Set(["tree","commit","tag"]),Ls=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(!Dd.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 ri(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Ka[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Ka,Va=Ee(()=>{"use strict";Ka=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;Ka[e]=t}});function rc(e){let t=nc(e);return tc(e.subarray(t,-4),{i:2})}function ai(e){let t=nc(e),n={i:2},r=tc(e.subarray(t),n),o=ec(n.p);return{result:r,bytesConsumed:t+o+4}}var qt,br,Md,Ya,Xa,jd,Za,Ja,Gd,ii,Ur,Br,Qa,Ld,Nd,si,Wt,oi,ec,_d,en,tc,nc,sc=Ee(()=>{"use strict";qt=Uint8Array,br=Uint16Array,Md=Int32Array,Ya=new qt([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]),Xa=new qt([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]),jd=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Za=(e,t)=>{let n=new br(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new Md(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:Ja}=Za(Ya,2);Ja[28]=258;({b:Gd}=Za(Xa,0)),ii=new br(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,ii[e]=((t&65280)>>8|(t&255)<<8)>>1}Ur=(e,t,n)=>{let r=e.length,o=0,s=new br(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new br(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new br(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[ii[d]>>c]=f}}else for(a=new br(r),o=0;o<r;++o)e[o]&&(a[o]=ii[i[e[o]-1]++]>>15-e[o]);return a},Br=new qt(288);for(let e=0;e<144;++e)Br[e]=8;for(let e=144;e<256;++e)Br[e]=9;for(let e=256;e<280;++e)Br[e]=7;for(let e=280;e<288;++e)Br[e]=8;Qa=new qt(32);for(let e=0;e<32;++e)Qa[e]=5;Ld=Ur(Br,9,1),Nd=Ur(Qa,5,1),si=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Wt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},oi=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},ec=e=>(e+7)/8|0,_d=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))),en=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},tc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new qt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new qt(o*3));let f=y=>{let x=n.length;if(y>x){let b=new qt(Math.max(x*2,y));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=Wt(e,d,1);let k=Wt(e,d+1,3);if(d+=3,k)if(k==1)u=Ld,h=Nd,p=9,g=5;else if(k==2){let E=Wt(e,d,31)+257,R=Wt(e,d+10,15)+4,C=E+Wt(e,d+5,31)+1;d+=14;let P=new qt(C),v=new qt(19);for(let S=0;S<R;++S)v[jd[S]]=Wt(e,d+S*3,7);d+=R*3;let D=si(v),O=(1<<D)-1,H=Ur(v,D,1);for(let S=0;S<C;){let _=H[Wt(e,d,O)];d+=_&15;let B=_>>4;if(B<16)P[S++]=B;else{let z=0,N=0;for(B==16?(N=3+Wt(e,d,3),d+=2,z=P[S-1]):B==17?(N=3+Wt(e,d,7),d+=3):B==18&&(N=11+Wt(e,d,127),d+=7);N--;)P[S++]=z}}let G=P.subarray(0,E),A=P.subarray(E);p=si(G),g=si(A),u=Ur(G,p,1),h=Ur(A,g,1)}else en(1);else{let E=ec(d)+4,R=e[E-4]|e[E-3]<<8,C=E+R;if(C>o){c&&en(0);break}a&&f(m+R),n.set(e.subarray(E,C),m),t.b=m+=R,t.p=d=C*8,t.f=l;continue}if(d>w){c&&en(0);break}}a&&f(m+131072);let y=(1<<p)-1,x=(1<<g)-1,b=d;for(;;b=d){let k=u[oi(e,d)&y],E=k>>4;if(d+=k&15,d>w){c&&en(0);break}if(k||en(2),E<256)n[m++]=E;else if(E==256){b=d,u=null;break}else{let R=E-254;if(E>264){let O=E-257,H=Ya[O];R=Wt(e,d,(1<<H)-1)+Ja[O],d+=H}let C=h[oi(e,d)&x],P=C>>4;C||en(3),d+=C&15;let v=Gd[P];if(P>3){let O=Xa[P];v+=oi(e,d)&(1<<O)-1,d+=O}if(d>w){c&&en(0);break}a&&f(m+131072);let D=m+R;if(m<v){let O=s-v,H=Math.min(v,D);for(O+m<0&&en(3);m<H;++m)n[m]=r[O+m]}for(;m<D;++m)n[m]=n[m-v]}}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?_d(n,0,m):n.subarray(0,m)},nc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&en(0,"invalid zlib data"),e[1]&32&&en(0,"zlib dictionaries are not supported"),2)});async function Fd(){let e;if(!(typeof document<"u"))try{e=$s(["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??ai}}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:rc,inflateWithConsumed:ai}}function ci(){return Ud??=Fd()}async function Wr(e){return await(await ci()).deflateSync(e)}async function yr(e){return await(await ci()).inflateSync(e)}async function oc(e,t){let n=await ci(),{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 Ud,Ns=Ee(()=>{"use strict";sc();Ud=null});async function hc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==li)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${li.toString(16)})`);let o=n.getUint32(4);if(o!==fc)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Fr(e,e.byteLength-20),l=Sn();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 qd(e,a);i.push(l),a=l.nextOffset}return(await zd(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function qd(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===qr){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===di&&(c=Fr(e,t),t+=20);let{result:f,bytesConsumed:l}=await oc(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function zd(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>ic)throw new Error(`delta chain depth ${i} exceeds limit of ${ic}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==qr&&c.typeNum!==di){let u=Bd[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let h={type:u,content:c.inflated,hash:await fi(u,c.inflated)};return r[s]=h,h}if(c.typeNum===qr){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=zr(h.content,c.inflated),g={type:h.type,content:p,hash:await fi(h.type,p)};return r[s]=g,g}let f=await Kd(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=zr(l.content,c.inflated),m={type:l.type,content:d,hash:await fi(l.type,d)};return r[s]=m,m}for(let s=0;s<e.length;s++)await o(s);return r}async function Kd(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==qr&&s.typeNum!==di&&(await r(o)).hash===n)return o}}function zr(e,t){let n=0,{value:r,newPos:o}=cc(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}=cc(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 _s(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,li),o.setUint32(4,fc),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=ac(qr,a.delta.byteLength),d=Yd(s-f),m=await Wr(a.delta);t.push(l,d,m),s+=l.byteLength+d.byteLength+m.byteLength}else{let l=Wd[a.type],d=ac(l,a.content.byteLength),m=await Wr(a.content);t.push(d,m),s+=d.byteLength+m.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Vd(t),entries:i}}async function Vd(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=Sn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(It(s),r),n}function Yd(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 ac(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 cc(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 fi(e,t){let n=Xd.encode(`${e} ${t.byteLength}\0`),r=Sn();return r.update(n),r.update(t),r.hex()}var li,fc,lc,dc,uc,mc,qr,di,Bd,Wd,ic,Xd,Kr=Ee(()=>{"use strict";dt();Jn();Ns();li=1346454347,fc=2,lc=1,dc=2,uc=3,mc=4,qr=6,di=7,Bd={[lc]:"commit",[dc]:"tree",[uc]:"blob",[mc]:"tag"},Wd={commit:lc,tree:dc,blob:uc,tag:mc};ic=50;Xd=new TextEncoder});async function wc(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,pc),c+=4,a.setUint32(c,gc),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(It(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=Sn();d.update(i.subarray(0,c));let m=await d.hex();return i.set(It(m),c),i}async function bc(e){let n=(await hc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:ri(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return wc(n,r)}async function yc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:ri(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return wc(n,r)}var pc,gc,zt,Fs=Ee(()=>{"use strict";dt();Jn();Va();Kr();pc=4285812579,gc=2,zt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==pc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==gc)throw new Error(`Unsupported pack index version: ${n.getUint32(4)}`);this.fanout=new Uint32Array(256);let r=8;for(let s=0;s<256;s++)this.fanout[s]=n.getUint32(r),r+=4;this.count=this.fanout[255],this.hashes=new Uint8Array(t.buffer,t.byteOffset+r,this.count*20),r+=this.count*20,r+=this.count*4,this.offsets=new Uint32Array(this.count);for(let s=0;s<this.count;s++)this.offsets[s]=n.getUint32(r),r+=4;let o=!1;for(let s=0;s<this.count;s++)if(this.offsets[s]&2147483648){o=!0;break}this.largeOffsets=o?new DataView(t.buffer,t.byteOffset+r):null}lookup(t){let n=It(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=It(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let 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 Zd,Jd,Qd,Ec,Vr,kc=Ee(()=>{"use strict";dt();Fs();Kr();Ns();Zd=6,Jd=7,Qd={1:"commit",2:"tree",3:"blob",4:"tag"},Ec=50,Vr=class{constructor(t,n){this.data=t;this.index=n instanceof zt?n:new zt(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>Ec)throw new Error(`delta chain depth ${n} exceeds limit of ${Ec}`);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===Zd){let d=r[o++],m=d&127;for(;d&128;)m+=1,d=r[o++],m=(m<<7)+(d&127);let u=await yr(r.subarray(o)),h=await this.readAt(t-m,n+1);return{type:h.type,content:zr(h.content,u)}}if(i===Jd){let d=Fr(r,o);o+=20;let m=await yr(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:zr(h.content,m)}}let f=Qd[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await yr(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 mi(e,t){let n=eu.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function nu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=tu.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 ui(e,t){return T(e,"objects",t.slice(0,2),t.slice(2))}var eu,tu,Er,hi=Ee(()=>{"use strict";dt();za();Fs();kc();Ns();le();Jn();eu=new TextEncoder,tu=new TextDecoder;Er=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ls(r),this.packDir=T(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=mi(t,n),o=await Tn(r),s=ui(this.gitDir,o);if(await this.fs.exists(s))return o;let i=T(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await Wr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=ui(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await yr(o),i=await Tn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=nu(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(ui(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=In(i),c=await Tn(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=T(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await bc(t),m=T(this.packDir,`${f}.idx`);await this.fs.writeFile(m,d),this.loadedPackNames.add(f);let u=new zt(d);return this.packs.push({name:f,index:u,reader:new Vr(t,u)}),s}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=T(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let 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=T(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Vr(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=T(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(T(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new zt(s),reader:null})}}}});function Yr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function Xr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var pi=Ee(()=>{"use strict"});function tn(e){let t=su.decode(e),n=t.indexOf(`
21
+ `);return{name:a,email:c,timestamp:s,timezone:i}}async function Qt(e,t){try{let n=await Ur(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 Ld(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:Nd(n)}}function Nd(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 Gd,Sn=Re(()=>{"use strict";We();Gd={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 In(e){let t="";for(let n=0;n<20;n++)t+=Fa[e[n]];return t}function Br(e,t){let n="";for(let r=0;r<20;r++)n+=Fa[e[t+r]];return n}function Tt(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var te,Fa,ht=Re(()=>{"use strict";te="0000000000000000000000000000000000000000",Fa=(()=>{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 Ua(e){return e.length===4&&e.toLowerCase()===".git"}function Jn(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===".."||Ua(n))return!1;return!0}function Ds(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function Ba(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||Ua(n))return!1;return!0}var Ms=Re(()=>{"use strict"});function ni(e){return typeof e=="string"?_d.encode(e):e}function Fd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(ni(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Os(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(ni(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(ni(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 In(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 Tn(e){return Wa().update(e).hex()}var _d,Wa,vn,Qn=Re(()=>{"use strict";ht();_d=new TextEncoder;Wa=Fd(),vn=Wa});async function z(e){let t=I(e.gitDir,"index");if(!await e.fs.exists(t))return{version:ri,entries:[]};let n=await e.fs.readFileBuffer(t);return Ud(n)}async function le(e,t){let n=I(e.gitDir,"index"),r=await Bd(t);await e.fs.writeFile(n,r)}function xt(e,t){if(!Jn(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(si),{...e,entries:n}}function lt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function js(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Ht(e){return e.entries.some(t=>t.stage>0)}function Bt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ge(e){return e.entries.filter(t=>t.stage===0)}function za(){return{version:ri,entries:[]}}function Gs(e){let t=[...e].sort(si);return{version:ri,entries:t}}function Ie(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Ud(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==qa)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=In(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 y=n;for(;y<e.byteLength&&e[y]!==0;)y++;w=new TextDecoder().decode(e.subarray(n,y)),g=y-n}let b=62+g+1,x=Math.ceil(b/8)*8;n=c+x,i.push({path:w,mode:l,hash:m,stage:h,stat:f})}return{version:o,entries:i}}async function Bd(e){let t=new TextEncoder,n=[...e.entries].sort(si),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,qa),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=Tt(u.hash);i.set(g,c),c+=20;let w=Math.min(h.byteLength,4095),b=(u.stage&3)<<12|w;a.setUint16(c,b),c+=2,i.set(h,c),c+=h.byteLength,i[c]=0,c+=1;let x=62+h.byteLength+1,y=Math.ceil(x/8)*8;c=p+y}let f=i.subarray(0,c),l=await Tn(f),d=Tt(l);return i.set(d,c),i}function si(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var qa,ri,$e=Re(()=>{"use strict";ht();Ms();me();Qn();qa=1145655875,ri=2});var Wd,Ls,Ka=Re(()=>{"use strict";Wd=new Set(["tree","commit","tag"]),Ls=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Wd.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function oi(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Va[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Va,Ya=Re(()=>{"use strict";Va=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;Va[e]=t}});function sc(e){let t=rc(e);return nc(e.subarray(t,-4),{i:2})}function fi(e){let t=rc(e),n={i:2},r=nc(e.subarray(t),n),o=tc(n.p);return{result:r,bytesConsumed:t+o+4}}var qt,yr,qd,Xa,Za,zd,Ja,Qa,Kd,ci,Wr,qr,ec,Vd,Yd,ii,Wt,ai,tc,Xd,en,nc,rc,oc=Re(()=>{"use strict";qt=Uint8Array,yr=Uint16Array,qd=Int32Array,Xa=new qt([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]),Za=new qt([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 qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ja=(e,t)=>{let n=new yr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new qd(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:Qa}=Ja(Xa,2);Qa[28]=258;({b:Kd}=Ja(Za,0)),ci=new yr(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,ci[e]=((t&65280)>>8|(t&255)<<8)>>1}Wr=(e,t,n)=>{let r=e.length,o=0,s=new yr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new yr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new yr(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[ci[d]>>c]=f}}else for(a=new yr(r),o=0;o<r;++o)e[o]&&(a[o]=ci[i[e[o]-1]++]>>15-e[o]);return a},qr=new qt(288);for(let e=0;e<144;++e)qr[e]=8;for(let e=144;e<256;++e)qr[e]=9;for(let e=256;e<280;++e)qr[e]=7;for(let e=280;e<288;++e)qr[e]=8;ec=new qt(32);for(let e=0;e<32;++e)ec[e]=5;Vd=Wr(qr,9,1),Yd=Wr(ec,5,1),ii=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Wt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ai=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},tc=e=>(e+7)/8|0,Xd=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))),en=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},nc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new qt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new qt(o*3));let f=b=>{let x=n.length;if(b>x){let y=new qt(Math.max(x*2,b));y.set(n),n=y}},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=Wt(e,d,1);let E=Wt(e,d+1,3);if(d+=3,E)if(E==1)u=Vd,h=Yd,p=9,g=5;else if(E==2){let k=Wt(e,d,31)+257,R=Wt(e,d+10,15)+4,C=k+Wt(e,d+5,31)+1;d+=14;let P=new qt(C),H=new qt(19);for(let T=0;T<R;++T)H[zd[T]]=Wt(e,d+T*3,7);d+=R*3;let D=ii(H),O=(1<<D)-1,A=Wr(H,D,1);for(let T=0;T<C;){let F=A[Wt(e,d,O)];d+=F&15;let _=F>>4;if(_<16)P[T++]=_;else{let U=0,N=0;for(_==16?(N=3+Wt(e,d,3),d+=2,U=P[T-1]):_==17?(N=3+Wt(e,d,7),d+=3):_==18&&(N=11+Wt(e,d,127),d+=7);N--;)P[T++]=U}}let G=P.subarray(0,k),v=P.subarray(k);p=ii(G),g=ii(v),u=Wr(G,p,1),h=Wr(v,g,1)}else en(1);else{let k=tc(d)+4,R=e[k-4]|e[k-3]<<8,C=k+R;if(C>o){c&&en(0);break}a&&f(m+R),n.set(e.subarray(k,C),m),t.b=m+=R,t.p=d=C*8,t.f=l;continue}if(d>w){c&&en(0);break}}a&&f(m+131072);let b=(1<<p)-1,x=(1<<g)-1,y=d;for(;;y=d){let E=u[ai(e,d)&b],k=E>>4;if(d+=E&15,d>w){c&&en(0);break}if(E||en(2),k<256)n[m++]=k;else if(k==256){y=d,u=null;break}else{let R=k-254;if(k>264){let O=k-257,A=Xa[O];R=Wt(e,d,(1<<A)-1)+Qa[O],d+=A}let C=h[ai(e,d)&x],P=C>>4;C||en(3),d+=C&15;let H=Kd[P];if(P>3){let O=Za[P];H+=ai(e,d)&(1<<O)-1,d+=O}if(d>w){c&&en(0);break}a&&f(m+131072);let D=m+R;if(m<H){let O=s-H,A=Math.min(H,D);for(O+m<0&&en(3);m<A;++m)n[m]=r[O+m]}for(;m<D;++m)n[m]=n[m-H]}}t.l=u,t.p=y,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?Xd(n,0,m):n.subarray(0,m)},rc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&en(0,"invalid zlib data"),e[1]&32&&en(0,"zlib dictionaries are not supported"),2)});async function Zd(){let e;if(!(typeof document<"u"))try{e=Os(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let 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??fi}}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:sc,inflateWithConsumed:fi}}function li(){return Jd??=Zd()}async function zr(e){return await(await li()).deflateSync(e)}async function Er(e){return await(await li()).inflateSync(e)}async function ic(e,t){let n=await li(),{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 Jd,Ns=Re(()=>{"use strict";oc();Jd=null});async function pc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==ui)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${ui.toString(16)})`);let o=n.getUint32(4);if(o!==lc)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Br(e,e.byteLength-20),l=vn();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 tu(e,a);i.push(l),a=l.nextOffset}return(await nu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function tu(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===Kr){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===mi&&(c=Br(e,t),t+=20);let{result:f,bytesConsumed:l}=await ic(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function nu(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>ac)throw new Error(`delta chain depth ${i} exceeds limit of ${ac}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==Kr&&c.typeNum!==mi){let u=Qd[c.typeNum];if(!u)throw new Error(`Unknown object type: ${c.typeNum}`);let h={type:u,content:c.inflated,hash:await di(u,c.inflated)};return r[s]=h,h}if(c.typeNum===Kr){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=Vr(h.content,c.inflated),g={type:h.type,content:p,hash:await di(h.type,p)};return r[s]=g,g}let f=await ru(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=Vr(l.content,c.inflated),m={type:l.type,content:d,hash:await di(l.type,d)};return r[s]=m,m}for(let s=0;s<e.length;s++)await o(s);return r}async function ru(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!==Kr&&s.typeNum!==mi&&(await r(o)).hash===n)return o}}function Vr(e,t){let n=0,{value:r,newPos:o}=fc(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}=fc(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 _s(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,ui),o.setUint32(4,lc),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=cc(Kr,a.delta.byteLength),d=ou(s-f),m=await zr(a.delta);t.push(l,d,m),s+=l.byteLength+d.byteLength+m.byteLength}else{let l=eu[a.type],d=cc(l,a.content.byteLength),m=await zr(a.content);t.push(d,m),s+=d.byteLength+m.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await su(t),entries:i}}async function su(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=vn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Tt(s),r),n}function ou(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 cc(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 fc(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 di(e,t){let n=iu.encode(`${e} ${t.byteLength}\0`),r=vn();return r.update(n),r.update(t),r.hex()}var ui,lc,dc,uc,mc,hc,Kr,mi,Qd,eu,ac,iu,Yr=Re(()=>{"use strict";ht();Qn();Ns();ui=1346454347,lc=2,dc=1,uc=2,mc=3,hc=4,Kr=6,mi=7,Qd={[dc]:"commit",[uc]:"tree",[mc]:"blob",[hc]:"tag"},eu={commit:dc,tree:uc,blob:mc,tag:hc};ac=50;iu=new TextEncoder});async function bc(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,gc),c+=4,a.setUint32(c,wc),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(Tt(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=vn();d.update(i.subarray(0,c));let m=await d.hex();return i.set(Tt(m),c),i}async function yc(e){let n=(await pc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:oi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return bc(n,r)}async function Ec(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:oi(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return bc(n,r)}var gc,wc,zt,Fs=Re(()=>{"use strict";ht();Qn();Ya();Yr();gc=4285812579,wc=2,zt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==gc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==wc)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=Tt(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=Tt(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 au,cu,fu,kc,Xr,Rc=Re(()=>{"use strict";ht();Fs();Yr();Ns();au=6,cu=7,fu={1:"commit",2:"tree",3:"blob",4:"tag"},kc=50,Xr=class{constructor(t,n){this.data=t;this.index=n instanceof zt?n:new zt(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>kc)throw new Error(`delta chain depth ${n} exceeds limit of ${kc}`);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===au){let d=r[o++],m=d&127;for(;d&128;)m+=1,d=r[o++],m=(m<<7)+(d&127);let u=await Er(r.subarray(o)),h=await this.readAt(t-m,n+1);return{type:h.type,content:Vr(h.content,u)}}if(i===cu){let d=Br(r,o);o+=20;let m=await Er(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:Vr(h.content,m)}}let f=fu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Er(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 pi(e,t){let n=lu.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function uu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=du.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 hi(e,t){return I(e,"objects",t.slice(0,2),t.slice(2))}var lu,du,kr,gi=Re(()=>{"use strict";ht();Ka();Fs();Rc();Ns();me();Qn();lu=new TextEncoder,du=new TextDecoder;kr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ls(r),this.packDir=I(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=pi(t,n),o=await Tn(r),s=hi(this.gitDir,o);if(await this.fs.exists(s))return o;let i=I(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await zr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=hi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Er(o),i=await Tn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=uu(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(hi(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=In(i),c=await Tn(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=I(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await yc(t),m=I(this.packDir,`${f}.idx`);await this.fs.writeFile(m,d),this.loadedPackNames.add(f);let u=new zt(d);return this.packs.push({name:f,index:u,reader:new Xr(t,u)}),s}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=I(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=I(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new Xr(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=I(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(I(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new zt(s),reader:null})}}}});function Zr(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 Jr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var wi=Re(()=>{"use strict"});function tn(e){let t=hu.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=Yr(m);break;case"committer":c=Yr(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 nn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Xr(e.author)}`),t.push(`committer ${Xr(e.committer)}`),t.push(""),t.push(e.message),ru.encode(t.join(`
25
- `))}var ru,su,mn=Ee(()=>{"use strict";pi();ru=new TextEncoder,su=new TextDecoder});function hn(e){let t=iu.decode(e),n=t.indexOf(`
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=Zr(m);break;case"committer":c=Zr(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 nn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Jr(e.author)}`),t.push(`committer ${Jr(e.committer)}`),t.push(""),t.push(e.message),mu.encode(t.join(`
25
+ `))}var mu,hu,mn=Re(()=>{"use strict";wi();mu=new TextEncoder,hu=new TextDecoder});function hn(e){let t=gu.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=Yr(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 Rc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Xr(e.tagger)}`),t.push(""),t.push(e.message),ou.encode(t.join(`
29
- `))}var ou,iu,Zr=Ee(()=>{"use strict";pi();ou=new TextEncoder,iu=new TextDecoder});async function ut(e,t){return Tn(mi(e,t))}async function Se(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function we(e,t){return e.objectStore.read(t)}async function Kt(e,t){return e.objectStore.exists(t)}async function Us(e,t){return e.objectStore.ingestPack(t)}async function xc(e,t){return e.objectStore.findByPrefix(t)}function Ie(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function vn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function oe(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return au.decode(n.content)}async function kt(e,t){let n=await we(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function j(e,t){let n=await we(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return tn(n.content)}async function Pc(e,t){let n=await we(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return hn(n.content)}async function Ne(e,t){let n=t;for(let r=0;r<100;r++){let o=await we(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=hn(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=Ee(()=>{"use strict";hi();mn();Zr();Jn();au=new TextDecoder});function Cc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var Jr,gi=Ee(()=>{"use strict";Jr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function fu(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?cu[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>=wi.length&&e.slice(s-wi.length,s)===wi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function Qr(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}=fu(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 pn(e){return!e||e.startsWith("-")?!1:Qr(`refs/heads/${e}`,0)}function Oc(e){return e?Qr(`refs/tags/${e}`,0):!1}async function Ic(e,t){return e.refStore.readRef(t)}async function F(e,t){let n=t;for(let r=0;r<$c;r++){let o=await Ic(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 Ic(e,"HEAD")}async function Z(e){return F(e,"HEAD")}async function X(e,t,n){let r=e.hooks?await F(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function ze(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function de(e,t){let n=e.hooks?await F(e,t):null;await e.refStore.deleteRef(t),await ts(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function ge(e,t="refs"){return e.refStore.listRefs(t)}function Re(e){return e.replace("refs/heads/","")}async function An(e,t){let n=await Q(e);n&&n.type==="symbolic"?await X(e,n.target,t):await X(e,"HEAD",t)}async function Sc(e){if(e.refStore&&!(e.refStore instanceof Hn))return;let t=await ge(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await we(e,o.hash);if(s.type==="tag"){let i=hn(s.content).object;for(let a=0;a<100;a++){let c=await we(e,i);if(c.type!=="tag")break;i=hn(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(T(e.gitDir,"packed-refs"),`${n.join(`
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=Zr(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 xc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Jr(e.tagger)}`),t.push(""),t.push(e.message),pu.encode(t.join(`
29
+ `))}var pu,gu,Qr=Re(()=>{"use strict";wi();pu=new TextEncoder,gu=new TextDecoder});async function pt(e,t){return Tn(pi(e,t))}async function Te(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function Ee(e,t){return e.objectStore.read(t)}async function Kt(e,t){return e.objectStore.exists(t)}async function Us(e,t){return e.objectStore.ingestPack(t)}async function Cc(e,t){return e.objectStore.findByPrefix(t)}function ve(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 Hn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function oe(e,t){let n=await Ee(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return wu.decode(n.content)}async function Ct(e,t){let n=await Ee(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 Ee(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return tn(n.content)}async function Pc(e,t){let n=await Ee(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return hn(n.content)}async function Le(e,t){let n=t;for(let r=0;r<100;r++){let o=await Ee(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=hn(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 wu,fe=Re(()=>{"use strict";gi();mn();Qr();Qn();wu=new TextDecoder});function $c(e){return typeof e=="string"?{type:"direct",hash:e}:e}var es,bi=Re(()=>{"use strict";es={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function yu(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?bu[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>=yi.length&&e.slice(s-yi.length,s)===yi?{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}=yu(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 pn(e){return!e||e.startsWith("-")?!1:ts(`refs/heads/${e}`,0)}function Oc(e){return e?ts(`refs/tags/${e}`,0):!1}async function Ic(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Sc;r++){let o=await Ic(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 Ic(e,"HEAD")}async function Z(e){return B(e,"HEAD")}async function X(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 Ye(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 be(e,t="refs"){return e.refStore.listRefs(t)}function Ce(e){return e.replace("refs/heads/","")}async function Dn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await X(e,n.target,t):await X(e,"HEAD",t)}async function vc(e){if(e.refStore&&!(e.refStore instanceof An))return;let t=await be(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 Ee(e,o.hash);if(s.type==="tag"){let i=hn(s.content).object;for(let a=0;a<100;a++){let c=await Ee(e,i);if(c.type!=="tag")break;i=hn(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(I(e.gitDir,"packed-refs"),`${n.join(`
30
30
  `)}
31
- `);for(let o of t){let s=T(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Tc(e,T(e.gitDir,"refs"));let r=T(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(T(r,"heads"),{recursive:!0}),await e.fs.mkdir(T(r,"tags"),{recursive:!0})}async function Tc(e,t){if(e.refStore&&!(e.refStore instanceof Hn)||!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 Tc(e,T(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var wi,cu,bi,$c,Hn,ue=Ee(()=>{"use strict";ie();Zr();le();Fe();Dn();gi();wi=".lock",cu=[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];bi="ref: ",$c=10,Hn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=T(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(bi)?{type:"symbolic",target:s.slice(bi.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=Cc(n),o=T(this.gitDir,t);await es(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${bi}${r.target}
31
+ `);for(let o of t){let s=I(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Tc(e,I(e.gitDir,"refs"));let r=I(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(I(r,"heads"),{recursive:!0}),await e.fs.mkdir(I(r,"tags"),{recursive:!0})}async function Tc(e,t){if(e.refStore&&!(e.refStore instanceof An)||!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 Tc(e,I(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var yi,bu,Ei,Sc,An,pe=Re(()=>{"use strict";fe();Qr();me();qe();Mn();bi();yi=".lock",bu=[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];Ei="ref: ",Sc=10,An=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=I(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Ei)?{type:"symbolic",target:s.slice(Ei.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=I(this.gitDir,t);await ns(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Ei}${r.target}
32
32
  `):await this.fs.writeFile(o,`${r.hash}
33
- `)}async deleteRef(t){let n=T(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=T(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(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<$c;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=T(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
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=T(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=I(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=I(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<Sc;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=I(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=I(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=T(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 Qn(e,t){let n=t;for(;;){let r=T(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Er(e,r),refStore:new Hn(e,r)};if(await lu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Er(e,n),refStore:new Hn(e,n)};let o=du(n);if(o===n)return null;n=o}}async function lu(e,t){let n=T(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=T(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function Bs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:T(t,".git"),i=r?null:t,a=T(s,"HEAD"),c=await e.exists(a);await e.mkdir(T(s,"objects"),{recursive:!0}),await e.mkdir(T(s,"refs","heads"),{recursive:!0}),await e.mkdir(T(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Er(e,s),refStore:new Hn(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(T(s,"config"),Zo(l))}return{ctx:f,reinit:c}}async function es(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function du(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Dn=Ee(()=>{"use strict";_e();hi();le();ue()});function Ws(e,t){return T(e.gitDir,"logs",t)}function uu(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 Je(e,t){let n=Ws(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=uu(s);i&&o.push(i)}return o}function vc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Mn(e,t,n){let r=Ws(e,t);if(await es(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(vc).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=I(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 er(e,t){let n=t;for(;;){let r=I(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new kr(e,r),refStore:new An(e,r)};if(await Eu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new kr(e,n),refStore:new An(e,n)};let o=ku(n);if(o===n)return null;n=o}}async function Eu(e,t){let n=I(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=I(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 Bs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:I(t,".git"),i=r?null:t,a=I(s,"HEAD"),c=await e.exists(a);await e.mkdir(I(s,"objects"),{recursive:!0}),await e.mkdir(I(s,"refs","heads"),{recursive:!0}),await e.mkdir(I(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new kr(e,s),refStore:new An(e,s)};if(!c){await Ye(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(I(s,"config"),Qo(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 ku(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Mn=Re(()=>{"use strict";We();gi();me();pe()});function Ws(e,t){return I(e.gitDir,"logs",t)}function Ru(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=Ws(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=Ru(s);i&&o.push(i)}return o}function Hc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function jn(e,t,n){let r=Ws(e,t);if(await ns(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Hc).join(`
38
38
  `)}
39
- `;await e.fs.writeFile(r,o)}async function Ke(e,t,n){let r=Ws(e,t);await es(e.fs,r);let o=`${vc(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 ts(e,t){let n=Ws(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function re(e,t,n,r,o,s,i=!1){let a=await Qt(e,t),c={oldHash:r??te,newHash:o,...a,message:s};await Ke(e,n,c),i&&n!=="HEAD"&&await Ke(e,"HEAD",c)}var Fe=Ee(()=>{"use strict";dt();$n();le();Dn();dt()});function mu(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 hu(e,t){let n=await xc(e,t);if(n.length===0)return null;if(n.length>1)throw new yi(t);return n[0]}async function pu(e,t){if(t==="HEAD"||t==="@")return F(e,"HEAD");if(Hc.includes(t))return F(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Kt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await hu(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await F(e,t);if(s)return s}let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);if(r)return r;let o=await F(e,`refs/remotes/${t}`);return o||null}function gu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Hc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function wu(e,t,n){let r=gu(t),o=await Je(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function bu(e,t,n){if(n===""||n==="commit")try{return await Ne(e,t)}catch{return null}if(n==="tree"){let o;try{o=await Ne(e,t)}catch{return null}return(await j(e,o)).tree}return(await we(e,t)).type!==n?null:t}async function Be(e,t){let{base:n,reflogIndex:r,suffixes:o}=mu(t),s;if(r!==void 0?s=await wu(e,n,r):s=await pu(e,n),!s)return null;o.some(a=>a.type==="tilde"||a.type==="caret")&&(s=await Ne(e,s));for(let a of o)if(a.type==="peel"){if(!s)return null;s=await bu(e,s,a.target)}else if(a.type==="tilde")for(let c=0;c<a.n;c++){if(!s)return null;let f=await j(e,s);if(f.parents.length===0||(s=f.parents[0]??null,!s))return null}else{if(a.n===0)continue;if(!s)return null;let c=await j(e,s);if(a.n>c.parents.length||(s=c.parents[a.n-1]??null,!s))return null}return s}function qs(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Hc,yi,gn=Ee(()=>{"use strict";ie();Fe();ue();Hc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];yi=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function lt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function wn(e){return typeof e=="string"?e==="120000":e===40960}async function ns(e,t){if((await lt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return yu.encode(r)}return e.readFileBuffer(t)}async function jn(e,t){let n=await ns(e,t);return ut("blob",n)}var yu,er=Ee(()=>{"use strict";ie();yu=new TextEncoder});function Ru(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(Ru(e))throw new Error(`invalid tree entry: '${e}'`);if(!ku.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function Gn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Ac.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Ac.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=In(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 Dc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Eu.encode(`${i} ${s.name}\0`),c=It(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Eu,Ac,ku,zs=Ee(()=>{"use strict";dt();Eu=new TextEncoder,Ac=new TextDecoder,ku=new Set(["100644","100755","040000","120000","160000"])});async function Ge(e,t){return Mc(e,t,"")}async function Mc(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:Pu(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 Mc(e,a,c);r.push({mode:Jr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Jr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Jr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Dc({type:"tree",entries:r});return Se(e,"tree",s)}async function Ve(e,t,n=""){let r=await we(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=Gn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Jr.DIRECTORY){let c=await Ve(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function ce(e,t){if(!t)return new Map;let n=await Ve(e,t);return new Map(n.map(r=>[r.path,r]))}async function We(e,t,n){let r=await ce(e,t),o=await ce(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Oe(i.path,a.path))}function Pu(e){return e.toString(8).padStart(6,"0")}var ve=Ee(()=>{"use strict";se();ie();zs();gi()});function jc(e){return/^[a-zA-Z0-9]$/.test(e)}function Cu(e){return/^[a-zA-Z]$/.test(e)}function Ou(e){return e>="0"&&e<="9"}function Ei(e){return e>="A"&&e<="Z"}function ki(e){return e>="a"&&e<="z"}function Gc(e){return/^\s$/.test(e)}function $u(e){return e===" "||e===" "}function xi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Iu(e){return xi(e)&&!Gc(e)}function Su(e){return xi(e)&&!jc(e)&&e!==" "}function Tu(e){let t=e.charCodeAt(0);return t<32||t===127}function vu(e){return/^[0-9a-fA-F]$/.test(e)}function rs(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Ri(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(!rs(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]==="/"&&Ri(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(!Hu(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=Ri(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],rs(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(ki(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(Ei(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="[",rs(c,u,s)&&(l=!0);else{let g=e.slice(h,h+p);Au(g,c,s)&&(l=!0),u=""}}else rs(c,u,s)&&(l=!0);d=u,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!rs(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function Hu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Au(e,t,n){switch(e){case"alnum":return jc(t);case"alpha":return Cu(t);case"blank":return $u(t);case"cntrl":return Tu(t);case"digit":return Ou(t);case"graph":return Iu(t);case"lower":return ki(t)||n&&Ei(t);case"print":return xi(t);case"punct":return Su(t);case"space":return Gc(t);case"upper":return Ei(t)||n&&ki(t);case"xdigit":return vu(t);default:return!1}}function tr(e,t,n=0){return Ri(e,0,t,0,n)===0?0:1}var Ks=Ee(()=>{"use strict"});function Fc(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 Du(e){return Fc(e)===e.length}function Mu(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|=Vs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=_c);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Lc);let a=Math.min(Fc(o),s);return o[0]==="*"&&Du(o.slice(1))&&(r|=Nc),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function ss(e,t,n){let r=[];for(let o of e.split(`
41
- `)){let s=Mu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function ju(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Nc){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return tr(n,e,2)===0}function Gu(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 tr(r,a,2)===0}function Pi(e,t,n){let r=e.lastIndexOf("/")>=0?e.slice(e.lastIndexOf("/")+1):e;for(let o=n.patterns.length-1;o>=0;o--){let s=n.patterns[o];if(s&&!(s.flags&_c&&!t)){if(s.flags&Lc){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(ju(r,s))return s;continue}if(Gu(e,s))return s}}return null}function rn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Pi(t,n,o);if(s)return s.flags&Vs?"not-ignored":"ignored"}if(e.excludeFile){let r=Pi(t,n,e.excludeFile);if(r)return r.flags&Vs?"not-ignored":"ignored"}if(e.globalExclude){let r=Pi(t,n,e.globalExclude);if(r)return r.flags&Vs?"not-ignored":"ignored"}return"undecided"}async function Rr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=T(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=ss(r,"",n)}catch{}try{let r=await ke(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=ss(o,"",r)}catch{}}catch{}return t}function nr(e,t,n,r){let s=ss(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Lc,Nc,_c,Vs,Xs=Ee(()=>{"use strict";_e();le();Ks();Lc=1,Nc=4,_c=8,Vs=16});async function Tt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=T(e.workTree,s.path),a;try{a=await lt(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 jn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await et(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Oe(s.path,i.path))}async function ct(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!Zn(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=T(e.workTree,t.path);if(!Ds(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&&wn(t.mode)&&e.fs.symlink){let s=Nu.decode(n.content);if(!Ua(s))throw new Error(`refusing to create symlink with unsafe target '${s}'`);await lt(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 Uc(e,t){let n=await Ve(e,t);for(let r of n)await ct(e,r)}async function sn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!Zn(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=T(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await lt(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=Lu.encode(f),d=await Se(e,"blob",l),m={path:n,mode:40960,hash:d,stage:0,stat:{...$e(),size:l.byteLength}};return{index:Et(t,m),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Se(e,"blob",s),a=o.mode!=null?_u(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...$e(),size:s.byteLength}};return{index:Et(t,c),hash:i}}async function et(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Rr(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);s=nr(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=T(t,c),l=n?`${n}/${c}`:c,d=await lt(e.fs,f);if(d.isSymbolicLink){if(s&&rn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&rn(s,l,!0)==="ignored")continue;let m=await et(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...m)}else if(d.isFile){if(s&&rn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function _u(e){return e>511?e:e&73?33261:33188}async function rr(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 rr(e,Jt(t),n))}var Lu,Nu,tt=Ee(()=>{"use strict";se();Xs();Ce();ie();Ms();le();er();ve();Lu=new TextEncoder,Nu=new TextDecoder});function Ci(e){return e.existsOnDisk&&e.indexHash===null}async function Fu(e,t,n){let r=await Promise.all(t.map(h=>ce(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await et(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await et(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),m=(h,p)=>r[h]?.get(p),u=[];for(let h of d){let p=null,g=null,w=null,y=null,x=null;if(r.length===1){let O=m(0,h);w=O?.hash??null,x=O?.mode??null}else if(r.length===2){let O=m(0,h),H=m(1,h);g=O?.hash??null,y=O?.mode??null,w=H?.hash??null,x=H?.mode??null}else if(r.length>=3){let O=m(0,h),H=m(1,h),G=m(2,h);p=O?.hash??null,g=H?.hash??null,y=H?.mode??null,w=G?.hash??null,x=G?.mode??null}let k=o.get(h)?.hash??null,E=s.has(h)?1:0,R=i.has(h),C,P=async()=>C!==void 0?C:R?(C=!(await c()).has(h),C):(C=!1,!1),v,D=async()=>{if(v!==void 0)return v;if(!R||!e.workTree)return v=null,null;let O=T(e.workTree,h);try{v=await jn(e.fs,O)}catch{v=null}return v};u.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:E,existsOnDisk:R,isIgnoredOnDisk:P,getWorktreeHash:D,headMode:y,remoteMode:x})}return u}function Zs(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 Js(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 Uu(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 Bu(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=Uu(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await Wu(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function Wu(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Ci(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 Ci(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Ci(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function qu(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:$e()}),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)=>Oe(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Qs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of zu){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 Xe(e,t,n){let r=Ws(e,t);await ns(e.fs,r);let o=`${Hc(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=Ws(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ae(e,t,n,r,o,s,i=!1){let a=await Qt(e,t),c={oldHash:r??te,newHash:o,...a,message:s};await Xe(e,n,c),i&&n!=="HEAD"&&await Xe(e,"HEAD",c)}var qe=Re(()=>{"use strict";ht();Sn();me();Mn();ht()});function xu(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 Cu(e,t){let n=await Cc(e,t);if(n.length===0)return null;if(n.length>1)throw new ki(t);return n[0]}async function Pu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Ac.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Kt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Cu(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 $u(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Ac)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Ou(e,t,n){let r=$u(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 Su(e,t,n){if(n===""||n==="commit")try{return await Le(e,t)}catch{return null}if(n==="tree"){let o;try{o=await Le(e,t)}catch{return null}return(await j(e,o)).tree}return(await Ee(e,t)).type!==n?null:t}async function Ke(e,t){let{base:n,reflogIndex:r,suffixes:o}=xu(t),s;if(r!==void 0?s=await Ou(e,n,r):s=await Pu(e,n),!s)return null;o.some(a=>a.type==="tilde"||a.type==="caret")&&(s=await Le(e,s));for(let a of o)if(a.type==="peel"){if(!s)return null;s=await Su(e,s,a.target)}else if(a.type==="tilde")for(let c=0;c<a.n;c++){if(!s)return null;let f=await j(e,s);if(f.parents.length===0||(s=f.parents[0]??null,!s))return null}else{if(a.n===0)continue;if(!s)return null;let c=await j(e,s);if(a.n>c.parents.length||(s=c.parents[a.n-1]??null,!s))return null}return s}function qs(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Ac,ki,gn=Re(()=>{"use strict";fe();qe();pe();Ac=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];ki=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 wn(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 Iu.encode(r)}return e.readFileBuffer(t)}async function Gn(e,t){let n=await ss(e,t);return pt("blob",n)}var Iu,tr=Re(()=>{"use strict";fe();Iu=new TextEncoder});function Hu(e){return e.length===4&&e.toLowerCase()===".git"}function Au(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(Hu(e))throw new Error(`invalid tree entry: '${e}'`);if(!Tu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function Ln(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Dc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Dc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=In(a),f=o.padStart(6,"0");Au(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Mc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=vu.encode(`${i} ${s.name}\0`),c=Tt(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var vu,Dc,Tu,zs=Re(()=>{"use strict";ht();vu=new TextEncoder,Dc=new TextDecoder,Tu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return jc(e,t,"")}async function jc(e,t,n){let r=[],o=new Map;for(let i of t){let a=n?i.path.slice(n.length+1):i.path,c=a.indexOf("/");if(c===-1)r.push({mode:Du(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),l=o.get(f);l||(l=[],o.set(f,l)),l.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await jc(e,a,c);r.push({mode: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=Mc({type:"tree",entries:r});return Te(e,"tree",s)}async function ze(e,t,n=""){let r=await Ee(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=Ln(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 ze(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 ze(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){let r=await de(e,t),o=await de(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)=>Se(i.path,a.path))}function Du(e){return e.toString(8).padStart(6,"0")}var He=Re(()=>{"use strict";ce();fe();zs();bi()});function Gc(e){return/^[a-zA-Z0-9]$/.test(e)}function Mu(e){return/^[a-zA-Z]$/.test(e)}function ju(e){return e>="0"&&e<="9"}function Ri(e){return e>="A"&&e<="Z"}function xi(e){return e>="a"&&e<="z"}function Lc(e){return/^\s$/.test(e)}function Gu(e){return e===" "||e===" "}function Pi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Lu(e){return Pi(e)&&!Lc(e)}function Nu(e){return Pi(e)&&!Gc(e)&&e!==" "}function _u(e){let t=e.charCodeAt(0);return t<32||t===127}function Fu(e){return/^[0-9a-fA-F]$/.test(e)}function os(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Ci(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]==="/"&&Ci(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(!Uu(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=Ci(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(xi(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(Ri(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);Bu(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 Uu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Bu(e,t,n){switch(e){case"alnum":return Gc(t);case"alpha":return Mu(t);case"blank":return Gu(t);case"cntrl":return _u(t);case"digit":return ju(t);case"graph":return Lu(t);case"lower":return xi(t)||n&&Ri(t);case"print":return Pi(t);case"punct":return Nu(t);case"space":return Lc(t);case"upper":return Ri(t)||n&&xi(t);case"xdigit":return Fu(t);default:return!1}}function nr(e,t,n=0){return Ci(e,0,t,0,n)===0?0:1}var Ks=Re(()=>{"use strict"});function Uc(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 Wu(e){return Uc(e)===e.length}function qu(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|=Vs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Fc);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Nc);let a=Math.min(Uc(o),s);return o[0]==="*"&&Wu(o.slice(1))&&(r|=_c),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function is(e,t,n){let r=[];for(let o of e.split(`
41
+ `)){let s=qu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function zu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&_c){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return nr(n,e,2)===0}function Ku(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 nr(r,a,2)===0}function $i(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&Fc&&!t)){if(s.flags&Nc){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(zu(r,s))return s;continue}if(Ku(e,s))return s}}return null}function rn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=$i(t,n,o);if(s)return s.flags&Vs?"not-ignored":"ignored"}if(e.excludeFile){let r=$i(t,n,e.excludeFile);if(r)return r.flags&Vs?"not-ignored":"ignored"}if(e.globalExclude){let r=$i(t,n,e.globalExclude);if(r)return r.flags&Vs?"not-ignored":"ignored"}return"undecided"}async function xr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=I(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=is(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=is(o,"",r)}catch{}}catch{}return t}function rr(e,t,n,r){let s=is(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Nc,_c,Fc,Vs,Xs=Re(()=>{"use strict";We();me();Ks();Nc=1,_c=4,Fc=8,Vs=16});async function At(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=I(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 Gn(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)=>Se(s.path,i.path))}async function dt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!Jn(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);let n=await Ee(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=I(e.workTree,t.path);if(!Ds(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&&wn(t.mode)&&e.fs.symlink){let s=Yu.decode(n.content);if(!Ba(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 Bc(e,t){let n=await ze(e,t);for(let r of n)await dt(e,r)}async function sn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!Jn(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=I(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=Vu.encode(f),d=await Te(e,"blob",l),m={path:n,mode:40960,hash:d,stage:0,stat:{...Ie(),size:l.byteLength}};return{index:xt(t,m),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Te(e,"blob",s),a=o.mode!=null?Xu(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Ie(),size:s.byteLength}};return{index:xt(t,c),hash:i}}async function st(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await xr(e);let c=I(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=I(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&rn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&rn(s,l,!0)==="ignored")continue;let m=await st(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...m)}else if(d.isFile){if(s&&rn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function Xu(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,Jt(t),n))}var Vu,Yu,ot=Re(()=>{"use strict";ce();Xs();$e();fe();Ms();me();tr();He();Vu=new TextEncoder,Yu=new TextDecoder});function Oi(e){return e.existsOnDisk&&e.indexHash===null}async function Zu(e,t,n){let r=await Promise.all(t.map(h=>de(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 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 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,b=null,x=null;if(r.length===1){let O=m(0,h);w=O?.hash??null,x=O?.mode??null}else if(r.length===2){let O=m(0,h),A=m(1,h);g=O?.hash??null,b=O?.mode??null,w=A?.hash??null,x=A?.mode??null}else if(r.length>=3){let O=m(0,h),A=m(1,h),G=m(2,h);p=O?.hash??null,g=A?.hash??null,b=A?.mode??null,w=G?.hash??null,x=G?.mode??null}let E=o.get(h)?.hash??null,k=s.has(h)?1:0,R=i.has(h),C,P=async()=>C!==void 0?C:R?(C=!(await c()).has(h),C):(C=!1,!1),H,D=async()=>{if(H!==void 0)return H;if(!R||!e.workTree)return H=null,null;let O=I(e.workTree,h);try{H=await Gn(e.fs,O)}catch{H=null}return H};u.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:E,indexStage:k,existsOnDisk:R,isIgnoredOnDisk:P,getWorktreeHash:D,headMode:b,remoteMode:x})}return u}function Zs(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 Js(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 Ju(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 Qu(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=Ju(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await em(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function em(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Oi(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 Oi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Oi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function tm(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:Ie()}),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)=>Se(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Qs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of nm){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 sr(e,t,n,r){let o=await Fu(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 Bu(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Qs(a,r)};let{newEntries:c,worktreeOps:f}=qu(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(!Zn(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=T(n,o.path);if(!Ds(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await lt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await ct(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await rr(e.fs,Jt(o),n)}async function Ln(e,t,n,r){return sr(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Bc(e,t,n,r){return sr(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function bn(e,t,n){return sr(e,[{label:"target",treeHash:t}],n,{mergeFn:Zs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function eo(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:De(n)},i=await sr(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Zs,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 or(e,t,n,r){let o=await Zu(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 Qu(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Qs(a,r)};let{newEntries:c,worktreeOps:f}=tm(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Ne(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!Jn(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=I(n,o.path);if(!Ds(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,Jt(o),n)}async function Nn(e,t,n,r){return or(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Wc(e,t,n,r){return or(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function bn(e,t,n){return or(e,[{label:"target",treeHash:t}],n,{mergeFn:Zs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function eo(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:Ge(n)},i=await or(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Zs,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
47
47
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
48
48
  `);return c.length>0&&(i.errorOutput=L(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
- `,128)),i}if(e.workTree&&o.size>0){let a=await ce(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var zu,on=Ee(()=>{"use strict";se();Ce();Ms();le();er();ve();tt();zu=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function $(e){return{stdout:"",stderr:`fatal: ${e}
50
- `,exitCode:128}}function L(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){let r=await Qn(e,t);return r?n?{...r,...n}:r:Ku}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Xe(e){return e.workTree?null:Vu}async function Ze(e){let t=await Z(e);return t||$("your current branch does not have any commits yet")}function yn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
- `){return St(e)?L(`error: ${t} is not possible because you have unmerged files.
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 nm,on=Re(()=>{"use strict";ce();$e();Ms();me();tr();He();ot();nm=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function S(e){return{stdout:"",stderr:`fatal: ${e}
50
+ `,exitCode:128}}function L(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){let r=await er(e,t);return r?n?{...r,...n}:r:rm}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Je(e){return e.workTree?null:sm}async function Qe(e){let t=await Z(e);return t||S("your current branch does not have any commits yet")}function yn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
+ `){return Ht(e)?L(`error: ${t} is not possible because you have unmerged files.
52
52
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
53
53
  hint: as appropriate to mark resolution and make a commit.
54
- `+n,128):null}async function vt(e,t,n){let r=await Be(e,t);return r||$(n??`bad revision '${t}'`)}async function He(e,t,n){let r=await Be(e,t);if(!r)return $(n??`bad revision '${t}'`);try{let o=await Ne(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return $(n??`bad revision '${t}'`)}}async function Qe(e,t){try{return await _r(e,t)}catch(n){return $(n.message)}}async function an(e,t){try{return await As(e,t)}catch(n){return $(n.message)}}function xr(e,t){let n=new Map;for(let r of e.entries)r.stage===0&&n.set(r.path,r);for(let[r,o]of n){let s=t.get(r);if(!s||s.hash!==o.hash)return!0}for(let[r]of t)if(!n.has(r))return!0;return!1}function Oe(e,t){return e<t?-1:e>t?1:0}function mt(e,t){return e.workTree?ft(e.workTree,t):""}function Y(e){return e.slice(0,7)}function fe(e){let t=e.indexOf(`
55
- `);return t===-1?e:e.slice(0,t)}function Vt(e){return $(`ambiguous argument '${e}': unknown revision or path not in the working tree.
54
+ `+n,128):null}async function gt(e,t,n){let r=await Ke(e,t);return r||S(n??`bad revision '${t}'`)}async function De(e,t,n){let r=await Ke(e,t);if(!r)return S(n??`bad revision '${t}'`);try{let o=await Le(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return S(n??`bad revision '${t}'`)}}async function tt(e,t){try{return await Ur(e,t)}catch(n){return S(n.message)}}async function an(e,t){try{return await As(e,t)}catch(n){return S(n.message)}}function Cr(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 Se(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?rt(e.workTree,t):""}function V(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
+ `);return t===-1?e:e.slice(0,t)}function Vt(e){return S(`ambiguous argument '${e}': unknown revision or path not in the working tree.
56
56
  Use '--' to separate paths from revisions, like this:
57
- 'git <command> [<revision>...] -- [<file>...]'`)}function Ht(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${Y(t)}] ${fe(n)}`}async function Nn(e,t,n){if(!await F(e,n.operationRef))return n.noOpError;let o=await F(e,"ORIG_HEAD")??await Z(e);if(!o)return $(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Z(e),i=await j(e,o),a=await K(e),c=await eo(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await An(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 re(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function ht(e,t,n,r,o,s){let i=nn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Se(e,"commit",i);return await An(e,a),a}function Yt(e){let t=e.split(`
57
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Dt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${V(t)}] ${ue(n)}`}async function _n(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await Z(e);if(!o)return S(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Z(e),i=await j(e,o),a=await z(e),c=await eo(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Dn(e,o),await le(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await ae(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function wt(e,t,n,r,o,s){let i=nn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Te(e,"commit",i);return await Dn(e,a),a}function Yt(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 At(e){return e.endsWith(`
60
+ `}function Mt(e){return e.endsWith(`
61
61
  `)?e:`${e}
62
- `}var Ku,Vu,se=Ee(()=>{"use strict";$n();Ce();ie();mn();le();Fe();ue();Dn();gn();on();Ku=$("not a git repository (or any of the parent directories): .git"),Vu=$("this operation must be run in a work tree")});var Vc={};bd(Vc,{CommitHeap:()=>_n,countAheadBehind:()=>Si,findOrphanedCommits:()=>Ti,walkCommits:()=>Dt});async function*Dt(e,t,n){if(n?.topoOrder){yield*em(e,t,n);return}let r=await Kc(e,n?.exclude),o=new Set(r),s=new _n,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let c of a)o.has(c)||s.push(await Pr(e,c));for(;s.size>0;){let c=s.pop();if(o.has(c.hash)||(o.add(c.hash),yield c,i?.has(c.hash)))continue;let f=n?.firstParent?c.commit.parents.slice(0,1):c.commit.parents;for(let l of f)if(!o.has(l))try{s.push(await Pr(e,l))}catch{}}}async function*em(e,t,n){let r=await Kc(e,n?.exclude),o=new Set(r),s=new _n,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Pr(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 Pr(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 Si(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of Dt(e,t))r.add(a.hash);let o=new Set;for await(let a of Dt(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 Ti(e,t,n){let r=n?.maxCount??25,o=await ge(e,"refs"),s=[];for(let l of o)try{s.push(await Ne(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of Dt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new _n;for(f.push(await Pr(e,t));f.size>0&&a.length<r;){let l=f.pop();if(!c.has(l.hash)&&(c.add(l.hash),!i.has(l.hash))){a.push({hash:l.hash,subject:fe(l.commit.message)});for(let d of l.commit.parents)c.has(d)||f.push(await Pr(e,d))}}return a}async function Kc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Dt(e,t))n.add(r.hash);return n}async function Pr(e,t){return{hash:t,commit:await j(e,t)}}var _n,ir=Ee(()=>{"use strict";se();ie();ue();_n=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 Wo=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 Oa(e){return new Wo({_kind:"arg",type:e,required:!0})}function $a(){return Oa("string")}function Ia(){return Oa("number")}var Is=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var qo=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}};function Sa(e){return new qo({_kind:"option",type:e})}function Ta(){return Sa("string")}function va(){return Sa("number")}var J={string:Ta,number:va};function I(){return new Is}var q={string:$a,number:Ia};function yd(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
- 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=`Unknown command "${e.path}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}}}function zo(e){return e.map(yd).join(`
64
- `)}function Ed(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 Ss(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Ed(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 Ha(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[m,u]of Object.entries(e)){let h=Gr(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:Ss(h,x).map(b=>`--${b}`)}),l++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,l++;continue}let w=p??n[++l];if(w===void 0){o.push({type:"missing_value",name:g.key}),l++;continue}let y=jr(w,g.def.type,g.key,o);y!==void 0&&(a[g.key]=y),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),y=w.length>0?w:n[++l];if(y===void 0){o.push({type:"missing_value",name:g.key});break}let x=jr(y,g.def.type,g.key,o);x!==void 0&&(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=>jr(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]=jr(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=jr(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 jr(e,t,n,r){switch(t){case"string":return e;case"number":{let o=Number(e);if(Number.isNaN(o)){r.push({type:"invalid_type",name:n,expected:"number",received:e});return}return o}case"boolean":{if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;r.push({type:"invalid_type",name:n,expected:"boolean",received:e});return}default:return e}}function Gr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function wr(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=kd(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(`
65
- `)}function kd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Gr(i);if(a._kind==="flag"){let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c}`);let d=[];f.description&&d.push(f.description),f.counted&&d.push("(counted)"),f.default!==void 0&&d.push(`(default: ${f.default})`),r.push([l.join(" "),d.join(" ")])}else{let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c} <${f.type}>`);let d=[];f.description&&d.push(f.description),f.required&&d.push("(required)"),f.default!==void 0&&d.push(`(default: ${JSON.stringify(f.default)})`),f.env&&d.push(`[env: ${f.env}]`),r.push([l.join(" "),d.join(" ")])}}let o=Math.max(...r.map(([i])=>i.length)),s=[];t&&s.push(t);for(let[i,a]of r)if(a){let c=" ".repeat(o-i.length+2);s.push(` ${i}${c}${a}`)}else s.push(` ${i}`);return s}function Aa(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Da(e){return e?e.map(t=>t._def):[]}var Ts=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,Aa(n.options),Da(n.args),n.examples??[],n.handler,n.transformArgs);return r.parent=this,this.children.set(t,r),r}get fullPath(){let t=[],n=this;for(;n;)t.unshift(n.name),n=n.parent;return t.join(" ")}toCommand(){return{name:this.name,execute:this.execute.bind(this)}}get allOptions(){return this.options}toTokens(t){let n=[],r=this.allOptions,o=t;for(let[s,i]of Object.entries(r)){let a=o[s],c=Gr(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(!this.handler&&o&&!o.startsWith("-")){let s=Ss(o,[...this.children.keys()]);return{stdout:"",stderr:zo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Rd(t))return{stdout:wr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ha(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:zo(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:wr(this),stderr:"",exitCode:0}}};function Ko(e,t){return new Ts(e,t.description,Aa(t.options),Da(t.args),t.examples??[],t.handler,t.transformArgs)}function Rd(e){return e.some(t=>t==="--help"||t==="-h")}se();Xs();Ce();le();Ks();var no=1,Oi=2,to=4,$i=8,os=16,qc=new Set(["*","?","[","\\"]),Xu={glob:no,literal:Oi,icase:to,top:$i,exclude:os};function or(e){for(let t=0;t<e.length;t++)if(qc.has(e[t]))return!0;return!1}function Zu(e){for(let t=0;t<e.length;t++)if(qc.has(e[t]))return t;return e.length}function Wc(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=Xu[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=$i,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=os,r=r.slice(2));n&Oi&&n&no&&(n&=~no);let o;n&$i||t===""?o=Wc(r):o=Wc(`${t}/${r}`);let s=!!(n&Oi),i=s?!1:or(o),a=s?o.length:Zu(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function ro(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&to),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&to){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&no&&(i|=2),o&to&&(i|=1),tr(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&os?ro(o,t)&&(r=!0):ro(o,t)&&(n=!0);return n&&!r}tt();function zc(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:I().alias("A").describe("Add changes from all tracked and untracked files"),force:I().alias("f").describe("Allow adding otherwise ignored files"),update:I().alias("u").describe("Update tracked files"),"dry-run":I().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await K(s);return p=await Ii(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.
66
- Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await K(s),d=[],m=[];for(let p of f)or(p)?m.push(p):d.push(p);let u=[];for(let p of d){let g=$t(r.cwd,p),w=ft(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return $(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=l.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`)),k=await Qu(s,a,w,b);if(k){b&&((await r.fs.stat(g)).isDirectory?l=await Ii(s,l,g,w,c):l=(await sn(s,l,w)).index),u.push(k);continue}}if((await r.fs.stat(g)).isDirectory)l=await Ii(s,l,g,w,c);else{let b=l.entries.find(E=>E.path===w&&E.stage===0)?.hash,k=await sn(s,l,w);l=k.index,c.actions&&k.hash!==b&&c.actions.push(`add '${w}'
67
- `)}}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}'
68
- `);l={...l,entries:l.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return $(`pathspec '${p}' did not match any files`)}if(u.length>0)return n["dry-run"]||await ae(s,l),L(`The following paths are ignored by one of your .gitignore files:
62
+ `}var rm,sm,ce=Re(()=>{"use strict";Sn();$e();fe();mn();me();qe();pe();Mn();gn();on();rm=S("not a git repository (or any of the parent directories): .git"),sm=S("this operation must be run in a work tree")});var Yc={};Sd(Yc,{CommitHeap:()=>Fn,countAheadBehind:()=>Ti,findOrphanedCommits:()=>Hi,walkCommits:()=>jt});async function*jt(e,t,n){if(n?.topoOrder){yield*lm(e,t,n);return}let r=await Vc(e,n?.exclude),o=new Set(r),s=new Fn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let c of a)o.has(c)||s.push(await Pr(e,c));for(;s.size>0;){let c=s.pop();if(o.has(c.hash)||(o.add(c.hash),yield c,i?.has(c.hash)))continue;let f=n?.firstParent?c.commit.parents.slice(0,1):c.commit.parents;for(let l of f)if(!o.has(l))try{s.push(await Pr(e,l))}catch{}}}async function*lm(e,t,n){let r=await Vc(e,n?.exclude),o=new Set(r),s=new Fn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let u of a)o.has(u)||s.push(await Pr(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 Pr(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 Ti(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of jt(e,t))r.add(a.hash);let o=new Set;for await(let a of jt(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 Hi(e,t,n){let r=n?.maxCount??25,o=await be(e,"refs"),s=[];for(let l of o)try{s.push(await Le(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of jt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Fn;for(f.push(await Pr(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 Pr(e,d))}}return a}async function Vc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}async function Pr(e,t){return{hash:t,commit:await j(e,t)}}var Fn,ar=Re(()=>{"use strict";ce();fe();pe();Fn=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 zo=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 Oa(e){return new zo({_kind:"arg",type:e,required:!0})}function Sa(){return Oa("string")}function Ia(){return Oa("number")}var Ss=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 Ko=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 va(e){return new Ko({_kind:"option",type:e})}function Ta(){return va("string")}function Ha(){return va("number")}var Y={string:Ta,number:Ha};function $(){return new Ss}var q={string:Sa,number:Ia};function Id(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
+ 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 Vo(e){return e.map(Id).join(`
65
+ `)+`
66
+ `}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 Is(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 Aa(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[m,u]of Object.entries(e)){let h=Nr(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 y=s.get(h.slice(3));if(y&&y.def._kind==="flag"){a[y.key]=y.def.counted?0:!1,l++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Is(h,x).map(y=>`--${y}`)}),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=Lr(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(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 y=[];s.has(p)&&y.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:y});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),b=w.length>0?w:n[++l];if(b===void 0){o.push({type:"missing_value",name:g.key});break}let x=Lr(b,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=>Lr(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]=Lr(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=Lr(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 Lr(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 Nr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function br(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=Td(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 Td(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Nr(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 Da(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Ma(e){return e?e.map(t=>t._def):[]}var vs=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,Da(n.options),Ma(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=Nr(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=Is(o,[...this.children.keys()]);return{stdout:"",stderr:Vo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Hd(t))return{stdout:br(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Aa(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:Vo(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:br(this),stderr:"",exitCode:0}}};function Yo(e,t){return new vs(e,t.description,Da(t.options),Ma(t.args),t.examples??[],t.handler,t.transformArgs)}function Hd(e){return e.some(t=>t==="--help")}ce();Xs();$e();me();Ks();var no=1,Si=2,to=4,Ii=8,as=16,zc=new Set(["*","?","[","\\"]),im={glob:no,literal:Si,icase:to,top:Ii,exclude:as};function ir(e){for(let t=0;t<e.length;t++)if(zc.has(e[t]))return!0;return!1}function am(e){for(let t=0;t<e.length;t++)if(zc.has(e[t]))return t;return e.length}function qc(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=im[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Ii,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=as,r=r.slice(2));n&Si&&n&no&&(n&=~no);let o;n&Ii||t===""?o=qc(r):o=qc(`${t}/${r}`);let s=!!(n&Si),i=s?!1:ir(o),a=s?o.length:am(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function ro(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&to),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&to){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&no&&(i|=2),o&to&&(i|=1),nr(n,t,i)===0}function ye(e,t){let n=!1,r=!1;for(let o of e)o.magic&as?ro(o,t)&&(r=!0):ro(o,t)&&(n=!0);return n&&!r}ot();function Kc(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=Je(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 vi(s,p,a,"",c),n["dry-run"]||await le(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=vt(r.cwd,p),w=rt(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return S(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let y=l.entries.some(k=>k.path===w||k.path.startsWith(`${w}/`)),E=await fm(s,a,w,y);if(E){y&&((await r.fs.stat(g)).isDirectory?l=await vi(s,l,g,w,c):l=(await sn(s,l,w)).index),u.push(E);continue}}if((await r.fs.stat(g)).isDirectory)l=await vi(s,l,g,w,c);else{let y=l.entries.find(k=>k.path===w&&k.stage===0)?.hash,E=await sn(s,l,w);l=E.index,c.actions&&E.hash!==y&&c.actions.push(`add '${w}'
69
+ `)}}else if(l.entries.some(y=>y.path===w||y.path.startsWith(`${w}/`))){if(c.actions)for(let y of l.entries)(y.path===w||y.path.startsWith(`${w}/`))&&c.actions.push(`remove '${y.path}'
70
+ `);l={...l,entries:l.entries.filter(y=>y.path!==w&&!y.path.startsWith(`${w}/`))}}else return S(`pathspec '${p}' did not match any files`)}if(u.length>0)return n["dry-run"]||await le(s,l),L(`The following paths are ignored by one of your .gitignore files:
69
71
  ${u.join(`
70
72
  `)}
71
73
  hint: Use -f if you really want to add them.
72
74
  hint: Disable this message with "git config set advice.addIgnoredFile false"
73
- `);if(m.length>0){let p=await Ju(s,r.cwd,l,m,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 Ju(e,t,n,r,o){let s=e.workTree,i=mt(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&&ro(a[m],d)&&(c[m]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!ye(a,d.path))continue;f(d.path);let m=T(s,d.path);if(await e.fs.exists(m)){let u=await sn(e,n,d.path);n=u.index,o?.actions&&u.hash!==d.hash&&o.actions.push(`add '${d.path}'
75
+ `);if(m.length>0){let p=await cm(s,r.cwd,l,m,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await le(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function cm(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&&ro(a[m],d)&&(c[m]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!ye(a,d.path))continue;f(d.path);let m=I(s,d.path);if(await e.fs.exists(m)){let u=await sn(e,n,d.path);n=u.index,o?.actions&&u.hash!==d.hash&&o.actions.push(`add '${d.path}'
74
76
  `)}else o?.actions&&o.actions.push(`remove '${d.path}'
75
- `),l.push(d.path)}for(let d of l)n=at(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(u=>u.path)),m=await et(e,s,"",{skipIgnore:o?.skipIgnore});for(let u of m){if(d.has(u)||!ye(a,u))continue;f(u),o?.actions&&o.actions.push(`add '${u}'
76
- `),n=(await sn(e,n,u)).index}}for(let d=0;d<a.length;d++){let m=a[d];if(!c[d]&&!(m.magic&os))return{index:n,error:$(`pathspec '${m.original}' did not match any files`)}}return{index:n}}async function Ii(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=T(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,m=await sn(e,t,f.path);t=m.index,o?.actions&&(d||m.hash!==f.hash)&&o.actions.push(`add '${f.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 st(e,s,"",{skipIgnore:o?.skipIgnore});for(let u of m){if(d.has(u)||!ye(a,u))continue;f(u),o?.actions&&o.actions.push(`add '${u}'
78
+ `),n=(await sn(e,n,u)).index}}for(let d=0;d<a.length;d++){let m=a[d];if(!c[d]&&!(m.magic&as))return{index:n,error:S(`pathspec '${m.original}' did not match any files`)}}return{index:n}}async function vi(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=I(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,m=await sn(e,t,f.path);t=m.index,o?.actions&&(d||m.hash!==f.hash)&&o.actions.push(`add '${f.path}'
77
79
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
78
- `),a.push(f.path)}for(let f of a)t=at(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await et(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
79
- `),t=(await sn(e,t,d)).index}}return t}async function Qu(e,t,n,r){let o=await Rr(e);try{let i=await e.fs.readFile(T(t,".gitignore"));o=nr(o,i,"",T(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=T(t,a);if(rn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(T(c,".gitignore"));o=nr(o,f,a,T(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(T(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(rn(o,n,i)==="ignored")return n}return null}se();se();ir();ie();le();ue();async function Pe(e,t){let n=T(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Te(e,t,n){await e.fs.writeFile(T(e.gitDir,t),n)}async function pe(e,t){let n=T(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function is(e){await de(e,"MERGE_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"SQUASH_MSG")}async function Mt(e){await de(e,"CHERRY_PICK_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG")}async function jt(e){await de(e,"REVERT_HEAD"),await de(e,"ORIG_HEAD"),await pe(e,"MERGE_MSG")}async function ar(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await de(e,t);await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"SQUASH_MSG")}var vi="DETACH_POINT";async function Yc(e,t){await e.fs.writeFile(T(e.gitDir,vi),t)}async function pt(e){let t=T(e.gitDir,vi);await e.fs.exists(t)&&await e.fs.rm(t)}async function as(e){let t=T(e.gitDir,vi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}le();ue();async function Rt(e){let t=await Pe(e,"BISECT_START");return t!=null&&t.trim().length>0}async function cs(e){let t=await Pe(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
80
- `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function so(e){let t=(await Pe(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await cs(e),o=await F(e,`refs/bisect/${n}`),s=[],i=[],a=await ge(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await Pe(e,"BISECT_HEAD")!=null||await e.fs.exists(T(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(T(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function xt(e,t){let n=await Pe(e,"BISECT_LOG")??"";await Te(e,"BISECT_LOG",n+t+`
81
- `)}async function oo(e){let t=await ge(e,"refs/bisect");for(let r of t)await de(e,r.name);await pe(e,"BISECT_EXPECTED_REV"),await pe(e,"BISECT_ANCESTORS_OK"),await pe(e,"BISECT_LOG"),await pe(e,"BISECT_TERMS"),await pe(e,"BISECT_NAMES"),await pe(e,"BISECT_FIRST_PARENT"),await pe(e,"BISECT_HEAD"),await pe(e,"BISECT_START");let n=T(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Xc(e,t,n,r,o){let s=[],i=new Map;for await(let g of Dt(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:fe(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,y=[g.hash],x=0;for(;x<y.length;){let b=y[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let k=i.get(b);if(k)for(let E of k)!w.has(E)&&c.has(E)&&y.push(E)}f.set(g.hash,w.size)}let l=s[0].hash,d=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}let m=!1;if(d===a){m=!0;for(let g of s){let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}}let u=s.find(g=>g.hash===l),h=tm(a),p=nm(a);return{hash:u.hash,subject:u.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:m}}function tm(e){return Math.floor((e-1)/2)}function nm(e){return e<=1?0:Math.ceil(Math.log2(e))}function Zc(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
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 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}'
81
+ `),t=(await sn(e,t,d)).index}}return t}async function fm(e,t,n,r){let o=await xr(e);try{let i=await e.fs.readFile(I(t,".gitignore"));o=rr(o,i,"",I(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=I(t,a);if(rn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(I(c,".gitignore"));o=rr(o,f,a,I(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(I(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(rn(o,n,i)==="ignored")return n}return null}ce();ce();ar();fe();me();pe();async function Oe(e,t){let n=I(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Ae(e,t,n){await e.fs.writeFile(I(e.gitDir,t),n)}async function we(e,t){let n=I(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function cs(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await we(e,"MERGE_MSG"),await we(e,"MERGE_MODE"),await we(e,"SQUASH_MSG")}async function Gt(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await we(e,"MERGE_MSG")}async function Lt(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await we(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 we(e,"MERGE_MSG"),await we(e,"MERGE_MODE"),await we(e,"SQUASH_MSG")}var Ai="DETACH_POINT";async function Xc(e,t){await e.fs.writeFile(I(e.gitDir,Ai),t)}async function bt(e){let t=I(e.gitDir,Ai);await e.fs.exists(t)&&await e.fs.rm(t)}async function fs(e){let t=I(e.gitDir,Ai);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();pe();async function Pt(e){let t=await Oe(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ls(e){let t=await Oe(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 so(e){let t=(await Oe(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ls(e),o=await B(e,`refs/bisect/${n}`),s=[],i=[],a=await be(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 Oe(e,"BISECT_HEAD")!=null||await e.fs.exists(I(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(I(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function $t(e,t){let n=await Oe(e,"BISECT_LOG")??"";await Ae(e,"BISECT_LOG",n+t+`
83
+ `)}async function oo(e){let t=await be(e,"refs/bisect");for(let r of t)await he(e,r.name);await we(e,"BISECT_EXPECTED_REV"),await we(e,"BISECT_ANCESTORS_OK"),await we(e,"BISECT_LOG"),await we(e,"BISECT_TERMS"),await we(e,"BISECT_NAMES"),await we(e,"BISECT_FIRST_PARENT"),await we(e,"BISECT_HEAD"),await we(e,"BISECT_START");let n=I(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Zc(e,t,n,r,o){let s=[],i=new Map;for await(let g of jt(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],x=0;for(;x<b.length;){let y=b[x++];if(w.has(y)||!c.has(y))continue;w.add(y);let E=i.get(y);if(E)for(let k of E)!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 m=!1;if(d===a){m=!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),h=dm(a),p=um(a);return{hash:u.hash,subject:u.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:m}}function dm(e){return Math.floor((e-1)/2)}function um(e){return e<=1?0:Math.ceil(Math.log2(e))}function Jc(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
84
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
83
85
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
84
- `}function Jc(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
86
+ `}function Qc(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
85
87
  [${e.hash}] ${e.subject}
86
- `}async function Qc(e,t){let n=await j(e,t),r=fe(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
88
+ `}async function ef(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
87
89
  `;return i+=`commit ${t}
88
90
  `,i+=`Author: ${n.author.name} <${n.author.email}>
89
91
  `,i+=`Date: ${s}
90
92
  `,i+=`
91
93
  `,i+=` ${r}
92
94
  `,i+=`
93
- `,i}se();ir();_e();Ce();ie();le();Fe();ue();se();ir();_e();Ce();ie();le();ie();mn();le();function Cr(e){return T(e.gitDir,"rebase-merge")}async function Gt(e){return e.fs.exists(Cr(e))}async function gt(e){let t=Cr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(T(t,"head-name")),r=await e.fs.readFile(T(t,"orig-head")),o=await e.fs.readFile(T(t,"onto")),s=Number.parseInt(await e.fs.readFile(T(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(T(t,"end")),10),a=await e.fs.exists(T(t,"git-rebase-todo"))?T(t,"git-rebase-todo"):T(t,"todo"),c=ef(await e.fs.readFile(a)),f=await e.fs.exists(T(t,"done"))?await e.fs.readFile(T(t,"done")):"",l=ef(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Hi(e,t){let n=Cr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(T(n,"head-name"),`${t.headName}
94
- `),await e.fs.writeFile(T(n,"orig-head"),`${t.origHead}
95
- `),await e.fs.writeFile(T(n,"onto"),`${t.onto}
96
- `),await e.fs.writeFile(T(n,"msgnum"),`${String(t.msgnum)}
97
- `),await e.fs.writeFile(T(n,"end"),`${String(t.end)}
98
- `),await e.fs.writeFile(T(n,"git-rebase-todo"),ao(t.todo)),await e.fs.writeFile(T(n,"done"),ao(t.done)),await e.fs.writeFile(T(n,"interactive"),"")}async function rf(e){let t=Cr(e),n=await gt(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(T(t,"msgnum"),`${String(n.msgnum)}
99
- `),await e.fs.writeFile(T(t,"git-rebase-todo"),ao(n.todo)),await e.fs.writeFile(T(t,"done"),ao(n.done))}async function Ai(e){let t=Cr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function co(e,t,n){let r=Cr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(T(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
95
+ `,i}ce();ar();We();$e();fe();me();qe();pe();ce();ar();We();$e();fe();me();fe();mn();me();function $r(e){return I(e.gitDir,"rebase-merge")}async function Nt(e){return e.fs.exists($r(e))}async function yt(e){let t=$r(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(I(t,"head-name")),r=await e.fs.readFile(I(t,"orig-head")),o=await e.fs.readFile(I(t,"onto")),s=Number.parseInt(await e.fs.readFile(I(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(I(t,"end")),10),a=await e.fs.exists(I(t,"git-rebase-todo"))?I(t,"git-rebase-todo"):I(t,"todo"),c=tf(await e.fs.readFile(a)),f=await e.fs.exists(I(t,"done"))?await e.fs.readFile(I(t,"done")):"",l=tf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Di(e,t){let n=$r(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(I(n,"head-name"),`${t.headName}
96
+ `),await e.fs.writeFile(I(n,"orig-head"),`${t.origHead}
97
+ `),await e.fs.writeFile(I(n,"onto"),`${t.onto}
98
+ `),await e.fs.writeFile(I(n,"msgnum"),`${String(t.msgnum)}
99
+ `),await e.fs.writeFile(I(n,"end"),`${String(t.end)}
100
+ `),await e.fs.writeFile(I(n,"git-rebase-todo"),ao(t.todo)),await e.fs.writeFile(I(n,"done"),ao(t.done)),await e.fs.writeFile(I(n,"interactive"),"")}async function sf(e){let t=$r(e),n=await yt(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(I(t,"msgnum"),`${String(n.msgnum)}
101
+ `),await e.fs.writeFile(I(t,"git-rebase-todo"),ao(n.todo)),await e.fs.writeFile(I(t,"done"),ao(n.done))}async function Mi(e){let t=$r(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function co(e,t,n){let r=$r(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(I(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
100
102
  GIT_AUTHOR_EMAIL='${n.email}'
101
103
  GIT_AUTHOR_DATE='${o}'
102
- `),await e.fs.writeFile(T(r,"stopped-sha"),`${t}
103
- `)}function ef(e){let t=[];for(let n of e.split(`
104
+ `),await e.fs.writeFile(I(r,"stopped-sha"),`${t}
105
+ `)}function tf(e){let t=[];for(let n of e.split(`
104
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 ao(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
105
107
  `)}
106
- `}async function sf(e,t,n){let r=new Map,[o,s]=await Promise.all([tf(e,t,r),tf(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 nf(e,r,n,i),left:await nf(e,r,t,a)}}async function tf(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 io(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function nf(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 io(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 io(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 io(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 io(e,t,n){let r=n.get(t);if(r)return r;let o=await we(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:tn(o.content)};return n.set(t,s),s}ue();ie();function Or(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function rm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Or(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Or(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var sm=50;async function nt(e,t,n=sm){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=rm(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 om(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 cm(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 om(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=Or(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=Or(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 kt(e,l.oldHash),u=await kt(e,d.newHash),h=am(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 of=107927;function fo(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))%of;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%of;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 im(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 am(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:af(e.length,fo(e),t.length,fo(t))}function af(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=im(t,r);return Math.floor(i*100/o)}async function cm(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await kt(e,l.oldHash);o.push({size:d.length,chunks:fo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await kt(e,l.newHash);s.push({size:d.length,chunks:fo(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=af(m.size,m.chunks,p.size,p.chunks);if(g>=r){let w=Or(d.path)===Or(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 cn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let 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}`}ve();tt();async function rt(e,t){let n=await Q(e),r=await Z(e),o,s=!1;n&&n.type==="symbolic"?o=Re(n.target):(s=!0,o="HEAD detached");let i=t?.index??await K(e),a=Mi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Di(e,c,i,a),d=await Tt(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)=>Oe(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=ji(u,h);return fm(e,r,s,o,i,l,m,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function cf(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${Y(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${Y(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function fm(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,m=await F(e,"CHERRY_PICK_HEAD"),u=await F(e,"REVERT_HEAD"),h=await F(e,"MERGE_HEAD"),p=!m&&!h,w=await Gt(e)?await gt(e):null;if(n&&w){let C=Y(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await as(e);if(C){let P=t===C?"at":"from";l.push(`HEAD detached ${P} ${Y(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await he(e),P=await En(e,C,r);if(P){let v=cr(P,{abbreviated:f?.fromCommit});for(let D of v.trimEnd().split(`
107
- `))l.push(D);d=!0}}if(d&&(w||m||u||h)&&l.push(""),w&&h)cf(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=St(o),P=await e.fs.exists(T(e.gitDir,"MERGE_MSG"));cf(l,w);let D=w.headName==="detached HEAD"?null:Re(w.headName),O=Y(w.onto),H=D?` branch '${D}' on '${O}'`:"";if(C)l.push(`You are currently rebasing${H}.`),l.push(' (fix conflicts and then run "git rebase --continue")'),l.push(' (use "git rebase --skip" to skip this patch)'),l.push(' (use "git rebase --abort" to check out the original branch)');else if(P)l.push(`You are currently rebasing${H}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let G=H?`You are currently editing a commit while rebasing${H}.`:"You are currently editing a commit during a rebase.";l.push(G),l.push(' (use "git commit --amend" to amend the current commit)'),l.push(' (use "git rebase --continue" once you are satisfied with your changes)')}d=!0}else m?(l.push(`You are currently cherry-picking commit ${Y(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 ${Y(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 Rt(e)){let P=(await Pe(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 y=f?.isInitial??!t;y&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(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(` ${ff(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(` ${lm(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(k),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${ff(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 R=s.length>0||!!h&&a.length===0;return!E&&d&&(f?.noWarn||R)&&l.push(""),!R&&!f?.noWarn&&(!E&&d&&i.length===0&&a.length===0&&c.length===0&&l.push(""),i.length>0||a.length>0?l.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?l.push('nothing added to commit but untracked files present (use "git add" to track)'):y?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
108
+ `}async function of(e,t,n){let r=new Map,[o,s]=await Promise.all([nf(e,t,r),nf(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 rf(e,r,n,i),left:await rf(e,r,t,a)}}async function nf(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 io(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function rf(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 io(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 io(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 io(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 io(e,t,n){let r=n.get(t);if(r)return r;let o=await Ee(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:tn(o.content)};return n.set(t,s),s}pe();fe();function Or(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function mm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Or(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Or(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var hm=50;async function it(e,t,n=hm){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=mm(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 pm(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 bm(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 pm(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=Or(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=Or(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 Ct(e,l.oldHash),u=await Ct(e,d.newHash),h=wm(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 af=107927;function fo(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))%af;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%af;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 gm(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 wm(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:cf(e.length,fo(e),t.length,fo(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}=gm(t,r);return Math.floor(i*100/o)}async function bm(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Ct(e,l.oldHash);o.push({size:d.length,chunks:fo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Ct(e,l.newHash);s.push({size:d.length,chunks:fo(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=cf(m.size,m.chunks,p.size,p.chunks);if(g>=r){let w=Or(d.path)===Or(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 cn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let 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}`}He();ot();async function at(e,t){let n=await Q(e),r=await Z(e),o,s=!1;n&&n.type==="symbolic"?o=Ce(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Gi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await ji(e,c,i,a),d=await At(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)=>Se(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Li(u,h);return ym(e,r,s,o,i,l,m,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function ff(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${V(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${V(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function ym(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 Nt(e)?await yt(e):null;if(n&&w){let C=V(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await fs(e);if(C){let P=t===C?"at":"from";l.push(`HEAD detached ${P} ${V(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await ge(e),P=await En(e,C,r);if(P){let H=fr(P,{abbreviated:f?.fromCommit});for(let D of H.trimEnd().split(`
109
+ `))l.push(D);d=!0}}if(d&&(w||m||u||h)&&l.push(""),w&&h)ff(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=Ht(o),P=await e.fs.exists(I(e.gitDir,"MERGE_MSG"));ff(l,w);let D=w.headName==="detached HEAD"?null:Ce(w.headName),O=V(w.onto),A=D?` branch '${D}' on '${O}'`:"";if(C)l.push(`You are currently rebasing${A}.`),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${A}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let G=A?`You are currently editing a commit while rebasing${A}.`:"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 m?(l.push(`You are currently cherry-picking commit ${V(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 ${V(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 Pt(e)){let P=(await Oe(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 b=f?.isInitial??!t;b&&(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 E=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:"),x&&l.push(x);for(let C of s)l.push(` ${lf(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(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(` ${Em(P.status,P.path)}`);l.push(""),k=!0}if(i.length>0){!k&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(E),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${lf(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 R=s.length>0||!!h&&a.length===0;return!k&&d&&(f?.noWarn||R)&&l.push(""),!R&&!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(`
108
110
  `)}
109
- `}async function Di(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 ce(e,s),a=new Map(De(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 nt(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)=>Oe(u.path,h.path))}function Mi(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Oe(r.path,o.path))}function ji(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 ff(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function lm(e,t){return`${e}:`.padEnd(17)+t}async function En(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await F(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await F(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:l,behind:d}=await Si(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function lf(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 cr(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
111
+ `}async function ji(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(Ge(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)=>Se(u.path,h.path))}function Gi(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)=>Se(r.path,o.path))}function Li(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 lf(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Em(e,t){return`${e}:`.padEnd(17)+t}async function En(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 Ti(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function df(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.
110
112
  (use "git branch --unset-upstream" to fixup)
111
113
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
112
114
  `;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}.
@@ -116,19 +118,19 @@ GIT_AUTHOR_DATE='${o}'
116
118
  `}let n=`Your branch and '${e.upstream}' have diverged,
117
119
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
118
120
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
119
- `}ve();on();tt();async function lo(e){let t=await Je(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await F(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function kn(e){let t="";return await F(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
120
- `),await F(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
121
- `),await ar(e),t}function dm(e){let t=new Set,n=[];for(let r of e.entries)r.stage>0&&!t.has(r.path)&&(t.add(r.path),n.push(`${r.path}: needs merge`));return n.sort(),n.length>0?`${n.join(`
121
+ `}He();on();ot();async function lo(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 kn(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
122
+ `),await B(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
123
+ `),await cr(e),t}function km(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(`
122
124
  `)}
123
- `:""}function Fn(e){return e.entries.some(t=>t.stage>0)?{stdout:dm(e),stderr:`error: you need to resolve your current index first
124
- `,exitCode:1}:null}async function uo(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");if(r)return um(e,t,n,r);let o=await K(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&ye(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&ye(s,c.path))?L(`error: path '${t[0]}' is unmerged
125
+ `:""}function Un(e){return e.entries.some(t=>t.stage>0)?{stdout:km(e),stderr:`error: you need to resolve your current index first
126
+ `,exitCode:1}:null}async function uo(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");if(r)return Rm(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&ye(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&ye(s,c.path))?L(`error: path '${t[0]}' is unmerged
125
127
  `):L(`error: pathspec '${t[0]}' did not match any file(s) known to git
126
- `);for(let a of i)await ct(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function um(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
127
- `);for(let c of a){let f=o.get(c);f&&(await ct(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Et(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:$e()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function mo(e,t,n,r,o){if(!e.workTree)return $("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await K(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)ye(a,f.path)&&c.add(f.path);if(c.size===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
128
- `);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 ct(e,{path:m.path,hash:m.hash,mode:m.mode});else if(s){let u=T(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 L(`error: path '${f}' does not have ${r===2?"our":"their"} version
129
- `)}return{stdout:"",stderr:"",exitCode:0}}async function fr(e,t,n){if(!e.workTree)return"";let r=await Ve(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=T(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 ut("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(`
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 Rm(e,t,n,r){let o=await de(e,r),s=await z(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)ye(i,c)&&a.push(c);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
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=xt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Ie()}))}return await le(e,s),{stdout:"",stderr:"",exitCode:0}}async function mo(e,t,n,r,o){if(!e.workTree)return S("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await z(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)ye(a,f.path)&&c.add(f.path);if(c.size===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
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=I(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 L(`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 ze(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=I(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(`
130
132
  `)}
131
- `)}var df=5;function mm(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>df?df-1:t,i=e.slice(0,o).map(c=>` ${Y(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
133
+ `)}var uf=5;function xm(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>uf?uf-1:t,i=e.slice(0,o).map(c=>` ${V(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
132
134
  any of your branches:
133
135
 
134
136
  ${i.join(`
@@ -137,12 +139,12 @@ ${i.join(`
137
139
  If you want to keep ${r} by creating a new branch, this may be a good time
138
140
  to do so with:
139
141
 
140
- git branch <new-branch-name> ${Y(e[0].hash)}
142
+ git branch <new-branch-name> ${V(e[0].hash)}
141
143
 
142
- `}async function Gi(e,t){let n=await j(e,t);return`Previous HEAD position was ${Y(t)} ${fe(n.message)}
143
- `}async function ho(e,t,n){let r=await Ti(e,t,{targetHash:n});return r.length>0?mm(r):t!==n?Gi(e,t):""}async function lr(e,t,n,r,o,s){let i=await Q(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
144
- `,exitCode:0};let a=await K(e),c=Fn(a);if(c)return c;let f=await Z(e),d=(await j(e,r)).tree,m=null;if(f&&(m=(await j(e,f)).tree),m!==d){let x=await Ln(e,m,d,a);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await ae(e,a),await Me(e,x.worktreeOps)}let u="";i?.type==="direct"&&f&&(u=await ho(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??te;await ze(e,"HEAD",n),await pt(e);let p=await kn(e);await re(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await fr(e,d,a),w=await he(e),y=await En(e,w,t);return y&&(g+=cr(y)),{stdout:g,stderr:`${u}Switched to branch '${t}'
145
- ${p}`,exitCode:0}}async function Un(e,t,n,r,o){let s=await K(e),i=Fn(s);if(i)return i;let a=await Z(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Ln(e,l,f,s);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await ae(e,s),await Me(e,x.worktreeOps)}let d=await Q(e),m=d?.type==="direct"&&a===t;if(await X(e,"HEAD",t),!m){await Yc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??te;await re(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let u=await kn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=Y(t),p=fe(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await ho(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
144
+ `}async function Ni(e,t){let n=await j(e,t);return`Previous HEAD position was ${V(t)} ${ue(n.message)}
145
+ `}async function ho(e,t,n){let r=await Hi(e,t,{targetHash:n});return r.length>0?xm(r):t!==n?Ni(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=Un(a);if(c)return c;let f=await Z(e),d=(await j(e,r)).tree,m=null;if(f&&(m=(await j(e,f)).tree),m!==d){let x=await Nn(e,m,d,a);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await le(e,a),await Ne(e,x.worktreeOps)}let u="";i?.type==="direct"&&f&&(u=await ho(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??te;await Ye(e,"HEAD",n),await bt(e);let p=await kn(e);await ae(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 ge(e),b=await En(e,w,t);return b&&(g+=fr(b)),{stdout:g,stderr:`${u}Switched to branch '${t}'
147
+ ${p}`,exitCode:0}}async function Bn(e,t,n,r,o){let s=await z(e),i=Un(s);if(i)return i;let a=await Z(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Nn(e,l,f,s);if(!x.success)return x.errorOutput??L("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await le(e,s),await Ne(e,x.worktreeOps)}let d=await Q(e),m=d?.type==="direct"&&a===t;if(await X(e,"HEAD",t),!m){await Xc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??te;await ae(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let u=await kn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=V(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await ho(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
146
148
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
147
149
 
148
150
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -161,93 +163,93 @@ Or undo this operation with:
161
163
  Turn off this advice by setting config variable advice.detachedHead to false
162
164
 
163
165
  HEAD is now at ${h} ${p}
164
- `,w+=u,{stdout:await fr(e,f,s),stderr:w,exitCode:0}}async function hm(e,t){if(t.startsWith("refs/remotes/")){if(!await F(e,t))return null;let s=t.slice(13).split("/");if(s.length<2)return null;let i=s[0],a=s.slice(1).join("/");return{remote:i,branch:a,ref:t}}let n=`refs/remotes/${t}`;if(await F(e,n)){let o=t.split("/");if(o.length<2)return null;let s=o[0],i=o.slice(1).join("/");return{remote:s,branch:i,ref:n}}return null}async function po(e,t,n){let r=await hm(e,n);if(!r||await ke(e,"branch.autoSetupMerge")==="false")return"";let s=await he(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await Ye(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
165
- `}async function go(e,t){let n=await ge(e,"refs/remotes"),r=[];for(let o of n){let s=o.name.replace(/^refs\/remotes\//,"").split("/"),i=s[0];s.length>=2&&i&&s.slice(1).join("/")===t&&r.push({remote:i,ref:o.name})}if(r.length===1){let o=r[0];return{remote:o.remote,startPoint:o.ref,trackingRef:o.ref}}if(r.length>1){let o=await ke(e,"checkout.defaultRemote");if(o){let s=r.filter(i=>i.remote===o);if(s.length===1){let i=s[0];return{remote:i.remote,startPoint:i.ref,trackingRef:i.ref}}}}return null}ie();le();ue();gn();var uf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ls={stdout:`You need to start by "git bisect start"
166
- `,stderr:"",exitCode:1};async function Li(e){let t=await Pe(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Z(e);return n||$("no current commit")}function mf(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]
167
- `,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:bm(a,o.env,t,s,i)}});pm(n,t),gm(n,t),ym(n,t),Em(n,t),Rm(n,t),xm(n,t),Cm(n,t),$m(n,t),Im(n,t)}function pm(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":J.string().describe("Alternate term for new/bad"),"term-bad":J.string().describe("Alternate term for new/bad"),"term-old":J.string().describe("Alternate term for old/good"),"term-good":J.string().describe("Alternate term for old/good"),"no-checkout":I().describe("Do not checkout the bisection commit"),"first-parent":I().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return uf.has(a)?$(`'${a}' is not a valid term`):uf.has(c)?$(`'${c}' is not a valid term`):a===c?$("'bad' and 'good' terms must be different"):hf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function hf(e,t,n,r,o,s,i,a){await Rt(e)&&await oo(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Z(e)??"HEAD",await Te(e,"BISECT_START",f+`
168
- `),await Te(e,"BISECT_TERMS",`${o}
166
+ `,w+=u,{stdout:await lr(e,f,s),stderr:w,exitCode:0}}async function Cm(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 po(e,t,n){let r=await Cm(e,n);if(!r||await xe(e,"branch.autoSetupMerge")==="false")return"";let s=await ge(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await Ze(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
167
+ `}async function go(e,t){let n=await be(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}fe();me();pe();gn();var mf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),us={stdout:`You need to start by "git bisect start"
168
+ `,stderr:"",exitCode:1};async function _i(e){let t=await Oe(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Z(e);return n||S("no current commit")}function hf(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:Sm(a,o.env,t,s,i)}});Pm(n,t),$m(n,t),Im(n,t),vm(n,t),Hm(n,t),Am(n,t),Mm(n,t),Gm(n,t),Lm(n,t)}function Pm(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Y.string().describe("Alternate term for new/bad"),"term-bad":Y.string().describe("Alternate term for new/bad"),"term-old":Y.string().describe("Alternate term for old/good"),"term-good":Y.string().describe("Alternate term for old/good"),"no-checkout":$().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=Je(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 mf.has(a)?S(`'${a}' is not a valid term`):mf.has(c)?S(`'${c}' is not a valid term`):a===c?S("'bad' and 'good' terms must be different"):pf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function pf(e,t,n,r,o,s,i,a){await Pt(e)&&await oo(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Z(e)??"HEAD",await Ae(e,"BISECT_START",f+`
170
+ `),await Ae(e,"BISECT_TERMS",`${o}
169
171
  ${s}
170
- `),await Te(e,"BISECT_NAMES",`
171
- `),a&&await Te(e,"BISECT_FIRST_PARENT",""),i){let m=await Z(e);m&&await Te(e,"BISECT_HEAD",m)}if(r.length>0){let m=r[0],u=await vt(e,m);if(M(u))return u;await X(e,`refs/bisect/${o}`,u);let h=await j(e,u);await xt(e,`# ${o}: [${u}] ${fe(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await vt(e,g);if(M(w))return w;await X(e,`refs/bisect/${s}-${w}`,w);let y=await j(e,w);await xt(e,`# ${s}: [${w}] ${fe(y.message)}`)}}let l=r.map(m=>`'${m}'`),d=l.length>0?` ${l.join(" ")}`:"";return await xt(e,`git bisect start${d}`),ds(e,t,n)}function gm(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:wm(s,o.env,t,n,r.rev)}})}async function wm(e,t,n,r,o){if(!await Rt(e))return ls;let s=await cs(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return fs(e,t,n,i,s,o)}async function bm(e,t,n,r,o){if(!await Rt(e))return ls;let s=await cs(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
172
- `,exitCode:1}:fs(e,t,n,r,s,o[0])}async function fs(e,t,n,r,o,s){let i;if(s){let f=await vt(e,s);if(M(f))return f;i=f}else{let f=await Li(e);if(M(f))return f;i=f}let a=await j(e,i),c=fe(a.message);return r===o.termBad?await X(e,`refs/bisect/${o.termBad}`,i):await X(e,`refs/bisect/${o.termGood}-${i}`,i),await xt(e,`# ${r}: [${i}] ${c}`),await xt(e,`git bisect ${r} ${i}`),ds(e,t,n)}function ym(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 Rt(s))return ls;let i=n.revs??[];if(i.length===0){let a=await Li(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 vt(s,a);if(M(l))return l;c=l}await X(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await xt(s,`# skip: [${c}] ${fe(f.message)}`),await xt(s,`git bisect skip ${c}`)}return ds(s,r.env,t)}})}function Em(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 Rt(s)?km(s,r.env,t,n.commit):{stdout:`We are not bisecting.
173
- `,stderr:"",exitCode:0}}})}async function km(e,t,n,r){let o=(await Pe(e,"BISECT_START"))?.trim()??"";if(await oo(e),r){let s=await vt(e,r);return M(s)?s:Un(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await F(e,s);if(i)return lr(e,o,s,i,t,n);let a=await Be(e,o);if(a)return Un(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Rm(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await Rt(s)?{stdout:await Pe(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
174
- `,exitCode:1}}})}function xm(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:T(r.cwd,n.logfile);if(!await r.fs.exists(i))return $(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Pm(s,r.env,t,a)}})}async function Pm(e,t,n,r){await Rt(e)&&await oo(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
175
- `)){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 hf(e,t,n,m,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await fs(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await fs(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let m of l?l.split(/\s+/):[]){await X(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await xt(e,`# skip: [${m}] ${fe(u.message)}`),await xt(e,`git bisect skip ${m}`)}d=await ds(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Cm(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 Rt(s))return ls;if(!r.exec)return $("bisect run requires shell execution support");let i=n.cmd.join(" ");return Om(s,r.env,t,i,r.exec,r.cwd)}})}async function Om(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
176
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let m=await Li(e);if(M(m))return m;await X(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await xt(e,`# skip: [${m}] ${fe(u.message)}`),await xt(e,`git bisect skip ${m}`);let h=await ds(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
177
- `,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await so(e),l=c===0?f.termGood:f.termBad,d=await fs(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
178
- `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function $m(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":I().describe("Show the term for the old state"),"term-bad":I().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Rt(s))return{stdout:"",stderr:`error: no terms defined
179
- `,exitCode:1};let{termBad:i,termGood:a}=await cs(s);return n["term-good"]?{stdout:`${a}
172
+ `),await Ae(e,"BISECT_NAMES",`
173
+ `),a&&await Ae(e,"BISECT_FIRST_PARENT",""),i){let m=await Z(e);m&&await Ae(e,"BISECT_HEAD",m)}if(r.length>0){let m=r[0],u=await gt(e,m);if(M(u))return u;await X(e,`refs/bisect/${o}`,u);let h=await j(e,u);await $t(e,`# ${o}: [${u}] ${ue(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await gt(e,g);if(M(w))return w;await X(e,`refs/bisect/${s}-${w}`,w);let b=await j(e,w);await $t(e,`# ${s}: [${w}] ${ue(b.message)}`)}}let l=r.map(m=>`'${m}'`),d=l.length>0?` ${l.join(" ")}`:"";return await $t(e,`git bisect start${d}`),ms(e,t,n)}function $m(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:Om(s,o.env,t,n,r.rev)}})}async function Om(e,t,n,r,o){if(!await Pt(e))return us;let s=await ls(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ds(e,t,n,i,s,o)}async function Sm(e,t,n,r,o){if(!await Pt(e))return us;let s=await ls(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
174
+ `,exitCode:1}:ds(e,t,n,r,s,o[0])}async function ds(e,t,n,r,o,s){let i;if(s){let f=await gt(e,s);if(M(f))return f;i=f}else{let f=await _i(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await X(e,`refs/bisect/${o.termBad}`,i):await X(e,`refs/bisect/${o.termGood}-${i}`,i),await $t(e,`# ${r}: [${i}] ${c}`),await $t(e,`git bisect ${r} ${i}`),ms(e,t,n)}function Im(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 Pt(s))return us;let i=n.revs??[];if(i.length===0){let a=await _i(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 gt(s,a);if(M(l))return l;c=l}await X(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await $t(s,`# skip: [${c}] ${ue(f.message)}`),await $t(s,`git bisect skip ${c}`)}return ms(s,r.env,t)}})}function vm(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 Pt(s)?Tm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
175
+ `,stderr:"",exitCode:0}}})}async function Tm(e,t,n,r){let o=(await Oe(e,"BISECT_START"))?.trim()??"";if(await oo(e),r){let s=await gt(e,r);return M(s)?s:Bn(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 Ke(e,o);if(a)return Bn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Hm(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 Pt(s)?{stdout:await Oe(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
176
+ `,exitCode:1}}})}function Am(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:I(r.cwd,n.logfile);if(!await r.fs.exists(i))return S(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Dm(s,r.env,t,a)}})}async function Dm(e,t,n,r){await Pt(e)&&await oo(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 pf(e,t,n,m,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ds(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ds(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let m of l?l.split(/\s+/):[]){await X(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await $t(e,`# skip: [${m}] ${ue(u.message)}`),await $t(e,`git bisect skip ${m}`)}d=await ms(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Mm(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 Pt(s))return us;if(!r.exec)return S("bisect run requires shell execution support");let i=n.cmd.join(" ");return jm(s,r.env,t,i,r.exec,r.cwd)}})}async function jm(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 _i(e);if(M(m))return m;await X(e,`refs/bisect/skip-${m}`,m);let u=await j(e,m);await $t(e,`# skip: [${m}] ${ue(u.message)}`),await $t(e,`git bisect skip ${m}`);let h=await ms(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 so(e),l=c===0?f.termGood:f.termBad,d=await ds(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 Gm(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 Pt(s))return{stdout:"",stderr:`error: no terms defined
181
+ `,exitCode:1};let{termBad:i,termGood:a}=await ls(s);return n["term-good"]?{stdout:`${a}
180
182
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
181
183
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
182
184
  and ${i} for the new state.
183
- `,stderr:"",exitCode:0}}})}function Im(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 Rt(i))return ls;let a=await so(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
184
- `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(ir(),Vc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${Y(l.hash)} ${fe(l.commit.message)}
185
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function ds(e,t,n){let r=await so(e);return!r.badHash||r.goodHashes.length===0?{stdout:Zc(r),stderr:"",exitCode:0}:(await Te(e,"BISECT_ANCESTORS_OK",""),Sm(e,t,n,r))}async function Sm(e,t,n,r){let o=await Xc(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
186
- `,exitCode:1};if(o.found){let s=await Qc(e,o.hash);return await xt(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.
185
+ `,stderr:"",exitCode:0}}})}function Lm(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 Pt(i))return us;let a=await so(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(),Yc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${V(l.hash)} ${ue(l.commit.message)}
187
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function ms(e,t,n){let r=await so(e);return!r.badHash||r.goodHashes.length===0?{stdout:Jc(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 Zc(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 ef(e,o.hash);return await $t(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
189
  The first bad commit could be any of:
188
190
  `;for(let i of r.skipHashes)s+=i+`
189
191
  `;return r.badHash&&(s+=r.badHash+`
190
192
  `),s+=`We cannot bisect more!
191
- `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Te(e,"BISECT_HEAD",o.hash);else{let s=await Un(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Te(e,"BISECT_EXPECTED_REV",o.hash+`
192
- `),{stdout:Jc(o),stderr:"",exitCode:0}}se();ie();function Lt(e){if(e.length===0)return[];let t=e.split(`
193
- `);return t[t.length-1]===""&&t.pop(),t}function bt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
194
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Tm=4,pf=1024,wo=100,Eo=0,bo=1,$r=2;function _i(e){let t=1;for(;t*t<e;)t++;return t}function vm(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 Hm(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 gf(e,t,n,r){t-n>wo&&(n=t-wo),r-t>wo&&(r=t+wo);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Eo)o++;else if(f===$r)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===Eo)i++;else if(f===$r)a++;else break}return i===0?!1:(i+=o,a+=s,a*Tm<a+i)}function Am(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),m=Math.min(_i(t),pf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Eo:w>=m?l[g]=$r:l[g]=bo}let u=Math.min(_i(r),pf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Eo:w>=u?d[g]=$r:d[g]=bo}let h=[];for(let g=s;g<=i;g++)l[g]===bo||l[g]===$r&&!gf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===bo||d[g]===$r&&!gf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Bn=20,wf=4,Dm=256,Mm=256,yo=2147483647;function wt(e,t){return e[t]??0}function jm(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,y=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 k=g;k>=p;k-=2){let E;wt(i,k-1)>=wt(i,k+1)?E=wt(i,k-1)+1:E=wt(i,k+1);let R=E,C=E-k;for(;E<n&&C<s&&e[E]===r[C];)E++,C++;if(E-R>Bn&&(b=!0),i[k]=E,h&&w<=k&&k<=y&&wt(a,k)<=E)return{i1:E,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=yo:++w,y<d?a[++y+1]=yo:--y;for(let k=y;k>=w;k-=2){let E;wt(a,k-1)<wt(a,k+1)?E=wt(a,k-1):E=wt(a,k+1)-1;let R=E,C=E-k;for(;E>t&&C>o&&e[E-1]===r[C-1];)E--,C--;if(R-E>Bn&&(b=!0),a[k]=E,!h&&p<=k&&k<=g&&E<=wt(i,k))return{i1:E,i2:C,minLo:!0,minHi:!0}}if(!c){if(b&&x>Dm){let k=0,E=null;for(let R=g;R>=p;R-=2){let C=R>m?R-m:m-R,P=wt(i,R),v=P-R,D=P-t+(v-o)-C;if(D>wf*x&&D>k&&t+Bn<=P&&P<n&&o+Bn<=v&&v<s){let O=!0;for(let H=1;H<=Bn;H++)if(e[P-H]!==r[v-H]){O=!1;break}O&&(k=D,E={i1:P,i2:v,minLo:!0,minHi:!1})}}if(E)return E;k=0,E=null;for(let R=y;R>=w;R-=2){let C=R>u?R-u:u-R,P=wt(a,R),v=P-R,D=n-P+(s-v)-C;if(D>wf*x&&D>k&&t<P&&P<=n-Bn&&o<v&&v<=s-Bn){let O=!0;for(let H=0;H<Bn;H++)if(e[P+H]!==r[v+H]){O=!1;break}O&&(k=D,E={i1:P,i2:v,minLo:!1,minHi:!0})}}if(E)return E}if(x>=f){let k=-1,E=-1;for(let P=g;P>=p;P-=2){let v=Math.min(wt(i,P),n),D=v-P;s<D&&(v=s+P,D=s),k<v+D&&(k=v+D,E=v)}let R=yo,C=yo;for(let P=y;P>=w;P-=2){let v=Math.max(t,wt(a,P)),D=v-P;D<o&&(v=o+P,D=o),v+D<R&&(R=v+D,C=v)}return n+s-R<k-(t+o)?{i1:E,i2:k-E,minLo:!0,minHi:!1}:{i1:C,i2:R-C,minLo:!1,minHi:!0}}}}}function Fi(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=jm(e,t,n,r,o,s,l,d,m,u);Fi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,u),Fi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,u)}}function Gm(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 bf=200,yf=20,Ef=100,Lm=1,Nm=21,_m=-30,Fm=6,Um=-4,Bm=10,Wm=24,qm=17,zm=23,Km=17,Vm=60;function Ni(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===32)t+=1;else if(r===9)t+=8-t%8;else if(!(r===10||r===13||r===11||r===12))return t;if(t>=bf)return bf}return-1}function kf(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=Ni(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Ni(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===yf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Ni(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===yf){r.postIndent=0;break}return r}function Rf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Lm),e.endOfFile&&(t.penalty+=Nm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=_m*r,t.penalty+=Fm*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?Bm:Um:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?qm:Wm:t.penalty+=s?Km:zm))}function Ym(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Vm*n+(e.penalty-t.penalty)}function xf(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-Ef>g&&(g=a-Ef);g<=a;g++){let w={effectiveIndent:0,penalty:0},y=kf(n,r,g);Rf(y,w);let x=kf(n,r,g-d);Rf(x,w),(h===-1||Ym(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 Ui(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}=vm(e,t),{dstart:f,dend1:l,dend2:d}=Hm(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}=Am(i,n,a,r,c,f,l,d,o,s);if(u>0&&p>0){let g=new Array(u);for(let E=0;E<u;E++)g[E]=i[m[E]];let w=new Array(p);for(let E=0;E<p;E++)w[E]=a[h[E]];let y={},x={},b=u+p+3,k=Math.max(Mm,_i(b));Fi(g,0,u,w,0,p,o,s,m,h,y,x,!1,k)}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;xf(o,i,e,n,s,r),xf(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function st(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}=Ui(e,t);return Gm(e,t,o,s)}var Xm=3;function Zm(e,t=Xm){if(e.length===0)return[];let n=[];for(let a=0;a<e.length;a++){let c=e[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),i=Math.min(e.length-1,r+t);for(let a=1;a<n.length;a++){let c=n[a]??0,f=Math.max(0,c-t),l=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=l}return o.push({start:s,end:i}),o.map(a=>Jm(e,a.start,a.end))}function Jm(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 ko(e){return e?e.length<40?e:Y(e):"0000000"}function Pf(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 Qm(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(Pf(u,e,l,d,m,f),o!==s){if(a||c){let h=ko(a),p=ko(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(`
193
+ `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Ae(e,"BISECT_HEAD",o.hash);else{let s=await Bn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Ae(e,"BISECT_EXPECTED_REV",o.hash+`
194
+ `),{stdout:Qc(o),stderr:"",exitCode:0}}ce();fe();function _t(e){if(e.length===0)return[];let t=e.split(`
195
+ `);return t[t.length-1]===""&&t.pop(),t}function kt(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 _m=4,gf=1024,wo=100,Eo=0,bo=1,Sr=2;function Ui(e){let t=1;for(;t*t<e;)t++;return t}function Fm(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 Um(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 wf(e,t,n,r){t-n>wo&&(n=t-wo),r-t>wo&&(r=t+wo);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Eo)o++;else if(f===Sr)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===Eo)i++;else if(f===Sr)a++;else break}return i===0?!1:(i+=o,a+=s,a*_m<a+i)}function Bm(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),m=Math.min(Ui(t),gf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Eo:w>=m?l[g]=Sr:l[g]=bo}let u=Math.min(Ui(r),gf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Eo:w>=u?d[g]=Sr:d[g]=bo}let h=[];for(let g=s;g<=i;g++)l[g]===bo||l[g]===Sr&&!wf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===bo||d[g]===Sr&&!wf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Wn=20,bf=4,Wm=256,qm=256,yo=2147483647;function Et(e,t){return e[t]??0}function zm(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,b=u;i[m]=t,a[u]=n;for(let x=1;;x++){let y=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let E=g;E>=p;E-=2){let k;Et(i,E-1)>=Et(i,E+1)?k=Et(i,E-1)+1:k=Et(i,E+1);let R=k,C=k-E;for(;k<n&&C<s&&e[k]===r[C];)k++,C++;if(k-R>Wn&&(y=!0),i[E]=k,h&&w<=E&&E<=b&&Et(a,E)<=k)return{i1:k,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=yo:++w,b<d?a[++b+1]=yo:--b;for(let E=b;E>=w;E-=2){let k;Et(a,E-1)<Et(a,E+1)?k=Et(a,E-1):k=Et(a,E+1)-1;let R=k,C=k-E;for(;k>t&&C>o&&e[k-1]===r[C-1];)k--,C--;if(R-k>Wn&&(y=!0),a[E]=k,!h&&p<=E&&E<=g&&k<=Et(i,E))return{i1:k,i2:C,minLo:!0,minHi:!0}}if(!c){if(y&&x>Wm){let E=0,k=null;for(let R=g;R>=p;R-=2){let C=R>m?R-m:m-R,P=Et(i,R),H=P-R,D=P-t+(H-o)-C;if(D>bf*x&&D>E&&t+Wn<=P&&P<n&&o+Wn<=H&&H<s){let O=!0;for(let A=1;A<=Wn;A++)if(e[P-A]!==r[H-A]){O=!1;break}O&&(E=D,k={i1:P,i2:H,minLo:!0,minHi:!1})}}if(k)return k;E=0,k=null;for(let R=b;R>=w;R-=2){let C=R>u?R-u:u-R,P=Et(a,R),H=P-R,D=n-P+(s-H)-C;if(D>bf*x&&D>E&&t<P&&P<=n-Wn&&o<H&&H<=s-Wn){let O=!0;for(let A=0;A<Wn;A++)if(e[P+A]!==r[H+A]){O=!1;break}O&&(E=D,k={i1:P,i2:H,minLo:!1,minHi:!0})}}if(k)return k}if(x>=f){let E=-1,k=-1;for(let P=g;P>=p;P-=2){let H=Math.min(Et(i,P),n),D=H-P;s<D&&(H=s+P,D=s),E<H+D&&(E=H+D,k=H)}let R=yo,C=yo;for(let P=b;P>=w;P-=2){let H=Math.max(t,Et(a,P)),D=H-P;D<o&&(H=o+P,D=o),H+D<R&&(R=H+D,C=H)}return n+s-R<E-(t+o)?{i1:k,i2:E-k,minLo:!0,minHi:!1}:{i1:C,i2:R-C,minLo:!1,minHi:!0}}}}}function Bi(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=zm(e,t,n,r,o,s,l,d,m,u);Bi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,u),Bi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,u)}}function Km(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 yf=200,Ef=20,kf=100,Vm=1,Ym=21,Xm=-30,Zm=6,Jm=-4,Qm=10,eh=24,th=17,nh=23,rh=17,sh=60;function Fi(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>=yf)return yf}return-1}function Rf(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=Fi(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Fi(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Ef){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Fi(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Ef){r.postIndent=0;break}return r}function xf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Vm),e.endOfFile&&(t.penalty+=Ym);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=Xm*r,t.penalty+=Zm*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?Qm:Jm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?th:eh:t.penalty+=s?rh:nh))}function oh(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return sh*n+(e.penalty-t.penalty)}function Cf(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-kf>g&&(g=a-kf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Rf(n,r,g);xf(b,w);let x=Rf(n,r,g-d);xf(x,w),(h===-1||oh(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 Wi(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}=Fm(e,t),{dstart:f,dend1:l,dend2:d}=Um(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}=Bm(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[m[k]];let w=new Array(p);for(let k=0;k<p;k++)w[k]=a[h[k]];let b={},x={},y=u+p+3,E=Math.max(qm,Ui(y));Bi(g,0,u,w,0,p,o,s,m,h,b,x,!1,E)}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;Cf(o,i,e,n,s,r),Cf(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}=Wi(e,t);return Km(e,t,o,s)}var ih=3;function ah(e,t=ih){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=>ch(e,a.start,a.end))}function ch(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 ko(e){return e?e.length<40?e:V(e):"0000000"}function Pf(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 fh(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(Pf(u,e,l,d,m,f),o!==s){if(a||c){let h=ko(a),p=ko(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
197
  `)}
196
- `}function Pt(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=Ie(n),d=Ie(r);if(l||d)return Qm(e,l,d);let m=Lt(n),u=Lt(r),h=n.length>0&&n.endsWith(`
198
+ `}function Ot(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=ve(n),d=ve(r);if(l||d)return fh(e,l,d);let m=_t(n),u=_t(r),h=n.length>0&&n.endsWith(`
197
199
  `),p=r.length>0&&r.endsWith(`
198
- `),g="\0NOEOL",w=m;!h&&m.length>0&&(w=m.slice(),w[w.length-1]+=g);let y=u;!p&&u.length>0&&(y=u.slice(),y[y.length-1]+=g);let x=st(w,y);if(!h||!p)for(let D of x)D.line.includes(g)&&(D.line=D.line.replace(g,""));let b=Zm(x);if(b.length===0&&!c)return"";let k=e.isNew??n==="",E=e.isDeleted??r==="",R=[];if(Pf(R,e,f,k,E,c),b.length===0)return`${R.join(`
200
+ `),g="\0NOEOL",w=m;!h&&m.length>0&&(w=m.slice(),w[w.length-1]+=g);let b=u;!p&&u.length>0&&(b=u.slice(),b[b.length-1]+=g);let x=ct(w,b);if(!h||!p)for(let D of x)D.line.includes(g)&&(D.line=D.line.replace(g,""));let y=ah(x,e.contextLines);if(y.length===0&&!c)return"";let E=e.isNew??n==="",k=e.isDeleted??r==="",R=[];if(Pf(R,e,f,E,k,c),y.length===0)return`${R.join(`
199
201
  `)}
200
- `;if(i||a){let D=ko(i),O=ko(a);k||E?R.push(`index ${D}..${O}`):c?R.push(`index ${D}..${O} ${o||"100644"}`):o&&s&&o!==s?R.push(`index ${D}..${O}`):R.push(`index ${D}..${O} ${o||"100644"}`)}let C=D=>D.includes(" ")?" ":"";k?(R.push("--- /dev/null"),R.push(`+++ b/${f}${C(f)}`)):E?(R.push(`--- a/${t}${C(t)}`),R.push("+++ /dev/null")):(R.push(`--- a/${t}${C(t)}`),R.push(`+++ b/${f}${C(f)}`));let P=m.length,v=u.length;for(let D of b){let O=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,H=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,G="";for(let _=D.oldStart-2;_>=0;_--){let B=m[_];if(B&&/^[a-zA-Z$_]/.test(B)){G=` ${B.trimEnd().slice(0,79)}`;break}}R.push(`@@ -${O} +${H} @@${G}`);let A=D.oldStart,S=D.newStart;for(let _ of D.lines)switch(_.type){case"context":R.push(` ${_.content}`),(!h&&A===P||!p&&S===v)&&R.push("\"),A++,S++;break;case"delete":R.push(`-${_.content}`),!h&&A===P&&R.push("\"),A++;break;case"insert":R.push(`+${_.content}`),!p&&S===v&&R.push("\"),S++;break}}return`${R.join(`
202
+ `;if(i||a){let D=ko(i),O=ko(a);E||k?R.push(`index ${D}..${O}`):c?R.push(`index ${D}..${O} ${o||"100644"}`):o&&s&&o!==s?R.push(`index ${D}..${O}`):R.push(`index ${D}..${O} ${o||"100644"}`)}let C=D=>D.includes(" ")?" ":"";E?(R.push("--- /dev/null"),R.push(`+++ b/${f}${C(f)}`)):k?(R.push(`--- a/${t}${C(t)}`),R.push("+++ /dev/null")):(R.push(`--- a/${t}${C(t)}`),R.push(`+++ b/${f}${C(f)}`));let P=m.length,H=u.length;for(let D of y){let O=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,A=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,G="",v=D.oldCount===0?D.oldStart-1:D.oldStart-2;for(let _=v;_>=0;_--){let U=m[_];if(U&&/^[a-zA-Z$_]/.test(U)){G=` ${U.trimEnd().slice(0,79)}`;break}}R.push(`@@ -${O} +${A} @@${G}`);let T=D.oldStart,F=D.newStart;for(let _ of D.lines)switch(_.type){case"context":R.push(` ${_.content}`),(!h&&T===P||!p&&F===H)&&R.push("\"),T++,F++;break;case"delete":R.push(`-${_.content}`),!h&&T===P&&R.push("\"),T++;break;case"insert":R.push(`+${_.content}`),!p&&F===H&&R.push("\"),F++;break}}return`${R.join(`
201
203
  `)}
202
- `}ie();ve();async function Wn(e,t,n){return(await ce(e,t)).get(n)?.hash??null}async function Cf(e,t,n,r){let o=await We(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await nt(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function eh(e,t,n,r,o,s){let i=await Wn(e,(await j(e,t)).tree,n);if(!i){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,qn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=Lt(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]=qn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!0,void 0);break}let g=await Wn(e,p.tree,m),w=null,y=[];for(let P of p.parents){let v=await j(e,P),D=m,O=await Wn(e,v.tree,D);if(!O){let H=await Cf(e,v.tree,p.tree,m);H&&(D=H,O=await Wn(e,v.tree,D))}if(O&&(y.push({hash:P,path:D,blobHash:O}),O===g)){w={hash:P,path:D};break}}if(w){d=w.hash,m=w.path;continue}if(y.length===0){for(let P of l)f[P.finalIdx]=qn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,void 0);break}let x=y[0],b=await oe(e,x.blobHash),k=Lt(b),E=st(k,u),R=new Map;for(let P of E)P.type==="keep"&&R.set(P.newLineNo,P.oldLineNo);let C=[];for(let P of l){let v=R.get(P.currentLine);v!==void 0?C.push({finalIdx:P.finalIdx,currentLine:v}):f[P.finalIdx]=qn(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=k}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function Of(e,t,n,r){let o=await j(e,t),s=await Wn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=Lt(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 R of m)d[R.finalIdx]=qn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!0,void 0);break}let w=await Wn(e,g.tree,h),y=[],x=null;for(let R of g.parents){let C=await j(e,R),P=h,v=await Wn(e,C.tree,P);if(!v){let D=await Cf(e,C.tree,g.tree,h);D&&(P=D,v=await Wn(e,C.tree,P))}if(v){let D={hash:R,path:P,blobHash:v};if(y.push(D),v===w){x=D;break}}}if(x){u=x.hash,h=x.path;continue}if(y.length===0){for(let R of m)d[R.finalIdx]=qn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,void 0);break}if(y.length===1){let R=y[0],C=await oe(e,R.blobHash),P=Lt(C),v=st(P,p),D=new Map;for(let H of v)H.type==="keep"&&D.set(H.newLineNo,H.oldLineNo);let O=[];for(let H of m){let G=D.get(H.currentLine);G!==void 0?O.push({finalIdx:H.finalIdx,currentLine:G}):d[H.finalIdx]=qn(u,h,H.currentLine,c+H.finalIdx,l[H.finalIdx],g,!1,{hash:R.hash,path:R.path})}m=O,u=R.hash,h=R.path,p=P;continue}let b=[];for(let R of y){let C=await oe(e,R.blobHash),P=Lt(C),v=st(P,p),D=new Map;for(let O of v)O.type==="keep"&&D.set(O.newLineNo,O.oldLineNo);b.push({info:R,newToOld:D})}let k=new Map;for(let R of m){let C=!1;for(let P=0;P<b.length;P++){let v=b[P],D=v.newToOld.get(R.currentLine);if(D!==void 0){let O=k.get(P);O||(O={info:v.info,lines:[]},k.set(P,O)),O.lines.push({finalIdx:R.finalIdx,currentLine:D}),C=!0;break}}C||(d[R.finalIdx]=qn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,{hash:y[0].hash,path:y[0].path}))}let E=k.get(0);for(let[R,C]of k){if(R===0)continue;let P=await eh(e,C.info.hash,C.info.path,C.lines,l,c);for(let[v,D]of P)d[v]=D}if(E&&E.lines.length>0){m=E.lines,u=E.info.hash,h=E.info.path;let R=await oe(e,E.info.blobHash);p=Lt(R)}else break}return d}function qn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
203
- `)[0],boundary:i,previous:a}}se();ie();ve();ie();le();function th(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 nh(e,t){let n=th(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 rh(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=nh(d.author.timestamp,d.author.timezone);l.push(`${m}${u} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
204
+ `}fe();He();async function qn(e,t,n){return(await de(e,t)).get(n)?.hash??null}async function $f(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 lh(e,t,n,r,o,s){let i=await qn(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,zn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=_t(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]=zn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!0,void 0);break}let g=await qn(e,p.tree,m),w=null,b=[];for(let P of p.parents){let H=await j(e,P),D=m,O=await qn(e,H.tree,D);if(!O){let A=await $f(e,H.tree,p.tree,m);A&&(D=A,O=await qn(e,H.tree,D))}if(O&&(b.push({hash:P,path:D,blobHash:O}),O===g)){w={hash:P,path:D};break}}if(w){d=w.hash,m=w.path;continue}if(b.length===0){for(let P of l)f[P.finalIdx]=zn(d,m,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,void 0);break}let x=b[0],y=await oe(e,x.blobHash),E=_t(y),k=ct(E,u),R=new Map;for(let P of k)P.type==="keep"&&R.set(P.newLineNo,P.oldLineNo);let C=[];for(let P of l){let H=R.get(P.currentLine);H!==void 0?C.push({finalIdx:P.finalIdx,currentLine:H}):f[P.finalIdx]=zn(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=E}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function Of(e,t,n,r){let o=await j(e,t),s=await qn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=_t(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 R of m)d[R.finalIdx]=zn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!0,void 0);break}let w=await qn(e,g.tree,h),b=[],x=null;for(let R of g.parents){let C=await j(e,R),P=h,H=await qn(e,C.tree,P);if(!H){let D=await $f(e,C.tree,g.tree,h);D&&(P=D,H=await qn(e,C.tree,P))}if(H){let D={hash:R,path:P,blobHash:H};if(b.push(D),H===w){x=D;break}}}if(x){u=x.hash,h=x.path;continue}if(b.length===0){for(let R of m)d[R.finalIdx]=zn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,void 0);break}if(b.length===1){let R=b[0],C=await oe(e,R.blobHash),P=_t(C),H=ct(P,p),D=new Map;for(let A of H)A.type==="keep"&&D.set(A.newLineNo,A.oldLineNo);let O=[];for(let A of m){let G=D.get(A.currentLine);G!==void 0?O.push({finalIdx:A.finalIdx,currentLine:G}):d[A.finalIdx]=zn(u,h,A.currentLine,c+A.finalIdx,l[A.finalIdx],g,!1,{hash:R.hash,path:R.path})}m=O,u=R.hash,h=R.path,p=P;continue}let y=[];for(let R of b){let C=await oe(e,R.blobHash),P=_t(C),H=ct(P,p),D=new Map;for(let O of H)O.type==="keep"&&D.set(O.newLineNo,O.oldLineNo);y.push({info:R,newToOld:D})}let E=new Map;for(let R of m){let C=!1;for(let P=0;P<y.length;P++){let H=y[P],D=H.newToOld.get(R.currentLine);if(D!==void 0){let O=E.get(P);O||(O={info:H.info,lines:[]},E.set(P,O)),O.lines.push({finalIdx:R.finalIdx,currentLine:D}),C=!0;break}}C||(d[R.finalIdx]=zn(u,h,R.currentLine,c+R.finalIdx,l[R.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let k=E.get(0);for(let[R,C]of E){if(R===0)continue;let P=await lh(e,C.info.hash,C.info.path,C.lines,l,c);for(let[H,D]of P)d[H]=D}if(k&&k.lines.length>0){m=k.lines,u=k.info.hash,h=k.info.path;let R=await oe(e,k.info.blobHash);p=_t(R)}else break}return d}function zn(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}}ce();fe();He();fe();me();function dh(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 uh(e,t){let n=dh(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 mh(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=uh(d.author.timestamp,d.author.timezone);l.push(`${m}${u} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
204
206
  `)}
205
- `}function sh(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(`
207
+ `}function hh(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(`
206
208
  `)}
207
- `}function oh(e,t,n){if(e.startsWith("/"))return ft(n,e);let r=ft(n,t);return r===""||r==="."?e:`${r}/${e}`}function $f(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:J.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:I().alias("l").describe("Show long revision"),showEmail:I().alias("e").describe("Show author email instead of name"),suppress:I().alias("s").describe("Suppress author name and date"),porcelain:I().alias("p").describe("Show in machine-readable format"),linePorcelain:I().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return $("this operation must be run in a work tree");let a=await Ze(i);if(M(a))return a;let c=n.args??[],f=o.passthrough??[],l=null,d=null;if(f.length>0?(d=f[f.length-1],c.length>0&&(l=c[0])):c.length===2?(l=c[0],d=c[1]):c.length===1&&(d=c[0]),!d)return $("no file specified");let m=oh(d,r.cwd,i.workTree),u;if(l){let E=await vt(i,l);if(M(E))return E;u=await Ne(i,E)}else u=a;let h=await j(i,u),p=await ce(i,h.tree);if(!p.has(m))return $(`no such path ${m} in ${l??"HEAD"}`);let g=p.get(m).hash,w=await oe(i,g);if(Ie(w))return $(`cannot blame binary file '${m}'`);let y,x;if(n.lineRange){let E=n.lineRange,R=E.match(/^(\d+),(\d+)$/);if(R)y=parseInt(R[1],10),x=parseInt(R[2],10);else return $(`invalid -L range: '${E}'`)}let b;try{b=await Of(i,u,m,{startLine:y,endLine:x})}catch(E){let R=E instanceof Error?E.message:String(E);return $(R)}let k;return n.porcelain||n.linePorcelain?k=sh(b,!!n.linePorcelain):k=rh(b,m,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}se();_e();$n();se();var ih=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ah=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Nt(e,t){let n=ch(t),r=new Date((e+n*60)*1e3),o=ih[r.getUTCDay()],s=ah[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 Bi(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 ch(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();ve();var Ro=new TextDecoder;function If(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
209
+ `}function ph(e,t,n){if(e.startsWith("/"))return rt(n,e);let r=rt(n,t);return r===""||r==="."?e:`${r}/${e}`}function Sf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[q.string().name("args").variadic().optional()],options:{lineRange:Y.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:$().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 S("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 S("no file specified");let m=ph(d,r.cwd,i.workTree),u;if(l){let k=await gt(i,l);if(M(k))return k;u=await Le(i,k)}else u=a;let h=await j(i,u),p=await de(i,h.tree);if(!p.has(m))return S(`no such path ${m} in ${l??"HEAD"}`);let g=p.get(m).hash,w=await oe(i,g);if(ve(w))return S(`cannot blame binary file '${m}'`);let b,x;if(n.lineRange){let k=n.lineRange,R=k.match(/^(\d+),(\d+)$/);if(R)b=parseInt(R[1],10),x=parseInt(R[2],10);else return S(`invalid -L range: '${k}'`)}let y;try{y=await Of(i,u,m,{startLine:b,endLine:x})}catch(k){let R=k instanceof Error?k.message:String(k);return S(R)}let E;return n.porcelain||n.linePorcelain?E=hh(y,!!n.linePorcelain):E=mh(y,m,!!n.long,!!n.showEmail,!!n.suppress),{stdout:E,stderr:"",exitCode:0}}})}ce();We();Sn();ce();var gh=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Rn(e,t){let n=bh(t),r=new Date((e+n*60)*1e3),o=gh[r.getUTCDay()],s=wh[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 qi(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 bh(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)}fe();He();var Ro=new TextDecoder;function If(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
208
210
  `&&t++;return e[e.length-1]!==`
209
- `&&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 Kn(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await kt(e,a.newHash);vn(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:If(Ro.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await kt(e,a.oldHash);vn(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:If(Ro.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await kt(e,a.oldHash),f=await kt(e,a.newHash);if(vn(c)||vn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=bt(Ro.decode(c)),d=bt(Ro.decode(f)),m=st(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=cn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await oe(e,a.oldHash),m=await oe(e,a.newHash);if(!Ie(d)&&!Ie(m)){let u=bt(d),h=bt(m),p=st(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=cn(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function fn(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: ${Nt(r.timestamp,r.timezone)}`),i)return a.join(`
211
+ `&&t++,t}function Kn(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 Vn(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Ct(e,a.newHash);Hn(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:If(Ro.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Ct(e,a.oldHash);Hn(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:If(Ro.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Ct(e,a.oldHash),f=await Ct(e,a.newHash);if(Hn(c)||Hn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=kt(Ro.decode(c)),d=kt(Ro.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=cn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await oe(e,a.oldHash),m=await oe(e,a.newHash);if(!ve(d)&&!ve(m)){let u=kt(d),h=kt(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=cn(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function fn(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: ${Rn(r.timestamp,r.timezone)}`),i)return a.join(`
210
212
  `)+(a.length>0?`
211
- `:"");let c=await We(e,t,n),{remaining:f,renames:l}=await nt(e,c),{fileStats:d,modeLines:m}=await Kn(e,f,l),u=0,h=0;for(let g of d)u+=g.insertions,h+=g.deletions;let p=zn(d.length,u,h);p&&a.push(p);for(let g of m)a.push(g);return a.join(`
213
+ `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await it(e,c),{fileStats:d,modeLines:m}=await Vn(e,f,l),u=0,h=0;for(let g of d)u+=g.insertions,h+=g.deletions;let p=Kn(d.length,u,h);p&&a.push(p);for(let g of m)a.push(g);return a.join(`
212
214
  `)+(a.length>0?`
213
- `:"")}var fh=80;function lh(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 dr(e,t=fh){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=lh(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,y=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let R=v=>v===0?0:1+Math.floor(v*(a-1)/r),C=R(w),P=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(x=R(p.insertions),b=P-x):(b=R(p.deletions),x=P-b)}let k="+".repeat(x)+"-".repeat(b),E=k?` ${k}`:"";l.push(` ${g} | ${y}${E}`)}let h=zn(u,d,m);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
215
+ `:"")}var yh=80;function Eh(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=yh){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=Eh(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,b=String(w).padStart(s),x,y;if(r<=a)x=p.insertions,y=p.deletions;else{let R=H=>H===0?0:1+Math.floor(H*(a-1)/r),C=R(w),P=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(x=R(p.insertions),y=P-x):(y=R(p.deletions),x=P-y)}let E="+".repeat(x)+"-".repeat(y),k=E?` ${E}`:"";l.push(` ${g} | ${b}${k}`)}let h=Kn(u,d,m);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
214
216
  `)}
215
- `}async function ln(e,t,n){let r=await We(e,t,n),{remaining:o,renames:s}=await nt(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await Kn(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=dr(i);for(let f of a)c+=`${f}
216
- `;return c}_e();Ce();ie();ue();on();async function dh(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 Rn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function _t(e,t,n){if(t===n)return[t];let r=await dh(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 Rn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:uh(e,t,n,c)}async function uh(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 y=1;y<l.length;y++){let x=l[y],b=await d(x.hash),k=l[m];(b>u||b===u&&x.seq<k.seq)&&(m=y,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 y of w.parents)l.push({hash:y,mask:g,seq:f++})}for(let m of r)s.has(m)||i.push(m);return i}async function ur(e,t,n){let r=await ke(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
217
+ `}async function ln(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 Vn(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}We();$e();fe();pe();on();async function kh(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 xn(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 Ft(e,t,n){if(t===n)return[t];let r=await kh(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 xn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:Rh(e,t,n,c)}async function Rh(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 b=1;b<l.length;b++){let x=l[b],y=await d(x.hash),E=l[m];(y>u||y===u&&x.seq<E.seq)&&(m=b,u=y)}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 b of w.parents)l.push({hash:b,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}'
217
219
  `:`Merge branch '${t}' into ${n}
218
- `}async function xo(e,t,n){let r=await j(e,t),o=await j(e,n),s=Y(t),i=Y(n),a=`Updating ${s}..${i}
219
- `;if(e.workTree){let f=await K(e),l=await Bc(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 An(e,n);let c=await ln(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
220
- ${c}`,stderr:"",exitCode:0}}ie();Fe();ue();function Sf(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:I().alias("d").describe("Delete a branch"),forceDelete:I().alias("D").describe("Force delete a branch"),move:I().alias("m").describe("Rename a branch"),forceMove:I().alias("M").describe("Force rename a branch"),remotes:I().alias("r").describe("List remote-tracking branches"),all:I().alias("a").describe("List all branches"),setUpstreamTo:J.string().alias("u").describe("Set upstream tracking branch"),verbose:I().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Re(i.target):null,c=!!n.forceMove;if(n.move||c){let w,y;if(n.newName)w=n.name,y=n.newName;else if(n.name){if(!a)return $("not on any branch");w=a,y=n.name}else return $("branch name required");if(!pn(y))return $(`'${y}' is not a valid branch name`);let x=`refs/heads/${w}`,b=`refs/heads/${y}`,k=await F(s,x);if(!k)return $(`no branch named '${w}'`);if(await Gt(s)&&(await gt(s))?.headName===x)return $(`branch ${x} is being rebased at ${s.workTree}`);let E=await F(s,b);if(E&&!c)return $(`a branch named '${y}' already exists`);E&&await de(s,b);let R=await Je(s,x);await X(s,b,k),await de(s,x),w===a&&await ze(s,"HEAD",b),R.length>0&&await Mn(s,b,R);let C=`Branch: renamed ${x} to ${b}`;if(await re(s,r.env,b,k,k,C),w===a){let D=await Qt(s,r.env);await Ke(s,"HEAD",{oldHash:k,newHash:te,...D,message:C}),await Ke(s,"HEAD",{oldHash:te,newHash:k,...D,message:C})}let P=await he(s),v=`branch "${w}"`;return P[v]&&(P[`branch "${y}"`]=P[v],delete P[v],await Ye(s,P)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return $("branch name required");let w=n.name===a;if(!w&&!a&&await Gt(s)&&(await gt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return L(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
221
- `);let y=`refs/heads/${n.name}`,x=await F(s,y);if(!x)return L(`error: branch '${n.name}' not found
222
- `);let b="";if(!f){let k=await Z(s),R=(await he(s))[`branch "${n.name}"`],C=R?.remote,P=R?.merge,v=null,D=null;if(C&&P&&(v=P.replace(/^refs\/heads\//,`refs/remotes/${C}/`),D=await F(s,v)),D&&v){if(!(x===D||await Rn(s,x,D))){let A=k!=null&&(x===k||await Rn(s,x,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
223
- '${v}', even though it is merged to HEAD
224
- `:"";return L(`${A}error: the branch '${n.name}' is not fully merged
220
+ `}async function xo(e,t,n){let r=await j(e,t),o=await j(e,n),s=V(t),i=V(n),a=`Updating ${s}..${i}
221
+ `;if(e.workTree){let f=await z(e),l=await Wc(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 le(e,{version:2,entries:l.newEntries}),await Ne(e,l.worktreeOps)}await Dn(e,n);let c=await ln(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
222
+ ${c}`,stderr:"",exitCode:0}}fe();qe();pe();function vf(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:Y.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"?Ce(i.target):null,c=!!n.forceMove;if(n.move||c){let w,b;if(n.newName)w=n.name,b=n.newName;else if(n.name){if(!a)return S("not on any branch");w=a,b=n.name}else return S("branch name required");if(!pn(b))return S(`'${b}' is not a valid branch name`);let x=`refs/heads/${w}`,y=`refs/heads/${b}`,E=await B(s,x);if(!E)return S(`no branch named '${w}'`);if(await Nt(s)&&(await yt(s))?.headName===x)return S(`branch ${x} is being rebased at ${s.workTree}`);let k=await B(s,y);if(k&&!c)return S(`a branch named '${b}' already exists`);k&&await he(s,y);let R=await et(s,x);await X(s,y,E),await he(s,x),w===a&&await Ye(s,"HEAD",y),R.length>0&&await jn(s,y,R);let C=`Branch: renamed ${x} to ${y}`;if(await ae(s,r.env,y,E,E,C),w===a){let D=await Qt(s,r.env);await Xe(s,"HEAD",{oldHash:E,newHash:te,...D,message:C}),await Xe(s,"HEAD",{oldHash:te,newHash:E,...D,message:C})}let P=await ge(s),H=`branch "${w}"`;return P[H]&&(P[`branch "${b}"`]=P[H],delete P[H],await Ze(s,P)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return S("branch name required");let w=n.name===a;if(!w&&!a&&await Nt(s)&&(await yt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return L(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
223
+ `);let b=`refs/heads/${n.name}`,x=await B(s,b);if(!x)return L(`error: branch '${n.name}' not found
224
+ `);let y="";if(!f){let E=await Z(s),R=(await ge(s))[`branch "${n.name}"`],C=R?.remote,P=R?.merge,H=null,D=null;if(C&&P&&(H=P.replace(/^refs\/heads\//,`refs/remotes/${C}/`),D=await B(s,H)),D&&H){if(!(x===D||await xn(s,x,D))){let v=E!=null&&(x===E||await xn(s,x,E))?`warning: not deleting branch '${n.name}' that is not yet merged to
225
+ '${H}', even though it is merged to HEAD
226
+ `:"";return L(`${v}error: the branch '${n.name}' is not fully merged
225
227
  hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
226
228
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
227
- `)}k!=null&&(x===k||await Rn(s,x,k))||(b=`warning: deleting branch '${n.name}' that has been merged to
228
- '${v}', but not yet merged to HEAD
229
- `)}else if(k&&x!==k&&!await Rn(s,x,k))return L(`error: the branch '${n.name}' is not fully merged
229
+ `)}E!=null&&(x===E||await xn(s,x,E))||(y=`warning: deleting branch '${n.name}' that has been merged to
230
+ '${H}', but not yet merged to HEAD
231
+ `)}else if(E&&x!==E&&!await xn(s,x,E))return L(`error: the branch '${n.name}' is not fully merged
230
232
  hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
231
233
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
232
- `)}return await de(s,y),{stdout:`Deleted branch ${n.name} (was ${Y(x)}).
233
- `,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||a;if(!y)return $("could not set upstream of HEAD when it does not point to any branch.");if(!await F(s,`refs/heads/${y}`))return $(`branch '${y}' does not exist`);let b=w.indexOf("/");if(b<0)return $(`the requested upstream branch '${w}' does not exist`);let k=w.slice(0,b),E=w.slice(b+1);if(!await F(s,`refs/remotes/${w}`))return $(`the requested upstream branch '${w}' does not exist`);let C=await he(s),P=`branch "${y}"`;return C[P]||(C[P]={}),C[P].remote=k,C[P].merge=`refs/heads/${E}`,await Ye(s,C),{stdout:"",stderr:`branch '${y}' set up to track '${w}'.
234
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!pn(n.name))return $(`'${n.name}' is not a valid branch name`);let w=n.newName,y;if(w){let R=await He(s,w,`not a valid object name: '${w}'`);if(M(R))return R;y=R.hash}else if(y=await Z(s),!y)return $("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await F(s,x))return $(`a branch named '${n.name}' already exists`);await X(s,x,y);let k=w??"HEAD";await re(s,r.env,x,null,y,`branch: Created from ${k}`);let E="";return w&&(E=await po(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 Z(s);if(w){let y=await Gt(s),x;if(y){let b=await gt(s);if(b?.headName){let k=Re(b.headName);if(k==="detached HEAD"){let E=await as(s);x=`(no branch, rebasing detached HEAD ${E?Y(E):"(null)"})`}else x=`(no branch, rebasing ${k})`}else x="(no branch)"}else{let b=await as(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${Y(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 y of w){let x=Re(y.name);u.push({displayName:x,hash:y.hash,isCurrent:x===a,branchName:x})}}if(m){let w=await ge(s,"refs/remotes");for(let y of w){let x=y.name.replace("refs/remotes/","");u.push({displayName:n.all?`remotes/${x}`:x,hash:y.hash,isCurrent:!1,branchName:null})}}if(u.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${u.map(y=>y.isCurrent?`* ${y.displayName}`:` ${y.displayName}`).join(`
234
+ `)}return await he(s,b),{stdout:`Deleted branch ${n.name} (was ${V(x)}).
235
+ `,stderr:y,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,b=n.name||a;if(!b)return S("could not set upstream of HEAD when it does not point to any branch.");if(!await B(s,`refs/heads/${b}`))return S(`branch '${b}' does not exist`);let y=w.indexOf("/");if(y<0)return S(`the requested upstream branch '${w}' does not exist`);let E=w.slice(0,y),k=w.slice(y+1);if(!await B(s,`refs/remotes/${w}`))return S(`the requested upstream branch '${w}' does not exist`);let C=await ge(s),P=`branch "${b}"`;return C[P]||(C[P]={}),C[P].remote=E,C[P].merge=`refs/heads/${k}`,await Ze(s,C),{stdout:"",stderr:`branch '${b}' set up to track '${w}'.
236
+ `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!pn(n.name))return S(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let R=await De(s,w,`not a valid object name: '${w}'`);if(M(R))return R;b=R.hash}else if(b=await Z(s),!b)return S("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await B(s,x))return S(`a branch named '${n.name}' already exists`);await X(s,x,b);let E=w??"HEAD";await ae(s,r.env,x,null,b,`branch: Created from ${E}`);let k="";return w&&(k=await po(s,n.name,w)),{stdout:"",stderr:k,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,m=n.remotes||n.all,u=[];if(d&&!a){let w=await Z(s);if(w){let b=await Nt(s),x;if(b){let y=await yt(s);if(y?.headName){let E=Ce(y.headName);if(E==="detached HEAD"){let k=await fs(s);x=`(no branch, rebasing detached HEAD ${k?V(k):"(null)"})`}else x=`(no branch, rebasing ${E})`}else x="(no branch)"}else{let y=await fs(s);y?x=`(HEAD detached ${w===y?"at":"from"} ${V(y)})`:x="(no branch)"}u.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await be(s,"refs/heads");for(let b of w){let x=Ce(b.name);u.push({displayName:x,hash:b.hash,isCurrent:x===a,branchName:x})}}if(m){let w=await be(s,"refs/remotes");for(let b of w){let x=b.name.replace("refs/remotes/","");u.push({displayName:n.all?`remotes/${x}`:x,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(`
235
237
  `)}
236
- `,stderr:"",exitCode:0};let h=l>=1?await he(s):null,p=Math.max(...u.map(w=>w.displayName.length)),g=[];for(let w of u){let y=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=Y(w.hash),k="";try{let R=await j(s,w.hash);k=fe(R.message)}catch{}let E="";if(h&&w.branchName){let R=await En(s,h,w.branchName);if(R){let C=lf(R,l>=2);C&&(E=` ${C}`)}}g.push(`${y}${x} ${b}${E} ${k}`)}return{stdout:`${g.join(`
238
+ `,stderr:"",exitCode:0};let h=l>=1?await ge(s):null,p=Math.max(...u.map(w=>w.displayName.length)),g=[];for(let w of u){let b=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),y=V(w.hash),E="";try{let R=await j(s,w.hash);E=ue(R.message)}catch{}let k="";if(h&&w.branchName){let R=await En(s,h,w.branchName);if(R){let C=df(R,l>=2);C&&(k=` ${C}`)}}g.push(`${b}${x} ${y}${k} ${E}`)}return{stdout:`${g.join(`
237
239
  `)}
238
- `,stderr:"",exitCode:0}}})}function ee(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var mh=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],hh=["commitMsg","mergeMsg"],ph=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],gh=["onRefUpdate","onRefDelete","onObjectWrite"];function wh(...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 mh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of hh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of ph){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 gh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}se();_e();Ce();ie();Fe();ue();gn();tt();function vf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:I().alias("b").describe("Create and switch to a new branch"),forceBranch:I().alias("B").describe("Create/reset and switch to a new branch"),detach:I().alias("d").describe("Detach HEAD at named commit"),orphan:I().describe("Create a new orphan branch"),ours:I().describe("Checkout our version for unmerged files"),theirs:I().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return $("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return $(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let m=mt(i,r.cwd),u=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return $("cannot specify both a revision and --ours/--theirs");let p=await He(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?mo(i,u,m,n.theirs?3:2):uo(i,u,m,h)}if(n.orphan)return n.branch?$("--orphan and -b are incompatible"):n.ours||n.theirs?$("--orphan and --ours/--theirs are incompatible"):a?yh(i,a,r.env,t):$("you must specify a branch to checkout");if(n.detach){let m=a??"HEAD",u=await He(i,m,`invalid reference: ${m}`);return M(u)?u:Tf(i,m,u.hash,r.env,t)}if(!a)return $("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Eh(i,a,r.env,t,!!n.forceBranch);if(a==="-")return bh(i,r.env,t);let c=`refs/heads/${a}`,f=await F(i,c);if(f)return Hf(i,a,c,f,r.env,t);let l=await go(i,a);if(l)return kh(i,a,l.trackingRef,r.env,t);let d=await Be(i,a);if(d){let m=await Ne(i,d);return Tf(i,a,m,r.env,t)}if(i.workTree){let m=await K(i),u=js(m,a);if(u)return await ct(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return L(`error: pathspec '${a}' did not match any file(s) known to git
239
- `)}})}async function bh(e,t,n){let r=await lo(e);return r?Hf(e,r.name,r.refName,r.hash,t,n):$("no previous branch")}async function yh(e,t,n,r){if(!pn(t))return $(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await F(e,o))return $(`a branch named '${t}' already exists`);let i=await K(e),a=Fn(i);if(a)return a;let c=await Z(e),f=null;c&&(f=(await j(e,c)).tree),await ze(e,"HEAD",o),await pt(e);let l=await kn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:te,isBranchCheckout:!0});let d="";return f&&(d=await fr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
240
- ${l}`,exitCode:0}}async function Eh(e,t,n,r,o=!1){if(!pn(t))return $(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await Q(e),a=await Z(e),c=`refs/heads/${t}`,f=await F(e,c);if(f&&!o)return $(`a branch named '${t}' already exists`);if(o){let g=await K(e),w=Fn(g);if(w)return w}a&&await X(e,c,a),await ze(e,"HEAD",c),await pt(e);let l=await kn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??te;a&&(f?f!==a&&await re(e,n,c,f,a,"branch: Reset to HEAD"):await re(e,n,c,null,a,"branch: Created from HEAD")),await re(e,n,"HEAD",a,a??te,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??te,isBranchCheckout:!0});let m="";if(o&&a){let g=await K(e),w=await j(e,a);m=await fr(e,w.tree,g)}let u=await he(e),h=await En(e,u,t);h&&(m+=cr(h));let p=f?`Switched to and reset branch '${t}'
240
+ `,stderr:"",exitCode:0}}})}function ee(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var xh=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preClean","preRm","preCherryPick","preRevert","preStash","beforeCommand"],Ch=["commitMsg","mergeMsg"],Ph=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postClean","postRm","postCherryPick","postRevert","postStash","afterCommand"],$h=["onRefUpdate","onRefDelete","onObjectWrite"];function Oh(...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 xh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of Ch){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(ee(a))return a}})}for(let r of Ph){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 $h){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}ce();We();$e();fe();qe();pe();gn();ot();function Hf(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 S("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return S("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return S(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let m=ut(i,r.cwd),u=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return S("cannot specify both a revision and --ours/--theirs");let p=await De(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?mo(i,u,m,n.theirs?3:2):uo(i,u,m,h)}if(n.orphan)return n.branch?S("--orphan and -b are incompatible"):n.ours||n.theirs?S("--orphan and --ours/--theirs are incompatible"):a?Ih(i,a,r.env,t):S("you must specify a branch to checkout");if(n.detach){let m=a??"HEAD",u=await De(i,m,`invalid reference: ${m}`);return M(u)?u:Tf(i,m,u.hash,r.env,t)}if(!a)return S("you must specify a branch to checkout");if(n.branch||n.forceBranch)return vh(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Sh(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Af(i,a,c,f,r.env,t);let l=await go(i,a);if(l)return Th(i,a,l.trackingRef,r.env,t);let d=await Ke(i,a);if(d){let m=await Le(i,d);return Tf(i,a,m,r.env,t)}if(i.workTree){let m=await z(i),u=js(m,a);if(u)return await dt(i,{path:u.path,hash:u.hash,mode:u.mode}),{stdout:"",stderr:"",exitCode:0}}return L(`error: pathspec '${a}' did not match any file(s) known to git
241
+ `)}})}async function Sh(e,t,n){let r=await lo(e);return r?Af(e,r.name,r.refName,r.hash,t,n):S("no previous branch")}async function Ih(e,t,n,r){if(!pn(t))return S(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return S(`a branch named '${t}' already exists`);let i=await z(e),a=Un(i);if(a)return a;let c=await Z(e),f=null;c&&(f=(await j(e,c)).tree),await Ye(e,"HEAD",o),await bt(e);let l=await kn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:te,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 vh(e,t,n,r,o=!1){if(!pn(t))return S(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await Q(e),a=await Z(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return S(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=Un(g);if(w)return w}a&&await X(e,c,a),await Ye(e,"HEAD",c),await bt(e);let l=await kn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??te;a&&(f?f!==a&&await ae(e,n,c,f,a,"branch: Reset to HEAD"):await ae(e,n,c,null,a,"branch: Created from HEAD")),await ae(e,n,"HEAD",a,a??te,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??te,isBranchCheckout:!0});let m="";if(o&&a){let g=await z(e),w=await j(e,a);m=await lr(e,w.tree,g)}let u=await ge(e),h=await En(e,u,t);h&&(m+=fr(h));let p=f?`Switched to and reset branch '${t}'
241
243
  `:`Switched to a new branch '${t}'
242
- `;return{stdout:m,stderr:`${p}${l}`,exitCode:0}}async function Hf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return ee(i)?L(i.message??""):lr(e,t,n,r,o,s)}async function kh(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await F(e,n);if(!i)return $(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await X(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await he(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await Ye(e,d),await re(e,r,a,null,i,`branch: Created from ${n}`);let m=await lr(e,t,a,i,r,o),u=c.slice(1).join("/");return m.stderr=`branch '${t}' set up to track '${f}/${u}'.
243
- ${m.stderr}`,m}async function Tf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return ee(s)?L(s.message??""):Un(e,n,r,o,{detachAdviceTarget:t})}se();_e();Ce();se();function Wi(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}=Ui(e,t);return Rh(o,n,s,r)}function Rh(e,t,n,r){let o=[],s=0,i=0;for(;s<t||i<r;){for(;s<t&&i<r&&!e[s]&&!n[i];)s++,i++;if(s>=t&&i>=r)break;let a=s,c=i;for(;s<t&&e[s];)s++;for(;i<r&&n[i];)i++;(s>a||i>c)&&o.push({buffer1:[a,s-a],buffer2:[c,i-c]})}return o}function xh(e,t,n){let r=[];for(let c of Wi(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 Wi(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 y=w.oStart,x=y+w.oLength,b=w.abStart,k=b+w.abLength,E=m[w.ab];E.abMin=Math.min(b,E.abMin),E.abMax=Math.max(k,E.abMax),E.oMin=Math.min(y,E.oMin),E.oMax=Math.max(x,E.oMax)}let 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 Ph(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=xh(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&&Df(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"?Af(i):Af(Ch(i))}function us(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=Ph(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 Ch(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Oh(n));return t}function Oh(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Df(t,n))return[e];let r=Wi(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 Af(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 mr(e,t,n,r){let o=us(Ct(e),Ct(t),Ct(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(qi);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
244
+ `;return{stdout:m,stderr:`${p}${l}`,exitCode:0}}async function Af(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return ee(i)?L(i.message??""):dr(e,t,n,r,o,s)}async function Th(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(ee(s))return L(s.message??"");let i=await B(e,n);if(!i)return S(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await X(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await ge(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await Ze(e,d),await ae(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 Tf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return ee(s)?L(s.message??""):Bn(e,n,r,o,{detachAdviceTarget:t})}ce();We();$e();ce();function zi(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}=Wi(e,t);return Hh(o,n,s,r)}function Hh(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 Ah(e,t,n){let r=[];for(let c of zi(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 zi(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 b=w.oStart,x=b+w.oLength,y=w.abStart,E=y+w.abLength,k=m[w.ab];k.abMin=Math.min(y,k.abMin),k.abMax=Math.max(E,k.abMax),k.oMin=Math.min(b,k.oMin),k.oMax=Math.max(x,k.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 Dh(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Ah(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&&Mf(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"?Df(i):Df(Mh(i))}function hs(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=Dh(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 Mh(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...jh(n));return t}function jh(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Mf(t,n))return[e];let r=zi(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 Df(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=hs(St(e),St(t),St(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(Ki);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
244
246
  `)}
245
247
  `:a.join(`
246
- `)}function Ct(e){if(e==="")return[];let t=e.split(`
247
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function qi(e){return e.endsWith("\0")?e.slice(0,-1):e}function Df(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();mn();le();er();ve();tt();on();var Ir=new TextDecoder,Vn=new TextEncoder,Mf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Ft(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Ih(e,t,n,r),f=await Th(e,s,i,a,c,o);return vh(e,s,o,f)}async function hs(e,t,n,r){let o=await _t(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Ft(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Ft(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Wf(e,t,n,o,1);return{...await Ft(e,a,s.tree,i.tree,r),baseTree:a}}async function Ih(e,t,n,r){let o=await ce(e,t),s=await ce(e,n),i=await ce(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let l=o.get(f)??null,d=s.get(f)??null,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,y=d?.hash??null,x=m?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===x&&(b|=5),y!==null&&y===x&&(b|=6);let k={path:f,stages:[u,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(Sh(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Sh(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 Th(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[A,S]of n)r.has(A)||a.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode}),o.has(A)||c.push({path:A,status:"deleted",oldHash:S.hash,oldMode:S.mode});for(let[A,S]of r)n.has(A)||a.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});for(let[A,S]of o)n.has(A)||c.push({path:A,status:"added",newHash:S.hash,newMode:S.mode});let f=await nt(e,a),l=await nt(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,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,S,_=0){i.msgBuf.push({sortKey:A,subOrder:_,text:S})}for(let A of[...n.keys()].sort()){let S=d.get(A),_=m.get(A);if(!S&&!_)continue;let B=n.get(A);if(h.add(A),S&&_)if(h.add(S.newPath),h.add(_.newPath),S.newPath===_.newPath){let z=r.get(S.newPath),N=o.get(_.newPath);if(z.hash===N.hash)i.entries.push(yt(S.newPath,z));else{let U=zi(t,S.newPath);U.stages=[{hash:B.hash,mode:B.mode},{hash:z.hash,mode:z.mode},{hash:N.hash,mode:N.mode}],U.pathnames=[A,S.newPath,_.newPath],U.filemask=7,U.merged={result:null,clean:!1}}}else{let z=r.get(S.newPath),N=o.get(_.newPath),U=await Bf(e,B,z,N,s);U.conflict&&w(A,`Auto-merging ${A}`,-1),i.conflicts.push({path:A,reason:"rename-rename",oursPath:S.newPath,theirsPath:_.newPath}),w(A,`CONFLICT (rename/rename): ${A} renamed to ${S.newPath} in ${p} and to ${_.newPath} in ${g}.`),i.entries.push(yt(A,B,1)),i.entries.push(ot(S.newPath,z.mode,U.hash,2)),i.entries.push(ot(_.newPath,N.mode,U.hash,3)),i.worktreeBlobs.set(S.newPath,{hash:U.hash,mode:z.mode}),i.worktreeBlobs.set(_.newPath,{hash:U.hash,mode:N.mode})}else if(S){h.add(S.newPath);let z=o.get(A),N=r.get(S.newPath),U=u.has(S.newPath);if(z)if(U)await Ff(e,i,S.newPath,A,B,N,z,r,o,!1,s);else if(z.hash===B.hash&&N.hash===B.hash)i.entries.push(yt(S.newPath,N));else if(z.hash===B.hash)i.entries.push(yt(S.newPath,N));else if(N.hash===B.hash)i.entries.push(ot(S.newPath,N.mode,z.hash));else{let V=zi(t,S.newPath);V.stages=[{hash:B.hash,mode:B.mode},{hash:N.hash,mode:N.mode},{hash:z.hash,mode:z.mode}],V.pathnames=[A,S.newPath,A],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=o.get(S.newPath);if(i.conflicts.push({path:S.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:A}),w(S.newPath,`CONFLICT (rename/delete): ${A} renamed to ${S.newPath} in ${p}, but deleted in ${g}.`),V){i.conflicts.push({path:S.newPath,reason:"add-add"}),w(S.newPath,`Auto-merging ${S.newPath}`,0),w(S.newPath,`CONFLICT (add/add): Merge conflict in ${S.newPath}`,1),i.entries.push(yt(S.newPath,N,2)),i.entries.push(yt(S.newPath,V,3));let be=await Po(e,N.hash,V.hash,N.mode,s);i.worktreeBlobs.set(S.newPath,{hash:be,mode:N.mode})}else i.entries.push(ot(S.newPath,B.mode,B.hash,1)),i.entries.push(yt(S.newPath,N,2)),i.worktreeBlobs.set(S.newPath,{hash:N.hash,mode:N.mode}),N.hash!==B.hash&&w(S.newPath,`CONFLICT (modify/delete): ${S.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${S.newPath} left in tree.`,1)}}else if(_){h.add(_.newPath);let z=r.get(A),N=o.get(_.newPath),U=u.has(_.newPath);if(z)if(U)await Ff(e,i,_.newPath,A,B,z,N,r,o,!0,s);else if(z.hash===B.hash&&N.hash===B.hash)i.entries.push(yt(_.newPath,N));else if(z.hash===B.hash)i.entries.push(yt(_.newPath,N));else if(N.hash===B.hash)i.entries.push(ot(_.newPath,N.mode,z.hash));else{let V=zi(t,_.newPath);V.stages=[{hash:B.hash,mode:B.mode},{hash:z.hash,mode:z.mode},{hash:N.hash,mode:N.mode}],V.pathnames=[A,A,_.newPath],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=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}.`),V){i.conflicts.push({path:_.newPath,reason:"add-add"}),w(_.newPath,`Auto-merging ${_.newPath}`,0),w(_.newPath,`CONFLICT (add/add): Merge conflict in ${_.newPath}`,1),i.entries.push(yt(_.newPath,V,2)),i.entries.push(yt(_.newPath,N,3));let be=await Po(e,V.hash,N.hash,V.mode,s);i.worktreeBlobs.set(_.newPath,{hash:be,mode:V.mode})}else i.entries.push(ot(_.newPath,B.mode,B.hash,1)),i.entries.push(yt(_.newPath,N,3)),i.worktreeBlobs.set(_.newPath,{hash:N.hash,mode:N.mode}),N.hash!==B.hash&&w(_.newPath,`CONFLICT (modify/delete): ${_.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${_.newPath} left in tree.`,1)}}}let y=new Set(f.renames.map(A=>A.newPath)),x=new Set(l.renames.map(A=>A.newPath)),b=jf(n,r),k=jf(n,o),E=Gf(b,o,n),R=Gf(k,r,n),C=Lf(f.renames,E),P=Lf(l.renames,R),v=Nf(C),D=Nf(P);for(let A of[...v.keys()])D.has(A)&&(v.delete(A),D.delete(A));let O=new Set(v.keys()),H=new Set(D.keys());if(D.size>0)for(let A of a){if(A.status!=="added"||y.has(A.path))continue;let S=_f(A.path,D,O);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(r.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let z=r.get(A.path),N=o.get(S)??n.get(S);i.entries.push(ot(S,z.mode,z.hash,2)),N&&i.entries.push(ot(S,N.mode,N.hash,3)),i.worktreeBlobs.set(S,{hash:z.hash,mode:z.mode}),i.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let _=r.get(A.path);i.entries.push(ot(S,_.mode,_.hash,2)),i.worktreeBlobs.set(S,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${S}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}if(v.size>0)for(let A of c){if(A.status!=="added"||x.has(A.path))continue;let S=_f(A.path,v,H);if(!S)continue;if(t.has(S)||n.has(S)||r.has(S)||o.has(S)){if(o.has(S)){w(S,`CONFLICT (implicit dir rename): Existing file/dir at ${S} in the way of implicit directory rename(s) putting the following path(s) there: ${A.path}.`,1);continue}let z=o.get(A.path),N=r.get(S)??n.get(S);N&&i.entries.push(ot(S,N.mode,N.hash,2)),i.entries.push(ot(S,z.mode,z.hash,3)),i.worktreeBlobs.set(S,{hash:z.hash,mode:z.mode}),i.conflicts.push({path:S,reason:"add-add"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let U=t.get(A.path);U&&(U.merged={result:null,clean:!0}),h.add(A.path);continue}let _=o.get(A.path);i.entries.push(ot(S,_.mode,_.hash,3)),i.worktreeBlobs.set(S,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:S,reason:"directory-rename"}),w(S,`CONFLICT (file location): ${A.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${S}.`,1);let B=t.get(A.path);B&&(B.merged={result:null,clean:!0}),h.add(A.path)}let G=new Set(i.entries.map(A=>A.path));for(let A of G){let S=t.get(A);S&&(S.merged={result:null,clean:!0})}for(let A of h){if(G.has(A))continue;let S=t.get(A);if(!S||S.merged.clean)continue;S.filemask===7&&!S.pathConflict||(S.merged={result:null,clean:!0})}return i}function jf(e,t){let n=new Set;for(let s of e.keys()){let i=Ot(s);for(;i;)n.add(i),i=Ot(i)}let r=new Set;for(let s of t.keys()){let i=Ot(s);for(;i;)r.add(i),i=Ot(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Gf(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=Ot(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Ot(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Ot(s)}return r}function Lf(e,t){let n=new Map;for(let r of e){let o=Ot(r.oldPath),s=Ot(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=Ot(o),s=Ot(s)}}return n}function Nf(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function _f(e,t,n){let r=Ot(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=Ot(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Ot(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Ff(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(ot(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Bf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(ot(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(yt(n,d,2)),t.entries.push(ot(n,i.mode,h.hash,3));let p=await Po(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(ot(n,s.mode,h.hash,2)),t.entries.push(yt(n,d,3));let p=await Po(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Bf(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(wn(t.mode)||wn(n.mode)||wn(r.mode))return{hash:n.hash,conflict:!0};let a=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(Ie(c)||Ie(f)||Ie(a))return{hash:n.hash,conflict:!0};let l=Ct(a),d=Ct(c),m=Ct(f),u=o?.conflictStyle,h=us(d,l,m,{conflictStyle:u});if(!h.conflict)return{hash:await Vi(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,y=s?.theirsPath?`${g}:${s.theirsPath}`:g,x=mr(c,a,f,{a:w,b:y,markerSize:i??7,conflictStyle:u});return{hash:await Se(e,"blob",Vn.encode(x)),conflict:!0}}async function Po(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=mr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Se(e,"blob",Vn.encode(a))}function yt(e,t,n=0){return ot(e,t.mode,t.hash,n)}function ot(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:$e()}}async function vh(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(je(u,h.merged.result.hash,h.merged.result.mode));continue}await Hh(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(je(u,h.hash,h.mode));l.sort((u,h)=>Oe(u.path,h.path));let m=await Ge(e,l);return{entries:o,conflicts:s,messages:f,resultTree:m}}async function Hh(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(je(a,d,c.mode,1)),r.push(je(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(je(a,d,c.mode,1)),r.push(je(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(je(a,m,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await oe(e,m),p=await oe(e,u);if(Ie(h)||Ie(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(je(a,m,f.mode,2)),r.push(je(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let g=Ct(""),w=Ct(h),y=Ct(p),x=us(w,g,y,{conflictStyle:n?.conflictStyle});if(!x.conflict){let E=await Vi(e,x.result);r.push(je(a,E,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(je(a,m,f.mode,2)),r.push(je(a,u,l.mode,3));let b=mr(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),k=await Se(e,"blob",Vn.encode(b));i.set(a,{hash:k,mode:f.mode});return}if(d!==null&&m!==null&&u!==null){if(m===d){r.push(je(a,u,l.mode));return}if(u===d){r.push(je(a,m,f.mode));return}if(m===u){r.push(je(a,m,f.mode));return}if(s(a,`Auto-merging ${a}`,0),wn(c.mode)||wn(f.mode)||wn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(je(a,d,c.mode,1)),r.push(je(a,m,f.mode,2)),r.push(je(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let h=await oe(e,d),p=await oe(e,m),g=await oe(e,u);if(Ie(p)||Ie(g)||Ie(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(je(a,d,c.mode,1)),r.push(je(a,m,f.mode,2)),r.push(je(a,u,l.mode,3)),i.set(a,{hash:m,mode:f.mode});return}let w=Ct(h),y=Ct(p),x=Ct(g),b=us(y,w,x,{conflictStyle:n?.conflictStyle});if(b.conflict){let k=t.pathnames[1],E=t.pathnames[2],R=k!==a||E!==a,C={path:a,reason:"content"};R&&(k!==a&&(C.oursOrigPath=k),E!==a&&(C.theirsOrigPath=E)),o.push(C),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(je(a,d,c.mode,1)),r.push(je(a,m,f.mode,2)),r.push(je(a,u,l.mode,3));let P=R?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",v=R?`${n?.b??"theirs"}:${E}`:n?.b??"theirs",D=mr(p,h,g,{a:P,b:v,conflictStyle:n?.conflictStyle}),O=await Se(e,"blob",Vn.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let k=await Vi(e,b.result);r.push(je(a,k,f.mode))}return}}var Ah=200;async function Wf(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>=Ah)u=f;else{let g=await _t(e,c,d);g.length===0?u=null:g.length===1?u=(await j(e,g[0])).tree:u=await Wf(e,c,d,g,o+1)}let h=await Ft(e,u,f,m);f=await Dh(e,h,o);let p=nn({type:"commit",tree:f,parents:[c,d],author:Mf,committer:Mf,message:"merged common ancestors"});c=await Se(e,"commit",p)}return f}async function Dh(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=Ir.decode((await we(e,u.hash)).content),g=Ir.decode((await we(e,h.hash)).content),w=m?Ir.decode((await we(e,m.hash)).content):"",y=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",k=mr(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:y}),E=await Se(e,"blob",Vn.encode(k));r.push({path:l,mode:u.mode,hash:E,stage:0,stat:$e()}),r.push({path:d,mode:h.mode,hash:E,stage:0,stat:$e()});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=Ir.decode((await we(e,c.hash)).content),d=Ir.decode((await we(e,f.hash)).content),m=a.reason==="content"?s(a.path,1):null,u=m?Ir.decode((await we(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,y=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=mr(l,u,d,{a:w,o:i.o,b:y,markerSize:i.markerSize}),b=await Se(e,"blob",Vn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:$e()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Oe(a.path,c.path)),Ge(e,r)}async function Vi(e,t){let n=t.map(qi);if(n.length===0)return Se(e,"blob",Vn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
248
+ `)}function St(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 Ki(e){return e.endsWith("\0")?e.slice(0,-1):e}function Mf(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}$e();fe();mn();me();tr();He();ot();on();var Ir=new TextDecoder,Yn=new TextEncoder,jf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Ut(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Lh(e,t,n,r),f=await _h(e,s,i,a,c,o);return Fh(e,s,o,f)}async function gs(e,t,n,r){let o=await Ft(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Ut(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Ut(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await qf(e,t,n,o,1);return{...await Ut(e,a,s.tree,i.tree,r),baseTree:a}}async function Lh(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,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,b=d?.hash??null,x=m?.hash??null,y=0;w!==null&&w===b&&(y|=3),w!==null&&w===x&&(y|=5),b!==null&&b===x&&(y|=6);let E={path:f,stages:[u,h,p],pathnames:[f,f,f],filemask:g,matchMask:y,merged:{result:null,clean:!1},pathConflict:!1};if(Nh(E)){c.set(f,E);continue}c.set(f,E)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Nh(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 _h(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[v,T]of n)r.has(v)||a.push({path:v,status:"deleted",oldHash:T.hash,oldMode:T.mode}),o.has(v)||c.push({path:v,status:"deleted",oldHash:T.hash,oldMode:T.mode});for(let[v,T]of r)n.has(v)||a.push({path:v,status:"added",newHash:T.hash,newMode:T.mode});for(let[v,T]of o)n.has(v)||c.push({path:v,status:"added",newHash:T.hash,newMode:T.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 v of f.renames)d.set(v.oldPath,v);for(let v of l.renames)m.set(v.oldPath,v);let u=new Set;for(let[v]of r)!n.has(v)&&o.has(v)&&u.add(v);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(v,T,F=0){i.msgBuf.push({sortKey:v,subOrder:F,text:T})}for(let v of[...n.keys()].sort()){let T=d.get(v),F=m.get(v);if(!T&&!F)continue;let _=n.get(v);if(h.add(v),T&&F)if(h.add(T.newPath),h.add(F.newPath),T.newPath===F.newPath){let U=r.get(T.newPath),N=o.get(F.newPath);if(U.hash===N.hash)i.entries.push(Rt(T.newPath,U));else{let K=Vi(t,T.newPath);K.stages=[{hash:_.hash,mode:_.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],K.pathnames=[v,T.newPath,F.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let U=r.get(T.newPath),N=o.get(F.newPath),K=await Wf(e,_,U,N,s);K.conflict&&w(v,`Auto-merging ${v}`,-1),i.conflicts.push({path:v,reason:"rename-rename",oursPath:T.newPath,theirsPath:F.newPath}),w(v,`CONFLICT (rename/rename): ${v} renamed to ${T.newPath} in ${p} and to ${F.newPath} in ${g}.`),i.entries.push(Rt(v,_,1)),i.entries.push(ft(T.newPath,U.mode,K.hash,2)),i.entries.push(ft(F.newPath,N.mode,K.hash,3)),i.worktreeBlobs.set(T.newPath,{hash:K.hash,mode:U.mode}),i.worktreeBlobs.set(F.newPath,{hash:K.hash,mode:N.mode})}else if(T){h.add(T.newPath);let U=o.get(v),N=r.get(T.newPath),K=u.has(T.newPath);if(U)if(K)await Uf(e,i,T.newPath,v,_,N,U,r,o,!1,s);else if(U.hash===_.hash&&N.hash===_.hash)i.entries.push(Rt(T.newPath,N));else if(U.hash===_.hash)i.entries.push(Rt(T.newPath,N));else if(N.hash===_.hash)i.entries.push(ft(T.newPath,N.mode,U.hash));else{let ne=Vi(t,T.newPath);ne.stages=[{hash:_.hash,mode:_.mode},{hash:N.hash,mode:N.mode},{hash:U.hash,mode:U.mode}],ne.pathnames=[v,T.newPath,v],ne.filemask=7,ne.merged={result:null,clean:!1}}else{let ne=o.get(T.newPath);if(i.conflicts.push({path:T.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:v}),w(T.newPath,`CONFLICT (rename/delete): ${v} renamed to ${T.newPath} in ${p}, but deleted in ${g}.`),ne){i.conflicts.push({path:T.newPath,reason:"add-add"}),w(T.newPath,`Auto-merging ${T.newPath}`,0),w(T.newPath,`CONFLICT (add/add): Merge conflict in ${T.newPath}`,1),i.entries.push(Rt(T.newPath,N,2)),i.entries.push(Rt(T.newPath,ne,3));let J=await Co(e,N.hash,ne.hash,N.mode,s);i.worktreeBlobs.set(T.newPath,{hash:J,mode:N.mode})}else i.entries.push(ft(T.newPath,_.mode,_.hash,1)),i.entries.push(Rt(T.newPath,N,2)),i.worktreeBlobs.set(T.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w(T.newPath,`CONFLICT (modify/delete): ${T.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${T.newPath} left in tree.`,1)}}else if(F){h.add(F.newPath);let U=r.get(v),N=o.get(F.newPath),K=u.has(F.newPath);if(U)if(K)await Uf(e,i,F.newPath,v,_,U,N,r,o,!0,s);else if(U.hash===_.hash&&N.hash===_.hash)i.entries.push(Rt(F.newPath,N));else if(U.hash===_.hash)i.entries.push(Rt(F.newPath,N));else if(N.hash===_.hash)i.entries.push(ft(F.newPath,N.mode,U.hash));else{let ne=Vi(t,F.newPath);ne.stages=[{hash:_.hash,mode:_.mode},{hash:U.hash,mode:U.mode},{hash:N.hash,mode:N.mode}],ne.pathnames=[v,v,F.newPath],ne.filemask=7,ne.merged={result:null,clean:!1}}else{let ne=r.get(F.newPath);if(i.conflicts.push({path:F.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:v}),w(F.newPath,`CONFLICT (rename/delete): ${v} renamed to ${F.newPath} in ${g}, but deleted in ${p}.`),ne){i.conflicts.push({path:F.newPath,reason:"add-add"}),w(F.newPath,`Auto-merging ${F.newPath}`,0),w(F.newPath,`CONFLICT (add/add): Merge conflict in ${F.newPath}`,1),i.entries.push(Rt(F.newPath,ne,2)),i.entries.push(Rt(F.newPath,N,3));let J=await Co(e,ne.hash,N.hash,ne.mode,s);i.worktreeBlobs.set(F.newPath,{hash:J,mode:ne.mode})}else i.entries.push(ft(F.newPath,_.mode,_.hash,1)),i.entries.push(Rt(F.newPath,N,3)),i.worktreeBlobs.set(F.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w(F.newPath,`CONFLICT (modify/delete): ${F.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${F.newPath} left in tree.`,1)}}}let b=new Set(f.renames.map(v=>v.newPath)),x=new Set(l.renames.map(v=>v.newPath)),y=Gf(n,r),E=Gf(n,o),k=Lf(y,o,n),R=Lf(E,r,n),C=Nf(f.renames,k),P=Nf(l.renames,R),H=_f(C),D=_f(P);for(let v of[...H.keys()])D.has(v)&&(H.delete(v),D.delete(v));let O=new Set(H.keys()),A=new Set(D.keys());if(D.size>0)for(let v of a){if(v.status!=="added"||b.has(v.path))continue;let T=Ff(v.path,D,O);if(!T)continue;if(t.has(T)||n.has(T)||r.has(T)||o.has(T)){if(r.has(T)){w(T,`CONFLICT (implicit dir rename): Existing file/dir at ${T} in the way of implicit directory rename(s) putting the following path(s) there: ${v.path}.`,1);continue}let U=r.get(v.path),N=o.get(T)??n.get(T);i.entries.push(ft(T,U.mode,U.hash,2)),N&&i.entries.push(ft(T,N.mode,N.hash,3)),i.worktreeBlobs.set(T,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:T,reason:"add-add"}),w(T,`CONFLICT (file location): ${v.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${T}.`,1);let K=t.get(v.path);K&&(K.merged={result:null,clean:!0}),h.add(v.path);continue}let F=r.get(v.path);i.entries.push(ft(T,F.mode,F.hash,2)),i.worktreeBlobs.set(T,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:T,reason:"directory-rename"}),w(T,`CONFLICT (file location): ${v.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${T}.`,1);let _=t.get(v.path);_&&(_.merged={result:null,clean:!0}),h.add(v.path)}if(H.size>0)for(let v of c){if(v.status!=="added"||x.has(v.path))continue;let T=Ff(v.path,H,A);if(!T)continue;if(t.has(T)||n.has(T)||r.has(T)||o.has(T)){if(o.has(T)){w(T,`CONFLICT (implicit dir rename): Existing file/dir at ${T} in the way of implicit directory rename(s) putting the following path(s) there: ${v.path}.`,1);continue}let U=o.get(v.path),N=r.get(T)??n.get(T);N&&i.entries.push(ft(T,N.mode,N.hash,2)),i.entries.push(ft(T,U.mode,U.hash,3)),i.worktreeBlobs.set(T,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:T,reason:"add-add"}),w(T,`CONFLICT (file location): ${v.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${T}.`,1);let K=t.get(v.path);K&&(K.merged={result:null,clean:!0}),h.add(v.path);continue}let F=o.get(v.path);i.entries.push(ft(T,F.mode,F.hash,3)),i.worktreeBlobs.set(T,{hash:F.hash,mode:F.mode}),i.conflicts.push({path:T,reason:"directory-rename"}),w(T,`CONFLICT (file location): ${v.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${T}.`,1);let _=t.get(v.path);_&&(_.merged={result:null,clean:!0}),h.add(v.path)}let G=new Set(i.entries.map(v=>v.path));for(let v of G){let T=t.get(v);T&&(T.merged={result:null,clean:!0})}for(let v of h){if(G.has(v))continue;let T=t.get(v);if(!T||T.merged.clean)continue;T.filemask===7&&!T.pathConflict||(T.merged={result:null,clean:!0})}return i}function Gf(e,t){let n=new Set;for(let s of e.keys()){let i=It(s);for(;i;)n.add(i),i=It(i)}let r=new Set;for(let s of t.keys()){let i=It(s);for(;i;)r.add(i),i=It(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Lf(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=It(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=It(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=It(s)}return r}function Nf(e,t){let n=new Map;for(let r of e){let o=It(r.oldPath),s=It(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=It(o),s=It(s)}}return n}function _f(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 Ff(e,t,n){let r=It(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=It(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function It(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Uf(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 Wf(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(Rt(n,d,2)),t.entries.push(ft(n,i.mode,h.hash,3));let p=await Co(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(Rt(n,d,3));let p=await Co(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Wf(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(wn(t.mode)||wn(n.mode)||wn(r.mode))return{hash:n.hash,conflict:!0};let a=await oe(e,t.hash),c=await oe(e,n.hash),f=await oe(e,r.hash);if(ve(c)||ve(f)||ve(a))return{hash:n.hash,conflict:!0};let l=St(a),d=St(c),m=St(f),u=o?.conflictStyle,h=hs(d,l,m,{conflictStyle:u});if(!h.conflict)return{hash:await Xi(e,h.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,x=hr(c,a,f,{a:w,b,markerSize:i??7,conflictStyle:u});return{hash:await Te(e,"blob",Yn.encode(x)),conflict:!0}}async function Co(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=hr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Te(e,"blob",Yn.encode(a))}function Rt(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:Ie()}}async function Fh(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 Uh(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)=>Se(u.path,h.path));let m=await Fe(e,l);return{entries:o,conflicts:s,messages:f,resultTree:m}}async function Uh(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 oe(e,m),p=await oe(e,u);if(ve(h)||ve(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=St(""),w=St(h),b=St(p),x=hs(w,g,b,{conflictStyle:n?.conflictStyle});if(!x.conflict){let k=await Xi(e,x.result);r.push(_e(a,k,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 y=hr(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),E=await Te(e,"blob",Yn.encode(y));i.set(a,{hash:E,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),wn(c.mode)||wn(f.mode)||wn(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 oe(e,d),p=await oe(e,m),g=await oe(e,u);if(ve(p)||ve(g)||ve(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=St(h),b=St(p),x=St(g),y=hs(b,w,x,{conflictStyle:n?.conflictStyle});if(y.conflict){let E=t.pathnames[1],k=t.pathnames[2],R=E!==a||k!==a,C={path:a,reason:"content"};R&&(E!==a&&(C.oursOrigPath=E),k!==a&&(C.theirsOrigPath=k)),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=R?`${n?.a??"HEAD"}:${E}`:n?.a??"HEAD",H=R?`${n?.b??"theirs"}:${k}`:n?.b??"theirs",D=hr(p,h,g,{a:P,b:H,conflictStyle:n?.conflictStyle}),O=await Te(e,"blob",Yn.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let E=await Xi(e,y.result);r.push(_e(a,E,f.mode))}return}}var Bh=200;async function qf(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>=Bh)u=f;else{let g=await Ft(e,c,d);g.length===0?u=null:g.length===1?u=(await j(e,g[0])).tree:u=await qf(e,c,d,g,o+1)}let h=await Ut(e,u,f,m);f=await Wh(e,h,o);let p=nn({type:"commit",tree:f,parents:[c,d],author:jf,committer:jf,message:"merged common ancestors"});c=await Te(e,"commit",p)}return f}async function Wh(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=Ir.decode((await Ee(e,u.hash)).content),g=Ir.decode((await Ee(e,h.hash)).content),w=m?Ir.decode((await Ee(e,m.hash)).content):"",b=8+n*2,x=i.a??"Temporary merge branch 1",y=i.b??"Temporary merge branch 2",E=hr(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${y}:${d}`,markerSize:b}),k=await Te(e,"blob",Yn.encode(E));r.push({path:l,mode:u.mode,hash:k,stage:0,stat:Ie()}),r.push({path:d,mode:h.mode,hash:k,stage:0,stat:Ie()});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=Ir.decode((await Ee(e,c.hash)).content),d=Ir.decode((await Ee(e,f.hash)).content),m=a.reason==="content"?s(a.path,1):null,u=m?Ir.decode((await Ee(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,b=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=hr(l,u,d,{a:w,o:i.o,b,markerSize:i.markerSize}),y=await Te(e,"blob",Yn.encode(x));r.push({path:a.path,mode:c.mode,hash:y,stage:0,stat:Ie()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Se(a.path,c.path)),Fe(e,r)}async function Xi(e,t){let n=t.map(Ki);if(n.length===0)return Te(e,"blob",Yn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
248
250
  `):`${n.join(`
249
251
  `)}
250
- `;return Se(e,"blob",Vn.encode(s))}function je(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:$e()}}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 ms(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}
252
+ `;return Te(e,"blob",Yn.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:Ie()}}function Vi(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 ps(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}
251
253
  ${e.join(" ")}
252
254
  Merge with strategy ort failed.
253
255
  `;let c=e.map(l=>` ${l}`).join(`
@@ -262,7 +264,7 @@ ${i}
262
264
  ${a}
263
265
  Aborting
264
266
  fatal: ${n} failed
265
- `}function Uf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
267
+ `}function Bf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
266
268
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
267
269
  ${i}
268
270
  Please commit your changes or stash them before you ${n}.
@@ -272,37 +274,37 @@ ${i}
272
274
  Please move or remove them before you ${n}.
273
275
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
274
276
  ${s}
275
- `}async function xn(e,t,n,r){let o=await K(e),s=await ce(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(De(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let y=s.get(g);(!y||y.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await Ki(e,o,s);let w=r.operationName??"merge",y=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ms(g,w,y,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await sr(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Zs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Ki(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),y=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&y.length>0?x=Uf(w,y,p,g):y.length>0?x=ms(y,p,g,"untracked","worktree"):x=ms(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await sr(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Ki(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),y=h.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),x=[];w.length>0&&x.push(ms(w,p,g,"local","worktree")),y.length>0&&x.push(ms(y,p,g,"untracked","worktree"));let b;return x.length>1?b=Uf(w,y,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Me(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),l=[...a,...f];l.sort((h,p)=>Oe(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await ae(e,d);let m=l.filter(h=>h.stage===0),u=await Ge(e,m);return{ok:!0,finalIndex:d,mergedTreeHash:u}}async function Ki(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=T(e.workTree,r.path);await e.fs.exists(o)||await ct(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();Fe();ue();ve();on();function qf(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:I().describe("Abort the current cherry-pick operation"),continue:I().describe("Continue the cherry-pick after conflict resolution"),skip:I().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":I().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:J.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:I().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let B=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commit:null});if(ee(B))return{stdout:"",stderr:B.message??"",exitCode:1};let z=await jh(s,r.env);return z.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),z}if(n.continue){let B=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commit:null});if(ee(B))return{stdout:"",stderr:B.message??"",exitCode:1};let z=await Gh(s,r.env);return z.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),z}if(n.skip)return Mh(s,r.env);let i=n.commit;if(!i)return $("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await He(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Ze(s);if(M(d))return d;let m=await K(s);if(n.noCommit){let B=m.entries.filter(z=>z.stage>0);if(B.length>0){let U=B.slice(0,10).map(be=>`${be.path}: unmerged (${be.hash})`).join(`
276
- `),V=B.length>10?`
277
- ...`:"";return L(`${U}${V}
277
+ `}async function Cn(e,t,n,r){let o=await z(e),s=await de(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Ge(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let b=s.get(g);(!b||b.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 Yi(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ps(g,w,b,"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:Zs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Yi(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(),b=h.errors.filter(y=>y.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||y.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(y=>y.path).sort(),x;return w.length>0&&b.length>0?x=Bf(w,b,p,g):b.length>0?x=ps(b,p,g,"untracked","worktree"):x=ps(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:Js,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Yi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(E=>E.error==="WOULD_OVERWRITE"||E.error==="NOT_UPTODATE_FILE").map(E=>E.path).sort(),b=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),x=[];w.length>0&&x.push(ps(w,p,g,"local","worktree")),b.length>0&&x.push(ps(b,p,g,"untracked","worktree"));let y;return x.length>1?y=Bf(w,b,p,g):y=x[0]??"",{ok:!1,stdout:"",stderr:y,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Ne(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)=>Se(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await le(e,d);let m=l.filter(h=>h.stage===0),u=await Fe(e,m);return{ok:!0,finalIndex:d,mergedTreeHash:u}}async function Yi(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=I(e.workTree,r.path);await e.fs.exists(o)||await dt(e,{path:r.path,hash:r.hash,mode:r.mode})}}fe();qe();pe();He();on();function zf(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:Y.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 _=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commit:null});if(ee(_))return{stdout:"",stderr:_.message??"",exitCode:1};let U=await zh(s,r.env);return U.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let _=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commit:null});if(ee(_))return{stdout:"",stderr:_.message??"",exitCode:1};let U=await Kh(s,r.env);return U.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),U}if(n.skip)return qh(s,r.env);let i=n.commit;if(!i)return S("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await De(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 _=m.entries.filter(U=>U.stage>0);if(_.length>0){let K=_.slice(0,10).map(J=>`${J.path}: unmerged (${J.hash})`).join(`
278
+ `),ne=_.length>10?`
279
+ ...`:"";return L(`${K}${ne}
278
280
  error: your index file is unmerged.
279
281
  fatal: cherry-pick failed
280
- `,128)}}else{let B=yn(m,"Cherry-picking",`fatal: cherry-pick failed
281
- `);if(B)return B}let u=await j(s,d),p=!!n["record-origin"]?Lh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let B=await ce(s,u.tree);if(xr(m,B))return L(`error: your local changes would be overwritten by cherry-pick.
282
+ `,128)}}else{let _=yn(m,"Cherry-picking",`fatal: cherry-pick failed
283
+ `);if(_)return _}let u=await j(s,d),p=!!n["record-origin"]?Vh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let _=await de(s,u.tree);if(Cr(m,_))return L(`error: your local changes would be overwritten by cherry-pick.
282
284
  hint: commit your changes or stash them to proceed.
283
285
  fatal: cherry-pick failed
284
286
  `,128)}if(l.parents.length>1){if(!n.mainline)return L(`error: commit ${f} is a merge but no -m option was given.
285
287
  fatal: cherry-pick failed
286
- `,128);let B=n.mainline-1;if(B<0||B>=l.parents.length)return L(`error: commit ${f} does not have parent ${n.mainline}
288
+ `,128);let _=n.mainline-1;if(_<0||_>=l.parents.length)return L(`error: commit ${f} does not have parent ${n.mainline}
287
289
  fatal: cherry-pick failed
288
290
  `,128)}else if(n.mainline)return L(`error: mainline was specified but commit is not a merge.
289
291
  fatal: cherry-pick failed
290
- `,128);let g;if(l.parents.length===0)g=await Ge(s,[]);else{let B=l.parents.length>1?n.mainline-1:0,z=l.parents[B];if(!z)throw new Error("unreachable: parent must exist");g=(await j(s,z)).tree}let w=Y(f),y=fe(l.message),x=await ke(s,"merge.conflictstyle")??"merge",b={a:"HEAD",b:y?`${w} (${y})`:w,conflictStyle:x},k=await Ft(s,g,u.tree,l.tree,b);if(k.conflicts.length===0&&k.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Te(s,"MERGE_MSG",p);let B=k.messages.length>0?`${k.messages.join(`
292
+ `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let _=l.parents.length>1?n.mainline-1:0,U=l.parents[_];if(!U)throw new Error("unreachable: parent must exist");g=(await j(s,U)).tree}let w=V(f),b=ue(l.message),x=await xe(s,"merge.conflictstyle")??"merge",y={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:x},E=await Ut(s,g,u.tree,l.tree,y);if(E.conflicts.length===0&&E.resultTree===u.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",p);let _=E.messages.length>0?`${E.messages.join(`
291
293
  `)}
292
- `:"",z=await rt(s,{fromCommit:!0});return{stdout:`${B}${z}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
294
+ `:"",U=await at(s,{fromCommit:!0});return{stdout:`${_}${U}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
293
295
  If you wish to commit it anyway, use:
294
296
 
295
297
  git commit --allow-empty
296
298
 
297
299
  Otherwise, please use 'git cherry-pick --skip'
298
- `,exitCode:1}}let E=await xn(s,k,u.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(k.conflicts.length>0){let B=k.messages.join(`
299
- `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:B?`${B}
300
- `:"",stderr:`error: could not apply ${w}... ${fe(l.message)}
300
+ `,exitCode:1}}let k=await Cn(s,E,u.tree,{labels:y,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!k.ok)return k;if(E.conflicts.length>0){let _=E.messages.join(`
301
+ `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:_?`${_}
302
+ `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
301
303
  hint: after resolving the conflicts, mark the corrected paths
302
304
  hint: with 'git add <paths>' or 'git rm <paths>'
303
305
  hint: Disable this message with "git config set advice.mergeConflict false"
304
- `,exitCode:1}:(await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Te(s,"MERGE_MSG",p),{stdout:B?`${B}
305
- `:"",stderr:`error: could not apply ${w}... ${fe(l.message)}
306
+ `,exitCode:1}:(await X(s,"CHERRY_PICK_HEAD",f),await X(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",p),{stdout:_?`${_}
307
+ `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
306
308
  hint: After resolving the conflicts, mark them with
307
309
  hint: "git add/rm <pathspec>", then run
308
310
  hint: "git cherry-pick --continue".
@@ -310,141 +312,146 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
310
312
  hint: To abort and get back to the state before "git cherry-pick",
311
313
  hint: run "git cherry-pick --abort".
312
314
  hint: Disable this message with "git config set advice.mergeConflict false"
313
- `,exitCode:1})}let R=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await Qe(s,r.env);if(M(C))return C;let P=await ht(s,R,[d],l.author,C,p);await Mt(s),await jt(s);let v=await Q(s),D=p.split(`
314
- `)[0]??"",O=v?.type==="symbolic"?v.target:"HEAD";await re(s,r.env,O,d,P,`cherry-pick: ${D}`,v?.type==="symbolic");let H=v?.type==="symbolic"?Re(v.target):"detached HEAD",G=u.tree,A=await fn(s,G,R,l.author,C,!0),S=Ht(H,P,p),_=k.messages.length>0?`${k.messages.join(`
315
+ `,exitCode:1})}let R=k.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await tt(s,r.env);if(M(C))return C;let P=await wt(s,R,[d],l.author,C,p);await Gt(s),await Lt(s);let H=await Q(s),D=p.split(`
316
+ `)[0]??"",O=H?.type==="symbolic"?H.target:"HEAD";await ae(s,r.env,O,d,P,`cherry-pick: ${D}`,H?.type==="symbolic");let A=H?.type==="symbolic"?Ce(H.target):"detached HEAD",G=u.tree,v=await fn(s,G,R,l.author,C,!0),T=Dt(A,P,p),F=E.messages.length>0?`${E.messages.join(`
315
317
  `)}
316
- `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${_}${S}
317
- ${A}`,stderr:"",exitCode:0}}})}async function Mh(e,t){if(!await F(e,"CHERRY_PICK_HEAD"))return L(`error: no cherry-pick in progress
318
+ `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${F}${T}
319
+ ${v}`,stderr:"",exitCode:0}}})}async function qh(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return L(`error: no cherry-pick in progress
318
320
  fatal: cherry-pick failed
319
- `,128);let r=await Z(e);if(!r)return $("unable to resolve HEAD");let o=await j(e,r),s=await K(e),i=await eo(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
321
+ `,128);let r=await Z(e);if(!r)return S("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await eo(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
320
322
  fatal: cherry-pick failed
321
- `}}return await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Mt(e),{stdout:"",stderr:"",exitCode:0}}async function jh(e,t){return await F(e,"CHERRY_PICK_HEAD")?Nn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
323
+ `}}return await le(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps),await ae(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Gt(e),{stdout:"",stderr:"",exitCode:0}}async function zh(e,t){return await B(e,"CHERRY_PICK_HEAD")?_n(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
322
324
  fatal: cherry-pick failed
323
- `,128),operationName:"cherry-pick",clearState:Mt,origHeadAsTargetRev:!0}):await F(e,"REVERT_HEAD")?Nn(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
325
+ `,128),operationName:"cherry-pick",clearState:Gt,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?_n(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
324
326
  fatal: cherry-pick failed
325
- `,128),operationName:"cherry-pick",clearState:jt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
327
+ `,128),operationName:"cherry-pick",clearState:Lt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
326
328
  fatal: cherry-pick failed
327
- `,128)}async function Gh(e,t){let n=await F(e,"CHERRY_PICK_HEAD");if(!n)return L(`error: no cherry-pick or revert in progress
329
+ `,128)}async function Kh(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return L(`error: no cherry-pick or revert in progress
328
330
  fatal: cherry-pick failed
329
- `,128);let r=await K(e),o=yn(r,"Committing");if(o)return o;let s=await j(e,n),i=await Pe(e,"MERGE_MSG");if(!i)return L(`Aborting commit due to empty commit message.
330
- `,1);let a=await Pe(e,"SQUASH_MSG");a&&(i=a+i),i=Yt(i);let c=De(r),f=await Ge(e,c),l=await Ze(e);if(M(l))return l;let m=(await j(e,l)).tree,u=await Qe(e,t);if(M(u))return u;let h=At(i),p=await ht(e,f,[l],s.author,u,h);await Mt(e),await jt(e),await pe(e,"SQUASH_MSG");let g=await Q(e),w=fe(h),y=g?.type==="symbolic"?g.target:"HEAD";await re(e,t,y,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Re(g.target):"detached HEAD",b=await fn(e,m,f,s.author,u,!0);return{stdout:`${Ht(x,p,i)}
331
- ${b}`,stderr:"",exitCode:0}}function Lh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
331
+ `,128);let r=await z(e),o=yn(r,"Committing");if(o)return o;let s=await j(e,n),i=await Oe(e,"MERGE_MSG");if(!i)return L(`Aborting commit due to empty commit message.
332
+ `,1);let a=await Oe(e,"SQUASH_MSG");a&&(i=a+i),i=Yt(i);let c=Ge(r),f=await Fe(e,c),l=await Qe(e);if(M(l))return l;let m=(await j(e,l)).tree,u=await tt(e,t);if(M(u))return u;let h=Mt(i),p=await wt(e,f,[l],s.author,u,h);await Gt(e),await Lt(e),await we(e,"SQUASH_MSG");let g=await Q(e),w=ue(h),b=g?.type==="symbolic"?g.target:"HEAD";await ae(e,t,b,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Ce(g.target):"detached HEAD",y=await fn(e,m,f,s.author,u,!0);return{stdout:`${Dt(x,p,i)}
333
+ ${y}`,stderr:"",exitCode:0}}function Vh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
332
334
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
333
335
  ${n}
334
336
  `:`${r}
335
337
 
336
338
  ${n}
337
- `}se();_e();Xs();Ce();le();function zf(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:I().alias("f").describe("Required to actually remove files"),"dry-run":I().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:I().alias("d").describe("Also remove untracked directories"),removeIgnored:I().alias("x").describe("Remove ignored files as well"),onlyIgnored:I().alias("X").describe("Remove only ignored files"),exclude:J.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,m=n.onlyIgnored,u=await t?.hooks?.preClean?.({repo:s,dryRun:c,force:f,removeDirs:l,removeIgnored:d,onlyIgnored:m});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};if(!f&&!c&&await ke(s,"clean.requireForce")!=="false")return $("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await K(s),p=new Set(h.entries.map(C=>C.path)),g=mt(s,r.cwd),w=n.pathspec,y=w.length>0?w.map(C=>Ue(C,g)):null,x=n.exclude?[n.exclude]:[],b=await Kf(s,a,"",{trackedPaths:p,removeDirs:l,removeIgnored:d,onlyIgnored:m,extraExcludes:x}),k;y?k=b.filter(C=>ye(y,C.path)):k=b,k.sort((C,P)=>C.path<P.path?-1:C.path>P.path?1:0);let E=[];if(c)for(let C of k){let P=C.isDir?`Would remove ${C.path}/`:`Would remove ${C.path}`;E.push(P)}else for(let C of k){let P=T(a,C.path);C.isDir?(await r.fs.rm(P,{recursive:!0}),E.push(`Removing ${C.path}/`)):(await r.fs.rm(P),E.push(`Removing ${C.path}`))}let R=E.length>0?`${E.join(`
339
+ `}ce();We();Xs();$e();me();function Kf(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:Y.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Je(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,u=await t?.hooks?.preClean?.({repo:s,dryRun:c,force:f,removeDirs:l,removeIgnored:d,onlyIgnored:m});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};if(!f&&!c&&await xe(s,"clean.requireForce")!=="false")return S("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await z(s),p=new Set(h.entries.map(C=>C.path)),g=ut(s,r.cwd),w=n.pathspec,b=w.length>0?w.map(C=>Ue(C,g)):null,x=n.exclude?[n.exclude]:[],y=await Vf(s,a,"",{trackedPaths:p,removeDirs:l,removeIgnored:d,onlyIgnored:m,extraExcludes:x}),E;b?E=y.filter(C=>ye(b,C.path)):E=y,E.sort((C,P)=>C.path<P.path?-1:C.path>P.path?1:0);let k=[];if(c)for(let C of E){let P=C.isDir?`Would remove ${C.path}/`:`Would remove ${C.path}`;k.push(P)}else for(let C of E){let P=I(a,C.path);C.isDir?(await r.fs.rm(P,{recursive:!0}),k.push(`Removing ${C.path}/`)):(await r.fs.rm(P),k.push(`Removing ${C.path}`))}let R=k.length>0?`${k.join(`
338
340
  `)}
339
- `:"";return await t?.hooks?.postClean?.({repo:s,removed:k.map(C=>C.path),dryRun:c}),{stdout:R,stderr:"",exitCode:0}}})}async function Kf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Rr(e);let c=T(t,".gitignore");try{let f=await e.fs.readFile(c);i=nr(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
340
- `),l=ss(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=T(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let m=i&&rn(i,l,!0)==="ignored",u=Nh(r.trackedPaths,l),h=()=>Kf(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&&rn(i,l,!1)==="ignored";r.onlyIgnored?m&&o.push({path:l,isDir:!1}):m&&s||o.push({path:l,isDir:!1})}}return o}function Nh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}se();_e();$n();Ce();ie();le();Fe();ue();Dn();ie();le();var ps=2147483647;async function Sr(e){let t=T(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
341
- `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function _h(e,t){let n=T(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
341
+ `:"";return await t?.hooks?.postClean?.({repo:s,removed:E.map(C=>C.path),dryRun:c}),{stdout:R,stderr:"",exitCode:0}}})}async function Vf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await xr(e);let c=I(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=is(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=I(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let m=i&&rn(i,l,!0)==="ignored",u=Yh(r.trackedPaths,l),h=()=>Vf(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&&rn(i,l,!1)==="ignored";r.onlyIgnored?m&&o.push({path:l,isDir:!1}):m&&s||o.push({path:l,isDir:!1})}}return o}function Yh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}ce();We();Sn();$e();fe();me();qe();pe();Mn();fe();me();var ws=2147483647;async function vr(e){let t=I(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 Xh(e,t){let n=I(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(`
342
344
  `)+`
343
- `)}async function Co(e){return(await Sr(e)).size>0}async function Tr(e,t,n){let r=n??await Sr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await _h(e,r)}async function Vf(e,t,n,r){if(n>=ps)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Kt(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 Kt(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}}_e();Dn();dt();ie();var $o=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]),Fh=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]),Oo=64,Uh=4,Yi=4096,Yf=65536,Bh=127;function Wh(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=zh(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])^$o[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<=Oo)continue;let h=[],p=u.length/Oo;for(let g=0;g<Oo;g++)h.push(u[Math.floor(g*p)]);c.set(m,h),s[m]=Oo}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 qh(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=Zf(i,a,r),a=Zf(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])^$o[f>>>23],l++;f=f>>>0;let m=d,u=0,h=0;for(;m<o;){if(h<Yi){f^=Fh[t[m-16]],f=((f<<8|t[m])^$o[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let x=e.entries[y];if(x.val!==f)continue;let b=x.ptr,k=s.byteLength-b,E=o-m;if(k>E&&(k=E),k<=h)break;let R=0;for(;R<k&&s[b+R]===t[m+R];)R++;if(R>h&&(h=R,u=b,h>=Yi))break}}if(h<Uh)c(2),l===0&&a++,i[a++]=t[m++],l++,l===Bh&&(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>Yf?h-Yf: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<Yi){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[m+y])^$o[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 Xf={blob:0,tree:1,commit:2,tag:3};function Io(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Xf[f.type]??99,m=Xf[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 k=qh(x,l.content,b);k&&(!m||k.byteLength<m.byteLength)&&(m=k,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(Wh(l.content)),c.push(l.hash)}return i}function zh(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 Zf(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}Kr();ue();ie();mn();Zr();zs();async function Kh(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await gs(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 ws(e,l,i,f,c,r);return{count:c.length,objects:Vh(c)}}async function vr(e,t,n,r,o){let{count:s,objects:i}=await Kh(e,t,n,r,o);return{count:s,objects:Yh(e,i)}}async function*Vh(e){for(let t of e)yield t}async function*Yh(e,t){for await(let n of t){let r=await we(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Hr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function gs(e,t,n,r){if(n.has(t)||(n.add(t),!await Kt(e,t)))return;let o=await we(e,t);switch(o.type){case"commit":{let s=tn(o.content);if(await gs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await gs(e,i,n,r);break}case"tree":{let s=Gn(o.content);for(let i of s.entries)await gs(e,i.hash,n,r);break}case"tag":{let s=hn(o.content);await gs(e,s.object,n,r);break}case"blob":break}}async function ws(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await we(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=tn(i.content);if(await ws(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await ws(e,c,n,r,o,s);break}case"tree":{let a=Gn(i.content);for(let c of a.entries)await ws(e,c.hash,n,r,o,s);break}case"tag":{let a=hn(i.content);await ws(e,a.object,n,r,o,s);break}case"blob":break}}var Xh=new TextEncoder,So=new TextDecoder,Jf=65520,Zh=new Uint8Array([48,48,48,48]);function Pn(e){let t=typeof e=="string"?Xh.encode(e):e,n=4+t.byteLength;if(n>Jf)throw new Error(`pkt-line too long: ${n} bytes (max ${Jf})`);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 Xi(){return Zh.slice()}function To(...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 Ar(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=So.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function vo(e){if(e.type==="flush")return"";let t=So.decode(e.data);return t.endsWith(`
344
- `)?t.slice(0,-1):t}var Jh=1,Qh=2,ep=3;function Zi(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case Jh:t.push(f),o+=f.byteLength;break;case Qh:n.push(So.decode(f));break;case ep:r.push(So.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}dt();function Ji(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function Qi(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...Ji(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=Ar(c);return tp(f,t)}function tp(e,t){let n=0,r=e[n];r?.type==="data"&&vo(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let m=l.slice(0,d),u=l.slice(d+1);if(!(m===te&&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 np=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function Qf(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=tl(r,np),c=[];c.push(Pn(`want ${t[0]} ${a.join(" ")}
345
+ `)}async function Po(e){return(await vr(e)).size>0}async function Tr(e,t,n){let r=n??await vr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await Xh(e,r)}async function Yf(e,t,n,r){if(n>=ws)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Kt(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 Kt(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}}We();Mn();ht();fe();var Oo=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Zh=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]),$o=64,Jh=4,Zi=4096,Xf=65536,Qh=127;function ep(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=np(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])^Oo[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<=$o)continue;let h=[],p=u.length/$o;for(let g=0;g<$o;g++)h.push(u[Math.floor(g*p)]);c.set(m,h),s[m]=$o}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 tp(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=Jf(i,a,r),a=Jf(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])^Oo[f>>>23],l++;f=f>>>0;let m=d,u=0,h=0;for(;m<o;){if(h<Zi){f^=Zh[t[m-16]],f=((f<<8|t[m])^Oo[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 x=e.entries[b];if(x.val!==f)continue;let y=x.ptr,E=s.byteLength-y,k=o-m;if(E>k&&(E=k),E<=h)break;let R=0;for(;R<E&&s[y+R]===t[m+R];)R++;if(R>h&&(h=R,u=y,h>=Zi))break}}if(h<Jh)c(2),l===0&&a++,i[a++]=t[m++],l++,l===Qh&&(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>Xf?h-Xf: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<Zi){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[m+b])^Oo[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 Zf={blob:0,tree:1,commit:2,tag:3};function So(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Zf[f.type]??99,m=Zf[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 y=m?m.byteLength:l.content.byteLength/2|0;if(y<16)continue;let E=tp(x,l.content,y);E&&(!m||E.byteLength<m.byteLength)&&(m=E,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(ep(l.content)),c.push(l.hash)}return i}function np(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 Jf(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}Yr();pe();fe();mn();Qr();zs();async function rp(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await bs(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 ys(e,l,i,f,c,r);return{count:c.length,objects:sp(c)}}async function Hr(e,t,n,r,o){let{count:s,objects:i}=await rp(e,t,n,r,o);return{count:s,objects:op(e,i)}}async function*sp(e){for(let t of e)yield t}async function*op(e,t){for await(let n of t){let r=await Ee(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Ar(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function bs(e,t,n,r){if(n.has(t)||(n.add(t),!await Kt(e,t)))return;let o=await Ee(e,t);switch(o.type){case"commit":{let s=tn(o.content);if(await bs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await bs(e,i,n,r);break}case"tree":{let s=Ln(o.content);for(let i of s.entries)await bs(e,i.hash,n,r);break}case"tag":{let s=hn(o.content);await bs(e,s.object,n,r);break}case"blob":break}}async function ys(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await Ee(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=tn(i.content);if(await ys(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await ys(e,c,n,r,o,s);break}case"tree":{let a=Ln(i.content);for(let c of a.entries)await ys(e,c.hash,n,r,o,s);break}case"tag":{let a=hn(i.content);await ys(e,a.object,n,r,o,s);break}case"blob":break}}var ip=new TextEncoder,Io=new TextDecoder,Qf=65520,ap=new Uint8Array([48,48,48,48]);function Pn(e){let t=typeof e=="string"?ip.encode(e):e,n=4+t.byteLength;if(n>Qf)throw new Error(`pkt-line too long: ${n} bytes (max ${Qf})`);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 Ji(){return ap.slice()}function vo(...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 Dr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=Io.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function To(e){if(e.type==="flush")return"";let t=Io.decode(e.data);return t.endsWith(`
346
+ `)?t.slice(0,-1):t}var cp=1,fp=2,lp=3;function Qi(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case cp:t.push(f),o+=f.byteLength;break;case fp:n.push(Io.decode(f));break;case lp:r.push(Io.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 ea(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ta(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ea(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=Dr(c);return dp(f,t)}function dp(e,t){let n=0,r=e[n];r?.type==="data"&&To(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let m=l.slice(0,d),u=l.slice(d+1);if(!(m===te&&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 up=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function el(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=nl(r,up),c=[];c.push(Pn(`want ${t[0]} ${a.join(" ")}
345
347
  `));for(let u=1;u<t.length;u++)c.push(Pn(`want ${t[u]}
346
348
  `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(Pn(`shallow ${u}
347
349
  `));i?.depth!==void 0&&c.push(Pn(`deepen ${i.depth}
348
- `)),c.push(Xi());for(let u of n)c.push(Pn(`have ${u}
350
+ `)),c.push(Ji());for(let u of n)c.push(Pn(`have ${u}
349
351
  `));c.push(Pn(`done
350
- `));let f=To(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...Ji(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 rp(m,a.includes("side-band-64k"))}function rp(e,t){let n=Ar(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=vo(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}=Zi(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 sp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function el(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=tl(r,sp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Pn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
352
+ `));let f=vo(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ea(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 mp(m,a.includes("side-band-64k"))}function mp(e,t){let n=Dr(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=To(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}=Qi(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 hp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function tl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=nl(r,hp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(Pn(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
351
353
  `));for(let h of f)a.push(Pn(`${h.oldHash} ${h.newHash} ${h.refName}
352
- `));a.push(Xi());let l;if(n&&n.byteLength>0){let h=To(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=To(...a);let d=e.replace(/\/+$/,""),m=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...Ji(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")?op(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function op(e,t){let n,r=[];if(t){let a=Ar(e),{packData:c,progress:f,errors:l}=Zi(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Ar(c)}else n=Ar(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=vo(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 tl(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 bs=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await ge(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await F(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await 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 Vf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await ea(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Us(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==te&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await ea(this.local,n,r);s&&await Us(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===te,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await Rn(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}}},ys=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 Qi(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 Qi(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 Qf(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Us(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==te&&l.newHash!==te&&!l.ok&&!await Rn(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??te,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==te&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==te&&s.push(l.oldHash);let a=null;i&&(a=await ea(this.local,o,s)??null);let c=await el(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 ea(e,t,n,r,o){let s=await vr(e,t,n,r,o);if(s.count===0)return;let i=await Hr(s),c=Io(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await _s(c);return f}async function ip(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 ta(e){return e.startsWith("http://")||e.startsWith("https://")}function nl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function rl(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(ta(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 ap(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 sl(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return ap(n)}async function ol(e,t,n,r){if(ta(t)){let o=rl(t,e.networkPolicy);if(o)throw new Error(o);let s=await sl(e,t,n);return new ys(e,t,s,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(t)??void 0),!r)throw nl(t)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${t}'.`):new Error(`'${t}' does not appear to be a git repository`);return new bs(e,r)}async function Dr(e,t,n){let r=await ip(e,t);if(!r)return null;if(ta(r.url)){let s=rl(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await sl(e,r.url,n):void 0;return{transport:new ys(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await Qn(e.fs,r.url);if(!o){if(nl(r.url))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${r.url}'.`);return null}return{transport:new bs(e,o),config:r}}ve();tt();function il(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:I().describe("Create a bare clone"),branch:J.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:J.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return $("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=s?o:$t(r.cwd,o),a=n.branch,c=n.directory;if(!c){let O=s?o.split("/").pop()??o:Lr(i);O.endsWith(".git")&&(O=O.slice(0,-4)),c=O}let f=$t(r.cwd,c),l=await t?.hooks?.preClone?.({repository:o,targetPath:f,bare:n.bare,branch:a??null});if(ee(l))return L(l.message??"");if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return $(`destination path '${c}' already exists and is not an empty directory.`)}catch{return $(`destination path '${c}' already exists and is not an empty directory.`)}let d=null;if(!s&&(t?.resolveRemote&&(d=await t.resolveRemote(i)),d||(d=await Qn(r.fs,i)),!d))return $(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:m}=await Bs(r.fs,f,{bare:n.bare}),u=t?{...m,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:m,h=await he(u);h['remote "origin"']={url:i,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Ye(u,h);let p;try{p=await ol(u,i,r.env,d??void 0)}catch(O){let H=O instanceof Error?O.message:"";return H.startsWith("network")?$(H):$(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:f,bare:n.bare,branch:a??null}),{stdout:"",stderr:`Cloning into '${c}'...
354
+ `));a.push(Ji());let l;if(n&&n.byteLength>0){let h=vo(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=vo(...a);let d=e.replace(/\/+$/,""),m=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ea(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")?pp(u,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function pp(e,t){let n,r=[];if(t){let a=Dr(e),{packData:c,progress:f,errors:l}=Qi(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Dr(c)}else n=Dr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=To(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 nl(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 Es=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await be(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 Yf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await na(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Us(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==te&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await na(this.local,n,r);s&&await Us(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===te,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await xn(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}}},ks=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 ta(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 ta(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 el(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Us(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==te&&l.newHash!==te&&!l.ok&&!await xn(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??te,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==te&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==te&&s.push(l.oldHash);let a=null;i&&(a=await na(this.local,o,s)??null);let c=await tl(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 na(e,t,n,r,o){let s=await Hr(e,t,n,r,o);if(s.count===0)return;let i=await Ar(s),c=So(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await _s(c);return f}async function gp(e,t){let r=(await ge(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function ra(e){return e.startsWith("http://")||e.startsWith("https://")}function rl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function sl(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(ra(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 wp(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 ol(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return wp(n)}async function il(e,t,n,r){if(ra(t)){let o=sl(t,e.networkPolicy);if(o)throw new Error(o);let s=await ol(e,t,n);return new ks(e,t,s,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(t)??void 0),!r)throw rl(t)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${t}'.`):new Error(`'${t}' does not appear to be a git repository`);return new Es(e,r)}async function Mr(e,t,n){let r=await gp(e,t);if(!r)return null;if(ra(r.url)){let s=sl(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await ol(e,r.url,n):void 0;return{transport:new ks(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await er(e.fs,r.url);if(!o){if(rl(r.url))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${r.url}'.`);return null}return{transport:new Es(e,o),config:r}}He();ot();function al(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:Y.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Y.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return S("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=o;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=vt(r.cwd,o),a=await er(r.fs,c)),!a)return S(`repository '${o}' does not exist`);let f=n.directory;if(!f){let O;s||o.includes("://")?O=o.split("/").pop()??o:O=_r(c),O.endsWith(".git")&&(O=O.slice(0,-4)),f=O}let l=vt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:o,targetPath:l,bare:n.bare,branch:i??null});if(ee(d))return L(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return S(`destination path '${f}' already exists and is not an empty directory.`)}catch{return S(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:m}=await Bs(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}:m,h=await ge(u);h['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Ze(u,h);let p;try{p=await il(u,c,r.env,a??void 0)}catch(O){let A=O instanceof Error?O.message:"";return A.startsWith("network")?S(A):S(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
353
355
  warning: You appear to have cloned an empty repository.
354
- `,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));let x=n.depth,b=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let O=await p.fetch(w,[],b);O.shallowUpdates&&await Tr(u,O.shallowUpdates)}let k=g.find(O=>O.name==="HEAD"),E=null,R=null,C=await Qt(u,r.env),P=`clone: from ${i}`,v=p.headTarget;v?.startsWith("refs/heads/")&&g.some(O=>O.name===v)&&(E=v.slice(11),R=g.find(O=>O.name===v)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let H=O.name.slice(11),G=`refs/remotes/origin/${H}`;await X(u,G,O.hash),await Ke(u,G,{oldHash:te,newHash:O.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P}),!E&&k&&O.hash===k.hash&&(E=H,R=O.hash)}O.name.startsWith("refs/tags/")&&await X(u,O.name,O.hash)}if(a){let O=g.find(H=>H.name===`refs/heads/${a}`);if(!O)return $(`Remote branch '${a}' not found in upstream origin`);E=a,R=O.hash}if(!E){let O=g.find(H=>H.name.startsWith("refs/heads/"));O&&(E=O.name.slice(11),R=O.hash)}if(n.bare)return E&&await ze(u,"HEAD",`refs/heads/${E}`),await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:f,bare:n.bare,branch:E}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
355
- `,exitCode:0};if(E&&await ze(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${E}`),E&&R){await X(u,`refs/heads/${E}`,R),await ze(u,"HEAD",`refs/heads/${E}`);let O={oldHash:te,newHash:R,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P};await Ke(u,`refs/heads/${E}`,O),await Ke(u,"HEAD",O);let H=await he(u);H[`branch "${E}"`]={remote:"origin",merge:`refs/heads/${E}`},await Ye(u,H);let G=await j(u,R);await Uc(u,G.tree);let A=await Ve(u,G.tree),S=Gs(A.map(_=>({path:_.path,mode:parseInt(_.mode,8),hash:_.hash,stage:0,stat:$e()})));await ae(u,S)}let D={stdout:"",stderr:`Cloning into '${c}'...
356
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:f,bare:n.bare,branch:E}),D}})}se();Ce();ie();mn();le();Fe();ue();ve();tt();function cp(e){let t=[],n=[],r=0;for(;r<e.length;){let o=e[r];if(o==="--"){for(;r<e.length;r++)n.push(e[r]);break}if(o==="-m"||o==="--message"){r+1<e.length?(t.push(e[r+1]),r+=2):(n.push(o),r++);continue}if(o.startsWith("--message=")){t.push(o.slice(10)),r++;continue}if(o.startsWith("-")&&!o.startsWith("--")&&o.length>1){let s=o.slice(1),i=s.indexOf("m");if(i!==-1){let a=s.slice(0,i),c=s.slice(i+1);if(a.length>0&&n.push(`-${a}`),c.length>0)t.push(c);else if(r+1<e.length){t.push(e[r+1]),r+=2;continue}r++;continue}}n.push(o),r++}return t.length>0&&n.push("-m",t.join(`
357
-
358
- `)),n}function al(e,t){e.command("commit",{description:"Record changes to the repository",transformArgs:cp,options:{message:J.string().alias("m").describe("Commit message"),file:J.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:I().describe("Allow creating an empty commit"),amend:I().describe("Amend the previous commit"),noEdit:I().describe("Use the previous commit message without editing"),all:I().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return $("options '-m' and '-F' cannot be used together");let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await K(s);if(n.all){let me=Xe(s);if(me)return me;let xe=await Tt(s,i);for(let qe of xe)qe.status==="modified"?i=(await sn(s,i,qe.path)).index:qe.status==="deleted"&&(i=at(i,qe.path));let Ut=new Set(De(i).map(qe=>qe.path)),On=new Set(i.entries.filter(qe=>qe.stage>0&&!Ut.has(qe.path)).map(qe=>qe.path));for(let qe of On){let gr=T(s.workTree,qe);await r.fs.exists(gr)?i=(await sn(s,i,qe)).index:i=at(i,qe)}}let a=await F(s,"MERGE_HEAD"),c=await F(s,"CHERRY_PICK_HEAD"),f=await F(s,"REVERT_HEAD"),d=await Gt(s)?await F(s,"REBASE_HEAD"):null,m=n.amend,u=await Z(s);if(m){if(!u)return $("You have nothing yet to amend.");if(a)return $("You are in the middle of a merge -- cannot amend.");if(c)return $("You are in the middle of a cherry-pick -- cannot amend.")}if(St(i)){let me=new Set,xe=[];for(let Ut of i.entries)Ut.stage>0&&!me.has(Ut.path)&&(me.add(Ut.path),xe.push(`U ${Ut.path}`));return xe.sort(),{stdout:xe.length>0?`${xe.join(`
356
+ `,exitCode:0};let w=[],b=new Set;for(let O of g)O.name!=="HEAD"&&(b.has(O.hash)||(b.add(O.hash),w.push(O.hash)));let x=n.depth,y=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let O=await p.fetch(w,[],y);O.shallowUpdates&&await Tr(u,O.shallowUpdates)}let E=g.find(O=>O.name==="HEAD"),k=null,R=null,C=await Qt(u,r.env),P=`clone: from ${c}`,H=p.headTarget;H?.startsWith("refs/heads/")&&g.some(O=>O.name===H)&&(k=H.slice(11),R=g.find(O=>O.name===H)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let A=O.name.slice(11),G=`refs/remotes/origin/${A}`;await X(u,G,O.hash),await Xe(u,G,{oldHash:te,newHash:O.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P}),!k&&E&&O.hash===E.hash&&(k=A,R=O.hash)}O.name.startsWith("refs/tags/")&&await X(u,O.name,O.hash)}if(i){let O=g.find(A=>A.name===`refs/heads/${i}`);if(!O)return S(`Remote branch '${i}' not found in upstream origin`);k=i,R=O.hash}if(!k){let O=g.find(A=>A.name.startsWith("refs/heads/"));O&&(k=O.name.slice(11),R=O.hash)}if(n.bare)return k&&await Ye(u,"HEAD",`refs/heads/${k}`),await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:l,bare:n.bare,branch:k}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
357
+ `,exitCode:0};if(k&&await Ye(u,"refs/remotes/origin/HEAD",`refs/remotes/origin/${k}`),k&&R){await X(u,`refs/heads/${k}`,R),await Ye(u,"HEAD",`refs/heads/${k}`);let O={oldHash:te,newHash:R,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P};await Xe(u,`refs/heads/${k}`,O),await Xe(u,"HEAD",O);let A=await ge(u);A[`branch "${k}"`]={remote:"origin",merge:`refs/heads/${k}`},await Ze(u,A);let G=await j(u,R);await Bc(u,G.tree);let v=await ze(u,G.tree),T=Gs(v.map(F=>({path:F.path,mode:parseInt(F.mode,8),hash:F.hash,stage:0,stat:Ie()})));await le(u,T)}let D={stdout:"",stderr:`Cloning into '${f}'...
358
+ `,exitCode:0};return await t?.hooks?.postClone?.({repo:u,repository:o,targetPath:l,bare:n.bare,branch:k}),D}})}ce();$e();fe();mn();me();qe();pe();He();ot();function cl(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Y.string().alias("m").repeatable().describe("Commit message"),file:Y.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:$().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 S("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 ie=Je(i);if(ie)return ie;let Pe=await At(i,a);for(let Be of Pe)Be.status==="modified"?a=(await sn(i,a,Be.path)).index:Be.status==="deleted"&&(a=lt(a,Be.path));let nt=new Set(Ge(a).map(Be=>Be.path)),On=new Set(a.entries.filter(Be=>Be.stage>0&&!nt.has(Be.path)).map(Be=>Be.path));for(let Be of On){let wr=I(i.workTree,Be);await r.fs.exists(wr)?a=(await sn(i,a,Be)).index:a=lt(a,Be)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),m=await Nt(i)?await B(i,"REBASE_HEAD"):null,u=n.amend,h=await Z(i);if(u){if(!h)return S("You have nothing yet to amend.");if(c)return S("You are in the middle of a merge -- cannot amend.");if(f)return S("You are in the middle of a cherry-pick -- cannot amend.")}if(Ht(a)){let ie=new Set,Pe=[];for(let nt of a.entries)nt.stage>0&&!ie.has(nt.path)&&(ie.add(nt.path),Pe.push(`U ${nt.path}`));return Pe.sort(),{stdout:Pe.length>0?`${Pe.join(`
359
359
  `)}
360
360
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
361
361
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
362
362
  hint: as appropriate to mark resolution and make a commit.
363
363
  fatal: Exiting because of an unresolved conflict.
364
- `,exitCode:128}}let h=m&&u?await j(s,u):null,p=n.message;if(p!==void 0&&(p=Yt(p),!p))return{stdout:`Aborting commit due to empty commit message.
365
- `,stderr:"",exitCode:1};if(!p&&n.file!==void 0){if(n.file==="-")p=r.stdin;else{let me=n.file.startsWith("/")?n.file:T(r.cwd,n.file);if(!await r.fs.exists(me))return $(`could not read log file '${n.file}': No such file or directory`);let xe=await r.fs.readFile(me);p=typeof xe=="string"?xe:new TextDecoder().decode(xe)}if(p=Yt(p),!p)return{stdout:`Aborting commit due to empty commit message.
366
- `,stderr:"",exitCode:1}}if(!p&&m&&h&&(p=h.message),!p&&(a||c||f||d)){let me=await Pe(s,"SQUASH_MSG");if(me)p=Yt(me);else{let xe=await Pe(s,"MERGE_MSG");xe!==null&&(p=Yt(xe))}}if(!p)return L("error: must provide a commit message with -m or -F");let g=De(i),w=await Ge(s,g),y=await t?.hooks?.preCommit?.({repo:s,index:i,treeHash:w});if(ee(y))return L(y.message??"");let x=n.allowEmpty,b=null;if(m&&h){let me=h.parents[0];me?b=(await j(s,me)).tree:b=await ut("tree",new Uint8Array(0))}else u&&(b=(await j(s,u)).tree);let k=m&&h&&h.parents.length>1;if(!x&&!a&&!k){if(!u&&!m&&g.length===0)return{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1};if(b!==null&&b===w){if(m){let me=h?.parents[0]??null;return{stdout:`${await rt(s,{fromCommit:!0,compareHash:me,noWarn:!0,index:i})}No changes
364
+ `,exitCode:128}}let p=u&&h?await j(i,h):null,g=o.length>0?o.join(`
365
+
366
+ `):void 0;if(g!==void 0&&(g=Yt(g),!g))return{stdout:`Aborting commit due to empty commit message.
367
+ `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ie=n.file.startsWith("/")?n.file:I(r.cwd,n.file);if(!await r.fs.exists(ie))return S(`could not read log file '${n.file}': No such file or directory`);let Pe=await r.fs.readFile(ie);g=typeof Pe=="string"?Pe:new TextDecoder().decode(Pe)}if(g=Yt(g),!g)return{stdout:`Aborting commit due to empty commit message.
368
+ `,stderr:"",exitCode:1}}if(!g&&u&&p&&(g=p.message),!g&&(c||f||l||m)){let ie=await Oe(i,"SQUASH_MSG");if(ie)g=Yt(ie);else{let Pe=await Oe(i,"MERGE_MSG");Pe!==null&&(g=Yt(Pe))}}if(!g)return L("error: must provide a commit message with -m or -F");let w=Ge(a),b=await Fe(i,w),x=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(ee(x))return L(x.message??"");let y=n.allowEmpty,E=null;if(u&&p){let ie=p.parents[0];ie?E=(await j(i,ie)).tree:E=await pt("tree",new Uint8Array(0))}else h&&(E=(await j(i,h)).tree);let k=u&&p&&p.parents.length>1;if(!y&&!c&&!k){if(!h&&!u&&w.length===0)return{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(E!==null&&E===b){if(u){let ie=p?.parents[0]??null;return{stdout:`${await at(i,{fromCommit:!0,compareHash:ie,noWarn:!0,index:a})}No changes
367
369
  `,stderr:`You asked to amend the most recent commit, but doing so would make
368
370
  it empty. You can repeat your command with --allow-empty, or you can
369
371
  remove the commit entirely with "git reset HEAD^".
370
- `,exitCode:1}}return c?{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
372
+ `,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.
371
373
  If you wish to commit it anyway, use:
372
374
 
373
375
  git commit --allow-empty
374
376
 
375
377
  Otherwise, please use 'git cherry-pick --skip'
376
- `,exitCode:1}:{stdout:await rt(s,{fromCommit:!0,index:i}),stderr:"",exitCode:1}}}let E=await an(s,r.env);if(M(E))return E;let R=await Qe(s,r.env);if(M(R))return R;m&&h&&(E.name=h.author.name,E.email=h.author.email,E.timestamp=h.author.timestamp,E.timezone=h.author.timezone),c&&(E=(await j(s,c)).author);let C=At(p),P={repo:s,message:C},v=await t?.hooks?.commitMsg?.(P);if(ee(v))return L(v.message??"");C=P.message;let D;m&&h?D=[...h.parents]:(D=u?[u]:[],a&&D.push(a));let O=nn({type:"commit",tree:w,parents:D,author:E,committer:R,message:C}),H=await Se(s,"commit",O);await ae(s,i);let G=await Q(s);G&&G.type==="symbolic"?await X(s,G.target,H):await X(s,"HEAD",H);let A=fe(C),S;m?S="commit (amend)":a?S="commit (merge)":c?S="commit (cherry-pick)":u?S="commit":S="commit (initial)";let _=`${S}: ${A}`,B=G?.type==="symbolic"?G.target:"HEAD";await re(s,r.env,B,u,H,_,G?.type==="symbolic"),a&&await is(s),c&&await Mt(s),f&&await jt(s),d&&await pe(s,"MERGE_MSG"),await pe(s,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:s,hash:H,message:C,branch:G?.type==="symbolic"?Re(G.target):null,parents:D,author:E});let z=G?.type==="symbolic"?G.target:null,N=z?Re(z):"detached HEAD",U;if(m&&h){let me=h.parents[0];U=me?(await j(s,me)).tree:null}else U=u?(await j(s,u)).tree:null;let V=E.timestamp!==R.timestamp||E.timezone!==R.timezone,be=D.length>1,Le=await fn(s,U,w,E,R,V,be);return{stdout:`${Ht(N,H,p,D.length===0&&!m)}
377
- ${Le}`,stderr:"",exitCode:0}}})}se();_e();le();function Cn(e){let t=e.split(".");return t.length===2||t.length===3}function fp(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 dl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:I().alias("l").describe("List all config entries"),get:I().describe("Get the value for a given key"),unset:I().describe("Remove a config key"),"get-all":I().describe("Get all values for a multi-valued key"),add:I().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return ll(s);if(n.get){let f=a;return f?Cn(f)?na(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(n["get-all"]){let f=a;return f?Cn(f)?cl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?L("error: missing key and/or value",2):Cn(f)?(await Ga(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Cn(f)?fl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="list")return ll(s);if(a==="get"){let f=i[1];return f?Cn(f)?na(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Cn(f)?cl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?L("error: missing key and/or value",2):Cn(f)?(await Qo(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Cn(f)?fl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(!a)return L("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Cn(a))return L(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await Qo(s,a,c),{stdout:"",stderr:"",exitCode:0}):na(s,a)}})}async function na(e,t){let n=await ke(e,t);return n===void 0?L(""):{stdout:`${n}
378
- `,stderr:"",exitCode:0}}async function cl(e,t){let n=await ja(e,t);return n.length===0?L(""):{stdout:`${n.join(`
378
+ `,exitCode:1}:{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let R=await an(i,r.env);if(M(R))return R;let C=await tt(i,r.env);if(M(C))return C;u&&p&&(R.name=p.author.name,R.email=p.author.email,R.timestamp=p.author.timestamp,R.timezone=p.author.timezone),f&&(R=(await j(i,f)).author);let P=Mt(g),H={repo:i,message:P},D=await t?.hooks?.commitMsg?.(H);if(ee(D))return L(D.message??"");P=H.message;let O;u&&p?O=[...p.parents]:(O=h?[h]:[],c&&O.push(c));let A=nn({type:"commit",tree:b,parents:O,author:R,committer:C,message:P}),G=await Te(i,"commit",A);await le(i,a);let v=await Q(i);v&&v.type==="symbolic"?await X(i,v.target,G):await X(i,"HEAD",G);let T=ue(P),F;u?F="commit (amend)":c?F="commit (merge)":f?F="commit (cherry-pick)":h?F="commit":F="commit (initial)";let _=`${F}: ${T}`,U=v?.type==="symbolic"?v.target:"HEAD";await ae(i,r.env,U,h,G,_,v?.type==="symbolic"),c&&await cs(i),f&&await Gt(i),l&&await Lt(i),m&&await we(i,"MERGE_MSG"),await we(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:G,message:P,branch:v?.type==="symbolic"?Ce(v.target):null,parents:O,author:R});let N=v?.type==="symbolic"?v.target:null,K=N?Ce(N):"detached HEAD",ne;if(u&&p){let ie=p.parents[0];ne=ie?(await j(i,ie)).tree:null}else ne=h?(await j(i,h)).tree:null;let J=R.timestamp!==C.timestamp||R.timezone!==C.timezone,re=O.length>1,ke=await fn(i,ne,b,R,C,J,re);return{stdout:`${Dt(K,G,g,O.length===0&&!u)}
379
+ ${ke}`,stderr:"",exitCode:0}}})}ce();We();me();function $n(e){let t=e.split(".");return t.length===2||t.length===3}function bp(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 ul(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 dl(s);if(n.get){let f=a;return f?$n(f)?sa(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(n["get-all"]){let f=a;return f?$n(f)?fl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?L("error: missing key and/or value",2):$n(f)?(await La(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?$n(f)?ll(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="list")return dl(s);if(a==="get"){let f=i[1];return f?$n(f)?sa(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?$n(f)?fl(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?L("error: missing key and/or value",2):$n(f)?(await ti(s,f,l),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?$n(f)?ll(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(!a)return L("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!$n(a))return L(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ti(s,a,c),{stdout:"",stderr:"",exitCode:0}):sa(s,a)}})}async function sa(e,t){let n=await xe(e,t);return n===void 0?L(""):{stdout:`${n}
380
+ `,stderr:"",exitCode:0}}async function fl(e,t){let n=await Ga(e,t);return n.length===0?L(""):{stdout:`${n.join(`
379
381
  `)}
380
- `,stderr:"",exitCode:0}}async function fl(e,t){return await La(e,t)?{stdout:"",stderr:"",exitCode:0}:L("",5)}async function ll(e){let t=T(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Yo(n),o=fp(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(`
382
+ `,stderr:"",exitCode:0}}async function ll(e,t){return await Na(e,t)?{stdout:"",stderr:"",exitCode:0}:L("",5)}async function dl(e){let t=I(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Zo(n),o=bp(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(`
381
383
  `)}
382
- `:"",stderr:"",exitCode:0}}se();function Ho(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(y=>y?Y(y):"0000000"),c=o?Y(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(y=>y===null),d=!f&&n.some(y=>y!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let y=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${y}`)}else{let y=r.map(k=>k||"000000"),x=s||"000000";y.some(k=>k!==x)&&i.push(`mode ${y.join(",")}..${x}`)}let m=n.some(y=>y!==null);if(i.push(m?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
384
+ `:"",stderr:"",exitCode:0}}ce();function Ho(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?V(b):"0000000"),c=o?V(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(x=>x||"000000").join(",");i.push(`deleted file mode ${b}`)}else{let b=r.map(E=>E||"000000"),x=s||"000000";b.some(E=>E!==x)&&i.push(`mode ${b.join(",")}..${x}`)}let m=n.some(b=>b!==null);if(i.push(m?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
383
385
  `)}
384
- `;let u=e.parentContents.map(y=>y.length>0?Lt(y):[]),h=e.resultContent.length>0?Lt(e.resultContent):[],p=u.map(y=>st(y,h)),g=lp(u,h,p),w=up(g,u.length,h);if(w.length===0)return"";for(let y of w)i.push(y);return`${i.join(`
386
+ `;let u=e.parentContents.map(b=>b.length>0?_t(b):[]),h=e.resultContent.length>0?_t(e.resultContent):[],p=u.map(b=>ct(b,h)),g=yp(u,h,p),w=kp(g,u.length,h);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
385
387
  `)}
386
- `}function lp(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=dp(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 dp(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=st(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 up(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 k=d.filter(E=>(E.parentLineNos[b]??0)>0||E.columns[b]==="-");if(k.length===0)m.push({start:1,count:0});else{let R=k.find(C=>(C.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;m.push({start:R,count:k.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 k=n[b];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let y=m.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${y.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of d)f.push(`${b.columns.join("")}${b.text}`)}return f}se();Ce();ie();le();function Ao(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}er();ue();ve();tt();var ra=new TextDecoder;function pl(e){return"exitCode"in e}function hr(e){return e.toString(8).padStart(6,"0")}function gl(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 wl(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[q.string().name("commits").variadic().optional()],options:{cached:I().describe("Show staged changes (index vs HEAD)"),staged:I().describe("Synonym for --cached"),stat:I().describe("Show diffstat summary"),nameOnly:I().describe("Show only names of changed files"),nameStatus:I().describe("Show names and status of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file")},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=mt(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(p=>Ue(p,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",m,u=c.length===1?Ao(c[0]):null;if(u){if(a)return $("too many arguments");u.type==="three-dot"?m=await gp(i,u.left,u.right,l):m=await hl(i,u.left,u.right,l)}else if(c.length===2)m=await hl(i,c[0],c[1],l);else{if(c.length>2)return $("too many arguments");a?m=await pp(i,c.length===1?c[0]:null,l):c.length===1?m=await wp(i,c[0],l):m=await mp(i,l)}if(pl(m))return m;let h=await bp(i,m.items,d);return m.stderr&&(h.stderr=m.stderr),h}})}async function mp(e,t){let n=Xe(e);if(n)return n;let r=await K(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await Tt(e,r);c.sort((l,d)=>Oe(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!ye(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let m=hr(d.mode),u;if(l.status==="modified"&&e.workTree){let h=T(e.workTree,l.path),p=await e.fs.readFileBuffer(h);u=await ut("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&&!ye(t,l))continue;let d=i.get(l),m=a.get(l);await hp(f,e,l,d,m)}return f.sort((l,d)=>{let m=Oe(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 hp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=hr(r.mode),a=hr(o.mode),{exists:c,hash:f}=await ul(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),ml(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=hr(r.mode),{exists:a,hash:c}=await ul(t.fs,s,n);ml(e,n,r.hash,i,a,c)}}async function ul(e,t,n){let r=T(t,n);if(!await e.exists(r))return{exists:!1};let o=await ns(e,r);return{exists:!0,hash:await ut("blob",o)}}function ml(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 pp(e,t,n){let r=null;if(t){let m=await He(e,t);if(M(m))return m;r=m.commit.tree}else{let m=await Z(e);m&&(r=(await j(e,m)).tree)}let o=await ce(e,r),s=await K(e),i=new Set;for(let m of s.entries)m.stage>0&&i.add(m.path);let a=new Map(De(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:hr(u.mode)}):c.push({path:m,status:"added",newHash:u.hash,newMode:hr(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 nt(e,c),d=gl(f,l);for(let m of i)d.push({path:m,status:"U"});return d.sort((m,u)=>Oe(m.path,u.path)),n?{items:d.filter(m=>ye(n,m.path))}:{items:d}}async function hl(e,t,n,r){let o=await He(e,t);if(M(o))return o;let s=await He(e,n);if(M(s))return s;let i=await We(e,o.commit.tree,s.commit.tree);return bl(e,i,r)}async function gp(e,t,n,r){let o=await He(e,t);if(M(o))return o;let s=await He(e,n);if(M(s))return s;let i=await _t(e,o.hash,s.hash);if(i.length===0)return $(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
387
- `);let c=i[0],f=await j(e,c),l=await We(e,f.tree,s.commit.tree),d=await bl(e,l,r);return pl(d)||a&&(d.stderr=a),d}async function bl(e,t,n){let{remaining:r,renames:o}=await nt(e,t),s=gl(r,o);return s.sort((i,a)=>Oe(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function wp(e,t,n){let r=Xe(e);if(r)return r;let o=await He(e,t);if(M(o))return o;let s=e.workTree,i=await ce(e,o.commit.tree),a=await K(e),c=new Map(De(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!ye(n,l))continue;let m=T(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 ut("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&&!ye(n,l))continue;let m=T(s,l);if(!await e.fs.exists(m))continue;let u=await e.fs.readFileBuffer(m),h=await ut("blob",u);f.push({path:l,status:"A",newHash:h,newMode:hr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Oe(l.path,d.path)),{items:f}}async function bp(e,t,n){let r;switch(n){case"stat":r=await Pp(e,t);break;case"shortstat":r=await Cp(e,t);break;case"numstat":r=await xp(e,t);break;case"name-only":r=kp(t);break;case"name-status":r=Rp(t);break;default:r=await yp(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function yp(e,t){let n="",r=new Set,o=await Ep(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let i=await Promise.all(s.combinedParentHashes.map(async f=>f?await oe(e,f):"")),a=await sa(e,s);if(i.some(f=>Ie(f))||Ie(a)){let f=s.combinedParentHashes.map(l=>l?Y(l):"0000000");n+=`diff --cc ${s.path}
388
- index ${f.join(",")}..0000000
388
+ `}function yp(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=Ep(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 Ep(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 kp(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 y=0;y<t;y++){let E=d.filter(k=>(k.parentLineNos[y]??0)>0||k.columns[y]==="-");if(E.length===0)m.push({start:1,count:0});else{let R=E.find(C=>(C.parentLineNos[y]??0)>0)?.parentLineNos[y]??1;m.push({start:R,count:E.length})}}let u=d.filter(y=>y.resultLineNo>0),h=u[0],p=h?h.resultLineNo:1,g=u.length,w="";for(let y=p-2;y>=0;y--){let E=n[y];if(E&&/^[a-zA-Z$_]/.test(E)){w=` ${E.trimEnd().slice(0,79)}`;break}}let b=m.map(y=>`-${y.start},${y.count}`),x=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let y of d)f.push(`${y.columns.join("")}${y.text}`)}return f}ce();$e();fe();me();function Ao(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}tr();pe();He();ot();var oa=new TextDecoder;function gl(e){return"exitCode"in e}function pr(e){return e.toString(8).padStart(6,"0")}function wl(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 bl(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:Y.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?Ao(c[0]):null;if(u){if(a)return S("too many arguments");u.type==="three-dot"?m=await Pp(i,u.left,u.right,l):m=await pl(i,u.left,u.right,l)}else if(c.length===2)m=await pl(i,c[0],c[1],l);else{if(c.length>2)return S("too many arguments");a?m=await Cp(i,c.length===1?c[0]:null,l):c.length===1?m=await $p(i,c[0],l):m=await Rp(i,l)}if(gl(m))return m;let h=n.unified,p=await Op(i,m.items,d,h);return m.stderr&&(p.stderr=m.stderr),p}})}async function Rp(e,t){let n=Je(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 At(e,r);c.sort((l,d)=>Se(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!ye(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let m=pr(d.mode),u;if(l.status==="modified"&&e.workTree){let h=I(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&&!ye(t,l))continue;let d=i.get(l),m=a.get(l);await xp(f,e,l,d,m)}return f.sort((l,d)=>{let m=Se(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 xp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=pr(r.mode),a=pr(o.mode),{exists:c,hash:f}=await ml(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),hl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=pr(r.mode),{exists:a,hash:c}=await ml(t.fs,s,n);hl(e,n,r.hash,i,a,c)}}async function ml(e,t,n){let r=I(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 hl(e,t,n,r,o,s){o&&s&&s!==n?e.push({path:t,status:"M",oldHash:n,newHash:s,oldMode:r,newMode:r,newFromWorkTree:!0}):o||e.push({path:t,status:"D",oldHash:n,oldMode:r})}async function Cp(e,t,n){let r=null;if(t){let m=await De(e,t);if(M(m))return m;r=m.commit.tree}else{let m=await Z(e);m&&(r=(await j(e,m)).tree)}let o=await de(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(Ge(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:pr(u.mode)}):c.push({path:m,status:"added",newHash:u.hash,newMode:pr(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=wl(f,l);for(let m of i)d.push({path:m,status:"U"});return d.sort((m,u)=>Se(m.path,u.path)),n?{items:d.filter(m=>ye(n,m.path))}:{items:d}}async function pl(e,t,n,r){let o=await De(e,t);if(M(o))return o;let s=await De(e,n);if(M(s))return s;let i=await Ve(e,o.commit.tree,s.commit.tree);return yl(e,i,r)}async function Pp(e,t,n,r){let o=await De(e,t);if(M(o))return o;let s=await De(e,n);if(M(s))return s;let i=await Ft(e,o.hash,s.hash);if(i.length===0)return S(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
389
+ `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await yl(e,l,r);return gl(d)||a&&(d.stderr=a),d}async function yl(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=wl(r,o);return s.sort((i,a)=>Se(i.path,a.path)),n?{items:s.filter(i=>ye(n,i.path))}:{items:s}}async function $p(e,t,n){let r=Je(e);if(r)return r;let o=await De(e,t);if(M(o))return o;let s=e.workTree,i=await de(e,o.commit.tree),a=await z(e),c=new Map(Ge(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!ye(n,l))continue;let m=I(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&&!ye(n,l))continue;let m=I(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:pr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Se(l.path,d.path)),{items:f}}async function Op(e,t,n,r){let o;switch(n){case"stat":o=await Ap(e,t);break;case"shortstat":o=await Dp(e,t);break;case"numstat":o=await Hp(e,t);break;case"name-only":o=vp(t);break;case"name-status":o=Tp(t);break;default:o=await Sp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Sp(e,t,n){let r="",o=new Set,s=await Ip(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 oe(e,l):"")),c=await ia(e,i);if(a.some(l=>ve(l))||ve(c)){let l=i.combinedParentHashes.map(d=>d?V(d):"0000000");r+=`diff --cc ${i.path}
390
+ index ${l.join(",")}..0000000
389
391
  Binary files differ
390
- `,r.add(s.path)}else{let f=Ho({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:i,resultHash:null,resultMode:s.newMode??null,resultContent:a});f?(n+=f,r.add(s.path)):n+=`* Unmerged path ${s.path}
391
- `}}else n+=`* Unmerged path ${s.path}
392
- `;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let i=s.oldHash?await oe(e,s.oldHash):"",a=await sa(e,s);s.status==="R"&&s.oldPath?n+=Pt({path:s.oldPath,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:Do(s.oldHash,o),newHash:Do(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=Pt({path:s.path,oldContent:i,newContent:a,oldMode:s.oldMode,newMode:s.newMode,oldHash:Do(s.oldHash,o),newHash:Do(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function Ep(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=T(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 Do(e,t){if(e)return e.length!==40?e:t.get(e)??Y(e)}function kp(e){let t="";for(let n of e)t+=`${n.path}
393
- `;return t}function Rp(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}
392
+ `,o.add(i.path)}else{let l=Ho({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}
393
+ `}}else r+=`* Unmerged path ${i.path}
394
+ `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await oe(e,i.oldHash):"",c=await ia(e,i);i.status==="R"&&i.oldPath?r+=Ot({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Do(i.oldHash,s),newHash:Do(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=Ot({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Do(i.oldHash,s),newHash:Do(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Ip(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=I(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 Do(e,t){if(e)return e.length!==40?e:t.get(e)??V(e)}function vp(e){let t="";for(let n of e)t+=`${n.path}
395
+ `;return t}function Tp(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}
394
396
  `}else t+=`${n.status} ${n.path}
395
- `;return t}async function xp(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
396
- `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await sa(e,r),i=Ie(o)||Ie(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=yl(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=cn(r.oldPath,r.path);n+=`${a} ${c} ${f}
397
+ `;return t}async function Hp(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
398
+ `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await ia(e,r),i=ve(o)||ve(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=El(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=cn(r.oldPath,r.path);n+=`${a} ${c} ${f}
397
399
  `}else n+=`${a} ${c} ${r.path}
398
- `}return n}async function Pp(e,t){let n=await El(e,t);return dr(n)}async function Cp(e,t){let n=await El(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}
400
+ `}return n}async function Ap(e,t){let n=await kl(e,t);return ur(n)}async function Dp(e,t){let n=await kl(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=Kn(s,r,o);return i?`${i}
399
401
  `:n.some(a=>a.isUnmerged)?` 0 files changed
400
- `:""}async function sa(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path),r=await ns(e.fs,n);return ra.decode(r)}return oe(e,t.newHash)}async function Op(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=T(e.workTree,t.path);return ns(e.fs,n)}return kt(e,t.newHash)}function yl(e,t){let n=bt(e),r=bt(t),o=st(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 El(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?cn(r.oldPath,r.path):r.path,s=r.oldHash?await kt(e,r.oldHash):new Uint8Array(0),i=await Op(e,r);if(vn(s)||vn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=ra.decode(s),c=ra.decode(i),{ins:f,del:l}=yl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}se();_e();$n();le();Fe();ue();function pr(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 $p(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 Mo(e,t){if(!$p(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 Rl(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:I().describe("Fetch from all remotes"),prune:I().alias("p").describe("Remove stale remote-tracking refs"),tags:I().describe("Also fetch tags"),depth:J.number().describe("Limit fetching to the specified number of commits"),unshallow:I().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return $("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Co(s))return $("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=ps),n.all){if(n.remote)return $("fetch --all does not take a remote argument");let c=await he(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 kl(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 kl(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function kl(e,t,n,r,o,s,i,a){let c;try{c=await Dr(e,t,s)}catch(H){let G=H instanceof Error?H.message:"";if(G.startsWith("network"))return $(G);throw H}if(!c)return $(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d;n&&n.length>0?d=n.map(pr):d=[pr(l.fetchRefspec)];let m=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(H=>`${H.src}:${H.dst}`),prune:r,tags:o});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let u=await f.advertiseRefs();if(u.length===0)return{stdout:"",stderr:"",exitCode:0};let p=(await ge(e)).map(H=>H.hash),g=await F(e,"HEAD");g&&p.push(g);let w=[],y=new Set,x=[];for(let H of u)if(H.name!=="HEAD")for(let G of d){let A=Mo(G,H.name);if(A!==null){x.push({remote:H,localRef:A,force:G.force}),y.has(H.hash)||(y.add(H.hash),w.push(H.hash));break}}if(o)for(let H of u)H.name.startsWith("refs/tags/")&&(x.push({remote:H,localRef:H.name,force:!1}),y.has(H.hash)||(y.add(H.hash),w.push(H.hash)));let b=new Set(p),k=w.filter(H=>!b.has(H)),E,R=a!==void 0?await Sr(e):void 0;a!==void 0&&(E={depth:a,existingShallows:R});let C=k.length>0?k:E?w:[];if(C.length>0){let H=await f.fetch(C,p,E);H.shallowUpdates&&await Tr(e,H.shallowUpdates,R)}let P=await Qt(e,s),v=[];v.push(`From ${l.url}
401
- `);for(let H of x){let G=await F(e,H.localRef);await X(e,H.localRef,H.remote.hash),await Ke(e,H.localRef,{oldHash:G??te,newHash:H.remote.hash,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:G?"fetch":"fetch: storing head"});let A=jo(H.remote.name),S=jo(H.localRef);if(G){if(G!==H.remote.hash){let _=Y(G),B=Y(H.remote.hash);v.push(` ${_}..${B} ${A} -> ${S}
402
- `)}}else{let B=H.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";v.push(`${B} ${A} -> ${S}
403
- `)}}if(!o)for(let H of u){if(!H.name.startsWith("refs/tags/")||y.has(H.hash))continue;let G=await F(e,H.name),A=H.peeledHash??H.hash;!G&&b.has(A)&&(await X(e,H.name,H.hash),await Ke(e,H.name,{oldHash:te,newHash:H.hash,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:"fetch: storing head"}),v.push(` * [new tag] ${jo(H.name)} -> ${jo(H.name)}
404
- `))}if(r){let H=`refs/remotes/${t}`,G=await ge(e,H),A=new Set(u.filter(S=>S.name.startsWith("refs/heads/")).map(S=>S.name.slice(11)));for(let S of G){let _=S.name.slice(H.length+1);A.has(_)||(await de(e,S.name),v.push(` - [deleted] (none) -> ${t}/${_}
405
- `))}}let D=u.find(H=>H.name==="HEAD");if(D){let H=T(e.gitDir,"FETCH_HEAD"),G=u.find(S=>S.name.startsWith("refs/heads/")&&S.hash===D.hash),A=G?`branch '${G.name.slice(11)}' of`:"of";await e.fs.writeFile(H,`${D.hash} ${A} ${l.url}
406
- `)}let O={stdout:"",stderr:v.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,refsUpdated:x.length}),O}function jo(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}se();Ce();ie();le();Fe();ue();se();Ce();ie();le();Fe();ue();async function xl(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ge(e,"refs");for(let a of r)t.add(a.hash);let o=T(e.gitDir,"logs");await e.fs.exists(o)&&await Pl(e,o,o,t);let s=await K(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await F(e,a);c&&t.add(c)}let i=[];for(let a of t)await Kt(e,a)&&i.push(a);return i}async function Pl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=T(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Pl(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Je(e,c);for(let l of f)l.newHash!==te&&r.add(l.newHash)}}}Fs();Kr();le();async function Ip(e,t){let n=new Set,r=T(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(T(r,i)),c=new zt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Hr(await vr(e,t,[])):(await Hr(await vr(e,t,[]))).filter(s=>!n.has(s.hash))}async function oa(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 Hr(await vr(t,r,[])):await Ip(t,r);if(a.length===0)return null;let c=a.length,f=Io(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 _s(d),h=await yc(m,u),p=m.subarray(m.byteLength-20),g="";for(let E=0;E<20;E++){let R=p[E];g+=(R>>4).toString(16)+(R&15).toString(16)}let w=T(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let y=`pack-${g}`,x=T(w,`${y}.pack`),b=T(w,`${y}.idx`);await n.writeFile(x,m),await n.writeFile(b,h);let k=new Set(f.map(E=>E.hash));if(t.objectStore.invalidatePacks?.(),o){let E=await n.readdir(w);for(let P of E){if(!P.endsWith(".idx"))continue;let v=P.slice(0,-4);if(v===y)continue;let D=T(w,`${v}.idx`),O=!0;try{let H=await n.readFileBuffer(D),G=new zt(H);for(let A of G.allHashes())if(!k.has(A)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(T(w,`${v}.pack`))}catch{}try{await n.rm(D)}catch{}}}let R=T(t.gitDir,"objects"),C;try{C=await n.readdir(R)}catch{C=[]}for(let P of C){if(P==="pack"||P==="info"||P.length!==2)continue;let v=T(R,P),D;try{D=await n.readdir(v)}catch{continue}for(let O of D){let H=`${P}${O}`;k.has(H)&&await n.rm(T(v,O))}try{(await n.readdir(v)).length===0&&await n.rm(v,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function ia(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(`
407
- `)}function Cl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:I().alias("a").describe("Pack all objects, including already-packed"),delete:I().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await xl(s),a=await oa({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${ia(a.totalCount,a.deltaCount)}
402
+ `:""}async function ia(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=I(e.workTree,t.path),r=await ss(e.fs,n);return oa.decode(r)}return oe(e,t.newHash)}async function Mp(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=I(e.workTree,t.path);return ss(e.fs,n)}return Ct(e,t.newHash)}function El(e,t){let n=kt(e),r=kt(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 kl(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?cn(r.oldPath,r.path):r.path,s=r.oldHash?await Ct(e,r.oldHash):new Uint8Array(0),i=await Mp(e,r);if(Hn(s)||Hn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=oa.decode(s),c=oa.decode(i),{ins:f,del:l}=El(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}ce();We();Sn();me();qe();pe();function gr(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 jp(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 Mo(e,t){if(!jp(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 xl(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:Y.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 S("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Po(s))return S("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=ws),n.all){if(n.remote)return S("fetch --all does not take a remote argument");let c=await ge(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 Rl(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 Rl(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function Rl(e,t,n,r,o,s,i,a){let c;try{c=await Mr(e,t,s)}catch(A){let G=A instanceof Error?A.message:"";if(G.startsWith("network"))return S(G);throw A}if(!c)return S(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d;n&&n.length>0?d=n.map(gr):d=[gr(l.fetchRefspec)];let m=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(A=>`${A.src}:${A.dst}`),prune:r,tags:o});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let u=await f.advertiseRefs();if(u.length===0)return{stdout:"",stderr:"",exitCode:0};let p=(await be(e)).map(A=>A.hash),g=await B(e,"HEAD");g&&p.push(g);let w=[],b=new Set,x=[];for(let A of u)if(A.name!=="HEAD")for(let G of d){let v=Mo(G,A.name);if(v!==null){x.push({remote:A,localRef:v,force:G.force}),b.has(A.hash)||(b.add(A.hash),w.push(A.hash));break}}if(o)for(let A of u)A.name.startsWith("refs/tags/")&&(x.push({remote:A,localRef:A.name,force:!1}),b.has(A.hash)||(b.add(A.hash),w.push(A.hash)));let y=new Set(p),E=w.filter(A=>!y.has(A)),k,R=a!==void 0?await vr(e):void 0;a!==void 0&&(k={depth:a,existingShallows:R});let C=E.length>0?E:k?w:[];if(C.length>0){let A=await f.fetch(C,p,k);A.shallowUpdates&&await Tr(e,A.shallowUpdates,R)}let P=await Qt(e,s),H=[];H.push(`From ${l.url}
403
+ `);for(let A of x){let G=await B(e,A.localRef);await X(e,A.localRef,A.remote.hash),await Xe(e,A.localRef,{oldHash:G??te,newHash:A.remote.hash,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:G?"fetch":"fetch: storing head"});let v=jo(A.remote.name),T=jo(A.localRef);if(G){if(G!==A.remote.hash){let F=V(G),_=V(A.remote.hash);H.push(` ${F}..${_} ${v} -> ${T}
404
+ `)}}else{let _=A.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";H.push(`${_} ${v} -> ${T}
405
+ `)}}if(!o)for(let A of u){if(!A.name.startsWith("refs/tags/")||b.has(A.hash))continue;let G=await B(e,A.name),v=A.peeledHash??A.hash;!G&&y.has(v)&&(await X(e,A.name,A.hash),await Xe(e,A.name,{oldHash:te,newHash:A.hash,name:P.name,email:P.email,timestamp:P.timestamp,tz:P.tz,message:"fetch: storing head"}),H.push(` * [new tag] ${jo(A.name)} -> ${jo(A.name)}
406
+ `))}if(r){let A=`refs/remotes/${t}`,G=await be(e,A),v=new Set(u.filter(T=>T.name.startsWith("refs/heads/")).map(T=>T.name.slice(11)));for(let T of G){let F=T.name.slice(A.length+1);v.has(F)||(await he(e,T.name),H.push(` - [deleted] (none) -> ${t}/${F}
407
+ `))}}let D=u.find(A=>A.name==="HEAD");if(D){let A=I(e.gitDir,"FETCH_HEAD"),G=u.find(T=>T.name.startsWith("refs/heads/")&&T.hash===D.hash),v=G?`branch '${G.name.slice(11)}' of`:"of";await e.fs.writeFile(A,`${D.hash} ${v} ${l.url}
408
+ `)}let O={stdout:"",stderr:H.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,refsUpdated:x.length}),O}function jo(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}ce();$e();fe();me();qe();pe();ce();$e();fe();me();qe();pe();async function Cl(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await be(e,"refs");for(let a of r)t.add(a.hash);let o=I(e.gitDir,"logs");await e.fs.exists(o)&&await Pl(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 Kt(e,a)&&i.push(a);return i}async function Pl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=I(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Pl(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await et(e,c);for(let l of f)l.newHash!==te&&r.add(l.newHash)}}}Fs();Yr();me();async function Gp(e,t){let n=new Set,r=I(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(I(r,i)),c=new zt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Ar(await Hr(e,t,[])):(await Ar(await Hr(e,t,[]))).filter(s=>!n.has(s.hash))}async function aa(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 Ar(await Hr(t,r,[])):await Gp(t,r);if(a.length===0)return null;let c=a.length,f=So(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:m,entries:u}=await _s(d),h=await Ec(m,u),p=m.subarray(m.byteLength-20),g="";for(let k=0;k<20;k++){let R=p[k];g+=(R>>4).toString(16)+(R&15).toString(16)}let w=I(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let b=`pack-${g}`,x=I(w,`${b}.pack`),y=I(w,`${b}.idx`);await n.writeFile(x,m),await n.writeFile(y,h);let E=new Set(f.map(k=>k.hash));if(t.objectStore.invalidatePacks?.(),o){let k=await n.readdir(w);for(let P of k){if(!P.endsWith(".idx"))continue;let H=P.slice(0,-4);if(H===b)continue;let D=I(w,`${H}.idx`),O=!0;try{let A=await n.readFileBuffer(D),G=new zt(A);for(let v of G.allHashes())if(!E.has(v)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(I(w,`${H}.pack`))}catch{}try{await n.rm(D)}catch{}}}let R=I(t.gitDir,"objects"),C;try{C=await n.readdir(R)}catch{C=[]}for(let P of C){if(P==="pack"||P==="info"||P.length!==2)continue;let H=I(R,P),D;try{D=await n.readdir(H)}catch{continue}for(let O of D){let A=`${P}${O}`;E.has(A)&&await n.rm(I(H,O))}try{(await n.readdir(H)).length===0&&await n.rm(H,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function ca(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(`
409
+ `)}function $l(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 Cl(s),a=await aa({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${ca(a.totalCount,a.deltaCount)}
408
410
  `,exitCode:0}:{stdout:`Nothing new to pack.
409
- `,stderr:"",exitCode:0}}})}function Ol(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:I().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;await Sc(s),await pt(s);let i=await Tp(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await oa({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:`${ia(f.totalCount,f.deltaCount,!0)}
410
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Sp=2160*60*60;async function Tp(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ge(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Sp,i=T(e.gitDir,"logs");await e.fs.exists(i)&&await $l(e,i,i,s,t);let a=await K(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let l=await F(e,f);l&&t.add(l)}let c=[];for(let f of t)await Kt(e,f)&&c.push(f);return c}async function $l(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=T(t,i),c=await e.fs.stat(a);if(c.isDirectory){await $l(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),l=await Je(e,f);if(f==="refs/stash"){for(let m of l)m.newHash!==te&&o.add(m.newHash);continue}let d=l.filter(m=>m.timestamp>=r);await Mn(e,f,d);for(let m of d)m.newHash!==te&&o.add(m.newHash)}}}async function vp(e,t){let n=T(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(T(n,o),{recursive:!0})}catch{}}le();Dn();function Il(e){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:I().describe("Create a bare repository"),initialBranch:J.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(t,n)=>{let r=t.initialBranch,o=t.directory?$t(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:i}=await Bs(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),a="";i&&r&&(a=`warning: re-init: ignored --initial-branch=${r}
411
- `);let c=t.bare?"bare ":"";return{stdout:`${i?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
412
- `,stderr:a,exitCode:0}}})}se();ir();var Go=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:Sl(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,Sl(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 Sl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}se();function Es(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+=Np(c.timestamp,c.timezone),s+=3;continue;case"i":o+=_p(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Nt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=Up(c.timestamp,c.timezone),s+=3;continue;case"r":o+=Fp(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=Y(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=Y(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(Y).join(" "),s+=2;continue;case"s":o+=aa(r.message),s+=2;continue;case"b":o+=Hp(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+=`
413
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var aa=fe;function Hp(e){let t=e.indexOf(`
414
-
415
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Lo(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 ks(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?Y(o):o,c=aa(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Y).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${aa(s.message)}`),a.join(`
416
- `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Y).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
411
+ `,stderr:"",exitCode:0}}})}function Ol(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 vc(s),await bt(s);let i=await Np(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await aa({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await _p(s.gitDir,r.fs),f)return{stdout:"",stderr:`${ca(f.totalCount,f.deltaCount,!0)}
412
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Lp=2160*60*60;async function Np(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await be(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Lp,i=I(e.gitDir,"logs");await e.fs.exists(i)&&await Sl(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 Kt(e,f)&&c.push(f);return c}async function Sl(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=I(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Sl(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!==te&&o.add(m.newHash);continue}let d=l.filter(m=>m.timestamp>=r);await jn(e,f,d);for(let m of d)m.newHash!==te&&o.add(m.newHash)}}}async function _p(e,t){let n=I(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(I(n,o),{recursive:!0})}catch{}}ce();function Fp(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 Il(e,t,n,r){if(Fp(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
413
+ `);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 Up(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vl(e,t){let n=t?.fixed?Up(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}$e();fe();me();He();async function Bp(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=I(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function Wp(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:()=>oe(e,s)})}return r}async function qp(e,t){return(await ze(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>oe(e,r.hash)}))}function zp(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Kp(e,t,n){return n||t===""?e:rt(t,e)}function Tl(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:Y.number().describe("Descend at most <n> levels of directories"),maxCount:Y.number().alias("m").describe("Maximum number of matches per file"),afterContext:Y.number().alias("A").describe("Show <n> lines after match"),beforeContext:Y.number().alias("B").describe("Show <n> lines before match"),context:Y.number().alias("C").describe("Show <n> lines before and after match"),heading:$().describe("Show filename above matches"),break:$().describe("Print empty line between results from different files"),pattern:Y.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return S("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let m=[];for(let U of f){let N=vl(U,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!N)return S(`command line, '${U}': invalid regular expression`);m.push(N)}let u=[];if(l.length>0)for(let U of l){let N=await gt(i,U);if(M(N))return N;let K;try{K=await Le(i,N)}catch{return S(`bad revision '${U}'`)}let ne=await j(i,K),J=await qp(i,ne.tree);u.push({prefix:`${U}:`,files:J})}else if(n.cached)u.push({prefix:"",files:await Wp(i)});else{if(!i.workTree)return S("this operation must be run in a work tree");u.push({prefix:"",files:await Bp(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,b=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),x=!!n.filesWithMatches,y=!!n.filesWithoutMatch,E=!!n.count,k=!!n.quiet,R=!!n.heading,C=!!n.break,P=!!n.suppressFilename,H=!!n.invertMatch,D=!!n.allMatch,O=n.context??n.afterContext??0,A=n.context??n.beforeContext??0,G=O>0||A>0,v=[],T=!1,F=!0;for(let U of u){let N=U.files.slice().sort((K,ne)=>K.path<ne.path?-1:K.path>ne.path?1:0);for(let K of N){if(p&&!ye(p,K.path)||g!==void 0&&zp(K.path)>g)continue;let ne=await K.getContent(),J=Il(ne,m,D,H),re=Kp(K.path,h,!!n.fullName),ke=U.prefix;if(J.binary){if(T=!0,k)return{stdout:"",stderr:"",exitCode:0};x?v.push(`${ke}${re}`):!y&&!E&&v.push(`Binary file ${ke}${re} matches`);continue}if(J.matches.length===0){y&&v.push(`${ke}${re}`);continue}if(T=!0,k)return{stdout:"",stderr:"",exitCode:0};if(y)continue;if(x){v.push(`${ke}${re}`);continue}if(E){let ie=w!==void 0?Math.min(J.matches.length,w):J.matches.length;v.push(`${ke}${re}:${ie}`);continue}let Me=J.matches;if(w!==void 0&&(Me=Me.slice(0,w)),G)Vp(v,ne,Me,ke,re,P,A,O,R,C,F);else if(R){!F&&C&&v.push(""),v.push(`${ke}${re}`);for(let ie of Me)b?v.push(`${ie.lineNo}:${ie.line}`):v.push(ie.line)}else{!F&&C&&v.push("");for(let ie of Me){let Pe=P?"":`${ke}${re}:`;b?v.push(`${Pe}${ie.lineNo}:${ie.line}`):v.push(`${Pe}${ie.line}`)}}F=!1}}return k?{stdout:"",stderr:"",exitCode:T?0:1}:{stdout:v.length>0?`${v.join(`
414
+ `)}
415
+ `:"",stderr:"",exitCode:T?0:1}}})}function Vp(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
416
+ `);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),b=Math.min(d.length,g.lineNo+a);u.push([w,b])}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,b]=h[g];for(let x=w;x<=b;x++){let y=d[x-1],k=m.has(x)?":":"-";c?e.push(`${x}${k}${y}`):e.push(`${p}${k}${x}${k}${y}`)}}}me();Mn();function Hl(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:Y.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?vt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await Bs(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
417
+ `);let f=n.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${f}Git repository in ${i.gitDir}/
418
+ `,stderr:c,exitCode:0}}})}ce();ar();var Go=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:Al(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,Al(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 Al(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}ce();function Rs(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+=jl(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Gl(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Lo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=Nl(c.timestamp,c.timezone),s+=3;continue;case"r":o+=Ll(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=V(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=V(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(V).join(" "),s+=2;continue;case"s":o+=fa(r.message),s+=2;continue;case"b":o+=Yp(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+=`
419
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var fa=ue;function Yp(e){let t=e.indexOf(`
420
+
421
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function No(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 xs(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?V(o):o,c=fa(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(V).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${fa(s.message)}`),a.join(`
422
+ `)}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(V).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(`
417
423
  `))a.push(` ${f}`);return a.join(`
418
- `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Y).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Nt(s.author.timestamp,s.author.timezone)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Nt(s.committer.timestamp,s.committer.timezone)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
424
+ `)}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(V).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Lo(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Lo(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
419
425
  `))a.push(` ${f}`);return a.join(`
420
- `)}case"raw":return Ap(t,n);default:return Dp(t,n)}}function Ap(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(`
426
+ `)}case"raw":return Xp(t,n);default:return Zp(t,n)}}function Xp(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(`
421
427
  `))o.push(` ${i}`);return o.join(`
422
- `)}function Dp(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(Y).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Nt(r.author.timestamp,r.author.timezone)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
428
+ `)}function Zp(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(V).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Lo(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
423
429
  `))s.push(` ${a}`);return s.join(`
424
- `)}var Mp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],jp=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Gp(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function ca(e,t){let n=Gp(t);return new Date((e+n*60)*1e3)}function Lp(e){return`${e.slice(0,3)}:${e.slice(3)}`}function Np(e,t){let n=ca(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${i}:${a}:${c}${Lp(t)}`}function _p(e,t){let n=ca(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 Fp(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 Up(e,t){let n=ca(e,t),r=Mp[n.getUTCDay()]?.slice(0,3),o=jp[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();ue();gn();ve();function Hl(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:J.number().alias("n").describe("Limit the number of commits to output"),oneline:I().describe("Condense each commit to a single line"),all:I().describe("Walk all refs, not just HEAD"),author:J.string().describe("Filter by author (regex or substring)"),grep:J.string().describe("Filter by commit message (regex or substring)"),since:J.string().describe("Show commits after date"),after:J.string().describe("Synonym for --since"),until:J.string().describe("Show commits before date"),before:J.string().describe("Synonym for --until"),decorate:I().describe("Show ref names next to commit hashes"),reverse:I().describe("Output commits in reverse order"),format:J.string().describe("Pretty-print format string"),pretty:J.string().describe("Pretty-print format or preset name"),patch:I().alias("p").describe("Show diff in patch format"),stat:I().describe("Show diffstat summary"),nameStatus:I().describe("Show names and status of changed files"),nameOnly:I().describe("Show only names of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file"),graph:I().describe("Draw text-based graph of the commit history"),firstParent:I().describe("Follow only the first parent of merge commits")},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?Ao(f[0]):null;if(l){let U=async me=>{let xe=await Be(i,me);if(!xe)return Vt(me);try{return await Ne(i,xe)}catch{return Vt(me)}},V=await U(l.left);if(typeof V=="object"&&"exitCode"in V)return V;let be=await U(l.right);if(typeof be=="object"&&"exitCode"in be)return be;let Le=V,it=be;if(l.type==="two-dot")a=[it],c=[Le];else{a=[Le,it];let me=await _t(i,Le,it);c=me.length>0?me:void 0}if(n.all){let me=await ge(i);for(let Ut of me)try{let On=await Ne(i,Ut.hash);a.includes(On)||a.push(On)}catch{}let xe=await Z(i);xe&&!a.includes(xe)&&a.push(xe)}}else if(n.all){let U=await ge(i),V=new Set;for(let Le of U)try{V.add(await Ne(i,Le.hash))}catch{}let be=await Z(i);be&&V.add(be),a=[...V]}else if(f&&f.length>0){let U=[];for(let V of f){let be=await Be(i,V);if(!be)return Vt(V);try{U.push(await Ne(i,be))}catch{return Vt(V)}}a=U}else{let U=await Ze(i);if(M(U))return U;a=[U]}if(a.length===0)return $("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(U=>Ue(U,"")):null,m=n.author?Tl(n.author):null,u=n.grep?Tl(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?Bi(h):null,w=p?Bi(p):null,y=n.format??n.pretty,x=null,b=null,k=!1;if(n.oneline)b="oneline",k=!0;else if(y!==void 0){let U=Lo(y);x=U.formatStr,b=U.preset}let E=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,R=n.graph;if(R&&n.reverse)return $("options '--graph' and '--reverse' cannot be used together");let P=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await qp(i):null,v=P?U=>vl(P,U):void 0,D=P?U=>{let V=vl(P,U);return V.startsWith("(")&&V.endsWith(")")?V.slice(1,-1):V}:void 0,O=n.maxCount,H=n.reverse,G=n.firstParent,A=d?Wp(i,a,d,c?await Bp(i,c):void 0,G):Dt(i,a,{exclude:c,topoOrder:R,firstParent:G}),S=[];for await(let U of A){if(O!==void 0&&S.length>=O)break;let{commit:V}=U;if(!(w!==null&&V.committer.timestamp>w)&&!(g!==null&&V.committer.timestamp<=g)){if(m){let be=`${V.author.name} <${V.author.email}>`;if(!m(be))continue}u&&!u(V.message)||S.push(U)}}let _=H?S.reverse():S;if(R)return zp(_,i,x,b,k,E,v,D);if(x!==null){let U=[];for(let V of _){let be={hash:V.hash,commit:V.commit,decorations:v,decorationsRaw:D},Le=Es(x,be),it=await fa(i,V.commit,E);it&&(Le+=`
430
+ `)}var Dl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ml=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Jp(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 _o(e,t){let n=Jp(t);return new Date((e+n*60)*1e3)}function Qp(e){return`${e.slice(0,3)}:${e.slice(3)}`}function jl(e,t){let n=_o(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":Qp(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function Gl(e,t){let n=_o(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 Ll(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 eg(e,t){let n=_o(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 tg(e,t){return`${e} ${t}`}function ng(e){return e.toString()}function rg(e,t){let n=new Date(e*1e3),r=Dl[n.getDay()]?.slice(0,3),o=Ml[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 Lo(e,t,n){switch(n){case"short":return eg(e,t);case"iso":return Gl(e,t);case"iso-strict":return jl(e,t);case"relative":case"human":return Ll(e);case"rfc":return Nl(e,t);case"raw":return tg(e,t);case"unix":return ng(e);case"local":return rg(e,t);default:return Rn(e,t)}}function Nl(e,t){let n=_o(e,t),r=Dl[n.getUTCDay()]?.slice(0,3),o=Ml[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}`}fe();pe();gn();He();function Ul(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[q.string().name("revisions").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of commits to output"),oneline:$().describe("Condense each commit to a single line"),all:$().describe("Walk all refs, not just HEAD"),author:Y.string().describe("Filter by author (regex or substring)"),grep:Y.string().describe("Filter by commit message (regex or substring)"),since:Y.string().describe("Show commits after date"),after:Y.string().describe("Synonym for --since"),until:Y.string().describe("Show commits before date"),before:Y.string().describe("Synonym for --until"),decorate:$().describe("Show ref names next to commit hashes"),reverse:$().describe("Output commits in reverse order"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name"),patch:$().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:Y.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Ao(f[0]):null;if(l){let J=async Pe=>{let nt=await Ke(i,Pe);if(!nt)return Vt(Pe);try{return await Le(i,nt)}catch{return Vt(Pe)}},re=await J(l.left);if(typeof re=="object"&&"exitCode"in re)return re;let ke=await J(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let Me=re,ie=ke;if(l.type==="two-dot")a=[ie],c=[Me];else{a=[Me,ie];let Pe=await Ft(i,Me,ie);c=Pe.length>0?Pe:void 0}if(n.all){let Pe=await be(i);for(let On of Pe)try{let Be=await Le(i,On.hash);a.includes(Be)||a.push(Be)}catch{}let nt=await Z(i);nt&&!a.includes(nt)&&a.push(nt)}}else if(n.all){let J=await be(i),re=new Set;for(let Me of J)try{re.add(await Le(i,Me.hash))}catch{}let ke=await Z(i);ke&&re.add(ke),a=[...re]}else if(f&&f.length>0){let J=[];for(let re of f){let ke=await Ke(i,re);if(!ke)return Vt(re);try{J.push(await Le(i,ke))}catch{return Vt(re)}}a=J}else{let J=await Qe(i);if(M(J))return J;a=[J]}if(a.length===0)return S("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?_l(n.author):null,u=n.grep?_l(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?qi(h):null,w=p?qi(p):null,b=n.format??n.pretty,x=null,y=null,E=!1;if(n.oneline)y="oneline",E=!0;else if(b!==void 0){let J=No(b);x=J.formatStr,y=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}
431
+ `,exitCode:128};let R=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 S("options '--graph' and '--reverse' cannot be used together");let D=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await ig(i):null,O=D?J=>Fl(D,J):void 0,A=D?J=>{let re=Fl(D,J);return re.startsWith("(")&&re.endsWith(")")?re.slice(1,-1):re}:void 0,G=n.maxCount,v=n.reverse,T=n.firstParent,F=d?og(i,a,d,c?await sg(i,c):void 0,T):jt(i,a,{exclude:c,topoOrder:P,firstParent:T}),_=[];for await(let J of F){if(G!==void 0&&_.length>=G)break;let{commit:re}=J;if(!(w!==null&&re.committer.timestamp>w)&&!(g!==null&&re.committer.timestamp<=g)){if(m){let ke=`${re.author.name} <${re.author.email}>`;if(!m(ke))continue}u&&!u(re.message)||_.push(J)}}let U=v?_.reverse():_;if(P)return ag(U,i,x,y,E,C,O,A,R);if(x!==null){let J=[];for(let re of U){let ke={hash:re.hash,commit:re.commit,decorations:O,decorationsRaw:A,dateMode:R},Me=Rs(x,ke),ie=await la(i,re.commit,C);ie&&(Me+=`
425
432
 
426
- ${it.replace(/\n$/,"")}`),U.push(Le)}return{stdout:U.length>0?`${U.join(`
433
+ ${ie.replace(/\n$/,"")}`),J.push(Me)}return{stdout:J.length>0?`${J.join(`
427
434
  `)}
428
- `:"",stderr:"",exitCode:0}}let B=b??"medium",z=B==="oneline",N=[];for(let U=0;U<_.length;U++){let V=_[U],be={hash:V.hash,commit:V.commit,decorations:v,decorationsRaw:D},Le=ks(B,be,U===0,k),it=await fa(i,V.commit,E);it&&(Le+=`${z?`
435
+ `:"",stderr:"",exitCode:0}}let N=y??"medium",K=N==="oneline",ne=[];for(let J=0;J<U.length;J++){let re=U[J],ke={hash:re.hash,commit:re.commit,decorations:O,decorationsRaw:A,dateMode:R},Me=xs(N,ke,J===0,E),ie=await la(i,re.commit,C);ie&&(Me+=`${K?`
429
436
  `:`
430
437
 
431
- `}${it.replace(/\n$/,"")}`),N.push(Le)}return{stdout:N.length>0?`${N.join(`
432
- `)}
433
- `:"",stderr:"",exitCode:0}}})}async function Bp(e,t){let n=new Set;for await(let r of Dt(e,t))n.add(r.hash);return n}function Tl(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Wp(e,t,n,r,o){let s=new Set(r),i=new _n,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await We(e,null,f.tree)).some(u=>ye(n,u.path))&&(yield c);continue}if(l.length===1){let m=l[0];if(m){try{let u=await j(e,m);(await We(e,u.tree,f.tree)).some(p=>ye(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 We(e,u.tree,f.tree)).some(p=>ye(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 qp(e){let t=await Q(e),n=t?.type==="symbolic"?Re(t.target):null,r=await Z(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,Re(f.name),f.name);let a=await ge(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await ge(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await Ne(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function vl(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 zp(e,t,n,r,o,s,i,a){let c=new Go,f=r??"medium",l=f==="oneline",d=[];for(let m=0;m<e.length;m++){let u=e[m],h={hash:u.hash,commit:u.commit,decorations:i,decorationsRaw:a},p;n!==null?p=Es(n,h):p=ks(f,h,!0,o),c.update(u.hash,u.commit.parents),m>0&&!l&&n===null&&d.push(c.paddingPrefix());let g=p.split(`
434
- `),w=0;for(;;){let{prefix:b,isCommitLine:k}=c.nextLine();if(k){d.push(b+(g[w++]??""));break}d.push(b)}for(;w<g.length;){let{prefix:b}=c.nextLine();d.push(b+g[w++])}for(;!c.isFinished();){let{prefix:b}=c.nextLine();d.push(b)}let y=80-c.width,x=await fa(t,u.commit,s,y);if(x){let b=x.replace(/\n$/,"").split(`
435
- `);if(l||n!==null)for(let k of b)d.push(c.paddingPrefix()+k);else{d.push(c.paddingPrefix());for(let k of b)d.push(c.paddingPrefix()+k)}}}return{stdout:d.length>0?`${d.join(`
436
- `)}
437
- `:"",stderr:"",exitCode:0}}async function fa(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await j(e,t.parents[0])).tree:null,s=await We(e,o,t.tree),{remaining:i,renames:a}=await nt(e,s);switch(n){case"name-only":return Kp(i,a);case"name-status":return Vp(i,a);case"stat":return Yp(e,i,a,r);case"shortstat":return Xp(e,i,a);case"numstat":return Zp(e,i,a);case"patch":return Jp(e,i,a)}}function Kp(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}
438
- `).join("")}function Vp(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}
439
- `).join("")}async function Yp(e,t,n,r){let{fileStats:o}=await Kn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),dr(o,r)}async function Xp(e,t,n){let{fileStats:r}=await Kn(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}
440
- `:""}async function Zp(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:cn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Ie(i)||Ie(a))o+=`- - ${s.display}
441
- `;else{let c=bt(i),f=bt(a),l=st(c,f),d=0,m=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&m++;o+=`${d} ${m} ${s.display}
442
- `}}return o}async function Jp(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 oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Pt({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 oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Pt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}se();Ce();le();er();tt();function Dl(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:I().alias("c").describe("Show cached files (default)"),modified:I().alias("m").describe("Show modified files"),deleted:I().alias("d").describe("Show deleted files"),others:I().alias("o").describe("Show other (untracked) files"),unmerged:I().alias("u").describe("Show unmerged files"),stage:I().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":I().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":I().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":I().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Xe(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,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 K(i),b=g?"\0":`
443
- `,k=o.passthrough.length>0?o.passthrough.map(C=>{let P=r.cwd!==c?Qp(c,r.cwd):"";return Ue(C,P)}):null,E=[];if(f)for(let C of x.entries){if(k&&!ye(k,C.path))continue;let P=w?C.stage>0?"M":"H":null;E.push(Al(C,h,P))}if(u&&!f)for(let C of x.entries)C.stage!==0&&(k&&!ye(k,C.path)||E.push(Al(C,!0,w?"M":null)));if(l||d){let C=await eg(i,c,x);for(let{path:P,status:v}of C){if(v==="modified"&&!l||v==="deleted"&&!d||k&&!ye(k,P))continue;let D=w?v==="deleted"?"R":"C":null;E.push(D?`${D} ${P}`:P)}}if(m){let C=await tg(i,c,x,p);for(let P of C)k&&!ye(k,P)||E.push(w?`? ${P}`:P)}return{stdout:E.length>0?E.join(b)+b:"",stderr:"",exitCode:0}}})}function Al(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 Qp(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function eg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=T(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await lt(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await jn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function tg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await et(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}se();ir();_e();Ce();ie();Fe();ue();gn();ve();function Ml(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:I().describe("Abort the current in-progress merge"),continue:I().describe("Continue the merge after conflict resolution"),noFf:I().describe("Create a merge commit even when fast-forward is possible"),ffOnly:I().describe("Refuse to merge unless fast-forward is possible"),squash:I().describe("Apply merge result to worktree/index without creating a merge commit"),edit:I().describe("Edit the merge message (no-op, accepted for compatibility)"),message:J.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 ig(s,r.env);if(n.continue)return og(s,r.env,t);let i=n.branch;if(!i)return $("you must specify a branch to merge");let a=await Ze(s);if(M(a))return a;let c=await K(s),f=yn(c,"Merging");if(f)return f;if(await F(s,"MERGE_HEAD"))return $(`You have not concluded your merge (MERGE_HEAD exists).
444
- Please, commit your changes before you merge.`);if(await F(s,"CHERRY_PICK_HEAD"))return $(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
445
- Please, commit your changes before you merge.`);let m=await Be(s,i);if(!m)return L(`merge: ${i} - not something we can merge
446
- `);let u=await Ne(s,m),h=await _t(s,a,u),p=h[0]??null;if(h.length===0)return $("refusing to merge unrelated histories");if(p===u)return await pe(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
447
- `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let k=await ke(s,"merge.ff");k==="false"?g=!0:k==="only"&&(w=!0)}if(g&&w)return $("--no-ff and --ff-only are incompatible");let y=p===a&&!g;if(w&&!y)return L(`hint: Diverging branches can't be fast-forwarded, you need to either:
438
+ `}${ie.replace(/\n$/,"")}`),ne.push(Me)}return{stdout:ne.length>0?`${ne.join(`
439
+ `)}
440
+ `:"",stderr:"",exitCode:0}}})}async function sg(e,t){let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}function _l(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*og(e,t,n,r,o){let s=new Set(r),i=new Fn,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=>ye(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=>ye(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=>ye(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 ig(e){let t=await Q(e),n=t?.type==="symbolic"?Ce(t.target):null,r=await Z(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 be(e,"refs/heads");for(let f of i)s(f.hash,Ce(f.name),f.name);let a=await be(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await be(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await Le(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function Fl(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 ag(e,t,n,r,o,s,i,a,c){let f=new Go,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=Rs(n,p):g=xs(l,p,!0,o),f.update(h.hash,h.commit.parents),u>0&&!d&&n===null&&m.push(f.paddingPrefix());let w=g.split(`
441
+ `),b=0;for(;;){let{prefix:E,isCommitLine:k}=f.nextLine();if(k){m.push(E+(w[b++]??""));break}m.push(E)}for(;b<w.length;){let{prefix:E}=f.nextLine();m.push(E+w[b++])}for(;!f.isFinished();){let{prefix:E}=f.nextLine();m.push(E)}let x=80-f.width,y=await la(t,h.commit,s,x);if(y){let E=y.replace(/\n$/,"").split(`
442
+ `);if(d||n!==null)for(let k of E)m.push(f.paddingPrefix()+k);else{m.push(f.paddingPrefix());for(let k of E)m.push(f.paddingPrefix()+k)}}}return{stdout:m.length>0?`${m.join(`
443
+ `)}
444
+ `:"",stderr:"",exitCode:0}}async function la(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 cg(i,a);case"name-status":return fg(i,a);case"stat":return lg(e,i,a,r);case"shortstat":return dg(e,i,a);case"numstat":return ug(e,i,a);case"patch":return mg(e,i,a)}}function cg(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}
445
+ `).join("")}function fg(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}
446
+ `).join("")}async function lg(e,t,n,r){let{fileStats:o}=await Vn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),ur(o,r)}async function dg(e,t,n){let{fileStats:r}=await Vn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Kn(r.length,o,s);return i?`${i}
447
+ `:""}async function ug(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:cn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(ve(i)||ve(a))o+=`- - ${s.display}
448
+ `;else{let c=kt(i),f=kt(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}
449
+ `}}return o}async function mg(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Ot({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 oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Ot({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}ce();$e();me();tr();ot();function Wl(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=Je(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),y=g?"\0":`
450
+ `,E=o.passthrough.length>0?o.passthrough.map(C=>{let P=r.cwd!==c?hg(c,r.cwd):"";return Ue(C,P)}):null,k=[];if(f)for(let C of x.entries){if(E&&!ye(E,C.path))continue;let P=w?C.stage>0?"M":"H":null;k.push(Bl(C,h,P))}if(u&&!f)for(let C of x.entries)C.stage!==0&&(E&&!ye(E,C.path)||k.push(Bl(C,!0,w?"M":null)));if(l||d){let C=await pg(i,c,x);for(let{path:P,status:H}of C){if(H==="modified"&&!l||H==="deleted"&&!d||E&&!ye(E,P))continue;let D=w?H==="deleted"?"R":"C":null;k.push(D?`${D} ${P}`:P)}}if(m){let C=await gg(i,c,x,p);for(let P of C)E&&!ye(E,P)||k.push(w?`? ${P}`:P)}return{stdout:k.length>0?k.join(y)+y:"",stderr:"",exitCode:0}}})}function Bl(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 hg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function pg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=I(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 Gn(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))}ce();ar();We();$e();fe();qe();pe();gn();He();function ql(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:Y.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return kg(s,r.env);if(n.continue)return Eg(s,r.env,t);let i=n.branch;if(!i)return S("you must specify a branch to merge");let a=await Qe(s);if(M(a))return a;let c=await z(s),f=yn(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return S(`You have not concluded your merge (MERGE_HEAD exists).
451
+ Please, commit your changes before you merge.`);if(await B(s,"CHERRY_PICK_HEAD"))return S(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
452
+ Please, commit your changes before you merge.`);let m=await Ke(s,i);if(!m)return L(`merge: ${i} - not something we can merge
453
+ `);let u=await Le(s,m),h=await Ft(s,a,u),p=h[0]??null;if(h.length===0)return S("refusing to merge unrelated histories");if(p===u)return await we(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
454
+ `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let E=await xe(s,"merge.ff");E==="false"?g=!0:E==="only"&&(w=!0)}if(g&&w)return S("--no-ff and --ff-only are incompatible");let b=p===a&&!g;if(w&&!b)return L(`hint: Diverging branches can't be fast-forwarded, you need to either:
448
455
  hint:
449
456
  hint: git merge --no-ff
450
457
  hint:
@@ -454,44 +461,44 @@ hint: git rebase
454
461
  hint:
455
462
  hint: Disable this message with "git config set advice.diverging false"
456
463
  fatal: Not possible to fast-forward, aborting.
457
- `,128);if(await F(s,"REVERT_HEAD")&&await jt(s),y&&!n.squash){let k=await Q(s),E=await xo(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 pe(s,"MERGE_MSG");let R=k?.type==="symbolic"?k.target:"HEAD";await re(s,r.env,R,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,k?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return E}let x=n.message,b=x?x.endsWith(`
464
+ `,128);if(await B(s,"REVERT_HEAD")&&await Lt(s),b&&!n.squash){let E=await Q(s),k=await xo(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 we(s,"MERGE_MSG");let R=E?.type==="symbolic"?E.target:"HEAD";await ae(s,r.env,R,a,u,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,E?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:u,strategy:"fast-forward",commitHash:null})}return k}let x=n.message,y=x?x.endsWith(`
458
465
  `)?x:`${x}
459
- `:void 0;return n.squash?sg(s,a,u,i,r.env,t,b):ng(s,a,u,i,r.env,g,t,b)}})}async function ng(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await Q(e),l=f?.type==="symbolic"?Re(f.target):"HEAD",d=await ke(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:r,conflictStyle:d},u=await hs(e,t,n,m),h=await xn(e,u,c.tree,{labels:m,errorExitCode:2,operationName:"merge"});if(!h.ok)return await pe(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(u.conflicts.length>0){await X(e,"MERGE_HEAD",n),await X(e,"ORIG_HEAD",t);let v=a??await ur(e,r,l),D={repo:e,message:v,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(D);if(ee(O))return{stdout:"",stderr:O.message??"",exitCode:1};v=D.message;let H=Bt({version:2,entries:u.entries}).sort();return v+=`
466
+ `:void 0;return n.squash?yg(s,a,u,i,r.env,t,y):wg(s,a,u,i,r.env,g,t,y)}})}async function wg(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await Q(e),l=f?.type==="symbolic"?Ce(f.target):"HEAD",d=await xe(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:r,conflictStyle:d},u=await gs(e,t,n,m),h=await Cn(e,u,c.tree,{labels:m,errorExitCode:2,operationName:"merge"});if(!h.ok)return await we(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await ae(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(u.conflicts.length>0){await X(e,"MERGE_HEAD",n),await X(e,"ORIG_HEAD",t);let H=a??await mr(e,r,l),D={repo:e,message:H,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(D);if(ee(O))return{stdout:"",stderr:O.message??"",exitCode:1};H=D.message;let A=Bt({version:2,entries:u.entries}).sort();return H+=`
460
467
  # Conflicts:
461
- ${H.map(A=>`# ${A}`).join(`
468
+ ${A.map(v=>`# ${v}`).join(`
462
469
  `)}
463
- `,await Te(e,"MERGE_MSG",v),await Te(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...u.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
470
+ `,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(`
464
471
  `)}
465
- `,stderr:"",exitCode:1}}await pe(e,"MERGE_MSG");let p=h.mergedTreeHash,g=await an(e,o);if(M(g))return g;let w=await Qe(e,o);if(M(w))return w;let y=a??await ur(e,r,l),x={repo:e,message:y,treeHash:p,headHash:t,theirsHash:n},b=await i?.hooks?.mergeMsg?.(x);if(ee(b))return{stdout:"",stderr:b.message??"",exitCode:1};y=x.message;let k=await i?.hooks?.preMergeCommit?.({repo:e,mergeMessage:y,treeHash:p,headHash:t,theirsHash:n});if(ee(k))return{stdout:"",stderr:k.message??"",exitCode:1};let E=await ht(e,p,[t,n],g,w,y),R=f?.type==="symbolic"?f.target:"HEAD";await re(e,o,R,t,E,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:E});let C=await ln(e,c.tree,p);return{stdout:`${u.messages.length>0?`${u.messages.join(`
472
+ `,stderr:"",exitCode:1}}await we(e,"MERGE_MSG");let p=h.mergedTreeHash,g=await an(e,o);if(M(g))return g;let w=await tt(e,o);if(M(w))return w;let b=a??await mr(e,r,l),x={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},y=await i?.hooks?.mergeMsg?.(x);if(ee(y))return{stdout:"",stderr:y.message??"",exitCode:1};b=x.message;let E=await i?.hooks?.preMergeCommit?.({repo:e,mergeMessage:b,treeHash:p,headHash:t,theirsHash:n});if(ee(E))return{stdout:"",stderr:E.message??"",exitCode:1};let k=await wt(e,p,[t,n],g,w,b),R=f?.type==="symbolic"?f.target:"HEAD";await ae(e,o,R,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 ln(e,c.tree,p);return{stdout:`${u.messages.length>0?`${u.messages.join(`
466
473
  `)}
467
474
  `:""}Merge made by the 'ort' strategy.
468
- ${C}`,stderr:"",exitCode:0}}async function rg(e,t,n){let r=[];for await(let o of Dt(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: ${Nt(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
475
+ ${C}`,stderr:"",exitCode:0}}async function bg(e,t,n){let r=[];for await(let o of jt(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: ${Rn(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
469
476
  `))r.push(` ${i}`);r.push("")}return r.join(`
470
- `)}async function sg(e,t,n,r,o,s,i){let a=await j(e,t),c=await Q(e),f=await ke(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await _t(e,t,n),m=d.length>0&&d[0]===t,u=m?`Updating ${Y(t)}..${Y(n)}
471
- `:"",h=await hs(e,t,n,l),p=await xn(e,h,a.tree,{labels:l,errorExitCode:m?1:2,operationName:"merge",skipStagedChangeCheck:m});if(!p.ok){await pe(e,"MERGE_MSG"),!m&&p.failureKind==="staged"&&c?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let k=p;return u&&(k.stdout=u+k.stdout),k}let g;if(i?g=`Squashed commit of the following:
477
+ `)}async function yg(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 Ft(e,t,n),m=d.length>0&&d[0]===t,u=m?`Updating ${V(t)}..${V(n)}
478
+ `:"",h=await gs(e,t,n,l),p=await Cn(e,h,a.tree,{labels:l,errorExitCode:m?1:2,operationName:"merge",skipStagedChangeCheck:m});if(!p.ok){await we(e,"MERGE_MSG"),!m&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ae(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=p;return u&&(E.stdout=u+E.stdout),E}let g;if(i?g=`Squashed commit of the following:
472
479
 
473
480
  ${i}`:g=`Squashed commit of the following:
474
481
 
475
- ${await rg(e,t,n)}`,await Te(e,"SQUASH_MSG",g),h.conflicts.length>0){let E=`
482
+ ${await bg(e,t,n)}`,await Ae(e,"SQUASH_MSG",g),h.conflicts.length>0){let k=`
476
483
  # Conflicts:
477
484
  ${Bt({version:2,entries:h.entries}).sort().map(P=>`# ${P}`).join(`
478
485
  `)}
479
- `,R=await Pe(e,"MERGE_MSG");return await Te(e,"MERGE_MSG",(R??"")+E),{stdout:`${[...h.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
486
+ `,R=await Oe(e,"MERGE_MSG");return await Ae(e,"MERGE_MSG",(R??"")+k),{stdout:`${[...h.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
480
487
  `)}
481
- `,stderr:"",exitCode:1}}let w=p.mergedTreeHash,y=await ln(e,a.tree,w),x=h.messages.length>0?`${h.messages.join(`
488
+ `,stderr:"",exitCode:1}}let w=p.mergedTreeHash,b=await ln(e,a.tree,w),x=h.messages.length>0?`${h.messages.join(`
482
489
  `)}
483
490
  `:"";return{stdout:`${m?`${u}Fast-forward
484
491
  `:""}${x}Squash commit -- not updating HEAD
485
- ${m?y:""}`,stderr:m?"":`Automatic merge went well; stopped before committing as requested
486
- `,exitCode:0}}async function og(e,t,n){let r=await F(e,"MERGE_HEAD");if(!r)return $("There is no merge in progress (MERGE_HEAD missing).");let o=await K(e),s=yn(o,"Committing");if(s)return s;let i=await Ze(e);if(M(i))return i;let a=await j(e,i),c=await Pe(e,"MERGE_MSG");if(c)c=Yt(c);else{let C=await Q(e),P=C?.type==="symbolic"?Re(C.target):"HEAD";c=await ur(e,"unknown",P)}let f=De(o),l=await Ge(e,f),d=await an(e,t);if(M(d))return d;let m=await Qe(e,t);if(M(m))return m;let u=At(c),h={repo:e,message:u,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(ee(p))return{stdout:"",stderr:p.message??"",exitCode:1};u=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,mergeMessage:u,treeHash:l,headHash:i,theirsHash:r});if(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await ht(e,l,[i,r],d,m,u);await is(e);let y=await Q(e),x=fe(u),b=y?.type==="symbolic"?y.target:"HEAD";await re(e,t,b,i,w,`commit (merge): ${x}`,y?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await ln(e,a.tree,l),E=y?.type==="symbolic"?Re(y.target):"detached HEAD";return{stdout:`${Ht(E,w,c)}
487
- ${k}`,stderr:"",exitCode:0}}async function ig(e,t){return Nn(e,t,{operationRef:"MERGE_HEAD",noOpError:$("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:is})}se();Ce();le();tt();function jl(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:I().alias("f").describe("Force renaming even if target exists"),"dry-run":I().alias("n").describe("Do nothing; only show what would happen"),skip:I().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return L(`usage: git mv [<options>] <source>... <destination>
488
- `);let f=c[c.length-1],l=c.slice(0,-1),d=$t(r.cwd,f),m=ft(a,d);if(m.startsWith(".."))return $(`'${f}' is outside repository at '${a}'`);let u=await K(s),h=await r.fs.exists(d),p=h&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return $(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let y=$t(r.cwd,w),x=ft(a,y);if(x.startsWith("..")){if(n.skip)continue;return $(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(y)){if(n.skip)continue;return $(`bad source, source=${x}, destination=${m}`)}let E=(await r.fs.stat(y)).isDirectory;if(!(E?u.entries.some(O=>O.path===x||O.path.startsWith(`${x}/`)):u.entries.some(O=>O.path===x&&O.stage===0))){let O=!E&&u.entries.some(H=>H.path===x&&H.stage>0);if(n.skip)continue;return $(O?`conflicted, source=${x}, destination=${m}`:`not under version control, source=${x}, destination=${m}`)}let C,P;if(p){let O=Lr(x);C=m===""||m==="."?O:`${m}/${O}`,P=T(d,O)}else C=m,P=d;if(await r.fs.exists(P)&&!n.force)if((await r.fs.stat(P)).isDirectory){let H=Lr(x);C=`${C}/${H}`,P=T(P,H)}else{if(n.skip)continue;return $(`destination exists, source=${x}, destination=${C}`)}if(x===C){if(n.skip)continue;return $(`can not move directory into itself, source=${x}, destination=${C}`)}let D=Jt(P);if(!await r.fs.exists(D)){if(n.skip)continue;return $(`renaming '${x}' failed: No such file or directory`)}if(E){let O=`${x}/`,H=u.entries.filter(G=>G.path.startsWith(O)&&G.stage===0);for(let G of H){let A=G.path.slice(x.length),S=C+A,_=P+A;g.push({srcRel:G.path,dstRel:S,srcAbs:T(a,G.path),dstAbs:_})}}else g.push({srcRel:x,dstRel:C,srcAbs:y,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 y=Jt(w.dstAbs);await r.fs.exists(y)||await r.fs.mkdir(y,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=js(u,w.srcRel,0);if(b){u=at(u,w.srcRel);let k={...b,path:w.dstRel};u=Et(u,k)}}for(let w of g)await rr(r.fs,Jt(w.srcAbs),a);return await ae(s,u),{stdout:"",stderr:"",exitCode:0}}})}se();_e();$n();Ce();ie();le();dt();Fe();ue();se();_e();Ce();ie();se();ie();mn();Jn();ve();async function la(e,t){let n=await we(e,t);if(n.type!=="commit")return null;let r=tn(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await we(e,r.parents[0]);f.type==="commit"&&(o=tn(f.content).tree)}let s=await We(e,o,r.tree);if(s.length===0)return null;let i=Sn(),a=!1,c=[...s].sort((f,l)=>Oe(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let u=await we(e,f.oldHash);l=new TextDecoder().decode(u.content)}catch{}if(f.newHash)try{let u=await we(e,f.newHash);d=new TextDecoder().decode(u.content)}catch{}let m=Pt({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(m)for(let u of m.split(`
492
+ ${m?b:""}`,stderr:m?"":`Automatic merge went well; stopped before committing as requested
493
+ `,exitCode:0}}async function Eg(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return S("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=yn(o,"Committing");if(s)return s;let i=await Qe(e);if(M(i))return i;let a=await j(e,i),c=await Oe(e,"MERGE_MSG");if(c)c=Yt(c);else{let C=await Q(e),P=C?.type==="symbolic"?Ce(C.target):"HEAD";c=await mr(e,"unknown",P)}let f=Ge(o),l=await Fe(e,f),d=await an(e,t);if(M(d))return d;let m=await tt(e,t);if(M(m))return m;let u=Mt(c),h={repo:e,message:u,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(ee(p))return{stdout:"",stderr:p.message??"",exitCode:1};u=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,mergeMessage:u,treeHash:l,headHash:i,theirsHash:r});if(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await wt(e,l,[i,r],d,m,u);await cs(e);let b=await Q(e),x=ue(u),y=b?.type==="symbolic"?b.target:"HEAD";await ae(e,t,y,i,w,`commit (merge): ${x}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let E=await ln(e,a.tree,l),k=b?.type==="symbolic"?Ce(b.target):"detached HEAD";return{stdout:`${Dt(k,w,c)}
494
+ ${E}`,stderr:"",exitCode:0}}async function kg(e,t){return _n(e,t,{operationRef:"MERGE_HEAD",noOpError:S("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:cs})}ce();$e();me();ot();function zl(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=Je(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return L(`usage: git mv [<options>] <source>... <destination>
495
+ `);let f=c[c.length-1],l=c.slice(0,-1),d=vt(r.cwd,f),m=rt(a,d);if(m.startsWith(".."))return S(`'${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 S(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let b=vt(r.cwd,w),x=rt(a,b);if(x.startsWith("..")){if(n.skip)continue;return S(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(b)){if(n.skip)continue;return S(`bad source, source=${x}, destination=${m}`)}let k=(await r.fs.stat(b)).isDirectory;if(!(k?u.entries.some(O=>O.path===x||O.path.startsWith(`${x}/`)):u.entries.some(O=>O.path===x&&O.stage===0))){let O=!k&&u.entries.some(A=>A.path===x&&A.stage>0);if(n.skip)continue;return S(O?`conflicted, source=${x}, destination=${m}`:`not under version control, source=${x}, destination=${m}`)}let C,P;if(p){let O=_r(x);C=m===""||m==="."?O:`${m}/${O}`,P=I(d,O)}else C=m,P=d;if(await r.fs.exists(P)&&!n.force)if((await r.fs.stat(P)).isDirectory){let A=_r(x);C=`${C}/${A}`,P=I(P,A)}else{if(n.skip)continue;return S(`destination exists, source=${x}, destination=${C}`)}if(x===C){if(n.skip)continue;return S(`can not move directory into itself, source=${x}, destination=${C}`)}let D=Jt(P);if(!await r.fs.exists(D)){if(n.skip)continue;return S(`renaming '${x}' failed: No such file or directory`)}if(k){let O=`${x}/`,A=u.entries.filter(G=>G.path.startsWith(O)&&G.stage===0);for(let G of A){let v=G.path.slice(x.length),T=C+v,F=P+v;g.push({srcRel:G.path,dstRel:T,srcAbs:I(a,G.path),dstAbs:F})}}else g.push({srcRel:x,dstRel:C,srcAbs:b,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 b=Jt(w.dstAbs);await r.fs.exists(b)||await r.fs.mkdir(b,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let y=js(u,w.srcRel,0);if(y){u=lt(u,w.srcRel);let E={...y,path:w.dstRel};u=xt(u,E)}}for(let w of g)await sr(r.fs,Jt(w.srcAbs),a);return await le(s,u),{stdout:"",stderr:"",exitCode:0}}})}ce();We();Sn();$e();fe();me();ht();qe();pe();ce();We();$e();fe();ce();fe();mn();Qn();He();async function da(e,t){let n=await Ee(e,t);if(n.type!=="commit")return null;let r=tn(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await Ee(e,r.parents[0]);f.type==="commit"&&(o=tn(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=vn(),a=!1,c=[...s].sort((f,l)=>Se(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let u=await Ee(e,f.oldHash);l=new TextDecoder().decode(u.content)}catch{}if(f.newHash)try{let u=await Ee(e,f.newHash);d=new TextDecoder().decode(u.content)}catch{}let m=Ot({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(m)for(let u of m.split(`
489
496
  `)){if(!u||u.startsWith("index "))continue;let p=(u.startsWith("@@")?u.replace(/^@@ [^@]* @@/,"@@ @@"):u).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
490
- `),a=!0)}}return a?i.hex():null}Fe();ue();ve();on();tt();async function ag(e){let t=await Q(e);return t?.type==="symbolic"?Re(t.target):"detached HEAD"}function Gl(e){return e==="HEAD"?`HEAD is up to date.
497
+ `),a=!0)}}return a?i.hex():null}qe();pe();He();on();ot();async function Rg(e){let t=await Q(e);return t?.type==="symbolic"?Ce(t.target):"detached HEAD"}function Kl(e){return e==="HEAD"?`HEAD is up to date.
491
498
  `:`Current branch ${e} is up to date.
492
- `}async function cg(e,t,n){if(!e.workTree)return null;let r=await ce(e,t),o=new Map(De(n).map(a=>[a.path,a])),s=new Set(await et(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=Qs(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return L(`${a.stderr}error: could not detach HEAD
493
- `)}return null}async function fg(e,t,n,r){if(!e.workTree)return null;let o=await ce(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await et(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${Qs(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
494
- `,exitCode:128}:null}async function Ll(e,t,n){if(!e.workTree)return null;let r=new Map(De(t).map(i=>[i.path,i])),o=new Set(await et(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function Nl(e,t){return`error: The following untracked working tree files would be overwritten by merge:
499
+ `}async function xg(e,t,n){if(!e.workTree)return null;let r=await de(e,t),o=new Map(Ge(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=Qs(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return L(`${a.stderr}error: could not detach HEAD
500
+ `)}return null}async function Cg(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:`${Qs(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
501
+ `,exitCode:128}:null}async function Vl(e,t,n){if(!e.workTree)return null;let r=new Map(Ge(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 Yl(e,t){return`error: The following untracked working tree files would be overwritten by merge:
495
502
  ${e.map(r=>` ${r}`).join(`
496
503
  `)}
497
504
  Please move or remove them before you merge.
@@ -505,20 +512,20 @@ hint: edit the todo list first:
505
512
  hint:
506
513
  hint: git rebase --edit-todo
507
514
  hint: git rebase --continue
508
- `}async function da(e,t,n,r,o,s){await re(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await re(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await re(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function No(e,t,n,r){let o=await j(e,t),s=await cg(e,o.tree,n);if(s)return s;let i=await bn(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps)),r!=="detached HEAD"?await X(e,r,t):await X(e,"HEAD",t),null}async function ua(e,t,n,r,o,s,i,a){let c=r.startsWith("refs/heads/")?Re(r):"HEAD",f=await K(e),l=Bt(f).sort();if(l.length>0)return{stdout:l.map(O=>`${O}: needs merge
515
+ `}async function ua(e,t,n,r,o,s){await ae(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ae(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ae(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Fo(e,t,n,r){let o=await j(e,t),s=await xg(e,o.tree,n);if(s)return s;let i=await bn(e,o.tree,n);return i.success&&(await le(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps)),r!=="detached HEAD"?await X(e,r,t):await X(e,"HEAD",t),null}async function ma(e,t,n,r,o,s,i,a){let c=r.startsWith("refs/heads/")?Ce(r):"HEAD",f=await z(e),l=Bt(f).sort();if(l.length>0)return{stdout:l.map(O=>`${O}: needs merge
509
516
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
510
517
  error: additionally, your index contains uncommitted changes.
511
518
  error: Please commit or stash them.
512
- `,exitCode:1};let d=await j(e,n),m=await ce(e,d.tree);if(e.workTree){let O=xr(f,m),G=(await Tt(e,f)).some(A=>A.status==="modified"||A.status==="deleted");if(O||G){let A=[];return G&&A.push("error: cannot rebase: You have unstaged changes."),O&&(G?A.push("error: additionally, your index contains uncommitted changes."):A.push("error: cannot rebase: Your index contains uncommitted changes.")),A.push("error: Please commit or stash them."),L(`${A.join(`
519
+ `,exitCode:1};let d=await j(e,n),m=await de(e,d.tree);if(e.workTree){let O=Cr(f,m),G=(await At(e,f)).some(v=>v.status==="modified"||v.status==="deleted");if(O||G){let v=[];return G&&v.push("error: cannot rebase: You have unstaged changes."),O&&(G?v.push("error: additionally, your index contains uncommitted changes."):v.push("error: cannot rebase: Your index contains uncommitted changes.")),v.push("error: Please commit or stash them."),L(`${v.join(`
513
520
  `)}
514
- `)}}let u=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};let h=await sf(e,o,n),p=h.right;if(p.length===0){if(s!==n){let O=await No(e,s,f,r);return O||(await da(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
515
- `,exitCode:0})}return{stdout:Gl(c),stderr:"",exitCode:0}}let g=[],w=h.left,y=new Set;for(let O of w){let H=await la(e,O.hash);H&&y.add(H)}let x=[];if(y.size>0)for(let O of p){let H=await la(e,O.hash);H&&y.has(H)?g.push(`warning: skipped previously applied commit ${Y(O.hash)}`):x.push(O)}else x.push(...p);let b="";if(g.length>0&&(b=`${g.join(`
521
+ `)}}let u=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(ee(u))return{stdout:"",stderr:u.message??"",exitCode:1};let h=await of(e,o,n),p=h.right;if(p.length===0){if(s!==n){let O=await Fo(e,s,f,r);return O||(await ua(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
522
+ `,exitCode:0})}return{stdout:Kl(c),stderr:"",exitCode:0}}let g=[],w=h.left,b=new Set;for(let O of w){let A=await da(e,O.hash);A&&b.add(A)}let x=[];if(b.size>0)for(let O of p){let A=await da(e,O.hash);A&&b.has(A)?g.push(`warning: skipped previously applied commit ${V(O.hash)}`):x.push(O)}else x.push(...p);let y="";if(g.length>0&&(y=`${g.join(`
516
523
  `)}
517
524
  hint: use --reapply-cherry-picks to include skipped commits
518
525
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
519
- `),x.length===0){if(s!==n){let O=await No(e,s,f,r);if(O)return O.stderr=b+O.stderr,O;await da(e,t,n,s,r,i)}return{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
520
- `,exitCode:0}}let k=x.map(O=>({hash:O.hash,subject:fe(O.commit.message)})),E=s,R=0;for(let O of k){let H=await j(e,O.hash);if(H.parents.length>1||H.parents.length===0||H.parents[0]!==E)break;E=O.hash,R++}let C=k.splice(0,R);if(k.length===0){if(E===n)return{stdout:Gl(c),stderr:b,exitCode:0};let O=await No(e,E,f,r);return O?(O.stderr=b+O.stderr,O):(await da(e,t,n,E,r,i),{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
521
- `,exitCode:0})}let P=await No(e,E,f,"detached HEAD");if(P)return P.stderr=b+P.stderr,P;await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await re(e,t,"HEAD",n,E,`rebase (start): checkout ${i}`);let v={headName:r,origHead:n,onto:s,todo:k,done:C,msgnum:R,end:R+k.length};await Hi(e,v),await X(e,"ORIG_HEAD",n);let D=await ma(e,t);return b&&(D.stderr=b+D.stderr),D}function _l(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:J.string().describe("Starting point at which to create new commits"),abort:I().describe("Abort the current rebase operation"),continue:I().describe("Continue the rebase after conflict resolution"),skip:I().describe("Skip the current patch and continue")},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 ug(s,r.env);if(n.continue)return mg(s,r.env);if(n.skip)return hg(s,r.env);let i=n.upstream;if(!i)return $("no upstream configured and no upstream argument given");if(await Gt(s))return $(`It seems that there is already a rebase-merge directory, and
526
+ `),x.length===0){if(s!==n){let O=await Fo(e,s,f,r);if(O)return O.stderr=y+O.stderr,O;await ua(e,t,n,s,r,i)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
527
+ `,exitCode:0}}let E=x.map(O=>({hash:O.hash,subject:ue(O.commit.message)})),k=s,R=0;for(let O of E){let A=await j(e,O.hash);if(A.parents.length>1||A.parents.length===0||A.parents[0]!==k)break;k=O.hash,R++}let C=E.splice(0,R);if(E.length===0){if(k===n)return{stdout:Kl(c),stderr:y,exitCode:0};let O=await Fo(e,k,f,r);return O?(O.stderr=y+O.stderr,O):(await ua(e,t,n,k,r,i),{stdout:"",stderr:`${y}Successfully rebased and updated ${r}.
528
+ `,exitCode:0})}let P=await Fo(e,k,f,"detached HEAD");if(P)return P.stderr=y+P.stderr,P;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await we(e,"MERGE_MSG"),await we(e,"MERGE_MODE"),await ae(e,t,"HEAD",n,k,`rebase (start): checkout ${i}`);let H={headName:r,origHead:n,onto:s,todo:E,done:C,msgnum:R,end:R+E.length};await Di(e,H),await X(e,"ORIG_HEAD",n);let D=await ha(e,t);return y&&(D.stderr=y+D.stderr),D}function Xl(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[q.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Y.string().describe("Starting point at which to create new commits"),abort:$().describe("Abort the current rebase operation"),continue:$().describe("Continue the rebase after conflict resolution"),skip:$().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Og(s,r.env);if(n.continue)return Sg(s,r.env);if(n.skip)return Ig(s,r.env);let i=n.upstream;if(!i)return S("no upstream configured and no upstream argument given");if(await Nt(s))return S(`It seems that there is already a rebase-merge directory, and
522
529
  I wonder if you are in the middle of another rebase. If that is the
523
530
  case, please try
524
531
  git rebase (--continue | --abort | --skip)
@@ -526,9 +533,9 @@ If that is not the case, please
526
533
  rm -fr ".git/rebase-merge"
527
534
  and run me again. I am stopping in case you still have something
528
535
  valuable there.
529
- `);let a=await Ze(s);if(M(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await He(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,m,u=n.onto;if(u){let h=await He(s,u,`Does not point to a valid commit: '${u}'`);if(M(h))return h;m=h.hash}else m=d;return ua(s,r.env,a,f,d,m,i,t)}})}async function ma(e,t){let n=[],r=[];for(;;){let o=await gt(e);if(!o||o.todo.length===0)break;let s=o.todo[0];if(!s)break;n.push(`Rebasing (${o.msgnum+1}/${o.end})\r`),await rf(e);let i=await lg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await gt(e);a&&(a.todo=[s,...a.todo],await Hi(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 lg(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await j(e,s):null,a=await Z(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
530
- `};if(s&&s===a){let G=await K(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
531
- `};let A=await Ve(e,i.tree),S=await Ve(e,o.tree),_=new Map(A.map(U=>[U.path,U.hash])),B=new Map;for(let U of S){let V=_.get(U.path);(!V||V!==U.hash)&&B.set(U.path,U.hash)}let z=await Ll(e,G,B);if(z)return await X(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Nl(z,t),rescheduleCurrent:!0};let N=await bn(e,o.tree,G);return N.success&&(await ae(e,{version:2,entries:N.newEntries}),await Me(e,N.worktreeOps)),await An(e,r),await re(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await j(e,a),f=i?i.tree:null,l=Y(r),d=fe(o.message),m=await ke(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:m},h=await Ft(e,f,c.tree,o.tree,u),p=await K(e),[g,w,y]=await Promise.all([Ve(e,c.tree),f?Ve(e,f):Promise.resolve([]),Ve(e,o.tree)]),x=new Set;for(let G of w)x.add(G.path);for(let G of g)x.add(G.path);for(let G of y)x.add(G.path);let b=p.entries.filter(G=>!x.has(G.path)),k=[...h.entries,...b];k.sort((G,A)=>Oe(G.path,A.path)||G.stage-A.stage);let E={version:2,entries:k},R=k.filter(G=>G.stage===0),C=await Ge(e,R),P=new Map(g.map(G=>[G.path,G])),v=new Map;for(let G of R){let A=P.get(G.path);(!A||A.hash!==G.hash)&&v.set(G.path,G.hash)}for(let G of h.conflicts){if(G.reason==="content"||G.reason==="add-add"){v.set(G.path,null);continue}if(G.reason==="delete-modify"){let A=h.entries.filter(B=>B.path===G.path&&B.stage>0),S=A.find(B=>B.stage===2),_=A.find(B=>B.stage===3);_&&!S&&v.set(G.path,_.hash)}}let D=await Ll(e,p,v);if(D)return await X(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Nl(D,t),rescheduleCurrent:!0};if(await ae(e,E),e.workTree){let G=await Ln(e,c.tree,h.resultTree,p);G.success&&await Me(e,G.worktreeOps)}if(h.conflicts.length>0){await X(e,"REBASE_HEAD",r),await co(e,r,o.author),await Te(e,"MERGE_MSG",o.message),await Te(e,"rebase-merge/message",o.message);let G=h.messages.join(`
536
+ `);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 De(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,m,u=n.onto;if(u){let h=await De(s,u,`Does not point to a valid commit: '${u}'`);if(M(h))return h;m=h.hash}else m=d;return ma(s,r.env,a,f,d,m,i,t)}})}async function ha(e,t){let n=[],r=[];for(;;){let o=await yt(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 sf(e);let i=await Pg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await yt(e);a&&(a.todo=[s,...a.todo],await Di(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 $g(e,n,t)}async function Pg(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await j(e,s):null,a=await Z(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
537
+ `};if(s&&s===a){let G=await z(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
538
+ `};let v=await ze(e,i.tree),T=await ze(e,o.tree),F=new Map(v.map(K=>[K.path,K.hash])),_=new Map;for(let K of T){let ne=F.get(K.path);(!ne||ne!==K.hash)&&_.set(K.path,K.hash)}let U=await Vl(e,G,_);if(U)return await X(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Yl(U,t),rescheduleCurrent:!0};let N=await bn(e,o.tree,G);return N.success&&(await le(e,{version:2,entries:N.newEntries}),await Ne(e,N.worktreeOps)),await Dn(e,r),await ae(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=V(r),d=ue(o.message),m=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:m},h=await Ut(e,f,c.tree,o.tree,u),p=await z(e),[g,w,b]=await Promise.all([ze(e,c.tree),f?ze(e,f):Promise.resolve([]),ze(e,o.tree)]),x=new Set;for(let G of w)x.add(G.path);for(let G of g)x.add(G.path);for(let G of b)x.add(G.path);let y=p.entries.filter(G=>!x.has(G.path)),E=[...h.entries,...y];E.sort((G,v)=>Se(G.path,v.path)||G.stage-v.stage);let k={version:2,entries:E},R=E.filter(G=>G.stage===0),C=await Fe(e,R),P=new Map(g.map(G=>[G.path,G])),H=new Map;for(let G of R){let v=P.get(G.path);(!v||v.hash!==G.hash)&&H.set(G.path,G.hash)}for(let G of h.conflicts){if(G.reason==="content"||G.reason==="add-add"){H.set(G.path,null);continue}if(G.reason==="delete-modify"){let v=h.entries.filter(_=>_.path===G.path&&_.stage>0),T=v.find(_=>_.stage===2),F=v.find(_=>_.stage===3);F&&!T&&H.set(G.path,F.hash)}}let D=await Vl(e,p,H);if(D)return await X(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Yl(D,t),rescheduleCurrent:!0};if(await le(e,k),e.workTree){let G=await Nn(e,c.tree,h.resultTree,p);G.success&&await Ne(e,G.worktreeOps)}if(h.conflicts.length>0){await X(e,"REBASE_HEAD",r),await co(e,r,o.author),await Ae(e,"MERGE_MSG",o.message),await Ae(e,"rebase-merge/message",o.message);let G=h.messages.join(`
532
539
  `);return{conflict:!0,stdout:G?`${G}
533
540
  `:"",stderr:`error: could not apply ${l}... ${t.subject}
534
541
  hint: Resolve all conflicts manually, mark them as resolved with
@@ -538,12 +545,12 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
538
545
  hint: Disable this message with "git config set advice.mergeConflict false"
539
546
  Could not apply ${l}... # ${t.subject}
540
547
  `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
541
- `};let O=await Qe(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let H=await ht(e,C,[a],o.author,O,o.message);return await re(e,n,"HEAD",a,H,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function dg(e,t,n){let r=await gt(e);if(!r)return $("no rebase in progress");let o=await Z(e);if(!o)return $("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await X(e,r.headName,o),await ze(e,"HEAD",r.headName),await pt(e),await re(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await re(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
542
- `;return await de(e,"REBASE_HEAD"),await ar(e),await Ai(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function ug(e,t){let n=await gt(e);if(!n)return $("no rebase in progress");let r=await Z(e),o=n.origHead,s=await j(e,o),i=await K(e),a=await fg(e,s.tree,i,o);if(a)return a;let c=await bn(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await Me(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await X(e,n.headName,o),await ze(e,"HEAD",n.headName),await pt(e)):await An(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await re(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await de(e,"REBASE_HEAD"),await ar(e),await Ai(e),{stdout:"",stderr:"",exitCode:0}}async function mg(e,t){let n="";if(!await gt(e))return $("no rebase in progress");let o=await K(e);if(St(o))return L(`error: Committing is not possible because you have unmerged files.
548
+ `};let O=await tt(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let A=await wt(e,C,[a],o.author,O,o.message);return await ae(e,n,"HEAD",a,A,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function $g(e,t,n){let r=await yt(e);if(!r)return S("no rebase in progress");let o=await Z(e);if(!o)return S("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await X(e,r.headName,o),await Ye(e,"HEAD",r.headName),await bt(e),await ae(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ae(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
549
+ `;return await he(e,"REBASE_HEAD"),await cr(e),await Mi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Og(e,t){let n=await yt(e);if(!n)return S("no rebase in progress");let r=await Z(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await Cg(e,s.tree,i,o);if(a)return a;let c=await bn(e,s.tree,i);c.success&&(await le(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await X(e,n.headName,o),await Ye(e,"HEAD",n.headName),await bt(e)):await Dn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ae(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await he(e,"REBASE_HEAD"),await cr(e),await Mi(e),{stdout:"",stderr:"",exitCode:0}}async function Sg(e,t){let n="";if(!await yt(e))return S("no rebase in progress");let o=await z(e);if(Ht(o))return L(`error: Committing is not possible because you have unmerged files.
543
550
  hint: Fix them up in the work tree, and then use 'git add <file>'
544
551
  hint: as appropriate to mark resolution and make a commit.
545
552
  fatal: Exiting because of an unresolved conflict.
546
- `,128);let s=await F(e,"REBASE_HEAD");if(s){let a=await Z(e);if(!a)return $("Cannot read HEAD");let c=await j(e,a),f=De(o),l=await Ge(e,f),d=l!==c.tree,m=await Pe(e,"rebase-merge/message")!==null;if(d&&!m)return L(`error: you have staged changes in your working tree
553
+ `,128);let s=await B(e,"REBASE_HEAD");if(s){let a=await Z(e);if(!a)return S("Cannot read HEAD");let c=await j(e,a),f=Ge(o),l=await Fe(e,f),d=l!==c.tree,m=await Oe(e,"rebase-merge/message")!==null;if(d&&!m)return L(`error: you have staged changes in your working tree
547
554
  If these changes are meant to be squashed into the previous commit, run:
548
555
 
549
556
  git commit --amend
@@ -556,37 +563,37 @@ In both cases, once you're done, continue with:
556
563
 
557
564
  git rebase --continue
558
565
 
559
- `);if(d){let u=await j(e,s),h=await F(e,"CHERRY_PICK_HEAD"),p=h?await j(e,h):u,g;g=await Pe(e,"rebase-merge/message")??await Pe(e,"MERGE_MSG")??void 0,g&&(g=Yt(g)),g||(g=u.message);let w=await Qe(e,t);if(M(w))return w;let y=At(g),x=[a],b=await F(e,"MERGE_HEAD");b&&x.push(b);let k=await ht(e,l,x,p.author,w,y);b&&(await de(e,"MERGE_HEAD"),await pe(e,"MERGE_MODE"));let E=fe(y);await re(e,t,"HEAD",a,k,`rebase (continue): ${E}`);let R=await ag(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,P=await fn(e,c.tree,l,p.author,w,C);n=`${Ht(R,k,y)}
560
- ${P}`}await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"rebase-merge/message")}let i=await ma(e,t);return n&&(i.stdout=n+i.stdout),i}async function hg(e,t){if(!await gt(e))return $("no rebase in progress");let r=await Z(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
566
+ `);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 Oe(e,"rebase-merge/message")??await Oe(e,"MERGE_MSG")??void 0,g&&(g=Yt(g)),g||(g=u.message);let w=await tt(e,t);if(M(w))return w;let b=Mt(g),x=[a],y=await B(e,"MERGE_HEAD");y&&x.push(y);let E=await wt(e,l,x,p.author,w,b);y&&(await he(e,"MERGE_HEAD"),await we(e,"MERGE_MODE"));let k=ue(b);await ae(e,t,"HEAD",a,E,`rebase (continue): ${k}`);let R=await Rg(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,P=await fn(e,c.tree,l,p.author,w,C);n=`${Dt(R,E,b)}
567
+ ${P}`}await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await we(e,"MERGE_MSG"),await we(e,"rebase-merge/message")}let i=await ha(e,t);return n&&(i.stdout=n+i.stdout),i}async function Ig(e,t){if(!await yt(e))return S("no rebase in progress");let r=await Z(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
561
568
  fatal: could not discard worktree changes
562
- `,exitCode:128};let o=await j(e,r),s=await K(e),i=await bn(e,o.tree,s);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await Me(e,i.worktreeOps)),await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await de(e,"MERGE_HEAD"),await pe(e,"MERGE_MSG"),await pe(e,"MERGE_MODE"),await pe(e,"rebase-merge/message"),ma(e,t)}function Fl(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:I().alias("r").describe("Rebase instead of merge"),noRebase:I().describe("Merge instead of rebase"),ffOnly:I().describe("Only fast-forward"),noFf:I().describe("Create a merge commit even for fast-forwards"),depth:J.number().describe("Limit fetching to the specified number of commits"),unshallow:I().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return $("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Co(s))return $("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=ps);let a=await Ze(s);if(M(a))return a;let c=await K(s);if(St(c))return L(`error: Pulling is not possible because you have unmerged files.
563
- `,128);let f=n.remote,l=n.branch;if(!f){let ne=await Q(s);if(ne?.type==="symbolic"){let Ae=ne.target.startsWith("refs/heads/")?ne.target.slice(11):ne.target,Zt=(await he(s))[`branch "${Ae}"`];Zt&&(f=Zt.remote||"origin",!l&&Zt.merge&&(l=Zt.merge.startsWith("refs/heads/")?Zt.merge.slice(11):Zt.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let ne=await Q(s);if(ne?.type==="symbolic"){let Ae=ne.target.startsWith("refs/heads/")?ne.target.slice(11):ne.target,un=await ke(s,`branch.${Ae}.rebase`);(un==="true"||un!=="false"&&await ke(s,"pull.rebase")==="true")&&(d=!0)}else await ke(s,"pull.rebase")==="true"&&(d=!0)}let m;try{m=await Dr(s,f,r.env)}catch(ne){let Ae=ne instanceof Error?ne.message:"";if(Ae.startsWith("network"))return $(Ae);throw ne}if(!m)return $(`'${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(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=pr(h.fetchRefspec),y=await u.advertiseRefs();if(y.length===0)return $("Couldn't find remote ref HEAD");let b=(await ge(s)).map(ne=>ne.hash),k=await F(s,"HEAD");k&&b.push(k);let E=[],R=new Set,C=[];for(let ne of y){if(ne.name==="HEAD")continue;let Ae=Mo(w,ne.name);Ae!==null&&(C.push({remote:ne,localRef:Ae}),R.has(ne.hash)||(R.add(ne.hash),E.push(ne.hash)))}let P=new Set(b),v=E.filter(ne=>!P.has(ne)),D,O=i!==void 0?await Sr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:O});let H=v.length>0?v:D?E:[];if(H.length>0){let ne=await u.fetch(H,b,D);ne.shallowUpdates&&await Tr(s,ne.shallowUpdates,O)}let G=await Qt(s,r.env);for(let ne of C){let Ae=await F(s,ne.localRef);await X(s,ne.localRef,ne.remote.hash),await Ke(s,ne.localRef,{oldHash:Ae??te,newHash:ne.remote.hash,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:Ae?"pull":"pull: storing head"})}let A=null;if(l){let ne=y.find(Ae=>Ae.name===`refs/heads/${l}`);if(ne)A=ne.hash;else return $(`Couldn't find remote ref refs/heads/${l}`)}else{let ne=y.find(Ae=>Ae.name==="HEAD");ne&&(A=ne.hash)}if(A&&await r.fs.writeFile(T(s.gitDir,"FETCH_HEAD"),`${A} ${h.url}
564
- `),!A)return $("Could not determine remote HEAD");let S=A;if(a===S)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
565
- `,stderr:"",exitCode:0};if(d){let ne=await Q(s),Ae=ne?.type==="symbolic"?ne.target:"detached HEAD",un=l?`${f}/${l}`:f,Zt=await ua(s,r.env,a,Ae,S,S,un,t);return Zt.exitCode===0&&await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:null}),Zt}let _=await _t(s,a,S),B=_[0]??null;if(_.length===0)return $("refusing to merge unrelated histories");if(B===S)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
566
- `,stderr:"",exitCode:0};let z=!!n.noFf,N=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let ne=await ke(s,"pull.ff");ne==="false"?z=!0:ne==="only"&&(N=!0)}let U=B===a;if(N&&!U)return $("Not possible to fast-forward, aborting.");if(U&&!z){let ne=await xo(s,a,S),Ae=await Q(s),un=Ae?.type==="symbolic"?Ae.target:"HEAD";return await Ke(s,un,{oldHash:a,newHash:S,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),Ae?.type==="symbolic"&&await Ke(s,"HEAD",{oldHash:a,newHash:S,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),ne.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:S,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:null})),ne}let V=await Q(s),be=V?.type==="symbolic"?Re(V.target):"HEAD",Le=l||f||"FETCH_HEAD",it=await ke(s,"merge.conflictstyle")??"merge",me={a:"HEAD",b:Le,conflictStyle:it},xe=await hs(s,a,S,me),Ut=await j(s,a),On=await xn(s,xe,Ut.tree,{labels:me,errorExitCode:2,operationName:"merge"});if(!On.ok)return On;if(xe.conflicts.length>0){await X(s,"MERGE_HEAD",S),await X(s,"ORIG_HEAD",a);let ne=await ur(s,Le,be),Ae=Bt({version:2,entries:xe.entries}).sort();return ne+=`
569
+ `,exitCode:128};let o=await j(e,r),s=await z(e),i=await bn(e,o.tree,s);return i.success&&(await le(e,{version:2,entries:i.newEntries}),await Ne(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 we(e,"MERGE_MSG"),await we(e,"MERGE_MODE"),await we(e,"rebase-merge/message"),ha(e,t)}function Zl(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:Y.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 S("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Po(s))return S("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=ws);let a=await Qe(s);if(M(a))return a;let c=await z(s);if(Ht(c))return L(`error: Pulling is not possible because you have unmerged files.
570
+ `,128);let f=n.remote,l=n.branch;if(!f){let se=await Q(s);if(se?.type==="symbolic"){let je=se.target.startsWith("refs/heads/")?se.target.slice(11):se.target,Zt=(await ge(s))[`branch "${je}"`];Zt&&(f=Zt.remote||"origin",!l&&Zt.merge&&(l=Zt.merge.startsWith("refs/heads/")?Zt.merge.slice(11):Zt.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let se=await Q(s);if(se?.type==="symbolic"){let je=se.target.startsWith("refs/heads/")?se.target.slice(11):se.target,un=await xe(s,`branch.${je}.rebase`);(un==="true"||un!=="false"&&await xe(s,"pull.rebase")==="true")&&(d=!0)}else await xe(s,"pull.rebase")==="true"&&(d=!0)}let m;try{m=await Mr(s,f,r.env)}catch(se){let je=se instanceof Error?se.message:"";if(je.startsWith("network"))return S(je);throw se}if(!m)return S(`'${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(ee(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=gr(h.fetchRefspec),b=await u.advertiseRefs();if(b.length===0)return S("Couldn't find remote ref HEAD");let y=(await be(s)).map(se=>se.hash),E=await B(s,"HEAD");E&&y.push(E);let k=[],R=new Set,C=[];for(let se of b){if(se.name==="HEAD")continue;let je=Mo(w,se.name);je!==null&&(C.push({remote:se,localRef:je}),R.has(se.hash)||(R.add(se.hash),k.push(se.hash)))}let P=new Set(y),H=k.filter(se=>!P.has(se)),D,O=i!==void 0?await vr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:O});let A=H.length>0?H:D?k:[];if(A.length>0){let se=await u.fetch(A,y,D);se.shallowUpdates&&await Tr(s,se.shallowUpdates,O)}let G=await Qt(s,r.env);for(let se of C){let je=await B(s,se.localRef);await X(s,se.localRef,se.remote.hash),await Xe(s,se.localRef,{oldHash:je??te,newHash:se.remote.hash,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:je?"pull":"pull: storing head"})}let v=null;if(l){let se=b.find(je=>je.name===`refs/heads/${l}`);if(se)v=se.hash;else return S(`Couldn't find remote ref refs/heads/${l}`)}else{let se=b.find(je=>je.name==="HEAD");se&&(v=se.hash)}if(v&&await r.fs.writeFile(I(s.gitDir,"FETCH_HEAD"),`${v} ${h.url}
571
+ `),!v)return S("Could not determine remote HEAD");let T=v;if(a===T)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
572
+ `,stderr:"",exitCode:0};if(d){let se=await Q(s),je=se?.type==="symbolic"?se.target:"detached HEAD",un=l?`${f}/${l}`:f,Zt=await ma(s,r.env,a,je,T,T,un,t);return Zt.exitCode===0&&await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:null}),Zt}let F=await Ft(s,a,T),_=F[0]??null;if(F.length===0)return S("refusing to merge unrelated histories");if(_===T)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
573
+ `,stderr:"",exitCode:0};let U=!!n.noFf,N=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let se=await xe(s,"pull.ff");se==="false"?U=!0:se==="only"&&(N=!0)}let K=_===a;if(N&&!K)return S("Not possible to fast-forward, aborting.");if(K&&!U){let se=await xo(s,a,T),je=await Q(s),un=je?.type==="symbolic"?je.target:"HEAD";return await Xe(s,un,{oldHash:a,newHash:T,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),je?.type==="symbolic"&&await Xe(s,"HEAD",{oldHash:a,newHash:T,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:"pull: Fast-forward"}),se.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:T,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:null})),se}let ne=await Q(s),J=ne?.type==="symbolic"?Ce(ne.target):"HEAD",re=l||f||"FETCH_HEAD",ke=await xe(s,"merge.conflictstyle")??"merge",Me={a:"HEAD",b:re,conflictStyle:ke},ie=await gs(s,a,T,Me),Pe=await j(s,a),nt=await Cn(s,ie,Pe.tree,{labels:Me,errorExitCode:2,operationName:"merge"});if(!nt.ok)return nt;if(ie.conflicts.length>0){await X(s,"MERGE_HEAD",T),await X(s,"ORIG_HEAD",a);let se=await mr(s,re,J),je=Bt({version:2,entries:ie.entries}).sort();return se+=`
567
574
  # Conflicts:
568
- ${Ae.map(un=>`# ${un}`).join(`
575
+ ${je.map(un=>`# ${un}`).join(`
569
576
  `)}
570
- `,await Te(s,"MERGE_MSG",ne),{stdout:`${[...xe.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
577
+ `,await Ae(s,"MERGE_MSG",se),{stdout:`${[...ie.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
571
578
  `)}
572
- `,stderr:"",exitCode:1}}let qe=On.mergedTreeHash,gr=await an(s,r.env);if(M(gr))return gr;let Ps=await Qe(s,r.env);if(M(Ps))return Ps;let Cs=await ur(s,Le,be),Ra={repo:s,message:Cs,treeHash:qe,headHash:a,theirsHash:S},xa=await t?.hooks?.mergeMsg?.(Ra);if(ee(xa))return{stdout:"",stderr:xa.message??"",exitCode:1};Cs=Ra.message;let Pa=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:Cs,treeHash:qe,headHash:a,theirsHash:S});if(ee(Pa))return{stdout:"",stderr:Pa.message??"",exitCode:1};let Os=await ht(s,qe,[a,S],gr,Ps,Cs);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:S,strategy:"three-way",commitHash:Os}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:Os});let pd=V?.type==="symbolic"?V.target:"HEAD",Ca="pull: Merge made by the 'ort' strategy.";await Ke(s,pd,{oldHash:a,newHash:Os,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:Ca}),V?.type==="symbolic"&&await Ke(s,"HEAD",{oldHash:a,newHash:Os,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:Ca});let gd=await ln(s,Ut.tree,qe);return{stdout:`${xe.messages.length>0?`${xe.messages.join(`
579
+ `,stderr:"",exitCode:1}}let On=nt.mergedTreeHash,Be=await an(s,r.env);if(M(Be))return Be;let wr=await tt(s,r.env);if(M(wr))return wr;let Gr=await mr(s,re,J),xa={repo:s,message:Gr,treeHash:On,headHash:a,theirsHash:T},Ca=await t?.hooks?.mergeMsg?.(xa);if(ee(Ca))return{stdout:"",stderr:Ca.message??"",exitCode:1};Gr=xa.message;let Pa=await t?.hooks?.preMergeCommit?.({repo:s,mergeMessage:Gr,treeHash:On,headHash:a,theirsHash:T});if(ee(Pa))return{stdout:"",stderr:Pa.message??"",exitCode:1};let $s=await wt(s,On,[a,T],Be,wr,Gr);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:T,strategy:"three-way",commitHash:$s}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:$s});let Pd=ne?.type==="symbolic"?ne.target:"HEAD",$a="pull: Merge made by the 'ort' strategy.";await Xe(s,Pd,{oldHash:a,newHash:$s,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:$a}),ne?.type==="symbolic"&&await Xe(s,"HEAD",{oldHash:a,newHash:$s,name:G.name,email:G.email,timestamp:G.timestamp,tz:G.tz,message:$a});let $d=await ln(s,Pe.tree,On);return{stdout:`${ie.messages.length>0?`${ie.messages.join(`
573
580
  `)}
574
581
  `:""}Merge made by the 'ort' strategy.
575
- ${gd}`,stderr:"",exitCode:0}}})}se();_e();dt();ue();function Ul(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:I().alias("f").describe("Force push"),"set-upstream":I().alias("u").describe("Set upstream tracking reference"),all:I().describe("Push all branches"),delete:I().alias("d").describe("Delete remote refs"),tags:I().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a;try{a=await Dr(s,i,r.env)}catch(b){let k=b instanceof Error?b.message:"";if(k.startsWith("network"))return $(k);throw b}if(!a)return $(`'${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);let u=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return $("--delete requires a ref argument");for(let k of b){let E=k.startsWith("refs/")?k:`refs/heads/${k}`,R=m.get(E)??null;if(!R)return L(`error: unable to delete '${k}': remote ref does not exist
576
- `);u.push({name:E,oldHash:R,newHash:te,ok:l})}}else if(n.all){let b=await ge(s,"refs/heads");for(let k of b){let E=k.name,R=m.get(E)??null;u.push({name:E,oldHash:R,newHash:k.hash,ok:l})}}else if(n.tags){let b=await ge(s,"refs/tags");for(let k of b){let E=m.get(k.name)??null;E!==k.hash&&u.push({name:k.name,oldHash:E,newHash:k.hash,ok:l})}}else if(h&&h.length>0)for(let b of h){let k=pr(b),E=await gg(s,k.src);if(!E)return L(`error: src refspec '${k.src}' does not match any
577
- `);let R=k.dst.startsWith("refs/")?k.dst:`refs/heads/${k.dst}`,C=m.get(R)??null;u.push({name:R,oldHash:C,newHash:E,ok:l||k.force})}else{let b=await Q(s);if(!b||b.type!=="symbolic")return $("You are not currently on a branch.");let k=b.target,E=k.startsWith("refs/heads/")?k.slice(11):k,R=await Z(s);if(!R)return L(`error: src refspec does not match any
578
- `);let C=(await ke(s,"push.default"))?.toLowerCase()??"simple",P=await pg(s,C,k,E,R,i,m,l);if("exitCode"in P)return P;u.push(P)}if(u.length===0)return{stdout:`Everything up-to-date
579
- `,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:u.map(b=>({srcRef:b.newHash===te?null:b.name,srcHash:b.newHash===te?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===te}))});if(ee(p))return L(p.message??"");let g=await c.push(u),w=[];w.push(`To ${f.url}
580
- `);let y=!1;for(let b of g.updates){let k=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name;if(!b.ok)w.push(` ! [rejected] ${k} -> ${k} (${b.error??"failed"})
581
- `),y=!0;else if(!b.oldHash)w.push(` * [new branch] ${k} -> ${k}
582
- `);else if(b.newHash===te)w.push(` - [deleted] ${k}
583
- `);else{let E=Y(b.oldHash),R=Y(b.newHash);w.push(` ${E}..${R} ${k} -> ${k}
584
- `)}}if(n["set-upstream"]&&!y){let b=await Q(s);if(b?.type==="symbolic"){let k=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,E=await he(s);E[`branch "${k}"`]={remote:i,merge:`refs/heads/${k}`},await Ye(s,E),w.push(`branch '${k}' set up to track '${i}/${k}'.
585
- `)}}let x={stdout:"",stderr:w.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:u.map(b=>({srcRef:b.newHash===te?null:b.name,srcHash:b.newHash===te?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===te}))}),x}})}async function pg(e,t,n,r,o,s,i,a){if(t==="nothing")return $(`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 $(`The current branch ${r} has no upstream branch.
582
+ ${$d}`,stderr:"",exitCode:0}}})}ce();We();ht();pe();function Jl(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 Mr(s,i,r.env)}catch(y){let E=y instanceof Error?y.message:"";if(E.startsWith("network"))return S(E);throw y}if(!a)return S(`'${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 y of d)m.set(y.name,y.hash);let u=[],h=n.refspec;if(n.delete){let y=h&&h.length>0?h:[];if(y.length===0)return S("--delete requires a ref argument");for(let E of y){let k=E.startsWith("refs/")?E:`refs/heads/${E}`,R=m.get(k)??null;if(!R)return L(`error: unable to delete '${E}': remote ref does not exist
583
+ `);u.push({name:k,oldHash:R,newHash:te,ok:l})}}else if(n.all){let y=await be(s,"refs/heads");for(let E of y){let k=E.name,R=m.get(k)??null;u.push({name:k,oldHash:R,newHash:E.hash,ok:l})}}else if(n.tags){let y=await be(s,"refs/tags");for(let E of y){let k=m.get(E.name)??null;k!==E.hash&&u.push({name:E.name,oldHash:k,newHash:E.hash,ok:l})}}else if(h&&h.length>0)for(let y of h){let E=gr(y),k=await Tg(s,E.src);if(!k)return L(`error: src refspec '${E.src}' does not match any
584
+ `);let R=E.dst.startsWith("refs/")?E.dst:`refs/heads/${E.dst}`,C=m.get(R)??null;u.push({name:R,oldHash:C,newHash:k,ok:l||E.force})}else{let y=await Q(s);if(!y||y.type!=="symbolic")return S("You are not currently on a branch.");let E=y.target,k=E.startsWith("refs/heads/")?E.slice(11):E,R=await Z(s);if(!R)return L(`error: src refspec does not match any
585
+ `);let C=(await xe(s,"push.default"))?.toLowerCase()??"simple",P=await vg(s,C,E,k,R,i,m,l);if("exitCode"in P)return P;u.push(P)}if(u.length===0)return{stdout:`Everything up-to-date
586
+ `,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:u.map(y=>({srcRef:y.newHash===te?null:y.name,srcHash:y.newHash===te?null:y.newHash,dstRef:y.name,dstHash:y.oldHash,force:!!y.ok,delete:y.newHash===te}))});if(ee(p))return L(p.message??"");let g=await c.push(u),w=[];w.push(`To ${f.url}
587
+ `);let b=!1;for(let y of g.updates){let E=y.name.startsWith("refs/heads/")?y.name.slice(11):y.name;if(!y.ok)w.push(` ! [rejected] ${E} -> ${E} (${y.error??"failed"})
588
+ `),b=!0;else if(!y.oldHash)w.push(` * [new branch] ${E} -> ${E}
589
+ `);else if(y.newHash===te)w.push(` - [deleted] ${E}
590
+ `);else{let k=V(y.oldHash),R=V(y.newHash);w.push(` ${k}..${R} ${E} -> ${E}
591
+ `)}}if(n["set-upstream"]&&!b){let y=await Q(s);if(y?.type==="symbolic"){let E=y.target.startsWith("refs/heads/")?y.target.slice(11):y.target,k=await ge(s);k[`branch "${E}"`]={remote:i,merge:`refs/heads/${E}`},await Ze(s,k),w.push(`branch '${E}' set up to track '${i}/${E}'.
592
+ `)}}let x={stdout:"",stderr:w.join(""),exitCode:b?1:0};return b||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:u.map(y=>({srcRef:y.newHash===te?null:y.name,srcHash:y.newHash===te?null:y.newHash,dstRef:y.name,dstHash:y.oldHash,force:!!y.ok,delete:y.newHash===te}))}),x}})}async function vg(e,t,n,r,o,s,i,a){if(t==="nothing")return S(`You didn't specify any refspecs to push, and push.default is "nothing".`);if(t==="current")return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a};if(t==="upstream"){let d=(await ge(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return S(`The current branch ${r} has no upstream branch.
586
593
  To push the current branch and set the remote as upstream, use
587
594
 
588
595
  git push --set-upstream ${s} ${r}
589
- `);let m=d.merge;return{name:m,oldHash:i.get(m)??null,newHash:o,ok:a}}let f=(await he(e))[`branch "${r}"`];if(f?.remote&&f?.merge){let l=f.remote,d=f.merge;if(l===s)return(d.startsWith("refs/heads/")?d.slice(11):d)!==r?$(`The upstream branch of your current branch does not match
596
+ `);let m=d.merge;return{name:m,oldHash:i.get(m)??null,newHash:o,ok:a}}let f=(await ge(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?S(`The upstream branch of your current branch does not match
590
597
  the name of your current branch. To push to the upstream branch
591
598
  on the remote, use
592
599
 
@@ -595,52 +602,52 @@ on the remote, use
595
602
  To push to the branch of the same name on the remote, use
596
603
 
597
604
  git push ${s} HEAD
598
- `):{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 gg(e,t){if(t.startsWith("refs/"))return F(e,t);let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);return r||(t==="HEAD"?Z(e):null)}se();le();Fe();ue();function wg(e,t,n,r){return`${Y(n)} ${e}@{${t}}: ${r}`}async function _o(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await F(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
605
+ `):{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 Tg(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"?Z(e):null)}ce();me();qe();pe();function Hg(e,t,n,r){return`${V(n)} ${e}@{${t}}: ${r}`}async function Uo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await B(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
599
606
  Use '--' to separate paths from revisions, like this:
600
607
  'git <command> [<revision>...] -- [<file>...]'
601
- `,exitCode:128};let s=await Je(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let l=s.length-1;l>=0&&c<a;l--){let d=s[l];if(!d)continue;let m=s.length-1-l;d.newHash!==te&&(i.push(wg(t,m,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
608
+ `,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!==te&&(i.push(Hg(t,m,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
602
609
  `)}
603
- `:"",stderr:"",exitCode:0}}function Bl(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:J.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 _o(i,"HEAD",r.maxCount);let c=a[0];if(!c)return _o(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return _o(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
604
- `,exitCode:128};let l=T(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return _o(i,c,r.maxCount)}})}se();_e();Fe();ue();function bg(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 Wl(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:I().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=bg(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(`
610
+ `:"",stderr:"",exitCode:0}}function Ql(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return Uo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Uo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Uo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
611
+ `,exitCode:128};let l=I(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Uo(i,c,r.maxCount)}})}ce();We();qe();pe();function Ag(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 ed(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 ge(a),f=Ag(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(`
605
612
  `)}
606
613
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
607
614
  `)}
608
- `,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(!Qr(`refs/remotes/${s.name}`,0))return $(`'${s.name}' is not a valid remote name`);let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?L(`error: remote ${s.name} already exists.
609
- `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Ye(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Eg(c,s.name),await Ye(a,c),await kg(a,s.name),{stdout:"",stderr:"",exitCode:0}):L(`error: No such remote: '${s.name}'
610
- `,2)},o=[q.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a);return yg(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;if(!(f in c))return L(`error: No such remote '${s.name}'
611
- `,2);let l=c[f];return l&&(l.url=s.url),await Ye(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await he(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
615
+ `,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 S(`'${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 ge(a),f=`remote "${s.name}"`;return f in c?L(`error: remote ${s.name} already exists.
616
+ `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Ze(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 ge(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Mg(c,s.name),await Ze(a,c),await jg(a,s.name),{stdout:"",stderr:"",exitCode:0}):L(`error: No such remote: '${s.name}'
617
+ `,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 ge(a);return Dg(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 ge(a),f=`remote "${s.name}"`;if(!(f in c))return L(`error: No such remote '${s.name}'
618
+ `,2);let l=c[f];return l&&(l.url=s.url),await Ze(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 ge(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
612
619
  `,stderr:"",exitCode:0}:L(`error: No such remote '${s.name}'
613
- `,2)}})}async function yg(e,t,n,r){if(!Qr(`refs/remotes/${r}`,0))return $(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return L(`error: No such remote: '${n}'
614
- `,2);let s=`remote "${r}"`;if(s in t)return $(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Ye(e,t);let a=`refs/remotes/${n}`,c=await ge(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await Je(e,f.name);await X(e,l,f.hash),await de(e,f.name),d.length>0&&await Mn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Eg(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 kg(e,t){let n=`refs/remotes/${t}`,r=await ge(e,n);for(let o of r)await de(e,o.name)}se();Ce();ie();le();Fe();ue();gn();ve();on();tt();function zl(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:I().describe("Only move HEAD"),mixed:I().describe("Move HEAD and reset index (default)"),hard:I().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await 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 $("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=mt(i,r.cwd);if(o.passthrough.length>0){let u=a.length>0?a[0]:void 0;return ha(i,o.passthrough,l,u,t)}if(!f&&a.length>0){let u=a[0],h=await Be(i,u);return a.length===1&&h?ql(i,u,"mixed",r.env,t):h?ha(i,a.slice(1),l,u,t):ha(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",m=a.length>0?a[0]:"HEAD";return ql(i,m,d,r.env,t)}})}async function ha(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",target:r??null});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await Be(e,r);if(!d)return Vt(r);let m=await Ne(e,d);i=(await j(e,m)).tree}else{let d=await Z(e);d&&(i=(await j(e,d)).tree)}let a=await ce(e,i??null),c=await K(e);if(t.some(or)){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(!ye(d,u))continue;let h=a.get(u);h?c=Et(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:$e()}):c=at(c,u)}}else for(let d of t){let m=a.get(d);if(m)c=Et(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:$e()});else if(c.entries.some(h=>h.path===d))c=at(c,d);else if(!(e.workTree&&await e.fs.exists(T(e.workTree,d))))return Vt(d)}await ae(e,c);let l={stdout:await Kl(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function Kl(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 Tt(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(`
620
+ `,2)}})}async function Dg(e,t,n,r){if(!ts(`refs/remotes/${r}`,0))return S(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return L(`error: No such remote: '${n}'
621
+ `,2);let s=`remote "${r}"`;if(s in t)return S(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Ze(e,t);let a=`refs/remotes/${n}`,c=await be(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await et(e,f.name);await X(e,l,f.hash),await he(e,f.name),d.length>0&&await jn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Mg(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 jg(e,t){let n=`refs/remotes/${t}`,r=await be(e,n);for(let o of r)await he(e,o.name)}ce();$e();fe();me();qe();pe();gn();He();on();ot();function nd(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 S("--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 pa(i,o.passthrough,l,u,t)}if(!f&&a.length>0){let u=a[0],h=await Ke(i,u);return a.length===1&&h?td(i,u,"mixed",r.env,t):h?pa(i,a.slice(1),l,u,t):pa(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",m=a.length>0?a[0]:"HEAD";return td(i,m,d,r.env,t)}})}async function pa(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",target:r??null});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await Ke(e,r);if(!d)return Vt(r);let m=await Le(e,d);i=(await j(e,m)).tree}else{let d=await Z(e);d&&(i=(await j(e,d)).tree)}let a=await de(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(!ye(d,u))continue;let h=a.get(u);h?c=xt(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Ie()}):c=lt(c,u)}}else for(let d of t){let m=a.get(d);if(m)c=xt(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:Ie()});else if(c.entries.some(h=>h.path===d))c=lt(c,d);else if(!(e.workTree&&await e.fs.exists(I(e.workTree,d))))return Vt(d)}await le(e,c);let l={stdout:await rd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function rd(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await At(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(`
615
622
  `)}
616
- `}async function ql(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,target:t});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await Be(e,t);if(!i)return Vt(t);let a=await Ne(e,i),c=await j(e,a);if(n==="soft"){let u=await F(e,"MERGE_HEAD"),h=await K(e);if(u||St(h))return $("Cannot do a soft reset in the middle of a merge.")}let f=await Z(e),l=await Q(e);l?.type==="symbolic"?await X(e,l.target,a):await X(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await re(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await re(e,r,"HEAD",f,a,d),await ar(e),n==="mixed"){let u=await Ve(e,c.tree),h=Gs(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:$e()})));await ae(e,h);let p=await Kl(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=Xe(e);if(u)return u;let h=await K(e),p=await bn(e,c.tree,h);await ae(e,{version:2,entries:p.newEntries}),await Me(e,p.worktreeOps)}let m=n==="hard"?`HEAD is now at ${Y(a)} ${fe(c.message)}
617
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:m,stderr:"",exitCode:0}}se();Ce();ie();ue();ve();tt();function Vl(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:J.string().alias("s").describe("Restore from tree-ish"),staged:I().alias("S").describe("Restore the index"),worktree:I().alias("W").describe("Restore the working tree (default)"),ours:I().describe("Checkout our version for unmerged files"),theirs:I().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return $("you must specify path(s) to restore");if(n.ours&&n.theirs)return $("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=mt(i,r.cwd);if(n.ours||n.theirs)return n.source?$("cannot specify both --source and --ours/--theirs"):c?$("cannot use --ours/--theirs with --staged"):mo(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let m=await He(i,n.source,`could not resolve '${n.source}'`);if(M(m))return m;d=m.commit.tree}else if(c){let m=await Z(i);m&&(d=(await j(i,m)).tree)}return c&&f?Pg(i,a,l,d):c?Rg(i,a,l,d):d?xg(i,a,l,d):uo(i,a,l)}})}async function Rg(e,t,n,r){let o=await ce(e,r),s=await K(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!ye(i,f))continue;c=!0;let l=o.get(f);if(l)s=Et(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:$e()});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
618
- `,exitCode:1};s=at(s,f)}}return c?(await ae(e,s),{stdout:"",stderr:"",exitCode:0}):L(`error: pathspec '${t[0]}' did not match any file(s) known to git
619
- `)}async function xg(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await K(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
623
+ `}async function td(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,target:t});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await Ke(e,t);if(!i)return Vt(t);let a=await Le(e,i),c=await j(e,a);if(n==="soft"){let u=await B(e,"MERGE_HEAD"),h=await z(e);if(u||Ht(h))return S("Cannot do a soft reset in the middle of a merge.")}let f=await Z(e),l=await Q(e);l?.type==="symbolic"?await X(e,l.target,a):await X(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await ae(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await ae(e,r,"HEAD",f,a,d),await cr(e),n==="mixed"){let u=await ze(e,c.tree),h=Gs(u.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Ie()})));await le(e,h);let p=await rd(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=Je(e);if(u)return u;let h=await z(e),p=await bn(e,c.tree,h);await le(e,{version:2,entries:p.newEntries}),await Ne(e,p.worktreeOps)}let m=n==="hard"?`HEAD is now at ${V(a)} ${ue(c.message)}
624
+ `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:m,stderr:"",exitCode:0}}ce();$e();fe();pe();He();ot();function sd(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:Y.string().alias("s").describe("Restore from tree-ish"),staged:$().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 S("you must specify path(s) to restore");if(n.ours&&n.theirs)return S("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=ut(i,r.cwd);if(n.ours||n.theirs)return n.source?S("cannot specify both --source and --ours/--theirs"):c?S("cannot use --ours/--theirs with --staged"):mo(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let m=await De(i,n.source,`could not resolve '${n.source}'`);if(M(m))return m;d=m.commit.tree}else if(c){let m=await Z(i);m&&(d=(await j(i,m)).tree)}return c&&f?Ng(i,a,l,d):c?Gg(i,a,l,d):d?Lg(i,a,l,d):uo(i,a,l)}})}async function Gg(e,t,n,r){let o=await de(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!ye(i,f))continue;c=!0;let l=o.get(f);if(l)s=xt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Ie()});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
625
+ `,exitCode:1};s=lt(s,f)}}return c?(await le(e,s),{stdout:"",stderr:"",exitCode:0}):L(`error: pathspec '${t[0]}' did not match any file(s) known to git
626
+ `)}async function Lg(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await de(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await z(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(ye(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
620
627
  `,exitCode:1};i.push(f)}if(i.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
621
- `);for(let f of i){let l=o.get(f);if(l)await ct(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 Pg(e,t,n,r){if(!e.workTree)return $("this operation must be run in a work tree");let o=await ce(e,r),s=await K(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)ye(i,f)&&a.push(f);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
622
- `);for(let f of a){let l=o.get(f);if(l)s=Et(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:$e()}),await ct(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
623
- `,exitCode:1};s=at(s,f);let m=`${e.workTree}/${f}`;await e.fs.exists(m)&&await e.fs.rm(m)}}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}se();ie();le();ue();gn();ve();function Yl(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:I().describe("Verify that exactly one parameter is provided and resolves to an object"),short:I().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":I().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":I().describe("Output the full symbolic ref name"),"show-toplevel":I().describe("Show the absolute path of the top-level directory"),"git-dir":I().describe("Show the path to the .git directory"),"is-inside-work-tree":I().describe("Output whether cwd is inside the work tree"),"is-bare-repository":I().describe("Output whether the repository is bare"),"show-prefix":I().describe("Show path of cwd relative to top-level directory"),"show-cdup":I().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(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,y=[];if(f){if(!w.workTree)return $("this operation must be run in a work tree");y.push(w.workTree)}if(l&&y.push(w.gitDir),d&&y.push(w.workTree?"true":"false"),m&&y.push(w.workTree?"false":"true"),u){if(!w.workTree)return $("this operation must be run in a work tree");let b=ft(w.workTree,r.cwd);y.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return $("this operation must be run in a work tree");let b=ft(r.cwd,w.workTree);y.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:y.map(k=>`${k}
624
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return $("Needed a single revision");for(let b of o){if(a){let R=await Cg(w,b);if(R===null)return pa(b,s);y.push(R);continue}if(c){let R=await Og(w,b);if(R===null)return pa(b,s);y.push(R);continue}let k=qs(b);if(k){let R=await $g(w,k.rev,k.path);if(R===null){let C=k.path.replace(/^\//,"");return $(`path '${C}' does not exist in '${k.rev}'`)}y.push(i?Y(R):R);continue}let E=await Be(w,b);if(!E)return pa(b,s);y.push(i?Y(E):E)}return{stdout:y.map(b=>`${b}
625
- `).join(""),stderr:"",exitCode:0}}})}function pa(e,t){return t?$("Needed a single revision"):Vt(e)}async function Cg(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 Be(e,t)?t:null}async function Og(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Be(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await F(e,o))return o}return t}async function $g(e,t,n){let r=await Be(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await ce(e,o.tree)).get(s)?.hash??null}se();_e();Ce();ie();Fe();ue();ve();function Xl(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:I().describe("Abort the current revert operation"),continue:I().describe("Continue the revert after conflict resolution"),"no-commit":I().alias("n").describe("Apply changes without creating a commit"),"no-edit":I().describe("Do not edit the commit message"),mainline:J.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let z=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(ee(z))return{stdout:"",stderr:z.message??"",exitCode:1};let N=await Ig(s,r.env);return N.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),N}if(n.continue){let z=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(ee(z))return{stdout:"",stderr:z.message??"",exitCode:1};let N=await Sg(s,r.env);return N.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),N}let i=n.commit;if(!i)return $("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await He(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Ze(s);if(M(d))return d;let m=await K(s),u=yn(m,"Reverting",`fatal: revert failed
626
- `);if(u)return u;let h=await j(s,d);if(s.workTree){let z=await ce(s,h.tree);if(xr(m,z))return L(`error: your local changes would be overwritten by revert.
628
+ `);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 Ng(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await de(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)ye(i,f)&&a.push(f);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
629
+ `);for(let f of a){let l=o.get(f);if(l)s=xt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Ie()}),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
630
+ `,exitCode:1};s=lt(s,f);let m=`${e.workTree}/${f}`;await e.fs.exists(m)&&await e.fs.rm(m)}}return await le(e,s),{stdout:"",stderr:"",exitCode:0}}ce();fe();me();pe();gn();He();function od(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(y=>y!==""),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,b=[];if(f){if(!w.workTree)return S("this operation must be run in a work tree");b.push(w.workTree)}if(l&&b.push(w.gitDir),d&&b.push(w.workTree?"true":"false"),m&&b.push(w.workTree?"false":"true"),u){if(!w.workTree)return S("this operation must be run in a work tree");let y=rt(w.workTree,r.cwd);b.push(y===""?"":`${y}/`)}if(h){if(!w.workTree)return S("this operation must be run in a work tree");let y=rt(r.cwd,w.workTree);b.push(y===""?"":`${y}/`)}if(p&&o.length===0)return{stdout:b.map(E=>`${E}
631
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return S("Needed a single revision");for(let y of o){if(a){let R=await _g(w,y);if(R===null)return ga(y,s);b.push(R);continue}if(c){let R=await Fg(w,y);if(R===null)return ga(y,s);b.push(R);continue}let E=qs(y);if(E){let R=await Ug(w,E.rev,E.path);if(R===null){let C=E.path.replace(/^\//,"");return S(`path '${C}' does not exist in '${E.rev}'`)}b.push(i?V(R):R);continue}let k=await Ke(w,y);if(!k)return ga(y,s);b.push(i?V(k):k)}return{stdout:b.map(y=>`${y}
632
+ `).join(""),stderr:"",exitCode:0}}})}function ga(e,t){return t?S("Needed a single revision"):Vt(e)}async function _g(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 Ke(e,t)?t:null}async function Fg(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Ke(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 Ug(e,t,n){let r=await Ke(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}ce();We();$e();fe();qe();pe();He();function id(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"),"no-commit":$().alias("n").describe("Apply changes without creating a commit"),"no-edit":$().describe("Do not edit the commit message"),mainline:Y.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let U=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commit:null});if(ee(U))return{stdout:"",stderr:U.message??"",exitCode:1};let N=await Bg(s,r.env);return N.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),N}if(n.continue){let U=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commit:null});if(ee(U))return{stdout:"",stderr:U.message??"",exitCode:1};let N=await Wg(s,r.env);return N.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:null,hadConflicts:!1}),N}let i=n.commit;if(!i)return S("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commit:i});if(ee(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await De(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=yn(m,"Reverting",`fatal: revert failed
633
+ `);if(u)return u;let h=await j(s,d);if(s.workTree){let U=await de(s,h.tree);if(Cr(m,U))return L(`error: your local changes would be overwritten by revert.
627
634
  hint: commit your changes or stash them to proceed.
628
635
  fatal: revert failed
629
636
  `,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return L(`error: commit ${f} is a merge but no -m option was given.
630
637
  fatal: revert failed
631
638
  `,128);if(p<1||p>l.parents.length)return L(`error: commit ${f} does not have parent ${p}
632
639
  fatal: revert failed
633
- `,128);let z=l.parents[p-1];g=(await j(s,z)).tree}else if(l.parents.length===0)g=await Ge(s,[]);else{let z=l.parents[0];g=(await j(s,z)).tree}let w=Y(f),y=fe(l.message),x=Tg(l,f,p),b=await ke(s,"merge.conflictstyle")??"merge",k={a:"HEAD",b:y?`parent of ${w} (${y})`:`parent of ${w}`,conflictStyle:b},E=await Ft(s,l.tree,h.tree,g,k);if(E.conflicts.length===0&&E.resultTree===h.tree){let z=E.messages.length>0?`${E.messages.join(`
640
+ `,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=V(f),b=ue(l.message),x=qg(l,f,p),y=await xe(s,"merge.conflictstyle")??"merge",E={a:"HEAD",b:b?`parent of ${w} (${b})`:`parent of ${w}`,conflictStyle:y},k=await Ut(s,l.tree,h.tree,g,E);if(k.conflicts.length===0&&k.resultTree===h.tree){let U=k.messages.length>0?`${k.messages.join(`
634
641
  `)}
635
- `:"",N=await rt(s,{fromCommit:!0}),U=await F(s,"CHERRY_PICK_HEAD");return{stdout:`${z}${N}`,stderr:U?`The previous cherry-pick is now empty, possibly due to conflict resolution.
642
+ `:"",N=await at(s,{fromCommit:!0}),K=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${U}${N}`,stderr:K?`The previous cherry-pick is now empty, possibly due to conflict resolution.
636
643
  If you wish to commit it anyway, use:
637
644
 
638
645
  git commit --allow-empty
639
646
 
640
647
  Otherwise, please use 'git cherry-pick --skip'
641
- `:"",exitCode:1}}let R=await xn(s,E,h.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!R.ok)return R;if(E.conflicts.length>0){await X(s,"REVERT_HEAD",f),await X(s,"ORIG_HEAD",d),await Te(s,"MERGE_MSG",x);let z=E.messages.join(`
642
- `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:z?`${z}
643
- `:"",stderr:`error: could not revert ${w}... ${fe(l.message)}
648
+ `:"",exitCode:1}}let R=await Cn(s,k,h.tree,{labels:E,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!R.ok)return R;if(k.conflicts.length>0){await X(s,"REVERT_HEAD",f),await X(s,"ORIG_HEAD",d),await Ae(s,"MERGE_MSG",x);let U=k.messages.join(`
649
+ `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:U?`${U}
650
+ `:"",stderr:`error: could not revert ${w}... ${ue(l.message)}
644
651
  hint: After resolving the conflicts, mark them with
645
652
  hint: "git add/rm <pathspec>", then run
646
653
  hint: "git revert --continue".
@@ -648,28 +655,28 @@ hint: You can instead skip this commit with "git revert --skip".
648
655
  hint: To abort and get back to the state before "git revert",
649
656
  hint: run "git revert --abort".
650
657
  hint: Disable this message with "git config set advice.mergeConflict false"
651
- `,exitCode:1}}if(n["no-commit"])return await X(s,"REVERT_HEAD",f),await Te(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let C=R.mergedTreeHash,P=await an(s,r.env);if(M(P))return P;let v=await Qe(s,r.env);if(M(v))return v;let D=await ht(s,C,[d],P,v,x);await jt(s),await Mt(s);let O=await Q(s),H=fe(x),G=O?.type==="symbolic"?O.target:"HEAD";await re(s,r.env,G,d,D,`revert: ${H}`,O?.type==="symbolic");let A=O?.type==="symbolic"?Re(O.target):"detached HEAD",S=await fn(s,h.tree,C,P,v,P.timestamp!==v.timestamp||P.timezone!==v.timezone),_=Ht(A,D,x),B=E.messages.length>0?`${E.messages.join(`
658
+ `,exitCode:1}}if(n["no-commit"])return await X(s,"REVERT_HEAD",f),await Ae(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let C=R.mergedTreeHash,P=await an(s,r.env);if(M(P))return P;let H=await tt(s,r.env);if(M(H))return H;let D=await wt(s,C,[d],P,H,x);await Lt(s),await Gt(s);let O=await Q(s),A=ue(x),G=O?.type==="symbolic"?O.target:"HEAD";await ae(s,r.env,G,d,D,`revert: ${A}`,O?.type==="symbolic");let v=O?.type==="symbolic"?Ce(O.target):"detached HEAD",T=await fn(s,h.tree,C,P,H,P.timestamp!==H.timestamp||P.timezone!==H.timezone),F=Dt(v,D,x),_=k.messages.length>0?`${k.messages.join(`
652
659
  `)}
653
- `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:D,hadConflicts:!1}),{stdout:`${B}${_}
654
- ${S}`,stderr:"",exitCode:0}}})}async function Ig(e,t){return await F(e,"REVERT_HEAD")?Nn(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
660
+ `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:D,hadConflicts:!1}),{stdout:`${_}${F}
661
+ ${T}`,stderr:"",exitCode:0}}})}async function Bg(e,t){return await B(e,"REVERT_HEAD")?_n(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
655
662
  fatal: revert failed
656
- `,128),operationName:"revert",clearState:async o=>{await jt(o),await Mt(o)},origHeadAsTargetRev:!0}):await F(e,"CHERRY_PICK_HEAD")?Nn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
663
+ `,128),operationName:"revert",clearState:async o=>{await Lt(o),await Gt(o)},origHeadAsTargetRev:!0}):await B(e,"CHERRY_PICK_HEAD")?_n(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
657
664
  fatal: revert failed
658
- `,128),operationName:"revert",clearState:Mt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
665
+ `,128),operationName:"revert",clearState:Gt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
659
666
  fatal: revert failed
660
- `,128)}async function Sg(e,t){if(!await F(e,"REVERT_HEAD"))return L(`error: no cherry-pick or revert in progress
667
+ `,128)}async function Wg(e,t){if(!await B(e,"REVERT_HEAD"))return L(`error: no cherry-pick or revert in progress
661
668
  fatal: revert failed
662
- `,128);let r=await K(e),o=yn(r,"Committing");if(o)return o;let s=await Pe(e,"MERGE_MSG");if(!s)return L(`Aborting commit due to empty commit message.
663
- `,1);let i=De(r),a=await Ge(e,i),c=await Ze(e);if(M(c))return c;let f=await j(e,c),l=await an(e,t);if(M(l))return l;let d=await Qe(e,t);if(M(d))return d;let m=await F(e,"CHERRY_PICK_HEAD");m&&(l=(await j(e,m)).author);let u=At(s),h=await ht(e,a,[c],l,d,u);await jt(e),await Mt(e);let p=await Q(e),g=fe(u),w=p?.type==="symbolic"?p.target:"HEAD";await re(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let y=p?.type==="symbolic"?Re(p.target):"detached HEAD",x=await fn(e,f.tree,a,l,d,l.timestamp!==d.timestamp||l.timezone!==d.timezone);return{stdout:`${Ht(y,h,s)}
664
- ${x}`,stderr:"",exitCode:0}}function Tg(e,t,n){let r=fe(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
669
+ `,128);let r=await z(e),o=yn(r,"Committing");if(o)return o;let s=await Oe(e,"MERGE_MSG");if(!s)return L(`Aborting commit due to empty commit message.
670
+ `,1);let i=Ge(r),a=await Fe(e,i),c=await Qe(e);if(M(c))return c;let f=await j(e,c),l=await an(e,t);if(M(l))return l;let d=await tt(e,t);if(M(d))return d;let m=await B(e,"CHERRY_PICK_HEAD");m&&(l=(await j(e,m)).author);let u=Mt(s),h=await wt(e,a,[c],l,d,u);await Lt(e),await Gt(e);let p=await Q(e),g=ue(u),w=p?.type==="symbolic"?p.target:"HEAD";await ae(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let b=p?.type==="symbolic"?Ce(p.target):"detached HEAD",x=await fn(e,f.tree,a,l,d,l.timestamp!==d.timestamp||l.timezone!==d.timezone);return{stdout:`${Dt(b,h,s)}
671
+ ${x}`,stderr:"",exitCode:0}}function qg(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
665
672
 
666
673
  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
667
674
  changes made to ${c}`}return a+=`.
668
- `,a}se();Ce();ie();le();ue();er();ve();function Zl(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:I().describe("Only remove from the index"),recursive:I().alias("r").describe("Allow recursive removal when a directory name is given"),force:I().alias("f").describe("Override the up-to-date check"),dryRun:I().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Xe(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return L("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,m=await t?.hooks?.preRm?.({repo:s,paths:c,cached:f,recursive:l,force:d});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let u=await K(s),h=[],p=mt(s,r.cwd);for(let y of c){if(or(y)){let E=[Ue(y,p)],R=u.entries.filter(C=>ye(E,C.path));if(R.length===0)return $(`pathspec '${y}' did not match any files`);for(let C of R)h.push(C.path);continue}let x=$t(r.cwd,y),b=ft(a,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return $(`'${y}' is outside repository at '${a}'`);if(await r.fs.exists(x)&&!(await lt(r.fs,x)).isSymbolicLink&&(await lt(r.fs,x)).isDirectory){if(!l)return $(`not removing '${b}' recursively without -r`);let E=b===""?"":`${b}/`,R=u.entries.filter(C=>E===""||C.path.startsWith(E));if(R.length===0)return $(`pathspec '${y}' did not match any files`);for(let C of R)h.push(C.path)}else{if(!u.entries.some(R=>R.path===b))return $(`pathspec '${y}' did not match any files`);h.push(b)}}if(!d){let y=await vg(s,u,h,f);if(y)return y}if(n.dryRun){let y=h.map(b=>`rm '${b}'`);return{stdout:y.length>0?`${y.join(`
675
+ `,a}ce();$e();fe();me();pe();tr();He();function ad(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=Je(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return L("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,m=await t?.hooks?.preRm?.({repo:s,paths:c,cached:f,recursive:l,force:d});if(ee(m))return{stdout:"",stderr:m.message??"",exitCode:1};let u=await z(s),h=[],p=ut(s,r.cwd);for(let b of c){if(ir(b)){let k=[Ue(b,p)],R=u.entries.filter(C=>ye(k,C.path));if(R.length===0)return S(`pathspec '${b}' did not match any files`);for(let C of R)h.push(C.path);continue}let x=vt(r.cwd,b),y=rt(a,x);if((y==="."||y==="")&&(y=""),y.startsWith(".."))return S(`'${b}' is outside repository at '${a}'`);if(await r.fs.exists(x)&&!(await mt(r.fs,x)).isSymbolicLink&&(await mt(r.fs,x)).isDirectory){if(!l)return S(`not removing '${y}' recursively without -r`);let k=y===""?"":`${y}/`,R=u.entries.filter(C=>k===""||C.path.startsWith(k));if(R.length===0)return S(`pathspec '${b}' did not match any files`);for(let C of R)h.push(C.path)}else{if(!u.entries.some(R=>R.path===y))return S(`pathspec '${b}' did not match any files`);h.push(y)}}if(!d){let b=await zg(s,u,h,f);if(b)return b}if(n.dryRun){let b=h.map(y=>`rm '${y}'`);return{stdout:b.length>0?`${b.join(`
669
676
  `)}
670
- `:"",stderr:"",exitCode:0}}let g=[];for(let y of h){if(u=at(u,y),!f){let x=T(a,y);await lt(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}g.push(`rm '${y}'`)}await ae(s,u);let w=g.length>0?`${g.join(`
677
+ `:"",stderr:"",exitCode:0}}let g=[];for(let b of h){if(u=lt(u,b),!f){let x=I(a,b);await mt(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}g.push(`rm '${b}'`)}await le(s,u);let w=g.length>0?`${g.join(`
671
678
  `)}
672
- `:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function vg(e,t,n,r){let o=await Z(e),s=new Map;if(o){let f=await j(e,o),l=await Ve(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(h=>h.path===f&&h.stage===0);if(!l)continue;let m=s.get(f)!==l.hash,u=!1;if(e.workTree){let h=T(e.workTree,f),p=!1;try{await lt(e.fs,h),p=!0}catch{p=!1}p&&(u=await jn(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(`
679
+ `:"";return await t?.hooks?.postRm?.({repo:s,removedPaths:h,cached:f}),{stdout:w,stderr:"",exitCode:0}}})}async function zg(e,t,n,r){let o=await Z(e),s=new Map;if(o){let f=await j(e,o),l=await ze(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=I(e.workTree,f),p=!1;try{await mt(e.fs,h),p=!0}catch{p=!1}p&&(u=await Gn(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(`
673
680
  `),l=i.length===1?"the following file has":"the following files have";return L(`error: ${l} staged content different from both the
674
681
  file and the HEAD:
675
682
  ${f}
@@ -682,40 +689,40 @@ ${f}
682
689
  `),l=c.length===1?"the following file has":"the following files have";return L(`error: ${l} local modifications:
683
690
  ${f}
684
691
  (use --cached to keep the file, or -f to force removal)
685
- `)}return null}se();ie();gn();zs();le();ve();var ga=new TextDecoder;function Jl(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:I().alias("p").describe("Show diff in patch format"),noPatch:I().describe("Suppress diff output"),stat:I().describe("Show diffstat summary"),nameOnly:I().describe("Show only names of changed files"),nameStatus:I().describe("Show names and status of changed files"),shortstat:I().describe("Show only the shortstat summary line"),numstat:I().describe("Machine-readable insertions/deletions per file"),format:J.string().describe("Pretty-print format string"),pretty:J.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=qs(a);if(c)return Hg(s,c.rev,c.path);if(a==="HEAD"){let p=await Ze(s);if(M(p))return p}let f=await vt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await we(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=Lo(m);u=p.formatStr,h=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await Ql(s,f,p,d,u,h),stderr:"",exitCode:0}}case"tag":{let p=await Pc(s,f);return{stdout:await Ag(s,p,d,u,h),stderr:"",exitCode:0}}case"tree":{let p=Gn(l.content);return{stdout:ed(p),stderr:"",exitCode:0}}case"blob":return{stdout:ga.decode(l.content),stderr:"",exitCode:0}}}})}async function Hg(e,t,n){let r=await He(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await ce(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=T(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return $(f)}let c=await we(e,a.hash);if(c.type==="blob")return{stdout:ga.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=Gn(c.content);return{stdout:ed(f),stderr:"",exitCode:0}}return{stdout:ga.decode(c.content),stderr:"",exitCode:0}}async function Ql(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Es(o,{hash:t,commit:n});else if(s!==null)i=ks(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=>Y(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Nt(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
692
+ `)}return null}ce();fe();gn();zs();me();He();var wa=new TextDecoder;function cd(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:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=qs(a);if(c)return Kg(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await gt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await Ee(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=No(m);u=p.formatStr,h=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await fd(s,f,p,d,u,h),stderr:"",exitCode:0}}case"tag":{let p=await Pc(s,f);return{stdout:await Vg(s,p,d,u,h),stderr:"",exitCode:0}}case"tree":{let p=Ln(l.content);return{stdout:ld(p),stderr:"",exitCode:0}}case"blob":return{stdout:wa.decode(l.content),stderr:"",exitCode:0}}}})}async function Kg(e,t,n){let r=await De(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=I(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return S(f)}let c=await Ee(e,a.hash);if(c.type==="blob")return{stdout:wa.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=Ln(c.content);return{stdout:ld(f),stderr:"",exitCode:0}}return{stdout:wa.decode(c.content),stderr:"",exitCode:0}}async function fd(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Rs(o,{hash:t,commit:n});else if(s!==null)i=xs(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=>V(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Rn(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
686
693
  `))c.push(` ${l}`);i=c.join(`
687
694
  `)}if(!r)return`${i}
688
- `;let a="";if(n.parents.length<=1){let c=n.parents.length===1?(await j(e,n.parents[0])).tree:null,f=await We(e,c,n.tree),{remaining:l,renames:d}=await nt(e,f);a=await Dg(e,l,d,r)}else r==="patch"&&(a=await Bg(e,n)??"");return a?`${i}
695
+ `;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 Yg(e,l,d,r)}else r==="patch"&&(a=await sw(e,n)??"");return a?`${i}
689
696
 
690
697
  ${a.replace(/\n$/,"")}
691
698
  `:n.parents.length>=2?`${i}
692
699
 
693
700
  `:`${i}
694
- `}async function Ag(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: ${Nt(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
695
- `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await Ql(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
701
+ `}async function Vg(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: ${Rn(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
702
+ `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await fd(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
696
703
  `)}
697
- `}function ed(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(`
704
+ `}function ld(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(`
698
705
  `)}
699
- `:""}async function Dg(e,t,n,r){switch(r){case"patch":return Ug(e,t,n);case"stat":return Gg(e,t,n);case"shortstat":return Lg(e,t,n);case"numstat":return Ng(e,t,n);case"name-only":return Mg(t,n);case"name-status":return jg(t,n);default:return""}}function Mg(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(`
706
+ `:""}async function Yg(e,t,n,r){switch(r){case"patch":return rw(e,t,n);case"stat":return Jg(e,t,n);case"shortstat":return Qg(e,t,n);case"numstat":return ew(e,t,n);case"name-only":return Xg(t,n);case"name-status":return Zg(t,n);default:return""}}function Xg(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(`
700
707
  `)}
701
- `:""}function jg(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}
702
- `).join(""):""}async function Gg(e,t,n){let{fileStats:r}=await Kn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),dr(r)}async function Lg(e,t,n){let{fileStats:r}=await Kn(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}
703
- `:""}async function Ng(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:cn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Ie(i)||Ie(a))o+=`- - ${s.display}
704
- `;else{let c=bt(i),f=bt(a),l=st(c,f),d=0,m=0;for(let u of l)u.type==="insert"?d++:u.type==="delete"&&m++;o+=`${d} ${m} ${s.display}
705
- `}}return o}async function _g(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Pt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function Fg(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Pt({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 Ug(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 Fg(e,s.entry):o+=await _g(e,s.entry);return o}async function Bg(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await j(e,a);return ce(e,c.tree)})),r=await ce(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(d=>(d.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await Wg(e,a,n,r);return i}async function Wg(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 oe(e,m):"")),d=i?await oe(e,i):"";return Ho({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}se();Ce();ie();ue();se();$n();Ce();ie();mn();le();Fe();ue();ve();on();tt();var Xt="refs/stash";function ba(e,t){return Oe(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function td(e){let t=await Je(e,Xt),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 Mr(e,t){let n=await Je(e,Xt);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 nd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Z(e);if(!s)return null;let i=await j(e,s),a=await K(e),c=De(a),f=await Ge(e,c),l=await We(e,i.tree,f),d=new Map(c.map(N=>[N.path,N])),m=await et(e,o,"",{skipIgnore:!0}),u=!1;for(let N of m){let U=d.get(N);if(!U)continue;let V=T(o,N),be=await e.fs.readFileBuffer(V);if(await ut("blob",be)!==U.hash){u=!0;break}}if(!u)for(let[N]of d){let U=T(o,N);if(!await e.fs.exists(U)){u=!0;break}}let h=[];if(r?.includeUntracked){let N=await et(e,o,"");for(let U of N)d.has(U)||h.push(U)}if(l.length===0&&!u&&h.length===0)return null;let p=await As(e,t),g=await _r(e,t),w=await Q(e),y=w?.type==="symbolic"?Re(w.target):"(no branch)",x=Y(s),b=fe(i.message),k=`index on ${y}: ${x} ${b}
706
- `,E=nn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),R=await Se(e,"commit",E),C=await ce(e,i.tree),P=[],v=new Set;for(let N of m){let U=d.get(N),V=C.get(N);if(!U&&!V)continue;let be=T(o,N),Le=await e.fs.readFileBuffer(be),it=await Se(e,"blob",Le),me=U?U.mode:parseInt(V?.mode??"100644",8);P.push({path:N,mode:me,hash:it,stage:0,stat:$e()}),v.add(N)}for(let[N,U]of d)v.has(N)||C.has(N)||P.push({path:N,mode:U.mode,hash:U.hash,stage:0,stat:$e()});let D=await Ge(e,P),O=null;if(r?.includeUntracked){let N=[];for(let Le of h){let it=T(o,Le),me=await e.fs.readFileBuffer(it),xe=await Se(e,"blob",me);N.push({path:Le,mode:33188,hash:xe,stage:0,stat:$e()})}let U=await Ge(e,N),V=`untracked files on ${y}: ${x} ${b}
707
- `,be=nn({type:"commit",tree:U,parents:[],author:p,committer:g,message:V});O=await Se(e,"commit",be)}let H=n?`On ${y}: ${n}`:`WIP on ${y}: ${x} ${b}`,G=[s,R];O&&G.push(O);let A=nn({type:"commit",tree:D,parents:G,author:p,committer:g,message:H}),S=await Se(e,"commit",A),_=await Mr(e,0)??te;await Ke(e,Xt,{oldHash:_,newHash:S,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:H.trimEnd()}),await X(e,Xt,S);let B=await bn(e,i.tree,a);await ae(e,{version:2,entries:B.newEntries}),await Me(e,B.worktreeOps),(await Q(e))?.type==="symbolic"&&await re(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let N of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await de(e,N);for(let N of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let U=T(e.gitDir,N);await e.fs.exists(U)&&await e.fs.rm(U)}if(h.length>0)for(let N of h){if(C.has(N))continue;let U=T(o,N);await e.fs.exists(U)&&(await e.fs.rm(U),await rr(e.fs,Jt(U),o))}return S}async function wa(e,t){let n=e.workTree,r=await j(e,t),o=await Ve(e,r.tree),s=[];for(let i of o){let a=T(n,i.path);await e.fs.exists(a)?s.push(i.path):await ct(e,i)}return s.length>0?(s.sort(ba),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
708
+ `:""}function Zg(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}
709
+ `).join(""):""}async function Jg(e,t,n){let{fileStats:r}=await Vn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),ur(r)}async function Qg(e,t,n){let{fileStats:r}=await Vn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Kn(r.length,o,s);return i?`${i}
710
+ `:""}async function ew(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:cn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(ve(i)||ve(a))o+=`- - ${s.display}
711
+ `;else{let c=kt(i),f=kt(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}
712
+ `}}return o}async function tw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ot({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function nw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ot({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 rw(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 nw(e,s.entry):o+=await tw(e,s.entry);return o}async function sw(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 ow(e,a,n,r);return i}async function ow(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 oe(e,m):"")),d=i?await oe(e,i):"";return Ho({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}ce();$e();fe();pe();ce();Sn();$e();fe();mn();me();qe();pe();He();on();ot();var Xt="refs/stash";function ya(e,t){return Se(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function dd(e){let t=await et(e,Xt),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 jr(e,t){let n=await et(e,Xt);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 ud(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Z(e);if(!s)return null;let i=await j(e,s),a=await z(e),c=Ge(a),f=await Fe(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(N=>[N.path,N])),m=await st(e,o,"",{skipIgnore:!0}),u=!1;for(let N of m){let K=d.get(N);if(!K)continue;let ne=I(o,N),J=await e.fs.readFileBuffer(ne);if(await pt("blob",J)!==K.hash){u=!0;break}}if(!u)for(let[N]of d){let K=I(o,N);if(!await e.fs.exists(K)){u=!0;break}}let h=[];if(r?.includeUntracked){let N=await st(e,o,"");for(let K of N)d.has(K)||h.push(K)}if(l.length===0&&!u&&h.length===0)return null;let p=await As(e,t),g=await Ur(e,t),w=await Q(e),b=w?.type==="symbolic"?Ce(w.target):"(no branch)",x=V(s),y=ue(i.message),E=`index on ${b}: ${x} ${y}
713
+ `,k=nn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:E}),R=await Te(e,"commit",k),C=await de(e,i.tree),P=[],H=new Set;for(let N of m){let K=d.get(N),ne=C.get(N);if(!K&&!ne)continue;let J=I(o,N),re=await e.fs.readFileBuffer(J),ke=await Te(e,"blob",re),Me=K?K.mode:parseInt(ne?.mode??"100644",8);P.push({path:N,mode:Me,hash:ke,stage:0,stat:Ie()}),H.add(N)}for(let[N,K]of d)H.has(N)||C.has(N)||P.push({path:N,mode:K.mode,hash:K.hash,stage:0,stat:Ie()});let D=await Fe(e,P),O=null;if(r?.includeUntracked){let N=[];for(let re of h){let ke=I(o,re),Me=await e.fs.readFileBuffer(ke),ie=await Te(e,"blob",Me);N.push({path:re,mode:33188,hash:ie,stage:0,stat:Ie()})}let K=await Fe(e,N),ne=`untracked files on ${b}: ${x} ${y}
714
+ `,J=nn({type:"commit",tree:K,parents:[],author:p,committer:g,message:ne});O=await Te(e,"commit",J)}let A=n?`On ${b}: ${n}`:`WIP on ${b}: ${x} ${y}`,G=[s,R];O&&G.push(O);let v=nn({type:"commit",tree:D,parents:G,author:p,committer:g,message:A}),T=await Te(e,"commit",v),F=await jr(e,0)??te;await Xe(e,Xt,{oldHash:F,newHash:T,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:A.trimEnd()}),await X(e,Xt,T);let _=await bn(e,i.tree,a);await le(e,{version:2,entries:_.newEntries}),await Ne(e,_.worktreeOps),(await Q(e))?.type==="symbolic"&&await ae(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let N of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,N);for(let N of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let K=I(e.gitDir,N);await e.fs.exists(K)&&await e.fs.rm(K)}if(h.length>0)for(let N of h){if(C.has(N))continue;let K=I(o,N);await e.fs.exists(K)&&(await e.fs.rm(K),await sr(e.fs,Jt(K),o))}return T}async function ba(e,t){let n=e.workTree,r=await j(e,t),o=await ze(e,r.tree),s=[];for(let i of o){let a=I(n,i.path);await e.fs.exists(a)?s.push(i.path):await dt(e,i)}return s.length>0?(s.sort(ya),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
708
715
  `)}
709
716
  error: could not restore untracked files from stash
710
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function ya(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
711
- `,exitCode:128};let n=await Mr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
717
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ea(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
718
+ `,exitCode:128};let n=await jr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
712
719
  `,exitCode:1};if(!await Z(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
713
- `,exitCode:1};let o=await K(e),s=Bt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
720
+ `,exitCode:1};let o=await z(e),s=Bt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
714
721
  `)}
715
722
  `,stderr:`error: could not write index
716
723
  `,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)
717
- `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=De(o),d=await Ge(e,l),m={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let R=await wa(e,f);if(!R.ok)return{...R,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let u=await Ft(e,c.tree,d,i.tree,m),h=await ce(e,d),p=await ce(e,u.resultTree),g=[];for(let[R,C]of p){let P=h.get(R);(!P||P.hash!==C.hash)&&g.push({path:R,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[R]of h)p.has(R)||g.push({path:R,type:"delete"});let w=new Map(l.map(R=>[R.path,R])),y=[],x=[];for(let R of g){let C=w.get(R.path),P=T(e.workTree,R.path);if(C){if(!await e.fs.exists(P))continue;let v=await e.fs.readFileBuffer(P);await ut("blob",v)!==C.hash&&y.push(R.path)}else R.type==="checkout"&&await e.fs.exists(P)&&x.push(R.path)}if(y.length>0||x.length>0){y.sort(ba),x.sort(ba);let R="";if(y.length>0&&(R+=`error: Your local changes to the following files would be overwritten by merge:
718
- ${y.map(C=>` ${C}`).join(`
724
+ `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Ge(o),d=await Fe(e,l),m={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let R=await ba(e,f);if(!R.ok)return{...R,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let u=await Ut(e,c.tree,d,i.tree,m),h=await de(e,d),p=await de(e,u.resultTree),g=[];for(let[R,C]of p){let P=h.get(R);(!P||P.hash!==C.hash)&&g.push({path:R,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[R]of h)p.has(R)||g.push({path:R,type:"delete"});let w=new Map(l.map(R=>[R.path,R])),b=[],x=[];for(let R of g){let C=w.get(R.path),P=I(e.workTree,R.path);if(C){if(!await e.fs.exists(P))continue;let H=await e.fs.readFileBuffer(P);await pt("blob",H)!==C.hash&&b.push(R.path)}else R.type==="checkout"&&await e.fs.exists(P)&&x.push(R.path)}if(b.length>0||x.length>0){b.sort(ya),x.sort(ya);let R="";if(b.length>0&&(R+=`error: Your local changes to the following files would be overwritten by merge:
725
+ ${b.map(C=>` ${C}`).join(`
719
726
  `)}
720
727
  Please commit your changes or stash them before you merge.
721
728
  `),x.length>0&&(R+=`error: The following untracked working tree files would be overwritten by merge:
@@ -723,46 +730,46 @@ ${x.map(C=>` ${C}`).join(`
723
730
  `)}
724
731
  Please move or remove them before you merge.
725
732
  `),R+=`Aborting
726
- `,f){let C=await wa(e,f);C.ok||(R+=C.stderr)}return{ok:!1,stdout:"",stderr:R,exitCode:1}}await Me(e,g);let b=new Set(u.conflicts.map(R=>R.path)),k=new Set;for(let R of u.entries)R.stage>0&&k.add(R.path);let E=b.size>0;if(E){let R=[];for(let[C,P]of p){if(b.has(C)||k.has(C))continue;let v=w.get(C);R.push({path:C,mode:parseInt(P.mode,8),hash:P.hash,stage:0,stat:v?.stat??$e()})}for(let C of u.entries)C.stage>0&&R.push(C);R.sort((C,P)=>Oe(C.path,P.path)||C.stage-P.stage),await ae(e,{version:2,entries:R})}else{let R=[...o.entries],C=new Set(R.map(P=>P.path));for(let[P,v]of p)h.has(P)||C.has(P)||R.push({path:P,mode:parseInt(v.mode,8),hash:v.hash,stage:0,stat:$e()});R.sort((P,v)=>Oe(P.path,v.path)||P.stage-v.stage),await ae(e,{version:2,entries:R})}if(f){let R=await wa(e,f);if(!R.ok)return{...R,messages:u.messages}}return{ok:!0,hasConflicts:E,messages:u.messages}}async function Ea(e,t=0){let n=await Je(e,Xt);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await de(e,Xt),await ts(e,Xt);else{await Mn(e,Xt,n);let o=n[n.length-1];o&&await X(e,Xt,o.newHash)}return null}async function rd(e){await de(e,Xt),await ts(e,Xt)}ve();function Fo(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 qg(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Pt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Yn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function Xn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function od(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:J.string().alias("m").describe("Stash message"),"include-untracked":I().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await sd(s,o.env,r.message,r["include-untracked"]);return await Xn(t,s,"push",a.exitCode===0),a}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:J.string().alias("m").describe("Stash message"),"include-untracked":I().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await sd(s,o.env,r.message,r["include-untracked"]);return await Xn(t,s,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"pop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await zg(s,r.stash);return await Xn(t,s,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"apply",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Kg(s,r.stash);return await Xn(t,s,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"list",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Vg(s);return await Xn(t,s,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"drop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Yg(s,r.stash);return await Xn(t,s,"drop",a.exitCode===0),a}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:I().alias("p").describe("Show full diff (default is --stat)")},args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"show",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Xg(s,r.stash,r.patch);return await Xn(t,s,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Yn(t,s,"clear",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await Zg(s);return await Xn(t,s,"clear",a.exitCode===0),a}})}async function sd(e,t,n,r){if(!await Z(e))return L(`You do not have the initial commit yet
727
- `);let s=await K(e),i=Bt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
733
+ `,f){let C=await ba(e,f);C.ok||(R+=C.stderr)}return{ok:!1,stdout:"",stderr:R,exitCode:1}}await Ne(e,g);let y=new Set(u.conflicts.map(R=>R.path)),E=new Set;for(let R of u.entries)R.stage>0&&E.add(R.path);let k=y.size>0;if(k){let R=[];for(let[C,P]of p){if(y.has(C)||E.has(C))continue;let H=w.get(C);R.push({path:C,mode:parseInt(P.mode,8),hash:P.hash,stage:0,stat:H?.stat??Ie()})}for(let C of u.entries)C.stage>0&&R.push(C);R.sort((C,P)=>Se(C.path,P.path)||C.stage-P.stage),await le(e,{version:2,entries:R})}else{let R=[...o.entries],C=new Set(R.map(P=>P.path));for(let[P,H]of p)h.has(P)||C.has(P)||R.push({path:P,mode:parseInt(H.mode,8),hash:H.hash,stage:0,stat:Ie()});R.sort((P,H)=>Se(P.path,H.path)||P.stage-H.stage),await le(e,{version:2,entries:R})}if(f){let R=await ba(e,f);if(!R.ok)return{...R,messages:u.messages}}return{ok:!0,hasConflicts:k,messages:u.messages}}async function ka(e,t=0){let n=await et(e,Xt);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,Xt),await rs(e,Xt);else{await jn(e,Xt,n);let o=n[n.length-1];o&&await X(e,Xt,o.newHash)}return null}async function md(e){await he(e,Xt),await rs(e,Xt)}He();function Bo(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 iw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ot({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Xn(e,t,n,r){return e?.hooks?.preStash?.({repo:t,action:n,ref:r})??null}async function Zn(e,t,n,r){await e?.hooks?.postStash?.({repo:t,action:n,ok:r})}function pd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await hd(s,o.env,r.message,r["include-untracked"]);return await Zn(t,s,"push",a.exitCode===0),a}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Y.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);if(M(s))return s;let i=await Xn(t,s,"push",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await hd(s,o.env,r.message,r["include-untracked"]);return await Zn(t,s,"push",a.exitCode===0),a}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"pop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await aw(s,r.stash);return await Zn(t,s,"pop",a.exitCode===0),a}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"apply",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await cw(s,r.stash);return await Zn(t,s,"apply",a.exitCode===0),a}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"list",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await fw(s);return await Zn(t,s,"list",a.exitCode===0),a}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"drop",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await lw(s,r.stash);return await Zn(t,s,"drop",a.exitCode===0),a}}),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);if(M(s))return s;let i=await Xn(t,s,"show",r.stash??null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await dw(s,r.stash,r.patch);return await Zn(t,s,"show",a.exitCode===0),a}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=await Xn(t,s,"clear",null);if(ee(i))return{stdout:"",stderr:i.message??"",exitCode:1};let a=await uw(s);return await Zn(t,s,"clear",a.exitCode===0),a}})}async function hd(e,t,n,r){if(!await Z(e))return L(`You do not have the initial commit yet
734
+ `);let s=await z(e),i=Bt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
728
735
  `)}
729
736
  `,stderr:`error: could not write index
730
- `,exitCode:1};let a;try{a=await nd(e,t,n,{includeUntracked:r})}catch(l){return $(l.message)}return a?{stdout:`Saved working directory and index state ${(await j(e,a)).message.trim()}
737
+ `,exitCode:1};let a;try{a=await ud(e,t,n,{includeUntracked:r})}catch(l){return S(l.message)}return a?{stdout:`Saved working directory and index state ${(await j(e,a)).message.trim()}
731
738
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
732
- `,stderr:"",exitCode:0}}async function zg(e,t){let n=Fo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Mr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await ya(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
739
+ `,stderr:"",exitCode:0}}async function aw(e,t){let n=Bo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await jr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await Ea(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
733
740
  `)}
734
741
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
735
- `,stderr:o.stderr,exitCode:o.exitCode};let l=await rt(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
742
+ `,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.
736
743
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
737
744
  `)}
738
- `:"",l=await rt(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
739
- `,stderr:"",exitCode:1}}let s=await Ea(e,n);if(s)return L(s);let i=o.messages.length>0?`${o.messages.join(`
745
+ `:"",l=await at(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
746
+ `,stderr:"",exitCode:1}}let s=await ka(e,n);if(s)return L(s);let i=o.messages.length>0?`${o.messages.join(`
740
747
  `)}
741
- `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await rt(e);return{stdout:`${i}${c}Dropped ${a} (${r})
742
- `,stderr:"",exitCode:0}}async function Kg(e,t){let n=Fo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await ya(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
748
+ `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await at(e);return{stdout:`${i}${c}Dropped ${a} (${r})
749
+ `,stderr:"",exitCode:0}}async function cw(e,t){let n=Bo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Ea(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
743
750
  `)}
744
- `:"",c=r.stdout;return c||(c=await rt(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
751
+ `:"",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(`
745
752
  `)}
746
- `:"",s=await rt(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Vg(e){let t=await td(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
753
+ `:"",s=await at(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function fw(e){let t=await dd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
747
754
  `)}
748
- `,stderr:"",exitCode:0}}async function Yg(e,t){let n=Fo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Mr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await Ea(e,n);return o?L(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
749
- `,stderr:"",exitCode:0}}async function Xg(e,t,n){let r=Fo(t);if(r<0)return L(`error: '${t}' is not a valid stash reference`);let o=await Mr(e,r);if(!o)return L(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return L("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await We(e,a.tree,s.tree),l="";for(let d of f)l+=await qg(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await ln(e,a.tree,s.tree),stderr:"",exitCode:0}}async function Zg(e){return await rd(e),{stdout:"",stderr:"",exitCode:0}}se();Ce();ue();tt();function id(e,t){e.command("status",{description:"Show the working tree status",options:{short:I().alias("s").describe("Give the output in the short-format"),porcelain:I().describe("Give the output in a machine-parseable format"),branch:I().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await rt(s),stderr:"",exitCode:0};let i=await Q(s),a=await Z(s),c;i&&i.type==="symbolic"?c=Re(i.target):c="HEAD detached";let f=await K(s),l=Mi(f),d=await Di(s,a,f,l),m=await Tt(s,f),u=[],h=[];for(let y of m)y.status==="untracked"?h.push(y.path):u.push({path:y.path,status:y.status});u.sort((y,x)=>Oe(y.path,x.path));let p=new Set(f.entries.map(y=>y.path)),g=ji(h,p);return{stdout:tw(c,d,u,l,g,n.branch),stderr:"",exitCode:0}}})}var Jg={"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 Qg(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function ew(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function tw(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(m=>[m.path,m])),c=new Map(t.map(m=>[m.path,m])),f=new Map(n.map(m=>[m.path,m])),l=new Set;for(let m of r)l.add(m.path);for(let m of t)l.add(m.path);for(let m of n)l.add(m.path);let d=[...l].sort();for(let m of d){let u=a.get(m);if(u){let y=Jg[u.status]??"UU";i.push(`${y} ${Rs(m)}`);continue}let h=c.get(m),p=f.get(m),g=h?Qg(h.status):" ",w=p?ew(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let y=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,y),b=h.displayPath.slice(y+4);i.push(`${g}${w} ${Rs(x)} -> ${Rs(b)}`)}else i.push(`${g}${w} ${Rs(m)}`)}for(let m of o)i.push(`?? ${Rs(m)}`);return i.length===0?"":`${i.join(`
755
+ `,stderr:"",exitCode:0}}async function lw(e,t){let n=Bo(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await jr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await ka(e,n);return o?L(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
756
+ `,stderr:"",exitCode:0}}async function dw(e,t,n){let r=Bo(t);if(r<0)return L(`error: '${t}' is not a valid stash reference`);let o=await jr(e,r);if(!o)return L(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return L("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 iw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await ln(e,a.tree,s.tree),stderr:"",exitCode:0}}async function uw(e){return await md(e),{stdout:"",stderr:"",exitCode:0}}ce();$e();pe();ot();function gd(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 Z(s),c;i&&i.type==="symbolic"?c=Ce(i.target):c="HEAD detached";let f=await z(s),l=Gi(f),d=await ji(s,a,f,l),m=await At(s,f),u=[],h=[];for(let b of m)b.status==="untracked"?h.push(b.path):u.push({path:b.path,status:b.status});u.sort((b,x)=>Se(b.path,x.path));let p=new Set(f.entries.map(b=>b.path)),g=Li(h,p);return{stdout:gw(c,d,u,l,g,n.branch),stderr:"",exitCode:0}}})}var mw={"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 hw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function pw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function gw(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(m=>[m.path,m])),c=new Map(t.map(m=>[m.path,m])),f=new Map(n.map(m=>[m.path,m])),l=new Set;for(let m of r)l.add(m.path);for(let m of t)l.add(m.path);for(let m of n)l.add(m.path);let d=[...l].sort();for(let m of d){let u=a.get(m);if(u){let b=mw[u.status]??"UU";i.push(`${b} ${Cs(m)}`);continue}let h=c.get(m),p=f.get(m),g=h?hw(h.status):" ",w=p?pw(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let b=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,b),y=h.displayPath.slice(b+4);i.push(`${g}${w} ${Cs(x)} -> ${Cs(y)}`)}else i.push(`${g}${w} ${Cs(m)}`)}for(let m of o)i.push(`?? ${Cs(m)}`);return i.length===0?"":`${i.join(`
750
757
  `)}
751
- `}function Rs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}se();_e();Ce();ie();Fe();ue();ve();on();function nw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??te}function cd(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:J.string().alias("c").describe("Create and switch to a new branch"),forceCreate:J.string().alias("C").describe("Create/reset and switch to a branch"),detach:I().alias("d").describe("Detach HEAD at named commit"),orphan:J.string().describe("Create a new orphan branch"),guess:I().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await 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?$("--orphan and -c/-C are incompatible"):n.detach?$("--orphan and --detach are incompatible"):ow(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return $("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await He(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 ad(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return $("missing branch or commit argument");if(a==="-")return rw(i,r.env,t);let c=`refs/heads/${a}`,f=await F(i,c);if(f)return fd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await go(i,a);if(l)return ad(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return $(`invalid reference: ${a}`)}})}async function xs(e){return await Pe(e,"CHERRY_PICK_HEAD")?$(`cannot switch branch while cherry-picking
752
- Consider "git cherry-pick --quit" or "git worktree add".`):await Pe(e,"MERGE_HEAD")?$(`cannot switch branch while merging
753
- Consider "git merge --quit" or "git worktree add".`):await Pe(e,"REVERT_HEAD")?$(`cannot switch branch while reverting
754
- Consider "git revert --quit" or "git worktree add".`):await Gt(e)?$(`cannot switch branch while rebasing
755
- Consider "git rebase --quit" or "git worktree add".`):null}async function rw(e,t,n){let r=await xs(e);if(r)return r;let o=await lo(e);return o?fd(e,o.name,o.refName,o.hash,t,n):$("no previous branch")}async function ad(e,t,n,r,o,s,i){if(!pn(t))return $(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await F(e,a);if(c&&!n)return $(`a branch named '${t}' already exists`);let f;if(r){let P=await He(e,r,`invalid reference: ${r}`);if(M(P))return P;f=P.hash}else{let P=await Z(e);if(!P){let v=await Q(e),D=v?.type==="symbolic"?v.target.replace(/^refs\/heads\//,""):"";n&&c&&await de(e,a),await ze(e,"HEAD",a),await pt(e);let O=await kn(e);return await re(e,o,"HEAD",null,te,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
756
- ${O}`,exitCode:0}}f=P}let l=await xs(e);if(l)return l;let d=await Z(e),m=await K(e);if(r){let P=Fn(m);if(P)return P}let u=await j(e,f);if(d&&d!==f){let P=await j(e,d);if(P.tree!==u.tree){let v=await Ln(e,P.tree,u.tree,m);if(!v.success)return v.errorOutput??L("error: checkout would overwrite local changes");m={version:2,entries:v.newEntries},await ae(e,m),await Me(e,v.worktreeOps)}}let h=await Q(e),p="";h?.type==="direct"&&d&&(p=await ho(e,d,f));let g=nw(h,d);await X(e,a,f),await ze(e,"HEAD",a),await pt(e);let w=await kn(e),y=r??"HEAD";n&&c?c!==f&&await re(e,o,a,c,f,`branch: Reset to ${y}`):await re(e,o,a,null,f,`branch: Created from ${y}`),await re(e,o,"HEAD",d,f,`checkout: moving from ${g} to ${t}`);let x="";if(i){let P=i.replace(/^refs\/remotes\//,"").split("/"),v=P[0]??"",D=`refs/heads/${P.slice(1).join("/")}`,O=await he(e);O[`branch "${t}"`]={...O[`branch "${t}"`],remote:v,merge:D},await Ye(e,O),x=`branch '${t}' set up to track '${v}/${P.slice(1).join("/")}'.
757
- `}else r&&(x=await po(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:d,newHead:f,isBranchCheckout:!0});let b=n&&c?`Switched to and reset branch '${t}'
758
+ `}function Cs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}ce();We();$e();fe();qe();pe();He();on();function ww(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??te}function bd(e,t){e.command("switch",{description:"Switch branches",args:[q.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:Y.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Y.string().alias("C").describe("Create/reset and switch to a branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:Y.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?S("--orphan and -c/-C are incompatible"):n.detach?S("--orphan and --detach are incompatible"):Ew(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return S("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await De(i,l,`invalid reference: ${l}`);return M(d)?d:yw(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 wd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return S("missing branch or commit argument");if(a==="-")return bw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return yd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await go(i,a);if(l)return wd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return S(`invalid reference: ${a}`)}})}async function Ps(e){return await Oe(e,"CHERRY_PICK_HEAD")?S(`cannot switch branch while cherry-picking
759
+ Consider "git cherry-pick --quit" or "git worktree add".`):await Oe(e,"MERGE_HEAD")?S(`cannot switch branch while merging
760
+ Consider "git merge --quit" or "git worktree add".`):await Oe(e,"REVERT_HEAD")?S(`cannot switch branch while reverting
761
+ Consider "git revert --quit" or "git worktree add".`):await Nt(e)?S(`cannot switch branch while rebasing
762
+ Consider "git rebase --quit" or "git worktree add".`):null}async function bw(e,t,n){let r=await Ps(e);if(r)return r;let o=await lo(e);return o?yd(e,o.name,o.refName,o.hash,t,n):S("no previous branch")}async function wd(e,t,n,r,o,s,i){if(!pn(t))return S(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return S(`a branch named '${t}' already exists`);let f;if(r){let P=await De(e,r,`invalid reference: ${r}`);if(M(P))return P;f=P.hash}else{let P=await Z(e);if(!P){let H=await Q(e),D=H?.type==="symbolic"?H.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Ye(e,"HEAD",a),await bt(e);let O=await kn(e);return await ae(e,o,"HEAD",null,te,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
763
+ ${O}`,exitCode:0}}f=P}let l=await Ps(e);if(l)return l;let d=await Z(e),m=await z(e);if(r){let P=Un(m);if(P)return P}let u=await j(e,f);if(d&&d!==f){let P=await j(e,d);if(P.tree!==u.tree){let H=await Nn(e,P.tree,u.tree,m);if(!H.success)return H.errorOutput??L("error: checkout would overwrite local changes");m={version:2,entries:H.newEntries},await le(e,m),await Ne(e,H.worktreeOps)}}let h=await Q(e),p="";h?.type==="direct"&&d&&(p=await ho(e,d,f));let g=ww(h,d);await X(e,a,f),await Ye(e,"HEAD",a),await bt(e);let w=await kn(e),b=r??"HEAD";n&&c?c!==f&&await ae(e,o,a,c,f,`branch: Reset to ${b}`):await ae(e,o,a,null,f,`branch: Created from ${b}`),await ae(e,o,"HEAD",d,f,`checkout: moving from ${g} to ${t}`);let x="";if(i){let P=i.replace(/^refs\/remotes\//,"").split("/"),H=P[0]??"",D=`refs/heads/${P.slice(1).join("/")}`,O=await ge(e);O[`branch "${t}"`]={...O[`branch "${t}"`],remote:H,merge:D},await Ze(e,O),x=`branch '${t}' set up to track '${H}/${P.slice(1).join("/")}'.
764
+ `}else r&&(x=await po(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:d,newHead:f,isBranchCheckout:!0});let y=n&&c?`Switched to and reset branch '${t}'
758
765
  `:`Switched to a new branch '${t}'
759
- `,k=p+b+w+x,E="";r&&(E=await fr(e,u.tree,m));let R=await he(e),C=await En(e,R,t);return C&&(E+=cr(C)),{stdout:E,stderr:k,exitCode:0}}async function fd(e,t,n,r,o,s){let i=await xs(e);return i||lr(e,t,n,r,o,s)}async function sw(e,t,n,r,o){let s=await xs(e);return s||Un(e,n,r,o)}async function ow(e,t,n,r){if(!pn(t))return $(`'${t}' is not a valid branch name`);let o=await xs(e);if(o)return o;let s=`refs/heads/${t}`;if(await F(e,s))return $(`a branch named '${t}' already exists`);let a=await K(e),c=Fn(a);if(c)return c;let f=await Z(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Gi(e,f)),e.workTree){let u=f?(await j(e,f)).tree:null,h=await Ge(e,[]),p=await Ln(e,u,h,a);if(!p.success)return p.errorOutput??L("error: checkout would overwrite local changes");await Me(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,qa());await ze(e,"HEAD",s),await pt(e);let m=await kn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:te,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
760
- ${m}`,exitCode:0}}se();ie();Zr();ue();Ks();function dd(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:I().alias("a").describe("Make an annotated tag object"),message:J.string().alias("m").describe("Tag message"),delete:I().alias("d").describe("Delete a tag"),force:I().alias("f").describe("Replace an existing tag"),list:I().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.delete){if(!n.name)return $("tag name required");let i=`refs/tags/${n.name}`,a=await F(s,i);return a?(await de(s,i),{stdout:`Deleted tag '${n.name}' (was ${Y(a)})
766
+ `,E=p+y+w+x,k="";r&&(k=await lr(e,u.tree,m));let R=await ge(e),C=await En(e,R,t);return C&&(k+=fr(C)),{stdout:k,stderr:E,exitCode:0}}async function yd(e,t,n,r,o,s){let i=await Ps(e);return i||dr(e,t,n,r,o,s)}async function yw(e,t,n,r,o){let s=await Ps(e);return s||Bn(e,n,r,o)}async function Ew(e,t,n,r){if(!pn(t))return S(`'${t}' is not a valid branch name`);let o=await Ps(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return S(`a branch named '${t}' already exists`);let a=await z(e),c=Un(a);if(c)return c;let f=await Z(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Ni(e,f)),e.workTree){let u=f?(await j(e,f)).tree:null,h=await Fe(e,[]),p=await Nn(e,u,h,a);if(!p.success)return p.errorOutput??L("error: checkout would overwrite local changes");await Ne(e,p.worktreeOps),await le(e,{version:2,entries:p.newEntries})}else await le(e,za());await Ye(e,"HEAD",s),await bt(e);let m=await kn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:te,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
767
+ ${m}`,exitCode:0}}ce();fe();Qr();pe();Ks();function kd(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:Y.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 S("tag name required");let i=`refs/tags/${n.name}`,a=await B(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${V(a)})
761
768
  `,stderr:"",exitCode:0}):L(`error: tag '${n.name}' not found.
762
- `)}if(n.list)return ld(s,n.name||void 0);if(n.name){if(!Oc(n.name))return $(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await vt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Z(s),!a)return $("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await F(s,c)&&!n.force)return $(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return $("no tag message specified (use -m)");let d=await Qe(s,r.env);if(M(d))return d;let m=At(n.message),u=Rc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:m}),h=await Se(s,"tag",u);await X(s,c,h)}else await X(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=>tr(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
769
+ `)}if(n.list)return Ed(s,n.name||void 0);if(n.name){if(!Oc(n.name))return S(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await gt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Z(s),!a)return S("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return S(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return S("no tag message specified (use -m)");let d=await tt(s,r.env);if(M(d))return d;let m=Mt(n.message),u=xc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:m}),h=await Te(s,"tag",u);await X(s,c,h)}else await X(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Ed(s)}})}async function Ed(e,t){let n=await be(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=>nr(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
763
770
  `)}
764
- `,stderr:"",exitCode:0}}var ud=new Set(["am","annotate","apply","archive","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","commit-tree","count-objects","credential","daemon","describe","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","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","rerere","send-email","send-pack","shortlog","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-pack","whatchanged","worktree","write-tree"]),iw={init:e=>Il(e),clone:(e,t)=>il(e,t),fetch:(e,t)=>Rl(e,t),pull:(e,t)=>Fl(e,t),push:(e,t)=>Ul(e,t),add:(e,t)=>zc(e,t),blame:(e,t)=>$f(e,t),commit:(e,t)=>al(e,t),status:(e,t)=>id(e,t),log:(e,t)=>Hl(e,t),branch:(e,t)=>Sf(e,t),tag:(e,t)=>dd(e,t),checkout:(e,t)=>vf(e,t),diff:(e,t)=>wl(e,t),reset:(e,t)=>zl(e,t),merge:(e,t)=>Ml(e,t),"cherry-pick":(e,t)=>qf(e,t),revert:(e,t)=>Xl(e,t),rebase:(e,t)=>_l(e,t),mv:(e,t)=>jl(e,t),rm:(e,t)=>Zl(e,t),remote:(e,t)=>Wl(e,t),config:(e,t)=>dl(e,t),show:(e,t)=>Jl(e,t),stash:(e,t)=>od(e,t),"rev-parse":(e,t)=>Yl(e,t),"ls-files":(e,t)=>Dl(e,t),clean:(e,t)=>zf(e,t),switch:(e,t)=>cd(e,t),restore:(e,t)=>Vl(e,t),reflog:(e,t)=>Bl(e,t),repack:(e,t)=>Cl(e,t),gc:(e,t)=>Ol(e,t),bisect:(e,t)=>mf(e,t)};function md(e){let t=Ko("git",{description:"Git command"});for(let n of Object.values(iw))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:wr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:wr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
765
- `,exitCode:1}}}),t}var aw="1.2.11";function cw(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 Uo=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=cw(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,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...r?{configOverrides:r}:{}};this.inner=md(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=fw(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)
771
+ `,stderr:"",exitCode:0}}var Rd=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","describe","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),kw={init:(e,t)=>Hl(e,t),clone:(e,t)=>al(e,t),fetch:(e,t)=>xl(e,t),pull:(e,t)=>Zl(e,t),push:(e,t)=>Jl(e,t),add:(e,t)=>Kc(e,t),blame:(e,t)=>Sf(e,t),commit:(e,t)=>cl(e,t),status:(e,t)=>gd(e,t),log:(e,t)=>Ul(e,t),branch:(e,t)=>vf(e,t),tag:(e,t)=>kd(e,t),checkout:(e,t)=>Hf(e,t),diff:(e,t)=>bl(e,t),reset:(e,t)=>nd(e,t),merge:(e,t)=>ql(e,t),"cherry-pick":(e,t)=>zf(e,t),revert:(e,t)=>id(e,t),rebase:(e,t)=>Xl(e,t),mv:(e,t)=>zl(e,t),rm:(e,t)=>ad(e,t),remote:(e,t)=>ed(e,t),config:(e,t)=>ul(e,t),show:(e,t)=>cd(e,t),stash:(e,t)=>pd(e,t),"rev-parse":(e,t)=>od(e,t),"ls-files":(e,t)=>Wl(e,t),clean:(e,t)=>Kf(e,t),switch:(e,t)=>bd(e,t),restore:(e,t)=>sd(e,t),reflog:(e,t)=>Ql(e,t),repack:(e,t)=>$l(e,t),gc:(e,t)=>Ol(e,t),bisect:(e,t)=>hf(e,t),grep:(e,t)=>Tl(e,t)};function xd(e){let t=Yo("git",{description:"Git command"});for(let n of Object.values(kw))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:br(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:br(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
772
+ `,exitCode:1}}}),t}var Rw="1.2.13";function xw(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 Wo=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=xw(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,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...r?{configOverrides:r}:{}};this.inner=xd(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=Cw(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 ${Rw} (virtual git implementation)
766
773
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
767
- `,exitCode:1};if(r&&ud.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
768
- `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function fw(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 lw(e){return new Uo(e)}var hd=new TextEncoder,dw=new TextDecoder;function dn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function Bo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var ka=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=dn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?hd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=Bo(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 dn(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("/")?dn(a):dn(Bo(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=dn(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("/")?dn(f):dn(Bo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return dw.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"?hd.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=dn(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=Bo(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=dn(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=dn(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})}};Dn();export{Uo as Git,ka as MemoryFileSystem,wh as composeGitHooks,lw as createGit,Qn as findRepo,ee as isRejection};
774
+ `,exitCode:1};if(r&&Rd.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
775
+ `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function Cw(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 Pw(e){return new Wo(e)}var Cd=new TextEncoder,$w=new TextDecoder;function dn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function qo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ra=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=dn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Cd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=qo(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 dn(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("/")?dn(a):dn(qo(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=dn(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("/")?dn(f):dn(qo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return $w.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"?Cd.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=dn(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=qo(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=dn(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=dn(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})}};Mn();export{Wo as Git,Ra as MemoryFileSystem,Oh as composeGitHooks,Pw as createGit,er as findRepo,ee as isRejection};