Archived
Fetch in the background and follow changes in the repositories
- On startup, after the local state is shown, fetch the superproject and every initialized submodule (all remotes, prune, at most 8 at once). Fetches never prompt; failures show git's message. --no-fetch skips it, f fetches again. - The header shows "fetching n/m", then the fetch age and failures; the detail pane shows each submodule's last fetch and fetch errors. - The git provider polls each repository's metadata (refs, HEAD, index, .gitmodules) every 2 s and reports changes. The app reloads only what changed, keeping old values, expansion and cursor; loads are single-flight with coalesced reruns. Refresh is driven by the repositories, so a fetch in another shell updates the view like ours. - r reloads everything (worktree edits are not watched). - Docs: F50-F53, N1/N8 rewritten, D18-D20 (D12 superseded). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
19c6f17eb2
commit
27f0c0b5d2
@@ -0,0 +1,43 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// gitDirs returns the git directory of the worktree at dir and its common
|
||||
// directory (they differ only for linked worktrees). A submodule's .git is
|
||||
// a file "gitdir: <path>".
|
||||
func gitDirs(dir string) (gitDir, commonDir string, err error) {
|
||||
dotGit := filepath.Join(dir, ".git")
|
||||
fi, err := os.Stat(dotGit)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
gitDir = dotGit
|
||||
if !fi.IsDir() {
|
||||
b, err := os.ReadFile(dotGit)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
p, ok := strings.CutPrefix(strings.TrimSpace(string(b)), "gitdir:")
|
||||
if !ok {
|
||||
return "", "", errors.New(dotGit + ": not a gitdir file")
|
||||
}
|
||||
gitDir = joinPath(dir, strings.TrimSpace(p))
|
||||
}
|
||||
commonDir = gitDir
|
||||
if b, err := os.ReadFile(filepath.Join(gitDir, "commondir")); err == nil {
|
||||
commonDir = joinPath(gitDir, strings.TrimSpace(string(b)))
|
||||
}
|
||||
return gitDir, commonDir, nil
|
||||
}
|
||||
|
||||
func joinPath(base, p string) string {
|
||||
if !filepath.IsAbs(p) {
|
||||
p = filepath.Join(base, p)
|
||||
}
|
||||
return filepath.Clean(p)
|
||||
}
|
||||
Reference in New Issue
Block a user