Commit Graph

5238 Commits

Author SHA1 Message Date
Edward Thomson
09866d6f84 stash: correctly stash wd modified/index deleted 2015-02-18 11:26:03 -05:00
Edward Thomson
b49edddcd0 checkout: let the stream writer close the fd 2015-02-18 10:24:43 -05:00
Edward Thomson
f7c0125f47 filter streams: base -> parent 2015-02-18 10:24:34 -05:00
Edward Thomson
b75f15aaf1 git_writestream: from git_filter_stream 2015-02-18 10:24:23 -05:00
Edward Thomson
646364e780 checkout: maintain temporary buffer for filters
Let the filters use the checkout data's temporary buffer, instead
of having to allocate new buffers each time.
2015-02-17 16:03:45 -05:00
Edward Thomson
e78f5c9f42 checkout: stream the blob into the filters
Use the new streaming filter API during checkout.
2015-02-17 15:57:10 -05:00
Edward Thomson
5555696f8a filters: stream internally
Migrate the `git_filter_list_apply_*` functions over to using the
new filter streams.
2015-02-17 15:57:04 -05:00
Edward Thomson
fbdc9db364 filters: introduce streaming filters
Add structures and preliminary functions to take a buffer, file or
blob and write the contents in chunks through an arbitrary number
of chained filters, finally writing into a user-provided function
accept the contents.
2015-02-17 02:19:05 -05:00
Stefan Widgren
c8e02b8776 Remove extra semicolon outside of a function
Without this change, compiling with gcc and pedantic generates warning:
ISO C does not allow extra ‘;’ outside of a function.
2015-02-15 21:07:05 +01:00
Jason Haslam
8588cb0cbf Fix race in git_packfile_unpack.
Increment refcount of newly added cache entries just like existing
entries looked up from the cache. Otherwise the new entry can be
evicted from the cache and destroyed while it's still in use.
2015-02-14 23:43:26 -07:00
Carlos Martín Nieto
a291790a8d Merge pull request #2831 from ethomson/merge_lock
merge: lock index during the merge (not just checkout)
2015-02-15 05:18:01 +01:00
Carlos Martín Nieto
a7fa970f8b Merge pull request #2895 from ethomson/alloc_overflow
allocations: test for overflow of requested size
2015-02-15 05:13:50 +01:00
Edward Thomson
41fae48df2 indexwriter: an indexwriter for repo operations
Provide git_indexwriter_init_for_operation for the common locking
pattern in merge, rebase, revert and cherry-pick.
2015-02-14 09:25:36 -05:00
Edward Thomson
be8404a768 merge-like operations: lock index while working 2015-02-14 09:25:35 -05:00
Edward Thomson
8b0ddd5dd9 merge: lock the index at the start of the merge
Always lock the index when we begin the merge, before we write
any of the metdata files.  This prevents a race where another
client may run a commit after we have written the MERGE_HEAD but
before we have updated the index, which will produce a merge
commit that is treesame to one parent.  The merge will finish and
update the index and the resultant commit would not be a merge at
all.
2015-02-14 09:25:35 -05:00
Edward Thomson
8639ea5f98 checkout: introduce GIT_CHECKOUT_DONT_WRITE_INDEX 2015-02-14 09:25:35 -05:00
Edward Thomson
55798fd153 git_indexwriter: lock then write the index
Introduce `git_indexwriter`, to allow us to lock the index while
performing additional operations, then complete the write (or abort,
unlocking the index).
2015-02-14 09:25:35 -05:00
Edward Thomson
ffbd51edc8 rebase: CHECKOUT_SAFE instead of FORCE
Switch to a standard branch-switching pattern of a `SAFE` checkout,
then updating `HEAD`.
2015-02-13 11:38:00 -05:00
Edward Thomson
49b8293c75 rebase: allow NULL branch to indicate HEAD
Don't require the branch to rebase, if given `NULL`, simply look up
`HEAD`.
2015-02-13 11:20:32 -05:00
Edward Thomson
92e87dd749 rebase: provide NULL exec on non-EXEC operations
Users may want to try to pay attention to the `exec` field on all
rebase operations.
2015-02-13 10:44:19 -05:00
Edward Thomson
0f07d54b44 pack-objects: unlock the cache on integer overflow 2015-02-13 09:35:20 -05:00
Edward Thomson
16942c6fda integer overflow: use compiler intrinsics if supported
gcc and clang support __builtin_add_overflow, use it whenever
possible, falling back to our naive routines.
2015-02-13 09:28:09 -05:00
Edward Thomson
8aab36a301 filebuf: use an int for return check 2015-02-13 09:28:05 -05:00
Edward Thomson
f1453c59b2 Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it.  This means dropping the ability to pass `NULL` as
an out parameter.

As a result, the macros also get updated to reflect this as well.
2015-02-13 09:27:33 -05:00
Edward Thomson
527ed59ad8 win32: limit the mode to _wopen/_waccess
Win32 generally ignores Unix-like mode bits that don't make any
sense on the platform (eg `0644` makes no sense to Windows).  But
WINE complains loudly when presented with POSIXy bits.  Remove them.

(Thanks @phkelley)
2015-02-13 09:18:49 -05:00
Carlos Martín Nieto
0b2ee7c07c Merge pull request #2883 from urkud/reget-reader-pointer
Reinit `reader` pointer after reading included config file
2015-02-13 08:56:01 +01:00
Carlos Martín Nieto
3ca91107fc Merge pull request #2897 from leoyanggit/fix_fileop_warning
Fix build warning on Android
2015-02-13 08:30:21 +01:00
Edward Thomson
650e45f691 Update khash.h to pull request 42
https://github.com/attractivechaos/klib/pull/42/files introduces
`kreallocarray`.  Hook that up as our `git__reallocarray`.
2015-02-12 22:54:48 -05:00
Edward Thomson
1ad48c8a08 khash: update to klib f28c067 2015-02-12 22:54:47 -05:00
Edward Thomson
190b76a698 Introduce git__add_sizet_overflow and friends
Add some helper functions to check for overflow in a type-specific
manner.
2015-02-12 22:54:47 -05:00
Edward Thomson
8d534b4758 p_read: ensure requested len is ssize_t
Ensure that the given length to `p_read` is of ssize_t and ensure
that callers test the return as if it were an `ssize_t`.
2015-02-12 22:54:47 -05:00
Edward Thomson
ec3b4d35f6 Use size_t to hold size of arrays
Use `size_t` to hold the size of arrays to ease overflow checking,
lest we check for overflow of a `size_t` then promptly truncate
by packing the length into a smaller type.
2015-02-12 22:54:47 -05:00
Edward Thomson
2884cc42de overflow checking: don't make callers set oom
Have the ALLOC_OVERFLOW testing macros also simply set_oom in the
case where a computation would overflow, so that callers don't
need to.
2015-02-12 22:54:47 -05:00
Edward Thomson
4aa664ae39 git_buf_grow_by: increase buf asize incrementally
Introduce `git_buf_grow_by` to incrementally increase the size of a
`git_buf`, performing an overflow calculation on the growth.
2015-02-12 22:54:47 -05:00
Edward Thomson
3603cb0978 git__*allocarray: safer realloc and malloc
Introduce git__reallocarray that checks the product of the number
of elements and element size for overflow before allocation.  Also
introduce git__mallocarray that behaves like calloc, but without the
`c`.  (It does not zero memory, for those truly worried about every
cycle.)
2015-02-12 22:54:47 -05:00
Edward Thomson
15d54fdd34 odb__hashlink: check st.st_size before casting 2015-02-12 22:54:46 -05:00
Edward Thomson
392702ee2c allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
2015-02-12 22:54:46 -05:00
Leo Yang
3556a82a2a Fix build warning on Android
Always do a time_t cast on st_mtime. st_mtime on Android is not
the type of time_t but has the same meaning which is the number
of seconds past epoch.
2015-02-12 16:38:55 -05:00
Yury G. Kudryashov
1713653883 Reinit reader pointer after reading included config file
Fixes #2869. If included file includes more files, it may reallocate
cfg_file->readers, hence invalidate not only `r` pointer, but `result`
pointer as well.
2015-02-13 00:15:16 +03:00
Jameson Miller
02eb1495a5 Check rebase options version on public entry points 2015-02-12 15:32:52 -05:00
Carlos Martín Nieto
d24a5312d8 Merge pull request #2866 from ethomson/checkout_perf2
Checkout performance
2015-02-12 02:34:58 +01:00
Carlos Martín Nieto
8e29ae7310 Merge pull request #2862 from jeffhostetler/jeffhostetler/bug/branch_create_after_namespace
Remove stale reflog namespace directory before branch creation
2015-02-12 00:43:01 +01:00
Carlos Martín Nieto
e07c1e1a15 Merge pull request #2880 from ethomson/mkdir_root
Ensure we can make a repo at the root of the filesystem
2015-02-12 00:40:12 +01:00
Edward Thomson
ec510666a1 Credit utf8proc for utf8 iterator 2015-02-10 21:34:08 -05:00
Carlos Martín Nieto
cc36f424d4 repository: parse init.templatedir as a path
This is a path so we must use the path getter so we get the tilde
expansion done.
2015-02-06 01:09:26 +01:00
Edward Thomson
9cb5b0f73c mkdir: respect the root path
Don't try to strip trailing paths from the root directory on
Windows (trying to create `C:` will fail).
2015-02-05 12:27:19 -05:00
Edward Thomson
3c68bfcd08 stat: don't remove trailing '/' from root on win32
`p_stat` calls `git_win32_path_from_utf8`, which canonicalizes the
path.  Do not further try to modify the path, else we trim the
trailing slash from a root directory and try to access `C:` instead
of `C:/`.
2015-02-05 12:27:16 -05:00
Edward Thomson
9bf5bd7cd8 Merge pull request #2867 from ethomson/8dot3
Handle 8dot3 filenames being disabled on Win32
2015-02-05 09:19:46 -05:00
Edward Thomson
a2e4593e82 hash_generic: __extension__ keyword for pedantry 2015-02-04 15:26:09 -05:00
Edward Thomson
fa89ff20cd remove some unused warnings 2015-02-04 14:15:13 +00:00
Edward Thomson
500ec54315 checkout: hold seen dir paths in a map 2015-02-04 14:15:13 +00:00
Edward Thomson
f58cc280c9 attr_session: keep a temp buffer 2015-02-04 14:15:13 +00:00
Edward Thomson
d4b1b76701 checkout: cache system attributes file location 2015-02-04 14:15:12 +00:00
Edward Thomson
710f66af35 bswap: remove unused bswap 2015-02-03 18:43:57 -05:00
Edward Thomson
5f28ec84a1 win32: cleanup 8.3 disabled tests 2015-02-03 12:23:04 -05:00
Jeff Hostetler
1589a93aa6 Fix branch creation when branch name matches namespace of previously deleted branch 2015-02-03 10:33:04 -05:00
Edward Thomson
9f779aacdd attrcache: don't re-read attrs during checkout
During checkout, assume that the .gitattributes files aren't
modified during the checkout.  Instead, create an "attribute session"
during checkout.  Assume that attribute data read in the same
checkout "session" hasn't been modified since the checkout started.
(But allow subsequent checkouts to invalidate the cache.)

Further, cache nonexistent git_attr_file data even when .gitattributes
files are not found to prevent re-scanning for nonexistent files.
2015-02-03 00:31:08 -05:00
Linquize
9dcc4a36f7 Fix test failures when 8.3 is disabled 2015-01-31 00:09:31 +08:00
Edward Thomson
1ac5acdc69 Merge pull request #2819 from libgit2/cmn/config-get-path
config: add parsing and getter for paths
2015-01-26 11:28:59 -06:00
Edward Thomson
2724219918 Merge pull request #2837 from swisspol/set_index
Allow passing a NULL index to git_repository_set_index()
2015-01-26 11:27:09 -06:00
Edward Thomson
ff80b5e80b Merge pull request #2847 from jacquesg/coverity
More coverity fixes
2015-01-26 11:24:47 -06:00
Edward Thomson
9f1ee63d8f Merge pull request #2841 from swisspol/set_bare
Fixed git_repository_set_bare() not setting "core.bare" correctly
2015-01-26 11:20:00 -06:00
Edward Thomson
65bc22fa50 Merge pull request #2844 from rakuco/netinet-include-fixes
openssl: Add all required includes for AF_INET6 and in6_addr.
2015-01-26 11:18:17 -06:00
Jacques Germishuys
bb6aafe88f Ensure the diff hunk callback is specified before trying to dereference it 2015-01-25 14:40:23 +02:00
Jacques Germishuys
636af2198e Return early if allocating a git_pathspec_match_list failed 2015-01-25 14:38:10 +02:00
Jacques Germishuys
b63b3b0e4d Ensure git_index_entry is not NULL before trying to free it 2015-01-25 14:08:05 +02:00
Boris Egorov
dc5fe00c65 pathspec: do not try to dereference NULL
pathspec_match_free() should not dereference a NULL passed to it.

I found this issue when I tried to run example log program with
nonexistent branch:

./example/log help

Such call leads to segmentation fault.
2015-01-25 01:40:44 +06:00
Raphael Kubo da Costa
3cda6be76b openssl: Add all required includes for AF_INET6 and in6_addr.
This fixes the build at least on FreeBSD, where those types were not
defined indirectly:

src/openssl_stream.c💯18: error: variable has incomplete type 'struct in6_addr'
        struct in6_addr addr6;
                        ^
src/openssl_stream.c💯9: note: forward declaration of 'struct in6_addr'
        struct in6_addr addr6;
               ^
src/openssl_stream.c:111:18: error: use of undeclared identifier 'AF_INET'
        if (p_inet_pton(AF_INET, host, &addr4)) {
                        ^
src/unix/posix.h:31:40: note: expanded from macro 'p_inet_pton'
                                       ^
src/openssl_stream.c:115:18: error: use of undeclared identifier 'AF_INET6'
                if(p_inet_pton(AF_INET6, host, &addr6)) {
                               ^
src/unix/posix.h:31:40: note: expanded from macro 'p_inet_pton'
                                       ^
2015-01-24 16:19:43 +02:00
Pierre-Olivier Latour
b2a7bcdb54 Fixed git_repository_set_bare() not setting "core.bare" correctly 2015-01-23 20:57:13 -08:00
Pierre-Olivier Latour
fa8ca519cc Allow passing a NULL index to git_repository_set_index()
This is supported by the underlying set_index() implementation
and setting the repository index to NULL is recommended by the
git_repository_set_bare() documentation.
2015-01-23 15:35:29 -08:00
Edward Thomson
1188803922 checkout: free last created directory 2015-01-23 00:19:11 +00:00
Edward Thomson
a789b36100 Merge pull request #2829 from jacquesg/dead-code
Remove logically dead code (we're already asserting)
2015-01-21 09:20:54 -06:00
Edward Thomson
e74340b000 checkout: remove files before writing new ones
On case insensitive filesystems, we may have files in the working
directory that case fold to a name we want to write.  Remove those
files (by default) so that we will not end up with a filename that
has the unexpected case.
2015-01-20 17:13:31 -06:00
Edward Thomson
c2dee0fcb0 checkout: drop newline in error message 2015-01-20 17:13:20 -06:00
Edward Thomson
b4cbd67f5f checkout: don't recreate previous directory
Don't bother trying to recreate the previously created directory
during checkout, for a modest reduction in the number of stats.
2015-01-20 17:12:58 -06:00
Edward Thomson
fe598f0903 mkdir: walk up tree to mkdir
Walk up the tree to mkdir, which is less immediately efficient,
but allows us to look at intermediate directories that may need
attention.
2015-01-20 17:12:46 -06:00
Edward Thomson
1fbfcdfcd0 git_path_join_unrooted: return base len
The documentation for `git_path_join_unrooted` states that the base
length will be returned, so that consumers like checkout know where
to start creating directories instead of always creating directories
at the directory root.
2015-01-20 17:12:35 -06:00
Edward Thomson
1d50b3649d checkout: introduce git_checkout_perfdata
Checkout can now provide performance data about the number of (some)
syscalls performed using an optional callback.
2015-01-20 17:12:23 -06:00
Sven Strickroth
0161e096a3 Make binary detection work similar to vanilla git
Main change: Don't treat chars > 128 as non-printable (common in UTF-8 files)

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2015-01-20 16:17:37 -06:00
Jacques Germishuys
9ae4ad2daf Treat a NULL string as if it's empty 2015-01-20 23:26:55 +02:00
Jacques Germishuys
526182d28c Remove logically dead code (we're already asserting) 2015-01-20 23:24:32 +02:00
Edward Thomson
147d86fc69 diff: only compute patches when requested
When we're called with no hunk or line callback, we don't need to
do the hunk or line computation.
2015-01-20 12:31:24 -06:00
Maks Naumov
d8b5c8c329 Remove strlen() calls from loop condition
Avoid str length recalculation every iteration
2015-01-15 15:16:19 +02:00
Carlos Martín Nieto
eac773d92b config: add parsing and getter for paths 2015-01-14 19:36:50 +01:00
Edward Thomson
85880693d5 Merge branch 'pr/2740' 2015-01-14 10:19:28 -06:00
Pierre-Olivier Latour
b3837d4d2b Always use GIT_HASHSIG_SMART_WHITESPACE when diffing for merges
git_merge_tree_flag_t cannot contain any GIT_DIFF_FIND_xxx flags so there's not point in checking for them
2015-01-14 10:18:00 -06:00
Pierre-Olivier Latour
36fc549781 Added GIT_HASHSIG_ALLOW_SMALL_FILES to allow computing signatures for small files
The implementation of the hashsig API disallows computing a signature on
small files containing only a few lines. This new flag disables this
behavior.

git_diff_find_similar() sets this flag by default which means that rename
/ copy detection of small files will now work. This in turn affects the
behavior of the git_status and git_blame APIs which will now detect rename
of small files assuming the right options are passed.
2015-01-14 10:17:56 -06:00
Carlos Martín Nieto
d4b2410126 Merge commit '4b1018d24f980273528743c27c47ceb96cb720bd'
Fix crash in free() when git_buf_grow() fails.
2015-01-09 16:47:48 +01:00
Jeff Hostetler
4b1018d24f Fix crash in free() when git_buf_grow() fails. 2015-01-09 16:46:44 +01:00
Edward Thomson
a8846da7b3 remote: plug leak 2015-01-08 13:45:22 -06:00
Edward Thomson
1646412d8f Merge pull request #2802 from calavera/remote_create_prune_config
Load prune configuration when a remote is created.
2015-01-08 11:20:44 -06:00
David Calavera
c868981f0e Add extern function to initialize submodule update options. 2015-01-07 09:04:49 -06:00
Edward Thomson
5018e2c639 submodule: declare vars at top of func block 2015-01-06 17:08:38 -06:00
David Calavera
66b71ea5f5 Fix intentation. 2015-01-05 13:33:36 -08:00
David Calavera
1ef3f0cebb Load prune configuration when a remote is created. 2015-01-05 13:24:11 -08:00
Carlos Martín Nieto
0c6012293a Merge commit 'refs/pull/2632/head' of github.com:libgit2/libgit2 2015-01-05 20:10:43 +00:00
Pierre-Olivier Latour
c070ac64fd Fixed internal push state not being cleared on download
git_remote_download() must also clear the internal push state resulting from a possible earlier push operation. Otherwise calling git_remote_update_tips() will execute the push version instead of the fetch version and among other things, tags won't be updated.
2015-01-01 04:19:33 -08:00
Edward Thomson
a3ef70bb40 Merge pull request #2761 from libgit2/cmn/fetch-prune
Remote-tracking branch prunning
2014-12-30 11:53:55 -06:00
Edward Thomson
c4c47fc286 Merge pull request #2762 from libgit2/cmn/hide-push
remote: remove git_push from the public API
2014-12-30 11:53:45 -06:00
Carlos Martín Nieto
fe794b2ea7 remote: remove git_push from the public API
Instead we provide git_remote_upload() and git_remote_update_tips() in
order to have a parallel API for fetching and pushing.
2014-12-30 17:02:50 +00:00
Carlos Martín Nieto
13da562a87 Merge pull request #2785 from jacquesg/coverity
Coverity fixes
2014-12-30 16:48:52 +00:00
Jacques Germishuys
dfda1cf507 Check for OOM 2014-12-30 12:33:40 +02:00
Jacques Germishuys
0beb7fe427 Added missing error handling path 2014-12-30 12:33:40 +02:00
Jacques Germishuys
3dbd9a0e86 Check the result of git_buf_joinpath 2014-12-30 12:33:39 +02:00
Edward Thomson
4ceb388b13 Merge pull request #2784 from jacquesg/undef-stat
Undef stat for Mingw
2014-12-29 14:22:36 -06:00
Jacques Germishuys
6f73e02605 Plug some leaks 2014-12-29 18:18:49 +02:00
Jacques Germishuys
a1daec3c53 Undef stat first 2014-12-29 18:11:33 +02:00
Edward Thomson
ddf9532498 Merge pull request #2783 from libgit2/cmn/treebuilder-new
treebuilder: rename _create() to _new()
2014-12-29 09:30:05 -06:00
Sebastian Bauer
7cf86f923a Added AmigaOS-specific implementation of git__timer().
The clock_gettime() function is normally not available under
AmigaOS, hence another solution is required. We are using now
GetUpTime() that is present in current versions of this
operating system.
2014-12-28 10:35:47 +01:00
Carlos Martín Nieto
208a2c8aef treebuilder: rename _create() to _new()
This function is a constructor, so let's name it like one and leave
_create() for the reference functions, which do create/write the
reference.
2014-12-27 12:09:11 +00:00
Carlos Martín Nieto
5692dcf181 Merge pull request #2772 from ethomson/case_changing_rename
Case changing rename
2014-12-24 06:24:42 +00:00
Carlos Martín Nieto
171c2ff121 Merge pull request #2778 from ethomson/whitespace_85
don't treat 0x85 as whitespace
2014-12-24 06:23:36 +00:00
Edward Thomson
73f0278e5d global: include sys/openssl.h for GIT_EXPORT of fn
The openssl setup function needs to be GIT_EXPORT'ed, be sure
to include the `sys/openssl.h` header so that it is appropriately
decorated as an export function.
2014-12-23 16:40:01 -06:00
Edward Thomson
fe5f7722f5 don't treat 0x85 as whitespace
A byte value of 0x85 is not whitespace, we were conflating that with
U+0085 (UTF8: 0xc2 0x85).  This caused us to incorrectly treat valid
multibyte characters like U+88C5 (UTF8: 0xe8 0xa3 0x85) as whitespace.
2014-12-23 11:27:01 -06:00
Edward Thomson
40d791545a Always checkout with case sensitive iterator
On a case-insensitive filesystem, we need to deal with case-changing
renames (eg, foo -> FOO) by removing the old and adding the new,
exactly as if we were on a case-sensitive filesystem.

Update the `checkout::tree::can_cancel_checkout_from_notify` test, now
that notifications are always sent case sensitively.
2014-12-23 10:14:04 -06:00
Edward Thomson
2fe8157e1b index: reuc and name entrycounts should be size_t
For the REUC and NAME entries, we use size_t internally, and we take
size_t for the get_byindex() functions, but the entrycount() functions
strangely cast to an unsigned int instead.
2014-12-22 18:42:03 -06:00
Jameson Miller
9d1f97df10 Introduce a convenience function for submodule update
This introduces the functionality of submodule update in
'git_submodule_do_update'. The existing 'git_submodule_update' function is
renamed to 'git_submodule_update_strategy'. The 'git_submodule_update'
function now refers to functionality similar to `git submodule update`,
while `git_submodule_update_strategy` is used to get the configured value
of submodule.<name>.update.
2014-12-22 16:37:35 -05:00
Jameson Miller
b2ab887e11 submodule init should resolve relative url paths
Submodule init should handle relative paths in .gitmodules files
and resolve these urls when updating the git config file.
2014-12-22 16:35:45 -05:00
Edward Thomson
d147900ea4 Merge pull request #2759 from libgit2/cmn/openssl-sys
Make OpenSSL locking warnings more severe
2014-12-20 21:24:45 -06:00
Edward Thomson
c7d9839f54 Merge pull request #2763 from libgit2/cmn/local-proto-progress
Show progress output on fetch for the local transport
2014-12-20 21:22:30 -06:00
Linquize
6fd00266a8 COM0 is a valid path, although Windows Explorer does not allow to create this 2014-12-19 23:54:01 +08:00
Carlos Martín Nieto
629417bd10 Fix ming32 compilation
We need to know what wchar_t and MAX_PATH are. Including common.h takes
care of that for us.
2014-12-19 08:08:47 +00:00
Edward Thomson
dce7b1a4e7 treebuilder: take a repository for path validation
Path validation may be influenced by `core.protectHFS` and
`core.protectNTFS` configuration settings, thus treebuilders
can take a repository to influence their configuration.
2014-12-17 13:05:27 -05:00
Edward Thomson
ec74b40cee Introduce core.protectHFS and core.protectNTFS
Validate HFS ignored char ".git" paths when `core.protectHFS` is
specified.  Validate NTFS invalid ".git" paths when `core.protectNTFS`
is specified.
2014-12-17 12:52:07 -05:00
Vicent Marti
8e35527de2 path: Use UTF8 iteration for HFS chars 2014-12-16 10:24:18 -06:00
Edward Thomson
11d67b754d checkout: disallow bad paths on HFS
HFS filesystems ignore some characters like U+200C.  When these
characters are included in a path, they will be ignored for the
purposes of comparison with other paths.  Thus, if you have a ".git"
folder, a folder of ".git<U+200C>" will also match.  Protect our
".git" folder by ensuring that ".git<U+200C>" and friends do not match it.
2014-12-16 10:08:59 -06:00
Edward Thomson
ee5da720e5 reference_create: validate loose names
Validate loose reference names on Win32.
2014-12-16 10:08:56 -06:00
Edward Thomson
a64119e396 checkout: disallow bad paths on win32
Disallow:
 1. paths with trailing dot
 2. paths with trailing space
 3. paths with trailing colon
 4. paths that are 8.3 short names of .git folders ("GIT~1")
 5. paths that are reserved path names (COM1, LPT1, etc).
 6. paths with reserved DOS characters (colons, asterisks, etc)

These paths would (without \\?\ syntax) be elided to other paths - for
example, ".git." would be written as ".git".  As a result, writing these
paths literally (using \\?\ syntax) makes them hard to operate with from
the shell, Windows Explorer or other tools.  Disallow these.
2014-12-16 10:08:53 -06:00
Vicent Marti
0d388adc86 index: Check for valid paths before creating an index entry 2014-12-16 10:08:49 -06:00
Vicent Marti
62155257d2 tree: Check for .git with case insensitivy 2014-12-16 10:08:46 -06:00
Edward Thomson
cceae9a25d win32: use NT-prefixed "\\?\" paths
When turning UTF-8 paths into UCS-2 paths for Windows, always use
the \\?\-prefixed paths.  Because this bypasses the system's
path canonicalization, handle the canonicalization functions ourselves.

We must:
 1. always use a backslash as a directory separator
 2. only use a single backslash between directories
 3. not rely on the system to translate "." and ".." in paths
 4. remove trailing backslashes, except at the drive root (C:\)
2014-12-16 10:08:43 -06:00
Carlos Martín Nieto
4fd2bda9ff local: send 'counting objects' output
Pretend we have a git process at the other end by creating a similar
progress output when inserting objects into the packbuilder.
2014-12-16 10:25:45 +01:00
Carlos Martín Nieto
26186b155b fetch: remove the prune setter
This option does not get persisted to disk, which makes it different
from the rest of the setters. Remove it until we go all the way.

We still respect the configuration option, and it's still possible to
perform a one-time prune by calling the function.
2014-12-14 21:52:27 +01:00
Carlos Martín Nieto
59ff8b6790 fetch: perform prune in separate steps
For each remote-tracking branch we want to remove, we need to consider
it against every other refspec in case we have overlapping refspecs,
such as with

    refs/heads/*:refs/remotes/origin/*
    refs/pull/*/head:refs/remotes/origin/pr/*

as we'd otherwise remove too many refspecs.

Create a list of condidates, which are the references matching the rhs
of any active refspec and then filter that list by removing those
entries for which we find a remove reference with any active
refspec. Those which are left after this are removed.
2014-12-14 21:25:08 +01:00
Carlos Martín Nieto
8c13eaedbb fetch: prune after updating tips
This makes a fetch+prune more similar to a connect+prune and makes it
more likely that we see errors in the decision to prune a reference.
2014-12-14 17:04:02 +01:00
David Calavera
439e19f632 Test that prune overlapping works as expected. 2014-12-14 17:04:01 +01:00
Linquize
5f47394753 remote: prune refs when fetching 2014-12-14 17:04:01 +01:00
Carlos Martín Nieto
263b1d6ed9 Make the OpenSSL locking function warnings more severe
Our git_openssl_set_locking() would ideally not exist. Make it clearer
that we provide it as a last resort and you should prefer anything else.
2014-12-12 15:46:57 +01:00
Carlos Martín Nieto
d524b2d3d1 push: fold unpack_ok() into finish()
The push cannot be successful if we sent a bad packfile. We should
return an error in that case instead of storing it elsewhere.
2014-12-10 18:55:54 +01:00
Edward Thomson
cd305c2f56 Merge pull request #2678 from libgit2/cmn/io-stream
Introduce stackable IO streams
2014-12-10 11:30:28 -05:00
Carlos Martín Nieto
a2fd56ab18 Fix a couple of compiler warnings 2014-12-10 16:22:50 +01:00
Carlos Martín Nieto
49ae22baac stream: constify the write buffer 2014-12-10 16:20:52 +01:00
Carlos Martín Nieto
1b75c29e3e gitno: remove code which is no longer needed
Most of the network-facing facilities have been copied to the socket and
openssl streams. No code now uses these functions directly anymore, so
we can now remove them.
2014-12-10 01:39:09 +01:00
Carlos Martín Nieto
4fd4341fe5 ssh: use socket_stream to perform the connection
Having an ssh stream would require extra work for stream capabilities we
don't need anywhere else (oob auth and command execution) so for now
let's move away from the gitno connection to use socket_stream.

We can introduce an ssh stream interface if and as we need it.
2014-12-10 01:39:09 +01:00
Carlos Martín Nieto
b6f5464e28 Port HTTP(S) to the new stream API 2014-12-10 01:39:09 +01:00
Carlos Martín Nieto
02b4c1e2a4 Port the TCP transport to the new stream API 2014-12-10 01:39:09 +01:00
Carlos Martín Nieto
468d7b11f9 Add an OpenSSL IO stream
This unfortunately isn't as stackable as could be possible, as it
hard-codes the socket stream. This is because the method of using a
custom openssl BIO is not clear, and we do not need this for now. We can
still bring this in if and as we need it.
2014-12-10 01:17:41 +01:00
Carlos Martín Nieto
dd4ff2c9b5 Introduce stackable IO streams
We currently have gitno for talking over TCP, but this needs to know
about both plaintext and OpenSSL connections and the code has gotten
somewhat messy with ifdefs determining which version of the function
should be called.

In order to clean this up and abstract away the details of sending over
the different types of streams, we can instead use an interface and
stack stream implementations.

We may not be able to use the stackability with all streams, but we
are definitely be able to use the abstraction which is currently spread
between different bits of gitno.
2014-12-10 01:17:40 +01:00
Edward Thomson
ad2bf40a9d winhttp: plug some leaks 2014-12-09 12:04:55 -05:00
Edward Thomson
c251f3bbe7 win32: remember to cleanup our hash_ctx 2014-12-09 12:04:47 -05:00
Edward Thomson
19ae843937 Merge pull request #2746 from libgit2/cmn/neg-ignore-dir
Fix negative ignores withing ignored dirs
2014-12-06 20:17:16 -05:00
Edward Thomson
013924c17c Merge pull request #2730 from libgit2/cmn/local-push
Adjust the local transport for the common refspec parser
2014-12-05 23:44:34 -05:00
Carlos Martín Nieto
21083a7129 notes: move the notes name argument
Make it consistent between git_note_create() and git_note_remote() by
putting it after the repository.
2014-12-06 04:20:09 +01:00
Carlos Martín Nieto
e05b2ff127 ignore: match git's rule negation rules
A rule can only negate something which was explicitly mentioned in the
rules before it. Change our parsing to ignore a negative rule which does
not negate something mentioned in the rules above it.

While here, fix a wrong allocator usage. The memory for the match string
comes from pool allocator. We must not free it with the general
allocator. We can instead simply forget the string and it will be
cleaned up.
2014-12-05 20:13:24 +01:00
nulltoken
30ec05260d Merge pull request #2744 from epmatsw/spelling
Spelling fixes
2014-12-05 07:44:09 +01:00
Carlos Martín Nieto
e79fbd9e8a Merge pull request #2743 from ethomson/init_val
init: return the number of initializations
2014-12-05 07:09:08 +01:00
Will Stamper
b874629b2d Spelling fixes 2014-12-04 21:06:59 -06:00
Edward Thomson
6d91dc5351 init: return the number of initializations 2014-12-04 20:42:27 -05:00
Carlos Martín Nieto
8bfbe6988f Merge pull request #2742 from stewid/add_missing_else_directive
Add missing else directive
2014-12-03 21:54:44 +01:00
Stefan Widgren
2d2cd625ea Add missing else directive
Add missing else directive to fix compiler warning: control reaches
end of non-void function
2014-12-03 21:01:42 +01:00
Edward Thomson
70d21742bf win32: clear connection data on close 2014-12-03 00:41:46 -05:00
Edward Thomson
32e2b758cf describe: check error codes 2014-11-29 15:57:35 -05:00
Edward Thomson
e952bc5a57 Merge pull request #2718 from libgit2/cmn/peeling-errors
peel: reject bad queries with EPEEL
2014-11-23 17:15:18 -05:00
Carlos Martín Nieto
d5c84f67d3 local: adjust to the common refspec parser
We no longer have NULL strings, but empty ones and duplicate the sides
if necessar, so the first check will never do anything.

While in the area, remove unnecessary ifs and early returns.
2014-11-23 21:34:45 +01:00
Carlos Martín Nieto
52ee0e8e6d remote: verify there is a push foreach callback set 2014-11-23 21:26:53 +01:00
Carlos Martín Nieto
f7fcb18f8a Plug leaks
Valgrind is now clean except for libssl and libgcrypt.
2014-11-23 15:51:31 +01:00
Carlos Martín Nieto
753e17b0f5 peel: reject bad queries with EINVALIDSPEC
There are some combination of objects and target types which we know
cannot be fulfilled. Return EINVALIDSPEC for those to signify that there
is a mismatch in the user-provided data and what the object model is
capable of satisfying.

If we start at a tag and in the course of peeling find out that we
cannot reach a particular type, we return EPEEL.
2014-11-22 18:55:22 +01:00
Carlos Martín Nieto
e06b1040d7 Merge pull request #2723 from ravindp/ravindp/fix_4_missing_delta_bases
Fix for misleading "missing delta bases" error.
2014-11-22 18:39:50 +01:00
Ravindra Patel
ec7e680c6c Fix for misleading "missing delta bases" error - Fix #2721. 2014-11-21 15:05:34 -05:00
Vicent Marti
24cce2398f text: Null-terminate a string if we've been gouging it 2014-11-21 18:09:57 +01:00
Vicent Marti
b7fb71e39c notes: Use git__strndup 2014-11-21 17:38:55 +01:00
Vicent Marti
1ba48b7caf notes: Do not assume blob contents are NULL-terminated 2014-11-21 17:21:34 +01:00
Vicent Marti
72d0024134 attr_file: Do not assume ODB data is NULL-terminated
That's a bad assumption to make, even though right now it holds
(because of the way we've implemented decompression of packfiles),
this may change in the future, given that ODB objects can be
binary data.

Furthermore, the ODB object can return a NULL pointer if the object
is empty. Copying the NULL pointer to the strbuf lets us handle it
like an empty string. Again, the NULL pointer is valid behavior because
you're supposed to check the *size* of the object before working
on it.
2014-11-21 17:21:34 +01:00
Vicent Marti
92e0b67930 buffer: Do not put anything if len is 0 2014-11-21 17:21:33 +01:00
Carlos Martín Nieto
deadc43e1d Merge pull request #2720 from ravindp/master
Fix for memory leak issue in indexer.c, that surfaces on windows
2014-11-21 15:21:00 +01:00
Vicent Marti
e015665142 odb: git_odb_object contents are never NULL
This is a contract that we made in the library and that we need to uphold. The
contents of a blob can never be NULL because several parts of the library (including
the filter and attributes code) expect `git_blob_rawcontent` to always return a
valid pointer.
2014-11-21 14:09:53 +01:00
Vicent Marti
fc6ac074ee Merge pull request #2713 from libgit2/jamill/push_fetch_first
Update message for error during push
2014-11-20 13:13:46 +01:00
Vicent Marti
fd10b110de Merge pull request #2717 from libgit2/cmn/remote-ls
Clarify the git_remote_ls() documentation
2014-11-20 13:12:49 +01:00
Carlos Martín Nieto
1ca61bdcb9 fetch: clear the connection data on close
When we fetch twice with the same remote object, we did not properly
clear the connection flags, so we would leak state from the last
connection.

This can cause the second fetch with the same remote object to fail if
using a HTTP URL where the server redirects to HTTPS, as the second
fetch would see `use_ssl` set and think the initial connection wanted to
downgrade the connection.
2014-11-19 20:57:15 +01:00
Ravindra Patel
7561f98d6d Fix for memory leak issue in indexer.c, that surfaces on windows 2014-11-19 14:54:30 -05:00
Carlos Martín Nieto
699dfcc3bc remote: clarify which list of references _ls() returns
Make it clear that this is not the ls-remote command but a way to access
the data we have and how long it's kept around.
2014-11-19 15:49:02 +01:00
Edward Thomson
45301cca30 Merge pull request #2608 from libgit2/cmn/remote-push
Provide a convenience function `git_remote_push()`
2014-11-18 11:44:59 -05:00
Edward Thomson
8b5b814e55 Merge pull request #2671 from swisspol/remote_create_fix
Fixed active_refspecs field not initialized on new git_remote objects
2014-11-17 20:10:58 -05:00
Edward Thomson
7f1b73b7c8 Merge pull request #2693 from libgit2/cmn/push-refspec-refactor
push: use the common refspec parser
2014-11-17 17:03:55 -05:00
Edward Thomson
a4221ccb09 Merge pull request #2699 from swisspol/fix_warnings
Fixed a couple Clang warnings
2014-11-17 16:36:54 -05:00
Jameson Miller
a03f6caf5c Update message for error during push
When attempting to update a reference on a remote during push, and the
reference on the remote refers to a commit that does not exist locally,
then we should report a more clear error message.
2014-11-17 16:30:31 -05:00
Pierre-Olivier Latour
d3cd7da51f Fixed active_refspecs field not initialized on new git_remote objects
When creating a new remote, contrary to loading one from disk,
active_refspecs was not populated. This means that if using the new
remote to push, git_push_update_tips() will be a no-op since it
checks the refspecs passed during the push against the base ones
i.e. active_refspecs. And therefore the local refs won't be created
or updated after the push operation.
2014-11-17 22:46:22 +09:00
Carlos Martín Nieto
5915d7001b branch: consider an empty upstream remote config as not found 2014-11-17 14:28:22 +01:00
Ungureanu Marius
d6ecc31140 Plug possible leak in the openssl locks 2014-11-17 14:03:15 +01:00
Pierre-Olivier Latour
692c040843 Fixed a couple Clang warnings 2014-11-10 08:18:48 +09:00
Carlos Martín Nieto
aad638f3a1 push: use the common refspec parser
There is one well-known and well-tested parser which we should use,
instead of implementing parsing a second time.

The common parser is also augmented to copy the LHS into the RHS if the
latter is empty.

The expressions test had to change a bit, as we now catch a bad RHS of a
refspec locally.
2014-11-09 16:07:43 +01:00
Carlos Martín Nieto
64e3e6d43a remote: use configured push refspecs if none are given
If the user does not pass any refspecs to push, try to use those
configured via the configuration or via add_push().
2014-11-09 00:01:58 +01:00
Carlos Martín Nieto
3149547b5a remote: introduce git_remote_push()
This function, similar in style to git_remote_fetch(), performs all the
steps required for a push, with a similar interface.

The remote callbacks struct has learnt about the push callbacks, letting
us set the callbacks a single time instead of setting some in the remote
and some in the push operation.
2014-11-09 00:01:58 +01:00
Carlos Martín Nieto
799e22ea0c Rename git_threads_ to git_libgit2_
This describes their purpose better, as we now initialize ssl and some
other global stuff in there. Calling the init function is not something
which has been optional for a while now.
2014-11-08 23:46:39 +01:00
Pierre-Olivier Latour
e284c451b0 Changed GIT_REMOTE_DOWNLOAD_TAGS_ALL to behave like git 1.9.0 2014-11-09 07:27:30 +09:00
Edward Thomson
02bc523304 Merge pull request #2698 from libgit2/cmn/fetchhead-refactor
Refactor fetchhead
2014-11-08 17:05:13 -05:00
Edward Thomson
bc8c4a8aeb Merge pull request #2695 from libgit2/cmn/remote-lookup
remote: rename _load() to _lookup()
2014-11-08 16:55:23 -05:00
Edward Thomson
e3bd48a793 Merge pull request #2696 from libgit2/cmn/empty-objects
odb: hardcode the empty blob and tree
2014-11-08 16:52:43 -05:00
Carlos Martín Nieto
2c9b9c8bb4 remote: refactor the reference-update decision
This is an ugly chunk of code, so let's put it into its own function.
2014-11-08 21:02:19 +01:00
Carlos Martín Nieto
e1ac010148 odb: hardcode the empty blob and tree
git hardocodes these as objects which exist regardless of whether they
are in the odb and uses them in the shell interface as a way of
expressing the lack of a blob or tree for one side of e.g. a diff.

In the library we use each language's natural way of declaring a lack of
value which makes a workaround like this unnecessary. Since git uses it,
it does however mean each shell application would need to perform this
check themselves.

This makes it common work across a range of applications and an issue
with compatibility with git, which fits right into what the library aims
to provide.

Thus we introduce the hard-coded empty blob and tree in the odb
frontend. These hard-coded objects are checked for before going to the
backends, but after the cache check, which means the second time they're
used, they will be treated as normal cached objects instead of creating
new ones.
2014-11-08 20:53:38 +01:00
Carlos Martín Nieto
64fdd86d0e remote: don't check for upstream on an anonymous remote
If the remote is anonymous, then we cannot check for any configuration,
as there is no name. Check for this before we try to use the name, which
may be a NULL pointer.

This fixes #2697.
2014-11-08 20:21:14 +01:00
Carlos Martín Nieto
e235db0212 remote: use git_branch_upstream_remote()
This reduces the clutter somewhat and lets us see what we're asking
about the reference.
2014-11-08 20:09:11 +01:00
Carlos Martín Nieto
82374d9825 branch: add getter for the upstream remote name
This gets the value from branch.<foo>.remote.
2014-11-08 20:00:17 +01:00
Carlos Martín Nieto
209425ce26 remote: rename _load() to _lookup()
This brings it in line with the rest of the lookup functions.
2014-11-08 13:28:27 +01:00
Ungureanu Marius
6818208569 git_status_file now takes an exact path
This function has one output but can match multiple files, which can be
unexpected for the user, which would usually path the exact path of the
file he wants the status of.
2014-11-07 21:34:54 +02:00
Carlos Martín Nieto
62a617dc68 iterator: submodules are determined by an index or tree
We cannot know from looking at .gitmodules whether a directory is a
submodule or not. We need the index or tree we are comparing against to
tell us. Otherwise we have to assume the entry in .gitmodules is stale
or otherwise invalid.

Thus we pass the index of the repository into the workdir iterator, even
if we do not want to compare against it. This follows what git does,
which even for `git diff <tree>`, it will consider staged submodules as
such.
2014-11-07 08:33:27 +01:00
Edward Thomson
2d24816b46 checkout_index: Remove stage 0 when checking out conflicts 2014-11-06 18:50:10 -05:00
Edward Thomson
9f664347ff checkout_index: remove conflicts when checking out new files 2014-11-06 18:49:57 -05:00
Edward Thomson
64dc248577 Merge pull request #2598 from libgit2/cmn/stacked-ignore
ignore: don't leak rules into higher directores
2014-11-06 10:38:25 -05:00
Edward Thomson
7bb639911b Merge pull request #2676 from libgit2/cmn/threading
Threading and crypto libraries
2014-11-06 10:25:23 -05:00
Edward Thomson
f890a84fe0 Merge pull request #2682 from libgit2/cmn/fetch-tags-refspec
remote: check for the validity of the refspec when updating FETCH_HEAD
2014-11-06 10:19:22 -05:00
Carlos Martín Nieto
6069042fcb ignore: don't leak rules into higher directories
A rule "src" in src/.gitignore must only match subdirectories of
src/. The current code does not include this context in the match rule
and would thus consider this rule to match the top-level src/ directory
instead of the intended src/src/.

Keep track fo the context in which the rule was defined so we can
perform a prefix match.
2014-11-06 10:10:26 +01:00
Edward Thomson
b4e5432ff0 Merge pull request #2688 from libgit2/cmn/ignore-file-trailing-cr
ignore: consider files with a CR in their names
2014-11-05 10:47:19 -05:00
Carlos Martín Nieto
5c54e2162a ignore: consider files with a CR in their names
We currently consider CR to start the end of the line, but that means
that we miss cases with CR CR LF which can be used with git to match
files whose names have CR at the end of their names.

The fix from the patch comes from Russell's comment in the issue.

This fixes #2536.
2014-11-05 16:22:01 +01:00
Edward Thomson
cce27d8242 git_remote_rename: propogate GIT_ENOTFOUND 2014-11-03 14:10:31 -05:00
Edward Thomson
de0c4555da Merge pull request #2679 from jfultz/missing-include
Make config reading continue after hitting a missing include file.
2014-11-03 11:32:47 -05:00
Carlos Martín Nieto
6d20006f7e remote: check the relevance of the refspec when updating FETCH_HEAD
Before trying to rtransform using the given refspec to figure out what
the name of the upstream branch is on the remote, we must make sure that
the target of the refspec applies to the current branch's upstream.
2014-11-03 15:12:32 +01:00
Edward Thomson
0a62918188 Merge pull request #2661 from swisspol/2656
Changed context_lines and interhunk_lines to uint32_t to match struct s_xdemitconf
2014-11-03 15:10:14 +01:00
Edward Thomson
4bb8708730 Merge pull request #2683 from libgit2/cmn/remote-unify
remote: unify the creation code
2014-11-03 15:01:41 +01:00
Edward Thomson
873eb899e4 Merge pull request #2680 from libgit2/cmn/invalid-cert-return
netops: return GIT_ECERTIFICATE when it fails the basic tests
2014-11-03 14:57:39 +01:00
Edward Thomson
0fab748e91 Merge pull request #2685 from libgit2/cmn/mmap-readable
Fix segmentation fault observed on OpenBSD/sparc64
2014-11-03 14:52:34 +01:00
Stefan Sperling
aad0bd6bc7 Fix segmentation fault observed on OpenBSD/sparc64
A non-readable mapping of a file causes an access violation in
the pack tests. Always use PROT_READ to work around this.
2014-11-03 13:49:04 +01:00
Jacques Germishuys
bc48bcdcb3 Make the Visual Studio compiler happy 2014-11-03 14:23:13 +02:00
John Fultz
ebc13b2b7c Clean up issues include.path issues found during code review.
* Error-handling is cleaned up to only let a file-not-found error
  through, not other sorts of errors.  And when a file-not-found
  error happens, we clean up the error.
* Test now checks that file-not-found introduces no error.  And
  other minor cleanups.
2014-11-02 19:16:49 -06:00
Carlos Martín Nieto
a68e217f5c remote: unify the creation code
The create function with default refspec is the same as the one with a
custom refspec, but it has the default refspec, so we can create the one
on top of the other.
2014-11-02 21:58:39 +01:00
Carlos Martín Nieto
22fbb2656e netops: return GIT_ECERTIFICATE when it fails the basic tests
When we first ask OpenSSL to verify the certfiicate itself (rather
than the HTTPS specifics), we should also return
GIT_ECERTIFICATE. Otherwise, the caller would consider this as a failed
operation rather than a failed validation and not call the user's own
validation.
2014-11-02 16:12:10 +01:00
John Fultz
727ae380a5 Make config reading continue after hitting a missing include file.
For example, if you have

[include]
path = foo

and foo didn't exist, git_config_open_ondisk() would just give up
on the rest of the file.  Now it ignores the unresolved include
without error and continues reading the rest of the file.
2014-11-01 11:21:45 -05:00
Carlos Martín Nieto
fe6b51ae40 ssl: separate locking init from general init
Extract the lock-setting functions into their own, as we cannot assume
that it's ok for us to set this unconditionally.
2014-11-01 10:58:55 +01:00
Carlos Martín Nieto
e083657771 ssl: clear the OpenSSL locking function
We're freeing the memory which holds the locks so we must make sure that
the locking function doesn't try to use it.
2014-11-01 10:47:22 +01:00
Pierre-Olivier Latour
64bcf567c3 Fixed potential crash with uninitialized variables 2014-10-27 09:19:07 -07:00
Pierre-Olivier Latour
ea66215d87 Removed some useless variable assignments 2014-10-27 09:19:07 -07:00
Pierre-Olivier Latour
d88766c4e1 Changed context_lines and interhunk_lines to uint32_t to match struct s_xdemitconf 2014-10-27 09:17:01 -07:00
Carlos Martín Nieto
177a29d832 Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2 2014-10-27 10:39:45 +01:00
Sven Strickroth
334a0696f9 Minor cleanup: Use defined no_check_cert_flags instead of C&P them again
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-10-26 23:23:08 -04:00
Edward Thomson
979645a719 rebase: updates based on PR comments 2014-10-26 22:59:50 -04:00
Edward Thomson
18b00406c6 s/git_merge_head/git_annotated_commit
Rename git_merge_head to git_annotated_commit, as it becomes used
in more operations than just merge.
2014-10-26 22:59:48 -04:00
Edward Thomson
796b03bd49 rebase: clean up some warnings and memory leaks 2014-10-26 22:59:46 -04:00
Edward Thomson
e69737d760 rebase: oid member of operation should be const 2014-10-26 22:59:43 -04:00
Edward Thomson
ed2c06a6a1 git_rebase: iterators for operations 2014-10-26 22:59:41 -04:00
Edward Thomson
f152f8ac0c rebase: preload all operations 2014-10-26 22:59:38 -04:00
Edward Thomson
b6b636a7fa rebase: init/open a git_rebase object 2014-10-26 22:59:36 -04:00
Edward Thomson
18b439b9be git_rebase_next: provide info about the operation 2014-10-26 22:59:34 -04:00
Edward Thomson
5ae9d296e3 git_rebase_finish: rewrite notes when finishing rebase 2014-10-26 22:59:32 -04:00
Edward Thomson
bad4937ea5 Introduce git_note_author, git_note_committer 2014-10-26 22:59:29 -04:00
Edward Thomson
a612a25fa6 git_rebase_commit: write HEAD's reflog appropriately 2014-10-26 22:59:27 -04:00
Edward Thomson
517644cce4 Introduce git_rebase_finish to complete a rebase 2014-10-26 22:59:25 -04:00
Edward Thomson
93a7004cc2 git_rebase_commit: drop already-picked commits
Already cherry-picked commits should not be re-included.  If all changes
included in a commit exist in the upstream, then we should error with
GIT_EAPPLIED.
2014-10-26 22:59:21 -04:00
Edward Thomson
a35a9890b0 Introduce git_rebase_commit
Commit the current patch of a rebase process.
2014-10-26 22:59:19 -04:00
Edward Thomson
443d5674fe git_rebase_next: write conflicts nicely during rebase 2014-10-26 22:59:16 -04:00
Edward Thomson
950a709159 Introduce git_rebase_next
`git_rebase_next` will apply the next patch (or cherry-pick)
operation, leaving the results checked out in the index / working
directory so that consumers can resolve any conflicts, as appropriate.
2014-10-26 22:59:14 -04:00
Edward Thomson
4fe84d624b Introduce git_rebase_abort
Abort an in-progress rebase and move the working directory and
repository back to the ORIG_HEAD state.
2014-10-26 22:59:12 -04:00
Edward Thomson
daf395b795 git_reset: const the git_signature arg 2014-10-26 22:59:10 -04:00
Edward Thomson
867a36f3a6 Introduce git_rebase to set up a rebase session
Introduce `git_rebase` to set up a rebase session that can
then be continued.  Immediately, only merge-type rebase is
supported.
2014-10-26 22:59:08 -04:00
Edward Thomson
5b0c63061b Remove unused warning on non-win32 2014-10-26 22:38:45 -04:00
Edward Thomson
5a7cd1bcc0 iterator: free paths when skipping them 2014-10-26 22:28:00 -04:00
Edward Thomson
8c8ca7309b mwindow: clean up pack map at shutdown 2014-10-26 22:27:56 -04:00
Edward Thomson
50aae0007b global: clean up openssl_locks on shutdown 2014-10-26 22:27:52 -04:00
Edward Thomson
bc42479aaa Cleanup memory leak in ssh transport 2014-10-26 22:27:46 -04:00
Edward Thomson
cdd71711ce Clean up some memory leaks 2014-10-26 22:27:44 -04:00
Edward Thomson
369b021733 Clean up various compiler warnings 2014-10-26 22:13:40 -04:00
Edward Thomson
d09458f3e9 Merge pull request #2638 from libgit2/cmn/config-refresh-remove
config: remove the refresh function and backend field
2014-10-24 16:52:39 -07:00
Edward Thomson
725cd5f29d Merge pull request #2646 from libgit2/cmn/remote-rename
remote: accept a repo and name for renaming
2014-10-24 16:44:07 -07:00
Edward Thomson
b8041215cf Merge pull request #2649 from swisspol/2630
Fixed memory leak in git_tag_delete()
2014-10-24 14:02:53 -07:00
Edward Thomson
cdfd2b62b7 Merge pull request #2645 from libgit2/cmn/common-crypto
[RFC] Use CommonCrypto for hashing
2014-10-24 08:27:38 -07:00
Pierre-Olivier Latour
1ad15540e4 Fixed memory leak in git_tag_delete() 2014-10-24 08:23:14 -07:00
Carlos Martín Nieto
46c8f7f845 remote: accept a repo and name for renaming
Remote objects are not meant to be changed from under the user. We did
this in rename, but only the name and left the refspecs, such that a
save would save the wrong refspecs (and a fetch and anything else would
use the wrong refspecs).

Instead, let's simply take a name and not change any loaded remote from
under the user.
2014-10-24 16:25:59 +02:00
Carlos Martín Nieto
0862f617da remote: delete git_remote_supported_url()
This function does not in fact tell us anything, as almost anything with
a colon in it is a valid rsync-style SSH path; it can not tell us that
we do not support ftp or afp or similar as those are still valid SSH
paths and we do support that.
2014-10-24 13:40:42 +02:00
Carlos Martín Nieto
d9c0dbb042 hash: use CommonCrypto on OSX for SHA-1
OSX has its own cryptographic library, let's make use of it instead of
calling out to OpenSSL.
2014-10-24 13:31:18 +02:00
Carlos Martín Nieto
55cb499972 config: remove the refresh function and backend field
We have been refreshing on read and write for a while now, so
git_config_refresh() is at best a no-op, and might just end up wasting
cycles.
2014-10-23 19:05:02 +02:00
Carlos Martín Nieto
4bb6ffb6bb Merge pull request #2622 from libgit2/refresh-config-snapshot
Refresh git configuration before looking for the tracking branch redux.
2014-10-23 18:58:39 +02:00
Edward Thomson
d676af43da Merge pull request #2625 from libgit2/cmn/ssl-tls
ssl: dump the SSL ciphers in favour of TLS
2014-10-23 08:27:13 -07:00
Carlos Martín Nieto
f0f9737094 ssl: dump the SSL ciphers in favour of TLS
All versions of SSL are considered deprecated now, so let's ask OpenSSl
to only use TLSv1. We still ask it to load those ciphers for
compatibility with servers which want to use an older hello but will use
TLS for encryption.

For good measure we also disable compression, which can be exploitable,
if the OpenSSL version supports it.
2014-10-23 15:56:29 +02:00
Alan Rogers
ad5adacb1d Patch from @carlosmn to refresh the parent config before snapshotting. 2014-10-23 15:21:30 +11:00
Edward Thomson
12f32d9193 Remote paths: canonicalize UNC paths on Win32
Git for Windows will handle UNC paths only when in forward-slash
format, eg "//server/path".  When given a UNC path as a remote,
rewrite standard format ("\\server\path") into this ridiculous
format.
2014-10-22 17:49:53 -04:00
Carlos Martín Nieto
bb0757d56c tree-cache: correct the entry_count calculation
The entry_count field is the amount of index entries covered by a
particular cache entry, that is how many files are there (recursively)
under a particular directory.

The current code that attemps to do this is severely defincient and is
trying to count the amount of children, which always comes up to zero.

We don't even need to recount, since we have the information during the
cache creation. We can take that number and keep it, as we only ever
invalidate or replace.
2014-10-22 21:25:08 +02:00
Edward Thomson
e0383fa35f Merge pull request #2609 from linquize/describe-opts
Handle describe options better
2014-10-13 16:59:56 -04:00
Edward Thomson
c6e2621052 Merge pull request #2615 from ethomson/mount_points
Mount points
2014-10-13 16:52:44 -04:00
Edward Thomson
6a26488f8b Don't copy buffer in checkout unless needed 2014-10-13 13:36:20 -04:00
Jacques Germishuys
5e2cf2ca2c Ensure filters (i.e. CRLF) are applied when checking out conflict content 2014-10-13 13:36:18 -04:00
Edward Thomson
969b6a4710 is_empty_dir (wi32): cope with empty mount points
FindFirstFile will fail with INVALID_HANDLE_VALUE if there are no
children to the given path, which can happen if the given path is a
file (and obviously has no children) or if the given path is an empty
mount point.  (Most directories have at least directory entries '.'
and '..', but ridiculously another volume mounted in another drive
letter's path space do not, and thus have nothing to enumerate.)

If FindFirstFile fails, check if this is a directory-like thing
(a mount point).
2014-10-13 10:58:05 -04:00
Edward Thomson
8d45b4691c p_lstat win32: don't canonicalize volume mounts
A reparse point that is an IO_REPARSE_TAG_MOUNT_POINT could be
a junction or an actual filesystem mount point.  (Who knew?)
If it's the latter, its reparse point will report the actual
volume information \??\Volume{GUID}\ and we should not attempt
to dereference that further, instead readlink should report
EINVAL since it's not a symlink / junction and its original
path was canonical.

Yes, really.
2014-10-13 10:58:03 -04:00
Sven Strickroth
cf1013a888 There is no "z" size specifier on MSVC
See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx and https://stackoverflow.com/questions/6655410/why-doesnt-zd-printf-format-work-in-vs2010

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-10-13 16:32:26 +02:00
Linquize
59186d9b15 describe: Initialize options for git_describe_format() if null 2014-10-11 07:52:47 +08:00
Linquize
0494a7c9a9 describe: Do not crash if pass null option to git_describe_commit() 2014-10-11 07:52:47 +08:00
Russell Belfer
85fe63bc58 Don't use cl_git_pass for POSIX functions
If there is a failure then cl_git_pass tries to get the libgit2
error, but p_... functions don't set that.

Also - trailing whitespace cleanup.
2014-10-10 15:17:27 -07:00
Russell Belfer
babbff347c Move un-namespaced constant to internal header
FLAG_BITS only seems to be used internally
2014-10-10 15:17:05 -07:00
Carlos Martín Nieto
7465e87399 index: fill the tree cache on write-tree
An obvious place to fill the tree cache is on write-tree, as we're
guaranteed to be able to fill in the whole tree cache.

The way this commit does this is not the most efficient, as we read the
root tree from the odb instead of filling in the cache as we go along,
but it fills the cache such that successive operations (and persisting
the index to disk) will be able to take advantage of the cache, and it
reuses the code we already have for filling the cache.

Filling in the cache as we create the trees would require some
reallocation of the children vector, which is currently not possible
with out pool implementation. A different data structure would likely
allow us to perform this operation at a later date.
2014-10-10 19:43:42 +02:00
Carlos Martín Nieto
795d8e9328 index: make sure to write cached subtrees if parent is invalidated
If e.g. the root tree is invalidated, we still want to write out
its children, since those may still have valid cache entries.
2014-10-10 19:43:42 +02:00
Carlos Martín Nieto
c2f8b21593 index: write out the tree cache extension
Keeping the cache around after read-tree is only one part of the
optimisation opportunities. In order to share the cache between program
instances, we need to write the TREE extension to the index.

Do so, taking the opportunity to rename 'entries' to 'entry_count' to
match the name given in the format description. The included test is
rather trivial, but works as a sanity check.
2014-10-10 19:43:42 +02:00
Carlos Martín Nieto
46bb006730 tree-cache: remove the parent pointer
This wasn't used. We invalidate based on the full path, so we always go
down the tree, never up.
2014-10-10 19:37:48 +02:00
Carlos Martín Nieto
6843cebe17 index: fill the tree cache when reading from a tree
When reading from a tree, we know what every tree is going to look like,
so we can fill in the tree cache completely, making use of the index for
modification of trees a lot quicker.
2014-10-10 19:35:19 +02:00
Carlos Martín Nieto
19c88310cb tree-cache: move to use a pool allocator
This simplifies freeing the entries quite a bit; though there aren't
that many failure paths right now, introducing filling the cache from a
tree will introduce more. This makes sure not to leak memory on errors.
2014-10-10 19:35:18 +02:00
Carlos Martín Nieto
d091a9dbde tree-cache: extract the allocation 2014-10-10 19:35:18 +02:00
Edward Thomson
a6ed1fcbe1 Merge pull request #2593 from libgit2/cmn/remote-delete-name
remote: accept a repository and remote name for deletion
2014-10-10 12:21:28 -04:00
Carlos Martín Nieto
bab92a8dcf Merge pull request #2575 from cirosantilli/factor-struct-typedef
[factor] Join typedef and struct definitions in single file.
2014-10-10 18:06:36 +02:00
Carlos Martín Nieto
4c0c001529 Merge pull request #2498 from linquize/read-large-file
Can read large file larger than 2GB on Win64
2014-10-10 17:58:35 +02:00
Carlos Martín Nieto
33ca356598 Merge pull request #2556 from sbc100/fix_warnings
Fix warnings in thread-utils.h when building without -DTHREADSAFE=ON
2014-10-10 17:52:31 +02:00
Carlos Martín Nieto
2139c9b76c Merge pull request #2542 from linquize/fetch-head
Do not error out when fetching from second remote
2014-10-10 17:50:28 +02:00
Carlos Martín Nieto
9b36537de4 Merge pull request #2588 from swansontec/ssl-cert-path2
Add support for setting the SSL CA location
2014-10-10 17:42:52 +02:00
Carlos Martín Nieto
0625638f06 Merge pull request #2499 from csware/hard-reset-checkout-callbacks
Allow to propagate checkout callbacks to git HARD reset
2014-10-10 17:40:53 +02:00