just-git 1.5.1 → 1.5.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 vd=Object.defineProperty;var Os=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ad=(e,t)=>{for(var n in t)vd(e,n,{get:t[n],enumerable:!0})};function vs(e){if(e==="")return".";if(e==="/")return"/";let t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47,r=e.split("/"),o=[];for(let i of r)i===""||i==="."||(i===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(i));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function v(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":vs(t)}function vt(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return vs(t||".")}function Qt(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 Fr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function st(e,t){let n=vs(e),r=vs(t);if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,l=Math.min(o.length,s.length);for(;f<l&&o[f]===s[f];)f++;let d=o.length-f,u=s.slice(f),m=[];for(let h=0;h<d;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var me=Re(()=>{"use strict"});function Yo(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 Gd(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=Yo(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 Xo(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=Yo(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 Zo(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 Jo(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} = ${Zo(s)}`)}return`${t.join(`
6
- `)}
7
- `}function Qo(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=Yo(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 Ld(e,t,n,r){let o=e.split(`
8
- `),s=Qo(o,t,n),i=` ${n} = ${Zo(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 Nd(e,t,n){let r=e.split(`
10
- `),o=Qo(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 we(e){let t=v(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Gd(n)}async function As(e){let t=v(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Je(e,t){let n=v(e.gitDir,"config");await e.fs.writeFile(n,Jo(t))}async function xe(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await we(e),{section:s,key:i}=Ur(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function ei(e,t,n){let r=await As(e),{section:o,key:s}=Ur(t),i=Ld(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Ga(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await As(e);if(o){let i=Xo(o),{section:a,key:c}=Ur(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function _d(e,t,n,r){let o=e.split(`
12
- `),s=Qo(o,t,n),i=` ${n} = ${Zo(r)}`;return s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
13
- `)}async function La(e,t,n){let r=await As(e),{section:o,key:s}=Ur(t),i=_d(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function Na(e,t){let n=await As(e),{section:r,key:o}=Ur(t),s=Nd(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Ur(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 qe=Re(()=>{"use strict";me()});function Hs(e,t){return _a(e,t,"author")}function Br(e,t){return _a(e,t,"committer")}async function _a(e,t,n){let r=Fd[n],o=e.identityOverride,{timestamp:s,timezone:i}=Ud(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 Ad=Object.defineProperty;var Is=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Re=(e,t)=>()=>(e&&(t=e(e=0)),t);var Hd=(e,t)=>{for(var n in t)Ad(e,n,{get:t[n],enumerable:!0})};function As(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===""?".":As(t)}function vt(...e){let t="";for(let n=e.length-1;n>=0;n--){let r=e[n];if(r&&(t=t?`${r}/${t}`:r,r.charCodeAt(0)===47))break}return As(t||".")}function Qt(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 Ur(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function st(e,t){let n=As(e),r=As(t);if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),i=n.charCodeAt(0)===47,a=r.charCodeAt(0)===47,f=i&&a?1:0,l=Math.min(o.length,s.length);for(;f<l&&o[f]===s[f];)f++;let d=o.length-f,u=s.slice(f),m=[];for(let h=0;h<d;h++)m.push("..");for(let h of u)m.push(h);return m.join("/")||"."}var me=Re(()=>{"use strict"});function Zo(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 Ga(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 Ld(e){let t={},n=null,r=e.split(`
3
+ `),o=0;for(;o<r.length;){let i=r[o].trim();if(!i||i.startsWith("#")||i.startsWith(";")){o++;continue}if(i.startsWith("[")){n=Zo(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}=Ga(l,r,o);a[f]=d,o+=u}continue}o++}return t}function Jo(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=Zo(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}=Ga(l,r,o);f in a?a[f].push(d):a[f]=[d],o+=u}continue}o++}return t}function Qo(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 ei(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} = ${Qo(s)}`)}return`${t.join(`
6
+ `)}
7
+ `}function ti(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=Zo(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 Nd(e,t,n,r){let o=e.split(`
8
+ `),s=ti(o,t,n),i=` ${n} = ${Qo(r)}`;return s.keyStart!==-1?o.splice(s.keyStart,s.keyEnd-s.keyStart+1,i):s.insertAfter!==-1?o.splice(s.insertAfter+1,0,i):(o.some(c=>c.trim().length>0)&&o.length>0&&o[o.length-1].trim()!==""&&o.push(""),o.push(`[${t}]`,i)),o.join(`
9
+ `)}function _d(e,t,n){let r=e.split(`
10
+ `),o=ti(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 we(e){let t=v(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return Ld(n)}async function Hs(e){let t=v(e.gitDir,"config");return await e.fs.exists(t)?e.fs.readFile(t):""}async function Je(e,t){let n=v(e.gitDir,"config");await e.fs.writeFile(n,ei(t))}async function xe(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return r;let o=await we(e),{section:s,key:i}=Br(t),a=o[s]?.[i];return a!==void 0?a:n?.defaults?.[t]}async function ni(e,t,n){let r=await Hs(e),{section:o,key:s}=Br(t),i=Nd(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function La(e,t){let n=e.configOverrides,r=n?.locked?.[t];if(r!==void 0)return[r];let o=await Hs(e);if(o){let i=Jo(o),{section:a,key:c}=Br(t),f=i[a]?.[c];if(f&&f.length>0)return f}let s=n?.defaults?.[t];return s!==void 0?[s]:[]}function Fd(e,t,n,r){let o=e.split(`
12
+ `),s=ti(o,t,n),i=` ${n} = ${Qo(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 Na(e,t,n){let r=await Hs(e),{section:o,key:s}=Br(t),i=Fd(r,o,s,n),a=v(e.gitDir,"config");await e.fs.writeFile(a,i)}async function _a(e,t){let n=await Hs(e),{section:r,key:o}=Br(t),s=_d(n,r,o);if(!s.found)return!1;let i=v(e.gitDir,"config");return await e.fs.writeFile(i,s.text),!0}function Br(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 qe=Re(()=>{"use strict";me()});function Ds(e,t){return Fa(e,t,"author")}function Wr(e,t){return Fa(e,t,"committer")}async function Fa(e,t,n){let r=Ud[n],o=e.identityOverride,{timestamp:s,timezone:i}=Bd(t.get(r.date));if(o?.locked)return{name:o.name,email:o.email,timestamp:s,timezone:i};let a=t.get(r.name)??await xe(e,"user.name")??o?.name,c=t.get(r.email)??await xe(e,"user.email")??o?.email;if(!a||!c)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
14
14
 
15
15
  *** Please tell me who you are.
16
16
 
@@ -18,97 +18,97 @@ Run
18
18
 
19
19
  git config user.email "you@example.com"
20
20
  git config user.name "Your Name"
21
- `);return{name:a,email:c,timestamp:s,timezone:i}}async function en(e,t){try{let n=await Br(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 Ud(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:Bd(n)}}function Bd(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 Fd,Tn=Re(()=>{"use strict";qe();Fd={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function vn(e){let t="";for(let n=0;n<20;n++)t+=Fa[e[n]];return t}function Wr(e,t){let n="";for(let r=0;r<20;r++)n+=Fa[e[t+r]];return n}function At(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var ee,Fa,ht=Re(()=>{"use strict";ee="0000000000000000000000000000000000000000",Fa=(()=>{let e=new Array(256);for(let t=0;t<256;t++)e[t]=(t>>4).toString(16)+(t&15).toString(16);return e})()});function Ua(e){return e.length===4&&e.toLowerCase()===".git"}function Qn(e){if(e.length===0||e.includes("\0")||e.charCodeAt(0)===47||e.charCodeAt(e.length-1)===47)return!1;let t=e.split("/");for(let n of t)if(n.length===0||n==="."||n===".."||Ua(n))return!1;return!0}function Ds(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function Ba(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||Ua(n))return!1;return!0}var Ms=Re(()=>{"use strict"});function ti(e){return typeof e=="string"?Wd.encode(e):e}function qd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(ti(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Os(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(ti(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(ti(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return vn(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}async function Hn(e){return Wa().update(e).hex()}var Wd,Wa,An,er=Re(()=>{"use strict";ht();Wd=new TextEncoder;Wa=qd(),An=Wa});async function z(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:ni,entries:[]};let n=await e.fs.readFileBuffer(t);return zd(n)}async function de(e,t){let n=v(e.gitDir,"index"),r=await Kd(t);await e.fs.writeFile(n,r)}function Ct(e,t){if(!Qn(t.path))throw new Error(`refusing to add unsafe path to index: '${t.path}'`);let n;return t.stage===0?n=e.entries.filter(r=>r.path!==t.path):n=e.entries.filter(r=>!(r.path===t.path&&r.stage===t.stage)),n.push(t),n.sort(ri),{...e,entries:n}}function lt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function js(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Ht(e){return e.entries.some(t=>t.stage>0)}function Bt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Le(e){return e.entries.filter(t=>t.stage===0)}function za(){return{version:ni,entries:[]}}function Gs(e){let t=[...e].sort(ri);return{version:ni,entries:t}}function Se(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function zd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==qa)throw new Error(`Invalid index signature: 0x${r.toString(16)}`);let o=t.getUint32(n);n+=4;let s=t.getUint32(n);n+=4;let i=[];for(let a=0;a<s;a++){let c=n,f={ctimeSeconds:t.getUint32(n),ctimeNanoseconds:t.getUint32(n+4),mtimeSeconds:t.getUint32(n+8),mtimeNanoseconds:t.getUint32(n+12),dev:t.getUint32(n+16),ino:t.getUint32(n+20),uid:t.getUint32(n+28),gid:t.getUint32(n+32),size:t.getUint32(n+36)},l=t.getUint32(n+24);n+=40;let d=e.subarray(n,n+20),u=vn(d);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let b=n;for(;b<e.byteLength&&e[b]!==0;)b++;w=new TextDecoder().decode(e.subarray(n,b)),g=b-n}let y=62+g+1,x=Math.ceil(y/8)*8;n=c+x,i.push({path:w,mode:l,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function Kd(e){let t=new TextEncoder,n=[...e.entries].sort(ri),r=[],o=12;for(let u of n){let m=t.encode(u.path);r.push(m);let h=62+m.byteLength+1;o+=Math.ceil(h/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,qa),c+=4,a.setUint32(c,e.version),c+=4,a.setUint32(c,n.length),c+=4;for(let u=0;u<n.length;u++){let m=n[u],h=r[u],p=c;a.setUint32(c,m.stat.ctimeSeconds),a.setUint32(c+4,m.stat.ctimeNanoseconds),a.setUint32(c+8,m.stat.mtimeSeconds),a.setUint32(c+12,m.stat.mtimeNanoseconds),a.setUint32(c+16,m.stat.dev),a.setUint32(c+20,m.stat.ino),a.setUint32(c+24,m.mode),a.setUint32(c+28,m.stat.uid),a.setUint32(c+32,m.stat.gid),a.setUint32(c+36,m.stat.size),c+=40;let g=At(m.hash);i.set(g,c),c+=20;let w=Math.min(h.byteLength,4095),y=(m.stage&3)<<12|w;a.setUint16(c,y),c+=2,i.set(h,c),c+=h.byteLength,i[c]=0,c+=1;let x=62+h.byteLength+1,b=Math.ceil(x/8)*8;c=p+b}let f=i.subarray(0,c),l=await Hn(f),d=At(l);return i.set(d,c),i}function ri(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var qa,ni,Ce=Re(()=>{"use strict";ht();Ms();me();er();qa=1145655875,ni=2});var Vd,Ls,Ka=Re(()=>{"use strict";Vd=new Set(["tree","commit","tag"]),Ls=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Vd.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 si(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Va[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Va,Ya=Re(()=>{"use strict";Va=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;Va[e]=t}});function sc(e){let t=rc(e);return nc(e.subarray(t,-4),{i:2})}function ci(e){let t=rc(e),n={i:2},r=nc(e.subarray(t),n),o=tc(n.p);return{result:r,bytesConsumed:t+o+4}}var qt,yr,Yd,Xa,Za,Xd,Ja,Qa,Zd,ai,qr,zr,ec,Jd,Qd,oi,Wt,ii,tc,eu,tn,nc,rc,oc=Re(()=>{"use strict";qt=Uint8Array,yr=Uint16Array,Yd=Int32Array,Xa=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Za=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Xd=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ja=(e,t)=>{let n=new yr(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new Yd(n[30]);for(let o=1;o<30;++o)for(let s=n[o];s<n[o+1];++s)r[s]=s-n[o]<<5|o;return{b:n,r}},{b:Qa}=Ja(Xa,2);Qa[28]=258;({b:Zd}=Ja(Za,0)),ai=new yr(32768);for(let e=0;e<32768;++e){let t=(e&43690)>>1|(e&21845)<<1;t=(t&52428)>>2|(t&13107)<<2,t=(t&61680)>>4|(t&3855)<<4,ai[e]=((t&65280)>>8|(t&255)<<8)>>1}qr=(e,t,n)=>{let r=e.length,o=0,s=new yr(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new yr(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new yr(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[ai[d]>>c]=f}}else for(a=new yr(r),o=0;o<r;++o)e[o]&&(a[o]=ai[i[e[o]-1]++]>>15-e[o]);return a},zr=new qt(288);for(let e=0;e<144;++e)zr[e]=8;for(let e=144;e<256;++e)zr[e]=9;for(let e=256;e<280;++e)zr[e]=7;for(let e=280;e<288;++e)zr[e]=8;ec=new qt(32);for(let e=0;e<32;++e)ec[e]=5;Jd=qr(zr,9,1),Qd=qr(ec,5,1),oi=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Wt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ii=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},tc=e=>(e+7)/8|0,eu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))),tn=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},nc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new qt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new qt(o*3));let f=y=>{let x=n.length;if(y>x){let b=new qt(Math.max(x*2,y));b.set(n),n=b}},l=t.f||0,d=t.p||0,u=t.b||0,m=t.l,h=t.d,p=t.m,g=t.n,w=o*8;do{if(!m){l=Wt(e,d,1);let E=Wt(e,d+1,3);if(d+=3,E)if(E==1)m=Jd,h=Qd,p=9,g=5;else if(E==2){let R=Wt(e,d,31)+257,k=Wt(e,d+10,15)+4,C=R+Wt(e,d+5,31)+1;d+=14;let P=new qt(C),T=new qt(19);for(let A=0;A<k;++A)T[Xd[A]]=Wt(e,d+A*3,7);d+=k*3;let D=oi(T),O=(1<<D)-1,N=qr(T,D,1);for(let A=0;A<C;){let _=N[Wt(e,d,O)];d+=_&15;let F=_>>4;if(F<16)P[A++]=F;else{let U=0,L=0;for(F==16?(L=3+Wt(e,d,3),d+=2,U=P[A-1]):F==17?(L=3+Wt(e,d,7),d+=3):F==18&&(L=11+Wt(e,d,127),d+=7);L--;)P[A++]=U}}let H=P.subarray(0,R),S=P.subarray(R);p=oi(H),g=oi(S),m=qr(H,p,1),h=qr(S,g,1)}else tn(1);else{let R=tc(d)+4,k=e[R-4]|e[R-3]<<8,C=R+k;if(C>o){c&&tn(0);break}a&&f(u+k),n.set(e.subarray(R,C),u),t.b=u+=k,t.p=d=C*8,t.f=l;continue}if(d>w){c&&tn(0);break}}a&&f(u+131072);let y=(1<<p)-1,x=(1<<g)-1,b=d;for(;;b=d){let E=m[ii(e,d)&y],R=E>>4;if(d+=E&15,d>w){c&&tn(0);break}if(E||tn(2),R<256)n[u++]=R;else if(R==256){b=d,m=null;break}else{let k=R-254;if(R>264){let O=R-257,N=Xa[O];k=Wt(e,d,(1<<N)-1)+Qa[O],d+=N}let C=h[ii(e,d)&x],P=C>>4;C||tn(3),d+=C&15;let T=Zd[P];if(P>3){let O=Za[P];T+=ii(e,d)&(1<<O)-1,d+=O}if(d>w){c&&tn(0);break}a&&f(u+131072);let D=u+k;if(u<T){let O=s-T,N=Math.min(T,D);for(O+u<0&&tn(3);u<N;++u)n[u]=r[O+u]}for(;u<D;++u)n[u]=n[u-T]}}t.l=m,t.p=b,t.b=u,t.f=l,m&&(l=1,t.m=p,t.d=h,t.n=g)}while(!l);return u!=n.length&&i?eu(n,0,u):n.subarray(0,u)},rc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&tn(0,"invalid zlib data"),e[1]&32&&tn(0,"zlib dictionaries are not supported"),2)});async function tu(){let e;if(!(typeof document<"u"))try{e=Os(["node","zlib"].join(":"))}catch{try{e=await import(["node","zlib"].join(":"))}catch{}}if(e&&typeof e.deflateSync=="function"&&typeof e.inflateSync=="function"){let r=null;try{let o=e.inflateSync(e.deflateSync(Buffer.from("x")),{info:!0});o?.engine&&typeof o.engine.bytesWritten=="number"&&(r=s=>{let i=e.inflateSync(s,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:o=>new Uint8Array(e.deflateSync(o)),inflateSync:o=>new Uint8Array(e.inflateSync(o)),inflateWithConsumed:r??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:sc,inflateWithConsumed:ci}}function fi(){return nu??=tu()}async function Er(e){return await(await fi()).deflateSync(e)}async function kr(e){return await(await fi()).inflateSync(e)}async function ic(e,t){let n=await fi(),{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 nu,Ns=Re(()=>{"use strict";oc();nu=null});async function hc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==_s)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${_s.toString(16)})`);let o=n.getUint32(4);if(o!==ui)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=Wr(e,e.byteLength-20),l=An();l.update(e.subarray(0,e.byteLength-20));let d=await l.hex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await su(e,a);i.push(l),a=l.nextOffset}return(await ou(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===Kr){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===mi&&(c=Wr(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 ou(e,t){let n=new Map;for(let s=0;s<e.length;s++)n.set(e[s].headerOffset,s);let r=new Array(e.length).fill(null);async function o(s,i=0){if(i>ac)throw new Error(`delta chain depth ${i} exceeds limit of ${ac}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==Kr&&c.typeNum!==mi){let m=ru[c.typeNum];if(!m)throw new Error(`Unknown object type: ${c.typeNum}`);let h={type:m,content:c.inflated,hash:await li(m,c.inflated)};return r[s]=h,h}if(c.typeNum===Kr){let m=n.get(c.baseOffset);if(m===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let h=await o(m,i+1),p=Vr(h.content,c.inflated),g={type:h.type,content:p,hash:await li(h.type,p)};return r[s]=g,g}let f=await iu(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let m=await t(c.baseHash);m&&(l=m)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=Vr(l.content,c.inflated),u={type:l.type,content:d,hash:await li(l.type,d)};return r[s]=u,u}for(let s=0;s<e.length;s++)await o(s);return r}async function iu(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==Kr&&s.typeNum!==mi&&(await r(o)).hash===n)return o}}function Vr(e,t){let n=0,{value:r,newPos:o}=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 pc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,_s),r.setUint32(4,ui),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=mc[o.type],i=await Er(o.content);t.push(di(s,o.content.byteLength)),t.push(i)}return gc(t)}async function Fs(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,_s),o.setUint32(4,ui),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=di(Kr,a.delta.byteLength),d=au(s-f),u=await Er(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=mc[a.type],d=di(l,a.content.byteLength),u=await Er(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await gc(t),entries:i}}async function gc(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=An();o.update(n.subarray(0,r));let s=await o.hex();return n.set(At(s),r),n}function au(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 di(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 li(e,t){let n=cu.encode(`${e} ${t.byteLength}\0`),r=An();return r.update(n),r.update(t),r.hex()}var _s,ui,fc,lc,dc,uc,Kr,mi,ru,mc,ac,cu,Rr=Re(()=>{"use strict";ht();er();Ns();_s=1346454347,ui=2,fc=1,lc=2,dc=3,uc=4,Kr=6,mi=7,ru={[fc]:"commit",[lc]:"tree",[dc]:"blob",[uc]:"tag"},mc={commit:fc,tree:lc,blob:dc,tag:uc};ac=50;cu=new TextEncoder});async function yc(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,wc),c+=4,a.setUint32(c,bc),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(At(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let l=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let d=An();d.update(i.subarray(0,c));let u=await d.hex();return i.set(At(u),c),i}async function Ec(e){let n=(await hc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:si(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return yc(n,r)}async function kc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:si(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return yc(n,r)}var wc,bc,zt,Us=Re(()=>{"use strict";ht();er();Ya();Rr();wc=4285812579,bc=2,zt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==wc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==bc)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=At(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=At(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,m=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==m){l=!1;break}}l&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var fu,lu,du,Rc,Yr,xc=Re(()=>{"use strict";ht();Us();Rr();Ns();fu=6,lu=7,du={1:"commit",2:"tree",3:"blob",4:"tag"},Rc=50,Yr=class{constructor(t,n){this.data=t;this.index=n instanceof zt?n:new zt(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n,0)}get objectCount(){return this.index.objectCount}async readAt(t,n){if(n>Rc)throw new Error(`delta chain depth ${n} exceeds limit of ${Rc}`);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===fu){let d=r[o++],u=d&127;for(;d&128;)u+=1,d=r[o++],u=(u<<7)+(d&127);let m=await kr(r.subarray(o)),h=await this.readAt(t-u,n+1);return{type:h.type,content:Vr(h.content,m)}}if(i===lu){let d=Wr(r,o);o+=20;let u=await kr(r.subarray(o)),m=this.index.lookup(d);if(m===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let h=await this.readAt(m,n+1);return{type:h.type,content:Vr(h.content,u)}}let f=du[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await kr(r.subarray(o));if(l.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${l.byteLength}, expected ${a}`);return{type:f,content:l}}}});function pi(e,t){let n=uu.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function hu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=mu.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function hi(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var uu,mu,xr,gi=Re(()=>{"use strict";ht();Ka();Us();xc();Rr();Ns();me();er();uu=new TextEncoder,mu=new TextDecoder;xr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ls(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=pi(t,n),o=await Hn(r),s=hi(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 Er(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=hi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await kr(o),i=await Hn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=hu(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(hi(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let o=n.getUint32(4);if(o!==2)throw new Error(`unsupported pack version: ${o}`);let s=n.getUint32(8);if(s===0)return 0;let i=t.subarray(t.byteLength-20),a=vn(i),c=await Hn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=v(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await Ec(t),u=v(this.packDir,`${f}.idx`);await this.fs.writeFile(u,d),this.loadedPackNames.add(f);let m=new zt(d);return this.packs.push({name:f,index:m,reader:new Yr(t,m)}),s}async ingestPackStream(t){let n=[];for await(let o of t)n.push(o);if(n.length===0)return 0;let r=await pc(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 Yr(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 zt(s),reader:null})}}}});function Xr(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 Zr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var wi=Re(()=>{"use strict"});function nn(e){let t=gu.decode(e),n=t.indexOf(`
21
+ `);return{name:a,email:c,timestamp:s,timezone:i}}async function en(e,t){try{let n=await Wr(e,t);return{name:n.name,email:n.email,timestamp:n.timestamp,tz:n.timezone}}catch{return{name:t.get("GIT_COMMITTER_NAME")??"",email:t.get("GIT_COMMITTER_EMAIL")??"",timestamp:Math.floor(Date.now()/1e3),tz:"+0000"}}}function Bd(e){let t={timestamp:Math.floor(Date.now()/1e3),timezone:"+0000"};if(!e)return t;let n=e.trim();if(!n)return t;if(n.startsWith("@")){let s=n.slice(1).trim(),i=parseInt(s,10);if(!Number.isNaN(i))return{timestamp:i,timezone:"+0000"}}if(/^\d+$/.test(n))return{timestamp:parseInt(n,10),timezone:"+0000"};let r=n.match(/^(\d+)\s+([+-]\d{4})$/);if(r)return{timestamp:parseInt(r[1],10),timezone:r[2]};let o=Date.parse(n);return Number.isNaN(o)?t:{timestamp:Math.floor(o/1e3),timezone:Wd(n)}}function Wd(e){if(/Z$/i.test(e))return"+0000";let t=e.match(/([+-])(\d{2}):(\d{2})$/);if(t)return`${t[1]}${t[2]}${t[3]}`;let n=e.match(/([+-]\d{4})$/);return n?n[1]:"+0000"}var Ud,Tn=Re(()=>{"use strict";qe();Ud={author:{name:"GIT_AUTHOR_NAME",email:"GIT_AUTHOR_EMAIL",date:"GIT_AUTHOR_DATE"},committer:{name:"GIT_COMMITTER_NAME",email:"GIT_COMMITTER_EMAIL",date:"GIT_COMMITTER_DATE"}}});function vn(e){let t="";for(let n=0;n<20;n++)t+=Ua[e[n]];return t}function qr(e,t){let n="";for(let r=0;r<20;r++)n+=Ua[e[t+r]];return n}function At(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var ee,Ua,ht=Re(()=>{"use strict";ee="0000000000000000000000000000000000000000",Ua=(()=>{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 Ba(e){return e.length===4&&e.toLowerCase()===".git"}function Qn(e){if(e.length===0||e.includes("\0")||e.charCodeAt(0)===47||e.charCodeAt(e.length-1)===47)return!1;let t=e.split("/");for(let n of t)if(n.length===0||n==="."||n===".."||Ba(n))return!1;return!0}function Ms(e,t){return t===e?!1:e==="/"?t.startsWith("/")&&t.length>1:t.startsWith(e+"/")}function Wa(e){if(e.length===0||e.charCodeAt(0)===47)return!1;let t=e.split("/");for(let n of t)if(n===".."||Ba(n))return!1;return!0}var js=Re(()=>{"use strict"});function ri(e){return typeof e=="string"?qd.encode(e):e}function zd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(ri(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Is(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(ri(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(ri(n)),t},async hex(){let n=0;for(let i of e)n+=i.byteLength;let r=new Uint8Array(n),o=0;for(let i of e)r.set(i,o),o+=i.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return vn(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}async function Hn(e){return qa().update(e).hex()}var qd,qa,An,er=Re(()=>{"use strict";ht();qd=new TextEncoder;qa=zd(),An=qa});async function z(e){let t=v(e.gitDir,"index");if(!await e.fs.exists(t))return{version:si,entries:[]};let n=await e.fs.readFileBuffer(t);return Kd(n)}async function de(e,t){let n=v(e.gitDir,"index"),r=await Vd(t);await e.fs.writeFile(n,r)}function Ct(e,t){if(!Qn(t.path))throw new Error(`refusing to add unsafe path to index: '${t.path}'`);let n;return t.stage===0?n=e.entries.filter(r=>r.path!==t.path):n=e.entries.filter(r=>!(r.path===t.path&&r.stage===t.stage)),n.push(t),n.sort(oi),{...e,entries:n}}function lt(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Gs(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Ht(e){return e.entries.some(t=>t.stage>0)}function Bt(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function Le(e){return e.entries.filter(t=>t.stage===0)}function Ka(){return{version:si,entries:[]}}function Ls(e){let t=[...e].sort(oi);return{version:si,entries:t}}function Se(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function Kd(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==za)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=vn(d);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g,w;if(p<4095)w=new TextDecoder().decode(e.subarray(n,n+p)),g=p;else{let b=n;for(;b<e.byteLength&&e[b]!==0;)b++;w=new TextDecoder().decode(e.subarray(n,b)),g=b-n}let y=62+g+1,x=Math.ceil(y/8)*8;n=c+x,i.push({path:w,mode:l,hash:u,stage:h,stat:f})}return{version:o,entries:i}}async function Vd(e){let t=new TextEncoder,n=[...e.entries].sort(oi),r=[],o=12;for(let u of n){let m=t.encode(u.path);r.push(m);let h=62+m.byteLength+1;o+=Math.ceil(h/8)*8}o+=20;let s=new ArrayBuffer(o),i=new Uint8Array(s),a=new DataView(s),c=0;a.setUint32(c,za),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 m=n[u],h=r[u],p=c;a.setUint32(c,m.stat.ctimeSeconds),a.setUint32(c+4,m.stat.ctimeNanoseconds),a.setUint32(c+8,m.stat.mtimeSeconds),a.setUint32(c+12,m.stat.mtimeNanoseconds),a.setUint32(c+16,m.stat.dev),a.setUint32(c+20,m.stat.ino),a.setUint32(c+24,m.mode),a.setUint32(c+28,m.stat.uid),a.setUint32(c+32,m.stat.gid),a.setUint32(c+36,m.stat.size),c+=40;let g=At(m.hash);i.set(g,c),c+=20;let w=Math.min(h.byteLength,4095),y=(m.stage&3)<<12|w;a.setUint16(c,y),c+=2,i.set(h,c),c+=h.byteLength,i[c]=0,c+=1;let x=62+h.byteLength+1,b=Math.ceil(x/8)*8;c=p+b}let f=i.subarray(0,c),l=await Hn(f),d=At(l);return i.set(d,c),i}function oi(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var za,si,Ce=Re(()=>{"use strict";ht();js();me();er();za=1145655875,si=2});var Yd,Ns,Va=Re(()=>{"use strict";Yd=new Set(["tree","commit","tag"]),Ns=class{map=new Map;currentBytes=0;maxBytes;constructor(t=16*1024*1024){this.maxBytes=t}get(t){return this.map.get(t)}set(t,n){if(!Yd.has(n.type))return;let r=n.content.byteLength;if(!(r>this.maxBytes/2)&&!this.map.has(t)){for(;this.currentBytes+r>this.maxBytes&&this.map.size>0;){let o=this.map.keys().next().value;this.currentBytes-=this.map.get(o).content.byteLength,this.map.delete(o)}this.map.set(t,n),this.currentBytes+=r}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}}});function ii(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Ya[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Ya,Xa=Re(()=>{"use strict";Ya=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;Ya[e]=t}});function oc(e){let t=sc(e);return rc(e.subarray(t,-4),{i:2})}function li(e){let t=sc(e),n={i:2},r=rc(e.subarray(t),n),o=nc(n.p);return{result:r,bytesConsumed:t+o+4}}var qt,Er,Xd,Za,Ja,Zd,Qa,ec,Jd,fi,zr,Kr,tc,Qd,eu,ai,Wt,ci,nc,tu,tn,rc,sc,ic=Re(()=>{"use strict";qt=Uint8Array,Er=Uint16Array,Xd=Int32Array,Za=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ja=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Zd=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qa=(e,t)=>{let n=new Er(31);for(let o=0;o<31;++o)n[o]=t+=1<<e[o-1];let r=new Xd(n[30]);for(let o=1;o<30;++o)for(let s=n[o];s<n[o+1];++s)r[s]=s-n[o]<<5|o;return{b:n,r}},{b:ec}=Qa(Za,2);ec[28]=258;({b:Jd}=Qa(Ja,0)),fi=new Er(32768);for(let e=0;e<32768;++e){let t=(e&43690)>>1|(e&21845)<<1;t=(t&52428)>>2|(t&13107)<<2,t=(t&61680)>>4|(t&3855)<<4,fi[e]=((t&65280)>>8|(t&255)<<8)>>1}zr=(e,t,n)=>{let r=e.length,o=0,s=new Er(t);for(;o<r;++o)e[o]&&++s[e[o]-1];let i=new Er(t);for(o=1;o<t;++o)i[o]=i[o-1]+s[o-1]<<1;let a;if(n){a=new Er(1<<t);let c=15-t;for(o=0;o<r;++o)if(e[o]){let f=o<<4|e[o],l=t-e[o],d=i[e[o]-1]++<<l;for(let u=d|(1<<l)-1;d<=u;++d)a[fi[d]>>c]=f}}else for(a=new Er(r),o=0;o<r;++o)e[o]&&(a[o]=fi[i[e[o]-1]++]>>15-e[o]);return a},Kr=new qt(288);for(let e=0;e<144;++e)Kr[e]=8;for(let e=144;e<256;++e)Kr[e]=9;for(let e=256;e<280;++e)Kr[e]=7;for(let e=280;e<288;++e)Kr[e]=8;tc=new qt(32);for(let e=0;e<32;++e)tc[e]=5;Qd=zr(Kr,9,1),eu=zr(tc,5,1),ai=e=>{let t=e[0];for(let n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Wt=(e,t,n)=>{let r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ci=(e,t)=>{let n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},nc=e=>(e+7)/8|0,tu=(e,t,n)=>((t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))),tn=(e,t)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(t||n[e]||"unknown inflate error")},rc=(e,t,n,r)=>{let o=e.length,s=r?r.length:0;if(!o||t.f&&!t.l)return n||new qt(0);let i=!n,a=i||t.i!=2,c=t.i;i&&(n=new qt(o*3));let f=y=>{let x=n.length;if(y>x){let b=new qt(Math.max(x*2,y));b.set(n),n=b}},l=t.f||0,d=t.p||0,u=t.b||0,m=t.l,h=t.d,p=t.m,g=t.n,w=o*8;do{if(!m){l=Wt(e,d,1);let E=Wt(e,d+1,3);if(d+=3,E)if(E==1)m=Qd,h=eu,p=9,g=5;else if(E==2){let R=Wt(e,d,31)+257,k=Wt(e,d+10,15)+4,C=R+Wt(e,d+5,31)+1;d+=14;let P=new qt(C),T=new qt(19);for(let A=0;A<k;++A)T[Zd[A]]=Wt(e,d+A*3,7);d+=k*3;let D=ai(T),O=(1<<D)-1,N=zr(T,D,1);for(let A=0;A<C;){let _=N[Wt(e,d,O)];d+=_&15;let F=_>>4;if(F<16)P[A++]=F;else{let U=0,L=0;for(F==16?(L=3+Wt(e,d,3),d+=2,U=P[A-1]):F==17?(L=3+Wt(e,d,7),d+=3):F==18&&(L=11+Wt(e,d,127),d+=7);L--;)P[A++]=U}}let H=P.subarray(0,R),S=P.subarray(R);p=ai(H),g=ai(S),m=zr(H,p,1),h=zr(S,g,1)}else tn(1);else{let R=nc(d)+4,k=e[R-4]|e[R-3]<<8,C=R+k;if(C>o){c&&tn(0);break}a&&f(u+k),n.set(e.subarray(R,C),u),t.b=u+=k,t.p=d=C*8,t.f=l;continue}if(d>w){c&&tn(0);break}}a&&f(u+131072);let y=(1<<p)-1,x=(1<<g)-1,b=d;for(;;b=d){let E=m[ci(e,d)&y],R=E>>4;if(d+=E&15,d>w){c&&tn(0);break}if(E||tn(2),R<256)n[u++]=R;else if(R==256){b=d,m=null;break}else{let k=R-254;if(R>264){let O=R-257,N=Za[O];k=Wt(e,d,(1<<N)-1)+ec[O],d+=N}let C=h[ci(e,d)&x],P=C>>4;C||tn(3),d+=C&15;let T=Jd[P];if(P>3){let O=Ja[P];T+=ci(e,d)&(1<<O)-1,d+=O}if(d>w){c&&tn(0);break}a&&f(u+131072);let D=u+k;if(u<T){let O=s-T,N=Math.min(T,D);for(O+u<0&&tn(3);u<N;++u)n[u]=r[O+u]}for(;u<D;++u)n[u]=n[u-T]}}t.l=m,t.p=b,t.b=u,t.f=l,m&&(l=1,t.m=p,t.d=h,t.n=g)}while(!l);return u!=n.length&&i?tu(n,0,u):n.subarray(0,u)},sc=e=>(((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&tn(0,"invalid zlib data"),e[1]&32&&tn(0,"zlib dictionaries are not supported"),2)});async function nu(){let e;if(!(typeof document<"u"))try{e=Is(["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??li}}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:li}}function di(){return ru??=nu()}async function kr(e){return await(await di()).deflateSync(e)}async function Rr(e){return await(await di()).inflateSync(e)}async function ac(e,t){let n=await di(),{result:r,bytesConsumed:o}=n.inflateWithConsumed(e);if(r.byteLength!==t)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${t}`);return{result:r,bytesConsumed:o}}var ru,_s=Re(()=>{"use strict";ic();ru=null});async function pc(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==Fs)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Fs.toString(16)})`);let o=n.getUint32(4);if(o!==hi)throw new Error(`Unsupported pack version: ${o}`);if(e.byteLength>=32){let f=qr(e,e.byteLength-20),l=An();l.update(e.subarray(0,e.byteLength-20));let d=await l.hex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}let s=n.getUint32(8),i=[],a=12;for(let f=0;f<s;f++){let l=await ou(e,a);i.push(l),a=l.nextOffset}return(await iu(i,t)).map((f,l)=>({...f,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function ou(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,i=4;for(;r&128;)r=e[t++],s|=(r&127)<<i,i+=7;let a,c;if(o===Vr){let d=e[t++];for(a=d&127;d&128;)a+=1,d=e[t++],a=(a<<7)+(d&127);a=n-a}else o===pi&&(c=qr(e,t),t+=20);let{result:f,bytesConsumed:l}=await ac(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>cc)throw new Error(`delta chain depth ${i} exceeds limit of ${cc}`);let a=r[s];if(a)return a;let c=e[s];if(c.typeNum!==Vr&&c.typeNum!==pi){let m=su[c.typeNum];if(!m)throw new Error(`Unknown object type: ${c.typeNum}`);let h={type:m,content:c.inflated,hash:await ui(m,c.inflated)};return r[s]=h,h}if(c.typeNum===Vr){let m=n.get(c.baseOffset);if(m===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let h=await o(m,i+1),p=Yr(h.content,c.inflated),g={type:h.type,content:p,hash:await ui(h.type,p)};return r[s]=g,g}let f=await au(e,r,c.baseHash,o),l;if(f!==void 0)l=await o(f,i+1);else if(t){let m=await t(c.baseHash);m&&(l=m)}if(!l)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let d=Yr(l.content,c.inflated),u={type:l.type,content:d,hash:await ui(l.type,d)};return r[s]=u,u}for(let s=0;s<e.length;s++)await o(s);return r}async function au(e,t,n,r){for(let o=0;o<t.length;o++)if(t[o]?.hash===n)return o;for(let o=0;o<e.length;o++){let s=e[o];if(s.typeNum!==Vr&&s.typeNum!==pi&&(await r(o)).hash===n)return o}}function Yr(e,t){let n=0,{value:r,newPos:o}=fc(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:i}=fc(t,n);n=i;let a=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let l=0,d=0;f&1&&(l=t[n++]),f&2&&(l|=t[n++]<<8),f&4&&(l|=t[n++]<<16),f&8&&(l|=t[n++]<<24),f&16&&(d=t[n++]),f&32&&(d|=t[n++]<<8),f&64&&(d|=t[n++]<<16),d===0&&(d=65536),a.set(e.subarray(l,l+d),c),c+=d}else if(f>0)a.set(t.subarray(n,n+f),c),c+=f,n+=f;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==s)throw new Error(`Delta produced ${c} bytes, expected ${s}`);return a}async function gc(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,Fs),r.setUint32(4,hi),r.setUint32(8,e.length),t.push(n);for(let o of e){let s=hc[o.type],i=await kr(o.content);t.push(mi(s,o.content.byteLength)),t.push(i)}return wc(t)}async function Us(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,Fs),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=mi(Vr,a.delta.byteLength),d=cu(s-f),u=await kr(a.delta);t.push(l,d,u),s+=l.byteLength+d.byteLength+u.byteLength}else{let l=hc[a.type],d=mi(l,a.content.byteLength),u=await kr(a.content);t.push(d,u),s+=d.byteLength+u.byteLength}i.push({hash:a.hash,offset:c,nextOffset:s})}return{data:await wc(t),entries:i}}async function wc(e){let t=0;for(let i of e)t+=i.byteLength;t+=20;let n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.byteLength;let o=An();o.update(n.subarray(0,r));let s=await o.hex();return n.set(At(s),r),n}function cu(e){let t=[];t.push(e&127);let n=e>>>7;for(;n>0;)t.unshift(128|--n&127),n>>>=7;return new Uint8Array(t)}function mi(e,t){let n=[],r=e<<4|t&15;for(t>>=4;t>0;)n.push(r|128),r=t&127,t>>=7;return n.push(r),new Uint8Array(n)}function fc(e,t){let n=0,r=0,o;do o=e[t++],n|=(o&127)<<r,r+=7;while(o&128);return{value:n,newPos:t}}async function ui(e,t){let n=fu.encode(`${e} ${t.byteLength}\0`),r=An();return r.update(n),r.update(t),r.hex()}var Fs,hi,lc,dc,uc,mc,Vr,pi,su,hc,cc,fu,xr=Re(()=>{"use strict";ht();er();_s();Fs=1346454347,hi=2,lc=1,dc=2,uc=3,mc=4,Vr=6,pi=7,su={[lc]:"commit",[dc]:"tree",[uc]:"blob",[mc]:"tag"},hc={commit:lc,tree:dc,blob:uc,tag:mc};cc=50;fu=new TextEncoder});async function Ec(e,t){let n=[...e].sort((m,h)=>m.hash<h.hash?-1:m.hash>h.hash?1:0),r=n.length,o=[];for(let m of n)m.offset>=2147483648&&o.push(BigInt(m.offset));let s=8+256*4+r*20+r*4+r*4+o.length*8+20+20,i=new Uint8Array(s),a=new DataView(i.buffer),c=0;a.setUint32(c,bc),c+=4,a.setUint32(c,yc),c+=4;let f=new Uint32Array(256);for(let m of n){let h=parseInt(m.hash.slice(0,2),16);for(let p=h;p<256;p++)f[p]++}for(let m=0;m<256;m++)a.setUint32(c,f[m]),c+=4;for(let m of n)i.set(At(m.hash),c),c+=20;for(let m of n)a.setUint32(c,m.crc),c+=4;let l=0;for(let m of n)m.offset>=2147483648?a.setUint32(c,2147483648|l++):a.setUint32(c,m.offset),c+=4;for(let m of o)a.setBigUint64(c,m),c+=8;i.set(t,c),c+=20;let d=An();d.update(i.subarray(0,c));let u=await d.hex();return i.set(At(u),c),i}async function kc(e){let n=(await pc(e)).map(o=>({hash:o.hash,offset:o.offset,crc:ii(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ec(n,r)}async function Rc(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:ii(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return Ec(n,r)}var bc,yc,zt,Bs=Re(()=>{"use strict";ht();er();Xa();xr();bc=4285812579,yc=2,zt=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==bc)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==yc)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=At(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=At(t.padEnd(40,"0")),i=t.length,a=[];for(let c=r;c<o;c++){let f=c*20,l=!0;for(let d=0;d<i;d++){let u=d%2===0?this.hashes[f+(d>>1)]>>4&15:this.hashes[f+(d>>1)]&15,m=d%2===0?s[d>>1]>>4&15:s[d>>1]&15;if(u!==m){l=!1;break}}l&&a.push(this.hashAtSlot(c))}return a}hashAtSlot(t){let n="",r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o];n+=(s>>4).toString(16)+(s&15).toString(16)}return n}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],i=n[o];if(s<i)return-1;if(s>i)return 1}return 0}getOffset(t){let n=this.offsets[t];if(n&2147483648){let r=n&2147483647;return Number(this.largeOffsets.getBigUint64(r*8))}return n}}});var lu,du,uu,xc,Xr,Cc=Re(()=>{"use strict";ht();Bs();xr();_s();lu=6,du=7,uu={1:"commit",2:"tree",3:"blob",4:"tag"},xc=50,Xr=class{constructor(t,n){this.data=t;this.index=n instanceof zt?n:new zt(n)}index;hasObject(t){return this.index.has(t)}findByPrefix(t){return this.index.findByPrefix(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n,0)}get objectCount(){return this.index.objectCount}async readAt(t,n){if(n>xc)throw new Error(`delta chain depth ${n} exceeds limit of ${xc}`);let r=this.data,o=t,s=r[o++],i=s>>4&7,a=s&15,c=4;for(;s&128;)s=r[o++],a|=(s&127)<<c,c+=7;if(i===lu){let d=r[o++],u=d&127;for(;d&128;)u+=1,d=r[o++],u=(u<<7)+(d&127);let m=await Rr(r.subarray(o)),h=await this.readAt(t-u,n+1);return{type:h.type,content:Yr(h.content,m)}}if(i===du){let d=qr(r,o);o+=20;let u=await Rr(r.subarray(o)),m=this.index.lookup(d);if(m===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let h=await this.readAt(m,n+1);return{type:h.type,content:Yr(h.content,u)}}let f=uu[i];if(!f)throw new Error(`Unknown pack object type: ${i}`);let l=await Rr(r.subarray(o));if(l.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${l.byteLength}, expected ${a}`);return{type:f,content:l}}}});function wi(e,t){let n=mu.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function pu(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=hu.decode(t.subarray(0,n)),o=r.indexOf(" ");if(o===-1)throw new Error(`Corrupt object ${e}: malformed header "${r}"`);let s=r.slice(0,o),i=parseInt(r.slice(o+1),10),a=t.subarray(n+1);if(a.byteLength!==i)throw new Error(`Corrupt object ${e}: expected ${i} bytes, got ${a.byteLength}`);return{type:s,content:a}}function gi(e,t){return v(e,"objects",t.slice(0,2),t.slice(2))}var mu,hu,Cr,bi=Re(()=>{"use strict";ht();Va();Bs();Cc();xr();_s();me();er();mu=new TextEncoder,hu=new TextDecoder;Cr=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.cache=new Ns(r),this.packDir=v(n,"objects","pack")}packs=[];loadedPackNames=new Set;discoverPromise=null;cache;packDir;async write(t,n){let r=wi(t,n),o=await Hn(r),s=gi(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 kr(r)),o}async read(t){let n=this.cache.get(t);if(n)return n;let r=gi(this.gitDir,t);if(await this.fs.exists(r)){let o=await this.fs.readFileBuffer(r),s=await Rr(o),i=await Hn(s);if(i!==t)throw new Error(`corrupt loose object ${t}: SHA-1 mismatch (computed ${i})`);let a=pu(t,s);return this.cache.set(t,a),a}await this.discover();for(let o of this.packs){if(!o.index.has(t))continue;let i=await(await this.ensureReader(o)).readObject(t);if(i)return this.cache.set(t,i),i}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(gi(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.index.has(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let o=n.getUint32(4);if(o!==2)throw new Error(`unsupported pack version: ${o}`);let s=n.getUint32(8);if(s===0)return 0;let i=t.subarray(t.byteLength-20),a=vn(i),c=await Hn(t.subarray(0,t.byteLength-20));if(c!==a)throw new Error(`pack checksum mismatch: expected ${a}, computed ${c}`);await this.fs.mkdir(this.packDir,{recursive:!0});let f=`pack-${a}`,l=v(this.packDir,`${f}.pack`);await this.fs.writeFile(l,t);let d=await kc(t),u=v(this.packDir,`${f}.idx`);await this.fs.writeFile(u,d),this.loadedPackNames.add(f);let m=new zt(d);return this.packs.push({name:f,index:m,reader:new Xr(t,m)}),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=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 Xr(r,t.index),t.reader}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){if(!await this.fs.exists(this.packDir))return;let t=await this.fs.readdir(this.packDir);for(let n of t){if(!n.endsWith(".idx"))continue;let r=n.slice(0,-4);if(this.loadedPackNames.has(r))continue;let o=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 zt(s),reader:null})}}}});function Zr(e){let t=e.indexOf("<"),n=e.indexOf(">");if(t===-1||n===-1)throw new Error(`Malformed identity line: "${e}"`);let r=e.slice(0,t).trimEnd(),o=e.slice(t+1,n),s=e.slice(n+2),[i="0",a="+0000"]=s.split(" "),c=parseInt(i,10);return{name:r,email:o,timestamp:c,timezone:a}}function Jr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var yi=Re(()=>{"use strict"});function nn(e){let t=wu.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=Xr(u);break;case"committer":c=Xr(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 rn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Zr(e.author)}`),t.push(`committer ${Zr(e.committer)}`),t.push(""),t.push(e.message),pu.encode(t.join(`
25
- `))}var pu,gu,gn=Re(()=>{"use strict";wi();pu=new TextEncoder,gu=new TextDecoder});function Kt(e){let t=bu.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=Zr(u);break;case"committer":c=Zr(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 rn(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Jr(e.author)}`),t.push(`committer ${Jr(e.committer)}`),t.push(""),t.push(e.message),gu.encode(t.join(`
25
+ `))}var gu,wu,gn=Re(()=>{"use strict";yi();gu=new TextEncoder,wu=new TextDecoder});function Kt(e){let t=yu.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=Xr(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 Cc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Zr(e.tagger)}`),t.push(""),t.push(e.message),wu.encode(t.join(`
29
- `))}var wu,bu,Cr=Re(()=>{"use strict";wi();wu=new TextEncoder,bu=new TextDecoder});async function pt(e,t){return Hn(pi(e,t))}async function He(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function be(e,t){return e.objectStore.read(t)}async function Vt(e,t){return e.objectStore.exists(t)}async function Bs(e,t){return e.objectStore.ingestPack(t)}async function Pc(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function Dn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function se(e,t){let n=await be(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return yu.decode(n.content)}async function Pt(e,t){let n=await be(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 be(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return nn(n.content)}async function $c(e,t){let n=await be(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Kt(n.content)}async function ve(e,t){let n=t;for(let r=0;r<100;r++){let o=await be(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Kt(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 yu,ae=Re(()=>{"use strict";gi();gn();Cr();er();yu=new TextDecoder});function Oc(e){return typeof e=="string"?{type:"direct",hash:e}:e}var Jr,bi=Re(()=>{"use strict";Jr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function ku(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?Eu[a]:0){case 1:break;case 2:if(r===46)return{len:-1,starConsumed:o};r=a;continue;case 3:if(r===64)return{len:-1,starConsumed:o};r=a;continue;case 4:return{len:-1,starConsumed:o};case 5:if(!n)return{len:-1,starConsumed:o};o=!0,r=a;continue;default:r=a;continue}break}let i=s-t;return i===0?{len:0,starConsumed:o}:e.charCodeAt(t)===46?{len:-1,starConsumed:o}:i>=yi.length&&e.slice(s-yi.length,s)===yi?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function Qr(e,t=0){if(e==="@"||e.length===0)return!1;let n=0,r=0,o=!!(t&2);for(;n<=e.length;){let{len:s,starConsumed:i}=ku(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 wn(e){return!e||e.startsWith("-")?!1:Qr(`refs/heads/${e}`,0)}function Ic(e){return e?Qr(`refs/tags/${e}`,0):!1}async function Tc(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Sc;r++){let o=await Tc(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 Tc(e,"HEAD")}async function Y(e){return B(e,"HEAD")}async function Z(e,t,n){let r=e.hooks?await B(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function Xe(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function he(e,t){let n=e.hooks?await B(e,t):null;await e.refStore.deleteRef(t),await ts(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function pe(e,t="refs"){return e.refStore.listRefs(t)}function Pe(e){return e.replace("refs/heads/","")}async function jn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await Z(e,n.target,t):await Z(e,"HEAD",t)}async function vc(e){if(e.refStore&&!(e.refStore instanceof Mn))return;let t=await pe(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await be(e,o.hash);if(s.type==="tag"){let i=Kt(s.content).object;for(let a=0;a<100;a++){let c=await be(e,i);if(c.type!=="tag")break;i=Kt(c.content).object}n.push(`^${i}`)}}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=Zr(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 Pc(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Jr(e.tagger)}`),t.push(""),t.push(e.message),bu.encode(t.join(`
29
+ `))}var bu,yu,Pr=Re(()=>{"use strict";yi();bu=new TextEncoder,yu=new TextDecoder});async function pt(e,t){return Hn(wi(e,t))}async function He(e,t,n){let r=await e.objectStore.write(t,n);return e.hooks?.onObjectWrite?.({repo:e,type:t,hash:r}),r}async function be(e,t){return e.objectStore.read(t)}async function Vt(e,t){return e.objectStore.exists(t)}async function Ws(e,t){return e.objectStore.ingestPack(t)}async function $c(e,t){return e.objectStore.findByPrefix(t)}function Te(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e.charCodeAt(n)===0)return!0;return!1}function Dn(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}async function se(e,t){let n=await be(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Eu.decode(n.content)}async function Pt(e,t){let n=await be(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 be(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return nn(n.content)}async function Oc(e,t){let n=await be(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Kt(n.content)}async function ve(e,t){let n=t;for(let r=0;r<100;r++){let o=await be(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Kt(o.content).object;continue}throw new Error(`Cannot peel ${o.type} object ${t} to commit`)}throw new Error(`Tag chain too deep for ${t}`)}var Eu,ae=Re(()=>{"use strict";bi();gn();Pr();er();Eu=new TextDecoder});function Ic(e){return typeof e=="string"?{type:"direct",hash:e}:e}var Qr,Ei=Re(()=>{"use strict";Qr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});function Ru(e,t,n){let r=0,o=!1,s=t;for(;s<e.length;s++){let a=e.charCodeAt(s);switch(a<128?ku[a]:0){case 1:break;case 2:if(r===46)return{len:-1,starConsumed:o};r=a;continue;case 3:if(r===64)return{len:-1,starConsumed:o};r=a;continue;case 4:return{len:-1,starConsumed:o};case 5:if(!n)return{len:-1,starConsumed:o};o=!0,r=a;continue;default:r=a;continue}break}let i=s-t;return i===0?{len:0,starConsumed:o}:e.charCodeAt(t)===46?{len:-1,starConsumed:o}:i>=ki.length&&e.slice(s-ki.length,s)===ki?{len:-1,starConsumed:o}:{len:i,starConsumed:o}}function es(e,t=0){if(e==="@"||e.length===0)return!1;let n=0,r=0,o=!!(t&2);for(;n<=e.length;){let{len:s,starConsumed:i}=Ru(e,n,o);if(s<0||s===0)return!1;i&&(o=!1),r++,n+=s+1}return!(e.charCodeAt(e.length-1)===46||!(t&1)&&r<2)}function wn(e){return!e||e.startsWith("-")?!1:es(`refs/heads/${e}`,0)}function Sc(e){return e?es(`refs/tags/${e}`,0):!1}async function vc(e,t){return e.refStore.readRef(t)}async function B(e,t){let n=t;for(let r=0;r<Tc;r++){let o=await vc(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 vc(e,"HEAD")}async function Y(e){return B(e,"HEAD")}async function Z(e,t,n){let r=e.hooks?await B(e,t):null;await e.refStore.writeRef(t,{type:"direct",hash:n}),e.hooks?.onRefUpdate?.({repo:e,ref:t,oldHash:r,newHash:n})}async function Xe(e,t,n){await e.refStore.writeRef(t,{type:"symbolic",target:n})}async function he(e,t){let n=e.hooks?await B(e,t):null;await e.refStore.deleteRef(t),await ns(e,t),e.hooks&&n&&e.hooks.onRefDelete?.({repo:e,ref:t,oldHash:n})}async function pe(e,t="refs"){return e.refStore.listRefs(t)}function Pe(e){return e.replace("refs/heads/","")}async function jn(e,t){let n=await Q(e);n&&n.type==="symbolic"?await Z(e,n.target,t):await Z(e,"HEAD",t)}async function Ac(e){if(e.refStore&&!(e.refStore instanceof Mn))return;let t=await pe(e,"refs");if(t.length===0)return;let n=["# pack-refs with: peeled fully-peeled sorted"];for(let o of t)if(n.push(`${o.hash} ${o.name}`),o.name.startsWith("refs/tags/"))try{let s=await be(e,o.hash);if(s.type==="tag"){let i=Kt(s.content).object;for(let a=0;a<100;a++){let c=await be(e,i);if(c.type!=="tag")break;i=Kt(c.content).object}n.push(`^${i}`)}}catch{}await e.fs.writeFile(v(e.gitDir,"packed-refs"),`${n.join(`
30
30
  `)}
31
- `);for(let o of t){let s=v(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Ac(e,v(e.gitDir,"refs"));let r=v(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(v(r,"heads"),{recursive:!0}),await e.fs.mkdir(v(r,"tags"),{recursive:!0})}async function Ac(e,t){if(e.refStore&&!(e.refStore instanceof Mn)||!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await Ac(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var yi,Eu,Ei,Sc,Mn,ge=Re(()=>{"use strict";ae();Cr();me();ze();Gn();bi();yi=".lock",Eu=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];Ei="ref: ",Sc=10,Mn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=v(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Ei)?{type:"symbolic",target:s.slice(Ei.length)}:{type:"direct",hash:s}}let o=(await this.readPackedRefs()).get(t);return o?{type:"direct",hash:o}:null}async writeRef(t,n){let r=Oc(n),o=v(this.gitDir,t);await es(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Ei}${r.target}
31
+ `);for(let o of t){let s=v(e.gitDir,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Hc(e,v(e.gitDir,"refs"));let r=v(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(v(r,"heads"),{recursive:!0}),await e.fs.mkdir(v(r,"tags"),{recursive:!0})}async function Hc(e,t){if(e.refStore&&!(e.refStore instanceof Mn)||!await e.fs.exists(t)||!(await e.fs.stat(t)).isDirectory)return;let r=await e.fs.readdir(t);for(let s of r)await Hc(e,v(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}var ki,ku,Ri,Tc,Mn,ge=Re(()=>{"use strict";ae();Pr();me();ze();Gn();Ei();ki=".lock",ku=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];Ri="ref: ",Tc=10,Mn=class{constructor(t,n){this.fs=t;this.gitDir=n}casLocks=new Map;async readRef(t){let n=v(this.gitDir,t);if(await this.fs.exists(n)){let s=(await this.fs.readFile(n)).trim();return s.startsWith(Ri)?{type:"symbolic",target:s.slice(Ri.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=Ic(n),o=v(this.gitDir,t);await ts(this.fs,o),r.type==="symbolic"?await this.fs.writeFile(o,`${Ri}${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<Sc;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=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(`
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<Tc;r++){let o=await this.readRef(n);if(!o)return null;if(o.type==="direct")return o.hash;n=o.target}throw new Error(`Symbolic ref loop detected resolving "${t}"`)}async readPackedRefs(){let t=v(this.gitDir,"packed-refs");if(!await this.fs.exists(t))return new Map;let n=await this.fs.readFile(t),r=new Map;for(let o of n.split(`
34
34
  `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let i=o.slice(0,s),a=o.slice(s+1).trim();i.length===40&&a&&r.set(a,i)}return r}async removePackedRef(t){let n=v(this.gitDir,"packed-refs");if(!await this.fs.exists(n))return;let o=(await this.fs.readFile(n)).split(`
35
35
  `),s=[],i=!1;for(let c of o){if(i&&c.startsWith("^")){i=!1;continue}if(i=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){i=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await this.fs.writeFile(n,s.join(`
36
- `)):await this.fs.rm(n)}async walkRefs(t,n,r){let o=await this.fs.readdir(t);for(let s of o){let i=v(t,s),a=`${n}/${s}`,c=await this.fs.stat(i);if(c.isDirectory)await this.walkRefs(i,a,r);else if(c.isFile){let f=await this.resolveRefInternal(a);f&&r.push({name:a,hash:f})}}}}});async function tr(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 xr(e,r),refStore:new Mn(e,r)};if(await Ru(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new xr(e,n),refStore:new Mn(e,n)};let o=xu(n);if(o===n)return null;n=o}}async function Ru(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 Ws(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 xr(e,s),refStore:new Mn(e,s)};if(!c){await Xe(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(v(s,"config"),Jo(l))}return{ctx:f,reinit:c}}async function es(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function xu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Gn=Re(()=>{"use strict";qe();gi();me();ge()});function qs(e,t){return v(e.gitDir,"logs",t)}function Cu(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),l=n.slice(a+1,c),d=n.slice(c+2),u=d.indexOf(" ");if(u<0)return null;let m=parseInt(d.slice(0,u),10),h=d.slice(u+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:m,tz:h,message:r}}async function et(e,t){let n=qs(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=Cu(s);i&&o.push(i)}return o}function Hc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Ln(e,t,n){let r=qs(e,t);if(await es(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Hc).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 tr(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 Cr(e,r),refStore:new Mn(e,r)};if(await xu(e,n))return{fs:e,gitDir:n,workTree:null,objectStore:new Cr(e,n),refStore:new Mn(e,n)};let o=Cu(n);if(o===n)return null;n=o}}async function xu(e,t){let n=v(t,"HEAD");if(!await e.exists(n))return!1;try{if(!(await e.stat(n)).isFile)return!1}catch{return!1}for(let r of["objects","refs"]){let o=v(t,r);if(!await e.exists(o))return!1;try{if(!(await e.stat(o)).isDirectory)return!1}catch{return!1}}return!0}async function qs(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:v(t,".git"),i=r?null:t,a=v(s,"HEAD"),c=await e.exists(a);await e.mkdir(v(s,"objects"),{recursive:!0}),await e.mkdir(v(s,"refs","heads"),{recursive:!0}),await e.mkdir(v(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:i,objectStore:new Cr(e,s),refStore:new Mn(e,s)};if(!c){await Xe(f,"HEAD",`refs/heads/${o}`);let l={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(v(s,"config"),ei(l))}return{ctx:f,reinit:c}}async function ts(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Cu(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Gn=Re(()=>{"use strict";qe();bi();me();ge()});function zs(e,t){return v(e.gitDir,"logs",t)}function Pu(e){let t=e.indexOf(" ");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),o=n.split(" ");if(o.length<5)return null;let s=o[0],i=o[1];if(!s||!i)return null;let a=n.indexOf("<"),c=n.indexOf(">",a);if(a<0||c<0)return null;let f=n.slice(s.length+1+i.length+1,a).trim(),l=n.slice(a+1,c),d=n.slice(c+2),u=d.indexOf(" ");if(u<0)return null;let m=parseInt(d.slice(0,u),10),h=d.slice(u+1);return{oldHash:s,newHash:i,name:f,email:l,timestamp:m,tz:h,message:r}}async function et(e,t){let n=zs(e,t);if(!await e.fs.exists(n))return[];let r=await e.fs.readFile(n);if(!r.trim())return[];let o=[];for(let s of r.split(`
37
+ `)){if(!s)continue;let i=Pu(s);i&&o.push(i)}return o}function Dc(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Ln(e,t,n){let r=zs(e,t);if(await ts(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(Dc).join(`
38
38
  `)}
39
- `;await e.fs.writeFile(r,o)}async function Ze(e,t,n){let r=qs(e,t);await es(e.fs,r);let o=`${Hc(n)}
40
- `;if(await e.fs.exists(r)){let s=await e.fs.readFile(r);await e.fs.writeFile(r,s+o)}else await e.fs.writeFile(r,o)}async function ts(e,t){let n=qs(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ce(e,t,n,r,o,s,i=!1){let a=await en(e,t),c={oldHash:r??ee,newHash:o,...a,message:s};await Ze(e,n,c),i&&n!=="HEAD"&&await Ze(e,"HEAD",c)}var ze=Re(()=>{"use strict";ht();Tn();me();Gn();ht()});function Pu(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let c=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:c}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^{([^}]*)}$/);if(i&&i[1]!==void 0&&i[2]!==void 0){t.unshift({type:"peel",target:i[2]}),n=i[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let c=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:c}),n=a[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function $u(e,t){let n=await Pc(e,t);if(n.length===0)return null;if(n.length>1)throw new ki(t);return n[0]}async function Ou(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Dc.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Vt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await $u(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await B(e,t);if(s)return s}let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);if(r)return r;let o=await B(e,`refs/remotes/${t}`);return o||null}function Iu(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Dc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Su(e,t,n){let r=Iu(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 Tu(e,t,n){if(n===""||n==="commit")try{return await ve(e,t)}catch{return null}if(n==="tree"){let o;try{o=await ve(e,t)}catch{return null}return(await j(e,o)).tree}return(await be(e,t)).type!==n?null:t}async function vu(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await ve(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await Tu(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 Be(e,t){let{base:n,reflogIndex:r,suffixes:o}=Pu(t),s;return r!==void 0?s=await Su(e,n,r):s=await Ou(e,n),s?vu(e,s,o):null}function zs(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Dc,ki,sn=Re(()=>{"use strict";ae();ze();ge();Dc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];ki=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function mt(e,t){return e.lstat?e.lstat(t):e.stat(t)}function bn(e){return typeof e=="string"?e==="120000":e===40960}async function ns(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Au.encode(r)}return e.readFileBuffer(t)}async function Nn(e,t){let n=await ns(e,t);return pt("blob",n)}var Au,nr=Re(()=>{"use strict";ae();Au=new TextEncoder});function Mu(e){return e.length===4&&e.toLowerCase()===".git"}function ju(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(Mu(e))throw new Error(`invalid tree entry: '${e}'`);if(!Du.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function _n(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Mc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=Mc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=vn(a),f=o.padStart(6,"0");ju(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=Hu.encode(`${i} ${s.name}\0`),c=At(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 Hu,Mc,Du,Ks=Re(()=>{"use strict";ht();Hu=new TextEncoder,Mc=new TextDecoder,Du=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Gc(e,t,"")}async function Gc(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:Gu(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 Gc(e,a,c);r.push({mode:Jr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Jr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Jr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=jc({type:"tree",entries:r});return He(e,"tree",s)}async function Ke(e,t,n=""){let r=await be(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=_n(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Jr.DIRECTORY){let c=await Ke(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function fe(e,t){if(!t)return new Map;let n=await Ke(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){let r=await fe(e,t),o=await fe(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Ie(i.path,a.path))}function Gu(e){return e.toString(8).padStart(6,"0")}var Ae=Re(()=>{"use strict";oe();ae();Ks();bi()});function Lc(e){return/^[a-zA-Z0-9]$/.test(e)}function Lu(e){return/^[a-zA-Z]$/.test(e)}function Nu(e){return e>="0"&&e<="9"}function Ri(e){return e>="A"&&e<="Z"}function xi(e){return e>="a"&&e<="z"}function Nc(e){return/^\s$/.test(e)}function _u(e){return e===" "||e===" "}function Pi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Fu(e){return Pi(e)&&!Nc(e)}function Uu(e){return Pi(e)&&!Lc(e)&&e!==" "}function Bu(e){let t=e.charCodeAt(0);return t<32||t===127}function Wu(e){return/^[0-9a-fA-F]$/.test(e)}function rs(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Ci(e,t,n,r,o){let s=(o&1)!==0,i=(o&2)!==0;for(;t<e.length;){let a=e[t];if(r>=n.length&&a!=="*")return-1;let c=r<n.length?n[r]:"";switch(a){case"\\":{if(t++,t>=e.length)return-1;if(!rs(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(i&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let l=t;for(;t<e.length&&e[t]==="*";)t++;if(!i)f=!0;else if((l-1<1||e[l-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&Ci(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!i;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let l=n.indexOf("/",r);if(l===-1)return-1;r=l+1,t++;break}for(;!(r>=n.length);){if(!qu(e[t])){let d=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==d;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let l=Ci(e,t,n,r,o);if(l!==1){if(!f||l!==-2)return l}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let l=!1,d="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],rs(c,m,s)&&(l=!0)}else if(m==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,m=e[t],m==="\\"){if(t++,t>=e.length)return-1;m=e[t]}let h=d,p=m;if(c>=h&&c<=p&&(l=!0),s){if(xi(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(Ri(c)){let g=c.toLowerCase();g>=h&&g<=p&&(l=!0)}}m=""}else if(m==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let h=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-h-1;if(p<0||e[t-1]!==":")t=h-2,m="[",rs(c,m,s)&&(l=!0);else{let g=e.slice(h,h+p);zu(g,c,s)&&(l=!0),m=""}}else rs(c,m,s)&&(l=!0);d=m,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!rs(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function qu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function zu(e,t,n){switch(e){case"alnum":return Lc(t);case"alpha":return Lu(t);case"blank":return _u(t);case"cntrl":return Bu(t);case"digit":return Nu(t);case"graph":return Fu(t);case"lower":return xi(t)||n&&Ri(t);case"print":return Pi(t);case"punct":return Uu(t);case"space":return Nc(t);case"upper":return Ri(t)||n&&xi(t);case"xdigit":return Wu(t);default:return!1}}function on(e,t,n=0){return Ci(e,0,t,0,n)===0?0:1}var ss=Re(()=>{"use strict"});function Bc(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 Ku(e){return Bc(e)===e.length}function Vu(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=Vs,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Uc);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=_c);let a=Math.min(Bc(o),s);return o[0]==="*"&&Ku(o.slice(1))&&(r|=Fc),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function os(e,t,n){let r=[];for(let o of e.split(`
41
- `)){let s=Vu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function Yu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Fc){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return on(n,e,2)===0}function Xu(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 on(r,a,2)===0}function $i(e,t,n){let r=e.lastIndexOf("/")>=0?e.slice(e.lastIndexOf("/")+1):e;for(let o=n.patterns.length-1;o>=0;o--){let s=n.patterns[o];if(s&&!(s.flags&Uc&&!t)){if(s.flags&_c){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(Yu(r,s))return s;continue}if(Xu(e,s))return s}}return null}function an(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=$i(t,n,o);if(s)return s.flags&Vs?"not-ignored":"ignored"}if(e.excludeFile){let r=$i(t,n,e.excludeFile);if(r)return r.flags&Vs?"not-ignored":"ignored"}if(e.globalExclude){let r=$i(t,n,e.globalExclude);if(r)return r.flags&Vs?"not-ignored":"ignored"}return"undecided"}async function Pr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=os(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=os(o,"",r)}catch{}}catch{}return t}function rr(e,t,n,r){let s=os(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var _c,Fc,Uc,Vs,Xs=Re(()=>{"use strict";qe();me();ss();_c=1,Fc=4,Uc=8,Vs=16});async function gt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=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 Nn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await ot(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ie(s.path,i.path))}async function dt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!Qn(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);let n=await be(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(!Ds(e.workTree,r))throw new Error(`refusing to check out path outside worktree: '${t.path}'`);let o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&bn(t.mode)&&e.fs.symlink){let s=Ju.decode(n.content);if(!Ba(s))throw new Error(`refusing to create symlink with unsafe target '${s}'`);await mt(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0}),await e.fs.symlink(s,r)}else{if(e.fs.lstat)try{(await e.fs.lstat(r)).isSymbolicLink&&await e.fs.rm(r,{force:!0})}catch{}await e.fs.writeFile(r,n.content)}}async function Wc(e,t){let n=await Ke(e,t);for(let r of n)await dt(e,r)}async function cn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!Qn(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=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=Zu.encode(f),d=await He(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...Se(),size:l.byteLength}};return{index:Ct(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await He(e,"blob",s),a=o.mode!=null?Qu(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Se(),size:s.byteLength}};return{index:Ct(t,c),hash:i}}async function ot(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await Pr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=rr(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=v(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&an(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&an(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&&an(s,l,!1)==="ignored")continue;i.push(l)}}return i}function Qu(e){return e>511?e:e&73?33261:33188}async function sr(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await sr(e,Qt(t),n))}var Zu,Ju,tt=Re(()=>{"use strict";oe();Xs();Ce();ae();Ms();me();nr();Ae();Zu=new TextEncoder,Ju=new TextDecoder});function Oi(e){return e.existsOnDisk&&e.indexHash===null}async function em(e,t,n){let r=await Promise.all(t.map(h=>fe(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await ot(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await ot(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of d){let p=null,g=null,w=null,y=null,x=null;if(r.length===1){let O=u(0,h);w=O?.hash??null,x=O?.mode??null}else if(r.length===2){let O=u(0,h),N=u(1,h);g=O?.hash??null,y=O?.mode??null,w=N?.hash??null,x=N?.mode??null}else if(r.length>=3){let O=u(0,h),N=u(1,h),H=u(2,h);p=O?.hash??null,g=N?.hash??null,y=N?.mode??null,w=H?.hash??null,x=H?.mode??null}let E=o.get(h)?.hash??null,R=s.has(h)?1:0,k=i.has(h),C,P=async()=>C!==void 0?C:k?(C=!(await c()).has(h),C):(C=!1,!1),T,D=async()=>{if(T!==void 0)return T;if(!k||!e.workTree)return T=null,null;let O=v(e.workTree,h);try{T=await Nn(e.fs,O)}catch{T=null}return T};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:E,indexStage:R,existsOnDisk:k,isIgnoredOnDisk:P,getWorktreeHash:D,headMode:y,remoteMode:x})}return m}function Zs(e,t){let n=e.remoteHash;return n===null?e.indexHash===null&&e.indexStage===0?{action:"SKIP",requirements:[]}:{action:"DELETE",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}:e.indexHash===n?{action:"KEEP",requirements:[]}:e.indexHash===null?{action:"TAKE",takeFrom:"remote",requirements:t.reset||!!t.strippedConflictPaths?.has(e.path)?[]:["NO_UNTRACKED"]}:{action:"TAKE",takeFrom:"remote",requirements:t.reset?[]:["WORKTREE_MUST_BE_UPTODATE"]}}function Js(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function tm(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 nm(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=tm(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await rm(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function rm(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Oi(t)?"WOULD_LOSE_UNTRACKED_REMOVED":null;case"INDEX_MUST_MATCH_HEAD":return t.indexHash!==t.headHash?"WOULD_OVERWRITE":null;case"INDEX_MUST_MATCH_RESULT":return t.indexHash!==null&&t.indexHash!==n?"WOULD_OVERWRITE":null;case"WORKTREE_MUST_BE_UPTODATE":{if(!t.existsOnDisk)return null;let o=await t.getWorktreeHash();return o!==t.indexHash?r?.allowContentEscapeHatch&&(n!==null&&o===n||o===null&&n===null)?null:"NOT_UPTODATE_FILE":null}case"NO_UNTRACKED":return Oi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Oi(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function sm(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:d,stage:0,stat:Se()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:m});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Ie(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Qs(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of om){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 Ze(e,t,n){let r=zs(e,t);await ts(e.fs,r);let o=`${Dc(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 ns(e,t){let n=zs(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ce(e,t,n,r,o,s,i=!1){let a=await en(e,t),c={oldHash:r??ee,newHash:o,...a,message:s};await Ze(e,n,c),i&&n!=="HEAD"&&await Ze(e,"HEAD",c)}var ze=Re(()=>{"use strict";ht();Tn();me();Gn();ht()});function $u(e){let t=[],n=e.length;for(;n>0;){let s=e.slice(0,n).match(/^(.+?)~(\d*)$/);if(s&&s[1]!==void 0&&s[2]!==void 0){let c=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:c}),n=s[1].length;continue}let i=e.slice(0,n).match(/^(.+?)\^{([^}]*)}$/);if(i&&i[1]!==void 0&&i[2]!==void 0){t.unshift({type:"peel",target:i[2]}),n=i[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let c=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:c}),n=a[1].length;continue}break}let r=e.slice(0,n),o=r.match(/^(.+?)@\{(\d+)\}$/);return o&&o[1]!==void 0&&o[2]!==void 0?{base:o[1],reflogIndex:parseInt(o[2],10),suffixes:t}:{base:r,suffixes:t}}async function Ou(e,t){let n=await $c(e,t);if(n.length===0)return null;if(n.length>1)throw new xi(t);return n[0]}async function Iu(e,t){if(t==="HEAD"||t==="@")return B(e,"HEAD");if(Mc.includes(t))return B(e,t);if(/^[0-9a-f]{40}$/.test(t))return await Vt(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Ou(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await B(e,t);if(s)return s}let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);if(r)return r;let o=await B(e,`refs/remotes/${t}`);return o||null}function Su(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Mc)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Tu(e,t,n){let r=Su(t),o=await et(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let i=o[s];return i?i.newHash:null}async function vu(e,t,n){if(n===""||n==="commit")try{return await ve(e,t)}catch{return null}if(n==="tree"){let o;try{o=await ve(e,t)}catch{return null}return(await j(e,o)).tree}return(await be(e,t)).type!==n?null:t}async function Au(e,t,n){let r=t;n.some(s=>s.type==="tilde"||s.type==="caret")&&(r=await ve(e,r));for(let s of n)if(s.type==="peel"){if(!r)return null;r=await vu(e,r,s.target)}else if(s.type==="tilde")for(let i=0;i<s.n;i++){if(!r)return null;let a=await j(e,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(s.n===0)continue;if(!r)return null;let i=await j(e,r);if(s.n>i.parents.length||(r=i.parents[s.n-1]??null,!r))return null}return r}async function Be(e,t){let{base:n,reflogIndex:r,suffixes:o}=$u(t),s;return r!==void 0?s=await Tu(e,n,r):s=await Iu(e,n),s?Au(e,s,o):null}function Ks(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var Mc,xi,sn=Re(()=>{"use strict";ae();ze();ge();Mc=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];xi=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 bn(e){return typeof e=="string"?e==="120000":e===40960}async function rs(e,t){if((await mt(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Hu.encode(r)}return e.readFileBuffer(t)}async function Nn(e,t){let n=await rs(e,t);return pt("blob",n)}var Hu,nr=Re(()=>{"use strict";ae();Hu=new TextEncoder});function ju(e){return e.length===4&&e.toLowerCase()===".git"}function Gu(e,t){if(e.length===0)throw new Error("invalid tree entry: empty name");if(e.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${e}'`);if(e.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(e==="."||e==="..")throw new Error(`invalid tree entry: '${e}'`);if(ju(e))throw new Error(`invalid tree entry: '${e}'`);if(!Mu.has(t))throw new Error(`invalid tree entry mode: '${t}' for '${e}'`)}function _n(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=jc.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let i=jc.decode(e.subarray(r+1,s)),a=e.subarray(s+1,s+21),c=vn(a),f=o.padStart(6,"0");Gu(i,f),t.push({mode:f,name:i,hash:c}),n=s+21}return{type:"tree",entries:t}}function Gc(e){let t=[];for(let s of e.entries){let i=s.mode.replace(/^0+/,""),a=Du.encode(`${i} ${s.name}\0`),c=At(s.hash);t.push(a),t.push(c)}let n=t.reduce((s,i)=>s+i.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Du,jc,Mu,Vs=Re(()=>{"use strict";ht();Du=new TextEncoder,jc=new TextDecoder,Mu=new Set(["100644","100755","040000","120000","160000"])});async function Fe(e,t){return Lc(e,t,"")}async function Lc(e,t,n){let r=[],o=new Map;for(let i of t){let a=n?i.path.slice(n.length+1):i.path,c=a.indexOf("/");if(c===-1)r.push({mode:Lu(i.mode),name:a,hash:i.hash});else{let f=a.slice(0,c),l=o.get(f);l||(l=[],o.set(f,l)),l.push(i)}}for(let[i,a]of o){let c=n?`${n}/${i}`:i,f=await Lc(e,a,c);r.push({mode:Qr.DIRECTORY,name:i,hash:f})}r.sort((i,a)=>{let c=i.mode===Qr.DIRECTORY?`${i.name}/`:i.name,f=a.mode===Qr.DIRECTORY?`${a.name}/`:a.name;return c<f?-1:c>f?1:0});let s=Gc({type:"tree",entries:r});return He(e,"tree",s)}async function Ke(e,t,n=""){let r=await be(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=_n(r.content),s=[];for(let i of o.entries){let a=n?`${n}/${i.name}`:i.name;if(i.mode===Qr.DIRECTORY){let c=await Ke(e,i.hash,a);s.push(...c)}else s.push({path:a,mode:i.mode,hash:i.hash})}return s}async function fe(e,t){if(!t)return new Map;let n=await Ke(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ve(e,t,n){let r=await fe(e,t),o=await fe(e,n),s=[];for(let[i,a]of r){let c=o.get(i);c?(a.hash!==c.hash||a.mode!==c.mode)&&s.push({path:i,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):s.push({path:i,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[i,a]of o)r.has(i)||s.push({path:i,status:"added",newHash:a.hash,newMode:a.mode});return s.sort((i,a)=>Ie(i.path,a.path))}function Lu(e){return e.toString(8).padStart(6,"0")}var Ae=Re(()=>{"use strict";oe();ae();Vs();Ei()});function Nc(e){return/^[a-zA-Z0-9]$/.test(e)}function Nu(e){return/^[a-zA-Z]$/.test(e)}function _u(e){return e>="0"&&e<="9"}function Ci(e){return e>="A"&&e<="Z"}function Pi(e){return e>="a"&&e<="z"}function _c(e){return/^\s$/.test(e)}function Fu(e){return e===" "||e===" "}function Oi(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Uu(e){return Oi(e)&&!_c(e)}function Bu(e){return Oi(e)&&!Nc(e)&&e!==" "}function Wu(e){let t=e.charCodeAt(0);return t<32||t===127}function qu(e){return/^[0-9a-fA-F]$/.test(e)}function ss(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function $i(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(!ss(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]==="/"&&$i(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!i;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let l=n.indexOf("/",r);if(l===-1)return-1;r=l+1,t++;break}for(;!(r>=n.length);){if(!zu(e[t])){let d=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==d;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let l=$i(e,t,n,r,o);if(l!==1){if(!f||l!==-2)return l}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(i&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let l=!1,d="",u=!0;for(;t<e.length&&(u||e[t]!=="]");){u=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],ss(c,m,s)&&(l=!0)}else if(m==="-"&&d&&t+1<e.length&&e[t+1]!=="]"){if(t++,m=e[t],m==="\\"){if(t++,t>=e.length)return-1;m=e[t]}let h=d,p=m;if(c>=h&&c<=p&&(l=!0),s){if(Pi(c)){let g=c.toUpperCase();g>=h&&g<=p&&(l=!0)}else if(Ci(c)){let g=c.toLowerCase();g>=h&&g<=p&&(l=!0)}}m=""}else if(m==="["&&t+1<e.length&&e[t+1]===":"){t+=2;let h=t;for(;t<e.length&&e[t]!=="]";)t++;if(t>=e.length)return-1;let p=t-h-1;if(p<0||e[t-1]!==":")t=h-2,m="[",ss(c,m,s)&&(l=!0);else{let g=e.slice(h,h+p);Ku(g,c,s)&&(l=!0),m=""}}else ss(c,m,s)&&(l=!0);d=m,t++}if(t>=e.length)return-1;if(t++,l===f)return 1;r++;break}default:{if(!ss(c,a,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function zu(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Ku(e,t,n){switch(e){case"alnum":return Nc(t);case"alpha":return Nu(t);case"blank":return Fu(t);case"cntrl":return Wu(t);case"digit":return _u(t);case"graph":return Uu(t);case"lower":return Pi(t)||n&&Ci(t);case"print":return Oi(t);case"punct":return Bu(t);case"space":return _c(t);case"upper":return Ci(t)||n&&Pi(t);case"xdigit":return qu(t);default:return!1}}function on(e,t,n=0){return $i(e,0,t,0,n)===0?0:1}var os=Re(()=>{"use strict"});function Wc(e){for(let t=0;t<e.length;t++){let n=e[t];if(n==="\\"){t++;continue}if(n==="*"||n==="?"||n==="[")return t}return e.length}function Vu(e){return Wc(e)===e.length}function Yu(e,t){let n=e;for(;n.length>0;){let c=n[n.length-1];if(c===" "||c===" "){if(n.length>=2&&n[n.length-2]==="\\"){n=n.slice(0,n.length-2)+n[n.length-1];break}n=n.slice(0,-1)}else break}if(n.length===0||n[0]==="#")return null;let r=0,o=n;if(o[0]==="!"&&(r|=Ys,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Bc);let i=!1;for(let c=0;c<s;c++)if(o[c]==="/"){i=!0;break}i||(r|=Fc);let a=Math.min(Wc(o),s);return o[0]==="*"&&Vu(o.slice(1))&&(r|=Uc),{pattern:o,patternLen:s,nowildcardLen:a,flags:r,base:t}}function is(e,t,n){let r=[];for(let o of e.split(`
41
+ `)){let s=Yu(o,t);s&&r.push(s)}return{patterns:r,src:n}}function Xu(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Uc){let i=n.slice(1);return e.length>=i.length&&e.endsWith(i)}return on(n,e,2)===0}function Zu(e,t){let{base:n}=t,{pattern:r,patternLen:o,nowildcardLen:s}=t;r[0]==="/"&&(r=r.slice(1),o--,s=Math.max(0,s-1));let i=n.length;if(i>0&&(e.length<i+1||e[i]!=="/"||!e.startsWith(n)))return!1;let a=i>0?e.slice(i+1):e,c=a.length;if(s>0){if(s>c||a.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return on(r,a,2)===0}function Ii(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&Bc&&!t)){if(s.flags&Fc){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(Xu(r,s))return s;continue}if(Zu(e,s))return s}}return null}function an(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Ii(t,n,o);if(s)return s.flags&Ys?"not-ignored":"ignored"}if(e.excludeFile){let r=Ii(t,n,e.excludeFile);if(r)return r.flags&Ys?"not-ignored":"ignored"}if(e.globalExclude){let r=Ii(t,n,e.globalExclude);if(r)return r.flags&Ys?"not-ignored":"ignored"}return"undecided"}async function $r(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=v(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=is(r,"",n)}catch{}try{let r=await xe(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=is(o,"",r)}catch{}}catch{}return t}function rr(e,t,n,r){let s=is(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Fc,Uc,Bc,Ys,Zs=Re(()=>{"use strict";qe();me();os();Fc=1,Uc=4,Bc=8,Ys=16});async function gt(e,t){if(!e.workTree)throw new Error("Cannot diff working tree in a bare repository");let n=[];for(let s of t.entries){if(s.stage!==0)continue;let i=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 Nn(e.fs,i)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await ot(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,i)=>Ie(s.path,i.path))}async function dt(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");if(!Qn(t.path))throw new Error(`refusing to check out unsafe path '${t.path}'`);let n=await be(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(!Ms(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&&bn(t.mode)&&e.fs.symlink){let s=Qu.decode(n.content);if(!Wa(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 qc(e,t){let n=await Ke(e,t);for(let r of n)await dt(e,r)}async function cn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");if(!Qn(n))throw new Error(`refusing to stage unsafe path '${n}'`);let r=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=Ju.encode(f),d=await He(e,"blob",l),u={path:n,mode:40960,hash:d,stage:0,stat:{...Se(),size:l.byteLength}};return{index:Ct(t,u),hash:d}}let s=await e.fs.readFileBuffer(r),i=await He(e,"blob",s),a=o.mode!=null?em(o.mode):33188,c={path:n,mode:a,hash:i,stage:0,stat:{...Se(),size:s.byteLength}};return{index:Ct(t,c),hash:i}}async function ot(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await $r(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);s=rr(s,f,n,c)}catch{}}let i=[],a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=v(t,c),l=n?`${n}/${c}`:c,d=await mt(e.fs,f);if(d.isSymbolicLink){if(s&&an(s,l,!1)==="ignored")continue;i.push(l)}else if(d.isDirectory){if(s&&an(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&&an(s,l,!1)==="ignored")continue;i.push(l)}}return i}function em(e){return e>511?e:e&73?33261:33188}async function sr(e,t,n){if(t===n||t==="/"||!t.startsWith(n)||!await e.exists(t)||!(await e.stat(t)).isDirectory)return;(await e.readdir(t)).length===0&&(await e.rm(t,{recursive:!0}),await sr(e,Qt(t),n))}var Ju,Qu,tt=Re(()=>{"use strict";oe();Zs();Ce();ae();js();me();nr();Ae();Ju=new TextEncoder,Qu=new TextDecoder});function Si(e){return e.existsOnDisk&&e.indexHash===null}async function tm(e,t,n){let r=await Promise.all(t.map(h=>fe(e,h.treeHash))),o=new Map,s=new Set;for(let h of n.entries)h.stage===0?o.set(h.path,h):s.add(h.path);let i=e.workTree?new Set(await ot(e,e.workTree,"",{skipIgnore:!0})):new Set,a=null,c=async()=>(a===null&&(a=e.workTree?new Set(await ot(e,e.workTree,"")):new Set),a),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let l=new Set;for(let h of n.entries)f.has(h.path)||l.add(h.path);for(let h of i)f.has(h)||l.add(h);let d=Array.from(f).sort().concat(Array.from(l).sort()),u=(h,p)=>r[h]?.get(p),m=[];for(let h of d){let p=null,g=null,w=null,y=null,x=null;if(r.length===1){let O=u(0,h);w=O?.hash??null,x=O?.mode??null}else if(r.length===2){let O=u(0,h),N=u(1,h);g=O?.hash??null,y=O?.mode??null,w=N?.hash??null,x=N?.mode??null}else if(r.length>=3){let O=u(0,h),N=u(1,h),H=u(2,h);p=O?.hash??null,g=N?.hash??null,y=N?.mode??null,w=H?.hash??null,x=H?.mode??null}let E=o.get(h)?.hash??null,R=s.has(h)?1:0,k=i.has(h),C,P=async()=>C!==void 0?C:k?(C=!(await c()).has(h),C):(C=!1,!1),T,D=async()=>{if(T!==void 0)return T;if(!k||!e.workTree)return T=null,null;let O=v(e.workTree,h);try{T=await Nn(e.fs,O)}catch{T=null}return T};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:E,indexStage:R,existsOnDisk:k,isIgnoredOnDisk:P,getWorktreeHash:D,headMode:y,remoteMode:x})}return m}function Js(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 Qs(e,t){let{headHash:n,remoteHash:r,indexHash:o}=e;return e.indexStage>0?n===r?r===null?{action:"DELETE",requirements:[]}:{action:"TAKE",takeFrom:"remote",requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}:o===null?r===null?n===null?{action:"SKIP",caseNumber:0,requirements:[]}:{action:"SKIP",caseNumber:2,requirements:["NO_UNTRACKED_REMOVED"]}:n!==null?n===r?{action:"SKIP",caseNumber:3,requirements:[]}:t.allowStagedChanges?{action:"TAKE",takeFrom:"remote",caseNumber:3,requirements:[]}:{action:"KEEP",caseNumber:3,requirements:["INDEX_MUST_MATCH_HEAD"]}:{action:"TAKE",takeFrom:"remote",caseNumber:1,requirements:["NO_UNTRACKED"]}:n===null&&r===null?{action:"KEEP",caseNumber:4,requirements:[]}:n===null&&r===o?{action:"KEEP",caseNumber:6,requirements:[]}:n===o&&r===null?{action:"DELETE",caseNumber:10,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:n!==null&&n===r?{action:"KEEP",caseNumber:14,requirements:[]}:n!==null&&r!==null&&o===r?{action:"KEEP",caseNumber:18,requirements:[]}:n!==null&&r!==null&&o===n&&o!==r?{action:"TAKE",takeFrom:"remote",caseNumber:20,requirements:["WORKTREE_MUST_BE_UPTODATE"]}:t.allowStagedChanges?r===null?{action:"DELETE",caseNumber:-1,requirements:[]}:{action:"TAKE",takeFrom:"remote",caseNumber:-1,requirements:[]}:{action:"KEEP",requirements:["INDEX_MUST_MATCH_HEAD"],caseNumber:-1}}function nm(e,t){switch(e.action){case"TAKE":return e.takeFrom==="head"?t.headHash:e.takeFrom==="remote"?t.remoteHash:e.takeFrom==="base"?t.baseHash:null;case"DELETE":return null;case"KEEP":return t.indexHash;default:return null}}async function rm(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let i=t.get(o);if(!i)continue;let a=nm(s,i);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await sm(c,i,a);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function sm(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Si(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 Si(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Si(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function om(e,t,n,r){let o=[],s=[],i=new Set(e.keys()),a=new Map;for(let c of n.entries)i.has(c.path)||o.push(c),c.stage===0&&a.set(c.path,c);for(let[c,f]of e){let l=t.get(c);if(l)switch(f.action){case"KEEP":{let d=a.get(c);d&&(o.push(d),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:d.hash,mode:d.mode}));break}case"TAKE":{let d=f.takeFrom==="head"?l.headHash:l.remoteHash,u=f.takeFrom==="head"?l.headMode:l.remoteMode,m=u?Number.parseInt(u,8):33188;o.push({path:c,mode:m,hash:d,stage:0,stat:Se()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:d,mode:m});break}case"DELETE":{r.updateWorktree&&l.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Ie(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function eo(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:i,fix:a}of im){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(l=>` ${l}`).join(`
42
42
  `);r.push(`${i(t.operationName)}
43
43
  ${f}
44
44
  ${a(n)}
45
45
  `)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
46
- `:"",exitCode:t.errorExitCode}}async function or(e,t,n,r){let o=await em(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 nm(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:Qs(a,r)};let{newEntries:c,worktreeOps:f}=sm(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Ne(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!Qn(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!Ds(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await dt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await sr(e.fs,Qt(o),n)}async function Fn(e,t,n,r){return or(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function qc(e,t,n,r){return or(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function En(e,t,n){return or(e,[{label:"target",treeHash:t}],n,{mergeFn:Zs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function eo(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:Le(n)},i=await or(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Zs,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
46
+ `:"",exitCode:t.errorExitCode}}async function or(e,t,n,r){let o=await tm(e,t,n),s=new Map(o.map(l=>[l.path,l])),i=new Map;for(let l of o){let d=r.mergeFn(l,r);i.set(l.path,d)}let a=await rm(i,s,r);if(a.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:a,errorOutput:eo(a,r)};let{newEntries:c,worktreeOps:f}=om(i,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Ne(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){if(!Qn(o.path))throw new Error(`refusing to apply worktree operation on unsafe path '${o.path}'`);let s=v(n,o.path);if(!Ms(n,s))throw new Error(`refusing to apply worktree operation outside worktree: '${o.path}'`);o.type==="delete"?await mt(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await dt(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await sr(e.fs,Qt(o),n)}async function Fn(e,t,n,r){return or(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Qs,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function zc(e,t,n,r){return or(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Qs,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function En(e,t,n){return or(e,[{label:"target",treeHash:t}],n,{mergeFn:Js,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function to(e,t,n,r){let o=new Set;for(let a of n.entries)a.stage>0&&o.add(a.path);let s={version:n.version,entries:Le(n)},i=await or(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!i.success){let a=r??"HEAD",c=[];for(let f of i.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
47
47
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
48
48
  `);return c.length>0&&(i.errorOutput=G(c.join("")+`fatal: Could not reset index file to revision '${a}'.
49
- `,128)),i}if(e.workTree&&o.size>0){let a=await fe(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 om,fn=Re(()=>{"use strict";oe();Ce();Ms();me();nr();Ae();tt();om=[{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 G(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await tr(e,t);return r?n?{...r,...n}:r:im}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:am}async function Qe(e){let t=await Y(e);return t||I("your current branch does not have any commits yet")}function kn(e,t,n=`fatal: Exiting because of an unresolved conflict.
49
+ `,128)),i}if(e.workTree&&o.size>0){let a=await fe(e,t),c=new Set(i.newEntries.map(f=>f.path));for(let f of o)!a.has(f)&&!c.has(f)&&i.worktreeOps.push({path:f,type:"delete"})}return i}var im,fn=Re(()=>{"use strict";oe();Ce();js();me();nr();Ae();tt();im=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function I(e){return{stdout:"",stderr:`fatal: ${e}
50
+ `,exitCode:128}}function G(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function W(e,t,n){if(n?.objectStore&&n?.refStore&&n?.gitDir)return{fs:e,gitDir:n.gitDir,workTree:n.workTree??t,objectStore:n.objectStore,refStore:n.refStore,...n};let r=await tr(e,t);return r?n?{...r,...n}:r:am}function M(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Ye(e){return e.workTree?null:cm}async function Qe(e){let t=await Y(e);return t||I("your current branch does not have any commits yet")}function kn(e,t,n=`fatal: Exiting because of an unresolved conflict.
51
51
  `){return Ht(e)?G(`error: ${t} is not possible because you have unmerged files.
52
52
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
53
53
  hint: as appropriate to mark resolution and make a commit.
54
- `+n,128):null}async function wt(e,t,n){let r=await Be(e,t);return r||I(n??`bad revision '${t}'`)}async function Me(e,t,n){let r=await Be(e,t);if(!r)return I(n??`bad revision '${t}'`);try{let o=await ve(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return I(n??`bad revision '${t}'`)}}async function nt(e,t){try{return await Br(e,t)}catch(n){return I(n.message)}}async function ln(e,t){try{return await Hs(e,t)}catch(n){return I(n.message)}}function Un(e,t){let n=new Map;for(let r of e.entries)r.stage===0&&n.set(r.path,r);for(let[r,o]of n){let s=t.get(r);if(!s||s.hash!==o.hash)return!0}for(let[r]of t)if(!n.has(r))return!0;return!1}function Ie(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?st(e.workTree,t):""}function X(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
54
+ `+n,128):null}async function wt(e,t,n){let r=await Be(e,t);return r||I(n??`bad revision '${t}'`)}async function Me(e,t,n){let r=await Be(e,t);if(!r)return I(n??`bad revision '${t}'`);try{let o=await ve(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return I(n??`bad revision '${t}'`)}}async function nt(e,t){try{return await Wr(e,t)}catch(n){return I(n.message)}}async function ln(e,t){try{return await Ds(e,t)}catch(n){return I(n.message)}}function Un(e,t){let n=new Map;for(let r of e.entries)r.stage===0&&n.set(r.path,r);for(let[r,o]of n){let s=t.get(r);if(!s||s.hash!==o.hash)return!0}for(let[r]of t)if(!n.has(r))return!0;return!1}function Ie(e,t){return e<t?-1:e>t?1:0}function ut(e,t){return e.workTree?st(e.workTree,t):""}function X(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
55
55
  `);return t===-1?e:e.slice(0,t)}function Yt(e){return I(`ambiguous argument '${e}': unknown revision or path not in the working tree.
56
56
  Use '--' to separate paths from revisions, like this:
57
- 'git <command> [<revision>...] -- [<file>...]'`)}function Dt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${X(t)}] ${ue(n)}`}async function Bn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await Y(e);if(!o)return I(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Y(e),i=await j(e,o),a=await z(e),c=await eo(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await jn(e,o),await de(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await ce(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function bt(e,t,n,r,o,s){let i=rn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await He(e,"commit",i);return await jn(e,a),a}function Xt(e){let t=e.split(`
57
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Dt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${X(t)}] ${ue(n)}`}async function Bn(e,t,n){if(!await B(e,n.operationRef))return n.noOpError;let o=await B(e,"ORIG_HEAD")??await Y(e);if(!o)return I(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Y(e),i=await j(e,o),a=await z(e),c=await to(e,i.tree,a,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await jn(e,o),await de(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps),s&&((await Q(e))?.type==="symbolic"||s!==o)){let d=n.origHeadAsTargetRev?o:"HEAD";await ce(e,t,"HEAD",s,o,`reset: moving to ${d}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function bt(e,t,n,r,o,s){let i=rn({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),a=await He(e,"commit",i);return await jn(e,a),a}function Xt(e){let t=e.split(`
58
58
  `).filter(o=>!o.startsWith("#")).map(o=>o.trimEnd());for(;t.length>0&&t[0]==="";)t.shift();for(;t.length>0&&t[t.length-1]==="";)t.pop();if(t.length===0)return"";let n=[],r=!1;for(let o of t)o===""?(r||n.push(o),r=!0):(n.push(o),r=!1);return n.join(`
59
59
  `)+`
60
60
  `}function Mt(e){return e.endsWith(`
61
61
  `)?e:`${e}
62
- `}var im,am,oe=Re(()=>{"use strict";Tn();Ce();ae();gn();me();ze();ge();Gn();sn();fn();im=I("not a git repository (or any of the parent directories): .git"),am=I("this operation must be run in a work tree")});var Xc={};Ad(Xc,{CommitHeap:()=>Wn,countAheadBehind:()=>vi,findOrphanedCommits:()=>Ai,walkCommits:()=>jt});async function*jt(e,t,n){if(n?.topoOrder){yield*mm(e,t,n);return}let r=await Yc(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let c of a)o.has(c)||s.push(await $r(e,c));for(;s.size>0;){let c=s.pop();if(o.has(c.hash)||(o.add(c.hash),yield c,i?.has(c.hash)))continue;let f=n?.firstParent?c.commit.parents.slice(0,1):c.commit.parents;for(let l of f)if(!o.has(l))try{s.push(await $r(e,l))}catch{}}}async function*mm(e,t,n){let r=await Yc(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let m of a)o.has(m)||s.push(await $r(e,m));let c=[],f=new Map;for(;s.size>0;){let m=s.pop();if(o.has(m.hash)||(o.add(m.hash),f.set(m.hash,c.length),c.push(m),i?.has(m.hash)))continue;let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h)if(!o.has(p))try{s.push(await $r(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let m of c){let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let u=[];for(let m=l-1;m>=0;m--)d[m]===0&&u.push(m);for(;u.length>0;){let m=u.pop();yield c[m];let h=n?.firstParent?c[m].commit.parents.slice(0,1):c[m].commit.parents;for(let p of h){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&u.push(g)}}}}async function vi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of jt(e,t))r.add(a.hash);let o=new Set;for await(let a of jt(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function Ai(e,t,n){let r=n?.maxCount??25,o=await pe(e,"refs"),s=[];for(let l of o)try{s.push(await ve(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of jt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Wn;for(f.push(await $r(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 $r(e,d))}}return a}async function Yc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}async function $r(e,t){return{hash:t,commit:await j(e,t)}}var Wn,ar=Re(()=>{"use strict";oe();ae();ge();Wn=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var qo=class e{_def;constructor(t){this._def=t}name(t){return new e({...this._def,name:t})}describe(t){return new e({...this._def,description:t})}optional(){return new e({...this._def,required:!1})}variadic(){return new e({...this._def,variadic:!0})}default(t){return new e({...this._def,required:!1,default:t})}};function Oa(e){return new qo({_kind:"arg",type:e,required:!0})}function Ia(){return Oa("string")}function Sa(){return Oa("number")}var Is=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var zo=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 Ta(e){return new zo({_kind:"option",type:e})}function va(){return Ta("string")}function Aa(){return Ta("number")}var V={string:va,number:Aa};function $(){return new Is}var q={string:Ia,number:Sa};function Hd(e){switch(e.type){case"unknown_option":{let t=`Unknown option "${e.name}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
62
+ `}var am,cm,oe=Re(()=>{"use strict";Tn();Ce();ae();gn();me();ze();ge();Gn();sn();fn();am=I("not a git repository (or any of the parent directories): .git"),cm=I("this operation must be run in a work tree")});var Zc={};Hd(Zc,{CommitHeap:()=>Wn,countAheadBehind:()=>Hi,findOrphanedCommits:()=>Di,walkCommits:()=>jt});async function*jt(e,t,n){if(n?.topoOrder){yield*hm(e,t,n);return}let r=await Xc(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let c of a)o.has(c)||s.push(await Or(e,c));for(;s.size>0;){let c=s.pop();if(o.has(c.hash)||(o.add(c.hash),yield c,i?.has(c.hash)))continue;let f=n?.firstParent?c.commit.parents.slice(0,1):c.commit.parents;for(let l of f)if(!o.has(l))try{s.push(await Or(e,l))}catch{}}}async function*hm(e,t,n){let r=await Xc(e,n?.exclude),o=new Set(r),s=new Wn,i=n?.shallowBoundary,a=Array.isArray(t)?t:[t];for(let m of a)o.has(m)||s.push(await Or(e,m));let c=[],f=new Map;for(;s.size>0;){let m=s.pop();if(o.has(m.hash)||(o.add(m.hash),f.set(m.hash,c.length),c.push(m),i?.has(m.hash)))continue;let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h)if(!o.has(p))try{s.push(await Or(e,p))}catch{}}let l=c.length;if(l===0)return;let d=new Int32Array(l);for(let m of c){let h=n?.firstParent?m.commit.parents.slice(0,1):m.commit.parents;for(let p of h){let g=f.get(p);g!==void 0&&(d[g]=(d[g]??0)+1)}}let u=[];for(let m=l-1;m>=0;m--)d[m]===0&&u.push(m);for(;u.length>0;){let m=u.pop();yield c[m];let h=n?.firstParent?c[m].commit.parents.slice(0,1):c[m].commit.parents;for(let p of h){let g=f.get(p);if(g!==void 0){let w=(d[g]??0)-1;d[g]=w,w===0&&u.push(g)}}}}async function Hi(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let a of jt(e,t))r.add(a.hash);let o=new Set;for await(let a of jt(e,n))o.add(a.hash);let s=0;for(let a of r)o.has(a)||s++;let i=0;for(let a of o)r.has(a)||i++;return{ahead:s,behind:i}}async function Di(e,t,n){let r=n?.maxCount??25,o=await pe(e,"refs"),s=[];for(let l of o)try{s.push(await ve(e,l.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let i=new Set;if(s.length>0)for await(let l of jt(e,s))i.add(l.hash);if(i.has(t))return[];let a=[],c=new Set,f=new Wn;for(f.push(await Or(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 Or(e,d))}}return a}async function Xc(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}async function Or(e,t){return{hash:t,commit:await j(e,t)}}var Wn,ar=Re(()=>{"use strict";oe();ae();ge();Wn=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(t){this.heap.push({entry:t,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:t}=this;if(t.length===0)return;let n=t[0],r=t.pop();return t.length>0&&(t[0]=r,this.siftDown(0)),n.entry}higher(t,n){let r=t.entry.commit.committer.timestamp,o=n.entry.commit.committer.timestamp;return r>o||r===o&&t.epoch<n.epoch}siftUp(t){let{heap:n}=this;for(;t>0;){let r=t-1>>1;if(!this.higher(n[t],n[r]))break;[n[r],n[t]]=[n[t],n[r]],t=r}}siftDown(t){let{heap:n}=this,r=n.length;for(;;){let o=t,s=2*t+1,i=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),i<r&&this.higher(n[i],n[o])&&(o=i),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var Ko=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 Ia(e){return new Ko({_kind:"arg",type:e,required:!0})}function Sa(){return Ia("string")}function Ta(){return Ia("number")}var Ss=class e{_def;constructor(t={_kind:"flag"}){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}default(t){return new e({...this._def,default:t})}count(){return new e({...this._def,counted:!0})}};var Vo=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}repeatable(){return new e({...this._def,repeatable:!0,default:[]})}};function va(e){return new Vo({_kind:"option",type:e})}function Aa(){return va("string")}function Ha(){return va("number")}var V={string:Aa,number:Ha};function $(){return new Ss}var q={string:Sa,number:Ta};function Dd(e){switch(e.type){case"unknown_option":{let t=`Unknown option "${e.name}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
63
63
  Not all git options are supported. Run 'git <command> --help' for available options.`,t}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`git: '${e.path.replace(/^git /,"")}' is not a git command.`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t+=`
64
- Run 'git help' for available commands.`,t}}}function Ko(e){return e.map(Hd).join(`
64
+ Run 'git help' for available commands.`,t}}}function Yo(e){return e.map(Dd).join(`
65
65
  `)+`
66
- `}function Dd(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function Ss(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Dd(e,s)})).filter(s=>s.distance<=r&&s.distance>0).sort((s,i)=>s.distance-i.distance).slice(0,2).map(s=>s.candidate)}function Ha(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=_r(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],l=0;for(;l<n.length;){let u=n[l];if(u==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,l++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Ss(h,x).map(b=>`--${b}`)}),l++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,l++;continue}let w=p??n[++l];if(w===void 0){o.push({type:"missing_value",name:g.key}),l++;continue}let y=Nr(w,g.def.type,g.key,o);y!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(y)):a[g.key]=y),l++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),y=w.length>0?w:n[++l];if(y===void 0){o.push({type:"missing_value",name:g.key});break}let x=Nr(y,g.def.type,g.key,o);x!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(x)):a[g.key]=x);break}l++;continue}c.push(u),l++}let d=0;for(let u=0;u<t.length;u++){let m=t[u],h=m.name??`arg${u}`;if(m.variadic){let p=c.slice(d);p.length>0?a[h]=p.map(g=>Nr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?a[h]=m.default:a[h]=[],d=c.length}else{let p=c[d];p!==void 0?(a[h]=Nr(p,m.type,h,o),d++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(d<c.length)for(let u=d;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,m]of Object.entries(e))if(a[u]===void 0){if(m._kind==="flag")a[u]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=Nr(r[h.env],h.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(a[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function Nr(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 _r(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function br(e){let t=[],n=e.children.size>0;e.description?t.push(`${e.fullPath} - ${e.description}`):t.push(e.fullPath),t.push("");let r=[e.fullPath];n&&r.push("<command>"),Object.keys(e.options).length>0&&r.push("[options]");let o=e.args;for(let i of o){let a=i.name??"arg",c=i.variadic?`${a}...`:a;r.push(i.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let i=[];for(let[c,f]of e.children)i.push([c,f.description||""]);let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let i=[];for(let c of o){let f=c.name??"arg",l=c.variadic?`${f}...`:f,d=[];c.description&&d.push(c.description),c.required&&d.push("(required)"),c.default!==void 0&&d.push(`(default: ${JSON.stringify(c.default)})`),i.push([l,d.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${f}`)}else t.push(` ${c}`);t.push("")}let s=Md(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
67
- `)}function Md(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=_r(i);if(a._kind==="flag"){let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c}`);let d=[];f.description&&d.push(f.description),f.counted&&d.push("(counted)"),f.default!==void 0&&d.push(`(default: ${f.default})`),r.push([l.join(" "),d.join(" ")])}else{let f=a,l=[];f.short&&l.push(`-${f.short},`),l.push(`--${c} <${f.type}>`);let d=[];f.description&&d.push(f.description),f.repeatable&&d.push("(repeatable)"),f.required&&d.push("(required)"),f.default!==void 0&&!f.repeatable&&d.push(`(default: ${JSON.stringify(f.default)})`),f.env&&d.push(`[env: ${f.env}]`),r.push([l.join(" "),d.join(" ")])}}let o=Math.max(...r.map(([i])=>i.length)),s=[];t&&s.push(t);for(let[i,a]of r)if(a){let c=" ".repeat(o-i.length+2);s.push(` ${i}${c}${a}`)}else s.push(` ${i}`);return s}function Da(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Ma(e){return e?e.map(t=>t._def):[]}var Ts=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,Da(n.options),Ma(n.args),n.examples??[],n.handler,n.transformArgs);return r.parent=this,this.children.set(t,r),r}get fullPath(){let t=[],n=this;for(;n;)t.unshift(n.name),n=n.parent;return t.join(" ")}toCommand(){return{name:this.name,execute:this.execute.bind(this)}}get allOptions(){return this.options}toTokens(t){let n=[],r=this.allOptions,o=t;for(let[s,i]of Object.entries(r)){let a=o[s],c=_r(s);if(i._kind==="flag")if(i.counted&&typeof a=="number"&&a>0)for(let f=0;f<a;f++)n.push(`--${c}`);else a===!0?n.push(`--${c}`):a===!1&&i.default===!0&&n.push(`--no-${c}`);else i._kind==="option"&&a!==void 0&&n.push(`--${c}`,String(a))}for(let s of this.args){let i=s.name??"arg",a=o[i];if(a!==void 0)if(s.variadic&&Array.isArray(a))for(let c of a)n.push(String(c));else n.push(String(a))}return n}async invoke(t,n){if(!this.handler)return{stdout:"",stderr:`Command "${this.fullPath}" has no handler`,exitCode:1};let r={...t},o=this.allOptions;for(let[s,i]of Object.entries(o))if(r[s]===void 0){if(i._kind==="flag")r[s]=i.default??(i.counted?0:!1);else if(i._kind==="option"){if(i.default!==void 0)r[s]=i.default;else if(i.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let i=s.name??"arg";if(r[i]===void 0){if(s.default!==void 0)r[i]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${i}"`,exitCode:1}}}try{return await this.handler(r,n,{passthrough:[]})}catch(s){return{stdout:"",stderr:s instanceof Error?s.message:String(s),exitCode:1}}}async execute(t,n){let r=n?.env?Object.fromEntries(n.env):{},o=t[0];if(o&&!o.startsWith("-")){let s=this.children.get(o);if(s)return s.execute(t.slice(1),n)}if(!this.handler&&o&&!o.startsWith("-")){let s=Ss(o,[...this.children.keys()]);return{stdout:"",stderr:Ko([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(jd(t))return{stdout:br(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Ha(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:Ko(i.errors),exitCode:1};try{return await this.handler(i.args,n,{passthrough:i.passthrough})}catch(a){return{stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1}}}return{stdout:br(this),stderr:"",exitCode:0}}};function Vo(e,t){return new Ts(e,t.description,Da(t.options),Ma(t.args),t.examples??[],t.handler,t.transformArgs)}function jd(e){return e.some(t=>t==="--help")}oe();Xs();Ce();me();ss();var no=1,Ii=2,to=4,Si=8,is=16,Kc=new Set(["*","?","[","\\"]),fm={glob:no,literal:Ii,icase:to,top:Si,exclude:is};function ir(e){for(let t=0;t<e.length;t++)if(Kc.has(e[t]))return!0;return!1}function lm(e){for(let t=0;t<e.length;t++)if(Kc.has(e[t]))return t;return e.length}function zc(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=fm[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=Si,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=is,r=r.slice(2));n&Ii&&n&no&&(n&=~no);let o;n&Si||t===""?o=zc(r):o=zc(`${t}/${r}`);let s=!!(n&Ii),i=s?!1:ir(o),a=s?o.length:lm(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function ro(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&to),c=a?n.toLowerCase():n,f=a?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let a=n.slice(0,s),c=t.slice(0,s);if(o&to){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&no&&(i|=2),o&to&&(i|=1),on(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&is?ro(o,t)&&(r=!0):ro(o,t)&&(n=!0);return n&&!r}tt();function Vc(e,t){e.command("add",{description:"Add file contents to the index",args:[q.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:$().alias("A").describe("Add changes from all tracked and untracked files"),force:$().alias("f").describe("Allow adding otherwise ignored files"),update:$().alias("u").describe("Update tracked files"),"dry-run":$().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await z(s);return p=await Ti(s,p,a,"",c),n["dry-run"]||await de(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
68
- Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],u=[];for(let p of f)ir(p)?u.push(p):d.push(p);let m=[];for(let p of d){let g=vt(r.cwd,p),w=st(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return I(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=l.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`)),E=await um(s,a,w,b);if(E){b&&((await r.fs.stat(g)).isDirectory?l=await Ti(s,l,g,w,c):l=(await cn(s,l,w)).index),m.push(E);continue}}if((await r.fs.stat(g)).isDirectory)l=await Ti(s,l,g,w,c);else{let b=l.entries.find(R=>R.path===w&&R.stage===0)?.hash,E=await cn(s,l,w);l=E.index,c.actions&&E.hash!==b&&c.actions.push(`add '${w}'
66
+ `}function Md(e,t){let n=e.length,r=t.length,o=new Array((n+1)*(r+1));for(let s=0;s<=n;s++)o[s*(r+1)]=s;for(let s=0;s<=r;s++)o[s]=s;for(let s=1;s<=n;s++)for(let i=1;i<=r;i++){let a=e[s-1]===t[i-1]?0:1;o[s*(r+1)+i]=Math.min(o[(s-1)*(r+1)+i]+1,o[s*(r+1)+(i-1)]+1,o[(s-1)*(r+1)+(i-1)]+a)}return o[n*(r+1)+r]}function Ts(e,t,n){let r=n??Math.min(Math.max(1,Math.floor(e.length/2)),3);return t.map(s=>({candidate:s,distance:Md(e,s)})).filter(s=>s.distance<=r&&s.distance>0).sort((s,i)=>s.distance-i.distance).slice(0,2).map(s=>s.candidate)}function Da(e,t,n,r){let o=[],s=new Map,i=new Map;for(let[u,m]of Object.entries(e)){let h=Fr(u);s.set(h,{key:u,def:m}),m.short&&i.set(m.short,{key:u,def:m})}let a={},c=[],f=[],l=0;for(;l<n.length;){let u=n[l];if(u==="--"){for(l++;l<n.length;)f.push(n[l]),l++;break}if(u.startsWith("--")){let m=u.indexOf("="),h,p;m!==-1?(h=u.slice(2,m),p=u.slice(m+1)):h=u.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let b=s.get(h.slice(3));if(b&&b.def._kind==="flag"){a[b.key]=b.def.counted?0:!1,l++;continue}}let x=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Ts(h,x).map(b=>`--${b}`)}),l++;continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0,l++;continue}let w=p??n[++l];if(w===void 0){o.push({type:"missing_value",name:g.key}),l++;continue}let y=_r(w,g.def.type,g.key,o);y!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(y)):a[g.key]=y),l++;continue}if(u.startsWith("-")&&u.length>1){let m=u.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=i.get(p);if(!g){let b=[];s.has(p)&&b.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:b});continue}if(g.def._kind==="flag"){g.def.counted?a[g.key]=(a[g.key]||0)+1:a[g.key]=!0;continue}let w=m.slice(h+1),y=w.length>0?w:n[++l];if(y===void 0){o.push({type:"missing_value",name:g.key});break}let x=_r(y,g.def.type,g.key,o);x!==void 0&&(g.def.repeatable?(Array.isArray(a[g.key])||(a[g.key]=[]),a[g.key].push(x)):a[g.key]=x);break}l++;continue}c.push(u),l++}let d=0;for(let u=0;u<t.length;u++){let m=t[u],h=m.name??`arg${u}`;if(m.variadic){let p=c.slice(d);p.length>0?a[h]=p.map(g=>_r(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?a[h]=m.default:a[h]=[],d=c.length}else{let p=c[d];p!==void 0?(a[h]=_r(p,m.type,h,o),d++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(a[h]=m.default)}}if(d<c.length)for(let u=d;u<c.length;u++)o.push({type:"unexpected_positional",value:c[u],maxPositionals:t.length});for(let[u,m]of Object.entries(e))if(a[u]===void 0){if(m._kind==="flag")a[u]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=_r(r[h.env],h.type,u,o);p!==void 0&&(a[u]=p)}a[u]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:u,kind:"option"}):h.default!==void 0&&(a[u]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:a,passthrough:f}}function _r(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 Fr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function yr(e){let t=[],n=e.children.size>0;e.description?t.push(`${e.fullPath} - ${e.description}`):t.push(e.fullPath),t.push("");let r=[e.fullPath];n&&r.push("<command>"),Object.keys(e.options).length>0&&r.push("[options]");let o=e.args;for(let i of o){let a=i.name??"arg",c=i.variadic?`${a}...`:a;r.push(i.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let i=[];for(let[c,f]of e.children)i.push([c,f.description||""]);let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let i=[];for(let c of o){let f=c.name??"arg",l=c.variadic?`${f}...`:f,d=[];c.description&&d.push(c.description),c.required&&d.push("(required)"),c.default!==void 0&&d.push(`(default: ${JSON.stringify(c.default)})`),i.push([l,d.join(" ")])}let a=Math.max(...i.map(([c])=>c.length));for(let[c,f]of i)if(f){let l=" ".repeat(a-c.length+2);t.push(` ${c}${l}${f}`)}else t.push(` ${c}`);t.push("")}let s=jd(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let i of e.examples)t.push(` ${i}`);t.push("")}return t.join(`
67
+ `)}function jd(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[i,a]of n){let c=Fr(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 Ma(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function ja(e){return e?e.map(t=>t._def):[]}var vs=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,i,a){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=i,this.transformArgs=a}command(t,n){let r=new e(t,n.description,Ma(n.options),ja(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=Fr(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=Ts(o,[...this.children.keys()]);return{stdout:"",stderr:Yo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}if(Gd(t))return{stdout:yr(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],i=Da(this.allOptions,this.args,s,r);if(!i.ok)return{stdout:"",stderr:Yo(i.errors),exitCode:1};try{return await this.handler(i.args,n,{passthrough:i.passthrough})}catch(a){return{stdout:"",stderr:a instanceof Error?a.message:String(a),exitCode:1}}}return{stdout:yr(this),stderr:"",exitCode:0}}};function Xo(e,t){return new vs(e,t.description,Ma(t.options),ja(t.args),t.examples??[],t.handler,t.transformArgs)}function Gd(e){return e.some(t=>t==="--help")}oe();Zs();Ce();me();os();var ro=1,Ti=2,no=4,vi=8,as=16,Vc=new Set(["*","?","[","\\"]),lm={glob:ro,literal:Ti,icase:no,top:vi,exclude:as};function ir(e){for(let t=0;t<e.length;t++)if(Vc.has(e[t]))return!0;return!1}function dm(e){for(let t=0;t<e.length;t++)if(Vc.has(e[t]))return t;return e.length}function Kc(e){let t=e.split("/"),n=[];for(let r of t)if(!(r===""||r===".")){if(r===".."){n.length>0&&n[n.length-1]!==".."&&n.pop();continue}n.push(r)}return n.join("/")}function Ue(e,t){let n=0,r=e;if(r.startsWith(":(")){let c=r.indexOf(")");if(c!==-1){let f=r.slice(2,c);r=r.slice(c+1);for(let l of f.split(",")){let d=lm[l.trim()];d!==void 0&&(n|=d)}}}else r.startsWith(":/")?(n|=vi,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=as,r=r.slice(2));n&Ti&&n&ro&&(n&=~ro);let o;n&vi||t===""?o=Kc(r):o=Kc(`${t}/${r}`);let s=!!(n&Ti),i=s?!1:ir(o),a=s?o.length:dm(o);return{original:e,pattern:o,magic:n,hasWildcard:i,nowildcardLen:a}}function so(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let a=!!(o&no),c=a?n.toLowerCase():n,f=a?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let a=n.slice(0,s),c=t.slice(0,s);if(o&no){if(a.toLowerCase()!==c.toLowerCase())return!1}else if(a!==c)return!1}let i=0;return o&ro&&(i|=2),o&no&&(i|=1),on(n,t,i)===0}function Ee(e,t){let n=!1,r=!1;for(let o of e)o.magic&as?so(o,t)&&(r=!0):so(o,t)&&(n=!0);return n&&!r}tt();function Yc(e,t){e.command("add",{description:"Add file contents to the index",args:[q.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:$().alias("A").describe("Add changes from all tracked and untracked files"),force:$().alias("f").describe("Allow adding otherwise ignored files"),update:$().alias("u").describe("Update tracked files"),"dry-run":$().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c={skipIgnore:n.force,updateOnly:n.update,actions:n["dry-run"]?[]:void 0},f=n.paths;if((n.all||n.update)&&f.length===0){let p=await z(s);return p=await Ai(s,p,a,"",c),n["dry-run"]||await de(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
68
+ Maybe you wanted to say 'git add .'?`,exitCode:0};let l=await z(s),d=[],u=[];for(let p of f)ir(p)?u.push(p):d.push(p);let m=[];for(let p of d){let g=vt(r.cwd,p),w=st(a,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return I(`'${p}' is outside repository at '${a}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let b=l.entries.some(R=>R.path===w||R.path.startsWith(`${w}/`)),E=await mm(s,a,w,b);if(E){b&&((await r.fs.stat(g)).isDirectory?l=await Ai(s,l,g,w,c):l=(await cn(s,l,w)).index),m.push(E);continue}}if((await r.fs.stat(g)).isDirectory)l=await Ai(s,l,g,w,c);else{let b=l.entries.find(R=>R.path===w&&R.stage===0)?.hash,E=await cn(s,l,w);l=E.index,c.actions&&E.hash!==b&&c.actions.push(`add '${w}'
69
69
  `)}}else if(l.entries.some(b=>b.path===w||b.path.startsWith(`${w}/`))){if(c.actions)for(let b of l.entries)(b.path===w||b.path.startsWith(`${w}/`))&&c.actions.push(`remove '${b.path}'
70
70
  `);l={...l,entries:l.entries.filter(b=>b.path!==w&&!b.path.startsWith(`${w}/`))}}else return I(`pathspec '${p}' did not match any files`)}if(m.length>0)return n["dry-run"]||await de(s,l),G(`The following paths are ignored by one of your .gitignore files:
71
71
  ${m.join(`
72
72
  `)}
73
73
  hint: Use -f if you really want to add them.
74
74
  hint: Disable this message with "git config set advice.addIgnoredFile false"
75
- `);if(u.length>0){let p=await dm(s,r.cwd,l,u,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await de(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function dm(e,t,n,r,o){let s=e.workTree,i=ut(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&ro(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 m=await cn(e,n,d.path);n=m.index,o?.actions&&m.hash!==d.hash&&o.actions.push(`add '${d.path}'
75
+ `);if(u.length>0){let p=await um(s,r.cwd,l,u,c);if(p.error)return p.error;l=p.index}return n["dry-run"]||await de(s,l),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function um(e,t,n,r,o){let s=e.workTree,i=ut(e,t),a=r.map(d=>Ue(d,i)),c=new Array(a.length).fill(!1),f=d=>{for(let u=0;u<a.length;u++)a[u].hasWildcard&&so(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 m=await cn(e,n,d.path);n=m.index,o?.actions&&m.hash!==d.hash&&o.actions.push(`add '${d.path}'
76
76
  `)}else o?.actions&&o.actions.push(`remove '${d.path}'
77
77
  `),l.push(d.path)}for(let d of l)n=lt(n,d);if(!o?.updateOnly){let d=new Set(n.entries.map(m=>m.path)),u=await ot(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of u){if(d.has(m)||!Ee(a,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
78
- `),n=(await cn(e,n,m)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&is))return{index:n,error:I(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function Ti(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 cn(e,t,f.path);t=u.index,o?.actions&&(d||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
78
+ `),n=(await cn(e,n,m)).index}}for(let d=0;d<a.length;d++){let u=a[d];if(!c[d]&&!(u.magic&as))return{index:n,error:I(`pathspec '${u.original}' did not match any files`)}}return{index:n}}async function Ai(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 cn(e,t,f.path);t=u.index,o?.actions&&(d||u.hash!==f.hash)&&o.actions.push(`add '${f.path}'
79
79
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
80
80
  `),a.push(f.path)}for(let f of a)t=lt(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(d=>d.path)),l=await ot(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let d of l){if(f.has(d))continue;o?.actions&&o.actions.push(`add '${d}'
81
- `),t=(await cn(e,t,d)).index}}return t}async function um(e,t,n,r){let o=await Pr(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=rr(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(an(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(v(c,".gitignore"));o=rr(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(an(o,n,i)==="ignored")return n}return null}oe();oe();ar();ae();me();ge();async function Oe(e,t){let n=v(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function De(e,t,n){await e.fs.writeFile(v(e.gitDir,t),n)}async function ye(e,t){let n=v(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function as(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"SQUASH_MSG")}async function Gt(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG")}async function Lt(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG")}async function cr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await he(e,t);await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"SQUASH_MSG")}var Hi="DETACH_POINT";async function Zc(e,t){await e.fs.writeFile(v(e.gitDir,Hi),t)}async function yt(e){let t=v(e.gitDir,Hi);await e.fs.exists(t)&&await e.fs.rm(t)}async function cs(e){let t=v(e.gitDir,Hi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();ge();async function $t(e){let t=await Oe(e,"BISECT_START");return t!=null&&t.trim().length>0}async function fs(e){let t=await Oe(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
82
- `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function so(e){let t=(await Oe(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await fs(e),o=await B(e,`refs/bisect/${n}`),s=[],i=[],a=await pe(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await Oe(e,"BISECT_HEAD")!=null||await e.fs.exists(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 Ot(e,t){let n=await Oe(e,"BISECT_LOG")??"";await De(e,"BISECT_LOG",n+t+`
83
- `)}async function oo(e){let t=await pe(e,"refs/bisect");for(let r of t)await he(e,r.name);await ye(e,"BISECT_EXPECTED_REV"),await ye(e,"BISECT_ANCESTORS_OK"),await ye(e,"BISECT_LOG"),await ye(e,"BISECT_TERMS"),await ye(e,"BISECT_NAMES"),await ye(e,"BISECT_FIRST_PARENT"),await ye(e,"BISECT_HEAD"),await ye(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 Jc(e,t,n,r,o){let s=[],i=new Map;for await(let g of jt(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ue(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,y=[g.hash],x=0;for(;x<y.length;){let b=y[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let E=i.get(b);if(E)for(let R of E)!w.has(R)&&c.has(R)&&y.push(R)}f.set(g.hash,w.size)}let l=s[0].hash,d=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}let u=!1;if(d===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}}let m=s.find(g=>g.hash===l),h=hm(a),p=pm(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function hm(e){return Math.floor((e-1)/2)}function pm(e){return e<=1?0:Math.ceil(Math.log2(e))}function Qc(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
81
+ `),t=(await cn(e,t,d)).index}}return t}async function mm(e,t,n,r){let o=await $r(e);try{let i=await e.fs.readFile(v(t,".gitignore"));o=rr(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(an(o,a,!0)==="ignored")return a;try{let f=await e.fs.readFile(v(c,".gitignore"));o=rr(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(an(o,n,i)==="ignored")return n}return null}oe();oe();ar();ae();me();ge();async function Oe(e,t){let n=v(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function De(e,t,n){await e.fs.writeFile(v(e.gitDir,t),n)}async function ye(e,t){let n=v(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function cs(e){await he(e,"MERGE_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"SQUASH_MSG")}async function Gt(e){await he(e,"CHERRY_PICK_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG")}async function Lt(e){await he(e,"REVERT_HEAD"),await he(e,"ORIG_HEAD"),await ye(e,"MERGE_MSG")}async function cr(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await he(e,t);await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"SQUASH_MSG")}var Mi="DETACH_POINT";async function Jc(e,t){await e.fs.writeFile(v(e.gitDir,Mi),t)}async function yt(e){let t=v(e.gitDir,Mi);await e.fs.exists(t)&&await e.fs.rm(t)}async function fs(e){let t=v(e.gitDir,Mi);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}me();ge();async function $t(e){let t=await Oe(e,"BISECT_START");return t!=null&&t.trim().length>0}async function ls(e){let t=await Oe(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
82
+ `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function oo(e){let t=(await Oe(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await ls(e),o=await B(e,`refs/bisect/${n}`),s=[],i=[],a=await pe(e,"refs/bisect");for(let l of a)l.name.startsWith(`refs/bisect/${r}-`)?s.push(l.hash):l.name.startsWith("refs/bisect/skip-")&&i.push(l.hash);let c=await Oe(e,"BISECT_HEAD")!=null||await e.fs.exists(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 Ot(e,t){let n=await Oe(e,"BISECT_LOG")??"";await De(e,"BISECT_LOG",n+t+`
83
+ `)}async function io(e){let t=await pe(e,"refs/bisect");for(let r of t)await he(e,r.name);await ye(e,"BISECT_EXPECTED_REV"),await ye(e,"BISECT_ANCESTORS_OK"),await ye(e,"BISECT_LOG"),await ye(e,"BISECT_TERMS"),await ye(e,"BISECT_NAMES"),await ye(e,"BISECT_FIRST_PARENT"),await ye(e,"BISECT_HEAD"),await ye(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 Qc(e,t,n,r,o){let s=[],i=new Map;for await(let g of jt(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:ue(g.commit.message)}),i.set(g.hash,w)}let a=s.length;if(a===0)return null;if(a===1)return{hash:s[0].hash,subject:s[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(s.map(g=>g.hash)),f=new Map;for(let g of s){let w=new Set,y=[g.hash],x=0;for(;x<y.length;){let b=y[x++];if(w.has(b)||!c.has(b))continue;w.add(b);let E=i.get(b);if(E)for(let R of E)!w.has(R)&&c.has(R)&&y.push(R)}f.set(g.hash,w.size)}let l=s[0].hash,d=a;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}let u=!1;if(d===a){u=!0;for(let g of s){let w=f.get(g.hash)??0,y=Math.abs(2*w-a);y<d&&(d=y,l=g.hash)}}let m=s.find(g=>g.hash===l),h=pm(a),p=gm(a);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:u}}function pm(e){return Math.floor((e-1)/2)}function gm(e){return e<=1?0:Math.ceil(Math.log2(e))}function ef(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
84
  `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
85
85
  `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
86
- `}function ef(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
86
+ `}function tf(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
87
87
  [${e.hash}] ${e.subject}
88
- `}async function tf(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
88
+ `}async function nf(e,t){let n=await j(e,t),r=ue(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),i=`${t} is the first bad commit
89
89
  `;return i+=`commit ${t}
90
90
  `,i+=`Author: ${n.author.name} <${n.author.email}>
91
91
  `,i+=`Date: ${s}
92
92
  `,i+=`
93
93
  `,i+=` ${r}
94
94
  `,i+=`
95
- `,i}oe();ar();qe();Ce();ae();me();ze();ge();oe();ar();qe();Ce();ae();me();ae();gn();me();function Or(e){return v(e.gitDir,"rebase-merge")}async function Nt(e){return e.fs.exists(Or(e))}async function Et(e){let t=Or(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=nf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=nf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function Di(e,t){let n=Or(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
95
+ `,i}oe();ar();qe();Ce();ae();me();ze();ge();oe();ar();qe();Ce();ae();me();ae();gn();me();function Ir(e){return v(e.gitDir,"rebase-merge")}async function Nt(e){return e.fs.exists(Ir(e))}async function Et(e){let t=Ir(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=rf(await e.fs.readFile(a)),f=await e.fs.exists(v(t,"done"))?await e.fs.readFile(v(t,"done")):"",l=rf(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:l,msgnum:s,end:i}}async function ji(e,t){let n=Ir(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(v(n,"head-name"),`${t.headName}
96
96
  `),await e.fs.writeFile(v(n,"orig-head"),`${t.origHead}
97
97
  `),await e.fs.writeFile(v(n,"onto"),`${t.onto}
98
98
  `),await e.fs.writeFile(v(n,"msgnum"),`${String(t.msgnum)}
99
99
  `),await e.fs.writeFile(v(n,"end"),`${String(t.end)}
100
- `),await e.fs.writeFile(v(n,"git-rebase-todo"),ao(t.todo)),await e.fs.writeFile(v(n,"done"),ao(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function of(e){let t=Or(e),n=await Et(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(v(t,"msgnum"),`${String(n.msgnum)}
101
- `),await e.fs.writeFile(v(t,"git-rebase-todo"),ao(n.todo)),await e.fs.writeFile(v(t,"done"),ao(n.done))}async function Mi(e){let t=Or(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function co(e,t,n){let r=Or(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
100
+ `),await e.fs.writeFile(v(n,"git-rebase-todo"),co(t.todo)),await e.fs.writeFile(v(n,"done"),co(t.done)),await e.fs.writeFile(v(n,"interactive"),"")}async function af(e){let t=Ir(e),n=await Et(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(v(t,"msgnum"),`${String(n.msgnum)}
101
+ `),await e.fs.writeFile(v(t,"git-rebase-todo"),co(n.todo)),await e.fs.writeFile(v(t,"done"),co(n.done))}async function Gi(e){let t=Ir(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function fo(e,t,n){let r=Ir(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(v(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
102
102
  GIT_AUTHOR_EMAIL='${n.email}'
103
103
  GIT_AUTHOR_DATE='${o}'
104
104
  `),await e.fs.writeFile(v(r,"stopped-sha"),`${t}
105
- `)}function nf(e){let t=[];for(let n of e.split(`
106
- `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^pick\s+([0-9a-f]+)\s+(.*)/);if(o?.[1]&&o[2]){let s=o[2].startsWith("# ")?o[2].slice(2):o[2];t.push({hash:o[1],subject:s})}}return t}function ao(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
105
+ `)}function rf(e){let t=[];for(let n of e.split(`
106
+ `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^pick\s+([0-9a-f]+)\s+(.*)/);if(o?.[1]&&o[2]){let s=o[2].startsWith("# ")?o[2].slice(2):o[2];t.push({hash:o[1],subject:s})}}return t}function co(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
107
107
  `)}
108
- `}async function af(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 sf(e,r,n,i),left:await sf(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 io(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function sf(e,t,n,r){if(r.size===0)return[];let o=new Map;for(let f of r)o.set(f,0);for(let f of r){let l=await io(e,f,t);for(let d of l.commit.parents)r.has(d)&&o.set(d,(o.get(d)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await io(e,f,t));s.sort((f,l)=>f.commit.committer.timestamp-l.commit.committer.timestamp);let i=s.map(f=>f.hash),a=[],c=new Set;for(;i.length>0;){let f=i.pop();if(!f||c.has(f))continue;c.add(f);let l=await io(e,f,t);l.commit.parents.length<=1&&a.push(l);for(let d of l.commit.parents)if(r.has(d)&&!c.has(d)){let u=(o.get(d)??0)-1;o.set(d,u),u<=0&&i.push(d)}}return a.reverse(),a}async function io(e,t,n){let r=n.get(t);if(r)return r;let o=await be(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:nn(o.content)};return n.set(t,s),s}ge();ae();function Ir(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function gm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Ir(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Ir(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var wm=50;async function it(e,t,n=wm){let r=new Map,o=[],s=[],i=[];for(let l of t)if(l.status==="deleted"&&l.oldHash){let d=r.get(l.oldHash)??[];d.push(l),r.set(l.oldHash,d),o.push(l)}else l.status==="added"&&l.newHash?s.push(l):i.push(l);let a=[],c=[];for(let l of s){let d=l.newHash;if(!d){c.push(l);continue}let u=r.get(d);if(u&&u.length>0){let m=gm(u,l.path);m&&a.push({oldPath:m.path,newPath:l.path,oldHash:m.oldHash??d,newHash:d,similarity:100,oldMode:m.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await bm(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await km(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function bm(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=Ir(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=Ir(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 Pt(e,l.oldHash),m=await Pt(e,d.newHash),h=Em(u,m);h<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:h,oldMode:l.oldMode,newMode:d.newMode})}return i}var cf=107927;function fo(e){let t=new Map,n=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let f=(r+Math.imul(o,97))%cf;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%cf;t.set(i,(t.get(i)??0)+n)}let s=[];for(let[i,a]of t)s.push({hash:i,count:a});return s.sort((i,a)=>i.hash-a.hash),s}function ym(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 Em(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:ff(e.length,fo(e),t.length,fo(t))}function ff(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=ym(t,r);return Math.floor(i*100/o)}async function km(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Pt(e,l.oldHash);o.push({size:d.length,chunks:fo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Pt(e,l.newHash);s.push({size:d.length,chunks:fo(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],u=o[l];if(!(!d||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=ff(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=Ir(d.path)===Ir(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:m})}}}i.sort((l,d)=>d.similarity-l.similarity||d.nameScore-l.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:l,delIdx:d,addIdx:u}of i){if(a.has(d)||c.has(u))continue;a.add(d),c.add(u);let m=t[d],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:l,oldMode:m.oldMode,newMode:h.newMode})}return f}function dn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let l=Math.max(0,n-o-a),d=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Ae();tt();async function at(e,t){let n=await Q(e),r=await Y(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Gi(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await ji(e,c,i,a),d=await gt(e,i),u=[],m=[];for(let g of d)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>Ie(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=Li(m,h);return Rm(e,r,s,o,i,l,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function lf(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 Rm(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,u=await B(e,"CHERRY_PICK_HEAD"),m=await B(e,"REVERT_HEAD"),h=await B(e,"MERGE_HEAD"),p=!u&&!h,w=await Nt(e)?await Et(e):null;if(n&&w){let C=X(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await cs(e);if(C){let P=t===C?"at":"from";l.push(`HEAD detached ${P} ${X(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await we(e),P=await Rn(e,C,r);if(P){let T=fr(P,{abbreviated:f?.fromCommit});for(let D of T.trimEnd().split(`
109
- `))l.push(D);d=!0}}if(d&&(w||u||m||h)&&l.push(""),w&&h)lf(l,w),l.push(""),a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0;else if(w){let C=Ht(o),P=await e.fs.exists(v(e.gitDir,"MERGE_MSG"));lf(l,w);let D=w.headName==="detached HEAD"?null:Pe(w.headName),O=X(w.onto),N=D?` branch '${D}' on '${O}'`:"";if(C)l.push(`You are currently rebasing${N}.`),l.push(' (fix conflicts and then run "git rebase --continue")'),l.push(' (use "git rebase --skip" to skip this patch)'),l.push(' (use "git rebase --abort" to check out the original branch)');else if(P)l.push(`You are currently rebasing${N}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let H=N?`You are currently editing a commit while rebasing${N}.`:"You are currently editing a commit during a rebase.";l.push(H),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):m?(l.push(`You are currently reverting commit ${X(m)}.`),a.length>0?l.push(' (fix conflicts and run "git revert --continue")'):l.push(' (all conflicts fixed: run "git revert --continue")'),l.push(' (use "git revert --skip" to skip this patch)'),l.push(' (use "git revert --abort" to cancel the revert operation)'),d=!0):h&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await $t(e)){let P=(await Oe(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${P}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}let y=f?.isInitial??!t;y&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let E=i.some(C=>C.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',R=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),x&&l.push(x);for(let C of s)l.push(` ${df(C.status,C.path,C.displayPath)}`);l.push(""),R=!0}if(a.length>0){!R&&d&&l.push(""),l.push("Unmerged paths:"),p&&(t?l.push(' (use "git restore --staged <file>..." to unstage)'):l.push(' (use "git rm --cached <file>..." to unstage)')),a.some(P=>P.status==="deleted by us"||P.status==="deleted by them"||P.status==="both deleted")?l.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):l.push(' (use "git add <file>..." to mark resolution)');for(let P of a)l.push(` ${xm(P.status,P.path)}`);l.push(""),R=!0}if(i.length>0){!R&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(E),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${df(C.status,C.path)}`);l.push(""),R=!0}if(c.length>0){!R&&d&&l.push(""),l.push("Untracked files:"),l.push(' (use "git add <file>..." to include in what will be committed)');for(let C of c)l.push(` ${C}`);l.push(""),R=!0}let k=s.length>0||!!h&&a.length===0;return!R&&d&&(f?.noWarn||k)&&l.push(""),!k&&!f?.noWarn&&(!R&&d&&i.length===0&&a.length===0&&c.length===0&&l.push(""),i.length>0||a.length>0?l.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?l.push('nothing added to commit but untracked files present (use "git add" to track)'):y?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
108
+ `}async function cf(e,t,n){let r=new Map,[o,s]=await Promise.all([sf(e,t,r),sf(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 of(e,r,n,i),left:await of(e,r,t,a)}}async function sf(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let i=o[s++];if(r.has(i))continue;r.add(i);let a=await ao(e,i,n);for(let c of a.commit.parents)r.has(c)||o.push(c)}return r}async function of(e,t,n,r){if(r.size===0)return[];let o=new Map;for(let f of r)o.set(f,0);for(let f of r){let l=await ao(e,f,t);for(let d of l.commit.parents)r.has(d)&&o.set(d,(o.get(d)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await ao(e,f,t));s.sort((f,l)=>f.commit.committer.timestamp-l.commit.committer.timestamp);let i=s.map(f=>f.hash),a=[],c=new Set;for(;i.length>0;){let f=i.pop();if(!f||c.has(f))continue;c.add(f);let l=await ao(e,f,t);l.commit.parents.length<=1&&a.push(l);for(let d of l.commit.parents)if(r.has(d)&&!c.has(d)){let u=(o.get(d)??0)-1;o.set(d,u),u<=0&&i.push(d)}}return a.reverse(),a}async function ao(e,t,n){let r=n.get(t);if(r)return r;let o=await be(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:nn(o.content)};return n.set(t,s),s}ge();ae();function Sr(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function wm(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=Sr(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&Sr(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var bm=50;async function it(e,t,n=bm){let r=new Map,o=[],s=[],i=[];for(let l of t)if(l.status==="deleted"&&l.oldHash){let d=r.get(l.oldHash)??[];d.push(l),r.set(l.oldHash,d),o.push(l)}else l.status==="added"&&l.newHash?s.push(l):i.push(l);let a=[],c=[];for(let l of s){let d=l.newHash;if(!d){c.push(l);continue}let u=r.get(d);if(u&&u.length>0){let m=wm(u,l.path);m&&a.push({oldPath:m.path,newPath:l.path,oldHash:m.oldHash??d,newHash:d,similarity:100,oldMode:m.oldMode,newMode:l.newMode})}else c.push(l)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let l=await ym(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}if(f.length>0&&c.length>0){let l=await Rm(e,f,c,n);if(l.length>0){let d=new Set(l.map(m=>m.oldPath)),u=new Set(l.map(m=>m.newPath));f=f.filter(m=>!d.has(m.path)),c=c.filter(m=>!u.has(m.path)),a.push(...l)}}return{remaining:[...i,...f,...c],renames:a}}async function ym(e,t,n,r){let o=new Map;for(let a=0;a<t.length;a++){let c=t[a];if(!c)continue;let f=Sr(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=Sr(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 Pt(e,l.oldHash),m=await Pt(e,d.newHash),h=km(u,m);h<r||i.push({oldPath:l.path,newPath:d.path,oldHash:l.oldHash,newHash:d.newHash,similarity:h,oldMode:l.oldMode,newMode:d.newMode})}return i}var ff=107927;function lo(e){let t=new Map,n=0,r=0,o=0;for(let i=0;i<e.length;i++){let a=e[i],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let f=(r+Math.imul(o,97))%ff;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let i=(r+Math.imul(o,97))%ff;t.set(i,(t.get(i)??0)+n)}let s=[];for(let[i,a]of t)s.push({hash:i,count:a});return s.sort((i,a)=>i.hash-a.hash),s}function Em(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let i=e[o];if(!i)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=i.hash)break;r+=f.count,s++}let a=i.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===i.hash&&(c=f.count,s++)}a<c?(r+=c-a,n+=a):n+=c,o++}for(;s<t.length;){let i=t[s];i&&(r+=i.count),s++}return{srcCopied:n,literalAdded:r}}function km(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:lf(e.length,lo(e),t.length,lo(t))}function lf(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:i}=Em(t,r);return Math.floor(i*100/o)}async function Rm(e,t,n,r){let o=[];for(let l of t)if(l.oldHash){let d=await Pt(e,l.oldHash);o.push({size:d.length,chunks:lo(d)})}else o.push(null);let s=[];for(let l of n)if(l.newHash){let d=await Pt(e,l.newHash);s.push({size:d.length,chunks:lo(d)})}else s.push(null);let i=[];for(let l=0;l<t.length;l++){let d=t[l],u=o[l];if(!(!d||!u))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=lf(u.size,u.chunks,p.size,p.chunks);if(g>=r){let w=Sr(d.path)===Sr(h.path)?1:0;i.push({similarity:g,nameScore:w,delIdx:l,addIdx:m})}}}i.sort((l,d)=>d.similarity-l.similarity||d.nameScore-l.nameScore);let a=new Set,c=new Set,f=[];for(let{similarity:l,delIdx:d,addIdx:u}of i){if(a.has(d)||c.has(u))continue;a.add(d),c.add(u);let m=t[d],h=n[u];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:l,oldMode:m.oldMode,newMode:h.newMode})}return f}function dn(e,t){let n=e.length,r=t.length,o=0,s=0;for(;s<n&&s<r&&e[s]===t[s];)e[s]==="/"&&(o=s+1),s++;let i=o>0?1:0,a=0,c=n,f=r;for(;o-i<=c&&o-i<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(a=n-c),c--,f--}let l=Math.max(0,n-o-a),d=Math.max(0,r-o-a),u=e.slice(0,o),m=e.slice(n-a),h=e.slice(o,o+l),p=t.slice(o,o+d);return o+a>0?`${u}{${h} => ${p}}${m}`:`${e} => ${t}`}Ae();tt();async function at(e,t){let n=await Q(e),r=await Y(e),o,s=!1;n&&n.type==="symbolic"?o=Pe(n.target):(s=!0,o="HEAD detached");let i=t?.index??await z(e),a=Ni(i),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,l=await Li(e,c,i,a),d=await gt(e,i),u=[],m=[];for(let g of d)g.status==="untracked"?m.push(g.path):u.push({path:g.path,status:g.status});u.sort((g,w)=>Ie(g.path,w.path));let h=new Set(i.entries.map(g=>g.path)),p=_i(m,h);return xm(e,r,s,o,i,l,u,a,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function df(e,t){if(t.done.length>0){let n=t.done.length;e.push(`Last command${n===1?"":"s"} done (${n} command${n===1?"":"s"} done):`);for(let r of t.done.slice(-2))e.push(` pick ${X(r.hash)} # ${r.subject}`);n>2&&e.push(" (see more in file .git/rebase-merge/done)")}if(t.todo.length>0){let n=t.todo.length;e.push(`Next command${n===1?"":"s"} to do (${n} remaining command${n===1?"":"s"}):`);for(let r of t.todo.slice(0,2))e.push(` pick ${X(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function xm(e,t,n,r,o,s,i,a,c,f){let l=[],d=!1,u=await B(e,"CHERRY_PICK_HEAD"),m=await B(e,"REVERT_HEAD"),h=await B(e,"MERGE_HEAD"),p=!u&&!h,w=await Nt(e)?await Et(e):null;if(n&&w){let C=X(w.onto);l.push(`interactive rebase in progress; onto ${C}`)}else if(n){let C=await fs(e);if(C){let P=t===C?"at":"from";l.push(`HEAD detached ${P} ${X(C)}`)}else l.push("Not currently on any branch.")}else l.push(`On branch ${r}`);if(!n&&!w){let C=await we(e),P=await Rn(e,C,r);if(P){let T=fr(P,{abbreviated:f?.fromCommit});for(let D of T.trimEnd().split(`
109
+ `))l.push(D);d=!0}}if(d&&(w||u||m||h)&&l.push(""),w&&h)df(l,w),l.push(""),a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0;else if(w){let C=Ht(o),P=await e.fs.exists(v(e.gitDir,"MERGE_MSG"));df(l,w);let D=w.headName==="detached HEAD"?null:Pe(w.headName),O=X(w.onto),N=D?` branch '${D}' on '${O}'`:"";if(C)l.push(`You are currently rebasing${N}.`),l.push(' (fix conflicts and then run "git rebase --continue")'),l.push(' (use "git rebase --skip" to skip this patch)'),l.push(' (use "git rebase --abort" to check out the original branch)');else if(P)l.push(`You are currently rebasing${N}.`),l.push(' (all conflicts fixed: run "git rebase --continue")');else{let H=N?`You are currently editing a commit while rebasing${N}.`:"You are currently editing a commit during a rebase.";l.push(H),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):m?(l.push(`You are currently reverting commit ${X(m)}.`),a.length>0?l.push(' (fix conflicts and run "git revert --continue")'):l.push(' (all conflicts fixed: run "git revert --continue")'),l.push(' (use "git revert --skip" to skip this patch)'),l.push(' (use "git revert --abort" to cancel the revert operation)'),d=!0):h&&(a.length>0?(l.push("You have unmerged paths."),l.push(' (fix conflicts and run "git commit")'),l.push(' (use "git merge --abort" to abort the merge)')):(l.push("All conflicts fixed but you are still merging."),l.push(' (use "git commit" to conclude merge)')),d=!0);if(await $t(e)){let P=(await Oe(e,"BISECT_START"))?.trim()??"";l.push(`You are currently bisecting, started from branch '${P}'.`),l.push(' (use "git bisect reset" to get back to the original branch)'),d=!0}let y=f?.isInitial??!t;y&&(l.push(""),l.push(f?.fromCommit?"Initial commit":"No commits yet"),d=!0);let x=null;p&&(x=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let E=i.some(C=>C.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',R=!1;if(s.length>0){d&&l.push(""),l.push("Changes to be committed:"),x&&l.push(x);for(let C of s)l.push(` ${uf(C.status,C.path,C.displayPath)}`);l.push(""),R=!0}if(a.length>0){!R&&d&&l.push(""),l.push("Unmerged paths:"),p&&(t?l.push(' (use "git restore --staged <file>..." to unstage)'):l.push(' (use "git rm --cached <file>..." to unstage)')),a.some(P=>P.status==="deleted by us"||P.status==="deleted by them"||P.status==="both deleted")?l.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):l.push(' (use "git add <file>..." to mark resolution)');for(let P of a)l.push(` ${Cm(P.status,P.path)}`);l.push(""),R=!0}if(i.length>0){!R&&d&&l.push(""),l.push("Changes not staged for commit:"),l.push(E),l.push(' (use "git restore <file>..." to discard changes in working directory)');for(let C of i)l.push(` ${uf(C.status,C.path)}`);l.push(""),R=!0}if(c.length>0){!R&&d&&l.push(""),l.push("Untracked files:"),l.push(' (use "git add <file>..." to include in what will be committed)');for(let C of c)l.push(` ${C}`);l.push(""),R=!0}let k=s.length>0||!!h&&a.length===0;return!R&&d&&(f?.noWarn||k)&&l.push(""),!k&&!f?.noWarn&&(!R&&d&&i.length===0&&a.length===0&&c.length===0&&l.push(""),i.length>0||a.length>0?l.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?l.push('nothing added to commit but untracked files present (use "git add" to track)'):y?l.push('nothing to commit (create/copy files and use "git add" to track)'):l.push("nothing to commit, working tree clean")),`${l.join(`
110
110
  `)}
111
- `}async function ji(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await fe(e,s),a=new Map(Le(n).map(m=>[m.path,m])),c=[];for(let[m,h]of a){if(o.has(m))continue;let p=i.get(m);p?p.hash!==h.hash&&c.push({path:m,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:m,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[m,h]of i)o.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:l}=await it(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let m of f){let h=d[m.status];h&&u.push({path:m.path,status:h})}for(let m of l)u.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return u.sort((m,h)=>Ie(m.path,h.path))}function Gi(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Ie(r.path,o.path))}function Li(e,t){if(e.length===0)return[];let n=new Set;for(let o of t){let s=o.indexOf("/");for(;s!==-1;)n.add(o.slice(0,s+1)),s=o.indexOf("/",s+1)}let r=new Set;for(let o of e){let s=o.split("/");if(s.length===1){r.add(o);continue}let i=!1;for(let a=1;a<s.length;a++){let c=`${s.slice(0,a).join("/")}/`;if(!n.has(c)){r.add(c),i=!0;break}}i||r.add(o)}return[...r].sort()}function df(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function xm(e,t){return`${e}:`.padEnd(17)+t}async function Rn(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await B(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await B(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:l,behind:d}=await vi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function uf(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function fr(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
111
+ `}async function Li(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await j(e,t)).tree);let i=await fe(e,s),a=new Map(Le(n).map(m=>[m.path,m])),c=[];for(let[m,h]of a){if(o.has(m))continue;let p=i.get(m);p?p.hash!==h.hash&&c.push({path:m,status:"modified",oldHash:p.hash,newHash:h.hash,oldMode:p.mode,newMode:h.mode.toString(8).padStart(6,"0")}):c.push({path:m,status:"added",newHash:h.hash,newMode:h.mode.toString(8).padStart(6,"0")})}for(let[m,h]of i)o.has(m)||a.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:l}=await it(e,c),d={added:"new file",deleted:"deleted",modified:"modified"},u=[];for(let m of f){let h=d[m.status];h&&u.push({path:m.path,status:h})}for(let m of l)u.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return u.sort((m,h)=>Ie(m.path,h.path))}function Ni(e){let t=new Map;for(let r of e.entries)if(r.stage>0){let o=t.get(r.path);o||(o=new Set,t.set(r.path,o)),o.add(r.stage)}let n=[];for(let[r,o]of t){let s,i=o.has(1),a=o.has(2),c=o.has(3);a&&c?s=i?"both modified":"both added":i&&!a&&!c?s="both deleted":i&&c?s="deleted by us":i&&a?s="deleted by them":a&&!i&&!c?s="added by us":c&&!i&&!a?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Ie(r.path,o.path))}function _i(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 uf(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Cm(e,t){return`${e}:`.padEnd(17)+t}async function Rn(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,i=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),a=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await B(e,i);if(!c)return{upstream:a,ahead:0,behind:0,gone:!0};let f=await B(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:a,ahead:0,behind:0,gone:!1};let{ahead:l,behind:d}=await Hi(e,f,c);return{upstream:a,ahead:l,behind:d,gone:!1}}function mf(e,t){if(t){if(e.gone)return`[${e.upstream}: gone]`;if(e.ahead===0&&e.behind===0)return`[${e.upstream}]`;let r=[];return e.ahead>0&&r.push(`ahead ${e.ahead}`),e.behind>0&&r.push(`behind ${e.behind}`),`[${e.upstream}: ${r.join(", ")}]`}if(e.gone)return"[gone]";if(e.ahead===0&&e.behind===0)return"";let n=[];return e.ahead>0&&n.push(`ahead ${e.ahead}`),e.behind>0&&n.push(`behind ${e.behind}`),`[${n.join(", ")}]`}function fr(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
112
112
  (use "git branch --unset-upstream" to fixup)
113
113
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
114
114
  `;if(e.ahead>0&&e.behind===0){let r=e.ahead===1?"commit":"commits";return`Your branch is ahead of '${e.upstream}' by ${e.ahead} ${r}.
@@ -118,19 +118,19 @@ GIT_AUTHOR_DATE='${o}'
118
118
  `}let n=`Your branch and '${e.upstream}' have diverged,
119
119
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
120
120
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
121
- `}Ae();fn();tt();async function lo(e){let t=await et(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await B(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function xn(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
121
+ `}Ae();fn();tt();async function uo(e){let t=await et(e,"HEAD");for(let n=t.length-1;n>=0;n--){let r=t[n];if(!r)continue;let o=r.message.match(/^checkout: moving from (.+) to (.+)$/);if(o?.[1]){let s=o[1],i=`refs/heads/${s}`,a=await B(e,i);if(a)return{name:s,refName:i,hash:a}}}return null}async function xn(e){let t="";return await B(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
122
122
  `),await B(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
123
- `),await cr(e),t}function Cm(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(`
123
+ `),await cr(e),t}function Pm(e){let t=new Set,n=[];for(let r of e.entries)r.stage>0&&!t.has(r.path)&&(t.add(r.path),n.push(`${r.path}: needs merge`));return n.sort(),n.length>0?`${n.join(`
124
124
  `)}
125
- `:""}function qn(e){return e.entries.some(t=>t.stage>0)?{stdout:Cm(e),stderr:`error: you need to resolve your current index first
126
- `,exitCode:1}:null}async function uo(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");if(r)return Pm(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?G(`error: path '${t[0]}' is unmerged
125
+ `:""}function qn(e){return e.entries.some(t=>t.stage>0)?{stdout:Pm(e),stderr:`error: you need to resolve your current index first
126
+ `,exitCode:1}:null}async function mo(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");if(r)return $m(e,t,n,r);let o=await z(e),s=t.map(a=>Ue(a,n)),i=o.entries.filter(a=>a.stage===0&&Ee(s,a.path));if(i.length===0)return o.entries.some(c=>c.stage>0&&Ee(s,c.path))?G(`error: path '${t[0]}' is unmerged
127
127
  `):G(`error: pathspec '${t[0]}' did not match any file(s) known to git
128
- `);for(let a of i)await dt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function Pm(e,t,n,r){let o=await fe(e,r),s=await z(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)Ee(i,c)&&a.push(c);if(a.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
129
- `);for(let c of a){let f=o.get(c);f&&(await dt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Ct(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Se()}))}return await de(e,s),{stdout:"",stderr:"",exitCode:0}}async function mo(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 G(`error: pathspec '${t[0]}' did not match any file(s) known to git
128
+ `);for(let a of i)await dt(e,{path:a.path,hash:a.hash,mode:a.mode});return{stdout:"",stderr:"",exitCode:0}}async function $m(e,t,n,r){let o=await fe(e,r),s=await z(e),i=t.map(c=>Ue(c,n)),a=[];for(let[c]of o)Ee(i,c)&&a.push(c);if(a.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
129
+ `);for(let c of a){let f=o.get(c);f&&(await dt(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Ct(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:Se()}))}return await de(e,s),{stdout:"",stderr:"",exitCode:0}}async function ho(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 G(`error: pathspec '${t[0]}' did not match any file(s) known to git
130
130
  `);for(let f of c){let l=i.entries.find(m=>m.path===f&&m.stage===r),d=!l&&i.entries.find(m=>m.path===f&&m.stage===0),u=l||d;if(u)await dt(e,{path:u.path,hash:u.hash,mode:u.mode});else if(s){let m=v(e.workTree,f);await e.fs.exists(m)&&await e.fs.rm(m)}else if(i.entries.some(h=>h.path===f&&h.stage>0))return G(`error: path '${f}' does not have ${r===2?"our":"their"} version
131
131
  `)}return{stdout:"",stderr:"",exitCode:0}}async function lr(e,t,n){if(!e.workTree)return"";let r=await Ke(e,t),o=new Map;for(let c of r)o.set(c.path,c.hash);let s=new Map;for(let c of n.entries)c.stage===0&&s.set(c.path,c.hash);let i=new Map;for(let[c]of s){let f=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 pt("blob",d))}}else i.set(c,null)}let a=[];for(let[c,f]of o){let l=s.get(c);if(l===void 0){a.push(`D ${c}`);continue}let d=i.get(c);d===null?a.push(`D ${c}`):(l!==f||d!==void 0&&d!==f)&&a.push(`M ${c}`)}for(let[c]of s)o.has(c)||i.get(c)!=null&&a.push(`A ${c}`);return a.length===0?"":(a.sort((c,f)=>{let l=c.slice(2),d=f.slice(2);return l<d?-1:l>d?1:0}),`${a.join(`
132
132
  `)}
133
- `)}var mf=5;function $m(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>mf?mf-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
133
+ `)}var hf=5;function Om(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>hf?hf-1:t,i=e.slice(0,o).map(c=>` ${X(c.hash)} ${c.subject}`),a=t-o;return a>0&&i.push(` ... and ${a} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
134
134
  any of your branches:
135
135
 
136
136
  ${i.join(`
@@ -141,10 +141,10 @@ to do so with:
141
141
 
142
142
  git branch <new-branch-name> ${X(e[0].hash)}
143
143
 
144
- `}async function Ni(e,t){let n=await j(e,t);return`Previous HEAD position was ${X(t)} ${ue(n.message)}
145
- `}async function ho(e,t,n){let r=await Ai(e,t,{targetHash:n});return r.length>0?$m(r):t!==n?Ni(e,t):""}async function dr(e,t,n,r,o,s){let i=await Q(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
146
- `,exitCode:0};let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),d=(await j(e,r)).tree,u=null;if(f&&(u=(await j(e,f)).tree),u!==d){let x=await Fn(e,u,d,a);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await de(e,a),await Ne(e,x.worktreeOps)}let m="";i?.type==="direct"&&f&&(m=await ho(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??ee;await Xe(e,"HEAD",n),await yt(e);let p=await xn(e);await ce(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await lr(e,d,a),w=await we(e),y=await Rn(e,w,t);return y&&(g+=fr(y)),{stdout:g,stderr:`${m}Switched to branch '${t}'
147
- ${p}`,exitCode:0}}async function zn(e,t,n,r,o){let s=await z(e),i=qn(s);if(i)return i;let a=await Y(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Fn(e,l,f,s);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await de(e,s),await Ne(e,x.worktreeOps)}let d=await Q(e),u=d?.type==="direct"&&a===t;if(await Z(e,"HEAD",t),!u){await Zc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ee;await ce(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let m=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=X(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await ho(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
144
+ `}async function Fi(e,t){let n=await j(e,t);return`Previous HEAD position was ${X(t)} ${ue(n.message)}
145
+ `}async function po(e,t,n){let r=await Di(e,t,{targetHash:n});return r.length>0?Om(r):t!==n?Fi(e,t):""}async function dr(e,t,n,r,o,s){let i=await Q(e);if(i?.type==="symbolic"&&i.target===n)return{stdout:"",stderr:`Already on '${t}'
146
+ `,exitCode:0};let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),d=(await j(e,r)).tree,u=null;if(f&&(u=(await j(e,f)).tree),u!==d){let x=await Fn(e,u,d,a);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");a={version:2,entries:x.newEntries},await de(e,a),await Ne(e,x.worktreeOps)}let m="";i?.type==="direct"&&f&&(m=await po(e,f,r));let h=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):f??ee;await Xe(e,"HEAD",n),await yt(e);let p=await xn(e);await ce(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:r,isBranchCheckout:!0});let g=await lr(e,d,a),w=await we(e),y=await Rn(e,w,t);return y&&(g+=fr(y)),{stdout:g,stderr:`${m}Switched to branch '${t}'
147
+ ${p}`,exitCode:0}}async function zn(e,t,n,r,o){let s=await z(e),i=qn(s);if(i)return i;let a=await Y(e),c=await j(e,t),f=c.tree,l=null;if(a&&(l=(await j(e,a)).tree),l!==f){let x=await Fn(e,l,f,s);if(!x.success)return x.errorOutput??G("error: checkout would overwrite local changes");s={version:2,entries:x.newEntries},await de(e,s),await Ne(e,x.worktreeOps)}let d=await Q(e),u=d?.type==="direct"&&a===t;if(await Z(e,"HEAD",t),!u){await Jc(e,t);let x=d?.type==="symbolic"?d.target.replace(/^refs\/heads\//,""):a??ee;await ce(e,n,"HEAD",a,t,`checkout: moving from ${x} to ${t}`)}let m=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:t,isBranchCheckout:!1});let h=X(t),p=ue(c.message),g=d?.type==="direct",w="";return g&&a&&a!==t&&(w+=await po(e,a,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
148
148
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
149
149
 
150
150
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -163,63 +163,63 @@ Or undo this operation with:
163
163
  Turn off this advice by setting config variable advice.detachedHead to false
164
164
 
165
165
  HEAD is now at ${h} ${p}
166
- `,w+=m,{stdout:await lr(e,f,s),stderr:w,exitCode:0}}async function Om(e,t){if(t.startsWith("refs/remotes/")){if(!await B(e,t))return null;let s=t.slice(13).split("/");if(s.length<2)return null;let i=s[0],a=s.slice(1).join("/");return{remote:i,branch:a,ref:t}}let n=`refs/remotes/${t}`;if(await B(e,n)){let o=t.split("/");if(o.length<2)return null;let s=o[0],i=o.slice(1).join("/");return{remote:s,branch:i,ref:n}}return null}async function po(e,t,n){let r=await Om(e,n);if(!r||await xe(e,"branch.autoSetupMerge")==="false")return"";let s=await we(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await Je(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
167
- `}async function go(e,t){let n=await pe(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}ae();me();ge();sn();var hf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),ds={stdout:`You need to start by "git bisect start"
168
- `,stderr:"",exitCode:1};async function _i(e){let t=await Oe(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Y(e);return n||I("no current commit")}function pf(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[q.string().name("subcommand").describe("Subcommand or custom term").optional(),q.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
169
- `,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:vm(a,o.env,t,s,i)}});Im(n,t),Sm(n,t),Am(n,t),Hm(n,t),Mm(n,t),jm(n,t),Lm(n,t),_m(n,t),Fm(n,t)}function Im(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":V.string().describe("Alternate term for new/bad"),"term-bad":V.string().describe("Alternate term for new/bad"),"term-old":V.string().describe("Alternate term for old/good"),"term-good":V.string().describe("Alternate term for old/good"),"no-checkout":$().describe("Do not checkout the bisection commit"),"first-parent":$().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return hf.has(a)?I(`'${a}' is not a valid term`):hf.has(c)?I(`'${c}' is not a valid term`):a===c?I("'bad' and 'good' terms must be different"):gf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function gf(e,t,n,r,o,s,i,a){await $t(e)&&await oo(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Y(e)??"HEAD",await De(e,"BISECT_START",f+`
166
+ `,w+=m,{stdout:await lr(e,f,s),stderr:w,exitCode:0}}async function Im(e,t){if(t.startsWith("refs/remotes/")){if(!await B(e,t))return null;let s=t.slice(13).split("/");if(s.length<2)return null;let i=s[0],a=s.slice(1).join("/");return{remote:i,branch:a,ref:t}}let n=`refs/remotes/${t}`;if(await B(e,n)){let o=t.split("/");if(o.length<2)return null;let s=o[0],i=o.slice(1).join("/");return{remote:s,branch:i,ref:n}}return null}async function go(e,t,n){let r=await Im(e,n);if(!r||await xe(e,"branch.autoSetupMerge")==="false")return"";let s=await we(e),i=`branch "${t}"`;return s[i]||(s[i]={}),s[i].remote=r.remote,s[i].merge=`refs/heads/${r.branch}`,await Je(e,s),`branch '${t}' set up to track '${r.remote}/${r.branch}'.
167
+ `}async function wo(e,t){let n=await pe(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}ae();me();ge();sn();var pf=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),us={stdout:`You need to start by "git bisect start"
168
+ `,stderr:"",exitCode:1};async function Ui(e){let t=await Oe(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Y(e);return n||I("no current commit")}function gf(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[q.string().name("subcommand").describe("Subcommand or custom term").optional(),q.string().name("rest").describe("Additional arguments").optional().variadic()],handler:async(r,o)=>{let s=r.subcommand;if(!s)return{stdout:"",stderr:`usage: git bisect [start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]
169
+ `,exitCode:1};let i=r.rest??[],a=await W(o.fs,o.cwd,t);return M(a)?a:Am(a,o.env,t,s,i)}});Sm(n,t),Tm(n,t),Hm(n,t),Dm(n,t),jm(n,t),Gm(n,t),Nm(n,t),Fm(n,t),Um(n,t)}function Sm(e,t){e.command("start",{description:"Start bisecting",args:[q.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":V.string().describe("Alternate term for new/bad"),"term-bad":V.string().describe("Alternate term for new/bad"),"term-old":V.string().describe("Alternate term for old/good"),"term-good":V.string().describe("Alternate term for old/good"),"no-checkout":$().describe("Do not checkout the bisection commit"),"first-parent":$().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i&&!n["no-checkout"])return i;let a=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return pf.has(a)?I(`'${a}' is not a valid term`):pf.has(c)?I(`'${c}' is not a valid term`):a===c?I("'bad' and 'good' terms must be different"):wf(s,r.env,t,n.revs??[],a,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function wf(e,t,n,r,o,s,i,a){await $t(e)&&await io(e);let c=await Q(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Y(e)??"HEAD",await De(e,"BISECT_START",f+`
170
170
  `),await De(e,"BISECT_TERMS",`${o}
171
171
  ${s}
172
172
  `),await De(e,"BISECT_NAMES",`
173
- `),a&&await De(e,"BISECT_FIRST_PARENT",""),i){let u=await Y(e);u&&await De(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await wt(e,u);if(M(m))return m;await Z(e,`refs/bisect/${o}`,m);let h=await j(e,m);await Ot(e,`# ${o}: [${m}] ${ue(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await wt(e,g);if(M(w))return w;await Z(e,`refs/bisect/${s}-${w}`,w);let y=await j(e,w);await Ot(e,`# ${s}: [${w}] ${ue(y.message)}`)}}let l=r.map(u=>`'${u}'`),d=l.length>0?` ${l.join(" ")}`:"";return await Ot(e,`git bisect start${d}`),us(e,t,n)}function Sm(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[q.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:Tm(s,o.env,t,n,r.rev)}})}async function Tm(e,t,n,r,o){if(!await $t(e))return ds;let s=await fs(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ls(e,t,n,i,s,o)}async function vm(e,t,n,r,o){if(!await $t(e))return ds;let s=await fs(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
174
- `,exitCode:1}:ls(e,t,n,r,s,o[0])}async function ls(e,t,n,r,o,s){let i;if(s){let f=await wt(e,s);if(M(f))return f;i=f}else{let f=await _i(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await Z(e,`refs/bisect/${o.termBad}`,i):await Z(e,`refs/bisect/${o.termGood}-${i}`,i),await Ot(e,`# ${r}: [${i}] ${c}`),await Ot(e,`git bisect ${r} ${i}`),us(e,t,n)}function Am(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[q.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return ds;let i=n.revs??[];if(i.length===0){let a=await _i(s);if(M(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let l=await wt(s,a);if(M(l))return l;c=l}await Z(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await Ot(s,`# skip: [${c}] ${ue(f.message)}`),await Ot(s,`git bisect skip ${c}`)}return us(s,r.env,t)}})}function Hm(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[q.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await $t(s)?Dm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
175
- `,stderr:"",exitCode:0}}})}async function Dm(e,t,n,r){let o=(await Oe(e,"BISECT_START"))?.trim()??"";if(await oo(e),r){let s=await wt(e,r);return M(s)?s:zn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return dr(e,o,s,i,t,n);let a=await Be(e,o);if(a)return zn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Mm(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await $t(s)?{stdout:await Oe(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
176
- `,exitCode:1}}})}function jm(e,t){e.command("replay",{description:"Replay a bisect log",args:[q.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile:v(r.cwd,n.logfile);if(!await r.fs.exists(i))return I(`cannot open '${n.logfile}': No such file or directory`);let a=await r.fs.readFile(i);return Gm(s,r.env,t,a)}})}async function Gm(e,t,n,r){await $t(e)&&await oo(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
177
- `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];d=await gf(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ls(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ls(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let u of l?l.split(/\s+/):[]){await Z(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Ot(e,`# skip: [${u}] ${ue(m.message)}`),await Ot(e,`git bisect skip ${u}`)}d=await us(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Lm(e,t){e.command("run",{description:"Bisect by running a command",args:[q.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return ds;if(!r.exec)return I("bisect run requires shell execution support");let i=n.cmd.join(" ");return Nm(s,r.env,t,i,r.exec,r.cwd)}})}async function Nm(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
178
- `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await _i(e);if(M(u))return u;await Z(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Ot(e,`# skip: [${u}] ${ue(m.message)}`),await Ot(e,`git bisect skip ${u}`);let h=await us(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
179
- `,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await so(e),l=c===0?f.termGood:f.termBad,d=await ls(e,t,n,l,f,void 0);if(i+=d.stdout,d.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
180
- `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function _m(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":$().describe("Show the term for the old state"),"term-bad":$().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return{stdout:"",stderr:`error: no terms defined
181
- `,exitCode:1};let{termBad:i,termGood:a}=await fs(s);return n["term-good"]?{stdout:`${a}
173
+ `),a&&await De(e,"BISECT_FIRST_PARENT",""),i){let u=await Y(e);u&&await De(e,"BISECT_HEAD",u)}if(r.length>0){let u=r[0],m=await wt(e,u);if(M(m))return m;await Z(e,`refs/bisect/${o}`,m);let h=await j(e,m);await Ot(e,`# ${o}: [${m}] ${ue(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await wt(e,g);if(M(w))return w;await Z(e,`refs/bisect/${s}-${w}`,w);let y=await j(e,w);await Ot(e,`# ${s}: [${w}] ${ue(y.message)}`)}}let l=r.map(u=>`'${u}'`),d=l.length>0?` ${l.join(" ")}`:"";return await Ot(e,`git bisect start${d}`),ms(e,t,n)}function Tm(e,t){for(let n of["bad","good","new","old"])e.command(n,{description:n==="bad"||n==="new"?"Mark a commit as bad/new":"Mark a commit as good/old",args:[q.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:vm(s,o.env,t,n,r.rev)}})}async function vm(e,t,n,r,o){if(!await $t(e))return us;let s=await ls(e),i=r==="bad"||r==="new"?s.termBad:s.termGood;return ds(e,t,n,i,s,o)}async function Am(e,t,n,r,o){if(!await $t(e))return us;let s=await ls(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
174
+ `,exitCode:1}:ds(e,t,n,r,s,o[0])}async function ds(e,t,n,r,o,s){let i;if(s){let f=await wt(e,s);if(M(f))return f;i=f}else{let f=await Ui(e);if(M(f))return f;i=f}let a=await j(e,i),c=ue(a.message);return r===o.termBad?await Z(e,`refs/bisect/${o.termBad}`,i):await Z(e,`refs/bisect/${o.termGood}-${i}`,i),await Ot(e,`# ${r}: [${i}] ${c}`),await Ot(e,`git bisect ${r} ${i}`),ms(e,t,n)}function Hm(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[q.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return us;let i=n.revs??[];if(i.length===0){let a=await Ui(s);if(M(a))return a;i.push(a)}for(let a of i){let c;if(a.length===40&&/^[0-9a-f]+$/.test(a))c=a;else{let l=await wt(s,a);if(M(l))return l;c=l}await Z(s,`refs/bisect/skip-${c}`,c);let f=await j(s,c);await Ot(s,`# skip: [${c}] ${ue(f.message)}`),await Ot(s,`git bisect skip ${c}`)}return ms(s,r.env,t)}})}function Dm(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[q.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await $t(s)?Mm(s,r.env,t,n.commit):{stdout:`We are not bisecting.
175
+ `,stderr:"",exitCode:0}}})}async function Mm(e,t,n,r){let o=(await Oe(e,"BISECT_START"))?.trim()??"";if(await io(e),r){let s=await wt(e,r);return M(s)?s:zn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,i=await B(e,s);if(i)return dr(e,o,s,i,t,n);let a=await Be(e,o);if(a)return zn(e,a,t,n)}return{stdout:"",stderr:"",exitCode:0}}function jm(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;return await $t(s)?{stdout:await Oe(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
176
+ `,exitCode:1}}})}function Gm(e,t){e.command("replay",{description:"Replay a bisect log",args:[q.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.logfile.startsWith("/")?n.logfile: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 Lm(s,r.env,t,a)}})}async function Lm(e,t,n,r){await $t(e)&&await io(e);let o={termBad:"bad",termGood:"good"},s="";for(let i of r.split(`
177
+ `)){let a=i.trim();if(!a||a.startsWith("#"))continue;let c=a.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],l=c[2].trim(),d;if(f==="start"){let u=l?l.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];d=await wf(e,t,n,u,"bad","good",!1,!1)}else if(f==="bad"||f==="new")d=await ds(e,t,n,"bad",o,l||void 0);else if(f==="good"||f==="old")d=await ds(e,t,n,"good",o,l||void 0);else if(f==="skip"){for(let u of l?l.split(/\s+/):[]){await Z(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Ot(e,`# skip: [${u}] ${ue(m.message)}`),await Ot(e,`git bisect skip ${u}`)}d=await ms(e,t,n)}else continue;if(d.exitCode!==0)return d;s+=d.stdout}return{stdout:s,stderr:"",exitCode:0}}function Nm(e,t){e.command("run",{description:"Bisect by running a command",args:[q.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return us;if(!r.exec)return I("bisect run requires shell execution support");let i=n.cmd.join(" ");return _m(s,r.env,t,i,r.exec,r.cwd)}})}async function _m(e,t,n,r,o,s){let i="";for(;;){i+=`running '${r}'
178
+ `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let u=await Ui(e);if(M(u))return u;await Z(e,`refs/bisect/skip-${u}`,u);let m=await j(e,u);await Ot(e,`# skip: [${u}] ${ue(m.message)}`),await Ot(e,`git bisect skip ${u}`);let h=await ms(e,t,n);if(i+=h.stdout,h.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
179
+ `,{stdout:i,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:i,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await oo(e),l=c===0?f.termGood:f.termBad,d=await ds(e,t,n,l,f,void 0);if(i+=d.stdout,d.stdout.includes("is the first bad commit"))return i+=`bisect found first bad commit
180
+ `,{stdout:i,stderr:"",exitCode:0};if(d.exitCode!==0)return{stdout:i,stderr:d.stderr,exitCode:d.exitCode}}}function Fm(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":$().describe("Show the term for the old state"),"term-bad":$().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!await $t(s))return{stdout:"",stderr:`error: no terms defined
181
+ `,exitCode:1};let{termBad:i,termGood:a}=await ls(s);return n["term-good"]?{stdout:`${a}
182
182
  `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${i}
183
183
  `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${a} for the old state
184
184
  and ${i} for the new state.
185
- `,stderr:"",exitCode:0}}})}function Fm(e,t){for(let n of["visualize","view"])e.command(n,{description:"Show remaining suspects in git log",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=s;if(!await $t(i))return ds;let a=await so(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
186
- `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(ar(),Xc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${X(l.hash)} ${ue(l.commit.message)}
187
- `;return{stdout:f,stderr:"",exitCode:0}}})}async function us(e,t,n){let r=await so(e);return!r.badHash||r.goodHashes.length===0?{stdout:Qc(r),stderr:"",exitCode:0}:(await De(e,"BISECT_ANCESTORS_OK",""),Um(e,t,n,r))}async function Um(e,t,n,r){let o=await Jc(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
188
- `,exitCode:1};if(o.found){let s=await tf(e,o.hash);return await Ot(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
185
+ `,stderr:"",exitCode:0}}})}function Um(e,t){for(let n of["visualize","view"])e.command(n,{description:"Show remaining suspects in git log",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=s;if(!await $t(i))return us;let a=await oo(i);if(!a.badHash||a.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
186
+ `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(ar(),Zc)),f="";for await(let l of c(i,a.badHash,{exclude:a.goodHashes}))f+=`${X(l.hash)} ${ue(l.commit.message)}
187
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function ms(e,t,n){let r=await oo(e);return!r.badHash||r.goodHashes.length===0?{stdout:ef(r),stderr:"",exitCode:0}:(await De(e,"BISECT_ANCESTORS_OK",""),Bm(e,t,n,r))}async function Bm(e,t,n,r){let o=await Qc(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
188
+ `,exitCode:1};if(o.found){let s=await nf(e,o.hash);return await Ot(e,`# first bad commit: [${o.hash}] ${o.subject}`),{stdout:s,stderr:"",exitCode:0}}if(o.onlySkippedLeft){let s=`There are only 'skip'ped commits left to test.
189
189
  The first bad commit could be any of:
190
190
  `;for(let i of r.skipHashes)s+=i+`
191
191
  `;return r.badHash&&(s+=r.badHash+`
192
192
  `),s+=`We cannot bisect more!
193
193
  `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await De(e,"BISECT_HEAD",o.hash);else{let s=await zn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await De(e,"BISECT_EXPECTED_REV",o.hash+`
194
- `),{stdout:ef(o),stderr:"",exitCode:0}}oe();ae();function _t(e){if(e.length===0)return[];let t=e.split(`
194
+ `),{stdout:tf(o),stderr:"",exitCode:0}}oe();ae();function _t(e){if(e.length===0)return[];let t=e.split(`
195
195
  `);return t[t.length-1]===""&&t.pop(),t}function Rt(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
196
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Bm=4,wf=1024,wo=100,Eo=0,bo=1,Sr=2;function Ui(e){let t=1;for(;t*t<e;)t++;return t}function Wm(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 qm(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>wo&&(n=t-wo),r-t>wo&&(r=t+wo);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Eo)o++;else if(f===Sr)s++;else break}if(o===0)return!1;let i=0,a=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===Eo)i++;else if(f===Sr)a++;else break}return i===0?!1:(i+=o,a+=s,a*Bm<a+i)}function zm(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),u=Math.min(Ui(t),wf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=Eo:w>=u?l[g]=Sr:l[g]=bo}let m=Math.min(Ui(r),wf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=Eo:w>=m?d[g]=Sr:d[g]=bo}let h=[];for(let g=s;g<=i;g++)l[g]===bo||l[g]===Sr&&!bf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===bo||d[g]===Sr&&!bf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Kn=20,yf=4,Km=256,Vm=256,yo=2147483647;function kt(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,m=n-s,h=u-m&1,p=u,g=u,w=m,y=m;i[u]=t,a[m]=n;for(let x=1;;x++){let b=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let E=g;E>=p;E-=2){let R;kt(i,E-1)>=kt(i,E+1)?R=kt(i,E-1)+1:R=kt(i,E+1);let k=R,C=R-E;for(;R<n&&C<s&&e[R]===r[C];)R++,C++;if(R-k>Kn&&(b=!0),i[E]=R,h&&w<=E&&E<=y&&kt(a,E)<=R)return{i1:R,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=yo:++w,y<d?a[++y+1]=yo:--y;for(let E=y;E>=w;E-=2){let R;kt(a,E-1)<kt(a,E+1)?R=kt(a,E-1):R=kt(a,E+1)-1;let k=R,C=R-E;for(;R>t&&C>o&&e[R-1]===r[C-1];)R--,C--;if(k-R>Kn&&(b=!0),a[E]=R,!h&&p<=E&&E<=g&&R<=kt(i,E))return{i1:R,i2:C,minLo:!0,minHi:!0}}if(!c){if(b&&x>Km){let E=0,R=null;for(let k=g;k>=p;k-=2){let C=k>u?k-u:u-k,P=kt(i,k),T=P-k,D=P-t+(T-o)-C;if(D>yf*x&&D>E&&t+Kn<=P&&P<n&&o+Kn<=T&&T<s){let O=!0;for(let N=1;N<=Kn;N++)if(e[P-N]!==r[T-N]){O=!1;break}O&&(E=D,R={i1:P,i2:T,minLo:!0,minHi:!1})}}if(R)return R;E=0,R=null;for(let k=y;k>=w;k-=2){let C=k>m?k-m:m-k,P=kt(a,k),T=P-k,D=n-P+(s-T)-C;if(D>yf*x&&D>E&&t<P&&P<=n-Kn&&o<T&&T<=s-Kn){let O=!0;for(let N=0;N<Kn;N++)if(e[P+N]!==r[T+N]){O=!1;break}O&&(E=D,R={i1:P,i2:T,minLo:!1,minHi:!0})}}if(R)return R}if(x>=f){let E=-1,R=-1;for(let P=g;P>=p;P-=2){let T=Math.min(kt(i,P),n),D=T-P;s<D&&(T=s+P,D=s),E<T+D&&(E=T+D,R=T)}let k=yo,C=yo;for(let P=y;P>=w;P-=2){let T=Math.max(t,kt(a,P)),D=T-P;D<o&&(T=o+P,D=o),T+D<k&&(k=T+D,C=T)}return n+s-k<E-(t+o)?{i1:R,i2:E-R,minLo:!0,minHi:!1}:{i1:C,i2:k-C,minLo:!1,minHi:!0}}}}}function Bi(e,t,n,r,o,s,i,a,c,f,l,d,u,m){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=Ym(e,t,n,r,o,s,l,d,u,m);Bi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,m),Bi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,m)}}function Xm(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 Ef=200,kf=20,Rf=100,Zm=1,Jm=21,Qm=-30,eh=6,th=-4,nh=10,rh=24,sh=17,oh=23,ih=17,ah=60;function Fi(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===32)t+=1;else if(r===9)t+=8-t%8;else if(!(r===10||r===13||r===11||r===12))return t;if(t>=Ef)return Ef}return-1}function xf(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=Fi(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Fi(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===kf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Fi(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===kf){r.postIndent=0;break}return r}function Cf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Zm),e.endOfFile&&(t.penalty+=Jm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=Qm*r,t.penalty+=eh*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?nh:th:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?sh:rh:t.penalty+=s?ih:oh))}function ch(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return ah*n+(e.penalty-t.penalty)}function Pf(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let l=(d,u)=>t[d]===t[u];for(;;){if(a!==i){let d,u,m;do{for(d=a-i,u=-1;i>0&&l(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=a,f>c&&(u=a);!(a>=r||!l(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(d!==a-i);if(a!==m)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(a-d-1>g&&(g=a-d-1),a-Rf>g&&(g=a-Rf);g<=a;g++){let w={effectiveIndent:0,penalty:0},y=xf(n,r,g);Cf(y,w);let x=xf(n,r,g-d);Cf(x,w),(h===-1||ch(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function Wi(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=Wm(e,t),{dstart:f,dend1:l,dend2:d}=qm(i,n,a,r);if(f>l)for(let u=f;u<r-(n-1-l);u++)s[u]=1;else if(f>d)for(let u=f;u<n-(r-1-d);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=zm(i,n,a,r,c,f,l,d,o,s);if(m>0&&p>0){let g=new Array(m);for(let R=0;R<m;R++)g[R]=i[u[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=a[h[R]];let y={},x={},b=m+p+3,E=Math.max(Vm,Ui(b));Bi(g,0,m,w,0,p,o,s,u,h,y,x,!1,E)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[u[g]]=1;Pf(o,i,e,n,s,r),Pf(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function ct(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=Wi(e,t);return Xm(e,t,o,s)}var fh=3;function lh(e,t=fh){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=>dh(e,a.start,a.end))}function dh(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let l=t;l<=n;l++){let d=e[l];if(d)switch(d.type){case"keep":c||(r=d.oldLineNo,c=!0),f||(s=d.newLineNo,f=!0),o++,i++,a.push({type:"context",content:d.line});break;case"delete":c||(r=d.oldLineNo,c=!0),o++,a.push({type:"delete",content:d.line});break;case"insert":f||(s=d.newLineNo,f=!0),i++,a.push({type:"insert",content:d.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="insert"){r=d.newLineNo>1?d.newLineNo-1:0;break}}if(i===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="delete"){s=d.oldLineNo>1?d.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function ko(e){return e?e.length<40?e:X(e):"0000000"}function $f(e,t,n,r,o,s){let{path:i,oldMode:a,newMode:c}=t;e.push(`diff --git a/${i} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${i}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(e.push(`old mode ${a}`),e.push(`new mode ${c}`))}function uh(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,l=e.renameTo??r,d=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if($f(m,e,l,d,u,f),o!==s){if(a||c){let h=ko(a),p=ko(c);d||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${l} differ`):d?m.push(`Binary files /dev/null and b/${l} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${l} differ`)}return`${m.join(`
196
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Wm=4,bf=1024,bo=100,ko=0,yo=1,Tr=2;function Wi(e){let t=1;for(;t*t<e;)t++;return t}function qm(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let i=0;i<e.length;i++){let a=e[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,o[i]=c}for(let i=0;i<t.length;i++){let a=t[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,s[i]=c}return{classes1:o,classes2:s,classInfo:r}}function zm(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let i=o,a=0,c=s-i;for(;a<c&&e[t-1-a]===n[r-1-a];)a++;return{dstart:i,dend1:t-a-1,dend2:r-a-1}}function yf(e,t,n,r){t-n>bo&&(n=t-bo),r-t>bo&&(r=t+bo);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===ko)o++;else if(f===Tr)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===ko)i++;else if(f===Tr)a++;else break}return i===0?!1:(i+=o,a+=s,a*Wm<a+i)}function Km(e,t,n,r,o,s,i,a,c,f){let l=new Uint8Array(t),d=new Uint8Array(r),u=Math.min(Wi(t),bf);for(let g=s;g<=i;g++){let w=o[e[g]].len2;w===0?l[g]=ko:w>=u?l[g]=Tr:l[g]=yo}let m=Math.min(Wi(r),bf);for(let g=s;g<=a;g++){let w=o[n[g]].len1;w===0?d[g]=ko:w>=m?d[g]=Tr:d[g]=yo}let h=[];for(let g=s;g<=i;g++)l[g]===yo||l[g]===Tr&&!yf(l,g,s,i)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=a;g++)d[g]===yo||d[g]===Tr&&!yf(d,g,s,a)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Kn=20,Ef=4,Vm=256,Ym=256,Eo=2147483647;function kt(e,t){return e[t]??0}function Xm(e,t,n,r,o,s,i,a,c,f){let l=t-s,d=n-o,u=t-o,m=n-s,h=u-m&1,p=u,g=u,w=m,y=m;i[u]=t,a[m]=n;for(let x=1;;x++){let b=!1;p>l?i[--p-1]=-1:++p,g<d?i[++g+1]=-1:--g;for(let E=g;E>=p;E-=2){let R;kt(i,E-1)>=kt(i,E+1)?R=kt(i,E-1)+1:R=kt(i,E+1);let k=R,C=R-E;for(;R<n&&C<s&&e[R]===r[C];)R++,C++;if(R-k>Kn&&(b=!0),i[E]=R,h&&w<=E&&E<=y&&kt(a,E)<=R)return{i1:R,i2:C,minLo:!0,minHi:!0}}w>l?a[--w-1]=Eo:++w,y<d?a[++y+1]=Eo:--y;for(let E=y;E>=w;E-=2){let R;kt(a,E-1)<kt(a,E+1)?R=kt(a,E-1):R=kt(a,E+1)-1;let k=R,C=R-E;for(;R>t&&C>o&&e[R-1]===r[C-1];)R--,C--;if(k-R>Kn&&(b=!0),a[E]=R,!h&&p<=E&&E<=g&&R<=kt(i,E))return{i1:R,i2:C,minLo:!0,minHi:!0}}if(!c){if(b&&x>Vm){let E=0,R=null;for(let k=g;k>=p;k-=2){let C=k>u?k-u:u-k,P=kt(i,k),T=P-k,D=P-t+(T-o)-C;if(D>Ef*x&&D>E&&t+Kn<=P&&P<n&&o+Kn<=T&&T<s){let O=!0;for(let N=1;N<=Kn;N++)if(e[P-N]!==r[T-N]){O=!1;break}O&&(E=D,R={i1:P,i2:T,minLo:!0,minHi:!1})}}if(R)return R;E=0,R=null;for(let k=y;k>=w;k-=2){let C=k>m?k-m:m-k,P=kt(a,k),T=P-k,D=n-P+(s-T)-C;if(D>Ef*x&&D>E&&t<P&&P<=n-Kn&&o<T&&T<=s-Kn){let O=!0;for(let N=0;N<Kn;N++)if(e[P+N]!==r[T+N]){O=!1;break}O&&(E=D,R={i1:P,i2:T,minLo:!1,minHi:!0})}}if(R)return R}if(x>=f){let E=-1,R=-1;for(let P=g;P>=p;P-=2){let T=Math.min(kt(i,P),n),D=T-P;s<D&&(T=s+P,D=s),E<T+D&&(E=T+D,R=T)}let k=Eo,C=Eo;for(let P=y;P>=w;P-=2){let T=Math.max(t,kt(a,P)),D=T-P;D<o&&(T=o+P,D=o),T+D<k&&(k=T+D,C=T)}return n+s-k<E-(t+o)?{i1:R,i2:E-R,minLo:!0,minHi:!1}:{i1:C,i2:k-C,minLo:!1,minHi:!0}}}}}function qi(e,t,n,r,o,s,i,a,c,f,l,d,u,m){for(;t<n&&o<s&&e[t]===r[o];)t++,o++;for(;t<n&&o<s&&e[n-1]===r[s-1];)n--,s--;if(t===n)for(let h=o;h<s;h++)a[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)i[c[h]]=1;else{let h=Xm(e,t,n,r,o,s,l,d,u,m);qi(e,t,h.i1,r,o,h.i2,i,a,c,f,l,d,h.minLo,m),qi(e,h.i1,n,r,h.i2,s,i,a,c,f,l,d,h.minHi,m)}}function Zm(e,t,n,r){let o=[],s=0,i=0,a=1,c=1;for(;s<e.length||i<t.length;){if(s<e.length&&i<t.length&&!n[s]&&!r[i]){o.push({type:"keep",line:e[s]??"",oldLineNo:a++,newLineNo:c++}),s++,i++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:a++,newLineNo:0}),s++;for(;i<t.length&&r[i];)o.push({type:"insert",line:t[i]??"",oldLineNo:0,newLineNo:c++}),i++}return o}var kf=200,Rf=20,xf=100,Jm=1,Qm=21,eh=-30,th=6,nh=-4,rh=10,sh=24,oh=17,ih=23,ah=17,ch=60;function Bi(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===32)t+=1;else if(r===9)t+=8-t%8;else if(!(r===10||r===13||r===11||r===12))return t;if(t>=kf)return kf}return-1}function Cf(e,t,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=t?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=Bi(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Bi(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Rf){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Bi(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Rf){r.postIndent=0;break}return r}function Pf(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=Jm),e.endOfFile&&(t.penalty+=Qm);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=eh*r,t.penalty+=th*n;let o=e.indent!==-1?e.indent:e.postIndent,s=r!==0;t.effectiveIndent+=o,o===-1||e.preIndent===-1||(o>e.preIndent?t.penalty+=s?rh:nh:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?oh:sh:t.penalty+=s?ah:ih))}function fh(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return ch*n+(e.penalty-t.penalty)}function $f(e,t,n,r,o,s){let i=0,a=0;for(;e[a];)a++;let c=0,f=0;for(;o[f];)f++;let l=(d,u)=>t[d]===t[u];for(;;){if(a!==i){let d,u,m;do{for(d=a-i,u=-1;i>0&&l(i-1,a-1);){for(e[--i]=1,e[--a]=0;e[i-1];)i--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=a,f>c&&(u=a);!(a>=r||!l(i,a));){for(e[i++]=0,e[a++]=1;e[a];)a++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(u=a)}}while(d!==a-i);if(a!==m)if(u!==-1)for(;f===c;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(a-d-1>g&&(g=a-d-1),a-xf>g&&(g=a-xf);g<=a;g++){let w={effectiveIndent:0,penalty:0},y=Cf(n,r,g);Pf(y,w);let x=Cf(n,r,g-d);Pf(x,w),(h===-1||fh(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;a>h;){for(e[--a]=0,e[--i]=1;e[i-1];)i--;for(f=c-1,c=f;o[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;e[a];a++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function zi(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=qm(e,t),{dstart:f,dend1:l,dend2:d}=zm(i,n,a,r);if(f>l)for(let u=f;u<r-(n-1-l);u++)s[u]=1;else if(f>d)for(let u=f;u<n-(r-1-d);u++)o[u]=1;else{let{refIndex1:u,nreff1:m,refIndex2:h,nreff2:p}=Km(i,n,a,r,c,f,l,d,o,s);if(m>0&&p>0){let g=new Array(m);for(let R=0;R<m;R++)g[R]=i[u[R]];let w=new Array(p);for(let R=0;R<p;R++)w[R]=a[h[R]];let y={},x={},b=m+p+3,E=Math.max(Ym,Wi(b));qi(g,0,m,w,0,p,o,s,u,h,y,x,!1,E)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[u[g]]=1;$f(o,i,e,n,s,r),$f(s,a,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function ct(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return e.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:o,changedNew:s}=zi(e,t);return Zm(e,t,o,s)}var lh=3;function dh(e,t=lh){if(t=Math.max(0,t),e.length===0)return[];let n=[];for(let a=0;a<e.length;a++){let c=e[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),i=Math.min(e.length-1,r+t);for(let a=1;a<n.length;a++){let c=n[a]??0,f=Math.max(0,c-t),l=Math.min(e.length-1,c+t);f<=i+1||(o.push({start:s,end:i}),s=f),i=l}return o.push({start:s,end:i}),o.map(a=>uh(e,a.start,a.end))}function uh(e,t,n){let r=0,o=0,s=0,i=0,a=[],c=!1,f=!1;for(let l=t;l<=n;l++){let d=e[l];if(d)switch(d.type){case"keep":c||(r=d.oldLineNo,c=!0),f||(s=d.newLineNo,f=!0),o++,i++,a.push({type:"context",content:d.line});break;case"delete":c||(r=d.oldLineNo,c=!0),o++,a.push({type:"delete",content:d.line});break;case"insert":f||(s=d.newLineNo,f=!0),i++,a.push({type:"insert",content:d.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="insert"){r=d.newLineNo>1?d.newLineNo-1:0;break}}if(i===0)for(let l=t;l<=n;l++){let d=e[l];if(d&&d.type==="delete"){s=d.oldLineNo>1?d.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:i,lines:a}}function Ro(e){return e?e.length<40?e:X(e):"0000000"}function Of(e,t,n,r,o,s){let{path:i,oldMode:a,newMode:c}=t;e.push(`diff --git a/${i} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${i}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(e.push(`old mode ${a}`),e.push(`new mode ${c}`))}function mh(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:i,oldHash:a,newHash:c}=e,f=e.renameTo!==void 0,l=e.renameTo??r,d=e.isNew??o==="",u=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(Of(m,e,l,d,u,f),o!==s){if(a||c){let h=Ro(a),p=Ro(c);d||u||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${i||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${l} differ`):d?m.push(`Binary files /dev/null and b/${l} differ`):u?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${l} differ`)}return`${m.join(`
197
197
  `)}
198
- `}function It(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,l=Te(n),d=Te(r);if(l||d)return uh(e,l,d);let u=_t(n),m=_t(r),h=n.length>0&&n.endsWith(`
198
+ `}function It(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:i,newHash:a}=e,c=e.renameTo!==void 0,f=e.renameTo??t,l=Te(n),d=Te(r);if(l||d)return mh(e,l,d);let u=_t(n),m=_t(r),h=n.length>0&&n.endsWith(`
199
199
  `),p=r.length>0&&r.endsWith(`
200
- `),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let x=ct(w,y);if(!h||!p)for(let D of x)D.line.includes(g)&&(D.line=D.line.replace(g,""));let b=lh(x,e.contextLines);if(b.length===0&&!c)return"";let E=e.isNew??n==="",R=e.isDeleted??r==="",k=[];if($f(k,e,f,E,R,c),b.length===0)return`${k.join(`
200
+ `),g="\0NOEOL",w=u;!h&&u.length>0&&(w=u.slice(),w[w.length-1]+=g);let y=m;!p&&m.length>0&&(y=m.slice(),y[y.length-1]+=g);let x=ct(w,y);if(!h||!p)for(let D of x)D.line.includes(g)&&(D.line=D.line.replace(g,""));let b=dh(x,e.contextLines);if(b.length===0&&!c)return"";let E=e.isNew??n==="",R=e.isDeleted??r==="",k=[];if(Of(k,e,f,E,R,c),b.length===0)return`${k.join(`
201
201
  `)}
202
- `;if(i||a){let D=ko(i),O=ko(a);E||R?k.push(`index ${D}..${O}`):c?k.push(`index ${D}..${O} ${o||"100644"}`):o&&s&&o!==s?k.push(`index ${D}..${O}`):k.push(`index ${D}..${O} ${o||"100644"}`)}let C=D=>D.includes(" ")?" ":"";E?(k.push("--- /dev/null"),k.push(`+++ b/${f}${C(f)}`)):R?(k.push(`--- a/${t}${C(t)}`),k.push("+++ /dev/null")):(k.push(`--- a/${t}${C(t)}`),k.push(`+++ b/${f}${C(f)}`));let P=u.length,T=m.length;for(let D of b){let O=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,N=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,H="",S=D.oldCount===0?D.oldStart-1:D.oldStart-2;for(let F=S;F>=0;F--){let U=u[F];if(U&&/^[a-zA-Z$_]/.test(U)){H=` ${U.trimEnd().slice(0,79)}`;break}}k.push(`@@ -${O} +${N} @@${H}`);let A=D.oldStart,_=D.newStart;for(let F of D.lines)switch(F.type){case"context":k.push(` ${F.content}`),(!h&&A===P||!p&&_===T)&&k.push("\"),A++,_++;break;case"delete":k.push(`-${F.content}`),!h&&A===P&&k.push("\"),A++;break;case"insert":k.push(`+${F.content}`),!p&&_===T&&k.push("\"),_++;break}}return`${k.join(`
202
+ `;if(i||a){let D=Ro(i),O=Ro(a);E||R?k.push(`index ${D}..${O}`):c?k.push(`index ${D}..${O} ${o||"100644"}`):o&&s&&o!==s?k.push(`index ${D}..${O}`):k.push(`index ${D}..${O} ${o||"100644"}`)}let C=D=>D.includes(" ")?" ":"";E?(k.push("--- /dev/null"),k.push(`+++ b/${f}${C(f)}`)):R?(k.push(`--- a/${t}${C(t)}`),k.push("+++ /dev/null")):(k.push(`--- a/${t}${C(t)}`),k.push(`+++ b/${f}${C(f)}`));let P=u.length,T=m.length;for(let D of b){let O=D.oldCount===1?`${D.oldStart}`:`${D.oldStart},${D.oldCount}`,N=D.newCount===1?`${D.newStart}`:`${D.newStart},${D.newCount}`,H="",S=D.oldCount===0?D.oldStart-1:D.oldStart-2;for(let F=S;F>=0;F--){let U=u[F];if(U&&/^[a-zA-Z$_]/.test(U)){H=` ${U.trimEnd().slice(0,79)}`;break}}k.push(`@@ -${O} +${N} @@${H}`);let A=D.oldStart,_=D.newStart;for(let F of D.lines)switch(F.type){case"context":k.push(` ${F.content}`),(!h&&A===P||!p&&_===T)&&k.push("\"),A++,_++;break;case"delete":k.push(`-${F.content}`),!h&&A===P&&k.push("\"),A++;break;case"insert":k.push(`+${F.content}`),!p&&_===T&&k.push("\"),_++;break}}return`${k.join(`
203
203
  `)}
204
- `}ae();Ae();async function Vn(e,t,n){return(await fe(e,t)).get(n)?.hash??null}async function Of(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 mh(e,t,n,r,o,s){let i=await Vn(e,(await j(e,t)).tree,n);if(!i){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,Yn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await se(e,i),c=_t(a),f=new Array(o.length),l=[...r],d=t,u=n,m=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let P of l)f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!0,void 0);break}let g=await Vn(e,p.tree,u),w=null,y=[];for(let P of p.parents){let T=await j(e,P),D=u,O=await Vn(e,T.tree,D);if(!O){let N=await Of(e,T.tree,p.tree,u);N&&(D=N,O=await Vn(e,T.tree,D))}if(O&&(y.push({hash:P,path:D,blobHash:O}),O===g)){w={hash:P,path:D};break}}if(w){d=w.hash,u=w.path;continue}if(y.length===0){for(let P of l)f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,void 0);break}let x=y[0],b=await se(e,x.blobHash),E=_t(b),R=ct(E,m),k=new Map;for(let P of R)P.type==="keep"&&k.set(P.newLineNo,P.oldLineNo);let C=[];for(let P of l){let T=k.get(P.currentLine);T!==void 0?C.push({finalIdx:P.finalIdx,currentLine:T}):f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,{hash:x.hash,path:x.path})}l=C,d=x.hash,u=x.path,m=E}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function If(e,t,n,r){let o=await j(e,t),s=await Vn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await se(e,s),a=_t(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),u=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await j(e,m);if(g.parents.length===0){for(let k of u)d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!0,void 0);break}let w=await Vn(e,g.tree,h),y=[],x=null;for(let k of g.parents){let C=await j(e,k),P=h,T=await Vn(e,C.tree,P);if(!T){let D=await Of(e,C.tree,g.tree,h);D&&(P=D,T=await Vn(e,C.tree,P))}if(T){let D={hash:k,path:P,blobHash:T};if(y.push(D),T===w){x=D;break}}}if(x){m=x.hash,h=x.path;continue}if(y.length===0){for(let k of u)d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,void 0);break}if(y.length===1){let k=y[0],C=await se(e,k.blobHash),P=_t(C),T=ct(P,p),D=new Map;for(let N of T)N.type==="keep"&&D.set(N.newLineNo,N.oldLineNo);let O=[];for(let N of u){let H=D.get(N.currentLine);H!==void 0?O.push({finalIdx:N.finalIdx,currentLine:H}):d[N.finalIdx]=Yn(m,h,N.currentLine,c+N.finalIdx,l[N.finalIdx],g,!1,{hash:k.hash,path:k.path})}u=O,m=k.hash,h=k.path,p=P;continue}let b=[];for(let k of y){let C=await se(e,k.blobHash),P=_t(C),T=ct(P,p),D=new Map;for(let O of T)O.type==="keep"&&D.set(O.newLineNo,O.oldLineNo);b.push({info:k,newToOld:D})}let E=new Map;for(let k of u){let C=!1;for(let P=0;P<b.length;P++){let T=b[P],D=T.newToOld.get(k.currentLine);if(D!==void 0){let O=E.get(P);O||(O={info:T.info,lines:[]},E.set(P,O)),O.lines.push({finalIdx:k.finalIdx,currentLine:D}),C=!0;break}}C||(d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,{hash:y[0].hash,path:y[0].path}))}let R=E.get(0);for(let[k,C]of E){if(k===0)continue;let P=await mh(e,C.info.hash,C.info.path,C.lines,l,c);for(let[T,D]of P)d[T]=D}if(R&&R.lines.length>0){u=R.lines,m=R.info.hash,h=R.info.path;let k=await se(e,R.info.blobHash);p=_t(k)}else break}return d}function Yn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
205
- `)[0],boundary:i,previous:a}}oe();ae();Ae();ae();me();function hh(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 ph(e,t){let n=hh(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 gh(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),i=String(s).length,a=e.some(d=>d.origPath!==t),c=0;if(!o)for(let d of e){let u=r?`<${d.author.email}>`:d.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let d of e)d.origPath.length>f&&(f=d.origPath.length);let l=[];for(let d of e){let u;n?u=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:u=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let m=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${u}${m} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let h=r?`<${d.author.email}>`:d.author.name,p=ph(d.author.timestamp,d.author.timezone);l.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
204
+ `}ae();Ae();async function Vn(e,t,n){return(await fe(e,t)).get(n)?.hash??null}async function If(e,t,n,r){let o=await Ve(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:i}=await it(e,o);return i.find(c=>c.newPath===r)?.oldPath??null}async function hh(e,t,n,r,o,s){let i=await Vn(e,(await j(e,t)).tree,n);if(!i){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,Yn(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let a=await se(e,i),c=_t(a),f=new Array(o.length),l=[...r],d=t,u=n,m=c;for(;l.length>0;){let p=await j(e,d);if(p.parents.length===0){for(let P of l)f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!0,void 0);break}let g=await Vn(e,p.tree,u),w=null,y=[];for(let P of p.parents){let T=await j(e,P),D=u,O=await Vn(e,T.tree,D);if(!O){let N=await If(e,T.tree,p.tree,u);N&&(D=N,O=await Vn(e,T.tree,D))}if(O&&(y.push({hash:P,path:D,blobHash:O}),O===g)){w={hash:P,path:D};break}}if(w){d=w.hash,u=w.path;continue}if(y.length===0){for(let P of l)f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,void 0);break}let x=y[0],b=await se(e,x.blobHash),E=_t(b),R=ct(E,m),k=new Map;for(let P of R)P.type==="keep"&&k.set(P.newLineNo,P.oldLineNo);let C=[];for(let P of l){let T=k.get(P.currentLine);T!==void 0?C.push({finalIdx:P.finalIdx,currentLine:T}):f[P.finalIdx]=Yn(d,u,P.currentLine,s+P.finalIdx,o[P.finalIdx],p,!1,{hash:x.hash,path:x.path})}l=C,d=x.hash,u=x.path,m=E}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function Sf(e,t,n,r){let o=await j(e,t),s=await Vn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let i=await se(e,s),a=_t(i),c=r?.startLine??1,f=r?.endLine??a.length,l=a.slice(c-1,f),d=new Array(l.length),u=l.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=a;for(;u.length>0;){let g=await j(e,m);if(g.parents.length===0){for(let k of u)d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!0,void 0);break}let w=await Vn(e,g.tree,h),y=[],x=null;for(let k of g.parents){let C=await j(e,k),P=h,T=await Vn(e,C.tree,P);if(!T){let D=await If(e,C.tree,g.tree,h);D&&(P=D,T=await Vn(e,C.tree,P))}if(T){let D={hash:k,path:P,blobHash:T};if(y.push(D),T===w){x=D;break}}}if(x){m=x.hash,h=x.path;continue}if(y.length===0){for(let k of u)d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,void 0);break}if(y.length===1){let k=y[0],C=await se(e,k.blobHash),P=_t(C),T=ct(P,p),D=new Map;for(let N of T)N.type==="keep"&&D.set(N.newLineNo,N.oldLineNo);let O=[];for(let N of u){let H=D.get(N.currentLine);H!==void 0?O.push({finalIdx:N.finalIdx,currentLine:H}):d[N.finalIdx]=Yn(m,h,N.currentLine,c+N.finalIdx,l[N.finalIdx],g,!1,{hash:k.hash,path:k.path})}u=O,m=k.hash,h=k.path,p=P;continue}let b=[];for(let k of y){let C=await se(e,k.blobHash),P=_t(C),T=ct(P,p),D=new Map;for(let O of T)O.type==="keep"&&D.set(O.newLineNo,O.oldLineNo);b.push({info:k,newToOld:D})}let E=new Map;for(let k of u){let C=!1;for(let P=0;P<b.length;P++){let T=b[P],D=T.newToOld.get(k.currentLine);if(D!==void 0){let O=E.get(P);O||(O={info:T.info,lines:[]},E.set(P,O)),O.lines.push({finalIdx:k.finalIdx,currentLine:D}),C=!0;break}}C||(d[k.finalIdx]=Yn(m,h,k.currentLine,c+k.finalIdx,l[k.finalIdx],g,!1,{hash:y[0].hash,path:y[0].path}))}let R=E.get(0);for(let[k,C]of E){if(k===0)continue;let P=await hh(e,C.info.hash,C.info.path,C.lines,l,c);for(let[T,D]of P)d[T]=D}if(R&&R.lines.length>0){u=R.lines,m=R.info.hash,h=R.info.path;let k=await se(e,R.info.blobHash);p=_t(k)}else break}return d}function Yn(e,t,n,r,o,s,i,a){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
205
+ `)[0],boundary:i,previous:a}}oe();ae();Ae();ae();me();function ph(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function gh(e,t){let n=ph(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),i=r.getUTCDate().toString().padStart(2,"0"),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${i} ${a}:${c}:${f} ${t}`}function wh(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),i=String(s).length,a=e.some(d=>d.origPath!==t),c=0;if(!o)for(let d of e){let u=r?`<${d.author.email}>`:d.author.name;u.length>c&&(c=u.length)}let f=0;if(a)for(let d of e)d.origPath.length>f&&(f=d.origPath.length);let l=[];for(let d of e){let u;n?u=d.boundary?`^${d.hash.slice(0,39)}`:d.hash:u=d.boundary?`^${d.hash.slice(0,7)}`:d.hash.slice(0,8);let m=a?` ${d.origPath.padEnd(f)}`:"";if(o)l.push(`${u}${m} ${String(d.finalLine).padStart(i)}) ${d.content}`);else{let h=r?`<${d.author.email}>`:d.author.name,p=gh(d.author.timestamp,d.author.timezone);l.push(`${u}${m} (${h.padEnd(c)} ${p} ${String(d.finalLine).padStart(i)}) ${d.content}`)}}return`${l.join(`
206
206
  `)}
207
- `}function wh(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
207
+ `}function bh(e,t){let n=new Set,r=[];for(let o of e){let s=!n.has(o.hash);n.add(o.hash),r.push(`${o.hash} ${o.origLine} ${o.finalLine} 1`),(s||t)&&(r.push(`author ${o.author.name}`),r.push(`author-mail <${o.author.email}>`),r.push(`author-time ${o.author.timestamp}`),r.push(`author-tz ${o.author.timezone}`),r.push(`committer ${o.committer.name}`),r.push(`committer-mail <${o.committer.email}>`),r.push(`committer-time ${o.committer.timestamp}`),r.push(`committer-tz ${o.committer.timezone}`),r.push(`summary ${o.summary}`),o.boundary&&r.push("boundary"),o.previous&&r.push(`previous ${o.previous.hash} ${o.previous.path}`),r.push(`filename ${o.origPath}`)),r.push(` ${o.content}`)}return`${r.join(`
208
208
  `)}
209
- `}function bh(e,t,n){if(e.startsWith("/"))return st(n,e);let r=st(n,t);return r===""||r==="."?e:`${r}/${e}`}function Sf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[q.string().name("args").variadic().optional()],options:{lineRange:V.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:$().alias("l").describe("Show long revision"),showEmail:$().alias("e").describe("Show author email instead of name"),suppress:$().alias("s").describe("Suppress author name and date"),porcelain:$().alias("p").describe("Show in machine-readable format"),linePorcelain:$().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return I("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 I("no file specified");let u=bh(d,r.cwd,i.workTree),m;if(l){let R=await wt(i,l);if(M(R))return R;m=await ve(i,R)}else m=a;let h=await j(i,m),p=await fe(i,h.tree);if(!p.has(u))return I(`no such path ${u} in ${l??"HEAD"}`);let g=p.get(u).hash,w=await se(i,g);if(Te(w))return I(`cannot blame binary file '${u}'`);let y,x;if(n.lineRange){let R=n.lineRange,k=R.match(/^(\d+),(\d+)$/);if(k)y=parseInt(k[1],10),x=parseInt(k[2],10);else return I(`invalid -L range: '${R}'`)}let b;try{b=await If(i,m,u,{startLine:y,endLine:x})}catch(R){let k=R instanceof Error?R.message:String(R);return I(k)}let E;return n.porcelain||n.linePorcelain?E=wh(b,!!n.linePorcelain):E=gh(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:E,stderr:"",exitCode:0}}})}oe();qe();Tn();oe();var yh=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Eh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Cn(e,t){let n=kh(t),r=new Date((e+n*60)*1e3),o=yh[r.getUTCDay()],s=Eh[r.getUTCMonth()],i=r.getUTCDate(),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),l=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${l} ${t}`}function qi(e){let t=e.trim();if(/^\d+$/.test(t))return parseInt(t,10);let n=Date.parse(t);return Number.isNaN(n)?null:Math.floor(n/1e3)}function kh(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)}ae();Ae();var Ro=new TextDecoder;function Tf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
209
+ `}function yh(e,t,n){if(e.startsWith("/"))return st(n,e);let r=st(n,t);return r===""||r==="."?e:`${r}/${e}`}function Tf(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[q.string().name("args").variadic().optional()],options:{lineRange:V.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:$().alias("l").describe("Show long revision"),showEmail:$().alias("e").describe("Show author email instead of name"),suppress:$().alias("s").describe("Suppress author name and date"),porcelain:$().alias("p").describe("Show in machine-readable format"),linePorcelain:$().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s;if(!i.workTree)return I("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 I("no file specified");let u=yh(d,r.cwd,i.workTree),m;if(l){let R=await wt(i,l);if(M(R))return R;m=await ve(i,R)}else m=a;let h=await j(i,m),p=await fe(i,h.tree);if(!p.has(u))return I(`no such path ${u} in ${l??"HEAD"}`);let g=p.get(u).hash,w=await se(i,g);if(Te(w))return I(`cannot blame binary file '${u}'`);let y,x;if(n.lineRange){let R=n.lineRange,k=R.match(/^(\d+),(\d+)$/);if(k)y=parseInt(k[1],10),x=parseInt(k[2],10);else return I(`invalid -L range: '${R}'`)}let b;try{b=await Sf(i,m,u,{startLine:y,endLine:x})}catch(R){let k=R instanceof Error?R.message:String(R);return I(k)}let E;return n.porcelain||n.linePorcelain?E=bh(b,!!n.linePorcelain):E=wh(b,u,!!n.long,!!n.showEmail,!!n.suppress),{stdout:E,stderr:"",exitCode:0}}})}oe();qe();Tn();oe();var Eh=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],kh=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Cn(e,t){let n=Rh(t),r=new Date((e+n*60)*1e3),o=Eh[r.getUTCDay()],s=kh[r.getUTCMonth()],i=r.getUTCDate(),a=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),l=r.getUTCFullYear();return`${o} ${s} ${i} ${a}:${c}:${f} ${l} ${t}`}function Ki(e){let t=e.trim();if(/^\d+$/.test(t))return parseInt(t,10);let n=Date.parse(t);return Number.isNaN(n)?null:Math.floor(n/1e3)}function Rh(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}ae();Ae();var xo=new TextDecoder;function vf(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
210
210
  `&&t++;return e[e.length-1]!==`
211
- `&&t++,t}function Xn(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function Zn(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Pt(e,a.newHash);Dn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:Tf(Ro.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Pt(e,a.oldHash);Dn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:Tf(Ro.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Pt(e,a.oldHash),f=await Pt(e,a.newHash);if(Dn(c)||Dn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=Rt(Ro.decode(c)),d=Rt(Ro.decode(f)),u=ct(l,d),m=0,h=0;for(let p of u)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:m,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=dn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await se(e,a.oldHash),u=await se(e,a.newHash);if(!Te(d)&&!Te(u)){let m=Rt(d),h=Rt(u),p=ct(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=dn(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 un(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${Cn(r.timestamp,r.timezone)}`),i)return a.join(`
211
+ `&&t++,t}function Xn(e,t,n){if(e===0)return"";let r=[];return r.push(`${e} file${e!==1?"s":""} changed`),(t>0||n===0)&&r.push(`${t} insertion${t!==1?"s":""}(+)`),(n>0||t===0)&&r.push(`${n} deletion${n!==1?"s":""}(-)`),` ${r.join(", ")}`}async function Zn(e,t,n){let r=[],o=[],s=[];for(let a of t)if(a.status==="added"&&a.newHash&&a.newMode){let c=await Pt(e,a.newHash);Dn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:a.path,sortKey:a.path,insertions:vf(xo.decode(c)),deletions:0}),o.push({path:a.path,mode:a.newMode})}else if(a.status==="deleted"&&a.oldHash&&a.oldMode){let c=await Pt(e,a.oldHash);Dn(c)?r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:a.path,sortKey:a.path,insertions:0,deletions:vf(xo.decode(c))}),s.push({path:a.path,mode:a.oldMode})}else if(a.status==="modified"&&a.oldHash&&a.newHash){let c=await Pt(e,a.oldHash),f=await Pt(e,a.newHash);if(Dn(c)||Dn(f))r.push({path:a.path,sortKey:a.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let l=Rt(xo.decode(c)),d=Rt(xo.decode(f)),u=ct(l,d),m=0,h=0;for(let p of u)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:a.path,sortKey:a.path,insertions:m,deletions:h})}a.oldMode&&a.newMode&&a.oldMode!==a.newMode&&(s.push({path:a.path,mode:a.oldMode}),o.push({path:a.path,mode:a.newMode}))}for(let a of n){let c=dn(a.oldPath,a.newPath),f=0,l=0;if(a.similarity<100&&a.oldHash&&a.newHash){let d=await se(e,a.oldHash),u=await se(e,a.newHash);if(!Te(d)&&!Te(u)){let m=Rt(d),h=Rt(u),p=ct(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&l++}}r.push({path:c,sortKey:a.newPath,insertions:f,deletions:l})}let i=[];for(let{path:a,mode:c}of o)i.push({sortKey:a,text:` create mode ${c} ${a}`});for(let{path:a,mode:c}of s)i.push({sortKey:a,text:` delete mode ${c} ${a}`});for(let a of n){let c=dn(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 un(e,t,n,r,o,s=!1,i=!1){let a=[];if((r.name!==o.name||r.email!==o.email)&&a.push(` Author: ${r.name} <${r.email}>`),s&&a.push(` Date: ${Cn(r.timestamp,r.timezone)}`),i)return a.join(`
212
212
  `)+(a.length>0?`
213
213
  `:"");let c=await Ve(e,t,n),{remaining:f,renames:l}=await it(e,c),{fileStats:d,modeLines:u}=await Zn(e,f,l),m=0,h=0;for(let g of d)m+=g.insertions,h+=g.deletions;let p=Xn(d.length,m,h);p&&a.push(p);for(let g of u)a.push(g);return a.join(`
214
214
  `)+(a.length>0?`
215
- `:"")}var Rh=80;function xh(e,t){if(e.length<=t)return e;let n=e;for(;n.length+4>t;){let o=n.indexOf("/");if(o===-1)break;n=n.slice(o+1)}let r=`.../${n}`;return r.length<=t?r:`...${e.slice(e.length-(t-3))}`}function ur(e,t=Rh){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=xh(p.path,c);let f=c,l=[],d=0,u=0,m=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(m++,d+=p.insertions,u+=p.deletions,p.isBinary){let C=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${C}`);continue}let w=p.insertions+p.deletions,y=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let k=T=>T===0?0:1+Math.floor(T*(a-1)/r),C=k(w),P=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(x=k(p.insertions),b=P-x):(b=k(p.deletions),x=P-b)}let E="+".repeat(x)+"-".repeat(b),R=E?` ${E}`:"";l.push(` ${g} | ${y}${R}`)}let h=Xn(m,d,u);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
215
+ `:"")}var xh=80;function Ch(e,t){if(e.length<=t)return e;let n=e;for(;n.length+4>t;){let o=n.indexOf("/");if(o===-1)break;n=n.slice(o+1)}let r=`.../${n}`;return r.length<=t?r:`...${e.slice(e.length-(t-3))}`}function ur(e,t=xh){if(e.length===0)return"";let n=e.filter(p=>!p.isUnmerged),r=n.length>0?Math.max(...n.map(p=>p.insertions+p.deletions)):0,o=e.some(p=>p.isBinary),s=r>0?String(r).length:1;o&&s<3&&(s=3);let i=Math.max(...e.map(p=>p.path.length)),a=r,c=i;if(c+s+6+a>t){let p=Math.floor(t*3/8)-s-6;a>p&&(a=Math.max(p,6));let g=t-s-6-a;c>g?c=g:a=t-s-6-c}for(let p of e)p.path=Ch(p.path,c);let f=c,l=[],d=0,u=0,m=0;for(let p of e){let g=p.path.padEnd(f);if(p.isUnmerged){l.push(` ${g} | Unmerged`);continue}if(m++,d+=p.insertions,u+=p.deletions,p.isBinary){let C=`${"Bin".padStart(s)} ${p.oldSize??0} -> ${p.newSize??0} bytes`;l.push(` ${g} | ${C}`);continue}let w=p.insertions+p.deletions,y=String(w).padStart(s),x,b;if(r<=a)x=p.insertions,b=p.deletions;else{let k=T=>T===0?0:1+Math.floor(T*(a-1)/r),C=k(w),P=C<2&&p.insertions>0&&p.deletions>0?2:C;p.insertions<p.deletions?(x=k(p.insertions),b=P-x):(b=k(p.deletions),x=P-b)}let E="+".repeat(x)+"-".repeat(b),R=E?` ${E}`:"";l.push(` ${g} | ${y}${R}`)}let h=Xn(m,d,u);return h?l.push(h):e.some(p=>p.isUnmerged)&&l.push(" 0 files changed"),`${l.join(`
216
216
  `)}
217
217
  `}async function mn(e,t,n){let r=await Ve(e,t,n),{remaining:o,renames:s}=await it(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:i,modeLines:a}=await Zn(e,o,s);i.sort((f,l)=>f.sortKey<l.sortKey?-1:f.sortKey>l.sortKey?1:0);let c=ur(i);for(let f of a)c+=`${f}
218
- `;return c}qe();Ce();ae();ge();fn();async function Ch(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i;try{i=await j(e,s)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function Pn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Ft(e,t,n){if(t===n)return[t];let r=await Ch(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let l;try{l=await j(e,f)}catch{continue}for(let d of l.parents)s.has(d)||i.push(d)}if(o.length<=1)return o;let c=[];for(let f of o){let l=!1;for(let d of o)if(d!==f&&await Pn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:Ph(e,t,n,c)}async function Ph(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,l=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function d(u){let m=c.get(u);if(m!==void 0)return m;let h=(await j(e,u)).committer.timestamp;return c.set(u,h),h}for(;l.length>0;){let u=0,m=await d(l[0].hash);for(let y=1;y<l.length;y++){let x=l[y],b=await d(x.hash),E=l[u];(b>m||b===m&&x.seq<E.seq)&&(u=y,m=b)}let h=l.splice(u,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await j(e,h.hash);for(let y of w.parents)l.push({hash:y,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function mr(e,t,n){let r=await xe(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
218
+ `;return c}qe();Ce();ae();ge();fn();async function Ph(e,t){let n=new Set,r=[t],o=0;for(;o<r.length;){let s=r[o++];if(n.has(s))continue;n.add(s);let i;try{i=await j(e,s)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function Pn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let i=o[s++];if(i===t)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await j(e,i)}catch{continue}for(let c of a.parents)r.has(c)||o.push(c)}return!1}async function Ft(e,t,n){if(t===n)return[t];let r=await Ph(e,t),o=[],s=new Set,i=[n],a=0;for(;a<i.length;){let f=i[a++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let l;try{l=await j(e,f)}catch{continue}for(let d of l.parents)s.has(d)||i.push(d)}if(o.length<=1)return o;let c=[];for(let f of o){let l=!1;for(let d of o)if(d!==f&&await Pn(e,f,d)){l=!0;break}l||c.push(f)}return c.length<=1?c:$h(e,t,n,c)}async function $h(e,t,n,r){let o=new Set(r),s=new Set,i=[],a=new Map,c=new Map,f=0,l=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function d(u){let m=c.get(u);if(m!==void 0)return m;let h=(await j(e,u)).committer.timestamp;return c.set(u,h),h}for(;l.length>0;){let u=0,m=await d(l[0].hash);for(let y=1;y<l.length;y++){let x=l[y],b=await d(x.hash),E=l[u];(b>m||b===m&&x.seq<E.seq)&&(u=y,m=b)}let h=l.splice(u,1)[0],p=a.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(a.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(i.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await j(e,h.hash);for(let y of w.parents)l.push({hash:y,mask:g,seq:f++})}for(let u of r)s.has(u)||i.push(u);return i}async function mr(e,t,n){let r=await xe(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
219
219
  `:`Merge branch '${t}' into ${n}
220
- `}async function xo(e,t,n){let r=await j(e,t),o=await j(e,n),s=X(t),i=X(n),a=`Updating ${s}..${i}
221
- `;if(e.workTree){let f=await z(e),l=await qc(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 de(e,{version:2,entries:l.newEntries}),await Ne(e,l.worktreeOps)}await jn(e,n);let c=await mn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
222
- ${c}`,stderr:"",exitCode:0}}ae();ze();ge();function vf(e,t){e.command("branch",{description:"List, create, or delete branches",args:[q.string().name("name").describe("Branch name").optional(),q.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:$().alias("d").describe("Delete a branch"),forceDelete:$().alias("D").describe("Force delete a branch"),move:$().alias("m").describe("Rename a branch"),forceMove:$().alias("M").describe("Force rename a branch"),remotes:$().alias("r").describe("List remote-tracking branches"),all:$().alias("a").describe("List all branches"),setUpstreamTo:V.string().alias("u").describe("Set upstream tracking branch"),verbose:$().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Pe(i.target):null,c=!!n.forceMove;if(n.move||c){let w,y;if(n.newName)w=n.name,y=n.newName;else if(n.name){if(!a)return I("not on any branch");w=a,y=n.name}else return I("branch name required");if(!wn(y))return I(`'${y}' is not a valid branch name`);let x=`refs/heads/${w}`,b=`refs/heads/${y}`,E=await B(s,x);if(!E)return I(`no branch named '${w}'`);if(await Nt(s)&&(await Et(s))?.headName===x)return I(`branch ${x} is being rebased at ${s.workTree}`);let R=await B(s,b);if(R&&!c)return I(`a branch named '${y}' already exists`);R&&await he(s,b);let k=await et(s,x);await Z(s,b,E),await he(s,x),w===a&&await Xe(s,"HEAD",b),k.length>0&&await Ln(s,b,k);let C=`Branch: renamed ${x} to ${b}`;if(await ce(s,r.env,b,E,E,C),w===a){let D=await en(s,r.env);await Ze(s,"HEAD",{oldHash:E,newHash:ee,...D,message:C}),await Ze(s,"HEAD",{oldHash:ee,newHash:E,...D,message:C})}let P=await we(s),T=`branch "${w}"`;return P[T]&&(P[`branch "${y}"`]=P[T],delete P[T],await Je(s,P)),{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 Nt(s)&&(await Et(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return G(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
220
+ `}async function Co(e,t,n){let r=await j(e,t),o=await j(e,n),s=X(t),i=X(n),a=`Updating ${s}..${i}
221
+ `;if(e.workTree){let f=await z(e),l=await zc(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 de(e,{version:2,entries:l.newEntries}),await Ne(e,l.worktreeOps)}await jn(e,n);let c=await mn(e,r.tree,o.tree);return{stdout:`${a}Fast-forward
222
+ ${c}`,stderr:"",exitCode:0}}ae();ze();ge();function Af(e,t){e.command("branch",{description:"List, create, or delete branches",args:[q.string().name("name").describe("Branch name").optional(),q.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:$().alias("d").describe("Delete a branch"),forceDelete:$().alias("D").describe("Force delete a branch"),move:$().alias("m").describe("Rename a branch"),forceMove:$().alias("M").describe("Force rename a branch"),remotes:$().alias("r").describe("List remote-tracking branches"),all:$().alias("a").describe("List all branches"),setUpstreamTo:V.string().alias("u").describe("Set upstream tracking branch"),verbose:$().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Q(s),a=i?.type==="symbolic"?Pe(i.target):null,c=!!n.forceMove;if(n.move||c){let w,y;if(n.newName)w=n.name,y=n.newName;else if(n.name){if(!a)return I("not on any branch");w=a,y=n.name}else return I("branch name required");if(!wn(y))return I(`'${y}' is not a valid branch name`);let x=`refs/heads/${w}`,b=`refs/heads/${y}`,E=await B(s,x);if(!E)return I(`no branch named '${w}'`);if(await Nt(s)&&(await Et(s))?.headName===x)return I(`branch ${x} is being rebased at ${s.workTree}`);let R=await B(s,b);if(R&&!c)return I(`a branch named '${y}' already exists`);R&&await he(s,b);let k=await et(s,x);await Z(s,b,E),await he(s,x),w===a&&await Xe(s,"HEAD",b),k.length>0&&await Ln(s,b,k);let C=`Branch: renamed ${x} to ${b}`;if(await ce(s,r.env,b,E,E,C),w===a){let D=await en(s,r.env);await Ze(s,"HEAD",{oldHash:E,newHash:ee,...D,message:C}),await Ze(s,"HEAD",{oldHash:ee,newHash:E,...D,message:C})}let P=await we(s),T=`branch "${w}"`;return P[T]&&(P[`branch "${y}"`]=P[T],delete P[T],await Je(s,P)),{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 Nt(s)&&(await Et(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return G(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
223
223
  `);let y=`refs/heads/${n.name}`,x=await B(s,y);if(!x)return G(`error: branch '${n.name}' not found
224
224
  `);let b="";if(!f){let E=await Y(s),k=(await we(s))[`branch "${n.name}"`],C=k?.remote,P=k?.merge,T=null,D=null;if(C&&P&&(T=P.replace(/^refs\/heads\//,`refs/remotes/${C}/`),D=await B(s,T)),D&&T){if(!(x===D||await Pn(s,x,D))){let S=E!=null&&(x===E||await Pn(s,x,E))?`warning: not deleting branch '${n.name}' that is not yet merged to
225
225
  '${T}', even though it is merged to HEAD
@@ -233,23 +233,23 @@ hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
233
233
  hint: Disable this message with "git config set advice.forceDeleteBranch false"
234
234
  `)}return await he(s,y),{stdout:`Deleted branch ${n.name} (was ${X(x)}).
235
235
  `,stderr:b,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,y=n.name||a;if(!y)return I("could not set upstream of HEAD when it does not point to any branch.");if(!await B(s,`refs/heads/${y}`))return I(`branch '${y}' does not exist`);let b=w.indexOf("/");if(b<0)return I(`the requested upstream branch '${w}' does not exist`);let E=w.slice(0,b),R=w.slice(b+1);if(!await B(s,`refs/remotes/${w}`))return I(`the requested upstream branch '${w}' does not exist`);let C=await we(s),P=`branch "${y}"`;return C[P]||(C[P]={}),C[P].remote=E,C[P].merge=`refs/heads/${R}`,await Je(s,C),{stdout:"",stderr:`branch '${y}' set up to track '${w}'.
236
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!wn(n.name))return I(`'${n.name}' is not a valid branch name`);let w=n.newName,y;if(w){let k=await Me(s,w,`not a valid object name: '${w}'`);if(M(k))return k;y=k.hash}else if(y=await Y(s),!y)return I("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await B(s,x))return I(`a branch named '${n.name}' already exists`);await Z(s,x,y);let E=w??"HEAD";await ce(s,r.env,x,null,y,`branch: Created from ${E}`);let R="";return w&&(R=await po(s,n.name,w)),{stdout:"",stderr:R,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,u=n.remotes||n.all,m=[];if(d&&!a){let w=await Y(s);if(w){let y=await Nt(s),x;if(y){let b=await Et(s);if(b?.headName){let E=Pe(b.headName);if(E==="detached HEAD"){let R=await cs(s);x=`(no branch, rebasing detached HEAD ${R?X(R):"(null)"})`}else x=`(no branch, rebasing ${E})`}else x="(no branch)"}else{let b=await cs(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${X(b)})`:x="(no branch)"}m.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await pe(s,"refs/heads");for(let y of w){let x=Pe(y.name);m.push({displayName:x,hash:y.hash,isCurrent:x===a,branchName:x})}}if(u){let w=await pe(s,"refs/remotes");for(let y of w){let x=y.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${x}`:x,hash:y.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${m.map(y=>y.isCurrent?`* ${y.displayName}`:` ${y.displayName}`).join(`
236
+ `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){if(!wn(n.name))return I(`'${n.name}' is not a valid branch name`);let w=n.newName,y;if(w){let k=await Me(s,w,`not a valid object name: '${w}'`);if(M(k))return k;y=k.hash}else if(y=await Y(s),!y)return I("Not a valid object name: 'HEAD'.");let x=`refs/heads/${n.name}`;if(await B(s,x))return I(`a branch named '${n.name}' already exists`);await Z(s,x,y);let E=w??"HEAD";await ce(s,r.env,x,null,y,`branch: Created from ${E}`);let R="";return w&&(R=await go(s,n.name,w)),{stdout:"",stderr:R,exitCode:0}}let l=n.verbose||0,d=!n.remotes||n.all,u=n.remotes||n.all,m=[];if(d&&!a){let w=await Y(s);if(w){let y=await Nt(s),x;if(y){let b=await Et(s);if(b?.headName){let E=Pe(b.headName);if(E==="detached HEAD"){let R=await fs(s);x=`(no branch, rebasing detached HEAD ${R?X(R):"(null)"})`}else x=`(no branch, rebasing ${E})`}else x="(no branch)"}else{let b=await fs(s);b?x=`(HEAD detached ${w===b?"at":"from"} ${X(b)})`:x="(no branch)"}m.push({displayName:x,hash:w,isCurrent:!0,branchName:null})}}if(d){let w=await pe(s,"refs/heads");for(let y of w){let x=Pe(y.name);m.push({displayName:x,hash:y.hash,isCurrent:x===a,branchName:x})}}if(u){let w=await pe(s,"refs/remotes");for(let y of w){let x=y.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${x}`:x,hash:y.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(l===0)return{stdout:`${m.map(y=>y.isCurrent?`* ${y.displayName}`:` ${y.displayName}`).join(`
237
237
  `)}
238
- `,stderr:"",exitCode:0};let h=l>=1?await we(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let y=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=X(w.hash),E="";try{let k=await j(s,w.hash);E=ue(k.message)}catch{}let R="";if(h&&w.branchName){let k=await Rn(s,h,w.branchName);if(k){let C=uf(k,l>=2);C&&(R=` ${C}`)}}g.push(`${y}${x} ${b}${R} ${E}`)}return{stdout:`${g.join(`
238
+ `,stderr:"",exitCode:0};let h=l>=1?await we(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let y=w.isCurrent?"* ":" ",x=w.displayName.padEnd(p),b=X(w.hash),E="";try{let k=await j(s,w.hash);E=ue(k.message)}catch{}let R="";if(h&&w.branchName){let k=await Rn(s,h,w.branchName);if(k){let C=mf(k,l>=2);C&&(R=` ${C}`)}}g.push(`${y}${x} ${b}${R} ${E}`)}return{stdout:`${g.join(`
239
239
  `)}
240
- `,stderr:"",exitCode:0}}})}function le(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var $h=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Oh=["commitMsg","mergeMsg"],Ih=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Sh=["onRefUpdate","onRefDelete","onObjectWrite"];function Th(...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 $h){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(le(a))return a}})}for(let r of Oh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(le(a))return a}})}for(let r of Ih){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o)try{await i(s)}catch{}})}for(let r of Sh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}oe();qe();Ce();ae();ze();ge();sn();tt();function Hf(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:$().alias("b").describe("Create and switch to a new branch"),forceBranch:$().alias("B").describe("Create/reset and switch to a new branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:$().describe("Create a new orphan branch"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return I("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return I(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let u=ut(i,r.cwd),m=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return I("cannot specify both a revision and --ours/--theirs");let p=await Me(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?mo(i,m,u,n.theirs?3:2):uo(i,m,u,h)}if(n.orphan)return n.branch?I("--orphan and -b are incompatible"):n.ours||n.theirs?I("--orphan and --ours/--theirs are incompatible"):a?Ah(i,a,r.env,t):I("you must specify a branch to checkout");if(n.detach){let u=a??"HEAD",m=await Me(i,u,`invalid reference: ${u}`);return M(m)?m:Af(i,u,m.hash,r.env,t)}if(!a)return I("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Hh(i,a,r.env,t,!!n.forceBranch);if(a==="-")return vh(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Df(i,a,c,f,r.env,t);let l=await go(i,a);if(l)return Dh(i,a,l.trackingRef,r.env,t);let d=await Be(i,a);if(d){let u=await ve(i,d);return Af(i,a,u,r.env,t)}if(i.workTree){let u=await z(i),m=js(u,a);if(m)return await dt(i,{path:m.path,hash:m.hash,mode:m.mode}),{stdout:"",stderr:"",exitCode:0}}return G(`error: pathspec '${a}' did not match any file(s) known to git
241
- `)}})}async function vh(e,t,n){let r=await lo(e);return r?Df(e,r.name,r.refName,r.hash,t,n):I("no previous branch")}async function Ah(e,t,n,r){if(!wn(t))return I(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return I(`a branch named '${t}' already exists`);let i=await z(e),a=qn(i);if(a)return a;let c=await Y(e),f=null;c&&(f=(await j(e,c)).tree),await Xe(e,"HEAD",o),await yt(e);let l=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ee,isBranchCheckout:!0});let d="";return f&&(d=await lr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
242
- ${l}`,exitCode:0}}async function Hh(e,t,n,r,o=!1){if(!wn(t))return I(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(s))return G(s.message??"");let i=await Q(e),a=await Y(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return I(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=qn(g);if(w)return w}a&&await Z(e,c,a),await Xe(e,"HEAD",c),await yt(e);let l=await xn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??ee;a&&(f?f!==a&&await ce(e,n,c,f,a,"branch: Reset to HEAD"):await ce(e,n,c,null,a,"branch: Created from HEAD")),await ce(e,n,"HEAD",a,a??ee,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??ee,isBranchCheckout:!0});let u="";if(o&&a){let g=await z(e),w=await j(e,a);u=await lr(e,w.tree,g)}let m=await we(e),h=await Rn(e,m,t);h&&(u+=fr(h));let p=f?`Switched to and reset branch '${t}'
240
+ `,stderr:"",exitCode:0}}})}function le(e){return e!=null&&typeof e=="object"&&"reject"in e&&e.reject===!0}var Oh=["preCommit","preMergeCommit","preCheckout","prePush","preFetch","preClone","prePull","preRebase","preReset","preCherryPick","preRevert","beforeCommand"],Ih=["commitMsg","mergeMsg"],Sh=["postCommit","postMerge","postCheckout","postPush","postFetch","postClone","postPull","postReset","postCherryPick","postRevert","afterCommand"],Th=["onRefUpdate","onRefDelete","onObjectWrite"];function vh(...e){let t=e.filter(r=>r!=null);if(t.length===0)return{};if(t.length===1)return t[0];let n={};for(let r of Oh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(le(a))return a}})}for(let r of Ih){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o){let a=await i(s);if(le(a))return a}})}for(let r of Sh){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=async s=>{for(let i of o)try{await i(s)}catch{}})}for(let r of Th){let o=t.filter(s=>s[r]).map(s=>s[r]);o.length>0&&(n[r]=s=>{for(let i of o)try{i(s)}catch{}})}return n}oe();qe();Ce();ae();ze();ge();sn();tt();function Df(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[q.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:$().alias("b").describe("Create and switch to a new branch"),forceBranch:$().alias("B").describe("Create/reset and switch to a new branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:$().describe("Create a new orphan branch"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.target;if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");if(n.detach&&(n.branch||n.forceBranch||n.orphan))return I("'--detach' cannot be used with '-b/-B/--orphan'");if(o.passthrough.length>0){if(n.detach)return I(`git checkout: --detach does not take a path argument '${o.passthrough[0]}'`);let u=ut(i,r.cwd),m=o.passthrough,h=null;if(a){if(n.ours||n.theirs)return I("cannot specify both a revision and --ours/--theirs");let p=await Me(i,a,`invalid reference: ${a}`);if(M(p))return p;h=p.commit.tree}return n.ours||n.theirs?ho(i,m,u,n.theirs?3:2):mo(i,m,u,h)}if(n.orphan)return n.branch?I("--orphan and -b are incompatible"):n.ours||n.theirs?I("--orphan and --ours/--theirs are incompatible"):a?Hh(i,a,r.env,t):I("you must specify a branch to checkout");if(n.detach){let u=a??"HEAD",m=await Me(i,u,`invalid reference: ${u}`);return M(m)?m:Hf(i,u,m.hash,r.env,t)}if(!a)return I("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Dh(i,a,r.env,t,!!n.forceBranch);if(a==="-")return Ah(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Mf(i,a,c,f,r.env,t);let l=await wo(i,a);if(l)return Mh(i,a,l.trackingRef,r.env,t);let d=await Be(i,a);if(d){let u=await ve(i,d);return Hf(i,a,u,r.env,t)}if(i.workTree){let u=await z(i),m=Gs(u,a);if(m)return await dt(i,{path:m.path,hash:m.hash,mode:m.mode}),{stdout:"",stderr:"",exitCode:0}}return G(`error: pathspec '${a}' did not match any file(s) known to git
241
+ `)}})}async function Ah(e,t,n){let r=await uo(e);return r?Mf(e,r.name,r.refName,r.hash,t,n):I("no previous branch")}async function Hh(e,t,n,r){if(!wn(t))return I(`'${t}' is not a valid branch name`);let o=`refs/heads/${t}`;if(await B(e,o))return I(`a branch named '${t}' already exists`);let i=await z(e),a=qn(i);if(a)return a;let c=await Y(e),f=null;c&&(f=(await j(e,c)).tree),await Xe(e,"HEAD",o),await yt(e);let l=await xn(e);await r?.hooks?.postCheckout?.({repo:e,prevHead:c,newHead:ee,isBranchCheckout:!0});let d="";return f&&(d=await lr(e,f,i)),{stdout:d,stderr:`Switched to a new branch '${t}'
242
+ ${l}`,exitCode:0}}async function Dh(e,t,n,r,o=!1){if(!wn(t))return I(`'${t}' is not a valid branch name`);let s=await r?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(s))return G(s.message??"");let i=await Q(e),a=await Y(e),c=`refs/heads/${t}`,f=await B(e,c);if(f&&!o)return I(`a branch named '${t}' already exists`);if(o){let g=await z(e),w=qn(g);if(w)return w}a&&await Z(e,c,a),await Xe(e,"HEAD",c),await yt(e);let l=await xn(e),d=i?.type==="symbolic"?i.target.replace(/^refs\/heads\//,""):a??ee;a&&(f?f!==a&&await ce(e,n,c,f,a,"branch: Reset to HEAD"):await ce(e,n,c,null,a,"branch: Created from HEAD")),await ce(e,n,"HEAD",a,a??ee,`checkout: moving from ${d} to ${t}`),await r?.hooks?.postCheckout?.({repo:e,prevHead:a,newHead:a??ee,isBranchCheckout:!0});let u="";if(o&&a){let g=await z(e),w=await j(e,a);u=await lr(e,w.tree,g)}let m=await we(e),h=await Rn(e,m,t);h&&(u+=fr(h));let p=f?`Switched to and reset branch '${t}'
243
243
  `:`Switched to a new branch '${t}'
244
- `;return{stdout:u,stderr:`${p}${l}`,exitCode:0}}async function Df(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return le(i)?G(i.message??""):dr(e,t,n,r,o,s)}async function Dh(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(s))return G(s.message??"");let i=await B(e,n);if(!i)return I(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await Z(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await we(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await Je(e,d),await ce(e,r,a,null,i,`branch: Created from ${n}`);let u=await dr(e,t,a,i,r,o),m=c.slice(1).join("/");return u.stderr=`branch '${t}' set up to track '${f}/${m}'.
245
- ${u.stderr}`,u}async function Af(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return le(s)?G(s.message??""):zn(e,n,r,o,{detachAdviceTarget:t})}oe();qe();Ce();oe();function zi(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{buffer1:[0,0],buffer2:[0,r]}];if(r===0)return[{buffer1:[0,n],buffer2:[0,0]}];let{changedOld:o,changedNew:s}=Wi(e,t);return Mh(o,n,s,r)}function Mh(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 jh(e,t,n){let r=[];for(let c of zi(t,e))r.push({ab:"a",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});for(let c of zi(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,l=c.oStart+c.oLength,d=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>l)break;l=Math.max(l,u.oStart+u.oLength),d.push(u),a++}if(d.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of d){let y=w.oStart,x=y+w.oLength,b=w.abStart,E=b+w.abLength,R=u[w.ab];R.abMin=Math.min(b,R.abMin),R.abMax=Math.max(E,R.abMax),R.oMin=Math.min(y,R.oMin),R.oMax=Math.max(x,R.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(l-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(l-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function Gh(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=jh(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&&jf(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"?Mf(i):Mf(Lh(i))}function ms(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=Gh(e,t,n,{conflictStyle:s}),d=!1,u=[];for(let m of l)m.type==="ok"?u.push(...m.lines):(d=!0,s==="diff3"?u.push(i,...m.a,a,...m.o,c,...m.b,f):u.push(i,...m.a,c,...m.b,f));return{conflict:d,result:u}}function Lh(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Nh(n));return t}function Nh(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(jf(t,n))return[e];let r=zi(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let l=c+a.buffer1[1],d=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,l),o:[],b:n.slice(a.buffer2[0],d)}),s=l}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function Mf(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function hr(e,t,n,r){let o=ms(St(e),St(t),St(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(Ki);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
244
+ `;return{stdout:u,stderr:`${p}${l}`,exitCode:0}}async function Mf(e,t,n,r,o,s){let i=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return le(i)?G(i.message??""):dr(e,t,n,r,o,s)}async function Mh(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(s))return G(s.message??"");let i=await B(e,n);if(!i)return I(`invalid reference: ${n}`);let a=`refs/heads/${t}`;await Z(e,a,i);let c=n.replace(/^refs\/remotes\//,"").split("/"),f=c[0]??"",l=`refs/heads/${c.slice(1).join("/")}`,d=await we(e);d[`branch "${t}"`]={...d[`branch "${t}"`],remote:f,merge:l},await Je(e,d),await ce(e,r,a,null,i,`branch: Created from ${n}`);let u=await dr(e,t,a,i,r,o),m=c.slice(1).join("/");return u.stderr=`branch '${t}' set up to track '${f}/${m}'.
245
+ ${u.stderr}`,u}async function Hf(e,t,n,r,o){let s=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return le(s)?G(s.message??""):zn(e,n,r,o,{detachAdviceTarget:t})}oe();qe();Ce();oe();function Vi(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}=zi(e,t);return jh(o,n,s,r)}function jh(e,t,n,r){let o=[],s=0,i=0;for(;s<t||i<r;){for(;s<t&&i<r&&!e[s]&&!n[i];)s++,i++;if(s>=t&&i>=r)break;let a=s,c=i;for(;s<t&&e[s];)s++;for(;i<r&&n[i];)i++;(s>a||i>c)&&o.push({buffer1:[a,s-a],buffer2:[c,i-c]})}return o}function Gh(e,t,n){let r=[];for(let c of Vi(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 Vi(t,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,f)=>c.oStart-f.oStart);let o=[],s=0;function i(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let a=0;for(;a<r.length;){let c=r[a++],f=c.oStart,l=c.oStart+c.oLength,d=[c];for(i(f);a<r.length;){let u=r[a];if(u.oStart>l)break;l=Math.max(l,u.oStart+u.oLength),d.push(u),a++}if(d.length===1){if(c.abLength>0){let u=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:u.slice(c.abStart,c.abStart+c.abLength)})}}else{let u={a:{abMin:e.length,abMax:-1,oMin:t.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:t.length,oMax:-1}};for(let w of d){let y=w.oStart,x=y+w.oLength,b=w.abStart,E=b+w.abLength,R=u[w.ab];R.abMin=Math.min(b,R.abMin),R.abMax=Math.max(E,R.abMax),R.oMin=Math.min(y,R.oMin),R.oMax=Math.max(x,R.oMax)}let m=u.a.abMin+(f-u.a.oMin),h=u.a.abMax+(l-u.a.oMax),p=u.b.abMin+(f-u.b.oMin),g=u.b.abMax+(l-u.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,l),b:n.slice(p,g)})}s=l}return i(t.length),o}function Lh(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Gh(e,t,n),i=[],a=[];function c(){a.length&&(i.push({type:"ok",lines:a}),a=[])}for(let f of s)f.stable?a.push(...f.content):o&&Gf(f.a,f.b)?a.push(...f.a):(c(),i.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),r?.conflictStyle==="diff3"?jf(i):jf(Nh(i))}function hs(e,t,n,r){let o=r?.markerSize??7,s=r?.conflictStyle??"merge",i=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a=`${"|".repeat(o)}${r?.o?` ${r.o}`:""}`,c="=".repeat(o),f=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,l=Lh(e,t,n,{conflictStyle:s}),d=!1,u=[];for(let m of l)m.type==="ok"?u.push(...m.lines):(d=!0,s==="diff3"?u.push(i,...m.a,a,...m.o,c,...m.b,f):u.push(i,...m.a,c,...m.b,f));return{conflict:d,result:u}}function Nh(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(..._h(n));return t}function _h(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Gf(t,n))return[e];let r=Vi(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let a of r){let c=a.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let l=c+a.buffer1[1],d=a.buffer2[0]+a.buffer2[1];o.push({type:"conflict",a:t.slice(c,l),o:[],b:n.slice(a.buffer2[0],d)}),s=l}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function jf(e){if(e.length<3)return e;let t=[e[0]];for(let r=1;r<e.length;r++){let o=t[t.length-1],s=e[r];o.type==="ok"&&s.type==="ok"?o.lines=[...o.lines,...s.lines]:t.push(s)}if(t.length<3)return t;let n=[t[0]];for(let r=1;r<t.length;r++){let o=n[n.length-1],s=t[r];if(o.type==="conflict"&&s.type==="ok"&&s.lines.length<=3&&r+1<t.length&&t[r+1].type==="conflict"){let i=t[r+1],a=o;a.a=[...o.a,...s.lines,...i.a],a.b=[...o.b,...s.lines,...i.b],a.o=[...o.o,...s.lines,...i.o],r++}else n.push(s)}return n}function hr(e,t,n,r){let o=hs(St(e),St(t),St(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(o.result[o.result.length-1]??"").endsWith("\0"),a=o.result.map(Yi);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
246
246
  `)}
247
247
  `:a.join(`
248
248
  `)}function St(e){if(e==="")return[];let t=e.split(`
249
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function Ki(e){return e.endsWith("\0")?e.slice(0,-1):e}function jf(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();ae();gn();me();nr();Ae();tt();fn();var Tr=new TextDecoder,Jn=new TextEncoder,Gf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Ut(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Fh(e,t,n,r),f=await Bh(e,s,i,a,c,o);return Wh(e,s,o,f)}async function ps(e,t,n,r){let o=await Ft(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Ut(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Ut(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await zf(e,t,n,o,1);return{...await Ut(e,a,s.tree,i.tree,r),baseTree:a}}async function Fh(e,t,n,r){let o=await fe(e,t),s=await fe(e,n),i=await fe(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let l=o.get(f)??null,d=s.get(f)??null,u=i.get(f)??null,m=l?{hash:l.hash,mode:l.mode}:null,h=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,y=d?.hash??null,x=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===x&&(b|=5),y!==null&&y===x&&(b|=6);let E={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(Uh(E)){c.set(f,E);continue}c.set(f,E)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Uh(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 Bh(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[S,A]of n)r.has(S)||a.push({path:S,status:"deleted",oldHash:A.hash,oldMode:A.mode}),o.has(S)||c.push({path:S,status:"deleted",oldHash:A.hash,oldMode:A.mode});for(let[S,A]of r)n.has(S)||a.push({path:S,status:"added",newHash:A.hash,newMode:A.mode});for(let[S,A]of o)n.has(S)||c.push({path:S,status:"added",newHash:A.hash,newMode:A.mode});let f=await it(e,a),l=await it(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,u=new Map;for(let S of f.renames)d.set(S.oldPath,S);for(let S of l.renames)u.set(S.oldPath,S);let m=new Set;for(let[S]of r)!n.has(S)&&o.has(S)&&m.add(S);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(S,A,_=0){i.msgBuf.push({sortKey:S,subOrder:_,text:A})}for(let S of[...n.keys()].sort()){let A=d.get(S),_=u.get(S);if(!A&&!_)continue;let F=n.get(S);if(h.add(S),A&&_)if(h.add(A.newPath),h.add(_.newPath),A.newPath===_.newPath){let U=r.get(A.newPath),L=o.get(_.newPath);if(U.hash===L.hash)i.entries.push(xt(A.newPath,U));else{let K=Vi(t,A.newPath);K.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],K.pathnames=[S,A.newPath,_.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let U=r.get(A.newPath),L=o.get(_.newPath),K=await qf(e,F,U,L,s);K.conflict&&w(S,`Auto-merging ${S}`,-1),i.conflicts.push({path:S,reason:"rename-rename",oursPath:A.newPath,theirsPath:_.newPath}),w(S,`CONFLICT (rename/rename): ${S} renamed to ${A.newPath} in ${p} and to ${_.newPath} in ${g}.`),i.entries.push(xt(S,F,1)),i.entries.push(ft(A.newPath,U.mode,K.hash,2)),i.entries.push(ft(_.newPath,L.mode,K.hash,3)),i.worktreeBlobs.set(A.newPath,{hash:K.hash,mode:U.mode}),i.worktreeBlobs.set(_.newPath,{hash:K.hash,mode:L.mode})}else if(A){h.add(A.newPath);let U=o.get(S),L=r.get(A.newPath),K=m.has(A.newPath);if(U)if(K)await Bf(e,i,A.newPath,S,F,L,U,r,o,!1,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(A.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(A.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(A.newPath,L.mode,U.hash));else{let te=Vi(t,A.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:L.hash,mode:L.mode},{hash:U.hash,mode:U.mode}],te.pathnames=[S,A.newPath,S],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=o.get(A.newPath);if(i.conflicts.push({path:A.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:S}),w(A.newPath,`CONFLICT (rename/delete): ${S} renamed to ${A.newPath} in ${p}, but deleted in ${g}.`),te){i.conflicts.push({path:A.newPath,reason:"add-add"}),w(A.newPath,`Auto-merging ${A.newPath}`,0),w(A.newPath,`CONFLICT (add/add): Merge conflict in ${A.newPath}`,1),i.entries.push(xt(A.newPath,L,2)),i.entries.push(xt(A.newPath,te,3));let J=await Co(e,L.hash,te.hash,L.mode,s);i.worktreeBlobs.set(A.newPath,{hash:J,mode:L.mode})}else i.entries.push(ft(A.newPath,F.mode,F.hash,1)),i.entries.push(xt(A.newPath,L,2)),i.worktreeBlobs.set(A.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(A.newPath,`CONFLICT (modify/delete): ${A.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${A.newPath} left in tree.`,1)}}else if(_){h.add(_.newPath);let U=r.get(S),L=o.get(_.newPath),K=m.has(_.newPath);if(U)if(K)await Bf(e,i,_.newPath,S,F,U,L,r,o,!0,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(_.newPath,L.mode,U.hash));else{let te=Vi(t,_.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],te.pathnames=[S,S,_.newPath],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=r.get(_.newPath);if(i.conflicts.push({path:_.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:S}),w(_.newPath,`CONFLICT (rename/delete): ${S} renamed to ${_.newPath} in ${g}, but deleted in ${p}.`),te){i.conflicts.push({path:_.newPath,reason:"add-add"}),w(_.newPath,`Auto-merging ${_.newPath}`,0),w(_.newPath,`CONFLICT (add/add): Merge conflict in ${_.newPath}`,1),i.entries.push(xt(_.newPath,te,2)),i.entries.push(xt(_.newPath,L,3));let J=await Co(e,te.hash,L.hash,te.mode,s);i.worktreeBlobs.set(_.newPath,{hash:J,mode:te.mode})}else i.entries.push(ft(_.newPath,F.mode,F.hash,1)),i.entries.push(xt(_.newPath,L,3)),i.worktreeBlobs.set(_.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(_.newPath,`CONFLICT (modify/delete): ${_.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${_.newPath} left in tree.`,1)}}}let y=new Set(f.renames.map(S=>S.newPath)),x=new Set(l.renames.map(S=>S.newPath)),b=Lf(n,r),E=Lf(n,o),R=Nf(b,o,n),k=Nf(E,r,n),C=_f(f.renames,R),P=_f(l.renames,k),T=Ff(C),D=Ff(P);for(let S of[...T.keys()])D.has(S)&&(T.delete(S),D.delete(S));let O=new Set(T.keys()),N=new Set(D.keys());if(D.size>0)for(let S of a){if(S.status!=="added"||y.has(S.path))continue;let A=Uf(S.path,D,O);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(r.has(A)){w(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${S.path}.`,1);continue}let U=r.get(S.path),L=o.get(A)??n.get(A);i.entries.push(ft(A,U.mode,U.hash,2)),L&&i.entries.push(ft(A,L.mode,L.hash,3)),i.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:A,reason:"add-add"}),w(A,`CONFLICT (file location): ${S.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let K=t.get(S.path);K&&(K.merged={result:null,clean:!0}),h.add(S.path);continue}let _=r.get(S.path);i.entries.push(ft(A,_.mode,_.hash,2)),i.worktreeBlobs.set(A,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:A,reason:"directory-rename"}),w(A,`CONFLICT (file location): ${S.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(S.path);F&&(F.merged={result:null,clean:!0}),h.add(S.path)}if(T.size>0)for(let S of c){if(S.status!=="added"||x.has(S.path))continue;let A=Uf(S.path,T,N);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(o.has(A)){w(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${S.path}.`,1);continue}let U=o.get(S.path),L=r.get(A)??n.get(A);L&&i.entries.push(ft(A,L.mode,L.hash,2)),i.entries.push(ft(A,U.mode,U.hash,3)),i.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:A,reason:"add-add"}),w(A,`CONFLICT (file location): ${S.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${A}.`,1);let K=t.get(S.path);K&&(K.merged={result:null,clean:!0}),h.add(S.path);continue}let _=o.get(S.path);i.entries.push(ft(A,_.mode,_.hash,3)),i.worktreeBlobs.set(A,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:A,reason:"directory-rename"}),w(A,`CONFLICT (file location): ${S.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(S.path);F&&(F.merged={result:null,clean:!0}),h.add(S.path)}let H=new Set(i.entries.map(S=>S.path));for(let S of H){let A=t.get(S);A&&(A.merged={result:null,clean:!0})}for(let S of h){if(H.has(S))continue;let A=t.get(S);if(!A||A.merged.clean)continue;A.filemask===7&&!A.pathConflict||(A.merged={result:null,clean:!0})}return i}function Lf(e,t){let n=new Set;for(let s of e.keys()){let i=Tt(s);for(;i;)n.add(i),i=Tt(i)}let r=new Set;for(let s of t.keys()){let i=Tt(s);for(;i;)r.add(i),i=Tt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Nf(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=Tt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Tt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Tt(s)}return r}function _f(e,t){let n=new Map;for(let r of e){let o=Tt(r.oldPath),s=Tt(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=Tt(o),s=Tt(s)}}return n}function Ff(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 Uf(e,t,n){let r=Tt(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=Tt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Tt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Bf(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),u=f?i:s;if(d.hash===u.hash){t.entries.push(ft(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await qf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(ft(n,d.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(xt(n,d,2)),t.entries.push(ft(n,i.mode,h.hash,3));let p=await Co(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(ft(n,s.mode,h.hash,2)),t.entries.push(xt(n,d,3));let p=await Co(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function qf(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(bn(t.mode)||bn(n.mode)||bn(r.mode))return{hash:n.hash,conflict:!0};let a=await se(e,t.hash),c=await se(e,n.hash),f=await se(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let l=St(a),d=St(c),u=St(f),m=o?.conflictStyle,h=ms(d,l,u,{conflictStyle:m});if(!h.conflict)return{hash:await Xi(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,y=s?.theirsPath?`${g}:${s.theirsPath}`:g,x=hr(c,a,f,{a:w,b:y,markerSize:i??7,conflictStyle:m});return{hash:await He(e,"blob",Jn.encode(x)),conflict:!0}}async function Co(e,t,n,r,o){let s=await se(e,t),i=await se(e,n),a=hr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return He(e,"blob",Jn.encode(a))}function xt(e,t,n=0){return ft(e,t.mode,t.hash,n)}function ft(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Se()}}async function Wh(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(_e(m,h.merged.result.hash,h.merged.result.mode));continue}await qh(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),l=[],d=new Set;for(let m of o)m.stage===0&&(l.push(m),d.add(m.path));for(let[m,h]of a)d.has(m)||l.push(_e(m,h.hash,h.mode));l.sort((m,h)=>Ie(m.path,h.path));let u=await Fe(e,l);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function qh(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,u=f?.hash??null,m=l?.hash??null;if(u===null&&m!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:m,mode:l.mode});return}if(m===null&&u!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(d===null&&u!==null&&m!==null){if(u===m){r.push(_e(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await se(e,u),p=await se(e,m);if(Te(h)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=St(""),w=St(h),y=St(p),x=ms(w,g,y,{conflictStyle:n?.conflictStyle});if(!x.conflict){let R=await Xi(e,x.result);r.push(_e(a,R,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3));let b=hr(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),E=await He(e,"blob",Jn.encode(b));i.set(a,{hash:E,mode:f.mode});return}if(d!==null&&u!==null&&m!==null){if(u===d){r.push(_e(a,m,l.mode));return}if(m===d){r.push(_e(a,u,f.mode));return}if(u===m){r.push(_e(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),bn(c.mode)||bn(f.mode)||bn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await se(e,d),p=await se(e,u),g=await se(e,m);if(Te(p)||Te(g)||Te(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=St(h),y=St(p),x=St(g),b=ms(y,w,x,{conflictStyle:n?.conflictStyle});if(b.conflict){let E=t.pathnames[1],R=t.pathnames[2],k=E!==a||R!==a,C={path:a,reason:"content"};k&&(E!==a&&(C.oursOrigPath=E),R!==a&&(C.theirsOrigPath=R)),o.push(C),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3));let P=k?`${n?.a??"HEAD"}:${E}`:n?.a??"HEAD",T=k?`${n?.b??"theirs"}:${R}`:n?.b??"theirs",D=hr(p,h,g,{a:P,b:T,conflictStyle:n?.conflictStyle}),O=await He(e,"blob",Jn.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let E=await Xi(e,b.result);r.push(_e(a,E,f.mode))}return}}var zh=200;async function zf(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await j(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await j(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],u=(await j(e,d)).tree,m=null;if(o>=zh)m=f;else{let g=await Ft(e,c,d);g.length===0?m=null:g.length===1?m=(await j(e,g[0])).tree:m=await zf(e,c,d,g,o+1)}let h=await Ut(e,m,f,u);f=await Kh(e,h,o);let p=rn({type:"commit",tree:f,parents:[c,d],author:Gf,committer:Gf,message:"merged common ancestors"});c=await He(e,"commit",p)}return f}async function Kh(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),m=s(l,2),h=s(d,3);if(m&&h){let p=Tr.decode((await be(e,m.hash)).content),g=Tr.decode((await be(e,h.hash)).content),w=u?Tr.decode((await be(e,u.hash)).content):"",y=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",E=hr(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:y}),R=await He(e,"blob",Jn.encode(E));r.push({path:l,mode:m.mode,hash:R,stage:0,stat:Se()}),r.push({path:d,mode:h.mode,hash:R,stage:0,stat:Se()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let l=Tr.decode((await be(e,c.hash)).content),d=Tr.decode((await be(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?Tr.decode((await be(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,y=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=hr(l,m,d,{a:w,o:i.o,b:y,markerSize:i.markerSize}),b=await He(e,"blob",Jn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Se()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ie(a.path,c.path)),Fe(e,r)}async function Xi(e,t){let n=t.map(Ki);if(n.length===0)return He(e,"blob",Jn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
249
+ `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function Yi(e){return e.endsWith("\0")?e.slice(0,-1):e}function Gf(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}Ce();ae();gn();me();nr();Ae();tt();fn();var vr=new TextDecoder,Jn=new TextEncoder,Lf={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Ut(e,t,n,r,o){let{paths:s,baseMap:i,oursMap:a,theirsMap:c}=await Uh(e,t,n,r),f=await Wh(e,s,i,a,c,o);return qh(e,s,o,f)}async function gs(e,t,n,r){let o=await Ft(e,t,n),s=await j(e,t),i=await j(e,n);if(o.length===0)return{...await Ut(e,null,s.tree,i.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await Ut(e,f.tree,s.tree,i.tree,r),baseTree:f.tree}}let a=await Kf(e,t,n,o,1);return{...await Ut(e,a,s.tree,i.tree,r),baseTree:a}}async function Uh(e,t,n,r){let o=await fe(e,t),s=await fe(e,n),i=await fe(e,r),a=new Set;for(let f of o.keys())a.add(f);for(let f of s.keys())a.add(f);for(let f of i.keys())a.add(f);let c=new Map;for(let f of a){let l=o.get(f)??null,d=s.get(f)??null,u=i.get(f)??null,m=l?{hash:l.hash,mode:l.mode}:null,h=d?{hash:d.hash,mode:d.mode}:null,p=u?{hash:u.hash,mode:u.mode}:null,g=(l?1:0)|(d?2:0)|(u?4:0),w=l?.hash??null,y=d?.hash??null,x=u?.hash??null,b=0;w!==null&&w===y&&(b|=3),w!==null&&w===x&&(b|=5),y!==null&&y===x&&(b|=6);let E={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:b,merged:{result:null,clean:!1},pathConflict:!1};if(Bh(E)){c.set(f,E);continue}c.set(f,E)}return{paths:c,baseMap:o,oursMap:s,theirsMap:i}}function Bh(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,i=r?.hash??null;return s===o&&i===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===i&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&i===null?(e.merged={result:null,clean:!0},!0):i===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&i!==o?(r?e.merged={result:{hash:i,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Wh(e,t,n,r,o,s){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[S,A]of n)r.has(S)||a.push({path:S,status:"deleted",oldHash:A.hash,oldMode:A.mode}),o.has(S)||c.push({path:S,status:"deleted",oldHash:A.hash,oldMode:A.mode});for(let[S,A]of r)n.has(S)||a.push({path:S,status:"added",newHash:A.hash,newMode:A.mode});for(let[S,A]of o)n.has(S)||c.push({path:S,status:"added",newHash:A.hash,newMode:A.mode});let f=await it(e,a),l=await it(e,c);if(f.renames.length===0&&l.renames.length===0)return i;let d=new Map,u=new Map;for(let S of f.renames)d.set(S.oldPath,S);for(let S of l.renames)u.set(S.oldPath,S);let m=new Set;for(let[S]of r)!n.has(S)&&o.has(S)&&m.add(S);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(S,A,_=0){i.msgBuf.push({sortKey:S,subOrder:_,text:A})}for(let S of[...n.keys()].sort()){let A=d.get(S),_=u.get(S);if(!A&&!_)continue;let F=n.get(S);if(h.add(S),A&&_)if(h.add(A.newPath),h.add(_.newPath),A.newPath===_.newPath){let U=r.get(A.newPath),L=o.get(_.newPath);if(U.hash===L.hash)i.entries.push(xt(A.newPath,U));else{let K=Xi(t,A.newPath);K.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],K.pathnames=[S,A.newPath,_.newPath],K.filemask=7,K.merged={result:null,clean:!1}}}else{let U=r.get(A.newPath),L=o.get(_.newPath),K=await zf(e,F,U,L,s);K.conflict&&w(S,`Auto-merging ${S}`,-1),i.conflicts.push({path:S,reason:"rename-rename",oursPath:A.newPath,theirsPath:_.newPath}),w(S,`CONFLICT (rename/rename): ${S} renamed to ${A.newPath} in ${p} and to ${_.newPath} in ${g}.`),i.entries.push(xt(S,F,1)),i.entries.push(ft(A.newPath,U.mode,K.hash,2)),i.entries.push(ft(_.newPath,L.mode,K.hash,3)),i.worktreeBlobs.set(A.newPath,{hash:K.hash,mode:U.mode}),i.worktreeBlobs.set(_.newPath,{hash:K.hash,mode:L.mode})}else if(A){h.add(A.newPath);let U=o.get(S),L=r.get(A.newPath),K=m.has(A.newPath);if(U)if(K)await Wf(e,i,A.newPath,S,F,L,U,r,o,!1,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(A.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(A.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(A.newPath,L.mode,U.hash));else{let te=Xi(t,A.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:L.hash,mode:L.mode},{hash:U.hash,mode:U.mode}],te.pathnames=[S,A.newPath,S],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=o.get(A.newPath);if(i.conflicts.push({path:A.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:S}),w(A.newPath,`CONFLICT (rename/delete): ${S} renamed to ${A.newPath} in ${p}, but deleted in ${g}.`),te){i.conflicts.push({path:A.newPath,reason:"add-add"}),w(A.newPath,`Auto-merging ${A.newPath}`,0),w(A.newPath,`CONFLICT (add/add): Merge conflict in ${A.newPath}`,1),i.entries.push(xt(A.newPath,L,2)),i.entries.push(xt(A.newPath,te,3));let J=await Po(e,L.hash,te.hash,L.mode,s);i.worktreeBlobs.set(A.newPath,{hash:J,mode:L.mode})}else i.entries.push(ft(A.newPath,F.mode,F.hash,1)),i.entries.push(xt(A.newPath,L,2)),i.worktreeBlobs.set(A.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(A.newPath,`CONFLICT (modify/delete): ${A.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${A.newPath} left in tree.`,1)}}else if(_){h.add(_.newPath);let U=r.get(S),L=o.get(_.newPath),K=m.has(_.newPath);if(U)if(K)await Wf(e,i,_.newPath,S,F,U,L,r,o,!0,s);else if(U.hash===F.hash&&L.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(U.hash===F.hash)i.entries.push(xt(_.newPath,L));else if(L.hash===F.hash)i.entries.push(ft(_.newPath,L.mode,U.hash));else{let te=Xi(t,_.newPath);te.stages=[{hash:F.hash,mode:F.mode},{hash:U.hash,mode:U.mode},{hash:L.hash,mode:L.mode}],te.pathnames=[S,S,_.newPath],te.filemask=7,te.merged={result:null,clean:!1}}else{let te=r.get(_.newPath);if(i.conflicts.push({path:_.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:S}),w(_.newPath,`CONFLICT (rename/delete): ${S} renamed to ${_.newPath} in ${g}, but deleted in ${p}.`),te){i.conflicts.push({path:_.newPath,reason:"add-add"}),w(_.newPath,`Auto-merging ${_.newPath}`,0),w(_.newPath,`CONFLICT (add/add): Merge conflict in ${_.newPath}`,1),i.entries.push(xt(_.newPath,te,2)),i.entries.push(xt(_.newPath,L,3));let J=await Po(e,te.hash,L.hash,te.mode,s);i.worktreeBlobs.set(_.newPath,{hash:J,mode:te.mode})}else i.entries.push(ft(_.newPath,F.mode,F.hash,1)),i.entries.push(xt(_.newPath,L,3)),i.worktreeBlobs.set(_.newPath,{hash:L.hash,mode:L.mode}),L.hash!==F.hash&&w(_.newPath,`CONFLICT (modify/delete): ${_.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${_.newPath} left in tree.`,1)}}}let y=new Set(f.renames.map(S=>S.newPath)),x=new Set(l.renames.map(S=>S.newPath)),b=Nf(n,r),E=Nf(n,o),R=_f(b,o,n),k=_f(E,r,n),C=Ff(f.renames,R),P=Ff(l.renames,k),T=Uf(C),D=Uf(P);for(let S of[...T.keys()])D.has(S)&&(T.delete(S),D.delete(S));let O=new Set(T.keys()),N=new Set(D.keys());if(D.size>0)for(let S of a){if(S.status!=="added"||y.has(S.path))continue;let A=Bf(S.path,D,O);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(r.has(A)){w(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${S.path}.`,1);continue}let U=r.get(S.path),L=o.get(A)??n.get(A);i.entries.push(ft(A,U.mode,U.hash,2)),L&&i.entries.push(ft(A,L.mode,L.hash,3)),i.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:A,reason:"add-add"}),w(A,`CONFLICT (file location): ${S.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let K=t.get(S.path);K&&(K.merged={result:null,clean:!0}),h.add(S.path);continue}let _=r.get(S.path);i.entries.push(ft(A,_.mode,_.hash,2)),i.worktreeBlobs.set(A,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:A,reason:"directory-rename"}),w(A,`CONFLICT (file location): ${S.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(S.path);F&&(F.merged={result:null,clean:!0}),h.add(S.path)}if(T.size>0)for(let S of c){if(S.status!=="added"||x.has(S.path))continue;let A=Bf(S.path,T,N);if(!A)continue;if(t.has(A)||n.has(A)||r.has(A)||o.has(A)){if(o.has(A)){w(A,`CONFLICT (implicit dir rename): Existing file/dir at ${A} in the way of implicit directory rename(s) putting the following path(s) there: ${S.path}.`,1);continue}let U=o.get(S.path),L=r.get(A)??n.get(A);L&&i.entries.push(ft(A,L.mode,L.hash,2)),i.entries.push(ft(A,U.mode,U.hash,3)),i.worktreeBlobs.set(A,{hash:U.hash,mode:U.mode}),i.conflicts.push({path:A,reason:"add-add"}),w(A,`CONFLICT (file location): ${S.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${A}.`,1);let K=t.get(S.path);K&&(K.merged={result:null,clean:!0}),h.add(S.path);continue}let _=o.get(S.path);i.entries.push(ft(A,_.mode,_.hash,3)),i.worktreeBlobs.set(A,{hash:_.hash,mode:_.mode}),i.conflicts.push({path:A,reason:"directory-rename"}),w(A,`CONFLICT (file location): ${S.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${A}.`,1);let F=t.get(S.path);F&&(F.merged={result:null,clean:!0}),h.add(S.path)}let H=new Set(i.entries.map(S=>S.path));for(let S of H){let A=t.get(S);A&&(A.merged={result:null,clean:!0})}for(let S of h){if(H.has(S))continue;let A=t.get(S);if(!A||A.merged.clean)continue;A.filemask===7&&!A.pathConflict||(A.merged={result:null,clean:!0})}return i}function Nf(e,t){let n=new Set;for(let s of e.keys()){let i=Tt(s);for(;i;)n.add(i),i=Tt(i)}let r=new Set;for(let s of t.keys()){let i=Tt(s);for(;i;)r.add(i),i=Tt(i)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function _f(e,t,n){if(e.size===0)return e;let r=new Set;for(let o of t.keys()){if(n.has(o))continue;let s=Tt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=Tt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=Tt(s)}return r}function Ff(e,t){let n=new Map;for(let r of e){let o=Tt(r.oldPath),s=Tt(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=Tt(o),s=Tt(s)}}return n}function Uf(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,i=null;for(let[a,c]of r)c===o?s=o:c>o&&(o=c,i=a);o>0&&s!==o&&i!==null&&t.set(n,i)}return t}function Bf(e,t,n){let r=Tt(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=Tt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function Tt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Wf(e,t,n,r,o,s,i,a,c,f=!1,l){let d=f?a.get(n):c.get(n),u=f?i:s;if(d.hash===u.hash){t.entries.push(ft(n,d.mode,d.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await zf(e,o,s,i,l,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(d.hash===h.hash)t.entries.push(ft(n,d.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(xt(n,d,2)),t.entries.push(ft(n,i.mode,h.hash,3));let p=await Po(e,d.hash,h.hash,d.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:d.mode})}else{t.entries.push(ft(n,s.mode,h.hash,2)),t.entries.push(xt(n,d,3));let p=await Po(e,h.hash,d.hash,s.mode,l);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function zf(e,t,n,r,o,s,i){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(bn(t.mode)||bn(n.mode)||bn(r.mode))return{hash:n.hash,conflict:!0};let a=await se(e,t.hash),c=await se(e,n.hash),f=await se(e,r.hash);if(Te(c)||Te(f)||Te(a))return{hash:n.hash,conflict:!0};let l=St(a),d=St(c),u=St(f),m=o?.conflictStyle,h=hs(d,l,u,{conflictStyle:m});if(!h.conflict)return{hash:await Ji(e,h.result),conflict:!1};let p=o?.a??"HEAD",g=o?.b??"theirs",w=s?.oursPath?`${p}:${s.oursPath}`:p,y=s?.theirsPath?`${g}:${s.theirsPath}`:g,x=hr(c,a,f,{a:w,b:y,markerSize:i??7,conflictStyle:m});return{hash:await He(e,"blob",Jn.encode(x)),conflict:!0}}async function Po(e,t,n,r,o){let s=await se(e,t),i=await se(e,n),a=hr(s,"",i,{a:o?.a??"HEAD",b:o?.b??"theirs",conflictStyle:o?.conflictStyle});return He(e,"blob",Jn.encode(a))}function xt(e,t,n=0){return ft(e,t.mode,t.hash,n)}function ft(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:Se()}}async function qh(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(m,h,p=0){i.push({sortKey:m,subOrder:p,text:h})}for(let m of[...t.keys()].sort()){let h=t.get(m);if(h.merged.clean){h.merged.result?.hash&&o.push(_e(m,h.merged.result.hash,h.merged.result.mode));continue}await zh(e,h,n,o,s,c,a)}i.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=i.map(m=>m.text),l=[],d=new Set;for(let m of o)m.stage===0&&(l.push(m),d.add(m.path));for(let[m,h]of a)d.has(m)||l.push(_e(m,h.hash,h.mode));l.sort((m,h)=>Ie(m.path,h.path));let u=await Fe(e,l);return{entries:o,conflicts:s,messages:f,resultTree:u}}async function zh(e,t,n,r,o,s,i){let a=t.path,[c,f,l]=t.stages,d=c?.hash??null,u=f?.hash??null,m=l?.hash??null;if(u===null&&m!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:m,mode:l.mode});return}if(m===null&&u!==null&&d!==null){o.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(a,`CONFLICT (modify/delete): ${a} deleted in ${h} and modified in ${p}. Version ${p} of ${a} left in tree.`),c&&r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),i.set(a,{hash:u,mode:f.mode});return}if(d===null&&u!==null&&m!==null){if(u===m){r.push(_e(a,u,f.mode));return}s(a,`Auto-merging ${a}`,0);let h=await se(e,u),p=await se(e,m);if(Te(h)||Te(p)){o.push({path:a,reason:"add-add"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let g=St(""),w=St(h),y=St(p),x=hs(w,g,y,{conflictStyle:n?.conflictStyle});if(!x.conflict){let R=await Ji(e,x.result);r.push(_e(a,R,f.mode));return}o.push({path:a,reason:"add-add"}),s(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3));let b=hr(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),E=await He(e,"blob",Jn.encode(b));i.set(a,{hash:E,mode:f.mode});return}if(d!==null&&u!==null&&m!==null){if(u===d){r.push(_e(a,m,l.mode));return}if(m===d){r.push(_e(a,u,f.mode));return}if(u===m){r.push(_e(a,u,f.mode));return}if(s(a,`Auto-merging ${a}`,0),bn(c.mode)||bn(f.mode)||bn(l.mode)){o.push({path:a,reason:"content"}),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let h=await se(e,d),p=await se(e,u),g=await se(e,m);if(Te(p)||Te(g)||Te(h)){o.push({path:a,reason:"content"}),s(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3)),i.set(a,{hash:u,mode:f.mode});return}let w=St(h),y=St(p),x=St(g),b=hs(y,w,x,{conflictStyle:n?.conflictStyle});if(b.conflict){let E=t.pathnames[1],R=t.pathnames[2],k=E!==a||R!==a,C={path:a,reason:"content"};k&&(E!==a&&(C.oursOrigPath=E),R!==a&&(C.theirsOrigPath=R)),o.push(C),s(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(_e(a,d,c.mode,1)),r.push(_e(a,u,f.mode,2)),r.push(_e(a,m,l.mode,3));let P=k?`${n?.a??"HEAD"}:${E}`:n?.a??"HEAD",T=k?`${n?.b??"theirs"}:${R}`:n?.b??"theirs",D=hr(p,h,g,{a:P,b:T,conflictStyle:n?.conflictStyle}),O=await He(e,"blob",Jn.encode(D));i.set(a,{hash:O,mode:f.mode})}else{let E=await Ji(e,b.result);r.push(_e(a,E,f.mode))}return}}var Kh=200;async function Kf(e,t,n,r,o){let s=await Promise.all(r.map(async l=>({hash:l,timestamp:(await j(e,l)).committer.timestamp})));s.sort((l,d)=>l.timestamp-d.timestamp);let i=s.map(l=>l.hash),a=i[0],c=a,f=(await j(e,a)).tree;for(let l=1;l<i.length;l++){let d=i[l],u=(await j(e,d)).tree,m=null;if(o>=Kh)m=f;else{let g=await Ft(e,c,d);g.length===0?m=null:g.length===1?m=(await j(e,g[0])).tree:m=await Kf(e,c,d,g,o+1)}let h=await Ut(e,m,f,u);f=await Vh(e,h,o);let p=rn({type:"commit",tree:f,parents:[c,d],author:Lf,committer:Lf,message:"merged common ancestors"});c=await He(e,"commit",p)}return f}async function Vh(e,t,n){let r=t.entries.filter(a=>a.stage===0),o=new Map;for(let a of t.entries)a.stage>0&&o.set(`${a.path}\0${a.stage}`,a);let s=(a,c)=>o.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of t.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let l=s(a.path,1);if(l){r.push({...l,stage:0});continue}}if(a.reason==="rename-rename"){let l=a.oursPath??a.path,d=a.theirsPath??a.path,u=s(a.path,1),m=s(l,2),h=s(d,3);if(m&&h){let p=vr.decode((await be(e,m.hash)).content),g=vr.decode((await be(e,h.hash)).content),w=u?vr.decode((await be(e,u.hash)).content):"",y=8+n*2,x=i.a??"Temporary merge branch 1",b=i.b??"Temporary merge branch 2",E=hr(p,w,g,{a:`${x}:${l}`,o:i.o,b:`${b}:${d}`,markerSize:y}),R=await He(e,"blob",Jn.encode(E));r.push({path:l,mode:m.mode,hash:R,stage:0,stat:Se()}),r.push({path:d,mode:h.mode,hash:R,stage:0,stat:Se()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(a.path,2),f=s(a.path,3);if(c&&f&&(a.reason==="content"||a.reason==="add-add")){let l=vr.decode((await be(e,c.hash)).content),d=vr.decode((await be(e,f.hash)).content),u=a.reason==="content"?s(a.path,1):null,m=u?vr.decode((await be(e,u.hash)).content):"",h=a.oursOrigPath||a.theirsOrigPath,p=i.a??"Temporary merge branch 1",g=i.b??"Temporary merge branch 2",w=h?`${p}:${a.oursOrigPath??a.path}`:p,y=h?`${g}:${a.theirsOrigPath??a.path}`:g,x=hr(l,m,d,{a:w,o:i.o,b:y,markerSize:i.markerSize}),b=await He(e,"blob",Jn.encode(x));r.push({path:a.path,mode:c.mode,hash:b,stage:0,stat:Se()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((a,c)=>Ie(a.path,c.path)),Fe(e,r)}async function Ji(e,t){let n=t.map(Yi);if(n.length===0)return He(e,"blob",Jn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
250
250
  `):`${n.join(`
251
251
  `)}
252
- `;return He(e,"blob",Jn.encode(s))}function _e(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Se()}}function Vi(e,t){let n=e.get(t);return n||(n={path:t,stages:[null,null,null],pathnames:[t,t,t],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},e.set(t,n)),n}function hs(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
252
+ `;return He(e,"blob",Jn.encode(s))}function _e(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:Se()}}function Xi(e,t){let n=e.get(t);return n||(n={path:t,stages:[null,null,null],pathnames:[t,t,t],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},e.set(t,n)),n}function ps(e,t,n,r,o){let s=r==="untracked"?`error: The following untracked working tree files would be overwritten by ${t}:`:`error: Your local changes to the following files would be overwritten by ${t}:`;if(n==="merge"){if(o==="staged")return`${s}
253
253
  ${e.join(" ")}
254
254
  Merge with strategy ort failed.
255
255
  `;let c=e.map(l=>` ${l}`).join(`
@@ -264,7 +264,7 @@ ${i}
264
264
  ${a}
265
265
  Aborting
266
266
  fatal: ${n} failed
267
- `}function Wf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
267
+ `}function qf(e,t,n,r){let o=[];if(e.length>0){let i=e.map(a=>` ${a}`).join(`
268
268
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
269
269
  ${i}
270
270
  Please commit your changes or stash them before you ${n}.
@@ -274,13 +274,13 @@ ${i}
274
274
  Please move or remove them before you ${n}.
275
275
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
276
276
  ${s}
277
- `}async function $n(e,t,n,r){let o=await z(e),s=await fe(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Le(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let y=s.get(g);(!y||y.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await Yi(e,o,s);let w=r.operationName??"merge",y=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:hs(g,w,y,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await or(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Zs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Yi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),y=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&y.length>0?x=Wf(w,y,p,g):y.length>0?x=hs(y,p,g,"untracked","worktree"):x=hs(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await or(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Js,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Yi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(E=>E.error==="WOULD_OVERWRITE"||E.error==="NOT_UPTODATE_FILE").map(E=>E.path).sort(),y=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),x=[];w.length>0&&x.push(hs(w,p,g,"local","worktree")),y.length>0&&x.push(hs(y,p,g,"untracked","worktree"));let b;return x.length>1?b=Wf(w,y,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Ne(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),l=[...a,...f];l.sort((h,p)=>Ie(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await de(e,d);let u=l.filter(h=>h.stage===0),m=await Fe(e,u);return{ok:!0,finalIndex:d,mergedTreeHash:m}}async function Yi(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=v(e.workTree,r.path);await e.fs.exists(o)||await dt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ae();ze();ge();Ae();fn();function Kf(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[q.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:$().describe("Abort the current cherry-pick operation"),continue:$().describe("Continue the cherry-pick after conflict resolution"),skip:$().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":$().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:V.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:$().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let F=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(le(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Yh(s,r.env);return U.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let F=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(le(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Xh(s,r.env);if(U.exitCode===0){let L=await Y(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:L,hadConflicts:!1})}return U}if(n.skip)return Vh(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(le(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 z(s);if(n.noCommit){let F=u.entries.filter(U=>U.stage>0);if(F.length>0){let K=F.slice(0,10).map(J=>`${J.path}: unmerged (${J.hash})`).join(`
277
+ `}async function $n(e,t,n,r){let o=await z(e),s=await fe(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(Le(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let y=s.get(g);(!y||y.hash!==w.hash)&&p.push(g)}for(let[g]of s)h.has(g)||p.push(g);if(p.length>0){let g=[...p].sort();await Zi(e,o,s);let w=r.operationName??"merge",y=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:ps(g,w,y,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await or(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Js,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await Zi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(b=>b.error==="WOULD_OVERWRITE"||b.error==="NOT_UPTODATE_FILE").map(b=>b.path).sort(),y=h.errors.filter(b=>b.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||b.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(b=>b.path).sort(),x;return w.length>0&&y.length>0?x=qf(w,y,p,g):y.length>0?x=ps(y,p,g,"untracked","worktree"):x=ps(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:x,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await or(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Qs,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await Zi(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(E=>E.error==="WOULD_OVERWRITE"||E.error==="NOT_UPTODATE_FILE").map(E=>E.path).sort(),y=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),x=[];w.length>0&&x.push(ps(w,p,g,"local","worktree")),y.length>0&&x.push(ps(y,p,g,"untracked","worktree"));let b;return x.length>1?b=qf(w,y,p,g):b=x[0]??"",{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Ne(e,h.worktreeOps)}let i=new Set,a=t.entries;if(r.preflightOnewayCheck){let h=[];for(let p of t.entries){if(p.stage===0){let g=s.get(p.path);if(g&&g.hash===p.hash){i.add(p.path);continue}}h.push(p)}a=h}let c=new Set(a.map(h=>h.path));for(let h of s.keys())i.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),l=[...a,...f];l.sort((h,p)=>Ie(h.path,p.path)||h.stage-p.stage);let d={version:2,entries:l};await de(e,d);let u=l.filter(h=>h.stage===0),m=await Fe(e,u);return{ok:!0,finalIndex:d,mergedTreeHash:m}}async function Zi(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 dt(e,{path:r.path,hash:r.hash,mode:r.mode})}}ae();ze();ge();Ae();fn();function Vf(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[q.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:$().describe("Abort the current cherry-pick operation"),continue:$().describe("Continue the cherry-pick after conflict resolution"),skip:$().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":$().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:V.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:$().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let F=await t?.hooks?.preCherryPick?.({repo:s,mode:"abort",commitRef:null});if(le(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Xh(s,r.env);return U.exitCode===0&&await t?.hooks?.postCherryPick?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),U}if(n.continue){let F=await t?.hooks?.preCherryPick?.({repo:s,mode:"continue",commitRef:null});if(le(F))return{stdout:"",stderr:F.message??"",exitCode:1};let U=await Zh(s,r.env);if(U.exitCode===0){let L=await Y(s);await t?.hooks?.postCherryPick?.({repo:s,mode:"continue",commitHash:L,hadConflicts:!1})}return U}if(n.skip)return Yh(s,r.env);let i=n.commit;if(!i)return I("you must specify a commit to cherry-pick");let a=await t?.hooks?.preCherryPick?.({repo:s,mode:"pick",commitRef:i});if(le(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 z(s);if(n.noCommit){let F=u.entries.filter(U=>U.stage>0);if(F.length>0){let K=F.slice(0,10).map(J=>`${J.path}: unmerged (${J.hash})`).join(`
278
278
  `),te=F.length>10?`
279
279
  ...`:"";return G(`${K}${te}
280
280
  error: your index file is unmerged.
281
281
  fatal: cherry-pick failed
282
282
  `,128)}}else{let F=kn(u,"Cherry-picking",`fatal: cherry-pick failed
283
- `);if(F)return F}let m=await j(s,d),p=!!n["record-origin"]?Zh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let F=await fe(s,m.tree);if(Un(u,F))return G(`error: your local changes would be overwritten by cherry-pick.
283
+ `);if(F)return F}let m=await j(s,d),p=!!n["record-origin"]?Jh(l.message,f):l.message;if(s.workTree&&!n.noCommit){let F=await fe(s,m.tree);if(Un(u,F))return G(`error: your local changes would be overwritten by cherry-pick.
284
284
  hint: commit your changes or stash them to proceed.
285
285
  fatal: cherry-pick failed
286
286
  `,128)}if(l.parents.length>1){if(!n.mainline)return G(`error: commit ${f} is a merge but no -m option was given.
@@ -316,53 +316,53 @@ hint: Disable this message with "git config set advice.mergeConflict false"
316
316
  `)[0]??"",O=T?.type==="symbolic"?T.target:"HEAD";await ce(s,r.env,O,d,P,`cherry-pick: ${D}`,T?.type==="symbolic");let N=T?.type==="symbolic"?Pe(T.target):"detached HEAD",H=m.tree,S=await un(s,H,k,l.author,C,!0),A=Dt(N,P,p),_=E.messages.length>0?`${E.messages.join(`
317
317
  `)}
318
318
  `:"";return await t?.hooks?.postCherryPick?.({repo:s,mode:"pick",commitHash:P,hadConflicts:!1}),{stdout:`${_}${A}
319
- ${S}`,stderr:"",exitCode:0}}})}async function Vh(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return G(`error: no cherry-pick in progress
319
+ ${S}`,stderr:"",exitCode:0}}})}async function Yh(e,t){if(!await B(e,"CHERRY_PICK_HEAD"))return G(`error: no cherry-pick in progress
320
320
  fatal: cherry-pick failed
321
- `,128);let r=await Y(e);if(!r)return I("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await eo(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
321
+ `,128);let r=await Y(e);if(!r)return I("unable to resolve HEAD");let o=await j(e,r),s=await z(e),i=await to(e,o.tree,s,r);if(!i.success){let a=i.errorOutput;return{...a,stderr:a.stderr+`error: failed to skip the commit
322
322
  fatal: cherry-pick failed
323
- `}}return await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps),await ce(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Gt(e),{stdout:"",stderr:"",exitCode:0}}async function Yh(e,t){return await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
323
+ `}}return await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps),await ce(e,t,"HEAD",r,r,`reset: moving to ${r}`),await Gt(e),{stdout:"",stderr:"",exitCode:0}}async function Xh(e,t){return await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
324
324
  fatal: cherry-pick failed
325
325
  `,128),operationName:"cherry-pick",clearState:Gt,origHeadAsTargetRev:!0}):await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
326
326
  fatal: cherry-pick failed
327
327
  `,128),operationName:"cherry-pick",clearState:Lt,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
328
328
  fatal: cherry-pick failed
329
- `,128)}async function Xh(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return G(`error: no cherry-pick or revert in progress
329
+ `,128)}async function Zh(e,t){let n=await B(e,"CHERRY_PICK_HEAD");if(!n)return G(`error: no cherry-pick or revert in progress
330
330
  fatal: cherry-pick failed
331
331
  `,128);let r=await z(e),o=kn(r,"Committing");if(o)return o;let s=await j(e,n),i=await Oe(e,"MERGE_MSG");if(!i)return G(`Aborting commit due to empty commit message.
332
332
  `,1);let a=await Oe(e,"SQUASH_MSG");a&&(i=a+i),i=Xt(i);let c=Le(r),f=await Fe(e,c),l=await Qe(e);if(M(l))return l;let u=(await j(e,l)).tree,m=await nt(e,t);if(M(m))return m;let h=Mt(i),p=await bt(e,f,[l],s.author,m,h);await Gt(e),await Lt(e),await ye(e,"SQUASH_MSG");let g=await Q(e),w=ue(h),y=g?.type==="symbolic"?g.target:"HEAD";await ce(e,t,y,l,p,`commit (cherry-pick): ${w}`,g?.type==="symbolic");let x=g?.type==="symbolic"?Pe(g.target):"detached HEAD",b=await un(e,u,f,s.author,m,!0);return{stdout:`${Dt(x,p,i)}
333
- ${b}`,stderr:"",exitCode:0}}function Zh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
333
+ ${b}`,stderr:"",exitCode:0}}function Jh(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
334
334
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
335
335
  ${n}
336
336
  `:`${r}
337
337
 
338
338
  ${n}
339
- `}oe();qe();Xs();Ce();me();function Vf(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[q.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:$().alias("f").describe("Required to actually remove files"),"dry-run":$().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:$().alias("d").describe("Also remove untracked directories"),removeIgnored:$().alias("x").describe("Remove ignored files as well"),onlyIgnored:$().alias("X").describe("Remove only ignored files"),exclude:V.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,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 m=await z(s),h=new Set(m.entries.map(k=>k.path)),p=ut(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(k=>Ue(k,p)):null,y=n.exclude?[n.exclude]:[],x=await Yf(s,a,"",{trackedPaths:h,removeDirs:l,removeIgnored:d,onlyIgnored:u,extraExcludes:y}),b;w?b=x.filter(k=>Ee(w,k.path)):b=x,b.sort((k,C)=>k.path<C.path?-1:k.path>C.path?1:0);let E=[];if(c)for(let k of b){let C=k.isDir?`Would remove ${k.path}/`:`Would remove ${k.path}`;E.push(C)}else for(let k of b){let C=v(a,k.path);k.isDir?(await r.fs.rm(C,{recursive:!0}),E.push(`Removing ${k.path}/`)):(await r.fs.rm(C),E.push(`Removing ${k.path}`))}return{stdout:E.length>0?`${E.join(`
339
+ `}oe();qe();Zs();Ce();me();function Yf(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[q.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:$().alias("f").describe("Required to actually remove files"),"dry-run":$().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:$().alias("d").describe("Also remove untracked directories"),removeIgnored:$().alias("x").describe("Remove ignored files as well"),onlyIgnored:$().alias("X").describe("Remove only ignored files"),exclude:V.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n["dry-run"],f=n.force,l=n.directories,d=n.removeIgnored,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 m=await z(s),h=new Set(m.entries.map(k=>k.path)),p=ut(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(k=>Ue(k,p)):null,y=n.exclude?[n.exclude]:[],x=await Xf(s,a,"",{trackedPaths:h,removeDirs:l,removeIgnored:d,onlyIgnored:u,extraExcludes:y}),b;w?b=x.filter(k=>Ee(w,k.path)):b=x,b.sort((k,C)=>k.path<C.path?-1:k.path>C.path?1:0);let E=[];if(c)for(let k of b){let C=k.isDir?`Would remove ${k.path}/`:`Would remove ${k.path}`;E.push(C)}else for(let k of b){let C=v(a,k.path);k.isDir?(await r.fs.rm(C,{recursive:!0}),E.push(`Removing ${k.path}/`)):(await r.fs.rm(C),E.push(`Removing ${k.path}`))}return{stdout:E.length>0?`${E.join(`
340
340
  `)}
341
- `:"",stderr:"",exitCode:0}}})}async function Yf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await Pr(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=rr(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
342
- `),l=os(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&&an(i,l,!0)==="ignored",m=Jh(r.trackedPaths,l),h=()=>Yf(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let u=i&&an(i,l,!1)==="ignored";r.onlyIgnored?u&&o.push({path:l,isDir:!1}):u&&s||o.push({path:l,isDir:!1})}}return o}function Jh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}oe();qe();Tn();Ce();ae();me();ze();ge();Gn();ae();me();var gs=2147483647;async function vr(e){let t=v(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
343
- `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function Qh(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(`
341
+ `:"",stderr:"",exitCode:0}}})}async function Xf(e,t,n,r){let o=[],s=!r.removeIgnored,i=null;if(s||r.onlyIgnored){i=r._ignore??await $r(e);let c=v(t,".gitignore");try{let f=await e.fs.readFile(c);i=rr(i,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
342
+ `),l=is(f,"","<cli>");i={...i,dirPatterns:[l,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=v(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let u=i&&an(i,l,!0)==="ignored",m=Qh(r.trackedPaths,l),h=()=>Xf(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(u&&!m){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(u&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let u=i&&an(i,l,!1)==="ignored";r.onlyIgnored?u&&o.push({path:l,isDir:!1}):u&&s||o.push({path:l,isDir:!1})}}return o}function Qh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}oe();qe();Tn();Ce();ae();me();ze();ge();Gn();ae();me();var ws=2147483647;async function Ar(e){let t=v(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
343
+ `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function ep(e,t){let n=v(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
344
344
  `)+`
345
- `)}async function Po(e){return(await vr(e)).size>0}async function Ar(e,t,n){let r=n??await vr(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await Qh(e,r)}async function Xf(e,t,n,r){if(n>=gs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Vt(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 Vt(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}}qe();Gn();ht();ae();var Oo=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),ep=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),$o=64,tp=4,Zi=4096,Zf=65536,np=127;function rp(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=op(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[u+h])^Oo[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=u+16;else{a=m;let h=m&o;i.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of i){let m=u.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(u)}for(let[u,m]of c){if(m.length<=$o)continue;let h=[],p=m.length/$o;for(let g=0;g<$o;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=$o}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let m=c.get(u);if(m){for(let h of m)l.push(h);d+=m.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function 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=Qf(i,a,r),a=Qf(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^Oo[f>>>23],l++;f=f>>>0;let u=d,m=0,h=0;for(;u<o;){if(h<Zi){f^=ep[t[u-16]],f=((f<<8|t[u])^Oo[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let x=e.entries[y];if(x.val!==f)continue;let b=x.ptr,E=s.byteLength-b,R=o-u;if(E>R&&(E=R),E<=h)break;let k=0;for(;k<E&&s[b+k]===t[u+k];)k++;if(k>h&&(h=k,m=b,h>=Zi))break}}if(h<tp)c(2),l===0&&a++,i[a++]=t[u++],l++,l===np&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Zf?h-Zf:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<Zi){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^Oo[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var Jf={blob:0,tree:1,commit:2,tag:3};function Io(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Jf[f.type]??99,u=Jf[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},u=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=u?u.byteLength:l.content.byteLength/2|0;if(b<16)continue;let E=sp(x,l.content,b);E&&(!u||E.byteLength<u.byteLength)&&(u=E,m=g.hash)}if(u&&m){d.delta=u,d.deltaBase=m;let p=s.get(m);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(rp(l.content)),c.push(l.hash)}return i}function op(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 Qf(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}Rr();ge();ae();gn();Cr();Ks();async function ip(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await ws(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 bs(e,l,i,f,c,r);return{count:c.length,objects:ap(c)}}async function Hr(e,t,n,r,o){let{count:s,objects:i}=await ip(e,t,n,r,o);return{count:s,objects:cp(e,i)}}async function*ap(e){for(let t of e)yield t}async function*cp(e,t){for await(let n of t){let r=await be(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Dr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function ws(e,t,n,r){if(n.has(t)||(n.add(t),!await Vt(e,t)))return;let o=await be(e,t);switch(o.type){case"commit":{let s=nn(o.content);if(await ws(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await ws(e,i,n,r);break}case"tree":{let s=_n(o.content);for(let i of s.entries)await ws(e,i.hash,n,r);break}case"tag":{let s=Kt(o.content);await ws(e,s.object,n,r);break}case"blob":break}}async function bs(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await be(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=nn(i.content);if(await bs(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await bs(e,c,n,r,o,s);break}case"tree":{let a=_n(i.content);for(let c of a.entries)await bs(e,c.hash,n,r,o,s);break}case"tag":{let a=Kt(i.content);await bs(e,a.object,n,r,o,s);break}case"blob":break}}var fp=new TextEncoder,So=new TextDecoder,el=65520,lp=new Uint8Array([48,48,48,48]),CR=new Uint8Array([48,48,48,49]),PR=new Uint8Array([48,48,48,50]);function On(e){let t=typeof e=="string"?fp.encode(e):e,n=4+t.byteLength;if(n>el)throw new Error(`pkt-line too long: ${n} bytes (max ${el})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function Ji(){return lp.slice()}function To(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function Mr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=So.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o===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 vo(e){if(e.type!=="data")return"";let t=So.decode(e.data);return t.endsWith(`
346
- `)?t.slice(0,-1):t}var dp=1,up=2,mp=3;function Qi(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 dp:t.push(f),o+=f.byteLength;break;case up:n.push(So.decode(f));break;case mp:r.push(So.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}ht();function ea(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ta(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ea(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let l=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(l))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=Mr(c);return hp(f,t)}function hp(e,t){let n=0,r=e[n];r?.type==="data"&&vo(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;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),m=l.slice(d+1);if(!(u===ee&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=u);continue}o.push({name:m,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var pp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function tl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=rl(r,pp),c=[];c.push(On(`want ${t[0]} ${a.join(" ")}
345
+ `)}async function $o(e){return(await Ar(e)).size>0}async function Hr(e,t,n){let r=n??await Ar(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await ep(e,r)}async function Zf(e,t,n,r){if(n>=ws)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Vt(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 Vt(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}}qe();Gn();ht();ae();var Io=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),tp=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Oo=64,np=4,Qi=4096,Jf=65536,rp=127;function sp(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=ip(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let u=n*16-16;u>=0;u-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[u+h])^Io[m>>>23];if(m=m>>>0,m===a)i[i.length-1].ptr=u+16;else{a=m;let h=m&o;i.push({ptr:u+16,val:m}),s[h]++}}let c=new Map;for(let u of i){let m=u.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(u)}for(let[u,m]of c){if(m.length<=Oo)continue;let h=[],p=m.length/Oo;for(let g=0;g<Oo;g++)h.push(m[Math.floor(g*p)]);c.set(u,h),s[u]=Oo}let f=new Uint32Array(r+1),l=[],d=0;for(let u=0;u<r;u++){f[u]=d;let m=c.get(u);if(m){for(let h of m)l.push(h);d+=m.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function op(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=el(i,a,r),a=el(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^Io[f>>>23],l++;f=f>>>0;let u=d,m=0,h=0;for(;u<o;){if(h<Qi){f^=tp[t[u-16]],f=((f<<8|t[u])^Io[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let y=g;y<w;y++){let x=e.entries[y];if(x.val!==f)continue;let b=x.ptr,E=s.byteLength-b,R=o-u;if(E>R&&(E=R),E<=h)break;let k=0;for(;k<E&&s[b+k]===t[u+k];)k++;if(k>h&&(h=k,m=b,h>=Qi))break}}if(h<np)c(2),l===0&&a++,i[a++]=t[u++],l++,l===rp&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;m>0&&s[m-1]===t[u-1];)if(h++,m--,u--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Jf?h-Jf:0;h-=p,c(8);let g=a++,w=128;if(m&255&&(i[a++]=m&255,w|=1),m&65280&&(i[a++]=m>>>8&255,w|=2),m&16711680&&(i[a++]=m>>>16&255,w|=4),m&4278190080&&(i[a++]=m>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,u+=h,m+=h,h=p,m>4294967295&&(h=0),h<Qi){f=0;for(let y=-16;y<0;y++)f=(f<<8|t[u+y])^Io[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var Qf={blob:0,tree:1,commit:2,tag:3};function So(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=Qf[f.type]??99,u=Qf[l.type]??99;return d!==u?d-u:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},u=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let b=u?u.byteLength:l.content.byteLength/2|0;if(b<16)continue;let E=op(x,l.content,b);E&&(!u||E.byteLength<u.byteLength)&&(u=E,m=g.hash)}if(u&&m){d.delta=u,d.deltaBase=m;let p=s.get(m);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(sp(l.content)),c.push(l.hash)}return i}function ip(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function el(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}xr();ge();ae();gn();Pr();Vs();async function ap(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await bs(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let u of d.parents)i.has(u)||a.push(u)}catch{}let c=[],f=new Set;for(let l of a)await ys(e,l,i,f,c,r);return{count:c.length,objects:cp(c)}}async function Dr(e,t,n,r,o){let{count:s,objects:i}=await ap(e,t,n,r,o);return{count:s,objects:fp(e,i)}}async function*cp(e){for(let t of e)yield t}async function*fp(e,t){for await(let n of t){let r=await be(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function Mr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function bs(e,t,n,r){if(n.has(t)||(n.add(t),!await Vt(e,t)))return;let o=await be(e,t);switch(o.type){case"commit":{let s=nn(o.content);if(await bs(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await bs(e,i,n,r);break}case"tree":{let s=_n(o.content);for(let i of s.entries)await bs(e,i.hash,n,r);break}case"tag":{let s=Kt(o.content);await bs(e,s.object,n,r);break}case"blob":break}}async function ys(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await be(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=nn(i.content);if(await ys(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await ys(e,c,n,r,o,s);break}case"tree":{let a=_n(i.content);for(let c of a.entries)await ys(e,c.hash,n,r,o,s);break}case"tag":{let a=Kt(i.content);await ys(e,a.object,n,r,o,s);break}case"blob":break}}var lp=new TextEncoder,To=new TextDecoder,tl=65520,dp=new Uint8Array([48,48,48,48]),$R=new Uint8Array([48,48,48,49]),OR=new Uint8Array([48,48,48,50]);function On(e){let t=typeof e=="string"?lp.encode(e):e,n=4+t.byteLength;if(n>tl)throw new Error(`pkt-line too long: ${n} bytes (max ${tl})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function ea(){return dp.slice()}function vo(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function jr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=To.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 Ao(e){if(e.type!=="data")return"";let t=To.decode(e.data);return t.endsWith(`
346
+ `)?t.slice(0,-1):t}var up=1,mp=2,hp=3;function ta(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case up:t.push(f),o+=f.byteLength;break;case mp:n.push(To.decode(f));break;case hp:r.push(To.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}ht();function na(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ra(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...na(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=jr(c);return pp(f,t)}function pp(e,t){let n=0,r=e[n];r?.type==="data"&&Ao(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),m=l.slice(d+1);if(!(u===ee&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=u);continue}o.push({name:m,hash:u})}}return{refs:o,capabilities:s,symrefs:i}}var gp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function nl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=sl(r,gp),c=[];c.push(On(`want ${t[0]} ${a.join(" ")}
347
347
  `));for(let m=1;m<t.length;m++)c.push(On(`want ${t[m]}
348
348
  `));if(i?.existingShallows)for(let m of i.existingShallows)c.push(On(`shallow ${m}
349
349
  `));i?.depth!==void 0&&c.push(On(`deepen ${i.depth}
350
- `)),c.push(Ji());for(let m of n)c.push(On(`have ${m}
350
+ `)),c.push(ea());for(let m of n)c.push(On(`have ${m}
351
351
  `));c.push(On(`done
352
- `));let f=To(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ea(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let u=new Uint8Array(await d.arrayBuffer());return gp(u,a.includes("side-band-64k"))}function gp(e,t){let n=Mr(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let u=n[d];if(!u||u.type==="flush"){i=d+1;continue}if(u.type!=="data")continue;let m=vo(u);if(m.startsWith("shallow "))o.push(m.slice(8)),i=d+1;else if(m.startsWith("unshallow "))s.push(m.slice(10)),i=d+1;else if(m.startsWith("ACK ")||m==="NAK")r.push(m),i=d+1;else{i=d;break}}let a=n.slice(i);if(t){let{packData:d,progress:u,errors:m}=Qi(a);if(m.length>0)throw new Error(`Remote error: ${m.join("")}`);return{packData:d,acks:r,progress:u,shallowLines:o,unshallowLines:s}}let c=0;for(let d of a)d.type==="data"&&(c+=d.data.byteLength);let f=new Uint8Array(c),l=0;for(let d of a)d.type==="data"&&(f.set(d.data,l),l+=d.data.byteLength);return{packData:f,acks:r,progress:[],shallowLines:o,unshallowLines:s}}var wp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function nl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=rl(r,wp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(On(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
352
+ `));let f=vo(...c),l=e.replace(/\/+$/,""),d=await s(`${l}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...na(o),"User-Agent":"just-git/1.0"},body:f});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${l}`);let u=new Uint8Array(await d.arrayBuffer());return wp(u,a.includes("side-band-64k"))}function wp(e,t){let n=jr(e),r=[],o=[],s=[],i=0;for(let d=0;d<n.length;d++){let u=n[d];if(!u||u.type==="flush"){i=d+1;continue}if(u.type!=="data")continue;let m=Ao(u);if(m.startsWith("shallow "))o.push(m.slice(8)),i=d+1;else if(m.startsWith("unshallow "))s.push(m.slice(10)),i=d+1;else if(m.startsWith("ACK ")||m==="NAK")r.push(m),i=d+1;else{i=d;break}}let a=n.slice(i);if(t){let{packData:d,progress:u,errors:m}=ta(a);if(m.length>0)throw new Error(`Remote error: ${m.join("")}`);return{packData:d,acks:r,progress:u,shallowLines:o,unshallowLines:s}}let c=0;for(let d of a)d.type==="data"&&(c+=d.data.byteLength);let f=new Uint8Array(c),l=0;for(let d of a)d.type==="data"&&(f.set(d.data,l),l+=d.data.byteLength);return{packData:f,acks:r,progress:[],shallowLines:o,unshallowLines:s}}var bp=["report-status","side-band-64k","ofs-delta","delete-refs"];async function rl(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let i=sl(r,bp),a=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");a.push(On(`${c.oldHash} ${c.newHash} ${c.refName}\0${i.join(" ")}
353
353
  `));for(let h of f)a.push(On(`${h.oldHash} ${h.newHash} ${h.refName}
354
- `));a.push(Ji());let l;if(n&&n.byteLength>0){let h=To(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=To(...a);let d=e.replace(/\/+$/,""),u=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ea(o),"User-Agent":"just-git/1.0"},body:l});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${d}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?bp(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function bp(e,t){let n,r=[];if(t){let a=Mr(e),{packData:c,progress:f,errors:l}=Qi(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=Mr(c)}else n=Mr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=vo(a);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))i.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),l=f.indexOf(" ");l!==-1?i.push({name:f.slice(0,l),ok:!1,error:f.slice(l+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function rl(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 ys=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await pe(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await B(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Q(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n,r){let o=await this.advertiseRefs();if(t.length===0)return{remoteRefs:o,objectCount:0};let s,i,a;if(r?.depth!==void 0){let l=r.existingShallows??new Set,d=await Xf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await na(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Bs(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ee&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await na(this.local,n,r);s&&await Bs(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ee,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await Pn(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},Es=class{constructor(t,n,r,o){this.local=t;this.url=n;this.auth=r;this.fetchFn=o}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await ta(this.url,"git-upload-pack",this.auth,this.fetchFn);this.cachedFetchCaps=t.capabilities,this.cachedFetchRefs=t.refs;let n=t.symrefs.get("HEAD");return n&&(this.headTarget=n),t.refs}async ensureFetchDiscovery(){return(!this.cachedFetchCaps||!this.cachedFetchRefs)&&await this.advertiseRefs(),{caps:this.cachedFetchCaps,refs:this.cachedFetchRefs}}async ensurePushDiscovery(){if(!this.cachedPushCaps){let t=await ta(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n,r){let{caps:o,refs:s}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:s,objectCount:0};let i=await tl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Bs(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==ee&&l.newHash!==ee&&!l.ok&&!await Pn(this.local,l.oldHash,l.newHash))return{updates:t.map(u=>u===l?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(l=>({oldHash:l.oldHash??ee,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==ee&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==ee&&s.push(l.oldHash);let a=null;i&&(a=await na(this.local,o,s)??null);let c=await nl(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(l=>{let d=c.refResults.find(h=>h.name===l.name),u=d?.ok??c.unpackOk,m=d?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...l,ok:u,error:m}})}}};async function na(e,t,n,r,o){let s=await Hr(e,t,n,r,o);if(s.count===0)return;let i=await Dr(s),c=Io(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Fs(c);return f}async function yp(e,t){let r=(await we(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function ra(e){return e.startsWith("http://")||e.startsWith("https://")}function sl(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function ol(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(ra(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function Ep(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 il(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return Ep(n)}async function al(e,t,n,r){if(ra(t)){let o=ol(t,e.networkPolicy);if(o)throw new Error(o);let s=await il(e,t,n);return new Es(e,t,s,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(t)??void 0),!r)throw sl(t)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${t}'.`):new Error(`'${t}' does not appear to be a git repository`);return new ys(e,r)}async function jr(e,t,n){let r=await yp(e,t);if(!r)return null;if(ra(r.url)){let s=ol(r.url,e.networkPolicy);if(s)throw new Error(s);let i=n?await il(e,r.url,n):void 0;return{transport:new Es(e,r.url,i,e.fetchFn),config:r}}let o=(e.resolveRemote?await e.resolveRemote(r.url):null)??await tr(e.fs,r.url);if(!o){if(sl(r.url))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${r.url}'.`);return null}return{transport:new ys(e,o),config:r}}Ae();tt();function cl(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[q.string().name("repository").describe("Repository to clone"),q.string().name("directory").describe("Target directory").optional()],options:{bare:$().describe("Create a bare clone"),branch:V.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:V.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return 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=o;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=vt(r.cwd,o),a=await tr(r.fs,c)),!a)return I(`repository '${o}' does not exist`);let f=n.directory;if(!f){let O;s||o.includes("://")?O=o.split("/").pop()??o:O=Fr(c),O.endsWith(".git")&&(O=O.slice(0,-4)),f=O}let l=vt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:o,targetPath:l,bare:n.bare,branch:i??null});if(le(d))return G(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 Ws(r.fs,l,{bare:n.bare}),m=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote}:u,h=await we(m);h['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Je(m,h);let p;try{p=await al(m,c,r.env,a??void 0)}catch(O){let N=O instanceof Error?O.message:"";return N.startsWith("network")?I(N):I(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
354
+ `));a.push(ea());let l;if(n&&n.byteLength>0){let h=vo(...a);l=new Uint8Array(h.byteLength+n.byteLength),l.set(h,0),l.set(n,h.byteLength)}else l=vo(...a);let d=e.replace(/\/+$/,""),u=await s(`${d}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...na(o),"User-Agent":"just-git/1.0"},body:l});if(!u.ok)throw new Error(`HTTP ${u.status} pushing to ${d}`);let m=new Uint8Array(await u.arrayBuffer());return i.includes("report-status")?yp(m,i.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function yp(e,t){let n,r=[];if(t){let a=jr(e),{packData:c,progress:f,errors:l}=ta(a);if(l.length>0)throw new Error(`Remote error: ${l.join("")}`);r=f,n=jr(c)}else n=jr(e);let o=!1,s,i=[];for(let a of n){if(a.type==="flush")break;let c=Ao(a);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))i.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),l=f.indexOf(" ");l!==-1?i.push({name:f.slice(0,l),ok:!1,error:f.slice(l+1)}):i.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:i,progress:r}}function sl(e,t){let n=new Set(e.map(o=>o.split("=",1)[0]??o)),r=[];for(let o of t)n.has(o)&&r.push(o);return r.push("agent=just-git/1.0"),r}var Es=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await pe(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await B(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Q(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n,r){let o=await this.advertiseRefs();if(t.length===0)return{remoteRefs:o,objectCount:0};let s,i,a;if(r?.depth!==void 0){let l=r.existingShallows??new Set,d=await Zf(this.remote,t,r.depth,l);i=d,s=new Set(d.shallow),l.size>0&&(a=l)}let c=await sa(this.remote,t,n,s,a);if(!c)return{remoteRefs:o,objectCount:0,shallowUpdates:i};let f=await Ws(this.local,c);return{remoteRefs:o,objectCount:f,shallowUpdates:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==ee&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await sa(this.local,n,r);s&&await Ws(this.remote,s)}let o=[];for(let s of t)try{let i=s.newHash===ee,a=s.oldHash??null;if(!i&&!s.ok&&s.oldHash&&!await Pn(this.remote,s.oldHash,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}let c=i?null:{type:"direct",hash:s.newHash};if(!await this.remote.refStore.compareAndSwapRef(s.name,a,c)){o.push({...s,ok:!1,error:`failed to lock ref '${s.name}'`});continue}this.remote.hooks&&(i&&s.oldHash?this.remote.hooks.onRefDelete?.({repo:this.remote,ref:s.name,oldHash:s.oldHash}):i||this.remote.hooks.onRefUpdate?.({repo:this.remote,ref:s.name,oldHash:s.oldHash,newHash:s.newHash})),o.push({...s,ok:!0})}catch(i){o.push({...s,ok:!1,error:i instanceof Error?i.message:String(i)})}return{updates:o}}},ks=class{constructor(t,n,r,o){this.local=t;this.url=n;this.auth=r;this.fetchFn=o}headTarget;cachedFetchCaps=null;cachedPushCaps=null;cachedFetchRefs=null;async advertiseRefs(){let t=await ra(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 ra(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n,r){let{caps:o,refs:s}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:s,objectCount:0};let i=await nl(this.url,t,n,o,this.auth,this.fetchFn,r);if(i.packData.byteLength===0)return{remoteRefs:s,objectCount:0};let a=await Ws(this.local,i.packData),c=i.shallowLines.length>0||i.unshallowLines.length>0?{shallow:i.shallowLines,unshallow:i.unshallowLines}:void 0;return{remoteRefs:s,objectCount:a,shallowUpdates:c}}async push(t){for(let l of t)if(l.oldHash&&l.oldHash!==ee&&l.newHash!==ee&&!l.ok&&!await Pn(this.local,l.oldHash,l.newHash))return{updates:t.map(u=>u===l?{...u,ok:!1,error:"non-fast-forward"}:{...u,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(l=>({oldHash:l.oldHash??ee,newHash:l.newHash,refName:l.name})),o=[],s=[],i=!1;for(let l of t)l.newHash!==ee&&(o.push(l.newHash),i=!0),l.oldHash&&l.oldHash!==ee&&s.push(l.oldHash);let a=null;i&&(a=await sa(this.local,o,s)??null);let c=await rl(this.url,r,a,n,this.auth,this.fetchFn);return{updates:t.map(l=>{let d=c.refResults.find(h=>h.name===l.name),u=d?.ok??c.unpackOk,m=d?.error??(!u&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...l,ok:u,error:m}})}}};async function sa(e,t,n,r,o){let s=await Dr(e,t,n,r,o);if(s.count===0)return;let i=await Mr(s),c=So(i).map(l=>({hash:l.hash,type:l.type,content:l.content,delta:l.delta,deltaBaseHash:l.deltaBase})),{data:f}=await Us(c);return f}function Ep(e){if(!Ho(e))return{url:e};try{let t=new URL(e);if(!t.username&&!t.password)return{url:e};let n={type:"basic",username:decodeURIComponent(t.username),password:decodeURIComponent(t.password)};return t.username="",t.password="",{url:t.href,embeddedAuth:n}}catch{return{url:e}}}function pr(e,t){let n=Ep(e);if(n.embeddedAuth&&t)try{t.set(new URL(n.url).origin,n.embeddedAuth)}catch{}return n}async function kp(e,t){let r=(await we(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function Ho(e){return e.startsWith("http://")||e.startsWith("https://")}function ol(e){return e.startsWith("ssh://")||e.startsWith("git@")||e.startsWith("git+ssh://")}function il(e,t){if(t===void 0)return null;if(t===!1)return"network access is disabled";if(!t.allowed)return null;if(t.allowed.length===0)return"network access is disabled";let n;try{n=new URL(e).hostname}catch{return`network policy: access to '${e}' is not allowed`}for(let r of t.allowed)if(Ho(r)){if(e===r||e.startsWith(r))return null}else if(n===r)return null;return`network policy: access to '${e}' is not allowed`}function Rp(e){let t=e.get("GIT_HTTP_BEARER_TOKEN");if(t)return{type:"bearer",token:t};let n=e.get("GIT_HTTP_USER"),r=e.get("GIT_HTTP_PASSWORD");if(n&&r)return{type:"basic",username:n,password:r}}async function al(e,t,n){if(e.credentialProvider){let o=await e.credentialProvider(t);if(o)return o}let r=Rp(n);if(r)return r;if(e.credentialCache)try{return e.credentialCache.get(new URL(t).origin)}catch{return}}async function cl(e,t,n,r){let o=pr(t,e.credentialCache).url;if(Ho(o)){let s=il(o,e.networkPolicy);if(s)throw new Error(s);let i=await al(e,o,n);return new ks(e,o,i,e.fetchFn)}if(!r&&e.resolveRemote&&(r=await e.resolveRemote(o)??void 0),!r)throw ol(o)?new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`):new Error(`'${o}' does not appear to be a git repository`);return new Es(e,r)}async function Gr(e,t,n){let r=await kp(e,t);if(!r)return null;let o=pr(r.url,e.credentialCache).url;if(Ho(o)){let i=il(o,e.networkPolicy);if(i)throw new Error(i);let a=n?await al(e,o,n):void 0;return{transport:new ks(e,o,a,e.fetchFn),config:{...r,url:o}}}let s=(e.resolveRemote?await e.resolveRemote(o):null)??await tr(e.fs,o);if(!s){if(ol(o))throw new Error(`SSH transport is not supported. Use an HTTPS URL instead of '${o}'.`);return null}return{transport:new Es(e,s),config:{...r,url:o}}}Ae();tt();function fl(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[q.string().name("repository").describe("Repository to clone"),q.string().name("directory").describe("Target directory").optional()],options:{bare:$().describe("Create a bare clone"),branch:V.string().alias("b").describe("Checkout this branch instead of HEAD"),depth:V.number().describe("Create a shallow clone with history truncated to N commits")},handler:async(n,r)=>{let o=n.repository;if(!o)return 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=pr(o,t?.credentialCache).url;else if(t?.resolveRemote&&(a=await t.resolveRemote(o)),a||(c=vt(r.cwd,o),a=await tr(r.fs,c)),!a)return I(`repository '${o}' does not exist`);let f=n.directory;if(!f){let O;s||o.includes("://")?O=c.split("/").pop()??c:O=Ur(c),O.endsWith(".git")&&(O=O.slice(0,-4)),f=O}let l=vt(r.cwd,f),d=await t?.hooks?.preClone?.({repository:c,targetPath:l,bare:n.bare,branch:i??null});if(le(d))return G(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 qs(r.fs,l,{bare:n.bare}),m=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy,resolveRemote:t.resolveRemote,credentialCache:t.credentialCache}:u,h=await we(m);h['remote "origin"']={url:c,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Je(m,h);let p;try{p=await cl(m,c,r.env,a??void 0)}catch(O){let N=O instanceof Error?O.message:"";return N.startsWith("network")?I(N):I(`repository '${o}' does not exist`)}let g=await p.advertiseRefs();if(g.length===0)return await t?.hooks?.postClone?.({repo:m,repository:c,targetPath:l,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${f}'...
355
355
  warning: You appear to have cloned an empty repository.
356
- `,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));let x=n.depth,b=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let O=await p.fetch(w,[],b);O.shallowUpdates&&await Ar(m,O.shallowUpdates)}let E=g.find(O=>O.name==="HEAD"),R=null,k=null,C=await en(m,r.env),P=`clone: from ${c}`,T=p.headTarget;T?.startsWith("refs/heads/")&&g.some(O=>O.name===T)&&(R=T.slice(11),k=g.find(O=>O.name===T)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let N=O.name.slice(11),H=`refs/remotes/origin/${N}`;await Z(m,H,O.hash),await Ze(m,H,{oldHash:ee,newHash:O.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P}),!R&&E&&O.hash===E.hash&&(R=N,k=O.hash)}O.name.startsWith("refs/tags/")&&await Z(m,O.name,O.hash)}if(i){let O=g.find(N=>N.name===`refs/heads/${i}`);if(!O)return I(`Remote branch '${i}' not found in upstream origin`);R=i,k=O.hash}if(!R){let O=g.find(N=>N.name.startsWith("refs/heads/"));O&&(R=O.name.slice(11),k=O.hash)}if(n.bare)return R&&await Xe(m,"HEAD",`refs/heads/${R}`),await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:l,bare:n.bare,branch:R}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
357
- `,exitCode:0};if(R&&await Xe(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${R}`),R&&k){await Z(m,`refs/heads/${R}`,k),await Xe(m,"HEAD",`refs/heads/${R}`);let O={oldHash:ee,newHash:k,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P};await Ze(m,`refs/heads/${R}`,O),await Ze(m,"HEAD",O);let N=await we(m);N[`branch "${R}"`]={remote:"origin",merge:`refs/heads/${R}`},await Je(m,N);let H=await j(m,k);await Wc(m,H.tree);let S=await Ke(m,H.tree),A=Gs(S.map(_=>({path:_.path,mode:parseInt(_.mode,8),hash:_.hash,stage:0,stat:Se()})));await de(m,A)}let D={stdout:"",stderr:`Cloning into '${f}'...
358
- `,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:o,targetPath:l,bare:n.bare,branch:R}),D}})}oe();ae();Ce();ge();sn();Ae();tt();ss();Cr();function ll(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[q.string().name("committish").describe("Commit to describe").optional()],options:{tags:$().describe("Use any tag, not just annotated"),always:$().describe("Show abbreviated hash as fallback"),long:$().describe("Always output long format"),abbrev:V.number().describe("Abbreviation length"),dirty:V.string().describe("Append dirty marker if worktree has changes"),match:V.string().describe("Only consider tags matching glob"),exclude:V.string().describe("Exclude tags matching glob"),exactMatch:$().alias("exact-match").describe("Only output exact matches"),firstParent:$().alias("first-parent").describe("Only follow first parent"),candidates:V.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,u=n.match,m=n.exclude,h=n.exactMatch,p=n.firstParent,g;if(i){let C=await Be(s,i);if(!C)return I(`Not a valid object name ${i}`);try{g=await ve(s,C)}catch{return I(`Not a valid object name ${i}`)}}else g=await Y(s);if(!g)return I("your current branch does not have any commits yet");let w=await kp(s,a,u,m),y=new Map,x=!1;for(let C of w){C.timestamp===0&&(x=!0);let P=y.get(C.commitHash);P||(P=[],y.set(C.commitHash,P)),P.push(C)}let b=await Rp(s,g,y,p,h?0:void 0);if(!b){if(h)return I(`no tag exactly matches '${g}'`);if(c){let P=g.slice(0,Math.max(l,1));return d&&await fl(s)&&(P+=d),{stdout:P+`
356
+ `,exitCode:0};let w=[],y=new Set;for(let O of g)O.name!=="HEAD"&&(y.has(O.hash)||(y.add(O.hash),w.push(O.hash)));let x=n.depth,b=x!==void 0&&x>0?{depth:x}:void 0;if(w.length>0){let O=await p.fetch(w,[],b);O.shallowUpdates&&await Hr(m,O.shallowUpdates)}let E=g.find(O=>O.name==="HEAD"),R=null,k=null,C=await en(m,r.env),P=`clone: from ${c}`,T=p.headTarget;T?.startsWith("refs/heads/")&&g.some(O=>O.name===T)&&(R=T.slice(11),k=g.find(O=>O.name===T)?.hash??null);for(let O of g)if(O.name!=="HEAD"){if(O.name.startsWith("refs/heads/")){let N=O.name.slice(11),H=`refs/remotes/origin/${N}`;await Z(m,H,O.hash),await Ze(m,H,{oldHash:ee,newHash:O.hash,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P}),!R&&E&&O.hash===E.hash&&(R=N,k=O.hash)}O.name.startsWith("refs/tags/")&&await Z(m,O.name,O.hash)}if(i){let O=g.find(N=>N.name===`refs/heads/${i}`);if(!O)return I(`Remote branch '${i}' not found in upstream origin`);R=i,k=O.hash}if(!R){let O=g.find(N=>N.name.startsWith("refs/heads/"));O&&(R=O.name.slice(11),k=O.hash)}if(n.bare)return R&&await Xe(m,"HEAD",`refs/heads/${R}`),await t?.hooks?.postClone?.({repo:m,repository:c,targetPath:l,bare:n.bare,branch:R}),{stdout:"",stderr:`Cloning into bare repository '${f}'...
357
+ `,exitCode:0};if(R&&await Xe(m,"refs/remotes/origin/HEAD",`refs/remotes/origin/${R}`),R&&k){await Z(m,`refs/heads/${R}`,k),await Xe(m,"HEAD",`refs/heads/${R}`);let O={oldHash:ee,newHash:k,name:C.name,email:C.email,timestamp:C.timestamp,tz:C.tz,message:P};await Ze(m,`refs/heads/${R}`,O),await Ze(m,"HEAD",O);let N=await we(m);N[`branch "${R}"`]={remote:"origin",merge:`refs/heads/${R}`},await Je(m,N);let H=await j(m,k);await qc(m,H.tree);let S=await Ke(m,H.tree),A=Ls(S.map(_=>({path:_.path,mode:parseInt(_.mode,8),hash:_.hash,stage:0,stat:Se()})));await de(m,A)}let D={stdout:"",stderr:`Cloning into '${f}'...
358
+ `,exitCode:0};return await t?.hooks?.postClone?.({repo:m,repository:c,targetPath:l,bare:n.bare,branch:R}),D}})}oe();ae();Ce();ge();sn();Ae();tt();os();Pr();function dl(e,t){e.command("describe",{description:"Give an object a human readable name based on an available ref",args:[q.string().name("committish").describe("Commit to describe").optional()],options:{tags:$().describe("Use any tag, not just annotated"),always:$().describe("Show abbreviated hash as fallback"),long:$().describe("Always output long format"),abbrev:V.number().describe("Abbreviation length"),dirty:V.string().describe("Append dirty marker if worktree has changes"),match:V.string().describe("Only consider tags matching glob"),exclude:V.string().describe("Exclude tags matching glob"),exactMatch:$().alias("exact-match").describe("Only output exact matches"),firstParent:$().alias("first-parent").describe("Only follow first parent"),candidates:V.number().describe("Consider N most recent tags")},transformArgs(n){return n.map(r=>r==="--dirty"?"--dirty=-dirty":r)},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.committish,a=n.tags,c=n.always,f=n.long,l=n.abbrev??7,d=n.dirty,u=n.match,m=n.exclude,h=n.exactMatch,p=n.firstParent,g;if(i){let C=await Be(s,i);if(!C)return I(`Not a valid object name ${i}`);try{g=await ve(s,C)}catch{return I(`Not a valid object name ${i}`)}}else g=await Y(s);if(!g)return I("your current branch does not have any commits yet");let w=await xp(s,a,u,m),y=new Map,x=!1;for(let C of w){C.timestamp===0&&(x=!0);let P=y.get(C.commitHash);P||(P=[],y.set(C.commitHash,P)),P.push(C)}let b=await Cp(s,g,y,p,h?0:void 0);if(!b){if(h)return I(`no tag exactly matches '${g}'`);if(c){let P=g.slice(0,Math.max(l,1));return d&&await ll(s)&&(P+=d),{stdout:P+`
359
359
  `,stderr:"",exitCode:0}}let C;return!a&&x?C=`fatal: No annotated tags can describe '${g}'.
360
360
  However, there were unannotated tags: try --tags.
361
361
  `:w.length===0&&!a&&(await pe(s,"refs/tags")).length>0?C=`fatal: No annotated tags can describe '${g}'.
362
362
  However, there were unannotated tags: try --tags.
363
363
  `:C=`fatal: No names found, cannot describe anything.
364
- `,{stdout:"",stderr:C,exitCode:128}}let{tag:E,depth:R}=b,k;if(R===0&&!f)k=E.name;else if(l===0)k=E.name;else{let C=g.slice(0,Math.max(l,1));k=`${E.name}-${R}-g${C}`}return d&&await fl(s)&&(k+=d),{stdout:k+`
365
- `,stderr:"",exitCode:0}}})}async function kp(e,t,n,r){let o=await pe(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&on(n,a,0)!==0||r&&on(r,a,0)===0)continue;let c=await be(e,i.hash);if(c.type==="tag"){let f=Kt(c.content),l;try{l=await ve(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function Rp(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:xp(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 xp(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function fl(e){if(Ye(e))return!1;let n=await Y(e);if(!n)return!1;let r=await j(e,n),o=await fe(e,r.tree),s=await z(e);return Un(s,o)?!0:(await gt(e,s)).length>0}oe();Ce();ae();gn();me();ze();ge();Ae();tt();function dl(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:V.string().alias("m").repeatable().describe("Commit message"),file:V.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:$().describe("Allow creating an empty commit"),amend:$().describe("Amend the previous commit"),noEdit:$().describe("Use the previous commit message without editing"),all:$().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{let o=n.message;if(o.length>0&&n.file!==void 0)return I("options '-m' and '-F' cannot be used together");let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await z(i);if(n.all){let ie=Ye(i);if(ie)return ie;let $e=await gt(i,a);for(let We of $e)We.status==="modified"?a=(await cn(i,a,We.path)).index:We.status==="deleted"&&(a=lt(a,We.path));let rt=new Set(Le(a).map(We=>We.path)),Sn=new Set(a.entries.filter(We=>We.stage>0&&!rt.has(We.path)).map(We=>We.path));for(let We of Sn){let wr=v(i.workTree,We);await r.fs.exists(wr)?a=(await cn(i,a,We)).index:a=lt(a,We)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),u=await Nt(i)?await B(i,"REBASE_HEAD"):null,m=n.amend,h=await Y(i);if(m){if(!h)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(Ht(a)){let ie=new Set,$e=[];for(let rt of a.entries)rt.stage>0&&!ie.has(rt.path)&&(ie.add(rt.path),$e.push(`U ${rt.path}`));return $e.sort(),{stdout:$e.length>0?`${$e.join(`
364
+ `,{stdout:"",stderr:C,exitCode:128}}let{tag:E,depth:R}=b,k;if(R===0&&!f)k=E.name;else if(l===0)k=E.name;else{let C=g.slice(0,Math.max(l,1));k=`${E.name}-${R}-g${C}`}return d&&await ll(s)&&(k+=d),{stdout:k+`
365
+ `,stderr:"",exitCode:0}}})}async function xp(e,t,n,r){let o=await pe(e,"refs/tags"),s=[];for(let i of o){let a=i.name.replace("refs/tags/","");if(n&&on(n,a,0)!==0||r&&on(r,a,0)===0)continue;let c=await be(e,i.hash);if(c.type==="tag"){let f=Kt(c.content),l;try{l=await ve(e,f.object)}catch{continue}s.push({name:a,commitHash:l,timestamp:f.tagger.timestamp})}else c.type==="commit"&&t&&s.push({name:a,commitHash:i.hash,timestamp:0})}return s}async function Cp(e,t,n,r,o){let s=new Set,i=[{hash:t,depth:0}];for(;i.length>0;){let{hash:a,depth:c}=i.shift();if(s.has(a)||(s.add(a),o!==void 0&&c>o))continue;let f=n.get(a);if(f&&f.length>0)return{tag:Pp(f),depth:c};let l;try{l=await j(e,a)}catch{continue}if(r)l.parents.length>0&&!s.has(l.parents[0])&&i.push({hash:l.parents[0],depth:c+1});else for(let d of l.parents)s.has(d)||i.push({hash:d,depth:c+1})}return null}function Pp(e){return e.sort((t,n)=>n.timestamp!==t.timestamp?n.timestamp-t.timestamp:t.name.localeCompare(n.name))[0]}async function ll(e){if(Ye(e))return!1;let n=await Y(e);if(!n)return!1;let r=await j(e,n),o=await fe(e,r.tree),s=await z(e);return Un(s,o)?!0:(await gt(e,s)).length>0}oe();Ce();ae();gn();me();ze();ge();Ae();tt();function ul(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:V.string().alias("m").repeatable().describe("Commit message"),file:V.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:$().describe("Allow creating an empty commit"),amend:$().describe("Amend the previous commit"),noEdit:$().describe("Use the previous commit message without editing"),all:$().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{let o=n.message;if(o.length>0&&n.file!==void 0)return I("options '-m' and '-F' cannot be used together");let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=await z(i);if(n.all){let ie=Ye(i);if(ie)return ie;let $e=await gt(i,a);for(let We of $e)We.status==="modified"?a=(await cn(i,a,We.path)).index:We.status==="deleted"&&(a=lt(a,We.path));let rt=new Set(Le(a).map(We=>We.path)),Sn=new Set(a.entries.filter(We=>We.stage>0&&!rt.has(We.path)).map(We=>We.path));for(let We of Sn){let br=v(i.workTree,We);await r.fs.exists(br)?a=(await cn(i,a,We)).index:a=lt(a,We)}}let c=await B(i,"MERGE_HEAD"),f=await B(i,"CHERRY_PICK_HEAD"),l=await B(i,"REVERT_HEAD"),u=await Nt(i)?await B(i,"REBASE_HEAD"):null,m=n.amend,h=await Y(i);if(m){if(!h)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(Ht(a)){let ie=new Set,$e=[];for(let rt of a.entries)rt.stage>0&&!ie.has(rt.path)&&(ie.add(rt.path),$e.push(`U ${rt.path}`));return $e.sort(),{stdout:$e.length>0?`${$e.join(`
366
366
  `)}
367
367
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
368
368
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
@@ -382,79 +382,79 @@ If you wish to commit it anyway, use:
382
382
  git commit --allow-empty
383
383
 
384
384
  Otherwise, please use 'git cherry-pick --skip'
385
- `,exitCode:1}:{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let k=await ln(i,r.env);if(M(k))return k;let C=await nt(i,r.env);if(M(C))return C;m&&p&&(k.name=p.author.name,k.email=p.author.email,k.timestamp=p.author.timestamp,k.timezone=p.author.timezone),f&&(k=(await j(i,f)).author);let P=Mt(g),T={repo:i,message:P},D=await t?.hooks?.commitMsg?.(T);if(le(D))return G(D.message??"");P=T.message;let O;m&&p?O=[...p.parents]:(O=h?[h]:[],c&&O.push(c));let N=rn({type:"commit",tree:y,parents:O,author:k,committer:C,message:P}),H=await He(i,"commit",N);await de(i,a);let S=await Q(i);S&&S.type==="symbolic"?await Z(i,S.target,H):await Z(i,"HEAD",H);let A=ue(P),_;m?_="commit (amend)":c?_="commit (merge)":f?_="commit (cherry-pick)":h?_="commit":_="commit (initial)";let F=`${_}: ${A}`,U=S?.type==="symbolic"?S.target:"HEAD";await ce(i,r.env,U,h,H,F,S?.type==="symbolic"),c&&await as(i),f&&await Gt(i),l&&await Lt(i),u&&await ye(i,"MERGE_MSG"),await ye(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:H,message:P,branch:S?.type==="symbolic"?Pe(S.target):null,parents:O,author:k});let L=S?.type==="symbolic"?S.target:null,K=L?Pe(L):"detached HEAD",te;if(m&&p){let ie=p.parents[0];te=ie?(await j(i,ie)).tree:null}else te=h?(await j(i,h)).tree:null;let J=k.timestamp!==C.timestamp||k.timezone!==C.timezone,ne=O.length>1,ke=await un(i,te,y,k,C,J,ne);return{stdout:`${Dt(K,H,g,O.length===0&&!m)}
386
- ${ke}`,stderr:"",exitCode:0}}})}oe();qe();me();function In(e){let t=e.split(".");return t.length===2||t.length===3}function Cp(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 pl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:$().alias("l").describe("List all config entries"),get:$().describe("Get the value for a given key"),unset:$().describe("Remove a config key"),"get-all":$().describe("Get all values for a multi-valued key"),add:$().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return hl(s);if(n.get){let f=a;return f?In(f)?sa(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n["get-all"]){let f=a;return f?In(f)?ul(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await La(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="list")return hl(s);if(a==="get"){let f=i[1];return f?In(f)?sa(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?In(f)?ul(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await ei(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(!a)return G("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!In(a))return G(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ei(s,a,c),{stdout:"",stderr:"",exitCode:0}):sa(s,a)}})}async function sa(e,t){let n=await xe(e,t);return n===void 0?G(""):{stdout:`${n}
387
- `,stderr:"",exitCode:0}}async function ul(e,t){let n=await Ga(e,t);return n.length===0?G(""):{stdout:`${n.join(`
385
+ `,exitCode:1}:{stdout:await at(i,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let k=await ln(i,r.env);if(M(k))return k;let C=await nt(i,r.env);if(M(C))return C;m&&p&&(k.name=p.author.name,k.email=p.author.email,k.timestamp=p.author.timestamp,k.timezone=p.author.timezone),f&&(k=(await j(i,f)).author);let P=Mt(g),T={repo:i,message:P},D=await t?.hooks?.commitMsg?.(T);if(le(D))return G(D.message??"");P=T.message;let O;m&&p?O=[...p.parents]:(O=h?[h]:[],c&&O.push(c));let N=rn({type:"commit",tree:y,parents:O,author:k,committer:C,message:P}),H=await He(i,"commit",N);await de(i,a);let S=await Q(i);S&&S.type==="symbolic"?await Z(i,S.target,H):await Z(i,"HEAD",H);let A=ue(P),_;m?_="commit (amend)":c?_="commit (merge)":f?_="commit (cherry-pick)":h?_="commit":_="commit (initial)";let F=`${_}: ${A}`,U=S?.type==="symbolic"?S.target:"HEAD";await ce(i,r.env,U,h,H,F,S?.type==="symbolic"),c&&await cs(i),f&&await Gt(i),l&&await Lt(i),u&&await ye(i,"MERGE_MSG"),await ye(i,"SQUASH_MSG"),await t?.hooks?.postCommit?.({repo:i,hash:H,message:P,branch:S?.type==="symbolic"?Pe(S.target):null,parents:O,author:k});let L=S?.type==="symbolic"?S.target:null,K=L?Pe(L):"detached HEAD",te;if(m&&p){let ie=p.parents[0];te=ie?(await j(i,ie)).tree:null}else te=h?(await j(i,h)).tree:null;let J=k.timestamp!==C.timestamp||k.timezone!==C.timezone,ne=O.length>1,ke=await un(i,te,y,k,C,J,ne);return{stdout:`${Dt(K,H,g,O.length===0&&!m)}
386
+ ${ke}`,stderr:"",exitCode:0}}})}oe();qe();me();function In(e){let t=e.split(".");return t.length===2||t.length===3}function $p(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,i]of Object.entries(r)){let a=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;for(let c of i)t.push(`${a}=${c}`)}}return t}function gl(e,t){e.command("config",{description:"Get and set repository options",args:[q.string().name("positionals").variadic().optional()],options:{list:$().alias("l").describe("List all config entries"),get:$().describe("Get the value for a given key"),unset:$().describe("Remove a config key"),"get-all":$().describe("Get all values for a multi-valued key"),add:$().describe("Add a new line without altering existing values")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.positionals,a=i[0];if(n.list)return pl(s);if(n.get){let f=a;return f?In(f)?oa(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n["get-all"]){let f=a;return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(n.add){let f=a,l=i[1];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await Na(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(n.unset){let f=a;return f?In(f)?hl(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="list")return pl(s);if(a==="get"){let f=i[1];return f?In(f)?oa(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="get-all"){let f=i[1];return f?In(f)?ml(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(a==="set"){let f=i[1],l=i[2];return!f||l===void 0?G("error: missing key and/or value",2):In(f)?(await ni(s,f,l),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(a==="unset"){let f=i[1];return f?In(f)?hl(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(!a)return G("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!In(a))return G(`error: invalid key: ${a}`,2);let c=i[1];return c!==void 0?(await ni(s,a,c),{stdout:"",stderr:"",exitCode:0}):oa(s,a)}})}async function oa(e,t){let n=await xe(e,t);return n===void 0?G(""):{stdout:`${n}
387
+ `,stderr:"",exitCode:0}}async function ml(e,t){let n=await La(e,t);return n.length===0?G(""):{stdout:`${n.join(`
388
388
  `)}
389
- `,stderr:"",exitCode:0}}async function ml(e,t){return await Na(e,t)?{stdout:"",stderr:"",exitCode:0}:G("",5)}async function hl(e){let t=v(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Xo(n),o=Cp(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(`
389
+ `,stderr:"",exitCode:0}}async function hl(e,t){return await _a(e,t)?{stdout:"",stderr:"",exitCode:0}:G("",5)}async function pl(e){let t=v(e.gitDir,"config"),n="";await e.fs.exists(t)&&(n=await e.fs.readFile(t));let r=Jo(n),o=$p(r),s=new Set(o.map(c=>c.split("=")[0])),i=e.configOverrides?.defaults;if(i)for(let[c,f]of Object.entries(i))s.has(c)||(o.push(`${c}=${f}`),s.add(c));let a=e.configOverrides?.locked;if(a)for(let[c,f]of Object.entries(a))s.has(c)||o.push(`${c}=${f}`);return{stdout:o.length>0?`${o.join(`
390
390
  `)}
391
- `:"",stderr:"",exitCode:0}}oe();function Ao(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(y=>y?X(y):"0000000"),c=o?X(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(y=>y===null),d=!f&&n.some(y=>y!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let y=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${y}`)}else{let y=r.map(E=>E||"000000"),x=s||"000000";y.some(E=>E!==x)&&i.push(`mode ${y.join(",")}..${x}`)}let u=n.some(y=>y!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
391
+ `:"",stderr:"",exitCode:0}}oe();function Do(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,i=[];i.push(`diff --cc ${t}`);let a=n.map(y=>y?X(y):"0000000"),c=o?X(o):"0000000";i.push(`index ${a.join(",")}..${c}`);let f=e.resultContent.length>0,l=n.every(y=>y===null),d=!f&&n.some(y=>y!==null);if(l&&s)i.push(`new file mode ${s}`);else if(d){let y=r.map(x=>x||"000000").join(",");i.push(`deleted file mode ${y}`)}else{let y=r.map(E=>E||"000000"),x=s||"000000";y.some(E=>E!==x)&&i.push(`mode ${y.join(",")}..${x}`)}let u=n.some(y=>y!==null);if(i.push(u?`--- a/${t}`:"--- /dev/null"),i.push(f?`+++ b/${t}`:"+++ /dev/null"),d||l)return`${i.join(`
392
392
  `)}
393
- `;let m=e.parentContents.map(y=>y.length>0?_t(y):[]),h=e.resultContent.length>0?_t(e.resultContent):[],p=m.map(y=>ct(y,h)),g=Pp(m,h,p),w=Op(g,m.length,h);if(w.length===0)return"";for(let y of w)i.push(y);return`${i.join(`
393
+ `;let m=e.parentContents.map(y=>y.length>0?_t(y):[]),h=e.resultContent.length>0?_t(e.resultContent):[],p=m.map(y=>ct(y,h)),g=Op(m,h,p),w=Sp(g,m.length,h);if(w.length===0)return"";for(let y of w)i.push(y);return`${i.join(`
394
394
  `)}
395
- `}function Pp(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=$p(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],l=Array(r).fill(0);for(let d=0;d<r;d++){let m=o[d]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[d];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function $p(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(m=>m.text===l.line&&m.parentLineNo===l.oldLineNo),u=s.find(m=>m.text===l.line&&m.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function Op(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),m=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let b=0;b<t;b++){let E=d.filter(R=>(R.parentLineNos[b]??0)>0||R.columns[b]==="-");if(E.length===0)u.push({start:1,count:0});else{let k=E.find(C=>(C.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;u.push({start:k,count:E.length})}}let m=d.filter(b=>b.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let b=p-2;b>=0;b--){let E=n[b];if(E&&/^[a-zA-Z$_]/.test(E)){w=` ${E.trimEnd().slice(0,79)}`;break}}let y=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${y.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of d)f.push(`${b.columns.join("")}${b.text}`)}return f}oe();Ce();ae();me();function Ho(e){let t=e.indexOf("...");if(t>=0)return{type:"three-dot",left:e.slice(0,t)||"HEAD",right:e.slice(t+3)||"HEAD"};let n=e.indexOf("..");return n>=0?{type:"two-dot",left:e.slice(0,n)||"HEAD",right:e.slice(n+2)||"HEAD"}:null}nr();ge();Ae();tt();var oa=new TextDecoder;function yl(e){return"exitCode"in e}function pr(e){return e.toString(8).padStart(6,"0")}function El(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 kl(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",transformArgs:n=>n.map(r=>{let o=/^-U(\d+)$/.exec(r);return o?`--unified=${o[1]}`:r}),args:[q.string().name("commits").variadic().optional()],options:{cached:$().describe("Show staged changes (index vs HEAD)"),staged:$().describe("Synonym for --cached"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),unified:V.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:$().alias("M").describe("Detect renames (enabled by default)"),findCopies:$().alias("C").describe("Detect copies (accepted for compatibility)"),color:$().describe("Show colored diff (accepted for compatibility)"),noColor:$().describe("Turn off colored diff (accepted for compatibility)")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=ut(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(g=>Ue(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,m=c.length===1?Ho(c[0]):null;if(m){if(a)return I("too many arguments");m.type==="three-dot"?u=await vp(i,m.left,m.right,l):u=await bl(i,m.left,m.right,l)}else if(c.length===2)u=await bl(i,c[0],c[1],l);else{if(c.length>2)return I("too many arguments");a?u=await Tp(i,c.length===1?c[0]:null,l):c.length===1?u=await Ap(i,c[0],l):u=await Ip(i,l)}if(yl(u))return u;let h=n.unified,p=await Hp(i,u.items,d,h);return u.stderr&&(p.stderr=u.stderr),p}})}async function Ip(e,t){let n=Ye(e);if(n)return n;let r=await z(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await gt(e,r);c.sort((l,d)=>Ie(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let u=pr(d.mode),m;if(l.status==="modified"&&e.workTree){let h=v(e.workTree,l.path),p=await e.fs.readFileBuffer(h);m=await pt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),u=a.get(l);await Sp(f,e,l,d,u)}return f.sort((l,d)=>{let u=Ie(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 Sp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=pr(r.mode),a=pr(o.mode),{exists:c,hash:f}=await gl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),wl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=pr(r.mode),{exists:a,hash:c}=await gl(t.fs,s,n);wl(e,n,r.hash,i,a,c)}}async function gl(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await ns(e,r);return{exists:!0,hash:await pt("blob",o)}}function wl(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 Tp(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 Y(e);u&&(r=(await j(e,u)).tree)}let o=await fe(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(Le(s).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(i.has(u))continue;let h=o.get(u);h?h.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:pr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:pr(m.mode)})}for(let[u,m]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await it(e,c),d=El(f,l);for(let u of i)d.push({path:u,status:"U"});return d.sort((u,m)=>Ie(u.path,m.path)),n?{items:d.filter(u=>Ee(n,u.path))}:{items:d}}async function bl(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 Rl(e,i,r)}async function vp(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 Ft(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]}
396
- `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await Rl(e,l,r);return yl(d)||a&&(d.stderr=a),d}async function Rl(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=El(r,o);return s.sort((i,a)=>Ie(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Ap(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 fe(e,o.commit.tree),a=await z(e),c=new Map(Le(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let m=await e.fs.readFileBuffer(u),h=await pt("blob",m);h!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:h,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u))continue;let m=await e.fs.readFileBuffer(u),h=await pt("blob",m);f.push({path:l,status:"A",newHash:h,newMode:pr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Ie(l.path,d.path)),{items:f}}async function Hp(e,t,n,r){let o;switch(n){case"stat":o=await Np(e,t);break;case"shortstat":o=await _p(e,t);break;case"numstat":o=await Lp(e,t);break;case"name-only":o=jp(t);break;case"name-status":o=Gp(t);break;default:o=await Dp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function Dp(e,t,n){let r="",o=new Set,s=await Mp(e,t);for(let i of t)if(i.status==="U")if(i.combinedParentHashes){let a=await Promise.all(i.combinedParentHashes.map(async l=>l?await se(e,l):"")),c=await ia(e,i);if(a.some(l=>Te(l))||Te(c)){let l=i.combinedParentHashes.map(d=>d?X(d):"0000000");r+=`diff --cc ${i.path}
395
+ `}function Op(e,t,n){let r=e.length,o=n.map(i=>{let a=[],c=new Map,f=0;for(let l of i)if(l.type==="keep")a[l.newLineNo-1]="keep",f=l.newLineNo;else if(l.type==="insert")a[l.newLineNo-1]="insert",f=l.newLineNo;else if(l.type==="delete"){let d=c.get(f)??[];d.push({text:l.line,parentLineNo:l.oldLineNo}),c.set(f,d)}return{resultStatus:a,deletions:c}}),s=[];for(let i=0;i<=t.length;i++){let a=[];for(let f=0;f<r;f++){let l=o[f];a.push(l?.deletions.get(i)??[])}let c=Ip(a,r);for(let f of c)s.push(f);if(i<t.length){let f=[],l=Array(r).fill(0);for(let d=0;d<r;d++){let m=o[d]?.resultStatus[i];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[d];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===i+1){l[d]=p.oldLineNo;break}}}}s.push({columns:f,text:t[i]??"",resultLineNo:i+1,parentLineNos:l})}}return s}function Ip(e,t){if(!e.some(o=>o.length>0))return[];if(t===2){let o=e[0]??[],s=e[1]??[];if(o.length===0)return s.map(l=>({columns:[" ","-"],text:l.text,resultLineNo:0,parentLineNos:[0,l.parentLineNo]}));if(s.length===0)return o.map(l=>({columns:["-"," "],text:l.text,resultLineNo:0,parentLineNos:[l.parentLineNo,0]}));let i=o.map(l=>l.text),a=s.map(l=>l.text),c=ct(i,a),f=[];for(let l of c)if(l.type==="keep"){let d=o.find(m=>m.text===l.line&&m.parentLineNo===l.oldLineNo),u=s.find(m=>m.text===l.line&&m.parentLineNo===l.newLineNo);f.push({columns:["-","-"],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,u?.parentLineNo??0]})}else if(l.type==="delete"){let d=o.find(u=>u.parentLineNo===l.oldLineNo);f.push({columns:["-"," "],text:l.line,resultLineNo:0,parentLineNos:[d?.parentLineNo??0,0]})}else if(l.type==="insert"){let d=s.find(u=>u.parentLineNo===l.newLineNo);f.push({columns:[" ","-"],text:l.line,resultLineNo:0,parentLineNos:[0,d?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let i of s){let a=Array(t).fill(" ");a[o]="-";let c=Array(t).fill(0);c[o]=i.parentLineNo,r.push({columns:a,text:i.text,resultLineNo:0,parentLineNos:c})}}return r}function Sp(e,t,n){let o=[];for(let l=0;l<e.length;l++)e[l]?.columns.some(u=>u!==" ")&&o.push(l);if(o.length===0)return[];let s=[],i=o[0]??0,a=Math.max(0,i-3),c=Math.min(e.length-1,i+3);for(let l=1;l<o.length;l++){let d=o[l]??0,u=Math.max(0,d-3),m=Math.min(e.length-1,d+3);u<=c+1||(s.push({start:a,end:c}),a=u),c=m}s.push({start:a,end:c});let f=[];for(let l of s){let d=e.slice(l.start,l.end+1),u=[];for(let b=0;b<t;b++){let E=d.filter(R=>(R.parentLineNos[b]??0)>0||R.columns[b]==="-");if(E.length===0)u.push({start:1,count:0});else{let k=E.find(C=>(C.parentLineNos[b]??0)>0)?.parentLineNos[b]??1;u.push({start:k,count:E.length})}}let m=d.filter(b=>b.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let b=p-2;b>=0;b--){let E=n[b];if(E&&/^[a-zA-Z$_]/.test(E)){w=` ${E.trimEnd().slice(0,79)}`;break}}let y=u.map(b=>`-${b.start},${b.count}`),x=`${"@".repeat(t+1)} ${y.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(x);for(let b of d)f.push(`${b.columns.join("")}${b.text}`)}return f}oe();Ce();ae();me();function Mo(e){let t=e.indexOf("...");if(t>=0)return{type:"three-dot",left:e.slice(0,t)||"HEAD",right:e.slice(t+3)||"HEAD"};let n=e.indexOf("..");return n>=0?{type:"two-dot",left:e.slice(0,n)||"HEAD",right:e.slice(n+2)||"HEAD"}:null}nr();ge();Ae();tt();var ia=new TextDecoder;function El(e){return"exitCode"in e}function gr(e){return e.toString(8).padStart(6,"0")}function kl(e,t){let n=[];for(let r of e)n.push({path:r.path,status:r.status==="added"?"A":r.status==="deleted"?"D":"M",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode});for(let r of t)n.push({path:r.newPath,status:"R",oldHash:r.oldHash,newHash:r.newHash,oldMode:r.oldMode,newMode:r.newMode,oldPath:r.oldPath,similarity:r.similarity});return n}function Rl(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",transformArgs:n=>n.map(r=>{let o=/^-U(\d+)$/.exec(r);return o?`--unified=${o[1]}`:r}),args:[q.string().name("commits").variadic().optional()],options:{cached:$().describe("Show staged changes (index vs HEAD)"),staged:$().describe("Synonym for --cached"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),unified:V.number().alias("U").describe("Generate diffs with <n> lines of context"),findRenames:$().alias("M").describe("Detect renames (enabled by default)"),findCopies:$().alias("C").describe("Detect copies (accepted for compatibility)"),color:$().describe("Show colored diff (accepted for compatibility)"),noColor:$().describe("Turn off colored diff (accepted for compatibility)")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.cached||n.staged,c=n.commits,f=ut(i,r.cwd),l=o.passthrough.length>0?o.passthrough.map(g=>Ue(g,f)):null,d=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",u,m=c.length===1?Mo(c[0]):null;if(m){if(a)return I("too many arguments");m.type==="three-dot"?u=await Hp(i,m.left,m.right,l):u=await yl(i,m.left,m.right,l)}else if(c.length===2)u=await yl(i,c[0],c[1],l);else{if(c.length>2)return I("too many arguments");a?u=await Ap(i,c.length===1?c[0]:null,l):c.length===1?u=await Dp(i,c[0],l):u=await Tp(i,l)}if(El(u))return u;let h=n.unified,p=await Mp(i,u.items,d,h);return u.stderr&&(p.stderr=u.stderr),p}})}async function Tp(e,t){let n=Ye(e);if(n)return n;let r=await z(e),o=new Set,s=new Map,i=new Map,a=new Map;for(let l of r.entries)l.stage===0?s.set(l.path,l):(o.add(l.path),l.stage===2?i.set(l.path,l):l.stage===3&&a.set(l.path,l));let c=await gt(e,r);c.sort((l,d)=>Ie(l.path,d.path));let f=[];for(let l of c){if(l.status==="untracked"||t&&!Ee(t,l.path)||o.has(l.path))continue;let d=s.get(l.path);if(!d)continue;let u=gr(d.mode),m;if(l.status==="modified"&&e.workTree){let h=v(e.workTree,l.path),p=await e.fs.readFileBuffer(h);m=await pt("blob",p)}f.push({path:l.path,status:l.status==="deleted"?"D":"M",oldHash:d.hash,newHash:m,oldMode:u,newMode:u,newFromWorkTree:l.status==="modified"})}for(let l of o){if(t&&!Ee(t,l))continue;let d=i.get(l),u=a.get(l);await vp(f,e,l,d,u)}return f.sort((l,d)=>{let u=Ie(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 vp(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let i=gr(r.mode),a=gr(o.mode),{exists:c,hash:f}=await wl(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:i,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[i,a]}),bl(e,n,r.hash,i,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let i=gr(r.mode),{exists:a,hash:c}=await wl(t.fs,s,n);bl(e,n,r.hash,i,a,c)}}async function wl(e,t,n){let r=v(t,n);if(!await e.exists(r))return{exists:!1};let o=await rs(e,r);return{exists:!0,hash:await pt("blob",o)}}function bl(e,t,n,r,o,s){o&&s&&s!==n?e.push({path:t,status:"M",oldHash:n,newHash:s,oldMode:r,newMode:r,newFromWorkTree:!0}):o||e.push({path:t,status:"D",oldHash:n,oldMode:r})}async function Ap(e,t,n){let r=null;if(t){let u=await Me(e,t);if(M(u))return u;r=u.commit.tree}else{let u=await Y(e);u&&(r=(await j(e,u)).tree)}let o=await fe(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(Le(s).map(u=>[u.path,u])),c=[];for(let[u,m]of a){if(i.has(u))continue;let h=o.get(u);h?h.hash!==m.hash&&c.push({path:u,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:gr(m.mode)}):c.push({path:u,status:"added",newHash:m.hash,newMode:gr(m.mode)})}for(let[u,m]of o)i.has(u)||a.has(u)||c.push({path:u,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:l}=await it(e,c),d=kl(f,l);for(let u of i)d.push({path:u,status:"U"});return d.sort((u,m)=>Ie(u.path,m.path)),n?{items:d.filter(u=>Ee(n,u.path))}:{items:d}}async function yl(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 xl(e,i,r)}async function Hp(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 Ft(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]}
396
+ `);let c=i[0],f=await j(e,c),l=await Ve(e,f.tree,s.commit.tree),d=await xl(e,l,r);return El(d)||a&&(d.stderr=a),d}async function xl(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=kl(r,o);return s.sort((i,a)=>Ie(i.path,a.path)),n?{items:s.filter(i=>Ee(n,i.path))}:{items:s}}async function Dp(e,t,n){let r=Ye(e);if(r)return r;let o=await Me(e,t);if(M(o))return o;let s=e.workTree,i=await fe(e,o.commit.tree),a=await z(e),c=new Map(Le(a).map(l=>[l.path,l])),f=[];for(let[l,d]of i){if(n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u)){f.push({path:l,status:"D",oldHash:d.hash,oldMode:d.mode});continue}let m=await e.fs.readFileBuffer(u),h=await pt("blob",m);h!==d.hash&&f.push({path:l,status:"M",oldHash:d.hash,newHash:h,oldMode:d.mode,newMode:d.mode,newFromWorkTree:!0})}for(let[l,d]of c){if(i.has(l)||n&&!Ee(n,l))continue;let u=v(s,l);if(!await e.fs.exists(u))continue;let m=await e.fs.readFileBuffer(u),h=await pt("blob",m);f.push({path:l,status:"A",newHash:h,newMode:gr(d.mode),newFromWorkTree:!0})}return f.sort((l,d)=>Ie(l.path,d.path)),{items:f}}async function Mp(e,t,n,r){let o;switch(n){case"stat":o=await Fp(e,t);break;case"shortstat":o=await Up(e,t);break;case"numstat":o=await _p(e,t);break;case"name-only":o=Lp(t);break;case"name-status":o=Np(t);break;default:o=await jp(e,t,r);break}return{stdout:o,stderr:"",exitCode:0}}async function jp(e,t,n){let r="",o=new Set,s=await Gp(e,t);for(let i of t)if(i.status==="U")if(i.combinedParentHashes){let a=await Promise.all(i.combinedParentHashes.map(async l=>l?await se(e,l):"")),c=await aa(e,i);if(a.some(l=>Te(l))||Te(c)){let l=i.combinedParentHashes.map(d=>d?X(d):"0000000");r+=`diff --cc ${i.path}
397
397
  index ${l.join(",")}..0000000
398
398
  Binary files differ
399
- `,o.add(i.path)}else{let l=Ao({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}
399
+ `,o.add(i.path)}else{let l=Do({path:i.path,parentHashes:i.combinedParentHashes,parentModes:i.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:i.newMode??null,resultContent:c});l?(r+=l,o.add(i.path)):r+=`* Unmerged path ${i.path}
400
400
  `}}else r+=`* Unmerged path ${i.path}
401
- `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await se(e,i.oldHash):"",c=await ia(e,i);i.status==="R"&&i.oldPath?r+=It({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Do(i.oldHash,s),newHash:Do(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=It({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:Do(i.oldHash,s),newHash:Do(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Mp(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 m of d)if(m.startsWith(l)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function Do(e,t){if(e)return e.length!==40?e:t.get(e)??X(e)}function jp(e){let t="";for(let n of e)t+=`${n.path}
402
- `;return t}function Gp(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}
401
+ `;for(let i of t){if(i.status==="U"||o.has(i.path))continue;let a=i.oldHash?await se(e,i.oldHash):"",c=await aa(e,i);i.status==="R"&&i.oldPath?r+=It({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:jo(i.oldHash,s),newHash:jo(i.newHash,s),renameTo:i.path,similarity:i.similarity,contextLines:n}):r+=It({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:jo(i.oldHash,s),newHash:jo(i.newHash,s),isNew:i.status==="A",isDeleted:i.status==="D",contextLines:n})}return r}async function Gp(e,t){let n=new Set;for(let a of t)a.oldHash&&a.oldHash.length===40&&n.add(a.oldHash),a.newHash&&a.newHash.length===40&&n.add(a.newHash);let r=new Map,o=async a=>{let c=r.get(a);if(c)return c;let f=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 m of d)if(m.startsWith(l)&&(u++,u>1))return!1;return u===1},i=new Map;for(let a of n){let c=7;for(;c<40&&!await s(a,c);)c++;i.set(a,a.slice(0,c))}return i}function jo(e,t){if(e)return e.length!==40?e:t.get(e)??X(e)}function Lp(e){let t="";for(let n of e)t+=`${n.path}
402
+ `;return t}function Np(e){let t="";for(let n of e)if(n.status==="R"){let r=String(n.similarity??100).padStart(3,"0");t+=`R${r} ${n.oldPath} ${n.path}
403
403
  `}else t+=`${n.status} ${n.path}
404
- `;return t}async function Lp(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
405
- `;continue}let o=r.oldHash?await se(e,r.oldHash):"",s=await ia(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=xl(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=dn(r.oldPath,r.path);n+=`${a} ${c} ${f}
404
+ `;return t}async function _p(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
405
+ `;continue}let o=r.oldHash?await se(e,r.oldHash):"",s=await aa(e,r),i=Te(o)||Te(s),a,c;if(i)a="-",c="-";else{let{ins:f,del:l}=Cl(o,s);a=String(f),c=String(l)}if(r.status==="R"&&r.oldPath){let f=dn(r.oldPath,r.path);n+=`${a} ${c} ${f}
406
406
  `}else n+=`${a} ${c} ${r.path}
407
- `}return n}async function Np(e,t){let n=await Cl(e,t);return ur(n)}async function _p(e,t){let n=await Cl(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=Xn(s,r,o);return i?`${i}
407
+ `}return n}async function Fp(e,t){let n=await Pl(e,t);return ur(n)}async function Up(e,t){let n=await Pl(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let a of n)a.isUnmerged||(s++,r+=a.insertions,o+=a.deletions);let i=Xn(s,r,o);return i?`${i}
408
408
  `:n.some(a=>a.isUnmerged)?` 0 files changed
409
- `:""}async function ia(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await ns(e.fs,n);return oa.decode(r)}return se(e,t.newHash)}async function Fp(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return ns(e.fs,n)}return Pt(e,t.newHash)}function xl(e,t){let n=Rt(e),r=Rt(t),o=ct(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function Cl(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?dn(r.oldPath,r.path):r.path,s=r.oldHash?await Pt(e,r.oldHash):new Uint8Array(0),i=await Fp(e,r);if(Dn(s)||Dn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=oa.decode(s),c=oa.decode(i),{ins:f,del:l}=xl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}oe();qe();Tn();me();ze();ge();function gr(e){let t=e,n=!1;t.startsWith("+")&&(n=!0,t=t.slice(1));let r=t.indexOf(":");return r===-1?{force:n,src:t,dst:t}:{force:n,src:t.slice(0,r),dst:t.slice(r+1)}}function Up(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 ks(e,t){if(!Up(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function $l(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[q.string().name("remote").describe("Remote to fetch from").optional(),q.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:$().describe("Fetch from all remotes"),prune:$().alias("p").describe("Remove stale remote-tracking refs"),tags:$().describe("Also fetch tags"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Po(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=gs),n.all){if(n.remote)return I("fetch --all does not take a remote argument");let c=await we(s),f=[];for(let u of Object.keys(c)){let m=u.match(/^remote "(.+)"$/);m?.[1]&&f.push(m[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let u of f){let m=await Pl(s,u,void 0,n.prune,n.tags,r.env,t,i);m.stderr&&l.push(m.stderr),m.exitCode!==0&&(d=m.exitCode)}return{stdout:"",stderr:l.join(""),exitCode:d}}let a=n.remote||"origin";return Pl(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function Pl(e,t,n,r,o,s,i,a){let c;try{c=await jr(e,t,s)}catch(H){let S=H instanceof Error?H.message:"";if(S.startsWith("network"))return I(S);throw H}if(!c)return I(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,u=gr(l.fetchRefspec);n&&n.length>0?d=n.map(H=>{let S=gr(H);if(H.includes(":"))return S;for(let A of[S.src,`refs/heads/${S.src}`,`refs/tags/${S.src}`]){let _=ks(u,A);if(_!==null)return{force:S.force||u.force,src:A,dst:_}}return S}):d=[u];let m=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(H=>`${H.src}:${H.dst}`),prune:r,tags:o});if(le(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await f.advertiseRefs();if(h.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await pe(e)).map(H=>H.hash),w=await B(e,"HEAD");w&&g.push(w);let y=[],x=new Set,b=[];for(let H of h)if(H.name!=="HEAD")for(let S of d){let A=ks(S,H.name);if(A!==null){b.push({remote:H,localRef:A,force:S.force}),x.has(H.hash)||(x.add(H.hash),y.push(H.hash));break}}if(o)for(let H of h)H.name.startsWith("refs/tags/")&&(b.push({remote:H,localRef:H.name,force:!1}),x.has(H.hash)||(x.add(H.hash),y.push(H.hash)));let E=new Set(g),R=y.filter(H=>!E.has(H)),k,C=a!==void 0?await vr(e):void 0;a!==void 0&&(k={depth:a,existingShallows:C});let P=R.length>0?R:k?y:[];if(P.length>0){let H=await f.fetch(P,g,k);H.shallowUpdates&&await Ar(e,H.shallowUpdates,C)}let T=await en(e,s),D=[];D.push(`From ${l.url}
410
- `);for(let H of b){let S=await B(e,H.localRef);await Z(e,H.localRef,H.remote.hash),await Ze(e,H.localRef,{oldHash:S??ee,newHash:H.remote.hash,name:T.name,email:T.email,timestamp:T.timestamp,tz:T.tz,message:S?"fetch":"fetch: storing head"});let A=Mo(H.remote.name),_=Mo(H.localRef);if(S){if(S!==H.remote.hash){let F=X(S),U=X(H.remote.hash);D.push(` ${F}..${U} ${A} -> ${_}
409
+ `:""}async function aa(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path),r=await rs(e.fs,n);return ia.decode(r)}return se(e,t.newHash)}async function Bp(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=v(e.workTree,t.path);return rs(e.fs,n)}return Pt(e,t.newHash)}function Cl(e,t){let n=Rt(e),r=Rt(t),o=ct(n,r),s=0,i=0;for(let a of o)a.type==="insert"?s++:a.type==="delete"&&i++;return{ins:s,del:i}}async function Pl(e,t){let n=[];for(let r of t){if(r.status==="U"){n.push({path:r.path,sortKey:r.path,insertions:0,deletions:0,isUnmerged:!0});continue}let o=r.status==="R"&&r.oldPath?dn(r.oldPath,r.path):r.path,s=r.oldHash?await Pt(e,r.oldHash):new Uint8Array(0),i=await Bp(e,r);if(Dn(s)||Dn(i))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:i.byteLength});else{let a=ia.decode(s),c=ia.decode(i),{ins:f,del:l}=Cl(a,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:l})}}return n}oe();qe();Tn();me();ze();ge();function wr(e){let t=e,n=!1;t.startsWith("+")&&(n=!0,t=t.slice(1));let r=t.indexOf(":");return r===-1?{force:n,src:t,dst:t}:{force:n,src:t.slice(0,r),dst:t.slice(r+1)}}function Wp(e,t){let n=e.indexOf("*");if(n===-1)return e===t;let r=e.slice(0,n),o=e.slice(n+1);return t.startsWith(r)&&t.endsWith(o)&&t.length>=r.length+o.length}function Rs(e,t){if(!Wp(e.src,t))return null;let n=e.src.indexOf("*"),r=e.dst.indexOf("*");if(n===-1)return e.dst;let o=e.src.slice(0,n),s=e.src.slice(n+1),i=s.length>0?t.length-s.length:t.length,a=t.slice(o.length,i);return r===-1?e.dst:e.dst.slice(0,r)+a+e.dst.slice(r+1)}function Ol(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[q.string().name("remote").describe("Remote to fetch from").optional(),q.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:$().describe("Fetch from all remotes"),prune:$().alias("p").describe("Remove stale remote-tracking refs"),tags:$().describe("Also fetch tags"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await $o(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;if(n.unshallow&&(i=ws),n.all){if(n.remote)return I("fetch --all does not take a remote argument");let c=await we(s),f=[];for(let u of Object.keys(c)){let m=u.match(/^remote "(.+)"$/);m?.[1]&&f.push(m[1])}if(f.length===0)return{stdout:"",stderr:"",exitCode:0};let l=[],d=0;for(let u of f){let m=await $l(s,u,void 0,n.prune,n.tags,r.env,t,i);m.stderr&&l.push(m.stderr),m.exitCode!==0&&(d=m.exitCode)}return{stdout:"",stderr:l.join(""),exitCode:d}}let a=n.remote||"origin";return $l(s,a,n.refspec,n.prune,n.tags,r.env,t,i)}})}async function $l(e,t,n,r,o,s,i,a){let c;try{c=await Gr(e,t,s)}catch(H){let S=H instanceof Error?H.message:"";if(S.startsWith("network"))return I(S);throw H}if(!c)return I(`'${t}' does not appear to be a git repository`);let{transport:f,config:l}=c,d,u=wr(l.fetchRefspec);n&&n.length>0?d=n.map(H=>{let S=wr(H);if(H.includes(":"))return S;for(let A of[S.src,`refs/heads/${S.src}`,`refs/tags/${S.src}`]){let _=Rs(u,A);if(_!==null)return{force:S.force||u.force,src:A,dst:_}}return S}):d=[u];let m=await i?.hooks?.preFetch?.({repo:e,remote:t,url:l.url,refspecs:d.map(H=>`${H.src}:${H.dst}`),prune:r,tags:o});if(le(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await f.advertiseRefs();if(h.length===0)return{stdout:"",stderr:"",exitCode:0};let g=(await pe(e)).map(H=>H.hash),w=await B(e,"HEAD");w&&g.push(w);let y=[],x=new Set,b=[];for(let H of h)if(H.name!=="HEAD")for(let S of d){let A=Rs(S,H.name);if(A!==null){b.push({remote:H,localRef:A,force:S.force}),x.has(H.hash)||(x.add(H.hash),y.push(H.hash));break}}if(o)for(let H of h)H.name.startsWith("refs/tags/")&&(b.push({remote:H,localRef:H.name,force:!1}),x.has(H.hash)||(x.add(H.hash),y.push(H.hash)));let E=new Set(g),R=y.filter(H=>!E.has(H)),k,C=a!==void 0?await Ar(e):void 0;a!==void 0&&(k={depth:a,existingShallows:C});let P=R.length>0?R:k?y:[];if(P.length>0){let H=await f.fetch(P,g,k);H.shallowUpdates&&await Hr(e,H.shallowUpdates,C)}let T=await en(e,s),D=[];D.push(`From ${l.url}
410
+ `);for(let H of b){let S=await B(e,H.localRef);await Z(e,H.localRef,H.remote.hash),await Ze(e,H.localRef,{oldHash:S??ee,newHash:H.remote.hash,name:T.name,email:T.email,timestamp:T.timestamp,tz:T.tz,message:S?"fetch":"fetch: storing head"});let A=Go(H.remote.name),_=Go(H.localRef);if(S){if(S!==H.remote.hash){let F=X(S),U=X(H.remote.hash);D.push(` ${F}..${U} ${A} -> ${_}
411
411
  `)}}else{let U=H.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";D.push(`${U} ${A} -> ${_}
412
- `)}}if(!o)for(let H of h){if(!H.name.startsWith("refs/tags/")||x.has(H.hash))continue;let S=await B(e,H.name),A=H.peeledHash??H.hash;!S&&E.has(A)&&(await Z(e,H.name,H.hash),await Ze(e,H.name,{oldHash:ee,newHash:H.hash,name:T.name,email:T.email,timestamp:T.timestamp,tz:T.tz,message:"fetch: storing head"}),D.push(` * [new tag] ${Mo(H.name)} -> ${Mo(H.name)}
412
+ `)}}if(!o)for(let H of h){if(!H.name.startsWith("refs/tags/")||x.has(H.hash))continue;let S=await B(e,H.name),A=H.peeledHash??H.hash;!S&&E.has(A)&&(await Z(e,H.name,H.hash),await Ze(e,H.name,{oldHash:ee,newHash:H.hash,name:T.name,email:T.email,timestamp:T.timestamp,tz:T.tz,message:"fetch: storing head"}),D.push(` * [new tag] ${Go(H.name)} -> ${Go(H.name)}
413
413
  `))}if(r){let H=`refs/remotes/${t}`,S=await pe(e,H),A=new Set(h.filter(_=>_.name.startsWith("refs/heads/")).map(_=>_.name.slice(11)));for(let _ of S){let F=_.name.slice(H.length+1);A.has(F)||(await he(e,_.name),D.push(` - [deleted] (none) -> ${t}/${F}
414
414
  `))}}let O=h.find(H=>H.name==="HEAD");if(O){let H=v(e.gitDir,"FETCH_HEAD"),S=h.find(_=>_.name.startsWith("refs/heads/")&&_.hash===O.hash),A=S?`branch '${S.name.slice(11)}' of`:"of";await e.fs.writeFile(H,`${O.hash} ${A} ${l.url}
415
- `)}let N={stdout:"",stderr:D.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:b.length}),N}function Mo(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}oe();Ce();ae();me();ze();ge();oe();Ce();ae();me();ze();ge();async function Ol(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await pe(e,"refs");for(let a of r)t.add(a.hash);let o=v(e.gitDir,"logs");await e.fs.exists(o)&&await Il(e,o,o,t);let s=await z(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await B(e,a);c&&t.add(c)}let i=[];for(let a of t)await Vt(e,a)&&i.push(a);return i}async function Il(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 Il(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await et(e,c);for(let l of f)l.newHash!==ee&&r.add(l.newHash)}}}Us();Rr();me();async function Bp(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 zt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Dr(await Hr(e,t,[])):(await Dr(await Hr(e,t,[]))).filter(s=>!n.has(s.hash))}async function aa(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,i=e.depth??50;if(r.length===0)return null;let a=e.all?await Dr(await Hr(t,r,[])):await Bp(t,r);if(a.length===0)return null;let c=a.length,f=Io(a,{window:s,depth:i}),l=f.filter(R=>R.delta).length,d=f.map(R=>({hash:R.hash,type:R.type,content:R.content,delta:R.delta,deltaBaseHash:R.deltaBase})),{data:u,entries:m}=await Fs(d),h=await kc(u,m),p=u.subarray(u.byteLength-20),g="";for(let R=0;R<20;R++){let k=p[R];g+=(k>>4).toString(16)+(k&15).toString(16)}let w=v(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let y=`pack-${g}`,x=v(w,`${y}.pack`),b=v(w,`${y}.idx`);await n.writeFile(x,u),await n.writeFile(b,h);let E=new Set(f.map(R=>R.hash));if(t.objectStore.invalidatePacks?.(),o){let R=await n.readdir(w);for(let P of R){if(!P.endsWith(".idx"))continue;let T=P.slice(0,-4);if(T===y)continue;let D=v(w,`${T}.idx`),O=!0;try{let N=await n.readFileBuffer(D),H=new zt(N);for(let S of H.allHashes())if(!E.has(S)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(v(w,`${T}.pack`))}catch{}try{await n.rm(D)}catch{}}}let k=v(t.gitDir,"objects"),C;try{C=await n.readdir(k)}catch{C=[]}for(let P of C){if(P==="pack"||P==="info"||P.length!==2)continue;let T=v(k,P),D;try{D=await n.readdir(T)}catch{continue}for(let O of D){let N=`${P}${O}`;E.has(N)&&await n.rm(v(T,O))}try{(await n.readdir(T)).length===0&&await n.rm(T,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function ca(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
416
- `)}function Sl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:$().alias("a").describe("Pack all objects, including already-packed"),delete:$().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Ol(s),a=await aa({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${ca(a.totalCount,a.deltaCount)}
415
+ `)}let N={stdout:"",stderr:D.join(""),exitCode:0};return await i?.hooks?.postFetch?.({repo:e,remote:t,url:l.url,updatedRefCount:b.length}),N}function Go(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}oe();Ce();ae();me();ze();ge();oe();Ce();ae();me();ze();ge();async function Il(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await pe(e,"refs");for(let a of r)t.add(a.hash);let o=v(e.gitDir,"logs");await e.fs.exists(o)&&await Sl(e,o,o,t);let s=await z(e);for(let a of s.entries)t.add(a.hash);for(let a of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await B(e,a);c&&t.add(c)}let i=[];for(let a of t)await Vt(e,a)&&i.push(a);return i}async function Sl(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let i=v(t,s),a=await e.fs.stat(i);if(a.isDirectory)await Sl(e,i,n,r);else if(a.isFile){let c=i.slice(n.length+1),f=await et(e,c);for(let l of f)l.newHash!==ee&&r.add(l.newHash)}}}Bs();xr();me();async function qp(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 zt(a);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?Mr(await Dr(e,t,[])):(await Mr(await Dr(e,t,[]))).filter(s=>!n.has(s.hash))}async function ca(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 Mr(await Dr(t,r,[])):await qp(t,r);if(a.length===0)return null;let c=a.length,f=So(a,{window:s,depth:i}),l=f.filter(R=>R.delta).length,d=f.map(R=>({hash:R.hash,type:R.type,content:R.content,delta:R.delta,deltaBaseHash:R.deltaBase})),{data:u,entries:m}=await Us(d),h=await Rc(u,m),p=u.subarray(u.byteLength-20),g="";for(let R=0;R<20;R++){let k=p[R];g+=(k>>4).toString(16)+(k&15).toString(16)}let w=v(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let y=`pack-${g}`,x=v(w,`${y}.pack`),b=v(w,`${y}.idx`);await n.writeFile(x,u),await n.writeFile(b,h);let E=new Set(f.map(R=>R.hash));if(t.objectStore.invalidatePacks?.(),o){let R=await n.readdir(w);for(let P of R){if(!P.endsWith(".idx"))continue;let T=P.slice(0,-4);if(T===y)continue;let D=v(w,`${T}.idx`),O=!0;try{let N=await n.readFileBuffer(D),H=new zt(N);for(let S of H.allHashes())if(!E.has(S)){O=!1;break}}catch{O=!1}if(O){try{await n.rm(v(w,`${T}.pack`))}catch{}try{await n.rm(D)}catch{}}}let k=v(t.gitDir,"objects"),C;try{C=await n.readdir(k)}catch{C=[]}for(let P of C){if(P==="pack"||P==="info"||P.length!==2)continue;let T=v(k,P),D;try{D=await n.readdir(T)}catch{continue}for(let O of D){let N=`${P}${O}`;E.has(N)&&await n.rm(v(T,O))}try{(await n.readdir(T)).length===0&&await n.rm(T,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:l,packHash:g}}function fa(e,t,n=!1){let r=e-t,o=[`Enumerating objects: ${e}, done.`];return n&&o.push(`Counting objects: 100% (${e}/${e}), done.`),o.push("Delta compression using 1 thread.",`Compressing objects: 100% (${r}/${e}), done.`,`Writing objects: 100% (${e}/${e}), done.`,`Total ${e} (delta ${t}), reused 0 (delta 0), pack-reused 0`),o.join(`
416
+ `)}function Tl(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:$().alias("a").describe("Pack all objects, including already-packed"),delete:$().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=await Il(s),a=await ca({gitCtx:s,fs:r.fs,tips:i,cleanup:n.delete,all:n.all});return a?{stdout:"",stderr:`${fa(a.totalCount,a.deltaCount)}
417
417
  `,exitCode:0}:{stdout:`Nothing new to pack.
418
- `,stderr:"",exitCode:0}}})}function Tl(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:$().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;await vc(s),await yt(s);let i=await qp(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await aa({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await zp(s.gitDir,r.fs),f)return{stdout:"",stderr:`${ca(f.totalCount,f.deltaCount,!0)}
419
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Wp=2160*60*60;async function qp(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await pe(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Wp,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await vl(e,i,i,s,t);let a=await z(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let l=await B(e,f);l&&t.add(l)}let c=[];for(let f of t)await Vt(e,f)&&c.push(f);return c}async function vl(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 vl(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!==ee&&o.add(u.newHash);continue}let d=l.filter(u=>u.timestamp>=r);await Ln(e,f,d);for(let u of d)u.newHash!==ee&&o.add(u.newHash)}}}async function zp(e,t){let n=v(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(v(n,o),{recursive:!0})}catch{}}oe();function Kp(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 Al(e,t,n,r){if(Kp(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
420
- `);if(o.length>0&&o[o.length-1]===""&&o.pop(),n&&t.length>1&&!t.every(a=>o.some(c=>a.test(c))))return{matches:[],binary:!1};let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.some(f=>f.test(a));(r?!c:c)&&s.push({lineNo:i+1,line:a})}return{matches:s,binary:!1}}function Vp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hl(e,t){let n=t?.fixed?Vp(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ae();me();Ae();async function Yp(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 Xp(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=o.hash;r.push({path:o.path,getContent:()=>se(e,s)})}return r}async function Zp(e,t){return(await Ke(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>se(e,r.hash)}))}function Jp(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function Qp(e,t,n){return n||t===""?e:st(t,e)}function Dl(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[q.string().name("args").variadic().optional()],options:{cached:$().describe("Search blobs registered in the index"),lineNumber:$().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:$().alias("l").describe("Show only filenames"),filesWithoutMatch:$().alias("L").describe("Show only filenames without matches"),count:$().alias("c").describe("Show count of matching lines per file"),ignoreCase:$().alias("i").describe("Case insensitive matching"),wordRegexp:$().alias("w").describe("Match whole words only"),invertMatch:$().alias("v").describe("Invert the sense of matching"),fixedStrings:$().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:$().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:$().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:$().alias("h").describe("Suppress filename prefix"),forceFilename:$().alias("H").describe("Force filename prefix"),fullName:$().describe("Force paths to be output relative to project top"),quiet:$().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:$().describe("Require all patterns to match in a file"),maxDepth:V.number().describe("Descend at most <n> levels of directories"),maxCount:V.number().alias("m").describe("Maximum number of matches per file"),afterContext:V.number().alias("A").describe("Show <n> lines after match"),beforeContext:V.number().alias("B").describe("Show <n> lines before match"),context:V.number().alias("C").describe("Show <n> lines before and after match"),heading:$().describe("Show filename above matches"),break:$().describe("Print empty line between results from different files"),pattern:V.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return I("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let u=[];for(let U of f){let L=Hl(U,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!L)return I(`command line, '${U}': invalid regular expression`);u.push(L)}let m=[];if(l.length>0)for(let U of l){let L=await wt(i,U);if(M(L))return L;let K;try{K=await ve(i,L)}catch{return I(`bad revision '${U}'`)}let te=await j(i,K),J=await Zp(i,te.tree);m.push({prefix:`${U}:`,files:J})}else if(n.cached)m.push({prefix:"",files:await Xp(i)});else{if(!i.workTree)return I("this operation must be run in a work tree");m.push({prefix:"",files:await Yp(i)})}let h=ut(i,r.cwd),p=null;c.length>0&&(p=c.map(U=>Ue(U,h)));let g=n.maxDepth,w=n.maxCount,y=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),x=!!n.filesWithMatches,b=!!n.filesWithoutMatch,E=!!n.count,R=!!n.quiet,k=!!n.heading,C=!!n.break,P=!!n.suppressFilename,T=!!n.invertMatch,D=!!n.allMatch,O=n.context??n.afterContext??0,N=n.context??n.beforeContext??0,H=O>0||N>0,S=[],A=!1,_=!0;for(let U of m){let L=U.files.slice().sort((K,te)=>K.path<te.path?-1:K.path>te.path?1:0);for(let K of L){if(p&&!Ee(p,K.path)||g!==void 0&&Jp(K.path)>g)continue;let te=await K.getContent(),J=Al(te,u,D,T),ne=Qp(K.path,h,!!n.fullName),ke=U.prefix;if(J.binary){if(A=!0,R)return{stdout:"",stderr:"",exitCode:0};x?S.push(`${ke}${ne}`):!b&&!E&&S.push(`Binary file ${ke}${ne} matches`);continue}if(J.matches.length===0){b&&S.push(`${ke}${ne}`);continue}if(A=!0,R)return{stdout:"",stderr:"",exitCode:0};if(b)continue;if(x){S.push(`${ke}${ne}`);continue}if(E){let ie=w!==void 0?Math.min(J.matches.length,w):J.matches.length;S.push(`${ke}${ne}:${ie}`);continue}let je=J.matches;if(w!==void 0&&(je=je.slice(0,w)),H)eg(S,te,je,ke,ne,P,N,O,k,C,_);else if(k){!_&&C&&S.push(""),S.push(`${ke}${ne}`);for(let ie of je)y?S.push(`${ie.lineNo}:${ie.line}`):S.push(ie.line)}else{!_&&C&&S.push("");for(let ie of je){let $e=P?"":`${ke}${ne}:`;y?S.push(`${$e}${ie.lineNo}:${ie.line}`):S.push(`${$e}${ie.line}`)}}_=!1}}return R?{stdout:"",stderr:"",exitCode:A?0:1}:{stdout:S.length>0?`${S.join(`
418
+ `,stderr:"",exitCode:0}}})}function vl(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:$().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;await Ac(s),await yt(s);let i=await Kp(s);if(i.length>0){let a=n.aggressive?250:10,c=n.aggressive?250:50,f=await ca({gitCtx:s,fs:r.fs,tips:i,window:a,depth:c,cleanup:!0,all:!0});if(await Vp(s.gitDir,r.fs),f)return{stdout:"",stderr:`${fa(f.totalCount,f.deltaCount,!0)}
419
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var zp=2160*60*60;async function Kp(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await pe(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-zp,i=v(e.gitDir,"logs");await e.fs.exists(i)&&await Al(e,i,i,s,t);let a=await z(e);for(let f of a.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let l=await B(e,f);l&&t.add(l)}let c=[];for(let f of t)await Vt(e,f)&&c.push(f);return c}async function Al(e,t,n,r,o){let s=await e.fs.readdir(t);for(let i of s){let a=v(t,i),c=await e.fs.stat(a);if(c.isDirectory){await Al(e,a,n,r,o);try{(await e.fs.readdir(a)).length===0&&await e.fs.rm(a,{recursive:!0})}catch{}}else if(c.isFile){let f=a.slice(n.length+1),l=await et(e,f);if(f==="refs/stash"){for(let u of l)u.newHash!==ee&&o.add(u.newHash);continue}let d=l.filter(u=>u.timestamp>=r);await Ln(e,f,d);for(let u of d)u.newHash!==ee&&o.add(u.newHash)}}}async function Vp(e,t){let n=v(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(v(n,o),{recursive:!0})}catch{}}oe();function Yp(e){let t=Math.min(e.length,8e3),n=0;for(let r=0;r<t;r++)e.charCodeAt(r)===0&&n++;return n>t*.01}function Hl(e,t,n,r){if(Yp(e)){let i=t.some(a=>a.test(e));return{matches:[],binary:i}}let o=e.split(`
420
+ `);if(o.length>0&&o[o.length-1]===""&&o.pop(),n&&t.length>1&&!t.every(a=>o.some(c=>a.test(c))))return{matches:[],binary:!1};let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.some(f=>f.test(a));(r?!c:c)&&s.push({lineNo:i+1,line:a})}return{matches:s,binary:!1}}function Xp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dl(e,t){let n=t?.fixed?Xp(e):e;t?.wordRegexp&&(n=`\\b${n}\\b`);let r=t?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}Ce();ae();me();Ae();async function Zp(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=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 Jp(e){let t=await z(e),n=new Set,r=[];for(let o of t.entries){if(o.stage!==0||n.has(o.path))continue;n.add(o.path);let s=o.hash;r.push({path:o.path,getContent:()=>se(e,s)})}return r}async function Qp(e,t){return(await Ke(e,t)).filter(r=>!r.mode.startsWith("120")).map(r=>({path:r.path,getContent:()=>se(e,r.hash)}))}function eg(e){let t=0;for(let n=0;n<e.length;n++)e[n]==="/"&&t++;return t}function tg(e,t,n){return n||t===""?e:st(t,e)}function Ml(e,t){e.command("grep",{description:"Print lines matching a pattern",args:[q.string().name("args").variadic().optional()],options:{cached:$().describe("Search blobs registered in the index"),lineNumber:$().alias("n").describe("Prefix the line number to matching lines"),filesWithMatches:$().alias("l").describe("Show only filenames"),filesWithoutMatch:$().alias("L").describe("Show only filenames without matches"),count:$().alias("c").describe("Show count of matching lines per file"),ignoreCase:$().alias("i").describe("Case insensitive matching"),wordRegexp:$().alias("w").describe("Match whole words only"),invertMatch:$().alias("v").describe("Invert the sense of matching"),fixedStrings:$().alias("F").describe("Interpret pattern as fixed string"),extendedRegexp:$().alias("E").describe("Interpret pattern as extended regexp"),basicRegexp:$().alias("G").describe("Interpret pattern as basic regexp"),suppressFilename:$().alias("h").describe("Suppress filename prefix"),forceFilename:$().alias("H").describe("Force filename prefix"),fullName:$().describe("Force paths to be output relative to project top"),quiet:$().alias("q").describe("Do not output matched lines; exit with status 0 on match"),allMatch:$().describe("Require all patterns to match in a file"),maxDepth:V.number().describe("Descend at most <n> levels of directories"),maxCount:V.number().alias("m").describe("Maximum number of matches per file"),afterContext:V.number().alias("A").describe("Show <n> lines after match"),beforeContext:V.number().alias("B").describe("Show <n> lines before match"),context:V.number().alias("C").describe("Show <n> lines before and after match"),heading:$().describe("Show filename above matches"),break:$().describe("Print empty line between results from different files"),pattern:V.string().alias("e").repeatable().describe("Match <pattern>")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args??[],c=o.passthrough??[],f=n.pattern,l=[],d=0;if(f.length===0){if(a.length===0)return I("no pattern given");f.push(a[d++])}for(;d<a.length;d++)l.push(a[d]);let u=[];for(let U of f){let L=Dl(U,{fixed:!!n.fixedStrings,ignoreCase:!!n.ignoreCase,wordRegexp:!!n.wordRegexp});if(!L)return I(`command line, '${U}': invalid regular expression`);u.push(L)}let m=[];if(l.length>0)for(let U of l){let L=await wt(i,U);if(M(L))return L;let K;try{K=await ve(i,L)}catch{return I(`bad revision '${U}'`)}let te=await j(i,K),J=await Qp(i,te.tree);m.push({prefix:`${U}:`,files:J})}else if(n.cached)m.push({prefix:"",files:await Jp(i)});else{if(!i.workTree)return I("this operation must be run in a work tree");m.push({prefix:"",files:await Zp(i)})}let h=ut(i,r.cwd),p=null;c.length>0&&(p=c.map(U=>Ue(U,h)));let g=n.maxDepth,w=n.maxCount,y=!!(n.lineNumber||n.afterContext!=null||n.beforeContext!=null||n.context!=null),x=!!n.filesWithMatches,b=!!n.filesWithoutMatch,E=!!n.count,R=!!n.quiet,k=!!n.heading,C=!!n.break,P=!!n.suppressFilename,T=!!n.invertMatch,D=!!n.allMatch,O=n.context??n.afterContext??0,N=n.context??n.beforeContext??0,H=O>0||N>0,S=[],A=!1,_=!0;for(let U of m){let L=U.files.slice().sort((K,te)=>K.path<te.path?-1:K.path>te.path?1:0);for(let K of L){if(p&&!Ee(p,K.path)||g!==void 0&&eg(K.path)>g)continue;let te=await K.getContent(),J=Hl(te,u,D,T),ne=tg(K.path,h,!!n.fullName),ke=U.prefix;if(J.binary){if(A=!0,R)return{stdout:"",stderr:"",exitCode:0};x?S.push(`${ke}${ne}`):!b&&!E&&S.push(`Binary file ${ke}${ne} matches`);continue}if(J.matches.length===0){b&&S.push(`${ke}${ne}`);continue}if(A=!0,R)return{stdout:"",stderr:"",exitCode:0};if(b)continue;if(x){S.push(`${ke}${ne}`);continue}if(E){let ie=w!==void 0?Math.min(J.matches.length,w):J.matches.length;S.push(`${ke}${ne}:${ie}`);continue}let je=J.matches;if(w!==void 0&&(je=je.slice(0,w)),H)ng(S,te,je,ke,ne,P,N,O,k,C,_);else if(k){!_&&C&&S.push(""),S.push(`${ke}${ne}`);for(let ie of je)y?S.push(`${ie.lineNo}:${ie.line}`):S.push(ie.line)}else{!_&&C&&S.push("");for(let ie of je){let $e=P?"":`${ke}${ne}:`;y?S.push(`${$e}${ie.lineNo}:${ie.line}`):S.push(`${$e}${ie.line}`)}}_=!1}}return R?{stdout:"",stderr:"",exitCode:A?0:1}:{stdout:S.length>0?`${S.join(`
421
421
  `)}
422
- `:"",stderr:"",exitCode:A?0:1}}})}function eg(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
423
- `);d.length>0&&d[d.length-1]===""&&d.pop();let u=new Set(n.map(g=>g.lineNo)),m=[];for(let g of n){let w=Math.max(1,g.lineNo-i),y=Math.min(d.length,g.lineNo+a);m.push([w,y])}let h=[];for(let[g,w]of m)h.length>0&&g<=h[h.length-1][1]+1?h[h.length-1][1]=Math.max(h[h.length-1][1],w):h.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<h.length;g++){g>0&&e.push("--");let[w,y]=h[g];for(let x=w;x<=y;x++){let b=d[x-1],R=u.has(x)?":":"-";c?e.push(`${x}${R}${b}`):e.push(`${p}${R}${x}${R}${b}`)}}}me();Gn();function Ml(e,t){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:$().describe("Create a bare repository"),initialBranch:V.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?vt(r.cwd,n.directory):r.cwd;n.directory&&await r.fs.mkdir(s,{recursive:!0});let{ctx:i,reinit:a}=await Ws(r.fs,s,{bare:n.bare,...o?{initialBranch:o}:{}}),c="";a&&o&&(c=`warning: re-init: ignored --initial-branch=${o}
422
+ `:"",stderr:"",exitCode:A?0:1}}})}function ng(e,t,n,r,o,s,i,a,c,f,l){let d=t.split(`
423
+ `);d.length>0&&d[d.length-1]===""&&d.pop();let u=new Set(n.map(g=>g.lineNo)),m=[];for(let g of n){let w=Math.max(1,g.lineNo-i),y=Math.min(d.length,g.lineNo+a);m.push([w,y])}let h=[];for(let[g,w]of m)h.length>0&&g<=h[h.length-1][1]+1?h[h.length-1][1]=Math.max(h[h.length-1][1],w):h.push([g,w]);let p=s?"":`${r}${o}`;c?(!l&&f&&e.push(""),e.push(`${r}${o}`)):!l&&f&&e.push("");for(let g=0;g<h.length;g++){g>0&&e.push("--");let[w,y]=h[g];for(let x=w;x<=y;x++){let b=d[x-1],R=u.has(x)?":":"-";c?e.push(`${x}${R}${b}`):e.push(`${p}${R}${x}${R}${b}`)}}}me();Gn();function jl(e,t){e.command("init",{description:"Initialize a new repository",args:[q.string().name("directory").describe("The directory to initialize").optional()],options:{bare:$().describe("Create a bare repository"),initialBranch:V.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(n,r)=>{let o=n.initialBranch??t?.configOverrides?.locked?.["init.defaultBranch"]??t?.configOverrides?.defaults?.["init.defaultBranch"],s=n.directory?vt(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}
424
424
  `);let f=n.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${f}Git repository in ${i.gitDir}/
425
- `,stderr:c,exitCode:0}}})}oe();ar();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:jl(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,jl(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 jl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}oe();function Rs(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let i=e[s+1];if(i===void 0){o+="%",s++;continue}if((i==="a"||i==="c")&&s+2<e.length){let a=e[s+2],c=i==="a"?r.author:r.committer;switch(a){case"n":o+=c.name,s+=3;continue;case"e":case"E":o+=c.email,s+=3;continue;case"t":o+=c.timestamp.toString(),s+=3;continue;case"I":o+=Nl(c.timestamp,c.timezone),s+=3;continue;case"i":o+=_l(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Go(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=Ul(c.timestamp,c.timezone),s+=3;continue;case"r":o+=Fl(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+=fa(r.message),s+=2;continue;case"b":o+=tg(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
426
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var fa=ue;function tg(e){let t=e.indexOf(`
425
+ `,stderr:c,exitCode:0}}})}oe();ar();var Lo=class{hash=null;parents=[];nParents=0;state=0;prevState=0;commitIdx=0;prevCommitIdx=0;mergeLayout=0;edgesAdded=0;prevEdgesAdded=0;w=0;expRow=0;cols=[];nCols=0;newCols=[];nNewCols=0;map=[];oldMap=[];mapSize=0;get width(){return this.w}update(t,n){this.hash=t,this.parents=n,this.nParents=n.length,this.prevCommitIdx=this.commitIdx,this.updateColumns(),this.expRow=0,this.state!==0?this.state=1:this.needsPreCommit()?this.state=2:this.state=3}nextLine(){let t,n=!1;switch(this.state){case 0:t=this.outPadding();break;case 1:t=this.outSkip();break;case 2:t=this.outPreCommit();break;case 3:t=this.outCommit(),n=!0;break;case 4:t=this.outPostMerge();break;case 5:t=this.outCollapsing();break}return{prefix:Gl(t,this.w),isCommitLine:n}}isFinished(){return this.state===0}paddingPrefix(){if(this.state!==3)return this.nextLine().prefix;let t="";for(let n=0;n<this.nCols;n++)t+="| ";return this.prevState=0,Gl(t,this.w)}updateColumns(){let t=this.newCols,n=this.nNewCols;this.newCols=this.cols,this.nNewCols=0,this.cols=t,this.nCols=n;let r=this.nCols+this.nParents;this.map.length<2*r&&(this.map=new Array(2*r),this.oldMap=new Array(2*r)),this.mapSize=2*r,this.map.fill(-1,0,this.mapSize),this.w=0,this.prevEdgesAdded=this.edgesAdded,this.edgesAdded=0;let o=!1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(o)break;i=this.hash}else i=this.cols[s];if(i===this.hash){o=!0,this.commitIdx=s,this.mergeLayout=-1;for(let a of this.parents)this.insertNewCol(a,s);this.nParents===0&&(this.w+=2)}else this.insertNewCol(i,-1)}for(;this.mapSize>1&&this.map[this.mapSize-1]<0;)this.mapSize--}findNewCol(t){for(let n=0;n<this.nNewCols;n++)if(this.newCols[n]===t)return n;return-1}insertNewCol(t,n){let r=this.findNewCol(t);r<0&&(r=this.nNewCols++,this.newCols[r]=t);let o;if(this.nParents>1&&n>-1&&this.mergeLayout===-1){let s=n-r,i=s>1?2*s-3:1;this.mergeLayout=s>0?0:1,this.edgesAdded=this.nParents+this.mergeLayout-2,o=this.w+(this.mergeLayout-1)*i,this.w+=2*this.mergeLayout}else this.edgesAdded>0&&this.w>=2&&r===this.map[this.w-2]?(o=this.w-2,this.edgesAdded=-1):(o=this.w,this.w+=2);this.map[o]=r}setState(t){this.prevState=this.state,this.state=t}numDashedParents(){return this.nParents+this.mergeLayout-3}numExpansionRows(){return this.numDashedParents()*2}needsPreCommit(){return this.nParents>=3&&this.commitIdx<this.nCols-1&&this.expRow<this.numExpansionRows()}isMappingCorrect(){for(let t=0;t<this.mapSize;t++){let n=this.map[t];if(!(n<0)&&n!==t>>1)return!1}return!0}outPadding(){let t="";for(let n=0;n<this.nNewCols;n++)t+="| ";return t}outSkip(){return this.needsPreCommit()?this.setState(2):this.setState(3),"..."}outPreCommit(){let t="",n=!1;for(let r=0;r<this.nCols;r++)this.cols[r]===this.hash?(n=!0,t+="|",t+=" ".repeat(this.expRow)):n&&this.expRow===0?this.prevState===4&&this.prevCommitIdx<r?t+="\\":t+="|":n?t+="\\":t+="|",t+=" ";return this.expRow++,this.needsPreCommit()||this.setState(3),t}outCommit(){let t="",n=!1;for(let r=0;r<=this.nCols;r++){let o;if(r===this.nCols){if(n)break;o=this.hash}else o=this.cols[r];o===this.hash?(n=!0,t+="*",this.nParents>2&&(t+=this.drawOctopus())):n&&this.edgesAdded>1?t+="\\":n&&this.edgesAdded===1?this.prevState===4&&this.prevEdgesAdded>0&&this.prevCommitIdx<r?t+="\\":t+="|":this.prevState===5&&this.oldMap[2*r+1]===r&&this.map[2*r]<r?t+="/":t+="|",t+=" "}return this.nParents>1?this.setState(4):this.isMappingCorrect()?this.setState(0):this.setState(5),t}drawOctopus(){let t=this.numDashedParents(),n="";for(let r=0;r<t;r++)n+="-",n+=r===t-1?".":"-";return n}outPostMerge(){let t=["/","|","\\"],n="",r=!1,o=-1;for(let s=0;s<=this.nCols;s++){let i;if(s===this.nCols){if(r)break;i=this.hash}else i=this.cols[s];if(i===this.hash){r=!0;let a=this.mergeLayout;for(let c=0;c<this.nParents;c++)n+=t[a],a===2?(this.edgesAdded>0||c<this.nParents-1)&&(n+=" "):a++;this.edgesAdded===0&&(n+=" ")}else r?(this.edgesAdded>0?n+="\\":n+="|",n+=" "):(n+="|",(this.mergeLayout!==0||s!==this.commitIdx-1)&&(o>=0?n+="_":n+=" "));i===this.parents[0]&&(o=s)}return this.isMappingCorrect()?this.setState(0):this.setState(5),n}outCollapsing(){let t=this.map;this.map=this.oldMap,this.oldMap=t,this.map.fill(-1,0,this.mapSize);let n=-1,r=-1;for(let i=0;i<this.mapSize;i++){let a=this.oldMap[i];if(!(a<0)){if(a*2===i)this.map[i]=a;else if(this.map[i-1]<0){if(this.map[i-1]=a,n===-1){n=i,r=a;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}else if(this.map[i-1]!==a){if(this.map[i-2]=a,n===-1){r=a,n=i-1;for(let c=a*2+3;c<i-2;c+=2)this.map[c]=a}}}}for(let i=0;i<this.mapSize;i++)this.oldMap[i]=this.map[i];this.mapSize>0&&this.map[this.mapSize-1]<0&&this.mapSize--;let o="",s=!1;for(let i=0;i<this.mapSize;i++){let a=this.map[i];a<0?o+=" ":a*2===i?o+="|":a===r&&i!==n-1?(i!==a*2+3&&(this.map[i]=-1),s=!0,o+="_"):(s&&i<n&&(this.map[i]=-1),o+="/")}return this.isMappingCorrect()&&this.setState(0),o}};function Gl(e,t){return e.length>=t?e:e+" ".repeat(t-e.length)}oe();function xs(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let i=e[s+1];if(i===void 0){o+="%",s++;continue}if((i==="a"||i==="c")&&s+2<e.length){let a=e[s+2],c=i==="a"?r.author:r.committer;switch(a){case"n":o+=c.name,s+=3;continue;case"e":case"E":o+=c.email,s+=3;continue;case"t":o+=c.timestamp.toString(),s+=3;continue;case"I":o+=_l(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Fl(c.timestamp,c.timezone),s+=3;continue;case"d":o+=No(c.timestamp,c.timezone,t.dateMode),s+=3;continue;case"D":o+=Bl(c.timestamp,c.timezone),s+=3;continue;case"r":o+=Ul(c.timestamp),s+=3;continue}}switch(i){case"H":o+=n,s+=2;continue;case"h":o+=X(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=X(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(X).join(" "),s+=2;continue;case"s":o+=la(r.message),s+=2;continue;case"b":o+=rg(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let a=t.decorations(n);o+=a?` ${a}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
426
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${i}`,s+=2;continue}}o+=e[s],s++}return o}var la=ue;function rg(e){let t=e.indexOf(`
427
427
 
428
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function Lo(e){return e.startsWith("format:")?{formatStr:e.slice(7),preset:null}:e.startsWith("tformat:")?{formatStr:e.slice(8),preset:null}:["oneline","short","medium","full","fuller","raw"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function xs(e,t,n,r=!1){let{hash:o,commit:s}=t,i=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let a=r?X(o):o,c=fa(s.message);return i?`${a} ${i} ${c}`:`${a} ${c}`}case"short":{let a=[];return n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(""),a.push(` ${fa(s.message)}`),a.join(`
428
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function _o(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 Cs(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=la(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(` ${la(s.message)}`),a.join(`
429
429
  `)}case"full":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
430
430
  `))a.push(` ${f}`);return a.join(`
431
- `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${Go(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${Go(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
431
+ `)}case"fuller":{let a=[];n||a.push(""),a.push(i?`commit ${o} ${i}`:`commit ${o}`),s.parents.length>=2&&a.push(`Merge: ${s.parents.map(X).join(" ")}`),a.push(`Author: ${s.author.name} <${s.author.email}>`),a.push(`AuthorDate: ${No(s.author.timestamp,s.author.timezone,t.dateMode)}`),a.push(`Commit: ${s.committer.name} <${s.committer.email}>`),a.push(`CommitDate: ${No(s.committer.timestamp,s.committer.timezone,t.dateMode)}`),a.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
432
432
  `))a.push(` ${f}`);return a.join(`
433
- `)}case"raw":return ng(t,n);default:return rg(t,n)}}function ng(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(`
433
+ `)}case"raw":return sg(t,n);default:return og(t,n)}}function sg(e,t){let{hash:n,commit:r}=e,o=[];t||o.push(""),o.push(`commit ${n}`),o.push(`tree ${r.tree}`);for(let i of r.parents)o.push(`parent ${i}`);o.push(`author ${r.author.name} <${r.author.email}> ${r.author.timestamp} ${r.author.timezone}`),o.push(`committer ${r.committer.name} <${r.committer.email}> ${r.committer.timestamp} ${r.committer.timezone}`),o.push("");let s=r.message.replace(/\n$/,"");for(let i of s.split(`
434
434
  `))o.push(` ${i}`);return o.join(`
435
- `)}function rg(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: ${Go(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
435
+ `)}function og(e,t){let{hash:n,commit:r}=e,o=e.decorations?e.decorations(n):"",s=[];t||s.push(""),s.push(o?`commit ${n} ${o}`:`commit ${n}`),r.parents.length>=2&&s.push(`Merge: ${r.parents.map(X).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${No(r.author.timestamp,r.author.timezone,e.dateMode)}`),s.push("");let i=r.message.replace(/\n$/,"");for(let a of i.split(`
436
436
  `))s.push(` ${a}`);return s.join(`
437
- `)}var Gl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ll=["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 No(e,t){let n=sg(t);return new Date((e+n*60)*1e3)}function og(e){return`${e.slice(0,3)}:${e.slice(3)}`}function Nl(e,t){let n=No(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":og(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function _l(e,t){let n=No(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 Fl(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 ig(e,t){let n=No(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 ag(e,t){return`${e} ${t}`}function cg(e){return e.toString()}function fg(e,t){let n=new Date(e*1e3),r=Gl[n.getDay()]?.slice(0,3),o=Ll[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 Go(e,t,n){switch(n){case"short":return ig(e,t);case"iso":return _l(e,t);case"iso-strict":return Nl(e,t);case"relative":case"human":return Fl(e);case"rfc":return Ul(e,t);case"raw":return ag(e,t);case"unix":return cg(e);case"local":return fg(e,t);default:return Cn(e,t)}}function Ul(e,t){let n=No(e,t),r=Gl[n.getUTCDay()]?.slice(0,3),o=Ll[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}`}ae();ge();sn();Ae();function ql(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[q.string().name("revisions").variadic().optional()],options:{maxCount:V.number().alias("n").describe("Limit the number of commits to output"),oneline:$().describe("Condense each commit to a single line"),all:$().describe("Walk all refs, not just HEAD"),author:V.string().describe("Filter by author (regex or substring)"),grep:V.string().describe("Filter by commit message (regex or substring)"),since:V.string().describe("Show commits after date"),after:V.string().describe("Synonym for --since"),until:V.string().describe("Show commits before date"),before:V.string().describe("Synonym for --until"),decorate:$().describe("Show ref names next to commit hashes"),reverse:$().describe("Output commits in reverse order"),format:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name"),patch:$().alias("p").describe("Show diff in patch format"),stat:$().describe("Show diffstat summary"),nameStatus:$().describe("Show names and status of changed files"),nameOnly:$().describe("Show only names of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),graph:$().describe("Draw text-based graph of the commit history"),firstParent:$().describe("Follow only the first parent of merge commits"),date:V.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Ho(f[0]):null;if(l){let J=async $e=>{let rt=await Be(i,$e);if(!rt)return Yt($e);try{return await ve(i,rt)}catch{return Yt($e)}},ne=await J(l.left);if(typeof ne=="object"&&"exitCode"in ne)return ne;let ke=await J(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let je=ne,ie=ke;if(l.type==="two-dot")a=[ie],c=[je];else{a=[je,ie];let $e=await Ft(i,je,ie);c=$e.length>0?$e:void 0}if(n.all){let $e=await pe(i);for(let Sn of $e)try{let We=await ve(i,Sn.hash);a.includes(We)||a.push(We)}catch{}let rt=await Y(i);rt&&!a.includes(rt)&&a.push(rt)}}else if(n.all){let J=await pe(i),ne=new Set;for(let je of J)try{ne.add(await ve(i,je.hash))}catch{}let ke=await Y(i);ke&&ne.add(ke),a=[...ne]}else if(f&&f.length>0){let J=[];for(let ne of f){let ke=await Be(i,ne);if(!ke)return Yt(ne);try{J.push(await ve(i,ke))}catch{return Yt(ne)}}a=J}else{let J=await Qe(i);if(M(J))return J;a=[J]}if(a.length===0)return I("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(J=>Ue(J,"")):null,u=n.author?Bl(n.author):null,m=n.grep?Bl(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?qi(h):null,w=p?qi(p):null,y=n.format??n.pretty,x=null,b=null,E=!1;if(n.oneline)b="oneline",E=!0;else if(y!==void 0){let J=Lo(y);x=J.formatStr,b=J.preset}let R=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!R.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
438
- `,exitCode:128};let k=n.date,C=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,P=n.graph;if(P&&n.reverse)return I("options '--graph' and '--reverse' cannot be used together");let D=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await ug(i):null,O=D?J=>Wl(D,J):void 0,N=D?J=>{let ne=Wl(D,J);return ne.startsWith("(")&&ne.endsWith(")")?ne.slice(1,-1):ne}:void 0,H=n.maxCount,S=n.reverse,A=n.firstParent,_=d?dg(i,a,d,c?await lg(i,c):void 0,A):jt(i,a,{exclude:c,topoOrder:P,firstParent:A}),F=[];for await(let J of _){if(H!==void 0&&F.length>=H)break;let{commit:ne}=J;if(!(w!==null&&ne.committer.timestamp>w)&&!(g!==null&&ne.committer.timestamp<=g)){if(u){let ke=`${ne.author.name} <${ne.author.email}>`;if(!u(ke))continue}m&&!m(ne.message)||F.push(J)}}let U=S?F.reverse():F;if(P)return mg(U,i,x,b,E,C,O,N,k);if(x!==null){let J=[];for(let ne of U){let ke={hash:ne.hash,commit:ne.commit,decorations:O,decorationsRaw:N,dateMode:k},je=Rs(x,ke),ie=await la(i,ne.commit,C);ie&&(je+=`
437
+ `)}var Ll=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Nl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ig(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function Fo(e,t){let n=ig(t);return new Date((e+n*60)*1e3)}function ag(e){return`${e.slice(0,3)}:${e.slice(3)}`}function _l(e,t){let n=Fo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=t==="+0000"||t==="-0000"?"Z":ag(t);return`${r}-${o}-${s}T${i}:${a}:${c}${f}`}function Fl(e,t){let n=Fo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${i}:${a}:${c} ${t}`}function Ul(e){let n=Math.floor(Date.now()/1e3)-e;if(n<0&&(n=0),n<90)return n===1?"1 second ago":`${n} seconds ago`;if(n=Math.round(n/60),n<90)return n===1?"1 minute ago":`${n} minutes ago`;if(n=Math.round(n/60),n<36)return n===1?"1 hour ago":`${n} hours ago`;if(n=Math.round(n/24),n<14)return n===1?"1 day ago":`${n} days ago`;if(n<70){let s=Math.round(n/7);return s===1?"1 week ago":`${s} weeks ago`}if(n<365){let s=Math.round(n/30);return s===1?"1 month ago":`${s} months ago`}let r=Math.floor(n/365),o=Math.round((n-r*365)/30);if(o>0){let s=r===1?"1 year":`${r} years`,i=o===1?"1 month":`${o} months`;return`${s}, ${i} ago`}return r===1?"1 year ago":`${r} years ago`}function cg(e,t){let n=Fo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0");return`${r}-${o}-${s}`}function fg(e,t){return`${e} ${t}`}function lg(e){return e.toString()}function dg(e,t){let n=new Date(e*1e3),r=Ll[n.getDay()]?.slice(0,3),o=Nl[n.getMonth()],s=n.getDate(),i=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),c=String(n.getSeconds()).padStart(2,"0"),f=n.getFullYear();return`${r} ${o} ${s} ${i}:${a}:${c} ${f}`}function No(e,t,n){switch(n){case"short":return cg(e,t);case"iso":return Fl(e,t);case"iso-strict":return _l(e,t);case"relative":case"human":return Ul(e);case"rfc":return Bl(e,t);case"raw":return fg(e,t);case"unix":return lg(e);case"local":return dg(e,t);default:return Cn(e,t)}}function Bl(e,t){let n=Fo(e,t),r=Ll[n.getUTCDay()]?.slice(0,3),o=Nl[n.getUTCMonth()],s=n.getUTCDate(),i=String(n.getUTCHours()).padStart(2,"0"),a=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${i}:${a}:${c} ${t}`}ae();ge();sn();Ae();function zl(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[q.string().name("revisions").variadic().optional()],options:{maxCount:V.number().alias("n").describe("Limit the number of commits to output"),oneline:$().describe("Condense each commit to a single line"),all:$().describe("Walk all refs, not just HEAD"),author:V.string().describe("Filter by author (regex or substring)"),grep:V.string().describe("Filter by commit message (regex or substring)"),since:V.string().describe("Show commits after date"),after:V.string().describe("Synonym for --since"),until:V.string().describe("Show commits before date"),before:V.string().describe("Synonym for --until"),decorate:$().describe("Show ref names next to commit hashes"),reverse:$().describe("Output commits in reverse order"),format:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name"),patch:$().alias("p").describe("Show diff in patch format"),stat:$().describe("Show diffstat summary"),nameStatus:$().describe("Show names and status of changed files"),nameOnly:$().describe("Show only names of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),graph:$().describe("Draw text-based graph of the commit history"),firstParent:$().describe("Follow only the first parent of merge commits"),date:V.string().describe("Date format: short, iso, iso-strict, relative, rfc, raw, unix, local, human, default")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a,c,f=n.revisions,l=f&&f.length===1?Mo(f[0]):null;if(l){let J=async $e=>{let rt=await Be(i,$e);if(!rt)return Yt($e);try{return await ve(i,rt)}catch{return Yt($e)}},ne=await J(l.left);if(typeof ne=="object"&&"exitCode"in ne)return ne;let ke=await J(l.right);if(typeof ke=="object"&&"exitCode"in ke)return ke;let je=ne,ie=ke;if(l.type==="two-dot")a=[ie],c=[je];else{a=[je,ie];let $e=await Ft(i,je,ie);c=$e.length>0?$e:void 0}if(n.all){let $e=await pe(i);for(let Sn of $e)try{let We=await ve(i,Sn.hash);a.includes(We)||a.push(We)}catch{}let rt=await Y(i);rt&&!a.includes(rt)&&a.push(rt)}}else if(n.all){let J=await pe(i),ne=new Set;for(let je of J)try{ne.add(await ve(i,je.hash))}catch{}let ke=await Y(i);ke&&ne.add(ke),a=[...ne]}else if(f&&f.length>0){let J=[];for(let ne of f){let ke=await Be(i,ne);if(!ke)return Yt(ne);try{J.push(await ve(i,ke))}catch{return Yt(ne)}}a=J}else{let J=await Qe(i);if(M(J))return J;a=[J]}if(a.length===0)return I("your current branch does not have any commits yet");let d=o.passthrough.length>0?o.passthrough.map(J=>Ue(J,"")):null,u=n.author?Wl(n.author):null,m=n.grep?Wl(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?Ki(h):null,w=p?Ki(p):null,y=n.format??n.pretty,x=null,b=null,E=!1;if(n.oneline)b="oneline",E=!0;else if(y!==void 0){let J=_o(y);x=J.formatStr,b=J.preset}let R=new Set(["default","short","iso","iso-strict","relative","rfc","raw","unix","local","human"]);if(n.date&&!R.has(n.date))return{stdout:"",stderr:`fatal: unknown date format ${n.date}
438
+ `,exitCode:128};let k=n.date,C=n.patch?"patch":n.stat?"stat":n.nameStatus?"name-status":n.nameOnly?"name-only":n.shortstat?"shortstat":n.numstat?"numstat":null,P=n.graph;if(P&&n.reverse)return I("options '--graph' and '--reverse' cannot be used together");let D=n.decorate||x!=null&&(x.includes("%d")||x.includes("%D"))?await hg(i):null,O=D?J=>ql(D,J):void 0,N=D?J=>{let ne=ql(D,J);return ne.startsWith("(")&&ne.endsWith(")")?ne.slice(1,-1):ne}:void 0,H=n.maxCount,S=n.reverse,A=n.firstParent,_=d?mg(i,a,d,c?await ug(i,c):void 0,A):jt(i,a,{exclude:c,topoOrder:P,firstParent:A}),F=[];for await(let J of _){if(H!==void 0&&F.length>=H)break;let{commit:ne}=J;if(!(w!==null&&ne.committer.timestamp>w)&&!(g!==null&&ne.committer.timestamp<=g)){if(u){let ke=`${ne.author.name} <${ne.author.email}>`;if(!u(ke))continue}m&&!m(ne.message)||F.push(J)}}let U=S?F.reverse():F;if(P)return pg(U,i,x,b,E,C,O,N,k);if(x!==null){let J=[];for(let ne of U){let ke={hash:ne.hash,commit:ne.commit,decorations:O,decorationsRaw:N,dateMode:k},je=xs(x,ke),ie=await da(i,ne.commit,C);ie&&(je+=`
439
439
 
440
440
  ${ie.replace(/\n$/,"")}`),J.push(je)}return{stdout:J.length>0?`${J.join(`
441
441
  `)}
442
- `:"",stderr:"",exitCode:0}}let L=b??"medium",K=L==="oneline",te=[];for(let J=0;J<U.length;J++){let ne=U[J],ke={hash:ne.hash,commit:ne.commit,decorations:O,decorationsRaw:N,dateMode:k},je=xs(L,ke,J===0,E),ie=await la(i,ne.commit,C);ie&&(je+=`${K?`
442
+ `:"",stderr:"",exitCode:0}}let L=b??"medium",K=L==="oneline",te=[];for(let J=0;J<U.length;J++){let ne=U[J],ke={hash:ne.hash,commit:ne.commit,decorations:O,decorationsRaw:N,dateMode:k},je=Cs(L,ke,J===0,E),ie=await da(i,ne.commit,C);ie&&(je+=`${K?`
443
443
  `:`
444
444
 
445
445
  `}${ie.replace(/\n$/,"")}`),te.push(je)}return{stdout:te.length>0?`${te.join(`
446
446
  `)}
447
- `:"",stderr:"",exitCode:0}}})}async function lg(e,t){let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}function Bl(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*dg(e,t,n,r,o){let s=new Set(r),i=new Wn,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await Ve(e,null,f.tree)).some(m=>Ee(n,m.path))&&(yield c);continue}if(l.length===1){let u=l[0];if(u){try{let m=await j(e,u);(await Ve(e,m.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 m=await j(e,u);(await Ve(e,m.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 ug(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await Y(e),o=new Map,s=(f,l,d)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:l,fullRef:d})},i=await pe(e,"refs/heads");for(let f of i)s(f.hash,Pe(f.name),f.name);let a=await pe(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await pe(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await ve(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function Wl(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 mg(e,t,n,r,o,s,i,a,c){let f=new jo,l=r??"medium",d=l==="oneline",u=[];for(let m=0;m<e.length;m++){let h=e[m],p={hash:h.hash,commit:h.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=Rs(n,p):g=xs(l,p,!0,o),f.update(h.hash,h.commit.parents),m>0&&!d&&n===null&&u.push(f.paddingPrefix());let w=g.split(`
448
- `),y=0;for(;;){let{prefix:E,isCommitLine:R}=f.nextLine();if(R){u.push(E+(w[y++]??""));break}u.push(E)}for(;y<w.length;){let{prefix:E}=f.nextLine();u.push(E+w[y++])}for(;!f.isFinished();){let{prefix:E}=f.nextLine();u.push(E)}let x=80-f.width,b=await la(t,h.commit,s,x);if(b){let E=b.replace(/\n$/,"").split(`
447
+ `:"",stderr:"",exitCode:0}}})}async function ug(e,t){let n=new Set;for await(let r of jt(e,t))n.add(r.hash);return n}function Wl(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*mg(e,t,n,r,o){let s=new Set(r),i=new Wn,a=async c=>{if(!s.has(c))try{let f=await j(e,c);i.push({hash:c,commit:f})}catch{}};for(let c of t)await a(c);for(;i.size>0;){let c=i.pop();if(s.has(c.hash))continue;s.add(c.hash);let{commit:f}=c,l=o?f.parents.slice(0,1):f.parents;if(l.length===0){(await Ve(e,null,f.tree)).some(m=>Ee(n,m.path))&&(yield c);continue}if(l.length===1){let u=l[0];if(u){try{let m=await j(e,u);(await Ve(e,m.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 m=await j(e,u);(await Ve(e,m.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 hg(e){let t=await Q(e),n=t?.type==="symbolic"?Pe(t.target):null,r=await Y(e),o=new Map,s=(f,l,d)=>{let u=o.get(f);u||(u=[],o.set(f,u)),u.push({label:l,fullRef:d})},i=await pe(e,"refs/heads");for(let f of i)s(f.hash,Pe(f.name),f.name);let a=await pe(e,"refs/remotes");for(let f of a)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await pe(e,"refs/tags");for(let f of c){let l=f.hash;try{l=await ve(e,f.hash)}catch{}s(l,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function ql(e,t){let n=e.byHash.get(t),r=!e.headTarget&&e.headHash!==null&&e.headHash===t;if((!n||n.length===0)&&!r)return"";let o=[],s=e.headTarget&&n?n.find(a=>a.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let i=n?n.filter(a=>a!==s):[];i.sort((a,c)=>a.fullRef>c.fullRef?-1:a.fullRef<c.fullRef?1:0);for(let a of i)o.push(a.label);return o.length>0?`(${o.join(", ")})`:""}async function pg(e,t,n,r,o,s,i,a,c){let f=new Lo,l=r??"medium",d=l==="oneline",u=[];for(let m=0;m<e.length;m++){let h=e[m],p={hash:h.hash,commit:h.commit,decorations:i,decorationsRaw:a,dateMode:c},g;n!==null?g=xs(n,p):g=Cs(l,p,!0,o),f.update(h.hash,h.commit.parents),m>0&&!d&&n===null&&u.push(f.paddingPrefix());let w=g.split(`
448
+ `),y=0;for(;;){let{prefix:E,isCommitLine:R}=f.nextLine();if(R){u.push(E+(w[y++]??""));break}u.push(E)}for(;y<w.length;){let{prefix:E}=f.nextLine();u.push(E+w[y++])}for(;!f.isFinished();){let{prefix:E}=f.nextLine();u.push(E)}let x=80-f.width,b=await da(t,h.commit,s,x);if(b){let E=b.replace(/\n$/,"").split(`
449
449
  `);if(d||n!==null)for(let R of E)u.push(f.paddingPrefix()+R);else{u.push(f.paddingPrefix());for(let R of E)u.push(f.paddingPrefix()+R)}}}return{stdout:u.length>0?`${u.join(`
450
450
  `)}
451
- `:"",stderr:"",exitCode:0}}async function la(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await j(e,t.parents[0])).tree:null,s=await Ve(e,o,t.tree),{remaining:i,renames:a}=await it(e,s);switch(n){case"name-only":return hg(i,a);case"name-status":return pg(i,a);case"stat":return gg(e,i,a,r);case"shortstat":return wg(e,i,a);case"numstat":return bg(e,i,a);case"patch":return yg(e,i,a)}}function hg(e,t){let n=[];for(let r of e)n.push({key:r.path,line:r.path});for(let r of t)n.push({key:r.newPath,line:r.newPath});return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
452
- `).join("")}function pg(e,t){let n=[];for(let r of e){let o=r.status==="added"?"A":r.status==="deleted"?"D":"M";n.push({key:r.path,line:`${o} ${r.path}`})}for(let r of t){let o=String(r.similarity??100).padStart(3,"0");n.push({key:r.newPath,line:`R${o} ${r.oldPath} ${r.newPath}`})}return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
453
- `).join("")}async function gg(e,t,n,r){let{fileStats:o}=await Zn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),ur(o,r)}async function wg(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
454
- `:""}async function bg(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:dn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
451
+ `:"",stderr:"",exitCode:0}}async function da(e,t,n,r){if(!n||t.parents.length>=2)return"";let o=t.parents.length===1?(await j(e,t.parents[0])).tree:null,s=await Ve(e,o,t.tree),{remaining:i,renames:a}=await it(e,s);switch(n){case"name-only":return gg(i,a);case"name-status":return wg(i,a);case"stat":return bg(e,i,a,r);case"shortstat":return yg(e,i,a);case"numstat":return Eg(e,i,a);case"patch":return kg(e,i,a)}}function gg(e,t){let n=[];for(let r of e)n.push({key:r.path,line:r.path});for(let r of t)n.push({key:r.newPath,line:r.newPath});return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
452
+ `).join("")}function wg(e,t){let n=[];for(let r of e){let o=r.status==="added"?"A":r.status==="deleted"?"D":"M";n.push({key:r.path,line:`${o} ${r.path}`})}for(let r of t){let o=String(r.similarity??100).padStart(3,"0");n.push({key:r.newPath,line:`R${o} ${r.oldPath} ${r.newPath}`})}return n.sort((r,o)=>r.key<o.key?-1:r.key>o.key?1:0),n.map(r=>`${r.line}
453
+ `).join("")}async function bg(e,t,n,r){let{fileStats:o}=await Zn(e,t,n);return o.sort((s,i)=>s.sortKey<i.sortKey?-1:s.sortKey>i.sortKey?1:0),ur(o,r)}async function yg(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
454
+ `:""}async function Eg(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:dn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
455
455
  `;else{let c=Rt(i),f=Rt(a),l=ct(c,f),d=0,u=0;for(let m of l)m.type==="insert"?d++:m.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
456
- `}}return o}async function yg(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=It({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=It({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}oe();Ce();me();nr();tt();function Kl(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:$().alias("c").describe("Show cached files (default)"),modified:$().alias("m").describe("Show modified files"),deleted:$().alias("d").describe("Show deleted files"),others:$().alias("o").describe("Show other (untracked) files"),unmerged:$().alias("u").describe("Show unmerged files"),stage:$().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":$().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":$().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":$().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||u||m||(f=!0);let x=await z(i),b=g?"\0":`
457
- `,E=o.passthrough.length>0?o.passthrough.map(C=>{let P=r.cwd!==c?Eg(c,r.cwd):"";return Ue(C,P)}):null,R=[];if(f)for(let C of x.entries){if(E&&!Ee(E,C.path))continue;let P=w?C.stage>0?"M":"H":null;R.push(zl(C,h,P))}if(m&&!f)for(let C of x.entries)C.stage!==0&&(E&&!Ee(E,C.path)||R.push(zl(C,!0,w?"M":null)));if(l||d){let C=await kg(i,c,x);for(let{path:P,status:T}of C){if(T==="modified"&&!l||T==="deleted"&&!d||E&&!Ee(E,P))continue;let D=w?T==="deleted"?"R":"C":null;R.push(D?`${D} ${P}`:P)}}if(u){let C=await Rg(i,c,x,p);for(let P of C)E&&!Ee(E,P)||R.push(w?`? ${P}`:P)}return{stdout:R.length>0?R.join(b)+b:"",stderr:"",exitCode:0}}})}function zl(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 Eg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function kg(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 Nn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Rg(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))}oe();ar();qe();Ce();ae();ze();ge();sn();Ae();function Vl(e,t){e.command("merge",{description:"Join two or more development histories together",args:[q.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:$().describe("Abort the current in-progress merge"),continue:$().describe("Continue the merge after conflict resolution"),noFf:$().describe("Create a merge commit even when fast-forward is possible"),ffOnly:$().describe("Refuse to merge unless fast-forward is possible"),squash:$().describe("Apply merge result to worktree/index without creating a merge commit"),edit:$().describe("Edit the merge message (no-op, accepted for compatibility)"),message:V.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Og(s,r.env);if(n.continue)return $g(s,r.env,t);let i=n.branch;if(!i)return I("you must specify a branch to merge");let a=await Qe(s);if(M(a))return a;let c=await z(s),f=kn(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return I(`You have not concluded your merge (MERGE_HEAD exists).
456
+ `}}return o}async function kg(e,t,n){let r=[];for(let s of t)r.push({type:"diff",entry:s});for(let s of n)r.push({type:"rename",entry:s});r.sort((s,i)=>{let a=s.type==="diff"?s.entry.path:s.entry.newPath,c=i.type==="diff"?i.entry.path:i.entry.newPath;return a<c?-1:a>c?1:0});let o="";for(let s of r)if(s.type==="rename"){let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=It({path:i.oldPath,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,renameTo:i.newPath,similarity:i.similarity})}else{let i=s.entry,a=i.oldHash?await se(e,i.oldHash):"",c=i.newHash?await se(e,i.newHash):"";o+=It({path:i.path,oldContent:a,newContent:c,oldMode:i.oldMode,newMode:i.newMode,oldHash:i.oldHash,newHash:i.newHash,isNew:i.status==="added",isDeleted:i.status==="deleted"})}return o}oe();Ce();me();nr();tt();function Vl(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:$().alias("c").describe("Show cached files (default)"),modified:$().alias("m").describe("Show modified files"),deleted:$().alias("d").describe("Show deleted files"),others:$().alias("o").describe("Show other (untracked) files"),unmerged:$().alias("u").describe("Show unmerged files"),stage:$().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":$().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":$().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":$().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=Ye(i);if(a)return a;let c=i.workTree,f=n.cached,l=n.modified,d=n.deleted,u=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||l||d||u||m||(f=!0);let x=await z(i),b=g?"\0":`
457
+ `,E=o.passthrough.length>0?o.passthrough.map(C=>{let P=r.cwd!==c?Rg(c,r.cwd):"";return Ue(C,P)}):null,R=[];if(f)for(let C of x.entries){if(E&&!Ee(E,C.path))continue;let P=w?C.stage>0?"M":"H":null;R.push(Kl(C,h,P))}if(m&&!f)for(let C of x.entries)C.stage!==0&&(E&&!Ee(E,C.path)||R.push(Kl(C,!0,w?"M":null)));if(l||d){let C=await xg(i,c,x);for(let{path:P,status:T}of C){if(T==="modified"&&!l||T==="deleted"&&!d||E&&!Ee(E,P))continue;let D=w?T==="deleted"?"R":"C":null;R.push(D?`${D} ${P}`:P)}}if(u){let C=await Cg(i,c,x,p);for(let P of C)E&&!Ee(E,P)||R.push(w?`? ${P}`:P)}return{stdout:R.length>0?R.join(b)+b:"",stderr:"",exitCode:0}}})}function Kl(e,t,n){if(t){let r=e.mode.toString(8).padStart(6,"0");return`${n?`${n} `:""}${r} ${e.hash} ${e.stage} ${e.path}`}return n?`${n} ${e.path}`:e.path}function Rg(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function xg(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=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 Nn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Cg(e,t,n,r){let o=new Set(n.entries.map(i=>i.path));return(await ot(e,t,"",{skipIgnore:!r})).filter(i=>!o.has(i))}oe();ar();qe();Ce();ae();ze();ge();sn();Ae();function Yl(e,t){e.command("merge",{description:"Join two or more development histories together",args:[q.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:$().describe("Abort the current in-progress merge"),continue:$().describe("Continue the merge after conflict resolution"),noFf:$().describe("Create a merge commit even when fast-forward is possible"),ffOnly:$().describe("Refuse to merge unless fast-forward is possible"),squash:$().describe("Apply merge result to worktree/index without creating a merge commit"),edit:$().describe("Edit the merge message (no-op, accepted for compatibility)"),message:V.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Sg(s,r.env);if(n.continue)return Ig(s,r.env,t);let i=n.branch;if(!i)return I("you must specify a branch to merge");let a=await Qe(s);if(M(a))return a;let c=await z(s),f=kn(c,"Merging");if(f)return f;if(await B(s,"MERGE_HEAD"))return I(`You have not concluded your merge (MERGE_HEAD exists).
458
458
  Please, commit your changes before you merge.`);if(await B(s,"CHERRY_PICK_HEAD"))return I(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
459
459
  Please, commit your changes before you merge.`);let u=await Be(s,i);if(!u)return G(`merge: ${i} - not something we can merge
460
460
  `);let m=await ve(s,u),h=await Ft(s,a,m),p=h[0]??null;if(h.length===0)return I("refusing to merge unrelated histories");if(p===m)return await ye(s,"MERGE_MSG"),{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
@@ -468,9 +468,9 @@ hint: git rebase
468
468
  hint:
469
469
  hint: Disable this message with "git config set advice.diverging false"
470
470
  fatal: Not possible to fast-forward, aborting.
471
- `,128);if(await B(s,"REVERT_HEAD")&&await Lt(s),y&&!n.squash){let E=await Q(s),R=await xo(s,a,m);if(R.exitCode===0&&n.message&&(R.stdout=R.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),R.exitCode===0){await ye(s,"MERGE_MSG");let k=E?.type==="symbolic"?E.target:"HEAD";await ce(s,r.env,k,a,m,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,E?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:m,strategy:"fast-forward",commitHash:null})}return R}let x=n.message,b=x?x.endsWith(`
471
+ `,128);if(await B(s,"REVERT_HEAD")&&await Lt(s),y&&!n.squash){let E=await Q(s),R=await Co(s,a,m);if(R.exitCode===0&&n.message&&(R.stdout=R.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),R.exitCode===0){await ye(s,"MERGE_MSG");let k=E?.type==="symbolic"?E.target:"HEAD";await ce(s,r.env,k,a,m,`merge ${i}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,E?.type==="symbolic"),await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:m,strategy:"fast-forward",commitHash:null})}return R}let x=n.message,b=x?x.endsWith(`
472
472
  `)?x:`${x}
473
- `:void 0;return n.squash?Pg(s,a,m,i,r.env,t,b):xg(s,a,m,i,r.env,g,t,b)}})}async function xg(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},m=await ps(e,t,n,u),h=await $n(e,m,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!h.ok)return await ye(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await ce(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(m.conflicts.length>0){await Z(e,"MERGE_HEAD",n),await Z(e,"ORIG_HEAD",t);let T=a??await mr(e,r,l),D={repo:e,message:T,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(D);if(le(O))return{stdout:"",stderr:O.message??"",exitCode:1};T=D.message;let N=Bt({version:2,entries:m.entries}).sort();return T+=`
473
+ `:void 0;return n.squash?Og(s,a,m,i,r.env,t,b):Pg(s,a,m,i,r.env,g,t,b)}})}async function Pg(e,t,n,r,o,s=!1,i,a){let c=await j(e,t),f=await Q(e),l=f?.type==="symbolic"?Pe(f.target):"HEAD",d=await xe(e,"merge.conflictstyle")??"merge",u={a:"HEAD",b:r,conflictStyle:d},m=await gs(e,t,n,u),h=await $n(e,m,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!h.ok)return await ye(e,"MERGE_MSG"),h.failureKind==="staged"&&f?.type==="symbolic"&&await ce(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),h;if(m.conflicts.length>0){await Z(e,"MERGE_HEAD",n),await Z(e,"ORIG_HEAD",t);let T=a??await mr(e,r,l),D={repo:e,message:T,treeHash:h.mergedTreeHash,headHash:t,theirsHash:n},O=await i?.hooks?.mergeMsg?.(D);if(le(O))return{stdout:"",stderr:O.message??"",exitCode:1};T=D.message;let N=Bt({version:2,entries:m.entries}).sort();return T+=`
474
474
  # Conflicts:
475
475
  ${N.map(S=>`# ${S}`).join(`
476
476
  `)}
@@ -479,14 +479,14 @@ ${N.map(S=>`# ${S}`).join(`
479
479
  `,stderr:"",exitCode:1}}await ye(e,"MERGE_MSG");let p=h.mergedTreeHash,g=await ln(e,o);if(M(g))return g;let w=await nt(e,o);if(M(w))return w;let y=a??await mr(e,r,l),x={repo:e,message:y,treeHash:p,headHash:t,theirsHash:n},b=await i?.hooks?.mergeMsg?.(x);if(le(b))return{stdout:"",stderr:b.message??"",exitCode:1};y=x.message;let E=await i?.hooks?.preMergeCommit?.({repo:e,message:y,treeHash:p,headHash:t,theirsHash:n});if(le(E))return{stdout:"",stderr:E.message??"",exitCode:1};let R=await bt(e,p,[t,n],g,w,y),k=f?.type==="symbolic"?f.target:"HEAD";await ce(e,o,k,t,R,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await i?.hooks?.postMerge?.({repo:e,headHash:t,theirsHash:n,strategy:"three-way",commitHash:R});let C=await mn(e,c.tree,p);return{stdout:`${m.messages.length>0?`${m.messages.join(`
480
480
  `)}
481
481
  `:""}Merge made by the 'ort' strategy.
482
- ${C}`,stderr:"",exitCode:0}}async function Cg(e,t,n){let r=[];for await(let o of jt(e,n,{exclude:[t]})){if(o.commit.parents.length>1)continue;r.push(`commit ${o.hash}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Cn(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
482
+ ${C}`,stderr:"",exitCode:0}}async function $g(e,t,n){let r=[];for await(let o of jt(e,n,{exclude:[t]})){if(o.commit.parents.length>1)continue;r.push(`commit ${o.hash}`);let s=o.commit.author;r.push(`Author: ${s.name} <${s.email}>`),r.push(`Date: ${Cn(s.timestamp,s.timezone)}`),r.push("");for(let i of o.commit.message.replace(/\n+$/,"").split(`
483
483
  `))r.push(` ${i}`);r.push("")}return r.join(`
484
- `)}async function Pg(e,t,n,r,o,s,i){let a=await j(e,t),c=await Q(e),f=await xe(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await Ft(e,t,n),u=d.length>0&&d[0]===t,m=u?`Updating ${X(t)}..${X(n)}
485
- `:"",h=await ps(e,t,n,l),p=await $n(e,h,a.tree,{labels:l,errorExitCode:u?1:2,operationName:"merge",skipStagedChangeCheck:u});if(!p.ok){await ye(e,"MERGE_MSG"),!u&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ce(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=p;return m&&(E.stdout=m+E.stdout),E}let g;if(i?g=`Squashed commit of the following:
484
+ `)}async function Og(e,t,n,r,o,s,i){let a=await j(e,t),c=await Q(e),f=await xe(e,"merge.conflictstyle")??"merge",l={a:"HEAD",b:r,conflictStyle:f},d=await Ft(e,t,n),u=d.length>0&&d[0]===t,m=u?`Updating ${X(t)}..${X(n)}
485
+ `:"",h=await gs(e,t,n,l),p=await $n(e,h,a.tree,{labels:l,errorExitCode:u?1:2,operationName:"merge",skipStagedChangeCheck:u});if(!p.ok){await ye(e,"MERGE_MSG"),!u&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ce(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let E=p;return m&&(E.stdout=m+E.stdout),E}let g;if(i?g=`Squashed commit of the following:
486
486
 
487
487
  ${i}`:g=`Squashed commit of the following:
488
488
 
489
- ${await Cg(e,t,n)}`,await De(e,"SQUASH_MSG",g),h.conflicts.length>0){let R=`
489
+ ${await $g(e,t,n)}`,await De(e,"SQUASH_MSG",g),h.conflicts.length>0){let R=`
490
490
  # Conflicts:
491
491
  ${Bt({version:2,entries:h.entries}).sort().map(P=>`# ${P}`).join(`
492
492
  `)}
@@ -497,15 +497,15 @@ ${Bt({version:2,entries:h.entries}).sort().map(P=>`# ${P}`).join(`
497
497
  `:"";return{stdout:`${u?`${m}Fast-forward
498
498
  `:""}${x}Squash commit -- not updating HEAD
499
499
  ${u?y:""}`,stderr:u?"":`Automatic merge went well; stopped before committing as requested
500
- `,exitCode:0}}async function $g(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return I("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=kn(o,"Committing");if(s)return s;let i=await Qe(e);if(M(i))return i;let a=await j(e,i),c=await Oe(e,"MERGE_MSG");if(c)c=Xt(c);else{let C=await Q(e),P=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await mr(e,"unknown",P)}let f=Le(o),l=await Fe(e,f),d=await ln(e,t);if(M(d))return d;let u=await nt(e,t);if(M(u))return u;let m=Mt(c),h={repo:e,message:m,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(le(p))return{stdout:"",stderr:p.message??"",exitCode:1};m=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:m,treeHash:l,headHash:i,theirsHash:r});if(le(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await bt(e,l,[i,r],d,u,m);await as(e);let y=await Q(e),x=ue(m),b=y?.type==="symbolic"?y.target:"HEAD";await ce(e,t,b,i,w,`commit (merge): ${x}`,y?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let E=await mn(e,a.tree,l),R=y?.type==="symbolic"?Pe(y.target):"detached HEAD";return{stdout:`${Dt(R,w,c)}
501
- ${E}`,stderr:"",exitCode:0}}async function Og(e,t){return Bn(e,t,{operationRef:"MERGE_HEAD",noOpError:I("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:as})}oe();Ce();me();tt();function Yl(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[q.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:$().alias("f").describe("Force renaming even if target exists"),"dry-run":$().alias("n").describe("Do nothing; only show what would happen"),skip:$().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return G(`usage: git mv [<options>] <source>... <destination>
502
- `);let f=c[c.length-1],l=c.slice(0,-1),d=vt(r.cwd,f),u=st(a,d);if(u.startsWith(".."))return I(`'${f}' is outside repository at '${a}'`);let m=await z(s),h=await r.fs.exists(d),p=h&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return I(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let y=vt(r.cwd,w),x=st(a,y);if(x.startsWith("..")){if(n.skip)continue;return I(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(y)){if(n.skip)continue;return I(`bad source, source=${x}, destination=${u}`)}let R=(await r.fs.stat(y)).isDirectory;if(!(R?m.entries.some(O=>O.path===x||O.path.startsWith(`${x}/`)):m.entries.some(O=>O.path===x&&O.stage===0))){let O=!R&&m.entries.some(N=>N.path===x&&N.stage>0);if(n.skip)continue;return I(O?`conflicted, source=${x}, destination=${u}`:`not under version control, source=${x}, destination=${u}`)}let C,P;if(p){let O=Fr(x);C=u===""||u==="."?O:`${u}/${O}`,P=v(d,O)}else C=u,P=d;if(await r.fs.exists(P)&&!n.force)if((await r.fs.stat(P)).isDirectory){let N=Fr(x);C=`${C}/${N}`,P=v(P,N)}else{if(n.skip)continue;return I(`destination exists, source=${x}, destination=${C}`)}if(x===C){if(n.skip)continue;return I(`can not move directory into itself, source=${x}, destination=${C}`)}let D=Qt(P);if(!await r.fs.exists(D)){if(n.skip)continue;return I(`renaming '${x}' failed: No such file or directory`)}if(R){let O=`${x}/`,N=m.entries.filter(H=>H.path.startsWith(O)&&H.stage===0);for(let H of N){let S=H.path.slice(x.length),A=C+S,_=P+S;g.push({srcRel:H.path,dstRel:A,srcAbs:v(a,H.path),dstAbs:_})}}else g.push({srcRel:x,dstRel:C,srcAbs:y,dstAbs:P})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let y=Qt(w.dstAbs);await r.fs.exists(y)||await r.fs.mkdir(y,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=js(m,w.srcRel,0);if(b){m=lt(m,w.srcRel);let E={...b,path:w.dstRel};m=Ct(m,E)}}for(let w of g)await sr(r.fs,Qt(w.srcAbs),a);return await de(s,m),{stdout:"",stderr:"",exitCode:0}}})}oe();qe();Tn();Ce();ae();me();ht();ze();ge();oe();qe();Ce();ae();oe();ae();gn();er();Ae();async function da(e,t){let n=await be(e,t);if(n.type!=="commit")return null;let r=nn(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await be(e,r.parents[0]);f.type==="commit"&&(o=nn(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=An(),a=!1,c=[...s].sort((f,l)=>Ie(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let m=await be(e,f.oldHash);l=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await be(e,f.newHash);d=new TextDecoder().decode(m.content)}catch{}let u=It({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
500
+ `,exitCode:0}}async function Ig(e,t,n){let r=await B(e,"MERGE_HEAD");if(!r)return I("There is no merge in progress (MERGE_HEAD missing).");let o=await z(e),s=kn(o,"Committing");if(s)return s;let i=await Qe(e);if(M(i))return i;let a=await j(e,i),c=await Oe(e,"MERGE_MSG");if(c)c=Xt(c);else{let C=await Q(e),P=C?.type==="symbolic"?Pe(C.target):"HEAD";c=await mr(e,"unknown",P)}let f=Le(o),l=await Fe(e,f),d=await ln(e,t);if(M(d))return d;let u=await nt(e,t);if(M(u))return u;let m=Mt(c),h={repo:e,message:m,treeHash:l,headHash:i,theirsHash:r},p=await n?.hooks?.mergeMsg?.(h);if(le(p))return{stdout:"",stderr:p.message??"",exitCode:1};m=h.message;let g=await n?.hooks?.preMergeCommit?.({repo:e,message:m,treeHash:l,headHash:i,theirsHash:r});if(le(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=await bt(e,l,[i,r],d,u,m);await cs(e);let y=await Q(e),x=ue(m),b=y?.type==="symbolic"?y.target:"HEAD";await ce(e,t,b,i,w,`commit (merge): ${x}`,y?.type==="symbolic"),await n?.hooks?.postMerge?.({repo:e,headHash:i,theirsHash:r,strategy:"three-way",commitHash:w});let E=await mn(e,a.tree,l),R=y?.type==="symbolic"?Pe(y.target):"detached HEAD";return{stdout:`${Dt(R,w,c)}
501
+ ${E}`,stderr:"",exitCode:0}}async function Sg(e,t){return Bn(e,t,{operationRef:"MERGE_HEAD",noOpError:I("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:cs})}oe();Ce();me();tt();function Xl(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[q.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:$().alias("f").describe("Force renaming even if target exists"),"dry-run":$().alias("n").describe("Do nothing; only show what would happen"),skip:$().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.sources;if(c.length<2)return G(`usage: git mv [<options>] <source>... <destination>
502
+ `);let f=c[c.length-1],l=c.slice(0,-1),d=vt(r.cwd,f),u=st(a,d);if(u.startsWith(".."))return I(`'${f}' is outside repository at '${a}'`);let m=await z(s),h=await r.fs.exists(d),p=h&&(await r.fs.stat(d)).isDirectory;if(l.length>1&&!p)return I(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of l){let y=vt(r.cwd,w),x=st(a,y);if(x.startsWith("..")){if(n.skip)continue;return I(`'${w}' is outside repository at '${a}'`)}if(!await r.fs.exists(y)){if(n.skip)continue;return I(`bad source, source=${x}, destination=${u}`)}let R=(await r.fs.stat(y)).isDirectory;if(!(R?m.entries.some(O=>O.path===x||O.path.startsWith(`${x}/`)):m.entries.some(O=>O.path===x&&O.stage===0))){let O=!R&&m.entries.some(N=>N.path===x&&N.stage>0);if(n.skip)continue;return I(O?`conflicted, source=${x}, destination=${u}`:`not under version control, source=${x}, destination=${u}`)}let C,P;if(p){let O=Ur(x);C=u===""||u==="."?O:`${u}/${O}`,P=v(d,O)}else C=u,P=d;if(await r.fs.exists(P)&&!n.force)if((await r.fs.stat(P)).isDirectory){let N=Ur(x);C=`${C}/${N}`,P=v(P,N)}else{if(n.skip)continue;return I(`destination exists, source=${x}, destination=${C}`)}if(x===C){if(n.skip)continue;return I(`can not move directory into itself, source=${x}, destination=${C}`)}let D=Qt(P);if(!await r.fs.exists(D)){if(n.skip)continue;return I(`renaming '${x}' failed: No such file or directory`)}if(R){let O=`${x}/`,N=m.entries.filter(H=>H.path.startsWith(O)&&H.stage===0);for(let H of N){let S=H.path.slice(x.length),A=C+S,_=P+S;g.push({srcRel:H.path,dstRel:A,srcAbs:v(a,H.path),dstAbs:_})}}else g.push({srcRel:x,dstRel:C,srcAbs:y,dstAbs:P})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let y=Qt(w.dstAbs);await r.fs.exists(y)||await r.fs.mkdir(y,{recursive:!0});let x=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,x),await r.fs.rm(w.srcAbs);let b=Gs(m,w.srcRel,0);if(b){m=lt(m,w.srcRel);let E={...b,path:w.dstRel};m=Ct(m,E)}}for(let w of g)await sr(r.fs,Qt(w.srcAbs),a);return await de(s,m),{stdout:"",stderr:"",exitCode:0}}})}oe();qe();Tn();Ce();ae();me();ht();ze();ge();oe();qe();Ce();ae();oe();ae();gn();er();Ae();async function ua(e,t){let n=await be(e,t);if(n.type!=="commit")return null;let r=nn(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await be(e,r.parents[0]);f.type==="commit"&&(o=nn(f.content).tree)}let s=await Ve(e,o,r.tree);if(s.length===0)return null;let i=An(),a=!1,c=[...s].sort((f,l)=>Ie(f.path,l.path));for(let f of c){let l="",d="";if(f.oldHash)try{let m=await be(e,f.oldHash);l=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await be(e,f.newHash);d=new TextDecoder().decode(m.content)}catch{}let u=It({path:f.path,oldContent:l,newContent:d,oldMode:f.oldMode,newMode:f.newMode});if(u)for(let m of u.split(`
503
503
  `)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(i.update(p),i.update(`
504
- `),a=!0)}}return a?i.hex():null}ze();ge();Ae();fn();tt();async function Ig(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function Xl(e){return e==="HEAD"?`HEAD is up to date.
504
+ `),a=!0)}}return a?i.hex():null}ze();ge();Ae();fn();tt();async function Tg(e){let t=await Q(e);return t?.type==="symbolic"?Pe(t.target):"detached HEAD"}function Zl(e){return e==="HEAD"?`HEAD is up to date.
505
505
  `:`Current branch ${e} is up to date.
506
- `}async function Sg(e,t,n){if(!e.workTree)return null;let r=await fe(e,t),o=new Map(Le(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=Qs(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return G(`${a.stderr}error: could not detach HEAD
507
- `)}return null}async function Tg(e,t,n,r){if(!e.workTree)return null;let o=await fe(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:`${Qs(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
508
- `,exitCode:128}:null}async function Zl(e,t,n){if(!e.workTree)return null;let r=new Map(Le(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 Jl(e,t){return`error: The following untracked working tree files would be overwritten by merge:
506
+ `}async function vg(e,t,n){if(!e.workTree)return null;let r=await fe(e,t),o=new Map(Le(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=eo(i,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return G(`${a.stderr}error: could not detach HEAD
507
+ `)}return null}async function Ag(e,t,n,r){if(!e.workTree)return null;let o=await fe(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:`${eo(a,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
508
+ `,exitCode:128}:null}async function Jl(e,t,n){if(!e.workTree)return null;let r=new Map(Le(t).map(i=>[i.path,i])),o=new Set(await ot(e,e.workTree,"")),s=[];for(let[i]of n)!r.has(i)&&o.has(i)&&s.push(i);return s.length>0?s:null}function Ql(e,t){return`error: The following untracked working tree files would be overwritten by merge:
509
509
  ${e.map(r=>` ${r}`).join(`
510
510
  `)}
511
511
  Please move or remove them before you merge.
@@ -519,20 +519,20 @@ hint: edit the todo list first:
519
519
  hint:
520
520
  hint: git rebase --edit-todo
521
521
  hint: git rebase --continue
522
- `}async function ua(e,t,n,r,o,s){await ce(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ce(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ce(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function _o(e,t,n,r){let o=await j(e,t),s=await Sg(e,o.tree,n);if(s)return s;let i=await En(e,o.tree,n);return i.success&&(await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps)),r!=="detached HEAD"?await Z(e,r,t):await Z(e,"HEAD",t),null}async function ma(e,t,n,r,o,s,i,a){let c=r.startsWith("refs/heads/")?Pe(r):"HEAD",f=await z(e),l=Bt(f).sort();if(l.length>0)return{stdout:l.map(O=>`${O}: needs merge
522
+ `}async function ma(e,t,n,r,o,s){await ce(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ce(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ce(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Uo(e,t,n,r){let o=await j(e,t),s=await vg(e,o.tree,n);if(s)return s;let i=await En(e,o.tree,n);return i.success&&(await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps)),r!=="detached HEAD"?await Z(e,r,t):await Z(e,"HEAD",t),null}async function ha(e,t,n,r,o,s,i,a){let c=r.startsWith("refs/heads/")?Pe(r):"HEAD",f=await z(e),l=Bt(f).sort();if(l.length>0)return{stdout:l.map(O=>`${O}: needs merge
523
523
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
524
524
  error: additionally, your index contains uncommitted changes.
525
525
  error: Please commit or stash them.
526
526
  `,exitCode:1};let d=await j(e,n),u=await fe(e,d.tree);if(e.workTree){let O=Un(f,u),H=(await gt(e,f)).some(S=>S.status==="modified"||S.status==="deleted");if(O||H){let S=[];return H&&S.push("error: cannot rebase: You have unstaged changes."),O&&(H?S.push("error: additionally, your index contains uncommitted changes."):S.push("error: cannot rebase: Your index contains uncommitted changes.")),S.push("error: Please commit or stash them."),G(`${S.join(`
527
527
  `)}
528
- `)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(le(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await af(e,o,n),p=h.right;if(p.length===0){if(s!==n){let O=await _o(e,s,f,r);return O||(await ua(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
529
- `,exitCode:0})}return{stdout:Xl(c),stderr:"",exitCode:0}}let g=[],w=h.left,y=new Set;for(let O of w){let N=await da(e,O.hash);N&&y.add(N)}let x=[];if(y.size>0)for(let O of p){let N=await da(e,O.hash);N&&y.has(N)?g.push(`warning: skipped previously applied commit ${X(O.hash)}`):x.push(O)}else x.push(...p);let b="";if(g.length>0&&(b=`${g.join(`
528
+ `)}}let m=await a?.hooks?.preRebase?.({repo:e,upstream:i,branch:r!=="detached HEAD"?c:null});if(le(m))return{stdout:"",stderr:m.message??"",exitCode:1};let h=await cf(e,o,n),p=h.right;if(p.length===0){if(s!==n){let O=await Uo(e,s,f,r);return O||(await ma(e,t,n,s,r,i),{stdout:"",stderr:`Successfully rebased and updated ${r}.
529
+ `,exitCode:0})}return{stdout:Zl(c),stderr:"",exitCode:0}}let g=[],w=h.left,y=new Set;for(let O of w){let N=await ua(e,O.hash);N&&y.add(N)}let x=[];if(y.size>0)for(let O of p){let N=await ua(e,O.hash);N&&y.has(N)?g.push(`warning: skipped previously applied commit ${X(O.hash)}`):x.push(O)}else x.push(...p);let b="";if(g.length>0&&(b=`${g.join(`
530
530
  `)}
531
531
  hint: use --reapply-cherry-picks to include skipped commits
532
532
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
533
- `),x.length===0){if(s!==n){let O=await _o(e,s,f,r);if(O)return O.stderr=b+O.stderr,O;await ua(e,t,n,s,r,i)}return{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
534
- `,exitCode:0}}let E=x.map(O=>({hash:O.hash,subject:ue(O.commit.message)})),R=s,k=0;for(let O of E){let N=await j(e,O.hash);if(N.parents.length>1||N.parents.length===0||N.parents[0]!==R)break;R=O.hash,k++}let C=E.splice(0,k);if(E.length===0){if(R===n)return{stdout:Xl(c),stderr:b,exitCode:0};let O=await _o(e,R,f,r);return O?(O.stderr=b+O.stderr,O):(await ua(e,t,n,R,r,i),{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
535
- `,exitCode:0})}let P=await _o(e,R,f,"detached HEAD");if(P)return P.stderr=b+P.stderr,P;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ce(e,t,"HEAD",n,R,`rebase (start): checkout ${i}`);let T={headName:r,origHead:n,onto:s,todo:E,done:C,msgnum:k,end:k+E.length};await Di(e,T),await Z(e,"ORIG_HEAD",n);let D=await ha(e,t);return b&&(D.stderr=b+D.stderr),D}function Ql(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[q.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:V.string().describe("Starting point at which to create new commits"),abort:$().describe("Abort the current rebase operation"),continue:$().describe("Continue the rebase after conflict resolution"),skip:$().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Hg(s,r.env);if(n.continue)return Dg(s,r.env);if(n.skip)return Mg(s,r.env);let i=n.upstream;if(!i)return I("no upstream configured and no upstream argument given");if(await Nt(s))return I(`It seems that there is already a rebase-merge directory, and
533
+ `),x.length===0){if(s!==n){let O=await Uo(e,s,f,r);if(O)return O.stderr=b+O.stderr,O;await ma(e,t,n,s,r,i)}return{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
534
+ `,exitCode:0}}let E=x.map(O=>({hash:O.hash,subject:ue(O.commit.message)})),R=s,k=0;for(let O of E){let N=await j(e,O.hash);if(N.parents.length>1||N.parents.length===0||N.parents[0]!==R)break;R=O.hash,k++}let C=E.splice(0,k);if(E.length===0){if(R===n)return{stdout:Zl(c),stderr:b,exitCode:0};let O=await Uo(e,R,f,r);return O?(O.stderr=b+O.stderr,O):(await ma(e,t,n,R,r,i),{stdout:"",stderr:`${b}Successfully rebased and updated ${r}.
535
+ `,exitCode:0})}let P=await Uo(e,R,f,"detached HEAD");if(P)return P.stderr=b+P.stderr,P;await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ce(e,t,"HEAD",n,R,`rebase (start): checkout ${i}`);let T={headName:r,origHead:n,onto:s,todo:E,done:C,msgnum:k,end:k+E.length};await ji(e,T),await Z(e,"ORIG_HEAD",n);let D=await pa(e,t);return b&&(D.stderr=b+D.stderr),D}function ed(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[q.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:V.string().describe("Starting point at which to create new commits"),abort:$().describe("Abort the current rebase operation"),continue:$().describe("Continue the rebase after conflict resolution"),skip:$().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort)return Mg(s,r.env);if(n.continue)return jg(s,r.env);if(n.skip)return Gg(s,r.env);let i=n.upstream;if(!i)return I("no upstream configured and no upstream argument given");if(await Nt(s))return I(`It seems that there is already a rebase-merge directory, and
536
536
  I wonder if you are in the middle of another rebase. If that is the
537
537
  case, please try
538
538
  git rebase (--continue | --abort | --skip)
@@ -540,9 +540,9 @@ If that is not the case, please
540
540
  rm -fr ".git/rebase-merge"
541
541
  and run me again. I am stopping in case you still have something
542
542
  valuable there.
543
- `);let a=await Qe(s);if(M(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Me(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,u,m=n.onto;if(m){let h=await Me(s,m,`Does not point to a valid commit: '${m}'`);if(M(h))return h;u=h.hash}else u=d;return ma(s,r.env,a,f,d,u,i,t)}})}async function ha(e,t){let n=[],r=[];for(;;){let o=await Et(e);if(!o||o.todo.length===0)break;let s=o.todo[0];if(!s)break;n.push(`Rebasing (${o.msgnum+1}/${o.end})\r`),await of(e);let i=await vg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await Et(e);a&&(a.todo=[s,...a.todo],await Di(e,a))}return i.stdout&&r.push(i.stdout),n.push(i.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}i.stdout&&r.push(i.stdout),i.stderr&&n.push(i.stderr)}return Ag(e,n,t)}async function vg(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await j(e,s):null,a=await Y(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
543
+ `);let a=await Qe(s);if(M(a))return a;let c=await Q(s),f=c?.type==="symbolic"?c.target:"detached HEAD",l=await Me(s,i,`invalid upstream '${i}'`);if(M(l))return l;let d=l.hash,u,m=n.onto;if(m){let h=await Me(s,m,`Does not point to a valid commit: '${m}'`);if(M(h))return h;u=h.hash}else u=d;return ha(s,r.env,a,f,d,u,i,t)}})}async function pa(e,t){let n=[],r=[];for(;;){let o=await Et(e);if(!o||o.todo.length===0)break;let s=o.todo[0];if(!s)break;n.push(`Rebasing (${o.msgnum+1}/${o.end})\r`),await af(e);let i=await Hg(e,s,t);if(i.conflict){if(i.rescheduleCurrent){let a=await Et(e);a&&(a.todo=[s,...a.todo],await ji(e,a))}return i.stdout&&r.push(i.stdout),n.push(i.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}i.stdout&&r.push(i.stdout),i.stderr&&n.push(i.stderr)}return Dg(e,n,t)}async function Hg(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,i=s?await j(e,s):null,a=await Y(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
544
544
  `};if(s&&s===a){let H=await z(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
545
- `};let S=await Ke(e,i.tree),A=await Ke(e,o.tree),_=new Map(S.map(K=>[K.path,K.hash])),F=new Map;for(let K of A){let te=_.get(K.path);(!te||te!==K.hash)&&F.set(K.path,K.hash)}let U=await Zl(e,H,F);if(U)return await Z(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Jl(U,t),rescheduleCurrent:!0};let L=await En(e,o.tree,H);return L.success&&(await de(e,{version:2,entries:L.newEntries}),await Ne(e,L.worktreeOps)),await jn(e,r),await ce(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await j(e,a),f=i?i.tree:null,l=X(r),d=ue(o.message),u=await xe(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:u},h=await Ut(e,f,c.tree,o.tree,m),p=await z(e),[g,w,y]=await Promise.all([Ke(e,c.tree),f?Ke(e,f):Promise.resolve([]),Ke(e,o.tree)]),x=new Set;for(let H of w)x.add(H.path);for(let H of g)x.add(H.path);for(let H of y)x.add(H.path);let b=p.entries.filter(H=>!x.has(H.path)),E=[...h.entries,...b];E.sort((H,S)=>Ie(H.path,S.path)||H.stage-S.stage);let R={version:2,entries:E},k=E.filter(H=>H.stage===0),C=await Fe(e,k),P=new Map(g.map(H=>[H.path,H])),T=new Map;for(let H of k){let S=P.get(H.path);(!S||S.hash!==H.hash)&&T.set(H.path,H.hash)}for(let H of h.conflicts){if(H.reason==="content"||H.reason==="add-add"){T.set(H.path,null);continue}if(H.reason==="delete-modify"){let S=h.entries.filter(F=>F.path===H.path&&F.stage>0),A=S.find(F=>F.stage===2),_=S.find(F=>F.stage===3);_&&!A&&T.set(H.path,_.hash)}}let D=await Zl(e,p,T);if(D)return await Z(e,"REBASE_HEAD",r),await co(e,r,o.author),{conflict:!0,stdout:"",stderr:Jl(D,t),rescheduleCurrent:!0};if(await de(e,R),e.workTree){let H=await Fn(e,c.tree,h.resultTree,p);H.success&&await Ne(e,H.worktreeOps)}if(h.conflicts.length>0){await Z(e,"REBASE_HEAD",r),await co(e,r,o.author),await De(e,"MERGE_MSG",o.message),await De(e,"rebase-merge/message",o.message);let H=h.messages.join(`
545
+ `};let S=await Ke(e,i.tree),A=await Ke(e,o.tree),_=new Map(S.map(K=>[K.path,K.hash])),F=new Map;for(let K of A){let te=_.get(K.path);(!te||te!==K.hash)&&F.set(K.path,K.hash)}let U=await Jl(e,H,F);if(U)return await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),{conflict:!0,stdout:"",stderr:Ql(U,t),rescheduleCurrent:!0};let L=await En(e,o.tree,H);return L.success&&(await de(e,{version:2,entries:L.newEntries}),await Ne(e,L.worktreeOps)),await jn(e,r),await ce(e,n,"HEAD",a,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await j(e,a),f=i?i.tree:null,l=X(r),d=ue(o.message),u=await xe(e,"merge.conflictstyle")??"merge",m={a:"HEAD",b:d?`${l} (${d})`:l,conflictStyle:u},h=await Ut(e,f,c.tree,o.tree,m),p=await z(e),[g,w,y]=await Promise.all([Ke(e,c.tree),f?Ke(e,f):Promise.resolve([]),Ke(e,o.tree)]),x=new Set;for(let H of w)x.add(H.path);for(let H of g)x.add(H.path);for(let H of y)x.add(H.path);let b=p.entries.filter(H=>!x.has(H.path)),E=[...h.entries,...b];E.sort((H,S)=>Ie(H.path,S.path)||H.stage-S.stage);let R={version:2,entries:E},k=E.filter(H=>H.stage===0),C=await Fe(e,k),P=new Map(g.map(H=>[H.path,H])),T=new Map;for(let H of k){let S=P.get(H.path);(!S||S.hash!==H.hash)&&T.set(H.path,H.hash)}for(let H of h.conflicts){if(H.reason==="content"||H.reason==="add-add"){T.set(H.path,null);continue}if(H.reason==="delete-modify"){let S=h.entries.filter(F=>F.path===H.path&&F.stage>0),A=S.find(F=>F.stage===2),_=S.find(F=>F.stage===3);_&&!A&&T.set(H.path,_.hash)}}let D=await Jl(e,p,T);if(D)return await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),{conflict:!0,stdout:"",stderr:Ql(D,t),rescheduleCurrent:!0};if(await de(e,R),e.workTree){let H=await Fn(e,c.tree,h.resultTree,p);H.success&&await Ne(e,H.worktreeOps)}if(h.conflicts.length>0){await Z(e,"REBASE_HEAD",r),await fo(e,r,o.author),await De(e,"MERGE_MSG",o.message),await De(e,"rebase-merge/message",o.message);let H=h.messages.join(`
546
546
  `);return{conflict:!0,stdout:H?`${H}
547
547
  `:"",stderr:`error: could not apply ${l}... ${t.subject}
548
548
  hint: Resolve all conflicts manually, mark them as resolved with
@@ -552,8 +552,8 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
552
552
  hint: Disable this message with "git config set advice.mergeConflict false"
553
553
  Could not apply ${l}... # ${t.subject}
554
554
  `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
555
- `};let O=await nt(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let N=await bt(e,C,[a],o.author,O,o.message);return await ce(e,n,"HEAD",a,N,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Ag(e,t,n){let r=await Et(e);if(!r)return I("no rebase in progress");let o=await Y(e);if(!o)return I("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Z(e,r.headName,o),await Xe(e,"HEAD",r.headName),await yt(e),await ce(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ce(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
556
- `;return await he(e,"REBASE_HEAD"),await cr(e),await Mi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Hg(e,t){let n=await Et(e);if(!n)return I("no rebase in progress");let r=await Y(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await Tg(e,s.tree,i,o);if(a)return a;let c=await En(e,s.tree,i);c.success&&(await de(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Z(e,n.headName,o),await Xe(e,"HEAD",n.headName),await yt(e)):await jn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ce(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await he(e,"REBASE_HEAD"),await cr(e),await Mi(e),{stdout:"",stderr:"",exitCode:0}}async function Dg(e,t){let n="";if(!await Et(e))return I("no rebase in progress");let o=await z(e);if(Ht(o))return G(`error: Committing is not possible because you have unmerged files.
555
+ `};let O=await nt(e,n);if(M(O))return{conflict:!0,stdout:"",stderr:O.stderr};let N=await bt(e,C,[a],o.author,O,o.message);return await ce(e,n,"HEAD",a,N,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Dg(e,t,n){let r=await Et(e);if(!r)return I("no rebase in progress");let o=await Y(e);if(!o)return I("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Z(e,r.headName,o),await Xe(e,"HEAD",r.headName),await yt(e),await ce(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ce(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let i=`Successfully rebased and updated ${r.headName}.
556
+ `;return await he(e,"REBASE_HEAD"),await cr(e),await Gi(e),{stdout:"",stderr:t.join("")+i,exitCode:0}}async function Mg(e,t){let n=await Et(e);if(!n)return I("no rebase in progress");let r=await Y(e),o=n.origHead,s=await j(e,o),i=await z(e),a=await Ag(e,s.tree,i,o);if(a)return a;let c=await En(e,s.tree,i);c.success&&(await de(e,{version:2,entries:c.newEntries}),await Ne(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Z(e,n.headName,o),await Xe(e,"HEAD",n.headName),await yt(e)):await jn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ce(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await he(e,"REBASE_HEAD"),await cr(e),await Gi(e),{stdout:"",stderr:"",exitCode:0}}async function jg(e,t){let n="";if(!await Et(e))return I("no rebase in progress");let o=await z(e);if(Ht(o))return G(`error: Committing is not possible because you have unmerged files.
557
557
  hint: Fix them up in the work tree, and then use 'git add <file>'
558
558
  hint: as appropriate to mark resolution and make a commit.
559
559
  fatal: Exiting because of an unresolved conflict.
@@ -570,33 +570,33 @@ In both cases, once you're done, continue with:
570
570
 
571
571
  git rebase --continue
572
572
 
573
- `);if(d){let m=await j(e,s),h=await B(e,"CHERRY_PICK_HEAD"),p=h?await j(e,h):m,g;g=await Oe(e,"rebase-merge/message")??await Oe(e,"MERGE_MSG")??void 0,g&&(g=Xt(g)),g||(g=m.message);let w=await nt(e,t);if(M(w))return w;let y=Mt(g),x=[a],b=await B(e,"MERGE_HEAD");b&&x.push(b);let E=await bt(e,l,x,p.author,w,y);b&&(await he(e,"MERGE_HEAD"),await ye(e,"MERGE_MODE"));let R=ue(y);await ce(e,t,"HEAD",a,E,`rebase (continue): ${R}`);let k=await Ig(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,P=await un(e,c.tree,l,p.author,w,C);n=`${Dt(k,E,y)}
574
- ${P}`}await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"rebase-merge/message")}let i=await ha(e,t);return n&&(i.stdout=n+i.stdout),i}async function Mg(e,t){if(!await Et(e))return I("no rebase in progress");let r=await Y(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
573
+ `);if(d){let m=await j(e,s),h=await B(e,"CHERRY_PICK_HEAD"),p=h?await j(e,h):m,g;g=await Oe(e,"rebase-merge/message")??await Oe(e,"MERGE_MSG")??void 0,g&&(g=Xt(g)),g||(g=m.message);let w=await nt(e,t);if(M(w))return w;let y=Mt(g),x=[a],b=await B(e,"MERGE_HEAD");b&&x.push(b);let E=await bt(e,l,x,p.author,w,y);b&&(await he(e,"MERGE_HEAD"),await ye(e,"MERGE_MODE"));let R=ue(y);await ce(e,t,"HEAD",a,E,`rebase (continue): ${R}`);let k=await Tg(e),C=p.author.timestamp!==w.timestamp||p.author.timezone!==w.timezone,P=await un(e,c.tree,l,p.author,w,C);n=`${Dt(k,E,y)}
574
+ ${P}`}await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"rebase-merge/message")}let i=await pa(e,t);return n&&(i.stdout=n+i.stdout),i}async function Gg(e,t){if(!await Et(e))return I("no rebase in progress");let r=await Y(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
575
575
  fatal: could not discard worktree changes
576
- `,exitCode:128};let o=await j(e,r),s=await z(e),i=await En(e,o.tree,s);return i.success&&(await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps)),await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await he(e,"MERGE_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"rebase-merge/message"),ha(e,t)}function ed(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[q.string().name("remote").describe("Remote to pull from").optional(),q.string().name("branch").describe("Remote branch").optional()],options:{rebase:$().alias("r").describe("Rebase instead of merge"),noRebase:$().describe("Merge instead of rebase"),ffOnly:$().describe("Only fast-forward"),noFf:$().describe("Create a merge commit even for fast-forwards"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await Po(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=gs);let a=await Qe(s);if(M(a))return a;let c=await z(s);if(Ht(c))return G(`error: Pulling is not possible because you have unmerged files.
577
- `,128);let f=n.remote,l=n.branch;if(!f){let re=await Q(s);if(re?.type==="symbolic"){let Ge=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,Jt=(await we(s))[`branch "${Ge}"`];Jt&&(f=Jt.remote||"origin",!l&&Jt.merge&&(l=Jt.merge.startsWith("refs/heads/")?Jt.merge.slice(11):Jt.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let re=await Q(s);if(re?.type==="symbolic"){let Ge=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,pn=await xe(s,`branch.${Ge}.rebase`);(pn==="true"||pn!=="false"&&await xe(s,"pull.rebase")==="true")&&(d=!0)}else await xe(s,"pull.rebase")==="true"&&(d=!0)}let u;try{u=await jr(s,f,r.env)}catch(re){let Ge=re instanceof Error?re.message:"";if(Ge.startsWith("network"))return I(Ge);throw re}if(!u)return I(`'${f}' does not appear to be a git repository`);let{transport:m,config:h}=u,p=l??null,g=await t?.hooks?.prePull?.({repo:s,remote:f,branch:p});if(le(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=gr(h.fetchRefspec),y=await m.advertiseRefs();if(y.length===0)return I("Couldn't find remote ref HEAD");let b=(await pe(s)).map(re=>re.hash),E=await B(s,"HEAD");E&&b.push(E);let R=[],k=new Set,C=[];for(let re of y){if(re.name==="HEAD")continue;let Ge=ks(w,re.name);Ge!==null&&(C.push({remote:re,localRef:Ge}),k.has(re.hash)||(k.add(re.hash),R.push(re.hash)))}let P=new Set(b),T=R.filter(re=>!P.has(re)),D,O=i!==void 0?await vr(s):void 0;i!==void 0&&(D={depth:i,existingShallows:O});let N=T.length>0?T:D?R:[];if(N.length>0){let re=await m.fetch(N,b,D);re.shallowUpdates&&await Ar(s,re.shallowUpdates,O)}let H=await en(s,r.env);for(let re of C){let Ge=await B(s,re.localRef);await Z(s,re.localRef,re.remote.hash),await Ze(s,re.localRef,{oldHash:Ge??ee,newHash:re.remote.hash,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:Ge?"pull":"pull: storing head"})}let S=null;if(l){let re=y.find(Ge=>Ge.name===`refs/heads/${l}`);if(re)S=re.hash;else return I(`Couldn't find remote ref refs/heads/${l}`)}else{let re=y.find(Ge=>Ge.name==="HEAD");re&&(S=re.hash)}if(S&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${S} ${h.url}
576
+ `,exitCode:128};let o=await j(e,r),s=await z(e),i=await En(e,o.tree,s);return i.success&&(await de(e,{version:2,entries:i.newEntries}),await Ne(e,i.worktreeOps)),await he(e,"REBASE_HEAD"),await he(e,"CHERRY_PICK_HEAD"),await he(e,"REVERT_HEAD"),await he(e,"MERGE_HEAD"),await ye(e,"MERGE_MSG"),await ye(e,"MERGE_MODE"),await ye(e,"rebase-merge/message"),pa(e,t)}function td(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[q.string().name("remote").describe("Remote to pull from").optional(),q.string().name("branch").describe("Remote branch").optional()],options:{rebase:$().alias("r").describe("Rebase instead of merge"),noRebase:$().describe("Merge instead of rebase"),ffOnly:$().describe("Only fast-forward"),noFf:$().describe("Create a merge commit even for fast-forwards"),depth:V.number().describe("Limit fetching to the specified number of commits"),unshallow:$().describe("Convert a shallow repository to a complete one")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.depth!==void 0&&n.unshallow)return I("--depth and --unshallow cannot be used together");if(n.unshallow&&!await $o(s))return I("--unshallow on a complete repository does not make sense");let i=n.depth;n.unshallow&&(i=ws);let a=await Qe(s);if(M(a))return a;let c=await z(s);if(Ht(c))return G(`error: Pulling is not possible because you have unmerged files.
577
+ `,128);let f=n.remote,l=n.branch;if(!f){let re=await Q(s);if(re?.type==="symbolic"){let Ge=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,Jt=(await we(s))[`branch "${Ge}"`];Jt&&(f=Jt.remote||"origin",!l&&Jt.merge&&(l=Jt.merge.startsWith("refs/heads/")?Jt.merge.slice(11):Jt.merge))}}f=f||"origin";let d=!1;if(n.rebase)d=!0;else if(!n.noRebase){let re=await Q(s);if(re?.type==="symbolic"){let Ge=re.target.startsWith("refs/heads/")?re.target.slice(11):re.target,pn=await xe(s,`branch.${Ge}.rebase`);(pn==="true"||pn!=="false"&&await xe(s,"pull.rebase")==="true")&&(d=!0)}else await xe(s,"pull.rebase")==="true"&&(d=!0)}let u;try{u=await Gr(s,f,r.env)}catch(re){let Ge=re instanceof Error?re.message:"";if(Ge.startsWith("network"))return I(Ge);throw re}if(!u)return I(`'${f}' does not appear to be a git repository`);let{transport:m,config:h}=u,p=l??null,g=await t?.hooks?.prePull?.({repo:s,remote:f,branch:p});if(le(g))return{stdout:"",stderr:g.message??"",exitCode:1};let w=wr(h.fetchRefspec),y=await m.advertiseRefs();if(y.length===0)return I("Couldn't find remote ref HEAD");let b=(await pe(s)).map(re=>re.hash),E=await B(s,"HEAD");E&&b.push(E);let R=[],k=new Set,C=[];for(let re of y){if(re.name==="HEAD")continue;let Ge=Rs(w,re.name);Ge!==null&&(C.push({remote:re,localRef:Ge}),k.has(re.hash)||(k.add(re.hash),R.push(re.hash)))}let P=new Set(b),T=R.filter(re=>!P.has(re)),D,O=i!==void 0?await Ar(s):void 0;i!==void 0&&(D={depth:i,existingShallows:O});let N=T.length>0?T:D?R:[];if(N.length>0){let re=await m.fetch(N,b,D);re.shallowUpdates&&await Hr(s,re.shallowUpdates,O)}let H=await en(s,r.env);for(let re of C){let Ge=await B(s,re.localRef);await Z(s,re.localRef,re.remote.hash),await Ze(s,re.localRef,{oldHash:Ge??ee,newHash:re.remote.hash,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:Ge?"pull":"pull: storing head"})}let S=null;if(l){let re=y.find(Ge=>Ge.name===`refs/heads/${l}`);if(re)S=re.hash;else return I(`Couldn't find remote ref refs/heads/${l}`)}else{let re=y.find(Ge=>Ge.name==="HEAD");re&&(S=re.hash)}if(S&&await r.fs.writeFile(v(s.gitDir,"FETCH_HEAD"),`${S} ${h.url}
578
578
  `),!S)return I("Could not determine remote HEAD");let A=S;if(a===A)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
579
- `,stderr:"",exitCode:0};if(d){let re=await Q(s),Ge=re?.type==="symbolic"?re.target:"detached HEAD",pn=l?`${f}/${l}`:f,Jt=await ma(s,r.env,a,Ge,A,A,pn,t);if(Jt.exitCode===0){let Td=await Y(s);await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:Td})}return Jt}let _=await Ft(s,a,A),F=_[0]??null;if(_.length===0)return I("refusing to merge unrelated histories");if(F===A)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
580
- `,stderr:"",exitCode:0};let U=!!n.noFf,L=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let re=await xe(s,"pull.ff");re==="false"?U=!0:re==="only"&&(L=!0)}let K=F===a;if(L&&!K)return I("Not possible to fast-forward, aborting.");if(K&&!U){let re=await xo(s,a,A),Ge=await Q(s),pn=Ge?.type==="symbolic"?Ge.target:"HEAD";return await Ze(s,pn,{oldHash:a,newHash:A,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:"pull: Fast-forward"}),Ge?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:A,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:"pull: Fast-forward"}),re.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:A,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:A})),re}let te=await Q(s),J=te?.type==="symbolic"?Pe(te.target):"HEAD",ne=l||f||"FETCH_HEAD",ke=await xe(s,"merge.conflictstyle")??"merge",je={a:"HEAD",b:ne,conflictStyle:ke},ie=await ps(s,a,A,je),$e=await j(s,a),rt=await $n(s,ie,$e.tree,{labels:je,errorExitCode:2,operationName:"merge"});if(!rt.ok)return rt;if(ie.conflicts.length>0){await Z(s,"MERGE_HEAD",A),await Z(s,"ORIG_HEAD",a);let re=await mr(s,ne,J),Ge=Bt({version:2,entries:ie.entries}).sort();return re+=`
579
+ `,stderr:"",exitCode:0};if(d){let re=await Q(s),Ge=re?.type==="symbolic"?re.target:"detached HEAD",pn=l?`${f}/${l}`:f,Jt=await ha(s,r.env,a,Ge,A,A,pn,t);if(Jt.exitCode===0){let vd=await Y(s);await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"rebase",commitHash:vd})}return Jt}let _=await Ft(s,a,A),F=_[0]??null;if(_.length===0)return I("refusing to merge unrelated histories");if(F===A)return await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
580
+ `,stderr:"",exitCode:0};let U=!!n.noFf,L=!!n.ffOnly;if(!n.noFf&&!n.ffOnly){let re=await xe(s,"pull.ff");re==="false"?U=!0:re==="only"&&(L=!0)}let K=F===a;if(L&&!K)return I("Not possible to fast-forward, aborting.");if(K&&!U){let re=await Co(s,a,A),Ge=await Q(s),pn=Ge?.type==="symbolic"?Ge.target:"HEAD";return await Ze(s,pn,{oldHash:a,newHash:A,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:"pull: Fast-forward"}),Ge?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:A,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:"pull: Fast-forward"}),re.exitCode===0&&(await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:A,strategy:"fast-forward",commitHash:null}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"fast-forward",commitHash:A})),re}let te=await Q(s),J=te?.type==="symbolic"?Pe(te.target):"HEAD",ne=l||f||"FETCH_HEAD",ke=await xe(s,"merge.conflictstyle")??"merge",je={a:"HEAD",b:ne,conflictStyle:ke},ie=await gs(s,a,A,je),$e=await j(s,a),rt=await $n(s,ie,$e.tree,{labels:je,errorExitCode:2,operationName:"merge"});if(!rt.ok)return rt;if(ie.conflicts.length>0){await Z(s,"MERGE_HEAD",A),await Z(s,"ORIG_HEAD",a);let re=await mr(s,ne,J),Ge=Bt({version:2,entries:ie.entries}).sort();return re+=`
581
581
  # Conflicts:
582
582
  ${Ge.map(pn=>`# ${pn}`).join(`
583
583
  `)}
584
584
  `,await De(s,"MERGE_MSG",re),{stdout:`${[...ie.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
585
585
  `)}
586
- `,stderr:"",exitCode:1}}let Sn=rt.mergedTreeHash,We=await ln(s,r.env);if(M(We))return We;let wr=await nt(s,r.env);if(M(wr))return wr;let Lr=await mr(s,ne,J),xa={repo:s,message:Lr,treeHash:Sn,headHash:a,theirsHash:A},Ca=await t?.hooks?.mergeMsg?.(xa);if(le(Ca))return{stdout:"",stderr:Ca.message??"",exitCode:1};Lr=xa.message;let Pa=await t?.hooks?.preMergeCommit?.({repo:s,message:Lr,treeHash:Sn,headHash:a,theirsHash:A});if(le(Pa))return{stdout:"",stderr:Pa.message??"",exitCode:1};let $s=await bt(s,Sn,[a,A],We,wr,Lr);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:A,strategy:"three-way",commitHash:$s}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:$s});let Id=te?.type==="symbolic"?te.target:"HEAD",$a="pull: Merge made by the 'ort' strategy.";await Ze(s,Id,{oldHash:a,newHash:$s,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:$a}),te?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:$s,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:$a});let Sd=await mn(s,$e.tree,Sn);return{stdout:`${ie.messages.length>0?`${ie.messages.join(`
586
+ `,stderr:"",exitCode:1}}let Sn=rt.mergedTreeHash,We=await ln(s,r.env);if(M(We))return We;let br=await nt(s,r.env);if(M(br))return br;let Nr=await mr(s,ne,J),Ca={repo:s,message:Nr,treeHash:Sn,headHash:a,theirsHash:A},Pa=await t?.hooks?.mergeMsg?.(Ca);if(le(Pa))return{stdout:"",stderr:Pa.message??"",exitCode:1};Nr=Ca.message;let $a=await t?.hooks?.preMergeCommit?.({repo:s,message:Nr,treeHash:Sn,headHash:a,theirsHash:A});if(le($a))return{stdout:"",stderr:$a.message??"",exitCode:1};let Os=await bt(s,Sn,[a,A],We,br,Nr);await t?.hooks?.postMerge?.({repo:s,headHash:a,theirsHash:A,strategy:"three-way",commitHash:Os}),await t?.hooks?.postPull?.({repo:s,remote:f,branch:p,strategy:"three-way",commitHash:Os});let Sd=te?.type==="symbolic"?te.target:"HEAD",Oa="pull: Merge made by the 'ort' strategy.";await Ze(s,Sd,{oldHash:a,newHash:Os,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:Oa}),te?.type==="symbolic"&&await Ze(s,"HEAD",{oldHash:a,newHash:Os,name:H.name,email:H.email,timestamp:H.timestamp,tz:H.tz,message:Oa});let Td=await mn(s,$e.tree,Sn);return{stdout:`${ie.messages.length>0?`${ie.messages.join(`
587
587
  `)}
588
588
  `:""}Merge made by the 'ort' strategy.
589
- ${Sd}`,stderr:"",exitCode:0}}})}oe();qe();ht();ge();function td(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[q.string().name("remote").describe("Remote to push to").optional(),q.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:$().alias("f").describe("Force push"),"set-upstream":$().alias("u").describe("Set upstream tracking reference"),all:$().describe("Push all branches"),delete:$().alias("d").describe("Delete remote refs"),tags:$().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a;try{a=await jr(s,i,r.env)}catch(b){let E=b instanceof Error?b.message:"";if(E.startsWith("network"))return I(E);throw b}if(!a)return I(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,l=n.force,d=await c.advertiseRefs(),u=new Map;for(let b of d)u.set(b.name,b.hash);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=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return I("--delete requires a ref argument");for(let E of b){let R=E.startsWith("refs/")?E:`refs/heads/${E}`,k=u.get(R)??null;if(!k)return G(`error: unable to delete '${E}': remote ref does not exist
590
- `);m.push({name:R,oldHash:k,newHash:ee,ok:l})}}else if(n.all){let b=await pe(s,"refs/heads");for(let E of b){let R=E.name,k=u.get(R)??null;m.push({name:R,oldHash:k,newHash:E.hash,ok:l})}}else if(h&&h.length>0)for(let b of h){let E=gr(b),R=await Gg(s,E.src);if(!R)return G(`error: src refspec '${E.src}' does not match any
589
+ ${Td}`,stderr:"",exitCode:0}}})}oe();qe();ht();ge();function nd(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[q.string().name("remote").describe("Remote to push to").optional(),q.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:$().alias("f").describe("Force push"),"set-upstream":$().alias("u").describe("Set upstream tracking reference"),all:$().describe("Push all branches"),delete:$().alias("d").describe("Delete remote refs"),tags:$().describe("Push all tags")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=n.remote||"origin",a;try{a=await Gr(s,i,r.env)}catch(b){let E=b instanceof Error?b.message:"";if(E.startsWith("network"))return I(E);throw b}if(!a)return I(`'${i}' does not appear to be a git repository`);let{transport:c,config:f}=a,l=n.force,d=await c.advertiseRefs(),u=new Map;for(let b of d)u.set(b.name,b.hash);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=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return I("--delete requires a ref argument");for(let E of b){let R=E.startsWith("refs/")?E:`refs/heads/${E}`,k=u.get(R)??null;if(!k)return G(`error: unable to delete '${E}': remote ref does not exist
590
+ `);m.push({name:R,oldHash:k,newHash:ee,ok:l})}}else if(n.all){let b=await pe(s,"refs/heads");for(let E of b){let R=E.name,k=u.get(R)??null;m.push({name:R,oldHash:k,newHash:E.hash,ok:l})}}else if(h&&h.length>0)for(let b of h){let E=wr(b),R=await Ng(s,E.src);if(!R)return G(`error: src refspec '${E.src}' does not match any
591
591
  `);let k=E.dst.startsWith("refs/")?E.dst:`refs/heads/${E.dst}`,C=u.get(k)??null;m.push({name:k,oldHash:C,newHash:R,ok:l||E.force})}else if(!n.tags){let b=await Q(s);if(!b||b.type!=="symbolic")return I("You are not currently on a branch.");let E=b.target,R=E.startsWith("refs/heads/")?E.slice(11):E,k=await Y(s);if(!k)return G(`error: src refspec does not match any
592
- `);let C=(await xe(s,"push.default"))?.toLowerCase()??"simple",P=await jg(s,C,E,R,k,i,u,l);if("exitCode"in P)return P;m.push(P)}if(n.tags){let b=await pe(s,"refs/tags");for(let E of b){let R=u.get(E.name)??null;R!==E.hash&&(m.some(k=>k.name===E.name)||m.push({name:E.name,oldHash:R,newHash:E.hash,ok:l}))}}if(m.length===0)return{stdout:`Everything up-to-date
592
+ `);let C=(await xe(s,"push.default"))?.toLowerCase()??"simple",P=await Lg(s,C,E,R,k,i,u,l);if("exitCode"in P)return P;m.push(P)}if(n.tags){let b=await pe(s,"refs/tags");for(let E of b){let R=u.get(E.name)??null;R!==E.hash&&(m.some(k=>k.name===E.name)||m.push({name:E.name,oldHash:R,newHash:E.hash,ok:l}))}}if(m.length===0)return{stdout:`Everything up-to-date
593
593
  `,stderr:"",exitCode:0};let p=await t?.hooks?.prePush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===ee?null:b.name,srcHash:b.newHash===ee?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===ee}))});if(le(p))return G(p.message??"");let g=await c.push(m),w=[];w.push(`To ${f.url}
594
594
  `);let y=!1;for(let b of g.updates){let E=b.name.startsWith("refs/tags/"),R=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name.startsWith("refs/tags/")?b.name.slice(10):b.name;if(!b.ok)w.push(` ! [rejected] ${R} -> ${R} (${b.error??"failed"})
595
595
  `),y=!0;else if(b.oldHash)if(b.newHash===ee)w.push(` - [deleted] ${R}
596
596
  `);else{let k=X(b.oldHash),C=X(b.newHash);w.push(` ${k}..${C} ${R} -> ${R}
597
597
  `)}else{let k=E?"[new tag]":"[new branch]";w.push(` * ${k} ${R} -> ${R}
598
598
  `)}}if(n["set-upstream"]&&!y){let b=await Q(s);if(b?.type==="symbolic"){let E=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,R=await we(s);R[`branch "${E}"`]={remote:i,merge:`refs/heads/${E}`},await Je(s,R),w.push(`branch '${E}' set up to track '${i}/${E}'.
599
- `)}}let x={stdout:"",stderr:w.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===ee?null:b.name,srcHash:b.newHash===ee?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===ee}))}),x}})}async function jg(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 we(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return I(`The current branch ${r} has no upstream branch.
599
+ `)}}let x={stdout:"",stderr:w.join(""),exitCode:y?1:0};return y||await t?.hooks?.postPush?.({repo:s,remote:i,url:f.url,refs:m.map(b=>({srcRef:b.newHash===ee?null:b.name,srcHash:b.newHash===ee?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===ee}))}),x}})}async function Lg(e,t,n,r,o,s,i,a){if(t==="nothing")return 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 we(e))[`branch "${r}"`];if(!d?.remote||!d?.merge)return I(`The current branch ${r} has no upstream branch.
600
600
  To push the current branch and set the remote as upstream, use
601
601
 
602
602
  git push --set-upstream ${s} ${r}
@@ -609,34 +609,34 @@ on the remote, use
609
609
  To push to the branch of the same name on the remote, use
610
610
 
611
611
  git push ${s} HEAD
612
- `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}async function Gg(e,t){if(t.startsWith("refs/"))return B(e,t);let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);return r||(t==="HEAD"?Y(e):null)}oe();me();ze();ge();function Lg(e,t,n,r){return`${X(n)} ${e}@{${t}}: ${r}`}async function Fo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await B(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
612
+ `):{name:d,oldHash:i.get(d)??null,newHash:o,ok:a}}return{name:n,oldHash:i.get(n)??null,newHash:o,ok:a}}async function Ng(e,t){if(t.startsWith("refs/"))return B(e,t);let n=await B(e,`refs/heads/${t}`);if(n)return n;let r=await B(e,`refs/tags/${t}`);return r||(t==="HEAD"?Y(e):null)}oe();me();ze();ge();function _g(e,t,n,r){return`${X(n)} ${e}@{${t}}: ${r}`}async function Bo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await B(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
613
613
  Use '--' to separate paths from revisions, like this:
614
614
  'git <command> [<revision>...] -- [<file>...]'
615
- `,exitCode:128};let s=await et(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let l=s.length-1;l>=0&&c<a;l--){let d=s[l];if(!d)continue;let u=s.length-1-l;d.newHash!==ee&&(i.push(Lg(t,u,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
615
+ `,exitCode:128};let s=await et(e,r),i=[],a=n!==void 0?n:s.length,c=0;for(let l=s.length-1;l>=0&&c<a;l--){let d=s[l];if(!d)continue;let u=s.length-1-l;d.newHash!==ee&&(i.push(_g(t,u,d.newHash,d.message)),c++)}return{stdout:i.length>0?`${i.join(`
616
616
  `)}
617
- `:"",stderr:"",exitCode:0}}function nd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:V.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return Fo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Fo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Fo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
618
- `,exitCode:128};let l=v(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Fo(i,c,r.maxCount)}})}oe();qe();ze();ge();function Ng(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 rd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:$().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=Ng(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let m=c[`remote "${d}"`]?.url??"";l.push(`${d} ${m} (fetch)`),l.push(`${d} ${m} (push)`)}return{stdout:`${l.join(`
617
+ `:"",stderr:"",exitCode:0}}function rd(e,t){return e.command("reflog",{description:"Manage reflog information",args:[q.string().name("args").variadic().optional()],options:{maxCount:V.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);if(M(s))return s;let i=s,a=r.args;if(a.length===0)return Bo(i,"HEAD",r.maxCount);let c=a[0];if(!c)return Bo(i,"HEAD",r.maxCount);if(c==="show"){let f=a[1]??"HEAD";return Bo(i,f,r.maxCount)}if(c==="exists"){let f=a[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
618
+ `,exitCode:128};let l=v(i.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await i.fs.exists(l)?0:1}}return Bo(i,c,r.maxCount)}})}oe();qe();ze();ge();function Fg(e){let t=[];for(let n of Object.keys(e)){let r=n.match(/^remote "(.+)"$/);r?.[1]&&t.push(r[1])}return t.sort()}function sd(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:$().alias("v").describe("Show remote URLs")},handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=Fg(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let l=[];for(let d of f){let m=c[`remote "${d}"`]?.url??"";l.push(`${d} ${m} (fetch)`),l.push(`${d} ${m} (push)`)}return{stdout:`${l.join(`
619
619
  `)}
620
620
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
621
621
  `)}
622
- `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!Qr(`refs/remotes/${s.name}`,0))return I(`'${s.name}' is not a valid remote name`);let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;return f in c?G(`error: remote ${s.name} already exists.
623
- `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Je(a,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Fg(c,s.name),await Je(a,c),await Ug(a,s.name),{stdout:"",stderr:"",exitCode:0}):G(`error: No such remote: '${s.name}'
624
- `,2)},o=[q.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a);return _g(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;if(!(f in c))return G(`error: No such remote '${s.name}'
625
- `,2);let l=c[f];return l&&(l.url=s.url),await Je(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
622
+ `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("Remote URL")],handler:async(s,i)=>{if(!es(`refs/remotes/${s.name}`,0))return I(`'${s.name}' is not a valid remote name`);let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;if(f in c)return G(`error: remote ${s.name} already exists.
623
+ `,3);let l=pr(s.url,t?.credentialCache).url;return c[f]={url:l,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Je(a,c),{stdout:"",stderr:"",exitCode:0}}});let r=async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;return f in c?(delete c[f],Bg(c,s.name),await Je(a,c),await Wg(a,s.name),{stdout:"",stderr:"",exitCode:0}):G(`error: No such remote: '${s.name}'
624
+ `,2)},o=[q.string().name("name").describe("Remote name")];n.command("remove",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rm",{description:"Remove the remote named <name>",args:o,handler:r}),n.command("rename",{description:"Rename the remote named <old> to <new>",args:[q.string().name("old").describe("Current remote name"),q.string().name("new").describe("New remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a);return Ug(a,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[q.string().name("name").describe("Remote name"),q.string().name("url").describe("New remote URL")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;if(!(f in c))return G(`error: No such remote '${s.name}'
625
+ `,2);let l=pr(s.url,t?.credentialCache).url,d=c[f];return d&&(d.url=l),await Je(a,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[q.string().name("name").describe("Remote name")],handler:async(s,i)=>{let a=await W(i.fs,i.cwd,t);if(M(a))return a;let c=await we(a),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
626
626
  `,stderr:"",exitCode:0}:G(`error: No such remote '${s.name}'
627
- `,2)}})}async function _g(e,t,n,r){if(!Qr(`refs/remotes/${r}`,0))return I(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return G(`error: No such remote: '${n}'
628
- `,2);let s=`remote "${r}"`;if(s in t)return 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 Je(e,t);let a=`refs/remotes/${n}`,c=await pe(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await et(e,f.name);await Z(e,l,f.hash),await he(e,f.name),d.length>0&&await Ln(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Fg(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 Ug(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await he(e,o.name)}oe();Ce();ae();me();ze();ge();sn();Ae();fn();tt();function od(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:$().describe("Only move HEAD"),mixed:$().describe("Move HEAD and reset index (default)"),hard:$().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return I("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=ut(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return pa(i,o.passthrough,l,m,t)}if(!f&&a.length>0){let m=a[0],h=await Be(i,m);return a.length===1&&h?sd(i,m,"mixed",r.env,t):h?pa(i,a.slice(1),l,m,t):pa(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return sd(i,u,d,r.env,t)}})}async function pa(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(le(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await Be(e,r);if(!d)return Yt(r);let u=await ve(e,d);i=(await j(e,u)).tree}else{let d=await Y(e);d&&(i=(await j(e,d)).tree)}let a=await fe(e,i??null),c=await z(e);if(t.some(ir)){let d=t.map(m=>Ue(m,n)),u=new Set;for(let[m]of a)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!Ee(d,m))continue;let h=a.get(m);h?c=Ct(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Se()}):c=lt(c,m)}}else for(let d of t){let u=a.get(d);if(u)c=Ct(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:Se()});else if(c.entries.some(h=>h.path===d))c=lt(c,d);else if(!(e.workTree&&await e.fs.exists(v(e.workTree,d))))return Yt(d)}await de(e,c);let l={stdout:await id(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function id(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await gt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
627
+ `,2)}})}async function Ug(e,t,n,r){if(!es(`refs/remotes/${r}`,0))return I(`'${r}' is not a valid remote name`);let o=`remote "${n}"`;if(!(o in t))return G(`error: No such remote: '${n}'
628
+ `,2);let s=`remote "${r}"`;if(s in t)return 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 Je(e,t);let a=`refs/remotes/${n}`,c=await pe(e,a);for(let f of c){let l=f.name.replace(a,`refs/remotes/${r}`),d=await et(e,f.name);await Z(e,l,f.hash),await he(e,f.name),d.length>0&&await Ln(e,l,d)}return{stdout:"",stderr:"",exitCode:0}}function Bg(e,t){for(let n of Object.keys(e))n.match(/^branch "(.+)"$/)&&e[n]?.remote===t&&(delete e[n].remote,delete e[n].merge,Object.keys(e[n]).length===0&&delete e[n])}async function Wg(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await he(e,o.name)}oe();Ce();ae();me();ze();ge();sn();Ae();fn();tt();function id(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[q.string().name("args").variadic().optional()],options:{soft:$().describe("Only move HEAD"),mixed:$().describe("Move HEAD and reset index (default)"),hard:$().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return I("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,l=ut(i,r.cwd);if(o.passthrough.length>0){let m=a.length>0?a[0]:void 0;return ga(i,o.passthrough,l,m,t)}if(!f&&a.length>0){let m=a[0],h=await Be(i,m);return a.length===1&&h?od(i,m,"mixed",r.env,t):h?ga(i,a.slice(1),l,m,t):ga(i,a,l,void 0,t)}let d=n.soft?"soft":n.hard?"hard":"mixed",u=a.length>0?a[0]:"HEAD";return od(i,u,d,r.env,t)}})}async function ga(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:"paths",targetRef:r??null});if(le(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=null;if(r){let d=await Be(e,r);if(!d)return Yt(r);let u=await ve(e,d);i=(await j(e,u)).tree}else{let d=await Y(e);d&&(i=(await j(e,d)).tree)}let a=await fe(e,i??null),c=await z(e);if(t.some(ir)){let d=t.map(m=>Ue(m,n)),u=new Set;for(let[m]of a)u.add(m);for(let m of c.entries)u.add(m.path);for(let m of u){if(!Ee(d,m))continue;let h=a.get(m);h?c=Ct(c,{path:h.path,mode:parseInt(h.mode,8),hash:h.hash,stage:0,stat:Se()}):c=lt(c,m)}}else for(let d of t){let u=a.get(d);if(u)c=Ct(c,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:Se()});else if(c.entries.some(h=>h.path===d))c=lt(c,d);else if(!(e.workTree&&await e.fs.exists(v(e.workTree,d))))return Yt(d)}await de(e,c);let l={stdout:await ad(e,c),stderr:"",exitCode:0};return await o?.hooks?.postReset?.({repo:e,mode:"paths",targetHash:null}),l}async function ad(e,t){if(!e.workTree)return"";let n=new Set;for(let i of t.entries)i.stage>0&&n.add(i.path);let o=(await gt(e,t)).filter(i=>i.status==="modified"||i.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let i of o){let a=i.status==="modified"?"M":"D";s.push(`${a} ${i.path}`)}for(let i of[...n].sort())s.push(`U ${i}`);return s.sort((i,a)=>{if(i==="Unstaged changes after reset:")return-1;if(a==="Unstaged changes after reset:")return 1;let c=i.slice(2),f=a.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
629
629
  `)}
630
- `}async function sd(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(le(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await Be(e,t);if(!i)return Yt(t);let a=await ve(e,i),c=await j(e,a);if(n==="soft"){let m=await B(e,"MERGE_HEAD"),h=await z(e);if(m||Ht(h))return I("Cannot do a soft reset in the middle of a merge.")}let f=await Y(e),l=await Q(e);l?.type==="symbolic"?await Z(e,l.target,a):await Z(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await ce(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await ce(e,r,"HEAD",f,a,d),await cr(e),n==="mixed"){let m=await Ke(e,c.tree),h=Gs(m.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Se()})));await de(e,h);let p=await id(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=Ye(e);if(m)return m;let h=await z(e),p=await En(e,c.tree,h);await de(e,{version:2,entries:p.newEntries}),await Ne(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${X(a)} ${ue(c.message)}
631
- `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}oe();Ce();ae();ge();Ae();tt();function ad(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:V.string().alias("s").describe("Restore from tree-ish"),staged:$().alias("S").describe("Restore the index"),worktree:$().alias("W").describe("Restore the working tree (default)"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return I("you must specify path(s) to restore");if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=ut(i,r.cwd);if(n.ours||n.theirs)return n.source?I("cannot specify both --source and --ours/--theirs"):c?I("cannot use --ours/--theirs with --staged"):mo(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 Y(i);u&&(d=(await j(i,u)).tree)}return c&&f?qg(i,a,l,d):c?Bg(i,a,l,d):d?Wg(i,a,l,d):uo(i,a,l)}})}async function Bg(e,t,n,r){let o=await fe(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Ct(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Se()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
630
+ `}async function od(e,t,n,r,o){let s=await o?.hooks?.preReset?.({repo:e,mode:n,targetRef:t});if(le(s))return{stdout:"",stderr:s.message??"",exitCode:1};let i=await Be(e,t);if(!i)return Yt(t);let a=await ve(e,i),c=await j(e,a);if(n==="soft"){let m=await B(e,"MERGE_HEAD"),h=await z(e);if(m||Ht(h))return I("Cannot do a soft reset in the middle of a merge.")}let f=await Y(e),l=await Q(e);l?.type==="symbolic"?await Z(e,l.target,a):await Z(e,"HEAD",a);let d=`reset: moving to ${t}`;if(l?.type==="symbolic"&&f!==a?await ce(e,r,l.target,f,a,d,!0):(l?.type==="symbolic"||f!==a)&&await ce(e,r,"HEAD",f,a,d),await cr(e),n==="mixed"){let m=await Ke(e,c.tree),h=Ls(m.map(g=>({path:g.path,mode:parseInt(g.mode,8),hash:g.hash,stage:0,stat:Se()})));await de(e,h);let p=await ad(e,h);if(p)return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:p,stderr:"",exitCode:0}}if(n==="hard"){let m=Ye(e);if(m)return m;let h=await z(e),p=await En(e,c.tree,h);await de(e,{version:2,entries:p.newEntries}),await Ne(e,p.worktreeOps)}let u=n==="hard"?`HEAD is now at ${X(a)} ${ue(c.message)}
631
+ `:"";return await o?.hooks?.postReset?.({repo:e,mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}oe();Ce();ae();ge();Ae();tt();function cd(e,t){e.command("restore",{description:"Restore working tree files",args:[q.string().name("pathspec").variadic().optional()],options:{source:V.string().alias("s").describe("Restore from tree-ish"),staged:$().alias("S").describe("Restore the index"),worktree:$().alias("W").describe("Restore the working tree (default)"),ours:$().describe("Checkout our version for unmerged files"),theirs:$().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=[...n.pathspec??[],...o.passthrough];if(a.length===0)return I("you must specify path(s) to restore");if(n.ours&&n.theirs)return I("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,l=ut(i,r.cwd);if(n.ours||n.theirs)return n.source?I("cannot specify both --source and --ours/--theirs"):c?I("cannot use --ours/--theirs with --staged"):ho(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 Y(i);u&&(d=(await j(i,u)).tree)}return c&&f?Kg(i,a,l,d):c?qg(i,a,l,d):d?zg(i,a,l,d):mo(i,a,l)}})}async function qg(e,t,n,r){let o=await fe(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=new Set;for(let[f]of o)a.add(f);for(let f of s.entries)a.add(f.path);let c=!1;for(let f of a){if(!Ee(i,f))continue;c=!0;let l=o.get(f);if(l)s=Ct(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Se()});else{if(s.entries.some(u=>u.path===f&&u.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
632
632
  `,exitCode:1};s=lt(s,f)}}return c?(await de(e,s),{stdout:"",stderr:"",exitCode:0}):G(`error: pathspec '${t[0]}' did not match any file(s) known to git
633
- `)}async function Wg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await fe(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
633
+ `)}async function zg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await fe(e,r),s=t.map(f=>Ue(f,n)),i=[],a=await z(e),c=new Set;for(let[f]of o)c.add(f);for(let f of a.entries)c.add(f.path);for(let f of c)if(Ee(s,f)){if(!o.has(f)&&a.entries.some(d=>d.path===f&&d.stage!==0))return{stdout:"",stderr:`error: path '${f}' is unmerged
634
634
  `,exitCode:1};i.push(f)}if(i.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
635
- `);for(let f of i){let l=o.get(f);if(l)await dt(e,{path:l.path,hash:l.hash,mode:l.mode});else{let d=`${e.workTree}/${f}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function qg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await fe(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)Ee(i,f)&&a.push(f);if(a.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
635
+ `);for(let f of i){let l=o.get(f);if(l)await dt(e,{path:l.path,hash:l.hash,mode:l.mode});else{let d=`${e.workTree}/${f}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function Kg(e,t,n,r){if(!e.workTree)return I("this operation must be run in a work tree");let o=await fe(e,r),s=await z(e),i=t.map(f=>Ue(f,n)),a=[],c=new Set;for(let[f]of o)c.add(f);for(let f of s.entries)c.add(f.path);for(let f of c)Ee(i,f)&&a.push(f);if(a.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
636
636
  `);for(let f of a){let l=o.get(f);if(l)s=Ct(s,{path:l.path,mode:parseInt(l.mode,8),hash:l.hash,stage:0,stat:Se()}),await dt(e,{path:l.path,hash:l.hash,mode:l.mode});else{if(s.entries.some(m=>m.path===f&&m.stage>0))return{stdout:"",stderr:`error: path '${f}' is unmerged
637
- `,exitCode:1};s=lt(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await de(e,s),{stdout:"",stderr:"",exitCode:0}}oe();ae();me();ge();sn();Ae();function cd(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[q.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:$().describe("Verify that exactly one parameter is provided and resolves to an object"),short:$().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":$().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":$().describe("Output the full symbolic ref name"),"show-toplevel":$().describe("Show the absolute path of the top-level directory"),"git-dir":$().describe("Show the path to the .git directory"),"is-inside-work-tree":$().describe("Output whether cwd is inside the work tree"),"is-bare-repository":$().describe("Output whether the repository is bare"),"show-prefix":$().describe("Show path of cwd relative to top-level directory"),"show-cdup":$().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||l||d||u||m||h,g=await W(r.fs,r.cwd,t);if(M(g))return g;let w=g,y=[];if(f){if(!w.workTree)return I("this operation must be run in a work tree");y.push(w.workTree)}if(l&&y.push(w.gitDir),d&&y.push(w.workTree?"true":"false"),u&&y.push(w.workTree?"false":"true"),m){if(!w.workTree)return I("this operation must be run in a work tree");let b=st(w.workTree,r.cwd);y.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return I("this operation must be run in a work tree");let b=st(r.cwd,w.workTree);y.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:y.map(E=>`${E}
638
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return I("Needed a single revision");for(let b of o){if(a){let k=await zg(w,b);if(k===null)return ga(b,s);y.push(k);continue}if(c){let k=await Kg(w,b);if(k===null)return ga(b,s);y.push(k);continue}let E=zs(b);if(E){let k=await Vg(w,E.rev,E.path);if(k===null){let C=E.path.replace(/^\//,"");return I(`path '${C}' does not exist in '${E.rev}'`)}y.push(i?X(k):k);continue}let R=await Be(w,b);if(!R)return ga(b,s);y.push(i?X(R):R)}return{stdout:y.map(b=>`${b}
639
- `).join(""),stderr:"",exitCode:0}}})}function ga(e,t){return t?I("Needed a single revision"):Yt(e)}async function zg(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await Be(e,t)?t:null}async function Kg(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Be(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await B(e,o))return o}return t}async function Vg(e,t,n){let r=await Be(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await fe(e,o.tree)).get(s)?.hash??null}oe();qe();Ce();ae();ze();ge();Ae();function fd(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:$().describe("Abort the current revert operation"),continue:$().describe("Continue the revert after conflict resolution"),"no-commit":$().alias("n").describe("Apply changes without creating a commit"),"no-edit":$().describe("Do not edit the commit message"),mainline:V.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let U=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(le(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Yg(s,r.env);return L.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),L}if(n.continue){let U=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(le(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Xg(s,r.env);if(L.exitCode===0){let K=await Y(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:K,hadConflicts:!1})}return L}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(le(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 z(s),m=kn(u,"Reverting",`fatal: revert failed
637
+ `,exitCode:1};s=lt(s,f);let u=`${e.workTree}/${f}`;await e.fs.exists(u)&&await e.fs.rm(u)}}return await de(e,s),{stdout:"",stderr:"",exitCode:0}}oe();ae();me();ge();sn();Ae();function fd(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[q.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:$().describe("Verify that exactly one parameter is provided and resolves to an object"),short:$().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":$().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":$().describe("Output the full symbolic ref name"),"show-toplevel":$().describe("Show the absolute path of the top-level directory"),"git-dir":$().describe("Show the path to the .git directory"),"is-inside-work-tree":$().describe("Output whether cwd is inside the work tree"),"is-bare-repository":$().describe("Output whether the repository is bare"),"show-prefix":$().describe("Show path of cwd relative to top-level directory"),"show-cdup":$().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(b=>b!==""),s=n.verify,i=n.short,a=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],l=n["git-dir"],d=n["is-inside-work-tree"],u=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||l||d||u||m||h,g=await W(r.fs,r.cwd,t);if(M(g))return g;let w=g,y=[];if(f){if(!w.workTree)return I("this operation must be run in a work tree");y.push(w.workTree)}if(l&&y.push(w.gitDir),d&&y.push(w.workTree?"true":"false"),u&&y.push(w.workTree?"false":"true"),m){if(!w.workTree)return I("this operation must be run in a work tree");let b=st(w.workTree,r.cwd);y.push(b===""?"":`${b}/`)}if(h){if(!w.workTree)return I("this operation must be run in a work tree");let b=st(r.cwd,w.workTree);y.push(b===""?"":`${b}/`)}if(p&&o.length===0)return{stdout:y.map(E=>`${E}
638
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return I("Needed a single revision");for(let b of o){if(a){let k=await Vg(w,b);if(k===null)return wa(b,s);y.push(k);continue}if(c){let k=await Yg(w,b);if(k===null)return wa(b,s);y.push(k);continue}let E=Ks(b);if(E){let k=await Xg(w,E.rev,E.path);if(k===null){let C=E.path.replace(/^\//,"");return I(`path '${C}' does not exist in '${E.rev}'`)}y.push(i?X(k):k);continue}let R=await Be(w,b);if(!R)return wa(b,s);y.push(i?X(R):R)}return{stdout:y.map(b=>`${b}
639
+ `).join(""),stderr:"",exitCode:0}}})}function wa(e,t){return t?I("Needed a single revision"):Yt(e)}async function Vg(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);if(!r)return null;if(r.type==="symbolic"){let o=r.target;return o.startsWith("refs/heads/")?o.slice(11):o}return"HEAD"}return await Be(e,t)?t:null}async function Yg(e,t){if(t==="HEAD"||t==="@"){let r=await Q(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Be(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await B(e,o))return o}return t}async function Xg(e,t,n){let r=await Be(e,t);if(!r)return null;let o=await j(e,r),s=n.replace(/^\//,"");return s===""?o.tree:(await fe(e,o.tree)).get(s)?.hash??null}oe();qe();Ce();ae();ze();ge();Ae();function ld(e,t){e.command("revert",{description:"Revert some existing commits",args:[q.string().name("commit").describe("The commit to revert").optional()],options:{abort:$().describe("Abort the current revert operation"),continue:$().describe("Continue the revert after conflict resolution"),"no-commit":$().alias("n").describe("Apply changes without creating a commit"),"no-edit":$().describe("Do not edit the commit message"),mainline:V.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.abort){let U=await t?.hooks?.preRevert?.({repo:s,mode:"abort",commitRef:null});if(le(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Zg(s,r.env);return L.exitCode===0&&await t?.hooks?.postRevert?.({repo:s,mode:"abort",commitHash:null,hadConflicts:!1}),L}if(n.continue){let U=await t?.hooks?.preRevert?.({repo:s,mode:"continue",commitRef:null});if(le(U))return{stdout:"",stderr:U.message??"",exitCode:1};let L=await Jg(s,r.env);if(L.exitCode===0){let K=await Y(s);await t?.hooks?.postRevert?.({repo:s,mode:"continue",commitHash:K,hadConflicts:!1})}return L}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(le(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 z(s),m=kn(u,"Reverting",`fatal: revert failed
640
640
  `);if(m)return m;let h=await j(s,d);if(s.workTree){let U=await fe(s,h.tree);if(Un(u,U))return G(`error: your local changes would be overwritten by revert.
641
641
  hint: commit your changes or stash them to proceed.
642
642
  fatal: revert failed
@@ -644,7 +644,7 @@ fatal: revert failed
644
644
  fatal: revert failed
645
645
  `,128);if(p<1||p>l.parents.length)return G(`error: commit ${f} does not have parent ${p}
646
646
  fatal: revert failed
647
- `,128);let U=l.parents[p-1];g=(await j(s,U)).tree}else if(l.parents.length===0)g=await Fe(s,[]);else{let U=l.parents[0];g=(await j(s,U)).tree}let w=X(f),y=ue(l.message),x=Zg(l,f,p),b=await xe(s,"merge.conflictstyle")??"merge",E={a:"HEAD",b:y?`parent of ${w} (${y})`:`parent of ${w}`,conflictStyle:b},R=await Ut(s,l.tree,h.tree,g,E);if(R.conflicts.length===0&&R.resultTree===h.tree){let U=R.messages.length>0?`${R.messages.join(`
647
+ `,128);let U=l.parents[p-1];g=(await j(s,U)).tree}else if(l.parents.length===0)g=await Fe(s,[]);else{let U=l.parents[0];g=(await j(s,U)).tree}let w=X(f),y=ue(l.message),x=Qg(l,f,p),b=await xe(s,"merge.conflictstyle")??"merge",E={a:"HEAD",b:y?`parent of ${w} (${y})`:`parent of ${w}`,conflictStyle:b},R=await Ut(s,l.tree,h.tree,g,E);if(R.conflicts.length===0&&R.resultTree===h.tree){let U=R.messages.length>0?`${R.messages.join(`
648
648
  `)}
649
649
  `:"",L=await at(s,{fromCommit:!0}),K=await B(s,"CHERRY_PICK_HEAD");return{stdout:`${U}${L}`,stderr:K?`The previous cherry-pick is now empty, possibly due to conflict resolution.
650
650
  If you wish to commit it anyway, use:
@@ -665,25 +665,25 @@ hint: Disable this message with "git config set advice.mergeConflict false"
665
665
  `,exitCode:1}}if(n["no-commit"])return await Z(s,"REVERT_HEAD",f),await De(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let C=k.mergedTreeHash,P=await ln(s,r.env);if(M(P))return P;let T=await nt(s,r.env);if(M(T))return T;let D=await bt(s,C,[d],P,T,x);await Lt(s),await Gt(s);let O=await Q(s),N=ue(x),H=O?.type==="symbolic"?O.target:"HEAD";await ce(s,r.env,H,d,D,`revert: ${N}`,O?.type==="symbolic");let S=O?.type==="symbolic"?Pe(O.target):"detached HEAD",A=await un(s,h.tree,C,P,T,P.timestamp!==T.timestamp||P.timezone!==T.timezone),_=Dt(S,D,x),F=R.messages.length>0?`${R.messages.join(`
666
666
  `)}
667
667
  `:"";return await t?.hooks?.postRevert?.({repo:s,mode:"revert",commitHash:D,hadConflicts:!1}),{stdout:`${F}${_}
668
- ${A}`,stderr:"",exitCode:0}}})}async function Yg(e,t){return await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
668
+ ${A}`,stderr:"",exitCode:0}}})}async function Zg(e,t){return await B(e,"REVERT_HEAD")?Bn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
669
669
  fatal: revert failed
670
670
  `,128),operationName:"revert",clearState:async o=>{await Lt(o),await Gt(o)},origHeadAsTargetRev:!0}):await B(e,"CHERRY_PICK_HEAD")?Bn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
671
671
  fatal: revert failed
672
672
  `,128),operationName:"revert",clearState:Gt,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
673
673
  fatal: revert failed
674
- `,128)}async function Xg(e,t){if(!await B(e,"REVERT_HEAD"))return G(`error: no cherry-pick or revert in progress
674
+ `,128)}async function Jg(e,t){if(!await B(e,"REVERT_HEAD"))return G(`error: no cherry-pick or revert in progress
675
675
  fatal: revert failed
676
676
  `,128);let r=await z(e),o=kn(r,"Committing");if(o)return o;let s=await Oe(e,"MERGE_MSG");if(!s)return G(`Aborting commit due to empty commit message.
677
677
  `,1);let i=Le(r),a=await Fe(e,i),c=await Qe(e);if(M(c))return c;let f=await j(e,c),l=await ln(e,t);if(M(l))return l;let d=await nt(e,t);if(M(d))return d;let u=await B(e,"CHERRY_PICK_HEAD");u&&(l=(await j(e,u)).author);let m=Mt(s),h=await bt(e,a,[c],l,d,m);await Lt(e),await Gt(e);let p=await Q(e),g=ue(m),w=p?.type==="symbolic"?p.target:"HEAD";await ce(e,t,w,c,h,`commit: ${g}`,p?.type==="symbolic");let y=p?.type==="symbolic"?Pe(p.target):"detached HEAD",x=await un(e,f.tree,a,l,d,l.timestamp!==d.timestamp||l.timezone!==d.timezone);return{stdout:`${Dt(y,h,s)}
678
- ${x}`,stderr:"",exitCode:0}}function Zg(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
678
+ ${x}`,stderr:"",exitCode:0}}function Qg(e,t,n){let r=ue(e.message),o='Revert "',a=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
679
679
 
680
680
  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
681
681
  changes made to ${c}`}return a+=`.
682
- `,a}oe();Ce();ae();me();ge();nr();Ae();function ld(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[q.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:$().describe("Only remove from the index"),recursive:$().alias("r").describe("Allow recursive removal when a directory name is given"),force:$().alias("f").describe("Override the up-to-date check"),dryRun:$().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return G("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,u=await z(s),m=[],h=ut(s,r.cwd);for(let w of c){if(ir(w)){let E=[Ue(w,h)],R=u.entries.filter(k=>Ee(E,k.path));if(R.length===0)return I(`pathspec '${w}' did not match any files`);for(let k of R)m.push(k.path);continue}let y=vt(r.cwd,w),x=st(a,y);if((x==="."||x==="")&&(x=""),x.startsWith(".."))return I(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(y)&&!(await mt(r.fs,y)).isSymbolicLink&&(await mt(r.fs,y)).isDirectory){if(!l)return I(`not removing '${x}' recursively without -r`);let E=x===""?"":`${x}/`,R=u.entries.filter(k=>E===""||k.path.startsWith(E));if(R.length===0)return I(`pathspec '${w}' did not match any files`);for(let k of R)m.push(k.path)}else{if(!u.entries.some(R=>R.path===x))return I(`pathspec '${w}' did not match any files`);m.push(x)}}if(!d){let w=await Jg(s,u,m,f);if(w)return w}if(n.dryRun){let w=m.map(x=>`rm '${x}'`);return{stdout:w.length>0?`${w.join(`
682
+ `,a}oe();Ce();ae();me();ge();nr();Ae();function dd(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[q.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:$().describe("Only remove from the index"),recursive:$().alias("r").describe("Allow recursive removal when a directory name is given"),force:$().alias("f").describe("Override the up-to-date check"),dryRun:$().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,i=Ye(s);if(i)return i;let a=s.workTree,c=n.paths;if(c.length===0)return G("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,l=n.recursive,d=n.force,u=await z(s),m=[],h=ut(s,r.cwd);for(let w of c){if(ir(w)){let E=[Ue(w,h)],R=u.entries.filter(k=>Ee(E,k.path));if(R.length===0)return I(`pathspec '${w}' did not match any files`);for(let k of R)m.push(k.path);continue}let y=vt(r.cwd,w),x=st(a,y);if((x==="."||x==="")&&(x=""),x.startsWith(".."))return I(`'${w}' is outside repository at '${a}'`);if(await r.fs.exists(y)&&!(await mt(r.fs,y)).isSymbolicLink&&(await mt(r.fs,y)).isDirectory){if(!l)return I(`not removing '${x}' recursively without -r`);let E=x===""?"":`${x}/`,R=u.entries.filter(k=>E===""||k.path.startsWith(E));if(R.length===0)return I(`pathspec '${w}' did not match any files`);for(let k of R)m.push(k.path)}else{if(!u.entries.some(R=>R.path===x))return I(`pathspec '${w}' did not match any files`);m.push(x)}}if(!d){let w=await ew(s,u,m,f);if(w)return w}if(n.dryRun){let w=m.map(x=>`rm '${x}'`);return{stdout:w.length>0?`${w.join(`
683
683
  `)}
684
684
  `:"",stderr:"",exitCode:0}}let p=[];for(let w of m){if(u=lt(u,w),!f){let y=v(a,w);await mt(r.fs,y).then(()=>!0).catch(()=>!1)&&await r.fs.rm(y)}p.push(`rm '${w}'`)}return await de(s,u),{stdout:p.length>0?`${p.join(`
685
685
  `)}
686
- `:"",stderr:"",exitCode:0}}})}async function Jg(e,t,n,r){let o=await Y(e),s=new Map;if(o){let f=await j(e,o),l=await Ke(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(h=>h.path===f&&h.stage===0);if(!l)continue;let u=s.get(f)!==l.hash,m=!1;if(e.workTree){let h=v(e.workTree,f),p=!1;try{await mt(e.fs,h),p=!0}catch{p=!1}p&&(m=await Nn(e.fs,h)!==l.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
686
+ `:"",stderr:"",exitCode:0}}})}async function ew(e,t,n,r){let o=await Y(e),s=new Map;if(o){let f=await j(e,o),l=await Ke(e,f.tree);for(let d of l)s.set(d.path,d.hash)}let i=[],a=[],c=[];for(let f of n){let l=t.entries.find(h=>h.path===f&&h.stage===0);if(!l)continue;let u=s.get(f)!==l.hash,m=!1;if(e.workTree){let h=v(e.workTree,f),p=!1;try{await mt(e.fs,h),p=!0}catch{p=!1}p&&(m=await Nn(e.fs,h)!==l.hash)}u&&m?i.push(f):u&&!r?a.push(f):m&&!r&&c.push(f)}if(i.length>0){let f=i.map(d=>` ${d}`).join(`
687
687
  `),l=i.length===1?"the following file has":"the following files have";return G(`error: ${l} staged content different from both the
688
688
  file and the HEAD:
689
689
  ${f}
@@ -696,39 +696,39 @@ ${f}
696
696
  `),l=c.length===1?"the following file has":"the following files have";return G(`error: ${l} local modifications:
697
697
  ${f}
698
698
  (use --cached to keep the file, or -f to force removal)
699
- `)}return null}oe();ae();sn();Ks();me();Ae();var wa=new TextDecoder;function dd(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:$().alias("p").describe("Show diff in patch format"),noPatch:$().describe("Suppress diff output"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),format:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=zs(a);if(c)return Qg(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await wt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await be(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,m=null,h=null;if(u!==void 0){let p=Lo(u);m=p.formatStr,h=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await ud(s,f,p,d,m,h),stderr:"",exitCode:0}}case"tag":{let p=await $c(s,f);return{stdout:await ew(s,p,d,m,h),stderr:"",exitCode:0}}case"tree":{let p=_n(l.content);return{stdout:md(p),stderr:"",exitCode:0}}case"blob":return{stdout:wa.decode(l.content),stderr:"",exitCode:0}}}})}async function Qg(e,t,n){let r=await Me(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await fe(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 be(e,a.hash);if(c.type==="blob")return{stdout:wa.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=_n(c.content);return{stdout:md(f),stderr:"",exitCode:0}}return{stdout:wa.decode(c.content),stderr:"",exitCode:0}}async function ud(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=Rs(o,{hash:t,commit:n});else if(s!==null)i=xs(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>X(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Cn(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
699
+ `)}return null}oe();ae();sn();Vs();me();Ae();var ba=new TextDecoder;function ud(e,t){e.command("show",{description:"Show various types of objects",args:[q.string().name("object").variadic().optional()],options:{patch:$().alias("p").describe("Show diff in patch format"),noPatch:$().describe("Suppress diff output"),stat:$().describe("Show diffstat summary"),nameOnly:$().describe("Show only names of changed files"),nameStatus:$().describe("Show names and status of changed files"),shortstat:$().describe("Show only the shortstat summary line"),numstat:$().describe("Machine-readable insertions/deletions per file"),format:V.string().describe("Pretty-print format string"),pretty:V.string().describe("Pretty-print format or preset name")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o,a=n.object[0]??"HEAD",c=Ks(a);if(c)return tw(s,c.rev,c.path);if(a==="HEAD"){let p=await Qe(s);if(M(p))return p}let f=await wt(s,a,`bad object '${a}'`);if(M(f))return f;let l=await be(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,m=null,h=null;if(u!==void 0){let p=_o(u);m=p.formatStr,h=p.preset}switch(l.type){case"commit":{let p=await j(s,f);return{stdout:await md(s,f,p,d,m,h),stderr:"",exitCode:0}}case"tag":{let p=await Oc(s,f);return{stdout:await nw(s,p,d,m,h),stderr:"",exitCode:0}}case"tree":{let p=_n(l.content);return{stdout:hd(p),stderr:"",exitCode:0}}case"blob":return{stdout:ba.decode(l.content),stderr:"",exitCode:0}}}})}async function tw(e,t,n){let r=await Me(e,t);if(M(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),a=(await fe(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 be(e,a.hash);if(c.type==="blob")return{stdout:ba.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=_n(c.content);return{stdout:hd(f),stderr:"",exitCode:0}}return{stdout:ba.decode(c.content),stderr:"",exitCode:0}}async function md(e,t,n,r="patch",o=null,s=null){let i;if(o!==null)i=xs(o,{hash:t,commit:n});else if(s!==null)i=Cs(s,{hash:t,commit:n},!0,!1);else{let c=[];if(c.push(`commit ${t}`),n.parents.length>=2){let l=n.parents.map(d=>X(d)).join(" ");c.push(`Merge: ${l}`)}c.push(`Author: ${n.author.name} <${n.author.email}>`),c.push(`Date: ${Cn(n.author.timestamp,n.author.timezone)}`),c.push("");let f=n.message.replace(/\n$/,"");for(let l of f.split(`
700
700
  `))c.push(` ${l}`);i=c.join(`
701
701
  `)}if(!r)return`${i}
702
- `;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 tw(e,l,d,r)}else r==="patch"&&(a=await lw(e,n)??"");return a?`${i}
702
+ `;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 rw(e,l,d,r)}else r==="patch"&&(a=await uw(e,n)??"");return a?`${i}
703
703
 
704
704
  ${a.replace(/\n$/,"")}
705
705
  `:n.parents.length>=2?`${i}
706
706
 
707
707
  `:`${i}
708
- `}async function ew(e,t,n="patch",r=null,o=null){let s=[];s.push(`tag ${t.name}`),s.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),s.push(`Date: ${Cn(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
709
- `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await ud(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
708
+ `}async function nw(e,t,n="patch",r=null,o=null){let s=[];s.push(`tag ${t.name}`),s.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),s.push(`Date: ${Cn(t.tagger.timestamp,t.tagger.timezone)}`),s.push("");let i=t.message.replace(/\n$/,"");for(let a of i.split(`
709
+ `))s.push(` ${a}`);if(t.objectType==="commit"){let a=await j(e,t.object),c=await md(e,t.object,a,n,r,o);s.push(""),s.push(c.replace(/\n$/,""))}return`${s.join(`
710
710
  `)}
711
- `}function md(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(`
711
+ `}function hd(e){let t=[];for(let n of e.entries){let r=n.mode==="040000"?"tree":"blob";t.push(`${n.mode} ${r} ${n.hash} ${n.name}`)}return t.length>0?`${t.join(`
712
712
  `)}
713
- `:""}async function tw(e,t,n,r){switch(r){case"patch":return fw(e,t,n);case"stat":return sw(e,t,n);case"shortstat":return ow(e,t,n);case"numstat":return iw(e,t,n);case"name-only":return nw(t,n);case"name-status":return rw(t,n);default:return""}}function nw(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(`
713
+ `:""}async function rw(e,t,n,r){switch(r){case"patch":return dw(e,t,n);case"stat":return iw(e,t,n);case"shortstat":return aw(e,t,n);case"numstat":return cw(e,t,n);case"name-only":return sw(t,n);case"name-status":return ow(t,n);default:return""}}function sw(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(`
714
714
  `)}
715
- `:""}function rw(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}
716
- `).join(""):""}async function sw(e,t,n){let{fileStats:r}=await Zn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),ur(r)}async function ow(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
717
- `:""}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:dn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
715
+ `:""}function ow(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}
716
+ `).join(""):""}async function iw(e,t,n){let{fileStats:r}=await Zn(e,t,n);return r.sort((o,s)=>o.sortKey<s.sortKey?-1:o.sortKey>s.sortKey?1:0),ur(r)}async function aw(e,t,n){let{fileStats:r}=await Zn(e,t,n),o=0,s=0;for(let a of r)o+=a.insertions,s+=a.deletions;let i=Xn(r.length,o,s);return i?`${i}
717
+ `:""}async function cw(e,t,n){let r=[];for(let s of t)r.push({key:s.path,oldHash:s.oldHash,newHash:s.newHash,display:s.path});for(let s of n)r.push({key:s.newPath,oldHash:s.oldHash,newHash:s.newHash,display:dn(s.oldPath,s.newPath)});r.sort((s,i)=>s.key<i.key?-1:s.key>i.key?1:0);let o="";for(let s of r){let i=s.oldHash?await se(e,s.oldHash):"",a=s.newHash?await se(e,s.newHash):"";if(Te(i)||Te(a))o+=`- - ${s.display}
718
718
  `;else{let c=Rt(i),f=Rt(a),l=ct(c,f),d=0,u=0;for(let m of l)m.type==="insert"?d++:m.type==="delete"&&u++;o+=`${d} ${u} ${s.display}
719
- `}}return o}async function aw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function cw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({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 fw(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 cw(e,s.entry):o+=await aw(e,s.entry);return o}async function lw(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 fe(e,c.tree)})),r=await fe(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 se(e,u):"")),d=i?await se(e,i):"";return Ao({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}oe();Ce();ae();ge();oe();Tn();Ce();ae();gn();me();ze();ge();Ae();fn();tt();var Zt="refs/stash";function ya(e,t){return Ie(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function hd(e){let t=await et(e,Zt),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 Gr(e,t){let n=await et(e,Zt);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 pd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Y(e);if(!s)return null;let i=await j(e,s),a=await z(e),c=Le(a),f=await Fe(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(L=>[L.path,L])),u=await ot(e,o,"",{skipIgnore:!0}),m=!1;for(let L of u){let K=d.get(L);if(!K)continue;let te=v(o,L),J=await e.fs.readFileBuffer(te);if(await pt("blob",J)!==K.hash){m=!0;break}}if(!m)for(let[L]of d){let K=v(o,L);if(!await e.fs.exists(K)){m=!0;break}}let h=[];if(r?.includeUntracked){let L=await ot(e,o,"");for(let K of L)d.has(K)||h.push(K)}if(l.length===0&&!m&&h.length===0)return null;let p=await Hs(e,t),g=await Br(e,t),w=await Q(e),y=w?.type==="symbolic"?Pe(w.target):"(no branch)",x=X(s),b=ue(i.message),E=`index on ${y}: ${x} ${b}
719
+ `}}return o}async function fw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function lw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({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 dw(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 lw(e,s.entry):o+=await fw(e,s.entry);return o}async function uw(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 fe(e,c.tree)})),r=await fe(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 mw(e,a,n,r);return i}async function mw(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 se(e,u):"")),d=i?await se(e,i):"";return Do({path:t,parentHashes:c,parentModes:f,parentContents:l,resultHash:i,resultMode:a,resultContent:d})}oe();Ce();ae();ge();oe();Tn();Ce();ae();gn();me();ze();ge();Ae();fn();tt();var Zt="refs/stash";function Ea(e,t){return Ie(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function pd(e){let t=await et(e,Zt),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 Lr(e,t){let n=await et(e,Zt);if(n.length===0)return null;let r=n.length-1-t;return r<0||r>=n.length?null:n[r]?.newHash??null}async function gd(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await Y(e);if(!s)return null;let i=await j(e,s),a=await z(e),c=Le(a),f=await Fe(e,c),l=await Ve(e,i.tree,f),d=new Map(c.map(L=>[L.path,L])),u=await ot(e,o,"",{skipIgnore:!0}),m=!1;for(let L of u){let K=d.get(L);if(!K)continue;let te=v(o,L),J=await e.fs.readFileBuffer(te);if(await pt("blob",J)!==K.hash){m=!0;break}}if(!m)for(let[L]of d){let K=v(o,L);if(!await e.fs.exists(K)){m=!0;break}}let h=[];if(r?.includeUntracked){let L=await ot(e,o,"");for(let K of L)d.has(K)||h.push(K)}if(l.length===0&&!m&&h.length===0)return null;let p=await Ds(e,t),g=await Wr(e,t),w=await Q(e),y=w?.type==="symbolic"?Pe(w.target):"(no branch)",x=X(s),b=ue(i.message),E=`index on ${y}: ${x} ${b}
720
720
  `,R=rn({type:"commit",tree:f,parents:[s],author:p,committer:g,message:E}),k=await He(e,"commit",R),C=await fe(e,i.tree),P=[],T=new Set;for(let L of u){let K=d.get(L),te=C.get(L);if(!K&&!te)continue;let J=v(o,L),ne=await e.fs.readFileBuffer(J),ke=await He(e,"blob",ne),je=K?K.mode:parseInt(te?.mode??"100644",8);P.push({path:L,mode:je,hash:ke,stage:0,stat:Se()}),T.add(L)}for(let[L,K]of d)T.has(L)||C.has(L)||P.push({path:L,mode:K.mode,hash:K.hash,stage:0,stat:Se()});let D=await Fe(e,P),O=null;if(r?.includeUntracked){let L=[];for(let ne of h){let ke=v(o,ne),je=await e.fs.readFileBuffer(ke),ie=await He(e,"blob",je);L.push({path:ne,mode:33188,hash:ie,stage:0,stat:Se()})}let K=await Fe(e,L),te=`untracked files on ${y}: ${x} ${b}
721
- `,J=rn({type:"commit",tree:K,parents:[],author:p,committer:g,message:te});O=await He(e,"commit",J)}let N=n?`On ${y}: ${n}`:`WIP on ${y}: ${x} ${b}`,H=[s,k];O&&H.push(O);let S=rn({type:"commit",tree:D,parents:H,author:p,committer:g,message:N}),A=await He(e,"commit",S),_=await Gr(e,0)??ee;await Ze(e,Zt,{oldHash:_,newHash:A,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:N.trimEnd()}),await Z(e,Zt,A);let F=await En(e,i.tree,a);await de(e,{version:2,entries:F.newEntries}),await Ne(e,F.worktreeOps),(await Q(e))?.type==="symbolic"&&await ce(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let L of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,L);for(let L of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let K=v(e.gitDir,L);await e.fs.exists(K)&&await e.fs.rm(K)}if(h.length>0)for(let L of h){if(C.has(L))continue;let K=v(o,L);await e.fs.exists(K)&&(await e.fs.rm(K),await sr(e.fs,Qt(K),o))}return A}async function ba(e,t){let n=e.workTree,r=await j(e,t),o=await Ke(e,r.tree),s=[];for(let i of o){let a=v(n,i.path);await e.fs.exists(a)?s.push(i.path):await dt(e,i)}return s.length>0?(s.sort(ya),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
721
+ `,J=rn({type:"commit",tree:K,parents:[],author:p,committer:g,message:te});O=await He(e,"commit",J)}let N=n?`On ${y}: ${n}`:`WIP on ${y}: ${x} ${b}`,H=[s,k];O&&H.push(O);let S=rn({type:"commit",tree:D,parents:H,author:p,committer:g,message:N}),A=await He(e,"commit",S),_=await Lr(e,0)??ee;await Ze(e,Zt,{oldHash:_,newHash:A,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:N.trimEnd()}),await Z(e,Zt,A);let F=await En(e,i.tree,a);await de(e,{version:2,entries:F.newEntries}),await Ne(e,F.worktreeOps),(await Q(e))?.type==="symbolic"&&await ce(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let L of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await he(e,L);for(let L of["MERGE_MSG","MERGE_MODE","SQUASH_MSG"]){let K=v(e.gitDir,L);await e.fs.exists(K)&&await e.fs.rm(K)}if(h.length>0)for(let L of h){if(C.has(L))continue;let K=v(o,L);await e.fs.exists(K)&&(await e.fs.rm(K),await sr(e.fs,Qt(K),o))}return A}async function ya(e,t){let n=e.workTree,r=await j(e,t),o=await Ke(e,r.tree),s=[];for(let i of o){let a=v(n,i.path);await e.fs.exists(a)?s.push(i.path):await dt(e,i)}return s.length>0?(s.sort(Ea),{ok:!1,stdout:"",stderr:`${s.map(i=>`${i} already exists, no checkout`).join(`
722
722
  `)}
723
723
  error: could not restore untracked files from stash
724
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ea(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
725
- `,exitCode:128};let n=await Gr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
724
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function ka(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
725
+ `,exitCode:128};let n=await Lr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
726
726
  `,exitCode:1};if(!await Y(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
727
727
  `,exitCode:1};let o=await z(e),s=Bt(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(C=>`${C}: needs merge`).join(`
728
728
  `)}
729
729
  `,stderr:`error: could not write index
730
730
  `,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)
731
- `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Le(o),d=await Fe(e,l),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let k=await ba(e,f);if(!k.ok)return{...k,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await Ut(e,c.tree,d,i.tree,u),h=await fe(e,d),p=await fe(e,m.resultTree),g=[];for(let[k,C]of p){let P=h.get(k);(!P||P.hash!==C.hash)&&g.push({path:k,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[k]of h)p.has(k)||g.push({path:k,type:"delete"});let w=new Map(l.map(k=>[k.path,k])),y=[],x=[];for(let k of g){let C=w.get(k.path),P=v(e.workTree,k.path);if(C){if(!await e.fs.exists(P))continue;let T=await e.fs.readFileBuffer(P);await pt("blob",T)!==C.hash&&y.push(k.path)}else k.type==="checkout"&&await e.fs.exists(P)&&x.push(k.path)}if(y.length>0||x.length>0){y.sort(ya),x.sort(ya);let k="";if(y.length>0&&(k+=`error: Your local changes to the following files would be overwritten by merge:
731
+ `,exitCode:1};let c=await j(e,a),f=i.parents[2],l=Le(o),d=await Fe(e,l),u={a:"Updated upstream",b:"Stashed changes"};if(c.tree===i.tree){if(f){let k=await ya(e,f);if(!k.ok)return{...k,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await Ut(e,c.tree,d,i.tree,u),h=await fe(e,d),p=await fe(e,m.resultTree),g=[];for(let[k,C]of p){let P=h.get(k);(!P||P.hash!==C.hash)&&g.push({path:k,type:"checkout",hash:C.hash,mode:parseInt(C.mode,8)})}for(let[k]of h)p.has(k)||g.push({path:k,type:"delete"});let w=new Map(l.map(k=>[k.path,k])),y=[],x=[];for(let k of g){let C=w.get(k.path),P=v(e.workTree,k.path);if(C){if(!await e.fs.exists(P))continue;let T=await e.fs.readFileBuffer(P);await pt("blob",T)!==C.hash&&y.push(k.path)}else k.type==="checkout"&&await e.fs.exists(P)&&x.push(k.path)}if(y.length>0||x.length>0){y.sort(Ea),x.sort(Ea);let k="";if(y.length>0&&(k+=`error: Your local changes to the following files would be overwritten by merge:
732
732
  ${y.map(C=>` ${C}`).join(`
733
733
  `)}
734
734
  Please commit your changes or stash them before you merge.
@@ -737,46 +737,46 @@ ${x.map(C=>` ${C}`).join(`
737
737
  `)}
738
738
  Please move or remove them before you merge.
739
739
  `),k+=`Aborting
740
- `,f){let C=await ba(e,f);C.ok||(k+=C.stderr)}return{ok:!1,stdout:"",stderr:k,exitCode:1}}await Ne(e,g);let b=new Set(m.conflicts.map(k=>k.path)),E=new Set;for(let k of m.entries)k.stage>0&&E.add(k.path);let R=b.size>0;if(R){let k=[];for(let[C,P]of p){if(b.has(C)||E.has(C))continue;let T=w.get(C);k.push({path:C,mode:parseInt(P.mode,8),hash:P.hash,stage:0,stat:T?.stat??Se()})}for(let C of m.entries)C.stage>0&&k.push(C);k.sort((C,P)=>Ie(C.path,P.path)||C.stage-P.stage),await de(e,{version:2,entries:k})}else{let k=[...o.entries],C=new Set(k.map(P=>P.path));for(let[P,T]of p)h.has(P)||C.has(P)||k.push({path:P,mode:parseInt(T.mode,8),hash:T.hash,stage:0,stat:Se()});k.sort((P,T)=>Ie(P.path,T.path)||P.stage-T.stage),await de(e,{version:2,entries:k})}if(f){let k=await ba(e,f);if(!k.ok)return{...k,messages:m.messages}}return{ok:!0,hasConflicts:R,messages:m.messages}}async function ka(e,t=0){let n=await et(e,Zt);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,Zt),await ts(e,Zt);else{await Ln(e,Zt,n);let o=n[n.length-1];o&&await Z(e,Zt,o.newHash)}return null}async function gd(e){await he(e,Zt),await ts(e,Zt)}Ae();function Uo(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 uw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({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:V.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:wd(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:wd(s,o.env,r.message,r["include-untracked"])}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:mw(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:hw(s,r.stash)}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:pw(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:gw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:$().alias("p").describe("Show full diff (default is --stat)")},args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:ww(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:bw(s)}})}async function wd(e,t,n,r){if(!await Y(e))return G(`You do not have the initial commit yet
740
+ `,f){let C=await ya(e,f);C.ok||(k+=C.stderr)}return{ok:!1,stdout:"",stderr:k,exitCode:1}}await Ne(e,g);let b=new Set(m.conflicts.map(k=>k.path)),E=new Set;for(let k of m.entries)k.stage>0&&E.add(k.path);let R=b.size>0;if(R){let k=[];for(let[C,P]of p){if(b.has(C)||E.has(C))continue;let T=w.get(C);k.push({path:C,mode:parseInt(P.mode,8),hash:P.hash,stage:0,stat:T?.stat??Se()})}for(let C of m.entries)C.stage>0&&k.push(C);k.sort((C,P)=>Ie(C.path,P.path)||C.stage-P.stage),await de(e,{version:2,entries:k})}else{let k=[...o.entries],C=new Set(k.map(P=>P.path));for(let[P,T]of p)h.has(P)||C.has(P)||k.push({path:P,mode:parseInt(T.mode,8),hash:T.hash,stage:0,stat:Se()});k.sort((P,T)=>Ie(P.path,T.path)||P.stage-T.stage),await de(e,{version:2,entries:k})}if(f){let k=await ya(e,f);if(!k.ok)return{...k,messages:m.messages}}return{ok:!0,hasConflicts:R,messages:m.messages}}async function Ra(e,t=0){let n=await et(e,Zt);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,Zt),await ns(e,Zt);else{await Ln(e,Zt,n);let o=n[n.length-1];o&&await Z(e,Zt,o.newHash)}return null}async function wd(e){await he(e,Zt),await ns(e,Zt)}Ae();function Wo(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 hw(e,t){let n=t.oldHash?await se(e,t.oldHash):"",r=t.newHash?await se(e,t.newHash):"";return It({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}function yd(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],i=[];for(let a of o)a.startsWith("-")?s.push(a):i.push(a);return i.length>0?[...s,"-m",i.join(" ")]:s},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:bd(s,o.env,r.message,r["include-untracked"])}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:V.string().alias("m").describe("Stash message"),"include-untracked":$().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:bd(s,o.env,r.message,r["include-untracked"])}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:pw(s,r.stash)}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:gw(s,r.stash)}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:ww(s)}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:bw(s,r.stash)}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",options:{patch:$().alias("p").describe("Show full diff (default is --stat)")},args:[q.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:yw(s,r.stash,r.patch)}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await W(o.fs,o.cwd,t);return M(s)?s:Ew(s)}})}async function bd(e,t,n,r){if(!await Y(e))return G(`You do not have the initial commit yet
741
741
  `);let s=await z(e),i=Bt(s).sort();if(i.length>0)return{stdout:`${i.map(l=>`${l}: needs merge`).join(`
742
742
  `)}
743
743
  `,stderr:`error: could not write index
744
- `,exitCode:1};let a;try{a=await pd(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()}
744
+ `,exitCode:1};let a;try{a=await gd(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()}
745
745
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
746
- `,stderr:"",exitCode:0}}async function mw(e,t){let n=Uo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Gr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await Ea(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
746
+ `,stderr:"",exitCode:0}}async function pw(e,t){let n=Wo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Lr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await ka(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
747
747
  `)}
748
748
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
749
749
  `,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.
750
750
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
751
751
  `)}
752
752
  `:"",l=await at(e);return{stdout:`${f}${l}The stash entry is kept in case you need it again.
753
- `,stderr:"",exitCode:1}}let s=await ka(e,n);if(s)return G(s);let i=o.messages.length>0?`${o.messages.join(`
753
+ `,stderr:"",exitCode:1}}let s=await Ra(e,n);if(s)return G(s);let i=o.messages.length>0?`${o.messages.join(`
754
754
  `)}
755
755
  `:"",a=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await at(e);return{stdout:`${i}${c}Dropped ${a} (${r})
756
- `,stderr:"",exitCode:0}}async function hw(e,t){let n=Uo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Ea(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
756
+ `,stderr:"",exitCode:0}}async function gw(e,t){let n=Wo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await ka(e,n);if(!r.ok){let a=r.messages?.length?`${r.messages.join(`
757
757
  `)}
758
758
  `:"",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(`
759
759
  `)}
760
- `:"",s=await at(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function pw(e){let t=await hd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
760
+ `:"",s=await at(e),i=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:i}}async function ww(e){let t=await pd(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
761
761
  `)}
762
- `,stderr:"",exitCode:0}}async function gw(e,t){let n=Uo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Gr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await ka(e,n);return o?G(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
763
- `,stderr:"",exitCode:0}}async function ww(e,t,n){let r=Uo(t);if(r<0)return G(`error: '${t}' is not a valid stash reference`);let o=await Gr(e,r);if(!o)return G(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return G("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await uw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await mn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function bw(e){return await gd(e),{stdout:"",stderr:"",exitCode:0}}oe();Ce();ge();tt();function yd(e,t){e.command("status",{description:"Show the working tree status",options:{short:$().alias("s").describe("Give the output in the short-format"),porcelain:$().describe("Give the output in a machine-parseable format"),branch:$().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await at(s),stderr:"",exitCode:0};let i=await Q(s),a=await Y(s),c;i&&i.type==="symbolic"?c=Pe(i.target):c="HEAD detached";let f=await z(s),l=Gi(f),d=await ji(s,a,f,l),u=await gt(s,f),m=[],h=[];for(let y of u)y.status==="untracked"?h.push(y.path):m.push({path:y.path,status:y.status});m.sort((y,x)=>Ie(y.path,x.path));let p=new Set(f.entries.map(y=>y.path)),g=Li(h,p);return{stdout:Rw(c,d,m,l,g,n.branch),stderr:"",exitCode:0}}})}var yw={"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 Ew(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function kw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function Rw(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(u=>[u.path,u])),c=new Map(t.map(u=>[u.path,u])),f=new Map(n.map(u=>[u.path,u])),l=new Set;for(let u of r)l.add(u.path);for(let u of t)l.add(u.path);for(let u of n)l.add(u.path);let d=[...l].sort();for(let u of d){let m=a.get(u);if(m){let y=yw[m.status]??"UU";i.push(`${y} ${Cs(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?Ew(h.status):" ",w=p?kw(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let y=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,y),b=h.displayPath.slice(y+4);i.push(`${g}${w} ${Cs(x)} -> ${Cs(b)}`)}else i.push(`${g}${w} ${Cs(u)}`)}for(let u of o)i.push(`?? ${Cs(u)}`);return i.length===0?"":`${i.join(`
762
+ `,stderr:"",exitCode:0}}async function bw(e,t){let n=Wo(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Lr(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await Ra(e,n);return o?G(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
763
+ `,stderr:"",exitCode:0}}async function yw(e,t,n){let r=Wo(t);if(r<0)return G(`error: '${t}' is not a valid stash reference`);let o=await Lr(e,r);if(!o)return G(`error: stash@{${r}} is not a valid reference`);let s=await j(e,o),i=s.parents[0];if(!i)return G("error: invalid stash commit (no parent)");let a=await j(e,i);if(n){let f=await Ve(e,a.tree,s.tree),l="";for(let d of f)l+=await hw(e,d);return{stdout:l,stderr:"",exitCode:0}}return{stdout:await mn(e,a.tree,s.tree),stderr:"",exitCode:0}}async function Ew(e){return await wd(e),{stdout:"",stderr:"",exitCode:0}}oe();Ce();ge();tt();function Ed(e,t){e.command("status",{description:"Show the working tree status",options:{short:$().alias("s").describe("Give the output in the short-format"),porcelain:$().describe("Give the output in a machine-parseable format"),branch:$().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await at(s),stderr:"",exitCode:0};let i=await Q(s),a=await Y(s),c;i&&i.type==="symbolic"?c=Pe(i.target):c="HEAD detached";let f=await z(s),l=Ni(f),d=await Li(s,a,f,l),u=await gt(s,f),m=[],h=[];for(let y of u)y.status==="untracked"?h.push(y.path):m.push({path:y.path,status:y.status});m.sort((y,x)=>Ie(y.path,x.path));let p=new Set(f.entries.map(y=>y.path)),g=_i(h,p);return{stdout:Cw(c,d,m,l,g,n.branch),stderr:"",exitCode:0}}})}var kw={"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 Rw(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function xw(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function Cw(e,t,n,r,o,s){let i=[];s&&(e==="HEAD detached"?i.push("## HEAD (no branch)"):i.push(`## ${e}`));let a=new Map(r.map(u=>[u.path,u])),c=new Map(t.map(u=>[u.path,u])),f=new Map(n.map(u=>[u.path,u])),l=new Set;for(let u of r)l.add(u.path);for(let u of t)l.add(u.path);for(let u of n)l.add(u.path);let d=[...l].sort();for(let u of d){let m=a.get(u);if(m){let y=kw[m.status]??"UU";i.push(`${y} ${Ps(u)}`);continue}let h=c.get(u),p=f.get(u),g=h?Rw(h.status):" ",w=p?xw(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let y=h.displayPath.indexOf(" -> "),x=h.displayPath.slice(0,y),b=h.displayPath.slice(y+4);i.push(`${g}${w} ${Ps(x)} -> ${Ps(b)}`)}else i.push(`${g}${w} ${Ps(u)}`)}for(let u of o)i.push(`?? ${Ps(u)}`);return i.length===0?"":`${i.join(`
764
764
  `)}
765
- `}function Cs(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}oe();qe();Ce();ae();ze();ge();Ae();fn();function xw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ee}function kd(e,t){e.command("switch",{description:"Switch branches",args:[q.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:V.string().alias("c").describe("Create and switch to a new branch"),forceCreate:V.string().alias("C").describe("Create/reset and switch to a branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:V.string().describe("Create a new orphan branch"),guess:$().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?I("--orphan and -c/-C are incompatible"):n.detach?I("--orphan and --detach are incompatible"):$w(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 Me(i,l,`invalid reference: ${l}`);return M(d)?d:Pw(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 Ed(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return I("missing branch or commit argument");if(a==="-")return Cw(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return Rd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await go(i,a);if(l)return Ed(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return I(`invalid reference: ${a}`)}})}async function Ps(e){return await Oe(e,"CHERRY_PICK_HEAD")?I(`cannot switch branch while cherry-picking
765
+ `}function Ps(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}oe();qe();Ce();ae();ze();ge();Ae();fn();function Pw(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??ee}function Rd(e,t){e.command("switch",{description:"Switch branches",args:[q.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:V.string().alias("c").describe("Create and switch to a new branch"),forceCreate:V.string().alias("C").describe("Create/reset and switch to a branch"),detach:$().alias("d").describe("Detach HEAD at named commit"),orphan:V.string().describe("Create a new orphan branch"),guess:$().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await W(r.fs,r.cwd,t);if(M(s))return s;let i=s,a=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?I("--orphan and -c/-C are incompatible"):n.detach?I("--orphan and --detach are incompatible"):Iw(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 Me(i,l,`invalid reference: ${l}`);return M(d)?d:Ow(i,l,d.hash,r.env,t)}if(n.create||n.forceCreate){let l=n.create||n.forceCreate,d=a??(o.passthrough.length>0?o.passthrough[0]:void 0);return kd(i,l,!!n.forceCreate,d,r.env,t)}if(!a)return I("missing branch or commit argument");if(a==="-")return $w(i,r.env,t);let c=`refs/heads/${a}`,f=await B(i,c);if(f)return xd(i,a,c,f,r.env,t);if(n.guess!==!1){let l=await wo(i,a);if(l)return kd(i,a,!1,l.startPoint,r.env,t,l.trackingRef)}return I(`invalid reference: ${a}`)}})}async function $s(e){return await Oe(e,"CHERRY_PICK_HEAD")?I(`cannot switch branch while cherry-picking
766
766
  Consider "git cherry-pick --quit" or "git worktree add".`):await Oe(e,"MERGE_HEAD")?I(`cannot switch branch while merging
767
767
  Consider "git merge --quit" or "git worktree add".`):await Oe(e,"REVERT_HEAD")?I(`cannot switch branch while reverting
768
768
  Consider "git revert --quit" or "git worktree add".`):await Nt(e)?I(`cannot switch branch while rebasing
769
- Consider "git rebase --quit" or "git worktree add".`):null}async function Cw(e,t,n){let r=await Ps(e);if(r)return r;let o=await lo(e);return o?Rd(e,o.name,o.refName,o.hash,t,n):I("no previous branch")}async function Ed(e,t,n,r,o,s,i){if(!wn(t))return I(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return I(`a branch named '${t}' already exists`);let f;if(r){let T=await Me(e,r,`invalid reference: ${r}`);if(M(T))return T;f=T.hash}else{let T=await Y(e);if(!T){let D=await Q(e),O=D?.type==="symbolic"?D.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Xe(e,"HEAD",a),await yt(e);let N=await xn(e);return await ce(e,o,"HEAD",null,ee,`checkout: moving from ${O} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
770
- ${N}`,exitCode:0}}f=T}let l=await Ps(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(d))return{stdout:"",stderr:d.message??"",exitCode:1};let u=await Y(e),m=await z(e);if(r){let T=qn(m);if(T)return T}let h=await j(e,f);if(u&&u!==f){let T=await j(e,u);if(T.tree!==h.tree){let D=await Fn(e,T.tree,h.tree,m);if(!D.success)return D.errorOutput??G("error: checkout would overwrite local changes");m={version:2,entries:D.newEntries},await de(e,m),await Ne(e,D.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&u&&(g=await ho(e,u,f));let w=xw(p,u);await Z(e,a,f),await Xe(e,"HEAD",a),await yt(e);let y=await xn(e),x=r??"HEAD";n&&c?c!==f&&await ce(e,o,a,c,f,`branch: Reset to ${x}`):await ce(e,o,a,null,f,`branch: Created from ${x}`),await ce(e,o,"HEAD",u,f,`checkout: moving from ${w} to ${t}`);let b="";if(i){let T=i.replace(/^refs\/remotes\//,"").split("/"),D=T[0]??"",O=`refs/heads/${T.slice(1).join("/")}`,N=await we(e);N[`branch "${t}"`]={...N[`branch "${t}"`],remote:D,merge:O},await Je(e,N),b=`branch '${t}' set up to track '${D}/${T.slice(1).join("/")}'.
771
- `}else r&&(b=await po(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:u,newHead:f,isBranchCheckout:!0});let E=n&&c?`Switched to and reset branch '${t}'
769
+ Consider "git rebase --quit" or "git worktree add".`):null}async function $w(e,t,n){let r=await $s(e);if(r)return r;let o=await uo(e);return o?xd(e,o.name,o.refName,o.hash,t,n):I("no previous branch")}async function kd(e,t,n,r,o,s,i){if(!wn(t))return I(`'${t}' is not a valid branch name`);let a=`refs/heads/${t}`,c=await B(e,a);if(c&&!n)return I(`a branch named '${t}' already exists`);let f;if(r){let T=await Me(e,r,`invalid reference: ${r}`);if(M(T))return T;f=T.hash}else{let T=await Y(e);if(!T){let D=await Q(e),O=D?.type==="symbolic"?D.target.replace(/^refs\/heads\//,""):"";n&&c&&await he(e,a),await Xe(e,"HEAD",a),await yt(e);let N=await xn(e);return await ce(e,o,"HEAD",null,ee,`checkout: moving from ${O} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
770
+ ${N}`,exitCode:0}}f=T}let l=await $s(e);if(l)return l;let d=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"create-branch"});if(le(d))return{stdout:"",stderr:d.message??"",exitCode:1};let u=await Y(e),m=await z(e);if(r){let T=qn(m);if(T)return T}let h=await j(e,f);if(u&&u!==f){let T=await j(e,u);if(T.tree!==h.tree){let D=await Fn(e,T.tree,h.tree,m);if(!D.success)return D.errorOutput??G("error: checkout would overwrite local changes");m={version:2,entries:D.newEntries},await de(e,m),await Ne(e,D.worktreeOps)}}let p=await Q(e),g="";p?.type==="direct"&&u&&(g=await po(e,u,f));let w=Pw(p,u);await Z(e,a,f),await Xe(e,"HEAD",a),await yt(e);let y=await xn(e),x=r??"HEAD";n&&c?c!==f&&await ce(e,o,a,c,f,`branch: Reset to ${x}`):await ce(e,o,a,null,f,`branch: Created from ${x}`),await ce(e,o,"HEAD",u,f,`checkout: moving from ${w} to ${t}`);let b="";if(i){let T=i.replace(/^refs\/remotes\//,"").split("/"),D=T[0]??"",O=`refs/heads/${T.slice(1).join("/")}`,N=await we(e);N[`branch "${t}"`]={...N[`branch "${t}"`],remote:D,merge:O},await Je(e,N),b=`branch '${t}' set up to track '${D}/${T.slice(1).join("/")}'.
771
+ `}else r&&(b=await go(e,t,r));await s?.hooks?.postCheckout?.({repo:e,prevHead:u,newHead:f,isBranchCheckout:!0});let E=n&&c?`Switched to and reset branch '${t}'
772
772
  `:`Switched to a new branch '${t}'
773
- `,R=g+E+y+b,k="";r&&(k=await lr(e,h.tree,m));let C=await we(e),P=await Rn(e,C,t);return P&&(k+=fr(P)),{stdout:k,stderr:R,exitCode:0}}async function Rd(e,t,n,r,o,s){let i=await Ps(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return le(a)?{stdout:"",stderr:a.message??"",exitCode:1}:dr(e,t,n,r,o,s)}async function Pw(e,t,n,r,o){let s=await Ps(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return le(i)?{stdout:"",stderr:i.message??"",exitCode:1}:zn(e,n,r,o)}async function $w(e,t,n,r){if(!wn(t))return I(`'${t}' is not a valid branch name`);let o=await Ps(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return I(`a branch named '${t}' already exists`);let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Ni(e,f)),e.workTree){let m=f?(await j(e,f)).tree:null,h=await Fe(e,[]),p=await Fn(e,m,h,a);if(!p.success)return p.errorOutput??G("error: checkout would overwrite local changes");await Ne(e,p.worktreeOps),await de(e,{version:2,entries:p.newEntries})}else await de(e,za());await Xe(e,"HEAD",s),await yt(e);let u=await xn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ee,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
774
- ${u}`,exitCode:0}}oe();ae();Cr();ge();ss();function Cd(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[q.string().name("name").describe("Tag name to create or delete").optional(),q.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:$().alias("a").describe("Make an annotated tag object"),message:V.string().alias("m").describe("Tag message"),delete:$().alias("d").describe("Delete a tag"),force:$().alias("f").describe("Replace an existing tag"),list:$().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.delete){if(!n.name)return I("tag name required");let i=`refs/tags/${n.name}`,a=await B(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${X(a)})
773
+ `,R=g+E+y+b,k="";r&&(k=await lr(e,h.tree,m));let C=await we(e),P=await Rn(e,C,t);return P&&(k+=fr(P)),{stdout:k,stderr:R,exitCode:0}}async function xd(e,t,n,r,o,s){let i=await $s(e);if(i)return i;let a=await s?.hooks?.preCheckout?.({repo:e,target:t,mode:"switch"});return le(a)?{stdout:"",stderr:a.message??"",exitCode:1}:dr(e,t,n,r,o,s)}async function Ow(e,t,n,r,o){let s=await $s(e);if(s)return s;let i=await o?.hooks?.preCheckout?.({repo:e,target:t,mode:"detach"});return le(i)?{stdout:"",stderr:i.message??"",exitCode:1}:zn(e,n,r,o)}async function Iw(e,t,n,r){if(!wn(t))return I(`'${t}' is not a valid branch name`);let o=await $s(e);if(o)return o;let s=`refs/heads/${t}`;if(await B(e,s))return I(`a branch named '${t}' already exists`);let a=await z(e),c=qn(a);if(c)return c;let f=await Y(e),l=await Q(e),d="";if(l?.type==="direct"&&f&&(d=await Fi(e,f)),e.workTree){let m=f?(await j(e,f)).tree:null,h=await Fe(e,[]),p=await Fn(e,m,h,a);if(!p.success)return p.errorOutput??G("error: checkout would overwrite local changes");await Ne(e,p.worktreeOps),await de(e,{version:2,entries:p.newEntries})}else await de(e,Ka());await Xe(e,"HEAD",s),await yt(e);let u=await xn(e);return await r?.hooks?.postCheckout?.({repo:e,prevHead:f,newHead:ee,isBranchCheckout:!0}),{stdout:"",stderr:`${d}Switched to a new branch '${t}'
774
+ ${u}`,exitCode:0}}oe();ae();Pr();ge();os();function Pd(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[q.string().name("name").describe("Tag name to create or delete").optional(),q.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:$().alias("a").describe("Make an annotated tag object"),message:V.string().alias("m").describe("Tag message"),delete:$().alias("d").describe("Delete a tag"),force:$().alias("f").describe("Replace an existing tag"),list:$().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await W(r.fs,r.cwd,t);if(M(o))return o;let s=o;if(n.delete){if(!n.name)return I("tag name required");let i=`refs/tags/${n.name}`,a=await B(s,i);return a?(await he(s,i),{stdout:`Deleted tag '${n.name}' (was ${X(a)})
775
775
  `,stderr:"",exitCode:0}):G(`error: tag '${n.name}' not found.
776
- `)}if(n.list)return xd(s,n.name||void 0);if(n.name){if(!Ic(n.name))return I(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await wt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Y(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(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 nt(s,r.env);if(M(d))return d;let u=Mt(n.message),m=Cc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:u}),h=await He(s,"tag",m);await Z(s,c,h)}else await Z(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return xd(s)}})}async function xd(e,t){let n=await pe(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=>on(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
776
+ `)}if(n.list)return Cd(s,n.name||void 0);if(n.name){if(!Sc(n.name))return I(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await wt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Y(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(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 nt(s,r.env);if(M(d))return d;let u=Mt(n.message),m=Pc({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:u}),h=await He(s,"tag",m);await Z(s,c,h)}else await Z(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Cd(s)}})}async function Cd(e,t){let n=await pe(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=>on(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
777
777
  `)}
778
- `,stderr:"",exitCode:0}}var Pd=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"]),Ow={init:(e,t)=>Ml(e,t),clone:(e,t)=>cl(e,t),describe:(e,t)=>ll(e,t),fetch:(e,t)=>$l(e,t),pull:(e,t)=>ed(e,t),push:(e,t)=>td(e,t),add:(e,t)=>Vc(e,t),blame:(e,t)=>Sf(e,t),commit:(e,t)=>dl(e,t),status:(e,t)=>yd(e,t),log:(e,t)=>ql(e,t),branch:(e,t)=>vf(e,t),tag:(e,t)=>Cd(e,t),checkout:(e,t)=>Hf(e,t),diff:(e,t)=>kl(e,t),reset:(e,t)=>od(e,t),merge:(e,t)=>Vl(e,t),"cherry-pick":(e,t)=>Kf(e,t),revert:(e,t)=>fd(e,t),rebase:(e,t)=>Ql(e,t),mv:(e,t)=>Yl(e,t),rm:(e,t)=>ld(e,t),remote:(e,t)=>rd(e,t),config:(e,t)=>pl(e,t),show:(e,t)=>dd(e,t),stash:(e,t)=>bd(e,t),"rev-parse":(e,t)=>cd(e,t),"ls-files":(e,t)=>Kl(e,t),clean:(e,t)=>Vf(e,t),switch:(e,t)=>kd(e,t),restore:(e,t)=>ad(e,t),reflog:(e,t)=>nd(e,t),repack:(e,t)=>Sl(e,t),gc:(e,t)=>Tl(e,t),bisect:(e,t)=>pf(e,t),grep:(e,t)=>Dl(e,t)};function $d(e){let t=Vo("git",{description:"Git command"});for(let n of Object.values(Ow))n(t,e);return t.command("help",{description:"Display help information",args:[q.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:br(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:br(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
779
- `,exitCode:1}}}),t}var Iw="1.5.1";function Sw(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 Bo=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=Sw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=$d(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Tw(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 ${Iw} (virtual git implementation)
778
+ `,stderr:"",exitCode:0}}var $d=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),Sw={init:(e,t)=>jl(e,t),clone:(e,t)=>fl(e,t),describe:(e,t)=>dl(e,t),fetch:(e,t)=>Ol(e,t),pull:(e,t)=>td(e,t),push:(e,t)=>nd(e,t),add:(e,t)=>Yc(e,t),blame:(e,t)=>Tf(e,t),commit:(e,t)=>ul(e,t),status:(e,t)=>Ed(e,t),log:(e,t)=>zl(e,t),branch:(e,t)=>Af(e,t),tag:(e,t)=>Pd(e,t),checkout:(e,t)=>Df(e,t),diff:(e,t)=>Rl(e,t),reset:(e,t)=>id(e,t),merge:(e,t)=>Yl(e,t),"cherry-pick":(e,t)=>Vf(e,t),revert:(e,t)=>ld(e,t),rebase:(e,t)=>ed(e,t),mv:(e,t)=>Xl(e,t),rm:(e,t)=>dd(e,t),remote:(e,t)=>sd(e,t),config:(e,t)=>gl(e,t),show:(e,t)=>ud(e,t),stash:(e,t)=>yd(e,t),"rev-parse":(e,t)=>fd(e,t),"ls-files":(e,t)=>Vl(e,t),clean:(e,t)=>Yf(e,t),switch:(e,t)=>Rd(e,t),restore:(e,t)=>cd(e,t),reflog:(e,t)=>rd(e,t),repack:(e,t)=>Tl(e,t),gc:(e,t)=>vl(e,t),bisect:(e,t)=>gf(e,t),grep:(e,t)=>Ml(e,t)};function Od(e){let t=Xo("git",{description:"Git command"});for(let n of Object.values(Sw))n(t,e);return t.command("help",{description:"Display help information",args:[q.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:yr(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:yr(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
779
+ `,exitCode:1}}}),t}var Tw="1.5.2";function vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var qo=class{name="git";defaultFs;defaultCwd;blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=vw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,credentialCache:new Map,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Od(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Aw(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 ${Tw} (virtual git implementation)
780
780
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
781
- `,exitCode:1};if(r&&Pd.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
782
- `,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(le(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 Tw(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 vw(e){return new Bo(e)}var Od=new TextEncoder,Aw=new TextDecoder;function hn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function Wo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ra=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=hn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Od.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=Wo(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 hn(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("/")?hn(a):hn(Wo(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=hn(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("/")?hn(f):hn(Wo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Aw.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"?Od.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=hn(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=Wo(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=hn(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=hn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};Gn();export{Bo as Git,Ra as MemoryFileSystem,Th as composeGitHooks,vw as createGit,tr as findRepo,le as isRejection};
781
+ `,exitCode:1};if(r&&$d.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
782
+ `,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(le(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 Aw(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 Hw(e){return new qo(e)}var Id=new TextEncoder,Dw=new TextDecoder;function hn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function zo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var xa=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=hn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Id.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=zo(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 hn(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("/")?hn(a):hn(zo(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=hn(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("/")?hn(f):hn(zo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Dw.decode(await this.readFileBuffer(t))}async readFileBuffer(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}async writeFile(t,n){let r=this.resolve(t);this.ensureParents(r),this.data.set(r,{type:"file",content:typeof n=="string"?Id.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=hn(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=zo(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=hn(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=hn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};Gn();export{qo as Git,xa as MemoryFileSystem,vh as composeGitHooks,Hw as createGit,tr as findRepo,le as isRejection};