Initial draft of libgit2 · nodegit/libgit2@c15648c · GitHub
Skip to content

Commit c15648c

Browse files
committed
Initial draft of libgit2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
0 parents  commit c15648c

9 files changed

Lines changed: 503 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions

‎LICENSE‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or
5+
* without modification, are permitted provided that the following
6+
* conditions are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above
12+
* copyright notice, this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided
14+
* with the distribution.
15+
*
16+
* - Neither the name of the Git Development Community nor the
17+
* names of its contributors may be used to endorse or promote
18+
* products derived from this software without specific prior
19+
* written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/

‎Makefile‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
all::
2+
3+
DOXYGEN = doxygen
4+
5+
CFLAGS = -g -O2
6+
BASIC_CFLAGS = -Isrc
7+
8+
OBJS = \
9+
src/git_odb.o \
10+
src/git_oid.o \
11+
#end OBJS
12+
13+
HDRS = \
14+
src/git_oid.h \
15+
src/git_common.h \
16+
#end HDRS
17+
18+
19+
all:: libgit2.a
20+
21+
clean:
22+
rm -f libgit2.a src/*.o
23+
rm -rf apidocs
24+
25+
apidocs:
26+
$(DOXYGEN) api.doxygen
27+
28+
.c.o:
29+
$(CC) $(BASIC_CFLAGS) $(CFLAGS) -c $< -o $@
30+
31+
src/%.o: src/%.c $(HDRS)
32+
libgit2.a: $(OBJS)
33+
rm -f libgit2.a
34+
$(AR) cr libgit2.a $(OBJS)
35+
36+
.PHONY: all
37+
.PHONY: clean
38+
.PHONY: apidocs

‎api.doxygen‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
PROJECT_NAME = libgit2
2+
3+
INPUT = src
4+
QUIET = YES
5+
RECURSIVE = YES
6+
FILE_PATTERNS = *.h
7+
OUTPUT_DIRECTORY = apidocs
8+
GENERATE_TAGFILE = apidocs/libgit2.tag
9+
10+
JAVADOC_AUTOBRIEF = YES
11+
MACRO_EXPANSION = YES
12+
EXPAND_ONLY_PREDEF = YES
13+
OPTIMIZE_OUTPUT_FOR_C = YES
14+
STRIP_CODE_COMMENTS = NO
15+
FULL_PATH_NAMES = NO
16+
CASE_SENSE_NAMES = NO
17+
18+
PREDEFINED = \
19+
"GIT_EXTERN(x)=x" \
20+
DOXYGEN=

‎src/git_common.h‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or
5+
* without modification, are permitted provided that the following
6+
* conditions are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above
12+
* copyright notice, this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided
14+
* with the distribution.
15+
*
16+
* - Neither the name of the Git Development Community nor the
17+
* names of its contributors may be used to endorse or promote
18+
* products derived from this software without specific prior
19+
* written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
36+
#ifndef INCLUDE_git_common_h__
37+
#define INCLUDE_git_common_h__
38+
39+
#ifdef __cplusplus
40+
# define GIT_BEGIN_DECL extern "C" {
41+
# define GIT_END_DECL }
42+
#else
43+
/** Start declarations in C mode */
44+
# define GIT_BEGIN_DECL /* empty */
45+
/** End declarations in C mode */
46+
# define GIT_END_DECL /* empty */
47+
#endif
48+
49+
/**
50+
* @file git_common.h
51+
* @brief Git common platform definitions
52+
* @defgroup git_common Git common platform definitions
53+
* @ingroup Git
54+
* @{
55+
*/
56+
GIT_BEGIN_DECL
57+
58+
/** Declare a public function exported for application use. */
59+
#define GIT_EXTERN(type) type
60+
61+
/** Generic result code for any API call. */
62+
typedef int git_result;
63+
64+
/** Operation completed successfully. */
65+
#define GIT_SUCCESS 0
66+
67+
/**
68+
* Operation failed, with unspecified reason.
69+
* This value also serves as the base error code; all other
70+
* error codes are subtracted from it such that all errors
71+
* are < 0, in typical POSIX C tradition.
72+
*/
73+
#define GIT_ERROR -1
74+
75+
/** Input was not a properly formatted Git object id. */
76+
#define GIT_ENOTOID (GIT_ERROR - 1)
77+
78+
/** Input does not exist in the scope searched. */
79+
#define GIT_ENOTFOUND (GIT_ERROR - 2)
80+
81+
/** @} */
82+
GIT_END_DECL
83+
#endif

‎src/git_odb.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or
5+
* without modification, are permitted provided that the following
6+
* conditions are met:
7+
*
8+
* - Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* - Redistributions in binary form must reproduce the above
12+
* copyright notice, this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials provided
14+
* with the distribution.
15+
*
16+
* - Neither the name of the Git Development Community nor the
17+
* names of its contributors may be used to endorse or promote
18+
* products derived from this software without specific prior
19+
* written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
26+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
36+
#include "git_odb.h"
37+
38+
git_result git_odb_sread(git_sobj *out, git_odb *db, git_oid *id)
39+
{
40+
if (!git_odb__sread_packed(out, db, id))
41+
return GIT_SUCCESS;
42+
return git_odb__sread_loose(out, db, id);
43+
}

‎src/git_odb.h‎

Lines changed: 133 additions & 0 deletions

0 commit comments

Comments
 (0)