eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
117 stars 33 forks source link

ArrayIndexOutOfBoundsException when doing a git pull #6

Closed pmmitkovv closed 7 months ago

pmmitkovv commented 8 months ago

Version

6.8.0.202311291450-r

Operating System

Linux/Unix, MacOS

Bug description

The issue is caused when doing a git pull that will lead to a merge conflict with the README.md file in my repository(which is part of the initial repository commit if that is relevant). The merge strategy is set to "recursive" - the default one and the pull is done with rebase.

Pull code:

PullResult result = git.pull()
                        .setRemoteBranchName("master")
                        .setTransportConfigCallback(createTransportConfigCallback())
                        .setRebase(true).call();

Stacktrace:

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at org.eclipse.jgit.revwalk.RevCommit.getParent(RevCommit.java:354) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.RebaseCommand.stop(RebaseCommand.java:1070) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.RebaseCommand.cherryPickCommitFlattening(RebaseCommand.java:568) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.RebaseCommand.cherryPickCommit(RebaseCommand.java:532) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.RebaseCommand.processStep(RebaseCommand.java:443) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.RebaseCommand.call(RebaseCommand.java:356) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]
    at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:366) ~[org.eclipse.jgit-6.8.0.202311291450-r.jar:6.8.0.202311291450-r]

Actual behavior

ArrayIndexOutOfBoundsException error

Expected behavior

Possible merge conflict. This is the output when doing the pull from the terminal on the same repository:

➜  local9b5e52ab-fd06-44e4-b0d3-f5afe3f6a2da git:(main) git pull origin master --rebase
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), 245 bytes | 35.00 KiB/s, done.
From https://gitlab-it.sof-mbu.eng.vmware.com/vrouitests/testcontent-push-e2e_git_ckoi_1702975571005
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
error: could not apply 700aedf... Initial commit
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 700aedf... Initial commit

Relevant log output

No response

Other information

No response

tomaswolf commented 7 months ago

See GerritHub change 1174394.

msohn commented 7 months ago

https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1174394 merged as 906c2bebed0dc732a2fbd5b397466cf3522714f0