gitgit-bundle

how can I create git bundle between 2 commits and include all the tag labels between them?


For example here I have some commits between v0.5.1 and v0.5.4:

git log --pretty=oneline  v0.5.1..v0.5.4
ec7a6416580276d2f9975802f487c1216dcc540d (tag: v0.5.4) Release v0.5.4
64b2b14d3123c619db5bbfac718c579e8daa8da8 fix: decoding nested dicts with tuple keys (#297)
ccff0b51418b4c41b63ee48f31126435e5cfd2bd (tag: v0.5.3) Release v0.5.3
2e51315f0fd7e088a66346e67224f38eea0da4a3 (tag: 0.5.3) chore(deps): update Pipfile.lock
0d9d73ac9f8dd5dbe9712100ac977fa9bad51602 chore(deps): pin pytest to >=6.2.3 to bump its transitive dep py
3dc59e01ccdfec619ee4e4c3502b9759b67c3fa8 (tag: v0.5.2) Release v0.5.2
5aba46a417ce48137f16f0f7fd3cc51ccdfee8c3 Revert "refactor!: remove `encode_json` optional arg for `to_dict`"
da2f98104ae5722af5d57f0c0118f903f0f12a91 docs: formatting
f8ee0c04590cc31ebe039e7010a8a668a42f97fb Update README.md

I want to export a bundle including those commits:

$ git bundle create ../notag-v0.5.4.bundle v0.5.1..v0.5.4
Enumerating objects: 44, done.
Counting objects: 100% (44/44), done.
Compressing objects: 100% (26/26), done.
Total 33 (delta 22), reused 17 (delta 7), pack-reused 0

$ git bundle list-heads ../notag-v0.5.4.bundle
ec7a6416580276d2f9975802f487c1216dcc540d refs/tags/v0.5.4

here we can see it does not include v0.5.2 and v0.5.3

however, if I add --tags, it includes far more commits:

$ git bundle create ../v0.5.4.bundle --tags v0.5.1..v0.5.4
Enumerating objects: 432, done.
Counting objects: 100% (432/432), done.
Compressing objects: 100% (159/159), done.
Total 402 (delta 256), reused 363 (delta 220), pack-reused 0

It change from 33 packs to 402 packs, which include all tags after v0.5.1

So far the only working way is to use tag list:

$ git bundle create ../v0.5.4.bundle v0.5.1..v0.5.4 v0.5.2 v0.5.3
Enumerating objects: 44, done.
Counting objects: 100% (44/44), done.
Compressing objects: 100% (26/26), done.
Total 33 (delta 22), reused 17 (delta 7), pack-reused 0

$ git bundle list-heads ../v0.5.4.bundle
ec7a6416580276d2f9975802f487c1216dcc540d refs/tags/v0.5.4
3dc59e01ccdfec619ee4e4c3502b9759b67c3fa8 refs/tags/v0.5.2
ccff0b51418b4c41b63ee48f31126435e5cfd2bd refs/tags/v0.5.3

But this is very annoying, I have to manually find out what tags are between those commits.

In more complicated situation it is not simple version like tags. It maybe fix-issue-220, feature-merge, etc. It can be any wording and no way to tell the order.

What is the canonical way to do this?


Solution

  • If I get your requirement correctly: you want to list the tags that are placed on a parent (any parent) of v0.5.4, and whose history contains v0.5.1.

    You can use git tag directly:

    git tag --contains v0.5.1 --merged v0.5.4
    

    Check git help tag to see what other relevant options -- for example: --list "v[0-9]*" will list only tags starting with "v" followed by a number