Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
fb8dd803
Commit
fb8dd803
authored
Feb 05, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sqlite-backend'
parents
40be9ae0
c041af95
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
763 additions
and
349 deletions
+763
-349
src/backends/sqlite.c
+277
-0
src/git2/odb_backend.h
+7
-0
src/t03-data.h
+344
-0
tests/t03-objwrite.c
+1
-345
tests/t11-sqlite.c
+123
-0
tests/test_main.c
+3
-1
wscript
+8
-3
No files found.
src/backends/sqlite.c
0 → 100644
View file @
fb8dd803
/*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* as published by the Free Software Foundation.
*
* In addition to the permissions in the GNU General Public License,
* the authors give you unlimited permission to link the compiled
* version of this file into combinations with other programs,
* and to distribute those combinations without any restriction
* coming from the use of this file. (The General Public License
* restrictions do apply in other respects; for example, they cover
* modification of the file, and distribution when not linked into
* a combined executable.)
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "common.h"
#include "git2/object.h"
#include "hash.h"
#include "odb.h"
#include "git2/odb_backend.h"
#ifdef GIT2_SQLITE_BACKEND
#include <sqlite3.h>
#define GIT2_TABLE_NAME "git2_odb"
typedef
struct
{
git_odb_backend
parent
;
sqlite3
*
db
;
sqlite3_stmt
*
st_read
;
sqlite3_stmt
*
st_write
;
sqlite3_stmt
*
st_read_header
;
}
sqlite_backend
;
int
sqlite_backend__read_header
(
git_rawobj
*
obj
,
git_odb_backend
*
_backend
,
const
git_oid
*
oid
)
{
sqlite_backend
*
backend
;
int
error
;
assert
(
obj
&&
_backend
&&
oid
);
backend
=
(
sqlite_backend
*
)
_backend
;
error
=
GIT_ERROR
;
obj
->
data
=
NULL
;
if
(
sqlite3_bind_text
(
backend
->
st_read_header
,
1
,
(
char
*
)
oid
->
id
,
20
,
SQLITE_TRANSIENT
)
==
SQLITE_OK
)
{
if
(
sqlite3_step
(
backend
->
st_read_header
)
==
SQLITE_ROW
)
{
obj
->
type
=
sqlite3_column_int
(
backend
->
st_read_header
,
0
);
obj
->
len
=
sqlite3_column_int
(
backend
->
st_read_header
,
1
);
assert
(
sqlite3_step
(
backend
->
st_read_header
)
==
SQLITE_DONE
);
error
=
GIT_SUCCESS
;
}
else
{
error
=
GIT_ENOTFOUND
;
}
}
sqlite3_reset
(
backend
->
st_read_header
);
return
error
;
}
int
sqlite_backend__read
(
git_rawobj
*
obj
,
git_odb_backend
*
_backend
,
const
git_oid
*
oid
)
{
sqlite_backend
*
backend
;
int
error
;
assert
(
obj
&&
_backend
&&
oid
);
backend
=
(
sqlite_backend
*
)
_backend
;
error
=
GIT_ERROR
;
if
(
sqlite3_bind_text
(
backend
->
st_read
,
1
,
(
char
*
)
oid
->
id
,
20
,
SQLITE_TRANSIENT
)
==
SQLITE_OK
)
{
if
(
sqlite3_step
(
backend
->
st_read
)
==
SQLITE_ROW
)
{
obj
->
type
=
sqlite3_column_int
(
backend
->
st_read
,
0
);
obj
->
len
=
sqlite3_column_int
(
backend
->
st_read
,
1
);
obj
->
data
=
git__malloc
(
obj
->
len
);
if
(
obj
->
data
==
NULL
)
{
error
=
GIT_ENOMEM
;
}
else
{
memcpy
(
obj
->
data
,
sqlite3_column_blob
(
backend
->
st_read
,
2
),
obj
->
len
);
error
=
GIT_SUCCESS
;
}
assert
(
sqlite3_step
(
backend
->
st_read
)
==
SQLITE_DONE
);
}
else
{
error
=
GIT_ENOTFOUND
;
}
}
sqlite3_reset
(
backend
->
st_read
);
return
error
;
}
int
sqlite_backend__exists
(
git_odb_backend
*
_backend
,
const
git_oid
*
oid
)
{
sqlite_backend
*
backend
;
int
found
;
assert
(
_backend
&&
oid
);
backend
=
(
sqlite_backend
*
)
_backend
;
found
=
0
;
if
(
sqlite3_bind_text
(
backend
->
st_read_header
,
1
,
(
char
*
)
oid
->
id
,
20
,
SQLITE_TRANSIENT
)
==
SQLITE_OK
)
{
if
(
sqlite3_step
(
backend
->
st_read_header
)
==
SQLITE_ROW
)
{
found
=
1
;
assert
(
sqlite3_step
(
backend
->
st_read_header
)
==
SQLITE_DONE
);
}
}
sqlite3_reset
(
backend
->
st_read_header
);
return
found
;
}
int
sqlite_backend__write
(
git_oid
*
id
,
git_odb_backend
*
_backend
,
git_rawobj
*
obj
)
{
char
hdr
[
64
];
int
hdrlen
;
int
error
;
sqlite_backend
*
backend
;
assert
(
id
&&
_backend
&&
obj
);
backend
=
(
sqlite_backend
*
)
_backend
;
if
((
error
=
git_odb__hash_obj
(
id
,
hdr
,
sizeof
(
hdr
),
&
hdrlen
,
obj
))
<
0
)
return
error
;
error
=
SQLITE_ERROR
;
if
(
sqlite3_bind_text
(
backend
->
st_write
,
1
,
(
char
*
)
id
->
id
,
20
,
SQLITE_TRANSIENT
)
==
SQLITE_OK
&&
sqlite3_bind_int
(
backend
->
st_write
,
2
,
(
int
)
obj
->
type
)
==
SQLITE_OK
&&
sqlite3_bind_int
(
backend
->
st_write
,
3
,
obj
->
len
)
==
SQLITE_OK
&&
sqlite3_bind_blob
(
backend
->
st_write
,
4
,
obj
->
data
,
obj
->
len
,
SQLITE_TRANSIENT
)
==
SQLITE_OK
)
{
error
=
sqlite3_step
(
backend
->
st_write
);
}
sqlite3_reset
(
backend
->
st_write
);
return
(
error
==
SQLITE_DONE
)
?
GIT_SUCCESS
:
GIT_ERROR
;
}
void
sqlite_backend__free
(
git_odb_backend
*
_backend
)
{
sqlite_backend
*
backend
;
assert
(
_backend
);
backend
=
(
sqlite_backend
*
)
_backend
;
sqlite3_finalize
(
backend
->
st_read
);
sqlite3_finalize
(
backend
->
st_read_header
);
sqlite3_finalize
(
backend
->
st_write
);
sqlite3_close
(
backend
->
db
);
free
(
backend
);
}
static
int
create_table
(
sqlite3
*
db
)
{
static
const
char
*
sql_creat
=
"CREATE TABLE '"
GIT2_TABLE_NAME
"' ("
"'oid' CHARACTER(20) PRIMARY KEY NOT NULL,"
"'type' INTEGER NOT NULL,"
"'size' INTEGER NOT NULL,"
"'data' BLOB);"
;
if
(
sqlite3_exec
(
db
,
sql_creat
,
NULL
,
NULL
,
NULL
)
!=
SQLITE_OK
)
return
GIT_ERROR
;
return
GIT_SUCCESS
;
}
static
int
init_db
(
sqlite3
*
db
)
{
static
const
char
*
sql_check
=
"SELECT name FROM sqlite_master WHERE type='table' AND name='"
GIT2_TABLE_NAME
"';"
;
sqlite3_stmt
*
st_check
;
int
error
;
if
(
sqlite3_prepare_v2
(
db
,
sql_check
,
-
1
,
&
st_check
,
NULL
)
!=
SQLITE_OK
)
return
GIT_ERROR
;
switch
(
sqlite3_step
(
st_check
))
{
case
SQLITE_DONE
:
/* the table was not found */
error
=
create_table
(
db
);
break
;
case
SQLITE_ROW
:
/* the table was found */
error
=
GIT_SUCCESS
;
break
;
default:
error
=
GIT_ERROR
;
break
;
}
sqlite3_finalize
(
st_check
);
return
error
;
}
static
int
init_statements
(
sqlite_backend
*
backend
)
{
static
const
char
*
sql_read
=
"SELECT type, size, data FROM '"
GIT2_TABLE_NAME
"' WHERE oid = ?;"
;
static
const
char
*
sql_read_header
=
"SELECT type, size FROM '"
GIT2_TABLE_NAME
"' WHERE oid = ?;"
;
static
const
char
*
sql_write
=
"INSERT OR IGNORE INTO '"
GIT2_TABLE_NAME
"' VALUES (?, ?, ?, ?);"
;
if
(
sqlite3_prepare_v2
(
backend
->
db
,
sql_read
,
-
1
,
&
backend
->
st_read
,
NULL
)
!=
SQLITE_OK
)
return
GIT_ERROR
;
if
(
sqlite3_prepare_v2
(
backend
->
db
,
sql_read_header
,
-
1
,
&
backend
->
st_read_header
,
NULL
)
!=
SQLITE_OK
)
return
GIT_ERROR
;
if
(
sqlite3_prepare_v2
(
backend
->
db
,
sql_write
,
-
1
,
&
backend
->
st_write
,
NULL
)
!=
SQLITE_OK
)
return
GIT_ERROR
;
return
GIT_SUCCESS
;
}
int
git_odb_backend_sqlite
(
git_odb_backend
**
backend_out
,
const
char
*
sqlite_db
)
{
sqlite_backend
*
backend
;
int
error
;
backend
=
git__calloc
(
1
,
sizeof
(
sqlite_backend
));
if
(
backend
==
NULL
)
return
GIT_ENOMEM
;
if
(
sqlite3_open
(
sqlite_db
,
&
backend
->
db
)
!=
SQLITE_OK
)
goto
cleanup
;
error
=
init_db
(
backend
->
db
);
if
(
error
<
0
)
goto
cleanup
;
error
=
init_statements
(
backend
);
if
(
error
<
0
)
goto
cleanup
;
backend
->
parent
.
read
=
&
sqlite_backend__read
;
backend
->
parent
.
read_header
=
&
sqlite_backend__read_header
;
backend
->
parent
.
write
=
&
sqlite_backend__write
;
backend
->
parent
.
exists
=
&
sqlite_backend__exists
;
backend
->
parent
.
free
=
&
sqlite_backend__free
;
backend
->
parent
.
priority
=
0
;
*
backend_out
=
(
git_odb_backend
*
)
backend
;
return
GIT_SUCCESS
;
cleanup:
sqlite_backend__free
((
git_odb_backend
*
)
backend
);
return
GIT_ERROR
;
}
#endif
/* HAVE_SQLITE3 */
src/git2/odb_backend.h
View file @
fb8dd803
...
...
@@ -66,6 +66,13 @@ struct git_odb_backend {
void
(
*
free
)(
struct
git_odb_backend
*
);
};
GIT_EXTERN
(
int
)
git_odb_backend_pack
(
git_odb_backend
**
backend_out
,
const
char
*
objects_dir
);
GIT_EXTERN
(
int
)
git_odb_backend_loose
(
git_odb_backend
**
backend_out
,
const
char
*
objects_dir
);
#ifdef GIT2_SQLITE_BACKEND
GIT_EXTERN
(
int
)
git_odb_backend_sqlite
(
git_odb_backend
**
backend_out
,
const
char
*
sqlite_db
);
#endif
GIT_END_DECL
#endif
src/t03-data.h
0 → 100644
View file @
fb8dd803
typedef
struct
object_data
{
char
*
id
;
/* object id (sha1) */
char
*
dir
;
/* object store (fan-out) directory name */
char
*
file
;
/* object store filename */
}
object_data
;
static
object_data
commit
=
{
"3d7f8a6af076c8c3f20071a8935cdbe8228594d1"
,
"test-objects/3d"
,
"test-objects/3d/7f8a6af076c8c3f20071a8935cdbe8228594d1"
,
};
static
unsigned
char
commit_data
[]
=
{
0x74
,
0x72
,
0x65
,
0x65
,
0x20
,
0x64
,
0x66
,
0x66
,
0x32
,
0x64
,
0x61
,
0x39
,
0x30
,
0x62
,
0x32
,
0x35
,
0x34
,
0x65
,
0x31
,
0x62
,
0x65
,
0x62
,
0x38
,
0x38
,
0x39
,
0x64
,
0x31
,
0x66
,
0x31
,
0x66
,
0x31
,
0x32
,
0x38
,
0x38
,
0x62
,
0x65
,
0x31
,
0x38
,
0x30
,
0x33
,
0x37
,
0x38
,
0x32
,
0x64
,
0x66
,
0x0a
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x41
,
0x20
,
0x55
,
0x20
,
0x54
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x3c
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x43
,
0x20
,
0x4f
,
0x20
,
0x4d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x3c
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x0a
,
0x41
,
0x20
,
0x6f
,
0x6e
,
0x65
,
0x2d
,
0x6c
,
0x69
,
0x6e
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x20
,
0x73
,
0x75
,
0x6d
,
0x6d
,
0x61
,
0x72
,
0x79
,
0x0a
,
0x0a
,
0x54
,
0x68
,
0x65
,
0x20
,
0x62
,
0x6f
,
0x64
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x20
,
0x6d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x2c
,
0x20
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x61
,
0x69
,
0x6e
,
0x69
,
0x6e
,
0x67
,
0x20
,
0x66
,
0x75
,
0x72
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x65
,
0x78
,
0x70
,
0x6c
,
0x61
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x0a
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x70
,
0x75
,
0x72
,
0x70
,
0x6f
,
0x73
,
0x65
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x68
,
0x61
,
0x6e
,
0x67
,
0x65
,
0x73
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x72
,
0x6f
,
0x64
,
0x75
,
0x63
,
0x65
,
0x64
,
0x20
,
0x62
,
0x79
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x2e
,
0x0a
,
0x0a
,
0x53
,
0x69
,
0x67
,
0x6e
,
0x65
,
0x64
,
0x2d
,
0x6f
,
0x66
,
0x2d
,
0x62
,
0x79
,
0x3a
,
0x20
,
0x41
,
0x20
,
0x55
,
0x20
,
0x54
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x3c
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x0a
,
};
static
git_rawobj
commit_obj
=
{
commit_data
,
sizeof
(
commit_data
),
GIT_OBJ_COMMIT
};
static
object_data
tree
=
{
"dff2da90b254e1beb889d1f1f1288be1803782df"
,
"test-objects/df"
,
"test-objects/df/f2da90b254e1beb889d1f1f1288be1803782df"
,
};
static
unsigned
char
tree_data
[]
=
{
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x6f
,
0x6e
,
0x65
,
0x00
,
0x8b
,
0x13
,
0x78
,
0x91
,
0x79
,
0x1f
,
0xe9
,
0x69
,
0x27
,
0xad
,
0x78
,
0xe6
,
0x4b
,
0x0a
,
0xad
,
0x7b
,
0xde
,
0xd0
,
0x8b
,
0xdc
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x73
,
0x6f
,
0x6d
,
0x65
,
0x00
,
0xfd
,
0x84
,
0x30
,
0xbc
,
0x86
,
0x4c
,
0xfc
,
0xd5
,
0xf1
,
0x0e
,
0x55
,
0x90
,
0xf8
,
0xa4
,
0x47
,
0xe0
,
0x1b
,
0x94
,
0x2b
,
0xfe
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x74
,
0x77
,
0x6f
,
0x00
,
0x78
,
0x98
,
0x19
,
0x22
,
0x61
,
0x3b
,
0x2a
,
0xfb
,
0x60
,
0x25
,
0x04
,
0x2f
,
0xf6
,
0xbd
,
0x87
,
0x8a
,
0xc1
,
0x99
,
0x4e
,
0x85
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x7a
,
0x65
,
0x72
,
0x6f
,
0x00
,
0xe6
,
0x9d
,
0xe2
,
0x9b
,
0xb2
,
0xd1
,
0xd6
,
0x43
,
0x4b
,
0x8b
,
0x29
,
0xae
,
0x77
,
0x5a
,
0xd8
,
0xc2
,
0xe4
,
0x8c
,
0x53
,
0x91
,
};
static
git_rawobj
tree_obj
=
{
tree_data
,
sizeof
(
tree_data
),
GIT_OBJ_TREE
};
static
object_data
tag
=
{
"09d373e1dfdc16b129ceec6dd649739911541e05"
,
"test-objects/09"
,
"test-objects/09/d373e1dfdc16b129ceec6dd649739911541e05"
,
};
static
unsigned
char
tag_data
[]
=
{
0x6f
,
0x62
,
0x6a
,
0x65
,
0x63
,
0x74
,
0x20
,
0x33
,
0x64
,
0x37
,
0x66
,
0x38
,
0x61
,
0x36
,
0x61
,
0x66
,
0x30
,
0x37
,
0x36
,
0x63
,
0x38
,
0x63
,
0x33
,
0x66
,
0x32
,
0x30
,
0x30
,
0x37
,
0x31
,
0x61
,
0x38
,
0x39
,
0x33
,
0x35
,
0x63
,
0x64
,
0x62
,
0x65
,
0x38
,
0x32
,
0x32
,
0x38
,
0x35
,
0x39
,
0x34
,
0x64
,
0x31
,
0x0a
,
0x74
,
0x79
,
0x70
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x0a
,
0x74
,
0x61
,
0x67
,
0x20
,
0x76
,
0x30
,
0x2e
,
0x30
,
0x2e
,
0x31
,
0x0a
,
0x74
,
0x61
,
0x67
,
0x67
,
0x65
,
0x72
,
0x20
,
0x43
,
0x20
,
0x4f
,
0x20
,
0x4d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x3c
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x0a
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x61
,
0x67
,
0x20
,
0x6f
,
0x62
,
0x6a
,
0x65
,
0x63
,
0x74
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x72
,
0x65
,
0x6c
,
0x65
,
0x61
,
0x73
,
0x65
,
0x20
,
0x76
,
0x30
,
0x2e
,
0x30
,
0x2e
,
0x31
,
0x0a
,
};
static
git_rawobj
tag_obj
=
{
tag_data
,
sizeof
(
tag_data
),
GIT_OBJ_TAG
};
static
object_data
zero
=
{
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
,
"test-objects/e6"
,
"test-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391"
,
};
static
unsigned
char
zero_data
[]
=
{
0x00
/* dummy data */
};
static
git_rawobj
zero_obj
=
{
zero_data
,
0
,
GIT_OBJ_BLOB
};
static
object_data
one
=
{
"8b137891791fe96927ad78e64b0aad7bded08bdc"
,
"test-objects/8b"
,
"test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc"
,
};
static
unsigned
char
one_data
[]
=
{
0x0a
,
};
static
git_rawobj
one_obj
=
{
one_data
,
sizeof
(
one_data
),
GIT_OBJ_BLOB
};
static
object_data
two
=
{
"78981922613b2afb6025042ff6bd878ac1994e85"
,
"test-objects/78"
,
"test-objects/78/981922613b2afb6025042ff6bd878ac1994e85"
,
};
static
unsigned
char
two_data
[]
=
{
0x61
,
0x0a
,
};
static
git_rawobj
two_obj
=
{
two_data
,
sizeof
(
two_data
),
GIT_OBJ_BLOB
};
static
object_data
some
=
{
"fd8430bc864cfcd5f10e5590f8a447e01b942bfe"
,
"test-objects/fd"
,
"test-objects/fd/8430bc864cfcd5f10e5590f8a447e01b942bfe"
,
};
static
unsigned
char
some_data
[]
=
{
0x2f
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x73
,
0x20
,
0x66
,
0x72
,
0x65
,
0x65
,
0x20
,
0x73
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x3b
,
0x20
,
0x79
,
0x6f
,
0x75
,
0x20
,
0x63
,
0x61
,
0x6e
,
0x20
,
0x72
,
0x65
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x20
,
0x69
,
0x74
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x2f
,
0x6f
,
0x72
,
0x20
,
0x6d
,
0x6f
,
0x64
,
0x69
,
0x66
,
0x79
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x69
,
0x74
,
0x20
,
0x75
,
0x6e
,
0x64
,
0x65
,
0x72
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x65
,
0x72
,
0x6d
,
0x73
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x2c
,
0x20
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x32
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x73
,
0x20
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x73
,
0x68
,
0x65
,
0x64
,
0x20
,
0x62
,
0x79
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x46
,
0x72
,
0x65
,
0x65
,
0x20
,
0x53
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x20
,
0x46
,
0x6f
,
0x75
,
0x6e
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x49
,
0x6e
,
0x20
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x70
,
0x65
,
0x72
,
0x6d
,
0x69
,
0x73
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x73
,
0x20
,
0x67
,
0x69
,
0x76
,
0x65
,
0x20
,
0x79
,
0x6f
,
0x75
,
0x20
,
0x75
,
0x6e
,
0x6c
,
0x69
,
0x6d
,
0x69
,
0x74
,
0x65
,
0x64
,
0x20
,
0x70
,
0x65
,
0x72
,
0x6d
,
0x69
,
0x73
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x70
,
0x69
,
0x6c
,
0x65
,
0x64
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x6f
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x20
,
0x6f
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x70
,
0x72
,
0x6f
,
0x67
,
0x72
,
0x61
,
0x6d
,
0x73
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x20
,
0x74
,
0x68
,
0x6f
,
0x73
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x6f
,
0x75
,
0x74
,
0x20
,
0x61
,
0x6e
,
0x79
,
0x20
,
0x72
,
0x65
,
0x73
,
0x74
,
0x72
,
0x69
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x69
,
0x6e
,
0x67
,
0x20
,
0x66
,
0x72
,
0x6f
,
0x6d
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x75
,
0x73
,
0x65
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x2e
,
0x20
,
0x20
,
0x28
,
0x54
,
0x68
,
0x65
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x72
,
0x65
,
0x73
,
0x74
,
0x72
,
0x69
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x64
,
0x6f
,
0x20
,
0x61
,
0x70
,
0x70
,
0x6c
,
0x79
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x6f
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x72
,
0x65
,
0x73
,
0x70
,
0x65
,
0x63
,
0x74
,
0x73
,
0x3b
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2c
,
0x20
,
0x74
,
0x68
,
0x65
,
0x79
,
0x20
,
0x63
,
0x6f
,
0x76
,
0x65
,
0x72
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x6d
,
0x6f
,
0x64
,
0x69
,
0x66
,
0x69
,
0x63
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x2c
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x77
,
0x68
,
0x65
,
0x6e
,
0x20
,
0x6e
,
0x6f
,
0x74
,
0x20
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x65
,
0x64
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x6f
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x65
,
0x64
,
0x20
,
0x65
,
0x78
,
0x65
,
0x63
,
0x75
,
0x74
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x2e
,
0x29
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x73
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x64
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x68
,
0x6f
,
0x70
,
0x65
,
0x20
,
0x74
,
0x68
,
0x61
,
0x74
,
0x20
,
0x69
,
0x74
,
0x20
,
0x77
,
0x69
,
0x6c
,
0x6c
,
0x20
,
0x62
,
0x65
,
0x20
,
0x75
,
0x73
,
0x65
,
0x66
,
0x75
,
0x6c
,
0x2c
,
0x20
,
0x62
,
0x75
,
0x74
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x57
,
0x49
,
0x54
,
0x48
,
0x4f
,
0x55
,
0x54
,
0x20
,
0x41
,
0x4e
,
0x59
,
0x20
,
0x57
,
0x41
,
0x52
,
0x52
,
0x41
,
0x4e
,
0x54
,
0x59
,
0x3b
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x6f
,
0x75
,
0x74
,
0x20
,
0x65
,
0x76
,
0x65
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x69
,
0x6d
,
0x70
,
0x6c
,
0x69
,
0x65
,
0x64
,
0x20
,
0x77
,
0x61
,
0x72
,
0x72
,
0x61
,
0x6e
,
0x74
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x4d
,
0x45
,
0x52
,
0x43
,
0x48
,
0x41
,
0x4e
,
0x54
,
0x41
,
0x42
,
0x49
,
0x4c
,
0x49
,
0x54
,
0x59
,
0x20
,
0x6f
,
0x72
,
0x20
,
0x46
,
0x49
,
0x54
,
0x4e
,
0x45
,
0x53
,
0x53
,
0x20
,
0x46
,
0x4f
,
0x52
,
0x20
,
0x41
,
0x20
,
0x50
,
0x41
,
0x52
,
0x54
,
0x49
,
0x43
,
0x55
,
0x4c
,
0x41
,
0x52
,
0x20
,
0x50
,
0x55
,
0x52
,
0x50
,
0x4f
,
0x53
,
0x45
,
0x2e
,
0x20
,
0x20
,
0x53
,
0x65
,
0x65
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x6d
,
0x6f
,
0x72
,
0x65
,
0x20
,
0x64
,
0x65
,
0x74
,
0x61
,
0x69
,
0x6c
,
0x73
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x59
,
0x6f
,
0x75
,
0x20
,
0x73
,
0x68
,
0x6f
,
0x75
,
0x6c
,
0x64
,
0x20
,
0x68
,
0x61
,
0x76
,
0x65
,
0x20
,
0x72
,
0x65
,
0x63
,
0x65
,
0x69
,
0x76
,
0x65
,
0x64
,
0x20
,
0x61
,
0x20
,
0x63
,
0x6f
,
0x70
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x6c
,
0x6f
,
0x6e
,
0x67
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x70
,
0x72
,
0x6f
,
0x67
,
0x72
,
0x61
,
0x6d
,
0x3b
,
0x20
,
0x73
,
0x65
,
0x65
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x43
,
0x4f
,
0x50
,
0x59
,
0x49
,
0x4e
,
0x47
,
0x2e
,
0x20
,
0x20
,
0x49
,
0x66
,
0x20
,
0x6e
,
0x6f
,
0x74
,
0x2c
,
0x20
,
0x77
,
0x72
,
0x69
,
0x74
,
0x65
,
0x20
,
0x74
,
0x6f
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x46
,
0x72
,
0x65
,
0x65
,
0x20
,
0x53
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x20
,
0x46
,
0x6f
,
0x75
,
0x6e
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x2c
,
0x20
,
0x35
,
0x31
,
0x20
,
0x46
,
0x72
,
0x61
,
0x6e
,
0x6b
,
0x6c
,
0x69
,
0x6e
,
0x20
,
0x53
,
0x74
,
0x72
,
0x65
,
0x65
,
0x74
,
0x2c
,
0x20
,
0x46
,
0x69
,
0x66
,
0x74
,
0x68
,
0x20
,
0x46
,
0x6c
,
0x6f
,
0x6f
,
0x72
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x42
,
0x6f
,
0x73
,
0x74
,
0x6f
,
0x6e
,
0x2c
,
0x20
,
0x4d
,
0x41
,
0x20
,
0x30
,
0x32
,
0x31
,
0x31
,
0x30
,
0x2d
,
0x31
,
0x33
,
0x30
,
0x31
,
0x2c
,
0x20
,
0x55
,
0x53
,
0x41
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x2f
,
0x0a
,
};
static
git_rawobj
some_obj
=
{
some_data
,
sizeof
(
some_data
),
GIT_OBJ_BLOB
};
tests/t03-objwrite.c
View file @
fb8dd803
...
...
@@ -23,354 +23,10 @@
* Boston, MA 02110-1301, USA.
*/
#include "test_lib.h"
#include "fileops.h"
static
char
*
odb_dir
=
"test-objects"
;
typedef
struct
object_data
{
char
*
id
;
/* object id (sha1) */
char
*
dir
;
/* object store (fan-out) directory name */
char
*
file
;
/* object store filename */
}
object_data
;
static
object_data
commit
=
{
"3d7f8a6af076c8c3f20071a8935cdbe8228594d1"
,
"test-objects/3d"
,
"test-objects/3d/7f8a6af076c8c3f20071a8935cdbe8228594d1"
,
};
static
unsigned
char
commit_data
[]
=
{
0x74
,
0x72
,
0x65
,
0x65
,
0x20
,
0x64
,
0x66
,
0x66
,
0x32
,
0x64
,
0x61
,
0x39
,
0x30
,
0x62
,
0x32
,
0x35
,
0x34
,
0x65
,
0x31
,
0x62
,
0x65
,
0x62
,
0x38
,
0x38
,
0x39
,
0x64
,
0x31
,
0x66
,
0x31
,
0x66
,
0x31
,
0x32
,
0x38
,
0x38
,
0x62
,
0x65
,
0x31
,
0x38
,
0x30
,
0x33
,
0x37
,
0x38
,
0x32
,
0x64
,
0x66
,
0x0a
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x41
,
0x20
,
0x55
,
0x20
,
0x54
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x3c
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x43
,
0x20
,
0x4f
,
0x20
,
0x4d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x3c
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x0a
,
0x41
,
0x20
,
0x6f
,
0x6e
,
0x65
,
0x2d
,
0x6c
,
0x69
,
0x6e
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x20
,
0x73
,
0x75
,
0x6d
,
0x6d
,
0x61
,
0x72
,
0x79
,
0x0a
,
0x0a
,
0x54
,
0x68
,
0x65
,
0x20
,
0x62
,
0x6f
,
0x64
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x20
,
0x6d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x2c
,
0x20
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x61
,
0x69
,
0x6e
,
0x69
,
0x6e
,
0x67
,
0x20
,
0x66
,
0x75
,
0x72
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x65
,
0x78
,
0x70
,
0x6c
,
0x61
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x0a
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x70
,
0x75
,
0x72
,
0x70
,
0x6f
,
0x73
,
0x65
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x68
,
0x61
,
0x6e
,
0x67
,
0x65
,
0x73
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x72
,
0x6f
,
0x64
,
0x75
,
0x63
,
0x65
,
0x64
,
0x20
,
0x62
,
0x79
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x2e
,
0x0a
,
0x0a
,
0x53
,
0x69
,
0x67
,
0x6e
,
0x65
,
0x64
,
0x2d
,
0x6f
,
0x66
,
0x2d
,
0x62
,
0x79
,
0x3a
,
0x20
,
0x41
,
0x20
,
0x55
,
0x20
,
0x54
,
0x68
,
0x6f
,
0x72
,
0x20
,
0x3c
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x0a
,
};
static
git_rawobj
commit_obj
=
{
commit_data
,
sizeof
(
commit_data
),
GIT_OBJ_COMMIT
};
static
object_data
tree
=
{
"dff2da90b254e1beb889d1f1f1288be1803782df"
,
"test-objects/df"
,
"test-objects/df/f2da90b254e1beb889d1f1f1288be1803782df"
,
};
static
unsigned
char
tree_data
[]
=
{
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x6f
,
0x6e
,
0x65
,
0x00
,
0x8b
,
0x13
,
0x78
,
0x91
,
0x79
,
0x1f
,
0xe9
,
0x69
,
0x27
,
0xad
,
0x78
,
0xe6
,
0x4b
,
0x0a
,
0xad
,
0x7b
,
0xde
,
0xd0
,
0x8b
,
0xdc
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x73
,
0x6f
,
0x6d
,
0x65
,
0x00
,
0xfd
,
0x84
,
0x30
,
0xbc
,
0x86
,
0x4c
,
0xfc
,
0xd5
,
0xf1
,
0x0e
,
0x55
,
0x90
,
0xf8
,
0xa4
,
0x47
,
0xe0
,
0x1b
,
0x94
,
0x2b
,
0xfe
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x74
,
0x77
,
0x6f
,
0x00
,
0x78
,
0x98
,
0x19
,
0x22
,
0x61
,
0x3b
,
0x2a
,
0xfb
,
0x60
,
0x25
,
0x04
,
0x2f
,
0xf6
,
0xbd
,
0x87
,
0x8a
,
0xc1
,
0x99
,
0x4e
,
0x85
,
0x31
,
0x30
,
0x30
,
0x36
,
0x34
,
0x34
,
0x20
,
0x7a
,
0x65
,
0x72
,
0x6f
,
0x00
,
0xe6
,
0x9d
,
0xe2
,
0x9b
,
0xb2
,
0xd1
,
0xd6
,
0x43
,
0x4b
,
0x8b
,
0x29
,
0xae
,
0x77
,
0x5a
,
0xd8
,
0xc2
,
0xe4
,
0x8c
,
0x53
,
0x91
,
};
static
git_rawobj
tree_obj
=
{
tree_data
,
sizeof
(
tree_data
),
GIT_OBJ_TREE
};
static
object_data
tag
=
{
"09d373e1dfdc16b129ceec6dd649739911541e05"
,
"test-objects/09"
,
"test-objects/09/d373e1dfdc16b129ceec6dd649739911541e05"
,
};
static
unsigned
char
tag_data
[]
=
{
0x6f
,
0x62
,
0x6a
,
0x65
,
0x63
,
0x74
,
0x20
,
0x33
,
0x64
,
0x37
,
0x66
,
0x38
,
0x61
,
0x36
,
0x61
,
0x66
,
0x30
,
0x37
,
0x36
,
0x63
,
0x38
,
0x63
,
0x33
,
0x66
,
0x32
,
0x30
,
0x30
,
0x37
,
0x31
,
0x61
,
0x38
,
0x39
,
0x33
,
0x35
,
0x63
,
0x64
,
0x62
,
0x65
,
0x38
,
0x32
,
0x32
,
0x38
,
0x35
,
0x39
,
0x34
,
0x64
,
0x31
,
0x0a
,
0x74
,
0x79
,
0x70
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x0a
,
0x74
,
0x61
,
0x67
,
0x20
,
0x76
,
0x30
,
0x2e
,
0x30
,
0x2e
,
0x31
,
0x0a
,
0x74
,
0x61
,
0x67
,
0x67
,
0x65
,
0x72
,
0x20
,
0x43
,
0x20
,
0x4f
,
0x20
,
0x4d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x20
,
0x3c
,
0x63
,
0x6f
,
0x6d
,
0x6d
,
0x69
,
0x74
,
0x74
,
0x65
,
0x72
,
0x40
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x3e
,
0x20
,
0x31
,
0x32
,
0x32
,
0x37
,
0x38
,
0x31
,
0x34
,
0x32
,
0x39
,
0x37
,
0x20
,
0x2b
,
0x30
,
0x30
,
0x30
,
0x30
,
0x0a
,
0x0a
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x61
,
0x67
,
0x20
,
0x6f
,
0x62
,
0x6a
,
0x65
,
0x63
,
0x74
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x72
,
0x65
,
0x6c
,
0x65
,
0x61
,
0x73
,
0x65
,
0x20
,
0x76
,
0x30
,
0x2e
,
0x30
,
0x2e
,
0x31
,
0x0a
,
};
static
git_rawobj
tag_obj
=
{
tag_data
,
sizeof
(
tag_data
),
GIT_OBJ_TAG
};
static
object_data
zero
=
{
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
,
"test-objects/e6"
,
"test-objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391"
,
};
static
unsigned
char
zero_data
[]
=
{
0x00
/* dummy data */
};
static
git_rawobj
zero_obj
=
{
zero_data
,
0
,
GIT_OBJ_BLOB
};
static
object_data
one
=
{
"8b137891791fe96927ad78e64b0aad7bded08bdc"
,
"test-objects/8b"
,
"test-objects/8b/137891791fe96927ad78e64b0aad7bded08bdc"
,
};
static
unsigned
char
one_data
[]
=
{
0x0a
,
};
static
git_rawobj
one_obj
=
{
one_data
,
sizeof
(
one_data
),
GIT_OBJ_BLOB
};
static
object_data
two
=
{
"78981922613b2afb6025042ff6bd878ac1994e85"
,
"test-objects/78"
,
"test-objects/78/981922613b2afb6025042ff6bd878ac1994e85"
,
};
static
unsigned
char
two_data
[]
=
{
0x61
,
0x0a
,
};
static
git_rawobj
two_obj
=
{
two_data
,
sizeof
(
two_data
),
GIT_OBJ_BLOB
};
static
object_data
some
=
{
"fd8430bc864cfcd5f10e5590f8a447e01b942bfe"
,
"test-objects/fd"
,
"test-objects/fd/8430bc864cfcd5f10e5590f8a447e01b942bfe"
,
};
static
unsigned
char
some_data
[]
=
{
0x2f
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x73
,
0x20
,
0x66
,
0x72
,
0x65
,
0x65
,
0x20
,
0x73
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x3b
,
0x20
,
0x79
,
0x6f
,
0x75
,
0x20
,
0x63
,
0x61
,
0x6e
,
0x20
,
0x72
,
0x65
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x20
,
0x69
,
0x74
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x2f
,
0x6f
,
0x72
,
0x20
,
0x6d
,
0x6f
,
0x64
,
0x69
,
0x66
,
0x79
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x69
,
0x74
,
0x20
,
0x75
,
0x6e
,
0x64
,
0x65
,
0x72
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x65
,
0x72
,
0x6d
,
0x73
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x2c
,
0x20
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x32
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x73
,
0x20
,
0x70
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x73
,
0x68
,
0x65
,
0x64
,
0x20
,
0x62
,
0x79
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x46
,
0x72
,
0x65
,
0x65
,
0x20
,
0x53
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x20
,
0x46
,
0x6f
,
0x75
,
0x6e
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x49
,
0x6e
,
0x20
,
0x61
,
0x64
,
0x64
,
0x69
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x70
,
0x65
,
0x72
,
0x6d
,
0x69
,
0x73
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x61
,
0x75
,
0x74
,
0x68
,
0x6f
,
0x72
,
0x73
,
0x20
,
0x67
,
0x69
,
0x76
,
0x65
,
0x20
,
0x79
,
0x6f
,
0x75
,
0x20
,
0x75
,
0x6e
,
0x6c
,
0x69
,
0x6d
,
0x69
,
0x74
,
0x65
,
0x64
,
0x20
,
0x70
,
0x65
,
0x72
,
0x6d
,
0x69
,
0x73
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x70
,
0x69
,
0x6c
,
0x65
,
0x64
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x76
,
0x65
,
0x72
,
0x73
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x6f
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x20
,
0x6f
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x70
,
0x72
,
0x6f
,
0x67
,
0x72
,
0x61
,
0x6d
,
0x73
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x20
,
0x74
,
0x6f
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x20
,
0x74
,
0x68
,
0x6f
,
0x73
,
0x65
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x6f
,
0x75
,
0x74
,
0x20
,
0x61
,
0x6e
,
0x79
,
0x20
,
0x72
,
0x65
,
0x73
,
0x74
,
0x72
,
0x69
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x69
,
0x6e
,
0x67
,
0x20
,
0x66
,
0x72
,
0x6f
,
0x6d
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x75
,
0x73
,
0x65
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x2e
,
0x20
,
0x20
,
0x28
,
0x54
,
0x68
,
0x65
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x72
,
0x65
,
0x73
,
0x74
,
0x72
,
0x69
,
0x63
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x20
,
0x64
,
0x6f
,
0x20
,
0x61
,
0x70
,
0x70
,
0x6c
,
0x79
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x6f
,
0x74
,
0x68
,
0x65
,
0x72
,
0x20
,
0x72
,
0x65
,
0x73
,
0x70
,
0x65
,
0x63
,
0x74
,
0x73
,
0x3b
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x65
,
0x78
,
0x61
,
0x6d
,
0x70
,
0x6c
,
0x65
,
0x2c
,
0x20
,
0x74
,
0x68
,
0x65
,
0x79
,
0x20
,
0x63
,
0x6f
,
0x76
,
0x65
,
0x72
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x6d
,
0x6f
,
0x64
,
0x69
,
0x66
,
0x69
,
0x63
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x2c
,
0x20
,
0x61
,
0x6e
,
0x64
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x20
,
0x77
,
0x68
,
0x65
,
0x6e
,
0x20
,
0x6e
,
0x6f
,
0x74
,
0x20
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x65
,
0x64
,
0x20
,
0x69
,
0x6e
,
0x74
,
0x6f
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x20
,
0x63
,
0x6f
,
0x6d
,
0x62
,
0x69
,
0x6e
,
0x65
,
0x64
,
0x20
,
0x65
,
0x78
,
0x65
,
0x63
,
0x75
,
0x74
,
0x61
,
0x62
,
0x6c
,
0x65
,
0x2e
,
0x29
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x54
,
0x68
,
0x69
,
0x73
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x69
,
0x73
,
0x20
,
0x64
,
0x69
,
0x73
,
0x74
,
0x72
,
0x69
,
0x62
,
0x75
,
0x74
,
0x65
,
0x64
,
0x20
,
0x69
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x68
,
0x6f
,
0x70
,
0x65
,
0x20
,
0x74
,
0x68
,
0x61
,
0x74
,
0x20
,
0x69
,
0x74
,
0x20
,
0x77
,
0x69
,
0x6c
,
0x6c
,
0x20
,
0x62
,
0x65
,
0x20
,
0x75
,
0x73
,
0x65
,
0x66
,
0x75
,
0x6c
,
0x2c
,
0x20
,
0x62
,
0x75
,
0x74
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x57
,
0x49
,
0x54
,
0x48
,
0x4f
,
0x55
,
0x54
,
0x20
,
0x41
,
0x4e
,
0x59
,
0x20
,
0x57
,
0x41
,
0x52
,
0x52
,
0x41
,
0x4e
,
0x54
,
0x59
,
0x3b
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x6f
,
0x75
,
0x74
,
0x20
,
0x65
,
0x76
,
0x65
,
0x6e
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x69
,
0x6d
,
0x70
,
0x6c
,
0x69
,
0x65
,
0x64
,
0x20
,
0x77
,
0x61
,
0x72
,
0x72
,
0x61
,
0x6e
,
0x74
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x4d
,
0x45
,
0x52
,
0x43
,
0x48
,
0x41
,
0x4e
,
0x54
,
0x41
,
0x42
,
0x49
,
0x4c
,
0x49
,
0x54
,
0x59
,
0x20
,
0x6f
,
0x72
,
0x20
,
0x46
,
0x49
,
0x54
,
0x4e
,
0x45
,
0x53
,
0x53
,
0x20
,
0x46
,
0x4f
,
0x52
,
0x20
,
0x41
,
0x20
,
0x50
,
0x41
,
0x52
,
0x54
,
0x49
,
0x43
,
0x55
,
0x4c
,
0x41
,
0x52
,
0x20
,
0x50
,
0x55
,
0x52
,
0x50
,
0x4f
,
0x53
,
0x45
,
0x2e
,
0x20
,
0x20
,
0x53
,
0x65
,
0x65
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x6d
,
0x6f
,
0x72
,
0x65
,
0x20
,
0x64
,
0x65
,
0x74
,
0x61
,
0x69
,
0x6c
,
0x73
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x59
,
0x6f
,
0x75
,
0x20
,
0x73
,
0x68
,
0x6f
,
0x75
,
0x6c
,
0x64
,
0x20
,
0x68
,
0x61
,
0x76
,
0x65
,
0x20
,
0x72
,
0x65
,
0x63
,
0x65
,
0x69
,
0x76
,
0x65
,
0x64
,
0x20
,
0x61
,
0x20
,
0x63
,
0x6f
,
0x70
,
0x79
,
0x20
,
0x6f
,
0x66
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x47
,
0x4e
,
0x55
,
0x20
,
0x47
,
0x65
,
0x6e
,
0x65
,
0x72
,
0x61
,
0x6c
,
0x20
,
0x50
,
0x75
,
0x62
,
0x6c
,
0x69
,
0x63
,
0x20
,
0x4c
,
0x69
,
0x63
,
0x65
,
0x6e
,
0x73
,
0x65
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x61
,
0x6c
,
0x6f
,
0x6e
,
0x67
,
0x20
,
0x77
,
0x69
,
0x74
,
0x68
,
0x20
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x70
,
0x72
,
0x6f
,
0x67
,
0x72
,
0x61
,
0x6d
,
0x3b
,
0x20
,
0x73
,
0x65
,
0x65
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x66
,
0x69
,
0x6c
,
0x65
,
0x20
,
0x43
,
0x4f
,
0x50
,
0x59
,
0x49
,
0x4e
,
0x47
,
0x2e
,
0x20
,
0x20
,
0x49
,
0x66
,
0x20
,
0x6e
,
0x6f
,
0x74
,
0x2c
,
0x20
,
0x77
,
0x72
,
0x69
,
0x74
,
0x65
,
0x20
,
0x74
,
0x6f
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x46
,
0x72
,
0x65
,
0x65
,
0x20
,
0x53
,
0x6f
,
0x66
,
0x74
,
0x77
,
0x61
,
0x72
,
0x65
,
0x20
,
0x46
,
0x6f
,
0x75
,
0x6e
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x2c
,
0x20
,
0x35
,
0x31
,
0x20
,
0x46
,
0x72
,
0x61
,
0x6e
,
0x6b
,
0x6c
,
0x69
,
0x6e
,
0x20
,
0x53
,
0x74
,
0x72
,
0x65
,
0x65
,
0x74
,
0x2c
,
0x20
,
0x46
,
0x69
,
0x66
,
0x74
,
0x68
,
0x20
,
0x46
,
0x6c
,
0x6f
,
0x6f
,
0x72
,
0x2c
,
0x0a
,
0x20
,
0x2a
,
0x20
,
0x42
,
0x6f
,
0x73
,
0x74
,
0x6f
,
0x6e
,
0x2c
,
0x20
,
0x4d
,
0x41
,
0x20
,
0x30
,
0x32
,
0x31
,
0x31
,
0x30
,
0x2d
,
0x31
,
0x33
,
0x30
,
0x31
,
0x2c
,
0x20
,
0x55
,
0x53
,
0x41
,
0x2e
,
0x0a
,
0x20
,
0x2a
,
0x2f
,
0x0a
,
};
static
git_rawobj
some_obj
=
{
some_data
,
sizeof
(
some_data
),
GIT_OBJ_BLOB
};
#include "t03-data.h"
static
int
make_odb_dir
(
void
)
{
...
...
tests/t11-sqlite.c
0 → 100644
View file @
fb8dd803
/*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* as published by the Free Software Foundation.
*
* In addition to the permissions in the GNU General Public License,
* the authors give you unlimited permission to link the compiled
* version of this file into combinations with other programs,
* and to distribute those combinations without any restriction
* coming from the use of this file. (The General Public License
* restrictions do apply in other respects; for example, they cover
* modification of the file, and distribution when not linked into
* a combined executable.)
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "test_lib.h"
#include "t03-data.h"
#include "fileops.h"
#include "git2/odb_backend.h"
static
int
cmp_objects
(
git_rawobj
*
o1
,
git_rawobj
*
o2
)
{
if
(
o1
->
type
!=
o2
->
type
)
return
-
1
;
if
(
o1
->
len
!=
o2
->
len
)
return
-
1
;
if
((
o1
->
len
>
0
)
&&
(
memcmp
(
o1
->
data
,
o2
->
data
,
o1
->
len
)
!=
0
))
return
-
1
;
return
0
;
}
static
git_odb
*
open_sqlite_odb
(
void
)
{
#ifdef GIT2_SQLITE_BACKEND
git_odb
*
odb
;
git_odb_backend
*
sqlite
;
if
(
git_odb_new
(
&
odb
)
<
GIT_SUCCESS
)
return
NULL
;
if
(
git_odb_backend_sqlite
(
&
sqlite
,
":memory"
)
<
GIT_SUCCESS
)
return
NULL
;
if
(
git_odb_add_backend
(
odb
,
sqlite
)
<
GIT_SUCCESS
)
return
NULL
;
return
odb
;
#else
return
NULL
;
#endif
}
#define TEST_WRITE(PTR) {\
git_odb *db; \
git_oid id1, id2; \
git_rawobj obj; \
db = open_sqlite_odb(); \
must_be_true(db != NULL); \
must_pass(git_oid_mkstr(&id1, PTR.id)); \
must_pass(git_odb_write(&id2, db, &PTR##_obj)); \
must_be_true(git_oid_cmp(&id1, &id2) == 0); \
must_pass(git_odb_read(&obj, db, &id1)); \
must_pass(cmp_objects(&obj, &PTR##_obj)); \
git_rawobj_close(&obj); \
git_odb_close(db); \
}
BEGIN_TEST
(
"sqlite"
,
sql_write_commit
)
TEST_WRITE
(
commit
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_tree
)
TEST_WRITE
(
tree
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_tag
)
TEST_WRITE
(
tag
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_zero
)
TEST_WRITE
(
zero
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_one
)
TEST_WRITE
(
one
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_two
)
TEST_WRITE
(
two
);
END_TEST
BEGIN_TEST
(
"sqlite"
,
sql_write_some
)
TEST_WRITE
(
some
);
END_TEST
git_testsuite
*
libgit2_suite_sqlite
(
void
)
{
git_testsuite
*
suite
=
git_testsuite_new
(
"SQLite Backend"
);
#ifdef GIT2_SQLITE_BACKEND
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_commit
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_tree
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_tag
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_zero
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_one
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_two
);
ADD_TEST
(
suite
,
"sqlite"
,
sql_write_some
);
#endif
return
suite
;
}
tests/test_main.c
View file @
fb8dd803
...
...
@@ -40,6 +40,7 @@ extern git_testsuite *libgit2_suite_hashtable(void);
extern
git_testsuite
*
libgit2_suite_tag
(
void
);
extern
git_testsuite
*
libgit2_suite_tree
(
void
);
extern
git_testsuite
*
libgit2_suite_refs
(
void
);
extern
git_testsuite
*
libgit2_suite_sqlite
(
void
);
typedef
git_testsuite
*
(
*
libgit2_suite
)(
void
);
...
...
@@ -54,7 +55,8 @@ static libgit2_suite suite_methods[]= {
libgit2_suite_hashtable
,
libgit2_suite_tag
,
libgit2_suite_tree
,
libgit2_suite_refs
libgit2_suite_refs
,
libgit2_suite_sqlite
,
};
#define GIT_SUITE_COUNT (ARRAY_SIZE(suite_methods))
...
...
wscript
View file @
fb8dd803
...
...
@@ -16,7 +16,7 @@ CFLAGS_WIN32_L = ['/RELEASE'] # used for /both/ debug and release builds.
# sets the module's checksum in the header.
CFLAGS_WIN32_L_DBG = ['/DEBUG']
ALL_LIBS = ['z', 'crypto', 'pthread']
ALL_LIBS = ['z', 'crypto', 'pthread'
, 'sqlite3'
]
def options(opt):
opt.load('compiler_c')
...
...
@@ -58,13 +58,17 @@ def configure(conf):
zlib_name = 'zlibwapi'
elif conf.env.CC_NAME == 'gcc':
conf.check
(features='c cprogram',
lib='pthread', uselib_store='pthread')
conf.check
_cc(
lib='pthread', uselib_store='pthread')
else:
conf.env.PLATFORM = 'unix'
# check for Z lib
conf.check(features='c cprogram', lib=zlib_name, uselib_store='z', install_path=None)
conf.check_cc(lib=zlib_name, uselib_store='z', install_path=None)
# check for sqlite3
if conf.check_cc(lib='sqlite3', uselib_store='sqlite3', install_path=None, mandatory=False):
conf.env.DEFINES += ['GIT2_SQLITE_BACKEND']
if conf.options.sha1 not in ['openssl', 'ppc', 'builtin']:
ctx.fatal('Invalid SHA1 option')
...
...
@@ -115,6 +119,7 @@ def build_library(bld, build_type):
# E.g. src/unix/*.c
# src/win32/*.c
sources = sources + directory.ant_glob('src/%s/*.c' % bld.env.PLATFORM)
sources = sources + directory.ant_glob('src/backends/*.c')
# SHA1 methods source
if bld.env.sha1 == "ppc":
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment