chitresh sirohi
chitresh sirohi

Reputation: 275

IntelliJ's show diff always compare with a same old git commit

This is a strange problem I'm observing in my IntelliJ. The show-diff always compare the current local version with same old commit of git which is NOT the latest commit. Ideally it should compare it with latest commit. If the file was created after that commit then the error is "Not a valid object name ". To bypass this problem I have to RightClick->Git->Compare with and then select latest version. Any clue what could be the issue? I have tried to search this commit id in the IntelliJ project folder but I could'nt find any. Also updated the Git CMD to latest version but no relief.

Upvotes: 2

Views: 441

Answers (1)

Dmitrii Smirnov
Dmitrii Smirnov

Reputation: 7558

To show diff for a file from Local changes IntelliJ calls git log -n1 HEAD -- path/to/file to get hash of the latest revision, and then gets file content with git cat-file -p hash:path/to/file. The latter is the result for Not a valid object name error.

Seems either HEAD is incorrectly resolved by git, which I really doubt, or there is something (e.g. a third-party plugin like Git Scope) that alters the logic.

One more possible reason - a tricky nested Git repo that includes the history up to the problematic commit. In this case, the Diff might be requested from that repo.

You could check the error and all the commands IDE executes enabling debug logging (use Help - Debug Log Settings...) for #git4idea.commands.GitHandler.

Upvotes: 3

Related Questions