77 const wxString& aBaseRef,
78 const wxString& aHeadRef )
80 std::vector<CHANGED_FILE>
result;
95 if( !aBaseRef.IsEmpty() )
103 git_diff* diff =
nullptr;
104 git_diff_options opts;
105 git_diff_options_init( &opts, GIT_DIFF_OPTIONS_VERSION );
107 if( git_diff_tree_to_tree( &diff, aRepo, baseTree.get(), headTree.get(), &opts ) != 0 )
109 wxLogTrace(
traceGit,
"git_diff_tree_to_tree failed: %s",
117 git_diff_find_options findOpts;
118 git_diff_find_options_init( &findOpts, GIT_DIFF_FIND_OPTIONS_VERSION );
119 findOpts.flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
120 git_diff_find_similar( diff, &findOpts );
122 result.reserve( git_diff_num_deltas( diff ) );
125 [&
result](
const git_diff_delta& aDelta )
128 entry.
status = deltaStatusToEnum( aDelta.status );
129 entry.
path = wxString::FromUTF8( aDelta.new_file.path
130 ? aDelta.new_file.path
131 : aDelta.old_file.path );
133 if( aDelta.status == GIT_DELTA_RENAMED || aDelta.status == GIT_DELTA_COPIED )
134 entry.
oldPath = wxString::FromUTF8( aDelta.old_file.path );
136 result.push_back( std::move( entry ) );
static wxString GetLastGitError()
libgit2's last message, without credentials from any URL it quotes, so it is safe to show or trace.
const wxChar *const traceGit
Flag to enable Git debugging output.
std::unique_ptr< git_tree, decltype([](git_tree *aTree) { git_tree_free(aTree); })> GitTreePtr
A unique pointer for git_tree objects with automatic cleanup.
std::vector< CHANGED_FILE > CompareRefs(git_repository *aRepo, const wxString &aBaseRef, const wxString &aHeadRef)
Compare two git refs (branch / tag / commit OID) within a repository and return the per-file change l...
git_tree * ResolveRefToTree(git_repository *aRepo, const wxString &aRef)
Resolve a string ref (branch name, short OID, full OID, tag) to its tree.
const char * FileChangeStatusToString(FILE_CHANGE_STATUS aStatus)
void CollectDiffDeltas(git_diff *aDiff, const std::function< void(const git_diff_delta &)> &aCallback)
Walk every delta in a computed diff, invoking aCallback once per delta.
std::unique_ptr< git_diff, decltype([](git_diff *aDiff) { git_diff_free(aDiff); })> GitDiffPtr
A unique pointer for git_diff objects with automatic cleanup.
FILE_CHANGE_STATUS status
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.