Missing commits from git4idea.history.GitHistoryUtils call

Hi,

I used the following code to get the commits from local git repo and branch:

GitRepository repository = GitRepositoryManager.getInstance(project).getRepositories().get(0);
this.branchName = repository.getCurrentBranchName();
List<GitCommit> commits = GitHistoryUtils.history(project, repository.getRoot(), this.branchName);

However, some of the commits are missing from the history call, some of the merge commits to be exact. Not all the merge commits are missing, but some of them.

0
7 comments

This method delegates to the `git log branchName` command, so it should return same commits as git itself. You can check if missing commits present in the output when command is executed via command line.

One possible cause is that they were filtered out by git. You can try adding `--full-history` to the parameters.

0
Avatar
Permanently deleted user

Here is the code snippet:

GitRepository repository = GitRepositoryManager.getInstance(project).getRepositories().get(0);
this.branchName = repository.getCurrentBranchName();
List<GitCommit> commits = GitHistoryUtils.history(project, repository.getRoot(), this.branchName);
System.out.println("Branch name: " + this.branchName);
for (int i = 0; i < 30; i ++) {
System.out.println("Commit ID #" + i + ": " + commits.get(i).getId().asString());
}

Here is the output on a local repo's master branch:

Branch name: master
Commit ID #0: c39e2286265a47a11f6bab2d3a57f08699a3a100
Commit ID #1: 0db21ad34b9be0e92d372b7920dbdcadf32154bb
Commit ID #2: 4946df563b14363bd55ae24c7785421e753fcc8f
Commit ID #3: 87c58a0ea24acfe33284ae0a63e6b2e733c6f8d8
Commit ID #4: 230fb8bc250991c208a111f5c2f319326782f715
Commit ID #5: 7e5bde4341b0374d3ff8224233d6e33b64c2899f
Commit ID #6: e35458c9a788d6da4461f998bfa64a8b9280dc75
Commit ID #7: a8cff8ebe15ba09daf651b72efaf34a6e4422f92
Commit ID #8: 8300f3270f34934e00b234187efaceafee7560a8
Commit ID #9: 97242dc31a9c6ffd2d9b5c9ed7054748e5ed009c
Commit ID #10: a1166731ef9a421d8c543cad4b9e9e54b36c66cb
Commit ID #11: 05473114e1e5c544c444fdf6d42ccbc1c83f933e
Commit ID #12: a8ff76eb9171fe7446bf96631d354aaf57b2e88b
Commit ID #13: 7b0af8859494c9e3f509062730a9285cafa630f5
Commit ID #14: 47068f09a7c9a1a69bbacee13890e12c510539c9
Commit ID #15: 7833855811dfad5d1916fbba7d3f12f08af8d6cc
Commit ID #16: 7d3efcd9679d9827888ffb11271b568a47ca168f
Commit ID #17: afbc5c4dfa1dc739ef97419beabcfaaeabd8f739
Commit ID #18: 234980e662ffc046604df8d3011d1cc3c8e99d85
Commit ID #19: bd08ec264f2b87500a1728859005283cbb445e5a
Commit ID #20: f95b72e367557ac4859893401c6d4600d0399422
Commit ID #21: ae40fdea5f5e3e772fe8e2fad6d6826ace562e02
Commit ID #22: 873df066e18ecca199a54be6079c74e09ccdf177
Commit ID #23: ef53d4c41dfb82b1965ea5e5ed5ce8fa03661878
Commit ID #24: ede9d60a0d520b70e00a659dd653f8682236c458
Commit ID #25: 98179fbdeb8f45e2f76d5c0738cf078d0d1e42e5
Commit ID #26: 920c375956ceda13b69195b87281909d6c18eb98
Commit ID #27: 6c36aaeb7d5269b4124e633b8ce03f2c741af459
Commit ID #28: 70b72f460e7a529f3cd5f154ed96ff290c770a4b
Commit ID #29: 9206b00eb21afbdd5610d2b24b791ee0a59da718

Here is the output of git command from local repo:

>git branch --list
  dev
* master

>git log master --full-history | grep "^commit" | more
commit 975a20a00c4442d0100064e14e994b22eebae013
commit c39e2286265a47a11f6bab2d3a57f08699a3a100
commit 0db21ad34b9be0e92d372b7920dbdcadf32154bb
commit 4946df563b14363bd55ae24c7785421e753fcc8f
commit 87c58a0ea24acfe33284ae0a63e6b2e733c6f8d8
commit 230fb8bc250991c208a111f5c2f319326782f715
commit 7e5bde4341b0374d3ff8224233d6e33b64c2899f
commit e35458c9a788d6da4461f998bfa64a8b9280dc75
commit a8cff8ebe15ba09daf651b72efaf34a6e4422f92
commit 8300f3270f34934e00b234187efaceafee7560a8
commit 97242dc31a9c6ffd2d9b5c9ed7054748e5ed009c
commit a1166731ef9a421d8c543cad4b9e9e54b36c66cb
commit 05473114e1e5c544c444fdf6d42ccbc1c83f933e
commit a8ff76eb9171fe7446bf96631d354aaf57b2e88b
commit 7b0af8859494c9e3f509062730a9285cafa630f5
commit 47068f09a7c9a1a69bbacee13890e12c510539c9
commit 7833855811dfad5d1916fbba7d3f12f08af8d6cc
commit b5bae929aaece38d6d9c5c2708106f9801209d60
commit 7d3efcd9679d9827888ffb11271b568a47ca168f
commit afbc5c4dfa1dc739ef97419beabcfaaeabd8f739
commit 234980e662ffc046604df8d3011d1cc3c8e99d85
commit bd08ec264f2b87500a1728859005283cbb445e5a
commit f95b72e367557ac4859893401c6d4600d0399422
commit ae40fdea5f5e3e772fe8e2fad6d6826ace562e02
commit 873df066e18ecca199a54be6079c74e09ccdf177
commit 2adf5006c4debc011f6572d84513d35e6b857601
commit ef53d4c41dfb82b1965ea5e5ed5ce8fa03661878
commit bca5706eb930e5fd7b43a911d363ddbdf84f9441
commit ede9d60a0d520b70e00a659dd653f8682236c458
commit 98179fbdeb8f45e2f76d5c0738cf078d0d1e42e5
commit 920c375956ceda13b69195b87281909d6c18eb98
commit 6c36aaeb7d5269b4124e633b8ce03f2c741af459
commit 70b72f460e7a529f3cd5f154ed96ff290c770a4b
commit 9206b00eb21afbdd5610d2b24b791ee0a59da718

I highlighted the missing commits.

0

The method does not path --full-history flag to git. So you should compare the code output to git log master | grep "^commit" | more

0
Avatar
Permanently deleted user

>git log master | grep "^commit" | more
commit 975a20a00c4442d0100064e14e994b22eebae013
commit c39e2286265a47a11f6bab2d3a57f08699a3a100
commit 0db21ad34b9be0e92d372b7920dbdcadf32154bb
commit 4946df563b14363bd55ae24c7785421e753fcc8f
commit 87c58a0ea24acfe33284ae0a63e6b2e733c6f8d8
commit 230fb8bc250991c208a111f5c2f319326782f715
commit 7e5bde4341b0374d3ff8224233d6e33b64c2899f
commit e35458c9a788d6da4461f998bfa64a8b9280dc75
commit a8cff8ebe15ba09daf651b72efaf34a6e4422f92
commit 8300f3270f34934e00b234187efaceafee7560a8
commit 97242dc31a9c6ffd2d9b5c9ed7054748e5ed009c
commit a1166731ef9a421d8c543cad4b9e9e54b36c66cb
commit 05473114e1e5c544c444fdf6d42ccbc1c83f933e
commit a8ff76eb9171fe7446bf96631d354aaf57b2e88b
commit 7b0af8859494c9e3f509062730a9285cafa630f5
commit 47068f09a7c9a1a69bbacee13890e12c510539c9
commit 7833855811dfad5d1916fbba7d3f12f08af8d6cc
commit b5bae929aaece38d6d9c5c2708106f9801209d60
commit 7d3efcd9679d9827888ffb11271b568a47ca168f
commit afbc5c4dfa1dc739ef97419beabcfaaeabd8f739
commit 234980e662ffc046604df8d3011d1cc3c8e99d85
commit bd08ec264f2b87500a1728859005283cbb445e5a
commit f95b72e367557ac4859893401c6d4600d0399422
commit ae40fdea5f5e3e772fe8e2fad6d6826ace562e02
commit 873df066e18ecca199a54be6079c74e09ccdf177
commit 2adf5006c4debc011f6572d84513d35e6b857601
commit ef53d4c41dfb82b1965ea5e5ed5ce8fa03661878
commit bca5706eb930e5fd7b43a911d363ddbdf84f9441
commit ede9d60a0d520b70e00a659dd653f8682236c458
commit 98179fbdeb8f45e2f76d5c0738cf078d0d1e42e5
commit 920c375956ceda13b69195b87281909d6c18eb98
commit 6c36aaeb7d5269b4124e633b8ce03f2c741af459
commit 70b72f460e7a529f3cd5f154ed96ff290c770a4b
commit 9206b00eb21afbdd5610d2b24b791ee0a59da718

The git command shows no difference with or without --full-history.

0

This is not a known issue, so you might have to debug `GitHistoryUtils`.

Are there any related warnings in IDE log ?
Is there are anything unusual/common about missing commits (ex: author, affected files, commit message - ASCII control sequences, "\u0001-3" UTF symbols) ?
Do you use same environment (ex: git version, git repository root) for IDE and command line?
Could some option in git config affect its output?

0

Another possibility is that these commits are reported out-of-order. Ex: last in the request or few thousands commits later.

0

There is a bug in this method: under specific conditions some merge commits appear out of order in the commits list returned by this method. So probably the missing commits are somewhere at the end of the list. There is an issue IDEA-186772 about it (our code that compares branches uses `GitHistoryUtils.history` method as well). You can follow the issue to get notified about the fix.

0

Please sign in to leave a comment.