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
932d1baf
Commit
932d1baf
authored
Jun 30, 2011
by
Kirill A. Shutemov
Committed by
Vicent Marti
Jul 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
parent
1f4f4d17
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
139 additions
and
139 deletions
+139
-139
CMakeLists.txt
+2
-2
COPYING
+5
-5
README.md
+1
-1
examples/general.c
+12
-12
include/git2/odb.h
+4
-4
include/git2/oid.h
+1
-1
include/git2/refs.h
+4
-4
include/git2/repository.h
+4
-4
include/git2/tag.h
+1
-1
include/git2/tree.h
+1
-1
include/git2/types.h
+1
-1
src/filebuf.c
+1
-1
src/fileops.c
+2
-2
src/fileops.h
+10
-10
src/hashtable.c
+5
-5
src/hashtable.h
+1
-1
src/index.c
+1
-1
src/odb.c
+1
-1
src/odb_pack.c
+6
-6
src/oid.c
+1
-1
src/pqueue.c
+1
-1
src/pqueue.h
+1
-1
src/refs.c
+14
-14
src/repository.c
+5
-5
src/signature.c
+5
-5
src/tag.c
+14
-14
src/tree.c
+10
-10
src/util.c
+8
-8
src/util.h
+4
-4
src/vector.c
+1
-1
tests/t00-core.c
+1
-1
tests/t02-objread.c
+1
-1
tests/t04-commit.c
+1
-1
tests/t05-revwalk.c
+2
-2
tests/t06-index.c
+1
-1
tests/t10-refs.c
+5
-5
tests/test_lib.h
+1
-1
No files found.
CMakeLists.txt
View file @
932d1baf
...
...
@@ -4,7 +4,7 @@
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
#
# Testing:
# > ctest -V
#
...
...
@@ -90,7 +90,7 @@ SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
SET_TARGET_PROPERTIES
(
git2 PROPERTIES SOVERSION
${
LIBGIT2_VERSION_MAJOR
}
)
# Install
INSTALL
(
TARGETS git2
INSTALL
(
TARGETS git2
RUNTIME DESTINATION
${
INSTALL_BIN
}
LIBRARY DESTINATION
${
INSTALL_LIB
}
ARCHIVE DESTINATION
${
INSTALL_LIB
}
...
...
COPYING
View file @
932d1baf
...
...
@@ -71,7 +71,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
...
...
@@ -126,7 +126,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
...
...
@@ -184,7 +184,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
...
...
@@ -241,7 +241,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
...
...
@@ -294,7 +294,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
...
...
README.md
View file @
932d1baf
...
...
@@ -101,7 +101,7 @@ GitHub, or join us on the mailing list by sending an email to:
libgit2@librelist.com
License
License
==================================
libgit2 is under GPL2
**with linking exemption**
. This means you
can link to the library with any program, commercial, open source or
...
...
examples/general.c
View file @
932d1baf
// [**libgit2**][lg] is a portable, pure C implementation of the Git core methods
// provided as a re-entrant linkable library with a solid API, allowing you
// to write native speed custom Git applications in any language which
// supports C bindings.
// to write native speed custom Git applications in any language which
// supports C bindings.
//
// This file is an example of using that API in a real, compilable C file.
// As the API is updated, this file will be updated to demonstrate the
...
...
@@ -65,8 +65,8 @@ int main (int argc, char** argv)
// ### Working with the Object Database
// **libgit2** provides [direct access][odb] to the object database.
// The object database is where the actual objects are stored in Git. For
// working with raw objects, we'll need to get this structure from the
// The object database is where the actual objects are stored in Git. For
// working with raw objects, we'll need to get this structure from the
// repository.
// [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb
git_odb
*
odb
;
...
...
@@ -94,10 +94,10 @@ int main (int argc, char** argv)
data
=
(
const
unsigned
char
*
)
git_odb_object_data
(
obj
);
otype
=
git_odb_object_type
(
obj
);
// We provide methods to convert from the object type which is an enum, to a string
// We provide methods to convert from the object type which is an enum, to a string
// representation of that value (and vice-versa).
str_type
=
git_object_type2string
(
otype
);
printf
(
"object length and type: %d, %s
\n
"
,
printf
(
"object length and type: %d, %s
\n
"
,
(
int
)
git_odb_object_size
(
obj
),
str_type
);
...
...
@@ -126,7 +126,7 @@ int main (int argc, char** argv)
// yourself.
// #### Commit Parsing
// [Parsing commit objects][pco] is simple and gives you access to all the data in the commit
// [Parsing commit objects][pco] is simple and gives you access to all the data in the commit
// - the // author (name, email, datetime), committer (same), tree, message, encoding and parent(s).
// [pco]: http://libgit2.github.com/libgit2/#HEAD/group/commit
...
...
@@ -156,7 +156,7 @@ int main (int argc, char** argv)
printf
(
"Author: %s (%s)
\n
"
,
author
->
name
,
author
->
email
);
// Commits can have zero or more parents. The first (root) commit will have no parents, most commits
// will have one, which is the commit it was based on, and merge commits will have two or more.
// will have one, which is the commit it was based on, and merge commits will have two or more.
// Commits can technically have any number, though it's pretty rare to have more than two.
parents
=
git_commit_parentcount
(
commit
);
for
(
p
=
0
;
p
<
parents
;
p
++
)
{
...
...
@@ -191,7 +191,7 @@ int main (int argc, char** argv)
987654321
,
90
);
// Commit objects need a tree to point to and optionally one or more parents. Here we're creating oid
// objects to create the commit with, but you can also use
// objects to create the commit with, but you can also use
git_oid_fromstr
(
&
tree_id
,
"28873d96b4e8f4e33ea30f4c682fd325f7ba56ac"
);
git_oid_fromstr
(
&
parent_id
,
"f0877d0b841d75172ec404fc9370173dfffc20d1"
);
...
...
@@ -227,7 +227,7 @@ int main (int argc, char** argv)
error
=
git_tag_lookup
(
&
tag
,
repo
,
&
oid
);
// Now that we have the tag object, we can extract the information it generally contains: the target
// (usually a commit object), the type of the target object (usually 'commit'), the name ('v1.0'),
// (usually a commit object), the type of the target object (usually 'commit'), the name ('v1.0'),
// the tagger (a git_signature - name, email, timestamp), and the tag message.
git_tag_target
((
git_object
**
)
&
commit
,
tag
);
tname
=
git_tag_name
(
tag
);
// "test"
...
...
@@ -275,7 +275,7 @@ int main (int argc, char** argv)
//
// The last object type is the simplest and requires the least parsing help. Blobs are just file
// contents and can contain anything, there is no structure to it. The main advantage to using the
// [simple blob api][ba] is that when you're creating blobs you don't have to calculate the size
// [simple blob api][ba] is that when you're creating blobs you don't have to calculate the size
// of the content. There is also a helper for reading a file from disk and writing it to the db and
// getting the oid back so you don't have to do all those steps yourself.
//
...
...
@@ -343,7 +343,7 @@ int main (int argc, char** argv)
// ### Index File Manipulation
//
// The [index file API][gi] allows you to read, traverse, update and write the Git index file
// The [index file API][gi] allows you to read, traverse, update and write the Git index file
// (sometimes thought of as the staging area).
//
// [gi]: http://libgit2.github.com/libgit2/#HEAD/group/index
...
...
include/git2/odb.h
View file @
932d1baf
...
...
@@ -91,7 +91,7 @@ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int
* backend will work as an alternate.
*
* Alternate backends are always checked for objects *after*
* all the main backends have been exhausted.
* all the main backends have been exhausted.
*
* The backends are checked in relative ordering, based on the
* value of the `priority` parameter.
...
...
@@ -220,12 +220,12 @@ GIT_EXTERN(int) git_odb_write(git_oid *oid, git_odb *odb, const void *data, size
*
* The returned stream will be of type `GIT_STREAM_WRONLY` and
* will have the following methods:
*
*
* - stream->write: write `n` bytes into the stream
* - stream->finalize_write: close the stream and store the object in
* the odb
* - stream->free: free the stream
*
*
* The streaming write won't be effective until `stream->finalize_write`
* is called and returns without an error
*
...
...
@@ -252,7 +252,7 @@ GIT_EXTERN(int) git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_
*
* The returned stream will be of type `GIT_STREAM_RDONLY` and
* will have the following methods:
*
*
* - stream->read: read `n` bytes from the stream
* - stream->free: free the stream
*
...
...
include/git2/oid.h
View file @
932d1baf
...
...
@@ -215,7 +215,7 @@ int git_oid_shorten_add(git_oid_shorten *os, const char *text_oid);
/**
* Free an OID shortener instance
*
*
* @param os a `git_oid_shorten` instance
*/
void
git_oid_shorten_free
(
git_oid_shorten
*
os
);
...
...
include/git2/refs.h
View file @
932d1baf
...
...
@@ -95,7 +95,7 @@ GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository
/**
* Get the OID pointed to by a reference.
*
*
* Only available if the reference is direct (i.e. not symbolic)
*
* @param ref The reference
...
...
@@ -105,7 +105,7 @@ GIT_EXTERN(const git_oid *) git_reference_oid(git_reference *ref);
/**
* Get full name to the reference pointed by this reference
*
*
* Only available if the reference is symbolic
*
* @param ref The reference
...
...
@@ -132,7 +132,7 @@ GIT_EXTERN(git_rtype) git_reference_type(git_reference *ref);
GIT_EXTERN
(
const
char
*
)
git_reference_name
(
git_reference
*
ref
);
/**
* Resolve a symbolic reference
* Resolve a symbolic reference
*
* Thie method iteratively peels a symbolic reference
* until it resolves to a direct reference to an OID.
...
...
@@ -212,7 +212,7 @@ GIT_EXTERN(int) git_reference_delete(git_reference *ref);
* Pack all the loose references in the repository
*
* This method will load into the cache all the loose
* references on the repository and update the
* references on the repository and update the
* `packed-refs` file with them.
*
* Once the `packed-refs` file has been written properly,
...
...
include/git2/repository.h
View file @
932d1baf
...
...
@@ -71,7 +71,7 @@ GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *pat
*
* @param git_dir The full path to the repository folder
* e.g. a '.git' folder for live repos, any folder for bare
* Equivalent to $GIT_DIR.
* Equivalent to $GIT_DIR.
* Cannot be NULL.
*
* @param git_object_directory The full path to the ODB folder.
...
...
@@ -105,7 +105,7 @@ GIT_EXTERN(int) git_repository_open2(git_repository **repository,
*
* @param git_dir The full path to the repository folder
* e.g. a '.git' folder for live repos, any folder for bare
* Equivalent to $GIT_DIR.
* Equivalent to $GIT_DIR.
* Cannot be NULL.
*
* @param object_database A pointer to a git_odb created & initialized
...
...
@@ -210,8 +210,8 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo);
*
* @param repo_out pointer to the repo which will be created or reinitialized
* @param path the path to the repository
* @param is_bare if true, a Git repository without a working directory is created
* at the pointed path. If false, provided path will be considered as the working
* @param is_bare if true, a Git repository without a working directory is created
* at the pointed path. If false, provided path will be considered as the working
* directory into which the .git directory will be created.
*
* @return 0 on success; error code otherwise
...
...
include/git2/tag.h
View file @
932d1baf
...
...
@@ -163,7 +163,7 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* @param repo Repository where to store the tag
*
* @param tag_name Name for the tag; this name is validated
* for consistency. It should also not conflict with an
* for consistency. It should also not conflict with an
* already existing tag name
*
* @param target Object to which this tag points. This object
...
...
include/git2/tree.h
View file @
932d1baf
...
...
@@ -190,7 +190,7 @@ GIT_EXTERN(int) git_tree_create_fromindex(git_oid *oid, git_index *index);
*
* If the `source` parameter is not NULL, the tree builder
* will be initialized with the entries of the given tree.
*
*
* If the `source` parameter is NULL, the tree builder will
* have no entries and will have to be filled manually.
*
...
...
include/git2/types.h
View file @
932d1baf
...
...
@@ -66,7 +66,7 @@ typedef __haiku_std_int64 git_time_t;
#else
/* POSIX */
/*
/*
* Note: Can't use off_t since if a client program includes <sys/types.h>
* before us (directly or indirectly), they'll get 32 bit off_t in their client
* app, even though /we/ define _FILE_OFFSET_BITS=64.
...
...
src/filebuf.c
View file @
932d1baf
...
...
@@ -200,7 +200,7 @@ int git_filebuf_open(git_filebuf *file, const char *path, int flags)
char
tmp_path
[
GIT_PATH_MAX
];
/* Open the file as temporary for locking */
file
->
fd
=
gitfo_mktemp
(
tmp_path
,
path
);
file
->
fd
=
gitfo_mktemp
(
tmp_path
,
path
);
if
(
file
->
fd
<
0
)
{
error
=
GIT_EOSERR
;
goto
cleanup
;
...
...
src/fileops.c
View file @
932d1baf
...
...
@@ -475,7 +475,7 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path, con
current
++
;
continue
;
}
only_dots
=
1
;
segment_len
=
0
;
...
...
@@ -753,7 +753,7 @@ int gitfo_hide_directory__w32(const char *path)
error
=
SetFileAttributes
(
path
,
FILE_ATTRIBUTE_HIDDEN
)
!=
0
?
GIT_SUCCESS
:
GIT_ERROR
;
/* MSDN states a "non zero" value indicates a success */
if
(
error
<
GIT_SUCCESS
)
if
(
error
<
GIT_SUCCESS
)
error
=
git__throw
(
GIT_EOSERR
,
"Failed to hide directory '%s'"
,
path
);
return
error
;
...
...
src/fileops.h
View file @
932d1baf
...
...
@@ -165,10 +165,10 @@ extern int gitfo_getcwd(char *buffer_out, size_t size);
/**
* Clean up a provided absolute or relative directory path.
*
* This prettification relies on basic operations such as coalescing
* multiple forward slashes into a single slash, removing '.' and
* './' current directory segments, and removing parent directory
*
* This prettification relies on basic operations such as coalescing
* multiple forward slashes into a single slash, removing '.' and
* './' current directory segments, and removing parent directory
* whenever '..' is encountered.
*
* If not empty, the returned path ends with a forward slash.
...
...
@@ -176,7 +176,7 @@ extern int gitfo_getcwd(char *buffer_out, size_t size);
* For instance, this will turn "d1/s1///s2/..//../s3" into "d1/s3/".
*
* This only performs a string based analysis of the path.
* No checks are done to make sure the path actually makes sense from
* No checks are done to make sure the path actually makes sense from
* the file system perspective.
*
* @param buffer_out buffer to populate with the normalized path.
...
...
@@ -190,16 +190,16 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path, con
/**
* Clean up a provided absolute or relative file path.
*
* This prettification relies on basic operations such as coalescing
* multiple forward slashes into a single slash, removing '.' and
* './' current directory segments, and removing parent directory
*
* This prettification relies on basic operations such as coalescing
* multiple forward slashes into a single slash, removing '.' and
* './' current directory segments, and removing parent directory
* whenever '..' is encountered.
*
* For instance, this will turn "d1/s1///s2/..//../s3" into "d1/s3".
*
* This only performs a string based analysis of the path.
* No checks are done to make sure the path actually makes sense from
* No checks are done to make sure the path actually makes sense from
* the file system perspective.
*
* @param buffer_out buffer to populate with the normalized path.
...
...
src/hashtable.c
View file @
932d1baf
...
...
@@ -94,22 +94,22 @@ static void node_swap_with(git_hashtable_node *self, git_hashtable_node *other)
}
static
int
node_insert
(
git_hashtable
*
self
,
git_hashtable_node
*
new_node
)
{
{
int
iteration
,
hash_id
;
for
(
iteration
=
0
;
iteration
<
MAX_LOOPS
;
iteration
++
)
{
for
(
iteration
=
0
;
iteration
<
MAX_LOOPS
;
iteration
++
)
{
for
(
hash_id
=
0
;
hash_id
<
GIT_HASHTABLE_HASHES
;
++
hash_id
)
{
git_hashtable_node
*
node
;
node
=
node_with_hash
(
self
,
new_node
->
key
,
hash_id
);
node_swap_with
(
new_node
,
node
);
if
(
new_node
->
key
==
0x0
){
self
->
key_count
++
;
return
GIT_SUCCESS
;
return
GIT_SUCCESS
;
}
}
}
if
(
self
->
is_resizing
)
if
(
self
->
is_resizing
)
return
git__throw
(
GIT_EBUSY
,
"Failed to insert node. Hashtable is currently resizing"
);
resize_to
(
self
,
self
->
size
*
2
);
...
...
@@ -130,7 +130,7 @@ static int insert_nodes(git_hashtable *self, git_hashtable_node *old_nodes, size
return
GIT_SUCCESS
;
}
git_hashtable
*
git_hashtable_alloc
(
size_t
min_size
,
git_hashtable
*
git_hashtable_alloc
(
size_t
min_size
,
git_hash_ptr
hash
,
git_hash_keyeq_ptr
key_eq
)
{
...
...
src/hashtable.h
View file @
932d1baf
...
...
@@ -31,7 +31,7 @@ struct git_hashtable {
typedef
struct
git_hashtable_node
git_hashtable_node
;
typedef
struct
git_hashtable
git_hashtable
;
git_hashtable
*
git_hashtable_alloc
(
size_t
min_size
,
git_hashtable
*
git_hashtable_alloc
(
size_t
min_size
,
git_hash_ptr
hash
,
git_hash_keyeq_ptr
key_eq
);
void
*
git_hashtable_lookup
(
git_hashtable
*
h
,
const
void
*
key
);
...
...
src/index.c
View file @
932d1baf
...
...
@@ -549,7 +549,7 @@ static int read_tree_internal(git_index_tree **out,
if
(
count
==
-
1
)
{
/* FIXME: return buffer_end or the end position for
* this single tree entry */
*
buffer_in
=
buffer_end
;
*
buffer_in
=
buffer_end
;
*
out
=
NULL
;
free_tree
(
tree
);
/* Needs to be done manually */
return
GIT_SUCCESS
;
...
...
src/odb.c
View file @
932d1baf
...
...
@@ -620,7 +620,7 @@ int git_odb_open_wstream(git_odb_stream **stream, git_odb *db, size_t size, git_
return
git__rethrow
(
error
,
"Failed to open write stream"
);
}
int
git_odb_open_rstream
(
git_odb_stream
**
stream
,
git_odb
*
db
,
const
git_oid
*
oid
)
int
git_odb_open_rstream
(
git_odb_stream
**
stream
,
git_odb
*
db
,
const
git_oid
*
oid
)
{
unsigned
int
i
;
int
error
=
GIT_ERROR
;
...
...
src/odb_pack.c
View file @
932d1baf
...
...
@@ -227,7 +227,7 @@ struct pack_backend {
/***********************************************************
*
* FORWARD DECLARATIONS
...
...
@@ -306,7 +306,7 @@ static off_t get_delta_base(struct pack_backend *backend,
static
unsigned
long
packfile_unpack_header1
(
size_t
*
sizep
,
git_otype
*
type
,
git_otype
*
type
,
const
unsigned
char
*
buf
,
unsigned
long
len
);
...
...
@@ -807,7 +807,7 @@ static int packfile_open(struct pack_file *p)
if
(
git_oid_cmp
(
&
sha1
,
(
git_oid
*
)
idx_sha1
)
!=
0
)
goto
cleanup
;
return
GIT_SUCCESS
;
return
GIT_SUCCESS
;
cleanup
:
gitfo_close
(
p
->
pack_fd
);
...
...
@@ -1068,7 +1068,7 @@ static int pack_entry_find1(
return
git__rethrow
(
error
,
"Failed to find pack entry. Couldn't find offset"
);
/* we found a unique entry in the index;
* make sure the packfile backing the index
* make sure the packfile backing the index
* still exists on disk */
if
(
p
->
pack_fd
==
-
1
&&
packfile_open
(
p
)
<
GIT_SUCCESS
)
return
git__throw
(
GIT_EOSERR
,
"Failed to find pack entry. Packfile doesn't exist on disk"
);
...
...
@@ -1177,7 +1177,7 @@ static int pack_entry_find_prefix(
static
unsigned
long
packfile_unpack_header1
(
size_t
*
sizep
,
git_otype
*
type
,
git_otype
*
type
,
const
unsigned
char
*
buf
,
unsigned
long
len
)
{
...
...
@@ -1385,7 +1385,7 @@ static int packfile_unpack(
size_t
size
=
0
;
git_otype
type
;
/*
/*
* TODO: optionally check the CRC on the packfile
*/
...
...
src/oid.c
View file @
932d1baf
...
...
@@ -305,7 +305,7 @@ void git_oid_shorten_free(git_oid_shorten *os)
*
* - Each normal node points to 16 children (one for each possible
* character in the oid). This is *not* stored in an array of
* pointers, because in a 64-bit arch this would be sucking
* pointers, because in a 64-bit arch this would be sucking
* 16*sizeof(void*) = 128 bytes of memory per node, which is fucking
* insane. What we do is store Node Indexes, and use these indexes
* to look up each node in the om->index array. These indexes are
...
...
src/pqueue.c
View file @
932d1baf
...
...
@@ -11,7 +11,7 @@
* Copyright 2010 Volkan Yazıcı <volkan.yazici@gmail.com>
* Copyright 2006-2010 The Apache Software Foundation
*
* This file is licensed under the Apache 2.0 license, which
* This file is licensed under the Apache 2.0 license, which
* supposedly makes it compatible with the GPLv2 that libgit2 uses.
*
* Check the Apache license at:
...
...
src/pqueue.h
View file @
932d1baf
...
...
@@ -11,7 +11,7 @@
* Copyright 2010 Volkan Yazıcı <volkan.yazici@gmail.com>
* Copyright 2006-2010 The Apache Software Foundation
*
* This file is licensed under the Apache 2.0 license, which
* This file is licensed under the Apache 2.0 license, which
* supposedly makes it compatible with the GPLv2 that libgit2 uses.
*
* Check the Apache license at:
...
...
src/refs.c
View file @
932d1baf
...
...
@@ -51,7 +51,7 @@ static uint32_t reftable_hash(const void *key, int hash_id)
static
uint32_t
hash_seeds
[
GIT_HASHTABLE_HASHES
]
=
{
2147483647
,
0x5d20bb23
,
0x7daaab3c
0x7daaab3c
};
return
git__hash
(
key
,
strlen
((
const
char
*
)
key
),
hash_seeds
[
hash_id
]);
...
...
@@ -230,9 +230,9 @@ static int loose_parse_symbolic(git_reference *ref, gitfo_buf *file_content)
return
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse loose reference. Object too short"
);
/*
/*
* Assume we have already checked for the header
* before calling this function
* before calling this function
*/
refname_start
+=
header_len
;
...
...
@@ -303,8 +303,8 @@ static git_rtype loose_guess_rtype(const char *full_path)
}
static
int
loose_lookup
(
git_reference
**
ref_out
,
git_repository
*
repo
,
git_reference
**
ref_out
,
git_repository
*
repo
,
const
char
*
name
,
int
skip_symbolic
)
{
...
...
@@ -405,7 +405,7 @@ unlock:
static
int
packed_parse_peel
(
reference_oid
*
tag_ref
,
const
char
**
buffer_out
,
const
char
**
buffer_out
,
const
char
*
buffer_end
)
{
const
char
*
buffer
=
*
buffer_out
+
1
;
...
...
@@ -525,7 +525,7 @@ static int packed_load(git_repository *repo)
git_hashtable_clear
(
repo
->
references
.
packfile
);
}
else
{
ref_cache
->
packfile
=
git_hashtable_alloc
(
default_table_size
,
default_table_size
,
reftable_hash
,
(
git_hash_keyeq_ptr
)
strcmp
);
...
...
@@ -680,7 +680,7 @@ static int packed_loadloose(git_repository *repository)
/*
* Load all the loose files from disk into the Packfile table.
* This will overwrite any old packed entries with their
* updated loose versions
* updated loose versions
*/
return
gitfo_dirent
(
refs_path
,
GIT_PATH_MAX
,
_dirent_loose_load
,
repository
);
}
...
...
@@ -696,7 +696,7 @@ static int packed_write_ref(reference_oid *ref, git_filebuf *file)
git_oid_fmt
(
oid
,
&
ref
->
oid
);
oid
[
GIT_OID_HEXSZ
]
=
0
;
/*
/*
* For references that peel to an object in the repo, we must
* write the resulting peel on a separate line, e.g.
*
...
...
@@ -722,7 +722,7 @@ static int packed_write_ref(reference_oid *ref, git_filebuf *file)
/*
* Find out what object this reference resolves to.
*
* For references that point to a 'big' tag (e.g. an
* For references that point to a 'big' tag (e.g. an
* actual tag object on the repository), we need to
* cache on the packfile the OID of the object to
* which that 'big tag' is pointing to.
...
...
@@ -998,7 +998,7 @@ int git_reference_lookup(git_reference **ref_out, git_repository *repo, const ch
/*
* If we cannot find a loose reference, we look into the packfile
* Load the packfile first if it hasn't been loaded
* Load the packfile first if it hasn't been loaded
*/
/* load all the packed references */
error
=
packed_load
(
repo
);
...
...
@@ -1234,7 +1234,7 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
git_oid_cpy
(
&
ref_oid
->
oid
,
id
);
ref
->
type
&=
~
GIT_REF_HAS_PEEL
;
error
=
loose_write
(
ref
);
error
=
loose_write
(
ref
);
if
(
error
<
GIT_SUCCESS
)
goto
cleanup
;
...
...
@@ -1445,7 +1445,7 @@ int git_reference_delete(git_reference *ref)
/* load the existing packfile */
if
((
error
=
packed_load
(
ref
->
owner
))
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to delete reference"
);
if
(
git_hashtable_remove
(
ref
->
owner
->
references
.
packfile
,
ref
->
name
)
<
GIT_SUCCESS
)
return
git__throw
(
GIT_ENOTFOUND
,
"Reference not found"
);
...
...
@@ -1482,7 +1482,7 @@ int git_reference_resolve(git_reference **resolved_ref, git_reference *ref)
if
((
error
=
loose_update
(
ref
))
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to resolve reference"
);
repo
=
ref
->
owner
;
for
(
i
=
0
;
i
<
MAX_NESTING_LEVEL
;
++
i
)
{
...
...
src/repository.c
View file @
932d1baf
...
...
@@ -118,7 +118,7 @@ static int assign_repository_dirs(
if
(
repo
->
path_index
==
NULL
)
return
GIT_ENOMEM
;
}
return
GIT_SUCCESS
;
}
...
...
@@ -207,8 +207,8 @@ int git_repository_open3(git_repository **repo_out,
if
(
repo
==
NULL
)
return
GIT_ENOMEM
;
error
=
assign_repository_dirs
(
repo
,
git_dir
,
error
=
assign_repository_dirs
(
repo
,
git_dir
,
NULL
,
git_index_file
,
git_work_tree
);
...
...
@@ -247,7 +247,7 @@ int git_repository_open2(git_repository **repo_out,
return
GIT_ENOMEM
;
error
=
assign_repository_dirs
(
repo
,
git_dir
,
git_dir
,
git_object_directory
,
git_index_file
,
git_work_tree
);
...
...
@@ -711,7 +711,7 @@ int git_repository_init(git_repository **repo_out, const char *path, unsigned is
int
error
=
GIT_SUCCESS
;
git_repository
*
repo
=
NULL
;
repo_init
results
;
assert
(
repo_out
&&
path
);
results
.
path_repository
=
NULL
;
...
...
src/signature.c
View file @
932d1baf
...
...
@@ -107,7 +107,7 @@ static int parse_timezone_offset(const char *buffer, long *offset_out)
const
char
*
offset_start
;
const
char
*
offset_end
;
//we are sure that *buffer == ' '
//we are sure that *buffer == ' '
offset_start
=
buffer
+
1
;
if
(
*
offset_start
==
'\n'
)
{
...
...
@@ -133,7 +133,7 @@ static int parse_timezone_offset(const char *buffer, long *offset_out)
hours
=
dec_offset
/
100
;
mins
=
dec_offset
%
100
;
if
(
hours
>
14
)
// see http://www.worldtimezone.com/faq.html
if
(
hours
>
14
)
// see http://www.worldtimezone.com/faq.html
return
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse TZ offset. Hour value too large"
);
if
(
mins
>
59
)
...
...
@@ -143,7 +143,7 @@ static int parse_timezone_offset(const char *buffer, long *offset_out)
if
(
offset_start
[
0
]
==
'-'
)
offset
*=
-
1
;
*
offset_out
=
offset
;
return
GIT_SUCCESS
;
...
...
@@ -218,7 +218,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
if
(
parse_timezone_offset
(
buffer
,
&
offset
)
<
GIT_SUCCESS
)
return
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse signature. Could not parse timezone offset"
);
sig
->
when
.
offset
=
offset
;
*
buffer_out
=
(
line_end
+
1
);
...
...
@@ -234,7 +234,7 @@ int git_signature__write(char **signature, const char *header, const git_signatu
offset
=
sig
->
when
.
offset
;
sign
=
(
sig
->
when
.
offset
<
0
)
?
'-'
:
'+'
;
if
(
offset
<
0
)
offset
=
-
offset
;
...
...
src/tag.c
View file @
932d1baf
...
...
@@ -205,7 +205,7 @@ int git_tag_create(
return
git__throw
(
GIT_EINVALIDARGS
,
"The given target does not belong to this repository"
);
error
=
retreive_tag_reference
(
&
new_ref
,
ref_name
,
repo
,
tag_name
);
switch
(
error
)
{
case
GIT_SUCCESS
:
case
GIT_ENOTFOUND
:
...
...
@@ -215,7 +215,7 @@ int git_tag_create(
return
git__rethrow
(
error
,
"Failed to create tag"
);
}
/** Ensure the tag name doesn't conflict with an already existing
/** Ensure the tag name doesn't conflict with an already existing
* reference unless overwriting has explictly been requested **/
if
(
new_ref
!=
NULL
)
{
if
(
!
allow_ref_overwrite
)
{
...
...
@@ -268,7 +268,7 @@ int git_tag_create(
error
=
git_reference_create_oid
(
&
new_ref
,
repo
,
ref_name
,
oid
,
0
);
else
error
=
git_reference_set_oid
(
new_ref
,
oid
);
return
error
==
GIT_SUCCESS
?
GIT_SUCCESS
:
git__rethrow
(
error
,
"Failed to create tag"
);
}
...
...
@@ -278,14 +278,14 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
int
error
,
should_update_ref
=
0
;
git_odb_stream
*
stream
;
git_odb_object
*
target_obj
;
git_reference
*
new_ref
;
char
ref_name
[
GIT_REFNAME_MAX
];
assert
(
oid
&&
buffer
);
memset
(
&
tag
,
0
,
sizeof
(
tag
));
/* validate the buffer */
if
((
error
=
parse_tag_buffer
(
&
tag
,
buffer
,
buffer
+
strlen
(
buffer
)))
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to create tag"
);
...
...
@@ -298,7 +298,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
return
git__throw
(
error
,
"The type for the given target is invalid"
);
git_odb_object_close
(
target_obj
);
error
=
retreive_tag_reference
(
&
new_ref
,
ref_name
,
repo
,
tag
.
tag_name
);
switch
(
error
)
{
...
...
@@ -320,16 +320,16 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
should_update_ref
=
1
;
}
}
/* write the buffer */
if
((
error
=
git_odb_open_wstream
(
&
stream
,
repo
->
db
,
strlen
(
buffer
),
GIT_OBJ_TAG
))
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to create tag"
);
stream
->
write
(
stream
,
buffer
,
strlen
(
buffer
));
error
=
stream
->
finalize_write
(
oid
,
stream
);
stream
->
free
(
stream
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to create tag"
);
...
...
@@ -337,11 +337,11 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
error
=
git_reference_create_oid
(
&
new_ref
,
repo
,
ref_name
,
oid
,
0
);
else
error
=
git_reference_set_oid
(
new_ref
,
oid
);
git_signature_free
(
tag
.
tagger
);
free
(
tag
.
tag_name
);
free
(
tag
.
message
);
return
error
==
GIT_SUCCESS
?
GIT_SUCCESS
:
git__rethrow
(
error
,
"Failed to create tag"
);
}
...
...
src/tree.c
View file @
932d1baf
...
...
@@ -34,7 +34,7 @@
#define MAX_FILEMODE_BYTES 6
static
int
valid_attributes
(
const
int
attributes
)
{
return
attributes
>=
0
&&
attributes
<=
MAX_FILEMODE
;
return
attributes
>=
0
&&
attributes
<=
MAX_FILEMODE
;
}
int
entry_search_cmp
(
const
void
*
key
,
const
void
*
array_member
)
...
...
@@ -47,7 +47,7 @@ int entry_search_cmp(const void *key, const void *array_member)
#if 0
static int valid_attributes(const int attributes) {
return attributes >= 0 && attributes <= MAX_FILEMODE;
return attributes >= 0 && attributes <= MAX_FILEMODE;
}
#endif
...
...
@@ -215,9 +215,9 @@ static int write_index(git_oid *oid, git_index *index, const char *base, int bas
buffer
=
git__malloc
(
size
);
if
(
buffer
==
NULL
)
return
GIT_ENOMEM
;
offset
=
0
;
for
(
nr
=
entry_no
;
nr
<
maxentries
;
++
nr
)
{
git_index_entry
*
entry
=
git_index_get
(
index
,
nr
);
...
...
@@ -227,11 +227,11 @@ static int write_index(git_oid *oid, git_index *index, const char *base, int bas
unsigned
int
write_mode
;
git_oid
subtree_oid
;
git_oid
*
write_oid
;
/* Did we hit the end of the directory? Return how many we wrote */
if
(
baselen
>=
pathlen
||
memcmp
(
base
,
pathname
,
baselen
)
!=
0
)
break
;
/* Do we have _further_ subdirectories? */
filename
=
pathname
+
baselen
;
dirname
=
strchr
(
filename
,
'/'
);
...
...
@@ -254,9 +254,9 @@ static int write_index(git_oid *oid, git_index *index, const char *base, int bas
free
(
buffer
);
return
subdir_written
;
}
nr
=
subdir_written
-
1
;
/* Now we need to write out the directory entry into this tree.. */
pathlen
=
dirname
-
pathname
;
write_oid
=
&
subtree_oid
;
...
...
@@ -267,14 +267,14 @@ static int write_index(git_oid *oid, git_index *index, const char *base, int bas
if
(
offset
+
entrylen
+
32
>
size
)
{
size
=
alloc_nr
(
offset
+
entrylen
+
32
);
buffer
=
git__realloc
(
buffer
,
size
);
if
(
buffer
==
NULL
)
return
GIT_ENOMEM
;
}
offset
+=
write_index_entry
(
buffer
+
offset
,
write_mode
,
filename
,
entrylen
,
write_oid
);
}
error
=
git_odb_write
(
oid
,
index
->
repository
->
db
,
buffer
,
offset
,
GIT_OBJ_TREE
);
free
(
buffer
);
...
...
src/util.c
View file @
932d1baf
...
...
@@ -427,17 +427,17 @@ uint32_t git__hash(const void *key, int len, unsigned int seed)
while
(
len
>=
4
)
{
uint32_t
k
=
*
(
uint32_t
*
)
data
;
k
*=
m
;
k
^=
k
>>
r
;
k
*=
m
;
h
*=
m
;
k
*=
m
;
k
^=
k
>>
r
;
k
*=
m
;
h
*=
m
;
h
^=
k
;
data
+=
4
;
len
-=
4
;
}
switch
(
len
)
{
case
3
:
h
^=
data
[
2
]
<<
16
;
case
2
:
h
^=
data
[
1
]
<<
8
;
...
...
@@ -450,7 +450,7 @@ uint32_t git__hash(const void *key, int len, unsigned int seed)
h
^=
h
>>
15
;
return
h
;
}
}
#else
/*
Cross-platform version of Murmurhash3
...
...
@@ -508,5 +508,5 @@ uint32_t git__hash(const void *key, int len, uint32_t seed)
h1
^=
h1
>>
16
;
return
h1
;
}
}
#endif
src/util.h
View file @
932d1baf
...
...
@@ -5,7 +5,7 @@
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
/*
/*
* Custom memory allocation wrappers
* that set error code and error message
* on allocation failure
...
...
@@ -78,7 +78,7 @@ extern int git__strtol32(long *n, const char *buff, const char **end_buf, int ba
* the string ".". If path is a null pointer or points to an empty string,
* dirname() shall return a pointer to the string "." .
*
* The `git__dirname` implementation is thread safe. The returned
* The `git__dirname` implementation is thread safe. The returned
* string must be manually free'd.
*
* The `git__dirname_r` implementation expects a string allocated
...
...
@@ -96,7 +96,7 @@ extern int git__dirname_r(char *buffer, size_t bufflen, const char *path);
* Trailing slashes and backslashes are significant: the basename of
* c:/foo/bar/ is an empty string after the rightmost slash.
*
* The `git__basename` implementation is thread safe. The returned
* The `git__basename` implementation is thread safe. The returned
* string must be manually free'd.
*
* The `git__basename_r` implementation expects a string allocated
...
...
@@ -112,7 +112,7 @@ extern const char *git__topdir(const char *path);
* middle slashes and everything
*
* The paths are joined together into buffer_out; this is expected
* to be an user allocated buffer of `GIT_PATH_MAX` size
* to be an user allocated buffer of `GIT_PATH_MAX` size
*/
extern
void
git__joinpath_n
(
char
*
buffer_out
,
int
npath
,
...);
...
...
src/vector.c
View file @
932d1baf
...
...
@@ -61,7 +61,7 @@ int git_vector_init(git_vector *v, unsigned int initial_size, git_vector_cmp cmp
v
->
_alloc_size
=
initial_size
;
v
->
_cmp
=
cmp
;
v
->
length
=
0
;
v
->
sorted
=
1
;
...
...
tests/t00-core.c
View file @
932d1baf
...
...
@@ -241,7 +241,7 @@ BEGIN_TEST(path3, "prettify and validate a path to a file")
must_fail
(
ensure_file_path_normalized
(
"d1/..."
,
NULL
,
0
));
must_fail
(
ensure_file_path_normalized
(
"d1/.../"
,
NULL
,
0
));
must_fail
(
ensure_file_path_normalized
(
"d1/.../d2"
,
NULL
,
0
));
must_pass
(
ensure_file_path_normalized
(
"/a"
,
"/a"
,
ROOTED_PATH
));
must_pass
(
ensure_file_path_normalized
(
"/./testrepo.git"
,
"/testrepo.git"
,
ROOTED_PATH
));
must_pass
(
ensure_file_path_normalized
(
"/./.git"
,
"/.git"
,
ROOTED_PATH
));
...
...
tests/t02-objread.c
View file @
932d1baf
...
...
@@ -210,7 +210,7 @@ BEGIN_TEST(readheader0, "read only the header of several packed objects")
git_odb_object_close
(
obj
);
}
git_odb_close
(
db
);
git_odb_close
(
db
);
END_TEST
BEGIN_TEST
(
readheader1
,
"read only the header of several loose objects"
)
...
...
tests/t04-commit.c
View file @
932d1baf
...
...
@@ -359,7 +359,7 @@ BEGIN_TEST(details0, "query the details on a parsed commit")
git_repository
*
repo
;
must_pass
(
git_repository_open
(
&
repo
,
REPOSITORY_FOLDER
));
for
(
i
=
0
;
i
<
commit_count
;
++
i
)
{
git_oid
id
;
git_commit
*
commit
;
...
...
tests/t05-revwalk.c
View file @
932d1baf
...
...
@@ -74,7 +74,7 @@ static int get_commit_index(git_oid *raw_oid)
char
oid
[
40
];
git_oid_fmt
(
oid
,
raw_oid
);
for
(
i
=
0
;
i
<
commit_count
;
++
i
)
if
(
memcmp
(
oid
,
commit_ids
[
i
],
40
)
==
0
)
return
i
;
...
...
@@ -108,7 +108,7 @@ static int test_walk(git_revwalk *walk, const git_oid *root,
}*/
}
for
(
i
=
0
;
i
<
results_count
;
++
i
)
for
(
i
=
0
;
i
<
results_count
;
++
i
)
if
(
memcmp
(
possible_results
[
i
],
result_array
,
result_bytes
)
==
0
)
return
GIT_SUCCESS
;
...
...
tests/t06-index.c
View file @
932d1baf
...
...
@@ -145,7 +145,7 @@ BEGIN_TEST(write0, "write an index back to disk")
must_pass
(
cmp_files
(
TEST_INDEXBIG_PATH
,
"index_rewrite"
));
git_index_free
(
index
);
gitfo_unlink
(
"index_rewrite"
);
END_TEST
...
...
tests/t10-refs.c
View file @
932d1baf
...
...
@@ -431,7 +431,7 @@ BEGIN_TEST(pack0, "create a packfile for an empty folder")
const
int
mode
=
0755
;
/* or 0777 ? */
must_pass
(
open_temp_repo
(
&
repo
,
REPOSITORY_FOLDER
));
git__joinpath_n
(
temp_path
,
3
,
repo
->
path_repository
,
GIT_REFS_HEADS_DIR
,
"empty_dir"
);
must_pass
(
gitfo_mkdir_recurs
(
temp_path
,
mode
));
...
...
@@ -446,12 +446,12 @@ BEGIN_TEST(pack1, "create a packfile from all the loose rn a repo")
char
temp_path
[
GIT_PATH_MAX
];
must_pass
(
open_temp_repo
(
&
repo
,
REPOSITORY_FOLDER
));
/* Ensure a known loose ref can be looked up */
must_pass
(
git_reference_lookup
(
&
reference
,
repo
,
loose_tag_ref_name
));
must_be_true
((
reference
->
type
&
GIT_REF_PACKED
)
==
0
);
must_be_true
(
strcmp
(
reference
->
name
,
loose_tag_ref_name
)
==
0
);
/*
* We are now trying to pack also a loose reference
* called `points_to_blob`, to make sure we can properly
...
...
@@ -913,7 +913,7 @@ BEGIN_TEST(list0, "try to list all the references in our test repo")
/* We have exactly 8 refs in total if we include the packed ones:
* there is a reference that exists both in the packfile and as
* loose, but we only list it once */
must_be_true
(
ref_list
.
count
==
8
);
must_be_true
(
ref_list
.
count
==
8
);
git_strarray_free
(
&
ref_list
);
git_repository_free
(
repo
);
...
...
@@ -925,7 +925,7 @@ BEGIN_TEST(list1, "try to list only the symbolic references")
must_pass
(
git_repository_open
(
&
repo
,
REPOSITORY_FOLDER
));
must_pass
(
git_reference_listall
(
&
ref_list
,
repo
,
GIT_REF_SYMBOLIC
));
must_be_true
(
ref_list
.
count
==
0
);
/* no symrefs in the test repo */
must_be_true
(
ref_list
.
count
==
0
);
/* no symrefs in the test repo */
git_strarray_free
(
&
ref_list
);
git_repository_free
(
repo
);
...
...
tests/test_lib.h
View file @
932d1baf
...
...
@@ -15,7 +15,7 @@
#define BEGIN_SUITE(SNAME) \
git_testsuite *libgit2_suite_##SNAME(void) {\
git_testsuite *_gitsuite = git_testsuite_new(#SNAME);
#define ADD_TEST(TNAME) \
git_testsuite_add(_gitsuite, _gittest__##TNAME);
...
...
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