Skip to content

Commit 7612b47

Browse files
AriehSchneierclaude
andcommitted
docs: Clarify that tag fetch defaults did not change in v6
Section 3 incorrectly claimed that FetchOptions defaulted to AllTags in v5 and changed to NoTags in v6. This was false. Actual behavior (both v5 and v6): - CloneOptions.Tags defaults to AllTags - FetchOptions.Tags defaults to TagFollowing (not AllTags, not NoTags) TagFollowing fetches tags reachable from fetched commits, matching git CLI behavior. This has been the default in both v5 and v6. PR #1459 was not a behavior change - it only fixed a test that incorrectly expected AllTags behavior without setting it explicitly. Changes made: - Corrected section 3 to clarify no default behavior changed - Explained what TagFollowing actually means - Removed misleading checklist item about tag fetch defaults changing - Updated examples to show defaults work identically in both versions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
1 parent d64a003 commit 7612b47

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/tutorials/migrating-from-v5-to-v6.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Use this checklist to audit your codebase before upgrading:
2626
- [ ] Update the module import path from `github.com/go-git/go-git/v5` to `github.com/go-git/go-git/v6`
2727
- [ ] Call `defer r.Close()` on every `*git.Repository` obtained from filesystem-backed operations
2828
- [ ] Remove the `isBare bool` positional argument from `git.PlainClone` calls; set `CloneOptions.Bare` instead
29-
- [ ] Update any explicit `git.AllTags` / tag-fetch logic — tags are **no longer fetched by default** on `Fetch`
3029
- [ ] Update explicit `git.TagMode` type references to `plumbing.TagMode` (constant usage like `git.AllTags` is unchanged)
3130
- [ ] Rename `config.Version_0` / `config.Version_1` constants to `config.Version0` / `config.Version1`
3231
- [ ] Update code that implements or embeds `commitgraph.Index` — the interface gained `io.Closer` and new methods
@@ -110,37 +109,37 @@ r, err := git.PlainClone("/path/to/repo", &git.CloneOptions{
110109

111110
---
112111

113-
### 3. Tags are no longer fetched by default on `Fetch` ✅ Merged
112+
### 3. Understanding tag fetch defaults (no change between v5 and v6) ✅ Clarification
114113

115-
**What changed:** `git.FetchOptions` previously defaulted to fetching all
116-
tags (`AllTags`). In v6 the default is **no tags**. This aligns go-git's
117-
behaviour with the `git fetch` CLI, which only auto-follows tags
118-
reachable from fetched commits when no explicit tag refspec is given.
114+
**What is the default behavior:** Tag fetching defaults have **not changed** between v5 and v6. Both versions use:
115+
- `CloneOptions.Tags` defaults to `AllTags` (fetch all tags)
116+
- `FetchOptions.Tags` defaults to `TagFollowing` (fetch tags reachable from fetched commits)
119117

120-
**Why:** When comparing actual `git fetch` behaviour with the test
121-
expectations in go-git, it became clear that the tests expected all tags to
122-
be pulled without the user explicitly requesting them.
118+
**What `TagFollowing` means:** `TagFollowing` fetches tags that point to commits being fetched (matching `git fetch` behavior without explicit tag refspecs). This is different from:
119+
- `AllTags` — fetch all tags from the remote (like `git fetch --tags`)
120+
- `NoTags` — fetch no tags at all (like `git fetch --no-tags`)
123121

124-
**Impact:** Code that relied on tags being silently included in every
125-
`Fetch` call will no longer receive them.
122+
**Why this section exists:** A test fix in PR #1459 corrected a test that incorrectly expected `AllTags` behavior without setting it. This was not a behavior change—just a test correction.
126123

127-
**How to migrate:** If you need all remote tags, set `Tags: git.AllTags`
128-
explicitly:
124+
**Impact:** None. If you were relying on default behavior in v5, it works identically in v6.
125+
126+
**If you need all tags with `Fetch`:** Explicitly set `Tags: git.AllTags`:
129127

130128
```go
131-
// v5 — tags were returned by default
129+
// Both v5 and v6 — default behavior (TagFollowing)
132130
err := r.Fetch(&git.FetchOptions{
133131
RemoteName: "origin",
132+
// Tags implicitly defaults to TagFollowing
134133
})
135134

136-
// v6 — must opt in to fetching all tags
135+
// Both v5 and v6 — fetch ALL tags explicitly
137136
err := r.Fetch(&git.FetchOptions{
138137
RemoteName: "origin",
139138
Tags: git.AllTags,
140139
})
141140
```
142141

143-
**References:** [PR #1459](https://github.com/go-git/go-git/pull/1459)
142+
**References:** [PR #1459](https://github.com/go-git/go-git/pull/1459) (test fix, not a behavior change)
144143

145144
---
146145

0 commit comments

Comments
 (0)