Commit Graph

5935 Commits

Author SHA1 Message Date
Patrick Steinhardt
7f407710ef odb_loose: fix undefined behavior when computing size
An object's size is computed by reading the object header's size
field until the most significant bit is not set anymore. To get
the total size, we increase the shift on each iteration and add
the shifted value to the total size.

We read the current value into a variable of type `unsigned
char`, from which we then take all bits except the most
significant bit and shift the result. We will end up with a
maximum shift of 60, but this exceeds the width of the value's
type, resulting in undefined behavior.

Fix the issue by instead reading the values into a variable of
type `unsigned long`, which matches the required width. This is
equivalent to git.git, which uses an `unsigned long` as well.
2016-05-02 17:45:24 +02:00
Patrick Steinhardt
7b24c4fd48 checkout: set ignorecase=0 when config lookup fails
When `git_repository__cvar` fails we may end up with a
`ignorecase` value of `-1`. As we subsequently check if
`ignorecase` is non-zero, we may end up reporting that data
should be removed when in fact it should not.

Err on the safer side and set `ignorecase = 0` when
`git_repository__cvar` fails.
2016-05-02 17:45:24 +02:00
Patrick Steinhardt
fcd1b78601 merge_file: do not unnecessarily check ours/theirs for NULL
The `merge_file__xdiff` function checks if either `ours` or
`theirs` is `NULL`. The function is to be called with existing
files, though, and in fact already unconditionally dereferences
both pointers.

Remove the unnecessary check to silence warnings.
2016-05-02 17:45:23 +02:00
Patrick Steinhardt
f80852af80 index: fix memory leak on error case 2016-05-02 14:30:14 +02:00
Carlos Martín Nieto
5e8ba35d44 Merge pull request #3763 from libgit2/ethomson/signature_from_buffer
Introduce `git_signature_from_buffer`
2016-04-29 10:36:01 +02:00
Edward Thomson
1e7fa834b5 Merge pull request #3760 from backhub/bug/openssl_read
Fix return value of openssl_read (infinite loop)
2016-04-28 22:32:20 -04: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
Christian Schlack
568c5a9fc1 Fix style: no braces 2016-04-27 13:56:16 +02:00
Edward Thomson
d55923788c annotated_commit: provide refs and description
Differentiate between the ref_name used to create an annotated_commit
(that can subsequently be used to look up the reference) and the
description that we resolved this with (which _cannot_ be looked up).

The description is used for things like reflogs (and may be a ref name,
and ID something that we revparsed to get here), while the ref name must
actually be a reference name, and is used for things like rebase to
return to the initial branch.
2016-04-26 13:19:58 -04:00
Christian Schlack
4734c52ab2 Fix return value of openssl_read (infinite loop)
openssl_read should return -1 in case of error.

SSL_read returns values <= 0 in case of error.

A return value of 0 can lead to an infinite loop, so the return value
of ssl_set_error will be returned if SSL_read is not successful (analog
to openssl_write).
2016-04-26 18:04:03 +02:00
Carlos Martín Nieto
9068704bd8 Merge pull request #3749 from arthurschreiber/arthur/add-git-reference-dup
Allow creating copies of `git_reference` objects.
2016-04-26 11:02:45 +02:00
Carlos Martín Nieto
c30955e0c0 Merge pull request #3748 from libgit2/ethomson/rebase_detached
Rebase improvements with IDs
2016-04-26 11:02:05 +02:00
Carlos Martín Nieto
eb39284bab tag: ignore extra header fields
While no extra header fields are defined for tags, git accepts them by
ignoring them and continuing the search for the message. There are a few
tags like this in the wild which git parses just fine, so we should do
the same.
2016-04-25 12:18:32 +02:00
Arthur Schreiber
908f24fd13 Allow creating copies of git_reference objects. 2016-04-22 10:34:17 -07:00
Edward Thomson
1f84caf0c0 rebase: correctly finish rebasing detached heads
When rebasing with IDs, we do not return to the `branch`,
we remain in a detached HEAD state.
2016-04-21 18:19:05 -04:00
Edward Thomson
badc72838f rebase: handle detached HEADs in init
When `init`ing a rebase from a detached HEAD, be sure to remember
that we were in a detached HEAD state so that we can correctly
`abort` the object that we just created.
2016-04-21 18:19:05 -04:00
Edward Thomson
375bb2fe60 transport: cast away constness for free 2016-04-21 11:02:31 -04:00
Edward Thomson
e0aed4bda3 stransport: pass proxy opts instead of char* 2016-04-21 11:01:09 -04:00
Edward Thomson
db22a91b86 iterator: ignore submodule in has_ended 2016-04-21 10:58:22 -04:00
Edward Thomson
1dc449105b Merge pull request #3110 from libgit2/cmn/proxy-config
Proxy configuration
2016-04-19 19:48:52 -04:00
Carlos Martín Nieto
d45928cc0d ignore: move star-star matching closer to it use
Instead of threading the state down to the larger loop, let's have the
loop where we detect the double star so each of them are easier to read.
2016-04-19 19:39:06 +02:00
Carlos Martín Nieto
1c3018eb12 ignore: fix directory limits when searching for star-star
In order to match the star-star, we disable the flag that's looking for
a single path element, but that leads to searching for the pattern in
the middle of elements in the input string.

Mark when we're handing a star-star so we jump over the elements in our
attempt to match the part of the pattern that comes after the star-star.

While here, tighten up the check so we don't allow invalid rules
through.
2016-04-19 19:39:05 +02: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
bf6f7ad297 winhttp: correctly detect HTTPS usage 2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
467e2cb1d7 curl: ask for proxy credentials 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
22e6aa0d4f proxy: don't require the trailing slash on WinHTTP
The path is not something that you use for proxies, so make use of the
new optionality of the path when extracting URL parts.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
4e01741390 netops: make the path optional in URLs
When we're dealing with proxy addresses, we only want a hostname and
port, and the user would not provide a path, so make it optional so we
can use this same function to parse git as well as proxy URLs.
2016-04-19 13:54:19 +02:00
Carlos Martín Nieto
b117721dd8 proxy: use poxy to test our Windows proxy support 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
Carlos Martín Nieto
77965c685d refs: provide a more general error message for dwim
If we cannot dwim the input, set the error message to be explicit about
that. Otherwise we leave the error for the last failed lookup, which
can be rather unexpected as it mentions a remote when the user thought
they were trying to look up a branch.
2016-04-11 17:47:03 +02:00
Carlos Martín Nieto
381caf5690 Merge pull request #3724 from ethomson/submodule_start_supports_silly_slashes
iterator/diff: allow trailing `/` on start/end paths to match submodules
2016-04-02 22:19:42 -07:00
Edward Thomson
d47f7e1c15 iterator: support trailing / in start for submod
Allow callers to specify a start path with a trailing slash to match
a submodule, instead of just a directory.  This is for some legacy
behavior that's sort of dumb, but there it is.
2016-04-02 13:34:55 -07:00
Carlos Martín Nieto
d364dc8b39 ignore: don't use realpath to canonicalize path
If we're looking for a symlink, realpath will give us the resolved path,
which is not what we're after, but a canonicalized version of the path
the user asked for.
2016-04-02 21:32:28 +02:00
Carlos Martín Nieto
36fc25572c Merge pull request #3720 from pks-t/pks/merge-driver-memleaks
merge_driver: fix missing `goto done;`
2016-04-01 04:09:50 -07:00
Patrick Steinhardt
83c93a7cc2 merge_driver: fix missing goto done;
The code initializing the merge driver registry accidentally
forgot a `goto done` in case of an error. Because of this the
next line, which registers the global shutdown callback for the
merge drivers, is only called when an error occured.

Fix this by adding the missing `goto done`. This fixes some
memory leaks when the global state is shut down.
2016-04-01 09:37:55 +02:00
Carlos Martín Nieto
1cac688d3f Merge pull request #3719 from libgit2/ethomson/submodule_status
WD iterator: properly identify submodules
2016-04-01 00:29:51 -07:00
Edward Thomson
4df6ddaa1a iterator: use correct search function 2016-03-31 17:58:43 -04:00
Edward Thomson
c4aa5c042c leaks: call xdl_free_classifier 2016-03-31 10:43:57 -04:00
Edward Thomson
9705483342 leaks: fix some iterator leaks 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
f5c874a475 Plug a few leaks 2016-03-31 10:41:33 -04:00
Carlos Martín Nieto
d53cc13e3a Merge pull request #3575 from pmq20/master-13jan16
Remove duplicated calls to git_mwindow_close
2016-03-31 04:12:46 -07:00
Patrick Steinhardt
6045afd398 xdiff/xprepare: fix a memory leak
The xdl_prepare_env() function may initialise an xdlclassifier_t
data structure via xdl_init_classifier(), which allocates memory
to several fields, for example 'rchash', 'rcrecs' and 'ncha'.
If this function later exits due to the failure of xdl_optimize_ctxs(),
then this xdlclassifier_t structure, and the memory allocated to it,
is not cleaned up.

In order to fix the memory leak, insert a call to xdl_free_classifier()
before returning.

This patch was originally written by Ramsay Jones (see commit
87f16258367a3b9a62663b11f898a4a6f3c19d31 in git.git).
2016-03-31 11:34:03 +02:00
Patrick Steinhardt
1bce14874f xdiff/xprepare: use the XDF_DIFF_ALG() macro to access flag bits
Commit 307ab20b3 ("xdiff: PATIENCE/HISTOGRAM are not independent option
bits", 19-02-2012) introduced the XDF_DIFF_ALG() macro to access the
flag bits used to represent the diff algorithm requested. In addition,
code which had used explicit manipulation of the flag bits was changed
to use the macros.

However, one example of direct manipulation remains. Update this code to
use the XDF_DIFF_ALG() macro.

This patch was originally written by Ramsay Jones (see commit
5cd6978a9cfef58de061a9525f3678ade479564d in git.git).
2016-03-31 11:33:40 +02:00
Carlos Martín Nieto
2f0450f4d6 Merge pull request #3712 from ethomson/config_duplicate_section
config: don't write duplicate section
2016-03-29 03:26:43 -07:00
Edward Thomson
b085ecbe09 Merge pull request #3703 from libgit2/cmn/multivar-set-locked
config: don't special-case multivars that don't exist yet
2016-03-28 13:51:21 -04:00
Edward Thomson
e25e1ca1b2 config: don't write section header if we're in it
If we hit the EOF while trying to write a new value, it may be that
we're already in the section that we were looking for.  If so, do not
write a (duplicate) section header, just write the value.
2016-03-28 11:13:51 -04:00
Carlos Martín Nieto
7b29be31c2 Merge pull request #3691 from ethomson/iterators
Some FANTASTIC iterator refactoring
2016-03-26 05:39:07 -07:00
Marc Strapetz
d6713ec64e iterator: comment fixed 2016-03-24 15:59:49 -04:00