Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# renovate: datasource=github-tags depName=golangci/golangci-lint
GOLANGCI_VERSION ?= v2.8.0
GOLANGCI_VERSION ?= v2.11.4
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools)

GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
Expand Down
4 changes: 4 additions & 0 deletions cmd/gogit-http-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,22 @@ var rootCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
directory := args[0]
addr := fmt.Sprintf(":%d", port)

abs, err := filepath.Abs(directory)
if err != nil {
return fmt.Errorf("failed to get absolute path: %w", err)
}

log.Printf("Using absolute path: %q", abs)

logger := log.Default()
loader := transport.NewFilesystemLoader(osfs.New(abs, osfs.WithBoundOS()), false)
gitmw := githttp.NewBackend(loader)

handler := LoggingMiddleware(logger, gitmw)

log.Printf("Starting server on %q for directory %q", addr, directory)

if err := http.ListenAndServe(addr, handler); !errors.Is(err, http.ErrServerClosed) {
return err
}
Expand Down
1 change: 1 addition & 0 deletions cmd/gogit/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var cloneCmd = &cobra.Command{
if cloneTags {
opts.Tags = git.TagFollowing
}

if cloneProgress {
opts.Progress = cmd.OutOrStdout()
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/gogit/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ var pushCmd = &cobra.Command{
}

var ep *transport.Endpoint

remoteName := git.DefaultRemoteName

if len(args) > 0 {
isRemote := false

for remote := range cfg.Remotes {
if args[0] == remote {
remoteName = remote
Expand All @@ -55,6 +58,7 @@ var pushCmd = &cobra.Command{
break
}
}

if !isRemote {
// Is this a repository URL?
ep, err = transport.NewEndpoint(args[0])
Expand All @@ -66,6 +70,7 @@ var pushCmd = &cobra.Command{
}

var refspecs []config.RefSpec

if len(args) > 1 {
for _, arg := range args[1:] {
ref := plumbing.NewBranchReferenceName(arg)
Expand Down Expand Up @@ -101,6 +106,7 @@ var pushCmd = &cobra.Command{
}

var isatty bool

stderr := cmd.ErrOrStderr()
if f, ok := stderr.(interface {
Fd() uintptr
Expand Down
2 changes: 2 additions & 0 deletions cmd/gogit/upload-pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ var uploadPackCmd = &cobra.Command{
}

ctx := cmd.Context()

if uploadPackTimeout > 0 {
var cancel context.CancelFunc

ctx, cancel = context.WithTimeout(ctx, time.Duration(uploadPackTimeout)*time.Second)
defer cancel()
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/gogit/worktree.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var worktreeAddCmd = &cobra.Command{
if worktreeAddDetach {
opts = append(opts, worktree.WithDetachedHead())
}

if worktreeAddCommit != "" {
hash := plumbing.NewHash(worktreeAddCommit)
if !hash.IsZero() {
Expand Down Expand Up @@ -121,13 +122,15 @@ var worktreeListCmd = &cobra.Command{
commonDir := wts.Filesystem()
for _, name := range worktrees {
gitdirPath := filepath.Join(commonDir.Root(), "worktrees", name, "gitdir")

gitdirData, err := os.ReadFile(gitdirPath)
if err != nil || len(gitdirData) == 0 {
continue
}

wtPath := filepath.Dir(string(gitdirData[:len(gitdirData)-1]))
wt := memfs.New()

err = w.Init(wt, name)
if err != nil {
continue
Expand Down
Loading