just-git 1.3.5 → 1.3.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/README.md CHANGED
@@ -99,7 +99,15 @@ Uses web-standard `Request`/`Response`. Works with Bun, Hono, Cloudflare Workers
99
99
  Everything operates on `GitRepo`, a minimal `{ objectStore, refStore }` interface shared by the client and server. A `GitRepo` can be backed by a virtual filesystem, SQLite, Postgres, or any custom storage. The same helpers work inside both client-side hooks and server-side hooks, and `createWorktree` lets you spin up a full git client against a database-backed repo.
100
100
 
101
101
  ```ts
102
- import { readFileAtCommit, getChangedFiles, mergeTrees } from "just-git/repo";
102
+ import { commit, readFileAtCommit, getChangedFiles, mergeTrees } from "just-git/repo";
103
+
104
+ // Commit files to a branch — handles blobs, trees, parents, and refs
105
+ await commit(repo, {
106
+ files: { "README.md": "# Hello\n", "src/index.ts": "export {};\n" },
107
+ message: "initial commit\n",
108
+ author: { name: "Alice", email: "alice@example.com" },
109
+ branch: "main",
110
+ });
103
111
 
104
112
  const content = await readFileAtCommit(repo, commitHash, "src/index.ts");
105
113
  const changes = await getChangedFiles(repo, parentHash, commitHash);
@@ -105,6 +105,12 @@ interface RawObject {
105
105
  type: ObjectType;
106
106
  content: Uint8Array;
107
107
  }
108
+ interface TreeEntry {
109
+ /** e.g. "100644", "040000", "100755", "120000", "160000" */
110
+ mode: string;
111
+ name: string;
112
+ hash: ObjectId;
113
+ }
108
114
  /** Author or committer identity with timestamp. */
109
115
  interface Identity {
110
116
  name: string;
@@ -647,4 +653,4 @@ interface GitHooks {
647
653
  */
648
654
  declare function composeGitHooks(...hookSets: (GitHooks | undefined)[]): GitHooks;
649
655
 
650
- export { type Ref as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type DirectRef as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PreCleanEvent as J, type PreCloneEvent as K, type PreCommitEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type PackObject as P, type PreFetchEvent as Q, type RemoteResolver as R, type PreMergeCommitEvent as S, type PrePullEvent as T, type PrePushEvent as U, type PreRebaseEvent as V, type PreResetEvent as W, type PreRevertEvent as X, type PreRmEvent as Y, type PreStashEvent as Z, type RawObject as _, type RefStore as a, type RefDeleteEvent as a0, type RefEntry as a1, type RefUpdateEvent as a2, type Rejection as a3, type SymbolicRef as a4, composeGitHooks as a5, isRejection as a6, type TreeDiffEntry as a7, type ConfigOverrides as b, type FileStat as c, type GitContext as d, type Commit as e, type CommitMsgEvent as f, type GitRepo as g, type Identity as h, type ObjectId as i, type ObjectType as j, type ObjectWriteEvent as k, type PostCheckoutEvent as l, type PostCherryPickEvent as m, type PostCleanEvent as n, type PostCloneEvent as o, type PostCommitEvent as p, type PostFetchEvent as q, type PostMergeEvent as r, type PostPullEvent as s, type PostPushEvent as t, type PostResetEvent as u, type PostRevertEvent as v, type PostRmEvent as w, type PostStashEvent as x, type PreCheckoutEvent as y, type PreCherryPickEvent as z };
656
+ export { type Ref as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type DirectRef as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PreCleanEvent as J, type PreCloneEvent as K, type PreCommitEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type PackObject as P, type PreFetchEvent as Q, type RemoteResolver as R, type PreMergeCommitEvent as S, type PrePullEvent as T, type PrePushEvent as U, type PreRebaseEvent as V, type PreResetEvent as W, type PreRevertEvent as X, type PreRmEvent as Y, type PreStashEvent as Z, type RawObject as _, type RefStore as a, type RefDeleteEvent as a0, type RefEntry as a1, type RefUpdateEvent as a2, type Rejection as a3, type SymbolicRef as a4, composeGitHooks as a5, isRejection as a6, type TreeEntry as a7, type TreeDiffEntry as a8, type ConfigOverrides as b, type FileStat as c, type GitContext as d, type Commit as e, type CommitMsgEvent as f, type GitRepo as g, type Identity as h, type ObjectId as i, type ObjectType as j, type ObjectWriteEvent as k, type PostCheckoutEvent as l, type PostCherryPickEvent as m, type PostCleanEvent as n, type PostCloneEvent as o, type PostCommitEvent as p, type PostFetchEvent as q, type PostMergeEvent as r, type PostPullEvent as s, type PostPushEvent as t, type PostResetEvent as u, type PostRevertEvent as v, type PostRmEvent as w, type PostStashEvent as x, type PreCheckoutEvent as y, type PreCherryPickEvent as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, E as ExecResult, c as FileStat, d as GitContext } from './hooks-t3k-y0u_.js';
2
- export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, P as PackObject, l as PostCheckoutEvent, m as PostCherryPickEvent, n as PostCleanEvent, o as PostCloneEvent, p as PostCommitEvent, q as PostFetchEvent, r as PostMergeEvent, s as PostPullEvent, t as PostPushEvent, u as PostResetEvent, v as PostRevertEvent, w as PostRmEvent, x as PostStashEvent, y as PreCheckoutEvent, z as PreCherryPickEvent, J as PreCleanEvent, K as PreCloneEvent, L as PreCommitEvent, Q as PreFetchEvent, S as PreMergeCommitEvent, T as PrePullEvent, U as PrePushEvent, V as PreRebaseEvent, W as PreResetEvent, X as PreRevertEvent, Y as PreRmEvent, Z as PreStashEvent, _ as RawObject, $ as Ref, a0 as RefDeleteEvent, a1 as RefEntry, a2 as RefUpdateEvent, a3 as Rejection, a4 as SymbolicRef, a5 as composeGitHooks, a6 as isRejection } from './hooks-t3k-y0u_.js';
1
+ import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, E as ExecResult, c as FileStat, d as GitContext } from './hooks-DNBNCTgb.js';
2
+ export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, P as PackObject, l as PostCheckoutEvent, m as PostCherryPickEvent, n as PostCleanEvent, o as PostCloneEvent, p as PostCommitEvent, q as PostFetchEvent, r as PostMergeEvent, s as PostPullEvent, t as PostPushEvent, u as PostResetEvent, v as PostRevertEvent, w as PostRmEvent, x as PostStashEvent, y as PreCheckoutEvent, z as PreCherryPickEvent, J as PreCleanEvent, K as PreCloneEvent, L as PreCommitEvent, Q as PreFetchEvent, S as PreMergeCommitEvent, T as PrePullEvent, U as PrePushEvent, V as PreRebaseEvent, W as PreResetEvent, X as PreRevertEvent, Y as PreRmEvent, Z as PreStashEvent, _ as RawObject, $ as Ref, a0 as RefDeleteEvent, a1 as RefEntry, a2 as RefUpdateEvent, a3 as Rejection, a4 as SymbolicRef, a5 as composeGitHooks, a6 as isRejection } from './hooks-DNBNCTgb.js';
3
3
 
4
4
  /** Options for subcommand execution (mirrors just-bash's CommandExecOptions). */
5
5
  interface CommandExecOptions {
package/dist/index.js CHANGED
@@ -342,8 +342,8 @@ ${n}
342
342
  `),l=as(f,"","<cli>");i={...i,dirPatterns:[l,...i.dirPatterns]}}}let a=await e.fs.readdir(t);for(let c of a){if(n===""&&c===".git")continue;let f=S(t,c),l=n?`${n}/${c}`:c,d=await e.fs.stat(f);if(d.isDirectory){let m=i&&an(i,l,!0)==="ignored",u=Qh(r.trackedPaths,l),h=()=>Zf(e,f,l,{...r,_ignore:i??void 0});if(r.onlyIgnored){if(m&&!u){r.removeDirs&&o.push({path:l,isDir:!0});continue}let p=await h();!u&&r.removeDirs?p.length>0&&o.push({path:l,isDir:!0}):o.push(...p)}else if(u){let p=await h();o.push(...p)}else if(!(m&&s)){if(r.removeDirs)if(r.removeIgnored)o.push({path:l,isDir:!0});else{let p=await h(),g=await e.fs.readdir(f);(p.length>0||g.length===0)&&o.push({path:l,isDir:!0})}}}else if(d.isFile){if(r.trackedPaths.has(l))continue;let m=i&&an(i,l,!1)==="ignored";r.onlyIgnored?m&&o.push({path:l,isDir:!1}):m&&s||o.push({path:l,isDir:!1})}}return o}function Qh(e,t){let n=`${t}/`;for(let r of e)if(r.startsWith(n))return!0;return!1}ie();qe();vn();Ce();ce();me();ze();ge();Gn();ce();me();var bs=2147483647;async function Ar(e){let t=S(e.gitDir,"shallow");try{let n=await e.fs.readFile(t),r=new Set;for(let o of n.split(`
343
343
  `)){let s=o.trim();s.length===40&&r.add(s)}return r}catch{return new Set}}async function ep(e,t){let n=S(e.gitDir,"shallow");if(t.size===0){try{await e.fs.rm(n,{force:!0})}catch{}return}let r=[...t].sort();await e.fs.writeFile(n,r.join(`
344
344
  `)+`
345
- `)}async function $o(e){return(await Ar(e)).size>0}async function Dr(e,t,n){let r=n??await Ar(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await ep(e,r)}async function Jf(e,t,n,r){if(n>=bs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Vt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await j(e,f)}catch{continue}for(let m of d.parents)!o.has(m)&&await Vt(e,m)&&(o.set(m,l+1),s.push({hash:m,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}qe();Gn();ht();ce();var Io=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),tp=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Oo=64,np=4,Qi=4096,Qf=65536,rp=127;function sp(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=ip(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let m=n*16-16;m>=0;m-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|e[m+h])^Io[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=m+16;else{a=u;let h=u&o;i.push({ptr:m+16,val:u}),s[h]++}}let c=new Map;for(let m of i){let u=m.val&o,h=c.get(u);h||(h=[],c.set(u,h)),h.push(m)}for(let[m,u]of c){if(u.length<=Oo)continue;let h=[],p=u.length/Oo;for(let g=0;g<Oo;g++)h.push(u[Math.floor(g*p)]);c.set(m,h),s[m]=Oo}let f=new Uint32Array(r+1),l=[],d=0;for(let m=0;m<r;m++){f[m]=d;let u=c.get(m);if(u){for(let h of u)l.push(h);d+=u.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function op(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=tl(i,a,r),a=tl(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^Io[f>>>23],l++;f=f>>>0;let m=d,u=0,h=0;for(;m<o;){if(h<Qi){f^=tp[t[m-16]],f=((f<<8|t[m])^Io[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let b=g;b<w;b++){let x=e.entries[b];if(x.val!==f)continue;let y=x.ptr,k=s.byteLength-y,E=o-m;if(k>E&&(k=E),k<=h)break;let R=0;for(;R<k&&s[y+R]===t[m+R];)R++;if(R>h&&(h=R,u=y,h>=Qi))break}}if(h<np)c(2),l===0&&a++,i[a++]=t[m++],l++,l===rp&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&s[u-1]===t[m-1];)if(h++,u--,m--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Qf?h-Qf:0;h-=p,c(8);let g=a++,w=128;if(u&255&&(i[a++]=u&255,w|=1),u&65280&&(i[a++]=u>>>8&255,w|=2),u&16711680&&(i[a++]=u>>>16&255,w|=4),u&4278190080&&(i[a++]=u>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,m+=h,u+=h,h=p,u>4294967295&&(h=0),h<Qi){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[m+b])^Io[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var el={blob:0,tree:1,commit:2,tag:3};function So(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=el[f.type]??99,m=el[l.type]??99;return d!==m?d-m:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},m=null,u=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let y=m?m.byteLength:l.content.byteLength/2|0;if(y<16)continue;let k=op(x,l.content,y);k&&(!m||k.byteLength<m.byteLength)&&(m=k,u=g.hash)}if(m&&u){d.delta=m,d.deltaBase=u;let p=s.get(u);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(sp(l.content)),c.push(l.hash)}return i}function ip(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function tl(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}Cr();ge();ce();gn();$r();Vs();async function ap(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await ys(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let m of d.parents)i.has(m)||a.push(m)}catch{}let c=[],f=new Set;for(let l of a)await Es(e,l,i,f,c,r);return{count:c.length,objects:cp(c)}}async function Mr(e,t,n,r,o){let{count:s,objects:i}=await ap(e,t,n,r,o);return{count:s,objects:fp(e,i)}}async function*cp(e){for(let t of e)yield t}async function*fp(e,t){for await(let n of t){let r=await be(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function jr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function ys(e,t,n,r){if(n.has(t)||(n.add(t),!await Vt(e,t)))return;let o=await be(e,t);switch(o.type){case"commit":{let s=nn(o.content);if(await ys(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await ys(e,i,n,r);break}case"tree":{let s=_n(o.content);for(let i of s.entries)await ys(e,i.hash,n,r);break}case"tag":{let s=Kt(o.content);await ys(e,s.object,n,r);break}case"blob":break}}async function Es(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await be(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=nn(i.content);if(await Es(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Es(e,c,n,r,o,s);break}case"tree":{let a=_n(i.content);for(let c of a.entries)await Es(e,c.hash,n,r,o,s);break}case"tag":{let a=Kt(i.content);await Es(e,a.object,n,r,o,s);break}case"blob":break}}var lp=new TextEncoder,vo=new TextDecoder,nl=65520,dp=new Uint8Array([48,48,48,48]);function On(e){let t=typeof e=="string"?lp.encode(e):e,n=4+t.byteLength;if(n>nl)throw new Error(`pkt-line too long: ${n} bytes (max ${nl})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function ea(){return dp.slice()}function To(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function Gr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=vo.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Ho(e){if(e.type==="flush")return"";let t=vo.decode(e.data);return t.endsWith(`
346
- `)?t.slice(0,-1):t}var up=1,mp=2,hp=3;function ta(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type==="flush"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case up:t.push(f),o+=f.byteLength;break;case mp:n.push(vo.decode(f));break;case hp:r.push(vo.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}ht();function na(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ra(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...na(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let l=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(l))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=Gr(c);return pp(f,t)}function pp(e,t){let n=0,r=e[n];r?.type==="data"&&Ho(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let m=l.slice(0,d),u=l.slice(d+1);if(!(m===te&&u==="capabilities^{}")){if(u.endsWith("^{}")){let h=u.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=m);continue}o.push({name:u,hash:m})}}return{refs:o,capabilities:s,symrefs:i}}var gp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function rl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=ol(r,gp),c=[];c.push(On(`want ${t[0]} ${a.join(" ")}
345
+ `)}async function $o(e){return(await Ar(e)).size>0}async function Dr(e,t,n){let r=n??await Ar(e);for(let o of t.shallow)r.add(o);for(let o of t.unshallow)r.delete(o);await ep(e,r)}async function Jf(e,t,n,r){if(n>=bs)return{shallow:[],unshallow:[...r]};let o=new Map,s=[];for(let f of t)!o.has(f)&&await Vt(e,f)&&(o.set(f,1),s.push({hash:f,level:1}));let i=new Set,a=0;for(;a<s.length;){let{hash:f,level:l}=s[a++];if(l>=n){i.add(f);continue}let d;try{d=await j(e,f)}catch{continue}for(let m of d.parents)!o.has(m)&&await Vt(e,m)&&(o.set(m,l+1),s.push({hash:m,level:l+1}))}let c=[];for(let f of r){let l=o.get(f);l!==void 0&&l<n&&c.push(f)}return{shallow:[...i],unshallow:c}}qe();Gn();ht();ce();var Io=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),tp=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Oo=64,np=4,Qi=4096,Qf=65536,rp=127;function sp(e){let t=e.byteLength;if(t===0)return null;let n=(t-1)/16|0;if(n===0)return null;let r=n>>>2;r<16&&(r=16),r=ip(r);let o=r-1,s=new Uint32Array(r),i=[],a=-1>>>0;for(let m=n*16-16;m>=0;m-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|e[m+h])^Io[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=m+16;else{a=u;let h=u&o;i.push({ptr:m+16,val:u}),s[h]++}}let c=new Map;for(let m of i){let u=m.val&o,h=c.get(u);h||(h=[],c.set(u,h)),h.push(m)}for(let[m,u]of c){if(u.length<=Oo)continue;let h=[],p=u.length/Oo;for(let g=0;g<Oo;g++)h.push(u[Math.floor(g*p)]);c.set(m,h),s[m]=Oo}let f=new Uint32Array(r+1),l=[],d=0;for(let m=0;m<r;m++){f[m]=d;let u=c.get(m);if(u){for(let h of u)l.push(h);d+=u.length}}return f[r]=d,{src:e,hashMask:o,buckets:f,entries:l}}function op(e,t,n){if(!e||t.byteLength===0)return null;let r=e.src.byteLength,o=t.byteLength,s=e.src,i=new Uint8Array(Math.max(o,1024)),a=0;function c(p){for(;a+p>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}a=tl(i,a,r),a=tl(i,a,o),c(18),a++;let f=0,l=0,d=Math.min(16,o);for(let p=0;p<d;p++)i[a++]=t[p],f=(f<<8|t[p])^Io[f>>>23],l++;f=f>>>0;let m=d,u=0,h=0;for(;m<o;){if(h<Qi){f^=tp[t[m-16]],f=((f<<8|t[m])^Io[f>>>23])>>>0;let p=f&e.hashMask,g=e.buckets[p],w=e.buckets[p+1];for(let b=g;b<w;b++){let x=e.entries[b];if(x.val!==f)continue;let y=x.ptr,k=s.byteLength-y,E=o-m;if(k>E&&(k=E),k<=h)break;let R=0;for(;R<k&&s[y+R]===t[m+R];)R++;if(R>h&&(h=R,u=y,h>=Qi))break}}if(h<np)c(2),l===0&&a++,i[a++]=t[m++],l++,l===rp&&(i[a-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&s[u-1]===t[m-1];)if(h++,u--,m--,a--,!(--l>0)){a--,l=-1;break}l>0&&(i[a-l-1]=l),l=0}let p=h>Qf?h-Qf:0;h-=p,c(8);let g=a++,w=128;if(u&255&&(i[a++]=u&255,w|=1),u&65280&&(i[a++]=u>>>8&255,w|=2),u&16711680&&(i[a++]=u>>>16&255,w|=4),u&4278190080&&(i[a++]=u>>>24&255,w|=8),h&255&&(i[a++]=h&255,w|=16),h&65280&&(i[a++]=h>>>8&255,w|=32),i[g]=w,m+=h,u+=h,h=p,u>4294967295&&(h=0),h<Qi){f=0;for(let b=-16;b<0;b++)f=(f<<8|t[m+b])^Io[f>>>23];f=f>>>0}}if(n&&a>n)return null}return l>0&&(i[a-l-1]=l),n&&a>n?null:i.subarray(0,a)}var el={blob:0,tree:1,commit:2,tag:3};function So(e,t){let n=t?.window??10,r=t?.depth??50,o=e.slice().sort((f,l)=>{let d=el[f.type]??99,m=el[l.type]??99;return d!==m?d-m:l.content.byteLength-f.content.byteLength}),s=new Map,i=[],a=[],c=[];for(let f=0;f<o.length;f++){let l=o[f],d={hash:l.hash,type:l.type,content:l.content,depth:0},m=null,u=null,h=Math.max(0,f-n);for(let p=f-1;p>=h;p--){let g=o[p];if(g.type!==l.type||(s.get(g.hash)?.depth??0)>=r||l.content.byteLength<g.content.byteLength>>>5)continue;let x=a[p-h]??null;if(!x)continue;let y=m?m.byteLength:l.content.byteLength/2|0;if(y<16)continue;let k=op(x,l.content,y);k&&(!m||k.byteLength<m.byteLength)&&(m=k,u=g.hash)}if(m&&u){d.delta=m,d.deltaBase=u;let p=s.get(u);d.depth=(p?.depth??0)+1}s.set(l.hash,d),i.push(d),a.length>=n&&(a.shift(),c.shift()),a.push(sp(l.content)),c.push(l.hash)}return i}function ip(e){let t=e;return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t<16?16:t}function tl(e,t,n){let r=n;do{let o=r&127;r>>>=7,r>0&&(o|=128),e[t++]=o}while(r>0);return t}Cr();ge();ce();gn();$r();Vs();async function ap(e,t,n,r,o){let s=o??r,i=new Set;for(let l of n)await ys(e,l,i,s);let a=[...t];if(o&&r)for(let l of o)try{let d=await j(e,l);for(let m of d.parents)i.has(m)||a.push(m)}catch{}let c=[],f=new Set;for(let l of a)await Es(e,l,i,f,c,r);return{count:c.length,objects:cp(c)}}async function Mr(e,t,n,r,o){let{count:s,objects:i}=await ap(e,t,n,r,o);return{count:s,objects:fp(e,i)}}async function*cp(e){for(let t of e)yield t}async function*fp(e,t){for await(let n of t){let r=await be(e,n.hash);yield{hash:n.hash,type:n.type,content:r.content}}}async function jr(e){let t=[];for await(let n of e.objects)t.push(n);return t}async function ys(e,t,n,r){if(n.has(t)||(n.add(t),!await Vt(e,t)))return;let o=await be(e,t);switch(o.type){case"commit":{let s=nn(o.content);if(await ys(e,s.tree,n,r),!r?.has(t))for(let i of s.parents)await ys(e,i,n,r);break}case"tree":{let s=_n(o.content);for(let i of s.entries)await ys(e,i.hash,n,r);break}case"tag":{let s=Kt(o.content);await ys(e,s.object,n,r);break}case"blob":break}}async function Es(e,t,n,r,o,s){if(r.has(t)||n.has(t))return;r.add(t);let i=await be(e,t);switch(o.push({hash:t,type:i.type}),i.type){case"commit":{let a=nn(i.content);if(await Es(e,a.tree,n,r,o,s),!s?.has(t))for(let c of a.parents)await Es(e,c,n,r,o,s);break}case"tree":{let a=_n(i.content);for(let c of a.entries)await Es(e,c.hash,n,r,o,s);break}case"tag":{let a=Kt(i.content);await Es(e,a.object,n,r,o,s);break}case"blob":break}}var lp=new TextEncoder,vo=new TextDecoder,nl=65520,dp=new Uint8Array([48,48,48,48]),$R=new Uint8Array([48,48,48,49]),OR=new Uint8Array([48,48,48,50]);function On(e){let t=typeof e=="string"?lp.encode(e):e,n=4+t.byteLength;if(n>nl)throw new Error(`pkt-line too long: ${n} bytes (max ${nl})`);let r=n.toString(16).padStart(4,"0"),o=new Uint8Array(n);return o[0]=r.charCodeAt(0),o[1]=r.charCodeAt(1),o[2]=r.charCodeAt(2),o[3]=r.charCodeAt(3),o.set(t,4),o}function ea(){return dp.slice()}function To(...e){let t=0;for(let o of e)t+=o.byteLength;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n}function Gr(e){let t=[],n=0;for(;n<e.byteLength;){if(n+4>e.byteLength)throw new Error("Truncated pkt-line header");let r=vo.decode(e.subarray(n,n+4)),o=parseInt(r,16);if(Number.isNaN(o))throw new Error(`Invalid pkt-line length: ${r}`);if(o===0){t.push({type:"flush"}),n+=4;continue}if(o===1){t.push({type:"delim"}),n+=4;continue}if(o===2){t.push({type:"response-end"}),n+=4;continue}if(o<4)throw new Error(`Invalid pkt-line length: ${o}`);if(n+o>e.byteLength)throw new Error(`Truncated pkt-line: need ${o} bytes at offset ${n}, have ${e.byteLength-n}`);t.push({type:"data",data:e.subarray(n+4,n+o)}),n+=o}return t}function Ho(e){if(e.type!=="data")return"";let t=vo.decode(e.data);return t.endsWith(`
346
+ `)?t.slice(0,-1):t}var up=1,mp=2,hp=3;function ta(e){let t=[],n=[],r=[],o=0;for(let a of e){if(a.type!=="data"||a.data.byteLength===0)continue;let c=a.data[0];if(c===void 0)continue;let f=a.data.subarray(1);switch(c){case up:t.push(f),o+=f.byteLength;break;case mp:n.push(vo.decode(f));break;case hp:r.push(vo.decode(f));break;default:break}}let s=new Uint8Array(o),i=0;for(let a of t)s.set(a,i),i+=a.byteLength;return{packData:s,progress:n,errors:r}}ht();function na(e){return e?e.type==="bearer"?{Authorization:`Bearer ${e.token}`}:{Authorization:`Basic ${btoa(`${e.username}:${e.password}`)}`}:{}}async function ra(e,t,n,r=globalThis.fetch){let o=e.replace(/\/+$/,""),s=await r(`${o}/info/refs?service=${t}`,{headers:{...na(n),"User-Agent":"just-git/1.0"}});if(!s.ok)throw new Error(`HTTP ${s.status} discovering refs at ${o}`);let i=s.headers.get("content-type")??"",a=`application/x-${t}-advertisement`,c=new Uint8Array(await s.arrayBuffer());if(!i.startsWith(a)){let l=new TextDecoder().decode(c.subarray(0,5));if(!/^[0-9a-f]{4}#/.test(l))throw new Error(`Server does not support smart HTTP (Content-Type: ${i})`)}let f=Gr(c);return pp(f,t)}function pp(e,t){let n=0,r=e[n];r?.type==="data"&&Ho(r)===`# service=${t}`&&n++,e[n]?.type==="flush"&&n++;let o=[],s=[],i=new Map;for(;n<e.length;n++){let a=e[n];if(!a||a.type==="flush")break;if(a.type!=="data")continue;let c=a.data,f=c.indexOf(0),l;if(f!==-1){l=new TextDecoder().decode(c.subarray(0,f)),s=new TextDecoder().decode(c.subarray(f+1)).replace(/\n$/,"").split(" ").filter(Boolean);for(let p of s)if(p.startsWith("symref=")){let g=p.slice(7),w=g.indexOf(":");w!==-1&&i.set(g.slice(0,w),g.slice(w+1))}}else l=new TextDecoder().decode(c).replace(/\n$/,"");let d=l.indexOf(" ");if(d===-1)continue;let m=l.slice(0,d),u=l.slice(d+1);if(!(m===te&&u==="capabilities^{}")){if(u.endsWith("^{}")){let h=u.slice(0,-3),p=o.find(g=>g.name===h);p&&(p.peeledHash=m);continue}o.push({name:u,hash:m})}}return{refs:o,capabilities:s,symrefs:i}}var gp=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"];async function rl(e,t,n,r,o,s=globalThis.fetch,i){if(t.length===0)throw new Error("fetchPack requires at least one want");let a=ol(r,gp),c=[];c.push(On(`want ${t[0]} ${a.join(" ")}
347
347
  `));for(let u=1;u<t.length;u++)c.push(On(`want ${t[u]}
348
348
  `));if(i?.existingShallows)for(let u of i.existingShallows)c.push(On(`shallow ${u}
349
349
  `));i?.depth!==void 0&&c.push(On(`deepen ${i.depth}
@@ -776,7 +776,7 @@ ${m}`,exitCode:0}}ie();ce();$r();ge();is();function $d(e,t){e.command("tag",{des
776
776
  `)}if(n.list)return Pd(s,n.name||void 0);if(n.name){if(!vc(n.name))return I(`'${n.name}' is not a valid tag name`);let i=n.commit,a;if(i){let d=await wt(s,i,`Failed to resolve '${i}' as a valid ref.`);if(M(d))return d;a=d}else if(a=await Z(s),!a)return I("Failed to resolve 'HEAD' as a valid ref.");let c=`refs/tags/${n.name}`;if(await B(s,c)&&!n.force)return I(`tag '${n.name}' already exists`);if(n.annotate||n.message){if(!n.message)return I("no tag message specified (use -m)");let d=await nt(s,r.env);if(M(d))return d;let m=Mt(n.message),u=$c({type:"tag",object:a,objectType:"commit",name:n.name,tagger:d,message:m}),h=await Ae(s,"tag",u);await X(s,c,h)}else await X(s,c,a);return{stdout:"",stderr:"",exitCode:0}}return Pd(s)}})}async function Pd(e,t){let n=await pe(e,"refs/tags");if(n.length===0)return{stdout:"",stderr:"",exitCode:0};let r=n.map(o=>o.name.replace("refs/tags/",""));return t&&(r=r.filter(o=>on(t,o,0)===0)),r.length===0?{stdout:"",stderr:"",exitCode:0}:{stdout:`${r.join(`
777
777
  `)}
778
778
  `,stderr:"",exitCode:0}}var Od=new Set(["am","annotate","apply","archive","bugreport","bundle","cat-file","check-ignore","check-mailmap","check-ref-format","checkout-index","cherry","commit-tree","count-objects","credential","daemon","diff-files","diff-index","diff-tree","difftool","fast-export","fast-import","filter-branch","for-each-ref","format-patch","fsck","hash-object","instaweb","interpret-trailers","log--hierarchical","ls-remote","ls-tree","maintenance","merge-base","merge-tree","mergetool","multi-pack-index","name-rev","notes","pack-objects","pack-refs","patch-id","prune","range-diff","read-tree","receive-pack","replace","request-pull","rerere","rev-list","send-email","send-pack","shortlog","show-branch","show-ref","sparse-checkout","stash--helper","stripspace","submodule","symbolic-ref","unpack-objects","update-index","update-ref","upload-pack","var","verify-commit","verify-pack","verify-tag","whatchanged","worktree","write-tree"]),Iw={init:(e,t)=>Gl(e,t),clone:(e,t)=>ll(e,t),describe:(e,t)=>ul(e,t),fetch:(e,t)=>Il(e,t),pull:(e,t)=>nd(e,t),push:(e,t)=>rd(e,t),add:(e,t)=>Xc(e,t),blame:(e,t)=>Tf(e,t),commit:(e,t)=>ml(e,t),status:(e,t)=>kd(e,t),log:(e,t)=>Kl(e,t),branch:(e,t)=>Af(e,t),tag:(e,t)=>$d(e,t),checkout:(e,t)=>Mf(e,t),diff:(e,t)=>xl(e,t),reset:(e,t)=>ad(e,t),merge:(e,t)=>Xl(e,t),"cherry-pick":(e,t)=>Yf(e,t),revert:(e,t)=>dd(e,t),rebase:(e,t)=>td(e,t),mv:(e,t)=>Zl(e,t),rm:(e,t)=>ud(e,t),remote:(e,t)=>od(e,t),config:(e,t)=>wl(e,t),show:(e,t)=>md(e,t),stash:(e,t)=>Ed(e,t),"rev-parse":(e,t)=>ld(e,t),"ls-files":(e,t)=>Yl(e,t),clean:(e,t)=>Xf(e,t),switch:(e,t)=>xd(e,t),restore:(e,t)=>fd(e,t),reflog:(e,t)=>sd(e,t),repack:(e,t)=>Tl(e,t),gc:(e,t)=>Hl(e,t),bisect:(e,t)=>wf(e,t),grep:(e,t)=>jl(e,t)};function Id(e){let t=Xo("git",{description:"Git command"});for(let n of Object.values(Iw))n(t,e);return t.command("help",{description:"Display help information",args:[q.string().name("command").describe("Command to get help for").optional()],handler:async n=>{let r=n.command;if(!r)return{stdout:Er(t),stderr:"",exitCode:0};let o=t.children.get(r);return o?{stdout:Er(o),stderr:"",exitCode:0}:{stdout:"",stderr:`git: no help available for '${r}'
779
- `,exitCode:1}}}),t}var Sw="1.3.5";function vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var qo=class{name="git";defaultFs;defaultCwd;blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=vw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Id(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Tw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${Sw} (virtual git implementation)
779
+ `,exitCode:1}}}),t}var Sw="1.3.7";function vw(e,t){if(!e)return t;let n=e.locked?"locked":"defaults",r={"user.name":e.name,"user.email":e.email};return t?{...t,[n]:{...r,...t[n]}}:{[n]:r}}var qo=class{name="git";defaultFs;defaultCwd;blocked;hooks;inner;locks=new WeakMap;async withLock(t,n){let r=this.locks.get(t)??Promise.resolve(),o,s=new Promise(i=>{o=i});this.locks.set(t,s),await r;try{return await n()}finally{o()}}constructor(t){this.defaultFs=t?.fs,this.defaultCwd=t?.cwd??"/",this.hooks=t?.hooks,this.blocked=t?.disabled?.length?new Set(t.disabled):null;let n=t?.network,r=vw(t?.identity,t?.config),o={hooks:t?.hooks,credentialProvider:t?.credentials,identityOverride:t?.identity,fetchFn:typeof n=="object"?n.fetch:void 0,networkPolicy:n,resolveRemote:t?.resolveRemote,...t?.objectStore?{objectStore:t.objectStore}:{},...t?.refStore?{refStore:t.refStore}:{},...t?.gitDir?{gitDir:t.gitDir,workTree:this.defaultCwd}:{},...r?{configOverrides:r}:{}};this.inner=Id(o).toCommand()}exec=async(t,n)=>{let r=n?.fs??this.defaultFs;if(!r)throw new Error("No filesystem: pass `fs` in exec() options or in createGit()");let o=n?.cwd??this.defaultCwd,s=Tw(t),i=new Map;if(n?.env)for(let[a,c]of Object.entries(n.env))i.set(a,c);return this.execute(s,{fs:r,cwd:o,env:i,stdin:n?.stdin??""})};execute=(t,n)=>this.withLock(n.fs,async()=>{let r=t[0]??"";if(r==="--version"||r==="version")return{stdout:`just-git version ${Sw} (virtual git implementation)
780
780
  `,stderr:"",exitCode:0};if(this.blocked?.has(r))return{stdout:"",stderr:`git: '${r}' is not available in this environment
781
781
  `,exitCode:1};if(r&&Od.has(r))return{stdout:"",stderr:`git: '${r}' is not implemented. Run 'git help' for available commands.
782
782
  `,exitCode:1};if(this.hooks?.beforeCommand){let s=await this.hooks.beforeCommand({command:r,args:t.slice(1),fs:n.fs,cwd:n.cwd,env:n.env});if(ee(s))return{stdout:"",stderr:s.message??"",exitCode:1}}let o=await this.inner.execute(t,n);return this.hooks?.afterCommand&&await this.hooks.afterCommand({command:r,args:t.slice(1),result:o}),o})};function Tw(e){let t=[],n="",r=0;for(;r<e.length;){let o=e[r];if(o==='"'){for(r++;r<e.length&&e[r]!=='"';){if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];if(s==='"'||s==="\\"){n+=s,r+=2;continue}}n+=e[r],r++}r++}else if(o==="'"){for(r++;r<e.length&&e[r]!=="'";)n+=e[r],r++;r++}else o===" "||o===" "?(n.length>0&&(t.push(n),n=""),r++):(n+=o,r++)}return n.length>0&&t.push(n),t.length>0&&t[0]==="git"&&t.shift(),t}function Hw(e){return new qo(e)}var Sd=new TextEncoder,Aw=new TextDecoder;function hn(e){let t=[];for(let n of e.split("/"))n==="."||n===""||(n===".."?t.pop():t.push(n));return"/"+t.join("/")}function zo(e){let t=e.lastIndexOf("/");return t<=0?"/":e.slice(0,t)}var Ca=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:16877,mtime:new Date}),t)for(let[n,r]of Object.entries(t)){let o=hn(n);this.ensureParents(o),this.data.set(o,{type:"file",content:typeof r=="string"?Sd.encode(r):r,mode:33188,mtime:new Date})}}ensureParents(t){let n=zo(t);n!=="/"&&(this.data.has(n)||(this.ensureParents(n),this.data.set(n,{type:"directory",mode:16877,mtime:new Date})))}resolve(t){let n="",r=new Set;for(let o of hn(t).slice(1).split("/")){n=`${n}/${o}`;let s=0,i=this.data.get(n);for(;i?.type==="symlink"&&s<40;){if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);r.add(n);let a=i.target;n=a.startsWith("/")?hn(a):hn(zo(n)+"/"+a),i=this.data.get(n),s++}if(s>=40)throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`)}return n}resolveParent(t){let n=hn(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let o="",s=new Set;for(let i=0;i<r.length-1;i++){o=`${o}/${r[i]}`;let a=this.data.get(o),c=0;for(;a?.type==="symlink"&&c<40;){if(s.has(o))throw new Error(`ELOOP: too many levels of symbolic links, '${t}'`);s.add(o);let f=a.target;o=f.startsWith("/")?hn(f):hn(zo(o)+"/"+f),a=this.data.get(o),c++}}return`${o}/${r[r.length-1]}`}async readFile(t){return Aw.decode(await this.readFileBuffer(t))}async readFileBuffer(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return n.content}async writeFile(t,n){let r=this.resolve(t);this.ensureParents(r),this.data.set(r,{type:"file",content:typeof n=="string"?Sd.encode(n):n,mode:33188,mtime:new Date})}async exists(t){try{return this.data.has(this.resolve(t))}catch{return!1}}async stat(t){let n=this.data.get(this.resolve(t));if(!n)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);return{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:n.type==="file"?n.content.byteLength:0,mtime:n.mtime}}async lstat(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime}}async mkdir(t,n){let r=hn(t);if(this.data.has(r)){if(this.data.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let o=zo(r);if(o!=="/"&&!this.data.has(o))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:16877,mtime:new Date})}async readdir(t){let n=this.resolve(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let o=n==="/"?"/":`${n}/`,s=new Set;for(let i of this.data.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&s.add(c)}return[...s].sort()}async rm(t,n){let r=hn(t),o=this.data.get(r);if(!o){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(o.type==="directory"){if(!n?.recursive&&(await this.readdir(r)).length>0)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);let s=r==="/"?"/":`${r}/`;for(let i of[...this.data.keys()])i.startsWith(s)&&this.data.delete(i)}this.data.delete(r)}async readlink(t){let n=this.resolveParent(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async symlink(t,n){let r=hn(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParents(r),this.data.set(r,{type:"symlink",target:t,mode:40960,mtime:new Date})}};Gn();export{qo as Git,Ca as MemoryFileSystem,Th as composeGitHooks,Hw as createGit,rr as findRepo,ee as isRejection};
@@ -1,4 +1,4 @@
1
- import { g as GitRepo, a1 as RefEntry, e as Commit, i as ObjectId, h as Identity, a7 as TreeDiffEntry, d as GitContext, F as FileSystem } from '../hooks-t3k-y0u_.js';
1
+ import { g as GitRepo, a1 as RefEntry, e as Commit, a7 as TreeEntry, i as ObjectId, h as Identity, a8 as TreeDiffEntry, j as ObjectType, d as GitContext, F as FileSystem } from '../hooks-DNBNCTgb.js';
2
2
 
3
3
  /**
4
4
  * Core grep matching logic shared by the `git grep` command and the
@@ -21,6 +21,21 @@ declare function readCommit(repo: GitRepo, hash: string): Promise<Commit>;
21
21
  declare function readBlob(repo: GitRepo, hash: string): Promise<Uint8Array>;
22
22
  /** Read a blob as a UTF-8 string by its hash. */
23
23
  declare function readBlobText(repo: GitRepo, hash: string): Promise<string>;
24
+ /**
25
+ * Read the direct children of a tree object.
26
+ *
27
+ * Unlike {@link flattenTree} (which recursively walks and returns full
28
+ * paths), this returns single-level entries — the same shape that
29
+ * {@link writeTree} accepts, making read-modify-write round-trips
30
+ * straightforward.
31
+ *
32
+ * ```ts
33
+ * const entries = await readTree(repo, commit.tree);
34
+ * entries.push({ name: "new-file.txt", hash: blobHash, mode: "100644" });
35
+ * const newTreeHash = await writeTree(repo, entries);
36
+ * ```
37
+ */
38
+ declare function readTree(repo: GitRepo, treeHash: string): Promise<TreeEntry[]>;
24
39
  /**
25
40
  * Read a file's content at a specific commit.
26
41
  * Returns null if the file doesn't exist at that commit.
@@ -201,14 +216,29 @@ declare function walkCommitHistory(repo: GitRepo, startHash: string | string[],
201
216
  paths?: string[];
202
217
  }): AsyncGenerator<CommitInfo>;
203
218
 
219
+ /**
220
+ * Simplified identity for the public API. When `date` is omitted,
221
+ * defaults to the current time. Accepts either this form or the
222
+ * internal `Identity` (with `timestamp`/`timezone`) for full control.
223
+ */
224
+ interface CommitAuthor {
225
+ name: string;
226
+ email: string;
227
+ /** Defaults to `new Date()` (current time). */
228
+ date?: Date;
229
+ }
230
+ /** Accepts either the simplified {@link CommitAuthor} or the internal `Identity` with raw timestamp/timezone. */
231
+ type CommitIdentity = CommitAuthor | Identity;
204
232
  /** Options for {@link createCommit}. */
205
233
  interface CreateCommitOptions {
206
234
  /** Hash of the tree object for this commit. */
207
235
  tree: string;
208
236
  /** Parent commit hashes (empty for root commits). */
209
237
  parents: string[];
210
- author: Identity;
211
- committer: Identity;
238
+ /** Author identity. Accepts `{ name, email, date? }` or full `Identity`. */
239
+ author: CommitIdentity;
240
+ /** Committer identity. Defaults to `author` when omitted. */
241
+ committer?: CommitIdentity;
212
242
  message: string;
213
243
  /**
214
244
  * When set, advances `refs/heads/<branch>` to the new commit.
@@ -226,6 +256,68 @@ interface CreateCommitOptions {
226
256
  * Without `branch`, no refs are updated.
227
257
  */
228
258
  declare function createCommit(repo: GitRepo, options: CreateCommitOptions): Promise<string>;
259
+ /** Options for {@link createAnnotatedTag}. */
260
+ interface CreateAnnotatedTagOptions {
261
+ /** Hash of the target object (usually a commit). */
262
+ target: string;
263
+ /** Tag name (written into the tag object and used for the ref). */
264
+ name: string;
265
+ /** Tagger identity. Accepts `{ name, email, date? }` or full `Identity`. */
266
+ tagger: CommitIdentity;
267
+ message: string;
268
+ /** Type of the target object. Defaults to `"commit"`. */
269
+ targetType?: ObjectType;
270
+ }
271
+ /**
272
+ * Create an annotated tag object and its ref.
273
+ * Returns the tag object's hash.
274
+ *
275
+ * ```ts
276
+ * await createAnnotatedTag(repo, {
277
+ * target: commitHash,
278
+ * name: "v1.0.0",
279
+ * tagger: { name: "Alice", email: "alice@example.com" },
280
+ * message: "Release 1.0.0",
281
+ * });
282
+ * ```
283
+ */
284
+ declare function createAnnotatedTag(repo: GitRepo, options: CreateAnnotatedTagOptions): Promise<string>;
285
+ /** Options for {@link commit}. */
286
+ interface CommitOptions {
287
+ /**
288
+ * Files to add, update, or delete.
289
+ * - `string` values are written as UTF-8 blobs.
290
+ * - `Uint8Array` values are written as raw blobs.
291
+ * - `null` deletes the file from the tree.
292
+ */
293
+ files: Record<string, string | Uint8Array | null>;
294
+ message: string;
295
+ /** Author identity. Accepts `{ name, email, date? }` or full `Identity`. Timestamp defaults to now. */
296
+ author: CommitIdentity;
297
+ /** Committer identity. Defaults to `author` when omitted. */
298
+ committer?: CommitIdentity;
299
+ /** Branch to commit to. Parent is auto-resolved from the current branch tip. */
300
+ branch: string;
301
+ }
302
+ /**
303
+ * Commit files to a branch in one call.
304
+ *
305
+ * Handles blob creation, tree construction, parent resolution, and
306
+ * ref advancement. When the branch already exists, the specified
307
+ * files are applied on top of the existing tree (unmentioned files
308
+ * are preserved). When the branch doesn't exist, a root commit is
309
+ * created with only the specified files.
310
+ *
311
+ * ```ts
312
+ * await commit(repo, {
313
+ * files: { "README.md": "# Hello\n", "src/index.ts": "export {};\n" },
314
+ * message: "initial commit",
315
+ * author: { name: "Alice", email: "alice@example.com" },
316
+ * branch: "main",
317
+ * });
318
+ * ```
319
+ */
320
+ declare function commit(repo: GitRepo, options: CommitOptions): Promise<string>;
229
321
  /** An entry to include in a tree built by {@link writeTree}. */
230
322
  interface TreeEntryInput {
231
323
  /** Filename (not a path — nesting is achieved by including tree entries). */
@@ -246,6 +338,29 @@ declare function writeTree(repo: GitRepo, entries: TreeEntryInput[]): Promise<st
246
338
  * Returns the blob's hash.
247
339
  */
248
340
  declare function writeBlob(repo: GitRepo, content: string): Promise<string>;
341
+ /** A file to add or update in a tree via {@link updateTree}. */
342
+ interface TreeUpdate {
343
+ /** Full repo-relative path (e.g. `"src/lib/foo.ts"`). */
344
+ path: string;
345
+ /** Blob hash. When `null`, the file is removed. */
346
+ hash: string | null;
347
+ /** File mode (default `"100644"`). Ignored when `hash` is `null`. */
348
+ mode?: string;
349
+ }
350
+ /**
351
+ * Apply path-based additions, updates, and deletions to an existing
352
+ * tree, handling nested subtree construction automatically.
353
+ * Returns the new root tree hash.
354
+ *
355
+ * ```ts
356
+ * const blob = await writeBlob(repo, "hello world\n");
357
+ * const newTree = await updateTree(repo, commit.tree, [
358
+ * { path: "src/new-file.ts", hash: blob },
359
+ * { path: "old-file.txt", hash: null },
360
+ * ]);
361
+ * ```
362
+ */
363
+ declare function updateTree(repo: GitRepo, treeHash: string, updates: TreeUpdate[]): Promise<string>;
249
364
 
250
365
  interface MergeConflict {
251
366
  path: string;
@@ -429,4 +544,4 @@ declare function readonlyRepo(repo: GitRepo): GitRepo;
429
544
  */
430
545
  declare function overlayRepo(repo: GitRepo): GitRepo;
431
546
 
432
- export { type BlameEntry, Commit, type CommitInfo, type CreateCommitOptions, type CreateWorktreeOptions, type DiffHunk, type ExtractTreeResult, type FileDiff, type FlatTreeEntry, GitRepo, type GrepFileMatch, type GrepMatch, type GrepOptions, Identity, type MergeConflict, type MergeTreesResult, RefEntry, TreeDiffEntry, type TreeEntryInput, type WorktreeResult, blame, countAheadBehind, createCommit, createSandboxWorktree, createWorktree, diffCommits, diffTrees, extractTree, findMergeBases, flattenTree, getChangedFiles, getNewCommits, grep, isAncestor, listBranches, listTags, mergeTrees, mergeTreesFromTreeHashes, overlayRepo, readBlob, readBlobText, readCommit, readFileAtCommit, readonlyRepo, resolveRef, walkCommitHistory, writeBlob, writeTree };
547
+ export { type BlameEntry, Commit, type CommitAuthor, type CommitIdentity, type CommitInfo, type CommitOptions, type CreateAnnotatedTagOptions, type CreateCommitOptions, type CreateWorktreeOptions, type DiffHunk, type ExtractTreeResult, type FileDiff, type FlatTreeEntry, GitRepo, type GrepFileMatch, type GrepMatch, type GrepOptions, Identity, type MergeConflict, type MergeTreesResult, RefEntry, TreeDiffEntry, TreeEntry, type TreeEntryInput, type TreeUpdate, type WorktreeResult, blame, commit, countAheadBehind, createAnnotatedTag, createCommit, createSandboxWorktree, createWorktree, diffCommits, diffTrees, extractTree, findMergeBases, flattenTree, getChangedFiles, getNewCommits, grep, isAncestor, listBranches, listTags, mergeTrees, mergeTreesFromTreeHashes, overlayRepo, readBlob, readBlobText, readCommit, readFileAtCommit, readTree, readonlyRepo, resolveRef, updateTree, walkCommitHistory, writeBlob, writeTree };