Skip to content

Commit

Permalink
fix(git): dont fetch tags by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weihanglo committed Oct 15, 2024
1 parent f9e20ff commit 1975c3c
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 1975c3c

Please sign in to comment.