Merge pull request #2575 from cirosantilli/factor-struct-typedef [factor] Join typedef and struct definitions in single file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
diff --git a/include/git2/diff.h b/include/git2/diff.h
index 8147fd3..ca49a9c 100644
--- a/include/git2/diff.h
+++ b/include/git2/diff.h
@@ -421,15 +421,14 @@ typedef int (*git_diff_file_cb)(
/**
* Structure describing a hunk of a diff.
*/
-typedef struct git_diff_hunk git_diff_hunk;
-struct git_diff_hunk {
+typedef struct git_diff_hunk {
int old_start; /**< Starting line number in old_file */
int old_lines; /**< Number of lines in old_file */
int new_start; /**< Starting line number in new_file */
int new_lines; /**< Number of lines in new_file */
size_t header_len; /**< Number of bytes in header text */
char header[128]; /**< Header text, NUL-byte terminated */
-};
+} git_diff_hunk;
/**
* When iterating over a diff, callback that will be made per hunk.
@@ -469,8 +468,7 @@ typedef enum {
/**
* Structure describing a line (or data span) of a diff.
*/
-typedef struct git_diff_line git_diff_line;
-struct git_diff_line {
+typedef struct git_diff_line {
char origin; /**< A git_diff_line_t value */
int old_lineno; /**< Line number in old file or -1 for added line */
int new_lineno; /**< Line number in new file or -1 for deleted line */
@@ -478,7 +476,7 @@ struct git_diff_line {
size_t content_len; /**< Number of bytes of data */
git_off_t content_offset; /**< Offset in the original file to the content */
const char *content; /**< Pointer to diff text, not NUL-byte terminated */
-};
+} git_diff_line;
/**
* When iterating over a diff, callback that will be made per text diff
diff --git a/src/diff_patch.c b/src/diff_patch.c
index 4e0672a..317dbea 100644
--- a/src/diff_patch.c
+++ b/src/diff_patch.c
@@ -14,12 +14,11 @@
#include "fileops.h"
/* cached information about a hunk in a diff */
-typedef struct diff_patch_hunk diff_patch_hunk;
-struct diff_patch_hunk {
+typedef struct diff_patch_hunk {
git_diff_hunk hunk;
size_t line_start;
size_t line_count;
-};
+} diff_patch_hunk;
struct git_patch {
git_refcount rc;
diff --git a/src/fetchhead.h b/src/fetchhead.h
index 74fce04..b03bd0f 100644
--- a/src/fetchhead.h
+++ b/src/fetchhead.h
@@ -9,14 +9,12 @@
#include "vector.h"
-struct git_fetchhead_ref {
+typedef struct git_fetchhead_ref {
git_oid oid;
unsigned int is_merge;
char *ref_name;
char *remote_url;
-};
-
-typedef struct git_fetchhead_ref git_fetchhead_ref;
+} git_fetchhead_ref;
int git_fetchhead_ref_create(
git_fetchhead_ref **fetchhead_ref_out,
diff --git a/src/filebuf.h b/src/filebuf.h
index 044af54..2bd18dc 100644
--- a/src/filebuf.h
+++ b/src/filebuf.h
@@ -25,11 +25,12 @@
#define GIT_FILELOCK_EXTENSION ".lock\0"
#define GIT_FILELOCK_EXTLENGTH 6
+typedef struct git_filebuf git_filebuf;
struct git_filebuf {
char *path_original;
char *path_lock;
- int (*write)(struct git_filebuf *file, void *source, size_t len);
+ int (*write)(git_filebuf *file, void *source, size_t len);
bool compute_digest;
git_hash_ctx digest;
@@ -47,8 +48,6 @@ struct git_filebuf {
int last_error;
};
-typedef struct git_filebuf git_filebuf;
-
#define GIT_FILEBUF_INIT {0}
/*
diff --git a/src/netops.h b/src/netops.h
index beb0e07..8ad9153 100644
--- a/src/netops.h
+++ b/src/netops.h
@@ -14,34 +14,28 @@
# include <openssl/ssl.h>
#endif
-struct gitno_ssl {
+typedef struct gitno_ssl {
#ifdef GIT_SSL
SSL *ssl;
#else
size_t dummy;
#endif
-};
-
-typedef struct gitno_ssl gitno_ssl;
+} gitno_ssl;
/* Represents a socket that may or may not be using SSL */
-struct gitno_socket {
+typedef struct gitno_socket {
GIT_SOCKET socket;
gitno_ssl ssl;
-};
+} gitno_socket;
-typedef struct gitno_socket gitno_socket;
-
-struct gitno_buffer {
+typedef struct gitno_buffer {
char *data;
size_t len;
size_t offset;
gitno_socket *socket;
int (*recv)(struct gitno_buffer *buffer);
void *cb_data;
-};
-
-typedef struct gitno_buffer gitno_buffer;
+} gitno_buffer;
/* Flags to gitno_connect */
enum {
diff --git a/src/tree-cache.h b/src/tree-cache.h
index 90c82db..7801712 100644
--- a/src/tree-cache.h
+++ b/src/tree-cache.h
@@ -11,7 +11,7 @@
#include "common.h"
#include "git2/oid.h"
-struct git_tree_cache {
+typedef struct {
struct git_tree_cache *parent;
struct git_tree_cache **children;
size_t children_count;
@@ -20,9 +20,7 @@ struct git_tree_cache {
git_oid oid;
size_t namelen;
char name[GIT_FLEX_ARRAY];
-};
-
-typedef struct git_tree_cache git_tree_cache;
+} git_tree_cache;
int git_tree_cache_read(git_tree_cache **tree, const char *buffer, size_t buffer_size);
void git_tree_cache_invalidate_path(git_tree_cache *tree, const char *path);