mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 08:58:41 +00:00
Add a failing test for autocrlf filters
This commit is contained in:
parent
11fccddcb5
commit
fcc48d1fce
68
tests-clar/checkout/binaryunicode.c
Normal file
68
tests-clar/checkout/binaryunicode.c
Normal file
@ -0,0 +1,68 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "refs.h"
|
||||
#include "repo/repo_helpers.h"
|
||||
#include "path.h"
|
||||
#include "fileops.h"
|
||||
|
||||
static git_repository *g_repo;
|
||||
|
||||
void test_checkout_binaryunicode__initialize(void)
|
||||
{
|
||||
g_repo = cl_git_sandbox_init("binaryunicode");
|
||||
}
|
||||
|
||||
void test_checkout_binaryunicode__cleanup(void)
|
||||
{
|
||||
cl_git_sandbox_cleanup();
|
||||
}
|
||||
|
||||
static void execute_test(void)
|
||||
{
|
||||
git_oid oid, check;
|
||||
git_commit *commit;
|
||||
git_tree *tree;
|
||||
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
|
||||
|
||||
cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/branch1"));
|
||||
cl_git_pass(git_commit_lookup(&commit, g_repo, &oid));
|
||||
cl_git_pass(git_commit_tree(&tree, commit));
|
||||
|
||||
opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
|
||||
cl_git_pass(git_checkout_tree(g_repo, (git_object *)tree, &opts));
|
||||
|
||||
git_tree_free(tree);
|
||||
git_commit_free(commit);
|
||||
|
||||
/* Verify that the lenna.jpg file was checked out correctly */
|
||||
cl_git_pass(git_oid_fromstr(&check, "8ab005d890fe53f65eda14b23672f60d9f4ec5a1"));
|
||||
cl_git_pass(git_odb_hashfile(&oid, "binaryunicode/lenna.jpg", GIT_OBJ_BLOB));
|
||||
cl_assert(git_oid_equal(&oid, &check));
|
||||
|
||||
/* Verify that the text file was checked out correctly */
|
||||
cl_git_pass(git_oid_fromstr(&check, "965b223880dd4249e2c66a0cc0b4cffe1dc40f5a"));
|
||||
cl_git_pass(git_odb_hashfile(&oid, "binaryunicode/utf16_withbom_noeol_crlf.txt", GIT_OBJ_BLOB));
|
||||
cl_assert(git_oid_equal(&oid, &check));
|
||||
}
|
||||
|
||||
void test_checkout_binaryunicode__noautocrlf(void)
|
||||
{
|
||||
git_config *config;
|
||||
|
||||
cl_git_pass(git_repository_config(&config, g_repo));
|
||||
cl_git_pass(git_config_set_bool(config, "core.autocrlf", false));
|
||||
git_config_free(config);
|
||||
|
||||
execute_test();
|
||||
}
|
||||
|
||||
void test_checkout_binaryunicode__autocrlf(void)
|
||||
{
|
||||
git_config *config;
|
||||
|
||||
cl_git_pass(git_repository_config(&config, g_repo));
|
||||
cl_git_pass(git_config_set_bool(config, "core.autocrlf", true));
|
||||
git_config_free(config);
|
||||
|
||||
execute_test();
|
||||
}
|
1
tests-clar/resources/binaryunicode/.gitted/HEAD
Normal file
1
tests-clar/resources/binaryunicode/.gitted/HEAD
Normal file
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
5
tests-clar/resources/binaryunicode/.gitted/config
Normal file
5
tests-clar/resources/binaryunicode/.gitted/config
Normal file
@ -0,0 +1,5 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
autocrlf = true
|
BIN
tests-clar/resources/binaryunicode/.gitted/index
Normal file
BIN
tests-clar/resources/binaryunicode/.gitted/index
Normal file
Binary file not shown.
3
tests-clar/resources/binaryunicode/.gitted/info/refs
Normal file
3
tests-clar/resources/binaryunicode/.gitted/info/refs
Normal file
@ -0,0 +1,3 @@
|
||||
39e046d1416a208265b754124d0d197b4c9c0c47 refs/heads/branch1
|
||||
9e7d8bcd4d24dd57e3f1179aaf7afe648ff50e80 refs/heads/branch2
|
||||
d2a291469f4c11f387600d189313b927ddfe891c refs/heads/master
|
@ -0,0 +1,2 @@
|
||||
P pack-c5bfca875b4995d7aba6e5abf36241f3c397327d.pack
|
||||
|
Binary file not shown.
Binary file not shown.
4
tests-clar/resources/binaryunicode/.gitted/packed-refs
Normal file
4
tests-clar/resources/binaryunicode/.gitted/packed-refs
Normal file
@ -0,0 +1,4 @@
|
||||
# pack-refs with: peeled
|
||||
39e046d1416a208265b754124d0d197b4c9c0c47 refs/heads/branch1
|
||||
9e7d8bcd4d24dd57e3f1179aaf7afe648ff50e80 refs/heads/branch2
|
||||
d2a291469f4c11f387600d189313b927ddfe891c refs/heads/master
|
1
tests-clar/resources/binaryunicode/file.txt
Normal file
1
tests-clar/resources/binaryunicode/file.txt
Normal file
@ -0,0 +1 @@
|
||||
Master branch.
|
Loading…
Reference in New Issue
Block a user