From 00c42ca36e93a22f233fc1d3f9a1afc241fd4464 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 5 Apr 2022 20:22:19 +0800 Subject: [PATCH] Use all tags by default, instead of requiring annotated tags (#298) This is a bit more user friendly, most projects don't use annotated tags. This makes sense for linux though, where lighweight tags might just be markers. --- git-repository/src/id.rs | 2 +- src/plumbing/main.rs | 4 ++-- src/plumbing/options.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/git-repository/src/id.rs b/git-repository/src/id.rs index c7a839c7ffa..34e74d35ab1 100644 --- a/git-repository/src/id.rs +++ b/git-repository/src/id.rs @@ -49,7 +49,7 @@ impl<'repo> Id<'repo> { fn calculate_auto_hex_len(num_packed_objects: u64) -> usize { let mut len = 64 - num_packed_objects.leading_zeros(); - len = (len + 2 - 1) / 2; + len = (len + 1) / 2; len.max(7) as usize } diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 2447650bfd4..00afd0a50e4 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -159,7 +159,7 @@ pub fn main() -> Result<()> { Subcommands::Repository(repo::Platform { repository, cmd }) => match cmd { repo::Subcommands::Commit { cmd } => match cmd { repo::commit::Subcommands::Describe { - all_tags, + annotated_tags, all_refs, first_parent, always, @@ -180,7 +180,7 @@ pub fn main() -> Result<()> { out, err, core::repository::commit::describe::Options { - all_tags, + all_tags: !annotated_tags, all_refs, long_format: long, first_parent, diff --git a/src/plumbing/options.rs b/src/plumbing/options.rs index 70027da4ff6..80d3a9647ba 100644 --- a/src/plumbing/options.rs +++ b/src/plumbing/options.rs @@ -395,12 +395,12 @@ pub mod repo { pub enum Subcommands { /// Describe the current commit or the given one using the name of the closest annotated tag in its ancestry. Describe { - /// Use all tag references for naming, not only annotated tags. + /// Use annotated tag references only, not all tags. #[clap(long, short = 't', conflicts_with("all-refs"))] - all_tags: bool, + annotated_tags: bool, /// Use all references under the `ref/` namespaces, which includes tag references, local and remote branches. - #[clap(long, short = 'a', conflicts_with("all-tags"))] + #[clap(long, short = 'a', conflicts_with("annotated-tags"))] all_refs: bool, /// Only follow the first parent when traversing the commit graph.