Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configuration option to fetch with git-the-CLI #5914

Merged
merged 1 commit into from
Aug 21, 2018

Conversation

alexcrichton
Copy link
Member

Currently Cargo always uses libgit2 to perform all fetches of git
repositories, but sometimes this is not sufficient. The libgit2 library
doesn't support all authentication schemes that git does and it isn't always
quite at feature parity with git itself, especially in terms of network
configuration.

This commit adds a configuration option to Cargo for fetching git repositories
with the git CLI tool rather than the internal libgit2. While this exposes
us to changes over time in the git CLI it's hopefully a very targeted use case
that doesn't change much. The internal libgit2 library should be sufficient
for all other forms of git repository management. (and using git for only
fetches shouldn't slow us down much)

The new configuration option in .cargo/config is:

[net]
git-fetch-with-cli = true

which can also be specified with CARGO_NET_GIT_FETCH_WITH_CLI=true via an
environment variable.

Closes #5903

@rust-highfive
Copy link

r? @matklad

(rust_highfive has picked a reviewer for you, use r? to override)

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of questions.


assert_that(
project.cargo("build -v"),
execs().with_status(0).with_stderr(stderr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 0 status is redundant 😉

let mut cmd = process("git");
cmd.arg("fetch")
.arg("--tags") // fetch all tags
.arg("--quiet")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this for feature parity with libgit2's variant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed yeah!

refspec: &str,
config: &Config,
) -> CargoResult<()> {
let mut cmd = process("git");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason (either way) to use cargo's process API over the stdlib's Command API (like used by the git gc below)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it mostly just had to do with how easy it was to deal with the result. The git gc piece is basically ignoring the result of the process no matter what happens, while here we want to report any failure of git and Cargo's already got good error handling and UI for all that.

@alexcrichton
Copy link
Member Author

@bors: r=dwijnand

@bors
Copy link
Collaborator

bors commented Aug 20, 2018

📌 Commit a3388a1 has been approved by dwijnand

bors added a commit that referenced this pull request Aug 20, 2018
Add a configuration option to fetch with git-the-CLI

Currently Cargo always uses `libgit2` to perform all fetches of git
repositories, but sometimes this is not sufficient. The `libgit2` library
doesn't support all authentication schemes that `git` does and it isn't always
quite at feature parity with `git` itself, especially in terms of network
configuration.

This commit adds a configuration option to Cargo for fetching git repositories
with the `git` CLI tool rather than the internal `libgit2`. While this exposes
us to changes over time in the `git` CLI it's hopefully a very targeted use case
that doesn't change much. The internal `libgit2` library should be sufficient
for all other forms of git repository management. (and using `git` for only
fetches shouldn't slow us down much)

The new configuration option in `.cargo/config` is:

    [net]
    git-fetch-with-cli = true

which can also be specified with `CARGO_NET_GIT_FETCH_WITH_CLI=true` via an
environment variable.

Closes #5903
@bors
Copy link
Collaborator

bors commented Aug 20, 2018

⌛ Testing commit a3388a1 with merge 24f38b8...

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 21, 2018

Why didn't @bors merge this yet?

@dwijnand
Copy link
Member

dwijnand commented Aug 21, 2018

Bors has been having issues lately. And the solution I've seen used is closing and reopening the PR.

@alexcrichton
Copy link
Member Author

@bors: retry r+

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

📌 Commit a3388a1 has been approved by alexcrichton

@alexcrichton
Copy link
Member Author

@bors: retry

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

⌛ Testing commit a3388a1 with merge f74ff24278fd986b425a160cde831a234199c1f0...

Currently Cargo always uses `libgit2` to perform all fetches of git
repositories, but sometimes this is not sufficient. The `libgit2` library
doesn't support all authentication schemes that `git` does and it isn't always
quite at feature parity with `git` itself, especially in terms of network
configuration.

This commit adds a configuration option to Cargo for fetching git repositories
with the `git` CLI tool rather than the internal `libgit2`. While this exposes
us to changes over time in the `git` CLI it's hopefully a very targeted use case
that doesn't change much. The internal `libgit2` library should be sufficient
for all other forms of git repository management. (and using `git` for only
fetches shouldn't slow us down much)

The new configuration option in `.cargo/config` is:

    [net]
    git-fetch-with-cli = true

which can also be specified with `CARGO_NET_GIT_FETCH_WITH_CLI=true` via an
environment variable.

Closes rust-lang#5903
@alexcrichton
Copy link
Member Author

@bors: r=dwijnand

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

📌 Commit a0591ee has been approved by dwijnand

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

⌛ Testing commit a0591ee with merge 2e9dc07155ea4675b3c532a962f0082731f1ff7f...

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

💥 Test timed out

@alexcrichton
Copy link
Member Author

@bors: retry

@bors
Copy link
Collaborator

bors commented Aug 21, 2018

⌛ Testing commit a0591ee with merge 7ff1bdb...

bors added a commit that referenced this pull request Aug 21, 2018
Add a configuration option to fetch with git-the-CLI

Currently Cargo always uses `libgit2` to perform all fetches of git
repositories, but sometimes this is not sufficient. The `libgit2` library
doesn't support all authentication schemes that `git` does and it isn't always
quite at feature parity with `git` itself, especially in terms of network
configuration.

This commit adds a configuration option to Cargo for fetching git repositories
with the `git` CLI tool rather than the internal `libgit2`. While this exposes
us to changes over time in the `git` CLI it's hopefully a very targeted use case
that doesn't change much. The internal `libgit2` library should be sufficient
for all other forms of git repository management. (and using `git` for only
fetches shouldn't slow us down much)

The new configuration option in `.cargo/config` is:

    [net]
    git-fetch-with-cli = true

which can also be specified with `CARGO_NET_GIT_FETCH_WITH_CLI=true` via an
environment variable.

Closes #5903
@bors
Copy link
Collaborator

bors commented Aug 21, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: dwijnand
Pushing 7ff1bdb to master...

@bors bors merged commit a0591ee into rust-lang:master Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shell out to system git on fetch
7 participants