Commit Graph

5238 Commits

Author SHA1 Message Date
Vicent Marti
d88e6e9b3c mkdir-ext: Retry lstat on EEXIST race 2015-03-19 18:38:13 +01:00
Tony Kelman
b631e0d96d Use swprintf_s everywhere except mingw.org 2015-03-19 08:42:45 -07:00
Carlos Martín Nieto
2c4e90f3fa Merge pull request #2996 from ethomson/dll_comments
win32 resource: allow custom comments field in DLL
2015-03-19 01:03:41 +01:00
Edward Thomson
523526e55d win32 resource: allow custom comments field in DLL 2015-03-18 18:25:14 -04:00
Edward Thomson
89ba9f1acc Merge pull request #2967 from jacquesg/merge-whitespace
Allow merges of files (and trees) with whitespace problems/fixes
2015-03-18 13:17:04 -04:00
Leo Yang
142e5379ca Add a custom param to git_smart_subtransport_definition
The smart transport has already take the payload param. For the
sub transport a payload param is useful for the implementer.
2015-03-18 13:15:21 -04:00
Carlos Martín Nieto
03b51b5d94 Merge pull request #2955 from git-up/update_tips_fixes
Update tips fixes
2015-03-18 05:04:12 +01:00
Carlos Martín Nieto
83ad46f726 Merge remote-tracking branch 'ethomson/submodule_8dot3' 2015-03-18 04:59:16 +01:00
Edward Thomson
fa8a38a490 Merge pull request #2983 from jeffhostetler/jeffhostetler/perf_merge_lazy_binary_check
PERF: In MERGE, lazily compute is_binary
2015-03-17 22:22:38 -04:00
Sebastian Bauer
cdedef4061 Initialize refs vector in git_remote_update_tips().
Otherwise, bailing out early when ls_to_vector() fails accesses
uninitialized memory.
2015-03-17 22:03:51 +01:00
Carlos Martín Nieto
c84a9dd2da local: recusrively insert non-branch objects into the packfile
When we insert e.g. a tag or tagged object into the packfile, we must
make sure to insert any referenced objects as well, or we will have
broken links.

Use the recursive version of packfile insertion to make sure we send
over not just the tagged object but also the objects it references.
2015-03-17 20:51:47 +01:00
Carlos Martín Nieto
84511143fd tree: add more correct error messages for not found
Don't use the full path, as that's not what we are asserting does not
exist, but just the subpath we were looking up.
2015-03-17 20:51:14 +01:00
Carlos Martín Nieto
a61fa4c0c7 packbuilder: introduce git_packbuilder_insert_recur()
This function recursively inserts the given object and any referenced
ones. It can be thought of as a more general version of the functions to
insert a commit or tree.
2015-03-17 20:51:14 +01:00
Carlos Martín Nieto
385449b1df note: use a git_buf to return the default namespace
The caller has otherwise no way to know how long the string will be
allocated or ability to free it.

This fixes #2944.
2015-03-17 20:50:02 +01:00
Edward Thomson
9bbc8f350b Merge pull request #2962 from libgit2/cmn/reflog-annotated
Add annotated versions of ref-modying functions
2015-03-17 10:21:28 -04:00
Edward Thomson
7800048afb Merge pull request #2972 from libgit2/cmn/pack-objects-walk
[WIP] Smarter pack-building
2015-03-17 10:06:50 -04:00
Edward Thomson
828e595969 Merge pull request #2982 from libgit2/cmn/stream-check-ec
Don't ask for a stream's certificate unless it's encrypted
2015-03-17 09:44:56 -04:00
Edward Thomson
c07d02064d Merge pull request #2977 from pks-t/submodule-sync-url-fix
Fix git_submodule_sync writing URL to wrong key.
2015-03-17 09:44:25 -04:00
Alex Crichton
3066026b04 Fix build on mingw-w64 2015-03-16 13:59:29 -07:00
Philip Kelley
8f426d7dd2 Win32: Enable WinHTTP for MinGW 2015-03-16 12:59:55 -07:00
Jeff Hostetler
fea24c5300 PERF: In MERGE, lazily compute is_binary 2015-03-16 15:54:53 -04:00
Carlos Martín Nieto
84d83b8e75 http: do not try to use the cert callback on unencrypted streams
When the user has a certificate check callback set, we still have to
check whether the stream we're using is even capable of providing a
certificate.

In the case of an unencrypted certificate, do not ask for it from the
stream, and do not call the callback.
2015-03-16 19:43:46 +01:00
Carlos Martín Nieto
62dd4d71db annotated_commit: provide a constructor from a revspec
This extra constructor will be useful for the annotated versions of
ref-modifying functions, as it allows us to create a commit with the
extended sha syntax which was used to retrieve it.
2015-03-16 16:57:30 +01:00
Carlos Martín Nieto
62d38a1ddb Add annotated commit versions of reflog-modifying functions
We do not always want to put the id directly into the reflog, but we
want to speicfy what a user typed. For this use-case we provide
annotated version of a few functions which let the caller specify what
user-friendly name was used when asking for the operation.
2015-03-16 16:57:30 +01:00
Jacques Germishuys
74c37c2a48 Added options to enable patience and minimal diff drivers 2015-03-16 09:53:27 +02:00
Jacques Germishuys
13de936316 Collapse whitespace flags into git_merge_file_flags_t 2015-03-16 09:53:27 +02:00
Jacques Germishuys
f29dde6828 Renamed git_merge_options 'flags' to 'tree_flags' 2015-03-16 09:53:27 +02:00
Jacques Germishuys
45a86bbfd0 Allow for merges with whitespace discrepancies 2015-03-16 09:53:27 +02:00
Carlos Martín Nieto
d675982a15 Merge pull request #2975 from git-up/diff_index_retain
Avoid retaining / releasing the index more than necessary when GIT_DIFF_...
2015-03-15 00:24:36 +01:00
Carlos Martín Nieto
7c63a33ffe indexer: bring back the error message on duplcate commits
It turns out that erroring out on duplicate commits is the right thing
to do, but git was not hitting the bug on the server-side.

Bring back a descriptive error message in case of duplicate entries and
error out.
2015-03-13 19:41:40 +01:00
Carlos Martín Nieto
dccf59ad38 indexer: don't worry about duplicate objects
If a packfile includes duplicate objects, we can choose to use the
secon copy instead of the first by using the same logic as if it were
the first.

Change the error condition from 0 to -1, which indicates a bad resize,
and set the OOM message in that case.

This does mean we will leak the first copy of the object. We can deal
with that later, but making fetches work is more important.
2015-03-13 18:28:07 +01:00
Carlos Martín Nieto
a34692c419 indexer: set an error message on duplicate objects in pack
While this is not even close to a fix, we can at least set an error
message so we know which error we are facing. Up to know we just
returned an error without a message.
2015-03-13 18:00:15 +01:00
Edward Thomson
12e1fff79d Merge pull request #2973 from libgit2/cmn/local-pack-threading
local: create pack with multiple threads
2015-03-12 18:04:25 -04:00
Patrick Steinhardt
e6903ea278 Fix git_submodule_sync writing URL to wrong key.
Currently git_submodule_sync writes the submodule's URL to the
key 'branch.<REMOTE_NAME>.remote' while the reference
implementation of `git submodule sync` writes to
'remote.<REMOTE_NAME>.url', which is the intended behavior
according to git-submodule(1).
2015-03-12 16:05:07 +01:00
Pierre-Olivier Latour
8a3934e49b Avoid retaining / releasing the index more than necessary when GIT_DIFF_UPDATE_INDEX is enabled 2015-03-11 19:29:36 -07:00
Pierre-Olivier Latour
1034f1b583 Fixed active refspecs not reset by git_remote_upload() 2015-03-11 11:51:12 -07:00
Pierre-Olivier Latour
e22ffb4209 Fixed update_tips callback called for failed pushed references
The current implementation does not set 'fire_callback' back to 0 for failed updates so the callback still fires.

Instead of adding yet another condition check to set 'fire_callback' to 0 if needed, considering this function should be a no-op for failed updates anyway, the best fix is to simplify its logic to check upfront if the update is a failed one.
2015-03-11 11:51:12 -07:00
Carlos Martín Nieto
15f581747c Merge commit 'refs/pull/2879/head' of ssh://github.com/libgit2/libgit2 2015-03-11 17:55:39 +01:00
Carlos Martín Nieto
0ef54a6358 local: create pack with multiple threads
The default behaviour for the packbuilder is to perform the work in a
single thread, which is fine for the public API, but we currently have
no way for a user to determine the number of threads to use when
creating the packfile, which makes our clone behaviour over the
filesystem quite a bit slower than what git offers.

This is a very particular scenario, in which we avoid spawning git by
being ourselves the server-side, so it's probably ok to auto-set the
threading, as the upload-pack process would do if we were talking to
git.
2015-03-11 17:24:14 +01:00
Carlos Martín Nieto
61ccba0d56 Merge pull request #2969 from adrienthebo/remote_add_invalid_refspec
refspec: report errors when parsing an invalid refspec
2015-03-11 16:13:31 +01:00
Carlos Martín Nieto
522df1cf1d Merge pull request #2970 from ethomson/inmemory_bare
"In-memory" repos are bare by default
2015-03-11 03:03:54 +01:00
Carlos Martín Nieto
e68b31a1a9 local: let the packbuilder perform smarter object insertion
Currently we use the most naïve and inefficient method for figuring out
which objects to send to the remote whereby we end up trying to insert
subdirs which have not changed multiple times.

Instead, make use of the packbuilder's built-in more efficient method
which uses the walk to feed the object list and avoids inserting an
object and its descendants.
2015-03-11 02:37:25 +01:00
Carlos Martín Nieto
04a36feff1 pack-objects: fill a packbuilder from a walk
Most use-cases for the object packer communicate in terms of commits
which each side has. We already have an object to specify this
relationship between commits, namely git_revwalk.

By knowing which commits we want to pack and which the other side
already has, we can perform similar optimisations to git, by marking
each tree as interesting or uninteresting only once, and not sending
those trees which we know the other side has.
2015-03-11 02:36:11 +01:00
Carlos Martín Nieto
b63b76e0b0 Reorder some khash declarations
Keep the definitions in the headers, while putting the declarations in
the C files. Putting the function definitions in headers causes
them to be duplicated if you include two headers with them.
2015-03-11 02:36:11 +01:00
Adrien Thebo
b523194d21 refspec: set err message on invalid refspec
If a refspec could not be parsed, the git_refspec__parse function would
return an error value but would not provide additional error information
for the callers. This commit amends that function to set a more useful
error message.
2015-03-10 13:31:26 -07:00
Edward Thomson
770aca94bd repository: in-memory repos are bare by default 2015-03-10 15:02:02 -04:00
Edward Thomson
d7c81945b0 Merge pull request #2964 from git-up/fixes
Fixes
2015-03-09 10:18:39 -04:00
Edward Thomson
959482e104 Merge pull request #2946 from tkelman/appveyor-mingw
RFC: add mingw to appveyor matrix
2015-03-09 09:18:37 -04:00
Pierre-Olivier Latour
2461e0d20f Removed unnecessary GIT_CHECKOUT_SKIP_UNMERGED for GIT_RESET_HARD 2015-03-08 14:10:02 -07:00
Carlos Martín Nieto
d578b45f3f refdb: use the same id for old and new when renaming a reference
When we rename a reference, we want the old and new ids to be the same
one (as we did not change it). The normal code path looks up the old id
from the current value of the brtanch, but by the time we look it up, it
does not exist anymore and thus we write a zero id.

Pass the old id explicitly instead.
2015-03-08 16:50:27 +01:00
Edward Thomson
01c3b184d3 Merge pull request #2961 from ethomson/filter_relative_paths
Filter relative paths
2015-03-06 16:52:07 -05:00
Edward Thomson
6a2edc5a11 filter: accept relative paths in apply_to_file 2015-03-06 15:16:40 -05:00
Matti Virolainen
78c34af016 Use secure API if available. 2015-03-06 12:07:54 -08:00
Tony Kelman
04c5a9c083 Add some missing definitions for mingw.org
these shouldn't be necessary if _WIN32_WINNT >= _WIN32_WINNT_VISTA
2015-03-06 12:07:05 -08:00
Tony Kelman
1a7ea63d22 Move definitions of strcasecmp and strncasecmp to msvc-compat.h
should cut down on compiler warnings with mingw
2015-03-06 12:07:05 -08:00
Edward Thomson
9a823badbf filter: drop old TODO 2015-03-06 14:37:41 -05:00
nulltoken
05e644dd7e Drop trailing whitespaces 2015-03-04 22:09:51 +01:00
nulltoken
7eb7673406 branch: fix generated reflog message upon renaming 2015-03-04 22:09:49 +01:00
nulltoken
015d4b7b38 branch: fix generated reflog message upon creation 2015-03-04 22:09:44 +01:00
Carlos Martín Nieto
bdf0e73450 Merge pull request #2932 from jeffhostetler/jeffhostetler/big_clone_crash
Fix crash in git_clone on extremely large repos
2015-03-04 14:55:56 +01:00
Edward Thomson
8e851c1e8c libgit2_shutdown: free TLS data (win32)
Free TLS data on thread exit (win32)
2015-03-04 14:48:46 +01:00
Edward Thomson
83fe60fa1b libgit2_shutdown: clear err message on shutdown
Clear the error message on git_libgit2_shutdown for all versions of
the library (no threads and Win32 threads).  Drop the giterr_clear
in clar, as that shouldn't be necessary.
2015-03-04 14:48:46 +01:00
Leo Yang
3a8b69d13d Fix leak of TLS error message in shutdown (ptherad version) 2015-03-04 14:47:57 +01:00
Carlos Martín Nieto
c69c042e0e Merge pull request #2945 from ethomson/empty_hashsig_heap
diff_tform: don't compare empty hashsig_heaps
2015-03-04 12:47:59 +01:00
Edward Thomson
f78d9b6cfe diff_tform: account for whitespace options
When comparing seemingly blank files, take whitespace options into
account.
2015-03-04 00:01:34 -05:00
Carlos Martín Nieto
fe21d708b0 Plug a few leaks 2015-03-04 00:29:37 +01:00
Edward Thomson
a212716fc3 diff_tform: don't compare empty hashsig_heaps
Don't try to compare two empty hashsig_heaps.
2015-03-03 18:19:42 -05:00
Edward Thomson
9ce97782b4 Merge pull request #2941 from libgit2/cmn/http-enforce-cred
http: enforce the credential types
2015-03-03 17:59:44 -05:00
Jeff Hostetler
d8be508777 Change ifdef for MINGW32. 2015-03-03 13:35:10 -05:00
Carlos Martín Nieto
9a97f49e3a config: borrow refcounted references
This changes the get_entry() method to return a refcounted version of
the config entry, which you have to free when you're done.

This allows us to avoid freeing the memory in which the entry is stored
on a refresh, which may happen at any time for a live config.

For this reason, get_string() has been forbidden on live configs and a
new function get_string_buf() has been added, which stores the string in
a git_buf which the user then owns.

The functions which parse the string value takea advantage of the
borrowing to parse safely and then release the entry.
2015-03-03 18:35:12 +01:00
Carlos Martín Nieto
e892b6a927 http: enforce the credential types
The user may decide to return any type of credential, including ones we
did not say we support. Add a check to make sure the user returned an
object of the right type and error out if not.
2015-03-03 18:07:16 +01:00
Carlos Martín Nieto
76f034180a Remove swp files 2015-03-03 17:04:38 +01:00
Edward Thomson
20273e4d3c Merge pull request #2934 from akikoskinen/mingw_build_fix
Fix build on mingw (master branch)
2015-03-03 10:08:51 -05:00
Edward Thomson
018fdbb580 Merge pull request #2913 from ethomson/stash_fixup
stash: correctly stash wd modified/index deleted
2015-03-03 10:08:28 -05:00
Jeff Hostetler
7e9b21aa2a Fix p_ftruncate to handle big files for git_clone 2015-03-03 08:47:44 -05:00
Carlos Martín Nieto
4e498646b6 repository: remove log message override for switching the active branch
We want to use the "checkout: moving from ..." message in order to let
git know when a change of branch has happened. Make the convenience
functions for this goal write this message.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
412a380888 push: remove reflog message override
We always use "update by push".
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
6bfb990dc7 branch: don't accept a reflog message override
This namespace is about behaving like git's branch command, so let's do
exactly that instead of taking a reflog message.

This override is still available via the reference namespace.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
23a17803b6 reset: remove reflog message override
This function is meant to simulate what git does in the reset command,
so we should include the reflog message in that.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
659cf2029f Remove the signature from ref-modifying functions
The signature for the reflog is not something which changes
dynamically. Almost all uses will be NULL, since we want for the
repository's default identity to be used, making it noise.

In order to allow for changing the identity, we instead provide
git_repository_set_ident() and git_repository_ident() which allow a user
to override the choice of signature.
2015-03-03 14:40:50 +01:00
Carlos Martín Nieto
99b68a2aec Merge pull request #2908 from ethomson/safe_create
Allow checkout to handle newly cloned repositories, remove `GIT_CHECKOUT_SAFE_CREATE`
2015-03-03 13:47:13 +01:00
Carlos Martín Nieto
31bc6c0440 branch: do capture the error code
We want to ignore GIT_ENOTFOUND, but for that we need to capture the
error code from the reflog deletion.
2015-03-03 13:25:40 +01:00
Carlos Martín Nieto
5ac2b7cb2a Merge pull request #2937 from git-up/branch_delete_reflog
git_branch_delete() should ignore errors from non-existing reflogs
2015-03-03 13:03:54 +01:00
Pierre-Olivier Latour
7986391719 git_branch_delete() should ignore errors from non-existing reflogs 2015-03-02 10:24:54 -08:00
Edward Thomson
bf1476f190 win32: add the patch level to the .dll fileversion
Win32 DLLs have four fields for the version number (major, minor,
teeny, patch).  If a consumer wants to build a custom DLL, it may
be useful to set the patchlevel version number in the DLL.

This value only affects the DLL version number, it does not affect
the resultant "version number", which remains major.minor.teeny.
2015-03-02 10:35:26 -05:00
Aki Koskinen
45df2237bf Include ws2tcpip.h in order to get in6_addr
It's currently required in src/openssl_stream.c only.
2015-03-02 11:15:32 +02:00
Aki Koskinen
ec03244227 Include openssl headers last
Windows headers #define some names that openssl uses too. Openssl
headers #undef the offending names before reusing them. But if those
offending Windows headers get included after the openssl headers the
namespace is polluted and nothing good happens.

Fixes issue #2850.
2015-03-02 11:15:13 +02:00
Aki Koskinen
a944c6cc40 Don't include headers on windows that aren't available
This mainly concerns mingw build.
2015-03-02 11:14:07 +02:00
Edward Thomson
96b82b11c6 checkout: remove GIT_CHECKOUT_SAFE_CREATE as a strategy 2015-02-27 13:50:44 -05:00
Edward Thomson
e6da3e4496 checkout: upgrade to SAFE_CREATE when no index file
When the repository does not contain an index, emulate git's behavior
and upgrade to `SAFE_CREATE`.  This allows us to check out repositories
created with `git clone --no-checkout`.
2015-02-27 13:50:32 -05:00
Edward Thomson
094cfc2904 cherrypick, revert: drop unnecessary SAFE_CREATE 2015-02-27 13:47:30 -05:00
Edward Thomson
3cbaa5872c rebase: check alloc result 2015-02-27 04:39:54 +00:00
Edward Thomson
4196dd8e8f repository: Introduce "reserved names"
A repository can have multiple "reserved names" now, not just
a single "short name" for the repository folder itself.  Refactor
to include a git_repository__reserved_names that returns all the
reserved names for a repository.
2015-02-27 04:36:47 +00:00
Damien PROFETA
a275fbc0f7 Add API to add a memory buffer to an index
git_index_add_frombuffer enables now to store a memory buffer in the odb
and to store an entry in the index directly if the index is attached to a
repository.
2015-02-25 10:24:13 +01:00
Jeff Hostetler
c92987d157 Fix MAX 32 bit build problem described in libgit2/libgit2#2917 2015-02-20 18:59:43 +01:00
Carlos Martín Nieto
5091aff782 Merge pull request #2907 from jasonhaslam/git_packfile_unpack_race
Fix race in git_packfile_unpack.
2015-02-20 08:40:40 +01:00
Edward Thomson
9c9aa1bad3 filter: take temp_buf in git_filter_options 2015-02-19 11:45:46 -05:00
Edward Thomson
d05218b06f filter: add git_filter_list__load_ext
Refactor `git_filter_list__load_with_attr_reader` into
`git_filter_list__load_ext`, which takes a `git_filter_options`.
2015-02-19 11:25:26 -05:00
Edward Thomson
795eaccd66 git_filter_opt_t -> git_filter_flag_t
For consistency with the rest of the library, where an opt is an
options *structure*.
2015-02-19 11:09:54 -05:00
Edward Thomson
d4cf167515 buffer: introduce git_buf_attach_notowned
Provide a convenience function that creates a buffer that can be provided
to callers but will not be freed via `git_buf_free`, so the buffer
creator maintains the allocation lifecycle of the buffer's contents.
2015-02-19 10:05:33 -05:00
Edward Thomson
09866d6f84 stash: correctly stash wd modified/index deleted 2015-02-18 11:26:03 -05:00
Edward Thomson
b49edddcd0 checkout: let the stream writer close the fd 2015-02-18 10:24:43 -05:00
Edward Thomson
f7c0125f47 filter streams: base -> parent 2015-02-18 10:24:34 -05:00
Edward Thomson
b75f15aaf1 git_writestream: from git_filter_stream 2015-02-18 10:24:23 -05:00
Edward Thomson
646364e780 checkout: maintain temporary buffer for filters
Let the filters use the checkout data's temporary buffer, instead
of having to allocate new buffers each time.
2015-02-17 16:03:45 -05:00
Edward Thomson
e78f5c9f42 checkout: stream the blob into the filters
Use the new streaming filter API during checkout.
2015-02-17 15:57:10 -05:00
Edward Thomson
5555696f8a filters: stream internally
Migrate the `git_filter_list_apply_*` functions over to using the
new filter streams.
2015-02-17 15:57:04 -05:00
Edward Thomson
fbdc9db364 filters: introduce streaming filters
Add structures and preliminary functions to take a buffer, file or
blob and write the contents in chunks through an arbitrary number
of chained filters, finally writing into a user-provided function
accept the contents.
2015-02-17 02:19:05 -05:00
Stefan Widgren
c8e02b8776 Remove extra semicolon outside of a function
Without this change, compiling with gcc and pedantic generates warning:
ISO C does not allow extra ‘;’ outside of a function.
2015-02-15 21:07:05 +01:00
Jason Haslam
8588cb0cbf Fix race in git_packfile_unpack.
Increment refcount of newly added cache entries just like existing
entries looked up from the cache. Otherwise the new entry can be
evicted from the cache and destroyed while it's still in use.
2015-02-14 23:43:26 -07:00
Carlos Martín Nieto
a291790a8d Merge pull request #2831 from ethomson/merge_lock
merge: lock index during the merge (not just checkout)
2015-02-15 05:18:01 +01:00
Carlos Martín Nieto
a7fa970f8b Merge pull request #2895 from ethomson/alloc_overflow
allocations: test for overflow of requested size
2015-02-15 05:13:50 +01:00
Edward Thomson
41fae48df2 indexwriter: an indexwriter for repo operations
Provide git_indexwriter_init_for_operation for the common locking
pattern in merge, rebase, revert and cherry-pick.
2015-02-14 09:25:36 -05:00
Edward Thomson
be8404a768 merge-like operations: lock index while working 2015-02-14 09:25:35 -05:00
Edward Thomson
8b0ddd5dd9 merge: lock the index at the start of the merge
Always lock the index when we begin the merge, before we write
any of the metdata files.  This prevents a race where another
client may run a commit after we have written the MERGE_HEAD but
before we have updated the index, which will produce a merge
commit that is treesame to one parent.  The merge will finish and
update the index and the resultant commit would not be a merge at
all.
2015-02-14 09:25:35 -05:00
Edward Thomson
8639ea5f98 checkout: introduce GIT_CHECKOUT_DONT_WRITE_INDEX 2015-02-14 09:25:35 -05:00
Edward Thomson
55798fd153 git_indexwriter: lock then write the index
Introduce `git_indexwriter`, to allow us to lock the index while
performing additional operations, then complete the write (or abort,
unlocking the index).
2015-02-14 09:25:35 -05:00
Edward Thomson
ffbd51edc8 rebase: CHECKOUT_SAFE instead of FORCE
Switch to a standard branch-switching pattern of a `SAFE` checkout,
then updating `HEAD`.
2015-02-13 11:38:00 -05:00
Edward Thomson
49b8293c75 rebase: allow NULL branch to indicate HEAD
Don't require the branch to rebase, if given `NULL`, simply look up
`HEAD`.
2015-02-13 11:20:32 -05:00
Edward Thomson
92e87dd749 rebase: provide NULL exec on non-EXEC operations
Users may want to try to pay attention to the `exec` field on all
rebase operations.
2015-02-13 10:44:19 -05:00
Edward Thomson
0f07d54b44 pack-objects: unlock the cache on integer overflow 2015-02-13 09:35:20 -05:00
Edward Thomson
16942c6fda integer overflow: use compiler intrinsics if supported
gcc and clang support __builtin_add_overflow, use it whenever
possible, falling back to our naive routines.
2015-02-13 09:28:09 -05:00
Edward Thomson
8aab36a301 filebuf: use an int for return check 2015-02-13 09:28:05 -05:00
Edward Thomson
f1453c59b2 Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it.  This means dropping the ability to pass `NULL` as
an out parameter.

As a result, the macros also get updated to reflect this as well.
2015-02-13 09:27:33 -05:00
Edward Thomson
527ed59ad8 win32: limit the mode to _wopen/_waccess
Win32 generally ignores Unix-like mode bits that don't make any
sense on the platform (eg `0644` makes no sense to Windows).  But
WINE complains loudly when presented with POSIXy bits.  Remove them.

(Thanks @phkelley)
2015-02-13 09:18:49 -05:00
Carlos Martín Nieto
0b2ee7c07c Merge pull request #2883 from urkud/reget-reader-pointer
Reinit `reader` pointer after reading included config file
2015-02-13 08:56:01 +01:00
Carlos Martín Nieto
3ca91107fc Merge pull request #2897 from leoyanggit/fix_fileop_warning
Fix build warning on Android
2015-02-13 08:30:21 +01:00
Edward Thomson
650e45f691 Update khash.h to pull request 42
https://github.com/attractivechaos/klib/pull/42/files introduces
`kreallocarray`.  Hook that up as our `git__reallocarray`.
2015-02-12 22:54:48 -05:00
Edward Thomson
1ad48c8a08 khash: update to klib f28c067 2015-02-12 22:54:47 -05:00
Edward Thomson
190b76a698 Introduce git__add_sizet_overflow and friends
Add some helper functions to check for overflow in a type-specific
manner.
2015-02-12 22:54:47 -05:00
Edward Thomson
8d534b4758 p_read: ensure requested len is ssize_t
Ensure that the given length to `p_read` is of ssize_t and ensure
that callers test the return as if it were an `ssize_t`.
2015-02-12 22:54:47 -05:00
Edward Thomson
ec3b4d35f6 Use size_t to hold size of arrays
Use `size_t` to hold the size of arrays to ease overflow checking,
lest we check for overflow of a `size_t` then promptly truncate
by packing the length into a smaller type.
2015-02-12 22:54:47 -05:00
Edward Thomson
2884cc42de overflow checking: don't make callers set oom
Have the ALLOC_OVERFLOW testing macros also simply set_oom in the
case where a computation would overflow, so that callers don't
need to.
2015-02-12 22:54:47 -05:00
Edward Thomson
4aa664ae39 git_buf_grow_by: increase buf asize incrementally
Introduce `git_buf_grow_by` to incrementally increase the size of a
`git_buf`, performing an overflow calculation on the growth.
2015-02-12 22:54:47 -05:00
Edward Thomson
3603cb0978 git__*allocarray: safer realloc and malloc
Introduce git__reallocarray that checks the product of the number
of elements and element size for overflow before allocation.  Also
introduce git__mallocarray that behaves like calloc, but without the
`c`.  (It does not zero memory, for those truly worried about every
cycle.)
2015-02-12 22:54:47 -05:00
Edward Thomson
15d54fdd34 odb__hashlink: check st.st_size before casting 2015-02-12 22:54:46 -05:00
Edward Thomson
392702ee2c allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
2015-02-12 22:54:46 -05:00
Leo Yang
3556a82a2a Fix build warning on Android
Always do a time_t cast on st_mtime. st_mtime on Android is not
the type of time_t but has the same meaning which is the number
of seconds past epoch.
2015-02-12 16:38:55 -05:00
Yury G. Kudryashov
1713653883 Reinit reader pointer after reading included config file
Fixes #2869. If included file includes more files, it may reallocate
cfg_file->readers, hence invalidate not only `r` pointer, but `result`
pointer as well.
2015-02-13 00:15:16 +03:00
Jameson Miller
02eb1495a5 Check rebase options version on public entry points 2015-02-12 15:32:52 -05:00
Carlos Martín Nieto
d24a5312d8 Merge pull request #2866 from ethomson/checkout_perf2
Checkout performance
2015-02-12 02:34:58 +01:00
Carlos Martín Nieto
8e29ae7310 Merge pull request #2862 from jeffhostetler/jeffhostetler/bug/branch_create_after_namespace
Remove stale reflog namespace directory before branch creation
2015-02-12 00:43:01 +01:00
Carlos Martín Nieto
e07c1e1a15 Merge pull request #2880 from ethomson/mkdir_root
Ensure we can make a repo at the root of the filesystem
2015-02-12 00:40:12 +01:00
Edward Thomson
ec510666a1 Credit utf8proc for utf8 iterator 2015-02-10 21:34:08 -05:00
Carlos Martín Nieto
cc36f424d4 repository: parse init.templatedir as a path
This is a path so we must use the path getter so we get the tilde
expansion done.
2015-02-06 01:09:26 +01:00
Edward Thomson
9cb5b0f73c mkdir: respect the root path
Don't try to strip trailing paths from the root directory on
Windows (trying to create `C:` will fail).
2015-02-05 12:27:19 -05:00
Edward Thomson
3c68bfcd08 stat: don't remove trailing '/' from root on win32
`p_stat` calls `git_win32_path_from_utf8`, which canonicalizes the
path.  Do not further try to modify the path, else we trim the
trailing slash from a root directory and try to access `C:` instead
of `C:/`.
2015-02-05 12:27:16 -05:00
Edward Thomson
9bf5bd7cd8 Merge pull request #2867 from ethomson/8dot3
Handle 8dot3 filenames being disabled on Win32
2015-02-05 09:19:46 -05:00
Edward Thomson
a2e4593e82 hash_generic: __extension__ keyword for pedantry 2015-02-04 15:26:09 -05:00
Edward Thomson
fa89ff20cd remove some unused warnings 2015-02-04 14:15:13 +00:00
Edward Thomson
500ec54315 checkout: hold seen dir paths in a map 2015-02-04 14:15:13 +00:00
Edward Thomson
f58cc280c9 attr_session: keep a temp buffer 2015-02-04 14:15:13 +00:00
Edward Thomson
d4b1b76701 checkout: cache system attributes file location 2015-02-04 14:15:12 +00:00
Edward Thomson
710f66af35 bswap: remove unused bswap 2015-02-03 18:43:57 -05:00
Edward Thomson
5f28ec84a1 win32: cleanup 8.3 disabled tests 2015-02-03 12:23:04 -05:00
Jeff Hostetler
1589a93aa6 Fix branch creation when branch name matches namespace of previously deleted branch 2015-02-03 10:33:04 -05:00
Edward Thomson
9f779aacdd attrcache: don't re-read attrs during checkout
During checkout, assume that the .gitattributes files aren't
modified during the checkout.  Instead, create an "attribute session"
during checkout.  Assume that attribute data read in the same
checkout "session" hasn't been modified since the checkout started.
(But allow subsequent checkouts to invalidate the cache.)

Further, cache nonexistent git_attr_file data even when .gitattributes
files are not found to prevent re-scanning for nonexistent files.
2015-02-03 00:31:08 -05:00
Linquize
9dcc4a36f7 Fix test failures when 8.3 is disabled 2015-01-31 00:09:31 +08:00
Edward Thomson
1ac5acdc69 Merge pull request #2819 from libgit2/cmn/config-get-path
config: add parsing and getter for paths
2015-01-26 11:28:59 -06:00
Edward Thomson
2724219918 Merge pull request #2837 from swisspol/set_index
Allow passing a NULL index to git_repository_set_index()
2015-01-26 11:27:09 -06:00
Edward Thomson
ff80b5e80b Merge pull request #2847 from jacquesg/coverity
More coverity fixes
2015-01-26 11:24:47 -06:00
Edward Thomson
9f1ee63d8f Merge pull request #2841 from swisspol/set_bare
Fixed git_repository_set_bare() not setting "core.bare" correctly
2015-01-26 11:20:00 -06:00
Edward Thomson
65bc22fa50 Merge pull request #2844 from rakuco/netinet-include-fixes
openssl: Add all required includes for AF_INET6 and in6_addr.
2015-01-26 11:18:17 -06:00
Jacques Germishuys
bb6aafe88f Ensure the diff hunk callback is specified before trying to dereference it 2015-01-25 14:40:23 +02:00
Jacques Germishuys
636af2198e Return early if allocating a git_pathspec_match_list failed 2015-01-25 14:38:10 +02:00
Jacques Germishuys
b63b3b0e4d Ensure git_index_entry is not NULL before trying to free it 2015-01-25 14:08:05 +02:00
Boris Egorov
dc5fe00c65 pathspec: do not try to dereference NULL
pathspec_match_free() should not dereference a NULL passed to it.

I found this issue when I tried to run example log program with
nonexistent branch:

./example/log help

Such call leads to segmentation fault.
2015-01-25 01:40:44 +06:00
Raphael Kubo da Costa
3cda6be76b openssl: Add all required includes for AF_INET6 and in6_addr.
This fixes the build at least on FreeBSD, where those types were not
defined indirectly:

src/openssl_stream.c💯18: error: variable has incomplete type 'struct in6_addr'
        struct in6_addr addr6;
                        ^
src/openssl_stream.c💯9: note: forward declaration of 'struct in6_addr'
        struct in6_addr addr6;
               ^
src/openssl_stream.c:111:18: error: use of undeclared identifier 'AF_INET'
        if (p_inet_pton(AF_INET, host, &addr4)) {
                        ^
src/unix/posix.h:31:40: note: expanded from macro 'p_inet_pton'
                                       ^
src/openssl_stream.c:115:18: error: use of undeclared identifier 'AF_INET6'
                if(p_inet_pton(AF_INET6, host, &addr6)) {
                               ^
src/unix/posix.h:31:40: note: expanded from macro 'p_inet_pton'
                                       ^
2015-01-24 16:19:43 +02:00
Pierre-Olivier Latour
b2a7bcdb54 Fixed git_repository_set_bare() not setting "core.bare" correctly 2015-01-23 20:57:13 -08:00
Pierre-Olivier Latour
fa8ca519cc Allow passing a NULL index to git_repository_set_index()
This is supported by the underlying set_index() implementation
and setting the repository index to NULL is recommended by the
git_repository_set_bare() documentation.
2015-01-23 15:35:29 -08:00
Edward Thomson
1188803922 checkout: free last created directory 2015-01-23 00:19:11 +00:00
Edward Thomson
a789b36100 Merge pull request #2829 from jacquesg/dead-code
Remove logically dead code (we're already asserting)
2015-01-21 09:20:54 -06:00
Edward Thomson
e74340b000 checkout: remove files before writing new ones
On case insensitive filesystems, we may have files in the working
directory that case fold to a name we want to write.  Remove those
files (by default) so that we will not end up with a filename that
has the unexpected case.
2015-01-20 17:13:31 -06:00
Edward Thomson
c2dee0fcb0 checkout: drop newline in error message 2015-01-20 17:13:20 -06:00
Edward Thomson
b4cbd67f5f checkout: don't recreate previous directory
Don't bother trying to recreate the previously created directory
during checkout, for a modest reduction in the number of stats.
2015-01-20 17:12:58 -06:00
Edward Thomson
fe598f0903 mkdir: walk up tree to mkdir
Walk up the tree to mkdir, which is less immediately efficient,
but allows us to look at intermediate directories that may need
attention.
2015-01-20 17:12:46 -06:00
Edward Thomson
1fbfcdfcd0 git_path_join_unrooted: return base len
The documentation for `git_path_join_unrooted` states that the base
length will be returned, so that consumers like checkout know where
to start creating directories instead of always creating directories
at the directory root.
2015-01-20 17:12:35 -06:00
Edward Thomson
1d50b3649d checkout: introduce git_checkout_perfdata
Checkout can now provide performance data about the number of (some)
syscalls performed using an optional callback.
2015-01-20 17:12:23 -06:00
Sven Strickroth
0161e096a3 Make binary detection work similar to vanilla git
Main change: Don't treat chars > 128 as non-printable (common in UTF-8 files)

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2015-01-20 16:17:37 -06:00
Jacques Germishuys
9ae4ad2daf Treat a NULL string as if it's empty 2015-01-20 23:26:55 +02:00
Jacques Germishuys
526182d28c Remove logically dead code (we're already asserting) 2015-01-20 23:24:32 +02:00
Edward Thomson
147d86fc69 diff: only compute patches when requested
When we're called with no hunk or line callback, we don't need to
do the hunk or line computation.
2015-01-20 12:31:24 -06:00
Maks Naumov
d8b5c8c329 Remove strlen() calls from loop condition
Avoid str length recalculation every iteration
2015-01-15 15:16:19 +02:00
Carlos Martín Nieto
eac773d92b config: add parsing and getter for paths 2015-01-14 19:36:50 +01:00
Edward Thomson
85880693d5 Merge branch 'pr/2740' 2015-01-14 10:19:28 -06:00
Pierre-Olivier Latour
b3837d4d2b Always use GIT_HASHSIG_SMART_WHITESPACE when diffing for merges
git_merge_tree_flag_t cannot contain any GIT_DIFF_FIND_xxx flags so there's not point in checking for them
2015-01-14 10:18:00 -06:00
Pierre-Olivier Latour
36fc549781 Added GIT_HASHSIG_ALLOW_SMALL_FILES to allow computing signatures for small files
The implementation of the hashsig API disallows computing a signature on
small files containing only a few lines. This new flag disables this
behavior.

git_diff_find_similar() sets this flag by default which means that rename
/ copy detection of small files will now work. This in turn affects the
behavior of the git_status and git_blame APIs which will now detect rename
of small files assuming the right options are passed.
2015-01-14 10:17:56 -06:00
Carlos Martín Nieto
d4b2410126 Merge commit '4b1018d24f980273528743c27c47ceb96cb720bd'
Fix crash in free() when git_buf_grow() fails.
2015-01-09 16:47:48 +01:00
Jeff Hostetler
4b1018d24f Fix crash in free() when git_buf_grow() fails. 2015-01-09 16:46:44 +01:00
Edward Thomson
a8846da7b3 remote: plug leak 2015-01-08 13:45:22 -06:00
Edward Thomson
1646412d8f Merge pull request #2802 from calavera/remote_create_prune_config
Load prune configuration when a remote is created.
2015-01-08 11:20:44 -06:00
David Calavera
c868981f0e Add extern function to initialize submodule update options. 2015-01-07 09:04:49 -06:00
Edward Thomson
5018e2c639 submodule: declare vars at top of func block 2015-01-06 17:08:38 -06:00
David Calavera
66b71ea5f5 Fix intentation. 2015-01-05 13:33:36 -08:00
David Calavera
1ef3f0cebb Load prune configuration when a remote is created. 2015-01-05 13:24:11 -08:00
Carlos Martín Nieto
0c6012293a Merge commit 'refs/pull/2632/head' of github.com:libgit2/libgit2 2015-01-05 20:10:43 +00:00
Pierre-Olivier Latour
c070ac64fd Fixed internal push state not being cleared on download
git_remote_download() must also clear the internal push state resulting from a possible earlier push operation. Otherwise calling git_remote_update_tips() will execute the push version instead of the fetch version and among other things, tags won't be updated.
2015-01-01 04:19:33 -08:00
Edward Thomson
a3ef70bb40 Merge pull request #2761 from libgit2/cmn/fetch-prune
Remote-tracking branch prunning
2014-12-30 11:53:55 -06:00
Edward Thomson
c4c47fc286 Merge pull request #2762 from libgit2/cmn/hide-push
remote: remove git_push from the public API
2014-12-30 11:53:45 -06:00
Carlos Martín Nieto
fe794b2ea7 remote: remove git_push from the public API
Instead we provide git_remote_upload() and git_remote_update_tips() in
order to have a parallel API for fetching and pushing.
2014-12-30 17:02:50 +00:00