8000 Repository.Push panics when it tries to push a tag with an empty name · Issue #929 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
Repository.Push panics when it tries to push a tag with an empty name #929
@peterzandbergen

Description

@peterzandbergen

When I Clone a remote repo in memory with no working area, tag the head with an empty tag name and then push it back to origin, Push panics.

Steps to reproduce:

  1. Clone a repo from e.g. github in memory
  2. tag the head with an empty tag name
  3. Push to origin, this panixs
// 1
repo, _ := git.CloneContext(ctx, memory.NewStorage(), nil, &co)

// 2
repo.CreateTag("", hash, opts)

// 
repo.PushContext(ctx, opts) // This generates a panic.

A test with my program using your great package (serious now)

# This command completes successfully.
 peza  c5361530-pop-os  ~  DevProjects  ggit  ERROR  $  go run ./cmd/ggit/     --repo-url https://gitlab.com/peterzandbergen/ggit-test.git      --loglevel debug     --branch main     --user peterzandbergen     --password *************     --name "Peter Zandbergen"     --email peter.zandbergen@myhops.nl     --message "Hallo daar"     --tag "new-tag-1"
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="create logger" application=ggit loglevel=DEBUG logformat=text
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="execute started" application=ggit
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="using basic auth" application=ggit
time=2023-11-16T10:17:12.377+01:00 level=DEBUG msg="authenticator created" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="repo cloned" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="annotated tag" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="head tagged" application=ggit
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="created tag ref spec" application=ggit tagRefSpec=refs/tags/*:refs/tags/*
time=2023-11-16T10:17:13.005+01:00 level=DEBUG msg="using auth" application=ggit auth.String="http-basic-auth - peterzandbergen:*******" auth.Name=http-basic-auth
time=2023-11-16T10:17:13.968+01:00 level=DEBUG msg="tags pushed" application=ggit


# When removing the --tag option the code panics
 peza  c5361530-pop-os  ~  DevProjects  ggit  $  go run ./cmd/ggit/     --repo-url https://gitlab.com/peterzandbergen/ggit-test.git      --loglevel debug     --branch main     --user peterzandbergen     --password *********     --name "Peter Zandbergen"     --email peter.zandbergen@myhops.nl     --message "Hallo daar" 
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="create logger" application=ggit loglevel=DEBUG logformat=text
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="execute started" application=ggit
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="using basic auth" application=ggit
time=2023-11-16T10:17:34.943+01:00 level=DEBUG msg="authenticator created" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="repo cloned" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="creating annotated tagger" application=ggit taggerName="Peter Zandbergen" taggerEmail=peter.zandbergen@myhops.nl
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="annotated tag" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="head tagged" application=ggit
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="created tag ref spec" application=ggit tagRefSpec=refs/tags/*:refs/tags/*
time=2023-11-16T10:17:35.559+01:00 level=DEBUG msg="using auth" application=ggit auth.String="http-basic-auth - peterzandbergen:*******" auth.Name=http-basic-auth
panic: runtime error: index out of range [1] with length 1

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing/object.(*Tag).Decode(0xc000416160, {0xac05a0, 0xc00011ebc0})
	/home/peza/DevProjects/go-git/plumbing/object/tag.go:119 +0x7f2
github.com/go-git/go-git/v5/plumbing/object.DecodeTag({0x7f693642e860?, 0xc0000a4300}, {0xac05a0, 0xc00011ebc0})
	/home/peza/DevProjects/go-git/plumbing/object/tag.go:58 +0x7b
github.com/go-git/go-git/v5/plumbing/object.DecodeObject({0x7f693642e860, 0xc0000a4300}, {0xac05a0, 0xc00011ebc0?})
	/home/peza/DevProjects/go-git/plumbing/object/object.go:71 +0xdb
github.com/go-git/go-git/v5/plumbing/object.GetObject({0x7f693642e860, 0xc0000a4300}, {0xbf, 0xba, 0x38, 0x96, 0x52, 0x2a, 0x9e, 0xf, ...})
	/home/peza/DevProjects/go-git/plumbing/object/object.go:57 +0x5d
github.com/go-git/go-git/v5.(*Remote).addReachableTags(0xc000382690, {0xc00011eec0, 0x7, 0x0?}, {0xac05f0, 0xc000381da0}, 0xc0003ba540)
	/home/peza/DevProjects/go-git/remote.go:263 +0x29c
github.com/go-git/go-git/v5.(*Remote).newReferenceUpdateRequest(0x0?, 0xc000487948, {0xc00011eec0, 0x7, 0x8}, {0xac05f0, 0xc000381da0}, 0xc0003a8460)
	/home/peza/DevProjects/go-git/remote.go:342 +0x310
github.com/go-git/go-git/v5.(*Remote).PushContext(0xc000382690, {0xabd748, 0xc00017e3f0}, 0xc000487948)
	/home/peza/DevProjects/go-git/remote.go:168 +0x5a5
github.com/go-git/go-git/v5.(*Repository).PushContext(0xc00011c240?, {0xabd748, 0xc00017e3f0}, 0xc000487948)
	/home/peza/DevProjects/go-git/repository.go:1226 +0x6a
github.com/myhops/ggit/command.(*TagRemoteConfig).pushTags(0xc000000300, {0xabd748, 0xc00017e3f0}, 0xfffffffffffffffc?, {0x9e4d2d, 0x6}, {0xabad18?, 0xc0001898e0?})
	/home/peza/DevProjects/ggit/command/tagremote.go:174 +0x438
github.com/myhops/ggit/command.(*TagRemoteConfig).ExecuteContext(0xc000000300, {0xabd748, 0xc00017e3f0})
	/home/peza/DevProjects/ggit/command/tagremote.go:209 +0x217
github.com/myhops/ggit/command.tagRemoteAction(0xc00017e150)
	/home/peza/DevProjects/ggit/command/tagremotecommand.go:62 +0x3a
github.com/urfave/cli/v3.(*Command).Run(0xc0000d4fc0, {0xabd710?, 0xe812a0}, {0xc000024120, 0x11, 0x12})
	/home/peza/go/pkg/mod/github.com/urfave/cli/v3@v3.0.0-alpha4/command.go:494 +0x1017
main.main()
	/home/peza/DevProjects/ggit/cmd/ggit/main.go:13 +0x3f
exit status 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0