mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-04 12:14:50 +00:00

This started out trying to look at the problems from issue #1425 and gradually grew to a broader set of fixes. There are two core things fixed here: 1. When you had an ignore like "/bin" which is rooted at the top of your tree, instead of immediately adding the "bin/" entry as an ignored item in the diff, we were returning all of the direct descendants of the directory as ignored items. This changes things to immediately ignore the directory. Note that this effects the behavior in test_status_ignore__subdirectories so that we no longer exactly match core gits ignore behavior, but the new behavior probably makes more sense (i.e. we now will include an ignored directory inside an untracked directory that we previously would have left off). 2. When a submodule only contained working directory changes, the diff code was always considering it unmodified which was just an outright bug. The HEAD SHA of the submodule matches the SHA in the parent repo index, and since the SHAs matches, the diff code was overwriting the actual status with UNMODIFIED. These fixes broke existing tests test_diff_workdir__submodules and test_status_ignore__subdirectories but looking it over, I actually think the new results are correct and the old results were wrong. @nulltoken had actually commented on the subdirectory ignore issue previously. I also included in the tests some debugging versions of the shared iteration callback routines that print status or diff information. These aren't used actively in the tests, but can be quickly swapped in to test code to give a better picture of what is being scanned in some of the complex test scenarios.
62 lines
1.1 KiB
C
62 lines
1.1 KiB
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;
|
|
|
|
typedef struct {
|
|
const char *path;
|
|
const char *matched_pathspec;
|
|
} notify_expected;
|
|
|
|
extern int diff_file_cb(
|
|
const git_diff_delta *delta,
|
|
float progress,
|
|
void *cb_data);
|
|
|
|
extern int diff_print_file_cb(
|
|
const git_diff_delta *delta,
|
|
float progress,
|
|
void *cb_data);
|
|
|
|
extern int diff_hunk_cb(
|
|
const git_diff_delta *delta,
|
|
const git_diff_range *range,
|
|
const char *header,
|
|
size_t header_len,
|
|
void *cb_data);
|
|
|
|
extern int diff_line_cb(
|
|
const git_diff_delta *delta,
|
|
const git_diff_range *range,
|
|
char line_origin,
|
|
const char *content,
|
|
size_t content_len,
|
|
void *cb_data);
|
|
|
|
extern int diff_foreach_via_iterator(
|
|
git_diff_list *diff,
|
|
git_diff_file_cb file_cb,
|
|
git_diff_hunk_cb hunk_cb,
|
|
git_diff_data_cb line_cb,
|
|
void *data);
|
|
|
|
extern void diff_print(FILE *fp, git_diff_list *diff);
|
|
|