Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/git/Blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Blob::operator git_blob *() const {

bool Blob::isBinary() const { return git_blob_is_binary(*this); }

bool Blob::isBinary(const QByteArray &data) {
return git_blob_data_is_binary(data.constData(), data.length());
}

QByteArray Blob::content() const {
const char *content = static_cast<const char *>(git_blob_rawcontent(*this));
return QByteArray(content, git_blob_rawsize(*this));
Expand Down
10 changes: 10 additions & 0 deletions src/git/Blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ class Blob : public Object {
Blob();
Blob(const Object &rhs);

/// @brief Check if the Blob object points to binary data
/// @return True if Blob oject is for a binary blob
bool isBinary() const;

/// @brief Check if given QByteArray contains binary data according to libgit2
/// @param data QByteArray to do a binary test on
/// @return True if data is binary
static bool isBinary(const QByteArray &data);

/// @brief Grab the content of the blob
/// @return QByteArray of the blob
QByteArray content() const;

private:
Expand Down
19 changes: 0 additions & 19 deletions src/git/Buffer.cpp

This file was deleted.

28 changes: 0 additions & 28 deletions src/git/Buffer.h

This file was deleted.

1 change: 0 additions & 1 deletion src/git/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ add_library(
Blame.cpp
Blob.cpp
Branch.cpp
Buffer.cpp
Command.cpp
Commit.cpp
Config.cpp
Expand Down
4 changes: 1 addition & 3 deletions src/ui/BlameEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "editor/TextEditor.h"
#include "git/Blame.h"
#include "git/Blob.h"
#include "git/Buffer.h"
#include "git/Commit.h"
#include "git/Index.h"
#include "git/Repository.h"
Expand Down Expand Up @@ -145,8 +144,7 @@ bool BlameEditor::load(const QString &name, const git::Blob &blob,

// Limit the read to kMaxReadBinary to determine if the file is binary
content = file.read(kMaxReadBinary);
git::Buffer buffer(content.constData(), content.length());
if (buffer.isBinary())
if (git::Blob::isBinary(content))
return false;
// Okay, not a binary file. Now we need to grab the rest if needed
else if (content.length() == kMaxReadBinary)
Expand Down
5 changes: 1 addition & 4 deletions src/ui/DiffView/FileWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "ui/FileContextMenu.h"
#include "git/Repository.h"

#include "git/Buffer.h"

#include <QCheckBox>
#include <QContextMenuEvent>
#include <QVBoxLayout>
Expand Down Expand Up @@ -358,8 +356,7 @@ FileWidget::FileWidget(DiffView *view, const git::Diff &diff,
// Limit the read to kMaxReadBinary number of bytes to determine if the
// file is binary or not
QByteArray content = dev.read(kMaxReadBinary);
git::Buffer buffer(content.constData(), content.length());
binary = buffer.isBinary();
binary = git::Blob::isBinary(content);
}
}

Expand Down
Loading