1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008, 2014 - TortoiseSVN
4 // Copyright (C) 2008-2017, 2019 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "GitStatusListCtrl.h"
24 #include "ColumnManager.h"
26 // sorter utility class
27 CSorter::CSorter ( ColumnManager
* columnManager
30 : columnManager (columnManager
)
31 , sortedColumn (sortedColumn
)
32 , ascending (ascending
)
34 s_bSortLogical
= !CRegDWORD(L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoStrCmpLogical", 0, false, HKEY_CURRENT_USER
);
36 s_bSortLogical
= !CRegDWORD(L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\NoStrCmpLogical", 0, false, HKEY_LOCAL_MACHINE
);
39 bool CSorter::operator() (const CTGitPath
* entry1
, const CTGitPath
* entry2
) const
41 #define SGN(x) ((x)==0?0:((x)>0?1:-1))
49 result
= entry1
->m_LFSLockOwner
.CompareNoCase(entry2
->m_LFSLockOwner
);
56 __int64 fileSize1
= entry1
->IsDirectory() ? 0 : entry1
->GetFileSize();
57 __int64 fileSize2
= entry2
->IsDirectory() ? 0 : entry2
->GetFileSize();
59 result
= SGN(fileSize1
- fileSize2
);
63 case 6: //Last Modification Date
67 __int64 writetime1
= entry1
->GetLastWriteTime();
68 __int64 writetime2
= entry2
->GetLastWriteTime();
70 result
= SGN(writetime1
- writetime2
);
77 result
= SGN(A2L(entry1
->m_StatDel
) - A2L(entry2
->m_StatDel
));
83 result
= SGN(A2L(entry1
->m_StatAdd
) - A2L(entry2
->m_StatAdd
));
90 result
= entry1
->GetActionName(entry1
->m_Action
).CompareNoCase(entry2
->GetActionName(entry2
->m_Action
));
98 result
= StrCmpLogicalW(entry1
->GetFileExtension(), entry2
->GetFileExtension());
100 result
= StrCmpI(entry1
->GetFileExtension(), entry2
->GetFileExtension());
109 result
= StrCmpLogicalW(entry1
->GetFileOrDirectoryName(), entry2
->GetFileOrDirectoryName());
111 result
= StrCmpI(entry1
->GetFileOrDirectoryName(), entry2
->GetFileOrDirectoryName());
115 case 0: // Full path column
120 result
= StrCmpLogicalW(entry1
->GetGitPathString(), entry2
->GetGitPathString());
122 result
= StrCmpI(entry1
->GetGitPathString(), entry2
->GetGitPathString());
126 } // switch (m_nSortedColumn)
127 // sort by path name as second priority
128 if (sortedColumn
> 0 && result
== 0)
131 result
= StrCmpLogicalW(entry1
->GetGitPathString(), entry2
->GetGitPathString());
133 result
= StrCmpI(entry1
->GetGitPathString(), entry2
->GetGitPathString());