From 3c1b0e2061172ca057b945aed00229b56fac4104 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 28 Apr 2022 18:44:38 +0200 Subject: [PATCH] WIP --- dep/libgit2/libgit2 | 2 +- src/git/Filter.cpp | 72 ++++++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/dep/libgit2/libgit2 b/dep/libgit2/libgit2 index 173ec88b51..a8d5610091 160000 --- a/dep/libgit2/libgit2 +++ b/dep/libgit2/libgit2 @@ -1 +1 @@ -Subproject commit 173ec88b51ddcb04ddc1d63e637e9cbacf7d411d +Subproject commit a8d5610091aaa91cb73123b2d540775e324eb92c diff --git a/src/git/Filter.cpp b/src/git/Filter.cpp index cfa03d8d5a..7da37c7723 100644 --- a/src/git/Filter.cpp +++ b/src/git/Filter.cpp @@ -38,38 +38,44 @@ struct FilterInfo { QString quote(const QString &path) { return QString("\"%1\"").arg(path); } -int apply(git_filter *self, void **payload, git_buf *to, const git_buf *from, - const git_filter_source *src) { - FilterInfo *info = reinterpret_cast(self); - git_filter_mode_t mode = git_filter_source_mode(src); - QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; - - // Substitute path. - command.replace("%f", quote(git_filter_source_path(src))); - - QString bash = Command::bashPath(); - if (bash.isEmpty()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - QProcess process; - git_repository *repo = git_filter_source_repo(src); - process.setWorkingDirectory(git_repository_workdir(repo)); - - process.start(bash, {"-c", command}); - if (!process.waitForStarted()) - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - - process.write(from->ptr, from->size); - process.closeWriteChannel(); - - if (!process.waitForFinished() || process.exitCode()) { - git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); - return info->required ? GIT_EUSER : GIT_PASSTHROUGH; - } - - QByteArray data = process.readAll(); - git_buf_set(to, data.constData(), data.length()); - return 0; +int stream( + git_writestream **out, + git_filter *self, + void **payload, + const git_filter_source *src, + git_writestream *next) +{ + return -1; +// FilterInfo *info = reinterpret_cast(self); +// git_filter_mode_t mode = git_filter_source_mode(src); +// QString command = (mode == GIT_FILTER_SMUDGE) ? info->smudge : info->clean; + +// // Substitute path. +// command.replace("%f", quote(git_filter_source_path(src))); + +// QString bash = Command::bashPath(); +// if (bash.isEmpty()) +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + +// QProcess process; +// git_repository *repo = git_filter_source_repo(src); +// process.setWorkingDirectory(git_repository_workdir(repo)); + +// process.start(bash, {"-c", command}); +// if (!process.waitForStarted()) +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; + +// process.write(from->ptr, from->size); +// process.closeWriteChannel(); + +// if (!process.waitForFinished() || process.exitCode()) { +// git_error_set_str(GIT_ERROR_FILTER, process.readAllStandardError()); +// return info->required ? GIT_EUSER : GIT_PASSTHROUGH; +// } + +// QByteArray data = process.readAll(); +// git_buf_set(to, data.constData(), data.length()); +// return 0; } } // namespace @@ -101,7 +107,7 @@ void Filter::init() { info.name = key.toUtf8(); info.attributes = kFilterFmt.arg(key).toUtf8(); - info.filter.apply = &apply; + info.filter.stream = &stream; info.filter.attributes = info.attributes.constData(); git_filter_register(info.name.constData(), &info.filter, GIT_FILTER_DRIVER_PRIORITY);