Browse Source
getRef() loops over its search path to find a ref: Ref ref = null; for (String prefix : SEARCH_PATH) { ref = readRef(prefix + needle, packed); if (ref != null) { ref = resolve(ref, 0, null, null, packed); break; } } fireRefsChanged(); return ref; If readRef returns null (indicating that the ref does not exist), the loop continues so we can find the ref later in the search path. And resolve should never return null, so if we return null it should mean we exhausted the entire search path and didn't find the ref. ... except that resolve can return null: it does so when it has followed too many symrefs and concluded that there is a symref loop: if (MAX_SYMBOLIC_REF_DEPTH <= depth) return null; // claim it doesn't exist Continue the loop instead of returning null immediately. This makes the behavior more consistent. Arguably getRef should throw an exception when a symref loop is detected. That would be a more invasive change, so if it's a good idea it will have to wait for another patch. Change-Id: Icb1c7fafd4f1e34c9b43538e27ab5bbc17ad9eef Signed-off-by: Jonathan Nieder <jrn@google.com>stable-4.3
Jonathan Nieder
9 years ago
2 changed files with 32 additions and 0 deletions
Loading…
Reference in new issue