mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-17 11:48:20 +00:00

This makes the git attributes and git ignores cache check stat information before using the file contents from the cache. For cached files from the index, it checks the SHA of the file instead. This should reduce the need to ever call `git_attr_cache_flush()` in most situations. This commit also fixes the `git_status_should_ignore` API to use the libgit2 standard parameter ordering.
195 lines
4.8 KiB
C
195 lines
4.8 KiB
C
#include "status_helpers.h"
|
|
|
|
/* entries for a plain copy of tests/resources/status */
|
|
|
|
static const char *entry_paths0[] = {
|
|
"file_deleted",
|
|
"ignored_file",
|
|
"modified_file",
|
|
"new_file",
|
|
"staged_changes",
|
|
"staged_changes_file_deleted",
|
|
"staged_changes_modified_file",
|
|
"staged_delete_file_deleted",
|
|
"staged_delete_modified_file",
|
|
"staged_new_file",
|
|
"staged_new_file_deleted_file",
|
|
"staged_new_file_modified_file",
|
|
|
|
"subdir/deleted_file",
|
|
"subdir/modified_file",
|
|
"subdir/new_file",
|
|
};
|
|
|
|
static const unsigned int entry_statuses0[] = {
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_IGNORED,
|
|
GIT_STATUS_WT_MODIFIED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_WT_MODIFIED,
|
|
GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_INDEX_DELETED | GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_INDEX_NEW | GIT_STATUS_WT_MODIFIED,
|
|
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_MODIFIED,
|
|
GIT_STATUS_WT_NEW,
|
|
};
|
|
|
|
static const size_t entry_count0 = 15;
|
|
|
|
/* entries for a copy of tests/resources/status with all content
|
|
* deleted from the working directory
|
|
*/
|
|
|
|
static const char *entry_paths2[] = {
|
|
"current_file",
|
|
"file_deleted",
|
|
"modified_file",
|
|
"staged_changes",
|
|
"staged_changes_file_deleted",
|
|
"staged_changes_modified_file",
|
|
"staged_delete_file_deleted",
|
|
"staged_delete_modified_file",
|
|
"staged_new_file",
|
|
"staged_new_file_deleted_file",
|
|
"staged_new_file_modified_file",
|
|
"subdir.txt",
|
|
"subdir/current_file",
|
|
"subdir/deleted_file",
|
|
"subdir/modified_file",
|
|
};
|
|
|
|
static const unsigned int entry_statuses2[] = {
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
};
|
|
|
|
static const size_t entry_count2 = 15;
|
|
|
|
/* entries for a copy of tests/resources/status with some mods */
|
|
|
|
static const char *entry_paths3[] = {
|
|
".HEADER",
|
|
"42-is-not-prime.sigh",
|
|
"README.md",
|
|
"current_file",
|
|
"current_file/",
|
|
"file_deleted",
|
|
"ignored_file",
|
|
"modified_file",
|
|
"new_file",
|
|
"staged_changes",
|
|
"staged_changes_file_deleted",
|
|
"staged_changes_modified_file",
|
|
"staged_delete_file_deleted",
|
|
"staged_delete_modified_file",
|
|
"staged_new_file",
|
|
"staged_new_file_deleted_file",
|
|
"staged_new_file_modified_file",
|
|
"subdir",
|
|
"subdir/current_file",
|
|
"subdir/deleted_file",
|
|
"subdir/modified_file",
|
|
};
|
|
|
|
static const unsigned int entry_statuses3[] = {
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_IGNORED,
|
|
GIT_STATUS_WT_MODIFIED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_WT_NEW | GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
};
|
|
|
|
static const size_t entry_count3 = 21;
|
|
|
|
|
|
/* entries for a copy of tests/resources/status with some mods
|
|
* and different options to the status call
|
|
*/
|
|
|
|
static const char *entry_paths4[] = {
|
|
".new_file",
|
|
"current_file",
|
|
"current_file/current_file",
|
|
"current_file/modified_file",
|
|
"current_file/new_file",
|
|
"file_deleted",
|
|
"modified_file",
|
|
"new_file",
|
|
"staged_changes",
|
|
"staged_changes_file_deleted",
|
|
"staged_changes_modified_file",
|
|
"staged_delete_file_deleted",
|
|
"staged_delete_modified_file",
|
|
"staged_new_file",
|
|
"staged_new_file_deleted_file",
|
|
"staged_new_file_modified_file",
|
|
"subdir",
|
|
"subdir/current_file",
|
|
"subdir/deleted_file",
|
|
"subdir/modified_file",
|
|
"zzz_new_dir/new_file",
|
|
"zzz_new_file"
|
|
};
|
|
|
|
static const unsigned int entry_statuses4[] = {
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_MODIFIED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_MODIFIED,
|
|
GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_WT_NEW | GIT_STATUS_INDEX_DELETED,
|
|
GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_DELETED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_MODIFIED | GIT_STATUS_INDEX_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_DELETED,
|
|
GIT_STATUS_WT_NEW,
|
|
GIT_STATUS_WT_NEW,
|
|
};
|
|
|
|
static const size_t entry_count4 = 22;
|