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
697665c0
Commit
697665c0
authored
Aug 21, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #889 from nulltoken/filemode-enum
Filemode enum
parents
b2be351a
9d7ac675
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
116 additions
and
92 deletions
+116
-92
include/git2/tree.h
+4
-4
include/git2/types.h
+10
-0
src/checkout.c
+2
-2
src/notes.c
+9
-3
src/tree.c
+23
-23
src/tree.h
+4
-0
tests-clar/index/filemodes.c
+20
-20
tests-clar/object/tree/attributes.c
+14
-17
tests-clar/object/tree/write.c
+30
-23
No files found.
include/git2/tree.h
View file @
697665c0
...
...
@@ -143,9 +143,9 @@ GIT_EXTERN(const git_tree_entry *) git_tree_entry_byoid(git_tree *tree, const gi
* Get the UNIX file attributes of a tree entry
*
* @param entry a tree entry
* @return
attributes
as an integer
* @return
filemode
as an integer
*/
GIT_EXTERN
(
unsigned
int
)
git_tree_entry_attributes
(
const
git_tree_entry
*
entry
);
GIT_EXTERN
(
git_filemode_t
)
git_tree_entry_filemode
(
const
git_tree_entry
*
entry
);
/**
* Get the filename of a tree entry
...
...
@@ -271,7 +271,7 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(git_treebuilder *bld, con
* @param bld Tree builder
* @param filename Filename of the entry
* @param id SHA1 oid of the entry
* @param
attributes
Folder attributes of the entry. This parameter must
* @param
filemode
Folder attributes of the entry. This parameter must
* be valued with one of the following entries: 0040000, 0100644,
* 0100755, 0120000 or 0160000.
* @return 0 or an error code
...
...
@@ -281,7 +281,7 @@ GIT_EXTERN(int) git_treebuilder_insert(
git_treebuilder
*
bld
,
const
char
*
filename
,
const
git_oid
*
id
,
unsigned
int
attributes
);
git_filemode_t
filemode
);
/**
* Remove an entry from the builder by its filename
...
...
include/git2/types.h
View file @
697665c0
...
...
@@ -175,6 +175,16 @@ typedef enum {
GIT_RESET_MIXED
=
2
,
}
git_reset_type
;
/** Valid modes for index and tree entries. */
typedef
enum
{
GIT_FILEMODE_NEW
=
0000000
,
GIT_FILEMODE_TREE
=
0040000
,
GIT_FILEMODE_BLOB
=
0100644
,
GIT_FILEMODE_BLOB_EXECUTABLE
=
0100755
,
GIT_FILEMODE_LINK
=
0120000
,
GIT_FILEMODE_COMMIT
=
0160000
,
}
git_filemode_t
;
typedef
struct
git_refspec
git_refspec
;
typedef
struct
git_remote
git_remote
;
...
...
src/checkout.c
View file @
697665c0
...
...
@@ -88,7 +88,7 @@ static int blob_contents_to_file(git_repository *repo, git_buf *fnbuf,
/* Allow overriding of file mode */
if
(
!
file_mode
)
file_mode
=
git_tree_entry_
attributes
(
entry
);
file_mode
=
git_tree_entry_
filemode
(
entry
);
if
((
retcode
=
git_futils_mkpath2file
(
git_buf_cstr
(
fnbuf
),
data
->
opts
->
dir_mode
))
<
0
)
goto
bctf_cleanup
;
...
...
@@ -111,7 +111,7 @@ static int checkout_walker(const char *path, const git_tree_entry *entry, void *
{
int
retcode
=
0
;
tree_walk_data
*
data
=
(
tree_walk_data
*
)
payload
;
int
attr
=
git_tree_entry_
attributes
(
entry
);
int
attr
=
git_tree_entry_
filemode
(
entry
);
git_buf
fnbuf
=
GIT_BUF_INIT
;
git_buf_join_n
(
&
fnbuf
,
'/'
,
3
,
git_repository_workdir
(
data
->
repo
),
...
...
src/notes.c
View file @
697665c0
...
...
@@ -33,7 +33,7 @@ static int find_subtree_in_current_level(
if
(
!
git__ishex
(
git_tree_entry_name
(
entry
)))
continue
;
if
(
S_ISDIR
(
git_tree_entry_
attributes
(
entry
))
if
(
S_ISDIR
(
git_tree_entry_
filemode
(
entry
))
&&
strlen
(
git_tree_entry_name
(
entry
))
==
2
&&
!
strncmp
(
git_tree_entry_name
(
entry
),
annotated_object_sha
+
fanout
,
2
))
return
git_tree_lookup
(
out
,
repo
,
git_tree_entry_id
(
entry
));
...
...
@@ -180,7 +180,7 @@ static int manipulate_note_in_tree_r(
subtree_name
[
2
]
=
'\0'
;
error
=
tree_write
(
out
,
repo
,
parent
,
git_tree_id
(
new
),
subtree_name
,
0040000
);
subtree_name
,
GIT_FILEMODE_TREE
);
cleanup:
...
...
@@ -252,7 +252,13 @@ static int insert_note_in_tree_enotfound_cb(git_tree **out,
GIT_UNUSED
(
current_error
);
/* No existing fanout at this level, insert in place */
return
tree_write
(
out
,
repo
,
parent
,
note_oid
,
annotated_object_sha
+
fanout
,
0100644
);
return
tree_write
(
out
,
repo
,
parent
,
note_oid
,
annotated_object_sha
+
fanout
,
GIT_FILEMODE_BLOB
);
}
static
int
note_write
(
git_oid
*
out
,
...
...
src/tree.c
View file @
697665c0
...
...
@@ -14,14 +14,14 @@
#define DEFAULT_TREE_SIZE 16
#define MAX_FILEMODE_BYTES 6
static
bool
valid_
attributes
(
const
int
attributes
)
static
bool
valid_
filemode
(
const
int
filemode
)
{
return
(
attributes
==
0040000
/* Directory */
||
attributes
==
0100644
/* Non executable file */
||
attributes
==
0100664
/* Non executable group writable file */
||
attributes
==
0100755
/* Executable file */
||
attributes
==
0120000
/* Symbolic link */
||
attributes
==
0160000
);
/* Git link */
return
(
filemode
==
GIT_FILEMODE_TREE
||
filemode
==
GIT_FILEMODE_BLOB
||
filemode
==
GIT_FILEMODE_BLOB_GROUP_WRITABLE
||
filemode
==
GIT_FILEMODE_BLOB_EXECUTABLE
||
filemode
==
GIT_FILEMODE_LINK
||
filemode
==
GIT_FILEMODE_COMMIT
);
}
static
int
valid_entry_name
(
const
char
*
filename
)
...
...
@@ -185,9 +185,9 @@ const git_oid *git_tree_id(git_tree *c)
return
git_object_id
((
git_object
*
)
c
);
}
unsigned
int
git_tree_entry_attributes
(
const
git_tree_entry
*
entry
)
git_filemode_t
git_tree_entry_filemode
(
const
git_tree_entry
*
entry
)
{
return
entry
->
attr
;
return
(
git_filemode_t
)
entry
->
attr
;
}
const
char
*
git_tree_entry_name
(
const
git_tree_entry
*
entry
)
...
...
@@ -308,8 +308,8 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
int
attr
;
if
(
git__strtol32
(
&
attr
,
buffer
,
&
buffer
,
8
)
<
0
||
!
buffer
||
!
valid_
attributes
(
attr
))
return
tree_error
(
"Failed to parse tree. Can't parse
attributes
"
);
!
buffer
||
!
valid_
filemode
(
attr
))
return
tree_error
(
"Failed to parse tree. Can't parse
filemode
"
);
if
(
*
buffer
++
!=
' '
)
return
tree_error
(
"Failed to parse tree. Object is corrupted"
);
...
...
@@ -368,7 +368,7 @@ static int append_entry(
git_treebuilder
*
bld
,
const
char
*
filename
,
const
git_oid
*
id
,
unsigned
int
attributes
)
git_filemode_t
filemode
)
{
git_tree_entry
*
entry
;
...
...
@@ -376,7 +376,7 @@ static int append_entry(
GITERR_CHECK_ALLOC
(
entry
);
git_oid_cpy
(
&
entry
->
oid
,
id
);
entry
->
attr
=
attributes
;
entry
->
attr
=
(
uint16_t
)
filemode
;
if
(
git_vector_insert
(
&
bld
->
entries
,
entry
)
<
0
)
return
-
1
;
...
...
@@ -517,17 +517,17 @@ static void sort_entries(git_treebuilder *bld)
git_vector_sort
(
&
bld
->
entries
);
}
GIT_INLINE
(
int
)
normalize_attributes
(
const
int
attributes
)
GIT_INLINE
(
git_filemode_t
)
normalize_filemode
(
git_filemode_t
filemode
)
{
/* 100664 mode is an early design mistake. Tree entries may bear
* this mode in some old git repositories, but it's now deprecated.
* We silently normalize while inserting new entries in a tree
* being built.
*/
if
(
attributes
==
0100664
)
return
0100644
;
if
(
filemode
==
GIT_FILEMODE_BLOB_GROUP_WRITABLE
)
return
GIT_FILEMODE_BLOB
;
return
attributes
;
return
filemode
;
}
int
git_treebuilder_create
(
git_treebuilder
**
builder_p
,
const
git_tree
*
source
)
...
...
@@ -553,7 +553,7 @@ int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
if
(
append_entry
(
bld
,
entry_src
->
filename
,
&
entry_src
->
oid
,
normalize_
attributes
(
entry_src
->
attr
))
<
0
)
normalize_
filemode
((
git_filemode_t
)
entry_src
->
attr
))
<
0
)
goto
on_error
;
}
}
...
...
@@ -571,17 +571,17 @@ int git_treebuilder_insert(
git_treebuilder
*
bld
,
const
char
*
filename
,
const
git_oid
*
id
,
unsigned
int
attributes
)
git_filemode_t
filemode
)
{
git_tree_entry
*
entry
;
int
pos
;
assert
(
bld
&&
id
&&
filename
);
if
(
!
valid_
attributes
(
attributes
))
return
tree_error
(
"Failed to insert entry. Invalid
attributes
"
);
if
(
!
valid_
filemode
(
filemode
))
return
tree_error
(
"Failed to insert entry. Invalid
filemode
"
);
attributes
=
normalize_attributes
(
attributes
);
filemode
=
normalize_filemode
(
filemode
);
if
(
!
valid_entry_name
(
filename
))
return
tree_error
(
"Failed to insert entry. Invalid name for a tree entry"
);
...
...
@@ -598,7 +598,7 @@ int git_treebuilder_insert(
}
git_oid_cpy
(
&
entry
->
oid
,
id
);
entry
->
attr
=
attributes
;
entry
->
attr
=
filemode
;
if
(
pos
<
0
)
{
if
(
git_vector_insert
(
&
bld
->
entries
,
entry
)
<
0
)
...
...
src/tree.h
View file @
697665c0
...
...
@@ -47,5 +47,9 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj);
*/
int
git_tree__prefix_position
(
git_tree
*
tree
,
const
char
*
prefix
);
/**
* Obsolete mode kept for compatibility reasons
*/
#define GIT_FILEMODE_BLOB_GROUP_WRITABLE 0100664
#endif
tests-clar/index/filemodes.c
View file @
697665c0
...
...
@@ -100,40 +100,40 @@ void test_index_filemodes__untrusted(void)
/* 1 - add 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.0"
,
0644
);
add_and_check_mode
(
index
,
"exec_off"
,
0100644
);
add_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 2 - add 0644 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.0"
,
0644
);
add_and_check_mode
(
index
,
"exec_on"
,
0100755
);
add_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 3 - add 0755 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.1"
,
0755
);
add_and_check_mode
(
index
,
"exec_off"
,
0100644
);
add_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 4 - add 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.1"
,
0755
);
add_and_check_mode
(
index
,
"exec_on"
,
0100755
);
add_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 5 - append 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.2"
,
0644
);
append_and_check_mode
(
index
,
"exec_off"
,
0100644
);
append_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 6 - append 0644 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.2"
,
0644
);
append_and_check_mode
(
index
,
"exec_on"
,
0100755
);
append_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 7 - append 0755 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.3"
,
0755
);
append_and_check_mode
(
index
,
"exec_off"
,
0100644
);
append_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 8 - append 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.3"
,
0755
);
append_and_check_mode
(
index
,
"exec_on"
,
0100755
);
append_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 9 - add new 0644 -> expect 0644 */
cl_git_write2file
(
"filemodes/new_off"
,
"blah"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
);
add_and_check_mode
(
index
,
"new_off"
,
0100644
);
add_and_check_mode
(
index
,
"new_off"
,
GIT_FILEMODE_BLOB
);
/* this test won't give predictable results on a platform
* that doesn't support filemodes correctly, so skip it.
...
...
@@ -142,7 +142,7 @@ void test_index_filemodes__untrusted(void)
/* 10 - add 0755 -> expect 0755 */
cl_git_write2file
(
"filemodes/new_on"
,
"blah"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0755
);
add_and_check_mode
(
index
,
"new_on"
,
0100755
);
add_and_check_mode
(
index
,
"new_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
}
git_index_free
(
index
);
...
...
@@ -168,45 +168,45 @@ void test_index_filemodes__trusted(void)
/* 1 - add 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.0"
,
0644
);
add_and_check_mode
(
index
,
"exec_off"
,
0100644
);
add_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 2 - add 0644 over existing 0755 -> expect 0644 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.0"
,
0644
);
add_and_check_mode
(
index
,
"exec_on"
,
0100644
);
add_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB
);
/* 3 - add 0755 over existing 0644 -> expect 0755 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.1"
,
0755
);
add_and_check_mode
(
index
,
"exec_off"
,
0100755
);
add_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 4 - add 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.1"
,
0755
);
add_and_check_mode
(
index
,
"exec_on"
,
0100755
);
add_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 5 - append 0644 over existing 0644 -> expect 0644 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.2"
,
0644
);
append_and_check_mode
(
index
,
"exec_off"
,
0100644
);
append_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB
);
/* 6 - append 0644 over existing 0755 -> expect 0644 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.2"
,
0644
);
append_and_check_mode
(
index
,
"exec_on"
,
0100644
);
append_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB
);
/* 7 - append 0755 over existing 0644 -> expect 0755 */
replace_file_with_mode
(
"exec_off"
,
"filemodes/exec_off.3"
,
0755
);
append_and_check_mode
(
index
,
"exec_off"
,
0100755
);
append_and_check_mode
(
index
,
"exec_off"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 8 - append 0755 over existing 0755 -> expect 0755 */
replace_file_with_mode
(
"exec_on"
,
"filemodes/exec_on.3"
,
0755
);
append_and_check_mode
(
index
,
"exec_on"
,
0100755
);
append_and_check_mode
(
index
,
"exec_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
/* 9 - add new 0644 -> expect 0644 */
cl_git_write2file
(
"filemodes/new_off"
,
"blah"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
);
add_and_check_mode
(
index
,
"new_off"
,
0100644
);
add_and_check_mode
(
index
,
"new_off"
,
GIT_FILEMODE_BLOB
);
/* 10 - add 0755 -> expect 0755 */
cl_git_write2file
(
"filemodes/new_on"
,
"blah"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0755
);
add_and_check_mode
(
index
,
"new_on"
,
0100755
);
add_and_check_mode
(
index
,
"new_on"
,
GIT_FILEMODE_BLOB_EXECUTABLE
);
git_index_free
(
index
);
}
tests-clar/object/tree/attributes.c
View file @
697665c0
...
...
@@ -4,9 +4,6 @@
static
const
char
*
blob_oid
=
"3d0970ec547fc41ef8a5882dde99c6adce65b021"
;
static
const
char
*
tree_oid
=
"1b05fdaa881ee45b48cbaa5e9b037d667a47745e"
;
#define GROUP_WRITABLE_FILE 0100664
#define REGULAR_FILE 0100644
void
test_object_tree_attributes__ensure_correctness_of_attributes_on_insertion
(
void
)
{
git_treebuilder
*
builder
;
...
...
@@ -16,9 +13,9 @@ void test_object_tree_attributes__ensure_correctness_of_attributes_on_insertion(
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
NULL
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
0777777
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
0100666
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
0000001
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
(
git_filemode_t
)
0777777
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
(
git_filemode_t
)
0100666
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"one.txt"
,
&
oid
,
(
git_filemode_t
)
0000001
));
git_treebuilder_free
(
builder
);
}
...
...
@@ -37,8 +34,8 @@ void test_object_tree_attributes__group_writable_tree_entries_created_with_an_an
entry
=
git_tree_entry_byname
(
tree
,
"old_mode.txt"
);
cl_assert_equal_i
(
G
ROUP_WRITABLE_FI
LE
,
git_tree_entry_
attributes
(
entry
));
G
IT_FILEMODE_BLOB_GROUP_WRITAB
LE
,
git_tree_entry_
filemode
(
entry
));
git_tree_free
(
tree
);
git_repository_free
(
repo
);
...
...
@@ -63,11 +60,11 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
builder
,
"normalized.txt"
,
&
bid
,
G
ROUP_WRITABLE_FI
LE
));
G
IT_FILEMODE_BLOB_GROUP_WRITAB
LE
));
cl_assert_equal_i
(
REGULAR_FILE
,
git_tree_entry_
attributes
(
entry
));
GIT_FILEMODE_BLOB
,
git_tree_entry_
filemode
(
entry
));
cl_git_pass
(
git_treebuilder_write
(
&
tid
,
repo
,
builder
));
git_treebuilder_free
(
builder
);
...
...
@@ -76,8 +73,8 @@ void test_object_tree_attributes__normalize_attributes_when_inserting_in_a_new_t
entry
=
git_tree_entry_byname
(
tree
,
"normalized.txt"
);
cl_assert_equal_i
(
REGULAR_FILE
,
git_tree_entry_
attributes
(
entry
));
GIT_FILEMODE_BLOB
,
git_tree_entry_
filemode
(
entry
));
git_tree_free
(
tree
);
cl_git_sandbox_cleanup
();
...
...
@@ -100,8 +97,8 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
entry
=
git_treebuilder_get
(
builder
,
"old_mode.txt"
);
cl_assert_equal_i
(
REGULAR_FILE
,
git_tree_entry_
attributes
(
entry
));
GIT_FILEMODE_BLOB
,
git_tree_entry_
filemode
(
entry
));
cl_git_pass
(
git_treebuilder_write
(
&
tid2
,
repo
,
builder
));
git_treebuilder_free
(
builder
);
...
...
@@ -110,8 +107,8 @@ void test_object_tree_attributes__normalize_attributes_when_creating_a_tree_from
cl_git_pass
(
git_tree_lookup
(
&
tree
,
repo
,
&
tid2
));
entry
=
git_tree_entry_byname
(
tree
,
"old_mode.txt"
);
cl_assert_equal_i
(
REGULAR_FILE
,
git_tree_entry_
attributes
(
entry
));
GIT_FILEMODE_BLOB
,
git_tree_entry_
filemode
(
entry
));
git_tree_free
(
tree
);
cl_git_sandbox_cleanup
();
...
...
tests-clar/object/tree/write.c
View file @
697665c0
...
...
@@ -35,11 +35,16 @@ void test_object_tree_write__from_memory(void)
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
tree
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
""
,
&
bid
,
0100644
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"/"
,
&
bid
,
0100644
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"folder/new.txt"
,
&
bid
,
0100644
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
""
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"/"
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_fail
(
git_treebuilder_insert
(
NULL
,
builder
,
"folder/new.txt"
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
GIT_FILEMODE_BLOB
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
0100644
));
cl_git_pass
(
git_treebuilder_write
(
&
rid
,
g_repo
,
builder
));
cl_assert
(
git_oid_cmp
(
&
rid
,
&
id2
)
==
0
);
...
...
@@ -63,14 +68,16 @@ void test_object_tree_write__subtree(void)
//create subtree
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
NULL
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
0100644
));
//-V536
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
GIT_FILEMODE_BLOB
));
//-V536
cl_git_pass
(
git_treebuilder_write
(
&
subtree_id
,
g_repo
,
builder
));
git_treebuilder_free
(
builder
);
// create parent tree
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
tree
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new"
,
&
subtree_id
,
040000
));
//-V536
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new"
,
&
subtree_id
,
GIT_FILEMODE_TREE
));
//-V536
cl_git_pass
(
git_treebuilder_write
(
&
id_hiearar
,
g_repo
,
builder
));
git_treebuilder_free
(
builder
);
git_tree_free
(
tree
);
...
...
@@ -96,23 +103,23 @@ void test_object_tree_write__sorted_subtrees(void)
unsigned
int
attr
;
const
char
*
filename
;
}
entries
[]
=
{
{
0100644
,
".gitattributes"
},
{
0100644
,
".gitignore"
},
{
0100644
,
".htaccess"
},
{
0100644
,
"Capfile"
},
{
0100644
,
"Makefile"
},
{
0100644
,
"README"
},
{
0040000
,
"app"
},
{
0040000
,
"cake"
},
{
0040000
,
"config"
},
{
0100644
,
"c"
},
{
0100644
,
"git_test.txt"
},
{
0100644
,
"htaccess.htaccess"
},
{
0100644
,
"index.php"
},
{
0040000
,
"plugins"
},
{
0040000
,
"schemas"
},
{
0040000
,
"ssl-certs"
},
{
0040000
,
"vendors"
}
{
GIT_FILEMODE_BLOB
,
".gitattributes"
},
{
GIT_FILEMODE_BLOB
,
".gitignore"
},
{
GIT_FILEMODE_BLOB
,
".htaccess"
},
{
GIT_FILEMODE_BLOB
,
"Capfile"
},
{
GIT_FILEMODE_BLOB
,
"Makefile"
},
{
GIT_FILEMODE_BLOB
,
"README"
},
{
GIT_FILEMODE_TREE
,
"app"
},
{
GIT_FILEMODE_TREE
,
"cake"
},
{
GIT_FILEMODE_TREE
,
"config"
},
{
GIT_FILEMODE_BLOB
,
"c"
},
{
GIT_FILEMODE_BLOB
,
"git_test.txt"
},
{
GIT_FILEMODE_BLOB
,
"htaccess.htaccess"
},
{
GIT_FILEMODE_BLOB
,
"index.php"
},
{
GIT_FILEMODE_TREE
,
"plugins"
},
{
GIT_FILEMODE_TREE
,
"schemas"
},
{
GIT_FILEMODE_TREE
,
"ssl-certs"
},
{
GIT_FILEMODE_TREE
,
"vendors"
}
};
git_oid
blank_oid
,
tree_oid
;
...
...
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