1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2015-2018 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "RepositoryFixtures.h"
22 #include "GitRevLoglist.h"
25 class GitRevLoglistCBasicGitWithTestRepoFixture
: public CBasicGitWithTestRepoFixture
29 class GitRevLoglistCBasicGitWithTestRepoBareFixture
: public CBasicGitWithTestRepoBareFixture
33 class GitRevLoglistCBasicGitWithSubmoduleRepoFixture
: public CBasicGitWithSubmoduleRepositoryFixture
37 class GitRevLoglistCBasicGitWithSubmoduleRepoBareFixture
: public CBasicGitWithSubmodulRepoeBareFixture
41 class GitRevLoglist2CBasicGitWithTestRepoFixture
: public CBasicGitWithTestRepoFixture
45 class GitRevLoglist2CBasicGitWithTestRepoBareFixture
: public CBasicGitWithTestRepoBareFixture
49 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglistCBasicGitWithTestRepoFixture
, testing::Values(LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
50 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglistCBasicGitWithTestRepoBareFixture
, testing::Values(LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
51 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglistCBasicGitWithSubmoduleRepoFixture
, testing::Values(LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
52 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglistCBasicGitWithSubmoduleRepoBareFixture
, testing::Values(LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
54 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglist2CBasicGitWithTestRepoFixture
, testing::Values(GIT_CLI
, LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
55 INSTANTIATE_TEST_CASE_P(GitRevLoglist
, GitRevLoglist2CBasicGitWithTestRepoBareFixture
, testing::Values(GIT_CLI
, LIBGIT
, LIBGIT2
, LIBGIT2_ALL
));
57 static void SafeFetchFullInfo(CGit
* cGit
)
60 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
61 EXPECT_EQ(1, rev
.CheckAndDiff());
62 EXPECT_STREQ(L
"", rev
.GetAuthorName());
63 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
64 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
65 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
66 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
67 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
68 rev
.m_IsDiffFiles
= 1;
69 EXPECT_EQ(0, rev
.GetFiles(nullptr).GetCount());
70 EXPECT_EQ(-1, rev
.SafeFetchFullInfo(cGit
));
71 EXPECT_STREQ(L
"", rev
.GetAuthorName());
72 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
73 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
74 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
75 EXPECT_EQ(TRUE
, rev
.m_IsDiffFiles
);
76 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
78 rev
.m_CommitHash
= L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6";
79 rev
.m_IsDiffFiles
= TRUE
;
80 EXPECT_EQ(1, rev
.CheckAndDiff());
81 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
82 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
83 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
84 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
85 EXPECT_STREQ(L
"", rev
.GetAuthorName());
86 rev
.m_IsDiffFiles
= FALSE
;
87 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
88 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
89 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
90 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
91 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
92 EXPECT_EQ(0, rev
.CheckAndDiff());
93 EXPECT_STREQ(L
"", rev
.GetAuthorName());
94 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
95 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
96 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
97 EXPECT_EQ(TRUE
, rev
.m_IsDiffFiles
);
98 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
99 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
100 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
102 list
= rev
.GetFiles(nullptr);
103 EXPECT_STREQ(L
"ascii.txt", list
[0].GetGitPathString());
104 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
105 EXPECT_STREQ(L
"2", list
[0].m_StatAdd
);
106 EXPECT_STREQ(L
"2", list
[0].m_StatDel
);
107 EXPECT_EQ(0, list
[0].m_ParentNo
);
108 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
109 EXPECT_FALSE(list
[0].IsDirectory());
111 rev
.m_CommitHash
= L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6";
112 rev
.m_IsUpdateing
= TRUE
; // do nothing
113 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
114 EXPECT_STREQ(L
"", rev
.GetAuthorName());
115 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
116 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
117 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
118 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
119 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
120 EXPECT_EQ(0U, rev
.GetAction(nullptr));
121 EXPECT_EQ(0, rev
.GetFiles(nullptr).GetCount());
123 rev
.m_CommitHash
= L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6";
124 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
125 EXPECT_STREQ(L
"", rev
.GetAuthorName());
126 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
127 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
128 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
129 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
130 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
131 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
132 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
133 list
= rev
.GetFiles(nullptr);
134 EXPECT_STREQ(L
"ascii.txt", list
[0].GetGitPathString());
135 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
136 EXPECT_STREQ(L
"2", list
[0].m_StatAdd
);
137 EXPECT_STREQ(L
"2", list
[0].m_StatDel
);
138 EXPECT_EQ(0, list
[0].m_ParentNo
);
139 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
141 EXPECT_EQ(0, rev
.GetFiles(nullptr).GetCount());
142 rev
.m_CommitHash
= L
"dead91b4aedeaddeaddead2a56d3c473c705dead"; // non-existent commit
143 EXPECT_EQ(-1, rev
.SafeFetchFullInfo(cGit
));
144 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
145 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
146 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
147 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
148 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
150 rev
.m_CommitHash
= L
"35c91b4ae2f77f4f21a7aba56d3c473c705d89e6";
151 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
152 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
153 ASSERT_EQ(4, rev
.GetFiles(nullptr).GetCount());
154 list
= rev
.GetFiles(nullptr);
155 EXPECT_STREQ(L
"copy/ansi.txt", list
[0].GetGitPathString());
156 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
157 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
158 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
159 EXPECT_EQ(0, list
[0].m_ParentNo
);
160 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
161 EXPECT_STREQ(L
"copy/utf16-be-nobom.txt", list
[1].GetGitPathString());
162 EXPECT_STREQ(L
"", list
[1].GetGitOldPathString());
163 EXPECT_STREQ(L
"-", list
[1].m_StatAdd
);
164 EXPECT_STREQ(L
"-", list
[1].m_StatDel
);
165 EXPECT_EQ(0, list
[1].m_ParentNo
);
166 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[1].m_Action
);
167 EXPECT_STREQ(L
"copy/utf8-bom.txt", list
[2].GetGitPathString());
168 EXPECT_STREQ(L
"", list
[2].GetGitOldPathString());
169 EXPECT_STREQ(L
"1", list
[2].m_StatAdd
);
170 EXPECT_STREQ(L
"1", list
[2].m_StatDel
);
171 EXPECT_EQ(0, list
[2].m_ParentNo
);
172 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[2].m_Action
);
173 EXPECT_STREQ(L
"copy/utf8-nobom.txt", list
[3].GetGitPathString());
174 EXPECT_STREQ(L
"", list
[3].GetGitOldPathString());
175 EXPECT_STREQ(L
"1", list
[3].m_StatAdd
);
176 EXPECT_STREQ(L
"1", list
[3].m_StatDel
);
177 EXPECT_EQ(0, list
[3].m_ParentNo
);
178 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[3].m_Action
);
180 rev
.m_CommitHash
= L
"8d1ebbcc7eeb63af10ff8bcf7712afb9fcc90b8a"; // merge commit
181 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
182 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, rev
.GetAction(nullptr));
183 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
184 list
= rev
.GetFiles(nullptr);
185 EXPECT_STREQ(L
"newfiles3.txt", list
[0].GetGitPathString());
186 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
187 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
188 EXPECT_STREQ(L
"0", list
[0].m_StatDel
);
189 EXPECT_EQ(0, list
[0].m_ParentNo
);
190 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, list
[0].m_Action
);
191 EXPECT_FALSE(list
[0].IsDirectory());
193 rev
.m_CommitHash
= L
"18da7c332dcad0f37f9977d9176dce0b0c66f3eb"; // stash commit
194 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
195 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
196 ASSERT_EQ(2, rev
.GetFiles(nullptr).GetCount());
197 list
= rev
.GetFiles(nullptr);
198 EXPECT_STREQ(L
"newfiles.txt", list
[0].GetGitPathString());
199 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
200 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
201 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
202 EXPECT_EQ(0, list
[0].m_ParentNo
);
203 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
204 EXPECT_FALSE(list
[0].IsDirectory());
205 EXPECT_STREQ(L
"newfiles.txt", list
[1].GetGitPathString());
206 EXPECT_STREQ(L
"", list
[1].GetGitOldPathString());
207 EXPECT_STREQ(L
"1", list
[1].m_StatAdd
);
208 EXPECT_STREQ(L
"1", list
[1].m_StatDel
);
209 EXPECT_EQ(1, list
[1].m_ParentNo
);
210 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[1].m_Action
);
211 EXPECT_FALSE(list
[1].IsDirectory());
213 rev
.m_CommitHash
= L
"844309789a13614b52d5e7cbfe6350dd73d1dc72"; // root commit
214 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
215 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, rev
.GetAction(nullptr));
216 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
217 EXPECT_STREQ(L
"ansi.txt", rev
.GetFiles(nullptr)[0].GetGitPathString());
218 EXPECT_STREQ(L
"", rev
.GetFiles(nullptr)[0].GetGitOldPathString());
220 rev
.m_CommitHash
= L
"4c5c93d2a0b368bc4570d5ec02ab03b9c4334d44"; // signed commit with renamed file last
221 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
222 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
| CTGitPath::LOGACTIONS_MODIFIED
| CTGitPath::LOGACTIONS_REPLACED
| CTGitPath::LOGACTIONS_DELETED
, rev
.GetAction(nullptr));
223 ASSERT_EQ(4, rev
.GetFiles(nullptr).GetCount());
224 list
= rev
.GetFiles(nullptr);
225 EXPECT_STREQ(L
"newfiles2 - Cöpy.txt", list
[0].GetGitPathString());
226 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
227 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
228 EXPECT_STREQ(L
"0", list
[0].m_StatDel
);
229 EXPECT_EQ(0, list
[0].m_ParentNo
);
230 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, list
[0].m_Action
);
231 EXPECT_FALSE(list
[0].IsDirectory());
232 EXPECT_STREQ(L
"utf16-be-nobom.txt", list
[1].GetGitPathString()); // changed from file to symlink
233 EXPECT_STREQ(L
"", list
[1].GetGitOldPathString());
234 EXPECT_STREQ(L
"-", list
[1].m_StatAdd
);
235 EXPECT_STREQ(L
"-", list
[1].m_StatDel
);
236 EXPECT_EQ(0, list
[1].m_ParentNo
);
237 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[1].m_Action
);
238 EXPECT_FALSE(list
[1].IsDirectory());
239 EXPECT_STREQ(L
"utf8-bom.txt", list
[2].GetGitPathString());
240 EXPECT_STREQ(L
"", list
[2].GetGitOldPathString());
241 EXPECT_STREQ(L
"0", list
[2].m_StatAdd
);
242 EXPECT_STREQ(L
"9", list
[2].m_StatDel
);
243 EXPECT_EQ(0, list
[2].m_ParentNo
);
244 EXPECT_EQ(CTGitPath::LOGACTIONS_DELETED
, list
[2].m_Action
);
245 EXPECT_FALSE(list
[2].IsDirectory());
246 EXPECT_STREQ(L
"was-ansi.txt", list
[3].GetGitPathString());
247 EXPECT_STREQ(L
"ansi.txt", list
[3].GetGitOldPathString());
248 EXPECT_STREQ(L
"0", list
[3].m_StatAdd
);
249 EXPECT_STREQ(L
"0", list
[3].m_StatDel
);
250 EXPECT_EQ(0, list
[3].m_ParentNo
);
251 EXPECT_EQ(CTGitPath::LOGACTIONS_REPLACED
, list
[3].m_Action
);
252 EXPECT_FALSE(list
[3].IsDirectory());
254 rev
.m_CommitHash
= L
"31ff87c86e9f6d3853e438cb151043f30f09029a"; // commit with renamed file first
255 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
256 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
| CTGitPath::LOGACTIONS_MODIFIED
| CTGitPath::LOGACTIONS_REPLACED
| CTGitPath::LOGACTIONS_DELETED
, rev
.GetAction(nullptr));
257 ASSERT_EQ(4, rev
.GetFiles(nullptr).GetCount());
258 list
= rev
.GetFiles(nullptr);
259 EXPECT_STREQ(L
"it-was-ansi.txt", list
[0].GetGitPathString());
260 EXPECT_STREQ(L
"ansi.txt", list
[0].GetGitOldPathString());
261 EXPECT_STREQ(L
"0", list
[0].m_StatAdd
);
262 EXPECT_STREQ(L
"0", list
[0].m_StatDel
);
263 EXPECT_EQ(0, list
[0].m_ParentNo
);
264 EXPECT_EQ(CTGitPath::LOGACTIONS_REPLACED
, list
[0].m_Action
);
265 EXPECT_FALSE(list
[1].IsDirectory());
266 EXPECT_STREQ(L
"newfiles2 - Cöpy.txt", list
[1].GetGitPathString());
267 EXPECT_STREQ(L
"", list
[1].GetGitOldPathString());
268 EXPECT_STREQ(L
"1", list
[1].m_StatAdd
);
269 EXPECT_STREQ(L
"0", list
[1].m_StatDel
);
270 EXPECT_EQ(0, list
[1].m_ParentNo
);
271 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, list
[1].m_Action
);
272 EXPECT_FALSE(list
[1].IsDirectory());
273 EXPECT_STREQ(L
"utf16-be-nobom.txt", list
[2].GetGitPathString()); // changed from file to symlink
274 EXPECT_STREQ(L
"", list
[2].GetGitOldPathString());
275 EXPECT_STREQ(L
"-", list
[2].m_StatAdd
);
276 EXPECT_STREQ(L
"-", list
[2].m_StatDel
);
277 EXPECT_EQ(0, list
[2].m_ParentNo
);
278 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[2].m_Action
);
279 EXPECT_FALSE(list
[2].IsDirectory());
280 EXPECT_STREQ(L
"utf8-bom.txt", list
[3].GetGitPathString());
281 EXPECT_STREQ(L
"", list
[3].GetGitOldPathString());
282 EXPECT_STREQ(L
"0", list
[3].m_StatAdd
);
283 EXPECT_STREQ(L
"9", list
[3].m_StatDel
);
284 EXPECT_EQ(0, list
[3].m_ParentNo
);
285 EXPECT_EQ(CTGitPath::LOGACTIONS_DELETED
, list
[3].m_Action
);
286 EXPECT_FALSE(list
[3].IsDirectory());
289 TEST_P(GitRevLoglistCBasicGitWithTestRepoFixture
, SafeFetchFullInfo
)
291 SafeFetchFullInfo(&g_Git
);
294 TEST_P(GitRevLoglistCBasicGitWithTestRepoBareFixture
, SafeFetchFullInfo
)
296 SafeFetchFullInfo(&g_Git
);
299 static void SafeFetchFullInfo_Submodule(CGit
* cGit
, config testConfig
)
303 // for "easy" tests see SafeFetchFullInfo
304 rev
.m_CommitHash
= L
"900539cd24776a94d1b642358ccfdb9d897c8254"; // added submodule
305 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
306 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
307 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
308 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
309 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, rev
.GetAction(nullptr));
310 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
311 list
= rev
.GetFiles(nullptr);
312 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
313 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
314 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
315 EXPECT_STREQ(L
"0", list
[0].m_StatDel
);
316 EXPECT_EQ(0, list
[0].m_ParentNo
);
317 EXPECT_EQ(CTGitPath::LOGACTIONS_ADDED
, list
[0].m_Action
);
318 EXPECT_TRUE(list
[0].IsDirectory());
320 rev
.m_CommitHash
= L
"c8d17f57c7b511aff4aa2fbfae158902281cad8e"; // modified submodule
321 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
322 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
323 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
324 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
325 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
326 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
327 list
= rev
.GetFiles(nullptr);
328 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
329 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
330 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
331 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
332 EXPECT_EQ(0, list
[0].m_ParentNo
);
333 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
334 EXPECT_TRUE(list
[0].IsDirectory());
336 rev
.m_CommitHash
= L
"4ed8d1f9ce9aedc6ad044d9051cb584a8bc294ac"; // deleted submodule
337 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
338 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
339 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
340 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
341 EXPECT_EQ(CTGitPath::LOGACTIONS_DELETED
, rev
.GetAction(nullptr));
342 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
343 list
= rev
.GetFiles(nullptr);
344 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
345 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
346 EXPECT_STREQ(L
"0", list
[0].m_StatAdd
);
347 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
348 EXPECT_EQ(0, list
[0].m_ParentNo
);
349 EXPECT_EQ(CTGitPath::LOGACTIONS_DELETED
, list
[0].m_Action
);
350 EXPECT_TRUE(list
[0].IsDirectory());
352 rev
.m_CommitHash
= L
"2e63f1a55bc3dce074897200b226009f575fbcae"; // submodule to file
353 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
354 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
355 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
356 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
357 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
358 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
359 list
= rev
.GetFiles(nullptr);
360 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
361 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
362 if (testConfig
== LIBGIT2_ALL
) // TODO: libgit behaves differently here
364 EXPECT_STREQ(L
"-", list
[0].m_StatAdd
);
365 EXPECT_STREQ(L
"-", list
[0].m_StatDel
);
369 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
370 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
372 EXPECT_EQ(0, list
[0].m_ParentNo
);
373 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
374 EXPECT_FALSE(list
[0].IsDirectory());
376 rev
.m_CommitHash
= L
"07ac6e5916c03747f7485195deb7ec9100d1c2ef"; // file to submodule
377 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
378 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
379 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
380 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
381 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
382 ASSERT_EQ(1, rev
.GetFiles(nullptr).GetCount());
383 list
= rev
.GetFiles(nullptr);
384 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
385 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
386 if (testConfig
== LIBGIT2_ALL
) // TODO: libgit behaves differently here
388 EXPECT_STREQ(L
"-", list
[0].m_StatAdd
);
389 EXPECT_STREQ(L
"-", list
[0].m_StatDel
);
393 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
394 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
396 EXPECT_EQ(0, list
[0].m_ParentNo
);
397 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
398 EXPECT_FALSE(list
[0].IsDirectory());
400 rev
.m_CommitHash
= L
"2d2017245cf3d016c64e5ad4eb6b0f1bccd1cf7f"; // merge use third
401 EXPECT_EQ(0, rev
.SafeFetchFullInfo(cGit
));
402 EXPECT_EQ(TRUE
, rev
.m_IsFull
);
403 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
404 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
405 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, rev
.GetAction(nullptr));
406 ASSERT_EQ(2, rev
.GetFiles(nullptr).GetCount());
407 list
= rev
.GetFiles(nullptr);
408 EXPECT_STREQ(L
"something", list
[0].GetGitPathString());
409 EXPECT_STREQ(L
"", list
[0].GetGitOldPathString());
410 EXPECT_STREQ(L
"1", list
[0].m_StatAdd
);
411 EXPECT_STREQ(L
"1", list
[0].m_StatDel
);
412 EXPECT_EQ(0, list
[0].m_ParentNo
);
413 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[0].m_Action
);
414 EXPECT_TRUE(list
[0].IsDirectory());
415 EXPECT_STREQ(L
"something", list
[1].GetGitPathString());
416 EXPECT_STREQ(L
"", list
[1].GetGitOldPathString());
417 EXPECT_STREQ(L
"1", list
[1].m_StatAdd
);
418 EXPECT_STREQ(L
"1", list
[1].m_StatDel
);
419 EXPECT_EQ(1, list
[1].m_ParentNo
);
420 EXPECT_EQ(CTGitPath::LOGACTIONS_MODIFIED
, list
[1].m_Action
);
421 EXPECT_TRUE(list
[1].IsDirectory());
424 TEST_P(GitRevLoglistCBasicGitWithSubmoduleRepoBareFixture
, SafeFetchFullInfo
)
426 SafeFetchFullInfo_Submodule(&g_Git
, GetParam());
429 TEST_P(GitRevLoglistCBasicGitWithSubmoduleRepoFixture
, SafeFetchFullInfo
)
431 SafeFetchFullInfo_Submodule(&g_Git
, GetParam());
434 static void SafeGetSimpleList(CGit
* cGit
)
437 EXPECT_EQ(-1, rev
.SafeGetSimpleList(cGit
));
438 EXPECT_STREQ(L
"", rev
.GetAuthorName());
439 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
440 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
441 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
442 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
443 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
444 EXPECT_TRUE(rev
.m_SimpleFileList
.empty());
446 rev
.m_CommitHash
= L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6";
447 rev
.m_IsUpdateing
= TRUE
; // do nothing
448 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
449 EXPECT_STREQ(L
"", rev
.GetAuthorName());
450 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
451 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
452 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
453 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
454 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
455 EXPECT_TRUE(rev
.m_SimpleFileList
.empty());
457 rev
.m_CommitHash
= L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6";
458 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
459 EXPECT_STREQ(L
"", rev
.GetAuthorName());
460 EXPECT_EQ(TRUE
, rev
.m_IsSimpleListReady
);
461 EXPECT_EQ(FALSE
, rev
.m_IsUpdateing
);
462 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
463 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
464 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
465 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
466 EXPECT_STREQ(L
"ascii.txt", rev
.m_SimpleFileList
[0]);
468 rev
.m_CommitHash
= L
"dead91b4aedeaddeaddead2a56d3c473c705dead"; // non-existent commit
469 EXPECT_EQ(-1, rev
.SafeGetSimpleList(cGit
));
470 EXPECT_EQ(FALSE
, rev
.m_IsSimpleListReady
);
471 EXPECT_EQ(TRUE
, rev
.m_IsUpdateing
);
472 EXPECT_EQ(FALSE
, rev
.m_IsFull
);
473 EXPECT_EQ(FALSE
, rev
.m_IsDiffFiles
);
474 EXPECT_EQ(FALSE
, rev
.m_IsCommitParsed
);
475 EXPECT_TRUE(rev
.m_SimpleFileList
.empty());
477 rev
.m_CommitHash
= L
"35c91b4ae2f77f4f21a7aba56d3c473c705d89e6";
478 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
479 EXPECT_EQ(TRUE
, rev
.m_IsSimpleListReady
);
480 ASSERT_EQ(4U, rev
.m_SimpleFileList
.size());
481 EXPECT_STREQ(L
"copy/ansi.txt", rev
.m_SimpleFileList
[0]);
482 EXPECT_STREQ(L
"copy/utf16-be-nobom.txt", rev
.m_SimpleFileList
[1]);
483 EXPECT_STREQ(L
"copy/utf8-bom.txt", rev
.m_SimpleFileList
[2]);
484 EXPECT_STREQ(L
"copy/utf8-nobom.txt", rev
.m_SimpleFileList
[3]);
486 rev
.m_CommitHash
= L
"8d1ebbcc7eeb63af10ff8bcf7712afb9fcc90b8a"; // merge commit
487 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
488 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
489 EXPECT_STREQ(L
"newfiles3.txt", rev
.m_SimpleFileList
[0]);
491 rev
.m_CommitHash
= L
"18da7c332dcad0f37f9977d9176dce0b0c66f3eb"; // stash commit
492 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
493 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
494 EXPECT_STREQ(L
"newfiles.txt", rev
.m_SimpleFileList
[0]);
496 rev
.m_CommitHash
= L
"844309789a13614b52d5e7cbfe6350dd73d1dc72"; // root commit
497 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
498 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
499 EXPECT_STREQ(L
"ansi.txt", rev
.m_SimpleFileList
[0]);
501 rev
.m_CommitHash
= L
"4c5c93d2a0b368bc4570d5ec02ab03b9c4334d44";
502 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
503 ASSERT_EQ(5U, rev
.m_SimpleFileList
.size());
504 EXPECT_STREQ(L
"ansi.txt", rev
.m_SimpleFileList
[0]); // has same hash as was-ansi.txt?!
505 EXPECT_STREQ(L
"newfiles2 - Cöpy.txt", rev
.m_SimpleFileList
[1]);
506 EXPECT_STREQ(L
"utf16-be-nobom.txt", rev
.m_SimpleFileList
[2]);
507 EXPECT_STREQ(L
"utf8-bom.txt", rev
.m_SimpleFileList
[3]);
508 EXPECT_STREQ(L
"was-ansi.txt", rev
.m_SimpleFileList
[4]);
511 TEST_P(GitRevLoglistCBasicGitWithTestRepoFixture
, SafeGetSimpleList
)
513 SafeGetSimpleList(&g_Git
);
516 TEST_P(GitRevLoglistCBasicGitWithTestRepoBareFixture
, SafeGetSimpleList
)
518 SafeGetSimpleList(&g_Git
);
521 static void SafeGetSimpleList_Submodule(CGit
* cGit
)
524 // for "easy" tests see SafeGetSimpleList
525 rev
.m_CommitHash
= L
"900539cd24776a94d1b642358ccfdb9d897c8254"; // added submodule
526 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
527 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
528 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
530 rev
.m_CommitHash
= L
"c8d17f57c7b511aff4aa2fbfae158902281cad8e"; // modified submodule
531 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
532 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
533 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
535 rev
.m_CommitHash
= L
"4ed8d1f9ce9aedc6ad044d9051cb584a8bc294ac"; // deleted submodule
536 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
537 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
538 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
540 rev
.m_CommitHash
= L
"2e63f1a55bc3dce074897200b226009f575fbcae"; // submodule to file
541 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
542 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
543 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
545 rev
.m_CommitHash
= L
"07ac6e5916c03747f7485195deb7ec9100d1c2ef"; // file to submodule
546 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
547 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
548 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
550 rev
.m_CommitHash
= L
"2d2017245cf3d016c64e5ad4eb6b0f1bccd1cf7f"; // merge use third
551 EXPECT_EQ(0, rev
.SafeGetSimpleList(cGit
));
552 ASSERT_EQ(1U, rev
.m_SimpleFileList
.size());
553 EXPECT_STREQ(L
"something", rev
.m_SimpleFileList
[0]);
556 TEST_P(GitRevLoglistCBasicGitWithSubmoduleRepoFixture
, SafeGetSimpleList
)
558 SafeGetSimpleList_Submodule(&g_Git
);
561 TEST_P(GitRevLoglistCBasicGitWithSubmoduleRepoBareFixture
, SafeGetSimpleList
)
563 SafeGetSimpleList_Submodule(&g_Git
);
566 TEST(GitRevLoglist
, IsBoundary
)
569 EXPECT_EQ(FALSE
, rev
.IsBoundary());
571 EXPECT_EQ(TRUE
, rev
.IsBoundary());
573 EXPECT_EQ(FALSE
, rev
.IsBoundary());
576 TEST(GitRevLoglist
, GetUnRevFiles
)
579 EXPECT_EQ(0, rev
.GetUnRevFiles().GetCount());
580 CTGitPathList
& list
= rev
.GetUnRevFiles();
581 list
.AddPath(CTGitPath("file.txt"));
582 EXPECT_EQ(1, rev
.GetUnRevFiles().GetCount());
584 EXPECT_EQ(0, list
.GetCount());
585 EXPECT_EQ(0, rev
.GetUnRevFiles().GetCount());
588 TEST(GitRevLoglist
, GetAction
)
591 EXPECT_EQ(0U, rev
.GetAction(nullptr));
592 auto& action
= rev
.GetAction(nullptr);
594 EXPECT_EQ(5U, rev
.GetAction(nullptr));
596 EXPECT_EQ(0U, action
);
597 EXPECT_EQ(0U, rev
.GetAction(nullptr));
600 static void GetReflog()
603 std::vector
<GitRevLoglist
> revloglist
;
604 EXPECT_EQ(0, GitRevLoglist::GetRefLog(L
"refs/stash", revloglist
, err
));
605 EXPECT_EQ(0U, revloglist
.size());
606 EXPECT_STREQ(L
"", err
);
608 EXPECT_EQ(0, GitRevLoglist::GetRefLog(L
"HEAD", revloglist
, err
));
609 EXPECT_EQ(12U, revloglist
.size());
610 EXPECT_STREQ(L
"", err
);
613 EXPECT_EQ(0, GitRevLoglist::GetRefLog(L
"refs/heads/does-not-exist", revloglist
, err
));
614 EXPECT_EQ(0U, revloglist
.size());
615 EXPECT_STREQ(L
"", err
);
618 EXPECT_EQ(0, GitRevLoglist::GetRefLog(L
"refs/heads/master", revloglist
, err
));
619 ASSERT_EQ(7U, revloglist
.size());
620 EXPECT_STREQ(L
"", err
);
622 EXPECT_STREQ(L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6", revloglist
[0].m_CommitHash
.ToString());
623 EXPECT_STREQ(L
"refs/heads/master@{0}", revloglist
[0].m_Ref
);
624 EXPECT_STREQ(L
"reset", revloglist
[0].m_RefAction
);
625 //EXPECT_STREQ(L"Sven Strickroth", revloglist[0].GetCommitterName());
626 //EXPECT_STREQ(L"email@cs-ware.de", revloglist[0].GetCommitterEmail());
627 EXPECT_STREQ(L
"2015-03-16 12:59:51", revloglist
[0].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
628 EXPECT_STREQ(L
"moving to 7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6", revloglist
[0].GetSubject());
630 EXPECT_STREQ(L
"aa5b97f89cea6863222823c8289ce392d06d1691", revloglist
[2].m_CommitHash
.ToString());
631 EXPECT_STREQ(L
"refs/heads/master@{2}", revloglist
[2].m_Ref
);
632 EXPECT_STREQ(L
"reset", revloglist
[2].m_RefAction
);
633 //EXPECT_STREQ(L"Dümmy User", revloglist[2].GetCommitterName());
634 //EXPECT_STREQ(L"dummy@example.com", revloglist[2].GetCommitterEmail());
635 EXPECT_STREQ(L
"2015-03-16 12:59:07", revloglist
[2].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
636 EXPECT_STREQ(L
"moving to aa5b97f89cea6863222823c8289ce392d06d1691", revloglist
[2].GetSubject());
638 EXPECT_STREQ(L
"df8019413c88d2aedbf33fc2dac3544312da4c18", revloglist
[3].m_CommitHash
.ToString());
639 EXPECT_STREQ(L
"refs/heads/master@{3}", revloglist
[3].m_Ref
);
640 EXPECT_STREQ(L
"commit (amend)", revloglist
[3].m_RefAction
);
641 //EXPECT_STREQ(L"Sven Strickroth", revloglist[3].GetCommitterName());
642 //EXPECT_STREQ(L"email@cs-ware.de", revloglist[3].GetCommitterEmail());
643 EXPECT_STREQ(L
"2015-03-16 12:55:00", revloglist
[3].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
644 EXPECT_STREQ(L
"Several actions", revloglist
[3].GetSubject());
646 EXPECT_STREQ(L
"32c344625f14ecb16b6f003a77eb7a3d2c15d470", revloglist
[4].m_CommitHash
.ToString());
647 EXPECT_STREQ(L
"refs/heads/master@{4}", revloglist
[4].m_Ref
);
648 EXPECT_STREQ(L
"commit", revloglist
[4].m_RefAction
);
649 //EXPECT_STREQ(L"Sven Strickroth", revloglist[4].GetCommitterName());
650 //EXPECT_STREQ(L"email@cs-ware.de", revloglist[4].GetCommitterEmail());
651 EXPECT_STREQ(L
"2015-03-16 12:52:22", revloglist
[4].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
652 EXPECT_STREQ(L
"renamed a file", revloglist
[4].GetSubject());
654 EXPECT_STREQ(L
"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6", revloglist
[5].m_CommitHash
.ToString());
655 EXPECT_STREQ(L
"refs/heads/master@{5}", revloglist
[5].m_Ref
);
656 EXPECT_STREQ(L
"fetch origin +refs/heads/*:refs/heads/*", revloglist
[5].m_RefAction
);
657 //EXPECT_STREQ(L"Dummy author", revloglist[5].GetCommitterName());
658 //EXPECT_STREQ(L"a@example.com", revloglist[5].GetCommitterEmail());
659 EXPECT_STREQ(L
"2015-03-16 12:52:10", revloglist
[5].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
660 EXPECT_STREQ(L
"forced-update", revloglist
[5].GetSubject());
662 EXPECT_STREQ(L
"560deea87853158b22d0c0fd73f60a458d47838a", revloglist
[6].m_CommitHash
.ToString());
663 EXPECT_STREQ(L
"refs/heads/master@{6}", revloglist
[6].m_Ref
);
664 EXPECT_STREQ(L
"push", revloglist
[6].m_RefAction
);
665 //EXPECT_STREQ(L"Sven Strickroth", revloglist[6].GetCommitterName());
666 //EXPECT_STREQ(L"email@cs-ware.de", revloglist[6].GetCommitterEmail());
667 EXPECT_STREQ(L
"2015-03-16 12:51:40", revloglist
[6].GetCommitterDate().FormatGmt(L
"%Y-%m-%d %H:%M:%S"));
668 EXPECT_STREQ(L
"", revloglist
[6].GetSubject());
671 TEST_P(GitRevLoglist2CBasicGitWithTestRepoFixture
, GetReflog
)
676 TEST_P(GitRevLoglist2CBasicGitWithTestRepoBareFixture
, GetReflog
)