1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Interact with git credentials in various ways and launch helper programs.
//!
//! ## Feature Flags
#![cfg_attr(
    all(doc, feature = "document-features"),
    doc = ::document_features::document_features!()
)]
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
#![deny(missing_docs, rust_2018_idioms)]
#![forbid(unsafe_code)]

/// A program/executable implementing the credential helper protocol.
#[derive(Debug)]
pub struct Program {
    /// The kind of program, ready for launch.
    pub kind: program::Kind,
    /// If true, stderr is enabled, which is the default.
    pub stderr: bool,
    /// `Some(…)` if the process is running.
    child: Option<std::process::Child>,
}

///
#[allow(clippy::empty_docs)]
pub mod helper;

///
#[allow(clippy::empty_docs)]
pub mod program;

///
#[allow(clippy::empty_docs)]
pub mod protocol;

/// Call the `git credential` helper program performing the given `action`, which reads all context from the git configuration
/// and does everything `git` typically does. The `action` should have been created with [`helper::Action::get_for_url()`] to
/// contain only the URL to kick off the process, or should be created by [`helper::NextAction`].
///
/// If more control is required, use the [`Cascade`][helper::Cascade] type.
#[allow(clippy::result_large_err)]
pub fn builtin(action: helper::Action) -> protocol::Result {
    protocol::helper_outcome_to_result(
        helper::invoke(&mut Program::from_kind(program::Kind::Builtin), &action)?,
        action,
    )
}