Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Murmele committed Nov 17, 2022
1 parent f46894c commit b71ad6b
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 80 deletions.
12 changes: 9 additions & 3 deletions dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ add_subdirectory(openssl)
add_subdirectory(libssh2)
add_subdirectory(libgit2)
# otherwise the zlib is not available in the src/git
set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
set(LIBGIT2_DEPENDENCY_OBJECTS
${LIBGIT2_DEPENDENCY_OBJECTS}
PARENT_SCOPE)
set(LIBGIT2_SYSTEM_LIBS
${LIBGIT2_SYSTEM_LIBS}
PARENT_SCOPE)
set(LIBGIT2_INCLUDES
${LIBGIT2_INCLUDES}
PARENT_SCOPE)

add_subdirectory(cmark)
add_subdirectory(lua)
Expand Down
14 changes: 10 additions & 4 deletions dep/libgit2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ endif()

if(NOT USE_SYSTEM_LIBGIT2)
add_subdirectory(libgit2)
# otherwise the zlib is not available in the src/git
set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
# otherwise the zlib is not available in the src/git
set(LIBGIT2_DEPENDENCY_OBJECTS
${LIBGIT2_DEPENDENCY_OBJECTS}
PARENT_SCOPE)
set(LIBGIT2_SYSTEM_LIBS
${LIBGIT2_SYSTEM_LIBS}
PARENT_SCOPE)
set(LIBGIT2_INCLUDES
${LIBGIT2_INCLUDES}
PARENT_SCOPE)
endif()
8 changes: 1 addition & 7 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ target_compile_definitions(
PRIVATE QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}"
BUILD_DESCRIPTION="${BUILD_DESCRIPTION}")

target_link_libraries(app
conf
git
ui
update
Qt5::Widgets
)
target_link_libraries(app conf git ui update Qt5::Widgets)

set_target_properties(app PROPERTIES AUTOMOC ON)

Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/SubmoduleTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ bool SubmoduleTableModel::setData(const QModelIndex &index,
QMessageBox::Warning, tr("Deinitialize Submodule?"), text,
QMessageBox::Cancel, qobject_cast<QWidget *>(parent()));

if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(mRepo.submoduleStatus(submodule.name())))
if (GIT_SUBMODULE_STATUS_IS_WD_DIRTY(
mRepo.submoduleStatus(submodule.name())))
mb->setInformativeText(
tr("The submodule working directory contains uncommitted "
"changes that will be lost if you continue."));
Expand Down
9 changes: 2 additions & 7 deletions src/git/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@

namespace git {

Buffer::Buffer(const char *data, int size)
: data(data), size(size)
{}
Buffer::Buffer(const char *data, int size) : data(data), size(size) {}

bool Buffer::isBinary() const
{
return git_blob_data_is_binary(data, size);
}
bool Buffer::isBinary() const { return git_blob_data_is_binary(data, size); }

} // namespace git
2 changes: 1 addition & 1 deletion src/git/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Buffer {
bool isBinary() const;

private:
const char* data;
const char *data;
const int size;
};

Expand Down
10 changes: 4 additions & 6 deletions src/git/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ add_library(
TagRef.cpp
Tree.cpp)

target_link_libraries(git
target_link_libraries(
git
$<TARGET_OBJECTS:libgit2>
$<TARGET_OBJECTS:util> # util of libgit2
gittyupUtil
${LIBGIT2_DEPENDENCY_OBJECTS}
${LIBGIT2_SYSTEM_LIBS}
Qt5::Core
Qt5::Network
)
Qt5::Network)

# needed also by the plugin target so it must be public
target_include_directories(git PUBLIC
${LIBGIT2_INCLUDES}
)
target_include_directories(git PUBLIC ${LIBGIT2_INCLUDES})

set_target_properties(git PROPERTIES AUTOMOC ON)
4 changes: 2 additions & 2 deletions src/git/Diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ QByteArray Diff::print() {
QByteArray diff;
for (auto file : data.files) {
for (auto hunk : file.hunks) {
diff.append(hunk.header.toUtf8());
diff.append(hunk.header.toUtf8());

for (auto line : hunk.lines)
diff.append(line.toUtf8());
diff.append(line.toUtf8());
}
}
qDebug() << QString(diff);
Expand Down
2 changes: 1 addition & 1 deletion src/git/Id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Id::Id(const git_oid *id) {
if (id) {
git_oid_cpy(&d, id);
} else {
memset(d.id, 0, GIT_OID_SHA1_SIZE);
memset(d.id, 0, GIT_OID_SHA1_SIZE);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/git/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ git_object_t Object::type() const { return git_object_type(d.data()); }

Id Object::id() const { return git_object_id(d.data()); }

QString Object::shortId() const
{
QString Object::shortId() const {
git_buf buf = GIT_BUF_INIT;
git_object_short_id(&buf, d.data());
QByteArray result(buf.ptr, buf.size);
Expand Down
7 changes: 4 additions & 3 deletions src/git/Patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ QByteArray Patch::generateResult(QList<QList<QByteArray>> &image,
if (!filters.isValid())
return result;

// Apply filters.
git_buf out = GIT_BUF_INIT;
git_filter_list_apply_to_buffer(&out, filters, result.data(), result.length());
// Apply filters.
git_buf out = GIT_BUF_INIT;
git_filter_list_apply_to_buffer(&out, filters, result.data(),
result.length());

QByteArray filtered(out.ptr, out.size);
git_buf_dispose(&out);
Expand Down
10 changes: 4 additions & 6 deletions src/git/Remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,8 @@ int Remote::Callbacks::update(const char *name, const git_oid *a,
return 0;
}

int Remote::Callbacks::remoteReady(
git_remote* remote,
int direction,
void *payload)
{
int Remote::Callbacks::remoteReady(git_remote *remote, int direction,
void *payload) {
Q_UNUSED(direction)

Remote::Callbacks *cbs = reinterpret_cast<Remote::Callbacks *>(payload);
Expand Down Expand Up @@ -617,7 +614,8 @@ Result Remote::clone(Callbacks *callbacks, const QString &url,
git_repository *repo = nullptr;
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected;
opts.fetch_opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect;
opts.fetch_opts.callbacks.about_to_disconnect =
&Remote::Callbacks::about_to_disconnect;
opts.fetch_opts.callbacks.sideband_progress = &Remote::Callbacks::sideband;
opts.fetch_opts.callbacks.credentials = &Remote::Callbacks::credentials;
opts.fetch_opts.callbacks.certificate_check = &Remote::Callbacks::certificate;
Expand Down
8 changes: 3 additions & 5 deletions src/git/Remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ class Remote {
virtual bool connectToAgent() const { return false; }

// static callback wrappers
static void connected(git_remote *remote, void *payload);
static void connected(git_remote *remote, void *payload);

static void about_to_disconnect(git_remote *remote, void *payload);
static void about_to_disconnect(git_remote *remote, void *payload);

static int sideband(const char *str, int len, void *payload);

Expand All @@ -110,9 +110,7 @@ class Remote {
static int update(const char *name, const git_oid *a, const git_oid *b,
void *payload);

static int remoteReady(git_remote *remote,
int direction,
void *payload);
static int remoteReady(git_remote *remote, int direction, void *payload);

protected:
// Try to stop the current remote.
Expand Down
26 changes: 14 additions & 12 deletions src/git/Repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ Id Repository::workdirId(const QString &path) const {
return id;
}

QString Repository::message() const
{
QString Repository::message() const {
git_buf buf = GIT_BUF_INIT;
git_repository_message(&buf, d->repo);
return QString::fromUtf8(buf.ptr, buf.size);
Expand Down Expand Up @@ -320,7 +319,9 @@ Diff Repository::diffIndexToWorkdir(const Index &index,
Diff::Callbacks *callbacks,
bool ignoreWhitespace) const {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
opts.flags |= (GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS | GIT_DIFF_INCLUDE_TYPECHANGE); // GIT_DIFF_DISABLE_MMAP flag really needed?
opts.flags |= (GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_UNTRACKED_DIRS |
GIT_DIFF_INCLUDE_TYPECHANGE); // GIT_DIFF_DISABLE_MMAP flag
// really needed?
if (ignoreWhitespace)
opts.flags |= GIT_DIFF_IGNORE_WHITESPACE;

Expand Down Expand Up @@ -687,18 +688,19 @@ Submodule Repository::lookupSubmodule(const QString &name) const {
return Submodule(submodule);
}

int Repository::submoduleStatus(const QString& name) const {
int Repository::submoduleStatus(const QString &name) const {

unsigned int status;
// TODO: testing!!!!
int returnValue = git_submodule_status(&status, d->repo, name.toLocal8Bit().data(), GIT_SUBMODULE_IGNORE_UNSPECIFIED);
if (returnValue < 0)
return returnValue;
return status;
unsigned int status;
// TODO: testing!!!!
int returnValue =
git_submodule_status(&status, d->repo, name.toLocal8Bit().data(),
GIT_SUBMODULE_IGNORE_UNSPECIFIED);
if (returnValue < 0)
return returnValue;
return status;
}

Remote Repository::addRemote(const QString &name, const QString &url)
{
Remote Repository::addRemote(const QString &name, const QString &url) {
// FIXME: Validate name?

emit d->notifier->remoteAboutToBeAdded(name);
Expand Down
2 changes: 1 addition & 1 deletion src/git/Repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Repository {
void invalidateSubmoduleCache();
QList<Submodule> submodules() const;
Submodule lookupSubmodule(const QString &path) const;
int submoduleStatus(const QString& name) const;
int submoduleStatus(const QString &name) const;

// remote
Remote addRemote(const QString &name, const QString &url);
Expand Down
7 changes: 4 additions & 3 deletions src/git/Submodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ Id Submodule::indexId() const { return git_submodule_index_id(d.data()); }

Id Submodule::workdirId() const { return git_submodule_wd_id(d.data()); }

Result Submodule::update(Remote::Callbacks *callbacks, bool init, bool checkout_force)
{
Result Submodule::update(Remote::Callbacks *callbacks, bool init,
bool checkout_force) {
git_submodule_update_options opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
opts.fetch_opts.callbacks.connected = &Remote::Callbacks::connected;
opts.fetch_opts.callbacks.about_to_disconnect = &Remote::Callbacks::about_to_disconnect;
opts.fetch_opts.callbacks.about_to_disconnect =
&Remote::Callbacks::about_to_disconnect;
opts.fetch_opts.callbacks.sideband_progress = &Remote::Callbacks::sideband;
opts.fetch_opts.callbacks.credentials = &Remote::Callbacks::credentials;
opts.fetch_opts.callbacks.certificate_check = &Remote::Callbacks::certificate;
Expand Down
3 changes: 2 additions & 1 deletion src/git/Submodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class Submodule {
Id indexId() const;
Id workdirId() const;

Result update(Remote::Callbacks *callbacks, bool init = false, bool checkout_force = false);
Result update(Remote::Callbacks *callbacks, bool init = false,
bool checkout_force = false);

Repository open() const;

Expand Down
10 changes: 5 additions & 5 deletions src/index/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ target_link_libraries(

set_target_properties(index PROPERTIES AUTOMOC ON)

if (BUILD_GITTYUP_TEST)
add_executable(lexer_test lexer_test.cpp)
target_link_libraries(lexer_test index)
if(BUILD_GITTYUP_TEST)
add_executable(lexer_test lexer_test.cpp)
target_link_libraries(lexer_test index)

add_executable(index_test index_test.cpp)
target_link_libraries(index_test index Qt5::Widgets)
add_executable(index_test index_test.cpp)
target_link_libraries(index_test index Qt5::Widgets)
endif()

add_executable(indexer indexer.cpp)
Expand Down
4 changes: 2 additions & 2 deletions src/index/Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Index::reset() {
QFile idFile(dir.filePath(kIdFile));
if (idFile.open(QIODevice::ReadOnly)) {
while (idFile.bytesAvailable() > 0)
mIds.append(idFile.read(GIT_OID_SHA1));
mIds.append(idFile.read(GIT_OID_SHA1));
}

// Read dictionary.
Expand Down Expand Up @@ -140,7 +140,7 @@ bool Index::write(PostingMap map) {

// Write id file.
foreach (const git::Id &id, mIds)
idFile.write(id.toByteArray(), GIT_OID_SHA1);
idFile.write(id.toByteArray(), GIT_OID_SHA1);

// Merge new entries into existing postings file.
// Write dictionary and postings files in lockstep.
Expand Down
17 changes: 9 additions & 8 deletions src/ui/RepoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,14 @@ QFuture<git::Result> RepoView::fetch(const git::Remote &rmt, bool tags,
QtConcurrent::run([this, remote, tags, submodules, prune] {
git::Result result = git::Remote(remote).fetch(mCallbacks, tags, prune);

if (result && submodules) {
// Scan for unmodified submodules on the fetch thread.
foreach (const git::Submodule &submodule, mRepo.submodules()) {
if (GIT_SUBMODULE_STATUS_IS_UNMODIFIED(mRepo.submoduleStatus(submodule.name())))
submodules->append(submodule.name());
}
}
if (result && submodules) {
// Scan for unmodified submodules on the fetch thread.
foreach (const git::Submodule &submodule, mRepo.submodules()) {
if (GIT_SUBMODULE_STATUS_IS_UNMODIFIED(
mRepo.submoduleStatus(submodule.name())))
submodules->append(submodule.name());
}
}

return result;
}));
Expand Down Expand Up @@ -2362,7 +2363,7 @@ RepoView::submoduleResetInfoList(const git::Repository &repo,
// Only reset modified submodules
QList<git::Submodule> modules;
foreach (const git::Submodule &submodule, submodules) {
int status = repo.submoduleStatus(submodule.name());
int status = repo.submoduleStatus(submodule.name());

if (status & (GIT_SUBMODULE_STATUS_WD_MODIFIED |
GIT_SUBMODULE_STATUS_WD_WD_MODIFIED |
Expand Down

0 comments on commit b71ad6b

Please sign in to comment.