format and remove not needed function

This commit is contained in:
Martin Marmsoler 2022-05-30 10:04:26 +02:00
parent 06011029c1
commit 927e1172ff
4 changed files with 18 additions and 38 deletions

View File

@ -565,16 +565,3 @@ void FileWidget::headerCheckStateChanged(int state) {
else
emit stageStateChanged(mModelIndex, git::Index::Unstaged);
}
bool FileWidget::crlfNewLine(const QByteArray& ba) const {
int index = ba.indexOf("\n");
// If the file does not contain any new line just return false
if (index < 0)
return false;
if (index - 1 > 0)
return ba.at(index - 1) == '\r';
return false;
}

View File

@ -121,7 +121,6 @@ signals:
private:
void discard();
bool crlfNewLine(const QByteArray& ba) const;
DiffView *mView{nullptr};

View File

@ -802,15 +802,14 @@ void TestEditorLineInfo::windowsCRLF() {
bool submodule = mRepo.lookupSubmodule(name).isValid();
auto *fw = new FileWidget(&diffView, diff, patch, stagedPatch, QModelIndex(),
name, path_, submodule);
name, path_, submodule);
fw->setStageState(git::Index::StagedState::Unstaged);
auto hunks = fw->hunks();
QVERIFY(hunks.count() == 1);
hunks[0]->load();
checkEditorMarkers(hunks.at(0)->editor(),
QVector<int>(), QVector<int>(),
checkEditorMarkers(hunks.at(0)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({3, 4, 5}), QVector<int>());
// Stage single lines
@ -825,14 +824,13 @@ void TestEditorLineInfo::windowsCRLF() {
delete fw;
fw = new FileWidget(&diffView, diff, patch, stagedPatch, QModelIndex(), name,
path, submodule);
path, submodule);
hunks = fw->hunks();
QVERIFY(hunks.count() == 1);
hunks[0]->load();
checkEditorMarkers(hunks.at(0)->editor(),
QVector<int>(), QVector<int>(),
checkEditorMarkers(hunks.at(0)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({5}), QVector<int>({3, 4}));
delete fw;
@ -842,7 +840,8 @@ void TestEditorLineInfo::windowsCRLF() {
void TestEditorLineInfo::windowsCRLFMultiHunk() {
/*
* Staging single lines in a file with CRLF instead of single LF for multiple hunks
* Staging single lines in a file with CRLF instead of single LF for multiple
* hunks
*/
INIT_REPO("15_windowsCRLF_multipleHunks.zip", false)
@ -857,7 +856,7 @@ void TestEditorLineInfo::windowsCRLFMultiHunk() {
bool submodule = mRepo.lookupSubmodule(name).isValid();
auto *fw = new FileWidget(&diffView, diff, patch, stagedPatch, QModelIndex(),
name, path_, submodule);
name, path_, submodule);
fw->setStageState(git::Index::StagedState::Unstaged);
auto hunks = fw->hunks();
@ -865,13 +864,11 @@ void TestEditorLineInfo::windowsCRLFMultiHunk() {
hunks[0]->load();
hunks[1]->load();
checkEditorMarkers(hunks.at(0)->editor(),
QVector<int>(), QVector<int>(),
QVector<int>({3, 4}), QVector<int>());
checkEditorMarkers(hunks.at(0)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({3, 4}), QVector<int>());
checkEditorMarkers(hunks.at(1)->editor(),
QVector<int>(), QVector<int>(),
QVector<int>({3}), QVector<int>());
checkEditorMarkers(hunks.at(1)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({3}), QVector<int>());
// Stage single lines
hunks[0]->stageSelected(3, 4); // stage first deletion
@ -885,25 +882,22 @@ void TestEditorLineInfo::windowsCRLFMultiHunk() {
delete fw;
fw = new FileWidget(&diffView, diff, patch, stagedPatch, QModelIndex(), name,
path, submodule);
path, submodule);
hunks = fw->hunks();
QVERIFY(hunks.count() == 2);
hunks[0]->load();
hunks[1]->load();
checkEditorMarkers(hunks.at(0)->editor(),
QVector<int>(), QVector<int>(),
QVector<int>({4}), QVector<int>({3}));
checkEditorMarkers(hunks.at(0)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({4}), QVector<int>({3}));
checkEditorMarkers(hunks.at(1)->editor(),
QVector<int>(), QVector<int>(),
QVector<int>({3}), QVector<int>({}));
checkEditorMarkers(hunks.at(1)->editor(), QVector<int>(), QVector<int>(),
QVector<int>({3}), QVector<int>({}));
delete fw;
}
void TestEditorLineInfo::cleanupTestCase() { qWait(closeDelay); }
TEST_MAIN(TestEditorLineInfo)

View File

@ -129,11 +129,11 @@ QString extractRepository(const QString &filename, bool useTempDir) {
folder.removeRecursively();
}
const char *path_c = exportPath.data();
// Copy data because for some reason the pointer to the char array might change otherwise
// Copy data because for some reason the pointer to the char array might
// change otherwise
QByteArray ba_filename = f.absoluteFilePath().toLatin1();
const char *filename_c = ba_filename.data();
int arg = 2;
auto res = zip_extract(filename_c, path_c, on_extract_entry, &arg);
if (res < 0) {