Commit 932d1baf by Kirill A. Shutemov Committed by Vicent Marti

cleanup: remove trailing spaces

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