Commit Graph

14439 Commits

Author SHA1 Message Date
Ashok P. Nadkarni
f4cc03bb20 Free parent and ref in lg2_commit before returning. 2022-02-18 08:55:13 -05:00
Michał Górny
f2cce1c740 cmake: Fix package name for system http-parser
Fix building against system http-parser library by fixing
the find_package() argument.  It seems to have been accidentally changed
from HTTPParser to HTTP_Parser in de178d36f, effectively making
the build against system library fail to find it:

```
CMake Warning at cmake/SelectHTTPParser.cmake:3 (find_package):
  By not providing "FindHTTP_Parser.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "HTTP_Parser", but CMake did not find one.

  Could not find a package configuration file provided by "HTTP_Parser" with
  any of the following names:

    HTTP_ParserConfig.cmake
    http_parser-config.cmake

  Add the installation prefix of "HTTP_Parser" to CMAKE_PREFIX_PATH or set
  "HTTP_Parser_DIR" to a directory containing one of the above files.  If
  "HTTP_Parser" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)

CMake Error at cmake/SelectHTTPParser.cmake:11 (message):
  http-parser support was requested but not found
Call Stack (most recent call first):
  src/CMakeLists.txt:97 (include)
```
2022-02-18 08:54:52 -05:00
Edward Thomson
403c48210a meta: show build status for v1.3 and v1.4 branches 2022-02-18 08:54:29 -05:00
Edward Thomson
1d5b9bd86d Merge pull request #6214 from libgit2/ethomson/v1.4
libgit2 v1.4
v1.4.0
2022-02-13 11:05:40 -05:00
Edward Thomson
bafd044fd9 v1.4: update the changelog 2022-02-13 10:07:49 -05:00
Edward Thomson
5c949d1faf v1.4: update version numbers 2022-02-13 10:06:15 -05:00
Edward Thomson
5f66aa264a Merge pull request #6212 from apnadkarni/patch-1
Fix crashes in example programs on Windows (sprintf_s not compatible with snprintf)
2022-02-13 09:16:09 -05:00
apnadkarni
77ef1a6e14 Update common.h 2022-02-13 14:11:46 +05:30
Edward Thomson
4c88b9d375 release.yml: use sentence case for everything 2022-02-12 21:29:43 -05:00
Edward Thomson
aded938e00 Merge pull request #6204 from boretrk/merge_flags
merge: fix overlap between GIT_MERGE_FILE_FAVOR__CONFLICTED and GIT_MERGE_FILE_SIMPLIFY_ALNUM
2022-02-12 21:23:01 -05:00
Edward Thomson
d99b4019e1 Merge pull request #6211 from libgit2/ethomson/release_config
meta: add a release configuration file
2022-02-12 14:20:47 -05:00
Edward Thomson
416f7cb347 Merge pull request #6208 from jorio/fix-stale-filesize-crash
diff_file: fix crash if size of diffed file changes in workdir
2022-02-12 10:38:08 -05:00
Edward Thomson
e3aad1dea0 meta: add a release configuration file
Let's let GitHub handle our release notes as much as possible:
https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
2022-02-12 10:27:12 -05:00
Edward Thomson
4467bd66ce Merge pull request #6207 from libgit2/ethomson/prng
mktmp: improve our temp file creation
2022-02-12 09:09:17 -05:00
Edward Thomson
0fbf62cd20 merge: make the internal flags public
We made the flags that enable recursive merge internal, on the
assumption that nobody would want them and they're hard to reason about.
(Giving people an option that nobody wants is just extra noise.)

However, it made it hard for _us_ to reason about.  There's no good
reason to keep it private, let's just make it public and push that
cognitive load onto our poor users.  But they should expect it, they're
dealing with git, after all.
2022-02-12 08:46:55 -05:00
Edward Thomson
d2ce981ffc diff: fail generation if a file changes size
When we know that we know a file's size, and the file's size changes,
fail.
2022-02-12 07:00:49 -05:00
Edward Thomson
359240b674 diff: indicate when the file size is "valid"
When we know the file size (because we're producing it from a working
directory iterator, or an index with an up-to-date cache) then set a
flag indicating as such.  This removes the ambiguity about a 0 file
size, which could indicate that a file exists and is 0 bytes, or that we
haven't read it yet.
2022-02-12 06:59:09 -05:00
Edward Thomson
e86e81c5d9 oid: make empty tree id global
Move the empty tree ID into a global space so that it can be generally
used.
2022-02-12 06:58:05 -05:00
Edward Thomson
e1415dc3fa diff_file: test empty workdir file grows after obtaining a diff
This test was also provided by @jorio
https://github.com/libgit2/libgit2/pull/6208#issuecomment-1034072050
2022-02-11 22:46:54 -05:00
Iliyas Jorio
9aade20b4e diff_file: test workdir file becomes empty after obtaining a diff 2022-02-11 22:46:54 -05:00
Iliyas Jorio
3bac68ff05 diff_file: Apply suggestions from code review
Skip new_file_size non-zero test, custom error message if file changed in workdir

Co-authored-by: Edward Thomson <ethomson@github.com>
2022-02-11 22:46:54 -05:00
Iliyas Jorio
0a0cd67dcb diff_file: fix crash if size of diffed file changes in workdir
"diff_file_content_load_workdir_file()" maps a file from the workdir
into memory. It uses git_diff_file.size to determine the size of the
memory mapping.

If this value goes stale, the mmaped area would be sized incorrectly.
This could occur if an external program changes the contents of the
file after libgit2 had cached its size. This used to segfault if the
file becomes smaller (mmaped area too large).

This patch causes diff_file_content_load_workdir_file to fail without
crashing if it detects that the file size has changed.
2022-02-11 22:46:54 -05:00
Edward Thomson
1d811f0eb9 Merge pull request #6203 from libgit2/ethomson/fetch_by_oid
Fetch by object id
2022-02-11 07:14:54 -05:00
Edward Thomson
b933c14a92 util: remove p_mktemp / p_mkstemp
We have our own temporary file creation function now in
`git_futils_mktmp`, remove the others since they may be terrible on some
platforms.
2022-02-09 09:41:22 -05:00
Edward Thomson
97fade4f19 fs_path: use new mktmp to query unicode support 2022-02-09 09:41:22 -05:00
Edward Thomson
53063e77fe futils: use our random function for mktemp
`mktemp` on mingw is exceedingly deficient, using a single monotonically
increasing alphabetic character and the pid.  We need to use our own
random number generator for temporary filenames.
2022-02-09 09:41:22 -05:00
Edward Thomson
86c58a5b6f str: add hexadigit encoding to strings 2022-02-09 09:41:22 -05:00
Edward Thomson
3c53796cbe rand: introduce git_rand PRNG
Introduce `git_rand`, a PRNG based on xoroshiro256**, a fast,
all-purpose pseudo-random number generator: https://prng.di.unimi.it

The PRNG will be seeded by the system's entropy store when possible,
falling back to current time and system data (pid, uptime, etc).
Inspiration for this was taken from libressl, but since our PRNG is
not used for cryptographic purposes (and indeed currently only generates
a unique temp file name that is written in a protected directory),
this should be more than sufficient.

Our implementation of xoroshiro256** was taken almost strictly from
the original author's sources, but was tested against PractRand to
ensure that there were no foolish mistranslations:

```
RNG_test using PractRand version 0.94
RNG = RNG_stdin64, seed = unknown
test set = core, folding = standard (64 bit)

rng=RNG_stdin64, seed=unknown
length= 256 megabytes (2^28 bytes), time= 2.9 seconds
  no anomalies in 210 test result(s)

rng=RNG_stdin64, seed=unknown
length= 512 megabytes (2^29 bytes), time= 6.2 seconds
  no anomalies in 226 test result(s)

rng=RNG_stdin64, seed=unknown
length= 1 gigabyte (2^30 bytes), time= 12.7 seconds
  no anomalies in 243 test result(s)

rng=RNG_stdin64, seed=unknown
length= 2 gigabytes (2^31 bytes), time= 25.4 seconds
  no anomalies in 261 test result(s)

rng=RNG_stdin64, seed=unknown
length= 4 gigabytes (2^32 bytes), time= 50.6 seconds
  no anomalies in 277 test result(s)

rng=RNG_stdin64, seed=unknown
length= 8 gigabytes (2^33 bytes), time= 104 seconds
  no anomalies in 294 test result(s)
```
2022-02-09 09:41:22 -05:00
Edward Thomson
d299a7aad6 Merge pull request #6205 from ccstolley/ccs_fix_http_push_timeout
push: Prepare pack before sending pack header.
2022-02-08 20:42:45 -05:00
Edward Thomson
1e7c8b1f64 Merge pull request #6206 from libgit2/ethomson/odb_write_failures
odb: check for write failures
2022-02-08 20:41:40 -05:00
Colin Stolley
aceac672fd Rename prepare_pack() to git_packbuilder__prepare() 2022-02-08 12:14:50 -06:00
Colin Stolley
9177585410 Update src/pack-objects.h
Co-authored-by: Edward Thomson <ethomson@github.com>
2022-02-08 18:04:52 +00:00
Edward Thomson
c19a3c7a23 odb: check for write failures 2022-02-07 11:22:04 -05:00
Colin Stolley
19ec5923db push: Prepare pack before sending pack header.
For large pushes, preparing the pack can take a while. Currently we
send the pack header first, followed by preparing the pack and then
finally sending the pack. Unfortunately github.com will terminate
a git-receive-pack command over http if it is idle for more than 10
seconds. This is easily exceeded for a large push, and so the push is
rejected with a Broken Pipe error.

This patch moves the pack preparation ahead of sending the pack header,
so that the timeout is avoided.

prepare_pack() can be called multiple times but will only do the work
once, so the original PREPARE_PACK call inside git_packbuilder_foreach()
remains.
2022-02-07 09:29:40 -06:00
Peter Pettersson
fed3fef451 merge: allocate merge flags for internal use
Allocate flags in git_merge_flag_t and git_merge_file_flag_t
for internal usage to prevent accidental double allocation.
2022-02-07 12:21:59 +01:00
Peter Pettersson
caaa1fdf8b merge: change enum GIT_MERGE_FILE_FAVOR__CONFLICTED to flag
GIT_MERGE_FILE__CONFLICTED

This is to avoid a possible problem where the value is set to the
same as GIT_MERGE_FILE_SIMPLIFY_ALNUM in git_merge_file_flag_t
2022-02-07 01:13:58 +01:00
Edward Thomson
d9863fc19e Merge pull request #6192 from libgit2/ethomson/sha256_preparation
SHA256: early preparation
2022-02-06 15:27:34 -05:00
Edward Thomson
9d88300a8e fetch: support oids in fetch specs 2022-02-06 15:08:35 -05:00
Edward Thomson
07264ea7b1 fetch: add a test for local fetching 2022-02-06 15:08:35 -05:00
Edward Thomson
37d98aaf44 transport: transports can indicate support for fetch by oid 2022-02-06 15:08:35 -05:00
Edward Thomson
7a00adcc68 remote: introduce git_remote_capabilities
Provide a mechanism for (internal) users to determine a remote's
capabilities from the transport.
2022-02-06 15:01:15 -05:00
Edward Thomson
923c16527c transport: add capabilities query function 2022-02-06 15:01:15 -05:00
Edward Thomson
b523776785 remote: refactor update tips function
Move the functionality to update an individual tip out of the loop;
although the update tip function remains rather gnarly, at least the
outer function is a bit less onerous.
2022-02-05 11:15:27 -05:00
Edward Thomson
b1e83cca1b remote: refactor ref updating
Pull ref updating into its own function for future uses.
2022-02-05 11:15:09 -05:00
Edward Thomson
b82d566464 oid: introduce git_oid__is_hexstr
Introduce a function that determines whether a given string is a valid
object id (40 chars of hexadigits).
2022-02-05 09:03:37 -05:00
Edward Thomson
4efd6563ca Merge pull request #6196 from libgit2/ethomson/at_revparse
revparse: support bare '@'
2022-02-03 16:39:26 -05:00
Edward Thomson
8d967d8580 Merge pull request #6200 from boretrk/c90
C90: add inline macro to xdiff and mbedtls
2022-02-03 14:25:15 -05:00
Peter Pettersson
b3384af2d8 C90: add inline macro to xdiff and mbedtls 2022-02-03 12:27:01 +01:00
Edward Thomson
61f1e31a14 Merge pull request #6197 from libgit2/ethomson/merge_msg_conflict_comment
merge: comment conflicts lines in MERGE_MSG
2022-02-02 22:35:18 -05:00
Edward Thomson
18a477e755 Merge pull request #6195 from libgit2/ethomson/zdiff3
merge: support zdiff3 conflict styles
2022-02-02 22:35:07 -05:00