git/list[1] front-page[2] threads[3] people[4] search[5] about
 

`git describe` skipping shallow fetched (grafted) tag

From
Anthony Sottile <asottile@umich.edu>
Date
Jul 8, 2019, 05:03 UTC
Message-ID
<CA+dzEBmmSmPWvK6ZKNiyH18V+HdTd+XMtq9TsSsDHorNThtGcA@mail.gmail.com>

I haven't been able to boil this down to a minimal reproduction yet but here's my current reproduction -- I'm very confused by the output I've gathered so far:

``` rm -rf repo1 git init repo1 cd repo1 git remote add origin https://github.com/asottile/pyupgrade git -c protocol.version=2 fetch origin v1.20.1 --depth=1 git fetch git describe origin/master --debug --tags ```

```
+ git --version
git version 2.20.1 (Apple Git-117)
+ rm -rf repo1
+ git init repo1
Initialized empty Git repository in /private/tmp/x/repo1/.git/
+ cd repo1
+ git remote add origin https://github.com/asottile/pyupgrade
+ git -c protocol.version=2 fetch origin v1.20.1 --depth=1
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 38 (delta 4), reused 27 (delta 3), pack-reused 0
Unpacking objects: 100% (38/38), done.
From https://github.com/asottile/pyupgrade
 * tag               v1.20.1    -> FETCH_HEAD
+ git fetch
remote: Enumerating objects: 1195, done.
remote: Counting objects: 100% (1195/1195), done.
remote: Compressing objects: 100% (436/436), done.
remote: Total 1195 (delta 753), reused 1188 (delta 748), pack-reused 0
Receiving objects: 100% (1195/1195), 290.55 KiB | 3.09 MiB/s, done.
Resolving deltas: 100% (753/753), done.
From https://github.com/asottile/pyupgrade
 * [new branch]      binary_literals -> origin/binary_literals
 * [new branch]      master          -> origin/master
 * [new tag]         v1.20.1         -> v1.20.1
 * [new tag]         v0.0.0          -> v0.0.0
 * [new tag]         v1.0.0          -> v1.0.0
 * [new tag]         v1.0.1          -> v1.0.1
 * [new tag]         v1.0.2          -> v1.0.2
 * [new tag]         v1.0.3          -> v1.0.3
 * [new tag]         v1.0.4          -> v1.0.4
 * [new tag]         v1.0.5          -> v1.0.5
 * [new tag]         v1.0.6          -> v1.0.6
 * [new tag]         v1.1.0          -> v1.1.0
 * [new tag]         v1.1.1          -> v1.1.1
 * [new tag]         v1.1.2          -> v1.1.2
 * [new tag]         v1.1.2-1        -> v1.1.2-1
 * [new tag]         v1.1.3          -> v1.1.3
 * [new tag]         v1.1.4          -> v1.1.4
 * [new tag]         v1.10.0         -> v1.10.0
 * [new tag]         v1.10.1         -> v1.10.1
 * [new tag]         v1.11.0         -> v1.11.0
 * [new tag]         v1.11.1         -> v1.11.1
 * [new tag]         v1.11.2         -> v1.11.2
 * [new tag]         v1.11.3         -> v1.11.3
 * [new tag]         v1.12.0         -> v1.12.0
 * [new tag]         v1.13.0         -> v1.13.0
 * [new tag]         v1.14.0         -> v1.14.0
 * [new tag]         v1.15.0         -> v1.15.0
 * [new tag]         v1.16.0         -> v1.16.0
 * [new tag]         v1.16.1         -> v1.16.1
 * [new tag]         v1.16.2         -> v1.16.2
 * [new tag]         v1.16.3         -> v1.16.3
 * [new tag]         v1.17.0         -> v1.17.0
 * [new tag]         v1.17.1         -> v1.17.1
 * [new tag]         v1.18.0         -> v1.18.0
 * [new tag]         v1.19.0         -> v1.19.0
 * [new tag]         v1.2.0          -> v1.2.0
 * [new tag]         v1.20.0         -> v1.20.0
 * [new tag]         v1.3.0          -> v1.3.0
 * [new tag]         v1.3.1          -> v1.3.1
 * [new tag]         v1.4.0          -> v1.4.0
 * [new tag]         v1.5.0          -> v1.5.0
 * [new tag]         v1.5.1          -> v1.5.1
 * [new tag]         v1.6.0          -> v1.6.0
 * [new tag]         v1.6.1          -> v1.6.1
 * [new tag]         v1.7.0          -> v1.7.0
 * [new tag]         v1.8.0          -> v1.8.0
 * [new tag]         v1.9.0          -> v1.9.0
 * [new tag]         v1.9.1          -> v1.9.1
+ git describe origin/master --debug --tags --abbrev=0
describe origin/master
No exact match on refs or tags, searching to describe
 lightweight        6 v1.20.0
 lightweight       26 v1.19.0
 lightweight       41 v1.18.0
 lightweight       63 v1.17.1
 lightweight       68 v1.17.0
 lightweight       76 v1.16.3
 lightweight       79 v1.16.2
 lightweight       82 v1.16.1
 lightweight       87 v1.16.0
 lightweight       99 v1.20.1
traversed 101 commits
more than 10 tags found; listed 10 most recent
gave up search at eff26acd6261727e049449e2aa481db4c8146d21
v1.20.0
```
If I inspect the history using `git log` inside of `repo1`:

``` $ git log origin/master --decorate --oneline | head -10 3c13b24 (origin/master) Merge pull request #184 from mxr/typing-bugs a5bfb80 Fix type annotation 91815ae Merge pull request #183 from asottile/parenthesized_format 38f1bcb (grafted, tag: v1.20.1) v1.20.1 559bc04 Utilize rfind_string_parts to improve .format() rewrite 72575fe simplify _get_body test c93c34e (tag: v1.20.0) v1.20.0 9bc6390 Merge pull request #181 from asottile/numeric_fixes_in_py3 6df0901 Also fix octal / long literals in python 3 14a7c6a Merge pull request #180 from asottile/stdin ```

I see the `grafted` tag appear sooner in the history than the non-grafted tag, but `git describe` doesn't find it.

real-world issue: https://github.com/pre-commit/pre-commit/issues/1076
Anthony
Message 1 of 1 in “`git describe` skipping shallow fetched (grafted) tag”
  1. Anthony SottileJul 8, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.