fix(checkpoint): stamp skipFetchAll only on remotes we create · Entire

fix(checkpoint): stamp skipFetchAll only on remotes we create

870ff89→main·

pjbgf·3d ago·2 files·+141 added/-54 removed

PR #1733 stamped skipFetchAll/skipDefaultUpdate onto any URL-keyed promisor section it found on every filtered fetch, rewriting config for remotes it did not create. Replace that with stamp-on-creation: check whether the remote. section exists before the fetch and only stamp the skip flags when this fetch is the one creating it. Drop the promisor read entirely. Pre-existing remotes are left untouched so we never rewrite the user's git config, and adhoc checkpoint URL remotes still stay out of git fetch --all / git remote update.

Assisted-by: Claude Opus 4.8 noreply@anthropic.com Signed-off-by: Paulo Gomes paulo@entire.io

Sessions

01KXGAHK64A47XQ9F5BC7MXKA4View transcript

Changes

2

84 unmodified lines

...

func markRemoteSkipped(ctx context.Context, dir, url string) {
    for _, key := range []string{"skipFetchAll", "skipDefaultUpdate"} {
        fullKey := "remote." + url + "." + key
        if gitConfigBool(ctx, dir, fullKey) {
            continue
        }
        cmd := exec.CommandContext(ctx, "git", "config", "--local", fullKey, "true")
        if dir != "" {
            cmd.Dir = dir
        }
      ... 
    }
}

// gitConfigBool reads a local git config key and reports whether it is set to
// a true value. Missing keys and read errors report false.
func gitConfigBool(ctx context.Context, dir, key string) bool {
    cmd := exec.CommandContext(ctx, "git", "config", "--local", "--get", "--type=bool", key)
    if dir != "" {
        cmd.Dir = dir
    }
    out, err := cmd.Output()
    if err != nil {
        return false
    }
    return strings.TrimSpace(string(out)) == "true"
}

// TestFetch_FilteredURLFetchMarksPromisorSkipped verifies that after a
// filtered fetch from a URL, the URL-keyed promisor config section git creates
// is excluded from `git fetch --all` / `git remote update`.
func TestFetch_FilteredURLFetchMarksPromisorSkipped(t *testing.T) {
    ctx := context.Background()
    tmpDir := t.TempDir()
    // tests... 
}