jgit/org.eclipse.jgit/src/org/eclipse/jgit
Dmitrii Filippov cb9f058f9b Fix crashes on rare combination of file names
The NameConflictTreeWalk class is used in merge for iterating over
entries in commits. The class uses a separate iterator for each
commit's tree. In rare cases it can incorrectly report the same entry
twice. As a result, duplicated entries are added to the merge result
and later jgit throws an exception when it tries to process merge
result.

The problem appears only when there is a directory-file conflict for
the last item in trees. Example from the bug:
Commit 1:
* subtree - file
* subtree-0 - file
Commit 2:
* subtree - directory
* subtree-0 - file
Here the names are ordered like this:
"subtree" file <"subtree-0" file < "subtree" directory.

The NameConflictTreeWalk handles similar cases correctly if there are
other files after subtree... in commits - this is processed in the
AbstractTreeIterator.min function. Existing code has a special
optimization for the case, when all trees are pointed to the same
entry name - it skips additional checks. However, this optimization
incorrectly skips checks if one of trees reached the end.

The fix processes a situation when some trees reached the end, while
others are still point to an entry.

bug: 535919
Change-Id: I62fde3dd89779fac282479c093400448b4ac5c86
2022-11-29 10:49:27 +01:00
..
annotations Update EDL 1.0 license headers to new short SPDX compliant format 2020-01-04 01:10:05 +01:00
api [pgm] Add options --name-only, --name-status to diff, log, show 2022-11-23 16:12:54 +01:00
attributes [checkout] Use .gitattributes from the commit to be checked out 2022-03-07 18:45:25 +01:00
blame Revert "Option to pass start RevCommit to be blamed on to the 2022-09-06 10:40:26 +02:00
diff RawText.isBinary(): handle complete buffer correctly 2022-11-16 15:17:19 -05:00
dircache DirCacheCheckout#getContent: also take InputStream supplier 2022-09-06 14:38:41 +02:00
errors Silence API errors 2022-11-20 19:55:22 +01:00
events Use Map interface instead of ConcurrentHashMap class 2021-01-01 12:49:05 -05:00
fnmatch Fix ProtectedMembersInFinalClass warning flagged by error prone 2020-06-04 16:24:16 +02:00
gitrepo BaseSuperprojectWriter: report invalid paths as manifest errors 2022-08-23 12:10:27 -07:00
hooks [push, lfs] Tell the pre-push hook whether the push is a dry run 2022-03-23 18:55:31 -04:00
ignore IgnoreNode: include path to file for invalid .gitignore patterns 2021-02-23 22:11:01 +01:00
internal DfsBlockCache: Report IndexEventConsumer metrics for reverse indexes. 2022-11-17 12:38:48 -05:00
lib Merge branch 'stable-6.3' 2022-11-16 10:15:30 +01:00
logging Fix bug in PerformanceLogContext 2020-11-06 19:20:08 -04:00
merge Fix API breakage caused by extracting WorkTreeUpdater 2022-11-15 15:18:38 +01:00
nls Use Map interface instead of ConcurrentHashMap class 2021-01-01 12:49:05 -05:00
notes Remove redundant type arguments 2021-09-30 09:31:12 +02:00
patch Fix warning about non-externalized String 2022-11-20 20:30:45 +01:00
revplot PlotCommit: Suppress ReferenceEquality Warnings 2022-04-01 17:27:42 -04:00
revwalk Revert "Adds FilteredRevCommit that can overwrites its parents in the 2022-09-06 10:40:26 +02:00
storage Remove stray files (probes or lock files) created by background threads 2022-05-27 01:20:16 +02:00
submodule Ensure .gitmodules is loaded when accessing submodule name 2020-10-25 22:24:17 +01:00
transport Merge branch 'stable-6.3' 2022-11-20 20:24:14 +01:00
treewalk Fix crashes on rare combination of file names 2022-11-29 10:49:27 +01:00
util Merge branch 'stable-6.3' 2022-11-20 20:24:14 +01:00