3

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?

Guildenstern
  • 2,179
  • 1
  • 17
  • 39
Wang
  • 7,250
  • 4
  • 35
  • 66
  • I think you should be able to use [`git log` to fetch the tags in the range](https://stackoverflow.com/a/63513907) to generate the list (instead of doing it manually) and append that to the command (and could probably create a wrapper to automate this). – Hasturkun Aug 07 '23 at 14:38
  • I guess that will involve annoying awk programming or whatever command to process the log output. Because git log cannot just give you tag, it include all possible descriptor. The closest I found is `%D` which still require parsing. – Wang Aug 07 '23 at 15:02
  • the closet thing I found is `git --no-pager log --simplify-by-decoration --decorate-refs='tags' --format='%D'`, but it still require extra parsing. since you get per line `tag: xxx, tag: yyy` – Wang Aug 07 '23 at 15:20
  • The answer I linked does a grep/sed combo to strip off the unwanted junk, but you can actually do `git log --simplify-by-decoration --decorate-refs='tags' --format=format:'%(describe:tags=1)'` and get just the tags without extra fluff. – Hasturkun Aug 07 '23 at 15:56
  • not really, the `$(describe:)` cannot describe `non-annotated tags`. in `git describe` you need to specify `--tags`, for the formater this option does not exist till very recent git version. at least `2.34` does not have it. – Wang Aug 07 '23 at 15:59
  • For versions that do support it (>=2.35) `%(describe:tags)` should work, but yes, otherwise you're probably stuck with parsing out the output – Hasturkun Aug 07 '23 at 16:05

0 Answers0