Support annotated tags given as base ref#135
Merged
tummychow merged 2 commits intotummychow:masterfrom Dec 21, 2024
Merged
Conversation
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}.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve the types of refspecs git-absorb knows how to parse that are
given via the '--base' flag.
This fixes the following:
According to the Git docs:
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:
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.