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
0e5243b7
Unverified
Commit
0e5243b7
authored
Nov 28, 2019
by
Patrick Steinhardt
Committed by
GitHub
Nov 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5123 from libgit2/ethomson/off_t
Move `git_off_t` to `git_object_size_t`
parents
7198d345
6460e8ab
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
211 additions
and
178 deletions
+211
-178
examples/blame.c
+1
-1
include/git2/blob.h
+1
-1
include/git2/diff.h
+6
-6
include/git2/object.h
+2
-0
include/git2/odb.h
+1
-1
include/git2/odb_backend.h
+2
-2
include/git2/sys/odb_backend.h
+1
-1
include/git2/types.h
+3
-0
src/attr_file.c
+1
-1
src/blame.c
+9
-2
src/blame.h
+1
-1
src/blob.c
+8
-8
src/blob.h
+1
-1
src/crlf.c
+1
-1
src/diff_file.c
+5
-3
src/diff_file.h
+1
-1
src/diff_generate.c
+2
-2
src/diff_generate.h
+2
-2
src/diff_stats.c
+1
-1
src/diff_tform.c
+1
-1
src/filter.c
+1
-1
src/futils.c
+14
-10
src/futils.h
+3
-3
src/indexer.c
+19
-19
src/integer.h
+4
-4
src/map.h
+1
-1
src/merge.c
+1
-1
src/mwindow.c
+9
-9
src/mwindow.h
+4
-4
src/notes.c
+1
-1
src/object.h
+2
-0
src/odb.c
+18
-12
src/odb.h
+1
-1
src/odb_loose.c
+2
-2
src/offmap.c
+7
-7
src/offmap.h
+7
-7
src/pack-objects.h
+1
-1
src/pack.c
+27
-27
src/pack.h
+11
-11
src/patch_parse.c
+2
-2
src/posix.c
+1
-1
src/posix.h
+12
-0
src/reader.c
+1
-1
src/repository.c
+2
-5
src/unix/map.c
+1
-1
src/win32/map.c
+3
-5
src/win32/posix.h
+1
-1
src/win32/posix_w32.c
+1
-1
src/win32/w32_util.h
+1
-1
tests/core/ftruncate.c
+1
-1
tests/index/tests.c
+1
-1
tests/object/blob/filter.c
+1
-1
No files found.
examples/blame.c
View file @
0e5243b7
...
...
@@ -33,7 +33,7 @@ static void parse_opts(struct opts *o, int argc, char *argv[]);
int
lg2_blame
(
git_repository
*
repo
,
int
argc
,
char
*
argv
[])
{
int
line
,
break_on_null_hunk
;
git_o
ff
_t
i
,
rawsize
;
git_o
bject_size
_t
i
,
rawsize
;
char
spec
[
1024
]
=
{
0
};
struct
opts
o
=
{
0
};
const
char
*
rawdata
;
...
...
include/git2/blob.h
View file @
0e5243b7
...
...
@@ -94,7 +94,7 @@ GIT_EXTERN(const void *) git_blob_rawcontent(const git_blob *blob);
* @param blob pointer to the blob
* @return size on bytes
*/
GIT_EXTERN
(
git_o
ff
_t
)
git_blob_rawsize
(
const
git_blob
*
blob
);
GIT_EXTERN
(
git_o
bject_size
_t
)
git_blob_rawsize
(
const
git_blob
*
blob
);
/**
* Flags to control the functionality of `git_blob_filter`.
...
...
include/git2/diff.h
View file @
0e5243b7
...
...
@@ -258,12 +258,12 @@ typedef enum {
* abbreviated to something reasonable, like 7 characters.
*/
typedef
struct
{
git_oid
id
;
const
char
*
path
;
git_o
ff_t
size
;
uint32_t
flags
;
uint16_t
mode
;
uint16_t
id_abbrev
;
git_oid
id
;
const
char
*
path
;
git_o
bject_size_t
size
;
uint32_t
flags
;
uint16_t
mode
;
uint16_t
id_abbrev
;
}
git_diff_file
;
/**
...
...
include/git2/object.h
View file @
0e5243b7
...
...
@@ -21,6 +21,8 @@
*/
GIT_BEGIN_DECL
#define GIT_OBJECT_SIZE_MAX UINT64_MAX
/**
* Lookup a reference to one of the objects in a repository.
*
...
...
include/git2/odb.h
View file @
0e5243b7
...
...
@@ -294,7 +294,7 @@ GIT_EXTERN(int) git_odb_write(git_oid *out, git_odb *odb, const void *data, size
* @param type type of the object that will be written
* @return 0 if the stream was created; error code otherwise
*/
GIT_EXTERN
(
int
)
git_odb_open_wstream
(
git_odb_stream
**
out
,
git_odb
*
db
,
git_o
ff
_t
size
,
git_object_t
type
);
GIT_EXTERN
(
int
)
git_odb_open_wstream
(
git_odb_stream
**
out
,
git_odb
*
db
,
git_o
bject_size
_t
size
,
git_object_t
type
);
/**
* Write to an odb stream
...
...
include/git2/odb_backend.h
View file @
0e5243b7
...
...
@@ -87,8 +87,8 @@ struct git_odb_stream {
unsigned
int
mode
;
void
*
hash_ctx
;
git_o
ff
_t
declared_size
;
git_o
ff
_t
received_bytes
;
git_o
bject_size
_t
declared_size
;
git_o
bject_size
_t
received_bytes
;
/**
* Write at most `len` bytes into `buffer` and advance the stream.
...
...
include/git2/sys/odb_backend.h
View file @
0e5243b7
...
...
@@ -53,7 +53,7 @@ struct git_odb_backend {
git_odb_backend
*
,
const
git_oid
*
,
const
void
*
,
size_t
,
git_object_t
);
int
GIT_CALLBACK
(
writestream
)(
git_odb_stream
**
,
git_odb_backend
*
,
git_o
ff
_t
,
git_object_t
);
git_odb_stream
**
,
git_odb_backend
*
,
git_o
bject_size
_t
,
git_object_t
);
int
GIT_CALLBACK
(
readstream
)(
git_odb_stream
**
,
size_t
*
,
git_object_t
*
,
...
...
include/git2/types.h
View file @
0e5243b7
...
...
@@ -63,6 +63,9 @@ typedef int64_t git_time_t; /**< time in seconds from epoch */
#endif
/** The maximum size of an object */
typedef
uint64_t
git_object_size_t
;
#include "buffer.h"
#include "oid.h"
...
...
src/attr_file.c
View file @
0e5243b7
...
...
@@ -120,7 +120,7 @@ int git_attr_file__load(
int
bom_offset
;
git_bom_t
bom
;
git_oid
id
;
git_o
ff
_t
blobsize
;
git_o
bject_size
_t
blobsize
;
*
out
=
NULL
;
...
...
src/blame.c
View file @
0e5243b7
...
...
@@ -268,7 +268,7 @@ static git_blame_hunk *split_hunk_in_vector(
static
int
index_blob_lines
(
git_blame
*
blame
)
{
const
char
*
buf
=
blame
->
final_buf
;
git_off
_t
len
=
blame
->
final_buf_size
;
size
_t
len
=
blame
->
final_buf_size
;
int
num
=
0
,
incomplete
=
0
,
bol
=
1
;
size_t
*
i
;
...
...
@@ -335,8 +335,15 @@ static int blame_internal(git_blame *blame)
if
((
error
=
load_blob
(
blame
))
<
0
||
(
error
=
git_blame__get_origin
(
&
o
,
blame
,
blame
->
final
,
blame
->
path
))
<
0
)
goto
cleanup
;
if
(
git_blob_rawsize
(
blame
->
final_blob
)
>
SIZE_MAX
)
{
git_error_set
(
GIT_ERROR_NOMEMORY
,
"blob is too large to blame"
);
error
=
-
1
;
goto
cleanup
;
}
blame
->
final_buf
=
git_blob_rawcontent
(
blame
->
final_blob
);
blame
->
final_buf_size
=
git_blob_rawsize
(
blame
->
final_blob
);
blame
->
final_buf_size
=
(
size_t
)
git_blob_rawsize
(
blame
->
final_blob
);
ent
=
git__calloc
(
1
,
sizeof
(
git_blame__entry
));
GIT_ERROR_CHECK_ALLOC
(
ent
);
...
...
src/blame.h
View file @
0e5243b7
...
...
@@ -84,7 +84,7 @@ struct git_blame {
git_blame__entry
*
ent
;
int
num_lines
;
const
char
*
final_buf
;
git_off
_t
final_buf_size
;
size
_t
final_buf_size
;
};
git_blame
*
git_blame__alloc
(
...
...
src/blob.c
View file @
0e5243b7
...
...
@@ -25,18 +25,18 @@ const void *git_blob_rawcontent(const git_blob *blob)
return
git_odb_object_data
(
blob
->
data
.
odb
);
}
git_o
ff
_t
git_blob_rawsize
(
const
git_blob
*
blob
)
git_o
bject_size
_t
git_blob_rawsize
(
const
git_blob
*
blob
)
{
assert
(
blob
);
if
(
blob
->
raw
)
return
blob
->
data
.
raw
.
size
;
else
return
(
git_o
ff
_t
)
git_odb_object_size
(
blob
->
data
.
odb
);
return
(
git_o
bject_size
_t
)
git_odb_object_size
(
blob
->
data
.
odb
);
}
int
git_blob__getbuf
(
git_buf
*
buffer
,
git_blob
*
blob
)
{
git_o
ff
_t
size
=
git_blob_rawsize
(
blob
);
git_o
bject_size
_t
size
=
git_blob_rawsize
(
blob
);
GIT_ERROR_CHECK_BLOBSIZE
(
size
);
return
git_buf_set
(
buffer
,
git_blob_rawcontent
(
blob
),
(
size_t
)
size
);
...
...
@@ -91,13 +91,13 @@ int git_blob_create_from_buffer(
}
static
int
write_file_stream
(
git_oid
*
id
,
git_odb
*
odb
,
const
char
*
path
,
git_o
ff
_t
file_size
)
git_oid
*
id
,
git_odb
*
odb
,
const
char
*
path
,
git_o
bject_size
_t
file_size
)
{
int
fd
,
error
;
char
buffer
[
FILEIO_BUFSIZE
];
git_odb_stream
*
stream
=
NULL
;
ssize_t
read_len
=
-
1
;
git_o
ff
_t
written
=
0
;
git_o
bject_size
_t
written
=
0
;
if
((
error
=
git_odb_open_wstream
(
&
stream
,
odb
,
file_size
,
GIT_OBJECT_BLOB
))
<
0
)
...
...
@@ -129,7 +129,7 @@ static int write_file_stream(
static
int
write_file_filtered
(
git_oid
*
id
,
git_o
ff
_t
*
size
,
git_o
bject_size
_t
*
size
,
git_odb
*
odb
,
const
char
*
full_path
,
git_filter_list
*
fl
)
...
...
@@ -184,7 +184,7 @@ int git_blob__create_from_paths(
int
error
;
struct
stat
st
;
git_odb
*
odb
=
NULL
;
git_o
ff
_t
size
;
git_o
bject_size
_t
size
;
mode_t
mode
;
git_buf
path
=
GIT_BUF_INIT
;
...
...
@@ -389,7 +389,7 @@ cleanup:
int
git_blob_is_binary
(
const
git_blob
*
blob
)
{
git_buf
content
=
GIT_BUF_INIT
;
git_o
ff
_t
size
;
git_o
bject_size
_t
size
;
assert
(
blob
);
...
...
src/blob.h
View file @
0e5243b7
...
...
@@ -21,7 +21,7 @@ struct git_blob {
git_odb_object
*
odb
;
struct
{
const
char
*
data
;
git_o
ff
_t
size
;
git_o
bject_size
_t
size
;
}
raw
;
}
data
;
unsigned
int
raw
:
1
;
...
...
src/crlf.c
View file @
0e5243b7
...
...
@@ -78,7 +78,7 @@ static int has_cr_in_index(const git_filter_source *src)
const
git_index_entry
*
entry
;
git_blob
*
blob
;
const
void
*
blobcontent
;
git_o
ff
_t
blobsize
;
git_o
bject_size
_t
blobsize
;
bool
found_cr
;
if
(
!
path
)
...
...
src/diff_file.c
View file @
0e5243b7
...
...
@@ -62,7 +62,7 @@ static int diff_file_content_init_common(
git_diff_driver_update_options
(
&
fc
->
opts_flags
,
fc
->
driver
);
/* make sure file is conceivable mmap-able */
if
((
git_off_t
)((
size_t
)
fc
->
file
->
size
)
!=
fc
->
file
->
size
)
if
((
size_t
)
fc
->
file
->
size
!=
fc
->
file
->
size
)
fc
->
file
->
flags
|=
GIT_DIFF_FLAG_BINARY
;
/* check if user is forcing text diff the file */
else
if
(
fc
->
opts_flags
&
GIT_DIFF_FORCE_TEXT
)
{
...
...
@@ -330,8 +330,10 @@ static int diff_file_content_load_workdir_file(
if
(
fd
<
0
)
return
fd
;
if
(
!
fc
->
file
->
size
&&
!
(
fc
->
file
->
size
=
git_futils_filesize
(
fd
)))
if
(
!
fc
->
file
->
size
)
error
=
git_futils_filesize
(
&
fc
->
file
->
size
,
fd
);
if
(
error
<
0
||
!
fc
->
file
->
size
)
goto
cleanup
;
if
((
diff_opts
->
flags
&
GIT_DIFF_SHOW_BINARY
)
==
0
&&
...
...
src/diff_file.h
View file @
0e5243b7
...
...
@@ -20,7 +20,7 @@ typedef struct {
git_diff_driver
*
driver
;
uint32_t
flags
;
uint32_t
opts_flags
;
git_o
ff
_t
opts_max_size
;
git_o
bject_size
_t
opts_max_size
;
git_iterator_type_t
src
;
const
git_blob
*
blob
;
git_map
map
;
...
...
src/diff_generate.c
View file @
0e5243b7
...
...
@@ -560,11 +560,11 @@ int git_diff__oid_for_file(
git_diff
*
diff
,
const
char
*
path
,
uint16_t
mode
,
git_o
ff
_t
size
)
git_o
bject_size
_t
size
)
{
git_index_entry
entry
;
if
(
size
<
0
||
size
>
UINT32_MAX
)
{
if
(
size
>
UINT32_MAX
)
{
git_error_set
(
GIT_ERROR_NOMEMORY
,
"file size overflow (for 32-bits) on '%s'"
,
path
);
return
-
1
;
}
...
...
src/diff_generate.h
View file @
0e5243b7
...
...
@@ -88,7 +88,7 @@ extern int git_diff__oid_for_file(
git_diff
*
diff
,
const
char
*
path
,
uint16_t
mode
,
git_o
ff
_t
size
);
git_o
bject_size
_t
size
);
extern
int
git_diff__oid_for_entry
(
git_oid
*
out
,
...
...
@@ -120,7 +120,7 @@ GIT_INLINE(int) git_diff_file__resolve_zero_size(
git_odb_free
(
odb
);
if
(
!
error
)
file
->
size
=
(
git_o
ff
_t
)
len
;
file
->
size
=
(
git_o
bject_size
_t
)
len
;
return
error
;
}
...
...
src/diff_stats.c
View file @
0e5243b7
...
...
@@ -55,7 +55,7 @@ int git_diff_file_stats__full_to_buf(
{
const
char
*
old_path
=
NULL
,
*
new_path
=
NULL
;
size_t
padding
;
git_o
ff
_t
old_size
,
new_size
;
git_o
bject_size
_t
old_size
,
new_size
;
old_path
=
delta
->
old_file
.
path
;
new_path
=
delta
->
new_file
.
path
;
...
...
src/diff_tform.c
View file @
0e5243b7
...
...
@@ -510,7 +510,7 @@ static int similarity_sig(
if
(
file
->
size
!=
git_blob_rawsize
(
info
->
blob
))
file
->
size
=
git_blob_rawsize
(
info
->
blob
);
sz
=
(
size_t
)(
git__is_sizet
(
file
->
size
)
?
file
->
size
:
-
1
)
;
sz
=
git__is_sizet
(
file
->
size
)
?
(
size_t
)
file
->
size
:
(
size_t
)
-
1
;
error
=
opts
->
metric
->
buffer_signature
(
&
cache
[
info
->
idx
],
info
->
file
,
...
...
src/filter.c
View file @
0e5243b7
...
...
@@ -764,7 +764,7 @@ int git_filter_list_apply_to_file(
static
int
buf_from_blob
(
git_buf
*
out
,
git_blob
*
blob
)
{
git_o
ff
_t
rawsize
=
git_blob_rawsize
(
blob
);
git_o
bject_size
_t
rawsize
=
git_blob_rawsize
(
blob
);
if
(
!
git__is_sizet
(
rawsize
))
{
git_error_set
(
GIT_ERROR_OS
,
"blob is too large to filter"
);
...
...
src/futils.c
View file @
0e5243b7
...
...
@@ -112,7 +112,7 @@ int git_futils_truncate(const char *path, int mode)
return
0
;
}
git_off_t
git_futils_filesize
(
git_file
fd
)
int
git_futils_filesize
(
uint64_t
*
out
,
git_file
fd
)
{
struct
stat
sb
;
...
...
@@ -121,7 +121,13 @@ git_off_t git_futils_filesize(git_file fd)
return
-
1
;
}
return
sb
.
st_size
;
if
(
sb
.
st_size
<
0
)
{
git_error_set
(
GIT_ERROR_INVALID
,
"invalid file size"
);
return
-
1
;
}
*
out
=
sb
.
st_size
;
return
0
;
}
mode_t
git_futils_canonical_mode
(
mode_t
raw_mode
)
...
...
@@ -301,7 +307,7 @@ int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmod
return
0
;
}
int
git_futils_mmap_ro
(
git_map
*
out
,
git_file
fd
,
git_off
_t
begin
,
size_t
len
)
int
git_futils_mmap_ro
(
git_map
*
out
,
git_file
fd
,
off64
_t
begin
,
size_t
len
)
{
return
p_mmap
(
out
,
len
,
GIT_PROT_READ
,
GIT_MAP_SHARED
,
fd
,
begin
);
}
...
...
@@ -309,16 +315,14 @@ int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len)
int
git_futils_mmap_ro_file
(
git_map
*
out
,
const
char
*
path
)
{
git_file
fd
=
git_futils_open_ro
(
path
);
git_off
_t
len
;
uint64
_t
len
;
int
result
;
if
(
fd
<
0
)
return
fd
;
if
((
len
=
git_futils_filesize
(
fd
))
<
0
)
{
result
=
-
1
;
if
((
result
=
git_futils_filesize
(
&
len
,
fd
))
<
0
)
goto
out
;
}
if
(
!
git__is_sizet
(
len
))
{
git_error_set
(
GIT_ERROR_OS
,
"file `%s` too large to mmap"
,
path
);
...
...
@@ -1106,7 +1110,7 @@ int git_futils_filestamp_check(
#if defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_nsec
==
st
.
st_mtime_nsec
&&
#endif
stamp
->
size
==
(
git_off
_t
)
st
.
st_size
&&
stamp
->
size
==
(
uint64
_t
)
st
.
st_size
&&
stamp
->
ino
==
(
unsigned
int
)
st
.
st_ino
)
return
0
;
...
...
@@ -1114,7 +1118,7 @@ int git_futils_filestamp_check(
#if defined(GIT_USE_NSEC)
stamp
->
mtime
.
tv_nsec
=
st
.
st_mtime_nsec
;
#endif
stamp
->
size
=
(
git_off
_t
)
st
.
st_size
;
stamp
->
size
=
(
uint64
_t
)
st
.
st_size
;
stamp
->
ino
=
(
unsigned
int
)
st
.
st_ino
;
return
1
;
...
...
@@ -1142,7 +1146,7 @@ void git_futils_filestamp_set_from_stat(
#else
stamp
->
mtime
.
tv_nsec
=
0
;
#endif
stamp
->
size
=
(
git_off
_t
)
st
->
st_size
;
stamp
->
size
=
(
uint64
_t
)
st
->
st_size
;
stamp
->
ino
=
(
unsigned
int
)
st
->
st_ino
;
}
else
{
memset
(
stamp
,
0
,
sizeof
(
*
stamp
));
...
...
src/futils.h
View file @
0e5243b7
...
...
@@ -255,7 +255,7 @@ extern int git_futils_truncate(const char *path, int mode);
/**
* Get the filesize in bytes of a file
*/
extern
git_off_t
git_futils_filesize
(
git_file
fd
);
extern
int
git_futils_filesize
(
uint64_t
*
out
,
git_file
fd
);
#define GIT_PERMS_IS_EXEC(MODE) (((MODE) & 0111) != 0)
#define GIT_PERMS_CANONICAL(MODE) (GIT_PERMS_IS_EXEC(MODE) ? 0755 : 0644)
...
...
@@ -290,7 +290,7 @@ extern mode_t git_futils_canonical_mode(mode_t raw_mode);
extern
int
git_futils_mmap_ro
(
git_map
*
out
,
git_file
fd
,
git_off
_t
begin
,
off64
_t
begin
,
size_t
len
);
/**
...
...
@@ -330,7 +330,7 @@ extern int git_futils_fake_symlink(const char *new, const char *old);
*/
typedef
struct
{
struct
timespec
mtime
;
git_off_t
size
;
uint64_t
size
;
unsigned
int
ino
;
}
git_futils_filestamp
;
...
...
src/indexer.c
View file @
0e5243b7
...
...
@@ -47,8 +47,8 @@ struct git_indexer {
struct
git_pack_header
hdr
;
struct
git_pack_file
*
pack
;
unsigned
int
mode
;
git_off
_t
off
;
git_off
_t
entry_start
;
off64
_t
off
;
off64
_t
entry_start
;
git_object_t
entry_type
;
git_buf
entry_data
;
git_packfile_stream
stream
;
...
...
@@ -75,7 +75,7 @@ struct git_indexer {
};
struct
delta_info
{
git_off
_t
delta_off
;
off64
_t
delta_off
;
};
const
git_oid
*
git_indexer_hash
(
const
git_indexer
*
idx
)
...
...
@@ -220,7 +220,7 @@ static int store_delta(git_indexer *idx)
return
0
;
}
static
int
hash_header
(
git_hash_ctx
*
ctx
,
git_off
_t
len
,
git_object_t
type
)
static
int
hash_header
(
git_hash_ctx
*
ctx
,
off64
_t
len
,
git_object_t
type
)
{
char
buffer
[
64
];
size_t
hdrlen
;
...
...
@@ -265,7 +265,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
if
(
type
==
GIT_OBJECT_REF_DELTA
)
{
idx
->
off
+=
GIT_OID_RAWSZ
;
}
else
{
git_off
_t
base_off
=
get_delta_base
(
idx
->
pack
,
&
w
,
&
idx
->
off
,
type
,
idx
->
entry_start
);
off64
_t
base_off
=
get_delta_base
(
idx
->
pack
,
&
w
,
&
idx
->
off
,
type
,
idx
->
entry_start
);
git_mwindow_close
(
&
w
);
if
(
base_off
<
0
)
return
(
int
)
base_off
;
...
...
@@ -291,7 +291,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
return
0
;
}
static
int
crc_object
(
uint32_t
*
crc_out
,
git_mwindow_file
*
mwf
,
git_off_t
start
,
git_off
_t
size
)
static
int
crc_object
(
uint32_t
*
crc_out
,
git_mwindow_file
*
mwf
,
off64_t
start
,
off64
_t
size
)
{
void
*
ptr
;
uint32_t
crc
;
...
...
@@ -414,9 +414,9 @@ static int store_object(git_indexer *idx)
int
i
,
error
;
git_oid
oid
;
struct
entry
*
entry
;
git_off
_t
entry_size
;
off64
_t
entry_size
;
struct
git_pack_entry
*
pentry
;
git_off
_t
entry_start
=
idx
->
entry_start
;
off64
_t
entry_start
=
idx
->
entry_start
;
entry
=
git__calloc
(
1
,
sizeof
(
*
entry
));
GIT_ERROR_CHECK_ALLOC
(
entry
);
...
...
@@ -485,7 +485,7 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
return
git_oidmap_exists
(
idx
->
pack
->
idx_cache
,
id
);
}
static
int
save_entry
(
git_indexer
*
idx
,
struct
entry
*
entry
,
struct
git_pack_entry
*
pentry
,
git_off
_t
entry_start
)
static
int
save_entry
(
git_indexer
*
idx
,
struct
entry
*
entry
,
struct
git_pack_entry
*
pentry
,
off64
_t
entry_start
)
{
int
i
;
...
...
@@ -515,7 +515,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return
0
;
}
static
int
hash_and_save
(
git_indexer
*
idx
,
git_rawobj
*
obj
,
git_off
_t
entry_start
)
static
int
hash_and_save
(
git_indexer
*
idx
,
git_rawobj
*
obj
,
off64
_t
entry_start
)
{
git_oid
oid
;
size_t
entry_size
;
...
...
@@ -596,12 +596,12 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
idx
->
inbuf_len
+=
size
-
to_expell
;
}
static
int
write_at
(
git_indexer
*
idx
,
const
void
*
data
,
git_off
_t
offset
,
size_t
size
)
static
int
write_at
(
git_indexer
*
idx
,
const
void
*
data
,
off64
_t
offset
,
size_t
size
)
{
git_file
fd
=
idx
->
pack
->
mwf
.
fd
;
size_t
mmap_alignment
;
size_t
page_offset
;
git_off
_t
page_start
;
off64
_t
page_start
;
unsigned
char
*
map_data
;
git_map
map
;
int
error
;
...
...
@@ -627,11 +627,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
static
int
append_to_pack
(
git_indexer
*
idx
,
const
void
*
data
,
size_t
size
)
{
git_off
_t
new_size
;
off64
_t
new_size
;
size_t
mmap_alignment
;
size_t
page_offset
;
git_off
_t
page_start
;
git_off
_t
current_size
=
idx
->
pack
->
mwf
.
size
;
off64
_t
page_start
;
off64
_t
current_size
=
idx
->
pack
->
mwf
.
size
;
int
fd
=
idx
->
pack
->
mwf
.
fd
;
int
error
;
...
...
@@ -661,7 +661,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
static
int
read_stream_object
(
git_indexer
*
idx
,
git_indexer_progress
*
stats
)
{
git_packfile_stream
*
stream
=
&
idx
->
stream
;
git_off
_t
entry_start
=
idx
->
off
;
off64
_t
entry_start
=
idx
->
off
;
size_t
entry_size
;
git_object_t
type
;
git_mwindow
*
w
=
NULL
;
...
...
@@ -865,7 +865,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
git_oid
foo
=
{{
0
}};
unsigned
char
hdr
[
64
];
git_buf
buf
=
GIT_BUF_INIT
;
git_off
_t
entry_start
;
off64
_t
entry_start
;
const
void
*
data
;
size_t
len
,
hdr_len
;
int
error
;
...
...
@@ -939,7 +939,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
size_t
size
;
git_object_t
type
;
git_mwindow
*
w
=
NULL
;
git_off
_t
curpos
=
0
;
off64
_t
curpos
=
0
;
unsigned
char
*
base_info
;
unsigned
int
left
=
0
;
git_oid
base
;
...
...
@@ -1054,7 +1054,7 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
{
void
*
ptr
;
size_t
chunk
=
1024
*
1024
;
git_off
_t
hashed
=
0
;
off64
_t
hashed
=
0
;
git_mwindow
*
w
=
NULL
;
git_mwindow_file
*
mwf
;
unsigned
int
left
;
...
...
src/integer.h
View file @
0e5243b7
...
...
@@ -8,10 +8,10 @@
#define INCLUDE_integer_h__
/** @return true if p fits into the range of a size_t */
GIT_INLINE
(
int
)
git__is_sizet
(
git_off
_t
p
)
GIT_INLINE
(
int
)
git__is_sizet
(
int64
_t
p
)
{
size_t
r
=
(
size_t
)
p
;
return
p
==
(
git_off
_t
)
r
;
return
p
==
(
int64
_t
)
r
;
}
/** @return true if p fits into the range of an ssize_t */
...
...
@@ -36,10 +36,10 @@ GIT_INLINE(int) git__is_uint32(size_t p)
}
/** @return true if p fits into the range of an unsigned long */
GIT_INLINE
(
int
)
git__is_ulong
(
git_off
_t
p
)
GIT_INLINE
(
int
)
git__is_ulong
(
int64
_t
p
)
{
unsigned
long
r
=
(
unsigned
long
)
p
;
return
p
==
(
git_off
_t
)
r
;
return
p
==
(
int64
_t
)
r
;
}
/** @return true if p fits into the range of an int */
...
...
src/map.h
View file @
0e5243b7
...
...
@@ -40,7 +40,7 @@ typedef struct { /* memory mapped buffer */
assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \
assert((flags & GIT_MAP_FIXED) == 0); } while (0)
extern
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off
_t
offset
);
extern
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
off64
_t
offset
);
extern
int
p_munmap
(
git_map
*
map
);
#endif
src/merge.c
View file @
0e5243b7
...
...
@@ -1024,7 +1024,7 @@ static int index_entry_similarity_calc(
{
git_blob
*
blob
;
git_diff_file
diff_file
=
{{{
0
}}};
git_o
ff
_t
blobsize
;
git_o
bject_size
_t
blobsize
;
int
error
;
*
out
=
NULL
;
...
...
src/mwindow.c
View file @
0e5243b7
...
...
@@ -167,11 +167,11 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
/*
* Check if a window 'win' contains the address 'offset'
*/
int
git_mwindow_contains
(
git_mwindow
*
win
,
git_off
_t
offset
)
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64
_t
offset
)
{
git_off
_t
win_off
=
win
->
offset
;
off64
_t
win_off
=
win
->
offset
;
return
win_off
<=
offset
&&
offset
<=
(
git_off
_t
)(
win_off
+
win
->
window_map
.
len
);
&&
offset
<=
(
off64
_t
)(
win_off
+
win
->
window_map
.
len
);
}
/*
...
...
@@ -246,12 +246,12 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
static
git_mwindow
*
new_window
(
git_mwindow_file
*
mwf
,
git_file
fd
,
git_off
_t
size
,
git_off
_t
offset
)
off64
_t
size
,
off64
_t
offset
)
{
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
size_t
walign
=
git_mwindow__window_size
/
2
;
git_off
_t
len
;
off64
_t
len
;
git_mwindow
*
w
;
w
=
git__malloc
(
sizeof
(
*
w
));
...
...
@@ -263,8 +263,8 @@ static git_mwindow *new_window(
w
->
offset
=
(
offset
/
walign
)
*
walign
;
len
=
size
-
w
->
offset
;
if
(
len
>
(
git_off
_t
)
git_mwindow__window_size
)
len
=
(
git_off
_t
)
git_mwindow__window_size
;
if
(
len
>
(
off64
_t
)
git_mwindow__window_size
)
len
=
(
off64
_t
)
git_mwindow__window_size
;
ctl
->
mapped
+=
(
size_t
)
len
;
...
...
@@ -311,7 +311,7 @@ static git_mwindow *new_window(
unsigned
char
*
git_mwindow_open
(
git_mwindow_file
*
mwf
,
git_mwindow
**
cursor
,
git_off
_t
offset
,
off64
_t
offset
,
size_t
extra
,
unsigned
int
*
left
)
{
...
...
src/mwindow.h
View file @
0e5243b7
...
...
@@ -16,7 +16,7 @@
typedef
struct
git_mwindow
{
struct
git_mwindow
*
next
;
git_map
window_map
;
git_off
_t
offset
;
off64
_t
offset
;
size_t
last_used
;
size_t
inuse_cnt
;
}
git_mwindow
;
...
...
@@ -24,7 +24,7 @@ typedef struct git_mwindow {
typedef
struct
git_mwindow_file
{
git_mwindow
*
windows
;
int
fd
;
git_off
_t
size
;
off64
_t
size
;
}
git_mwindow_file
;
typedef
struct
git_mwindow_ctl
{
...
...
@@ -37,10 +37,10 @@ typedef struct git_mwindow_ctl {
git_vector
windowfiles
;
}
git_mwindow_ctl
;
int
git_mwindow_contains
(
git_mwindow
*
win
,
git_off
_t
offset
);
int
git_mwindow_contains
(
git_mwindow
*
win
,
off64
_t
offset
);
void
git_mwindow_free_all
(
git_mwindow_file
*
mwf
);
/* locks */
void
git_mwindow_free_all_locked
(
git_mwindow_file
*
mwf
);
/* run under lock */
unsigned
char
*
git_mwindow_open
(
git_mwindow_file
*
mwf
,
git_mwindow
**
cursor
,
git_off
_t
offset
,
size_t
extra
,
unsigned
int
*
left
);
unsigned
char
*
git_mwindow_open
(
git_mwindow_file
*
mwf
,
git_mwindow
**
cursor
,
off64
_t
offset
,
size_t
extra
,
unsigned
int
*
left
);
int
git_mwindow_file_register
(
git_mwindow_file
*
mwf
);
void
git_mwindow_file_deregister
(
git_mwindow_file
*
mwf
);
void
git_mwindow_close
(
git_mwindow
**
w_cursor
);
...
...
src/notes.c
View file @
0e5243b7
...
...
@@ -320,7 +320,7 @@ static int note_new(
git_blob
*
blob
)
{
git_note
*
note
=
NULL
;
git_o
ff
_t
blobsize
;
git_o
bject_size
_t
blobsize
;
note
=
git__malloc
(
sizeof
(
git_note
));
GIT_ERROR_CHECK_ALLOC
(
note
);
...
...
src/object.h
View file @
0e5243b7
...
...
@@ -11,6 +11,8 @@
#include "repository.h"
#define GIT_OBJECT_SIZE_MAX UINT64_MAX
extern
bool
git_object__strict_input_validation
;
/** Base git object for inheritance */
...
...
src/odb.c
View file @
0e5243b7
...
...
@@ -89,7 +89,7 @@ int git_odb__format_object_header(
size_t
*
written
,
char
*
hdr
,
size_t
hdr_size
,
git_o
ff
_t
obj_len
,
git_o
bject_size
_t
obj_len
,
git_object_t
obj_type
)
{
const
char
*
type_str
=
git_object_type2string
(
obj_type
);
...
...
@@ -320,20 +320,26 @@ int git_odb__hashlink(git_oid *out, const char *path)
int
git_odb_hashfile
(
git_oid
*
out
,
const
char
*
path
,
git_object_t
type
)
{
git_off_t
size
;
int
result
,
fd
=
git_futils_open_ro
(
path
);
if
(
fd
<
0
)
uint64_t
size
;
int
fd
,
error
=
0
;
if
((
fd
=
git_futils_open_ro
(
path
))
<
0
)
return
fd
;
if
((
size
=
git_futils_filesize
(
fd
))
<
0
||
!
git__is_sizet
(
size
))
{
if
((
error
=
git_futils_filesize
(
&
size
,
fd
))
<
0
)
goto
done
;
if
(
!
git__is_sizet
(
size
))
{
git_error_set
(
GIT_ERROR_OS
,
"file size overflow for 32-bit systems"
);
p_close
(
fd
)
;
return
-
1
;
error
=
-
1
;
goto
done
;
}
result
=
git_odb__hashfd
(
out
,
fd
,
(
size_t
)
size
,
type
);
error
=
git_odb__hashfd
(
out
,
fd
,
(
size_t
)
size
,
type
);
done:
p_close
(
fd
);
return
result
;
return
error
;
}
int
git_odb_hash
(
git_oid
*
id
,
const
void
*
data
,
size_t
len
,
git_object_t
type
)
...
...
@@ -385,7 +391,7 @@ static void fake_wstream__free(git_odb_stream *_stream)
git__free
(
stream
);
}
static
int
init_fake_wstream
(
git_odb_stream
**
stream_p
,
git_odb_backend
*
backend
,
git_o
ff
_t
size
,
git_object_t
type
)
static
int
init_fake_wstream
(
git_odb_stream
**
stream_p
,
git_odb_backend
*
backend
,
git_o
bject_size
_t
size
,
git_object_t
type
)
{
fake_wstream
*
stream
;
size_t
blobsize
;
...
...
@@ -1319,7 +1325,7 @@ int git_odb_write(
return
error
;
}
static
int
hash_header
(
git_hash_ctx
*
ctx
,
git_o
ff
_t
size
,
git_object_t
type
)
static
int
hash_header
(
git_hash_ctx
*
ctx
,
git_o
bject_size
_t
size
,
git_object_t
type
)
{
char
header
[
64
];
size_t
hdrlen
;
...
...
@@ -1333,7 +1339,7 @@ static int hash_header(git_hash_ctx *ctx, git_off_t size, git_object_t type)
}
int
git_odb_open_wstream
(
git_odb_stream
**
stream
,
git_odb
*
db
,
git_o
ff
_t
size
,
git_object_t
type
)
git_odb_stream
**
stream
,
git_odb
*
db
,
git_o
bject_size
_t
size
,
git_object_t
type
)
{
size_t
i
,
writes
=
0
;
int
error
=
GIT_ERROR
;
...
...
src/odb.h
View file @
0e5243b7
...
...
@@ -70,7 +70,7 @@ int git_odb__hashobj(git_oid *id, git_rawobj *obj);
/*
* Format the object header such as it would appear in the on-disk object
*/
int
git_odb__format_object_header
(
size_t
*
out_len
,
char
*
hdr
,
size_t
hdr_size
,
git_o
ff
_t
obj_len
,
git_object_t
obj_type
);
int
git_odb__format_object_header
(
size_t
*
out_len
,
char
*
hdr
,
size_t
hdr_size
,
git_o
bject_size
_t
obj_len
,
git_object_t
obj_type
);
/*
* Hash an open file descriptor.
...
...
src/odb_loose.c
View file @
0e5243b7
...
...
@@ -824,7 +824,7 @@ static int filebuf_flags(loose_backend *backend)
return
flags
;
}
static
int
loose_backend__writestream
(
git_odb_stream
**
stream_out
,
git_odb_backend
*
_backend
,
git_o
ff
_t
length
,
git_object_t
type
)
static
int
loose_backend__writestream
(
git_odb_stream
**
stream_out
,
git_odb_backend
*
_backend
,
git_o
bject_size
_t
length
,
git_object_t
type
)
{
loose_backend
*
backend
;
loose_writestream
*
stream
=
NULL
;
...
...
@@ -833,7 +833,7 @@ static int loose_backend__writestream(git_odb_stream **stream_out, git_odb_backe
size_t
hdrlen
;
int
error
;
assert
(
_backend
&&
length
>=
0
);
assert
(
_backend
);
backend
=
(
loose_backend
*
)
_backend
;
*
stream_out
=
NULL
;
...
...
src/offmap.c
View file @
0e5243b7
...
...
@@ -14,9 +14,9 @@
#define kfree git__free
#include "khash.h"
__KHASH_TYPE
(
off
,
git_off
_t
,
void
*
)
__KHASH_TYPE
(
off
,
off64
_t
,
void
*
)
__KHASH_IMPL
(
off
,
static
kh_inline
,
git_off
_t
,
void
*
,
1
,
kh_int64_hash_func
,
kh_int64_hash_equal
)
__KHASH_IMPL
(
off
,
static
kh_inline
,
off64
_t
,
void
*
,
1
,
kh_int64_hash_func
,
kh_int64_hash_equal
)
int
git_offmap_new
(
git_offmap
**
out
)
...
...
@@ -42,7 +42,7 @@ size_t git_offmap_size(git_offmap *map)
return
kh_size
(
map
);
}
void
*
git_offmap_get
(
git_offmap
*
map
,
const
git_off
_t
key
)
void
*
git_offmap_get
(
git_offmap
*
map
,
const
off64
_t
key
)
{
size_t
idx
=
kh_get
(
off
,
map
,
key
);
if
(
idx
==
kh_end
(
map
)
||
!
kh_exist
(
map
,
idx
))
...
...
@@ -50,7 +50,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key)
return
kh_val
(
map
,
idx
);
}
int
git_offmap_set
(
git_offmap
*
map
,
const
git_off
_t
key
,
void
*
value
)
int
git_offmap_set
(
git_offmap
*
map
,
const
off64
_t
key
,
void
*
value
)
{
size_t
idx
;
int
rval
;
...
...
@@ -67,7 +67,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value)
return
0
;
}
int
git_offmap_delete
(
git_offmap
*
map
,
const
git_off
_t
key
)
int
git_offmap_delete
(
git_offmap
*
map
,
const
off64
_t
key
)
{
khiter_t
idx
=
kh_get
(
off
,
map
,
key
);
if
(
idx
==
kh_end
(
map
))
...
...
@@ -76,12 +76,12 @@ int git_offmap_delete(git_offmap *map, const git_off_t key)
return
0
;
}
int
git_offmap_exists
(
git_offmap
*
map
,
const
git_off
_t
key
)
int
git_offmap_exists
(
git_offmap
*
map
,
const
off64
_t
key
)
{
return
kh_get
(
off
,
map
,
key
)
!=
kh_end
(
map
);
}
int
git_offmap_iterate
(
void
**
value
,
git_offmap
*
map
,
size_t
*
iter
,
git_off
_t
*
key
)
int
git_offmap_iterate
(
void
**
value
,
git_offmap
*
map
,
size_t
*
iter
,
off64
_t
*
key
)
{
size_t
i
=
*
iter
;
...
...
src/offmap.h
View file @
0e5243b7
...
...
@@ -11,11 +11,11 @@
#include "git2/types.h"
/** A map with `
git_off
_t`s as key. */
/** A map with `
off64
_t`s as key. */
typedef
struct
kh_off_s
git_offmap
;
/**
* Allocate a new `
git_off
_t` map.
* Allocate a new `
off64
_t` map.
*
* @param out Pointer to the map that shall be allocated.
* @return 0 on success, an error code if allocation has failed.
...
...
@@ -59,7 +59,7 @@ size_t git_offmap_size(git_offmap *map);
* @param key key to search for
* @return value associated with the given key or NULL if the key was not found
*/
void
*
git_offmap_get
(
git_offmap
*
map
,
const
git_off
_t
key
);
void
*
git_offmap_get
(
git_offmap
*
map
,
const
off64
_t
key
);
/**
* Set the entry for key to value.
...
...
@@ -74,7 +74,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key);
* @return zero if the key was successfully set, a negative error
* code otherwise
*/
int
git_offmap_set
(
git_offmap
*
map
,
const
git_off
_t
key
,
void
*
value
);
int
git_offmap_set
(
git_offmap
*
map
,
const
off64
_t
key
,
void
*
value
);
/**
* Delete an entry from the map.
...
...
@@ -88,7 +88,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value);
* such key was found, a negative code in case of an
* error
*/
int
git_offmap_delete
(
git_offmap
*
map
,
const
git_off
_t
key
);
int
git_offmap_delete
(
git_offmap
*
map
,
const
off64
_t
key
);
/**
* Check whether a key exists in the given map.
...
...
@@ -97,7 +97,7 @@ int git_offmap_delete(git_offmap *map, const git_off_t key);
* @param key key to search for
* @return 0 if the key has not been found, 1 otherwise
*/
int
git_offmap_exists
(
git_offmap
*
map
,
const
git_off
_t
key
);
int
git_offmap_exists
(
git_offmap
*
map
,
const
off64
_t
key
);
/**
* Iterate over entries of the map.
...
...
@@ -118,7 +118,7 @@ int git_offmap_exists(git_offmap *map, const git_off_t key);
* GIT_ITEROVER if no entries are left. A negative error
* code otherwise.
*/
int
git_offmap_iterate
(
void
**
value
,
git_offmap
*
map
,
size_t
*
iter
,
git_off
_t
*
key
);
int
git_offmap_iterate
(
void
**
value
,
git_offmap
*
map
,
size_t
*
iter
,
off64
_t
*
key
);
#define git_offmap_foreach(h, kvar, vvar, code) { size_t __i = 0; \
while (git_offmap_iterate((void **) &(vvar), h, &__i, &(kvar)) == 0) { \
...
...
src/pack-objects.h
View file @
0e5243b7
...
...
@@ -30,7 +30,7 @@
typedef
struct
git_pobject
{
git_oid
id
;
git_object_t
type
;
git_off
_t
offset
;
off64
_t
offset
;
size_t
size
;
...
...
src/pack.c
View file @
0e5243b7
...
...
@@ -20,12 +20,12 @@
bool
git_disable_pack_keep_file_checks
=
false
;
static
int
packfile_open
(
struct
git_pack_file
*
p
);
static
git_off
_t
nth_packed_object_offset
(
const
struct
git_pack_file
*
p
,
uint32_t
n
);
static
off64
_t
nth_packed_object_offset
(
const
struct
git_pack_file
*
p
,
uint32_t
n
);
static
int
packfile_unpack_compressed
(
git_rawobj
*
obj
,
struct
git_pack_file
*
p
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
,
off64
_t
*
curpos
,
size_t
size
,
git_object_t
type
);
...
...
@@ -37,7 +37,7 @@ static int packfile_unpack_compressed(
* GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ.
*/
static
int
pack_entry_find_offset
(
git_off
_t
*
offset_out
,
off64
_t
*
offset_out
,
git_oid
*
found_oid
,
struct
git_pack_file
*
p
,
const
git_oid
*
short_oid
,
...
...
@@ -109,7 +109,7 @@ static int cache_init(git_pack_cache *cache)
return
0
;
}
static
git_pack_cache_entry
*
cache_get
(
git_pack_cache
*
cache
,
git_off
_t
offset
)
static
git_pack_cache_entry
*
cache_get
(
git_pack_cache
*
cache
,
off64
_t
offset
)
{
git_pack_cache_entry
*
entry
;
...
...
@@ -128,7 +128,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
/* Run with the cache lock held */
static
void
free_lowest_entry
(
git_pack_cache
*
cache
)
{
git_off
_t
offset
;
off64
_t
offset
;
git_pack_cache_entry
*
entry
;
git_offmap_foreach
(
cache
->
entries
,
offset
,
entry
,
{
...
...
@@ -144,7 +144,7 @@ static int cache_add(
git_pack_cache_entry
**
cached_out
,
git_pack_cache
*
cache
,
git_rawobj
*
base
,
git_off
_t
offset
)
off64
_t
offset
)
{
git_pack_cache_entry
*
entry
;
int
exists
;
...
...
@@ -345,7 +345,7 @@ static int pack_index_open(struct git_pack_file *p)
static
unsigned
char
*
pack_window_open
(
struct
git_pack_file
*
p
,
git_mwindow
**
w_cursor
,
git_off
_t
offset
,
off64
_t
offset
,
unsigned
int
*
left
)
{
if
(
p
->
mwf
.
fd
==
-
1
&&
packfile_open
(
p
)
<
0
)
...
...
@@ -441,7 +441,7 @@ int git_packfile_unpack_header(
git_object_t
*
type_p
,
git_mwindow_file
*
mwf
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
)
off64
_t
*
curpos
)
{
unsigned
char
*
base
;
unsigned
int
left
;
...
...
@@ -474,13 +474,13 @@ int git_packfile_resolve_header(
size_t
*
size_p
,
git_object_t
*
type_p
,
struct
git_pack_file
*
p
,
git_off
_t
offset
)
off64
_t
offset
)
{
git_mwindow
*
w_curs
=
NULL
;
git_off
_t
curpos
=
offset
;
off64
_t
curpos
=
offset
;
size_t
size
;
git_object_t
type
;
git_off
_t
base_offset
;
off64
_t
base_offset
;
int
error
;
error
=
git_packfile_unpack_header
(
&
size
,
&
type
,
&
p
->
mwf
,
&
w_curs
,
&
curpos
);
...
...
@@ -528,13 +528,13 @@ int git_packfile_resolve_header(
* cache, we stop calculating there.
*/
static
int
pack_dependency_chain
(
git_dependency_chain
*
chain_out
,
git_pack_cache_entry
**
cached_out
,
git_off
_t
*
cached_off
,
git_pack_cache_entry
**
cached_out
,
off64
_t
*
cached_off
,
struct
pack_chain_elem
*
small_stack
,
size_t
*
stack_sz
,
struct
git_pack_file
*
p
,
git_off
_t
obj_offset
)
struct
git_pack_file
*
p
,
off64
_t
obj_offset
)
{
git_dependency_chain
chain
=
GIT_ARRAY_INIT
;
git_mwindow
*
w_curs
=
NULL
;
git_off
_t
curpos
=
obj_offset
,
base_offset
;
off64
_t
curpos
=
obj_offset
,
base_offset
;
int
error
=
0
,
use_heap
=
0
;
size_t
size
,
elem_pos
;
git_object_t
type
;
...
...
@@ -619,10 +619,10 @@ on_error:
int
git_packfile_unpack
(
git_rawobj
*
obj
,
struct
git_pack_file
*
p
,
git_off
_t
*
obj_offset
)
off64
_t
*
obj_offset
)
{
git_mwindow
*
w_curs
=
NULL
;
git_off
_t
curpos
=
*
obj_offset
;
off64
_t
curpos
=
*
obj_offset
;
int
error
,
free_base
=
0
;
git_dependency_chain
chain
=
GIT_ARRAY_INIT
;
struct
pack_chain_elem
*
elem
=
NULL
,
*
stack
;
...
...
@@ -777,7 +777,7 @@ static void use_git_free(void *opaq, void *ptr)
git__free
(
ptr
);
}
int
git_packfile_stream_open
(
git_packfile_stream
*
obj
,
struct
git_pack_file
*
p
,
git_off
_t
curpos
)
int
git_packfile_stream_open
(
git_packfile_stream
*
obj
,
struct
git_pack_file
*
p
,
off64
_t
curpos
)
{
int
st
;
...
...
@@ -846,7 +846,7 @@ static int packfile_unpack_compressed(
git_rawobj
*
obj
,
struct
git_pack_file
*
p
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
,
off64
_t
*
curpos
,
size_t
size
,
git_object_t
type
)
{
...
...
@@ -909,16 +909,16 @@ static int packfile_unpack_compressed(
* curpos is where the data starts, delta_obj_offset is the where the
* header starts
*/
git_off
_t
get_delta_base
(
off64
_t
get_delta_base
(
struct
git_pack_file
*
p
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
,
off64
_t
*
curpos
,
git_object_t
type
,
git_off
_t
delta_obj_offset
)
off64
_t
delta_obj_offset
)
{
unsigned
int
left
=
0
;
unsigned
char
*
base_info
;
git_off
_t
base_offset
;
off64
_t
base_offset
;
git_oid
unused
;
base_info
=
pack_window_open
(
p
,
w_curs
,
*
curpos
,
&
left
);
...
...
@@ -1045,7 +1045,7 @@ static int packfile_open(struct git_pack_file *p)
if
(
!
p
->
mwf
.
size
)
{
if
(
!
S_ISREG
(
st
.
st_mode
))
goto
cleanup
;
p
->
mwf
.
size
=
(
git_off
_t
)
st
.
st_size
;
p
->
mwf
.
size
=
(
off64
_t
)
st
.
st_size
;
}
else
if
(
p
->
mwf
.
size
!=
st
.
st_size
)
goto
cleanup
;
...
...
@@ -1182,7 +1182,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
*
***********************************************************/
static
git_off
_t
nth_packed_object_offset
(
const
struct
git_pack_file
*
p
,
uint32_t
n
)
static
off64
_t
nth_packed_object_offset
(
const
struct
git_pack_file
*
p
,
uint32_t
n
)
{
const
unsigned
char
*
index
=
p
->
index_map
.
data
;
const
unsigned
char
*
end
=
index
+
p
->
index_map
.
len
;
...
...
@@ -1270,7 +1270,7 @@ int git_pack_foreach_entry(
}
static
int
pack_entry_find_offset
(
git_off
_t
*
offset_out
,
off64
_t
*
offset_out
,
git_oid
*
found_oid
,
struct
git_pack_file
*
p
,
const
git_oid
*
short_oid
,
...
...
@@ -1280,7 +1280,7 @@ static int pack_entry_find_offset(
const
unsigned
char
*
index
;
unsigned
hi
,
lo
,
stride
;
int
pos
,
found
=
0
;
git_off
_t
offset
;
off64
_t
offset
;
const
unsigned
char
*
current
=
0
;
*
offset_out
=
0
;
...
...
@@ -1375,7 +1375,7 @@ int git_pack_entry_find(
const
git_oid
*
short_oid
,
size_t
len
)
{
git_off
_t
offset
;
off64
_t
offset
;
git_oid
found_oid
;
int
error
;
...
...
src/pack.h
View file @
0e5243b7
...
...
@@ -64,8 +64,8 @@ typedef struct git_pack_cache_entry {
}
git_pack_cache_entry
;
struct
pack_chain_elem
{
git_off
_t
base_key
;
git_off
_t
offset
;
off64
_t
base_key
;
off64
_t
offset
;
size_t
size
;
git_object_t
type
;
};
...
...
@@ -108,13 +108,13 @@ struct git_pack_file {
};
struct
git_pack_entry
{
git_off
_t
offset
;
off64
_t
offset
;
git_oid
sha1
;
struct
git_pack_file
*
p
;
};
typedef
struct
git_packfile_stream
{
git_off
_t
curpos
;
off64
_t
curpos
;
int
done
;
z_stream
zstream
;
struct
git_pack_file
*
p
;
...
...
@@ -130,23 +130,23 @@ int git_packfile_unpack_header(
git_object_t
*
type_p
,
git_mwindow_file
*
mwf
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
);
off64
_t
*
curpos
);
int
git_packfile_resolve_header
(
size_t
*
size_p
,
git_object_t
*
type_p
,
struct
git_pack_file
*
p
,
git_off
_t
offset
);
off64
_t
offset
);
int
git_packfile_unpack
(
git_rawobj
*
obj
,
struct
git_pack_file
*
p
,
git_off
_t
*
obj_offset
);
int
git_packfile_unpack
(
git_rawobj
*
obj
,
struct
git_pack_file
*
p
,
off64
_t
*
obj_offset
);
int
git_packfile_stream_open
(
git_packfile_stream
*
obj
,
struct
git_pack_file
*
p
,
git_off
_t
curpos
);
int
git_packfile_stream_open
(
git_packfile_stream
*
obj
,
struct
git_pack_file
*
p
,
off64
_t
curpos
);
ssize_t
git_packfile_stream_read
(
git_packfile_stream
*
obj
,
void
*
buffer
,
size_t
len
);
void
git_packfile_stream_dispose
(
git_packfile_stream
*
obj
);
git_off
_t
get_delta_base
(
struct
git_pack_file
*
p
,
git_mwindow
**
w_curs
,
git_off
_t
*
curpos
,
git_object_t
type
,
git_off
_t
delta_obj_offset
);
off64
_t
get_delta_base
(
struct
git_pack_file
*
p
,
git_mwindow
**
w_curs
,
off64
_t
*
curpos
,
git_object_t
type
,
off64
_t
delta_obj_offset
);
void
git_packfile_close
(
struct
git_pack_file
*
p
,
bool
unlink_packfile
);
void
git_packfile_free
(
struct
git_pack_file
*
p
);
...
...
src/patch_parse.c
View file @
0e5243b7
...
...
@@ -491,7 +491,7 @@ done:
static
int
parse_int
(
int
*
out
,
git_patch_parse_ctx
*
ctx
)
{
git_off
_t
num
;
int64
_t
num
;
if
(
git_parse_advance_digit
(
&
num
,
&
ctx
->
parse_ctx
,
10
)
<
0
||
!
git__is_int
(
num
))
return
-
1
;
...
...
@@ -765,7 +765,7 @@ static int parse_patch_binary_side(
{
git_diff_binary_t
type
=
GIT_DIFF_BINARY_NONE
;
git_buf
base85
=
GIT_BUF_INIT
,
decoded
=
GIT_BUF_INIT
;
git_off
_t
len
;
int64
_t
len
;
int
error
=
0
;
if
(
git_parse_ctx_contains_s
(
&
ctx
->
parse_ctx
,
"literal "
))
{
...
...
src/posix.c
View file @
0e5243b7
...
...
@@ -235,7 +235,7 @@ int git__mmap_alignment(size_t *alignment)
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off
_t
offset
)
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
off64
_t
offset
)
{
GIT_MMAP_VALIDATE
(
out
,
len
,
prot
,
flags
);
...
...
src/posix.h
View file @
0e5243b7
...
...
@@ -89,6 +89,18 @@
#define EAFNOSUPPORT (INT_MAX-1)
#endif
/* Provide a 64-bit size for offsets. */
#if defined(_MSC_VER)
typedef
__int64
off64_t
;
#elif defined(__HAIKU__)
typedef
__haiku_std_int64
off64_t
;
#elif defined(__APPLE__)
typedef
__int64_t
off64_t
;
#else
typedef
int64_t
off64_t
;
#endif
typedef
int
git_file
;
/**
...
...
src/reader.c
View file @
0e5243b7
...
...
@@ -32,7 +32,7 @@ static int tree_reader_read(
tree_reader
*
reader
=
(
tree_reader
*
)
_reader
;
git_tree_entry
*
tree_entry
=
NULL
;
git_blob
*
blob
=
NULL
;
git_o
ff
_t
blobsize
;
git_o
bject_size
_t
blobsize
;
int
error
;
if
((
error
=
git_tree_entry_bypath
(
&
tree_entry
,
reader
->
tree
,
filename
))
<
0
||
...
...
src/repository.c
View file @
0e5243b7
...
...
@@ -2545,7 +2545,7 @@ int git_repository_hashfile(
int
error
;
git_filter_list
*
fl
=
NULL
;
git_file
fd
=
-
1
;
git_off
_t
len
;
uint64
_t
len
;
git_buf
full_path
=
GIT_BUF_INIT
;
assert
(
out
&&
path
&&
repo
);
/* as_path can be NULL */
...
...
@@ -2582,11 +2582,8 @@ int git_repository_hashfile(
goto
cleanup
;
}
len
=
git_futils_filesize
(
fd
);
if
(
len
<
0
)
{
error
=
(
int
)
len
;
if
((
error
=
git_futils_filesize
(
&
len
,
fd
))
<
0
)
goto
cleanup
;
}
if
(
!
git__is_sizet
(
len
))
{
git_error_set
(
GIT_ERROR_OS
,
"file size overflow for 32-bit systems"
);
...
...
src/unix/map.c
View file @
0e5243b7
...
...
@@ -32,7 +32,7 @@ int git__mmap_alignment(size_t *alignment)
return
git__page_size
(
alignment
);
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off
_t
offset
)
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
off64
_t
offset
)
{
int
mprot
=
PROT_READ
;
int
mflag
=
0
;
...
...
src/win32/map.c
View file @
0e5243b7
...
...
@@ -50,7 +50,7 @@ int git__mmap_alignment(size_t *page_size)
return
0
;
}
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
git_off
_t
offset
)
int
p_mmap
(
git_map
*
out
,
size_t
len
,
int
prot
,
int
flags
,
int
fd
,
off64
_t
offset
)
{
HANDLE
fh
=
(
HANDLE
)
_get_osfhandle
(
fd
);
DWORD
alignment
=
get_allocation_granularity
();
...
...
@@ -58,8 +58,8 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
DWORD
view_prot
=
0
;
DWORD
off_low
=
0
;
DWORD
off_hi
=
0
;
git_off
_t
page_start
;
git_off
_t
page_offset
;
off64
_t
page_start
;
off64
_t
page_offset
;
GIT_MMAP_VALIDATE
(
out
,
len
,
prot
,
flags
);
...
...
@@ -99,8 +99,6 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
return
-
1
;
}
assert
(
sizeof
(
git_off_t
)
==
8
);
off_low
=
(
DWORD
)(
page_start
);
off_hi
=
(
DWORD
)(
page_start
>>
32
);
out
->
data
=
MapViewOfFile
(
out
->
fmh
,
view_prot
,
off_hi
,
off_low
,
len
);
...
...
src/win32/posix.h
View file @
0e5243b7
...
...
@@ -47,7 +47,7 @@ extern int p_chdir(const char* path);
extern
int
p_chmod
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_rmdir
(
const
char
*
path
);
extern
int
p_access
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_ftruncate
(
int
fd
,
git_off
_t
size
);
extern
int
p_ftruncate
(
int
fd
,
off64
_t
size
);
/* p_lstat is almost but not quite POSIX correct. Specifically, the use of
* ENOTDIR is wrong, in that it does not mean precisely that a non-directory
...
...
src/win32/posix_w32.c
View file @
0e5243b7
...
...
@@ -210,7 +210,7 @@ on_error:
* We now take a "git_off_t" rather than "long" because
* files may be longer than 2Gb.
*/
int
p_ftruncate
(
int
fd
,
git_off
_t
size
)
int
p_ftruncate
(
int
fd
,
off64
_t
size
)
{
if
(
size
<
0
)
{
errno
=
EINVAL
;
...
...
src/win32/w32_util.h
View file @
0e5243b7
...
...
@@ -120,7 +120,7 @@ GIT_INLINE(void) git_win32__stat_init(
st
->
st_uid
=
0
;
st
->
st_nlink
=
1
;
st
->
st_mode
=
mode
;
st
->
st_size
=
((
git_off
_t
)
nFileSizeHigh
<<
32
)
+
nFileSizeLow
;
st
->
st_size
=
((
int64
_t
)
nFileSizeHigh
<<
32
)
+
nFileSizeLow
;
st
->
st_dev
=
_getdrive
()
-
1
;
st
->
st_rdev
=
st
->
st_dev
;
git_win32__filetime_to_timespec
(
&
ftLastAccessTime
,
&
(
st
->
st_atim
));
...
...
tests/core/ftruncate.c
View file @
0e5243b7
...
...
@@ -27,7 +27,7 @@ void test_core_ftruncate__cleanup(void)
p_unlink
(
filename
);
}
static
void
_extend
(
git_off
_t
i64len
)
static
void
_extend
(
off64
_t
i64len
)
{
struct
stat
st
;
int
error
;
...
...
tests/index/tests.c
View file @
0e5243b7
...
...
@@ -13,7 +13,7 @@ static const size_t index_entry_count_2 = 1437;
struct
test_entry
{
size_t
index
;
char
path
[
128
];
git_off
_t
file_size
;
off64
_t
file_size
;
git_time_t
mtime
;
};
...
...
tests/object/blob/filter.c
View file @
0e5243b7
...
...
@@ -19,7 +19,7 @@ static const char *g_crlf_raw[CRLF_NUM_TEST_OBJECTS] = {
"
\xFE\xFF\x00
T
\x00
h
\x00
i
\x00
s
\x00
!"
};
static
git_off
_t
g_crlf_raw_len
[
CRLF_NUM_TEST_OBJECTS
]
=
{
static
off64
_t
g_crlf_raw_len
[
CRLF_NUM_TEST_OBJECTS
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
17
,
-
1
,
-
1
,
12
};
...
...
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