]> git.proxmox.com Git - libgit2.git/log
libgit2.git
7 years agocheckout: fix double-free of checkout_data's mkdir_map
Patrick Steinhardt [Mon, 20 Mar 2017 07:59:30 +0000 (08:59 +0100)]
checkout: fix double-free of checkout_data's mkdir_map

We currently call `git_strmap_free` on `checkout_data.mkdir_map` in the
`checkout_data_clear` function. The only thing protecting us from a
double-free is that the `git_strmap_free` function is in fact not a
function, but a macro that also sets the map to NULL.

Remove the second call to `git_strmap_free` and explicitly set the map
member to NULL.

7 years agoMerge pull request #4161 from pks-t/pks/submodule-index-fix
Edward Thomson [Wed, 15 Mar 2017 15:03:45 +0000 (15:03 +0000)]
Merge pull request #4161 from pks-t/pks/submodule-index-fix

submodule: catch when submodule is not staged on update

7 years agoMerge branch 'gumenikav/merge_driver_source_info'
Patrick Steinhardt [Wed, 15 Mar 2017 07:20:26 +0000 (08:20 +0100)]
Merge branch 'gumenikav/merge_driver_source_info'

7 years agomerge_driver: add unresolved getters for git_merge_driver_source
Gumenik Alexandr [Mon, 6 Mar 2017 09:30:31 +0000 (12:30 +0300)]
merge_driver: add unresolved getters for git_merge_driver_source

7 years agoMerge pull request #4146 from pks-t/pks/winhttp-errors
Patrick Steinhardt [Tue, 14 Mar 2017 14:04:18 +0000 (15:04 +0100)]
Merge pull request #4146 from pks-t/pks/winhttp-errors

winhttp: disambiguate error messages when sending requests

7 years agosubmodule: catch when submodule is not staged on update
Patrick Steinhardt [Tue, 14 Mar 2017 13:53:32 +0000 (14:53 +0100)]
submodule: catch when submodule is not staged on update

When calling `git_submodule_update` on a submodule, we have to retrieve
the ID of the submodule entry in the index. If the function is called on
a submodule which is only partly initialized, the submodule entry may
not be added to the index yet. This leads to an assert when trying to
look up the blob later on.

Fix the issue by checking if the index actually holds the submodule's
ID and erroring out if it does not.

7 years agoMerge pull request #4157 from adamniedzielski/4099-git-sort-time-uninteresting
Carlos Martín Nieto [Sat, 11 Mar 2017 18:52:05 +0000 (19:52 +0100)]
Merge pull request #4157 from adamniedzielski/4099-git-sort-time-uninteresting

Skip uninteresting commits in revwalk timesort iterator

7 years agoMerge pull request #4156 from libgit2/ethomson/readbuffer_dont_hash
Carlos Martín Nieto [Sat, 11 Mar 2017 18:09:27 +0000 (19:09 +0100)]
Merge pull request #4156 from libgit2/ethomson/readbuffer_dont_hash

git_futils_readbuffer: don't compute sha-1

7 years agoMerge pull request #4151 from novalis/dturner/rebase-submodule-untracked
Edward Thomson [Thu, 9 Mar 2017 16:32:38 +0000 (16:32 +0000)]
Merge pull request #4151 from novalis/dturner/rebase-submodule-untracked

rebase: ignore untracked files in submodules

7 years agoSkip uninteresting commits in revwalk timesort iterator
Adam Niedzielski [Thu, 9 Mar 2017 13:01:10 +0000 (14:01 +0100)]
Skip uninteresting commits in revwalk timesort iterator

Fixes #4099

7 years agogit_futils_readbuffer: don't compute sha-1
Edward Thomson [Thu, 9 Mar 2017 12:26:23 +0000 (12:26 +0000)]
git_futils_readbuffer: don't compute sha-1

Don't compute the sha-1 in `git_futils_readbuffer_updated` unless the
checksum was requested.  This means that `git_futils_readbuffer` will
not calculate the checksum unnecessarily.

7 years agoMerge pull request #4154 from libgit2/ethomson/namespaces
Edward Thomson [Mon, 6 Mar 2017 15:53:57 +0000 (15:53 +0000)]
Merge pull request #4154 from libgit2/ethomson/namespaces

Support namespaced references again

7 years agorefdb_fs: honor the namespace
Edward Thomson [Mon, 6 Mar 2017 13:14:47 +0000 (13:14 +0000)]
refdb_fs: honor the namespace

7 years agorefs::namespace: add namespace tests
Edward Thomson [Mon, 6 Mar 2017 13:13:47 +0000 (13:13 +0000)]
refs::namespace: add namespace tests

These simple tests only ensure that we enforce the existence of a
namespace; these mirror the rugged tests, they are not exhaustive.

7 years agorebase: ignore untracked files in submodules
David Turner [Fri, 3 Mar 2017 18:27:47 +0000 (13:27 -0500)]
rebase: ignore untracked files in submodules

An untracked file in a submodule should not prevent a rebase from
starting.  Even if the submodule's SHA is changed, and that file would
conflict with a new tracked file, it's still OK to start the rebase
and discover the conflict later.

Signed-off-by: David Turner <dturner@twosigma.com>
7 years agoMerge pull request #4150 from libgit2/ethomson/freshen_trees
Carlos Martín Nieto [Fri, 3 Mar 2017 15:12:12 +0000 (16:12 +0100)]
Merge pull request #4150 from libgit2/ethomson/freshen_trees

git_commit_create: freshen tree objects in commit

7 years agogit_commit_create: freshen tree objects in commit
Edward Thomson [Fri, 3 Mar 2017 13:26:29 +0000 (13:26 +0000)]
git_commit_create: freshen tree objects in commit

Freshen the tree object that a commit points to during commit time.

7 years agoMerge pull request #4136 from libgit2/ethomson/sha1dc
Carlos Martín Nieto [Fri, 3 Mar 2017 11:36:36 +0000 (12:36 +0100)]
Merge pull request #4136 from libgit2/ethomson/sha1dc

Introduce (optional) SHA1 collision attack detection

7 years agocmake: drop unset `SHA1_TYPE`
Edward Thomson [Thu, 2 Mar 2017 20:56:47 +0000 (20:56 +0000)]
cmake: drop unset `SHA1_TYPE`

We never set `SHA1_TYPE` to `builtin`.  Don't bother testing for it.

7 years agohash: test for sha1 collision attack detection
Edward Thomson [Fri, 24 Feb 2017 14:14:56 +0000 (14:14 +0000)]
hash: test for sha1 collision attack detection

7 years agohash: include sha1collisiondetection
Edward Thomson [Fri, 24 Feb 2017 13:34:01 +0000 (13:34 +0000)]
hash: include sha1collisiondetection

Include the SHA1 collision attack detection library from
https://github.com/cr-marcstevens/sha1collisiondetection

7 years agohash: rename implementation selection constants
Edward Thomson [Fri, 24 Feb 2017 13:03:15 +0000 (13:03 +0000)]
hash: rename implementation selection constants

7 years agoMerge pull request #4148 from pks-t/pks/fix-haiku-builds
Patrick Steinhardt [Wed, 1 Mar 2017 13:51:39 +0000 (14:51 +0100)]
Merge pull request #4148 from pks-t/pks/fix-haiku-builds

cmake: only enable supported compiler warning flags

7 years agocmake: only enable supported compiler warning flags
Patrick Steinhardt [Wed, 1 Mar 2017 12:58:15 +0000 (13:58 +0100)]
cmake: only enable supported compiler warning flags

We currently unconditionally enable the "-Wall" and "-Wextra" flags.
Some platforms rely on compilers which do not support these flags,
though. One of these platforms is Haiku, which does not support
"-Wextra" due to being stuck on GCC version 2.

Fix builds on such platforms by adding these flags only if supported by
the compiler.

7 years agoMerge pull request #4145 from pks-t/pks/refs-create-memleak
Patrick Steinhardt [Wed, 1 Mar 2017 07:45:48 +0000 (08:45 +0100)]
Merge pull request #4145 from pks-t/pks/refs-create-memleak

tests: refs::create: fix memory leak

7 years agowinhttp: disambiguate error messages when sending requests
Patrick Steinhardt [Wed, 1 Mar 2017 06:58:40 +0000 (07:58 +0100)]
winhttp: disambiguate error messages when sending requests

7 years agotests: refs::create: fix memory leak
Patrick Steinhardt [Wed, 1 Mar 2017 06:45:14 +0000 (07:45 +0100)]
tests: refs::create: fix memory leak

7 years agoMerge pull request #4143 from richardipsum/issue-4094
Patrick Steinhardt [Wed, 1 Mar 2017 06:35:44 +0000 (07:35 +0100)]
Merge pull request #4143 from richardipsum/issue-4094

Fix: make reflog include "(merge)" for merge commits

7 years agoAdd test for inclusion of (merge) in reflog
Richard Ipsum [Tue, 28 Feb 2017 22:22:02 +0000 (22:22 +0000)]
Add test for inclusion of (merge) in reflog

This test ensures that the string '(merge)' is included in the reflog
when a merge commit is made.

7 years agoFix: make reflog include "(merge)" for merge commits
Richard Ipsum [Sun, 26 Feb 2017 13:34:13 +0000 (13:34 +0000)]
Fix: make reflog include "(merge)" for merge commits

This fixes issue #4094

7 years agoMerge pull request #4138 from richardipsum/symbolic-create-arbitrary-tgt-test
Edward Thomson [Sun, 26 Feb 2017 16:12:30 +0000 (16:12 +0000)]
Merge pull request #4138 from richardipsum/symbolic-create-arbitrary-tgt-test

tests: Add create__symbolic_with_arbitrary_content

7 years agoMerge pull request #4142 from pblesi/patch-1
Edward Thomson [Sun, 26 Feb 2017 16:08:00 +0000 (16:08 +0000)]
Merge pull request #4142 from pblesi/patch-1

Fix minor typos in CONVENTIONS.md

7 years agoMerge pull request #4141 from kainjow/patch-2
Edward Thomson [Sun, 26 Feb 2017 16:01:32 +0000 (16:01 +0000)]
Merge pull request #4141 from kainjow/patch-2

Fix inet_pton tests triggering an assert in Haiku

7 years agoFix minor typos in CONVENTIONS.md
Patrick Blesi [Sun, 26 Feb 2017 05:09:42 +0000 (23:09 -0600)]
Fix minor typos in CONVENTIONS.md

7 years agoFix inet_pton tests triggering an assert in Haiku
Kevin Wojniak [Sat, 25 Feb 2017 18:21:59 +0000 (10:21 -0800)]
Fix inet_pton tests triggering an assert in Haiku

Haiku will assert in a nightly build if the "dst" input to inet_pton() is NULL.

7 years agoWhitespace and style fixes
Richard Ipsum [Sat, 25 Feb 2017 14:17:10 +0000 (14:17 +0000)]
Whitespace and style fixes

Use C style comments as per style guide,
and fix mismatching indentation.

7 years agotests: Add create__symbolic_with_arbitrary_content
Richard Ipsum [Sun, 22 Jan 2017 00:21:30 +0000 (00:21 +0000)]
tests: Add create__symbolic_with_arbitrary_content

This test ensures that it's possible to create a symbolic ref that
has arbitrary data as its target. It also ensures it's possible
to obtain the target of that symbolic reference from the git_reference
object.

7 years agoMerge pull request #4137 from libgit2/ethomson/appveyor
Edward Thomson [Sat, 25 Feb 2017 12:45:14 +0000 (12:45 +0000)]
Merge pull request #4137 from libgit2/ethomson/appveyor

appveyor: don't rewrite the system mingw

7 years agoappveyor: don't rewrite system mingw
Edward Thomson [Fri, 24 Feb 2017 17:37:00 +0000 (17:37 +0000)]
appveyor: don't rewrite system mingw

Download mingw-w64 into our build directory and execute it there, don't
try to overwrite the system's mingw.

7 years agoappveyor: always build the 'appveyor' branch
Edward Thomson [Fri, 24 Feb 2017 17:38:42 +0000 (17:38 +0000)]
appveyor: always build the 'appveyor' branch

The 'appveyor' branch is useful for testing AppVeyor builds.

7 years agoMerge pull request #4133 from stinb/khash-cleanup-regression
Patrick Steinhardt [Fri, 24 Feb 2017 07:51:50 +0000 (08:51 +0100)]
Merge pull request #4133 from stinb/khash-cleanup-regression

fix regression from #4092

7 years agopack: fix looping over cache entries
Jason Haslam [Wed, 22 Feb 2017 16:29:00 +0000 (09:29 -0700)]
pack: fix looping over cache entries

Fixes a regression from #4092. This is a crash on 32-bit and I assume that
it doesn't do the right thing on 64-bit either. MSVC emits a warning for this,
but of course, it's easy to get lost among all of the similar 'possible loss
of data' warnings.

7 years agoMerge pull request #4131 from pks-t/pks/attrcache-cleanups
Carlos Martín Nieto [Wed, 22 Feb 2017 15:30:57 +0000 (16:30 +0100)]
Merge pull request #4131 from pks-t/pks/attrcache-cleanups

Attrcache cleanups

7 years agoMerge pull request #4135 from libgit2/ethomson/ancient_gcc_not_threadsafe
Carlos Martín Nieto [Wed, 22 Feb 2017 15:17:54 +0000 (16:17 +0100)]
Merge pull request #4135 from libgit2/ethomson/ancient_gcc_not_threadsafe

Provide error on gcc < 4.1 when THREADSAFE

7 years agoProvide error on gcc < 4.1 when THREADSAFE
Edward Thomson [Wed, 22 Feb 2017 10:34:19 +0000 (10:34 +0000)]
Provide error on gcc < 4.1 when THREADSAFE

Provide a descriptive error message when compiling THREADSAFE on gcc
versions < 4.1.  We require the atomic primitives (eg
`__sync_synchronize`) that were introduced in that version.

(Note, clang setes `__GNUC__` but appears to set its version > 4.1.)

7 years agoattrcache: remove useless `do_init` indirection
Patrick Steinhardt [Tue, 21 Feb 2017 14:14:04 +0000 (15:14 +0100)]
attrcache: remove useless `do_init` indirection

Remove useless indirection from `git_attr_cache__init` to
`git_attr_cache__do_init`. The difference is that the
`git_attr_cache__init` macro first checks if the cache is already
initialized and, if so, not call `git_attr_cache__do_init`. But
actually, `git_attr_cache__do_init` already does the same thing and
returns immediately if the cache is already initialized.

Remove the indirection.

7 years agoattrcache: replace existing file entry with `git__swap`
Patrick Steinhardt [Tue, 21 Feb 2017 10:52:15 +0000 (11:52 +0100)]
attrcache: replace existing file entry with `git__swap`

When doing an upsert of a file, we used to use `git__compare_and_swap`,
comparing the entry's file which is to be replaced with itself. This can
be more easily formulated by using `git__swap`, which unconditionally
replaces the value.

7 years agoattrcache: do not lock/unlock the mutex directly
Patrick Steinhardt [Tue, 21 Feb 2017 10:43:32 +0000 (11:43 +0100)]
attrcache: do not lock/unlock the mutex directly

Improve encapsulation by not referencing the attrcache mutex directly
but instead using the `attr_cache_lock` and `attr_cache_unlock`
functions.

7 years agoMerge pull request #4130 from libgit2/ethomson/clar_messages
Edward Thomson [Fri, 17 Feb 2017 16:32:14 +0000 (16:32 +0000)]
Merge pull request #4130 from libgit2/ethomson/clar_messages

Improve clar messages

7 years ago`cl_git_exec` -> `cl_git_expect`
Edward Thomson [Fri, 17 Feb 2017 13:01:49 +0000 (13:01 +0000)]
`cl_git_exec` -> `cl_git_expect`

7 years agotests: provide better pass/failure error messages
Edward Thomson [Fri, 17 Feb 2017 12:13:35 +0000 (12:13 +0000)]
tests: provide better pass/failure error messages

Provide more detailed messages when conditions pass or fail
unexpectedly.  In particular, this provides the error messages when a
test fails with a different error code than was expected.

7 years agop_snprintf: no need for arguments to a format
Edward Thomson [Fri, 17 Feb 2017 12:10:19 +0000 (12:10 +0000)]
p_snprintf: no need for arguments to a format

`snprintf` requires a _format_ but does not require _arguments_ to the
format.  eg: `snprintf(buf, 42, "hi")` is perfectly legal.  Expand the
macro to match.

Without this, `p_sprintf(buf, 42, "hi")` errors with:

```
error: expected expression
                p_snprintf(msg, 42, "hi");
                ^
src/unix/posix.h:53:34: note: expanded from macro 'p_snprintf'
                                 ^
/usr/include/secure/_stdio.h:57:73: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str),
__VA_ARGS__)
```

7 years agoMerge pull request #4092 from pks-t/pks/khash-cleanups
Patrick Steinhardt [Fri, 17 Feb 2017 11:41:05 +0000 (12:41 +0100)]
Merge pull request #4092 from pks-t/pks/khash-cleanups

khash cleanups

7 years agoidxmap: remove GIT__USE_IDXMAP
Patrick Steinhardt [Thu, 2 Feb 2017 12:09:32 +0000 (13:09 +0100)]
idxmap: remove GIT__USE_IDXMAP

7 years agoidxmap: convert to use functions instead of macros
Patrick Steinhardt [Thu, 2 Feb 2017 11:20:17 +0000 (12:20 +0100)]
idxmap: convert to use functions instead of macros

7 years agooffmap: remove GIT__USE_OFFMAP macro
Patrick Steinhardt [Thu, 2 Feb 2017 10:58:48 +0000 (11:58 +0100)]
offmap: remove GIT__USE_OFFMAP macro

7 years agooffmap: convert to use functions instead of macros
Patrick Steinhardt [Thu, 2 Feb 2017 10:57:31 +0000 (11:57 +0100)]
offmap: convert to use functions instead of macros

7 years agooidmap: remove GIT__USE_OIDMAP macro
Patrick Steinhardt [Fri, 27 Jan 2017 14:23:15 +0000 (15:23 +0100)]
oidmap: remove GIT__USE_OIDMAP macro

7 years agooidmap: convert macros to functions
Patrick Steinhardt [Fri, 27 Jan 2017 13:53:23 +0000 (14:53 +0100)]
oidmap: convert macros to functions

7 years agostrmap: remove GIT__USE_STRMAP macro
Patrick Steinhardt [Fri, 27 Jan 2017 13:32:23 +0000 (14:32 +0100)]
strmap: remove GIT__USE_STRMAP macro

7 years agostrmap: convert macros to functions
Patrick Steinhardt [Fri, 27 Jan 2017 13:13:49 +0000 (14:13 +0100)]
strmap: convert macros to functions

7 years agokhash: avoid using `kh_resize` directly
Patrick Steinhardt [Thu, 2 Feb 2017 12:08:52 +0000 (13:08 +0100)]
khash: avoid using `kh_resize` directly

7 years agokhash: avoid using macro magic to get return address
Patrick Steinhardt [Fri, 27 Jan 2017 13:20:24 +0000 (14:20 +0100)]
khash: avoid using macro magic to get return address

7 years agokhash: avoid using `kh_key`/`kh_val` as lvalue
Patrick Steinhardt [Fri, 27 Jan 2017 13:05:10 +0000 (14:05 +0100)]
khash: avoid using `kh_key`/`kh_val` as lvalue

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

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

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

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.