type-git 0.3.0-alpha.0 → 0.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { G as GitErrorCategory, e as ExecOpts, f as RawResult, L as LfsMode, g as GitProgress, h as GitOpenOptions, A as AuditConfig, R as RuntimeAdapters, i as ExecutionContext, j as GitError, E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle } from '../../adapters-BEKkCViX.cjs';
1
+ import { G as GitErrorCategory, e as ExecOpts, f as RawResult, L as LfsMode, g as GitProgress, h as GitOpenOptions, i as EnvInheritance, A as AuditConfig, R as RuntimeAdapters, j as ExecutionContext, k as GitError, E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle } from '../../adapters-sSzx9O1u.cjs';
2
2
 
3
3
  /**
4
4
  * stdout parsing utilities for Git output
@@ -3940,6 +3940,16 @@ type CliRunnerOptions = {
3940
3940
  gitBinary?: string;
3941
3941
  /** Additional environment variables */
3942
3942
  env?: Record<string, string>;
3943
+ /**
3944
+ * Controls how the parent process environment is inherited by spawned Git commands.
3945
+ *
3946
+ * By default, only a curated allowlist of variables that Git needs to operate is
3947
+ * inherited (environment variable traversal prevention); the full parent environment is
3948
+ * NOT forwarded. See {@link EnvInheritance} for all options.
3949
+ *
3950
+ * @default undefined (inherit the default allowlist)
3951
+ */
3952
+ inheritEnv?: EnvInheritance;
3943
3953
  /** Directories to prepend to PATH */
3944
3954
  pathPrefix?: string[];
3945
3955
  /** Custom HOME directory for git config isolation */
@@ -3949,6 +3959,23 @@ type CliRunnerOptions = {
3949
3959
  /** Audit configuration for command tracking and tracing */
3950
3960
  audit?: AuditConfig;
3951
3961
  };
3962
+ /**
3963
+ * Per-call options for {@link CliRunner.run} / {@link CliRunner.runOrThrow}.
3964
+ *
3965
+ * Extends {@link ExecOpts} with an `env` overlay so callers (e.g. the repository
3966
+ * implementations) can inject command-specific environment variables — such as
3967
+ * `GIT_LFS_SKIP_SMUDGE` for an LFS skip-smudge mode. This keeps `env` out of the
3968
+ * public `ExecOpts` / repository operation option types, scoping it to the
3969
+ * runner's own `run` / `runOrThrow` entry points.
3970
+ */
3971
+ type RunOptions = ExecOpts & {
3972
+ /**
3973
+ * Extra environment variables merged on top of the resolved environment for
3974
+ * this single command. Values here take precedence over the configured
3975
+ * environment but do not persist across calls.
3976
+ */
3977
+ env?: Record<string, string>;
3978
+ };
3952
3979
  /**
3953
3980
  * CLI Runner for executing Git commands
3954
3981
  *
@@ -3962,6 +3989,7 @@ declare class CliRunner {
3962
3989
  private readonly exec;
3963
3990
  private readonly gitBinary;
3964
3991
  private readonly baseEnv;
3992
+ private readonly inheritEnv;
3965
3993
  private readonly pathPrefix;
3966
3994
  private readonly home;
3967
3995
  private readonly credential;
@@ -3980,7 +4008,10 @@ declare class CliRunner {
3980
4008
  /**
3981
4009
  * Build the effective environment for command execution
3982
4010
  *
3983
- * Applies home directory and PATH prefix overrides
4011
+ * Seeds the environment from the inherited (allowlisted) parent variables, then layers
4012
+ * the configured `env`, home directory, and PATH prefix overrides on top. The parent
4013
+ * process environment is never forwarded wholesale unless `inheritEnv: true` is set
4014
+ * (environment variable traversal prevention).
3984
4015
  */
3985
4016
  private buildEnv;
3986
4017
  /**
@@ -3990,7 +4021,7 @@ declare class CliRunner {
3990
4021
  /**
3991
4022
  * Run a Git command
3992
4023
  */
3993
- run(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
4024
+ run(context: ExecutionContext, args: string[], opts?: RunOptions): Promise<RawResult>;
3994
4025
  /**
3995
4026
  * Process a single line from stderr for progress and trace callbacks
3996
4027
  */
@@ -4010,7 +4041,7 @@ declare class CliRunner {
4010
4041
  /**
4011
4042
  * Run a command and throw on error
4012
4043
  */
4013
- runOrThrow(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
4044
+ runOrThrow(context: ExecutionContext, args: string[], opts?: RunOptions): Promise<RawResult>;
4014
4045
  }
4015
4046
 
4016
4047
  /**
@@ -1,4 +1,4 @@
1
- import { G as GitErrorCategory, e as ExecOpts, f as RawResult, L as LfsMode, g as GitProgress, h as GitOpenOptions, A as AuditConfig, R as RuntimeAdapters, i as ExecutionContext, j as GitError, E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle } from '../../adapters-BEKkCViX.js';
1
+ import { G as GitErrorCategory, e as ExecOpts, f as RawResult, L as LfsMode, g as GitProgress, h as GitOpenOptions, i as EnvInheritance, A as AuditConfig, R as RuntimeAdapters, j as ExecutionContext, k as GitError, E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle } from '../../adapters-sSzx9O1u.js';
2
2
 
3
3
  /**
4
4
  * stdout parsing utilities for Git output
@@ -3940,6 +3940,16 @@ type CliRunnerOptions = {
3940
3940
  gitBinary?: string;
3941
3941
  /** Additional environment variables */
3942
3942
  env?: Record<string, string>;
3943
+ /**
3944
+ * Controls how the parent process environment is inherited by spawned Git commands.
3945
+ *
3946
+ * By default, only a curated allowlist of variables that Git needs to operate is
3947
+ * inherited (environment variable traversal prevention); the full parent environment is
3948
+ * NOT forwarded. See {@link EnvInheritance} for all options.
3949
+ *
3950
+ * @default undefined (inherit the default allowlist)
3951
+ */
3952
+ inheritEnv?: EnvInheritance;
3943
3953
  /** Directories to prepend to PATH */
3944
3954
  pathPrefix?: string[];
3945
3955
  /** Custom HOME directory for git config isolation */
@@ -3949,6 +3959,23 @@ type CliRunnerOptions = {
3949
3959
  /** Audit configuration for command tracking and tracing */
3950
3960
  audit?: AuditConfig;
3951
3961
  };
3962
+ /**
3963
+ * Per-call options for {@link CliRunner.run} / {@link CliRunner.runOrThrow}.
3964
+ *
3965
+ * Extends {@link ExecOpts} with an `env` overlay so callers (e.g. the repository
3966
+ * implementations) can inject command-specific environment variables — such as
3967
+ * `GIT_LFS_SKIP_SMUDGE` for an LFS skip-smudge mode. This keeps `env` out of the
3968
+ * public `ExecOpts` / repository operation option types, scoping it to the
3969
+ * runner's own `run` / `runOrThrow` entry points.
3970
+ */
3971
+ type RunOptions = ExecOpts & {
3972
+ /**
3973
+ * Extra environment variables merged on top of the resolved environment for
3974
+ * this single command. Values here take precedence over the configured
3975
+ * environment but do not persist across calls.
3976
+ */
3977
+ env?: Record<string, string>;
3978
+ };
3952
3979
  /**
3953
3980
  * CLI Runner for executing Git commands
3954
3981
  *
@@ -3962,6 +3989,7 @@ declare class CliRunner {
3962
3989
  private readonly exec;
3963
3990
  private readonly gitBinary;
3964
3991
  private readonly baseEnv;
3992
+ private readonly inheritEnv;
3965
3993
  private readonly pathPrefix;
3966
3994
  private readonly home;
3967
3995
  private readonly credential;
@@ -3980,7 +4008,10 @@ declare class CliRunner {
3980
4008
  /**
3981
4009
  * Build the effective environment for command execution
3982
4010
  *
3983
- * Applies home directory and PATH prefix overrides
4011
+ * Seeds the environment from the inherited (allowlisted) parent variables, then layers
4012
+ * the configured `env`, home directory, and PATH prefix overrides on top. The parent
4013
+ * process environment is never forwarded wholesale unless `inheritEnv: true` is set
4014
+ * (environment variable traversal prevention).
3984
4015
  */
3985
4016
  private buildEnv;
3986
4017
  /**
@@ -3990,7 +4021,7 @@ declare class CliRunner {
3990
4021
  /**
3991
4022
  * Run a Git command
3992
4023
  */
3993
- run(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
4024
+ run(context: ExecutionContext, args: string[], opts?: RunOptions): Promise<RawResult>;
3994
4025
  /**
3995
4026
  * Process a single line from stderr for progress and trace callbacks
3996
4027
  */
@@ -4010,7 +4041,7 @@ declare class CliRunner {
4010
4041
  /**
4011
4042
  * Run a command and throw on error
4012
4043
  */
4013
- runOrThrow(context: ExecutionContext, args: string[], opts?: ExecOpts): Promise<RawResult>;
4044
+ runOrThrow(context: ExecutionContext, args: string[], opts?: RunOptions): Promise<RawResult>;
4014
4045
  }
4015
4046
 
4016
4047
  /**
@@ -417,6 +417,132 @@ function detectErrorCategory(stderr) {
417
417
 
418
418
  // src/runner/cli-runner.ts
419
419
  import process2 from "process";
420
+
421
+ // src/core/env.ts
422
+ var DEFAULT_ENV_ALLOWLIST = [
423
+ // Executable resolution
424
+ "PATH",
425
+ "PATHEXT",
426
+ // User home / identity
427
+ "HOME",
428
+ "USER",
429
+ "LOGNAME",
430
+ // Locale and time
431
+ "LANG",
432
+ "LANGUAGE",
433
+ "LC_ALL",
434
+ "LC_CTYPE",
435
+ "LC_MESSAGES",
436
+ "LC_NUMERIC",
437
+ "LC_TIME",
438
+ "LC_COLLATE",
439
+ "LC_MONETARY",
440
+ "TZ",
441
+ // Temporary directories
442
+ "TMPDIR",
443
+ "TMP",
444
+ "TEMP",
445
+ // Terminal
446
+ "TERM",
447
+ "COLORTERM",
448
+ // SSH agent (required for Git-over-SSH authentication)
449
+ "SSH_AUTH_SOCK",
450
+ "SSH_AGENT_PID",
451
+ // Git SSH transport and TLS configuration. These are commonly required for
452
+ // fetch/push to keep working under the default allowlist. They are transport
453
+ // configuration rather than credential stores, but note they can still carry
454
+ // sensitive data depending on local setup (e.g. GIT_SSH_COMMAND can name a command
455
+ // Git executes). The most credential-prone / askpass variables (GIT_ASKPASS,
456
+ // SSH_ASKPASS, GIT_PROXY_COMMAND) are intentionally NOT inherited by default — they
457
+ // can carry inline credentials or run a helper that reads secrets from the
458
+ // environment, which would weaken the traversal-prevention model. Opt into those
459
+ // explicitly via `inheritEnv` when needed.
460
+ "GIT_SSH",
461
+ "GIT_SSH_COMMAND",
462
+ "GIT_SSH_VARIANT",
463
+ "GIT_SSL_CAINFO",
464
+ "GIT_SSL_CAPATH",
465
+ "GIT_TERMINAL_PROMPT",
466
+ "GIT_CONFIG_NOSYSTEM",
467
+ // HTTP(S) proxy configuration (required for Git network operations behind a proxy)
468
+ "HTTP_PROXY",
469
+ "HTTPS_PROXY",
470
+ "http_proxy",
471
+ "https_proxy",
472
+ "ALL_PROXY",
473
+ "all_proxy",
474
+ "NO_PROXY",
475
+ "no_proxy",
476
+ // Windows essentials
477
+ "USERPROFILE",
478
+ "HOMEDRIVE",
479
+ "HOMEPATH",
480
+ "APPDATA",
481
+ "LOCALAPPDATA",
482
+ "PROGRAMDATA",
483
+ "ALLUSERSPROFILE",
484
+ "PROGRAMFILES",
485
+ "PROGRAMFILES(X86)",
486
+ "PROGRAMW6432",
487
+ "PUBLIC",
488
+ "SYSTEMROOT",
489
+ "SYSTEMDRIVE",
490
+ "WINDIR",
491
+ "COMSPEC",
492
+ "COMPUTERNAME",
493
+ "USERDOMAIN",
494
+ "NUMBER_OF_PROCESSORS",
495
+ "PROCESSOR_ARCHITECTURE"
496
+ ];
497
+ function pickEnv(parentEnv, predicate) {
498
+ const result = {};
499
+ for (const [key, value] of Object.entries(parentEnv)) {
500
+ if (value !== void 0 && predicate(key)) {
501
+ result[key] = value;
502
+ }
503
+ }
504
+ return result;
505
+ }
506
+ function buildAllowlist(inheritEnv) {
507
+ const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
508
+ if (Array.isArray(inheritEnv)) {
509
+ for (const name of inheritEnv) {
510
+ allow.add(name);
511
+ }
512
+ return { allow, remove: void 0 };
513
+ }
514
+ if (inheritEnv === false) {
515
+ return { allow, remove: void 0 };
516
+ }
517
+ for (const name of inheritEnv.add ?? []) {
518
+ allow.add(name);
519
+ }
520
+ const hasRemove = inheritEnv.remove !== void 0 && inheritEnv.remove.length > 0;
521
+ const remove = hasRemove ? new Set(inheritEnv.remove) : void 0;
522
+ return { allow, remove };
523
+ }
524
+ function makeNameMatcher(names, isWindows) {
525
+ if (!isWindows) {
526
+ return (name) => names.has(name);
527
+ }
528
+ const lower = new Set([...names].map((name) => name.toLowerCase()));
529
+ return (name) => lower.has(name.toLowerCase());
530
+ }
531
+ function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
532
+ if (inheritEnv === true) {
533
+ return pickEnv(parentEnv, () => true);
534
+ }
535
+ if (typeof inheritEnv === "function") {
536
+ return pickEnv(parentEnv, inheritEnv);
537
+ }
538
+ const { allow, remove } = buildAllowlist(inheritEnv ?? []);
539
+ const isWindows = platform === "win32";
540
+ const isAllowed = makeNameMatcher(allow, isWindows);
541
+ const isRemoved = remove ? makeNameMatcher(remove, isWindows) : () => false;
542
+ return pickEnv(parentEnv, (name) => isAllowed(name) && !isRemoved(name));
543
+ }
544
+
545
+ // src/runner/cli-runner.ts
420
546
  var FATAL_ERROR_PATTERN = /fatal:\s*(.+)/i;
421
547
  var ERROR_PATTERN = /error:\s*(.+)/i;
422
548
  var LINE_SEPARATOR_PATTERN = /\r|\n/;
@@ -470,6 +596,7 @@ var CliRunner = class _CliRunner {
470
596
  exec;
471
597
  gitBinary;
472
598
  baseEnv;
599
+ inheritEnv;
473
600
  pathPrefix;
474
601
  home;
475
602
  credential;
@@ -478,6 +605,7 @@ var CliRunner = class _CliRunner {
478
605
  this.exec = adapters.exec;
479
606
  this.gitBinary = options?.gitBinary ?? "git";
480
607
  this.baseEnv = options?.env ?? {};
608
+ this.inheritEnv = options?.inheritEnv;
481
609
  this.pathPrefix = options?.pathPrefix ?? [];
482
610
  this.home = options?.home;
483
611
  this.credential = options?.credential;
@@ -491,6 +619,7 @@ var CliRunner = class _CliRunner {
491
619
  withOptions(options) {
492
620
  const mergedEnv = { ...this.baseEnv, ...options.env };
493
621
  const mergedPathPrefix = [...this.pathPrefix, ...options.pathPrefix ?? []];
622
+ const inheritEnv = options.inheritEnv ?? this.inheritEnv;
494
623
  const home = options.home ?? this.home;
495
624
  const credential = options.credential ?? this.credential;
496
625
  const audit = options.audit ?? this.audit;
@@ -508,6 +637,7 @@ var CliRunner = class _CliRunner {
508
637
  {
509
638
  gitBinary: options.gitBinary ?? this.gitBinary,
510
639
  env: mergedEnv,
640
+ inheritEnv,
511
641
  pathPrefix: mergedPathPrefix,
512
642
  home,
513
643
  credential,
@@ -539,10 +669,16 @@ var CliRunner = class _CliRunner {
539
669
  /**
540
670
  * Build the effective environment for command execution
541
671
  *
542
- * Applies home directory and PATH prefix overrides
672
+ * Seeds the environment from the inherited (allowlisted) parent variables, then layers
673
+ * the configured `env`, home directory, and PATH prefix overrides on top. The parent
674
+ * process environment is never forwarded wholesale unless `inheritEnv: true` is set
675
+ * (environment variable traversal prevention).
543
676
  */
544
677
  buildEnv() {
545
- const env = { ...this.baseEnv };
678
+ const env = {
679
+ ...resolveInheritedEnv(process2.env, this.inheritEnv, process2.platform),
680
+ ...this.baseEnv
681
+ };
546
682
  if (this.home) {
547
683
  env.HOME = this.home;
548
684
  env.USERPROFILE = this.home;
@@ -555,9 +691,11 @@ var CliRunner = class _CliRunner {
555
691
  }
556
692
  }
557
693
  if (allPathPrefixes.length > 0) {
558
- const separator = process2.platform === "win32" ? ";" : ":";
559
- const currentPath = process2.env.PATH ?? "";
560
- env.PATH = [...allPathPrefixes, currentPath].join(separator);
694
+ const isWindows = process2.platform === "win32";
695
+ const separator = isWindows ? ";" : ":";
696
+ const pathKey = isWindows ? Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "PATH" : "PATH";
697
+ const currentPath = env[pathKey] ?? "";
698
+ env[pathKey] = [...allPathPrefixes, currentPath].join(separator);
561
699
  }
562
700
  if (this.audit?.onTrace) {
563
701
  if (env.GIT_TRACE === void 0) {
@@ -586,8 +724,11 @@ var CliRunner = class _CliRunner {
586
724
  */
587
725
  async run(context, args, opts) {
588
726
  const argv = this.buildArgv(context, args);
589
- const { signal, onProgress, onLfsProgress } = opts ?? {};
727
+ const { signal, onProgress, onLfsProgress, env: envOverride } = opts ?? {};
590
728
  const env = this.buildEnv();
729
+ if (envOverride) {
730
+ Object.assign(env, envOverride);
731
+ }
591
732
  if (onLfsProgress) {
592
733
  env.GIT_LFS_FORCE_PROGRESS = "1";
593
734
  }
@@ -608,6 +749,9 @@ var CliRunner = class _CliRunner {
608
749
  {
609
750
  argv,
610
751
  env,
752
+ // The env above is already fully resolved (including any inherited variables),
753
+ // so the adapter must not merge the parent environment on top of it.
754
+ inheritEnv: false,
611
755
  cwd: context.type === "worktree" ? context.workdir : void 0,
612
756
  signal
613
757
  },
@@ -1152,7 +1296,7 @@ var BareRepoImpl = class {
1152
1296
  */
1153
1297
  async push(opts) {
1154
1298
  const args = ["push"];
1155
- if (opts?.onProgress) {
1299
+ if (opts?.onProgress || opts?.onLfsProgress) {
1156
1300
  args.push("--progress");
1157
1301
  }
1158
1302
  if (opts?.force) {
@@ -2050,7 +2194,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2050
2194
  */
2051
2195
  async push(opts) {
2052
2196
  const args = ["push"];
2053
- if (opts?.onProgress) {
2197
+ if (opts?.onProgress || opts?.onLfsProgress) {
2054
2198
  args.push("--progress");
2055
2199
  }
2056
2200
  if (opts?.verbose) {
@@ -2155,6 +2299,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2155
2299
  setLfsMode(mode) {
2156
2300
  this._lfsMode = mode;
2157
2301
  }
2302
+ /**
2303
+ * Per-command environment overrides derived from the configured LFS mode.
2304
+ *
2305
+ * When the repository was opened (or reconfigured) with an object-form LFS
2306
+ * mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
2307
+ * operations (checkout, switch, reset, merge, pull, rebase, restore) run with
2308
+ * `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
2309
+ * of downloading their contents during the implicit checkout.
2310
+ *
2311
+ * The objects can be materialized later via the explicit `repo.lfs.pull()` /
2312
+ * `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
2313
+ * not affected by `GIT_LFS_SKIP_SMUDGE`.
2314
+ *
2315
+ * Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
2316
+ * runner environment is left untouched.
2317
+ */
2318
+ lfsModeEnv() {
2319
+ const mode = this._lfsMode;
2320
+ if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
2321
+ return { GIT_LFS_SKIP_SMUDGE: "1" };
2322
+ }
2323
+ return void 0;
2324
+ }
2158
2325
  // ==========================================================================
2159
2326
  // LFS Operations
2160
2327
  // ==========================================================================
@@ -2177,7 +2344,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2177
2344
  }
2178
2345
  await this.runner.runOrThrow(this.context, args, {
2179
2346
  signal: opts?.signal,
2180
- onProgress: opts?.onProgress
2347
+ onProgress: opts?.onProgress,
2348
+ onLfsProgress: opts?.onLfsProgress
2181
2349
  });
2182
2350
  }
2183
2351
  async lfsPush(opts) {
@@ -2206,7 +2374,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2206
2374
  }
2207
2375
  await this.runner.runOrThrow(this.context, args, {
2208
2376
  signal: opts?.signal,
2209
- onProgress: opts?.onProgress
2377
+ onProgress: opts?.onProgress,
2378
+ onLfsProgress: opts?.onLfsProgress
2210
2379
  });
2211
2380
  }
2212
2381
  async lfsStatus(opts) {
@@ -2289,7 +2458,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2289
2458
  const args = ["lfs", "push", remote, "--object-id", ...batch];
2290
2459
  const result = await this.runner.run(this.context, args, {
2291
2460
  signal: opts?.signal,
2292
- onProgress: opts?.onProgress
2461
+ onProgress: opts?.onProgress,
2462
+ onLfsProgress: opts?.onLfsProgress
2293
2463
  });
2294
2464
  if (result.exitCode === 0) {
2295
2465
  uploadedCount += batch.length;
@@ -2366,7 +2536,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2366
2536
  const args = ["lfs", "fetch", remote, "--", ...batch];
2367
2537
  const result = await this.runner.run(this.context, args, {
2368
2538
  signal: opts?.signal,
2369
- onProgress: opts?.onProgress
2539
+ onProgress: opts?.onProgress,
2540
+ onLfsProgress: opts?.onLfsProgress
2370
2541
  });
2371
2542
  if (result.exitCode === 0) {
2372
2543
  downloadedCount += batch.length;
@@ -2431,7 +2602,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2431
2602
  return;
2432
2603
  }
2433
2604
  const args = ["lfs", "fetch"];
2434
- if (opts?.onProgress) {
2605
+ if (opts?.onProgress || opts?.onLfsProgress) {
2435
2606
  args.push("--progress");
2436
2607
  }
2437
2608
  if (opts?.all) {
@@ -2464,7 +2635,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2464
2635
  }
2465
2636
  await this.runner.runOrThrow(this.context, args, {
2466
2637
  signal: opts?.signal,
2467
- onProgress: opts?.onProgress
2638
+ onProgress: opts?.onProgress,
2639
+ onLfsProgress: opts?.onLfsProgress
2468
2640
  });
2469
2641
  }
2470
2642
  async lfsInstall(opts) {
@@ -3226,7 +3398,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3226
3398
  }
3227
3399
  }
3228
3400
  await this.runner.runOrThrow(this.context, args, {
3229
- signal: opts?.signal
3401
+ signal: opts?.signal,
3402
+ env: this.lfsModeEnv()
3230
3403
  });
3231
3404
  }
3232
3405
  // ==========================================================================
@@ -3583,7 +3756,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3583
3756
  }
3584
3757
  args.push(branch);
3585
3758
  const result = await this.runner.run(this.context, args, {
3586
- signal: opts?.signal
3759
+ signal: opts?.signal,
3760
+ env: this.lfsModeEnv()
3587
3761
  });
3588
3762
  if (result.exitCode !== 0) {
3589
3763
  const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
@@ -3612,7 +3786,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3612
3786
  // ==========================================================================
3613
3787
  async pull(opts) {
3614
3788
  const args = ["pull"];
3615
- if (opts?.onProgress) {
3789
+ if (opts?.onProgress || opts?.onLfsProgress) {
3616
3790
  args.push("--progress");
3617
3791
  }
3618
3792
  if (opts?.rebase === true) {
@@ -3760,7 +3934,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3760
3934
  }
3761
3935
  await this.runner.runOrThrow(this.context, args, {
3762
3936
  signal: opts?.signal,
3763
- onProgress: opts?.onProgress
3937
+ onProgress: opts?.onProgress,
3938
+ onLfsProgress: opts?.onLfsProgress,
3939
+ env: this.lfsModeEnv()
3764
3940
  });
3765
3941
  }
3766
3942
  // ==========================================================================
@@ -3790,7 +3966,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3790
3966
  args.push(target);
3791
3967
  }
3792
3968
  await this.runner.runOrThrow(this.context, args, {
3793
- signal: opts?.signal
3969
+ signal: opts?.signal,
3970
+ env: this.lfsModeEnv()
3794
3971
  });
3795
3972
  }
3796
3973
  // ==========================================================================
@@ -3986,7 +4163,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3986
4163
  args.push(opts.startPoint);
3987
4164
  }
3988
4165
  await this.runner.runOrThrow(this.context, args, {
3989
- signal: opts?.signal
4166
+ signal: opts?.signal,
4167
+ env: this.lfsModeEnv()
3990
4168
  });
3991
4169
  }
3992
4170
  // ==========================================================================
@@ -4413,7 +4591,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4413
4591
  args.push(opts.upstream);
4414
4592
  }
4415
4593
  await this.runner.runOrThrow(this.context, args, {
4416
- signal: opts?.signal
4594
+ signal: opts?.signal,
4595
+ env: this.lfsModeEnv()
4417
4596
  });
4418
4597
  }
4419
4598
  // ==========================================================================
@@ -4471,7 +4650,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4471
4650
  const pathList = Array.isArray(paths) ? paths : [paths];
4472
4651
  args.push("--", ...pathList);
4473
4652
  await this.runner.runOrThrow(this.context, args, {
4474
- signal: opts?.signal
4653
+ signal: opts?.signal,
4654
+ env: this.lfsModeEnv()
4475
4655
  });
4476
4656
  }
4477
4657
  // ==========================================================================
@@ -5382,6 +5562,7 @@ function toCliRunnerOptions(opts) {
5382
5562
  }
5383
5563
  return {
5384
5564
  env: opts.env,
5565
+ inheritEnv: opts.inheritEnv,
5385
5566
  pathPrefix: opts.pathPrefix,
5386
5567
  home: opts.home,
5387
5568
  credential: opts.credential ? {
@@ -5483,7 +5664,7 @@ var GitImpl = class {
5483
5664
  }
5484
5665
  async clone(url, path, opts) {
5485
5666
  const args = buildCloneArgs(opts);
5486
- if (opts?.onProgress) {
5667
+ if (opts?.onProgress || opts?.onLfsProgress) {
5487
5668
  args.push("--progress");
5488
5669
  }
5489
5670
  args.push(url, path);
@@ -5825,6 +6006,12 @@ async function createGit(options) {
5825
6006
 
5826
6007
  // src/adapters/node/exec.ts
5827
6008
  import { spawn } from "child_process";
6009
+ function resolveChildEnv(env, inheritEnv) {
6010
+ if (inheritEnv === false) {
6011
+ return env ?? {};
6012
+ }
6013
+ return env ? { ...process.env, ...env } : process.env;
6014
+ }
5828
6015
  async function* streamToAsyncIterable(stream) {
5829
6016
  let buffer = "";
5830
6017
  for await (const chunk of stream) {
@@ -5851,7 +6038,7 @@ var NodeExecAdapter = class {
5851
6038
  };
5852
6039
  }
5853
6040
  spawn(options, handlers) {
5854
- const { argv, env, cwd, signal } = options;
6041
+ const { argv, env, inheritEnv, cwd, signal } = options;
5855
6042
  const command = argv[0];
5856
6043
  if (command === void 0) {
5857
6044
  throw new Error("argv must not be empty");
@@ -5860,7 +6047,7 @@ var NodeExecAdapter = class {
5860
6047
  return new Promise((resolve, reject) => {
5861
6048
  const child = spawn(command, args, {
5862
6049
  cwd,
5863
- env: env ? { ...process.env, ...env } : process.env,
6050
+ env: resolveChildEnv(env, inheritEnv),
5864
6051
  stdio: ["ignore", "pipe", "pipe"]
5865
6052
  });
5866
6053
  let stdout = "";
@@ -5908,7 +6095,7 @@ var NodeExecAdapter = class {
5908
6095
  });
5909
6096
  }
5910
6097
  spawnStreaming(options) {
5911
- const { argv, env, cwd, signal } = options;
6098
+ const { argv, env, inheritEnv, cwd, signal } = options;
5912
6099
  const command = argv[0];
5913
6100
  if (command === void 0) {
5914
6101
  throw new Error("argv must not be empty");
@@ -5916,7 +6103,7 @@ var NodeExecAdapter = class {
5916
6103
  const args = argv.slice(1);
5917
6104
  const child = spawn(command, args, {
5918
6105
  cwd,
5919
- env: env ? { ...process.env, ...env } : process.env,
6106
+ env: resolveChildEnv(env, inheritEnv),
5920
6107
  stdio: ["ignore", "pipe", "pipe"]
5921
6108
  });
5922
6109
  let aborted = false;