main de06cbd

repo_fix_test.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package git
4
5import (
6	"errors"
7	"math"
8	"os"
9	"testing"
10)
11
12func TestWithMaxObjectSizeClamped(t *testing.T) {
13	var o options
14	WithMaxObjectSize(math.MaxInt64)(&o)
15	if o.maxObject != math.MaxInt {
16		t.Errorf("maxObject = %d, want %d", o.maxObject, math.MaxInt)
17	}
18	WithMaxObjectSize(1 << 20)(&o)
19	if o.maxObject != 1<<20 {
20		t.Errorf("maxObject = %d", o.maxObject)
21	}
22	WithMaxObjectSize(-5)(&o)
23	if o.maxObject != 1<<20 {
24		t.Errorf("a negative bound changed it to %d", o.maxObject)
25	}
26}
27
28func TestReplaceDirErrorsAreReturned(t *testing.T) {
29	if os.Geteuid() == 0 {
30		t.Skip("root reads any directory")
31	}
32	f := newFx(t)
33	f.write("a", []byte("a"), 0o644)
34	f.commit("one")
35	dir := f.dir + "/refs/replace"
36	if err := os.MkdirAll(dir, 0o755); err != nil {
37		t.Fatal(err)
38	}
39	if err := os.Chmod(dir, 0); err != nil {
40		t.Fatal(err)
41	}
42	t.Cleanup(func() { _ = os.Chmod(dir, 0o755) })
43	if _, err := Open(f.work); !errors.Is(err, os.ErrPermission) {
44		t.Fatalf("Open with an unreadable refs/replace = %v, want a permission error", err)
45	}
46	// Absent, or not a directory: nothing to refuse.
47	_ = os.Chmod(dir, 0o755)
48	_ = os.Remove(dir)
49	if err := checkLayout(f.dir); err != nil {
50		t.Errorf("no refs/replace: %v", err)
51	}
52	writeFile(t, dir, "a file")
53	if err := checkLayout(f.dir); err != nil {
54		t.Errorf("refs/replace is a file: %v", err)
55	}
56}

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