]> git.proxmox.com Git - libgit2.git/log
libgit2.git
8 years agoMerge pull request #3865 from libgit2/ethomson/leaks
Edward Thomson [Tue, 2 Aug 2016 22:43:12 +0000 (18:43 -0400)]
Merge pull request #3865 from libgit2/ethomson/leaks

Fix leaks, some warnings and an error

8 years agocrlf: set a safe crlf default
Edward Thomson [Sun, 24 Jul 2016 20:10:30 +0000 (16:10 -0400)]
crlf: set a safe crlf default

8 years agoMerge pull request #3815 from pks-t/pks/coverity-model
Edward Thomson [Sun, 24 Jul 2016 20:05:17 +0000 (16:05 -0400)]
Merge pull request #3815 from pks-t/pks/coverity-model

Coverity user model

8 years agoMerge pull request #3862 from novalis/dturner/do-not-die-on-missing-config
Edward Thomson [Sun, 24 Jul 2016 19:51:13 +0000 (15:51 -0400)]
Merge pull request #3862 from novalis/dturner/do-not-die-on-missing-config

remote: Handle missing config values when deleting a remote

8 years agorepository: don't cast to `int` for no reason
Edward Thomson [Fri, 22 Jul 2016 18:02:00 +0000 (14:02 -0400)]
repository: don't cast to `int` for no reason

And give it a default so that some compilers don't (unnecessarily)
complain.

8 years agoindex: cast to avoid warning
Edward Thomson [Fri, 22 Jul 2016 16:53:13 +0000 (12:53 -0400)]
index: cast to avoid warning

8 years agotests: use a `size_t`
Edward Thomson [Fri, 22 Jul 2016 16:01:24 +0000 (12:01 -0400)]
tests: use a `size_t`

8 years agopackbuilder: `size_t` all the things
Edward Thomson [Fri, 15 Jul 2016 21:18:39 +0000 (17:18 -0400)]
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.

8 years agoapply: safety check files that dont end with eol
Edward Thomson [Fri, 15 Jul 2016 03:32:35 +0000 (23:32 -0400)]
apply: safety check files that dont end with eol

8 years agoapply: check allocation properly
Edward Thomson [Fri, 15 Jul 2016 03:04:47 +0000 (23:04 -0400)]
apply: check allocation properly

8 years agoapply: compare preimage to image
Edward Thomson [Fri, 15 Jul 2016 02:59:37 +0000 (22:59 -0400)]
apply: compare preimage to image

Compare the preimage to the image; don't compare the preimage to itself.

8 years agorepo::open: remove dead code, free buffers
Edward Thomson [Fri, 15 Jul 2016 16:43:57 +0000 (12:43 -0400)]
repo::open: remove dead code, free buffers

8 years agoMerge pull request #3868 from libgit2/ethomson/mac_build
Edward Thomson [Sun, 24 Jul 2016 19:47:58 +0000 (15:47 -0400)]
Merge pull request #3868 from libgit2/ethomson/mac_build

ci: point to the homebrew libssh2 install

8 years agoci: install homebrew's curl on mac
Edward Thomson [Sun, 24 Jul 2016 18:51:28 +0000 (14:51 -0400)]
ci: install homebrew's curl on mac

8 years agoci: install homebrew's zlib on mac
Edward Thomson [Fri, 22 Jul 2016 21:45:03 +0000 (17:45 -0400)]
ci: install homebrew's zlib on mac

8 years agoremote: Handle missing config values when deleting a remote
David Turner [Fri, 15 Jul 2016 17:32:23 +0000 (13:32 -0400)]
remote: Handle missing config values when deleting a remote

Somehow I ended up with the following in my ~/.gitconfig:
[branch "master"]
remote = origin
merge = master
rebase = true

I assume something went crazy while I was running the git.git tests
some time ago, and that I never noticed until now.

This is not a good configuration, but it shouldn't cause problems. But
it does. Specifically, if you have this in your config, and you
perform the following set of actions:

create a remote
fetch from that remote
create a branch off of the remote master branch called "master"
delete the branch
delete the remote

The remote delete fails with the message "Could not find key
'branch.master.rebase' to delete". This is because it's iterating over
the config entries (including the ones in the global config) and
believes that there is a master branch which must therefore have these
config keys.

https://github.com/libgit2/libgit2/issues/3856

8 years agoMerge pull request #3851 from txdv/get-user-agent
Edward Thomson [Tue, 5 Jul 2016 19:51:01 +0000 (15:51 -0400)]
Merge pull request #3851 from txdv/get-user-agent

Add get user agent functionality.

8 years agoMerge pull request #3846 from rkrp/fix_bug_parsing_int64min
Edward Thomson [Tue, 5 Jul 2016 16:46:27 +0000 (12:46 -0400)]
Merge pull request #3846 from rkrp/fix_bug_parsing_int64min

Fixed bug while parsing INT64_MIN

8 years agoAdd get user agent functionality.
Andrius Bentkus [Tue, 5 Jul 2016 06:41:51 +0000 (09:41 +0300)]
Add get user agent functionality.

8 years agoMerge pull request #3836 from joshtriplett/cleanup-find_repo
Edward Thomson [Fri, 1 Jul 2016 22:47:06 +0000 (18:47 -0400)]
Merge pull request #3836 from joshtriplett/cleanup-find_repo

find_repo: Clean up and simplify logic

8 years agoMerge pull request #3711 from joshtriplett/git_repository_discover_default
Edward Thomson [Fri, 1 Jul 2016 22:45:10 +0000 (18:45 -0400)]
Merge pull request #3711 from joshtriplett/git_repository_discover_default

Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars

8 years agoCHANGELOG.md: Document new flags for git_repository_open_ext
Josh Triplett [Thu, 30 Jun 2016 15:08:36 +0000 (08:08 -0700)]
CHANGELOG.md: Document new flags for git_repository_open_ext

Document GIT_REPOSITORY_OPEN_NO_DOTGIT and GIT_REPOSITORY_OPEN_FROM_ENV.

8 years agoCHANGELOG.md: Document behavior change in repository discovery
Josh Triplett [Thu, 30 Jun 2016 15:08:06 +0000 (08:08 -0700)]
CHANGELOG.md: Document behavior change in repository discovery

8 years agoMerge pull request #3847 from libgit2/ethomson/read_index_conflicts
Edward Thomson [Thu, 30 Jun 2016 14:20:32 +0000 (10:20 -0400)]
Merge pull request #3847 from libgit2/ethomson/read_index_conflicts

Include conflicts in `git_index_read_index`

8 years agoindex: include conflicts in `git_index_read_index`
Edward Thomson [Wed, 29 Jun 2016 21:55:44 +0000 (17:55 -0400)]
index: include conflicts in `git_index_read_index`

Ensure that we include conflicts when calling `git_index_read_index`,
which will remove conflicts in the index that do not exist in the new
target, and will add conflicts from the new target.

8 years agoindex: refactor common `read_index` functionality
Edward Thomson [Wed, 29 Jun 2016 21:01:47 +0000 (17:01 -0400)]
index: refactor common `read_index` functionality

Most of `git_index_read_index` is common to reading any iterator.
Refactor it out in case we want to implement `read_tree` in terms of it
in the future.

8 years agoMerge pull request #3813 from stinb/submodule-update-fetch
Edward Thomson [Wed, 29 Jun 2016 14:01:26 +0000 (10:01 -0400)]
Merge pull request #3813 from stinb/submodule-update-fetch

submodule: Try to fetch when update fails to find the target commit.

8 years agoMerge pull request #3842 from pks-t/pks/double-free
Edward Thomson [Wed, 29 Jun 2016 13:35:56 +0000 (09:35 -0400)]
Merge pull request #3842 from pks-t/pks/double-free

blame: increment reference count for origin's commit

8 years agoblame: do not decrement commit refcount in make_origin
Patrick Steinhardt [Mon, 27 Jun 2016 13:20:20 +0000 (15:20 +0200)]
blame: do not decrement commit refcount in make_origin

When we create a blame origin, we try to look up the blob that is
to be blamed at a certain revision. When this lookup fails, e.g.
because the file did not exist at that certain revision, we fail
to create the blame origin and return `NULL`. The blame origin
that we have just allocated is thereby free'd with
`origin_decref`.

The `origin_decref` function does not only decrement reference
counts for the blame origin, though, but also for its commit and
blob. When this is done in the error case, we will cause an
uneven reference count for these objects. This may result in
hard-to-debug failures at seemingly unrelated code paths, where
we try to access these objects when they in fact have already
been free'd.

Fix the issue by refactoring `make_origin` such that we only
allocate the object after the only function that may fail so that
we do not have to call `origin_decref` at all. Also fix the
`pass_blame` function, which indirectly calls `make_origin`, to
free the commit when `make_origin` failed.

8 years agoFixed bug while parsing INT64_MIN
Krishna Ram Prakash R [Tue, 28 Jun 2016 14:49:52 +0000 (20:19 +0530)]
Fixed bug while parsing INT64_MIN

8 years agosubmodule: Try to fetch when update fails to find the target commit in the submodule.
Jason Haslam [Tue, 28 Jun 2016 22:07:25 +0000 (16:07 -0600)]
submodule: Try to fetch when update fails to find the target commit in the submodule.

8 years agoMerge pull request #3223 from ethomson/apply
Edward Thomson [Sun, 26 Jun 2016 03:33:05 +0000 (23:33 -0400)]
Merge pull request #3223 from ethomson/apply

Reading patch files

8 years agoMerge pull request #3831 from libgit2/ethomson/readme
Edward Thomson [Sun, 26 Jun 2016 03:20:43 +0000 (23:20 -0400)]
Merge pull request #3831 from libgit2/ethomson/readme

Improve the README

8 years agopatch: show copy information for identical copies
Edward Thomson [Tue, 26 Apr 2016 05:18:01 +0000 (01:18 -0400)]
patch: show copy information for identical copies

When showing copy information because we are duplicating contents,
for example, when performing a `diff --find-copies-harder -M100 -B100`,
then show copy from/to lines in a patch, and do not show context.
Ensure that we can also parse such patches.

8 years agopatch::parse: test diff with exact rename and copy
Edward Thomson [Tue, 26 Apr 2016 02:35:55 +0000 (22:35 -0400)]
patch::parse: test diff with exact rename and copy

8 years agopatch::parse: test diff with simple rename
Edward Thomson [Mon, 25 Apr 2016 22:08:03 +0000 (18:08 -0400)]
patch::parse: test diff with simple rename

8 years agopatch::parse: handle patches with no hunks
Edward Thomson [Mon, 25 Apr 2016 21:52:39 +0000 (17:52 -0400)]
patch::parse: handle patches with no hunks

Patches may have no hunks when there's no modifications (for example,
in a rename).  Handle them.

8 years agodiff::parse tests: test parsing a diff
Edward Thomson [Mon, 25 Apr 2016 20:47:48 +0000 (16:47 -0400)]
diff::parse tests: test parsing a diff

Test that we can create a diff file, then parse the results and
that the two are identical in-memory.

8 years agofind_repo: Clean up and simplify logic
Josh Triplett [Fri, 24 Jun 2016 22:59:37 +0000 (15:59 -0700)]
find_repo: Clean up and simplify logic

find_repo had a complex loop and heavily nested conditionals, making it
difficult to follow.  Simplify this as much as possible:

- Separate assignments from conditionals.
- Check the complex loop condition in the only place it can change.
- Break out of the loop on error, rather than going through the rest of
  the loop body first.
- Handle error cases by immediately breaking, rather than nesting
  conditionals.
- Free repo_link unconditionally on the way out of the function, rather
  than in multiple places.
- Add more comments on the remaining complex steps.

8 years agoAdd GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
Josh Triplett [Mon, 4 Apr 2016 00:22:07 +0000 (17:22 -0700)]
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.

8 years agoAdd GIT_REPOSITORY_OPEN_NO_DOTGIT flag to avoid appending /.git
Josh Triplett [Sun, 3 Apr 2016 23:01:01 +0000 (16:01 -0700)]
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.

8 years agoFix repository discovery with ceiling_dirs at current directory
Josh Triplett [Mon, 4 Apr 2016 02:24:15 +0000 (19:24 -0700)]
Fix repository discovery with ceiling_dirs at current directory

git only checks ceiling directories when its search ascends to a parent
directory.  A ceiling directory matching the starting directory will not
prevent git from finding a repository in the starting directory or a
parent directory.  libgit2 handled the former case correctly, but
differed from git in the latter case: given a ceiling directory matching
the starting directory, but no repository at the starting directory,
libgit2 would stop the search at that point rather than finding a
repository in a parent directory.

Test case using git command-line tools:

/tmp$ git init x
Initialized empty Git repository in /tmp/x/.git/
/tmp$ cd x/
/tmp/x$ mkdir subdir
/tmp/x$ cd subdir/
/tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x git rev-parse --git-dir
fatal: Not a git repository (or any of the parent directories): .git
/tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x/subdir git rev-parse --git-dir
/tmp/x/.git

Fix the testsuite to test this case (in one case fixing a test that
depended on the current behavior), and then fix find_repo to handle this
case correctly.

In the process, simplify and document the logic in find_repo():
- Separate the concepts of "currently checking a .git directory" and
  "number of iterations left before going further counts as a search"
  into two separate variables, in_dot_git and min_iterations.
- Move the logic to handle in_dot_git and append /.git to the top of the
  loop.
- Only search ceiling_dirs and find ceiling_offset after running out of
  min_iterations; since ceiling_offset only tracks the longest matching
  ceiling directory, if ceiling_dirs contained both the current
  directory and a parent directory, this change makes find_repo stop the
  search at the parent directory.

8 years agoMerge pull request #3834 from pks-t/pks/cleanups
Edward Thomson [Tue, 21 Jun 2016 17:26:29 +0000 (13:26 -0400)]
Merge pull request #3834 from pks-t/pks/cleanups

Cleanups

8 years agoMerge pull request #3833 from pks-t/pks/msys-conditional-fpic
Edward Thomson [Tue, 21 Jun 2016 17:23:04 +0000 (13:23 -0400)]
Merge pull request #3833 from pks-t/pks/msys-conditional-fpic

cmake: do not use -fPIC for MSYS2

8 years agoRemove unused static functions
Patrick Steinhardt [Tue, 9 Feb 2016 11:29:31 +0000 (12:29 +0100)]
Remove unused static functions

8 years agoAvoid old-style function definitions
Patrick Steinhardt [Tue, 9 Feb 2016 11:18:28 +0000 (12:18 +0100)]
Avoid old-style function definitions

Avoid declaring old-style functions without any parameters.
Functions not accepting any parameters should be declared with
`void fn(void)`. See ISO C89 $3.5.4.3.

8 years agocmake: do not use -fPIC for MSYS2
Patrick Steinhardt [Mon, 20 Jun 2016 09:09:49 +0000 (11:09 +0200)]
cmake: do not use -fPIC for MSYS2

The MSYS2 build system automatically compiles all code with position-independent
code. When we manually add the -fPIC flag to the compiler flags, MSYS2 will
loudly complain about PIC being the default and thus not required.

Fix the annoyance by stripping -fPIC in MSYS2 enviroments like it is already
done for MinGW.

8 years agoMerge pull request #3830 from pks-t/pks/thread-namespacing
Edward Thomson [Tue, 21 Jun 2016 02:50:46 +0000 (22:50 -0400)]
Merge pull request #3830 from pks-t/pks/thread-namespacing

Thread namespacing

8 years agoREADME: update "Getting Help" section
Edward Thomson [Mon, 20 Jun 2016 19:05:02 +0000 (15:05 -0400)]
README: update "Getting Help" section

8 years agoREADME: update bindings
Edward Thomson [Mon, 20 Jun 2016 18:30:33 +0000 (14:30 -0400)]
README: update bindings

Drop node-gitteh.  Replace outdated PowerShell bindings with PSGit.

8 years agoREADME: improve contributing paragraph
Edward Thomson [Mon, 20 Jun 2016 18:24:17 +0000 (14:24 -0400)]
README: improve contributing paragraph

8 years agoREADME: disambiguate what to distribute source of
Edward Thomson [Mon, 20 Jun 2016 18:16:50 +0000 (14:16 -0400)]
README: disambiguate what to distribute source of

Indicate that if you make changes to libgit2 that you must distribute
the source _to libgit2_, not the source _of your program_.

8 years agothreads: add platform-independent thread initialization function
Patrick Steinhardt [Mon, 20 Jun 2016 18:07:33 +0000 (20:07 +0200)]
threads: add platform-independent thread initialization function

8 years agowin32: rename pthread.{c,h} to thread.{c,h}
Patrick Steinhardt [Mon, 20 Jun 2016 16:21:42 +0000 (18:21 +0200)]
win32: rename pthread.{c,h} to thread.{c,h}

The old pthread-file did re-implement the pthreads API with exact symbol
matching. As the thread-abstraction has now been split up between Unix- and
Windows-specific files within the `git_` namespace to avoid symbol-clashes
between libgit2 and pthreads, the rewritten wrappers have nothing to do with
pthreads anymore.

Rename the Windows-specific pthread-files to honor this change.

8 years agothreads: remove now-useless typedefs
Patrick Steinhardt [Mon, 20 Jun 2016 16:28:00 +0000 (18:28 +0200)]
threads: remove now-useless typedefs

8 years agothreads: remove unused function pthread_num_processors_np
Patrick Steinhardt [Mon, 20 Jun 2016 17:40:45 +0000 (19:40 +0200)]
threads: remove unused function pthread_num_processors_np

The function pthread_num_processors_np is currently unused and superseded by the
function `git_online_cpus`. Remove the function.

8 years agothreads: split up OS-dependent rwlock code
Patrick Steinhardt [Mon, 20 Jun 2016 15:49:47 +0000 (17:49 +0200)]
threads: split up OS-dependent rwlock code

8 years agothreads: split up OS-dependent thread-condition code
Patrick Steinhardt [Mon, 20 Jun 2016 15:20:13 +0000 (17:20 +0200)]
threads: split up OS-dependent thread-condition code

8 years agothreads: remove unused function pthread_cond_broadcast
Patrick Steinhardt [Mon, 20 Jun 2016 17:48:19 +0000 (19:48 +0200)]
threads: remove unused function pthread_cond_broadcast

8 years agothreads: split up OS-dependent mutex code
Patrick Steinhardt [Mon, 20 Jun 2016 15:07:14 +0000 (17:07 +0200)]
threads: split up OS-dependent mutex code

8 years agothreads: split up OS-dependent thread code
Patrick Steinhardt [Mon, 20 Jun 2016 15:44:04 +0000 (17:44 +0200)]
threads: split up OS-dependent thread code

8 years agoMerge pull request #3818 from meatcoder/fix_odb_read_error
Edward Thomson [Mon, 20 Jun 2016 15:16:49 +0000 (11:16 -0400)]
Merge pull request #3818 from meatcoder/fix_odb_read_error

Fix truncation of SHA in error message for git_odb_read

8 years agofix error message SHA truncation in git_odb__error_notfound()
Sim Domingo [Thu, 9 Jun 2016 14:50:53 +0000 (22:50 +0800)]
fix error message SHA truncation in git_odb__error_notfound()

8 years agoMerge pull request #3827 from dbrnz/basic_auth
Edward Thomson [Mon, 20 Jun 2016 15:09:31 +0000 (11:09 -0400)]
Merge pull request #3827 from dbrnz/basic_auth

HTTP authentication scheme name is case insensitive.

8 years agoHTTP authentication scheme name is case insensitive.
David Brooks [Sun, 19 Jun 2016 10:46:43 +0000 (11:46 +0100)]
HTTP authentication scheme name is case insensitive.

8 years agoMerge pull request #3823 from libgit2/ethomson/checkout_no_index
Carlos Martín Nieto [Fri, 17 Jun 2016 13:45:55 +0000 (15:45 +0200)]
Merge pull request #3823 from libgit2/ethomson/checkout_no_index

checkout: use empty baseline when no index file exists

8 years agoMerge pull request #3822 from libgit2/ethomson/checkout_head_docs
Carlos Martín Nieto [Thu, 16 Jun 2016 06:53:30 +0000 (08:53 +0200)]
Merge pull request #3822 from libgit2/ethomson/checkout_head_docs

documentation: improve docs for `checkout_head`

8 years agocheckout: use empty baseline when no index
Edward Thomson [Wed, 15 Jun 2016 20:47:28 +0000 (15:47 -0500)]
checkout: use empty baseline when no index

When no index file exists and a baseline is not explicitly provided, use
an empty baseline instead of trying to load `HEAD`.

8 years agodocumentation: improve docs for `checkout_head`
Edward Thomson [Tue, 14 Jun 2016 17:27:03 +0000 (12:27 -0500)]
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.

8 years agoMerge pull request #3812 from stinb/fetch-tag-update-callback
Edward Thomson [Tue, 14 Jun 2016 21:42:00 +0000 (11:42 -1000)]
Merge pull request #3812 from stinb/fetch-tag-update-callback

fetch: Fixed spurious update callback for existing tags.

8 years agofetch: Fixed spurious update callback for existing tags.
Jason Haslam [Tue, 14 Jun 2016 20:46:12 +0000 (14:46 -0600)]
fetch: Fixed spurious update callback for existing tags.

8 years agoMerge pull request #3816 from pks-t/pks/memory-leaks
Edward Thomson [Tue, 14 Jun 2016 14:33:55 +0000 (04:33 -1000)]
Merge pull request #3816 from pks-t/pks/memory-leaks

Memory leak fixes

8 years agoMerge pull request #3814 from pks-t/pks/invalid-memrefs
Edward Thomson [Tue, 14 Jun 2016 14:10:11 +0000 (04:10 -1000)]
Merge pull request #3814 from pks-t/pks/invalid-memrefs

Fix invalid memory references

8 years agowinhttp: plug several memory leaks
Patrick Steinhardt [Tue, 7 Jun 2016 12:14:07 +0000 (14:14 +0200)]
winhttp: plug several memory leaks

8 years agoglobal: clean up crt only after freeing tls data
Patrick Steinhardt [Tue, 7 Jun 2016 10:55:17 +0000 (12:55 +0200)]
global: clean up crt only after freeing tls data

The thread local storage is used to hold some global state that
is dynamically allocated and should be freed upon exit. On
Windows, we clean up the C run-time right after execution of
registered shutdown callbacks and before cleaning up the TLS.

When we clean up the CRT, we also cause it to analyze for memory
leaks. As we did not free the TLS yet this will lead to false
positives.

Fix the issue by first freeing the TLS and cleaning up the CRT
only afterwards.

8 years agotests: fix memory leaks in checkout::typechange
Patrick Steinhardt [Tue, 7 Jun 2016 10:29:16 +0000 (12:29 +0200)]
tests: fix memory leaks in checkout::typechange

8 years agocoverity: model functions printing into git_buf
Patrick Steinhardt [Tue, 7 Jun 2016 07:20:35 +0000 (09:20 +0200)]
coverity: model functions printing into git_buf

The `git_buf` structure seems to be too complicated to correctly
grasp for Coverity. As such, add simpler models trying to guide
Coverity and remove false positives related to these functions.

8 years agocoverity: add user model
Patrick Steinhardt [Tue, 7 Jun 2016 07:17:52 +0000 (09:17 +0200)]
coverity: add user model

The static analysis engine coverity allows for user models
overriding how it treats functions when analyzing code. Like
this, one can greatly reduce the rate of false positives and thus
make it easier to spot actual errors.

Add a user model that overrides function models for `git_buf_len`
and `git_vector_insert`, which together amount for a majority of
false positives.

8 years agoindex: fix NULL pointer access in index_remove_entry
Patrick Steinhardt [Tue, 7 Jun 2016 06:35:26 +0000 (08:35 +0200)]
index: fix NULL pointer access in index_remove_entry

When removing an entry from the index by its position, we first
retrieve the position from the index's entries and then try to
remove the retrieved value from the index map with
`DELETE_IN_MAP`. When `index_remove_entry` returns `NULL` we try
to feed it into the `DELETE_IN_MAP` macro, which will
unconditionally call `idxentry_hash` and then happily dereference
the `NULL` entry pointer.

Fix the issue by not passing a `NULL` entry into `DELETE_IN_MAP`.

8 years agotransports: smart: fix potential invalid memory dereferences
Patrick Steinhardt [Mon, 6 Jun 2016 10:59:17 +0000 (12:59 +0200)]
transports: smart: fix potential invalid memory dereferences

When we receive a packet of exactly four bytes encoding its
length as those four bytes it can be treated as an empty line.
While it is not really specified how those empty lines should be
treated, we currently ignore them and do not return an error when
trying to parse it but simply advance the data pointer.

Callers invoking `git_pkt_parse_line` are currently not prepared
to handle this case as they do not explicitly check this case.
While they could always reset the passed out-pointer to `NULL`
before calling `git_pkt_parse_line` and determine if the pointer
has been set afterwards, it makes more sense to update
`git_pkt_parse_line` to set the out-pointer to `NULL` itself when
it encounters such an empty packet. Like this it is guaranteed
that there will be no invalid memory references to free'd
pointers.

As such, the issue has been fixed such that `git_pkt_parse_line`
always sets the packet out pointer to `NULL` when an empty packet
has been received and callers check for this condition, skipping
such packets.

8 years agoMerge pull request #3808 from ethomson/read_index_fixes
Edward Thomson [Thu, 2 Jun 2016 08:08:26 +0000 (03:08 -0500)]
Merge pull request #3808 from ethomson/read_index_fixes

`git_index_read_index` fixes

8 years agoindex_read_index: invalidate new paths in tree cache
Edward Thomson [Thu, 2 Jun 2016 07:34:03 +0000 (02:34 -0500)]
index_read_index: invalidate new paths in tree cache

When adding a new entry to an existing index via `git_index_read_index`,
be sure to remove the tree cache entry for that new path.  This will
mark all parent trees as dirty.

8 years agorebase: test rebasing a new commit with subfolder
Edward Thomson [Thu, 2 Jun 2016 06:58:25 +0000 (01:58 -0500)]
rebase: test rebasing a new commit with subfolder

Test a rebase (both a merge rebase and an inmemory rebase) with a new
commit that adds files underneath a new subfolder.

8 years agotest: ensure we can round-trip a written tree
Edward Thomson [Thu, 2 Jun 2016 03:31:16 +0000 (22:31 -0500)]
test: ensure we can round-trip a written tree

Read a tree into an index, write the index, then re-open the index and
ensure that we are treesame to the original.

8 years agoindex_read_index: set flags for path_len correctly
Edward Thomson [Thu, 2 Jun 2016 06:04:58 +0000 (01:04 -0500)]
index_read_index: set flags for path_len correctly

Update the flags to reset the path_len (to emulate `index_insert`)

8 years agoindex_read_index: differentiate on mode
Edward Thomson [Thu, 2 Jun 2016 05:47:51 +0000 (00:47 -0500)]
index_read_index: differentiate on mode

Treat index entries with different modes as different, which they
are, at least for the purposes of up-to-date calculations.

8 years agoindex_read_index: reset error correctly
Edward Thomson [Wed, 1 Jun 2016 19:56:27 +0000 (14:56 -0500)]
index_read_index: reset error correctly

Clear any error state upon each iteration.  If one of the iterations
ends (with an error of `GIT_ITEROVER`) we need to reset that error to 0,
lest we stop the whole process prematurely.

8 years agoround-trip trees through index_read_index
Edward Thomson [Wed, 1 Jun 2016 19:52:25 +0000 (14:52 -0500)]
round-trip trees through index_read_index

Read a tree into an index using `git_index_read_index` (by reading
a tree into a new index, then reading that index into the current
index), then write the index back out, ensuring that our new index
is treesame to the tree that we read.

8 years agoMerge pull request #3796 from mmuman/haiku
Edward Thomson [Wed, 1 Jun 2016 16:33:58 +0000 (11:33 -0500)]
Merge pull request #3796 from mmuman/haiku

Preliminary Haiku port

8 years agoMerge pull request #3801 from ethomson/warning
Edward Thomson [Wed, 1 Jun 2016 16:05:45 +0000 (11:05 -0500)]
Merge pull request #3801 from ethomson/warning

cleanup: unused warning

8 years agowin32: clean up unused warnings in DllMain
Edward Thomson [Thu, 26 May 2016 17:52:29 +0000 (12:52 -0500)]
win32: clean up unused warnings in DllMain

8 years agorebase: change assertion to avoid
Edward Thomson [Thu, 26 May 2016 17:42:43 +0000 (12:42 -0500)]
rebase: change assertion to avoid

It looks like we're getting the operation and not doing anything
with it, when in fact we are asserting that it's not null.  Simply
assert that we are within the operation boundary instead of using
the `git_array_get` macro to do this for us.

8 years agofilebuf: fix uninitialized warning
Edward Thomson [Thu, 26 May 2016 17:39:09 +0000 (12:39 -0500)]
filebuf: fix uninitialized warning

8 years agocheckout: drop unused repo
Edward Thomson [Thu, 26 May 2016 17:28:32 +0000 (12:28 -0500)]
checkout: drop unused repo

8 years agocleanup: unused warning
Edward Thomson [Thu, 26 May 2016 15:51:16 +0000 (10:51 -0500)]
cleanup: unused warning

8 years agoMerge pull request #3803 from glensc/patch-1
Edward Thomson [Fri, 27 May 2016 14:15:01 +0000 (09:15 -0500)]
Merge pull request #3803 from glensc/patch-1

Update CMakeLists.txt

8 years agoUpdate CMakeLists.txt
Elan Ruusamäe [Fri, 27 May 2016 07:20:35 +0000 (10:20 +0300)]
Update CMakeLists.txt

typo fix

8 years agopatch: zero id and abbrev length for empty files
Edward Thomson [Mon, 25 Apr 2016 20:32:30 +0000 (16:32 -0400)]
patch: zero id and abbrev length for empty files

8 years agopatch: identify non-binary patches as `NOT_BINARY`
Edward Thomson [Mon, 25 Apr 2016 17:07:18 +0000 (13:07 -0400)]
patch: identify non-binary patches as `NOT_BINARY`

8 years agoIntroduce `git_diff_to_buf`
Edward Thomson [Mon, 25 Apr 2016 16:40:19 +0000 (12:40 -0400)]
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`.