Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support annotated tags given as base ref #135

Merged
merged 2 commits into from
Dec 21, 2024

Conversation

karlding
Copy link
Contributor

Improve the types of refspecs git-absorb knows how to parse that are
given via the '--base' flag.

This fixes the following:

# create an annotated tag
$ git tag -a 'annotated-tag' -m 'My annotated tag description'

# make + stage some changes
(...)

# try to absorb the changes
$ git absorb --base annotated-tag

According to the Git docs:

> Git supports two types of tags: lightweight and annotated.
>
> A lightweight tag is very much like a branch that doesn't
> change-it's just a pointer to a specific commit.
>
> Annotated tags, however, are stored as full objects in the Git
> database.

This meant that when passing an annotated tag via '--base', calling
git2::Repository::find_commit would fail since the given object would
be of the incorrect type:

> the requested type does not match the type in the ODB

However, eventually if we keep unpeeling, we would encounter the
corresponding commit.

Use git2::Object::peel_to_commit instead of simply peeling once
via 'find_commit' to ensure that peeling is performed recursively
until a commit is found.

Improve the types of refspecs git-absorb knows how to parse that are
given via the '--base' flag.

This fixes the following:

    # create an annotated tag
    $ git tag -a 'annotated-tag' -m 'My annotated tag description'

    # make + stage some changes
    (...)

    # try to absorb the changes
    $ git absorb --base annotated-tag

According to the Git docs:

    > Git supports two types of tags: lightweight and annotated.
    >
    > A lightweight tag is very much like a branch that doesn't
    > change-it's just a pointer to a specific commit.
    >
    > Annotated tags, however, are stored as full objects in the Git
    > database.

This meant that when passing an annotated tag via '--base', calling
git2::Repository::find_commit would fail since the given object would
be of the incorrect type:

    > the requested type does not match the type in the ODB

However, eventually if we keep unpeeling, we would encounter the
corresponding commit.

Use git2::Object::peel_to_commit instead of simply peeling once
via 'find_commit' to ensure that peeling is performed recursively
until a commit is found.
Add a test script that modifies a text file using 'ed' to test
annotated commits provided via '--base':

    1. Initialize a git repository
    2. Create some commits
    3. Tag an annotated commit
    4. Make some changes on top of the annotated tag that commute
    5. Try to absorb using '--base annotated-tag'

Note: The path to 'git-absorb' is taken via '${1}' so we can point to
locally built versions without needing to add additional directories to
our ${PATH}.
@tummychow tummychow merged commit 425cb17 into tummychow:master Dec 21, 2024
3 checks passed
@karlding karlding deleted the support_annotated_tags branch December 30, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants