SlHelpers
Loading...
Searching...
No Matches
SlGit::Diff Class Reference

Diff is a representation of a git diff. More...

#include <Diff.h>

Classes

struct  ForEachCB
 Callbacks for forEach(). More...

Public Types

using PrintCB
 Callback for print().

Public Member Functions

size_t numDeltas () const noexcept
 Get count of deltas in this Diff.
size_t numDeltas (const git_delta_t &type) const noexcept
 Get count of deltas with the type (GIT_DELTA_ADDED, ...).
const git_diff_delta * getDelta (size_t idx) const noexcept
 Get a delta on the idx-th position.
bool findSimilar (const git_diff_find_options *options=nullptr) const noexcept
 Find similar files in the Diff (in-place).
bool isSortedICase () const noexcept
 Return true if ignore-case-sorted.
int forEach (const ForEachCB &forEachCB) const
 Invoke forEachCB callbacks for each file, hunk, ... in the diff.
int print (git_diff_format_t format, const PrintCB &printCB) const
 Invoke forEachCB callbacks for each file, hunk, ... in the diff.
std::optional< BuftoBuf (git_diff_format_t format) const noexcept
 Convert to Buf.
GitTy * diff () const noexcept
 Get the stored pointer to libgit2's git_diff.
 operator GitTy * () const noexcept
 Alias for diff() – implicit conversion.

Static Public Member Functions

static std::optional< Diff > createFromBuffer (std::string_view buffer) noexcept
 Create a new Diff from buffer.

Friends

class Repo

Detailed Description

Diff is a representation of a git diff.

Member Typedef Documentation

◆ PrintCB

Initial value:
std::function<int(const git_diff_delta &delta, const git_diff_hunk *hunk,
const git_diff_line &line)>

Callback for print().

Member Function Documentation

◆ findSimilar()

bool SlGit::Diff::findSimilar ( const git_diff_find_options * options = nullptr) const
inlinenoexcept

Find similar files in the Diff (in-place).

Parameters
optionsOptions to use (like rename threshold)
Returns
True on success.
git diff -M

◆ forEach()

int SlGit::Diff::forEach ( const ForEachCB & forEachCB) const

Invoke forEachCB callbacks for each file, hunk, ... in the diff.

Parameters
forEachCBCallbacks
Returns
0 on success, non-zero callback return value, or error code.

◆ print()

int SlGit::Diff::print ( git_diff_format_t format,
const PrintCB & printCB ) const

Invoke forEachCB callbacks for each file, hunk, ... in the diff.

Parameters
formatGIT_DIFF_FORMAT_PATCH, GIT_DIFF_FORMAT_PATCH_HEADER, ...
printCBCallback
Returns
0 on success, non-zero callback return value, or error code.

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/slhelpers-20260428.f233ce9-build/slhelpers-20260428.f233ce9/include/git/Diff.h