summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/git2/commit.h10
-rw-r--r--include/git2/common.h22
-rw-r--r--include/git2/errors.h4
-rw-r--r--include/git2/index.h30
-rw-r--r--include/git2/odb.h6
-rw-r--r--include/git2/oid.h26
-rw-r--r--include/git2/revwalk.h10
-rw-r--r--include/git2/status.h14
-rw-r--r--include/git2/tag.h4
-rw-r--r--include/git2/thread-utils.h58
-rw-r--r--include/git2/types.h22
-rw-r--r--src/bswap.h4
-rw-r--r--src/cc-compat.h18
-rw-r--r--src/common.h4
-rw-r--r--src/config.c2
-rw-r--r--src/config_file.c4
-rw-r--r--src/delta-apply.c14
-rw-r--r--src/dir.h14
-rw-r--r--src/errors.c2
-rw-r--r--src/fileops.c12
-rw-r--r--src/fileops.h10
-rw-r--r--src/index.c8
-rw-r--r--src/map.h22
-rw-r--r--src/mwindow.c8
-rw-r--r--src/object.c14
-rw-r--r--src/odb.c4
-rw-r--r--src/odb.h6
-rw-r--r--src/odb_loose.c34
-rw-r--r--src/odb_pack.c130
-rw-r--r--src/oid.c6
-rw-r--r--src/pack.c42
-rw-r--r--src/pack.h2
-rw-r--r--src/path.c132
-rw-r--r--src/pkt.c8
-rw-r--r--src/ppc/sha1.c2
-rw-r--r--src/pqueue.c122
-rw-r--r--src/pqueue.h8
-rw-r--r--src/reflog.c2
-rw-r--r--src/refs.c18
-rw-r--r--src/refspec.c2
-rw-r--r--src/remote.c2
-rw-r--r--src/sha1.c26
-rw-r--r--src/sha1_lookup.c68
-rw-r--r--src/sha1_lookup.h8
-rw-r--r--src/tag.c8
-rw-r--r--src/thread-utils.c16
-rw-r--r--src/thread-utils.h6
-rw-r--r--src/transport.h2
-rw-r--r--src/transport_git.c6
-rw-r--r--src/tsort.c4
-rw-r--r--src/util.c46
-rw-r--r--src/util.h2
-rw-r--r--src/win32/fnmatch.c296
-rw-r--r--src/win32/fnmatch.h18
-rw-r--r--src/win32/map.c4
-rw-r--r--src/win32/mingw-compat.h2
-rw-r--r--src/win32/msvc-compat.h20
-rw-r--r--src/win32/posix.c16
-rw-r--r--src/win32/pthread.c46
-rw-r--r--src/win32/pthread.h4
-rw-r--r--tests-clay/clay_main.c104
-rw-r--r--tests-clay/core/dirent.c46
-rw-r--r--tests-clay/core/vector.c2
63 files changed, 806 insertions, 806 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 2e94a6497..3c90e8007 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -26,8 +26,8 @@ GIT_BEGIN_DECL
*
* @param commit pointer to the looked up commit
* @param repo the repo to use when locating the commit.
- * @param id identity of the commit to locate. If the object is
- * an annotated tag it will be peeled back to the commit.
+ * @param id identity of the commit to locate. If the object is
+ * an annotated tag it will be peeled back to the commit.
* @return GIT_SUCCESS or an error code
*/
GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id)
@@ -43,8 +43,8 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
*
* @param commit pointer to the looked up commit
* @param repo the repo to use when locating the commit.
- * @param id identity of the commit to locate. If the object is
- * an annotated tag it will be peeled back to the commit.
+ * @param id identity of the commit to locate. If the object is
+ * an annotated tag it will be peeled back to the commit.
* @param len the length of the short identifier
* @return GIT_SUCCESS or an error code
*/
@@ -197,7 +197,7 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
* time of this commit
*
* @param committer Signature representing the committer and the
- * commit time of this commit
+ * commit time of this commit
*
* @param message_encoding The encoding for the message in the
* commit, represented with a standard encoding name.
diff --git a/include/git2/common.h b/include/git2/common.h
index f14314054..1a595b058 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -12,20 +12,20 @@
#include <stdlib.h>
#ifdef __cplusplus
-# define GIT_BEGIN_DECL extern "C" {
-# define GIT_END_DECL }
+# define GIT_BEGIN_DECL extern "C" {
+# define GIT_END_DECL }
#else
- /** Start declarations in C mode */
-# define GIT_BEGIN_DECL /* empty */
- /** End declarations in C mode */
-# define GIT_END_DECL /* empty */
+ /** Start declarations in C mode */
+# define GIT_BEGIN_DECL /* empty */
+ /** End declarations in C mode */
+# define GIT_END_DECL /* empty */
#endif
/** Declare a public function exported for application use. */
#ifdef __GNUC__
# define GIT_EXTERN(type) extern \
- __attribute__((visibility("default"))) \
- type
+ __attribute__((visibility("default"))) \
+ type
#elif defined(_MSC_VER)
# define GIT_EXTERN(type) __declspec(dllexport) type
#else
@@ -35,9 +35,9 @@
/** Declare a public TLS symbol exported for application use. */
#ifdef __GNUC__
# define GIT_EXTERN_TLS(type) extern \
- __attribute__((visibility("default"))) \
- GIT_TLS \
- type
+ __attribute__((visibility("default"))) \
+ GIT_TLS \
+ type
#elif defined(_MSC_VER)
# define GIT_EXTERN_TLS(type) __declspec(dllexport) GIT_TLS type
#else
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 8b9fe3b07..5ac0d5b27 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -64,7 +64,7 @@ typedef enum {
GIT_EINVALIDREFNAME = -15,
/** The specified reference has its data corrupted */
- GIT_EREFCORRUPTED = -16,
+ GIT_EREFCORRUPTED = -16,
/** The specified symbolic reference is too deeply nested */
GIT_ETOONESTEDSYMREF = -17,
@@ -111,7 +111,7 @@ typedef enum {
/** The path pattern and string did not match */
GIT_ENOMATCH = -31,
- /** The buffer is too short to satisfy the request */
+ /** The buffer is too short to satisfy the request */
GIT_ESHORTBUFFER = -32,
} git_error;
diff --git a/include/git2/index.h b/include/git2/index.h
index 70d928b8e..5e9c34d4b 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -20,10 +20,10 @@
*/
GIT_BEGIN_DECL
-#define GIT_IDXENTRY_NAMEMASK (0x0fff)
+#define GIT_IDXENTRY_NAMEMASK (0x0fff)
#define GIT_IDXENTRY_STAGEMASK (0x3000)
-#define GIT_IDXENTRY_EXTENDED (0x4000)
-#define GIT_IDXENTRY_VALID (0x8000)
+#define GIT_IDXENTRY_EXTENDED (0x4000)
+#define GIT_IDXENTRY_VALID (0x8000)
#define GIT_IDXENTRY_STAGESHIFT 12
/*
@@ -33,26 +33,26 @@ GIT_BEGIN_DECL
*
* In-memory only flags:
*/
-#define GIT_IDXENTRY_UPDATE (1 << 0)
-#define GIT_IDXENTRY_REMOVE (1 << 1)
-#define GIT_IDXENTRY_UPTODATE (1 << 2)
-#define GIT_IDXENTRY_ADDED (1 << 3)
+#define GIT_IDXENTRY_UPDATE (1 << 0)
+#define GIT_IDXENTRY_REMOVE (1 << 1)
+#define GIT_IDXENTRY_UPTODATE (1 << 2)
+#define GIT_IDXENTRY_ADDED (1 << 3)
-#define GIT_IDXENTRY_HASHED (1 << 4)
-#define GIT_IDXENTRY_UNHASHED (1 << 5)
-#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
-#define GIT_IDXENTRY_CONFLICTED (1 << 7)
+#define GIT_IDXENTRY_HASHED (1 << 4)
+#define GIT_IDXENTRY_UNHASHED (1 << 5)
+#define GIT_IDXENTRY_WT_REMOVE (1 << 6) /* remove in work directory */
+#define GIT_IDXENTRY_CONFLICTED (1 << 7)
-#define GIT_IDXENTRY_UNPACKED (1 << 8)
+#define GIT_IDXENTRY_UNPACKED (1 << 8)
#define GIT_IDXENTRY_NEW_SKIP_WORKTREE (1 << 9)
/*
* Extended on-disk flags:
*/
-#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
-#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
+#define GIT_IDXENTRY_INTENT_TO_ADD (1 << 13)
+#define GIT_IDXENTRY_SKIP_WORKTREE (1 << 14)
/* GIT_IDXENTRY_EXTENDED2 is for future extension */
-#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
+#define GIT_IDXENTRY_EXTENDED2 (1 << 15)
#define GIT_IDXENTRY_EXTENDED_FLAGS (GIT_IDXENTRY_INTENT_TO_ADD | GIT_IDXENTRY_SKIP_WORKTREE)
diff --git a/include/git2/odb.h b/include/git2/odb.h
index 0f719ae7f..27837418b 100644
--- a/include/git2/odb.h
+++ b/include/git2/odb.h
@@ -28,7 +28,7 @@ GIT_BEGIN_DECL
* backend must be manually added using `git_odb_add_backend()`
*
* @param out location to store the database pointer, if opened.
- * Set to NULL if the open failed.
+ * Set to NULL if the open failed.
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_odb_new(git_odb **out);
@@ -45,7 +45,7 @@ GIT_EXTERN(int) git_odb_new(git_odb **out);
* contains a 'pack/' folder with the corresponding data
*
* @param out location to store the database pointer, if opened.
- * Set to NULL if the open failed.
+ * Set to NULL if the open failed.
* @param objects_dir path of the backends' "objects" directory.
* @return GIT_SUCCESS or an error code
*/
@@ -90,7 +90,7 @@ GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, in
/**
* Close an open object database.
*
- * @param db database pointer to close. If NULL no action is taken.
+ * @param db database pointer to close. If NULL no action is taken.
*/
GIT_EXTERN(void) git_odb_close(git_odb *db);
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 2dd9e4f51..f9636d1fc 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -41,8 +41,8 @@ struct _git_oid {
*
* @param out oid structure the result is written into.
* @param str input hex string; must be pointing at the start of
- * the hex sequence and have at least the number of bytes
- * needed for an oid encoded in hex (40 bytes).
+ * the hex sequence and have at least the number of bytes
+ * needed for an oid encoded in hex (40 bytes).
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
@@ -72,10 +72,10 @@ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw);
* Format a git_oid into a hex string.
*
* @param str output hex string; must be pointing at the start of
- * the hex sequence and have at least the number of bytes
- * needed for an oid encoded in hex (40 bytes). Only the
- * oid digits are written; a '\\0' terminator must be added
- * by the caller if it is required.
+ * the hex sequence and have at least the number of bytes
+ * needed for an oid encoded in hex (40 bytes). Only the
+ * oid digits are written; a '\\0' terminator must be added
+ * by the caller if it is required.
* @param oid oid structure to format.
*/
GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid);
@@ -87,10 +87,10 @@ GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid);
* hex digitis of the oid and "..." is the remaining 38 digits.
*
* @param str output hex string; must be pointing at the start of
- * the hex sequence and have at least the number of bytes
- * needed for an oid encoded in hex (41 bytes). Only the
- * oid digits are written; a '\\0' terminator must be added
- * by the caller if it is required.
+ * the hex sequence and have at least the number of bytes
+ * needed for an oid encoded in hex (41 bytes). Only the
+ * oid digits are written; a '\\0' terminator must be added
+ * by the caller if it is required.
* @param oid oid structure to format.
*/
GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
@@ -99,8 +99,8 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid);
* Format a git_oid into a newly allocated c-string.
*
* @param oid the oid structure to format
- * @return the c-string; NULL if memory is exhausted. Caller must
- * deallocate the string with free().
+ * @return the c-string; NULL if memory is exhausted. Caller must
+ * deallocate the string with free().
*/
GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
@@ -117,7 +117,7 @@ GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid);
* @param n the size of the out buffer.
* @param oid the oid structure to format.
* @return the out buffer pointer, assuming no input parameter
- * errors, otherwise a pointer to an empty string.
+ * errors, otherwise a pointer to an empty string.
*/
GIT_EXTERN(char *) git_oid_to_string(char *out, size_t n, const git_oid *oid);
diff --git a/include/git2/revwalk.h b/include/git2/revwalk.h
index b232de83a..c84c5d301 100644
--- a/include/git2/revwalk.h
+++ b/include/git2/revwalk.h
@@ -26,28 +26,28 @@ GIT_BEGIN_DECL
* and subject to change at any time.
* This is the default sorting for new walkers.
*/
-#define GIT_SORT_NONE (0)
+#define GIT_SORT_NONE (0)
/**
* Sort the repository contents in topological order
* (parents before children); this sorting mode
* can be combined with time sorting.
*/
-#define GIT_SORT_TOPOLOGICAL (1 << 0)
+#define GIT_SORT_TOPOLOGICAL (1 << 0)
/**
* Sort the repository contents by commit time;
* this sorting mode can be combined with
* topological sorting.
*/
-#define GIT_SORT_TIME (1 << 1)
+#define GIT_SORT_TIME (1 << 1)
/**
* Iterate through the repository contents in reverse
* order; this sorting mode can be combined with
* any of the above.
*/
-#define GIT_SORT_REVERSE (1 << 2)
+#define GIT_SORT_REVERSE (1 << 2)
/**
* Allocate a new revision walker to iterate through a repo.
@@ -151,7 +151,7 @@ GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
/**
* Free a revision walker previously allocated.
*
- * @param walk traversal handle to close. If NULL nothing occurs.
+ * @param walk traversal handle to close. If NULL nothing occurs.
*/
GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk);
diff --git a/include/git2/status.h b/include/git2/status.h
index 5f498d882..42b2dd197 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -19,19 +19,19 @@
*/
GIT_BEGIN_DECL
-#define GIT_STATUS_CURRENT 0
+#define GIT_STATUS_CURRENT 0
/** Flags for index status */
-#define GIT_STATUS_INDEX_NEW (1 << 0)
+#define GIT_STATUS_INDEX_NEW (1 << 0)
#define GIT_STATUS_INDEX_MODIFIED (1 << 1)
-#define GIT_STATUS_INDEX_DELETED (1 << 2)
+#define GIT_STATUS_INDEX_DELETED (1 << 2)
/** Flags for worktree status */
-#define GIT_STATUS_WT_NEW (1 << 3)
-#define GIT_STATUS_WT_MODIFIED (1 << 4)
-#define GIT_STATUS_WT_DELETED (1 << 5)
+#define GIT_STATUS_WT_NEW (1 << 3)
+#define GIT_STATUS_WT_MODIFIED (1 << 4)
+#define GIT_STATUS_WT_DELETED (1 << 5)
// TODO Ignored files not handled yet
-#define GIT_STATUS_IGNORED (1 << 6)
+#define GIT_STATUS_IGNORED (1 << 6)
/**
* Gather file statuses and run a callback for each one.
diff --git a/include/git2/tag.h b/include/git2/tag.h
index baf7f9d61..63a522882 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -152,7 +152,7 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* must belong to the given `repo`.
*
* @param tagger Signature of the tagger for this tag, and
- * of the tagging time
+ * of the tagging time
*
* @param message Full message for this tag
*
@@ -211,7 +211,7 @@ GIT_EXTERN(int) git_tag_create_frombuffer(
*
* @return GIT_SUCCESS or an error code
* A proper reference is written in the /refs/tags folder,
- * pointing to the provided target object
+ * pointing to the provided target object
*/
GIT_EXTERN(int) git_tag_create_lightweight(
git_oid *oid,
diff --git a/include/git2/thread-utils.h b/include/git2/thread-utils.h
index e5085fc3a..81c62d135 100644
--- a/include/git2/thread-utils.h
+++ b/include/git2/thread-utils.h
@@ -10,51 +10,51 @@
/*
* How TLS works is compiler+platform dependant
* Sources: http://en.wikipedia.org/wiki/Thread-Specific_Storage
- * http://predef.sourceforge.net/precomp.html
+ * http://predef.sourceforge.net/precomp.html
*/
#ifdef GIT_THREADS
-# define GIT_HAS_TLS 1
+# define GIT_HAS_TLS 1
/* No TLS in Cygwin */
-# if defined(__CHECKER__) || defined(__CYGWIN__)
-# undef GIT_HAS_TLS
-# define GIT_TLS
+# if defined(__CHECKER__) || defined(__CYGWIN__)
+# undef GIT_HAS_TLS
+# define GIT_TLS
/* No TLS in Mach binaries for Mac OS X */
-# elif defined(__APPLE__) && defined(__MACH__)
-# undef GIT_TLS
-# define GIT_TLS
+# elif defined(__APPLE__) && defined(__MACH__)
+# undef GIT_TLS
+# define GIT_TLS
/* Normal TLS for GCC */
-# elif defined(__GNUC__) || \
- defined(__SUNPRO_C) || \
- defined(__SUNPRO_CC) || \
- defined(__xlc__) || \
- defined(__xlC__)
-# define GIT_TLS __thread
+# elif defined(__GNUC__) || \
+ defined(__SUNPRO_C) || \
+ defined(__SUNPRO_CC) || \
+ defined(__xlc__) || \
+ defined(__xlC__)
+# define GIT_TLS __thread
/* ICC may run on Windows or Linux */
-# elif defined(__INTEL_COMPILER)
-# if defined(_WIN32) || defined(_WIN32_CE)
-# define GIT_TLS __declspec(thread)
-# else
-# define GIT_TLS __thread
-# endif
+# elif defined(__INTEL_COMPILER)
+# if defined(_WIN32) || defined(_WIN32_CE)
+# define GIT_TLS __declspec(thread)
+# else
+# define GIT_TLS __thread
+# endif
/* Declspec for MSVC in Win32 */
-# elif defined(_WIN32) || \
- defined(_WIN32_CE) || \
- defined(__BORLANDC__)
-# define GIT_TLS __declspec(thread)
+# elif defined(_WIN32) || \
+ defined(_WIN32_CE) || \
+ defined(__BORLANDC__)
+# define GIT_TLS __declspec(thread)
/* Other platform; no TLS */
-# else
-# undef GIT_HAS_TLS
-# define GIT_TLS /* nothing: tls vars are thread-global */
-# endif
+# else
+# undef GIT_HAS_TLS
+# define GIT_TLS /* nothing: tls vars are thread-global */
+# endif
#else /* Disable TLS if libgit2 is not threadsafe */
-# define GIT_TLS
+# define GIT_TLS
#endif /* GIT_THREADS */
#endif /* INCLUDE_git_thread_utils_h__ */
diff --git a/include/git2/types.h b/include/git2/types.h
index d4edda58f..1df18974a 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -36,7 +36,7 @@ GIT_BEGIN_DECL
#if defined(_MSC_VER)
typedef __int64 git_off_t;
-typedef __time64_t git_time_t;
+typedef __time64_t git_time_t;
#elif defined(__MINGW32__)
@@ -48,7 +48,7 @@ typedef __time64_t git_time_t;
typedef __haiku_std_int64 git_off_t;
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>
@@ -63,15 +63,15 @@ typedef int64_t git_time_t;
/** Basic type (loose or packed) of any Git object. */
typedef enum {
GIT_OBJ_ANY = -2, /**< Object can be any of the following */
- GIT_OBJ_BAD = -1, /**< Object is invalid. */
- GIT_OBJ__EXT1 = 0, /**< Reserved for future use. */
- GIT_OBJ_COMMIT = 1, /**< A commit object. */
- GIT_OBJ_TREE = 2, /**< A tree (directory listing) object. */
- GIT_OBJ_BLOB = 3, /**< A file revision object. */
- GIT_OBJ_TAG = 4, /**< An annotated tag object. */
- GIT_OBJ__EXT2 = 5, /**< Reserved for future use. */
- GIT_OBJ_OFS_DELTA = 6, /**< A delta, base is given by an offset. */
- GIT_OBJ_REF_DELTA = 7, /**< A delta, base is given by object id. */
+ GIT_OBJ_BAD = -1, /**< Object is invalid. */
+ GIT_OBJ__EXT1 = 0, /**< Reserved for future use. */
+ GIT_OBJ_COMMIT = 1, /**< A commit object. */
+ GIT_OBJ_TREE = 2, /**< A tree (directory listing) object. */
+ GIT_OBJ_BLOB = 3, /**< A file revision object. */
+ GIT_OBJ_TAG = 4, /**< An annotated tag object. */
+ GIT_OBJ__EXT2 = 5, /**< Reserved for future use. */
+ GIT_OBJ_OFS_DELTA = 6, /**< A delta, base is given by an offset. */
+ GIT_OBJ_REF_DELTA = 7, /**< A delta, base is given by object id. */
} git_otype;
/** An open object database handle. */
diff --git a/src/bswap.h b/src/bswap.h
index edb64a2a2..0914906ff 100644
--- a/src/bswap.h
+++ b/src/bswap.h
@@ -14,8 +14,8 @@
GIT_INLINE(uint32_t) default_swab32(uint32_t val)
{
return (((val & 0xff000000) >> 24) |
- ((val & 0x00ff0000) >> 8) |
- ((val & 0x0000ff00) << 8) |
+ ((val & 0x00ff0000) >> 8) |
+ ((val & 0x0000ff00) << 8) |
((val & 0x000000ff) << 24));
}
diff --git a/src/cc-compat.h b/src/cc-compat.h
index 521e49183..cce4ca9b1 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -12,18 +12,18 @@
*/
#ifndef GIT_FLEX_ARRAY
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-# define GIT_FLEX_ARRAY /* empty */
+# define GIT_FLEX_ARRAY /* empty */
# elif defined(__GNUC__)
-# if (__GNUC__ >= 3)
-# define GIT_FLEX_ARRAY /* empty */
-# else
-# define GIT_FLEX_ARRAY 0 /* older GNU extension */
-# endif
+# if (__GNUC__ >= 3)
+# define GIT_FLEX_ARRAY /* empty */
+# else
+# define GIT_FLEX_ARRAY 0 /* older GNU extension */
+# endif
# endif
/* Default to safer but a bit wasteful traditional style */
# ifndef GIT_FLEX_ARRAY
-# define GIT_FLEX_ARRAY 1
+# define GIT_FLEX_ARRAY 1
# endif
#endif
@@ -37,9 +37,9 @@
# define GIT_UNUSED(x)
#else
# ifdef __GNUC__
-# define GIT_UNUSED(x) x __attribute__ ((__unused__))
+# define GIT_UNUSED(x) x __attribute__ ((__unused__))
# else
-# define GIT_UNUSED(x) x
+# define GIT_UNUSED(x) x
# endif
#endif
diff --git a/src/common.h b/src/common.h
index 2d0f3f482..ed04de206 100644
--- a/src/common.h
+++ b/src/common.h
@@ -32,7 +32,7 @@
# include "win32/msvc-compat.h"
# include "win32/mingw-compat.h"
# ifdef GIT_THREADS
-# include "win32/pthread.h"
+# include "win32/pthread.h"
#endif
# define snprintf _snprintf
@@ -43,7 +43,7 @@ typedef SSIZE_T ssize_t;
# include <unistd.h>
# ifdef GIT_THREADS
-# include <pthread.h>
+# include <pthread.h>
# endif
#endif
diff --git a/src/config.c b/src/config.c
index 1974df94e..975e353f2 100644
--- a/src/config.c
+++ b/src/config.c
@@ -151,7 +151,7 @@ int git_config_foreach(git_config *cfg, int (*fn)(const char *, const char *, vo
int git_config_delete(git_config *cfg, const char *name)
{
- return git_config_set_string(cfg, name, NULL);
+ return git_config_set_string(cfg, name, NULL);
}
/**************
diff --git a/src/config_file.c b/src/config_file.c
index 564f9a25a..f7e6f61b4 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -748,7 +748,7 @@ static int skip_bom(diskfile_backend *cfg)
if (memcmp(cfg->reader.read_ptr, utf8_bom, sizeof(utf8_bom)) == 0)
cfg->reader.read_ptr += sizeof(utf8_bom);
- /* TODO: the reference implementation does pretty stupid
+ /* TODO: the reference implementation does pretty stupid
shit with the BoM
*/
@@ -1019,7 +1019,7 @@ static int config_write(diskfile_backend *cfg, cvar_t *var)
/* And then the write out rest of the file */
error = git_filebuf_write(&file, post_start,
- cfg->reader.buffer.len - (post_start - data_start));
+ cfg->reader.buffer.len - (post_start - data_start));
if (error < GIT_SUCCESS) {
git__rethrow(error, "Failed to write the rest of the file");
diff --git a/src/delta-apply.c b/src/delta-apply.c
index 70ddfd9bc..e1fb15b9b 100644
--- a/src/delta-apply.c
+++ b/src/delta-apply.c
@@ -11,7 +11,7 @@
/*
* This file was heavily cribbed from BinaryDelta.java in JGit, which
* itself was heavily cribbed from <code>patch-delta.c</code> in the
- * GIT project. The original delta patching code was written by
+ * GIT project. The original delta patching code was written by
* Nicolas Pitre <nico@cam.org>.
*/
@@ -70,15 +70,15 @@ int git__delta_apply(
*/
size_t off = 0, len = 0;
- if (cmd & 0x01) off = *delta++;
- if (cmd & 0x02) off |= *delta++ << 8;
+ if (cmd & 0x01) off = *delta++;
+ if (cmd & 0x02) off |= *delta++ << 8;
if (cmd & 0x04) off |= *delta++ << 16;
if (cmd & 0x08) off |= *delta++ << 24;
- if (cmd & 0x10) len = *delta++;
- if (cmd & 0x20) len |= *delta++ << 8;
+ if (cmd & 0x10) len = *delta++;
+ if (cmd & 0x20) len |= *delta++ << 8;
if (cmd & 0x40) len |= *delta++ << 16;
- if (!len) len = 0x10000;
+ if (!len) len = 0x10000;
if (base_len < off + len || res_sz < len)
goto fail;
@@ -93,7 +93,7 @@ int git__delta_apply(
if (delta_end - delta < cmd || res_sz < cmd)
goto fail;
memcpy(res_dp, delta, cmd);
- delta += cmd;
+ delta += cmd;
res_dp += cmd;
res_sz -= cmd;
diff --git a/src/dir.h b/src/dir.h
index 148062e22..ed517da33 100644
--- a/src/dir.h
+++ b/src/dir.h
@@ -16,7 +16,7 @@
#ifdef GIT_WIN32
struct git__dirent {
- int d_ino;
+ int d_ino;
char d_name[261];
};
@@ -34,12 +34,12 @@ extern void git__rewinddir(git__DIR *);
extern int git__closedir(git__DIR *);
# ifndef GIT__WIN32_NO_WRAP_DIR
-# define dirent git__dirent
-# define DIR git__DIR
-# define opendir git__opendir
-# define readdir git__readdir
-# define rewinddir git__rewinddir
-# define closedir git__closedir
+# define dirent git__dirent
+# define DIR git__DIR
+# define opendir git__opendir
+# define readdir git__readdir
+# define rewinddir git__rewinddir
+# define closedir git__closedir
# endif
#endif
diff --git a/src/errors.c b/src/errors.c
index 45091e37f..60d774636 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -71,7 +71,7 @@ void git___rethrow(const char *msg, ...)
va_end(va);
old_error = strdup(g_last_error);
- snprintf(g_last_error, sizeof(g_last_error), "%s \n - %s", new_error, old_error);
+ snprintf(g_last_error, sizeof(g_last_error), "%s \n - %s", new_error, old_error);
free(old_error);
}
diff --git a/src/fileops.c b/src/fileops.c
index 84573397e..bfd63f584 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -194,7 +194,7 @@ int git_futils_readbuffer_updated(git_fbuffer *obj, const char *path, time_t *mt
*updated = 1;
obj->data = buff;
- obj->len = len;
+ obj->len = len;
return GIT_SUCCESS;
}
@@ -293,7 +293,7 @@ int git_futils_mkdir_r(const char *path, int mode)
{
int error, root_path_offset;
char *pp, *sp;
- char *path_copy = git__strdup(path);
+ char *path_copy = git__strdup(path);
if (path_copy == NULL)
return GIT_ENOMEM;
@@ -305,7 +305,7 @@ int git_futils_mkdir_r(const char *path, int mode)
if (root_path_offset > 0)
pp += root_path_offset; /* On Windows, will skip the drive name (eg. C: or D:) */
- while (error == GIT_SUCCESS && (sp = strchr(pp, '/')) != NULL) {
+ while (error == GIT_SUCCESS && (sp = strchr(pp, '/')) != NULL) {
if (sp != pp && git_futils_isdir(path_copy) < GIT_SUCCESS) {
*sp = 0;
error = p_mkdir(path_copy, mode);
@@ -359,7 +359,7 @@ int git_futils_rmdir_r(const char *path, int force)
{
char p[GIT_PATH_MAX];
strncpy(p, path, GIT_PATH_MAX);
- return _rmdir_recurs_foreach(&force, p);
+ return _rmdir_recurs_foreach(&force, p);
}
int git_futils_cmp_path(const char *name1, int len1, int isdir1,
@@ -373,10 +373,10 @@ int git_futils_cmp_path(const char *name1, int len1, int isdir1,
return cmp;
if (len1 < len2)
return ((!isdir1 && !isdir2) ? -1 :
- (isdir1 ? '/' - name2[len1] : name2[len1] - '/'));
+ (isdir1 ? '/' - name2[len1] : name2[len1] - '/'));
if (len1 > len2)
return ((!isdir1 && !isdir2) ? 1 :
- (isdir2 ? name1[len2] - '/' : '/' - name1[len2]));
+ (isdir2 ? name1[len2] - '/' : '/' - name1[len2]));
return 0;
}
diff --git a/src/fileops.h b/src/fileops.h
index 92d2fb8fd..5b69199d2 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -20,9 +20,9 @@
*/
#define GIT_FBUFFER_INIT {NULL, 0}
-typedef struct { /* file io buffer */
- void *data; /* data bytes */
- size_t len; /* data length */
+typedef struct { /* file io buffer */
+ void *data; /* data bytes */
+ size_t len; /* data length */
} git_fbuffer;
extern int git_futils_readbuffer(git_fbuffer *obj, const char *path);
@@ -139,8 +139,8 @@ extern void git_futils_mmap_free(git_map *map);
* @param pathbuf buffer the function reads the initial directory
* path from, and updates with each successive entry's name.
* @param pathmax maximum allocation of pathbuf.
- * @param fn function to invoke with each entry. The first arg is
- * the input state and the second arg is pathbuf. The function
+ * @param fn function to invoke with each entry. The first arg is
+ * the input state and the second arg is pathbuf. The function
* may modify the pathbuf, but only by appending new text.
* @param state to pass to fn as the first arg.
*/
diff --git a/src/index.c b/src/index.c
index fed4f2a6d..e6a181979 100644
--- a/src/index.c
+++ b/src/index.c
@@ -963,11 +963,11 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry)
ondisk->mtime.seconds = htonl((uint32_t)entry->mtime.seconds);
ondisk->ctime.nanoseconds = htonl(entry->ctime.nanoseconds);
ondisk->mtime.nanoseconds = htonl(entry->mtime.nanoseconds);
- ondisk->dev = htonl(entry->dev);
- ondisk->ino = htonl(entry->ino);
+ ondisk->dev = htonl(entry->dev);
+ ondisk->ino = htonl(entry->ino);
ondisk->mode = htonl(entry->mode);
- ondisk->uid = htonl(entry->uid);
- ondisk->gid = htonl(entry->gid);
+ ondisk->uid = htonl(entry->uid);
+ ondisk->gid = htonl(entry->gid);
ondisk->file_size = htonl((uint32_t)entry->file_size);
git_oid_cpy(&ondisk->oid, &entry->oid);
diff --git a/src/map.h b/src/map.h
index a3ca1a113..6969de5b3 100644
--- a/src/map.h
+++ b/src/map.h
@@ -11,23 +11,23 @@
/* p_mmap() prot values */
-#define GIT_PROT_NONE 0x0
-#define GIT_PROT_READ 0x1
+#define GIT_PROT_NONE 0x0
+#define GIT_PROT_READ 0x1
#define GIT_PROT_WRITE 0x2
-#define GIT_PROT_EXEC 0x4
+#define GIT_PROT_EXEC 0x4
/* git__mmmap() flags values */
-#define GIT_MAP_FILE 0
-#define GIT_MAP_SHARED 1
+#define GIT_MAP_FILE 0
+#define GIT_MAP_SHARED 1
#define GIT_MAP_PRIVATE 2
-#define GIT_MAP_TYPE 0xf
-#define GIT_MAP_FIXED 0x10
+#define GIT_MAP_TYPE 0xf
+#define GIT_MAP_FIXED 0x10
-typedef struct { /* memory mapped buffer */
- void *data; /* data bytes */
- size_t len; /* data length */
+typedef struct { /* memory mapped buffer */
+ void *data; /* data bytes */
+ size_t len; /* data length */
#ifdef GIT_WIN32
- HANDLE fmh; /* file mapping handle */
+ HANDLE fmh; /* file mapping handle */
#endif
} git_map;
diff --git a/src/mwindow.c b/src/mwindow.c
index cb35e4804..76b80d779 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -13,7 +13,7 @@
#define DEFAULT_WINDOW_SIZE \
(sizeof(void*) >= 8 \
- ? 1 * 1024 * 1024 * 1024 \
+ ? 1 * 1024 * 1024 * 1024 \
: 32 * 1024 * 1024)
#define DEFAULT_MAPPED_LIMIT \
@@ -165,7 +165,7 @@ static git_mwindow *new_window(git_mwindow_file *mwf, git_file fd, git_off_t siz
ctl.mapped += (size_t)len;
while(ctl.mapped_limit < ctl.mapped &&
- git_mwindow_close_lru(mwf) == GIT_SUCCESS) {}
+ git_mwindow_close_lru(mwf) == GIT_SUCCESS) {}
/* FIXME: Shouldn't we error out if there's an error in closing lru? */
@@ -193,7 +193,7 @@ cleanup:
* enough space. Don't forget to add it to your list
*/
unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor,
- git_off_t offset, int extra, unsigned int *left)
+ git_off_t offset, int extra, unsigned int *left)
{
git_mwindow *w = *cursor;
@@ -241,7 +241,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
int error;
if (ctl.windowfiles.length == 0 &&
- (error = git_vector_init(&ctl.windowfiles, 8, NULL)) < GIT_SUCCESS)
+ (error = git_vector_init(&ctl.windowfiles, 8, NULL)) < GIT_SUCCESS)
return error;
return git_vector_insert(&ctl.windowfiles, mwf);
diff --git a/src/object.c b/src/object.c
index 4b6141bab..edc2d80fa 100644
--- a/src/object.c
+++ b/src/object.c
@@ -19,8 +19,8 @@
static const int OBJECT_BASE_SIZE = 4096;
static struct {
- const char *str; /* type name string */
- int loose; /* valid loose object type flag */
+ const char *str; /* type name string */
+ int loose; /* valid loose object type flag */
size_t size; /* size in bytes of the object structure */
} git_objects_table[] = {
/* 0 = GIT_OBJ__EXT1 */
@@ -92,7 +92,7 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
if (len > GIT_OID_HEXSZ)
len = GIT_OID_HEXSZ;
- if (len == GIT_OID_HEXSZ) {
+ if (len == GIT_OID_HEXSZ) {
/* We want to match the full id : we can first look up in the cache,
* since there is no need to check for non ambiguousity
*/
@@ -126,10 +126,10 @@ int git_object_lookup_prefix(git_object **object_out, git_repository *repo, cons
/* If len < GIT_OID_HEXSZ (a strict short oid was given), we have
* 2 options :
* - We always search in the cache first. If we find that short oid is
- * ambiguous, we can stop. But in all the other cases, we must then
- * explore all the backends (to find an object if there was match,
- * or to check that oid is not ambiguous if we have found 1 match in
- * the cache)
+ * ambiguous, we can stop. But in all the other cases, we must then
+ * explore all the backends (to find an object if there was match,
+ * or to check that oid is not ambiguous if we have found 1 match in
+ * the cache)
* - We never explore the cache, go right to exploring the backends
* We chose the latter : we explore directly the backends.
*/
diff --git a/src/odb.c b/src/odb.c
index ed50dbc96..02809beec 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -57,9 +57,9 @@ int git_odb__hash_obj(git_oid *id, git_rawobj *obj)
return git__rethrow(hdrlen, "Failed to hash object");
vec[0].data = header;
- vec[0].len = hdrlen;
+ vec[0].len = hdrlen;
vec[1].data = obj->data;
- vec[1].len = obj->len;
+ vec[1].len = obj->len;
git_hash_vec(id, vec, 2);
diff --git a/src/odb.h b/src/odb.h
index 49c6359a5..4e850916b 100644
--- a/src/odb.h
+++ b/src/odb.h
@@ -16,9 +16,9 @@
/* DO NOT EXPORT */
typedef struct {
- void *data; /**< Raw, decompressed object data. */
- size_t len; /**< Total number of bytes in data. */
- git_otype type; /**< Type of this object. */
+ void *data; /**< Raw, decompressed object data. */
+ size_t len; /**< Total number of bytes in data. */
+ git_otype type; /**< Type of this object. */
} git_rawobj;
/* EXPORT */
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 6ecd9a4ca..59703ce95 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -18,9 +18,9 @@
#include "git2/odb_backend.h"
#include "git2/types.h"
-typedef struct { /* object header data */
- git_otype type; /* object type */
- size_t size; /* object size */
+typedef struct { /* object header data */
+ git_otype type; /* object type */
+ size_t size; /* object size */
} obj_hdr;
typedef struct {
@@ -124,7 +124,7 @@ static size_t get_object_header(obj_hdr *hdr, unsigned char *data)
if (used == 0)
return 0;
hdr->type = git_object_string2type(typename);
- used++; /* consume the space */
+ used++; /* consume the space */
/*
* length follows immediately in decimal (without
@@ -164,19 +164,19 @@ static size_t get_object_header(obj_hdr *hdr, unsigned char *data)
static void init_stream(z_stream *s, void *out, size_t len)
{
memset(s, 0, sizeof(*s));
- s->next_out = out;
+ s->next_out = out;
s->avail_out = (uInt)len;
}
static void set_stream_input(z_stream *s, void *in, size_t len)
{
- s->next_in = in;
+ s->next_in = in;
s->avail_in = (uInt)len;
}
static void set_stream_output(z_stream *s, void *out, size_t len)
{
- s->next_out = out;
+ s->next_out = out;
s->avail_out = (uInt)len;
}
@@ -224,10 +224,10 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
memset(&zs, 0x0, sizeof(zs));
- zs.next_out = out;
+ zs.next_out = out;
zs.avail_out = (uInt)outlen;
- zs.next_in = in;
+ zs.next_in = in;
zs.avail_in = (uInt)inlen;
if (inflateInit(&zs) < Z_OK)
@@ -314,7 +314,7 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
if (!buf)
return GIT_ENOMEM;
- in = ((unsigned char *)obj->data) + used;
+ in = ((unsigned char *)obj->data) + used;
len = obj->len - used;
if (inflate_buffer(in, len, buf, hdr.size)) {
free(buf);
@@ -323,7 +323,7 @@ static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_fbuffer *obj)
buf[hdr.size] = '\0';
out->data = buf;
- out->len = hdr.size;
+ out->len = hdr.size;
out->type = hdr.type;
return GIT_SUCCESS;
@@ -364,7 +364,7 @@ static int inflate_disk_obj(git_rawobj *out, git_fbuffer *obj)
buf[hdr.size] = '\0';
out->data = buf;
- out->len = hdr.size;
+ out->len = hdr.size;
out->type = hdr.type;
return GIT_SUCCESS;
@@ -392,7 +392,7 @@ static int read_loose(git_rawobj *out, const char *loc)
assert(out && loc);
out->data = NULL;
- out->len = 0;
+ out->len = 0;
out->type = GIT_OBJ_BAD;
if (git_futils_readbuffer(&obj, loc) < 0)
@@ -443,7 +443,7 @@ static int read_header_loose(git_rawobj *out, const char *loc)
goto cleanup;
}
- out->len = header_obj.size;
+ out->len = header_obj.size;
out->type = header_obj.type;
cleanup:
@@ -694,8 +694,8 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o
const char *type_str = git_object_type2string(obj_type);
int len = snprintf(hdr, n, "%s %"PRIuZ, type_str, obj_len);
- assert(len > 0); /* otherwise snprintf() is broken */
- assert(((size_t) len) < n); /* otherwise the caller is broken! */
+ assert(len > 0); /* otherwise snprintf() is broken */
+ assert(((size_t) len) < n); /* otherwise the caller is broken! */
if (len < 0 || ((size_t) len) >= n)
return git__throw(GIT_ERROR, "Failed to format object header. Length is out of bounds");
@@ -708,7 +708,7 @@ int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend
loose_writestream *stream;
char hdr[64], tmp_path[GIT_PATH_MAX];
- int hdrlen;
+ int hdrlen;
int error;
assert(_backend);
diff --git a/src/odb_pack.c b/src/odb_pack.c
index 4a171f977..1867ada96 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -30,9 +30,9 @@ struct pack_backend {
/**
* The wonderful tale of a Packed Object lookup query
* ===================================================
- * A riveting and epic story of epicness and ASCII
- * art, presented by yours truly,
- * Sir Vicent of Marti
+ * A riveting and epic story of epicness and ASCII
+ * art, presented by yours truly,
+ * Sir Vicent of Marti
*
*
* Chapter 1: Once upon a time...
@@ -43,32 +43,32 @@ struct pack_backend {
* | Creates the pack backend structure, initializes the
* | callback pointers to our default read() and exist() methods,
* | and tries to preload all the known packfiles in the ODB.
- * |
+ * |
* |-# packfile_load_all
- * | Tries to find the `pack` folder, if it exists. ODBs without
- * | a pack folder are ignored altogether. If there's a `pack` folder
- * | we run a `dirent` callback through every file in the pack folder
- * | to find our packfiles. The packfiles are then sorted according
- * | to a sorting callback.
- * |
- * |-# packfile_load__cb
- * | | This callback is called from `dirent` with every single file
- * | | inside the pack folder. We find the packs by actually locating
- * | | their index (ends in ".idx"). From that index, we verify that
- * | | the corresponding packfile exists and is valid, and if so, we
- * | | add it to the pack list.
- * | |
- * | |-# packfile_check
- * | Make sure that there's a packfile to back this index, and store
- * | some very basic information regarding the packfile itself,
- * | such as the full path, the size, and the modification time.
- * | We don't actually open the packfile to check for internal consistency.
- * |
- * |-# packfile_sort__cb
- * Sort all the preloaded packs according to some specific criteria:
- * we prioritize the "newer" packs because it's more likely they
- * contain the objects we are looking for, and we prioritize local
- * packs over remote ones.
+ * | Tries to find the `pack` folder, if it exists. ODBs without
+ * | a pack folder are ignored altogether. If there's a `pack` folder
+ * | we run a `dirent` callback through every file in the pack folder
+ * | to find our packfiles. The packfiles are then sorted according
+ * | to a sorting callback.
+ * |
+ * |-# packfile_load__cb
+ * | | This callback is called from `dirent` with every single file
+ * | | inside the pack folder. We find the packs by actually locating
+ * | | their index (ends in ".idx"). From that index, we verify that
+ * | | the corresponding packfile exists and is valid, and if so, we
+ * | | add it to the pack list.
+ * | |
+ * | |-# packfile_check
+ * | Make sure that there's a packfile to back this index, and store
+ * | some very basic information regarding the packfile itself,
+ * | such as the full path, the size, and the modification time.
+ * | We don't actually open the packfile to check for internal consistency.
+ * |
+ * |-# packfile_sort__cb
+ * Sort all the preloaded packs according to some specific criteria:
+ * we prioritize the "newer" packs because it's more likely they
+ * contain the objects we are looking for, and we prioritize local
+ * packs over remote ones.
*
*
*
@@ -76,41 +76,41 @@ struct pack_backend {
* A standard packed `exist` query for an OID
* --------------------------------------------------
*
- * # pack_backend__exists
- * | Check if the given SHA1 oid exists in any of the packs
- * | that have been loaded for our ODB.
- * |
- * |-# pack_entry_find
- * | Iterate through all the packs that have been preloaded
- * | (starting by the pack where the latest object was found)
- * | to try to find the OID in one of them.
- * |
- * |-# pack_entry_find1
- * | Check the index of an individual pack to see if the SHA1
- * | OID can be found. If we can find the offset to that SHA1
- * | inside of the index, that means the object is contained
- * | inside of the packfile and we can stop searching.
- * | Before returning, we verify that the packfile behing the
- * | index we are searching still exists on disk.
- * |
- * |-# pack_entry_find_offset
- * | | Mmap the actual index file to disk if it hasn't been opened
- * | | yet, and run a binary search through it to find the OID.
- * | | See <http://book.git-scm.com/7_the_packfile.html> for specifics
- * | | on the Packfile Index format and how do we find entries in it.
- * | |
- * | |-# pack_index_open
- * | | Guess the name of the index based on the full path to the
- * | | packfile, open it and verify its contents. Only if the index
- * | | has not been opened already.
- * | |
- * | |-# pack_index_check
- * | Mmap the index file and do a quick run through the header
- * | to guess the index version (right now we support v1 and v2),
- * | and to verify that the size of the index makes sense.
- * |
- * |-# packfile_open
- * See `packfile_open` in Chapter 3
+ * # pack_backend__exists
+ * | Check if the given SHA1 oid exists in any of the packs
+ * | that have been loaded for our ODB.
+ * |
+ * |-# pack_entry_find
+ * | Iterate through all the packs that have been preloaded
+ * | (starting by the pack where the latest object was found)
+ * | to try to find the OID in one of them.
+ * |
+ * |-# pack_entry_find1
+ * | Check the index of an individual pack to see if the SHA1
+ * | OID can be found. If we can find the offset to that SHA1
+ * | inside of the index, that means the object is contained
+ * | inside of the packfile and we can stop searching.
+ * | Before returning, we verify that the packfile behing the
+ * | index we are searching still exists on disk.
+ * |
+ * |-# pack_entry_find_offset
+ * | | Mmap the actual index file to disk if it hasn't been opened
+ * | | yet, and run a binary search through it to find the OID.
+ * | | See <http://book.git-scm.com/7_the_packfile.html> for specifics
+ * | | on the Packfile Index format and how do we find entries in it.
+ * | |
+ * | |-# pack_index_open
+ * | | Guess the name of the index based on the full path to the
+ * | | packfile, open it and verify its contents. Only if the index
+ * | | has not been opened already.
+ * | |
+ * | |-# pack_index_check
+ * | Mmap the index file and do a quick run through the header
+ * | to guess the index version (right now we support v1 and v2),
+ * | and to verify that the size of the index makes sense.
+ * |
+ * |-# packfile_open
+ * See `packfile_open` in Chapter 3
*
*
*
@@ -170,7 +170,7 @@ GIT_INLINE(int) pack_window_contains(git_mwindow *win, off_t offset)
/* We must promise at least 20 bytes (one hash) after the
* offset is available from this window, otherwise the offset
* is not actually in this window and a different window (which
- * has that one hash excess) must be used. This is to support
+ * has that one hash excess) must be used. This is to support
* the object header and delta base parsing routines below.
*/
return git_mwindow_contains(win, offset + 20);
@@ -184,7 +184,7 @@ static int packfile_sort__cb(const void *a_, const void *b_)
/*
* Local packs tend to contain objects specific to our
- * variant of the project than remote ones. In addition,
+ * variant of the project than remote ones. In addition,
* remote ones could be on a network mounted filesystem.
* Favor local ones for these reasons.
*/
diff --git a/src/oid.c b/src/oid.c
index 794f5e224..e2d16d537 100644
--- a/src/oid.c
+++ b/src/oid.c
@@ -15,7 +15,7 @@ static signed char from_hex[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 20 */
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 30 */
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 30 */
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 40 */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 50 */
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 60 */
@@ -43,7 +43,7 @@ int git_oid_fromstrn(git_oid *out, const char *str, size_t length)
for (p = 0; p < length; p += 2) {
int v = (from_hex[(unsigned char)str[p + 0]] << 4)
- | from_hex[(unsigned char)str[p + 1]];
+ | from_hex[(unsigned char)str[p + 1]];
if (v < 0)
return git__throw(GIT_ENOTOID, "Failed to generate sha1. Given string is not a valid sha1 hash");
@@ -104,7 +104,7 @@ char *git_oid_to_string(char *out, size_t n, const git_oid *oid)
if (!out || n == 0 || !oid)
return "";
- n--; /* allow room for terminating NUL */
+ n--; /* allow room for terminating NUL */
if (n > 0) {
git_oid_fmt(str, oid);
diff --git a/src/pack.c b/src/pack.c
index 130ee49e2..8de2d7814 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -52,7 +52,7 @@ static void pack_index_free(struct git_pack_file *p)
}
}
-static int pack_index_check(const char *path, struct git_pack_file *p)
+static int pack_index_check(const char *path, struct git_pack_file *p)
{
struct git_pack_idx_header *hdr;
uint32_t version, nr, i, *index;
@@ -108,7 +108,7 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
index = idx_map;
if (version > 1)
- index += 2; /* skip index header */
+ index += 2; /* skip index header */
for (i = 0; i < 256; i++) {
uint32_t n = ntohl(index[i]);
@@ -122,10 +122,10 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
if (version == 1) {
/*
* Total size:
- * - 256 index entries 4 bytes each
- * - 24-byte entries * nr (20-byte sha1 + 4-byte offset)
- * - 20-byte SHA1 of the packfile
- * - 20-byte SHA1 file checksum
+ * - 256 index entries 4 bytes each
+ * - 24-byte entries * nr (20-byte sha1 + 4-byte offset)
+ * - 20-byte SHA1 of the packfile
+ * - 20-byte SHA1 file checksum
*/
if (idx_size != 4*256 + nr * 24 + 20 + 20) {
git_futils_mmap_free(&p->index_map);
@@ -134,13 +134,13 @@ static int pack_index_check(const char *path, struct git_pack_file *p)
} else if (version == 2) {
/*
* Minimum size:
- * - 8 bytes of header
- * - 256 index entries 4 bytes each
- * - 20-byte sha1 entry * nr
- * - 4-byte crc entry * nr
- * - 4-byte offset entry * nr
- * - 20-byte SHA1 of the packfile
- * - 20-byte SHA1 file checksum
+ * - 8 bytes of header
+ * - 256 index entries 4 bytes each
+ * - 20-byte sha1 entry * nr
+ * - 4-byte crc entry * nr
+ * - 4-byte offset entry * nr
+ * - 20-byte SHA1 of the packfile
+ * - 20-byte SHA1 file checksum
* And after the 4-byte offset table might be a
* variable sized table containing 8-byte entries
* for offsets larger than 2^31.
@@ -245,8 +245,8 @@ int git_packfile_unpack_header(
unsigned long used;
/* pack_window_open() assures us we have [base, base + 20) available
- * as a range that we can look at at. (Its actually the hash
- * size that is assured.) With our object header encoding
+ * as a range that we can look at at. (Its actually the hash
+ * size that is assured.) With our object header encoding
* the maximum deflated object size is 2^137, which is just
* insane, so we know won't exceed what we have been given.
*/
@@ -435,8 +435,8 @@ off_t get_delta_base(
/* pack_window_open() assured us we have [base_info, base_info + 20)
* as a range that we can look at without walking off the
- * end of the mapped window. Its actually the hash size
- * that is assured. An OFS_DELTA longer than the hash size
+ * end of the mapped window. Its actually the hash size
+ * that is assured. An OFS_DELTA longer than the hash size
* is stupid, as then a REF_DELTA would be smaller to store.
*/
if (type == GIT_OBJ_OFS_DELTA) {
@@ -446,13 +446,13 @@ off_t get_delta_base(
while (c & 128) {
base_offset += 1;
if (!base_offset || MSB(base_offset, 7))
- return 0; /* overflow */
+ return 0; /* overflow */
c = base_info[used++];
base_offset = (base_offset << 7) + (c & 127);
}
base_offset = delta_obj_offset - base_offset;
if (base_offset <= 0 || base_offset >= delta_obj_offset)
- return 0; /* out of bound */
+ return 0; /* out of bound */
*curpos += used;
} else if (type == GIT_OBJ_REF_DELTA) {
/* If we have the cooperative cache, search in it first */
@@ -650,7 +650,7 @@ static off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n)
return off;
index += p->num_objects * 4 + (off & 0x7fffffff) * 8;
return (((uint64_t)ntohl(*((uint32_t *)(index + 0)))) << 32) |
- ntohl(*((uint32_t *)(index + 4)));
+ ntohl(*((uint32_t *)(index + 4)));
}
}
@@ -703,7 +703,7 @@ static int pack_entry_find_offset(
#endif
/* Use git.git lookup code */
- pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id);
+ pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id);
if (pos >= 0) {
/* An object matching exactly the oid was found */
diff --git a/src/pack.h b/src/pack.h
index ca3587854..0fddd9dc8 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -38,7 +38,7 @@ struct git_pack_header {
* Very old git binaries will also compare the first 4 bytes to the
* next 4 bytes in the index and abort with a "non-monotonic index"
* error if the second 4 byte word is smaller than the first 4
- * byte word. This would be true in the proposed future index
+ * byte word. This would be true in the proposed future index
* format as idx_signature would be greater than idx_version.
*/
diff --git a/src/path.c b/src/path.c
index ce4203ff3..2c6b76dd0 100644
--- a/src/path.c
+++ b/src/path.c
@@ -23,8 +23,8 @@ int git_path_basename_r(char *buffer, size_t bufflen, const char *path)
/* Empty or NULL string gets treated as "." */
if (path == NULL || *path == '\0') {
- startp = ".";
- len = 1;
+ startp = ".";
+ len = 1;
goto Exit;
}
@@ -36,7 +36,7 @@ int git_path_basename_r(char *buffer, size_t bufflen, const char *path)
/* All slashes becomes "/" */
if (endp == path && *endp == '/') {
startp = "/";
- len = 1;
+ len = 1;
goto Exit;
}
@@ -53,7 +53,7 @@ Exit:
return result;
}
if (len > (int)bufflen-1) {
- len = (int)bufflen-1;
+ len = (int)bufflen-1;
result = GIT_ENOMEM;
}
@@ -70,103 +70,103 @@ Exit:
*/
int git_path_dirname_r(char *buffer, size_t bufflen, const char *path)
{
- const char *endp;
- int result, len;
-
- /* Empty or NULL string gets treated as "." */
- if (path == NULL || *path == '\0') {
- path = ".";
- len = 1;
- goto Exit;
- }
-
- /* Strip trailing slashes */
- endp = path + strlen(path) - 1;
- while (endp > path && *endp == '/')
- endp--;
-
- /* Find the start of the dir */
- while (endp > path && *endp != '/')
- endp--;
-
- /* Either the dir is "/" or there are no slashes */
- if (endp == path) {
- path = (*endp == '/') ? "/" : ".";
- len = 1;
- goto Exit;
- }
-
- do {
- endp--;
- } while (endp > path && *endp == '/');
-
- len = endp - path +1;
+ const char *endp;
+ int result, len;
+
+ /* Empty or NULL string gets treated as "." */
+ if (path == NULL || *path == '\0') {
+ path = ".";
+ len = 1;
+ goto Exit;
+ }
+
+ /* Strip trailing slashes */
+ endp = path + strlen(path) - 1;
+ while (endp > path && *endp == '/')
+ endp--;
+
+ /* Find the start of the dir */
+ while (endp > path && *endp != '/')
+ endp--;
+
+ /* Either the dir is "/" or there are no slashes */
+ if (endp == path) {
+ path = (*endp == '/') ? "/" : ".";
+ len = 1;
+ goto Exit;
+ }
+
+ do {
+ endp--;
+ } while (endp > path && *endp == '/');
+
+ len = endp - path +1;
#ifdef GIT_WIN32
- /* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return
- 'C:/' here */
+ /* Mimic unix behavior where '/.git' returns '/': 'C:/.git' will return
+ 'C:/' here */
- if (len == 2 && isalpha(path[0]) && path[1] == ':') {
- len = 3;
- goto Exit;
- }
+ if (len == 2 && isalpha(path[0]) && path[1] == ':') {
+ len = 3;
+ goto Exit;
+ }
#endif
Exit:
- result = len;
- if (len+1 > GIT_PATH_MAX) {
- return GIT_ENOMEM;
- }
- if (buffer == NULL)
- return result;
-
- if (len > (int)bufflen-1) {
- len = (int)bufflen-1;
- result = GIT_ENOMEM;
- }
-
- if (len >= 0) {
- memmove(buffer, path, len);
- buffer[len] = 0;
- }
- return result;
+ result = len;
+ if (len+1 > GIT_PATH_MAX) {
+ return GIT_ENOMEM;
+ }
+ if (buffer == NULL)
+ return result;
+
+ if (len > (int)bufflen-1) {
+ len = (int)bufflen-1;
+ result = GIT_ENOMEM;
+ }
+
+ if (len >= 0) {
+ memmove(buffer, path, len);
+ buffer[len] = 0;
+ }
+ return result;
}
char *git_path_dirname(const char *path)
{
- char *dname = NULL;
- int len;
+ char *dname = NULL;
+ int len;
len = (path ? strlen(path) : 0) + 2;
dname = (char *)git__malloc(len);
if (dname == NULL)
return NULL;
- if (git_path_dirname_r(dname, len, path) < GIT_SUCCESS) {
+ if (git_path_dirname_r(dname, len, path) < GIT_SUCCESS) {
free(dname);
return NULL;
}
- return dname;
+ return dname;
}
char *git_path_basename(const char *path)
{
- char *bname = NULL;
- int len;
+ char *bname = NULL;
+ int len;
len = (path ? strlen(path) : 0) + 2;
bname = (char *)git__malloc(len);
if (bname == NULL)
return NULL;
- if (git_path_basename_r(bname, len, path) < GIT_SUCCESS) {
+ if (git_path_basename_r(bname, len, path) < GIT_SUCCESS) {
free(bname);
return NULL;
}
- return bname;
+ return bname;
}
diff --git a/src/pkt.c b/src/pkt.c
index 97e922466..e0beb72e0 100644
--- a/src/pkt.c
+++ b/src/pkt.c
@@ -163,11 +163,11 @@ static ssize_t parse_len(const char *line)
/*
* As per the documentation, the syntax is:
*
- * pkt-line = data-pkt / flush-pkt
- * data-pkt = pkt-len pkt-payload
- * pkt-len = 4*(HEXDIG)
+ * pkt-line = data-pkt / flush-pkt
+ * data-pkt = pkt-len pkt-payload
+ * pkt-len = 4*(HEXDIG)
* pkt-payload = (pkt-len -4)*(OCTET)
- * flush-pkt = "0000"
+ * flush-pkt = "0000"
*
* Which means that the first four bytes are the length of the line,
* in ASCII hexadecimal (including itself)
diff --git a/src/ppc/sha1.c b/src/ppc/sha1.c
index 947000f04..a34bf2557 100644
--- a/src/ppc/sha1.c
+++ b/src/ppc/sha1.c
@@ -9,7 +9,7 @@
#include "sha1.h"
extern void ppc_sha1_core(uint32_t *hash, const unsigned char *p,
- unsigned int nblocks);
+ unsigned int nblocks);
int ppc_SHA1_Init(ppc_SHA_CTX *c)
{
diff --git a/src/pqueue.c b/src/pqueue.c
index a244ed739..b5ddab835 100644
--- a/src/pqueue.c
+++ b/src/pqueue.c
@@ -8,29 +8,29 @@
#include "common.h"
#include "pqueue.h"
-#define left(i) ((i) << 1)
-#define right(i) (((i) << 1) + 1)
+#define left(i) ((i) << 1)
+#define right(i) (((i) << 1) + 1)
#define parent(i) ((i) >> 1)
int git_pqueue_init(git_pqueue *q, size_t n, git_pqueue_cmp cmppri)
{
assert(q);
- /* Need to allocate n+1 elements since element 0 isn't used. */
- if ((q->d = malloc((n + 1) * sizeof(void *))) == NULL)
+ /* Need to allocate n+1 elements since element 0 isn't used. */
+ if ((q->d = malloc((n + 1) * sizeof(void *))) == NULL)
return GIT_ENOMEM;
- q->size = 1;
- q->avail = q->step = (n + 1); /* see comment above about n+1 */
- q->cmppri = cmppri;
+ q->size = 1;
+ q->avail = q->step = (n + 1); /* see comment above about n+1 */
+ q->cmppri = cmppri;
- return GIT_SUCCESS;
+ return GIT_SUCCESS;
}
void git_pqueue_free(git_pqueue *q)
{
- free(q->d);
+ free(q->d);
q->d = NULL;
}
@@ -41,101 +41,101 @@ void git_pqueue_clear(git_pqueue *q)
size_t git_pqueue_size(git_pqueue *q)
{
- /* queue element 0 exists but doesn't count since it isn't used. */
- return (q->size - 1);
+ /* queue element 0 exists but doesn't count since it isn't used. */
+ return (q->size - 1);
}
static void bubble_up(git_pqueue *q, size_t i)
{
- size_t parent_node;
- void *moving_node = q->d[i];
+ size_t parent_node;
+ void *moving_node = q->d[i];
- for (parent_node = parent(i);
- ((i > 1) && q->cmppri(q->d[parent_node], moving_node));
- i = parent_node, parent_node = parent(i)) {
- q->d[i] = q->d[parent_node];
- }
+ for (parent_node = parent(i);
+ ((i > 1) && q->cmppri(q->d[parent_node], moving_node));
+ i = parent_node, parent_node = parent(i)) {
+ q->d[i] = q->d[parent_node];
+ }
- q->d[i] = moving_node;
+ q->d[i] = moving_node;
}
static size_t maxchild(git_pqueue *q, size_t i)
{
- size_t child_node = left(i);
+ size_t child_node = left(i);
- if (child_node >= q->size)
- return 0;
+ if (child_node >= q->size)
+ return 0;
- if ((child_node + 1) < q->size &&
- q->cmppri(q->d[child_node], q->d[child_node + 1]))
- child_node++; /* use right child instead of left */
+ if ((child_node + 1) < q->size &&
+ q->cmppri(q->d[child_node], q->d[child_node + 1]))
+ child_node++; /* use right child instead of left */
- return child_node;
+ return child_node;
}
static void percolate_down(git_pqueue *q, size_t i)
{
- size_t child_node;
- void *moving_node = q->d[i];
+ size_t child_node;
+ void *moving_node = q->d[i];
- while ((child_node = maxchild(q, i)) != 0 &&
- q->cmppri(moving_node, q->d[child_node])) {
- q->d[i] = q->d[child_node];
- i = child_node;
- }
+ while ((child_node = maxchild(q, i)) != 0 &&
+ q->cmppri(moving_node, q->d[child_node])) {
+ q->d[i] = q->d[child_node];
+ i = child_node;
+ }
- q->d[i] = moving_node;
+ q->d[i] = moving_node;
}
int git_pqueue_insert(git_pqueue *q, void *d)
{
- void *tmp;
- size_t i;
- size_t newsize;
+ void *tmp;
+ size_t i;
+ size_t newsize;
- if (!q) return 1;
+ if (!q) return 1;
- /* allocate more memory if necessary */
- if (q->size >= q->avail) {
- newsize = q->size + q->step;
- if ((tmp = realloc(q->d, sizeof(void *) * newsize)) == NULL)
- return GIT_ENOMEM;
+ /* allocate more memory if necessary */
+ if (q->size >= q->avail) {
+ newsize = q->size + q->step;
+ if ((tmp = realloc(q->d, sizeof(void *) * newsize)) == NULL)
+ return GIT_ENOMEM;
- q->d = tmp;
- q->avail = newsize;
- }
+ q->d = tmp;
+ q->avail = newsize;
+ }
- /* insert item */
- i = q->size++;
- q->d[i] = d;
- bubble_up(q, i);
+ /* insert item */
+ i = q->size++;
+ q->d[i] = d;
+ bubble_up(q, i);
- return GIT_SUCCESS;
+ return GIT_SUCCESS;
}
void *git_pqueue_pop(git_pqueue *q)
{
- void *head;
+ void *head;
- if (!q || q->size == 1)
- return NULL;
+ if (!q || q->size == 1)
+ return NULL;
- head = q->d[1];
- q->d[1] = q->d[--q->size];
- percolate_down(q, 1);
+ head = q->d[1];
+ q->d[1] = q->d[--q->size];
+ percolate_down(q, 1);
- return head;
+ return head;
}
void *git_pqueue_peek(git_pqueue *q)
{
- if (!q || q->size == 1)
- return NULL;
- return q->d[1];
+ if (!q || q->size == 1)
+ return NULL;
+ return q->d[1];
}
diff --git a/src/pqueue.h b/src/pqueue.h
index e9ac4b7d1..6826055e5 100644
--- a/src/pqueue.h
+++ b/src/pqueue.h
@@ -13,9 +13,9 @@ typedef int (*git_pqueue_cmp)(void *a, void *b);
/** the priority queue handle */
typedef struct {
- size_t size, avail, step;
- git_pqueue_cmp cmppri;
- void **d;
+ size_t size, avail, step;
+ git_pqueue_cmp cmppri;
+ void **d;
} git_pqueue;
@@ -23,7 +23,7 @@ typedef struct {
* initialize the queue
*
* @param n the initial estimate of the number of queue items for which memory
- * should be preallocated
+ * should be preallocated
* @param cmppri the callback function to compare two nodes of the queue
*
* @Return the handle or NULL for insufficent memory
diff --git a/src/reflog.c b/src/reflog.c
index e4ced352d..594963c03 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -205,7 +205,7 @@ int git_reflog_read(git_reflog **reflog, git_reference *ref)
}
int git_reflog_write(git_reference *ref, const git_oid *oid_old,
- const git_signature *committer, const char *msg)
+ const git_signature *committer, const char *msg)
{
int error;
char old[GIT_OID_HEXSZ+1];
diff --git a/src/refs.c b/src/refs.c
index 868fe21bd..7cfbe557f 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -494,7 +494,7 @@ static int packed_load(git_repository *repo)
}
error = reference_read(&packfile, &ref_cache->packfile_time,
- repo->path_repository, GIT_PACKEDREFS_FILE, &updated);
+ repo->path_repository, GIT_PACKEDREFS_FILE, &updated);
/*
* If we couldn't find the file, we need to clear the table and
@@ -827,7 +827,7 @@ static int packed_write(git_repository *repo)
const void *GIT_UNUSED(_unused);
GIT_HASHTABLE_FOREACH(repo->references.packfile, _unused, reference,
- git_vector_insert(&packing_list, reference); /* cannot fail: vector already has the right size */
+ git_vector_insert(&packing_list, reference); /* cannot fail: vector already has the right size */
);
}
@@ -905,7 +905,7 @@ static int _reference_available_cb(const char *ref, void *data)
const char *lead = reflen < newlen ? new : ref;
if (!strncmp(new, ref, cmplen) &&
- lead[cmplen] == '/')
+ lead[cmplen] == '/')
return GIT_EEXISTS;
}
@@ -1054,7 +1054,7 @@ int git_reference_create_symbolic(git_reference **ref_out, git_repository *repo,
* need a new reference because we can't make a symbolic ref out
* of an oid one.
* If if didn't exist, then we need to create a new one anyway.
- */
+ */
if (ref && ref->type & GIT_REF_SYMBOLIC){
updated = 1;
} else {
@@ -1113,7 +1113,7 @@ int git_reference_create_oid(git_reference **ref_out, git_repository *repo, cons
* need a new reference because we can't make a symbolic ref out
* of an oid one.
* If if didn't exist, then we need to create a new one anyway.
- */
+ */
if (ref && ref-> type & GIT_REF_OID){
updated = 1;
} else {
@@ -1344,10 +1344,10 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
* writes reflogs by default in any repo with a working directory:
*
* "We only enable reflogs in repositories that have a working directory
- * associated with them, as shared/bare repositories do not have
- * an easy means to prune away old log entries, or may fail logging
- * entirely if the user's gecos information is not valid during a push.
- * This heuristic was suggested on the mailing list by Junio."
+ * associated with them, as shared/bare repositories do not have
+ * an easy means to prune away old log entries, or may fail logging
+ * entirely if the user's gecos information is not valid during a push.
+ * This heuristic was suggested on the mailing list by Junio."
*
* Shawn O. Pearce - 0bee59186976b1d9e6b2dd77332480c9480131d5
*
diff --git a/src/refspec.c b/src/refspec.c
index b79733ad2..9de273071 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -55,7 +55,7 @@ int git_refspec_src_match(const git_refspec *refspec, const char *refname)
return git__fnmatch(refspec->src, refname, 0);
}
-int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name)
+int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, const char *name)
{
size_t baselen, namelen;
diff --git a/src/remote.c b/src/remote.c
index 027894d45..74a238d95 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -110,7 +110,7 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
error = git_config_get_string(cfg, buf, &val);
if (error < GIT_SUCCESS) {
- error = git__rethrow(error, "Remote's url doesn't exist");
+ error = git__rethrow(error, "Remote's url doesn't exist");
goto cleanup;
}
diff --git a/src/sha1.c b/src/sha1.c
index 2d7d10ab1..4043fb168 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -52,11 +52,11 @@
*/
#if defined(__i386__) || defined(__x86_64__)
- #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
+ #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val))
#elif defined(__GNUC__) && defined(__arm__)
- #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
+ #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0)
#else
- #define setW(x, val) (W(x) = (val))
+ #define setW(x, val) (W(x) = (val))
#endif
/*
@@ -67,10 +67,10 @@
*/
#if defined(__i386__) || defined(__x86_64__) || \
- defined(_M_IX86) || defined(_M_X64) || \
- defined(__ppc__) || defined(__ppc64__) || \
- defined(__powerpc__) || defined(__powerpc64__) || \
- defined(__s390__) || defined(__s390x__)
+ defined(_M_IX86) || defined(_M_X64) || \
+ defined(__ppc__) || defined(__ppc64__) || \
+ defined(__powerpc__) || defined(__powerpc64__) || \
+ defined(__s390__) || defined(__s390x__)
#define get_be32(p) ntohl(*(const unsigned int *)(p))
#define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0)
@@ -80,14 +80,14 @@
#define get_be32(p) ( \
(*((const unsigned char *)(p) + 0) << 24) | \
(*((const unsigned char *)(p) + 1) << 16) | \
- (*((const unsigned char *)(p) + 2) << 8) | \
- (*((const unsigned char *)(p) + 3) << 0) )
+ (*((const unsigned char *)(p) + 2) << 8) | \
+ (*((const unsigned char *)(p) + 3) << 0) )
#define put_be32(p, v) do { \
unsigned int __v = (v); \
*((unsigned char *)(p) + 0) = __v >> 24; \
*((unsigned char *)(p) + 1) = __v >> 16; \
- *((unsigned char *)(p) + 2) = __v >> 8; \
- *((unsigned char *)(p) + 3) = __v >> 0; } while (0)
+ *((unsigned char *)(p) + 2) = __v >> 8; \
+ *((unsigned char *)(p) + 3) = __v >> 0; } while (0)
#endif
@@ -106,11 +106,11 @@
E += TEMP + SHA_ROL(A,5) + (fn) + (constant); \
B = SHA_ROR(B, 2); } while (0)
-#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
+#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
#define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E )
#define T_20_39(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E )
#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E )
-#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
+#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E )
static void blk_SHA1_Block(blk_SHA_CTX *ctx, const unsigned int *data)
{
diff --git a/src/sha1_lookup.c b/src/sha1_lookup.c
index f63f78524..3051568a3 100644
--- a/src/sha1_lookup.c
+++ b/src/sha1_lookup.c
@@ -14,69 +14,69 @@
* Conventional binary search loop looks like this:
*
* unsigned lo, hi;
- * do {
- * unsigned mi = (lo + hi) / 2;
- * int cmp = "entry pointed at by mi" minus "target";
- * if (!cmp)
- * return (mi is the wanted one)
- * if (cmp > 0)
- * hi = mi; "mi is larger than target"
- * else
- * lo = mi+1; "mi is smaller than target"
- * } while (lo < hi);
+ * do {
+ * unsigned mi = (lo + hi) / 2;
+ * int cmp = "entry pointed at by mi" minus "target";
+ * if (!cmp)
+ * return (mi is the wanted one)
+ * if (cmp > 0)
+ * hi = mi; "mi is larger than target"
+ * else
+ * lo = mi+1; "mi is smaller than target"
+ * } while (lo < hi);
*
* The invariants are:
*
* - When entering the loop, lo points at a slot that is never
- * above the target (it could be at the target), hi points at a
- * slot that is guaranteed to be above the target (it can never
- * be at the target).
+ * above the target (it could be at the target), hi points at a
+ * slot that is guaranteed to be above the target (it can never
+ * be at the target).
*
* - We find a point 'mi' between lo and hi (mi could be the same
- * as lo, but never can be as same as hi), and check if it hits
- * the target. There are three cases:
+ * as lo, but never can be as same as hi), and check if it hits
+ * the target. There are three cases:
*
- * - if it is a hit, we are happy.
+ * - if it is a hit, we are happy.
*
- * - if it is strictly higher than the target, we set it to hi,
- * and repeat the search.
+ * - if it is strictly higher than the target, we set it to hi,
+ * and repeat the search.
*
- * - if it is strictly lower than the target, we update lo to
- * one slot after it, because we allow lo to be at the target.
+ * - if it is strictly lower than the target, we update lo to
+ * one slot after it, because we allow lo to be at the target.
*
- * If the loop exits, there is no matching entry.
+ * If the loop exits, there is no matching entry.
*
* When choosing 'mi', we do not have to take the "middle" but
* anywhere in between lo and hi, as long as lo <= mi < hi is
- * satisfied. When we somehow know that the distance between the
+ * satisfied. When we somehow know that the distance between the
* target and lo is much shorter than the target and hi, we could
* pick mi that is much closer to lo than the midway.
*
* Now, we can take advantage of the fact that SHA-1 is a good hash
* function, and as long as there are enough entries in the table, we
- * can expect uniform distribution. An entry that begins with for
+ * can expect uniform distribution. An entry that begins with for
* example "deadbeef..." is much likely to appear much later than in
- * the midway of the table. It can reasonably be expected to be near
+ * the midway of the table. It can reasonably be expected to be near
* 87% (222/256) from the top of the table.
*
- * However, we do not want to pick "mi" too precisely. If the entry at
+ * However, we do not want to pick "mi" too precisely. If the entry at
* the 87% in the above example turns out to be higher than the target
* we are looking for, we would end up narrowing the search space down
* only by 13%, instead of 50% we would get if we did a simple binary
- * search. So we would want to hedge our bets by being less aggressive.
+ * search. So we would want to hedge our bets by being less aggressive.
*
* The table at "table" holds at least "nr" entries of "elem_size"
- * bytes each. Each entry has the SHA-1 key at "key_offset". The
- * table is sorted by the SHA-1 key of the entries. The caller wants
+ * bytes each. Each entry has the SHA-1 key at "key_offset". The
+ * table is sorted by the SHA-1 key of the entries. The caller wants
* to find the entry with "key", and knows that the entry at "lo" is
* not higher than the entry it is looking for, and that the entry at
* "hi" is higher than the entry it is looking for.
*/
int sha1_entry_pos(const void *table,
- size_t elem_size,
- size_t key_offset,
- unsigned lo, unsigned hi, unsigned nr,
- const unsigned char *key)
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key)
{
const unsigned char *base = (const unsigned char*)table;
const unsigned char *hi_key, *lo_key;
@@ -138,7 +138,7 @@ int sha1_entry_pos(const void *table,
* end up narrowing the search space by a smaller
* amount (i.e. the distance between 'mi' and 'hi')
* than what we would have (i.e. about half of 'lo'
- * and 'hi'). Hedge our bets to pick 'mi' less
+ * and 'hi'). Hedge our bets to pick 'mi' less
* aggressively, i.e. make 'mi' a bit closer to the
* middle than we would otherwise pick.
*/
@@ -154,7 +154,7 @@ int sha1_entry_pos(const void *table,
#ifdef INDEX_DEBUG_LOOKUP
printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi);
printf("ofs %u lov %x, hiv %x, kyv %x\n",
- ofs_0, lov, hiv, kyv);
+ ofs_0, lov, hiv, kyv);
#endif
if (!(lo <= mi && mi < hi)) {
diff --git a/src/sha1_lookup.h b/src/sha1_lookup.h
index bf167b38c..52282e672 100644
--- a/src/sha1_lookup.h
+++ b/src/sha1_lookup.h
@@ -10,9 +10,9 @@
#include <stdlib.h>
int sha1_entry_pos(const void *table,
- size_t elem_size,
- size_t key_offset,
- unsigned lo, unsigned hi, unsigned nr,
- const unsigned char *key);
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key);
#endif
diff --git a/src/tag.c b/src/tag.c
index 7afc22ddc..fc9f8b5e4 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -227,7 +227,7 @@ static int git_tag_create__internal(
}
/** 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 (!allow_ref_overwrite) {
git_oid_cpy(oid, git_reference_oid(new_ref));
@@ -312,7 +312,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
}
/** 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 (!allow_ref_overwrite) {
git_oid_cpy(oid, git_reference_oid(new_ref));
@@ -366,8 +366,8 @@ int git_tag__parse(git_tag *tag, git_odb_object *obj)
}
typedef struct {
- git_vector *taglist;
- const char *pattern;
+ git_vector *taglist;
+ const char *pattern;
} tag_filter_data;
#define GIT_REFS_TAGS_DIR_LEN strlen(GIT_REFS_TAGS_DIR)
diff --git a/src/thread-utils.c b/src/thread-utils.c
index ff7a79586..f582f4311 100644
--- a/src/thread-utils.c
+++ b/src/thread-utils.c
@@ -8,10 +8,10 @@
#include "thread-utils.h"
#ifdef _WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
#elif defined(hpux) || defined(__hpux) || defined(_hpux)
-# include <sys/pstat.h>
+# include <sys/pstat.h>
#endif
/*
@@ -20,11 +20,11 @@
* with this disgusting nest of #ifdefs.
*/
#ifndef _SC_NPROCESSORS_ONLN
-# ifdef _SC_NPROC_ONLN
-# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
-# elif defined _SC_CRAY_NCPU
-# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
-# endif
+# ifdef _SC_NPROC_ONLN
+# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+# elif defined _SC_CRAY_NCPU
+# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
+# endif
#endif
int git_online_cpus(void)
diff --git a/src/thread-utils.h b/src/thread-utils.h
index f331de9eb..3361ed8bc 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -33,10 +33,10 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
/* Pthreads Mutex */
#define git_mutex pthread_mutex_t
-#define git_mutex_init(a) pthread_mutex_init(a, NULL)
-#define git_mutex_lock(a) pthread_mutex_lock(a)
+#define git_mutex_init(a) pthread_mutex_init(a, NULL)
+#define git_mutex_lock(a) pthread_mutex_lock(a)
#define git_mutex_unlock(a) pthread_mutex_unlock(a)
-#define git_mutex_free(a) pthread_mutex_destroy(a)
+#define git_mutex_free(a) pthread_mutex_destroy(a)
/* Pthreads condition vars -- disabled by now */
#define git_cond unsigned int //pthread_cond_t
diff --git a/src/transport.h b/src/transport.h
index ff0bb00fd..233cfb1db 100644
--- a/src/transport.h
+++ b/src/transport.h
@@ -15,7 +15,7 @@
typedef struct git_transport_caps {
int common:1,
- ofs_delta:1;
+ ofs_delta:1;
} git_transport_caps;
/*
diff --git a/src/transport_git.c b/src/transport_git.c
index 2d54b4278..ac268cd43 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -387,8 +387,8 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
error = gitno_recv(&buf);
if (error < GIT_SUCCESS) {
- error = git__rethrow(error, "Error receiving data");
- goto cleanup;
+ error = git__rethrow(error, "Error receiving data");
+ goto cleanup;
}
error = git_pkt_parse_line(&pkt, ptr, &line_end, buf.offset);
if (error == GIT_ESHORTBUFFER)
@@ -535,7 +535,7 @@ static int git_close(git_transport *transport)
int s = t->socket;
int error;
- /* Can't do anything if there's an error, so don't bother checking */
+ /* Can't do anything if there's an error, so don't bother checking */
git_pkt_send_flush(s);
error = close(s);
if (error < 0)
diff --git a/src/tsort.c b/src/tsort.c
index 6a517025d..5dd99cc6e 100644
--- a/src/tsort.c
+++ b/src/tsort.c
@@ -68,7 +68,7 @@ static int binsearch(void **dst, const void *x, size_t size, cmp_ptr_t cmp)
}
}
-/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */
+/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */
static void bisort(void **dst, size_t start, size_t size, cmp_ptr_t cmp)
{
size_t i;
@@ -207,7 +207,7 @@ static void merge(void **dst, const struct tsort_run *stack, int stack_curr, str
if (resize(store, MIN(A, B)) < 0)
return;
- storage = store->storage;
+ storage = store->storage;
/* left merge */
if (A < B) {
diff --git a/src/util.c b/src/util.c
index a178a5a4c..b46a2a15c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -214,7 +214,7 @@ void git__hexdump(const char *buffer, size_t len)
printf("%02X ", (unsigned char)*line & 0xFF);
for (j = 0; j < (LINE_WIDTH - last_line); ++j)
- printf(" ");
+ printf(" ");
printf("| ");
@@ -255,7 +255,7 @@ uint32_t git__hash(const void *key, int len, unsigned int seed)
case 3: h ^= data[2] << 16;
case 2: h ^= data[1] << 8;
case 1: h ^= data[0];
- h *= m;
+ h *= m;
};
h ^= h >> 13;
@@ -276,13 +276,13 @@ uint32_t git__hash(const void *key, int len, uint32_t seed)
{
#define MURMUR_BLOCK() {\
- k1 *= c1; \
- k1 = git__rotl(k1,11);\
- k1 *= c2;\
- h1 ^= k1;\
- h1 = h1*3 + 0x52dce729;\
- c1 = c1*5 + 0x7b7d159c;\
- c2 = c2*5 + 0x6bce6396;\
+ k1 *= c1; \
+ k1 = git__rotl(k1,11);\
+ k1 *= c2;\
+ h1 ^= k1;\
+ h1 = h1*3 + 0x52dce729;\
+ c1 = c1*5 + 0x7b7d159c;\
+ c2 = c2*5 + 0x6bce6396;\
}
const uint8_t *data = (const uint8_t*)key;
@@ -332,20 +332,20 @@ uint32_t git__hash(const void *key, int len, uint32_t seed)
*/
void **git__bsearch(const void *key, void **base, size_t nmemb, int (*compar)(const void *, const void *))
{
- int lim, cmp;
- void **p;
-
- for (lim = nmemb; lim != 0; lim >>= 1) {
- p = base + (lim >> 1);
- cmp = (*compar)(key, *p);
- if (cmp > 0) { /* key > p: move right */
- base = p + 1;
- lim--;
- } else if (cmp == 0) {
- return (void **)p;
- } /* else move left */
- }
- return NULL;
+ int lim, cmp;
+ void **p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = base + (lim >> 1);
+ cmp = (*compar)(key, *p);
+ if (cmp > 0) { /* key > p: move right */
+ base = p + 1;
+ lim--;
+ } else if (cmp == 0) {
+ return (void **)p;
+ } /* else move left */
+ }
+ return NULL;
}
/**
diff --git a/src/util.h b/src/util.h
index cd63abcf8..f24afb3ad 100644
--- a/src/util.h
+++ b/src/util.h
@@ -8,7 +8,7 @@
#define INCLUDE_util_h__
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-#define bitsizeof(x) (CHAR_BIT * sizeof(x))
+#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~0ULL << (bitsizeof(x) - (bits))))
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
diff --git a/src/win32/fnmatch.c b/src/win32/fnmatch.c
index cdce057da..7d7c77d48 100644
--- a/src/win32/fnmatch.c
+++ b/src/win32/fnmatch.c
@@ -16,165 +16,165 @@
#include "fnmatch.h"
-#define EOS '\0'
+#define EOS '\0'
-#define RANGE_MATCH 1
-#define RANGE_NOMATCH 0
-#define RANGE_ERROR (-1)
+#define RANGE_MATCH 1
+#define RANGE_NOMATCH 0
+#define RANGE_ERROR (-1)
static int rangematch(const char *, char, int, char **);
int
p_fnmatch(const char *pattern, const char *string, int flags)
{
- const char *stringstart;
- char *newp;
- char c, test;
-
- for (stringstart = string;;)
- switch (c = *pattern++) {
- case EOS:
- if ((flags & FNM_LEADING_DIR) && *string == '/')
- return (0);
- return (*string == EOS ? 0 : FNM_NOMATCH);
- case '?':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
- ++string;
- break;
- case '*':
- c = *pattern;
- /* Collapse multiple stars. */
- while (c == '*')
- c = *++pattern;
-
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- /* Optimize for pattern with * at end or before /. */
- if (c == EOS) {
- if (flags & FNM_PATHNAME)
- return ((flags & FNM_LEADING_DIR) ||
- strchr(string, '/') == NULL ?
- 0 : FNM_NOMATCH);
- else
- return (0);
- } else if (c == '/' && (flags & FNM_PATHNAME)) {
- if ((string = strchr(string, '/')) == NULL)
- return (FNM_NOMATCH);
- break;
- }
-
- /* General case, use recursion. */
- while ((test = *string) != EOS) {
- if (!p_fnmatch(pattern, string, flags & ~FNM_PERIOD))
- return (0);
- if (test == '/' && (flags & FNM_PATHNAME))
- break;
- ++string;
- }
- return (FNM_NOMATCH);
- case '[':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- switch (rangematch(pattern, *string, flags, &newp)) {
- case RANGE_ERROR:
- /* not a good range, treat as normal text */
- goto normal;
- case RANGE_MATCH:
- pattern = newp;
- break;
- case RANGE_NOMATCH:
- return (FNM_NOMATCH);
- }
- ++string;
- break;
- case '\\':
- if (!(flags & FNM_NOESCAPE)) {
- if ((c = *pattern++) == EOS) {
- c = '\\';
- --pattern;
- }
- }
- /* FALLTHROUGH */
- default:
- normal:
- if (c != *string && !((flags & FNM_CASEFOLD) &&
- (tolower((unsigned char)c) ==
- tolower((unsigned char)*string))))
- return (FNM_NOMATCH);
- ++string;
- break;
- }
- /* NOTREACHED */
+ const char *stringstart;
+ char *newp;
+ char c, test;
+
+ for (stringstart = string;;)
+ switch (c = *pattern++) {
+ case EOS:
+ if ((flags & FNM_LEADING_DIR) && *string == '/')
+ return (0);
+ return (*string == EOS ? 0 : FNM_NOMATCH);
+ case '?':
+ if (*string == EOS)
+ return (FNM_NOMATCH);
+ if (*string == '/' && (flags & FNM_PATHNAME))
+ return (FNM_NOMATCH);
+ if (*string == '.' && (flags & FNM_PERIOD) &&
+ (string == stringstart ||
+ ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+ return (FNM_NOMATCH);
+ ++string;
+ break;
+ case '*':
+ c = *pattern;
+ /* Collapse multiple stars. */
+ while (c == '*')
+ c = *++pattern;
+
+ if (*string == '.' && (flags & FNM_PERIOD) &&
+ (string == stringstart ||
+ ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+ return (FNM_NOMATCH);
+
+ /* Optimize for pattern with * at end or before /. */
+ if (c == EOS) {
+ if (flags & FNM_PATHNAME)
+ return ((flags & FNM_LEADING_DIR) ||
+ strchr(string, '/') == NULL ?
+ 0 : FNM_NOMATCH);
+ else
+ return (0);
+ } else if (c == '/' && (flags & FNM_PATHNAME)) {
+ if ((string = strchr(string, '/')) == NULL)
+ return (FNM_NOMATCH);
+ break;
+ }
+
+ /* General case, use recursion. */
+ while ((test = *string) != EOS) {
+ if (!p_fnmatch(pattern, string, flags & ~FNM_PERIOD))
+ return (0);
+ if (test == '/' && (flags & FNM_PATHNAME))
+ break;
+ ++string;
+ }
+ return (FNM_NOMATCH);
+ case '[':
+ if (*string == EOS)
+ return (FNM_NOMATCH);
+ if (*string == '/' && (flags & FNM_PATHNAME))
+ return (FNM_NOMATCH);
+ if (*string == '.' && (flags & FNM_PERIOD) &&
+ (string == stringstart ||
+ ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
+ return (FNM_NOMATCH);
+
+ switch (rangematch(pattern, *string, flags, &newp)) {
+ case RANGE_ERROR:
+ /* not a good range, treat as normal text */
+ goto normal;
+ case RANGE_MATCH:
+ pattern = newp;
+ break;
+ case RANGE_NOMATCH:
+ return (FNM_NOMATCH);
+ }
+ ++string;
+ break;
+ case '\\':
+ if (!(flags & FNM_NOESCAPE)) {
+ if ((c = *pattern++) == EOS) {
+ c = '\\';
+ --pattern;
+ }
+ }
+ /* FALLTHROUGH */
+ default:
+ normal:
+ if (c != *string && !((flags & FNM_CASEFOLD) &&
+ (tolower((unsigned char)c) ==
+ tolower((unsigned char)*string))))
+ return (FNM_NOMATCH);
+ ++string;
+ break;
+ }
+ /* NOTREACHED */
}
static int
rangematch(const char *pattern, char test, int flags, char **newp)
{
- int negate, ok;
- char c, c2;
-
- /*
- * A bracket expression starting with an unquoted circumflex
- * character produces unspecified results (IEEE 1003.2-1992,
- * 3.13.2). This implementation treats it like '!', for
- * consistency with the regular expression syntax.
- * J.T. Conklin (conklin@ngai.kaleida.com)
- */
- if ((negate = (*pattern == '!' || *pattern == '^')) != 0)
- ++pattern;
-
- if (flags & FNM_CASEFOLD)
- test = (char)tolower((unsigned char)test);
-
- /*
- * A right bracket shall lose its special meaning and represent
- * itself in a bracket expression if it occurs first in the list.
- * -- POSIX.2 2.8.3.2
- */
- ok = 0;
- c = *pattern++;
- do {
- if (c == '\\' && !(flags & FNM_NOESCAPE))
- c = *pattern++;
- if (c == EOS)
- return (RANGE_ERROR);
- if (c == '/' && (flags & FNM_PATHNAME))
- return (RANGE_NOMATCH);
- if ((flags & FNM_CASEFOLD))
- c = (char)tolower((unsigned char)c);
- if (*pattern == '-'
- && (c2 = *(pattern+1)) != EOS && c2 != ']') {
- pattern += 2;
- if (c2 == '\\' && !(flags & FNM_NOESCAPE))
- c2 = *pattern++;
- if (c2 == EOS)
- return (RANGE_ERROR);
- if (flags & FNM_CASEFOLD)
- c2 = (char)tolower((unsigned char)c2);
- if (c <= test && test <= c2)
- ok = 1;
- } else if (c == test)
- ok = 1;
- } while ((c = *pattern++) != ']');
-
- *newp = (char *)pattern;
- return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
+ int negate, ok;
+ char c, c2;
+
+ /*
+ * A bracket expression starting with an unquoted circumflex
+ * character produces unspecified results (IEEE 1003.2-1992,
+ * 3.13.2). This implementation treats it like '!', for
+ * consistency with the regular expression syntax.
+ * J.T. Conklin (conklin@ngai.kaleida.com)
+ */
+ if ((negate = (*pattern == '!' || *pattern == '^')) != 0)
+ ++pattern;
+
+ if (flags & FNM_CASEFOLD)
+ test = (char)tolower((unsigned char)test);
+
+ /*
+ * A right bracket shall lose its special meaning and represent
+ * itself in a bracket expression if it occurs first in the list.
+ * -- POSIX.2 2.8.3.2
+ */
+ ok = 0;
+ c = *pattern++;
+ do {
+ if (c == '\\' && !(flags & FNM_NOESCAPE))
+ c = *pattern++;
+ if (c == EOS)
+ return (RANGE_ERROR);
+ if (c == '/' && (flags & FNM_PATHNAME))
+ return (RANGE_NOMATCH);
+ if ((flags & FNM_CASEFOLD))
+ c = (char)tolower((unsigned char)c);
+ if (*pattern == '-'
+ && (c2 = *(pattern+1)) != EOS && c2 != ']') {
+ pattern += 2;
+ if (c2 == '\\' && !(flags & FNM_NOESCAPE))
+ c2 = *pattern++;
+ if (c2 == EOS)
+ return (RANGE_ERROR);
+ if (flags & FNM_CASEFOLD)
+ c2 = (char)tolower((unsigned char)c2);
+ if (c <= test && test <= c2)
+ ok = 1;
+ } else if (c == test)
+ ok = 1;
+ } while ((c = *pattern++) != ']');
+
+ *newp = (char *)pattern;
+ return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
}
diff --git a/src/win32/fnmatch.h b/src/win32/fnmatch.h
index 2490292bb..1caac37fe 100644
--- a/src/win32/fnmatch.h
+++ b/src/win32/fnmatch.h
@@ -9,17 +9,17 @@
#include "common.h"
-#define FNM_NOMATCH 1 /* Match failed. */
-#define FNM_NOSYS 2 /* Function not supported (unused). */
+#define FNM_NOMATCH 1 /* Match failed. */
+#define FNM_NOSYS 2 /* Function not supported (unused). */
-#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
-#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
-#define FNM_PERIOD 0x04 /* Period must be matched by period. */
-#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
-#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
+#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */
+#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */
+#define FNM_PERIOD 0x04 /* Period must be matched by period. */
+#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */
+#define FNM_CASEFOLD 0x10 /* Case insensitive search. */
-#define FNM_IGNORECASE FNM_CASEFOLD
-#define FNM_FILE_NAME FNM_PATHNAME
+#define FNM_IGNORECASE FNM_CASEFOLD
+#define FNM_FILE_NAME FNM_PATHNAME
extern int p_fnmatch(const char *pattern, const char *string, int flags);
diff --git a/src/win32/map.c b/src/win32/map.c
index a30714c11..3e6b3d878 100644
--- a/src/win32/map.c
+++ b/src/win32/map.c
@@ -29,7 +29,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
DWORD fmap_prot = 0;
DWORD view_prot = 0;
DWORD off_low = 0;
- DWORD off_hi = 0;
+ DWORD off_hi = 0;
git_off_t page_start;
git_off_t page_offset;
@@ -71,7 +71,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
page_start = (offset / page_size) * page_size;
page_offset = offset - page_start;
- if (page_offset != 0) { /* offset must be multiple of page size */
+ if (page_offset != 0) { /* offset must be multiple of page size */
errno = EINVAL;
return git__throw(GIT_ERROR, "Failed to mmap. Offset must be multiple of page size");
}
diff --git a/src/win32/mingw-compat.h b/src/win32/mingw-compat.h
index bd12de88c..7207d882f 100644
--- a/src/win32/mingw-compat.h
+++ b/src/win32/mingw-compat.h
@@ -17,7 +17,7 @@
/* stat: file mode type testing macros */
# define _S_IFLNK 0120000
# define S_IFLNK _S_IFLNK
-# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
+# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
#endif
diff --git a/src/win32/msvc-compat.h b/src/win32/msvc-compat.h
index 57ff81148..64ed18476 100644
--- a/src/win32/msvc-compat.h
+++ b/src/win32/msvc-compat.h
@@ -9,10 +9,10 @@
#if defined(_MSC_VER)
-/* access() mode parameter #defines */
-# define F_OK 0 /* existence check */
-# define W_OK 2 /* write mode check */
-# define R_OK 4 /* read mode check */
+/* access() mode parameter #defines */
+# define F_OK 0 /* existence check */
+# define W_OK 2 /* write mode check */
+# define R_OK 4 /* read mode check */
# define lseek _lseeki64
# define stat _stat64
@@ -22,16 +22,16 @@
# define _S_IFLNK 0120000
# define S_IFLNK _S_IFLNK
-# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
-# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
-# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
-# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
+# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
+# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
# define mode_t unsigned short
/* case-insensitive string comparison */
-# define strcasecmp _stricmp
-# define strncasecmp _strnicmp
+# define strcasecmp _stricmp
+# define strncasecmp _strnicmp
#if (_MSC_VER >= 1600)
# include <stdint.h>
diff --git a/src/win32/posix.c b/src/win32/posix.c
index 2f630499f..38e505e20 100644
--- a/src/win32/posix.c
+++ b/src/win32/posix.c
@@ -144,13 +144,13 @@ int p_readlink(const char *link, char *target, size_t target_len)
"'GetFinalPathNameByHandleA' is not available in this platform");
}
- hFile = CreateFile(link, // file to open
- GENERIC_READ, // open for reading
- FILE_SHARE_READ, // share for reading
- NULL, // default security
- OPEN_EXISTING, // existing file only
+ hFile = CreateFile(link, // file to open
+ GENERIC_READ, // open for reading
+ FILE_SHARE_READ, // share for reading
+ NULL, // default security
+ OPEN_EXISTING, // existing file only
FILE_FLAG_BACKUP_SEMANTICS, // normal file
- NULL); // no attr. template
+ NULL); // no attr. template
if (hFile == INVALID_HANDLE_VALUE)
return GIT_EOSERR;
@@ -163,7 +163,7 @@ int p_readlink(const char *link, char *target, size_t target_len)
if (dwRet > 4) {
/* Skip first 4 characters if they are "\\?\" */
- if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') {
+ if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') {
char tmp[GIT_PATH_MAX];
unsigned int offset = 4;
dwRet -= 4;
@@ -189,7 +189,7 @@ int p_hide_directory__w32(const char *path)
int error;
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)
error = git__throw(GIT_EOSERR, "Failed to hide directory '%s'", path);
diff --git a/src/win32/pthread.c b/src/win32/pthread.c
index b613e91d7..e0f6c14a8 100644
--- a/src/win32/pthread.c
+++ b/src/win32/pthread.c
@@ -8,8 +8,8 @@
#include "pthread.h"
int pthread_create(pthread_t *GIT_RESTRICT thread,
- const pthread_attr_t *GIT_RESTRICT GIT_UNUSED(attr),
- void *(*start_routine)(void*), void *GIT_RESTRICT arg)
+ const pthread_attr_t *GIT_RESTRICT GIT_UNUSED(attr),
+ void *(*start_routine)(void*), void *GIT_RESTRICT arg)
{
GIT_UNUSED_ARG(attr);
*thread = (pthread_t) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, arg, 0, NULL);
@@ -18,48 +18,48 @@ int pthread_create(pthread_t *GIT_RESTRICT thread,
int pthread_join(pthread_t thread, void **value_ptr)
{
- int ret;
- ret = WaitForSingleObject(thread, INFINITE);
- if (ret && value_ptr)
- GetExitCodeThread(thread, (void*) value_ptr);
- return -(!!ret);
+ int ret;
+ ret = WaitForSingleObject(thread, INFINITE);
+ if (ret && value_ptr)
+ GetExitCodeThread(thread, (void*) value_ptr);
+ return -(!!ret);
}
int pthread_mutex_init(pthread_mutex_t *GIT_RESTRICT mutex,
- const pthread_mutexattr_t *GIT_RESTRICT GIT_UNUSED(mutexattr))
+ const pthread_mutexattr_t *GIT_RESTRICT GIT_UNUSED(mutexattr))
{
- GIT_UNUSED_ARG(mutexattr);
- InitializeCriticalSection(mutex);
- return 0;
+ GIT_UNUSED_ARG(mutexattr);
+ InitializeCriticalSection(mutex);
+ return 0;
}
int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
- DeleteCriticalSection(mutex);
- return 0;
+ DeleteCriticalSection(mutex);
+ return 0;
}
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
- EnterCriticalSection(mutex);
- return 0;
+ EnterCriticalSection(mutex);
+ return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *mutex)
{
- LeaveCriticalSection(mutex);
- return 0;
+ LeaveCriticalSection(mutex);
+ return 0;
}
int pthread_num_processors_np(void)
{
- DWORD_PTR p, s;
- int n = 0;
+ DWORD_PTR p, s;
+ int n = 0;
- if (GetProcessAffinityMask(GetCurrentProcess(), &p, &s))
- for (; p; p >>= 1)
- n += p&1;
+ if (GetProcessAffinityMask(GetCurrentProcess(), &p, &s))
+ for (; p; p >>= 1)
+ n += p&1;
- return n ? n : 1;
+ return n ? n : 1;
}
diff --git a/src/win32/pthread.h b/src/win32/pthread.h
index aaa226de5..3ea8c7ac1 100644
--- a/src/win32/pthread.h
+++ b/src/win32/pthread.h
@@ -25,8 +25,8 @@ typedef HANDLE pthread_t;
#define PTHREAD_MUTEX_INITIALIZER {(void*)-1};
int pthread_create(pthread_t *GIT_RESTRICT,
- const pthread_attr_t *GIT_RESTRICT,
- void *(*start_routine)(void*), void *__restrict);
+ const pthread_attr_t *GIT_RESTRICT,
+ void *(*start_routine)(void*), void *__restrict);
int pthread_join(pthread_t, void **);
diff --git a/tests-clay/clay_main.c b/tests-clay/clay_main.c
index 90c33bd5d..b536b6a97 100644
--- a/tests-clay/clay_main.c
+++ b/tests-clay/clay_main.c
@@ -139,7 +139,7 @@ clay_run_test(
static void
clay_print_error(int num, const struct clay_error *error)
{
- clay_print(" %d) Failure:\n", num);
+ clay_print(" %d) Failure:\n", num);
clay_print("%s::%s (%s) [%s:%d] [-t%d]\n",
error->suite,
@@ -149,10 +149,10 @@ clay_print_error(int num, const struct clay_error *error)
error->line_number,
error->test_number);
- clay_print(" %s\n", error->error_msg);
+ clay_print(" %s\n", error->error_msg);
if (error->description != NULL)
- clay_print(" %s\n", error->description);
+ clay_print(" %s\n", error->description);
clay_print("\n");
}
@@ -204,8 +204,8 @@ clay_usage(const char *arg)
{
printf("Usage: %s [options]\n\n", arg);
printf("Options:\n");
- printf(" -tXX\t\tRun only the test number XX\n");
- printf(" -sXX\t\tRun only the suite number XX\n");
+ printf(" -tXX\t\tRun only the test number XX\n");
+ printf(" -sXX\t\tRun only the suite number XX\n");
exit(-1);
}
@@ -691,7 +691,7 @@ extern void test_status_worktree__whole_repository(void);
extern void test_status_worktree__empty_repository(void);
static const struct clay_func _all_callbacks[] = {
- {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 0},
+ {"dont_traverse_dot", &test_core_dirent__dont_traverse_dot, 0},
{"traverse_subfolder", &test_core_dirent__traverse_subfolder, 0},
{"traverse_slash_terminated_folder", &test_core_dirent__traverse_slash_terminated_folder, 0},
{"dont_traverse_empty_folders", &test_core_dirent__dont_traverse_empty_folders, 0},
@@ -717,63 +717,63 @@ static const struct clay_func _all_callbacks[] = {
};
static const struct clay_suite _all_suites[] = {
- {
- "core::dirent",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[0], 5
- },
{
- "core::filebuf",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[5], 3
- },
+ "core::dirent",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[0], 5
+ },
{
- "core::path",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[8], 5
- },
+ "core::filebuf",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[5], 3
+ },
{
- "core::rmdir",
- {"initialize", &test_core_rmdir__initialize, 3},
- {NULL, NULL, 0},
- &_all_callbacks[13], 2
- },
+ "core::path",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[8], 5
+ },
{
- "core::string",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[15], 2
- },
+ "core::rmdir",
+ {"initialize", &test_core_rmdir__initialize, 3},
+ {NULL, NULL, 0},
+ &_all_callbacks[13], 2
+ },
{
- "core::vector",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[17], 3
- },
+ "core::string",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[15], 2
+ },
{
- "status::single",
- {NULL, NULL, 0},
- {NULL, NULL, 0},
- &_all_callbacks[20], 1
- },
+ "core::vector",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[17], 3
+ },
{
- "status::worktree",
- {"initialize", &test_status_worktree__initialize, 7},
- {"cleanup", &test_status_worktree__cleanup, 7},
- &_all_callbacks[21], 2
- }
+ "status::single",
+ {NULL, NULL, 0},
+ {NULL, NULL, 0},
+ &_all_callbacks[20], 1
+ },
+ {
+ "status::worktree",
+ {"initialize", &test_status_worktree__initialize, 7},
+ {"cleanup", &test_status_worktree__cleanup, 7},
+ &_all_callbacks[21], 2
+ }
};
static const char _suites_str[] = "core::dirent, core::filebuf, core::path, core::rmdir, core::string, core::vector, status::single, status::worktree";
int _CC main(int argc, char *argv[])
{
- return clay_test(
- argc, argv, _suites_str,
- _all_callbacks, 23,
- _all_suites, 8
- );
+ return clay_test(
+ argc, argv, _suites_str,
+ _all_callbacks, 23,
+ _all_suites, 8
+ );
}
diff --git a/tests-clay/core/dirent.c b/tests-clay/core/dirent.c
index ed51890e6..73f571595 100644
--- a/tests-clay/core/dirent.c
+++ b/tests-clay/core/dirent.c
@@ -2,13 +2,13 @@
#include "fileops.h"
typedef struct name_data {
- int count; /* return count */
- char *name; /* filename */
+ int count; /* return count */
+ char *name; /* filename */
} name_data;
typedef struct walk_data {
- char *sub; /* sub-directory name */
- name_data *names; /* name state data */
+ char *sub; /* sub-directory name */
+ name_data *names; /* name state data */
} walk_data;
@@ -112,9 +112,9 @@ void test_core_dirent__dont_traverse_dot(void)
setup(&dot);
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- one_entry,
- &dot));
+ sizeof(path_buffer),
+ one_entry,
+ &dot));
check_counts(&dot);
}
@@ -138,9 +138,9 @@ void test_core_dirent__traverse_subfolder(void)
setup(&sub);
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- one_entry,
- &sub));
+ sizeof(path_buffer),
+ one_entry,
+ &sub));
check_counts(&sub);
}
@@ -158,9 +158,9 @@ void test_core_dirent__traverse_slash_terminated_folder(void)
setup(&sub_slash);
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- one_entry,
- &sub_slash));
+ sizeof(path_buffer),
+ one_entry,
+ &sub_slash));
check_counts(&sub_slash);
}
@@ -181,17 +181,17 @@ void test_core_dirent__dont_traverse_empty_folders(void)
setup(&empty);
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- one_entry,
- &empty));
+ sizeof(path_buffer),
+ one_entry,
+ &empty));
check_counts(&empty);
/* make sure callback not called */
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- dont_call_me,
- &empty));
+ sizeof(path_buffer),
+ dont_call_me,
+ &empty));
}
static name_data odd_names[] = {
@@ -199,7 +199,7 @@ static name_data odd_names[] = {
{ 0, "odd/..c" },
/* the following don't work on cygwin/win32 */
/* { 0, "odd/.b." }, */
- /* { 0, "odd/..d.." }, */
+ /* { 0, "odd/..d.." }, */
{ 0, NULL }
};
static walk_data odd = {
@@ -214,9 +214,9 @@ void test_core_dirent__traverse_weird_filenames(void)
setup(&odd);
cl_git_pass(git_futils_direach(path_buffer,
- sizeof(path_buffer),
- one_entry,
- &odd));
+ sizeof(path_buffer),
+ one_entry,
+ &odd));
check_counts(&odd);
}
diff --git a/tests-clay/core/vector.c b/tests-clay/core/vector.c
index ba9d18857..44e6d873d 100644
--- a/tests-clay/core/vector.c
+++ b/tests-clay/core/vector.c
@@ -24,7 +24,7 @@ void test_core_vector__1(void)
git_vector_insert(&x, (void*) 0xdef);
git_vector_insert(&x, (void*) 0x123);
- git_vector_remove(&x, 0); // used to read past array bounds.
+ git_vector_remove(&x, 0); // used to read past array bounds.
git_vector_free(&x);
}