[go: up one dir, main page]

Skip to content

Panic on `=Z delete`

reposurgeon built from tag 4.38 (also tried with current master but ran into #428 (closed) instead)

Situation

I was trying to split off everything within a certain directory of an existing git repository into a separate repo.

The directory started its life as api/, has later been moved to software/api/ for some time but recently has been moved back to api/.

When using the following script, reposurgeon 4.38 crashes on =Z delete.

Unfortunately I cannot share the original git repository for corporate reasons, but maybe my steps before =Z delete may give a hint on what's broken? If not, I may try to find a way to reproduce with a synthetic test repo.

set progress echo
logfile reposurgeon-api.log

# read git repository
read /path/to/local/git/repo

# delete all non-local tags and branches
branch delete @^refs/heads/@ --not

# discard all file changes that do not touch anything in software/api/ or api/ (keep global .gitignore)
expunge --not @^(software/)?api/|^.gitignore$@ --notagify

# delete api/.gitignore to prevent collision with global .gitignore in next step
expunge @^(software/)?api/.gitignore$@ --notagify

# move everything to root directory
path rename @^(software/)?api/@ ""

# These two commits contained renames (=MODIFY <new name> + DELETE <old name>)
# of files from software/api/<foo> to api/<foo>.
# Since after "path rename" from previous step new and old name are identical now,
# those commits would end up deleting api files instead.
# So remove all DELETE ops from those commits and keep only the MODIFYs:
/move api procect to root (and edit some files)/  remove deletes
/merge branch 'move-api-to-root' into 'master'/   remove deletes

# delete all commits that are now without fileops (e.g. because they only modified files outside of api/)
=Z delete   # <-- panic here!

# write new git repository
write /path/to/new/repo/
reposurgeon% =Z delete
=Z delete
panic: runtime error: makeslice: cap out of range [recovered]
        panic: runtime error: makeslice: cap out of range [recovered]
        panic: runtime error: makeslice: cap out of range

goroutine 1 [running]:
main.main.func1()
        /home/florian/projects/3rdparty/reposurgeon/surgeon/reposurgeon.go:7767 +0x11c
panic({0x8a4d00?, 0x9fa7d0?})
        /usr/local/go1.21.3.linux-amd64/src/runtime/panic.go:914 +0x21f
main.catch({0x913c9b?, 0x40?}, {0x8a4d00, 0x9fa7d0?})
        /home/florian/projects/3rdparty/reposurgeon/surgeon/inner.go:128 +0x12c
main.(*Reposurgeon).SetCore.func1.1(0xc0004d5c4e)
        /home/florian/projects/3rdparty/reposurgeon/surgeon/reposurgeon.go:479 +0x3c
panic({0x8a4d00?, 0x9fa7d0?})
        /usr/local/go1.21.3.linux-amd64/src/runtime/panic.go:914 +0x21f
main.(*Repository).scavenge(0xc00025a000, 0x178, {0x91970a, 0xd})
        /home/florian/projects/3rdparty/reposurgeon/surgeon/inner.go:6488 +0x72
main.(*Repository).squash(0xc00025a000, {0xc0355655b0}, {0xc035565590, 0x1, 0x881560?}, 0x0?)
        /home/florian/projects/3rdparty/reposurgeon/surgeon/inner.go:6844 +0x1266
main.(*Reposurgeon).DoDelete(0xc0000a0000, {0xc069fe7bf3?, 0x1?})
        /home/florian/projects/3rdparty/reposurgeon/surgeon/reposurgeon.go:3325 +0x165
gitlab.com/ianbruene/kommandant.(*Kmdt).bind.func1({0x9ff140?, 0xc0001d4420?}, {0xc069fe7bf3, 0x0})
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:296 +0x4f
gitlab.com/ianbruene/kommandant.(*Kmdt).OneCmd_core(0xc0000a62c0, {0x9ff140, 0xc0001d4420}, {0xc069fe7bf3?, 0x0?})
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:711 +0x369
main.(*Reposurgeon).SetCore.func1({0x9ff140?, 0xc0001d4420?}, {0xc069fe7bf3?, 0xc069fe7bf3?})
        /home/florian/projects/3rdparty/reposurgeon/surgeon/reposurgeon.go:484 +0x8a
gitlab.com/ianbruene/kommandant.(*Kmdt).OneCmd(0xc0000a62c0, {0x9ff140, 0xc0001d4420}, {0xc069fe7bf3, 0x6})
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:251 +0x109
gitlab.com/ianbruene/kommandant.(*Kmdt).CmdLoop(0xc0000a62c0, {0x9ff140, 0xc0001d4420}, {0x0, 0x0})
        /home/florian/go/pkg/mod/gitlab.com/ianbruene/kommandant@v0.6.2/kommandant.go:636 +0x7c5
main.main()
        /home/florian/projects/3rdparty/reposurgeon/surgeon/reposurgeon.go:7798 +0x525
Edited by Florian Karuhtz