]> git.proxmox.com Git - libgit2.git/log
libgit2.git
7 years agokhash: avoid using `kh_val`/`kh_value` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:26:58 +0000 (14:26 +0100)]
khash: avoid using `kh_val`/`kh_value` directly

7 years agokhash: avoid using `kh_exist` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:20:56 +0000 (14:20 +0100)]
khash: avoid using `kh_exist` directly

7 years agokhash: avoid using `kh_clear` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:16:35 +0000 (14:16 +0100)]
khash: avoid using `kh_clear` directly

7 years agokhash: avoid using `kh_get` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:14:32 +0000 (14:14 +0100)]
khash: avoid using `kh_get` directly

7 years agokhash: avoid using `kh_end` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:14:12 +0000 (14:14 +0100)]
khash: avoid using `kh_end` directly

7 years agokhash: use `git_map_exists` where applicable
Patrick Steinhardt [Wed, 25 Jan 2017 13:11:42 +0000 (14:11 +0100)]
khash: use `git_map_exists` where applicable

7 years agokhash: avoid using `kh_foreach`/`kh_foreach_value` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:09:17 +0000 (14:09 +0100)]
khash: avoid using `kh_foreach`/`kh_foreach_value` directly

7 years agokhash: avoid using `kh_size` directly
Patrick Steinhardt [Wed, 25 Jan 2017 13:05:24 +0000 (14:05 +0100)]
khash: avoid using `kh_size` directly

7 years agooffmap: remove unused macro `git_offmap_insert2`
Patrick Steinhardt [Fri, 27 Jan 2017 13:15:45 +0000 (14:15 +0100)]
offmap: remove unused macro `git_offmap_insert2`

7 years agostrmap: remove unused macro `git_strmap_insert2`
Patrick Steinhardt [Wed, 25 Jan 2017 13:12:13 +0000 (14:12 +0100)]
strmap: remove unused macro `git_strmap_insert2`

7 years agoMerge pull request #4124 from pks-t/pks/worktree-refs
Patrick Steinhardt [Fri, 17 Feb 2017 10:14:53 +0000 (11:14 +0100)]
Merge pull request #4124 from pks-t/pks/worktree-refs

refdb: catch additional per-worktree refs

7 years agoMerge pull request #4127 from Uncommon/comment
Edward Thomson [Thu, 16 Feb 2017 22:30:33 +0000 (22:30 +0000)]
Merge pull request #4127 from Uncommon/comment

Minor comment fix

7 years agoMinor comment fix
David Catmull [Thu, 16 Feb 2017 15:40:49 +0000 (08:40 -0700)]
Minor comment fix

7 years agorefdb: catch additional per-worktree refs
Patrick Steinhardt [Tue, 14 Feb 2017 10:13:32 +0000 (11:13 +0100)]
refdb: catch additional per-worktree refs

The upstream git.git project currently identifies all references inside
of `refs/bisect/` as well as `HEAD` as per-worktree references. This is
already incorrect and is currently being fixed by an in-flight topic
[1]. The new behavior will be to match all pseudo-references outside of
the `refs/` hierarchy as well as `refs/bisect/`.

Our current behavior is to mark a selection of pseudo-references as
per-worktree, only. This matches more pseudo-references than current
git, but forgets about `refs/bisect/`. Adjust behavior to match the
in-flight topic, that is classify the following references as
per-worktree:

- everything outside of `refs/`
- everything inside of `refs/bisect/`

[1]: <20170213152011.12050-1-pclouds@gmail.com>

7 years agoMerge pull request #4122 from pks-t/pks/signature-dbl-free
Edward Thomson [Mon, 13 Feb 2017 14:38:12 +0000 (14:38 +0000)]
Merge pull request #4122 from pks-t/pks/signature-dbl-free

Signature cleanups

7 years agocommit: avoid possible use-after-free
Patrick Steinhardt [Mon, 13 Feb 2017 12:46:17 +0000 (13:46 +0100)]
commit: avoid possible use-after-free

When extracting a commit's signature, we first free the object and only
afterwards put its signature contents into the result buffer. This works
in most cases - the free'd object will normally be cached anyway, so we
only end up decrementing its reference count without actually freeing
its contents. But in some more exotic setups, where caching is disabled,
this can definitly be a problem, as we might be the only instance
currently holding a reference to this object.

Fix this issue by first extracting the contents and freeing the object
afterwards only.

7 years agocommit: clear user-provided buffers
Patrick Steinhardt [Mon, 13 Feb 2017 12:42:16 +0000 (13:42 +0100)]
commit: clear user-provided buffers

The functions `git_commit_header_field` and
`git_commit_extract_signature` both receive buffers used to hand back
the results to the user. While these functions called `git_buf_sanitize`
on these buffers, this is not the right thing to do, as it will simply
initialize or zero-terminate passed buffers. As we want to overwrite
contents, we instead have to call `git_buf_clear` to completely reset
them.

7 years agoMerge pull request #4115 from gsaralms/users/gsaral/optionalOfsDelta
Edward Thomson [Mon, 13 Feb 2017 12:46:00 +0000 (12:46 +0000)]
Merge pull request #4115 from gsaralms/users/gsaral/optionalOfsDelta

Changes to provide option to turn off/on ofs_delta

7 years agobuffer: clarify how `git_buf_sanitize` handles non-NULL input
Patrick Steinhardt [Mon, 13 Feb 2017 12:31:37 +0000 (13:31 +0100)]
buffer: clarify how `git_buf_sanitize` handles non-NULL input

When `git_buf_sanitize` gets called, it converts a buffer with NULL
content to be correctly initialized. This is done by pointing it to
`git_buf__initbuf`. While the method's documentation states this
clearly, it may also lead to the conclusion that it will do the same to
buffers which do _not_ have NULL contents.

Clarify behavior when passing a buffer with non-NULL contents, where
`git_buf_sanitize` will ensure that the contents are `\0`-terminated.

7 years agoMerge pull request #3436 from pks-t/libgit2-worktree
Edward Thomson [Mon, 13 Feb 2017 11:10:49 +0000 (11:10 +0000)]
Merge pull request #3436 from pks-t/libgit2-worktree

Worktree implementation

7 years agoworktree: extract git_worktree_is_prunable
Patrick Steinhardt [Fri, 3 Feb 2017 12:52:23 +0000 (13:52 +0100)]
worktree: extract git_worktree_is_prunable

7 years agoworktree: test opening worktree via gitlink, gitdir and worktree
Patrick Steinhardt [Wed, 9 Nov 2016 13:18:22 +0000 (14:18 +0100)]
worktree: test opening worktree via gitlink, gitdir and worktree

7 years agoworktree: test creating and opening submodule worktrees
Patrick Steinhardt [Tue, 8 Nov 2016 11:13:59 +0000 (12:13 +0100)]
worktree: test creating and opening submodule worktrees

7 years agoMerge pull request #4121 from pks-t/pks/fix-test-index-permissions
Patrick Steinhardt [Mon, 13 Feb 2017 10:10:18 +0000 (11:10 +0100)]
Merge pull request #4121 from pks-t/pks/fix-test-index-permissions

tests: fix permissions on testrepo.git index file

7 years agoworktree: test opening discovered submodule worktrees
Patrick Steinhardt [Mon, 7 Nov 2016 09:23:34 +0000 (10:23 +0100)]
worktree: test opening discovered submodule worktrees

7 years agoworktree: compute workdir for worktrees opened via their gitdir
Patrick Steinhardt [Fri, 4 Nov 2016 12:39:54 +0000 (13:39 +0100)]
worktree: compute workdir for worktrees opened via their gitdir

When opening a worktree via the gitdir of its parent repository
we fail to correctly set up the worktree's working directory. The
problem here is two-fold: we first fail to see that the gitdir
actually is a gitdir of a working tree and then subsequently
fail to determine the working tree location from the gitdir.

The first problem of not noticing a gitdir belongs to a worktree
can be solved by checking for the existence of a `gitdir` file in
the gitdir. This file points back to the gitlink file located in
the working tree's working directory. As this file only exists
for worktrees, it should be sufficient indication of the gitdir
belonging to a worktree.

The second problem, that is determining the location of the
worktree's working directory, can then be solved by reading the
`gitdir` file in the working directory's gitdir. When we now
resolve relative paths and strip the final `.git` component, we
have the actual worktree's working directory location.

7 years agorepository: rename `path_repository` and `path_gitlink`
Patrick Steinhardt [Fri, 4 Nov 2016 10:59:52 +0000 (11:59 +0100)]
repository: rename `path_repository` and `path_gitlink`

The `path_repository` variable is actually confusing to think
about, as it is not always clear what the repository actually is.
It may either be the path to the folder containing worktree and
.git directory, the path to .git itself, a worktree or something
entirely different. Actually, the intent of the variable is to
hold the path to the gitdir, which is either the .git directory
or the bare repository.

Rename the variable to `gitdir` to avoid confusion. While at it,
also rename `path_gitlink` to `gitlink` to improve consistency.

7 years agorepository: restrict checking out checked out branches
Patrick Steinhardt [Tue, 27 Oct 2015 13:17:52 +0000 (14:17 +0100)]
repository: restrict checking out checked out branches

If a branch is already checked out in a working tree we are not
allowed to check out that branch in another repository. Introduce
this restriction when setting a repository's HEAD.

7 years agobranch: restrict branch deletion for worktrees
Patrick Steinhardt [Fri, 6 Nov 2015 11:33:59 +0000 (12:33 +0100)]
branch: restrict branch deletion for worktrees

Restrict the ability to delete branches that are checked out in
any linked repository.

7 years agobranch: implement `git_branch_is_checked_out`
Patrick Steinhardt [Fri, 6 Nov 2015 11:08:15 +0000 (12:08 +0100)]
branch: implement `git_branch_is_checked_out`

Implement a new function that is able to determine if a branch is
checked out in any repository connected to the current
repository. In particular, this is required to check if for a
given repository and branch, there exists any working tree
connected to that repository that is referencing this branch.

7 years agoworktree: test basic merge functionality
Patrick Steinhardt [Tue, 10 Nov 2015 15:54:48 +0000 (16:54 +0100)]
worktree: test basic merge functionality

7 years agoworktree: implement functions reading HEAD
Patrick Steinhardt [Tue, 27 Oct 2015 11:37:51 +0000 (12:37 +0100)]
worktree: implement functions reading HEAD

Implement `git_repository_head_for_worktree` and
`git_repository_head_detached_for_worktree` for directly accessing a
worktree's HEAD without opening it as a `git_repository` first.

7 years agoworktree: implement `git_worktree_prune`
Patrick Steinhardt [Wed, 21 Oct 2015 11:53:18 +0000 (13:53 +0200)]
worktree: implement `git_worktree_prune`

Implement the `git_worktree_prune` function. This function can be
used to delete working trees from a repository. According to the
flags passed to it, it can either delete the working tree's
gitdir only or both gitdir and the working directory.

7 years agoworktree: implement locking mechanisms
Patrick Steinhardt [Wed, 21 Oct 2015 14:03:04 +0000 (16:03 +0200)]
worktree: implement locking mechanisms

Working trees support locking by creating a file `locked` inside
the tree's gitdir with an optional reason inside. Support this
feature by adding functions to get and set the locking status.

7 years agoworktree: implement `git_worktree_add`
Patrick Steinhardt [Fri, 23 Oct 2015 12:11:44 +0000 (14:11 +0200)]
worktree: implement `git_worktree_add`

Implement the `git_worktree_add` function which can be used to create
new working trees for a given repository.

7 years agoworktree: implement `git_worktree_validate`
Patrick Steinhardt [Wed, 21 Oct 2015 11:49:55 +0000 (13:49 +0200)]
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.

7 years agoworktree: implement `git_repository_open_from_worktree`
Patrick Steinhardt [Wed, 21 Oct 2015 10:10:30 +0000 (12:10 +0200)]
worktree: implement `git_repository_open_from_worktree`

Add function `git_repository_open_from_worktree`, which allows to open a
`git_worktree` as repository.

7 years agotests: fix permissions on testrepo.git index file
Patrick Steinhardt [Mon, 13 Feb 2017 09:34:08 +0000 (10:34 +0100)]
tests: fix permissions on testrepo.git index file

7 years agoworktree: introduce `struct git_worktree`
Patrick Steinhardt [Wed, 21 Oct 2015 10:02:31 +0000 (12:02 +0200)]
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.

7 years agoworktree: implement `git_worktree_list`
Patrick Steinhardt [Wed, 21 Oct 2015 09:48:02 +0000 (11:48 +0200)]
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.

7 years agorepository: expose `repo_init_create_head`
Patrick Steinhardt [Mon, 26 Oct 2015 15:21:09 +0000 (16:21 +0100)]
repository: expose `repo_init_create_head`

Expose the function `repo_init_create_head` as
`git_repository_create_head`.

7 years agoconfig: open configuration in commondir
Patrick Steinhardt [Thu, 24 Sep 2015 12:37:10 +0000 (14:37 +0200)]
config: open configuration in commondir

A repository's configuartion file can always be found in the
GIT_COMMON_DIR, which has been newly introduced. For normal
repositories this does change nothing, but for working trees this
change allows to access the shared configuration file.

7 years agorefdb: look for reflog in commondir
Patrick Steinhardt [Thu, 24 Sep 2015 13:32:26 +0000 (15:32 +0200)]
refdb: look for reflog in commondir

7 years agorefdb: introduce commondir awareness
Patrick Steinhardt [Wed, 16 Sep 2015 14:09:24 +0000 (16:09 +0200)]
refdb: introduce commondir awareness

The refdb_fs_backend is not aware of the git commondir, which
stores common objects like the o bject database and packed/loose
refereensces when worktrees are used.

Make refdb_fs_backend aware of the common directory by
introducing a new commonpath variable that points to the actual
common path of the database and using it instead of the gitdir
for the mentioned objects.

7 years agorefdb: rename refdb_fs_backend's .path to .gitpath
Patrick Steinhardt [Thu, 17 Sep 2015 09:40:55 +0000 (11:40 +0200)]
refdb: rename refdb_fs_backend's .path to .gitpath

The variable '.path' of the refdb_fs_backend struct becomes
confusing regarding the introduction of the git commondir. It
does not immediatly become obvious what it should point to.

Fix this problem by renaming the variable to `gitpath`,
clarifying that it acutally points to the `.git` directory of the
repository, in contrast to the commonpath directory, which points
to the directory containing shared objects like references and
the object store.

7 years agorepository: introduce is_worktree variable
Patrick Steinhardt [Thu, 15 Oct 2015 13:58:05 +0000 (15:58 +0200)]
repository: introduce is_worktree variable

7 years agorepository: use `git_repository_item_path`
Patrick Steinhardt [Fri, 11 Nov 2016 13:36:43 +0000 (14:36 +0100)]
repository: use `git_repository_item_path`

The recent introduction of the commondir variable of a repository
requires callers to distinguish whether their files are part of
the dot-git directory or the common directory shared between
multpile worktrees. In order to take the burden from callers and
unify knowledge on which files reside where, the
`git_repository_item_path` function has been introduced which
encapsulate this knowledge.

Modify most existing callers of `git_repository_path` to use
`git_repository_item_path` instead, thus making them implicitly
aware of the common directory.

7 years agorepository: add function to retrieve paths for repo items
Patrick Steinhardt [Fri, 11 Nov 2016 12:46:59 +0000 (13:46 +0100)]
repository: add function to retrieve paths for repo items

7 years agorepository: introduce commondir variable
Patrick Steinhardt [Wed, 16 Sep 2015 10:10:11 +0000 (12:10 +0200)]
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.

7 years agotests: implement worktree helpers
Patrick Steinhardt [Wed, 11 Nov 2015 09:54:41 +0000 (10:54 +0100)]
tests: implement worktree helpers

7 years agotests: add merge-conflict branch for testrepo
Patrick Steinhardt [Tue, 10 Nov 2015 14:53:09 +0000 (15:53 +0100)]
tests: add merge-conflict branch for testrepo

Add a new branch that causes a merge conflict to `testrepo` so
that we are able to test merging in worktrees.

7 years agotests: add submodule worktree test data
Patrick Steinhardt [Mon, 9 Nov 2015 16:00:41 +0000 (17:00 +0100)]
tests: add submodule worktree test data

Create worktrees for submodule repositories. The worktrees are
created for the parent repository (e.g. the one containing
submodules) and for the contained child repository.

7 years agotests: add worktree test data
Patrick Steinhardt [Wed, 11 Nov 2015 09:54:08 +0000 (10:54 +0100)]
tests: add worktree test data

7 years agoMerge pull request #4112 from cbargren/fix/proxy-env-vars
Edward Thomson [Fri, 10 Feb 2017 16:15:41 +0000 (16:15 +0000)]
Merge pull request #4112 from cbargren/fix/proxy-env-vars

Add support for lowercase proxy environment variables

7 years agoFixing a code style issue
Christopher Bargren [Fri, 10 Feb 2017 14:59:22 +0000 (07:59 -0700)]
Fixing a code style issue

7 years agoMerge pull request #4111 from pks-t/pks/dos-prefix
Edward Thomson [Fri, 10 Feb 2017 11:01:23 +0000 (11:01 +0000)]
Merge pull request #4111 from pks-t/pks/dos-prefix

dirname with DOS prefixes

7 years agoMerge pull request #4117 from rcjsuen/patch-1
Edward Thomson [Fri, 10 Feb 2017 10:59:27 +0000 (10:59 +0000)]
Merge pull request #4117 from rcjsuen/patch-1

Flag options in git_stash_apply and git_stash_pop as being optional

7 years agoChanges to provide option to turn off/on ofs_delta
Gaurav Saral [Wed, 8 Feb 2017 10:52:44 +0000 (16:22 +0530)]
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

7 years agoMerge pull request #4119 from libgit2/ethomson/submodule_renames
Edward Thomson [Fri, 10 Feb 2017 08:57:37 +0000 (08:57 +0000)]
Merge pull request #4119 from libgit2/ethomson/submodule_renames

rename detection: don't try to detect submodule renames

7 years agodiff: don't do rename detection on submodules
Edward Thomson [Thu, 9 Feb 2017 18:28:19 +0000 (18:28 +0000)]
diff: don't do rename detection on submodules

7 years agomerge: don't do rename detection on submodules
Edward Thomson [Thu, 9 Feb 2017 16:57:22 +0000 (16:57 +0000)]
merge: don't do rename detection on submodules

7 years agomerge_trees: introduce test for submodule renames
Edward Thomson [Thu, 9 Feb 2017 16:52:03 +0000 (16:52 +0000)]
merge_trees: introduce test for submodule renames

Test that shows that submodules are incorrectly considered in renames,
and `git_merge_trees` will fail to lookup the submodule as a blob.

7 years agoFlag optional parameters for apply and pop
Remy Suen [Thu, 9 Feb 2017 10:12:31 +0000 (19:12 +0900)]
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.

7 years agoMerge pull request #4104 from cbargren/fix/windows-digest-proxy
Edward Thomson [Thu, 9 Feb 2017 09:27:04 +0000 (09:27 +0000)]
Merge pull request #4104 from cbargren/fix/windows-digest-proxy

Fix digest credentials for proxy in windows

7 years agoAddressing PR feedback
Christopher Bargren [Wed, 8 Feb 2017 22:01:30 +0000 (15:01 -0700)]
Addressing PR feedback

7 years agoAdd support for lowercase proxy environment variables
Christopher Bargren [Tue, 7 Feb 2017 23:33:28 +0000 (16:33 -0700)]
Add support for lowercase proxy environment variables

curl supports HTTPS_PROXY in addition to https_proxy (and their http counterparts). This change ensures parity with curl's behavior.

7 years agotests: repo: assert discovery starting at Win32 roots finishes
Patrick Steinhardt [Wed, 8 Feb 2017 11:02:32 +0000 (12:02 +0100)]
tests: repo: assert discovery starting at Win32 roots finishes

As of recently, we failed to correctly discover repositories at a
Win32 system root. Instead of aborting the upwards-traversal of
the file system, we were looping infinitely when traversal
started at either a Win32 drive prefix ("C:/") or a network path
("//somehost").

The issue has been fixed, so add a test to catch regressions.

7 years agopath: ensure dirname on Win32 prefix always has a trailing '/'
Patrick Steinhardt [Wed, 8 Feb 2017 10:41:10 +0000 (11:41 +0100)]
path: ensure dirname on Win32 prefix always has a trailing '/'

When calling `git_path_dirname_r` on a Win32 prefix, e.g. a drive
or network share prefix, we always want to return the trailing
'/'. This does not work currently when passing in a path like
'C:', where the '/' would not be appended correctly.

Fix this by appending a '/' if we try to normalize a Win32 prefix
and there is no trailing '/'.

7 years agopath: get correct dirname for Windows root
Patrick Steinhardt [Tue, 7 Feb 2017 19:30:11 +0000 (20:30 +0100)]
path: get correct dirname for Windows root

Getting the dirname of a filesystem root should return the filesystem
root itself. E.g. the dirname of "/" is always "/". On Windows, we
emulate this behavior and as such, we should return e.g. "C:/" if
calling dirname on "C:/". But we currently fail to do so and instead
return ".", as we do not check if we actually have a Windows prefix
before stripping off the last directory component.

Fix this by calling out to `win32_prefix_length` immediately after
stripping trailing slashes, returning early if we have a prefix.

7 years agopath: extract `win32_path_prefix` function
Patrick Steinhardt [Tue, 7 Feb 2017 19:21:38 +0000 (20:21 +0100)]
path: extract `win32_path_prefix` function

Extract code which determines if a path is at a Windows system's root.
This incluses drive prefixes (e.g. "C:\") as well as network computer
names (e.g. "//computername/").

7 years agoMerge pull request #4109 from rcjsuen/patch-1
Edward Thomson [Wed, 8 Feb 2017 10:21:55 +0000 (10:21 +0000)]
Merge pull request #4109 from rcjsuen/patch-1

Flag checkout_opts in git_reset as optional

7 years agoPass proxy options payload to credentials callback
Christopher Bargren [Mon, 6 Feb 2017 18:00:06 +0000 (11:00 -0700)]
Pass proxy options payload to credentials callback

7 years agoFix digest credentials for proxy in windows
Chris Bargren [Wed, 1 Feb 2017 16:28:30 +0000 (09:28 -0700)]
Fix digest credentials for proxy in windows

7 years agoFlag checkout_opts in git_reset as optional
Remy Suen [Sat, 4 Feb 2017 22:12:32 +0000 (07:12 +0900)]
Flag checkout_opts in git_reset as optional

The check_outs argument can be NULL and should be flagged accordingly
in the header file.

7 years agoMerge pull request #4108 from rcjsuen/patch-1
Edward Thomson [Sat, 4 Feb 2017 10:04:30 +0000 (11:04 +0100)]
Merge pull request #4108 from rcjsuen/patch-1

Flag given_opts in git_revert as optional

7 years agoFlag given_opts in git_revert as optional
Remy Suen [Sat, 4 Feb 2017 08:24:31 +0000 (17:24 +0900)]
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.

7 years agoMerge pull request #4105 from pks-t/pks/vector-reverse-overflow
Edward Thomson [Thu, 2 Feb 2017 16:21:23 +0000 (17:21 +0100)]
Merge pull request #4105 from pks-t/pks/vector-reverse-overflow

Vector reverse overflow

7 years agovector: do not reverse a vector if it is empty
Patrick Steinhardt [Thu, 2 Feb 2017 15:02:57 +0000 (16:02 +0100)]
vector: do not reverse a vector if it is empty

The code reversing a vector initially determines the rear-pointer by
simply subtracting 1 from the vector's length. Obviously, this fails if
the vector is empty, in which case we have an integer overflow.

Fix the issue by returning early if the vector is empty.

7 years agorevwal: add failing test for walking with topo-sort
Adam Niedzielski [Wed, 1 Feb 2017 16:31:31 +0000 (17:31 +0100)]
revwal: add failing test for walking with topo-sort

7 years agoMerge pull request #4096 from mplough/master
Edward Thomson [Thu, 2 Feb 2017 13:31:33 +0000 (13:31 +0000)]
Merge pull request #4096 from mplough/master

Update docs for git_oid_fromstrn and p

7 years agoUpdate docs for git_oid_fromstrn and p
Matthew Plough [Fri, 27 Jan 2017 19:37:16 +0000 (14:37 -0500)]
Update docs for git_oid_fromstrn and p

7 years agoMerge pull request #4095 from mplough/master
Edward Thomson [Fri, 27 Jan 2017 17:56:52 +0000 (17:56 +0000)]
Merge pull request #4095 from mplough/master

Fix uninitialized variable warning

7 years agoFix uninitialized variable warning
Matthew Plough [Fri, 27 Jan 2017 17:49:48 +0000 (12:49 -0500)]
Fix uninitialized variable warning

Fix the following warning emitted by clang:
[ 16%] Building C object CMakeFiles/libgit2_clar.dir/src/submodule.c.o
/Users/mplough/devel/external/libgit2/src/submodule.c:408:6: warning: variable 'i' is used uninitialized whenever 'if' condition is true
      [-Wsometimes-uninitialized]
        if ((error = load_submodule_names(names, cfg)))
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mplough/devel/external/libgit2/src/submodule.c:448:20: note: uninitialized use occurs here
        git_iterator_free(i);
                          ^
/Users/mplough/devel/external/libgit2/src/submodule.c:408:2: note: remove the 'if' if its condition is always false
        if ((error = load_submodule_names(names, cfg)))
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/mplough/devel/external/libgit2/src/submodule.c:404:17: note: initialize the variable 'i' to silence this warning
        git_iterator *i;
                       ^
                        = NULL
1 warning generated.

7 years agoMerge pull request #4086 from libgit2/ethomson/fixes
Carlos Martín Nieto [Tue, 24 Jan 2017 21:26:41 +0000 (21:26 +0000)]
Merge pull request #4086 from libgit2/ethomson/fixes

WIP: some coverity & compiler warning fixes

7 years agoMerge pull request #4050 from ethomson/ethomson/winhttp_errmsgs
Carlos Martín Nieto [Tue, 24 Jan 2017 21:10:46 +0000 (21:10 +0000)]
Merge pull request #4050 from ethomson/ethomson/winhttp_errmsgs

WinHTTP: set proper error messages when SSL fails

7 years agocheckout::tree test: cleanup memory leak
Edward Thomson [Mon, 23 Jan 2017 23:32:13 +0000 (17:32 -0600)]
checkout::tree test: cleanup memory leak

7 years agoattr_cache_remove: don't remove given file
Edward Thomson [Mon, 23 Jan 2017 23:00:00 +0000 (23:00 +0000)]
attr_cache_remove: don't remove given file

If `attr_cache_lookup_entry` fails to find the given file, make sure
that we do not try to free the given file.

7 years agomac: on 32 bit, use `__builtin_umull_overflow`
Edward Thomson [Sun, 22 Jan 2017 01:42:45 +0000 (01:42 +0000)]
mac: on 32 bit, use `__builtin_umull_overflow`

7 years agosubmodule: only examine idx & head given a config
Edward Thomson [Sun, 22 Jan 2017 00:58:41 +0000 (00:58 +0000)]
submodule: only examine idx & head given a config

7 years agosubmodule: don't double free during load failure
Edward Thomson [Sun, 22 Jan 2017 00:30:02 +0000 (00:30 +0000)]
submodule: don't double free during load failure

When we fail to load submodules, don't free the list; it is later freed
unconditionally.

7 years agoMerge pull request #4087 from tiennou/warnings
Edward Thomson [Mon, 23 Jan 2017 13:29:14 +0000 (13:29 +0000)]
Merge pull request #4087 from tiennou/warnings

Fix a few recent warnings

7 years agovariable 'i' is used uninitialized whenever 'if' condition is true
Etienne Samson [Mon, 23 Jan 2017 12:29:47 +0000 (13:29 +0100)]
variable 'i' is used uninitialized whenever 'if' condition is true

7 years agoparameter 'id' not found in the function declaration
Etienne Samson [Mon, 23 Jan 2017 12:28:02 +0000 (12:28 +0000)]
parameter 'id' not found in the function declaration

7 years agoMerge pull request #4051 from tiennou/clang-analyzer-1
Edward Thomson [Sat, 21 Jan 2017 23:58:41 +0000 (23:58 +0000)]
Merge pull request #4051 from tiennou/clang-analyzer-1

Clang analyzer run

7 years agoMerge pull request #4053 from chescock/extend-packfile-by-pages
Edward Thomson [Sat, 21 Jan 2017 23:55:21 +0000 (23:55 +0000)]
Merge pull request #4053 from chescock/extend-packfile-by-pages

Extend packfile in increments of page_size.

7 years agoMerge branch 'pr/3912'
Edward Thomson [Sat, 21 Jan 2017 23:50:38 +0000 (23:50 +0000)]
Merge branch 'pr/3912'

7 years agosymbolic ref target validation: fixups
Edward Thomson [Sat, 21 Jan 2017 23:45:23 +0000 (23:45 +0000)]
symbolic ref target validation: fixups

Fixups requested in #3912.

7 years agowinhttp: set proper cert failure error messages
Edward Thomson [Fri, 30 Dec 2016 17:42:42 +0000 (12:42 -0500)]
winhttp: set proper cert failure error messages

Set up a WinHTTP status callback; inspect the WinHTTP status for
WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, and convert the status code
to a useful message for callers.

7 years agoMerge pull request #4078 from pks-t/pks/example-cleanup
Edward Thomson [Sat, 21 Jan 2017 23:11:13 +0000 (23:11 +0000)]
Merge pull request #4078 from pks-t/pks/example-cleanup

Fix general example memory leaks

7 years agoMerge pull request #3892 from mitesch/shared_buffer
Edward Thomson [Sat, 21 Jan 2017 22:51:50 +0000 (22:51 +0000)]
Merge pull request #3892 from mitesch/shared_buffer

Use a shared buffer in calls of git_treebuilder_write to avoid heap contention