Address PR comments

* Make GIT_INLINE an internal definition so it cannot be used in
  public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
This commit is contained in:
Russell Belfer 2014-02-20 14:27:10 -08:00
parent 68a19ca9ff
commit 72556cc63b
10 changed files with 30 additions and 29 deletions

View File

@ -89,7 +89,7 @@ code snippet.
The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C)
(a.k.a. C89) compatible. Internally, `libgit2` is written using a portable
subset of C99 - in order to compiler with GCC, Clang, MSVC, etc., we keep
subset of C99 - in order to compile with GCC, Clang, MSVC, etc., we keep
local variable declarations at the tops of blocks only and avoid `//` style
comments. Additionally, `libgit2` follows some extra conventions for
function and type naming, code formatting, and testing.
@ -109,14 +109,15 @@ are any unresolved issues to jump in on. Also, here is a list of some
smaller project ideas that could help you become familiar with the code
base and make a nice first step:
* Convert a `git_*modulename*_foreach()` callback-based iteration API
into a `git_*modulename*_iterator` object with a create/advance style
of API. This helps folks writing language bindings and usually isn't
too complicated.
* Write a new `examples/` program that mirrors a particular core git
command. (See `examples/diff.c` for example.) This lets you (and us)
easily exercise a particular facet of the API and measure compatability
and feature parity with core git.
* Look at the `examples/` programs, find an existing one that mirrors a
core Git command and add a missing command-line option. There are many
gaps right now and this helps demonstrate how to use the library.
* Pick a Git command that is not emulates in `examples/` and write a new
example that mirrors the behavior. Examples don't have to be perfect
emulations, but should demonstrate how to use the libgit2 APIs to get
results that are similar to Git commands. This lets you (and us) easily
exercise a particular facet of the API and measure compatability and
feature parity with core git.
* Submit a PR to clarify documentation! While we do try to document all of
the APIs, your fresh eyes on the documentation will find areas that are
confusing much more easily.

View File

@ -37,13 +37,6 @@
# define GIT_EXTERN(type) extern type
#endif
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define GIT_INLINE(type) static __inline type
#else
# define GIT_INLINE(type) static inline type
#endif
/** Declare a function's takes printf style arguments. */
#ifdef __GNUC__
# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))

View File

@ -120,10 +120,10 @@ typedef struct git_index_entry {
/** Capabilities of system that affect index actions. */
typedef enum {
GIT_INDEXCAP_IGNORE_CASE = 1u,
GIT_INDEXCAP_NO_FILEMODE = 2u,
GIT_INDEXCAP_NO_SYMLINKS = 4u,
GIT_INDEXCAP_FROM_OWNER = ~0u
GIT_INDEXCAP_IGNORE_CASE = 1,
GIT_INDEXCAP_NO_FILEMODE = 2,
GIT_INDEXCAP_NO_SYMLINKS = 4,
GIT_INDEXCAP_FROM_OWNER = -1,
} git_indexcap_t;
/** Callback for APIs that add/remove/update files matching pathspec */
@ -206,7 +206,7 @@ GIT_EXTERN(git_repository *) git_index_owner(const git_index *index);
* @param index An existing index object
* @return A combination of GIT_INDEXCAP values
*/
GIT_EXTERN(unsigned int) git_index_caps(const git_index *index);
GIT_EXTERN(int) git_index_caps(const git_index *index);
/**
* Set index capabilities flags.
@ -219,7 +219,7 @@ GIT_EXTERN(unsigned int) git_index_caps(const git_index *index);
* @param caps A combination of GIT_INDEXCAP values
* @return 0 on success, -1 on failure
*/
GIT_EXTERN(int) git_index_set_caps(git_index *index, unsigned int caps);
GIT_EXTERN(int) git_index_set_caps(git_index *index, int caps);
/**
* Update the contents of an existing index object in memory by reading

View File

@ -7,7 +7,7 @@
#ifndef INCLUDE_array_h__
#define INCLUDE_array_h__
#include "util.h"
#include "common.h"
/*
* Use this to declare a typesafe resizable array of items, a la:

View File

@ -7,7 +7,7 @@
#ifndef INCLUDE_bitvec_h__
#define INCLUDE_bitvec_h__
#include "util.h"
#include "common.h"
/*
* This is a silly little fixed length bit vector type that will store

View File

@ -10,6 +10,13 @@
#include "git2/common.h"
#include "cc-compat.h"
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define GIT_INLINE(type) static __inline type
#else
# define GIT_INLINE(type) static inline type
#endif
#include <assert.h>
#include <errno.h>
#include <limits.h>

View File

@ -438,7 +438,7 @@ static int create_index_error(int error, const char *msg)
return error;
}
int git_index_set_caps(git_index *index, unsigned int caps)
int git_index_set_caps(git_index *index, int caps)
{
unsigned int old_ignore_case;
@ -474,7 +474,7 @@ int git_index_set_caps(git_index *index, unsigned int caps)
return 0;
}
unsigned int git_index_caps(const git_index *index)
int git_index_caps(const git_index *index)
{
return ((index->ignore_case ? GIT_INDEXCAP_IGNORE_CASE : 0) |
(index->distrust_filemode ? GIT_INDEXCAP_NO_FILEMODE : 0) |

View File

@ -2364,7 +2364,7 @@ done:
int git_merge__indexes(git_repository *repo, git_index *index_new)
{
git_index *index_repo = NULL;
unsigned int index_repo_caps = 0;
int index_repo_caps = 0;
git_vector paths = GIT_VECTOR_INIT;
size_t index_conflicts = 0, wd_conflicts = 0, conflicts, i;
char *path;

View File

@ -7,7 +7,7 @@
#ifndef INCLUDE_vector_h__
#define INCLUDE_vector_h__
#include "git2/common.h"
#include "common.h"
typedef int (*git_vector_cmp)(const void *, const void *);

View File

@ -156,7 +156,7 @@ void test_repo_iterator__index_icase(void)
{
git_iterator *i;
git_index *index;
unsigned int caps;
int caps;
g_repo = cl_git_sandbox_init("icase");