GitLabgitlab-org
cli
main
1package git
3import (
4 "bytes"
5 "errors"
6 "fmt"
7 "io"
8 "net/url"
9 "os"
10 "os/exec"
11 "path"
12 "path/filepath"
13 "regexp"
14 "slices"
15 "strings"
17 "gitlab.com/gitlab-org/cli/internal/run"
18)
20const DefaultRemote = "origin"
22var headBranchRe = regexp.MustCompile(`(HEAD branch:)\s+`)
24func GetRemoteURL(remoteAlias string) (string, error) {
25 return Config("remote." + remoteAlias + ".url")
26}
28// GetDefaultBranch finds and returns the remote's default branch
29func GetDefaultBranch(remote string) (string, error) {
30 getDefBranch := exec.Command("git", "remote", "show", remote)
32 // Ensure output from git is in English
33 getDefBranch.Env = os.Environ()
34 getDefBranch.Env = append(getDefBranch.Env, "LC_ALL=C")
36 output, err := run.PrepareCmd(getDefBranch).Output()
37 if err != nil {
38 return DefaultBranchName, err
39 }
41 return ParseDefaultBranch(output)
42}
44func RemoteBranchExists(branch string, gr GitRunner) bool {
45 _, err := gr.Git("ls-remote", "--exit-code", "--heads", DefaultRemote, branch)
46 return err == nil
47}
49func ParseDefaultBranch(output []byte) (string, error) {
50 var headBranch string
52 for o := range strings.SplitSeq(string(output), "\n") {
53 o = strings.TrimSpace(o)
54 if headBranchRe.MatchString(o) {
55 headBranch = strings.TrimPrefix(o, "HEAD branch: ")
56 break
57 }
58 }
59 return headBranch, nil
60}
62// ErrNotOnAnyBranch indicates that the user is in detached HEAD state
63var ErrNotOnAnyBranch = errors.New("you're not on any Git branch (a 'detached HEAD' state)")
65// ErrNotAGitRepository indicates the command ran outside a Git repository.
66// Check it with errors.Is rather than matching git's message: git localizes
67// its output, so the wording varies with the user's locale.
68var ErrNotAGitRepository = errors.New("not a git repository")
70// Ref represents a git commit reference
71type Ref struct {
72 Hash string
73 Name string
74}
76// CurrentBranch reads the checked-out branch for the git repository
77func CurrentBranch() (string, error) {
78 refCmd := GitCommand("symbolic-ref", "--quiet", "--short", "HEAD")
80 output, err := run.PrepareCmd(refCmd).Output()
81 if err == nil {
82 // Found the branch name
83 return firstLine(output), nil
84 }
86 var cmdErr *run.CmdError
87 if errors.As(err, &cmdErr) {
88 if cmdErr.Stderr.Len() == 0 {
89 // Detached head
90 return "", ErrNotOnAnyBranch
91 }
92 }
94 // Unknown error
95 return "", err
96}
98func listRemotes() ([]string, error) {
99 remoteCmd := exec.Command("git", "remote", "-v")
100 output, err := run.PrepareCmd(remoteCmd).Output()
101 return outputLines(output), err
102}
104func Config(name string) (string, error) {
105 configCmd := exec.Command("git", "config", name)
106 output, err := run.PrepareCmd(configCmd).Output()
107 if err != nil {
108 return "", fmt.Errorf("unknown config key: %s", name)
109 }
111 return firstLine(output), nil
112}
114var GitCommand = func(args ...string) *exec.Cmd {
115 return exec.Command("git", args...)
116}
118func UncommittedChangeCount() (int, error) {
119 statusCmd := GitCommand("status", "--porcelain")
120 output, err := run.PrepareCmd(statusCmd).Output()
121 if err != nil {
122 return 0, err
123 }
124 lines := strings.Split(string(output), "\n")
126 count := 0
128 for _, l := range lines {
129 if l != "" {
130 count++
131 }
132 }
134 return count, nil
135}
137func GitUserName() ([]byte, error) {
138 nameGrab := GitCommand("config", "user.name")
139 output, err := run.PrepareCmd(nameGrab).Output()
140 if err != nil {
141 return []byte{}, err
142 }
144 return output, nil
145}
147type Commit struct {
148 Sha string
149 Title string
150}
152func Commits(baseRef, headRef string) ([]*Commit, error) {
153 logCmd := GitCommand(
154 "-c", "log.ShowSignature=false",
155 "log", "--pretty=format:%H,%s",
156 "--cherry", fmt.Sprintf("%s...%s", baseRef, headRef))
157 output, err := run.PrepareCmd(logCmd).Output()
158 if err != nil {
159 return []*Commit{}, err
160 }
162 var commits []*Commit
163 sha := 0
164 title := 1
165 for _, line := range outputLines(output) {
166 split := strings.SplitN(line, ",", 2)
167 if len(split) != 2 {
168 continue
169 }
170 commits = append(commits, &Commit{
171 Sha: split[sha],
172 Title: split[title],
173 })
174 }
176 if len(commits) == 0 {
177 return commits, fmt.Errorf("could not find any commits between %s and %s", baseRef, headRef)
178 }
180 return commits, nil
181}
183func CommitBody(sha string) (string, error) {
184 showCmd := GitCommand("-c", "log.ShowSignature=false", "show", "-s", "--pretty=format:%b", sha)
185 output, err := run.PrepareCmd(showCmd).Output()
186 if err != nil {
187 return "", err
188 }
189 return string(output), nil
190}
192// Push publishes a git ref to a remote
193func Push(remote string, ref string, cmdOut, cmdErr io.Writer) error {
194 pushCmd := GitCommand("push", remote, ref)
195 pushCmd.Stdout = cmdOut
196 pushCmd.Stderr = cmdErr
197 return run.PrepareCmd(pushCmd).Run()
198}
200// SetUpstream sets the upstream (tracking) of a branch
201func SetUpstream(remote string, branch string, cmdOut, cmdErr io.Writer) error {
202 setCmd := GitCommand("branch", "--set-upstream-to", fmt.Sprintf("%s/%s", remote, branch))
203 setCmd.Stdout = cmdOut
204 setCmd.Stderr = cmdErr
205 return run.PrepareCmd(setCmd).Run()
206}
208type BranchConfig struct {
209 RemoteName string
210 RemoteURL *url.URL
211 MergeRef string
212}
214// ReadBranchConfig parses the `branch.BRANCH.(remote|merge)` part of git config
215func ReadBranchConfig(branch string) BranchConfig {
216 prefix := regexp.QuoteMeta(fmt.Sprintf("branch.%s.", branch))
217 configCmd := GitCommand("config", "--get-regexp", fmt.Sprintf("^%s(remote|merge)$", prefix))
218 output, err := run.PrepareCmd(configCmd).Output()
219 if err != nil {
220 return BranchConfig{}
221 }
222 cfg := BranchConfig{}
223 for _, line := range outputLines(output) {
224 parts := strings.SplitN(line, " ", 2)
225 if len(parts) < 2 {
226 continue
227 }
228 keys := strings.Split(parts[0], ".")
229 switch keys[len(keys)-1] {
230 case "remote":
231 if strings.Contains(parts[1], ":") {
232 u, err := ParseURL(parts[1])
233 if err != nil {
234 continue
235 }
236 cfg.RemoteURL = u
237 } else if !isFilesystemPath(parts[1]) {
238 cfg.RemoteName = parts[1]
239 }
240 case "merge":
241 cfg.MergeRef = parts[1]
242 }
243 }
244 return cfg
245}
247func DeleteLocalBranch(branch string, gr GitRunner) error {
248 _, err := gr.Git("branch", "-D", branch)
249 if err != nil {
250 return fmt.Errorf("could not delete local branch: %w", err)
251 }
253 return nil
254}
256// ListLocalBranches returns the names of every local branch in the repository.
257func ListLocalBranches(gr GitRunner) ([]string, error) {
258 out, err := gr.Git("for-each-ref", "--format=%(refname:short)", "refs/heads/")
259 if err != nil {
260 return nil, fmt.Errorf("could not list local branches: %w", err)
261 }
263 var branches []string
264 for line := range strings.SplitSeq(out, "\n") {
265 line = strings.TrimSpace(line)
266 if line != "" {
267 branches = append(branches, line)
268 }
269 }
270 return branches, nil
271}
273// ListMergedBranches returns the names of local branches reachable from target
274// (i.e. what `git branch --merged target` would print). This only catches
275// fast-forward merges — squash and rebase merges look like distinct commits to
276// git, so they are not reported as merged.
277func ListMergedBranches(target string, gr GitRunner) ([]string, error) {
278 out, err := gr.Git("branch", "--merged", target, "--format=%(refname:short)")
279 if err != nil {
280 return nil, fmt.Errorf("could not list merged branches: %w", err)
281 }
283 var branches []string
284 for line := range strings.SplitSeq(out, "\n") {
285 line = strings.TrimSpace(line)
286 if line != "" {
287 branches = append(branches, line)
288 }
289 }
290 return branches, nil
291}
293func CheckoutBranch(branch string, gr GitRunner) error {
294 _, err := gr.Git("checkout", branch)
295 if err != nil {
296 return fmt.Errorf("could not checkout branch: %w", err)
297 }
299 return nil
300}
302func CheckoutNewBranch(branch string) error {
303 configCmd := GitCommand("checkout", "-b", branch)
304 err := run.PrepareCmd(configCmd).Run()
305 return err
306}
308func RunClone(cloneURL string, target string, args []string) (string, error) {
309 cloneArgs := append(slices.Clone(args), "--", cloneURL)
311 // If the args contain an explicit target, pass it to clone
312 // otherwise, parse the URL to determine where git cloned it to so we can return it
313 if target != "" {
314 cloneArgs = append(cloneArgs, target)
315 } else {
316 target = cloneTargetDir(cloneURL)
317 }
319 cloneArgs = append([]string{"clone"}, cloneArgs...)
321 cloneCmd := GitCommand(cloneArgs...)
322 cloneCmd.Stdin = os.Stdin
323 cloneCmd.Stdout = os.Stdout
324 cloneCmd.Stderr = os.Stderr
326 err := run.PrepareCmd(cloneCmd).Run()
327 return target, err
328}
330// cloneTargetDir returns the directory git clones cloneURL into when no
331// explicit target is given. Trailing slashes are trimmed before the ".git"
332// suffix is stripped: a URL ending in ".git/" does not match the ".git" suffix,
333// so it would otherwise resolve to "repo.git" while git clones into "repo".
334func cloneTargetDir(cloneURL string) string {
335 return path.Base(StripDotGit(cloneURL))
336}
338// StripDotGit normalizes a Git URL path by removing trailing slashes and a
339// ".git" suffix.
340func StripDotGit(value string) string {
341 return strings.TrimSuffix(strings.TrimRight(value, "/"), ".git")
342}
344func AddUpstreamRemote(upstreamURL, cloneDir string) error {
345 cloneCmd := GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", "--", upstreamURL)
346 cloneCmd.Stdout = os.Stdout
347 cloneCmd.Stderr = os.Stderr
348 return run.PrepareCmd(cloneCmd).Run()
349}
351func isFilesystemPath(p string) bool {
352 return p == "." || strings.HasPrefix(p, "./") || strings.HasPrefix(p, "/")
353}
355// ToplevelDir returns the top-level directory path of the current repository
356var ToplevelDir = func() (string, error) {
357 showCmd := exec.Command("git", "rev-parse", "--show-toplevel")
358 output, err := run.PrepareCmd(showCmd).Output()
359 return firstLine(output), err
360}
362// GitDir returns the path to the .git directory (or the worktree-specific git dir).
363// In a normal repo this returns "<toplevel>/.git".
364// In a worktree this returns something like "<main-repo>/.git/worktrees/<name>".
365var GitDir = func() (string, error) {
366 cmd := exec.Command("git", "rev-parse", "--git-dir")
367 output, err := run.PrepareCmd(cmd).Output()
368 if err != nil {
369 return "", err
370 }
371 return firstLine(output), nil
372}
374// RebaseInProgress reports whether a Git rebase is currently in progress in
375// this worktree (its git dir contains a rebase-merge or rebase-apply
376// directory).
377func RebaseInProgress() bool {
378 gitDir, err := GitDir()
379 if err != nil {
380 return false
381 }
382 for _, dir := range []string{"rebase-merge", "rebase-apply"} {
383 if _, err := os.Stat(filepath.Join(gitDir, dir)); err == nil {
384 return true
385 }
386 }
387 return false
388}
390// GitCommonDir returns the path to the shared git directory for the repository.
391// In a normal repo this returns "<toplevel>/.git".
392// In a worktree this returns "<main-repo>/.git" (the common dir shared by all worktrees).
393func GitCommonDir() (string, error) {
394 cmd := exec.Command("git", "rev-parse", "--git-common-dir")
395 output, err := run.PrepareCmd(cmd).Output()
396 if err != nil {
397 return "", err
398 }
399 return firstLine(output), nil
400}
402func outputLines(output []byte) []string {
403 lines := strings.ReplaceAll(string(output), "\r\n", "\n")
404 lines = strings.TrimSuffix(lines, "\n")
405 return strings.Split(lines, "\n")
406}
408func firstLine(output []byte) string {
409 if i := bytes.IndexAny(output, "\n"); i >= 0 {
410 return string(output)[0:i]
411 }
412 return string(output)
413}
415var remoteRE = regexp.MustCompile(`(.+)\s+(.+)\s+\((push|fetch)\)`)
417// RemoteSet is a slice of git remotes
418type RemoteSet []*Remote
420func NewRemote(name string, u string) *Remote {
421 pu, _ := url.Parse(u)
422 return &Remote{
423 Name: name,
424 FetchURL: pu,
425 PushURL: pu,
426 }
427}
429// Remote is a parsed git remote
430type Remote struct {
431 Name string
432 Resolved string // Deprecated: Use ResolvedBase or ResolvedHead
433 ResolvedBase string
434 ResolvedHead string
435 FetchURL *url.URL
436 PushURL *url.URL
437}
439func (r *Remote) String() string {
440 return r.Name
441}
443// Remotes gets the git remotes set for the current repo
444func Remotes() (RemoteSet, error) {
445 list, err := listRemotes()
446 if err != nil {
447 // Distinguish "there is no repo here" from a genuine git failure, so
448 // callers can branch on errors.Is instead of matching git's localized
449 // message. GitDir keys off exit status, so it is locale-independent.
450 // Costs a second subprocess, but only on the error path. The two calls
451 // are not atomic: a repo deleted between them is reported as
452 // ErrNotAGitRepository. Accepted — the caller fails either way.
453 if _, gitDirErr := GitDir(); gitDirErr != nil {
454 return nil, fmt.Errorf("%w: %w", ErrNotAGitRepository, err)
455 }
456 return nil, err
457 }
458 remotes := parseRemotes(list)
460 // this is affected by SetRemoteResolution
461 // Read from both old and new config keys for backward compatibility
462 remoteCmd := exec.Command("git", "config", "--get-regexp", `^remote\..*\.glab-resolved(-base|-head)?$`)
463 output, _ := run.PrepareCmd(remoteCmd).Output()
464 for _, l := range outputLines(output) {
465 parts := strings.SplitN(l, " ", 2)
466 if len(parts) < 2 {
467 continue
468 }
469 rp := strings.SplitN(parts[0], ".", 4)
470 if len(rp) < 3 {
471 continue
472 }
473 name := rp[1]
474 configKey := rp[2]
475 resolution := parts[1]
477 for _, r := range remotes {
478 if r.Name == name {
479 // Store in appropriate field based on config key
480 switch configKey {
481 case "glab-resolved-base":
482 r.ResolvedBase = resolution
483 case "glab-resolved-head":
484 r.ResolvedHead = resolution
485 case "glab-resolved":
486 // Legacy config key - populate Resolved for backward compatibility
487 r.Resolved = resolution
488 }
489 break
490 }
491 }
492 }
494 return remotes, nil
495}
497func parseRemotes(gitRemotes []string) RemoteSet {
498 remotes := RemoteSet{}
499 for _, r := range gitRemotes {
500 match := remoteRE.FindStringSubmatch(r)
501 if match == nil {
502 continue
503 }
504 name := strings.TrimSpace(match[1])
505 urlStr := strings.TrimSpace(match[2])
506 urlType := strings.TrimSpace(match[3])
508 var rem *Remote
509 if len(remotes) > 0 {
510 rem = remotes[len(remotes)-1]
511 if name != rem.Name {
512 rem = nil
513 }
514 }
515 if rem == nil {
516 rem = &Remote{Name: name}
517 remotes = append(remotes, rem)
518 }
520 u, err := ParseURL(urlStr)
521 if err != nil {
522 continue
523 }
525 switch urlType {
526 case "fetch":
527 rem.FetchURL = u
528 case "push":
529 rem.PushURL = u
530 }
531 }
532 return remotes
533}
535// AddRemote adds a new git remote and auto-fetches objects from it
536func AddRemote(name, u string) (*Remote, error) {
537 addCmd := exec.Command("git", "remote", "add", "-f", name, "--", u)
538 addCmd.Stderr = os.Stderr
539 err := run.PrepareCmd(addCmd).Run()
540 if err != nil {
541 return nil, err
542 }
544 var urlParsed *url.URL
545 if strings.HasPrefix(u, "https") {
546 urlParsed, err = url.Parse(u)
547 if err != nil {
548 return nil, err
549 }
551 } else {
552 urlParsed, err = ParseURL(u)
553 if err != nil {
554 return nil, err
555 }
557 }
559 return &Remote{
560 Name: name,
561 FetchURL: urlParsed,
562 PushURL: urlParsed,
563 }, nil
564}
566var SetRemoteResolution = func(name, resolution string) error {
567 // Use separate config keys for base and head resolutions to avoid conflicts
568 // when both are stored for the same remote
569 configKey := "glab-resolved"
570 if resolution == "base" || strings.HasPrefix(resolution, "base:") {
571 configKey = "glab-resolved-base"
572 } else if resolution == "head" || strings.HasPrefix(resolution, "head:") {
573 configKey = "glab-resolved-head"
574 }
575 return SetRemoteConfig(name, configKey, resolution)
576}
578func SetRemoteConfig(remote, key, value string) error {
579 return SetConfig(fmt.Sprintf("remote.%s.%s", remote, key), value)
580}
582func SetConfig(key, value string) error {
583 found, err := configValueExists(key, value)
584 if err != nil {
585 return err
586 }
587 if found {
588 return nil
589 }
590 addCmd := GitCommand("config", "--add", key, value)
591 _, err = run.PrepareCmd(addCmd).Output()
592 if err != nil {
593 return fmt.Errorf("setting git config: %w", err)
594 }
595 return nil
596}
598func configValueExists(key, value string) (bool, error) {
599 output, err := GetAllConfig(key)
600 if err == nil {
601 return outputContainsLine(output, value), nil
602 }
603 return false, err
604}
606// GetConfig returns the local config value associated with the provided key.
607// If there are multiple values associated with the key, they are all returned.
608func GetAllConfig(key string) ([]byte, error) {
609 err := assertValidConfigKey(key)
610 if err != nil {
611 return nil, err
612 }
614 gitCmd := GitCommand("config", "--get-all", key)
615 output, err := run.PrepareCmd(gitCmd).Output()
616 if err == nil {
617 return output, nil
618 }
620 // git-config will exit with 1 in almost all cases, but only when it prints
621 // out things it is an actual error that is worth mentioning.
622 // Therefore ignore errors that don't output to stderr.
623 var cmdErr *run.CmdError
624 if errors.As(err, &cmdErr) && cmdErr.Stderr.Len() == 0 {
625 return nil, nil
626 }
627 return nil, fmt.Errorf("getting Git configuration value cmd: %s: %w", gitCmd.String(), err)
628}
630func assertValidConfigKey(key string) error {
631 s := strings.Split(key, ".")
632 if len(s) < 2 {
633 return fmt.Errorf("incorrect Git configuration key")
634 }
635 return nil
636}
638// outputContainsLine searches through each line in the command output
639// and returns true if one matches the needle a.k.a. the search string.
640func outputContainsLine(output []byte, needle string) bool {
641 return slices.Contains(outputLines(output), needle)
642}
644func RunCmd(args []string) error {
645 gitCmd := GitCommand(args...)
646 gitCmd.Stdout = os.Stdout
647 gitCmd.Stderr = os.Stderr
649 return run.PrepareCmd(gitCmd).Run()
650}
652// DescribeByTags gives a description of the current object.
653// Non-annotated tags are considered.
654// Reference: https://git-scm.com/docs/git-describe
655func DescribeByTags() (string, error) {
656 gitCmd := GitCommand("describe", "--tags")
658 output, err := run.PrepareCmd(gitCmd).Output()
659 if err != nil {
660 return "", fmt.Errorf("running cmd: %s out: %s: %w", gitCmd.String(), output, err)
661 }
663 return firstLine(output), nil
664}
666// ListTags gives a slice of tags from the current repository.
667func ListTags() ([]string, error) {
668 gitCmd := GitCommand("tag", "-l")
670 output, err := run.PrepareCmd(gitCmd).Output()
671 if err != nil {
672 return nil, fmt.Errorf("running cmd: %s out: %s: %w", gitCmd.String(), output, err)
673 }
675 tagsStr := string(output)
676 if tagsStr == "" {
677 return nil, nil
678 }
680 return strings.Fields(tagsStr), nil
681}
Diagnostics6 git calls · 50 ms
CallStatusSizeTime050 ms
discover200185 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=185 git.server.agent=git/2.56.g1891de4-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=185 git.pkt.payload.max=35
ls-refs20058 KiB · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=59849 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=731 git.pkt.data=730 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=59849 git.pkt.payload.max=143 git.ls_refs.count=730 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=32926 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=22 git.pkt.data=20 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=32926 git.pkt.payload.max=32046 git.sideband.band1.bytes=32046 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=80 git.pack.bytes=32046 git.pack.ofs_delta=36 git.pack.ref_delta=0 git.pack.chain.max=2 git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91 git.pack.full=44Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=4 git.response.bytes=4273 git.response.cache=HIT git.response.duration_ms=4 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4273 git.pkt.payload.max=4173 git.sideband.band1.bytes=4173 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=11 git.pack.bytes=4173 git.fetch.wide.objects=11 git.fetch.wide.extra_bytes=3930 git.fetch.wide.blobs=0
fetchtree:0200510 B · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=510 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=a3147172443266d011121808a125248c5c915972 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=510 git.pkt.payload.max=483 git.sideband.band1.bytes=483 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=483 git.pack.trailer=4ef234d86a93490a6a3da3549aa13a474a5c9eacOpen pack map
fetch2005.5 KiB · hit40 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=40 git.response.bytes=5589 git.response.cache=HIT git.response.duration_ms=40 git.fetch.wants=412bdc11df3af6507693b2102daafd9c77aa64a1 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=5589 git.pkt.payload.max=5562 git.sideband.band1.bytes=5562 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://gitlab.com/gitlab-org/cli
- Ref
- refs/heads/main
- Commit
- 0dd7574dce9e385c5c30540e6c15657adc6bdce9
- cf-ray
- a5e11fbeeffa7fd8
- Request
- 3b40ecc1…
- Protocol
- v2 · sha1
- Agent
- git/2.56.g1891de4-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format