mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-04 06:37:09 +00:00

This implements the basis for diff rename and copy detection, although it is based on simple SHA comparison right now instead of using a matching algortihm. Just as `git_diff_merge` can be used as a post-pass on diffs to emulate certain command line behaviors, there is a new API `git_diff_detect` which will update a diff list in-place, adjusting some deltas to RENAMED or COPIED state (and also, eventually, splitting MODIFIED deltas where the change is too large into DELETED/ADDED pairs). This also adds a new test repo that will hold rename/copy/split scenarios. Right now, it just has exact-match rename and copy, but the tests are written to use tree diffs, so we should be able to add new test scenarios easily without breaking tests.
51 lines
989 B
C
51 lines
989 B
C
#include "fileops.h"
|
|
#include "git2/diff.h"
|
|
|
|
extern git_tree *resolve_commit_oid_to_tree(
|
|
git_repository *repo, const char *partial_oid);
|
|
|
|
typedef struct {
|
|
int files;
|
|
int files_binary;
|
|
|
|
int file_status[10]; /* indexed by git_delta_t value */
|
|
|
|
int hunks;
|
|
int hunk_new_lines;
|
|
int hunk_old_lines;
|
|
|
|
int lines;
|
|
int line_ctxt;
|
|
int line_adds;
|
|
int line_dels;
|
|
} diff_expects;
|
|
|
|
extern int diff_file_fn(
|
|
void *cb_data,
|
|
const git_diff_delta *delta,
|
|
float progress);
|
|
|
|
extern int diff_hunk_fn(
|
|
void *cb_data,
|
|
const git_diff_delta *delta,
|
|
const git_diff_range *range,
|
|
const char *header,
|
|
size_t header_len);
|
|
|
|
extern int diff_line_fn(
|
|
void *cb_data,
|
|
const git_diff_delta *delta,
|
|
const git_diff_range *range,
|
|
char line_origin,
|
|
const char *content,
|
|
size_t content_len);
|
|
|
|
extern int diff_foreach_via_iterator(
|
|
git_diff_list *diff,
|
|
void *data,
|
|
git_diff_file_fn file_cb,
|
|
git_diff_hunk_fn hunk_cb,
|
|
git_diff_data_fn line_cb);
|
|
|
|
extern void diff_print(FILE *fp, git_diff_list *diff);
|