Skip to content

Commit

Permalink
Auto merge of #14688 - weihanglo:git-cli, r=epage
Browse files Browse the repository at this point in the history
fix(git): dont fetch tags by default

### What does this PR try to resolve?

Change Cargo to pass [`--no-tags`] Git CLI option by default. This aligns with how libgit2 works in Cargo.

Based on the Git official doc,
the flag has been there since at least 2.0.5

[`--no-tags`]: https://git-scm.com/docs/git-fetch/2.0.5#Documentation/git-fetch.txt---no-tags

### How should we test and review this PR?

Not sure if we want a test for this.
`CARGO_NET_GIT_FETCH_WITH_CLI` is barely tested.

### Additional information

Fixes #14687
  • Loading branch information
bors committed Oct 15, 2024
2 parents 5b220de + 1975c3c commit 3c4c0a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,8 @@ fn fetch_with_cli(
cmd.arg("fetch");
if tags {
cmd.arg("--tags");
} else {
cmd.arg("--no-tags");
}
match gctx.shell().verbosity() {
Verbosity::Normal => {}
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2954,7 +2954,7 @@ fn use_the_cli() {

let stderr = str![[r#"
[UPDATING] git repository `[ROOTURL]/dep1`
[RUNNING] `git fetch --verbose --force --update-head-ok [..][ROOTURL]/dep1[..] [..]+HEAD:refs/remotes/origin/HEAD[..]`
[RUNNING] `git fetch --no-tags --verbose --force --update-head-ok [..][ROOTURL]/dep1[..] [..]+HEAD:refs/remotes/origin/HEAD[..]`
From [ROOTURL]/dep1
* [new ref] [..] -> origin/HEAD[..]
[LOCKING] 1 package to latest compatible version
Expand Down

0 comments on commit 3c4c0a2

Please sign in to comment.