Commit Graph

5330 Commits

Author SHA1 Message Date
Carlos Martín Nieto
2b92283221 Merge pull request #3127 from libgit2/cmn/remote-fixups
Tackle remote API issues from bindings
2015-05-28 16:09:17 +02:00
Edward Thomson
9b3e41f72b index_add_all: remove conflicts when no wd file
If there exists a conflict in the index, but no file in the working
directory, this implies that the user wants to accept the resolution
by removing the file.  Thus, remove the conflict entry from the
index, instead of trying to add a (nonexistent) file.
2015-05-28 09:47:51 -04:00
Edward Thomson
10549a2df1 Introduce GIT_DIFF_FLAG_EXISTS
Mark the `old_file` and `new_file` sides of a delta with a new bit,
`GIT_DIFF_FLAG_EXISTS`, that introduces that a particular side of
the delta exists in the diff.

This is useful for indicating whether a working directory item exists
or not, in the presence of a conflict.  Diff users may have previously
used DELETED to determine this information.
2015-05-28 09:47:47 -04:00
Edward Thomson
253a05f76b diff: prettify maybe_modified a little 2015-05-28 09:47:35 -04:00
Edward Thomson
9f545b9d71 introduce git_index_entry_is_conflict
It's not always obvious the mapping between stage level and
conflict-ness.  More importantly, this can lead otherwise sane
people to write constructs like `if (!git_index_entry_stage(entry))`,
which (while technically correct) is unreadable.

Provide a nice method to help avoid such messy thinking.
2015-05-28 09:47:31 -04:00
Edward Thomson
191e97a02b diff conflicts: don't include incorrect ID
Since a diff entry only concerns a single entry, zero the information
for the index side of a conflict.  (The index entry would otherwise
erroneously include the lowest-stage index entry - generally the
ancestor of a conflict.)

Test that during status, the index side of the conflict is empty.
2015-05-28 09:44:18 -04:00
Edward Thomson
7877146fc2 diff: for conflicts w/o workdir, blank nitem side
Make sure that we provide a blanked nitem side when the item does not
exist in the working directory.
2015-05-28 09:44:06 -04:00
Edward Thomson
7c94801400 diff/status: introduce conflicts
When diffing against an index, return a new `GIT_DELTA_CONFLICTED`
delta type for items that are conflicted.  For a single file path,
only one delta will be produced (despite the fact that there are
multiple entries in the index).

Index iterators now have the (optional) ability to return conflicts
in the index.  Prior to this change, they would be omitted, and callers
(like diff) would omit conflicted index entries entirely.
2015-05-28 09:44:02 -04:00
Edward Thomson
d67f270e58 index: validate mode of new conflicts 2015-05-28 09:43:57 -04:00
Edward Thomson
3ab5a65967 index: remove error message in non-error remove
If `git_index_remove_bypath` does no work, and returns an OK error
code, it should not set an error message.
2015-05-28 09:43:53 -04:00
Edward Thomson
ecd60a56eb conflicts: when adding conflicts, remove staged
When adding a conflict for some path, remove the staged entry.
Otherwise, an illegal index (with both stage 0 and high-stage
entries) would result.
2015-05-28 09:43:49 -04:00
Edward Thomson
1b6c26db97 diff: wrap the iterator functions
Wrap the iterator current / advance functions so that we can extend
them, but also handle GIT_ITEROVER cases in the iterator funcs
instead of the callers.
2015-05-28 09:43:45 -04:00
Edward Thomson
aa3af01db0 index iterator: optionally include conflicts 2015-05-28 09:43:41 -04:00
Carlos Martín Nieto
9566ce430f remote: call the update_tips callback for opportunisitc updates
These are updates, same as the rest, we should call this callback. As we
are using the callback, let's make sure to skip unnecessary updates.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
c6e942fb3d remote: validate refspecs before adding to config
When we moved from acting on the instance to acting on the
configuration, we dropped the validation of the passed refspec, which
can lead to writing an invalid refspec to the configuration. Bring that
validation back.
2015-05-28 15:32:20 +02:00
Carlos Martín Nieto
ae5b93629c remote: remove fetch parameter from create_anonymous
An anonymous remote is not configured and cannot therefore have
configured refspecs. Remove the parameter which adds this from the
constructor.
2015-05-28 15:32:20 +02:00
Michał Górny
2629fc874d cred: Check for null values when getting key from memory
The public key field is optional and as such can take NULL. Account for
that and do not call strlen() on NULL values. Also assert() for non-NULL
values of username & private key.
2015-05-27 20:36:53 +02:00
Michał Górny
f7142b5e4a cred: Declare GIT_CREDTYPE_SSH_MEMORY unconditionally
Declare GIT_CREDTYPE_SSH_MEMORY to have consistent API independently of
whether libgit2 was built with or without in-memory key passing support.
Or rather, to have it at all since build-time definitions are not stored
in headers.
2015-05-27 20:36:53 +02:00
David Calavera
08e6b875c1 Return an error when ssh memory credentials are not supported.
To not modify the external api.
2015-05-27 20:36:53 +02:00
David Calavera
7a8b85032f Add support to read ssh keys from memory. 2015-05-27 20:36:53 +02:00
Colomban Wendling
1ecbcd8e51 Fix ident replacement to match Git behavior
Git inserts a space after the SHA1 (as of 2.1.4 at least), so do the
same.
2015-05-26 19:56:06 +02:00
Carlos Martín Nieto
c11daac9de Merge pull request #3151 from ethomson/thinpack
Thin packs: don't
2015-05-22 22:12:40 +02:00
Edward Thomson
e2dd3735a5 indexer: avoid loading already existent bases
When thickening a pack, avoid loading already loaded bases and
trying to insert them all over again.
2015-05-22 15:27:52 -04:00
Edward Thomson
38c10ecd99 indexer: don't look for the index we're creating
When creating an index, know that we do not have an index for
our own packfile, preventing some unnecessary file opens and
error reporting.
2015-05-22 15:27:48 -04:00
Edward Thomson
2540487fcd Merge pull request #3108 from libgit2/cmn/ssl-no-want
openssl: don't try to handle WANT_READ or WANT_WRITE
2015-05-22 12:53:52 -04:00
Carlos Martín Nieto
5014fe95f5 branch: error out if we cannot find the remote
When we look for which remote corresponds to a remote-tracking branch,
we look in the refspecs to see which ones matches. If none do, we should
abort. We currently ignore the error message from this operation, so
let's not do that anymore.

As part of the test we're writing, let's test for the expected behaviour
if we cannot find a refspec which tells us what the remote-tracking
branch for a remote would look like.
2015-05-22 12:31:39 +02:00
Carlos Martín Nieto
7cd4ba1b17 refspec: make sure matching refspecs have src, dst and input strings
When we find out that we're dealing with a matching refspec, we set the
flag and return immediately. This leaves the strings as NULL, which
breaks the contract.

Assign these pointers to a string with the correct values.
2015-05-22 12:11:42 +02:00
Carlos Martín Nieto
a6ea108b56 Merge branch 'sni' 2015-05-21 14:04:46 +02:00
Cristian Oneț
987045c74a Call the openssl API to be able to work with SNI servers. 2015-05-21 14:03:44 +02:00
Carlos Martín Nieto
6675aaba88 Merge pull request #3146 from ethomson/add_untracked_files
index_add_all: include untracked files in new subdirs
2015-05-21 04:58:16 +02:00
Edward Thomson
cbfeecf33f git_index_add_all: don't recurse ignored dirs
No need to get reports about individual ignored files, having a
single ignored directory delta is enough.
2015-05-20 20:14:31 -04:00
Edward Thomson
fa9a969d80 index_add_all: include untracked files in new subdirs 2015-05-20 20:05:55 -04:00
Carlos Martín Nieto
2c57114f11 ignore: clear the error when matching a pattern negation
When we discover that we want to keep a negative rule, make sure to
clear the error variable, as it we otherwise return whatever was left by
the previous loop iteration.
2015-05-20 21:49:02 +02:00
Carlos Martín Nieto
1396c38178 errors: add GIT_EEOF to indicate early EOF
This can be used by tools to show mesages about failing to communicate
with the server. The error message in this case will often contain the
server's error message, as far as it managed to send anything.
2015-05-20 15:08:39 +02:00
Carlos Martín Nieto
e3435673b8 ssh: read from stderr if stdout is empty
When we fail to read from stdout, it's typically because the URL was
wrong and the server process has sent some output over its stderr
output.

Read that output and set the error message to whatever we read from it.
2015-05-20 15:08:39 +02:00
Edward Thomson
acc573cba3 Merge pull request #3109 from libgit2/cmn/index-use-diff
Use a diff for iteration in index_update_all and index_add_all
2015-05-19 14:12:40 -04:00
Carlos Martín Nieto
edef91ee25 fileops: set an error on write error for file copy
We set an error if we get an error when reading, but we don't bother
setting an error message for write failing. This causes a cryptic error
to be shown to the user when the target filesystem is full.
2015-05-17 15:48:33 +02:00
Carlos Martín Nieto
70f7484d2a remote: get rid of the run-time refspec setters
These were left over from the culling as it's not clear which use-cases
might benefit from this. It is not clear that we want to support any
use-case which depends on changing the remote's idea of the base
refspecs rather than passing in different per-operation refspec list, so
remove these functions.
2015-05-17 15:45:37 +02:00
Carlos Martín Nieto
54738368ec fileops: set an error message if we fail to link a file
Now that `git_path_direach` lets us specify an error message to report,
set an appropriate error message while linking.
2015-05-15 12:18:05 +02:00
Carlos Martín Nieto
8a4d77f990 path: don't let direach overwrite the callback's error message
This function deals with functions doing IO which means the amount of
errors that can happen is quit large. It does not help if it always
ovewrites the underlying error message with a less understandable
version of "something went wrong".

Instead, only use this generic message if there was no error set by the
callback.
2015-05-15 12:15:45 +02:00
Marius Ungureanu
7e9a240e0a Make "Early EOF" message start with lowercase 2015-05-14 21:39:52 +03:00
Carlos Martín Nieto
542a7de0cd local: plug a leak in the progress reporting 2015-05-14 17:26:09 +02:00
Carlos Martín Nieto
2b2dfe80f0 index: include TYPECHANGE in the diff
Without this option, we would not be able to catch exec bit changes.
2015-05-14 15:23:12 +02:00
Carlos Martín Nieto
0a78a52ed9 index: make add_all to act on a diff
Instead of going through each entry we have and re-adding, which may not
even be correct for certain crlf options and has bad performance, use
the function which performs a diff against the worktree and try to add
and remove files from that list.
2015-05-14 15:23:12 +02:00
Carlos Martín Nieto
197307f6b1 index: refactor diff-based update_all to match other applies
Refactor so we look like the code we're replacing, which should also
allow us to more easily inplement add-all.
2015-05-14 15:23:12 +02:00
Carlos Martín Nieto
713e11e0b1 index: use a diff to perform update_all
We currently iterate over all the entries and re-add them to the
index. While this provides correctness, it is wasteful as we try to
re-insert files which have not changed.

Instead, take a diff between the index and the worktree and only re-add
those which we already know have changed.
2015-05-14 15:23:12 +02:00
Carlos Martín Nieto
254ff3e929 push: fix the update constructor
There was a copypasta error and the source and destination IDs were
reversed.
2015-05-14 10:34:42 +02:00
Carlos Martín Nieto
16d742ebdb Merge pull request #3119 from ethomson/ignore
Attributes: don't match files for folders
2015-05-13 21:43:58 +02:00
Edward Thomson
cd430bc786 Merge pull request #3103 from libgit2/cmn/local-push-message
Use the packbuilder in local push
2015-05-13 14:26:20 -04:00
Edward Thomson
2ec73fa9ed Merge pull request #3102 from libgit2/cmn/pack-objects-report
Show progress during packing for the local transport
2015-05-13 14:26:06 -04:00
Edward Thomson
a6f2ceaf48 Merge pull request #3118 from libgit2/cmn/stream-size
odb: make the writestream's size a git_off_t
2015-05-13 12:11:55 -04:00
Carlos Martín Nieto
3e529e9d2d Fix a few leaks
The interesting one is the notification macro, which was returning
directly on a soft-abort instead of going through the cleanup.
2015-05-13 16:40:18 +02:00
Carlos Martín Nieto
3c337a5d37 packbuilder: report progress during deltification
This is useful to send to the client while we're performing the work.

The reporting function has a force parameter which makes sure that we
do send out the message of 100% completed, even if this comes before the
next udpate window.
2015-05-13 15:52:13 +02:00
Carlos Martín Nieto
8cec2b8ae9 local: send the packbuilder progress via the sideband
Set a callback for the packbuilder so we can send the sideband messages
to the caller, formatting them as git would.
2015-05-13 15:52:13 +02:00
Edward Thomson
a3ff28e9d1 Merge pull request #3120 from libgit2/cmn/backends-prio
odb: reverse the default backend priorities
2015-05-13 09:02:00 -04:00
Carlos Martín Nieto
4a5b781a48 local: use the packbuilder to push
Instead of copying each object individually, as we'd been doing, use the
packbuilder which should be faster and give us some feedback.

While performing this change, we can hook up the packbuilder's writing
to the push progress so the caller knows how far along we are.
2015-05-13 10:56:37 +02:00
Carlos Martín Nieto
81c0fb08bd local: add clarification for non-bare push restriction 2015-05-13 10:50:38 +02:00
Carlos Martín Nieto
b0d7f329a8 odb: reverse the default backend priorities
We currently first look in the loose object dir and then in the packs
for objects. When performing operations on recent history this has a
higher likelihood of hitting, but when we deal with operations which
look further back into the past, we start spending a large amount of
time getting ENOTENT from `access`.

Reversing the priorities means that long-running operations can get to
their objects faster, as we can look at the index data we have in memory
(or rather mapped) to figure out whether we have an object, which is
faster than going out to the filesystem.

The packed backend already implements an optimistic read algorithm by
first looking at the packs we know about and only going out to disk to
referesh if the object is not found which means that in the case where
we do have the object (which will be in the majority for anything that
traverses the graph) we can avoid going to to disk entirely to determine
whether an object exists.

Operations which look at recent history may take a slight impact, but
these would be operations which look a lot less at object and thus take
less time regardless.
2015-05-13 10:23:19 +02:00
Carlos Martín Nieto
3251972e1f push: free the update list 2015-05-13 09:46:57 +02:00
Carlos Martín Nieto
3e20154a9d remote: simplify anonymous creation
We're down to simply having it be a call to create_internal() so let's
simply do that. The rest of the code is just a distraction.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
a4b6452a6a remote: remove git_remote_save()
It has now become a no-op, so remove the function and all references to
it.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
7725499072 remote: remove live changing of refspecs
The base refspecs changing can be a cause of confusion as to what is the
current base refspec set and complicate saving the remote's
configuration.

Change `git_remote_add_{fetch,push}()` to update the configuration
instead of an instance.

This finally makes `git_remote_save()` a no-op, it will be removed in a
later commit.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
35a8a8c546 remote: move the tagopt setting to the fetch options
This is another option which we should not be keeping in the remote, but
is specific to each particular operation.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
3eff2a5728 remote: move the update_fetchhead setting to the options
While this will rarely be different from the default, having it in the
remote adds yet another setting it has to keep around and can affect its
behaviour. Move it to the options.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
058b753ceb remote: move the transport ctor to the callbacks
Instead of having it set in a different place from every other callback,
put it the main structure. This removes some state from the remote and
makes it behave more like clone, where the constructors are passed via
the options.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
6fb373a0e8 remote: add prune option to fetch
Add a prune setting in the fetch options to allow to fall back to the
configuration (the default) or to set it on or off.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
22261344de remote: remove url and pushurl from the save logic
As a first step in removing the repository-saving logic, don't allow
chaning the url or push url from a remote object, but change the
configuration on the configuration immediately.
2015-05-13 09:46:36 +02:00
Carlos Martín Nieto
8f0104ecc5 Remove the callbacks struct from the remote
Having the setting be different from calling its actions was not a great
idea and made for the sake of the wrong convenience.

Instead of that, accept either fetch options, push options or the
callbacks when dealing with the remote. The fetch options are currently
only the callbacks, but more options will be moved from setters and
getters on the remote to the options.

This does mean passing the same struct along the different functions but
the typical use-case will only call git_remote_fetch() or
git_remote_push() and so won't notice much difference.
2015-05-13 09:46:35 +02:00
Carlos Martín Nieto
0525911442 push: remove own copy of callbacks
The push object knows which remote it's associated with, and therefore
does not need to keep its own copy of the callbacks stored in the
remote.

Remove the copy and simply access the callbacks struct within the
remote.
2015-05-13 09:46:35 +02:00
Carlos Martín Nieto
77b339f7b6 odb: make the writestream's size a git_off_t
Restricting files to size_t is a silly limitation. The loose backend
writes to a file directly, so there is no issue in using 63 bits for the
size.

We still assume that the header is going to fit in 64 bytes, which does
mean quite a bit smaller files due to the run-length encoding, but it's
still a much larger size than you would want Git to handle.
2015-05-13 09:34:20 +02:00
Edward Thomson
34593aaec0 attr: declare variable at top of block for msvc 2015-05-12 17:00:35 -04:00
Edward Thomson
90997e405d attr: less path mangling during attribute matching
When handling attr matching, simply compare the directory path where the
attribute file resides to the path being matched.  Skip over commonality
to allow us to compare the contents of the attribute file to the remainder
of the path.

This allows us to more easily compare the pattern directly to the path,
instead of trying to guess whether we want to compare the path's basename
or the full path based on whether the match was inside a containing
directory or not.

This also allows us to do fewer translations on the pattern (trying to
re-prefix it.)
2015-05-12 16:22:31 -04:00
Edward Thomson
9465bedb09 attr: don't mangle file path during attr matching
When determining whether some file matches an attr pattern, do
not try to truncate the path to pass to fnmatch.  When there is
no containing directory for an item (eg, from a .gitignore in the
root) this will cause us to truncate our path, which means that
we cannot do meaningful comparisons on it and we may have false
positives when trying to determine whether a given file is actually
a file or a folder (as we have lost the path's base information.)

This mangling was to allow fnmatch to compare a directory on disk to
the name of a directory, but it is unnecessary as our fnmatch accepts
FNM_LEADING_DIR.
2015-05-12 16:02:18 -04:00
Edward Thomson
30e629a073 attr: always return errors 2015-05-12 14:39:49 -04:00
Edward Thomson
ef6d072236 attr: don't match files for folders
When ignoring a path "foo/", ensure that this is actually a directory,
and not simply a file named "foo".
2015-05-12 14:36:52 -04:00
Carlos Martín Nieto
f85a9c2767 Merge pull request #3111 from whoisj/centralizing-buffer-sizes
Centralizing all IO buffer size values
2015-05-12 11:27:37 +02:00
Edward Thomson
4497287321 stash: propagate the error when writing a tree 2015-05-11 14:12:47 -04:00
Edward Thomson
4ea3eebf4b stash_apply: provide progress callbacks 2015-05-11 14:12:42 -04:00
Edward Thomson
19c80a6fd1 stash_apply: provide its own options structure 2015-05-11 14:12:39 -04:00
Edward Thomson
12149a20ef stash apply: default to at least GIT_CHECKOUT_SAFE 2015-05-11 14:12:31 -04:00
Edward Thomson
f78bb2afb3 stash: return GIT_EMERGECONFLICT on merge conflict 2015-05-11 14:12:27 -04:00
Edward Thomson
f0957589ee stash: refactor to use merge_iterators 2015-05-11 14:12:19 -04:00
Edward Thomson
90f8408dac stash: ensure a reflog has entries 2015-05-11 14:12:16 -04:00
Edward Thomson
d0dd3fcee7 stash apply: check out a tree, not piecewise 2015-05-11 14:12:12 -04:00
Edward Thomson
7f26b1b9cf stash: use git_commit_summary for a summary 2015-05-11 14:12:09 -04:00
Edward Thomson
35d3976151 index: introduce git_index_read_index 2015-05-11 14:12:05 -04:00
Edward Thomson
73dce1f688 checkout: allow baseline to be specified as index
Allow the baseline to be specified as an index, so that users
need not write their index to a tree just to checkout with that
as the baseline.
2015-05-11 14:12:01 -04:00
Edward Thomson
9ebb5a3ff3 merge: merge iterators 2015-05-11 14:11:56 -04:00
Pierre-Olivier Latour
bf8dd3f53d Added git_stash_apply() and git_stash_pop() APIs 2015-05-11 14:11:53 -04:00
J Wyman
7dd2253826 centralizing all IO buffer size values 2015-05-11 10:32:08 -07:00
Carlos Martín Nieto
77bffc2cd6 openssl: don't try to handle WANT_READ or WANT_WRITE
We use a blocking socket and set the mode to AUTO_RETRY which means that
`SSL_write` and `SSL_read` will only return once the read or write has
been completed. We therefore don't need to handle partial writes or
re-try read due to a regenotiation.

While here, consider that a zero also indicates an error condition.
2015-05-09 13:21:39 +02:00
Carlos Martín Nieto
9cdd657887 Merge pull request #3104 from whoisj/optimal-buffer-size
Adjusting stream buffer size to 64KB
2015-05-09 13:11:46 +02:00
J Wyman
7eb7e03db8 Adjusting stream buffer size to 64KB
64K is optimal buffer size per https://technet.microsoft.com/en-us/library/cc938632.aspx
2015-05-07 08:50:12 -07:00
Carlos Martín Nieto
b162d97a4f config: plug a couple of leaks 2015-05-05 09:47:16 +02:00
Carlos Martín Nieto
074d323f73 Merge pull request #3079 from ethomson/config
Configuration changes for handling multiple of the same sections
2015-05-04 15:23:40 +02:00
Edward Thomson
63c0cc65bc config: cleanup some now-unused variables 2015-05-04 07:41:38 -05:00
Edward Thomson
9c26de0fd1 config: lock the file for write before reading
When writing a configuration file, we want to take a lock on the
new file (eg, `config.lock`) before opening the configuration file
(`config`) for reading so that we can prevent somebody from changing
the contents underneath us.
2015-05-04 07:41:37 -05:00
Edward Thomson
2a950c945a config: write existing lines as-is when rewriting
When updating a configuration file, we want to copy the old data
from the file to preserve comments and funny whitespace, instead
of writing it in some "canonical" format.  Thus, we keep a
pointer to the start of the line and the line length to preserve
these things we don't care to rewrite.
2015-05-04 07:41:35 -05:00
Edward Thomson
bf99390eef config: examine whole file when writing
Previously we would try to be clever when writing the configuration
file and try to stop parsing (and simply copy the rest of the old
file) when we either found the value we were trying to write,
or when we left the section that value was in, the assumption being
that there was no more work to do.

Regrettably, you can have another section with the same name later
in the file, and we must cope with that gracefully, thus we read the
whole file in order to write a new file.

Now, writing a file looks even more than reading.  Pull the config
parsing out into its own function that can be used by both reading
and writing the configuration.
2015-05-04 07:41:33 -05:00
Edward Thomson
4beab1f8bb checkout: break case-changes into delete/add
When checking out with a case-insensitive working directory, we
want to change the case of items in the working directory to
reflect changes that occured in the checkout target.  Diff now
has an option to break case-changing renames into delete/add.
2015-05-04 07:18:28 -05:00