From 1975c3ca530e4e168f517275c45a32a3b1b3a3bc Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 14 Oct 2024 23:31:57 -0400 Subject: [PATCH] fix(git): dont fetch tags by default 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 --- src/cargo/sources/git/utils.rs | 2 ++ tests/testsuite/git.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 844a4dcf58b..f9b2f582c81 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -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 => {} diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 0fd25bf2db0..6bc72423c72 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -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