just-git 1.6.0 → 1.6.2

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 tu=Object.defineProperty;var Gs=(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 nu=(e,t)=>{for(var n in t)tu(e,n,{get:t[n],enumerable:!0})};function Us(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function v(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Us(t)}function Dt(...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 Us(t||".")}function rn(e){if(e==="")return".";if(e==="/")return"/";let t=e.length;for(;t>1&&e.charCodeAt(t-1)===47;)t--;let n=e.slice(0,t),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}function Xr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function nt(e,t){let n=Us(e),r=Us(t);if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,l=Math.min(o.length,s.length);for(;f<l&&o[f]===s[f];)f++;let d=o.length-f,u=s.slice(f),h=[];for(let m=0;m<d;m++)h.push("..");for(let m of u)h.push(m);return h.join("/")||"."}var me=Re(()=>{"use strict"});function di(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 u=c[f+1];switch(l(),u){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
2
- `;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=u;break}i=!0,f+=2;continue}l(),r+=d,i=!0,f++}break}return{value:r,linesConsumed:a-n+1};function l(){for(;s>0;)r+=" ",s--}}function au(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=di(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1)a[i.toLowerCase()]="true",o++;else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=Ja(l,r,o);a[f]=d,o+=u}continue}o++}return t}function ui(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=di(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1){let f=i.toLowerCase();f in a?a[f].push("true"):a[f]=["true"],o++}else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=Ja(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=u}continue}o++}return t}function hi(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 mi(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} = ${hi(s)}`)}return`${t.join(`
6
- `)}
7
- `}function pi(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=di(l),r===t&&(a=f,i=f,c=!1),f++;continue}let d=f;for(;d<e.length-1&&e[d].replace(/\r$/,"").endsWith("\\");)d++;if(r===t){let u=l.indexOf("=");(u===-1?l.toLowerCase():l.slice(0,u).trim().toLowerCase())===n?(o=f,s=d):c=!0,i=d}f=d+1}return{keyStart:o,keyEnd:s,insertAfter:i,sectionHeaderLine:a,sectionHasOtherKeys:c}}function cu(e,t,n,r){let o=e.split(`
8
- `),s=pi(o,t,n),i=` ${n} = ${hi(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 fu(e,t,n){let r=e.split(`
10
- `),o=pi(r,t,n);return o.keyStart===-1?{text:e,found:!1}:(r.splice(o.keyStart,o.keyEnd-o.keyStart+1),!o.sectionHasOtherKeys&&o.sectionHeaderLine!==-1&&r.splice(o.sectionHeaderLine,1),{text:r.join(`
11
- `),found:!0})}async function pe(e){let t=v(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return au(n)}async function Bs(e){let t=v(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function ze(e,t){let n=v(e.gitDir,"config");await e.fs.writeFile(n,mi(t))}async function xe(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await pe(e),{section:s,key:i}=Zr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function gi(e,t,n){let r=await Bs(e),{section:o,key:s}=Zr(t),i=cu(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Qa(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Bs(e);if(o){let i=ui(o),{section:a,key:c}=Zr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function lu(e,t,n,r){let o=e.split(`
12
- `),s=pi(o,t,n),i=` ${n} = ${hi(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 ec(e,t,n){let r=await Bs(e),{section:o,key:s}=Zr(t),i=lu(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function tc(e,t){let n=await Bs(e),{section:r,key:o}=Zr(t),s=fu(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Zr(e){let t=e.split(".");if(t.length===2){let[n="",r=""]=t;return{section:n,key:r.toLowerCase()}}if(t.length===3){let[n="",r="",o=""]=t;return{section:`${n} "${r}"`,key:o.toLowerCase()}}throw new Error(`Invalid config key: "${e}"`)}var Be=Re(()=>{"use strict";me()});function Ws(e,t){return nc(e,t,"author")}function Jr(e,t){return nc(e,t,"committer")}async function nc(e,t,n){let r=du[n],o=e.identityOverride,{timestamp:s,timezone:i}=uu(t.get(r.date));if(o?.locked)return{name:o.name,email:o.email,timestamp:s,timezone:i};let a=t.get(r.name)??await xe(e,"user.name")??o?.name,c=t.get(r.email)??await xe(e,"user.email")??o?.email;if(!a||!c)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
1
+ var wu=Object.defineProperty;var js=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var xe=(e,t)=>()=>(e&&(t=e(e=0)),t);var bu=(e,t)=>{for(var n in t)wu(e,n,{get:t[n],enumerable:!0})};function Fs(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function H(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Fs(t)}function Mt(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return Fs(t||".")}function sn(e){if(e==="")return".";if(e==="/")return"/";let t=e.length;for(;t>1&&e.charCodeAt(t-1)===47;)t--;let n=e.slice(0,t),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}function Vr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function rt(e,t){let n=Fs(e),r=Fs(t);if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,l=Math.min(o.length,s.length);for(;f<l&&o[f]===s[f];)f++;let d=o.length-f,u=s.slice(f),h=[];for(let m=0;m<d;m++)h.push("..");for(let m of u)h.push(m);return h.join("/")||"."}var me=xe(()=>{"use strict"});function pi(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 oc(e,t,n){let r="",o=!1,s=0,i=!1,a=n,c=e,f=0;e:for(;;){for(;f<c.length;){let d=c[f];if(d==="\r"){f++;continue}if(!o&&(d==="#"||d===";"))break e;if(!o&&(d===" "||d===" ")){i&&s++,f++;continue}if(d==='"'){l(),o=!o,f++;continue}if(d==="\\"){if(f+1>=c.length){if(a++,a<t.length){c=t[a],f=0;continue}break e}let u=c[f+1];switch(l(),u){case"\\":r+="\\";break;case'"':r+='"';break;case"n":r+=`
2
+ `;break;case"t":r+=" ";break;case"b":r+="\b";break;default:r+="\\",r+=u;break}i=!0,f+=2;continue}l(),r+=d,i=!0,f++}break}return{value:r,linesConsumed:a-n+1};function l(){for(;s>0;)r+=" ",s--}}function xu(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=pi(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1)a[i.toLowerCase()]="true",o++;else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=oc(l,r,o);a[f]=d,o+=u}continue}o++}return t}function gi(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=pi(i),n!==null&&!(n in t)&&(t[n]={}),o++;continue}if(n!==null){let a=t[n];if(!a){o++;continue}let c=i.indexOf("=");if(c===-1){let f=i.toLowerCase();f in a?a[f].push("true"):a[f]=["true"],o++}else{let f=i.slice(0,c).trim().toLowerCase(),l=i.slice(c+1),{value:d,linesConsumed:u}=oc(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=u}continue}o++}return t}function wi(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 bi(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} = ${wi(s)}`)}return`${t.join(`
6
+ `)}
7
+ `}function yi(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=pi(l),r===t&&(a=f,i=f,c=!1),f++;continue}let d=f;for(;d<e.length-1&&e[d].replace(/\r$/,"").endsWith("\\");)d++;if(r===t){let u=l.indexOf("=");(u===-1?l.toLowerCase():l.slice(0,u).trim().toLowerCase())===n?(o=f,s=d):c=!0,i=d}f=d+1}return{keyStart:o,keyEnd:s,insertAfter:i,sectionHeaderLine:a,sectionHasOtherKeys:c}}function Cu(e,t,n,r){let o=e.split(`
8
+ `),s=yi(o,t,n),i=` ${n} = ${wi(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 Pu(e,t,n){let r=e.split(`
10
+ `),o=yi(r,t,n);return o.keyStart===-1?{text:e,found:!1}:(r.splice(o.keyStart,o.keyEnd-o.keyStart+1),!o.sectionHasOtherKeys&&o.sectionHeaderLine!==-1&&r.splice(o.sectionHeaderLine,1),{text:r.join(`
11
+ `),found:!0})}async function pe(e){let t=H(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return xu(n)}async function _s(e){let t=H(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function ze(e,t){let n=H(e.gitDir,"config");await e.fs.writeFile(n,bi(t))}async function ke(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await pe(e),{section:s,key:i}=Yr(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function Ei(e,t,n){let r=await _s(e),{section:o,key:s}=Yr(t),i=Cu(r,o,s,n),a=H(e.gitDir,"config");await e.fs.writeFile(a,i)}async function ic(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await _s(e);if(o){let i=gi(o),{section:a,key:c}=Yr(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function $u(e,t,n,r){let o=e.split(`
12
+ `),s=yi(o,t,n),i=` ${n} = ${wi(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 ac(e,t,n){let r=await _s(e),{section:o,key:s}=Yr(t),i=$u(r,o,s,n),a=H(e.gitDir,"config");await e.fs.writeFile(a,i)}async function cc(e,t){let n=await _s(e),{section:r,key:o}=Yr(t),s=Pu(n,r,o);if(!s.found)return!1;let i=H(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Yr(e){let t=e.split(".");if(t.length===2){let[n="",r=""]=t;return{section:n,key:r.toLowerCase()}}if(t.length===3){let[n="",r="",o=""]=t;return{section:`${n} "${r}"`,key:o.toLowerCase()}}throw new Error(`Invalid config key: "${e}"`)}var Ue=xe(()=>{"use strict";me()});function Us(e,t){return fc(e,t,"author")}function Xr(e,t){return fc(e,t,"committer")}async function fc(e,t,n){let r=Ou[n],o=e.identityOverride,{timestamp:s,timezone:i}=Su(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
14
14
 
15
15
  *** Please tell me who you are.
16
16
 
@@ -18,99 +18,102 @@ 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 vn(e,t){try{let n=await Jr(e,t);return{name:n.name,email:n.email,timestamp:n.timestamp,tz:n.timezone}}catch{return{name:t.get("GIT_COMMITTER_NAME")??"",email:t.get("GIT_COMMITTER_EMAIL")??"",timestamp:Math.floor(Date.now()/1e3),tz:"+0000"}}}function uu(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:hu(n)}}function hu(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 du,rr=Re(()=>{"use strict";Be();du={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function An(e){let t="";for(let n=0;n<20;n++)t+=rc[e[n]];return t}function Qr(e,t){let n="";for(let r=0;r<20;r++)n+=rc[e[t+r]];return n}function Mt(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 ne,rc,pt=Re(()=>{"use strict";ne="0000000000000000000000000000000000000000",rc=(()=>{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 sc(e){return e.length===4&&e.toLowerCase()===".git"}function sr(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===".."||sc(n))return!1;return!0}function qs(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function oc(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||sc(n))return!1;return!0}var Ks=Re(()=>{"use strict"});function wi(e){return typeof e=="string"?mu.encode(e):e}function pu(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(wi(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Gs(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(wi(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(wi(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return An(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}async function Dn(e){return ic().update(e).hex()}var mu,ic,Hn,or=Re(()=>{"use strict";pt();mu=new TextEncoder;ic=pu(),Hn=ic});async function z(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:bi,entries:[]};let n=await e.fs.readFileBuffer(t);return gu(n)}async function ae(e,t){let n=v(e.gitDir,"index"),r=await wu(t);await e.fs.writeFile(n,r)}function Pt(e,t){if(!sr(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(yi),{...e,entries:n}}function ct(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function zs(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function jt(e){return e.entries.some(t=>t.stage>0)}function Kt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ne(e){return e.entries.filter(t=>t.stage===0)}function cc(){return{version:bi,entries:[]}}function Vs(e){let t=[...e].sort(yi);return{version:bi,entries:t}}function ve(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function gu(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==ac)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},l=t.getUint32(n+24);n+=40;let d=e.subarray(n,n+20),u=An(d);n+=20;let h=t.getUint16(n);n+=2;let m=h>>12&3,p=h&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let k=n;for(;k<e.byteLength&&e[k]!==0;)k++;w=new TextDecoder().decode(e.subarray(n,k)),g=k-n}let b=62+g+1,E=Math.ceil(b/8)*8;n=c+E,i.push({path:w,mode:l,hash:u,stage:m,stat:f})}return{version:o,entries:i}}async function wu(e){let t=new TextEncoder,n=[...e.entries].sort(yi),r=[],o=12;for(let u of n){let h=t.encode(u.path);r.push(h);let m=62+h.byteLength+1;o+=Math.ceil(m/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,ac),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let u=0;u<n.length;u++){let h=n[u],m=r[u],p=c;a.setUint32(c,h.stat.ctimeSeconds),a.setUint32(c+4,h.stat.ctimeNanoseconds),a.setUint32(c+8,h.stat.mtimeSeconds),a.setUint32(c+12,h.stat.mtimeNanoseconds),a.setUint32(c+16,h.stat.dev),a.setUint32(c+20,h.stat.ino),a.setUint32(c+24,h.mode),a.setUint32(c+28,h.stat.uid),a.setUint32(c+32,h.stat.gid),a.setUint32(c+36,h.stat.size),c+=40;let g=Mt(h.hash);i.set(g,c),c+=20;let w=Math.min(m.byteLength,4095),b=(h.stage&3)<<12|w;a.setUint16(c,b),c+=2,i.set(m,c),c+=m.byteLength,i[c]=0,c+=1;let E=62+m.byteLength+1,k=Math.ceil(E/8)*8;c=p+k}let f=i.subarray(0,c),l=await Dn(f),d=Mt(l);return i.set(d,c),i}function yi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var ac,bi,Ce=Re(()=>{"use strict";pt();Ks();me();or();ac=1145655875,bi=2});var bu,Ys,fc=Re(()=>{"use strict";bu=new Set(["tree","commit","tag"]),Ys=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(!bu.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 Ei(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=lc[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var lc,dc=Re(()=>{"use strict";lc=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;lc[e]=t}});function Ec(e){let t=yc(e);return bc(e.subarray(t,-4),{i:2})}function Ci(e){let t=yc(e),n={i:2},r=bc(e.subarray(t),n),o=wc(n.p);return{result:r,bytesConsumed:t+o+4}}var Vt,Pr,yu,uc,hc,Eu,mc,pc,ku,xi,es,ts,gc,Ru,xu,ki,zt,Ri,wc,Cu,sn,bc,yc,kc=Re(()=>{"use strict";Vt=Uint8Array,Pr=Uint16Array,yu=Int32Array,uc=new Vt([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]),hc=new Vt([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]),Eu=new Vt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mc=(e,t)=>{let n=new Pr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new yu(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:pc}=mc(uc,2);pc[28]=258;({b:ku}=mc(hc,0)),xi=new Pr(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,xi[e]=((t&65280)>>8|(t&255)<<8)>>1}es=(e,t,n)=>{let r=e.length,o=0,s=new Pr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new Pr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new Pr(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[xi[d]>>c]=f}}else for(a=new Pr(r),o=0;o<r;++o)e[o]&&(a[o]=xi[i[e[o]-1]++]>>15-e[o]);return a},ts=new Vt(288);for(let e=0;e<144;++e)ts[e]=8;for(let e=144;e<256;++e)ts[e]=9;for(let e=256;e<280;++e)ts[e]=7;for(let e=280;e<288;++e)ts[e]=8;gc=new Vt(32);for(let e=0;e<32;++e)gc[e]=5;Ru=es(ts,9,1),xu=es(gc,5,1),ki=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},zt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Ri=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},wc=e=>(e+7)/8|0,Cu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Vt(e.subarray(t,n))),sn=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},bc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Vt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Vt(o*3));let f=b=>{let E=n.length;if(b>E){let k=new Vt(Math.max(E*2,b));k.set(n),n=k}},l=t.f||0,d=t.p||0,u=t.b||0,h=t.l,m=t.d,p=t.m,g=t.n,w=o*8;do{if(!h){l=zt(e,d,1);let R=zt(e,d+1,3);if(d+=3,R)if(R==1)h=Ru,m=xu,p=9,g=5;else if(R==2){let x=zt(e,d,31)+257,y=zt(e,d+10,15)+4,C=x+zt(e,d+5,31)+1;d+=14;let $=new Vt(C),D=new Vt(19);for(let O=0;O<y;++O)D[Eu[O]]=zt(e,d+O*3,7);d+=y*3;let P=ki(D),T=(1<<P)-1,A=es(D,P,1);for(let O=0;O<C;){let H=A[zt(e,d,T)];d+=H&15;let L=H>>4;if(L<16)$[O++]=L;else{let G=0,B=0;for(L==16?(B=3+zt(e,d,3),d+=2,G=$[O-1]):L==17?(B=3+zt(e,d,7),d+=3):L==18&&(B=11+zt(e,d,127),d+=7);B--;)$[O++]=G}}let U=$.subarray(0,x),_=$.subarray(x);p=ki(U),g=ki(_),h=es(U,p,1),m=es(_,g,1)}else sn(1);else{let x=wc(d)+4,y=e[x-4]|e[x-3]<<8,C=x+y;if(C>o){c&&sn(0);break}a&&f(u+y),n.set(e.subarray(x,C),u),t.b=u+=y,t.p=d=C*8,t.f=l;continue}if(d>w){c&&sn(0);break}}a&&f(u+131072);let b=(1<<p)-1,E=(1<<g)-1,k=d;for(;;k=d){let R=h[Ri(e,d)&b],x=R>>4;if(d+=R&15,d>w){c&&sn(0);break}if(R||sn(2),x<256)n[u++]=x;else if(x==256){k=d,h=null;break}else{let y=x-254;if(x>264){let T=x-257,A=uc[T];y=zt(e,d,(1<<A)-1)+pc[T],d+=A}let C=m[Ri(e,d)&E],$=C>>4;C||sn(3),d+=C&15;let D=ku[$];if($>3){let T=hc[$];D+=Ri(e,d)&(1<<T)-1,d+=T}if(d>w){c&&sn(0);break}a&&f(u+131072);let P=u+y;if(u<D){let T=s-D,A=Math.min(D,P);for(T+u<0&&sn(3);u<A;++u)n[u]=r[T+u]}for(;u<P;++u)n[u]=n[u-D]}}t.l=h,t.p=k,t.b=u,t.f=l,h&&(l=1,t.m=p,t.d=m,t.n=g)}while(!l);return u!=n.length&&i?Cu(n,0,u):n.subarray(0,u)},yc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&sn(0,"invalid zlib data"),e[1]&32&&sn(0,"zlib dictionaries are not supported"),2)});async function Pu(){let e;if(!(typeof document<"u"))try{e=Gs(["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??Ci}}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:Ec,inflateWithConsumed:Ci}}function Pi(){return $u??=Pu()}async function $r(e){return await(await Pi()).deflateSync(e)}async function Or(e){return await(await Pi()).inflateSync(e)}async function Rc(e,t){let n=await Pi(),{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 $u,Xs=Re(()=>{"use strict";kc();$u=null});async function Tc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Zs)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Zs.toString(16)})`);let o=n.getUint32(4);if(o!==Si)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Qr(e,e.byteLength-20),l=Hn();l.update(e.subarray(0,e.byteLength-20));let d=await l.hex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await Su(e,a);i.push(l),a=l.nextOffset}return(await Iu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function Su(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===ns){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===Ii&&(c=Qr(e,t),t+=20);let{result:f,bytesConsumed:l}=await Rc(e.subarray(t),s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:a,baseHash:c,nextOffset:t+l}}async function Iu(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s,i=0){if(i>xc)throw new Error(`delta chain depth ${i} exceeds limit of ${xc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==ns&&c.typeNum!==Ii){let h=Ou[c.typeNum];if(!h)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:h,content:c.inflated,hash:await $i(h,c.inflated)};return r[s]=m,m}if(c.typeNum===ns){let h=n.get(c.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await o(h,i+1),p=rs(m.content,c.inflated),g={type:m.type,content:p,hash:await $i(m.type,p)};return r[s]=g,g}let f=await Tu(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let h=await t(c.baseHash);h&&(l=h)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=rs(l.content,c.inflated),u={type:l.type,content:d,hash:await $i(l.type,d)};return r[s]=u,u}for(let s=0;s<e.length;s++)await o(s);return r}async function Tu(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!==ns&&s.typeNum!==Ii&&(await r(o)).hash===n)return o}}function rs(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 vc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Zs),r.setUint32(4,Si),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=Ic[o.type],i=await $r(o.content);t.push(Oi(s,o.content.byteLength)),t.push(i)}return Ac(t)}async function Js(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Zs),o.setUint32(4,Si),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=Oi(ns,a.delta.byteLength),d=vu(s-f),u=await $r(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=Ic[a.type],d=Oi(l,a.content.byteLength),u=await $r(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Ac(t),entries:i}}async function Ac(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=Hn();o.update(n.subarray(0,r));let s=await o.hex();return n.set(Mt(s),r),n}function vu(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 Oi(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 $i(e,t){let n=Au.encode(`${e} ${t.byteLength}\0`),r=Hn();return r.update(n),r.update(t),r.hex()}var Zs,Si,Pc,$c,Oc,Sc,ns,Ii,Ou,Ic,xc,Au,Sr=Re(()=>{"use strict";pt();or();Xs();Zs=1346454347,Si=2,Pc=1,$c=2,Oc=3,Sc=4,ns=6,Ii=7,Ou={[Pc]:"commit",[$c]:"tree",[Oc]:"blob",[Sc]:"tag"},Ic={commit:Pc,tree:$c,blob:Oc,tag:Sc};xc=50;Au=new TextEncoder});async function Mc(e,t){let n=[...e].sort((h,m)=>h.hash<m.hash?-1:h.hash>m.hash?1:0),r=n.length,o=[];for(let h of n)h.offset>=2147483648&&o.push(BigInt(h.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,Hc),c+=4,a.setUint32(c,Dc),c+=4;let f=new Uint32Array(256);for(let h of n){let m=parseInt(h.hash.slice(0,2),16);for(let p=m;p<256;p++)f[p]++}for(let h=0;h<256;h++)a.setUint32(c,f[h]),c+=4;for(let h of n)i.set(Mt(h.hash),c),c+=20;for(let h of n)a.setUint32(c,h.crc),c+=4;let l=0;for(let h of n)h.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,h.offset),c+=4;for(let h of o)a.setBigUint64(c,h),c+=8;i.set(t,c),c+=20;let d=Hn();d.update(i.subarray(0,c));let u=await d.hex();return i.set(Mt(u),c),i}async function jc(e){let n=(await Tc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Ei(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Mc(n,r)}async function Lc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Ei(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Mc(n,r)}var Hc,Dc,Yt,Qs=Re(()=>{"use strict";pt();or();dc();Sr();Hc=4285812579,Dc=2,Yt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==Hc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==Dc)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=Mt(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=Mt(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,h=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==h){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 Hu,Du,Mu,Gc,ss,Nc=Re(()=>{"use strict";pt();Qs();Sr();Xs();Hu=6,Du=7,Mu={1:"commit",2:"tree",3:"blob",4:"tag"},Gc=50,ss=class{constructor(t,n){this.data=t;this.index=n instanceof Yt?n:new Yt(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>Gc)throw new Error(`delta chain depth ${n} exceeds limit of ${Gc}`);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===Hu){let d=r[o++],u=d&127;for(;d&128;)u+=1,d=r[o++],u=(u<<7)+(d&127);let h=await Or(r.subarray(o)),m=await this.readAt(t-u,n+1);return{type:m.type,content:rs(m.content,h)}}if(i===Du){let d=Qr(r,o);o+=20;let u=await Or(r.subarray(o)),h=this.index.lookup(d);if(h===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(h,n+1);return{type:m.type,content:rs(m.content,u)}}let f=Mu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Or(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 vi(e,t){let n=ju.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Gu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Lu.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 Ti(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var ju,Lu,Ir,Ai=Re(()=>{"use strict";pt();fc();Qs();Nc();Sr();Xs();me();or();ju=new TextEncoder,Lu=new TextDecoder;Ir=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ys(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=vi(t,n),o=await Dn(r),s=Ti(this.gitDir,o);if(await this.fs.exists(s))return o;let i=v(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await $r(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Ti(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Or(o),i=await Dn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=Gu(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(Ti(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let o=n.getUint32(4);if(o!==2)throw new Error(`unsupported pack version: ${o}`);let s=n.getUint32(8);if(s===0)return 0;let i=t.subarray(t.byteLength-20),a=An(i),c=await Dn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=v(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await jc(t),u=v(this.packDir,`${f}.idx`);await this.fs.writeFile(u,d),this.loadedPackNames.add(f);let h=new Yt(d);return this.packs.push({name:f,index:h,reader:new ss(t,h)}),s}async ingestPackStream(t){let n=[];for await(let o of t)n.push(o);if(n.length===0)return 0;let r=await vc(n);return this.ingestPack(r)}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=v(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=v(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new ss(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=v(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(v(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Yt(s),reader:null})}}}});function os(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 is(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Hi=Re(()=>{"use strict"});function on(e){let t=Fu.decode(e),n=t.indexOf(`
21
+ `);return{name:a,email:c,timestamp:s,timezone:i}}async function Mn(e,t){try{let n=await Xr(e,t);return{name:n.name,email:n.email,timestamp:n.timestamp,tz:n.timezone}}catch{return{name:t.get("GIT_COMMITTER_NAME")??"",email:t.get("GIT_COMMITTER_EMAIL")??"",timestamp:Math.floor(Date.now()/1e3),tz:"+0000"}}}function Su(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:Iu(n)}}function Iu(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 Ou,sr=xe(()=>{"use strict";Ue();Ou={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 jn(e){let t="";for(let n=0;n<20;n++)t+=lc[e[n]];return t}function Zr(e,t){let n="";for(let r=0;r<20;r++)n+=lc[e[t+r]];return n}function jt(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var ne,lc,pt=xe(()=>{"use strict";ne="0000000000000000000000000000000000000000",lc=(()=>{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 dc(e){return e.length===4&&e.toLowerCase()===".git"}function or(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===".."||dc(n))return!1;return!0}function Bs(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function uc(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||dc(n))return!1;return!0}var Ws=xe(()=>{"use strict"});function ki(e){return typeof e=="string"?Tu.encode(e):e}function vu(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(ki(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=js(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(ki(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(ki(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 jn(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 Gn(e){return hc().update(e).hex()}var Tu,hc,Ln,ir=xe(()=>{"use strict";pt();Tu=new TextEncoder;hc=vu(),Ln=hc});async function V(e){let t=H(e.gitDir,"index");if(!await e.fs.exists(t))return{version:Ri,entries:[]};let n=await e.fs.readFileBuffer(t);return Hu(n)}async function ae(e,t){let n=H(e.gitDir,"index"),r=await Au(t);await e.fs.writeFile(n,r)}function Pt(e,t){if(!or(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(xi),{...e,entries:n}}function lt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function qs(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Lt(e){return e.entries.some(t=>t.stage>0)}function zt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Ge(e){return e.entries.filter(t=>t.stage===0)}function pc(){return{version:Ri,entries:[]}}function Ks(e){let t=[...e].sort(xi);return{version:Ri,entries:t}}function He(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Hu(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==mc)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},l=t.getUint32(n+24);n+=40;let d=e.subarray(n,n+20),u=jn(d);n+=20;let h=t.getUint16(n);n+=2;let m=h>>12&3,p=h&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let E=n;for(;E<e.byteLength&&e[E]!==0;)E++;w=new TextDecoder().decode(e.subarray(n,E)),g=E-n}let b=62+g+1,R=Math.ceil(b/8)*8;n=c+R,i.push({path:w,mode:l,hash:u,stage:m,stat:f})}return{version:o,entries:i}}async function Au(e){let t=new TextEncoder,n=[...e.entries].sort(xi),r=[],o=12;for(let u of n){let h=t.encode(u.path);r.push(h);let m=62+h.byteLength+1;o+=Math.ceil(m/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,mc),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let u=0;u<n.length;u++){let h=n[u],m=r[u],p=c;a.setUint32(c,h.stat.ctimeSeconds),a.setUint32(c+4,h.stat.ctimeNanoseconds),a.setUint32(c+8,h.stat.mtimeSeconds),a.setUint32(c+12,h.stat.mtimeNanoseconds),a.setUint32(c+16,h.stat.dev),a.setUint32(c+20,h.stat.ino),a.setUint32(c+24,h.mode),a.setUint32(c+28,h.stat.uid),a.setUint32(c+32,h.stat.gid),a.setUint32(c+36,h.stat.size),c+=40;let g=jt(h.hash);i.set(g,c),c+=20;let w=Math.min(m.byteLength,4095),b=(h.stage&3)<<12|w;a.setUint16(c,b),c+=2,i.set(m,c),c+=m.byteLength,i[c]=0,c+=1;let R=62+m.byteLength+1,E=Math.ceil(R/8)*8;c=p+E}let f=i.subarray(0,c),l=await Gn(f),d=jt(l);return i.set(d,c),i}function xi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var mc,Ri,Ce=xe(()=>{"use strict";pt();Ws();me();ir();mc=1145655875,Ri=2});var Du,zs,gc=xe(()=>{"use strict";Du=new Set(["tree","commit","tag"]),zs=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Du.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 Ci(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=wc[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var wc,bc=xe(()=>{"use strict";wc=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;wc[e]=t}});function Oc(e){let t=$c(e);return Pc(e.subarray(t,-4),{i:2})}function Si(e){let t=$c(e),n={i:2},r=Pc(e.subarray(t),n),o=Cc(n.p);return{result:r,bytesConsumed:t+o+4}}var Yt,Pr,Mu,yc,Ec,ju,kc,Rc,Lu,Oi,Jr,Qr,xc,Gu,Nu,Pi,Vt,$i,Cc,Fu,on,Pc,$c,Sc=xe(()=>{"use strict";Yt=Uint8Array,Pr=Uint16Array,Mu=Int32Array,yc=new Yt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ec=new Yt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ju=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),kc=(e,t)=>{let n=new Pr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new Mu(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:Rc}=kc(yc,2);Rc[28]=258;({b:Lu}=kc(Ec,0)),Oi=new Pr(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,Oi[e]=((t&65280)>>8|(t&255)<<8)>>1}Jr=(e,t,n)=>{let r=e.length,o=0,s=new Pr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new Pr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new Pr(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[Oi[d]>>c]=f}}else for(a=new Pr(r),o=0;o<r;++o)e[o]&&(a[o]=Oi[i[e[o]-1]++]>>15-e[o]);return a},Qr=new Yt(288);for(let e=0;e<144;++e)Qr[e]=8;for(let e=144;e<256;++e)Qr[e]=9;for(let e=256;e<280;++e)Qr[e]=7;for(let e=280;e<288;++e)Qr[e]=8;xc=new Yt(32);for(let e=0;e<32;++e)xc[e]=5;Gu=Jr(Qr,9,1),Nu=Jr(xc,5,1),Pi=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Vt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},$i=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Cc=e=>(e+7)/8|0,Fu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Yt(e.subarray(t,n))),on=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},Pc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new Yt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new Yt(o*3));let f=b=>{let R=n.length;if(b>R){let E=new Yt(Math.max(R*2,b));E.set(n),n=E}},l=t.f||0,d=t.p||0,u=t.b||0,h=t.l,m=t.d,p=t.m,g=t.n,w=o*8;do{if(!h){l=Vt(e,d,1);let k=Vt(e,d+1,3);if(d+=3,k)if(k==1)h=Gu,m=Nu,p=9,g=5;else if(k==2){let x=Vt(e,d,31)+257,y=Vt(e,d+10,15)+4,P=x+Vt(e,d+5,31)+1;d+=14;let C=new Yt(P),A=new Yt(19);for(let I=0;I<y;++I)A[ju[I]]=Vt(e,d+I*3,7);d+=y*3;let D=Pi(A),$=(1<<D)-1,v=Jr(A,D,1);for(let I=0;I<P;){let T=v[Vt(e,d,$)];d+=T&15;let G=T>>4;if(G<16)C[I++]=G;else{let W=0,F=0;for(G==16?(F=3+Vt(e,d,3),d+=2,W=C[I-1]):G==17?(F=3+Vt(e,d,7),d+=3):G==18&&(F=11+Vt(e,d,127),d+=7);F--;)C[I++]=W}}let N=C.subarray(0,x),L=C.subarray(x);p=Pi(N),g=Pi(L),h=Jr(N,p,1),m=Jr(L,g,1)}else on(1);else{let x=Cc(d)+4,y=e[x-4]|e[x-3]<<8,P=x+y;if(P>o){c&&on(0);break}a&&f(u+y),n.set(e.subarray(x,P),u),t.b=u+=y,t.p=d=P*8,t.f=l;continue}if(d>w){c&&on(0);break}}a&&f(u+131072);let b=(1<<p)-1,R=(1<<g)-1,E=d;for(;;E=d){let k=h[$i(e,d)&b],x=k>>4;if(d+=k&15,d>w){c&&on(0);break}if(k||on(2),x<256)n[u++]=x;else if(x==256){E=d,h=null;break}else{let y=x-254;if(x>264){let $=x-257,v=yc[$];y=Vt(e,d,(1<<v)-1)+Rc[$],d+=v}let P=m[$i(e,d)&R],C=P>>4;P||on(3),d+=P&15;let A=Lu[C];if(C>3){let $=Ec[C];A+=$i(e,d)&(1<<$)-1,d+=$}if(d>w){c&&on(0);break}a&&f(u+131072);let D=u+y;if(u<A){let $=s-A,v=Math.min(A,D);for($+u<0&&on(3);u<v;++u)n[u]=r[$+u]}for(;u<D;++u)n[u]=n[u-A]}}t.l=h,t.p=E,t.b=u,t.f=l,h&&(l=1,t.m=p,t.d=m,t.n=g)}while(!l);return u!=n.length&&i?Fu(n,0,u):n.subarray(0,u)},$c=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&on(0,"invalid zlib data"),e[1]&32&&on(0,"zlib dictionaries are not supported"),2)});async function _u(){let e;if(!(typeof document<"u"))try{e=js(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let r=null;try{let o=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});o?.engine&&typeof o.engine.bytesWritten=="number"&&(r=s=>{let i=e.inflateSync(s,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:o=>new Uint8Array(e.deflateSync(o)),inflateSync:o=>new Uint8Array(e.inflateSync(o)),inflateWithConsumed:r??Si}}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:Oc,inflateWithConsumed:Si}}function Ii(){return Uu??=_u()}async function $r(e){return await(await Ii()).deflateSync(e)}async function Or(e){return await(await Ii()).inflateSync(e)}async function Ic(e,t){let n=await Ii(),{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 Uu,Vs=xe(()=>{"use strict";Sc();Uu=null});async function Lc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Ys)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Ys.toString(16)})`);let o=n.getUint32(4);if(o!==Hi)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Zr(e,e.byteLength-20),l=Ln();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 Wu(e,a);i.push(l),a=l.nextOffset}return(await qu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function Wu(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===es){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===Ai&&(c=Zr(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 qu(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>Tc)throw new Error(`delta chain depth ${i} exceeds limit of ${Tc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==es&&c.typeNum!==Ai){let h=Bu[c.typeNum];if(!h)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:h,content:c.inflated,hash:await Ti(h,c.inflated)};return r[s]=m,m}if(c.typeNum===es){let h=n.get(c.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await o(h,i+1),p=ts(m.content,c.inflated),g={type:m.type,content:p,hash:await Ti(m.type,p)};return r[s]=g,g}let f=await Ku(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let h=await t(c.baseHash);h&&(l=h)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=ts(l.content,c.inflated),u={type:l.type,content:d,hash:await Ti(l.type,d)};return r[s]=u,u}for(let s=0;s<e.length;s++)await o(s);return r}async function Ku(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==es&&s.typeNum!==Ai&&(await r(o)).hash===n)return o}}function ts(e,t){let n=0,{value:r,newPos:o}=vc(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}=vc(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 Gc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Ys),r.setUint32(4,Hi),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=jc[o.type],i=await $r(o.content);t.push(vi(s,o.content.byteLength)),t.push(i)}return Nc(t)}async function Xs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Ys),o.setUint32(4,Hi),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=vi(es,a.delta.byteLength),d=zu(s-f),u=await $r(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=jc[a.type],d=vi(l,a.content.byteLength),u=await $r(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await Nc(t),entries:i}}async function Nc(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=Ln();o.update(n.subarray(0,r));let s=await o.hex();return n.set(jt(s),r),n}function zu(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 vi(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 vc(e,t){let n=0,r=0,o;do o=e[t++],n|=(o&127)<<r,r+=7;while(o&128);return{value:n,newPos:t}}async function Ti(e,t){let n=Vu.encode(`${e} ${t.byteLength}\0`),r=Ln();return r.update(n),r.update(t),r.hex()}var Ys,Hi,Hc,Ac,Dc,Mc,es,Ai,Bu,jc,Tc,Vu,Sr=xe(()=>{"use strict";pt();ir();Vs();Ys=1346454347,Hi=2,Hc=1,Ac=2,Dc=3,Mc=4,es=6,Ai=7,Bu={[Hc]:"commit",[Ac]:"tree",[Dc]:"blob",[Mc]:"tag"},jc={commit:Hc,tree:Ac,blob:Dc,tag:Mc};Tc=50;Vu=new TextEncoder});async function Uc(e,t){let n=[...e].sort((h,m)=>h.hash<m.hash?-1:h.hash>m.hash?1:0),r=n.length,o=[];for(let h of n)h.offset>=2147483648&&o.push(BigInt(h.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,Fc),c+=4,a.setUint32(c,_c),c+=4;let f=new Uint32Array(256);for(let h of n){let m=parseInt(h.hash.slice(0,2),16);for(let p=m;p<256;p++)f[p]++}for(let h=0;h<256;h++)a.setUint32(c,f[h]),c+=4;for(let h of n)i.set(jt(h.hash),c),c+=20;for(let h of n)a.setUint32(c,h.crc),c+=4;let l=0;for(let h of n)h.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,h.offset),c+=4;for(let h of o)a.setBigUint64(c,h),c+=8;i.set(t,c),c+=20;let d=Ln();d.update(i.subarray(0,c));let u=await d.hex();return i.set(jt(u),c),i}async function Bc(e){let n=(await Lc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:Ci(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Uc(n,r)}async function Wc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:Ci(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Uc(n,r)}var Fc,_c,Xt,Zs=xe(()=>{"use strict";pt();ir();bc();Sr();Fc=4285812579,_c=2,Xt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==Fc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==_c)throw new Error(`Unsupported pack index version: ${n.getUint32(4)}`);this.fanout=new Uint32Array(256);let r=8;for(let s=0;s<256;s++)this.fanout[s]=n.getUint32(r),r+=4;this.count=this.fanout[255],this.hashes=new Uint8Array(t.buffer,t.byteOffset+r,this.count*20),r+=this.count*20,r+=this.count*4,this.offsets=new Uint32Array(this.count);for(let s=0;s<this.count;s++)this.offsets[s]=n.getUint32(r),r+=4;let o=!1;for(let s=0;s<this.count;s++)if(this.offsets[s]&2147483648){o=!0;break}this.largeOffsets=o?new DataView(t.buffer,t.byteOffset+r):null}lookup(t){let n=jt(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],i=o,a=s;for(;i<a;){let c=i+a>>>1,f=this.compareAt(c,n);if(f<0)i=c+1;else if(f>0)a=c;else return this.getOffset(c)}return null}has(t){return this.lookup(t)!==null}get objectCount(){return this.count}allHashes(){let t=[];for(let n=0;n<this.count;n++)t.push(this.hashAtSlot(n));return t}findByPrefix(t){if(t.length<2)return[];let n=parseInt(t.slice(0,2),16),r=n===0?0:this.fanout[n-1],o=this.fanout[n],s=jt(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,h=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==h){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 Yu,Xu,Zu,qc,ns,Kc=xe(()=>{"use strict";pt();Zs();Sr();Vs();Yu=6,Xu=7,Zu={1:"commit",2:"tree",3:"blob",4:"tag"},qc=50,ns=class{constructor(t,n){this.data=t;this.index=n instanceof Xt?n:new Xt(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n,0)}get objectCount(){return this.index.objectCount}async readAt(t,n){if(n>qc)throw new Error(`delta chain depth ${n} exceeds limit of ${qc}`);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===Yu){let d=r[o++],u=d&127;for(;d&128;)u+=1,d=r[o++],u=(u<<7)+(d&127);let h=await Or(r.subarray(o)),m=await this.readAt(t-u,n+1);return{type:m.type,content:ts(m.content,h)}}if(i===Xu){let d=Zr(r,o);o+=20;let u=await Or(r.subarray(o)),h=this.index.lookup(d);if(h===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(h,n+1);return{type:m.type,content:ts(m.content,u)}}let f=Zu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Or(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=Ju.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function eh(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Qu.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 Di(e,t){return H(e,"objects",t.slice(0,2),t.slice(2))}var Ju,Qu,Ir,ji=xe(()=>{"use strict";pt();gc();Zs();Kc();Sr();Vs();me();ir();Ju=new TextEncoder,Qu=new TextDecoder;Ir=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new zs(r),this.packDir=H(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=Mi(t,n),o=await Gn(r),s=Di(this.gitDir,o);if(await this.fs.exists(s))return o;let i=H(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(i,{recursive:!0}),await this.fs.writeFile(s,await $r(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=Di(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Or(o),i=await Gn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=eh(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(Di(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=jn(i),c=await Gn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=H(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await Bc(t),u=H(this.packDir,`${f}.idx`);await this.fs.writeFile(u,d),this.loadedPackNames.add(f);let h=new Xt(d);return this.packs.push({name:f,index:h,reader:new ns(t,h)}),s}async ingestPackStream(t){let n=[];for await(let o of t)n.push(o);if(n.length===0)return 0;let r=await Gc(n);return this.ingestPack(r)}invalidatePacks(){this.packs=[],this.loadedPackNames.clear(),this.discoverPromise=null,this.cache.clear()}async findByPrefix(t){if(t.length<4)return[];let n=t.slice(0,2),r=t.slice(2),o=H(this.gitDir,"objects",n),s=[];if(await this.fs.exists(o)){let i=await this.fs.readdir(o);for(let a of i)a.startsWith(r)&&s.push(`${n}${a}`)}await this.discover();for(let i of this.packs)for(let a of i.index.findByPrefix(t))s.includes(a)||s.push(a);return s}async ensureReader(t){if(t.reader)return t.reader;let n=H(this.packDir,`${t.name}.pack`),r=await this.fs.readFileBuffer(n);return t.reader=new ns(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=H(this.packDir,`${r}.pack`);if(!await this.fs.exists(o))continue;let s=await this.fs.readFileBuffer(H(this.packDir,n));this.loadedPackNames.add(r),this.packs.push({name:r,index:new Xt(s),reader:null})}}}});function rs(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function ss(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Li=xe(()=>{"use strict"});function an(e){let t=nh.decode(e),n=t.indexOf(`
22
22
 
23
23
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i=[],a,c;for(let f of r.split(`
24
- `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=os(u);break;case"committer":c=os(u);break}}if(!s)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:i,author:a,committer:c,message:o}}function an(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${is(e.author)}`),t.push(`committer ${is(e.committer)}`),t.push(""),t.push(e.message),Nu.encode(t.join(`
25
- `))}var Nu,Fu,wn=Re(()=>{"use strict";Hi();Nu=new TextEncoder,Fu=new TextDecoder});function Xt(e){let t=Uu.decode(e),n=t.indexOf(`
24
+ `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"tree":s=u;break;case"parent":i.push(u);break;case"author":a=rs(u);break;case"committer":c=rs(u);break}}if(!s)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:i,author:a,committer:c,message:o}}function cn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${ss(e.author)}`),t.push(`committer ${ss(e.committer)}`),t.push(""),t.push(e.message),th.encode(t.join(`
25
+ `))}var th,nh,bn=xe(()=>{"use strict";Li();th=new TextEncoder,nh=new TextDecoder});function Zt(e){let t=sh.decode(e),n=t.indexOf(`
26
26
 
27
27
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",i="commit",a="",c;for(let f of r.split(`
28
- `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=os(u);break}}if(!s)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:i,name:a,tagger:c,message:o}}function Fc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${is(e.tagger)}`),t.push(""),t.push(e.message),_u.encode(t.join(`
29
- `))}var _u,Uu,Tr=Re(()=>{"use strict";Hi();_u=new TextEncoder,Uu=new TextDecoder});async function gt(e,t){return Dn(vi(e,t))}async function Ie(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function ye(e,t){return e.objectStore.read(t)}async function Zt(e,t){return e.objectStore.exists(t)}async function eo(e,t){return e.objectStore.ingestPack(t)}async function _c(e,t){return e.objectStore.findByPrefix(t)}function Ae(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function Mn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function oe(e,t){let n=await ye(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Bu.decode(n.content)}async function $t(e,t){let n=await ye(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function j(e,t){let n=await ye(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return on(n.content)}async function Uc(e,t){let n=await ye(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Xt(n.content)}async function He(e,t){let n=t;for(let r=0;r<100;r++){let o=await ye(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Xt(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 Bu,ie=Re(()=>{"use strict";Ai();wn();Tr();or();Bu=new TextDecoder});function Bc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var bn,Di=Re(()=>{"use strict";bn={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function qu(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?Wu[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>=Mi.length&&e.slice(s-Mi.length,s)===Mi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function as(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}=qu(e,n,o);if(s<0||s===0)return!1;i&&(o=!1),r++,n+=s+1}return!(e.charCodeAt(e.length-1)===46||!(t&1)&&r<2)}function yn(e){return!e||e.startsWith("-")?!1:as(`refs/heads/${e}`,0)}function Wc(e){return e?as(`refs/tags/${e}`,0):!1}async function Kc(e,t){return e.refStore.readRef(t)}async function W(e,t){let n=t;for(let r=0;r<qc;r++){let o=await Kc(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 Kc(e,"HEAD")}async function X(e){return W(e,"HEAD")}async function J(e,t,n){let r=e.hooks?await W(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 vr(e,t,n,r){let o=n.find(f=>f.name==="HEAD");if(!o)return;let s;if(r?.startsWith("refs/heads/"))s=r.slice(11);else{let f=n.find(l=>l.name.startsWith("refs/heads/")&&l.hash===o.hash);if(!f)return;s=f.name.slice(11)}let i=`refs/remotes/${t}/HEAD`;if(await e.refStore.readRef(i))return;let c=`refs/remotes/${t}/${s}`;await e.refStore.writeRef(i,{type:"symbolic",target:c})}async function he(e,t){let n=e.hooks?await W(e,t):null;await e.refStore.deleteRef(t),await fs(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function we(e,t="refs"){return e.refStore.listRefs(t)}function Pe(e){return e.replace("refs/heads/","")}function Ln(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}async function Gn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await J(e,n.target,t):await J(e,"HEAD",t)}async function zc(e){if(e.refStore&&!(e.refStore instanceof jn))return;let t=await we(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"],r=[];for(let s of t){let i=v(e.gitDir,s.name);if(!(await e.fs.exists(i)&&(await e.fs.readFile(i)).trim().startsWith("ref: "))&&(r.push(s.name),n.push(`${s.hash} ${s.name}`),s.name.startsWith("refs/tags/")))try{let a=await ye(e,s.hash);if(a.type==="tag"){let c=Xt(a.content).object;for(let f=0;f<100;f++){let l=await ye(e,c);if(l.type!=="tag")break;c=Xt(l.content).object}n.push(`^${c}`)}}catch{}}await e.fs.writeFile(v(e.gitDir,"packed-refs"),`${n.join(`
28
+ `)){let l=f.indexOf(" ");if(l===-1)continue;let d=f.slice(0,l),u=f.slice(l+1);switch(d){case"object":s=u;break;case"type":i=u;break;case"tag":a=u;break;case"tagger":c=rs(u);break}}if(!s)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:i,name:a,tagger:c,message:o}}function zc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${ss(e.tagger)}`),t.push(""),t.push(e.message),rh.encode(t.join(`
29
+ `))}var rh,sh,Tr=xe(()=>{"use strict";Li();rh=new TextEncoder,sh=new TextDecoder});async function gt(e,t){return Gn(Mi(e,t))}async function Ie(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 wt(e,t){return e.objectStore.exists(t)}async function Js(e,t){return e.objectStore.ingestPack(t)}async function Vc(e,t){return e.objectStore.findByPrefix(t)}function je(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 Nn(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 oh.decode(n.content)}async function $t(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 an(n.content)}async function Yc(e,t){let n=await we(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Zt(n.content)}async function Te(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=Zt(o.content).object;continue}throw new Error(`Cannot peel ${o.type} object ${t} to commit`)}throw new Error(`Tag chain too deep for ${t}`)}var oh,ie=xe(()=>{"use strict";ji();bn();Tr();ir();oh=new TextDecoder});function Xc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var yn,Gi=xe(()=>{"use strict";yn={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function ah(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?ih[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>=Ni.length&&e.slice(s-Ni.length,s)===Ni?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function os(e,t=0){if(e==="@"||e.length===0)return!1;let n=0,r=0,o=!!(t&2);for(;n<=e.length;){let{len:s,starConsumed:i}=ah(e,n,o);if(s<0||s===0)return!1;i&&(o=!1),r++,n+=s+1}return!(e.charCodeAt(e.length-1)===46||!(t&1)&&r<2)}function En(e){return!e||e.startsWith("-")?!1:os(`refs/heads/${e}`,0)}function Zc(e){return e?os(`refs/tags/${e}`,0):!1}async function Qc(e,t){return e.refStore.readRef(t)}async function U(e,t){let n=t;for(let r=0;r<Jc;r++){let o=await Qc(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 te(e){return Qc(e,"HEAD")}async function Z(e){return U(e,"HEAD")}async function J(e,t,n){let r=e.hooks?await U(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 vr(e,t,n,r){let o=n.find(f=>f.name==="HEAD");if(!o)return;let s;if(r?.startsWith("refs/heads/"))s=r.slice(11);else{let f=n.find(l=>l.name.startsWith("refs/heads/")&&l.hash===o.hash);if(!f)return;s=f.name.slice(11)}let i=`refs/remotes/${t}/HEAD`;if(await e.refStore.readRef(i))return;let c=`refs/remotes/${t}/${s}`;await e.refStore.writeRef(i,{type:"symbolic",target:c})}async function he(e,t){let n=e.hooks?await U(e,t):null;await e.refStore.deleteRef(t),await as(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function ye(e,t="refs"){return e.refStore.listRefs(t)}function Pe(e){return e.replace("refs/heads/","")}function Gt(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}async function _n(e,t){let n=await te(e);n&&n.type==="symbolic"?await J(e,n.target,t):await J(e,"HEAD",t)}async function ef(e){if(e.refStore&&!(e.refStore instanceof Fn))return;let t=await ye(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"],r=[];for(let s of t){let i=H(e.gitDir,s.name);if(!(await e.fs.exists(i)&&(await e.fs.readFile(i)).trim().startsWith("ref: "))&&(r.push(s.name),n.push(`${s.hash} ${s.name}`),s.name.startsWith("refs/tags/")))try{let a=await we(e,s.hash);if(a.type==="tag"){let c=Zt(a.content).object;for(let f=0;f<100;f++){let l=await we(e,c);if(l.type!=="tag")break;c=Zt(l.content).object}n.push(`^${c}`)}}catch{}}await e.fs.writeFile(H(e.gitDir,"packed-refs"),`${n.join(`
30
30
  `)}
31
- `);for(let s of r){let i=v(e.gitDir,s);await e.fs.exists(i)&&await e.fs.rm(i)}await Vc(e,v(e.gitDir,"refs"));let o=v(e.gitDir,"refs");await e.fs.mkdir(o,{recursive:!0}),await e.fs.mkdir(v(o,"heads"),{recursive:!0}),await e.fs.mkdir(v(o,"tags"),{recursive:!0})}async function Vc(e,t){if(e.refStore&&!(e.refStore instanceof jn)||!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await Vc(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Mi,Wu,ji,qc,jn,ge=Re(()=>{"use strict";ie();Tr();me();Ke();Nn();Di();Mi=".lock",Wu=[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];ji="ref: ",qc=10,jn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=v(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(ji)?{type:"symbolic",target:s.slice(ji.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=Bc(n),o=v(this.gitDir,t);await cs(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${ji}${r.target}
31
+ `);for(let s of r){let i=H(e.gitDir,s);await e.fs.exists(i)&&await e.fs.rm(i)}await tf(e,H(e.gitDir,"refs"));let o=H(e.gitDir,"refs");await e.fs.mkdir(o,{recursive:!0}),await e.fs.mkdir(H(o,"heads"),{recursive:!0}),await e.fs.mkdir(H(o,"tags"),{recursive:!0})}async function tf(e,t){if(e.refStore&&!(e.refStore instanceof Fn)||!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 tf(e,H(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var Ni,ih,Fi,Jc,Fn,ge=xe(()=>{"use strict";ie();Tr();me();Be();kn();Gi();Ni=".lock",ih=[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];Fi="ref: ",Jc=10,Fn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=H(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Fi)?{type:"symbolic",target:s.slice(Fi.length)}:{type:"direct",hash:s}}let o=(await this.readPackedRefs()).get(t);return o?{type:"direct",hash:o}:null}async writeRef(t,n){let r=Xc(n),o=H(this.gitDir,t);await is(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Fi}${r.target}
32
32
  `):await this.fs.writeFile(o,`${r.hash}
33
- `)}async deleteRef(t){let n=v(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=v(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}async compareAndSwapRef(t,n,r){let s=(this.casLocks.get(t)??Promise.resolve(!1)).then(()=>this.compareAndSwapUnsafe(t,n,r),()=>this.compareAndSwapUnsafe(t,n,r));this.casLocks.set(t,s);try{return await s}finally{this.casLocks.get(t)===s&&this.casLocks.delete(t)}}async compareAndSwapUnsafe(t,n,r){let o=await this.resolveRefInternal(t);if(n===null){if(await this.readRef(t)!==null)return!1}else if(o!==n)return!1;return r===null?await this.deleteRef(t):await this.writeRef(t,r),!0}async resolveRefInternal(t){let n=t;for(let r=0;r<qc;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=v(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
34
- `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=v(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
33
+ `)}async deleteRef(t){let n=H(this.gitDir,t);await this.fs.exists(n)&&await this.fs.rm(n),await this.removePackedRef(t)}async listRefs(t="refs"){let n=[],r=H(this.gitDir,t);await this.fs.exists(r)&&await this.walkRefs(r,t,n);let o=await this.readPackedRefs();if(o.size>0){let s=new Set(n.map(a=>a.name)),i=`${t}/`;for(let[a,c]of o)a.startsWith(i)&&!s.has(a)&&n.push({name:a,hash:c})}return n.sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0)}async compareAndSwapRef(t,n,r){let s=(this.casLocks.get(t)??Promise.resolve(!1)).then(()=>this.compareAndSwapUnsafe(t,n,r),()=>this.compareAndSwapUnsafe(t,n,r));this.casLocks.set(t,s);try{return await s}finally{this.casLocks.get(t)===s&&this.casLocks.delete(t)}}async compareAndSwapUnsafe(t,n,r){let o=await this.resolveRefInternal(t);if(n===null){if(await this.readRef(t)!==null)return!1}else if(o!==n)return!1;return r===null?await this.deleteRef(t):await this.writeRef(t,r),!0}async resolveRefInternal(t){let n=t;for(let r=0;r<Jc;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=H(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
34
+ `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=H(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
35
35
  `),s=[],i=!1;for(let c of o){if(i&&c.startsWith("^")){i=!1;continue}if(i=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){i=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await this.fs.writeFile(n,s.join(`
36
- `)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=v(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function ir(e,t){let n=t;for(;;){let r=v(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Ir(e,r),refStore:new jn(e,r)};if(await Ku(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Ir(e,n),refStore:new jn(e,n)};let o=zu(n);if(o===n)return null;n=o}}async function Ku(e,t){let n=v(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=v(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function to(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:v(t,".git"),i=r?null:t,a=v(s,"HEAD"),c=await e.exists(a);await e.mkdir(v(s,"objects"),{recursive:!0}),await e.mkdir(v(s,"refs","heads"),{recursive:!0}),await e.mkdir(v(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Ir(e,s),refStore:new jn(e,s)};if(!c){await Ze(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(v(s,"config"),mi(l))}return{ctx:f,reinit:c}}async function cs(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function zu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Nn=Re(()=>{"use strict";Be();Ai();me();ge()});function no(e,t){return v(e.gitDir,"logs",t)}function Vu(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),l=n.slice(a+1,c),d=n.slice(c+2),u=d.indexOf(" ");if(u<0)return null;let h=parseInt(d.slice(0,u),10),m=d.slice(u+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:h,tz:m,message:r}}async function Qe(e,t){let n=no(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=Vu(s);i&&o.push(i)}return o}function Yc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Fn(e,t,n){let r=no(e,t);if(await cs(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Yc).join(`
36
+ `)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=H(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function Rn(e,t){let n=t;for(;;){let r=H(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n,objectStore:new Ir(e,r),refStore:new Fn(e,r)};if(await ch(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Ir(e,n),refStore:new Fn(e,n)};let o=fh(n);if(o===n)return null;n=o}}async function ch(e,t){let n=H(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=H(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function Qs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:H(t,".git"),i=r?null:t,a=H(s,"HEAD"),c=await e.exists(a);await e.mkdir(H(s,"objects"),{recursive:!0}),await e.mkdir(H(s,"refs","heads"),{recursive:!0}),await e.mkdir(H(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Ir(e,s),refStore:new Fn(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(H(s,"config"),bi(l))}return{ctx:f,reinit:c}}async function is(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function fh(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var kn=xe(()=>{"use strict";Ue();ji();me();ge()});function eo(e,t){return H(e.gitDir,"logs",t)}function lh(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),l=n.slice(a+1,c),d=n.slice(c+2),u=d.indexOf(" ");if(u<0)return null;let h=parseInt(d.slice(0,u),10),m=d.slice(u+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:h,tz:m,message:r}}async function et(e,t){let n=eo(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
37
+ `)){if(!s)continue;let i=lh(s);i&&o.push(i)}return o}function nf(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Un(e,t,n){let r=eo(e,t);if(await is(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(nf).join(`
38
38
  `)}
39
- `;await e.fs.writeFile(r,o)}async function ft(e,t,n){let r=no(e,t);await cs(e.fs,r);let o=`${Yc(n)}
40
- `;if(await e.fs.exists(r)){let s=await e.fs.readFile(r);await e.fs.writeFile(r,s+o)}else await e.fs.writeFile(r,o)}async function fs(e,t){let n=no(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 vn(e,t),c={oldHash:r??ne,newHash:o,...a,message:s};await ft(e,n,c),i&&n!=="HEAD"&&await ft(e,"HEAD",c)}var Ke=Re(()=>{"use strict";pt();rr();me();Nn();pt()});function Yu(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 Xu(e,t){let n=await _c(e,t);if(n.length===0)return null;if(n.length>1)throw new Li(t);return n[0]}async function Zu(e,t){if(t==="HEAD"||t==="@")return W(e,"HEAD");if(Xc.includes(t))return W(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Zt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Xu(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await W(e,t);if(s)return s}let n=await W(e,`refs/heads/${t}`);if(n)return n;let r=await W(e,`refs/tags/${t}`);if(r)return r;let o=await W(e,`refs/remotes/${t}`);return o||null}function Ju(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Xc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Qu(e,t,n){let r=Ju(t),o=await Qe(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function eh(e,t,n){if(n===""||n==="commit")try{return await He(e,t)}catch{return null}if(n==="tree"){let o;try{o=await He(e,t)}catch{return null}return(await j(e,o)).tree}return(await ye(e,t)).type!==n?null:t}async function th(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await He(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await eh(e,r,s.target)}else if(s.type==="tilde")for(let i=0;i<s.n;i++){if(!r)return null;let a=await j(e,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(s.n===0)continue;if(!r)return null;let i=await j(e,r);if(s.n>i.parents.length||(r=i.parents[s.n-1]??null,!r))return null}return r}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=Yu(t),s;return r!==void 0?s=await Qu(e,n,r):s=await Zu(e,n),s?th(e,s,o):null}function ro(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Xc,Li,cn=Re(()=>{"use strict";ie();Ke();ge();Xc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];Li=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function mt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function En(e){return typeof e=="string"?e==="120000":e===40960}function _n(e){return typeof e=="string"?e==="160000":e===57344}async function ls(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return nh.encode(r)}return e.readFileBuffer(t)}async function Un(e,t){let n=await ls(e,t);return gt("blob",n)}var nh,kn=Re(()=>{"use strict";ie();nh=new TextEncoder});function oh(e){return e.length===4&&e.toLowerCase()===".git"}function ih(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(oh(e))throw new Error(`invalid tree entry: '${e}'`);if(!sh.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function Rn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Zc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Zc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=An(a),f=o.padStart(6,"0");ih(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Jc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=rh.encode(`${i} ${s.name}\0`),c=Mt(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 rh,Zc,sh,so=Re(()=>{"use strict";pt();rh=new TextEncoder,Zc=new TextDecoder,sh=new Set(["100644","100755","040000","120000","160000"])});async function _e(e,t){return ef(e,t,"")}async function ef(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:ah(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 ef(e,a,c);r.push({mode:bn.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===bn.DIRECTORY?`${i.name}/`:i.name,f=a.mode===bn.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Jc({type:"tree",entries:r});return Ie(e,"tree",s)}async function qe(e,t,n=""){let r=await ye(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=Rn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===bn.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function de(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){if(t===n)return[];let r=[];return await tf(e,t,n,"",r),r.sort((o,s)=>Te(o.path,s.path))}async function Qc(e,t){let n=await ye(e,t);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return Rn(n.content).entries}async function tf(e,t,n,r,o){if(t===n)return;let s=t?await Qc(e,t):[],i=n?await Qc(e,n):[],a=new Map;for(let l of s)a.set(l.name,l);let c=new Map;for(let l of i)c.set(l.name,l);let f=new Set;for(let l of s)f.add(l.name);for(let l of i)f.add(l.name);for(let l of f){let d=a.get(l),u=c.get(l),h=r?`${r}/${l}`:l;if(d&&u){if(d.hash===u.hash&&d.mode===u.mode)continue;let m=d.mode===bn.DIRECTORY,p=u.mode===bn.DIRECTORY;m&&p?await tf(e,d.hash,u.hash,h,o):m?(await oo(e,d.hash,h,"deleted",o),o.push({path:h,status:"added",newHash:u.hash,newMode:u.mode})):p?(o.push({path:h,status:"deleted",oldHash:d.hash,oldMode:d.mode}),await oo(e,u.hash,h,"added",o)):o.push({path:h,status:"modified",oldHash:d.hash,newHash:u.hash,oldMode:d.mode,newMode:u.mode})}else if(d)d.mode===bn.DIRECTORY?await oo(e,d.hash,h,"deleted",o):o.push({path:h,status:"deleted",oldHash:d.hash,oldMode:d.mode});else{let m=u;m.mode===bn.DIRECTORY?await oo(e,m.hash,h,"added",o):o.push({path:h,status:"added",newHash:m.hash,newMode:m.mode})}}}async function oo(e,t,n,r,o){let s=await qe(e,t,n);for(let i of s)r==="added"?o.push({path:i.path,status:"added",newHash:i.hash,newMode:i.mode}):o.push({path:i.path,status:"deleted",oldHash:i.hash,oldMode:i.mode})}function ah(e){return e.toString(8).padStart(6,"0")}var De=Re(()=>{"use strict";se();ie();so();Di()});function nf(e){return/^[a-zA-Z0-9]$/.test(e)}function ch(e){return/^[a-zA-Z]$/.test(e)}function fh(e){return e>="0"&&e<="9"}function Gi(e){return e>="A"&&e<="Z"}function Ni(e){return e>="a"&&e<="z"}function rf(e){return/^\s$/.test(e)}function lh(e){return e===" "||e===" "}function _i(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function dh(e){return _i(e)&&!rf(e)}function uh(e){return _i(e)&&!nf(e)&&e!==" "}function hh(e){let t=e.charCodeAt(0);return t<32||t===127}function mh(e){return/^[0-9a-fA-F]$/.test(e)}function ds(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Fi(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(!ds(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]==="/"&&Fi(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(!ph(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=Fi(e,t,n,r,o);if(l!==1){if(!f||l!==-2)return l}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let l=!1,d="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let h=e[t];if(h==="\\"){if(t++,t>=e.length)return-1;h=e[t],ds(c,h,s)&&(l=!0)}else if(h==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,h=e[t],h==="\\"){if(t++,t>=e.length)return-1;h=e[t]}let m=d,p=h;if(c>=m&&c<=p&&(l=!0),s){if(Ni(c)){let g=c.toUpperCase();g>=m&&g<=p&&(l=!0)}else if(Gi(c)){let g=c.toLowerCase();g>=m&&g<=p&&(l=!0)}}h=""}else if(h==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let m=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-m-1;if(p<0||e[t-1]!==":")t=m-2,h="[",ds(c,h,s)&&(l=!0);else{let g=e.slice(m,m+p);gh(g,c,s)&&(l=!0),h=""}}else ds(c,h,s)&&(l=!0);d=h,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!ds(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function ph(e){return e==="*"||e==="?"||e==="["||e==="\\"}function gh(e,t,n){switch(e){case"alnum":return nf(t);case"alpha":return ch(t);case"blank":return lh(t);case"cntrl":return hh(t);case"digit":return fh(t);case"graph":return dh(t);case"lower":return Ni(t)||n&&Gi(t);case"print":return _i(t);case"punct":return uh(t);case"space":return rf(t);case"upper":return Gi(t)||n&&Ni(t);case"xdigit":return mh(t);default:return!1}}function fn(e,t,n=0){return Fi(e,0,t,0,n)===0?0:1}var us=Re(()=>{"use strict"});function cf(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 wh(e){return cf(e)===e.length}function bh(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|=io,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=af);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=sf);let a=Math.min(cf(o),s);return o[0]==="*"&&wh(o.slice(1))&&(r|=of),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function hs(e,t,n){let r=[];for(let o of e.split(`
41
- `)){let s=bh(o,t);s&&r.push(s)}return{patterns:r,src:n}}function yh(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&of){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return fn(n,e,2)===0}function Eh(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return fn(r,a,2)===0}function Ui(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&af&&!t)){if(s.flags&sf){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(yh(r,s))return s;continue}if(Eh(e,s))return s}}return null}function ln(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Ui(t,n,o);if(s)return s.flags&io?"not-ignored":"ignored"}if(e.excludeFile){let r=Ui(t,n,e.excludeFile);if(r)return r.flags&io?"not-ignored":"ignored"}if(e.globalExclude){let r=Ui(t,n,e.globalExclude);if(r)return r.flags&io?"not-ignored":"ignored"}return"undecided"}async function Ar(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=hs(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=hs(o,"",r)}catch{}}catch{}return t}function ar(e,t,n,r){let s=hs(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var sf,of,af,io,co=Re(()=>{"use strict";Be();me();us();sf=1,of=4,af=8,io=16});async function wt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0||_n(s.mode))continue;let i=v(e.workTree,s.path),a;try{a=await mt(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await Un(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await rt(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Te(s.path,i.path))}async function lt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!sr(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);if(t.mode!=null&&_n(t.mode)){let s=v(e.workTree,t.path);await e.fs.mkdir(s,{recursive:!0});return}let n=await ye(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=v(e.workTree,t.path);if(!qs(e.workTree,r))throw new Error(`refusing to check out path outside worktree: '${t.path}'`);let o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&En(t.mode)&&e.fs.symlink){let s=Rh.decode(n.content);if(!oc(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 ff(e,t){let n=await qe(e,t);for(let r of n)await lt(e,r)}async function dn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!sr(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=v(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await mt(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=kh.encode(f),d=await Ie(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...ve(),size:l.byteLength}};return{index:Pt(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Ie(e,"blob",s),a=o.mode!=null?xh(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...ve(),size:s.byteLength}};return{index:Pt(t,c),hash:i}}async function rt(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Ar(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=ar(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=v(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&ln(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&ln(s,l,!0)==="ignored")continue;let u=await rt(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(d.isFile){if(s&&ln(s,l,!1)==="ignored")continue;i.push(l)}}return i}function xh(e){return e>511?e:e&73?33261:33188}async function cr(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 cr(e,rn(t),n))}var kh,Rh,et=Re(()=>{"use strict";se();co();Ce();ie();Ks();me();kn();De();kh=new TextEncoder,Rh=new TextDecoder});function Bi(e){return e.existsOnDisk&&e.indexHash===null}async function Ch(e,t,n){let r=await Promise.all(t.map(m=>de(e,m.treeHash))),o=new Map,s=new Set;for(let m of n.entries)m.stage===0?o.set(m.path,m):s.add(m.path);let i=e.workTree?new Set(await rt(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await rt(e,e.workTree,"")):new Set),a),f=new Set;for(let m of r)for(let p of m.keys())f.add(p);let l=new Set;for(let m of n.entries)f.has(m.path)||l.add(m.path);for(let m of i)f.has(m)||l.add(m);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(m,p)=>r[m]?.get(p),h=[];for(let m of d){let p=null,g=null,w=null,b=null,E=null;if(r.length===1){let T=u(0,m);w=T?.hash??null,E=T?.mode??null}else if(r.length===2){let T=u(0,m),A=u(1,m);g=T?.hash??null,b=T?.mode??null,w=A?.hash??null,E=A?.mode??null}else if(r.length>=3){let T=u(0,m),A=u(1,m),U=u(2,m);p=T?.hash??null,g=A?.hash??null,b=A?.mode??null,w=U?.hash??null,E=U?.mode??null}let R=o.get(m)?.hash??null,x=s.has(m)?1:0,y=i.has(m),C,$=async()=>C!==void 0?C:y?(C=!(await c()).has(m),C):(C=!1,!1),D,P=async()=>{if(D!==void 0)return D;if(!y||!e.workTree)return D=null,null;let T=v(e.workTree,m);try{D=await Un(e.fs,T)}catch{D=null}return D};h.push({path:m,baseHash:p,headHash:g,remoteHash:w,indexHash:R,indexStage:x,existsOnDisk:y,isIgnoredOnDisk:$,getWorktreeHash:P,headMode:b,remoteMode:E})}return h}function fo(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 lo(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function Ph(e,t){switch(e.action){case"TAKE":return e.takeFrom==="head"?t.headHash:e.takeFrom==="remote"?t.remoteHash:e.takeFrom==="base"?t.baseHash:null;case"DELETE":return null;case"KEEP":return t.indexHash;default:return null}}async function $h(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=Ph(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await Oh(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function Oh(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Bi(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 Bi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Bi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function Sh(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,h=u?Number.parseInt(u,8):33188;o.push({path:c,mode:h,hash:d,stage:0,stat:ve()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:h});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Te(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function uo(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of Ih){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 st(e,t,n){let r=eo(e,t);await is(e.fs,r);let o=`${nf(n)}
40
+ `;if(await e.fs.exists(r)){let s=await e.fs.readFile(r);await e.fs.writeFile(r,s+o)}else await e.fs.writeFile(r,o)}async function as(e,t){let n=eo(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function re(e,t,n,r,o,s,i=!1){let a=await Mn(e,t),c={oldHash:r??ne,newHash:o,...a,message:s};await st(e,n,c),i&&n!=="HEAD"&&await st(e,"HEAD",c)}var Be=xe(()=>{"use strict";pt();sr();me();kn();pt()});function dh(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 uh(e,t){let n=await Vc(e,t);if(n.length===0)return null;if(n.length>1)throw new _i(t);return n[0]}async function hh(e,t){if(t==="HEAD"||t==="@")return U(e,"HEAD");if(rf.includes(t))return U(e,t);if(/^[0-9a-f]{40}$/.test(t))return await wt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await uh(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await U(e,t);if(s)return s}let n=await U(e,`refs/heads/${t}`);if(n)return n;let r=await U(e,`refs/tags/${t}`);if(r)return r;let o=await U(e,`refs/remotes/${t}`);return o||null}function mh(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of rf)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function ph(e,t,n){let r=mh(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 gh(e,t,n){if(n===""||n==="commit")try{return await Te(e,t)}catch{return null}if(n==="tree"){let o;try{o=await Te(e,t)}catch{return null}return(await j(e,o)).tree}return(await we(e,t)).type!==n?null:t}async function wh(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await Te(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await gh(e,r,s.target)}else if(s.type==="tilde")for(let i=0;i<s.n;i++){if(!r)return null;let a=await j(e,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(s.n===0)continue;if(!r)return null;let i=await j(e,r);if(s.n>i.parents.length||(r=i.parents[s.n-1]??null,!r))return null}return r}async function We(e,t){let{base:n,reflogIndex:r,suffixes:o}=dh(t),s;return r!==void 0?s=await ph(e,n,r):s=await hh(e,n),s?wh(e,s,o):null}function to(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var rf,_i,fn=xe(()=>{"use strict";ie();Be();ge();rf=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];_i=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function Eh(e){return e.length===4&&e.toLowerCase()===".git"}function kh(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(Eh(e))throw new Error(`invalid tree entry: '${e}'`);if(!yh.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function xn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=sf.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=sf.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=jn(a),f=o.padStart(6,"0");kh(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function of(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=bh.encode(`${i} ${s.name}\0`),c=jt(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var bh,sf,yh,no=xe(()=>{"use strict";pt();bh=new TextEncoder,sf=new TextDecoder,yh=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return cf(e,t,"")}async function cf(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:Rh(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 cf(e,a,c);r.push({mode:yn.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===yn.DIRECTORY?`${i.name}/`:i.name,f=a.mode===yn.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=of({type:"tree",entries:r});return Ie(e,"tree",s)}async function qe(e,t,n=""){let r=await we(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=xn(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===yn.DIRECTORY){let c=await qe(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function le(e,t){if(!t)return new Map;let n=await qe(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){if(t===n)return[];let r=[];return await ff(e,t,n,"",r),r.sort((o,s)=>ve(o.path,s.path))}async function af(e,t){let n=await we(e,t);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return xn(n.content).entries}async function ff(e,t,n,r,o){if(t===n)return;let s=t?await af(e,t):[],i=n?await af(e,n):[],a=new Map;for(let l of s)a.set(l.name,l);let c=new Map;for(let l of i)c.set(l.name,l);let f=new Set;for(let l of s)f.add(l.name);for(let l of i)f.add(l.name);for(let l of f){let d=a.get(l),u=c.get(l),h=r?`${r}/${l}`:l;if(d&&u){if(d.hash===u.hash&&d.mode===u.mode)continue;let m=d.mode===yn.DIRECTORY,p=u.mode===yn.DIRECTORY;m&&p?await ff(e,d.hash,u.hash,h,o):m?(await ro(e,d.hash,h,"deleted",o),o.push({path:h,status:"added",newHash:u.hash,newMode:u.mode})):p?(o.push({path:h,status:"deleted",oldHash:d.hash,oldMode:d.mode}),await ro(e,u.hash,h,"added",o)):o.push({path:h,status:"modified",oldHash:d.hash,newHash:u.hash,oldMode:d.mode,newMode:u.mode})}else if(d)d.mode===yn.DIRECTORY?await ro(e,d.hash,h,"deleted",o):o.push({path:h,status:"deleted",oldHash:d.hash,oldMode:d.mode});else{let m=u;m.mode===yn.DIRECTORY?await ro(e,m.hash,h,"added",o):o.push({path:h,status:"added",newHash:m.hash,newMode:m.mode})}}}async function ro(e,t,n,r,o){let s=await qe(e,t,n);for(let i of s)r==="added"?o.push({path:i.path,status:"added",newHash:i.hash,newMode:i.mode}):o.push({path:i.path,status:"deleted",oldHash:i.hash,oldMode:i.mode})}function Rh(e){return e.toString(8).padStart(6,"0")}var Ae=xe(()=>{"use strict";se();ie();no();Gi()});function mt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function Cn(e){return typeof e=="string"?e==="120000":e===40960}function Bn(e){return typeof e=="string"?e==="160000":e===57344}async function cs(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return xh.encode(r)}return e.readFileBuffer(t)}async function Wn(e,t){let n=await cs(e,t);return gt("blob",n)}var xh,Pn=xe(()=>{"use strict";ie();xh=new TextEncoder});function lf(e){return/^[a-zA-Z0-9]$/.test(e)}function Ch(e){return/^[a-zA-Z]$/.test(e)}function Ph(e){return e>="0"&&e<="9"}function Ui(e){return e>="A"&&e<="Z"}function Bi(e){return e>="a"&&e<="z"}function df(e){return/^\s$/.test(e)}function $h(e){return e===" "||e===" "}function qi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Oh(e){return qi(e)&&!df(e)}function Sh(e){return qi(e)&&!lf(e)&&e!==" "}function Ih(e){let t=e.charCodeAt(0);return t<32||t===127}function Th(e){return/^[0-9a-fA-F]$/.test(e)}function fs(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Wi(e,t,n,r,o){let s=(o&1)!==0,i=(o&2)!==0;for(;t<e.length;){let a=e[t];if(r>=n.length&&a!=="*")return-1;let c=r<n.length?n[r]:"";switch(a){case"\\":{if(t++,t>=e.length)return-1;if(!fs(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(i&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let l=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((l-1<1||e[l-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&Wi(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(!vh(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=Wi(e,t,n,r,o);if(l!==1){if(!f||l!==-2)return l}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let l=!1,d="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let h=e[t];if(h==="\\"){if(t++,t>=e.length)return-1;h=e[t],fs(c,h,s)&&(l=!0)}else if(h==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,h=e[t],h==="\\"){if(t++,t>=e.length)return-1;h=e[t]}let m=d,p=h;if(c>=m&&c<=p&&(l=!0),s){if(Bi(c)){let g=c.toUpperCase();g>=m&&g<=p&&(l=!0)}else if(Ui(c)){let g=c.toLowerCase();g>=m&&g<=p&&(l=!0)}}h=""}else if(h==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let m=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-m-1;if(p<0||e[t-1]!==":")t=m-2,h="[",fs(c,h,s)&&(l=!0);else{let g=e.slice(m,m+p);Hh(g,c,s)&&(l=!0),h=""}}else fs(c,h,s)&&(l=!0);d=h,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!fs(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function vh(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Hh(e,t,n){switch(e){case"alnum":return lf(t);case"alpha":return Ch(t);case"blank":return $h(t);case"cntrl":return Ih(t);case"digit":return Ph(t);case"graph":return Oh(t);case"lower":return Bi(t)||n&&Ui(t);case"print":return qi(t);case"punct":return Sh(t);case"space":return df(t);case"upper":return Ui(t)||n&&Bi(t);case"xdigit":return Th(t);default:return!1}}function ln(e,t,n=0){return Wi(e,0,t,0,n)===0?0:1}var ls=xe(()=>{"use strict"});function pf(e){for(let t=0;t<e.length;t++){let n=e[t];if(n==="\\"){t++;continue}if(n==="*"||n==="?"||n==="[")return t}return e.length}function Ah(e){return pf(e)===e.length}function Dh(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=so,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=mf);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=uf);let a=Math.min(pf(o),s);return o[0]==="*"&&Ah(o.slice(1))&&(r|=hf),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function ds(e,t,n){let r=[];for(let o of e.split(`
41
+ `)){let s=Dh(o,t);s&&r.push(s)}return{patterns:r,src:n}}function Mh(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&hf){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return ln(n,e,2)===0}function jh(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return ln(r,a,2)===0}function Ki(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&mf&&!t)){if(s.flags&uf){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(Mh(r,s))return s;continue}if(jh(e,s))return s}}return null}function dn(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Ki(t,n,o);if(s)return s.flags&so?"not-ignored":"ignored"}if(e.excludeFile){let r=Ki(t,n,e.excludeFile);if(r)return r.flags&so?"not-ignored":"ignored"}if(e.globalExclude){let r=Ki(t,n,e.globalExclude);if(r)return r.flags&so?"not-ignored":"ignored"}return"undecided"}async function Hr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=H(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=ds(r,"",n)}catch{}try{let r=await ke(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=ds(o,"",r)}catch{}}catch{}return t}function ar(e,t,n,r){let s=ds(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var uf,hf,mf,so,io=xe(()=>{"use strict";Ue();me();ls();uf=1,hf=4,mf=8,so=16});async function bt(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||Bn(s.mode))continue;let i=H(e.workTree,s.path),a;try{a=await mt(e.fs,i)}catch{a=null}if(!a){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!a.isFile&&!a.isSymbolicLink){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}await Wn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await ot(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>ve(s.path,i.path))}async function dt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!or(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);if(t.mode!=null&&Bn(t.mode)){let s=H(e.workTree,t.path);await e.fs.mkdir(s,{recursive:!0});return}let n=await we(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=H(e.workTree,t.path);if(!Bs(e.workTree,r))throw new Error(`refusing to check out path outside worktree: '${t.path}'`);let o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&Cn(t.mode)&&e.fs.symlink){let s=Gh.decode(n.content);if(!uc(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 gf(e,t){let n=await qe(e,t);for(let r of n)await dt(e,r)}async function un(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!or(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=H(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await mt(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),l=Lh.encode(f),d=await Ie(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...He(),size:l.byteLength}};return{index:Pt(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await Ie(e,"blob",s),a=o.mode!=null?Nh(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...He(),size:s.byteLength}};return{index:Pt(t,c),hash:i}}async function ot(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Hr(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);s=ar(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=H(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&dn(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&dn(s,l,!0)==="ignored")continue;let u=await ot(e,f,l,{skipIgnore:o,_ignore:s??void 0});i.push(...u)}else if(d.isFile){if(s&&dn(s,l,!1)==="ignored")continue;i.push(l)}}return i}function Nh(e){return e>511?e:e&73?33261:33188}async function cr(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 cr(e,sn(t),n))}var Lh,Gh,Je=xe(()=>{"use strict";se();io();Ce();ie();Ws();me();Pn();Ae();Lh=new TextEncoder,Gh=new TextDecoder});function zi(e){return e.existsOnDisk&&e.indexHash===null}async function Fh(e,t,n){let r=await Promise.all(t.map(m=>le(e,m.treeHash))),o=new Map,s=new Set;for(let m of n.entries)m.stage===0?o.set(m.path,m):s.add(m.path);let i=e.workTree?new Set(await ot(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await ot(e,e.workTree,"")):new Set),a),f=new Set;for(let m of r)for(let p of m.keys())f.add(p);let l=new Set;for(let m of n.entries)f.has(m.path)||l.add(m.path);for(let m of i)f.has(m)||l.add(m);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(m,p)=>r[m]?.get(p),h=[];for(let m of d){let p=null,g=null,w=null,b=null,R=null;if(r.length===1){let $=u(0,m);w=$?.hash??null,R=$?.mode??null}else if(r.length===2){let $=u(0,m),v=u(1,m);g=$?.hash??null,b=$?.mode??null,w=v?.hash??null,R=v?.mode??null}else if(r.length>=3){let $=u(0,m),v=u(1,m),N=u(2,m);p=$?.hash??null,g=v?.hash??null,b=v?.mode??null,w=N?.hash??null,R=N?.mode??null}let k=o.get(m)?.hash??null,x=s.has(m)?1:0,y=i.has(m),P,C=async()=>P!==void 0?P:y?(P=!(await c()).has(m),P):(P=!1,!1),A,D=async()=>{if(A!==void 0)return A;if(!y||!e.workTree)return A=null,null;let $=H(e.workTree,m);try{A=await Wn(e.fs,$)}catch{A=null}return A};h.push({path:m,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:x,existsOnDisk:y,isIgnoredOnDisk:C,getWorktreeHash:D,headMode:b,remoteMode:R})}return h}function ao(e,t){let n=e.remoteHash;return n===null?e.indexHash===null&&e.indexStage===0?{action:"SKIP",requirements:[]}:{action:"DELETE",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}:e.indexHash===n?{action:"KEEP",requirements:[]}:e.indexHash===null?{action:"TAKE",takeFrom:"remote",requirements:t.reset||!!t.strippedConflictPaths?.has(e.path)?[]:["NO_UNTRACKED"]}:{action:"TAKE",takeFrom:"remote",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}}function co(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function _h(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 Uh(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=_h(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await Bh(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function Bh(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":zi(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 zi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return zi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function Wh(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,h=u?Number.parseInt(u,8):33188;o.push({path:c,mode:h,hash:d,stage:0,stat:He()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:h});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>ve(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function fo(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of qh){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 fr(e,t,n,r){let o=await Ch(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 $h(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:uo(a,r)};let{newEntries:c,worktreeOps:f}=Sh(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function je(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!sr(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!qs(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await lt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await cr(e.fs,rn(o),n)}async function Bn(e,t,n,r){return fr(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:lo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function lf(e,t,n,r){return fr(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:lo,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function Cn(e,t,n){return fr(e,[{label:"target",treeHash:t}],n,{mergeFn:fo,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Hr(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:Ne(n)},i=await fr(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:fo,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 fr(e,t,n,r){let o=await Fh(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 Uh(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:fo(a,r)};let{newEntries:c,worktreeOps:f}=Wh(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function De(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!or(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=H(n,o.path);if(!Bs(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await dt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await cr(e.fs,sn(o),n)}async function hn(e,t,n,r){return fr(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function wf(e,t,n,r){return fr(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function On(e,t,n){return fr(e,[{label:"target",treeHash:t}],n,{mergeFn:ao,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Ar(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 fr(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:ao,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
47
47
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
48
- `);return c.length>0&&(i.errorOutput=N(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
- `,128)),i}if(e.workTree&&o.size>0){let a=await de(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var Ih,Jt=Re(()=>{"use strict";se();Ce();Ks();me();kn();De();et();Ih=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function I(e){return{stdout:"",stderr:`fatal: ${e}
50
- `,exitCode:128}}function N(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function q(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await ir(e,t);return r?n?{...r,...n}:r:Th}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:vh}async function Je(e){let t=await X(e);return t||I("your current branch does not have any commits yet")}function Pn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
- `){return jt(e)?N(`error: ${t} is not possible because you have unmerged files.
48
+ `);return c.length>0&&(i.errorOutput=_(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
+ `,128)),i}if(e.workTree&&o.size>0){let a=await le(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var qh,Nt=xe(()=>{"use strict";se();Ce();Ws();me();Pn();Ae();Je();qh=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function S(e){return{stdout:"",stderr:`fatal: ${e}
50
+ `,exitCode:128}}function _(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function K(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await Rn(e,t);return r?n?{...r,...n}:r:Kh}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:zh}async function Qe(e){let t=await Z(e);return t||S("your current branch does not have any commits yet")}function Sn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
+ `){return Lt(e)?_(`error: ${t} is not possible because you have unmerged files.
52
52
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
53
53
  hint: as appropriate to mark resolution and make a commit.
54
- `+n,128):null}async function bt(e,t,n){let r=await We(e,t);return r||I(n??`bad revision '${t}'`)}async function Ge(e,t,n){let r=await We(e,t);if(!r)return I(n??`bad revision '${t}'`);try{let o=await He(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return I(n??`bad revision '${t}'`)}}async function tt(e,t){try{return await Jr(e,t)}catch(n){return I(n.message)}}async function un(e,t){try{return await Ws(e,t)}catch(n){return I(n.message)}}function Wn(e,t){let n=new Map;for(let r of e.entries)r.stage===0&&n.set(r.path,r);for(let[r,o]of n){let s=t.get(r);if(!s||s.hash!==o.hash)return!0}for(let[r]of t)if(!n.has(r))return!0;return!1}function Te(e,t){return e<t?-1:e>t?1:0}function dt(e,t){return e.workTree?nt(e.workTree,t):""}function Z(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
- `);return t===-1?e:e.slice(0,t)}function Qt(e){return I(`ambiguous argument '${e}': unknown revision or path not in the working tree.
54
+ `+n,128):null}async function yt(e,t,n){let r=await We(e,t);return r||S(n??`bad revision '${t}'`)}async function Me(e,t,n){let r=await We(e,t);if(!r)return S(n??`bad revision '${t}'`);try{let o=await Te(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 Xr(e,t)}catch(n){return S(n.message)}}async function mn(e,t){try{return await Us(e,t)}catch(n){return S(n.message)}}function lr(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}async function lo(e,t,n){if(!e.workTree)return null;let r=await j(e,t),o=await le(e,r.tree),s=lr(n,o),a=(await bt(e,n)).some(c=>c.status==="modified"||c.status==="deleted");return!s&&!a?null:{hasStaged:s,hasUnstaged:a}}function uo(e,t,n=1){let r=[];return t.hasUnstaged&&r.push(`error: cannot ${e}: You have unstaged changes.`),t.hasStaged&&(t.hasUnstaged?r.push("error: additionally, your index contains uncommitted changes."):r.push(`error: cannot ${e}: Your index contains uncommitted changes.`)),r.push("error: Please commit or stash them."),_(`${r.join(`
55
+ `)}
56
+ `,n)}function ve(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?rt(e.workTree,t):""}function X(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
57
+ `);return t===-1?e:e.slice(0,t)}function Jt(e){return S(`ambiguous argument '${e}': unknown revision or path not in the working tree.
56
58
  Use '--' to separate paths from revisions, like this:
57
- 'git <command> [<revision>...] -- [<file>...]'`)}function Lt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${Z(t)}] ${ue(n)}`}async function qn(e,t,n){if(!await W(e,n.operationRef))return n.noOpError;let o=await W(e,"ORIG_HEAD")??await X(e);if(!o)return I(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),i=await j(e,o),a=await z(e),c=await Hr(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Gn(e,o),await ae(e,{version:2,entries:c.newEntries}),await je(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 yt(e,t,n,r,o,s){let i=an({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Ie(e,"commit",i);return await Gn(e,a),a}function Ot(e){let t=e.split(`
59
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Qt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${X(t)}] ${ue(n)}`}async function qn(e,t,n){if(!await U(e,n.operationRef))return n.noOpError;let o=await U(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 V(e),c=await Ar(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await _n(e,o),await ae(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps),s&&((await te(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 Ot(e,t,n,r,o,s){let i=cn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await Ie(e,"commit",i);return await _n(e,a),a}function St(e){let t=e.split(`
58
60
  `).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
61
  `)+`
60
- `}function Gt(e){return e.endsWith(`
62
+ `}function It(e){return e.endsWith(`
61
63
  `)?e:`${e}
62
64
  `}function Dr(e,t=0,n=!0){let o=n?Math.max(t,...e.map(s=>s.from.length)):0;return e.map(s=>{let i=s.prefix.padEnd(21);if(!s.to)return`${i}${s.from}
63
65
  `;let a=o>0?s.from.padEnd(o):s.from,c=s.suffix?` ${s.suffix}`:"";return`${i}${a} -> ${s.to}${c}
64
- `}).join("")}function ho(e,t,n){let r=[];for(let o of e){let s=t(o.remote.name),i=t(o.localRef);if(o.oldHash){if(o.oldHash!==o.remote.hash){let a=n(o.oldHash),c=n(o.remote.hash);r.push({prefix:` ${a}..${c}`,from:s,to:i})}}else{let c=o.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";r.push({prefix:c,from:s,to:i})}}return r}var Th,vh,se=Re(()=>{"use strict";rr();Ce();ie();wn();me();Ke();ge();Nn();cn();Jt();Th=I("not a git repository (or any of the parent directories): .git"),vh=I("this operation must be run in a work tree")});var pf={};nu(pf,{CommitHeap:()=>Kn,countAheadBehind:()=>zi,findOrphanedCommits:()=>Vi,walkCommits:()=>Nt});async function*Nt(e,t,n){if(n?.topoOrder){yield*Lh(e,t,n);return}let r=await mf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=n?.limit,c=0,f=Array.isArray(t)?t:[t];for(let l of f)o.has(l)||s.push(await Mr(e,l));for(;s.size>0;){let l=s.pop();if(o.has(l.hash))continue;if(o.add(l.hash),yield l,a!==void 0&&++c>=a)return;if(i?.has(l.hash))continue;let d=n?.firstParent?l.commit.parents.slice(0,1):l.commit.parents;for(let u of d)if(!o.has(u))try{s.push(await Mr(e,u))}catch{}}}async function*Lh(e,t,n){let r=await mf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let h of a)o.has(h)||s.push(await Mr(e,h));let c=[],f=new Map;for(;s.size>0;){let h=s.pop();if(o.has(h.hash)||(o.add(h.hash),f.set(h.hash,c.length),c.push(h),i?.has(h.hash)))continue;let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let p of m)if(!o.has(p))try{s.push(await Mr(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let h of c){let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let p of m){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let u=[];for(let h=l-1;h>=0;h--)d[h]===0&&u.push(h);for(;u.length>0;){let h=u.pop();yield c[h];let m=n?.firstParent?c[h].commit.parents.slice(0,1):c[h].commit.parents;for(let p of m){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&u.push(g)}}}}async function zi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of Nt(e,t))r.add(a.hash);let o=new Set;for await(let a of Nt(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 Vi(e,t,n){let r=n?.maxCount??25,o=await we(e,"refs"),s=[];for(let l of o)try{s.push(await He(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of Nt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Kn;for(f.push(await Mr(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 Mr(e,d))}}return a}async function mf(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Nt(e,t))n.add(r.hash);return n}async function Mr(e,t){return{hash:t,commit:await j(e,t)}}var Kn,dr=Re(()=>{"use strict";se();ie();ge();Kn=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var ai=class e{_def;constructor(t){this._def=t}name(t){return new e({...this._def,name:t})}describe(t){return new e({...this._def,description:t})}optional(){return new e({...this._def,required:!1})}variadic(){return new e({...this._def,variadic:!0})}default(t){return new e({...this._def,required:!1,default:t})}};function Ba(e){return new ai({_kind:"arg",type:e,required:!0})}function Wa(){return Ba("string")}function qa(){return Ba("number")}var Ns=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 ci=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 Ka(e){return new ci({_kind:"option",type:e})}function za(){return Ka("string")}function Va(){return Ka("number")}var Y={string:za,number:Va};function S(){return new Ns}var K={string:Wa,number:qa};function ru(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+=`
66
+ `}).join("")}function us(e,t,n){let r=[];for(let o of e){let s=t(o.remote.name),i=t(o.localRef);if(o.oldHash){if(o.oldHash!==o.remote.hash){let a=n(o.oldHash),c=n(o.remote.hash);r.push({prefix:` ${a}..${c}`,from:s,to:i})}}else{let c=o.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";r.push({prefix:c,from:s,to:i})}}return r}var Kh,zh,se=xe(()=>{"use strict";sr();Ce();ie();bn();me();Be();ge();kn();fn();Ae();Nt();Je();Kh=S("not a git repository (or any of the parent directories): .git"),zh=S("this operation must be run in a work tree")});var Rf={};bu(Rf,{CommitHeap:()=>Kn,countAheadBehind:()=>Zi,findOrphanedCommits:()=>Ji,walkCommits:()=>Ft});async function*Ft(e,t,n){if(n?.topoOrder){yield*Qh(e,t,n);return}let r=await kf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=n?.limit,c=0,f=Array.isArray(t)?t:[t];for(let l of f)o.has(l)||s.push(await Mr(e,l));for(;s.size>0;){let l=s.pop();if(o.has(l.hash))continue;if(o.add(l.hash),yield l,a!==void 0&&++c>=a)return;if(i?.has(l.hash))continue;let d=n?.firstParent?l.commit.parents.slice(0,1):l.commit.parents;for(let u of d)if(!o.has(u))try{s.push(await Mr(e,u))}catch{}}}async function*Qh(e,t,n){let r=await kf(e,n?.exclude),o=new Set(r),s=new Kn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let h of a)o.has(h)||s.push(await Mr(e,h));let c=[],f=new Map;for(;s.size>0;){let h=s.pop();if(o.has(h.hash)||(o.add(h.hash),f.set(h.hash,c.length),c.push(h),i?.has(h.hash)))continue;let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let p of m)if(!o.has(p))try{s.push(await Mr(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let h of c){let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let p of m){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let u=[];for(let h=l-1;h>=0;h--)d[h]===0&&u.push(h);for(;u.length>0;){let h=u.pop();yield c[h];let m=n?.firstParent?c[h].commit.parents.slice(0,1):c[h].commit.parents;for(let p of m){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&u.push(g)}}}}async function Zi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of Ft(e,t))r.add(a.hash);let o=new Set;for await(let a of Ft(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 Ji(e,t,n){let r=n?.maxCount??25,o=await ye(e,"refs"),s=[];for(let l of o)try{s.push(await Te(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of Ft(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Kn;for(f.push(await Mr(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 Mr(e,d))}}return a}async function kf(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Ft(e,t))n.add(r.hash);return n}async function Mr(e,t){return{hash:t,commit:await j(e,t)}}var Kn,ur=xe(()=>{"use strict";se();ie();ge();Kn=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var di=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 Xa(e){return new di({_kind:"arg",type:e,required:!0})}function Za(){return Xa("string")}function Ja(){return Xa("number")}var Ls=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 ui=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 Qa(e){return new ui({_kind:"option",type:e})}function ec(){return Qa("string")}function tc(){return Qa("number")}var Y={string:ec,number:tc};function O(){return new Ls}var q={string:Za,number:Ja};function yu(e){switch(e.type){case"unknown_option":{let t=`Unknown option "${e.name}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
65
67
  Not all git options are supported. Run 'git <command> --help' for available options.`,t}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`git: '${e.path.replace(/^git /,"")}' is not a git command.`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
66
- Run 'git help' for available commands.`,t}}}function fi(e){return e.map(ru).join(`
68
+ Run 'git help' for available commands.`,t}}}function hi(e){return e.map(yu).join(`
67
69
  `)+`
68
- `}function su(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 Fs(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:su(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 Ya(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,h]of Object.entries(e)){let m=Yr(u);s.set(m,{key:u,def:h}),h.short&&i.set(h.short,{key:u,def:h})}let a={},c=[],f=[],l=0;for(;l<n.length;){let u=n[l];if(u==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(u.startsWith("--")){let h=u.indexOf("="),m,p;h!==-1?(m=u.slice(2,h),p=u.slice(h+1)):m=u.slice(2);let g=s.get(m);if(!g){if(m.startsWith("no-")){let k=s.get(m.slice(3));if(k&&k.def._kind==="flag"){a[k.key]=k.def.counted?0:!1,l++;continue}}let E=[...s.keys()];o.push({type:"unknown_option",name:`--${m}`,suggestions:Fs(m,E).map(k=>`--${k}`)}),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=Vr(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(u.startsWith("-")&&u.length>1){let h=u.slice(1);for(let m=0;m<h.length;m++){let p=h[m],g=i.get(p);if(!g){let k=[];s.has(p)&&k.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:k});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=h.slice(m+1),b=w.length>0?w:n[++l];if(b===void 0){o.push({type:"missing_value",name:g.key});break}let E=Vr(b,g.def.type,g.key,o);E!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(E)):a[g.key]=E);break}l++;continue}c.push(u),l++}let d=0;for(let u=0;u<t.length;u++){let h=t[u],m=h.name??`arg${u}`;if(h.variadic){let p=c.slice(d);p.length>0?a[m]=p.map(g=>Vr(g,h.type,m,o)):h.required?o.push({type:"missing_required",name:m,kind:"arg"}):h.default!==void 0?a[m]=h.default:a[m]=[],d=c.length}else{let p=c[d];p!==void 0?(a[m]=Vr(p,h.type,m,o),d++):h.required?o.push({type:"missing_required",name:m,kind:"arg"}):h.default!==void 0&&(a[m]=h.default)}}if(d<c.length)for(let u=d;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,h]of Object.entries(e))if(a[u]===void 0){if(h._kind==="flag")a[u]=h.default??(h.counted?0:!1);else if(h._kind==="option"){let m=h;if(m.env&&r?.[m.env]!==void 0){let p=Vr(r[m.env],m.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(m.required&&m.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):m.default!==void 0&&(a[u]=m.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Vr(e,t,n,r){switch(t){case"string":return e;case"number":{let o=Number(e);if(Number.isNaN(o)){r.push({type:"invalid_type",name:n,expected:"number",received:e});return}return o}case"boolean":{if(e==="true"||e==="1")return!0;if(e==="false"||e==="0")return!1;r.push({type:"invalid_type",name:n,expected:"boolean",received:e});return}default:return e}}function Yr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Cr(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=ou(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
69
- `)}function ou(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Yr(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 Xa(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Za(e){return e?e.map(t=>t._def):[]}var _s=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,Xa(n.options),Za(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=Yr(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=Fs(o,[...this.children.keys()]);return{stdout:"",stderr:fi([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(iu(t))return{stdout:Cr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ya(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:fi(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:Cr(this),stderr:"",exitCode:0}}};function li(e,t){return new _s(e,t.description,Xa(t.options),Za(t.args),t.examples??[],t.handler,t.transformArgs)}function iu(e){return e.some(t=>t==="--help")}se();co();Ce();me();us();var po=1,Wi=2,mo=4,qi=8,ms=16,uf=new Set(["*","?","[","\\"]),Hh={glob:po,literal:Wi,icase:mo,top:qi,exclude:ms};function lr(e){for(let t=0;t<e.length;t++)if(uf.has(e[t]))return!0;return!1}function Dh(e){for(let t=0;t<e.length;t++)if(uf.has(e[t]))return t;return e.length}function df(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=Hh[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=qi,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=ms,r=r.slice(2));n&Wi&&n&po&&(n&=~po);let o;n&qi||t===""?o=df(r):o=df(`${t}/${r}`);let s=!!(n&Wi),i=s?!1:lr(o),a=s?o.length:Dh(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function go(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&mo),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&mo){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&po&&(i|=2),o&mo&&(i|=1),fn(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&ms?go(o,t)&&(r=!0):go(o,t)&&(n=!0);return n&&!r}et();function hf(e,t){e.command("add",{description:"Add file contents to the index",args:[K.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:S().alias("A").describe("Add changes from all tracked and untracked files"),force:S().alias("f").describe("Allow adding otherwise ignored files"),update:S().alias("u").describe("Update tracked files"),"dry-run":S().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await z(s);return p=await Ki(s,p,a,"",c),n["dry-run"]||await ae(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
70
- Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],u=[];for(let p of f)lr(p)?u.push(p):d.push(p);let h=[];for(let p of d){let g=Dt(r.cwd,p),w=nt(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return I(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let k=l.entries.some(x=>x.path===w||x.path.startsWith(`${w}/`)),R=await jh(s,a,w,k);if(R){k&&((await r.fs.stat(g)).isDirectory?l=await Ki(s,l,g,w,c):l=(await dn(s,l,w)).index),h.push(R);continue}}if((await r.fs.stat(g)).isDirectory)l=await Ki(s,l,g,w,c);else{let k=l.entries.find(x=>x.path===w&&x.stage===0)?.hash,R=await dn(s,l,w);l=R.index,c.actions&&R.hash!==k&&c.actions.push(`add '${w}'
71
- `)}}else if(l.entries.some(k=>k.path===w||k.path.startsWith(`${w}/`))){if(c.actions)for(let k of l.entries)(k.path===w||k.path.startsWith(`${w}/`))&&c.actions.push(`remove '${k.path}'
72
- `);l={...l,entries:l.entries.filter(k=>k.path!==w&&!k.path.startsWith(`${w}/`))}}else return I(`pathspec '${p}' did not match any files`)}if(h.length>0)return n["dry-run"]||await ae(s,l),N(`The following paths are ignored by one of your .gitignore files:
70
+ `}function Eu(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function Gs(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Eu(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 nc(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,h]of Object.entries(e)){let m=zr(u);s.set(m,{key:u,def:h}),h.short&&i.set(h.short,{key:u,def:h})}let a={},c=[],f=[],l=0;for(;l<n.length;){let u=n[l];if(u==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(u.startsWith("--")){let h=u.indexOf("="),m,p;h!==-1?(m=u.slice(2,h),p=u.slice(h+1)):m=u.slice(2);let g=s.get(m);if(!g){if(m.startsWith("no-")){let E=s.get(m.slice(3));if(E&&E.def._kind==="flag"){a[E.key]=E.def.counted?0:!1,l++;continue}}let R=[...s.keys()];o.push({type:"unknown_option",name:`--${m}`,suggestions:Gs(m,R).map(E=>`--${E}`)}),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=Kr(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(u.startsWith("-")&&u.length>1){let h=u.slice(1);for(let m=0;m<h.length;m++){let p=h[m],g=i.get(p);if(!g){let E=[];s.has(p)&&E.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:E});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=h.slice(m+1),b=w.length>0?w:n[++l];if(b===void 0){o.push({type:"missing_value",name:g.key});break}let R=Kr(b,g.def.type,g.key,o);R!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(R)):a[g.key]=R);break}l++;continue}c.push(u),l++}let d=0;for(let u=0;u<t.length;u++){let h=t[u],m=h.name??`arg${u}`;if(h.variadic){let p=c.slice(d);p.length>0?a[m]=p.map(g=>Kr(g,h.type,m,o)):h.required?o.push({type:"missing_required",name:m,kind:"arg"}):h.default!==void 0?a[m]=h.default:a[m]=[],d=c.length}else{let p=c[d];p!==void 0?(a[m]=Kr(p,h.type,m,o),d++):h.required?o.push({type:"missing_required",name:m,kind:"arg"}):h.default!==void 0&&(a[m]=h.default)}}if(d<c.length)for(let u=d;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,h]of Object.entries(e))if(a[u]===void 0){if(h._kind==="flag")a[u]=h.default??(h.counted?0:!1);else if(h._kind==="option"){let m=h;if(m.env&&r?.[m.env]!==void 0){let p=Kr(r[m.env],m.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(m.required&&m.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):m.default!==void 0&&(a[u]=m.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Kr(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 zr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Cr(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=ku(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(`
71
+ `)}function ku(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=zr(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 rc(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function sc(e){return e?e.map(t=>t._def):[]}var Ns=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,rc(n.options),sc(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=zr(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(!this.handler&&o&&!o.startsWith("-")){let s=Gs(o,[...this.children.keys()]);return{stdout:"",stderr:hi([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Ru(t))return{stdout:Cr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=nc(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:hi(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:Cr(this),stderr:"",exitCode:0}}};function mi(e,t){return new Ns(e,t.description,rc(t.options),sc(t.args),t.examples??[],t.handler,t.transformArgs)}function Ru(e){return e.some(t=>t==="--help")}se();io();Ce();me();ls();var mo=1,Vi=2,ho=4,Yi=8,hs=16,yf=new Set(["*","?","[","\\"]),Yh={glob:mo,literal:Vi,icase:ho,top:Yi,exclude:hs};function dr(e){for(let t=0;t<e.length;t++)if(yf.has(e[t]))return!0;return!1}function Xh(e){for(let t=0;t<e.length;t++)if(yf.has(e[t]))return t;return e.length}function bf(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 _e(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=Yh[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Yi,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=hs,r=r.slice(2));n&Vi&&n&mo&&(n&=~mo);let o;n&Yi||t===""?o=bf(r):o=bf(`${t}/${r}`);let s=!!(n&Vi),i=s?!1:dr(o),a=s?o.length:Xh(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function po(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&ho),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&ho){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&mo&&(i|=2),o&ho&&(i|=1),ln(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&hs?po(o,t)&&(r=!0):po(o,t)&&(n=!0);return n&&!r}Je();function Ef(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:O().alias("A").describe("Add changes from all tracked and untracked files"),force:O().alias("f").describe("Allow adding otherwise ignored files"),update:O().alias("u").describe("Update tracked files"),"dry-run":O().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await V(s);return p=await Xi(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.
72
+ Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await V(s),d=[],u=[];for(let p of f)dr(p)?u.push(p):d.push(p);let h=[];for(let p of d){let g=Mt(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 E=l.entries.some(x=>x.path===w||x.path.startsWith(`${w}/`)),k=await Jh(s,a,w,E);if(k){E&&((await r.fs.stat(g)).isDirectory?l=await Xi(s,l,g,w,c):l=(await un(s,l,w)).index),h.push(k);continue}}if((await r.fs.stat(g)).isDirectory)l=await Xi(s,l,g,w,c);else{let E=l.entries.find(x=>x.path===w&&x.stage===0)?.hash,k=await un(s,l,w);l=k.index,c.actions&&k.hash!==E&&c.actions.push(`add '${w}'
73
+ `)}}else if(l.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`))){if(c.actions)for(let E of l.entries)(E.path===w||E.path.startsWith(`${w}/`))&&c.actions.push(`remove '${E.path}'
74
+ `);l={...l,entries:l.entries.filter(E=>E.path!==w&&!E.path.startsWith(`${w}/`))}}else return S(`pathspec '${p}' did not match any files`)}if(h.length>0)return n["dry-run"]||await ae(s,l),_(`The following paths are ignored by one of your .gitignore files:
73
75
  ${h.join(`
74
76
  `)}
75
77
  hint: Use -f if you really want to add them.
76
78
  hint: Disable this message with "git config set advice.addIgnoredFile false"
77
- `);if(u.length>0){let p=await Mh(s,r.cwd,l,u,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 Mh(e,t,n,r,o){let s=e.workTree,i=dt(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&go(a[u],d)&&(c[u]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!Ee(a,d.path))continue;f(d.path);let u=v(s,d.path);if(await e.fs.exists(u)){let h=await dn(e,n,d.path);n=h.index,o?.actions&&h.hash!==d.hash&&o.actions.push(`add '${d.path}'
79
+ `);if(u.length>0){let p=await Zh(s,r.cwd,l,u,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 Zh(e,t,n,r,o){let s=e.workTree,i=ut(e,t),a=r.map(d=>_e(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&po(a[u],d)&&(c[u]=!0)},l=[];for(let d of n.entries){if(d.stage>0||!Ee(a,d.path))continue;f(d.path);let u=H(s,d.path);if(await e.fs.exists(u)){let h=await un(e,n,d.path);n=h.index,o?.actions&&h.hash!==d.hash&&o.actions.push(`add '${d.path}'
78
80
  `)}else o?.actions&&o.actions.push(`remove '${d.path}'
79
- `),l.push(d.path)}for(let d of l)n=ct(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(h=>h.path)),u=await rt(e,s,"",{skipIgnore:o?.skipIgnore});for(let h of u){if(d.has(h)||!Ee(a,h))continue;f(h),o?.actions&&o.actions.push(`add '${h}'
80
- `),n=(await dn(e,n,h)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&ms))return{index:n,error:I(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function Ki(e,t,n,r,o){let s=r===""?"":`${r}/`,i=e.workTree,a=[],c=new Set;for(let f of t.entries){if(!(s===""||f.path.startsWith(s))||c.has(f.path))continue;c.add(f.path);let l=v(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,u=await dn(e,t,f.path);t=u.index,o?.actions&&(d||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
81
+ `),l.push(d.path)}for(let d of l)n=lt(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(h=>h.path)),u=await ot(e,s,"",{skipIgnore:o?.skipIgnore});for(let h of u){if(d.has(h)||!Ee(a,h))continue;f(h),o?.actions&&o.actions.push(`add '${h}'
82
+ `),n=(await un(e,n,h)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&hs))return{index:n,error:S(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function Xi(e,t,n,r,o){let s=r===""?"":`${r}/`,i=e.workTree,a=[],c=new Set;for(let f of t.entries){if(!(s===""||f.path.startsWith(s))||c.has(f.path))continue;c.add(f.path);let l=H(i,f.path);if(await e.fs.exists(l)){let d=f.stage>0,u=await un(e,t,f.path);t=u.index,o?.actions&&(d||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
81
83
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
82
- `),a.push(f.path)}for(let f of a)t=ct(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await rt(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
83
- `),t=(await dn(e,t,d)).index}}return t}async function jh(e,t,n,r){let o=await Ar(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=ar(o,i,"",v(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=v(t,a);if(ln(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(v(c,".gitignore"));o=ar(o,f,a,v(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(v(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(ln(o,n,i)==="ignored")return n}return null}se();se();dr();ie();me();ge();async function $e(e,t){let n=v(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Me(e,t,n){await e.fs.writeFile(v(e.gitDir,t),n)}async function be(e,t){let n=v(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ps(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}async function Ft(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function St(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function ur(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await he(e,t);await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}var Yi="DETACH_POINT";async function gf(e,t){await e.fs.writeFile(v(e.gitDir,Yi),t)}async function Et(e){let t=v(e.gitDir,Yi);await e.fs.exists(t)&&await e.fs.rm(t)}async function gs(e){let t=v(e.gitDir,Yi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();ge();async function It(e){let t=await $e(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ws(e){let t=await $e(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
84
- `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function wo(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ws(e),o=await W(e,`refs/bisect/${n}`),s=[],i=[],a=await we(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await $e(e,"BISECT_HEAD")!=null||await e.fs.exists(v(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(v(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function Tt(e,t){let n=await $e(e,"BISECT_LOG")??"";await Me(e,"BISECT_LOG",n+t+`
85
- `)}async function bo(e){let t=await we(e,"refs/bisect");for(let r of t)await he(e,r.name);await be(e,"BISECT_EXPECTED_REV"),await be(e,"BISECT_ANCESTORS_OK"),await be(e,"BISECT_LOG"),await be(e,"BISECT_TERMS"),await be(e,"BISECT_NAMES"),await be(e,"BISECT_FIRST_PARENT"),await be(e,"BISECT_HEAD"),await be(e,"BISECT_START");let n=v(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function wf(e,t,n,r,o){let s=[],i=new Map;for await(let g of Nt(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],E=0;for(;E<b.length;){let k=b[E++];if(w.has(k)||!c.has(k))continue;w.add(k);let R=i.get(k);if(R)for(let x of R)!w.has(x)&&c.has(x)&&b.push(x)}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 u=!1;if(d===a){u=!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 h=s.find(g=>g.hash===l),m=Gh(a),p=Nh(a);return{hash:h.hash,subject:h.subject,remaining:m,steps:p,found:!1,onlySkippedLeft:u}}function Gh(e){return Math.floor((e-1)/2)}function Nh(e){return e<=1?0:Math.ceil(Math.log2(e))}function bf(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
84
+ `),a.push(f.path)}for(let f of a)t=lt(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await ot(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
85
+ `),t=(await un(e,t,d)).index}}return t}async function Jh(e,t,n,r){let o=await Hr(e);try{let i=await e.fs.readFile(H(t,".gitignore"));o=ar(o,i,"",H(t,".gitignore"))}catch{}let s=n.split("/");for(let i=0;i<s.length-1;i++){let a=s.slice(0,i+1).join("/"),c=H(t,a);if(dn(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(H(c,".gitignore"));o=ar(o,f,a,H(c,".gitignore"))}catch{}}if(!r){let i=await e.fs.stat(H(t,n)).then(a=>a.isDirectory).catch(()=>!1);if(dn(o,n,i)==="ignored")return n}return null}se();se();ur();ie();me();ge();async function $e(e,t){let n=H(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Le(e,t,n){await e.fs.writeFile(H(e.gitDir,t),n)}async function be(e,t){let n=H(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ms(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}async function en(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function _t(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await be(e,"MERGE_MSG"),await be(e,"SQUASH_MSG")}async function hr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await he(e,t);await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"SQUASH_MSG")}var Qi="DETACH_POINT";async function xf(e,t){await e.fs.writeFile(H(e.gitDir,Qi),t)}async function Et(e){let t=H(e.gitDir,Qi);await e.fs.exists(t)&&await e.fs.rm(t)}async function ps(e){let t=H(e.gitDir,Qi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();ge();async function Tt(e){let t=await $e(e,"BISECT_START");return t!=null&&t.trim().length>0}async function gs(e){let t=await $e(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
86
+ `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function go(e){let t=(await $e(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await gs(e),o=await U(e,`refs/bisect/${n}`),s=[],i=[],a=await ye(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await $e(e,"BISECT_HEAD")!=null||await e.fs.exists(H(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(H(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:i,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function vt(e,t){let n=await $e(e,"BISECT_LOG")??"";await Le(e,"BISECT_LOG",n+t+`
87
+ `)}async function wo(e){let t=await ye(e,"refs/bisect");for(let r of t)await he(e,r.name);await be(e,"BISECT_EXPECTED_REV"),await be(e,"BISECT_ANCESTORS_OK"),await be(e,"BISECT_LOG"),await be(e,"BISECT_TERMS"),await be(e,"BISECT_NAMES"),await be(e,"BISECT_FIRST_PARENT"),await be(e,"BISECT_HEAD"),await be(e,"BISECT_START");let n=H(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Cf(e,t,n,r,o){let s=[],i=new Map;for await(let g of Ft(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],R=0;for(;R<b.length;){let E=b[R++];if(w.has(E)||!c.has(E))continue;w.add(E);let k=i.get(E);if(k)for(let x of k)!w.has(x)&&c.has(x)&&b.push(x)}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 u=!1;if(d===a){u=!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 h=s.find(g=>g.hash===l),m=em(a),p=tm(a);return{hash:h.hash,subject:h.subject,remaining:m,steps:p,found:!1,onlySkippedLeft:u}}function em(e){return Math.floor((e-1)/2)}function tm(e){return e<=1?0:Math.ceil(Math.log2(e))}function Pf(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
86
88
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
87
89
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
88
- `}function yf(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
90
+ `}function $f(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
89
91
  [${e.hash}] ${e.subject}
90
- `}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
92
+ `}async function Of(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
91
93
  `;return i+=`commit ${t}
92
94
  `,i+=`Author: ${n.author.name} <${n.author.email}>
93
95
  `,i+=`Date: ${s}
94
96
  `,i+=`
95
97
  `,i+=` ${r}
96
98
  `,i+=`
97
- `,i}se();dr();Be();Ce();ie();me();Ke();ge();se();dr();Be();Ce();ie();me();ie();wn();me();function jr(e){return v(e.gitDir,"rebase-merge")}async function _t(e){return e.fs.exists(jr(e))}async function kt(e){let t=jr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(v(t,"head-name")),r=await e.fs.readFile(v(t,"orig-head")),o=await e.fs.readFile(v(t,"onto")),s=Number.parseInt(await e.fs.readFile(v(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(v(t,"end")),10),a=await e.fs.exists(v(t,"git-rebase-todo"))?v(t,"git-rebase-todo"):v(t,"todo"),c=kf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=kf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Xi(e,t){let n=jr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
98
- `),await e.fs.writeFile(v(n,"orig-head"),`${t.origHead}
99
- `),await e.fs.writeFile(v(n,"onto"),`${t.onto}
100
- `),await e.fs.writeFile(v(n,"msgnum"),`${String(t.msgnum)}
101
- `),await e.fs.writeFile(v(n,"end"),`${String(t.end)}
102
- `),await e.fs.writeFile(v(n,"git-rebase-todo"),Eo(t.todo)),await e.fs.writeFile(v(n,"done"),Eo(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function Cf(e){let t=jr(e),n=await kt(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(v(t,"msgnum"),`${String(n.msgnum)}
103
- `),await e.fs.writeFile(v(t,"git-rebase-todo"),Eo(n.todo)),await e.fs.writeFile(v(t,"done"),Eo(n.done))}async function Zi(e){let t=jr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function ko(e,t,n){let r=jr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
99
+ `,i}se();ur();Ue();Ce();ie();me();Be();ge();se();ur();Ue();Ce();ie();me();ie();bn();me();function jr(e){return H(e.gitDir,"rebase-merge")}async function Ut(e){return e.fs.exists(jr(e))}async function kt(e){let t=jr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(H(t,"head-name")),r=await e.fs.readFile(H(t,"orig-head")),o=await e.fs.readFile(H(t,"onto")),s=Number.parseInt(await e.fs.readFile(H(t,"msgnum")),10),i=Number.parseInt(await e.fs.readFile(H(t,"end")),10),a=await e.fs.exists(H(t,"git-rebase-todo"))?H(t,"git-rebase-todo"):H(t,"todo"),c=Sf(await e.fs.readFile(a)),f=await e.fs.exists(H(t,"done"))?await e.fs.readFile(H(t,"done")):"",l=Sf(f),d=await e.fs.exists(H(t,"reflog-action"))?(await e.fs.readFile(H(t,"reflog-action"))).trim():"rebase";return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i,reflogAction:d}}async function ea(e,t){let n=jr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(H(n,"head-name"),`${t.headName}
100
+ `),await e.fs.writeFile(H(n,"orig-head"),`${t.origHead}
101
+ `),await e.fs.writeFile(H(n,"onto"),`${t.onto}
102
+ `),await e.fs.writeFile(H(n,"msgnum"),`${String(t.msgnum)}
103
+ `),await e.fs.writeFile(H(n,"end"),`${String(t.end)}
104
+ `),await e.fs.writeFile(H(n,"reflog-action"),`${t.reflogAction??"rebase"}
105
+ `),await e.fs.writeFile(H(n,"git-rebase-todo"),yo(t.todo)),await e.fs.writeFile(H(n,"done"),yo(t.done)),await e.fs.writeFile(H(n,"interactive"),"")}async function vf(e){let t=jr(e),n=await kt(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(H(t,"msgnum"),`${String(n.msgnum)}
106
+ `),await e.fs.writeFile(H(t,"git-rebase-todo"),yo(n.todo)),await e.fs.writeFile(H(t,"done"),yo(n.done))}async function ta(e){let t=jr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Eo(e,t,n){let r=jr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(H(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
104
107
  GIT_AUTHOR_EMAIL='${n.email}'
105
108
  GIT_AUTHOR_DATE='${o}'
106
- `),await e.fs.writeFile(v(r,"stopped-sha"),`${t}
107
- `)}function kf(e){let t=[];for(let n of e.split(`
108
- `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^pick\s+([0-9a-f]+)\s+(.*)/);if(o?.[1]&&o[2]){let s=o[2].startsWith("# ")?o[2].slice(2):o[2];t.push({hash:o[1],subject:s})}}return t}function Eo(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
109
+ `),await e.fs.writeFile(H(r,"stopped-sha"),`${t}
110
+ `)}function Sf(e){let t=[];for(let n of e.split(`
111
+ `)){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 yo(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
109
112
  `)}
110
- `}async function Pf(e,t,n){let r=new Map,[o,s]=await Promise.all([Rf(e,t,r),Rf(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 xf(e,r,n,i),left:await xf(e,r,t,a)}}async function Rf(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 yo(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function xf(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 yo(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 yo(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 yo(e,f,t);l.commit.parents.length<=1&&a.push(l);for(let d of l.commit.parents)if(r.has(d)&&!c.has(d)){let u=(o.get(d)??0)-1;o.set(d,u),u<=0&&i.push(d)}}return a.reverse(),a}async function yo(e,t,n){let r=n.get(t);if(r)return r;let o=await ye(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:on(o.content)};return n.set(t,s),s}ge();ie();function Lr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Fh(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Lr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Lr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var _h=50;async function st(e,t,n=_h){let r=new Map,o=[],s=[],i=[];for(let l of t)if(l.status==="deleted"&&l.oldHash){let d=r.get(l.oldHash)??[];d.push(l),r.set(l.oldHash,d),o.push(l)}else l.status==="added"&&l.newHash?s.push(l):i.push(l);let a=[],c=[];for(let l of s){let d=l.newHash;if(!d){c.push(l);continue}let u=r.get(d);if(u&&u.length>0){let h=Fh(u,l.path);h&&a.push({oldPath:h.path,newPath:l.path,oldHash:h.oldHash??d,newHash:d,similarity:100,oldMode:h.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await Uh(e,f,c,n);if(l.length>0){let d=new Set(l.map(h=>h.oldPath)),u=new Set(l.map(h=>h.newPath));f=f.filter(h=>!d.has(h.path)),c=c.filter(h=>!u.has(h.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await qh(e,f,c,n);if(l.length>0){let d=new Set(l.map(h=>h.oldPath)),u=new Set(l.map(h=>h.newPath));f=f.filter(h=>!d.has(h.path)),c=c.filter(h=>!u.has(h.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function Uh(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=Lr(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=Lr(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let l=t[c],d=n[f];if(!l?.oldHash||!d?.newHash||l.oldHash===d.newHash)continue;let u=await $t(e,l.oldHash),h=await $t(e,d.newHash),m=Wh(u,h);m<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:m,oldMode:l.oldMode,newMode:d.newMode})}return i}var $f=107927;function Ro(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))%$f;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%$f;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 Bh(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 Wh(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Of(e.length,Ro(e),t.length,Ro(t))}function Of(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Bh(t,r);return Math.floor(i*100/o)}async function qh(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await $t(e,l.oldHash);o.push({size:d.length,chunks:Ro(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await $t(e,l.newHash);s.push({size:d.length,chunks:Ro(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],u=o[l];if(!(!d||!u))for(let h=0;h<n.length;h++){let m=n[h],p=s[h];if(!m||!p)continue;let g=Of(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=Lr(d.path)===Lr(m.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:h})}}}i.sort((l,d)=>d.similarity-l.similarity||d.nameScore-l.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:l,delIdx:d,addIdx:u}of i){if(a.has(d)||c.has(u))continue;a.add(d),c.add(u);let h=t[d],m=n[u];!h||!m||f.push({oldPath:h.path,newPath:m.path,oldHash:h.oldHash??"",newHash:m.newHash??"",similarity:l,oldMode:h.oldMode,newMode:m.newMode})}return f}function hn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let l=Math.max(0,n-o-a),d=Math.max(0,r-o-a),u=e.slice(0,o),h=e.slice(n-a),m=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${u}{${m} => ${p}}${h}`:`${e} => ${t}`}De();et();async function ot(e,t){let n=await Q(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Qi(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 wt(e,i),u=[],h=[];for(let g of d)g.status==="untracked"?h.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>Te(g.path,w.path));let m=new Set(i.entries.map(g=>g.path)),p=ea(h,m);return Kh(e,r,s,o,i,l,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Sf(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${Z(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Kh(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,u=await W(e,"CHERRY_PICK_HEAD"),h=await W(e,"REVERT_HEAD"),m=await W(e,"MERGE_HEAD"),p=!u&&!m,w=await _t(e)?await kt(e):null;if(n&&w){let C=Z(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await gs(e);if(C){let $=t===C?"at":"from";l.push(`HEAD detached ${$} ${Z(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);let b=f?.isInitial??!t;if(!n&&!w&&!b){let C=await pe(e),$=await Ut(e,C,r);if($){let D=zn($,{abbreviated:f?.fromCommit});for(let P of D.trimEnd().split(`
111
- `))l.push(P);d=!0}}if(d&&(w||u||h||m)&&l.push(""),w&&m)Sf(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=jt(o),$=await e.fs.exists(v(e.gitDir,"MERGE_MSG"));Sf(l,w);let P=w.headName==="detached HEAD"?null:Pe(w.headName),T=Z(w.onto),A=P?` branch '${P}' on '${T}'`:"";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($)l.push(`You are currently rebasing${A}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let U=A?`You are currently editing a commit while rebasing${A}.`:"You are currently editing a commit during a rebase.";l.push(U),l.push(' (use "git commit --amend" to amend the current commit)'),l.push(' (use "git rebase --continue" once you are satisfied with your changes)')}d=!0}else u?(l.push(`You are currently cherry-picking commit ${Z(u)}.`),a.length>0?l.push(' (fix conflicts and run "git cherry-pick --continue")'):l.push(' (all conflicts fixed: run "git cherry-pick --continue")'),l.push(' (use "git cherry-pick --skip" to skip this patch)'),l.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),d=!0):h?(l.push(`You are currently reverting commit ${Z(h)}.`),a.length>0?l.push(' (fix conflicts and run "git revert --continue")'):l.push(' (all conflicts fixed: run "git revert --continue")'),l.push(' (use "git revert --skip" to skip this patch)'),l.push(' (use "git revert --abort" to cancel the revert operation)'),d=!0):m&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await It(e)){let $=(await $e(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${$}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}b&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let E=null;p&&(E=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let R=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)',x=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),E&&l.push(E);for(let C of s)l.push(` ${If(C.status,C.path,C.displayPath)}`);l.push(""),x=!0}if(a.length>0){!x&&d&&l.push(""),l.push("Unmerged paths:"),p&&(t?l.push(' (use "git restore --staged <file>..." to unstage)'):l.push(' (use "git rm --cached <file>..." to unstage)')),a.some($=>$.status==="deleted by us"||$.status==="deleted by them"||$.status==="both deleted")?l.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):l.push(' (use "git add <file>..." to mark resolution)');for(let $ of a)l.push(` ${zh($.status,$.path)}`);l.push(""),x=!0}if(i.length>0){!x&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(R),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${If(C.status,C.path)}`);l.push(""),x=!0}if(c.length>0){!x&&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(""),x=!0}let y=s.length>0||!!m&&a.length===0;return!x&&d&&(f?.noWarn||y)&&l.push(""),!y&&!f?.noWarn&&(!x&&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(`
113
+ `}async function Hf(e,t,n){let r=new Map,[o,s]=await Promise.all([If(e,t,r),If(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 Tf(e,r,n,i),left:await Tf(e,r,t,a)}}async function If(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 bo(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function Tf(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 bo(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 bo(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 bo(e,f,t);l.commit.parents.length<=1&&a.push(l);for(let d of l.commit.parents)if(r.has(d)&&!c.has(d)){let u=(o.get(d)??0)-1;o.set(d,u),u<=0&&i.push(d)}}return a.reverse(),a}async function bo(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:an(o.content)};return n.set(t,s),s}ge();ie();function Lr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function nm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Lr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Lr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var rm=50;async function it(e,t,n=rm){let r=new Map,o=[],s=[],i=[];for(let l of t)if(l.status==="deleted"&&l.oldHash){let d=r.get(l.oldHash)??[];d.push(l),r.set(l.oldHash,d),o.push(l)}else l.status==="added"&&l.newHash?s.push(l):i.push(l);let a=[],c=[];for(let l of s){let d=l.newHash;if(!d){c.push(l);continue}let u=r.get(d);if(u&&u.length>0){let h=nm(u,l.path);h&&a.push({oldPath:h.path,newPath:l.path,oldHash:h.oldHash??d,newHash:d,similarity:100,oldMode:h.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await sm(e,f,c,n);if(l.length>0){let d=new Set(l.map(h=>h.oldPath)),u=new Set(l.map(h=>h.newPath));f=f.filter(h=>!d.has(h.path)),c=c.filter(h=>!u.has(h.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await am(e,f,c,n);if(l.length>0){let d=new Set(l.map(h=>h.oldPath)),u=new Set(l.map(h=>h.newPath));f=f.filter(h=>!d.has(h.path)),c=c.filter(h=>!u.has(h.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function sm(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=Lr(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=Lr(c.path);s.has(f)?s.set(f,-1):s.set(f,a)}let i=[];for(let[a,c]of o){if(c===-1)continue;let f=s.get(a);if(f===void 0||f===-1)continue;let l=t[c],d=n[f];if(!l?.oldHash||!d?.newHash||l.oldHash===d.newHash)continue;let u=await $t(e,l.oldHash),h=await $t(e,d.newHash),m=im(u,h);m<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:m,oldMode:l.oldMode,newMode:d.newMode})}return i}var Af=107927;function ko(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 om(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 im(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:Df(e.length,ko(e),t.length,ko(t))}function Df(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=om(t,r);return Math.floor(i*100/o)}async function am(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await $t(e,l.oldHash);o.push({size:d.length,chunks:ko(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await $t(e,l.newHash);s.push({size:d.length,chunks:ko(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],u=o[l];if(!(!d||!u))for(let h=0;h<n.length;h++){let m=n[h],p=s[h];if(!m||!p)continue;let g=Df(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=Lr(d.path)===Lr(m.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:h})}}}i.sort((l,d)=>d.similarity-l.similarity||d.nameScore-l.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:l,delIdx:d,addIdx:u}of i){if(a.has(d)||c.has(u))continue;a.add(d),c.add(u);let h=t[d],m=n[u];!h||!m||f.push({oldPath:h.path,newPath:m.path,oldHash:h.oldHash??"",newHash:m.newHash??"",similarity:l,oldMode:h.oldMode,newMode:m.newMode})}return f}function pn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let l=Math.max(0,n-o-a),d=Math.max(0,r-o-a),u=e.slice(0,o),h=e.slice(n-a),m=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${u}{${m} => ${p}}${h}`:`${e} => ${t}`}Ae();Je();async function at(e,t){let n=await te(e),r=await Z(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await V(e),a=ra(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await na(e,c,i,a),d=await bt(e,i),u=[],h=[];for(let g of d)g.status==="untracked"?h.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>ve(g.path,w.path));let m=new Set(i.entries.map(g=>g.path)),p=sa(h,m);return cm(e,r,s,o,i,l,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Mf(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${X(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${X(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function cm(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,u=await U(e,"CHERRY_PICK_HEAD"),h=await U(e,"REVERT_HEAD"),m=await U(e,"MERGE_HEAD"),p=!u&&!m,w=await Ut(e)?await kt(e):null;if(n&&w){let P=X(w.onto);l.push(`interactive rebase in progress; onto ${P}`)}else if(n){let P=await ps(e);if(P){let C=t===P?"at":"from";l.push(`HEAD detached ${C} ${X(P)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);let b=f?.isInitial??!t;if(!n&&!w&&!b){let P=await pe(e),C=await Bt(e,P,r);if(C){let A=zn(C,{abbreviated:f?.fromCommit});for(let D of A.trimEnd().split(`
114
+ `))l.push(D);d=!0}}if(d&&(w||u||h||m)&&l.push(""),w&&m)Mf(l,w),l.push(""),a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0;else if(w){let P=Lt(o),C=await e.fs.exists(H(e.gitDir,"MERGE_MSG"));Mf(l,w);let D=w.headName==="detached HEAD"?null:Pe(w.headName),$=X(w.onto),v=D?` branch '${D}' on '${$}'`:"";if(P)l.push(`You are currently rebasing${v}.`),l.push(' (fix conflicts and then run "git rebase --continue")'),l.push(' (use "git rebase --skip" to skip this patch)'),l.push(' (use "git rebase --abort" to check out the original branch)');else if(C)l.push(`You are currently rebasing${v}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let N=v?`You are currently editing a commit while rebasing${v}.`:"You are currently editing a commit during a rebase.";l.push(N),l.push(' (use "git commit --amend" to amend the current commit)'),l.push(' (use "git rebase --continue" once you are satisfied with your changes)')}d=!0}else u?(l.push(`You are currently cherry-picking commit ${X(u)}.`),a.length>0?l.push(' (fix conflicts and run "git cherry-pick --continue")'):l.push(' (all conflicts fixed: run "git cherry-pick --continue")'),l.push(' (use "git cherry-pick --skip" to skip this patch)'),l.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),d=!0):h?(l.push(`You are currently reverting commit ${X(h)}.`),a.length>0?l.push(' (fix conflicts and run "git revert --continue")'):l.push(' (all conflicts fixed: run "git revert --continue")'),l.push(' (use "git revert --skip" to skip this patch)'),l.push(' (use "git revert --abort" to cancel the revert operation)'),d=!0):m&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await Tt(e)){let C=(await $e(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${C}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}b&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let R=null;p&&(R=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=i.some(P=>P.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',x=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),R&&l.push(R);for(let P of s)l.push(` ${jf(P.status,P.path,P.displayPath)}`);l.push(""),x=!0}if(a.length>0){!x&&d&&l.push(""),l.push("Unmerged paths:"),p&&(t?l.push(' (use "git restore --staged <file>..." to unstage)'):l.push(' (use "git rm --cached <file>..." to unstage)')),a.some(C=>C.status==="deleted by us"||C.status==="deleted by them"||C.status==="both deleted")?l.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):l.push(' (use "git add <file>..." to mark resolution)');for(let C of a)l.push(` ${fm(C.status,C.path)}`);l.push(""),x=!0}if(i.length>0){!x&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(k),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let P of i)l.push(` ${jf(P.status,P.path)}`);l.push(""),x=!0}if(c.length>0){!x&&d&&l.push(""),l.push("Untracked files:"),l.push(' (use "git add <file>..." to include in what will be committed)');for(let P of c)l.push(` ${P}`);l.push(""),x=!0}let y=s.length>0||!!m&&a.length===0;return!x&&d&&(f?.noWarn||y)&&l.push(""),!y&&!f?.noWarn&&(!x&&d&&i.length===0&&a.length===0&&c.length===0&&l.push(""),i.length>0||a.length>0?l.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?l.push('nothing added to commit but untracked files present (use "git add" to track)'):b?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
112
115
  `)}
113
- `}async function Ji(e,t,n,r){let o=new Set(r?.map(h=>h.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await de(e,s),a=new Map(Ne(n).map(h=>[h.path,h])),c=[];for(let[h,m]of a){if(o.has(h))continue;let p=i.get(h);p?p.hash!==m.hash&&c.push({path:h,status:"modified",oldHash:p.hash,newHash:m.hash,oldMode:p.mode,newMode:m.mode.toString(8).padStart(6,"0")}):c.push({path:h,status:"added",newHash:m.hash,newMode:m.mode.toString(8).padStart(6,"0")})}for(let[h,m]of i)o.has(h)||a.has(h)||c.push({path:h,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await st(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let h of f){let m=d[h.status];m&&u.push({path:h.path,status:m})}for(let h of l)u.push({path:h.newPath,status:"renamed",displayPath:`${h.oldPath} -> ${h.newPath}`});return u.sort((h,m)=>Te(h.path,m.path))}function Qi(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Te(r.path,o.path))}function ea(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 If(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function zh(e,t){return`${e}:`.padEnd(17)+t}async function Ut(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 W(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await W(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 zi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function xo(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function zn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
116
+ `}async function na(e,t,n,r){let o=new Set(r?.map(h=>h.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await le(e,s),a=new Map(Ge(n).map(h=>[h.path,h])),c=[];for(let[h,m]of a){if(o.has(h))continue;let p=i.get(h);p?p.hash!==m.hash&&c.push({path:h,status:"modified",oldHash:p.hash,newHash:m.hash,oldMode:p.mode,newMode:m.mode.toString(8).padStart(6,"0")}):c.push({path:h,status:"added",newHash:m.hash,newMode:m.mode.toString(8).padStart(6,"0")})}for(let[h,m]of i)o.has(h)||a.has(h)||c.push({path:h,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await it(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let h of f){let m=d[h.status];m&&u.push({path:h.path,status:m})}for(let h of l)u.push({path:h.newPath,status:"renamed",displayPath:`${h.oldPath} -> ${h.newPath}`});return u.sort((h,m)=>ve(h.path,m.path))}function ra(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)=>ve(r.path,o.path))}function sa(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 jf(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function fm(e,t){return`${e}:`.padEnd(17)+t}async function Bt(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await U(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await U(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 Zi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function Ro(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function zn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
114
117
  (use "git branch --unset-upstream" to fixup)
115
118
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
116
119
  `;if(e.ahead>0&&e.behind===0){let r=e.ahead===1?"commit":"commits";return`Your branch is ahead of '${e.upstream}' by ${e.ahead} ${r}.
@@ -120,19 +123,19 @@ GIT_AUTHOR_DATE='${o}'
120
123
  `}let n=`Your branch and '${e.upstream}' have diverged,
121
124
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
122
125
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
123
- `}kn();De();Jt();et();async function Co(e){let t=await Qe(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await W(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function $n(e){let t="";return await W(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
124
- `),await W(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
125
- `),await ur(e),t}function Vh(e){let t=new Set,n=[];for(let r of e.entries)r.stage>0&&!t.has(r.path)&&(t.add(r.path),n.push(`${r.path}: needs merge`));return n.sort(),n.length>0?`${n.join(`
126
- `)}
127
- `:""}function Vn(e){return e.entries.some(t=>t.stage>0)?{stdout:Vh(e),stderr:`error: you need to resolve your current index first
128
- `,exitCode:1}:null}async function Po(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");if(r)return Yh(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?N(`error: path '${t[0]}' is unmerged
129
- `):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
130
- `);for(let a of i)await lt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Yh(e,t,n,r){let o=await de(e,r),s=await z(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)Ee(i,c)&&a.push(c);if(a.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
131
- `);for(let c of a){let f=o.get(c);f&&(await lt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Pt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:ve()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function $o(e,t,n,r,o){if(!e.workTree)return I("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await z(e),a=t.map(f=>Ue(f,n)),c=new Set;for(let f of i.entries)Ee(a,f.path)&&c.add(f.path);if(c.size===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
132
- `);for(let f of c){let l=i.entries.find(h=>h.path===f&&h.stage===r),d=!l&&i.entries.find(h=>h.path===f&&h.stage===0),u=l||d;if(u)await lt(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let h=v(e.workTree,f);await e.fs.exists(h)&&await e.fs.rm(h)}else if(i.entries.some(m=>m.path===f&&m.stage>0))return N(`error: path '${f}' does not have ${r===2?"our":"their"} version
133
- `)}return{stdout:"",stderr:"",exitCode:0}}async function hr(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)_n(c.mode)||o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=v(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let d=await e.fs.readFileBuffer(f);i.set(c,await gt("blob",d))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let l=s.get(c);if(l===void 0){a.push(`D ${c}`);continue}let d=i.get(c);d===null?a.push(`D ${c}`):(l!==f||d!==void 0&&d!==f)&&a.push(`M ${c}`)}for(let[c]of s)o.has(c)||i.get(c)!=null&&a.push(`A ${c}`);return a.length===0?"":(a.sort((c,f)=>{let l=c.slice(2),d=f.slice(2);return l<d?-1:l>d?1:0}),`${a.join(`
134
- `)}
135
- `)}var Tf=5;function Xh(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Tf?Tf-1:t,i=e.slice(0,o).map(c=>` ${Z(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
126
+ `}Pn();Ae();Nt();Je();async function oa(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])continue;let s=o[1],i=`refs/heads/${s}`,a=await U(e,i);if(a)return{kind:"branch",name:s,refName:i,hash:a};let c=await Me(e,s,`a branch is expected, got commit '${s}'`);return M(c)?null:{kind:"commit",target:s}}return null}async function Gf(e){let t=await oa(e);return t?.kind==="branch"?t:null}async function In(e){let t="";return await U(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
127
+ `),await U(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
128
+ `),await hr(e),t}function lm(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(`
129
+ `)}
130
+ `:""}function Vn(e){return e.entries.some(t=>t.stage>0)?{stdout:lm(e),stderr:`error: you need to resolve your current index first
131
+ `,exitCode:1}:null}async function xo(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");if(r)return dm(e,t,n,r);let o=await V(e),s=t.map(a=>_e(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?_(`error: path '${t[0]}' is unmerged
132
+ `):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
133
+ `);for(let a of i)await dt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function dm(e,t,n,r){let o=await le(e,r),s=await V(e),i=t.map(c=>_e(c,n)),a=[];for(let[c]of o)Ee(i,c)&&a.push(c);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
134
+ `);for(let c of a){let f=o.get(c);f&&(await dt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Pt(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:He()}))}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}async function Co(e,t,n,r,o){if(!e.workTree)return S("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,i=await V(e),a=t.map(f=>_e(f,n)),c=new Set;for(let f of i.entries)Ee(a,f.path)&&c.add(f.path);if(c.size===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
135
+ `);for(let f of c){let l=i.entries.find(h=>h.path===f&&h.stage===r),d=!l&&i.entries.find(h=>h.path===f&&h.stage===0),u=l||d;if(u)await dt(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let h=H(e.workTree,f);await e.fs.exists(h)&&await e.fs.rm(h)}else if(i.entries.some(m=>m.path===f&&m.stage>0))return _(`error: path '${f}' does not have ${r===2?"our":"their"} version
136
+ `)}return{stdout:"",stderr:"",exitCode:0}}async function Yn(e,t,n){if(!e.workTree)return"";let r=await qe(e,t),o=new Map;for(let c of r)Bn(c.mode)||o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=H(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let d=await e.fs.readFileBuffer(f);i.set(c,await gt("blob",d))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let l=s.get(c);if(l===void 0){a.push(`D ${c}`);continue}let d=i.get(c);d===null?a.push(`D ${c}`):(l!==f||d!==void 0&&d!==f)&&a.push(`M ${c}`)}for(let[c]of s)o.has(c)||i.get(c)!=null&&a.push(`A ${c}`);return a.length===0?"":(a.sort((c,f)=>{let l=c.slice(2),d=f.slice(2);return l<d?-1:l>d?1:0}),`${a.join(`
137
+ `)}
138
+ `)}var Lf=5;function um(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Lf?Lf-1:t,i=e.slice(0,o).map(c=>` ${X(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
136
139
  any of your branches:
137
140
 
138
141
  ${i.join(`
@@ -141,12 +144,12 @@ ${i.join(`
141
144
  If you want to keep ${r} by creating a new branch, this may be a good time
142
145
  to do so with:
143
146
 
144
- git branch <new-branch-name> ${Z(e[0].hash)}
147
+ git branch <new-branch-name> ${X(e[0].hash)}
145
148
 
146
- `}async function ta(e,t){let n=await j(e,t);return`Previous HEAD position was ${Z(t)} ${ue(n.message)}
147
- `}async function Oo(e,t,n){let r=await Vi(e,t,{targetHash:n});return r.length>0?Xh(r):t!==n?ta(e,t):""}async function mr(e,t,n,r,o,s,i){let a=await Q(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
148
- `,exitCode:0};let c=await z(e),f=Vn(c);if(f)return f;let l=await X(e),u=(await j(e,r)).tree,h=null;if(l&&(h=(await j(e,l)).tree),h!==u){let k=await Bn(e,h,u,c);if(!k.success)return k.errorOutput??N("error: checkout would overwrite local changes");c={version:2,entries:k.newEntries},await ae(e,c),await je(e,k.worktreeOps)}let m="";a?.type==="direct"&&l&&(m=await Oo(e,l,r));let p=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):l??ne;await Ze(e,"HEAD",n),await Et(e);let g=await $n(e);await re(e,o,"HEAD",l,r,`checkout: moving from ${p} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:r,isBranchCheckout:!0});let w=await hr(e,u,c),b=await pe(e),E=await Ut(e,b,t);return E&&(w+=zn(E)),{stdout:w,stderr:`${m}Switched to ${i?.isNew?"a new ":""}branch '${t}'
149
- ${g}`,exitCode:0}}async function Yn(e,t,n,r,o){let s=await z(e),i=Vn(s);if(i)return i;let a=await X(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let E=await Bn(e,l,f,s);if(!E.success)return E.errorOutput??N("error: checkout would overwrite local changes");s={version:2,entries:E.newEntries},await ae(e,s),await je(e,E.worktreeOps)}let d=await Q(e),u=d?.type==="direct"&&a===t;if(await J(e,"HEAD",t),!u){await gf(e,t);let E=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ne;await re(e,n,"HEAD",a,t,`checkout: moving from ${E} to ${t}`)}let h=await $n(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let m=Z(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Oo(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${m} ${p}
149
+ `}async function ia(e,t){let n=await j(e,t);return`Previous HEAD position was ${X(t)} ${ue(n.message)}
150
+ `}async function Po(e,t,n){let r=await Ji(e,t,{targetHash:n});return r.length>0?um(r):t!==n?ia(e,t):""}async function mr(e,t,n,r,o,s,i){let a=await te(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
151
+ `,exitCode:0};let c=await V(e),f=Vn(c);if(f)return f;let l=await Z(e),u=(await j(e,r)).tree,h=null;if(l&&(h=(await j(e,l)).tree),h!==u){let E=await hn(e,h,u,c);if(!E.success)return E.errorOutput??_("error: checkout would overwrite local changes");c={version:2,entries:E.newEntries},await ae(e,c),await De(e,E.worktreeOps)}let m="";a?.type==="direct"&&l&&(m=await Po(e,l,r));let p=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):l??ne;await Ze(e,"HEAD",n),await Et(e);let g=await In(e);await re(e,o,"HEAD",l,r,`checkout: moving from ${p} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:l,newHead:r,isBranchCheckout:!0});let w=await Yn(e,u,c),b=await pe(e),R=await Bt(e,b,t);return R&&(w+=zn(R)),{stdout:w,stderr:`${m}Switched to ${i?.isNew?"a new ":""}branch '${t}'
152
+ ${g}`,exitCode:0}}async function Xn(e,t,n,r,o){let s=await V(e),i=Vn(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 R=await hn(e,l,f,s);if(!R.success)return R.errorOutput??_("error: checkout would overwrite local changes");s={version:2,entries:R.newEntries},await ae(e,s),await De(e,R.worktreeOps)}let d=await te(e),u=d?.type==="direct"&&a===t;if(await J(e,"HEAD",t),!u){await xf(e,t);let R=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ne;await re(e,n,"HEAD",a,t,`checkout: moving from ${R} to ${t}`)}let h=await In(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let m=X(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await Po(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${m} ${p}
150
153
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
151
154
 
152
155
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -165,93 +168,105 @@ Or undo this operation with:
165
168
  Turn off this advice by setting config variable advice.detachedHead to false
166
169
 
167
170
  HEAD is now at ${m} ${p}
168
- `,w+=h,{stdout:await hr(e,f,s),stderr:w,exitCode:0}}async function Zh(e,t){if(t.startsWith("refs/remotes/")){if(!await W(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 W(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 So(e,t,n){let r=await Zh(e,n);if(!r||await xe(e,"branch.autoSetupMerge")==="false")return"";let s=await pe(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await ze(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
169
- `}async function Io(e,t){let n=await we(e,"refs/remotes"),r=[];for(let o of n){let s=o.name.replace(/^refs\/remotes\//,"").split("/"),i=s[0];s.length>=2&&i&&s.slice(1).join("/")===t&&r.push({remote:i,ref:o.name})}if(r.length===1){let o=r[0];return{remote:o.remote,startPoint:o.ref,trackingRef:o.ref}}if(r.length>1){let o=await xe(e,"checkout.defaultRemote");if(o){let s=r.filter(i=>i.remote===o);if(s.length===1){let i=s[0];return{remote:i.remote,startPoint:i.ref,trackingRef:i.ref}}}}return null}ie();me();ge();cn();var vf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ys={stdout:`You need to start by "git bisect start"
170
- `,stderr:"",exitCode:1};async function na(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await X(e);return n||I("no current commit")}function Af(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[K.string().name("subcommand").describe("Subcommand or custom term").optional(),K.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
171
- `,exitCode:1};let i=r.rest??[],a=await q(o.fs,o.cwd,t);return M(a)?a:tm(a,o.env,t,s,i)}});Jh(n,t),Qh(n,t),nm(n,t),rm(n,t),om(n,t),im(n,t),cm(n,t),lm(n,t),dm(n,t)}function Jh(e,t){e.command("start",{description:"Start bisecting",args:[K.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Y.string().describe("Alternate term for new/bad"),"term-bad":Y.string().describe("Alternate term for new/bad"),"term-old":Y.string().describe("Alternate term for old/good"),"term-good":Y.string().describe("Alternate term for old/good"),"no-checkout":S().describe("Do not checkout the bisection commit"),"first-parent":S().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return vf.has(a)?I(`'${a}' is not a valid term`):vf.has(c)?I(`'${c}' is not a valid term`):a===c?I("'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 It(e)&&await bo(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await X(e)??"HEAD",await Me(e,"BISECT_START",f+`
172
- `),await Me(e,"BISECT_TERMS",`${o}
171
+ `,w+=h,{stdout:await Yn(e,f,s),stderr:w,exitCode:0}}async function hm(e,t){if(t.startsWith("refs/remotes/")){if(!await U(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 U(e,n)){let o=t.split("/");if(o.length<2)return null;let s=o[0],i=o.slice(1).join("/");return{remote:s,branch:i,ref:n}}return null}async function $o(e,t,n){let r=await hm(e,n);if(!r||await ke(e,"branch.autoSetupMerge")==="false")return"";let s=await pe(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await ze(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
172
+ `}async function Oo(e,t){let n=await ye(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();me();ge();fn();var Nf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),bs={stdout:`You need to start by "git bisect start"
173
+ `,stderr:"",exitCode:1};async function aa(e){let t=await $e(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Z(e);return n||S("no current commit")}function Ff(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]
174
+ `,exitCode:1};let i=r.rest??[],a=await K(o.fs,o.cwd,t);return M(a)?a:wm(a,o.env,t,s,i)}});mm(n,t),pm(n,t),bm(n,t),ym(n,t),km(n,t),Rm(n,t),Cm(n,t),$m(n,t),Om(n,t)}function mm(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":O().describe("Do not checkout the bisection commit"),"first-parent":O().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return Nf.has(a)?S(`'${a}' is not a valid term`):Nf.has(c)?S(`'${c}' is not a valid term`):a===c?S("'bad' and 'good' terms must be different"):_f(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function _f(e,t,n,r,o,s,i,a){await Tt(e)&&await wo(e);let c=await te(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Z(e)??"HEAD",await Le(e,"BISECT_START",f+`
175
+ `),await Le(e,"BISECT_TERMS",`${o}
173
176
  ${s}
174
- `),await Me(e,"BISECT_NAMES",`
175
- `),a&&await Me(e,"BISECT_FIRST_PARENT",""),i){let u=await X(e);u&&await Me(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],h=await bt(e,u);if(M(h))return h;await J(e,`refs/bisect/${o}`,h);let m=await j(e,h);await Tt(e,`# ${o}: [${h}] ${ue(m.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await bt(e,g);if(M(w))return w;await J(e,`refs/bisect/${s}-${w}`,w);let b=await j(e,w);await Tt(e,`# ${s}: [${w}] ${ue(b.message)}`)}}let l=r.map(u=>`'${u}'`),d=l.length>0?` ${l.join(" ")}`:"";return await Tt(e,`git bisect start${d}`),Es(e,t,n)}function Qh(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[K.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:em(s,o.env,t,n,r.rev)}})}async function em(e,t,n,r,o){if(!await It(e))return ys;let s=await ws(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return bs(e,t,n,i,s,o)}async function tm(e,t,n,r,o){if(!await It(e))return ys;let s=await ws(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
176
- `,exitCode:1}:bs(e,t,n,r,s,o[0])}async function bs(e,t,n,r,o,s){let i;if(s){let f=await bt(e,s);if(M(f))return f;i=f}else{let f=await na(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await J(e,`refs/bisect/${o.termBad}`,i):await J(e,`refs/bisect/${o.termGood}-${i}`,i),await Tt(e,`# ${r}: [${i}] ${c}`),await Tt(e,`git bisect ${r} ${i}`),Es(e,t,n)}function nm(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[K.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await It(s))return ys;let i=n.revs??[];if(i.length===0){let a=await na(s);if(M(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let l=await bt(s,a);if(M(l))return l;c=l}await J(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await Tt(s,`# skip: [${c}] ${ue(f.message)}`),await Tt(s,`git bisect skip ${c}`)}return Es(s,r.env,t)}})}function rm(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[K.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await It(s)?sm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
177
- `,stderr:"",exitCode:0}}})}async function sm(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await bo(e),r){let s=await bt(e,r);return M(s)?s:Yn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await W(e,s);if(i)return mr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Yn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function om(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await It(s)?{stdout:await $e(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
178
- `,exitCode:1}}})}function im(e,t){e.command("replay",{description:"Replay a bisect log",args:[K.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:v(r.cwd,n.logfile);if(!await r.fs.exists(i))return I(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return am(s,r.env,t,a)}})}async function am(e,t,n,r){await It(e)&&await bo(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
179
- `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(h=>h.replace(/^'|'$/g,"")):[];d=await Hf(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await bs(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await bs(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let u of l?l.split(/\s+/):[]){await J(e,`refs/bisect/skip-${u}`,u);let h=await j(e,u);await Tt(e,`# skip: [${u}] ${ue(h.message)}`),await Tt(e,`git bisect skip ${u}`)}d=await Es(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:[K.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await It(s))return ys;if(!r.exec)return I("bisect run requires shell execution support");let i=n.cmd.join(" ");return fm(s,r.env,t,i,r.exec,r.cwd)}})}async function fm(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
180
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await na(e);if(M(u))return u;await J(e,`refs/bisect/skip-${u}`,u);let h=await j(e,u);await Tt(e,`# skip: [${u}] ${ue(h.message)}`),await Tt(e,`git bisect skip ${u}`);let m=await Es(e,t,n);if(i+=m.stdout,m.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
181
- `,{stdout:i,stderr:"",exitCode:0};if(m.exitCode!==0)return{stdout:i,stderr:m.stderr,exitCode:m.exitCode};continue}let f=await wo(e),l=c===0?f.termGood:f.termBad,d=await bs(e,t,n,l,f,void 0);if(i+=d.stdout,d.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
182
- `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function lm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":S().describe("Show the term for the old state"),"term-bad":S().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await It(s))return{stdout:"",stderr:`error: no terms defined
183
- `,exitCode:1};let{termBad:i,termGood:a}=await ws(s);return n["term-good"]?{stdout:`${a}
177
+ `),await Le(e,"BISECT_NAMES",`
178
+ `),a&&await Le(e,"BISECT_FIRST_PARENT",""),i){let u=await Z(e);u&&await Le(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],h=await yt(e,u);if(M(h))return h;await J(e,`refs/bisect/${o}`,h);let m=await j(e,h);await vt(e,`# ${o}: [${h}] ${ue(m.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await yt(e,g);if(M(w))return w;await J(e,`refs/bisect/${s}-${w}`,w);let b=await j(e,w);await vt(e,`# ${s}: [${w}] ${ue(b.message)}`)}}let l=r.map(u=>`'${u}'`),d=l.length>0?` ${l.join(" ")}`:"";return await vt(e,`git bisect start${d}`),ys(e,t,n)}function pm(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 K(o.fs,o.cwd,t);return M(s)?s:gm(s,o.env,t,n,r.rev)}})}async function gm(e,t,n,r,o){if(!await Tt(e))return bs;let s=await gs(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ws(e,t,n,i,s,o)}async function wm(e,t,n,r,o){if(!await Tt(e))return bs;let s=await gs(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
179
+ `,exitCode:1}:ws(e,t,n,r,s,o[0])}async function ws(e,t,n,r,o,s){let i;if(s){let f=await yt(e,s);if(M(f))return f;i=f}else{let f=await aa(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await J(e,`refs/bisect/${o.termBad}`,i):await J(e,`refs/bisect/${o.termGood}-${i}`,i),await vt(e,`# ${r}: [${i}] ${c}`),await vt(e,`git bisect ${r} ${i}`),ys(e,t,n)}function bm(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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return bs;let i=n.revs??[];if(i.length===0){let a=await aa(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 yt(s,a);if(M(l))return l;c=l}await J(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await vt(s,`# skip: [${c}] ${ue(f.message)}`),await vt(s,`git bisect skip ${c}`)}return ys(s,r.env,t)}})}function ym(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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await Tt(s)?Em(s,r.env,t,n.commit):{stdout:`We are not bisecting.
180
+ `,stderr:"",exitCode:0}}})}async function Em(e,t,n,r){let o=(await $e(e,"BISECT_START"))?.trim()??"";if(await wo(e),r){let s=await yt(e,r);return M(s)?s:Xn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await U(e,s);if(i)return mr(e,o,s,i,t,n);let a=await We(e,o);if(a)return Xn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function km(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await Tt(s)?{stdout:await $e(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
181
+ `,exitCode:1}}})}function Rm(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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:H(r.cwd,n.logfile);if(!await r.fs.exists(i))return S(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return xm(s,r.env,t,a)}})}async function xm(e,t,n,r){await Tt(e)&&await wo(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
182
+ `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(h=>h.replace(/^'|'$/g,"")):[];d=await _f(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ws(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ws(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let u of l?l.split(/\s+/):[]){await J(e,`refs/bisect/skip-${u}`,u);let h=await j(e,u);await vt(e,`# skip: [${u}] ${ue(h.message)}`),await vt(e,`git bisect skip ${u}`)}d=await ys(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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return bs;if(!r.exec)return S("bisect run requires shell execution support");let i=n.cmd.join(" ");return Pm(s,r.env,t,i,r.exec,r.cwd)}})}async function Pm(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
183
+ `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await aa(e);if(M(u))return u;await J(e,`refs/bisect/skip-${u}`,u);let h=await j(e,u);await vt(e,`# skip: [${u}] ${ue(h.message)}`),await vt(e,`git bisect skip ${u}`);let m=await ys(e,t,n);if(i+=m.stdout,m.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
184
+ `,{stdout:i,stderr:"",exitCode:0};if(m.exitCode!==0)return{stdout:i,stderr:m.stderr,exitCode:m.exitCode};continue}let f=await go(e),l=c===0?f.termGood:f.termBad,d=await ws(e,t,n,l,f,void 0);if(i+=d.stdout,d.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
185
+ `,{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":O().describe("Show the term for the old state"),"term-bad":O().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await Tt(s))return{stdout:"",stderr:`error: no terms defined
186
+ `,exitCode:1};let{termBad:i,termGood:a}=await gs(s);return n["term-good"]?{stdout:`${a}
184
187
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
185
188
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
186
189
  and ${i} for the new state.
187
- `,stderr:"",exitCode:0}}})}function dm(e,t){for(let n of["visualize","view"])e.command(n,{description:"Show remaining suspects in git log",handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);if(M(s))return s;let i=s;if(!await It(i))return ys;let a=await wo(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
188
- `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(dr(),pf)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${Z(l.hash)} ${ue(l.commit.message)}
189
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function Es(e,t,n){let r=await wo(e);return!r.badHash||r.goodHashes.length===0?{stdout:bf(r),stderr:"",exitCode:0}:(await Me(e,"BISECT_ANCESTORS_OK",""),um(e,t,n,r))}async function um(e,t,n,r){let o=await wf(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
190
- `,exitCode:1};if(o.found){let s=await Ef(e,o.hash);return await Tt(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.
190
+ `,stderr:"",exitCode:0}}})}function Om(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 K(o.fs,o.cwd,t);if(M(s))return s;let i=s;if(!await Tt(i))return bs;let a=await go(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
191
+ `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(ur(),Rf)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${X(l.hash)} ${ue(l.commit.message)}
192
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function ys(e,t,n){let r=await go(e);return!r.badHash||r.goodHashes.length===0?{stdout:Pf(r),stderr:"",exitCode:0}:(await Le(e,"BISECT_ANCESTORS_OK",""),Sm(e,t,n,r))}async function Sm(e,t,n,r){let o=await Cf(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
193
+ `,exitCode:1};if(o.found){let s=await Of(e,o.hash);return await vt(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
191
194
  The first bad commit could be any of:
192
195
  `;for(let i of r.skipHashes)s+=i+`
193
196
  `;return r.badHash&&(s+=r.badHash+`
194
197
  `),s+=`We cannot bisect more!
195
- `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Me(e,"BISECT_HEAD",o.hash);else{let s=await Yn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Me(e,"BISECT_EXPECTED_REV",o.hash+`
196
- `),{stdout:yf(o),stderr:"",exitCode:0}}se();ie();function Bt(e){if(e.length===0)return[];let t=e.split(`
198
+ `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Le(e,"BISECT_HEAD",o.hash);else{let s=await Xn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Le(e,"BISECT_EXPECTED_REV",o.hash+`
199
+ `),{stdout:$f(o),stderr:"",exitCode:0}}se();ie();function Wt(e){if(e.length===0)return[];let t=e.split(`
197
200
  `);return t[t.length-1]===""&&t.pop(),t}function xt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
198
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var hm=4,Df=1024,To=100,Ho=0,vo=1,Gr=2;function sa(e){let t=1;for(;t*t<e;)t++;return t}function mm(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 pm(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 Mf(e,t,n,r){t-n>To&&(n=t-To),r-t>To&&(r=t+To);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Ho)o++;else if(f===Gr)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===Ho)i++;else if(f===Gr)a++;else break}return i===0?!1:(i+=o,a+=s,a*hm<a+i)}function gm(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),u=Math.min(sa(t),Df);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Ho:w>=u?l[g]=Gr:l[g]=vo}let h=Math.min(sa(r),Df);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Ho:w>=h?d[g]=Gr:d[g]=vo}let m=[];for(let g=s;g<=i;g++)l[g]===vo||l[g]===Gr&&!Mf(l,g,s,i)?m.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===vo||d[g]===Gr&&!Mf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:m,nreff1:m.length,refIndex2:p,nreff2:p.length}}var Xn=20,jf=4,wm=256,bm=256,Ao=2147483647;function Rt(e,t){return e[t]??0}function ym(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,u=t-o,h=n-s,m=u-h&1,p=u,g=u,w=h,b=h;i[u]=t,a[h]=n;for(let E=1;;E++){let k=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let R=g;R>=p;R-=2){let x;Rt(i,R-1)>=Rt(i,R+1)?x=Rt(i,R-1)+1:x=Rt(i,R+1);let y=x,C=x-R;for(;x<n&&C<s&&e[x]===r[C];)x++,C++;if(x-y>Xn&&(k=!0),i[R]=x,m&&w<=R&&R<=b&&Rt(a,R)<=x)return{i1:x,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=Ao:++w,b<d?a[++b+1]=Ao:--b;for(let R=b;R>=w;R-=2){let x;Rt(a,R-1)<Rt(a,R+1)?x=Rt(a,R-1):x=Rt(a,R+1)-1;let y=x,C=x-R;for(;x>t&&C>o&&e[x-1]===r[C-1];)x--,C--;if(y-x>Xn&&(k=!0),a[R]=x,!m&&p<=R&&R<=g&&x<=Rt(i,R))return{i1:x,i2:C,minLo:!0,minHi:!0}}if(!c){if(k&&E>wm){let R=0,x=null;for(let y=g;y>=p;y-=2){let C=y>u?y-u:u-y,$=Rt(i,y),D=$-y,P=$-t+(D-o)-C;if(P>jf*E&&P>R&&t+Xn<=$&&$<n&&o+Xn<=D&&D<s){let T=!0;for(let A=1;A<=Xn;A++)if(e[$-A]!==r[D-A]){T=!1;break}T&&(R=P,x={i1:$,i2:D,minLo:!0,minHi:!1})}}if(x)return x;R=0,x=null;for(let y=b;y>=w;y-=2){let C=y>h?y-h:h-y,$=Rt(a,y),D=$-y,P=n-$+(s-D)-C;if(P>jf*E&&P>R&&t<$&&$<=n-Xn&&o<D&&D<=s-Xn){let T=!0;for(let A=0;A<Xn;A++)if(e[$+A]!==r[D+A]){T=!1;break}T&&(R=P,x={i1:$,i2:D,minLo:!1,minHi:!0})}}if(x)return x}if(E>=f){let R=-1,x=-1;for(let $=g;$>=p;$-=2){let D=Math.min(Rt(i,$),n),P=D-$;s<P&&(D=s+$,P=s),R<D+P&&(R=D+P,x=D)}let y=Ao,C=Ao;for(let $=b;$>=w;$-=2){let D=Math.max(t,Rt(a,$)),P=D-$;P<o&&(D=o+$,P=o),D+P<y&&(y=D+P,C=D)}return n+s-y<R-(t+o)?{i1:x,i2:R-x,minLo:!0,minHi:!1}:{i1:C,i2:y-C,minLo:!1,minHi:!0}}}}}function oa(e,t,n,r,o,s,i,a,c,f,l,d,u,h){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let m=o;m<s;m++)a[f[m]]=1;else if(o===s)for(let m=t;m<n;m++)i[c[m]]=1;else{let m=ym(e,t,n,r,o,s,l,d,u,h);oa(e,t,m.i1,r,o,m.i2,i,a,c,f,l,d,m.minLo,h),oa(e,m.i1,n,r,m.i2,s,i,a,c,f,l,d,m.minHi,h)}}function Em(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 Lf=200,Gf=20,Nf=100,km=1,Rm=21,xm=-30,Cm=6,Pm=-4,$m=10,Om=24,Sm=17,Im=23,Tm=17,vm=60;function ra(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>=Lf)return Lf}return-1}function Ff(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=ra(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ra(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Gf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ra(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Gf){r.postIndent=0;break}return r}function _f(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=km),e.endOfFile&&(t.penalty+=Rm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=xm*r,t.penalty+=Cm*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?$m:Pm:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?Sm:Om:t.penalty+=s?Tm:Im))}function Am(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return vm*n+(e.penalty-t.penalty)}function Uf(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let l=(d,u)=>t[d]===t[u];for(;;){if(a!==i){let d,u,h;do{for(d=a-i,u=-1;i>0&&l(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(h=a,f>c&&(u=a);!(a>=r||!l(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(d!==a-i);if(a!==h)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let m=-1,p={effectiveIndent:0,penalty:0},g=h;for(a-d-1>g&&(g=a-d-1),a-Nf>g&&(g=a-Nf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Ff(n,r,g);_f(b,w);let E=Ff(n,r,g-d);_f(E,w),(m===-1||Am(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},m=g)}for(;a>m;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function ia(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}=mm(e,t),{dstart:f,dend1:l,dend2:d}=pm(i,n,a,r);if(f>l)for(let u=f;u<r-(n-1-l);u++)s[u]=1;else if(f>d)for(let u=f;u<n-(r-1-d);u++)o[u]=1;else{let{refIndex1:u,nreff1:h,refIndex2:m,nreff2:p}=gm(i,n,a,r,c,f,l,d,o,s);if(h>0&&p>0){let g=new Array(h);for(let x=0;x<h;x++)g[x]=i[u[x]];let w=new Array(p);for(let x=0;x<p;x++)w[x]=a[m[x]];let b={},E={},k=h+p+3,R=Math.max(bm,sa(k));oa(g,0,h,w,0,p,o,s,u,m,b,E,!1,R)}else if(h===0)for(let g=0;g<p;g++)s[m[g]]=1;else for(let g=0;g<h;g++)o[u[g]]=1;Uf(o,i,e,n,s,r),Uf(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function it(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=ia(e,t);return Em(e,t,o,s)}var Hm=3;function Dm(e,t=Hm){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=>Mm(e,a.start,a.end))}function Mm(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 Do(e){return e?e.length<40?e:Z(e):"0000000"}function Bf(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 jm(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,l=e.renameTo??r,d=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let h=[];if(Bf(h,e,l,d,u,f),o!==s){if(a||c){let m=Do(a),p=Do(c);d||u||f?h.push(`index ${m}..${p}`):h.push(`index ${m}..${p} ${i||"100644"}`)}t&&n?h.push(`Binary files a/${r} and b/${l} differ`):d?h.push(`Binary files /dev/null and b/${l} differ`):u?h.push(`Binary files a/${r} and /dev/null differ`):h.push(`Binary files a/${r} and b/${l} differ`)}return`${h.join(`
201
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Im=4,Uf=1024,So=100,vo=0,Io=1,Gr=2;function fa(e){let t=1;for(;t*t<e;)t++;return t}function Tm(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 vm(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 Bf(e,t,n,r){t-n>So&&(n=t-So),r-t>So&&(r=t+So);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===vo)o++;else if(f===Gr)s++;else break}if(o===0)return!1;let i=0,a=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===vo)i++;else if(f===Gr)a++;else break}return i===0?!1:(i+=o,a+=s,a*Im<a+i)}function Hm(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),u=Math.min(fa(t),Uf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=vo:w>=u?l[g]=Gr:l[g]=Io}let h=Math.min(fa(r),Uf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=vo:w>=h?d[g]=Gr:d[g]=Io}let m=[];for(let g=s;g<=i;g++)l[g]===Io||l[g]===Gr&&!Bf(l,g,s,i)?m.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===Io||d[g]===Gr&&!Bf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:m,nreff1:m.length,refIndex2:p,nreff2:p.length}}var Zn=20,Wf=4,Am=256,Dm=256,To=2147483647;function Rt(e,t){return e[t]??0}function Mm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,u=t-o,h=n-s,m=u-h&1,p=u,g=u,w=h,b=h;i[u]=t,a[h]=n;for(let R=1;;R++){let E=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let x;Rt(i,k-1)>=Rt(i,k+1)?x=Rt(i,k-1)+1:x=Rt(i,k+1);let y=x,P=x-k;for(;x<n&&P<s&&e[x]===r[P];)x++,P++;if(x-y>Zn&&(E=!0),i[k]=x,m&&w<=k&&k<=b&&Rt(a,k)<=x)return{i1:x,i2:P,minLo:!0,minHi:!0}}w>l?a[--w-1]=To:++w,b<d?a[++b+1]=To:--b;for(let k=b;k>=w;k-=2){let x;Rt(a,k-1)<Rt(a,k+1)?x=Rt(a,k-1):x=Rt(a,k+1)-1;let y=x,P=x-k;for(;x>t&&P>o&&e[x-1]===r[P-1];)x--,P--;if(y-x>Zn&&(E=!0),a[k]=x,!m&&p<=k&&k<=g&&x<=Rt(i,k))return{i1:x,i2:P,minLo:!0,minHi:!0}}if(!c){if(E&&R>Am){let k=0,x=null;for(let y=g;y>=p;y-=2){let P=y>u?y-u:u-y,C=Rt(i,y),A=C-y,D=C-t+(A-o)-P;if(D>Wf*R&&D>k&&t+Zn<=C&&C<n&&o+Zn<=A&&A<s){let $=!0;for(let v=1;v<=Zn;v++)if(e[C-v]!==r[A-v]){$=!1;break}$&&(k=D,x={i1:C,i2:A,minLo:!0,minHi:!1})}}if(x)return x;k=0,x=null;for(let y=b;y>=w;y-=2){let P=y>h?y-h:h-y,C=Rt(a,y),A=C-y,D=n-C+(s-A)-P;if(D>Wf*R&&D>k&&t<C&&C<=n-Zn&&o<A&&A<=s-Zn){let $=!0;for(let v=0;v<Zn;v++)if(e[C+v]!==r[A+v]){$=!1;break}$&&(k=D,x={i1:C,i2:A,minLo:!1,minHi:!0})}}if(x)return x}if(R>=f){let k=-1,x=-1;for(let C=g;C>=p;C-=2){let A=Math.min(Rt(i,C),n),D=A-C;s<D&&(A=s+C,D=s),k<A+D&&(k=A+D,x=A)}let y=To,P=To;for(let C=b;C>=w;C-=2){let A=Math.max(t,Rt(a,C)),D=A-C;D<o&&(A=o+C,D=o),A+D<y&&(y=A+D,P=A)}return n+s-y<k-(t+o)?{i1:x,i2:k-x,minLo:!0,minHi:!1}:{i1:P,i2:y-P,minLo:!1,minHi:!0}}}}}function la(e,t,n,r,o,s,i,a,c,f,l,d,u,h){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let m=o;m<s;m++)a[f[m]]=1;else if(o===s)for(let m=t;m<n;m++)i[c[m]]=1;else{let m=Mm(e,t,n,r,o,s,l,d,u,h);la(e,t,m.i1,r,o,m.i2,i,a,c,f,l,d,m.minLo,h),la(e,m.i1,n,r,m.i2,s,i,a,c,f,l,d,m.minHi,h)}}function jm(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 qf=200,Kf=20,zf=100,Lm=1,Gm=21,Nm=-30,Fm=6,_m=-4,Um=10,Bm=24,Wm=17,qm=23,Km=17,zm=60;function ca(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>=qf)return qf}return-1}function Vf(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=ca(e[n]));for(let o=n-1;o>=0&&(r.preIndent=ca(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Kf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=ca(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Kf){r.postIndent=0;break}return r}function Yf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Lm),e.endOfFile&&(t.penalty+=Gm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=Nm*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?Um:_m:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?Wm:Bm:t.penalty+=s?Km:qm))}function Vm(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return zm*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,u)=>t[d]===t[u];for(;;){if(a!==i){let d,u,h;do{for(d=a-i,u=-1;i>0&&l(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(h=a,f>c&&(u=a);!(a>=r||!l(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(d!==a-i);if(a!==h)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let m=-1,p={effectiveIndent:0,penalty:0},g=h;for(a-d-1>g&&(g=a-d-1),a-zf>g&&(g=a-zf);g<=a;g++){let w={effectiveIndent:0,penalty:0},b=Vf(n,r,g);Yf(b,w);let R=Vf(n,r,g-d);Yf(R,w),(m===-1||Vm(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},m=g)}for(;a>m;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function da(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}=Tm(e,t),{dstart:f,dend1:l,dend2:d}=vm(i,n,a,r);if(f>l)for(let u=f;u<r-(n-1-l);u++)s[u]=1;else if(f>d)for(let u=f;u<n-(r-1-d);u++)o[u]=1;else{let{refIndex1:u,nreff1:h,refIndex2:m,nreff2:p}=Hm(i,n,a,r,c,f,l,d,o,s);if(h>0&&p>0){let g=new Array(h);for(let x=0;x<h;x++)g[x]=i[u[x]];let w=new Array(p);for(let x=0;x<p;x++)w[x]=a[m[x]];let b={},R={},E=h+p+3,k=Math.max(Dm,fa(E));la(g,0,h,w,0,p,o,s,u,m,b,R,!1,k)}else if(h===0)for(let g=0;g<p;g++)s[m[g]]=1;else for(let g=0;g<h;g++)o[u[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 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}=da(e,t);return jm(e,t,o,s)}var Ym=3;function Xm(e,t=Ym){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=>Zm(e,a.start,a.end))}function Zm(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let l=t;l<=n;l++){let d=e[l];if(d)switch(d.type){case"keep":c||(r=d.oldLineNo,c=!0),f||(s=d.newLineNo,f=!0),o++,i++,a.push({type:"context",content:d.line});break;case"delete":c||(r=d.oldLineNo,c=!0),o++,a.push({type:"delete",content:d.line});break;case"insert":f||(s=d.newLineNo,f=!0),i++,a.push({type:"insert",content:d.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="insert"){r=d.newLineNo>1?d.newLineNo-1:0;break}}if(i===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="delete"){s=d.oldLineNo>1?d.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function Ho(e){return e?e.length<40?e:X(e):"0000000"}function Zf(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 Jm(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,l=e.renameTo??r,d=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let h=[];if(Zf(h,e,l,d,u,f),o!==s){if(a||c){let m=Ho(a),p=Ho(c);d||u||f?h.push(`index ${m}..${p}`):h.push(`index ${m}..${p} ${i||"100644"}`)}t&&n?h.push(`Binary files a/${r} and b/${l} differ`):d?h.push(`Binary files /dev/null and b/${l} differ`):u?h.push(`Binary files a/${r} and /dev/null differ`):h.push(`Binary files a/${r} and b/${l} differ`)}return`${h.join(`
199
202
  `)}
200
- `}function vt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,l=Ae(n),d=Ae(r);if(l||d)return jm(e,l,d);let u=Bt(n),h=Bt(r),m=n.length>0&&n.endsWith(`
203
+ `}function Ht(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,l=je(n),d=je(r);if(l||d)return Jm(e,l,d);let u=Wt(n),h=Wt(r),m=n.length>0&&n.endsWith(`
201
204
  `),p=r.length>0&&r.endsWith(`
202
- `),g="\0NOEOL",w=u;!m&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let b=h;!p&&h.length>0&&(b=h.slice(),b[b.length-1]+=g);let E=it(w,b);if(!m||!p)for(let P of E)P.line.includes(g)&&(P.line=P.line.replace(g,""));let k=Dm(E,e.contextLines);if(k.length===0&&!c)return"";let R=e.isNew??n==="",x=e.isDeleted??r==="",y=[];if(Bf(y,e,f,R,x,c),k.length===0)return`${y.join(`
205
+ `),g="\0NOEOL",w=u;!m&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let b=h;!p&&h.length>0&&(b=h.slice(),b[b.length-1]+=g);let R=ct(w,b);if(!m||!p)for(let D of R)D.line.includes(g)&&(D.line=D.line.replace(g,""));let E=Xm(R,e.contextLines);if(E.length===0&&!c)return"";let k=e.isNew??n==="",x=e.isDeleted??r==="",y=[];if(Zf(y,e,f,k,x,c),E.length===0)return`${y.join(`
203
206
  `)}
204
- `;if(i||a){let P=Do(i),T=Do(a);R||x?y.push(`index ${P}..${T}`):c?y.push(`index ${P}..${T} ${o||"100644"}`):o&&s&&o!==s?y.push(`index ${P}..${T}`):y.push(`index ${P}..${T} ${o||"100644"}`)}let C=P=>P.includes(" ")?" ":"";R?(y.push("--- /dev/null"),y.push(`+++ b/${f}${C(f)}`)):x?(y.push(`--- a/${t}${C(t)}`),y.push("+++ /dev/null")):(y.push(`--- a/${t}${C(t)}`),y.push(`+++ b/${f}${C(f)}`));let $=u.length,D=h.length;for(let P of k){let T=P.oldCount===1?`${P.oldStart}`:`${P.oldStart},${P.oldCount}`,A=P.newCount===1?`${P.newStart}`:`${P.newStart},${P.newCount}`,U="",_=P.oldCount===0?P.oldStart-1:P.oldStart-2;for(let L=_;L>=0;L--){let G=u[L];if(G&&/^[a-zA-Z$_]/.test(G)){U=` ${G.trimEnd().slice(0,79)}`;break}}y.push(`@@ -${T} +${A} @@${U}`);let O=P.oldStart,H=P.newStart;for(let L of P.lines)switch(L.type){case"context":y.push(` ${L.content}`),(!m&&O===$||!p&&H===D)&&y.push("\"),O++,H++;break;case"delete":y.push(`-${L.content}`),!m&&O===$&&y.push("\"),O++;break;case"insert":y.push(`+${L.content}`),!p&&H===D&&y.push("\"),H++;break}}return`${y.join(`
207
+ `;if(i||a){let D=Ho(i),$=Ho(a);k||x?y.push(`index ${D}..${$}`):c?y.push(`index ${D}..${$} ${o||"100644"}`):o&&s&&o!==s?y.push(`index ${D}..${$}`):y.push(`index ${D}..${$} ${o||"100644"}`)}let P=D=>D.includes(" ")?" ":"";k?(y.push("--- /dev/null"),y.push(`+++ b/${f}${P(f)}`)):x?(y.push(`--- a/${t}${P(t)}`),y.push("+++ /dev/null")):(y.push(`--- a/${t}${P(t)}`),y.push(`+++ b/${f}${P(f)}`));let C=u.length,A=h.length;for(let D of E){let $=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,v=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,N="",L=D.oldCount===0?D.oldStart-1:D.oldStart-2;for(let G=L;G>=0;G--){let W=u[G];if(W&&/^[a-zA-Z$_]/.test(W)){N=` ${W.trimEnd().slice(0,79)}`;break}}y.push(`@@ -${$} +${v} @@${N}`);let I=D.oldStart,T=D.newStart;for(let G of D.lines)switch(G.type){case"context":y.push(` ${G.content}`),(!m&&I===C||!p&&T===A)&&y.push("\"),I++,T++;break;case"delete":y.push(`-${G.content}`),!m&&I===C&&y.push("\"),I++;break;case"insert":y.push(`+${G.content}`),!p&&T===A&&y.push("\"),T++;break}}return`${y.join(`
205
208
  `)}
206
- `}ie();De();async function Zn(e,t,n){return(await de(e,t)).get(n)?.hash??null}async function Wf(e,t,n,r){let o=await Ve(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await st(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function Lm(e,t,n,r,o,s){let i=await Zn(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,Jn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=Bt(a),f=new Array(o.length),l=[...r],d=t,u=n,h=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let $ of l)f[$.finalIdx]=Jn(d,u,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!0,void 0);break}let g=await Zn(e,p.tree,u),w=null,b=[];for(let $ of p.parents){let D=await j(e,$),P=u,T=await Zn(e,D.tree,P);if(!T){let A=await Wf(e,D.tree,p.tree,u);A&&(P=A,T=await Zn(e,D.tree,P))}if(T&&(b.push({hash:$,path:P,blobHash:T}),T===g)){w={hash:$,path:P};break}}if(w){d=w.hash,u=w.path;continue}if(b.length===0){for(let $ of l)f[$.finalIdx]=Jn(d,u,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,void 0);break}let E=b[0],k=await oe(e,E.blobHash),R=Bt(k),x=it(R,h),y=new Map;for(let $ of x)$.type==="keep"&&y.set($.newLineNo,$.oldLineNo);let C=[];for(let $ of l){let D=y.get($.currentLine);D!==void 0?C.push({finalIdx:$.finalIdx,currentLine:D}):f[$.finalIdx]=Jn(d,u,$.currentLine,s+$.finalIdx,o[$.finalIdx],p,!1,{hash:E.hash,path:E.path})}l=C,d=E.hash,u=E.path,h=R}let m=new Map;for(let p of r)f[p.finalIdx]&&m.set(p.finalIdx,f[p.finalIdx]);return m}async function qf(e,t,n,r){let o=await j(e,t),s=await Zn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=Bt(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),u=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),h=t,m=n,p=a;for(;u.length>0;){let g=await j(e,h);if(g.parents.length===0){for(let y of u)d[y.finalIdx]=Jn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!0,void 0);break}let w=await Zn(e,g.tree,m),b=[],E=null;for(let y of g.parents){let C=await j(e,y),$=m,D=await Zn(e,C.tree,$);if(!D){let P=await Wf(e,C.tree,g.tree,m);P&&($=P,D=await Zn(e,C.tree,$))}if(D){let P={hash:y,path:$,blobHash:D};if(b.push(P),D===w){E=P;break}}}if(E){h=E.hash,m=E.path;continue}if(b.length===0){for(let y of u)d[y.finalIdx]=Jn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,void 0);break}if(b.length===1){let y=b[0],C=await oe(e,y.blobHash),$=Bt(C),D=it($,p),P=new Map;for(let A of D)A.type==="keep"&&P.set(A.newLineNo,A.oldLineNo);let T=[];for(let A of u){let U=P.get(A.currentLine);U!==void 0?T.push({finalIdx:A.finalIdx,currentLine:U}):d[A.finalIdx]=Jn(h,m,A.currentLine,c+A.finalIdx,l[A.finalIdx],g,!1,{hash:y.hash,path:y.path})}u=T,h=y.hash,m=y.path,p=$;continue}let k=[];for(let y of b){let C=await oe(e,y.blobHash),$=Bt(C),D=it($,p),P=new Map;for(let T of D)T.type==="keep"&&P.set(T.newLineNo,T.oldLineNo);k.push({info:y,newToOld:P})}let R=new Map;for(let y of u){let C=!1;for(let $=0;$<k.length;$++){let D=k[$],P=D.newToOld.get(y.currentLine);if(P!==void 0){let T=R.get($);T||(T={info:D.info,lines:[]},R.set($,T)),T.lines.push({finalIdx:y.finalIdx,currentLine:P}),C=!0;break}}C||(d[y.finalIdx]=Jn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let x=R.get(0);for(let[y,C]of R){if(y===0)continue;let $=await Lm(e,C.info.hash,C.info.path,C.lines,l,c);for(let[D,P]of $)d[D]=P}if(x&&x.lines.length>0){u=x.lines,h=x.info.hash,m=x.info.path;let y=await oe(e,x.info.blobHash);p=Bt(y)}else break}return d}function Jn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
207
- `)[0],boundary:i,previous:a}}se();ie();De();ie();me();function Gm(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 Nm(e,t){let n=Gm(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 Fm(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),i=String(s).length,a=e.some(d=>d.origPath!==t),c=0;if(!o)for(let d of e){let u=r?`<${d.author.email}>`:d.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let d of e)d.origPath.length>f&&(f=d.origPath.length);let l=[];for(let d of e){let u;n?u=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:u=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let h=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${u}${h} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,p=Nm(d.author.timestamp,d.author.timezone);l.push(`${u}${h} (${m.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
209
+ `}ie();Ae();async function Jn(e,t,n){return(await le(e,t)).get(n)?.hash??null}async function Jf(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 Qm(e,t,n,r,o,s){let i=await Jn(e,(await j(e,t)).tree,n);if(!i){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,Qn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await oe(e,i),c=Wt(a),f=new Array(o.length),l=[...r],d=t,u=n,h=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let C of l)f[C.finalIdx]=Qn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!0,void 0);break}let g=await Jn(e,p.tree,u),w=null,b=[];for(let C of p.parents){let A=await j(e,C),D=u,$=await Jn(e,A.tree,D);if(!$){let v=await Jf(e,A.tree,p.tree,u);v&&(D=v,$=await Jn(e,A.tree,D))}if($&&(b.push({hash:C,path:D,blobHash:$}),$===g)){w={hash:C,path:D};break}}if(w){d=w.hash,u=w.path;continue}if(b.length===0){for(let C of l)f[C.finalIdx]=Qn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!1,void 0);break}let R=b[0],E=await oe(e,R.blobHash),k=Wt(E),x=ct(k,h),y=new Map;for(let C of x)C.type==="keep"&&y.set(C.newLineNo,C.oldLineNo);let P=[];for(let C of l){let A=y.get(C.currentLine);A!==void 0?P.push({finalIdx:C.finalIdx,currentLine:A}):f[C.finalIdx]=Qn(d,u,C.currentLine,s+C.finalIdx,o[C.finalIdx],p,!1,{hash:R.hash,path:R.path})}l=P,d=R.hash,u=R.path,h=k}let m=new Map;for(let p of r)f[p.finalIdx]&&m.set(p.finalIdx,f[p.finalIdx]);return m}async function Qf(e,t,n,r){let o=await j(e,t),s=await Jn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await oe(e,s),a=Wt(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),u=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),h=t,m=n,p=a;for(;u.length>0;){let g=await j(e,h);if(g.parents.length===0){for(let y of u)d[y.finalIdx]=Qn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!0,void 0);break}let w=await Jn(e,g.tree,m),b=[],R=null;for(let y of g.parents){let P=await j(e,y),C=m,A=await Jn(e,P.tree,C);if(!A){let D=await Jf(e,P.tree,g.tree,m);D&&(C=D,A=await Jn(e,P.tree,C))}if(A){let D={hash:y,path:C,blobHash:A};if(b.push(D),A===w){R=D;break}}}if(R){h=R.hash,m=R.path;continue}if(b.length===0){for(let y of u)d[y.finalIdx]=Qn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,void 0);break}if(b.length===1){let y=b[0],P=await oe(e,y.blobHash),C=Wt(P),A=ct(C,p),D=new Map;for(let v of A)v.type==="keep"&&D.set(v.newLineNo,v.oldLineNo);let $=[];for(let v of u){let N=D.get(v.currentLine);N!==void 0?$.push({finalIdx:v.finalIdx,currentLine:N}):d[v.finalIdx]=Qn(h,m,v.currentLine,c+v.finalIdx,l[v.finalIdx],g,!1,{hash:y.hash,path:y.path})}u=$,h=y.hash,m=y.path,p=C;continue}let E=[];for(let y of b){let P=await oe(e,y.blobHash),C=Wt(P),A=ct(C,p),D=new Map;for(let $ of A)$.type==="keep"&&D.set($.newLineNo,$.oldLineNo);E.push({info:y,newToOld:D})}let k=new Map;for(let y of u){let P=!1;for(let C=0;C<E.length;C++){let A=E[C],D=A.newToOld.get(y.currentLine);if(D!==void 0){let $=k.get(C);$||($={info:A.info,lines:[]},k.set(C,$)),$.lines.push({finalIdx:y.finalIdx,currentLine:D}),P=!0;break}}P||(d[y.finalIdx]=Qn(h,m,y.currentLine,c+y.finalIdx,l[y.finalIdx],g,!1,{hash:b[0].hash,path:b[0].path}))}let x=k.get(0);for(let[y,P]of k){if(y===0)continue;let C=await Qm(e,P.info.hash,P.info.path,P.lines,l,c);for(let[A,D]of C)d[A]=D}if(x&&x.lines.length>0){u=x.lines,h=x.info.hash,m=x.info.path;let y=await oe(e,x.info.blobHash);p=Wt(y)}else break}return d}function Qn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
210
+ `)[0],boundary:i,previous:a}}se();ie();Ae();ie();me();function ep(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 tp(e,t){let n=ep(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 np(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),i=String(s).length,a=e.some(d=>d.origPath!==t),c=0;if(!o)for(let d of e){let u=r?`<${d.author.email}>`:d.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let d of e)d.origPath.length>f&&(f=d.origPath.length);let l=[];for(let d of e){let u;n?u=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:u=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let h=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${u}${h} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,p=tp(d.author.timestamp,d.author.timezone);l.push(`${u}${h} (${m.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
208
211
  `)}
209
- `}function _m(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
212
+ `}function rp(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
210
213
  `)}
211
- `}function Um(e,t,n){if(e.startsWith("/"))return nt(n,e);let r=nt(n,t);return r===""||r==="."?e:`${r}/${e}`}function Kf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[K.string().name("args").variadic().optional()],options:{lineRange:Y.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:S().alias("l").describe("Show long revision"),showEmail:S().alias("e").describe("Show author email instead of name"),suppress:S().alias("s").describe("Suppress author name and date"),porcelain:S().alias("p").describe("Show in machine-readable format"),linePorcelain:S().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return I("this operation must be run in a work tree");let a=await Je(i);if(M(a))return a;let c=n.args??[],f=o.passthrough??[],l=null,d=null;if(f.length>0?(d=f[f.length-1],c.length>0&&(l=c[0])):c.length===2?(l=c[0],d=c[1]):c.length===1&&(d=c[0]),!d)return I("no file specified");let u=Um(d,r.cwd,i.workTree),h;if(l){let x=await bt(i,l);if(M(x))return x;h=await He(i,x)}else h=a;let m=await j(i,h),p=await de(i,m.tree);if(!p.has(u))return I(`no such path ${u} in ${l??"HEAD"}`);let g=p.get(u).hash,w=await oe(i,g);if(Ae(w))return I(`cannot blame binary file '${u}'`);let b,E;if(n.lineRange){let x=n.lineRange,y=x.match(/^(\d+),(\d+)$/);if(y)b=parseInt(y[1],10),E=parseInt(y[2],10);else return I(`invalid -L range: '${x}'`)}let k;try{k=await qf(i,h,u,{startLine:b,endLine:E})}catch(x){let y=x instanceof Error?x.message:String(x);return I(y)}let R;return n.porcelain||n.linePorcelain?R=_m(k,!!n.linePorcelain):R=Fm(k,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:R,stderr:"",exitCode:0}}})}se();Be();rr();se();var Bm=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Wm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function On(e,t){let n=qm(t),r=new Date((e+n*60)*1e3),o=Bm[r.getUTCDay()],s=Wm[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 aa(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 qm(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}ie();De();var Mo=new TextDecoder;function zf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
214
+ `}function sp(e,t,n){if(e.startsWith("/"))return rt(n,e);let r=rt(n,t);return r===""||r==="."?e:`${r}/${e}`}function el(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:O().alias("l").describe("Show long revision"),showEmail:O().alias("e").describe("Show author email instead of name"),suppress:O().alias("s").describe("Suppress author name and date"),porcelain:O().alias("p").describe("Show in machine-readable format"),linePorcelain:O().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await K(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 u=sp(d,r.cwd,i.workTree),h;if(l){let x=await yt(i,l);if(M(x))return x;h=await Te(i,x)}else h=a;let m=await j(i,h),p=await le(i,m.tree);if(!p.has(u))return S(`no such path ${u} in ${l??"HEAD"}`);let g=p.get(u).hash,w=await oe(i,g);if(je(w))return S(`cannot blame binary file '${u}'`);let b,R;if(n.lineRange){let x=n.lineRange,y=x.match(/^(\d+),(\d+)$/);if(y)b=parseInt(y[1],10),R=parseInt(y[2],10);else return S(`invalid -L range: '${x}'`)}let E;try{E=await Qf(i,h,u,{startLine:b,endLine:R})}catch(x){let y=x instanceof Error?x.message:String(x);return S(y)}let k;return n.porcelain||n.linePorcelain?k=rp(E,!!n.linePorcelain):k=np(E,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}se();Ue();sr();se();var op=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ip=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Tn(e,t){let n=ap(t),r=new Date((e+n*60)*1e3),o=op[r.getUTCDay()],s=ip[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 ua(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 ap(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();Ae();var Ao=new TextDecoder;function tl(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
212
215
  `&&t++;return e[e.length-1]!==`
213
- `&&t++,t}function Qn(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function er(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await $t(e,a.newHash);Mn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:zf(Mo.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await $t(e,a.oldHash);Mn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:zf(Mo.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await $t(e,a.oldHash),f=await $t(e,a.newHash);if(Mn(c)||Mn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=xt(Mo.decode(c)),d=xt(Mo.decode(f)),u=it(l,d),h=0,m=0;for(let p of u)p.type==="insert"?h++:p.type==="delete"&&m++;r.push({path:a.path,sortKey:a.path,insertions:h,deletions:m})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=hn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await oe(e,a.oldHash),u=await oe(e,a.newHash);if(!Ae(d)&&!Ae(u)){let h=xt(d),m=xt(u),p=it(h,m);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=hn(a.oldPath,a.newPath);i.push({sortKey:a.newPath,text:` rename ${c} (${a.similarity}%)`})}return i.sort((a,c)=>a.sortKey<c.sortKey?-1:a.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:i.map(a=>a.text)}}async function mn(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${On(r.timestamp,r.timezone)}`),i)return a.join(`
216
+ `&&t++,t}function er(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function tr(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await $t(e,a.newHash);Nn(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:tl(Ao.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await $t(e,a.oldHash);Nn(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:tl(Ao.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await $t(e,a.oldHash),f=await $t(e,a.newHash);if(Nn(c)||Nn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=xt(Ao.decode(c)),d=xt(Ao.decode(f)),u=ct(l,d),h=0,m=0;for(let p of u)p.type==="insert"?h++:p.type==="delete"&&m++;r.push({path:a.path,sortKey:a.path,insertions:h,deletions:m})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=pn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await oe(e,a.oldHash),u=await oe(e,a.newHash);if(!je(d)&&!je(u)){let h=xt(d),m=xt(u),p=ct(h,m);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=pn(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 vn(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: ${Tn(r.timestamp,r.timezone)}`),i)return a.join(`
214
217
  `)+(a.length>0?`
215
- `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await st(e,c),{fileStats:d,modeLines:u}=await er(e,f,l),h=0,m=0;for(let g of d)h+=g.insertions,m+=g.deletions;let p=Qn(d.length,h,m);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
218
+ `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await it(e,c),{fileStats:d,modeLines:u}=await tr(e,f,l),h=0,m=0;for(let g of d)h+=g.insertions,m+=g.deletions;let p=er(d.length,h,m);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
216
219
  `)+(a.length>0?`
217
- `:"")}var Km=80;function zm(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 pr(e,t=Km){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=zm(p.path,c);let f=c,l=[],d=0,u=0,h=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(h++,d+=p.insertions,u+=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),E,k;if(r<=a)E=p.insertions,k=p.deletions;else{let y=D=>D===0?0:1+Math.floor(D*(a-1)/r),C=y(w),$=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(E=y(p.insertions),k=$-E):(k=y(p.deletions),E=$-k)}let R="+".repeat(E)+"-".repeat(k),x=R?` ${R}`:"";l.push(` ${g} | ${b}${x}`)}let m=Qn(h,d,u);return m?l.push(m):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
220
+ `:"")}var cp=80;function fp(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 pr(e,t=cp){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=fp(p.path,c);let f=c,l=[],d=0,u=0,h=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(h++,d+=p.insertions,u+=p.deletions,p.isBinary){let P=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${P}`);continue}let w=p.insertions+p.deletions,b=String(w).padStart(s),R,E;if(r<=a)R=p.insertions,E=p.deletions;else{let y=A=>A===0?0:1+Math.floor(A*(a-1)/r),P=y(w),C=P<2&&p.insertions>0&&p.deletions>0?2:P;p.insertions<p.deletions?(R=y(p.insertions),E=C-R):(E=y(p.deletions),R=C-E)}let k="+".repeat(R)+"-".repeat(E),x=k?` ${k}`:"";l.push(` ${g} | ${b}${x}`)}let m=er(h,d,u);return m?l.push(m):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
218
221
  `)}
219
- `}async function pn(e,t,n){let r=await Ve(e,t,n),{remaining:o,renames:s}=await st(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await er(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=pr(i);for(let f of a)c+=`${f}
220
- `;return c}Be();Ce();ie();ge();Jt();async function Vm(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i;try{i=await j(e,s)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function en(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Wt(e,t,n){if(t===n)return[t];let r=await Vm(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let l;try{l=await j(e,f)}catch{continue}for(let d of l.parents)s.has(d)||i.push(d)}if(o.length<=1)return o;let c=[];for(let f of o){let l=!1;for(let d of o)if(d!==f&&await en(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:Ym(e,t,n,c)}async function Ym(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,l=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function d(u){let h=c.get(u);if(h!==void 0)return h;let m=(await j(e,u)).committer.timestamp;return c.set(u,m),m}for(;l.length>0;){let u=0,h=await d(l[0].hash);for(let b=1;b<l.length;b++){let E=l[b],k=await d(E.hash),R=l[u];(k>h||k===h&&E.seq<R.seq)&&(u=b,h=k)}let m=l.splice(u,1)[0],p=a.get(m.hash)??0,g=p|m.mask;if(g===p)continue;if(a.set(m.hash,g),g===3&&o.has(m.hash)&&!s.has(m.hash)&&(i.push(m.hash),s.add(m.hash),s.size===o.size))break;let w=await j(e,m.hash);for(let b of w.parents)l.push({hash:b,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function gr(e,t,n,r){let o=await xe(e,"init.defaultBranch")??"main",s=r?` of ${r}`:"";return n===o?`Merge branch '${t}'${s}
222
+ `}async function gn(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 tr(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=pr(i);for(let f of a)c+=`${f}
223
+ `;return c}Ue();Ce();ie();ge();Nt();async function lp(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 tn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function qt(e,t,n){if(t===n)return[t];let r=await lp(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 tn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:dp(e,t,n,c)}async function dp(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,l=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function d(u){let h=c.get(u);if(h!==void 0)return h;let m=(await j(e,u)).committer.timestamp;return c.set(u,m),m}for(;l.length>0;){let u=0,h=await d(l[0].hash);for(let b=1;b<l.length;b++){let R=l[b],E=await d(R.hash),k=l[u];(E>h||E===h&&R.seq<k.seq)&&(u=b,h=E)}let m=l.splice(u,1)[0],p=a.get(m.hash)??0,g=p|m.mask;if(g===p)continue;if(a.set(m.hash,g),g===3&&o.has(m.hash)&&!s.has(m.hash)&&(i.push(m.hash),s.add(m.hash),s.size===o.size))break;let w=await j(e,m.hash);for(let b of w.parents)l.push({hash:b,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function gr(e,t,n,r){let o=await ke(e,"init.defaultBranch")??"main",s=r?` of ${r}`:"";return n===o?`Merge branch '${t}'${s}
221
224
  `:`Merge branch '${t}'${s} into ${n}
222
- `}async function jo(e,t,n){let r=await j(e,t),o=await j(e,n),s=Z(t),i=Z(n),a=`Updating ${s}..${i}
223
- `;if(e.workTree){let f=await z(e),l=await lf(e,r.tree,o.tree,f);if(!l.success){let d=l.errorOutput;return{stdout:a+d.stdout,stderr:d.stderr,exitCode:d.exitCode}}await ae(e,{version:2,entries:l.newEntries}),await je(e,l.worktreeOps)}await Gn(e,n);let c=await pn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
224
- ${c}`,stderr:"",exitCode:0}}ie();Ke();ge();function Vf(e,t){e.command("branch",{description:"List, create, or delete branches",args:[K.string().name("name").describe("Branch name").optional(),K.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:S().alias("d").describe("Delete a branch"),forceDelete:S().alias("D").describe("Force delete a branch"),move:S().alias("m").describe("Rename a branch"),forceMove:S().alias("M").describe("Force rename a branch"),remotes:S().alias("r").describe("List remote-tracking branches"),all:S().alias("a").describe("List all branches"),setUpstreamTo:Y.string().alias("u").describe("Set upstream tracking branch"),verbose:S().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Pe(i.target):null,c=!!n.forceMove;if(n.move||c){let w,b;if(n.newName)w=n.name,b=n.newName;else if(n.name){if(!a)return I("not on any branch");w=a,b=n.name}else return I("branch name required");if(!yn(b))return I(`'${b}' is not a valid branch name`);let E=`refs/heads/${w}`,k=`refs/heads/${b}`,R=await W(s,E);if(!R)return I(`no branch named '${w}'`);if(await _t(s)&&(await kt(s))?.headName===E)return I(`branch ${E} is being rebased at ${s.workTree}`);let x=await W(s,k);if(x&&!c)return I(`a branch named '${b}' already exists`);x&&await he(s,k);let y=await Qe(s,E);await J(s,k,R),await he(s,E),w===a&&await Ze(s,"HEAD",k),y.length>0&&await Fn(s,k,y);let C=`Branch: renamed ${E} to ${k}`;if(await re(s,r.env,k,R,R,C),w===a){let P=await vn(s,r.env);await ft(s,"HEAD",{oldHash:R,newHash:ne,...P,message:C}),await ft(s,"HEAD",{oldHash:ne,newHash:R,...P,message:C})}let $=await pe(s),D=`branch "${w}"`;return $[D]&&($[`branch "${b}"`]=$[D],delete $[D],await ze(s,$)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return I("branch name required");let w=n.name===a;if(!w&&!a&&await _t(s)&&(await kt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return N(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
225
- `);let b=`refs/heads/${n.name}`,E=await W(s,b);if(!E)return N(`error: branch '${n.name}' not found
226
- `);let k="";if(!f){let R=await X(s),y=(await pe(s))[`branch "${n.name}"`],C=y?.remote,$=y?.merge,D=null,P=null;if(C&&$&&(D=$.replace(/^refs\/heads\//,`refs/remotes/${C}/`),P=await W(s,D)),P&&D){if(!(E===P||await en(s,E,P))){let _=R!=null&&(E===R||await en(s,E,R))?`warning: not deleting branch '${n.name}' that is not yet merged to
227
- '${D}', even though it is merged to HEAD
228
- `:"";return N(`${_}error: the branch '${n.name}' is not fully merged
229
- hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
230
- hint: Disable this message with "git config set advice.forceDeleteBranch false"
231
- `)}R!=null&&(E===R||await en(s,E,R))||(k=`warning: deleting branch '${n.name}' that has been merged to
232
- '${D}', but not yet merged to HEAD
233
- `)}else if(R&&E!==R&&!await en(s,E,R))return N(`error: the branch '${n.name}' is not fully merged
234
- hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
225
+ `}async function Do(e,t,n){let r=await j(e,t),o=await j(e,n),s=X(t),i=X(n),a=`Updating ${s}..${i}
226
+ `;if(e.workTree){let f=await V(e),l=await wf(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 De(e,l.worktreeOps)}await _n(e,n);let c=await gn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
227
+ ${c}`,stderr:"",exitCode:0}}ie();Be();ge();function nl(e){return{stdout:"",stderr:`fatal: the requested upstream branch '${e}' does not exist
228
+ hint:
229
+ hint: If you are planning on basing your work on an upstream
230
+ hint: branch that already exists at the remote, you may need to
231
+ hint: run "git fetch" to retrieve it.
232
+ hint:
233
+ hint: If you are planning to push out a new local branch that
234
+ hint: will track its remote counterpart, you may want to use
235
+ hint: "git push -u" to set the upstream config as you push.
236
+ hint: Disable this message with "git config set advice.setUpstreamFailure false"
237
+ `,exitCode:128}}async function rl(e,t,n=""){let r=(await ke(e,"advice.forceDeleteBranch"))?.toLowerCase();return r==="false"?_(`${n}error: the branch '${t}' is not fully merged
238
+ `):r==="true"?_(`${n}error: the branch '${t}' is not fully merged
239
+ hint: If you are sure you want to delete it, run 'git branch -D ${t}'
240
+ `):_(`${n}error: the branch '${t}' is not fully merged
241
+ hint: If you are sure you want to delete it, run 'git branch -D ${t}'
235
242
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
236
- `)}return await he(s,b),{stdout:`Deleted branch ${n.name} (was ${Z(E)}).
237
- `,stderr:k,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,b=n.name||a;if(!b)return I("could not set upstream of HEAD when it does not point to any branch.");if(!await W(s,`refs/heads/${b}`))return I(`branch '${b}' does not exist`);let k=w.indexOf("/");if(k<0)return I(`the requested upstream branch '${w}' does not exist`);let R=w.slice(0,k),x=w.slice(k+1);if(!await W(s,`refs/remotes/${w}`))return I(`the requested upstream branch '${w}' does not exist`);let C=await pe(s),$=`branch "${b}"`;return C[$]||(C[$]={}),C[$].remote=R,C[$].merge=`refs/heads/${x}`,await ze(s,C),{stdout:"",stderr:`branch '${b}' set up to track '${w}'.
238
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!yn(n.name))return I(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let y=await Ge(s,w,`not a valid object name: '${w}'`);if(M(y))return y;b=y.hash}else if(b=await X(s),!b)return I("Not a valid object name: 'HEAD'.");let E=`refs/heads/${n.name}`;if(await W(s,E))return I(`a branch named '${n.name}' already exists`);await J(s,E,b);let R=w??"HEAD";await re(s,r.env,E,null,b,`branch: Created from ${R}`);let x="";return w&&(x=await So(s,n.name,w)),{stdout:"",stderr:x,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,u=n.remotes||n.all,h=[];if(d&&!a){let w=await X(s);if(w){let b=await _t(s),E;if(b){let k=await kt(s);if(k?.headName){let R=Pe(k.headName);if(R==="detached HEAD"){let x=await gs(s);E=`(no branch, rebasing detached HEAD ${x?Z(x):"(null)"})`}else E=`(no branch, rebasing ${R})`}else E="(no branch)"}else{let k=await gs(s);k?E=`(HEAD detached ${w===k?"at":"from"} ${Z(k)})`:E="(no branch)"}h.push({displayName:E,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await we(s,"refs/heads");for(let b of w){let E=Pe(b.name);h.push({displayName:E,hash:b.hash,isCurrent:E===a,branchName:E})}}if(u){let w=await we(s,"refs/remotes");for(let b of w){let E=b.name.replace("refs/remotes/",""),k=null,R=await s.refStore.readRef(b.name);R?.type==="symbolic"&&(k=R.target.replace("refs/remotes/",""));let x=k?n.all?`remotes/${E} -> ${k}`:`${E} -> ${k}`:n.all?`remotes/${E}`:E;h.push({displayName:x,hash:b.hash,isCurrent:!1,branchName:null})}}if(h.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${h.map(b=>b.isCurrent?`* ${b.displayName}`:` ${b.displayName}`).join(`
239
- `)}
240
- `,stderr:"",exitCode:0};let m=l>=1?await pe(s):null,p=Math.max(...h.map(w=>w.displayName.length)),g=[];for(let w of h){let b=w.isCurrent?"* ":" ",E=w.displayName.padEnd(p),k=Z(w.hash),R="";try{let y=await j(s,w.hash);R=ue(y.message)}catch{}let x="";if(m&&w.branchName){let y=await Ut(s,m,w.branchName);if(y){let C=xo(y,l>=2);C&&(x=` ${C}`)}}g.push(`${b}${E} ${k}${x} ${R}`)}return{stdout:`${g.join(`
241
- `)}
242
- `,stderr:"",exitCode:0}}})}function fe(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Xm=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Zm=["commitMsg","mergeMsg"],Jm=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Qm=["onRefUpdate","onRefDelete","onObjectWrite"];function ep(...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 Xm){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(fe(a))return a}})}for(let r of Zm){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(fe(a))return a}})}for(let r of Jm){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 Qm){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();Be();Ce();ie();Ke();ge();cn();et();function Xf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[K.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:S().alias("b").describe("Create and switch to a new branch"),forceBranch:S().alias("B").describe("Create/reset and switch to a new branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:S().describe("Create a new orphan branch"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return I("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return I(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let u=dt(i,r.cwd),h=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return I("cannot specify both a revision and --ours/--theirs");let p=await Ge(i,a,`invalid reference: ${a}`);if(M(p))return p;m=p.commit.tree}return n.ours||n.theirs?$o(i,h,u,n.theirs?3:2):Po(i,h,u,m)}if(n.orphan)return n.branch?I("--orphan and -b are incompatible"):n.ours||n.theirs?I("--orphan and --ours/--theirs are incompatible"):a?np(i,a,r.env,t):I("you must specify a branch to checkout");if(n.detach){let u=a??"HEAD",h=await Ge(i,u,`invalid reference: ${u}`);return M(h)?h:Yf(i,u,h.hash,r.env,t)}if(!a)return I("you must specify a branch to checkout");if(n.branch||n.forceBranch)return rp(i,a,r.env,t,!!n.forceBranch);if(a==="-")return tp(i,r.env,t);let c=`refs/heads/${a}`,f=await W(i,c);if(f)return Zf(i,a,c,f,r.env,t);let l=await Io(i,a);if(l)return sp(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let u=await He(i,d);return Yf(i,a,u,r.env,t)}if(i.workTree){let u=await z(i),h=zs(u,a);if(h)return await lt(i,{path:h.path,hash:h.hash,mode:h.mode}),{stdout:"",stderr:"",exitCode:0}}return N(`error: pathspec '${a}' did not match any file(s) known to git
243
- `)}})}async function tp(e,t,n){let r=await Co(e);return r?Zf(e,r.name,r.refName,r.hash,t,n):I("no previous branch")}async function np(e,t,n,r){if(!yn(t))return I(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await W(e,o))return I(`a branch named '${t}' already exists`);let i=await z(e),a=Vn(i);if(a)return a;let c=await X(e),f=null;c&&(f=(await j(e,c)).tree),await Ze(e,"HEAD",o),await Et(e);let l=await $n(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ne,isBranchCheckout:!0});let d="";return f&&(d=await hr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
244
- ${l}`,exitCode:0}}async function rp(e,t,n,r,o=!1){if(!yn(t))return I(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return N(s.message??"");let i=await Q(e),a=await X(e),c=`refs/heads/${t}`,f=await W(e,c);if(f&&!o)return I(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=Vn(g);if(w)return w}a&&await J(e,c,a),await Ze(e,"HEAD",c),await Et(e);let l=await $n(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??ne;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??ne,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??ne,isBranchCheckout:!0});let u="";if(o&&a){let g=await z(e),w=await j(e,a);u=await hr(e,w.tree,g)}let h=await pe(e),m=await Ut(e,h,t);m&&(u+=zn(m));let p=f?`Switched to and reset branch '${t}'
243
+ `)}function sl(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:O().alias("d").describe("Delete a branch"),forceDelete:O().alias("D").describe("Force delete a branch"),move:O().alias("m").describe("Rename a branch"),forceMove:O().alias("M").describe("Force rename a branch"),remotes:O().alias("r").describe("List remote-tracking branches"),all:O().alias("a").describe("List all branches"),showCurrent:O().describe("Print the current branch name"),setUpstreamTo:Y.string().alias("u").describe("Set upstream tracking branch"),verbose:O().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await te(s),a=i?.type==="symbolic"?Pe(i.target):null;if(n.showCurrent)return{stdout:a?`${a}
244
+ `:"",stderr:"",exitCode:0};let 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(!En(b))return S(`'${b}' is not a valid branch name`);let R=`refs/heads/${w}`,E=`refs/heads/${b}`,k=await U(s,R);if(!k)return S(`no branch named '${w}'`);if(await Ut(s)&&(await kt(s))?.headName===R)return S(`branch ${R} is being rebased at ${s.workTree}`);let x=await U(s,E);if(x&&!c)return S(`a branch named '${b}' already exists`);x&&await he(s,E);let y=await et(s,R);await J(s,E,k),await he(s,R),w===a&&await Ze(s,"HEAD",E),y.length>0&&await Un(s,E,y);let P=`Branch: renamed ${R} to ${E}`;if(await re(s,r.env,E,k,k,P),w===a){let D=await Mn(s,r.env);await st(s,"HEAD",{oldHash:k,newHash:ne,...D,message:P}),await st(s,"HEAD",{oldHash:ne,newHash:k,...D,message:P})}let C=await pe(s),A=`branch "${w}"`;return C[A]&&(C[`branch "${b}"`]=C[A],delete C[A],await ze(s,C)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return S("branch name required");let w=n.name===a;if(!w&&!a&&await Ut(s)&&(await kt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return _(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
245
+ `);let b=`refs/heads/${n.name}`,R=await U(s,b);if(!R)return _(`error: branch '${n.name}' not found
246
+ `);let E="";if(!f){let k=await Z(s),y=(await pe(s))[`branch "${n.name}"`],P=y?.remote,C=y?.merge,A=null,D=null;if(P&&C&&(A=C.replace(/^refs\/heads\//,`refs/remotes/${P}/`),D=await U(s,A)),D&&A){if(!(R===D||await tn(s,R,D))){let L=k!=null&&(R===k||await tn(s,R,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
247
+ '${A}', even though it is merged to HEAD
248
+ `:"";return rl(s,n.name,L)}k!=null&&(R===k||await tn(s,R,k))||(E=`warning: deleting branch '${n.name}' that has been merged to
249
+ '${A}', but not yet merged to HEAD
250
+ `)}else if(k&&R!==k&&!await tn(s,R,k))return rl(s,n.name)}return await he(s,b),{stdout:`Deleted branch ${n.name} (was ${X(R)}).
251
+ `,stderr:E,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 U(s,`refs/heads/${b}`))return S(`branch '${b}' does not exist`);let E=w.indexOf("/");if(E<0)return nl(w);let k=w.slice(0,E),x=w.slice(E+1);if(!await U(s,`refs/remotes/${w}`))return nl(w);let P=await pe(s),C=`branch "${b}"`;return P[C]||(P[C]={}),P[C].remote=k,P[C].merge=`refs/heads/${x}`,await ze(s,P),{stdout:`branch '${b}' set up to track '${w}'.
252
+ `,stderr:"",exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!En(n.name))return S(`'${n.name}' is not a valid branch name`);let w=n.newName,b;if(w){let y=await Me(s,w,`not a valid object name: '${w}'`);if(M(y))return y;b=y.hash}else if(b=await Z(s),!b)return S("Not a valid object name: 'HEAD'.");let R=`refs/heads/${n.name}`;if(await U(s,R))return S(`a branch named '${n.name}' already exists`);await J(s,R,b);let k=w??"HEAD";await re(s,r.env,R,null,b,`branch: Created from ${k}`);let x="";return w&&(x=await $o(s,n.name,w)),{stdout:"",stderr:x,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,u=n.remotes||n.all,h=[];if(d&&!a){let w=await Z(s);if(w){let b=await Ut(s),R;if(b){let E=await kt(s);if(E?.headName){let k=Pe(E.headName);if(k==="detached HEAD"){let x=await ps(s);R=`(no branch, rebasing detached HEAD ${x?X(x):"(null)"})`}else R=`(no branch, rebasing ${k})`}else R="(no branch)"}else{let E=await ps(s);E?R=`(HEAD detached ${w===E?"at":"from"} ${X(E)})`:R="(no branch)"}h.push({displayName:R,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await ye(s,"refs/heads");for(let b of w){let R=Pe(b.name);h.push({displayName:R,hash:b.hash,isCurrent:R===a,branchName:R})}}if(u){let w=await ye(s,"refs/remotes");for(let b of w){let R=b.name.replace("refs/remotes/",""),E=null,k=await s.refStore.readRef(b.name);k?.type==="symbolic"&&(E=k.target.replace("refs/remotes/",""));let x=E?n.all?`remotes/${R} -> ${E}`:`${R} -> ${E}`:n.all?`remotes/${R}`:R;h.push({displayName:x,hash:b.hash,isCurrent:!1,branchName:null})}}if(h.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${h.map(b=>b.isCurrent?`* ${b.displayName}`:` ${b.displayName}`).join(`
253
+ `)}
254
+ `,stderr:"",exitCode:0};let m=l>=1?await pe(s):null,p=Math.max(...h.map(w=>w.displayName.length)),g=[];for(let w of h){let b=w.isCurrent?"* ":" ",R=w.displayName.padEnd(p),E=X(w.hash),k="";try{let y=await j(s,w.hash);k=ue(y.message)}catch{}let x="";if(m&&w.branchName){let y=await Bt(s,m,w.branchName);if(y){let P=Ro(y,l>=2);P&&(x=` ${P}`)}}g.push(`${b}${R} ${E}${x} ${k}`)}return{stdout:`${g.join(`
255
+ `)}
256
+ `,stderr:"",exitCode:0}}})}function de(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var up=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],hp=["commitMsg","mergeMsg"],mp=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],pp=["onRefUpdate","onRefDelete","onObjectWrite"];function gp(...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 up){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(de(a))return a}})}for(let r of hp){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(de(a))return a}})}for(let r of mp){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 pp){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();Ue();Ce();ie();Be();ge();fn();Nt();Je();function il(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch, commit, path, or start-point for -b/-B").optional()],options:{branch:Y.string().alias("b").describe("Create and switch to a new branch"),forceBranch:Y.string().alias("B").describe("Create/reset and switch to a new branch"),detach:O().alias("d").describe("Detach HEAD at named commit"),orphan:O().describe("Create a new orphan branch"),ours:O().describe("Checkout our version for unmerged files"),theirs:O().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await K(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 u=ut(i,r.cwd),h=o.passthrough,m=null;if(a){if(n.ours||n.theirs)return S("cannot specify both a revision and --ours/--theirs");let p=await Me(i,a,`invalid reference: ${a}`);if(M(p))return p;m=p.commit.tree}return n.ours||n.theirs?Co(i,h,u,n.theirs?3:2):xo(i,h,u,m)}if(n.orphan)return n.branch?S("--orphan and -b are incompatible"):n.ours||n.theirs?S("--orphan and --ours/--theirs are incompatible"):a?bp(i,a,r.env,t):S("you must specify a branch to checkout");if(n.detach){let u=a??"HEAD",h=await Me(i,u,`invalid reference: ${u}`);return M(h)?h:ol(i,u,h.hash,r.env,t)}if(n.branch||n.forceBranch){let u=n.branch||n.forceBranch;return yp(i,u,a,r.env,t,!!n.forceBranch)}if(!a)return S("you must specify a branch to checkout");if(a==="-")return wp(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return al(i,a,c,f,r.env,t);let l=await Oo(i,a);if(l)return Ep(i,a,l.trackingRef,r.env,t);let d=await We(i,a);if(d){let u=await Te(i,d);return ol(i,a,u,r.env,t)}if(i.workTree){let u=await V(i),h=qs(u,a);if(h)return await dt(i,{path:h.path,hash:h.hash,mode:h.mode}),{stdout:"",stderr:"",exitCode:0}}return _(`error: pathspec '${a}' did not match any file(s) known to git
257
+ `)}})}async function wp(e,t,n){let r=await Gf(e);return r?al(e,r.name,r.refName,r.hash,t,n):S("no previous branch")}async function bp(e,t,n,r){if(!En(t))return S(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await U(e,o))return S(`a branch named '${t}' already exists`);let i=await V(e),a=Vn(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 Et(e);let l=await In(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ne,isBranchCheckout:!0});let d="";return f&&(d=await Yn(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
258
+ ${l}`,exitCode:0}}async function yp(e,t,n,r,o,s=!1){if(!En(t))return S(`'${t}' is not a valid branch name`);let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(i))return _(i.message??"");let a=await te(e),c=await Z(e),f=`refs/heads/${t}`,l=await U(e,f);if(l&&!s)return S(`a branch named '${t}' already exists`);let d;if(n){let k=await Me(e,n,`invalid reference: ${n}`);if(M(k))return k;d=k.hash}else d=c;if(s||n){let k=await V(e),x=Vn(k);if(x)return x}d&&await J(e,f,d);let u=await V(e);if(d&&c&&d!==c){let k=await j(e,c),x=await j(e,d);if(k.tree!==x.tree){let y=await hn(e,k.tree,x.tree,u);if(!y.success)return y.errorOutput??_("error: checkout would overwrite local changes");u={version:2,entries:y.newEntries},await ae(e,u),await De(e,y.worktreeOps)}}await Ze(e,"HEAD",f),await Et(e);let h=await In(e),m=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):c??ne,p=n??"HEAD";d&&(l?l!==d&&await re(e,r,f,l,d,`branch: Reset to ${p}`):await re(e,r,f,null,d,`branch: Created from ${p}`)),await re(e,r,"HEAD",c,d??ne,`checkout: moving from ${m} to ${t}`),await o?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:d??ne,isBranchCheckout:!0});let g="";if((s||n)&&d){let k=await j(e,d);g=await Yn(e,k.tree,u)}let w=await pe(e),b=await Bt(e,w,t);b&&(g+=zn(b));let R=a?.type==="symbolic"&&a.target===f,E=l?R?`Reset branch '${t}'
259
+ `:`Switched to and reset branch '${t}'
245
260
  `:`Switched to a new branch '${t}'
246
- `;return{stdout:u,stderr:`${p}${l}`,exitCode:0}}async function Zf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(i)?N(i.message??""):mr(e,t,n,r,o,s)}async function sp(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(s))return N(s.message??"");let i=await W(e,n);if(!i)return I(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await J(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await pe(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await ze(e,d),await re(e,r,a,null,i,`branch: Created from ${n}`);let u=await mr(e,t,a,i,r,o,{isNew:!0}),h=c.slice(1).join("/");return u.stdout=`branch '${t}' set up to track '${f}/${h}'.
247
- `,u}async function Yf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(s)?N(s.message??""):Yn(e,n,r,o,{detachAdviceTarget:t})}se();Be();Ce();se();function ca(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}=ia(e,t);return op(o,n,s,r)}function op(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 ip(e,t,n){let r=[];for(let c of ca(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 ca(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,l=c.oStart+c.oLength,d=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>l)break;l=Math.max(l,u.oStart+u.oLength),d.push(u),a++}if(d.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of d){let b=w.oStart,E=b+w.oLength,k=w.abStart,R=k+w.abLength,x=u[w.ab];x.abMin=Math.min(k,x.abMin),x.abMax=Math.max(R,x.abMax),x.oMin=Math.min(b,x.oMin),x.oMax=Math.max(E,x.oMax)}let h=u.a.abMin+(f-u.a.oMin),m=u.a.abMax+(l-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(l-u.b.oMax);o.push({stable:!1,a:e.slice(h,m),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function ap(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=ip(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&&Qf(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),r?.conflictStyle==="diff3"?Jf(i):Jf(cp(i))}function ks(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=ap(e,t,n,{conflictStyle:s}),d=!1,u=[];for(let h of l)h.type==="ok"?u.push(...h.lines):(d=!0,s==="diff3"?u.push(i,...h.a,a,...h.o,c,...h.b,f):u.push(i,...h.a,c,...h.b,f));return{conflict:d,result:u}}function cp(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...fp(n));return t}function fp(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Qf(t,n))return[e];let r=ca(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let l=c+a.buffer1[1],d=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,l),o:[],b:n.slice(a.buffer2[0],d)}),s=l}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function Jf(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function wr(e,t,n,r){let o=ks(At(e),At(t),At(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(fa);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
261
+ `;return{stdout:g,stderr:`${E}${h}`,exitCode:0}}async function al(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return de(i)?_(i.message??""):mr(e,t,n,r,o,s)}async function Ep(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(s))return _(s.message??"");let i=await U(e,n);if(!i)return S(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await J(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await pe(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await ze(e,d),await re(e,r,a,null,i,`branch: Created from ${n}`);let u=await mr(e,t,a,i,r,o,{isNew:!0}),h=c.slice(1).join("/");return u.stdout=`branch '${t}' set up to track '${f}/${h}'.
262
+ `,u}async function ol(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return de(s)?_(s.message??""):Xn(e,n,r,o,{detachAdviceTarget:t})}se();Ue();Ce();se();function ha(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}=da(e,t);return kp(o,n,s,r)}function kp(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 Rp(e,t,n){let r=[];for(let c of ha(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 ha(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,l=c.oStart+c.oLength,d=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>l)break;l=Math.max(l,u.oStart+u.oLength),d.push(u),a++}if(d.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of d){let b=w.oStart,R=b+w.oLength,E=w.abStart,k=E+w.abLength,x=u[w.ab];x.abMin=Math.min(E,x.abMin),x.abMax=Math.max(k,x.abMax),x.oMin=Math.min(b,x.oMin),x.oMax=Math.max(R,x.oMax)}let h=u.a.abMin+(f-u.a.oMin),m=u.a.abMax+(l-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(l-u.b.oMax);o.push({stable:!1,a:e.slice(h,m),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function xp(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Rp(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&&fl(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"?cl(i):cl(Cp(i))}function Es(e,t,n,r){let o=r?.markerSize??7,s=r?.conflictStyle??"merge",i=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a=`${"|".repeat(o)}${r?.o?` ${r.o}`:""}`,c="=".repeat(o),f=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,l=xp(e,t,n,{conflictStyle:s}),d=!1,u=[];for(let h of l)h.type==="ok"?u.push(...h.lines):(d=!0,s==="diff3"?u.push(i,...h.a,a,...h.o,c,...h.b,f):u.push(i,...h.a,c,...h.b,f));return{conflict:d,result:u}}function Cp(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Pp(n));return t}function Pp(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(fl(t,n))return[e];let r=ha(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 cl(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 wr(e,t,n,r){let o=Es(At(e),At(t),At(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(ma);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
248
263
  `)}
249
264
  `:a.join(`
250
265
  `)}function At(e){if(e==="")return[];let t=e.split(`
251
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function fa(e){return e.endsWith("\0")?e.slice(0,-1):e}function Qf(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Ce();ie();wn();me();kn();De();et();Jt();var Nr=new TextDecoder,tn=new TextEncoder,el={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function qt(e,t,n,r,o,s){let{paths:i,baseMap:a,oursMap:c,theirsMap:f}=await dp(e,t,n,r),l=await hp(e,i,a,c,f,o,s);return mp(e,i,o,l,s)}async function xs(e,t,n,r,o){let s=await Wt(e,t,n),i=await j(e,t),a=await j(e,n);if(s.length===0)return{...await qt(e,null,i.tree,a.tree,r,o),baseTree:null};if(s.length===1){let l=await j(e,s[0]);return{...await qt(e,l.tree,i.tree,a.tree,r,o),baseTree:l.tree}}let c=await fl(e,t,n,s,1,o);return{...await qt(e,c,i.tree,a.tree,r,o),baseTree:c}}async function dp(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,u=i.get(f)??null,h=l?{hash:l.hash,mode:l.mode}:null,m=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,b=d?.hash??null,E=u?.hash??null,k=0;w!==null&&w===b&&(k|=3),w!==null&&w===E&&(k|=5),b!==null&&b===E&&(k|=6);let R={path:f,stages:[h,m,p],pathnames:[f,f,f],filemask:g,matchMask:k,merged:{result:null,clean:!1},pathConflict:!1};if(up(R)){c.set(f,R);continue}c.set(f,R)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function up(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 hp(e,t,n,r,o,s,i){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},c=[],f=[];for(let[O,H]of n)r.has(O)||c.push({path:O,status:"deleted",oldHash:H.hash,oldMode:H.mode}),o.has(O)||f.push({path:O,status:"deleted",oldHash:H.hash,oldMode:H.mode});for(let[O,H]of r)n.has(O)||c.push({path:O,status:"added",newHash:H.hash,newMode:H.mode});for(let[O,H]of o)n.has(O)||f.push({path:O,status:"added",newHash:H.hash,newMode:H.mode});let l=await st(e,c),d=await st(e,f);if(l.renames.length===0&&d.renames.length===0)return a;let u=new Map,h=new Map;for(let O of l.renames)u.set(O.oldPath,O);for(let O of d.renames)h.set(O.oldPath,O);let m=new Set;for(let[O]of r)!n.has(O)&&o.has(O)&&m.add(O);let p=new Set,g=s?.a??"HEAD",w=s?.b??"theirs";function b(O,H,L=0){a.msgBuf.push({sortKey:O,subOrder:L,text:H})}for(let O of[...n.keys()].sort()){let H=u.get(O),L=h.get(O);if(!H&&!L)continue;let G=n.get(O);if(p.add(O),H&&L)if(p.add(H.newPath),p.add(L.newPath),H.newPath===L.newPath){let B=r.get(H.newPath),F=o.get(L.newPath);if(B.hash===F.hash)a.entries.push(Ct(H.newPath,B));else{let ee=la(t,H.newPath);ee.stages=[{hash:G.hash,mode:G.mode},{hash:B.hash,mode:B.mode},{hash:F.hash,mode:F.mode}],ee.pathnames=[O,H.newPath,L.newPath],ee.filemask=7,ee.merged={result:null,clean:!1}}}else{let B=r.get(H.newPath),F=o.get(L.newPath),ee=await cl(e,G,B,F,s,void 0,void 0,i);ee.conflict&&b(O,`Auto-merging ${O}`,-1),a.conflicts.push({path:O,reason:"rename-rename",oursPath:H.newPath,theirsPath:L.newPath}),b(O,`CONFLICT (rename/rename): ${O} renamed to ${H.newPath} in ${g} and to ${L.newPath} in ${w}.`),a.entries.push(Ct(O,G,1)),a.entries.push(at(H.newPath,B.mode,ee.hash,2)),a.entries.push(at(L.newPath,F.mode,ee.hash,3)),a.worktreeBlobs.set(H.newPath,{hash:ee.hash,mode:B.mode}),a.worktreeBlobs.set(L.newPath,{hash:ee.hash,mode:F.mode})}else if(H){p.add(H.newPath);let B=o.get(O),F=r.get(H.newPath),ee=m.has(H.newPath);if(B)if(ee)await il(e,a,H.newPath,O,G,F,B,r,o,!1,s,i);else if(B.hash===G.hash&&F.hash===G.hash)a.entries.push(Ct(H.newPath,F));else if(B.hash===G.hash)a.entries.push(Ct(H.newPath,F));else if(F.hash===G.hash)a.entries.push(at(H.newPath,F.mode,B.hash));else{let V=la(t,H.newPath);V.stages=[{hash:G.hash,mode:G.mode},{hash:F.hash,mode:F.mode},{hash:B.hash,mode:B.mode}],V.pathnames=[O,H.newPath,O],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=o.get(H.newPath);if(a.conflicts.push({path:H.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:O}),b(H.newPath,`CONFLICT (rename/delete): ${O} renamed to ${H.newPath} in ${g}, but deleted in ${w}.`),V){a.conflicts.push({path:H.newPath,reason:"add-add"}),b(H.newPath,`Auto-merging ${H.newPath}`,0),b(H.newPath,`CONFLICT (add/add): Merge conflict in ${H.newPath}`,1),a.entries.push(Ct(H.newPath,F,2)),a.entries.push(Ct(H.newPath,V,3));let te=await Lo(e,F.hash,V.hash,F.mode,s);a.worktreeBlobs.set(H.newPath,{hash:te,mode:F.mode})}else a.entries.push(at(H.newPath,G.mode,G.hash,1)),a.entries.push(Ct(H.newPath,F,2)),a.worktreeBlobs.set(H.newPath,{hash:F.hash,mode:F.mode}),F.hash!==G.hash&&b(H.newPath,`CONFLICT (modify/delete): ${H.newPath} deleted in ${w} and modified in ${g}. Version ${g} of ${H.newPath} left in tree.`,1)}}else if(L){p.add(L.newPath);let B=r.get(O),F=o.get(L.newPath),ee=m.has(L.newPath);if(B)if(ee)await il(e,a,L.newPath,O,G,B,F,r,o,!0,s,i);else if(B.hash===G.hash&&F.hash===G.hash)a.entries.push(Ct(L.newPath,F));else if(B.hash===G.hash)a.entries.push(Ct(L.newPath,F));else if(F.hash===G.hash)a.entries.push(at(L.newPath,F.mode,B.hash));else{let V=la(t,L.newPath);V.stages=[{hash:G.hash,mode:G.mode},{hash:B.hash,mode:B.mode},{hash:F.hash,mode:F.mode}],V.pathnames=[O,O,L.newPath],V.filemask=7,V.merged={result:null,clean:!1}}else{let V=r.get(L.newPath);if(a.conflicts.push({path:L.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:O}),b(L.newPath,`CONFLICT (rename/delete): ${O} renamed to ${L.newPath} in ${w}, but deleted in ${g}.`),V){a.conflicts.push({path:L.newPath,reason:"add-add"}),b(L.newPath,`Auto-merging ${L.newPath}`,0),b(L.newPath,`CONFLICT (add/add): Merge conflict in ${L.newPath}`,1),a.entries.push(Ct(L.newPath,V,2)),a.entries.push(Ct(L.newPath,F,3));let te=await Lo(e,V.hash,F.hash,V.mode,s);a.worktreeBlobs.set(L.newPath,{hash:te,mode:V.mode})}else a.entries.push(at(L.newPath,G.mode,G.hash,1)),a.entries.push(Ct(L.newPath,F,3)),a.worktreeBlobs.set(L.newPath,{hash:F.hash,mode:F.mode}),F.hash!==G.hash&&b(L.newPath,`CONFLICT (modify/delete): ${L.newPath} deleted in ${g} and modified in ${w}. Version ${w} of ${L.newPath} left in tree.`,1)}}}let E=new Set(l.renames.map(O=>O.newPath)),k=new Set(d.renames.map(O=>O.newPath)),R=tl(n,r),x=tl(n,o),y=nl(R,o,n),C=nl(x,r,n),$=rl(l.renames,y),D=rl(d.renames,C),P=sl($),T=sl(D);for(let O of[...P.keys()])T.has(O)&&(P.delete(O),T.delete(O));let A=new Set(P.keys()),U=new Set(T.keys());if(T.size>0)for(let O of c){if(O.status!=="added"||E.has(O.path))continue;let H=ol(O.path,T,A);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(r.has(H)){b(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${O.path}.`,1);continue}let B=r.get(O.path),F=o.get(H)??n.get(H);a.entries.push(at(H,B.mode,B.hash,2)),F&&a.entries.push(at(H,F.mode,F.hash,3)),a.worktreeBlobs.set(H,{hash:B.hash,mode:B.mode}),a.conflicts.push({path:H,reason:"add-add"}),b(H,`CONFLICT (file location): ${O.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${H}.`,1);let ee=t.get(O.path);ee&&(ee.merged={result:null,clean:!0}),p.add(O.path);continue}let L=r.get(O.path);a.entries.push(at(H,L.mode,L.hash,2)),a.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:H,reason:"directory-rename"}),b(H,`CONFLICT (file location): ${O.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${H}.`,1);let G=t.get(O.path);G&&(G.merged={result:null,clean:!0}),p.add(O.path)}if(P.size>0)for(let O of f){if(O.status!=="added"||k.has(O.path))continue;let H=ol(O.path,P,U);if(!H)continue;if(t.has(H)||n.has(H)||r.has(H)||o.has(H)){if(o.has(H)){b(H,`CONFLICT (implicit dir rename): Existing file/dir at ${H} in the way of implicit directory rename(s) putting the following path(s) there: ${O.path}.`,1);continue}let B=o.get(O.path),F=r.get(H)??n.get(H);F&&a.entries.push(at(H,F.mode,F.hash,2)),a.entries.push(at(H,B.mode,B.hash,3)),a.worktreeBlobs.set(H,{hash:B.hash,mode:B.mode}),a.conflicts.push({path:H,reason:"add-add"}),b(H,`CONFLICT (file location): ${O.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let ee=t.get(O.path);ee&&(ee.merged={result:null,clean:!0}),p.add(O.path);continue}let L=o.get(O.path);a.entries.push(at(H,L.mode,L.hash,3)),a.worktreeBlobs.set(H,{hash:L.hash,mode:L.mode}),a.conflicts.push({path:H,reason:"directory-rename"}),b(H,`CONFLICT (file location): ${O.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${H}.`,1);let G=t.get(O.path);G&&(G.merged={result:null,clean:!0}),p.add(O.path)}let _=new Set(a.entries.map(O=>O.path));for(let O of _){let H=t.get(O);H&&(H.merged={result:null,clean:!0})}for(let O of p){if(_.has(O))continue;let H=t.get(O);if(!H||H.merged.clean)continue;H.filemask===7&&!H.pathConflict||(H.merged={result:null,clean:!0})}return a}function tl(e,t){let n=new Set;for(let s of e.keys()){let i=Ht(s);for(;i;)n.add(i),i=Ht(i)}let r=new Set;for(let s of t.keys()){let i=Ht(s);for(;i;)r.add(i),i=Ht(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function nl(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=Ht(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Ht(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Ht(s)}return r}function rl(e,t){let n=new Map;for(let r of e){let o=Ht(r.oldPath),s=Ht(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=Ht(o),s=Ht(s)}}return n}function sl(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 ol(e,t,n){let r=Ht(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=Ht(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Ht(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function il(e,t,n,r,o,s,i,a,c,f=!1,l,d){let u=f?a.get(n):c.get(n),h=f?i:s;if(u.hash===h.hash){t.entries.push(at(n,u.mode,u.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let p=await cl(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8,d);if(u.hash===p.hash)t.entries.push(at(n,u.mode,p.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(Ct(n,u,2)),t.entries.push(at(n,i.mode,p.hash,3));let g=await Lo(e,u.hash,p.hash,u.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:u.mode})}else{t.entries.push(at(n,s.mode,p.hash,2)),t.entries.push(Ct(n,u,3));let g=await Lo(e,p.hash,u.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:s.mode})}}async function cl(e,t,n,r,o,s,i,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(En(t.mode)||En(n.mode)||En(r.mode))return{hash:n.hash,conflict:!0};let c=await oe(e,t.hash),f=await oe(e,n.hash),l=await oe(e,r.hash);if(Ae(f)||Ae(l)||Ae(c))return{hash:n.hash,conflict:!0};if(a){let x=await a({path:t.path??n.path??r.path??"",base:c,ours:f,theirs:l});if(x!==null)return{hash:await Ie(e,"blob",tn.encode(x.content)),conflict:x.conflict}}let d=At(c),u=At(f),h=At(l),m=o?.conflictStyle,p=ks(u,d,h,{conflictStyle:m});if(!p.conflict)return{hash:await ua(e,p.result),conflict:!1};let g=o?.a??"HEAD",w=o?.b??"theirs",b=s?.oursPath?`${g}:${s.oursPath}`:g,E=s?.theirsPath?`${w}:${s.theirsPath}`:w,k=wr(f,c,l,{a:b,b:E,markerSize:i??7,conflictStyle:m});return{hash:await Ie(e,"blob",tn.encode(k)),conflict:!0}}async function Lo(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=wr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Ie(e,"blob",tn.encode(a))}function Ct(e,t,n=0){return at(e,t.mode,t.hash,n)}function at(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:ve()}}async function mp(e,t,n,r,o){let s=[...r.entries],i=[...r.conflicts],a=[...r.msgBuf],c=new Map(r.worktreeBlobs);function f(m,p,g=0){a.push({sortKey:m,subOrder:g,text:p})}for(let m of[...t.keys()].sort()){let p=t.get(m);if(p.merged.clean){p.merged.result?.hash&&s.push(Oe(m,p.merged.result.hash,p.merged.result.mode));continue}await pp(e,p,n,s,i,f,c,o)}a.sort((m,p)=>(m.sortKey<p.sortKey?-1:m.sortKey>p.sortKey?1:0)||m.subOrder-p.subOrder);let l=a.map(m=>m.text),d=[],u=new Set;for(let m of s)m.stage===0&&(d.push(m),u.add(m.path));for(let[m,p]of c)u.has(m)||d.push(Oe(m,p.hash,p.mode));d.sort((m,p)=>Te(m.path,p.path));let h=await _e(e,d);return{entries:s,conflicts:i,messages:l,resultTree:h}}async function pp(e,t,n,r,o,s,i,a){let c=t.path,[f,l,d]=t.stages,u=f?.hash??null,h=l?.hash??null,m=d?.hash??null;if(h===null&&m!==null&&u!==null){o.push({path:c,reason:"delete-modify",deletedBy:"ours"});let p=n?.a??"HEAD",g=n?.b??"theirs";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:m,mode:d.mode});return}if(m===null&&h!==null&&u!==null){o.push({path:c,reason:"delete-modify",deletedBy:"theirs"});let p=n?.b??"theirs",g=n?.a??"HEAD";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),i.set(c,{hash:h,mode:l.mode});return}if(u===null&&h!==null&&m!==null){if(h===m){r.push(Oe(c,h,l.mode));return}s(c,`Auto-merging ${c}`,0);let p=await oe(e,h),g=await oe(e,m);if(Ae(p)||Ae(g)){o.push({path:c,reason:"add-add"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}if(a){let y=await a({path:c,base:null,ours:p,theirs:g});if(y!==null){let C=await Ie(e,"blob",tn.encode(y.content));if(!y.conflict){r.push(Oe(c,C,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:C,mode:l.mode});return}}let w=At(""),b=At(p),E=At(g),k=ks(b,w,E,{conflictStyle:n?.conflictStyle});if(!k.conflict){let y=await ua(e,k.result);r.push(Oe(c,y,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3));let R=wr(p,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),x=await Ie(e,"blob",tn.encode(R));i.set(c,{hash:x,mode:l.mode});return}if(u!==null&&h!==null&&m!==null){if(h===u){r.push(Oe(c,m,d.mode));return}if(m===u){r.push(Oe(c,h,l.mode));return}if(h===m){r.push(Oe(c,h,l.mode));return}if(s(c,`Auto-merging ${c}`,0),En(f.mode)||En(l.mode)||En(d.mode)){o.push({path:c,reason:"content"}),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}let p=await oe(e,u),g=await oe(e,h),w=await oe(e,m);if(Ae(g)||Ae(w)||Ae(p)){o.push({path:c,reason:"content"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}if(a){let x=await a({path:c,base:p,ours:g,theirs:w});if(x!==null){let y=await Ie(e,"blob",tn.encode(x.content));if(!x.conflict){r.push(Oe(c,y,l.mode));return}let C=t.pathnames[1],$=t.pathnames[2],D=C!==c||$!==c,P={path:c,reason:"content"};D&&(C!==c&&(P.oursOrigPath=C),$!==c&&(P.theirsOrigPath=$)),o.push(P),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:y,mode:l.mode});return}}let b=At(p),E=At(g),k=At(w),R=ks(E,b,k,{conflictStyle:n?.conflictStyle});if(R.conflict){let x=t.pathnames[1],y=t.pathnames[2],C=x!==c||y!==c,$={path:c,reason:"content"};C&&(x!==c&&($.oursOrigPath=x),y!==c&&($.theirsOrigPath=y)),o.push($),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3));let D=C?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",P=C?`${n?.b??"theirs"}:${y}`:n?.b??"theirs",T=wr(g,p,w,{a:D,b:P,conflictStyle:n?.conflictStyle}),A=await Ie(e,"blob",tn.encode(T));i.set(c,{hash:A,mode:l.mode})}else{let x=await ua(e,R.result);r.push(Oe(c,x,l.mode))}return}}var gp=200;async function fl(e,t,n,r,o,s){let i=await Promise.all(r.map(async d=>({hash:d,timestamp:(await j(e,d)).committer.timestamp})));i.sort((d,u)=>d.timestamp-u.timestamp);let a=i.map(d=>d.hash),c=a[0],f=c,l=(await j(e,c)).tree;for(let d=1;d<a.length;d++){let u=a[d],h=(await j(e,u)).tree,m=null;if(o>=gp)m=l;else{let w=await Wt(e,f,u);w.length===0?m=null:w.length===1?m=(await j(e,w[0])).tree:m=await fl(e,f,u,w,o+1,s)}let p=await qt(e,m,l,h,void 0,s);l=await wp(e,p,o);let g=an({type:"commit",tree:l,parents:[f,u],author:el,committer:el,message:"merged common ancestors"});f=await Ie(e,"commit",g)}return l}async function wp(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),h=s(l,2),m=s(d,3);if(h&&m){let p=Nr.decode((await ye(e,h.hash)).content),g=Nr.decode((await ye(e,m.hash)).content),w=u?Nr.decode((await ye(e,u.hash)).content):"",b=8+n*2,E=i.a??"Temporary merge branch 1",k=i.b??"Temporary merge branch 2",R=wr(p,w,g,{a:`${E}:${l}`,o:i.o,b:`${k}:${d}`,markerSize:b}),x=await Ie(e,"blob",tn.encode(R));r.push({path:l,mode:h.mode,hash:x,stage:0,stat:ve()}),r.push({path:d,mode:m.mode,hash:x,stage:0,stat:ve()});continue}else if(h){r.push({...h,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=Nr.decode((await ye(e,c.hash)).content),d=Nr.decode((await ye(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,h=u?Nr.decode((await ye(e,u.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=m?`${p}:${a.oursOrigPath??a.path}`:p,b=m?`${g}:${a.theirsOrigPath??a.path}`:g,E=wr(l,h,d,{a:w,o:i.o,b,markerSize:i.markerSize}),k=await Ie(e,"blob",tn.encode(E));r.push({path:a.path,mode:c.mode,hash:k,stage:0,stat:ve()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Te(a.path,c.path)),_e(e,r)}async function ua(e,t){let n=t.map(fa);if(n.length===0)return Ie(e,"blob",tn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
266
+ `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ma(e){return e.endsWith("\0")?e.slice(0,-1):e}function fl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Ce();ie();bn();me();Pn();Ae();Je();Nt();var Nr=new TextDecoder,nn=new TextEncoder,ll={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Kt(e,t,n,r,o,s){let{paths:i,baseMap:a,oursMap:c,theirsMap:f}=await Op(e,t,n,r),l=await Ip(e,i,a,c,f,o,s);return Tp(e,i,o,l,s)}async function Rs(e,t,n,r,o){let s=await qt(e,t,n),i=await j(e,t),a=await j(e,n);if(s.length===0)return{...await Kt(e,null,i.tree,a.tree,r,o),baseTree:null};if(s.length===1){let l=await j(e,s[0]);return{...await Kt(e,l.tree,i.tree,a.tree,r,o),baseTree:l.tree}}let c=await yl(e,t,n,s,1,o);return{...await Kt(e,c,i.tree,a.tree,r,o),baseTree:c}}async function Op(e,t,n,r){let o=await le(e,t),s=await le(e,n),i=await le(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let l=o.get(f)??null,d=s.get(f)??null,u=i.get(f)??null,h=l?{hash:l.hash,mode:l.mode}:null,m=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,b=d?.hash??null,R=u?.hash??null,E=0;w!==null&&w===b&&(E|=3),w!==null&&w===R&&(E|=5),b!==null&&b===R&&(E|=6);let k={path:f,stages:[h,m,p],pathnames:[f,f,f],filemask:g,matchMask:E,merged:{result:null,clean:!1},pathConflict:!1};if(Sp(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Sp(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 Ip(e,t,n,r,o,s,i){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},c=[],f=[];for(let[I,T]of n)r.has(I)||c.push({path:I,status:"deleted",oldHash:T.hash,oldMode:T.mode}),o.has(I)||f.push({path:I,status:"deleted",oldHash:T.hash,oldMode:T.mode});for(let[I,T]of r)n.has(I)||c.push({path:I,status:"added",newHash:T.hash,newMode:T.mode});for(let[I,T]of o)n.has(I)||f.push({path:I,status:"added",newHash:T.hash,newMode:T.mode});let l=await it(e,c),d=await it(e,f);if(l.renames.length===0&&d.renames.length===0)return a;let u=new Map,h=new Map;for(let I of l.renames)u.set(I.oldPath,I);for(let I of d.renames)h.set(I.oldPath,I);let m=new Set;for(let[I]of r)!n.has(I)&&o.has(I)&&m.add(I);let p=new Set,g=s?.a??"HEAD",w=s?.b??"theirs";function b(I,T,G=0){a.msgBuf.push({sortKey:I,subOrder:G,text:T})}for(let I of[...n.keys()].sort()){let T=u.get(I),G=h.get(I);if(!T&&!G)continue;let W=n.get(I);if(p.add(I),T&&G)if(p.add(T.newPath),p.add(G.newPath),T.newPath===G.newPath){let F=r.get(T.newPath),B=o.get(G.newPath);if(F.hash===B.hash)a.entries.push(Ct(T.newPath,F));else{let ee=pa(t,T.newPath);ee.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:B.hash,mode:B.mode}],ee.pathnames=[I,T.newPath,G.newPath],ee.filemask=7,ee.merged={result:null,clean:!1}}}else{let F=r.get(T.newPath),B=o.get(G.newPath),ee=await bl(e,W,F,B,s,void 0,void 0,i);ee.conflict&&b(I,`Auto-merging ${I}`,-1),a.conflicts.push({path:I,reason:"rename-rename",oursPath:T.newPath,theirsPath:G.newPath}),b(I,`CONFLICT (rename/rename): ${I} renamed to ${T.newPath} in ${g} and to ${G.newPath} in ${w}.`),a.entries.push(Ct(I,W,1)),a.entries.push(ft(T.newPath,F.mode,ee.hash,2)),a.entries.push(ft(G.newPath,B.mode,ee.hash,3)),a.worktreeBlobs.set(T.newPath,{hash:ee.hash,mode:F.mode}),a.worktreeBlobs.set(G.newPath,{hash:ee.hash,mode:B.mode})}else if(T){p.add(T.newPath);let F=o.get(I),B=r.get(T.newPath),ee=m.has(T.newPath);if(F)if(ee)await gl(e,a,T.newPath,I,W,B,F,r,o,!1,s,i);else if(F.hash===W.hash&&B.hash===W.hash)a.entries.push(Ct(T.newPath,B));else if(F.hash===W.hash)a.entries.push(Ct(T.newPath,B));else if(B.hash===W.hash)a.entries.push(ft(T.newPath,B.mode,F.hash));else{let z=pa(t,T.newPath);z.stages=[{hash:W.hash,mode:W.mode},{hash:B.hash,mode:B.mode},{hash:F.hash,mode:F.mode}],z.pathnames=[I,T.newPath,I],z.filemask=7,z.merged={result:null,clean:!1}}else{let z=o.get(T.newPath);if(a.conflicts.push({path:T.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:I}),b(T.newPath,`CONFLICT (rename/delete): ${I} renamed to ${T.newPath} in ${g}, but deleted in ${w}.`),z){a.conflicts.push({path:T.newPath,reason:"add-add"}),b(T.newPath,`Auto-merging ${T.newPath}`,0),b(T.newPath,`CONFLICT (add/add): Merge conflict in ${T.newPath}`,1),a.entries.push(Ct(T.newPath,B,2)),a.entries.push(Ct(T.newPath,z,3));let Q=await Mo(e,B.hash,z.hash,B.mode,s);a.worktreeBlobs.set(T.newPath,{hash:Q,mode:B.mode})}else a.entries.push(ft(T.newPath,W.mode,W.hash,1)),a.entries.push(Ct(T.newPath,B,2)),a.worktreeBlobs.set(T.newPath,{hash:B.hash,mode:B.mode}),B.hash!==W.hash&&b(T.newPath,`CONFLICT (modify/delete): ${T.newPath} deleted in ${w} and modified in ${g}. Version ${g} of ${T.newPath} left in tree.`,1)}}else if(G){p.add(G.newPath);let F=r.get(I),B=o.get(G.newPath),ee=m.has(G.newPath);if(F)if(ee)await gl(e,a,G.newPath,I,W,F,B,r,o,!0,s,i);else if(F.hash===W.hash&&B.hash===W.hash)a.entries.push(Ct(G.newPath,B));else if(F.hash===W.hash)a.entries.push(Ct(G.newPath,B));else if(B.hash===W.hash)a.entries.push(ft(G.newPath,B.mode,F.hash));else{let z=pa(t,G.newPath);z.stages=[{hash:W.hash,mode:W.mode},{hash:F.hash,mode:F.mode},{hash:B.hash,mode:B.mode}],z.pathnames=[I,I,G.newPath],z.filemask=7,z.merged={result:null,clean:!1}}else{let z=r.get(G.newPath);if(a.conflicts.push({path:G.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:I}),b(G.newPath,`CONFLICT (rename/delete): ${I} renamed to ${G.newPath} in ${w}, but deleted in ${g}.`),z){a.conflicts.push({path:G.newPath,reason:"add-add"}),b(G.newPath,`Auto-merging ${G.newPath}`,0),b(G.newPath,`CONFLICT (add/add): Merge conflict in ${G.newPath}`,1),a.entries.push(Ct(G.newPath,z,2)),a.entries.push(Ct(G.newPath,B,3));let Q=await Mo(e,z.hash,B.hash,z.mode,s);a.worktreeBlobs.set(G.newPath,{hash:Q,mode:z.mode})}else a.entries.push(ft(G.newPath,W.mode,W.hash,1)),a.entries.push(Ct(G.newPath,B,3)),a.worktreeBlobs.set(G.newPath,{hash:B.hash,mode:B.mode}),B.hash!==W.hash&&b(G.newPath,`CONFLICT (modify/delete): ${G.newPath} deleted in ${g} and modified in ${w}. Version ${w} of ${G.newPath} left in tree.`,1)}}}let R=new Set(l.renames.map(I=>I.newPath)),E=new Set(d.renames.map(I=>I.newPath)),k=dl(n,r),x=dl(n,o),y=ul(k,o,n),P=ul(x,r,n),C=hl(l.renames,y),A=hl(d.renames,P),D=ml(C),$=ml(A);for(let I of[...D.keys()])$.has(I)&&(D.delete(I),$.delete(I));let v=new Set(D.keys()),N=new Set($.keys());if($.size>0)for(let I of c){if(I.status!=="added"||R.has(I.path))continue;let T=pl(I.path,$,v);if(!T)continue;if(t.has(T)||n.has(T)||r.has(T)||o.has(T)){if(r.has(T)){b(T,`CONFLICT (implicit dir rename): Existing file/dir at ${T} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let F=r.get(I.path),B=o.get(T)??n.get(T);a.entries.push(ft(T,F.mode,F.hash,2)),B&&a.entries.push(ft(T,B.mode,B.hash,3)),a.worktreeBlobs.set(T,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:T,reason:"add-add"}),b(T,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${T}.`,1);let ee=t.get(I.path);ee&&(ee.merged={result:null,clean:!0}),p.add(I.path);continue}let G=r.get(I.path);a.entries.push(ft(T,G.mode,G.hash,2)),a.worktreeBlobs.set(T,{hash:G.hash,mode:G.mode}),a.conflicts.push({path:T,reason:"directory-rename"}),b(T,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${w}, suggesting it should perhaps be moved to ${T}.`,1);let W=t.get(I.path);W&&(W.merged={result:null,clean:!0}),p.add(I.path)}if(D.size>0)for(let I of f){if(I.status!=="added"||E.has(I.path))continue;let T=pl(I.path,D,N);if(!T)continue;if(t.has(T)||n.has(T)||r.has(T)||o.has(T)){if(o.has(T)){b(T,`CONFLICT (implicit dir rename): Existing file/dir at ${T} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let F=o.get(I.path),B=r.get(T)??n.get(T);B&&a.entries.push(ft(T,B.mode,B.hash,2)),a.entries.push(ft(T,F.mode,F.hash,3)),a.worktreeBlobs.set(T,{hash:F.hash,mode:F.mode}),a.conflicts.push({path:T,reason:"add-add"}),b(T,`CONFLICT (file location): ${I.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${T}.`,1);let ee=t.get(I.path);ee&&(ee.merged={result:null,clean:!0}),p.add(I.path);continue}let G=o.get(I.path);a.entries.push(ft(T,G.mode,G.hash,3)),a.worktreeBlobs.set(T,{hash:G.hash,mode:G.mode}),a.conflicts.push({path:T,reason:"directory-rename"}),b(T,`CONFLICT (file location): ${I.path} added in ${w} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${T}.`,1);let W=t.get(I.path);W&&(W.merged={result:null,clean:!0}),p.add(I.path)}let L=new Set(a.entries.map(I=>I.path));for(let I of L){let T=t.get(I);T&&(T.merged={result:null,clean:!0})}for(let I of p){if(L.has(I))continue;let T=t.get(I);if(!T||T.merged.clean)continue;T.filemask===7&&!T.pathConflict||(T.merged={result:null,clean:!0})}return a}function dl(e,t){let n=new Set;for(let s of e.keys()){let i=Dt(s);for(;i;)n.add(i),i=Dt(i)}let r=new Set;for(let s of t.keys()){let i=Dt(s);for(;i;)r.add(i),i=Dt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function ul(e,t,n){if(e.size===0)return e;let r=new Set;for(let o of t.keys()){if(n.has(o))continue;let s=Dt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Dt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Dt(s)}return r}function hl(e,t){let n=new Map;for(let r of e){let o=Dt(r.oldPath),s=Dt(r.newPath),i=!0;for(;;){if(!i){let a=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),l=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==l)break}if(t.has(o)){let a=n.get(o);a||(a=new Map,n.set(o,a)),a.set(s,(a.get(s)??0)+1)}if(i=!1,!o||!s)break;o=Dt(o),s=Dt(s)}}return n}function ml(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 pl(e,t,n){let r=Dt(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let i=e.slice(r.length+1);return s?`${s}/${i}`:i}r=Dt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Dt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function gl(e,t,n,r,o,s,i,a,c,f=!1,l,d){let u=f?a.get(n):c.get(n),h=f?i:s;if(u.hash===h.hash){t.entries.push(ft(n,u.mode,u.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let p=await bl(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8,d);if(u.hash===p.hash)t.entries.push(ft(n,u.mode,p.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(Ct(n,u,2)),t.entries.push(ft(n,i.mode,p.hash,3));let g=await Mo(e,u.hash,p.hash,u.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:u.mode})}else{t.entries.push(ft(n,s.mode,p.hash,2)),t.entries.push(Ct(n,u,3));let g=await Mo(e,p.hash,u.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:g,mode:s.mode})}}async function bl(e,t,n,r,o,s,i,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(Cn(t.mode)||Cn(n.mode)||Cn(r.mode))return{hash:n.hash,conflict:!0};let c=await oe(e,t.hash),f=await oe(e,n.hash),l=await oe(e,r.hash);if(je(f)||je(l)||je(c))return{hash:n.hash,conflict:!0};if(a){let x=await a({path:t.path??n.path??r.path??"",base:c,ours:f,theirs:l});if(x!==null)return{hash:await Ie(e,"blob",nn.encode(x.content)),conflict:x.conflict}}let d=At(c),u=At(f),h=At(l),m=o?.conflictStyle,p=Es(u,d,h,{conflictStyle:m});if(!p.conflict)return{hash:await wa(e,p.result),conflict:!1};let g=o?.a??"HEAD",w=o?.b??"theirs",b=s?.oursPath?`${g}:${s.oursPath}`:g,R=s?.theirsPath?`${w}:${s.theirsPath}`:w,E=wr(f,c,l,{a:b,b:R,markerSize:i??7,conflictStyle:m});return{hash:await Ie(e,"blob",nn.encode(E)),conflict:!0}}async function Mo(e,t,n,r,o){let s=await oe(e,t),i=await oe(e,n),a=wr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return Ie(e,"blob",nn.encode(a))}function Ct(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:He()}}async function Tp(e,t,n,r,o){let s=[...r.entries],i=[...r.conflicts],a=[...r.msgBuf],c=new Map(r.worktreeBlobs);function f(m,p,g=0){a.push({sortKey:m,subOrder:g,text:p})}for(let m of[...t.keys()].sort()){let p=t.get(m);if(p.merged.clean){p.merged.result?.hash&&s.push(Oe(m,p.merged.result.hash,p.merged.result.mode));continue}await vp(e,p,n,s,i,f,c,o)}a.sort((m,p)=>(m.sortKey<p.sortKey?-1:m.sortKey>p.sortKey?1:0)||m.subOrder-p.subOrder);let l=a.map(m=>m.text),d=[],u=new Set;for(let m of s)m.stage===0&&(d.push(m),u.add(m.path));for(let[m,p]of c)u.has(m)||d.push(Oe(m,p.hash,p.mode));d.sort((m,p)=>ve(m.path,p.path));let h=await Fe(e,d);return{entries:s,conflicts:i,messages:l,resultTree:h}}async function vp(e,t,n,r,o,s,i,a){let c=t.path,[f,l,d]=t.stages,u=f?.hash??null,h=l?.hash??null,m=d?.hash??null;if(h===null&&m!==null&&u!==null){o.push({path:c,reason:"delete-modify",deletedBy:"ours"});let p=n?.a??"HEAD",g=n?.b??"theirs";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:m,mode:d.mode});return}if(m===null&&h!==null&&u!==null){o.push({path:c,reason:"delete-modify",deletedBy:"theirs"});let p=n?.b??"theirs",g=n?.a??"HEAD";s(c,`CONFLICT (modify/delete): ${c} deleted in ${p} and modified in ${g}. Version ${g} of ${c} left in tree.`),f&&r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),i.set(c,{hash:h,mode:l.mode});return}if(u===null&&h!==null&&m!==null){if(h===m){r.push(Oe(c,h,l.mode));return}s(c,`Auto-merging ${c}`,0);let p=await oe(e,h),g=await oe(e,m);if(je(p)||je(g)){o.push({path:c,reason:"add-add"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}if(a){let y=await a({path:c,base:null,ours:p,theirs:g});if(y!==null){let P=await Ie(e,"blob",nn.encode(y.content));if(!y.conflict){r.push(Oe(c,P,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:P,mode:l.mode});return}}let w=At(""),b=At(p),R=At(g),E=Es(b,w,R,{conflictStyle:n?.conflictStyle});if(!E.conflict){let y=await wa(e,E.result);r.push(Oe(c,y,l.mode));return}o.push({path:c,reason:"add-add"}),s(c,`CONFLICT (add/add): Merge conflict in ${c}`,1),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3));let k=wr(p,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),x=await Ie(e,"blob",nn.encode(k));i.set(c,{hash:x,mode:l.mode});return}if(u!==null&&h!==null&&m!==null){if(h===u){r.push(Oe(c,m,d.mode));return}if(m===u){r.push(Oe(c,h,l.mode));return}if(h===m){r.push(Oe(c,h,l.mode));return}if(s(c,`Auto-merging ${c}`,0),Cn(f.mode)||Cn(l.mode)||Cn(d.mode)){o.push({path:c,reason:"content"}),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}let p=await oe(e,u),g=await oe(e,h),w=await oe(e,m);if(je(g)||je(w)||je(p)){o.push({path:c,reason:"content"}),s(c,`warning: Cannot merge binary files: ${c} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:h,mode:l.mode});return}if(a){let x=await a({path:c,base:p,ours:g,theirs:w});if(x!==null){let y=await Ie(e,"blob",nn.encode(x.content));if(!x.conflict){r.push(Oe(c,y,l.mode));return}let P=t.pathnames[1],C=t.pathnames[2],A=P!==c||C!==c,D={path:c,reason:"content"};A&&(P!==c&&(D.oursOrigPath=P),C!==c&&(D.theirsOrigPath=C)),o.push(D),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3)),i.set(c,{hash:y,mode:l.mode});return}}let b=At(p),R=At(g),E=At(w),k=Es(R,b,E,{conflictStyle:n?.conflictStyle});if(k.conflict){let x=t.pathnames[1],y=t.pathnames[2],P=x!==c||y!==c,C={path:c,reason:"content"};P&&(x!==c&&(C.oursOrigPath=x),y!==c&&(C.theirsOrigPath=y)),o.push(C),s(c,`CONFLICT (content): Merge conflict in ${c}`,1),r.push(Oe(c,u,f.mode,1)),r.push(Oe(c,h,l.mode,2)),r.push(Oe(c,m,d.mode,3));let A=P?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",D=P?`${n?.b??"theirs"}:${y}`:n?.b??"theirs",$=wr(g,p,w,{a:A,b:D,conflictStyle:n?.conflictStyle}),v=await Ie(e,"blob",nn.encode($));i.set(c,{hash:v,mode:l.mode})}else{let x=await wa(e,k.result);r.push(Oe(c,x,l.mode))}return}}var Hp=200;async function yl(e,t,n,r,o,s){let i=await Promise.all(r.map(async d=>({hash:d,timestamp:(await j(e,d)).committer.timestamp})));i.sort((d,u)=>d.timestamp-u.timestamp);let a=i.map(d=>d.hash),c=a[0],f=c,l=(await j(e,c)).tree;for(let d=1;d<a.length;d++){let u=a[d],h=(await j(e,u)).tree,m=null;if(o>=Hp)m=l;else{let w=await qt(e,f,u);w.length===0?m=null:w.length===1?m=(await j(e,w[0])).tree:m=await yl(e,f,u,w,o+1,s)}let p=await Kt(e,m,l,h,void 0,s);l=await Ap(e,p,o);let g=cn({type:"commit",tree:l,parents:[f,u],author:ll,committer:ll,message:"merged common ancestors"});f=await Ie(e,"commit",g)}return l}async function Ap(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),h=s(l,2),m=s(d,3);if(h&&m){let p=Nr.decode((await we(e,h.hash)).content),g=Nr.decode((await we(e,m.hash)).content),w=u?Nr.decode((await we(e,u.hash)).content):"",b=8+n*2,R=i.a??"Temporary merge branch 1",E=i.b??"Temporary merge branch 2",k=wr(p,w,g,{a:`${R}:${l}`,o:i.o,b:`${E}:${d}`,markerSize:b}),x=await Ie(e,"blob",nn.encode(k));r.push({path:l,mode:h.mode,hash:x,stage:0,stat:He()}),r.push({path:d,mode:m.mode,hash:x,stage:0,stat:He()});continue}else if(h){r.push({...h,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=Nr.decode((await we(e,c.hash)).content),d=Nr.decode((await we(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,h=u?Nr.decode((await we(e,u.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=m?`${p}:${a.oursOrigPath??a.path}`:p,b=m?`${g}:${a.theirsOrigPath??a.path}`:g,R=wr(l,h,d,{a:w,o:i.o,b,markerSize:i.markerSize}),E=await Ie(e,"blob",nn.encode(R));r.push({path:a.path,mode:c.mode,hash:E,stage:0,stat:He()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>ve(a.path,c.path)),Fe(e,r)}async function wa(e,t){let n=t.map(ma);if(n.length===0)return Ie(e,"blob",nn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
252
267
  `):`${n.join(`
253
268
  `)}
254
- `;return Ie(e,"blob",tn.encode(s))}function Oe(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:ve()}}function la(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 Rs(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}
269
+ `;return Ie(e,"blob",nn.encode(s))}function Oe(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:He()}}function pa(e,t){let n=e.get(t);return n||(n={path:t,stages:[null,null,null],pathnames:[t,t,t],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},e.set(t,n)),n}function ks(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
255
270
  ${e.join(" ")}
256
271
  Merge with strategy ort failed.
257
272
  `;let c=e.map(l=>` ${l}`).join(`
@@ -266,7 +281,7 @@ ${i}
266
281
  ${a}
267
282
  Aborting
268
283
  fatal: ${n} failed
269
- `}function al(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
284
+ `}function wl(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
270
285
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
271
286
  ${i}
272
287
  Please commit your changes or stash them before you ${n}.
@@ -276,36 +291,36 @@ ${i}
276
291
  Please move or remove them before you ${n}.
277
292
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
278
293
  ${s}
279
- `}async function Sn(e,t,n,r){let o=await z(e),s=await de(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let m=new Map(Ne(o).map(g=>[g.path,g])),p=[];for(let[g,w]of m){let b=s.get(g);(!b||b.hash!==w.hash)&&p.push(g)}for(let[g]of s)m.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await da(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Rs(g,w,b,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let m=await fr(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:fo,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!m.success){await da(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),b=m.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),E;return w.length>0&&b.length>0?E=al(w,b,p,g):b.length>0?E=Rs(b,p,g,"untracked","worktree"):E=Rs(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:E,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let m=await fr(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:lo,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!m.success){await da(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(R=>R.error==="WOULD_OVERWRITE"||R.error==="NOT_UPTODATE_FILE").map(R=>R.path).sort(),b=m.errors.filter(R=>R.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||R.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(R=>R.path).sort(),E=[];w.length>0&&E.push(Rs(w,p,g,"local","worktree")),b.length>0&&E.push(Rs(b,p,g,"untracked","worktree"));let k;return E.length>1?k=al(w,b,p,g):k=E[0]??"",{ok:!1,stdout:"",stderr:k,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await je(e,m.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let m=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}m.push(p)}a=m}let c=new Set(a.map(m=>m.path));for(let m of s.keys())i.has(m)||c.add(m);let f=o.entries.filter(m=>!c.has(m.path)),l=[...a,...f];l.sort((m,p)=>Te(m.path,p.path)||m.stage-p.stage);let d={version:2,entries:l};await ae(e,d);let u=l.filter(m=>m.stage===0),h=await _e(e,u);return{ok:!0,finalIndex:d,mergedTreeHash:h}}async function da(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=v(e.workTree,r.path);await e.fs.exists(o)||await lt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();Ke();ge();De();Jt();function ll(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[K.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:S().describe("Abort the current cherry-pick operation"),continue:S().describe("Continue the cherry-pick after conflict resolution"),skip:S().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":S().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:Y.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:S().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(fe(L))return{stdout:"",stderr:L.message??"",exitCode:1};let G=await yp(s,r.env);return G.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),G}if(n.continue){let L=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(fe(L))return{stdout:"",stderr:L.message??"",exitCode:1};let G=await Ep(s,r.env);if(G.exitCode===0){let B=await X(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:B,hadConflicts:!1})}return G}if(n.skip)return bp(s,r.env);let i=n.commit;if(!i)return I("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Ge(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Je(s);if(M(d))return d;let u=await z(s);if(n.noCommit){let L=u.entries.filter(G=>G.stage>0);if(L.length>0){let F=L.slice(0,10).map(V=>`${V.path}: unmerged (${V.hash})`).join(`
280
- `),ee=L.length>10?`
281
- ...`:"";return N(`${F}${ee}
294
+ `}async function Hn(e,t,n,r){let o=await V(e),s=await le(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let m=new Map(Ge(o).map(g=>[g.path,g])),p=[];for(let[g,w]of m){let b=s.get(g);(!b||b.hash!==w.hash)&&p.push(g)}for(let[g]of s)m.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await ga(e,o,s);let w=r.operationName??"merge",b=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ks(g,w,b,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let m=await fr(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:ao,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!m.success){await ga(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(E=>E.error==="WOULD_OVERWRITE"||E.error==="NOT_UPTODATE_FILE").map(E=>E.path).sort(),b=m.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),R;return w.length>0&&b.length>0?R=wl(w,b,p,g):b.length>0?R=ks(b,p,g,"untracked","worktree"):R=ks(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:R,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let m=await fr(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:co,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!m.success){await ga(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=m.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),b=m.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),R=[];w.length>0&&R.push(ks(w,p,g,"local","worktree")),b.length>0&&R.push(ks(b,p,g,"untracked","worktree"));let E;return R.length>1?E=wl(w,b,p,g):E=R[0]??"",{ok:!1,stdout:"",stderr:E,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await De(e,m.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let m=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}m.push(p)}a=m}let c=new Set(a.map(m=>m.path));for(let m of s.keys())i.has(m)||c.add(m);let f=o.entries.filter(m=>!c.has(m.path)),l=[...a,...f];l.sort((m,p)=>ve(m.path,p.path)||m.stage-p.stage);let d={version:2,entries:l};await ae(e,d);let u=l.filter(m=>m.stage===0),h=await Fe(e,u);return{ok:!0,finalIndex:d,mergedTreeHash:h}}async function ga(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=H(e.workTree,r.path);await e.fs.exists(o)||await dt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ie();Be();ge();Ae();Nt();function El(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:O().describe("Abort the current cherry-pick operation"),continue:O().describe("Continue the cherry-pick after conflict resolution"),skip:O().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":O().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:O().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let G=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(de(G))return{stdout:"",stderr:G.message??"",exitCode:1};let W=await Mp(s,r.env);return W.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),W}if(n.continue){let G=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(de(G))return{stdout:"",stderr:G.message??"",exitCode:1};let W=await jp(s,r.env);if(W.exitCode===0){let F=await Z(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:F,hadConflicts:!1})}return W}if(n.skip)return Dp(s,r.env);let i=n.commit;if(!i)return S("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(de(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Me(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let u=await V(s);if(n.noCommit){let G=u.entries.filter(W=>W.stage>0);if(G.length>0){let B=G.slice(0,10).map(z=>`${z.path}: unmerged (${z.hash})`).join(`
295
+ `),ee=G.length>10?`
296
+ ...`:"";return _(`${B}${ee}
282
297
  error: your index file is unmerged.
283
298
  fatal: cherry-pick failed
284
- `,128)}}else{let L=Pn(u,"Cherry-picking",`fatal: cherry-pick failed
285
- `);if(L)return L}let h=await j(s,d),p=!!n["record-origin"]?kp(l.message,f):l.message;if(s.workTree&&!n.noCommit){let L=await de(s,h.tree);if(Wn(u,L))return N(`error: your local changes would be overwritten by cherry-pick.
299
+ `,128)}}else{let G=Sn(u,"Cherry-picking",`fatal: cherry-pick failed
300
+ `);if(G)return G}let h=await j(s,d),p=!!n["record-origin"]?Lp(l.message,f):l.message;if(s.workTree&&!n.noCommit){let G=await le(s,h.tree);if(lr(u,G))return _(`error: your local changes would be overwritten by cherry-pick.
286
301
  hint: commit your changes or stash them to proceed.
287
302
  fatal: cherry-pick failed
288
- `,128)}if(l.parents.length>1){if(!n.mainline)return N(`error: commit ${f} is a merge but no -m option was given.
303
+ `,128)}if(l.parents.length>1){if(!n.mainline)return _(`error: commit ${f} is a merge but no -m option was given.
289
304
  fatal: cherry-pick failed
290
- `,128);let L=n.mainline-1;if(L<0||L>=l.parents.length)return N(`error: commit ${f} does not have parent ${n.mainline}
305
+ `,128);let G=n.mainline-1;if(G<0||G>=l.parents.length)return _(`error: commit ${f} does not have parent ${n.mainline}
291
306
  fatal: cherry-pick failed
292
- `,128)}else if(n.mainline)return N(`error: mainline was specified but commit is not a merge.
307
+ `,128)}else if(n.mainline)return _(`error: mainline was specified but commit is not a merge.
293
308
  fatal: cherry-pick failed
294
- `,128);let g;if(l.parents.length===0)g=await _e(s,[]);else{let L=l.parents.length>1?n.mainline-1:0,G=l.parents[L];if(!G)throw new Error("unreachable: parent must exist");g=(await j(s,G)).tree}let w=Z(f),b=ue(l.message),E=await xe(s,"merge.conflictstyle")??"merge",k={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:E},R=await qt(s,g,h.tree,l.tree,k,t?.mergeDriver);if(R.conflicts.length===0&&R.resultTree===h.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p);let L=R.messages.length>0?`${R.messages.join(`
309
+ `,128);let g;if(l.parents.length===0)g=await Fe(s,[]);else{let G=l.parents.length>1?n.mainline-1:0,W=l.parents[G];if(!W)throw new Error("unreachable: parent must exist");g=(await j(s,W)).tree}let w=X(f),b=ue(l.message),R=await ke(s,"merge.conflictstyle")??"merge",E={a:"HEAD",b:b?`${w} (${b})`:w,conflictStyle:R},k=await Kt(s,g,h.tree,l.tree,E,t?.mergeDriver);if(k.conflicts.length===0&&k.resultTree===h.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Le(s,"MERGE_MSG",p);let G=k.messages.length>0?`${k.messages.join(`
295
310
  `)}
296
- `:"",G=await ot(s,{fromCommit:!0});return{stdout:`${L}${G}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
311
+ `:"",W=await at(s,{fromCommit:!0});return{stdout:`${G}${W}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
297
312
  If you wish to commit it anyway, use:
298
313
 
299
314
  git commit --allow-empty
300
315
 
301
316
  Otherwise, please use 'git cherry-pick --skip'
302
- `,exitCode:1}}let x=await Sn(s,R,h.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!x.ok)return x;if(R.conflicts.length>0){let L=R.messages.join(`
303
- `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:L?`${L}
317
+ `,exitCode:1}}let x=await Hn(s,k,h.tree,{labels:E,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!x.ok)return x;if(k.conflicts.length>0){let G=k.messages.join(`
318
+ `);return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:G?`${G}
304
319
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
305
320
  hint: after resolving the conflicts, mark the corrected paths
306
321
  hint: with 'git add <paths>' or 'git rm <paths>'
307
322
  hint: Disable this message with "git config set advice.mergeConflict false"
308
- `,exitCode:1}:(await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",p),{stdout:L?`${L}
323
+ `,exitCode:1}:(await J(s,"CHERRY_PICK_HEAD",f),await J(s,"ORIG_HEAD",d),await Le(s,"MERGE_MSG",p),{stdout:G?`${G}
309
324
  `:"",stderr:`error: could not apply ${w}... ${ue(l.message)}
310
325
  hint: After resolving the conflicts, mark them with
311
326
  hint: "git add/rm <pathspec>", then run
@@ -314,58 +329,58 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
314
329
  hint: To abort and get back to the state before "git cherry-pick",
315
330
  hint: run "git cherry-pick --abort".
316
331
  hint: Disable this message with "git config set advice.mergeConflict false"
317
- `,exitCode:1})}let y=x.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let C=await tt(s,r.env);if(M(C))return C;let $=await yt(s,y,[d],l.author,C,p);await Ft(s),await St(s);let D=await Q(s),P=p.split(`
318
- `)[0]??"",T=D?.type==="symbolic"?D.target:"HEAD";await re(s,r.env,T,d,$,`cherry-pick: ${P}`,D?.type==="symbolic");let A=D?.type==="symbolic"?Pe(D.target):"detached HEAD",U=h.tree,_=await mn(s,U,y,l.author,C,!0),O=Lt(A,$,p),H=R.messages.length>0?`${R.messages.join(`
332
+ `,exitCode:1})}let y=x.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let P=await tt(s,r.env);if(M(P))return P;let C=await Ot(s,y,[d],l.author,P,p);await en(s),await _t(s);let A=await te(s),D=p.split(`
333
+ `)[0]??"",$=A?.type==="symbolic"?A.target:"HEAD";await re(s,r.env,$,d,C,`cherry-pick: ${D}`,A?.type==="symbolic");let v=A?.type==="symbolic"?Pe(A.target):"detached HEAD",N=h.tree,L=await vn(s,N,y,l.author,P,!0),I=Qt(v,C,p),T=k.messages.length>0?`${k.messages.join(`
319
334
  `)}
320
- `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:$,hadConflicts:!1}),{stdout:`${H}${O}
321
- ${_}`,stderr:"",exitCode:0}}})}async function bp(e,t){if(!await W(e,"CHERRY_PICK_HEAD"))return N(`error: no cherry-pick in progress
335
+ `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${T}${I}
336
+ ${L}`,stderr:"",exitCode:0}}})}async function Dp(e,t){if(!await U(e,"CHERRY_PICK_HEAD"))return _(`error: no cherry-pick in progress
322
337
  fatal: cherry-pick failed
323
- `,128);let r=await X(e);if(!r)return I("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Hr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
338
+ `,128);let r=await Z(e);if(!r)return S("unable to resolve HEAD");let o=await j(e,r),s=await V(e),i=await Ar(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
324
339
  fatal: cherry-pick failed
325
- `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Ft(e),{stdout:"",stderr:"",exitCode:0}}async function yp(e,t){return await W(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
340
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await en(e),{stdout:"",stderr:"",exitCode:0}}async function Mp(e,t){return await U(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
326
341
  fatal: cherry-pick failed
327
- `,128),operationName:"cherry-pick",clearState:Ft,origHeadAsTargetRev:!0}):await W(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
342
+ `,128),operationName:"cherry-pick",clearState:en,origHeadAsTargetRev:!0}):await U(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
328
343
  fatal: cherry-pick failed
329
- `,128),operationName:"cherry-pick",clearState:St,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
344
+ `,128),operationName:"cherry-pick",clearState:_t,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
330
345
  fatal: cherry-pick failed
331
- `,128)}async function Ep(e,t){let n=await W(e,"CHERRY_PICK_HEAD");if(!n)return N(`error: no cherry-pick or revert in progress
346
+ `,128)}async function jp(e,t){let n=await U(e,"CHERRY_PICK_HEAD");if(!n)return _(`error: no cherry-pick or revert in progress
332
347
  fatal: cherry-pick failed
333
- `,128);let r=await z(e),o=Pn(r,"Committing");if(o)return o;let s=await j(e,n),i=await $e(e,"MERGE_MSG");if(!i)return N(`Aborting commit due to empty commit message.
334
- `,1);let a=await $e(e,"SQUASH_MSG");if(a&&(i=a+i),i=Ot(i),!i)return N(`Aborting commit due to empty commit message.
335
- `,1);let c=Ne(r),f=await _e(e,c),l=await Je(e);if(M(l))return l;let u=(await j(e,l)).tree,h=await tt(e,t);if(M(h))return h;let m=Gt(i),p=await yt(e,f,[l],s.author,h,m);await Ft(e),await St(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await re(e,t,b,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let E=g?.type==="symbolic"?Pe(g.target):"detached HEAD",k=await mn(e,u,f,s.author,h,!0);return{stdout:`${Lt(E,p,i)}
336
- ${k}`,stderr:"",exitCode:0}}function kp(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
348
+ `,128);let r=await V(e),o=Sn(r,"Committing");if(o)return o;let s=await j(e,n),i=await $e(e,"MERGE_MSG");if(!i)return _(`Aborting commit due to empty commit message.
349
+ `,1);let a=await $e(e,"SQUASH_MSG");if(a&&(i=a+i),i=St(i),!i)return _(`Aborting commit due to empty commit message.
350
+ `,1);let c=Ge(r),f=await Fe(e,c),l=await Qe(e);if(M(l))return l;let u=(await j(e,l)).tree,h=await tt(e,t);if(M(h))return h;let m=It(i),p=await Ot(e,f,[l],s.author,h,m);await en(e),await _t(e);let g=await te(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await re(e,t,b,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let R=g?.type==="symbolic"?Pe(g.target):"detached HEAD",E=await vn(e,u,f,s.author,h,!0);return{stdout:`${Qt(R,p,i)}
351
+ ${E}`,stderr:"",exitCode:0}}function Lp(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
337
352
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
338
353
  ${n}
339
354
  `:`${r}
340
355
 
341
356
  ${n}
342
- `}se();Be();co();Ce();me();function dl(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[K.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:S().alias("f").describe("Required to actually remove files"),"dry-run":S().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:S().alias("d").describe("Also remove untracked directories"),removeIgnored:S().alias("x").describe("Remove ignored files as well"),onlyIgnored:S().alias("X").describe("Remove only ignored files"),exclude:Y.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,u=n.onlyIgnored;if(!f&&!c&&await xe(s,"clean.requireForce")!=="false")return I("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await z(s),m=new Set(h.entries.map(y=>y.path)),p=dt(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(y=>Ue(y,p)):null,b=n.exclude?[n.exclude]:[],E=await ul(s,a,"",{trackedPaths:m,removeDirs:l,removeIgnored:d,onlyIgnored:u,extraExcludes:b}),k;w?k=E.filter(y=>Ee(w,y.path)):k=E,k.sort((y,C)=>y.path<C.path?-1:y.path>C.path?1:0);let R=[];if(c)for(let y of k){let C=y.isDir?`Would remove ${y.path}/`:`Would remove ${y.path}`;R.push(C)}else for(let y of k){let C=v(a,y.path);y.isDir?(await r.fs.rm(C,{recursive:!0}),R.push(`Removing ${y.path}/`)):(await r.fs.rm(C),R.push(`Removing ${y.path}`))}return{stdout:R.length>0?`${R.join(`
357
+ `}se();Ue();io();Ce();me();function kl(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:O().alias("f").describe("Required to actually remove files"),"dry-run":O().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:O().alias("d").describe("Also remove untracked directories"),removeIgnored:O().alias("x").describe("Remove ignored files as well"),onlyIgnored:O().alias("X").describe("Remove only ignored files"),exclude:Y.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,u=n.onlyIgnored;if(!f&&!c&&await ke(s,"clean.requireForce")!=="false")return S("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let h=await V(s),m=new Set(h.entries.map(y=>y.path)),p=ut(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(y=>_e(y,p)):null,b=n.exclude?[n.exclude]:[],R=await Rl(s,a,"",{trackedPaths:m,removeDirs:l,removeIgnored:d,onlyIgnored:u,extraExcludes:b}),E;w?E=R.filter(y=>Ee(w,y.path)):E=R,E.sort((y,P)=>y.path<P.path?-1:y.path>P.path?1:0);let k=[];if(c)for(let y of E){let P=y.isDir?`Would remove ${y.path}/`:`Would remove ${y.path}`;k.push(P)}else for(let y of E){let P=H(a,y.path);y.isDir?(await r.fs.rm(P,{recursive:!0}),k.push(`Removing ${y.path}/`)):(await r.fs.rm(P),k.push(`Removing ${y.path}`))}return{stdout:k.length>0?`${k.join(`
343
358
  `)}
344
- `:"",stderr:"",exitCode:0}}})}async function ul(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Ar(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=ar(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
345
- `),l=hs(f,"","<cli>");i={...i,dirPatterns:[l,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=v(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let u=i&&ln(i,l,!0)==="ignored",h=Rp(r.trackedPaths,l),m=()=>ul(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!h){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await m();!h&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(h){let p=await m();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await m(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let u=i&&ln(i,l,!1)==="ignored";r.onlyIgnored?u&&o.push({path:l,isDir:!1}):u&&s||o.push({path:l,isDir:!1})}}return o}function Rp(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}se();Be();Ce();ie();me();Ke();ge();Nn();ie();me();var Cs=2147483647;async function Fr(e){let t=v(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
346
- `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function xp(e,t){let n=v(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
359
+ `:"",stderr:"",exitCode:0}}})}async function Rl(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Hr(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);i=ar(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
360
+ `),l=ds(f,"","<cli>");i={...i,dirPatterns:[l,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=H(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let u=i&&dn(i,l,!0)==="ignored",h=Gp(r.trackedPaths,l),m=()=>Rl(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!h){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await m();!h&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(h){let p=await m();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await m(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let u=i&&dn(i,l,!1)==="ignored";r.onlyIgnored?u&&o.push({path:l,isDir:!1}):u&&s||o.push({path:l,isDir:!1})}}return o}function Gp(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}se();Ue();Ce();ie();me();Be();ge();kn();ie();me();var ba=2147483647;async function jo(e){let t=H(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
361
+ `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function Np(e,t){let n=H(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
347
362
  `)+`
348
- `)}async function Go(e){return(await Fr(e)).size>0}async function _r(e,t,n){let r=n??await Fr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await xp(e,r)}async function hl(e,t,n,r){if(n>=Cs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Zt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await j(e,f)}catch{continue}for(let u of d.parents)!o.has(u)&&await Zt(e,u)&&(o.set(u,l+1),s.push({hash:u,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}Be();Nn();pt();ie();var Fo=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]),Cp=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]),No=64,Pp=4,ha=4096,ml=65536,$p=127;function Op(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=Ip(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let h=0;for(let m=1;m<=16;m++)h=(h<<8|e[u+m])^Fo[h>>>23];if(h=h>>>0,h===a)i[i.length-1].ptr=u+16;else{a=h;let m=h&o;i.push({ptr:u+16,val:h}),s[m]++}}let c=new Map;for(let u of i){let h=u.val&o,m=c.get(h);m||(m=[],c.set(h,m)),m.push(u)}for(let[u,h]of c){if(h.length<=No)continue;let m=[],p=h.length/No;for(let g=0;g<No;g++)m.push(h[Math.floor(g*p)]);c.set(u,m),s[u]=No}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let h=c.get(u);if(h){for(let m of h)l.push(m);d+=h.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function Sp(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=gl(i,a,r),a=gl(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])^Fo[f>>>23],l++;f=f>>>0;let u=d,h=0,m=0;for(;u<o;){if(m<ha){f^=Cp[t[u-16]],f=((f<<8|t[u])^Fo[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 E=e.entries[b];if(E.val!==f)continue;let k=E.ptr,R=s.byteLength-k,x=o-u;if(R>x&&(R=x),R<=m)break;let y=0;for(;y<R&&s[k+y]===t[u+y];)y++;if(y>m&&(m=y,h=k,m>=ha))break}}if(m<Pp)c(2),l===0&&a++,i[a++]=t[u++],l++,l===$p&&(i[a-l-1]=l,l=0),m=0;else{if(l>0){for(;h>0&&s[h-1]===t[u-1];)if(m++,h--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=m>ml?m-ml:0;m-=p,c(8);let g=a++,w=128;if(h&255&&(i[a++]=h&255,w|=1),h&65280&&(i[a++]=h>>>8&255,w|=2),h&16711680&&(i[a++]=h>>>16&255,w|=4),h&4278190080&&(i[a++]=h>>>24&255,w|=8),m&255&&(i[a++]=m&255,w|=16),m&65280&&(i[a++]=m>>>8&255,w|=32),i[g]=w,u+=m,h+=m,m=p,h>4294967295&&(m=0),m<ha){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[u+b])^Fo[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 pl={blob:0,tree:1,commit:2,tag:3};function _o(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=pl[f.type]??99,u=pl[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},u=null,h=null,m=Math.max(0,f-n);for(let p=f-1;p>=m;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let E=a[p-m]??null;if(!E)continue;let k=u?u.byteLength:l.content.byteLength/2|0;if(k<16)continue;let R=Sp(E,l.content,k);R&&(!u||R.byteLength<u.byteLength)&&(u=R,h=g.hash)}if(u&&h){d.delta=u,d.deltaBase=h;let p=s.get(h);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(Op(l.content)),c.push(l.hash)}return i}function Ip(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function gl(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}Sr();ge();ie();wn();Tr();so();async function Ur(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await Ps(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let u of d.parents)i.has(u)||a.push(u)}catch{}let c=[],f=new Set;for(let l of a)await $s(e,l,i,f,c,r);return{count:c.length,objects:Tp(c)}}async function*Tp(e){for(let t of e)yield t}async function Br(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function Ps(e,t,n,r){if(n.has(t))return;n.add(t);let o=await vp(e,t);if(o)switch(o.type){case"commit":{let s=on(o.content);if(await Ps(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await Ps(e,i,n,r);break}case"tree":{let s=Rn(o.content);for(let i of s.entries)await Ps(e,i.hash,n,r);break}case"tag":{let s=Xt(o.content);await Ps(e,s.object,n,r);break}case"blob":break}}async function $s(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await ye(e,t);switch(o.push({hash:t,type:i.type,content:i.content}),i.type){case"commit":{let a=on(i.content);if(await $s(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await $s(e,c,n,r,o,s);break}case"tree":{let a=Rn(i.content);for(let c of a.entries)await $s(e,c.hash,n,r,o,s);break}case"tag":{let a=Xt(i.content);await $s(e,a.object,n,r,o,s);break}case"blob":break}}async function vp(e,t){try{return await ye(e,t)}catch(n){if(n instanceof Error&&n.message===`object ${t} not found`)return null;throw n}}var Ap=new TextEncoder,tr=new TextDecoder,wl=65520,Hp=new Uint8Array([48,48,48,48]),XR=new Uint8Array([48,48,48,49]),ZR=new Uint8Array([48,48,48,50]);function In(e){let t=typeof e=="string"?Ap.encode(e):e,n=4+t.byteLength;if(n>wl)throw new Error(`pkt-line too long: ${n} bytes (max ${wl})`);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 ma(){return Hp.slice()}function Uo(...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 br(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=tr.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o===1){t.push({type:"delim"}),n+=4;continue}if(o===2){t.push({type:"response-end"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Os(e){if(e.type!=="data")return"";let t=tr.decode(e.data);return t.endsWith(`
349
- `)?t.slice(0,-1):t}var Dp=65536;async function*pa(e){let t=e.getReader(),n=new Uint8Array(Dp),r=0;try{for(;;){for(;!(r<4);){let c=tr.decode(n.subarray(0,4)),f=parseInt(c,16);if(Number.isNaN(f))throw new Error(`Invalid pkt-line length: ${c}`);if(f===0){yield{type:"flush"},o(4);continue}if(f===1){yield{type:"delim"},o(4);continue}if(f===2){yield{type:"response-end"},o(4);continue}if(f<4)throw new Error(`Invalid pkt-line length: ${f}`);if(r<f)break;yield{type:"data",data:n.slice(4,f)},o(f)}let{done:s,value:i}=await t.read();if(s)break;if(i.byteLength===0)continue;let a=r+i.byteLength;if(a>n.byteLength){let c=n.byteLength;for(;c<a;)c*=2;let f=new Uint8Array(c);f.set(n.subarray(0,r)),n=f}n.set(i,r),r+=i.byteLength}for(;!(r<4);){let s=tr.decode(n.subarray(0,4)),i=parseInt(s,16);if(Number.isNaN(i))throw new Error(`Invalid pkt-line length: ${s}`);if(i===0){yield{type:"flush"},o(4);continue}if(i===1){yield{type:"delim"},o(4);continue}if(i===2){yield{type:"response-end"},o(4);continue}if(i<4)throw new Error(`Invalid pkt-line length: ${i}`);if(r<i)throw new Error(`Truncated pkt-line: need ${i} bytes, have ${r}`);yield{type:"data",data:n.slice(4,i)},o(i)}if(r>0)throw new Error("Truncated pkt-line header")}finally{t.releaseLock()}function o(s){n.copyWithin(0,s,r),r-=s}}var bl=1,yl=2,El=3;async function ga(e,t){let n=[],r=[],o=0,s=!1;for await(let c of e){if(c.type!=="data"){s||n.push(c);continue}if(c.data.byteLength===0){s||n.push(c);continue}let f=c.data[0];if(!s)if(f>=1&&f<=3)s=!0;else{n.push(c);continue}let l=c.data.subarray(1);switch(f){case bl:r.push(l),o+=l.byteLength;break;case yl:t?.(tr.decode(l));break;case El:throw new Error(`Remote error: ${tr.decode(l)}`);default:break}}let i=new Uint8Array(o),a=0;for(let c of r)i.set(c,a),a+=c.byteLength;return{packData:i,preambleLines:n}}function wa(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case bl:t.push(f),o+=f.byteLength;break;case yl:n.push(tr.decode(f));break;case El:r.push(tr.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}pt();function ba(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ya(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ba(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=br(c);return Mp(f,t)}function Mp(e,t){let n=0,r=e[n];r?.type==="data"&&Os(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;if(a.type!=="data")continue;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let u=l.slice(0,d),h=l.slice(d+1);if(!(u===ne&&h==="capabilities^{}")){if(h.endsWith("^{}")){let m=h.slice(0,-3),p=o.find(g=>g.name===m);p&&(p.peeledHash=u);continue}o.push({name:h,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var jp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function kl(e,t,n,r,o,s=globalThis.fetch,i,a){if(t.length===0)throw new Error("fetchPack requires at least one want");let c=Cl(r,jp),f=[];f.push(In(`want ${t[0]} ${c.join(" ")}
350
- `));for(let p=1;p<t.length;p++)f.push(In(`want ${t[p]}
351
- `));if(i?.existingShallows)for(let p of i.existingShallows)f.push(In(`shallow ${p}
352
- `));i?.depth!==void 0&&f.push(In(`deepen ${i.depth}
353
- `)),f.push(ma());for(let p of n)f.push(In(`have ${p}
354
- `));f.push(In(`done
355
- `));let l=Uo(...f),d=e.replace(/\/+$/,""),u=await s(`${d}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ba(o),"User-Agent":"just-git/1.0"},body:l});if(!u.ok)throw new Error(`HTTP ${u.status} fetching pack from ${d}`);let h=c.includes("side-band-64k");if(h&&u.body)return Lp(u.body,a);let m=new Uint8Array(await u.arrayBuffer());return Gp(m,h,a)}async function Lp(e,t){let n=pa(e),{packData:r,preambleLines:o}=await ga(n,t),s=[],i=[],a=[];for(let c of o){if(c.type!=="data")continue;let f=Os(c);f.startsWith("shallow ")?i.push(f.slice(8)):f.startsWith("unshallow ")?a.push(f.slice(10)):(f.startsWith("ACK ")||f==="NAK")&&s.push(f)}return{packData:r,acks:s,shallowLines:i,unshallowLines:a}}function Gp(e,t,n){let r=br(e),o=[],s=[],i=[],a=0;for(let u=0;u<r.length;u++){let h=r[u];if(!h||h.type==="flush"){a=u+1;continue}if(h.type!=="data")continue;let m=Os(h);if(m.startsWith("shallow "))s.push(m.slice(8)),a=u+1;else if(m.startsWith("unshallow "))i.push(m.slice(10)),a=u+1;else if(m.startsWith("ACK ")||m==="NAK")o.push(m),a=u+1;else{a=u;break}}let c=r.slice(a);if(t){let{packData:u,progress:h,errors:m}=wa(c);if(m.length>0)throw new Error(`Remote error: ${m.join("")}`);if(n)for(let p of h)n(p);return{packData:u,acks:o,shallowLines:s,unshallowLines:i}}let f=0;for(let u of c)u.type==="data"&&(f+=u.data.byteLength);let l=new Uint8Array(f),d=0;for(let u of c)u.type==="data"&&(l.set(u.data,d),d+=u.data.byteLength);return{packData:l,acks:o,shallowLines:s,unshallowLines:i}}var Np=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Rl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("pushPack requires at least one command");let a=Cl(r,Np),c=[],[f,...l]=t;if(!f)throw new Error("pushPack requires at least one command");c.push(In(`${f.oldHash} ${f.newHash} ${f.refName}\0${a.join(" ")}
356
- `));for(let g of l)c.push(In(`${g.oldHash} ${g.newHash} ${g.refName}
357
- `));c.push(ma());let d;if(n&&n.byteLength>0){let g=Uo(...c);d=new Uint8Array(g.byteLength+n.byteLength),d.set(g,0),d.set(n,g.byteLength)}else d=Uo(...c);let u=e.replace(/\/+$/,""),h=await s(`${u}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ba(o),"User-Agent":"just-git/1.0"},body:d});if(!h.ok)throw new Error(`HTTP ${h.status} pushing to ${u}`);if(!a.includes("report-status"))return{unpackOk:!0,refResults:[]};let m=a.includes("side-band-64k");if(m&&h.body)return Fp(h.body,i);let p=new Uint8Array(await h.arrayBuffer());return _p(p,m,i)}async function Fp(e,t){let n=pa(e),{packData:r}=await ga(n,t),o=br(r);return xl(o)}function _p(e,t,n){let r;if(t){let o=br(e),{packData:s,progress:i,errors:a}=wa(o);if(a.length>0)throw new Error(`Remote error: ${a.join("")}`);if(n)for(let c of i)n(c);r=br(s)}else r=br(e);return xl(r)}function xl(e){let t=!1,n,r=[];for(let o of e){if(o.type==="flush")break;let s=Os(o);if(s.startsWith("unpack "))t=s==="unpack ok",t||(n=s.slice(7));else if(s.startsWith("ok "))r.push({name:s.slice(3),ok:!0});else if(s.startsWith("ng ")){let i=s.slice(3),a=i.indexOf(" ");a!==-1?r.push({name:i.slice(0,a),ok:!1,error:i.slice(a+1)}):r.push({name:i,ok:!1})}}return{unpackOk:t,unpackError:n,refResults:r}}function Cl(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 Ss=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await we(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await W(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 hl(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 eo(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ne&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await Ea(this.local,n,r);s&&await eo(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ne,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await en(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},Is=class{constructor(t,n,r,o,s){this.local=t;this.url=n;this.auth=r;this.fetchFn=o;this.onProgress=s}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await ya(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 ya(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 kl(this.url,t,n,o,this.auth,this.fetchFn,r,this.onProgress);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await eo(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){let n=new Set,r=[];for(let h of t)if(h.oldHash&&h.oldHash!==ne&&h.newHash!==ne&&!h.ok&&!await en(this.local,h.oldHash,h.newHash)){let g=await Zt(this.local,h.oldHash)?"non-fast-forward":"fetch first";n.add(h.name),r.push({...h,ok:!1,error:g})}let o=t.filter(h=>!n.has(h.name));if(o.length===0)return{updates:r};let s=await this.ensurePushDiscovery(),i=o.map(h=>({oldHash:h.oldHash??ne,newHash:h.newHash,refName:h.name})),a=[],c=[],f=!1;for(let h of o)h.newHash!==ne&&(a.push(h.newHash),f=!0),h.oldHash&&h.oldHash!==ne&&c.push(h.oldHash);let l=null;f&&(l=await Ea(this.local,a,c)??null);let d=await Rl(this.url,i,l,s,this.auth,this.fetchFn,this.onProgress);return{updates:[...o.map(h=>{let m=d.refResults.find(w=>w.name===h.name),p=m?.ok??d.unpackOk,g=m?.error??(!p&&d.unpackError?`unpack failed: ${d.unpackError}`:void 0);return{...h,ok:p,error:g}}),...r]}}};async function Ea(e,t,n,r,o){let s=await Ur(e,t,n,r,o);if(s.count===0)return;let i=await Br(s),c=_o(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Js(c);return f}function Up(e){if(!Bo(e))return{url:e};try{let t=new URL(e);if(!t.username&&!t.password)return{url:e};let n={type:"basic",username:decodeURIComponent(t.username),password:decodeURIComponent(t.password)};return t.username="",t.password="",{url:t.href,embeddedAuth:n}}catch{return{url:e}}}function yr(e,t){let n=Up(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function Bp(e,t){let r=(await pe(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function Bo(e){return e.startsWith("http://")||e.startsWith("https://")}function Pl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function $l(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(Bo(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function 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 o=await e.credentialProvider(t);if(o)return o}let r=Wp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function Sl(e,t,n,r){let o=yr(t,e.credentialCache).url;if(Bo(o)){let s=$l(o,e.networkPolicy);if(s)throw new Error(s);let i=await Ol(e,o,n);return new Is(e,o,i,e.fetchFn,e.onProgress)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw Pl(o)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`):new Error(`'${o}' does not appear to be a git repository`);return new Ss(e,r)}async function Wr(e,t,n){let r=await Bp(e,t);if(!r)return null;let o=yr(r.url,e.credentialCache).url;if(Bo(o)){let i=$l(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await Ol(e,o,n):void 0;return{transport:new Is(e,o,a,e.fetchFn,e.onProgress),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await ir(e.fs,o);if(!s){if(Pl(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new Ss(e,s),config:{...r,url:o}}}De();et();function Il(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[K.string().name("repository").describe("Repository to clone"),K.string().name("directory").describe("Target directory").optional()],options:{bare:S().describe("Create a bare clone"),branch:Y.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Y.number().describe("Create a shallow clone with history truncated to N commits"),singleBranch:S().describe("Clone only the history of the specified or default branch"),noSingleBranch:S().describe("Clone all branches even with --depth"),noTags:S().describe("Don't clone any tags"),noCheckout:S().alias("n").describe("Don't create a checkout")},handler:async(n,r)=>{let o=n.repository;if(!o)return I("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=yr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Dt(r.cwd,o),a=await ir(r.fs,c)),!a)return I(`repository '${o}' does not exist`);let f=n.directory;if(!f){let A;s||o.includes("://")?A=c.split("/").pop()??c:A=Xr(c),A.endsWith(".git")&&(A=A.slice(0,-4)),f=A}let l=Dt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(fe(d))return N(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return I(`destination path '${f}' already exists and is not an empty directory.`)}catch{return I(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:u}=await to(r.fs,l,{bare:n.bare}),h=t?{...u,...t}:u,m=n.depth,p=n.singleBranch||m!==void 0&&!n.noSingleBranch,g=n.noTags||p,w=n.noCheckout,b=await pe(h),E;try{E=await Sl(h,c,r.env,a??void 0)}catch(A){let U=A instanceof Error?A.message:"";return U.startsWith("network")?I(U):I(`repository '${o}' does not exist`)}let k=await E.advertiseRefs();if(k.length===0)return b['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await ze(h,b),await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
363
+ `)}async function xl(e){return(await jo(e)).size>0}async function Fr(e,t,n){let r=n??await jo(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await Np(e,r)}async function Cl(e,t,n,r){if(n>=ba)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await wt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await j(e,f)}catch{continue}for(let u of d.parents)!o.has(u)&&await wt(e,u)&&(o.set(u,l+1),s.push({hash:u,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}Ue();kn();pt();ie();var Go=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]),Fp=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]),Lo=64,_p=4,ya=4096,Pl=65536,Up=127;function Bp(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=qp(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let h=0;for(let m=1;m<=16;m++)h=(h<<8|e[u+m])^Go[h>>>23];if(h=h>>>0,h===a)i[i.length-1].ptr=u+16;else{a=h;let m=h&o;i.push({ptr:u+16,val:h}),s[m]++}}let c=new Map;for(let u of i){let h=u.val&o,m=c.get(h);m||(m=[],c.set(h,m)),m.push(u)}for(let[u,h]of c){if(h.length<=Lo)continue;let m=[],p=h.length/Lo;for(let g=0;g<Lo;g++)m.push(h[Math.floor(g*p)]);c.set(u,m),s[u]=Lo}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let h=c.get(u);if(h){for(let m of h)l.push(m);d+=h.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function Wp(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=Ol(i,a,r),a=Ol(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])^Go[f>>>23],l++;f=f>>>0;let u=d,h=0,m=0;for(;u<o;){if(m<ya){f^=Fp[t[u-16]],f=((f<<8|t[u])^Go[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 R=e.entries[b];if(R.val!==f)continue;let E=R.ptr,k=s.byteLength-E,x=o-u;if(k>x&&(k=x),k<=m)break;let y=0;for(;y<k&&s[E+y]===t[u+y];)y++;if(y>m&&(m=y,h=E,m>=ya))break}}if(m<_p)c(2),l===0&&a++,i[a++]=t[u++],l++,l===Up&&(i[a-l-1]=l,l=0),m=0;else{if(l>0){for(;h>0&&s[h-1]===t[u-1];)if(m++,h--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=m>Pl?m-Pl:0;m-=p,c(8);let g=a++,w=128;if(h&255&&(i[a++]=h&255,w|=1),h&65280&&(i[a++]=h>>>8&255,w|=2),h&16711680&&(i[a++]=h>>>16&255,w|=4),h&4278190080&&(i[a++]=h>>>24&255,w|=8),m&255&&(i[a++]=m&255,w|=16),m&65280&&(i[a++]=m>>>8&255,w|=32),i[g]=w,u+=m,h+=m,m=p,h>4294967295&&(m=0),m<ya){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[u+b])^Go[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 $l={blob:0,tree:1,commit:2,tag:3};function No(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=$l[f.type]??99,u=$l[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},u=null,h=null,m=Math.max(0,f-n);for(let p=f-1;p>=m;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let R=a[p-m]??null;if(!R)continue;let E=u?u.byteLength:l.content.byteLength/2|0;if(E<16)continue;let k=Wp(R,l.content,E);k&&(!u||k.byteLength<u.byteLength)&&(u=k,h=g.hash)}if(u&&h){d.delta=u,d.deltaBase=h;let p=s.get(h);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(Bp(l.content)),c.push(l.hash)}return i}function qp(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 Ol(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}Sr();ge();ie();bn();Tr();no();async function _r(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await xs(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let u of d.parents)i.has(u)||a.push(u)}catch{}let c=[],f=new Set;for(let l of a)await Cs(e,l,i,f,c,r);return{count:c.length,objects:Kp(c)}}async function*Kp(e){for(let t of e)yield t}async function Ur(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function xs(e,t,n,r){if(n.has(t))return;n.add(t);let o=await zp(e,t);if(o)switch(o.type){case"commit":{let s=an(o.content);if(await xs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await xs(e,i,n,r);break}case"tree":{let s=xn(o.content);for(let i of s.entries)await xs(e,i.hash,n,r);break}case"tag":{let s=Zt(o.content);await xs(e,s.object,n,r);break}case"blob":break}}async function Cs(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await we(e,t);switch(o.push({hash:t,type:i.type,content:i.content}),i.type){case"commit":{let a=an(i.content);if(await Cs(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Cs(e,c,n,r,o,s);break}case"tree":{let a=xn(i.content);for(let c of a.entries)await Cs(e,c.hash,n,r,o,s);break}case"tag":{let a=Zt(i.content);await Cs(e,a.object,n,r,o,s);break}case"blob":break}}async function zp(e,t){try{return await we(e,t)}catch(n){if(n instanceof Error&&n.message===`object ${t} not found`)return null;throw n}}var Vp=new TextEncoder,nr=new TextDecoder,Sl=65520,Yp=new Uint8Array([48,48,48,48]),kx=new Uint8Array([48,48,48,49]),Rx=new Uint8Array([48,48,48,50]);function An(e){let t=typeof e=="string"?Vp.encode(e):e,n=4+t.byteLength;if(n>Sl)throw new Error(`pkt-line too long: ${n} bytes (max ${Sl})`);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 Ea(){return Yp.slice()}function Fo(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function br(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=nr.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o===1){t.push({type:"delim"}),n+=4;continue}if(o===2){t.push({type:"response-end"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Ps(e){if(e.type!=="data")return"";let t=nr.decode(e.data);return t.endsWith(`
364
+ `)?t.slice(0,-1):t}var Xp=65536;async function*ka(e){let t=e.getReader(),n=new Uint8Array(Xp),r=0;try{for(;;){for(;!(r<4);){let c=nr.decode(n.subarray(0,4)),f=parseInt(c,16);if(Number.isNaN(f))throw new Error(`Invalid pkt-line length: ${c}`);if(f===0){yield{type:"flush"},o(4);continue}if(f===1){yield{type:"delim"},o(4);continue}if(f===2){yield{type:"response-end"},o(4);continue}if(f<4)throw new Error(`Invalid pkt-line length: ${f}`);if(r<f)break;yield{type:"data",data:n.slice(4,f)},o(f)}let{done:s,value:i}=await t.read();if(s)break;if(i.byteLength===0)continue;let a=r+i.byteLength;if(a>n.byteLength){let c=n.byteLength;for(;c<a;)c*=2;let f=new Uint8Array(c);f.set(n.subarray(0,r)),n=f}n.set(i,r),r+=i.byteLength}for(;!(r<4);){let s=nr.decode(n.subarray(0,4)),i=parseInt(s,16);if(Number.isNaN(i))throw new Error(`Invalid pkt-line length: ${s}`);if(i===0){yield{type:"flush"},o(4);continue}if(i===1){yield{type:"delim"},o(4);continue}if(i===2){yield{type:"response-end"},o(4);continue}if(i<4)throw new Error(`Invalid pkt-line length: ${i}`);if(r<i)throw new Error(`Truncated pkt-line: need ${i} bytes, have ${r}`);yield{type:"data",data:n.slice(4,i)},o(i)}if(r>0)throw new Error("Truncated pkt-line header")}finally{t.releaseLock()}function o(s){n.copyWithin(0,s,r),r-=s}}var Il=1,Tl=2,vl=3;async function Ra(e,t){let n=[],r=[],o=0,s=!1;for await(let c of e){if(c.type!=="data"){s||n.push(c);continue}if(c.data.byteLength===0){s||n.push(c);continue}let f=c.data[0];if(!s)if(f>=1&&f<=3)s=!0;else{n.push(c);continue}let l=c.data.subarray(1);switch(f){case Il:r.push(l),o+=l.byteLength;break;case Tl:t?.(nr.decode(l));break;case vl:throw new Error(`Remote error: ${nr.decode(l)}`);default:break}}let i=new Uint8Array(o),a=0;for(let c of r)i.set(c,a),a+=c.byteLength;return{packData:i,preambleLines:n}}function xa(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case Il:t.push(f),o+=f.byteLength;break;case Tl:n.push(nr.decode(f));break;case vl:r.push(nr.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}pt();function Ca(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function Pa(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...Ca(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=br(c);return Zp(f,t)}function Zp(e,t){let n=0,r=e[n];r?.type==="data"&&Ps(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;if(a.type!=="data")continue;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let u=l.slice(0,d),h=l.slice(d+1);if(!(u===ne&&h==="capabilities^{}")){if(h.endsWith("^{}")){let m=h.slice(0,-3),p=o.find(g=>g.name===m);p&&(p.peeledHash=u);continue}o.push({name:h,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var Jp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function Hl(e,t,n,r,o,s=globalThis.fetch,i,a){if(t.length===0)throw new Error("fetchPack requires at least one want");let c=Ml(r,Jp),f=[];f.push(An(`want ${t[0]} ${c.join(" ")}
365
+ `));for(let p=1;p<t.length;p++)f.push(An(`want ${t[p]}
366
+ `));if(i?.existingShallows)for(let p of i.existingShallows)f.push(An(`shallow ${p}
367
+ `));i?.depth!==void 0&&f.push(An(`deepen ${i.depth}
368
+ `)),f.push(Ea());for(let p of n)f.push(An(`have ${p}
369
+ `));f.push(An(`done
370
+ `));let l=Fo(...f),d=e.replace(/\/+$/,""),u=await s(`${d}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...Ca(o),"User-Agent":"just-git/1.0"},body:l});if(!u.ok)throw new Error(`HTTP ${u.status} fetching pack from ${d}`);let h=c.includes("side-band-64k");if(h&&u.body)return Qp(u.body,a);let m=new Uint8Array(await u.arrayBuffer());return eg(m,h,a)}async function Qp(e,t){let n=ka(e),{packData:r,preambleLines:o}=await Ra(n,t),s=[],i=[],a=[];for(let c of o){if(c.type!=="data")continue;let f=Ps(c);f.startsWith("shallow ")?i.push(f.slice(8)):f.startsWith("unshallow ")?a.push(f.slice(10)):(f.startsWith("ACK ")||f==="NAK")&&s.push(f)}return{packData:r,acks:s,shallowLines:i,unshallowLines:a}}function eg(e,t,n){let r=br(e),o=[],s=[],i=[],a=0;for(let u=0;u<r.length;u++){let h=r[u];if(!h||h.type==="flush"){a=u+1;continue}if(h.type!=="data")continue;let m=Ps(h);if(m.startsWith("shallow "))s.push(m.slice(8)),a=u+1;else if(m.startsWith("unshallow "))i.push(m.slice(10)),a=u+1;else if(m.startsWith("ACK ")||m==="NAK")o.push(m),a=u+1;else{a=u;break}}let c=r.slice(a);if(t){let{packData:u,progress:h,errors:m}=xa(c);if(m.length>0)throw new Error(`Remote error: ${m.join("")}`);if(n)for(let p of h)n(p);return{packData:u,acks:o,shallowLines:s,unshallowLines:i}}let f=0;for(let u of c)u.type==="data"&&(f+=u.data.byteLength);let l=new Uint8Array(f),d=0;for(let u of c)u.type==="data"&&(l.set(u.data,d),d+=u.data.byteLength);return{packData:l,acks:o,shallowLines:s,unshallowLines:i}}var tg=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Al(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("pushPack requires at least one command");let a=Ml(r,tg),c=[],[f,...l]=t;if(!f)throw new Error("pushPack requires at least one command");c.push(An(`${f.oldHash} ${f.newHash} ${f.refName}\0${a.join(" ")}
371
+ `));for(let g of l)c.push(An(`${g.oldHash} ${g.newHash} ${g.refName}
372
+ `));c.push(Ea());let d;if(n&&n.byteLength>0){let g=Fo(...c);d=new Uint8Array(g.byteLength+n.byteLength),d.set(g,0),d.set(n,g.byteLength)}else d=Fo(...c);let u=e.replace(/\/+$/,""),h=await s(`${u}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...Ca(o),"User-Agent":"just-git/1.0"},body:d});if(!h.ok)throw new Error(`HTTP ${h.status} pushing to ${u}`);if(!a.includes("report-status"))return{unpackOk:!0,refResults:[]};let m=a.includes("side-band-64k");if(m&&h.body)return ng(h.body,i);let p=new Uint8Array(await h.arrayBuffer());return rg(p,m,i)}async function ng(e,t){let n=ka(e),{packData:r}=await Ra(n,t),o=br(r);return Dl(o)}function rg(e,t,n){let r;if(t){let o=br(e),{packData:s,progress:i,errors:a}=xa(o);if(a.length>0)throw new Error(`Remote error: ${a.join("")}`);if(n)for(let c of i)n(c);r=br(s)}else r=br(e);return Dl(r)}function Dl(e){let t=!1,n,r=[];for(let o of e){if(o.type==="flush")break;let s=Ps(o);if(s.startsWith("unpack "))t=s==="unpack ok",t||(n=s.slice(7));else if(s.startsWith("ok "))r.push({name:s.slice(3),ok:!0});else if(s.startsWith("ng ")){let i=s.slice(3),a=i.indexOf(" ");a!==-1?r.push({name:i.slice(0,a),ok:!1,error:i.slice(a+1)}):r.push({name:i,ok:!1})}}return{unpackOk:t,unpackError:n,refResults:r}}function Ml(e,t){let n=new Set(e.map(o=>o.split("=",1)[0]??o)),r=[];for(let o of t)n.has(o)&&r.push(o);return r.push("agent=just-git/1.0"),r}var $s=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await ye(this.remote),n=[];for(let s of t){if(s.name.startsWith("refs/tags/"))try{if((await we(this.remote,s.hash)).type==="tag"){n.push({name:s.name,hash:s.hash,peeledHash:await Te(this.remote,s.hash)});continue}}catch{}n.push({name:s.name,hash:s.hash})}let r=await U(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await te(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 Cl(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await $a(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Js(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ne&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await $a(this.local,n,r);s&&await Js(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ne,a=s.oldHash??null;if(Ll(s)&&!s.ok){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}if(!i&&!s.ok&&s.oldHash&&!await tn(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},Os=class{constructor(t,n,r,o,s){this.local=t;this.url=n;this.auth=r;this.fetchFn=o;this.onProgress=s}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await Pa(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 Pa(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 Hl(this.url,t,n,o,this.auth,this.fetchFn,r,this.onProgress);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Js(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){let n=new Set,r=[];for(let h of t){if(Ll(h)&&!h.ok){n.add(h.name),r.push({...h,ok:!1,error:"non-fast-forward"});continue}if(jl(h)&&!h.ok&&!await tn(this.local,h.oldHash,h.newHash)){let g=await wt(this.local,h.oldHash)?"non-fast-forward":"fetch first";n.add(h.name),r.push({...h,ok:!1,error:g})}}let o=t.filter(h=>!n.has(h.name));if(o.length===0)return{updates:r};let s=await this.ensurePushDiscovery(),i=o.map(h=>({oldHash:h.oldHash??ne,newHash:h.newHash,refName:h.name})),a=[],c=[],f=!1;for(let h of o)h.newHash!==ne&&(a.push(h.newHash),f=!0),h.oldHash&&h.oldHash!==ne&&c.push(h.oldHash);let l=null;f&&(l=await $a(this.local,a,c)??null);let d=await Al(this.url,i,l,s,this.auth,this.fetchFn,this.onProgress);return{updates:[...o.map(h=>{let m=d.refResults.find(w=>w.name===h.name),p=m?.ok??d.unpackOk,g=m?.error??(!p&&d.unpackError?`unpack failed: ${d.unpackError}`:void 0);return{...h,ok:p,error:g}}),...r]}}};function jl(e){return!!e.oldHash&&e.oldHash!==ne&&e.newHash!==ne}function Ll(e){return e.name.startsWith("refs/tags/")&&jl(e)}async function $a(e,t,n,r,o){let s=await _r(e,t,n,r,o);if(s.count===0)return;let i=await Ur(s),c=No(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Xs(c);return f}function sg(e){if(!_o(e))return{url:e};try{let t=new URL(e);if(!t.username&&!t.password)return{url:e};let n={type:"basic",username:decodeURIComponent(t.username),password:decodeURIComponent(t.password)};return t.username="",t.password="",{url:t.href,embeddedAuth:n}}catch{return{url:e}}}function yr(e,t){let n=sg(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function og(e,t){let r=(await pe(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function _o(e){return e.startsWith("http://")||e.startsWith("https://")}function Gl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function Nl(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(_o(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function ig(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 Fl(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=ig(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function _l(e,t,n,r){let o=yr(t,e.credentialCache).url;if(_o(o)){let s=Nl(o,e.networkPolicy);if(s)throw new Error(s);let i=await Fl(e,o,n);return new Os(e,o,i,e.fetchFn,e.onProgress)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw Gl(o)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`):new Error(`'${o}' does not appear to be a git repository`);return new $s(e,r)}async function Uo(e,t,n){let r=await og(e,t);if(!r)return null;let o=yr(r.url,e.credentialCache).url;if(_o(o)){let i=Nl(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await Fl(e,o,n):void 0;return{transport:new Os(e,o,a,e.fetchFn,e.onProgress),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await Rn(e.fs,o);if(!s){if(Gl(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new $s(e,s),config:{...r,url:o}}}Ae();Je();function Ul(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:O().describe("Create a bare clone"),branch:Y.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:Y.number().describe("Create a shallow clone with history truncated to N commits"),singleBranch:O().describe("Clone only the history of the specified or default branch"),noSingleBranch:O().describe("Clone all branches even with --depth"),noTags:O().describe("Don't clone any tags"),noCheckout:O().alias("n").describe("Don't create a checkout")},handler:async(n,r)=>{let o=n.repository;if(!o)return S("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),i=n.branch,a=null,c=o;if(s)c=yr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=Mt(r.cwd,o),a=await Rn(r.fs,c)),!a)return S(`repository '${o}' does not exist`);let f=n.directory;if(!f){let v;s||o.includes("://")?v=c.split("/").pop()??c:v=Vr(c),v.endsWith(".git")&&(v=v.slice(0,-4)),f=v}let l=Mt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(de(d))return _(d.message??"");if(await r.fs.exists(l))try{if((await r.fs.readdir(l)).length>0)return S(`destination path '${f}' already exists and is not an empty directory.`)}catch{return S(`destination path '${f}' already exists and is not an empty directory.`)}await r.fs.mkdir(l,{recursive:!0});let{ctx:u}=await Qs(r.fs,l,{bare:n.bare}),h=t?{...u,...t}:u,m=n.depth,p=n.singleBranch||m!==void 0&&!n.noSingleBranch,g=n.noTags||p,w=n.noCheckout,b=await pe(h),R;try{R=await _l(h,c,r.env,a??void 0)}catch(v){let N=v instanceof Error?v.message:"";return N.startsWith("network")?S(N):S(`repository '${o}' does not exist`)}let E=await R.advertiseRefs();if(E.length===0)return b['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await ze(h,b),await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
358
373
  warning: You appear to have cloned an empty repository.
359
- `,exitCode:0};let R=null,x=null;if(i){let A=k.find(U=>U.name===`refs/heads/${i}`);if(!A)return I(`Remote branch '${i}' not found in upstream origin`);R=i,x=A.hash}else{let A=E.headTarget;if(A?.startsWith("refs/heads/")&&k.some(U=>U.name===A)&&(R=A.slice(11),x=k.find(U=>U.name===A)?.hash??null),!R){let U=k.find(_=>_.name==="HEAD");if(U){let _=k.find(O=>O.name.startsWith("refs/heads/")&&O.hash===U.hash);_&&(R=_.name.slice(11),x=_.hash)}}if(!R){let U=k.find(_=>_.name.startsWith("refs/heads/"));U&&(R=U.name.slice(11),x=U.hash)}}let y={url:c,fetch:p&&R?`+refs/heads/${R}:refs/remotes/origin/${R}`:"+refs/heads/*:refs/remotes/origin/*"};g&&(y.tagOpt="--no-tags"),b['remote "origin"']=y;let C=[],$=new Set;for(let A of k)if(A.name!=="HEAD"){if(A.name.startsWith("refs/heads/")){if(p&&R&&A.name!==`refs/heads/${R}`)continue}else if(A.name.startsWith("refs/tags/")){if(g)continue}else continue;$.has(A.hash)||($.add(A.hash),C.push(A.hash))}let D=m!==void 0&&m>0?{depth:m}:void 0;if(C.length>0){let A=await E.fetch(C,[],D);A.shallowUpdates&&await _r(h,A.shallowUpdates)}let P=`clone: from ${c}`;for(let A of k)if(A.name!=="HEAD"){if(A.name.startsWith("refs/heads/")){if(p&&R&&A.name!==`refs/heads/${R}`)continue;let U=`refs/remotes/origin/${A.name.slice(11)}`;await J(h,U,A.hash),await re(h,r.env,U,null,A.hash,P)}A.name.startsWith("refs/tags/")&&(g||await J(h,A.name,A.hash))}if(n.bare)return await ze(h,b),R&&await Ze(h,"HEAD",`refs/heads/${R}`),await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:R}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
360
- `,exitCode:0};if(await vr(h,"origin",k,E.headTarget),R&&x&&(await J(h,`refs/heads/${R}`,x),await Ze(h,"HEAD",`refs/heads/${R}`),await re(h,r.env,`refs/heads/${R}`,null,x,P,!0),b[`branch "${R}"`]={remote:"origin",merge:`refs/heads/${R}`},!w)){let A=await j(h,x);await ff(h,A.tree);let U=await qe(h,A.tree),_=Vs(U.map(O=>({path:O.path,mode:parseInt(O.mode,8),hash:O.hash,stage:0,stat:ve()})));await ae(h,_)}await ze(h,b);let T={stdout:"",stderr:`Cloning into '${f}'...
361
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:R}),T}})}se();ie();Ce();ge();cn();De();et();us();Tr();function vl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[K.string().name("committish").describe("Commit to describe").optional()],options:{tags:S().describe("Use any tag, not just annotated"),always:S().describe("Show abbreviated hash as fallback"),long:S().describe("Always output long format"),abbrev:Y.number().describe("Abbreviation length"),dirty:Y.string().describe("Append dirty marker if worktree has changes"),match:Y.string().describe("Only consider tags matching glob"),exclude:Y.string().describe("Exclude tags matching glob"),exactMatch:S().alias("exact-match").describe("Only output exact matches"),firstParent:S().alias("first-parent").describe("Only follow first parent"),candidates:Y.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,u=n.match,h=n.exclude,m=n.exactMatch,p=n.firstParent,g;if(i){let C=await We(s,i);if(!C)return I(`Not a valid object name ${i}`);try{g=await He(s,C)}catch{return I(`Not a valid object name ${i}`)}}else g=await X(s);if(!g)return I("your current branch does not have any commits yet");let w=await qp(s,a,u,h),b=new Map,E=!1;for(let C of w){C.timestamp===0&&(E=!0);let $=b.get(C.commitHash);$||($=[],b.set(C.commitHash,$)),$.push(C)}let k=await Kp(s,g,b,p,m?0:void 0);if(!k){if(m)return I(`no tag exactly matches '${g}'`);if(c){let $=g.slice(0,Math.max(l,1));return d&&await Tl(s)&&($+=d),{stdout:$+`
362
- `,stderr:"",exitCode:0}}let C;return!a&&E?C=`fatal: No annotated tags can describe '${g}'.
374
+ `,exitCode:0};let k=null,x=null;if(i){let v=E.find(N=>N.name===`refs/heads/${i}`);if(!v)return S(`Remote branch '${i}' not found in upstream origin`);k=i,x=v.hash}else{let v=R.headTarget;if(v?.startsWith("refs/heads/")&&E.some(N=>N.name===v)&&(k=v.slice(11),x=E.find(N=>N.name===v)?.hash??null),!k){let N=E.find(L=>L.name==="HEAD");if(N){let L=E.find(I=>I.name.startsWith("refs/heads/")&&I.hash===N.hash);L&&(k=L.name.slice(11),x=L.hash)}}if(!k){let N=E.find(L=>L.name.startsWith("refs/heads/"));N&&(k=N.name.slice(11),x=N.hash)}}let y={url:c,fetch:p&&k?`+refs/heads/${k}:refs/remotes/origin/${k}`:"+refs/heads/*:refs/remotes/origin/*"};g&&(y.tagOpt="--no-tags"),b['remote "origin"']=y;let P=[],C=new Set;for(let v of E)if(v.name!=="HEAD"){if(v.name.startsWith("refs/heads/")){if(p&&k&&v.name!==`refs/heads/${k}`)continue}else if(v.name.startsWith("refs/tags/")){if(g)continue}else continue;C.has(v.hash)||(C.add(v.hash),P.push(v.hash))}let A=m!==void 0&&m>0?{depth:m}:void 0;if(P.length>0){let v=await R.fetch(P,[],A);v.shallowUpdates&&await Fr(h,v.shallowUpdates)}let D=`clone: from ${c}`;for(let v of E)if(v.name!=="HEAD"){if(v.name.startsWith("refs/heads/")){if(p&&k&&v.name!==`refs/heads/${k}`)continue;let N=`refs/remotes/origin/${v.name.slice(11)}`;await J(h,N,v.hash),await re(h,r.env,N,null,v.hash,D)}v.name.startsWith("refs/tags/")&&(g||await J(h,v.name,v.hash))}if(n.bare)return await ze(h,b),k&&await Ze(h,"HEAD",`refs/heads/${k}`),await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:k}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
375
+ `,exitCode:0};if(await vr(h,"origin",E,R.headTarget),k&&x&&(await J(h,`refs/heads/${k}`,x),await Ze(h,"HEAD",`refs/heads/${k}`),await re(h,r.env,`refs/heads/${k}`,null,x,D,!0),b[`branch "${k}"`]={remote:"origin",merge:`refs/heads/${k}`},!w)){let v=await j(h,x);await gf(h,v.tree);let N=await qe(h,v.tree),L=Ks(N.map(I=>({path:I.path,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:He()})));await ae(h,L)}await ze(h,b);let $={stdout:"",stderr:`Cloning into '${f}'...
376
+ `,exitCode:0};return await t?.hooks?.postClone?.({repo:h,repository:c,targetPath:l,bare:n.bare,branch:k}),$}})}se();ie();Ce();ge();fn();Ae();Je();ls();Tr();function Wl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[q.string().name("committish").describe("Commit to describe").optional()],options:{tags:O().describe("Use any tag, not just annotated"),always:O().describe("Show abbreviated hash as fallback"),long:O().describe("Always output long format"),abbrev:Y.number().describe("Abbreviation length"),dirty:Y.string().describe("Append dirty marker if worktree has changes"),match:Y.string().describe("Only consider tags matching glob"),exclude:Y.string().describe("Exclude tags matching glob"),exactMatch:O().alias("exact-match").describe("Only output exact matches"),firstParent:O().alias("first-parent").describe("Only follow first parent"),candidates:Y.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,u=n.match,h=n.exclude,m=n.exactMatch,p=n.firstParent,g;if(i){let P=await We(s,i);if(!P)return S(`Not a valid object name ${i}`);try{g=await Te(s,P)}catch{return S(`Not a valid object name ${i}`)}}else g=await Z(s);if(!g)return S("your current branch does not have any commits yet");let w=await ag(s,a,u,h),b=new Map,R=!1;for(let P of w){P.timestamp===0&&(R=!0);let C=b.get(P.commitHash);C||(C=[],b.set(P.commitHash,C)),C.push(P)}let E=await cg(s,g,b,p,m?0:void 0);if(!E){if(m)return S(`no tag exactly matches '${g}'`);if(c){let C=g.slice(0,Math.max(l,1));return d&&await Bl(s)&&(C+=d),{stdout:C+`
377
+ `,stderr:"",exitCode:0}}let P;return!a&&R?P=`fatal: No annotated tags can describe '${g}'.
363
378
  However, there were unannotated tags: try --tags.
364
- `:w.length===0&&!a&&(await we(s,"refs/tags")).length>0?C=`fatal: No annotated tags can describe '${g}'.
379
+ `:w.length===0&&!a&&(await ye(s,"refs/tags")).length>0?P=`fatal: No annotated tags can describe '${g}'.
365
380
  However, there were unannotated tags: try --tags.
366
- `:C=`fatal: No names found, cannot describe anything.
367
- `,{stdout:"",stderr:C,exitCode:128}}let{tag:R,depth:x}=k,y;if(x===0&&!f)y=R.name;else if(l===0)y=R.name;else{let C=g.slice(0,Math.max(l,1));y=`${R.name}-${x}-g${C}`}return d&&await Tl(s)&&(y+=d),{stdout:y+`
368
- `,stderr:"",exitCode:0}}})}async function qp(e,t,n,r){let o=await we(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&fn(n,a,0)!==0||r&&fn(r,a,0)===0)continue;let c=await ye(e,i.hash);if(c.type==="tag"){let f=Xt(c.content),l;try{l=await He(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function Kp(e,t,n,r,o){let s=new Set,i=[{hash:t,depth:0}];for(;i.length>0;){let{hash:a,depth:c}=i.shift();if(s.has(a)||(s.add(a),o!==void 0&&c>o))continue;let f=n.get(a);if(f&&f.length>0)return{tag:zp(f),depth:c};let l;try{l=await j(e,a)}catch{continue}if(r)l.parents.length>0&&!s.has(l.parents[0])&&i.push({hash:l.parents[0],depth:c+1});else for(let d of l.parents)s.has(d)||i.push({hash:d,depth:c+1})}return null}function zp(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function Tl(e){if(Ye(e))return!1;let n=await X(e);if(!n)return!1;let r=await j(e,n),o=await de(e,r.tree),s=await z(e);return Wn(s,o)?!0:(await wt(e,s)).length>0}se();Ce();ie();wn();me();Ke();ge();De();et();function Al(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Y.string().alias("m").repeatable().describe("Commit message"),file:Y.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:S().describe("Allow creating an empty commit"),amend:S().describe("Amend the previous commit"),noEdit:S().describe("Use the previous commit message without editing"),all:S().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{let o=n.message;if(o.length>0&&n.file!==void 0)return I("options '-m' and '-F' cannot be used together");let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await z(i);if(n.all){let ce=Ye(i);if(ce)return ce;let Se=await wt(i,a);for(let Xe of Se)Xe.status==="modified"?a=(await dn(i,a,Xe.path)).index:Xe.status==="deleted"&&(a=ct(a,Xe.path));let ut=new Set(Ne(a).map(Xe=>Xe.path)),Rr=new Set(a.entries.filter(Xe=>Xe.stage>0&&!ut.has(Xe.path)).map(Xe=>Xe.path));for(let Xe of Rr){let Kr=v(i.workTree,Xe);await r.fs.exists(Kr)?a=(await dn(i,a,Xe)).index:a=ct(a,Xe)}}let c=await W(i,"MERGE_HEAD"),f=await W(i,"CHERRY_PICK_HEAD"),l=await W(i,"REVERT_HEAD"),u=await _t(i)?await W(i,"REBASE_HEAD"):null,h=n.amend,m=await X(i);if(h){if(!m)return I("You have nothing yet to amend.");if(c)return I("You are in the middle of a merge -- cannot amend.");if(f)return I("You are in the middle of a cherry-pick -- cannot amend.")}if(jt(a)){let ce=new Set,Se=[];for(let ut of a.entries)ut.stage>0&&!ce.has(ut.path)&&(ce.add(ut.path),Se.push(`U ${ut.path}`));return Se.sort(),{stdout:Se.length>0?`${Se.join(`
381
+ `:P=`fatal: No names found, cannot describe anything.
382
+ `,{stdout:"",stderr:P,exitCode:128}}let{tag:k,depth:x}=E,y;if(x===0&&!f)y=k.name;else if(l===0)y=k.name;else{let P=g.slice(0,Math.max(l,1));y=`${k.name}-${x}-g${P}`}return d&&await Bl(s)&&(y+=d),{stdout:y+`
383
+ `,stderr:"",exitCode:0}}})}async function ag(e,t,n,r){let o=await ye(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&ln(n,a,0)!==0||r&&ln(r,a,0)===0)continue;let c=await we(e,i.hash);if(c.type==="tag"){let f=Zt(c.content),l;try{l=await Te(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function cg(e,t,n,r,o){let s=new Set,i=[{hash:t,depth:0}];for(;i.length>0;){let{hash:a,depth:c}=i.shift();if(s.has(a)||(s.add(a),o!==void 0&&c>o))continue;let f=n.get(a);if(f&&f.length>0)return{tag:fg(f),depth:c};let l;try{l=await j(e,a)}catch{continue}if(r)l.parents.length>0&&!s.has(l.parents[0])&&i.push({hash:l.parents[0],depth:c+1});else for(let d of l.parents)s.has(d)||i.push({hash:d,depth:c+1})}return null}function fg(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function Bl(e){if(Ye(e))return!1;let n=await Z(e);if(!n)return!1;let r=await j(e,n),o=await le(e,r.tree),s=await V(e);return lr(s,o)?!0:(await bt(e,s)).length>0}se();Ce();ie();bn();me();Be();ge();Ae();Je();function ql(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:O().describe("Allow creating an empty commit"),amend:O().describe("Amend the previous commit"),noEdit:O().describe("Use the previous commit message without editing"),all:O().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 K(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await V(i);if(n.all){let ce=Ye(i);if(ce)return ce;let Se=await bt(i,a);for(let Xe of Se)Xe.status==="modified"?a=(await un(i,a,Xe.path)).index:Xe.status==="deleted"&&(a=lt(a,Xe.path));let ht=new Set(Ge(a).map(Xe=>Xe.path)),Rr=new Set(a.entries.filter(Xe=>Xe.stage>0&&!ht.has(Xe.path)).map(Xe=>Xe.path));for(let Xe of Rr){let Wr=H(i.workTree,Xe);await r.fs.exists(Wr)?a=(await un(i,a,Xe)).index:a=lt(a,Xe)}}let c=await U(i,"MERGE_HEAD"),f=await U(i,"CHERRY_PICK_HEAD"),l=await U(i,"REVERT_HEAD"),u=await Ut(i)?await U(i,"REBASE_HEAD"):null,h=n.amend,m=await Z(i);if(h){if(!m)return S("You have nothing yet to amend.");if(c)return S("You are in the middle of a merge -- cannot amend.");if(f)return S("You are in the middle of a cherry-pick -- cannot amend.")}if(Lt(a)){let ce=new Set,Se=[];for(let ht of a.entries)ht.stage>0&&!ce.has(ht.path)&&(ce.add(ht.path),Se.push(`U ${ht.path}`));return Se.sort(),{stdout:Se.length>0?`${Se.join(`
369
384
  `)}
370
385
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
371
386
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
@@ -373,89 +388,89 @@ hint: as appropriate to mark resolution and make a commit.
373
388
  fatal: Exiting because of an unresolved conflict.
374
389
  `,exitCode:128}}let p=h&&m?await j(i,m):null,g=o.length>0?o.join(`
375
390
 
376
- `):void 0;if(g!==void 0&&(g=Ot(g),!g))return{stdout:`Aborting commit due to empty commit message.
377
- `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ce=n.file.startsWith("/")?n.file:v(r.cwd,n.file);if(!await r.fs.exists(ce))return I(`could not read log file '${n.file}': No such file or directory`);let Se=await r.fs.readFile(ce);g=typeof Se=="string"?Se:new TextDecoder().decode(Se)}if(g=Ot(g),!g)return{stdout:`Aborting commit due to empty commit message.
378
- `,stderr:"",exitCode:1}}if(!g&&h&&p&&(g=p.message),!g&&(c||f||l||u)){let ce=await $e(i,"SQUASH_MSG");if(ce)g=Ot(ce);else{let Se=await $e(i,"MERGE_MSG");Se!==null&&(g=Ot(Se))}}if(!g)return N("error: must provide a commit message with -m or -F");let w=Ne(a),b=await _e(i,w),E=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(fe(E))return N(E.message??"");let k=n.allowEmpty,R=null;if(h&&p){let ce=p.parents[0];ce?R=(await j(i,ce)).tree:R=await gt("tree",new Uint8Array(0))}else m&&(R=(await j(i,m)).tree);let x=h&&p&&p.parents.length>1;if(!k&&!c&&!x){if(!m&&!h&&w.length===0)return{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(R!==null&&R===b){if(h){let ce=p?.parents[0]??null;return{stdout:`${await ot(i,{fromCommit:!0,compareHash:ce,noWarn:!0,index:a})}No changes
391
+ `):void 0;if(g!==void 0&&(g=St(g),!g))return{stdout:`Aborting commit due to empty commit message.
392
+ `,stderr:"",exitCode:1};if(!g&&n.file!==void 0){if(n.file==="-")g=r.stdin;else{let ce=n.file.startsWith("/")?n.file:H(r.cwd,n.file);if(!await r.fs.exists(ce))return S(`could not read log file '${n.file}': No such file or directory`);let Se=await r.fs.readFile(ce);g=typeof Se=="string"?Se:new TextDecoder().decode(Se)}if(g=St(g),!g)return{stdout:`Aborting commit due to empty commit message.
393
+ `,stderr:"",exitCode:1}}if(!g&&h&&p&&(g=p.message),!g&&(c||f||l||u)){let ce=await $e(i,"SQUASH_MSG");if(ce)g=St(ce);else{let Se=await $e(i,"MERGE_MSG");Se!==null&&(g=St(Se))}}if(!g)return _("error: must provide a commit message with -m or -F");let w=Ge(a),b=await Fe(i,w),R=await t?.hooks?.preCommit?.({repo:i,index:a,treeHash:b});if(de(R))return _(R.message??"");let E=n.allowEmpty,k=null;if(h&&p){let ce=p.parents[0];ce?k=(await j(i,ce)).tree:k=await gt("tree",new Uint8Array(0))}else m&&(k=(await j(i,m)).tree);let x=h&&p&&p.parents.length>1;if(!E&&!c&&!x){if(!m&&!h&&w.length===0)return{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(k!==null&&k===b){if(h){let ce=p?.parents[0]??null;return{stdout:`${await at(i,{fromCommit:!0,compareHash:ce,noWarn:!0,index:a})}No changes
379
394
  `,stderr:`You asked to amend the most recent commit, but doing so would make
380
395
  it empty. You can repeat your command with --allow-empty, or you can
381
396
  remove the commit entirely with "git reset HEAD^".
382
- `,exitCode:1}}return f?{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
397
+ `,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.
383
398
  If you wish to commit it anyway, use:
384
399
 
385
400
  git commit --allow-empty
386
401
 
387
402
  Otherwise, please use 'git cherry-pick --skip'
388
- `,exitCode:1}:{stdout:await ot(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let y=await un(i,r.env);if(M(y))return y;let C=await tt(i,r.env);if(M(C))return C;h&&p&&(y.name=p.author.name,y.email=p.author.email,y.timestamp=p.author.timestamp,y.timezone=p.author.timezone),f&&(y=(await j(i,f)).author);let $=Gt(g),D={repo:i,message:$},P=await t?.hooks?.commitMsg?.(D);if(fe(P))return N(P.message??"");$=D.message;let T;h&&p?T=[...p.parents]:(T=m?[m]:[],c&&T.push(c));let A=an({type:"commit",tree:b,parents:T,author:y,committer:C,message:$}),U=await Ie(i,"commit",A);await ae(i,a);let _=await Q(i);_&&_.type==="symbolic"?await J(i,_.target,U):await J(i,"HEAD",U);let O=ue($),H;h?H="commit (amend)":c?H="commit (merge)":f?H="commit (cherry-pick)":m?H="commit":H="commit (initial)";let L=`${H}: ${O}`,G=_?.type==="symbolic"?_.target:"HEAD";await re(i,r.env,G,m,U,L,_?.type==="symbolic"),c&&await ps(i),f&&await Ft(i),l&&await St(i),u&&await be(i,"MERGE_MSG"),await be(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:U,message:$,branch:_?.type==="symbolic"?Pe(_.target):null,parents:T,author:y});let B=_?.type==="symbolic"?_.target:null,F=B?Pe(B):"detached HEAD",ee;if(h&&p){let ce=p.parents[0];ee=ce?(await j(i,ce)).tree:null}else ee=m?(await j(i,m)).tree:null;let V=y.timestamp!==C.timestamp||y.timezone!==C.timezone,te=T.length>1,ke=await mn(i,ee,b,y,C,V,te);return{stdout:`${Lt(F,U,g,T.length===0&&!h)}
389
- ${ke}`,stderr:"",exitCode:0}}})}se();Be();me();function Tn(e){let t=e.split(".");return t.length===2||t.length===3}function Vp(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 jl(e,t){e.command("config",{description:"Get and set repository options",args:[K.string().name("positionals").variadic().optional()],options:{list:S().alias("l").describe("List all config entries"),get:S().describe("Get the value for a given key"),unset:S().describe("Remove a config key"),"get-all":S().describe("Get all values for a multi-valued key"),add:S().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Ml(s);if(n.get){let f=a;return f?Tn(f)?ka(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(n["get-all"]){let f=a;return f?Tn(f)?Hl(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?N("error: missing key and/or value",2):Tn(f)?(await ec(s,f,l),{stdout:"",stderr:"",exitCode:0}):N(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Tn(f)?Dl(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="list")return Ml(s);if(a==="get"){let f=i[1];return f?Tn(f)?ka(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Tn(f)?Hl(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?N("error: missing key and/or value",2):Tn(f)?(await gi(s,f,l),{stdout:"",stderr:"",exitCode:0}):N(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Tn(f)?Dl(s,f):N(`error: invalid key: ${f}`,2):N("error: missing key",2)}if(!a)return N("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Tn(a))return N(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await gi(s,a,c),{stdout:"",stderr:"",exitCode:0}):ka(s,a)}})}async function ka(e,t){let n=await xe(e,t);return n===void 0?N(""):{stdout:`${n}
390
- `,stderr:"",exitCode:0}}async function Hl(e,t){let n=await Qa(e,t);return n.length===0?N(""):{stdout:`${n.join(`
403
+ `,exitCode:1}:{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let y=await mn(i,r.env);if(M(y))return y;let P=await tt(i,r.env);if(M(P))return P;h&&p&&(y.name=p.author.name,y.email=p.author.email,y.timestamp=p.author.timestamp,y.timezone=p.author.timezone),f&&(y=(await j(i,f)).author);let C=It(g),A={repo:i,message:C},D=await t?.hooks?.commitMsg?.(A);if(de(D))return _(D.message??"");C=A.message;let $;h&&p?$=[...p.parents]:($=m?[m]:[],c&&$.push(c));let v=cn({type:"commit",tree:b,parents:$,author:y,committer:P,message:C}),N=await Ie(i,"commit",v);await ae(i,a);let L=await te(i);L&&L.type==="symbolic"?await J(i,L.target,N):await J(i,"HEAD",N);let I=ue(C),T;h?T="commit (amend)":c?T="commit (merge)":f?T="commit (cherry-pick)":m?T="commit":T="commit (initial)";let G=`${T}: ${I}`,W=L?.type==="symbolic"?L.target:"HEAD";await re(i,r.env,W,m,N,G,L?.type==="symbolic"),c&&await ms(i),f&&await en(i),l&&await _t(i),u&&await be(i,"MERGE_MSG"),await be(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:N,message:C,branch:L?.type==="symbolic"?Pe(L.target):null,parents:$,author:y});let F=L?.type==="symbolic"?L.target:null,B=F?Pe(F):"detached HEAD",ee;if(h&&p){let ce=p.parents[0];ee=ce?(await j(i,ce)).tree:null}else ee=m?(await j(i,m)).tree:null;let z=y.timestamp!==P.timestamp||y.timezone!==P.timezone,Q=$.length>1,Re=await vn(i,ee,b,y,P,z,Q);return{stdout:`${Qt(B,N,g,$.length===0&&!h)}
404
+ ${Re}`,stderr:"",exitCode:0}}})}se();Ue();me();function Dn(e){let t=e.split(".");return t.length===2||t.length===3}function lg(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 Yl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:O().alias("l").describe("List all config entries"),get:O().describe("Get the value for a given key"),unset:O().describe("Remove a config key"),"get-all":O().describe("Get all values for a multi-valued key"),add:O().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return Vl(s);if(n.get){let f=a;return f?Dn(f)?Oa(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n["get-all"]){let f=a;return f?Dn(f)?Kl(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?_("error: missing key and/or value",2):Dn(f)?(await ac(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?Dn(f)?zl(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="list")return Vl(s);if(a==="get"){let f=i[1];return f?Dn(f)?Oa(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?Dn(f)?Kl(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?_("error: missing key and/or value",2):Dn(f)?(await Ei(s,f,l),{stdout:"",stderr:"",exitCode:0}):_(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?Dn(f)?zl(s,f):_(`error: invalid key: ${f}`,2):_("error: missing key",2)}if(!a)return _("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!Dn(a))return _(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await Ei(s,a,c),{stdout:"",stderr:"",exitCode:0}):Oa(s,a)}})}async function Oa(e,t){let n=await ke(e,t);return n===void 0?_(""):{stdout:`${n}
405
+ `,stderr:"",exitCode:0}}async function Kl(e,t){let n=await ic(e,t);return n.length===0?_(""):{stdout:`${n.join(`
391
406
  `)}
392
- `,stderr:"",exitCode:0}}async function Dl(e,t){return await tc(e,t)?{stdout:"",stderr:"",exitCode:0}:N("",5)}async function Ml(e){let t=v(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=ui(n),o=Vp(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(`
407
+ `,stderr:"",exitCode:0}}async function zl(e,t){return await cc(e,t)?{stdout:"",stderr:"",exitCode:0}:_("",5)}async function Vl(e){let t=H(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=gi(n),o=lg(r),s=new Set(o.map(c=>c.split("=")[0])),i=e.configOverrides?.defaults;if(i)for(let[c,f]of Object.entries(i))s.has(c)||(o.push(`${c}=${f}`),s.add(c));let a=e.configOverrides?.locked;if(a)for(let[c,f]of Object.entries(a))s.has(c)||o.push(`${c}=${f}`);return{stdout:o.length>0?`${o.join(`
393
408
  `)}
394
- `:"",stderr:"",exitCode:0}}se();function Wo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(b=>b?Z(b):"0000000"),c=o?Z(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(b=>b===null),d=!f&&n.some(b=>b!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let b=r.map(E=>E||"000000").join(",");i.push(`deleted file mode ${b}`)}else{let b=r.map(R=>R||"000000"),E=s||"000000";b.some(R=>R!==E)&&i.push(`mode ${b.join(",")}..${E}`)}let u=n.some(b=>b!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
409
+ `:"",stderr:"",exitCode:0}}se();function Bo(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(b=>b?X(b):"0000000"),c=o?X(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(b=>b===null),d=!f&&n.some(b=>b!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let b=r.map(R=>R||"000000").join(",");i.push(`deleted file mode ${b}`)}else{let b=r.map(k=>k||"000000"),R=s||"000000";b.some(k=>k!==R)&&i.push(`mode ${b.join(",")}..${R}`)}let u=n.some(b=>b!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
395
410
  `)}
396
- `;let h=e.parentContents.map(b=>b.length>0?Bt(b):[]),m=e.resultContent.length>0?Bt(e.resultContent):[],p=h.map(b=>it(b,m)),g=Yp(h,m,p),w=Zp(g,h.length,m);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
411
+ `;let h=e.parentContents.map(b=>b.length>0?Wt(b):[]),m=e.resultContent.length>0?Wt(e.resultContent):[],p=h.map(b=>ct(b,m)),g=dg(h,m,p),w=hg(g,h.length,m);if(w.length===0)return"";for(let b of w)i.push(b);return`${i.join(`
397
412
  `)}
398
- `}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=Xp(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 h=o[d]?.resultStatus[i];if(f.push(h==="insert"?"+":" "),h==="keep"){let m=n[d];if(m){for(let p of m)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function Xp(e,t){if(!e.some(o=>o.length>0))return[];if(t===2){let o=e[0]??[],s=e[1]??[];if(o.length===0)return s.map(l=>({columns:[" ","-"],text:l.text,resultLineNo:0,parentLineNos:[0,l.parentLineNo]}));if(s.length===0)return o.map(l=>({columns:["-"," "],text:l.text,resultLineNo:0,parentLineNos:[l.parentLineNo,0]}));let i=o.map(l=>l.text),a=s.map(l=>l.text),c=it(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(h=>h.text===l.line&&h.parentLineNo===l.oldLineNo),u=s.find(h=>h.text===l.line&&h.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function Zp(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),h=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=h}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let k=0;k<t;k++){let R=d.filter(x=>(x.parentLineNos[k]??0)>0||x.columns[k]==="-");if(R.length===0)u.push({start:1,count:0});else{let y=R.find(C=>(C.parentLineNos[k]??0)>0)?.parentLineNos[k]??1;u.push({start:y,count:R.length})}}let h=d.filter(k=>k.resultLineNo>0),m=h[0],p=m?m.resultLineNo:1,g=h.length,w="";for(let k=p-2;k>=0;k--){let R=n[k];if(R&&/^[a-zA-Z$_]/.test(R)){w=` ${R.trimEnd().slice(0,79)}`;break}}let b=u.map(k=>`-${k.start},${k.count}`),E=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(E);for(let k of d)f.push(`${k.columns.join("")}${k.text}`)}return f}se();Ce();ie();me();function qo(e){let t=e.indexOf("...");if(t>=0)return{type:"three-dot",left:e.slice(0,t)||"HEAD",right:e.slice(t+3)||"HEAD"};let n=e.indexOf("..");return n>=0?{type:"two-dot",left:e.slice(0,n)||"HEAD",right:e.slice(n+2)||"HEAD"}:null}kn();ge();De();et();var Ra=new TextDecoder;function Fl(e){return"exitCode"in e}function Er(e){return e.toString(8).padStart(6,"0")}function _l(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 Ul(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",transformArgs:n=>n.map(r=>{let o=/^-U(\d+)$/.exec(r);return o?`--unified=${o[1]}`:r}),args:[K.string().name("commits").variadic().optional()],options:{cached:S().describe("Show staged changes (index vs HEAD)"),staged:S().describe("Synonym for --cached"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),unified:Y.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:S().alias("M").describe("Detect renames (enabled by default)"),findCopies:S().alias("C").describe("Detect copies (accepted for compatibility)"),color:S().describe("Show colored diff (accepted for compatibility)"),noColor:S().describe("Turn off colored diff (accepted for compatibility)")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=dt(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(g=>Ue(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,h=c.length===1?qo(c[0]):null;if(h){if(a)return I("too many arguments");h.type==="three-dot"?u=await tg(i,h.left,h.right,l):u=await Nl(i,h.left,h.right,l)}else if(c.length===2)u=await Nl(i,c[0],c[1],l);else{if(c.length>2)return I("too many arguments");a?u=await eg(i,c.length===1?c[0]:null,l):c.length===1?u=await ng(i,c[0],l):u=await Jp(i,l)}if(Fl(u))return u;let m=n.unified,p=await rg(i,u.items,d,m);return u.stderr&&(p.stderr=u.stderr),p}})}async function Jp(e,t){let n=Ye(e);if(n)return n;let r=await z(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await wt(e,r);c.sort((l,d)=>Te(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let u=Er(d.mode),h;if(l.status==="modified"&&e.workTree){let m=v(e.workTree,l.path),p=await e.fs.readFileBuffer(m);h=await gt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:h,oldMode:u,newMode:u,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),u=a.get(l);await Qp(f,e,l,d,u)}return f.sort((l,d)=>{let u=Te(l.path,d.path);return u!==0?u:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function Qp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=Er(r.mode),a=Er(o.mode),{exists:c,hash:f}=await Ll(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),Gl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=Er(r.mode),{exists:a,hash:c}=await Ll(t.fs,s,n);Gl(e,n,r.hash,i,a,c)}}async function Ll(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await ls(e,r);return{exists:!0,hash:await gt("blob",o)}}function Gl(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 eg(e,t,n){let r=null;if(t){let u=await Ge(e,t);if(M(u))return u;r=u.commit.tree}else{let u=await X(e);u&&(r=(await j(e,u)).tree)}let o=await de(e,r),s=await z(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(Ne(s).map(u=>[u.path,u])),c=[];for(let[u,h]of a){if(i.has(u))continue;let m=o.get(u);m?m.hash!==h.hash&&c.push({path:u,status:"modified",oldHash:m.hash,newHash:h.hash,oldMode:m.mode,newMode:Er(h.mode)}):c.push({path:u,status:"added",newHash:h.hash,newMode:Er(h.mode)})}for(let[u,h]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:l}=await st(e,c),d=_l(f,l);for(let u of i)d.push({path:u,status:"U"});return d.sort((u,h)=>Te(u.path,h.path)),n?{items:d.filter(u=>Ee(n,u.path))}:{items:d}}async function Nl(e,t,n,r){let o=await Ge(e,t);if(M(o))return o;let s=await Ge(e,n);if(M(s))return s;let i=await Ve(e,o.commit.tree,s.commit.tree);return Bl(e,i,r)}async function tg(e,t,n,r){let o=await Ge(e,t);if(M(o))return o;let s=await Ge(e,n);if(M(s))return s;let i=await Wt(e,o.hash,s.hash);if(i.length===0)return I(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
399
- `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await Bl(e,l,r);return Fl(d)||a&&(d.stderr=a),d}async function Bl(e,t,n){let{remaining:r,renames:o}=await st(e,t),s=_l(r,o);return s.sort((i,a)=>Te(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function ng(e,t,n){let r=Ye(e);if(r)return r;let o=await Ge(e,t);if(M(o))return o;let s=e.workTree,i=await de(e,o.commit.tree),a=await z(e),c=new Map(Ne(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let h=await e.fs.readFileBuffer(u),m=await gt("blob",h);m!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:m,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u))continue;let h=await e.fs.readFileBuffer(u),m=await gt("blob",h);f.push({path:l,status:"A",newHash:m,newMode:Er(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Te(l.path,d.path)),{items:f}}async function rg(e,t,n,r){let o;switch(n){case"stat":o=await fg(e,t);break;case"shortstat":o=await lg(e,t);break;case"numstat":o=await cg(e,t);break;case"name-only":o=ig(t);break;case"name-status":o=ag(t);break;default:o=await sg(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function sg(e,t,n){let r="",o=new Set,s=await og(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 xa(e,i);if(a.some(l=>Ae(l))||Ae(c)){let l=i.combinedParentHashes.map(d=>d?Z(d):"0000000");r+=`diff --cc ${i.path}
413
+ `}function dg(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=ug(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 h=o[d]?.resultStatus[i];if(f.push(h==="insert"?"+":" "),h==="keep"){let m=n[d];if(m){for(let p of m)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function ug(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(h=>h.text===l.line&&h.parentLineNo===l.oldLineNo),u=s.find(h=>h.text===l.line&&h.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function hg(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),h=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=h}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let E=0;E<t;E++){let k=d.filter(x=>(x.parentLineNos[E]??0)>0||x.columns[E]==="-");if(k.length===0)u.push({start:1,count:0});else{let y=k.find(P=>(P.parentLineNos[E]??0)>0)?.parentLineNos[E]??1;u.push({start:y,count:k.length})}}let h=d.filter(E=>E.resultLineNo>0),m=h[0],p=m?m.resultLineNo:1,g=h.length,w="";for(let E=p-2;E>=0;E--){let k=n[E];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let b=u.map(E=>`-${E.start},${E.count}`),R=`${"@".repeat(t+1)} ${b.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(R);for(let E of d)f.push(`${E.columns.join("")}${E.text}`)}return f}se();Ce();ie();me();function Wo(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}Pn();ge();Ae();Je();var Sa=new TextDecoder;function Ql(e){return"exitCode"in e}function Er(e){return e.toString(8).padStart(6,"0")}function ed(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 td(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:O().describe("Show staged changes (index vs HEAD)"),staged:O().describe("Synonym for --cached"),stat:O().describe("Show diffstat summary"),nameOnly:O().describe("Show only names of changed files"),nameStatus:O().describe("Show names and status of changed files"),shortstat:O().describe("Show only the shortstat summary line"),numstat:O().describe("Machine-readable insertions/deletions per file"),unified:Y.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:O().alias("M").describe("Detect renames (enabled by default)"),findCopies:O().alias("C").describe("Detect copies (accepted for compatibility)"),color:O().describe("Show colored diff (accepted for compatibility)"),noColor:O().describe("Turn off colored diff (accepted for compatibility)")},handler:async(n,r,o)=>{let s=await K(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=>_e(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,h=c.length===1?Wo(c[0]):null;if(h){if(a)return S("too many arguments");h.type==="three-dot"?u=await wg(i,h.left,h.right,l):u=await Jl(i,h.left,h.right,l)}else if(c.length===2)u=await Jl(i,c[0],c[1],l);else{if(c.length>2)return S("too many arguments");a?u=await gg(i,c.length===1?c[0]:null,l):c.length===1?u=await bg(i,c[0],l):u=await mg(i,l)}if(Ql(u))return u;let m=n.unified,p=await yg(i,u.items,d,m);return u.stderr&&(p.stderr=u.stderr),p}})}async function mg(e,t){let n=Ye(e);if(n)return n;let r=await V(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 bt(e,r);c.sort((l,d)=>ve(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let u=Er(d.mode),h;if(l.status==="modified"&&e.workTree){let m=H(e.workTree,l.path),p=await e.fs.readFileBuffer(m);h=await gt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:h,oldMode:u,newMode:u,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),u=a.get(l);await pg(f,e,l,d,u)}return f.sort((l,d)=>{let u=ve(l.path,d.path);return u!==0?u:l.status==="U"&&d.status!=="U"?-1:l.status!=="U"&&d.status==="U"?1:0}),{items:f}}async function pg(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=Er(r.mode),a=Er(o.mode),{exists:c,hash:f}=await Xl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),Zl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=Er(r.mode),{exists:a,hash:c}=await Xl(t.fs,s,n);Zl(e,n,r.hash,i,a,c)}}async function Xl(e,t,n){let r=H(t,n);if(!await e.exists(r))return{exists:!1};let o=await cs(e,r);return{exists:!0,hash:await gt("blob",o)}}function Zl(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 gg(e,t,n){let r=null;if(t){let u=await Me(e,t);if(M(u))return u;r=u.commit.tree}else{let u=await Z(e);u&&(r=(await j(e,u)).tree)}let o=await le(e,r),s=await V(e),i=new Set;for(let u of s.entries)u.stage>0&&i.add(u.path);let a=new Map(Ge(s).map(u=>[u.path,u])),c=[];for(let[u,h]of a){if(i.has(u))continue;let m=o.get(u);m?m.hash!==h.hash&&c.push({path:u,status:"modified",oldHash:m.hash,newHash:h.hash,oldMode:m.mode,newMode:Er(h.mode)}):c.push({path:u,status:"added",newHash:h.hash,newMode:Er(h.mode)})}for(let[u,h]of o)i.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=ed(f,l);for(let u of i)d.push({path:u,status:"U"});return d.sort((u,h)=>ve(u.path,h.path)),n?{items:d.filter(u=>Ee(n,u.path))}:{items:d}}async function Jl(e,t,n,r){let o=await Me(e,t);if(M(o))return o;let s=await Me(e,n);if(M(s))return s;let i=await Ve(e,o.commit.tree,s.commit.tree);return nd(e,i,r)}async function wg(e,t,n,r){let o=await Me(e,t);if(M(o))return o;let s=await Me(e,n);if(M(s))return s;let i=await qt(e,o.hash,s.hash);if(i.length===0)return S(`${t}...${n}: no merge base`);let a;i.length>1&&(a=`warning: ${t}...${n}: multiple merge bases, using ${i[0]}
414
+ `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await nd(e,l,r);return Ql(d)||a&&(d.stderr=a),d}async function nd(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=ed(r,o);return s.sort((i,a)=>ve(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function bg(e,t,n){let r=Ye(e);if(r)return r;let o=await Me(e,t);if(M(o))return o;let s=e.workTree,i=await le(e,o.commit.tree),a=await V(e),c=new Map(Ge(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let u=H(s,l);if(!await e.fs.exists(u)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let h=await e.fs.readFileBuffer(u),m=await gt("blob",h);m!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:m,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let u=H(s,l);if(!await e.fs.exists(u))continue;let h=await e.fs.readFileBuffer(u),m=await gt("blob",h);f.push({path:l,status:"A",newHash:m,newMode:Er(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>ve(l.path,d.path)),{items:f}}async function yg(e,t,n,r){let o;switch(n){case"stat":o=await Pg(e,t);break;case"shortstat":o=await $g(e,t);break;case"numstat":o=await Cg(e,t);break;case"name-only":o=Rg(t);break;case"name-status":o=xg(t);break;default:o=await Eg(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Eg(e,t,n){let r="",o=new Set,s=await kg(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=>je(l))||je(c)){let l=i.combinedParentHashes.map(d=>d?X(d):"0000000");r+=`diff --cc ${i.path}
400
415
  index ${l.join(",")}..0000000
401
416
  Binary files differ
402
- `,o.add(i.path)}else{let l=Wo({path:i.path,parentHashes:i.combinedParentHashes,parentModes:i.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:i.newMode??null,resultContent:c});l?(r+=l,o.add(i.path)):r+=`* Unmerged path ${i.path}
417
+ `,o.add(i.path)}else{let l=Bo({path:i.path,parentHashes:i.combinedParentHashes,parentModes:i.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:i.newMode??null,resultContent:c});l?(r+=l,o.add(i.path)):r+=`* Unmerged path ${i.path}
403
418
  `}}else r+=`* Unmerged path ${i.path}
404
- `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await oe(e,i.oldHash):"",c=await xa(e,i);i.status==="R"&&i.oldPath?r+=vt({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Ko(i.oldHash,s),newHash:Ko(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=vt({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Ko(i.oldHash,s),newHash:Ko(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function og(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=v(e.gitDir,"objects",a),l=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,l),l},s=async(a,c)=>{let f=a.slice(0,2),l=a.slice(2,c),d=await o(f),u=0;for(let h of d)if(h.startsWith(l)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function Ko(e,t){if(e)return e.length!==40?e:t.get(e)??Z(e)}function ig(e){let t="";for(let n of e)t+=`${n.path}
405
- `;return t}function ag(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}
419
+ `;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+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:qo(i.oldHash,s),newHash:qo(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=Ht({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:qo(i.oldHash,s),newHash:qo(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function kg(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=H(e.gitDir,"objects",a),l=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(a,l),l},s=async(a,c)=>{let f=a.slice(0,2),l=a.slice(2,c),d=await o(f),u=0;for(let h of d)if(h.startsWith(l)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function qo(e,t){if(e)return e.length!==40?e:t.get(e)??X(e)}function Rg(e){let t="";for(let n of e)t+=`${n.path}
420
+ `;return t}function xg(e){let t="";for(let n of e)if(n.status==="R"){let r=String(n.similarity??100).padStart(3,"0");t+=`R${r} ${n.oldPath} ${n.path}
406
421
  `}else t+=`${n.status} ${n.path}
407
- `;return t}async function cg(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
408
- `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await xa(e,r),i=Ae(o)||Ae(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Wl(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=hn(r.oldPath,r.path);n+=`${a} ${c} ${f}
422
+ `;return t}async function Cg(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
423
+ `;continue}let o=r.oldHash?await oe(e,r.oldHash):"",s=await Ia(e,r),i=je(o)||je(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=rd(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=pn(r.oldPath,r.path);n+=`${a} ${c} ${f}
409
424
  `}else n+=`${a} ${c} ${r.path}
410
- `}return n}async function fg(e,t){let n=await ql(e,t);return pr(n)}async function lg(e,t){let n=await ql(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=Qn(s,r,o);return i?`${i}
425
+ `}return n}async function Pg(e,t){let n=await sd(e,t);return pr(n)}async function $g(e,t){let n=await sd(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=er(s,r,o);return i?`${i}
411
426
  `:n.some(a=>a.isUnmerged)?` 0 files changed
412
- `:""}async function xa(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await ls(e.fs,n);return Ra.decode(r)}return oe(e,t.newHash)}async function dg(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return ls(e.fs,n)}return $t(e,t.newHash)}function Wl(e,t){let n=xt(e),r=xt(t),o=it(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function ql(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?hn(r.oldPath,r.path):r.path,s=r.oldHash?await $t(e,r.oldHash):new Uint8Array(0),i=await dg(e,r);if(Mn(s)||Mn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=Ra.decode(s),c=Ra.decode(i),{ins:f,del:l}=Wl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}se();Be();rr();me();Ke();ge();function kr(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 ug(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 Ts(e,t){if(!ug(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 zl(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[K.string().name("remote").describe("Remote to fetch from").optional(),K.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:S().describe("Fetch from all remotes"),prune:S().alias("p").describe("Remove stale remote-tracking refs"),tags:S().describe("Also fetch tags"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:S().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Go(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=Cs),n.all){if(n.remote)return I("fetch --all does not take a remote argument");let c=await pe(s),f=[];for(let u of Object.keys(c)){let h=u.match(/^remote "(.+)"$/);h?.[1]&&f.push(h[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let u of f){let h=await Kl(s,u,void 0,n.prune,n.tags,r.env,t,i);h.stderr&&l.push(h.stderr),h.exitCode!==0&&(d=h.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 Wr(e,t,s)}catch(O){let H=O instanceof Error?O.message:"";if(H.startsWith("network"))return I(H);throw O}if(!c)return I(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,u=kr(l.fetchRefspec);n&&n.length>0?d=n.map(O=>{let H=kr(O);if(O.includes(":"))return H;for(let L of[H.src,`refs/heads/${H.src}`,`refs/tags/${H.src}`]){let G=Ts(u,L);if(G!==null)return{force:H.force||u.force,src:L,dst:G}}return H}):d=[u];let h=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(O=>`${O.src}:${O.dst}`),prune:r,tags:o});if(fe(h))return{stdout:"",stderr:h.message??"",exitCode:1};let m=await f.advertiseRefs();if(m.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await we(e)).map(O=>O.hash),w=await W(e,"HEAD");w&&g.push(w);let b=[],E=new Set,k=[];for(let O of m)if(O.name!=="HEAD")for(let H of d){let L=Ts(H,O.name);if(L!==null){k.push({remote:O,localRef:L,force:H.force}),E.has(O.hash)||(E.add(O.hash),b.push(O.hash));break}}if(o)for(let O of m)O.name.startsWith("refs/tags/")&&(k.push({remote:O,localRef:O.name,force:!1}),E.has(O.hash)||(E.add(O.hash),b.push(O.hash)));let R=new Set(g),x=b.filter(O=>!R.has(O)),y,C=a!==void 0?await Fr(e):void 0;a!==void 0&&(y={depth:a,existingShallows:C});let $=x.length>0?x:y?b:[];if($.length>0){let O=await f.fetch($,g,y);O.shallowUpdates&&await _r(e,O.shallowUpdates,C)}let D=await vn(e,s),P=[],T=[];for(let O of k){let H=await W(e,O.localRef);T.push(H),await J(e,O.localRef,O.remote.hash),await ft(e,O.localRef,{oldHash:H??ne,newHash:O.remote.hash,name:D.name,email:D.email,timestamp:D.timestamp,tz:D.tz,message:H?"fetch":"fetch: storing head"})}if(P.push(...ho(k.map((O,H)=>({...O,oldHash:T[H]})),Ln,Z)),!o)for(let O of m){if(!O.name.startsWith("refs/tags/")||E.has(O.hash))continue;let H=await W(e,O.name),L=O.peeledHash??O.hash;!H&&R.has(L)&&(await J(e,O.name,O.hash),await ft(e,O.name,{oldHash:ne,newHash:O.hash,name:D.name,email:D.email,timestamp:D.timestamp,tz:D.tz,message:"fetch: storing head"}),P.push({prefix:" * [new tag]",from:Ln(O.name),to:Ln(O.name)}))}if(r){let O=`refs/remotes/${t}`,H=await we(e,O),L=new Set(m.filter(G=>G.name.startsWith("refs/heads/")).map(G=>G.name.slice(11)));for(let G of H){if((await e.refStore.readRef(G.name))?.type==="symbolic")continue;let F=G.name.slice(O.length+1);F!=="HEAD"&&(L.has(F)||(await he(e,G.name),P.push({prefix:" - [deleted]",from:"(none)",to:`${t}/${F}`})))}}let A=m.find(O=>O.name==="HEAD");if(A){let O=v(e.gitDir,"FETCH_HEAD"),H=m.find(G=>G.name.startsWith("refs/heads/")&&G.hash===A.hash),L=H?`branch '${H.name.slice(11)}' of`:"of";await e.fs.writeFile(O,`${A.hash} ${L} ${l.url}
413
- `),await vr(e,t,m,f.headTarget)}let _={stdout:"",stderr:P.length>0?`From ${l.url}
414
- ${Dr(P,10)}`:"",exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:k.length}),_}se();Ce();ie();me();Ke();ge();Qs();Sr();me();async function hg(e,t){let n=new Set,r=v(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(v(r,i)),c=new Yt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Br(await Ur(e,t,[])):(await Br(await Ur(e,t,[]))).filter(s=>!n.has(s.hash))}async function zo(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 Br(await Ur(t,r,[])):await hg(t,r);if(a.length===0)return null;let c=a.length,f=_o(a,{window:s,depth:i}),l=f.filter(x=>x.delta).length,d=f.map(x=>({hash:x.hash,type:x.type,content:x.content,delta:x.delta,deltaBaseHash:x.deltaBase})),{data:u,entries:h}=await Js(d),m=await Lc(u,h),p=u.subarray(u.byteLength-20),g="";for(let x=0;x<20;x++){let y=p[x];g+=(y>>4).toString(16)+(y&15).toString(16)}let w=v(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let b=`pack-${g}`,E=v(w,`${b}.pack`),k=v(w,`${b}.idx`);await n.writeFile(E,u),await n.writeFile(k,m);let R=new Set(f.map(x=>x.hash));if(t.objectStore.invalidatePacks?.(),o){let x=await n.readdir(w);for(let $ of x){if(!$.endsWith(".idx"))continue;let D=$.slice(0,-4);if(D===b)continue;let P=v(w,`${D}.idx`),T=!0;try{let A=await n.readFileBuffer(P),U=new Yt(A);for(let _ of U.allHashes())if(!R.has(_)){T=!1;break}}catch{T=!1}if(T){try{await n.rm(v(w,`${D}.pack`))}catch{}try{await n.rm(P)}catch{}}}let y=v(t.gitDir,"objects"),C;try{C=await n.readdir(y)}catch{C=[]}for(let $ of C){if($==="pack"||$==="info"||$.length!==2)continue;let D=v(y,$),P;try{P=await n.readdir(D)}catch{continue}for(let T of P){let A=`${$}${T}`;R.has(A)&&await n.rm(v(D,T))}try{(await n.readdir(D)).length===0&&await n.rm(D,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function Vo(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
415
- `)}function Vl(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:S().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;await zc(s),await Et(s);let i=await pg(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await zo({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await gg(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Vo(f.totalCount,f.deltaCount,!0)}
416
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var mg=2160*60*60;async function pg(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await we(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-mg,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await Yl(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 W(e,f);l&&t.add(l)}let c=[];for(let f of t)await Zt(e,f)&&c.push(f);return c}async function Yl(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=v(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Yl(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),l=await Qe(e,f);if(f==="refs/stash"){for(let u of l)u.newHash!==ne&&o.add(u.newHash);continue}let d=l.filter(u=>u.timestamp>=r);await Fn(e,f,d);for(let u of d)u.newHash!==ne&&o.add(u.newHash)}}}async function gg(e,t){let n=v(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(v(n,o),{recursive:!0})}catch{}}se();function wg(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 Xl(e,t,n,r){if(wg(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
417
- `);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 bg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zl(e,t){let n=t?.fixed?bg(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ie();me();De();async function yg(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=v(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function Eg(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 kg(e,t){return(await qe(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>oe(e,r.hash)}))}function Rg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function xg(e,t,n){return n||t===""?e:nt(t,e)}function Jl(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[K.string().name("args").variadic().optional()],options:{cached:S().describe("Search blobs registered in the index"),lineNumber:S().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:S().alias("l").describe("Show only filenames"),filesWithoutMatch:S().alias("L").describe("Show only filenames without matches"),count:S().alias("c").describe("Show count of matching lines per file"),ignoreCase:S().alias("i").describe("Case insensitive matching"),wordRegexp:S().alias("w").describe("Match whole words only"),invertMatch:S().alias("v").describe("Invert the sense of matching"),fixedStrings:S().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:S().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:S().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:S().alias("h").describe("Suppress filename prefix"),forceFilename:S().alias("H").describe("Force filename prefix"),fullName:S().describe("Force paths to be output relative to project top"),quiet:S().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:S().describe("Require all patterns to match in a file"),maxDepth:Y.number().describe("Descend at most <n> levels of directories"),maxCount:Y.number().alias("m").describe("Maximum number of matches per file"),afterContext:Y.number().alias("A").describe("Show <n> lines after match"),beforeContext:Y.number().alias("B").describe("Show <n> lines before match"),context:Y.number().alias("C").describe("Show <n> lines before and after match"),heading:S().describe("Show filename above matches"),break:S().describe("Print empty line between results from different files"),pattern:Y.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return I("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let u=[];for(let G of f){let B=Zl(G,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!B)return I(`command line, '${G}': invalid regular expression`);u.push(B)}let h=[];if(l.length>0)for(let G of l){let B=await bt(i,G);if(M(B))return B;let F;try{F=await He(i,B)}catch{return I(`bad revision '${G}'`)}let ee=await j(i,F),V=await kg(i,ee.tree);h.push({prefix:`${G}:`,files:V})}else if(n.cached)h.push({prefix:"",files:await Eg(i)});else{if(!i.workTree)return I("this operation must be run in a work tree");h.push({prefix:"",files:await yg(i)})}let m=dt(i,r.cwd),p=null;c.length>0&&(p=c.map(G=>Ue(G,m)));let g=n.maxDepth,w=n.maxCount,b=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),E=!!n.filesWithMatches,k=!!n.filesWithoutMatch,R=!!n.count,x=!!n.quiet,y=!!n.heading,C=!!n.break,$=!!n.suppressFilename,D=!!n.invertMatch,P=!!n.allMatch,T=n.context??n.afterContext??0,A=n.context??n.beforeContext??0,U=T>0||A>0,_=[],O=!1,H=!0;for(let G of h){let B=G.files.slice().sort((F,ee)=>F.path<ee.path?-1:F.path>ee.path?1:0);for(let F of B){if(p&&!Ee(p,F.path)||g!==void 0&&Rg(F.path)>g)continue;let ee=await F.getContent(),V=Xl(ee,u,P,D),te=xg(F.path,m,!!n.fullName),ke=G.prefix;if(V.binary){if(O=!0,x)return{stdout:"",stderr:"",exitCode:0};E?_.push(`${ke}${te}`):!k&&!R&&_.push(`Binary file ${ke}${te} matches`);continue}if(V.matches.length===0){k&&_.push(`${ke}${te}`);continue}if(O=!0,x)return{stdout:"",stderr:"",exitCode:0};if(k)continue;if(E){_.push(`${ke}${te}`);continue}if(R){let ce=w!==void 0?Math.min(V.matches.length,w):V.matches.length;_.push(`${ke}${te}:${ce}`);continue}let Fe=V.matches;if(w!==void 0&&(Fe=Fe.slice(0,w)),U)Cg(_,ee,Fe,ke,te,$,A,T,y,C,H);else if(y){!H&&C&&_.push(""),_.push(`${ke}${te}`);for(let ce of Fe)b?_.push(`${ce.lineNo}:${ce.line}`):_.push(ce.line)}else{!H&&C&&_.push("");for(let ce of Fe){let Se=$?"":`${ke}${te}:`;b?_.push(`${Se}${ce.lineNo}:${ce.line}`):_.push(`${Se}${ce.line}`)}}H=!1}}return x?{stdout:"",stderr:"",exitCode:O?0:1}:{stdout:_.length>0?`${_.join(`
418
- `)}
419
- `:"",stderr:"",exitCode:O?0:1}}})}function Cg(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
420
- `);d.length>0&&d[d.length-1]===""&&d.pop();let u=new Set(n.map(g=>g.lineNo)),h=[];for(let g of n){let w=Math.max(1,g.lineNo-i),b=Math.min(d.length,g.lineNo+a);h.push([w,b])}let m=[];for(let[g,w]of h)m.length>0&&g<=m[m.length-1][1]+1?m[m.length-1][1]=Math.max(m[m.length-1][1],w):m.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<m.length;g++){g>0&&e.push("--");let[w,b]=m[g];for(let E=w;E<=b;E++){let k=d[E-1],x=u.has(E)?":":"-";c?e.push(`${E}${x}${k}`):e.push(`${p}${x}${E}${x}${k}`)}}}me();Nn();function Ql(e,t){e.command("init",{description:"Initialize a new repository",args:[K.string().name("directory").describe("The directory to initialize").optional()],options:{bare:S().describe("Create a bare repository"),initialBranch:Y.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?Dt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await to(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
427
+ `:""}async function Ia(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path),r=await cs(e.fs,n);return Sa.decode(r)}return oe(e,t.newHash)}async function Og(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path);return cs(e.fs,n)}return $t(e,t.newHash)}function rd(e,t){let n=xt(e),r=xt(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 sd(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?pn(r.oldPath,r.path):r.path,s=r.oldHash?await $t(e,r.oldHash):new Uint8Array(0),i=await Og(e,r);if(Nn(s)||Nn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=Sa.decode(s),c=Sa.decode(i),{ins:f,del:l}=rd(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}se();Ue();se();ie();Be();ge();async function Ko(e,t){return t.depth!==void 0&&t.unshallow?S("--depth and --unshallow cannot be used together"):t.unshallow&&!await xl(e)?S("--unshallow on a complete repository does not make sense"):{depth:t.unshallow?ba:t.depth}}async function zo(e,t,n,r=S){try{let o=await Uo(e,t,n);return o||r(`'${t}' does not appear to be a git repository`)}catch(o){let s=o instanceof Error?o.message:"";if(s.startsWith("network"))return r(s);throw o}}async function Ss(e){let n=(await ye(e)).map(o=>o.hash),r=await U(e,"HEAD");return r&&n.push(r),n}async function Vo(e,t){let n=t!==void 0?await jo(e):void 0;return{existingShallows:n,shallowOpts:t!==void 0?{depth:t,existingShallows:n}:void 0}}async function Yo(e){let{gitCtx:t,transport:n,remoteRefs:r,ident:o,reflogAction:s}=e,i=[];for(let f of r){if(!f.name.startsWith("refs/tags/")||await U(t,f.name))continue;let l=f.peeledHash??f.hash;await wt(t,l)&&i.push(f)}let a=[];for(let f of i)f.peeledHash&&!await wt(t,f.hash)&&a.push(f.hash);a.length>0&&await n.fetch(a,await Ss(t));let c=[];for(let f of i)await J(t,f.name,f.hash),await st(t,f.name,{oldHash:ne,newHash:f.hash,name:o.name,email:o.email,timestamp:o.timestamp,tz:o.tz,message:`${s}: storing head`}),c.push({prefix:" * [new tag]",from:Gt(f.name),to:Gt(f.name)});return c}sr();me();Be();ge();function kr(e){let t=e,n=!1;t.startsWith("+")&&(n=!0,t=t.slice(1));let r=t.indexOf(":");return r===-1?{force:n,src:t,dst:t}:{force:n,src:t.slice(0,r),dst:t.slice(r+1)}}function Sg(e,t){let n=e.indexOf("*");if(n===-1)return e===t;let r=e.slice(0,n),o=e.slice(n+1);return t.startsWith(r)&&t.endsWith(o)&&t.length>=r.length+o.length}function Is(e,t){if(!Sg(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function id(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:O().describe("Fetch from all remotes"),prune:O().alias("p").describe("Remove stale remote-tracking refs"),tags:O().describe("Also fetch tags"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:O().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Ko(s,n);if(M(i))return i;let{depth:a}=i;if(n.all){if(n.remote)return S("fetch --all does not take a remote argument");let f=await pe(s),l=[];for(let h of Object.keys(f)){let m=h.match(/^remote "(.+)"$/);m?.[1]&&l.push(m[1])}if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let d=[],u=0;for(let h of l){let m=await od(s,h,void 0,n.prune,n.tags,r.env,t,a);m.stderr&&d.push(m.stderr),m.exitCode!==0&&(u=m.exitCode)}return{stdout:"",stderr:d.join(""),exitCode:u}}let c=n.remote||"origin";return od(s,c,n.refspec,n.prune,n.tags,r.env,t,a)}})}function Ig(e,t){return!e||e.length===0?[t]:e.map(n=>{let r=kr(n);if(n.includes(":"))return r;for(let o of[r.src,`refs/heads/${r.src}`,`refs/tags/${r.src}`]){let s=Is(t,o);if(s!==null)return{force:r.force||t.force,src:o,dst:s}}return r})}function Tg(e,t){let n=[],r=new Set,o=[],s=new Array(t.length).fill(!1);for(let i of e)if(i.name!=="HEAD")for(let[a,c]of t.entries()){let f=Is(c,i.name);if(f!==null){s[a]=!0,o.push({remote:i,localRef:f,force:c.force}),r.has(i.hash)||(r.add(i.hash),n.push(i.hash));break}}return{wants:n,refUpdates:o,matchedSpecs:s}}function vg(e,t,n){if(!e||e.length===0)return null;for(let[r,o]of t.entries())if(!n[r]&&!o.src.includes("*"))return S(`couldn't find remote ref ${o.src}`);return null}async function Hg(e,t,n,r){let o=[],s=!1,i=[],a=[];for(let f of t){let l=await U(e,f.localRef);if(r&&f.remote.name.startsWith("refs/tags/")&&l&&l!==f.remote.hash){s=!0,a.push({prefix:" ! [rejected]",from:Gt(f.remote.name),to:Gt(f.localRef),suffix:" (would clobber existing tag)"});continue}i.push({...f,oldHash:l}),f.localRef.startsWith("refs/tags/")&&a.push({update:f,oldHash:l}),await J(e,f.localRef,f.remote.hash),await st(e,f.localRef,{oldHash:l??ne,newHash:f.remote.hash,name:n.name,email:n.email,timestamp:n.timestamp,tz:n.tz,message:l?"fetch":"fetch: storing head"})}let c=i.filter(f=>!f.localRef.startsWith("refs/tags/"));o.push(...us(c,Gt,X));for(let f of a){if("prefix"in f){o.push(f);continue}o.push(...us([{...f.update,oldHash:f.oldHash}],Gt,X))}return{refLines:o,hadTagRejection:s,appliedUpdates:i}}async function od(e,t,n,r,o,s,i,a){let c=await zo(e,t,s);if(M(c))return c;let{transport:f,config:l}=c,d=kr(l.fetchRefspec),u=Ig(n,d),h=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:u.map(T=>`${T.src}:${T.dst}`),prune:r,tags:o});if(de(h))return{stdout:"",stderr:h.message??"",exitCode:1};let m=await f.advertiseRefs();if(m.length===0){if(n&&n.length>0){for(let T of u)if(!T.src.includes("*"))return S(`couldn't find remote ref ${T.src}`)}return{stdout:"",stderr:"",exitCode:0}}let{wants:p,refUpdates:g,matchedSpecs:w}=Tg(m,u),b=vg(n,u,w);if(b)return b;let R=new Set(p);if(o)for(let T of m)T.name.startsWith("refs/tags/")&&(g.push({remote:T,localRef:T.name,force:!1}),R.has(T.hash)||(R.add(T.hash),p.push(T.hash)));let E=await Ss(e),k=new Set(E),x=p.filter(T=>!k.has(T)),{existingShallows:y,shallowOpts:P}=await Vo(e,a),C=x.length>0?x:P?p:[];if(C.length>0){let T=await f.fetch(C,E,P);T.shallowUpdates&&await Fr(e,T.shallowUpdates,y)}let A=await Mn(e,s),{refLines:D,hadTagRejection:$,appliedUpdates:v}=await Hg(e,g,A,o);if(o||D.push(...await Yo({gitCtx:e,transport:f,remoteRefs:m,ident:A,reflogAction:"fetch"})),r){let T=`refs/remotes/${t}`,G=await ye(e,T),W=new Set(m.filter(F=>F.name.startsWith("refs/heads/")).map(F=>F.name.slice(11)));for(let F of G){if((await e.refStore.readRef(F.name))?.type==="symbolic")continue;let ee=F.name.slice(T.length+1);ee!=="HEAD"&&(W.has(ee)||(await he(e,F.name),D.push({prefix:" - [deleted]",from:"(none)",to:`${t}/${ee}`})))}}let N=m.find(T=>T.name==="HEAD");if(N){let T=H(e.gitDir,"FETCH_HEAD"),G=m.find(F=>F.name.startsWith("refs/heads/")&&F.hash===N.hash),W=G?`branch '${G.name.slice(11)}' of`:"of";await e.fs.writeFile(T,`${N.hash} ${W} ${l.url}
428
+ `),(!n||n.length===0)&&await vr(e,t,m,f.headTarget)}let I={stdout:"",stderr:D.length>0?`From ${l.url}
429
+ ${Dr(D,10)}`:"",exitCode:$?1:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:v.length}),I}se();Ce();ie();me();Be();ge();Zs();Sr();me();async function Ag(e,t){let n=new Set,r=H(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let i of s){if(!i.endsWith(".idx"))continue;let a=await e.fs.readFileBuffer(H(r,i)),c=new Xt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Ur(await _r(e,t,[])):(await Ur(await _r(e,t,[]))).filter(s=>!n.has(s.hash))}async function Xo(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 Ur(await _r(t,r,[])):await Ag(t,r);if(a.length===0)return null;let c=a.length,f=No(a,{window:s,depth:i}),l=f.filter(x=>x.delta).length,d=f.map(x=>({hash:x.hash,type:x.type,content:x.content,delta:x.delta,deltaBaseHash:x.deltaBase})),{data:u,entries:h}=await Xs(d),m=await Wc(u,h),p=u.subarray(u.byteLength-20),g="";for(let x=0;x<20;x++){let y=p[x];g+=(y>>4).toString(16)+(y&15).toString(16)}let w=H(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let b=`pack-${g}`,R=H(w,`${b}.pack`),E=H(w,`${b}.idx`);await n.writeFile(R,u),await n.writeFile(E,m);let k=new Set(f.map(x=>x.hash));if(t.objectStore.invalidatePacks?.(),o){let x=await n.readdir(w);for(let C of x){if(!C.endsWith(".idx"))continue;let A=C.slice(0,-4);if(A===b)continue;let D=H(w,`${A}.idx`),$=!0;try{let v=await n.readFileBuffer(D),N=new Xt(v);for(let L of N.allHashes())if(!k.has(L)){$=!1;break}}catch{$=!1}if($){try{await n.rm(H(w,`${A}.pack`))}catch{}try{await n.rm(D)}catch{}}}let y=H(t.gitDir,"objects"),P;try{P=await n.readdir(y)}catch{P=[]}for(let C of P){if(C==="pack"||C==="info"||C.length!==2)continue;let A=H(y,C),D;try{D=await n.readdir(A)}catch{continue}for(let $ of D){let v=`${C}${$}`;k.has(v)&&await n.rm(H(A,$))}try{(await n.readdir(A)).length===0&&await n.rm(A,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function Zo(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(`
430
+ `)}function ad(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:O().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o;await ef(s),await Et(s);let i=await Mg(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await Xo({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(f)return{stdout:"",stderr:`${Zo(f.totalCount,f.deltaCount,!0)}
431
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Dg=2160*60*60;async function Mg(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ye(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Dg,i=H(e.gitDir,"logs");await e.fs.exists(i)&&await cd(e,i,i,s,t);let a=await V(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 U(e,f);l&&t.add(l)}let c=[];for(let f of t)await wt(e,f)&&c.push(f);return c}async function cd(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=H(t,i),c=await e.fs.stat(a);if(c.isDirectory){await cd(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 u of l)u.newHash!==ne&&o.add(u.newHash);continue}let d=l.filter(u=>u.timestamp>=r);await Un(e,f,d);for(let u of d)u.newHash!==ne&&o.add(u.newHash)}}}se();function jg(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 fd(e,t,n,r){if(jg(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
432
+ `);if(o.length>0&&o[o.length-1]===""&&o.pop(),n&&t.length>1&&!t.every(a=>o.some(c=>a.test(c))))return{matches:[],binary:!1};let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.some(f=>f.test(a));(r?!c:c)&&s.push({lineNo:i+1,line:a})}return{matches:s,binary:!1}}function Lg(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ld(e,t){let n=t?.fixed?Lg(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ie();me();Ae();async function Gg(e){let t=await V(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=H(e.workTree,o.path);r.push({path:o.path,getContent:async()=>{try{return await e.fs.readFile(s)}catch{return""}}})}return r}async function Ng(e){let t=await V(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 Fg(e,t){return(await qe(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>oe(e,r.hash)}))}function _g(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Ug(e,t,n){return n||t===""?e:rt(t,e)}function dd(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[q.string().name("args").variadic().optional()],options:{cached:O().describe("Search blobs registered in the index"),lineNumber:O().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:O().alias("l").describe("Show only filenames"),filesWithoutMatch:O().alias("L").describe("Show only filenames without matches"),count:O().alias("c").describe("Show count of matching lines per file"),ignoreCase:O().alias("i").describe("Case insensitive matching"),wordRegexp:O().alias("w").describe("Match whole words only"),invertMatch:O().alias("v").describe("Invert the sense of matching"),fixedStrings:O().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:O().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:O().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:O().alias("h").describe("Suppress filename prefix"),forceFilename:O().alias("H").describe("Force filename prefix"),fullName:O().describe("Force paths to be output relative to project top"),quiet:O().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:O().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:O().describe("Show filename above matches"),break:O().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 K(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 u=[];for(let W of f){let F=ld(W,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!F)return S(`command line, '${W}': invalid regular expression`);u.push(F)}let h=[];if(l.length>0)for(let W of l){let F=await yt(i,W);if(M(F))return F;let B;try{B=await Te(i,F)}catch{return S(`bad revision '${W}'`)}let ee=await j(i,B),z=await Fg(i,ee.tree);h.push({prefix:`${W}:`,files:z})}else if(n.cached)h.push({prefix:"",files:await Ng(i)});else{if(!i.workTree)return S("this operation must be run in a work tree");h.push({prefix:"",files:await Gg(i)})}let m=ut(i,r.cwd),p=null;c.length>0&&(p=c.map(W=>_e(W,m)));let g=n.maxDepth,w=n.maxCount,b=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),R=!!n.filesWithMatches,E=!!n.filesWithoutMatch,k=!!n.count,x=!!n.quiet,y=!!n.heading,P=!!n.break,C=!!n.suppressFilename,A=!!n.invertMatch,D=!!n.allMatch,$=n.context??n.afterContext??0,v=n.context??n.beforeContext??0,N=$>0||v>0,L=[],I=!1,T=!0;for(let W of h){let F=W.files.slice().sort((B,ee)=>B.path<ee.path?-1:B.path>ee.path?1:0);for(let B of F){if(p&&!Ee(p,B.path)||g!==void 0&&_g(B.path)>g)continue;let ee=await B.getContent(),z=fd(ee,u,D,A),Q=Ug(B.path,m,!!n.fullName),Re=W.prefix;if(z.binary){if(I=!0,x)return{stdout:"",stderr:"",exitCode:0};R?L.push(`${Re}${Q}`):!E&&!k&&L.push(`Binary file ${Re}${Q} matches`);continue}if(z.matches.length===0){E&&L.push(`${Re}${Q}`);continue}if(I=!0,x)return{stdout:"",stderr:"",exitCode:0};if(E)continue;if(R){L.push(`${Re}${Q}`);continue}if(k){let ce=w!==void 0?Math.min(z.matches.length,w):z.matches.length;L.push(`${Re}${Q}:${ce}`);continue}let Ne=z.matches;if(w!==void 0&&(Ne=Ne.slice(0,w)),N)Bg(L,ee,Ne,Re,Q,C,v,$,y,P,T);else if(y){!T&&P&&L.push(""),L.push(`${Re}${Q}`);for(let ce of Ne)b?L.push(`${ce.lineNo}:${ce.line}`):L.push(ce.line)}else{!T&&P&&L.push("");for(let ce of Ne){let Se=C?"":`${Re}${Q}:`;b?L.push(`${Se}${ce.lineNo}:${ce.line}`):L.push(`${Se}${ce.line}`)}}T=!1}}return x?{stdout:"",stderr:"",exitCode:I?0:1}:{stdout:L.length>0?`${L.join(`
433
+ `)}
434
+ `:"",stderr:"",exitCode:I?0:1}}})}function Bg(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
435
+ `);d.length>0&&d[d.length-1]===""&&d.pop();let u=new Set(n.map(g=>g.lineNo)),h=[];for(let g of n){let w=Math.max(1,g.lineNo-i),b=Math.min(d.length,g.lineNo+a);h.push([w,b])}let m=[];for(let[g,w]of h)m.length>0&&g<=m[m.length-1][1]+1?m[m.length-1][1]=Math.max(m[m.length-1][1],w):m.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<m.length;g++){g>0&&e.push("--");let[w,b]=m[g];for(let R=w;R<=b;R++){let E=d[R-1],x=u.has(R)?":":"-";c?e.push(`${R}${x}${E}`):e.push(`${p}${x}${R}${x}${E}`)}}}me();kn();function ud(e,t){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:O().describe("Create a bare repository"),initialBranch:Y.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?Mt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await Qs(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
421
436
  `);let f=n.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${f}Git repository in ${i.gitDir}/
422
- `,stderr:c,exitCode:0}}})}se();dr();var Yo=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:ed(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,ed(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 ed(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}se();function vs(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+=rd(c.timestamp,c.timezone),s+=3;continue;case"i":o+=sd(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Xo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=id(c.timestamp,c.timezone),s+=3;continue;case"r":o+=od(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=Z(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=Z(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(Z).join(" "),s+=2;continue;case"s":o+=Ca(r.message),s+=2;continue;case"b":o+=Pg(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+=`
423
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Ca=ue;function Pg(e){let t=e.indexOf(`
437
+ `,stderr:c,exitCode:0}}})}se();ur();var Jo=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:hd(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,hd(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 hd(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}se();function Ts(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+=gd(c.timestamp,c.timezone),s+=3;continue;case"i":o+=wd(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Qo(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=yd(c.timestamp,c.timezone),s+=3;continue;case"r":o+=bd(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=X(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=X(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(X).join(" "),s+=2;continue;case"s":o+=Ta(r.message),s+=2;continue;case"b":o+=Wg(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
438
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var Ta=ue;function Wg(e){let t=e.indexOf(`
424
439
 
425
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Zo(e){return e.startsWith("format:")?{formatStr:e.slice(7),preset:null}:e.startsWith("tformat:")?{formatStr:e.slice(8),preset:null}:["oneline","short","medium","full","fuller","raw"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function As(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?Z(o):o,c=Ca(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${Ca(s.message)}`),a.join(`
426
- `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
440
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function ei(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 vs(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?X(o):o,c=Ta(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${Ta(s.message)}`),a.join(`
441
+ `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
427
442
  `))a.push(` ${f}`);return a.join(`
428
- `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(Z).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Xo(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Xo(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
443
+ `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Qo(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Qo(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
429
444
  `))a.push(` ${f}`);return a.join(`
430
- `)}case"raw":return $g(t,n);default:return Og(t,n)}}function $g(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(`
445
+ `)}case"raw":return qg(t,n);default:return Kg(t,n)}}function qg(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(`
431
446
  `))o.push(` ${i}`);return o.join(`
432
- `)}function Og(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(Z).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Xo(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
447
+ `)}function Kg(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(X).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Qo(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
433
448
  `))s.push(` ${a}`);return s.join(`
434
- `)}var td=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],nd=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Sg(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 Jo(e,t){let n=Sg(t);return new Date((e+n*60)*1e3)}function Ig(e){return`${e.slice(0,3)}:${e.slice(3)}`}function rd(e,t){let n=Jo(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":Ig(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function sd(e,t){let n=Jo(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 od(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 Tg(e,t){let n=Jo(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 vg(e,t){return`${e} ${t}`}function Ag(e){return e.toString()}function Hg(e,t){let n=new Date(e*1e3),r=td[n.getDay()]?.slice(0,3),o=nd[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 Xo(e,t,n){switch(n){case"short":return Tg(e,t);case"iso":return sd(e,t);case"iso-strict":return rd(e,t);case"relative":case"human":return od(e);case"rfc":return id(e,t);case"raw":return vg(e,t);case"unix":return Ag(e);case"local":return Hg(e,t);default:return On(e,t)}}function id(e,t){let n=Jo(e,t),r=td[n.getUTCDay()]?.slice(0,3),o=nd[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();ge();cn();De();function fd(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[K.string().name("revisions").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of commits to output"),oneline:S().describe("Condense each commit to a single line"),all:S().describe("Walk all refs, not just HEAD"),author:Y.string().describe("Filter by author (regex or substring)"),grep:Y.string().describe("Filter by commit message (regex or substring)"),since:Y.string().describe("Show commits after date"),after:Y.string().describe("Synonym for --since"),until:Y.string().describe("Show commits before date"),before:Y.string().describe("Synonym for --until"),decorate:S().describe("Show ref names next to commit hashes"),reverse:S().describe("Output commits in reverse order"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name"),patch:S().alias("p").describe("Show diff in patch format"),stat:S().describe("Show diffstat summary"),nameStatus:S().describe("Show names and status of changed files"),nameOnly:S().describe("Show only names of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),graph:S().describe("Draw text-based graph of the commit history"),firstParent:S().describe("Follow only the first parent of merge commits"),date:Y.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?qo(f[0]):null;if(l){let V=async Se=>{let ut=await We(i,Se);if(!ut)return Qt(Se);try{return await He(i,ut)}catch{return Qt(Se)}},te=await V(l.left);if(typeof te=="object"&&"exitCode"in te)return te;let ke=await V(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let Fe=te,ce=ke;if(l.type==="two-dot")a=[ce],c=[Fe];else{a=[Fe,ce];let Se=await Wt(i,Fe,ce);c=Se.length>0?Se:void 0}if(n.all){let Se=await we(i);for(let Rr of Se)try{let Xe=await He(i,Rr.hash);a.includes(Xe)||a.push(Xe)}catch{}let ut=await X(i);ut&&!a.includes(ut)&&a.push(ut)}}else if(n.all){let V=await we(i),te=new Set;for(let Fe of V)try{te.add(await He(i,Fe.hash))}catch{}let ke=await X(i);ke&&te.add(ke),a=[...te]}else if(f&&f.length>0){let V=[];for(let te of f){let ke=await We(i,te);if(!ke)return Qt(te);try{V.push(await He(i,ke))}catch{return Qt(te)}}a=V}else{let V=await Je(i);if(M(V))return V;a=[V]}if(a.length===0)return I("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(V=>Ue(V,"")):null,u=n.author?ad(n.author):null,h=n.grep?ad(n.grep):null,m=n.since??n.after,p=n.until??n.before,g=m?aa(m):null,w=p?aa(p):null,b=n.format??n.pretty,E=null,k=null,R=!1;if(n.oneline)k="oneline",R=!0;else if(b!==void 0){let V=Zo(b);E=V.formatStr,k=V.preset}let x=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!x.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
435
- `,exitCode:128};let y=n.date,C=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,$=n.graph;if($&&n.reverse)return I("options '--graph' and '--reverse' cannot be used together");let P=n.decorate||E!=null&&(E.includes("%d")||E.includes("%D"))?await jg(i):null,T=P?V=>cd(P,V):void 0,A=P?V=>{let te=cd(P,V);return te.startsWith("(")&&te.endsWith(")")?te.slice(1,-1):te}:void 0,U=n.maxCount,_=n.reverse,O=n.firstParent,H=d?Mg(i,a,d,c?await Dg(i,c):void 0,O):Nt(i,a,{exclude:c,topoOrder:$,firstParent:O}),L=[];for await(let V of H){if(U!==void 0&&L.length>=U)break;let{commit:te}=V;if(!(w!==null&&te.committer.timestamp>w)&&!(g!==null&&te.committer.timestamp<=g)){if(u){let ke=`${te.author.name} <${te.author.email}>`;if(!u(ke))continue}h&&!h(te.message)||L.push(V)}}let G=_?L.reverse():L;if($)return Lg(G,i,E,k,R,C,T,A,y);if(E!==null){let V=[];for(let te of G){let ke={hash:te.hash,commit:te.commit,decorations:T,decorationsRaw:A,dateMode:y},Fe=vs(E,ke),ce=await Pa(i,te.commit,C);ce&&(Fe+=`
449
+ `)}var md=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],pd=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function zg(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 ti(e,t){let n=zg(t);return new Date((e+n*60)*1e3)}function Vg(e){return`${e.slice(0,3)}:${e.slice(3)}`}function gd(e,t){let n=ti(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":Vg(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function wd(e,t){let n=ti(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 bd(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 Yg(e,t){let n=ti(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0");return`${r}-${o}-${s}`}function Xg(e,t){return`${e} ${t}`}function Zg(e){return e.toString()}function Jg(e,t){let n=new Date(e*1e3),r=md[n.getDay()]?.slice(0,3),o=pd[n.getMonth()],s=n.getDate(),i=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0"),f=n.getFullYear();return`${r} ${o} ${s} ${i}:${a}:${c} ${f}`}function Qo(e,t,n){switch(n){case"short":return Yg(e,t);case"iso":return wd(e,t);case"iso-strict":return gd(e,t);case"relative":case"human":return bd(e);case"rfc":return yd(e,t);case"raw":return Xg(e,t);case"unix":return Zg(e);case"local":return Jg(e,t);default:return Tn(e,t)}}function yd(e,t){let n=ti(e,t),r=md[n.getUTCDay()]?.slice(0,3),o=pd[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();ge();fn();Ae();function Rd(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:O().describe("Condense each commit to a single line"),all:O().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:O().describe("Show ref names next to commit hashes"),reverse:O().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:O().alias("p").describe("Show diff in patch format"),stat:O().describe("Show diffstat summary"),nameStatus:O().describe("Show names and status of changed files"),nameOnly:O().describe("Show only names of changed files"),shortstat:O().describe("Show only the shortstat summary line"),numstat:O().describe("Machine-readable insertions/deletions per file"),graph:O().describe("Draw text-based graph of the commit history"),firstParent:O().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 K(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Wo(f[0]):null;if(l){let z=async Se=>{let ht=await We(i,Se);if(!ht)return Jt(Se);try{return await Te(i,ht)}catch{return Jt(Se)}},Q=await z(l.left);if(typeof Q=="object"&&"exitCode"in Q)return Q;let Re=await z(l.right);if(typeof Re=="object"&&"exitCode"in Re)return Re;let Ne=Q,ce=Re;if(l.type==="two-dot")a=[ce],c=[Ne];else{a=[Ne,ce];let Se=await qt(i,Ne,ce);c=Se.length>0?Se:void 0}if(n.all){let Se=await ye(i);for(let Rr of Se)try{let Xe=await Te(i,Rr.hash);a.includes(Xe)||a.push(Xe)}catch{}let ht=await Z(i);ht&&!a.includes(ht)&&a.push(ht)}}else if(n.all){let z=await ye(i),Q=new Set;for(let Ne of z)try{Q.add(await Te(i,Ne.hash))}catch{}let Re=await Z(i);Re&&Q.add(Re),a=[...Q]}else if(f&&f.length>0){let z=[];for(let Q of f){let Re=await We(i,Q);if(!Re)return Jt(Q);try{z.push(await Te(i,Re))}catch{return Jt(Q)}}a=z}else{let z=await Qe(i);if(M(z))return z;a=[z]}if(a.length===0)return S("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(z=>_e(z,"")):null,u=n.author?Ed(n.author):null,h=n.grep?Ed(n.grep):null,m=n.since??n.after,p=n.until??n.before,g=m?ua(m):null,w=p?ua(p):null,b=n.format??n.pretty,R=null,E=null,k=!1;if(n.oneline)E="oneline",k=!0;else if(b!==void 0){let z=ei(b);R=z.formatStr,E=z.preset}let x=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!x.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
450
+ `,exitCode:128};let y=n.date,P=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,C=n.graph;if(C&&n.reverse)return S("options '--graph' and '--reverse' cannot be used together");let D=n.decorate||R!=null&&(R.includes("%d")||R.includes("%D"))?await tw(i):null,$=D?z=>kd(D,z):void 0,v=D?z=>{let Q=kd(D,z);return Q.startsWith("(")&&Q.endsWith(")")?Q.slice(1,-1):Q}:void 0,N=n.maxCount,L=n.reverse,I=n.firstParent,T=d?ew(i,a,d,c?await Qg(i,c):void 0,I):Ft(i,a,{exclude:c,topoOrder:C,firstParent:I}),G=[];for await(let z of T){if(N!==void 0&&G.length>=N)break;let{commit:Q}=z;if(!(w!==null&&Q.committer.timestamp>w)&&!(g!==null&&Q.committer.timestamp<=g)){if(u){let Re=`${Q.author.name} <${Q.author.email}>`;if(!u(Re))continue}h&&!h(Q.message)||G.push(z)}}let W=L?G.reverse():G;if(C)return nw(W,i,R,E,k,P,$,v,y);if(R!==null){let z=[];for(let Q of W){let Re={hash:Q.hash,commit:Q.commit,decorations:$,decorationsRaw:v,dateMode:y},Ne=Ts(R,Re),ce=await va(i,Q.commit,P);ce&&(Ne+=`
436
451
 
437
- ${ce.replace(/\n$/,"")}`),V.push(Fe)}return{stdout:V.length>0?`${V.join(`
452
+ ${ce.replace(/\n$/,"")}`),z.push(Ne)}return{stdout:z.length>0?`${z.join(`
438
453
  `)}
439
- `:"",stderr:"",exitCode:0}}let B=k??"medium",F=B==="oneline",ee=[];for(let V=0;V<G.length;V++){let te=G[V],ke={hash:te.hash,commit:te.commit,decorations:T,decorationsRaw:A,dateMode:y},Fe=As(B,ke,V===0,R),ce=await Pa(i,te.commit,C);ce&&(Fe+=`${F?`
454
+ `:"",stderr:"",exitCode:0}}let F=E??"medium",B=F==="oneline",ee=[];for(let z=0;z<W.length;z++){let Q=W[z],Re={hash:Q.hash,commit:Q.commit,decorations:$,decorationsRaw:v,dateMode:y},Ne=vs(F,Re,z===0,k),ce=await va(i,Q.commit,P);ce&&(Ne+=`${B?`
440
455
  `:`
441
456
 
442
- `}${ce.replace(/\n$/,"")}`),ee.push(Fe)}return{stdout:ee.length>0?`${ee.join(`
443
- `)}
444
- `:"",stderr:"",exitCode:0}}})}async function Dg(e,t){let n=new Set;for await(let r of Nt(e,t))n.add(r.hash);return n}function ad(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Mg(e,t,n,r,o){let s=new Set(r),i=new Kn,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await Ve(e,null,f.tree)).some(h=>Ee(n,h.path))&&(yield c);continue}if(l.length===1){let u=l[0];if(u){try{let h=await j(e,u);(await Ve(e,h.tree,f.tree)).some(p=>Ee(n,p.path))&&(yield c)}catch{yield c}await a(u)}continue}let d=[];for(let u of l)try{let h=await j(e,u);(await Ve(e,h.tree,f.tree)).some(p=>Ee(n,p.path))||d.push(u)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let u of l)await a(u)}}}async function jg(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await X(e),o=new Map,s=(f,l,d)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:l,fullRef:d})},i=await we(e,"refs/heads");for(let f of i)s(f.hash,Pe(f.name),f.name);let a=await we(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await we(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await He(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function cd(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 Lg(e,t,n,r,o,s,i,a,c){let f=new Yo,l=r??"medium",d=l==="oneline",u=[];for(let h=0;h<e.length;h++){let m=e[h],p={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=vs(n,p):g=As(l,p,!0,o),f.update(m.hash,m.commit.parents),h>0&&!d&&n===null&&u.push(f.paddingPrefix());let w=g.split(`
445
- `),b=0;for(;;){let{prefix:R,isCommitLine:x}=f.nextLine();if(x){u.push(R+(w[b++]??""));break}u.push(R)}for(;b<w.length;){let{prefix:R}=f.nextLine();u.push(R+w[b++])}for(;!f.isFinished();){let{prefix:R}=f.nextLine();u.push(R)}let E=80-f.width,k=await Pa(t,m.commit,s,E);if(k){let R=k.replace(/\n$/,"").split(`
446
- `);if(d||n!==null)for(let x of R)u.push(f.paddingPrefix()+x);else{u.push(f.paddingPrefix());for(let x of R)u.push(f.paddingPrefix()+x)}}}return{stdout:u.length>0?`${u.join(`
447
- `)}
448
- `:"",stderr:"",exitCode:0}}async function Pa(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 st(e,s);switch(n){case"name-only":return Gg(i,a);case"name-status":return Ng(i,a);case"stat":return Fg(e,i,a,r);case"shortstat":return _g(e,i,a);case"numstat":return Ug(e,i,a);case"patch":return Bg(e,i,a)}}function Gg(e,t){let n=[];for(let r of e)n.push({key:r.path,line:r.path});for(let r of t)n.push({key:r.newPath,line:r.newPath});return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
449
- `).join("")}function Ng(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}
450
- `).join("")}async function Fg(e,t,n,r){let{fileStats:o}=await er(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),pr(o,r)}async function _g(e,t,n){let{fileStats:r}=await er(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Qn(r.length,o,s);return i?`${i}
451
- `:""}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:hn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Ae(i)||Ae(a))o+=`- - ${s.display}
452
- `;else{let c=xt(i),f=xt(a),l=it(c,f),d=0,u=0;for(let h of l)h.type==="insert"?d++:h.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
453
- `}}return o}async function Bg(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+=vt({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+=vt({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();me();kn();et();function dd(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:S().alias("c").describe("Show cached files (default)"),modified:S().alias("m").describe("Show modified files"),deleted:S().alias("d").describe("Show deleted files"),others:S().alias("o").describe("Show other (untracked) files"),unmerged:S().alias("u").describe("Show unmerged files"),stage:S().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":S().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":S().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":S().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,u=n.others,h=n.unmerged,m=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||u||h||(f=!0);let E=await z(i),k=g?"\0":`
454
- `,R=o.passthrough.length>0?o.passthrough.map(C=>{let $=r.cwd!==c?Wg(c,r.cwd):"";return Ue(C,$)}):null,x=[];if(f)for(let C of E.entries){if(R&&!Ee(R,C.path))continue;let $=w?C.stage>0?"M":"H":null;x.push(ld(C,m,$))}if(h&&!f)for(let C of E.entries)C.stage!==0&&(R&&!Ee(R,C.path)||x.push(ld(C,!0,w?"M":null)));if(l||d){let C=await qg(i,c,E);for(let{path:$,status:D}of C){if(D==="modified"&&!l||D==="deleted"&&!d||R&&!Ee(R,$))continue;let P=w?D==="deleted"?"R":"C":null;x.push(P?`${P} ${$}`:$)}}if(u){let C=await Kg(i,c,E,p);for(let $ of C)R&&!Ee(R,$)||x.push(w?`? ${$}`:$)}return{stdout:x.length>0?x.join(k)+k:"",stderr:"",exitCode:0}}})}function ld(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 Wg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function qg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=v(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await mt(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Un(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Kg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await rt(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}se();dr();Be();Ce();ie();Ke();ge();cn();De();function ud(e,t){e.command("merge",{description:"Join two or more development histories together",args:[K.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:S().describe("Abort the current in-progress merge"),continue:S().describe("Continue the merge after conflict resolution"),noFf:S().describe("Create a merge commit even when fast-forward is possible"),ffOnly:S().describe("Refuse to merge unless fast-forward is possible"),squash:S().describe("Apply merge result to worktree/index without creating a merge commit"),edit:S().describe("Edit the merge message (no-op, accepted for compatibility)"),message:Y.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Zg(s,r.env);if(n.continue)return Xg(s,r.env,t);let i=n.branch;if(!i)return I("you must specify a branch to merge");let a=await Je(s);if(M(a))return a;let c=await z(s),f=Pn(c,"Merging");if(f)return f;if(await W(s,"MERGE_HEAD"))return I(`You have not concluded your merge (MERGE_HEAD exists).
455
- Please, commit your changes before you merge.`);if(await W(s,"CHERRY_PICK_HEAD"))return I(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
456
- Please, commit your changes before you merge.`);let u=await We(s,i);if(!u)return N(`merge: ${i} - not something we can merge
457
- `);let h=await He(s,u),m=await Wt(s,a,h),p=m[0]??null;if(m.length===0)return I("refusing to merge unrelated histories");if(p===h)return await be(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
458
- `,stderr:"",exitCode:0};let g=!!n.noFf,w=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let R=await xe(s,"merge.ff");R==="false"?g=!0:R==="only"&&(w=!0)}if(g&&w)return I("--no-ff and --ff-only are incompatible");let b=p===a&&!g;if(w&&!b)return N(`hint: Diverging branches can't be fast-forwarded, you need to either:
457
+ `}${ce.replace(/\n$/,"")}`),ee.push(Ne)}return{stdout:ee.length>0?`${ee.join(`
458
+ `)}
459
+ `:"",stderr:"",exitCode:0}}})}async function Qg(e,t){let n=new Set;for await(let r of Ft(e,t))n.add(r.hash);return n}function Ed(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*ew(e,t,n,r,o){let s=new Set(r),i=new Kn,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await Ve(e,null,f.tree)).some(h=>Ee(n,h.path))&&(yield c);continue}if(l.length===1){let u=l[0];if(u){try{let h=await j(e,u);(await Ve(e,h.tree,f.tree)).some(p=>Ee(n,p.path))&&(yield c)}catch{yield c}await a(u)}continue}let d=[];for(let u of l)try{let h=await j(e,u);(await Ve(e,h.tree,f.tree)).some(p=>Ee(n,p.path))||d.push(u)}catch{}if(d.length>0&&d[0])await a(d[0]);else{yield c;for(let u of l)await a(u)}}}async function tw(e){let t=await te(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await Z(e),o=new Map,s=(f,l,d)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:l,fullRef:d})},i=await ye(e,"refs/heads");for(let f of i)s(f.hash,Pe(f.name),f.name);let a=await ye(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await ye(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await Te(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function kd(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 nw(e,t,n,r,o,s,i,a,c){let f=new Jo,l=r??"medium",d=l==="oneline",u=[];for(let h=0;h<e.length;h++){let m=e[h],p={hash:m.hash,commit:m.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=Ts(n,p):g=vs(l,p,!0,o),f.update(m.hash,m.commit.parents),h>0&&!d&&n===null&&u.push(f.paddingPrefix());let w=g.split(`
460
+ `),b=0;for(;;){let{prefix:k,isCommitLine:x}=f.nextLine();if(x){u.push(k+(w[b++]??""));break}u.push(k)}for(;b<w.length;){let{prefix:k}=f.nextLine();u.push(k+w[b++])}for(;!f.isFinished();){let{prefix:k}=f.nextLine();u.push(k)}let R=80-f.width,E=await va(t,m.commit,s,R);if(E){let k=E.replace(/\n$/,"").split(`
461
+ `);if(d||n!==null)for(let x of k)u.push(f.paddingPrefix()+x);else{u.push(f.paddingPrefix());for(let x of k)u.push(f.paddingPrefix()+x)}}}return{stdout:u.length>0?`${u.join(`
462
+ `)}
463
+ `:"",stderr:"",exitCode:0}}async function va(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 rw(i,a);case"name-status":return sw(i,a);case"stat":return ow(e,i,a,r);case"shortstat":return iw(e,i,a);case"numstat":return aw(e,i,a);case"patch":return cw(e,i,a)}}function rw(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}
464
+ `).join("")}function sw(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}
465
+ `).join("")}async function ow(e,t,n,r){let{fileStats:o}=await tr(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),pr(o,r)}async function iw(e,t,n){let{fileStats:r}=await tr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=er(r.length,o,s);return i?`${i}
466
+ `:""}async function aw(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:pn(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(je(i)||je(a))o+=`- - ${s.display}
467
+ `;else{let c=xt(i),f=xt(a),l=ct(c,f),d=0,u=0;for(let h of l)h.type==="insert"?d++:h.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
468
+ `}}return o}async function cw(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+=Ht({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await oe(e,i.oldHash):"",c=i.newHash?await oe(e,i.newHash):"";o+=Ht({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}se();Ce();me();Pn();Je();function Cd(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",args:[q.string().name("pathspec").variadic().optional()],options:{cached:O().alias("c").describe("Show cached files (default)"),modified:O().alias("m").describe("Show modified files"),deleted:O().alias("d").describe("Show deleted files"),others:O().alias("o").describe("Show other (untracked) files"),unmerged:O().alias("u").describe("Show unmerged files"),stage:O().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":O().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":O().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":O().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await K(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,u=n.others,h=n.unmerged,m=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||u||h||(f=!0);let R=await V(i),E=g?"\0":`
469
+ `,k=[...n.pathspec??[],...o.passthrough],x=k.length>0?k.map(C=>{let A=r.cwd!==c?fw(c,r.cwd):"";return _e(C,A)}):null,y=[];if(f)for(let C of R.entries){if(x&&!Ee(x,C.path))continue;let A=w?C.stage>0?"M":"H":null;y.push(xd(C,m,A))}if(h&&!f)for(let C of R.entries)C.stage!==0&&(x&&!Ee(x,C.path)||y.push(xd(C,!0,w?"M":null)));if(l||d){let C=await lw(i,c,R);for(let{path:A,status:D}of C){if(D==="modified"&&!l||D==="deleted"&&!d||x&&!Ee(x,A))continue;let $=w?D==="deleted"?"R":"C":null;y.push($?`${$} ${A}`:A)}}if(u){let C=await dw(i,c,R,p);for(let A of C)x&&!Ee(x,A)||y.push(w?`? ${A}`:A)}return{stdout:y.length>0?y.join(E)+E:"",stderr:"",exitCode:0}}})}function xd(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 fw(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function lw(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=H(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let a=await mt(e.fs,s);if(!a.isFile&&!a.isSymbolicLink)continue;await Wn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function dw(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await ot(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}se();ur();Ue();Ce();ie();Be();ge();fn();Ae();function Pd(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:O().describe("Abort the current in-progress merge"),continue:O().describe("Continue the merge after conflict resolution"),noFf:O().describe("Create a merge commit even when fast-forward is possible"),ffOnly:O().describe("Refuse to merge unless fast-forward is possible"),squash:O().describe("Apply merge result to worktree/index without creating a merge commit"),edit:O().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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return gw(s,r.env);if(n.continue)return pw(s,r.env,t);let i=n.branch;if(!i)return S("you must specify a branch to merge");if(n.squash&&n.noFf)return S("options '--squash' and '--no-ff.' cannot be used together");let a=await Qe(s);if(M(a))return a;let c=await V(s),f=Sn(c,"Merging");if(f)return f;if(await U(s,"MERGE_HEAD"))return S(`You have not concluded your merge (MERGE_HEAD exists).
470
+ Please, commit your changes before you merge.`);if(await U(s,"CHERRY_PICK_HEAD"))return S(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
471
+ Please, commit your changes before you merge.`);let u=await We(s,i);if(!u)return _(`merge: ${i} - not something we can merge
472
+ `);let h=await Te(s,u),m=!!n.noFf,p=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let k=await ke(s,"merge.ff");k==="false"?m=!0:k==="only"&&(p=!0)}if(n.squash&&m)return S("options '--squash' and '--no-ff.' cannot be used together");let g=await qt(s,a,h),w=g[0]??null;if(g.length===0)return S("refusing to merge unrelated histories");if(w===h)return await be(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
473
+ `,stderr:"",exitCode:0};if(m&&p)return S("--no-ff and --ff-only are incompatible");let b=w===a&&!m;if(p&&!b)return _(`hint: Diverging branches can't be fast-forwarded, you need to either:
459
474
  hint:
460
475
  hint: git merge --no-ff
461
476
  hint:
@@ -465,42 +480,42 @@ hint: git rebase
465
480
  hint:
466
481
  hint: Disable this message with "git config set advice.diverging false"
467
482
  fatal: Not possible to fast-forward, aborting.
468
- `,128);if(await W(s,"REVERT_HEAD")&&await St(s),b&&!n.squash){let R=await Q(s),x=await jo(s,a,h);if(x.exitCode===0&&n.message&&(x.stdout=x.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),x.exitCode===0){await be(s,"MERGE_MSG");let y=R?.type==="symbolic"?R.target:"HEAD";await re(s,r.env,y,a,h,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,R?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:h,strategy:"fast-forward",commitHash:null})}return x}let E=n.message,k=E?E.endsWith(`
469
- `)?E:`${E}
470
- `:void 0;return n.squash?Yg(s,a,h,i,r.env,t,k):zg(s,a,h,i,r.env,g,t,k)}})}async function zg(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await Q(e),l=f?.type==="symbolic"?Pe(f.target):"HEAD",d=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:r,conflictStyle:d},h=await xs(e,t,n,u,i?.mergeDriver),m=await Sn(e,h,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!m.ok)return await be(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(h.conflicts.length>0){await J(e,"MERGE_HEAD",n),await J(e,"ORIG_HEAD",t);let D=a??await gr(e,r,l),P={repo:e,message:D,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},T=await i?.hooks?.mergeMsg?.(P);if(fe(T))return{stdout:"",stderr:T.message??"",exitCode:1};D=P.message;let A=Kt({version:2,entries:h.entries}).sort();return D+=`
483
+ `,128);if(await U(s,"REVERT_HEAD")&&await _t(s),b&&!n.squash){let k=await te(s),x=await Do(s,a,h);if(x.exitCode===0&&n.message&&(x.stdout=x.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),x.exitCode===0){await be(s,"MERGE_MSG");let y=k?.type==="symbolic"?k.target:"HEAD";await re(s,r.env,y,a,h,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,k?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:h,strategy:"fast-forward",commitHash:null})}return x}let R=n.message,E=R?R.endsWith(`
484
+ `)?R:`${R}
485
+ `:void 0;return n.squash?mw(s,a,h,i,r.env,t,E):uw(s,a,h,i,r.env,m,t,E)}})}async function uw(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await te(e),l=f?.type==="symbolic"?Pe(f.target):"HEAD",d=await ke(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:r,conflictStyle:d},h=await Rs(e,t,n,u,i?.mergeDriver),m=await Hn(e,h,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!m.ok)return await be(e,"MERGE_MSG"),m.failureKind==="staged"&&f?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(h.conflicts.length>0){await J(e,"MERGE_HEAD",n),await J(e,"ORIG_HEAD",t);let A=a??await gr(e,r,l),D={repo:e,message:A,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},$=await i?.hooks?.mergeMsg?.(D);if(de($))return{stdout:"",stderr:$.message??"",exitCode:1};A=D.message;let v=zt({version:2,entries:h.entries}).sort();return A+=`
471
486
  # Conflicts:
472
- ${A.map(_=>`# ${_}`).join(`
487
+ ${v.map(L=>`# ${L}`).join(`
473
488
  `)}
474
- `,await Me(e,"MERGE_MSG",D),await Me(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...h.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
489
+ `,await Le(e,"MERGE_MSG",A),await Le(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...h.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
475
490
  `)}
476
- `,stderr:"",exitCode:1}}await be(e,"MERGE_MSG");let p=m.mergedTreeHash,g=await un(e,o);if(M(g))return g;let w=await tt(e,o);if(M(w))return w;let b=a??await gr(e,r,l),E={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},k=await i?.hooks?.mergeMsg?.(E);if(fe(k))return{stdout:"",stderr:k.message??"",exitCode:1};b=E.message;let R=await i?.hooks?.preMergeCommit?.({repo:e,message:b,treeHash:p,headHash:t,theirsHash:n});if(fe(R))return{stdout:"",stderr:R.message??"",exitCode:1};let x=await yt(e,p,[t,n],g,w,b),y=f?.type==="symbolic"?f.target:"HEAD";await re(e,o,y,t,x,`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:x});let C=await pn(e,c.tree,p);return{stdout:`${h.messages.length>0?`${h.messages.join(`
491
+ `,stderr:"",exitCode:1}}await be(e,"MERGE_MSG");let p=m.mergedTreeHash,g=await mn(e,o);if(M(g))return g;let w=await tt(e,o);if(M(w))return w;let b=a??await gr(e,r,l),R={repo:e,message:b,treeHash:p,headHash:t,theirsHash:n},E=await i?.hooks?.mergeMsg?.(R);if(de(E))return{stdout:"",stderr:E.message??"",exitCode:1};b=R.message;let k=await i?.hooks?.preMergeCommit?.({repo:e,message:b,treeHash:p,headHash:t,theirsHash:n});if(de(k))return{stdout:"",stderr:k.message??"",exitCode:1};let x=await Ot(e,p,[t,n],g,w,b),y=f?.type==="symbolic"?f.target:"HEAD";await re(e,o,y,t,x,`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:x});let P=await gn(e,c.tree,p);return{stdout:`${h.messages.length>0?`${h.messages.join(`
477
492
  `)}
478
493
  `:""}Merge made by the 'ort' strategy.
479
- ${C}`,stderr:"",exitCode:0}}async function Vg(e,t,n){let r=[];for await(let o of Nt(e,n,{exclude:[t]})){r.push(`commit ${o.hash}`),o.commit.parents.length>1&&r.push(`Merge: ${o.commit.parents.map(i=>i.slice(0,7)).join(" ")}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${On(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
494
+ ${P}`,stderr:"",exitCode:0}}async function hw(e,t,n){let r=[];for await(let o of Ft(e,n,{exclude:[t]})){r.push(`commit ${o.hash}`),o.commit.parents.length>1&&r.push(`Merge: ${o.commit.parents.map(i=>i.slice(0,7)).join(" ")}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Tn(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
480
495
  `))r.push(` ${i}`);r.push("")}return r.join(`
481
- `)}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 Wt(e,t,n),u=d.length>0&&d[0]===t,h=u?`Updating ${Z(t)}..${Z(n)}
482
- `:"",m=await xs(e,t,n,l,s?.mergeDriver),p=await Sn(e,m,a.tree,{labels:l,errorExitCode:u?1:2,operationName:"merge",skipStagedChangeCheck:u});if(!p.ok){await be(e,"MERGE_MSG"),!u&&p.failureKind==="staged"&&c?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let y=p;return u&&(y.stderr=y.stderr.replace(/Merge with strategy ort failed\.\n$/,"")),h&&(y.stdout=h+y.stdout),y}let w=`Squashed commit of the following:
496
+ `)}async function mw(e,t,n,r,o,s,i){let a=await j(e,t),c=await te(e),f=await ke(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await qt(e,t,n),u=d.length>0&&d[0]===t,h=u?`Updating ${X(t)}..${X(n)}
497
+ `:"",m=await Rs(e,t,n,l,s?.mergeDriver),p=await Hn(e,m,a.tree,{labels:l,errorExitCode:u?1:2,operationName:"merge",skipStagedChangeCheck:u});if(!p.ok){await be(e,"MERGE_MSG"),!u&&p.failureKind==="staged"&&c?.type==="symbolic"&&await re(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let y=p;return u&&(y.stderr=y.stderr.replace(/Merge with strategy ort failed\.\n$/,"")),h&&(y.stdout=h+y.stdout),y}let w=`Squashed commit of the following:
483
498
 
484
- ${await Vg(e,t,n)}`;if(await Me(e,"SQUASH_MSG",w),m.conflicts.length>0){let C=`
499
+ ${await hw(e,t,n)}`;if(await Le(e,"SQUASH_MSG",w),m.conflicts.length>0){let P=`
485
500
  # Conflicts:
486
- ${Kt({version:2,entries:m.entries}).sort().map(P=>`# ${P}`).join(`
501
+ ${zt({version:2,entries:m.entries}).sort().map(D=>`# ${D}`).join(`
487
502
  `)}
488
- `,$=await $e(e,"MERGE_MSG");return await Me(e,"MERGE_MSG",($??"")+C),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
503
+ `,C=await $e(e,"MERGE_MSG");return await Le(e,"MERGE_MSG",(C??"")+P),{stdout:`${[...m.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
489
504
  `)}
490
- `,stderr:"",exitCode:1}}let b=p.mergedTreeHash,E=await pn(e,a.tree,b),k=m.messages.length>0?`${m.messages.join(`
505
+ `,stderr:"",exitCode:1}}let b=p.mergedTreeHash,R=await gn(e,a.tree,b),E=m.messages.length>0?`${m.messages.join(`
491
506
  `)}
492
507
  `:"";return{stdout:`${u?`${h}${i?"Fast-forward (no commit created; -m option ignored)":"Fast-forward"}
493
- `:""}${k}Squash commit -- not updating HEAD
494
- ${u?E:""}`,stderr:u?"":`Automatic merge went well; stopped before committing as requested
495
- `,exitCode:0}}async function Xg(e,t,n){let r=await W(e,"MERGE_HEAD");if(!r)return I("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=Pn(o,"Committing");if(s)return s;let i=await Je(e);if(M(i))return i;let a=await j(e,i),c=await $e(e,"MERGE_MSG");if(c)c=Ot(c);else{let C=await Q(e),$=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await gr(e,"unknown",$)}let f=Ne(o),l=await _e(e,f),d=await un(e,t);if(M(d))return d;let u=await tt(e,t);if(M(u))return u;let h=Gt(c),m={repo:e,message:h,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(m);if(fe(p))return{stdout:"",stderr:p.message??"",exitCode:1};h=m.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:h,treeHash:l,headHash:i,theirsHash:r});if(fe(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await yt(e,l,[i,r],d,u,h);await ps(e);let b=await Q(e),E=ue(h),k=b?.type==="symbolic"?b.target:"HEAD";await re(e,t,k,i,w,`commit (merge): ${E}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let R=await pn(e,a.tree,l),x=b?.type==="symbolic"?Pe(b.target):"detached HEAD";return{stdout:`${Lt(x,w,c)}
496
- ${R}`,stderr:"",exitCode:0}}async function Zg(e,t){return qn(e,t,{operationRef:"MERGE_HEAD",noOpError:I("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:ps})}se();Ce();me();et();function hd(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[K.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:S().alias("f").describe("Force renaming even if target exists"),"dry-run":S().alias("n").describe("Do nothing; only show what would happen"),skip:S().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return N(`usage: git mv [<options>] <source>... <destination>
497
- `);let f=c[c.length-1],l=c.slice(0,-1),d=Dt(r.cwd,f),u=nt(a,d);if(u.startsWith(".."))return I(`'${f}' is outside repository at '${a}'`);let h=await z(s),m=await r.fs.exists(d),p=m&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return I(m?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let b=Dt(r.cwd,w),E=nt(a,b);if(E.startsWith("..")){if(n.skip)continue;return I(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(b)){if(n.skip)continue;return I(`bad source, source=${E}, destination=${u}`)}let x=(await r.fs.stat(b)).isDirectory;if(!(x?h.entries.some(T=>T.path===E||T.path.startsWith(`${E}/`)):h.entries.some(T=>T.path===E&&T.stage===0))){let T=!x&&h.entries.some(A=>A.path===E&&A.stage>0);if(n.skip)continue;return I(T?`conflicted, source=${E}, destination=${u}`:`not under version control, source=${E}, destination=${u}`)}let C,$;if(p){let T=Xr(E);C=u===""||u==="."?T:`${u}/${T}`,$=v(d,T)}else C=u,$=d;if(await r.fs.exists($)&&!n.force)if((await r.fs.stat($)).isDirectory){let A=Xr(E);C=`${C}/${A}`,$=v($,A)}else{if(n.skip)continue;return I(`destination exists, source=${E}, destination=${C}`)}if(E===C){if(n.skip)continue;return I(`can not move directory into itself, source=${E}, destination=${C}`)}let P=rn($);if(!await r.fs.exists(P)){if(n.skip)continue;return I(`renaming '${E}' failed: No such file or directory`)}if(x){let T=`${E}/`,A=h.entries.filter(U=>U.path.startsWith(T)&&U.stage===0);for(let U of A){let _=U.path.slice(E.length),O=C+_,H=$+_;g.push({srcRel:U.path,dstRel:O,srcAbs:v(a,U.path),dstAbs:H})}}else g.push({srcRel:E,dstRel:C,srcAbs:b,dstAbs:$})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let b=rn(w.dstAbs);await r.fs.exists(b)||await r.fs.mkdir(b,{recursive:!0});let E=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,E),await r.fs.rm(w.srcAbs);let k=zs(h,w.srcRel,0);if(k){h=ct(h,w.srcRel);let R={...k,path:w.dstRel};h=Pt(h,R)}}for(let w of g)await cr(r.fs,rn(w.srcAbs),a);return await ae(s,h),{stdout:"",stderr:"",exitCode:0}}})}se();Be();rr();Ce();ie();me();pt();Ke();ge();se();Be();Ce();ie();se();ie();wn();or();De();async function $a(e,t){let n=await ye(e,t);if(n.type!=="commit")return null;let r=on(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await ye(e,r.parents[0]);f.type==="commit"&&(o=on(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=Hn(),a=!1,c=[...s].sort((f,l)=>Te(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let h=await ye(e,f.oldHash);l=new TextDecoder().decode(h.content)}catch{}if(f.newHash)try{let h=await ye(e,f.newHash);d=new TextDecoder().decode(h.content)}catch{}let u=vt({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let h of u.split(`
508
+ `:""}${E}Squash commit -- not updating HEAD
509
+ ${u?R:""}`,stderr:u?"":`Automatic merge went well; stopped before committing as requested
510
+ `,exitCode:0}}async function pw(e,t,n){let r=await U(e,"MERGE_HEAD");if(!r)return S("There is no merge in progress (MERGE_HEAD missing).");let o=await V(e),s=Sn(o,"Committing");if(s)return s;let i=await Qe(e);if(M(i))return i;let a=await j(e,i),c=await $e(e,"MERGE_MSG");if(c)c=St(c);else{let P=await te(e),C=P?.type==="symbolic"?Pe(P.target):"HEAD";c=await gr(e,"unknown",C)}let f=Ge(o),l=await Fe(e,f),d=await mn(e,t);if(M(d))return d;let u=await tt(e,t);if(M(u))return u;let h=It(c),m={repo:e,message:h,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(m);if(de(p))return{stdout:"",stderr:p.message??"",exitCode:1};h=m.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:h,treeHash:l,headHash:i,theirsHash:r});if(de(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await Ot(e,l,[i,r],d,u,h);await ms(e);let b=await te(e),R=ue(h),E=b?.type==="symbolic"?b.target:"HEAD";await re(e,t,E,i,w,`commit (merge): ${R}`,b?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let k=await gn(e,a.tree,l),x=b?.type==="symbolic"?Pe(b.target):"detached HEAD";return{stdout:`${Qt(x,w,c)}
511
+ ${k}`,stderr:"",exitCode:0}}async function gw(e,t){return qn(e,t,{operationRef:"MERGE_HEAD",noOpError:S("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:ms})}se();Ce();me();Je();function $d(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:O().alias("f").describe("Force renaming even if target exists"),"dry-run":O().alias("n").describe("Do nothing; only show what would happen"),skip:O().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return _(`usage: git mv [<options>] <source>... <destination>
512
+ `);let f=c[c.length-1],l=c.slice(0,-1),d=Mt(r.cwd,f),u=rt(a,d);if(u.startsWith(".."))return S(`'${f}' is outside repository at '${a}'`);let h=await V(s),m=await r.fs.exists(d),p=m&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return S(m?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let b=Mt(r.cwd,w),R=rt(a,b);if(R.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=${R}, destination=${u}`)}let x=(await r.fs.stat(b)).isDirectory;if(!(x?h.entries.some($=>$.path===R||$.path.startsWith(`${R}/`)):h.entries.some($=>$.path===R&&$.stage===0))){let $=!x&&h.entries.some(v=>v.path===R&&v.stage>0);if(n.skip)continue;return S($?`conflicted, source=${R}, destination=${u}`:`not under version control, source=${R}, destination=${u}`)}let P,C;if(p){let $=Vr(R);P=u===""||u==="."?$:`${u}/${$}`,C=H(d,$)}else P=u,C=d;if(await r.fs.exists(C)&&!n.force)if((await r.fs.stat(C)).isDirectory){let v=Vr(R);P=`${P}/${v}`,C=H(C,v)}else{if(n.skip)continue;return S(`destination exists, source=${R}, destination=${P}`)}if(R===P){if(n.skip)continue;return S(`can not move directory into itself, source=${R}, destination=${P}`)}let D=sn(C);if(!await r.fs.exists(D)){if(n.skip)continue;return S(`renaming '${R}' failed: No such file or directory`)}if(x){let $=`${R}/`,v=h.entries.filter(N=>N.path.startsWith($)&&N.stage===0);for(let N of v){let L=N.path.slice(R.length),I=P+L,T=C+L;g.push({srcRel:N.path,dstRel:I,srcAbs:H(a,N.path),dstAbs:T})}}else g.push({srcRel:R,dstRel:P,srcAbs:b,dstAbs:C})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let b=sn(w.dstAbs);await r.fs.exists(b)||await r.fs.mkdir(b,{recursive:!0});let R=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,R),await r.fs.rm(w.srcAbs);let E=qs(h,w.srcRel,0);if(E){h=lt(h,w.srcRel);let k={...E,path:w.dstRel};h=Pt(h,k)}}for(let w of g)await cr(r.fs,sn(w.srcAbs),a);return await ae(s,h),{stdout:"",stderr:"",exitCode:0}}})}se();Ue();sr();Ce();ie();me();pt();Be();ge();se();Ue();Ce();ie();se();ie();bn();ir();Ae();async function Ha(e,t){let n=await we(e,t);if(n.type!=="commit")return null;let r=an(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await we(e,r.parents[0]);f.type==="commit"&&(o=an(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=Ln(),a=!1,c=[...s].sort((f,l)=>ve(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let h=await we(e,f.oldHash);l=new TextDecoder().decode(h.content)}catch{}if(f.newHash)try{let h=await we(e,f.newHash);d=new TextDecoder().decode(h.content)}catch{}let u=Ht({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let h of u.split(`
498
513
  `)){if(!h||h.startsWith("index "))continue;let p=(h.startsWith("@@")?h.replace(/^@@ [^@]* @@/,"@@ @@"):h).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
499
- `),a=!0)}}return a?i.hex():null}Ke();ge();De();Jt();et();async function Jg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function md(e){return e==="HEAD"?`HEAD is up to date.
514
+ `),a=!0)}}return a?i.hex():null}Be();ge();Ae();Nt();Je();async function ww(e){let t=await te(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}var bw="4b825dc642cb6eb9a060e54bf8d69288fbee4904";function Od(e){return e==="HEAD"?`HEAD is up to date.
500
515
  `:`Current branch ${e} is up to date.
501
- `}async function Qg(e,t,n){if(!e.workTree)return null;let r=await de(e,t),o=new Map(Ne(n).map(a=>[a.path,a])),s=new Set(await rt(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=uo(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return N(`${a.stderr}error: could not detach HEAD
502
- `)}return null}async function ew(e,t,n,r){if(!e.workTree)return null;let o=await de(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await rt(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${uo(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
503
- `,exitCode:128}:null}async function pd(e,t,n){if(!e.workTree)return null;let r=new Map(Ne(t).map(i=>[i.path,i])),o=new Set(await rt(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function gd(e,t){return`error: The following untracked working tree files would be overwritten by merge:
516
+ `}async function yw(e,t,n){if(!e.workTree)return null;let r=await le(e,t),o=new Map(Ge(n).map(a=>[a.path,a])),s=new Set(await ot(e,e.workTree,"")),i=[];for(let[a]of r)o.has(a)||s.has(a)&&i.push({path:a,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(i.length>0){let a=fo(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return _(`${a.stderr}error: could not detach HEAD
517
+ `)}return null}async function Ew(e,t,n,r){if(!e.workTree)return null;let o=await le(e,t),s=new Set(n.entries.map(c=>c.path)),i=new Set(await ot(e,e.workTree,"")),a=[];for(let[c]of o)!s.has(c)&&i.has(c)&&a.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return a.length>0?{stdout:"",stderr:`${fo(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
518
+ `,exitCode:128}:null}async function Sd(e,t,n){if(!e.workTree)return null;let r=new Map(Ge(t).map(i=>[i.path,i])),o=new Set(await ot(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function Id(e,t){return`error: The following untracked working tree files would be overwritten by merge:
504
519
  ${e.map(r=>` ${r}`).join(`
505
520
  `)}
506
521
  Please move or remove them before you merge.
@@ -514,23 +529,21 @@ hint: edit the todo list first:
514
529
  hint:
515
530
  hint: git rebase --edit-todo
516
531
  hint: git rebase --continue
517
- `}async function Oa(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 Qo(e,t,n,r){let o=await j(e,t),s=await Qg(e,o.tree,n);if(s)return s;let i=await Cn(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps)),r!=="detached HEAD"?await J(e,r,t):await J(e,"HEAD",t),null}async function ei(e,t,n,r,o,s,i,a,c){let f=r.startsWith("refs/heads/")?Pe(r):"HEAD",l=await z(e),d=Kt(l).sort();if(d.length>0)return{stdout:d.map(P=>`${P}: needs merge
532
+ `}async function Aa(e,t,n,r,o,s,i){await re(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await re(e,t,o,n,r,`${i} (finish): ${o} onto ${r}`),await re(e,t,"HEAD",r,r,`${i} (finish): returning to ${o}`))}async function ni(e,t,n,r){let o=await j(e,t),s=await yw(e,o.tree,n);if(s)return s;let i=await On(e,o.tree,n);return i.success&&(await ae(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps)),r!=="detached HEAD"?await J(e,r,t):await J(e,"HEAD",t),null}async function ri(e,t,n,r,o,s,i,a,c,f){let l=r.startsWith("refs/heads/")?Pe(r):"HEAD",d=f?.reflogAction??"rebase",u=await V(e),h=zt(u).sort();if(h.length>0)return{stdout:h.map($=>`${$}: needs merge
518
533
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
519
534
  error: additionally, your index contains uncommitted changes.
520
535
  error: Please commit or stash them.
521
- `,exitCode:1};let u=await j(e,n),h=await de(e,u.tree);if(e.workTree){let P=Wn(l,h),A=(await wt(e,l)).some(U=>U.status==="modified"||U.status==="deleted");if(P||A){let U=[];return A&&U.push("error: cannot rebase: You have unstaged changes."),P&&(A?U.push("error: additionally, your index contains uncommitted changes."):U.push("error: cannot rebase: Your index contains uncommitted changes.")),U.push("error: Please commit or stash them."),N(`${U.join(`
522
- `)}
523
- `)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?f:null});if(fe(m))return{stdout:"",stderr:m.message??"",exitCode:1};let p=await Pf(e,o,n),g=p.right;if(g.length===0){if(s!==n){let P=await Qo(e,s,l,r);return P||(await Oa(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
524
- `,exitCode:0})}return{stdout:md(f),stderr:"",exitCode:0}}let w=[],b=[];if(c?.reapplyCherryPicks)b.push(...g);else{let P=p.left,T=new Set;for(let A of P){let U=await $a(e,A.hash);U&&T.add(U)}if(T.size>0)for(let A of g){let U=await $a(e,A.hash);U&&T.has(U)?w.push(`warning: skipped previously applied commit ${Z(A.hash)}`):b.push(A)}else b.push(...g)}let E="";if(w.length>0&&(E=`${w.join(`
536
+ `,exitCode:1};let m=await lo(e,n,u);if(m)return uo("rebase",m);let p=await c?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?l:null});if(de(p))return{stdout:"",stderr:p.message??"",exitCode:1};let g=await Hf(e,o,n),w=g.right;if(w.length===0){if(s!==n){let $=await ni(e,s,u,r);return $||(await Aa(e,t,n,s,r,a,d),{stdout:"",stderr:`Successfully rebased and updated ${r}.
537
+ `,exitCode:0})}return{stdout:Od(l),stderr:"",exitCode:0}}let b=[],R=[];if(f?.reapplyCherryPicks)R.push(...w);else{let $=g.left,v=new Set;for(let N of $){let L=await Ha(e,N.hash);L&&v.add(L)}if(v.size>0)for(let N of w){let L=await Ha(e,N.hash);L&&v.has(L)?b.push(`warning: skipped previously applied commit ${X(N.hash)}`):R.push(N)}else R.push(...w)}let E="";if(b.length>0&&(E=`${b.join(`
525
538
  `)}
526
539
  hint: use --reapply-cherry-picks to include skipped commits
527
540
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
528
- `),b.length===0){if(s!==n){let P=await Qo(e,s,l,r);if(P)return P.stderr=E+P.stderr,P;await Oa(e,t,n,s,r,i)}return{stdout:"",stderr:`${E}Successfully rebased and updated ${r}.
529
- `,exitCode:0}}let k=b.map(P=>({hash:P.hash,subject:ue(P.commit.message)})),R=s,x=0;for(let P of k){let T=await j(e,P.hash);if(T.parents.length>1||T.parents.length===0||T.parents[0]!==R)break;R=P.hash,x++}let y=k.splice(0,x);if(k.length===0){if(R===n)return{stdout:md(f),stderr:E,exitCode:0};let P=await Qo(e,R,l,r);return P?(P.stderr=E+P.stderr,P):(await Oa(e,t,n,R,r,i),{stdout:"",stderr:`${E}Successfully rebased and updated ${r}.
530
- `,exitCode:0})}let C=await Qo(e,R,l,"detached HEAD");if(C)return C.stderr=E+C.stderr,C;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await re(e,t,"HEAD",n,R,`rebase (start): checkout ${i}`);let $={headName:r,origHead:n,onto:s,todo:k,done:y,msgnum:x,end:x+k.length};await Xi(e,$),await J(e,"ORIG_HEAD",n);let D=await Sa(e,t,a?.mergeDriver);return E&&(D.stderr=E+D.stderr),D}async function Sa(e,t,n){let r=[],o=[];for(;;){let s=await kt(e);if(!s||s.todo.length===0)break;let i=s.todo[0];if(!i)break;r.push(`Rebasing (${s.msgnum+1}/${s.end})\r`),await Cf(e);let a=await tw(e,i,t,n);if(a.conflict){if(a.rescheduleCurrent){let c=await kt(e);c&&(c.todo=[i,...c.todo],await Xi(e,c))}return a.stdout&&o.push(a.stdout),r.push(a.stderr),{stdout:o.join(""),stderr:r.join(""),exitCode:1}}a.stdout&&o.push(a.stdout),a.stderr&&r.push(a.stderr)}return nw(e,r,t)}async function tw(e,t,n,r){let o=t.hash,s=await j(e,o),i=s.parents.length>0?s.parents[0]:null,a=i?await j(e,i):null,c=await X(e);if(!c)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
531
- `};if(i&&i===c){let _=await z(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
532
- `};let O=await qe(e,a.tree),H=await qe(e,s.tree),L=new Map(O.map(ee=>[ee.path,ee.hash])),G=new Map;for(let ee of H){let V=L.get(ee.path);(!V||V!==ee.hash)&&G.set(ee.path,ee.hash)}let B=await pd(e,_,G);if(B)return await J(e,"REBASE_HEAD",o),await ko(e,o,s.author),{conflict:!0,stdout:"",stderr:gd(B,t),rescheduleCurrent:!0};let F=await Cn(e,s.tree,_);return F.success&&(await ae(e,{version:2,entries:F.newEntries}),await je(e,F.worktreeOps)),await Gn(e,o),await re(e,n,"HEAD",c,o,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let f=await j(e,c),l=a?a.tree:null,d=Z(o),u=ue(s.message),h=await xe(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:u?`${d} (${u})`:d,conflictStyle:h},p=await qt(e,l,f.tree,s.tree,m,r),g=await z(e),[w,b,E]=await Promise.all([qe(e,f.tree),l?qe(e,l):Promise.resolve([]),qe(e,s.tree)]),k=new Set;for(let _ of b)k.add(_.path);for(let _ of w)k.add(_.path);for(let _ of E)k.add(_.path);let R=g.entries.filter(_=>!k.has(_.path)),x=[...p.entries,...R];x.sort((_,O)=>Te(_.path,O.path)||_.stage-O.stage);let y={version:2,entries:x},C=x.filter(_=>_.stage===0),$=await _e(e,C),D=new Map(w.map(_=>[_.path,_])),P=new Map;for(let _ of C){let O=D.get(_.path);(!O||O.hash!==_.hash)&&P.set(_.path,_.hash)}for(let _ of p.conflicts){if(_.reason==="content"||_.reason==="add-add"){P.set(_.path,null);continue}if(_.reason==="delete-modify"){let O=p.entries.filter(G=>G.path===_.path&&G.stage>0),H=O.find(G=>G.stage===2),L=O.find(G=>G.stage===3);L&&!H&&P.set(_.path,L.hash)}}let T=await pd(e,g,P);if(T)return await J(e,"REBASE_HEAD",o),await ko(e,o,s.author),{conflict:!0,stdout:"",stderr:gd(T,t),rescheduleCurrent:!0};if(await ae(e,y),e.workTree){let _=await Bn(e,f.tree,p.resultTree,g);_.success&&await je(e,_.worktreeOps)}if(p.conflicts.length>0){await J(e,"REBASE_HEAD",o),await ko(e,o,s.author),await Me(e,"MERGE_MSG",s.message),await Me(e,"rebase-merge/message",s.message);let _=p.messages.join(`
533
- `);return{conflict:!0,stdout:_?`${_}
541
+ `),R.length===0){if(s!==n){let $=await ni(e,s,u,r);if($)return $.stderr=E+$.stderr,$;await Aa(e,t,n,s,r,a,d)}return{stdout:"",stderr:`${E}Successfully rebased and updated ${r}.
542
+ `,exitCode:0}}let k=R.map($=>({hash:$.hash,subject:ue($.commit.message)})),x=s,y=0;for(let $ of k){let v=await j(e,$.hash);if(v.parents.length>1||v.parents.length===0||v.parents[0]!==x)break;x=$.hash,y++}let P=k.splice(0,y);if(k.length===0){if(x===n&&!E)return{stdout:Od(l),stderr:"",exitCode:0};if(x!==n){let $=await ni(e,x,u,r);if($)return $.stderr=E+$.stderr,$;await Aa(e,t,n,x,r,a,d)}return{stdout:"",stderr:`${E}Successfully rebased and updated ${r}.
543
+ `,exitCode:0}}let C=await ni(e,x,u,"detached HEAD");if(C)return C.stderr=E+C.stderr,C;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await re(e,t,"HEAD",n,x,`rebase (start): checkout ${a}`);let A={headName:r,origHead:n,onto:s,todo:k,done:P,msgnum:y,end:y+k.length,reflogAction:d};await ea(e,A),await J(e,"ORIG_HEAD",n);let D=await Da(e,t,c?.mergeDriver);return E&&(D.stderr=E+D.stderr),D}async function Da(e,t,n){let r=[],o=[];for(;;){let s=await kt(e);if(!s||s.todo.length===0)break;let i=s.todo[0];if(!i)break;r.push(`Rebasing (${s.msgnum+1}/${s.end})\r`),await vf(e);let a=await kw(e,i,t,n);if(a.conflict){if(a.rescheduleCurrent){let c=await kt(e);c&&(c.todo=[i,...c.todo],await ea(e,c))}return a.stdout&&o.push(a.stdout),r.push(a.stderr),{stdout:o.join(""),stderr:r.join(""),exitCode:1}}a.stdout&&o.push(a.stdout),a.stderr&&r.push(a.stderr)}return Rw(e,r,t)}async function kw(e,t,n,r){let o=t.hash,s=await j(e,o),i=s.parents.length>0?s.parents[0]:null,a=i?await j(e,i):null,c=await Z(e);if(!c)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
544
+ `};if(i&&i===c){let I=await V(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
545
+ `};let T=await qe(e,a.tree),G=await qe(e,s.tree),W=new Map(T.map(z=>[z.path,z.hash])),F=new Map;for(let z of G){let Q=W.get(z.path);(!Q||Q!==z.hash)&&F.set(z.path,z.hash)}let B=await Sd(e,I,F);if(B)return await J(e,"REBASE_HEAD",o),await Eo(e,o,s.author),{conflict:!0,stdout:"",stderr:Id(B,t),rescheduleCurrent:!0};let ee=await On(e,s.tree,I);return ee.success&&(await ae(e,{version:2,entries:ee.newEntries}),await De(e,ee.worktreeOps)),await _n(e,o),await re(e,n,"HEAD",c,o,"rebase: fast-forward"),{conflict:!1,stdout:"",stderr:""}}let f=await j(e,c),l=a?a.tree:null,d=X(o),u=ue(s.message),h=await ke(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:u?`${d} (${u})`:d,conflictStyle:h},p=await Kt(e,l,f.tree,s.tree,m,r),g=await V(e),[w,b,R]=await Promise.all([qe(e,f.tree),l?qe(e,l):Promise.resolve([]),qe(e,s.tree)]),E=new Set;for(let I of b)E.add(I.path);for(let I of w)E.add(I.path);for(let I of R)E.add(I.path);let k=g.entries.filter(I=>!E.has(I.path)),x=[...p.entries,...k];x.sort((I,T)=>ve(I.path,T.path)||I.stage-T.stage);let y={version:2,entries:x},P=x.filter(I=>I.stage===0),C=await Fe(e,P),A=new Map(w.map(I=>[I.path,I])),D=new Map;for(let I of P){let T=A.get(I.path);(!T||T.hash!==I.hash)&&D.set(I.path,I.hash)}for(let I of p.conflicts){if(I.reason==="content"||I.reason==="add-add"){D.set(I.path,null);continue}if(I.reason==="delete-modify"){let T=p.entries.filter(F=>F.path===I.path&&F.stage>0),G=T.find(F=>F.stage===2),W=T.find(F=>F.stage===3);W&&!G&&D.set(I.path,W.hash)}}let $=await Sd(e,g,D);if($)return await J(e,"REBASE_HEAD",o),await Eo(e,o,s.author),{conflict:!0,stdout:"",stderr:Id($,t),rescheduleCurrent:!0};if(await ae(e,y),e.workTree){let I=await hn(e,f.tree,p.resultTree,g);I.success&&await De(e,I.worktreeOps)}if(p.conflicts.length>0){await J(e,"REBASE_HEAD",o),await Eo(e,o,s.author),await Le(e,"MERGE_MSG",s.message),await Le(e,"rebase-merge/message",s.message);let I=p.messages.join(`
546
+ `);return{conflict:!0,stdout:I?`${I}
534
547
  `:"",stderr:`error: could not apply ${d}... ${t.subject}
535
548
  hint: Resolve all conflicts manually, mark them as resolved with
536
549
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
@@ -538,13 +551,15 @@ hint: You can instead skip this commit: run "git rebase --skip".
538
551
  hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
539
552
  hint: Disable this message with "git config set advice.mergeConflict false"
540
553
  Could not apply ${d}... # ${t.subject}
541
- `}}if($===f.tree)return{conflict:!1,stdout:"",stderr:`dropping ${o} ${t.subject} -- patch contents already upstream
542
- `};let A=await tt(e,n);if(M(A))return{conflict:!0,stdout:"",stderr:A.stderr};let U=await yt(e,$,[c],s.author,A,s.message);return await re(e,n,"HEAD",c,U,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function nw(e,t,n){let r=await kt(e);if(!r)return I("no rebase in progress");let o=await X(e);if(!o)return I("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await J(e,r.headName,o),await Ze(e,"HEAD",r.headName),await Et(e),await 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}.
543
- `;return await he(e,"REBASE_HEAD"),await ur(e),await Zi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function wd(e,t){let n=await kt(e);if(!n)return I("no rebase in progress");let r=await X(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await ew(e,s.tree,i,o);if(a)return a;let c=await Cn(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await je(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await J(e,n.headName,o),await Ze(e,"HEAD",n.headName),await Et(e)):await Gn(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 he(e,"REBASE_HEAD"),await ur(e),await Zi(e),{stdout:"",stderr:"",exitCode:0}}async function bd(e,t,n){let r="";if(!await kt(e))return I("no rebase in progress");let s=await z(e);if(jt(s))return N(`error: Committing is not possible because you have unmerged files.
554
+ `}}let v=i===null?s.tree===bw:s.tree===l;if(C===f.tree&&!v)return{conflict:!1,stdout:"",stderr:`dropping ${o} ${t.subject} -- patch contents already upstream
555
+ `};let N=await tt(e,n);if(M(N))return{conflict:!0,stdout:"",stderr:N.stderr};let L=await Ot(e,C,[c],s.author,N,s.message);return await re(e,n,"HEAD",c,L,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Rw(e,t,n){let r=await kt(e);if(!r)return S("no rebase in progress");let o=await Z(e);if(!o)return S("no HEAD during rebase finish");if(r.headName!=="detached HEAD"){let a=await U(e,r.headName);if(a!==r.origHead)return{stdout:"",stderr:t.join("")+`error: update_ref failed for ref '${r.headName}': cannot lock ref '${r.headName}': is at ${a??"(null)"} but expected ${r.origHead}
556
+ error: could not update ${r.headName}
557
+ `,exitCode:1};await J(e,r.headName,o),await Ze(e,"HEAD",r.headName),await Et(e),await re(e,n,r.headName,r.origHead,o,`${r.reflogAction??"rebase"} (finish): ${r.headName} onto ${r.onto}`),await re(e,n,"HEAD",o,o,`${r.reflogAction??"rebase"} (finish): returning to ${r.headName}`)}let i=`Successfully rebased and updated ${r.headName}.
558
+ `;return await he(e,"REBASE_HEAD"),await hr(e),await ta(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Td(e,t){let n=await kt(e);if(!n)return S("no rebase in progress");let r=await Z(e),o=n.origHead,s=await j(e,o),i=await V(e),a=await Ew(e,s.tree,i,o);if(a)return a;let c=await On(e,s.tree,i);c.success&&(await ae(e,{version:2,entries:c.newEntries}),await De(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await J(e,n.headName,o),await Ze(e,"HEAD",n.headName),await Et(e)):await _n(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 he(e,"REBASE_HEAD"),await hr(e),await ta(e),{stdout:"",stderr:"",exitCode:0}}async function vd(e,t,n){let r="",o=await kt(e);if(!o)return S("no rebase in progress");let s=await V(e);if(Lt(s))return _(`error: Committing is not possible because you have unmerged files.
544
559
  hint: Fix them up in the work tree, and then use 'git add <file>'
545
560
  hint: as appropriate to mark resolution and make a commit.
546
561
  fatal: Exiting because of an unresolved conflict.
547
- `,128);let i=await W(e,"REBASE_HEAD");if(i){let c=await X(e);if(!c)return I("Cannot read HEAD");let f=await j(e,c),l=Ne(s),d=await _e(e,l),u=d!==f.tree,h=await $e(e,"rebase-merge/message")!==null;if(u&&!h)return N(`error: you have staged changes in your working tree
562
+ `,128);let i=await U(e,"REBASE_HEAD");if(i){let c=await Z(e);if(!c)return S("Cannot read HEAD");let f=await j(e,c),l=Ge(s),d=await Fe(e,l),u=d!==f.tree,h=await $e(e,"rebase-merge/message")!==null;if(u&&!h)return _(`error: you have staged changes in your working tree
548
563
  If these changes are meant to be squashed into the previous commit, run:
549
564
 
550
565
  git commit --amend
@@ -557,48 +572,38 @@ In both cases, once you're done, continue with:
557
572
 
558
573
  git rebase --continue
559
574
 
560
- `);if(u){let m=await j(e,i),p=await W(e,"CHERRY_PICK_HEAD"),g=p?await j(e,p):m,w;w=await $e(e,"rebase-merge/message")??await $e(e,"MERGE_MSG")??void 0,w&&(w=Ot(w)),w||(w=m.message);let b=await tt(e,t);if(M(b))return b;let E=Gt(w),k=[c],R=await W(e,"MERGE_HEAD");R&&k.push(R);let x=await yt(e,d,k,g.author,b,E);R&&(await he(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let y=ue(E);await re(e,t,"HEAD",c,x,`rebase (continue): ${y}`);let C=await Jg(e),$=g.author.timestamp!==b.timestamp||g.author.timezone!==b.timezone,D=await mn(e,f.tree,d,g.author,b,$);r=`${Lt(C,x,E)}
561
- ${D}`}await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"rebase-merge/message")}let a=await Sa(e,t,n);return r&&(a.stdout=r+a.stdout),a}async function yd(e,t,n){if(!await kt(e))return I("no rebase in progress");let o=await X(e);if(!o)return{stdout:"",stderr:`error: could not determine HEAD revision
575
+ `);if(u){let p=await j(e,i),g=await U(e,"CHERRY_PICK_HEAD"),w=g?await j(e,g):p,b;b=await $e(e,"rebase-merge/message")??await $e(e,"MERGE_MSG")??void 0,b&&(b=St(b)),b||(b=p.message);let R=await tt(e,t);if(M(R))return R;let E=It(b),k=[c],x=await U(e,"MERGE_HEAD");x&&k.push(x);let y=await Ot(e,d,k,w.author,R,E);x&&(await he(e,"MERGE_HEAD"),await be(e,"MERGE_MODE"));let P=ue(E);await re(e,t,"HEAD",c,y,`rebase (continue): ${P}`);let C=await ww(e),A=w.author.timestamp!==R.timestamp||w.author.timezone!==R.timezone,D=await vn(e,f.tree,d,w.author,R,A);r=`${Qt(C,y,E)}
576
+ ${D}`}o.todo.length===0||await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await be(e,"MERGE_MSG"),await be(e,"rebase-merge/message")}let a=await Da(e,t,n);return r&&(a.stdout=r+a.stdout),a}async function Hd(e,t,n){if(!await kt(e))return S("no rebase in progress");let o=await Z(e);if(!o)return{stdout:"",stderr:`error: could not determine HEAD revision
562
577
  fatal: could not discard worktree changes
563
- `,exitCode:128};let s=await j(e,o),i=await z(e),a=await Cn(e,s.tree,i);return a.success&&(await ae(e,{version:2,entries:a.newEntries}),await je(e,a.worktreeOps)),await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await he(e,"MERGE_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"rebase-merge/message"),Sa(e,t,n)}function Ed(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[K.string().name("remote").describe("Remote to pull from").optional(),K.string().name("branch").describe("Remote branch").optional()],options:{rebase:S().alias("r").describe("Rebase instead of merge"),noRebase:S().describe("Merge instead of rebase"),ffOnly:S().describe("Only fast-forward"),noFf:S().describe("Create a merge commit even for fast-forwards"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:S().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Go(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=Cs);let a=await Je(s);if(M(a))return a;let c=await Q(s),f=await z(s);if(jt(f))return{stdout:"",stderr:`error: Pulling is not possible because you have unmerged files.
578
+ `,exitCode:128};let s=await j(e,o),i=await V(e),a=await On(e,s.tree,i);return a.success&&(await ae(e,{version:2,entries:a.newEntries}),await De(e,a.worktreeOps)),await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await he(e,"MERGE_HEAD"),await be(e,"MERGE_MSG"),await be(e,"MERGE_MODE"),await be(e,"rebase-merge/message"),Da(e,t,n)}function Ad(e,t,n,r,o){if(t.useRebase&&!n&&r.length>0&&o){let s=e?.type==="symbolic"?Pe(e.target):"HEAD";return s==="HEAD"?`HEAD is up to date.
579
+ `:`Current branch ${s} is up to date.
580
+ `}return`Already up to date.
581
+ `}function Dd(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:O().alias("r").describe("Rebase instead of merge"),noRebase:O().describe("Merge instead of rebase"),ffOnly:O().describe("Only fast-forward"),noFf:O().describe("Create a merge commit even for fast-forwards"),depth:Y.number().describe("Limit fetching to the specified number of commits"),unshallow:O().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Ko(s,n);if(M(i))return i;let{depth:a}=i,c=await Qe(s);if(M(c))return c;let f=await te(s),l=await V(s);if(Lt(l))return{stdout:"",stderr:`error: Pulling is not possible because you have unmerged files.
564
582
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
565
583
  hint: as appropriate to mark resolution and make a commit.
566
584
  fatal: Exiting because of an unresolved conflict.
567
- `,exitCode:128};let l=n.remote,d=n.branch,u=null;if(!l&&c?.type==="symbolic"){let le=c.target.startsWith("refs/heads/")?c.target.slice(11):c.target,ht=(await pe(s))[`branch "${le}"`];ht?(l=ht.remote||"origin",!d&&ht.merge&&(d=ht.merge.startsWith("refs/heads/")?ht.merge.slice(11):ht.merge)):d||(u=le)}l=l||"origin";let h=await rw(s,n,c),m;try{m=await Wr(s,l,r.env)}catch(le){let Le=le instanceof Error?le.message:"";if(Le.startsWith("network"))return{stdout:"",stderr:`fatal: ${Le}
568
- `,exitCode:1};throw le}if(!m)return{stdout:"",stderr:`fatal: '${l}' does not appear to be a git repository
569
- `,exitCode:1};let{transport:p,config:g}=m,w=d??null,b=await t?.hooks?.prePull?.({repo:s,remote:l,branch:w});if(fe(b))return{stdout:"",stderr:b.message??"",exitCode:1};let E=kr(g.fetchRefspec),k=await p.advertiseRefs(),x=(await we(s)).map(le=>le.hash),y=await W(s,"HEAD");y&&x.push(y);let C=[],$=new Set,D=[];for(let le of k){if(le.name==="HEAD")continue;let Le=Ts(E,le.name);Le!==null&&(D.push({remote:le,localRef:Le}),$.has(le.hash)||($.add(le.hash),C.push(le.hash)))}let P=new Set(x),T=C.filter(le=>!P.has(le)),A,U=i!==void 0?await Fr(s):void 0;i!==void 0&&(A={depth:i,existingShallows:U});let _=T.length>0?T:A?C:[];if(_.length>0){let le=await p.fetch(_,x,A);le.shallowUpdates&&await _r(s,le.shallowUpdates,U)}let O=await vn(s,r.env),H=[];for(let le of D){let Le=await W(s,le.localRef);H.push(Le),await J(s,le.localRef,le.remote.hash),await ft(s,le.localRef,{oldHash:Le??ne,newHash:le.remote.hash,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Le?"pull":"pull: storing head"})}let L=ho(D.map((le,Le)=>({...le,oldHash:H[Le]})),Ln,Z),G=L.length>0?`From ${g.url}
570
- ${Dr(L,10)}`:"";if(await vr(s,l,k,p.headTarget),c?.type!=="symbolic"&&!d)return{stdout:"",stderr:G+`You are not currently on a branch.
571
- Please specify which branch you want to merge with.
585
+ `,exitCode:128};let d=n.remote,u=n.branch,h=null;if(!d&&f?.type==="symbolic"){let fe=f.target.startsWith("refs/heads/")?f.target.slice(11):f.target,nt=(await pe(s))[`branch "${fe}"`];nt?(d=nt.remote||"origin",!u&&nt.merge&&(u=nt.merge.startsWith("refs/heads/")?nt.merge.slice(11):nt.merge)):u||(h=fe)}d=d||"origin";let m=await xw(s,n,f);if(m.useRebase){let fe=await lo(s,c,l);if(fe)return uo("pull with rebase",fe,128)}let p=await zo(s,d,r.env,fe=>({stdout:"",stderr:`fatal: ${fe}
586
+ `,exitCode:1}));if(M(p))return p;let{transport:g,config:w}=p,b=u??null,R=await t?.hooks?.prePull?.({repo:s,remote:d,branch:b});if(de(R))return{stdout:"",stderr:R.message??"",exitCode:1};let E=kr(w.fetchRefspec),k=await g.advertiseRefs(),x=await Ss(s),y=[],P=new Set,C=[];for(let fe of k){if(fe.name==="HEAD")continue;let Ke=Is(E,fe.name);Ke!==null&&(C.push({remote:fe,localRef:Ke}),P.has(fe.hash)||(P.add(fe.hash),y.push(fe.hash)))}let A=new Set(x),D=y.filter(fe=>!A.has(fe)),{existingShallows:$,shallowOpts:v}=await Vo(s,a),N=D.length>0?D:v?y:[];if(N.length>0){let fe=await g.fetch(N,x,v);fe.shallowUpdates&&await Fr(s,fe.shallowUpdates,$)}let L=await Mn(s,r.env),I=[];for(let fe of C){let Ke=await U(s,fe.localRef);I.push(Ke),await J(s,fe.localRef,fe.remote.hash),await st(s,fe.localRef,{oldHash:Ke??ne,newHash:fe.remote.hash,name:L.name,email:L.email,timestamp:L.timestamp,tz:L.tz,message:Ke?"pull":"pull: storing head"})}let T=us(C.map((fe,Ke)=>({...fe,oldHash:I[Ke]})),Gt,X);T.push(...await Yo({gitCtx:s,transport:g,remoteRefs:k,ident:L,reflogAction:"pull"}));let G=T.length>0?`From ${w.url}
587
+ ${Dr(T,10)}`:"";if(await vr(s,d,k,g.headTarget),f?.type!=="symbolic"&&!u){let fe=m.useRebase?"rebase against":"merge with";return{stdout:"",stderr:G+`You are not currently on a branch.
588
+ Please specify which branch you want to ${fe}.
572
589
  See git-pull(1) for details.
573
590
 
574
591
  git pull <remote> <branch>
575
592
 
576
- `,exitCode:1};if(u){let le=await pe(s),Le=[];for(let xr of Object.keys(le)){let Ua=xr.match(/^remote "(.+)"$/);Ua?.[1]&&Le.push(Ua[1])}let ht=Le.length===1?Le[0]:"<remote>";return{stdout:"",stderr:G+`There is no tracking information for the current branch.
577
- Please specify which branch you want to merge with.
593
+ `,exitCode:1}}if(h){let fe=m.useRebase?"rebase against":"merge with",Ke=await pe(s),nt=[];for(let gu of Object.keys(Ke)){let Ya=gu.match(/^remote "(.+)"$/);Ya?.[1]&&nt.push(Ya[1])}let xr=nt.length===1?nt[0]:"<remote>";return{stdout:"",stderr:G+`There is no tracking information for the current branch.
594
+ Please specify which branch you want to ${fe}.
578
595
  See git-pull(1) for details.
579
596
 
580
597
  git pull <remote> <branch>
581
598
 
582
599
  If you wish to set tracking information for this branch you can do so with:
583
600
 
584
- git branch --set-upstream-to=${ht}/<branch> ${u}
601
+ git branch --set-upstream-to=${xr}/<branch> ${h}
585
602
 
586
- `,exitCode:1}}let B=null;if(d){let le=k.find(Le=>Le.name===`refs/heads/${d}`);if(le)B=le.hash;else return{stdout:"",stderr:G+`Your configuration specifies to merge with the ref 'refs/heads/${d}'
603
+ `,exitCode:1}}let W=null;if(u){let fe=k.find(Ke=>Ke.name===`refs/heads/${u}`);if(fe)W=fe.hash;else return{stdout:"",stderr:G+`Your configuration specifies to merge with the ref 'refs/heads/${u}'
587
604
  from the remote, but no such ref was fetched.
588
- `,exitCode:1}}else{let le=k.find(Le=>Le.name==="HEAD");le&&(B=le.hash)}if(B&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${B} ${g.url}
589
- `),!B)return I("Could not determine remote HEAD");let F=B;if(await be(s,"MERGE_MSG"),a===F)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
590
- `,stderr:G,exitCode:0};if(h.useRebase){let le=c?.type==="symbolic"?c.target:"detached HEAD",Le=d?`${l}/${d}`:l,ht=await ei(s,r.env,a,le,F,F,Le,t);if(ht.exitCode===0){let xr=await X(s);await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"rebase",commitHash:xr})}return{...ht,stderr:G+ht.stderr}}let ee=await Wt(s,a,F),V=ee[0]??null;if(V===F)return await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
591
- `,stderr:G,exitCode:0};let{noFf:te,ffOnly:ke,configured:Fe}=h,ce=V===a;if(ke&&!ce)return{stdout:"",stderr:G+`hint: Diverging branches can't be fast-forwarded, you need to either:
592
- hint:
593
- hint: git merge --no-ff
594
- hint:
595
- hint: or:
596
- hint:
597
- hint: git rebase
598
- hint:
599
- hint: Disable this message with "git config set advice.diverging false"
600
- fatal: Not possible to fast-forward, aborting.
601
- `,exitCode:128};if(!ce&&!Fe)return{stdout:"",stderr:G+`hint: You have divergent branches and need to specify how to reconcile them.
605
+ `,exitCode:1}}else{let fe=k.find(Ke=>Ke.name==="HEAD");fe&&(W=fe.hash)}if(W&&await r.fs.writeFile(H(s.gitDir,"FETCH_HEAD"),`${W} ${w.url}
606
+ `),!W)return S("Could not determine remote HEAD");let F=W;if(await be(s,"MERGE_MSG"),c===F)return await t?.hooks?.postPull?.({repo:s,remote:d,branch:b,strategy:"up-to-date",commitHash:null}),{stdout:Ad(f,m,!!n.ffOnly,G,!1),stderr:G,exitCode:0};if(m.useRebase&&!m.ffOnly){let fe=f?.type==="symbolic"?f.target:"detached HEAD",Ke=u?`${d}/${u}`:d,nt=await ri(s,r.env,c,fe,F,F,Ke,Ke,t,{reflogAction:"pull"});if(nt.exitCode===0){let xr=await Z(s);await t?.hooks?.postPull?.({repo:s,remote:d,branch:b,strategy:"rebase",commitHash:xr})}return{...nt,stderr:G+nt.stderr}}let B=await qt(s,c,F),ee=B[0]??null;if(ee===F)return await t?.hooks?.postPull?.({repo:s,remote:d,branch:b,strategy:"up-to-date",commitHash:null}),{stdout:Ad(f,m,!!n.ffOnly,G,!0),stderr:G,exitCode:0};let{noFf:z,ffOnly:Q,ffOnlySource:Re,hasReconciliationStrategy:Ne}=m,ce=ee===c;if(!ce&&!Ne)return{stdout:"",stderr:G+`hint: You have divergent branches and need to specify how to reconcile them.
602
607
  hint: You can do so by running one of the following commands sometime before
603
608
  hint: your next pull:
604
609
  hint:
@@ -611,24 +616,29 @@ hint: preference for all repositories. You can also pass --rebase, --no-rebase,
611
616
  hint: or --ff-only on the command line to override the configured default per
612
617
  hint: invocation.
613
618
  fatal: Need to specify how to reconcile divergent branches.
614
- `,exitCode:128};if(ee.length===0)return{stdout:"",stderr:G+`fatal: refusing to merge unrelated histories
615
- `,exitCode:128};if(ce&&!te){let le=await jo(s,a,F);if(le.exitCode===0){let Le=c?.type==="symbolic"?c.target:"HEAD",xr=`pull${ke?" --ff-only":""}: Fast-forward`;await ft(s,Le,{oldHash:a,newHash:F,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:xr}),c?.type==="symbolic"&&await ft(s,"HEAD",{oldHash:a,newHash:F,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:xr}),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:F,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"fast-forward",commitHash:F})}return{...le,stderr:G+le.stderr}}let Se=c?.type==="symbolic"?Pe(c.target):"HEAD",ut=F,Rr=d||"HEAD",Xe=await xe(s,"merge.conflictstyle")??"merge",Kr={a:"HEAD",b:ut,conflictStyle:Xe},nr=await xs(s,a,F,Kr,t?.mergeDriver),La=await j(s,a),zr=await Sn(s,nr,La.tree,{labels:Kr,errorExitCode:2,operationName:"merge"});if(!zr.ok)return{stdout:zr.stdout,stderr:G+zr.stderr,exitCode:zr.exitCode};if(nr.conflicts.length>0){await J(s,"MERGE_HEAD",F),await J(s,"ORIG_HEAD",a);let le=await gr(s,Rr,Se,g.url),Le=Kt({version:2,entries:nr.entries}).sort();return le+=`
619
+ `,exitCode:128};if(B.length===0&&Re!=="cli"&&Re!=="pull")return{stdout:"",stderr:G+`fatal: refusing to merge unrelated histories
620
+ `,exitCode:128};if(Q&&!ce)return{stdout:"",stderr:G+`hint: Diverging branches can't be fast-forwarded, you need to either:
621
+ hint:
622
+ hint: git merge --no-ff
623
+ hint:
624
+ hint: or:
625
+ hint:
626
+ hint: git rebase
627
+ hint:
628
+ hint: Disable this message with "git config set advice.diverging false"
629
+ fatal: Not possible to fast-forward, aborting.
630
+ `,exitCode:128};if(ce&&!z){let fe=await Do(s,c,F);if(fe.exitCode===0){let Ke=f?.type==="symbolic"?f.target:"HEAD",xr=`pull${Q?" --ff-only":""}: Fast-forward`;await st(s,Ke,{oldHash:c,newHash:F,name:L.name,email:L.email,timestamp:L.timestamp,tz:L.tz,message:xr}),f?.type==="symbolic"&&await st(s,"HEAD",{oldHash:c,newHash:F,name:L.name,email:L.email,timestamp:L.timestamp,tz:L.tz,message:xr}),await t?.hooks?.postMerge?.({repo:s,headHash:c,theirsHash:F,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:d,branch:b,strategy:"fast-forward",commitHash:F})}return{...fe,stderr:G+fe.stderr}}let Se=f?.type==="symbolic"?Pe(f.target):"HEAD",ht=F,Rr=u||"HEAD",Xe=await ke(s,"merge.conflictstyle")??"merge",Wr={a:"HEAD",b:ht,conflictStyle:Xe},rr=await Rs(s,c,F,Wr,t?.mergeDriver),Wa=await j(s,c),qr=await Hn(s,rr,Wa.tree,{labels:Wr,errorExitCode:2,operationName:"merge"});if(!qr.ok)return{stdout:qr.stdout,stderr:G+qr.stderr,exitCode:qr.exitCode};if(rr.conflicts.length>0){await J(s,"MERGE_HEAD",F),await J(s,"ORIG_HEAD",c);let fe=await gr(s,Rr,Se,w.url),Ke=zt({version:2,entries:rr.entries}).sort();return fe+=`
616
631
  # Conflicts:
617
- ${Le.map(ht=>`# ${ht}`).join(`
632
+ ${Ke.map(nt=>`# ${nt}`).join(`
618
633
  `)}
619
- `,await Me(s,"MERGE_MSG",le),await Me(s,"MERGE_MODE",te?"no-ff":""),{stdout:`${[...nr.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
634
+ `,await Le(s,"MERGE_MSG",fe),await Le(s,"MERGE_MODE",z?"no-ff":""),{stdout:`${[...rr.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
620
635
  `)}
621
- `,stderr:G,exitCode:1}}let Ms=zr.mergedTreeHash,oi=await un(s,r.env);if(M(oi))return oi;let ii=await tt(s,r.env);if(M(ii))return ii;let js=await gr(s,Rr,Se,g.url),Ga={repo:s,message:js,treeHash:Ms,headHash:a,theirsHash:F},Na=await t?.hooks?.mergeMsg?.(Ga);if(fe(Na))return{stdout:"",stderr:Na.message??"",exitCode:1};js=Ga.message;let Fa=await t?.hooks?.preMergeCommit?.({repo:s,message:js,treeHash:Ms,headHash:a,theirsHash:F});if(fe(Fa))return{stdout:"",stderr:Fa.message??"",exitCode:1};let Ls=await yt(s,Ms,[a,F],oi,ii,js);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:F,strategy:"three-way",commitHash:Ls}),await t?.hooks?.postPull?.({repo:s,remote:l,branch:w,strategy:"three-way",commitHash:Ls});let Qd=c?.type==="symbolic"?c.target:"HEAD",_a=`pull${te?" --no-ff":""}: Merge made by the 'ort' strategy.`;await ft(s,Qd,{oldHash:a,newHash:Ls,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:_a}),c?.type==="symbolic"&&await ft(s,"HEAD",{oldHash:a,newHash:Ls,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:_a});let eu=await pn(s,La.tree,Ms);return{stdout:`${nr.messages.length>0?`${nr.messages.join(`
636
+ `,stderr:G,exitCode:1}}let As=qr.mergedTreeHash,fi=await mn(s,r.env);if(M(fi))return fi;let li=await tt(s,r.env);if(M(li))return li;let Ds=await gr(s,Rr,Se,w.url),qa={repo:s,message:Ds,treeHash:As,headHash:c,theirsHash:F},Ka=await t?.hooks?.mergeMsg?.(qa);if(de(Ka))return{stdout:"",stderr:Ka.message??"",exitCode:1};Ds=qa.message;let za=await t?.hooks?.preMergeCommit?.({repo:s,message:Ds,treeHash:As,headHash:c,theirsHash:F});if(de(za))return{stdout:"",stderr:za.message??"",exitCode:1};let Ms=await Ot(s,As,[c,F],fi,li,Ds);await t?.hooks?.postMerge?.({repo:s,headHash:c,theirsHash:F,strategy:"three-way",commitHash:Ms}),await t?.hooks?.postPull?.({repo:s,remote:d,branch:b,strategy:"three-way",commitHash:Ms});let mu=f?.type==="symbolic"?f.target:"HEAD",Va=`pull${z?" --no-ff":""}: Merge made by the 'ort' strategy.`;await st(s,mu,{oldHash:c,newHash:Ms,name:L.name,email:L.email,timestamp:L.timestamp,tz:L.tz,message:Va}),f?.type==="symbolic"&&await st(s,"HEAD",{oldHash:c,newHash:Ms,name:L.name,email:L.email,timestamp:L.timestamp,tz:L.tz,message:Va});let pu=await gn(s,Wa.tree,As);return{stdout:`${rr.messages.length>0?`${rr.messages.join(`
622
637
  `)}
623
638
  `:""}Merge made by the 'ort' strategy.
624
- ${eu}`,stderr:G,exitCode:0}}})}async function rw(e,t,n){let r=!!t.noFf,o=!!t.ffOnly,s=!!t.rebase||!!t.noRebase||!!t.noFf||!!t.ffOnly,i=!1;if(t.rebase)i=!0;else if(!t.noRebase)if(n?.type==="symbolic"){let a=n.target.startsWith("refs/heads/")?n.target.slice(11):n.target,c=await xe(e,`branch.${a}.rebase`);c==="true"?(i=!0,s=!0):c==="false"?s=!0:await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0)}else await xe(e,"pull.rebase")==="true"&&(i=!0,s=!0);if(!t.noFf&&!t.ffOnly){let a=await xe(e,"pull.ff");a==="false"?(r=!0,s=!0):a==="only"&&(o=!0,s=!0)}return{useRebase:i,noFf:r,ffOnly:o,configured:s}}se();Be();pt();ge();function Rd(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[K.string().name("remote").describe("Remote to push to").optional(),K.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:S().alias("f").describe("Force push"),"set-upstream":S().alias("u").describe("Set upstream tracking reference"),all:S().describe("Push all branches"),delete:S().alias("d").describe("Delete remote refs"),tags:S().describe("Push all tags")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a=n.refspec;if(!n.delete&&!n.all&&!n.tags&&(!a||a.length===0)){let P=await Q(s);if(!P||P.type!=="symbolic")return I(`You are not currently on a branch.
625
- To push the history leading to the current (detached HEAD)
626
- state now, use
627
-
628
- git push origin HEAD:<name-of-remote-branch>
629
- `)}let c;try{c=await Wr(s,i,r.env)}catch(P){let T=P instanceof Error?P.message:"";if(T.startsWith("network"))return I(T);throw P}if(!c)return I(`'${i}' does not appear to be a git repository`);let{transport:f,config:l}=c,d=n.force,u=await f.advertiseRefs(),h=new Map;for(let P of u)h.set(P.name,P.hash);if(n.tags&&n.all)return I("options '--tags' and '--all/--branches' cannot be used together");if(n.tags&&n.delete)return I("options '--delete' and '--tags' cannot be used together");let m=[];if(n.delete){let P=a&&a.length>0?a:[];if(P.length===0)return I("--delete requires a ref argument");let T=[];for(let A of P){let U=A.startsWith("refs/")?A:`refs/heads/${A}`,_=h.get(U)??null;if(!_){T.push(`error: unable to delete '${A}': remote ref does not exist
630
- `);continue}m.push({name:U,oldHash:_,newHash:ne,ok:d})}if(T.length>0&&m.length===0)return N(T.join("")+`error: failed to push some refs to '${l.url}'
631
- `)}else if(n.all){let P=await we(s,"refs/heads");for(let T of P){let A=T.name,U=h.get(A)??null;m.push({name:A,oldHash:U,newHash:T.hash,ok:d})}}else if(a&&a.length>0)for(let P of a){let T=kr(P),A=P.replace(/^\+/,"").includes(":"),U=T.dst;if(!A&&T.src==="HEAD"){let L=await Q(s);if(L?.type==="symbolic")U=L.target.startsWith("refs/heads/")?L.target.slice(11):L.target;else return{stdout:"",stderr:`error: The destination you provided is not a full refname (i.e.,
639
+ ${pu}`,stderr:G,exitCode:0}}})}async function xw(e,t,n){let r=!!t.noFf,o=!!t.ffOnly,s=t.ffOnly?"cli":null,i=!!t.rebase||!!t.noRebase||!!t.noFf||!!t.ffOnly,a=!1;if(t.rebase)a=!0;else if(!t.noRebase)if(n?.type==="symbolic"){let c=n.target.startsWith("refs/heads/")?n.target.slice(11):n.target,f=await ke(e,`branch.${c}.rebase`);if(f==="true")a=!0,i=!0;else if(f==="false")i=!0;else{let l=await ke(e,"pull.rebase");l==="true"?(a=!0,i=!0):l==="false"&&(i=!0)}}else{let c=await ke(e,"pull.rebase");c==="true"?(a=!0,i=!0):c==="false"&&(i=!0)}if(!t.noFf&&!t.ffOnly){let c=await ke(e,"pull.ff");if(c==="false")r=!0,i=!0;else if(c==="only")o=!0,s="pull",i=!0;else{let f=await ke(e,"merge.ff");f==="false"?r=!0:f==="only"&&(o=!0,s="merge")}}return{useRebase:a,noFf:r,ffOnly:o,ffOnlySource:s,hasReconciliationStrategy:i}}se();Ue();pt();ge();function jd(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:O().alias("f").describe("Force push"),"set-upstream":O().alias("u").describe("Set upstream tracking reference"),all:O().describe("Push all branches"),delete:O().alias("d").describe("Delete remote refs"),tags:O().describe("Push all tags")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a=n.refspec,c;try{c=await Uo(s,i,r.env)}catch($){let v=$ instanceof Error?$.message:"";if(v.startsWith("network"))return S(v);throw $}if(!c)return S(`'${i}' does not appear to be a git repository`);let{transport:f,config:l}=c,d=n.force,u=await f.advertiseRefs(),h=new Map;for(let $ of u)h.set($.name,$.hash);if(n.tags&&n.all)return S("options '--tags' and '--all/--branches' cannot be used together");if(n.tags&&n.delete)return S("options '--delete' and '--tags' cannot be used together");let m=[];if(n.delete){let $=a&&a.length>0?a:[];if($.length===0)return S("--delete requires a ref argument");let v=[];for(let N of $){let L=N.startsWith("refs/")?N:h.has(`refs/heads/${N}`)?`refs/heads/${N}`:h.has(`refs/tags/${N}`)?`refs/tags/${N}`:`refs/heads/${N}`,I=h.get(L)??null;if(!I){v.push(`error: unable to delete '${N}': remote ref does not exist
640
+ `);continue}m.push({name:L,oldHash:I,newHash:ne,ok:d})}if(v.length>0&&m.length===0)return _(v.join("")+`error: failed to push some refs to '${l.url}'
641
+ `)}else if(n.all){let $=await ye(s,"refs/heads");for(let v of $){let N=v.name,L=h.get(N)??null;m.push({name:N,oldHash:L,newHash:v.hash,ok:d})}}else if(a&&a.length>0)for(let $ of a){let v=kr($),N=$.replace(/^\+/,"").includes(":"),L=v.dst;if(!N&&v.src==="HEAD"){let W=await te(s);if(W?.type==="symbolic")L=W.target.startsWith("refs/heads/")?W.target.slice(11):W.target;else return{stdout:"",stderr:`error: The destination you provided is not a full refname (i.e.,
632
642
  starting with "refs/"). We tried to guess what you meant by:
633
643
 
634
644
  - Looking for a ref that matches 'HEAD' on the remote side.
@@ -641,55 +651,56 @@ hint: The <src> part of the refspec is a commit object.
641
651
  hint: Did you mean to create a new branch by pushing to
642
652
  hint: 'HEAD:refs/heads/HEAD'?
643
653
  error: failed to push some refs to '${l.url}'
644
- `,exitCode:1}}let _=await ow(s,T.src);if(!_)return N(`error: src refspec ${T.src} does not match any
654
+ `,exitCode:1}}let I=await Pw(s,v.src);if(!I)return _(`error: src refspec ${v.src} does not match any
645
655
  error: failed to push some refs to '${l.url}'
646
- `);let O=U.startsWith("refs/")?U:`refs/heads/${U}`,H=h.get(O)??null;m.push({name:O,oldHash:H,newHash:_,ok:d||T.force})}else if(!n.tags){let P=await Q(s);if(!P||P.type!=="symbolic")return I(`You are not currently on a branch.
656
+ `);let T;L.startsWith("refs/")?T=L:!N&&I.fullRef.startsWith("refs/")?T=I.fullRef.slice(0,I.fullRef.indexOf("/",5)+1)+L:T=`refs/heads/${L}`;let G=h.get(T)??null;m.push({name:T,oldHash:G,newHash:I.hash,ok:d||v.force})}else if(!n.tags){let $=(await ke(s,"push.default"))?.toLowerCase()??"simple";if($==="nothing")return S(`You didn't specify any refspecs to push, and push.default is "nothing".`);let v=await te(s);if(!v||v.type!=="symbolic")return S(`You are not currently on a branch.
647
657
  To push the history leading to the current (detached HEAD)
648
658
  state now, use
649
659
 
650
660
  git push origin HEAD:<name-of-remote-branch>
651
- `);let T=P.target,A=T.startsWith("refs/heads/")?T.slice(11):T,U=await X(s);if(!U)return N(`error: src refspec does not match any
652
- `);let _=(await xe(s,"push.default"))?.toLowerCase()??"simple",O=await sw(s,_,T,A,U,i,h,d);if("exitCode"in O)return O;m.push(O)}if(n.tags){let P=await we(s,"refs/tags");for(let T of P){let A=h.get(T.name)??null;A!==T.hash&&(m.some(U=>U.name===T.name)||m.push({name:T.name,oldHash:A,newHash:T.hash,ok:d}))}}let p=m.filter(P=>P.oldHash!==P.newHash);if(p.length===0){let P="";if(n["set-upstream"]){let T=await Q(s);if(T?.type==="symbolic"){let A=T.target.startsWith("refs/heads/")?T.target.slice(11):T.target,U=await pe(s);U[`branch "${A}"`]={remote:i,merge:`refs/heads/${A}`},await ze(s,U),P=`branch '${A}' set up to track '${i}/${A}'.
653
- `}}return{stdout:P,stderr:`Everything up-to-date
654
- `,exitCode:0}}let g=await t?.hooks?.prePush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===ne?null:P.name,srcHash:P.newHash===ne?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===ne}))});if(fe(g))return N(g.message??"");let w=new Set(p.filter(P=>P.ok).map(P=>P.name)),b=await f.push(p),E=b.updates.filter(P=>P.ok&&P.oldHash&&P.newHash!==ne&&w.has(P.name)),k=await Promise.all(E.map(P=>en(s,P.oldHash,P.newHash))),R=new Set;E.forEach((P,T)=>{k[T]||R.add(P.name)});let x=[],y=!1;for(let P of b.updates){let T=P.name.startsWith("refs/tags/"),A=Ln(P.name);if(P.ok)if(P.oldHash)if(P.newHash===ne)x.push({prefix:" - [deleted]",from:A,to:""});else{let U=Z(P.oldHash),_=Z(P.newHash);R.has(P.name)?x.push({prefix:` + ${U}...${_}`,from:A,to:A,suffix:"(forced update)"}):x.push({prefix:` ${U}..${_}`,from:A,to:A})}else{let U=T?"[new tag]":"[new branch]";x.push({prefix:` * ${U}`,from:A,to:A})}else{let U=P.error?.includes("fetch first"),_=P.error?.includes("non-fast-forward"),O=U?"fetch first":_?"non-fast-forward":P.error??"failed";x.push({prefix:" ! [rejected]",from:A,to:A,suffix:`(${O})`}),y=!0}}x.sort((P,T)=>kd(P)-kd(T));let C=[];if(C.push(`To ${l.url}
661
+ `);let N=v.target,L=N.startsWith("refs/heads/")?N.slice(11):N,I=await Z(s);if(!I)return _(`error: src refspec does not match any
662
+ `);let T=await Cw(s,$,N,L,I,i,h,d);if("exitCode"in T)return T;m.push(T)}if(n.tags){let $=await ye(s,"refs/tags");for(let v of $){let N=h.get(v.name)??null;N!==v.hash&&(m.some(L=>L.name===v.name)||m.push({name:v.name,oldHash:N,newHash:v.hash,ok:d}))}}let p=m.filter($=>$.oldHash!==$.newHash);if(p.length===0){let $="";if(n["set-upstream"]){let v=await te(s);if(v?.type==="symbolic"){let N=v.target.startsWith("refs/heads/")?v.target.slice(11):v.target,L=await pe(s);L[`branch "${N}"`]={remote:i,merge:`refs/heads/${N}`},await ze(s,L),$=`branch '${N}' set up to track '${i}/${N}'.
663
+ `}}return{stdout:$,stderr:`Everything up-to-date
664
+ `,exitCode:0}}let g=await t?.hooks?.prePush?.({repo:s,remote:i,url:l.url,refs:p.map($=>({srcRef:$.newHash===ne?null:$.name,srcHash:$.newHash===ne?null:$.newHash,dstRef:$.name,dstHash:$.oldHash,force:!!$.ok,delete:$.newHash===ne}))});if(de(g))return _(g.message??"");let w=new Set(p.filter($=>$.ok).map($=>$.name)),b=await f.push(p),R=b.updates.filter($=>$.ok&&$.oldHash&&$.newHash!==ne&&w.has($.name)),E=await Promise.all(R.map($=>tn(s,$.oldHash,$.newHash))),k=new Set;R.forEach(($,v)=>{E[v]||k.add($.name)});let x=[],y=!1,P=!1;for(let $ of b.updates){let v=$.name.startsWith("refs/tags/"),N=Gt($.name);if($.ok)if($.oldHash)if($.newHash===ne)x.push({prefix:" - [deleted]",from:N,to:""});else{let L=X($.oldHash),I=X($.newHash);k.has($.name)?x.push({prefix:` + ${L}...${I}`,from:N,to:N,suffix:"(forced update)"}):x.push({prefix:` ${L}..${I}`,from:N,to:N})}else{let L=v?"[new tag]":"[new branch]";x.push({prefix:` * ${L}`,from:N,to:N})}else{let L=$.error?.includes("fetch first"),I=$.error?.includes("non-fast-forward");v&&I&&(P=!0);let T=L?"fetch first":v&&I?"already exists":I?"non-fast-forward":$.error??"failed";x.push({prefix:" ! [rejected]",from:N,to:N,suffix:`(${T})`}),y=!0}}x.sort(($,v)=>Md($)-Md(v));let C=[];if(C.push(`To ${l.url}
655
665
  `),C.push(Dr(x,0,!1)),y){C.push(`error: failed to push some refs to '${l.url}'
656
- `);let P=b.updates.some(A=>!A.ok&&A.error?.includes("fetch first")),T=b.updates.some(A=>!A.ok&&A.error?.includes("non-fast-forward"));P?C.push(`hint: Updates were rejected because the remote contains work that you do not
666
+ `);let $=b.updates.some(N=>!N.ok&&N.error?.includes("fetch first")),v=b.updates.some(N=>!N.ok&&N.error?.includes("non-fast-forward"));P?C.push(`hint: Updates were rejected because the tag already exists in the remote.
667
+ `):$?C.push(`hint: Updates were rejected because the remote contains work that you do not
657
668
  hint: have locally. This is usually caused by another repository pushing to
658
669
  hint: the same ref. If you want to integrate the remote changes, use
659
670
  hint: 'git pull' before pushing again.
660
671
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
661
- `):T&&C.push(`hint: Updates were rejected because the tip of your current branch is behind
672
+ `):v&&C.push(`hint: Updates were rejected because the tip of your current branch is behind
662
673
  hint: its remote counterpart. If you want to integrate the remote changes,
663
674
  hint: use 'git pull' before pushing again.
664
675
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
665
- `)}let $="";for(let P of b.updates){if(!P.ok||!P.name.startsWith("refs/heads/"))continue;let T=`refs/remotes/${i}/${P.name.slice(11)}`;P.newHash===ne?await he(s,T):await J(s,T,P.newHash)}if(n["set-upstream"]&&!y){let P=await Q(s);if(P?.type==="symbolic"){let T=P.target.startsWith("refs/heads/")?P.target.slice(11):P.target,A=await pe(s);A[`branch "${T}"`]={remote:i,merge:`refs/heads/${T}`},await ze(s,A),$=`branch '${T}' set up to track '${i}/${T}'.
666
- `}}let D={stdout:$,stderr:C.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:l.url,refs:p.map(P=>({srcRef:P.newHash===ne?null:P.name,srcHash:P.newHash===ne?null:P.newHash,dstRef:P.name,dstHash:P.oldHash,force:!!P.ok,delete:P.newHash===ne}))}),D}})}async function sw(e,t,n,r,o,s,i,a){if(t==="nothing")return I(`You didn't specify any refspecs to push, and push.default is "nothing".`);if(t==="current")return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a};if(t==="upstream"){let d=(await pe(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return I(`The current branch ${r} has no upstream branch.
676
+ `)}let A="";for(let $ of b.updates){if(!$.ok||!$.name.startsWith("refs/heads/"))continue;let v=`refs/remotes/${i}/${$.name.slice(11)}`;$.newHash===ne?await he(s,v):await J(s,v,$.newHash)}if(n["set-upstream"]&&!y){let $=await te(s);if($?.type==="symbolic"){let v=$.target.startsWith("refs/heads/")?$.target.slice(11):$.target,N=await pe(s);N[`branch "${v}"`]={remote:i,merge:`refs/heads/${v}`},await ze(s,N),A=`branch '${v}' set up to track '${i}/${v}'.
677
+ `}}let D={stdout:A,stderr:C.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:l.url,refs:p.map($=>({srcRef:$.newHash===ne?null:$.name,srcHash:$.newHash===ne?null:$.newHash,dstRef:$.name,dstHash:$.oldHash,force:!!$.ok,delete:$.newHash===ne}))}),D}})}async function Cw(e,t,n,r,o,s,i,a){if(t==="nothing")return S(`You didn't specify any refspecs to push, and push.default is "nothing".`);if(t==="current")return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a};if(t==="upstream"){let d=(await pe(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return S(`The current branch ${r} has no upstream branch.
667
678
  To push the current branch and set the remote as upstream, use
668
679
 
669
680
  git push --set-upstream ${s} ${r}
670
- `);let u=d.merge;return{name:u,oldHash:i.get(u)??null,newHash:o,ok:a}}let f=(await pe(e))[`branch "${r}"`];if(f?.remote&&f?.merge){let l=f.remote,d=f.merge;if(l===s){let u=d.startsWith("refs/heads/")?d.slice(11):d;return u!==r?I(`The upstream branch of your current branch does not match
681
+ `);let u=d.merge;return{name:u,oldHash:i.get(u)??null,newHash:o,ok:a}}let c=await pe(e),f=c[`branch "${r}"`];if(f?.remote&&f?.merge){let l=f.remote,d=f.merge,u=c.push?.default?.toLowerCase();if(l===s){let h=d.startsWith("refs/heads/")?d.slice(11):d;if(h!==r){let m=u==="simple"?"":`To choose either option permanently, see push.default in 'git help config'.
682
+
683
+ `;return S(`The upstream branch of your current branch does not match
671
684
  the name of your current branch. To push to the upstream branch
672
685
  on the remote, use
673
686
 
674
- git push ${s} HEAD:${u}
687
+ git push ${s} HEAD:${h}
675
688
 
676
689
  To push to the branch of the same name on the remote, use
677
690
 
678
691
  git push ${s} HEAD
679
692
 
680
- To choose either option permanently, see push.default in 'git help config'.
681
-
682
- To avoid automatically configuring an upstream branch when its name
693
+ `+m+`To avoid automatically configuring an upstream branch when its name
683
694
  won't match the local branch, see option 'simple' of branch.autoSetupMerge
684
695
  in 'git help config'.
685
- `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}return I(`The current branch ${r} has no upstream branch.
696
+ `)}return{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}return S(`The current branch ${r} has no upstream branch.
686
697
  To push the current branch and set the remote as upstream, use
687
698
 
688
699
  git push --set-upstream ${s} ${r}
689
700
 
690
701
  To have this happen automatically for branches without a tracking
691
702
  upstream, see 'push.autoSetupRemote' in 'git help config'.
692
- `)}function kd(e){return e.prefix.startsWith(" ")||e.prefix.startsWith(" + ")?0:e.prefix.includes("[new ")?1:e.prefix.includes("[deleted]")?2:e.prefix.includes("[rejected]")?3:4}async function ow(e,t){if(t.startsWith("refs/"))return W(e,t);let n=await W(e,`refs/heads/${t}`);if(n)return n;let r=await W(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}se();ge();function xd(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[K.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Y.string().describe("Starting point at which to create new commits"),abort:S().describe("Abort the current rebase operation"),continue:S().describe("Continue the rebase after conflict resolution"),skip:S().describe("Skip the current patch and continue"),"reapply-cherry-picks":S().describe("Do not skip commits that are cherry-pick equivalents"),"no-reapply-cherry-picks":S().describe("Skip commits that are cherry-pick equivalents (default)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return wd(s,r.env);if(n.continue)return bd(s,r.env,t?.mergeDriver);if(n.skip)return yd(s,r.env,t?.mergeDriver);let i=n.upstream;if(!i)return I("no upstream configured and no upstream argument given");if(await _t(s))return I(`It seems that there is already a rebase-merge directory, and
703
+ `)}function Md(e){return e.prefix.startsWith(" ")||e.prefix.startsWith(" + ")?0:e.prefix.includes("[new ")?1:e.prefix.includes("[deleted]")?2:e.prefix.includes("[rejected]")?3:4}async function Pw(e,t){if(t.startsWith("refs/")){let o=await U(e,t);return o?{hash:o,fullRef:t}:null}let n=await U(e,`refs/heads/${t}`);if(n)return{hash:n,fullRef:`refs/heads/${t}`};let r=await U(e,`refs/tags/${t}`);if(r)return{hash:r,fullRef:`refs/tags/${t}`};if(t==="HEAD"){let o=await Z(e);return o?{hash:o,fullRef:"HEAD"}:null}return null}se();ge();function Ld(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:O().describe("Abort the current rebase operation"),continue:O().describe("Continue the rebase after conflict resolution"),skip:O().describe("Skip the current patch and continue"),"reapply-cherry-picks":O().describe("Do not skip commits that are cherry-pick equivalents"),"no-reapply-cherry-picks":O().describe("Skip commits that are cherry-pick equivalents (default)")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Td(s,r.env);if(n.continue)return vd(s,r.env,t?.mergeDriver);if(n.skip)return Hd(s,r.env,t?.mergeDriver);let i=n.upstream;if(!i)return S("no upstream configured and no upstream argument given");if(await Ut(s))return S(`It seems that there is already a rebase-merge directory, and
693
704
  I wonder if you are in the middle of another rebase. If that is the
694
705
  case, please try
695
706
  git rebase (--continue | --abort | --skip)
@@ -697,181 +708,192 @@ If that is not the case, please
697
708
  rm -fr ".git/rebase-merge"
698
709
  and run me again. I am stopping in case you still have something
699
710
  valuable there.
700
- `);let a=await Je(s);if(M(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Ge(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,u,h=n.onto;if(h){let p=await Ge(s,h,`Does not point to a valid commit: '${h}'`);if(M(p))return p;u=p.hash}else u=d;let m=!!n["reapply-cherry-picks"];return ei(s,r.env,a,f,d,u,i,t,m?{reapplyCherryPicks:!0}:void 0)}})}se();me();Ke();ge();function iw(e,t,n,r){return`${Z(n)} ${e}@{${t}}: ${r}`}async function ti(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await W(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
711
+ `);let a=await Qe(s);if(M(a))return a;let c=await te(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Me(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,u,h=n.onto;if(h){let g=await Me(s,h,`Does not point to a valid commit: '${h}'`);if(M(g))return g;u=g.hash}else u=d;let m=!!n["reapply-cherry-picks"],p=h??i;return ri(s,r.env,a,f,d,u,i,p,t,m?{reapplyCherryPicks:!0}:void 0)}})}se();me();Be();ge();function $w(e,t,n,r){return`${X(n)} ${e}@{${t}}: ${r}`}async function si(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await U(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
701
712
  Use '--' to separate paths from revisions, like this:
702
713
  'git <command> [<revision>...] -- [<file>...]'
703
- `,exitCode:128};let s=await Qe(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let l=s.length-1;l>=0&&c<a;l--){let d=s[l];if(!d)continue;let u=s.length-1-l;d.newHash!==ne&&(i.push(iw(t,u,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
714
+ `,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 u=s.length-1-l;d.newHash!==ne&&(i.push($w(t,u,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
704
715
  `)}
705
- `:"",stderr:"",exitCode:0}}function Cd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[K.string().name("args").variadic().optional()],options:{maxCount:Y.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return ti(i,"HEAD",r.maxCount);let c=a[0];if(!c)return ti(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return ti(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
706
- `,exitCode:128};let l=v(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return ti(i,c,r.maxCount)}})}se();Be();Ke();ge();function aw(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 Pd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:S().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=aw(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let h=c[`remote "${d}"`]?.url??"";l.push(`${d} ${h} (fetch)`),l.push(`${d} ${h} (push)`)}return{stdout:`${l.join(`
716
+ `:"",stderr:"",exitCode:0}}function Gd(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 K(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return si(i,"HEAD",r.maxCount);let c=a[0];if(!c)return si(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return si(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
717
+ `,exitCode:128};let l=H(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return si(i,c,r.maxCount)}})}se();Ue();Be();ge();function Ow(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 Nd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:O().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=Ow(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let h=c[`remote "${d}"`]?.url??"";l.push(`${d} ${h} (fetch)`),l.push(`${d} ${h} (push)`)}return{stdout:`${l.join(`
707
718
  `)}
708
719
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
709
720
  `)}
710
- `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[K.string().name("name").describe("Remote name"),K.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!as(`refs/remotes/${s.name}`,0))return I(`'${s.name}' is not a valid remote name`);let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(f in c)return N(`error: remote ${s.name} already exists.
711
- `,3);let l=yr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await ze(a,c),{stdout:"",stderr:"",exitCode:0}}});let r=async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?(delete c[f],fw(c,s.name),await ze(a,c),await lw(a,s.name),{stdout:"",stderr:"",exitCode:0}):N(`error: No such remote: '${s.name}'
712
- `,2)},o=[K.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[K.string().name("old").describe("Current remote name"),K.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a);return cw(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[K.string().name("name").describe("Remote name"),K.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(!(f in c))return N(`error: No such remote '${s.name}'
713
- `,2);let l=yr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await ze(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[K.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await q(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
714
- `,stderr:"",exitCode:0}:N(`error: No such remote '${s.name}'
715
- `,2)}})}async function cw(e,t,n,r){if(!as(`refs/remotes/${r}`,0))return I(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return N(`error: No such remote: '${n}'
716
- `,2);let s=`remote "${r}"`;if(s in t)return I(`remote ${r} already exists.`);let i={...t[o]};i.fetch&&(i.fetch=i.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=i,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await ze(e,t);let a=`refs/remotes/${n}`,c=await we(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await Qe(e,f.name);await J(e,l,f.hash),await he(e,f.name),d.length>0&&await Fn(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function fw(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 lw(e,t){let n=`refs/remotes/${t}`,r=await we(e,n);for(let o of r)await he(e,o.name)}se();Ce();ie();me();Ke();ge();async function $d(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await we(e,"refs");for(let a of r)t.add(a.hash);let o=v(e.gitDir,"logs");await e.fs.exists(o)&&await Od(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 W(e,a);c&&t.add(c)}let i=[];for(let a of t)await Zt(e,a)&&i.push(a);return i}async function Od(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=v(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Od(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await Qe(e,c);for(let l of f)l.newHash!==ne&&r.add(l.newHash)}}}function Sd(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:S().alias("a").describe("Pack all objects, including already-packed"),delete:S().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await $d(s),a=await zo({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Vo(a.totalCount,a.deltaCount)}
721
+ `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!os(`refs/remotes/${s.name}`,0))return S(`'${s.name}' is not a valid remote name`);let a=await K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(f in c)return _(`error: remote ${s.name} already exists.
722
+ `,3);let l=yr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await ze(a,c),{stdout:"",stderr:"",exitCode:0}}});let r=async(s,i)=>{let a=await K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Iw(c,s.name),await ze(a,c),await Tw(a,s.name),{stdout:"",stderr:"",exitCode:0}):_(`error: No such remote: '${s.name}'
723
+ `,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 K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a);return Sw(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 K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;if(!(f in c))return _(`error: No such remote '${s.name}'
724
+ `,2);let l=yr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await ze(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await K(i.fs,i.cwd,t);if(M(a))return a;let c=await pe(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
725
+ `,stderr:"",exitCode:0}:_(`error: No such remote '${s.name}'
726
+ `,2)}})}async function Sw(e,t,n,r){if(!os(`refs/remotes/${r}`,0))return S(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return _(`error: No such remote: '${n}'
727
+ `,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 ye(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await et(e,f.name);await J(e,l,f.hash),await he(e,f.name),d.length>0&&await Un(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Iw(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 Tw(e,t){let n=`refs/remotes/${t}`,r=await ye(e,n);for(let o of r)await he(e,o.name)}se();Ce();ie();me();Be();ge();async function Fd(e){let t=new Set,n=await Z(e);n&&t.add(n);let r=await ye(e,"refs");for(let a of r)t.add(a.hash);let o=H(e.gitDir,"logs");await e.fs.exists(o)&&await _d(e,o,o,t);let s=await V(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 U(e,a);c&&t.add(c)}let i=[];for(let a of t)await wt(e,a)&&i.push(a);return i}async function _d(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=H(t,s),a=await e.fs.stat(i);if(a.isDirectory)await _d(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!==ne&&r.add(l.newHash)}}}function Ud(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:O().alias("a").describe("Pack all objects, including already-packed"),delete:O().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Fd(s),a=await Xo({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${Zo(a.totalCount,a.deltaCount)}
717
728
  `,exitCode:0}:{stdout:`Nothing new to pack.
718
- `,stderr:"",exitCode:0}}})}se();Ce();ie();me();Ke();ge();cn();De();Jt();et();function Td(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[K.string().name("args").variadic().optional()],options:{soft:S().describe("Only move HEAD"),mixed:S().describe("Move HEAD and reset index (default)"),hard:S().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return I("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=dt(i,r.cwd);if(o.passthrough.length>0){let h=a.length>0?a[0]:void 0;return Ia(i,o.passthrough,l,h,t)}if(!f&&a.length>0){let h=a[0],m=await We(i,h);return a.length===1&&m?Id(i,h,"mixed",r.env,t):m?Ia(i,a.slice(1),l,h,t):Ia(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return Id(i,u,d,r.env,t)}})}async function Ia(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await We(e,r);if(!d)return Qt(r);let u=await He(e,d);i=(await j(e,u)).tree}else{let d=await X(e);d&&(i=(await j(e,d)).tree)}let a=await de(e,i??null),c=await z(e);if(t.some(lr)){let d=t.map(h=>Ue(h,n)),u=new Set;for(let[h]of a)u.add(h);for(let h of c.entries)u.add(h.path);for(let h of u){if(!Ee(d,h))continue;let m=a.get(h);m?c=Pt(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:ve()}):c=ct(c,h)}}else for(let d of t){let u=a.get(d);if(u)c=Pt(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:ve()});else if(c.entries.some(m=>m.path===d))c=ct(c,d);else if(!(e.workTree&&await e.fs.exists(v(e.workTree,d))))return Qt(d)}await ae(e,c);let l={stdout:await vd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function vd(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await wt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
719
- `)}
720
- `}async function Id(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Qt(t);let a=await He(e,i),c=await j(e,a);if(n==="soft"){let h=await W(e,"MERGE_HEAD"),m=await z(e);if(h||jt(m))return I("Cannot do a soft reset in the middle of a merge.")}let f=await X(e),l=await Q(e);l?.type==="symbolic"?await J(e,l.target,a):await J(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await re(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await re(e,r,"HEAD",f,a,d),await ur(e),n==="mixed"){let h=await qe(e,c.tree),m=Vs(h.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:ve()})));await ae(e,m);let p=await vd(e,m);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let h=Ye(e);if(h)return h;let m=await z(e),p=await Cn(e,c.tree,m);await ae(e,{version:2,entries:p.newEntries}),await je(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${Z(a)} ${ue(c.message)}
721
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}se();Ce();ie();ge();De();et();function Ad(e,t){e.command("restore",{description:"Restore working tree files",args:[K.string().name("pathspec").variadic().optional()],options:{source:Y.string().alias("s").describe("Restore from tree-ish"),staged:S().alias("S").describe("Restore the index"),worktree:S().alias("W").describe("Restore the working tree (default)"),ours:S().describe("Checkout our version for unmerged files"),theirs:S().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return I("you must specify path(s) to restore");if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=dt(i,r.cwd);if(n.ours||n.theirs)return n.source?I("cannot specify both --source and --ours/--theirs"):c?I("cannot use --ours/--theirs with --staged"):$o(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let u=await Ge(i,n.source,`could not resolve '${n.source}'`);if(M(u))return u;d=u.commit.tree}else if(c){let u=await X(i);u&&(d=(await j(i,u)).tree)}return c&&f?hw(i,a,l,d):c?dw(i,a,l,d):d?uw(i,a,l,d):Po(i,a,l)}})}async function dw(e,t,n,r){let o=await de(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:ve()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
722
- `,exitCode:1};s=ct(s,f)}}return c?(await ae(e,s),{stdout:"",stderr:"",exitCode:0}):N(`error: pathspec '${t[0]}' did not match any file(s) known to git
723
- `)}async function uw(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await de(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await z(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(Ee(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
724
- `,exitCode:1};i.push(f)}if(i.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
725
- `);for(let f of i){let l=o.get(f);if(l)await lt(e,{path:l.path,hash:l.hash,mode:l.mode});else{let d=`${e.workTree}/${f}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function hw(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await de(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)Ee(i,f)&&a.push(f);if(a.length===0)return N(`error: pathspec '${t[0]}' did not match any file(s) known to git
726
- `);for(let f of a){let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:ve()}),await lt(e,{path:l.path,hash:l.hash,mode:l.mode});else{if(s.entries.some(h=>h.path===f&&h.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
727
- `,exitCode:1};s=ct(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}se();ie();me();ge();cn();De();function Hd(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[K.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:S().describe("Verify that exactly one parameter is provided and resolves to an object"),short:S().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":S().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":S().describe("Output the full symbolic ref name"),"show-toplevel":S().describe("Show the absolute path of the top-level directory"),"git-dir":S().describe("Show the path to the .git directory"),"is-inside-work-tree":S().describe("Output whether cwd is inside the work tree"),"is-bare-repository":S().describe("Output whether the repository is bare"),"show-prefix":S().describe("Show path of cwd relative to top-level directory"),"show-cdup":S().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(k=>k!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],u=n["is-bare-repository"],h=n["show-prefix"],m=n["show-cdup"],p=f||l||d||u||h||m,g=await q(r.fs,r.cwd,t);if(M(g))return g;let w=g,b=[];if(f){if(!w.workTree)return I("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"),u&&b.push(w.workTree?"false":"true"),h){if(!w.workTree)return I("this operation must be run in a work tree");let k=nt(w.workTree,r.cwd);b.push(k===""?"":`${k}/`)}if(m){if(!w.workTree)return I("this operation must be run in a work tree");let k=nt(r.cwd,w.workTree);b.push(k===""?"":`${k}/`)}if(p&&o.length===0)return{stdout:b.map(R=>`${R}
728
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return I("Needed a single revision");for(let k of o){if(a){let y=await mw(w,k);if(y===null)return Ta(k,s);b.push(y);continue}if(c){let y=await pw(w,k);if(y===null)return Ta(k,s);b.push(y);continue}let R=ro(k);if(R){let y=await gw(w,R.rev,R.path);if(y===null){let C=R.path.replace(/^\//,"");return I(`path '${C}' does not exist in '${R.rev}'`)}b.push(i?Z(y):y);continue}let x=await We(w,k);if(!x)return Ta(k,s);b.push(i?Z(x):x)}return{stdout:b.map(k=>`${k}
729
- `).join(""),stderr:"",exitCode:0}}})}function Ta(e,t){return t?I("Needed a single revision"):Qt(e)}async function mw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function pw(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await W(e,o))return o}return t}async function gw(e,t,n){let r=await We(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await de(e,o.tree)).get(s)?.hash??null}se();Be();Ce();ie();Ke();ge();De();Jt();function Dd(e,t){e.command("revert",{description:"Revert some existing commits",args:[K.string().name("commit").describe("The commit to revert").optional()],options:{abort:S().describe("Abort the current revert operation"),continue:S().describe("Continue the revert after conflict resolution"),skip:S().describe("Skip the current commit and continue"),"no-commit":S().alias("n").describe("Apply changes without creating a commit"),"no-edit":S().describe("Do not edit the commit message"),mainline:Y.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let G=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(fe(G))return{stdout:"",stderr:G.message??"",exitCode:1};let B=await ww(s,r.env);return B.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),B}if(n.continue){let G=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(fe(G))return{stdout:"",stderr:G.message??"",exitCode:1};let B=await yw(s,r.env);if(B.exitCode===0){let F=await X(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:F,hadConflicts:!1})}return B}if(n.skip)return bw(s,r.env);let i=n.commit;if(!i)return I("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commitRef:i});if(fe(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Ge(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Je(s);if(M(d))return d;let u=await z(s),h=Pn(u,"Reverting",`fatal: revert failed
730
- `);if(h)return h;let m=await j(s,d);if(s.workTree){let G=await de(s,m.tree);if(Wn(u,G))return N(`error: your local changes would be overwritten by revert.
729
+ `,stderr:"",exitCode:0}}})}se();Ce();ie();me();Be();ge();fn();Ae();Nt();Je();function Wd(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:O().describe("Only move HEAD"),mixed:O().describe("Move HEAD and reset index (default)"),hard:O().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await K(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 h=a.length>0?a[0]:void 0;return Ma(i,o.passthrough,l,h,t)}if(!f&&a.length>0){let h=a[0],m=await We(i,h);return a.length===1&&m?Bd(i,h,"mixed",r.env,t):m?Ma(i,a.slice(1),l,h,t):Ma(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return Bd(i,u,d,r.env,t)}})}async function Ma(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(de(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await We(e,r);if(!d)return Jt(r);let u=await Te(e,d);i=(await j(e,u)).tree}else{let d=await Z(e);d&&(i=(await j(e,d)).tree)}let a=await le(e,i??null),c=await V(e);if(t.some(dr)){let d=t.map(h=>_e(h,n)),u=new Set;for(let[h]of a)u.add(h);for(let h of c.entries)u.add(h.path);for(let h of u){if(!Ee(d,h))continue;let m=a.get(h);m?c=Pt(c,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:He()}):c=lt(c,h)}}else for(let d of t){let u=a.get(d);if(u)c=Pt(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:He()});else if(c.entries.some(m=>m.path===d))c=lt(c,d);else if(!(e.workTree&&await e.fs.exists(H(e.workTree,d))))return Jt(d)}await ae(e,c);let l={stdout:await qd(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function qd(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 bt(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(`
730
+ `)}
731
+ `}async function Bd(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(de(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await We(e,t);if(!i)return Jt(t);let a=await Te(e,i),c=await j(e,a);if(n==="soft"){let h=await U(e,"MERGE_HEAD"),m=await V(e);if(h||Lt(m))return S("Cannot do a soft reset in the middle of a merge.")}let f=await Z(e),l=await te(e);l?.type==="symbolic"?await J(e,l.target,a):await J(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await re(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await re(e,r,"HEAD",f,a,d),await hr(e),n==="mixed"){let h=await qe(e,c.tree),m=Ks(h.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:He()})));await ae(e,m);let p=await qd(e,m);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let h=Ye(e);if(h)return h;let m=await V(e),p=await On(e,c.tree,m);await ae(e,{version:2,entries:p.newEntries}),await De(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${X(a)} ${ue(c.message)}
732
+ `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}se();Ce();ie();ge();Ae();Je();function Kd(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:O().alias("S").describe("Restore the index"),worktree:O().alias("W").describe("Restore the working tree (default)"),ours:O().describe("Checkout our version for unmerged files"),theirs:O().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await K(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"):Co(i,a,l,n.theirs?3:2,{deleteOnMissing:!0});let d=null;if(n.source){let u=await Me(i,n.source,`could not resolve '${n.source}'`);if(M(u))return u;d=u.commit.tree}else if(c){let u=await Z(i);u&&(d=(await j(i,u)).tree)}return c&&f?Aw(i,a,l,d):c?vw(i,a,l,d):d?Hw(i,a,l,d):xo(i,a,l)}})}async function vw(e,t,n,r){let o=await le(e,r),s=await V(e),i=t.map(f=>_e(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:He()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
733
+ `,exitCode:1};s=lt(s,f)}}return c?(await ae(e,s),{stdout:"",stderr:"",exitCode:0}):_(`error: pathspec '${t[0]}' did not match any file(s) known to git
734
+ `)}async function Hw(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await le(e,r),s=t.map(f=>_e(f,n)),i=[],a=await V(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(Ee(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
735
+ `,exitCode:1};i.push(f)}if(i.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
736
+ `);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 Aw(e,t,n,r){if(!e.workTree)return S("this operation must be run in a work tree");let o=await le(e,r),s=await V(e),i=t.map(f=>_e(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)Ee(i,f)&&a.push(f);if(a.length===0)return _(`error: pathspec '${t[0]}' did not match any file(s) known to git
737
+ `);for(let f of a){let l=o.get(f);if(l)s=Pt(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:He()}),await dt(e,{path:l.path,hash:l.hash,mode:l.mode});else{if(s.entries.some(h=>h.path===f&&h.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
738
+ `,exitCode:1};s=lt(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await ae(e,s),{stdout:"",stderr:"",exitCode:0}}se();ie();me();ge();fn();Ae();function zd(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:O().describe("Verify that exactly one parameter is provided and resolves to an object"),short:O().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":O().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":O().describe("Output the full symbolic ref name"),"show-toplevel":O().describe("Show the absolute path of the top-level directory"),"git-dir":O().describe("Show the path to the .git directory"),"is-inside-work-tree":O().describe("Output whether cwd is inside the work tree"),"is-bare-repository":O().describe("Output whether the repository is bare"),"show-prefix":O().describe("Show path of cwd relative to top-level directory"),"show-cdup":O().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(E=>E!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],u=n["is-bare-repository"],h=n["show-prefix"],m=n["show-cdup"],p=f||l||d||u||h||m,g=await K(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"),u&&b.push(w.workTree?"false":"true"),h){if(!w.workTree)return S("this operation must be run in a work tree");let E=rt(w.workTree,r.cwd);b.push(E===""?"":`${E}/`)}if(m){if(!w.workTree)return S("this operation must be run in a work tree");let E=rt(r.cwd,w.workTree);b.push(E===""?"":`${E}/`)}if(p&&o.length===0)return{stdout:b.map(k=>`${k}
739
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return S("Needed a single revision");for(let E of o){if(a){let y=await Dw(w,E);if(y===null)return ja(E,s);b.push(y);continue}if(c){let y=await Mw(w,E);if(y===null)return ja(E,s);b.push(y);continue}let k=to(E);if(k){let y=await jw(w,k.rev,k.path);if(y===null){let P=k.path.replace(/^\//,"");return S(`path '${P}' does not exist in '${k.rev}'`)}b.push(i?X(y):y);continue}let x=await We(w,E);if(!x)return ja(E,s);b.push(i?X(x):x)}return{stdout:b.map(E=>`${E}
740
+ `).join(""),stderr:"",exitCode:0}}})}function ja(e,t){return t?S("Needed a single revision"):Jt(e)}async function Dw(e,t){if(t==="HEAD"||t==="@"){let r=await te(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await We(e,t)?t:null}async function Mw(e,t){if(t==="HEAD"||t==="@"){let r=await te(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await We(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await U(e,o))return o}return t}async function jw(e,t,n){let r=await We(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await le(e,o.tree)).get(s)?.hash??null}se();Ue();Ce();ie();Be();ge();Ae();Nt();function Vd(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:O().describe("Abort the current revert operation"),continue:O().describe("Continue the revert after conflict resolution"),skip:O().describe("Skip the current commit and continue"),"no-commit":O().alias("n").describe("Apply changes without creating a commit"),"no-edit":O().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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let L=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(de(L))return{stdout:"",stderr:L.message??"",exitCode:1};let I=await Lw(s,r.env);return I.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),I}if(n.continue){let L=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(de(L))return{stdout:"",stderr:L.message??"",exitCode:1};let I=await Nw(s,r.env);if(I.exitCode===0){let T=await Z(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:T,hadConflicts:!1})}return I}if(n.skip)return Gw(s,r.env);let i=n.commit;if(!i)return S("you must specify a commit to revert");let a=await t?.hooks?.preRevert?.({repo:s,mode:"revert",commitRef:i});if(de(a))return{stdout:"",stderr:a.message??"",exitCode:1};let c=await Me(s,i);if(M(c))return c;let f=c.hash,l=c.commit,d=await Qe(s);if(M(d))return d;let u=n["no-commit"]?"no-commit":"commit",h=await V(s),m=Fw(h,u);if(m)return m;let p=await j(s,d);if(s.workTree&&u==="commit"){let L=await le(s,p.tree);if(lr(h,L))return _(`error: your local changes would be overwritten by revert.
731
741
  hint: commit your changes or stash them to proceed.
732
742
  fatal: revert failed
733
- `,128)}let p=n.mainline,g;if(l.parents.length>1){if(p===void 0)return N(`error: commit ${f} is a merge but no -m option was given.
743
+ `,128)}let g=n.mainline,w;if(l.parents.length>1){if(g===void 0)return _(`error: commit ${f} is a merge but no -m option was given.
734
744
  fatal: revert failed
735
- `,128);if(p<1||p>l.parents.length)return N(`error: commit ${f} does not have parent ${p}
745
+ `,128);if(g<1||g>l.parents.length)return _(`error: commit ${f} does not have parent ${g}
736
746
  fatal: revert failed
737
- `,128);let G=l.parents[p-1];g=(await j(s,G)).tree}else if(l.parents.length===0)g=await _e(s,[]);else{let G=l.parents[0];g=(await j(s,G)).tree}let w=Z(f),b=ue(l.message),E=Ew(l,f,p),k=await xe(s,"merge.conflictstyle")??"merge",R={a:"HEAD",b:b?`parent of ${w} (${b})`:`parent of ${w}`,conflictStyle:k},x=await qt(s,l.tree,m.tree,g,R,t?.mergeDriver);if(x.conflicts.length===0&&x.resultTree===m.tree){let G=x.messages.length>0?`${x.messages.join(`
747
+ `,128);let L=l.parents[g-1];w=(await j(s,L)).tree}else if(l.parents.length===0)w=await Fe(s,[]);else{let L=l.parents[0];w=(await j(s,L)).tree}let b=X(f),R=ue(l.message),E=Uw(l,f,g),k=It(E),x=await ke(s,"merge.conflictstyle")??"merge",y={a:"HEAD",b:R?`parent of ${b} (${R})`:`parent of ${b}`,conflictStyle:x},P=await Kt(s,l.tree,p.tree,w,y,t?.mergeDriver);if(P.conflicts.length===0&&P.resultTree===p.tree){if(u==="no-commit")return await La(s,f,E),{stdout:"",stderr:"",exitCode:0};let L=P.messages.length>0?`${P.messages.join(`
738
748
  `)}
739
- `:"",B=await ot(s,{fromCommit:!0}),F=await W(s,"CHERRY_PICK_HEAD");return{stdout:`${G}${B}`,stderr:F?`The previous cherry-pick is now empty, possibly due to conflict resolution.
749
+ `:"",I=await at(s,{fromCommit:!0}),T=await U(s,"CHERRY_PICK_HEAD");return{stdout:`${L}${I}`,stderr:T?`The previous cherry-pick is now empty, possibly due to conflict resolution.
740
750
  If you wish to commit it anyway, use:
741
751
 
742
752
  git commit --allow-empty
743
753
 
744
754
  Otherwise, please use 'git cherry-pick --skip'
745
- `:"",exitCode:1}}let y=await Sn(s,x,m.tree,{labels:R,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!y.ok)return y;if(x.conflicts.length>0){await J(s,"REVERT_HEAD",f),await J(s,"ORIG_HEAD",d),await Me(s,"MERGE_MSG",E);let G=x.messages.join(`
746
- `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:G?`${G}
747
- `:"",stderr:`error: could not revert ${w}... ${ue(l.message)}
748
- hint: After resolving the conflicts, mark them with
749
- hint: "git add/rm <pathspec>", then run
750
- hint: "git revert --continue".
751
- hint: You can instead skip this commit with "git revert --skip".
752
- hint: To abort and get back to the state before "git revert",
753
- hint: run "git revert --abort".
754
- hint: Disable this message with "git config set advice.mergeConflict false"
755
- `,exitCode:1}}if(n["no-commit"])return await J(s,"REVERT_HEAD",f),await Me(s,"MERGE_MSG",E),{stdout:"",stderr:"",exitCode:0};let C=y.mergedTreeHash,$=await un(s,r.env);if(M($))return $;let D=await tt(s,r.env);if(M(D))return D;let P=await yt(s,C,[d],$,D,E);await St(s),await Ft(s);let T=await Q(s),A=ue(E),U=T?.type==="symbolic"?T.target:"HEAD";await re(s,r.env,U,d,P,`revert: ${A}`,T?.type==="symbolic");let _=T?.type==="symbolic"?Pe(T.target):"detached HEAD",O=await mn(s,m.tree,C,$,D,$.timestamp!==D.timestamp||$.timezone!==D.timezone),H=Lt(_,P,E),L=x.messages.length>0?`${x.messages.join(`
755
+ `:"",exitCode:1}}let C=await Hn(s,P,p.tree,{labels:y,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!C.ok)return C;if(P.conflicts.length>0){await La(s,f,E,d);let L=P.messages.join(`
756
+ `);return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:L?`${L}
757
+ `:"",stderr:_w(b,ue(l.message),u),exitCode:1}}if(u==="no-commit")return await La(s,f,E),{stdout:"",stderr:"",exitCode:0};let A=C.mergedTreeHash,D=await mn(s,r.env);if(M(D))return D;let $=await tt(s,r.env);if(M($))return $;let v=await Yd({gitCtx:s,env:r.env,headHash:d,headTreeHash:p.tree,treeHash:A,author:D,committer:$,commitMessage:k,displayMessage:E,reflogMessage:`revert: ${ue(E)}`}),N=P.messages.length>0?`${P.messages.join(`
756
758
  `)}
757
- `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:P,hadConflicts:!1}),{stdout:`${L}${H}
758
- ${O}`,stderr:"",exitCode:0}}})}async function ww(e,t){return await W(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
759
+ `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:v.commitHash,hadConflicts:!1}),{stdout:`${N}${v.stdout}`,stderr:"",exitCode:0}}})}async function Lw(e,t){return await U(e,"REVERT_HEAD")?qn(e,t,{operationRef:"REVERT_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
760
+ fatal: revert failed
761
+ `,128),operationName:"revert",clearState:async o=>{await _t(o),await en(o)},origHeadAsTargetRev:!0}):await U(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:_(`error: no cherry-pick or revert in progress
759
762
  fatal: revert failed
760
- `,128),operationName:"revert",clearState:async o=>{await St(o),await Ft(o)},origHeadAsTargetRev:!0}):await W(e,"CHERRY_PICK_HEAD")?qn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:N(`error: no cherry-pick or revert in progress
763
+ `,128),operationName:"revert",clearState:en,origHeadAsTargetRev:!0}):_(`error: no cherry-pick or revert in progress
761
764
  fatal: revert failed
762
- `,128),operationName:"revert",clearState:Ft,origHeadAsTargetRev:!0}):N(`error: no cherry-pick or revert in progress
765
+ `,128)}async function Gw(e,t){if(!await U(e,"REVERT_HEAD"))return _(`error: no revert in progress
763
766
  fatal: revert failed
764
- `,128)}async function bw(e,t){if(!await W(e,"REVERT_HEAD"))return N(`error: no revert in progress
767
+ `,128);let r=await Z(e);if(!r)return S("unable to resolve HEAD");let o=await j(e,r),s=await V(e),i=await Ar(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
765
768
  fatal: revert failed
766
- `,128);let r=await X(e);if(!r)return I("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await Hr(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
769
+ `}}return await ae(e,{version:2,entries:i.newEntries}),await De(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await _t(e),{stdout:"",stderr:"",exitCode:0}}async function Nw(e,t){if(!await U(e,"REVERT_HEAD"))return _(`error: no cherry-pick or revert in progress
767
770
  fatal: revert failed
768
- `}}return await ae(e,{version:2,entries:i.newEntries}),await je(e,i.worktreeOps),await re(e,t,"HEAD",r,r,`reset: moving to ${r}`),await St(e),{stdout:"",stderr:"",exitCode:0}}async function yw(e,t){if(!await W(e,"REVERT_HEAD"))return N(`error: no cherry-pick or revert in progress
771
+ `,128);let r=await V(e),o=Sn(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return _(`Aborting commit due to empty commit message.
772
+ `,1);let i=await $e(e,"SQUASH_MSG");if(i&&(s=i+s),s=St(s),!s)return _(`Aborting commit due to empty commit message.
773
+ `,1);let a=Ge(r),c=await Fe(e,a),f=await Qe(e);if(M(f))return f;let l=await j(e,f),d=await mn(e,t);if(M(d))return d;let u=await tt(e,t);if(M(u))return u;let h=await U(e,"CHERRY_PICK_HEAD");h&&(d=(await j(e,h)).author);let m=It(s);return{stdout:(await Yd({gitCtx:e,env:t,headHash:f,headTreeHash:l.tree,treeHash:c,author:d,committer:u,commitMessage:m,displayMessage:s,reflogMessage:`commit: ${ue(m)}`})).stdout,stderr:"",exitCode:0}}function Fw(e,t){if(t==="commit")return Sn(e,"Reverting",`fatal: revert failed
774
+ `);let n=e.entries.filter(a=>a.stage>0);if(n.length===0)return null;let r=10,s=n.slice(0,r).map(a=>`${a.path}: unmerged (${a.hash})`).join(`
775
+ `),i=n.length>r?`
776
+ ...`:"";return _(`${s}${i}
777
+ error: your index file is unmerged.
769
778
  fatal: revert failed
770
- `,128);let r=await z(e),o=Pn(r,"Committing");if(o)return o;let s=await $e(e,"MERGE_MSG");if(!s)return N(`Aborting commit due to empty commit message.
771
- `,1);let i=await $e(e,"SQUASH_MSG");if(i&&(s=i+s),s=Ot(s),!s)return N(`Aborting commit due to empty commit message.
772
- `,1);let a=Ne(r),c=await _e(e,a),f=await Je(e);if(M(f))return f;let l=await j(e,f),d=await un(e,t);if(M(d))return d;let u=await tt(e,t);if(M(u))return u;let h=await W(e,"CHERRY_PICK_HEAD");h&&(d=(await j(e,h)).author);let m=Gt(s),p=await yt(e,c,[f],d,u,m);await St(e),await Ft(e);let g=await Q(e),w=ue(m),b=g?.type==="symbolic"?g.target:"HEAD";await re(e,t,b,f,p,`commit: ${w}`,g?.type==="symbolic");let E=g?.type==="symbolic"?Pe(g.target):"detached HEAD",k=await mn(e,l.tree,c,d,u,d.timestamp!==u.timestamp||d.timezone!==u.timezone);return{stdout:`${Lt(E,p,s)}
773
- ${k}`,stderr:"",exitCode:0}}function Ew(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
779
+ `,128)}async function La(e,t,n,r){await J(e,"REVERT_HEAD",t),r&&await J(e,"ORIG_HEAD",r),await Le(e,"MERGE_MSG",n)}function _w(e,t,n){let r=`error: could not revert ${e}... ${t}
780
+ `;return n==="no-commit"?r+`hint: after resolving the conflicts, mark the corrected paths
781
+ hint: with 'git add <paths>' or 'git rm <paths>'
782
+ hint: Disable this message with "git config set advice.mergeConflict false"
783
+ `:r+`hint: After resolving the conflicts, mark them with
784
+ hint: "git add/rm <pathspec>", then run
785
+ hint: "git revert --continue".
786
+ hint: You can instead skip this commit with "git revert --skip".
787
+ hint: To abort and get back to the state before "git revert",
788
+ hint: run "git revert --abort".
789
+ hint: Disable this message with "git config set advice.mergeConflict false"
790
+ `}async function Yd(e){let{gitCtx:t,env:n,headHash:r,headTreeHash:o,treeHash:s,author:i,committer:a,commitMessage:c,displayMessage:f,reflogMessage:l}=e,d=await Ot(t,s,[r],i,a,c);await _t(t),await en(t);let u=await te(t),h=u?.type==="symbolic"?u.target:"HEAD";await re(t,n,h,r,d,l,u?.type==="symbolic");let m=u?.type==="symbolic"?Pe(u.target):"detached HEAD",p=await vn(t,o,s,i,a,i.name!==a.name||i.email!==a.email||i.timestamp!==a.timestamp||i.timezone!==a.timezone),g=Qt(m,d,f);return{commitHash:d,stdout:`${g}
791
+ ${p}`}}function Uw(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
774
792
 
775
- 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
793
+ This reverts commit ${t}`;if(n!==void 0&&e.parents.length>1&&n>=1){let c=e.parents[n-1]??e.parents[0];a+=`, reversing
776
794
  changes made to ${c}`}return a+=`.
777
- `,a}se();Ce();ie();me();ge();kn();De();function Md(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[K.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:S().describe("Only remove from the index"),recursive:S().alias("r").describe("Allow recursive removal when a directory name is given"),force:S().alias("f").describe("Override the up-to-date check"),dryRun:S().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return N("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,u=await z(s),h=[],m=dt(s,r.cwd);for(let w of c){if(lr(w)){let R=[Ue(w,m)],x=u.entries.filter(y=>Ee(R,y.path));if(x.length===0)return I(`pathspec '${w}' did not match any files`);for(let y of x)h.push(y.path);continue}let b=Dt(r.cwd,w),E=nt(a,b);if((E==="."||E==="")&&(E=""),E.startsWith(".."))return I(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(b)&&!(await mt(r.fs,b)).isSymbolicLink&&(await mt(r.fs,b)).isDirectory){if(!l)return I(`not removing '${E}' recursively without -r`);let R=E===""?"":`${E}/`,x=u.entries.filter(y=>R===""||y.path.startsWith(R));if(x.length===0)return I(`pathspec '${w}' did not match any files`);for(let y of x)h.push(y.path)}else{if(!u.entries.some(x=>x.path===E))return I(`pathspec '${w}' did not match any files`);h.push(E)}}if(!d){let w=await kw(s,u,h,f);if(w)return w}if(n.dryRun){let w=h.map(E=>`rm '${E}'`);return{stdout:w.length>0?`${w.join(`
795
+ `,a}se();Ce();ie();me();ge();Pn();Ae();function Xd(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:O().describe("Only remove from the index"),recursive:O().alias("r").describe("Allow recursive removal when a directory name is given"),force:O().alias("f").describe("Override the up-to-date check"),dryRun:O().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await K(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return _("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,u=await V(s),h=[],m=ut(s,r.cwd);for(let w of c){if(dr(w)){let k=[_e(w,m)],x=u.entries.filter(y=>Ee(k,y.path));if(x.length===0)return S(`pathspec '${w}' did not match any files`);for(let y of x)h.push(y.path);continue}let b=Mt(r.cwd,w),R=rt(a,b);if((R==="."||R==="")&&(R=""),R.startsWith(".."))return S(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(b)&&!(await mt(r.fs,b)).isSymbolicLink&&(await mt(r.fs,b)).isDirectory){if(!l)return S(`not removing '${R}' recursively without -r`);let k=R===""?"":`${R}/`,x=u.entries.filter(y=>k===""||y.path.startsWith(k));if(x.length===0)return S(`pathspec '${w}' did not match any files`);for(let y of x)h.push(y.path)}else{if(!u.entries.some(x=>x.path===R))return S(`pathspec '${w}' did not match any files`);h.push(R)}}if(!d){let w=await Bw(s,u,h,f);if(w)return w}if(n.dryRun){let w=h.map(R=>`rm '${R}'`);return{stdout:w.length>0?`${w.join(`
778
796
  `)}
779
- `:"",stderr:"",exitCode:0}}let p=[];for(let w of h){if(u=ct(u,w),!f){let b=v(a,w);await mt(r.fs,b).then(()=>!0).catch(()=>!1)&&await r.fs.rm(b)}p.push(`rm '${w}'`)}return await ae(s,u),{stdout:p.length>0?`${p.join(`
797
+ `:"",stderr:"",exitCode:0}}let p=[];for(let w of h){if(u=lt(u,w),!f){let b=H(a,w);await mt(r.fs,b).then(()=>!0).catch(()=>!1)&&await r.fs.rm(b)}p.push(`rm '${w}'`)}return await ae(s,u),{stdout:p.length>0?`${p.join(`
780
798
  `)}
781
- `:"",stderr:"",exitCode:0}}})}async function kw(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await j(e,o),l=await qe(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(m=>m.path===f&&m.stage===0);if(!l)continue;let u=s.get(f)!==l.hash,h=!1;if(e.workTree){let m=v(e.workTree,f),p=!1;try{await mt(e.fs,m),p=!0}catch{p=!1}p&&(h=await Un(e.fs,m)!==l.hash)}u&&h?i.push(f):u&&!r?a.push(f):h&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
782
- `),l=i.length===1?"the following file has":"the following files have";return N(`error: ${l} staged content different from both the
799
+ `:"",stderr:"",exitCode:0}}})}async function Bw(e,t,n,r){let o=await Z(e),s=new Map;if(o){let f=await j(e,o),l=await qe(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(m=>m.path===f&&m.stage===0);if(!l)continue;let u=s.get(f)!==l.hash,h=!1;if(e.workTree){let m=H(e.workTree,f),p=!1;try{await mt(e.fs,m),p=!0}catch{p=!1}p&&(h=await Wn(e.fs,m)!==l.hash)}u&&h?i.push(f):u&&!r?a.push(f):h&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
800
+ `),l=i.length===1?"the following file has":"the following files have";return _(`error: ${l} staged content different from both the
783
801
  file and the HEAD:
784
802
  ${f}
785
803
  (use -f to force removal)
786
804
  `)}if(a.length>0){let f=a.map(d=>` ${d}`).join(`
787
- `),l=a.length===1?"the following file has":"the following files have";return N(`error: ${l} changes staged in the index:
805
+ `),l=a.length===1?"the following file has":"the following files have";return _(`error: ${l} changes staged in the index:
788
806
  ${f}
789
807
  (use --cached to keep the file, or -f to force removal)
790
808
  `)}if(c.length>0){let f=c.map(d=>` ${d}`).join(`
791
- `),l=c.length===1?"the following file has":"the following files have";return N(`error: ${l} local modifications:
809
+ `),l=c.length===1?"the following file has":"the following files have";return _(`error: ${l} local modifications:
792
810
  ${f}
793
811
  (use --cached to keep the file, or -f to force removal)
794
- `)}return null}se();ie();cn();so();me();De();var va=new TextDecoder;function jd(e,t){e.command("show",{description:"Show various types of objects",args:[K.string().name("object").variadic().optional()],options:{patch:S().alias("p").describe("Show diff in patch format"),noPatch:S().describe("Suppress diff output"),stat:S().describe("Show diffstat summary"),nameOnly:S().describe("Show only names of changed files"),nameStatus:S().describe("Show names and status of changed files"),shortstat:S().describe("Show only the shortstat summary line"),numstat:S().describe("Machine-readable insertions/deletions per file"),format:Y.string().describe("Pretty-print format string"),pretty:Y.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=ro(a);if(c)return Rw(s,c.rev,c.path);if(a==="HEAD"){let p=await Je(s);if(M(p))return p}let f=await bt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await ye(s,f),d;n.noPatch?d=null:n.stat?d="stat":n.nameOnly?d="name-only":n.nameStatus?d="name-status":n.shortstat?d="shortstat":n.numstat?d="numstat":d="patch";let u=n.format??n.pretty,h=null,m=null;if(u!==void 0){let p=Zo(u);h=p.formatStr,m=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await Ld(s,f,p,d,h,m),stderr:"",exitCode:0}}case"tag":{let p=await Uc(s,f);return{stdout:await xw(s,p,d,h,m),stderr:"",exitCode:0}}case"tree":{let p=Rn(l.content);return{stdout:Gd(p),stderr:"",exitCode:0}}case"blob":return{stdout:va.decode(l.content),stderr:"",exitCode:0}}}})}async function Rw(e,t,n){let r=await Ge(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await de(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=v(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return I(f)}let c=await ye(e,a.hash);if(c.type==="blob")return{stdout:va.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=Rn(c.content);return{stdout:Gd(f),stderr:"",exitCode:0}}return{stdout:va.decode(c.content),stderr:"",exitCode:0}}async function Ld(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=vs(o,{hash:t,commit:n});else if(s!==null)i=As(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>Z(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${On(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
812
+ `)}return null}se();ie();fn();no();me();Ae();var Ga=new TextDecoder;function Zd(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:O().alias("p").describe("Show diff in patch format"),noPatch:O().describe("Suppress diff output"),stat:O().describe("Show diffstat summary"),nameOnly:O().describe("Show only names of changed files"),nameStatus:O().describe("Show names and status of changed files"),shortstat:O().describe("Show only the shortstat summary line"),numstat:O().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 K(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=to(a);if(c)return Ww(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await yt(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 u=n.format??n.pretty,h=null,m=null;if(u!==void 0){let p=ei(u);h=p.formatStr,m=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await Jd(s,f,p,d,h,m),stderr:"",exitCode:0}}case"tag":{let p=await Yc(s,f);return{stdout:await qw(s,p,d,h,m),stderr:"",exitCode:0}}case"tree":{let p=xn(l.content);return{stdout:Qd(p),stderr:"",exitCode:0}}case"blob":return{stdout:Ga.decode(l.content),stderr:"",exitCode:0}}}})}async function Ww(e,t,n){let r=await Me(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await le(e,o)).get(s);if(!a){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let l=H(e.workTree,s);await e.fs.exists(l)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return S(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=xn(c.content);return{stdout:Qd(f),stderr:"",exitCode:0}}return{stdout:Ga.decode(c.content),stderr:"",exitCode:0}}async function Jd(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Ts(o,{hash:t,commit:n});else if(s!==null)i=vs(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>X(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Tn(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
795
813
  `))c.push(` ${l}`);i=c.join(`
796
814
  `)}if(!r)return`${i}
797
- `;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 st(e,f);a=await Cw(e,l,d,r)}else r==="patch"&&(a=await Hw(e,n)??"");return a?`${i}
815
+ `;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 Kw(e,l,d,r)}else r==="patch"&&(a=await tb(e,n)??"");return a?`${i}
798
816
 
799
817
  ${a.replace(/\n$/,"")}
800
818
  `:n.parents.length>=2?`${i}
801
819
 
802
820
  `:`${i}
803
- `}async function xw(e,t,n="patch",r=null,o=null){let s=[];s.push(`tag ${t.name}`),s.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),s.push(`Date: ${On(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
804
- `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await Ld(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
821
+ `}async function qw(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: ${Tn(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
822
+ `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await Jd(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
805
823
  `)}
806
- `}function Gd(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(`
824
+ `}function Qd(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(`
807
825
  `)}
808
- `:""}async function Cw(e,t,n,r){switch(r){case"patch":return Aw(e,t,n);case"stat":return Ow(e,t,n);case"shortstat":return Sw(e,t,n);case"numstat":return Iw(e,t,n);case"name-only":return Pw(t,n);case"name-status":return $w(t,n);default:return""}}function Pw(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(`
826
+ `:""}async function Kw(e,t,n,r){switch(r){case"patch":return eb(e,t,n);case"stat":return Yw(e,t,n);case"shortstat":return Xw(e,t,n);case"numstat":return Zw(e,t,n);case"name-only":return zw(t,n);case"name-status":return Vw(t,n);default:return""}}function zw(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(`
809
827
  `)}
810
- `:""}function $w(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}
811
- `).join(""):""}async function Ow(e,t,n){let{fileStats:r}=await er(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),pr(r)}async function Sw(e,t,n){let{fileStats:r}=await er(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Qn(r.length,o,s);return i?`${i}
812
- `:""}async function Iw(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:hn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await oe(e,s.oldHash):"",a=s.newHash?await oe(e,s.newHash):"";if(Ae(i)||Ae(a))o+=`- - ${s.display}
813
- `;else{let c=xt(i),f=xt(a),l=it(c,f),d=0,u=0;for(let h of l)h.type==="insert"?d++:h.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
814
- `}}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 vt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function vw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return vt({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 Aw(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 vw(e,s.entry):o+=await Tw(e,s.entry);return o}async function Hw(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 Dw(e,a,n,r);return i}async function Dw(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(u=>u?.hash??null),f=s.map(u=>u?.mode??null),l=await Promise.all(c.map(async u=>u?await oe(e,u):"")),d=i?await oe(e,i):"";return Wo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}se();Ce();ie();ge();se();rr();Ce();ie();wn();me();Ke();ge();kn();De();Jt();et();var nn="refs/stash";function Ha(e,t){return Te(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Nd(e){let t=await Qe(e,nn),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function qr(e,t){let n=await Qe(e,nn);if(n.length===0)return null;let r=n.length-1-t;return r<0||r>=n.length?null:n[r]?.newHash??null}async function Fd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let i=await j(e,s),a=await z(e),c=Ne(a),f=await _e(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(B=>[B.path,B])),u=await rt(e,o,"",{skipIgnore:!0}),h=!1;for(let B of u){let F=d.get(B);if(!F)continue;let ee=v(o,B),V=await e.fs.readFileBuffer(ee);if(await gt("blob",V)!==F.hash){h=!0;break}}if(!h)for(let[B]of d){let F=v(o,B);if(!await e.fs.exists(F)){h=!0;break}}let m=[];if(r?.includeUntracked){let B=await rt(e,o,"");for(let F of B)d.has(F)||m.push(F)}if(l.length===0&&!h&&m.length===0)return null;let p=await Ws(e,t),g=await Jr(e,t),w=await Q(e),b=w?.type==="symbolic"?Pe(w.target):"(no branch)",E=Z(s),k=ue(i.message),R=`index on ${b}: ${E} ${k}
815
- `,x=an({type:"commit",tree:f,parents:[s],author:p,committer:g,message:R}),y=await Ie(e,"commit",x),C=await de(e,i.tree),$=[],D=new Set;for(let B of u){let F=d.get(B),ee=C.get(B);if(!F&&!ee)continue;let V=v(o,B),te=await e.fs.readFileBuffer(V),ke=await Ie(e,"blob",te),Fe=F?F.mode:parseInt(ee?.mode??"100644",8);$.push({path:B,mode:Fe,hash:ke,stage:0,stat:ve()}),D.add(B)}for(let[B,F]of d)if(!D.has(B)){if(_n(F.mode)){$.push({path:B,mode:F.mode,hash:F.hash,stage:0,stat:ve()});continue}C.has(B)||$.push({path:B,mode:F.mode,hash:F.hash,stage:0,stat:ve()})}let P=await _e(e,$),T=null;if(r?.includeUntracked){let B=[];for(let te of m){let ke=v(o,te),Fe=await e.fs.readFileBuffer(ke),ce=await Ie(e,"blob",Fe);B.push({path:te,mode:33188,hash:ce,stage:0,stat:ve()})}let F=await _e(e,B),ee=`untracked files on ${b}: ${E} ${k}
816
- `,V=an({type:"commit",tree:F,parents:[],author:p,committer:g,message:ee});T=await Ie(e,"commit",V)}let A=n?`On ${b}: ${n}`:`WIP on ${b}: ${E} ${k}`,U=[s,y];T&&U.push(T);let _=an({type:"commit",tree:P,parents:U,author:p,committer:g,message:A}),O=await Ie(e,"commit",_),H=await qr(e,0)??ne;await ft(e,nn,{oldHash:H,newHash:O,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:A.trimEnd()}),await J(e,nn,O);let L=await Cn(e,i.tree,a);await ae(e,{version:2,entries:L.newEntries}),await je(e,L.worktreeOps),(await Q(e))?.type==="symbolic"&&await re(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let B of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,B);for(let B of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let F=v(e.gitDir,B);await e.fs.exists(F)&&await e.fs.rm(F)}if(m.length>0)for(let B of m){if(C.has(B))continue;let F=v(o,B);await e.fs.exists(F)&&(await e.fs.rm(F),await cr(e.fs,rn(F),o))}return O}async function Aa(e,t){let n=e.workTree,r=await j(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=v(n,i.path);await e.fs.exists(a)?s.push(i.path):await lt(e,i)}return s.length>0?(s.sort(Ha),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
828
+ `:""}function Vw(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}
829
+ `).join(""):""}async function Yw(e,t,n){let{fileStats:r}=await tr(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),pr(r)}async function Xw(e,t,n){let{fileStats:r}=await tr(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=er(r.length,o,s);return i?`${i}
830
+ `:""}async function Zw(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:pn(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(je(i)||je(a))o+=`- - ${s.display}
831
+ `;else{let c=xt(i),f=xt(a),l=ct(c,f),d=0,u=0;for(let h of l)h.type==="insert"?d++:h.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
832
+ `}}return o}async function Jw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function Qw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ht({path:t.oldPath,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash,renameTo:t.newPath,similarity:t.similarity})}async function eb(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 Qw(e,s.entry):o+=await Jw(e,s.entry);return o}async function tb(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async a=>{let c=await j(e,a);return le(e,c.tree)})),r=await le(e,t.tree),o=new Set;for(let a of n)for(let c of a.keys())o.add(c);for(let a of r.keys())o.add(a);let s=[];for(let a of o){let f=r.get(a)?.hash??null;n.every(d=>(d.get(a)?.hash??null)!==f)&&s.push(a)}if(s.sort(),s.length===0)return"";let i="";for(let a of s)i+=await nb(e,a,n,r);return i}async function nb(e,t,n,r){let o=r.get(t),s=n.map(u=>u.get(t)??null),i=o?.hash??null,a=o?.mode??null,c=s.map(u=>u?.hash??null),f=s.map(u=>u?.mode??null),l=await Promise.all(c.map(async u=>u?await oe(e,u):"")),d=i?await oe(e,i):"";return Bo({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}se();Ce();ie();ge();se();sr();Ce();ie();bn();me();Be();ge();Pn();Ae();Nt();Je();var rn="refs/stash";function Fa(e,t){return ve(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function eu(e){let t=await et(e,rn),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function Br(e,t){let n=await et(e,rn);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 tu(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 V(e),c=Ge(a),f=await Fe(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(F=>[F.path,F])),u=await ot(e,o,"",{skipIgnore:!0}),h=!1;for(let F of u){let B=d.get(F);if(!B)continue;let ee=H(o,F),z=await e.fs.readFileBuffer(ee);if(await gt("blob",z)!==B.hash){h=!0;break}}if(!h)for(let[F]of d){let B=H(o,F);if(!await e.fs.exists(B)){h=!0;break}}let m=[];if(r?.includeUntracked){let F=await ot(e,o,"");for(let B of F)d.has(B)||m.push(B)}if(l.length===0&&!h&&m.length===0)return null;let p=await Us(e,t),g=await Xr(e,t),w=await te(e),b=w?.type==="symbolic"?Pe(w.target):"(no branch)",R=X(s),E=ue(i.message),k=`index on ${b}: ${R} ${E}
833
+ `,x=cn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),y=await Ie(e,"commit",x),P=await le(e,i.tree),C=[],A=new Set;for(let F of u){let B=d.get(F),ee=P.get(F);if(!B&&!ee)continue;let z=H(o,F),Q=await e.fs.readFileBuffer(z),Re=await Ie(e,"blob",Q),Ne=B?B.mode:parseInt(ee?.mode??"100644",8);C.push({path:F,mode:Ne,hash:Re,stage:0,stat:He()}),A.add(F)}for(let[F,B]of d)if(!A.has(F)){if(Bn(B.mode)){C.push({path:F,mode:B.mode,hash:B.hash,stage:0,stat:He()});continue}P.has(F)||C.push({path:F,mode:B.mode,hash:B.hash,stage:0,stat:He()})}let D=await Fe(e,C),$=null;if(r?.includeUntracked){let F=[];for(let Q of m){let Re=H(o,Q),Ne=await e.fs.readFileBuffer(Re),ce=await Ie(e,"blob",Ne);F.push({path:Q,mode:33188,hash:ce,stage:0,stat:He()})}let B=await Fe(e,F),ee=`untracked files on ${b}: ${R} ${E}
834
+ `,z=cn({type:"commit",tree:B,parents:[],author:p,committer:g,message:ee});$=await Ie(e,"commit",z)}let v=n?`On ${b}: ${n}`:`WIP on ${b}: ${R} ${E}`,N=[s,y];$&&N.push($);let L=cn({type:"commit",tree:D,parents:N,author:p,committer:g,message:v}),I=await Ie(e,"commit",L),T=await Br(e,0)??ne;await st(e,rn,{oldHash:T,newHash:I,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:v.trimEnd()}),await J(e,rn,I);let G=await On(e,i.tree,a);await ae(e,{version:2,entries:G.newEntries}),await De(e,G.worktreeOps),(await te(e))?.type==="symbolic"&&await re(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let F of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,F);for(let F of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let B=H(e.gitDir,F);await e.fs.exists(B)&&await e.fs.rm(B)}if(m.length>0)for(let F of m){if(P.has(F))continue;let B=H(o,F);await e.fs.exists(B)&&(await e.fs.rm(B),await cr(e.fs,sn(B),o))}return I}async function Na(e,t){let n=e.workTree,r=await j(e,t),o=await qe(e,r.tree),s=[];for(let i of o){let a=H(n,i.path);await e.fs.exists(a)?s.push(i.path):await dt(e,i)}return s.length>0?(s.sort(Fa),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
817
835
  `)}
818
836
  error: could not restore untracked files from stash
819
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Da(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
820
- `,exitCode:128};let n=await qr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
821
- `,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
822
- `,exitCode:1};let o=await z(e),s=Kt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
837
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function _a(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
838
+ `,exitCode:128};let n=await Br(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
839
+ `,exitCode:1};if(!await Z(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
840
+ `,exitCode:1};let o=await V(e),s=zt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(P=>`${P}: needs merge`).join(`
823
841
  `)}
824
842
  `,stderr:`error: could not write index
825
843
  `,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)
826
- `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Ne(o),d=await _e(e,l),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let y=await Aa(e,f);if(!y.ok)return{...y,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let h=await qt(e,c.tree,d,i.tree,u),m=await de(e,d),p=await de(e,h.resultTree),g=[];for(let[y,C]of p){let $=m.get(y);(!$||$.hash!==C.hash)&&g.push({path:y,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[y]of m)p.has(y)||g.push({path:y,type:"delete"});let w=new Map(l.map(y=>[y.path,y])),b=[],E=[];for(let y of g){let C=w.get(y.path),$=v(e.workTree,y.path);if(C){if(_n(C.mode)||!await e.fs.exists($))continue;let D=await e.fs.readFileBuffer($);await gt("blob",D)!==C.hash&&b.push(y.path)}else y.type==="checkout"&&await e.fs.exists($)&&E.push(y.path)}if(b.length>0||E.length>0){b.sort(Ha),E.sort(Ha);let y="";if(b.length>0&&(y+=`error: Your local changes to the following files would be overwritten by merge:
827
- ${b.map(C=>` ${C}`).join(`
844
+ `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Ge(o),d=await Fe(e,l),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let y=await Na(e,f);if(!y.ok)return{...y,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let h=await Kt(e,c.tree,d,i.tree,u),m=await le(e,d),p=await le(e,h.resultTree),g=[];for(let[y,P]of p){let C=m.get(y);(!C||C.hash!==P.hash)&&g.push({path:y,type:"checkout",hash:P.hash,mode:parseInt(P.mode,8)})}for(let[y]of m)p.has(y)||g.push({path:y,type:"delete"});let w=new Map(l.map(y=>[y.path,y])),b=[],R=[];for(let y of g){let P=w.get(y.path),C=H(e.workTree,y.path);if(P){if(Bn(P.mode)||!await e.fs.exists(C))continue;let A=await e.fs.readFileBuffer(C);await gt("blob",A)!==P.hash&&b.push(y.path)}else y.type==="checkout"&&await e.fs.exists(C)&&R.push(y.path)}if(b.length>0||R.length>0){b.sort(Fa),R.sort(Fa);let y="";if(b.length>0&&(y+=`error: Your local changes to the following files would be overwritten by merge:
845
+ ${b.map(P=>` ${P}`).join(`
828
846
  `)}
829
847
  Please commit your changes or stash them before you merge.
830
- `),E.length>0&&(y+=`error: The following untracked working tree files would be overwritten by merge:
831
- ${E.map(C=>` ${C}`).join(`
848
+ `),R.length>0&&(y+=`error: The following untracked working tree files would be overwritten by merge:
849
+ ${R.map(P=>` ${P}`).join(`
832
850
  `)}
833
851
  Please move or remove them before you merge.
834
852
  `),y+=`Aborting
835
- `,f){let C=await Aa(e,f);C.ok||(y+=C.stderr)}return{ok:!1,stdout:"",stderr:y,exitCode:1}}await je(e,g);let k=new Set(h.conflicts.map(y=>y.path)),R=new Set;for(let y of h.entries)y.stage>0&&R.add(y.path);let x=k.size>0;if(x){let y=[];for(let[C,$]of p){if(k.has(C)||R.has(C))continue;let D=w.get(C);y.push({path:C,mode:parseInt($.mode,8),hash:$.hash,stage:0,stat:D?.stat??ve()})}for(let C of h.entries)C.stage>0&&y.push(C);y.sort((C,$)=>Te(C.path,$.path)||C.stage-$.stage),await ae(e,{version:2,entries:y})}else{let y=[...o.entries],C=new Set(y.map($=>$.path));for(let[$,D]of p)m.has($)||C.has($)||y.push({path:$,mode:parseInt(D.mode,8),hash:D.hash,stage:0,stat:ve()});y.sort(($,D)=>Te($.path,D.path)||$.stage-D.stage),await ae(e,{version:2,entries:y})}if(f){let y=await Aa(e,f);if(!y.ok)return{...y,messages:h.messages}}return{ok:!0,hasConflicts:x,messages:h.messages}}async function Ma(e,t=0){let n=await Qe(e,nn);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await he(e,nn),await fs(e,nn);else{await Fn(e,nn,n);let o=n[n.length-1];o&&await J(e,nn,o.newHash)}return null}async function _d(e){await he(e,nn),await fs(e,nn)}De();function ni(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 Mw(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return vt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function Bd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Ud(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":S().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Ud(s,o.env,r.message,r["include-untracked"])}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:jw(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Lw(s,r.stash)}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Gw(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Nw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:S().alias("p").describe("Show full diff (default is --stat)")},args:[K.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:Fw(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await q(o.fs,o.cwd,t);return M(s)?s:_w(s)}})}async function Ud(e,t,n,r){if(!await X(e))return N(`You do not have the initial commit yet
836
- `);let s=await z(e),i=Kt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
853
+ `,f){let P=await Na(e,f);P.ok||(y+=P.stderr)}return{ok:!1,stdout:"",stderr:y,exitCode:1}}await De(e,g);let E=new Set(h.conflicts.map(y=>y.path)),k=new Set;for(let y of h.entries)y.stage>0&&k.add(y.path);let x=E.size>0;if(x){let y=[];for(let[P,C]of p){if(E.has(P)||k.has(P))continue;let A=w.get(P);y.push({path:P,mode:parseInt(C.mode,8),hash:C.hash,stage:0,stat:A?.stat??He()})}for(let P of h.entries)P.stage>0&&y.push(P);y.sort((P,C)=>ve(P.path,C.path)||P.stage-C.stage),await ae(e,{version:2,entries:y})}else{let y=[...o.entries],P=new Set(y.map(C=>C.path));for(let[C,A]of p)m.has(C)||P.has(C)||y.push({path:C,mode:parseInt(A.mode,8),hash:A.hash,stage:0,stat:He()});y.sort((C,A)=>ve(C.path,A.path)||C.stage-A.stage),await ae(e,{version:2,entries:y})}if(f){let y=await Na(e,f);if(!y.ok)return{...y,messages:h.messages}}return{ok:!0,hasConflicts:x,messages:h.messages}}async function Ua(e,t=0){let n=await et(e,rn);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,rn),await as(e,rn);else{await Un(e,rn,n);let o=n[n.length-1];o&&await J(e,rn,o.newHash)}return null}async function nu(e){await he(e,rn),await as(e,rn)}Ae();function oi(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 rb(e,t){let n=t.oldHash?await oe(e,t.oldHash):"",r=t.newHash?await oe(e,t.newHash):"";return Ht({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function su(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":O().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 K(o.fs,o.cwd,t);return M(s)?s:ru(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Y.string().alias("m").describe("Stash message"),"include-untracked":O().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:ru(s,o.env,r.message,r["include-untracked"])}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:sb(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:ob(s,r.stash)}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:ib(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:ab(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:O().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 K(o.fs,o.cwd,t);return M(s)?s:cb(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await K(o.fs,o.cwd,t);return M(s)?s:fb(s)}})}async function ru(e,t,n,r){if(!await Z(e))return _(`You do not have the initial commit yet
854
+ `);let s=await V(e),i=zt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
837
855
  `)}
838
856
  `,stderr:`error: could not write index
839
- `,exitCode:1};let a;try{a=await Fd(e,t,n,{includeUntracked:r})}catch(l){return I(l.message)}return a?{stdout:`Saved working directory and index state ${(await j(e,a)).message.trim()}
857
+ `,exitCode:1};let a;try{a=await tu(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()}
840
858
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
841
- `,stderr:"",exitCode:0}}async function jw(e,t){let n=ni(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await qr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await Da(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
859
+ `,stderr:"",exitCode:0}}async function sb(e,t){let n=oi(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Br(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await _a(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
842
860
  `)}
843
861
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
844
- `,stderr:o.stderr,exitCode:o.exitCode};let l=await ot(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
862
+ `,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.
845
863
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
846
864
  `)}
847
- `:"",l=await ot(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
848
- `,stderr:"",exitCode:1}}let s=await Ma(e,n);if(s)return N(s);let i=o.messages.length>0?`${o.messages.join(`
865
+ `:"",l=await at(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
866
+ `,stderr:"",exitCode:1}}let s=await Ua(e,n);if(s)return _(s);let i=o.messages.length>0?`${o.messages.join(`
849
867
  `)}
850
- `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await ot(e);return{stdout:`${i}${c}Dropped ${a} (${r})
851
- `,stderr:"",exitCode:0}}async function Lw(e,t){let n=ni(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await Da(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
868
+ `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await at(e);return{stdout:`${i}${c}Dropped ${a} (${r})
869
+ `,stderr:"",exitCode:0}}async function ob(e,t){let n=oi(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await _a(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
852
870
  `)}
853
- `:"",c=r.stdout;return c||(c=await ot(e)),{stdout:`${a}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
871
+ `:"",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(`
854
872
  `)}
855
- `:"",s=await ot(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function Gw(e){let t=await Nd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
873
+ `:"",s=await at(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function ib(e){let t=await eu(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
856
874
  `)}
857
- `,stderr:"",exitCode:0}}async function Nw(e,t){let n=ni(t);if(n<0)return N(`error: '${t}' is not a valid stash reference`);let r=await qr(e,n);if(!r)return N(`error: stash@{${n}} is not a valid reference`);let o=await Ma(e,n);return o?N(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
858
- `,stderr:"",exitCode:0}}async function Fw(e,t,n){let r=ni(t);if(r<0)return N(`error: '${t}' is not a valid stash reference`);let o=await qr(e,r);if(!o)return N(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return N("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await Mw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await pn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function _w(e){return await _d(e),{stdout:"",stderr:"",exitCode:0}}se();Be();Ce();ge();et();function Wd(e,t){e.command("status",{description:"Show the working tree status",options:{short:S().alias("s").describe("Give the output in the short-format"),porcelain:S().describe("Give the output in a machine-parseable format"),branch:S().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await ot(s),stderr:"",exitCode:0};let i=await Q(s),a=await X(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let E=await pe(s),k=await Ut(s,E,c);f=Kw(c,k)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await z(s),d=Qi(l),u=await Ji(s,a,l,d),h=await wt(s,l),m=[],p=[];for(let E of h)E.status==="untracked"?p.push(E.path):m.push({path:E.path,status:E.status});m.sort((E,k)=>Te(E.path,k.path));let g=new Set(l.entries.map(E=>E.path)),w=ea(p,g);return{stdout:qw(f,u,m,d,w),stderr:"",exitCode:0}}})}var Uw={"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 Bw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Ww(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function qw(e,t,n,r,o){let s=[];e&&s.push(e);let i=new Map(r.map(d=>[d.path,d])),a=new Map(t.map(d=>[d.path,d])),c=new Map(n.map(d=>[d.path,d])),f=new Set;for(let d of r)f.add(d.path);for(let d of t)f.add(d.path);for(let d of n)f.add(d.path);let l=[...f].sort();for(let d of l){let u=i.get(d);if(u){let w=Uw[u.status]??"UU";s.push(`${w} ${Hs(d)}`);continue}let h=a.get(d),m=c.get(d),p=h?Bw(h.status):" ",g=m?Ww(m.status):" ";if(h?.status==="renamed"&&h.displayPath){let w=h.displayPath.indexOf(" -> "),b=h.displayPath.slice(0,w),E=h.displayPath.slice(w+4);s.push(`${p}${g} ${Hs(b)} -> ${Hs(E)}`)}else s.push(`${p}${g} ${Hs(d)}`)}for(let d of o)s.push(`?? ${Hs(d)}`);return s.length===0?"":`${s.join(`
875
+ `,stderr:"",exitCode:0}}async function ab(e,t){let n=oi(t);if(n<0)return _(`error: '${t}' is not a valid stash reference`);let r=await Br(e,n);if(!r)return _(`error: stash@{${n}} is not a valid reference`);let o=await Ua(e,n);return o?_(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
876
+ `,stderr:"",exitCode:0}}async function cb(e,t,n){let r=oi(t);if(r<0)return _(`error: '${t}' is not a valid stash reference`);let o=await Br(e,r);if(!o)return _(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return _("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await rb(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await gn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function fb(e){return await nu(e),{stdout:"",stderr:"",exitCode:0}}se();Ue();Ce();ge();Je();function ou(e,t){e.command("status",{description:"Show the working tree status",options:{short:O().alias("s").describe("Give the output in the short-format"),porcelain:O().describe("Give the output in a machine-parseable format"),branch:O().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await K(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 te(s),a=await Z(s),c,f=null;if(i&&i.type==="symbolic"){if(c=Pe(i.target),n.branch){let R=await pe(s),E=await Bt(s,R,c);f=mb(c,E)}}else c="HEAD detached",n.branch&&(f="## HEAD (no branch)");let l=await V(s),d=ra(l),u=await na(s,a,l,d),h=await bt(s,l),m=[],p=[];for(let R of h)R.status==="untracked"?p.push(R.path):m.push({path:R.path,status:R.status});m.sort((R,E)=>ve(R.path,E.path));let g=new Set(l.entries.map(R=>R.path)),w=sa(p,g);return{stdout:hb(f,u,m,d,w),stderr:"",exitCode:0}}})}var lb={"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 db(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function ub(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function hb(e,t,n,r,o){let s=[];e&&s.push(e);let i=new Map(r.map(d=>[d.path,d])),a=new Map(t.map(d=>[d.path,d])),c=new Map(n.map(d=>[d.path,d])),f=new Set;for(let d of r)f.add(d.path);for(let d of t)f.add(d.path);for(let d of n)f.add(d.path);let l=[...f].sort();for(let d of l){let u=i.get(d);if(u){let w=lb[u.status]??"UU";s.push(`${w} ${Hs(d)}`);continue}let h=a.get(d),m=c.get(d),p=h?db(h.status):" ",g=m?ub(m.status):" ";if(h?.status==="renamed"&&h.displayPath){let w=h.displayPath.indexOf(" -> "),b=h.displayPath.slice(0,w),R=h.displayPath.slice(w+4);s.push(`${p}${g} ${Hs(b)} -> ${Hs(R)}`)}else s.push(`${p}${g} ${Hs(d)}`)}for(let d of o)s.push(`?? ${Hs(d)}`);return s.length===0?"":`${s.join(`
859
877
  `)}
860
- `}function Kw(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=xo(t,!1);return r?`${n} ${r}`:n}function Hs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}se();Be();Ce();ie();Ke();ge();De();Jt();function zw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ne}function Kd(e,t){e.command("switch",{description:"Switch branches",args:[K.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:Y.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Y.string().alias("C").describe("Create/reset and switch to a branch"),detach:S().alias("d").describe("Detach HEAD at named commit"),orphan:Y.string().describe("Create a new orphan branch"),guess:S().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await q(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?I("--orphan and -c/-C are incompatible"):n.detach?I("--orphan and --detach are incompatible"):Xw(i,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return I("--detach and -c/-C are incompatible");let l=a??"HEAD",d=await Ge(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 qd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return I("missing branch or commit argument");if(a==="-")return Vw(i,r.env,t);let c=`refs/heads/${a}`,f=await W(i,c);if(f)return zd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await Io(i,a);if(l)return qd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return I(`invalid reference: ${a}`)}})}async function Ds(e){return await $e(e,"CHERRY_PICK_HEAD")?I(`cannot switch branch while cherry-picking
861
- Consider "git cherry-pick --quit" or "git worktree add".`):await $e(e,"MERGE_HEAD")?I(`cannot switch branch while merging
862
- Consider "git merge --quit" or "git worktree add".`):await $e(e,"REVERT_HEAD")?I(`cannot switch branch while reverting
863
- Consider "git revert --quit" or "git worktree add".`):await _t(e)?I(`cannot switch branch while rebasing
864
- Consider "git rebase --quit" or "git worktree add".`):null}async function Vw(e,t,n){let r=await Ds(e);if(r)return r;let o=await Co(e);return o?zd(e,o.name,o.refName,o.hash,t,n):I("no previous branch")}async function qd(e,t,n,r,o,s,i){if(!yn(t))return I(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await W(e,a);if(c&&!n)return I(`a branch named '${t}' already exists`);let f;if(r){let C=await Ge(e,r,`invalid reference: ${r}`);if(M(C))return C;f=C.hash}else{let C=await X(e);if(!C){let $=await Q(e),D=$?.type==="symbolic"?$.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Ze(e,"HEAD",a),await Et(e);let P=await $n(e);return await re(e,o,"HEAD",null,ne,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
865
- ${P}`,exitCode:0}}f=C}let l=await Ds(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(fe(d))return{stdout:"",stderr:d.message??"",exitCode:1};let u=await X(e),h=await z(e);if(r){let C=Vn(h);if(C)return C}let m=await j(e,f);if(u&&u!==f){let C=await j(e,u);if(C.tree!==m.tree){let $=await Bn(e,C.tree,m.tree,h);if(!$.success)return $.errorOutput??N("error: checkout would overwrite local changes");h={version:2,entries:$.newEntries},await ae(e,h),await je(e,$.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&u&&(g=await Oo(e,u,f));let w=zw(p,u);await J(e,a,f),await Ze(e,"HEAD",a),await Et(e);let b=await $n(e),E=r??"HEAD";n&&c?c!==f&&await re(e,o,a,c,f,`branch: Reset to ${E}`):await re(e,o,a,null,f,`branch: Created from ${E}`),await re(e,o,"HEAD",u,f,`checkout: moving from ${w} to ${t}`);let k="";if(i){let C=i.replace(/^refs\/remotes\//,"").split("/"),$=C[0]??"",D=`refs/heads/${C.slice(1).join("/")}`,P=await pe(e);P[`branch "${t}"`]={...P[`branch "${t}"`],remote:$,merge:D},await ze(e,P),k=`branch '${t}' set up to track '${$}/${C.slice(1).join("/")}'.
866
- `}else r&&(k=await So(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:u,newHead:f,isBranchCheckout:!0});let R=n&&c?`Switched to and reset branch '${t}'
878
+ `}function mb(e,t){if(!t)return`## ${e}`;let n=`## ${e}...${t.upstream}`,r=Ro(t,!1);return r?`${n} ${r}`:n}function Hs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}se();Ue();Ce();ie();Be();ge();Ae();Nt();function pb(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ne}function au(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:O().alias("d").describe("Detach HEAD at named commit"),orphan:Y.string().describe("Create a new orphan branch"),guess:O().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await K(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"):bb(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 Me(i,l,`invalid reference: ${l}`);return M(d)?d:wb(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 iu(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return S("missing branch or commit argument");if(a==="-")return gb(i,r.env,t);let c=`refs/heads/${a}`,f=await U(i,c);if(f)return cu(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await Oo(i,a);if(l)return iu(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return S(`invalid reference: ${a}`)}})}async function ii(e){return await $e(e,"CHERRY_PICK_HEAD")?S(`cannot switch branch while cherry-picking
879
+ Consider "git cherry-pick --quit" or "git worktree add".`):await $e(e,"MERGE_HEAD")?S(`cannot switch branch while merging
880
+ Consider "git merge --quit" or "git worktree add".`):await $e(e,"REVERT_HEAD")?S(`cannot switch branch while reverting
881
+ Consider "git revert --quit" or "git worktree add".`):await Ut(e)?S(`cannot switch branch while rebasing
882
+ Consider "git rebase --quit" or "git worktree add".`):null}async function gb(e,t,n){let r=await oa(e);return r?r.kind==="commit"?{stdout:"",stderr:`fatal: a branch is expected, got commit '${r.target}'
883
+ hint: If you want to detach HEAD at the commit, try again with the --detach option.
884
+ `,exitCode:128}:cu(e,r.name,r.refName,r.hash,t,n):S("invalid reference: @{-1}")}async function iu(e,t,n,r,o,s,i){if(!En(t))return S(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await U(e,a);if(c&&!n)return S(`a branch named '${t}' already exists`);let f;if(r){let C=await Me(e,r,`invalid reference: ${r}`);if(M(C))return C;f=C.hash}else{let C=await Z(e);if(!C){let A=await te(e),D=A?.type==="symbolic"?A.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Ze(e,"HEAD",a),await Et(e);let $=await In(e);return await re(e,o,"HEAD",null,ne,`checkout: moving from ${D} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
885
+ ${$}`,exitCode:0}}f=C}let l=await ii(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(de(d))return{stdout:"",stderr:d.message??"",exitCode:1};let u=await Z(e),h=await V(e);if(r){let C=Vn(h);if(C)return C}let m=await j(e,f);if(u&&u!==f){let C=await j(e,u);if(C.tree!==m.tree){let A=await hn(e,C.tree,m.tree,h);if(!A.success)return A.errorOutput??_("error: checkout would overwrite local changes");h={version:2,entries:A.newEntries},await ae(e,h),await De(e,A.worktreeOps)}}let p=await te(e),g="";p?.type==="direct"&&u&&(g=await Po(e,u,f));let w=pb(p,u);await J(e,a,f),await Ze(e,"HEAD",a),await Et(e);let b=await In(e),R=r??"HEAD";n&&c?c!==f&&await re(e,o,a,c,f,`branch: Reset to ${R}`):await re(e,o,a,null,f,`branch: Created from ${R}`),await re(e,o,"HEAD",u,f,`checkout: moving from ${w} to ${t}`);let E="";if(i){let C=i.replace(/^refs\/remotes\//,"").split("/"),A=C[0]??"",D=`refs/heads/${C.slice(1).join("/")}`,$=await pe(e);$[`branch "${t}"`]={...$[`branch "${t}"`],remote:A,merge:D},await ze(e,$),E=`branch '${t}' set up to track '${A}/${C.slice(1).join("/")}'.
886
+ `}else r&&(E=await $o(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:u,newHead:f,isBranchCheckout:!0});let k=p?.type==="symbolic"&&p.target===a,x=n&&c?k?`Reset branch '${t}'
887
+ `:`Switched to and reset branch '${t}'
867
888
  `:`Switched to a new branch '${t}'
868
- `,x=g+R+b,y="";if(k)y=k;else if(r){y=await hr(e,m.tree,h);let C=await pe(e),$=await Ut(e,C,t);$&&(y+=zn($))}else if(n&&c){let C=await pe(e),$=await Ut(e,C,t);$&&(y=zn($))}return{stdout:y,stderr:x,exitCode:0}}async function zd(e,t,n,r,o,s){let i=await Ds(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return fe(a)?{stdout:"",stderr:a.message??"",exitCode:1}:mr(e,t,n,r,o,s)}async function Yw(e,t,n,r,o){let s=await Ds(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return fe(i)?{stdout:"",stderr:i.message??"",exitCode:1}:Yn(e,n,r,o)}async function Xw(e,t,n,r){if(!yn(t))return I(`'${t}' is not a valid branch name`);let o=await Ds(e);if(o)return o;let s=`refs/heads/${t}`;if(await W(e,s))return I(`a branch named '${t}' already exists`);let a=await z(e),c=Vn(a);if(c)return c;let f=await X(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await ta(e,f)),e.workTree){let h=f?(await j(e,f)).tree:null,m=await _e(e,[]),p=await Bn(e,h,m,a);if(!p.success)return p.errorOutput??N("error: checkout would overwrite local changes");await je(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,cc());await Ze(e,"HEAD",s),await Et(e);let u=await $n(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ne,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
869
- ${u}`,exitCode:0}}se();ie();Tr();ge();us();function Yd(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[K.string().name("name").describe("Tag name to create or delete").optional(),K.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:S().alias("a").describe("Make an annotated tag object"),message:Y.string().alias("m").describe("Tag message"),delete:S().alias("d").describe("Delete a tag"),force:S().alias("f").describe("Replace an existing tag"),list:S().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await q(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.delete){if(!n.name)return I("tag name required");let i=`refs/tags/${n.name}`,a=await W(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${Z(a)})
870
- `,stderr:"",exitCode:0}):N(`error: tag '${n.name}' not found.
871
- `)}if(n.list)return Vd(s,n.name||void 0);if(n.name){if(!Wc(n.name))return I(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await bt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await X(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await W(s,c)&&!n.force)return I(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return I("no tag message specified (use -m)");let d=await tt(s,r.env);if(M(d))return d;let u=Gt(n.message),h=Fc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:u}),m=await Ie(s,"tag",h);await J(s,c,m)}else await J(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Vd(s)}})}async function Vd(e,t){let n=await we(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>fn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
872
- `)}
873
- `,stderr:"",exitCode:0}}var Xd=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),Zw={init:(e,t)=>Ql(e,t),clone:(e,t)=>Il(e,t),describe:(e,t)=>vl(e,t),fetch:(e,t)=>zl(e,t),pull:(e,t)=>Ed(e,t),push:(e,t)=>Rd(e,t),add:(e,t)=>hf(e,t),blame:(e,t)=>Kf(e,t),commit:(e,t)=>Al(e,t),status:(e,t)=>Wd(e,t),log:(e,t)=>fd(e,t),branch:(e,t)=>Vf(e,t),tag:(e,t)=>Yd(e,t),checkout:(e,t)=>Xf(e,t),diff:(e,t)=>Ul(e,t),reset:(e,t)=>Td(e,t),merge:(e,t)=>ud(e,t),"cherry-pick":(e,t)=>ll(e,t),revert:(e,t)=>Dd(e,t),rebase:(e,t)=>xd(e,t),mv:(e,t)=>hd(e,t),rm:(e,t)=>Md(e,t),remote:(e,t)=>Pd(e,t),config:(e,t)=>jl(e,t),show:(e,t)=>jd(e,t),stash:(e,t)=>Bd(e,t),"rev-parse":(e,t)=>Hd(e,t),"ls-files":(e,t)=>dd(e,t),clean:(e,t)=>dl(e,t),switch:(e,t)=>Kd(e,t),restore:(e,t)=>Ad(e,t),reflog:(e,t)=>Cd(e,t),repack:(e,t)=>Sd(e,t),gc:(e,t)=>Vl(e,t),bisect:(e,t)=>Af(e,t),grep:(e,t)=>Jl(e,t)};function Zd(e){let t=li("git",{description:"Git command"});for(let n of Object.values(Zw))n(t,e);return t.command("help",{description:"Display help information",args:[K.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Cr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Cr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
874
- `,exitCode:1}}}),t}var Jw="1.6.0";function Qw(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 ri=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=Qw(t?.identity,t?.config),o=t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},s={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,credentialCache:new Map,onProgress:t?.onProgress,mergeDriver:t?.mergeDriver,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...o,...r?{configOverrides:r}:{}};this.inner=Zd(s).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=eb(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 ${Jw} (virtual git implementation)
889
+ `,y=g+x+b,P="";if(E)P=await Yn(e,m.tree,h)+E;else if(r){P=await Yn(e,m.tree,h);let C=await pe(e),A=await Bt(e,C,t);A&&(P+=zn(A))}else if(n&&c){let C=await pe(e),A=await Bt(e,C,t);A&&(P=zn(A))}return{stdout:P,stderr:y,exitCode:0}}async function cu(e,t,n,r,o,s){let i=await ii(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return de(a)?{stdout:"",stderr:a.message??"",exitCode:1}:mr(e,t,n,r,o,s)}async function wb(e,t,n,r,o){let s=await ii(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return de(i)?{stdout:"",stderr:i.message??"",exitCode:1}:Xn(e,n,r,o)}async function bb(e,t,n,r){if(!En(t))return S(`'${t}' is not a valid branch name`);let o=await ii(e);if(o)return o;let s=`refs/heads/${t}`;if(await U(e,s))return S(`a branch named '${t}' already exists`);let a=await V(e),c=Vn(a);if(c)return c;let f=await Z(e),l=await te(e),d="";if(l?.type==="direct"&&f&&(d=await ia(e,f)),e.workTree){let h=f?(await j(e,f)).tree:null,m=await Fe(e,[]),p=await hn(e,h,m,a);if(!p.success)return p.errorOutput??_("error: checkout would overwrite local changes");await De(e,p.worktreeOps),await ae(e,{version:2,entries:p.newEntries})}else await ae(e,pc());await Ze(e,"HEAD",s),await Et(e);let u=await In(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ne,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
890
+ ${u}`,exitCode:0}}se();ie();Tr();ge();ls();function lu(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:O().alias("a").describe("Make an annotated tag object"),message:Y.string().alias("m").describe("Tag message"),delete:O().alias("d").describe("Delete a tag"),force:O().alias("f").describe("Replace an existing tag"),list:O().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await K(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 U(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${X(a)})
891
+ `,stderr:"",exitCode:0}):_(`error: tag '${n.name}' not found.
892
+ `)}if(n.list)return fu(s,n.name||void 0);if(n.name){if(!Zc(n.name))return S(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let h=await yt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(h))return h;a=h}else if(a=await Z(s),!a)return S("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`,f=await U(s,c);if(f&&!n.force)return S(`tag '${n.name}' already exists`);let l=n.annotate||n.message,d;if(l){if(!n.message)return S("no tag message specified (use -m)");let h=await tt(s,r.env);if(M(h))return h;let m=It(n.message),p=zc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:h,message:m}),g=await Ie(s,"tag",p);await J(s,c,g),d=g}else await J(s,c,a),d=a;return{stdout:f&&n.force&&f!==d?`Updated tag '${n.name}' (was ${X(f)})
893
+ `:"",stderr:"",exitCode:0}}return fu(s)}})}async function fu(e,t){let n=await ye(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>ln(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
894
+ `)}
895
+ `,stderr:"",exitCode:0}}var du=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),yb={init:(e,t)=>ud(e,t),clone:(e,t)=>Ul(e,t),describe:(e,t)=>Wl(e,t),fetch:(e,t)=>id(e,t),pull:(e,t)=>Dd(e,t),push:(e,t)=>jd(e,t),add:(e,t)=>Ef(e,t),blame:(e,t)=>el(e,t),commit:(e,t)=>ql(e,t),status:(e,t)=>ou(e,t),log:(e,t)=>Rd(e,t),branch:(e,t)=>sl(e,t),tag:(e,t)=>lu(e,t),checkout:(e,t)=>il(e,t),diff:(e,t)=>td(e,t),reset:(e,t)=>Wd(e,t),merge:(e,t)=>Pd(e,t),"cherry-pick":(e,t)=>El(e,t),revert:(e,t)=>Vd(e,t),rebase:(e,t)=>Ld(e,t),mv:(e,t)=>$d(e,t),rm:(e,t)=>Xd(e,t),remote:(e,t)=>Nd(e,t),config:(e,t)=>Yl(e,t),show:(e,t)=>Zd(e,t),stash:(e,t)=>su(e,t),"rev-parse":(e,t)=>zd(e,t),"ls-files":(e,t)=>Cd(e,t),clean:(e,t)=>kl(e,t),switch:(e,t)=>au(e,t),restore:(e,t)=>Kd(e,t),reflog:(e,t)=>Gd(e,t),repack:(e,t)=>Ud(e,t),gc:(e,t)=>ad(e,t),bisect:(e,t)=>Ff(e,t),grep:(e,t)=>dd(e,t)};function uu(e){let t=mi("git",{description:"Git command"});for(let n of Object.values(yb))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:Cr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Cr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
896
+ `,exitCode:1}}}),t}kn();var Eb="1.6.2";function kb(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 ai=class{name="git";defaultFs;defaultCwd;blocked;hooks;ext;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=kb(t?.identity,t?.config),o=t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},s={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,credentialCache:new Map,onProgress:t?.onProgress,mergeDriver:t?.mergeDriver,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...o,...r?{configOverrides:r}:{}};this.ext=s,this.inner=uu(s).toCommand()}async findRepo(t){let n=t?.fs??this.defaultFs;if(!n)throw new Error("No filesystem: pass `fs` in findRepo() options or in createGit()");let r=t?.cwd??this.defaultCwd;if(this.ext.objectStore&&this.ext.refStore&&this.ext.gitDir)return{fs:n,gitDir:this.ext.gitDir,workTree:this.ext.workTree??r,objectStore:this.ext.objectStore,refStore:this.ext.refStore,...this.ext};let o=await Rn(n,r);return o?{...o,...this.ext}:null}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=Rb(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 ${Eb} (virtual git implementation)
875
897
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
876
- `,exitCode:1};if(r&&Xd.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
877
- `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(fe(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function eb(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 tb(e){return new ri(e)}var Jd=new TextEncoder,nb=new TextDecoder;function gn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function si(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var ja=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=gn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Jd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=si(t);n!=="/"&&(this.data.has(n)||(this.ensureParents(n),this.data.set(n,{type:"directory",mode:16877,mtime:new Date})))}resolve(t){let n="",r=new Set;for(let o of gn(t).slice(1).split("/")){n=`${n}/${o}`;let s=0,i=this.data.get(n);for(;i?.type==="symlink"&&s<40;){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);r.add(n);let a=i.target;n=a.startsWith("/")?gn(a):gn(si(n)+"/"+a),i=this.data.get(n),s++}if(s>=40)throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`)}return n}resolveParent(t){let n=gn(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let o="",s=new Set;for(let i=0;i<r.length-1;i++){o=`${o}/${r[i]}`;let a=this.data.get(o),c=0;for(;a?.type==="symlink"&&c<40;){if(s.has(o))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);s.add(o);let f=a.target;o=f.startsWith("/")?gn(f):gn(si(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return nb.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"?Jd.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=gn(t);if(this.data.has(r)){if(this.data.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let o=si(r);if(o!=="/"&&!this.data.has(o))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:16877,mtime:new Date})}async readdir(t){let n=this.resolve(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let o=n==="/"?"/":`${n}/`,s=new Set;for(let i of this.data.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&s.add(c)}return[...s].sort()}async rm(t,n){let r=gn(t),o=this.data.get(r);if(!o){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(o.type==="directory"){if(!n?.recursive&&(await this.readdir(r)).length>0)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);let s=r==="/"?"/":`${r}/`;for(let i of[...this.data.keys()])i.startsWith(s)&&this.data.delete(i)}this.data.delete(r)}async readlink(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async symlink(t,n){let r=gn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};Nn();export{ri as Git,ja as MemoryFileSystem,ep as composeGitHooks,tb as createGit,ir as findRepo,fe as isRejection};
898
+ `,exitCode:1};if(r&&du.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
899
+ `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(de(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function Rb(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 xb(e){return new ai(e)}var hu=new TextEncoder,Cb=new TextDecoder;function wn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function ci(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ba=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=wn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?hu.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=ci(t);n!=="/"&&(this.data.has(n)||(this.ensureParents(n),this.data.set(n,{type:"directory",mode:16877,mtime:new Date})))}resolve(t){let n="",r=new Set;for(let o of wn(t).slice(1).split("/")){n=`${n}/${o}`;let s=0,i=this.data.get(n);for(;i?.type==="symlink"&&s<40;){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);r.add(n);let a=i.target;n=a.startsWith("/")?wn(a):wn(ci(n)+"/"+a),i=this.data.get(n),s++}if(s>=40)throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`)}return n}resolveParent(t){let n=wn(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let o="",s=new Set;for(let i=0;i<r.length-1;i++){o=`${o}/${r[i]}`;let a=this.data.get(o),c=0;for(;a?.type==="symlink"&&c<40;){if(s.has(o))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);s.add(o);let f=a.target;o=f.startsWith("/")?wn(f):wn(ci(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Cb.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"?hu.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=wn(t);if(this.data.has(r)){if(this.data.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let o=ci(r);if(o!=="/"&&!this.data.has(o))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:16877,mtime:new Date})}async readdir(t){let n=this.resolve(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let o=n==="/"?"/":`${n}/`,s=new Set;for(let i of this.data.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&s.add(c)}return[...s].sort()}async rm(t,n){let r=wn(t),o=this.data.get(r);if(!o){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(o.type==="directory"){if(!n?.recursive&&(await this.readdir(r)).length>0)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);let s=r==="/"?"/":`${r}/`;for(let i of[...this.data.keys()])i.startsWith(s)&&this.data.delete(i)}this.data.delete(r)}async readlink(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async symlink(t,n){let r=wn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};kn();export{ai as Git,Ba as MemoryFileSystem,gp as composeGitHooks,xb as createGit,Rn as findRepo,de as isRejection};