From: Linus Torvalds Date: Fri, 20 May 2005 15:53:23 GMT Subject: Re: "git-diff-tree -R A B == git-diff-tree B A"? Message-ID: In-Reply-To: <7vzmupud54.fsf@assigned-by-dhcp.cox.net> On Fri, 20 May 2005, Junio C Hamano wrote: > > Keep git-diff-tree output sorted in cache order on dir/file swap. No, this is wrong. Or rather, it is incomplete - it gets only a small subset of the interesting cases right. You need to really teach diff-tree about directory sorting, because it is more complicated than you think. The sorting does _not_ just affect files/directories with the same names. It affects files and directories that have the same _beginning_. The only correct way to do name sorting is the one that fsck does in "verify_order()". To realize why, you need to realize that "A" (the directory) sorts _after_ a filename "A file", because '/' sorts after ' '. In contrast, "A" (the directory) sorts _before_ "ABBA" (the band), because '/' sorts before 'B'. -- Side note: Btw, right now I depend on "memcmp()" doing comparisons as "unsigned char", which is supposed to be true, but I don't know whether it's entirely portable. So it might be that I should implement my own "namecmp()" entirely from scratch. Does anybody know if some broken system does "memcmp" ordering on signed chars? Linus