Skip to content

Commit

Permalink
Update updateFilesList to use Git::CommitID instead of QString
Browse files Browse the repository at this point in the history
  • Loading branch information
soramimi committed Jun 23, 2024
1 parent 3ff9007 commit 67072a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
49 changes: 25 additions & 24 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4028,7 +4028,7 @@ void MainWindow::setupShowFileListHandler()
});
}

void MainWindow::updateFilesList(RepositoryWrapperFrame *frame, QString const &id) // TODO: change id as Git::CommitID
void MainWindow::updateFilesList(RepositoryWrapperFrame *frame, Git::CommitID const &id)
{
GitPtr g = git();
if (!isValidWorkingCopy(g)) return;
Expand All @@ -4039,21 +4039,38 @@ void MainWindow::updateFilesList(RepositoryWrapperFrame *frame, QString const &i
m->update_files_list_thread.join();
}

m->update_files_list_thread = std::thread([this](GitPtr g, RepositoryWrapperFrame *frame, QString const &id){
m->update_files_list_thread = std::thread([this](GitPtr g, RepositoryWrapperFrame *frame, Git::CommitID const &id){

ExchangeData xdata;
xdata.frame = frame;
xdata.files_list_type = FilesListType::SingleList;

if (id.isEmpty()) { // Uncommited changes が選択されているとき
if (id) {
auto diffs = makeDiffs(g, frame, Git::CommitID(id));
if (diffs) {
setDiffResult(*diffs);
} else {
setDiffResult({});
return;
}
showFileList(xdata.files_list_type);
xdata.frame = frame;
xdata.files_list_type = xdata.files_list_type;

auto AddItem = [&](ObjectData const &obj){
xdata.object_data.push_back(obj);
};
addDiffItems(diffResult(), AddItem);

} else { // Uncommited changes が選択されているとき

updateUncommitedChanges();

bool uncommited = isThereUncommitedChanges();
if (uncommited) {
xdata.files_list_type = FilesListType::SideBySide;
}
auto diffs = makeDiffs(g, frame, Git::CommitID(uncommited ? QString() : id));
auto diffs = makeDiffs(g, frame, uncommited ? Git::CommitID() : id);
if (diffs) {
setDiffResult(*diffs);
} else {
Expand Down Expand Up @@ -4119,22 +4136,6 @@ void MainWindow::updateFilesList(RepositoryWrapperFrame *frame, QString const &i
xdata.files_list_type = xdata.files_list_type;
xdata.object_data.push_back(obj);
}
} else {
auto diffs = makeDiffs(g, frame, Git::CommitID(id));
if (diffs) {
setDiffResult(*diffs);
} else {
setDiffResult({});
return;
}
showFileList(xdata.files_list_type);
xdata.frame = frame;
xdata.files_list_type = xdata.files_list_type;

auto AddItem = [&](ObjectData const &obj){
xdata.object_data.push_back(obj);
};
addDiffItems(diffResult(), AddItem);
}

addFileObjectData(xdata);
Expand Down Expand Up @@ -4178,11 +4179,11 @@ void MainWindow::execCommitViewWindow(const Git::CommitItem *commit)

void MainWindow::updateFilesList(RepositoryWrapperFrame *frame, Git::CommitItem const &commit)
{
QString id;
Git::CommitID id;
if (Git::isUncommited(commit)) {
// empty id for uncommited changes
} else {
id = commit.commit_id.toQString();
id = commit.commit_id;
}
updateFilesList(frame, id);
}
Expand Down Expand Up @@ -4448,8 +4449,8 @@ void MainWindow::runFetch_(GitPtr g)
RepositoryWrapperFrame *frame = this->frame();

detectGitServerType(g);

updateFilesList(frame, QString());
updateFilesList(frame, Git::CommitID());

// ログを取得
queryCommitLog(frame, g);
Expand Down
2 changes: 1 addition & 1 deletion src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class MainWindow : public QMainWindow {
void postEvent(QObject *receiver, QEvent *event, int ms_later);
void postUserFunctionEvent(const std::function<void (const QVariant &, void *)> fn, QVariant const &v = QVariant(), void *p = nullptr, int ms_later = 0);

void updateFilesList(RepositoryWrapperFrame *frame, QString const &id);
void updateFilesList(RepositoryWrapperFrame *frame, const Git::CommitID &id);
void updateFilesList(RepositoryWrapperFrame *frame, Git::CommitItem const &commit);
void updateRepositoriesList();

Expand Down

0 comments on commit 67072a3

Please sign in to comment.