Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-25 Thread Junio C Hamano
Jeff King writes: > But we can also do that with a hash table, or an auxiliary sorted array. > And sure enough, that's exactly what the rename_dst array is. > ... > which I think is a pretty simple and sane fix. Yeah, good observation. > So to go forward, I'm happy to prepare a patch, but I'd l

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-25 Thread Jeff King
On Tue, Feb 24, 2015 at 09:00:20PM -0800, Junio C Hamano wrote: > Jeff King writes: > > > 3. The sort order check is wrong. :-/ It needs to take into account > > git's magic "if it's a tree, pretend it has '/' after it" rule. > > That's not too hard for a single tree (fsck.c:verify_o

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Junio C Hamano
Jeff King writes: > 3. The sort order check is wrong. :-/ It needs to take into account > git's magic "if it's a tree, pretend it has '/' after it" rule. > That's not too hard for a single tree (fsck.c:verify_ordered does > it). But for filepairs, I'm not sure what to do. Most ca

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Jeff King
On Tue, Feb 24, 2015 at 03:11:00PM -0800, Junio C Hamano wrote: > Jeff King writes: > > > I'm assuming there _is_ a sane sort order. We have two halves of a > > filepair, but I think before any of the rename or break detection kicks > > in, each pair should either: > > > > 1. Have a name in pa

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Junio C Hamano
Jeff King writes: > I'm assuming there _is_ a sane sort order. We have two halves of a > filepair, but I think before any of the rename or break detection kicks > in, each pair should either: > > 1. Have a name in pair->one, and an invalid filespec in pair->two > (i.e., a deletion). > >

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Jeff King
On Tue, Feb 24, 2015 at 02:42:42PM -0800, Junio C Hamano wrote: > > That does fix this problem, and it doesn't break any other tests. But > > frankly, I don't know what I'm doing and this feels like a giant hack. > > > > Given that this is tangentially related to the "-B -M" stuff you've been > >

Re: [BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Junio C Hamano
Jeff King writes: > I ran across a real-world case where git segfaults on some trees that > have duplicate entries. Those trees are obviously broken, and I'm fine > with us producing whatever output we like on them. But probably we > shouldn't segfault. Thanks. > ... > That does fix this proble

[BUG] diffcore-rename with duplicate tree entries can segfault

2015-02-24 Thread Jeff King
I ran across a real-world case where git segfaults on some trees that have duplicate entries. Those trees are obviously broken, and I'm fine with us producing whatever output we like on them. But probably we shouldn't segfault. Basically what happens is that the rename_dst array maps paths to diff