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
f2ef6cee
Commit
f2ef6cee
authored
Jun 22, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3242 from libgit2/cmn/maint-update
Another round of backports
parents
900e5d3b
7e59552b
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
119 additions
and
29 deletions
+119
-29
.travis.yml
+1
-1
appveyor.yml
+1
-0
include/git2/reset.h
+1
-0
script/cibuild.sh
+2
-2
src/clone.c
+15
-2
src/fileops.c
+5
-1
src/ident.c
+2
-2
src/indexer.c
+18
-4
src/openssl_stream.c
+3
-0
src/pack.c
+7
-0
src/path.c
+5
-1
src/refspec.c
+6
-0
src/transports/ssh.c
+8
-1
tests/checkout/crlf.c
+6
-6
tests/filter/blob.c
+2
-2
tests/filter/custom.c
+1
-1
tests/filter/ident.c
+6
-6
tests/network/refspecs.c
+10
-0
tests/odb/foreach.c
+20
-0
No files found.
.travis.yml
View file @
f2ef6cee
...
...
@@ -57,8 +57,8 @@ after_success:
# Only watch the development and master branches
branches
:
only
:
-
development
-
master
-
/^maint.*/
# Notify development list when needed
notifications
:
...
...
appveyor.yml
View file @
f2ef6cee
...
...
@@ -2,6 +2,7 @@ version: '{build}'
branches
:
only
:
-
master
-
/^maint.*/
build_script
:
-
ps
:
>-
choco install cmake
...
...
include/git2/reset.h
View file @
f2ef6cee
...
...
@@ -10,6 +10,7 @@
#include "common.h"
#include "types.h"
#include "strarray.h"
#include "checkout.h"
/**
* @file git2/reset.h
...
...
script/cibuild.sh
View file @
f2ef6cee
...
...
@@ -45,8 +45,8 @@ export GITTEST_REMOTE_SSH_PASSPHRASE=""
if
[
-e
./libgit2_clar
]
;
then
./libgit2_clar
-sonline
::push
-sonline
::clone::ssh_cert
&&
./libgit2_clar
-sonline
::clone::ssh_with_paths
./libgit2_clar
-sonline
::clone::ssh_with_paths
||
exit
$?
if
[
"
$TRAVIS_OS_NAME
"
=
"linux"
]
;
then
./libgit2_clar
-sonline
::clone::cred_callback
./libgit2_clar
-sonline
::clone::cred_callback
||
exit
$?
fi
fi
src/clone.c
View file @
f2ef6cee
...
...
@@ -547,8 +547,21 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
if
(
can_link
(
git_repository_path
(
src
),
git_repository_path
(
repo
),
link
))
flags
|=
GIT_CPDIR_LINK_FILES
;
if
((
error
=
git_futils_cp_r
(
git_buf_cstr
(
&
src_odb
),
git_buf_cstr
(
&
dst_odb
),
flags
,
GIT_OBJECT_DIR_MODE
))
<
0
)
error
=
git_futils_cp_r
(
git_buf_cstr
(
&
src_odb
),
git_buf_cstr
(
&
dst_odb
),
flags
,
GIT_OBJECT_DIR_MODE
);
/*
* can_link() doesn't catch all variations, so if we hit an
* error and did want to link, let's try again without trying
* to link.
*/
if
(
error
<
0
&&
link
)
{
flags
&=
~
GIT_CPDIR_LINK_FILES
;
error
=
git_futils_cp_r
(
git_buf_cstr
(
&
src_odb
),
git_buf_cstr
(
&
dst_odb
),
flags
,
GIT_OBJECT_DIR_MODE
);
}
if
(
error
<
0
)
goto
cleanup
;
git_buf_printf
(
&
reflog_message
,
"clone: from %s"
,
git_remote_url
(
remote
));
...
...
src/fileops.c
View file @
f2ef6cee
...
...
@@ -664,6 +664,9 @@ static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done)
error
=
(
int
)
len
;
}
if
(
error
<
0
)
giterr_set
(
GITERR_OS
,
"write error while copying file"
);
if
(
close_fd_when_done
)
{
p_close
(
ifd
);
p_close
(
ofd
);
...
...
@@ -818,7 +821,8 @@ static int _cp_r_callback(void *ref, git_buf *from)
/* make symlink or regular file */
if
(
info
->
flags
&
GIT_CPDIR_LINK_FILES
)
{
error
=
p_link
(
from
->
ptr
,
info
->
to
.
ptr
);
if
((
error
=
p_link
(
from
->
ptr
,
info
->
to
.
ptr
))
<
0
)
giterr_set
(
GITERR_OS
,
"failed to link '%s'"
,
from
->
ptr
);
}
else
if
(
S_ISLNK
(
from_st
.
st_mode
))
{
error
=
cp_link
(
from
->
ptr
,
info
->
to
.
ptr
,
(
size_t
)
from_st
.
st_size
);
}
else
{
...
...
src/ident.c
View file @
f2ef6cee
...
...
@@ -56,7 +56,7 @@ static int ident_insert_id(
return
GIT_PASSTHROUGH
;
need_size
=
(
size_t
)(
id_start
-
from
->
ptr
)
+
5
/* "$Id: " */
+
GIT_OID_HEXSZ
+
1
/* "
$" */
+
5
/* "$Id: " */
+
GIT_OID_HEXSZ
+
2
/* "
$" */
+
(
size_t
)(
from_end
-
id_end
);
if
(
git_buf_grow
(
to
,
need_size
)
<
0
)
...
...
@@ -65,7 +65,7 @@ static int ident_insert_id(
git_buf_set
(
to
,
from
->
ptr
,
(
size_t
)(
id_start
-
from
->
ptr
));
git_buf_put
(
to
,
"$Id: "
,
5
);
git_buf_put
(
to
,
oid
,
GIT_OID_HEXSZ
);
git_buf_put
c
(
to
,
'$'
);
git_buf_put
(
to
,
" $"
,
2
);
git_buf_put
(
to
,
id_end
,
(
size_t
)(
from_end
-
id_end
));
return
git_buf_oom
(
to
)
?
-
1
:
0
;
...
...
src/indexer.c
View file @
f2ef6cee
...
...
@@ -316,6 +316,13 @@ on_error:
return
-
1
;
}
GIT_INLINE
(
bool
)
has_entry
(
git_indexer
*
idx
,
git_oid
*
id
)
{
khiter_t
k
;
k
=
kh_get
(
oid
,
idx
->
pack
->
idx_cache
,
id
);
return
(
k
!=
kh_end
(
idx
->
pack
->
idx_cache
));
}
static
int
save_entry
(
git_indexer
*
idx
,
struct
entry
*
entry
,
struct
git_pack_entry
*
pentry
,
git_off_t
entry_start
)
{
int
i
,
error
;
...
...
@@ -330,8 +337,11 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
pentry
->
offset
=
entry_start
;
k
=
kh_put
(
oid
,
idx
->
pack
->
idx_cache
,
&
pentry
->
sha1
,
&
error
);
if
(
!
error
)
if
(
error
<=
0
)
{
giterr_set
(
GITERR_INDEXER
,
"cannot insert object into pack"
);
return
-
1
;
}
kh_value
(
idx
->
pack
->
idx_cache
,
k
)
=
pentry
;
...
...
@@ -459,13 +469,14 @@ 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
current_size
=
idx
->
pack
->
mwf
.
size
;
int
fd
=
idx
->
pack
->
mwf
.
fd
;
if
(
!
size
)
return
0
;
/* add the extra space we need at the end */
if
(
p_ftruncate
(
idx
->
pack
->
mwf
.
fd
,
current_size
+
size
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"
Failed to increase size of pack
file '%s'"
,
idx
->
pack
->
pack_name
);
if
(
p_lseek
(
fd
,
current_size
+
size
-
1
,
SEEK_SET
)
<
0
||
p_write
(
idx
->
pack
->
mwf
.
fd
,
data
,
1
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"
cannot extend pack
file '%s'"
,
idx
->
pack
->
pack_name
);
return
-
1
;
}
...
...
@@ -782,6 +793,9 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
git_oid_fromraw
(
&
base
,
base_info
);
git_mwindow_close
(
&
w
);
if
(
has_entry
(
idx
,
&
base
))
return
0
;
if
(
inject_object
(
idx
,
&
base
)
<
0
)
return
-
1
;
...
...
src/openssl_stream.c
View file @
f2ef6cee
...
...
@@ -243,6 +243,9 @@ int openssl_connect(git_stream *stream)
return
ssl_set_error
(
st
->
ssl
,
ret
);
}
/* specify the host in case SNI is needed */
SSL_set_tlsext_host_name
(
st
->
ssl
,
st
->
socket
->
host
);
if
((
ret
=
SSL_connect
(
st
->
ssl
))
<=
0
)
return
ssl_set_error
(
st
->
ssl
,
ret
);
...
...
src/pack.c
View file @
f2ef6cee
...
...
@@ -951,8 +951,15 @@ git_off_t get_delta_base(
if
(
k
!=
kh_end
(
p
->
idx_cache
))
{
*
curpos
+=
20
;
return
((
struct
git_pack_entry
*
)
kh_value
(
p
->
idx_cache
,
k
))
->
offset
;
}
else
{
/* If we're building an index, don't try to find the pack
* entry; we just haven't seen it yet. We'll make
* progress again in the next loop.
*/
return
GIT_PASSTHROUGH
;
}
}
/* The base entry _must_ be in the same pack */
if
(
pack_entry_find_offset
(
&
base_offset
,
&
unused
,
p
,
(
git_oid
*
)
base_info
,
GIT_OID_HEXSZ
)
<
0
)
return
packfile_error
(
"base entry delta is not in the same pack"
);
...
...
src/path.c
View file @
f2ef6cee
...
...
@@ -1038,12 +1038,16 @@ int git_path_direach(
if
((
error
=
git_buf_put
(
path
,
de_path
,
de_len
))
<
0
)
break
;
giterr_clear
();
error
=
fn
(
arg
,
path
);
git_buf_truncate
(
path
,
wd_len
);
/* restore path */
/* Only set our own error if the callback did not set one already */
if
(
error
!=
0
)
{
giterr_set_after_callback
(
error
);
if
(
!
giterr_last
())
giterr_set_after_callback
(
error
);
break
;
}
}
...
...
src/refspec.c
View file @
f2ef6cee
...
...
@@ -42,6 +42,12 @@ int git_refspec__parse(git_refspec *refspec, const char *input, bool is_fetch)
*/
if
(
!
is_fetch
&&
rhs
==
lhs
&&
rhs
[
1
]
==
'\0'
)
{
refspec
->
matching
=
1
;
refspec
->
string
=
git__strdup
(
input
);
GITERR_CHECK_ALLOC
(
refspec
->
string
);
refspec
->
src
=
git__strdup
(
""
);
GITERR_CHECK_ALLOC
(
refspec
->
src
);
refspec
->
dst
=
git__strdup
(
""
);
GITERR_CHECK_ALLOC
(
refspec
->
dst
);
return
0
;
}
...
...
src/transports/ssh.c
View file @
f2ef6cee
...
...
@@ -125,10 +125,17 @@ static int ssh_stream_read(
return
-
1
;
if
((
rc
=
libssh2_channel_read
(
s
->
channel
,
buffer
,
buf_size
))
<
LIBSSH2_ERROR_NONE
)
{
ssh_error
(
s
->
session
,
"SSH could not read data"
);
;
ssh_error
(
s
->
session
,
"SSH could not read data"
);
return
-
1
;
}
/* Having something in stderr is typically a not-found error */
if
(
rc
==
0
&&
(
rc
=
libssh2_channel_read_stderr
(
s
->
channel
,
buffer
,
buf_size
))
>
0
)
{
giterr_set
(
GITERR_SSH
,
"%*s"
,
rc
,
buffer
);
return
-
1
;
}
*
bytes_read
=
rc
;
return
0
;
...
...
tests/checkout/crlf.c
View file @
f2ef6cee
...
...
@@ -196,29 +196,29 @@ void test_checkout_crlf__with_ident(void)
if
(
GIT_EOL_NATIVE
==
GIT_EOL_LF
)
{
cl_assert_equal_file
(
ALL_LF_TEXT_RAW
"
\n
$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467$
\n
"
,
"
\n
$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467
$
\n
"
,
0
,
"crlf/lf.ident"
);
cl_assert_equal_file
(
ALL_CRLF_TEXT_AS_LF
"
\n
$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857$
\n\n
"
,
"
\n
$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857
$
\n\n
"
,
0
,
"crlf/crlf.ident"
);
}
else
{
cl_assert_equal_file
(
ALL_LF_TEXT_AS_CRLF
"
\r\n
$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467$
\r\n
"
,
"
\r\n
$Id: fcf6d4d9c212dc66563b1171b1cd99953c756467
$
\r\n
"
,
0
,
"crlf/lf.ident"
);
cl_assert_equal_file
(
ALL_CRLF_TEXT_RAW
"
\r\n
$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857$
\r\n\r\n
"
,
"
\r\n
$Id: f2c66ad9b2b5a734d9bf00d5000cc10a62b8a857
$
\r\n\r\n
"
,
0
,
"crlf/crlf.ident"
);
}
cl_assert_equal_file
(
"$Id: f7830382dac1f1583422be5530fdfbd26289431b$
\n
"
"$Id: f7830382dac1f1583422be5530fdfbd26289431b
$
\n
"
MORE_LF_TEXT_AS_LF
,
0
,
"crlf/more1.identlf"
);
cl_assert_equal_file
(
"
\r\n
$Id: 74677a68413012ce8d7e7cfc3f12603df3a3eac4$
\r\n
"
"
\r\n
$Id: 74677a68413012ce8d7e7cfc3f12603df3a3eac4
$
\r\n
"
MORE_CRLF_TEXT_AS_CRLF
,
0
,
"crlf/more2.identcrlf"
);
git_index_free
(
index
);
...
...
tests/filter/blob.c
View file @
f2ef6cee
...
...
@@ -105,11 +105,11 @@ void test_filter_blob__ident(void)
cl_git_pass
(
git_blob_filtered_content
(
&
buf
,
blob
,
"filter.identcrlf"
,
1
));
cl_assert_equal_s
(
"Some text
\r\n
$Id: 3164f585d548ac68027d22b104f2d8100b2b6845$
\r\n
Goes there
\r\n
"
,
buf
.
ptr
);
"Some text
\r\n
$Id: 3164f585d548ac68027d22b104f2d8100b2b6845
$
\r\n
Goes there
\r\n
"
,
buf
.
ptr
);
cl_git_pass
(
git_blob_filtered_content
(
&
buf
,
blob
,
"filter.identlf"
,
1
));
cl_assert_equal_s
(
"Some text
\n
$Id: 3164f585d548ac68027d22b104f2d8100b2b6845$
\n
Goes there
\n
"
,
buf
.
ptr
);
"Some text
\n
$Id: 3164f585d548ac68027d22b104f2d8100b2b6845
$
\n
Goes there
\n
"
,
buf
.
ptr
);
git_buf_free
(
&
buf
);
git_blob_free
(
blob
);
...
...
tests/filter/custom.c
View file @
f2ef6cee
...
...
@@ -318,7 +318,7 @@ void test_filter_custom__order_dependency(void)
/* expansion because reverse was applied at checkin and at ident time,
* reverse is not applied yet */
cl_assert_equal_s
(
"Another test
\n
$59001fe193103b1016b27027c0c827d036fd0ac8 :dI$
\n
Crazy!
\n
"
,
buf
.
ptr
);
"Another test
\n
$
59001fe193103b1016b27027c0c827d036fd0ac8 :dI$
\n
Crazy!
\n
"
,
buf
.
ptr
);
cl_assert_equal_i
(
0
,
git_oid_strcmp
(
git_blob_id
(
blob
),
"8ca0df630d728c0c72072b6101b301391ef10095"
));
git_blob_free
(
blob
);
...
...
tests/filter/ident.c
View file @
f2ef6cee
...
...
@@ -49,22 +49,22 @@ void test_filter_ident__to_worktree(void)
add_blob_and_filter
(
"Hello
\n
$Id$
\n
Fun stuff
\n
"
,
fl
,
"Hello
\n
$Id: b69e2387aafcaf73c4de5b9ab59abe27fdadee30$
\n
Fun stuff
\n
"
);
"Hello
\n
$Id: b69e2387aafcaf73c4de5b9ab59abe27fdadee30
$
\n
Fun stuff
\n
"
);
add_blob_and_filter
(
"Hello
\n
$Id: Junky$
\n
Fun stuff
\n
"
,
fl
,
"Hello
\n
$Id: 45cd107a7102911cb2a7df08404674327fa050b9$
\n
Fun stuff
\n
"
);
"Hello
\n
$Id: 45cd107a7102911cb2a7df08404674327fa050b9
$
\n
Fun stuff
\n
"
);
add_blob_and_filter
(
"$Id$
\n
At the start
\n
"
,
fl
,
"$Id: b13415c767abc196fb95bd17070e8c1113e32160$
\n
At the start
\n
"
);
"$Id: b13415c767abc196fb95bd17070e8c1113e32160
$
\n
At the start
\n
"
);
add_blob_and_filter
(
"At the end
\n
$Id$"
,
fl
,
"At the end
\n
$Id: 1344925c6bc65b34c5a7b50f86bf688e48e9a272$"
);
"At the end
\n
$Id: 1344925c6bc65b34c5a7b50f86bf688e48e9a272
$"
);
add_blob_and_filter
(
"$Id$"
,
fl
,
"$Id: b3f5ebfb5843bc43ceecff6d4f26bb37c615beb1$"
);
"$Id: b3f5ebfb5843bc43ceecff6d4f26bb37c615beb1
$"
);
add_blob_and_filter
(
"$Id: Some sort of junk goes here$"
,
fl
,
"$Id: ab2dd3853c7c9a4bff55aca2bea077a73c32ac06$"
);
"$Id: ab2dd3853c7c9a4bff55aca2bea077a73c32ac06
$"
);
add_blob_and_filter
(
"$Id: "
,
fl
,
"$Id: "
);
add_blob_and_filter
(
"$Id"
,
fl
,
"$Id"
);
...
...
tests/network/refspecs.c
View file @
f2ef6cee
...
...
@@ -146,3 +146,13 @@ void test_network_refspecs__invalid_reverse(void)
assert_invalid_rtransform
(
"refs/heads/*:refs/remotes/origin/*"
,
"master"
);
assert_invalid_rtransform
(
"refs/heads/*:refs/remotes/origin/*"
,
"refs/remotes/o/master"
);
}
void
test_network_refspecs__matching
(
void
)
{
git_refspec
spec
;
cl_git_pass
(
git_refspec__parse
(
&
spec
,
":"
,
false
));
cl_assert_equal_s
(
":"
,
spec
.
string
);
cl_assert_equal_s
(
""
,
spec
.
src
);
cl_assert_equal_s
(
""
,
spec
.
dst
);
}
tests/odb/foreach.c
View file @
f2ef6cee
...
...
@@ -71,15 +71,35 @@ static int foreach_stop_cb(const git_oid *oid, void *data)
return
(
*
nobj
==
1000
)
?
-
321
:
0
;
}
static
int
foreach_stop_first_cb
(
const
git_oid
*
oid
,
void
*
data
)
{
int
*
nobj
=
data
;
(
*
nobj
)
++
;
GIT_UNUSED
(
oid
);
return
-
123
;
}
void
test_odb_foreach__interrupt_foreach
(
void
)
{
int
nobj
=
0
;
git_oid
id
;
cl_git_pass
(
git_repository_open
(
&
_repo
,
cl_fixture
(
"testrepo.git"
)));
git_repository_odb
(
&
_odb
,
_repo
);
cl_assert_equal_i
(
-
321
,
git_odb_foreach
(
_odb
,
foreach_stop_cb
,
&
nobj
));
cl_assert
(
nobj
==
1000
);
git_odb_free
(
_odb
);
git_repository_free
(
_repo
);
cl_git_pass
(
git_repository_init
(
&
_repo
,
"onlyloose.git"
,
true
));
git_repository_odb
(
&
_odb
,
_repo
);
cl_git_pass
(
git_odb_write
(
&
id
,
_odb
,
""
,
0
,
GIT_OBJ_BLOB
));
cl_assert_equal_i
(
-
123
,
git_odb_foreach
(
_odb
,
foreach_stop_first_cb
,
&
nobj
));
}
void
test_odb_foreach__files_in_objects_dir
(
void
)
...
...
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