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
0e9ea5d0
Commit
0e9ea5d0
authored
Nov 17, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1077 from nulltoken/fix/api
Itsy bitsy tiny winy minor api related fixes
parents
e087973e
b15df1d9
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
260 additions
and
119 deletions
+260
-119
examples/general.c
+1
-1
include/git2/config.h
+6
-18
include/git2/reflog.h
+10
-4
include/git2/repository.h
+1
-1
include/git2/tag.h
+1
-1
src/config.c
+19
-7
src/config.h
+13
-0
src/pack-objects.h
+5
-5
src/reflog.c
+23
-18
src/repository.c
+54
-20
src/revparse.c
+3
-3
src/stash.c
+2
-2
src/tag.c
+1
-1
tests-clar/clar_helpers.c
+49
-0
tests-clar/clar_libgit2.h
+3
-0
tests-clar/config/new.c
+1
-0
tests-clar/config/read.c
+20
-0
tests-clar/core/env.c
+16
-8
tests-clar/object/raw/short.c
+1
-1
tests-clar/object/tag/read.c
+1
-1
tests-clar/refs/reflog/drop.c
+12
-10
tests-clar/refs/reflog/reflog.c
+2
-2
tests-clar/repo/getters.c
+15
-15
tests-clar/stash/drop.c
+1
-1
No files found.
examples/general.c
View file @
0e9ea5d0
...
@@ -239,7 +239,7 @@ int main (int argc, char** argv)
...
@@ -239,7 +239,7 @@ int main (int argc, char** argv)
// the tagger (a git_signature - name, email, timestamp), and the tag message.
// the tagger (a git_signature - name, email, timestamp), and the tag message.
git_tag_target
((
git_object
**
)
&
commit
,
tag
);
git_tag_target
((
git_object
**
)
&
commit
,
tag
);
tname
=
git_tag_name
(
tag
);
// "test"
tname
=
git_tag_name
(
tag
);
// "test"
ttype
=
git_tag_type
(
tag
);
// GIT_OBJ_COMMIT (otype enum)
ttype
=
git_tag_t
arget_t
ype
(
tag
);
// GIT_OBJ_COMMIT (otype enum)
tmessage
=
git_tag_message
(
tag
);
// "tag message\n"
tmessage
=
git_tag_message
(
tag
);
// "tag message\n"
printf
(
"Tag Message: %s
\n
"
,
tmessage
);
printf
(
"Tag Message: %s
\n
"
,
tmessage
);
...
...
include/git2/config.h
View file @
0e9ea5d0
...
@@ -135,19 +135,6 @@ GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
...
@@ -135,19 +135,6 @@ GIT_EXTERN(int) git_config_find_system(char *system_config_path, size_t length);
GIT_EXTERN
(
int
)
git_config_open_default
(
git_config
**
out
);
GIT_EXTERN
(
int
)
git_config_open_default
(
git_config
**
out
);
/**
/**
* Create a configuration file backend for ondisk files
*
* These are the normal `.gitconfig` files that Core Git
* processes. Note that you first have to add this file to a
* configuration object before you can query it for configuration
* variables.
*
* @param out the new backend
* @param path where the config file is located
*/
GIT_EXTERN
(
int
)
git_config_file__ondisk
(
struct
git_config_file
**
out
,
const
char
*
path
);
/**
* Allocate a new configuration object
* Allocate a new configuration object
*
*
* This object is empty, so you have to add a file to it before you
* This object is empty, so you have to add a file to it before you
...
@@ -202,7 +189,8 @@ GIT_EXTERN(int) git_config_add_file(
...
@@ -202,7 +189,8 @@ GIT_EXTERN(int) git_config_add_file(
* @param force if a config file already exists for the given
* @param force if a config file already exists for the given
* priority level, replace it
* priority level, replace it
* @return 0 on success, GIT_EEXISTS when adding more than one file
* @return 0 on success, GIT_EEXISTS when adding more than one file
* for a given priority level (and force_replace set to 0), or error code
* for a given priority level (and force_replace set to 0),
* GIT_ENOTFOUND when the file doesn't exist or error code
*/
*/
GIT_EXTERN
(
int
)
git_config_add_file_ondisk
(
GIT_EXTERN
(
int
)
git_config_add_file_ondisk
(
git_config
*
cfg
,
git_config
*
cfg
,
...
@@ -210,7 +198,6 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
...
@@ -210,7 +198,6 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
unsigned
int
level
,
unsigned
int
level
,
int
force
);
int
force
);
/**
/**
* Create a new config instance containing a single on-disk file
* Create a new config instance containing a single on-disk file
*
*
...
@@ -219,11 +206,12 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
...
@@ -219,11 +206,12 @@ GIT_EXTERN(int) git_config_add_file_ondisk(
* - git_config_new
* - git_config_new
* - git_config_add_file_ondisk
* - git_config_add_file_ondisk
*
*
* @param
cfg
The configuration instance to create
* @param
out
The configuration instance to create
* @param path Path to the on-disk file to open
* @param path Path to the on-disk file to open
* @return 0 or an error code
* @return 0 on success, GIT_ENOTFOUND when the file doesn't exist
* or an error code
*/
*/
GIT_EXTERN
(
int
)
git_config_open_ondisk
(
git_config
**
cfg
,
const
char
*
path
);
GIT_EXTERN
(
int
)
git_config_open_ondisk
(
git_config
**
out
,
const
char
*
path
);
/**
/**
* Build a single-level focused config object from a multi-level one.
* Build a single-level focused config object from a multi-level one.
...
...
include/git2/reflog.h
View file @
0e9ea5d0
...
@@ -88,8 +88,12 @@ GIT_EXTERN(unsigned int) git_reflog_entrycount(git_reflog *reflog);
...
@@ -88,8 +88,12 @@ GIT_EXTERN(unsigned int) git_reflog_entrycount(git_reflog *reflog);
/**
/**
* Lookup an entry by its index
* Lookup an entry by its index
*
*
* Requesting the reflog entry with an index of 0 (zero) will
* return the most recently created entry.
*
* @param reflog a previously loaded reflog
* @param reflog a previously loaded reflog
* @param idx the position to lookup
* @param idx the position of the entry to lookup. Should be greater than or
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
* @return the entry; NULL if not found
* @return the entry; NULL if not found
*/
*/
GIT_EXTERN
(
const
git_reflog_entry
*
)
git_reflog_entry_byindex
(
git_reflog
*
reflog
,
size_t
idx
);
GIT_EXTERN
(
const
git_reflog_entry
*
)
git_reflog_entry_byindex
(
git_reflog
*
reflog
,
size_t
idx
);
...
@@ -103,15 +107,17 @@ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog
...
@@ -103,15 +107,17 @@ GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog
*
*
* @param reflog a previously loaded reflog.
* @param reflog a previously loaded reflog.
*
*
* @param idx the position of the entry to remove.
* @param idx the position of the entry to remove. Should be greater than or
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
*
*
* @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
* @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
*
*
* @return 0 on success or an error code.
* @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist
* or an error code.
*/
*/
GIT_EXTERN
(
int
)
git_reflog_drop
(
GIT_EXTERN
(
int
)
git_reflog_drop
(
git_reflog
*
reflog
,
git_reflog
*
reflog
,
unsigned
in
t
idx
,
size_
t
idx
,
int
rewrite_previous_entry
);
int
rewrite_previous_entry
);
/**
/**
...
...
include/git2/repository.h
View file @
0e9ea5d0
...
@@ -305,7 +305,7 @@ GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo);
...
@@ -305,7 +305,7 @@ GIT_EXTERN(int) git_repository_head_orphan(git_repository *repo);
* Check if a repository is empty
* Check if a repository is empty
*
*
* An empty repository has just been initialized and contains
* An empty repository has just been initialized and contains
* no
commit
s.
* no
reference
s.
*
*
* @param repo Repo to test
* @param repo Repo to test
* @return 1 if the repository is empty, 0 if it isn't, error code
* @return 1 if the repository is empty, 0 if it isn't, error code
...
...
include/git2/tag.h
View file @
0e9ea5d0
...
@@ -104,7 +104,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
...
@@ -104,7 +104,7 @@ GIT_EXTERN(const git_oid *) git_tag_target_oid(git_tag *tag);
* @param tag a previously loaded tag.
* @param tag a previously loaded tag.
* @return type of the tagged object
* @return type of the tagged object
*/
*/
GIT_EXTERN
(
git_otype
)
git_tag_type
(
git_tag
*
tag
);
GIT_EXTERN
(
git_otype
)
git_tag_t
arget_t
ype
(
git_tag
*
tag
);
/**
/**
* Get the name of a tag
* Get the name of a tag
...
...
src/config.c
View file @
0e9ea5d0
...
@@ -90,6 +90,13 @@ int git_config_add_file_ondisk(
...
@@ -90,6 +90,13 @@ int git_config_add_file_ondisk(
git_config_file
*
file
=
NULL
;
git_config_file
*
file
=
NULL
;
int
res
;
int
res
;
assert
(
cfg
&&
path
);
if
(
!
git_path_isfile
(
path
))
{
giterr_set
(
GITERR_CONFIG
,
"File '%s' doesn't exists."
,
path
);
return
GIT_ENOTFOUND
;
}
if
(
git_config_file__ondisk
(
&
file
,
path
)
<
0
)
if
(
git_config_file__ondisk
(
&
file
,
path
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -105,17 +112,22 @@ int git_config_add_file_ondisk(
...
@@ -105,17 +112,22 @@ int git_config_add_file_ondisk(
return
0
;
return
0
;
}
}
int
git_config_open_ondisk
(
git_config
**
cfg
,
const
char
*
path
)
int
git_config_open_ondisk
(
git_config
**
out
,
const
char
*
path
)
{
{
i
f
(
git_config_new
(
cfg
)
<
0
)
i
nt
error
;
return
-
1
;
git_config
*
config
;
if
(
git_config_add_file_ondisk
(
*
cfg
,
path
,
GIT_CONFIG_LEVEL_LOCAL
,
0
)
<
0
)
{
*
out
=
NULL
;
git_config_free
(
*
cfg
);
if
(
git_config_new
(
&
config
)
<
0
)
return
-
1
;
return
-
1
;
}
return
0
;
if
((
error
=
git_config_add_file_ondisk
(
config
,
path
,
GIT_CONFIG_LEVEL_LOCAL
,
0
))
<
0
)
git_config_free
(
config
);
else
*
out
=
config
;
return
error
;
}
}
static
int
find_internal_file_by_level
(
static
int
find_internal_file_by_level
(
...
...
src/config.h
View file @
0e9ea5d0
...
@@ -32,4 +32,17 @@ extern int git_config_rename_section(
...
@@ -32,4 +32,17 @@ extern int git_config_rename_section(
const
char
*
old_section_name
,
/* eg "branch.dummy" */
const
char
*
old_section_name
,
/* eg "branch.dummy" */
const
char
*
new_section_name
);
/* NULL to drop the old section */
const
char
*
new_section_name
);
/* NULL to drop the old section */
/**
* Create a configuration file backend for ondisk files
*
* These are the normal `.gitconfig` files that Core Git
* processes. Note that you first have to add this file to a
* configuration object before you can query it for configuration
* variables.
*
* @param out the new backend
* @param path where the config file is located
*/
extern
int
git_config_file__ondisk
(
struct
git_config_file
**
out
,
const
char
*
path
);
#endif
#endif
src/pack-objects.h
View file @
0e9ea5d0
...
@@ -71,11 +71,11 @@ struct git_packbuilder {
...
@@ -71,11 +71,11 @@ struct git_packbuilder {
git_cond
progress_cond
;
git_cond
progress_cond
;
/* configs */
/* configs */
u
nsigned
long
delta_cache_size
;
u
int64_t
delta_cache_size
;
u
nsigned
long
max_delta_cache_size
;
u
int64_t
max_delta_cache_size
;
u
nsigned
long
cache_max_small_delta_size
;
u
int64_t
cache_max_small_delta_size
;
u
nsigned
long
big_file_threshold
;
u
int64_t
big_file_threshold
;
u
nsigned
long
window_memory_limit
;
u
int64_t
window_memory_limit
;
int
nr_threads
;
/* nr of threads to use */
int
nr_threads
;
/* nr of threads to use */
...
...
src/reflog.c
View file @
0e9ea5d0
...
@@ -291,8 +291,8 @@ success:
...
@@ -291,8 +291,8 @@ success:
int
git_reflog_append
(
git_reflog
*
reflog
,
const
git_oid
*
new_oid
,
int
git_reflog_append
(
git_reflog
*
reflog
,
const
git_oid
*
new_oid
,
const
git_signature
*
committer
,
const
char
*
msg
)
const
git_signature
*
committer
,
const
char
*
msg
)
{
{
int
count
;
git_reflog_entry
*
entry
;
git_reflog_entry
*
entry
;
const
git_reflog_entry
*
previous
;
const
char
*
newline
;
const
char
*
newline
;
assert
(
reflog
&&
new_oid
&&
committer
);
assert
(
reflog
&&
new_oid
&&
committer
);
...
@@ -319,16 +319,12 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid,
...
@@ -319,16 +319,12 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid,
}
}
}
}
count
=
git_reflog_entrycount
(
reflog
);
previous
=
git_reflog_entry_byindex
(
reflog
,
0
);
if
(
count
==
0
)
if
(
previous
==
NULL
)
git_oid_fromstr
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
);
git_oid_fromstr
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
);
else
{
else
const
git_reflog_entry
*
previous
;
previous
=
git_reflog_entry_byindex
(
reflog
,
count
-
1
);
git_oid_cpy
(
&
entry
->
oid_old
,
&
previous
->
oid_cur
);
git_oid_cpy
(
&
entry
->
oid_old
,
&
previous
->
oid_cur
);
}
git_oid_cpy
(
&
entry
->
oid_cur
,
new_oid
);
git_oid_cpy
(
&
entry
->
oid_cur
,
new_oid
);
...
@@ -417,8 +413,16 @@ unsigned int git_reflog_entrycount(git_reflog *reflog)
...
@@ -417,8 +413,16 @@ unsigned int git_reflog_entrycount(git_reflog *reflog)
const
git_reflog_entry
*
git_reflog_entry_byindex
(
git_reflog
*
reflog
,
size_t
idx
)
const
git_reflog_entry
*
git_reflog_entry_byindex
(
git_reflog
*
reflog
,
size_t
idx
)
{
{
int
pos
;
assert
(
reflog
);
assert
(
reflog
);
return
git_vector_get
(
&
reflog
->
entries
,
idx
);
pos
=
git_reflog_entrycount
(
reflog
)
-
(
idx
+
1
);
if
(
pos
<
0
)
return
NULL
;
return
git_vector_get
(
&
reflog
->
entries
,
pos
);
}
}
const
git_oid
*
git_reflog_entry_oidold
(
const
git_reflog_entry
*
entry
)
const
git_oid
*
git_reflog_entry_oidold
(
const
git_reflog_entry
*
entry
)
...
@@ -447,7 +451,7 @@ char * git_reflog_entry_msg(const git_reflog_entry *entry)
...
@@ -447,7 +451,7 @@ char * git_reflog_entry_msg(const git_reflog_entry *entry)
int
git_reflog_drop
(
int
git_reflog_drop
(
git_reflog
*
reflog
,
git_reflog
*
reflog
,
unsigned
in
t
idx
,
size_
t
idx
,
int
rewrite_previous_entry
)
int
rewrite_previous_entry
)
{
{
unsigned
int
entrycount
;
unsigned
int
entrycount
;
...
@@ -457,30 +461,31 @@ int git_reflog_drop(
...
@@ -457,30 +461,31 @@ int git_reflog_drop(
entrycount
=
git_reflog_entrycount
(
reflog
);
entrycount
=
git_reflog_entrycount
(
reflog
);
if
(
idx
>=
entrycount
)
entry
=
(
git_reflog_entry
*
)
git_reflog_entry_byindex
(
reflog
,
idx
);
if
(
entry
==
NULL
)
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
entry
=
git_vector_get
(
&
reflog
->
entries
,
idx
);
reflog_entry_free
(
entry
);
reflog_entry_free
(
entry
);
if
(
git_vector_remove
(
&
reflog
->
entries
,
idx
)
<
0
)
if
(
git_vector_remove
(
&
reflog
->
entries
,
entrycount
-
(
idx
+
1
)
)
<
0
)
return
-
1
;
return
-
1
;
if
(
!
rewrite_previous_entry
)
if
(
!
rewrite_previous_entry
)
return
0
;
return
0
;
/* No need to rewrite anything when removing the most recent entry */
/* No need to rewrite anything when removing the most recent entry */
if
(
idx
==
entrycount
-
1
)
if
(
idx
==
0
)
return
0
;
return
0
;
/*
There are no more entries in the log
*/
/*
Have the latest entry just been dropped?
*/
if
(
entrycount
==
1
)
if
(
entrycount
==
1
)
return
0
;
return
0
;
entry
=
(
git_reflog_entry
*
)
git_reflog_entry_byindex
(
reflog
,
idx
);
entry
=
(
git_reflog_entry
*
)
git_reflog_entry_byindex
(
reflog
,
idx
-
1
);
/* If the oldest entry has just been removed... */
/* If the oldest entry has just been removed... */
if
(
idx
==
0
)
{
if
(
idx
==
entrycount
-
1
)
{
/* ...clear the oid_old member of the "new" oldest entry */
/* ...clear the oid_old member of the "new" oldest entry */
if
(
git_oid_fromstr
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
<
0
)
if
(
git_oid_fromstr
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -488,7 +493,7 @@ int git_reflog_drop(
...
@@ -488,7 +493,7 @@ int git_reflog_drop(
return
0
;
return
0
;
}
}
previous
=
(
git_reflog_entry
*
)
git_reflog_entry_byindex
(
reflog
,
idx
-
1
);
previous
=
(
git_reflog_entry
*
)
git_reflog_entry_byindex
(
reflog
,
idx
);
git_oid_cpy
(
&
entry
->
oid_old
,
&
previous
->
oid_cur
);
git_oid_cpy
(
&
entry
->
oid_old
,
&
previous
->
oid_cur
);
return
0
;
return
0
;
...
...
src/repository.c
View file @
0e9ea5d0
...
@@ -750,6 +750,23 @@ static bool are_symlinks_supported(const char *wd_path)
...
@@ -750,6 +750,23 @@ static bool are_symlinks_supported(const char *wd_path)
return
_symlinks_supported
;
return
_symlinks_supported
;
}
}
static
int
create_empty_file
(
const
char
*
path
,
mode_t
mode
)
{
int
fd
;
if
((
fd
=
p_creat
(
path
,
mode
))
<
0
)
{
giterr_set
(
GITERR_OS
,
"Error while creating '%s'"
,
path
);
return
-
1
;
}
if
(
p_close
(
fd
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"Error while closing '%s'"
,
path
);
return
-
1
;
}
return
0
;
}
static
int
repo_init_config
(
static
int
repo_init_config
(
const
char
*
repo_dir
,
const
char
*
repo_dir
,
const
char
*
work_dir
,
const
char
*
work_dir
,
...
@@ -766,6 +783,12 @@ static int repo_init_config(
...
@@ -766,6 +783,12 @@ static int repo_init_config(
if
(
git_buf_joinpath
(
&
cfg_path
,
repo_dir
,
GIT_CONFIG_FILENAME_INREPO
)
<
0
)
if
(
git_buf_joinpath
(
&
cfg_path
,
repo_dir
,
GIT_CONFIG_FILENAME_INREPO
)
<
0
)
return
-
1
;
return
-
1
;
if
(
!
git_path_isfile
(
git_buf_cstr
(
&
cfg_path
))
&&
create_empty_file
(
git_buf_cstr
(
&
cfg_path
),
GIT_CONFIG_FILE_MODE
)
<
0
)
{
git_buf_free
(
&
cfg_path
);
return
-
1
;
}
if
(
git_config_open_ondisk
(
&
config
,
git_buf_cstr
(
&
cfg_path
))
<
0
)
{
if
(
git_config_open_ondisk
(
&
config
,
git_buf_cstr
(
&
cfg_path
))
<
0
)
{
git_buf_free
(
&
cfg_path
);
git_buf_free
(
&
cfg_path
);
return
-
1
;
return
-
1
;
...
@@ -1241,36 +1264,47 @@ int git_repository_head_orphan(git_repository *repo)
...
@@ -1241,36 +1264,47 @@ int git_repository_head_orphan(git_repository *repo)
return
0
;
return
0
;
}
}
int
git_repository_is_empty
(
git_repository
*
repo
)
int
at_least_one_cb
(
const
char
*
refname
,
void
*
payload
)
{
{
git_reference
*
head
=
NULL
,
*
branch
=
NULL
;
GIT_UNUSED
(
refname
)
;
int
error
;
GIT_UNUSED
(
payload
)
;
if
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
)
<
0
)
return
GIT_EUSER
;
return
-
1
;
}
if
(
git_reference_type
(
head
)
!=
GIT_REF_SYMBOLIC
)
{
static
int
repo_contains_no_reference
(
git_repository
*
repo
)
git_reference_free
(
head
);
{
return
0
;
int
error
;
}
error
=
git_reference_foreach
(
repo
,
GIT_REF_LISTALL
,
at_least_one_cb
,
NULL
);
if
(
strcmp
(
git_reference_target
(
head
),
GIT_REFS_HEADS_DIR
"master"
)
!=
0
)
{
if
(
error
==
GIT_EUSER
)
git_reference_free
(
head
);
return
0
;
return
0
;
}
error
=
git_reference_resolve
(
&
branch
,
head
);
git_reference_free
(
head
)
;
return
error
==
0
?
1
:
error
;
git_reference_free
(
branch
);
}
if
(
error
==
GIT_ENOTFOUND
)
int
git_repository_is_empty
(
git_repository
*
repo
)
return
1
;
{
git_reference
*
head
=
NULL
;
int
error
,
ref_count
=
0
;
if
(
error
<
0
)
if
(
git_reference_lookup
(
&
head
,
repo
,
GIT_HEAD_FILE
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
if
(
!
(
error
=
git_reference_type
(
head
)
==
GIT_REF_SYMBOLIC
))
goto
cleanup
;
if
(
!
(
error
=
strcmp
(
git_reference_target
(
head
),
GIT_REFS_HEADS_DIR
"master"
)
==
0
))
goto
cleanup
;
error
=
repo_contains_no_reference
(
repo
);
cleanup:
git_reference_free
(
head
);
return
error
<
0
?
-
1
:
error
;
}
}
const
char
*
git_repository_path
(
git_repository
*
repo
)
const
char
*
git_repository_path
(
git_repository
*
repo
)
...
...
src/revparse.c
View file @
0e9ea5d0
...
@@ -201,7 +201,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
...
@@ -201,7 +201,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
numentries
=
git_reflog_entrycount
(
reflog
);
numentries
=
git_reflog_entrycount
(
reflog
);
for
(
i
=
numentries
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
0
;
i
<
numentries
;
i
++
)
{
entry
=
git_reflog_entry_byindex
(
reflog
,
i
);
entry
=
git_reflog_entry_byindex
(
reflog
,
i
);
msg
=
git_reflog_entry_msg
(
entry
);
msg
=
git_reflog_entry_msg
(
entry
);
...
@@ -263,7 +263,7 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i
...
@@ -263,7 +263,7 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i
}
}
entry
=
git_reflog_entry_byindex
(
reflog
,
identifier
);
entry
=
git_reflog_entry_byindex
(
reflog
,
identifier
);
git_oid_cpy
(
oid
,
git_reflog_entry_oid
old
(
entry
));
git_oid_cpy
(
oid
,
git_reflog_entry_oid
new
(
entry
));
error
=
0
;
error
=
0
;
goto
cleanup
;
goto
cleanup
;
...
@@ -271,7 +271,7 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i
...
@@ -271,7 +271,7 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i
int
i
;
int
i
;
git_time
commit_time
;
git_time
commit_time
;
for
(
i
=
numentries
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
0
;
i
<
numentries
;
i
++
)
{
entry
=
git_reflog_entry_byindex
(
reflog
,
i
);
entry
=
git_reflog_entry_byindex
(
reflog
,
i
);
commit_time
=
git_reflog_entry_committer
(
entry
)
->
when
;
commit_time
=
git_reflog_entry_committer
(
entry
)
->
when
;
...
...
src/stash.c
View file @
0e9ea5d0
...
@@ -600,7 +600,7 @@ int git_stash_foreach(
...
@@ -600,7 +600,7 @@ int git_stash_foreach(
max
=
git_reflog_entrycount
(
reflog
);
max
=
git_reflog_entrycount
(
reflog
);
for
(
i
=
0
;
i
<
max
;
i
++
)
{
for
(
i
=
0
;
i
<
max
;
i
++
)
{
entry
=
git_reflog_entry_byindex
(
reflog
,
max
-
i
-
1
);
entry
=
git_reflog_entry_byindex
(
reflog
,
i
);
if
(
callback
(
i
,
if
(
callback
(
i
,
git_reflog_entry_msg
(
entry
),
git_reflog_entry_msg
(
entry
),
...
@@ -642,7 +642,7 @@ int git_stash_drop(
...
@@ -642,7 +642,7 @@ int git_stash_drop(
goto
cleanup
;
goto
cleanup
;
}
}
if
((
error
=
git_reflog_drop
(
reflog
,
max
-
index
-
1
,
true
))
<
0
)
if
((
error
=
git_reflog_drop
(
reflog
,
index
,
true
))
<
0
)
goto
cleanup
;
goto
cleanup
;
if
((
error
=
git_reflog_write
(
reflog
))
<
0
)
if
((
error
=
git_reflog_write
(
reflog
))
<
0
)
...
...
src/tag.c
View file @
0e9ea5d0
...
@@ -39,7 +39,7 @@ const git_oid *git_tag_target_oid(git_tag *t)
...
@@ -39,7 +39,7 @@ const git_oid *git_tag_target_oid(git_tag *t)
return
&
t
->
target
;
return
&
t
->
target
;
}
}
git_otype
git_tag_type
(
git_tag
*
t
)
git_otype
git_tag_t
arget_t
ype
(
git_tag
*
t
)
{
{
assert
(
t
);
assert
(
t
);
return
t
->
type
;
return
t
->
type
;
...
...
tests-clar/clar_helpers.c
View file @
0e9ea5d0
...
@@ -271,3 +271,52 @@ const char* cl_git_path_url(const char *path)
...
@@ -271,3 +271,52 @@ const char* cl_git_path_url(const char *path)
git_buf_free
(
&
path_buf
);
git_buf_free
(
&
path_buf
);
return
url
;
return
url
;
}
}
typedef
struct
{
const
char
*
filename
;
size_t
filename_len
;
}
remove_data
;
static
int
remove_placeholders_recurs
(
void
*
_data
,
git_buf
*
path
)
{
remove_data
*
data
=
(
remove_data
*
)
_data
;
size_t
pathlen
;
if
(
git_path_isdir
(
path
->
ptr
)
==
true
)
return
git_path_direach
(
path
,
remove_placeholders_recurs
,
data
);
pathlen
=
path
->
size
;
if
(
pathlen
<
data
->
filename_len
)
return
0
;
/* if path ends in '/'+filename (or equals filename) */
if
(
!
strcmp
(
data
->
filename
,
path
->
ptr
+
pathlen
-
data
->
filename_len
)
&&
(
pathlen
==
data
->
filename_len
||
path
->
ptr
[
pathlen
-
data
->
filename_len
-
1
]
==
'/'
))
return
p_unlink
(
path
->
ptr
);
return
0
;
}
int
cl_git_remove_placeholders
(
const
char
*
directory_path
,
const
char
*
filename
)
{
int
error
;
remove_data
data
;
git_buf
buffer
=
GIT_BUF_INIT
;
if
(
git_path_isdir
(
directory_path
)
==
false
)
return
-
1
;
if
(
git_buf_sets
(
&
buffer
,
directory_path
)
<
0
)
return
-
1
;
data
.
filename
=
filename
;
data
.
filename_len
=
strlen
(
filename
);
error
=
remove_placeholders_recurs
(
&
data
,
&
buffer
);
git_buf_free
(
&
buffer
);
return
error
;
}
tests-clar/clar_libgit2.h
View file @
0e9ea5d0
...
@@ -61,4 +61,7 @@ void cl_git_sandbox_cleanup(void);
...
@@ -61,4 +61,7 @@ void cl_git_sandbox_cleanup(void);
const
char
*
cl_git_fixture_url
(
const
char
*
fixturename
);
const
char
*
cl_git_fixture_url
(
const
char
*
fixturename
);
const
char
*
cl_git_path_url
(
const
char
*
path
);
const
char
*
cl_git_path_url
(
const
char
*
path
);
/* Test repository cleaner */
int
cl_git_remove_placeholders
(
const
char
*
directory_path
,
const
char
*
filename
);
#endif
#endif
tests-clar/config/new.c
View file @
0e9ea5d0
...
@@ -11,6 +11,7 @@ void test_config_new__write_new_config(void)
...
@@ -11,6 +11,7 @@ void test_config_new__write_new_config(void)
const
char
*
out
;
const
char
*
out
;
git_config
*
config
;
git_config
*
config
;
cl_git_mkfile
(
TEST_CONFIG
,
""
);
cl_git_pass
(
git_config_open_ondisk
(
&
config
,
TEST_CONFIG
));
cl_git_pass
(
git_config_open_ondisk
(
&
config
,
TEST_CONFIG
));
cl_git_pass
(
git_config_set_string
(
config
,
"color.ui"
,
"auto"
));
cl_git_pass
(
git_config_set_string
(
config
,
"color.ui"
,
"auto"
));
...
...
tests-clar/config/read.c
View file @
0e9ea5d0
...
@@ -430,3 +430,23 @@ void test_config_read__simple_read_from_specific_level(void)
...
@@ -430,3 +430,23 @@ void test_config_read__simple_read_from_specific_level(void)
git_config_free
(
cfg_specific
);
git_config_free
(
cfg_specific
);
git_config_free
(
cfg
);
git_config_free
(
cfg
);
}
}
void
test_config_read__can_load_and_parse_an_empty_config_file
(
void
)
{
git_config
*
cfg
;
int
i
;
cl_git_mkfile
(
"./empty"
,
""
);
cl_git_pass
(
git_config_open_ondisk
(
&
cfg
,
"./empty"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_get_int32
(
&
i
,
cfg
,
"nope.neither"
));
git_config_free
(
cfg
);
}
void
test_config_read__cannot_load_a_non_existing_config_file
(
void
)
{
git_config
*
cfg
;
int
i
;
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_open_ondisk
(
&
cfg
,
"./no.config"
));
}
tests-clar/core/env.c
View file @
0e9ea5d0
...
@@ -84,13 +84,15 @@ void test_core_env__0(void)
...
@@ -84,13 +84,15 @@ void test_core_env__0(void)
cl_git_mkfile
(
path
.
ptr
,
"find me"
);
cl_git_mkfile
(
path
.
ptr
,
"find me"
);
git_buf_rtruncate_at_char
(
&
path
,
'/'
);
git_buf_rtruncate_at_char
(
&
path
,
'/'
);
cl_git_fail
(
git_futils_find_global_file
(
&
found
,
testfile
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
found
,
testfile
));
setenv_and_check
(
"HOME"
,
path
.
ptr
);
setenv_and_check
(
"HOME"
,
path
.
ptr
);
cl_git_pass
(
git_futils_find_global_file
(
&
found
,
testfile
));
cl_git_pass
(
git_futils_find_global_file
(
&
found
,
testfile
));
cl_setenv
(
"HOME"
,
env_save
[
0
]);
cl_setenv
(
"HOME"
,
env_save
[
0
]);
cl_git_fail
(
git_futils_find_global_file
(
&
found
,
testfile
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
found
,
testfile
));
#ifdef GIT_WIN32
#ifdef GIT_WIN32
setenv_and_check
(
"HOMEDRIVE"
,
NULL
);
setenv_and_check
(
"HOMEDRIVE"
,
NULL
);
...
@@ -106,7 +108,8 @@ void test_core_env__0(void)
...
@@ -106,7 +108,8 @@ void test_core_env__0(void)
if
(
root
>=
0
)
{
if
(
root
>=
0
)
{
setenv_and_check
(
"USERPROFILE"
,
NULL
);
setenv_and_check
(
"USERPROFILE"
,
NULL
);
cl_git_fail
(
git_futils_find_global_file
(
&
found
,
testfile
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
found
,
testfile
));
old
=
path
.
ptr
[
root
];
old
=
path
.
ptr
[
root
];
path
.
ptr
[
root
]
=
'\0'
;
path
.
ptr
[
root
]
=
'\0'
;
...
@@ -128,7 +131,8 @@ void test_core_env__1(void)
...
@@ -128,7 +131,8 @@ void test_core_env__1(void)
{
{
git_buf
path
=
GIT_BUF_INIT
;
git_buf
path
=
GIT_BUF_INIT
;
cl_must_fail
(
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_git_pass
(
cl_setenv
(
"HOME"
,
"doesnotexist"
));
cl_git_pass
(
cl_setenv
(
"HOME"
,
"doesnotexist"
));
#ifdef GIT_WIN32
#ifdef GIT_WIN32
...
@@ -136,7 +140,8 @@ void test_core_env__1(void)
...
@@ -136,7 +140,8 @@ void test_core_env__1(void)
cl_git_pass
(
cl_setenv
(
"USERPROFILE"
,
"doesnotexist"
));
cl_git_pass
(
cl_setenv
(
"USERPROFILE"
,
"doesnotexist"
));
#endif
#endif
cl_must_fail
(
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_git_pass
(
cl_setenv
(
"HOME"
,
NULL
));
cl_git_pass
(
cl_setenv
(
"HOME"
,
NULL
));
#ifdef GIT_WIN32
#ifdef GIT_WIN32
...
@@ -144,13 +149,16 @@ void test_core_env__1(void)
...
@@ -144,13 +149,16 @@ void test_core_env__1(void)
cl_git_pass
(
cl_setenv
(
"USERPROFILE"
,
NULL
));
cl_git_pass
(
cl_setenv
(
"USERPROFILE"
,
NULL
));
#endif
#endif
cl_must_fail
(
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_global_file
(
&
path
,
"nonexistentfile"
));
cl_must_fail
(
git_futils_find_system_file
(
&
path
,
"nonexistentfile"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_system_file
(
&
path
,
"nonexistentfile"
));
#ifdef GIT_WIN32
#ifdef GIT_WIN32
cl_git_pass
(
cl_setenv
(
"PROGRAMFILES"
,
NULL
));
cl_git_pass
(
cl_setenv
(
"PROGRAMFILES"
,
NULL
));
cl_must_fail
(
git_futils_find_system_file
(
&
path
,
"nonexistentfile"
));
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_futils_find_system_file
(
&
path
,
"nonexistentfile"
));
#endif
#endif
git_buf_free
(
&
path
);
git_buf_free
(
&
path
);
...
...
tests-clar/object/raw/short.c
View file @
0e9ea5d0
...
@@ -43,7 +43,7 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
...
@@ -43,7 +43,7 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
for
(
i
=
0
;
i
<
MAX_OIDS
;
++
i
)
{
for
(
i
=
0
;
i
<
MAX_OIDS
;
++
i
)
{
char
*
oid_text
;
char
*
oid_text
;
sprintf
(
number_buffer
,
"%u"
,
(
unsigned
int
)
i
);
p_snprintf
(
number_buffer
,
16
,
"%u"
,
(
unsigned
int
)
i
);
git_hash_buf
(
&
oid
,
number_buffer
,
strlen
(
number_buffer
));
git_hash_buf
(
&
oid
,
number_buffer
,
strlen
(
number_buffer
));
oid_text
=
git__malloc
(
GIT_OID_HEXSZ
+
1
);
oid_text
=
git__malloc
(
GIT_OID_HEXSZ
+
1
);
...
...
tests-clar/object/tag/read.c
View file @
0e9ea5d0
...
@@ -38,7 +38,7 @@ void test_object_tag_read__parse(void)
...
@@ -38,7 +38,7 @@ void test_object_tag_read__parse(void)
cl_git_pass
(
git_tag_lookup
(
&
tag1
,
g_repo
,
&
id1
));
cl_git_pass
(
git_tag_lookup
(
&
tag1
,
g_repo
,
&
id1
));
cl_assert_equal_s
(
git_tag_name
(
tag1
),
"test"
);
cl_assert_equal_s
(
git_tag_name
(
tag1
),
"test"
);
cl_assert
(
git_tag_type
(
tag1
)
==
GIT_OBJ_TAG
);
cl_assert
(
git_tag_t
arget_t
ype
(
tag1
)
==
GIT_OBJ_TAG
);
cl_git_pass
(
git_tag_target
((
git_object
**
)
&
tag2
,
tag1
));
cl_git_pass
(
git_tag_target
((
git_object
**
)
&
tag2
,
tag1
));
cl_assert
(
tag2
!=
NULL
);
cl_assert
(
tag2
!=
NULL
);
...
...
tests-clar/refs/reflog/drop.c
View file @
0e9ea5d0
...
@@ -49,14 +49,16 @@ void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
...
@@ -49,14 +49,16 @@ void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
cl_assert
(
entrycount
>
4
);
cl_assert
(
entrycount
>
4
);
before_current
=
git_reflog_entry_byindex
(
g_reflog
,
2
);
before_current
=
git_reflog_entry_byindex
(
g_reflog
,
1
);
git_oid_cpy
(
&
before_current_old_oid
,
&
before_current
->
oid_old
);
git_oid_cpy
(
&
before_current_old_oid
,
&
before_current
->
oid_old
);
git_oid_cpy
(
&
before_current_cur_oid
,
&
before_current
->
oid_cur
);
git_oid_cpy
(
&
before_current_cur_oid
,
&
before_current
->
oid_cur
);
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
2
,
1
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
1
,
1
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
after_current
=
git_reflog_entry_byindex
(
g_reflog
,
2
);
after_current
=
git_reflog_entry_byindex
(
g_reflog
,
0
);
cl_assert_equal_i
(
0
,
git_oid_cmp
(
&
before_current_old_oid
,
&
after_current
->
oid_old
));
cl_assert_equal_i
(
0
,
git_oid_cmp
(
&
before_current_old_oid
,
&
after_current
->
oid_old
));
cl_assert
(
0
!=
git_oid_cmp
(
&
before_current_cur_oid
,
&
after_current
->
oid_cur
));
cl_assert
(
0
!=
git_oid_cmp
(
&
before_current_cur_oid
,
&
after_current
->
oid_cur
));
...
@@ -68,10 +70,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
...
@@ -68,10 +70,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
cl_assert
(
entrycount
>
2
);
cl_assert
(
entrycount
>
2
);
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
0
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
entrycount
-
1
,
0
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
entry
=
git_reflog_entry_byindex
(
g_reflog
,
0
);
entry
=
git_reflog_entry_byindex
(
g_reflog
,
entrycount
-
2
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
!=
0
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
!=
0
);
}
}
...
@@ -81,10 +83,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
...
@@ -81,10 +83,10 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
cl_assert
(
entrycount
>
2
);
cl_assert
(
entrycount
>
2
);
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
1
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
entrycount
-
1
,
1
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
entry
=
git_reflog_entry_byindex
(
g_reflog
,
0
);
entry
=
git_reflog_entry_byindex
(
g_reflog
,
entrycount
-
2
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
==
0
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
==
0
);
}
}
...
@@ -93,8 +95,8 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void)
...
@@ -93,8 +95,8 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void)
cl_assert
(
--
entrycount
>
0
);
cl_assert
(
--
entrycount
>
0
);
do
{
do
{
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
--
entrycount
,
1
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
1
));
}
while
(
entrycount
>
0
);
}
while
(
--
entrycount
>
0
);
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
1
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
1
));
...
@@ -108,7 +110,7 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
...
@@ -108,7 +110,7 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
cl_assert
(
entrycount
>
2
);
cl_assert
(
entrycount
>
2
);
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
g_reflog
->
ref_name
));
cl_git_pass
(
git_reference_lookup
(
&
ref
,
g_repo
,
g_reflog
->
ref_name
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
entrycount
-
1
,
1
));
cl_git_pass
(
git_reflog_drop
(
g_reflog
,
0
,
1
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
cl_assert_equal_i
(
entrycount
-
1
,
git_reflog_entrycount
(
g_reflog
));
cl_git_pass
(
git_reflog_write
(
g_reflog
));
cl_git_pass
(
git_reflog_write
(
g_reflog
));
...
...
tests-clar/refs/reflog/reflog.c
View file @
0e9ea5d0
...
@@ -68,13 +68,13 @@ void test_refs_reflog_reflog__append_then_read(void)
...
@@ -68,13 +68,13 @@ void test_refs_reflog_reflog__append_then_read(void)
cl_git_pass
(
git_reflog_read
(
&
reflog
,
lookedup_ref
));
cl_git_pass
(
git_reflog_read
(
&
reflog
,
lookedup_ref
));
cl_assert_equal_i
(
2
,
git_reflog_entrycount
(
reflog
));
cl_assert_equal_i
(
2
,
git_reflog_entrycount
(
reflog
));
entry
=
git_reflog_entry_byindex
(
reflog
,
0
);
entry
=
git_reflog_entry_byindex
(
reflog
,
1
);
assert_signature
(
committer
,
entry
->
committer
);
assert_signature
(
committer
,
entry
->
committer
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
==
0
);
cl_assert
(
git_oid_streq
(
&
entry
->
oid_old
,
GIT_OID_HEX_ZERO
)
==
0
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_cur
)
==
0
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_cur
)
==
0
);
cl_assert
(
entry
->
msg
==
NULL
);
cl_assert
(
entry
->
msg
==
NULL
);
entry
=
git_reflog_entry_byindex
(
reflog
,
1
);
entry
=
git_reflog_entry_byindex
(
reflog
,
0
);
assert_signature
(
committer
,
entry
->
committer
);
assert_signature
(
committer
,
entry
->
committer
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_old
)
==
0
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_old
)
==
0
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_cur
)
==
0
);
cl_assert
(
git_oid_cmp
(
&
oid
,
&
entry
->
oid_cur
)
==
0
);
...
...
tests-clar/repo/getters.c
View file @
0e9ea5d0
#include "clar_libgit2.h"
#include "clar_libgit2.h"
void
test_repo_getters__i
nitialize
(
void
)
void
test_repo_getters__i
s_empty_correctly_deals_with_pristine_looking_repos
(
void
)
{
{
cl_fixture_sandbox
(
"testrepo.git"
);
git_repository
*
repo
;
}
void
test_repo_getters__cleanup
(
void
)
repo
=
cl_git_sandbox_init
(
"empty_bare.git"
);
{
cl_git_remove_placeholders
(
git_repository_path
(
repo
),
"dummy-marker.txt"
);
cl_fixture_cleanup
(
"testrepo.git"
);
cl_assert_equal_i
(
true
,
git_repository_is_empty
(
repo
));
cl_git_sandbox_cleanup
();
}
}
void
test_repo_getters__
empty
(
void
)
void
test_repo_getters__
is_empty_can_detect_used_repositories
(
void
)
{
{
git_repository
*
repo
_empty
,
*
repo_normal
;
git_repository
*
repo
;
cl_git_pass
(
git_repository_open
(
&
repo_normal
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_repository_open
(
&
repo
,
cl_fixture
(
"testrepo.git"
)));
cl_assert
(
git_repository_is_empty
(
repo_normal
)
==
0
);
git_repository_free
(
repo_normal
);
cl_
git_pass
(
git_repository_open
(
&
repo_empty
,
cl_fixture
(
"empty_bare.git"
)
));
cl_
assert_equal_i
(
false
,
git_repository_is_empty
(
repo
));
cl_assert
(
git_repository_is_empty
(
repo_empty
)
==
1
);
git_repository_free
(
repo
_empty
);
git_repository_free
(
repo
);
}
}
void
test_repo_getters__retrieving_the_odb_honors_the_refcount
(
void
)
void
test_repo_getters__retrieving_the_odb_honors_the_refcount
(
void
)
...
@@ -28,7 +28,7 @@ void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
...
@@ -28,7 +28,7 @@ void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
git_odb
*
odb
;
git_odb
*
odb
;
git_repository
*
repo
;
git_repository
*
repo
;
cl_git_pass
(
git_repository_open
(
&
repo
,
"testrepo.git"
));
cl_git_pass
(
git_repository_open
(
&
repo
,
cl_fixture
(
"testrepo.git"
)
));
cl_git_pass
(
git_repository_odb
(
&
odb
,
repo
));
cl_git_pass
(
git_repository_odb
(
&
odb
,
repo
));
cl_assert
(((
git_refcount
*
)
odb
)
->
refcount
==
2
);
cl_assert
(((
git_refcount
*
)
odb
)
->
refcount
==
2
);
...
...
tests-clar/stash/drop.c
View file @
0e9ea5d0
...
@@ -99,7 +99,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
...
@@ -99,7 +99,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
cl_git_pass
(
git_stash_drop
(
repo
,
1
));
cl_git_pass
(
git_stash_drop
(
repo
,
1
));
cl_git_pass
(
git_reflog_read
(
&
reflog
,
stash
));
cl_git_pass
(
git_reflog_read
(
&
reflog
,
stash
));
entry
=
git_reflog_entry_byindex
(
reflog
,
1
);
entry
=
git_reflog_entry_byindex
(
reflog
,
0
);
cl_assert_equal_i
(
0
,
git_oid_cmp
(
&
oid
,
git_reflog_entry_oidold
(
entry
)));
cl_assert_equal_i
(
0
,
git_oid_cmp
(
&
oid
,
git_reflog_entry_oidold
(
entry
)));
cl_assert_equal_i
(
count
-
1
,
git_reflog_entrycount
(
reflog
));
cl_assert_equal_i
(
count
-
1
,
git_reflog_entrycount
(
reflog
));
...
...
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