Commit Graph

1937 Commits

Author SHA1 Message Date
Patrick Steinhardt
dea7488e93 worktree: implement git_worktree_add
Implement the `git_worktree_add` function which can be used to create
new working trees for a given repository.
2017-02-13 11:00:17 +01:00
Patrick Steinhardt
372dc9ff6a worktree: implement git_worktree_validate
Add a new function that checks wether a given `struct
git_worktree` is valid. The validation includes checking if the
gitdir, parent directory and common directory are present.
2017-02-13 10:59:16 +01:00
Patrick Steinhardt
8c8d726ef7 worktree: implement git_repository_open_from_worktree
Add function `git_repository_open_from_worktree`, which allows to open a
`git_worktree` as repository.
2017-02-13 10:59:04 +01:00
Patrick Steinhardt
d3bc09e816 worktree: introduce struct git_worktree
Introduce a new `struct git_worktree`, which holds information
about a possible working tree connected to a repository.
Introduce functions to allow opening working trees for a
repository.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
45f2b7a43f worktree: implement git_worktree_list
Add new module for working trees with the `git_worktree_list`
function. The function lists names for all working trees of a
certain repository.
2017-02-13 10:28:15 +01:00
Patrick Steinhardt
79ab3ef69f repository: introduce is_worktree variable 2017-02-13 10:28:15 +01:00
Patrick Steinhardt
cb3269c970 repository: add function to retrieve paths for repo items 2017-02-13 10:28:15 +01:00
Patrick Steinhardt
c09fd54e2e repository: introduce commondir variable
The commondir variable stores the path to the common directory.
The common directory is used to store objects and references
shared across multiple repositories. A current use case is the
newly introduced `git worktree` feature, which sets up a separate
working copy, where the backing git object store and references
are pointed to by the common directory.
2017-02-13 10:13:02 +01:00
Gaurav Saral
61acc9fade Changes to provide option to turn off/on ofs_delta
This change provides an option in git_libgit2_opt_t which can be used in git_libgit2_opts to turn off/on ofs_delta capability in libGit2
2017-02-10 15:22:00 +05:30
Remy Suen
93e2c74493 Flag optional parameters for apply and pop
The options parameter in both git_stash_apply and git_stash_pop can
be NULL. They should be flagged as such in the documentation.
2017-02-09 19:12:31 +09:00
Remy Suen
3a13365269 Flag checkout_opts in git_reset as optional
The check_outs argument can be NULL and should be flagged accordingly
in the header file.
2017-02-05 07:12:32 +09:00
Remy Suen
21d4a3783e Flag given_opts in git_revert as optional
The given_opts argument can actually be NULL and thus should be
flagged accordingly in the header file.
2017-02-04 17:24:31 +09:00
Matthew Plough
921493cc94 Update docs for git_oid_fromstrn and p 2017-01-27 14:37:16 -05:00
Etienne Samson
7414acf5f9 parameter 'id' not found in the function declaration 2017-01-23 13:32:34 +01:00
Edward Thomson
8d3b39a6ad Merge branch 'pr/3912' 2017-01-21 23:50:38 +00:00
Edward Thomson
28d0ba0ba5 symbolic ref target validation: fixups
Fixups requested in #3912.
2017-01-21 23:45:23 +00:00
Edward Thomson
44e8af8f29 Merge pull request #3892 from mitesch/shared_buffer
Use a shared buffer in calls of git_treebuilder_write to avoid heap contention
2017-01-21 22:51:50 +00:00
Edward Thomson
9e78b7279d Merge branch 'master' into pr/3938 2017-01-21 22:39:59 +00:00
Brock Peabody
4d99c4cfc6 Allow for caching of submodules.
Added `git_repository_submodule_cache_all` to initialze a cache of
submodules on the repository so that operations looking up N
submodules are O(N) and not O(N^2).  Added a
`git_repository_submodule_cache_clear` function to remove the cache.

Also optimized the function that loads all submodules as it was itself
O(N^2) w.r.t the number of submodules, having to loop through the
`.gitmodules` file once per submodule.  I changed it to process the
`.gitmodules` file once, into a map.

Signed-off-by: David Turner <dturner@twosigma.com>
2017-01-20 17:33:56 -05:00
Edward Thomson
19ed4d0ca3 merge: set default rename threshold
When `GIT_MERGE_FIND_RENAMES` is set, provide a default for
`rename_threshold` when it is unset.
2017-01-01 22:34:43 +00:00
Carlos Martín Nieto
75db289a04 Merge pull request #3980 from tiennou/doc-fixes
Documentation fixes
2016-12-20 19:14:20 +00:00
Carlos Martín Nieto
77e4623257 settings: clarify what each value means
Most importantly, clarify what it means for HTTPS and SSH to be supported.
2016-12-17 14:31:36 +00:00
Michael Tesch
87aaefe20b write_tree: use shared buffer for writing trees
The function to write trees allocates a new buffer for each tree.
This causes problems with performance when performing a lot
of actions involving writing trees, e.g. when doing many merges.
Fix the issue by instead handing in a shared buffer, which is then
re-used across the calls without having to re-allocate between
calls.
2016-12-12 10:46:05 -05:00
Josh Bleecher Snyder
72cee16890 remote: fix typo in git_fetch_init_options docs 2016-12-02 16:14:47 -08:00
Carlos Martín Nieto
5569778a52 Bump version number to v0.25 2016-11-15 11:15:40 +01:00
Etienne Samson
8d400c096a transaction: fix documentation 2016-11-01 17:49:07 +01:00
Etienne Samson
788fcdb8e3 remote: fix documentation and indent 2016-11-01 17:46:57 +01:00
Etienne Samson
2adac91008 remote: unused function typedef 2016-11-01 17:46:37 +01:00
Etienne Samson
8d2784d570 describe: fix documentation 2016-11-01 17:46:20 +01:00
Patrick Steinhardt
6502398f96 proxy: fix typo in documentation 2016-11-01 16:55:16 +01:00
Davide Coppola
6d8ecf087c patch: minor documentation fix.
Fix @return description of git_patch_num_lines_in_hunk.
2016-10-16 00:43:27 +01:00
Josh Leeb-du Toit
3e22bb71f2 Update submodule update opts init as per code review
Update the `GIT_SUBMODULE_UPDATE_OPTIONS_INIT` definition with the
correct values after removing `clone_checkout_strategy` in
`git_submodule_update_options`.
2016-10-10 09:50:24 +11:00
Josh Leeb-du Toit
567fd782d9 Remove clone_checkout_strategy in submodule update opts
Remove `clone_checkout_strategy` in `git_submodule_update_options` as
per issue #3784.
2016-10-10 09:50:24 +11:00
Edward Thomson
93392cdd91 docs: GIT_OPT_ENABLE_STRICT_OBJECT_CREATION is enabled
We changed the defaults on strict object creation - it is enabled by
default.  Update the documentation to reflect that.
2016-10-09 11:27:56 +01:00
Carlos Martín Nieto
82d4c0e6b8 revwalk: update the description for the default sorting
It changed from implementation-defined to git's default sorting, as there are
systems (e.g. rebase) which depend on this order. Also specify more explicitly
how you can get git's "date-order".
2016-10-06 11:04:55 +02:00
Vicent Marti
2749ff46d8 time: Export git_time_monotonic 2016-09-13 15:52:43 +02:00
Edward Thomson
adedac5aba diff: treat binary patches with no data special
When creating and printing diffs, deal with binary deltas that have
binary data specially, versus diffs that have a binary file but lack the
actual binary data.
2016-09-05 12:26:47 -05:00
Richard Ipsum
452bf57cbe Make symbolic ref target validation optional
Introduce GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION option.
Setting this option to 0 allows
validation of a symbolic ref's target to be bypassed.
This option is enabled by default.

This mechanism is added primarily to address a discrepancy between git
behaviour and libgit2 behaviour, whereby the former allows the symbolic
ref target to carry an arbitrary string and the latter does not, so:

    $ git symbolic-ref refs/heads/foo bar
    $ cat .git/refs/heads/foo
    ref: bar

where as attempting the same via libgit2 raises an error:

    The given reference name 'bar' is not valid

this mechanism also allows those that might want to make use of
git's more lenient treatment of symbolic ref targets to do so.
2016-08-27 18:25:02 +01:00
David Turner
5625d86b99 index: support index v4
Support reading and writing index v4.  Index v4 uses a very simple
compression scheme for pathnames, but is otherwise similar to index v3.

Signed-off-by: David Turner <dturner@twitter.com>
2016-08-10 14:19:30 -04:00
Edward Thomson
e2e7f31ad0 diff: document git_diff_from_buffer 2016-08-05 20:01:52 -04:00
Edward Thomson
8f09a98e18 odb: freshen existing objects when writing
When writing an object, we calculate its OID and see if it exists in the
object database.  If it does, we need to freshen the file that contains
it.
2016-08-04 15:12:04 -04:00
Edward Thomson
002c8e29a1 git_diff_file: move id_abbrev
Move `id_abbrev` to a more reasonable place where it packs more nicely
(before anybody starts using it).
2016-08-03 17:57:37 -04:00
Edward Thomson
60e15ecd55 packbuilder: size_t all the things
After 1cd65991, we were passing a pointer to an `unsigned long` to
a function that now expected a pointer to a `size_t`.  These types
differ on 64-bit Windows, which means that we trash the stack.

Use `size_t`s in the packbuilder to avoid this.
2016-07-24 15:49:19 -04:00
Andrius Bentkus
f1dba14481 Add get user agent functionality. 2016-07-05 18:10:24 +03:00
Edward Thomson
ebeb56f0f5 Merge pull request #3711 from joshtriplett/git_repository_discover_default
Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
2016-07-01 18:45:10 -04:00
Jason Haslam
de43efcf27 submodule: Try to fetch when update fails to find the target commit in the submodule. 2016-06-28 16:08:58 -06:00
Edward Thomson
20302aa437 Merge pull request #3223 from ethomson/apply
Reading patch files
2016-06-25 23:33:05 -04:00
Josh Triplett
0dd98b6905 Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
git_repository_open_ext provides parameters for the start path, whether
to search across filesystems, and what ceiling directories to stop at.
git commands have standard environment variables and defaults for each
of those, as well as various other parameters of the repository. To
avoid duplicate environment variable handling in users of libgit2, add a
GIT_REPOSITORY_OPEN_FROM_ENV flag, which makes git_repository_open_ext
automatically handle the appropriate environment variables. Commands
that intend to act just like those built into git itself can use this
flag to get the expected default behavior.

git_repository_open_ext with the GIT_REPOSITORY_OPEN_FROM_ENV flag
respects $GIT_DIR, $GIT_DISCOVERY_ACROSS_FILESYSTEM,
$GIT_CEILING_DIRECTORIES, $GIT_INDEX_FILE, $GIT_NAMESPACE,
$GIT_OBJECT_DIRECTORY, and $GIT_ALTERNATE_OBJECT_DIRECTORIES.  In the
future, when libgit2 gets worktree support, git_repository_open_env will
also respect $GIT_WORK_TREE and $GIT_COMMON_DIR; until then,
git_repository_open_ext with this flag will error out if either
$GIT_WORK_TREE or $GIT_COMMON_DIR is set.
2016-06-24 12:26:51 -07:00
Josh Triplett
39c6fca33a Add GIT_REPOSITORY_OPEN_NO_DOTGIT flag to avoid appending /.git
GIT_REPOSITORY_OPEN_NO_SEARCH does not search up through parent
directories, but still tries the specified path both directly and with
/.git appended.  GIT_REPOSITORY_OPEN_BARE avoids appending /.git, but
opens the repository in bare mode even if it has a working directory.
To support the semantics git uses when given $GIT_DIR in the
environment, provide a new GIT_REPOSITORY_OPEN_NO_DOTGIT flag to not try
appending /.git.
2016-06-24 11:44:01 -07:00
Edward Thomson
b926648839 documentation: improve docs for checkout_head
`git_checkout_head` is sadly misunderstood as something that can
switch branches.  It cannot.  Update the documentation to reflect this.
2016-06-15 15:23:39 -05:00
Edward Thomson
728274904f Introduce git_diff_to_buf
Like `git_patch_to_buf`, provide a simple helper method that can
print an entire diff directory to a `git_buf`.
2016-05-26 13:01:09 -05:00
Edward Thomson
7166bb1665 introduce git_diff_from_buffer to parse diffs
Parse diff files into a `git_diff` structure.
2016-05-26 13:01:09 -05:00
Edward Thomson
440e3bae10 patch: git_patch_from_patchfile -> git_patch_from_buffer 2016-05-26 13:01:08 -05:00
Edward Thomson
82175084e1 Introduce git_patch_options, handle prefixes
Handle prefixes (in terms of number of path components) for patch
parsing.
2016-05-26 13:01:06 -05:00
Edward Thomson
d68cb73677 diff: include oid length in deltas
Now that `git_diff_delta` data can be produced by reading patch
file data, which may have an abbreviated oid, allow consumers to
know that the id is abbreviated.
2016-05-26 13:01:05 -05:00
Edward Thomson
d34f68261e Patch parsing from patch files 2016-05-26 11:36:11 -05:00
Edward Thomson
7cb904ba44 Introduce git_apply_patch
The beginnings of patch application from an existing (diff-created)
git_patch object: applies the hunks of a git_patch to a buffer.
2016-05-26 11:36:11 -05:00
Carlos Martín Nieto
9464f9ebc1 Introduce a function to create a tree based on a different one
Instead of going through the usual steps of reading a tree recursively
into an index, modifying it and writing it back out as a tree, introduce
a function to perform simple updates more efficiently.

`git_tree_create_updated` avoids reading trees which are not modified
and supports upsert and delete operations. It is not as versatile as
modifying the index, but it makes some common operations much more
efficient.
2016-05-17 17:41:05 +02:00
Edward Thomson
d383c39b3b Introduce git_signature_from_buffer
Allow users to construct a signature from the type of signature
lines that actually appear in commits.
2016-04-28 12:47:14 -04:00
Arthur Schreiber
a3e379cb4e Remove traces of git_blob_create_fromchunks 2016-04-26 11:10:31 +02:00
Arthur Schreiber
908f24fd13 Allow creating copies of git_reference objects. 2016-04-22 10:34:17 -07:00
Carlos Martín Nieto
0d72f67f28 proxy: don't specify the protocol in the type
We leave this up to the scheme in the url field. The type should only
tell us about whether we want a proxy and whether we want to auto-detect
it.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
60d717c6f1 proxy: add a payload field for the proxy options
I don't quite recall what we do in the other places where we use this,
but we should pass this payload to the callbacks.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
b373e9a6ba net: use proxy options struct in the stream config 2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
07bd3e57d9 proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
a7bece2014 proxy: introduce a proxy options struct
It is currently unused; it will go into the remote's options.
2016-04-19 13:54:19 +02:00
Josh Junon
fc15befdcd Add missing ')' to callbacks documentation
Super minor, but it was bugging me.

There was a missing closing paren in the docs.
2016-04-12 21:50:18 -07:00
Carlos Martín Nieto
9844453611 Add a no-op size_t typedef for the doc parser
Clang's documentation parser, which we use in our documentation system
does not report any comments for functions which use size_t as a type.

The root cause is buried somewhere in libclang but we can work around it
by defining the type ourselves. This typedef makes sure that libclang
sees it and that we do not change its size.
2016-03-31 11:55:47 +02:00
Edward Thomson
f0224772ee git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
Carlos Martín Nieto
0a5c602889 blob: introduce creating a blob by writing into a stream
The pair of `git_blob_create_frombuffer()` and
`git_blob_create_frombuffer_commit()` is meant to replace
`git_blob_create_fromchunks()` by providing a way for a user to write a
new blob when they want filtering or they do not know the size.

This approach allows the caller to retain control over when to add data
to this buffer and a more natural fit into higher-level language's own
stream abstractions instead of having to handle IO wait in the callback.

The in-memory buffer size of 2MB is chosen somewhat arbitrarily to be a
round multiple of usual page sizes and a value where most blobs seem
likely to be either going to be way below or way over that size. It's
also a round number of pages.

This implementation re-uses the helper we have from `_fromchunks()` so
we end up writing everything to disk, but hopefully more efficiently
than with a default filebuf. A later optimisation can be to avoid
writing the in-memory contents to disk, with some extra complexity.
2016-03-22 19:34:08 +01:00
Edward Thomson
6d8b2cdbee merge driver: remove check callback
Since the `apply` callback can defer, the `check` callback is not
necessary.  Removing the `check` callback further makes the `payload`
unnecessary along with the `cleanup` callback.
2016-03-17 11:06:00 -04:00
Edward Thomson
3f7d3df1ec merge driver: improve inline documentation 2016-03-17 11:06:00 -04:00
Edward Thomson
30a94ab756 merge driver: allow custom default driver
Allow merge users to configure a custom default merge driver via
`git_merge_options`.  Similarly, honor the `merge.default` configuration
option.
2016-03-17 11:02:27 -04:00
Edward Thomson
3f04219fcd merge driver: introduce custom merge drivers
Consumers can now register custom merged drivers with
`git_merge_driver_register`.  This allows consumers to support the
merge drivers, as configured in `.gitattributes`.  Consumers will be
asked to perform the file-level merge when a custom driver is
configured.
2016-03-17 11:02:26 -04:00
Edward Thomson
ba3493228c Merge pull request #3673 from libgit2/cmn/commit-with-signature
commit: add function to attach a signature to a commit
2016-03-17 06:57:56 -07:00
Carlos Martín Nieto
02d61a3b66 commit: add function to attach a signature to a commit
In combination with the function which creates a commit into a buffer,
this allows us to more easily create signed commits.
2016-03-15 12:55:03 +01:00
Dirkjan Bussink
fa72d6daf8 Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.

Implements the first part of https://github.com/libgit2/libgit2/issues/3682
2016-03-14 12:07:13 +00:00
Carlos Martín Nieto
1ddada422c Merge pull request #3636 from nerdishbynature/fix-non-modular-header-in-module
Don't include inttypes if compiling for Mac/iOS
2016-03-11 16:31:32 +01:00
Piet Brauer
0ac4a5ded4 Check for __CLANG_INTTYPES_H
This fixes an issue in Xcode 7.3 in objective-git where we get the error
"Include of non-modular header file in module". Not importing this
header again fixes the issue.
2016-03-11 10:33:37 +08:00
Vicent Marti
c68044a879 Merge pull request #3656 from ethomson/exists_prefixes
Introduce `git_odb_expand_ids`
2016-03-08 21:17:38 +01:00
Edward Thomson
62484f52d1 git_odb_expand_ids: accept git_odb_expand_id array
Take (and write to) an array of a struct, `git_odb_expand_id`.
2016-03-08 14:57:20 -05:00
Edward Thomson
4b1f0f79ac git_odb_expand_ids: rename func, return the type 2016-03-08 11:44:21 -05:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
Sometimes you want to create a commit but not write it out to the
objectdb immediately. For these cases, provide a new function to
retrieve the buffer instead of having to go through the db.
2016-03-08 13:11:49 +01:00
Edward Thomson
6c04269c8f git_odb_exists_many_prefixes: query odb for multiple short ids
Query the object database for multiple objects at a time, given their
object ID (which may be abbreviated) and optional type.
2016-03-07 16:10:25 -05:00
Carlos Martín Nieto
1e8255a39b Bump version to 0.24.0 2016-03-03 20:20:43 +01:00
Edward Thomson
22a19f5b57 git_libgit2_opts: introduce GIT_OPT_ENABLE_STRICT_OBJECT_CREATION 2016-02-28 12:38:39 -05:00
Edward Thomson
0d9a7498c5 Merge pull request #3628 from pks-t/pks/coverity-fixes
Coverity fixes
2016-02-25 12:09:49 -05:00
Edward Thomson
cd59e0c0c7 giterr_set_str: remove GITERR_OS documentation
The `giterr_set_str` does not actually honor `GITERR_OS`.  Remove
the documentation that claims that we do.
2016-02-23 13:08:58 -05:00
Patrick Steinhardt
0f1e2d2066 index: fix contradicting comparison
The overflow check in `read_reuc` tries to verify if the
`git__strtol32` parses an integer bigger than UINT_MAX. The `tmp`
variable is casted to an unsigned int for this and then checked
for being greater than UINT_MAX, which obviously can never be
true.

Fix this by instead fixing the `mode` field's size in `struct
git_index_reuc_entry` to `uint32_t`. We can now parse the int
with `git__strtol64`, which can never return a value bigger than
`UINT32_MAX`, and additionally checking if the returned value is
smaller than zero.

We do not need to handle overflows explicitly here, as
`git__strtol64` returns an error when the returned value would
overflow.
2016-02-23 12:07:14 +01:00
Edward Thomson
5bc93eaea0 git_libgit2_opts: document GIT_OPT_SET_USER_AGENT 2016-02-22 22:26:01 -05:00
Carlos Martín Nieto
88ab3be6f5 Fix a few checkout -> rebase typos 2016-02-22 15:41:01 +01:00
Carlos Martín Nieto
78e16c3442 Merge pull request #3597 from ethomson/filter_registration
Filter registration
2016-02-19 13:06:51 +01:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
We should be checking whether the object we're looking up is a commit,
and we should let the caller know whether the not-found return code
comes from a bad object type or just a missing signature.
2016-02-16 14:06:48 +01:00
Edward Thomson
f28bae0c38 rebase: persist a single in-memory index
When performing an in-memory rebase, keep a single index for the
duration, so that callers have the expected index lifecycle and
do not hold on to an index that is free'd out from under them.
2016-02-15 19:27:06 +00:00
Edward Thomson
a202e0d45b rebase: allow custom merge_options
Allow callers of rebase to specify custom merge options.  This may
allow custom conflict resolution, or failing fast when conflicts
are detected.
2016-02-11 10:49:25 -08:00
Edward Thomson
ee6673070a rebase: introduce inmemory rebasing
Introduce the ability to rebase in-memory or in a bare repository.

When `rebase_options.inmemory` is specified, the resultant `git_rebase`
session will not be persisted to disk.  Callers may still analyze
the rebase operations, resolve any conflicts against the in-memory
index and create the commits.  Neither `HEAD` nor the working
directory will be updated during this process.
2016-02-11 10:48:48 -08:00
Edward Thomson
82abd40d80 filter: clean up documentation around custom filters 2016-02-09 21:47:51 -08:00
Vicent Marti
488e2b8505 Merge pull request #3599 from libgit2/gpgsign
Introduce git_commit_extract_signature
2016-02-09 16:26:58 +01:00
Carlos Martín Nieto
a65afb757e Introduce git_commit_extract_signature
This returns the GPG signature for a commit and its contents without the
signature block, allowing for the verification of the commit's
signature.
2016-02-09 15:58:16 +01:00
Edward Thomson
b00c959f45 Better document git_merge_commits redux
`git_merge_commits` and `git_merge` now *do* handle recursive base
building for criss-cross merges.  Remove the documentation that says
that they do not.

This reverts commit 5e44d9bcb6.
2016-02-08 17:56:41 -08:00