v0.1.1 de06cbd

stat_unix.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3//go:build linux || darwin || freebsd || openbsd || netbsd || dragonfly
4
5package git
6
7import (
8	"io"
9	"os"
10	"syscall"
11)
12
13// fillStat converts the result of a stat system call into st. An absent path
14// is not an error.
15func fillStat(st *fileStat, sys *syscall.Stat_t, nul []byte, err error) error {
16	*st = fileStat{}
17	if err != nil {
18		if err == syscall.ENOENT || err == syscall.ENOTDIR {
19			return nil
20		}
21		return &os.PathError{Op: "stat", Path: string(nul[:len(nul)-1]), Err: err}
22	}
23	*st = fileStat{
24		exists: true,
25		isDir:  sys.Mode&syscall.S_IFMT == syscall.S_IFDIR,
26		size:   sys.Size,
27		mtime:  statMtime(sys),
28		ino:    uint64(sys.Ino), //nolint:unconvert // the type differs per OS
29	}
30	return nil
31}
32
33// rawFile is an open file descriptor.
34type rawFile struct{ fd int }
35
36// read returns io.EOF at the end of the file.
37func (f rawFile) read(p []byte) (int, error) {
38	for {
39		n, err := syscall.Read(f.fd, p)
40		if err == syscall.EINTR {
41			continue
42		}
43		if err != nil {
44			return 0, err
45		}
46		if n == 0 {
47			return 0, io.EOF
48		}
49		return n, nil
50	}
51}
52
53func (f rawFile) close() { _ = syscall.Close(f.fd) }
54
55// isNotExistErrno reports whether err, from openNul, says that the file or
56// a directory on the way is absent.
57func isNotExistErrno(err error) bool { return err == syscall.ENOENT || err == syscall.ENOTDIR }
58
59func openError(nul []byte, err error) error {
60	return &os.PathError{Op: "open", Path: string(nul[:len(nul)-1]), Err: err}
61}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 2

↑↓ moveenter openesc close