-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
Version
7.3.0.202506031305-r, 5.6.0.201912101111-r
Operating System
Windows
Bug description
If a file is within the git workspace but not added to git then git blame
with the CLI will throw an error:
$ git status
On branch master
Untracked files:
(use "git add ..." to include in what will be committed)
foo.txtnothing added to commit but untracked files present (use "git add" to track)
$ git blame foo.txt
fatal: no such path 'foo.txt' in HEAD
JGit returns null in this case. Perhaps this should be an exception?
import java.io.File
import org.eclipse.jgit.lib.RepositoryBuilder
import org.eclipse.jgit.api.Git
def repo = new RepositoryBuilder().setWorkTree(new File("$projectDir")).setMustExist(true).build()
def git = new Git(repo)
def blameCommand = git.blame()
blameCommand.setFilePath("foo.txt")
def res = blameCommand.call()
println(res)
Actual behavior
In jgit 5.5.1.201910021850-r a BlameResult was returned with a the file showing up as new
In jgit 5.6.0.201912101111-r and above the behavior changed and null is returned
Expected behavior
Either
- An exception is thrown (since git CLI treats this as an error)
- The meaning of a null result is explicitly documented
Relevant log output
Other information
No response
Metadata
Metadata
Assignees
Labels
No labels