Skip to content

gitindex: diff config updates for existing clones#1019

Merged
keegancsmith merged 1 commit intomainfrom
k/port-pr-635
Mar 23, 2026
Merged

gitindex: diff config updates for existing clones#1019
keegancsmith merged 1 commit intomainfrom
k/port-pr-635

Conversation

@keegancsmith
Copy link
Copy Markdown
Member

@keegancsmith keegancsmith commented Mar 20, 2026

This supersedes #635 by porting its selective config-sync idea onto current main with a smaller, easier-to-read shape. Clone orchestration stays in gitindex/clone.go, while config argument generation and existing-clone sync logic now live in gitindex/clone_config.go.

For existing clones, we now diff each zoekt.* setting before writing. Unchanged values are skipped, changed values are updated, and settings that disappear are removed. CloneRepo returns the repo destination only when a setting change actually happened so the caller can trigger reindexing only when needed.

cmd/zoekt-mirror-github was also cleaned up so optional integer metadata keys are only added to the config map when present, which avoids pushing empty config values downstream.

Note: On #635 review it mentioned using go-git. This commit initially explored that but it ended up being a lot more code due to missing utilities around easily setting values based on a git config string.

@keegancsmith keegancsmith requested review from a team, burmudar and stefanhengl and removed request for a team March 20, 2026 07:18
@keegancsmith keegancsmith marked this pull request as draft March 20, 2026 08:01
@keegancsmith
Copy link
Copy Markdown
Member Author

Sorry vibe coded this change and the agent decided to go ahead and open a PR before I had reviewed / improved anything

This supersedes #635 by porting its selective config-sync idea onto
current main with a smaller, easier-to-read shape. Clone orchestration
stays in gitindex/clone.go, while config argument generation and
existing-clone sync logic now live in gitindex/clone_config.go.

For existing clones, we now diff each zoekt.* setting before writing.
Unchanged values are skipped, changed values are updated, and settings
that disappear are removed. CloneRepo returns the repo destination only
when a setting change actually happened so the caller can trigger
reindexing only when needed.

cmd/zoekt-mirror-github was also cleaned up so optional integer metadata
keys are only added to the config map when present, which avoids pushing
empty config values downstream.

Note: On #635 review it mentioned using go-git. This commit initially
explored that but it ended up being a _lot_ more code due to missing
utilities around easily setting values based on a git config string.
@keegancsmith keegancsmith marked this pull request as ready for review March 23, 2026 10:50
@keegancsmith keegancsmith enabled auto-merge (squash) March 23, 2026 11:30
if !ok {
return false, nil
}
if err := unsetRepoConfigValue(repoDest, key); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the chances of there already being a key with an empty value?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry missed this comment.

it was a previous bug that we would marshal the empty string here. So this does clean it up. In practice though I don't think it happened for the zoekt use cases.

Copy link
Copy Markdown
Contributor

@burmudar burmudar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty straight forward 🚀

@keegancsmith keegancsmith merged commit 1e12144 into main Mar 23, 2026
10 checks passed
@keegancsmith keegancsmith deleted the k/port-pr-635 branch March 23, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants