Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
9780020b
Commit
9780020b
authored
Feb 09, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for crlf filtering into the repository
parent
f77127da
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
0 deletions
+136
-0
tests/index/crlf.c
+136
-0
No files found.
tests/index/crlf.c
0 → 100644
View file @
9780020b
#include "clar_libgit2.h"
#include "../filter/crlf.h"
#include "git2/checkout.h"
#include "repository.h"
#include "posix.h"
#define FILE_CONTENTS_LF "one\ntwo\nthree\nfour\n"
#define FILE_CONTENTS_CRLF "one\r\ntwo\r\nthree\r\nfour\r\n"
#define FILE_OID_LF "f384549cbeb481e437091320de6d1f2e15e11b4a"
#define FILE_OID_CRLF "7fbf4d847b191141d80f30c8ab03d2ad4cd543a9"
static
git_repository
*
g_repo
;
static
git_index
*
g_index
;
void
test_index_crlf__initialize
(
void
)
{
g_repo
=
cl_git_sandbox_init
(
"crlf"
);
cl_git_pass
(
git_repository_index
(
&
g_index
,
g_repo
));
}
void
test_index_crlf__cleanup
(
void
)
{
git_index_free
(
g_index
);
cl_git_sandbox_cleanup
();
}
void
test_index_crlf__autocrlf_false_no_attrs
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
false
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_OID_CRLF
:
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
void
test_index_crlf__autocrlf_true_no_attrs
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
true
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
void
test_index_crlf__autocrlf_input_no_attrs
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_repo_set_string
(
g_repo
,
"core.autocrlf"
,
"input"
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
void
test_index_crlf__autocrlf_false_text_auto_attr
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_git_mkfile
(
"./crlf/.gitattributes"
,
"* text=auto
\n
"
);
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
false
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
void
test_index_crlf__autocrlf_true_text_auto_attr
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_git_mkfile
(
"./crlf/.gitattributes"
,
"* text=auto
\n
"
);
cl_repo_set_bool
(
g_repo
,
"core.autocrlf"
,
false
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
void
test_index_crlf__autocrlf_input_text_auto_attr
(
void
)
{
const
git_index_entry
*
entry
;
git_oid
oid
;
cl_git_mkfile
(
"./crlf/.gitattributes"
,
"* text=auto
\n
"
);
cl_repo_set_string
(
g_repo
,
"core.autocrlf"
,
"input"
);
cl_git_mkfile
(
"./crlf/newfile.txt"
,
(
GIT_EOL_NATIVE
==
GIT_EOL_CRLF
)
?
FILE_CONTENTS_CRLF
:
FILE_CONTENTS_LF
);
cl_git_pass
(
git_index_add_bypath
(
g_index
,
"newfile.txt"
));
entry
=
git_index_get_bypath
(
g_index
,
"newfile.txt"
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
FILE_OID_LF
));
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
id
)
==
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment