Skip to content

Divergent hash length behaviour from git when running git describe --tags --always #1176

@jpcorreia99

Description

@jpcorreia99

Hey there!

Noticed that when using git2 to compute the result of git describe, the behaviour can diverge from git

In particular this code

pub fn git_describe_native(path: &Path) -> Result<String> {
    let repo = Repository::open(path)?;

    let mut describe_opts = DescribeOptions::new();
    describe_opts.describe_tags();
    describe_opts.show_commit_oid_as_fallback(true);

    let description = repo.describe(&describe_opts).into_diagnostic()?;

    let format_opts = DescribeFormatOptions::new();
    description.format(Some(&format_opts)).into_diagnostic()?;
}

will differ from git describe --tags --always in specific cases where the repo grows too large.

According to git docs the length of the abbreviation scales as the repository grows, using the approximate number of objects in the repository and a bit of math around the birthday paradox, and defaults to a minimum of 7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions