just-git 0.1.6 → 0.1.7

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,9 +1,7 @@
1
- var Er=(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 Ts=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 Bo(e){return new Ts({_kind:"arg",type:e,required:!0})}function Wo(){return Bo("string")}function qo(){return Bo("number")}var xr=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 Hs=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}};function Ko(e){return new Hs({_kind:"option",type:e})}function zo(){return Ko("string")}function Vo(){return Ko("number")}var te={string:zo,number:Vo};function v(){return new xr}var W={string:Wo,number:qo};function af(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}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`Unknown command "${e.path}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}}}function As(e){return e.map(af).join(`
2
- `)}function cf(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 a=1;a<=r;a++){let i=e[s-1]===t[a-1]?0:1;o[s*(r+1)+a]=Math.min(o[(s-1)*(r+1)+a]+1,o[s*(r+1)+(a-1)]+1,o[(s-1)*(r+1)+(a-1)]+i)}return o[n*(r+1)+r]}function kr(e,t,n=3){return t.map(o=>({candidate:o,distance:cf(e,o)})).filter(o=>o.distance<=n&&o.distance>0).sort((o,s)=>o.distance-s.distance).slice(0,2).map(o=>o.candidate)}function Yo(e,t,n,r){let o=[],s=new Map,a=new Map;for(let[l,m]of Object.entries(e)){let h=Kn(l);s.set(h,{key:l,def:m}),m.short&&a.set(m.short,{key:l,def:m})}let i={},c=[],f=[],d=0;for(;d<n.length;){let l=n[d];if(l==="--"){for(d++;d<n.length;)f.push(n[d]),d++;break}if(l.startsWith("--")){let m=l.indexOf("="),h,p;m!==-1?(h=l.slice(2,m),p=l.slice(m+1)):h=l.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let E=s.get(h.slice(3));if(E&&E.def._kind==="flag"){i[E.key]=E.def.counted?0:!1,d++;continue}}let b=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:kr(h,b).map(E=>`--${E}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?i[g.key]=(i[g.key]||0)+1:i[g.key]=!0,d++;continue}let w=p??n[++d];if(w===void 0){o.push({type:"missing_value",name:g.key}),d++;continue}let x=qn(w,g.def.type,g.key,o);x!==void 0&&(i[g.key]=x),d++;continue}if(l.startsWith("-")&&l.length>1){let m=l.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=a.get(p);if(!g){let E=[];s.has(p)&&E.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:E});continue}if(g.def._kind==="flag"){g.def.counted?i[g.key]=(i[g.key]||0)+1:i[g.key]=!0;continue}let w=m.slice(h+1),x=w.length>0?w:n[++d];if(x===void 0){o.push({type:"missing_value",name:g.key});break}let b=qn(x,g.def.type,g.key,o);b!==void 0&&(i[g.key]=b);break}d++;continue}c.push(l),d++}let u=0;for(let l=0;l<t.length;l++){let m=t[l],h=m.name??`arg${l}`;if(m.variadic){let p=c.slice(u);p.length>0?i[h]=p.map(g=>qn(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?i[h]=m.default:i[h]=[],u=c.length}else{let p=c[u];p!==void 0?(i[h]=qn(p,m.type,h,o),u++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(i[h]=m.default)}}if(u<c.length)for(let l=u;l<c.length;l++)o.push({type:"unexpected_positional",value:c[l],maxPositionals:t.length});for(let[l,m]of Object.entries(e))if(i[l]===void 0){if(m._kind==="flag")i[l]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=qn(r[h.env],h.type,l,o);p!==void 0&&(i[l]=p)}i[l]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:l,kind:"option"}):h.default!==void 0&&(i[l]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:i,passthrough:f}}function qn(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 Kn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function vs(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 a of o){let i=a.name??"arg",c=a.variadic?`${i}...`:i;r.push(a.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let a=[];for(let[c,f]of e.children)a.push([c,f.description||""]);let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let a=[];for(let c of o){let f=c.name??"arg",d=c.variadic?`${f}...`:f,u=[];c.description&&u.push(c.description),c.required&&u.push("(required)"),c.default!==void 0&&u.push(`(default: ${JSON.stringify(c.default)})`),a.push([d,u.join(" ")])}let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=ff(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let a of e.examples)t.push(` ${a}`);t.push("")}return t.join(`
3
- `)}function ff(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[a,i]of n){let c=Kn(a);if(i._kind==="flag"){let f=i,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c}`);let u=[];f.description&&u.push(f.description),f.counted&&u.push("(counted)"),f.default!==void 0&&u.push(`(default: ${f.default})`),r.push([d.join(" "),u.join(" ")])}else{let f=i,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c} <${f.type}>`);let u=[];f.description&&u.push(f.description),f.required&&u.push("(required)"),f.default!==void 0&&u.push(`(default: ${JSON.stringify(f.default)})`),f.env&&u.push(`[env: ${f.env}]`),r.push([d.join(" "),u.join(" ")])}}let o=Math.max(...r.map(([a])=>a.length)),s=[];t&&s.push(t);for(let[a,i]of r)if(i){let c=" ".repeat(o-a.length+2);s.push(` ${a}${c}${i}`)}else s.push(` ${a}`);return s}function Xo(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Zo(e){return e?e.map(t=>t._def):[]}var Cr=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,a,i){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=a,this.transformArgs=i}command(t,n){let r=new e(t,n.description,Xo(n.options),Zo(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,a]of Object.entries(r)){let i=o[s],c=Kn(s);if(a._kind==="flag")if(a.counted&&typeof i=="number"&&i>0)for(let f=0;f<i;f++)n.push(`--${c}`);else i===!0?n.push(`--${c}`):i===!1&&a.default===!0&&n.push(`--no-${c}`);else a._kind==="option"&&i!==void 0&&n.push(`--${c}`,String(i))}for(let s of this.args){let a=s.name??"arg",i=o[a];if(i!==void 0)if(s.variadic&&Array.isArray(i))for(let c of i)n.push(String(c));else n.push(String(i))}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,a]of Object.entries(o))if(r[s]===void 0){if(a._kind==="flag")r[s]=a.default??(a.counted?0:!1);else if(a._kind==="option"){if(a.default!==void 0)r[s]=a.default;else if(a.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let a=s.name??"arg";if(r[a]===void 0){if(s.default!==void 0)r[a]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${a}"`,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(df(t))return{stdout:vs(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],a=Yo(this.allOptions,this.args,s,r);if(!a.ok)return{stdout:"",stderr:As(a.errors),exitCode:1};try{return await this.handler(a.args,n,{passthrough:a.passthrough})}catch(i){return{stdout:"",stderr:i instanceof Error?i.message:String(i),exitCode:1}}}if(o&&!o.startsWith("-")){let s=kr(o,[...this.children.keys()]);return{stdout:"",stderr:As([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:vs(this),stderr:"",exitCode:0}}};function Ss(e,t){return new Cr(e,t.description,Xo(t.options),Zo(t.args),t.examples??[],t.handler,t.transformArgs)}function df(e){return e.some(t=>t==="--help"||t==="-h")}function Pr(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 a of r)a===""||a==="."||(a===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(a));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function H(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Pr(t)}function ft(...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 Pr(t||".")}function Pt(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 zn(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 Ke(e,t){let n=Pr(e),r=Pr(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),a=n.charCodeAt(0)===47,i=r.charCodeAt(0)===47,f=a&&i?1:0,d=Math.min(o.length,s.length);for(;f<d&&o[f]===s[f];)f++;let u=o.length-f,l=s.slice(f),m=[];for(let h=0;h<u;h++)m.push("..");for(let h of l)m.push(h);return m.join("/")||"."}function lf(e){let t={},n=null;for(let r of e.split(`
4
- `)){let o=r.trim();if(!(!o||o.startsWith("#")||o.startsWith(";"))){if(o.startsWith("[")){let s=o.indexOf("]");if(s===-1)continue;n=o.slice(1,s).trim(),n in t||(t[n]={});continue}if(n!==null){let s=t[n];if(!s)continue;let a=o.indexOf("=");if(a===-1){let i=o.trim().toLowerCase();s[i]="true"}else{let i=o.slice(0,a).trim().toLowerCase(),c=o.slice(a+1).trim();s[i]=c}}}}return t}function Ds(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} = ${s}`)}return`${t.join(`
1
+ var td=Object.defineProperty;var Yr=(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 be=(e,t)=>()=>(e&&(t=e(e=0)),t);var nd=(e,t)=>{for(var n in t)td(e,n,{get:t[n],enumerable:!0})};function Qr(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 a of r)a===""||a==="."||(a===".."?t||o.length>0&&o[o.length-1]!==".."?o.pop():o.push(".."):o.push(a));let s=o.join("/");return t&&(s=`/${s}`),n&&s.length>1&&!s.endsWith("/")&&(s+="/"),s||(t?"/":n?"./":".")}function H(...e){if(e.length===0)return".";let t=e.filter(n=>n!=="").join("/");return t===""?".":Qr(t)}function xt(...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 Qr(t||".")}function Lt(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 gr(e,t){if(e==="")return"";let n=e.length;for(;n>1&&e.charCodeAt(n-1)===47;)n--;let r=e.slice(0,n);if(r==="/")return"";let o=r.lastIndexOf("/"),s=o===-1?r:r.slice(o+1);return t&&s.endsWith(t)&&s.length>t.length?s.slice(0,s.length-t.length):s}function rt(e,t){let n=Qr(e),r=Qr(t);if(n===r)return"";let o=n==="/"?[""]:n.split("/"),s=r==="/"?[""]:r.split("/"),a=n.charCodeAt(0)===47,i=r.charCodeAt(0)===47,f=a&&i?1:0,d=Math.min(o.length,s.length);for(;f<d&&o[f]===s[f];)f++;let u=o.length-f,l=s.slice(f),m=[];for(let h=0;h<u;h++)m.push("..");for(let h of l)m.push(h);return m.join("/")||"."}var fe=be(()=>{"use strict"});function ad(e){let t={},n=null;for(let r of e.split(`
2
+ `)){let o=r.trim();if(!(!o||o.startsWith("#")||o.startsWith(";"))){if(o.startsWith("[")){let s=o.indexOf("]");if(s===-1)continue;n=o.slice(1,s).trim(),n in t||(t[n]={});continue}if(n!==null){let s=t[n];if(!s)continue;let a=o.indexOf("=");if(a===-1){let i=o.trim().toLowerCase();s[i]="true"}else{let i=o.slice(0,a).trim().toLowerCase(),c=o.slice(a+1).trim();s[i]=c}}}}return t}function po(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} = ${s}`)}return`${t.join(`
5
3
  `)}
6
- `}async function ce(e){let t=H(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return lf(n)}async function Ge(e,t){let n=H(e.gitDir,"config");await e.fs.writeFile(n,Ds(t))}async function Et(e,t){let n=await ce(e),{section:r,key:o}=js(t);return n[r]?.[o]}async function Ms(e,t,n){let r=await ce(e),{section:o,key:s}=js(t);r[o]||(r[o]={}),r[o][s]=n,await Ge(e,r)}async function Jo(e,t){let n=await ce(e),{section:r,key:o}=js(t);return n[r]?.[o]?(delete n[r][o],Object.keys(n[r]).length===0&&delete n[r],await Ge(e,n),!0):!1}function js(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 uf={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 Or(e,t){return ei(e,t,"author")}function Vn(e,t){return ei(e,t,"committer")}async function ei(e,t,n){let r=uf[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Qo(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await Et(e,"user.name")??o?.name,a=t.get(r.email)??await Et(e,"user.email")??o?.email;if(!s||!a)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
4
+ `}async function me(e){let t=H(e.gitDir,"config");if(!await e.fs.exists(t))return{};let n=await e.fs.readFile(t);return ad(n)}async function Xe(e,t){let n=H(e.gitDir,"config");await e.fs.writeFile(n,po(t))}async function Dt(e,t){let n=await me(e),{section:r,key:o}=wo(t);return n[r]?.[o]}async function go(e,t,n){let r=await me(e),{section:o,key:s}=wo(t);r[o]||(r[o]={}),r[o][s]=n,await Xe(e,r)}async function ji(e,t){let n=await me(e),{section:r,key:o}=wo(t);return n[r]?.[o]?(delete n[r][o],Object.keys(n[r]).length===0&&delete n[r],await Xe(e,n),!0):!1}function wo(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 Ze=be(()=>{"use strict";fe()});function es(e,t){return Li(e,t,"author")}function wr(e,t){return Li(e,t,"committer")}async function Li(e,t,n){let r=cd[n],o=e.identityOverride;if(o?.locked)return{name:o.name,email:o.email,timestamp:Gi(t.get(r.date)),timezone:"+0000"};let s=t.get(r.name)??await Dt(e,"user.name")??o?.name,a=t.get(r.email)??await Dt(e,"user.email")??o?.email;if(!s||!a)throw new Error(`${n.charAt(0).toUpperCase()}${n.slice(1)} identity unknown
7
5
 
8
6
  *** Please tell me who you are.
9
7
 
@@ -11,106 +9,94 @@ Run
11
9
 
12
10
  git config user.email "you@example.com"
13
11
  git config user.name "Your Name"
14
- `);return{name:s,email:a,timestamp:Qo(t.get(r.date)),timezone:"+0000"}}async function Ot(e,t){try{let n=await Vn(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 Qo(e){if(e){let t=parseInt(e,10);if(!Number.isNaN(t))return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.floor(n/1e3)}return Math.floor(Date.now()/1e3)}var Z="0000000000000000000000000000000000000000",ti=(()=>{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 Kt(e){let t="";for(let n=0;n<20;n++)t+=ti[e[n]];return t}function Ir(e,t){let n="";for(let r=0;r<20;r++)n+=ti[e[t+r]];return n}function dt(e){let t=new Uint8Array(20);for(let n=0;n<20;n++)t[n]=parseInt(e.slice(n*2,n*2+2),16);return t}var mf=new TextEncoder;function Ls(e){return typeof e=="string"?mf.encode(e):e}function hf(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(Ls(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Er(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(Ls(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(Ls(n)),t},async hex(){let n=0;for(let a of e)n+=a.byteLength;let r=new Uint8Array(n),o=0;for(let a of e)r.set(a,o),o+=a.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return Kt(new Uint8Array(s))}};return t};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var ni=hf(),zt=ni;async function Rn(e){return ni().update(e).hex()}var ri=1145655875,Gs=2;async function U(e){let t=H(e.gitDir,"index");if(!await e.fs.exists(t))return{version:Gs,entries:[]};let n=await e.fs.readFileBuffer(t);return pf(n)}async function re(e,t){let n=H(e.gitDir,"index"),r=await gf(t);await e.fs.writeFile(n,r)}function Xe(e,t){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(Ns),{...e,entries:n}}function Ne(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Dt(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function lt(e){return e.entries.some(t=>t.stage>0)}function It(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function xe(e){return e.entries.filter(t=>t.stage===0)}function si(){return{version:Gs,entries:[]}}function Rr(e){let t=[...e].sort(Ns);return{version:Gs,entries:t}}function pe(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function pf(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==ri)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 a=[];for(let i=0;i<s;i++){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)},d=t.getUint32(n+24);n+=40;let u=e.subarray(n,n+20),l=Kt(u);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let b=n;for(;b<e.byteLength&&e[b]!==0;)b++;g=new TextDecoder().decode(e.subarray(n,b))}let w=62+g.length+1,x=Math.ceil(w/8)*8;n=c+x,a.push({path:g,mode:d,hash:l,stage:h,stat:f})}return{version:o,entries:a}}async function gf(e){let t=[...e.entries].sort(Ns),n=12;for(let d of t){let u=62+d.path.length+1;n+=Math.ceil(u/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),a=0;s.setUint32(a,ri),a+=4,s.setUint32(a,e.version),a+=4,s.setUint32(a,t.length),a+=4;for(let d of t){let u=a;s.setUint32(a,d.stat.ctimeSeconds),s.setUint32(a+4,d.stat.ctimeNanoseconds),s.setUint32(a+8,d.stat.mtimeSeconds),s.setUint32(a+12,d.stat.mtimeNanoseconds),s.setUint32(a+16,d.stat.dev),s.setUint32(a+20,d.stat.ino),s.setUint32(a+24,d.mode),s.setUint32(a+28,d.stat.uid),s.setUint32(a+32,d.stat.gid),s.setUint32(a+36,d.stat.size),a+=40;let l=dt(d.hash);o.set(l,a),a+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(a,h),a+=2;let p=new TextEncoder().encode(d.path);o.set(p,a),a+=p.byteLength,o[a]=0,a+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;a=u+w}let i=o.subarray(0,a),c=await Rn(i),f=dt(c);return o.set(f,a),o}function Ns(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var oi=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;oi[e]=t}function _s(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=oi[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}function wf(){try{let e=Er(["node","zlib"].join(":"));if(typeof e.deflateSync=="function"&&typeof e.inflateSync=="function")return{deflate:t=>Promise.resolve(new Uint8Array(e.deflateSync(t))),inflate:t=>Promise.resolve(new Uint8Array(e.inflateSync(t)))}}catch{}if(typeof globalThis.CompressionStream=="function"&&typeof globalThis.DecompressionStream=="function")return{async deflate(e){let t=new CompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())},async inflate(e){let t=new DecompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())}};throw new Error("No zlib implementation available. Requires Bun, Node.js, Deno, or a browser with CompressionStream.")}var ii=wf(),$n=ii.deflate,Mt=ii.inflate;var $r=1346454347,Us=2,fi=1,di=2,li=3,ui=4,Yn=6,Bs=7,bf={[fi]:"commit",[di]:"tree",[li]:"blob",[ui]:"tag"},mi={commit:fi,tree:di,blob:li,tag:ui};async function hi(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==$r)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${$r.toString(16)})`);let r=t.getUint32(4);if(r!==Us)throw new Error(`Unsupported pack version: ${r}`);let o=t.getUint32(8),s=[],a=12;for(let c=0;c<o;c++){let f=await yf(e,a);s.push(f),a=f.nextOffset}return(await Ef(s)).map((c,f)=>({...c,offset:s[f].headerOffset,nextOffset:s[f].nextOffset}))}async function yf(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,a=4;for(;r&128;)r=e[t++],s|=(r&127)<<a,a+=7;let i,c;if(o===Yn){let u=e[t++];for(i=u&127;u&128;)i+=1,u=e[t++],i=(i<<7)+(u&127);i=n-i}else o===Bs&&(c=Ir(e,t),t+=20);let{result:f,bytesConsumed:d}=await Cf(e,t,s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:i,baseHash:c,nextOffset:t+d}}async function Ef(e){let t=new Map;for(let o=0;o<e.length;o++)t.set(e[o].headerOffset,o);let n=new Array(e.length).fill(null);async function r(o){let s=n[o];if(s)return s;let a=e[o];if(a.typeNum!==Yn&&a.typeNum!==Bs){let u=bf[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let l={type:u,content:a.inflated,hash:await ci(u,a.inflated)};return n[o]=l,l}let i;if(a.typeNum===Yn){if(i=t.get(a.baseOffset),i===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`)}else if(i=await xf(e,n,a.baseHash,r),i===void 0)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let c=await r(i),f=Tr(c.content,a.inflated),d={type:c.type,content:f,hash:await ci(c.type,f)};return n[o]=d,d}for(let o=0;o<e.length;o++)await r(o);return n}async function xf(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!==Yn&&s.typeNum!==Bs&&(await r(o)).hash===n)return o}}function Tr(e,t){let n=0,{value:r,newPos:o}=ai(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:a}=ai(t,n);n=a;let i=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,u=0;f&1&&(d=t[n++]),f&2&&(d|=t[n++]<<8),f&4&&(d|=t[n++]<<16),f&8&&(d|=t[n++]<<24),f&16&&(u=t[n++]),f&32&&(u|=t[n++]<<8),f&64&&(u|=t[n++]<<16),u===0&&(u=65536),i.set(e.subarray(d,d+u),c),c+=u}else if(f>0)i.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 i}async function Hr(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,$r),r.setUint32(4,Us),r.setUint32(8,e.length),t.push(n);for(let d of e){let u=mi[d.type],l=await $n(d.content),m=Fs(u,d.content.byteLength);t.push(m),t.push(l)}let o=0;for(let d of t)o+=d.byteLength;o+=20;let s=new Uint8Array(o),a=0;for(let d of t)s.set(d,a),a+=d.byteLength;let i=zt();i.update(s.subarray(0,a));let c=await i.hex(),f=dt(c);return s.set(f,a),s}async function pi(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,$r),o.setUint32(4,Us),o.setUint32(8,e.length),t.push(r);let s=12,a=[];for(let l of e){let m=s;n.set(l.hash,s);let h=l.delta&&l.deltaBaseHash?n.get(l.deltaBaseHash):void 0;if(l.delta&&h!==void 0){let p=Fs(Yn,l.delta.byteLength),g=kf(s-h),w=await $n(l.delta);t.push(p,g,w),s+=p.byteLength+g.byteLength+w.byteLength}else{let p=mi[l.type],g=Fs(p,l.content.byteLength),w=await $n(l.content);t.push(g,w),s+=g.byteLength+w.byteLength}a.push({hash:l.hash,offset:m,nextOffset:s})}let i=0;for(let l of t)i+=l.byteLength;i+=20;let c=new Uint8Array(i),f=0;for(let l of t)c.set(l,f),f+=l.byteLength;let d=zt();d.update(c.subarray(0,f));let u=await d.hex();return c.set(dt(u),f),{data:c,entries:a}}function kf(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 Fs(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 ai(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 Cf(e,t,n){let r=e.subarray(t),o=await Mt(r);if(o.byteLength!==n)throw new Error(`Inflate size mismatch: got ${o.byteLength}, expected ${n}`);let s=2,a=r.byteLength;for(;s<a;){let i=s+a>>>1;try{(await Mt(r.subarray(0,i))).byteLength===n?a=i:s=i+1}catch{s=i+1}}return{result:o,bytesConsumed:s}}var Pf=new TextEncoder;async function ci(e,t){let n=Pf.encode(`${e} ${t.byteLength}\0`),r=zt();return r.update(n),r.update(t),r.hex()}var gi=4285812579,wi=2,hn=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==gi)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==wi)throw new Error(`Unsupported pack index version: ${n.getUint32(4)}`);this.fanout=new Uint32Array(256);let r=8;for(let s=0;s<256;s++)this.fanout[s]=n.getUint32(r),r+=4;this.count=this.fanout[255],this.hashes=new Uint8Array(t.buffer,t.byteOffset+r,this.count*20),r+=this.count*20,r+=this.count*4,this.offsets=new Uint32Array(this.count);for(let s=0;s<this.count;s++)this.offsets[s]=n.getUint32(r),r+=4;let o=!1;for(let s=0;s<this.count;s++)if(this.offsets[s]&2147483648){o=!0;break}this.largeOffsets=o?new DataView(t.buffer,t.byteOffset+r):null}lookup(t){let n=dt(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],a=o,i=s;for(;a<i;){let c=a+i>>>1,f=this.compareAt(c,n);if(f<0)a=c+1;else if(f>0)i=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++){let r="",o=n*20;for(let s=0;s<20;s++){let a=this.hashes[o+s];r+=(a>>4).toString(16)+(a&15).toString(16)}t.push(r)}return t}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],a=n[o];if(s<a)return-1;if(s>a)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}};async function bi(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,a=new Uint8Array(s),i=new DataView(a.buffer),c=0;i.setUint32(c,gi),c+=4,i.setUint32(c,wi),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++)i.setUint32(c,f[m]),c+=4;for(let m of n)a.set(dt(m.hash),c),c+=20;for(let m of n)i.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?i.setUint32(c,2147483648|d++):i.setUint32(c,m.offset),c+=4;for(let m of o)i.setBigUint64(c,m),c+=8;a.set(t,c),c+=20;let u=zt();u.update(a.subarray(0,c));let l=await u.hex();return a.set(dt(l),c),a}async function yi(e){let n=(await hi(e)).map(o=>({hash:o.hash,offset:o.offset,crc:_s(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return bi(n,r)}async function Ei(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:_s(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return bi(n,r)}var Of=6,If=7,Rf={1:"commit",2:"tree",3:"blob",4:"tag"},Xn=class{constructor(t,n){this.data=t;this.index=new hn(n)}index;hasObject(t){return this.index.has(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,a=o&15,i=4;for(;o&128;)o=n[r++],a|=(o&127)<<i,i+=7;if(s===Of){let d=n[r++],u=d&127;for(;d&128;)u+=1,d=n[r++],u=(u<<7)+(d&127);let l=await Mt(n.subarray(r)),m=await this.readAt(t-u);return{type:m.type,content:Tr(m.content,l)}}if(s===If){let d=Ir(n,r);r+=20;let u=await Mt(n.subarray(r)),l=this.index.lookup(d);if(l===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(l);return{type:m.type,content:Tr(m.content,u)}}let c=Rf[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await Mt(n.subarray(r));if(f.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${a}`);return{type:c,content:f}}};var $f=new TextEncoder,Tf=new TextDecoder;function qs(e,t){let n=$f.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Hf(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Tf.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),a=parseInt(r.slice(o+1),10),i=t.subarray(n+1);if(i.byteLength!==a)throw new Error(`Corrupt object ${e}: expected ${a} bytes, got ${i.byteLength}`);return{type:s,content:i}}function Ws(e,t){return H(e,"objects",t.slice(0,2),t.slice(2))}var Ar=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.hooks=r}packs=[];loadedPackNames=new Set;discoverPromise=null;async write(t,n){let r=qs(t,n),o=await Rn(r),s=Ws(this.gitDir,o);if(await this.fs.exists(s))return o;let a=H(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(a,{recursive:!0}),await this.fs.writeFile(s,await $n(r)),this.hooks?.emit("object:write",{type:t,hash:o}),o}async read(t){let n=Ws(this.gitDir,t);if(await this.fs.exists(n)){let r=await this.fs.readFileBuffer(n),o=await Mt(r);return Hf(t,o)}await this.discover();for(let r of this.packs){let o=await r.readObject(t);if(o)return o}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Ws(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.hasObject(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=Kt(o),a=H(this.gitDir,"objects","pack");await this.fs.mkdir(a,{recursive:!0});let i=`pack-${s}`,c=H(a,`${i}.pack`);await this.fs.writeFile(c,t);let f=await yi(t),d=H(a,`${i}.idx`);return await this.fs.writeFile(d,f),this.loadedPackNames.add(i),this.packs.push(new Xn(t,f)),r}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){let t=H(this.gitDir,"objects","pack");if(!await this.fs.exists(t))return;let n=await this.fs.readdir(t);for(let r of n){if(!r.endsWith(".idx"))continue;let o=r.slice(0,-4);if(this.loadedPackNames.has(o))continue;let s=H(t,`${o}.pack`);if(!await this.fs.exists(s))continue;let[a,i]=await Promise.all([this.fs.readFileBuffer(H(t,r)),this.fs.readFileBuffer(s)]);this.loadedPackNames.add(o),this.packs.push(new Xn(i,a))}}};function Zn(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),[a="0",i="+0000"]=s.split(" "),c=parseInt(a,10);return{name:r,email:o,timestamp:c,timezone:i}}function Jn(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Af=new TextEncoder,vf=new TextDecoder;function Rt(e){let t=vf.decode(e),n=t.indexOf(`
12
+ `);return{name:s,email:a,timestamp:Gi(t.get(r.date)),timezone:"+0000"}}async function Nt(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 Gi(e){if(e){let t=parseInt(e,10);if(!Number.isNaN(t))return t;let n=Date.parse(e);if(!Number.isNaN(n))return Math.floor(n/1e3)}return Math.floor(Date.now()/1e3)}var cd,ln=be(()=>{"use strict";Ze();cd={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 un(e){let t="";for(let n=0;n<20;n++)t+=Ni[e[n]];return t}function ts(e,t){let n="";for(let r=0;r<20;r++)n+=Ni[e[t+r]];return n}function Ct(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 J,Ni,at=be(()=>{"use strict";J="0000000000000000000000000000000000000000",Ni=(()=>{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 bo(e){return typeof e=="string"?fd.encode(e):e}function dd(){if(typeof globalThis.Bun<"u")return()=>{let e=new Bun.CryptoHasher("sha1"),t={update(n){return e.update(bo(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t};try{let e=Yr(["node","crypto"].join(":"));if(typeof e.createHash=="function")return()=>{let t=e.createHash("sha1"),n={update(r){return t.update(bo(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(bo(n)),t},async hex(){let n=0;for(let a of e)n+=a.byteLength;let r=new Uint8Array(n),o=0;for(let a of e)r.set(a,o),o+=a.byteLength;let s=await crypto.subtle.digest("SHA-1",r);return un(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 Xn(e){return _i().update(e).hex()}var fd,_i,mn,Dn=be(()=>{"use strict";at();fd=new TextEncoder;_i=dd(),mn=_i});async function W(e){let t=H(e.gitDir,"index");if(!await e.fs.exists(t))return{version:yo,entries:[]};let n=await e.fs.readFileBuffer(t);return ld(n)}async function ie(e,t){let n=H(e.gitDir,"index"),r=await ud(t);await e.fs.writeFile(n,r)}function ct(e,t){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(Eo),{...e,entries:n}}function Je(e,t){return{...e,entries:e.entries.filter(n=>n.path!==t)}}function Xt(e,t,n=0){return e.entries.find(r=>r.path===t&&r.stage===n)}function Pt(e){return e.entries.some(t=>t.stage>0)}function _t(e){return[...new Set(e.entries.filter(t=>t.stage>0).map(t=>t.path))]}function He(e){return e.entries.filter(t=>t.stage===0)}function Ui(){return{version:yo,entries:[]}}function ns(e){let t=[...e].sort(Eo);return{version:yo,entries:t}}function ke(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}function ld(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=0,r=t.getUint32(n);if(n+=4,r!==Fi)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 a=[];for(let i=0;i<s;i++){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)},d=t.getUint32(n+24);n+=40;let u=e.subarray(n,n+20),l=un(u);n+=20;let m=t.getUint16(n);n+=2;let h=m>>12&3,p=m&4095,g;if(p<4095)g=new TextDecoder().decode(e.subarray(n,n+p));else{let b=n;for(;b<e.byteLength&&e[b]!==0;)b++;g=new TextDecoder().decode(e.subarray(n,b))}let w=62+g.length+1,k=Math.ceil(w/8)*8;n=c+k,a.push({path:g,mode:d,hash:l,stage:h,stat:f})}return{version:o,entries:a}}async function ud(e){let t=[...e.entries].sort(Eo),n=12;for(let d of t){let u=62+d.path.length+1;n+=Math.ceil(u/8)*8}n+=20;let r=new ArrayBuffer(n),o=new Uint8Array(r),s=new DataView(r),a=0;s.setUint32(a,Fi),a+=4,s.setUint32(a,e.version),a+=4,s.setUint32(a,t.length),a+=4;for(let d of t){let u=a;s.setUint32(a,d.stat.ctimeSeconds),s.setUint32(a+4,d.stat.ctimeNanoseconds),s.setUint32(a+8,d.stat.mtimeSeconds),s.setUint32(a+12,d.stat.mtimeNanoseconds),s.setUint32(a+16,d.stat.dev),s.setUint32(a+20,d.stat.ino),s.setUint32(a+24,d.mode),s.setUint32(a+28,d.stat.uid),s.setUint32(a+32,d.stat.gid),s.setUint32(a+36,d.stat.size),a+=40;let l=Ct(d.hash);o.set(l,a),a+=20;let m=Math.min(d.path.length,4095),h=(d.stage&3)<<12|m;s.setUint16(a,h),a+=2;let p=new TextEncoder().encode(d.path);o.set(p,a),a+=p.byteLength,o[a]=0,a+=1;let g=62+p.byteLength+1,w=Math.ceil(g/8)*8;a=u+w}let i=o.subarray(0,a),c=await Xn(i),f=Ct(c);return o.set(f,a),o}function Eo(e,t){return e.path<t.path?-1:e.path>t.path?1:e.stage-t.stage}var Fi,yo,ye=be(()=>{"use strict";at();fe();Dn();Fi=1145655875,yo=2});function ko(e){let t=4294967295;for(let n=0;n<e.byteLength;n++)t=Bi[(t^e[n])&255]^t>>>8;return(t^4294967295)>>>0}var Bi,Wi=be(()=>{"use strict";Bi=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;Bi[e]=t}});function md(){try{let e=Yr(["node","zlib"].join(":"));if(typeof e.deflateSync=="function"&&typeof e.inflateSync=="function")return{deflate:t=>Promise.resolve(new Uint8Array(e.deflateSync(t))),inflate:t=>Promise.resolve(new Uint8Array(e.inflateSync(t)))}}catch{}if(typeof globalThis.CompressionStream=="function"&&typeof globalThis.DecompressionStream=="function")return{async deflate(e){let t=new CompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())},async inflate(e){let t=new DecompressionStream("deflate"),n=t.writable.getWriter();return n.write(e),n.close(),new Uint8Array(await new Response(t.readable).arrayBuffer())}};throw new Error("No zlib implementation available. Requires Bun, Node.js, Deno, or a browser with CompressionStream.")}var qi,Zn,Zt,rs=be(()=>{"use strict";qi=md(),Zn=qi.deflate,Zt=qi.inflate});async function Qi(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==ss)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${ss.toString(16)})`);let r=t.getUint32(4);if(r!==Co)throw new Error(`Unsupported pack version: ${r}`);let o=t.getUint32(8),s=[],a=12;for(let c=0;c<o;c++){let f=await pd(e,a);s.push(f),a=f.nextOffset}return(await gd(s)).map((c,f)=>({...c,offset:s[f].headerOffset,nextOffset:s[f].nextOffset}))}async function pd(e,t){let n=t,r=e[t++],o=r>>4&7,s=r&15,a=4;for(;r&128;)r=e[t++],s|=(r&127)<<a,a+=7;let i,c;if(o===br){let u=e[t++];for(i=u&127;u&128;)i+=1,u=e[t++],i=(i<<7)+(u&127);i=n-i}else o===Po&&(c=ts(e,t),t+=20);let{result:f,bytesConsumed:d}=await yd(e,t,s);return{headerOffset:n,typeNum:o,inflated:f,baseOffset:i,baseHash:c,nextOffset:t+d}}async function gd(e){let t=new Map;for(let o=0;o<e.length;o++)t.set(e[o].headerOffset,o);let n=new Array(e.length).fill(null);async function r(o){let s=n[o];if(s)return s;let a=e[o];if(a.typeNum!==br&&a.typeNum!==Po){let u=hd[a.typeNum];if(!u)throw new Error(`Unknown object type: ${a.typeNum}`);let l={type:u,content:a.inflated,hash:await zi(u,a.inflated)};return n[o]=l,l}let i;if(a.typeNum===br){if(i=t.get(a.baseOffset),i===void 0)throw new Error(`OFS_DELTA base not found at offset ${a.baseOffset}`)}else if(i=await wd(e,n,a.baseHash,r),i===void 0)throw new Error(`REF_DELTA base not found for hash ${a.baseHash}`);let c=await r(i),f=os(c.content,a.inflated),d={type:c.type,content:f,hash:await zi(c.type,f)};return n[o]=d,d}for(let o=0;o<e.length;o++)await r(o);return n}async function wd(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!==br&&s.typeNum!==Po&&(await r(o)).hash===n)return o}}function os(e,t){let n=0,{value:r,newPos:o}=Ki(t,n);if(n=o,r!==e.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${e.byteLength}`);let{value:s,newPos:a}=Ki(t,n);n=a;let i=new Uint8Array(s),c=0;for(;n<t.byteLength;){let f=t[n++];if(f&128){let d=0,u=0;f&1&&(d=t[n++]),f&2&&(d|=t[n++]<<8),f&4&&(d|=t[n++]<<16),f&8&&(d|=t[n++]<<24),f&16&&(u=t[n++]),f&32&&(u|=t[n++]<<8),f&64&&(u|=t[n++]<<16),u===0&&(u=65536),i.set(e.subarray(d,d+u),c),c+=u}else if(f>0)i.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 i}async function is(e){let t=[],n=new Uint8Array(12),r=new DataView(n.buffer);r.setUint32(0,ss),r.setUint32(4,Co),r.setUint32(8,e.length),t.push(n);for(let d of e){let u=Ji[d.type],l=await Zn(d.content),m=xo(u,d.content.byteLength);t.push(m),t.push(l)}let o=0;for(let d of t)o+=d.byteLength;o+=20;let s=new Uint8Array(o),a=0;for(let d of t)s.set(d,a),a+=d.byteLength;let i=mn();i.update(s.subarray(0,a));let c=await i.hex(),f=Ct(c);return s.set(f,a),s}async function ea(e){let t=[],n=new Map,r=new Uint8Array(12),o=new DataView(r.buffer);o.setUint32(0,ss),o.setUint32(4,Co),o.setUint32(8,e.length),t.push(r);let s=12,a=[];for(let l of e){let m=s;n.set(l.hash,s);let h=l.delta&&l.deltaBaseHash?n.get(l.deltaBaseHash):void 0;if(l.delta&&h!==void 0){let p=xo(br,l.delta.byteLength),g=bd(s-h),w=await Zn(l.delta);t.push(p,g,w),s+=p.byteLength+g.byteLength+w.byteLength}else{let p=Ji[l.type],g=xo(p,l.content.byteLength),w=await Zn(l.content);t.push(g,w),s+=g.byteLength+w.byteLength}a.push({hash:l.hash,offset:m,nextOffset:s})}let i=0;for(let l of t)i+=l.byteLength;i+=20;let c=new Uint8Array(i),f=0;for(let l of t)c.set(l,f),f+=l.byteLength;let d=mn();d.update(c.subarray(0,f));let u=await d.hex();return c.set(Ct(u),f),{data:c,entries:a}}function bd(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 xo(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 Ki(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 yd(e,t,n){let r=e.subarray(t),o=await Zt(r);if(o.byteLength!==n)throw new Error(`Inflate size mismatch: got ${o.byteLength}, expected ${n}`);let s=2,a=r.byteLength;for(;s<a;){let i=s+a>>>1;try{(await Zt(r.subarray(0,i))).byteLength===n?a=i:s=i+1}catch{s=i+1}}return{result:o,bytesConsumed:s}}async function zi(e,t){let n=Ed.encode(`${e} ${t.byteLength}\0`),r=mn();return r.update(n),r.update(t),r.hex()}var ss,Co,Vi,Yi,Xi,Zi,br,Po,hd,Ji,Ed,yr=be(()=>{"use strict";at();Dn();rs();ss=1346454347,Co=2,Vi=1,Yi=2,Xi=3,Zi=4,br=6,Po=7,hd={[Vi]:"commit",[Yi]:"tree",[Xi]:"blob",[Zi]:"tag"},Ji={commit:Vi,tree:Yi,blob:Xi,tag:Zi};Ed=new TextEncoder});async function ra(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,a=new Uint8Array(s),i=new DataView(a.buffer),c=0;i.setUint32(c,ta),c+=4,i.setUint32(c,na),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++)i.setUint32(c,f[m]),c+=4;for(let m of n)a.set(Ct(m.hash),c),c+=20;for(let m of n)i.setUint32(c,m.crc),c+=4;let d=0;for(let m of n)m.offset>=2147483648?i.setUint32(c,2147483648|d++):i.setUint32(c,m.offset),c+=4;for(let m of o)i.setBigUint64(c,m),c+=8;a.set(t,c),c+=20;let u=mn();u.update(a.subarray(0,c));let l=await u.hex();return a.set(Ct(l),c),a}async function sa(e){let n=(await Qi(e)).map(o=>({hash:o.hash,offset:o.offset,crc:ko(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ra(n,r)}async function oa(e,t){let n=t.map(o=>({hash:o.hash,offset:o.offset,crc:ko(e.subarray(o.offset,o.nextOffset))})),r=e.subarray(e.byteLength-20);return ra(n,r)}var ta,na,Mn,as=be(()=>{"use strict";at();Dn();Wi();yr();ta=4285812579,na=2,Mn=class{fanout;hashes;offsets;largeOffsets;count;constructor(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0)!==ta)throw new Error("Invalid pack index: bad magic");if(n.getUint32(4)!==na)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=Ct(t),r=n[0],o=r===0?0:this.fanout[r-1],s=this.fanout[r],a=o,i=s;for(;a<i;){let c=a+i>>>1,f=this.compareAt(c,n);if(f<0)a=c+1;else if(f>0)i=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++){let r="",o=n*20;for(let s=0;s<20;s++){let a=this.hashes[o+s];r+=(a>>4).toString(16)+(a&15).toString(16)}t.push(r)}return t}compareAt(t,n){let r=t*20;for(let o=0;o<20;o++){let s=this.hashes[r+o],a=n[o];if(s<a)return-1;if(s>a)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 kd,xd,Cd,Er,ia=be(()=>{"use strict";at();as();yr();rs();kd=6,xd=7,Cd={1:"commit",2:"tree",3:"blob",4:"tag"},Er=class{constructor(t,n){this.data=t;this.index=new Mn(n)}index;hasObject(t){return this.index.has(t)}async readObject(t){let n=this.index.lookup(t);return n===null?null:this.readAt(n)}get objectCount(){return this.index.objectCount}async readAt(t){let n=this.data,r=t,o=n[r++],s=o>>4&7,a=o&15,i=4;for(;o&128;)o=n[r++],a|=(o&127)<<i,i+=7;if(s===kd){let d=n[r++],u=d&127;for(;d&128;)u+=1,d=n[r++],u=(u<<7)+(d&127);let l=await Zt(n.subarray(r)),m=await this.readAt(t-u);return{type:m.type,content:os(m.content,l)}}if(s===xd){let d=ts(n,r);r+=20;let u=await Zt(n.subarray(r)),l=this.index.lookup(d);if(l===null)throw new Error(`REF_DELTA base ${d} not found in pack`);let m=await this.readAt(l);return{type:m.type,content:os(m.content,u)}}let c=Cd[s];if(!c)throw new Error(`Unknown pack object type: ${s}`);let f=await Zt(n.subarray(r));if(f.byteLength!==a)throw new Error(`Pack inflate size mismatch at offset ${t}: got ${f.byteLength}, expected ${a}`);return{type:c,content:f}}}});function Io(e,t){let n=Pd.encode(`${e} ${t.byteLength}\0`),r=new Uint8Array(n.byteLength+t.byteLength);return r.set(n),r.set(t,n.byteLength),r}function Id(e,t){let n=t.indexOf(0);if(n===-1)throw new Error(`Corrupt object ${e}: no null byte in header`);let r=Rd.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),a=parseInt(r.slice(o+1),10),i=t.subarray(n+1);if(i.byteLength!==a)throw new Error(`Corrupt object ${e}: expected ${a} bytes, got ${i.byteLength}`);return{type:s,content:i}}function Ro(e,t){return H(e,"objects",t.slice(0,2),t.slice(2))}var Pd,Rd,cs,aa=be(()=>{"use strict";at();as();ia();rs();fe();Dn();Pd=new TextEncoder,Rd=new TextDecoder;cs=class{constructor(t,n,r){this.fs=t;this.gitDir=n;this.hooks=r}packs=[];loadedPackNames=new Set;discoverPromise=null;async write(t,n){let r=Io(t,n),o=await Xn(r),s=Ro(this.gitDir,o);if(await this.fs.exists(s))return o;let a=H(this.gitDir,"objects",o.slice(0,2));return await this.fs.mkdir(a,{recursive:!0}),await this.fs.writeFile(s,await Zn(r)),this.hooks?.emit("object:write",{type:t,hash:o}),o}async read(t){let n=Ro(this.gitDir,t);if(await this.fs.exists(n)){let r=await this.fs.readFileBuffer(n),o=await Zt(r);return Id(t,o)}await this.discover();for(let r of this.packs){let o=await r.readObject(t);if(o)return o}throw new Error(`object ${t} not found`)}async exists(t){if(await this.fs.exists(Ro(this.gitDir,t)))return!0;await this.discover();for(let n of this.packs)if(n.hasObject(t))return!0;return!1}async ingestPack(t){if(t.byteLength<32)return 0;let r=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(8);if(r===0)return 0;let o=t.subarray(t.byteLength-20),s=un(o),a=H(this.gitDir,"objects","pack");await this.fs.mkdir(a,{recursive:!0});let i=`pack-${s}`,c=H(a,`${i}.pack`);await this.fs.writeFile(c,t);let f=await sa(t),d=H(a,`${i}.idx`);return await this.fs.writeFile(d,f),this.loadedPackNames.add(i),this.packs.push(new Er(t,f)),r}discover(){return this.discoverPromise||(this.discoverPromise=this.doDiscover()),this.discoverPromise}async doDiscover(){let t=H(this.gitDir,"objects","pack");if(!await this.fs.exists(t))return;let n=await this.fs.readdir(t);for(let r of n){if(!r.endsWith(".idx"))continue;let o=r.slice(0,-4);if(this.loadedPackNames.has(o))continue;let s=H(t,`${o}.pack`);if(!await this.fs.exists(s))continue;let[a,i]=await Promise.all([this.fs.readFileBuffer(H(t,r)),this.fs.readFileBuffer(s)]);this.loadedPackNames.add(o),this.packs.push(new Er(i,a))}}}});function kr(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),[a="0",i="+0000"]=s.split(" "),c=parseInt(a,10);return{name:r,email:o,timestamp:c,timezone:i}}function xr(e){return`${e.name} <${e.email}> ${e.timestamp} ${e.timezone}`}var Oo=be(()=>{"use strict"});function Ft(e){let t=$d.decode(e),n=t.indexOf(`
15
13
 
16
14
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",a=[],i,c;for(let f of r.split(`
17
- `)){let d=f.indexOf(" ");if(d===-1)continue;let u=f.slice(0,d),l=f.slice(d+1);switch(u){case"tree":s=l;break;case"parent":a.push(l);break;case"author":i=Zn(l);break;case"committer":c=Zn(l);break}}if(!s)throw new Error("Commit missing tree field");if(!i)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:a,author:i,committer:c,message:o}}function $t(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${Jn(e.author)}`),t.push(`committer ${Jn(e.committer)}`),t.push(""),t.push(e.message),Af.encode(t.join(`
18
- `))}var Sf=new TextEncoder,Df=new TextDecoder;function jt(e){let t=Df.decode(e),n=t.indexOf(`
15
+ `)){let d=f.indexOf(" ");if(d===-1)continue;let u=f.slice(0,d),l=f.slice(d+1);switch(u){case"tree":s=l;break;case"parent":a.push(l);break;case"author":i=kr(l);break;case"committer":c=kr(l);break}}if(!s)throw new Error("Commit missing tree field");if(!i)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:s,parents:a,author:i,committer:c,message:o}}function Ut(e){let t=[];t.push(`tree ${e.tree}`);for(let n of e.parents)t.push(`parent ${n}`);return t.push(`author ${xr(e.author)}`),t.push(`committer ${xr(e.committer)}`),t.push(""),t.push(e.message),Od.encode(t.join(`
16
+ `))}var Od,$d,Jt=be(()=>{"use strict";Oo();Od=new TextEncoder,$d=new TextDecoder});function Qt(e){let t=Hd.decode(e),n=t.indexOf(`
19
17
 
20
18
  `),r=n===-1?t:t.slice(0,n),o=n===-1?"":t.slice(n+2),s="",a="commit",i="",c;for(let f of r.split(`
21
- `)){let d=f.indexOf(" ");if(d===-1)continue;let u=f.slice(0,d),l=f.slice(d+1);switch(u){case"object":s=l;break;case"type":a=l;break;case"tag":i=l;break;case"tagger":c=Zn(l);break}}if(!s)throw new Error("Tag missing object field");if(!i)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:a,name:i,tagger:c,message:o}}function xi(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${Jn(e.tagger)}`),t.push(""),t.push(e.message),Sf.encode(t.join(`
22
- `))}function vr(e){if(e.objectStore)return e.objectStore;let t=new Ar(e.fs,e.gitDir,e.hooks);return e.objectStore=t,t}async function st(e,t){return Rn(qs(e,t))}async function we(e,t,n){return vr(e).write(t,n)}async function fe(e,t){return vr(e).read(t)}async function Vt(e,t){return vr(e).exists(t)}async function Sr(e,t){return vr(e).ingestPack(t)}function Pe(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 Yt(e){let t=Math.min(e.byteLength,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Mf=new TextDecoder;async function ie(e,t){let n=await fe(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Mf.decode(n.content)}async function ot(e,t){let n=await fe(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 fe(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return Rt(n.content)}async function ki(e,t){let n=await fe(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return jt(n.content)}async function Ie(e,t){let n=t;for(let r=0;r<100;r++){let o=await fe(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=jt(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 Ks="ref: ",jf=10;async function Ci(e,t){let n=Qn(e,t);if(await e.fs.exists(n)){let s=(await e.fs.readFile(n)).trim();return s.startsWith(Ks)?{type:"symbolic",target:s.slice(Ks.length)}:{type:"direct",hash:s}}let o=(await Ii(e)).get(t);return o?{type:"direct",hash:o}:null}async function F(e,t){let n=t;for(let r=0;r<jf;r++){let o=await Ci(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 J(e){return Ci(e,"HEAD")}async function X(e){return F(e,"HEAD")}async function Y(e,t,n){let r=e.hooks?await F(e,t):null,o=Qn(e,t);await Tn(e.fs,o),await e.fs.writeFile(o,`${n}
23
- `),e.hooks?.emit("ref:update",{ref:t,oldHash:r,newHash:n})}async function $e(e,t,n){let r=Qn(e,t);await Tn(e.fs,r),await e.fs.writeFile(r,`${Ks}${n}
24
- `)}async function ae(e,t){let n=e.hooks?await F(e,t):null,r=Qn(e,t);await e.fs.exists(r)&&await e.fs.rm(r),await Lf(e,t),await er(e,t),e.hooks&&n&&e.hooks.emit("ref:delete",{ref:t,oldHash:n})}async function le(e,t="refs"){let n=[],r=H(e.gitDir,t);await e.fs.exists(r)&&await Ri(e,r,t,n);let o=await Ii(e);if(o.size>0){let s=new Set(n.map(i=>i.name)),a=`${t}/`;for(let[i,c]of o)i.startsWith(a)&&!s.has(i)&&n.push({name:i,hash:c})}return n.sort((s,a)=>s.name<a.name?-1:s.name>a.name?1:0)}function de(e){return e.replace("refs/heads/","")}async function Xt(e,t){let n=await J(e);n&&n.type==="symbolic"?await Y(e,n.target,t):await Y(e,"HEAD",t)}async function Lf(e,t){let n=H(e.gitDir,"packed-refs");if(!await e.fs.exists(n))return;let o=(await e.fs.readFile(n)).split(`
19
+ `)){let d=f.indexOf(" ");if(d===-1)continue;let u=f.slice(0,d),l=f.slice(d+1);switch(u){case"object":s=l;break;case"type":a=l;break;case"tag":i=l;break;case"tagger":c=kr(l);break}}if(!s)throw new Error("Tag missing object field");if(!i)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:s,objectType:a,name:i,tagger:c,message:o}}function ca(e){let t=[];return t.push(`object ${e.object}`),t.push(`type ${e.objectType}`),t.push(`tag ${e.name}`),t.push(`tagger ${xr(e.tagger)}`),t.push(""),t.push(e.message),Td.encode(t.join(`
20
+ `))}var Td,Hd,Cr=be(()=>{"use strict";Oo();Td=new TextEncoder,Hd=new TextDecoder});function fs(e){if(e.objectStore)return e.objectStore;let t=new cs(e.fs,e.gitDir,e.hooks);return e.objectStore=t,t}async function pt(e,t){return Xn(Io(e,t))}async function Re(e,t,n){return fs(e).write(t,n)}async function he(e,t){return fs(e).read(t)}async function hn(e,t){return fs(e).exists(t)}async function ds(e,t){return fs(e).ingestPack(t)}function De(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 pn(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 le(e,t){let n=await he(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return Ad.decode(n.content)}async function gt(e,t){let n=await he(e,t);if(n.type!=="blob")throw new Error(`Expected blob for ${t}, got ${n.type}`);return n.content}async function D(e,t){let n=await he(e,t);if(n.type!=="commit")throw new Error(`Expected commit object for ${t}, got ${n.type}`);return Ft(n.content)}async function fa(e,t){let n=await he(e,t);if(n.type!=="tag")throw new Error(`Expected tag object for ${t}, got ${n.type}`);return Qt(n.content)}async function Ge(e,t){let n=t;for(let r=0;r<100;r++){let o=await he(e,n);if(o.type==="commit")return n;if(o.type==="tag"){n=Qt(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 Ad,re=be(()=>{"use strict";aa();Jt();Cr();Dn();Ad=new TextDecoder});async function da(e,t){let n=Pr(e,t);if(await e.fs.exists(n)){let s=(await e.fs.readFile(n)).trim();return s.startsWith($o)?{type:"symbolic",target:s.slice($o.length)}:{type:"direct",hash:s}}let o=(await ma(e)).get(t);return o?{type:"direct",hash:o}:null}async function F(e,t){let n=t;for(let r=0;r<vd;r++){let o=await da(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 Z(e){return da(e,"HEAD")}async function Y(e){return F(e,"HEAD")}async function z(e,t,n){let r=e.hooks?await F(e,t):null,o=Pr(e,t);await Jn(e.fs,o),await e.fs.writeFile(o,`${n}
21
+ `),e.hooks?.emit("ref:update",{ref:t,oldHash:r,newHash:n})}async function Ne(e,t,n){let r=Pr(e,t);await Jn(e.fs,r),await e.fs.writeFile(r,`${$o}${n}
22
+ `)}async function de(e,t){let n=e.hooks?await F(e,t):null,r=Pr(e,t);await e.fs.exists(r)&&await e.fs.rm(r),await Sd(e,t),await Rr(e,t),e.hooks&&n&&e.hooks.emit("ref:delete",{ref:t,oldHash:n})}async function pe(e,t="refs"){let n=[],r=H(e.gitDir,t);await e.fs.exists(r)&&await ha(e,r,t,n);let o=await ma(e);if(o.size>0){let s=new Set(n.map(i=>i.name)),a=`${t}/`;for(let[i,c]of o)i.startsWith(a)&&!s.has(i)&&n.push({name:i,hash:c})}return n.sort((s,a)=>s.name<a.name?-1:s.name>a.name?1:0)}function ge(e){return e.replace("refs/heads/","")}async function gn(e,t){let n=await Z(e);n&&n.type==="symbolic"?await z(e,n.target,t):await z(e,"HEAD",t)}async function Sd(e,t){let n=H(e.gitDir,"packed-refs");if(!await e.fs.exists(n))return;let o=(await e.fs.readFile(n)).split(`
25
23
  `),s=[],a=!1;for(let c of o){if(a&&c.startsWith("^")){a=!1;continue}if(a=!1,!c||c.startsWith("#")){s.push(c);continue}let f=c.indexOf(" ");if(f!==-1&&c.slice(f+1).trim()===t){a=!0;continue}s.push(c)}s.some(c=>c&&!c.startsWith("#")&&!c.startsWith("^"))?await e.fs.writeFile(n,s.join(`
26
- `)):await e.fs.rm(n)}async function Pi(e){let t=await le(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 fe(e,o.hash);if(s.type==="tag"){let a=jt(s.content).object;for(let i=0;i<100;i++){let c=await fe(e,a);if(c.type!=="tag")break;a=jt(c.content).object}n.push(`^${a}`)}}catch{}await e.fs.writeFile(H(e.gitDir,"packed-refs"),`${n.join(`
24
+ `)):await e.fs.rm(n)}async function la(e){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 he(e,o.hash);if(s.type==="tag"){let a=Qt(s.content).object;for(let i=0;i<100;i++){let c=await he(e,a);if(c.type!=="tag")break;a=Qt(c.content).object}n.push(`^${a}`)}}catch{}await e.fs.writeFile(H(e.gitDir,"packed-refs"),`${n.join(`
27
25
  `)}
28
- `);for(let o of t){let s=Qn(e,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await Oi(e,H(e.gitDir,"refs"));let r=H(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(H(r,"heads"),{recursive:!0}),await e.fs.mkdir(H(r,"tags"),{recursive:!0})}async function Oi(e,t){if(!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 Oi(e,H(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}async function Ii(e){let t=H(e.gitDir,"packed-refs");if(!await e.fs.exists(t))return new Map;let n=await e.fs.readFile(t),r=new Map;for(let o of n.split(`
29
- `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let a=o.slice(0,s),i=o.slice(s+1).trim();a.length===40&&i&&r.set(i,a)}return r}function Qn(e,t){return H(e.gitDir,t)}async function Ri(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let a=H(t,s),i=`${n}/${s}`,c=await e.fs.stat(a);if(c.isDirectory)await Ri(e,a,i,r);else if(c.isFile){let f=await F(e,i);f&&r.push({name:i,hash:f})}}}async function Hn(e,t){let n=t;for(;;){let r=H(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n};let o=Gf(n);if(o===n)return null;n=o}}async function Dr(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:H(t,".git"),a=r?null:t,i=H(s,"HEAD"),c=await e.exists(i);await e.mkdir(H(s,"objects"),{recursive:!0}),await e.mkdir(H(s,"refs","heads"),{recursive:!0}),await e.mkdir(H(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:a};if(!c){await $e(f,"HEAD",`refs/heads/${o}`);let d={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(H(s,"config"),Ds(d))}return{ctx:f,reinit:c}}async function Tn(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Gf(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}function Mr(e,t){return H(e.gitDir,"logs",t)}function Nf(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],a=o[1];if(!s||!a)return null;let i=n.indexOf("<"),c=n.indexOf(">",i);if(i<0||c<0)return null;let f=n.slice(s.length+1+a.length+1,i).trim(),d=n.slice(i+1,c),u=n.slice(c+2),l=u.indexOf(" ");if(l<0)return null;let m=parseInt(u.slice(0,l),10),h=u.slice(l+1);return{oldHash:s,newHash:a,name:f,email:d,timestamp:m,tz:h,message:r}}async function Me(e,t){let n=Mr(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(`
30
- `)){if(!s)continue;let a=Nf(s);a&&o.push(a)}return o}function $i(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function Zt(e,t,n){let r=Mr(e,t);if(await Tn(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map($i).join(`
26
+ `);for(let o of t){let s=Pr(e,o.name);await e.fs.exists(s)&&await e.fs.rm(s)}await ua(e,H(e.gitDir,"refs"));let r=H(e.gitDir,"refs");await e.fs.mkdir(r,{recursive:!0}),await e.fs.mkdir(H(r,"heads"),{recursive:!0}),await e.fs.mkdir(H(r,"tags"),{recursive:!0})}async function ua(e,t){if(!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 ua(e,H(t,s));(await e.fs.readdir(t)).length===0&&await e.fs.rm(t,{recursive:!0})}async function ma(e){let t=H(e.gitDir,"packed-refs");if(!await e.fs.exists(t))return new Map;let n=await e.fs.readFile(t),r=new Map;for(let o of n.split(`
27
+ `)){if(!o||o.startsWith("#")||o.startsWith("^"))continue;let s=o.indexOf(" ");if(s===-1)continue;let a=o.slice(0,s),i=o.slice(s+1).trim();a.length===40&&i&&r.set(i,a)}return r}function Pr(e,t){return H(e.gitDir,t)}async function ha(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let a=H(t,s),i=`${n}/${s}`,c=await e.fs.stat(a);if(c.isDirectory)await ha(e,a,i,r);else if(c.isFile){let f=await F(e,i);f&&r.push({name:i,hash:f})}}}var $o,vd,ue=be(()=>{"use strict";re();Cr();fe();Me();jn();$o="ref: ",vd=10});async function Qn(e,t){let n=t;for(;;){let r=H(n,".git");if(await e.exists(r)&&(await e.stat(r)).isDirectory)return{fs:e,gitDir:r,workTree:n};let o=Dd(n);if(o===n)return null;n=o}}async function ls(e,t,n={}){let{bare:r=!1,initialBranch:o="main"}=n,s=r?t:H(t,".git"),a=r?null:t,i=H(s,"HEAD"),c=await e.exists(i);await e.mkdir(H(s,"objects"),{recursive:!0}),await e.mkdir(H(s,"refs","heads"),{recursive:!0}),await e.mkdir(H(s,"refs","tags"),{recursive:!0});let f={fs:e,gitDir:s,workTree:a};if(!c){await Ne(f,"HEAD",`refs/heads/${o}`);let d={core:{repositoryformatversion:"0",filemode:"true",bare:r?"true":"false",...r?{}:{logallrefupdates:"true"}}};await e.writeFile(H(s,"config"),po(d))}return{ctx:f,reinit:c}}async function Jn(e,t){let n=t.lastIndexOf("/");if(n>0){let r=t.slice(0,n);await e.mkdir(r,{recursive:!0})}}function Dd(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var jn=be(()=>{"use strict";Ze();fe();ue()});function us(e,t){return H(e.gitDir,"logs",t)}function Md(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],a=o[1];if(!s||!a)return null;let i=n.indexOf("<"),c=n.indexOf(">",i);if(i<0||c<0)return null;let f=n.slice(s.length+1+a.length+1,i).trim(),d=n.slice(i+1,c),u=n.slice(c+2),l=u.indexOf(" ");if(l<0)return null;let m=parseInt(u.slice(0,l),10),h=u.slice(l+1);return{oldHash:s,newHash:a,name:f,email:d,timestamp:m,tz:h,message:r}}async function Ve(e,t){let n=us(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(`
28
+ `)){if(!s)continue;let a=Md(s);a&&o.push(a)}return o}function pa(e){return`${e.oldHash} ${e.newHash} ${e.name} <${e.email}> ${e.timestamp} ${e.tz} ${e.message}`}async function wn(e,t,n){let r=us(e,t);if(await Jn(e.fs,r),n.length===0){await e.fs.writeFile(r,"");return}let o=`${n.map(pa).join(`
31
29
  `)}
32
- `;await e.fs.writeFile(r,o)}async function Te(e,t,n){let r=Mr(e,t);await Tn(e.fs,r);let o=`${$i(n)}
33
- `;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 er(e,t){let n=Mr(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ee(e,t,n,r,o,s,a=!1){let i=await Ot(e,t),c={oldHash:r??Z,newHash:o,...i,message:s};await Te(e,n,c),a&&n!=="HEAD"&&await Te(e,"HEAD",c)}function _f(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 i=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:i}),n=s[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let i=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:i}),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}}var Ti=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];async function Ff(e,t){let n=t.slice(0,2),r=t.slice(2),o=H(e.gitDir,"objects",n);if(!await e.fs.exists(o))return null;let a=(await e.fs.readdir(o)).filter(i=>i.startsWith(r));if(a.length===0)return null;if(a.length>1)throw new zs(t);return`${n}${a[0]}`}var zs=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}};async function Uf(e,t){if(t==="HEAD"||t==="@")return F(e,"HEAD");if(Ti.includes(t))return F(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 Ff(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await F(e,t);if(s)return s}let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);if(r)return r;let o=await F(e,`refs/remotes/${t}`);return o||null}function Bf(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of Ti)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function Wf(e,t,n){let r=Bf(t),o=await Me(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let a=o[s];return a?a.newHash:null}async function je(e,t){let{base:n,reflogIndex:r,suffixes:o}=_f(t),s;if(r!==void 0?s=await Wf(e,n,r):s=await Uf(e,n),!s)return null;o.length>0&&(s=await Ie(e,s));for(let a of o)if(a.type==="tilde")for(let i=0;i<a.n;i++){if(!s)return null;let c=await j(e,s);if(c.parents.length===0||(s=c.parents[0]??null,!s))return null}else{if(a.n===0)continue;if(!s)return null;let i=await j(e,s);if(a.n>i.parents.length||(s=i.parents[a.n-1]??null,!s))return null}return s}function Hi(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var qf=new TextEncoder;function ze(e,t){return e.lstat?e.lstat(t):e.stat(t)}function Lt(e){return typeof e=="string"?e==="120000":e===40960}async function tr(e,t){if((await ze(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return qf.encode(r)}return e.readFileBuffer(t)}async function Jt(e,t){let n=await tr(e,t);return st("blob",n)}var Kf=new TextEncoder,Ai=new TextDecoder;function Qt(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=Ai.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let a=Ai.decode(e.subarray(r+1,s)),i=e.subarray(s+1,s+21),c=Kt(i),f=o.padStart(6,"0");t.push({mode:f,name:a,hash:c}),n=s+21}return{type:"tree",entries:t}}function vi(e){let t=[];for(let s of e.entries){let a=s.mode.replace(/^0+/,""),i=Kf.encode(`${a} ${s.name}\0`),c=dt(s.hash);t.push(i),t.push(c)}let n=t.reduce((s,a)=>s+a.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var nr={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"};async function ke(e,t){return Si(e,t,"")}async function Si(e,t,n){let r=[],o=new Map;for(let a of t){let i=n?a.path.slice(n.length+1):a.path,c=i.indexOf("/");if(c===-1)r.push({mode:zf(a.mode),name:i,hash:a.hash});else{let f=i.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(a)}}for(let[a,i]of o){let c=n?`${n}/${a}`:a,f=await Si(e,i,c);r.push({mode:nr.DIRECTORY,name:a,hash:f})}r.sort((a,i)=>{let c=a.mode===nr.DIRECTORY?`${a.name}/`:a.name,f=i.mode===nr.DIRECTORY?`${i.name}/`:i.name;return c<f?-1:c>f?1:0});let s=vi({type:"tree",entries:r});return we(e,"tree",s)}async function He(e,t,n=""){let r=await fe(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=Qt(r.content),s=[];for(let a of o.entries){let i=n?`${n}/${a.name}`:a.name;if(a.mode===nr.DIRECTORY){let c=await He(e,a.hash,i);s.push(...c)}else s.push({path:i,mode:a.mode,hash:a.hash})}return s}async function se(e,t){if(!t)return new Map;let n=await He(e,t);return new Map(n.map(r=>[r.path,r]))}async function Ae(e,t,n){let r=await se(e,t),o=await se(e,n),s=[];for(let[a,i]of r){let c=o.get(a);c?(i.hash!==c.hash||i.mode!==c.mode)&&s.push({path:a,status:"modified",oldHash:i.hash,newHash:c.hash,oldMode:i.mode,newMode:c.mode}):s.push({path:a,status:"deleted",oldHash:i.hash,oldMode:i.mode})}for(let[a,i]of o)r.has(a)||s.push({path:a,status:"added",newHash:i.hash,newMode:i.mode});return s.sort((a,i)=>he(a.path,i.path))}function zf(e){return e.toString(8).padStart(6,"0")}function Di(e){return/^[a-zA-Z0-9]$/.test(e)}function Vf(e){return/^[a-zA-Z]$/.test(e)}function Yf(e){return e>="0"&&e<="9"}function Vs(e){return e>="A"&&e<="Z"}function Ys(e){return e>="a"&&e<="z"}function Mi(e){return/^\s$/.test(e)}function Xf(e){return e===" "||e===" "}function Zs(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function Zf(e){return Zs(e)&&!Mi(e)}function Jf(e){return Zs(e)&&!Di(e)&&e!==" "}function Qf(e){let t=e.charCodeAt(0);return t<32||t===127}function ed(e){return/^[0-9a-fA-F]$/.test(e)}function rr(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function Xs(e,t,n,r,o){let s=(o&1)!==0,a=(o&2)!==0;for(;t<e.length;){let i=e[t];if(r>=n.length&&i!=="*")return-1;let c=r<n.length?n[r]:"";switch(i){case"\\":{if(t++,t>=e.length)return-1;if(!rr(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(a&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let d=t;for(;t<e.length&&e[t]==="*";)t++;if(!a)f=!0;else if((d-1<1||e[d-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&Xs(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!a;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let d=n.indexOf("/",r);if(d===-1)return-1;r=d+1,t++;break}for(;!(r>=n.length);){if(!td(e[t])){let u=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==u;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let d=Xs(e,t,n,r,o);if(d!==1){if(!f||d!==-2)return d}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(a&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let d=!1,u="",l=!0;for(;t<e.length&&(l||e[t]!=="]");){l=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],rr(c,m,s)&&(d=!0)}else if(m==="-"&&u&&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=u,p=m;if(c>=h&&c<=p&&(d=!0),s){if(Ys(c)){let g=c.toUpperCase();g>=h&&g<=p&&(d=!0)}else if(Vs(c)){let g=c.toLowerCase();g>=h&&g<=p&&(d=!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="[",rr(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);nd(g,c,s)&&(d=!0),m=""}}else rr(c,m,s)&&(d=!0);u=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!rr(c,i,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function td(e){return e==="*"||e==="?"||e==="["||e==="\\"}function nd(e,t,n){switch(e){case"alnum":return Di(t);case"alpha":return Vf(t);case"blank":return Xf(t);case"cntrl":return Qf(t);case"digit":return Yf(t);case"graph":return Zf(t);case"lower":return Ys(t)||n&&Vs(t);case"print":return Zs(t);case"punct":return Jf(t);case"space":return Mi(t);case"upper":return Vs(t)||n&&Ys(t);case"xdigit":return ed(t);default:return!1}}function pn(e,t,n=0){return Xs(e,0,t,0,n)===0?0:1}var ji=1,Li=4,Gi=8,jr=16;function Ni(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 rd(e){return Ni(e)===e.length}function sd(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|=jr,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Gi);let a=!1;for(let c=0;c<s;c++)if(o[c]==="/"){a=!0;break}a||(r|=ji);let i=Math.min(Ni(o),s);return o[0]==="*"&&rd(o.slice(1))&&(r|=Li),{pattern:o,patternLen:s,nowildcardLen:i,flags:r,base:t}}function sr(e,t,n){let r=[];for(let o of e.split(`
34
- `)){let s=sd(o,t);s&&r.push(s)}return{patterns:r,src:n}}function od(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Li){let a=n.slice(1);return e.length>=a.length&&e.endsWith(a)}return pn(n,e,2)===0}function id(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 a=n.length;if(a>0&&(e.length<a+1||e[a]!=="/"||!e.startsWith(n)))return!1;let i=a>0?e.slice(a+1):e,c=i.length;if(s>0){if(s>c||i.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return pn(r,i,2)===0}function Js(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&Gi&&!t)){if(s.flags&ji){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(od(r,s))return s;continue}if(id(e,s))return s}}return null}function Tt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Js(t,n,o);if(s)return s.flags&jr?"not-ignored":"ignored"}if(e.excludeFile){let r=Js(t,n,e.excludeFile);if(r)return r.flags&jr?"not-ignored":"ignored"}if(e.globalExclude){let r=Js(t,n,e.globalExclude);if(r)return r.flags&jr?"not-ignored":"ignored"}return"undecided"}async function vn(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=H(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=sr(r,"",n)}catch{}try{let r=await Et(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=sr(o,"",r)}catch{}}catch{}return t}function gn(e,t,n,r){let s=sr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var ad=new TextEncoder,cd=new TextDecoder;async function ut(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 a=H(e.workTree,s.path),i;try{i=await ze(e.fs,a)}catch{i=null}if(!i){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!i.isFile&&!i.isSymbolicLink)continue;await Jt(e.fs,a)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await _e(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,a)=>he(s.path,a.path))}async function ve(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await fe(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=H(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&Lt(t.mode)&&e.fs.symlink){await ze(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let a=cd.decode(n.content);await e.fs.symlink(a,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 _i(e,t){let n=await He(e,t);for(let r of n)await ve(e,r)}async function Gt(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=H(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await ze(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=ad.encode(f),u=await we(e,"blob",d),l={path:n,mode:40960,hash:u,stage:0,stat:{...pe(),size:d.byteLength}};return{index:Xe(t,l),hash:u}}let s=await e.fs.readFileBuffer(r),a=await we(e,"blob",s),i=o.mode!=null?fd(o.mode):33188,c={path:n,mode:i,hash:a,stage:0,stat:{...pe(),size:s.byteLength}};return{index:Xe(t,c),hash:a}}async function _e(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await vn(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);s=gn(s,f,n,c)}catch{}}let a=[],i=await e.fs.readdir(t);for(let c of i){if(n===""&&c===".git")continue;let f=H(t,c),d=n?`${n}/${c}`:c,u=await ze(e.fs,f);if(u.isSymbolicLink){if(s&&Tt(s,d,!1)==="ignored")continue;a.push(d)}else if(u.isDirectory){if(s&&Tt(s,d,!0)==="ignored")continue;let l=await _e(e,f,d,{skipIgnore:o,_ignore:s??void 0});a.push(...l)}else if(u.isFile){if(s&&Tt(s,d,!1)==="ignored")continue;a.push(d)}}return a}function fd(e){return e>511?e:e&73?33261:33188}async function wn(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),await wn(e,Pt(t),n))}function Qs(e){return e.existsOnDisk&&e.indexHash===null}async function dd(e,t,n){let r=await Promise.all(t.map(h=>se(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 a=e.workTree?new Set(await _e(e,e.workTree,"",{skipIgnore:!0})):new Set,i=null,c=async()=>(i===null&&(i=e.workTree?new Set(await _e(e,e.workTree,"")):new Set),i),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of a)f.has(h)||d.add(h);let u=Array.from(f).sort().concat(Array.from(d).sort()),l=(h,p)=>r[h]?.get(p),m=[];for(let h of u){let p=null,g=null,w=null,x=null,b=null;if(r.length===1){let L=l(0,h);w=L?.hash??null,b=L?.mode??null}else if(r.length===2){let L=l(0,h),D=l(1,h);g=L?.hash??null,x=L?.mode??null,w=D?.hash??null,b=D?.mode??null}else if(r.length>=3){let L=l(0,h),D=l(1,h),z=l(2,h);p=L?.hash??null,g=D?.hash??null,x=D?.mode??null,w=z?.hash??null,b=z?.mode??null}let k=o.get(h)?.hash??null,P=s.has(h)?1:0,C=a.has(h),O,y=async()=>O!==void 0?O:C?(O=!(await c()).has(h),O):(O=!1,!1),I,A=async()=>{if(I!==void 0)return I;if(!C||!e.workTree)return I=null,null;let L=H(e.workTree,h);try{I=await Jt(e.fs,L)}catch{I=null}return I};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:k,indexStage:P,existsOnDisk:C,isIgnoredOnDisk:y,getWorktreeHash:A,headMode:x,remoteMode:b})}return m}function Gr(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 Nr(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 ld(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 ud(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let a=t.get(o);if(!a)continue;let i=ld(s,a);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await md(c,a,i);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function md(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Qs(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 Qs(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Qs(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function hd(e,t,n,r){let o=[],s=[],a=new Set(e.keys()),i=new Map;for(let c of n.entries)a.has(c.path)||o.push(c),c.stage===0&&i.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let u=i.get(c);u&&(o.push(u),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:u.hash,mode:u.mode}));break}case"TAKE":{let u=f.takeFrom==="head"?d.headHash:d.remoteHash,l=f.takeFrom==="head"?d.headMode:d.remoteMode,m=l?Number.parseInt(l,8):33188;o.push({path:c,mode:m,hash:u,stage:0,stat:pe()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:u,mode:m});break}case"DELETE":{r.updateWorktree&&d.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>he(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}var pd=[{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 _r(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:a,fix:i}of pd){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
30
+ `;await e.fs.writeFile(r,o)}async function _e(e,t,n){let r=us(e,t);await Jn(e.fs,r);let o=`${pa(n)}
31
+ `;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 Rr(e,t){let n=us(e,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ne(e,t,n,r,o,s,a=!1){let i=await Nt(e,t),c={oldHash:r??J,newHash:o,...i,message:s};await _e(e,n,c),a&&n!=="HEAD"&&await _e(e,"HEAD",c)}var Me=be(()=>{"use strict";at();ln();fe();jn();at()});function jd(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 i=s[2]===""?1:parseInt(s[2],10);t.unshift({type:"tilde",n:i}),n=s[1].length;continue}let a=e.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let i=a[2]===""?1:parseInt(a[2],10);t.unshift({type:"caret",n:i}),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 Gd(e,t){let n=t.slice(0,2),r=t.slice(2),o=H(e.gitDir,"objects",n);if(!await e.fs.exists(o))return null;let a=(await e.fs.readdir(o)).filter(i=>i.startsWith(r));if(a.length===0)return null;if(a.length>1)throw new To(t);return`${n}${a[0]}`}async function Ld(e,t){if(t==="HEAD"||t==="@")return F(e,"HEAD");if(ga.includes(t))return F(e,t);if(/^[0-9a-f]{40}$/.test(t))return await hn(e,t)?t:null;if(/^[0-9a-f]{4,39}$/.test(t)){let s=await Gd(e,t);if(s)return s}if(t.startsWith("refs/")){let s=await F(e,t);if(s)return s}let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);if(r)return r;let o=await F(e,`refs/remotes/${t}`);return o||null}function Nd(e){if(e==="HEAD"||e==="@")return"HEAD";for(let t of ga)if(e===t)return t;return e.startsWith("refs/")?e:`refs/heads/${e}`}async function _d(e,t,n){let r=Nd(t),o=await Ve(e,r);if(o.length===0)return null;let s=o.length-1-n;if(s<0||s>=o.length)return null;let a=o[s];return a?a.newHash:null}async function Fe(e,t){let{base:n,reflogIndex:r,suffixes:o}=jd(t),s;if(r!==void 0?s=await _d(e,n,r):s=await Ld(e,n),!s)return null;o.length>0&&(s=await Ge(e,s));for(let a of o)if(a.type==="tilde")for(let i=0;i<a.n;i++){if(!s)return null;let c=await D(e,s);if(c.parents.length===0||(s=c.parents[0]??null,!s))return null}else{if(a.n===0)continue;if(!s)return null;let i=await D(e,s);if(a.n>i.parents.length||(s=i.parents[a.n-1]??null,!s))return null}return s}function wa(e){let t=e.indexOf(":");return t<0?null:{rev:e.slice(0,t)||"HEAD",path:e.slice(t+1)}}var ga,To,en=be(()=>{"use strict";re();fe();Me();ue();ga=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];To=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}}});function st(e,t){return e.lstat?e.lstat(t):e.stat(t)}function tn(e){return typeof e=="string"?e==="120000":e===40960}async function Ir(e,t){if((await st(e,t)).isSymbolicLink&&e.readlink){let r=await e.readlink(t);return Fd.encode(r)}return e.readFileBuffer(t)}async function bn(e,t){let n=await Ir(e,t);return pt("blob",n)}var Fd,Gn=be(()=>{"use strict";re();Fd=new TextEncoder});function yn(e){let t=[],n=0;for(;n<e.byteLength;){let r=e.indexOf(32,n);if(r===-1)break;let o=ba.decode(e.subarray(n,r)),s=e.indexOf(0,r+1);if(s===-1)break;let a=ba.decode(e.subarray(r+1,s)),i=e.subarray(s+1,s+21),c=un(i),f=o.padStart(6,"0");t.push({mode:f,name:a,hash:c}),n=s+21}return{type:"tree",entries:t}}function ya(e){let t=[];for(let s of e.entries){let a=s.mode.replace(/^0+/,""),i=Ud.encode(`${a} ${s.name}\0`),c=Ct(s.hash);t.push(i),t.push(c)}let n=t.reduce((s,a)=>s+a.byteLength,0),r=new Uint8Array(n),o=0;for(let s of t)r.set(s,o),o+=s.byteLength;return r}var Ud,ba,ms=be(()=>{"use strict";at();Ud=new TextEncoder,ba=new TextDecoder});var Or,Ea=be(()=>{"use strict";Or={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"}});async function Ae(e,t){return ka(e,t,"")}async function ka(e,t,n){let r=[],o=new Map;for(let a of t){let i=n?a.path.slice(n.length+1):a.path,c=i.indexOf("/");if(c===-1)r.push({mode:Bd(a.mode),name:i,hash:a.hash});else{let f=i.slice(0,c),d=o.get(f);d||(d=[],o.set(f,d)),d.push(a)}}for(let[a,i]of o){let c=n?`${n}/${a}`:a,f=await ka(e,i,c);r.push({mode:Or.DIRECTORY,name:a,hash:f})}r.sort((a,i)=>{let c=a.mode===Or.DIRECTORY?`${a.name}/`:a.name,f=i.mode===Or.DIRECTORY?`${i.name}/`:i.name;return c<f?-1:c>f?1:0});let s=ya({type:"tree",entries:r});return Re(e,"tree",s)}async function Ue(e,t,n=""){let r=await he(e,t);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let o=yn(r.content),s=[];for(let a of o.entries){let i=n?`${n}/${a.name}`:a.name;if(a.mode===Or.DIRECTORY){let c=await Ue(e,a.hash,i);s.push(...c)}else s.push({path:i,mode:a.mode,hash:a.hash})}return s}async function ae(e,t){if(!t)return new Map;let n=await Ue(e,t);return new Map(n.map(r=>[r.path,r]))}async function Be(e,t,n){let r=await ae(e,t),o=await ae(e,n),s=[];for(let[a,i]of r){let c=o.get(a);c?(i.hash!==c.hash||i.mode!==c.mode)&&s.push({path:a,status:"modified",oldHash:i.hash,newHash:c.hash,oldMode:i.mode,newMode:c.mode}):s.push({path:a,status:"deleted",oldHash:i.hash,oldMode:i.mode})}for(let[a,i]of o)r.has(a)||s.push({path:a,status:"added",newHash:i.hash,newMode:i.mode});return s.sort((a,i)=>Ee(a.path,i.path))}function Bd(e){return e.toString(8).padStart(6,"0")}var Ie=be(()=>{"use strict";ee();re();ms();Ea()});function xa(e){return/^[a-zA-Z0-9]$/.test(e)}function Wd(e){return/^[a-zA-Z]$/.test(e)}function qd(e){return e>="0"&&e<="9"}function Ho(e){return e>="A"&&e<="Z"}function Ao(e){return e>="a"&&e<="z"}function Ca(e){return/^\s$/.test(e)}function Kd(e){return e===" "||e===" "}function So(e){let t=e.charCodeAt(0);return t>=32&&t<=126}function zd(e){return So(e)&&!Ca(e)}function Vd(e){return So(e)&&!xa(e)&&e!==" "}function Yd(e){let t=e.charCodeAt(0);return t<32||t===127}function Xd(e){return/^[0-9a-fA-F]$/.test(e)}function $r(e,t,n){return n?e.toLowerCase()===t.toLowerCase():e===t}function vo(e,t,n,r,o){let s=(o&1)!==0,a=(o&2)!==0;for(;t<e.length;){let i=e[t];if(r>=n.length&&i!=="*")return-1;let c=r<n.length?n[r]:"";switch(i){case"\\":{if(t++,t>=e.length)return-1;if(!$r(n[r],e[t],s))return 1;r++,t++;break}case"?":{if(a&&c==="/")return 1;r++,t++;break}case"*":{let f;if(t++,t<e.length&&e[t]==="*"){let d=t;for(;t<e.length&&e[t]==="*";)t++;if(!a)f=!0;else if((d-1<1||e[d-2]==="/")&&(t>=e.length||e[t]==="/"||e[t]==="\\"&&t+1<e.length&&e[t+1]==="/")){if(t<e.length&&e[t]==="/"&&vo(e,t+1,n,r,o)===0)return 0;f=!0}else f=!1}else f=!a;if(t>=e.length)return!f&&n.indexOf("/",r)!==-1?-2:0;if(!f&&e[t]==="/"){let d=n.indexOf("/",r);if(d===-1)return-1;r=d+1,t++;break}for(;!(r>=n.length);){if(!Zd(e[t])){let u=s?e[t].toLowerCase():e[t];for(;r<n.length&&(f||n[r]!=="/")&&(s?n[r].toLowerCase():n[r])!==u;)r++;if(r>=n.length||!f&&n[r]==="/")return r<n.length&&!f&&n[r]==="/"?-2:f?-1:-2}let d=vo(e,t,n,r,o);if(d!==1){if(!f||d!==-2)return d}else if(!f&&n[r]==="/")return-2;r++}return-1}case"[":{if(a&&c==="/")return 1;if(t++,t>=e.length)return-1;let f=!1;(e[t]==="!"||e[t]==="^")&&(f=!0,t++);let d=!1,u="",l=!0;for(;t<e.length&&(l||e[t]!=="]");){l=!1;let m=e[t];if(m==="\\"){if(t++,t>=e.length)return-1;m=e[t],$r(c,m,s)&&(d=!0)}else if(m==="-"&&u&&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=u,p=m;if(c>=h&&c<=p&&(d=!0),s){if(Ao(c)){let g=c.toUpperCase();g>=h&&g<=p&&(d=!0)}else if(Ho(c)){let g=c.toLowerCase();g>=h&&g<=p&&(d=!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="[",$r(c,m,s)&&(d=!0);else{let g=e.slice(h,h+p);Jd(g,c,s)&&(d=!0),m=""}}else $r(c,m,s)&&(d=!0);u=m,t++}if(t>=e.length)return-1;if(t++,d===f)return 1;r++;break}default:{if(!$r(c,i,s))return 1;r++,t++;break}}}return r>=n.length?0:1}function Zd(e){return e==="*"||e==="?"||e==="["||e==="\\"}function Jd(e,t,n){switch(e){case"alnum":return xa(t);case"alpha":return Wd(t);case"blank":return Kd(t);case"cntrl":return Yd(t);case"digit":return qd(t);case"graph":return zd(t);case"lower":return Ao(t)||n&&Ho(t);case"print":return So(t);case"punct":return Vd(t);case"space":return Ca(t);case"upper":return Ho(t)||n&&Ao(t);case"xdigit":return Xd(t);default:return!1}}function Ln(e,t,n=0){return vo(e,0,t,0,n)===0?0:1}var hs=be(()=>{"use strict"});function Oa(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 Qd(e){return Oa(e)===e.length}function el(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|=ps,o=o.slice(1)),o.length===0)return null;let s=o.length;o[s-1]==="/"&&(s--,o=o.slice(0,s),r|=Ia);let a=!1;for(let c=0;c<s;c++)if(o[c]==="/"){a=!0;break}a||(r|=Pa);let i=Math.min(Oa(o),s);return o[0]==="*"&&Qd(o.slice(1))&&(r|=Ra),{pattern:o,patternLen:s,nowildcardLen:i,flags:r,base:t}}function Tr(e,t,n){let r=[];for(let o of e.split(`
32
+ `)){let s=el(o,t);s&&r.push(s)}return{patterns:r,src:n}}function tl(e,t){let{pattern:n,patternLen:r,nowildcardLen:o,flags:s}=t;if(o===r)return e===n;if(s&Ra){let a=n.slice(1);return e.length>=a.length&&e.endsWith(a)}return Ln(n,e,2)===0}function nl(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 a=n.length;if(a>0&&(e.length<a+1||e[a]!=="/"||!e.startsWith(n)))return!1;let i=a>0?e.slice(a+1):e,c=i.length;if(s>0){if(s>c||i.slice(0,s)!==r.slice(0,s))return!1;if(o===s&&c===s)return!0}return Ln(r,i,2)===0}function Do(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&Ia&&!t)){if(s.flags&Pa){if(s.base&&!e.startsWith(`${s.base}/`))continue;if(tl(r,s))return s;continue}if(nl(e,s))return s}}return null}function Bt(e,t,n){for(let r=e.dirPatterns.length-1;r>=0;r--){let o=e.dirPatterns[r],s=Do(t,n,o);if(s)return s.flags&ps?"not-ignored":"ignored"}if(e.excludeFile){let r=Do(t,n,e.excludeFile);if(r)return r.flags&ps?"not-ignored":"ignored"}if(e.globalExclude){let r=Do(t,n,e.globalExclude);if(r)return r.flags&ps?"not-ignored":"ignored"}return"undecided"}async function tr(e){let t={dirPatterns:[],excludeFile:null,globalExclude:null},n=H(e.gitDir,"info","exclude");try{let r=await e.fs.readFile(n);t.excludeFile=Tr(r,"",n)}catch{}try{let r=await Dt(e,"core.excludesFile");if(r)try{let o=await e.fs.readFile(r);t.globalExclude=Tr(o,"",r)}catch{}}catch{}return t}function Nn(e,t,n,r){let s=Tr(t,n===""?"":n,r);return{...e,dirPatterns:[...e.dirPatterns,s]}}var Pa,Ra,Ia,ps,ws=be(()=>{"use strict";Ze();fe();hs();Pa=1,Ra=4,Ia=8,ps=16});async function Rt(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 a=H(e.workTree,s.path),i;try{i=await st(e.fs,a)}catch{i=null}if(!i){n.push({path:s.path,status:"deleted",indexHash:s.hash});continue}if(!i.isFile&&!i.isSymbolicLink)continue;await bn(e.fs,a)!==s.hash&&n.push({path:s.path,status:"modified",indexHash:s.hash})}let r=new Set(t.entries.map(s=>s.path)),o=await Qe(e,e.workTree,"");for(let s of o)r.has(s)||n.push({path:s,status:"untracked"});return n.sort((s,a)=>Ee(s.path,a.path))}async function We(e,t){if(!e.workTree)throw new Error("Cannot checkout in a bare repository");let n=await he(e,t.hash);if(n.type!=="blob")throw new Error(`Expected blob for ${t.path}, got ${n.type}`);let r=H(e.workTree,t.path),o=r.lastIndexOf("/");if(o>0&&await e.fs.mkdir(r.slice(0,o),{recursive:!0}),t.mode!=null&&tn(t.mode)&&e.fs.symlink){await st(e.fs,r).then(()=>!0).catch(()=>!1)&&await e.fs.rm(r,{force:!0});let a=sl.decode(n.content);await e.fs.symlink(a,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 $a(e,t){let n=await Ue(e,t);for(let r of n)await We(e,r)}async function nn(e,t,n){if(!e.workTree)throw new Error("Cannot stage in a bare repository");let r=H(e.workTree,n);if(!await e.fs.exists(r))throw new Error(`Path does not exist: ${n}`);let o=await st(e.fs,r);if(o.isSymbolicLink&&e.fs.readlink){let f=await e.fs.readlink(r),d=rl.encode(f),u=await Re(e,"blob",d),l={path:n,mode:40960,hash:u,stage:0,stat:{...ke(),size:d.byteLength}};return{index:ct(t,l),hash:u}}let s=await e.fs.readFileBuffer(r),a=await Re(e,"blob",s),i=o.mode!=null?ol(o.mode):33188,c={path:n,mode:i,hash:a,stage:0,stat:{...ke(),size:s.byteLength}};return{index:ct(t,c),hash:a}}async function Qe(e,t,n,r){let o=r?.skipIgnore??!1,s=null;if(!o){s=r?._ignore??await tr(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);s=Nn(s,f,n,c)}catch{}}let a=[],i=await e.fs.readdir(t);for(let c of i){if(n===""&&c===".git")continue;let f=H(t,c),d=n?`${n}/${c}`:c,u=await st(e.fs,f);if(u.isSymbolicLink){if(s&&Bt(s,d,!1)==="ignored")continue;a.push(d)}else if(u.isDirectory){if(s&&Bt(s,d,!0)==="ignored")continue;let l=await Qe(e,f,d,{skipIgnore:o,_ignore:s??void 0});a.push(...l)}else if(u.isFile){if(s&&Bt(s,d,!1)==="ignored")continue;a.push(d)}}return a}function ol(e){return e>511?e:e&73?33261:33188}async function _n(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),await _n(e,Lt(t),n))}var rl,sl,et=be(()=>{"use strict";ee();ws();ye();re();fe();Gn();Ie();rl=new TextEncoder,sl=new TextDecoder});function Mo(e){return e.existsOnDisk&&e.indexHash===null}async function il(e,t,n){let r=await Promise.all(t.map(h=>ae(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 a=e.workTree?new Set(await Qe(e,e.workTree,"",{skipIgnore:!0})):new Set,i=null,c=async()=>(i===null&&(i=e.workTree?new Set(await Qe(e,e.workTree,"")):new Set),i),f=new Set;for(let h of r)for(let p of h.keys())f.add(p);let d=new Set;for(let h of n.entries)f.has(h.path)||d.add(h.path);for(let h of a)f.has(h)||d.add(h);let u=Array.from(f).sort().concat(Array.from(d).sort()),l=(h,p)=>r[h]?.get(p),m=[];for(let h of u){let p=null,g=null,w=null,k=null,b=null;if(r.length===1){let G=l(0,h);w=G?.hash??null,b=G?.mode??null}else if(r.length===2){let G=l(0,h),M=l(1,h);g=G?.hash??null,k=G?.mode??null,w=M?.hash??null,b=M?.mode??null}else if(r.length>=3){let G=l(0,h),M=l(1,h),V=l(2,h);p=G?.hash??null,g=M?.hash??null,k=M?.mode??null,w=V?.hash??null,b=V?.mode??null}let x=o.get(h)?.hash??null,P=s.has(h)?1:0,C=a.has(h),R,y=async()=>R!==void 0?R:C?(R=!(await c()).has(h),R):(R=!1,!1),I,v=async()=>{if(I!==void 0)return I;if(!C||!e.workTree)return I=null,null;let G=H(e.workTree,h);try{I=await bn(e.fs,G)}catch{I=null}return I};m.push({path:h,baseHash:p,headHash:g,remoteHash:w,indexHash:x,indexStage:P,existsOnDisk:C,isIgnoredOnDisk:y,getWorktreeHash:v,headMode:k,remoteMode:b})}return m}function bs(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 ys(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 al(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 cl(e,t,n){let r=[];if(n.reset)return r;for(let[o,s]of e){if(s.requirements.length===0)continue;let a=t.get(o);if(!a)continue;let i=al(s,a);for(let c of s.requirements){if(n.allowStagedChanges&&c==="INDEX_MUST_MATCH_HEAD")continue;let f=await fl(c,a,i);if(f){r.push({path:o,error:f});break}}if(n.stopAtFirstError&&r.length>0)break}return r}async function fl(e,t,n,r){switch(e){case"INDEX_MUST_NOT_EXIST":return t.indexHash!==null?"WOULD_OVERWRITE":Mo(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 Mo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_OVERWRITTEN":null;case"NO_UNTRACKED_REMOVED":return Mo(t)?await t.isIgnoredOnDisk()?null:"WOULD_LOSE_UNTRACKED_REMOVED":null}}function dl(e,t,n,r){let o=[],s=[],a=new Set(e.keys()),i=new Map;for(let c of n.entries)a.has(c.path)||o.push(c),c.stage===0&&i.set(c.path,c);for(let[c,f]of e){let d=t.get(c);if(d)switch(f.action){case"KEEP":{let u=i.get(c);u&&(o.push(u),r.reset&&r.updateWorktree&&s.push({path:c,type:"checkout",hash:u.hash,mode:u.mode}));break}case"TAKE":{let u=f.takeFrom==="head"?d.headHash:d.remoteHash,l=f.takeFrom==="head"?d.headMode:d.remoteMode,m=l?Number.parseInt(l,8):33188;o.push({path:c,mode:m,hash:u,stage:0,stat:ke()}),r.updateWorktree&&s.push({path:c,type:"checkout",hash:u,mode:m});break}case"DELETE":{r.updateWorktree&&d.existsOnDisk&&s.push({path:c,type:"delete"});break}case"SKIP":break}}return o.sort((c,f)=>Ee(c.path,f.path)||c.stage-f.stage),{newEntries:o,worktreeOps:s}}function Es(e,t){let n=t.actionHint??t.operationName,r=[];for(let{error:s,msg:a,fix:i}of ll){let c=e.filter(f=>f.error===s).map(f=>f.path).sort();if(c.length>0){let f=c.map(d=>` ${d}`).join(`
35
33
  `);r.push(`${a(t.operationName)}
36
34
  ${f}
37
35
  ${i(n)}
38
36
  `)}}return{stdout:"",stderr:r.length>0?`${r.join("")}Aborting
39
- `:"",exitCode:t.errorExitCode}}async function bn(e,t,n,r){let o=await dd(e,t,n),s=new Map(o.map(d=>[d.path,d])),a=new Map;for(let d of o){let u=r.mergeFn(d,r);a.set(d.path,u)}let i=await ud(a,s,r);if(i.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:i,errorOutput:_r(i,r)};let{newEntries:c,worktreeOps:f}=hd(a,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function be(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){let s=H(n,o.path);o.type==="delete"?await ze(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await ve(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await wn(e.fs,Pt(o),n)}async function en(e,t,n,r){return bn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Nr,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Fi(e,t,n,r){return bn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:Nr,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function Nt(e,t,n){return bn(e,[{label:"target",treeHash:t}],n,{mergeFn:Gr,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function Fr(e,t,n,r){let o=new Set;for(let i of n.entries)i.stage>0&&o.add(i.path);let s={version:n.version,entries:xe(n)},a=await bn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:Gr,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!a.success){let i=r??"HEAD",c=[];for(let f of a.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
37
+ `:"",exitCode:t.errorExitCode}}async function Fn(e,t,n,r){let o=await il(e,t,n),s=new Map(o.map(d=>[d.path,d])),a=new Map;for(let d of o){let u=r.mergeFn(d,r);a.set(d.path,u)}let i=await cl(a,s,r);if(i.length>0)return{success:!1,newEntries:[],worktreeOps:[],errors:i,errorOutput:Es(i,r)};let{newEntries:c,worktreeOps:f}=dl(a,s,n,r);return{success:!0,newEntries:c,worktreeOps:f,errors:[],errorOutput:null}}async function Oe(e,t){if(!e.workTree)return;let n=e.workTree,r=[];for(let o of t){let s=H(n,o.path);o.type==="delete"?await st(e.fs,s).then(()=>!0).catch(()=>!1)&&(await e.fs.rm(s),r.push(s)):o.type==="checkout"&&o.hash&&await We(e,{path:o.path,hash:o.hash,mode:o.mode})}for(let o of r)await _n(e.fs,Lt(o),n)}async function En(e,t,n,r){return Fn(e,[{label:"current",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:ys,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"checkout",actionHint:"switch branches"})}async function Ta(e,t,n,r){return Fn(e,[{label:"HEAD",treeHash:t},{label:"target",treeHash:n}],r,{mergeFn:ys,updateWorktree:!0,reset:!1,errorExitCode:1,operationName:"merge"})}async function rn(e,t,n){return Fn(e,[{label:"target",treeHash:t}],n,{mergeFn:bs,updateWorktree:!0,reset:!0,errorExitCode:128,operationName:"reset"})}async function ks(e,t,n,r){let o=new Set;for(let i of n.entries)i.stage>0&&o.add(i.path);let s={version:n.version,entries:He(n)},a=await Fn(e,[{label:"ORIG_HEAD",treeHash:t}],s,{mergeFn:bs,updateWorktree:!0,reset:!1,errorExitCode:128,operationName:"merge",stopAtFirstError:!0,strippedConflictPaths:o});if(!a.success){let i=r??"HEAD",c=[];for(let f of a.errors)f.error==="NOT_UPTODATE_FILE"?c.push(`error: Entry '${f.path}' not uptodate. Cannot merge.
40
38
  `):f.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"&&c.push(`error: Untracked working tree file '${f.path}' would be overwritten by merge.
41
- `);return c.length>0&&(a.errorOutput=G(c.join("")+`fatal: Could not reset index file to revision '${i}'.
42
- `,128)),a}if(e.workTree&&o.size>0){let i=await se(e,t),c=new Set(a.newEntries.map(f=>f.path));for(let f of o)!i.has(f)&&!c.has(f)&&a.worktreeOps.push({path:f,type:"delete"})}return a}function T(e){return{stdout:"",stderr:`fatal: ${e}
43
- `,exitCode:128}}function G(e,t=1){return{stdout:"",stderr:e,exitCode:t}}var gd=T("not a git repository (or any of the parent directories): .git"),wd=T("this operation must be run in a work tree");async function B(e,t,n){let r=await Hn(e,t);return r?n?{...r,...n}:r:gd}function S(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function Fe(e){return e.workTree?null:wd}async function Se(e){let t=await X(e);return t||T("your current branch does not have any commits yet")}function _t(e,t,n=`fatal: Exiting because of an unresolved conflict.
44
- `){return lt(e)?G(`error: ${t} is not possible because you have unmerged files.
39
+ `);return c.length>0&&(a.errorOutput=L(c.join("")+`fatal: Could not reset index file to revision '${i}'.
40
+ `,128)),a}if(e.workTree&&o.size>0){let i=await ae(e,t),c=new Set(a.newEntries.map(f=>f.path));for(let f of o)!i.has(f)&&!c.has(f)&&a.worktreeOps.push({path:f,type:"delete"})}return a}var ll,Wt=be(()=>{"use strict";ee();ye();fe();Gn();Ie();et();ll=[{error:"WOULD_OVERWRITE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"NOT_UPTODATE_FILE",msg:e=>`error: Your local changes to the following files would be overwritten by ${e}:`,fix:e=>`Please commit your changes or stash them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN",msg:e=>`error: The following untracked working tree files would be overwritten by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`},{error:"WOULD_LOSE_UNTRACKED_REMOVED",msg:e=>`error: The following untracked working tree files would be removed by ${e}:`,fix:e=>`Please move or remove them before you ${e}.`}]});function T(e){return{stdout:"",stderr:`fatal: ${e}
41
+ `,exitCode:128}}function L(e,t=1){return{stdout:"",stderr:e,exitCode:t}}async function U(e,t,n){let r=await Qn(e,t);return r?n?{...r,...n}:r:ul}function S(e){return typeof e=="object"&&e!==null&&"exitCode"in e}function qe(e){return e.workTree?null:ml}async function Ke(e){let t=await Y(e);return t||T("your current branch does not have any commits yet")}function sn(e,t,n=`fatal: Exiting because of an unresolved conflict.
42
+ `){return Pt(e)?L(`error: ${t} is not possible because you have unmerged files.
45
43
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
46
44
  hint: as appropriate to mark resolution and make a commit.
47
- `+n,128):null}async function Sn(e,t,n){let r=await je(e,t);return r||T(n??`bad revision '${t}'`)}async function ye(e,t,n){let r=await je(e,t);if(!r)return T(n??`bad revision '${t}'`);try{let o=await Ie(e,r),s=await j(e,o);return{hash:o,commit:s}}catch{return T(n??`bad revision '${t}'`)}}async function Le(e,t){try{return await Vn(e,t)}catch(n){return T(n.message)}}async function Ht(e,t){try{return await Or(e,t)}catch(n){return T(n.message)}}function Dn(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 he(e,t){return e<t?-1:e>t?1:0}function Ze(e,t){return e.workTree?Ke(e.workTree,t):""}function K(e){return e.slice(0,7)}function ue(e){let t=e.indexOf(`
48
- `);return t===-1?e:e.slice(0,t)}function xt(e){return T(`ambiguous argument '${e}': unknown revision or path not in the working tree.
45
+ `+n,128):null}async function It(e,t,n){let r=await Fe(e,t);return r||T(n??`bad revision '${t}'`)}async function $e(e,t,n){let r=await Fe(e,t);if(!r)return T(n??`bad revision '${t}'`);try{let o=await Ge(e,r),s=await D(e,o);return{hash:o,commit:s}}catch{return T(n??`bad revision '${t}'`)}}async function Ye(e,t){try{return await wr(e,t)}catch(n){return T(n.message)}}async function qt(e,t){try{return await es(e,t)}catch(n){return T(n.message)}}function nr(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 Ee(e,t){return e<t?-1:e>t?1:0}function ft(e,t){return e.workTree?rt(e.workTree,t):""}function K(e){return e.slice(0,7)}function se(e){let t=e.indexOf(`
46
+ `);return t===-1?e:e.slice(0,t)}function Mt(e){return T(`ambiguous argument '${e}': unknown revision or path not in the working tree.
49
47
  Use '--' to separate paths from revisions, like this:
50
- 'git <command> [<revision>...] -- [<file>...]'`)}function mt(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${K(t)}] ${ue(n)}`}async function tn(e,t,n){if(!await F(e,n.operationRef))return n.noOpError;let o=await F(e,"ORIG_HEAD")??await X(e);if(!o)return T(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await X(e),a=await j(e,o),i=await U(e),c=await Fr(e,a.tree,i,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await Xt(e,o),await re(e,{version:2,entries:c.newEntries}),await be(e,c.worktreeOps),s&&((await J(e))?.type==="symbolic"||s!==o)){let u=n.origHeadAsTargetRev?o:"HEAD";await ee(e,t,"HEAD",s,o,`reset: moving to ${u}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function Je(e,t,n,r,o,s){let a=$t({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),i=await we(e,"commit",a);return await Xt(e,i),i}function or(e){return e.split(`
48
+ 'git <command> [<revision>...] -- [<file>...]'`)}function Ot(e,t,n,r=!1){return`[${e}${r?" (root-commit)":""} ${K(t)}] ${se(n)}`}async function kn(e,t,n){if(!await F(e,n.operationRef))return n.noOpError;let o=await F(e,"ORIG_HEAD")??await Y(e);if(!o)return T(`There is no ${n.operationName} to abort (ORIG_HEAD missing).`);let s=await Y(e),a=await D(e,o),i=await W(e),c=await ks(e,a.tree,i,n.origHeadAsTargetRev?o:void 0);if(!c.success)return c.errorOutput;if(await gn(e,o),await ie(e,{version:2,entries:c.newEntries}),await Oe(e,c.worktreeOps),s&&((await Z(e))?.type==="symbolic"||s!==o)){let u=n.origHeadAsTargetRev?o:"HEAD";await ne(e,t,"HEAD",s,o,`reset: moving to ${u}`)}return await n.clearState(e),{stdout:"",stderr:"",exitCode:0}}async function dt(e,t,n,r,o,s){let a=Ut({type:"commit",tree:t,parents:n,author:r,committer:o,message:s}),i=await Re(e,"commit",a);return await gn(e,i),i}function Hr(e){return e.split(`
51
49
  `).filter(t=>!t.startsWith("#")).join(`
52
50
  `).replace(/\n+$/,`
53
- `)}function ht(e){return e.endsWith(`
51
+ `)}function $t(e){return e.endsWith(`
54
52
  `)?e:`${e}
55
- `}var Br=1,eo=2,Ur=4,to=8,ir=16,Ui=new Set(["*","?","[","\\"]),yd={glob:Br,literal:eo,icase:Ur,top:to,exclude:ir};function Ve(e){for(let t=0;t<e.length;t++)if(Ui.has(e[t]))return!0;return!1}function Ed(e){for(let t=0;t<e.length;t++)if(Ui.has(e[t]))return t;return e.length}function xd(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 Oe(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 d of f.split(",")){let u=yd[d.trim()];u!==void 0&&(n|=u)}}}else r.startsWith(":/")?(n|=to,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=ir,r=r.slice(2));n&eo&&n&Br&&(n&=~Br);let o;n&to||t===""?o=r:o=xd(`${t}/${r}`);let s=!!(n&eo),a=s?!1:Ve(o),i=s?o.length:Ed(o);return{original:e,pattern:o,magic:n,hasWildcard:a,nowildcardLen:i}}function Wr(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let i=!!(o&Ur),c=i?n.toLowerCase():n,f=i?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let i=n.slice(0,s),c=t.slice(0,s);if(o&Ur){if(i.toLowerCase()!==c.toLowerCase())return!1}else if(i!==c)return!1}let a=0;return o&Br&&(a|=2),o&Ur&&(a|=1),pn(n,t,a)===0}function me(e,t){let n=!1,r=!1;for(let o of e)o.magic&ir?Wr(o,t)&&(r=!0):Wr(o,t)&&(n=!0);return n&&!r}function Wi(e,t){e.command("add",{description:"Add file contents to the index",args:[W.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:v().alias("A").describe("Add changes from all tracked and untracked files"),force:v().alias("f").describe("Allow adding otherwise ignored files"),update:v().alias("u").describe("Update tracked files"),"dry-run":v().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=Fe(s);if(a)return a;let i=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 U(s);return p=await Bi(s,p,i,"",c),n["dry-run"]||await re(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
56
- Maybe you wanted to say 'git add .'?`,exitCode:0};let d=await U(s),u=[],l=[];for(let p of f)Ve(p)?l.push(p):u.push(p);let m=[];for(let p of u){let g=ft(r.cwd,p),w=Ke(i,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return T(`'${p}' is outside repository at '${i}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let E=d.entries.some(P=>P.path===w||P.path.startsWith(`${w}/`)),k=await Cd(s,i,w,E);if(k){m.push(k);continue}}if((await r.fs.stat(g)).isDirectory)d=await Bi(s,d,g,w,c);else{let E=d.entries.find(P=>P.path===w&&P.stage===0)?.hash,k=await Gt(s,d,w);d=k.index,c.actions&&k.hash!==E&&c.actions.push(`add '${w}'
53
+ `}var ul,ml,ee=be(()=>{"use strict";ln();ye();re();Jt();fe();Me();ue();jn();en();Wt();ul=T("not a git repository (or any of the parent directories): .git"),ml=T("this operation must be run in a work tree")});var Sa={};nd(Sa,{CommitHeap:()=>Un,countAheadBehind:()=>Lo,findOrphanedCommits:()=>No,walkCommits:()=>Kt});async function*Kt(e,t,n){let r=await El(e,n?.exclude),o=new Set(r),s=new Un,a=Array.isArray(t)?t:[t];for(let i of a)o.has(i)||s.push(await Rs(e,i));for(;s.size>0;){let i=s.pop();if(!o.has(i.hash)){o.add(i.hash),yield i;for(let c of i.commit.parents)o.has(c)||s.push(await Rs(e,c))}}}async function Lo(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let i of Kt(e,t))r.add(i.hash);let o=new Set;for await(let i of Kt(e,n))o.add(i.hash);let s=0;for(let i of r)o.has(i)||s++;let a=0;for(let i of o)r.has(i)||a++;return{ahead:s,behind:a}}async function No(e,t,n){let r=n?.maxCount??25,o=await pe(e,"refs"),s=[];for(let d of o)try{s.push(await Ge(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let a=new Set;if(s.length>0)for await(let d of Kt(e,s))a.add(d.hash);if(a.has(t))return[];let i=[],c=new Set,f=new Un;for(f.push(await Rs(e,t));f.size>0&&i.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!a.has(d.hash))){i.push({hash:d.hash,subject:se(d.commit.message)});for(let u of d.commit.parents)c.has(u)||f.push(await Rs(e,u))}}return i}async function El(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of Kt(e,t))n.add(r.hash);return n}async function Rs(e,t){return{hash:t,commit:await D(e,t)}}var Un,rr=be(()=>{"use strict";ee();re();ue();Un=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,a=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),a<r&&this.higher(n[a],n[o])&&(o=a),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}}});var fo=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 Oi(e){return new fo({_kind:"arg",type:e,required:!0})}function $i(){return Oi("string")}function Ti(){return Oi("number")}var Xr=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 lo=class e{_def;constructor(t){this._def=t}describe(t){return new e({...this._def,description:t})}alias(t){return new e({...this._def,short:t})}env(t){return new e({...this._def,env:t})}required(){return new e({...this._def,required:!0})}default(t){return new e({...this._def,default:t})}};function Hi(e){return new lo({_kind:"option",type:e})}function Ai(){return Hi("string")}function vi(){return Hi("number")}var Q={string:Ai,number:vi};function A(){return new Xr}var B={string:$i,number:Ti};function rd(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}case"invalid_type":return`Invalid value for "${e.name}": expected ${e.expected}, got "${e.received}".`;case"missing_required":return e.kind==="option"?`Missing required option "--${e.name}".`:`Missing required argument <${e.name}>.`;case"unexpected_positional":return e.maxPositionals===0?`Unexpected argument "${e.value}". This command takes no positional arguments.`:`Unexpected argument "${e.value}". Expected at most ${e.maxPositionals} positional argument${e.maxPositionals===1?"":"s"}.`;case"missing_value":return`Option "--${e.name}" requires a value.`;case"unknown_command":{let t=`Unknown command "${e.path}".`;return e.suggestions.length>0&&(t+=` Did you mean ${e.suggestions.map(n=>`"${n}"`).join(" or ")}?`),t}}}function uo(e){return e.map(rd).join(`
54
+ `)}function sd(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 a=1;a<=r;a++){let i=e[s-1]===t[a-1]?0:1;o[s*(r+1)+a]=Math.min(o[(s-1)*(r+1)+a]+1,o[s*(r+1)+(a-1)]+1,o[(s-1)*(r+1)+(a-1)]+i)}return o[n*(r+1)+r]}function Zr(e,t,n=3){return t.map(o=>({candidate:o,distance:sd(e,o)})).filter(o=>o.distance<=n&&o.distance>0).sort((o,s)=>o.distance-s.distance).slice(0,2).map(o=>o.candidate)}function Si(e,t,n,r){let o=[],s=new Map,a=new Map;for(let[l,m]of Object.entries(e)){let h=pr(l);s.set(h,{key:l,def:m}),m.short&&a.set(m.short,{key:l,def:m})}let i={},c=[],f=[],d=0;for(;d<n.length;){let l=n[d];if(l==="--"){for(d++;d<n.length;)f.push(n[d]),d++;break}if(l.startsWith("--")){let m=l.indexOf("="),h,p;m!==-1?(h=l.slice(2,m),p=l.slice(m+1)):h=l.slice(2);let g=s.get(h);if(!g){if(h.startsWith("no-")){let E=s.get(h.slice(3));if(E&&E.def._kind==="flag"){i[E.key]=E.def.counted?0:!1,d++;continue}}let b=[...s.keys()];o.push({type:"unknown_option",name:`--${h}`,suggestions:Zr(h,b).map(E=>`--${E}`)}),d++;continue}if(g.def._kind==="flag"){g.def.counted?i[g.key]=(i[g.key]||0)+1:i[g.key]=!0,d++;continue}let w=p??n[++d];if(w===void 0){o.push({type:"missing_value",name:g.key}),d++;continue}let k=hr(w,g.def.type,g.key,o);k!==void 0&&(i[g.key]=k),d++;continue}if(l.startsWith("-")&&l.length>1){let m=l.slice(1);for(let h=0;h<m.length;h++){let p=m[h],g=a.get(p);if(!g){let E=[];s.has(p)&&E.push(`--${p}`),o.push({type:"unknown_option",name:`-${p}`,suggestions:E});continue}if(g.def._kind==="flag"){g.def.counted?i[g.key]=(i[g.key]||0)+1:i[g.key]=!0;continue}let w=m.slice(h+1),k=w.length>0?w:n[++d];if(k===void 0){o.push({type:"missing_value",name:g.key});break}let b=hr(k,g.def.type,g.key,o);b!==void 0&&(i[g.key]=b);break}d++;continue}c.push(l),d++}let u=0;for(let l=0;l<t.length;l++){let m=t[l],h=m.name??`arg${l}`;if(m.variadic){let p=c.slice(u);p.length>0?i[h]=p.map(g=>hr(g,m.type,h,o)):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0?i[h]=m.default:i[h]=[],u=c.length}else{let p=c[u];p!==void 0?(i[h]=hr(p,m.type,h,o),u++):m.required?o.push({type:"missing_required",name:h,kind:"arg"}):m.default!==void 0&&(i[h]=m.default)}}if(u<c.length)for(let l=u;l<c.length;l++)o.push({type:"unexpected_positional",value:c[l],maxPositionals:t.length});for(let[l,m]of Object.entries(e))if(i[l]===void 0){if(m._kind==="flag")i[l]=m.default??(m.counted?0:!1);else if(m._kind==="option"){let h=m;if(h.env&&r?.[h.env]!==void 0){let p=hr(r[h.env],h.type,l,o);p!==void 0&&(i[l]=p)}i[l]===void 0&&(h.required&&h.default===void 0?o.push({type:"missing_required",name:l,kind:"option"}):h.default!==void 0&&(i[l]=h.default))}}return o.length>0?{ok:!1,errors:o}:{ok:!0,args:i,passthrough:f}}function hr(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 pr(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function mo(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 a of o){let i=a.name??"arg",c=a.variadic?`${i}...`:i;r.push(a.required?`<${c}>`:`[${c}]`)}if(t.push("Usage:"),t.push(` ${r.join(" ")}`),t.push(""),n){t.push("Commands:");let a=[];for(let[c,f]of e.children)a.push([c,f.description||""]);let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}if(o.length>0){t.push("Arguments:");let a=[];for(let c of o){let f=c.name??"arg",d=c.variadic?`${f}...`:f,u=[];c.description&&u.push(c.description),c.required&&u.push("(required)"),c.default!==void 0&&u.push(`(default: ${JSON.stringify(c.default)})`),a.push([d,u.join(" ")])}let i=Math.max(...a.map(([c])=>c.length));for(let[c,f]of a)if(f){let d=" ".repeat(i-c.length+2);t.push(` ${c}${d}${f}`)}else t.push(` ${c}`);t.push("")}let s=od(e.options);if(s.length>0&&(t.push("Options:"),t.push(...s),t.push("")),e.examples.length>0){t.push("Examples:");for(let a of e.examples)t.push(` ${a}`);t.push("")}return t.join(`
55
+ `)}function od(e,t){let n=Object.entries(e);if(n.length===0)return[];let r=[];for(let[a,i]of n){let c=pr(a);if(i._kind==="flag"){let f=i,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c}`);let u=[];f.description&&u.push(f.description),f.counted&&u.push("(counted)"),f.default!==void 0&&u.push(`(default: ${f.default})`),r.push([d.join(" "),u.join(" ")])}else{let f=i,d=[];f.short&&d.push(`-${f.short},`),d.push(`--${c} <${f.type}>`);let u=[];f.description&&u.push(f.description),f.required&&u.push("(required)"),f.default!==void 0&&u.push(`(default: ${JSON.stringify(f.default)})`),f.env&&u.push(`[env: ${f.env}]`),r.push([d.join(" "),u.join(" ")])}}let o=Math.max(...r.map(([a])=>a.length)),s=[];t&&s.push(t);for(let[a,i]of r)if(i){let c=" ".repeat(o-a.length+2);s.push(` ${a}${c}${i}`)}else s.push(` ${a}`);return s}function Di(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[n]=r._def;return t}function Mi(e){return e?e.map(t=>t._def):[]}var Jr=class e{name;description;options;args;examples;handler;transformArgs;children=new Map;parent;constructor(t,n,r,o,s,a,i){this.name=t,this.description=n,this.options=r,this.args=o,this.examples=s,this.handler=a,this.transformArgs=i}command(t,n){let r=new e(t,n.description,Di(n.options),Mi(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,a]of Object.entries(r)){let i=o[s],c=pr(s);if(a._kind==="flag")if(a.counted&&typeof i=="number"&&i>0)for(let f=0;f<i;f++)n.push(`--${c}`);else i===!0?n.push(`--${c}`):i===!1&&a.default===!0&&n.push(`--no-${c}`);else a._kind==="option"&&i!==void 0&&n.push(`--${c}`,String(i))}for(let s of this.args){let a=s.name??"arg",i=o[a];if(i!==void 0)if(s.variadic&&Array.isArray(i))for(let c of i)n.push(String(c));else n.push(String(i))}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,a]of Object.entries(o))if(r[s]===void 0){if(a._kind==="flag")r[s]=a.default??(a.counted?0:!1);else if(a._kind==="option"){if(a.default!==void 0)r[s]=a.default;else if(a.required)return{stdout:"",stderr:`Missing required option "${s}"`,exitCode:1}}}for(let s of this.args){let a=s.name??"arg";if(r[a]===void 0){if(s.default!==void 0)r[a]=s.default;else if(s.required)return{stdout:"",stderr:`Missing required arg "${a}"`,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(id(t))return{stdout:mo(this),stderr:"",exitCode:0};if(this.handler){let s=this.transformArgs?this.transformArgs([...t]):[...t],a=Si(this.allOptions,this.args,s,r);if(!a.ok)return{stdout:"",stderr:uo(a.errors),exitCode:1};try{return await this.handler(a.args,n,{passthrough:a.passthrough})}catch(i){return{stdout:"",stderr:i instanceof Error?i.message:String(i),exitCode:1}}}if(o&&!o.startsWith("-")){let s=Zr(o,[...this.children.keys()]);return{stdout:"",stderr:uo([{type:"unknown_command",path:`${this.fullPath} ${o}`,suggestions:s}]),exitCode:1}}return{stdout:mo(this),stderr:"",exitCode:0}}};function ho(e,t){return new Jr(e,t.description,Di(t.options),Mi(t.args),t.examples??[],t.handler,t.transformArgs)}function id(e){return e.some(t=>t==="--help"||t==="-h")}ee();ws();ye();fe();hs();var Cs=1,jo=2,xs=4,Go=8,Ar=16,Ha=new Set(["*","?","[","\\"]),pl={glob:Cs,literal:jo,icase:xs,top:Go,exclude:Ar};function ot(e){for(let t=0;t<e.length;t++)if(Ha.has(e[t]))return!0;return!1}function gl(e){for(let t=0;t<e.length;t++)if(Ha.has(e[t]))return t;return e.length}function wl(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 je(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 d of f.split(",")){let u=pl[d.trim()];u!==void 0&&(n|=u)}}}else r.startsWith(":/")?(n|=Go,r=r.slice(2)):(r.startsWith(":!")||r.startsWith(":^"))&&(n|=Ar,r=r.slice(2));n&jo&&n&Cs&&(n&=~Cs);let o;n&Go||t===""?o=r:o=wl(`${t}/${r}`);let s=!!(n&jo),a=s?!1:ot(o),i=s?o.length:gl(o);return{original:e,pattern:o,magic:n,hasWildcard:a,nowildcardLen:i}}function Ps(e,t){let{pattern:n,hasWildcard:r,magic:o,nowildcardLen:s}=e;if(n==="")return!0;if(!r){let i=!!(o&xs),c=i?n.toLowerCase():n,f=i?t.toLowerCase():t;return!!(c===f||f.startsWith(c)&&f[c.length]==="/"||c.endsWith("/")&&f.startsWith(c))}if(s>0){let i=n.slice(0,s),c=t.slice(0,s);if(o&xs){if(i.toLowerCase()!==c.toLowerCase())return!1}else if(i!==c)return!1}let a=0;return o&Cs&&(a|=2),o&xs&&(a|=1),Ln(n,t,a)===0}function we(e,t){let n=!1,r=!1;for(let o of e)o.magic&Ar?Ps(o,t)&&(r=!0):Ps(o,t)&&(n=!0);return n&&!r}et();function va(e,t){e.command("add",{description:"Add file contents to the index",args:[B.string().name("paths").describe("Pathspec of files to add").optional().variadic()],options:{all:A().alias("A").describe("Add changes from all tracked and untracked files"),force:A().alias("f").describe("Allow adding otherwise ignored files"),update:A().alias("u").describe("Update tracked files"),"dry-run":A().alias("n").describe("Don't actually add the file(s)")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=qe(s);if(a)return a;let i=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 W(s);return p=await Aa(s,p,i,"",c),n["dry-run"]||await ie(s,p),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}if(f.length===0)return{stdout:"",stderr:`Nothing specified, nothing added.
56
+ Maybe you wanted to say 'git add .'?`,exitCode:0};let d=await W(s),u=[],l=[];for(let p of f)ot(p)?l.push(p):u.push(p);let m=[];for(let p of u){let g=xt(r.cwd,p),w=rt(i,g);if((w==="."||w==="")&&(w=""),w.startsWith(".."))return T(`'${p}' is outside repository at '${i}'`);if(await r.fs.exists(g)){if(!n.force&&w!==""){let E=d.entries.some(P=>P.path===w||P.path.startsWith(`${w}/`)),x=await yl(s,i,w,E);if(x){m.push(x);continue}}if((await r.fs.stat(g)).isDirectory)d=await Aa(s,d,g,w,c);else{let E=d.entries.find(P=>P.path===w&&P.stage===0)?.hash,x=await nn(s,d,w);d=x.index,c.actions&&x.hash!==E&&c.actions.push(`add '${w}'
57
57
  `)}}else if(d.entries.some(E=>E.path===w||E.path.startsWith(`${w}/`))){if(c.actions)for(let E of d.entries)(E.path===w||E.path.startsWith(`${w}/`))&&c.actions.push(`remove '${E.path}'
58
- `);d={...d,entries:d.entries.filter(E=>E.path!==w&&!E.path.startsWith(`${w}/`))}}else return T(`pathspec '${p}' did not match any files`)}if(m.length>0)return G(`The following paths are ignored by one of your .gitignore files:
58
+ `);d={...d,entries:d.entries.filter(E=>E.path!==w&&!E.path.startsWith(`${w}/`))}}else return T(`pathspec '${p}' did not match any files`)}if(m.length>0)return L(`The following paths are ignored by one of your .gitignore files:
59
59
  ${m.join(`
60
60
  `)}
61
61
  hint: Use -f if you really want to add them.
62
62
  hint: Disable this message with "git config set advice.addIgnoredFile false"
63
- `);if(l.length>0){let p=await kd(s,r.cwd,d,l,c);if(p.error)return p.error;d=p.index}return n["dry-run"]||await re(s,d),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function kd(e,t,n,r,o){let s=e.workTree,a=Ze(e,t),i=r.map(u=>Oe(u,a)),c=new Array(i.length).fill(!1),f=u=>{for(let l=0;l<i.length;l++)i[l].hasWildcard&&Wr(i[l],u)&&(c[l]=!0)},d=[];for(let u of n.entries){if(u.stage>0||!me(i,u.path))continue;f(u.path);let l=H(s,u.path);if(await e.fs.exists(l)){let m=await Gt(e,n,u.path);n=m.index,o?.actions&&m.hash!==u.hash&&o.actions.push(`add '${u.path}'
63
+ `);if(l.length>0){let p=await bl(s,r.cwd,d,l,c);if(p.error)return p.error;d=p.index}return n["dry-run"]||await ie(s,d),{stdout:c.actions?c.actions.join(""):"",stderr:"",exitCode:0}}})}async function bl(e,t,n,r,o){let s=e.workTree,a=ft(e,t),i=r.map(u=>je(u,a)),c=new Array(i.length).fill(!1),f=u=>{for(let l=0;l<i.length;l++)i[l].hasWildcard&&Ps(i[l],u)&&(c[l]=!0)},d=[];for(let u of n.entries){if(u.stage>0||!we(i,u.path))continue;f(u.path);let l=H(s,u.path);if(await e.fs.exists(l)){let m=await nn(e,n,u.path);n=m.index,o?.actions&&m.hash!==u.hash&&o.actions.push(`add '${u.path}'
64
64
  `)}else o?.actions&&o.actions.push(`remove '${u.path}'
65
- `),d.push(u.path)}for(let u of d)n=Ne(n,u);if(!o?.updateOnly){let u=new Set(n.entries.map(m=>m.path)),l=await _e(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of l){if(u.has(m)||!me(i,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
66
- `),n=(await Gt(e,n,m)).index}}for(let u=0;u<i.length;u++){let l=i[u];if(!c[u]&&!(l.magic&ir))return{index:n,error:T(`pathspec '${l.original}' did not match any files`)}}return{index:n}}async function Bi(e,t,n,r,o){let s=r===""?"":`${r}/`,a=e.workTree,i=[],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 d=H(a,f.path);if(await e.fs.exists(d)){let u=f.stage>0,l=await Gt(e,t,f.path);t=l.index,o?.actions&&(u||l.hash!==f.hash)&&o.actions.push(`add '${f.path}'
65
+ `),d.push(u.path)}for(let u of d)n=Je(n,u);if(!o?.updateOnly){let u=new Set(n.entries.map(m=>m.path)),l=await Qe(e,s,"",{skipIgnore:o?.skipIgnore});for(let m of l){if(u.has(m)||!we(i,m))continue;f(m),o?.actions&&o.actions.push(`add '${m}'
66
+ `),n=(await nn(e,n,m)).index}}for(let u=0;u<i.length;u++){let l=i[u];if(!c[u]&&!(l.magic&Ar))return{index:n,error:T(`pathspec '${l.original}' did not match any files`)}}return{index:n}}async function Aa(e,t,n,r,o){let s=r===""?"":`${r}/`,a=e.workTree,i=[],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 d=H(a,f.path);if(await e.fs.exists(d)){let u=f.stage>0,l=await nn(e,t,f.path);t=l.index,o?.actions&&(u||l.hash!==f.hash)&&o.actions.push(`add '${f.path}'
67
67
  `)}else o?.actions&&o.actions.push(`remove '${f.path}'
68
- `),i.push(f.path)}for(let f of i)t=Ne(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(u=>u.path)),d=await _e(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let u of d){if(f.has(u))continue;o?.actions&&o.actions.push(`add '${u}'
69
- `),t=(await Gt(e,t,u)).index}}return t}async function Cd(e,t,n,r){let o=await vn(e);try{let a=await e.fs.readFile(H(t,".gitignore"));o=gn(o,a,"",H(t,".gitignore"))}catch{}let s=n.split("/");for(let a=0;a<s.length-1;a++){let i=s.slice(0,a+1).join("/"),c=H(t,i);if(Tt(o,i,!0)==="ignored")return i;try{let f=await e.fs.readFile(H(c,".gitignore"));o=gn(o,f,i,H(c,".gitignore"))}catch{}}if(!r){let a=await e.fs.stat(H(t,n)).then(i=>i.isDirectory).catch(()=>!1);if(Tt(o,n,a)==="ignored")return n}return null}function pt(e){if(e.length===0)return[];let t=e.split(`
70
- `);return t[t.length-1]===""&&t.pop(),t}function rn(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
71
- `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Pd=4,qi=1024,qr=100,Vr=0,Kr=1,Mn=2;function ro(e){let t=1;for(;t*t<e;)t++;return t}function Od(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let a=0;a<e.length;a++){let i=e[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len1++,o[a]=c}for(let a=0;a<t.length;a++){let i=t[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len2++,s[a]=c}return{classes1:o,classes2:s,classInfo:r}}function Id(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let a=o,i=0,c=s-a;for(;i<c&&e[t-1-i]===n[r-1-i];)i++;return{dstart:a,dend1:t-i-1,dend2:r-i-1}}function Ki(e,t,n,r){t-n>qr&&(n=t-qr),r-t>qr&&(r=t+qr);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Vr)o++;else if(f===Mn)s++;else break}if(o===0)return!1;let a=0,i=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===Vr)a++;else if(f===Mn)i++;else break}return a===0?!1:(a+=o,i+=s,i*Pd<i+a)}function Rd(e,t,n,r,o,s,a,i,c,f){let d=new Uint8Array(t),u=new Uint8Array(r),l=Math.min(ro(t),qi);for(let g=s;g<=a;g++){let w=o[e[g]].len2;w===0?d[g]=Vr:w>=l?d[g]=Mn:d[g]=Kr}let m=Math.min(ro(r),qi);for(let g=s;g<=i;g++){let w=o[n[g]].len1;w===0?u[g]=Vr:w>=m?u[g]=Mn:u[g]=Kr}let h=[];for(let g=s;g<=a;g++)d[g]===Kr||d[g]===Mn&&!Ki(d,g,s,a)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=i;g++)u[g]===Kr||u[g]===Mn&&!Ki(u,g,s,i)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var nn=20,zi=4,$d=256,Td=256,zr=2147483647;function Qe(e,t){return e[t]??0}function Hd(e,t,n,r,o,s,a,i,c,f){let d=t-s,u=n-o,l=t-o,m=n-s,h=l-m&1,p=l,g=l,w=m,x=m;a[l]=t,i[m]=n;for(let b=1;;b++){let E=!1;p>d?a[--p-1]=-1:++p,g<u?a[++g+1]=-1:--g;for(let k=g;k>=p;k-=2){let P;Qe(a,k-1)>=Qe(a,k+1)?P=Qe(a,k-1)+1:P=Qe(a,k+1);let C=P,O=P-k;for(;P<n&&O<s&&e[P]===r[O];)P++,O++;if(P-C>nn&&(E=!0),a[k]=P,h&&w<=k&&k<=x&&Qe(i,k)<=P)return{i1:P,i2:O,minLo:!0,minHi:!0}}w>d?i[--w-1]=zr:++w,x<u?i[++x+1]=zr:--x;for(let k=x;k>=w;k-=2){let P;Qe(i,k-1)<Qe(i,k+1)?P=Qe(i,k-1):P=Qe(i,k+1)-1;let C=P,O=P-k;for(;P>t&&O>o&&e[P-1]===r[O-1];)P--,O--;if(C-P>nn&&(E=!0),i[k]=P,!h&&p<=k&&k<=g&&P<=Qe(a,k))return{i1:P,i2:O,minLo:!0,minHi:!0}}if(!c){if(E&&b>$d){let k=0,P=null;for(let C=g;C>=p;C-=2){let O=C>l?C-l:l-C,y=Qe(a,C),I=y-C,A=y-t+(I-o)-O;if(A>zi*b&&A>k&&t+nn<=y&&y<n&&o+nn<=I&&I<s){let L=!0;for(let D=1;D<=nn;D++)if(e[y-D]!==r[I-D]){L=!1;break}L&&(k=A,P={i1:y,i2:I,minLo:!0,minHi:!1})}}if(P)return P;k=0,P=null;for(let C=x;C>=w;C-=2){let O=C>m?C-m:m-C,y=Qe(i,C),I=y-C,A=n-y+(s-I)-O;if(A>zi*b&&A>k&&t<y&&y<=n-nn&&o<I&&I<=s-nn){let L=!0;for(let D=0;D<nn;D++)if(e[y+D]!==r[I+D]){L=!1;break}L&&(k=A,P={i1:y,i2:I,minLo:!1,minHi:!0})}}if(P)return P}if(b>=f){let k=-1,P=-1;for(let y=g;y>=p;y-=2){let I=Math.min(Qe(a,y),n),A=I-y;s<A&&(I=s+y,A=s),k<I+A&&(k=I+A,P=I)}let C=zr,O=zr;for(let y=x;y>=w;y-=2){let I=Math.max(t,Qe(i,y)),A=I-y;A<o&&(I=o+y,A=o),I+A<C&&(C=I+A,O=I)}return n+s-C<k-(t+o)?{i1:P,i2:k-P,minLo:!0,minHi:!1}:{i1:O,i2:C-O,minLo:!1,minHi:!0}}}}}function so(e,t,n,r,o,s,a,i,c,f,d,u,l,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++)i[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)a[c[h]]=1;else{let h=Hd(e,t,n,r,o,s,d,u,l,m);so(e,t,h.i1,r,o,h.i2,a,i,c,f,d,u,h.minLo,m),so(e,h.i1,n,r,h.i2,s,a,i,c,f,d,u,h.minHi,m)}}function Ad(e,t,n,r){let o=[],s=0,a=0,i=1,c=1;for(;s<e.length||a<t.length;){if(s<e.length&&a<t.length&&!n[s]&&!r[a]){o.push({type:"keep",line:e[s]??"",oldLineNo:i++,newLineNo:c++}),s++,a++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:i++,newLineNo:0}),s++;for(;a<t.length&&r[a];)o.push({type:"insert",line:t[a]??"",oldLineNo:0,newLineNo:c++}),a++}return o}var Vi=200,Yi=20,Xi=100,vd=1,Sd=21,Dd=-30,Md=6,jd=-4,Ld=10,Gd=24,Nd=17,_d=23,Fd=17,Ud=60;function no(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>=Vi)return Vi}return-1}function Zi(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=no(e[n]));for(let o=n-1;o>=0&&(r.preIndent=no(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===Yi){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=no(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===Yi){r.postIndent=0;break}return r}function Ji(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=vd),e.endOfFile&&(t.penalty+=Sd);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=Dd*r,t.penalty+=Md*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?Ld:jd:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?Nd:Gd:t.penalty+=s?Fd:_d))}function Bd(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return Ud*n+(e.penalty-t.penalty)}function Qi(e,t,n,r,o,s){let a=0,i=0;for(;e[i];)i++;let c=0,f=0;for(;o[f];)f++;let d=(u,l)=>t[u]===t[l];for(;;){if(i!==a){let u,l,m;do{for(u=i-a,l=-1;a>0&&d(a-1,i-1);){for(e[--a]=1,e[--i]=0;e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=i,f>c&&(l=i);!(i>=r||!d(a,i));){for(e[a++]=0,e[i++]=1;e[i];)i++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(l=i)}}while(u!==i-a);if(i!==m)if(l!==-1)for(;f===c;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(i-u-1>g&&(g=i-u-1),i-Xi>g&&(g=i-Xi);g<=i;g++){let w={effectiveIndent:0,penalty:0},x=Zi(n,r,g);Ji(x,w);let b=Zi(n,r,g-u);Ji(b,w),(h===-1||Bd(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;i>h;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}}}if(i>=r)break;for(a=i+1,i=a;e[i];i++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function oo(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:a,classes2:i,classInfo:c}=Od(e,t),{dstart:f,dend1:d,dend2:u}=Id(a,n,i,r);if(f>d)for(let l=f;l<r-(n-1-d);l++)s[l]=1;else if(f>u)for(let l=f;l<n-(r-1-u);l++)o[l]=1;else{let{refIndex1:l,nreff1:m,refIndex2:h,nreff2:p}=Rd(a,n,i,r,c,f,d,u,o,s);if(m>0&&p>0){let g=new Array(m);for(let P=0;P<m;P++)g[P]=a[l[P]];let w=new Array(p);for(let P=0;P<p;P++)w[P]=i[h[P]];let x={},b={},E=m+p+3,k=Math.max(Td,ro(E));so(g,0,m,w,0,p,o,s,l,h,x,b,!1,k)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[l[g]]=1;Qi(o,a,e,n,s,r),Qi(s,i,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function it(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((a,i)=>({type:"insert",line:a,oldLineNo:0,newLineNo:i+1}));if(r===0)return e.map((a,i)=>({type:"delete",line:a,oldLineNo:i+1,newLineNo:0}));let{changedOld:o,changedNew:s}=oo(e,t);return Ad(e,t,o,s)}var Wd=3;function qd(e,t=Wd){if(e.length===0)return[];let n=[];for(let i=0;i<e.length;i++){let c=e[i];c&&c.type!=="keep"&&n.push(i)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),a=Math.min(e.length-1,r+t);for(let i=1;i<n.length;i++){let c=n[i]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=a+1||(o.push({start:s,end:a}),s=f),a=d}return o.push({start:s,end:a}),o.map(i=>Kd(e,i.start,i.end))}function Kd(e,t,n){let r=0,o=0,s=0,a=0,i=[],c=!1,f=!1;for(let d=t;d<=n;d++){let u=e[d];if(u)switch(u.type){case"keep":c||(r=u.oldLineNo,c=!0),f||(s=u.newLineNo,f=!0),o++,a++,i.push({type:"context",content:u.line});break;case"delete":c||(r=u.oldLineNo,c=!0),o++,i.push({type:"delete",content:u.line});break;case"insert":f||(s=u.newLineNo,f=!0),a++,i.push({type:"insert",content:u.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let d=t;d<=n;d++){let u=e[d];if(u&&u.type==="insert"){r=u.newLineNo>1?u.newLineNo-1:0;break}}if(a===0)for(let d=t;d<=n;d++){let u=e[d];if(u&&u.type==="delete"){s=u.oldLineNo>1?u.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:a,lines:i}}function Yr(e){return e?e.length<40?e:K(e):"0000000"}function ea(e,t,n,r,o,s){let{path:a,oldMode:i,newMode:c}=t;e.push(`diff --git a/${a} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${a}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${i||"100644"}`):i&&c&&i!==c&&(e.push(`old mode ${i}`),e.push(`new mode ${c}`))}function zd(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:a,oldHash:i,newHash:c}=e,f=e.renameTo!==void 0,d=e.renameTo??r,u=e.isNew??o==="",l=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(ea(m,e,d,u,l,f),o!==s){if(i||c){let h=Yr(i),p=Yr(c);u||l||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${a||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${d} differ`):u?m.push(`Binary files /dev/null and b/${d} differ`):l?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${d} differ`)}return`${m.join(`
72
- `)}
73
- `}function At(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:a,newHash:i}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=Pe(n),u=Pe(r);if(d||u)return zd(e,d,u);let l=pt(n),m=pt(r),h=n.length>0&&n.endsWith(`
74
- `),p=r.length>0&&r.endsWith(`
75
- `),g="\0NOEOL",w=l;!h&&l.length>0&&(w=l.slice(),w[w.length-1]+=g);let x=m;!p&&m.length>0&&(x=m.slice(),x[x.length-1]+=g);let b=it(w,x);if(!h||!p)for(let A of b)A.line.includes(g)&&(A.line=A.line.replace(g,""));let E=qd(b);if(E.length===0&&!c)return"";let k=e.isNew??n==="",P=e.isDeleted??r==="",C=[];if(ea(C,e,f,k,P,c),E.length===0)return`${C.join(`
76
- `)}
77
- `;if(a||i){let A=Yr(a),L=Yr(i);k||P?C.push(`index ${A}..${L}`):c?C.push(`index ${A}..${L} ${o||"100644"}`):o&&s&&o!==s?C.push(`index ${A}..${L}`):C.push(`index ${A}..${L} ${o||"100644"}`)}let O=A=>A.includes(" ")?" ":"";k?(C.push("--- /dev/null"),C.push(`+++ b/${f}${O(f)}`)):P?(C.push(`--- a/${t}${O(t)}`),C.push("+++ /dev/null")):(C.push(`--- a/${t}${O(t)}`),C.push(`+++ b/${f}${O(f)}`));let y=l.length,I=m.length;for(let A of E){let L=A.oldCount===1?`${A.oldStart}`:`${A.oldStart},${A.oldCount}`,D=A.newCount===1?`${A.newStart}`:`${A.newStart},${A.newCount}`,z="";for(let R=A.oldStart-2;R>=0;R--){let _=l[R];if(_&&/^[a-zA-Z$_]/.test(_)){z=` ${_.trimEnd().slice(0,79)}`;break}}C.push(`@@ -${L} +${D} @@${z}`);let M=A.oldStart,$=A.newStart;for(let R of A.lines)switch(R.type){case"context":C.push(` ${R.content}`),(!h&&M===y||!p&&$===I)&&C.push("\"),M++,$++;break;case"delete":C.push(`-${R.content}`),!h&&M===y&&C.push("\"),M++;break;case"insert":C.push(`+${R.content}`),!p&&$===I&&C.push("\"),$++;break}}return`${C.join(`
78
- `)}
79
- `}function jn(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Vd(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=jn(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&jn(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Yd=50;async function Ye(e,t,n=Yd){let r=new Map,o=[],s=[],a=[];for(let d of t)if(d.status==="deleted"&&d.oldHash){let u=r.get(d.oldHash)??[];u.push(d),r.set(d.oldHash,u),o.push(d)}else d.status==="added"&&d.newHash?s.push(d):a.push(d);let i=[],c=[];for(let d of s){let u=d.newHash;if(!u){c.push(d);continue}let l=r.get(u);if(l&&l.length>0){let m=Vd(l,d.path);m&&i.push({oldPath:m.path,newPath:d.path,oldHash:m.oldHash??u,newHash:u,similarity:100,oldMode:m.oldMode,newMode:d.newMode})}else c.push(d)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let d=await Xd(e,f,c,n);if(d.length>0){let u=new Set(d.map(m=>m.oldPath)),l=new Set(d.map(m=>m.newPath));f=f.filter(m=>!u.has(m.path)),c=c.filter(m=>!l.has(m.path)),i.push(...d)}}if(f.length>0&&c.length>0){let d=await Qd(e,f,c,n);if(d.length>0){let u=new Set(d.map(m=>m.oldPath)),l=new Set(d.map(m=>m.newPath));f=f.filter(m=>!u.has(m.path)),c=c.filter(m=>!l.has(m.path)),i.push(...d)}}return{remaining:[...a,...f,...c],renames:i}}async function Xd(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++){let c=t[i];if(!c)continue;let f=jn(c.path);o.has(f)?o.set(f,-1):o.set(f,i)}let s=new Map;for(let i=0;i<n.length;i++){let c=n[i];if(!c)continue;let f=jn(c.path);s.has(f)?s.set(f,-1):s.set(f,i)}let a=[];for(let[i,c]of o){if(c===-1)continue;let f=s.get(i);if(f===void 0||f===-1)continue;let d=t[c],u=n[f];if(!d?.oldHash||!u?.newHash||d.oldHash===u.newHash)continue;let l=await ot(e,d.oldHash),m=await ot(e,u.newHash),h=Jd(l,m);h<r||a.push({oldPath:d.path,newPath:u.path,oldHash:d.oldHash,newHash:u.newHash,similarity:h,oldMode:d.oldMode,newMode:u.newMode})}return a}var ta=107927;function Xr(e){let t=new Map,n=0,r=0,o=0;for(let a=0;a<e.length;a++){let i=e[a],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+i>>>0,n++,n<64&&i!==10)continue;let f=(r+Math.imul(o,97))%ta;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let a=(r+Math.imul(o,97))%ta;t.set(a,(t.get(a)??0)+n)}let s=[];for(let[a,i]of t)s.push({hash:a,count:i});return s.sort((a,i)=>a.hash-i.hash),s}function Zd(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let a=e[o];if(!a)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=a.hash)break;r+=f.count,s++}let i=a.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===a.hash&&(c=f.count,s++)}i<c?(r+=c-i,n+=i):n+=c,o++}for(;s<t.length;){let a=t[s];a&&(r+=a.count),s++}return{srcCopied:n,literalAdded:r}}function Jd(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:na(e.length,Xr(e),t.length,Xr(t))}function na(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:a}=Zd(t,r);return Math.floor(a*100/o)}async function Qd(e,t,n,r){let o=[];for(let d of t)if(d.oldHash){let u=await ot(e,d.oldHash);o.push({size:u.length,chunks:Xr(u)})}else o.push(null);let s=[];for(let d of n)if(d.newHash){let u=await ot(e,d.newHash);s.push({size:u.length,chunks:Xr(u)})}else s.push(null);let a=[];for(let d=0;d<t.length;d++){let u=t[d],l=o[d];if(!(!u||!l))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=na(l.size,l.chunks,p.size,p.chunks);if(g>=r){let w=jn(u.path)===jn(h.path)?1:0;a.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}a.sort((d,u)=>u.similarity-d.similarity||u.nameScore-d.nameScore);let i=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:u,addIdx:l}of a){if(i.has(u)||c.has(l))continue;i.add(u),c.add(l);let m=t[u],h=n[l];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:d,oldMode:m.oldMode,newMode:h.newMode})}return f}function Ln(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 a=o>0?1:0,i=0,c=n,f=r;for(;o-a<=c&&o-a<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(i=n-c),c--,f--}let d=Math.max(0,n-o-i),u=Math.max(0,r-o-i),l=e.slice(0,o),m=e.slice(n-i),h=e.slice(o,o+d),p=t.slice(o,o+u);return o+i>0?`${l}{${h} => ${p}}${m}`:`${e} => ${t}`}async function sn(e,t,n){return(await se(e,t)).get(n)?.hash??null}async function ra(e,t,n,r){let o=await Ae(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:a}=await Ye(e,o);return a.find(c=>c.newPath===r)?.oldPath??null}async function el(e,t,n,r,o,s){let a=await sn(e,(await j(e,t)).tree,n);if(!a){let p=new Map,g=await j(e,t);for(let w of r)p.set(w.finalIdx,on(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let i=await ie(e,a),c=pt(i),f=new Array(o.length),d=[...r],u=t,l=n,m=c;for(;d.length>0;){let p=await j(e,u);if(p.parents.length===0){for(let y of d)f[y.finalIdx]=on(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!0,void 0);break}let g=await sn(e,p.tree,l),w=null,x=[];for(let y of p.parents){let I=await j(e,y),A=l,L=await sn(e,I.tree,A);if(!L){let D=await ra(e,I.tree,p.tree,l);D&&(A=D,L=await sn(e,I.tree,A))}if(L&&(x.push({hash:y,path:A,blobHash:L}),L===g)){w={hash:y,path:A};break}}if(w){u=w.hash,l=w.path;continue}if(x.length===0){for(let y of d)f[y.finalIdx]=on(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,void 0);break}let b=x[0],E=await ie(e,b.blobHash),k=pt(E),P=it(k,m),C=new Map;for(let y of P)y.type==="keep"&&C.set(y.newLineNo,y.oldLineNo);let O=[];for(let y of d){let I=C.get(y.currentLine);I!==void 0?O.push({finalIdx:y.finalIdx,currentLine:I}):f[y.finalIdx]=on(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,{hash:b.hash,path:b.path})}d=O,u=b.hash,l=b.path,m=k}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function sa(e,t,n,r){let o=await j(e,t),s=await sn(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let a=await ie(e,s),i=pt(a),c=r?.startLine??1,f=r?.endLine??i.length,d=i.slice(c-1,f),u=new Array(d.length),l=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=i;for(;l.length>0;){let g=await j(e,m);if(g.parents.length===0){for(let C of l)u[C.finalIdx]=on(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await sn(e,g.tree,h),x=[],b=null;for(let C of g.parents){let O=await j(e,C),y=h,I=await sn(e,O.tree,y);if(!I){let A=await ra(e,O.tree,g.tree,h);A&&(y=A,I=await sn(e,O.tree,y))}if(I){let A={hash:C,path:y,blobHash:I};if(x.push(A),I===w){b=A;break}}}if(b){m=b.hash,h=b.path;continue}if(x.length===0){for(let C of l)u[C.finalIdx]=on(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(x.length===1){let C=x[0],O=await ie(e,C.blobHash),y=pt(O),I=it(y,p),A=new Map;for(let D of I)D.type==="keep"&&A.set(D.newLineNo,D.oldLineNo);let L=[];for(let D of l){let z=A.get(D.currentLine);z!==void 0?L.push({finalIdx:D.finalIdx,currentLine:z}):u[D.finalIdx]=on(m,h,D.currentLine,c+D.finalIdx,d[D.finalIdx],g,!1,{hash:C.hash,path:C.path})}l=L,m=C.hash,h=C.path,p=y;continue}let E=[];for(let C of x){let O=await ie(e,C.blobHash),y=pt(O),I=it(y,p),A=new Map;for(let L of I)L.type==="keep"&&A.set(L.newLineNo,L.oldLineNo);E.push({info:C,newToOld:A})}let k=new Map;for(let C of l){let O=!1;for(let y=0;y<E.length;y++){let I=E[y],A=I.newToOld.get(C.currentLine);if(A!==void 0){let L=k.get(y);L||(L={info:I.info,lines:[]},k.set(y,L)),L.lines.push({finalIdx:C.finalIdx,currentLine:A}),O=!0;break}}O||(u[C.finalIdx]=on(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:x[0].hash,path:x[0].path}))}let P=k.get(0);for(let[C,O]of k){if(C===0)continue;let y=await el(e,O.info.hash,O.info.path,O.lines,d,c);for(let[I,A]of y)u[I]=A}if(P&&P.lines.length>0){l=P.lines,m=P.info.hash,h=P.info.path;let C=await ie(e,P.info.blobHash);p=pt(C)}else break}return u}function on(e,t,n,r,o,s,a,i){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
80
- `)[0],boundary:a,previous:i}}function tl(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 nl(e,t){let n=tl(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),a=r.getUTCDate().toString().padStart(2,"0"),i=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${a} ${i}:${c}:${f} ${t}`}function rl(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),a=String(s).length,i=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=[];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 l=i&&d.origPath!==t?` ${d.origPath}`:"";if(o)f.push(`${u}${l} ${String(d.finalLine).padStart(a)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,h=nl(d.author.timestamp,d.author.timezone);f.push(`${u}${l} (${m.padEnd(c)} ${h} ${String(d.finalLine).padStart(a)}) ${d.content}`)}}return`${f.join(`
81
- `)}
82
- `}function sl(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(`
83
- `)}
84
- `}function ol(e,t,n){if(e.startsWith("/"))return Ke(n,e);let r=Ke(n,t);return r===""||r==="."?e:`${r}/${e}`}function oa(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[W.string().name("args").variadic().optional()],options:{lineRange:te.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:v().alias("l").describe("Show long revision"),showEmail:v().alias("e").describe("Show author email instead of name"),suppress:v().alias("s").describe("Suppress author name and date"),porcelain:v().alias("p").describe("Show in machine-readable format"),linePorcelain:v().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s;if(!a.workTree)return T("this operation must be run in a work tree");let i=await Se(a);if(S(i))return i;let c=n.args??[],f=o.passthrough??[],d=null,u=null;if(f.length>0?(u=f[f.length-1],c.length>0&&(d=c[0])):c.length===2?(d=c[0],u=c[1]):c.length===1&&(u=c[0]),!u)return T("no file specified");let l=ol(u,r.cwd,a.workTree),m;if(d){let P=await Sn(a,d);if(S(P))return P;m=await Ie(a,P)}else m=i;let h=await j(a,m),p=await se(a,h.tree);if(!p.has(l))return T(`no such path ${l} in ${d??"HEAD"}`);let g=p.get(l).hash,w=await ie(a,g);if(Pe(w))return T(`cannot blame binary file '${l}'`);let x,b;if(n.lineRange){let P=n.lineRange,C=P.match(/^(\d+),(\d+)$/);if(C)x=parseInt(C[1],10),b=parseInt(C[2],10);else return T(`invalid -L range: '${P}'`)}let E;try{E=await sa(a,m,l,{startLine:x,endLine:b})}catch(P){let C=P instanceof Error?P.message:String(P);return T(C)}let k;return n.porcelain||n.linePorcelain?k=sl(E,!!n.linePorcelain):k=rl(E,l,!!n.long,!!n.showEmail,!!n.suppress),{stdout:k,stderr:"",exitCode:0}}})}var il=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],al=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vt(e,t){let n=cl(t),r=new Date((e+n*60)*1e3),o=il[r.getUTCDay()],s=al[r.getUTCMonth()],a=r.getUTCDate(),i=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),d=r.getUTCFullYear();return`${o} ${s} ${a} ${i}:${c}:${f} ${d} ${t}`}function io(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 cl(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)}var Zr=new TextDecoder;function ia(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
85
- `&&t++;return e[e.length-1]!==`
86
- `&&t++,t}function Qr(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 aa(e,t,n){let r=[],o=[],s=[];for(let i of t)if(i.status==="added"&&i.newHash&&i.newMode){let c=await ot(e,i.newHash);Yt(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:i.path,sortKey:i.path,insertions:ia(Zr.decode(c)),deletions:0}),o.push({path:i.path,mode:i.newMode})}else if(i.status==="deleted"&&i.oldHash&&i.oldMode){let c=await ot(e,i.oldHash);Yt(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:i.path,sortKey:i.path,insertions:0,deletions:ia(Zr.decode(c))}),s.push({path:i.path,mode:i.oldMode})}else if(i.status==="modified"&&i.oldHash&&i.newHash){let c=await ot(e,i.oldHash),f=await ot(e,i.newHash);if(Yt(c)||Yt(f))r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=rn(Zr.decode(c)),u=rn(Zr.decode(f)),l=it(d,u),m=0,h=0;for(let p of l)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:i.path,sortKey:i.path,insertions:m,deletions:h})}i.oldMode&&i.newMode&&i.oldMode!==i.newMode&&(s.push({path:i.path,mode:i.oldMode}),o.push({path:i.path,mode:i.newMode}))}for(let i of n){let c=Ln(i.oldPath,i.newPath),f=0,d=0;if(i.similarity<100&&i.oldHash&&i.newHash){let u=await ie(e,i.oldHash),l=await ie(e,i.newHash);if(!Pe(u)&&!Pe(l)){let m=rn(u),h=rn(l),p=it(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:i.newPath,insertions:f,deletions:d})}let a=[];for(let{path:i,mode:c}of o)a.push({sortKey:i,text:` create mode ${c} ${i}`});for(let{path:i,mode:c}of s)a.push({sortKey:i,text:` delete mode ${c} ${i}`});for(let i of n){let c=Ln(i.oldPath,i.newPath);a.push({sortKey:i.newPath,text:` rename ${c} (${i.similarity}%)`})}return a.sort((i,c)=>i.sortKey<c.sortKey?-1:i.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:a.map(i=>i.text)}}async function St(e,t,n,r,o,s=!1,a=!1){let i=[];if((r.name!==o.name||r.email!==o.email)&&i.push(` Author: ${r.name} <${r.email}>`),s&&i.push(` Date: ${vt(r.timestamp,r.timezone)}`),a)return i.join(`
87
- `)+(i.length>0?`
88
- `:"");let c=await Ae(e,t,n),{remaining:f,renames:d}=await Ye(e,c),{fileStats:u,modeLines:l}=await aa(e,f,d),m=0,h=0;for(let g of u)m+=g.insertions,h+=g.deletions;let p=Qr(u.length,m,h);p&&i.push(p);for(let g of l)i.push(g);return i.join(`
89
- `)+(i.length>0?`
90
- `:"")}var Jr=80;function fl(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 ao(e){if(e.length===0)return"";let t=e.filter(h=>!h.isUnmerged),n=t.length>0?Math.max(...t.map(h=>h.insertions+h.deletions)):0,r=e.some(h=>h.isBinary),o=n>0?String(n).length:1;r&&o<3&&(o=3);let s=Math.max(...e.map(h=>h.path.length)),a=n,i=s;if(i+o+6+a>Jr){let h=Math.floor(Jr*3/8)-o-6;a>h&&(a=Math.max(h,6));let p=Jr-o-6-a;i>p?i=p:a=Jr-o-6-i}for(let h of e)h.path=fl(h.path,i);let c=i,f=[],d=0,u=0,l=0;for(let h of e){let p=h.path.padEnd(c);if(h.isUnmerged){f.push(` ${p} | Unmerged`);continue}if(l++,d+=h.insertions,u+=h.deletions,h.isBinary){let C=`${"Bin".padStart(o)} ${h.oldSize??0} -> ${h.newSize??0} bytes`;f.push(` ${p} | ${C}`);continue}let g=h.insertions+h.deletions,w=String(g).padStart(o),x,b;if(n<=a)x=h.insertions,b=h.deletions;else{let P=y=>y===0?0:1+Math.floor(y*(a-1)/n),C=P(g),O=C<2&&h.insertions>0&&h.deletions>0?2:C;h.insertions<h.deletions?(x=P(h.insertions),b=O-x):(b=P(h.deletions),x=O-b)}let E="+".repeat(x)+"-".repeat(b),k=E?` ${E}`:"";f.push(` ${p} | ${w}${k}`)}let m=Qr(l,d,u);return m?f.push(m):e.some(h=>h.isUnmerged)&&f.push(" 0 files changed"),`${f.join(`
91
- `)}
92
- `}async function an(e,t,n){let r=await Ae(e,t,n),{remaining:o,renames:s}=await Ye(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:a,modeLines:i}=await aa(e,o,s);a.sort((f,d)=>f.sortKey<d.sortKey?-1:f.sortKey>d.sortKey?1:0);let c=ao(a);for(let f of i)c+=`${f}
93
- `;return c}async function dl(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 a=await j(e,s);for(let i of a.parents)n.has(i)||r.push(i)}return n}async function Ft(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let a=o[s++];if(a===t)return!0;if(r.has(a))continue;r.add(a);let i=await j(e,a);for(let c of i.parents)r.has(c)||o.push(c)}return!1}async function gt(e,t,n){if(t===n)return[t];let r=await dl(e,t),o=[],s=new Set,a=[n],i=0;for(;i<a.length;){let f=a[i++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let d=await j(e,f);for(let u of d.parents)s.has(u)||a.push(u)}if(o.length<=1)return o;let c=[];for(let f of o){let d=!1;for(let u of o)if(u!==f&&await Ft(e,f,u)){d=!0;break}d||c.push(f)}return c.length<=1?c:ll(e,t,n,c)}async function ll(e,t,n,r){let o=new Set(r),s=new Set,a=[],i=new Map,c=new Map,f=0,d=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function u(l){let m=c.get(l);if(m!==void 0)return m;let h=(await j(e,l)).committer.timestamp;return c.set(l,h),h}for(;d.length>0;){let l=0,m=await u(d[0].hash);for(let x=1;x<d.length;x++){let b=d[x],E=await u(b.hash),k=d[l];(E>m||E===m&&b.seq<k.seq)&&(l=x,m=E)}let h=d.splice(l,1)[0],p=i.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(i.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(a.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await j(e,h.hash);for(let x of w.parents)d.push({hash:x,mask:g,seq:f++})}for(let l of r)s.has(l)||a.push(l);return a}async function Ut(e,t,n){let r=await Et(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
94
- `:`Merge branch '${t}' into ${n}
95
- `}async function es(e,t,n){let r=await j(e,t),o=await j(e,n),s=K(t),a=K(n),i=`Updating ${s}..${a}
96
- `;if(e.workTree){let f=await U(e),d=await Fi(e,r.tree,o.tree,f);if(!d.success){let u=d.errorOutput;return{stdout:i+u.stdout,stderr:u.stderr,exitCode:u.exitCode}}await re(e,{version:2,entries:d.newEntries}),await be(e,d.worktreeOps)}await Xt(e,n);let c=await an(e,r.tree,o.tree);return{stdout:`${i}Fast-forward
97
- ${c}`,stderr:"",exitCode:0}}async function qe(e,t){let n=H(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Ue(e,t,n){await e.fs.writeFile(H(e.gitDir,t),n)}async function et(e,t){let n=H(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function ar(e){await ae(e,"MERGE_HEAD"),await ae(e,"ORIG_HEAD"),await et(e,"MERGE_MSG"),await et(e,"MERGE_MODE")}async function kt(e){await ae(e,"CHERRY_PICK_HEAD"),await ae(e,"ORIG_HEAD"),await et(e,"MERGE_MSG")}async function wt(e){await ae(e,"REVERT_HEAD"),await ae(e,"ORIG_HEAD"),await et(e,"MERGE_MSG")}async function yn(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await ae(e,t);await et(e,"MERGE_MSG"),await et(e,"MERGE_MODE")}var co="DETACH_POINT";async function ca(e,t){await e.fs.writeFile(H(e.gitDir,co),t)}async function tt(e){let t=H(e.gitDir,co);await e.fs.exists(t)&&await e.fs.rm(t)}async function cr(e){let t=H(e.gitDir,co);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}function Gn(e){return H(e.gitDir,"rebase-merge")}async function bt(e){return e.fs.exists(Gn(e))}async function nt(e){let t=Gn(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(H(t,"head-name")),r=await e.fs.readFile(H(t,"orig-head")),o=await e.fs.readFile(H(t,"onto")),s=Number.parseInt(await e.fs.readFile(H(t,"msgnum")),10),a=Number.parseInt(await e.fs.readFile(H(t,"end")),10),i=await e.fs.exists(H(t,"git-rebase-todo"))?H(t,"git-rebase-todo"):H(t,"todo"),c=fa(await e.fs.readFile(i)),f=await e.fs.exists(H(t,"done"))?await e.fs.readFile(H(t,"done")):"",d=fa(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:d,msgnum:s,end:a}}async function fo(e,t){let n=Gn(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(H(n,"head-name"),`${t.headName}
68
+ `),i.push(f.path)}for(let f of i)t=Je(t,f);if(!o?.updateOnly){let f=new Set(t.entries.map(u=>u.path)),d=await Qe(e,n,r===""?"":r,{skipIgnore:o?.skipIgnore});for(let u of d){if(f.has(u))continue;o?.actions&&o.actions.push(`add '${u}'
69
+ `),t=(await nn(e,t,u)).index}}return t}async function yl(e,t,n,r){let o=await tr(e);try{let a=await e.fs.readFile(H(t,".gitignore"));o=Nn(o,a,"",H(t,".gitignore"))}catch{}let s=n.split("/");for(let a=0;a<s.length-1;a++){let i=s.slice(0,a+1).join("/"),c=H(t,i);if(Bt(o,i,!0)==="ignored")return i;try{let f=await e.fs.readFile(H(c,".gitignore"));o=Nn(o,f,i,H(c,".gitignore"))}catch{}}if(!r){let a=await e.fs.stat(H(t,n)).then(i=>i.isDirectory).catch(()=>!1);if(Bt(o,n,a)==="ignored")return n}return null}ee();ee();rr();re();fe();ue();async function Ce(e,t){let n=H(e.gitDir,t);return await e.fs.exists(n)?e.fs.readFile(n):null}async function Pe(e,t,n){await e.fs.writeFile(H(e.gitDir,t),n)}async function Se(e,t){let n=H(e.gitDir,t);await e.fs.exists(n)&&await e.fs.rm(n)}async function vr(e){await de(e,"MERGE_HEAD"),await de(e,"ORIG_HEAD"),await Se(e,"MERGE_MSG"),await Se(e,"MERGE_MODE")}async function jt(e){await de(e,"CHERRY_PICK_HEAD"),await de(e,"ORIG_HEAD"),await Se(e,"MERGE_MSG")}async function Tt(e){await de(e,"REVERT_HEAD"),await de(e,"ORIG_HEAD"),await Se(e,"MERGE_MSG")}async function Bn(e){for(let t of["CHERRY_PICK_HEAD","REVERT_HEAD","MERGE_HEAD","ORIG_HEAD"])await de(e,t);await Se(e,"MERGE_MSG"),await Se(e,"MERGE_MODE")}var _o="DETACH_POINT";async function Da(e,t){await e.fs.writeFile(H(e.gitDir,_o),t)}async function lt(e){let t=H(e.gitDir,_o);await e.fs.exists(t)&&await e.fs.rm(t)}async function Sr(e){let t=H(e.gitDir,_o);return await e.fs.exists(t)?(await e.fs.readFile(t))?.trim()??null:null}fe();ue();async function wt(e){let t=await Ce(e,"BISECT_START");return t!=null&&t.trim().length>0}async function Dr(e){let t=await Ce(e,"BISECT_TERMS");if(!t)return{termBad:"bad",termGood:"good"};let n=t.trim().split(`
70
+ `);return{termBad:n[0]??"bad",termGood:n[1]??"good"}}async function Is(e){let t=(await Ce(e,"BISECT_START"))?.trim()??"",{termBad:n,termGood:r}=await Dr(e),o=await F(e,`refs/bisect/${n}`),s=[],a=[],i=await pe(e,"refs/bisect");for(let d of i)d.name.startsWith(`refs/bisect/${r}-`)?s.push(d.hash):d.name.startsWith("refs/bisect/skip-")&&a.push(d.hash);let c=await Ce(e,"BISECT_HEAD")!=null||await e.fs.exists(H(e.gitDir,"BISECT_HEAD")),f=await e.fs.exists(H(e.gitDir,"BISECT_FIRST_PARENT"));return{startRef:t,badHash:o,goodHashes:s,skipHashes:a,termBad:n,termGood:r,noCheckout:c,firstParent:f}}async function bt(e,t){let n=await Ce(e,"BISECT_LOG")??"";await Pe(e,"BISECT_LOG",n+t+`
71
+ `)}async function Os(e){let t=await pe(e,"refs/bisect");for(let r of t)await de(e,r.name);await Se(e,"BISECT_EXPECTED_REV"),await Se(e,"BISECT_ANCESTORS_OK"),await Se(e,"BISECT_LOG"),await Se(e,"BISECT_TERMS"),await Se(e,"BISECT_NAMES"),await Se(e,"BISECT_FIRST_PARENT"),await Se(e,"BISECT_HEAD"),await Se(e,"BISECT_START");let n=H(e.gitDir,"refs","bisect");if(await e.fs.exists(n))try{await e.fs.rm(n,{recursive:!0})}catch{}}async function Ma(e,t,n,r,o){let s=[],a=new Map;for await(let g of Kt(e,t,{exclude:n})){let w=o?g.commit.parents.slice(0,1):g.commit.parents;s.push({hash:g.hash,subject:se(g.commit.message)}),a.set(g.hash,w)}let i=s.length;if(i===0)return null;if(i===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,k=[g.hash],b=0;for(;b<k.length;){let E=k[b++];if(w.has(E)||!c.has(E))continue;w.add(E);let x=a.get(E);if(x)for(let P of x)!w.has(P)&&c.has(P)&&k.push(P)}f.set(g.hash,w.size)}let d=s[0].hash,u=i;for(let g of s){if(r.has(g.hash))continue;let w=f.get(g.hash)??0,k=Math.abs(2*w-i);k<u&&(u=k,d=g.hash)}let l=!1;if(u===i){l=!0;for(let g of s){let w=f.get(g.hash)??0,k=Math.abs(2*w-i);k<u&&(u=k,d=g.hash)}}let m=s.find(g=>g.hash===d),h=kl(i),p=xl(i);return{hash:m.hash,subject:m.subject,remaining:h,steps:p,found:!1,onlySkippedLeft:l}}function kl(e){return Math.floor((e-1)/2)}function xl(e){return e<=1?0:Math.ceil(Math.log2(e))}function ja(e){let t=e.badHash!=null,n=e.goodHashes.length;return!t&&n===0?`status: waiting for both ${e.termGood} and ${e.termBad} commits
72
+ `:t?n===0?`status: waiting for ${e.termGood} commit(s), ${e.termBad} commit known
73
+ `:"":`status: waiting for ${e.termBad} commit, ${n} ${e.termGood} commit(s) known
74
+ `}function Ga(e){return`Bisecting: ${e.remaining} revision${e.remaining===1?"":"s"} left to test after this (roughly ${e.steps} step${e.steps===1?"":"s"})
75
+ [${e.hash}] ${e.subject}
76
+ `}async function La(e,t){let n=await D(e,t),r=se(n.message),s=new Date(n.author.timestamp*1e3).toUTCString().replace("GMT","+0000"),a=`${t} is the first bad commit
77
+ `;return a+=`commit ${t}
78
+ `,a+=`Author: ${n.author.name} <${n.author.email}>
79
+ `,a+=`Date: ${s}
80
+ `,a+=`
81
+ `,a+=` ${r}
82
+ `,a+=`
83
+ `,a}ee();rr();Ze();ye();re();fe();Me();ue();ee();rr();Ze();ye();re();fe();re();Jt();fe();function sr(e){return H(e.gitDir,"rebase-merge")}async function Ht(e){return e.fs.exists(sr(e))}async function ut(e){let t=sr(e);if(!await e.fs.exists(t))return null;let n=await e.fs.readFile(H(t,"head-name")),r=await e.fs.readFile(H(t,"orig-head")),o=await e.fs.readFile(H(t,"onto")),s=Number.parseInt(await e.fs.readFile(H(t,"msgnum")),10),a=Number.parseInt(await e.fs.readFile(H(t,"end")),10),i=await e.fs.exists(H(t,"git-rebase-todo"))?H(t,"git-rebase-todo"):H(t,"todo"),c=Na(await e.fs.readFile(i)),f=await e.fs.exists(H(t,"done"))?await e.fs.readFile(H(t,"done")):"",d=Na(f);return{headName:n.trim(),origHead:r.trim(),onto:o.trim(),todo:c,done:d,msgnum:s,end:a}}async function Fo(e,t){let n=sr(e);await e.fs.mkdir(n,{recursive:!0}),await e.fs.writeFile(H(n,"head-name"),`${t.headName}
98
84
  `),await e.fs.writeFile(H(n,"orig-head"),`${t.origHead}
99
85
  `),await e.fs.writeFile(H(n,"onto"),`${t.onto}
100
86
  `),await e.fs.writeFile(H(n,"msgnum"),`${String(t.msgnum)}
101
87
  `),await e.fs.writeFile(H(n,"end"),`${String(t.end)}
102
- `),await e.fs.writeFile(H(n,"git-rebase-todo"),ns(t.todo)),await e.fs.writeFile(H(n,"done"),ns(t.done)),await e.fs.writeFile(H(n,"interactive"),"")}async function ua(e){let t=Gn(e),n=await nt(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(H(t,"msgnum"),`${String(n.msgnum)}
103
- `),await e.fs.writeFile(H(t,"git-rebase-todo"),ns(n.todo)),await e.fs.writeFile(H(t,"done"),ns(n.done))}async function lo(e){let t=Gn(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function rs(e,t,n){let r=Gn(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(H(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
88
+ `),await e.fs.writeFile(H(n,"git-rebase-todo"),Ts(t.todo)),await e.fs.writeFile(H(n,"done"),Ts(t.done)),await e.fs.writeFile(H(n,"interactive"),"")}async function Ua(e){let t=sr(e),n=await ut(e);if(!n)throw new Error("No rebase in progress");let r=n.todo.shift();r&&n.done.push(r),n.msgnum=n.done.length,await e.fs.writeFile(H(t,"msgnum"),`${String(n.msgnum)}
89
+ `),await e.fs.writeFile(H(t,"git-rebase-todo"),Ts(n.todo)),await e.fs.writeFile(H(t,"done"),Ts(n.done))}async function Uo(e){let t=sr(e);await e.fs.exists(t)&&await e.fs.rm(t,{recursive:!0})}async function Hs(e,t,n){let r=sr(e),o=`@${n.timestamp} ${n.timezone}`;await e.fs.writeFile(H(r,"author-script"),`GIT_AUTHOR_NAME='${n.name}'
104
90
  GIT_AUTHOR_EMAIL='${n.email}'
105
91
  GIT_AUTHOR_DATE='${o}'
106
92
  `),await e.fs.writeFile(H(r,"stopped-sha"),`${t}
107
- `)}function fa(e){let t=[];for(let n of e.split(`
108
- `)){let r=n.trim();if(!r||r.startsWith("#"))continue;let o=r.match(/^pick\s+([0-9a-f]+)\s+(.*)/);if(o?.[1]&&o[2]){let s=o[2].startsWith("# ")?o[2].slice(2):o[2];t.push({hash:o[1],subject:s})}}return t}function ns(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
93
+ `)}function Na(e){let t=[];for(let n of e.split(`
94
+ `)){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 Ts(e){return e.length===0?"":`${e.map(t=>`pick ${t.hash} # ${t.subject}`).join(`
109
95
  `)}
110
- `}async function ma(e,t,n){let r=new Map,[o,s]=await Promise.all([da(e,t,r),da(e,n,r)]),a=new Set;for(let c of s)o.has(c)||a.add(c);let i=new Set;for(let c of o)s.has(c)||i.add(c);return{right:await la(e,r,n,a),left:await la(e,r,t,i)}}async function da(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let a=o[s++];if(r.has(a))continue;r.add(a);let i=await ts(e,a,n);for(let c of i.commit.parents)r.has(c)||o.push(c)}return r}async function la(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 d=await ts(e,f,t);for(let u of d.commit.parents)r.has(u)&&o.set(u,(o.get(u)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await ts(e,f,t));s.sort((f,d)=>f.commit.committer.timestamp-d.commit.committer.timestamp);let a=s.map(f=>f.hash),i=[],c=new Set;for(;a.length>0;){let f=a.pop();if(!f||c.has(f))continue;c.add(f);let d=await ts(e,f,t);d.commit.parents.length<=1&&i.push(d);for(let u of d.commit.parents)if(r.has(u)&&!c.has(u)){let l=(o.get(u)??0)-1;o.set(u,l),l<=0&&a.push(u)}}return i.reverse(),i}async function ts(e,t,n){let r=n.get(t);if(r)return r;let o=await fe(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Rt(o.content)};return n.set(t,s),s}var Nn=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,a=2*t+2;if(s<r&&this.higher(n[s],n[o])&&(o=s),a<r&&this.higher(n[a],n[o])&&(o=a),o===t)break;[n[t],n[o]]=[n[o],n[t]],t=o}}};async function*En(e,t,n){let r=await ul(e,n?.exclude),o=new Set(r),s=new Nn,a=Array.isArray(t)?t:[t];for(let i of a)o.has(i)||s.push(await ss(e,i));for(;s.size>0;){let i=s.pop();if(!o.has(i.hash)){o.add(i.hash),yield i;for(let c of i.commit.parents)o.has(c)||s.push(await ss(e,c))}}}async function ha(e,t,n){if(t===n)return{ahead:0,behind:0};let r=new Set;for await(let i of En(e,t))r.add(i.hash);let o=new Set;for await(let i of En(e,n))o.add(i.hash);let s=0;for(let i of r)o.has(i)||s++;let a=0;for(let i of o)r.has(i)||a++;return{ahead:s,behind:a}}async function pa(e,t,n){let r=n?.maxCount??25,o=await le(e,"refs"),s=[];for(let d of o)try{s.push(await Ie(e,d.hash))}catch{}n?.targetHash&&s.push(n.targetHash);let a=new Set;if(s.length>0)for await(let d of En(e,s))a.add(d.hash);if(a.has(t))return[];let i=[],c=new Set,f=new Nn;for(f.push(await ss(e,t));f.size>0&&i.length<r;){let d=f.pop();if(!c.has(d.hash)&&(c.add(d.hash),!a.has(d.hash))){i.push({hash:d.hash,subject:ue(d.commit.message)});for(let u of d.commit.parents)c.has(u)||f.push(await ss(e,u))}}return i}async function ul(e,t){if(!t||t.length===0)return new Set;let n=new Set;for await(let r of En(e,t))n.add(r.hash);return n}async function ss(e,t){return{hash:t,commit:await j(e,t)}}async function Be(e,t){let n=await J(e),r=await X(e),o,s=!1;n&&n.type==="symbolic"?o=de(n.target):(s=!0,o="HEAD detached");let a=t?.index??await U(e),i=mo(a),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await uo(e,c,a,i),u=await ut(e,a),l=[],m=[];for(let g of u)g.status==="untracked"?m.push(g.path):l.push({path:g.path,status:g.status});l.sort((g,w)=>he(g.path,w.path));let h=new Set(a.entries.map(g=>g.path)),p=ho(m,h);return ml(e,r,s,o,a,d,l,i,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function ga(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 ${K(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 ${K(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function ml(e,t,n,r,o,s,a,i,c,f){let d=[],u=!1,l=await F(e,"CHERRY_PICK_HEAD"),m=await F(e,"REVERT_HEAD"),h=await F(e,"MERGE_HEAD"),p=!l&&!h,w=await bt(e)?await nt(e):null;if(n&&w){let O=K(w.onto);d.push(`interactive rebase in progress; onto ${O}`)}else if(n){let O=await cr(e);if(O){let y=t===O?"at":"from";d.push(`HEAD detached ${y} ${K(O)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let O=await ce(e),y=await Bt(e,O,r);if(y){let I=xn(y,{abbreviated:f?.fromCommit});for(let A of I.trimEnd().split(`
111
- `))d.push(A);u=!0}}if(u&&(w||l||m||h)&&d.push(""),w&&h)ga(d,w),d.push(""),i.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),u=!0;else if(w){let O=lt(o),y=await e.fs.exists(H(e.gitDir,"MERGE_MSG"));ga(d,w);let A=w.headName==="detached HEAD"?null:de(w.headName),L=K(w.onto),D=A?` branch '${A}' on '${L}'`:"";if(O)d.push(`You are currently rebasing${D}.`),d.push(' (fix conflicts and then run "git rebase --continue")'),d.push(' (use "git rebase --skip" to skip this patch)'),d.push(' (use "git rebase --abort" to check out the original branch)');else if(y)d.push(`You are currently rebasing${D}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let z=D?`You are currently editing a commit while rebasing${D}.`:"You are currently editing a commit during a rebase.";d.push(z),d.push(' (use "git commit --amend" to amend the current commit)'),d.push(' (use "git rebase --continue" once you are satisfied with your changes)')}u=!0}else l?(d.push(`You are currently cherry-picking commit ${K(l)}.`),i.length>0?d.push(' (fix conflicts and run "git cherry-pick --continue")'):d.push(' (all conflicts fixed: run "git cherry-pick --continue")'),d.push(' (use "git cherry-pick --skip" to skip this patch)'),d.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),u=!0):m?(d.push(`You are currently reverting commit ${K(m)}.`),i.length>0?d.push(' (fix conflicts and run "git revert --continue")'):d.push(' (all conflicts fixed: run "git revert --continue")'),d.push(' (use "git revert --skip" to skip this patch)'),d.push(' (use "git revert --abort" to cancel the revert operation)'),u=!0):h&&(i.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),u=!0);let x=f?.isInitial??!t;x&&(d.push(""),d.push(f?.fromCommit?"Initial commit":"No commits yet"),u=!0);let b=null;p&&(b=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let k=a.some(O=>O.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',P=!1;if(s.length>0){u&&d.push(""),d.push("Changes to be committed:"),b&&d.push(b);for(let O of s)d.push(` ${wa(O.status,O.path,O.displayPath)}`);d.push(""),P=!0}if(i.length>0){!P&&u&&d.push(""),d.push("Unmerged paths:"),p&&(t?d.push(' (use "git restore --staged <file>..." to unstage)'):d.push(' (use "git rm --cached <file>..." to unstage)')),i.some(y=>y.status==="deleted by us"||y.status==="deleted by them"||y.status==="both deleted")?d.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):d.push(' (use "git add <file>..." to mark resolution)');for(let y of i)d.push(` ${hl(y.status,y.path)}`);d.push(""),P=!0}if(a.length>0){!P&&u&&d.push(""),d.push("Changes not staged for commit:"),d.push(k),d.push(' (use "git restore <file>..." to discard changes in working directory)');for(let O of a)d.push(` ${wa(O.status,O.path)}`);d.push(""),P=!0}if(c.length>0){!P&&u&&d.push(""),d.push("Untracked files:"),d.push(' (use "git add <file>..." to include in what will be committed)');for(let O of c)d.push(` ${O}`);d.push(""),P=!0}let C=s.length>0||!!h&&i.length===0;return!P&&u&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!P&&u&&a.length===0&&i.length===0&&c.length===0&&d.push(""),a.length>0||i.length>0?d.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?d.push('nothing added to commit but untracked files present (use "git add" to track)'):x?d.push('nothing to commit (create/copy files and use "git add" to track)'):d.push("nothing to commit, working tree clean")),`${d.join(`
96
+ `}async function Ba(e,t,n){let r=new Map,[o,s]=await Promise.all([_a(e,t,r),_a(e,n,r)]),a=new Set;for(let c of s)o.has(c)||a.add(c);let i=new Set;for(let c of o)s.has(c)||i.add(c);return{right:await Fa(e,r,n,a),left:await Fa(e,r,t,i)}}async function _a(e,t,n){let r=new Set,o=[t],s=0;for(;s<o.length;){let a=o[s++];if(r.has(a))continue;r.add(a);let i=await $s(e,a,n);for(let c of i.commit.parents)r.has(c)||o.push(c)}return r}async function Fa(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 d=await $s(e,f,t);for(let u of d.commit.parents)r.has(u)&&o.set(u,(o.get(u)??0)+1)}let s=[];for(let f of r)o.get(f)===0&&s.push(await $s(e,f,t));s.sort((f,d)=>f.commit.committer.timestamp-d.commit.committer.timestamp);let a=s.map(f=>f.hash),i=[],c=new Set;for(;a.length>0;){let f=a.pop();if(!f||c.has(f))continue;c.add(f);let d=await $s(e,f,t);d.commit.parents.length<=1&&i.push(d);for(let u of d.commit.parents)if(r.has(u)&&!c.has(u)){let l=(o.get(u)??0)-1;o.set(u,l),l<=0&&a.push(u)}}return i.reverse(),i}async function $s(e,t,n){let r=n.get(t);if(r)return r;let o=await he(e,t);if(o.type!=="commit")throw new Error(`Expected commit object, got ${o.type}`);let s={hash:t,commit:Ft(o.content)};return n.set(t,s),s}ue();re();function or(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Cl(e,t){if(e.length===0)return;if(e.length===1)return e.shift();let n=or(t),r=0;for(let o=0;o<e.length;o++){let s=e[o];if(s&&or(s.path)===n){r=o;break}}return e.splice(r,1)[0]}var Pl=50;async function it(e,t,n=Pl){let r=new Map,o=[],s=[],a=[];for(let d of t)if(d.status==="deleted"&&d.oldHash){let u=r.get(d.oldHash)??[];u.push(d),r.set(d.oldHash,u),o.push(d)}else d.status==="added"&&d.newHash?s.push(d):a.push(d);let i=[],c=[];for(let d of s){let u=d.newHash;if(!u){c.push(d);continue}let l=r.get(u);if(l&&l.length>0){let m=Cl(l,d.path);m&&i.push({oldPath:m.path,newPath:d.path,oldHash:m.oldHash??u,newHash:u,similarity:100,oldMode:m.oldMode,newMode:d.newMode})}else c.push(d)}let f=[...r.values()].flat();if(f.length>0&&c.length>0){let d=await Rl(e,f,c,n);if(d.length>0){let u=new Set(d.map(m=>m.oldPath)),l=new Set(d.map(m=>m.newPath));f=f.filter(m=>!u.has(m.path)),c=c.filter(m=>!l.has(m.path)),i.push(...d)}}if(f.length>0&&c.length>0){let d=await $l(e,f,c,n);if(d.length>0){let u=new Set(d.map(m=>m.oldPath)),l=new Set(d.map(m=>m.newPath));f=f.filter(m=>!u.has(m.path)),c=c.filter(m=>!l.has(m.path)),i.push(...d)}}return{remaining:[...a,...f,...c],renames:i}}async function Rl(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++){let c=t[i];if(!c)continue;let f=or(c.path);o.has(f)?o.set(f,-1):o.set(f,i)}let s=new Map;for(let i=0;i<n.length;i++){let c=n[i];if(!c)continue;let f=or(c.path);s.has(f)?s.set(f,-1):s.set(f,i)}let a=[];for(let[i,c]of o){if(c===-1)continue;let f=s.get(i);if(f===void 0||f===-1)continue;let d=t[c],u=n[f];if(!d?.oldHash||!u?.newHash||d.oldHash===u.newHash)continue;let l=await gt(e,d.oldHash),m=await gt(e,u.newHash),h=Ol(l,m);h<r||a.push({oldPath:d.path,newPath:u.path,oldHash:d.oldHash,newHash:u.newHash,similarity:h,oldMode:d.oldMode,newMode:u.newMode})}return a}var Wa=107927;function As(e){let t=new Map,n=0,r=0,o=0;for(let a=0;a<e.length;a++){let i=e[a],c=r;if(r=(r<<7^o>>>25)>>>0,o=(o<<7^c>>>25)>>>0,r=r+i>>>0,n++,n<64&&i!==10)continue;let f=(r+Math.imul(o,97))%Wa;t.set(f,(t.get(f)??0)+n),n=0,r=0,o=0}if(n>0){let a=(r+Math.imul(o,97))%Wa;t.set(a,(t.get(a)??0)+n)}let s=[];for(let[a,i]of t)s.push({hash:a,count:i});return s.sort((a,i)=>a.hash-i.hash),s}function Il(e,t){let n=0,r=0,o=0,s=0;for(;o<e.length;){let a=e[o];if(!a)break;for(;s<t.length;){let f=t[s];if(!f||f.hash>=a.hash)break;r+=f.count,s++}let i=a.count,c=0;if(s<t.length){let f=t[s];f&&f.hash===a.hash&&(c=f.count,s++)}i<c?(r+=c-i,n+=i):n+=c,o++}for(;s<t.length;){let a=t[s];a&&(r+=a.count),s++}return{srcCopied:n,literalAdded:r}}function Ol(e,t){return e.length===0&&t.length===0?100:e.length===0||t.length===0?0:qa(e.length,As(e),t.length,As(t))}function qa(e,t,n,r){let o=Math.max(e,n),s=Math.min(e,n);if(s<o-s)return 0;let{srcCopied:a}=Il(t,r);return Math.floor(a*100/o)}async function $l(e,t,n,r){let o=[];for(let d of t)if(d.oldHash){let u=await gt(e,d.oldHash);o.push({size:u.length,chunks:As(u)})}else o.push(null);let s=[];for(let d of n)if(d.newHash){let u=await gt(e,d.newHash);s.push({size:u.length,chunks:As(u)})}else s.push(null);let a=[];for(let d=0;d<t.length;d++){let u=t[d],l=o[d];if(!(!u||!l))for(let m=0;m<n.length;m++){let h=n[m],p=s[m];if(!h||!p)continue;let g=qa(l.size,l.chunks,p.size,p.chunks);if(g>=r){let w=or(u.path)===or(h.path)?1:0;a.push({similarity:g,nameScore:w,delIdx:d,addIdx:m})}}}a.sort((d,u)=>u.similarity-d.similarity||u.nameScore-d.nameScore);let i=new Set,c=new Set,f=[];for(let{similarity:d,delIdx:u,addIdx:l}of a){if(i.has(u)||c.has(l))continue;i.add(u),c.add(l);let m=t[u],h=n[l];!m||!h||f.push({oldPath:m.path,newPath:h.path,oldHash:m.oldHash??"",newHash:h.newHash??"",similarity:d,oldMode:m.oldMode,newMode:h.newMode})}return f}function ir(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 a=o>0?1:0,i=0,c=n,f=r;for(;o-a<=c&&o-a<=f&&c>=0&&f>=0;){if(c===n&&f===r){c--,f--;continue}if(e[c]!==t[f])break;e[c]==="/"&&(i=n-c),c--,f--}let d=Math.max(0,n-o-i),u=Math.max(0,r-o-i),l=e.slice(0,o),m=e.slice(n-i),h=e.slice(o,o+d),p=t.slice(o,o+u);return o+i>0?`${l}{${h} => ${p}}${m}`:`${e} => ${t}`}Ie();et();async function tt(e,t){let n=await Z(e),r=await Y(e),o,s=!1;n&&n.type==="symbolic"?o=ge(n.target):(s=!0,o="HEAD detached");let a=t?.index??await W(e),i=Wo(a),c=t?.compareHash!==void 0?t.compareHash:r,f=t?.compareHash!==void 0?!t.compareHash:!r,d=await Bo(e,c,a,i),u=await Rt(e,a),l=[],m=[];for(let g of u)g.status==="untracked"?m.push(g.path):l.push({path:g.path,status:g.status});l.sort((g,w)=>Ee(g.path,w.path));let h=new Set(a.entries.map(g=>g.path)),p=qo(m,h);return Tl(e,r,s,o,a,d,l,i,p,{fromCommit:t?.fromCommit,noWarn:t?.noWarn,isInitial:f})}function Ka(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 ${K(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 ${K(r.hash)} # ${r.subject}`);e.push(' (use "git rebase --edit-todo" to view and edit)')}else e.push("No commands remaining.")}async function Tl(e,t,n,r,o,s,a,i,c,f){let d=[],u=!1,l=await F(e,"CHERRY_PICK_HEAD"),m=await F(e,"REVERT_HEAD"),h=await F(e,"MERGE_HEAD"),p=!l&&!h,w=await Ht(e)?await ut(e):null;if(n&&w){let R=K(w.onto);d.push(`interactive rebase in progress; onto ${R}`)}else if(n){let R=await Sr(e);if(R){let y=t===R?"at":"from";d.push(`HEAD detached ${y} ${K(R)}`)}else d.push("Not currently on any branch.")}else d.push(`On branch ${r}`);if(!n&&!w){let R=await me(e),y=await on(e,R,r);if(y){let I=Wn(y,{abbreviated:f?.fromCommit});for(let v of I.trimEnd().split(`
97
+ `))d.push(v);u=!0}}if(u&&(w||l||m||h)&&d.push(""),w&&h)Ka(d,w),d.push(""),i.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),u=!0;else if(w){let R=Pt(o),y=await e.fs.exists(H(e.gitDir,"MERGE_MSG"));Ka(d,w);let v=w.headName==="detached HEAD"?null:ge(w.headName),G=K(w.onto),M=v?` branch '${v}' on '${G}'`:"";if(R)d.push(`You are currently rebasing${M}.`),d.push(' (fix conflicts and then run "git rebase --continue")'),d.push(' (use "git rebase --skip" to skip this patch)'),d.push(' (use "git rebase --abort" to check out the original branch)');else if(y)d.push(`You are currently rebasing${M}.`),d.push(' (all conflicts fixed: run "git rebase --continue")');else{let V=M?`You are currently editing a commit while rebasing${M}.`:"You are currently editing a commit during a rebase.";d.push(V),d.push(' (use "git commit --amend" to amend the current commit)'),d.push(' (use "git rebase --continue" once you are satisfied with your changes)')}u=!0}else l?(d.push(`You are currently cherry-picking commit ${K(l)}.`),i.length>0?d.push(' (fix conflicts and run "git cherry-pick --continue")'):d.push(' (all conflicts fixed: run "git cherry-pick --continue")'),d.push(' (use "git cherry-pick --skip" to skip this patch)'),d.push(' (use "git cherry-pick --abort" to cancel the cherry-pick operation)'),u=!0):m?(d.push(`You are currently reverting commit ${K(m)}.`),i.length>0?d.push(' (fix conflicts and run "git revert --continue")'):d.push(' (all conflicts fixed: run "git revert --continue")'),d.push(' (use "git revert --skip" to skip this patch)'),d.push(' (use "git revert --abort" to cancel the revert operation)'),u=!0):h&&(i.length>0?(d.push("You have unmerged paths."),d.push(' (fix conflicts and run "git commit")'),d.push(' (use "git merge --abort" to abort the merge)')):(d.push("All conflicts fixed but you are still merging."),d.push(' (use "git commit" to conclude merge)')),u=!0);if(await wt(e)){let y=(await Ce(e,"BISECT_START"))?.trim()??"";d.push(`You are currently bisecting, started from branch '${y}'.`),d.push(' (use "git bisect reset" to get back to the original branch)'),u=!0}let k=f?.isInitial??!t;k&&(d.push(""),d.push(f?.fromCommit?"Initial commit":"No commits yet"),u=!0);let b=null;p&&(b=t?' (use "git restore --staged <file>..." to unstage)':' (use "git rm --cached <file>..." to unstage)');let x=a.some(R=>R.status==="deleted")?' (use "git add/rm <file>..." to update what will be committed)':' (use "git add <file>..." to update what will be committed)',P=!1;if(s.length>0){u&&d.push(""),d.push("Changes to be committed:"),b&&d.push(b);for(let R of s)d.push(` ${za(R.status,R.path,R.displayPath)}`);d.push(""),P=!0}if(i.length>0){!P&&u&&d.push(""),d.push("Unmerged paths:"),p&&(t?d.push(' (use "git restore --staged <file>..." to unstage)'):d.push(' (use "git rm --cached <file>..." to unstage)')),i.some(y=>y.status==="deleted by us"||y.status==="deleted by them"||y.status==="both deleted")?d.push(' (use "git add/rm <file>..." as appropriate to mark resolution)'):d.push(' (use "git add <file>..." to mark resolution)');for(let y of i)d.push(` ${Hl(y.status,y.path)}`);d.push(""),P=!0}if(a.length>0){!P&&u&&d.push(""),d.push("Changes not staged for commit:"),d.push(x),d.push(' (use "git restore <file>..." to discard changes in working directory)');for(let R of a)d.push(` ${za(R.status,R.path)}`);d.push(""),P=!0}if(c.length>0){!P&&u&&d.push(""),d.push("Untracked files:"),d.push(' (use "git add <file>..." to include in what will be committed)');for(let R of c)d.push(` ${R}`);d.push(""),P=!0}let C=s.length>0||!!h&&i.length===0;return!P&&u&&(f?.noWarn||C)&&d.push(""),!C&&!f?.noWarn&&(!P&&u&&a.length===0&&i.length===0&&c.length===0&&d.push(""),a.length>0||i.length>0?d.push('no changes added to commit (use "git add" and/or "git commit -a")'):c.length>0?d.push('nothing added to commit but untracked files present (use "git add" to track)'):k?d.push('nothing to commit (create/copy files and use "git add" to track)'):d.push("nothing to commit, working tree clean")),`${d.join(`
112
98
  `)}
113
- `}async function uo(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await j(e,t)).tree);let a=await se(e,s),i=new Map(xe(n).map(m=>[m.path,m])),c=[];for(let[m,h]of i){if(o.has(m))continue;let p=a.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 a)o.has(m)||i.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await Ye(e,c),u={added:"new file",deleted:"deleted",modified:"modified"},l=[];for(let m of f){let h=u[m.status];h&&l.push({path:m.path,status:h})}for(let m of d)l.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return l.sort((m,h)=>he(m.path,h.path))}function mo(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,a=o.has(1),i=o.has(2),c=o.has(3);i&&c?s=a?"both modified":"both added":a&&!i&&!c?s="both deleted":a&&c?s="deleted by us":a&&i?s="deleted by them":i&&!a&&!c?s="added by us":c&&!a&&!i?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>he(r.path,o.path))}function ho(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 a=!1;for(let i=1;i<s.length;i++){let c=`${s.slice(0,i).join("/")}/`;if(!n.has(c)){r.add(c),a=!0;break}}a||r.add(o)}return[...r].sort()}function wa(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function hl(e,t){return`${e}:`.padEnd(17)+t}async function Bt(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,a=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),i=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await F(e,a);if(!c)return{upstream:i,ahead:0,behind:0,gone:!0};let f=await F(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:i,ahead:0,behind:0,gone:!1};let{ahead:d,behind:u}=await ha(e,f,c);return{upstream:i,ahead:d,behind:u,gone:!1}}function ba(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 xn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
99
+ `}async function Bo(e,t,n,r){let o=new Set(r?.map(m=>m.path)),s=null;t&&(s=(await D(e,t)).tree);let a=await ae(e,s),i=new Map(He(n).map(m=>[m.path,m])),c=[];for(let[m,h]of i){if(o.has(m))continue;let p=a.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 a)o.has(m)||i.has(m)||c.push({path:m,status:"deleted",oldHash:h.hash,oldMode:h.mode});let{remaining:f,renames:d}=await it(e,c),u={added:"new file",deleted:"deleted",modified:"modified"},l=[];for(let m of f){let h=u[m.status];h&&l.push({path:m.path,status:h})}for(let m of d)l.push({path:m.newPath,status:"renamed",displayPath:`${m.oldPath} -> ${m.newPath}`});return l.sort((m,h)=>Ee(m.path,h.path))}function Wo(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,a=o.has(1),i=o.has(2),c=o.has(3);i&&c?s=a?"both modified":"both added":a&&!i&&!c?s="both deleted":a&&c?s="deleted by us":a&&i?s="deleted by them":i&&!a&&!c?s="added by us":c&&!a&&!i?s="added by them":s="unmerged",n.push({path:r,status:s})}return n.sort((r,o)=>Ee(r.path,o.path))}function qo(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 a=!1;for(let i=1;i<s.length;i++){let c=`${s.slice(0,i).join("/")}/`;if(!n.has(c)){r.add(c),a=!0;break}}a||r.add(o)}return[...r].sort()}function za(e,t,n){return`${e}:`.padEnd(12)+(n??t)}function Hl(e,t){return`${e}:`.padEnd(17)+t}async function on(e,t,n){let r=t[`branch "${n}"`];if(!r?.remote||!r?.merge)return null;let o=r.remote,s=r.merge,a=s.replace(/^refs\/heads\//,`refs/remotes/${o}/`),i=`${o}/${s.replace(/^refs\/heads\//,"")}`,c=await F(e,a);if(!c)return{upstream:i,ahead:0,behind:0,gone:!0};let f=await F(e,`refs/heads/${n}`);if(!f)return null;if(f===c)return{upstream:i,ahead:0,behind:0,gone:!1};let{ahead:d,behind:u}=await Lo(e,f,c);return{upstream:i,ahead:d,behind:u,gone:!1}}function Va(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 Wn(e,t){if(e.gone)return`Your branch is based on '${e.upstream}', but the upstream is gone.
114
100
  (use "git branch --unset-upstream" to fixup)
115
101
  `;if(e.ahead===0&&e.behind===0)return`Your branch is up to date with '${e.upstream}'.
116
102
  `;if(e.ahead>0&&e.behind===0){let r=e.ahead===1?"commit":"commits";return`Your branch is ahead of '${e.upstream}' by ${e.ahead} ${r}.
@@ -120,40 +106,22 @@ GIT_AUTHOR_DATE='${o}'
120
106
  `}let n=`Your branch and '${e.upstream}' have diverged,
121
107
  and have ${e.ahead} and ${e.behind} different commits each, respectively.
122
108
  `;return t?.abbreviated?n:n+` (use "git pull" if you want to integrate the remote branch with yours)
123
- `}function ya(e,t){e.command("branch",{description:"List, create, or delete branches",args:[W.string().name("name").describe("Branch name").optional(),W.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:v().alias("d").describe("Delete a branch"),forceDelete:v().alias("D").describe("Force delete a branch"),move:v().alias("m").describe("Rename a branch"),forceMove:v().alias("M").describe("Force rename a branch"),remotes:v().alias("r").describe("List remote-tracking branches"),all:v().alias("a").describe("List all branches"),setUpstreamTo:te.string().alias("u").describe("Set upstream tracking branch"),verbose:v().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await J(s),i=a?.type==="symbolic"?de(a.target):null,c=!!n.forceMove;if(n.move||c){let w,x;if(n.newName)w=n.name,x=n.newName;else if(n.name){if(!i)return T("not on any branch");w=i,x=n.name}else return T("branch name required");let b=`refs/heads/${w}`,E=`refs/heads/${x}`,k=await F(s,b);if(!k)return T(`no branch named '${w}'`);if(await bt(s)&&(await nt(s))?.headName===b)return T(`branch ${b} is being rebased at ${s.workTree}`);let P=await F(s,E);if(P&&!c)return T(`a branch named '${x}' already exists`);P&&await ae(s,E);let C=await Me(s,b);await Y(s,E,k),await ae(s,b),w===i&&await $e(s,"HEAD",E),C.length>0&&await Zt(s,E,C);let O=`Branch: renamed ${b} to ${E}`;if(await ee(s,r.env,E,k,k,O),w===i){let A=await Ot(s,r.env);await Te(s,"HEAD",{oldHash:k,newHash:Z,...A,message:O}),await Te(s,"HEAD",{oldHash:Z,newHash:k,...A,message:O})}let y=await ce(s),I=`branch "${w}"`;return y[I]&&(y[`branch "${x}"`]=y[I],delete y[I],await Ge(s,y)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return T("branch name required");let w=n.name===i;if(!w&&!i&&await bt(s)&&(await nt(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return G(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
124
- `);let x=`refs/heads/${n.name}`,b=await F(s,x);if(!b)return G(`error: branch '${n.name}' not found
125
- `);let E="";if(!f){let k=await X(s),C=(await ce(s))[`branch "${n.name}"`],O=C?.remote,y=C?.merge,I=null,A=null;if(O&&y&&(I=y.replace(/^refs\/heads\//,`refs/remotes/${O}/`),A=await F(s,I)),A&&I){if(!(b===A||await Ft(s,b,A))){let M=k!=null&&(b===k||await Ft(s,b,k))?`warning: not deleting branch '${n.name}' that is not yet merged to
126
- '${I}', even though it is merged to HEAD
127
- `:"";return G(`${M}error: the branch '${n.name}' is not fully merged
128
- hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
129
- hint: Disable this message with "git config set advice.forceDeleteBranch false"
130
- `)}k!=null&&(b===k||await Ft(s,b,k))||(E=`warning: deleting branch '${n.name}' that has been merged to
131
- '${I}', but not yet merged to HEAD
132
- `)}else if(k&&b!==k&&!await Ft(s,b,k))return G(`error: the branch '${n.name}' is not fully merged
133
- hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
134
- hint: Disable this message with "git config set advice.forceDeleteBranch false"
135
- `)}return await ae(s,x),{stdout:`Deleted branch ${n.name} (was ${K(b)}).
136
- `,stderr:E,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,x=n.name||i;if(!x)return T("could not set upstream of HEAD when it does not point to any branch.");if(!await F(s,`refs/heads/${x}`))return T(`branch '${x}' does not exist`);let E=w.indexOf("/");if(E<0)return T(`the requested upstream branch '${w}' does not exist`);let k=w.slice(0,E),P=w.slice(E+1);if(!await F(s,`refs/remotes/${w}`))return T(`the requested upstream branch '${w}' does not exist`);let O=await ce(s),y=`branch "${x}"`;return O[y]||(O[y]={}),O[y].remote=k,O[y].merge=`refs/heads/${P}`,await Ge(s,O),{stdout:"",stderr:`branch '${x}' set up to track '${w}'.
137
- `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,x;if(w){let P=await ye(s,w,`not a valid object name: '${w}'`);if(S(P))return P;x=P.hash}else if(x=await X(s),!x)return T("Not a valid object name: 'HEAD'.");let b=`refs/heads/${n.name}`;if(await F(s,b))return T(`a branch named '${n.name}' already exists`);await Y(s,b,x);let k=w??"HEAD";return await ee(s,r.env,b,null,x,`branch: Created from ${k}`),{stdout:"",stderr:"",exitCode:0}}let d=n.verbose||0,u=!n.remotes||n.all,l=n.remotes||n.all,m=[];if(u&&!i){let w=await X(s);if(w){let x=await bt(s),b;if(x){let E=await nt(s);if(E?.headName){let k=de(E.headName);if(k==="detached HEAD"){let P=await cr(s);b=`(no branch, rebasing detached HEAD ${P?K(P):"(null)"})`}else b=`(no branch, rebasing ${k})`}else b="(no branch)"}else{let E=await cr(s);E?b=`(HEAD detached ${w===E?"at":"from"} ${K(E)})`:b="(no branch)"}m.push({displayName:b,hash:w,isCurrent:!0,branchName:null})}}if(u){let w=await le(s,"refs/heads");for(let x of w){let b=de(x.name);m.push({displayName:b,hash:x.hash,isCurrent:b===i,branchName:b})}}if(l){let w=await le(s,"refs/remotes");for(let x of w){let b=x.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${b}`:b,hash:x.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(d===0)return{stdout:`${m.map(x=>x.isCurrent?`* ${x.displayName}`:` ${x.displayName}`).join(`
138
- `)}
139
- `,stderr:"",exitCode:0};let h=d>=1?await ce(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let x=w.isCurrent?"* ":" ",b=w.displayName.padEnd(p),E=K(w.hash),k="";try{let C=await j(s,w.hash);k=ue(C.message)}catch{}let P="";if(h&&w.branchName){let C=await Bt(s,h,w.branchName);if(C){let O=ba(C,d>=2);O&&(P=` ${O}`)}}g.push(`${x}${b} ${E}${P} ${k}`)}return{stdout:`${g.join(`
140
- `)}
141
- `,stderr:"",exitCode:0}}})}async function os(e){let t=await Me(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],a=`refs/heads/${s}`,i=await F(e,a);if(i)return{name:s,refName:a,hash:i}}}return null}async function Wt(e){let t="";return await F(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
109
+ `}Ie();Wt();et();async function vs(e){let t=await Ve(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],a=`refs/heads/${s}`,i=await F(e,a);if(i)return{name:s,refName:a,hash:i}}}return null}async function an(e){let t="";return await F(e,"CHERRY_PICK_HEAD")&&(t=`warning: cancelling a cherry picking in progress
142
110
  `),await F(e,"REVERT_HEAD")&&(t+=`warning: cancelling a revert in progress
143
- `),await yn(e),t}function pl(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(`
144
- `)}
145
- `:""}function cn(e){return e.entries.some(t=>t.stage>0)?{stdout:pl(e),stderr:`error: you need to resolve your current index first
146
- `,exitCode:1}:null}async function is(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");if(r)return gl(e,t,n,r);let o=await U(e);if(t.some(Ve)){let a=t.map(c=>Oe(c,n)),i=o.entries.filter(c=>c.stage===0&&me(a,c.path));if(i.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
147
- `);for(let c of i)await ve(e,{path:c.path,hash:c.hash,mode:c.mode})}else for(let a of t){let i=Dt(o,a);if(!i)return o.entries.some(f=>f.path===a&&f.stage>0)?G(`error: path '${a}' is unmerged
148
- `):G(`error: pathspec '${a}' did not match any file(s) known to git
149
- `);await ve(e,{path:i.path,hash:i.hash,mode:i.mode})}return{stdout:"",stderr:"",exitCode:0}}async function gl(e,t,n,r){let o=await se(e,r),s=await U(e),a=t.some(Ve),i=[];if(a){let c=t.map(f=>Oe(f,n));for(let[f]of o)me(c,f)&&i.push(f);if(i.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
150
- `)}else for(let c of t){if(!o.get(c))return G(`error: pathspec '${c}' did not match any file(s) known to git
151
- `);i.push(c)}for(let c of i){let f=o.get(c);f&&(await ve(e,{path:f.path,hash:f.hash,mode:f.mode}),s=Xe(s,{path:f.path,hash:f.hash,mode:parseInt(f.mode,8),stage:0,stat:pe()}))}return await re(e,s),{stdout:"",stderr:"",exitCode:0}}async function as(e,t,n,r,o){if(!e.workTree)return T("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,a=await U(e);if(t.some(Ve)){let c=t.map(d=>Oe(d,n)),f=new Set;for(let d of a.entries)me(c,d.path)&&f.add(d.path);if(f.size===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
152
- `);for(let d of f){let u=a.entries.find(h=>h.path===d&&h.stage===r),l=!u&&a.entries.find(h=>h.path===d&&h.stage===0),m=u||l;if(m)await ve(e,{path:m.path,hash:m.hash,mode:m.mode});else if(s){let h=H(e.workTree,d);await e.fs.exists(h)&&await e.fs.rm(h)}}}else for(let c of t)if(a.entries.some(d=>d.path===c&&d.stage>0)){let d=a.entries.find(u=>u.path===c&&u.stage===r);if(d)await ve(e,{path:d.path,hash:d.hash,mode:d.mode});else if(s){let u=H(e.workTree,c);await e.fs.exists(u)&&await e.fs.rm(u)}else return G(`error: path '${c}' does not have ${r===2?"our":"their"} version
153
- `)}else{let d=Dt(a,c);if(!d)return G(`error: pathspec '${c}' did not match any file(s) known to git
154
- `);await ve(e,{path:d.path,hash:d.hash,mode:d.mode})}return{stdout:"",stderr:"",exitCode:0}}async function kn(e,t,n){if(!e.workTree)return"";let r=await He(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 a=new Map;for(let[c]of s){let f=H(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let u=await e.fs.readFileBuffer(f);a.set(c,await st("blob",u))}}else a.set(c,null)}let i=[];for(let[c,f]of o){let d=s.get(c);if(d===void 0){i.push(`D ${c}`);continue}let u=a.get(c);u===null?i.push(`D ${c}`):(d!==f||u!==void 0&&u!==f)&&i.push(`M ${c}`)}for(let[c]of s)o.has(c)||a.get(c)!=null&&i.push(`A ${c}`);return i.length===0?"":(i.sort((c,f)=>{let d=c.slice(2),u=f.slice(2);return d<u?-1:d>u?1:0}),`${i.join(`
155
- `)}
156
- `)}var Ea=5;function wl(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Ea?Ea-1:t,a=e.slice(0,o).map(c=>` ${K(c.hash)} ${c.subject}`),i=t-o;return i>0&&a.push(` ... and ${i} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
111
+ `),await Bn(e),t}function Al(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(`
112
+ `)}
113
+ `:""}function xn(e){return e.entries.some(t=>t.stage>0)?{stdout:Al(e),stderr:`error: you need to resolve your current index first
114
+ `,exitCode:1}:null}async function Ss(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");if(r)return vl(e,t,n,r);let o=await W(e);if(t.some(ot)){let a=t.map(c=>je(c,n)),i=o.entries.filter(c=>c.stage===0&&we(a,c.path));if(i.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
115
+ `);for(let c of i)await We(e,{path:c.path,hash:c.hash,mode:c.mode})}else for(let a of t){let i=Xt(o,a);if(!i)return o.entries.some(f=>f.path===a&&f.stage>0)?L(`error: path '${a}' is unmerged
116
+ `):L(`error: pathspec '${a}' did not match any file(s) known to git
117
+ `);await We(e,{path:i.path,hash:i.hash,mode:i.mode})}return{stdout:"",stderr:"",exitCode:0}}async function vl(e,t,n,r){let o=await ae(e,r),s=await W(e),a=t.some(ot),i=[];if(a){let c=t.map(f=>je(f,n));for(let[f]of o)we(c,f)&&i.push(f);if(i.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
118
+ `)}else for(let c of t){if(!o.get(c))return L(`error: pathspec '${c}' did not match any file(s) known to git
119
+ `);i.push(c)}for(let c of i){let f=o.get(c);f&&(await We(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:ke()}))}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}async function Ds(e,t,n,r,o){if(!e.workTree)return T("this operation must be run in a work tree");let s=o?.deleteOnMissing??!1,a=await W(e);if(t.some(ot)){let c=t.map(d=>je(d,n)),f=new Set;for(let d of a.entries)we(c,d.path)&&f.add(d.path);if(f.size===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
120
+ `);for(let d of f){let u=a.entries.find(h=>h.path===d&&h.stage===r),l=!u&&a.entries.find(h=>h.path===d&&h.stage===0),m=u||l;if(m)await We(e,{path:m.path,hash:m.hash,mode:m.mode});else if(s){let h=H(e.workTree,d);await e.fs.exists(h)&&await e.fs.rm(h)}}}else for(let c of t)if(a.entries.some(d=>d.path===c&&d.stage>0)){let d=a.entries.find(u=>u.path===c&&u.stage===r);if(d)await We(e,{path:d.path,hash:d.hash,mode:d.mode});else if(s){let u=H(e.workTree,c);await e.fs.exists(u)&&await e.fs.rm(u)}else return L(`error: path '${c}' does not have ${r===2?"our":"their"} version
121
+ `)}else{let d=Xt(a,c);if(!d)return L(`error: pathspec '${c}' did not match any file(s) known to git
122
+ `);await We(e,{path:d.path,hash:d.hash,mode:d.mode})}return{stdout:"",stderr:"",exitCode:0}}async function qn(e,t,n){if(!e.workTree)return"";let r=await Ue(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 a=new Map;for(let[c]of s){let f=H(e.workTree,c);if(await e.fs.exists(f)){if((await e.fs.stat(f)).isFile){let u=await e.fs.readFileBuffer(f);a.set(c,await pt("blob",u))}}else a.set(c,null)}let i=[];for(let[c,f]of o){let d=s.get(c);if(d===void 0){i.push(`D ${c}`);continue}let u=a.get(c);u===null?i.push(`D ${c}`):(d!==f||u!==void 0&&u!==f)&&i.push(`M ${c}`)}for(let[c]of s)o.has(c)||a.get(c)!=null&&i.push(`A ${c}`);return i.length===0?"":(i.sort((c,f)=>{let d=c.slice(2),u=f.slice(2);return d<u?-1:d>u?1:0}),`${i.join(`
123
+ `)}
124
+ `)}var Ya=5;function Sl(e){let t=e.length,n=t===1?"commit":"commits",r=t===1?"it":"them",o=t>Ya?Ya-1:t,a=e.slice(0,o).map(c=>` ${K(c.hash)} ${c.subject}`),i=t-o;return i>0&&a.push(` ... and ${i} more.`),`Warning: you are leaving ${t} ${n} behind, not connected to
157
125
  any of your branches:
158
126
 
159
127
  ${a.join(`
@@ -164,10 +132,10 @@ to do so with:
164
132
 
165
133
  git branch <new-branch-name> ${K(e[0].hash)}
166
134
 
167
- `}async function po(e,t){let n=await j(e,t);return`Previous HEAD position was ${K(t)} ${ue(n.message)}
168
- `}async function cs(e,t,n){let r=await pa(e,t,{targetHash:n});return r.length>0?wl(r):t!==n?po(e,t):""}async function fs(e,t,n,r,o,s){let a=await J(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
169
- `,exitCode:0};let i=await U(e),c=cn(i);if(c)return c;let f=await X(e),u=(await j(e,r)).tree,l=null;if(f&&(l=(await j(e,f)).tree),l!==u){let b=await en(e,l,u,i);if(!b.success)return b.errorOutput??G("error: checkout would overwrite local changes");i={version:2,entries:b.newEntries},await re(e,i),await be(e,b.worktreeOps)}let m="";a?.type==="direct"&&f&&(m=await cs(e,f,r));let h=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):f??Z;await $e(e,"HEAD",n),await tt(e);let p=await Wt(e);await ee(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:r,isBranchCheckout:!0});let g=await kn(e,u,i),w=await ce(e),x=await Bt(e,w,t);return x&&(g+=xn(x)),{stdout:g,stderr:`${m}Switched to branch '${t}'
170
- ${p}`,exitCode:0}}async function ds(e,t,n,r,o){let s=await U(e),a=cn(s);if(a)return a;let i=await X(e),c=await j(e,t),f=c.tree,d=null;if(i&&(d=(await j(e,i)).tree),d!==f){let b=await en(e,d,f,s);if(!b.success)return b.errorOutput??G("error: checkout would overwrite local changes");s={version:2,entries:b.newEntries},await re(e,s),await be(e,b.worktreeOps)}let u=await J(e),l=u?.type==="direct"&&i===t;if(await Y(e,"HEAD",t),!l){await ca(e,t);let b=u?.type==="symbolic"?u.target.replace(/^refs\/heads\//,""):i??Z;await ee(e,n,"HEAD",i,t,`checkout: moving from ${b} to ${t}`)}let m=await Wt(e);await r?.hooks?.emitPost("post-checkout",{prevHead:i,newHead:t,isBranchCheckout:!1});let h=K(t),p=ue(c.message),g=u?.type==="direct",w="";return g&&i&&i!==t&&(w+=await cs(e,i,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
135
+ `}async function Ko(e,t){let n=await D(e,t);return`Previous HEAD position was ${K(t)} ${se(n.message)}
136
+ `}async function Ms(e,t,n){let r=await No(e,t,{targetHash:n});return r.length>0?Sl(r):t!==n?Ko(e,t):""}async function ar(e,t,n,r,o,s){let a=await Z(e);if(a?.type==="symbolic"&&a.target===n)return{stdout:"",stderr:`Already on '${t}'
137
+ `,exitCode:0};let i=await W(e),c=xn(i);if(c)return c;let f=await Y(e),u=(await D(e,r)).tree,l=null;if(f&&(l=(await D(e,f)).tree),l!==u){let b=await En(e,l,u,i);if(!b.success)return b.errorOutput??L("error: checkout would overwrite local changes");i={version:2,entries:b.newEntries},await ie(e,i),await Oe(e,b.worktreeOps)}let m="";a?.type==="direct"&&f&&(m=await Ms(e,f,r));let h=a?.type==="symbolic"?a.target.replace(/^refs\/heads\//,""):f??J;await Ne(e,"HEAD",n),await lt(e);let p=await an(e);await ne(e,o,"HEAD",f,r,`checkout: moving from ${h} to ${t}`),await s?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:r,isBranchCheckout:!0});let g=await qn(e,u,i),w=await me(e),k=await on(e,w,t);return k&&(g+=Wn(k)),{stdout:g,stderr:`${m}Switched to branch '${t}'
138
+ ${p}`,exitCode:0}}async function Cn(e,t,n,r,o){let s=await W(e),a=xn(s);if(a)return a;let i=await Y(e),c=await D(e,t),f=c.tree,d=null;if(i&&(d=(await D(e,i)).tree),d!==f){let b=await En(e,d,f,s);if(!b.success)return b.errorOutput??L("error: checkout would overwrite local changes");s={version:2,entries:b.newEntries},await ie(e,s),await Oe(e,b.worktreeOps)}let u=await Z(e),l=u?.type==="direct"&&i===t;if(await z(e,"HEAD",t),!l){await Da(e,t);let b=u?.type==="symbolic"?u.target.replace(/^refs\/heads\//,""):i??J;await ne(e,n,"HEAD",i,t,`checkout: moving from ${b} to ${t}`)}let m=await an(e);await r?.hooks?.emitPost("post-checkout",{prevHead:i,newHead:t,isBranchCheckout:!1});let h=K(t),p=se(c.message),g=u?.type==="direct",w="";return g&&i&&i!==t&&(w+=await Ms(e,i,t)),g||!o?.detachAdviceTarget?w+=`HEAD is now at ${h} ${p}
171
139
  `:w=`Note: switching to '${o.detachAdviceTarget}'.
172
140
 
173
141
  You are in 'detached HEAD' state. You can look around, make experimental
@@ -186,18 +154,91 @@ Or undo this operation with:
186
154
  Turn off this advice by setting config variable advice.detachedHead to false
187
155
 
188
156
  HEAD is now at ${h} ${p}
189
- `,w+=m,{stdout:await kn(e,f,s),stderr:w,exitCode:0}}function xa(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[W.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:v().alias("b").describe("Create and switch to a new branch"),forceBranch:v().alias("B").describe("Create/reset and switch to a new branch"),orphan:v().describe("Create a new orphan branch"),ours:v().describe("Checkout our version for unmerged files"),theirs:v().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.target;if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");if(o.passthrough.length>0){let u=Ze(a,r.cwd),l=o.passthrough,m=null;if(i){if(n.ours||n.theirs)return T("cannot specify both a revision and --ours/--theirs");let h=await ye(a,i,`invalid reference: ${i}`);if(S(h))return h;m=h.commit.tree}return n.ours||n.theirs?as(a,l,u,n.theirs?3:2):is(a,l,u,m)}if(n.orphan)return n.branch?T("--orphan and -b are incompatible"):n.ours||n.theirs?T("--orphan and --ours/--theirs are incompatible"):i?yl(a,i,r.env,t):T("you must specify a branch to checkout");if(!i)return T("you must specify a branch to checkout");if(n.branch||n.forceBranch)return El(a,i,r.env,t,!!n.forceBranch);if(i==="-")return bl(a,r.env,t);let c=`refs/heads/${i}`,f=await F(a,c);if(f)return ka(a,i,c,f,r.env,t);let d=await je(a,i);if(d){let u=await Ie(a,d);return xl(a,i,u,r.env,t)}if(a.workTree){let u=await U(a),l=Dt(u,i);if(l)return await ve(a,{path:l.path,hash:l.hash,mode:l.mode}),{stdout:"",stderr:"",exitCode:0}}return G(`error: pathspec '${i}' did not match any file(s) known to git
190
- `)}})}async function bl(e,t,n){let r=await os(e);return r?ka(e,r.name,r.refName,r.hash,t,n):T("no previous branch")}async function yl(e,t,n,r){let o=`refs/heads/${t}`;if(await F(e,o))return T(`a branch named '${t}' already exists`);let a=await U(e),i=cn(a);if(i)return i;let c=await X(e),f=null;c&&(f=(await j(e,c)).tree),await $e(e,"HEAD",o),await tt(e);let d=await Wt(e);await r?.hooks?.emitPost("post-checkout",{prevHead:c,newHead:Z,isBranchCheckout:!0});let u="";return f&&(u=await kn(e,f,a)),{stdout:u,stderr:`Switched to a new branch '${t}'
191
- ${d}`,exitCode:0}}async function El(e,t,n,r,o=!1){if(r?.hooks){let p=await r.hooks.emitPre("pre-checkout",{target:t,mode:"create-branch"});if(p)return{stdout:"",stderr:p.message??"",exitCode:1}}let s=await J(e),a=await X(e),i=`refs/heads/${t}`,c=await F(e,i);if(c&&!o)return T(`a branch named '${t}' already exists`);if(o){let p=await U(e),g=cn(p);if(g)return g}a&&await Y(e,i,a),await $e(e,"HEAD",i),await tt(e);let f=await Wt(e),d=s?.type==="symbolic"?s.target.replace(/^refs\/heads\//,""):a??Z;a&&await ee(e,n,i,c,a,c?"branch: Reset to HEAD":"branch: Created from HEAD"),await ee(e,n,"HEAD",a,a??Z,`checkout: moving from ${d} to ${t}`),await r?.hooks?.emitPost("post-checkout",{prevHead:a,newHead:a??Z,isBranchCheckout:!0});let u="";if(o&&a){let p=await U(e),g=await j(e,a);u=await kn(e,g.tree,p)}let l=await ce(e),m=await Bt(e,l,t);m&&(u+=xn(m));let h=c?`Switched to and reset branch '${t}'
157
+ `,w+=m,{stdout:await qn(e,f,s),stderr:w,exitCode:0}}re();fe();ue();en();var Xa=new Set(["help","start","skip","next","reset","visualize","view","replay","log","run","terms"]),jr={stdout:`You need to start by "git bisect start"
158
+ `,stderr:"",exitCode:1};async function zo(e){let t=await Ce(e,"BISECT_HEAD");if(t?.trim())return t.trim();let n=await Y(e);return n||T("no current commit")}function Za(e,t){let n=e.command("bisect",{description:"Use binary search to find the commit that introduced a bug",args:[B.string().name("subcommand").describe("Subcommand or custom term").optional(),B.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]
159
+ `,exitCode:1};let a=r.rest??[],i=await U(o.fs,o.cwd,t);return S(i)?i:Gl(i,o.env,t,s,a)}});Dl(n,t),Ml(n,t),Ll(n,t),Nl(n,t),Fl(n,t),Ul(n,t),Wl(n,t),Kl(n,t),zl(n,t)}function Dl(e,t){e.command("start",{description:"Start bisecting",args:[B.string().name("revs").describe("Bad and good revisions").optional().variadic()],options:{"term-new":Q.string().describe("Alternate term for new/bad"),"term-bad":Q.string().describe("Alternate term for new/bad"),"term-old":Q.string().describe("Alternate term for old/good"),"term-good":Q.string().describe("Alternate term for old/good"),"no-checkout":A().describe("Do not checkout the bisection commit"),"first-parent":A().describe("Follow only first parent on merges")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=qe(s);if(a&&!n["no-checkout"])return a;let i=n["term-new"]??n["term-bad"]??"bad",c=n["term-old"]??n["term-good"]??"good";return Xa.has(i)?T(`'${i}' is not a valid term`):Xa.has(c)?T(`'${c}' is not a valid term`):i===c?T("'bad' and 'good' terms must be different"):Ja(s,r.env,t,n.revs??[],i,c,n["no-checkout"]??!1,n["first-parent"]??!1)}})}async function Ja(e,t,n,r,o,s,a,i){await wt(e)&&await Os(e);let c=await Z(e),f;if(c?.type==="symbolic"?f=c.target.replace(/^refs\/heads\//,""):f=await Y(e)??"HEAD",await Pe(e,"BISECT_START",f+`
160
+ `),await Pe(e,"BISECT_TERMS",`${o}
161
+ ${s}
162
+ `),await Pe(e,"BISECT_NAMES",`
163
+ `),i&&await Pe(e,"BISECT_FIRST_PARENT",""),a){let l=await Y(e);l&&await Pe(e,"BISECT_HEAD",l)}if(r.length>0){let l=r[0],m=await It(e,l);if(S(m))return m;await z(e,`refs/bisect/${o}`,m);let h=await D(e,m);await bt(e,`# ${o}: [${m}] ${se(h.message)}`);for(let p=1;p<r.length;p++){let g=r[p],w=await It(e,g);if(S(w))return w;await z(e,`refs/bisect/${s}-${w}`,w);let k=await D(e,w);await bt(e,`# ${s}: [${w}] ${se(k.message)}`)}}let d=r.map(l=>`'${l}'`),u=d.length>0?` ${d.join(" ")}`:"";return await bt(e,`git bisect start${u}`),Gr(e,t,n)}function Ml(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:[B.string().name("rev").describe("Revision to mark").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);return S(s)?s:jl(s,o.env,t,n,r.rev)}})}async function jl(e,t,n,r,o){if(!await wt(e))return jr;let s=await Dr(e),a=r==="bad"||r==="new"?s.termBad:s.termGood;return Mr(e,t,n,a,s,o)}async function Gl(e,t,n,r,o){if(!await wt(e))return jr;let s=await Dr(e);return r!==s.termBad&&r!==s.termGood?{stdout:"",stderr:`error: unknown command: 'git bisect ${r}'
164
+ `,exitCode:1}:Mr(e,t,n,r,s,o[0])}async function Mr(e,t,n,r,o,s){let a;if(s){let f=await It(e,s);if(S(f))return f;a=f}else{let f=await zo(e);if(S(f))return f;a=f}let i=await D(e,a),c=se(i.message);return r===o.termBad?await z(e,`refs/bisect/${o.termBad}`,a):await z(e,`refs/bisect/${o.termGood}-${a}`,a),await bt(e,`# ${r}: [${a}] ${c}`),await bt(e,`git bisect ${r} ${a}`),Gr(e,t,n)}function Ll(e,t){e.command("skip",{description:"Mark a commit as untestable",args:[B.string().name("revs").describe("Revisions to skip").optional().variadic()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return jr;let a=n.revs??[];if(a.length===0){let i=await zo(s);if(S(i))return i;a.push(i)}for(let i of a){let c;if(i.length===40&&/^[0-9a-f]+$/.test(i))c=i;else{let d=await It(s,i);if(S(d))return d;c=d}await z(s,`refs/bisect/skip-${c}`,c);let f=await D(s,c);await bt(s,`# skip: [${c}] ${se(f.message)}`),await bt(s,`git bisect skip ${c}`)}return Gr(s,r.env,t)}})}function Nl(e,t){e.command("reset",{description:"Finish bisecting and return to original branch",args:[B.string().name("commit").describe("Branch or commit to checkout").optional()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;return await wt(s)?_l(s,r.env,t,n.commit):{stdout:`We are not bisecting.
165
+ `,stderr:"",exitCode:0}}})}async function _l(e,t,n,r){let o=(await Ce(e,"BISECT_START"))?.trim()??"";if(await Os(e),r){let s=await It(e,r);return S(s)?s:Cn(e,s,t,n)}if(o){let s=`refs/heads/${o}`,a=await F(e,s);if(a)return ar(e,o,s,a,t,n);let i=await Fe(e,o);if(i)return Cn(e,i,t,n)}return{stdout:"",stderr:"",exitCode:0}}function Fl(e,t){e.command("log",{description:"Show the bisect log",handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;return await wt(s)?{stdout:await Ce(s,"BISECT_LOG")??"",stderr:"",exitCode:0}:{stdout:"",stderr:`error: We are not bisecting.
166
+ `,exitCode:1}}})}function Ul(e,t){e.command("replay",{description:"Replay a bisect log",args:[B.string().name("logfile").describe("Path to bisect log file")],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.logfile.startsWith("/")?n.logfile:H(r.cwd,n.logfile);if(!await r.fs.exists(a))return T(`cannot open '${n.logfile}': No such file or directory`);let i=await r.fs.readFile(a);return Bl(s,r.env,t,i)}})}async function Bl(e,t,n,r){await wt(e)&&await Os(e);let o={termBad:"bad",termGood:"good"},s="";for(let a of r.split(`
167
+ `)){let i=a.trim();if(!i||i.startsWith("#"))continue;let c=i.match(/^git[\s-]bisect\s+(\S+)(.*)$/);if(!c)continue;let f=c[1],d=c[2].trim(),u;if(f==="start"){let l=d?d.split(/\s+/).map(m=>m.replace(/^'|'$/g,"")):[];u=await Ja(e,t,n,l,"bad","good",!1,!1)}else if(f==="bad"||f==="new")u=await Mr(e,t,n,"bad",o,d||void 0);else if(f==="good"||f==="old")u=await Mr(e,t,n,"good",o,d||void 0);else if(f==="skip"){for(let l of d?d.split(/\s+/):[]){await z(e,`refs/bisect/skip-${l}`,l);let m=await D(e,l);await bt(e,`# skip: [${l}] ${se(m.message)}`),await bt(e,`git bisect skip ${l}`)}u=await Gr(e,t,n)}else continue;if(u.exitCode!==0)return u;s+=u.stdout}return{stdout:s,stderr:"",exitCode:0}}function Wl(e,t){e.command("run",{description:"Bisect by running a command",args:[B.string().name("cmd").describe("Command and arguments to run").variadic()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return jr;if(!r.exec)return T("bisect run requires shell execution support");let a=n.cmd.join(" ");return ql(s,r.env,t,a,r.exec,r.cwd)}})}async function ql(e,t,n,r,o,s){let a="";for(;;){a+=`running '${r}'
168
+ `;let c=(await o(r,{cwd:s})).exitCode;if(c===125){let l=await zo(e);if(S(l))return l;await z(e,`refs/bisect/skip-${l}`,l);let m=await D(e,l);await bt(e,`# skip: [${l}] ${se(m.message)}`),await bt(e,`git bisect skip ${l}`);let h=await Gr(e,t,n);if(a+=h.stdout,h.stdout.includes("is the first bad commit"))return a+=`bisect found first bad commit
169
+ `,{stdout:a,stderr:"",exitCode:0};if(h.exitCode!==0)return{stdout:a,stderr:h.stderr,exitCode:h.exitCode};continue}let f=await Is(e),d=c===0?f.termGood:f.termBad,u=await Mr(e,t,n,d,f,void 0);if(a+=u.stdout,u.stdout.includes("is the first bad commit"))return a+=`bisect found first bad commit
170
+ `,{stdout:a,stderr:"",exitCode:0};if(u.exitCode!==0)return{stdout:a,stderr:u.stderr,exitCode:u.exitCode}}}function Kl(e,t){e.command("terms",{description:"Show the terms used for old and new commits",options:{"term-good":A().describe("Show the term for the old state"),"term-bad":A().describe("Show the term for the new state")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!await wt(s))return{stdout:"",stderr:`error: no terms defined
171
+ `,exitCode:1};let{termBad:a,termGood:i}=await Dr(s);return n["term-good"]?{stdout:`${i}
172
+ `,stderr:"",exitCode:0}:n["term-bad"]?{stdout:`${a}
173
+ `,stderr:"",exitCode:0}:{stdout:`Your current terms are ${i} for the old state
174
+ and ${a} for the new state.
175
+ `,stderr:"",exitCode:0}}})}function zl(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 U(o.fs,o.cwd,t);if(S(s))return s;let a=s;if(!await wt(a))return jr;let i=await Is(a);if(!i.badHash||i.goodHashes.length===0)return{stdout:"",stderr:`error: need both bad and good commits to visualize
176
+ `,exitCode:1};let{walkCommits:c}=await Promise.resolve().then(()=>(rr(),Sa)),f="";for await(let d of c(a,i.badHash,{exclude:i.goodHashes}))f+=`${K(d.hash)} ${se(d.commit.message)}
177
+ `;return{stdout:f,stderr:"",exitCode:0}}})}async function Gr(e,t,n){let r=await Is(e);return!r.badHash||r.goodHashes.length===0?{stdout:ja(r),stderr:"",exitCode:0}:(await Pe(e,"BISECT_ANCESTORS_OK",""),Vl(e,t,n,r))}async function Vl(e,t,n,r){let o=await Ma(e,r.badHash,r.goodHashes,new Set(r.skipHashes),r.firstParent);if(!o)return{stdout:"",stderr:`error: no testable commits found
178
+ `,exitCode:1};if(o.found){let s=await La(e,o.hash);return await bt(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.
179
+ The first bad commit could be any of:
180
+ `;for(let a of r.skipHashes)s+=a+`
181
+ `;return r.badHash&&(s+=r.badHash+`
182
+ `),s+=`We cannot bisect more!
183
+ `,{stdout:s,stderr:"",exitCode:2}}if(r.noCheckout)await Pe(e,"BISECT_HEAD",o.hash);else{let s=await Cn(e,o.hash,t,n);if(s.exitCode!==0)return s}return await Pe(e,"BISECT_EXPECTED_REV",o.hash+`
184
+ `),{stdout:Ga(o),stderr:"",exitCode:0}}ee();re();function At(e){if(e.length===0)return[];let t=e.split(`
185
+ `);return t[t.length-1]===""&&t.pop(),t}function Rn(e){if(e.length===0)return[];let t=[],n=0;for(let r=0;r<e.length;r++)e[r]===`
186
+ `&&(t.push(e.slice(n,r+1)),n=r+1);return n<e.length&&t.push(e.slice(n)),t}var Yl=4,Qa=1024,js=100,Ns=0,Gs=1,cr=2;function Yo(e){let t=1;for(;t*t<e;)t++;return t}function Xl(e,t){let n=new Map,r=[],o=new Array(e.length),s=new Array(t.length);for(let a=0;a<e.length;a++){let i=e[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len1++,o[a]=c}for(let a=0;a<t.length;a++){let i=t[a],c=n.get(i);c===void 0&&(c=r.length,n.set(i,c),r.push({len1:0,len2:0})),r[c].len2++,s[a]=c}return{classes1:o,classes2:s,classInfo:r}}function Zl(e,t,n,r){let o=0,s=Math.min(t,r);for(;o<s&&e[o]===n[o];)o++;let a=o,i=0,c=s-a;for(;i<c&&e[t-1-i]===n[r-1-i];)i++;return{dstart:a,dend1:t-i-1,dend2:r-i-1}}function ec(e,t,n,r){t-n>js&&(n=t-js),r-t>js&&(r=t+js);let o=0,s=1;for(let c=1;t-c>=n;c++){let f=e[t-c];if(f===Ns)o++;else if(f===cr)s++;else break}if(o===0)return!1;let a=0,i=1;for(let c=1;t+c<=r;c++){let f=e[t+c];if(f===Ns)a++;else if(f===cr)i++;else break}return a===0?!1:(a+=o,i+=s,i*Yl<i+a)}function Jl(e,t,n,r,o,s,a,i,c,f){let d=new Uint8Array(t),u=new Uint8Array(r),l=Math.min(Yo(t),Qa);for(let g=s;g<=a;g++){let w=o[e[g]].len2;w===0?d[g]=Ns:w>=l?d[g]=cr:d[g]=Gs}let m=Math.min(Yo(r),Qa);for(let g=s;g<=i;g++){let w=o[n[g]].len1;w===0?u[g]=Ns:w>=m?u[g]=cr:u[g]=Gs}let h=[];for(let g=s;g<=a;g++)d[g]===Gs||d[g]===cr&&!ec(d,g,s,a)?h.push(g):c[g]=1;let p=[];for(let g=s;g<=i;g++)u[g]===Gs||u[g]===cr&&!ec(u,g,s,i)?p.push(g):f[g]=1;return{refIndex1:h,nreff1:h.length,refIndex2:p,nreff2:p.length}}var Pn=20,tc=4,Ql=256,eu=256,Ls=2147483647;function mt(e,t){return e[t]??0}function tu(e,t,n,r,o,s,a,i,c,f){let d=t-s,u=n-o,l=t-o,m=n-s,h=l-m&1,p=l,g=l,w=m,k=m;a[l]=t,i[m]=n;for(let b=1;;b++){let E=!1;p>d?a[--p-1]=-1:++p,g<u?a[++g+1]=-1:--g;for(let x=g;x>=p;x-=2){let P;mt(a,x-1)>=mt(a,x+1)?P=mt(a,x-1)+1:P=mt(a,x+1);let C=P,R=P-x;for(;P<n&&R<s&&e[P]===r[R];)P++,R++;if(P-C>Pn&&(E=!0),a[x]=P,h&&w<=x&&x<=k&&mt(i,x)<=P)return{i1:P,i2:R,minLo:!0,minHi:!0}}w>d?i[--w-1]=Ls:++w,k<u?i[++k+1]=Ls:--k;for(let x=k;x>=w;x-=2){let P;mt(i,x-1)<mt(i,x+1)?P=mt(i,x-1):P=mt(i,x+1)-1;let C=P,R=P-x;for(;P>t&&R>o&&e[P-1]===r[R-1];)P--,R--;if(C-P>Pn&&(E=!0),i[x]=P,!h&&p<=x&&x<=g&&P<=mt(a,x))return{i1:P,i2:R,minLo:!0,minHi:!0}}if(!c){if(E&&b>Ql){let x=0,P=null;for(let C=g;C>=p;C-=2){let R=C>l?C-l:l-C,y=mt(a,C),I=y-C,v=y-t+(I-o)-R;if(v>tc*b&&v>x&&t+Pn<=y&&y<n&&o+Pn<=I&&I<s){let G=!0;for(let M=1;M<=Pn;M++)if(e[y-M]!==r[I-M]){G=!1;break}G&&(x=v,P={i1:y,i2:I,minLo:!0,minHi:!1})}}if(P)return P;x=0,P=null;for(let C=k;C>=w;C-=2){let R=C>m?C-m:m-C,y=mt(i,C),I=y-C,v=n-y+(s-I)-R;if(v>tc*b&&v>x&&t<y&&y<=n-Pn&&o<I&&I<=s-Pn){let G=!0;for(let M=0;M<Pn;M++)if(e[y+M]!==r[I+M]){G=!1;break}G&&(x=v,P={i1:y,i2:I,minLo:!1,minHi:!0})}}if(P)return P}if(b>=f){let x=-1,P=-1;for(let y=g;y>=p;y-=2){let I=Math.min(mt(a,y),n),v=I-y;s<v&&(I=s+y,v=s),x<I+v&&(x=I+v,P=I)}let C=Ls,R=Ls;for(let y=k;y>=w;y-=2){let I=Math.max(t,mt(i,y)),v=I-y;v<o&&(I=o+y,v=o),I+v<C&&(C=I+v,R=I)}return n+s-C<x-(t+o)?{i1:P,i2:x-P,minLo:!0,minHi:!1}:{i1:R,i2:C-R,minLo:!1,minHi:!0}}}}}function Xo(e,t,n,r,o,s,a,i,c,f,d,u,l,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++)i[f[h]]=1;else if(o===s)for(let h=t;h<n;h++)a[c[h]]=1;else{let h=tu(e,t,n,r,o,s,d,u,l,m);Xo(e,t,h.i1,r,o,h.i2,a,i,c,f,d,u,h.minLo,m),Xo(e,h.i1,n,r,h.i2,s,a,i,c,f,d,u,h.minHi,m)}}function nu(e,t,n,r){let o=[],s=0,a=0,i=1,c=1;for(;s<e.length||a<t.length;){if(s<e.length&&a<t.length&&!n[s]&&!r[a]){o.push({type:"keep",line:e[s]??"",oldLineNo:i++,newLineNo:c++}),s++,a++;continue}for(;s<e.length&&n[s];)o.push({type:"delete",line:e[s]??"",oldLineNo:i++,newLineNo:0}),s++;for(;a<t.length&&r[a];)o.push({type:"insert",line:t[a]??"",oldLineNo:0,newLineNo:c++}),a++}return o}var nc=200,rc=20,sc=100,ru=1,su=21,ou=-30,iu=6,au=-4,cu=10,fu=24,du=17,lu=23,uu=17,mu=60;function Vo(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>=nc)return nc}return-1}function oc(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=Vo(e[n]));for(let o=n-1;o>=0&&(r.preIndent=Vo(e[o]),r.preIndent===-1);o--)if(r.preBlank+=1,r.preBlank===rc){r.preIndent=0;break}for(let o=n+1;o<t&&(r.postIndent=Vo(e[o]),r.postIndent===-1);o++)if(r.postBlank+=1,r.postBlank===rc){r.postIndent=0;break}return r}function ic(e,t){e.preIndent===-1&&e.preBlank===0&&(t.penalty+=ru),e.endOfFile&&(t.penalty+=su);let n=e.indent===-1?1+e.postBlank:0,r=e.preBlank+n;t.penalty+=ou*r,t.penalty+=iu*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?cu:au:o===e.preIndent||(e.postIndent!==-1&&e.postIndent>o?t.penalty+=s?du:fu:t.penalty+=s?uu:lu))}function hu(e,t){let n=(e.effectiveIndent>t.effectiveIndent?1:0)-(e.effectiveIndent<t.effectiveIndent?1:0);return mu*n+(e.penalty-t.penalty)}function ac(e,t,n,r,o,s){let a=0,i=0;for(;e[i];)i++;let c=0,f=0;for(;o[f];)f++;let d=(u,l)=>t[u]===t[l];for(;;){if(i!==a){let u,l,m;do{for(u=i-a,l=-1;a>0&&d(a-1,i-1);){for(e[--a]=1,e[--i]=0;e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;o[c-1];c--);}for(m=i,f>c&&(l=i);!(i>=r||!d(a,i));){for(e[a++]=0,e[i++]=1;e[i];)i++;if(f>=s)break;for(c=f+1,f=c;o[f];f++);f>c&&(l=i)}}while(u!==i-a);if(i!==m)if(l!==-1)for(;f===c;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}else{let h=-1,p={effectiveIndent:0,penalty:0},g=m;for(i-u-1>g&&(g=i-u-1),i-sc>g&&(g=i-sc);g<=i;g++){let w={effectiveIndent:0,penalty:0},k=oc(n,r,g);ic(k,w);let b=oc(n,r,g-u);ic(b,w),(h===-1||hu(w,p)<=0)&&(p={effectiveIndent:w.effectiveIndent,penalty:w.penalty},h=g)}for(;i>h;){for(e[--i]=0,e[--a]=1;e[a-1];)a--;for(f=c-1,c=f;o[c-1];c--);}}}if(i>=r)break;for(a=i+1,i=a;e[i];i++);if(f>=s)break;for(c=f+1,f=c;o[f];f++);}}function Zo(e,t){let n=e.length,r=t.length,o=new Uint8Array(n),s=new Uint8Array(r);if(n>0&&r>0){let{classes1:a,classes2:i,classInfo:c}=Xl(e,t),{dstart:f,dend1:d,dend2:u}=Zl(a,n,i,r);if(f>d)for(let l=f;l<r-(n-1-d);l++)s[l]=1;else if(f>u)for(let l=f;l<n-(r-1-u);l++)o[l]=1;else{let{refIndex1:l,nreff1:m,refIndex2:h,nreff2:p}=Jl(a,n,i,r,c,f,d,u,o,s);if(m>0&&p>0){let g=new Array(m);for(let P=0;P<m;P++)g[P]=a[l[P]];let w=new Array(p);for(let P=0;P<p;P++)w[P]=i[h[P]];let k={},b={},E=m+p+3,x=Math.max(eu,Yo(E));Xo(g,0,m,w,0,p,o,s,l,h,k,b,!1,x)}else if(m===0)for(let g=0;g<p;g++)s[h[g]]=1;else for(let g=0;g<m;g++)o[l[g]]=1;ac(o,a,e,n,s,r),ac(s,i,t,r,o,n)}}else n===0?s.fill(1):o.fill(1);return{changedOld:o,changedNew:s}}function yt(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return t.map((a,i)=>({type:"insert",line:a,oldLineNo:0,newLineNo:i+1}));if(r===0)return e.map((a,i)=>({type:"delete",line:a,oldLineNo:i+1,newLineNo:0}));let{changedOld:o,changedNew:s}=Zo(e,t);return nu(e,t,o,s)}var pu=3;function gu(e,t=pu){if(e.length===0)return[];let n=[];for(let i=0;i<e.length;i++){let c=e[i];c&&c.type!=="keep"&&n.push(i)}if(n.length===0)return[];let r=n[0]??0,o=[],s=Math.max(0,r-t),a=Math.min(e.length-1,r+t);for(let i=1;i<n.length;i++){let c=n[i]??0,f=Math.max(0,c-t),d=Math.min(e.length-1,c+t);f<=a+1||(o.push({start:s,end:a}),s=f),a=d}return o.push({start:s,end:a}),o.map(i=>wu(e,i.start,i.end))}function wu(e,t,n){let r=0,o=0,s=0,a=0,i=[],c=!1,f=!1;for(let d=t;d<=n;d++){let u=e[d];if(u)switch(u.type){case"keep":c||(r=u.oldLineNo,c=!0),f||(s=u.newLineNo,f=!0),o++,a++,i.push({type:"context",content:u.line});break;case"delete":c||(r=u.oldLineNo,c=!0),o++,i.push({type:"delete",content:u.line});break;case"insert":f||(s=u.newLineNo,f=!0),a++,i.push({type:"insert",content:u.line});break}}if(c||(r=s>0?s:1),f||(s=r>0?r:1),o===0)for(let d=t;d<=n;d++){let u=e[d];if(u&&u.type==="insert"){r=u.newLineNo>1?u.newLineNo-1:0;break}}if(a===0)for(let d=t;d<=n;d++){let u=e[d];if(u&&u.type==="delete"){s=u.oldLineNo>1?u.oldLineNo-1:0;break}}return{oldStart:r,oldCount:o,newStart:s,newCount:a,lines:i}}function _s(e){return e?e.length<40?e:K(e):"0000000"}function cc(e,t,n,r,o,s){let{path:a,oldMode:i,newMode:c}=t;e.push(`diff --git a/${a} b/${n}`),s?(e.push(`similarity index ${t.similarity??100}%`),e.push(`rename from ${a}`),e.push(`rename to ${n}`)):r?e.push(`new file mode ${c||"100644"}`):o?e.push(`deleted file mode ${i||"100644"}`):i&&c&&i!==c&&(e.push(`old mode ${i}`),e.push(`new mode ${c}`))}function bu(e,t,n){let{path:r,oldContent:o,newContent:s,oldMode:a,oldHash:i,newHash:c}=e,f=e.renameTo!==void 0,d=e.renameTo??r,u=e.isNew??o==="",l=e.isDeleted??s==="";if(o===s&&!f)return"";let m=[];if(cc(m,e,d,u,l,f),o!==s){if(i||c){let h=_s(i),p=_s(c);u||l||f?m.push(`index ${h}..${p}`):m.push(`index ${h}..${p} ${a||"100644"}`)}t&&n?m.push(`Binary files a/${r} and b/${d} differ`):u?m.push(`Binary files /dev/null and b/${d} differ`):l?m.push(`Binary files a/${r} and /dev/null differ`):m.push(`Binary files a/${r} and b/${d} differ`)}return`${m.join(`
187
+ `)}
188
+ `}function zt(e){let{path:t,oldContent:n,newContent:r,oldMode:o,newMode:s,oldHash:a,newHash:i}=e,c=e.renameTo!==void 0,f=e.renameTo??t,d=De(n),u=De(r);if(d||u)return bu(e,d,u);let l=At(n),m=At(r),h=n.length>0&&n.endsWith(`
189
+ `),p=r.length>0&&r.endsWith(`
190
+ `),g="\0NOEOL",w=l;!h&&l.length>0&&(w=l.slice(),w[w.length-1]+=g);let k=m;!p&&m.length>0&&(k=m.slice(),k[k.length-1]+=g);let b=yt(w,k);if(!h||!p)for(let v of b)v.line.includes(g)&&(v.line=v.line.replace(g,""));let E=gu(b);if(E.length===0&&!c)return"";let x=e.isNew??n==="",P=e.isDeleted??r==="",C=[];if(cc(C,e,f,x,P,c),E.length===0)return`${C.join(`
191
+ `)}
192
+ `;if(a||i){let v=_s(a),G=_s(i);x||P?C.push(`index ${v}..${G}`):c?C.push(`index ${v}..${G} ${o||"100644"}`):o&&s&&o!==s?C.push(`index ${v}..${G}`):C.push(`index ${v}..${G} ${o||"100644"}`)}let R=v=>v.includes(" ")?" ":"";x?(C.push("--- /dev/null"),C.push(`+++ b/${f}${R(f)}`)):P?(C.push(`--- a/${t}${R(t)}`),C.push("+++ /dev/null")):(C.push(`--- a/${t}${R(t)}`),C.push(`+++ b/${f}${R(f)}`));let y=l.length,I=m.length;for(let v of E){let G=v.oldCount===1?`${v.oldStart}`:`${v.oldStart},${v.oldCount}`,M=v.newCount===1?`${v.newStart}`:`${v.newStart},${v.newCount}`,V="";for(let O=v.oldStart-2;O>=0;O--){let _=l[O];if(_&&/^[a-zA-Z$_]/.test(_)){V=` ${_.trimEnd().slice(0,79)}`;break}}C.push(`@@ -${G} +${M} @@${V}`);let j=v.oldStart,$=v.newStart;for(let O of v.lines)switch(O.type){case"context":C.push(` ${O.content}`),(!h&&j===y||!p&&$===I)&&C.push("\"),j++,$++;break;case"delete":C.push(`-${O.content}`),!h&&j===y&&C.push("\"),j++;break;case"insert":C.push(`+${O.content}`),!p&&$===I&&C.push("\"),$++;break}}return`${C.join(`
193
+ `)}
194
+ `}re();Ie();async function In(e,t,n){return(await ae(e,t)).get(n)?.hash??null}async function fc(e,t,n,r){let o=await Be(e,t,n);if(!o.find(c=>c.status==="added"&&c.path===r))return null;let{renames:a}=await it(e,o);return a.find(c=>c.newPath===r)?.oldPath??null}async function yu(e,t,n,r,o,s){let a=await In(e,(await D(e,t)).tree,n);if(!a){let p=new Map,g=await D(e,t);for(let w of r)p.set(w.finalIdx,On(t,n,w.currentLine,s+w.finalIdx,o[w.finalIdx],g,!1,void 0));return p}let i=await le(e,a),c=At(i),f=new Array(o.length),d=[...r],u=t,l=n,m=c;for(;d.length>0;){let p=await D(e,u);if(p.parents.length===0){for(let y of d)f[y.finalIdx]=On(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!0,void 0);break}let g=await In(e,p.tree,l),w=null,k=[];for(let y of p.parents){let I=await D(e,y),v=l,G=await In(e,I.tree,v);if(!G){let M=await fc(e,I.tree,p.tree,l);M&&(v=M,G=await In(e,I.tree,v))}if(G&&(k.push({hash:y,path:v,blobHash:G}),G===g)){w={hash:y,path:v};break}}if(w){u=w.hash,l=w.path;continue}if(k.length===0){for(let y of d)f[y.finalIdx]=On(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,void 0);break}let b=k[0],E=await le(e,b.blobHash),x=At(E),P=yt(x,m),C=new Map;for(let y of P)y.type==="keep"&&C.set(y.newLineNo,y.oldLineNo);let R=[];for(let y of d){let I=C.get(y.currentLine);I!==void 0?R.push({finalIdx:y.finalIdx,currentLine:I}):f[y.finalIdx]=On(u,l,y.currentLine,s+y.finalIdx,o[y.finalIdx],p,!1,{hash:b.hash,path:b.path})}d=R,u=b.hash,l=b.path,m=x}let h=new Map;for(let p of r)f[p.finalIdx]&&h.set(p.finalIdx,f[p.finalIdx]);return h}async function dc(e,t,n,r){let o=await D(e,t),s=await In(e,o.tree,n);if(!s)throw new Error(`no such path '${n}' in ${t.slice(0,7)}`);let a=await le(e,s),i=At(a),c=r?.startLine??1,f=r?.endLine??i.length,d=i.slice(c-1,f),u=new Array(d.length),l=d.map((g,w)=>({finalIdx:w,currentLine:c+w})),m=t,h=n,p=i;for(;l.length>0;){let g=await D(e,m);if(g.parents.length===0){for(let C of l)u[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!0,void 0);break}let w=await In(e,g.tree,h),k=[],b=null;for(let C of g.parents){let R=await D(e,C),y=h,I=await In(e,R.tree,y);if(!I){let v=await fc(e,R.tree,g.tree,h);v&&(y=v,I=await In(e,R.tree,y))}if(I){let v={hash:C,path:y,blobHash:I};if(k.push(v),I===w){b=v;break}}}if(b){m=b.hash,h=b.path;continue}if(k.length===0){for(let C of l)u[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,void 0);break}if(k.length===1){let C=k[0],R=await le(e,C.blobHash),y=At(R),I=yt(y,p),v=new Map;for(let M of I)M.type==="keep"&&v.set(M.newLineNo,M.oldLineNo);let G=[];for(let M of l){let V=v.get(M.currentLine);V!==void 0?G.push({finalIdx:M.finalIdx,currentLine:V}):u[M.finalIdx]=On(m,h,M.currentLine,c+M.finalIdx,d[M.finalIdx],g,!1,{hash:C.hash,path:C.path})}l=G,m=C.hash,h=C.path,p=y;continue}let E=[];for(let C of k){let R=await le(e,C.blobHash),y=At(R),I=yt(y,p),v=new Map;for(let G of I)G.type==="keep"&&v.set(G.newLineNo,G.oldLineNo);E.push({info:C,newToOld:v})}let x=new Map;for(let C of l){let R=!1;for(let y=0;y<E.length;y++){let I=E[y],v=I.newToOld.get(C.currentLine);if(v!==void 0){let G=x.get(y);G||(G={info:I.info,lines:[]},x.set(y,G)),G.lines.push({finalIdx:C.finalIdx,currentLine:v}),R=!0;break}}R||(u[C.finalIdx]=On(m,h,C.currentLine,c+C.finalIdx,d[C.finalIdx],g,!1,{hash:k[0].hash,path:k[0].path}))}let P=x.get(0);for(let[C,R]of x){if(C===0)continue;let y=await yu(e,R.info.hash,R.info.path,R.lines,d,c);for(let[I,v]of y)u[I]=v}if(P&&P.lines.length>0){l=P.lines,m=P.info.hash,h=P.info.path;let C=await le(e,P.info.blobHash);p=At(C)}else break}return u}function On(e,t,n,r,o,s,a,i){return{hash:e,origPath:t,origLine:n,finalLine:r,content:o,author:s.author,committer:s.committer,summary:s.message.split(`
195
+ `)[0],boundary:a,previous:i}}ee();re();Ie();re();fe();function Eu(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 ku(e,t){let n=Eu(t),r=new Date((e+n*60)*1e3),o=r.getUTCFullYear(),s=(r.getUTCMonth()+1).toString().padStart(2,"0"),a=r.getUTCDate().toString().padStart(2,"0"),i=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0");return`${o}-${s}-${a} ${i}:${c}:${f} ${t}`}function xu(e,t,n,r,o){if(e.length===0)return"";let s=Math.max(...e.map(d=>d.finalLine)),a=String(s).length,i=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=[];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 l=i&&d.origPath!==t?` ${d.origPath}`:"";if(o)f.push(`${u}${l} ${String(d.finalLine).padStart(a)}) ${d.content}`);else{let m=r?`<${d.author.email}>`:d.author.name,h=ku(d.author.timestamp,d.author.timezone);f.push(`${u}${l} (${m.padEnd(c)} ${h} ${String(d.finalLine).padStart(a)}) ${d.content}`)}}return`${f.join(`
196
+ `)}
197
+ `}function Cu(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(`
198
+ `)}
199
+ `}function Pu(e,t,n){if(e.startsWith("/"))return rt(n,e);let r=rt(n,t);return r===""||r==="."?e:`${r}/${e}`}function lc(e,t){e.command("blame",{description:"Show what revision and author last modified each line of a file",args:[B.string().name("args").variadic().optional()],options:{lineRange:Q.string().alias("L").describe("Annotate only the given line range (<start>,<end>)"),long:A().alias("l").describe("Show long revision"),showEmail:A().alias("e").describe("Show author email instead of name"),suppress:A().alias("s").describe("Suppress author name and date"),porcelain:A().alias("p").describe("Show in machine-readable format"),linePorcelain:A().describe("Show porcelain format with full headers for each line")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s;if(!a.workTree)return T("this operation must be run in a work tree");let i=await Ke(a);if(S(i))return i;let c=n.args??[],f=o.passthrough??[],d=null,u=null;if(f.length>0?(u=f[f.length-1],c.length>0&&(d=c[0])):c.length===2?(d=c[0],u=c[1]):c.length===1&&(u=c[0]),!u)return T("no file specified");let l=Pu(u,r.cwd,a.workTree),m;if(d){let P=await It(a,d);if(S(P))return P;m=await Ge(a,P)}else m=i;let h=await D(a,m),p=await ae(a,h.tree);if(!p.has(l))return T(`no such path ${l} in ${d??"HEAD"}`);let g=p.get(l).hash,w=await le(a,g);if(De(w))return T(`cannot blame binary file '${l}'`);let k,b;if(n.lineRange){let P=n.lineRange,C=P.match(/^(\d+),(\d+)$/);if(C)k=parseInt(C[1],10),b=parseInt(C[2],10);else return T(`invalid -L range: '${P}'`)}let E;try{E=await dc(a,m,l,{startLine:k,endLine:b})}catch(P){let C=P instanceof Error?P.message:String(P);return T(C)}let x;return n.porcelain||n.linePorcelain?x=Cu(E,!!n.linePorcelain):x=xu(E,l,!!n.long,!!n.showEmail,!!n.suppress),{stdout:x,stderr:"",exitCode:0}}})}ee();Ze();ln();ee();var Ru=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Iu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Vt(e,t){let n=Ou(t),r=new Date((e+n*60)*1e3),o=Ru[r.getUTCDay()],s=Iu[r.getUTCMonth()],a=r.getUTCDate(),i=r.getUTCHours().toString().padStart(2,"0"),c=r.getUTCMinutes().toString().padStart(2,"0"),f=r.getUTCSeconds().toString().padStart(2,"0"),d=r.getUTCFullYear();return`${o} ${s} ${a} ${i}:${c}:${f} ${d} ${t}`}function Jo(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 Ou(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)}re();Ie();var Fs=new TextDecoder;function uc(e){if(e.length===0)return 0;let t=0;for(let n=0;n<e.length;n++)e[n]===`
200
+ `&&t++;return e[e.length-1]!==`
201
+ `&&t++,t}function Bs(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 mc(e,t,n){let r=[],o=[],s=[];for(let i of t)if(i.status==="added"&&i.newHash&&i.newMode){let c=await gt(e,i.newHash);pn(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:0,newSize:c.byteLength}):r.push({path:i.path,sortKey:i.path,insertions:uc(Fs.decode(c)),deletions:0}),o.push({path:i.path,mode:i.newMode})}else if(i.status==="deleted"&&i.oldHash&&i.oldMode){let c=await gt(e,i.oldHash);pn(c)?r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:0}):r.push({path:i.path,sortKey:i.path,insertions:0,deletions:uc(Fs.decode(c))}),s.push({path:i.path,mode:i.oldMode})}else if(i.status==="modified"&&i.oldHash&&i.newHash){let c=await gt(e,i.oldHash),f=await gt(e,i.newHash);if(pn(c)||pn(f))r.push({path:i.path,sortKey:i.path,insertions:0,deletions:0,isBinary:!0,oldSize:c.byteLength,newSize:f.byteLength});else{let d=Rn(Fs.decode(c)),u=Rn(Fs.decode(f)),l=yt(d,u),m=0,h=0;for(let p of l)p.type==="insert"?m++:p.type==="delete"&&h++;r.push({path:i.path,sortKey:i.path,insertions:m,deletions:h})}i.oldMode&&i.newMode&&i.oldMode!==i.newMode&&(s.push({path:i.path,mode:i.oldMode}),o.push({path:i.path,mode:i.newMode}))}for(let i of n){let c=ir(i.oldPath,i.newPath),f=0,d=0;if(i.similarity<100&&i.oldHash&&i.newHash){let u=await le(e,i.oldHash),l=await le(e,i.newHash);if(!De(u)&&!De(l)){let m=Rn(u),h=Rn(l),p=yt(m,h);for(let g of p)g.type==="insert"?f++:g.type==="delete"&&d++}}r.push({path:c,sortKey:i.newPath,insertions:f,deletions:d})}let a=[];for(let{path:i,mode:c}of o)a.push({sortKey:i,text:` create mode ${c} ${i}`});for(let{path:i,mode:c}of s)a.push({sortKey:i,text:` delete mode ${c} ${i}`});for(let i of n){let c=ir(i.oldPath,i.newPath);a.push({sortKey:i.newPath,text:` rename ${c} (${i.similarity}%)`})}return a.sort((i,c)=>i.sortKey<c.sortKey?-1:i.sortKey>c.sortKey?1:0),{fileStats:r,modeLines:a.map(i=>i.text)}}async function Yt(e,t,n,r,o,s=!1,a=!1){let i=[];if((r.name!==o.name||r.email!==o.email)&&i.push(` Author: ${r.name} <${r.email}>`),s&&i.push(` Date: ${Vt(r.timestamp,r.timezone)}`),a)return i.join(`
202
+ `)+(i.length>0?`
203
+ `:"");let c=await Be(e,t,n),{remaining:f,renames:d}=await it(e,c),{fileStats:u,modeLines:l}=await mc(e,f,d),m=0,h=0;for(let g of u)m+=g.insertions,h+=g.deletions;let p=Bs(u.length,m,h);p&&i.push(p);for(let g of l)i.push(g);return i.join(`
204
+ `)+(i.length>0?`
205
+ `:"")}var Us=80;function $u(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 Qo(e){if(e.length===0)return"";let t=e.filter(h=>!h.isUnmerged),n=t.length>0?Math.max(...t.map(h=>h.insertions+h.deletions)):0,r=e.some(h=>h.isBinary),o=n>0?String(n).length:1;r&&o<3&&(o=3);let s=Math.max(...e.map(h=>h.path.length)),a=n,i=s;if(i+o+6+a>Us){let h=Math.floor(Us*3/8)-o-6;a>h&&(a=Math.max(h,6));let p=Us-o-6-a;i>p?i=p:a=Us-o-6-i}for(let h of e)h.path=$u(h.path,i);let c=i,f=[],d=0,u=0,l=0;for(let h of e){let p=h.path.padEnd(c);if(h.isUnmerged){f.push(` ${p} | Unmerged`);continue}if(l++,d+=h.insertions,u+=h.deletions,h.isBinary){let C=`${"Bin".padStart(o)} ${h.oldSize??0} -> ${h.newSize??0} bytes`;f.push(` ${p} | ${C}`);continue}let g=h.insertions+h.deletions,w=String(g).padStart(o),k,b;if(n<=a)k=h.insertions,b=h.deletions;else{let P=y=>y===0?0:1+Math.floor(y*(a-1)/n),C=P(g),R=C<2&&h.insertions>0&&h.deletions>0?2:C;h.insertions<h.deletions?(k=P(h.insertions),b=R-k):(b=P(h.deletions),k=R-b)}let E="+".repeat(k)+"-".repeat(b),x=E?` ${E}`:"";f.push(` ${p} | ${w}${x}`)}let m=Bs(l,d,u);return m?f.push(m):e.some(h=>h.isUnmerged)&&f.push(" 0 files changed"),`${f.join(`
206
+ `)}
207
+ `}async function $n(e,t,n){let r=await Be(e,t,n),{remaining:o,renames:s}=await it(e,r);if(o.length===0&&s.length===0)return"";let{fileStats:a,modeLines:i}=await mc(e,o,s);a.sort((f,d)=>f.sortKey<d.sortKey?-1:f.sortKey>d.sortKey?1:0);let c=Qo(a);for(let f of i)c+=`${f}
208
+ `;return c}Ze();ye();re();ue();Wt();async function Tu(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 a=await D(e,s);for(let i of a.parents)n.has(i)||r.push(i)}return n}async function cn(e,t,n){if(t===n)return!0;let r=new Set,o=[n],s=0;for(;s<o.length;){let a=o[s++];if(a===t)return!0;if(r.has(a))continue;r.add(a);let i=await D(e,a);for(let c of i.parents)r.has(c)||o.push(c)}return!1}async function vt(e,t,n){if(t===n)return[t];let r=await Tu(e,t),o=[],s=new Set,a=[n],i=0;for(;i<a.length;){let f=a[i++];if(s.has(f))continue;if(s.add(f),r.has(f)){o.push(f);continue}let d=await D(e,f);for(let u of d.parents)s.has(u)||a.push(u)}if(o.length<=1)return o;let c=[];for(let f of o){let d=!1;for(let u of o)if(u!==f&&await cn(e,f,u)){d=!0;break}d||c.push(f)}return c.length<=1?c:Hu(e,t,n,c)}async function Hu(e,t,n,r){let o=new Set(r),s=new Set,a=[],i=new Map,c=new Map,f=0,d=[{hash:t,mask:1,seq:f++},{hash:n,mask:2,seq:f++}];async function u(l){let m=c.get(l);if(m!==void 0)return m;let h=(await D(e,l)).committer.timestamp;return c.set(l,h),h}for(;d.length>0;){let l=0,m=await u(d[0].hash);for(let k=1;k<d.length;k++){let b=d[k],E=await u(b.hash),x=d[l];(E>m||E===m&&b.seq<x.seq)&&(l=k,m=E)}let h=d.splice(l,1)[0],p=i.get(h.hash)??0,g=p|h.mask;if(g===p)continue;if(i.set(h.hash,g),g===3&&o.has(h.hash)&&!s.has(h.hash)&&(a.push(h.hash),s.add(h.hash),s.size===o.size))break;let w=await D(e,h.hash);for(let k of w.parents)d.push({hash:k,mask:g,seq:f++})}for(let l of r)s.has(l)||a.push(l);return a}async function fn(e,t,n){let r=await Dt(e,"init.defaultBranch")??"main";return n===r?`Merge branch '${t}'
209
+ `:`Merge branch '${t}' into ${n}
210
+ `}async function Ws(e,t,n){let r=await D(e,t),o=await D(e,n),s=K(t),a=K(n),i=`Updating ${s}..${a}
211
+ `;if(e.workTree){let f=await W(e),d=await Ta(e,r.tree,o.tree,f);if(!d.success){let u=d.errorOutput;return{stdout:i+u.stdout,stderr:u.stderr,exitCode:u.exitCode}}await ie(e,{version:2,entries:d.newEntries}),await Oe(e,d.worktreeOps)}await gn(e,n);let c=await $n(e,r.tree,o.tree);return{stdout:`${i}Fast-forward
212
+ ${c}`,stderr:"",exitCode:0}}re();Me();ue();function hc(e,t){e.command("branch",{description:"List, create, or delete branches",args:[B.string().name("name").describe("Branch name").optional(),B.string().name("newName").describe("New branch name (for -m) or start-point (for create)").optional()],options:{delete:A().alias("d").describe("Delete a branch"),forceDelete:A().alias("D").describe("Force delete a branch"),move:A().alias("m").describe("Rename a branch"),forceMove:A().alias("M").describe("Force rename a branch"),remotes:A().alias("r").describe("List remote-tracking branches"),all:A().alias("a").describe("List all branches"),setUpstreamTo:Q.string().alias("u").describe("Set upstream tracking branch"),verbose:A().alias("v").count().describe("Show hash and subject")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await Z(s),i=a?.type==="symbolic"?ge(a.target):null,c=!!n.forceMove;if(n.move||c){let w,k;if(n.newName)w=n.name,k=n.newName;else if(n.name){if(!i)return T("not on any branch");w=i,k=n.name}else return T("branch name required");let b=`refs/heads/${w}`,E=`refs/heads/${k}`,x=await F(s,b);if(!x)return T(`no branch named '${w}'`);if(await Ht(s)&&(await ut(s))?.headName===b)return T(`branch ${b} is being rebased at ${s.workTree}`);let P=await F(s,E);if(P&&!c)return T(`a branch named '${k}' already exists`);P&&await de(s,E);let C=await Ve(s,b);await z(s,E,x),await de(s,b),w===i&&await Ne(s,"HEAD",E),C.length>0&&await wn(s,E,C);let R=`Branch: renamed ${b} to ${E}`;if(await ne(s,r.env,E,x,x,R),w===i){let v=await Nt(s,r.env);await _e(s,"HEAD",{oldHash:x,newHash:J,...v,message:R}),await _e(s,"HEAD",{oldHash:J,newHash:x,...v,message:R})}let y=await me(s),I=`branch "${w}"`;return y[I]&&(y[`branch "${k}"`]=y[I],delete y[I],await Xe(s,y)),{stdout:"",stderr:"",exitCode:0}}let f=n.forceDelete;if(n.delete||f){if(!n.name)return T("branch name required");let w=n.name===i;if(!w&&!i&&await Ht(s)&&(await ut(s))?.headName===`refs/heads/${n.name}`&&(w=!0),w)return L(`error: cannot delete branch '${n.name}' used by worktree at '${s.workTree}'
213
+ `);let k=`refs/heads/${n.name}`,b=await F(s,k);if(!b)return L(`error: branch '${n.name}' not found
214
+ `);let E="";if(!f){let x=await Y(s),C=(await me(s))[`branch "${n.name}"`],R=C?.remote,y=C?.merge,I=null,v=null;if(R&&y&&(I=y.replace(/^refs\/heads\//,`refs/remotes/${R}/`),v=await F(s,I)),v&&I){if(!(b===v||await cn(s,b,v))){let j=x!=null&&(b===x||await cn(s,b,x))?`warning: not deleting branch '${n.name}' that is not yet merged to
215
+ '${I}', even though it is merged to HEAD
216
+ `:"";return L(`${j}error: the branch '${n.name}' is not fully merged
217
+ hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
218
+ hint: Disable this message with "git config set advice.forceDeleteBranch false"
219
+ `)}x!=null&&(b===x||await cn(s,b,x))||(E=`warning: deleting branch '${n.name}' that has been merged to
220
+ '${I}', but not yet merged to HEAD
221
+ `)}else if(x&&b!==x&&!await cn(s,b,x))return L(`error: the branch '${n.name}' is not fully merged
222
+ hint: If you are sure you want to delete it, run 'git branch -D ${n.name}'
223
+ hint: Disable this message with "git config set advice.forceDeleteBranch false"
224
+ `)}return await de(s,k),{stdout:`Deleted branch ${n.name} (was ${K(b)}).
225
+ `,stderr:E,exitCode:0}}if(n.setUpstreamTo){let w=n.setUpstreamTo,k=n.name||i;if(!k)return T("could not set upstream of HEAD when it does not point to any branch.");if(!await F(s,`refs/heads/${k}`))return T(`branch '${k}' does not exist`);let E=w.indexOf("/");if(E<0)return T(`the requested upstream branch '${w}' does not exist`);let x=w.slice(0,E),P=w.slice(E+1);if(!await F(s,`refs/remotes/${w}`))return T(`the requested upstream branch '${w}' does not exist`);let R=await me(s),y=`branch "${k}"`;return R[y]||(R[y]={}),R[y].remote=x,R[y].merge=`refs/heads/${P}`,await Xe(s,R),{stdout:"",stderr:`branch '${k}' set up to track '${w}'.
226
+ `,exitCode:0}}if(n.name&&!n.remotes&&!n.all){let w=n.newName,k;if(w){let P=await $e(s,w,`not a valid object name: '${w}'`);if(S(P))return P;k=P.hash}else if(k=await Y(s),!k)return T("Not a valid object name: 'HEAD'.");let b=`refs/heads/${n.name}`;if(await F(s,b))return T(`a branch named '${n.name}' already exists`);await z(s,b,k);let x=w??"HEAD";return await ne(s,r.env,b,null,k,`branch: Created from ${x}`),{stdout:"",stderr:"",exitCode:0}}let d=n.verbose||0,u=!n.remotes||n.all,l=n.remotes||n.all,m=[];if(u&&!i){let w=await Y(s);if(w){let k=await Ht(s),b;if(k){let E=await ut(s);if(E?.headName){let x=ge(E.headName);if(x==="detached HEAD"){let P=await Sr(s);b=`(no branch, rebasing detached HEAD ${P?K(P):"(null)"})`}else b=`(no branch, rebasing ${x})`}else b="(no branch)"}else{let E=await Sr(s);E?b=`(HEAD detached ${w===E?"at":"from"} ${K(E)})`:b="(no branch)"}m.push({displayName:b,hash:w,isCurrent:!0,branchName:null})}}if(u){let w=await pe(s,"refs/heads");for(let k of w){let b=ge(k.name);m.push({displayName:b,hash:k.hash,isCurrent:b===i,branchName:b})}}if(l){let w=await pe(s,"refs/remotes");for(let k of w){let b=k.name.replace("refs/remotes/","");m.push({displayName:n.all?`remotes/${b}`:b,hash:k.hash,isCurrent:!1,branchName:null})}}if(m.length===0)return{stdout:"",stderr:"",exitCode:0};if(d===0)return{stdout:`${m.map(k=>k.isCurrent?`* ${k.displayName}`:` ${k.displayName}`).join(`
227
+ `)}
228
+ `,stderr:"",exitCode:0};let h=d>=1?await me(s):null,p=Math.max(...m.map(w=>w.displayName.length)),g=[];for(let w of m){let k=w.isCurrent?"* ":" ",b=w.displayName.padEnd(p),E=K(w.hash),x="";try{let C=await D(s,w.hash);x=se(C.message)}catch{}let P="";if(h&&w.branchName){let C=await on(s,h,w.branchName);if(C){let R=Va(C,d>=2);R&&(P=` ${R}`)}}g.push(`${k}${b} ${E}${P} ${x}`)}return{stdout:`${g.join(`
229
+ `)}
230
+ `,stderr:"",exitCode:0}}})}ee();Ze();ye();re();Me();ue();en();et();function pc(e,t){e.command("checkout",{description:"Switch branches or restore working tree files",args:[B.string().name("target").describe("Branch name or path to checkout").optional()],options:{branch:A().alias("b").describe("Create and switch to a new branch"),forceBranch:A().alias("B").describe("Create/reset and switch to a new branch"),orphan:A().describe("Create a new orphan branch"),ours:A().describe("Checkout our version for unmerged files"),theirs:A().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.target;if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");if(o.passthrough.length>0){let u=ft(a,r.cwd),l=o.passthrough,m=null;if(i){if(n.ours||n.theirs)return T("cannot specify both a revision and --ours/--theirs");let h=await $e(a,i,`invalid reference: ${i}`);if(S(h))return h;m=h.commit.tree}return n.ours||n.theirs?Ds(a,l,u,n.theirs?3:2):Ss(a,l,u,m)}if(n.orphan)return n.branch?T("--orphan and -b are incompatible"):n.ours||n.theirs?T("--orphan and --ours/--theirs are incompatible"):i?vu(a,i,r.env,t):T("you must specify a branch to checkout");if(!i)return T("you must specify a branch to checkout");if(n.branch||n.forceBranch)return Su(a,i,r.env,t,!!n.forceBranch);if(i==="-")return Au(a,r.env,t);let c=`refs/heads/${i}`,f=await F(a,c);if(f)return gc(a,i,c,f,r.env,t);let d=await Fe(a,i);if(d){let u=await Ge(a,d);return Du(a,i,u,r.env,t)}if(a.workTree){let u=await W(a),l=Xt(u,i);if(l)return await We(a,{path:l.path,hash:l.hash,mode:l.mode}),{stdout:"",stderr:"",exitCode:0}}return L(`error: pathspec '${i}' did not match any file(s) known to git
231
+ `)}})}async function Au(e,t,n){let r=await vs(e);return r?gc(e,r.name,r.refName,r.hash,t,n):T("no previous branch")}async function vu(e,t,n,r){let o=`refs/heads/${t}`;if(await F(e,o))return T(`a branch named '${t}' already exists`);let a=await W(e),i=xn(a);if(i)return i;let c=await Y(e),f=null;c&&(f=(await D(e,c)).tree),await Ne(e,"HEAD",o),await lt(e);let d=await an(e);await r?.hooks?.emitPost("post-checkout",{prevHead:c,newHead:J,isBranchCheckout:!0});let u="";return f&&(u=await qn(e,f,a)),{stdout:u,stderr:`Switched to a new branch '${t}'
232
+ ${d}`,exitCode:0}}async function Su(e,t,n,r,o=!1){if(r?.hooks){let p=await r.hooks.emitPre("pre-checkout",{target:t,mode:"create-branch"});if(p)return{stdout:"",stderr:p.message??"",exitCode:1}}let s=await Z(e),a=await Y(e),i=`refs/heads/${t}`,c=await F(e,i);if(c&&!o)return T(`a branch named '${t}' already exists`);if(o){let p=await W(e),g=xn(p);if(g)return g}a&&await z(e,i,a),await Ne(e,"HEAD",i),await lt(e);let f=await an(e),d=s?.type==="symbolic"?s.target.replace(/^refs\/heads\//,""):a??J;a&&await ne(e,n,i,c,a,c?"branch: Reset to HEAD":"branch: Created from HEAD"),await ne(e,n,"HEAD",a,a??J,`checkout: moving from ${d} to ${t}`),await r?.hooks?.emitPost("post-checkout",{prevHead:a,newHead:a??J,isBranchCheckout:!0});let u="";if(o&&a){let p=await W(e),g=await D(e,a);u=await qn(e,g.tree,p)}let l=await me(e),m=await on(e,l,t);m&&(u+=Wn(m));let h=c?`Switched to and reset branch '${t}'
192
233
  `:`Switched to a new branch '${t}'
193
- `;return{stdout:u,stderr:`${h}${f}`,exitCode:0}}async function ka(e,t,n,r,o,s){if(s?.hooks){let a=await s.hooks.emitPre("pre-checkout",{target:t,mode:"switch"});if(a)return{stdout:"",stderr:a.message??"",exitCode:1}}return fs(e,t,n,r,o,s)}async function xl(e,t,n,r,o){if(o?.hooks){let s=await o.hooks.emitPre("pre-checkout",{target:t,mode:"detach"});if(s)return{stdout:"",stderr:s.message??"",exitCode:1}}return ds(e,n,r,o,{detachAdviceTarget:t})}function go(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}=oo(e,t);return Ca(o,e,s,t),Ca(s,t,o,e),kl(o,n,s,r)}function kl(e,t,n,r){let o=[],s=0,a=0;for(;s<t||a<r;){for(;s<t&&a<r&&!e[s]&&!n[a];)s++,a++;if(s>=t&&a>=r)break;let i=s,c=a;for(;s<t&&e[s];)s++;for(;a<r&&n[a];)a++;(s>i||a>c)&&o.push({buffer1:[i,s-i],buffer2:[c,a-c]})}return o}function Ca(e,t,n,r){let o=t.length,s=r.length,a=0,i=0;for(;i<o&&e[i];)i++;let c=0,f=0;for(;f<s&&n[f];)f++;for(;;){if(i===a){if(i>=o)break;for(a=i+1,i=a;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++;continue}let d,u,l;do{for(d=i-a,l=-1;a>0&&i>0&&t[a-1]===t[i-1];){for(e[--a]=1,e[--i]=0;a>0&&e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;c>0&&n[c-1];)c--}for(u=i,f>c&&(l=i);i<o&&t[a]===t[i];){for(e[a++]=0,e[i++]=1;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++;f>c&&(l=i)}}while(d!==i-a);if(i!==u&&l!==-1)for(;f===c&&!(a<=0||t[a-1]!==t[i-1]);){for(e[--a]=1,e[--i]=0;a>0&&e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;c>0&&n[c-1];)c--}if(i>=o)break;for(a=i+1,i=a;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++}}function Cl(e,t,n){let r=[];for(let c of go(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 go(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 a(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let i=0;for(;i<r.length;){let c=r[i++],f=c.oStart,d=c.oStart+c.oLength,u=[c];for(a(f);i<r.length;){let l=r[i];if(l.oStart>d)break;d=Math.max(d,l.oStart+l.oLength),u.push(l),i++}if(u.length===1){if(c.abLength>0){let l=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:l.slice(c.abStart,c.abStart+c.abLength)})}}else{let l={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 u){let x=w.oStart,b=x+w.oLength,E=w.abStart,k=E+w.abLength,P=l[w.ab];P.abMin=Math.min(E,P.abMin),P.abMax=Math.max(k,P.abMax),P.oMin=Math.min(x,P.oMin),P.oMax=Math.max(b,P.oMax)}let m=l.a.abMin+(f-l.a.oMin),h=l.a.abMax+(d-l.a.oMax),p=l.b.abMin+(f-l.b.oMin),g=l.b.abMax+(d-l.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,d),b:n.slice(p,g)})}s=d}return a(t.length),o}function Pl(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=Cl(e,t,n),a=[],i=[];function c(){i.length&&(a.push({type:"ok",lines:i}),i=[])}for(let f of s)f.stable?i.push(...f.content):o&&Pa(f.a,f.b)?i.push(...f.a):(c(),a.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),Rl(Ol(a))}function fr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a="=".repeat(o),i=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,c=Pl(e,t,n),f=!1,d=[];for(let u of c)u.type==="ok"?d.push(...u.lines):(f=!0,d.push(s,...u.a,a,...u.b,i));return{conflict:f,result:d}}function Ol(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Il(n));return t}function Il(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(Pa(t,n))return[e];let r=go(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let i of r){let c=i.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+i.buffer1[1],u=i.buffer2[0]+i.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(i.buffer2[0],u)}),s=d}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function Rl(e){if(e.length<3)return e;let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],o=e[n];if(r.type==="conflict"&&o.type==="ok"&&o.lines.length<=3&&n+1<e.length&&e[n+1].type==="conflict"){let s=e[n+1],a=r;a.a=[...r.a,...o.lines,...s.a],a.b=[...r.b,...o.lines,...s.b],a.o=[...r.o,...o.lines,...s.o],n++}else t.push(o)}return t}function Cn(e,t,n,r){let o=fr(at(e),at(t),at(n),{a:r.a,b:r.b,markerSize:r.markerSize}),a=(o.result[o.result.length-1]??"").endsWith("\0"),i=o.result.map(wo);return(i[i.length-1]??"").startsWith(">>>>>>>")||!a?`${i.join(`
234
+ `;return{stdout:u,stderr:`${h}${f}`,exitCode:0}}async function gc(e,t,n,r,o,s){if(s?.hooks){let a=await s.hooks.emitPre("pre-checkout",{target:t,mode:"switch"});if(a)return{stdout:"",stderr:a.message??"",exitCode:1}}return ar(e,t,n,r,o,s)}async function Du(e,t,n,r,o){if(o?.hooks){let s=await o.hooks.emitPre("pre-checkout",{target:t,mode:"detach"});if(s)return{stdout:"",stderr:s.message??"",exitCode:1}}return Cn(e,n,r,o,{detachAdviceTarget:t})}ee();ye();ee();function ei(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}=Zo(e,t);return wc(o,e,s,t),wc(s,t,o,e),Mu(o,n,s,r)}function Mu(e,t,n,r){let o=[],s=0,a=0;for(;s<t||a<r;){for(;s<t&&a<r&&!e[s]&&!n[a];)s++,a++;if(s>=t&&a>=r)break;let i=s,c=a;for(;s<t&&e[s];)s++;for(;a<r&&n[a];)a++;(s>i||a>c)&&o.push({buffer1:[i,s-i],buffer2:[c,a-c]})}return o}function wc(e,t,n,r){let o=t.length,s=r.length,a=0,i=0;for(;i<o&&e[i];)i++;let c=0,f=0;for(;f<s&&n[f];)f++;for(;;){if(i===a){if(i>=o)break;for(a=i+1,i=a;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++;continue}let d,u,l;do{for(d=i-a,l=-1;a>0&&i>0&&t[a-1]===t[i-1];){for(e[--a]=1,e[--i]=0;a>0&&e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;c>0&&n[c-1];)c--}for(u=i,f>c&&(l=i);i<o&&t[a]===t[i];){for(e[a++]=0,e[i++]=1;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++;f>c&&(l=i)}}while(d!==i-a);if(i!==u&&l!==-1)for(;f===c&&!(a<=0||t[a-1]!==t[i-1]);){for(e[--a]=1,e[--i]=0;a>0&&e[a-1];)a--;if(c===0)break;for(f=c-1,c=f;c>0&&n[c-1];)c--}if(i>=o)break;for(a=i+1,i=a;i<o&&e[i];)i++;if(f>=s)break;for(c=f+1,f=c;f<s&&n[f];)f++}}function ju(e,t,n){let r=[];for(let c of ei(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 ei(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 a(c){c>s&&(o.push({stable:!0,buffer:"o",bufferStart:s,bufferLength:c-s,content:t.slice(s,c)}),s=c)}let i=0;for(;i<r.length;){let c=r[i++],f=c.oStart,d=c.oStart+c.oLength,u=[c];for(a(f);i<r.length;){let l=r[i];if(l.oStart>d)break;d=Math.max(d,l.oStart+l.oLength),u.push(l),i++}if(u.length===1){if(c.abLength>0){let l=c.ab==="a"?e:n;o.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:l.slice(c.abStart,c.abStart+c.abLength)})}}else{let l={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 u){let k=w.oStart,b=k+w.oLength,E=w.abStart,x=E+w.abLength,P=l[w.ab];P.abMin=Math.min(E,P.abMin),P.abMax=Math.max(x,P.abMax),P.oMin=Math.min(k,P.oMin),P.oMax=Math.max(b,P.oMax)}let m=l.a.abMin+(f-l.a.oMin),h=l.a.abMax+(d-l.a.oMax),p=l.b.abMin+(f-l.b.oMin),g=l.b.abMax+(d-l.b.oMax);o.push({stable:!1,a:e.slice(m,h),o:t.slice(f,d),b:n.slice(p,g)})}s=d}return a(t.length),o}function Gu(e,t,n,r){let o=r?.excludeFalseConflicts??!0,s=ju(e,t,n),a=[],i=[];function c(){i.length&&(a.push({type:"ok",lines:i}),i=[])}for(let f of s)f.stable?i.push(...f.content):o&&bc(f.a,f.b)?i.push(...f.a):(c(),a.push({type:"conflict",a:f.a,o:f.o,b:f.b}));return c(),_u(Lu(a))}function Lr(e,t,n,r){let o=r?.markerSize??7,s=`${"<".repeat(o)}${r?.a?` ${r.a}`:""}`,a="=".repeat(o),i=`${">".repeat(o)}${r?.b?` ${r.b}`:""}`,c=Gu(e,t,n),f=!1,d=[];for(let u of c)u.type==="ok"?d.push(...u.lines):(f=!0,d.push(s,...u.a,a,...u.b,i));return{conflict:f,result:d}}function Lu(e){let t=[];for(let n of e)n.type==="ok"?t.push(n):t.push(...Nu(n));return t}function Nu(e){let{a:t,b:n}=e;if(t.length===0||n.length===0)return[e];if(bc(t,n))return[e];let r=ei(t,n);if(r.length===0)return[{type:"ok",lines:t}];let o=[],s=0;for(let i of r){let c=i.buffer1[0];c-s>0&&o.push({type:"ok",lines:t.slice(s,c)});let d=c+i.buffer1[1],u=i.buffer2[0]+i.buffer2[1];o.push({type:"conflict",a:t.slice(c,d),o:[],b:n.slice(i.buffer2[0],u)}),s=d}return t.length-s>0&&o.push({type:"ok",lines:t.slice(s)}),o.length===1&&o[0].type==="conflict"?[e]:o}function _u(e){if(e.length<3)return e;let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],o=e[n];if(r.type==="conflict"&&o.type==="ok"&&o.lines.length<=3&&n+1<e.length&&e[n+1].type==="conflict"){let s=e[n+1],a=r;a.a=[...r.a,...o.lines,...s.a],a.b=[...r.b,...o.lines,...s.b],a.o=[...r.o,...o.lines,...s.o],n++}else t.push(o)}return t}function Kn(e,t,n,r){let o=Lr(Et(e),Et(t),Et(n),{a:r.a,b:r.b,markerSize:r.markerSize}),a=(o.result[o.result.length-1]??"").endsWith("\0"),i=o.result.map(ti);return(i[i.length-1]??"").startsWith(">>>>>>>")||!a?`${i.join(`
194
235
  `)}
195
236
  `:i.join(`
196
- `)}function at(e){if(e==="")return[];let t=e.split(`
197
- `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function wo(e){return e.endsWith("\0")?e.slice(0,-1):e}function Pa(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}var _n=new TextDecoder,fn=new TextEncoder,Oa={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function yt(e,t,n,r,o){let{paths:s,baseMap:a,oursMap:i,theirsMap:c}=await Tl(e,t,n,r),f=await Al(e,s,a,i,c,o);return vl(e,s,o,f)}async function lr(e,t,n,r){let o=await gt(e,t,n),s=await j(e,t),a=await j(e,n);if(o.length===0)return{...await yt(e,null,s.tree,a.tree,r),baseTree:null};if(o.length===1){let f=await j(e,o[0]);return{...await yt(e,f.tree,s.tree,a.tree,r),baseTree:f.tree}}let i=await Da(e,t,n,o,1);return{...await yt(e,i,s.tree,a.tree,r),baseTree:i}}async function Tl(e,t,n,r){let o=await se(e,t),s=await se(e,n),a=await se(e,r),i=new Set;for(let f of o.keys())i.add(f);for(let f of s.keys())i.add(f);for(let f of a.keys())i.add(f);let c=new Map;for(let f of i){let d=o.get(f)??null,u=s.get(f)??null,l=a.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=u?{hash:u.hash,mode:u.mode}:null,p=l?{hash:l.hash,mode:l.mode}:null,g=(d?1:0)|(u?2:0)|(l?4:0),w=d?.hash??null,x=u?.hash??null,b=l?.hash??null,E=0;w!==null&&w===x&&(E|=3),w!==null&&w===b&&(E|=5),x!==null&&x===b&&(E|=6);let k={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:E,merged:{result:null,clean:!1},pathConflict:!1};if(Hl(k)){c.set(f,k);continue}c.set(f,k)}return{paths:c,baseMap:o,oursMap:s,theirsMap:a}}function Hl(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,a=r?.hash??null;return s===o&&a===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===a&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&a===null?(e.merged={result:null,clean:!0},!0):a===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&a!==o?(r?e.merged={result:{hash:a,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Al(e,t,n,r,o,s){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},i=[],c=[];for(let[M,$]of n)r.has(M)||i.push({path:M,status:"deleted",oldHash:$.hash,oldMode:$.mode}),o.has(M)||c.push({path:M,status:"deleted",oldHash:$.hash,oldMode:$.mode});for(let[M,$]of r)n.has(M)||i.push({path:M,status:"added",newHash:$.hash,newMode:$.mode});for(let[M,$]of o)n.has(M)||c.push({path:M,status:"added",newHash:$.hash,newMode:$.mode});let f=await Ye(e,i),d=await Ye(e,c);if(f.renames.length===0&&d.renames.length===0)return a;let u=new Map,l=new Map;for(let M of f.renames)u.set(M.oldPath,M);for(let M of d.renames)l.set(M.oldPath,M);let m=new Set;for(let[M]of r)!n.has(M)&&o.has(M)&&m.add(M);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(M,$,R=0){a.msgBuf.push({sortKey:M,subOrder:R,text:$})}for(let M of[...n.keys()].sort()){let $=u.get(M),R=l.get(M);if(!$&&!R)continue;let _=n.get(M);if(h.add(M),$&&R)if(h.add($.newPath),h.add(R.newPath),$.newPath===R.newPath){let q=r.get($.newPath),N=o.get(R.newPath);if(q.hash===N.hash)a.entries.push(rt($.newPath,q));else{let V=bo(t,$.newPath);V.stages=[{hash:_.hash,mode:_.mode},{hash:q.hash,mode:q.mode},{hash:N.hash,mode:N.mode}],V.pathnames=[M,$.newPath,R.newPath],V.filemask=7,V.merged={result:null,clean:!1}}}else{let q=r.get($.newPath),N=o.get(R.newPath),V=await Sa(e,_,q,N,s);V.conflict&&w(M,`Auto-merging ${M}`,-1),a.conflicts.push({path:M,reason:"rename-rename",oursPath:$.newPath,theirsPath:R.newPath}),w(M,`CONFLICT (rename/rename): ${M} renamed to ${$.newPath} in ${p} and to ${R.newPath} in ${g}.`),a.entries.push(rt(M,_,1)),a.entries.push(We($.newPath,q.mode,V.hash,2)),a.entries.push(We(R.newPath,N.mode,V.hash,3)),a.worktreeBlobs.set($.newPath,{hash:V.hash,mode:q.mode}),a.worktreeBlobs.set(R.newPath,{hash:V.hash,mode:N.mode})}else if($){h.add($.newPath);let q=o.get(M),N=r.get($.newPath),V=m.has($.newPath);if(q)if(V)await Aa(e,a,$.newPath,M,_,N,q,r,o,!1,s);else if(q.hash===_.hash&&N.hash===_.hash)a.entries.push(rt($.newPath,N));else if(q.hash===_.hash)a.entries.push(rt($.newPath,N));else if(N.hash===_.hash)a.entries.push(We($.newPath,N.mode,q.hash));else{let oe=bo(t,$.newPath);oe.stages=[{hash:_.hash,mode:_.mode},{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode}],oe.pathnames=[M,$.newPath,M],oe.filemask=7,oe.merged={result:null,clean:!1}}else{let oe=o.get($.newPath);if(a.conflicts.push({path:$.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:M}),w($.newPath,`CONFLICT (rename/delete): ${M} renamed to ${$.newPath} in ${p}, but deleted in ${g}.`),oe){a.conflicts.push({path:$.newPath,reason:"add-add"}),w($.newPath,`Auto-merging ${$.newPath}`,0),w($.newPath,`CONFLICT (add/add): Merge conflict in ${$.newPath}`,1),a.entries.push(rt($.newPath,N,2)),a.entries.push(rt($.newPath,oe,3));let Q=await ls(e,N.hash,oe.hash,N.mode,s);a.worktreeBlobs.set($.newPath,{hash:Q,mode:N.mode})}else a.entries.push(We($.newPath,_.mode,_.hash,1)),a.entries.push(rt($.newPath,N,2)),a.worktreeBlobs.set($.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w($.newPath,`CONFLICT (modify/delete): ${$.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${$.newPath} left in tree.`,1)}}else if(R){h.add(R.newPath);let q=r.get(M),N=o.get(R.newPath),V=m.has(R.newPath);if(q)if(V)await Aa(e,a,R.newPath,M,_,q,N,r,o,!0,s);else if(q.hash===_.hash&&N.hash===_.hash)a.entries.push(rt(R.newPath,N));else if(q.hash===_.hash)a.entries.push(rt(R.newPath,N));else if(N.hash===_.hash)a.entries.push(We(R.newPath,N.mode,q.hash));else{let oe=bo(t,R.newPath);oe.stages=[{hash:_.hash,mode:_.mode},{hash:q.hash,mode:q.mode},{hash:N.hash,mode:N.mode}],oe.pathnames=[M,M,R.newPath],oe.filemask=7,oe.merged={result:null,clean:!1}}else{let oe=r.get(R.newPath);if(a.conflicts.push({path:R.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:M}),w(R.newPath,`CONFLICT (rename/delete): ${M} renamed to ${R.newPath} in ${g}, but deleted in ${p}.`),oe){a.conflicts.push({path:R.newPath,reason:"add-add"}),w(R.newPath,`Auto-merging ${R.newPath}`,0),w(R.newPath,`CONFLICT (add/add): Merge conflict in ${R.newPath}`,1),a.entries.push(rt(R.newPath,oe,2)),a.entries.push(rt(R.newPath,N,3));let Q=await ls(e,oe.hash,N.hash,oe.mode,s);a.worktreeBlobs.set(R.newPath,{hash:Q,mode:oe.mode})}else a.entries.push(We(R.newPath,_.mode,_.hash,1)),a.entries.push(rt(R.newPath,N,3)),a.worktreeBlobs.set(R.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w(R.newPath,`CONFLICT (modify/delete): ${R.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${R.newPath} left in tree.`,1)}}}let x=new Set(f.renames.map(M=>M.newPath)),b=new Set(d.renames.map(M=>M.newPath)),E=Ia(n,r),k=Ia(n,o),P=Ra(E,o,n),C=Ra(k,r,n),O=$a(f.renames,P),y=$a(d.renames,C),I=Ta(O),A=Ta(y);for(let M of[...I.keys()])A.has(M)&&(I.delete(M),A.delete(M));let L=new Set(I.keys()),D=new Set(A.keys());if(A.size>0)for(let M of i){if(M.status!=="added"||x.has(M.path))continue;let $=Ha(M.path,A,L);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(r.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${M.path}.`,1);continue}let q=r.get(M.path),N=o.get($)??n.get($);a.entries.push(We($,q.mode,q.hash,2)),N&&a.entries.push(We($,N.mode,N.hash,3)),a.worktreeBlobs.set($,{hash:q.hash,mode:q.mode}),a.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${M.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let V=t.get(M.path);V&&(V.merged={result:null,clean:!0}),h.add(M.path);continue}let R=r.get(M.path);a.entries.push(We($,R.mode,R.hash,2)),a.worktreeBlobs.set($,{hash:R.hash,mode:R.mode}),a.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${M.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let _=t.get(M.path);_&&(_.merged={result:null,clean:!0}),h.add(M.path)}if(I.size>0)for(let M of c){if(M.status!=="added"||b.has(M.path))continue;let $=Ha(M.path,I,D);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(o.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${M.path}.`,1);continue}let q=o.get(M.path),N=r.get($)??n.get($);N&&a.entries.push(We($,N.mode,N.hash,2)),a.entries.push(We($,q.mode,q.hash,3)),a.worktreeBlobs.set($,{hash:q.hash,mode:q.mode}),a.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${M.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let V=t.get(M.path);V&&(V.merged={result:null,clean:!0}),h.add(M.path);continue}let R=o.get(M.path);a.entries.push(We($,R.mode,R.hash,3)),a.worktreeBlobs.set($,{hash:R.hash,mode:R.mode}),a.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${M.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let _=t.get(M.path);_&&(_.merged={result:null,clean:!0}),h.add(M.path)}let z=new Set(a.entries.map(M=>M.path));for(let M of z){let $=t.get(M);$&&($.merged={result:null,clean:!0})}for(let M of h){if(z.has(M))continue;let $=t.get(M);if(!$||$.merged.clean)continue;$.filemask===7&&!$.pathConflict||($.merged={result:null,clean:!0})}return a}function Ia(e,t){let n=new Set;for(let s of e.keys()){let a=ct(s);for(;a;)n.add(a),a=ct(a)}let r=new Set;for(let s of t.keys()){let a=ct(s);for(;a;)r.add(a),a=ct(a)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function Ra(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=ct(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=ct(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=ct(s)}return r}function $a(e,t){let n=new Map;for(let r of e){let o=ct(r.oldPath),s=ct(r.newPath),a=!0;for(;;){if(!a){let i=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(i,r.oldPath.indexOf("/",i)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let i=n.get(o);i||(i=new Map,n.set(o,i)),i.set(s,(i.get(s)??0)+1)}if(a=!1,!o||!s)break;o=ct(o),s=ct(s)}}return n}function Ta(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,a=null;for(let[i,c]of r)c===o?s=o:c>o&&(o=c,a=i);o>0&&s!==o&&a!==null&&t.set(n,a)}return t}function Ha(e,t,n){let r=ct(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let a=e.slice(r.length+1);return s?`${s}/${a}`:a}r=ct(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function ct(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Aa(e,t,n,r,o,s,a,i,c,f=!1,d){let u=f?i.get(n):c.get(n),l=f?a:s;if(u.hash===l.hash){t.entries.push(We(n,u.mode,u.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Sa(e,o,s,a,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(u.hash===h.hash)t.entries.push(We(n,u.mode,h.hash));else if(t.conflicts.push({path:n,reason:"add-add"}),t.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),t.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),f){t.entries.push(rt(n,u,2)),t.entries.push(We(n,a.mode,h.hash,3));let p=await ls(e,u.hash,h.hash,u.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:u.mode})}else{t.entries.push(We(n,s.mode,h.hash,2)),t.entries.push(rt(n,u,3));let p=await ls(e,h.hash,u.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Sa(e,t,n,r,o,s,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(Lt(t.mode)||Lt(n.mode)||Lt(r.mode))return{hash:n.hash,conflict:!0};let i=await ie(e,t.hash),c=await ie(e,n.hash),f=await ie(e,r.hash);if(Pe(c)||Pe(f)||Pe(i))return{hash:n.hash,conflict:!0};let d=at(i),u=at(c),l=at(f),m=fr(u,d,l);if(!m.conflict)return{hash:await Eo(e,m.result),conflict:!1};let h=o?.a??"HEAD",p=o?.b??"theirs",g=s?.oursPath?`${h}:${s.oursPath}`:h,w=s?.theirsPath?`${p}:${s.theirsPath}`:p,x=Cn(c,i,f,{a:g,b:w,markerSize:a??7});return{hash:await we(e,"blob",fn.encode(x)),conflict:!0}}async function ls(e,t,n,r,o){let s=await ie(e,t),a=await ie(e,n),i=Cn(s,"",a,{a:o?.a??"HEAD",b:o?.b??"theirs"});return we(e,"blob",fn.encode(i))}function rt(e,t,n=0){return We(e,t.mode,t.hash,n)}function We(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:pe()}}async function vl(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],a=[...r.msgBuf],i=new Map(r.worktreeBlobs);function c(m,h,p=0){a.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(Ee(m,h.merged.result.hash,h.merged.result.mode));continue}await Sl(e,h,n,o,s,c,i)}a.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=a.map(m=>m.text),d=[],u=new Set;for(let m of o)m.stage===0&&(d.push(m),u.add(m.path));for(let[m,h]of i)u.has(m)||d.push(Ee(m,h.hash,h.mode));d.sort((m,h)=>he(m.path,h.path));let l=await ke(e,d);return{entries:o,conflicts:s,messages:f,resultTree:l}}async function Sl(e,t,n,r,o,s,a){let i=t.path,[c,f,d]=t.stages,u=c?.hash??null,l=f?.hash??null,m=d?.hash??null;if(l===null&&m!==null&&u!==null){o.push({path:i,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(Ee(i,u,c.mode,1)),r.push(Ee(i,m,d.mode,3)),a.set(i,{hash:m,mode:d.mode});return}if(m===null&&l!==null&&u!==null){o.push({path:i,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(Ee(i,u,c.mode,1)),r.push(Ee(i,l,f.mode,2)),a.set(i,{hash:l,mode:f.mode});return}if(u===null&&l!==null&&m!==null){if(l===m){r.push(Ee(i,l,f.mode));return}s(i,`Auto-merging ${i}`,0);let h=await ie(e,l),p=await ie(e,m);if(Pe(h)||Pe(p)){o.push({path:i,reason:"add-add"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(Ee(i,l,f.mode,2)),r.push(Ee(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let g=at(""),w=at(h),x=at(p),b=fr(w,g,x,n);if(!b.conflict){let P=await Eo(e,b.result);r.push(Ee(i,P,f.mode));return}o.push({path:i,reason:"add-add"}),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(Ee(i,l,f.mode,2)),r.push(Ee(i,m,d.mode,3));let E=Cn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),k=await we(e,"blob",fn.encode(E));a.set(i,{hash:k,mode:f.mode});return}if(u!==null&&l!==null&&m!==null){if(l===u){r.push(Ee(i,m,d.mode));return}if(m===u){r.push(Ee(i,l,f.mode));return}if(l===m){r.push(Ee(i,l,f.mode));return}if(s(i,`Auto-merging ${i}`,0),Lt(c.mode)||Lt(f.mode)||Lt(d.mode)){o.push({path:i,reason:"content"}),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Ee(i,u,c.mode,1)),r.push(Ee(i,l,f.mode,2)),r.push(Ee(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let h=await ie(e,u),p=await ie(e,l),g=await ie(e,m);if(Pe(p)||Pe(g)||Pe(h)){o.push({path:i,reason:"content"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Ee(i,u,c.mode,1)),r.push(Ee(i,l,f.mode,2)),r.push(Ee(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let w=at(h),x=at(p),b=at(g),E=fr(x,w,b,n);if(E.conflict){let k=t.pathnames[1],P=t.pathnames[2],C=k!==i||P!==i,O={path:i,reason:"content"};C&&(k!==i&&(O.oursOrigPath=k),P!==i&&(O.theirsOrigPath=P)),o.push(O),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Ee(i,u,c.mode,1)),r.push(Ee(i,l,f.mode,2)),r.push(Ee(i,m,d.mode,3));let y=C?`${n?.a??"HEAD"}:${k}`:n?.a??"HEAD",I=C?`${n?.b??"theirs"}:${P}`:n?.b??"theirs",A=Cn(p,h,g,{a:y,b:I}),L=await we(e,"blob",fn.encode(A));a.set(i,{hash:L,mode:f.mode})}else{let k=await Eo(e,E.result);r.push(Ee(i,k,f.mode))}return}}var Dl=200;async function Da(e,t,n,r,o){let s=await Promise.all(r.map(async d=>({hash:d,timestamp:(await j(e,d)).committer.timestamp})));s.sort((d,u)=>d.timestamp-u.timestamp);let a=s.map(d=>d.hash),i=a[0],c=i,f=(await j(e,i)).tree;for(let d=1;d<a.length;d++){let u=a[d],l=(await j(e,u)).tree,m=null;if(o>=Dl)m=f;else{let g=await gt(e,c,u);g.length===0?m=null:g.length===1?m=(await j(e,g[0])).tree:m=await Da(e,c,u,g,o+1)}let h=await yt(e,m,f,l);f=await Ml(e,h,o);let p=$t({type:"commit",tree:f,parents:[c,u],author:Oa,committer:Oa,message:"merged common ancestors"});c=await we(e,"commit",p)}return f}async function Ml(e,t,n){let r=t.entries.filter(i=>i.stage===0),o=new Map;for(let i of t.entries)i.stage>0&&o.set(`${i.path}\0${i.stage}`,i);let s=(i,c)=>o.get(`${i}\0${c}`),a={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let i of t.conflicts){if(i.reason==="delete-modify"||i.reason==="rename-delete"){let d=s(i.path,1);if(d){r.push({...d,stage:0});continue}}if(i.reason==="rename-rename"){let d=i.oursPath??i.path,u=i.theirsPath??i.path,l=s(i.path,1),m=s(d,2),h=s(u,3);if(m&&h){let p=_n.decode((await fe(e,m.hash)).content),g=_n.decode((await fe(e,h.hash)).content),w=l?_n.decode((await fe(e,l.hash)).content):"",x=8+n*2,b=a.a??"Temporary merge branch 1",E=a.b??"Temporary merge branch 2",k=Cn(p,w,g,{a:`${b}:${d}`,o:a.o,b:`${E}:${u}`,markerSize:x}),P=await we(e,"blob",fn.encode(k));r.push({path:d,mode:m.mode,hash:P,stage:0,stat:pe()}),r.push({path:u,mode:h.mode,hash:P,stage:0,stat:pe()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(i.path,2),f=s(i.path,3);if(c&&f&&(i.reason==="content"||i.reason==="add-add")){let d=_n.decode((await fe(e,c.hash)).content),u=_n.decode((await fe(e,f.hash)).content),l=i.reason==="content"?s(i.path,1):null,m=l?_n.decode((await fe(e,l.hash)).content):"",h=i.oursOrigPath||i.theirsOrigPath,p=a.a??"Temporary merge branch 1",g=a.b??"Temporary merge branch 2",w=h?`${p}:${i.oursOrigPath??i.path}`:p,x=h?`${g}:${i.theirsOrigPath??i.path}`:g,b=Cn(d,m,u,{a:w,o:a.o,b:x,markerSize:a.markerSize}),E=await we(e,"blob",fn.encode(b));r.push({path:i.path,mode:c.mode,hash:E,stage:0,stat:pe()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((i,c)=>he(i.path,c.path)),ke(e,r)}async function Eo(e,t){let n=t.map(wo);if(n.length===0)return we(e,"blob",fn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
237
+ `)}function Et(e){if(e==="")return[];let t=e.split(`
238
+ `);if(t[t.length-1]==="")t.pop();else{let n=t[t.length-1]??"";t[t.length-1]=`${n}\0`}return t}function ti(e){return e.endsWith("\0")?e.slice(0,-1):e}function bc(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}ye();re();Jt();fe();Gn();Ie();et();Wt();var fr=new TextDecoder,Tn=new TextEncoder,yc={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function St(e,t,n,r,o){let{paths:s,baseMap:a,oursMap:i,theirsMap:c}=await Uu(e,t,n,r),f=await Wu(e,s,a,i,c,o);return qu(e,s,o,f)}async function _r(e,t,n,r){let o=await vt(e,t,n),s=await D(e,t),a=await D(e,n);if(o.length===0)return{...await St(e,null,s.tree,a.tree,r),baseTree:null};if(o.length===1){let f=await D(e,o[0]);return{...await St(e,f.tree,s.tree,a.tree,r),baseTree:f.tree}}let i=await $c(e,t,n,o,1);return{...await St(e,i,s.tree,a.tree,r),baseTree:i}}async function Uu(e,t,n,r){let o=await ae(e,t),s=await ae(e,n),a=await ae(e,r),i=new Set;for(let f of o.keys())i.add(f);for(let f of s.keys())i.add(f);for(let f of a.keys())i.add(f);let c=new Map;for(let f of i){let d=o.get(f)??null,u=s.get(f)??null,l=a.get(f)??null,m=d?{hash:d.hash,mode:d.mode}:null,h=u?{hash:u.hash,mode:u.mode}:null,p=l?{hash:l.hash,mode:l.mode}:null,g=(d?1:0)|(u?2:0)|(l?4:0),w=d?.hash??null,k=u?.hash??null,b=l?.hash??null,E=0;w!==null&&w===k&&(E|=3),w!==null&&w===b&&(E|=5),k!==null&&k===b&&(E|=6);let x={path:f,stages:[m,h,p],pathnames:[f,f,f],filemask:g,matchMask:E,merged:{result:null,clean:!1},pathConflict:!1};if(Bu(x)){c.set(f,x);continue}c.set(f,x)}return{paths:c,baseMap:o,oursMap:s,theirsMap:a}}function Bu(e){let[t,n,r]=e.stages,o=t?.hash??null,s=n?.hash??null,a=r?.hash??null;return s===o&&a===o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===a&&s!==null?(e.merged={result:{hash:s,mode:n.mode},clean:!0},!0):s===null&&a===null?(e.merged={result:null,clean:!0},!0):a===o&&s!==o?(n?e.merged={result:{hash:s,mode:n.mode},clean:!0}:e.merged={result:null,clean:!0},!0):s===o&&a!==o?(r?e.merged={result:{hash:a,mode:r.mode},clean:!0}:e.merged={result:null,clean:!0},!0):!1}async function Wu(e,t,n,r,o,s){let a={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},i=[],c=[];for(let[j,$]of n)r.has(j)||i.push({path:j,status:"deleted",oldHash:$.hash,oldMode:$.mode}),o.has(j)||c.push({path:j,status:"deleted",oldHash:$.hash,oldMode:$.mode});for(let[j,$]of r)n.has(j)||i.push({path:j,status:"added",newHash:$.hash,newMode:$.mode});for(let[j,$]of o)n.has(j)||c.push({path:j,status:"added",newHash:$.hash,newMode:$.mode});let f=await it(e,i),d=await it(e,c);if(f.renames.length===0&&d.renames.length===0)return a;let u=new Map,l=new Map;for(let j of f.renames)u.set(j.oldPath,j);for(let j of d.renames)l.set(j.oldPath,j);let m=new Set;for(let[j]of r)!n.has(j)&&o.has(j)&&m.add(j);let h=new Set,p=s?.a??"HEAD",g=s?.b??"theirs";function w(j,$,O=0){a.msgBuf.push({sortKey:j,subOrder:O,text:$})}for(let j of[...n.keys()].sort()){let $=u.get(j),O=l.get(j);if(!$&&!O)continue;let _=n.get(j);if(h.add(j),$&&O)if(h.add($.newPath),h.add(O.newPath),$.newPath===O.newPath){let q=r.get($.newPath),N=o.get(O.newPath);if(q.hash===N.hash)a.entries.push(ht($.newPath,q));else{let X=ni(t,$.newPath);X.stages=[{hash:_.hash,mode:_.mode},{hash:q.hash,mode:q.mode},{hash:N.hash,mode:N.mode}],X.pathnames=[j,$.newPath,O.newPath],X.filemask=7,X.merged={result:null,clean:!1}}}else{let q=r.get($.newPath),N=o.get(O.newPath),X=await Oc(e,_,q,N,s);X.conflict&&w(j,`Auto-merging ${j}`,-1),a.conflicts.push({path:j,reason:"rename-rename",oursPath:$.newPath,theirsPath:O.newPath}),w(j,`CONFLICT (rename/rename): ${j} renamed to ${$.newPath} in ${p} and to ${O.newPath} in ${g}.`),a.entries.push(ht(j,_,1)),a.entries.push(nt($.newPath,q.mode,X.hash,2)),a.entries.push(nt(O.newPath,N.mode,X.hash,3)),a.worktreeBlobs.set($.newPath,{hash:X.hash,mode:q.mode}),a.worktreeBlobs.set(O.newPath,{hash:X.hash,mode:N.mode})}else if($){h.add($.newPath);let q=o.get(j),N=r.get($.newPath),X=m.has($.newPath);if(q)if(X)await Rc(e,a,$.newPath,j,_,N,q,r,o,!1,s);else if(q.hash===_.hash&&N.hash===_.hash)a.entries.push(ht($.newPath,N));else if(q.hash===_.hash)a.entries.push(ht($.newPath,N));else if(N.hash===_.hash)a.entries.push(nt($.newPath,N.mode,q.hash));else{let ce=ni(t,$.newPath);ce.stages=[{hash:_.hash,mode:_.mode},{hash:N.hash,mode:N.mode},{hash:q.hash,mode:q.mode}],ce.pathnames=[j,$.newPath,j],ce.filemask=7,ce.merged={result:null,clean:!1}}else{let ce=o.get($.newPath);if(a.conflicts.push({path:$.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:j}),w($.newPath,`CONFLICT (rename/delete): ${j} renamed to ${$.newPath} in ${p}, but deleted in ${g}.`),ce){a.conflicts.push({path:$.newPath,reason:"add-add"}),w($.newPath,`Auto-merging ${$.newPath}`,0),w($.newPath,`CONFLICT (add/add): Merge conflict in ${$.newPath}`,1),a.entries.push(ht($.newPath,N,2)),a.entries.push(ht($.newPath,ce,3));let te=await qs(e,N.hash,ce.hash,N.mode,s);a.worktreeBlobs.set($.newPath,{hash:te,mode:N.mode})}else a.entries.push(nt($.newPath,_.mode,_.hash,1)),a.entries.push(ht($.newPath,N,2)),a.worktreeBlobs.set($.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w($.newPath,`CONFLICT (modify/delete): ${$.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${$.newPath} left in tree.`,1)}}else if(O){h.add(O.newPath);let q=r.get(j),N=o.get(O.newPath),X=m.has(O.newPath);if(q)if(X)await Rc(e,a,O.newPath,j,_,q,N,r,o,!0,s);else if(q.hash===_.hash&&N.hash===_.hash)a.entries.push(ht(O.newPath,N));else if(q.hash===_.hash)a.entries.push(ht(O.newPath,N));else if(N.hash===_.hash)a.entries.push(nt(O.newPath,N.mode,q.hash));else{let ce=ni(t,O.newPath);ce.stages=[{hash:_.hash,mode:_.mode},{hash:q.hash,mode:q.mode},{hash:N.hash,mode:N.mode}],ce.pathnames=[j,j,O.newPath],ce.filemask=7,ce.merged={result:null,clean:!1}}else{let ce=r.get(O.newPath);if(a.conflicts.push({path:O.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:j}),w(O.newPath,`CONFLICT (rename/delete): ${j} renamed to ${O.newPath} in ${g}, but deleted in ${p}.`),ce){a.conflicts.push({path:O.newPath,reason:"add-add"}),w(O.newPath,`Auto-merging ${O.newPath}`,0),w(O.newPath,`CONFLICT (add/add): Merge conflict in ${O.newPath}`,1),a.entries.push(ht(O.newPath,ce,2)),a.entries.push(ht(O.newPath,N,3));let te=await qs(e,ce.hash,N.hash,ce.mode,s);a.worktreeBlobs.set(O.newPath,{hash:te,mode:ce.mode})}else a.entries.push(nt(O.newPath,_.mode,_.hash,1)),a.entries.push(ht(O.newPath,N,3)),a.worktreeBlobs.set(O.newPath,{hash:N.hash,mode:N.mode}),N.hash!==_.hash&&w(O.newPath,`CONFLICT (modify/delete): ${O.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${O.newPath} left in tree.`,1)}}}let k=new Set(f.renames.map(j=>j.newPath)),b=new Set(d.renames.map(j=>j.newPath)),E=Ec(n,r),x=Ec(n,o),P=kc(E,o,n),C=kc(x,r,n),R=xc(f.renames,P),y=xc(d.renames,C),I=Cc(R),v=Cc(y);for(let j of[...I.keys()])v.has(j)&&(I.delete(j),v.delete(j));let G=new Set(I.keys()),M=new Set(v.keys());if(v.size>0)for(let j of i){if(j.status!=="added"||k.has(j.path))continue;let $=Pc(j.path,v,G);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(r.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let q=r.get(j.path),N=o.get($)??n.get($);a.entries.push(nt($,q.mode,q.hash,2)),N&&a.entries.push(nt($,N.mode,N.hash,3)),a.worktreeBlobs.set($,{hash:q.hash,mode:q.mode}),a.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let X=t.get(j.path);X&&(X.merged={result:null,clean:!0}),h.add(j.path);continue}let O=r.get(j.path);a.entries.push(nt($,O.mode,O.hash,2)),a.worktreeBlobs.set($,{hash:O.hash,mode:O.mode}),a.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${j.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${$}.`,1);let _=t.get(j.path);_&&(_.merged={result:null,clean:!0}),h.add(j.path)}if(I.size>0)for(let j of c){if(j.status!=="added"||b.has(j.path))continue;let $=Pc(j.path,I,M);if(!$)continue;if(t.has($)||n.has($)||r.has($)||o.has($)){if(o.has($)){w($,`CONFLICT (implicit dir rename): Existing file/dir at ${$} in the way of implicit directory rename(s) putting the following path(s) there: ${j.path}.`,1);continue}let q=o.get(j.path),N=r.get($)??n.get($);N&&a.entries.push(nt($,N.mode,N.hash,2)),a.entries.push(nt($,q.mode,q.hash,3)),a.worktreeBlobs.set($,{hash:q.hash,mode:q.mode}),a.conflicts.push({path:$,reason:"add-add"}),w($,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let X=t.get(j.path);X&&(X.merged={result:null,clean:!0}),h.add(j.path);continue}let O=o.get(j.path);a.entries.push(nt($,O.mode,O.hash,3)),a.worktreeBlobs.set($,{hash:O.hash,mode:O.mode}),a.conflicts.push({path:$,reason:"directory-rename"}),w($,`CONFLICT (file location): ${j.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${$}.`,1);let _=t.get(j.path);_&&(_.merged={result:null,clean:!0}),h.add(j.path)}let V=new Set(a.entries.map(j=>j.path));for(let j of V){let $=t.get(j);$&&($.merged={result:null,clean:!0})}for(let j of h){if(V.has(j))continue;let $=t.get(j);if(!$||$.merged.clean)continue;$.filemask===7&&!$.pathConflict||($.merged={result:null,clean:!0})}return a}function Ec(e,t){let n=new Set;for(let s of e.keys()){let a=kt(s);for(;a;)n.add(a),a=kt(a)}let r=new Set;for(let s of t.keys()){let a=kt(s);for(;a;)r.add(a),a=kt(a)}let o=new Set;for(let s of n)r.has(s)||o.add(s);return o}function kc(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=kt(o)??"";e.has(s)&&r.add(s)}for(let o of[...r]){let s=kt(o);for(;s;)e.has(s)&&!r.has(s)&&r.add(s),s=kt(s)}return r}function xc(e,t){let n=new Map;for(let r of e){let o=kt(r.oldPath),s=kt(r.newPath),a=!0;for(;;){if(!a){let i=o.length+(o?1:0),c=s.length+(s?1:0),f=r.oldPath.slice(i,r.oldPath.indexOf("/",i)),d=r.newPath.slice(c,r.newPath.indexOf("/",c));if(f!==d)break}if(t.has(o)){let i=n.get(o);i||(i=new Map,n.set(o,i)),i.set(s,(i.get(s)??0)+1)}if(a=!1,!o||!s)break;o=kt(o),s=kt(s)}}return n}function Cc(e){let t=new Map;for(let[n,r]of e){let o=0,s=0,a=null;for(let[i,c]of r)c===o?s=o:c>o&&(o=c,a=i);o>0&&s!==o&&a!==null&&t.set(n,a)}return t}function Pc(e,t,n){let r=kt(e);for(;r;){let s=t.get(r);if(s!==void 0){if(n.has(s))return null;let a=e.slice(r.length+1);return s?`${s}/${a}`:a}r=kt(r)}let o=t.get("");return o!==void 0&&!n.has(o)?`${o}/${e}`:null}function kt(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}async function Rc(e,t,n,r,o,s,a,i,c,f=!1,d){let u=f?i.get(n):c.get(n),l=f?a:s;if(u.hash===l.hash){t.entries.push(nt(n,u.mode,u.hash)),t.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let h=await Oc(e,o,s,a,d,f?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(u.hash===h.hash)t.entries.push(nt(n,u.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(ht(n,u,2)),t.entries.push(nt(n,a.mode,h.hash,3));let p=await qs(e,u.hash,h.hash,u.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:u.mode})}else{t.entries.push(nt(n,s.mode,h.hash,2)),t.entries.push(ht(n,u,3));let p=await qs(e,h.hash,u.hash,s.mode,d);t.worktreeBlobs.set(n,{hash:p,mode:s.mode})}}async function Oc(e,t,n,r,o,s,a){if(n.hash===t.hash)return{hash:r.hash,conflict:!1};if(r.hash===t.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(tn(t.mode)||tn(n.mode)||tn(r.mode))return{hash:n.hash,conflict:!0};let i=await le(e,t.hash),c=await le(e,n.hash),f=await le(e,r.hash);if(De(c)||De(f)||De(i))return{hash:n.hash,conflict:!0};let d=Et(i),u=Et(c),l=Et(f),m=Lr(u,d,l);if(!m.conflict)return{hash:await si(e,m.result),conflict:!1};let h=o?.a??"HEAD",p=o?.b??"theirs",g=s?.oursPath?`${h}:${s.oursPath}`:h,w=s?.theirsPath?`${p}:${s.theirsPath}`:p,k=Kn(c,i,f,{a:g,b:w,markerSize:a??7});return{hash:await Re(e,"blob",Tn.encode(k)),conflict:!0}}async function qs(e,t,n,r,o){let s=await le(e,t),a=await le(e,n),i=Kn(s,"",a,{a:o?.a??"HEAD",b:o?.b??"theirs"});return Re(e,"blob",Tn.encode(i))}function ht(e,t,n=0){return nt(e,t.mode,t.hash,n)}function nt(e,t,n,r=0){return{path:e,mode:parseInt(t,8),hash:n,stage:r,stat:ke()}}async function qu(e,t,n,r){let o=[...r.entries],s=[...r.conflicts],a=[...r.msgBuf],i=new Map(r.worktreeBlobs);function c(m,h,p=0){a.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(Te(m,h.merged.result.hash,h.merged.result.mode));continue}await Ku(e,h,n,o,s,c,i)}a.sort((m,h)=>(m.sortKey<h.sortKey?-1:m.sortKey>h.sortKey?1:0)||m.subOrder-h.subOrder);let f=a.map(m=>m.text),d=[],u=new Set;for(let m of o)m.stage===0&&(d.push(m),u.add(m.path));for(let[m,h]of i)u.has(m)||d.push(Te(m,h.hash,h.mode));d.sort((m,h)=>Ee(m.path,h.path));let l=await Ae(e,d);return{entries:o,conflicts:s,messages:f,resultTree:l}}async function Ku(e,t,n,r,o,s,a){let i=t.path,[c,f,d]=t.stages,u=c?.hash??null,l=f?.hash??null,m=d?.hash??null;if(l===null&&m!==null&&u!==null){o.push({path:i,reason:"delete-modify",deletedBy:"ours"});let h=n?.a??"HEAD",p=n?.b??"theirs";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(Te(i,u,c.mode,1)),r.push(Te(i,m,d.mode,3)),a.set(i,{hash:m,mode:d.mode});return}if(m===null&&l!==null&&u!==null){o.push({path:i,reason:"delete-modify",deletedBy:"theirs"});let h=n?.b??"theirs",p=n?.a??"HEAD";s(i,`CONFLICT (modify/delete): ${i} deleted in ${h} and modified in ${p}. Version ${p} of ${i} left in tree.`),c&&r.push(Te(i,u,c.mode,1)),r.push(Te(i,l,f.mode,2)),a.set(i,{hash:l,mode:f.mode});return}if(u===null&&l!==null&&m!==null){if(l===m){r.push(Te(i,l,f.mode));return}s(i,`Auto-merging ${i}`,0);let h=await le(e,l),p=await le(e,m);if(De(h)||De(p)){o.push({path:i,reason:"add-add"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(Te(i,l,f.mode,2)),r.push(Te(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let g=Et(""),w=Et(h),k=Et(p),b=Lr(w,g,k,n);if(!b.conflict){let P=await si(e,b.result);r.push(Te(i,P,f.mode));return}o.push({path:i,reason:"add-add"}),s(i,`CONFLICT (add/add): Merge conflict in ${i}`,1),r.push(Te(i,l,f.mode,2)),r.push(Te(i,m,d.mode,3));let E=Kn(h,"",p,{a:n?.a??"HEAD",b:n?.b??"theirs"}),x=await Re(e,"blob",Tn.encode(E));a.set(i,{hash:x,mode:f.mode});return}if(u!==null&&l!==null&&m!==null){if(l===u){r.push(Te(i,m,d.mode));return}if(m===u){r.push(Te(i,l,f.mode));return}if(l===m){r.push(Te(i,l,f.mode));return}if(s(i,`Auto-merging ${i}`,0),tn(c.mode)||tn(f.mode)||tn(d.mode)){o.push({path:i,reason:"content"}),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Te(i,u,c.mode,1)),r.push(Te(i,l,f.mode,2)),r.push(Te(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let h=await le(e,u),p=await le(e,l),g=await le(e,m);if(De(p)||De(g)||De(h)){o.push({path:i,reason:"content"}),s(i,`warning: Cannot merge binary files: ${i} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Te(i,u,c.mode,1)),r.push(Te(i,l,f.mode,2)),r.push(Te(i,m,d.mode,3)),a.set(i,{hash:l,mode:f.mode});return}let w=Et(h),k=Et(p),b=Et(g),E=Lr(k,w,b,n);if(E.conflict){let x=t.pathnames[1],P=t.pathnames[2],C=x!==i||P!==i,R={path:i,reason:"content"};C&&(x!==i&&(R.oursOrigPath=x),P!==i&&(R.theirsOrigPath=P)),o.push(R),s(i,`CONFLICT (content): Merge conflict in ${i}`,1),r.push(Te(i,u,c.mode,1)),r.push(Te(i,l,f.mode,2)),r.push(Te(i,m,d.mode,3));let y=C?`${n?.a??"HEAD"}:${x}`:n?.a??"HEAD",I=C?`${n?.b??"theirs"}:${P}`:n?.b??"theirs",v=Kn(p,h,g,{a:y,b:I}),G=await Re(e,"blob",Tn.encode(v));a.set(i,{hash:G,mode:f.mode})}else{let x=await si(e,E.result);r.push(Te(i,x,f.mode))}return}}var zu=200;async function $c(e,t,n,r,o){let s=await Promise.all(r.map(async d=>({hash:d,timestamp:(await D(e,d)).committer.timestamp})));s.sort((d,u)=>d.timestamp-u.timestamp);let a=s.map(d=>d.hash),i=a[0],c=i,f=(await D(e,i)).tree;for(let d=1;d<a.length;d++){let u=a[d],l=(await D(e,u)).tree,m=null;if(o>=zu)m=f;else{let g=await vt(e,c,u);g.length===0?m=null:g.length===1?m=(await D(e,g[0])).tree:m=await $c(e,c,u,g,o+1)}let h=await St(e,m,f,l);f=await Vu(e,h,o);let p=Ut({type:"commit",tree:f,parents:[c,u],author:yc,committer:yc,message:"merged common ancestors"});c=await Re(e,"commit",p)}return f}async function Vu(e,t,n){let r=t.entries.filter(i=>i.stage===0),o=new Map;for(let i of t.entries)i.stage>0&&o.set(`${i.path}\0${i.stage}`,i);let s=(i,c)=>o.get(`${i}\0${c}`),a={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let i of t.conflicts){if(i.reason==="delete-modify"||i.reason==="rename-delete"){let d=s(i.path,1);if(d){r.push({...d,stage:0});continue}}if(i.reason==="rename-rename"){let d=i.oursPath??i.path,u=i.theirsPath??i.path,l=s(i.path,1),m=s(d,2),h=s(u,3);if(m&&h){let p=fr.decode((await he(e,m.hash)).content),g=fr.decode((await he(e,h.hash)).content),w=l?fr.decode((await he(e,l.hash)).content):"",k=8+n*2,b=a.a??"Temporary merge branch 1",E=a.b??"Temporary merge branch 2",x=Kn(p,w,g,{a:`${b}:${d}`,o:a.o,b:`${E}:${u}`,markerSize:k}),P=await Re(e,"blob",Tn.encode(x));r.push({path:d,mode:m.mode,hash:P,stage:0,stat:ke()}),r.push({path:u,mode:h.mode,hash:P,stage:0,stat:ke()});continue}else if(m){r.push({...m,stage:0});continue}}let c=s(i.path,2),f=s(i.path,3);if(c&&f&&(i.reason==="content"||i.reason==="add-add")){let d=fr.decode((await he(e,c.hash)).content),u=fr.decode((await he(e,f.hash)).content),l=i.reason==="content"?s(i.path,1):null,m=l?fr.decode((await he(e,l.hash)).content):"",h=i.oursOrigPath||i.theirsOrigPath,p=a.a??"Temporary merge branch 1",g=a.b??"Temporary merge branch 2",w=h?`${p}:${i.oursOrigPath??i.path}`:p,k=h?`${g}:${i.theirsOrigPath??i.path}`:g,b=Kn(d,m,u,{a:w,o:a.o,b:k,markerSize:a.markerSize}),E=await Re(e,"blob",Tn.encode(b));r.push({path:i.path,mode:c.mode,hash:E,stage:0,stat:ke()})}else c?r.push({...c,stage:0}):f&&r.push({...f,stage:0})}return r.sort((i,c)=>Ee(i.path,c.path)),Ae(e,r)}async function si(e,t){let n=t.map(ti);if(n.length===0)return Re(e,"blob",Tn.encode(""));let s=(t[t.length-1]??"").endsWith("\0")?n.join(`
198
239
  `):`${n.join(`
199
240
  `)}
200
- `;return we(e,"blob",fn.encode(s))}function Ee(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:pe()}}function bo(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 dr(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}
241
+ `;return Re(e,"blob",Tn.encode(s))}function Te(e,t,n,r=0){let o=typeof n=="string"?parseInt(n,8):n;return{path:e,mode:o,hash:t,stage:r,stat:ke()}}function ni(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 Nr(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}
201
242
  ${e.join(" ")}
202
243
  Merge with strategy ort failed.
203
244
  `;let c=e.map(d=>` ${d}`).join(`
@@ -212,7 +253,7 @@ ${a}
212
253
  ${i}
213
254
  Aborting
214
255
  fatal: ${n} failed
215
- `}function va(e,t,n,r){let o=[];if(e.length>0){let a=e.map(i=>` ${i}`).join(`
256
+ `}function Ic(e,t,n,r){let o=[];if(e.length>0){let a=e.map(i=>` ${i}`).join(`
216
257
  `);o.push(`error: Your local changes to the following files would be overwritten by ${n}:
217
258
  ${a}
218
259
  Please commit your changes or stash them before you ${n}.
@@ -222,37 +263,37 @@ ${a}
222
263
  Please move or remove them before you ${n}.
223
264
  `)}let s=r==="merge"?"Merge with strategy ort failed.":`fatal: ${r} failed`;return`${o.join("")}Aborting
224
265
  ${s}
225
- `}async function qt(e,t,n,r){let o=await U(e),s=await se(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(xe(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let x=s.get(g);(!x||x.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 yo(e,o,s);let w=r.operationName??"merge",x=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:dr(g,w,x,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await bn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:Gr,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await yo(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(),x=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),b;return w.length>0&&x.length>0?b=va(w,x,p,g):x.length>0?b=dr(x,p,g,"untracked","worktree"):b=dr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await bn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:Nr,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await yo(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(k=>k.error==="WOULD_OVERWRITE"||k.error==="NOT_UPTODATE_FILE").map(k=>k.path).sort(),x=h.errors.filter(k=>k.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||k.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(k=>k.path).sort(),b=[];w.length>0&&b.push(dr(w,p,g,"local","worktree")),x.length>0&&b.push(dr(x,p,g,"untracked","worktree"));let E;return b.length>1?E=va(w,x,p,g):E=b[0]??"",{ok:!1,stdout:"",stderr:E,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await be(e,h.worktreeOps)}let a=new Set,i=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){a.add(p.path);continue}}h.push(p)}i=h}let c=new Set(i.map(h=>h.path));for(let h of s.keys())a.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...i,...f];d.sort((h,p)=>he(h.path,p.path)||h.stage-p.stage);let u={version:2,entries:d};await re(e,u);let l=d.filter(h=>h.stage===0),m=await ke(e,l);return{ok:!0,finalIndex:u,mergedTreeHash:m}}async function yo(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=H(e.workTree,r.path);await e.fs.exists(o)||await ve(e,{path:r.path,hash:r.hash,mode:r.mode})}}function Ma(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[W.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:v().describe("Abort the current cherry-pick operation"),continue:v().describe("Continue the cherry-pick after conflict resolution"),skip:v().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":v().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:te.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:v().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let R=await t.hooks.emitPre("pre-cherry-pick",{mode:"abort",commit:null});if(R)return{stdout:"",stderr:R.message??"",exitCode:1}}let $=await Ll(s,r.env);return $.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"abort",commitHash:null,hadConflicts:!1}),$}if(n.continue){if(t?.hooks){let R=await t.hooks.emitPre("pre-cherry-pick",{mode:"continue",commit:null});if(R)return{stdout:"",stderr:R.message??"",exitCode:1}}let $=await Gl(s,r.env);return $.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"continue",commitHash:null,hadConflicts:!1}),$}if(n.skip)return jl(s,r.env);let a=n.commit;if(!a)return T("you must specify a commit to cherry-pick");if(t?.hooks){let $=await t.hooks.emitPre("pre-cherry-pick",{mode:"pick",commit:a});if($)return{stdout:"",stderr:$.message??"",exitCode:1}}let i=await ye(s,a);if(S(i))return i;let c=i.hash,f=i.commit,d=await Se(s);if(S(d))return d;let u=await U(s);if(n.noCommit){let $=u.entries.filter(R=>R.stage>0);if($.length>0){let q=$.slice(0,10).map(V=>`${V.path}: unmerged (${V.hash})`).join(`
266
+ `}async function dn(e,t,n,r){let o=await W(e),s=await ae(e,n);if(!r.skipStagedChangeCheck&&e.workTree){let h=new Map(He(o).map(g=>[g.path,g])),p=[];for(let[g,w]of h){let k=s.get(g);(!k||k.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 ri(e,o,s);let w=r.operationName??"merge",k=r.callerCommand??"merge";return{ok:!1,stdout:"",stderr:Nr(g,w,k,"local","staged"),exitCode:r.errorExitCode??2,failureKind:"staged"}}}if(e.workTree&&r.preflightOnewayCheck){let h=await Fn(e,[{label:"target",treeHash:t.resultTree}],o,{mergeFn:bs,updateWorktree:!1,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge"});if(!h.success){await ri(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(),k=h.errors.filter(E=>E.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||E.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(E=>E.path).sort(),b;return w.length>0&&k.length>0?b=Ic(w,k,p,g):k.length>0?b=Nr(k,p,g,"untracked","worktree"):b=Nr(w,p,g,"local","worktree"),{ok:!1,stdout:"",stderr:b,exitCode:r.errorExitCode??2,failureKind:"worktree"}}}if(e.workTree){let h=await Fn(e,[{label:"current",treeHash:n},{label:"target",treeHash:t.resultTree}],o,{mergeFn:ys,updateWorktree:!0,reset:!1,errorExitCode:r.errorExitCode??2,operationName:r.operationName??"merge",allowStagedChanges:!!r.preflightOnewayCheck});if(!h.success){await ri(e,o,s);let p=r.operationName??"merge",g=r.callerCommand??"merge",w=h.errors.filter(x=>x.error==="WOULD_OVERWRITE"||x.error==="NOT_UPTODATE_FILE").map(x=>x.path).sort(),k=h.errors.filter(x=>x.error==="WOULD_LOSE_UNTRACKED_OVERWRITTEN"||x.error==="WOULD_LOSE_UNTRACKED_REMOVED").map(x=>x.path).sort(),b=[];w.length>0&&b.push(Nr(w,p,g,"local","worktree")),k.length>0&&b.push(Nr(k,p,g,"untracked","worktree"));let E;return b.length>1?E=Ic(w,k,p,g):E=b[0]??"",{ok:!1,stdout:"",stderr:E,exitCode:r.errorExitCode??2,failureKind:"worktree"}}await Oe(e,h.worktreeOps)}let a=new Set,i=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){a.add(p.path);continue}}h.push(p)}i=h}let c=new Set(i.map(h=>h.path));for(let h of s.keys())a.has(h)||c.add(h);let f=o.entries.filter(h=>!c.has(h.path)),d=[...i,...f];d.sort((h,p)=>Ee(h.path,p.path)||h.stage-p.stage);let u={version:2,entries:d};await ie(e,u);let l=d.filter(h=>h.stage===0),m=await Ae(e,l);return{ok:!0,finalIndex:u,mergedTreeHash:m}}async function ri(e,t,n){if(e.workTree)for(let r of t.entries){if(r.stage!==0||n.has(r.path))continue;let o=H(e.workTree,r.path);await e.fs.exists(o)||await We(e,{path:r.path,hash:r.hash,mode:r.mode})}}re();Me();ue();Ie();Wt();function Tc(e,t){e.command("cherry-pick",{description:"Apply the changes introduced by some existing commits",args:[B.string().name("commit").describe("The commit to cherry-pick").optional()],options:{abort:A().describe("Abort the current cherry-pick operation"),continue:A().describe("Continue the cherry-pick after conflict resolution"),skip:A().describe("Skip the current cherry-pick and continue with the rest"),"record-origin":A().alias("x").describe('Append "(cherry picked from commit ...)" to the commit message'),mainline:Q.number().alias("m").describe("Select parent number for merge commit (1-based)"),noCommit:A().alias("n").describe("Apply changes without creating a commit")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let O=await t.hooks.emitPre("pre-cherry-pick",{mode:"abort",commit:null});if(O)return{stdout:"",stderr:O.message??"",exitCode:1}}let $=await Xu(s,r.env);return $.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"abort",commitHash:null,hadConflicts:!1}),$}if(n.continue){if(t?.hooks){let O=await t.hooks.emitPre("pre-cherry-pick",{mode:"continue",commit:null});if(O)return{stdout:"",stderr:O.message??"",exitCode:1}}let $=await Zu(s,r.env);return $.exitCode===0&&await t?.hooks?.emitPost("post-cherry-pick",{mode:"continue",commitHash:null,hadConflicts:!1}),$}if(n.skip)return Yu(s,r.env);let a=n.commit;if(!a)return T("you must specify a commit to cherry-pick");if(t?.hooks){let $=await t.hooks.emitPre("pre-cherry-pick",{mode:"pick",commit:a});if($)return{stdout:"",stderr:$.message??"",exitCode:1}}let i=await $e(s,a);if(S(i))return i;let c=i.hash,f=i.commit,d=await Ke(s);if(S(d))return d;let u=await W(s);if(n.noCommit){let $=u.entries.filter(O=>O.stage>0);if($.length>0){let q=$.slice(0,10).map(X=>`${X.path}: unmerged (${X.hash})`).join(`
226
267
  `),N=$.length>10?`
227
- ...`:"";return G(`${q}${N}
268
+ ...`:"";return L(`${q}${N}
228
269
  error: your index file is unmerged.
229
270
  fatal: cherry-pick failed
230
- `,128)}}else{let $=_t(u,"Cherry-picking",`fatal: cherry-pick failed
231
- `);if($)return $}let l=await j(s,d),h=!!n["record-origin"]?Nl(f.message,c):f.message;if(s.workTree&&!n.noCommit){let $=await se(s,l.tree);if(Dn(u,$))return G(`error: your local changes would be overwritten by cherry-pick.
271
+ `,128)}}else{let $=sn(u,"Cherry-picking",`fatal: cherry-pick failed
272
+ `);if($)return $}let l=await D(s,d),h=!!n["record-origin"]?Ju(f.message,c):f.message;if(s.workTree&&!n.noCommit){let $=await ae(s,l.tree);if(nr(u,$))return L(`error: your local changes would be overwritten by cherry-pick.
232
273
  hint: commit your changes or stash them to proceed.
233
274
  fatal: cherry-pick failed
234
- `,128)}if(f.parents.length>1){if(!n.mainline)return G(`error: commit ${c} is a merge but no -m option was given.
275
+ `,128)}if(f.parents.length>1){if(!n.mainline)return L(`error: commit ${c} is a merge but no -m option was given.
235
276
  fatal: cherry-pick failed
236
- `,128);let $=n.mainline-1;if($<0||$>=f.parents.length)return G(`error: commit ${c} does not have parent ${n.mainline}
277
+ `,128);let $=n.mainline-1;if($<0||$>=f.parents.length)return L(`error: commit ${c} does not have parent ${n.mainline}
237
278
  fatal: cherry-pick failed
238
- `,128)}else if(n.mainline)return G(`error: mainline was specified but commit is not a merge.
279
+ `,128)}else if(n.mainline)return L(`error: mainline was specified but commit is not a merge.
239
280
  fatal: cherry-pick failed
240
- `,128);let p;if(f.parents.length===0)p=await ke(s,[]);else{let $=f.parents.length>1?n.mainline-1:0,R=f.parents[$];if(!R)throw new Error("unreachable: parent must exist");p=(await j(s,R)).tree}let g=K(c),w=ue(f.message),x={a:"HEAD",b:w?`${g} (${w})`:g},b=await yt(s,p,l.tree,f.tree,x);if(b.conflicts.length===0&&b.resultTree===l.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await Y(s,"CHERRY_PICK_HEAD",c),await Y(s,"ORIG_HEAD",d),await Ue(s,"MERGE_MSG",h);let $=b.messages.length>0?`${b.messages.join(`
281
+ `,128);let p;if(f.parents.length===0)p=await Ae(s,[]);else{let $=f.parents.length>1?n.mainline-1:0,O=f.parents[$];if(!O)throw new Error("unreachable: parent must exist");p=(await D(s,O)).tree}let g=K(c),w=se(f.message),k={a:"HEAD",b:w?`${g} (${w})`:g},b=await St(s,p,l.tree,f.tree,k);if(b.conflicts.length===0&&b.resultTree===l.tree){if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};await z(s,"CHERRY_PICK_HEAD",c),await z(s,"ORIG_HEAD",d),await Pe(s,"MERGE_MSG",h);let $=b.messages.length>0?`${b.messages.join(`
241
282
  `)}
242
- `:"",R=await Be(s,{fromCommit:!0});return{stdout:`${$}${R}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
283
+ `:"",O=await tt(s,{fromCommit:!0});return{stdout:`${$}${O}`,stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
243
284
  If you wish to commit it anyway, use:
244
285
 
245
286
  git commit --allow-empty
246
287
 
247
288
  Otherwise, please use 'git cherry-pick --skip'
248
- `,exitCode:1}}let E=await qt(s,b,l.tree,{labels:x,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(b.conflicts.length>0){let $=b.messages.join(`
289
+ `,exitCode:1}}let E=await dn(s,b,l.tree,{labels:k,errorExitCode:128,operationName:"merge",callerCommand:"cherry-pick",skipStagedChangeCheck:!0,preflightOnewayCheck:!!n.noCommit});if(!E.ok)return E;if(b.conflicts.length>0){let $=b.messages.join(`
249
290
  `);return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:null,hadConflicts:!0}),n.noCommit?{stdout:$?`${$}
250
- `:"",stderr:`error: could not apply ${g}... ${ue(f.message)}
291
+ `:"",stderr:`error: could not apply ${g}... ${se(f.message)}
251
292
  hint: after resolving the conflicts, mark the corrected paths
252
293
  hint: with 'git add <paths>' or 'git rm <paths>'
253
294
  hint: Disable this message with "git config set advice.mergeConflict false"
254
- `,exitCode:1}:(await Y(s,"CHERRY_PICK_HEAD",c),await Y(s,"ORIG_HEAD",d),await Ue(s,"MERGE_MSG",h),{stdout:$?`${$}
255
- `:"",stderr:`error: could not apply ${g}... ${ue(f.message)}
295
+ `,exitCode:1}:(await z(s,"CHERRY_PICK_HEAD",c),await z(s,"ORIG_HEAD",d),await Pe(s,"MERGE_MSG",h),{stdout:$?`${$}
296
+ `:"",stderr:`error: could not apply ${g}... ${se(f.message)}
256
297
  hint: After resolving the conflicts, mark them with
257
298
  hint: "git add/rm <pathspec>", then run
258
299
  hint: "git cherry-pick --continue".
@@ -260,114 +301,114 @@ hint: You can instead skip this commit with "git cherry-pick --skip".
260
301
  hint: To abort and get back to the state before "git cherry-pick",
261
302
  hint: run "git cherry-pick --abort".
262
303
  hint: Disable this message with "git config set advice.mergeConflict false"
263
- `,exitCode:1})}let k=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let P=await Le(s,r.env);if(S(P))return P;let C=await Je(s,k,[d],f.author,P,h);await kt(s),await wt(s);let O=await J(s),y=h.split(`
264
- `)[0]??"",I=O?.type==="symbolic"?O.target:"HEAD";await ee(s,r.env,I,d,C,`cherry-pick: ${y}`,O?.type==="symbolic");let A=O?.type==="symbolic"?de(O.target):"detached HEAD",L=l.tree,D=await St(s,L,k,f.author,P,!0),z=mt(A,C,h),M=b.messages.length>0?`${b.messages.join(`
304
+ `,exitCode:1})}let x=E.mergedTreeHash;if(n.noCommit)return{stdout:"",stderr:"",exitCode:0};let P=await Ye(s,r.env);if(S(P))return P;let C=await dt(s,x,[d],f.author,P,h);await jt(s),await Tt(s);let R=await Z(s),y=h.split(`
305
+ `)[0]??"",I=R?.type==="symbolic"?R.target:"HEAD";await ne(s,r.env,I,d,C,`cherry-pick: ${y}`,R?.type==="symbolic");let v=R?.type==="symbolic"?ge(R.target):"detached HEAD",G=l.tree,M=await Yt(s,G,x,f.author,P,!0),V=Ot(v,C,h),j=b.messages.length>0?`${b.messages.join(`
265
306
  `)}
266
- `:"";return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${M}${z}
267
- ${D}`,stderr:"",exitCode:0}}})}async function jl(e,t){if(!await F(e,"CHERRY_PICK_HEAD"))return G(`error: no cherry-pick in progress
307
+ `:"";return await t?.hooks?.emitPost("post-cherry-pick",{mode:"pick",commitHash:C,hadConflicts:!1}),{stdout:`${j}${V}
308
+ ${M}`,stderr:"",exitCode:0}}})}async function Yu(e,t){if(!await F(e,"CHERRY_PICK_HEAD"))return L(`error: no cherry-pick in progress
268
309
  fatal: cherry-pick failed
269
- `,128);let r=await X(e);if(!r)return T("unable to resolve HEAD");let o=await j(e,r),s=await U(e),a=await Fr(e,o.tree,s,r);if(!a.success){let i=a.errorOutput;return{...i,stderr:i.stderr+`error: failed to skip the commit
310
+ `,128);let r=await Y(e);if(!r)return T("unable to resolve HEAD");let o=await D(e,r),s=await W(e),a=await ks(e,o.tree,s,r);if(!a.success){let i=a.errorOutput;return{...i,stderr:i.stderr+`error: failed to skip the commit
270
311
  fatal: cherry-pick failed
271
- `}}return await re(e,{version:2,entries:a.newEntries}),await be(e,a.worktreeOps),await ee(e,t,"HEAD",r,r,`reset: moving to ${r}`),await kt(e),{stdout:"",stderr:"",exitCode:0}}async function Ll(e,t){return await F(e,"CHERRY_PICK_HEAD")?tn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
312
+ `}}return await ie(e,{version:2,entries:a.newEntries}),await Oe(e,a.worktreeOps),await ne(e,t,"HEAD",r,r,`reset: moving to ${r}`),await jt(e),{stdout:"",stderr:"",exitCode:0}}async function Xu(e,t){return await F(e,"CHERRY_PICK_HEAD")?kn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
272
313
  fatal: cherry-pick failed
273
- `,128),operationName:"cherry-pick",clearState:kt,origHeadAsTargetRev:!0}):await F(e,"REVERT_HEAD")?tn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
314
+ `,128),operationName:"cherry-pick",clearState:jt,origHeadAsTargetRev:!0}):await F(e,"REVERT_HEAD")?kn(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
274
315
  fatal: cherry-pick failed
275
- `,128),operationName:"cherry-pick",clearState:wt,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
316
+ `,128),operationName:"cherry-pick",clearState:Tt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
276
317
  fatal: cherry-pick failed
277
- `,128)}async function Gl(e,t){let n=await F(e,"CHERRY_PICK_HEAD");if(!n)return G(`error: no cherry-pick or revert in progress
318
+ `,128)}async function Zu(e,t){let n=await F(e,"CHERRY_PICK_HEAD");if(!n)return L(`error: no cherry-pick or revert in progress
278
319
  fatal: cherry-pick failed
279
- `,128);let r=await U(e),o=_t(r,"Committing");if(o)return o;let s=await j(e,n),a=await qe(e,"MERGE_MSG");a||(a=s.message);let i=xe(r),c=await ke(e,i),f=await Se(e);if(S(f))return f;let u=(await j(e,f)).tree,l=await Le(e,t);if(S(l))return l;let m=ht(a),h=await Je(e,c,[f],s.author,l,m);await kt(e),await wt(e);let p=await J(e),g=ue(m),w=p?.type==="symbolic"?p.target:"HEAD";await ee(e,t,w,f,h,`commit (cherry-pick): ${g}`,p?.type==="symbolic");let x=p?.type==="symbolic"?de(p.target):"detached HEAD",b=await St(e,u,c,s.author,l,!0);return{stdout:`${mt(x,h,a)}
280
- ${b}`,stderr:"",exitCode:0}}function Nl(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
320
+ `,128);let r=await W(e),o=sn(r,"Committing");if(o)return o;let s=await D(e,n),a=await Ce(e,"MERGE_MSG");a||(a=s.message);let i=He(r),c=await Ae(e,i),f=await Ke(e);if(S(f))return f;let u=(await D(e,f)).tree,l=await Ye(e,t);if(S(l))return l;let m=$t(a),h=await dt(e,c,[f],s.author,l,m);await jt(e),await Tt(e);let p=await Z(e),g=se(m),w=p?.type==="symbolic"?p.target:"HEAD";await ne(e,t,w,f,h,`commit (cherry-pick): ${g}`,p?.type==="symbolic");let k=p?.type==="symbolic"?ge(p.target):"detached HEAD",b=await Yt(e,u,c,s.author,l,!0);return{stdout:`${Ot(k,h,a)}
321
+ ${b}`,stderr:"",exitCode:0}}function Ju(e,t){let n=`(cherry picked from commit ${t})`,r=e.replace(/\n+$/,""),o=r.lastIndexOf(`
281
322
  `),s=o===-1?r:r.slice(o+1);return/^\(cherry picked from commit [0-9a-f]+\)$/.test(s)?`${r}
282
323
  ${n}
283
324
  `:`${r}
284
325
 
285
326
  ${n}
286
- `}function ja(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[W.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:v().alias("f").describe("Required to actually remove files"),"dry-run":v().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:v().alias("d").describe("Also remove untracked directories"),removeIgnored:v().alias("x").describe("Remove ignored files as well"),onlyIgnored:v().alias("X").describe("Remove only ignored files"),exclude:te.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=Fe(s);if(a)return a;let i=s.workTree,c=n["dry-run"],f=n.force,d=n.directories,u=n.removeIgnored,l=n.onlyIgnored;if(t?.hooks){let C=await t.hooks.emitPre("pre-clean",{dryRun:c,force:f,removeDirs:d,removeIgnored:u,onlyIgnored:l});if(C)return{stdout:"",stderr:C.message??"",exitCode:1}}if(!f&&!c&&await Et(s,"clean.requireForce")!=="false")return T("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let m=await U(s),h=new Set(m.entries.map(C=>C.path)),p=Ze(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(C=>Oe(C,p)):null,x=n.exclude?[n.exclude]:[],b=await La(s,i,"",{trackedPaths:h,removeDirs:d,removeIgnored:u,onlyIgnored:l,extraExcludes:x}),E;w?E=b.filter(C=>me(w,C.path)):E=b,E.sort((C,O)=>C.path<O.path?-1:C.path>O.path?1:0);let k=[];if(c)for(let C of E){let O=C.isDir?`Would remove ${C.path}/`:`Would remove ${C.path}`;k.push(O)}else for(let C of E){let O=H(i,C.path);C.isDir?(await r.fs.rm(O,{recursive:!0}),k.push(`Removing ${C.path}/`)):(await r.fs.rm(O),k.push(`Removing ${C.path}`))}let P=k.length>0?`${k.join(`
287
- `)}
288
- `:"";return await t?.hooks?.emitPost("post-clean",{removed:E.map(C=>C.path),dryRun:c}),{stdout:P,stderr:"",exitCode:0}}})}async function La(e,t,n,r){let o=[],s=!r.removeIgnored,a=null;if(s||r.onlyIgnored){a=r._ignore??await vn(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);a=gn(a,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
289
- `),d=sr(f,"","<cli>");a={...a,dirPatterns:[d,...a.dirPatterns]}}}let i=await e.fs.readdir(t);for(let c of i){if(n===""&&c===".git")continue;let f=H(t,c),d=n?`${n}/${c}`:c,u=await e.fs.stat(f);if(u.isDirectory){let l=a&&Tt(a,d,!0)==="ignored",m=_l(r.trackedPaths,d),h=()=>La(e,f,d,{...r,_ignore:a??void 0});if(r.onlyIgnored){if(l&&!m){r.removeDirs&&o.push({path:d,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:d,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(l&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:d,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:d,isDir:!0})}}}else if(u.isFile){if(r.trackedPaths.has(d))continue;let l=a&&Tt(a,d,!1)==="ignored";r.onlyIgnored?l&&o.push({path:d,isDir:!1}):l&&s||o.push({path:d,isDir:!1})}}return o}function _l(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}async function us(e,t,n){return Ga(e,t,n,!1)}async function ms(e,t,n){return Ga(e,t,n,!0)}async function Ga(e,t,n,r){let o=new Set;for(let i of n)await ur(e,i,o);let s=[],a=new Set;for(let i of t)await mr(e,i,o,a,s,r);return s}async function ur(e,t,n){if(n.has(t)||(n.add(t),!await Vt(e,t)))return;let r=await fe(e,t);switch(r.type){case"commit":{let o=Rt(r.content);await ur(e,o.tree,n);for(let s of o.parents)await ur(e,s,n);break}case"tree":{let o=Qt(r.content);for(let s of o.entries)await ur(e,s.hash,n);break}case"tag":{let o=jt(r.content);await ur(e,o.object,n);break}case"blob":break}}async function mr(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let a=await fe(e,t);switch(o.push(s?{hash:t,type:a.type,content:a.content}:{hash:t,type:a.type}),a.type){case"commit":{let i=Rt(a.content);await mr(e,i.tree,n,r,o,s);for(let c of i.parents)await mr(e,c,n,r,o,s);break}case"tree":{let i=Qt(a.content);for(let c of i.entries)await mr(e,c.hash,n,r,o,s);break}case"tag":{let i=jt(a.content);await mr(e,i.object,n,r,o,s);break}case"blob":break}}var Fl=new TextEncoder,hs=new TextDecoder,Na=65520,Ul=new Uint8Array([48,48,48,48]);function Pn(e){let t=typeof e=="string"?Fl.encode(e):e,n=4+t.byteLength;if(n>Na)throw new Error(`pkt-line too long: ${n} bytes (max ${Na})`);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 xo(){return Ul.slice()}function ps(...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 Fn(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=hs.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function gs(e){if(e.type==="flush")return"";let t=hs.decode(e.data);return t.endsWith(`
290
- `)?t.slice(0,-1):t}var Bl=1,Wl=2,ql=3;function ko(e){let t=[],n=[],r=[],o=0;for(let i of e){if(i.type==="flush"||i.data.byteLength===0)continue;let c=i.data[0];if(c===void 0)continue;let f=i.data.subarray(1);switch(c){case Bl:t.push(f),o+=f.byteLength;break;case Wl:n.push(hs.decode(f));break;case ql:r.push(hs.decode(f));break;default:break}}let s=new Uint8Array(o),a=0;for(let i of t)s.set(i,a),a+=i.byteLength;return{packData:s,progress:n,errors:r}}function Co(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function Po(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...Co(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let a=s.headers.get("content-type")??"",i=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!a.startsWith(i)){let d=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(d))throw new Error(`Server does not support smart HTTP (Content-Type: ${a})`)}let f=Fn(c);return Kl(f,t)}function Kl(e,t){let n=0,r=e[n];r?.type==="data"&&gs(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],a=new Map;for(;n<e.length;n++){let i=e[n];if(!i||i.type==="flush")break;let c=i.data,f=c.indexOf(0),d;if(f!==-1){d=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&&a.set(g.slice(0,w),g.slice(w+1))}}else d=new TextDecoder().decode(c).replace(/\n$/,"");let u=d.indexOf(" ");if(u===-1)continue;let l=d.slice(0,u),m=d.slice(u+1);if(!(l===Z&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=l);continue}o.push({name:m,hash:l})}}return{refs:o,capabilities:s,symrefs:a}}var zl=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","thin-pack","include-tag"];async function _a(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=Ua(r,zl),i=[];i.push(Pn(`want ${t[0]} ${a.join(" ")}
291
- `));for(let l=1;l<t.length;l++)i.push(Pn(`want ${t[l]}
292
- `));i.push(xo());for(let l of n)i.push(Pn(`have ${l}
293
- `));i.push(Pn(`done
294
- `));let c=ps(...i),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...Co(o),"User-Agent":"just-git/1.0"},body:c});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${f}`);let u=new Uint8Array(await d.arrayBuffer());return Vl(u,a.includes("side-band-64k"))}function Vl(e,t){let n=Fn(e),r=[],o=0;for(let f=0;f<n.length;f++){let d=n[f];if(!d||d.type==="flush"){o=f+1;continue}if(d.type!=="data")continue;let u=gs(d);if(u.startsWith("ACK ")||u==="NAK")r.push(u),o=f+1;else{o=f;break}}let s=n.slice(o);if(t){let{packData:f,progress:d,errors:u}=ko(s);if(u.length>0)throw new Error(`Remote error: ${u.join("")}`);return{packData:f,acks:r,progress:d}}let a=0;for(let f of s)f.type==="data"&&(a+=f.data.byteLength);let i=new Uint8Array(a),c=0;for(let f of s)f.type==="data"&&(i.set(f.data,c),c+=f.data.byteLength);return{packData:i,acks:r,progress:[]}}var Yl=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Fa(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let a=Ua(r,Yl),i=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");i.push(Pn(`${c.oldHash} ${c.newHash} ${c.refName}\0${a.join(" ")}
295
- `));for(let h of f)i.push(Pn(`${h.oldHash} ${h.newHash} ${h.refName}
296
- `));i.push(xo());let d;if(n&&n.byteLength>0){let h=ps(...i);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=ps(...i);let u=e.replace(/\/+$/,""),l=await s(`${u}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...Co(o),"User-Agent":"just-git/1.0"},body:d});if(!l.ok)throw new Error(`HTTP ${l.status} pushing to ${u}`);let m=new Uint8Array(await l.arrayBuffer());return a.includes("report-status")?Xl(m,a.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function Xl(e,t){let n,r=[];if(t){let i=Fn(e),{packData:c,progress:f,errors:d}=ko(i);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=Fn(c)}else n=Fn(e);let o=!1,s,a=[];for(let i of n){if(i.type==="flush")break;let c=gs(i);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))a.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?a.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):a.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:a,progress:r}}function Ua(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 hr=class{constructor(t,n){this.local=t;this.remote=n}headTarget;async advertiseRefs(){let t=await le(this.remote),n=[];for(let s of t)n.push({name:s.name,hash:s.hash});let r=await F(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await J(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n){let r=await this.advertiseRefs();if(t.length===0)return{remoteRefs:r,objectCount:0};let o=await us(this.remote,t,n);if(o.length===0)return{remoteRefs:r,objectCount:0};let s=[];for(let c of o){let f=await fe(this.remote,c.hash);s.push({type:f.type,content:f.content})}let a=await Hr(s),i=await Sr(this.local,a);return{remoteRefs:r,objectCount:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==Z&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await us(this.local,n,r);if(s.length>0){let a=[];for(let c of s){let f=await fe(this.local,c.hash);a.push({type:f.type,content:f.content})}let i=await Hr(a);await Sr(this.remote,i)}}let o=[];for(let s of t)try{if(s.newHash===Z){await ae(this.remote,s.name),o.push({...s,ok:!0});continue}let a=await F(this.remote,s.name);if(a&&!s.ok&&!await Ft(this.remote,a,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}await Y(this.remote,s.name,s.newHash),o.push({...s,ok:!0})}catch(a){o.push({...s,ok:!1,error:a instanceof Error?a.message:String(a)})}return{updates:o}}},pr=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 Po(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 Po(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n){let{caps:r,refs:o}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:o,objectCount:0};let s=await _a(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let a=await Sr(this.local,s.packData);return{remoteRefs:o,objectCount:a}}async push(t){for(let d of t)if(d.oldHash&&d.oldHash!==Z&&d.newHash!==Z&&!d.ok&&!await Ft(this.local,d.oldHash,d.newHash))return{updates:t.map(l=>l===d?{...l,ok:!1,error:"non-fast-forward"}:{...l,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(d=>({oldHash:d.oldHash??Z,newHash:d.newHash,refName:d.name})),o=[],s=[],a=!1;for(let d of t)d.newHash!==Z&&(o.push(d.newHash),a=!0),d.oldHash&&d.oldHash!==Z&&s.push(d.oldHash);let i=null;if(a){let d=await us(this.local,o,s),u=[];for(let l of d){let m=await fe(this.local,l.hash);u.push({type:m.type,content:m.content})}i=await Hr(u)}let c=await Fa(this.url,r,i,n,this.auth,this.fetchFn);return{updates:t.map(d=>{let u=c.refResults.find(h=>h.name===d.name),l=u?.ok??c.unpackOk,m=u?.error??(!l&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...d,ok:l,error:m}})}}};async function Zl(e,t){let r=(await ce(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function Oo(e){return e.startsWith("http://")||e.startsWith("https://")}function Ba(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(Oo(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 Jl(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 Wa(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return Jl(n)}async function qa(e,t,n,r){if(Oo(t)){let o=Ba(t,e.networkPolicy);if(o)throw new Error(o);let s=await Wa(e,t,n);return new pr(e,t,s,e.fetchFn)}if(!r)throw new Error(`'${t}' does not appear to be a git repository`);return new hr(e,r)}async function Un(e,t,n){let r=await Zl(e,t);if(!r)return null;if(Oo(r.url)){let s=Ba(r.url,e.networkPolicy);if(s)throw new Error(s);let a=n?await Wa(e,r.url,n):void 0;return{transport:new pr(e,r.url,a,e.fetchFn),config:r}}let o=await Hn(e.fs,r.url);return o?{transport:new hr(e,o),config:r}:null}function Ka(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[W.string().name("repository").describe("Repository to clone"),W.string().name("directory").describe("Target directory").optional()],options:{bare:v().describe("Create a bare clone"),branch:te.string().alias("b").describe("Checkout this branch instead of HEAD")},handler:async(n,r)=>{let o=n.repository;if(!o)return T("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),a=s?o:ft(r.cwd,o),i=n.branch,c=n.directory;if(!c){let y=s?o.split("/").pop()??o:zn(a);y.endsWith(".git")&&(y=y.slice(0,-4)),c=y}let f=ft(r.cwd,c);if(t?.hooks){let y=await t.hooks.emitPre("pre-clone",{repository:o,targetPath:f,bare:n.bare,branch:i??null});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return T(`destination path '${c}' already exists and is not an empty directory.`)}catch{return T(`destination path '${c}' already exists and is not an empty directory.`)}let d=null;if(!s&&(d=await Hn(r.fs,a),!d))return T(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await Dr(r.fs,f,{bare:n.bare}),l=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy}:u,m=await ce(l);m['remote "origin"']={url:a,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Ge(l,m);let h;try{h=await qa(l,a,r.env,d??void 0)}catch(y){let I=y instanceof Error?y.message:"";return I.startsWith("network")?T(I):T(`repository '${o}' does not exist`)}let p=await h.advertiseRefs();if(p.length===0)return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${c}'...
327
+ `}ee();Ze();ws();ye();fe();function Hc(e,t){e.command("clean",{description:"Remove untracked files from the working tree",args:[B.string().name("pathspec").describe("Pathspec to limit which files are removed").optional().variadic()],options:{force:A().alias("f").describe("Required to actually remove files"),"dry-run":A().alias("n").describe("Don't actually remove anything, just show what would be done"),directories:A().alias("d").describe("Also remove untracked directories"),removeIgnored:A().alias("x").describe("Remove ignored files as well"),onlyIgnored:A().alias("X").describe("Remove only ignored files"),exclude:Q.string().alias("e").describe("Additional exclude pattern")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=qe(s);if(a)return a;let i=s.workTree,c=n["dry-run"],f=n.force,d=n.directories,u=n.removeIgnored,l=n.onlyIgnored;if(t?.hooks){let C=await t.hooks.emitPre("pre-clean",{dryRun:c,force:f,removeDirs:d,removeIgnored:u,onlyIgnored:l});if(C)return{stdout:"",stderr:C.message??"",exitCode:1}}if(!f&&!c&&await Dt(s,"clean.requireForce")!=="false")return T("clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean");let m=await W(s),h=new Set(m.entries.map(C=>C.path)),p=ft(s,r.cwd),g=n.pathspec,w=g.length>0?g.map(C=>je(C,p)):null,k=n.exclude?[n.exclude]:[],b=await Ac(s,i,"",{trackedPaths:h,removeDirs:d,removeIgnored:u,onlyIgnored:l,extraExcludes:k}),E;w?E=b.filter(C=>we(w,C.path)):E=b,E.sort((C,R)=>C.path<R.path?-1:C.path>R.path?1:0);let x=[];if(c)for(let C of E){let R=C.isDir?`Would remove ${C.path}/`:`Would remove ${C.path}`;x.push(R)}else for(let C of E){let R=H(i,C.path);C.isDir?(await r.fs.rm(R,{recursive:!0}),x.push(`Removing ${C.path}/`)):(await r.fs.rm(R),x.push(`Removing ${C.path}`))}let P=x.length>0?`${x.join(`
328
+ `)}
329
+ `:"";return await t?.hooks?.emitPost("post-clean",{removed:E.map(C=>C.path),dryRun:c}),{stdout:P,stderr:"",exitCode:0}}})}async function Ac(e,t,n,r){let o=[],s=!r.removeIgnored,a=null;if(s||r.onlyIgnored){a=r._ignore??await tr(e);let c=H(t,".gitignore");try{let f=await e.fs.readFile(c);a=Nn(a,f,n,c)}catch{}if(!r._ignore&&r.extraExcludes.length>0){let f=r.extraExcludes.join(`
330
+ `),d=Tr(f,"","<cli>");a={...a,dirPatterns:[d,...a.dirPatterns]}}}let i=await e.fs.readdir(t);for(let c of i){if(n===""&&c===".git")continue;let f=H(t,c),d=n?`${n}/${c}`:c,u=await e.fs.stat(f);if(u.isDirectory){let l=a&&Bt(a,d,!0)==="ignored",m=Qu(r.trackedPaths,d),h=()=>Ac(e,f,d,{...r,_ignore:a??void 0});if(r.onlyIgnored){if(l&&!m){r.removeDirs&&o.push({path:d,isDir:!0});continue}let p=await h();!m&&r.removeDirs?p.length>0&&o.push({path:d,isDir:!0}):o.push(...p)}else if(m){let p=await h();o.push(...p)}else if(!(l&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:d,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:d,isDir:!0})}}}else if(u.isFile){if(r.trackedPaths.has(d))continue;let l=a&&Bt(a,d,!1)==="ignored";r.onlyIgnored?l&&o.push({path:d,isDir:!1}):l&&s||o.push({path:d,isDir:!1})}}return o}function Qu(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}ee();Ze();ln();ye();re();fe();Me();ue();jn();Ze();jn();at();re();yr();ue();re();Jt();Cr();ms();async function Ks(e,t,n){return vc(e,t,n,!1)}async function zs(e,t,n){return vc(e,t,n,!0)}async function vc(e,t,n,r){let o=new Set;for(let i of n)await Fr(e,i,o);let s=[],a=new Set;for(let i of t)await Ur(e,i,o,a,s,r);return s}async function Fr(e,t,n){if(n.has(t)||(n.add(t),!await hn(e,t)))return;let r=await he(e,t);switch(r.type){case"commit":{let o=Ft(r.content);await Fr(e,o.tree,n);for(let s of o.parents)await Fr(e,s,n);break}case"tree":{let o=yn(r.content);for(let s of o.entries)await Fr(e,s.hash,n);break}case"tag":{let o=Qt(r.content);await Fr(e,o.object,n);break}case"blob":break}}async function Ur(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let a=await he(e,t);switch(o.push(s?{hash:t,type:a.type,content:a.content}:{hash:t,type:a.type}),a.type){case"commit":{let i=Ft(a.content);await Ur(e,i.tree,n,r,o,s);for(let c of i.parents)await Ur(e,c,n,r,o,s);break}case"tree":{let i=yn(a.content);for(let c of i.entries)await Ur(e,c.hash,n,r,o,s);break}case"tag":{let i=Qt(a.content);await Ur(e,i.object,n,r,o,s);break}case"blob":break}}var em=new TextEncoder,Vs=new TextDecoder,Sc=65520,tm=new Uint8Array([48,48,48,48]);function zn(e){let t=typeof e=="string"?em.encode(e):e,n=4+t.byteLength;if(n>Sc)throw new Error(`pkt-line too long: ${n} bytes (max ${Sc})`);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 oi(){return tm.slice()}function Ys(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function dr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=Vs.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Xs(e){if(e.type==="flush")return"";let t=Vs.decode(e.data);return t.endsWith(`
331
+ `)?t.slice(0,-1):t}var nm=1,rm=2,sm=3;function ii(e){let t=[],n=[],r=[],o=0;for(let i of e){if(i.type==="flush"||i.data.byteLength===0)continue;let c=i.data[0];if(c===void 0)continue;let f=i.data.subarray(1);switch(c){case nm:t.push(f),o+=f.byteLength;break;case rm:n.push(Vs.decode(f));break;case sm:r.push(Vs.decode(f));break;default:break}}let s=new Uint8Array(o),a=0;for(let i of t)s.set(i,a),a+=i.byteLength;return{packData:s,progress:n,errors:r}}at();function ai(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ci(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...ai(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let a=s.headers.get("content-type")??"",i=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!a.startsWith(i)){let d=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(d))throw new Error(`Server does not support smart HTTP (Content-Type: ${a})`)}let f=dr(c);return om(f,t)}function om(e,t){let n=0,r=e[n];r?.type==="data"&&Xs(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],a=new Map;for(;n<e.length;n++){let i=e[n];if(!i||i.type==="flush")break;let c=i.data,f=c.indexOf(0),d;if(f!==-1){d=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&&a.set(g.slice(0,w),g.slice(w+1))}}else d=new TextDecoder().decode(c).replace(/\n$/,"");let u=d.indexOf(" ");if(u===-1)continue;let l=d.slice(0,u),m=d.slice(u+1);if(!(l===J&&m==="capabilities^{}")){if(m.endsWith("^{}")){let h=m.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=l);continue}o.push({name:m,hash:l})}}return{refs:o,capabilities:s,symrefs:a}}var im=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","thin-pack","include-tag"];async function Dc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=jc(r,im),i=[];i.push(zn(`want ${t[0]} ${a.join(" ")}
332
+ `));for(let l=1;l<t.length;l++)i.push(zn(`want ${t[l]}
333
+ `));i.push(oi());for(let l of n)i.push(zn(`have ${l}
334
+ `));i.push(zn(`done
335
+ `));let c=Ys(...i),f=e.replace(/\/+$/,""),d=await s(`${f}/git-upload-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-upload-pack-request",...ai(o),"User-Agent":"just-git/1.0"},body:c});if(!d.ok)throw new Error(`HTTP ${d.status} fetching pack from ${f}`);let u=new Uint8Array(await d.arrayBuffer());return am(u,a.includes("side-band-64k"))}function am(e,t){let n=dr(e),r=[],o=0;for(let f=0;f<n.length;f++){let d=n[f];if(!d||d.type==="flush"){o=f+1;continue}if(d.type!=="data")continue;let u=Xs(d);if(u.startsWith("ACK ")||u==="NAK")r.push(u),o=f+1;else{o=f;break}}let s=n.slice(o);if(t){let{packData:f,progress:d,errors:u}=ii(s);if(u.length>0)throw new Error(`Remote error: ${u.join("")}`);return{packData:f,acks:r,progress:d}}let a=0;for(let f of s)f.type==="data"&&(a+=f.data.byteLength);let i=new Uint8Array(a),c=0;for(let f of s)f.type==="data"&&(i.set(f.data,c),c+=f.data.byteLength);return{packData:i,acks:r,progress:[]}}var cm=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Mc(e,t,n,r,o,s=globalThis.fetch){if(t.length===0)throw new Error("pushPack requires at least one command");let a=jc(r,cm),i=[],[c,...f]=t;if(!c)throw new Error("pushPack requires at least one command");i.push(zn(`${c.oldHash} ${c.newHash} ${c.refName}\0${a.join(" ")}
336
+ `));for(let h of f)i.push(zn(`${h.oldHash} ${h.newHash} ${h.refName}
337
+ `));i.push(oi());let d;if(n&&n.byteLength>0){let h=Ys(...i);d=new Uint8Array(h.byteLength+n.byteLength),d.set(h,0),d.set(n,h.byteLength)}else d=Ys(...i);let u=e.replace(/\/+$/,""),l=await s(`${u}/git-receive-pack`,{method:"POST",headers:{"Content-Type":"application/x-git-receive-pack-request",...ai(o),"User-Agent":"just-git/1.0"},body:d});if(!l.ok)throw new Error(`HTTP ${l.status} pushing to ${u}`);let m=new Uint8Array(await l.arrayBuffer());return a.includes("report-status")?fm(m,a.includes("side-band-64k")):{unpackOk:!0,refResults:[],progress:[]}}function fm(e,t){let n,r=[];if(t){let i=dr(e),{packData:c,progress:f,errors:d}=ii(i);if(d.length>0)throw new Error(`Remote error: ${d.join("")}`);r=f,n=dr(c)}else n=dr(e);let o=!1,s,a=[];for(let i of n){if(i.type==="flush")break;let c=Xs(i);if(c.startsWith("unpack "))o=c==="unpack ok",o||(s=c.slice(7));else if(c.startsWith("ok "))a.push({name:c.slice(3),ok:!0});else if(c.startsWith("ng ")){let f=c.slice(3),d=f.indexOf(" ");d!==-1?a.push({name:f.slice(0,d),ok:!1,error:f.slice(d+1)}):a.push({name:f,ok:!1})}}return{unpackOk:o,unpackError:s,refResults:a,progress:r}}function jc(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 Br=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 F(this.remote,"HEAD");r&&n.push({name:"HEAD",hash:r});let o=await Z(this.remote);return o?.type==="symbolic"&&(this.headTarget=o.target),n}async fetch(t,n){let r=await this.advertiseRefs();if(t.length===0)return{remoteRefs:r,objectCount:0};let o=await Ks(this.remote,t,n);if(o.length===0)return{remoteRefs:r,objectCount:0};let s=[];for(let c of o){let f=await he(this.remote,c.hash);s.push({type:f.type,content:f.content})}let a=await is(s),i=await ds(this.local,a);return{remoteRefs:r,objectCount:i}}async push(t){let n=[],r=[];for(let s of t)s.newHash!==J&&n.push(s.newHash),s.oldHash&&r.push(s.oldHash);if(n.length>0){let s=await Ks(this.local,n,r);if(s.length>0){let a=[];for(let c of s){let f=await he(this.local,c.hash);a.push({type:f.type,content:f.content})}let i=await is(a);await ds(this.remote,i)}}let o=[];for(let s of t)try{if(s.newHash===J){await de(this.remote,s.name),o.push({...s,ok:!0});continue}let a=await F(this.remote,s.name);if(a&&!s.ok&&!await cn(this.remote,a,s.newHash)){o.push({...s,ok:!1,error:`non-fast-forward update rejected for ${s.name}`});continue}await z(this.remote,s.name,s.newHash),o.push({...s,ok:!0})}catch(a){o.push({...s,ok:!1,error:a instanceof Error?a.message:String(a)})}return{updates:o}}},Wr=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 ci(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 ci(this.url,"git-receive-pack",this.auth,this.fetchFn);this.cachedPushCaps=t.capabilities}return this.cachedPushCaps}async fetch(t,n){let{caps:r,refs:o}=await this.ensureFetchDiscovery();if(t.length===0)return{remoteRefs:o,objectCount:0};let s=await Dc(this.url,t,n,r,this.auth,this.fetchFn);if(s.packData.byteLength===0)return{remoteRefs:o,objectCount:0};let a=await ds(this.local,s.packData);return{remoteRefs:o,objectCount:a}}async push(t){for(let d of t)if(d.oldHash&&d.oldHash!==J&&d.newHash!==J&&!d.ok&&!await cn(this.local,d.oldHash,d.newHash))return{updates:t.map(l=>l===d?{...l,ok:!1,error:"non-fast-forward"}:{...l,ok:!1,error:"atomic push failed"})};let n=await this.ensurePushDiscovery(),r=t.map(d=>({oldHash:d.oldHash??J,newHash:d.newHash,refName:d.name})),o=[],s=[],a=!1;for(let d of t)d.newHash!==J&&(o.push(d.newHash),a=!0),d.oldHash&&d.oldHash!==J&&s.push(d.oldHash);let i=null;if(a){let d=await Ks(this.local,o,s),u=[];for(let l of d){let m=await he(this.local,l.hash);u.push({type:m.type,content:m.content})}i=await is(u)}let c=await Mc(this.url,r,i,n,this.auth,this.fetchFn);return{updates:t.map(d=>{let u=c.refResults.find(h=>h.name===d.name),l=u?.ok??c.unpackOk,m=u?.error??(!l&&c.unpackError?`unpack failed: ${c.unpackError}`:void 0);return{...d,ok:l,error:m}})}}};async function dm(e,t){let r=(await me(e))[`remote "${t}"`];return r?.url?{name:t,url:r.url,fetchRefspec:r.fetch??"+refs/heads/*:refs/remotes/origin/*"}:null}function fi(e){return e.startsWith("http://")||e.startsWith("https://")}function Gc(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(fi(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 lm(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 Lc(e,t,n){if(e.credentialProvider){let r=await e.credentialProvider(t);if(r)return r}return lm(n)}async function Nc(e,t,n,r){if(fi(t)){let o=Gc(t,e.networkPolicy);if(o)throw new Error(o);let s=await Lc(e,t,n);return new Wr(e,t,s,e.fetchFn)}if(!r)throw new Error(`'${t}' does not appear to be a git repository`);return new Br(e,r)}async function lr(e,t,n){let r=await dm(e,t);if(!r)return null;if(fi(r.url)){let s=Gc(r.url,e.networkPolicy);if(s)throw new Error(s);let a=n?await Lc(e,r.url,n):void 0;return{transport:new Wr(e,r.url,a,e.fetchFn),config:r}}let o=await Qn(e.fs,r.url);return o?{transport:new Br(e,o),config:r}:null}Ie();et();function _c(e,t){e.command("clone",{description:"Clone a repository into a new directory",args:[B.string().name("repository").describe("Repository to clone"),B.string().name("directory").describe("Target directory").optional()],options:{bare:A().describe("Create a bare clone"),branch:Q.string().alias("b").describe("Checkout this branch instead of HEAD")},handler:async(n,r)=>{let o=n.repository;if(!o)return T("You must specify a repository to clone.");let s=o.startsWith("http://")||o.startsWith("https://"),a=s?o:xt(r.cwd,o),i=n.branch,c=n.directory;if(!c){let y=s?o.split("/").pop()??o:gr(a);y.endsWith(".git")&&(y=y.slice(0,-4)),c=y}let f=xt(r.cwd,c);if(t?.hooks){let y=await t.hooks.emitPre("pre-clone",{repository:o,targetPath:f,bare:n.bare,branch:i??null});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}if(await r.fs.exists(f))try{if((await r.fs.readdir(f)).length>0)return T(`destination path '${c}' already exists and is not an empty directory.`)}catch{return T(`destination path '${c}' already exists and is not an empty directory.`)}let d=null;if(!s&&(d=await Qn(r.fs,a),!d))return T(`repository '${o}' does not exist`);await r.fs.mkdir(f,{recursive:!0});let{ctx:u}=await ls(r.fs,f,{bare:n.bare}),l=t?{...u,hooks:t.hooks,credentialProvider:t.credentialProvider,identityOverride:t.identityOverride,fetchFn:t.fetchFn,networkPolicy:t.networkPolicy}:u,m=await me(l);m['remote "origin"']={url:a,fetch:"+refs/heads/*:refs/remotes/origin/*"},await Xe(l,m);let h;try{h=await Nc(l,a,r.env,d??void 0)}catch(y){let I=y instanceof Error?y.message:"";return I.startsWith("network")?T(I):T(`repository '${o}' does not exist`)}let p=await h.advertiseRefs();if(p.length===0)return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:i??null}),{stdout:"",stderr:`Cloning into '${c}'...
297
338
  warning: You appear to have cloned an empty repository.
298
- `,exitCode:0};let g=[],w=new Set;for(let y of p)y.name!=="HEAD"&&(w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));g.length>0&&await h.fetch(g,[]);let x=p.find(y=>y.name==="HEAD"),b=null,E=null,k=await Ot(l,r.env),P=`clone: from ${a}`,C=h.headTarget;C?.startsWith("refs/heads/")&&p.some(y=>y.name===C)&&(b=C.slice(11),E=p.find(y=>y.name===C)?.hash??null);for(let y of p)if(y.name!=="HEAD"){if(y.name.startsWith("refs/heads/")){let I=y.name.slice(11),A=`refs/remotes/origin/${I}`;await Y(l,A,y.hash),await Te(l,A,{oldHash:Z,newHash:y.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:P}),!b&&x&&y.hash===x.hash&&(b=I,E=y.hash)}y.name.startsWith("refs/tags/")&&await Y(l,y.name,y.hash)}if(i){let y=p.find(I=>I.name===`refs/heads/${i}`);if(!y)return T(`Remote branch '${i}' not found in upstream origin`);b=i,E=y.hash}if(!b){let y=p.find(I=>I.name.startsWith("refs/heads/"));y&&(b=y.name.slice(11),E=y.hash)}if(n.bare)return b&&await $e(l,"HEAD",`refs/heads/${b}`),await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
299
- `,exitCode:0};if(b&&await $e(l,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&E){await Y(l,`refs/heads/${b}`,E),await $e(l,"HEAD",`refs/heads/${b}`);let y={oldHash:Z,newHash:E,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:P};await Te(l,`refs/heads/${b}`,y),await Te(l,"HEAD",y);let I=await ce(l);I[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Ge(l,I);let A=await j(l,E);await _i(l,A.tree);let L=await He(l,A.tree),D=Rr(L.map(z=>({path:z.path,mode:parseInt(z.mode,8),hash:z.hash,stage:0,stat:pe()})));await re(l,D)}let O={stdout:"",stderr:`Cloning into '${c}'...
300
- `,exitCode:0};return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),O}})}function za(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:te.string().alias("m").describe("Commit message"),file:te.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:v().describe("Allow creating an empty commit"),amend:v().describe("Amend the previous commit"),noEdit:v().describe("Use the previous commit message without editing"),all:v().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return T("options '-m' and '-F' cannot be used together");let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await U(s);if(n.all){let Q=Fe(s);if(Q)return Q;let ge=await ut(s,a);for(let Re of ge)Re.status==="modified"?a=(await Gt(s,a,Re.path)).index:Re.status==="deleted"&&(a=Ne(a,Re.path));let De=new Set(xe(a).map(Re=>Re.path)),un=new Set(a.entries.filter(Re=>Re.stage>0&&!De.has(Re.path)).map(Re=>Re.path));for(let Re of un){let yr=H(s.workTree,Re);await r.fs.exists(yr)?a=(await Gt(s,a,Re)).index:a=Ne(a,Re)}}let i=await F(s,"MERGE_HEAD"),c=await F(s,"CHERRY_PICK_HEAD"),f=await F(s,"REVERT_HEAD"),u=await bt(s)?await F(s,"REBASE_HEAD"):null,l=n.amend,m=await X(s);if(l){if(!m)return T("You have nothing yet to amend.");if(i)return T("You are in the middle of a merge -- cannot amend.");if(c)return T("You are in the middle of a cherry-pick -- cannot amend.")}if(lt(a)){let Q=new Set,ge=[];for(let De of a.entries)De.stage>0&&!Q.has(De.path)&&(Q.add(De.path),ge.push(`U ${De.path}`));return ge.sort(),{stdout:ge.length>0?`${ge.join(`
339
+ `,exitCode:0};let g=[],w=new Set;for(let y of p)y.name!=="HEAD"&&(w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));g.length>0&&await h.fetch(g,[]);let k=p.find(y=>y.name==="HEAD"),b=null,E=null,x=await Nt(l,r.env),P=`clone: from ${a}`,C=h.headTarget;C?.startsWith("refs/heads/")&&p.some(y=>y.name===C)&&(b=C.slice(11),E=p.find(y=>y.name===C)?.hash??null);for(let y of p)if(y.name!=="HEAD"){if(y.name.startsWith("refs/heads/")){let I=y.name.slice(11),v=`refs/remotes/origin/${I}`;await z(l,v,y.hash),await _e(l,v,{oldHash:J,newHash:y.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:P}),!b&&k&&y.hash===k.hash&&(b=I,E=y.hash)}y.name.startsWith("refs/tags/")&&await z(l,y.name,y.hash)}if(i){let y=p.find(I=>I.name===`refs/heads/${i}`);if(!y)return T(`Remote branch '${i}' not found in upstream origin`);b=i,E=y.hash}if(!b){let y=p.find(I=>I.name.startsWith("refs/heads/"));y&&(b=y.name.slice(11),E=y.hash)}if(n.bare)return b&&await Ne(l,"HEAD",`refs/heads/${b}`),await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),{stdout:"",stderr:`Cloning into bare repository '${c}'...
340
+ `,exitCode:0};if(b&&await Ne(l,"refs/remotes/origin/HEAD",`refs/remotes/origin/${b}`),b&&E){await z(l,`refs/heads/${b}`,E),await Ne(l,"HEAD",`refs/heads/${b}`);let y={oldHash:J,newHash:E,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:P};await _e(l,`refs/heads/${b}`,y),await _e(l,"HEAD",y);let I=await me(l);I[`branch "${b}"`]={remote:"origin",merge:`refs/heads/${b}`},await Xe(l,I);let v=await D(l,E);await $a(l,v.tree);let G=await Ue(l,v.tree),M=ns(G.map(V=>({path:V.path,mode:parseInt(V.mode,8),hash:V.hash,stage:0,stat:ke()})));await ie(l,M)}let R={stdout:"",stderr:`Cloning into '${c}'...
341
+ `,exitCode:0};return await t?.hooks?.emitPost("post-clone",{repository:o,targetPath:f,bare:n.bare,branch:b}),R}})}ee();ye();re();Jt();fe();Me();ue();Ie();et();function Fc(e,t){e.command("commit",{description:"Record changes to the repository",options:{message:Q.string().alias("m").describe("Commit message"),file:Q.string().alias("F").describe("Read commit message from file ('-' for stdin)"),allowEmpty:A().describe("Allow creating an empty commit"),amend:A().describe("Amend the previous commit"),noEdit:A().describe("Use the previous commit message without editing"),all:A().alias("a").describe("Auto-stage modified and deleted tracked files")},handler:async(n,r)=>{if(n.message!==void 0&&n.file!==void 0)return T("options '-m' and '-F' cannot be used together");let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await W(s);if(n.all){let te=qe(s);if(te)return te;let xe=await Rt(s,a);for(let Le of xe)Le.status==="modified"?a=(await nn(s,a,Le.path)).index:Le.status==="deleted"&&(a=Je(a,Le.path));let ze=new Set(He(a).map(Le=>Le.path)),vn=new Set(a.entries.filter(Le=>Le.stage>0&&!ze.has(Le.path)).map(Le=>Le.path));for(let Le of vn){let Vr=H(s.workTree,Le);await r.fs.exists(Vr)?a=(await nn(s,a,Le)).index:a=Je(a,Le)}}let i=await F(s,"MERGE_HEAD"),c=await F(s,"CHERRY_PICK_HEAD"),f=await F(s,"REVERT_HEAD"),u=await Ht(s)?await F(s,"REBASE_HEAD"):null,l=n.amend,m=await Y(s);if(l){if(!m)return T("You have nothing yet to amend.");if(i)return T("You are in the middle of a merge -- cannot amend.");if(c)return T("You are in the middle of a cherry-pick -- cannot amend.")}if(Pt(a)){let te=new Set,xe=[];for(let ze of a.entries)ze.stage>0&&!te.has(ze.path)&&(te.add(ze.path),xe.push(`U ${ze.path}`));return xe.sort(),{stdout:xe.length>0?`${xe.join(`
301
342
  `)}
302
343
  `:"",stderr:`error: Committing is not possible because you have unmerged files.
303
344
  hint: Fix them up in the work tree, and then use 'git add/rm <file>'
304
345
  hint: as appropriate to mark resolution and make a commit.
305
346
  fatal: Exiting because of an unresolved conflict.
306
- `,exitCode:128}}let h=l&&m?await j(s,m):null,p=n.message;if(!p&&n.file!==void 0){if(n.file==="-")p=r.stdin;else{let Q=n.file.startsWith("/")?n.file:H(r.cwd,n.file);if(!await r.fs.exists(Q))return T(`could not read log file '${n.file}': No such file or directory`);let ge=await r.fs.readFile(Q);p=typeof ge=="string"?ge:new TextDecoder().decode(ge)}if(p=or(p),!p)return{stdout:`Aborting commit due to empty commit message.
307
- `,stderr:"",exitCode:1}}if(!p&&l&&h&&(p=h.message),!p&&(i||c||f||u)){let Q=await qe(s,"MERGE_MSG");Q!==null&&(p=or(Q))}if(!p)return G("error: must provide a commit message with -m or -F");let g=xe(a),w=await ke(s,g);if(t?.hooks){let Q=await t.hooks.emitPre("pre-commit",{index:a,treeHash:w});if(Q)return G(Q.message??"")}let x=n.allowEmpty,b=null;if(l&&h){let Q=h.parents[0];Q?b=(await j(s,Q)).tree:b=await st("tree",new Uint8Array(0))}else m&&(b=(await j(s,m)).tree);let E=l&&h&&h.parents.length>1;if(!x&&!i&&!E){if(!m&&!l&&g.length===0)return{stdout:await Be(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(b!==null&&b===w){if(l){let Q=h?.parents[0]??null;return{stdout:`${await Be(s,{fromCommit:!0,compareHash:Q,noWarn:!0,index:a})}No changes
347
+ `,exitCode:128}}let h=l&&m?await D(s,m):null,p=n.message;if(!p&&n.file!==void 0){if(n.file==="-")p=r.stdin;else{let te=n.file.startsWith("/")?n.file:H(r.cwd,n.file);if(!await r.fs.exists(te))return T(`could not read log file '${n.file}': No such file or directory`);let xe=await r.fs.readFile(te);p=typeof xe=="string"?xe:new TextDecoder().decode(xe)}if(p=Hr(p),!p)return{stdout:`Aborting commit due to empty commit message.
348
+ `,stderr:"",exitCode:1}}if(!p&&l&&h&&(p=h.message),!p&&(i||c||f||u)){let te=await Ce(s,"MERGE_MSG");te!==null&&(p=Hr(te))}if(!p)return L("error: must provide a commit message with -m or -F");let g=He(a),w=await Ae(s,g);if(t?.hooks){let te=await t.hooks.emitPre("pre-commit",{index:a,treeHash:w});if(te)return L(te.message??"")}let k=n.allowEmpty,b=null;if(l&&h){let te=h.parents[0];te?b=(await D(s,te)).tree:b=await pt("tree",new Uint8Array(0))}else m&&(b=(await D(s,m)).tree);let E=l&&h&&h.parents.length>1;if(!k&&!i&&!E){if(!m&&!l&&g.length===0)return{stdout:await tt(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1};if(b!==null&&b===w){if(l){let te=h?.parents[0]??null;return{stdout:`${await tt(s,{fromCommit:!0,compareHash:te,noWarn:!0,index:a})}No changes
308
349
  `,stderr:`You asked to amend the most recent commit, but doing so would make
309
350
  it empty. You can repeat your command with --allow-empty, or you can
310
351
  remove the commit entirely with "git reset HEAD^".
311
- `,exitCode:1}}return c?{stdout:await Be(s,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
352
+ `,exitCode:1}}return c?{stdout:await tt(s,{fromCommit:!0,index:a}),stderr:`The previous cherry-pick is now empty, possibly due to conflict resolution.
312
353
  If you wish to commit it anyway, use:
313
354
 
314
355
  git commit --allow-empty
315
356
 
316
357
  Otherwise, please use 'git cherry-pick --skip'
317
- `,exitCode:1}:{stdout:await Be(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let k=await Ht(s,r.env);if(S(k))return k;let P=await Le(s,r.env);if(S(P))return P;l&&h&&(k.name=h.author.name,k.email=h.author.email,k.timestamp=h.author.timestamp,k.timezone=h.author.timezone),c&&(k=(await j(s,c)).author);let C=ht(p);if(t?.hooks){let Q={message:C},ge=await t.hooks.emitPre("commit-msg",Q);if(ge)return G(ge.message??"");C=Q.message}let O;l&&h?O=[...h.parents]:(O=m?[m]:[],i&&O.push(i));let y=$t({type:"commit",tree:w,parents:O,author:k,committer:P,message:C}),I=await we(s,"commit",y);await re(s,a);let A=await J(s);A&&A.type==="symbolic"?await Y(s,A.target,I):await Y(s,"HEAD",I);let L=ue(C),D;l?D="commit (amend)":i?D="commit (merge)":c?D="commit (cherry-pick)":m?D="commit":D="commit (initial)";let z=`${D}: ${L}`,M=A?.type==="symbolic"?A.target:"HEAD";await ee(s,r.env,M,m,I,z,A?.type==="symbolic"),i&&await ar(s),c&&await kt(s),f&&await wt(s),u&&await et(s,"MERGE_MSG"),await t?.hooks?.emitPost("post-commit",{hash:I,message:C,branch:A?.type==="symbolic"?de(A.target):null,parents:O,author:k});let $=A?.type==="symbolic"?A.target:null,R=$?de($):"detached HEAD",_;if(l&&h){let Q=h.parents[0];_=Q?(await j(s,Q)).tree:null}else _=m?(await j(s,m)).tree:null;let q=k.timestamp!==P.timestamp||k.timezone!==P.timezone,N=O.length>1,V=await St(s,_,w,k,P,q,N);return{stdout:`${mt(R,I,p,O.length===0&&!l)}
318
- ${V}`,stderr:"",exitCode:0}}})}function gr(e){let t=e.split(".");return t.length===2||t.length===3}function Ql(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,a]of Object.entries(r)){let i=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${i}=${a}`)}}return t}function Za(e,t){e.command("config",{description:"Get and set repository options",args:[W.string().name("positionals").variadic().optional()],options:{list:v().alias("l").describe("List all config entries"),unset:v().describe("Remove a config key")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.positionals,i=a[0];if(n.list)return Xa(await ce(s));if(n.unset){let f=i;return f?gr(f)?Ya(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(i==="list")return Xa(await ce(s));if(i==="get"){let f=a[1];return f?gr(f)?Va(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(i==="set"){let f=a[1],d=a[2];return!f||d===void 0?G("error: missing key and/or value",2):gr(f)?(await Ms(s,f,d),{stdout:"",stderr:"",exitCode:0}):G(`error: invalid key: ${f}`,2)}if(i==="unset"){let f=a[1];return f?gr(f)?Ya(s,f):G(`error: invalid key: ${f}`,2):G("error: missing key",2)}if(!i)return G("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!gr(i))return G(`error: invalid key: ${i}`,2);let c=a[1];return c!==void 0?(await Ms(s,i,c),{stdout:"",stderr:"",exitCode:0}):Va(s,i)}})}async function Va(e,t){let n=await Et(e,t);return n===void 0?G(""):{stdout:`${n}
319
- `,stderr:"",exitCode:0}}async function Ya(e,t){return await Jo(e,t)?{stdout:"",stderr:"",exitCode:0}:G("",5)}function Xa(e){let t=Ql(e);return{stdout:t.length>0?`${t.join(`
358
+ `,exitCode:1}:{stdout:await tt(s,{fromCommit:!0,index:a}),stderr:"",exitCode:1}}}let x=await qt(s,r.env);if(S(x))return x;let P=await Ye(s,r.env);if(S(P))return P;l&&h&&(x.name=h.author.name,x.email=h.author.email,x.timestamp=h.author.timestamp,x.timezone=h.author.timezone),c&&(x=(await D(s,c)).author);let C=$t(p);if(t?.hooks){let te={message:C},xe=await t.hooks.emitPre("commit-msg",te);if(xe)return L(xe.message??"");C=te.message}let R;l&&h?R=[...h.parents]:(R=m?[m]:[],i&&R.push(i));let y=Ut({type:"commit",tree:w,parents:R,author:x,committer:P,message:C}),I=await Re(s,"commit",y);await ie(s,a);let v=await Z(s);v&&v.type==="symbolic"?await z(s,v.target,I):await z(s,"HEAD",I);let G=se(C),M;l?M="commit (amend)":i?M="commit (merge)":c?M="commit (cherry-pick)":m?M="commit":M="commit (initial)";let V=`${M}: ${G}`,j=v?.type==="symbolic"?v.target:"HEAD";await ne(s,r.env,j,m,I,V,v?.type==="symbolic"),i&&await vr(s),c&&await jt(s),f&&await Tt(s),u&&await Se(s,"MERGE_MSG"),await t?.hooks?.emitPost("post-commit",{hash:I,message:C,branch:v?.type==="symbolic"?ge(v.target):null,parents:R,author:x});let $=v?.type==="symbolic"?v.target:null,O=$?ge($):"detached HEAD",_;if(l&&h){let te=h.parents[0];_=te?(await D(s,te)).tree:null}else _=m?(await D(s,m)).tree:null;let q=x.timestamp!==P.timestamp||x.timezone!==P.timezone,N=R.length>1,X=await Yt(s,_,w,x,P,q,N);return{stdout:`${Ot(O,I,p,R.length===0&&!l)}
359
+ ${X}`,stderr:"",exitCode:0}}})}ee();Ze();function qr(e){let t=e.split(".");return t.length===2||t.length===3}function um(e){let t=[];for(let[n,r]of Object.entries(e)){let o=n.match(/^(\S+)\s+"(.+)"$/);for(let[s,a]of Object.entries(r)){let i=o?`${o[1]}.${o[2]}.${s}`:`${n}.${s}`;t.push(`${i}=${a}`)}}return t}function qc(e,t){e.command("config",{description:"Get and set repository options",args:[B.string().name("positionals").variadic().optional()],options:{list:A().alias("l").describe("List all config entries"),unset:A().describe("Remove a config key")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.positionals,i=a[0];if(n.list)return Wc(await me(s));if(n.unset){let f=i;return f?qr(f)?Bc(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(i==="list")return Wc(await me(s));if(i==="get"){let f=a[1];return f?qr(f)?Uc(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(i==="set"){let f=a[1],d=a[2];return!f||d===void 0?L("error: missing key and/or value",2):qr(f)?(await go(s,f,d),{stdout:"",stderr:"",exitCode:0}):L(`error: invalid key: ${f}`,2)}if(i==="unset"){let f=a[1];return f?qr(f)?Bc(s,f):L(`error: invalid key: ${f}`,2):L("error: missing key",2)}if(!i)return L("usage: git config [get|set|unset|list] [<key>] [<value>]",2);if(!qr(i))return L(`error: invalid key: ${i}`,2);let c=a[1];return c!==void 0?(await go(s,i,c),{stdout:"",stderr:"",exitCode:0}):Uc(s,i)}})}async function Uc(e,t){let n=await Dt(e,t);return n===void 0?L(""):{stdout:`${n}
360
+ `,stderr:"",exitCode:0}}async function Bc(e,t){return await ji(e,t)?{stdout:"",stderr:"",exitCode:0}:L("",5)}function Wc(e){let t=um(e);return{stdout:t.length>0?`${t.join(`
320
361
  `)}
321
- `:"",stderr:"",exitCode:0}}function ws(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,a=[];a.push(`diff --cc ${t}`);let i=n.map(x=>x?K(x):"0000000"),c=o?K(o):"0000000";a.push(`index ${i.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(x=>x===null),u=!f&&n.some(x=>x!==null);if(d&&s)a.push(`new file mode ${s}`);else if(u){let x=r.map(b=>b||"000000").join(",");a.push(`deleted file mode ${x}`)}else{let x=r.map(k=>k||"000000"),b=s||"000000";x.some(k=>k!==b)&&a.push(`mode ${x.join(",")}..${b}`)}let l=n.some(x=>x!==null);if(a.push(l?`--- a/${t}`:"--- /dev/null"),a.push(f?`+++ b/${t}`:"+++ /dev/null"),u||d)return`${a.join(`
362
+ `:"",stderr:"",exitCode:0}}ee();function Zs(e){let{path:t,parentHashes:n,parentModes:r,resultHash:o,resultMode:s}=e,a=[];a.push(`diff --cc ${t}`);let i=n.map(k=>k?K(k):"0000000"),c=o?K(o):"0000000";a.push(`index ${i.join(",")}..${c}`);let f=e.resultContent.length>0,d=n.every(k=>k===null),u=!f&&n.some(k=>k!==null);if(d&&s)a.push(`new file mode ${s}`);else if(u){let k=r.map(b=>b||"000000").join(",");a.push(`deleted file mode ${k}`)}else{let k=r.map(x=>x||"000000"),b=s||"000000";k.some(x=>x!==b)&&a.push(`mode ${k.join(",")}..${b}`)}let l=n.some(k=>k!==null);if(a.push(l?`--- a/${t}`:"--- /dev/null"),a.push(f?`+++ b/${t}`:"+++ /dev/null"),u||d)return`${a.join(`
322
363
  `)}
323
- `;let m=e.parentContents.map(x=>x.length>0?pt(x):[]),h=e.resultContent.length>0?pt(e.resultContent):[],p=m.map(x=>it(x,h)),g=eu(m,h,p),w=nu(g,m.length,h);if(w.length===0)return"";for(let x of w)a.push(x);return`${a.join(`
364
+ `;let m=e.parentContents.map(k=>k.length>0?At(k):[]),h=e.resultContent.length>0?At(e.resultContent):[],p=m.map(k=>yt(k,h)),g=mm(m,h,p),w=pm(g,m.length,h);if(w.length===0)return"";for(let k of w)a.push(k);return`${a.join(`
324
365
  `)}
325
- `}function eu(e,t,n){let r=e.length,o=n.map(a=>{let i=[],c=new Map,f=0;for(let d of a)if(d.type==="keep")i[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")i[d.newLineNo-1]="insert",f=d.newLineNo;else if(d.type==="delete"){let u=c.get(f)??[];u.push({text:d.line,parentLineNo:d.oldLineNo}),c.set(f,u)}return{resultStatus:i,deletions:c}}),s=[];for(let a=0;a<=t.length;a++){let i=[];for(let f=0;f<r;f++){let d=o[f];i.push(d?.deletions.get(a)??[])}let c=tu(i,r);for(let f of c)s.push(f);if(a<t.length){let f=[],d=Array(r).fill(0);for(let u=0;u<r;u++){let m=o[u]?.resultStatus[a];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[u];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===a+1){d[u]=p.oldLineNo;break}}}}s.push({columns:f,text:t[a]??"",resultLineNo:a+1,parentLineNos:d})}}return s}function tu(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(d=>({columns:[" ","-"],text:d.text,resultLineNo:0,parentLineNos:[0,d.parentLineNo]}));if(s.length===0)return o.map(d=>({columns:["-"," "],text:d.text,resultLineNo:0,parentLineNos:[d.parentLineNo,0]}));let a=o.map(d=>d.text),i=s.map(d=>d.text),c=it(a,i),f=[];for(let d of c)if(d.type==="keep"){let u=o.find(m=>m.text===d.line&&m.parentLineNo===d.oldLineNo),l=s.find(m=>m.text===d.line&&m.parentLineNo===d.newLineNo);f.push({columns:["-","-"],text:d.line,resultLineNo:0,parentLineNos:[u?.parentLineNo??0,l?.parentLineNo??0]})}else if(d.type==="delete"){let u=o.find(l=>l.parentLineNo===d.oldLineNo);f.push({columns:["-"," "],text:d.line,resultLineNo:0,parentLineNos:[u?.parentLineNo??0,0]})}else if(d.type==="insert"){let u=s.find(l=>l.parentLineNo===d.newLineNo);f.push({columns:[" ","-"],text:d.line,resultLineNo:0,parentLineNos:[0,u?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let a of s){let i=Array(t).fill(" ");i[o]="-";let c=Array(t).fill(0);c[o]=a.parentLineNo,r.push({columns:i,text:a.text,resultLineNo:0,parentLineNos:c})}}return r}function nu(e,t,n){let o=[];for(let d=0;d<e.length;d++)e[d]?.columns.some(l=>l!==" ")&&o.push(d);if(o.length===0)return[];let s=[],a=o[0]??0,i=Math.max(0,a-3),c=Math.min(e.length-1,a+3);for(let d=1;d<o.length;d++){let u=o[d]??0,l=Math.max(0,u-3),m=Math.min(e.length-1,u+3);l<=c+1||(s.push({start:i,end:c}),i=l),c=m}s.push({start:i,end:c});let f=[];for(let d of s){let u=e.slice(d.start,d.end+1),l=[];for(let E=0;E<t;E++){let k=u.filter(P=>(P.parentLineNos[E]??0)>0||P.columns[E]==="-");if(k.length===0)l.push({start:1,count:0});else{let C=k.find(O=>(O.parentLineNos[E]??0)>0)?.parentLineNos[E]??1;l.push({start:C,count:k.length})}}let m=u.filter(E=>E.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let E=p-2;E>=0;E--){let k=n[E];if(k&&/^[a-zA-Z$_]/.test(k)){w=` ${k.trimEnd().slice(0,79)}`;break}}let x=l.map(E=>`-${E.start},${E.count}`),b=`${"@".repeat(t+1)} ${x.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(b);for(let E of u)f.push(`${E.columns.join("")}${E.text}`)}return f}function bs(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}var Io=new TextDecoder;function tc(e){return"exitCode"in e}function Bn(e){return e.toString(8).padStart(6,"0")}function nc(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 rc(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[W.string().name("commits").variadic().optional()],options:{cached:v().describe("Show staged changes (index vs HEAD)"),staged:v().describe("Synonym for --cached"),stat:v().describe("Show diffstat summary"),nameOnly:v().describe("Show only names of changed files"),nameStatus:v().describe("Show names and status of changed files"),shortstat:v().describe("Show only the shortstat summary line"),numstat:v().describe("Machine-readable insertions/deletions per file")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.cached||n.staged,c=n.commits,f=Ze(a,r.cwd),d=o.passthrough.length>0?o.passthrough.map(p=>Oe(p,f)):null,u=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",l,m=c.length===1?bs(c[0]):null;if(m){if(i)return T("too many arguments");m.type==="three-dot"?l=await iu(a,m.left,m.right,d):l=await ec(a,m.left,m.right,d)}else if(c.length===2)l=await ec(a,c[0],c[1],d);else{if(c.length>2)return T("too many arguments");i?l=await ou(a,c.length===1?c[0]:null,d):c.length===1?l=await au(a,c[0],d):l=await ru(a,d)}if(tc(l))return l;let h=await cu(a,l.items,u);return l.stderr&&(h.stderr=l.stderr),h}})}async function ru(e,t){let n=Fe(e);if(n)return n;let r=await U(e),o=new Set,s=new Map,a=new Map,i=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?a.set(d.path,d):d.stage===3&&i.set(d.path,d));let c=await ut(e,r);c.sort((d,u)=>he(d.path,u.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!me(t,d.path)||o.has(d.path))continue;let u=s.get(d.path);if(!u)continue;let l=Bn(u.mode),m;if(d.status==="modified"&&e.workTree){let h=H(e.workTree,d.path),p=await e.fs.readFileBuffer(h);m=await st("blob",p)}f.push({path:d.path,status:d.status==="deleted"?"D":"M",oldHash:u.hash,newHash:m,oldMode:l,newMode:l,newFromWorkTree:d.status==="modified"})}for(let d of o){if(t&&!me(t,d))continue;let u=a.get(d),l=i.get(d);await su(f,e,d,u,l)}return f.sort((d,u)=>{let l=he(d.path,u.path);return l!==0?l:d.status==="U"&&u.status!=="U"?-1:d.status!=="U"&&u.status==="U"?1:0}),{items:f}}async function su(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let a=Bn(r.mode),i=Bn(o.mode),{exists:c,hash:f}=await Ja(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:a,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[a,i]}),Qa(e,n,r.hash,a,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let a=Bn(r.mode),{exists:i,hash:c}=await Ja(t.fs,s,n);Qa(e,n,r.hash,a,i,c)}}async function Ja(e,t,n){let r=H(t,n);if(!await e.exists(r))return{exists:!1};let o=await tr(e,r);return{exists:!0,hash:await st("blob",o)}}function Qa(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 ou(e,t,n){let r=null;if(t){let l=await ye(e,t);if(S(l))return l;r=l.commit.tree}else{let l=await X(e);l&&(r=(await j(e,l)).tree)}let o=await se(e,r),s=await U(e),a=new Set;for(let l of s.entries)l.stage>0&&a.add(l.path);let i=new Map(xe(s).map(l=>[l.path,l])),c=[];for(let[l,m]of i){if(a.has(l))continue;let h=o.get(l);h?h.hash!==m.hash&&c.push({path:l,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:Bn(m.mode)}):c.push({path:l,status:"added",newHash:m.hash,newMode:Bn(m.mode)})}for(let[l,m]of o)a.has(l)||i.has(l)||c.push({path:l,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await Ye(e,c),u=nc(f,d);for(let l of a)u.push({path:l,status:"U"});return u.sort((l,m)=>he(l.path,m.path)),n?{items:u.filter(l=>me(n,l.path))}:{items:u}}async function ec(e,t,n,r){let o=await ye(e,t);if(S(o))return o;let s=await ye(e,n);if(S(s))return s;let a=await Ae(e,o.commit.tree,s.commit.tree);return sc(e,a,r)}async function iu(e,t,n,r){let o=await ye(e,t);if(S(o))return o;let s=await ye(e,n);if(S(s))return s;let a=await gt(e,o.hash,s.hash);if(a.length===0)return T(`${t}...${n}: no merge base`);let i;a.length>1&&(i=`warning: ${t}...${n}: multiple merge bases, using ${a[0]}
326
- `);let c=a[0],f=await j(e,c),d=await Ae(e,f.tree,s.commit.tree),u=await sc(e,d,r);return tc(u)||i&&(u.stderr=i),u}async function sc(e,t,n){let{remaining:r,renames:o}=await Ye(e,t),s=nc(r,o);return s.sort((a,i)=>he(a.path,i.path)),n?{items:s.filter(a=>me(n,a.path))}:{items:s}}async function au(e,t,n){let r=Fe(e);if(r)return r;let o=await ye(e,t);if(S(o))return o;let s=e.workTree,a=await se(e,o.commit.tree),i=[];for(let[c,f]of a){if(n&&!me(n,c))continue;let d=H(s,c);if(!await e.fs.exists(d)){i.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let u=await e.fs.readFileBuffer(d),l=await st("blob",u);l!==f.hash&&i.push({path:c,status:"M",oldHash:f.hash,newHash:l,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return i.sort((c,f)=>he(c.path,f.path)),{items:i}}async function cu(e,t,n){let r;switch(n){case"stat":r=await hu(e,t);break;case"shortstat":r=await pu(e,t);break;case"numstat":r=await mu(e,t);break;case"name-only":r=lu(t);break;case"name-status":r=uu(t);break;default:r=await fu(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function fu(e,t){let n="",r=new Set,o=await du(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let a=await Promise.all(s.combinedParentHashes.map(async f=>f?await ie(e,f):"")),i=await Ro(e,s);if(a.some(f=>Pe(f))||Pe(i)){let f=s.combinedParentHashes.map(d=>d?K(d):"0000000");n+=`diff --cc ${s.path}
366
+ `}function mm(e,t,n){let r=e.length,o=n.map(a=>{let i=[],c=new Map,f=0;for(let d of a)if(d.type==="keep")i[d.newLineNo-1]="keep",f=d.newLineNo;else if(d.type==="insert")i[d.newLineNo-1]="insert",f=d.newLineNo;else if(d.type==="delete"){let u=c.get(f)??[];u.push({text:d.line,parentLineNo:d.oldLineNo}),c.set(f,u)}return{resultStatus:i,deletions:c}}),s=[];for(let a=0;a<=t.length;a++){let i=[];for(let f=0;f<r;f++){let d=o[f];i.push(d?.deletions.get(a)??[])}let c=hm(i,r);for(let f of c)s.push(f);if(a<t.length){let f=[],d=Array(r).fill(0);for(let u=0;u<r;u++){let m=o[u]?.resultStatus[a];if(f.push(m==="insert"?"+":" "),m==="keep"){let h=n[u];if(h){for(let p of h)if(p.type==="keep"&&p.newLineNo===a+1){d[u]=p.oldLineNo;break}}}}s.push({columns:f,text:t[a]??"",resultLineNo:a+1,parentLineNos:d})}}return s}function hm(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(d=>({columns:[" ","-"],text:d.text,resultLineNo:0,parentLineNos:[0,d.parentLineNo]}));if(s.length===0)return o.map(d=>({columns:["-"," "],text:d.text,resultLineNo:0,parentLineNos:[d.parentLineNo,0]}));let a=o.map(d=>d.text),i=s.map(d=>d.text),c=yt(a,i),f=[];for(let d of c)if(d.type==="keep"){let u=o.find(m=>m.text===d.line&&m.parentLineNo===d.oldLineNo),l=s.find(m=>m.text===d.line&&m.parentLineNo===d.newLineNo);f.push({columns:["-","-"],text:d.line,resultLineNo:0,parentLineNos:[u?.parentLineNo??0,l?.parentLineNo??0]})}else if(d.type==="delete"){let u=o.find(l=>l.parentLineNo===d.oldLineNo);f.push({columns:["-"," "],text:d.line,resultLineNo:0,parentLineNos:[u?.parentLineNo??0,0]})}else if(d.type==="insert"){let u=s.find(l=>l.parentLineNo===d.newLineNo);f.push({columns:[" ","-"],text:d.line,resultLineNo:0,parentLineNos:[0,u?.parentLineNo??0]})}return f}let r=[];for(let o=0;o<t;o++){let s=e[o]??[];for(let a of s){let i=Array(t).fill(" ");i[o]="-";let c=Array(t).fill(0);c[o]=a.parentLineNo,r.push({columns:i,text:a.text,resultLineNo:0,parentLineNos:c})}}return r}function pm(e,t,n){let o=[];for(let d=0;d<e.length;d++)e[d]?.columns.some(l=>l!==" ")&&o.push(d);if(o.length===0)return[];let s=[],a=o[0]??0,i=Math.max(0,a-3),c=Math.min(e.length-1,a+3);for(let d=1;d<o.length;d++){let u=o[d]??0,l=Math.max(0,u-3),m=Math.min(e.length-1,u+3);l<=c+1||(s.push({start:i,end:c}),i=l),c=m}s.push({start:i,end:c});let f=[];for(let d of s){let u=e.slice(d.start,d.end+1),l=[];for(let E=0;E<t;E++){let x=u.filter(P=>(P.parentLineNos[E]??0)>0||P.columns[E]==="-");if(x.length===0)l.push({start:1,count:0});else{let C=x.find(R=>(R.parentLineNos[E]??0)>0)?.parentLineNos[E]??1;l.push({start:C,count:x.length})}}let m=u.filter(E=>E.resultLineNo>0),h=m[0],p=h?h.resultLineNo:1,g=m.length,w="";for(let E=p-2;E>=0;E--){let x=n[E];if(x&&/^[a-zA-Z$_]/.test(x)){w=` ${x.trimEnd().slice(0,79)}`;break}}let k=l.map(E=>`-${E.start},${E.count}`),b=`${"@".repeat(t+1)} ${k.join(" ")} +${p},${g} ${"@".repeat(t+1)}${w}`;f.push(b);for(let E of u)f.push(`${E.columns.join("")}${E.text}`)}return f}ee();ye();re();fe();function Js(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}Gn();ue();Ie();et();var di=new TextDecoder;function Yc(e){return"exitCode"in e}function ur(e){return e.toString(8).padStart(6,"0")}function Xc(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 Zc(e,t){e.command("diff",{description:"Show changes between commits, commit and working tree, etc.",args:[B.string().name("commits").variadic().optional()],options:{cached:A().describe("Show staged changes (index vs HEAD)"),staged:A().describe("Synonym for --cached"),stat:A().describe("Show diffstat summary"),nameOnly:A().describe("Show only names of changed files"),nameStatus:A().describe("Show names and status of changed files"),shortstat:A().describe("Show only the shortstat summary line"),numstat:A().describe("Machine-readable insertions/deletions per file")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.cached||n.staged,c=n.commits,f=ft(a,r.cwd),d=o.passthrough.length>0?o.passthrough.map(p=>je(p,f)):null,u=n.stat?"stat":n.nameOnly?"name-only":n.nameStatus?"name-status":n.shortstat?"shortstat":n.numstat?"numstat":"unified",l,m=c.length===1?Js(c[0]):null;if(m){if(i)return T("too many arguments");m.type==="three-dot"?l=await ym(a,m.left,m.right,d):l=await Vc(a,m.left,m.right,d)}else if(c.length===2)l=await Vc(a,c[0],c[1],d);else{if(c.length>2)return T("too many arguments");i?l=await bm(a,c.length===1?c[0]:null,d):c.length===1?l=await Em(a,c[0],d):l=await gm(a,d)}if(Yc(l))return l;let h=await km(a,l.items,u);return l.stderr&&(h.stderr=l.stderr),h}})}async function gm(e,t){let n=qe(e);if(n)return n;let r=await W(e),o=new Set,s=new Map,a=new Map,i=new Map;for(let d of r.entries)d.stage===0?s.set(d.path,d):(o.add(d.path),d.stage===2?a.set(d.path,d):d.stage===3&&i.set(d.path,d));let c=await Rt(e,r);c.sort((d,u)=>Ee(d.path,u.path));let f=[];for(let d of c){if(d.status==="untracked"||t&&!we(t,d.path)||o.has(d.path))continue;let u=s.get(d.path);if(!u)continue;let l=ur(u.mode),m;if(d.status==="modified"&&e.workTree){let h=H(e.workTree,d.path),p=await e.fs.readFileBuffer(h);m=await pt("blob",p)}f.push({path:d.path,status:d.status==="deleted"?"D":"M",oldHash:u.hash,newHash:m,oldMode:l,newMode:l,newFromWorkTree:d.status==="modified"})}for(let d of o){if(t&&!we(t,d))continue;let u=a.get(d),l=i.get(d);await wm(f,e,d,u,l)}return f.sort((d,u)=>{let l=Ee(d.path,u.path);return l!==0?l:d.status==="U"&&u.status!=="U"?-1:d.status!=="U"&&u.status==="U"?1:0}),{items:f}}async function wm(e,t,n,r,o){let s=t.workTree;if(s&&r&&o){let a=ur(r.mode),i=ur(o.mode),{exists:c,hash:f}=await Kc(t.fs,s,n);e.push({path:n,status:"U",newHash:f,newMode:a,newFromWorkTree:c,combinedParentHashes:[r.hash,o.hash],combinedParentModes:[a,i]}),zc(e,n,r.hash,a,c,f);return}if(e.push({path:n,status:"U"}),s&&r){let a=ur(r.mode),{exists:i,hash:c}=await Kc(t.fs,s,n);zc(e,n,r.hash,a,i,c)}}async function Kc(e,t,n){let r=H(t,n);if(!await e.exists(r))return{exists:!1};let o=await Ir(e,r);return{exists:!0,hash:await pt("blob",o)}}function zc(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 bm(e,t,n){let r=null;if(t){let l=await $e(e,t);if(S(l))return l;r=l.commit.tree}else{let l=await Y(e);l&&(r=(await D(e,l)).tree)}let o=await ae(e,r),s=await W(e),a=new Set;for(let l of s.entries)l.stage>0&&a.add(l.path);let i=new Map(He(s).map(l=>[l.path,l])),c=[];for(let[l,m]of i){if(a.has(l))continue;let h=o.get(l);h?h.hash!==m.hash&&c.push({path:l,status:"modified",oldHash:h.hash,newHash:m.hash,oldMode:h.mode,newMode:ur(m.mode)}):c.push({path:l,status:"added",newHash:m.hash,newMode:ur(m.mode)})}for(let[l,m]of o)a.has(l)||i.has(l)||c.push({path:l,status:"deleted",oldHash:m.hash,oldMode:m.mode});let{remaining:f,renames:d}=await it(e,c),u=Xc(f,d);for(let l of a)u.push({path:l,status:"U"});return u.sort((l,m)=>Ee(l.path,m.path)),n?{items:u.filter(l=>we(n,l.path))}:{items:u}}async function Vc(e,t,n,r){let o=await $e(e,t);if(S(o))return o;let s=await $e(e,n);if(S(s))return s;let a=await Be(e,o.commit.tree,s.commit.tree);return Jc(e,a,r)}async function ym(e,t,n,r){let o=await $e(e,t);if(S(o))return o;let s=await $e(e,n);if(S(s))return s;let a=await vt(e,o.hash,s.hash);if(a.length===0)return T(`${t}...${n}: no merge base`);let i;a.length>1&&(i=`warning: ${t}...${n}: multiple merge bases, using ${a[0]}
367
+ `);let c=a[0],f=await D(e,c),d=await Be(e,f.tree,s.commit.tree),u=await Jc(e,d,r);return Yc(u)||i&&(u.stderr=i),u}async function Jc(e,t,n){let{remaining:r,renames:o}=await it(e,t),s=Xc(r,o);return s.sort((a,i)=>Ee(a.path,i.path)),n?{items:s.filter(a=>we(n,a.path))}:{items:s}}async function Em(e,t,n){let r=qe(e);if(r)return r;let o=await $e(e,t);if(S(o))return o;let s=e.workTree,a=await ae(e,o.commit.tree),i=[];for(let[c,f]of a){if(n&&!we(n,c))continue;let d=H(s,c);if(!await e.fs.exists(d)){i.push({path:c,status:"D",oldHash:f.hash,oldMode:f.mode});continue}let u=await e.fs.readFileBuffer(d),l=await pt("blob",u);l!==f.hash&&i.push({path:c,status:"M",oldHash:f.hash,newHash:l,oldMode:f.mode,newMode:f.mode,newFromWorkTree:!0})}return i.sort((c,f)=>Ee(c.path,f.path)),{items:i}}async function km(e,t,n){let r;switch(n){case"stat":r=await Om(e,t);break;case"shortstat":r=await $m(e,t);break;case"numstat":r=await Im(e,t);break;case"name-only":r=Pm(t);break;case"name-status":r=Rm(t);break;default:r=await xm(e,t);break}return{stdout:r,stderr:"",exitCode:0}}async function xm(e,t){let n="",r=new Set,o=await Cm(e,t);for(let s of t)if(s.status==="U")if(s.combinedParentHashes){let a=await Promise.all(s.combinedParentHashes.map(async f=>f?await le(e,f):"")),i=await li(e,s);if(a.some(f=>De(f))||De(i)){let f=s.combinedParentHashes.map(d=>d?K(d):"0000000");n+=`diff --cc ${s.path}
327
368
  index ${f.join(",")}..0000000
328
369
  Binary files differ
329
- `,r.add(s.path)}else{let f=ws({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:s.newMode??null,resultContent:i});f?(n+=f,r.add(s.path)):n+=`* Unmerged path ${s.path}
370
+ `,r.add(s.path)}else{let f=Zs({path:s.path,parentHashes:s.combinedParentHashes,parentModes:s.combinedParentModes??[],parentContents:a,resultHash:null,resultMode:s.newMode??null,resultContent:i});f?(n+=f,r.add(s.path)):n+=`* Unmerged path ${s.path}
330
371
  `}}else n+=`* Unmerged path ${s.path}
331
- `;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let a=s.oldHash?await ie(e,s.oldHash):"",i=await Ro(e,s);s.status==="R"&&s.oldPath?n+=At({path:s.oldPath,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:ys(s.oldHash,o),newHash:ys(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=At({path:s.path,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:ys(s.oldHash,o),newHash:ys(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function du(e,t){let n=new Set;for(let i of t)i.oldHash&&i.oldHash.length===40&&n.add(i.oldHash),i.newHash&&i.newHash.length===40&&n.add(i.newHash);let r=new Map,o=async i=>{let c=r.get(i);if(c)return c;let f=H(e.gitDir,"objects",i),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(i,d),d},s=async(i,c)=>{let f=i.slice(0,2),d=i.slice(2,c),u=await o(f),l=0;for(let m of u)if(m.startsWith(d)&&(l++,l>1))return!1;return l===1},a=new Map;for(let i of n){let c=7;for(;c<40&&!await s(i,c);)c++;a.set(i,i.slice(0,c))}return a}function ys(e,t){if(e)return e.length!==40?e:t.get(e)??K(e)}function lu(e){let t="";for(let n of e)t+=`${n.path}
332
- `;return t}function uu(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}
372
+ `;for(let s of t){if(s.status==="U"||r.has(s.path))continue;let a=s.oldHash?await le(e,s.oldHash):"",i=await li(e,s);s.status==="R"&&s.oldPath?n+=zt({path:s.oldPath,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:Qs(s.oldHash,o),newHash:Qs(s.newHash,o),renameTo:s.path,similarity:s.similarity}):n+=zt({path:s.path,oldContent:a,newContent:i,oldMode:s.oldMode,newMode:s.newMode,oldHash:Qs(s.oldHash,o),newHash:Qs(s.newHash,o),isNew:s.status==="A",isDeleted:s.status==="D"})}return n}async function Cm(e,t){let n=new Set;for(let i of t)i.oldHash&&i.oldHash.length===40&&n.add(i.oldHash),i.newHash&&i.newHash.length===40&&n.add(i.newHash);let r=new Map,o=async i=>{let c=r.get(i);if(c)return c;let f=H(e.gitDir,"objects",i),d=await e.fs.exists(f)?await e.fs.readdir(f):[];return r.set(i,d),d},s=async(i,c)=>{let f=i.slice(0,2),d=i.slice(2,c),u=await o(f),l=0;for(let m of u)if(m.startsWith(d)&&(l++,l>1))return!1;return l===1},a=new Map;for(let i of n){let c=7;for(;c<40&&!await s(i,c);)c++;a.set(i,i.slice(0,c))}return a}function Qs(e,t){if(e)return e.length!==40?e:t.get(e)??K(e)}function Pm(e){let t="";for(let n of e)t+=`${n.path}
373
+ `;return t}function Rm(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}
333
374
  `}else t+=`${n.status} ${n.path}
334
- `;return t}async function mu(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
335
- `;continue}let o=r.oldHash?await ie(e,r.oldHash):"",s=await Ro(e,r),a=Pe(o)||Pe(s),i,c;if(a)i="-",c="-";else{let{ins:f,del:d}=oc(o,s);i=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=Ln(r.oldPath,r.path);n+=`${i} ${c} ${f}
375
+ `;return t}async function Im(e,t){let n="";for(let r of t){if(r.status==="U"){n+=`0 0 ${r.path}
376
+ `;continue}let o=r.oldHash?await le(e,r.oldHash):"",s=await li(e,r),a=De(o)||De(s),i,c;if(a)i="-",c="-";else{let{ins:f,del:d}=Qc(o,s);i=String(f),c=String(d)}if(r.status==="R"&&r.oldPath){let f=ir(r.oldPath,r.path);n+=`${i} ${c} ${f}
336
377
  `}else n+=`${i} ${c} ${r.path}
337
- `}return n}async function hu(e,t){let n=await ic(e,t);return ao(n)}async function pu(e,t){let n=await ic(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let i of n)i.isUnmerged||(s++,r+=i.insertions,o+=i.deletions);let a=Qr(s,r,o);return a?`${a}
378
+ `}return n}async function Om(e,t){let n=await ef(e,t);return Qo(n)}async function $m(e,t){let n=await ef(e,t);if(n.length===0)return"";let r=0,o=0,s=0;for(let i of n)i.isUnmerged||(s++,r+=i.insertions,o+=i.deletions);let a=Bs(s,r,o);return a?`${a}
338
379
  `:n.some(i=>i.isUnmerged)?` 0 files changed
339
- `:""}async function Ro(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path),r=await tr(e.fs,n);return Io.decode(r)}return ie(e,t.newHash)}async function gu(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path);return tr(e.fs,n)}return ot(e,t.newHash)}function oc(e,t){let n=rn(e),r=rn(t),o=it(n,r),s=0,a=0;for(let i of o)i.type==="insert"?s++:i.type==="delete"&&a++;return{ins:s,del:a}}async function ic(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?Ln(r.oldPath,r.path):r.path,s=r.oldHash?await ot(e,r.oldHash):new Uint8Array(0),a=await gu(e,r);if(Yt(s)||Yt(a))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:a.byteLength});else{let i=Io.decode(s),c=Io.decode(a),{ins:f,del:d}=oc(i,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}function On(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 wu(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 Es(e,t){if(!wu(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),a=s.length>0?t.length-s.length:t.length,i=t.slice(o.length,a);return r===-1?e.dst:e.dst.slice(0,r)+i+e.dst.slice(r+1)}function ac(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[W.string().name("remote").describe("Remote to fetch from").optional(),W.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:v().describe("Fetch from all remotes"),prune:v().alias("p").describe("Remove stale remote-tracking refs"),tags:v().describe("Also fetch tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.remote||"origin",i;try{i=await Un(s,a,r.env)}catch(y){let I=y instanceof Error?y.message:"";if(I.startsWith("network"))return T(I);throw y}if(!i)return T(`'${a}' does not appear to be a git repository`);let{transport:c,config:f}=i,d=n.refspec,u;if(d&&d.length>0?u=d.map(On):u=[On(f.fetchRefspec)],t?.hooks){let y=await t.hooks.emitPre("pre-fetch",{remote:a,url:f.url,refspecs:u.map(I=>`${I.src}:${I.dst}`),prune:n.prune,tags:n.tags});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}let l=await c.advertiseRefs();if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let h=(await le(s)).map(y=>y.hash),p=await F(s,"HEAD");p&&h.push(p);let g=[],w=new Set,x=[];for(let y of l)if(y.name!=="HEAD")for(let I of u){let A=Es(I,y.name);if(A!==null){x.push({remote:y,localRef:A,force:I.force}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash));break}}if(n.tags)for(let y of l)y.name.startsWith("refs/tags/")&&(x.push({remote:y,localRef:y.name,force:!1}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));let b=new Set(h),E=g.filter(y=>!b.has(y));E.length>0&&await c.fetch(E,h);let k=await Ot(s,r.env),P=[];P.push(`From ${f.url}
340
- `);for(let y of x){let I=await F(s,y.localRef);await Y(s,y.localRef,y.remote.hash),await Te(s,y.localRef,{oldHash:I??Z,newHash:y.remote.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:I?"fetch":"fetch: storing head"});let A=xs(y.remote.name),L=xs(y.localRef);if(I){if(I!==y.remote.hash){let D=K(I),z=K(y.remote.hash);P.push(` ${D}..${z} ${A} -> ${L}
341
- `)}}else{let z=y.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";P.push(`${z} ${A} -> ${L}
342
- `)}}if(!n.tags)for(let y of l){if(!y.name.startsWith("refs/tags/")||w.has(y.hash))continue;let I=await F(s,y.name),A=y.peeledHash??y.hash;!I&&b.has(A)&&(await Y(s,y.name,y.hash),await Te(s,y.name,{oldHash:Z,newHash:y.hash,name:k.name,email:k.email,timestamp:k.timestamp,tz:k.tz,message:"fetch: storing head"}),P.push(` * [new tag] ${xs(y.name)} -> ${xs(y.name)}
343
- `))}if(n.prune){let y=`refs/remotes/${a}`,I=await le(s,y),A=new Set(l.filter(L=>L.name.startsWith("refs/heads/")).map(L=>L.name.slice(11)));for(let L of I){let D=L.name.slice(y.length+1);A.has(D)||(await ae(s,L.name),P.push(` - [deleted] (none) -> ${a}/${D}
344
- `))}}let C=l.find(y=>y.name==="HEAD");if(C){let y=H(s.gitDir,"FETCH_HEAD"),I=l.find(L=>L.name.startsWith("refs/heads/")&&L.hash===C.hash),A=I?`branch '${I.name.slice(11)}' of`:"of";await r.fs.writeFile(y,`${C.hash} ${A} ${f.url}
345
- `)}let O={stdout:"",stderr:P.join(""),exitCode:0};return await t?.hooks?.emitPost("post-fetch",{remote:a,url:f.url,refsUpdated:x.length}),O}})}function xs(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}async function cc(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await le(e,"refs");for(let i of r)t.add(i.hash);let o=H(e.gitDir,"logs");await e.fs.exists(o)&&await fc(e,o,o,t);let s=await U(e);for(let i of s.entries)t.add(i.hash);for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await F(e,i);c&&t.add(c)}let a=[];for(let i of t)await Vt(e,i)&&a.push(i);return a}async function fc(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let a=H(t,s),i=await e.fs.stat(a);if(i.isDirectory)await fc(e,a,n,r);else if(i.isFile){let c=a.slice(n.length+1),f=await Me(e,c);for(let d of f)d.newHash!==Z&&r.add(d.newHash)}}}var Cs=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]),bu=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]),ks=64,yu=4,$o=4096,dc=65536,Eu=127;function xu(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=Cu(r);let o=r-1,s=new Uint32Array(r),a=[],i=-1>>>0;for(let l=n*16-16;l>=0;l-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[l+h])^Cs[m>>>23];if(m=m>>>0,m===i)a[a.length-1].ptr=l+16;else{i=m;let h=m&o;a.push({ptr:l+16,val:m}),s[h]++}}let c=new Map;for(let l of a){let m=l.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(l)}for(let[l,m]of c){if(m.length<=ks)continue;let h=[],p=m.length/ks;for(let g=0;g<ks;g++)h.push(m[Math.floor(g*p)]);c.set(l,h),s[l]=ks}let f=new Uint32Array(r+1),d=[],u=0;for(let l=0;l<r;l++){f[l]=u;let m=c.get(l);if(m){for(let h of m)d.push(h);u+=m.length}}return f[r]=u,{src:e,hashMask:o,buckets:f,entries:d}}function ku(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,a=new Uint8Array(Math.max(o,1024)),i=0;function c(p){for(;i+p>a.length;){let g=new Uint8Array(a.length*2);g.set(a),a=g}}i=uc(a,i,r),i=uc(a,i,o),c(18),i++;let f=0,d=0,u=Math.min(16,o);for(let p=0;p<u;p++)a[i++]=t[p],f=(f<<8|t[p])^Cs[f>>>23],d++;f=f>>>0;let l=u,m=0,h=0;for(;l<o;){if(h<$o){f^=bu[t[l-16]],f=((f<<8|t[l])^Cs[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let x=g;x<w;x++){let b=e.entries[x];if(b.val!==f)continue;let E=b.ptr,k=s.byteLength-E,P=o-l;if(k>P&&(k=P),k<=h)break;let C=0;for(;C<k&&s[E+C]===t[l+C];)C++;if(C>h&&(h=C,m=E,h>=$o))break}}if(h<yu)c(2),d===0&&i++,a[i++]=t[l++],d++,d===Eu&&(a[i-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[l-1];)if(h++,m--,l--,i--,!(--d>0)){i--,d=-1;break}d>0&&(a[i-d-1]=d),d=0}let p=h>dc?h-dc:0;h-=p,c(8);let g=i++,w=128;if(m&255&&(a[i++]=m&255,w|=1),m&65280&&(a[i++]=m>>>8&255,w|=2),m&16711680&&(a[i++]=m>>>16&255,w|=4),m&4278190080&&(a[i++]=m>>>24&255,w|=8),h&255&&(a[i++]=h&255,w|=16),h&65280&&(a[i++]=h>>>8&255,w|=32),a[g]=w,l+=h,m+=h,h=p,m>4294967295&&(h=0),h<$o){f=0;for(let x=-16;x<0;x++)f=(f<<8|t[l+x])^Cs[f>>>23];f=f>>>0}}if(n&&i>n)return null}return d>0&&(a[i-d-1]=d),n&&i>n?null:a.subarray(0,i)}var lc={blob:0,tree:1,commit:2,tag:3};function mc(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let u=lc[f.type]??99,l=lc[d.type]??99;return u!==l?u-l:d.content.byteLength-f.content.byteLength}),s=new Map,a=[],i=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],u={hash:d.hash,type:d.type,content:d.content,depth:0},l=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==d.type||(s.get(g.hash)?.depth??0)>=r||d.content.byteLength<g.content.byteLength>>>5)continue;let b=i[p-h]??null;if(!b)continue;let E=l?l.byteLength:d.content.byteLength/2|0;if(E<16)continue;let k=ku(b,d.content,E);k&&(!l||k.byteLength<l.byteLength)&&(l=k,m=g.hash)}if(l&&m){u.delta=l,u.deltaBase=m;let p=s.get(m);u.depth=(p?.depth??0)+1}s.set(d.hash,u),a.push(u),i.length>=n&&(i.shift(),c.shift()),i.push(xu(d.content)),c.push(d.hash)}return a}function Cu(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 uc(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}async function Pu(e,t){let n=new Set,r=H(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let a of s){if(!a.endsWith(".idx"))continue;let i=await e.fs.readFileBuffer(H(r,a)),c=new hn(i);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?ms(e,t,[]):(await ms(e,t,[])).filter(s=>!n.has(s.hash))}async function To(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,a=e.depth??50;if(r.length===0)return null;let i=e.all?await ms(t,r,[]):await Pu(t,r);if(i.length===0)return null;let c=i.length,f=mc(i,{window:s,depth:a}),d=f.filter(P=>P.delta).length,u=f.map(P=>({hash:P.hash,type:P.type,content:P.content,delta:P.delta,deltaBaseHash:P.deltaBase})),{data:l,entries:m}=await pi(u),h=await Ei(l,m),p=l.subarray(l.byteLength-20),g="";for(let P=0;P<20;P++){let C=p[P];g+=(C>>4).toString(16)+(C&15).toString(16)}let w=H(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let x=`pack-${g}`,b=H(w,`${x}.pack`),E=H(w,`${x}.idx`);await n.writeFile(b,l),await n.writeFile(E,h);let k=new Set(f.map(P=>P.hash));if(o){let P=await n.readdir(w);for(let y of P){if(!y.endsWith(".idx"))continue;let I=y.slice(0,-4);if(I===x)continue;let A=H(w,`${I}.idx`),L=!0;try{let D=await n.readFileBuffer(A),z=new hn(D);for(let M of z.allHashes())if(!k.has(M)){L=!1;break}}catch{L=!1}if(L){try{await n.rm(H(w,`${I}.pack`))}catch{}try{await n.rm(A)}catch{}}}let C=H(t.gitDir,"objects"),O;try{O=await n.readdir(C)}catch{O=[]}for(let y of O){if(y==="pack"||y==="info"||y.length!==2)continue;let I=H(C,y),A;try{A=await n.readdir(I)}catch{continue}for(let L of A){let D=`${y}${L}`;k.has(D)&&await n.rm(H(I,L))}try{(await n.readdir(I)).length===0&&await n.rm(I,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function Ho(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(`
346
- `)}function hc(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:v().alias("a").describe("Pack all objects, including already-packed"),delete:v().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await cc(s),i=await To({gitCtx:s,fs:r.fs,tips:a,cleanup:n.delete,all:n.all});return i?{stdout:"",stderr:`${Ho(i.totalCount,i.deltaCount)}
380
+ `:""}async function li(e,t){if(!t.newHash)return"";if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path),r=await Ir(e.fs,n);return di.decode(r)}return le(e,t.newHash)}async function Tm(e,t){if(!t.newHash)return new Uint8Array(0);if(t.newFromWorkTree&&e.workTree){let n=H(e.workTree,t.path);return Ir(e.fs,n)}return gt(e,t.newHash)}function Qc(e,t){let n=Rn(e),r=Rn(t),o=yt(n,r),s=0,a=0;for(let i of o)i.type==="insert"?s++:i.type==="delete"&&a++;return{ins:s,del:a}}async function ef(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?ir(r.oldPath,r.path):r.path,s=r.oldHash?await gt(e,r.oldHash):new Uint8Array(0),a=await Tm(e,r);if(pn(s)||pn(a))n.push({path:o,sortKey:r.path,insertions:0,deletions:0,isBinary:!0,oldSize:s.byteLength,newSize:a.byteLength});else{let i=di.decode(s),c=di.decode(a),{ins:f,del:d}=Qc(i,c);n.push({path:o,sortKey:r.path,insertions:f,deletions:d})}}return n}ee();ln();fe();Me();ue();function Vn(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 Hm(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 eo(e,t){if(!Hm(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),a=s.length>0?t.length-s.length:t.length,i=t.slice(o.length,a);return r===-1?e.dst:e.dst.slice(0,r)+i+e.dst.slice(r+1)}function tf(e,t){e.command("fetch",{description:"Download objects and refs from another repository",args:[B.string().name("remote").describe("Remote to fetch from").optional(),B.string().name("refspec").describe("Refspec(s) to fetch").optional().variadic()],options:{all:A().describe("Fetch from all remotes"),prune:A().alias("p").describe("Remove stale remote-tracking refs"),tags:A().describe("Also fetch tags")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.remote||"origin",i;try{i=await lr(s,a,r.env)}catch(y){let I=y instanceof Error?y.message:"";if(I.startsWith("network"))return T(I);throw y}if(!i)return T(`'${a}' does not appear to be a git repository`);let{transport:c,config:f}=i,d=n.refspec,u;if(d&&d.length>0?u=d.map(Vn):u=[Vn(f.fetchRefspec)],t?.hooks){let y=await t.hooks.emitPre("pre-fetch",{remote:a,url:f.url,refspecs:u.map(I=>`${I.src}:${I.dst}`),prune:n.prune,tags:n.tags});if(y)return{stdout:"",stderr:y.message??"",exitCode:1}}let l=await c.advertiseRefs();if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let h=(await pe(s)).map(y=>y.hash),p=await F(s,"HEAD");p&&h.push(p);let g=[],w=new Set,k=[];for(let y of l)if(y.name!=="HEAD")for(let I of u){let v=eo(I,y.name);if(v!==null){k.push({remote:y,localRef:v,force:I.force}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash));break}}if(n.tags)for(let y of l)y.name.startsWith("refs/tags/")&&(k.push({remote:y,localRef:y.name,force:!1}),w.has(y.hash)||(w.add(y.hash),g.push(y.hash)));let b=new Set(h),E=g.filter(y=>!b.has(y));E.length>0&&await c.fetch(E,h);let x=await Nt(s,r.env),P=[];P.push(`From ${f.url}
381
+ `);for(let y of k){let I=await F(s,y.localRef);await z(s,y.localRef,y.remote.hash),await _e(s,y.localRef,{oldHash:I??J,newHash:y.remote.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:I?"fetch":"fetch: storing head"});let v=to(y.remote.name),G=to(y.localRef);if(I){if(I!==y.remote.hash){let M=K(I),V=K(y.remote.hash);P.push(` ${M}..${V} ${v} -> ${G}
382
+ `)}}else{let V=y.remote.name.startsWith("refs/tags/")?" * [new tag]":" * [new branch]";P.push(`${V} ${v} -> ${G}
383
+ `)}}if(!n.tags)for(let y of l){if(!y.name.startsWith("refs/tags/")||w.has(y.hash))continue;let I=await F(s,y.name),v=y.peeledHash??y.hash;!I&&b.has(v)&&(await z(s,y.name,y.hash),await _e(s,y.name,{oldHash:J,newHash:y.hash,name:x.name,email:x.email,timestamp:x.timestamp,tz:x.tz,message:"fetch: storing head"}),P.push(` * [new tag] ${to(y.name)} -> ${to(y.name)}
384
+ `))}if(n.prune){let y=`refs/remotes/${a}`,I=await pe(s,y),v=new Set(l.filter(G=>G.name.startsWith("refs/heads/")).map(G=>G.name.slice(11)));for(let G of I){let M=G.name.slice(y.length+1);v.has(M)||(await de(s,G.name),P.push(` - [deleted] (none) -> ${a}/${M}
385
+ `))}}let C=l.find(y=>y.name==="HEAD");if(C){let y=H(s.gitDir,"FETCH_HEAD"),I=l.find(G=>G.name.startsWith("refs/heads/")&&G.hash===C.hash),v=I?`branch '${I.name.slice(11)}' of`:"of";await r.fs.writeFile(y,`${C.hash} ${v} ${f.url}
386
+ `)}let R={stdout:"",stderr:P.join(""),exitCode:0};return await t?.hooks?.emitPost("post-fetch",{remote:a,url:f.url,refsUpdated:k.length}),R}})}function to(e){return e.startsWith("refs/heads/")?e.slice(11):e.startsWith("refs/tags/")?e.slice(10):e.startsWith("refs/remotes/")?e.slice(13):e}ee();ye();re();fe();Me();ue();ee();ye();re();fe();Me();ue();async function nf(e){let t=new Set,n=await Y(e);n&&t.add(n);let r=await pe(e,"refs");for(let i of r)t.add(i.hash);let o=H(e.gitDir,"logs");await e.fs.exists(o)&&await rf(e,o,o,t);let s=await W(e);for(let i of s.entries)t.add(i.hash);for(let i of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let c=await F(e,i);c&&t.add(c)}let a=[];for(let i of t)await hn(e,i)&&a.push(i);return a}async function rf(e,t,n,r){let o=await e.fs.readdir(t);for(let s of o){let a=H(t,s),i=await e.fs.stat(a);if(i.isDirectory)await rf(e,a,n,r);else if(i.isFile){let c=a.slice(n.length+1),f=await Ve(e,c);for(let d of f)d.newHash!==J&&r.add(d.newHash)}}}var ro=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]),Am=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),no=64,vm=4,ui=4096,sf=65536,Sm=127;function Dm(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=jm(r);let o=r-1,s=new Uint32Array(r),a=[],i=-1>>>0;for(let l=n*16-16;l>=0;l-=16){let m=0;for(let h=1;h<=16;h++)m=(m<<8|e[l+h])^ro[m>>>23];if(m=m>>>0,m===i)a[a.length-1].ptr=l+16;else{i=m;let h=m&o;a.push({ptr:l+16,val:m}),s[h]++}}let c=new Map;for(let l of a){let m=l.val&o,h=c.get(m);h||(h=[],c.set(m,h)),h.push(l)}for(let[l,m]of c){if(m.length<=no)continue;let h=[],p=m.length/no;for(let g=0;g<no;g++)h.push(m[Math.floor(g*p)]);c.set(l,h),s[l]=no}let f=new Uint32Array(r+1),d=[],u=0;for(let l=0;l<r;l++){f[l]=u;let m=c.get(l);if(m){for(let h of m)d.push(h);u+=m.length}}return f[r]=u,{src:e,hashMask:o,buckets:f,entries:d}}function Mm(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,a=new Uint8Array(Math.max(o,1024)),i=0;function c(p){for(;i+p>a.length;){let g=new Uint8Array(a.length*2);g.set(a),a=g}}i=af(a,i,r),i=af(a,i,o),c(18),i++;let f=0,d=0,u=Math.min(16,o);for(let p=0;p<u;p++)a[i++]=t[p],f=(f<<8|t[p])^ro[f>>>23],d++;f=f>>>0;let l=u,m=0,h=0;for(;l<o;){if(h<ui){f^=Am[t[l-16]],f=((f<<8|t[l])^ro[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let k=g;k<w;k++){let b=e.entries[k];if(b.val!==f)continue;let E=b.ptr,x=s.byteLength-E,P=o-l;if(x>P&&(x=P),x<=h)break;let C=0;for(;C<x&&s[E+C]===t[l+C];)C++;if(C>h&&(h=C,m=E,h>=ui))break}}if(h<vm)c(2),d===0&&i++,a[i++]=t[l++],d++,d===Sm&&(a[i-d-1]=d,d=0),h=0;else{if(d>0){for(;m>0&&s[m-1]===t[l-1];)if(h++,m--,l--,i--,!(--d>0)){i--,d=-1;break}d>0&&(a[i-d-1]=d),d=0}let p=h>sf?h-sf:0;h-=p,c(8);let g=i++,w=128;if(m&255&&(a[i++]=m&255,w|=1),m&65280&&(a[i++]=m>>>8&255,w|=2),m&16711680&&(a[i++]=m>>>16&255,w|=4),m&4278190080&&(a[i++]=m>>>24&255,w|=8),h&255&&(a[i++]=h&255,w|=16),h&65280&&(a[i++]=h>>>8&255,w|=32),a[g]=w,l+=h,m+=h,h=p,m>4294967295&&(h=0),h<ui){f=0;for(let k=-16;k<0;k++)f=(f<<8|t[l+k])^ro[f>>>23];f=f>>>0}}if(n&&i>n)return null}return d>0&&(a[i-d-1]=d),n&&i>n?null:a.subarray(0,i)}var of={blob:0,tree:1,commit:2,tag:3};function cf(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,d)=>{let u=of[f.type]??99,l=of[d.type]??99;return u!==l?u-l:d.content.byteLength-f.content.byteLength}),s=new Map,a=[],i=[],c=[];for(let f=0;f<o.length;f++){let d=o[f],u={hash:d.hash,type:d.type,content:d.content,depth:0},l=null,m=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==d.type||(s.get(g.hash)?.depth??0)>=r||d.content.byteLength<g.content.byteLength>>>5)continue;let b=i[p-h]??null;if(!b)continue;let E=l?l.byteLength:d.content.byteLength/2|0;if(E<16)continue;let x=Mm(b,d.content,E);x&&(!l||x.byteLength<l.byteLength)&&(l=x,m=g.hash)}if(l&&m){u.delta=l,u.deltaBase=m;let p=s.get(m);u.depth=(p?.depth??0)+1}s.set(d.hash,u),a.push(u),i.length>=n&&(i.shift(),c.shift()),i.push(Dm(d.content)),c.push(d.hash)}return a}function jm(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 af(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}as();yr();fe();async function Gm(e,t){let n=new Set,r=H(e.gitDir,"objects","pack");try{let s=await e.fs.readdir(r);for(let a of s){if(!a.endsWith(".idx"))continue;let i=await e.fs.readFileBuffer(H(r,a)),c=new Mn(i);for(let f of c.allHashes())n.add(f)}}catch{}return n.size===0?zs(e,t,[]):(await zs(e,t,[])).filter(s=>!n.has(s.hash))}async function mi(e){let{gitCtx:t,fs:n,tips:r,cleanup:o}=e,s=e.window??10,a=e.depth??50;if(r.length===0)return null;let i=e.all?await zs(t,r,[]):await Gm(t,r);if(i.length===0)return null;let c=i.length,f=cf(i,{window:s,depth:a}),d=f.filter(P=>P.delta).length,u=f.map(P=>({hash:P.hash,type:P.type,content:P.content,delta:P.delta,deltaBaseHash:P.deltaBase})),{data:l,entries:m}=await ea(u),h=await oa(l,m),p=l.subarray(l.byteLength-20),g="";for(let P=0;P<20;P++){let C=p[P];g+=(C>>4).toString(16)+(C&15).toString(16)}let w=H(t.gitDir,"objects","pack");await n.mkdir(w,{recursive:!0});let k=`pack-${g}`,b=H(w,`${k}.pack`),E=H(w,`${k}.idx`);await n.writeFile(b,l),await n.writeFile(E,h);let x=new Set(f.map(P=>P.hash));if(o){let P=await n.readdir(w);for(let y of P){if(!y.endsWith(".idx"))continue;let I=y.slice(0,-4);if(I===k)continue;let v=H(w,`${I}.idx`),G=!0;try{let M=await n.readFileBuffer(v),V=new Mn(M);for(let j of V.allHashes())if(!x.has(j)){G=!1;break}}catch{G=!1}if(G){try{await n.rm(H(w,`${I}.pack`))}catch{}try{await n.rm(v)}catch{}}}let C=H(t.gitDir,"objects"),R;try{R=await n.readdir(C)}catch{R=[]}for(let y of R){if(y==="pack"||y==="info"||y.length!==2)continue;let I=H(C,y),v;try{v=await n.readdir(I)}catch{continue}for(let G of v){let M=`${y}${G}`;x.has(M)&&await n.rm(H(I,G))}try{(await n.readdir(I)).length===0&&await n.rm(I,{recursive:!0})}catch{}}}return{totalCount:c,deltaCount:d,packHash:g}}function hi(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(`
387
+ `)}function ff(e,t){e.command("repack",{description:"Pack unpacked objects in a repository",options:{all:A().alias("a").describe("Pack all objects, including already-packed"),delete:A().alias("d").describe("After packing, remove redundant packs and loose objects")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await nf(s),i=await mi({gitCtx:s,fs:r.fs,tips:a,cleanup:n.delete,all:n.all});return i?{stdout:"",stderr:`${hi(i.totalCount,i.deltaCount)}
347
388
  `,exitCode:0}:{stdout:`Nothing new to pack.
348
- `,stderr:"",exitCode:0}}})}function pc(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:v().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;await Pi(s),await tt(s);let a=await Iu(s);if(a.length>0){let i=n.aggressive?250:10,c=n.aggressive?250:50,f=await To({gitCtx:s,fs:r.fs,tips:a,window:i,depth:c,cleanup:!0,all:!0});if(await Ru(s.gitDir,r.fs),f)return{stdout:"",stderr:`${Ho(f.totalCount,f.deltaCount,!0)}
349
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Ou=2160*60*60;async function Iu(e){let t=new Set,n=await X(e);n&&t.add(n);let r=await le(e,"refs");for(let f of r)t.add(f.hash);let s=Math.floor(Date.now()/1e3)-Ou,a=H(e.gitDir,"logs");await e.fs.exists(a)&&await gc(e,a,a,s,t);let i=await U(e);for(let f of i.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let d=await F(e,f);d&&t.add(d)}let c=[];for(let f of t)await Vt(e,f)&&c.push(f);return c}async function gc(e,t,n,r,o){let s=await e.fs.readdir(t);for(let a of s){let i=H(t,a),c=await e.fs.stat(i);if(c.isDirectory){await gc(e,i,n,r,o);try{(await e.fs.readdir(i)).length===0&&await e.fs.rm(i,{recursive:!0})}catch{}}else if(c.isFile){let f=i.slice(n.length+1),d=await Me(e,f);if(f==="refs/stash"){for(let l of d)l.newHash!==Z&&o.add(l.newHash);continue}let u=d.filter(l=>l.timestamp>=r);await Zt(e,f,u);for(let l of u)l.newHash!==Z&&o.add(l.newHash)}}}async function Ru(e,t){let n=H(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(H(n,o),{recursive:!0})}catch{}}function wc(e){e.command("init",{description:"Initialize a new repository",args:[W.string().name("directory").describe("The directory to initialize").optional()],options:{bare:v().describe("Create a bare repository"),initialBranch:te.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(t,n)=>{let r=t.initialBranch,o=t.directory?ft(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:a}=await Dr(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),i="";a&&r&&(i=`warning: re-init: ignored --initial-branch=${r}
389
+ `,stderr:"",exitCode:0}}})}function df(e,t){e.command("gc",{description:"Cleanup unnecessary files and optimize the local repository",options:{aggressive:A().describe("More aggressively optimize the repository")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;await la(s),await lt(s);let a=await Nm(s);if(a.length>0){let i=n.aggressive?250:10,c=n.aggressive?250:50,f=await mi({gitCtx:s,fs:r.fs,tips:a,window:i,depth:c,cleanup:!0,all:!0});if(await _m(s.gitDir,r.fs),f)return{stdout:"",stderr:`${hi(f.totalCount,f.deltaCount,!0)}
390
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}})}var Lm=2160*60*60;async function Nm(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)-Lm,a=H(e.gitDir,"logs");await e.fs.exists(a)&&await lf(e,a,a,s,t);let i=await W(e);for(let f of i.entries)t.add(f.hash);for(let f of["MERGE_HEAD","CHERRY_PICK_HEAD","ORIG_HEAD"]){let d=await F(e,f);d&&t.add(d)}let c=[];for(let f of t)await hn(e,f)&&c.push(f);return c}async function lf(e,t,n,r,o){let s=await e.fs.readdir(t);for(let a of s){let i=H(t,a),c=await e.fs.stat(i);if(c.isDirectory){await lf(e,i,n,r,o);try{(await e.fs.readdir(i)).length===0&&await e.fs.rm(i,{recursive:!0})}catch{}}else if(c.isFile){let f=i.slice(n.length+1),d=await Ve(e,f);if(f==="refs/stash"){for(let l of d)l.newHash!==J&&o.add(l.newHash);continue}let u=d.filter(l=>l.timestamp>=r);await wn(e,f,u);for(let l of u)l.newHash!==J&&o.add(l.newHash)}}}async function _m(e,t){let n=H(e,"objects"),r;try{r=await t.readdir(n)}catch{return}for(let o of r)if(!(o==="pack"||o==="info"||o.length!==2))try{await t.rm(H(n,o),{recursive:!0})}catch{}}fe();jn();function uf(e){e.command("init",{description:"Initialize a new repository",args:[B.string().name("directory").describe("The directory to initialize").optional()],options:{bare:A().describe("Create a bare repository"),initialBranch:Q.string().alias("b").describe("Name for the initial branch")},examples:["git init","git init --bare","git init my-project"],handler:async(t,n)=>{let r=t.initialBranch,o=t.directory?xt(n.cwd,t.directory):n.cwd;t.directory&&await n.fs.mkdir(o,{recursive:!0});let{ctx:s,reinit:a}=await ls(n.fs,o,{bare:t.bare,...r?{initialBranch:r}:{}}),i="";a&&r&&(i=`warning: re-init: ignored --initial-branch=${r}
350
391
  `);let c=t.bare?"bare ":"";return{stdout:`${a?"Reinitialized existing":"Initialized empty"} ${c}Git repository in ${s.gitDir}/
351
- `,stderr:i,exitCode:0}}})}function bc(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let a=e[s+1];if(a===void 0){o+="%",s++;continue}if((a==="a"||a==="c")&&s+2<e.length){let i=e[s+2],c=a==="a"?r.author:r.committer;switch(i){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+=Du(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Mu(c.timestamp,c.timezone),s+=3;continue;case"d":o+=vt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=ju(c.timestamp,c.timezone),s+=3;continue}}switch(a){case"H":o+=n,s+=2;continue;case"h":o+=K(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=K(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(K).join(" "),s+=2;continue;case"s":o+=Ao(r.message),s+=2;continue;case"b":o+=$u(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let i=t.decorations(n);o+=i?` ${i}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
352
- `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${a}`,s+=2;continue}}o+=e[s],s++}return o}var Ao=ue;function $u(e){let t=e.indexOf(`
392
+ `,stderr:i,exitCode:0}}})}ee();rr();ee();function mf(e,t){let{hash:n,commit:r}=t,o="",s=0;for(;s<e.length;){if(e[s]==="%"){let a=e[s+1];if(a===void 0){o+="%",s++;continue}if((a==="a"||a==="c")&&s+2<e.length){let i=e[s+2],c=a==="a"?r.author:r.committer;switch(i){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+=zm(c.timestamp,c.timezone),s+=3;continue;case"i":o+=Vm(c.timestamp,c.timezone),s+=3;continue;case"d":o+=Vt(c.timestamp,c.timezone),s+=3;continue;case"D":o+=Ym(c.timestamp,c.timezone),s+=3;continue}}switch(a){case"H":o+=n,s+=2;continue;case"h":o+=K(n),s+=2;continue;case"T":o+=r.tree,s+=2;continue;case"t":o+=K(r.tree),s+=2;continue;case"P":o+=r.parents.join(" "),s+=2;continue;case"p":o+=r.parents.map(K).join(" "),s+=2;continue;case"s":o+=pi(r.message),s+=2;continue;case"b":o+=Fm(r.message),s+=2;continue;case"B":o+=r.message.replace(/\n$/,""),s+=2;continue;case"d":if(t.decorations){let i=t.decorations(n);o+=i?` ${i}`:""}s+=2;continue;case"D":t.decorationsRaw&&(o+=t.decorationsRaw(n)),s+=2;continue;case"n":o+=`
393
+ `,s+=2;continue;case"%":o+="%",s+=2;continue;default:o+=`%${a}`,s+=2;continue}}o+=e[s],s++}return o}var pi=se;function Fm(e){let t=e.indexOf(`
353
394
 
354
- `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function yc(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"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function Ec(e,t,n,r=!1){let{hash:o,commit:s}=t,a=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let i=r?K(o):o,c=Ao(s.message);return a?`${i} ${a} ${c}`:`${i} ${c}`}case"short":{let i=[];return n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(K).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(""),i.push(` ${Ao(s.message)}`),i.join(`
395
+ `);return t===-1?"":e.slice(t+2).replace(/\n$/,"")}function hf(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"].includes(e)?{formatStr:null,preset:e}:{formatStr:e,preset:null}}function pf(e,t,n,r=!1){let{hash:o,commit:s}=t,a=t.decorations?t.decorations(o):"";switch(e){case"oneline":{let i=r?K(o):o,c=pi(s.message);return a?`${i} ${a} ${c}`:`${i} ${c}`}case"short":{let i=[];return n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(K).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(""),i.push(` ${pi(s.message)}`),i.join(`
355
396
  `)}case"full":{let i=[];n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(K).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(`Commit: ${s.committer.name} <${s.committer.email}>`),i.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
356
397
  `))i.push(` ${f}`);return i.join(`
357
- `)}case"fuller":{let i=[];n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(K).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(`AuthorDate: ${vt(s.author.timestamp,s.author.timezone)}`),i.push(`Commit: ${s.committer.name} <${s.committer.email}>`),i.push(`CommitDate: ${vt(s.committer.timestamp,s.committer.timezone)}`),i.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
398
+ `)}case"fuller":{let i=[];n||i.push(""),i.push(a?`commit ${o} ${a}`:`commit ${o}`),s.parents.length>=2&&i.push(`Merge: ${s.parents.map(K).join(" ")}`),i.push(`Author: ${s.author.name} <${s.author.email}>`),i.push(`AuthorDate: ${Vt(s.author.timestamp,s.author.timezone)}`),i.push(`Commit: ${s.committer.name} <${s.committer.email}>`),i.push(`CommitDate: ${Vt(s.committer.timestamp,s.committer.timezone)}`),i.push("");let c=s.message.replace(/\n$/,"");for(let f of c.split(`
358
399
  `))i.push(` ${f}`);return i.join(`
359
- `)}default:return Tu(t,n)}}function Tu(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(K).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${vt(r.author.timestamp,r.author.timezone)}`),s.push("");let a=r.message.replace(/\n$/,"");for(let i of a.split(`
400
+ `)}default:return Um(t,n)}}function Um(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(K).join(" ")}`),s.push(`Author: ${r.author.name} <${r.author.email}>`),s.push(`Date: ${Vt(r.author.timestamp,r.author.timezone)}`),s.push("");let a=r.message.replace(/\n$/,"");for(let i of a.split(`
360
401
  `))s.push(` ${i}`);return s.join(`
361
- `)}var Hu=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Au=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vu(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 vo(e,t){let n=vu(t);return new Date((e+n*60)*1e3)}function Su(e){return`${e.slice(0,3)}:${e.slice(3)}`}function Du(e,t){let n=vo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${a}:${i}:${c}${Su(t)}`}function Mu(e,t){let n=vo(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${a}:${i}:${c} ${t}`}function ju(e,t){let n=vo(e,t),r=Hu[n.getUTCDay()]?.slice(0,3),o=Au[n.getUTCMonth()],s=n.getUTCDate(),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${a}:${i}:${c} ${t}`}function Cc(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[W.string().name("revisions").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of commits to output"),oneline:v().describe("Condense each commit to a single line"),all:v().describe("Walk all refs, not just HEAD"),author:te.string().describe("Filter by author (regex or substring)"),grep:te.string().describe("Filter by commit message (regex or substring)"),since:te.string().describe("Show commits after date"),after:te.string().describe("Synonym for --since"),until:te.string().describe("Show commits before date"),before:te.string().describe("Synonym for --until"),decorate:v().describe("Show ref names next to commit hashes"),reverse:v().describe("Output commits in reverse order"),format:te.string().describe("Pretty-print format string"),pretty:te.string().describe("Pretty-print format or preset name")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i,c,f=n.revisions,d=f&&f.length===1?bs(f[0]):null;if(d){let R=async oe=>{let Q=await je(a,oe);if(!Q)return xt(oe);try{return await Ie(a,Q)}catch{return xt(oe)}},_=await R(d.left);if(typeof _=="object"&&"exitCode"in _)return _;let q=await R(d.right);if(typeof q=="object"&&"exitCode"in q)return q;let N=_,V=q;if(d.type==="two-dot")i=[V],c=[N];else{i=[N,V];let oe=await gt(a,N,V);c=oe.length>0?oe:void 0}if(n.all){let oe=await le(a);for(let ge of oe)try{let De=await Ie(a,ge.hash);i.includes(De)||i.push(De)}catch{}let Q=await X(a);Q&&!i.includes(Q)&&i.push(Q)}}else if(n.all){let R=await le(a),_=new Set;for(let N of R)try{_.add(await Ie(a,N.hash))}catch{}let q=await X(a);q&&_.add(q),i=[..._]}else if(f&&f.length>0){let R=[];for(let _ of f){let q=await je(a,_);if(!q)return xt(_);try{R.push(await Ie(a,q))}catch{return xt(_)}}i=R}else{let R=await Se(a);if(S(R))return R;i=[R]}if(i.length===0)return T("your current branch does not have any commits yet");let u=o.passthrough.length>0?o.passthrough.map(R=>Oe(R,"")):null,l=n.author?xc(n.author):null,m=n.grep?xc(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?io(h):null,w=p?io(p):null,x=n.format??n.pretty,b=null,E=null,k=!1;if(n.oneline)E="oneline",k=!0;else if(x!==void 0){let R=yc(x);b=R.formatStr,E=R.preset}let C=n.decorate||b!=null&&(b.includes("%d")||b.includes("%D"))?await Nu(a):null,O=C?R=>kc(C,R):void 0,y=C?R=>{let _=kc(C,R);return _.startsWith("(")&&_.endsWith(")")?_.slice(1,-1):_}:void 0,I=n.maxCount,A=n.reverse,L=u?Gu(a,i,u,c?await Lu(a,c):void 0):En(a,i,{exclude:c}),D=[];for await(let R of L){if(I!==void 0&&D.length>=I)break;let{commit:_}=R;if(!(w!==null&&_.committer.timestamp>w)&&!(g!==null&&_.committer.timestamp<=g)){if(l){let q=`${_.author.name} <${_.author.email}>`;if(!l(q))continue}m&&!m(_.message)||D.push(R)}}let z=A?D.reverse():D;if(b!==null){let R=[];for(let _ of z){let q={hash:_.hash,commit:_.commit,decorations:O,decorationsRaw:y};R.push(bc(b,q))}return{stdout:R.length>0?`${R.join(`
402
+ `)}var Bm=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Wm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qm(e){let t=e.startsWith("-")?-1:1,n=e.replace(/^[+-]/,""),r=parseInt(n.slice(0,2),10)||0,o=parseInt(n.slice(2,4),10)||0;return t*(r*60+o)}function gi(e,t){let n=qm(t);return new Date((e+n*60)*1e3)}function Km(e){return`${e.slice(0,3)}:${e.slice(3)}`}function zm(e,t){let n=gi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s}T${a}:${i}:${c}${Km(t)}`}function Vm(e,t){let n=gi(e,t),r=n.getUTCFullYear(),o=String(n.getUTCMonth()+1).padStart(2,"0"),s=String(n.getUTCDate()).padStart(2,"0"),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0");return`${r}-${o}-${s} ${a}:${i}:${c} ${t}`}function Ym(e,t){let n=gi(e,t),r=Bm[n.getUTCDay()]?.slice(0,3),o=Wm[n.getUTCMonth()],s=n.getUTCDate(),a=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),c=String(n.getUTCSeconds()).padStart(2,"0"),f=n.getUTCFullYear();return`${r}, ${s} ${o} ${f} ${a}:${i}:${c} ${t}`}re();ue();en();Ie();function bf(e,t){e.command("log",{description:"Show commit logs",transformArgs:n=>n.map(r=>/^-(\d+)$/.test(r)?`-n${r.slice(1)}`:r),args:[B.string().name("revisions").variadic().optional()],options:{maxCount:Q.number().alias("n").describe("Limit the number of commits to output"),oneline:A().describe("Condense each commit to a single line"),all:A().describe("Walk all refs, not just HEAD"),author:Q.string().describe("Filter by author (regex or substring)"),grep:Q.string().describe("Filter by commit message (regex or substring)"),since:Q.string().describe("Show commits after date"),after:Q.string().describe("Synonym for --since"),until:Q.string().describe("Show commits before date"),before:Q.string().describe("Synonym for --until"),decorate:A().describe("Show ref names next to commit hashes"),reverse:A().describe("Output commits in reverse order"),format:Q.string().describe("Pretty-print format string"),pretty:Q.string().describe("Pretty-print format or preset name")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i,c,f=n.revisions,d=f&&f.length===1?Js(f[0]):null;if(d){let O=async ce=>{let te=await Fe(a,ce);if(!te)return Mt(ce);try{return await Ge(a,te)}catch{return Mt(ce)}},_=await O(d.left);if(typeof _=="object"&&"exitCode"in _)return _;let q=await O(d.right);if(typeof q=="object"&&"exitCode"in q)return q;let N=_,X=q;if(d.type==="two-dot")i=[X],c=[N];else{i=[N,X];let ce=await vt(a,N,X);c=ce.length>0?ce:void 0}if(n.all){let ce=await pe(a);for(let xe of ce)try{let ze=await Ge(a,xe.hash);i.includes(ze)||i.push(ze)}catch{}let te=await Y(a);te&&!i.includes(te)&&i.push(te)}}else if(n.all){let O=await pe(a),_=new Set;for(let N of O)try{_.add(await Ge(a,N.hash))}catch{}let q=await Y(a);q&&_.add(q),i=[..._]}else if(f&&f.length>0){let O=[];for(let _ of f){let q=await Fe(a,_);if(!q)return Mt(_);try{O.push(await Ge(a,q))}catch{return Mt(_)}}i=O}else{let O=await Ke(a);if(S(O))return O;i=[O]}if(i.length===0)return T("your current branch does not have any commits yet");let u=o.passthrough.length>0?o.passthrough.map(O=>je(O,"")):null,l=n.author?gf(n.author):null,m=n.grep?gf(n.grep):null,h=n.since??n.after,p=n.until??n.before,g=h?Jo(h):null,w=p?Jo(p):null,k=n.format??n.pretty,b=null,E=null,x=!1;if(n.oneline)E="oneline",x=!0;else if(k!==void 0){let O=hf(k);b=O.formatStr,E=O.preset}let C=n.decorate||b!=null&&(b.includes("%d")||b.includes("%D"))?await Jm(a):null,R=C?O=>wf(C,O):void 0,y=C?O=>{let _=wf(C,O);return _.startsWith("(")&&_.endsWith(")")?_.slice(1,-1):_}:void 0,I=n.maxCount,v=n.reverse,G=u?Zm(a,i,u,c?await Xm(a,c):void 0):Kt(a,i,{exclude:c}),M=[];for await(let O of G){if(I!==void 0&&M.length>=I)break;let{commit:_}=O;if(!(w!==null&&_.committer.timestamp>w)&&!(g!==null&&_.committer.timestamp<=g)){if(l){let q=`${_.author.name} <${_.author.email}>`;if(!l(q))continue}m&&!m(_.message)||M.push(O)}}let V=v?M.reverse():M;if(b!==null){let O=[];for(let _ of V){let q={hash:_.hash,commit:_.commit,decorations:R,decorationsRaw:y};O.push(mf(b,q))}return{stdout:O.length>0?`${O.join(`
362
403
  `)}
363
- `:"",stderr:"",exitCode:0}}let M=E??"medium",$=[];for(let R=0;R<z.length;R++){let _=z[R],q={hash:_.hash,commit:_.commit,decorations:O,decorationsRaw:y};$.push(Ec(M,q,R===0,k))}return{stdout:$.length>0?`${$.join(`
404
+ `:"",stderr:"",exitCode:0}}let j=E??"medium",$=[];for(let O=0;O<V.length;O++){let _=V[O],q={hash:_.hash,commit:_.commit,decorations:R,decorationsRaw:y};$.push(pf(j,q,O===0,x))}return{stdout:$.length>0?`${$.join(`
364
405
  `)}
365
- `:"",stderr:"",exitCode:0}}})}async function Lu(e,t){let n=new Set;for await(let r of En(e,t))n.add(r.hash);return n}function xc(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Gu(e,t,n,r){let o=new Set(r),s=new Nn,a=async i=>{if(!o.has(i)){let c=await j(e,i);s.push({hash:i,commit:c})}};for(let i of t)await a(i);for(;s.size>0;){let i=s.pop();if(o.has(i.hash))continue;o.add(i.hash);let{commit:c}=i,f=c.parents;if(f.length===0){(await Ae(e,null,c.tree)).some(l=>me(n,l.path))&&(yield i);continue}if(f.length===1){let u=f[0];if(u){let l=await j(e,u);(await Ae(e,l.tree,c.tree)).some(h=>me(n,h.path))&&(yield i),await a(u)}continue}let d=[];for(let u of f){let l=await j(e,u);(await Ae(e,l.tree,c.tree)).some(h=>me(n,h.path))||d.push(u)}if(d.length>0&&d[0])await a(d[0]);else{yield i;for(let u of f)await a(u)}}}async function Nu(e){let t=await J(e),n=t?.type==="symbolic"?de(t.target):null,r=await X(e),o=new Map,s=(f,d,u)=>{let l=o.get(f);l||(l=[],o.set(f,l)),l.push({label:d,fullRef:u})},a=await le(e,"refs/heads");for(let f of a)s(f.hash,de(f.name),f.name);let i=await le(e,"refs/remotes");for(let f of i)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await le(e,"refs/tags");for(let f of c){let d=f.hash;try{d=await Ie(e,f.hash)}catch{}s(d,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function kc(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(i=>i.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let a=n?n.filter(i=>i!==s):[];a.sort((i,c)=>i.fullRef>c.fullRef?-1:i.fullRef<c.fullRef?1:0);for(let i of a)o.push(i.label);return o.length>0?`(${o.join(", ")})`:""}function Oc(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:v().alias("c").describe("Show cached files (default)"),modified:v().alias("m").describe("Show modified files"),deleted:v().alias("d").describe("Show deleted files"),others:v().alias("o").describe("Show other (untracked) files"),unmerged:v().alias("u").describe("Show unmerged files"),stage:v().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":v().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":v().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":v().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=Fe(a);if(i)return i;let c=a.workTree,f=n.cached,d=n.modified,u=n.deleted,l=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||d||u||l||m||(f=!0);let b=await U(a),E=g?"\0":`
366
- `,k=o.passthrough.length>0?o.passthrough.map(O=>{let y=r.cwd!==c?_u(c,r.cwd):"";return Oe(O,y)}):null,P=[];if(f)for(let O of b.entries){if(k&&!me(k,O.path))continue;let y=w?O.stage>0?"M":"H":null;P.push(Pc(O,h,y))}if(m&&!f)for(let O of b.entries)O.stage!==0&&(k&&!me(k,O.path)||P.push(Pc(O,!0,w?"M":null)));if(d||u){let O=await Fu(a,c,b);for(let{path:y,status:I}of O){if(I==="modified"&&!d||I==="deleted"&&!u||k&&!me(k,y))continue;let A=w?I==="deleted"?"R":"C":null;P.push(A?`${A} ${y}`:y)}}if(l){let O=await Uu(a,c,b,p);for(let y of O)k&&!me(k,y)||P.push(w?`? ${y}`:y)}return{stdout:P.length>0?P.join(E)+E:"",stderr:"",exitCode:0}}})}function Pc(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 _u(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function Fu(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=H(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let i=await ze(e.fs,s);if(!i.isFile&&!i.isSymbolicLink)continue;await Jt(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function Uu(e,t,n,r){let o=new Set(n.entries.map(a=>a.path));return(await _e(e,t,"",{skipIgnore:!r})).filter(a=>!o.has(a))}function Ic(e,t){e.command("merge",{description:"Join two or more development histories together",args:[W.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:v().describe("Abort the current in-progress merge"),continue:v().describe("Continue the merge after conflict resolution"),noFf:v().describe("Create a merge commit even when fast-forward is possible"),ffOnly:v().describe("Refuse to merge unless fast-forward is possible"),squash:v().describe("Apply merge result to worktree/index without creating a merge commit"),edit:v().describe("Edit the merge message (no-op, accepted for compatibility)"),message:te.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return Ku(s,r.env);if(n.continue)return qu(s,r.env,t);let a=n.branch;if(!a)return T("you must specify a branch to merge");let i=await Se(s);if(S(i))return i;let c=await U(s),f=_t(c,"Merging");if(f)return f;if(await F(s,"MERGE_HEAD"))return T(`You have not concluded your merge (MERGE_HEAD exists).
406
+ `:"",stderr:"",exitCode:0}}})}async function Xm(e,t){let n=new Set;for await(let r of Kt(e,t))n.add(r.hash);return n}function gf(e){try{let t=new RegExp(e);return n=>t.test(n)}catch{return t=>t.includes(e)}}async function*Zm(e,t,n,r){let o=new Set(r),s=new Un,a=async i=>{if(!o.has(i)){let c=await D(e,i);s.push({hash:i,commit:c})}};for(let i of t)await a(i);for(;s.size>0;){let i=s.pop();if(o.has(i.hash))continue;o.add(i.hash);let{commit:c}=i,f=c.parents;if(f.length===0){(await Be(e,null,c.tree)).some(l=>we(n,l.path))&&(yield i);continue}if(f.length===1){let u=f[0];if(u){let l=await D(e,u);(await Be(e,l.tree,c.tree)).some(h=>we(n,h.path))&&(yield i),await a(u)}continue}let d=[];for(let u of f){let l=await D(e,u);(await Be(e,l.tree,c.tree)).some(h=>we(n,h.path))||d.push(u)}if(d.length>0&&d[0])await a(d[0]);else{yield i;for(let u of f)await a(u)}}}async function Jm(e){let t=await Z(e),n=t?.type==="symbolic"?ge(t.target):null,r=await Y(e),o=new Map,s=(f,d,u)=>{let l=o.get(f);l||(l=[],o.set(f,l)),l.push({label:d,fullRef:u})},a=await pe(e,"refs/heads");for(let f of a)s(f.hash,ge(f.name),f.name);let i=await pe(e,"refs/remotes");for(let f of i)s(f.hash,f.name.replace("refs/remotes/",""),f.name);let c=await pe(e,"refs/tags");for(let f of c){let d=f.hash;try{d=await Ge(e,f.hash)}catch{}s(d,`tag: ${f.name.replace("refs/tags/","")}`,f.name)}return{headTarget:n,headHash:r,byHash:o}}function wf(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(i=>i.label===e.headTarget):null;s?o.push(`HEAD -> ${s.label}`):r&&o.push("HEAD");let a=n?n.filter(i=>i!==s):[];a.sort((i,c)=>i.fullRef>c.fullRef?-1:i.fullRef<c.fullRef?1:0);for(let i of a)o.push(i.label);return o.length>0?`(${o.join(", ")})`:""}ee();ye();fe();Gn();et();function Ef(e,t){e.command("ls-files",{description:"Show information about files in the index and the working tree",options:{cached:A().alias("c").describe("Show cached files (default)"),modified:A().alias("m").describe("Show modified files"),deleted:A().alias("d").describe("Show deleted files"),others:A().alias("o").describe("Show other (untracked) files"),unmerged:A().alias("u").describe("Show unmerged files"),stage:A().alias("s").describe("Show staged contents' mode, hash, and stage number"),"exclude-standard":A().describe("Add standard git exclusions (.gitignore, info/exclude, core.excludesFile)"),"nul-terminate":A().alias("z").describe("Use \\0 as line terminator instead of \\n"),"show-tags":A().alias("t").describe("Show status tags")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=qe(a);if(i)return i;let c=a.workTree,f=n.cached,d=n.modified,u=n.deleted,l=n.others,m=n.unmerged,h=n.stage,p=n["exclude-standard"],g=n["nul-terminate"],w=n["show-tags"];f||d||u||l||m||(f=!0);let b=await W(a),E=g?"\0":`
407
+ `,x=o.passthrough.length>0?o.passthrough.map(R=>{let y=r.cwd!==c?Qm(c,r.cwd):"";return je(R,y)}):null,P=[];if(f)for(let R of b.entries){if(x&&!we(x,R.path))continue;let y=w?R.stage>0?"M":"H":null;P.push(yf(R,h,y))}if(m&&!f)for(let R of b.entries)R.stage!==0&&(x&&!we(x,R.path)||P.push(yf(R,!0,w?"M":null)));if(d||u){let R=await eh(a,c,b);for(let{path:y,status:I}of R){if(I==="modified"&&!d||I==="deleted"&&!u||x&&!we(x,y))continue;let v=w?I==="deleted"?"R":"C":null;P.push(v?`${v} ${y}`:y)}}if(l){let R=await th(a,c,b,p);for(let y of R)x&&!we(x,y)||P.push(w?`? ${y}`:y)}return{stdout:P.length>0?P.join(E)+E:"",stderr:"",exitCode:0}}})}function yf(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 Qm(e,t){return t===e?"":t.startsWith(`${e}/`)?t.slice(e.length+1):""}async function eh(e,t,n){let r=[];for(let o of n.entries){if(o.stage!==0)continue;let s=H(t,o.path);if(!await e.fs.exists(s)){r.push({path:o.path,status:"deleted"});continue}let i=await st(e.fs,s);if(!i.isFile&&!i.isSymbolicLink)continue;await bn(e.fs,s)!==o.hash&&r.push({path:o.path,status:"modified"})}return r}async function th(e,t,n,r){let o=new Set(n.entries.map(a=>a.path));return(await Qe(e,t,"",{skipIgnore:!r})).filter(a=>!o.has(a))}ee();ye();re();Me();ue();en();Ie();function kf(e,t){e.command("merge",{description:"Join two or more development histories together",args:[B.string().name("branch").describe("Branch to merge into the current branch").optional()],options:{abort:A().describe("Abort the current in-progress merge"),continue:A().describe("Continue the merge after conflict resolution"),noFf:A().describe("Create a merge commit even when fast-forward is possible"),ffOnly:A().describe("Refuse to merge unless fast-forward is possible"),squash:A().describe("Apply merge result to worktree/index without creating a merge commit"),edit:A().describe("Edit the merge message (no-op, accepted for compatibility)"),message:Q.string().alias("m").describe("Merge commit message")},transformArgs:n=>n.filter(r=>r!=="--ff"),handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return oh(s,r.env);if(n.continue)return sh(s,r.env,t);let a=n.branch;if(!a)return T("you must specify a branch to merge");let i=await Ke(s);if(S(i))return i;let c=await W(s),f=sn(c,"Merging");if(f)return f;if(await F(s,"MERGE_HEAD"))return T(`You have not concluded your merge (MERGE_HEAD exists).
367
408
  Please, commit your changes before you merge.`);if(await F(s,"CHERRY_PICK_HEAD"))return T(`You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).
368
- Please, commit your changes before you merge.`);let l=await je(s,a);if(!l)return G(`merge: ${a} - not something we can merge
369
- `);let m=await Ie(s,l),h=await gt(s,i,m),p=h[0]??null;if(h.length===0)return T("refusing to merge unrelated histories");if(p===m)return{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
370
- `,stderr:"",exitCode:0};if(n.noFf&&n.ffOnly)return T("--no-ff and --ff-only are incompatible");let g=p===i&&!n.noFf;if(n.ffOnly&&!g)return G(`hint: Diverging branches can't be fast-forwarded, you need to either:
409
+ Please, commit your changes before you merge.`);let l=await Fe(s,a);if(!l)return L(`merge: ${a} - not something we can merge
410
+ `);let m=await Ge(s,l),h=await vt(s,i,m),p=h[0]??null;if(h.length===0)return T("refusing to merge unrelated histories");if(p===m)return{stdout:`Already up to date.${n.squash?" (nothing to squash)":""}
411
+ `,stderr:"",exitCode:0};if(n.noFf&&n.ffOnly)return T("--no-ff and --ff-only are incompatible");let g=p===i&&!n.noFf;if(n.ffOnly&&!g)return L(`hint: Diverging branches can't be fast-forwarded, you need to either:
371
412
  hint:
372
413
  hint: git merge --no-ff
373
414
  hint:
@@ -377,61 +418,61 @@ hint: git rebase
377
418
  hint:
378
419
  hint: Disable this message with "git config set advice.diverging false"
379
420
  fatal: Not possible to fast-forward, aborting.
380
- `,128);if(await F(s,"REVERT_HEAD")&&await wt(s),g&&!n.squash){let b=await J(s),E=await es(s,i,m);if(E.exitCode===0&&n.message&&(E.stdout=E.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),E.exitCode===0){let k=b?.type==="symbolic"?b.target:"HEAD";await ee(s,r.env,k,i,m,`merge ${a}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,b?.type==="symbolic"),await t?.hooks?.emitPost("post-merge",{headHash:i,theirsHash:m,strategy:"fast-forward",commitHash:null})}return E}let w=n.message,x=w?w.endsWith(`
421
+ `,128);if(await F(s,"REVERT_HEAD")&&await Tt(s),g&&!n.squash){let b=await Z(s),E=await Ws(s,i,m);if(E.exitCode===0&&n.message&&(E.stdout=E.stdout.replace(/^Fast-forward$/m,"Fast-forward (no commit created; -m option ignored)")),E.exitCode===0){let x=b?.type==="symbolic"?b.target:"HEAD";await ne(s,r.env,x,i,m,`merge ${a}: Fast-forward${n.message?" (no commit created; -m option ignored)":""}`,b?.type==="symbolic"),await t?.hooks?.emitPost("post-merge",{headHash:i,theirsHash:m,strategy:"fast-forward",commitHash:null})}return E}let w=n.message,k=w?w.endsWith(`
381
422
  `)?w:`${w}
382
- `:void 0;return n.squash?Wu(s,i,m,a,r.env,t,x):Bu(s,i,m,a,r.env,n.noFf,t,x)}})}async function Bu(e,t,n,r,o,s=!1,a,i){let c=await j(e,t),f=await J(e),d=f?.type==="symbolic"?de(f.target):"HEAD",u={a:"HEAD",b:r},l=await lr(e,t,n,u),m=await qt(e,l,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!m.ok)return m.failureKind==="staged"&&f?.type==="symbolic"&&await ee(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(l.conflicts.length>0){await Y(e,"MERGE_HEAD",n),await Y(e,"ORIG_HEAD",t);let P=i??await Ut(e,r,d);if(a?.hooks){let y={message:P,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},I=await a.hooks.emitPre("merge-msg",y);if(I)return{stdout:"",stderr:I.message??"",exitCode:1};P=y.message}let C=It({version:2,entries:l.entries}).sort();return P+=`
423
+ `:void 0;return n.squash?rh(s,i,m,a,r.env,t,k):nh(s,i,m,a,r.env,n.noFf,t,k)}})}async function nh(e,t,n,r,o,s=!1,a,i){let c=await D(e,t),f=await Z(e),d=f?.type==="symbolic"?ge(f.target):"HEAD",u={a:"HEAD",b:r},l=await _r(e,t,n,u),m=await dn(e,l,c.tree,{labels:u,errorExitCode:2,operationName:"merge"});if(!m.ok)return m.failureKind==="staged"&&f?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`),m;if(l.conflicts.length>0){await z(e,"MERGE_HEAD",n),await z(e,"ORIG_HEAD",t);let P=i??await fn(e,r,d);if(a?.hooks){let y={message:P,treeHash:m.mergedTreeHash,headHash:t,theirsHash:n},I=await a.hooks.emitPre("merge-msg",y);if(I)return{stdout:"",stderr:I.message??"",exitCode:1};P=y.message}let C=_t({version:2,entries:l.entries}).sort();return P+=`
383
424
  # Conflicts:
384
425
  ${C.map(y=>`# ${y}`).join(`
385
426
  `)}
386
- `,await Ue(e,"MERGE_MSG",P),await Ue(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...l.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
427
+ `,await Pe(e,"MERGE_MSG",P),await Pe(e,"MERGE_MODE",s?"no-ff":""),{stdout:`${[...l.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
387
428
  `)}
388
- `,stderr:"",exitCode:1}}let h=m.mergedTreeHash,p=await Ht(e,o);if(S(p))return p;let g=await Le(e,o);if(S(g))return g;let w=i??await Ut(e,r,d);if(a?.hooks){let P={message:w,treeHash:h,headHash:t,theirsHash:n},C=await a.hooks.emitPre("merge-msg",P);if(C)return{stdout:"",stderr:C.message??"",exitCode:1};w=P.message}if(a?.hooks){let P=await a.hooks.emitPre("pre-merge-commit",{mergeMessage:w,treeHash:h,headHash:t,theirsHash:n});if(P)return{stdout:"",stderr:P.message??"",exitCode:1}}let x=await Je(e,h,[t,n],p,g,w),b=f?.type==="symbolic"?f.target:"HEAD";await ee(e,o,b,t,x,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await a?.hooks?.emitPost("post-merge",{headHash:t,theirsHash:n,strategy:"three-way",commitHash:x});let E=await an(e,c.tree,h);return{stdout:`${l.messages.length>0?`${l.messages.join(`
429
+ `,stderr:"",exitCode:1}}let h=m.mergedTreeHash,p=await qt(e,o);if(S(p))return p;let g=await Ye(e,o);if(S(g))return g;let w=i??await fn(e,r,d);if(a?.hooks){let P={message:w,treeHash:h,headHash:t,theirsHash:n},C=await a.hooks.emitPre("merge-msg",P);if(C)return{stdout:"",stderr:C.message??"",exitCode:1};w=P.message}if(a?.hooks){let P=await a.hooks.emitPre("pre-merge-commit",{mergeMessage:w,treeHash:h,headHash:t,theirsHash:n});if(P)return{stdout:"",stderr:P.message??"",exitCode:1}}let k=await dt(e,h,[t,n],p,g,w),b=f?.type==="symbolic"?f.target:"HEAD";await ne(e,o,b,t,k,`merge ${r}: Merge made by the 'ort' strategy.`,f?.type==="symbolic"),await a?.hooks?.emitPost("post-merge",{headHash:t,theirsHash:n,strategy:"three-way",commitHash:k});let E=await $n(e,c.tree,h);return{stdout:`${l.messages.length>0?`${l.messages.join(`
389
430
  `)}
390
431
  `:""}Merge made by the 'ort' strategy.
391
- ${E}`,stderr:"",exitCode:0}}async function Wu(e,t,n,r,o,s,a){let i=await j(e,t),c=await J(e),f=c?.type==="symbolic"?de(c.target):"HEAD",d={a:"HEAD",b:r},u=await gt(e,t,n),l=u.length>0&&u[0]===t,m=l?`Updating ${K(t)}..${K(n)}
392
- `:"",h=await lr(e,t,n,d),p=await qt(e,h,i.tree,{labels:d,errorExitCode:l?1:2,operationName:"merge",skipStagedChangeCheck:l});if(!p.ok){!l&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ee(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let k=p;return m&&(k.stdout=m+k.stdout),k}if(h.conflicts.length>0){await Y(e,"ORIG_HEAD",t);let k=a??await Ut(e,r,f);return k=`Squashed commit of the following:
432
+ ${E}`,stderr:"",exitCode:0}}async function rh(e,t,n,r,o,s,a){let i=await D(e,t),c=await Z(e),f=c?.type==="symbolic"?ge(c.target):"HEAD",d={a:"HEAD",b:r},u=await vt(e,t,n),l=u.length>0&&u[0]===t,m=l?`Updating ${K(t)}..${K(n)}
433
+ `:"",h=await _r(e,t,n,d),p=await dn(e,h,i.tree,{labels:d,errorExitCode:l?1:2,operationName:"merge",skipStagedChangeCheck:l});if(!p.ok){!l&&p.failureKind==="staged"&&c?.type==="symbolic"&&await ne(e,o,"HEAD",t,t,`merge ${r}: updating HEAD`);let x=p;return m&&(x.stdout=m+x.stdout),x}if(h.conflicts.length>0){await z(e,"ORIG_HEAD",t);let x=a??await fn(e,r,f);return x=`Squashed commit of the following:
393
434
 
394
- ${k}`,await Ue(e,"MERGE_MSG",k),await Ue(e,"MERGE_MODE",""),{stdout:`${[...h.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
435
+ ${x}`,await Pe(e,"MERGE_MSG",x),await Pe(e,"MERGE_MODE",""),{stdout:`${[...h.messages,"Squash commit -- not updating HEAD","Automatic merge failed; fix conflicts and then commit the result."].join(`
395
436
  `)}
396
- `,stderr:"",exitCode:1}}let g=p.mergedTreeHash,w=await an(e,i.tree,g),x=h.messages.length>0?`${h.messages.join(`
437
+ `,stderr:"",exitCode:1}}let g=p.mergedTreeHash,w=await $n(e,i.tree,g),k=h.messages.length>0?`${h.messages.join(`
397
438
  `)}
398
- `:"",b=a??await Ut(e,r,f);return b=`Squashed commit of the following:
439
+ `:"",b=a??await fn(e,r,f);return b=`Squashed commit of the following:
399
440
 
400
- ${b}`,await Ue(e,"MERGE_MSG",b),{stdout:`${l?`${m}Fast-forward
401
- `:""}${x}Squash commit -- not updating HEAD
441
+ ${b}`,await Pe(e,"MERGE_MSG",b),{stdout:`${l?`${m}Fast-forward
442
+ `:""}${k}Squash commit -- not updating HEAD
402
443
  ${l?w:""}`,stderr:l?"":`Automatic merge went well; stopped before committing as requested
403
- `,exitCode:0}}async function qu(e,t,n){let r=await F(e,"MERGE_HEAD");if(!r)return T("There is no merge in progress (MERGE_HEAD missing).");let o=await U(e),s=_t(o,"Committing");if(s)return s;let a=await Se(e);if(S(a))return a;let i=await j(e,a),c=await qe(e,"MERGE_MSG");if(c)c=or(c);else{let k=await J(e),P=k?.type==="symbolic"?de(k.target):"HEAD";c=await Ut(e,"unknown",P)}let f=xe(o),d=await ke(e,f),u=await Ht(e,t);if(S(u))return u;let l=await Le(e,t);if(S(l))return l;let m=ht(c);if(n?.hooks){let k={message:m,treeHash:d,headHash:a,theirsHash:r},P=await n.hooks.emitPre("merge-msg",k);if(P)return{stdout:"",stderr:P.message??"",exitCode:1};m=k.message}if(n?.hooks){let k=await n.hooks.emitPre("pre-merge-commit",{mergeMessage:m,treeHash:d,headHash:a,theirsHash:r});if(k)return{stdout:"",stderr:k.message??"",exitCode:1}}let h=await Je(e,d,[a,r],u,l,m);await ar(e);let p=await J(e),g=ue(m),w=p?.type==="symbolic"?p.target:"HEAD";await ee(e,t,w,a,h,`commit (merge): ${g}`,p?.type==="symbolic"),await n?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:r,strategy:"three-way",commitHash:h});let x=await an(e,i.tree,d),b=p?.type==="symbolic"?de(p.target):"detached HEAD";return{stdout:`${mt(b,h,c)}
404
- ${x}`,stderr:"",exitCode:0}}async function Ku(e,t){return tn(e,t,{operationRef:"MERGE_HEAD",noOpError:T("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:ar})}function Rc(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[W.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:v().alias("f").describe("Force renaming even if target exists"),"dry-run":v().alias("n").describe("Do nothing; only show what would happen"),skip:v().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=Fe(s);if(a)return a;let i=s.workTree,c=n.sources;if(c.length<2)return G(`usage: git mv [<options>] <source>... <destination>
405
- `);let f=c[c.length-1],d=c.slice(0,-1),u=ft(r.cwd,f),l=Ke(i,u);if(l.startsWith(".."))return T(`'${f}' is outside repository at '${i}'`);let m=await U(s),h=await r.fs.exists(u),p=h&&(await r.fs.stat(u)).isDirectory;if(d.length>1&&!p)return T(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of d){let x=ft(r.cwd,w),b=Ke(i,x);if(b.startsWith("..")){if(n.skip)continue;return T(`'${w}' is outside repository at '${i}'`)}if(!await r.fs.exists(x)){if(n.skip)continue;return T(`bad source, source=${b}, destination=${l}`)}let P=(await r.fs.stat(x)).isDirectory;if(!(P?m.entries.some(L=>L.path===b||L.path.startsWith(`${b}/`)):m.entries.some(L=>L.path===b&&L.stage===0))){let L=!P&&m.entries.some(D=>D.path===b&&D.stage>0);if(n.skip)continue;return T(L?`conflicted, source=${b}, destination=${l}`:`not under version control, source=${b}, destination=${l}`)}let O,y;if(p){let L=zn(b);O=l===""||l==="."?L:`${l}/${L}`,y=H(u,L)}else O=l,y=u;if(await r.fs.exists(y)&&!n.force)if((await r.fs.stat(y)).isDirectory){let D=zn(b);O=`${O}/${D}`,y=H(y,D)}else{if(n.skip)continue;return T(`destination exists, source=${b}, destination=${O}`)}if(b===O){if(n.skip)continue;return T(`can not move directory into itself, source=${b}, destination=${O}`)}let A=Pt(y);if(!await r.fs.exists(A)){if(n.skip)continue;return T(`renaming '${b}' failed: No such file or directory`)}if(P){let L=`${b}/`,D=m.entries.filter(z=>z.path.startsWith(L)&&z.stage===0);for(let z of D){let M=z.path.slice(b.length),$=O+M,R=y+M;g.push({srcRel:z.path,dstRel:$,srcAbs:H(i,z.path),dstAbs:R})}}else g.push({srcRel:b,dstRel:O,srcAbs:x,dstAbs:y})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let x=Pt(w.dstAbs);await r.fs.exists(x)||await r.fs.mkdir(x,{recursive:!0});let b=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,b),await r.fs.rm(w.srcAbs);let E=Dt(m,w.srcRel,0);if(E){m=Ne(m,w.srcRel);let k={...E,path:w.dstRel};m=Xe(m,k)}}for(let w of g)await wn(r.fs,Pt(w.srcAbs),i);return await re(s,m),{stdout:"",stderr:"",exitCode:0}}})}function $c(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[W.string().name("remote").describe("Remote to pull from").optional(),W.string().name("branch").describe("Remote branch").optional()],options:{rebase:v().alias("r").describe("Rebase instead of merge"),noRebase:v().describe("Merge instead of rebase"),ffOnly:v().describe("Only fast-forward"),noFf:v().describe("Create a merge commit even for fast-forwards")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await Se(s);if(S(a))return a;let i=await U(s);if(lt(i))return G(`error: Pulling is not possible because you have unmerged files.
406
- `,128);let c=n.remote,f=n.branch;if(!c){let ne=await J(s);if(ne?.type==="symbolic"){let Ce=ne.target.startsWith("refs/heads/")?ne.target.slice(11):ne.target,In=(await ce(s))[`branch "${Ce}"`];In&&(c=In.remote||"origin",!f&&In.merge&&(f=In.merge.startsWith("refs/heads/")?In.merge.slice(11):In.merge))}}c=c||"origin";let d;try{d=await Un(s,c,r.env)}catch(ne){let Ce=ne instanceof Error?ne.message:"";if(Ce.startsWith("network"))return T(Ce);throw ne}if(!d)return T(`'${c}' does not appear to be a git repository`);let{transport:u,config:l}=d,m=f??null;if(t?.hooks){let ne=await t.hooks.emitPre("pre-pull",{remote:c,branch:m});if(ne)return{stdout:"",stderr:ne.message??"",exitCode:1}}let h=On(l.fetchRefspec),p=await u.advertiseRefs();if(p.length===0)return T("Couldn't find remote ref HEAD");let w=(await le(s)).map(ne=>ne.hash),x=await F(s,"HEAD");x&&w.push(x);let b=[],E=new Set,k=[];for(let ne of p){if(ne.name==="HEAD")continue;let Ce=Es(h,ne.name);Ce!==null&&(k.push({remote:ne,localRef:Ce}),E.has(ne.hash)||(E.add(ne.hash),b.push(ne.hash)))}let P=new Set(w),C=b.filter(ne=>!P.has(ne));C.length>0&&await u.fetch(C,w);let O=await Ot(s,r.env);for(let ne of k){let Ce=await F(s,ne.localRef);await Y(s,ne.localRef,ne.remote.hash),await Te(s,ne.localRef,{oldHash:Ce??Z,newHash:ne.remote.hash,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Ce?"pull":"pull: storing head"})}let y=null;if(f){let ne=p.find(Ce=>Ce.name===`refs/heads/${f}`);if(ne)y=ne.hash;else return T(`Couldn't find remote ref refs/heads/${f}`)}else{let ne=p.find(Ce=>Ce.name==="HEAD");ne&&(y=ne.hash)}if(y&&await r.fs.writeFile(H(s.gitDir,"FETCH_HEAD"),`${y} ${l.url}
444
+ `,exitCode:0}}async function sh(e,t,n){let r=await F(e,"MERGE_HEAD");if(!r)return T("There is no merge in progress (MERGE_HEAD missing).");let o=await W(e),s=sn(o,"Committing");if(s)return s;let a=await Ke(e);if(S(a))return a;let i=await D(e,a),c=await Ce(e,"MERGE_MSG");if(c)c=Hr(c);else{let x=await Z(e),P=x?.type==="symbolic"?ge(x.target):"HEAD";c=await fn(e,"unknown",P)}let f=He(o),d=await Ae(e,f),u=await qt(e,t);if(S(u))return u;let l=await Ye(e,t);if(S(l))return l;let m=$t(c);if(n?.hooks){let x={message:m,treeHash:d,headHash:a,theirsHash:r},P=await n.hooks.emitPre("merge-msg",x);if(P)return{stdout:"",stderr:P.message??"",exitCode:1};m=x.message}if(n?.hooks){let x=await n.hooks.emitPre("pre-merge-commit",{mergeMessage:m,treeHash:d,headHash:a,theirsHash:r});if(x)return{stdout:"",stderr:x.message??"",exitCode:1}}let h=await dt(e,d,[a,r],u,l,m);await vr(e);let p=await Z(e),g=se(m),w=p?.type==="symbolic"?p.target:"HEAD";await ne(e,t,w,a,h,`commit (merge): ${g}`,p?.type==="symbolic"),await n?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:r,strategy:"three-way",commitHash:h});let k=await $n(e,i.tree,d),b=p?.type==="symbolic"?ge(p.target):"detached HEAD";return{stdout:`${Ot(b,h,c)}
445
+ ${k}`,stderr:"",exitCode:0}}async function oh(e,t){return kn(e,t,{operationRef:"MERGE_HEAD",noOpError:T("There is no merge to abort (MERGE_HEAD missing)."),operationName:"merge",clearState:vr})}ee();ye();fe();et();function xf(e,t){e.command("mv",{description:"Move or rename a file, directory, or symlink",args:[B.string().name("sources").describe("Source file(s) or directory").optional().variadic()],options:{force:A().alias("f").describe("Force renaming even if target exists"),"dry-run":A().alias("n").describe("Do nothing; only show what would happen"),skip:A().alias("k").describe("Skip move/rename actions that would lead to errors")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=qe(s);if(a)return a;let i=s.workTree,c=n.sources;if(c.length<2)return L(`usage: git mv [<options>] <source>... <destination>
446
+ `);let f=c[c.length-1],d=c.slice(0,-1),u=xt(r.cwd,f),l=rt(i,u);if(l.startsWith(".."))return T(`'${f}' is outside repository at '${i}'`);let m=await W(s),h=await r.fs.exists(u),p=h&&(await r.fs.stat(u)).isDirectory;if(d.length>1&&!p)return T(h?`destination '${f}' is not a directory`:`destination directory '${f}' does not exist`);let g=[];for(let w of d){let k=xt(r.cwd,w),b=rt(i,k);if(b.startsWith("..")){if(n.skip)continue;return T(`'${w}' is outside repository at '${i}'`)}if(!await r.fs.exists(k)){if(n.skip)continue;return T(`bad source, source=${b}, destination=${l}`)}let P=(await r.fs.stat(k)).isDirectory;if(!(P?m.entries.some(G=>G.path===b||G.path.startsWith(`${b}/`)):m.entries.some(G=>G.path===b&&G.stage===0))){let G=!P&&m.entries.some(M=>M.path===b&&M.stage>0);if(n.skip)continue;return T(G?`conflicted, source=${b}, destination=${l}`:`not under version control, source=${b}, destination=${l}`)}let R,y;if(p){let G=gr(b);R=l===""||l==="."?G:`${l}/${G}`,y=H(u,G)}else R=l,y=u;if(await r.fs.exists(y)&&!n.force)if((await r.fs.stat(y)).isDirectory){let M=gr(b);R=`${R}/${M}`,y=H(y,M)}else{if(n.skip)continue;return T(`destination exists, source=${b}, destination=${R}`)}if(b===R){if(n.skip)continue;return T(`can not move directory into itself, source=${b}, destination=${R}`)}let v=Lt(y);if(!await r.fs.exists(v)){if(n.skip)continue;return T(`renaming '${b}' failed: No such file or directory`)}if(P){let G=`${b}/`,M=m.entries.filter(V=>V.path.startsWith(G)&&V.stage===0);for(let V of M){let j=V.path.slice(b.length),$=R+j,O=y+j;g.push({srcRel:V.path,dstRel:$,srcAbs:H(i,V.path),dstAbs:O})}}else g.push({srcRel:b,dstRel:R,srcAbs:k,dstAbs:y})}if(g.length===0)return{stdout:"",stderr:"",exitCode:0};if(n["dry-run"])return{stdout:"",stderr:"",exitCode:0};for(let w of g){let k=Lt(w.dstAbs);await r.fs.exists(k)||await r.fs.mkdir(k,{recursive:!0});let b=await r.fs.readFileBuffer(w.srcAbs);await r.fs.writeFile(w.dstAbs,b),await r.fs.rm(w.srcAbs);let E=Xt(m,w.srcRel,0);if(E){m=Je(m,w.srcRel);let x={...E,path:w.dstRel};m=ct(m,x)}}for(let w of g)await _n(r.fs,Lt(w.srcAbs),i);return await ie(s,m),{stdout:"",stderr:"",exitCode:0}}})}ee();Ze();ln();ye();re();fe();at();Me();ue();function Cf(e,t){e.command("pull",{description:"Fetch from and integrate with another repository",args:[B.string().name("remote").describe("Remote to pull from").optional(),B.string().name("branch").describe("Remote branch").optional()],options:{rebase:A().alias("r").describe("Rebase instead of merge"),noRebase:A().describe("Merge instead of rebase"),ffOnly:A().describe("Only fast-forward"),noFf:A().describe("Create a merge commit even for fast-forwards")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=await Ke(s);if(S(a))return a;let i=await W(s);if(Pt(i))return L(`error: Pulling is not possible because you have unmerged files.
447
+ `,128);let c=n.remote,f=n.branch;if(!c){let oe=await Z(s);if(oe?.type==="symbolic"){let ve=oe.target.startsWith("refs/heads/")?oe.target.slice(11):oe.target,Yn=(await me(s))[`branch "${ve}"`];Yn&&(c=Yn.remote||"origin",!f&&Yn.merge&&(f=Yn.merge.startsWith("refs/heads/")?Yn.merge.slice(11):Yn.merge))}}c=c||"origin";let d;try{d=await lr(s,c,r.env)}catch(oe){let ve=oe instanceof Error?oe.message:"";if(ve.startsWith("network"))return T(ve);throw oe}if(!d)return T(`'${c}' does not appear to be a git repository`);let{transport:u,config:l}=d,m=f??null;if(t?.hooks){let oe=await t.hooks.emitPre("pre-pull",{remote:c,branch:m});if(oe)return{stdout:"",stderr:oe.message??"",exitCode:1}}let h=Vn(l.fetchRefspec),p=await u.advertiseRefs();if(p.length===0)return T("Couldn't find remote ref HEAD");let w=(await pe(s)).map(oe=>oe.hash),k=await F(s,"HEAD");k&&w.push(k);let b=[],E=new Set,x=[];for(let oe of p){if(oe.name==="HEAD")continue;let ve=eo(h,oe.name);ve!==null&&(x.push({remote:oe,localRef:ve}),E.has(oe.hash)||(E.add(oe.hash),b.push(oe.hash)))}let P=new Set(w),C=b.filter(oe=>!P.has(oe));C.length>0&&await u.fetch(C,w);let R=await Nt(s,r.env);for(let oe of x){let ve=await F(s,oe.localRef);await z(s,oe.localRef,oe.remote.hash),await _e(s,oe.localRef,{oldHash:ve??J,newHash:oe.remote.hash,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:ve?"pull":"pull: storing head"})}let y=null;if(f){let oe=p.find(ve=>ve.name===`refs/heads/${f}`);if(oe)y=oe.hash;else return T(`Couldn't find remote ref refs/heads/${f}`)}else{let oe=p.find(ve=>ve.name==="HEAD");oe&&(y=oe.hash)}if(y&&await r.fs.writeFile(H(s.gitDir,"FETCH_HEAD"),`${y} ${l.url}
407
448
  `),!y)return T("Could not determine remote HEAD");let I=y;if(a===I)return await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
408
- `,stderr:"",exitCode:0};let A=await gt(s,a,I),L=A[0]??null;if(A.length===0)return T("refusing to merge unrelated histories");if(L===I)return await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
409
- `,stderr:"",exitCode:0};let D=L===a;if(n.ffOnly&&!D)return T("Not possible to fast-forward, aborting.");if(D&&!n.noFf){let ne=await es(s,a,I),Ce=await J(s),mn=Ce?.type==="symbolic"?Ce.target:"HEAD";return await Te(s,mn,{oldHash:a,newHash:I,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:"pull: Fast-forward"}),Ce?.type==="symbolic"&&await Te(s,"HEAD",{oldHash:a,newHash:I,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:"pull: Fast-forward"}),ne.exitCode===0&&(await t?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:I,strategy:"fast-forward",commitHash:null}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"fast-forward",commitHash:null})),ne}let z=await J(s),M=z?.type==="symbolic"?de(z.target):"HEAD",$=f||c||"FETCH_HEAD",R={a:"HEAD",b:$},_=await lr(s,a,I,R),q=await j(s,a),N=await qt(s,_,q.tree,{labels:R,errorExitCode:2,operationName:"merge"});if(!N.ok)return N;if(_.conflicts.length>0){await Y(s,"MERGE_HEAD",I),await Y(s,"ORIG_HEAD",a);let ne=await Ut(s,$,M),Ce=It({version:2,entries:_.entries}).sort();return ne+=`
449
+ `,stderr:"",exitCode:0};let v=await vt(s,a,I),G=v[0]??null;if(v.length===0)return T("refusing to merge unrelated histories");if(G===I)return await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"up-to-date",commitHash:null}),{stdout:`Already up to date.
450
+ `,stderr:"",exitCode:0};let M=G===a;if(n.ffOnly&&!M)return T("Not possible to fast-forward, aborting.");if(M&&!n.noFf){let oe=await Ws(s,a,I),ve=await Z(s),Sn=ve?.type==="symbolic"?ve.target:"HEAD";return await _e(s,Sn,{oldHash:a,newHash:I,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:"pull: Fast-forward"}),ve?.type==="symbolic"&&await _e(s,"HEAD",{oldHash:a,newHash:I,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:"pull: Fast-forward"}),oe.exitCode===0&&(await t?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:I,strategy:"fast-forward",commitHash:null}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"fast-forward",commitHash:null})),oe}let V=await Z(s),j=V?.type==="symbolic"?ge(V.target):"HEAD",$=f||c||"FETCH_HEAD",O={a:"HEAD",b:$},_=await _r(s,a,I,O),q=await D(s,a),N=await dn(s,_,q.tree,{labels:O,errorExitCode:2,operationName:"merge"});if(!N.ok)return N;if(_.conflicts.length>0){await z(s,"MERGE_HEAD",I),await z(s,"ORIG_HEAD",a);let oe=await fn(s,$,j),ve=_t({version:2,entries:_.entries}).sort();return oe+=`
410
451
  # Conflicts:
411
- ${Ce.map(mn=>`# ${mn}`).join(`
452
+ ${ve.map(Sn=>`# ${Sn}`).join(`
412
453
  `)}
413
- `,await Ue(s,"MERGE_MSG",ne),{stdout:`${[..._.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
454
+ `,await Pe(s,"MERGE_MSG",oe),{stdout:`${[..._.messages,"Automatic merge failed; fix conflicts and then commit the result."].join(`
414
455
  `)}
415
- `,stderr:"",exitCode:1}}let V=N.mergedTreeHash,oe=await Ht(s,r.env);if(S(oe))return oe;let Q=await Le(s,r.env);if(S(Q))return Q;let ge=await Ut(s,$,M);if(t?.hooks){let ne={message:ge,treeHash:V,headHash:a,theirsHash:I},Ce=await t.hooks.emitPre("merge-msg",ne);if(Ce)return{stdout:"",stderr:Ce.message??"",exitCode:1};ge=ne.message;let mn=await t.hooks.emitPre("pre-merge-commit",{mergeMessage:ge,treeHash:V,headHash:a,theirsHash:I});if(mn)return{stdout:"",stderr:mn.message??"",exitCode:1}}let De=await Je(s,V,[a,I],oe,Q,ge);await t?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:I,strategy:"three-way",commitHash:De}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"three-way",commitHash:De});let un=z?.type==="symbolic"?z.target:"HEAD",Re="pull: Merge made by the 'ort' strategy.";await Te(s,un,{oldHash:a,newHash:De,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Re}),z?.type==="symbolic"&&await Te(s,"HEAD",{oldHash:a,newHash:De,name:O.name,email:O.email,timestamp:O.timestamp,tz:O.tz,message:Re});let yr=await an(s,q.tree,V);return{stdout:`${_.messages.length>0?`${_.messages.join(`
456
+ `,stderr:"",exitCode:1}}let X=N.mergedTreeHash,ce=await qt(s,r.env);if(S(ce))return ce;let te=await Ye(s,r.env);if(S(te))return te;let xe=await fn(s,$,j);if(t?.hooks){let oe={message:xe,treeHash:X,headHash:a,theirsHash:I},ve=await t.hooks.emitPre("merge-msg",oe);if(ve)return{stdout:"",stderr:ve.message??"",exitCode:1};xe=oe.message;let Sn=await t.hooks.emitPre("pre-merge-commit",{mergeMessage:xe,treeHash:X,headHash:a,theirsHash:I});if(Sn)return{stdout:"",stderr:Sn.message??"",exitCode:1}}let ze=await dt(s,X,[a,I],ce,te,xe);await t?.hooks?.emitPost("post-merge",{headHash:a,theirsHash:I,strategy:"three-way",commitHash:ze}),await t?.hooks?.emitPost("post-pull",{remote:c,branch:m,strategy:"three-way",commitHash:ze});let vn=V?.type==="symbolic"?V.target:"HEAD",Le="pull: Merge made by the 'ort' strategy.";await _e(s,vn,{oldHash:a,newHash:ze,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:Le}),V?.type==="symbolic"&&await _e(s,"HEAD",{oldHash:a,newHash:ze,name:R.name,email:R.email,timestamp:R.timestamp,tz:R.tz,message:Le});let Vr=await $n(s,q.tree,X);return{stdout:`${_.messages.length>0?`${_.messages.join(`
416
457
  `)}
417
458
  `:""}Merge made by the 'ort' strategy.
418
- ${yr}`,stderr:"",exitCode:0}}})}function Tc(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[W.string().name("remote").describe("Remote to push to").optional(),W.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:v().alias("f").describe("Force push"),"set-upstream":v().alias("u").describe("Set upstream tracking reference"),all:v().describe("Push all branches"),delete:v().alias("d").describe("Delete remote refs"),tags:v().describe("Push all tags")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.remote||"origin",i;try{i=await Un(s,a,r.env)}catch(b){let E=b instanceof Error?b.message:"";if(E.startsWith("network"))return T(E);throw b}if(!i)return T(`'${a}' does not appear to be a git repository`);let{transport:c,config:f}=i,d=n.force,u=await c.advertiseRefs(),l=new Map;for(let b of u)l.set(b.name,b.hash);let m=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return T("--delete requires a ref argument");for(let E of b){let k=E.startsWith("refs/")?E:`refs/heads/${E}`,P=l.get(k)??null;if(!P)return G(`error: unable to delete '${E}': remote ref does not exist
419
- `);m.push({name:k,oldHash:P,newHash:Z,ok:d})}}else if(n.all){let b=await le(s,"refs/heads");for(let E of b){let k=E.name,P=l.get(k)??null;m.push({name:k,oldHash:P,newHash:E.hash,ok:d})}}else if(n.tags){let b=await le(s,"refs/tags");for(let E of b){let k=l.get(E.name)??null;k!==E.hash&&m.push({name:E.name,oldHash:k,newHash:E.hash,ok:d})}}else if(h&&h.length>0)for(let b of h){let E=On(b),k=await zu(s,E.src);if(!k)return G(`error: src refspec '${E.src}' does not match any
420
- `);let P=E.dst.startsWith("refs/")?E.dst:`refs/heads/${E.dst}`,C=l.get(P)??null;m.push({name:P,oldHash:C,newHash:k,ok:d||E.force})}else{let b=await J(s);if(!b||b.type!=="symbolic")return T("You are not currently on a branch.");let E=b.target,k=await X(s);if(!k)return G(`error: src refspec does not match any
421
- `);let P=l.get(E)??null;m.push({name:E,oldHash:P,newHash:k,ok:d})}if(m.length===0)return{stdout:`Everything up-to-date
422
- `,stderr:"",exitCode:0};if(t?.hooks){let b=await t.hooks.emitPre("pre-push",{remote:a,url:f.url,refs:m.map(E=>({srcRef:E.newHash===Z?null:E.name,srcHash:E.newHash===Z?null:E.newHash,dstRef:E.name,dstHash:E.oldHash,force:!!E.ok,delete:E.newHash===Z}))});if(b)return G(b.message??"")}let p=await c.push(m),g=[];g.push(`To ${f.url}
459
+ ${Vr}`,stderr:"",exitCode:0}}})}ee();Ze();at();ue();function Pf(e,t){e.command("push",{description:"Update remote refs along with associated objects",args:[B.string().name("remote").describe("Remote to push to").optional(),B.string().name("refspec").describe("Refspec(s) to push").optional().variadic()],options:{force:A().alias("f").describe("Force push"),"set-upstream":A().alias("u").describe("Set upstream tracking reference"),all:A().describe("Push all branches"),delete:A().alias("d").describe("Delete remote refs"),tags:A().describe("Push all tags")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=n.remote||"origin",i;try{i=await lr(s,a,r.env)}catch(b){let E=b instanceof Error?b.message:"";if(E.startsWith("network"))return T(E);throw b}if(!i)return T(`'${a}' does not appear to be a git repository`);let{transport:c,config:f}=i,d=n.force,u=await c.advertiseRefs(),l=new Map;for(let b of u)l.set(b.name,b.hash);let m=[],h=n.refspec;if(n.delete){let b=h&&h.length>0?h:[];if(b.length===0)return T("--delete requires a ref argument");for(let E of b){let x=E.startsWith("refs/")?E:`refs/heads/${E}`,P=l.get(x)??null;if(!P)return L(`error: unable to delete '${E}': remote ref does not exist
460
+ `);m.push({name:x,oldHash:P,newHash:J,ok:d})}}else if(n.all){let b=await pe(s,"refs/heads");for(let E of b){let x=E.name,P=l.get(x)??null;m.push({name:x,oldHash:P,newHash:E.hash,ok:d})}}else if(n.tags){let b=await pe(s,"refs/tags");for(let E of b){let x=l.get(E.name)??null;x!==E.hash&&m.push({name:E.name,oldHash:x,newHash:E.hash,ok:d})}}else if(h&&h.length>0)for(let b of h){let E=Vn(b),x=await ih(s,E.src);if(!x)return L(`error: src refspec '${E.src}' does not match any
461
+ `);let P=E.dst.startsWith("refs/")?E.dst:`refs/heads/${E.dst}`,C=l.get(P)??null;m.push({name:P,oldHash:C,newHash:x,ok:d||E.force})}else{let b=await Z(s);if(!b||b.type!=="symbolic")return T("You are not currently on a branch.");let E=b.target,x=await Y(s);if(!x)return L(`error: src refspec does not match any
462
+ `);let P=l.get(E)??null;m.push({name:E,oldHash:P,newHash:x,ok:d})}if(m.length===0)return{stdout:`Everything up-to-date
463
+ `,stderr:"",exitCode:0};if(t?.hooks){let b=await t.hooks.emitPre("pre-push",{remote:a,url:f.url,refs:m.map(E=>({srcRef:E.newHash===J?null:E.name,srcHash:E.newHash===J?null:E.newHash,dstRef:E.name,dstHash:E.oldHash,force:!!E.ok,delete:E.newHash===J}))});if(b)return L(b.message??"")}let p=await c.push(m),g=[];g.push(`To ${f.url}
423
464
  `);let w=!1;for(let b of p.updates){let E=b.name.startsWith("refs/heads/")?b.name.slice(11):b.name;if(!b.ok)g.push(` ! [rejected] ${E} -> ${E} (${b.error??"failed"})
424
465
  `),w=!0;else if(!b.oldHash)g.push(` * [new branch] ${E} -> ${E}
425
- `);else if(b.newHash===Z)g.push(` - [deleted] ${E}
426
- `);else{let k=K(b.oldHash),P=K(b.newHash);g.push(` ${k}..${P} ${E} -> ${E}
427
- `)}}if(n["set-upstream"]&&!w){let b=await J(s);if(b?.type==="symbolic"){let E=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,k=await ce(s);k[`branch "${E}"`]={remote:a,merge:`refs/heads/${E}`},await Ge(s,k),g.push(`branch '${E}' set up to track '${a}/${E}'.
428
- `)}}let x={stdout:"",stderr:g.join(""),exitCode:w?1:0};return w||await t?.hooks?.emitPost("post-push",{remote:a,url:f.url,refs:m.map(b=>({srcRef:b.newHash===Z?null:b.name,srcHash:b.newHash===Z?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===Z}))}),x}})}async function zu(e,t){if(t.startsWith("refs/"))return F(e,t);let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);return r||(t==="HEAD"?X(e):null)}async function So(e,t){let n=await fe(e,t);if(n.type!=="commit")return null;let r=Rt(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await fe(e,r.parents[0]);f.type==="commit"&&(o=Rt(f.content).tree)}let s=await Ae(e,o,r.tree);if(s.length===0)return null;let a=zt(),i=!1,c=[...s].sort((f,d)=>he(f.path,d.path));for(let f of c){let d="",u="";if(f.oldHash)try{let m=await fe(e,f.oldHash);d=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await fe(e,f.newHash);u=new TextDecoder().decode(m.content)}catch{}let l=At({path:f.path,oldContent:d,newContent:u,oldMode:f.oldMode,newMode:f.newMode});if(l)for(let m of l.split(`
466
+ `);else if(b.newHash===J)g.push(` - [deleted] ${E}
467
+ `);else{let x=K(b.oldHash),P=K(b.newHash);g.push(` ${x}..${P} ${E} -> ${E}
468
+ `)}}if(n["set-upstream"]&&!w){let b=await Z(s);if(b?.type==="symbolic"){let E=b.target.startsWith("refs/heads/")?b.target.slice(11):b.target,x=await me(s);x[`branch "${E}"`]={remote:a,merge:`refs/heads/${E}`},await Xe(s,x),g.push(`branch '${E}' set up to track '${a}/${E}'.
469
+ `)}}let k={stdout:"",stderr:g.join(""),exitCode:w?1:0};return w||await t?.hooks?.emitPost("post-push",{remote:a,url:f.url,refs:m.map(b=>({srcRef:b.newHash===J?null:b.name,srcHash:b.newHash===J?null:b.newHash,dstRef:b.name,dstHash:b.oldHash,force:!!b.ok,delete:b.newHash===J}))}),k}})}async function ih(e,t){if(t.startsWith("refs/"))return F(e,t);let n=await F(e,`refs/heads/${t}`);if(n)return n;let r=await F(e,`refs/tags/${t}`);return r||(t==="HEAD"?Y(e):null)}ee();ye();re();ee();re();Jt();Dn();Ie();async function wi(e,t){let n=await he(e,t);if(n.type!=="commit")return null;let r=Ft(n.content),o=null;if(r.parents.length>0&&r.parents[0]){let f=await he(e,r.parents[0]);f.type==="commit"&&(o=Ft(f.content).tree)}let s=await Be(e,o,r.tree);if(s.length===0)return null;let a=mn(),i=!1,c=[...s].sort((f,d)=>Ee(f.path,d.path));for(let f of c){let d="",u="";if(f.oldHash)try{let m=await he(e,f.oldHash);d=new TextDecoder().decode(m.content)}catch{}if(f.newHash)try{let m=await he(e,f.newHash);u=new TextDecoder().decode(m.content)}catch{}let l=zt({path:f.path,oldContent:d,newContent:u,oldMode:f.oldMode,newMode:f.newMode});if(l)for(let m of l.split(`
429
470
  `)){if(!m||m.startsWith("index "))continue;let p=(m.startsWith("@@")?m.replace(/^@@ [^@]* @@/,"@@ @@"):m).replace(/[ \t\r]/g,"");p&&(a.update(p),a.update(`
430
- `),i=!0)}}return i?a.hex():null}async function Vu(e){let t=await J(e);return t?.type==="symbolic"?de(t.target):"detached HEAD"}function Hc(e){return e==="HEAD"?`HEAD is up to date.
471
+ `),i=!0)}}return i?a.hex():null}Me();ue();Ie();Wt();et();async function ah(e){let t=await Z(e);return t?.type==="symbolic"?ge(t.target):"detached HEAD"}function Rf(e){return e==="HEAD"?`HEAD is up to date.
431
472
  `:`Current branch ${e} is up to date.
432
- `}async function Yu(e,t,n){if(!e.workTree)return null;let r=await se(e,t),o=new Map(xe(n).map(i=>[i.path,i])),s=new Set(await _e(e,e.workTree,"")),a=[];for(let[i]of r)o.has(i)||s.has(i)&&a.push({path:i,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(a.length>0){let i=_r(a,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return G(`${i.stderr}error: could not detach HEAD
433
- `)}return null}async function Xu(e,t,n,r){if(!e.workTree)return null;let o=await se(e,t),s=new Set(n.entries.map(c=>c.path)),a=new Set(await _e(e,e.workTree,"")),i=[];for(let[c]of o)!s.has(c)&&a.has(c)&&i.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return i.length>0?{stdout:"",stderr:`${_r(i,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
434
- `,exitCode:128}:null}async function Ac(e,t,n){if(!e.workTree)return null;let r=new Map(xe(t).map(a=>[a.path,a])),o=new Set(await _e(e,e.workTree,"")),s=[];for(let[a]of n)!r.has(a)&&o.has(a)&&s.push(a);return s.length>0?s:null}function vc(e,t){return`error: The following untracked working tree files would be overwritten by merge:
473
+ `}async function ch(e,t,n){if(!e.workTree)return null;let r=await ae(e,t),o=new Map(He(n).map(i=>[i.path,i])),s=new Set(await Qe(e,e.workTree,"")),a=[];for(let[i]of r)o.has(i)||s.has(i)&&a.push({path:i,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});if(a.length>0){let i=Es(a,{errorExitCode:1,operationName:"checkout",actionHint:"switch branches"});return L(`${i.stderr}error: could not detach HEAD
474
+ `)}return null}async function fh(e,t,n,r){if(!e.workTree)return null;let o=await ae(e,t),s=new Set(n.entries.map(c=>c.path)),a=new Set(await Qe(e,e.workTree,"")),i=[];for(let[c]of o)!s.has(c)&&a.has(c)&&i.push({path:c,error:"WOULD_LOSE_UNTRACKED_OVERWRITTEN"});return i.length>0?{stdout:"",stderr:`${Es(i,{errorExitCode:128,operationName:"reset",actionHint:"reset"}).stderr}fatal: could not move back to ${r}
475
+ `,exitCode:128}:null}async function If(e,t,n){if(!e.workTree)return null;let r=new Map(He(t).map(a=>[a.path,a])),o=new Set(await Qe(e,e.workTree,"")),s=[];for(let[a]of n)!r.has(a)&&o.has(a)&&s.push(a);return s.length>0?s:null}function Of(e,t){return`error: The following untracked working tree files would be overwritten by merge:
435
476
  ${e.map(r=>` ${r}`).join(`
436
477
  `)}
437
478
  Please move or remove them before you merge.
@@ -445,7 +486,7 @@ hint: edit the todo list first:
445
486
  hint:
446
487
  hint: git rebase --edit-todo
447
488
  hint: git rebase --continue
448
- `}async function Do(e,t,n,r,o,s){await ee(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ee(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ee(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function Ps(e,t,n,r){let o=await j(e,t),s=await Yu(e,o.tree,n);if(s)return s;let a=await Nt(e,o.tree,n);return a.success&&(await re(e,{version:2,entries:a.newEntries}),await be(e,a.worktreeOps)),r!=="detached HEAD"?await Y(e,r,t):await Y(e,"HEAD",t),null}function Sc(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[W.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:te.string().describe("Starting point at which to create new commits"),abort:v().describe("Abort the current rebase operation"),continue:v().describe("Continue the rebase after conflict resolution"),skip:v().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return Qu(s,r.env);if(n.continue)return em(s,r.env);if(n.skip)return tm(s,r.env);let a=n.upstream;if(!a)return T("no upstream configured and no upstream argument given");if(await bt(s))return T(`It seems that there is already a rebase-merge directory, and
489
+ `}async function bi(e,t,n,r,o,s){await ne(e,t,"HEAD",n,r,`rebase (start): checkout ${s}`),o!=="detached HEAD"&&(await ne(e,t,o,n,r,`rebase (finish): ${o} onto ${r}`),await ne(e,t,"HEAD",r,r,`rebase (finish): returning to ${o}`))}async function so(e,t,n,r){let o=await D(e,t),s=await ch(e,o.tree,n);if(s)return s;let a=await rn(e,o.tree,n);return a.success&&(await ie(e,{version:2,entries:a.newEntries}),await Oe(e,a.worktreeOps)),r!=="detached HEAD"?await z(e,r,t):await z(e,"HEAD",t),null}function $f(e,t){e.command("rebase",{description:"Reapply commits on top of another base tip",args:[B.string().name("upstream").describe("Upstream branch to rebase onto").optional()],options:{onto:Q.string().describe("Starting point at which to create new commits"),abort:A().describe("Abort the current rebase operation"),continue:A().describe("Continue the rebase after conflict resolution"),skip:A().describe("Skip the current patch and continue")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort)return uh(s,r.env);if(n.continue)return mh(s,r.env);if(n.skip)return hh(s,r.env);let a=n.upstream;if(!a)return T("no upstream configured and no upstream argument given");if(await Ht(s))return T(`It seems that there is already a rebase-merge directory, and
449
490
  I wonder if you are in the middle of another rebase. If that is the
450
491
  case, please try
451
492
  git rebase (--continue | --abort | --skip)
@@ -453,23 +494,23 @@ If that is not the case, please
453
494
  rm -fr ".git/rebase-merge"
454
495
  and run me again. I am stopping in case you still have something
455
496
  valuable there.
456
- `);let i=await Se(s);if(S(i))return i;let c=await J(s),f=c?.type==="symbolic"?c.target:"detached HEAD",d=c?.type==="symbolic"?de(c.target):"HEAD",u=await ye(s,a,`invalid upstream '${a}'`);if(S(u))return u;let l=u.hash,m,h=n.onto;if(h){let R=await ye(s,h,`Does not point to a valid commit: '${h}'`);if(S(R))return R;m=R.hash}else m=l;let p=await U(s),g=It(p).sort();if(g.length>0)return{stdout:g.map(R=>`${R}: needs merge
497
+ `);let i=await Ke(s);if(S(i))return i;let c=await Z(s),f=c?.type==="symbolic"?c.target:"detached HEAD",d=c?.type==="symbolic"?ge(c.target):"HEAD",u=await $e(s,a,`invalid upstream '${a}'`);if(S(u))return u;let l=u.hash,m,h=n.onto;if(h){let O=await $e(s,h,`Does not point to a valid commit: '${h}'`);if(S(O))return O;m=O.hash}else m=l;let p=await W(s),g=_t(p).sort();if(g.length>0)return{stdout:g.map(O=>`${O}: needs merge
457
498
  `).join(""),stderr:`error: cannot rebase: You have unstaged changes.
458
499
  error: additionally, your index contains uncommitted changes.
459
500
  error: Please commit or stash them.
460
- `,exitCode:1};let w=await j(s,i),x=await se(s,w.tree);if(s.workTree){let R=Dn(p,x),q=(await ut(s,p)).some(N=>N.status==="modified"||N.status==="deleted");if(R||q){let N=[];return q&&N.push("error: cannot rebase: You have unstaged changes."),R&&(q?N.push("error: additionally, your index contains uncommitted changes."):N.push("error: cannot rebase: Your index contains uncommitted changes.")),N.push("error: Please commit or stash them."),G(`${N.join(`
501
+ `,exitCode:1};let w=await D(s,i),k=await ae(s,w.tree);if(s.workTree){let O=nr(p,k),q=(await Rt(s,p)).some(N=>N.status==="modified"||N.status==="deleted");if(O||q){let N=[];return q&&N.push("error: cannot rebase: You have unstaged changes."),O&&(q?N.push("error: additionally, your index contains uncommitted changes."):N.push("error: cannot rebase: Your index contains uncommitted changes.")),N.push("error: Please commit or stash them."),L(`${N.join(`
461
502
  `)}
462
- `)}}if(t?.hooks){let R=await t.hooks.emitPre("pre-rebase",{upstream:a,branch:c?.type==="symbolic"?de(c.target):null});if(R)return{stdout:"",stderr:R.message??"",exitCode:1}}let b=await ma(s,l,i),E=b.right;if(E.length===0){if(m!==i){let R=await Ps(s,m,p,f);return R||(await Do(s,r.env,i,m,f,a),{stdout:"",stderr:`Successfully rebased and updated ${f}.
463
- `,exitCode:0})}return{stdout:Hc(d),stderr:"",exitCode:0}}let k=[],P=b.left,C=new Set;for(let R of P){let _=await So(s,R.hash);_&&C.add(_)}let O=[];if(C.size>0)for(let R of E){let _=await So(s,R.hash);_&&C.has(_)?k.push(`warning: skipped previously applied commit ${K(R.hash)}`):O.push(R)}else O.push(...E);let y="";if(k.length>0&&(y=`${k.join(`
503
+ `)}}if(t?.hooks){let O=await t.hooks.emitPre("pre-rebase",{upstream:a,branch:c?.type==="symbolic"?ge(c.target):null});if(O)return{stdout:"",stderr:O.message??"",exitCode:1}}let b=await Ba(s,l,i),E=b.right;if(E.length===0){if(m!==i){let O=await so(s,m,p,f);return O||(await bi(s,r.env,i,m,f,a),{stdout:"",stderr:`Successfully rebased and updated ${f}.
504
+ `,exitCode:0})}return{stdout:Rf(d),stderr:"",exitCode:0}}let x=[],P=b.left,C=new Set;for(let O of P){let _=await wi(s,O.hash);_&&C.add(_)}let R=[];if(C.size>0)for(let O of E){let _=await wi(s,O.hash);_&&C.has(_)?x.push(`warning: skipped previously applied commit ${K(O.hash)}`):R.push(O)}else R.push(...E);let y="";if(x.length>0&&(y=`${x.join(`
464
505
  `)}
465
506
  hint: use --reapply-cherry-picks to include skipped commits
466
507
  hint: Disable this message with "git config set advice.skippedCherryPicks false"
467
- `),O.length===0){if(m!==i){let R=await Ps(s,m,p,f);if(R)return R.stderr=y+R.stderr,R;await Do(s,r.env,i,m,f,a)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
468
- `,exitCode:0}}let I=O.map(R=>({hash:R.hash,subject:ue(R.commit.message)})),A=m,L=0;for(let R of I){let _=await j(s,R.hash);if(_.parents.length>1||_.parents.length===0||_.parents[0]!==A)break;A=R.hash,L++}let D=I.splice(0,L);if(I.length===0){if(A===i)return{stdout:Hc(d),stderr:y,exitCode:0};let R=await Ps(s,A,p,f);return R?(R.stderr=y+R.stderr,R):(await Do(s,r.env,i,A,f,a),{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
469
- `,exitCode:0})}let z=await Ps(s,A,p,"detached HEAD");if(z)return z.stderr=y+z.stderr,z;await ee(s,r.env,"HEAD",i,A,`rebase (start): checkout ${a}`);let M={headName:f,origHead:i,onto:m,todo:I,done:D,msgnum:L,end:L+I.length};await fo(s,M),await Y(s,"ORIG_HEAD",i);let $=await Mo(s,r.env);return y&&($.stderr=y+$.stderr),$}})}async function Mo(e,t){let n=[],r=[];for(;;){let o=await nt(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 ua(e);let a=await Zu(e,s,t);if(a.conflict){if(a.rescheduleCurrent){let i=await nt(e);i&&(i.todo=[s,...i.todo],await fo(e,i))}return a.stdout&&r.push(a.stdout),n.push(a.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}a.stdout&&r.push(a.stdout),a.stderr&&n.push(a.stderr)}return Ju(e,n,t)}async function Zu(e,t,n){let r=t.hash,o=await j(e,r),s=o.parents.length>0?o.parents[0]:null,a=s?await j(e,s):null,i=await X(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
470
- `};if(s&&s===i){let D=await U(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
471
- `};let z=await He(e,a.tree),M=await He(e,o.tree),$=new Map(z.map(N=>[N.path,N.hash])),R=new Map;for(let N of M){let V=$.get(N.path);(!V||V!==N.hash)&&R.set(N.path,N.hash)}let _=await Ac(e,D,R);if(_)return await Y(e,"REBASE_HEAD",r),await rs(e,r,o.author),{conflict:!0,stdout:"",stderr:vc(_,t),rescheduleCurrent:!0};let q=await Nt(e,o.tree,D);return q.success&&(await re(e,{version:2,entries:q.newEntries}),await be(e,q.worktreeOps)),await Xt(e,r),await ee(e,n,"HEAD",i,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await j(e,i),f=a?a.tree:null,d=K(r),u=ue(o.message),l={a:"HEAD",b:u?`${d} (${u})`:d},m=await yt(e,f,c.tree,o.tree,l),h=await U(e),[p,g,w]=await Promise.all([He(e,c.tree),f?He(e,f):Promise.resolve([]),He(e,o.tree)]),x=new Set;for(let D of g)x.add(D.path);for(let D of p)x.add(D.path);for(let D of w)x.add(D.path);let b=h.entries.filter(D=>!x.has(D.path)),E=[...m.entries,...b];E.sort((D,z)=>he(D.path,z.path)||D.stage-z.stage);let k={version:2,entries:E},P=E.filter(D=>D.stage===0),C=await ke(e,P),O=new Map(p.map(D=>[D.path,D])),y=new Map;for(let D of P){let z=O.get(D.path);(!z||z.hash!==D.hash)&&y.set(D.path,D.hash)}for(let D of m.conflicts){if(D.reason==="content"||D.reason==="add-add"){y.set(D.path,null);continue}if(D.reason==="delete-modify"){let z=m.entries.filter(R=>R.path===D.path&&R.stage>0),M=z.find(R=>R.stage===2),$=z.find(R=>R.stage===3);$&&!M&&y.set(D.path,$.hash)}}let I=await Ac(e,h,y);if(I)return await Y(e,"REBASE_HEAD",r),await rs(e,r,o.author),{conflict:!0,stdout:"",stderr:vc(I,t),rescheduleCurrent:!0};if(await re(e,k),e.workTree){let D=await en(e,c.tree,m.resultTree,h);D.success&&await be(e,D.worktreeOps)}if(m.conflicts.length>0){await Y(e,"REBASE_HEAD",r),await rs(e,r,o.author),await Ue(e,"MERGE_MSG",o.message),await Ue(e,"rebase-merge/message",o.message);let D=m.messages.join(`
472
- `);return{conflict:!0,stdout:D?`${D}
508
+ `),R.length===0){if(m!==i){let O=await so(s,m,p,f);if(O)return O.stderr=y+O.stderr,O;await bi(s,r.env,i,m,f,a)}return{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
509
+ `,exitCode:0}}let I=R.map(O=>({hash:O.hash,subject:se(O.commit.message)})),v=m,G=0;for(let O of I){let _=await D(s,O.hash);if(_.parents.length>1||_.parents.length===0||_.parents[0]!==v)break;v=O.hash,G++}let M=I.splice(0,G);if(I.length===0){if(v===i)return{stdout:Rf(d),stderr:y,exitCode:0};let O=await so(s,v,p,f);return O?(O.stderr=y+O.stderr,O):(await bi(s,r.env,i,v,f,a),{stdout:"",stderr:`${y}Successfully rebased and updated ${f}.
510
+ `,exitCode:0})}let V=await so(s,v,p,"detached HEAD");if(V)return V.stderr=y+V.stderr,V;await ne(s,r.env,"HEAD",i,v,`rebase (start): checkout ${a}`);let j={headName:f,origHead:i,onto:m,todo:I,done:M,msgnum:G,end:G+I.length};await Fo(s,j),await z(s,"ORIG_HEAD",i);let $=await yi(s,r.env);return y&&($.stderr=y+$.stderr),$}})}async function yi(e,t){let n=[],r=[];for(;;){let o=await ut(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 Ua(e);let a=await dh(e,s,t);if(a.conflict){if(a.rescheduleCurrent){let i=await ut(e);i&&(i.todo=[s,...i.todo],await Fo(e,i))}return a.stdout&&r.push(a.stdout),n.push(a.stderr),{stdout:r.join(""),stderr:n.join(""),exitCode:1}}a.stdout&&r.push(a.stdout),a.stderr&&n.push(a.stderr)}return lh(e,n,t)}async function dh(e,t,n){let r=t.hash,o=await D(e,r),s=o.parents.length>0?o.parents[0]:null,a=s?await D(e,s):null,i=await Y(e);if(!i)return{conflict:!0,stdout:"",stderr:`fatal: no HEAD commit during rebase
511
+ `};if(s&&s===i){let M=await W(e);if(!a)return{conflict:!0,stdout:"",stderr:`fatal: missing parent commit during rebase
512
+ `};let V=await Ue(e,a.tree),j=await Ue(e,o.tree),$=new Map(V.map(N=>[N.path,N.hash])),O=new Map;for(let N of j){let X=$.get(N.path);(!X||X!==N.hash)&&O.set(N.path,N.hash)}let _=await If(e,M,O);if(_)return await z(e,"REBASE_HEAD",r),await Hs(e,r,o.author),{conflict:!0,stdout:"",stderr:Of(_,t),rescheduleCurrent:!0};let q=await rn(e,o.tree,M);return q.success&&(await ie(e,{version:2,entries:q.newEntries}),await Oe(e,q.worktreeOps)),await gn(e,r),await ne(e,n,"HEAD",i,r,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}let c=await D(e,i),f=a?a.tree:null,d=K(r),u=se(o.message),l={a:"HEAD",b:u?`${d} (${u})`:d},m=await St(e,f,c.tree,o.tree,l),h=await W(e),[p,g,w]=await Promise.all([Ue(e,c.tree),f?Ue(e,f):Promise.resolve([]),Ue(e,o.tree)]),k=new Set;for(let M of g)k.add(M.path);for(let M of p)k.add(M.path);for(let M of w)k.add(M.path);let b=h.entries.filter(M=>!k.has(M.path)),E=[...m.entries,...b];E.sort((M,V)=>Ee(M.path,V.path)||M.stage-V.stage);let x={version:2,entries:E},P=E.filter(M=>M.stage===0),C=await Ae(e,P),R=new Map(p.map(M=>[M.path,M])),y=new Map;for(let M of P){let V=R.get(M.path);(!V||V.hash!==M.hash)&&y.set(M.path,M.hash)}for(let M of m.conflicts){if(M.reason==="content"||M.reason==="add-add"){y.set(M.path,null);continue}if(M.reason==="delete-modify"){let V=m.entries.filter(O=>O.path===M.path&&O.stage>0),j=V.find(O=>O.stage===2),$=V.find(O=>O.stage===3);$&&!j&&y.set(M.path,$.hash)}}let I=await If(e,h,y);if(I)return await z(e,"REBASE_HEAD",r),await Hs(e,r,o.author),{conflict:!0,stdout:"",stderr:Of(I,t),rescheduleCurrent:!0};if(await ie(e,x),e.workTree){let M=await En(e,c.tree,m.resultTree,h);M.success&&await Oe(e,M.worktreeOps)}if(m.conflicts.length>0){await z(e,"REBASE_HEAD",r),await Hs(e,r,o.author),await Pe(e,"MERGE_MSG",o.message),await Pe(e,"rebase-merge/message",o.message);let M=m.messages.join(`
513
+ `);return{conflict:!0,stdout:M?`${M}
473
514
  `:"",stderr:`error: could not apply ${d}... ${t.subject}
474
515
  hint: Resolve all conflicts manually, mark them as resolved with
475
516
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
@@ -478,12 +519,12 @@ hint: To abort and get back to the state before "git rebase", run "git rebase --
478
519
  hint: Disable this message with "git config set advice.mergeConflict false"
479
520
  Could not apply ${d}... # ${t.subject}
480
521
  `}}if(C===c.tree)return{conflict:!1,stdout:"",stderr:`dropping ${r} ${t.subject} -- patch contents already upstream
481
- `};let A=await Le(e,n);if(S(A))return{conflict:!0,stdout:"",stderr:A.stderr};let L=await Je(e,C,[i],o.author,A,o.message);return await ee(e,n,"HEAD",i,L,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function Ju(e,t,n){let r=await nt(e);if(!r)return T("no rebase in progress");let o=await X(e);if(!o)return T("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await Y(e,r.headName,o),await $e(e,"HEAD",r.headName),await tt(e),await ee(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ee(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let a=`Successfully rebased and updated ${r.headName}.
482
- `;return await ae(e,"REBASE_HEAD"),await yn(e),await lo(e),{stdout:"",stderr:t.join("")+a,exitCode:0}}async function Qu(e,t){let n=await nt(e);if(!n)return T("no rebase in progress");let r=await X(e),o=n.origHead,s=await j(e,o),a=await U(e),i=await Xu(e,s.tree,a,o);if(i)return i;let c=await Nt(e,s.tree,a);c.success&&(await re(e,{version:2,entries:c.newEntries}),await be(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await Y(e,n.headName,o),await $e(e,"HEAD",n.headName),await tt(e)):await Xt(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ee(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await ae(e,"REBASE_HEAD"),await yn(e),await lo(e),{stdout:"",stderr:"",exitCode:0}}async function em(e,t){let n="";if(!await nt(e))return T("no rebase in progress");let o=await U(e);if(lt(o))return G(`error: Committing is not possible because you have unmerged files.
522
+ `};let v=await Ye(e,n);if(S(v))return{conflict:!0,stdout:"",stderr:v.stderr};let G=await dt(e,C,[i],o.author,v,o.message);return await ne(e,n,"HEAD",i,G,`rebase (pick): ${t.subject}`),{conflict:!1,stdout:"",stderr:""}}async function lh(e,t,n){let r=await ut(e);if(!r)return T("no rebase in progress");let o=await Y(e);if(!o)return T("no HEAD during rebase finish");r.headName!=="detached HEAD"&&(await z(e,r.headName,o),await Ne(e,"HEAD",r.headName),await lt(e),await ne(e,n,r.headName,r.origHead,o,`rebase (finish): ${r.headName} onto ${r.onto}`),await ne(e,n,"HEAD",o,o,`rebase (finish): returning to ${r.headName}`));let a=`Successfully rebased and updated ${r.headName}.
523
+ `;return await de(e,"REBASE_HEAD"),await Bn(e),await Uo(e),{stdout:"",stderr:t.join("")+a,exitCode:0}}async function uh(e,t){let n=await ut(e);if(!n)return T("no rebase in progress");let r=await Y(e),o=n.origHead,s=await D(e,o),a=await W(e),i=await fh(e,s.tree,a,o);if(i)return i;let c=await rn(e,s.tree,a);c.success&&(await ie(e,{version:2,entries:c.newEntries}),await Oe(e,c.worktreeOps)),n.headName!=="detached HEAD"?(await z(e,n.headName,o),await Ne(e,"HEAD",n.headName),await lt(e)):await gn(e,o);let f=n.headName==="detached HEAD"?o:n.headName;return await ne(e,t,"HEAD",r,o,`rebase (abort): returning to ${f}`),await de(e,"REBASE_HEAD"),await Bn(e),await Uo(e),{stdout:"",stderr:"",exitCode:0}}async function mh(e,t){let n="";if(!await ut(e))return T("no rebase in progress");let o=await W(e);if(Pt(o))return L(`error: Committing is not possible because you have unmerged files.
483
524
  hint: Fix them up in the work tree, and then use 'git add <file>'
484
525
  hint: as appropriate to mark resolution and make a commit.
485
526
  fatal: Exiting because of an unresolved conflict.
486
- `,128);let s=await F(e,"REBASE_HEAD");if(s){let i=await X(e);if(!i)return T("Cannot read HEAD");let c=await j(e,i),f=xe(o),d=await ke(e,f),u=d!==c.tree,l=await qe(e,"rebase-merge/message")!==null;if(u&&!l)return G(`error: you have staged changes in your working tree
527
+ `,128);let s=await F(e,"REBASE_HEAD");if(s){let i=await Y(e);if(!i)return T("Cannot read HEAD");let c=await D(e,i),f=He(o),d=await Ae(e,f),u=d!==c.tree,l=await Ce(e,"rebase-merge/message")!==null;if(u&&!l)return L(`error: you have staged changes in your working tree
487
528
  If these changes are meant to be squashed into the previous commit, run:
488
529
 
489
530
  git commit --amend
@@ -496,58 +537,58 @@ In both cases, once you're done, continue with:
496
537
 
497
538
  git rebase --continue
498
539
 
499
- `);if(u){let m=await j(e,s),h;h=await qe(e,"rebase-merge/message")??await qe(e,"MERGE_MSG")??void 0,h||(h=m.message);let p=await Le(e,t);if(S(p))return p;let g=ht(h),w=[i],x=await F(e,"MERGE_HEAD");x&&w.push(x);let b=await Je(e,d,w,m.author,p,g);x&&(await ae(e,"MERGE_HEAD"),await et(e,"MERGE_MODE"));let E=ue(g);await ee(e,t,"HEAD",i,b,`rebase (continue): ${E}`);let k=await Vu(e),P=await St(e,c.tree,d,m.author,p,!1);n=`${mt(k,b,g)}
500
- ${P}`}await ae(e,"REBASE_HEAD"),await ae(e,"CHERRY_PICK_HEAD"),await ae(e,"REVERT_HEAD"),await et(e,"MERGE_MSG"),await et(e,"rebase-merge/message")}let a=await Mo(e,t);return n&&(a.stdout=n+a.stdout),a}async function tm(e,t){if(!await nt(e))return T("no rebase in progress");let r=await X(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
540
+ `);if(u){let m=await D(e,s),h;h=await Ce(e,"rebase-merge/message")??await Ce(e,"MERGE_MSG")??void 0,h||(h=m.message);let p=await Ye(e,t);if(S(p))return p;let g=$t(h),w=[i],k=await F(e,"MERGE_HEAD");k&&w.push(k);let b=await dt(e,d,w,m.author,p,g);k&&(await de(e,"MERGE_HEAD"),await Se(e,"MERGE_MODE"));let E=se(g);await ne(e,t,"HEAD",i,b,`rebase (continue): ${E}`);let x=await ah(e),P=await Yt(e,c.tree,d,m.author,p,!1);n=`${Ot(x,b,g)}
541
+ ${P}`}await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await Se(e,"MERGE_MSG"),await Se(e,"rebase-merge/message")}let a=await yi(e,t);return n&&(a.stdout=n+a.stdout),a}async function hh(e,t){if(!await ut(e))return T("no rebase in progress");let r=await Y(e);if(!r)return{stdout:"",stderr:`error: could not determine HEAD revision
501
542
  fatal: could not discard worktree changes
502
- `,exitCode:128};let o=await j(e,r),s=await U(e),a=await Nt(e,o.tree,s);return a.success&&(await re(e,{version:2,entries:a.newEntries}),await be(e,a.worktreeOps)),await ae(e,"REBASE_HEAD"),await ae(e,"CHERRY_PICK_HEAD"),await ae(e,"REVERT_HEAD"),await et(e,"MERGE_MSG"),await et(e,"rebase-merge/message"),Mo(e,t)}function nm(e,t,n,r){return`${K(n)} ${e}@{${t}}: ${r}`}async function Os(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await F(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
543
+ `,exitCode:128};let o=await D(e,r),s=await W(e),a=await rn(e,o.tree,s);return a.success&&(await ie(e,{version:2,entries:a.newEntries}),await Oe(e,a.worktreeOps)),await de(e,"REBASE_HEAD"),await de(e,"CHERRY_PICK_HEAD"),await de(e,"REVERT_HEAD"),await Se(e,"MERGE_MSG"),await Se(e,"rebase-merge/message"),yi(e,t)}ee();fe();Me();ue();function ph(e,t,n,r){return`${K(n)} ${e}@{${t}}: ${r}`}async function oo(e,t,n){let r=t==="HEAD"?"HEAD":`refs/heads/${t}`;if(!await F(e,r))return{stdout:"",stderr:`fatal: ambiguous argument '${t}': unknown revision or path not in the working tree.
503
544
  Use '--' to separate paths from revisions, like this:
504
545
  'git <command> [<revision>...] -- [<file>...]'
505
- `,exitCode:128};let s=await Me(e,r),a=[],i=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<i;d--){let u=s[d];if(!u)continue;let l=s.length-1-d;u.newHash!==Z&&(a.push(nm(t,l,u.newHash,u.message)),c++)}return{stdout:a.length>0?`${a.join(`
546
+ `,exitCode:128};let s=await Ve(e,r),a=[],i=n!==void 0?n:s.length,c=0;for(let d=s.length-1;d>=0&&c<i;d--){let u=s[d];if(!u)continue;let l=s.length-1-d;u.newHash!==J&&(a.push(ph(t,l,u.newHash,u.message)),c++)}return{stdout:a.length>0?`${a.join(`
506
547
  `)}
507
- `:"",stderr:"",exitCode:0}}function Dc(e,t){return e.command("reflog",{description:"Manage reflog information",args:[W.string().name("args").variadic().optional()],options:{maxCount:te.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=s,i=r.args;if(i.length===0)return Os(a,"HEAD",r.maxCount);let c=i[0];if(!c)return Os(a,"HEAD",r.maxCount);if(c==="show"){let f=i[1]??"HEAD";return Os(a,f,r.maxCount)}if(c==="exists"){let f=i[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
508
- `,exitCode:128};let d=H(a.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await a.fs.exists(d)?0:1}}return Os(a,c,r.maxCount)}})}function rm(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 Mc(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:v().alias("v").describe("Show remote URLs")},handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i),f=rm(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let d=[];for(let u of f){let m=c[`remote "${u}"`]?.url??"";d.push(`${u} ${m} (fetch)`),d.push(`${u} ${m} (push)`)}return{stdout:`${d.join(`
548
+ `:"",stderr:"",exitCode:0}}function Tf(e,t){return e.command("reflog",{description:"Manage reflog information",args:[B.string().name("args").variadic().optional()],options:{maxCount:Q.number().alias("n").describe("Limit the number of entries to output")},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=s,i=r.args;if(i.length===0)return oo(a,"HEAD",r.maxCount);let c=i[0];if(!c)return oo(a,"HEAD",r.maxCount);if(c==="show"){let f=i[1]??"HEAD";return oo(a,f,r.maxCount)}if(c==="exists"){let f=i[1];if(!f)return{stdout:"",stderr:`fatal: reflog exists requires a ref argument
549
+ `,exitCode:128};let d=H(a.gitDir,"logs",f);return{stdout:"",stderr:"",exitCode:await a.fs.exists(d)?0:1}}return oo(a,c,r.maxCount)}})}ee();Ze();Me();ue();function gh(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 Hf(e,t){let n=e.command("remote",{description:"Manage set of tracked repositories",options:{verbose:A().alias("v").describe("Show remote URLs")},handler:async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i),f=gh(c);if(f.length===0)return{stdout:"",stderr:"",exitCode:0};if(s.verbose){let d=[];for(let u of f){let m=c[`remote "${u}"`]?.url??"";d.push(`${u} ${m} (fetch)`),d.push(`${u} ${m} (push)`)}return{stdout:`${d.join(`
509
550
  `)}
510
551
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
511
552
  `)}
512
- `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[W.string().name("name").describe("Remote name"),W.string().name("url").describe("Remote URL")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i),f=`remote "${s.name}"`;return f in c?G(`error: remote ${s.name} already exists.
513
- `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Ge(i,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i),f=`remote "${s.name}"`;return f in c?(delete c[f],om(c,s.name),await Ge(i,c),await im(i,s.name),{stdout:"",stderr:"",exitCode:0}):G(`error: No such remote: '${s.name}'
514
- `,2)},o=[W.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:[W.string().name("old").describe("Current remote name"),W.string().name("new").describe("New remote name")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i);return sm(i,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[W.string().name("name").describe("Remote name"),W.string().name("url").describe("New remote URL")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i),f=`remote "${s.name}"`;if(!(f in c))return G(`error: No such remote '${s.name}'
515
- `,2);let d=c[f];return d&&(d.url=s.url),await Ge(i,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[W.string().name("name").describe("Remote name")],handler:async(s,a)=>{let i=await B(a.fs,a.cwd,t);if(S(i))return i;let c=await ce(i),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
516
- `,stderr:"",exitCode:0}:G(`error: No such remote '${s.name}'
517
- `,2)}})}async function sm(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return G(`error: No such remote: '${n}'
518
- `,2);let s=`remote "${r}"`;if(s in t)return T(`remote ${r} already exists.`);let a={...t[o]};a.fetch&&(a.fetch=a.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=a,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Ge(e,t);let i=`refs/remotes/${n}`,c=await le(e,i);for(let f of c){let d=f.name.replace(i,`refs/remotes/${r}`),u=await Me(e,f.name);await Y(e,d,f.hash),await ae(e,f.name),u.length>0&&await Zt(e,d,u)}return{stdout:"",stderr:"",exitCode:0}}function om(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 im(e,t){let n=`refs/remotes/${t}`,r=await le(e,n);for(let o of r)await ae(e,o.name)}function Lc(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[W.string().name("args").variadic().optional()],options:{soft:v().describe("Only move HEAD"),mixed:v().describe("Move HEAD and reset index (default)"),hard:v().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return T("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,d=Ze(a,r.cwd);if(o.passthrough.length>0){let m=i.length>0?i[0]:void 0;return jo(a,o.passthrough,d,m,t)}if(!f&&i.length>0){let m=i[0],h=await je(a,m);return i.length===1&&h?jc(a,m,"mixed",r.env,t):h?jo(a,i.slice(1),d,m,t):jo(a,i,d,void 0,t)}let u=n.soft?"soft":n.hard?"hard":"mixed",l=i.length>0?i[0]:"HEAD";return jc(a,l,u,r.env,t)}})}async function jo(e,t,n,r,o){if(o?.hooks){let d=await o.hooks.emitPre("pre-reset",{mode:"paths",target:r??null});if(d)return{stdout:"",stderr:d.message??"",exitCode:1}}let s=null;if(r){let d=await je(e,r);if(!d)return xt(r);let u=await Ie(e,d);s=(await j(e,u)).tree}else{let d=await X(e);d&&(s=(await j(e,d)).tree)}let a=await se(e,s??null),i=await U(e);if(t.some(Ve)){let d=t.map(l=>Oe(l,n)),u=new Set;for(let[l]of a)u.add(l);for(let l of i.entries)u.add(l.path);for(let l of u){if(!me(d,l))continue;let m=a.get(l);m?i=Xe(i,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:pe()}):i=Ne(i,l)}}else for(let d of t){let u=a.get(d);if(u)i=Xe(i,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:pe()});else if(i.entries.some(m=>m.path===d))i=Ne(i,d);else if(!(e.workTree&&await e.fs.exists(H(e.workTree,d))))return xt(d)}await re(e,i);let f={stdout:await Gc(e,i),stderr:"",exitCode:0};return await o?.hooks?.emitPost("post-reset",{mode:"paths",targetHash:null}),f}async function Gc(e,t){if(!e.workTree)return"";let n=new Set;for(let a of t.entries)a.stage>0&&n.add(a.path);let o=(await ut(e,t)).filter(a=>a.status==="modified"||a.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let a of o){let i=a.status==="modified"?"M":"D";s.push(`${i} ${a.path}`)}for(let a of[...n].sort())s.push(`U ${a}`);return s.sort((a,i)=>{if(a==="Unstaged changes after reset:")return-1;if(i==="Unstaged changes after reset:")return 1;let c=a.slice(2),f=i.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
519
- `)}
520
- `}async function jc(e,t,n,r,o){if(o?.hooks){let l=await o.hooks.emitPre("pre-reset",{mode:n,target:t});if(l)return{stdout:"",stderr:l.message??"",exitCode:1}}let s=await je(e,t);if(!s)return xt(t);let a=await Ie(e,s),i=await j(e,a);if(n==="soft"){let l=await F(e,"MERGE_HEAD"),m=await U(e);if(l||lt(m))return T("Cannot do a soft reset in the middle of a merge.")}let c=await X(e),f=await J(e);f?.type==="symbolic"?await Y(e,f.target,a):await Y(e,"HEAD",a);let d=`reset: moving to ${t}`;if(f?.type==="symbolic"&&c!==a?await ee(e,r,f.target,c,a,d,!0):(f?.type==="symbolic"||c!==a)&&await ee(e,r,"HEAD",c,a,d),await yn(e),n==="mixed"){let l=await He(e,i.tree),m=Rr(l.map(p=>({path:p.path,mode:parseInt(p.mode,8),hash:p.hash,stage:0,stat:pe()})));await re(e,m);let h=await Gc(e,m);if(h)return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:a}),{stdout:h,stderr:"",exitCode:0}}if(n==="hard"){let l=Fe(e);if(l)return l;let m=await U(e),h=await Nt(e,i.tree,m);await re(e,{version:2,entries:h.newEntries}),await be(e,h.worktreeOps)}let u=n==="hard"?`HEAD is now at ${K(a)} ${ue(i.message)}
521
- `:"";return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}function Nc(e,t){e.command("restore",{description:"Restore working tree files",args:[W.string().name("pathspec").variadic().optional()],options:{source:te.string().alias("s").describe("Restore from tree-ish"),staged:v().alias("S").describe("Restore the index"),worktree:v().alias("W").describe("Restore the working tree (default)"),ours:v().describe("Checkout our version for unmerged files"),theirs:v().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=[...n.pathspec??[],...o.passthrough];if(i.length===0)return T("you must specify path(s) to restore");if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,d=Ze(a,r.cwd);if(n.ours||n.theirs)return n.source?T("cannot specify both --source and --ours/--theirs"):c?T("cannot use --ours/--theirs with --staged"):as(a,i,d,n.theirs?3:2,{deleteOnMissing:!0});let u=null;if(n.source){let l=await ye(a,n.source,`could not resolve '${n.source}'`);if(S(l))return l;u=l.commit.tree}else if(c){let l=await X(a);l&&(u=(await j(a,l)).tree)}return c&&f?fm(a,i,d,u):c?am(a,i,d,u):u?cm(a,i,d,u):is(a,i,d)}})}async function am(e,t,n,r){let o=await se(e,r),s=await U(e);if(t.some(Ve)){let i=t.map(d=>Oe(d,n)),c=new Set;for(let[d]of o)c.add(d);for(let d of s.entries)c.add(d.path);let f=!1;for(let d of c){if(!me(i,d))continue;f=!0;let u=o.get(d);u?s=Xe(s,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:pe()}):s=Ne(s,d)}if(!f)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
522
- `)}else for(let i of t){let c=o.get(i),f=s.entries.some(d=>d.path===i&&d.stage>0);if(c)s=Xe(s,{path:c.path,mode:parseInt(c.mode,8),hash:c.hash,stage:0,stat:pe()});else{if(f)return{stdout:"",stderr:`error: path '${i}' is unmerged
523
- `,exitCode:1};if(s.entries.some(u=>u.path===i))s=Ne(s,i);else return G(`error: pathspec '${i}' did not match any file(s) known to git
524
- `)}}return await re(e,s),{stdout:"",stderr:"",exitCode:0}}async function cm(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await se(e,r),s=t.some(Ve),a=[],i=await U(e);if(s){let c=t.map(d=>Oe(d,n)),f=new Set;for(let[d]of o)f.add(d);for(let d of i.entries)f.add(d.path);for(let d of f)me(c,d)&&a.push(d);if(a.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
553
+ `,stderr:"",exitCode:0}}});n.command("add",{description:"Add a remote named <name> for the repository at <url>",args:[B.string().name("name").describe("Remote name"),B.string().name("url").describe("Remote URL")],handler:async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i),f=`remote "${s.name}"`;return f in c?L(`error: remote ${s.name} already exists.
554
+ `,3):(c[f]={url:s.url,fetch:`+refs/heads/*:refs/remotes/${s.name}/*`},await Xe(i,c),{stdout:"",stderr:"",exitCode:0})}});let r=async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i),f=`remote "${s.name}"`;return f in c?(delete c[f],bh(c,s.name),await Xe(i,c),await yh(i,s.name),{stdout:"",stderr:"",exitCode:0}):L(`error: No such remote: '${s.name}'
555
+ `,2)},o=[B.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:[B.string().name("old").describe("Current remote name"),B.string().name("new").describe("New remote name")],handler:async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i);return wh(i,c,s.old,s.new)}}),n.command("set-url",{description:"Change the URL for an existing remote",args:[B.string().name("name").describe("Remote name"),B.string().name("url").describe("New remote URL")],handler:async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i),f=`remote "${s.name}"`;if(!(f in c))return L(`error: No such remote '${s.name}'
556
+ `,2);let d=c[f];return d&&(d.url=s.url),await Xe(i,c),{stdout:"",stderr:"",exitCode:0}}}),n.command("get-url",{description:"Retrieve the URL for an existing remote",args:[B.string().name("name").describe("Remote name")],handler:async(s,a)=>{let i=await U(a.fs,a.cwd,t);if(S(i))return i;let c=await me(i),f=`remote "${s.name}"`;return f in c?{stdout:`${c[f]?.url??""}
557
+ `,stderr:"",exitCode:0}:L(`error: No such remote '${s.name}'
558
+ `,2)}})}async function wh(e,t,n,r){let o=`remote "${n}"`;if(!(o in t))return L(`error: No such remote: '${n}'
559
+ `,2);let s=`remote "${r}"`;if(s in t)return T(`remote ${r} already exists.`);let a={...t[o]};a.fetch&&(a.fetch=a.fetch.replace(`refs/remotes/${n}/`,`refs/remotes/${r}/`)),t[s]=a,delete t[o];for(let f of Object.keys(t))f.match(/^branch "(.+)"$/)&&t[f]?.remote===n&&(t[f].remote=r);await Xe(e,t);let i=`refs/remotes/${n}`,c=await pe(e,i);for(let f of c){let d=f.name.replace(i,`refs/remotes/${r}`),u=await Ve(e,f.name);await z(e,d,f.hash),await de(e,f.name),u.length>0&&await wn(e,d,u)}return{stdout:"",stderr:"",exitCode:0}}function bh(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 yh(e,t){let n=`refs/remotes/${t}`,r=await pe(e,n);for(let o of r)await de(e,o.name)}ee();ye();re();fe();Me();ue();en();Ie();Wt();et();function vf(e,t){e.command("reset",{description:"Reset current HEAD to the specified state",args:[B.string().name("args").variadic().optional()],options:{soft:A().describe("Only move HEAD"),mixed:A().describe("Move HEAD and reset index (default)"),hard:A().describe("Move HEAD, reset index, and reset working tree")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n.args;if([n.soft,n.mixed,n.hard].filter(Boolean).length>1)return T("--soft, --mixed, and --hard are mutually exclusive");let f=n.soft||n.mixed||n.hard,d=ft(a,r.cwd);if(o.passthrough.length>0){let m=i.length>0?i[0]:void 0;return Ei(a,o.passthrough,d,m,t)}if(!f&&i.length>0){let m=i[0],h=await Fe(a,m);return i.length===1&&h?Af(a,m,"mixed",r.env,t):h?Ei(a,i.slice(1),d,m,t):Ei(a,i,d,void 0,t)}let u=n.soft?"soft":n.hard?"hard":"mixed",l=i.length>0?i[0]:"HEAD";return Af(a,l,u,r.env,t)}})}async function Ei(e,t,n,r,o){if(o?.hooks){let d=await o.hooks.emitPre("pre-reset",{mode:"paths",target:r??null});if(d)return{stdout:"",stderr:d.message??"",exitCode:1}}let s=null;if(r){let d=await Fe(e,r);if(!d)return Mt(r);let u=await Ge(e,d);s=(await D(e,u)).tree}else{let d=await Y(e);d&&(s=(await D(e,d)).tree)}let a=await ae(e,s??null),i=await W(e);if(t.some(ot)){let d=t.map(l=>je(l,n)),u=new Set;for(let[l]of a)u.add(l);for(let l of i.entries)u.add(l.path);for(let l of u){if(!we(d,l))continue;let m=a.get(l);m?i=ct(i,{path:m.path,mode:parseInt(m.mode,8),hash:m.hash,stage:0,stat:ke()}):i=Je(i,l)}}else for(let d of t){let u=a.get(d);if(u)i=ct(i,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:ke()});else if(i.entries.some(m=>m.path===d))i=Je(i,d);else if(!(e.workTree&&await e.fs.exists(H(e.workTree,d))))return Mt(d)}await ie(e,i);let f={stdout:await Sf(e,i),stderr:"",exitCode:0};return await o?.hooks?.emitPost("post-reset",{mode:"paths",targetHash:null}),f}async function Sf(e,t){if(!e.workTree)return"";let n=new Set;for(let a of t.entries)a.stage>0&&n.add(a.path);let o=(await Rt(e,t)).filter(a=>a.status==="modified"||a.status==="deleted");if(o.length===0&&n.size===0)return"";let s=["Unstaged changes after reset:"];for(let a of o){let i=a.status==="modified"?"M":"D";s.push(`${i} ${a.path}`)}for(let a of[...n].sort())s.push(`U ${a}`);return s.sort((a,i)=>{if(a==="Unstaged changes after reset:")return-1;if(i==="Unstaged changes after reset:")return 1;let c=a.slice(2),f=i.slice(2);return c<f?-1:c>f?1:0}),`${s.join(`
560
+ `)}
561
+ `}async function Af(e,t,n,r,o){if(o?.hooks){let l=await o.hooks.emitPre("pre-reset",{mode:n,target:t});if(l)return{stdout:"",stderr:l.message??"",exitCode:1}}let s=await Fe(e,t);if(!s)return Mt(t);let a=await Ge(e,s),i=await D(e,a);if(n==="soft"){let l=await F(e,"MERGE_HEAD"),m=await W(e);if(l||Pt(m))return T("Cannot do a soft reset in the middle of a merge.")}let c=await Y(e),f=await Z(e);f?.type==="symbolic"?await z(e,f.target,a):await z(e,"HEAD",a);let d=`reset: moving to ${t}`;if(f?.type==="symbolic"&&c!==a?await ne(e,r,f.target,c,a,d,!0):(f?.type==="symbolic"||c!==a)&&await ne(e,r,"HEAD",c,a,d),await Bn(e),n==="mixed"){let l=await Ue(e,i.tree),m=ns(l.map(p=>({path:p.path,mode:parseInt(p.mode,8),hash:p.hash,stage:0,stat:ke()})));await ie(e,m);let h=await Sf(e,m);if(h)return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:a}),{stdout:h,stderr:"",exitCode:0}}if(n==="hard"){let l=qe(e);if(l)return l;let m=await W(e),h=await rn(e,i.tree,m);await ie(e,{version:2,entries:h.newEntries}),await Oe(e,h.worktreeOps)}let u=n==="hard"?`HEAD is now at ${K(a)} ${se(i.message)}
562
+ `:"";return await o?.hooks?.emitPost("post-reset",{mode:n,targetHash:a}),{stdout:u,stderr:"",exitCode:0}}ee();ye();re();ue();Ie();et();function Df(e,t){e.command("restore",{description:"Restore working tree files",args:[B.string().name("pathspec").variadic().optional()],options:{source:Q.string().alias("s").describe("Restore from tree-ish"),staged:A().alias("S").describe("Restore the index"),worktree:A().alias("W").describe("Restore the working tree (default)"),ours:A().describe("Checkout our version for unmerged files"),theirs:A().describe("Checkout their version for unmerged files")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=[...n.pathspec??[],...o.passthrough];if(i.length===0)return T("you must specify path(s) to restore");if(n.ours&&n.theirs)return T("--ours and --theirs are incompatible");let c=!!n.staged,f=n.worktree!==void 0?!!n.worktree:!c,d=ft(a,r.cwd);if(n.ours||n.theirs)return n.source?T("cannot specify both --source and --ours/--theirs"):c?T("cannot use --ours/--theirs with --staged"):Ds(a,i,d,n.theirs?3:2,{deleteOnMissing:!0});let u=null;if(n.source){let l=await $e(a,n.source,`could not resolve '${n.source}'`);if(S(l))return l;u=l.commit.tree}else if(c){let l=await Y(a);l&&(u=(await D(a,l)).tree)}return c&&f?xh(a,i,d,u):c?Eh(a,i,d,u):u?kh(a,i,d,u):Ss(a,i,d)}})}async function Eh(e,t,n,r){let o=await ae(e,r),s=await W(e);if(t.some(ot)){let i=t.map(d=>je(d,n)),c=new Set;for(let[d]of o)c.add(d);for(let d of s.entries)c.add(d.path);let f=!1;for(let d of c){if(!we(i,d))continue;f=!0;let u=o.get(d);u?s=ct(s,{path:u.path,mode:parseInt(u.mode,8),hash:u.hash,stage:0,stat:ke()}):s=Je(s,d)}if(!f)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
563
+ `)}else for(let i of t){let c=o.get(i),f=s.entries.some(d=>d.path===i&&d.stage>0);if(c)s=ct(s,{path:c.path,mode:parseInt(c.mode,8),hash:c.hash,stage:0,stat:ke()});else{if(f)return{stdout:"",stderr:`error: path '${i}' is unmerged
564
+ `,exitCode:1};if(s.entries.some(u=>u.path===i))s=Je(s,i);else return L(`error: pathspec '${i}' did not match any file(s) known to git
565
+ `)}}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}async function kh(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await ae(e,r),s=t.some(ot),a=[],i=await W(e);if(s){let c=t.map(d=>je(d,n)),f=new Set;for(let[d]of o)f.add(d);for(let d of i.entries)f.add(d.path);for(let d of f)we(c,d)&&a.push(d);if(a.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
525
566
  `)}else for(let c of t){let f=o.has(c);if(!f&&i.entries.some(l=>l.path===c&&l.stage!==0))return{stdout:"",stderr:`error: path '${c}' is unmerged
526
- `,exitCode:1};let d=Dt(i,c);if(!f&&!d)return G(`error: pathspec '${c}' did not match any file(s) known to git
527
- `);a.push(c)}for(let c of a){let f=o.get(c);if(f)await ve(e,{path:f.path,hash:f.hash,mode:f.mode});else{let d=`${e.workTree}/${c}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function fm(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await se(e,r),s=await U(e),a=t.some(Ve),i=[];if(a){let c=t.map(d=>Oe(d,n)),f=new Set;for(let[d]of o)f.add(d);for(let d of s.entries)f.add(d.path);for(let d of f)me(c,d)&&i.push(d);if(i.length===0)return G(`error: pathspec '${t[0]}' did not match any file(s) known to git
567
+ `,exitCode:1};let d=Xt(i,c);if(!f&&!d)return L(`error: pathspec '${c}' did not match any file(s) known to git
568
+ `);a.push(c)}for(let c of a){let f=o.get(c);if(f)await We(e,{path:f.path,hash:f.hash,mode:f.mode});else{let d=`${e.workTree}/${c}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return{stdout:"",stderr:"",exitCode:0}}async function xh(e,t,n,r){if(!e.workTree)return T("this operation must be run in a work tree");let o=await ae(e,r),s=await W(e),a=t.some(ot),i=[];if(a){let c=t.map(d=>je(d,n)),f=new Set;for(let[d]of o)f.add(d);for(let d of s.entries)f.add(d.path);for(let d of f)we(c,d)&&i.push(d);if(i.length===0)return L(`error: pathspec '${t[0]}' did not match any file(s) known to git
528
569
  `)}else for(let c of t){if(s.entries.some(l=>l.path===c&&l.stage>0))return{stdout:"",stderr:`error: path '${c}' is unmerged
529
- `,exitCode:1};let d=o.get(c),u=s.entries.some(l=>l.path===c);if(!d&&!u)return G(`error: pathspec '${c}' did not match any file(s) known to git
530
- `);i.push(c)}for(let c of i){let f=o.get(c);if(f)s=Xe(s,{path:f.path,mode:parseInt(f.mode,8),hash:f.hash,stage:0,stat:pe()}),await ve(e,{path:f.path,hash:f.hash,mode:f.mode});else{s=Ne(s,c);let d=`${e.workTree}/${c}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return await re(e,s),{stdout:"",stderr:"",exitCode:0}}function _c(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[W.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:v().describe("Verify that exactly one parameter is provided and resolves to an object"),short:v().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":v().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":v().describe("Output the full symbolic ref name"),"show-toplevel":v().describe("Show the absolute path of the top-level directory"),"git-dir":v().describe("Show the path to the .git directory"),"is-inside-work-tree":v().describe("Output whether cwd is inside the work tree"),"is-bare-repository":v().describe("Output whether the repository is bare"),"show-prefix":v().describe("Show path of cwd relative to top-level directory"),"show-cdup":v().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(E=>E!==""),s=n.verify,a=n.short,i=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],d=n["git-dir"],u=n["is-inside-work-tree"],l=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||d||u||l||m||h,g=await B(r.fs,r.cwd,t);if(S(g))return g;let w=g,x=[];if(f){if(!w.workTree)return T("this operation must be run in a work tree");x.push(w.workTree)}if(d&&x.push(w.gitDir),u&&x.push(w.workTree?"true":"false"),l&&x.push(w.workTree?"false":"true"),m){if(!w.workTree)return T("this operation must be run in a work tree");let E=Ke(w.workTree,r.cwd);x.push(E===""?"":`${E}/`)}if(h){if(!w.workTree)return T("this operation must be run in a work tree");let E=Ke(r.cwd,w.workTree);x.push(E===""?"":`${E}/`)}if(p&&o.length===0)return{stdout:x.map(k=>`${k}
531
- `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return T("Needed a single revision");for(let E of o){if(i){let P=await dm(w,E);if(P===null)return Lo(E,s);x.push(P);continue}if(c){let P=await lm(w,E);if(P===null)return Lo(E,s);x.push(P);continue}let k=await je(w,E);if(!k)return Lo(E,s);x.push(a?K(k):k)}return{stdout:x.map(E=>`${E}
532
- `).join(""),stderr:"",exitCode:0}}})}function Lo(e,t){return t?T("Needed a single revision"):xt(e)}async function dm(e,t){if(t==="HEAD"||t==="@"){let r=await J(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 je(e,t)?t:null}async function lm(e,t){if(t==="HEAD"||t==="@"){let r=await J(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await je(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await F(e,o))return o}return t}function Fc(e,t){e.command("revert",{description:"Revert some existing commits",args:[W.string().name("commit").describe("The commit to revert").optional()],options:{abort:v().describe("Abort the current revert operation"),continue:v().describe("Continue the revert after conflict resolution"),"no-commit":v().alias("n").describe("Apply changes without creating a commit"),"no-edit":v().describe("Do not edit the commit message"),mainline:te.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let _=await t.hooks.emitPre("pre-revert",{mode:"abort",commit:null});if(_)return{stdout:"",stderr:_.message??"",exitCode:1}}let R=await um(s,r.env);return R.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"abort",commitHash:null,hadConflicts:!1}),R}if(n.continue){if(t?.hooks){let _=await t.hooks.emitPre("pre-revert",{mode:"continue",commit:null});if(_)return{stdout:"",stderr:_.message??"",exitCode:1}}let R=await mm(s,r.env);return R.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"continue",commitHash:null,hadConflicts:!1}),R}let a=n.commit;if(!a)return T("you must specify a commit to revert");if(t?.hooks){let R=await t.hooks.emitPre("pre-revert",{mode:"revert",commit:a});if(R)return{stdout:"",stderr:R.message??"",exitCode:1}}let i=await ye(s,a);if(S(i))return i;let c=i.hash,f=i.commit,d=await Se(s);if(S(d))return d;let u=await U(s),l=_t(u,"Reverting",`fatal: revert failed
533
- `);if(l)return l;let m=await j(s,d);if(s.workTree){let R=await se(s,m.tree);if(Dn(u,R))return G(`error: your local changes would be overwritten by revert.
570
+ `,exitCode:1};let d=o.get(c),u=s.entries.some(l=>l.path===c);if(!d&&!u)return L(`error: pathspec '${c}' did not match any file(s) known to git
571
+ `);i.push(c)}for(let c of i){let f=o.get(c);if(f)s=ct(s,{path:f.path,mode:parseInt(f.mode,8),hash:f.hash,stage:0,stat:ke()}),await We(e,{path:f.path,hash:f.hash,mode:f.mode});else{s=Je(s,c);let d=`${e.workTree}/${c}`;await e.fs.exists(d)&&await e.fs.rm(d)}}return await ie(e,s),{stdout:"",stderr:"",exitCode:0}}ee();fe();ue();en();function Mf(e,t){e.command("rev-parse",{description:"Pick out and massage parameters",args:[B.string().name("args").describe("Refs or revision expressions to resolve").optional().variadic()],options:{verify:A().describe("Verify that exactly one parameter is provided and resolves to an object"),short:A().describe("Abbreviate object name (default 7 chars)"),"abbrev-ref":A().describe("Output abbreviated ref name instead of object hash"),"symbolic-full-name":A().describe("Output the full symbolic ref name"),"show-toplevel":A().describe("Show the absolute path of the top-level directory"),"git-dir":A().describe("Show the path to the .git directory"),"is-inside-work-tree":A().describe("Output whether cwd is inside the work tree"),"is-bare-repository":A().describe("Output whether the repository is bare"),"show-prefix":A().describe("Show path of cwd relative to top-level directory"),"show-cdup":A().describe("Show relative path from cwd up to top-level directory")},handler:async(n,r)=>{let o=n.args.filter(E=>E!==""),s=n.verify,a=n.short,i=n["abbrev-ref"],c=n["symbolic-full-name"],f=n["show-toplevel"],d=n["git-dir"],u=n["is-inside-work-tree"],l=n["is-bare-repository"],m=n["show-prefix"],h=n["show-cdup"],p=f||d||u||l||m||h,g=await U(r.fs,r.cwd,t);if(S(g))return g;let w=g,k=[];if(f){if(!w.workTree)return T("this operation must be run in a work tree");k.push(w.workTree)}if(d&&k.push(w.gitDir),u&&k.push(w.workTree?"true":"false"),l&&k.push(w.workTree?"false":"true"),m){if(!w.workTree)return T("this operation must be run in a work tree");let E=rt(w.workTree,r.cwd);k.push(E===""?"":`${E}/`)}if(h){if(!w.workTree)return T("this operation must be run in a work tree");let E=rt(r.cwd,w.workTree);k.push(E===""?"":`${E}/`)}if(p&&o.length===0)return{stdout:k.map(x=>`${x}
572
+ `).join(""),stderr:"",exitCode:0};if(s&&o.length!==1)return T("Needed a single revision");for(let E of o){if(i){let P=await Ch(w,E);if(P===null)return ki(E,s);k.push(P);continue}if(c){let P=await Ph(w,E);if(P===null)return ki(E,s);k.push(P);continue}let x=await Fe(w,E);if(!x)return ki(E,s);k.push(a?K(x):x)}return{stdout:k.map(E=>`${E}
573
+ `).join(""),stderr:"",exitCode:0}}})}function ki(e,t){return t?T("Needed a single revision"):Mt(e)}async function Ch(e,t){if(t==="HEAD"||t==="@"){let r=await Z(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 Fe(e,t)?t:null}async function Ph(e,t){if(t==="HEAD"||t==="@"){let r=await Z(e);return r?r.type==="symbolic"?r.target:"HEAD":null}if(!await Fe(e,t))return null;if(t.startsWith("refs/"))return t;for(let r of["refs/heads/","refs/tags/","refs/remotes/"]){let o=`${r}${t}`;if(await F(e,o))return o}return t}ee();ye();re();Me();ue();Ie();function jf(e,t){e.command("revert",{description:"Revert some existing commits",args:[B.string().name("commit").describe("The commit to revert").optional()],options:{abort:A().describe("Abort the current revert operation"),continue:A().describe("Continue the revert after conflict resolution"),"no-commit":A().alias("n").describe("Apply changes without creating a commit"),"no-edit":A().describe("Do not edit the commit message"),mainline:Q.number().alias("m").describe("Select the parent number for reverting merges")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.abort){if(t?.hooks){let _=await t.hooks.emitPre("pre-revert",{mode:"abort",commit:null});if(_)return{stdout:"",stderr:_.message??"",exitCode:1}}let O=await Rh(s,r.env);return O.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"abort",commitHash:null,hadConflicts:!1}),O}if(n.continue){if(t?.hooks){let _=await t.hooks.emitPre("pre-revert",{mode:"continue",commit:null});if(_)return{stdout:"",stderr:_.message??"",exitCode:1}}let O=await Ih(s,r.env);return O.exitCode===0&&await t?.hooks?.emitPost("post-revert",{mode:"continue",commitHash:null,hadConflicts:!1}),O}let a=n.commit;if(!a)return T("you must specify a commit to revert");if(t?.hooks){let O=await t.hooks.emitPre("pre-revert",{mode:"revert",commit:a});if(O)return{stdout:"",stderr:O.message??"",exitCode:1}}let i=await $e(s,a);if(S(i))return i;let c=i.hash,f=i.commit,d=await Ke(s);if(S(d))return d;let u=await W(s),l=sn(u,"Reverting",`fatal: revert failed
574
+ `);if(l)return l;let m=await D(s,d);if(s.workTree){let O=await ae(s,m.tree);if(nr(u,O))return L(`error: your local changes would be overwritten by revert.
534
575
  hint: commit your changes or stash them to proceed.
535
576
  fatal: revert failed
536
- `,128)}let h=n.mainline,p;if(f.parents.length>1){if(h===void 0)return G(`error: commit ${c} is a merge but no -m option was given.
577
+ `,128)}let h=n.mainline,p;if(f.parents.length>1){if(h===void 0)return L(`error: commit ${c} is a merge but no -m option was given.
537
578
  fatal: revert failed
538
- `,128);if(h<1||h>f.parents.length)return G(`error: commit ${c} does not have parent ${h}
579
+ `,128);if(h<1||h>f.parents.length)return L(`error: commit ${c} does not have parent ${h}
539
580
  fatal: revert failed
540
- `,128);let R=f.parents[h-1];p=(await j(s,R)).tree}else if(f.parents.length===0)p=await ke(s,[]);else{let R=f.parents[0];p=(await j(s,R)).tree}let g=K(c),w=ue(f.message),x=Uc(f,c,h),b={a:"HEAD",b:w?`parent of ${g} (${w})`:`parent of ${g}`},E=await yt(s,f.tree,m.tree,p,b);if(E.conflicts.length===0&&E.resultTree===m.tree){let R=E.messages.length>0?`${E.messages.join(`
581
+ `,128);let O=f.parents[h-1];p=(await D(s,O)).tree}else if(f.parents.length===0)p=await Ae(s,[]);else{let O=f.parents[0];p=(await D(s,O)).tree}let g=K(c),w=se(f.message),k=Gf(f,c,h),b={a:"HEAD",b:w?`parent of ${g} (${w})`:`parent of ${g}`},E=await St(s,f.tree,m.tree,p,b);if(E.conflicts.length===0&&E.resultTree===m.tree){let O=E.messages.length>0?`${E.messages.join(`
541
582
  `)}
542
- `:"",_=await Be(s,{fromCommit:!0}),q=await F(s,"CHERRY_PICK_HEAD");return{stdout:`${R}${_}`,stderr:q?`The previous cherry-pick is now empty, possibly due to conflict resolution.
583
+ `:"",_=await tt(s,{fromCommit:!0}),q=await F(s,"CHERRY_PICK_HEAD");return{stdout:`${O}${_}`,stderr:q?`The previous cherry-pick is now empty, possibly due to conflict resolution.
543
584
  If you wish to commit it anyway, use:
544
585
 
545
586
  git commit --allow-empty
546
587
 
547
588
  Otherwise, please use 'git cherry-pick --skip'
548
- `:"",exitCode:1}}let k=await qt(s,E,m.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!k.ok)return k;if(E.conflicts.length>0){await Y(s,"REVERT_HEAD",c),await Y(s,"ORIG_HEAD",d),await Ue(s,"MERGE_MSG",x);let R=E.messages.join(`
549
- `);return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:R?`${R}
550
- `:"",stderr:`error: could not revert ${g}... ${ue(f.message)}
589
+ `:"",exitCode:1}}let x=await dn(s,E,m.tree,{labels:b,errorExitCode:128,operationName:"merge",callerCommand:"revert",skipStagedChangeCheck:!0});if(!x.ok)return x;if(E.conflicts.length>0){await z(s,"REVERT_HEAD",c),await z(s,"ORIG_HEAD",d),await Pe(s,"MERGE_MSG",k);let O=E.messages.join(`
590
+ `);return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:null,hadConflicts:!0}),{stdout:O?`${O}
591
+ `:"",stderr:`error: could not revert ${g}... ${se(f.message)}
551
592
  hint: After resolving the conflicts, mark them with
552
593
  hint: "git add/rm <pathspec>", then run
553
594
  hint: "git revert --continue".
@@ -555,105 +596,105 @@ hint: You can instead skip this commit with "git revert --skip".
555
596
  hint: To abort and get back to the state before "git revert",
556
597
  hint: run "git revert --abort".
557
598
  hint: Disable this message with "git config set advice.mergeConflict false"
558
- `,exitCode:1}}if(n["no-commit"])return await Y(s,"REVERT_HEAD",c),await Ue(s,"MERGE_MSG",x),{stdout:"",stderr:"",exitCode:0};let P=k.mergedTreeHash,C=await Ht(s,r.env);if(S(C))return C;let O=await Le(s,r.env);if(S(O))return O;let y=await Je(s,P,[d],C,O,x);await wt(s),await kt(s);let I=await J(s),A=ue(x),L=I?.type==="symbolic"?I.target:"HEAD";await ee(s,r.env,L,d,y,`revert: ${A}`,I?.type==="symbolic");let D=I?.type==="symbolic"?de(I.target):"detached HEAD",z=await St(s,m.tree,P,C,O,C.timestamp!==O.timestamp||C.timezone!==O.timezone),M=mt(D,y,x),$=E.messages.length>0?`${E.messages.join(`
599
+ `,exitCode:1}}if(n["no-commit"])return await z(s,"REVERT_HEAD",c),await Pe(s,"MERGE_MSG",k),{stdout:"",stderr:"",exitCode:0};let P=x.mergedTreeHash,C=await qt(s,r.env);if(S(C))return C;let R=await Ye(s,r.env);if(S(R))return R;let y=await dt(s,P,[d],C,R,k);await Tt(s),await jt(s);let I=await Z(s),v=se(k),G=I?.type==="symbolic"?I.target:"HEAD";await ne(s,r.env,G,d,y,`revert: ${v}`,I?.type==="symbolic");let M=I?.type==="symbolic"?ge(I.target):"detached HEAD",V=await Yt(s,m.tree,P,C,R,C.timestamp!==R.timestamp||C.timezone!==R.timezone),j=Ot(M,y,k),$=E.messages.length>0?`${E.messages.join(`
559
600
  `)}
560
- `:"";return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:y,hadConflicts:!1}),{stdout:`${$}${M}
561
- ${z}`,stderr:"",exitCode:0}}})}async function um(e,t){return await F(e,"REVERT_HEAD")?tn(e,t,{operationRef:"REVERT_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
601
+ `:"";return await t?.hooks?.emitPost("post-revert",{mode:"revert",commitHash:y,hadConflicts:!1}),{stdout:`${$}${j}
602
+ ${V}`,stderr:"",exitCode:0}}})}async function Rh(e,t){return await F(e,"REVERT_HEAD")?kn(e,t,{operationRef:"REVERT_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
562
603
  fatal: revert failed
563
- `,128),operationName:"revert",clearState:wt,origHeadAsTargetRev:!0}):await F(e,"CHERRY_PICK_HEAD")?tn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:G(`error: no cherry-pick or revert in progress
604
+ `,128),operationName:"revert",clearState:Tt,origHeadAsTargetRev:!0}):await F(e,"CHERRY_PICK_HEAD")?kn(e,t,{operationRef:"CHERRY_PICK_HEAD",noOpError:L(`error: no cherry-pick or revert in progress
564
605
  fatal: revert failed
565
- `,128),operationName:"revert",clearState:kt,origHeadAsTargetRev:!0}):G(`error: no cherry-pick or revert in progress
606
+ `,128),operationName:"revert",clearState:jt,origHeadAsTargetRev:!0}):L(`error: no cherry-pick or revert in progress
566
607
  fatal: revert failed
567
- `,128)}async function mm(e,t){let n=await F(e,"REVERT_HEAD");if(!n)return G(`error: no cherry-pick or revert in progress
608
+ `,128)}async function Ih(e,t){let n=await F(e,"REVERT_HEAD");if(!n)return L(`error: no cherry-pick or revert in progress
568
609
  fatal: revert failed
569
- `,128);let r=await U(e),o=_t(r,"Committing");if(o)return o;let s=await qe(e,"MERGE_MSG");if(!s){let E=await j(e,n);s=Uc(E,n)}let a=xe(r),i=await ke(e,a),c=await Se(e);if(S(c))return c;let f=await j(e,c),d=await Ht(e,t);if(S(d))return d;let u=await Le(e,t);if(S(u))return u;let l=ht(s),m=await Je(e,i,[c],d,u,l);await wt(e),await kt(e);let h=await J(e),p=ue(l),g=h?.type==="symbolic"?h.target:"HEAD";await ee(e,t,g,c,m,`commit: ${p}`,h?.type==="symbolic");let w=h?.type==="symbolic"?de(h.target):"detached HEAD",x=await St(e,f.tree,i,d,u,d.timestamp!==u.timestamp||d.timezone!==u.timezone);return{stdout:`${mt(w,m,s)}
570
- ${x}`,stderr:"",exitCode:0}}function Uc(e,t,n){let r=ue(e.message),o='Revert "',i=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
610
+ `,128);let r=await W(e),o=sn(r,"Committing");if(o)return o;let s=await Ce(e,"MERGE_MSG");if(!s){let E=await D(e,n);s=Gf(E,n)}let a=He(r),i=await Ae(e,a),c=await Ke(e);if(S(c))return c;let f=await D(e,c),d=await qt(e,t);if(S(d))return d;let u=await Ye(e,t);if(S(u))return u;let l=$t(s),m=await dt(e,i,[c],d,u,l);await Tt(e),await jt(e);let h=await Z(e),p=se(l),g=h?.type==="symbolic"?h.target:"HEAD";await ne(e,t,g,c,m,`commit: ${p}`,h?.type==="symbolic");let w=h?.type==="symbolic"?ge(h.target):"detached HEAD",k=await Yt(e,f.tree,i,d,u,d.timestamp!==u.timestamp||d.timezone!==u.timezone);return{stdout:`${Ot(w,m,s)}
611
+ ${k}`,stderr:"",exitCode:0}}function Gf(e,t,n){let r=se(e.message),o='Revert "',i=`${r.startsWith(o)&&r.endsWith('"')?`Reapply "${r.slice(o.length,-1)}"`:`Revert "${r}"`}
571
612
 
572
613
  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];i+=`, reversing
573
614
  changes made to ${c}`}return i+=`.
574
- `,i}function Bc(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[W.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:v().describe("Only remove from the index"),recursive:v().alias("r").describe("Allow recursive removal when a directory name is given"),force:v().alias("f").describe("Override the up-to-date check"),dryRun:v().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=Fe(s);if(a)return a;let i=s.workTree,c=n.paths;if(c.length===0)return G("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,d=n.recursive,u=n.force;if(t?.hooks){let w=await t.hooks.emitPre("pre-rm",{paths:c,cached:f,recursive:d,force:u});if(w)return{stdout:"",stderr:w.message??"",exitCode:1}}let l=await U(s),m=[],h=Ze(s,r.cwd);for(let w of c){if(Ve(w)){let k=[Oe(w,h)],P=l.entries.filter(C=>me(k,C.path));if(P.length===0)return T(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path);continue}let x=ft(r.cwd,w),b=Ke(i,x);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return T(`'${w}' is outside repository at '${i}'`);if(await r.fs.exists(x)&&!(await ze(r.fs,x)).isSymbolicLink&&(await ze(r.fs,x)).isDirectory){if(!d)return T(`not removing '${b}' recursively without -r`);let k=b===""?"":`${b}/`,P=l.entries.filter(C=>k===""||C.path.startsWith(k));if(P.length===0)return T(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path)}else{if(!l.entries.some(P=>P.path===b))return T(`pathspec '${w}' did not match any files`);m.push(b)}}if(!u){let w=await hm(s,l,m,f);if(w)return w}if(n.dryRun){let w=m.map(b=>`rm '${b}'`);return{stdout:w.length>0?`${w.join(`
615
+ `,i}ee();ye();re();fe();ue();Gn();Ie();function Lf(e,t){e.command("rm",{description:"Remove files from the working tree and from the index",args:[B.string().name("paths").describe("Files to remove").optional().variadic()],options:{cached:A().describe("Only remove from the index"),recursive:A().alias("r").describe("Allow recursive removal when a directory name is given"),force:A().alias("f").describe("Override the up-to-date check"),dryRun:A().alias("n").describe("Don't actually remove any file(s)")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,a=qe(s);if(a)return a;let i=s.workTree,c=n.paths;if(c.length===0)return L("usage: git rm [--cached] [-f] [-r] <file>...");let f=n.cached,d=n.recursive,u=n.force;if(t?.hooks){let w=await t.hooks.emitPre("pre-rm",{paths:c,cached:f,recursive:d,force:u});if(w)return{stdout:"",stderr:w.message??"",exitCode:1}}let l=await W(s),m=[],h=ft(s,r.cwd);for(let w of c){if(ot(w)){let x=[je(w,h)],P=l.entries.filter(C=>we(x,C.path));if(P.length===0)return T(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path);continue}let k=xt(r.cwd,w),b=rt(i,k);if((b==="."||b==="")&&(b=""),b.startsWith(".."))return T(`'${w}' is outside repository at '${i}'`);if(await r.fs.exists(k)&&!(await st(r.fs,k)).isSymbolicLink&&(await st(r.fs,k)).isDirectory){if(!d)return T(`not removing '${b}' recursively without -r`);let x=b===""?"":`${b}/`,P=l.entries.filter(C=>x===""||C.path.startsWith(x));if(P.length===0)return T(`pathspec '${w}' did not match any files`);for(let C of P)m.push(C.path)}else{if(!l.entries.some(P=>P.path===b))return T(`pathspec '${w}' did not match any files`);m.push(b)}}if(!u){let w=await Oh(s,l,m,f);if(w)return w}if(n.dryRun){let w=m.map(b=>`rm '${b}'`);return{stdout:w.length>0?`${w.join(`
575
616
  `)}
576
- `:"",stderr:"",exitCode:0}}let p=[];for(let w of m){if(l=Ne(l,w),!f){let x=H(i,w);await ze(r.fs,x).then(()=>!0).catch(()=>!1)&&await r.fs.rm(x)}p.push(`rm '${w}'`)}await re(s,l);let g=p.length>0?`${p.join(`
617
+ `:"",stderr:"",exitCode:0}}let p=[];for(let w of m){if(l=Je(l,w),!f){let k=H(i,w);await st(r.fs,k).then(()=>!0).catch(()=>!1)&&await r.fs.rm(k)}p.push(`rm '${w}'`)}await ie(s,l);let g=p.length>0?`${p.join(`
577
618
  `)}
578
- `:"";return await t?.hooks?.emitPost("post-rm",{removedPaths:m,cached:f}),{stdout:g,stderr:"",exitCode:0}}})}async function hm(e,t,n,r){let o=await X(e),s=new Map;if(o){let f=await j(e,o),d=await He(e,f.tree);for(let u of d)s.set(u.path,u.hash)}let a=[],i=[],c=[];for(let f of n){let d=t.entries.find(h=>h.path===f&&h.stage===0);if(!d)continue;let l=s.get(f)!==d.hash,m=!1;if(e.workTree){let h=H(e.workTree,f),p=!1;try{await ze(e.fs,h),p=!0}catch{p=!1}p&&(m=await Jt(e.fs,h)!==d.hash)}l&&m?a.push(f):l&&!r?i.push(f):m&&!r&&c.push(f)}if(a.length>0){let f=a.map(u=>` ${u}`).join(`
579
- `),d=a.length===1?"the following file has":"the following files have";return G(`error: ${d} staged content different from both the
619
+ `:"";return await t?.hooks?.emitPost("post-rm",{removedPaths:m,cached:f}),{stdout:g,stderr:"",exitCode:0}}})}async function Oh(e,t,n,r){let o=await Y(e),s=new Map;if(o){let f=await D(e,o),d=await Ue(e,f.tree);for(let u of d)s.set(u.path,u.hash)}let a=[],i=[],c=[];for(let f of n){let d=t.entries.find(h=>h.path===f&&h.stage===0);if(!d)continue;let l=s.get(f)!==d.hash,m=!1;if(e.workTree){let h=H(e.workTree,f),p=!1;try{await st(e.fs,h),p=!0}catch{p=!1}p&&(m=await bn(e.fs,h)!==d.hash)}l&&m?a.push(f):l&&!r?i.push(f):m&&!r&&c.push(f)}if(a.length>0){let f=a.map(u=>` ${u}`).join(`
620
+ `),d=a.length===1?"the following file has":"the following files have";return L(`error: ${d} staged content different from both the
580
621
  file and the HEAD:
581
622
  ${f}
582
623
  (use -f to force removal)
583
624
  `)}if(i.length>0){let f=i.map(u=>` ${u}`).join(`
584
- `),d=i.length===1?"the following file has":"the following files have";return G(`error: ${d} changes staged in the index:
625
+ `),d=i.length===1?"the following file has":"the following files have";return L(`error: ${d} changes staged in the index:
585
626
  ${f}
586
627
  (use --cached to keep the file, or -f to force removal)
587
628
  `)}if(c.length>0){let f=c.map(u=>` ${u}`).join(`
588
- `),d=c.length===1?"the following file has":"the following files have";return G(`error: ${d} local modifications:
629
+ `),d=c.length===1?"the following file has":"the following files have";return L(`error: ${d} local modifications:
589
630
  ${f}
590
631
  (use --cached to keep the file, or -f to force removal)
591
- `)}return null}var Go=new TextDecoder;function Wc(e,t){e.command("show",{description:"Show various types of objects",args:[W.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.object[0]??"HEAD",c=Hi(i);if(c)return pm(s,c.rev,c.path);if(i==="HEAD"){let u=await Se(s);if(S(u))return u}let f=await Sn(s,i,`bad object '${i}'`);if(S(f))return f;let d=await fe(s,f);switch(d.type){case"commit":{let u=await j(s,f);return{stdout:await qc(s,f,u),stderr:"",exitCode:0}}case"tag":{let u=await ki(s,f);return{stdout:await gm(s,u),stderr:"",exitCode:0}}case"tree":{let u=Qt(d.content);return{stdout:Kc(u),stderr:"",exitCode:0}}case"blob":return{stdout:Go.decode(d.content),stderr:"",exitCode:0}}}})}async function pm(e,t,n){let r=await ye(e,t);if(S(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),i=(await se(e,o)).get(s);if(!i){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let d=H(e.workTree,s);await e.fs.exists(d)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return T(f)}let c=await fe(e,i.hash);if(c.type==="blob")return{stdout:Go.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=Qt(c.content);return{stdout:Kc(f),stderr:"",exitCode:0}}return{stdout:Go.decode(c.content),stderr:"",exitCode:0}}async function qc(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(a=>K(a)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${vt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
592
- `))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await j(e,n.parents[0])).tree:null,a=await Ae(e,s,n.tree),{remaining:i,renames:c}=await Ye(e,a),f=await ym(e,i,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await Em(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
632
+ `)}return null}ee();re();en();ms();fe();Ie();var xi=new TextDecoder;function Nf(e,t){e.command("show",{description:"Show various types of objects",args:[B.string().name("object").variadic().optional()],handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o,i=n.object[0]??"HEAD",c=wa(i);if(c)return $h(s,c.rev,c.path);if(i==="HEAD"){let u=await Ke(s);if(S(u))return u}let f=await It(s,i,`bad object '${i}'`);if(S(f))return f;let d=await he(s,f);switch(d.type){case"commit":{let u=await D(s,f);return{stdout:await _f(s,f,u),stderr:"",exitCode:0}}case"tag":{let u=await fa(s,f);return{stdout:await Th(s,u),stderr:"",exitCode:0}}case"tree":{let u=yn(d.content);return{stdout:Ff(u),stderr:"",exitCode:0}}case"blob":return{stdout:xi.decode(d.content),stderr:"",exitCode:0}}}})}async function $h(e,t,n){let r=await $e(e,t);if(S(r))return r;let o=r.commit.tree,s=n.replace(/^\//,""),i=(await ae(e,o)).get(s);if(!i){let f=`path '${s}' does not exist in '${t}'`;if(e.workTree){let d=H(e.workTree,s);await e.fs.exists(d)&&(f=`path '${s}' exists on disk, but not in '${t}'`)}return T(f)}let c=await he(e,i.hash);if(c.type==="blob")return{stdout:xi.decode(c.content),stderr:"",exitCode:0};if(c.type==="tree"){let f=yn(c.content);return{stdout:Ff(f),stderr:"",exitCode:0}}return{stdout:xi.decode(c.content),stderr:"",exitCode:0}}async function _f(e,t,n){let r=[];if(r.push(`commit ${t}`),n.parents.length>=2){let s=n.parents.map(a=>K(a)).join(" ");r.push(`Merge: ${s}`)}r.push(`Author: ${n.author.name} <${n.author.email}>`),r.push(`Date: ${Vt(n.author.timestamp,n.author.timezone)}`),r.push("");let o=n.message.replace(/\n$/,"");for(let s of o.split(`
633
+ `))r.push(` ${s}`);if(n.parents.length<=1){let s=n.parents.length===1?(await D(e,n.parents[0])).tree:null,a=await Be(e,s,n.tree),{remaining:i,renames:c}=await it(e,a),f=await vh(e,i,c);f&&(r.push(""),r.push(f.replace(/\n$/,"")))}else{let s=await Sh(e,n);s?(r.push(""),r.push(s.replace(/\n$/,""))):r.push("")}return`${r.join(`
593
634
  `)}
594
- `}async function gm(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${vt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
595
- `))n.push(` ${o}`);if(t.objectType==="commit"){let o=await j(e,t.object),s=await qc(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
635
+ `}async function Th(e,t){let n=[];n.push(`tag ${t.name}`),n.push(`Tagger: ${t.tagger.name} <${t.tagger.email}>`),n.push(`Date: ${Vt(t.tagger.timestamp,t.tagger.timezone)}`),n.push("");let r=t.message.replace(/\n$/,"");for(let o of r.split(`
636
+ `))n.push(` ${o}`);if(t.objectType==="commit"){let o=await D(e,t.object),s=await _f(e,t.object,o);n.push(""),n.push(s.replace(/\n$/,""))}return`${n.join(`
596
637
  `)}
597
- `}function Kc(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(`
638
+ `}function Ff(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(`
598
639
  `)}
599
- `:""}async function wm(e,t){let n=t.oldHash?await ie(e,t.oldHash):"",r=t.newHash?await ie(e,t.newHash):"";return At({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function bm(e,t){let n=t.oldHash?await ie(e,t.oldHash):"",r=t.newHash?await ie(e,t.newHash):"";return At({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 ym(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,a)=>{let i=s.type==="diff"?s.entry.path:s.entry.newPath,c=a.type==="diff"?a.entry.path:a.entry.newPath;return i<c?-1:i>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await bm(e,s.entry):o+=await wm(e,s.entry);return o}async function Em(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async i=>{let c=await j(e,i);return se(e,c.tree)})),r=await se(e,t.tree),o=new Set;for(let i of n)for(let c of i.keys())o.add(c);for(let i of r.keys())o.add(i);let s=[];for(let i of o){let f=r.get(i)?.hash??null;n.every(u=>(u.get(i)?.hash??null)!==f)&&s.push(i)}if(s.sort(),s.length===0)return"";let a="";for(let i of s)a+=await xm(e,i,n,r);return a}async function xm(e,t,n,r){let o=r.get(t),s=n.map(l=>l.get(t)??null),a=o?.hash??null,i=o?.mode??null,c=s.map(l=>l?.hash??null),f=s.map(l=>l?.mode??null),d=await Promise.all(c.map(async l=>l?await ie(e,l):"")),u=a?await ie(e,a):"";return ws({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:a,resultMode:i,resultContent:u})}var Ct="refs/stash";function _o(e,t){return he(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function zc(e){let t=await Me(e,Ct),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 Wn(e,t){let n=await Me(e,Ct);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 Vc(e,t,n,r){if(!e.workTree)throw new Error("Cannot stash in a bare repository");let o=e.workTree,s=await X(e);if(!s)return null;let a=await j(e,s),i=await U(e),c=xe(i),f=await ke(e,c),d=await Ae(e,a.tree,f),u=new Map(c.map(N=>[N.path,N])),l=await _e(e,o,"",{skipIgnore:!0}),m=!1;for(let N of l){let V=u.get(N);if(!V)continue;let oe=H(o,N),Q=await e.fs.readFileBuffer(oe);if(await st("blob",Q)!==V.hash){m=!0;break}}if(!m)for(let[N]of u){let V=H(o,N);if(!await e.fs.exists(V)){m=!0;break}}let h=[];if(r?.includeUntracked){let N=await _e(e,o,"");for(let V of N)u.has(V)||h.push(V)}if(d.length===0&&!m&&h.length===0)return null;let p=await Or(e,t),g=await Vn(e,t),w=await J(e),x=w?.type==="symbolic"?de(w.target):"(no branch)",b=K(s),E=ue(a.message),k=`index on ${x}: ${b} ${E}
600
- `,P=$t({type:"commit",tree:f,parents:[s],author:p,committer:g,message:k}),C=await we(e,"commit",P),O=await se(e,a.tree),y=[],I=new Set;for(let N of l){let V=u.get(N),oe=O.get(N);if(!V&&!oe)continue;let Q=H(o,N),ge=await e.fs.readFileBuffer(Q),De=await we(e,"blob",ge),un=V?V.mode:parseInt(oe?.mode??"100644",8);y.push({path:N,mode:un,hash:De,stage:0,stat:pe()}),I.add(N)}for(let[N,V]of u)I.has(N)||O.has(N)||y.push({path:N,mode:V.mode,hash:V.hash,stage:0,stat:pe()});let A=await ke(e,y),L=null;if(r?.includeUntracked){let N=[];for(let ge of h){let De=H(o,ge),un=await e.fs.readFileBuffer(De),Re=await we(e,"blob",un);N.push({path:ge,mode:33188,hash:Re,stage:0,stat:pe()})}let V=await ke(e,N),oe=`untracked files on ${x}: ${b} ${E}
601
- `,Q=$t({type:"commit",tree:V,parents:[],author:p,committer:g,message:oe});L=await we(e,"commit",Q)}let D=n?`On ${x}: ${n}`:`WIP on ${x}: ${b} ${E}`,z=[s,C];L&&z.push(L);let M=$t({type:"commit",tree:A,parents:z,author:p,committer:g,message:D}),$=await we(e,"commit",M),R=await Wn(e,0)??Z;await Te(e,Ct,{oldHash:R,newHash:$,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:D.trimEnd()}),await Y(e,Ct,$);let _=await Nt(e,a.tree,i);await re(e,{version:2,entries:_.newEntries}),await be(e,_.worktreeOps),(await J(e))?.type==="symbolic"&&await ee(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let N of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await ae(e,N);for(let N of["MERGE_MSG","MERGE_MODE"]){let V=H(e.gitDir,N);await e.fs.exists(V)&&await e.fs.rm(V)}if(h.length>0)for(let N of h){if(O.has(N))continue;let V=H(o,N);await e.fs.exists(V)&&(await e.fs.rm(V),await wn(e.fs,Pt(V),o))}return $}async function No(e,t){let n=e.workTree,r=await j(e,t),o=await He(e,r.tree),s=[];for(let a of o){let i=H(n,a.path);await e.fs.exists(i)?s.push(a.path):await ve(e,a)}return s.length>0?(s.sort(_o),{ok:!1,stdout:"",stderr:`${s.map(a=>`${a} already exists, no checkout`).join(`
640
+ `:""}async function Hh(e,t){let n=t.oldHash?await le(e,t.oldHash):"",r=t.newHash?await le(e,t.newHash):"";return zt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode,oldHash:t.oldHash,newHash:t.newHash})}async function Ah(e,t){let n=t.oldHash?await le(e,t.oldHash):"",r=t.newHash?await le(e,t.newHash):"";return zt({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 vh(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,a)=>{let i=s.type==="diff"?s.entry.path:s.entry.newPath,c=a.type==="diff"?a.entry.path:a.entry.newPath;return i<c?-1:i>c?1:0});let o="";for(let s of r)s.type==="rename"?o+=await Ah(e,s.entry):o+=await Hh(e,s.entry);return o}async function Sh(e,t){if(t.parents.length<2)return"";let n=await Promise.all(t.parents.map(async i=>{let c=await D(e,i);return ae(e,c.tree)})),r=await ae(e,t.tree),o=new Set;for(let i of n)for(let c of i.keys())o.add(c);for(let i of r.keys())o.add(i);let s=[];for(let i of o){let f=r.get(i)?.hash??null;n.every(u=>(u.get(i)?.hash??null)!==f)&&s.push(i)}if(s.sort(),s.length===0)return"";let a="";for(let i of s)a+=await Dh(e,i,n,r);return a}async function Dh(e,t,n,r){let o=r.get(t),s=n.map(l=>l.get(t)??null),a=o?.hash??null,i=o?.mode??null,c=s.map(l=>l?.hash??null),f=s.map(l=>l?.mode??null),d=await Promise.all(c.map(async l=>l?await le(e,l):"")),u=a?await le(e,a):"";return Zs({path:t,parentHashes:c,parentModes:f,parentContents:d,resultHash:a,resultMode:i,resultContent:u})}ee();ye();re();ue();ee();ln();ye();re();Jt();fe();Me();ue();Ie();Wt();et();var Gt="refs/stash";function Pi(e,t){return Ee(e.replaceAll("/","\0"),t.replaceAll("/","\0"))}async function Uf(e){let t=await Ve(e,Gt),n=[];for(let r=t.length-1;r>=0;r--){let o=t[r];o&&n.push({index:t.length-1-r,hash:o.newHash,message:o.message})}return n}async function mr(e,t){let n=await Ve(e,Gt);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 Bf(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 a=await D(e,s),i=await W(e),c=He(i),f=await Ae(e,c),d=await Be(e,a.tree,f),u=new Map(c.map(N=>[N.path,N])),l=await Qe(e,o,"",{skipIgnore:!0}),m=!1;for(let N of l){let X=u.get(N);if(!X)continue;let ce=H(o,N),te=await e.fs.readFileBuffer(ce);if(await pt("blob",te)!==X.hash){m=!0;break}}if(!m)for(let[N]of u){let X=H(o,N);if(!await e.fs.exists(X)){m=!0;break}}let h=[];if(r?.includeUntracked){let N=await Qe(e,o,"");for(let X of N)u.has(X)||h.push(X)}if(d.length===0&&!m&&h.length===0)return null;let p=await es(e,t),g=await wr(e,t),w=await Z(e),k=w?.type==="symbolic"?ge(w.target):"(no branch)",b=K(s),E=se(a.message),x=`index on ${k}: ${b} ${E}
641
+ `,P=Ut({type:"commit",tree:f,parents:[s],author:p,committer:g,message:x}),C=await Re(e,"commit",P),R=await ae(e,a.tree),y=[],I=new Set;for(let N of l){let X=u.get(N),ce=R.get(N);if(!X&&!ce)continue;let te=H(o,N),xe=await e.fs.readFileBuffer(te),ze=await Re(e,"blob",xe),vn=X?X.mode:parseInt(ce?.mode??"100644",8);y.push({path:N,mode:vn,hash:ze,stage:0,stat:ke()}),I.add(N)}for(let[N,X]of u)I.has(N)||R.has(N)||y.push({path:N,mode:X.mode,hash:X.hash,stage:0,stat:ke()});let v=await Ae(e,y),G=null;if(r?.includeUntracked){let N=[];for(let xe of h){let ze=H(o,xe),vn=await e.fs.readFileBuffer(ze),Le=await Re(e,"blob",vn);N.push({path:xe,mode:33188,hash:Le,stage:0,stat:ke()})}let X=await Ae(e,N),ce=`untracked files on ${k}: ${b} ${E}
642
+ `,te=Ut({type:"commit",tree:X,parents:[],author:p,committer:g,message:ce});G=await Re(e,"commit",te)}let M=n?`On ${k}: ${n}`:`WIP on ${k}: ${b} ${E}`,V=[s,C];G&&V.push(G);let j=Ut({type:"commit",tree:v,parents:V,author:p,committer:g,message:M}),$=await Re(e,"commit",j),O=await mr(e,0)??J;await _e(e,Gt,{oldHash:O,newHash:$,name:g.name,email:g.email,timestamp:g.timestamp,tz:g.timezone,message:M.trimEnd()}),await z(e,Gt,$);let _=await rn(e,a.tree,i);await ie(e,{version:2,entries:_.newEntries}),await Oe(e,_.worktreeOps),(await Z(e))?.type==="symbolic"&&await ne(e,t,"HEAD",s,s,"reset: moving to HEAD");for(let N of["CHERRY_PICK_HEAD","MERGE_HEAD","ORIG_HEAD","REVERT_HEAD"])await de(e,N);for(let N of["MERGE_MSG","MERGE_MODE"]){let X=H(e.gitDir,N);await e.fs.exists(X)&&await e.fs.rm(X)}if(h.length>0)for(let N of h){if(R.has(N))continue;let X=H(o,N);await e.fs.exists(X)&&(await e.fs.rm(X),await _n(e.fs,Lt(X),o))}return $}async function Ci(e,t){let n=e.workTree,r=await D(e,t),o=await Ue(e,r.tree),s=[];for(let a of o){let i=H(n,a.path);await e.fs.exists(i)?s.push(a.path):await We(e,a)}return s.length>0?(s.sort(Pi),{ok:!1,stdout:"",stderr:`${s.map(a=>`${a} already exists, no checkout`).join(`
602
643
  `)}
603
644
  error: could not restore untracked files from stash
604
- `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Fo(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
605
- `,exitCode:128};let n=await Wn(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
606
- `,exitCode:1};if(!await X(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
607
- `,exitCode:1};let o=await U(e),s=It(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(O=>`${O}: needs merge`).join(`
645
+ `,exitCode:1}):{ok:!0,hasConflicts:!1,messages:[]}}async function Ri(e,t=0){if(!e.workTree)return{ok:!1,stdout:"",stderr:`fatal: this operation must be run in a work tree
646
+ `,exitCode:128};let n=await mr(e,t);if(!n)return{ok:!1,stdout:"",stderr:`error: stash@{${t}} is not a valid reference
647
+ `,exitCode:1};if(!await Y(e))return{ok:!1,stdout:"",stderr:`error: your current branch does not have any commits yet
648
+ `,exitCode:1};let o=await W(e),s=_t(o).sort();if(s.length>0)return{ok:!1,stdout:`${s.map(R=>`${R}: needs merge`).join(`
608
649
  `)}
609
650
  `,stderr:`error: could not write index
610
- `,exitCode:1};let a=await j(e,n),i=a.parents[0];if(!i)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
611
- `,exitCode:1};let c=await j(e,i),f=a.parents[2],d=xe(o),u=await ke(e,d),l={a:"Updated upstream",b:"Stashed changes"};if(c.tree===a.tree){if(f){let C=await No(e,f);if(!C.ok)return{...C,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await yt(e,c.tree,u,a.tree,l),h=await se(e,u),p=await se(e,m.resultTree),g=[];for(let[C,O]of p){let y=h.get(C);(!y||y.hash!==O.hash)&&g.push({path:C,type:"checkout",hash:O.hash,mode:parseInt(O.mode,8)})}for(let[C]of h)p.has(C)||g.push({path:C,type:"delete"});let w=new Map(d.map(C=>[C.path,C])),x=[],b=[];for(let C of g){let O=w.get(C.path),y=H(e.workTree,C.path);if(O){if(!await e.fs.exists(y))continue;let I=await e.fs.readFileBuffer(y);await st("blob",I)!==O.hash&&x.push(C.path)}else C.type==="checkout"&&await e.fs.exists(y)&&b.push(C.path)}if(x.length>0||b.length>0){x.sort(_o),b.sort(_o);let C="";if(x.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
612
- ${x.map(O=>` ${O}`).join(`
651
+ `,exitCode:1};let a=await D(e,n),i=a.parents[0];if(!i)return{ok:!1,stdout:"",stderr:`error: invalid stash commit (no parent)
652
+ `,exitCode:1};let c=await D(e,i),f=a.parents[2],d=He(o),u=await Ae(e,d),l={a:"Updated upstream",b:"Stashed changes"};if(c.tree===a.tree){if(f){let C=await Ci(e,f);if(!C.ok)return{...C,messages:["Already up to date."]}}return{ok:!0,hasConflicts:!1,messages:["Already up to date."]}}let m=await St(e,c.tree,u,a.tree,l),h=await ae(e,u),p=await ae(e,m.resultTree),g=[];for(let[C,R]of p){let y=h.get(C);(!y||y.hash!==R.hash)&&g.push({path:C,type:"checkout",hash:R.hash,mode:parseInt(R.mode,8)})}for(let[C]of h)p.has(C)||g.push({path:C,type:"delete"});let w=new Map(d.map(C=>[C.path,C])),k=[],b=[];for(let C of g){let R=w.get(C.path),y=H(e.workTree,C.path);if(R){if(!await e.fs.exists(y))continue;let I=await e.fs.readFileBuffer(y);await pt("blob",I)!==R.hash&&k.push(C.path)}else C.type==="checkout"&&await e.fs.exists(y)&&b.push(C.path)}if(k.length>0||b.length>0){k.sort(Pi),b.sort(Pi);let C="";if(k.length>0&&(C+=`error: Your local changes to the following files would be overwritten by merge:
653
+ ${k.map(R=>` ${R}`).join(`
613
654
  `)}
614
655
  Please commit your changes or stash them before you merge.
615
656
  `),b.length>0&&(C+=`error: The following untracked working tree files would be overwritten by merge:
616
- ${b.map(O=>` ${O}`).join(`
657
+ ${b.map(R=>` ${R}`).join(`
617
658
  `)}
618
659
  Please move or remove them before you merge.
619
660
  `),C+=`Aborting
620
- `,f){let O=await No(e,f);O.ok||(C+=O.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await be(e,g);let E=new Set(m.conflicts.map(C=>C.path)),k=new Set;for(let C of m.entries)C.stage>0&&k.add(C.path);let P=E.size>0;if(P){let C=[];for(let[O,y]of p){if(E.has(O)||k.has(O))continue;let I=w.get(O);C.push({path:O,mode:parseInt(y.mode,8),hash:y.hash,stage:0,stat:I?.stat??pe()})}for(let O of m.entries)O.stage>0&&C.push(O);C.sort((O,y)=>he(O.path,y.path)||O.stage-y.stage),await re(e,{version:2,entries:C})}else{let C=[...o.entries],O=new Set(C.map(y=>y.path));for(let[y,I]of p)h.has(y)||O.has(y)||C.push({path:y,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:pe()});C.sort((y,I)=>he(y.path,I.path)||y.stage-I.stage),await re(e,{version:2,entries:C})}if(f){let C=await No(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:P,messages:m.messages}}async function Uo(e,t=0){let n=await Me(e,Ct);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 ae(e,Ct),await er(e,Ct);else{await Zt(e,Ct,n);let o=n[n.length-1];o&&await Y(e,Ct,o.newHash)}return null}async function Yc(e){await ae(e,Ct),await er(e,Ct)}function Is(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 km(e,t){let n=t.oldHash?await ie(e,t.oldHash):"",r=t.newHash?await ie(e,t.newHash):"";return At({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function dn(e,t,n){return e?.hooks?e.hooks.emitPre("pre-stash",{action:t,ref:n}):null}async function ln(e,t,n){await e?.hooks?.emitPost("post-stash",{action:t,ok:n})}function Zc(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":v().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],a=[];for(let i of o)i.startsWith("-")?s.push(i):a.push(i);return a.length>0?[...s,"-m",a.join(" ")]:s},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"push",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Xc(s,o.env,r.message,r["include-untracked"]);return await ln(t,"push",i.exitCode===0),i}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:te.string().alias("m").describe("Stash message"),"include-untracked":v().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"push",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Xc(s,o.env,r.message,r["include-untracked"]);return await ln(t,"push",i.exitCode===0),i}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"pop",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Cm(s,r.stash);return await ln(t,"pop",i.exitCode===0),i}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"apply",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Pm(s,r.stash);return await ln(t,"apply",i.exitCode===0),i}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"list",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Om(s);return await ln(t,"list",i.exitCode===0),i}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"drop",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Im(s,r.stash);return await ln(t,"drop",i.exitCode===0),i}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[W.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"show",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Rm(s,r.stash);return await ln(t,"show",i.exitCode===0),i}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await B(o.fs,o.cwd,t);if(S(s))return s;let a=await dn(t,"clear",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await $m(s);return await ln(t,"clear",i.exitCode===0),i}})}async function Xc(e,t,n,r){if(!await X(e))return G(`You do not have the initial commit yet
621
- `);let s=await U(e),a=It(s).sort();if(a.length>0)return{stdout:`${a.map(d=>`${d}: needs merge`).join(`
661
+ `,f){let R=await Ci(e,f);R.ok||(C+=R.stderr)}return{ok:!1,stdout:"",stderr:C,exitCode:1}}await Oe(e,g);let E=new Set(m.conflicts.map(C=>C.path)),x=new Set;for(let C of m.entries)C.stage>0&&x.add(C.path);let P=E.size>0;if(P){let C=[];for(let[R,y]of p){if(E.has(R)||x.has(R))continue;let I=w.get(R);C.push({path:R,mode:parseInt(y.mode,8),hash:y.hash,stage:0,stat:I?.stat??ke()})}for(let R of m.entries)R.stage>0&&C.push(R);C.sort((R,y)=>Ee(R.path,y.path)||R.stage-y.stage),await ie(e,{version:2,entries:C})}else{let C=[...o.entries],R=new Set(C.map(y=>y.path));for(let[y,I]of p)h.has(y)||R.has(y)||C.push({path:y,mode:parseInt(I.mode,8),hash:I.hash,stage:0,stat:ke()});C.sort((y,I)=>Ee(y.path,I.path)||y.stage-I.stage),await ie(e,{version:2,entries:C})}if(f){let C=await Ci(e,f);if(!C.ok)return{...C,messages:m.messages}}return{ok:!0,hasConflicts:P,messages:m.messages}}async function Ii(e,t=0){let n=await Ve(e,Gt);if(n.length===0)return`error: stash@{${t}} is not a valid reference`;let r=n.length-1-t;if(r<0||r>=n.length)return`error: stash@{${t}} is not a valid reference`;if(n.splice(r,1),n.length===0)await de(e,Gt),await Rr(e,Gt);else{await wn(e,Gt,n);let o=n[n.length-1];o&&await z(e,Gt,o.newHash)}return null}async function Wf(e){await de(e,Gt),await Rr(e,Gt)}Ie();function io(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 Mh(e,t){let n=t.oldHash?await le(e,t.oldHash):"",r=t.newHash?await le(e,t.newHash):"";return zt({path:t.path,oldContent:n,newContent:r,oldMode:t.oldMode,newMode:t.newMode})}async function Hn(e,t,n){return e?.hooks?e.hooks.emitPre("pre-stash",{action:t,ref:n}):null}async function An(e,t,n){await e?.hooks?.emitPost("post-stash",{action:t,ok:n})}function Kf(e,t){let n=e.command("stash",{description:"Stash the changes in a dirty working directory away",options:{message:Q.string().alias("m").describe("Stash message"),"include-untracked":A().alias("u").describe("Also stash untracked files")},transformArgs:r=>{if(r[0]!=="save")return r;let o=r.slice(1),s=[],a=[];for(let i of o)i.startsWith("-")?s.push(i):a.push(i);return a.length>0?[...s,"-m",a.join(" ")]:s},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"push",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await qf(s,o.env,r.message,r["include-untracked"]);return await An(t,"push",i.exitCode===0),i}});n.command("push",{description:"Save your local modifications to a new stash entry",options:{message:Q.string().alias("m").describe("Stash message"),"include-untracked":A().alias("u").describe("Also stash untracked files")},handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"push",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await qf(s,o.env,r.message,r["include-untracked"]);return await An(t,"push",i.exitCode===0),i}}),n.command("pop",{description:"Remove a single stash entry and apply it on top of the current working tree",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"pop",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await jh(s,r.stash);return await An(t,"pop",i.exitCode===0),i}}),n.command("apply",{description:"Apply a stash entry on top of the current working tree",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"apply",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Gh(s,r.stash);return await An(t,"apply",i.exitCode===0),i}}),n.command("list",{description:"List the stash entries that you currently have",handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"list",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Lh(s);return await An(t,"list",i.exitCode===0),i}}),n.command("drop",{description:"Remove a single stash entry from the list of stash entries",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"drop",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Nh(s,r.stash);return await An(t,"drop",i.exitCode===0),i}}),n.command("show",{description:"Show the changes recorded in a stash entry as a diff",args:[B.string().name("stash").describe("Stash reference (e.g. stash@{0})").optional()],handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"show",r.stash??null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await _h(s,r.stash);return await An(t,"show",i.exitCode===0),i}}),n.command("clear",{description:"Remove all the stash entries",handler:async(r,o)=>{let s=await U(o.fs,o.cwd,t);if(S(s))return s;let a=await Hn(t,"clear",null);if(a)return{stdout:"",stderr:a.message??"",exitCode:1};let i=await Fh(s);return await An(t,"clear",i.exitCode===0),i}})}async function qf(e,t,n,r){if(!await Y(e))return L(`You do not have the initial commit yet
662
+ `);let s=await W(e),a=_t(s).sort();if(a.length>0)return{stdout:`${a.map(d=>`${d}: needs merge`).join(`
622
663
  `)}
623
664
  `,stderr:`error: could not write index
624
- `,exitCode:1};let i;try{i=await Vc(e,t,n,{includeUntracked:r})}catch(d){return T(d.message)}return i?{stdout:`Saved working directory and index state ${(await j(e,i)).message.trim()}
665
+ `,exitCode:1};let i;try{i=await Bf(e,t,n,{includeUntracked:r})}catch(d){return T(d.message)}return i?{stdout:`Saved working directory and index state ${(await D(e,i)).message.trim()}
625
666
  `,stderr:"",exitCode:0}:{stdout:`No local changes to save
626
- `,stderr:"",exitCode:0}}async function Cm(e,t){let n=Is(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Wn(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await Fo(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
667
+ `,stderr:"",exitCode:0}}async function jh(e,t){let n=io(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await mr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await Ri(e,n);if(!o.ok){let f=o.messages?.length?`${o.messages.join(`
627
668
  `)}
628
669
  `:"";if(o.stdout)return{stdout:`${f}${o.stdout}The stash entry is kept in case you need it again.
629
- `,stderr:o.stderr,exitCode:o.exitCode};let d=await Be(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
670
+ `,stderr:o.stderr,exitCode:o.exitCode};let d=await tt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
630
671
  `,stderr:o.stderr,exitCode:o.exitCode}}if(o.hasConflicts){let f=o.messages.length>0?`${o.messages.join(`
631
672
  `)}
632
- `:"",d=await Be(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
633
- `,stderr:"",exitCode:1}}let s=await Uo(e,n);if(s)return G(s);let a=o.messages.length>0?`${o.messages.join(`
673
+ `:"",d=await tt(e);return{stdout:`${f}${d}The stash entry is kept in case you need it again.
674
+ `,stderr:"",exitCode:1}}let s=await Ii(e,n);if(s)return L(s);let a=o.messages.length>0?`${o.messages.join(`
634
675
  `)}
635
- `:"",i=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await Be(e);return{stdout:`${a}${c}Dropped ${i} (${r})
636
- `,stderr:"",exitCode:0}}async function Pm(e,t){let n=Is(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Fo(e,n);if(!r.ok){let i=r.messages?.length?`${r.messages.join(`
676
+ `:"",i=t?`stash@{${n}}`:`refs/stash@{${n}}`,c=await tt(e);return{stdout:`${a}${c}Dropped ${i} (${r})
677
+ `,stderr:"",exitCode:0}}async function Gh(e,t){let n=io(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await Ri(e,n);if(!r.ok){let i=r.messages?.length?`${r.messages.join(`
637
678
  `)}
638
- `:"",c=r.stdout;return c||(c=await Be(e)),{stdout:`${i}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
679
+ `:"",c=r.stdout;return c||(c=await tt(e)),{stdout:`${i}${c}`,stderr:r.stderr,exitCode:r.exitCode}}let o=r.messages.length>0?`${r.messages.join(`
639
680
  `)}
640
- `:"",s=await Be(e),a=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:a}}async function Om(e){let t=await zc(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
681
+ `:"",s=await tt(e),a=r.hasConflicts?1:0;return{stdout:`${o}${s}`,stderr:"",exitCode:a}}async function Lh(e){let t=await Uf(e);return t.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${t.map(r=>`stash@{${r.index}}: ${r.message}`).join(`
641
682
  `)}
642
- `,stderr:"",exitCode:0}}async function Im(e,t){let n=Is(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Wn(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await Uo(e,n);return o?G(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
643
- `,stderr:"",exitCode:0}}async function Rm(e,t){let n=Is(t);if(n<0)return G(`error: '${t}' is not a valid stash reference`);let r=await Wn(e,n);if(!r)return G(`error: stash@{${n}} is not a valid reference`);let o=await j(e,r),s=o.parents[0];if(!s)return G("error: invalid stash commit (no parent)");let a=await j(e,s),i=await Ae(e,a.tree,o.tree),c="";for(let f of i)c+=await km(e,f);return{stdout:c,stderr:"",exitCode:0}}async function $m(e){return await Yc(e),{stdout:"",stderr:"",exitCode:0}}function Jc(e,t){e.command("status",{description:"Show the working tree status",options:{short:v().alias("s").describe("Give the output in the short-format"),porcelain:v().describe("Give the output in a machine-parseable format"),branch:v().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await Be(s),stderr:"",exitCode:0};let a=await J(s),i=await X(s),c;a&&a.type==="symbolic"?c=de(a.target):c="HEAD detached";let f=await U(s),d=mo(f),u=await uo(s,i,f,d),l=await ut(s,f),m=[],h=[];for(let x of l)x.status==="untracked"?h.push(x.path):m.push({path:x.path,status:x.status});m.sort((x,b)=>he(x.path,b.path));let p=new Set(f.entries.map(x=>x.path)),g=ho(h,p);return{stdout:vm(c,u,m,d,g,n.branch),stderr:"",exitCode:0}}})}var Tm={"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 Hm(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Am(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function vm(e,t,n,r,o,s){let a=[];s&&(e==="HEAD detached"?a.push("## HEAD (no branch)"):a.push(`## ${e}`));let i=new Map(r.map(l=>[l.path,l])),c=new Map(t.map(l=>[l.path,l])),f=new Map(n.map(l=>[l.path,l])),d=new Set;for(let l of r)d.add(l.path);for(let l of t)d.add(l.path);for(let l of n)d.add(l.path);let u=[...d].sort();for(let l of u){let m=i.get(l);if(m){let x=Tm[m.status]??"UU";a.push(`${x} ${wr(l)}`);continue}let h=c.get(l),p=f.get(l),g=h?Hm(h.status):" ",w=p?Am(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let x=h.displayPath.indexOf(" -> "),b=h.displayPath.slice(0,x),E=h.displayPath.slice(x+4);a.push(`${g}${w} ${wr(b)} -> ${wr(E)}`)}else a.push(`${g}${w} ${wr(l)}`)}for(let l of o)a.push(`?? ${wr(l)}`);return a.length===0?"":`${a.join(`
683
+ `,stderr:"",exitCode:0}}async function Nh(e,t){let n=io(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await mr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await Ii(e,n);return o?L(o):{stdout:`Dropped ${t?`stash@{${n}}`:`refs/stash@{${n}}`} (${r})
684
+ `,stderr:"",exitCode:0}}async function _h(e,t){let n=io(t);if(n<0)return L(`error: '${t}' is not a valid stash reference`);let r=await mr(e,n);if(!r)return L(`error: stash@{${n}} is not a valid reference`);let o=await D(e,r),s=o.parents[0];if(!s)return L("error: invalid stash commit (no parent)");let a=await D(e,s),i=await Be(e,a.tree,o.tree),c="";for(let f of i)c+=await Mh(e,f);return{stdout:c,stderr:"",exitCode:0}}async function Fh(e){return await Wf(e),{stdout:"",stderr:"",exitCode:0}}ee();ye();ue();et();function zf(e,t){e.command("status",{description:"Show the working tree status",options:{short:A().alias("s").describe("Give the output in the short-format"),porcelain:A().describe("Give the output in a machine-parseable format"),branch:A().alias("b").describe("Show the branch in short-format output")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(!n.short&&!n.porcelain)return{stdout:await tt(s),stderr:"",exitCode:0};let a=await Z(s),i=await Y(s),c;a&&a.type==="symbolic"?c=ge(a.target):c="HEAD detached";let f=await W(s),d=Wo(f),u=await Bo(s,i,f,d),l=await Rt(s,f),m=[],h=[];for(let k of l)k.status==="untracked"?h.push(k.path):m.push({path:k.path,status:k.status});m.sort((k,b)=>Ee(k.path,b.path));let p=new Set(f.entries.map(k=>k.path)),g=qo(h,p);return{stdout:qh(c,u,m,d,g,n.branch),stderr:"",exitCode:0}}})}var Uh={"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 Bh(e){switch(e){case"new file":return"A";case"modified":return"M";case"deleted":return"D";case"renamed":return"R";default:return" "}}function Wh(e){switch(e){case"modified":return"M";case"deleted":return"D";default:return" "}}function qh(e,t,n,r,o,s){let a=[];s&&(e==="HEAD detached"?a.push("## HEAD (no branch)"):a.push(`## ${e}`));let i=new Map(r.map(l=>[l.path,l])),c=new Map(t.map(l=>[l.path,l])),f=new Map(n.map(l=>[l.path,l])),d=new Set;for(let l of r)d.add(l.path);for(let l of t)d.add(l.path);for(let l of n)d.add(l.path);let u=[...d].sort();for(let l of u){let m=i.get(l);if(m){let k=Uh[m.status]??"UU";a.push(`${k} ${Kr(l)}`);continue}let h=c.get(l),p=f.get(l),g=h?Bh(h.status):" ",w=p?Wh(p.status):" ";if(h?.status==="renamed"&&h.displayPath){let k=h.displayPath.indexOf(" -> "),b=h.displayPath.slice(0,k),E=h.displayPath.slice(k+4);a.push(`${g}${w} ${Kr(b)} -> ${Kr(E)}`)}else a.push(`${g}${w} ${Kr(l)}`)}for(let l of o)a.push(`?? ${Kr(l)}`);return a.length===0?"":`${a.join(`
644
685
  `)}
645
- `}function wr(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}function Sm(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??Z}function ef(e,t){e.command("switch",{description:"Switch branches",args:[W.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:te.string().alias("c").describe("Create and switch to a new branch"),forceCreate:te.string().alias("C").describe("Create/reset and switch to a branch"),detach:v().alias("d").describe("Detach HEAD at named commit"),orphan:te.string().describe("Create a new orphan branch"),guess:v().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await B(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?T("--orphan and -c/-C are incompatible"):n.detach?T("--orphan and --detach are incompatible"):Lm(a,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return T("--detach and -c/-C are incompatible");let d=i??"HEAD",u=await ye(a,d,`invalid reference: ${d}`);return S(u)?u:jm(a,d,u.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,u=i??(o.passthrough.length>0?o.passthrough[0]:void 0);return Qc(a,d,!!n.forceCreate,u,r.env,t)}if(!i)return T("missing branch or commit argument");if(i==="-")return Dm(a,r.env,t);let c=`refs/heads/${i}`,f=await F(a,c);if(f)return tf(a,i,c,f,r.env,t);if(n.guess!==!1){let d=await Mm(a,i);if(d)return Qc(a,i,!1,d.startPoint,r.env,t,d.trackingRef)}return T(`invalid reference: ${i}`)}})}async function br(e){return await qe(e,"CHERRY_PICK_HEAD")?T(`cannot switch branch while cherry-picking
646
- Consider "git cherry-pick --quit" or "git worktree add".`):await qe(e,"MERGE_HEAD")?T(`cannot switch branch while merging
647
- Consider "git merge --quit" or "git worktree add".`):await qe(e,"REVERT_HEAD")?T(`cannot switch branch while reverting
648
- Consider "git revert --quit" or "git worktree add".`):await bt(e)?T(`cannot switch branch while rebasing
649
- Consider "git rebase --quit" or "git worktree add".`):null}async function Dm(e,t,n){let r=await br(e);if(r)return r;let o=await os(e);return o?tf(e,o.name,o.refName,o.hash,t,n):T("no previous branch")}async function Mm(e,t){let n=await le(e,"refs/remotes"),r=[];for(let s of n){let a=s.name.replace(/^refs\/remotes\//,"").split("/"),i=a[0];a.length>=2&&i&&a.slice(1).join("/")===t&&r.push({remote:i,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function Qc(e,t,n,r,o,s,a){let i=`refs/heads/${t}`,c=await F(e,i);if(c&&!n)return T(`a branch named '${t}' already exists`);let f;if(r){let y=await ye(e,r,`invalid reference: ${r}`);if(S(y))return y;f=y.hash}else{let y=await X(e);if(!y){let I=await J(e),A=I?.type==="symbolic"?I.target.replace(/^refs\/heads\//,""):"";n&&c&&await ae(e,i),await $e(e,"HEAD",i),await tt(e);let L=await Wt(e);return await ee(e,o,"HEAD",null,Z,`checkout: moving from ${A} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
650
- ${L}`,exitCode:0}}f=y}let d=await br(e);if(d)return d;let u=await X(e),l=await U(e);if(r){let y=cn(l);if(y)return y}let m=await j(e,f);if(u&&u!==f){let y=await j(e,u);if(y.tree!==m.tree){let I=await en(e,y.tree,m.tree,l);if(!I.success)return I.errorOutput??G("error: checkout would overwrite local changes");l={version:2,entries:I.newEntries},await re(e,l),await be(e,I.worktreeOps)}}let h=await J(e),p="";h?.type==="direct"&&u&&(p=await cs(e,u,f));let g=Sm(h,u);await Y(e,i,f),await $e(e,"HEAD",i),await tt(e);let w=await Wt(e),x=r??"HEAD";n&&c?c!==f&&await ee(e,o,i,c,f,`branch: Reset to ${x}`):await ee(e,o,i,null,f,`branch: Created from ${x}`),await ee(e,o,"HEAD",u,f,`checkout: moving from ${g} to ${t}`);let b=a?.replace(/^refs\/remotes\//,"").split("/");if(b){let y=b[0]??"",I=`refs/heads/${b.slice(1).join("/")}`,A=await ce(e);A[`branch "${t}"`]={...A[`branch "${t}"`],remote:y,merge:I},await Ge(e,A)}await s?.hooks?.emitPost("post-checkout",{prevHead:u,newHead:f,isBranchCheckout:!0});let E=n&&c?`Switched to and reset branch '${t}'
686
+ `}function Kr(e){return!/[ \t"\\]/.test(e)&&!/[^\x20-\x7E]/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\t/g,"\\t").replace(/\n/g,"\\n")}"`}ee();Ze();ye();re();Me();ue();Ie();Wt();function Kh(e,t){return e?.type==="symbolic"?e.target.replace(/^refs\/heads\//,""):t??J}function Yf(e,t){e.command("switch",{description:"Switch branches",args:[B.string().name("branch-or-start-point").describe("Branch to switch to, or start-point for -c/-C").optional()],options:{create:Q.string().alias("c").describe("Create and switch to a new branch"),forceCreate:Q.string().alias("C").describe("Create/reset and switch to a branch"),detach:A().alias("d").describe("Detach HEAD at named commit"),orphan:Q.string().describe("Create a new orphan branch"),guess:A().default(!0).describe("Guess branch from remote tracking")},handler:async(n,r,o)=>{let s=await U(r.fs,r.cwd,t);if(S(s))return s;let a=s,i=n["branch-or-start-point"];if(n.orphan)return n.create||n.forceCreate?T("--orphan and -c/-C are incompatible"):n.detach?T("--orphan and --detach are incompatible"):Xh(a,n.orphan,r.env,t);if(n.detach){if(n.create||n.forceCreate)return T("--detach and -c/-C are incompatible");let d=i??"HEAD",u=await $e(a,d,`invalid reference: ${d}`);return S(u)?u:Yh(a,d,u.hash,r.env,t)}if(n.create||n.forceCreate){let d=n.create||n.forceCreate,u=i??(o.passthrough.length>0?o.passthrough[0]:void 0);return Vf(a,d,!!n.forceCreate,u,r.env,t)}if(!i)return T("missing branch or commit argument");if(i==="-")return zh(a,r.env,t);let c=`refs/heads/${i}`,f=await F(a,c);if(f)return Xf(a,i,c,f,r.env,t);if(n.guess!==!1){let d=await Vh(a,i);if(d)return Vf(a,i,!1,d.startPoint,r.env,t,d.trackingRef)}return T(`invalid reference: ${i}`)}})}async function zr(e){return await Ce(e,"CHERRY_PICK_HEAD")?T(`cannot switch branch while cherry-picking
687
+ Consider "git cherry-pick --quit" or "git worktree add".`):await Ce(e,"MERGE_HEAD")?T(`cannot switch branch while merging
688
+ Consider "git merge --quit" or "git worktree add".`):await Ce(e,"REVERT_HEAD")?T(`cannot switch branch while reverting
689
+ Consider "git revert --quit" or "git worktree add".`):await Ht(e)?T(`cannot switch branch while rebasing
690
+ Consider "git rebase --quit" or "git worktree add".`):null}async function zh(e,t,n){let r=await zr(e);if(r)return r;let o=await vs(e);return o?Xf(e,o.name,o.refName,o.hash,t,n):T("no previous branch")}async function Vh(e,t){let n=await pe(e,"refs/remotes"),r=[];for(let s of n){let a=s.name.replace(/^refs\/remotes\//,"").split("/"),i=a[0];a.length>=2&&i&&a.slice(1).join("/")===t&&r.push({remote:i,ref:s.name})}let o=r.length===1?r[0]:void 0;return o?{startPoint:o.ref,trackingRef:o.ref}:null}async function Vf(e,t,n,r,o,s,a){let i=`refs/heads/${t}`,c=await F(e,i);if(c&&!n)return T(`a branch named '${t}' already exists`);let f;if(r){let y=await $e(e,r,`invalid reference: ${r}`);if(S(y))return y;f=y.hash}else{let y=await Y(e);if(!y){let I=await Z(e),v=I?.type==="symbolic"?I.target.replace(/^refs\/heads\//,""):"";n&&c&&await de(e,i),await Ne(e,"HEAD",i),await lt(e);let G=await an(e);return await ne(e,o,"HEAD",null,J,`checkout: moving from ${v} to ${t}`),{stdout:"",stderr:`Switched to a new branch '${t}'
691
+ ${G}`,exitCode:0}}f=y}let d=await zr(e);if(d)return d;let u=await Y(e),l=await W(e);if(r){let y=xn(l);if(y)return y}let m=await D(e,f);if(u&&u!==f){let y=await D(e,u);if(y.tree!==m.tree){let I=await En(e,y.tree,m.tree,l);if(!I.success)return I.errorOutput??L("error: checkout would overwrite local changes");l={version:2,entries:I.newEntries},await ie(e,l),await Oe(e,I.worktreeOps)}}let h=await Z(e),p="";h?.type==="direct"&&u&&(p=await Ms(e,u,f));let g=Kh(h,u);await z(e,i,f),await Ne(e,"HEAD",i),await lt(e);let w=await an(e),k=r??"HEAD";n&&c?c!==f&&await ne(e,o,i,c,f,`branch: Reset to ${k}`):await ne(e,o,i,null,f,`branch: Created from ${k}`),await ne(e,o,"HEAD",u,f,`checkout: moving from ${g} to ${t}`);let b=a?.replace(/^refs\/remotes\//,"").split("/");if(b){let y=b[0]??"",I=`refs/heads/${b.slice(1).join("/")}`,v=await me(e);v[`branch "${t}"`]={...v[`branch "${t}"`],remote:y,merge:I},await Xe(e,v)}await s?.hooks?.emitPost("post-checkout",{prevHead:u,newHead:f,isBranchCheckout:!0});let E=n&&c?`Switched to and reset branch '${t}'
651
692
  `:`Switched to a new branch '${t}'
652
- `,k=p+E+w;if(b){let y=b.slice(1).join("/");k+=`branch '${t}' set up to track '${b[0]}/${y}'.
653
- `}let P="";r&&(P=await kn(e,m.tree,l));let C=await ce(e),O=await Bt(e,C,t);return O&&(P+=xn(O)),{stdout:P,stderr:k,exitCode:0}}async function tf(e,t,n,r,o,s){let a=await br(e);return a||fs(e,t,n,r,o,s)}async function jm(e,t,n,r,o){let s=await br(e);return s||ds(e,n,r,o)}async function Lm(e,t,n,r){let o=await br(e);if(o)return o;let s=`refs/heads/${t}`;if(await F(e,s))return T(`a branch named '${t}' already exists`);let i=await U(e),c=cn(i);if(c)return c;let f=await X(e),d=await J(e),u="";if(d?.type==="direct"&&f&&(u=await po(e,f)),e.workTree){let m=f?(await j(e,f)).tree:null,h=await ke(e,[]),p=await en(e,m,h,i);if(!p.success)return p.errorOutput??G("error: checkout would overwrite local changes");await be(e,p.worktreeOps)}await re(e,si()),await $e(e,"HEAD",s),await tt(e);let l=await Wt(e);return await r?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:Z,isBranchCheckout:!0}),{stdout:"",stderr:`${u}Switched to a new branch '${t}'
654
- ${l}`,exitCode:0}}function rf(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[W.string().name("name").describe("Tag name to create or delete").optional(),W.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:v().alias("a").describe("Make an annotated tag object"),message:te.string().alias("m").describe("Tag message"),delete:v().alias("d").describe("Delete a tag"),force:v().alias("f").describe("Replace an existing tag"),list:te.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await B(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.delete){if(!n.name)return T("tag name required");let a=`refs/tags/${n.name}`,i=await F(s,a);return i?(await ae(s,a),{stdout:`Deleted tag '${n.name}' (was ${K(i)})
655
- `,stderr:"",exitCode:0}):G(`error: tag '${n.name}' not found.
656
- `)}if(n.list!==void 0)return nf(s,n.list||void 0);if(n.name){let a=n.commit,i;if(a){let u=await Sn(s,a,`Failed to resolve '${a}' as a valid ref.`);if(S(u))return u;i=u}else if(i=await X(s),!i)return T("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await F(s,c)&&!n.force)return T(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return T("no tag message specified (use -m)");let u=await Le(s,r.env);if(S(u))return u;let l=ht(n.message),m=xi({type:"tag",object:i,objectType:"commit",name:n.name,tagger:u,message:l}),h=await we(s,"tag",m);await Y(s,c,h)}else await Y(s,c,i);return{stdout:"",stderr:"",exitCode:0}}return nf(s)}})}async function nf(e,t){let n=await le(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=>pn(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
657
- `)}
658
- `,stderr:"",exitCode:0}}var Gm={init:e=>wc(e),clone:(e,t)=>Ka(e,t),fetch:(e,t)=>ac(e,t),pull:(e,t)=>$c(e,t),push:(e,t)=>Tc(e,t),add:(e,t)=>Wi(e,t),blame:(e,t)=>oa(e,t),commit:(e,t)=>za(e,t),status:(e,t)=>Jc(e,t),log:(e,t)=>Cc(e,t),branch:(e,t)=>ya(e,t),tag:(e,t)=>rf(e,t),checkout:(e,t)=>xa(e,t),diff:(e,t)=>rc(e,t),reset:(e,t)=>Lc(e,t),merge:(e,t)=>Ic(e,t),"cherry-pick":(e,t)=>Ma(e,t),revert:(e,t)=>Fc(e,t),rebase:(e,t)=>Sc(e,t),mv:(e,t)=>Rc(e,t),rm:(e,t)=>Bc(e,t),remote:(e,t)=>Mc(e,t),config:(e,t)=>Za(e,t),show:(e,t)=>Wc(e,t),stash:(e,t)=>Zc(e,t),"rev-parse":(e,t)=>_c(e,t),"ls-files":(e,t)=>Oc(e,t),clean:(e,t)=>ja(e,t),switch:(e,t)=>ef(e,t),restore:(e,t)=>Nc(e,t),reflog:(e,t)=>Dc(e,t),repack:(e,t)=>hc(e,t),gc:(e,t)=>pc(e,t)};function sf(e){let t=Ss("git",{description:"Git command"});for(let n of Object.values(Gm))n(t,e);return t}var Rs=class{listeners=new Map;onError=()=>{};on(t,n){let r=t,o=this.listeners.get(r);o||(o=[],this.listeners.set(r,o));let s=n;return o.push(s),()=>{let a=this.listeners.get(r);if(a){let i=a.indexOf(s);i!==-1&&a.splice(i,1)}}}async emitPre(t,n){let r=this.listeners.get(t);if(!r||r.length===0)return null;for(let o of r){let s=await o(n);if(s&&typeof s=="object"&&"abort"in s)return s}return null}async emitPost(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)await o(n)}emit(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)try{let s=o(n);s&&typeof s=="object"&&"then"in s&&s.catch(this.onError)}catch(s){this.onError(s)}}};var $s=class{name="git";hooks;middlewares=[];extensions;inner;constructor(t){this.hooks=new Rs;let n=t?.network;if(this.extensions={hooks:this.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n},t?.disabled?.length){let r=new Set(t.disabled);this.use(async(o,s)=>o.command&&r.has(o.command)?{stdout:"",stderr:`git: '${o.command}' is not available in this environment
659
- `,exitCode:1}:s())}this.inner=sf(this.extensions).toCommand()}on(t,n){return this.hooks.on(t,n)}use(t){return this.middlewares.push(t),()=>{let n=this.middlewares.indexOf(t);n!==-1&&this.middlewares.splice(n,1)}}execute=async(t,n)=>{let r={command:t[0],rawArgs:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env,stdin:n.stdin,exec:n.exec,signal:n.signal};return this.runMiddleware(r,()=>this.inner.execute(t,n))};async runMiddleware(t,n){if(this.middlewares.length===0)return n();let r=0,o=async()=>{if(r>=this.middlewares.length)return n();let s=this.middlewares[r++];return s(t,o)};return o()}};function Nm(e){return new $s(e)}export{$s as Git,Nm as createGit};
693
+ `,x=p+E+w;if(b){let y=b.slice(1).join("/");x+=`branch '${t}' set up to track '${b[0]}/${y}'.
694
+ `}let P="";r&&(P=await qn(e,m.tree,l));let C=await me(e),R=await on(e,C,t);return R&&(P+=Wn(R)),{stdout:P,stderr:x,exitCode:0}}async function Xf(e,t,n,r,o,s){let a=await zr(e);return a||ar(e,t,n,r,o,s)}async function Yh(e,t,n,r,o){let s=await zr(e);return s||Cn(e,n,r,o)}async function Xh(e,t,n,r){let o=await zr(e);if(o)return o;let s=`refs/heads/${t}`;if(await F(e,s))return T(`a branch named '${t}' already exists`);let i=await W(e),c=xn(i);if(c)return c;let f=await Y(e),d=await Z(e),u="";if(d?.type==="direct"&&f&&(u=await Ko(e,f)),e.workTree){let m=f?(await D(e,f)).tree:null,h=await Ae(e,[]),p=await En(e,m,h,i);if(!p.success)return p.errorOutput??L("error: checkout would overwrite local changes");await Oe(e,p.worktreeOps)}await ie(e,Ui()),await Ne(e,"HEAD",s),await lt(e);let l=await an(e);return await r?.hooks?.emitPost("post-checkout",{prevHead:f,newHead:J,isBranchCheckout:!0}),{stdout:"",stderr:`${u}Switched to a new branch '${t}'
695
+ ${l}`,exitCode:0}}ee();re();Cr();ue();hs();function Jf(e,t){e.command("tag",{description:"Create, list, or delete tags",args:[B.string().name("name").describe("Tag name to create or delete").optional(),B.string().name("commit").describe("Commit to tag (defaults to HEAD)").optional()],options:{annotate:A().alias("a").describe("Make an annotated tag object"),message:Q.string().alias("m").describe("Tag message"),delete:A().alias("d").describe("Delete a tag"),force:A().alias("f").describe("Replace an existing tag"),list:Q.string().alias("l").describe("List tags matching pattern")},handler:async(n,r)=>{let o=await U(r.fs,r.cwd,t);if(S(o))return o;let s=o;if(n.delete){if(!n.name)return T("tag name required");let a=`refs/tags/${n.name}`,i=await F(s,a);return i?(await de(s,a),{stdout:`Deleted tag '${n.name}' (was ${K(i)})
696
+ `,stderr:"",exitCode:0}):L(`error: tag '${n.name}' not found.
697
+ `)}if(n.list!==void 0)return Zf(s,n.list||void 0);if(n.name){let a=n.commit,i;if(a){let u=await It(s,a,`Failed to resolve '${a}' as a valid ref.`);if(S(u))return u;i=u}else if(i=await Y(s),!i)return T("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await F(s,c)&&!n.force)return T(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return T("no tag message specified (use -m)");let u=await Ye(s,r.env);if(S(u))return u;let l=$t(n.message),m=ca({type:"tag",object:i,objectType:"commit",name:n.name,tagger:u,message:l}),h=await Re(s,"tag",m);await z(s,c,h)}else await z(s,c,i);return{stdout:"",stderr:"",exitCode:0}}return Zf(s)}})}async function Zf(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=>Ln(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
698
+ `)}
699
+ `,stderr:"",exitCode:0}}var Zh={init:e=>uf(e),clone:(e,t)=>_c(e,t),fetch:(e,t)=>tf(e,t),pull:(e,t)=>Cf(e,t),push:(e,t)=>Pf(e,t),add:(e,t)=>va(e,t),blame:(e,t)=>lc(e,t),commit:(e,t)=>Fc(e,t),status:(e,t)=>zf(e,t),log:(e,t)=>bf(e,t),branch:(e,t)=>hc(e,t),tag:(e,t)=>Jf(e,t),checkout:(e,t)=>pc(e,t),diff:(e,t)=>Zc(e,t),reset:(e,t)=>vf(e,t),merge:(e,t)=>kf(e,t),"cherry-pick":(e,t)=>Tc(e,t),revert:(e,t)=>jf(e,t),rebase:(e,t)=>$f(e,t),mv:(e,t)=>xf(e,t),rm:(e,t)=>Lf(e,t),remote:(e,t)=>Hf(e,t),config:(e,t)=>qc(e,t),show:(e,t)=>Nf(e,t),stash:(e,t)=>Kf(e,t),"rev-parse":(e,t)=>Mf(e,t),"ls-files":(e,t)=>Ef(e,t),clean:(e,t)=>Hc(e,t),switch:(e,t)=>Yf(e,t),restore:(e,t)=>Df(e,t),reflog:(e,t)=>Tf(e,t),repack:(e,t)=>ff(e,t),gc:(e,t)=>df(e,t),bisect:(e,t)=>Za(e,t)};function Qf(e){let t=ho("git",{description:"Git command"});for(let n of Object.values(Zh))n(t,e);return t}var ao=class{listeners=new Map;onError=()=>{};on(t,n){let r=t,o=this.listeners.get(r);o||(o=[],this.listeners.set(r,o));let s=n;return o.push(s),()=>{let a=this.listeners.get(r);if(a){let i=a.indexOf(s);i!==-1&&a.splice(i,1)}}}async emitPre(t,n){let r=this.listeners.get(t);if(!r||r.length===0)return null;for(let o of r){let s=await o(n);if(s&&typeof s=="object"&&"abort"in s)return s}return null}async emitPost(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)await o(n)}emit(t,n){let r=this.listeners.get(t);if(!(!r||r.length===0))for(let o of r)try{let s=o(n);s&&typeof s=="object"&&"then"in s&&s.catch(this.onError)}catch(s){this.onError(s)}}};var co=class{name="git";hooks;middlewares=[];extensions;inner;constructor(t){this.hooks=new ao;let n=t?.network;if(this.extensions={hooks:this.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n},t?.disabled?.length){let r=new Set(t.disabled);this.use(async(o,s)=>o.command&&r.has(o.command)?{stdout:"",stderr:`git: '${o.command}' is not available in this environment
700
+ `,exitCode:1}:s())}this.inner=Qf(this.extensions).toCommand()}on(t,n){return this.hooks.on(t,n)}use(t){return this.middlewares.push(t),()=>{let n=this.middlewares.indexOf(t);n!==-1&&this.middlewares.splice(n,1)}}execute=async(t,n)=>{let r={command:t[0],rawArgs:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env,stdin:n.stdin,exec:n.exec,signal:n.signal};return this.runMiddleware(r,()=>this.inner.execute(t,n))};async runMiddleware(t,n){if(this.middlewares.length===0)return n();let r=0,o=async()=>{if(r>=this.middlewares.length)return n();let s=this.middlewares[r++];return s(t,o)};return o()}};function Jh(e){return new co(e)}export{co as Git,Jh as createGit};