Skip to main content

git_policy_cli/transaction/
transaction_git.rs

1//! What:
2//!  Running real Git for transaction,
3//!  recovery and landing work:
4//!  captured output,
5//!  an
6//!       optional private index and object store,
7//!  extra or removed variables,
8//!  and bytes on
9//!       standard input.
10//! Why:
11//!  Every transaction step asks Git a question or writes an object;
12//!  one runner keeps every
13//!      such start an argument array (never a shell string) carrying the wrapper's child
14//!      environment overlay (lock PID injection),
15//!  as the incumbent's `runTransactionGit` does.
16//!
17//! In TS you'd write (pseudocode):
18//! ```ts
19//! const { stdout } = await runTransactionGit({ gitPath, cwd, args, indexPath, input });
20//! ```
21
22/// Building a Git child from an argument array and an overlay.
23use crate::forwarding::git_command;
24use crate::repo_read_hook::try_request;
25/// The watched run that announces a step that takes long and stops it at the bound.
26use crate::child_class::{ChildClass, class_of};
27use crate::child_watch::{WatchTerms, output_watched_within};
28use crate::wait_ceilings::{OBJECT_STEP_CEILING, PLUMBING_STEP_CEILING, REFERENCE_STEP_CEILING};
29/// Private exclusive files for standard input.
30use crate::private_storage::write_exclusive_scratch;
31/// The repository scratch directory the input file is made in.
32use crate::scratch_location::prepare_repository_scratch;
33/// Starts that ride out a short shortage of processes.
34use crate::start_retry::{START_RETRY_BUDGET, retry_refused_start_with};
35/// Unique temporary names.
36use crate::random_id::random_uuid;
37/// `OsStr`/`OsString` are borrowed/owned operating-system text of raw bytes.
38use std::ffi::{OsStr, OsString};
39/// `Path`/`PathBuf` are borrowed/owned filesystem paths.
40use std::path::{Path, PathBuf};
41/// `Command` builds a child process;
42///  `Stdio` configures its streams.
43use std::io::Write;
44use std::process::{Command, Stdio};
45/// A span of time, for the bounded rerun.
46use std::time::Duration;
47
48/// What:
49///  The real Git executable and the variables every Git child receives.
50/// Why:
51///   Transaction code is handed this once and starts every Git through it.
52///
53/// In TS you'd write (pseudocode):
54/// ```ts
55/// type GitContext = { gitPath: string; overlay: [string, string][] };
56/// ```
57#[derive(Clone, Debug, Eq, PartialEq)]
58pub struct GitContext {
59    /// Absolute real Git executable.
60    pub real_git: PathBuf,
61    /// Variables added to every child:
62    ///  lock PID injection and the forward-target marker.
63    pub overlay: Vec<(OsString, OsString)>,
64    /// Global options of the invocation,
65    ///  kept before every subcommand (`-C`,
66    ///  `--git-dir`,
67    ///  `-c`).
68    pub global_prefix: Vec<OsString>,
69    /// The repository's common Git directory,
70    ///  where the input file of a request that carries input is made (`cli-git-scratch` inside it);
71    ///  `None` where the repository is not yet known,
72    ///  and a request with input then fails naming the defect.
73    pub common_dir: Option<PathBuf>,
74}
75
76/// What:
77///  One Git start:
78///  where it runs,
79///  its arguments after the global prefix,
80///  and its
81///       environment and input adjustments.
82/// Why:
83///   A builder keeps call sites short while every option stays explicit.
84///
85/// In TS you'd write (pseudocode):
86/// ```ts
87/// type GitRequest = { cwd: string; args: string[]; indexPath?: string; objectDirectory?: string; environment?: Record<string, string>; unset?: string[]; input?: Uint8Array };
88/// ```
89#[derive(Clone, Debug, Default)]
90pub struct GitRequest {
91    /// Working directory.
92    pub cwd: PathBuf,
93    /// Arguments after the global prefix.
94    pub arguments: Vec<OsString>,
95    /// Whether the invocation's global prefix is left out (shadow and private-store commands).
96    pub without_prefix: bool,
97    /// Private index,
98    ///  as `GIT_INDEX_FILE`.
99    pub index: Option<PathBuf>,
100    /// Object store receiving every written object,
101    ///  as `GIT_OBJECT_DIRECTORY`.
102    pub object_directory: Option<PathBuf>,
103    /// Variables added after the overlay.
104    pub environment: Vec<(OsString, OsString)>,
105    /// Inherited variables removed before the additions apply.
106    pub unset: Vec<OsString>,
107    /// Bytes on standard input;
108    ///  none means an empty input.
109    pub input: Option<Vec<u8>>,
110}
111
112/// Builder methods for one request.
113impl GitRequest {
114    /// What:
115    ///  A request running `arguments` in `cwd`.
116    /// Why:
117    ///   Most requests need nothing else.
118    ///
119    /// In TS you'd write (pseudocode):
120    /// ```ts
121    /// { cwd, args }
122    /// ```
123    pub fn new<S: AsRef<OsStr>>(cwd: &Path, arguments: &[S]) -> Self {
124        // `mut` allows collecting the arguments one at a time.
125        let mut owned: Vec<OsString> = Vec::with_capacity(arguments.len());
126        for argument in arguments {
127            owned.push(argument.as_ref().to_os_string());
128        }
129        return Self {
130            cwd: cwd.to_path_buf(),
131            arguments: owned,
132            ..Self::default()
133        };
134    }
135}
136
137/// What:
138///  How one Git start ended and what it wrote.
139/// Why:
140///   Callers decide on the exit code and parse standard output as bytes.
141///
142/// In TS you'd write (pseudocode):
143/// ```ts
144/// type GitOutput = { stdout: Uint8Array; stderr: string; exitCode: number };
145/// ```
146#[derive(Clone, Debug, Eq, PartialEq)]
147pub struct GitOutput {
148    /// Exit code;
149    ///  `None` when a signal ended Git.
150    pub code: Option<i32>,
151    /// Standard output bytes.
152    pub stdout: Vec<u8>,
153    /// Standard error bytes.
154    pub stderr: Vec<u8>,
155}
156
157/// Methods over a finished Git start.
158impl GitOutput {
159    /// What:
160    ///  Whether Git exited with status 0.
161    /// Why:
162    ///   Most callers only need success or failure.
163    ///
164    /// In TS you'd write (pseudocode):
165    /// ```ts
166    /// output.exitCode === 0
167    /// ```
168    pub fn succeeded(&self) -> bool {
169        return self.code == Some(0);
170    }
171
172    /// What:
173    ///  Standard error as trimmed,
174    ///  lossily decoded text for diagnostics.
175    /// Why:
176    ///   Failure messages quote what Git said.
177    ///
178    /// In TS you'd write (pseudocode):
179    /// ```ts
180    /// output.stderr.trim()
181    /// ```
182    pub fn error_text(&self) -> String {
183        return String::from_utf8_lossy(self.stderr.as_slice())
184            .trim()
185            .to_string();
186    }
187}
188
189/// What:
190///  Why a Git start failed.
191/// Why:
192///   A start that could not happen and a Git that exited unsuccessfully are reported with
193///       the command named,
194///  as `CommitTransactionGitError`.
195///
196/// In TS you'd write (pseudocode):
197/// ```ts
198/// class CommitTransactionGitError extends Error {}
199/// ```
200#[derive(Clone, Debug, Eq, PartialEq)]
201pub struct GitFailure(pub String);
202
203/// What:
204///  The failure message as display text.
205/// Why:
206///   Diagnostics print it unchanged.
207///
208/// In TS you'd write (pseudocode):
209/// ```ts
210/// error.message
211/// ```
212impl std::fmt::Display for GitFailure {
213    /// Writes the message.
214    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
215        return formatter.write_str(self.0.as_str());
216    }
217}
218
219/// What:
220///  The arguments of a request as display text,
221///  `git <arguments>`.
222/// Why:
223///   Failure messages name the command.
224///
225/// In TS you'd write (pseudocode):
226/// ```ts
227/// `git ${args.join(' ')}`
228/// ```
229pub fn command_text(arguments: &[OsString]) -> String {
230    let mut text: String = String::from("git");
231    for argument in arguments {
232        text.push(' ');
233        text.push_str(argument.to_string_lossy().as_ref());
234    }
235    return text;
236}
237
238/// What:
239///  An already unlinked private file holding `bytes`,
240///  opened for reading.
241///  The file is made in the repository scratch directory of `common_dir`,
242///  never in the system temporary directory.
243/// Why:
244///   Git may write output before it reads all its input;
245///  feeding input from a file instead
246///       of a pipe can never deadlock and needs no writer thread.
247///  The name is removed at once,
248///       so nothing is left behind even after a crash,
249///  and a crash inside that moment leaves a file that the next preparation of the directory
250///       sweeps once it is a day old.
251///
252/// In TS you'd write (pseudocode):
253/// ```ts
254/// // child.stdin.end(input);
255/// ```
256fn input_file(bytes: &[u8], common_dir: Option<&Path>) -> std::io::Result<std::fs::File> {
257    let Some(common) = common_dir else {
258        return Err(std::io::Error::other(
259            "cli-git has no repository scratch directory for the input of this Git command: the command was started \
260             before the repository was known, which is a defect in cli-git",
261        ));
262    };
263    let directory: PathBuf = prepare_repository_scratch(common)?;
264    let unique: String = match random_uuid() {
265        Ok(id) => id,
266        Err(error) => return Err(std::io::Error::other(error.0)),
267    };
268    let path: PathBuf = directory.join(format!("cli-git-input-{unique}"));
269    write_exclusive_scratch(path.as_path(), bytes)?;
270    let file: std::io::Result<std::fs::File> = std::fs::File::open(&path);
271    // The open handle keeps the bytes readable after the name is gone. If the platform refuses
272    // to remove an open file, the private file stays behind and the error is ignored.
273    let _ = std::fs::remove_file(&path);
274    let opened: std::fs::File = file?;
275    return Ok(opened);
276}
277
278/// What:
279///  Build the child command for one request.
280/// Why:
281///   The prefix,
282///  the overlay,
283///  the removals and the additions apply in a fixed order.
284///
285/// In TS you'd write (pseudocode):
286/// ```ts
287/// spawn(gitPath, args, { cwd, env: { ...withoutUnset(process.env), ...environment, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY } })
288/// ```
289fn build_command(context: &GitContext, request: &GitRequest) -> Command {
290    // `mut` allows assembling the argument list in order.
291    let mut arguments: Vec<OsString> = Vec::new();
292    if !request.without_prefix {
293        arguments.extend(context.global_prefix.iter().cloned());
294    }
295    arguments.extend(request.arguments.iter().cloned());
296    let mut command: Command = git_command(
297        context.real_git.as_path(),
298        arguments.as_slice(),
299        context.overlay.as_slice(),
300    );
301    command.current_dir(request.cwd.as_path());
302    for name in &request.unset {
303        command.env_remove(name);
304    }
305    for (name, value) in &request.environment {
306        command.env(name, value);
307    }
308    if let Some(index) = &request.index {
309        command.env("GIT_INDEX_FILE", index);
310    }
311    if let Some(objects) = &request.object_directory {
312        command.env("GIT_OBJECT_DIRECTORY", objects);
313    }
314    return command;
315}
316
317/// What:
318///  Run one request and capture its output,
319///  whatever its exit code.
320///       `std::io::Result<GitOutput>` is "the outcome,
321///  or why Git could not start".
322/// Why:
323///   Callers that treat a non-zero exit as an answer (a conflict,
324///  a missing ref) read the
325///       code themselves.
326///
327/// In TS you'd write (pseudocode):
328/// ```ts
329/// await runTransactionGit({ ..., allowFailure: true })
330/// ```
331pub fn run_git(context: &GitContext, request: &GitRequest) -> std::io::Result<GitOutput> {
332    // An exact read-only command line the in-process readers know costs no Git process.
333    if let Some(answered) = try_request(context, request) {
334        return Ok(answered);
335    }
336    let label: String = crate::add_timing::git_step_label(request.arguments.as_slice());
337    return crate::add_timing::step(label.as_str(), || { return run_git_pausing(context, request, START_RETRY_BUDGET, &mut |wait: Duration| { std::thread::sleep(wait); }); });
338}
339
340/// Commands whose second run after a refusal is harmless: they read, or they write content-addressed objects,
341///  or they set the same value again.
342const RERUNNABLE: [&str; 17] = [
343    "rev-parse",
344    "symbolic-ref",
345    "for-each-ref",
346    "ls-files",
347    "diff",
348    "diff-index",
349    "diff-tree",
350    "cat-file",
351    "show",
352    "hash-object",
353    "write-tree",
354    "ls-remote",
355    "merge-tree",
356    "init",
357    "pack-objects",
358    "index-pack",
359    "version",
360];
361
362/// What:
363///  The subcommand a request runs and where it sits among the arguments,
364///  past the global options (`-c <pair>`, `-C <directory>` and the `--option` forms).
365/// Why:
366///   The rerun allow-list is decided by the subcommand and, for a few, by its options.
367///
368/// In TS you'd write (pseudocode):
369/// ```ts
370/// const index = args.findIndex(...); // first token that is not a global option or its value
371/// ```
372pub(crate) fn subcommand_of(arguments: &[OsString]) -> Option<(usize, String)> {
373    let mut index: usize = 0;
374    while index < arguments.len() {
375        let text: String = arguments[index].to_string_lossy().into_owned();
376        if text == "-c" || text == "-C" {
377            index += 2;
378            continue;
379        }
380        if text.starts_with('-') {
381            index += 1;
382            continue;
383        }
384        return Some((index, text));
385    }
386    return None;
387}
388
389/// What:
390///  Whether running the request a second time after the system refused it is harmless.
391/// Why:
392///   Git reports a refused process or thread as a failure after it started,
393///  so only commands that read, write content-addressed objects, or change a private index the same way twice
394///  may be run again;
395///  reference updates, commits and every other writer are not,
396///  and recovery already completes or rolls those back.
397///
398/// In TS you'd write (pseudocode):
399/// ```ts
400/// RERUNNABLE.includes(subcommand) || (subcommand === 'config' && reads(args)) || ...
401/// ```
402fn may_be_rerun(request: &GitRequest) -> bool {
403    let Some((position, name)) = subcommand_of(request.arguments.as_slice()) else {
404        return false;
405    };
406    let rest: Vec<String> = request.arguments[position + 1..]
407        .iter()
408        .map(|argument| { return argument.to_string_lossy().into_owned(); })
409        .collect();
410    match name.as_str() {
411        "config" => return rest.iter().any(|option| {
412            return matches!(option.as_str(), "--get" | "--get-all" | "--get-regexp" | "--list" | "-l");
413        }),
414        "remote" => return rest.first().is_some_and(|word| { return word == "get-url"; }),
415        "add" | "reset" | "read-tree" | "update-index" => return request.index.is_some(),
416        other => return RERUNNABLE.contains(&other),
417    }
418}
419
420/// What:
421///  Whether Git failed because the system would not give it a process or a thread.
422/// Why:
423///   Git words these failures with the system's own text (`unable to create thread: Resource temporarily
424///  unavailable`, `cannot fork() for ...`), and no other failure of a rerunnable command carries it.
425///
426/// In TS you'd write (pseudocode):
427/// ```ts
428/// output.exitCode !== 0 && output.stderr.includes('Resource temporarily unavailable')
429/// ```
430fn refused_by_the_system(output: &GitOutput) -> bool {
431    return output.code != Some(0)
432        && String::from_utf8_lossy(output.stderr.as_slice()).contains("Resource temporarily unavailable");
433}
434
435/// What:
436///  Run one request, running it again within the budget when Git reports a refused process or thread
437///  and the command is harmless to run twice.
438///  After the budget the last output is returned as it was, so the caller reports Git's own words.
439/// Why:
440///   The command is rebuilt for each run, so its input file is fresh.
441///  A start that already waited out its own budget is not waited for again.
442///
443/// In TS you'd write (pseudocode):
444/// ```ts
445/// await retryWhile(() => runGitOnce(request), (output) => refusedBySystem(output) && mayBeRerun(request));
446/// ```
447fn run_git_pausing(
448    context: &GitContext,
449    request: &GitRequest,
450    budget: Duration,
451    pause: &mut dyn FnMut(Duration),
452) -> std::io::Result<GitOutput> {
453    if !may_be_rerun(request) {
454        return run_git_once(context, request);
455    }
456    let what: String = command_text(&request.arguments);
457    let mut refused: Option<GitOutput> = None;
458    let result: std::io::Result<GitOutput> = retry_refused_start_with(what.as_str(), budget, pause, &mut || {
459        let output: GitOutput = match run_git_once(context, request) {
460            Ok(finished) => finished,
461            Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => return Err(std::io::Error::other(error)),
462            Err(error) => return Err(error),
463        };
464        if refused_by_the_system(&output) {
465            refused = Some(output);
466            return Err(std::io::Error::from(std::io::ErrorKind::WouldBlock));
467        }
468        return Ok(output);
469    });
470    match (result, refused.take()) {
471        (Ok(finished), _) => return Ok(finished),
472        (Err(error), Some(last)) if error.kind() == std::io::ErrorKind::WouldBlock => return Ok(last),
473        (Err(error), _) => return Err(error),
474    }
475}
476
477/// What:
478///  Run one request once and capture its output, whatever its exit code.
479/// Why:
480///   The command and its input file are built here, so every run starts from the request alone.
481///
482/// In TS you'd write (pseudocode):
483/// ```ts
484/// await runTransactionGitOnce({ gitPath, cwd, args })
485/// ```
486fn run_git_once(context: &GitContext, request: &GitRequest) -> std::io::Result<GitOutput> {
487    return run_git_once_with(context, request, &|| { return terms_for_request(request); });
488}
489
490/// What:
491///  The watch terms of a request: those of the class its subcommand belongs to.
492/// Why:
493///   A query step and a bulk step are stopped at different bounds, so the choice is one function a test can pin.
494///
495/// In TS you'd write (pseudocode):
496/// ```ts
497/// termsForClass(classOf(request.args))
498/// ```
499pub(crate) fn terms_for_request(request: &GitRequest) -> WatchTerms {
500    return WatchTerms::for_class(class_of(request.arguments.as_slice()));
501}
502
503/// What:
504///  `run_git_once` with the notice cadence, the quiet window and the notice sink of its wait made by `terms`, which is asked
505///  for again at each start.
506///  A step that shows no sign of work for the window is ended and run once more; a step that may not be run twice is only
507///  waited for.
508/// Why:
509///   The production entry reads the terms from the environment;
510///  tests choose short ones and read the notices from a buffer.
511///  The owner's rule: "End Git, hold hooks (Recommended)": a Git child with no progress is ended and its step redone, and a
512///  person's hook is never ended (none runs below a step the wrapper starts, `hooks_off.rs`). Redoing is limited to the steps
513///  that are safe to run twice (`may_be_rerun`); a step that is quiet again in its redo is reported with the sentence of
514///  `watched_timeout_text`. That the redo happens once is the coordinator's reading of "redone" (audit, pick 4), open to veto.
515///
516/// In TS you'd write (pseudocode):
517/// ```ts
518/// try { return await runOnce(terms()); } catch (quiet) { if (!mayBeRerun(request)) throw quiet; return await runOnce(terms()); }
519/// ```
520fn run_git_once_with(
521    context: &GitContext,
522    request: &GitRequest,
523    terms: &dyn Fn() -> WatchTerms,
524) -> std::io::Result<GitOutput> {
525    let first: std::io::Result<GitOutput> = run_git_watched(context, request, terms());
526    return match first {
527        Err(error) if error.kind() == std::io::ErrorKind::TimedOut && may_be_rerun(request) && !crate::child_watch::is_ceiling(&error) => {
528            // Terminal output error: a notice is advisory; a failed write must not stop the commit.
529            let _written = writeln!(
530                std::io::stderr(),
531                "cli-git: {} showed no sign of work and was ended; running it again",
532                step_subject(request)
533            );
534            run_git_watched(context, request, terms())
535        }
536        other => other,
537    };
538}
539
540/// How a request names itself in notices and in the sentence of a step that was ended: the command and the kind of step.
541fn step_subject(request: &GitRequest) -> String {
542    return format!(
543        "{}, {}",
544        command_text(&request.arguments),
545        class_of(request.arguments.as_slice()).label()
546    );
547}
548
549/// What:
550///  The longest the request's step runs before it is ended, whatever it shows: the reference update has the shortest ceiling, the
551///  other steps the ceiling of their class.
552/// Why:
553///   The owner's rule is that nothing waits for ever, and a landing's one thread must not be held for good by a step that never
554///  returns (`wait_ceilings.rs`). In a unit test the ceiling can be shortened for the thread that runs the control.
555///
556/// In TS you'd write (pseudocode):
557/// ```ts
558/// function stepCeiling(request): number { return request.subcommand === 'update-ref' ? REFERENCE_STEP_CEILING : classOf(request).ceiling }
559/// ```
560fn step_ceiling(request: &GitRequest) -> Duration {
561    #[cfg(test)]
562    if let Some(shortened) = STEP_CEILING_FOR_THIS_THREAD.with(std::cell::Cell::get) {
563        return shortened;
564    }
565    let reference: bool = subcommand_of(request.arguments.as_slice()).is_some_and(|(_, name)| { return name == "update-ref"; });
566    if reference {
567        return REFERENCE_STEP_CEILING;
568    }
569    return match class_of(request.arguments.as_slice()) {
570        ChildClass::Plumbing => PLUMBING_STEP_CEILING,
571        ChildClass::Object => OBJECT_STEP_CEILING,
572    };
573}
574
575#[cfg(test)]
576thread_local! {
577    /// A shortened ceiling for the steps the current thread starts, so a control ends a step in a moment.
578    pub(crate) static STEP_CEILING_FOR_THIS_THREAD: std::cell::Cell<Option<Duration>> = const { std::cell::Cell::new(None) };
579}
580
581/// What:
582///  Start one request once under a watch and capture its output, whatever its exit code.
583/// Why:
584///   The command and its input file are built here, so every run starts from the request alone.
585///
586/// In TS you'd write (pseudocode):
587/// ```ts
588/// await runWatched({ gitPath, cwd, args, terms, stoppable: mayBeRerun(request) })
589/// ```
590fn run_git_watched(context: &GitContext, request: &GitRequest, terms: WatchTerms) -> std::io::Result<GitOutput> {
591    let mut command: Command = build_command(context, request);
592    match &request.input {
593        Some(bytes) => {
594            command.stdin(Stdio::from(input_file(bytes.as_slice(), context.common_dir.as_deref())?));
595        }
596        None => {
597            command.stdin(Stdio::null());
598        }
599    }
600    // The class label travels in the subject, so the notices and the timeout sentence name the kind of step.
601    let subject: String = step_subject(request);
602    let ledger_step: String = crate::add_timing::git_step_label(request.arguments.as_slice());
603    let output: std::process::Output =
604        output_watched_within(&mut command, subject.as_str(), ledger_step.as_str(), terms, may_be_rerun(request), step_ceiling(request))?;
605    return Ok(GitOutput {
606        code: output.status.code(),
607        stdout: output.stdout,
608        stderr: output.stderr,
609    });
610}
611
612/// What:
613///  Run one request and require success;
614///  a start failure or a non-zero exit is a
615///       failure naming the command and quoting Git's standard error.
616/// Why:
617///   Most transaction steps cannot continue without Git's answer.
618///
619/// In TS you'd write (pseudocode):
620/// ```ts
621/// await runTransactionGit({ gitPath, cwd, args }) // throws CommitTransactionGitError
622/// ```
623pub fn run_git_checked(
624    context: &GitContext,
625    request: &GitRequest,
626) -> Result<GitOutput, GitFailure> {
627    return checked_from(run_git(context, request), request.arguments.as_slice());
628}
629
630/// What:
631///  Turn the outcome of a run into the checked result:
632///  success needs a start and a zero exit, and each failure names the command.
633/// Why:
634///   A step stopped at its bound did start, and its own text already says which command and why;
635///  every other start failure and every non-zero exit is named here.
636///
637/// In TS you'd write (pseudocode):
638/// ```ts
639/// function checkedFrom(outcome: GitOutput | Error, args: string[]): GitOutput; // throws CommitTransactionGitError
640/// ```
641fn checked_from(outcome: std::io::Result<GitOutput>, arguments: &[OsString]) -> Result<GitOutput, GitFailure> {
642    let output: GitOutput = match outcome {
643        Ok(finished) => finished,
644        Err(error) if error.kind() == std::io::ErrorKind::TimedOut => {
645            return Err(GitFailure(error.to_string()));
646        }
647        Err(error) => {
648            return Err(GitFailure(format!("{} could not start: {error}", command_text(arguments))));
649        }
650    };
651    if !output.succeeded() {
652        return Err(GitFailure(format!("{} failed: {}", command_text(arguments), output.error_text())));
653    }
654    return Ok(output);
655}
656
657/// Real-Git runner controls stay out of the release executable.
658#[cfg(test)]
659#[path = "transaction_git_tests.rs"]
660mod tests;