libgit2sharp
libgit2sharp copied to clipboard
KeyNotFoundException when trying to iterate through QueryBy result set.
I'm trying to get all commits that a particular file is associated with. This is the code that I'm running:
IEnumerable<LogEntry> fileHistory = repo.Commits.QueryBy(fileRelativePath);
foreach (LogEntry version in fileHistory){
// do something...
}
The foreach throws a KeyNotFoundException. Any idea on how to overcome this?
I'm using: LibGit2Sharp.0.23.1
Same situation. I definitely have a history of a file, but QueryBy throws an exception
Same issue. But I found a possible reason! If the result contains one commit with a "Slash" in the commit message, then this exception is fired!
I had this with: gitRepo.Commits.QueryBy(projectSubFolder).Take(1).FirstOrDefault() ...and my last commit message contained a Slash. After a new dummy commit in this folder, everything is fine now!
I'm seeing a similar exception while trying to get history of a particular file. There is no special character in the commit message. The KeyNotFoundException occurs in FileHistory.FullHistory:
I'm able to fix this problem by changing the code a little bit:
var currentPath = map.Keys.Count > 0 ? map[currentCommit] : path;
To:
var currentPath = map.Keys.Count > 0 && map.ContainsKey(currentCommit) ? map[currentCommit] : path;
I'm not sure about the root cause for this situation unfortunately. Does that makes sense to submit a PR for that?
Since you can hit this in the debugger - I'd be interested to know what currentCommit
is and what the contents of map
are... Something's confusing this in a way that's not obvious. More data would be helpful, if possible. :)
@ethomson here are some details:
- There are 157 items in the
map
dictionary - The current commit is not in the map
Current commit:
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7a0731b2855ca3d6f4fe5c2613ad7b46926f3822",
"group1": {
"$type": "LibGit2Sharp.Core.GitObjectLazyGroup",
"$tostring": "LibGit2Sharp.Core.GitObjectLazyGroup"
},
"group2": {
"$type": "LibGit2Sharp.Core.GitObjectLazyGroup",
"$tostring": "LibGit2Sharp.Core.GitObjectLazyGroup"
},
"lazyTree": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.LazyWrapper<LibGit2Sharp.Tree>",
"$tostring": "7ca77d5d173785e70adcc4df9ec496ca35d0ba1c"
},
"lazyAuthor": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.Dependent<LibGit2Sharp.Core.Handles.ObjectHandle, LibGit2Sharp.Signature>",
"$tostring": "LibGit2Sharp.Core.LazyGroup`1+Dependent`2[LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Signature]"
},
"lazyCommitter": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.Dependent<LibGit2Sharp.Core.Handles.ObjectHandle, LibGit2Sharp.Signature>",
"$tostring": "LibGit2Sharp.Core.LazyGroup`1+Dependent`2[LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Signature]"
},
"lazyMessage": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.Dependent<LibGit2Sharp.Core.Handles.ObjectHandle, string>",
"$tostring": "LibGit2Sharp.Core.LazyGroup`1+Dependent`2[LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Core.Handles.ObjectHandle,System.String]"
},
"lazyMessageShort": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.Dependent<LibGit2Sharp.Core.Handles.ObjectHandle, string>",
"$tostring": "LibGit2Sharp.Core.LazyGroup`1+Dependent`2[LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Core.Handles.ObjectHandle,System.String]"
},
"lazyEncoding": {
"$type": "LibGit2Sharp.Core.LazyGroup<LibGit2Sharp.Core.Handles.ObjectHandle>.Dependent<LibGit2Sharp.Core.Handles.ObjectHandle, string>",
"$tostring": "LibGit2Sharp.Core.LazyGroup`1+Dependent`2[LibGit2Sharp.Core.Handles.ObjectHandle,LibGit2Sharp.Core.Handles.ObjectHandle,System.String]"
},
"parents": {
"$type": "LibGit2Sharp.Commit.ParentsCollection",
"$values": []
},
"lazyNotes": {
"$type": "System.Lazy<System.Collections.Generic.IEnumerable<LibGit2Sharp.Note>>",
"$tostring": "System.Collections.Generic.List`1[LibGit2Sharp.Note]"
},
"repo": {
"$type": "LibGit2Sharp.Repository",
"$tostring": "LibGit2Sharp.Repository"
},
"Message": "add explanation about assembly version\n",
"MessageShort": "add explanation about assembly version",
"Encoding": "UTF-8",
"Author": {
"$type": "LibGit2Sharp.Signature",
"$tostring": "Jeremy Alles <[email protected]>"
},
"Committer": {
"$type": "LibGit2Sharp.Signature",
"$tostring": "Jeremy Alles <[email protected]>"
},
"Tree": {
"$type": "LibGit2Sharp.Tree",
"$values": []
},
"Parents": {
"$type": "LibGit2Sharp.Commit.ParentsCollection",
"$values": []
},
"Notes": {
"$type": "System.Collections.Generic.List<LibGit2Sharp.Note>",
"$values": []
},
"DebuggerDisplay": "7a0731b",
"Id": {
"$type": "LibGit2Sharp.ObjectId",
"$tostring": "7a0731b2855ca3d6f4fe5c2613ad7b46926f3822"
},
"Sha": "7a0731b2855ca3d6f4fe5c2613ad7b46926f3822",
"LibGit2Sharp.IBelongToARepository.Repository": {
"$type": "LibGit2Sharp.Repository",
"$tostring": "LibGit2Sharp.Repository"
}
}
Content of the map:
{
"$type": "System.Collections.Generic.Dictionary<LibGit2Sharp.Commit, string>.KeyCollection",
"$values": [
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0317511a96519ada38e10febafcccd0f3402ed7b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0cc3a6566a4e54f9bf67284d3cbcea441112daf1"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "e3ae99b2afa24ff9948baa402dbd1dca9f8bfd42"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ce5b704d7c652bbe253e541caf70af1b96b2a8f0"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "6ec999fe597b85a79c09970ca73efb61a6746dc6"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7698fef4b97ea9f1ba573cfab265f15c7c3a4208"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8585fa937ed017d55faa59fc078c20aaaeb6d65b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "437372484a8d479ba6c81f63558080ceac1999f1"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "3f39cdc8a7fb7582136c8a6b331321bda70eac50"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "bb3734c1e14fe8391f94d7c9d472aea40eb27742"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "013b44ec8391b7d3d79b591aa06fb3cd9b7ccbc8"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "1eb12f13886228839a00608dd0425d00733013c9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "24ffb06fb5b5dd1d63eea9bf47051da689f3dbdb"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "32ca9d9059efa5a6515269472849358d8156fe02"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ec9a49d7e3acb63a80cd1d4265c3f7acd4eeb07a"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4d7149000c37851b5b84a05560687d78d48175dd"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "23bf69f63814e6f3fb6cd8d70f33bbc8c8aa77d8"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7f9eedd11c43b0af5e75c4737acbbe8c6518d47a"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "fdaa161d7d813edd2df0e4e8243130ea93e446d9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a52ec4f6d9aa54e9ed3f3db7de0c0e86bbd1b286"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "cb6145e9548bd81baebeca3a091c98936173700b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b221a2cf765ec2f4a03613ba24a98473c6324e0f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0a6bfaff22563cc97a78ee6a996458a1286838cf"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ba8d348621b74af252d4a2d1ebf43d1dd64649d7"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "e8c4308e7614d6afd26200071e565f5fc5c61db6"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "fdde0e1a4cb631387c50225f36ce5a8a6a7637af"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "96ba063dda191173a0849bd7c80da34920b01a00"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b1cd59373f5439c6300f60c32bae3eca5f2a539f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c9780a0b025140aa1b8fab837dc41e9f08de0e41"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b30e7ab6f8d5dfb24db5ec1506e4a8e69f8df3d2"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b83fbafb1000b17bcc7651fc669c49e69c9bcf99"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7b18446650b1c0ec3a55ae71094603e520d40afe"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c701d1c54605a84d1761b8d398d0c624453adbd3"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0e266f5c7409d2638b5e836be2548b7979299971"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0a885dd01283ffea2939641938a8cacc9c932454"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "5aa8a28443fabe5d482dca6703511bab7543734a"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "3cc7976586d2ab19e203882aec1ebed55c09a427"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "5f8a48fe6f49a8a0dfa5f348a9dcb22bf058a7b5"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "fe15e053e623d22747a579efb28474dee5def058"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "00cac270167034e73630a93fa0bb6de0a69ec213"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7bbc25e6fc9ac7ae9dfab44b328cedceba3a0acc"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "2610db1a3b5620618a4bf853361428bbd5f624da"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "015952804f9b1d9edb89791b111f86fc3a295bf1"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4f7042406236651ae33e3c72fe46759858e51846"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "97d4c79cf07e9d7b06878c992c9640e2008cbdb8"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "009b3cf357bcfcc657332910233b5f819f3c82d5"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4f95738f544c799296fddd7fe40ac5181d2e1791"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "812be71b532c4c41e994a5bb9bd0b096416749d3"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "cf271d9a4f1c0821a3a4f9de0a07a557a67cc257"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "bea7860dfff7b316b0451a3e62d545ad08876915"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "014a2a779da2f92978463f24c4e41d02b0252785"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a1214c167bea4e6ed405d4168027b79c6162a370"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c0f6fe7fc386732978fc496462bd357415e11e62"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "2c24ac149c3b09a0b1a14e56069e4f5d098b997d"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "375924e4003f70fa986fa9ab0733c563760b314f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c81ec54f346d9c3502831ca7a1b432c65e0a77cb"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b91a7b98afd406c62fdf18596979de04604e573f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "6d4c48dbf8f39141ed3ed0f5a8d57cb3a2930fd8"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "80b414dfb88c3a0a5f5bd588a0f60f20c4d33fe9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "5c7a9fe5dacb35846c17a4f92c9f4430b3984c90"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "065eb6efd8e0c2b60256566d4a164fb3380b9a5c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "61040f5589336c4883da98192b634654c1663df4"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d7004de518a153c52e7f6001047592d7865f39ba"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4862a3104fe2ba6fee0073b06573141339389e04"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "49ae8e8d79f5ffb6083837f73810f633be16c72c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f84b62980dcbd618bc91c609a5d0fba27b390f2e"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "2e955ee41aecdd0f1b04ba1a1c00b62e9699a087"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "edb751feec4ec604e5227a0b7f8623df2196657c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "674d9127931bc68a6396e7922727b8f3e5655f5b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8aeaabbf5f1642c6342fca8ed4ed83154ec1b833"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "20998b4aa70d33a55829398ff224106ad5b643b9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "be033c9eaa21b3be905d45ed7d1535bec28b04ed"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "44c7e11d361c842fa0dac46b64a48967c8998569"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "367f97b4bd511ac5ebe60d62dde72c5f6acc8f60"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "442c7d8b0c61bad3d0cf5e0e0f9383a7ae950369"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c8ac55fd30838309488ffd7a650a1dc1342ce977"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "80b38ebd4c988535d21d1e84d379d088a115b684"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "990e1910e19dec62d8c430b610e90eabf17096df"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c5bd4c6fef0498b12ce364d142bad1fe960d96d7"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "84d2711d1b7882ff2010a37a5d1f40fa88654509"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "75e7f879056a28e79b4295082d769a438ca68df2"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a5bfdef4356321ed136a7fd24d4e6922d9c9ade6"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9e4fffdc76b0482d51132668a066d908ace931fc"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "afcf270ec41e1babea971554045cc483056a5ba0"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9f745571c0471ae17ea6e0c6a6957bec29ffe976"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8aea4aaf729578d75b605ffafd0c69756fb76932"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "1dd0c5cfa406f223cd077f8bbadad6c6578ff59b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "6c3d7468b0bd46e40d9ade1a4de96c34bce65de5"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ee76924940b9b0ceeaee8acaa61319c230e01571"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "92897af703ebb4d9380f282b5b384179d5a0953b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8112fe1c1237760bb0445348ea040da85351f5e2"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "039d26c3c50c99aeb70c84dcdb384ca62c1e547d"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a8c6b3d919425cefca7539409b002ab92e5dbab3"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4f1cc5ac985755319ba469d1912fb62151f123b5"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "82ba55f2475170027b12af54f41f1fa2b0d71b99"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9dfed0aec8f8f61bc69c8733528f90580c6005fd"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "6ec8df84cd6b95f52a46961af55eb34d9a96a091"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "6d88e3514190b0fb85b045dd95a7372a86f7097b"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f93c37565c09c528fe7719009511229473abbf53"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "dc044431deebd22b1838728f8caa1a961a3f412a"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9a385d6326779e34da96ae637e50819c5fddfa43"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "2c952c19f40d11692d62f99cbe3d1d0276b21c43"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "aeadd3c5a31a16e6f0f2d0e2eed22c81fe144be6"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4a47ccf66786a85062832fa154177eb6ce24efb9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "070ffb8066aa02b49c51fa994f374c330ff3e1d4"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d25db3c0efbf0f9b61afe7592a4e557da1457ba0"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "62237815c10d4db4890d70e4fece41c6f6dabc98"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "798f5f200b29919c9515eef82cb125d81d81e30d"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "e0b9580cf87af6689ef3d6d0f57ff64b8070dc7f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "59a19dcaf6427331939bb90db6fa21dcbefefb12"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "e7405b191da4d9ef9b7fcf747443c8e3b2aabae2"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "766cfded120313654717feabfc4037765bac8be9"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c3146b7aa8ec8a270db085f4ff02a5a0f38bf3d6"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4660f7500eda6f24d919b63be604ed539ef337b5"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7b43d0c8a564a76d201025553eb6af94338e6b85"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b66029adc74d58635650e3f3d2551f7285fdf47f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ffd38d4effc03325d2f15787b4236bf8f2e5089d"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a1a076459391b2dbf13901645a530c9e4d3c30a0"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7776b16732e166fcec87027ab148743edc8cc3cb"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d8c78e2529ae1e1fa96cbcee6c39d79317de0d5e"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f6629b342d13e7e9889aa93fb0fe9a83b14d6bb7"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f78a758b0153f963ccbfc2dc6bc2fa345589701e"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d56be0318d34e47a1144d0e6199bf283a737af10"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0b6343c4daa39e3a76baf434cfaefdd774b7e86a"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "a4c91cf536a910f0686f512480242c11c294c983"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "eb71c34f7bda10c849b46d57fe4f2fff74c21abf"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "4fee16a62ab8218711e06a0865091db1f15daeeb"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "896550fd74d7cded821f497adca3b534129b96b3"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ed7328aadc783dc7d1040d586c7d892c7fb8c128"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9f152c6c27971c22c8f0758127f6efaa041e9dff"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "902646e2dcac5c5f0f17d12bf6a8ecc012517bfa"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "425ceb0e871136d1b81ca073edc146a46d2cbd63"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "1b878b0497fd97675cc1cdcc9ecf226ba6086107"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ad4da81c0eec702c8032227a4e5d878b8945bd82"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8e8a180de9a54d01b207e0ad254009ccad723e68"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "3c688a5ba7faa0d64e85ea7316e109ffc1cd911c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "58a8672b3c8896214c05ee0f3669d91f71f1b070"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "252b6c7c9b33ce6eb403aa62c4b8e48481d4a977"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "ef185c3a2dd15b592fd0c928a1b327635422244c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "1d3b56c55c6ec1ac4b6b2c324f7f421da5c8c01c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "b451e2a39366c182a643e94775ccea053e10b33c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "96055cac0e71f6ce2b832998192898eef73715cb"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "192beb180c074035819099ffbfcc2c47121e1c5f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d9a8c32085db74f9182bfaf7e6d940cf2bc918e1"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f034fba6fe355b7ab52be5ddd4428aa0e8ddfc03"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "314da0261d7f91383941398f2c2b9e9fe928beaa"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "09e403bdbc3425db5645e00b5f6085e64ac04577"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c8c5a3946ecb39f4be678c5d0cd08bb276134fe0"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f7b30ecbf8f9e97ef3fc17af7962f7c73bd3e4bf"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "7ac6e383073b87841dccd1c22fd8bd1060554960"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "f25829ec82494225861642dfec86b007955b6a15"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "c59a9e8c35609a4738694a4ec37fea5a58159d2c"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9abf0d8e0e0ad45e2ec614d0743774f52dabc65f"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "9e628490105c32a9c7c87beca14c06e246b3f882"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "d89138bb54f7c996da2ec6a701623d4e21a383a4"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "8b1c204538d21270cbed476577dc51c859252285"
},
{
"$type": "LibGit2Sharp.Commit",
"$tostring": "0d0106e82d07dfa128e48b02ad24e65587e89b88"
}
]
}
I experienced the KeyNotFoundException as well. After building in the fix suggested by @japf, the exception is avoided. No ill affects detected so far.
I faced the same issue. It is not necessary to change library source code to avoid this issue. It's possible to provide custom CommitFilter with Topological sorting. FullHistory adds each parent of current commit to the map and expects to find each commit on the map. But some commits may appear in the timeline before their children and this leads to KeyNotFoundException. Maybe it's better to allow Topological sorting only? The patch @japf suggested breaks tracking of renamed files.
Specifying Topological sorting does not seem to fix the issue. If anyone wants to take a crack at this, here are a couple of files that reproduce the issue using the latest version on nuget (0.25.2). git-repo.zip Program.cs.txt
Edit: After a closer look, this does not appear to be the same issue, but it is related. My issue is stemming from the fact that I am iterating commits for a specific path from multiple branch starting points. Given the following history for a single file:
* f1e67d1297e470163d3fc9260d895a716076e21f another update for change.sql
| * 3efe5e7c6747323f1b45f5107531c305255decc3 (branch) branch update for change.sql
|/
* b76f581f9dbdd1eed37da13934b4e5155a9cafa7 update change.sql
* f87bd482b7fea6320795f45eff578fe948260f04 initial commit
Iterating repository.Commits.QueryBy("change.sql", new CommitFilter { IncludeReachableFrom = repository.Branches })
will always throw a key not found exception. git log --all --graph --pretty=oneline change.sql
prints the above graph, so it does seem like a bug.
Edit 2: I've opened a new issue #1599 for my problem since it doesn't seem like the same issue and the topological sorting workaround doesn't work in this case.
Hello, I've just started hitting this exact issue in this exact line.
Another - maybe unrelated issue is that there history/log for a file that has only been added and hasn't changed the history is empty - using the QueryBy
filtering api.
The problem is that FileHistory
unconditionally simulates the behaviour of git log --follow
and attempts to track the file renames.
As @ki0ki0 already explained, the code of FullHistory(...)
expects that the query returns the commits in the topological order and we iterate the parents after we iterated at least one of their children.
This rule doesn't hold if you sort by time but the timestamps are not linear (what most people see), or when you sort topologically but there branches in the history (that's what @nickdurcholz sees). Then you get this exception.
In my opinion, the --follow
behaviour should be disabled by default. The library user should explicitly request it when calling Commits.QueryBy(...)
.
It comes with the corner cases and restrictions as mentioned in the git docs and even by the reviewer @nulltoken in the original PR.