Commit Graph

1291 Commits

Author SHA1 Message Date
Jacques Germishuys
940da54861 Added test for stashing files in ignored directories 2014-09-24 13:24:06 +02:00
Sven Strickroth
e6e834a129 Provide host name to certificate_check_cb
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-09-22 16:27:52 +02:00
Vicent Marti
14556cbff7 Merge pull request #2567 from cirosantilli/factor-41
Factor 40 and 41 constants from source.
2014-09-17 17:13:25 +02:00
Vicent Marti
276d9ea3a6 Merge pull request #2571 from libgit2/vmg/walk-up-path
Fix `git_path_walk_up` to work with non-rooted paths
2014-09-17 15:39:57 +02:00
Vicent Marti
4592b62ee5 Merge pull request #2572 from cirosantilli/factor-void
Replace void casts with GIT_UNUSED.
2014-09-17 15:26:48 +02:00
Ciro Santilli
c5cf8cade3 Replace void casts with GIT_UNUSED. 2014-09-17 15:19:08 +02:00
The rugged tests are fragile
4cb7c4a4c7 attr: Add an extra test for files under a subfolder 2014-09-17 15:08:16 +02:00
The rugged tests are fragile
bbb988a519 path: Fix git_path_walk_up to work with non-rooted paths 2014-09-17 15:00:12 +02:00
Vicent Marti
1312f87b68 Merge pull request #2464 from libgit2/cmn/host-cert-info
Provide a callback for certificate validation
2014-09-17 14:56:39 +02:00
Carlos Martín Nieto
25abbc27a7 Clean up some leaks in the test suite 2014-09-17 03:19:40 +02:00
Carlos Martín Nieto
52e09724fd ssh: skip the localhost cert check earlier
Skip it before we attempt to clone, as we would exit with -1 on systems
which do not have sshd running.
2014-09-16 17:13:58 +02:00
Carlos Martín Nieto
1e0aa105fa ssh: expose both hashes
The user may have the data hashed as MD5 or SHA-1, so we should provide
both types for consumption.
2014-09-16 17:02:33 +02:00
Carlos Martín Nieto
286369a81f ssh: provide our own types for host key lengths
Instead of using the libssh2 defines, provide our own, which eases usage
as we do not need to check whether libgit2 was built with libssh2 or not.
2014-09-16 17:02:32 +02:00
Carlos Martín Nieto
0782fc43f8 net: use only structs to pass information about cert
Instead of spreading the data in function arguments, some of which
aren't used for ssh and having a struct only for ssh, use a struct for
both, using a common parent to pass to the callback.
2014-09-16 17:02:32 +02:00
Carlos Martín Nieto
0fef38999a Merge remote-tracking branch 'upstream/master' into cmn/host-cert-info 2014-09-16 17:02:28 +02:00
Carlos Martín Nieto
bf8756d6a2 ssh: add test for host key
Test that the certificate check callback gets the right fingerprint from
the host we're connecting to.
2014-09-16 17:01:32 +02:00
Carlos Martín Nieto
08545d366b winhttp: credential check on successful connect
On successful connection, still ask the user whether they accept the server's certificate, indicating that WinHTTP would let it though.
2014-09-16 17:01:31 +02:00
Carlos Martín Nieto
23ca0ad5eb Bring certificate check back to the normal return code
Returning 0 lets the certificate check succeed. An error code is bubbled
up to the user.
2014-09-16 17:01:31 +02:00
Carlos Martín Nieto
2f5864c50c ssh: do ssh cert info before asking for credentials
We know the host's key as soon as we connect, so we should perform the
check as soon as we can, before we bother with the user's credentials.
2014-09-16 17:01:31 +02:00
Carlos Martín Nieto
17491f6e56 transport: always call the certificate check callback
We should let the user decide whether to cancel the connection or not
regardless of whether our checks have decided that the certificate is
fine. We provide our own assessment to the callback to let the user fall
back to our checks if they so desire.
2014-09-16 17:01:30 +02:00
Carlos Martín Nieto
85acc56262 remote: add tests for the certificate callback 2014-09-16 17:01:30 +02:00
Carlos Martín Nieto
9b9405865e Provide a callback for certificate validation
If the certificate validation fails (or always in the case of ssh),
let the user decide whether to allow the connection.

The data structure passed to the user is the native certificate
information from the underlying implementation, namely OpenSSL or
WinHTTP.
2014-09-16 17:01:30 +02:00
Vicent Marti
903a76168e Merge pull request #2561 from jacquesg/merge-skip
No files merged may result in bogus merge conflict error
2014-09-16 13:22:40 +02:00
Ciro Santilli
3b2cb2c91e Factor 40 and 41 constants from source. 2014-09-16 13:07:04 +02:00
Russell Belfer
1fbeb2f04c Fix attribute lookup in index for bare repos
When using a bare repo with an index, libgit2 attempts to read
files from the index.  It caches those files based on the path
to the file, specifically the path to the directory that contains
the file.

If there is no working directory, we use `git_path_dirname_r` to
get the path to the containing directory.  However, for the
`.gitattributes` file in the root of the repository, this ends up
normalizing the containing path to `"."` instead of the empty
string and the lookup the `.gitattributes` data fails.

This adds a test of attribute lookups on bare repos and also
fixes the problem by simply rewriting `"."` to be `""`.
2014-09-15 21:59:23 -07:00
Vicent Marti
a7fcac13a5 Merge pull request #2554 from linquize/fetch-head-tag
When auto follow tags, FETCH_HEAD should list only newly followed tags
2014-09-15 20:26:12 +02:00
Carlos Martín Nieto
fdea219a86 global: free the error message when exiting a thread
When we free the global state at thread termination, we must also free
the error message in order not to leak the string once per thread.
2014-09-14 00:39:07 +02:00
Jacques Germishuys
493c340cef Added test case to illustrate bogus conflicts detected if no files were merged, and untracked files exist in the workdir. 2014-09-12 22:01:22 +02:00
Carlos Martín Nieto
76e3c43fb9 signature: don't allow empty emails
A signature is made up of a non-empty name and a non-empty email so
let's validate that. This also brings us more in line with git, which
also rejects ident with an empty email.
2014-09-10 18:14:46 +02:00
Vicent Marti
31e752b654 Merge pull request #2511 from libgit2/cmn/remote-default-restrict
Restrict which refs can be the default branch
2014-09-09 12:52:36 +02:00
Linquize
d908351a6c When auto follow tags, FETCH_HEAD should list only newly followed tags 2014-09-06 00:26:56 +08:00
Vicent Marti
89e05e2ab1 Merge pull request #2543 from libgit2/cmn/known-transports
Clean up transport lookup
2014-09-03 12:50:44 +02:00
Jameson Miller
bc737620dd Introduce option to use relative paths for repository work directory
Teach git_repository_init_ext to use relative paths for the gitlink
to the work directory. This is used when creating a sub repository
where the sub repository resides in the parent repository's
.git directory.
2014-09-02 21:07:26 -04:00
Edward Thomson
0ee9f31c3b Introduce git_path_make_relative 2014-09-02 21:07:23 -04:00
Vicent Marti
0ac9f9a0c7 Merge pull request #2545 from linquize/no-ssh
Skip SSH clone tests if libgit2 not built with GIT_SSH defined
2014-09-03 00:13:23 +02:00
Linquize
8deea5899d Add network::fetchlocal multi remotes test 2014-09-02 21:28:21 +08:00
Carlos Martín Nieto
15c30b72e1 clone: handle overly restrictive refspecs
When the fetch refspec does not include the remote's default branch, it
indicates an error in user expectations or programmer error. Error out
in that case.

This lets us get rid of the dummy refspec which can never work as its
zeroed out. In the cases where we did not find a default branch, we set
HEAD detached immediately, which lets us refactor the "normal" path,
removing `found_branch`.
2014-09-02 13:23:54 +02:00
Carlos Martín Nieto
e128a1af6e clone: correct handling of an unborn HEAD
If the remote does not advertise HEAD, then it is unborn and we cannot
checkout that branch. Handle it the same way as an empty repo.
2014-09-02 13:10:19 +02:00
Carlos Martín Nieto
538f908175 remote: add test for single-branch clone
When cloning, we may be asking for a particular branch or subset of
branches. Make sure we test for that.
2014-09-02 12:47:12 +02:00
Carlos Martín Nieto
f2ffab618a remote: add tests for remote-branch edge cases
Add tests for the case when there are no branches on the remote and when
HEAD is detached but has the id of a non-branch. In both of these cases,
we should return ENOTFOUND.
2014-09-02 12:47:12 +02:00
Linquize
fe3b67891b Skip SSH clone tests if libgit2 not built with GIT_SSH defined 2014-09-01 19:18:20 +08:00
Carlos Martín Nieto
05ac70514f remote: test for supported URLs in a single place
Instead of using ifdefs to run the tests, use them to set when we expect
to support a particular scheme and always have the tests in the code.
2014-08-31 21:53:42 +02:00
Carlos Martín Nieto
ba67c07522 remote: get rid of git_remote_valid_url()
It does the same as git_remote_supported_url() but has a name which
implies we'd check the URL for correctness while we're simply looking at
the scheme and looking it up in our lists.

While here, fix up the tests so we check all the combination of what's
supported.
2014-08-31 21:50:28 +02:00
Linquize
aff7001825 MSVC does not support zero size array 2014-08-31 22:43:53 +08:00
Vicent Marti
46a13f3247 Merge pull request #2481 from libgit2/cmn/oidarray
merge: expose multiple merge bases
2014-08-29 18:19:56 +02:00
Carlos Martín Nieto
94412b009e remote: assert what we want to happen when ther is no default branch
Assert what we already do, so as to notice changes.
2014-08-29 15:28:10 +02:00
Vicent Marti
d99c8ca178 Merge pull request #2539 from libgit2/cmn/ahead-behind-order
Fix ahead-behind results
2014-08-28 16:33:53 +02:00
Carlos Martín Nieto
e07aebb4e2 Fix ahead-behind tests
The logic was reversed. I have checked manually each pair with git and
adjusted the expectation to what git status prints.
2014-08-28 13:34:42 +02:00
Vicent Marti
69db893427 Merge pull request #2538 from libgit2/ntk/propagate_url_parsing_error
winhttp: Prevent swallowing of url parsing error
2014-08-27 19:19:55 +02:00
Vicent Marti
1485c6833a Merge pull request #2490 from csware/ssh-wintunnel
Allow to override default ssh transport_cb - in order to allow third party ssh transports
2014-08-27 18:02:10 +02:00
nulltoken
f0c53d21a4 winhttp: Prevent swallowing of url parsing error 2014-08-27 17:37:29 +02:00
Sven Strickroth
0e5bb61992 Added some tests
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-08-27 17:27:07 +02:00
Carlos Martín Nieto
c13b68442f Adjust clone tests to USERNAME cred type 2014-08-27 15:25:46 +02:00
Carlos Martín Nieto
6a0d2b43ee Merge remote-tracking branch 'upstream/master' into cmn/ssh-retry 2014-08-27 15:09:07 +02:00
Vicent Marti
00e9ae5ab4 Merge pull request #2508 from libgit2/rb/fix-ignore-slash-star
Fix bugs with negative ignores inside an ignored parent directory
2014-08-26 17:48:20 +02:00
Vicent Marti
5af52c628b Merge pull request #2531 from libgit2/rb/mkdir-allow-parent-failures
Allow mkdir helper to skip parent errors
2014-08-25 21:04:09 +02:00
Vicent Marti
2c1de697e0 Merge pull request #2527 from jacquesg/refspec-crash
Check if the refspec matches before transforming
2014-08-25 18:18:06 +02:00
Russell Belfer
668ae2ddf8 Allow mkdir helper to skip parent errors
Our mkdir helper was failing is a parent directory was not
accessible even if the child directory could be created.
This changes the helper to keep trying child directories
even when the parent is unwritable.
2014-08-22 10:05:09 -07:00
Vicent Marti
d28b2b7a5f Merge pull request #2528 from libgit2/vmg/tostr_s
Export `git_oid_tostr_s` instead of `_allocfmt`
2014-08-18 15:18:59 +02:00
Vicent Marti
43ebca8d7b Revert "test: Remove symlinks from the source tree"
This reverts commit 0dc54e1494.
2014-08-18 15:18:47 +02:00
Vicent Marti
0dc54e1494 test: Remove symlinks from the source tree
We don't really use this at all, and it breaks packaging in Windows.
2014-08-18 12:47:16 +02:00
Vicent Marti
4ca0b566ca oid: Export git_oid_tostr_s instead of _allocfmt
The old `allocfmt` is of no use to callers, as they are not able to free
the returned buffer. Export a new API that returns a static string that
doesn't need to be freed.
2014-08-18 12:41:06 +02:00
Jacques Germishuys
4e53c28096 Check if the refspec matches before transforming 2014-08-17 14:55:06 +02:00
Jacques Germishuys
dc8adda4f1 git_remote_ls() should return an error if the transport is not available 2014-08-15 22:56:15 +02:00
Edward Thomson
e003f83a58 Introduce git_buf_decode_base64
Decode base64-encoded text into a git_buf
2014-08-15 11:12:42 -04:00
Edward Thomson
adcdeb36b0 online::clone::credentials support default credentials 2014-08-15 11:12:42 -04:00
Edward Thomson
f96e7e6c94 Free references during push validation 2014-08-15 11:12:42 -04:00
Edward Thomson
0f29e96793 Remove the refs/notes/commits that we push in test
The online::push::notes test pushes a note but leaves it hanging
around for other tests to stumble across when they're validating
that they're seeing the refs they expect to see.  Clean it up on
exit.
2014-08-14 10:18:21 -05:00
Edward Thomson
aea676336c Don't run the ssh clone tests against http remotes 2014-08-14 10:18:20 -05:00
Vicent Marti
fb48a51c63 Merge pull request #2469 from ethomson/transport2
Custom transport: minor cleanups
2014-08-14 17:01:02 +02:00
Edward Thomson
c180c06586 Custom transport: minor cleanups
* Move the transport registration mechanisms into a new header under
   'sys/' because this is advanced stuff.
 * Remove the 'priority' argument from the registration as it adds
   unnecessary complexity.  (Since transports cannot decline to operate,
   only the highest priority transport is ever executed.)  Users who
   require per-priority transports can implement that in their custom
   transport themselves.
 * Simplify registration further by taking a scheme (eg "http") instead
   of a prefix (eg "http://").
2014-08-14 08:52:20 -05:00
Edward Thomson
c8402334d2 Don't include the unreadable tests on win32 2014-08-13 17:23:07 -04:00
Carlos Martín Nieto
9dac1f9579 config: a multiline var can start immediately
In the check for multiline, we traverse the backslashes from the end
backwards and int the end assert that we haven't gone past the beginning
of the line. We make sure of this in the loop condition, but we also
check in the return value.

However, for certain configurations, a line in a multiline variable
might be empty to aid formatting. In that case, 'end' == 'start', since
we ended up looking at the first char which made it a multiline.

There is no need for the (end > start) check in the return, since the
loop guarantees we won't go further back than the first char in the
line, and we do accept the first char to be the final backslash.

This fixes #2483.
2014-08-09 11:06:49 +02:00
Rob Rix
bbe13802b7 Demonstrate a trailing slash failure.
`git help ignore` has this to say about trailing slashes:

> If the pattern ends with a slash, it is removed for the purpose of
> the following description, but it would only find a match with a
> directory. In other words, foo/ will match a directory foo and
> paths underneath it, but will not match a regular file or a
> symbolic link foo (this is consistent with the way how pathspec
> works in general in Git).

Sure enough, having manually performed the same steps as this test,
`git status` tells us the following:

	# On branch master
	#
	# Initial commit
	#
	# Changes to be committed:
	#   (use "git rm --cached <file>..." to unstage)
	#
	#	new file:   force.txt
	#
	# Untracked files:
	#   (use "git add <file>..." to include in what will be committed)
	#
	#	../.gitignore
	#	child1/
	#	child2/

i.e. neither child1 nor child2 is ignored.
2014-08-08 15:19:16 -07:00
Carlos Martín Nieto
aa5cdf63bf status: failing test with slash-star
When writing 'bin/*' in the rules, this means we ignore very file inside
bin/ individually, but do not ignore the directory itself. Thus the
status listing should list both files under bin/, one untracked and one
ignored.
2014-08-08 14:53:22 -07:00
Russell Belfer
f18234fad6 Don't report status on named pipes
Git skips entries in directories that are not S_ISDIR, S_ISREG, or
S_ISLNK, so let's make libgit2 do the same thing.
2014-08-08 13:17:50 -07:00
Vicent Marti
8f759ac0b3 Merge pull request #2471 from jacquesg/compatibility-cleanup
Compatibility/Portability cleanup
2014-08-07 18:00:57 +02:00
Jacques Germishuys
c7dd0a56bf Use p_snprintf also in tests 2014-08-05 20:51:59 +02:00
Sven Strickroth
b8add6c42e Allow to propagate checkout callbacks to git HARD reset
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-08-03 16:29:51 +02:00
Carlos Martín Nieto
7db0e6ee48 merge: expose multiple merge bases
We always calculate multiple merge bases, but up to now we had only
exposed the "best" merge base.

Introduce git_oidarray which analogously to git_strarray lets us return
multiple ids.
2014-07-27 17:17:22 +02:00
Vicent Marti
243db06ce3 Merge pull request #2484 from libgit2/fix-git-status-list-new-unreadable-folder
Fix git status list new unreadable folder
2014-07-23 07:57:20 +02:00
Edward Thomson
0ba4dca526 git_cherry_pick -> git_cherrypick 2014-07-22 10:40:23 -04:00
Alan Rogers
7d0ab0fae0 Merge remote-tracking branch 'origin/master' into fix-git-status-list-new-unreadable-folder 2014-07-22 15:08:24 +10:00
Vicent Marti
ec813d83e7 Merge pull request #2476 from linquize/config-lf-eof
When adding new config section, handle config file not ending with LF
2014-07-16 13:07:17 -07:00
Vicent Marti
ed99e0b54f Merge pull request #2467 from ethomson/win_local_clone
Handle local file:/// paths on Windows
2014-07-16 13:00:15 -07:00
Linquize
693748694b Add unit test to test add section without lf at EOF 2014-07-16 21:54:53 +08:00
Edward Thomson
3d997dc255 Switch description and path reporting 2014-07-15 10:00:46 -04:00
Edward Thomson
529fd30d1f Handle local file:/// paths on Windows
Windows can't handle a path like `/c:/foo`; when turning file:///
URIs into local paths, we must strip the leading slash.
2014-07-11 18:46:00 -04:00
Vicent Marti
44cfb6f387 Merge pull request #2463 from libgit2/cmn/ssh-factory-for-paths
ssh: provide a factory function for setting ssh paths
2014-07-11 16:49:23 +02:00
Alan Rogers
4edd1a036b Merge remote-tracking branch 'origin/development' into fix-git-status-list-new-unreadable-folder 2014-07-10 19:17:34 -07:00
Carlos Martín Nieto
d4256ed554 ssh: provide a factory function for setting ssh paths
git allows you to set which paths to use for the git server programs
when connecting over ssh; and we want to provide something similar.

We do this by providing a factory function which can be set as the
remote's transport callback which will set the given paths upon
creation.
2014-07-07 14:51:51 +02:00
Carlos Martín Nieto
f5287fa6c3 refspec: support asterisks in the middle of a pattern
We used to assume a refspec would only have an asterisk in the middle of
their respective pattern. This has not been a valid assumption for some
time now with git.

Instead of assuming where the asterisk is going to be, change the logic
to treat each pattern as having two halves with a replacement bit in the
middle, where the asterisk is.
2014-07-04 18:00:20 +02:00
Vicent Marti
b0ed61f822 Merge pull request #2460 from libgit2/cmn/sched-yield
Move yield to the tests and enable for FreeBSD
2014-07-03 15:30:38 +02:00
Carlos Martín Nieto
905fb5929b Move yield to the tests and enable for FreeBSD
Move the definition of git_thread_yield() to the test which needs it and
add the correct definition for it for FreeBSD and derivatives.

Original patch adding FreeBSD and derivatives by @jacquesg.
2014-07-03 05:55:02 +02:00
Vicent Marti
193fe9cbbf Merge pull request #2459 from libgit2/cmn/http-url-path
netops: error out on url without a path
2014-07-03 02:41:10 +02:00
Carlos Martín Nieto
1380e7c6b1 netops: error out on url without a path
In order to connect to a remote server, we need to provide a path to the
repository we're interested in. Consider the lack of path in the url an
error.
2014-07-03 02:34:32 +02:00
Vicent Marti
c1bf2942fc Merge pull request #2455 from ethomson/equal_oid
Introduce `cl_assert_equal_oid`
2014-07-02 15:29:25 +02:00
Vicent Marti
4df4ebd7c7 Merge pull request #2453 from ethomson/checkout_index
git_checkout_index: checkout other indexes
2014-07-02 15:29:14 +02:00
Vicent Marti
b0ca1b18e2 Merge pull request #2452 from libgit2/cmn/clone-custom-repo
Provide a callback to customize the repository on clone
2014-07-02 15:29:05 +02:00
Carlos Martín Nieto
6812afaf38 clone: remote git_clone_into{,_local} from the public API
As git_clone now has callbacks to configure the details of the
repository and remote, remove the lower-level functions from the public
API, as they lack some of the logic from git_clone proper.
2014-07-02 07:05:00 +02:00
Edward Thomson
967f5a76b1 git_checkout_index: checkout other indexes
git_checkout_index can now check out other git_index's (that are not
necessarily the repository index).  This allows checkout_index to use
the repository's index for stat cache information instead of the index
data being checked out.  git_merge and friends now check out their
indexes directly instead of trying to blend it into the running index.
2014-07-01 17:32:15 -04:00
Edward Thomson
9879fee184 revwalk::simplify test should test
The revwalk::simplify test was not actually tested the values from
the revwalk against the expected.  (Further, the expected had two
IDs transposed.)
2014-07-01 14:40:16 -04:00
Edward Thomson
0cee70ebb7 Introduce cl_assert_equal_oid 2014-07-01 14:40:16 -04:00
Russell Belfer
5fa8cda981 Round up pool alloc sizes for alignment
To make sure that items returned from pool allocations are aligned
on nice boundaries, this rounds up all pool allocation sizes to a
multiple of 8.  This adds a small amount of overhead to each item.

The rounding up could be made optional with an extra parameter to
the pool initialization that turned on rounding only for pools
where item alignment actually matters, but I think for the extra
code and complexity that would be involved, that it makes sense
just to burn a little bit of extra memory and enable this all the
time.
2014-06-30 12:05:25 -07:00
Vicent Marti
dcdb8500e3 Merge pull request #2440 from phkelley/transports
Improvements to git_transport extensibility
2014-06-30 17:35:42 +02:00
Philip Kelley
1697cd6ff5 Improvements to git_transport extensibility
git_remote_set_transport now takes a transport factory rather than a transport
git_clone_options now allows the caller to specify a remote creation callback
2014-06-26 22:34:37 -04:00
Carlos Martín Nieto
e26b08d32c ssh: adjust clone and push test credentials to the split user+pass method
For urls where we do not specify a username, we must handle the case
where the ssh transport asks us for the username.

Test also that switching username fails.
2014-06-26 22:58:39 +02:00
Carlos Martín Nieto
ccb85c8fa1 ssh: make sure to ask for a username and use the same one
In order to know which authentication methods are supported/allowed by
the ssh server, we need to send a NONE auth request, which needs a
username associated with it.

Most ssh server implementations do not allow switching the username
between authentication attempts, which means we cannot use a dummy
username and then switch. There are two ways around this.

The first is to use a different connection, which an earlier commit
implements, but this increases how long it takes to get set up, and
without knowing the right username, we cannot guarantee that the
list we get in response is the right one.

The second is what's implemented here: if there is no username specified
in the url, ask for it first. We can then ask for the list of auth
methods and use the user's credentials in the same connection.
2014-06-26 22:58:39 +02:00
Carlos Martín Nieto
d7f962f408 ssh: request credentials again on authentication failure
Instead of completely giving up on the first failure, ask for
credentials as long as we fail to authenticate.
2014-06-26 22:58:38 +02:00
Edward Thomson
f4046267dc checkout::conflict tests: only test owner mode
The checkout::conflict type conflict tests were failing because
they were overly assertive about the resultant mode, testing
group & other bits, which failed miserably for people who had a
umask less restrictive than 022.  Only test the resultant owner bits.
2014-06-26 09:16:12 -04:00
Edward Thomson
d412165f94 Update text=auto / core.autocrlf=false behavior
Git for Windows 1.9.4 changed the behavior when the text=auto
attribute is specified and core.autocrlf=false.  Previous observed
behavior would *not* filter files when going into the working
directory, the new behavior *does* filter.  Update our behavior to match.
2014-06-24 13:46:32 -04:00
Carlos Martín Nieto
3ddd0d929d Merge remote-tracking branch 'upstream/cmn/mixed-eol-passthrough' 2014-06-24 17:55:15 +02:00
Carlos Martín Nieto
5e37874dd4 Merge remote-tracking branch 'upstream/cmn/treebuilder-perf' 2014-06-24 17:51:45 +02:00
Carlos Martín Nieto
5a76ad35aa crlf: pass-through mixed EOL buffers from LF->CRLF
When checking out files, we're performing conversion into the user's
native line endings, but we only want to do it for files which have
consistent line endings. Refuse to perform the conversion for mixed-EOL
files.

The CRLF->LF filter is left as-is, as that conversion is considered to be
normalization by git and should force a conversion of the line endings.
2014-06-23 22:27:12 +02:00
Carlos Martín Nieto
b3b66c5793 Share packs across repository instances
Opening the same repository multiple times will currently open the same
file multiple times, as well as map the same region of the file multiple
times. This is not necessary, as the packfile data is immutable.

Instead of opening and closing packfiles directly, introduce an
indirection and allocate packfiles globally. This does mean locking on
each packfile open, but we already use this lock for the global mwindow
list so it doesn't introduce a new contention point.
2014-06-23 21:50:36 +02:00
Carlos Martín Nieto
b529c5f96d ssh: propagate the error code from the auth callback
We need to be able to get a GIT_EUSER back through the outermost call.
2014-06-17 10:51:17 +02:00
Carlos Martín Nieto
22618906a5 ssh: detect authentication methods
Before calling the credentials callback, ask the sever which
authentication methods it supports and report that to the user, instead
of simply reporting everything that the transport supports.

In case of an error, we do fall back to listing all of them.
2014-06-17 10:51:17 +02:00
Carlos Martín Nieto
09561d33e4 test: remove assembla clone test
The assembla failure we were seeing referred to a private repository,
which is not what is there at the moment.

This reverts 1fd21b0342
2014-06-13 22:27:46 +02:00
Carlos Martín Nieto
3382d8b14f test: use read-only account
Don't write in plaintext the password of an account which has full
control over the repository. Instead use an account with read-only
access.
2014-06-13 22:24:43 +02:00
Carlos Martín Nieto
4d3f1f9740 treebuilder: use a map instead of vector to store the entries
Finding a filename in a vector means we need to resort it every time we
want to read from it, which includes every time we want to write to it
as well, as we want to find duplicate keys.

A hash-map fits what we want to do much more accurately, as we do not
care about sorting, but just the particular filename.

We still keep removed entries around, as the interface let you assume
they were going to be around until the treebuilder is cleared or freed,
but in this case that involves an append to a vector in the filter case,
which can now fail.

The only time we care about sorting is when we write out the tree, so
let's make that the only time we do any sorting.
2014-06-10 15:14:13 +02:00
Vicent Marti
ce5e6617b0 Merge pull request #2407 from libgit2/cmn/remote-rename-more
More remote rename fixes
2014-06-08 16:44:32 +02:00
Philip Kelley
fb5917679d Win32: Fix object::cache::threadmania test on x64 2014-06-07 12:51:48 -04:00
Philip Kelley
daf2a648b1 Win32: Fix diff::workdir::submodules test #2361 2014-06-07 12:18:56 -04:00
Philip Kelley
6d1b04383e Win32: Fix failing clone_mirror test 2014-06-07 12:18:24 -04:00
Carlos Martín Nieto
231f350d91 remote: don't free the remote on delete
This was a bad idea. Don't free except in the free function.
2014-06-06 22:55:34 +02:00
Carlos Martín Nieto
eb6aa791a7 remote: failing test for renaming with a symref 2014-06-06 22:36:41 +02:00
Carlos Martín Nieto
72bca13e5d remote: return problem refspecs instead of using a callback
There is no reason why we need to use a callback here. A string array
fits better with the usage, as this is not an event and we don't need
anything from the user.
2014-06-06 21:43:04 +02:00
Carlos Martín Nieto
fe3b9d0731 remote: failing test for rename
When there is a reference in the target namespace, we should overwrite
it. Instead it gets a different name under the current code.
2014-06-06 00:54:11 +02:00
Alan Rogers
dc49e1b5b3 Merge remote-tracking branch 'origin/development' into fix-git-status-list-new-unreadable-folder
Conflicts:
	include/git2/diff.h
2014-06-04 15:36:28 -07:00
Alan Rogers
a576a34257 Add another test for unreadable and not included. 2014-06-04 14:47:44 -07:00
Alan Rogers
79d5b5c916 Add GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED
and a (failing) test for it.
2014-06-03 17:42:52 -07:00
Russell Belfer
dfcba09e67 Merge pull request #2395 from libgit2/cmn/ref-iter-concurrent
Concurrent ref iterator access
2014-06-03 13:05:20 -07:00
Vicent Marti
bccb36ebf9 Merge pull request #2389 from arthurschreiber/arthur/set-error-when-no-remote-found
Remote: Set an error when a remote cannot be found.
2014-06-03 17:25:59 +02:00
Carlos Martín Nieto
69a1a6918c Plug a leak in the tests 2014-06-03 16:18:08 +02:00
Carlos Martín Nieto
4ee2543c5a refs: failing test for concurrent ref access
If we remove a reference while we're iterating through the packed refs,
the position in the iterator will be off.
2014-06-02 16:46:47 +02:00
Alan Rogers
523553f902 Fix the no permissions test. 2014-05-30 16:22:26 -07:00
Alan Rogers
59fcebaa89 Use 'X' for unreadable status. 2014-05-30 16:22:13 -07:00
Arthur Schreiber
d723dbed0c Remote: Set an error when a remote cannot be found.
Inside `git_remote_load`, the calls to `get_optional_config` use
`giterr_clear` to unset any errors that are set due to missing config
keys. If neither a fetch nor a push url config was found for a remote,
we should set an error again.
2014-05-30 19:26:49 +02:00
Edward Thomson
49837fd49f Ignore core.safecrlf=warn until we have a warn infrastructure 2014-05-30 11:30:53 -05:00
Arthur Schreiber
9d6c3d2853 Refs: Extend unicode test for branch creation.
This adds another assertion to ensure that the reference name inside
the git_reference struct returned by `git_branch_create` is returned as
precomposed if `core.precomposeunicode` is enabled.
2014-05-30 15:15:54 +02:00
Arthur Schreiber
1a90b1e3f1 Refs: Add a unicode test for git_branch_move.
This tests that decomposed branch names are correctly precomposed when
passed to `git_branch_move` and `core.precomposeunicode` is enabled.
2014-05-30 14:53:28 +02:00
Vicent Marti
31c551528b Merge pull request #2011 from libgit2/cmn/clone-local
Local clone
2014-05-29 14:50:57 +02:00
Carlos Martín Nieto
bc9f67fa85 clone: more explicit local tests
Assert the exact amount of links we expect. While there, check that a
plain git_clone() automatically chooses to link.
2014-05-29 10:06:48 +02:00
Carlos Martín Nieto
2614819cf3 clone: allow for linking in local clone
If requested, git_clone_local_into() will try to link the object files
instead of copying them.

This only works on non-Windows (since it doesn't have this) when both
are on the same filesystem (which are unix semantics).
2014-05-28 15:40:47 +02:00
Carlos Martín Nieto
94f742bac6 fileops: allow linking files when copying directory structures
When passed the LINK_FILES flag, the recursive copy will hardlink files
instead of copying them.
2014-05-28 15:40:22 +02:00
Carlos Martín Nieto
c1dbfcbb4a clone: add flag not to link 2014-05-28 15:40:22 +02:00
Carlos Martín Nieto
121b26738e clone: add flags to override whether to perform a local clone 2014-05-28 15:40:22 +02:00
Vicent Marti
5d91bea22a Merge pull request #2380 from libgit2/cmn/index-add-modes
index: check for valid filemodes on add
2014-05-28 13:55:57 +02:00
Vicent Marti
ab882e21b4 Merge pull request #2385 from karipe/development
Fix compile error on Visual Studio
2014-05-28 13:49:38 +02:00
Edward Thomson
eff531e103 Modify GIT_MERGE_CONFIG -> GIT_MERGE_PREFERENCE 2014-05-27 20:58:20 -05:00
Edward Thomson
a3622ba6cc Move GIT_MERGE_CONFIG_* to its own enum 2014-05-27 20:49:20 -05:00
Edward Thomson
d362093f9e Introduce GIT_MERGE_CONFIG_* for merge.ff settings
git_merge_analysis will now return GIT_MERGE_CONFIG_NO_FASTFORWARD
when merge.ff=false and GIT_MERGE_CONFIG_FASTFORWARD_ONLY when
merge.ff=true
2014-05-27 20:49:16 -05:00
Cha, Hojeong
3ac1ff42d7 Fix compile error on Visual Studio 2014-05-27 23:36:07 +09:00
Alan Rogers
c3252c11bf We do expect the foo path in the nopermissions test 2014-05-23 00:29:04 +10:00
Carlos Martín Nieto
052a2ffde4 index: check for valid filemodes on add 2014-05-22 16:01:02 +02:00
Alan Rogers
6580b11c2a Remove errant newline 2014-05-22 19:26:55 +10:00
Vicent Marti
a598264463 Merge pull request #2376 from libgit2/cmn/remote-symref
Add support for the symref extension
2014-05-22 02:28:42 +02:00
Vicent Marti
7ee233a920 Merge pull request #2375 from libgit2/rb/safecrlf-on-lf-platform
Make core.safecrlf not generate an error on LF-ending platforms
2014-05-22 02:27:33 +02:00
Alan Rogers
9532edc028 Simplify the no permission test. 2014-05-21 23:13:46 +10:00
Carlos Martín Nieto
d22db24fb7 remote: add api to guess the remote's default branch
If the remote supports the symref protocol extension, then we return
that, otherwise we guess with git's rules.
2014-05-21 12:12:32 +02:00
Carlos Martín Nieto
306475eb01 remote: expose the remote's symref mappings
Add a symref_target field to git_remote_head to expose the symref
mappings to the user.
2014-05-21 12:12:32 +02:00
Carlos Martín Nieto
430866d28c Fix a leak in the tests 2014-05-20 08:29:51 +02:00
Russell Belfer
16798d08cf Make core.safecrlf work on LF-ending platforms
If you enabled core.safecrlf on an LF-ending platform, we would
error even for files with all LFs.  We should only be warning on
irreversible mappings, I think.
2014-05-19 14:57:09 -07:00
Vicent Marti
124a45ead3 Merge pull request #2354 from libgit2/cmn/clone-into-mirror
Allow mirror-clone via `git_clone_into()`
2014-05-19 15:00:50 +02:00
Carlos Martín Nieto
b206724863 clone: add failing test for a mirror-clone with clone_into
Show a failure to perform a mirror-clone from a repository, both local
and remote.
2014-05-19 14:24:43 +02:00
Carlos Martín Nieto
49e369b29d message: don't assume the comment char
The comment char is configurable and we need to provide a way for the
user to specify which comment char they chose for their message.
2014-05-18 10:06:49 +02:00
Philip Kelley
d7a294633d Fix a bug in the pack::packbuilder suite 2014-05-17 16:58:09 -04:00
Vicent Marti
191ff93609 Merge pull request #2362 from libgit2/rb/update-4k-to-8k
Test and fix Git diff binary detection compatibility
2014-05-17 02:37:13 +02:00
Russell Belfer
8af4966db1 Git binary check compat tests
A variety of data patterns for diffs verified to match the
behavior of binary detection with Git on the command line.
2014-05-16 16:30:58 -07:00
Vicent Marti
228272ef58 Merge pull request #2313 from libgit2/cmn/remote-delete
Remote deletion
2014-05-16 11:56:37 +02:00
Carlos Martín Nieto
ec8a949a58 remote: remove remote-tracking branches on delete
When we delete a remote, we also need to go through its fetch refspecs
and remove the references they create locally.
2014-05-16 10:02:07 +02:00
Russell Belfer
8487e23797 Better search path sandboxing
There are a number of tests that modify the global or system
search paths during the tests.  This adds a helper function to
make it easier to restore those paths and makes sure that they
are getting restored in a manner that preserves test isolation.
2014-05-15 10:56:28 -07:00
Alan Rogers
dc4906f12a Skip unreadable files for now. 2014-05-15 17:40:28 +10:00
Alan Rogers
8d3a2d5fc5 Simplify the test. 2014-05-15 16:33:26 +10:00
Alan Rogers
2b5a99d8ff Add a test (failing) for a work tree status.
When thees is an unreadable folder, we should still be able
to enumerate status.
2014-05-14 17:02:07 +10:00
Vicent Marti
03fcef1889 Merge pull request #2328 from libgit2/rb/how-broken-can-ignores-be
Improve checks for ignore containment
2014-05-13 12:40:13 +02:00
Russell Belfer
df3419269b Merge pull request #2336 from libgit2/rb/unicode-branch-names
Pass unconverted Unicode path data when iconv doesn't like it
2014-05-12 10:51:56 -07:00
Russell Belfer
af567e8853 Merge pull request #2334 from libgit2/rb/fix-2333
Be more careful with user-supplied buffers
2014-05-12 10:44:13 -07:00
Russell Belfer
ce3b71d91b Don't scale diff stat when not needed 2014-05-12 10:28:45 -07:00
Russell Belfer
7bcced44b7 Merge pull request #2300 from libgit2/cmn/match-host-tests
Some improvements to the cert checking
2014-05-12 10:15:30 -07:00
Russell Belfer
d2c4d1c63d Merge pull request #2188 from libgit2/cmn/config-snapshot
Configuration snapshotting
2014-05-12 10:04:52 -07:00
Vicent Marti
e18d5e52e3 Merge pull request #2331 from libgit2/rb/dont-stop-diff-on-safecrlf
Add filter options and ALLOW_UNSAFE
2014-05-09 08:59:59 +02:00
Russell Belfer
bb45e39063 Disable threads::refdb::edit_while_iterate test
It seems that with the various recent changes to reference updating
and reflog writing, that the thread safety of refdb updates has
been reduced (either that or it was never thread safe and the
window for error has increased).  Either way, this test is now
sometimes segfaulting which is no good, so let's disable the test
for now.  We don't really make any public promises about thread
safety for this type of operation, so I think this is acceptable,
at least in the short term.
2014-05-08 15:01:07 -07:00
Russell Belfer
8a2ef218b9 Don't always test composed-insensitive lookups
Only on a filesystem that is composed/decomposed insensitive,
should be testing that a branch can be looked up by the opposite
form and still work correctly.
2014-05-08 14:48:27 -07:00
Russell Belfer
be20ac5a1d Allow cl_repo_get_bool to work with missing key
One of the test helpers provides a quick way for looking up a
boolean key.  But if the key way missing completely, the check
would actually raise an error.  Given the way we use this helper,
if the key is missing, this should just return false, I think.
2014-05-08 14:33:37 -07:00
Russell Belfer
43a0413524 Pass unconverted data when iconv doesn't like it
When using Iconv to convert unicode data and iconv doesn't like
the source data (because it thinks that it's not actual UTF-8),
instead of stopping the operation, just use the unconverted data.
This will generally do the right thing on the filesystem, since
that is the source of the non-UTF-8 path data anyhow.

This adds some tests for creating and looking up branches with
messy Unicode names.  Also, this takes the helper function that
was previously internal to `git_repository_init` and makes it
into `git_path_does_fs_decompose_unicode` which is a useful in
tests to understand what the expected results should be.
2014-05-08 13:52:46 -07:00
Russell Belfer
1e4976cb01 Be more careful with user-supplied buffers
This adds in missing calls to `git_buf_sanitize` and fixes a
number of places where `git_buf` APIs could inadvertently write
NUL terminator bytes into invalid buffers.  This also changes the
behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
and of `git_buf_shorten` to do nothing if it can.

Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
which was previously triggering a segfault.
2014-05-08 10:17:14 -07:00
Russell Belfer
5269008cf6 Add filter options and ALLOW_UNSAFE
Diff and status do not want core.safecrlf to actually raise an
error regardless of the setting, so this extends the filter API
with an additional options flags parameter and adds a flag so that
filters can be applied with GIT_FILTER_OPT_ALLOW_UNSAFE, indicating
that unsafe filter application should be downgraded from a failure
to a warning.
2014-05-06 16:01:49 -07:00
Russell Belfer
f554611a27 Improve checks for ignore containment
The diff code was using an "ignored_prefix" directory to track if
a parent directory was ignored that contained untracked files
alongside tracked files. Unfortunately, when negative ignore rules
were used for directories inside ignored parents, the wrong rules
were applied to untracked files inside the negatively ignored
child directories.

This commit moves the logic for ignore containment into the workdir
iterator (which is a better place for it), so the ignored-ness of
a directory is contained in the frame stack during traversal.  This
allows a child directory to override with a negative ignore and yet
still restore the ignored state of the parent when we traverse out
of the child.

Along with this, there are some problems with "directory only"
ignore rules on container directories.  Given "a/*" and "!a/b/c/"
(where the second rule is a directory rule but the first rule is
just a generic prefix rule), then the directory only constraint
was having "a/b/c/d/file" match the first rule and not the second.
This was fixed by having ignore directory-only rules test a rule
against the prefix of a file with LEADINGDIR enabled.

Lastly, spot checks for ignores using `git_ignore_path_is_ignored`
were tested from the top directory down to the bottom to deal with
the containment problem, but this is wrong. We have to test bottom
to top so that negative subdirectory rules will be checked before
parent ignore rules.

This does change the behavior of some existing tests, but it seems
only to bring us more in line with core Git, so I think those
changes are acceptable.
2014-05-06 12:41:26 -07:00
Carlos Martín Nieto
ee311907ee odb: ignore files in the objects dir
We assume that everything under GIT_DIR/objects/ is a directory. This is
not necessarily the case if some process left a stray file in there.

Check beforehand if we do have a directory and ignore the entry
otherwise.
2014-05-05 16:34:18 +02:00
Vicent Marti
272b462db7 Merge pull request #2308 from libgit2/rb/diff-update-index-stat-cache
Reduce excessive OID calculation for diff and stat
2014-05-02 09:50:15 -07:00
Russell Belfer
9862ef8ef8 Merge pull request #2310 from libgit2/cmn/commit-create-safe
commit: safer commit creation with reference update
2014-05-02 09:42:07 -07:00
Russell Belfer
99dfa47039 Some further sandboxing cleanups to tests
Trying to find other issues where tests may not clean up quite
properly when they are through...
2014-05-02 09:21:33 -07:00
Russell Belfer
0f603132bc Improve handling of fake home directory
There are a few tests that set up a fake home directory and a
fake GLOBAL search path so that we can test things in global
ignore or attribute or config files.  This cleans up that code to
work more robustly even if there is a test failure.  This also
fixes some valgrind warnings where scanning search paths for
separators could end up doing a little bit of sketchy data access
when coming to the end of search list.
2014-05-02 09:21:33 -07:00
Russell Belfer
bc91347b58 Fix remaining init_options inconsistencies
There were a couple of "init_opts()" functions a few more cases
of structure initialization that I somehow missed.
2014-05-02 09:21:33 -07:00
Russell Belfer
9c8ed49997 Remove trace / add git_diff_perfdata struct + api 2014-05-02 09:21:33 -07:00
Russell Belfer
7a2e56a3f6 Get rid of redundant git_diff_options_init fn
Since git_diff_init_options was introduced, remove this old fn.
2014-05-02 09:21:33 -07:00
Russell Belfer
b23b112dfe Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs.  This makes the
trace levels into a bitmask so that they can be selectively enabled
and adds a callback-level payload, plus a message-level payload.

This makes it easier for me to a GIT_TRACE_PERF callbacks that
are simply bypassed if the PERF level is not set.
2014-05-02 09:21:33 -07:00
Russell Belfer
225aab5d6a Don't use trace if GIT_TRACE not defined 2014-05-02 09:21:33 -07:00
Russell Belfer
cd424ad551 Add GIT_STATUS_OPT_UPDATE_INDEX and use trace API
This adds an option to refresh the stat cache while generating
status.  It also rips out the GIT_PERF stuff I had an makes use
of the trace API to keep statistics about what happens during diff.
2014-05-02 09:21:33 -07:00
Russell Belfer
94fb4aadc8 Add diff option to update index stat cache
When diff is scanning the working directory, if it finds a file
where it is not sure if the index entry matches the working dir,
it will recalculate the OID (which is pretty expensive).  This
adds a new flag to diff so that if the OID calculation finds that
the file actually has not changed (i.e. just the modified time was
altered or such), then it will refresh the stat cache in the index
so that future calls to diff will not have to check the oid again.
2014-05-02 09:21:33 -07:00
Russell Belfer
8ef4e11a76 Skip diff oid calc when size definitely changed
When we think the stat cache in the index seems valid and the size
or mode of a file has definitely changed, then don't bother trying
to recalculate the OID of the workdir bits to confirm that it is
modified - just accept that it is modified.

This can result in files that show as modified with no actual diff,
but the behavior actually appears to match Git on the command line.

This also includes a minor optimization to not perform a submodule
lookup on the ".git" directory itself.
2014-05-02 09:21:32 -07:00
Russell Belfer
240f4af321 Add build option for diff internal statistics 2014-05-02 09:21:32 -07:00
Russell Belfer
d19b2f9f9f Make ** pattern eat trailing slash
This allows "foo/**/*.html" to match "foo/file.html"
2014-05-01 12:46:46 -07:00
nulltoken
40e48ea40f remote: Introduce git_remote_delete() 2014-04-30 11:45:49 +02:00
nulltoken
3a728fb508 object: introduce git_describe_object() 2014-04-30 09:46:25 +02:00
nulltoken
4cc71bb7fb tests: Add "describe" test repository
Built with the following script:

	#!/bin/sh

	test_tick () {
		sleep 10
	}

	test_tick &&
	echo one >file && git add file && git commit -m initial &&
	one=$(git rev-parse HEAD) &&

	git describe --always HEAD &&

	test_tick &&
	echo two >file && git add file && git commit -m second &&
	two=$(git rev-parse HEAD) &&

	test_tick &&
	echo three >file && git add file && git commit -m third &&

	test_tick &&
	echo A >file && git add file && git commit -m A &&
	test_tick &&
	git tag -a -m A A &&

	test_tick &&
	echo c >file && git add file && git commit -m c &&
	test_tick &&
	git tag c &&

	git reset --hard $two &&
	test_tick &&
	echo B >side && git add side && git commit -m B &&
	test_tick &&
	git tag -a -m B B &&

	test_tick &&
	git merge -m Merged c &&
	merged=$(git rev-parse HEAD) &&

	git reset --hard $two &&
	test_tick &&
	echo D >another && git add another && git commit -m D &&
	test_tick &&
	git tag -a -m D D &&
	test_tick &&
	git tag -a -m R R &&

	test_tick &&
	echo DD >another && git commit -a -m another &&

	test_tick &&
	git tag e &&

	test_tick &&
	echo DDD >another && git commit -a -m "yet another" &&

	test_tick &&
	git merge -m Merged $merged &&

	test_tick &&
	echo X >file && echo X >side && git add file side &&
	git commit -m x
2014-04-30 09:31:58 +02:00
nulltoken
48ebea662a tests: Introduce count_config_entries_match() helper 2014-04-30 07:24:20 +02:00
Carlos Martín Nieto
217c029b54 commit: safer commit creation with reference update
The current version of the commit creation and amend function are unsafe
to use when passing the update_ref parameter, as they do not check that
the reference at the moment of update points to what the user expects.

Make sure that we're moving history forward when we ask the library to
update the reference for us by checking that the first parent of the new
commit is the current value of the reference. We also make sure that the
ref we're updating hasn't moved between the read and the write.

Similarly, when amending a commit, make sure that the current tip of the
branch is the commit we're amending.
2014-04-30 00:41:37 +02:00
Carlos Martín Nieto
1f0d4f3d8d netops: unit-test the cert host-name pattern matching
This kind of stuff should have unit tests, even if it's just to show
what we expect to match successfully.
2014-04-26 17:27:42 +02:00
Jiri Pospisil
7b8d564d5d Reset tests: Use sandboxed index 2014-04-25 15:49:58 +02:00
Vicent Marti
8443ed6c1d Merge pull request #2284 from jacquesg/push-progress-callback
Fire progress and update tips callbacks also for pushes.
2014-04-25 02:10:19 -07:00
Vicent Marti
332e4f2027 Merge pull request #2297 from libgit2/rb/status-with-precomposed-changes
Improve test coverage of status with different core.precomposeunicode settings
2014-04-25 02:07:42 -07:00
Vicent Marti
2ad51b81d2 Merge pull request #2241 from libgit2/rb/stash-skip-submodules
Improve stash and checkout for ignored + untracked items
2014-04-25 02:04:12 -07:00
Russell Belfer
af9eeac939 Merge pull request #2294 from ethomson/merge_checkout_strategy
Merge checkout strategy
2014-04-24 16:20:08 -07:00
Russell Belfer
6b833e3a4a Improve docs for status rename detection limits
and make tests empty on platforms without iconv support.
2014-04-24 15:40:50 -07:00
Russell Belfer
f608f3bb27 Test toggling core.precomposeunicode yields rename
There is an interesting difference with core Git here, though.
Because libgit2 will do rename detection with the working directory,
in the last case where the HEAD and the working directory both
have the decomposed data and the index has the composed data, we
generate a single status record with two renames whereas Git will
generate one rename (head to index) and one untracked file.
2014-04-24 15:25:01 -07:00
Russell Belfer
2334e3d8c3 Test decomposed unicode renames work as expected 2014-04-24 14:46:59 -07:00
Carlos Martín Nieto
bdc82e1c00 fetchhead: deal with quotes in branch names
The current FETCH_HEAD parsing code assumes that a quote must end the
branch name. Git however allows for quotes as part of a branch name,
which causes us to consider the FETCH_HEAD file as invalid.

Instead of searching for a single quote char, search for a quote char
followed by SP, which is not a valid part of a ref name.
2014-04-24 14:08:29 +02:00
Edward Thomson
a4e2c36a66 merge: checkout default shouldn't clobber given 2014-04-23 19:43:35 -04:00
Edward Thomson
26564d80aa merge: default checkout strategy for should be SAFE 2014-04-23 19:42:50 -04:00
Vicent Marti
212b6205d7 Merge pull request #2291 from ethomson/patch_binary
patch: emit deflated binary patches (optionally)
2014-04-23 09:27:15 -07:00
Vicent Marti
5ca410b9a9 Merge pull request #2283 from phkelley/win32_fs
Win32: UTF-8 <-> WCHAR conversion overhaul
2014-04-23 07:13:49 -07:00
Philip Kelley
7110000dd5 React to feedback for UTF-8 <-> WCHAR and reparse work 2014-04-23 09:23:50 -04:00
Russell Belfer
37da368545 Make checkout match diff for untracked/ignored dir
When diff finds an untracked directory, it emulates Git behavior
by looking inside the directory to see if there are any untracked
items inside it. If there are only ignored items inside the dir,
then diff considers it ignored, even if there is no direct ignore
rule for it.

Checkout was not copying this behavior - when it found an untracked
directory, it just treated it as untracked.  Unfortunately, when
combined with GIT_CHECKOUT_REMOVE_UNTRACKED, this made is seem that
checkout (and stash, which uses checkout) was removing ignored
items when you had only asked it to remove untracked ones.

This commit moves the logic for advancing past an untracked dir
while scanning for non-ignored items into an iterator helper fn,
and uses that for both diff and checkout.
2014-04-22 21:51:54 -07:00
Edward Thomson
e349ed500b patch: emit binary patches (optionally) 2014-04-22 19:08:21 -05:00
Russell Belfer
3c1aa4c110 Failing test for stashing a buried ignored file 2014-04-22 15:23:43 -07:00
Russell Belfer
24d17de255 Make stash and checkout ignore contained repos
To emulate git, stash should not remove untracked git repositories
inside the parent repo, and checkout's REMOVE_UNTRACKED should
also skip over these items.

`git stash` actually prints a warning message for these items.
That should be possible with a checkout notify callback if you
wanted to, although it would require a bit of extra logic as things
are at the moment.
2014-04-22 15:23:43 -07:00
Russell Belfer
8d09efa24e Use git_diff_get_stats in example/diff + refactor
This takes the `--stat` and related example options in the example
diff.c program and converts them to use the `git_diff_get_stats`
API which nicely formats stats for you.

I went to add bar-graph scaling to the stats formatter and noticed
that the `git_diff_stats` structure was holding on to all of the
`git_patch` objects.  Unfortunately, each of these objects keeps
the full text of the diff in memory, so this is very expensive.  I
ended up modifying `git_diff_stats` to keep just the data that it
needs to keep and allowed it to release the patches.  Then, I added
width scaling to the output on top of that.

In making the diff example program match 'git diff' output, I ended
up removing an newline from the sumamry output which I then had to
compensate for in the email formatting to match the expectations.

Lastly, I went through and refactored the tests to use a couple of
helper functions and reduce the overall amount of code there.
2014-04-22 12:33:27 -07:00
Edward Thomson
65477db166 Handle win32 reparse points properly 2014-04-22 00:28:27 -04:00
Russell Belfer
bd101a7eca Fix reset for staged deletes 2014-04-21 11:54:54 -07:00
Jacques Germishuys
f70cfd34f5 Verify update_tips callbacks in push test cases 2014-04-21 19:38:34 +02:00
Philip Kelley
c2c8161541 Win32: UTF-8 <-> WCHAR conversion overhaul 2014-04-19 21:50:44 -04:00
Vicent Marti
7b0f8ba9a8 Merge pull request #2279 from libgit2/rb/moar-eegnöre-fîxés
Fix several ignore and attribute file behavior bugs
2014-04-19 13:05:32 +02:00
Russell Belfer
916fcbd617 Fix ignore difference from git with trailing /*
Ignore patterns that ended with a trailing '/*' were still needing
to match against another actual '/' character in the full path.
This is not the same behavior as core Git.

Instead, we strip a trailing '/*' off of any patterns that were
matching and just take it to imply the FNM_LEADING_DIR behavior.
2014-04-18 14:42:40 -07:00
Russell Belfer
e3a2a04cef Preload attribute files that may contain macros
There was a latent bug where files that use macro definitions
could be parsed before the macro definitions were loaded.  Because
of attribute file caching, preloading files that are going to be
used doesn't add a significant amount of overhead, so let's always
preload any files that could contain macros before we assemble the
actual vector of files to scan for attributes.
2014-04-18 14:29:58 -07:00
Russell Belfer
50e46d6018 Cleanup tests with helper functions 2014-04-18 10:58:01 -07:00
Russell Belfer
6a0956e504 Pop ignore only if whole relative path matches
When traversing the directory structure, the iterator pushes and
pops ignore files using a vector.  Some directories don't have
ignore files, so it uses a path comparison to decide when it is
right to actually pop the last ignore file.  This was only
comparing directory suffixes, though, so a subdirectory with the
same name as a parent could result in the parent's .gitignore
being popped off the list ignores too early.  This changes the
logic to compare the entire relative path of the ignore file.
2014-04-18 10:32:35 -07:00
Russell Belfer
386777fd0d Merge pull request #2213 from ethomson/safecrlf
Introduce core.safecrlf handling
2014-04-18 09:26:38 -07:00
Carlos Martín Nieto
8c1f4ab4ab config: refresh on delete
When we delete an entry, we also want to refresh the configuration to
catch any changes that happened externally.

This allows us to simplify the logic, as we no longer need to delete
these variables internally. The whole state will be refreshed and the
deleted entries won't be there.
2014-04-18 16:07:33 +02:00
Carlos Martín Nieto
523032cd24 config: refresh before reading a value
With the isolation of complex reads, we can now try to refresh the
on-disk file before reading a value from it.

This changes the semantics a bit, as before we could be sure that a
string we got from the configuration was valid until we wrote or
refreshed. This is no longer the case, as a read can also invalidate the
pointer.
2014-04-18 16:07:33 +02:00
Carlos Martín Nieto
eaf3703401 config: refresh the values on write
When writing out, parse the resulting file instead of adding or
replacing the value locally. This has the effect of reading external
changes as well.
2014-04-18 16:07:33 +02:00
Carlos Martín Nieto
55ebd7d369 config: implement config snapshotting
In order to have consistent views of the config files for remotes,
submodules et al. and a configuration that represents what is currently
stored on-disk, we need a way to provide a view of the configuration
that does not change.

The goal here is to provide the snapshotting part by creating a
read-only copy of the state of the configuration at a particular point
in time, which does not change when a repository's main config changes.
2014-04-18 16:03:01 +02:00
Carlos Martín Nieto
36913b8cb4 config: document current write behaviour in a test
On set, we set/add the value written to the config's internal values,
but we do not refresh old values.

Document this in a test in preparation for the refresh changes.
2014-04-18 15:55:25 +02:00
Russell Belfer
8303827226 Some memory leak fixes 2014-04-17 15:04:42 -07:00
Russell Belfer
823c0e9cc1 Fix broken logic for attr cache invalidation
The checks to see if files were out of date in the attibute cache
was wrong because the cache-breaker data wasn't getting stored
correctly.  Additionally, when the cache-breaker triggered, the
old file data was being leaked.
2014-04-17 15:04:41 -07:00
Russell Belfer
ea642d61f9 Fix race checking for existing index items
In the threading tests, I was still seeing a race condition where
the same item could end up being inserted multiple times into the
index.  Preserving the sorted-ness of the index outside of the
`index_insert` call fixes the issue.
2014-04-17 14:56:41 -07:00
Russell Belfer
7d4908724f Attribute file cache refactor
This is a big refactoring of the attribute file cache to be a bit
simpler which in turn makes it easier to enforce a lock around any
updates to the cache so that it can be used in a threaded env.
Tons of changes to the attributes and ignores code.
2014-04-17 14:56:41 -07:00
Russell Belfer
3816debc13 Fix threading tests when threads disabled 2014-04-17 14:43:46 -07:00
Russell Belfer
8a2834d341 Index locking and entry allocation changes
This makes the lock management on the index a little bit broader,
having a number of routines hold the lock across looking up the
item to be modified and actually making the modification.  Still
not true thread safety, but more pure index modifications are now
safe which allows the simple cases (such as starting up a diff
while index modifications are underway) safe enough to get the
snapshot without hitting allocation problems.

As part of this, I simplified the allocation of index entries to
use a flex array and just put the path at the end of the index
entry.  This makes every entry self-contained and makes it a
little easier to feel sure that pointers to strings aren't
being accidentally copied and freed while other references are
still being held.
2014-04-17 14:43:45 -07:00
Russell Belfer
40ed499039 Add diff threading tests and attr file cache locks
This adds a basic test of doing simultaneous diffs on multiple
threads and adds basic locking for the attr file cache because
that was the immediate problem that arose from these tests.
2014-04-17 14:43:45 -07:00
Russell Belfer
3b4c401a38 Decouple index iterator sort from index
This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE
and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the
index data itself.  To take advantage of this, I had to export a
number of the internal index entry comparison functions.  I also
wrote some new tests to exercise the capability.
2014-04-17 14:43:45 -07:00
Russell Belfer
27e54bcf82 Add public diff print helpers
The usefulness of these helpers came up for me while debugging
some of the iterator changes that I was making, so since they
have also been requested (albeit indirectly) I thought I'd include
them.
2014-04-17 14:43:45 -07:00
Russell Belfer
c67fd4c9d5 Some vector utility tweaks
This is just laying some groundwork for internal index changes
that I'm working on.
2014-04-17 14:43:45 -07:00
Vicent Marti
c5cacc4ec2 Merge pull request #2261 from jacquesg/format-patch
Support for format-patch
2014-04-16 19:09:35 +02:00
Sven Strickroth
fa13ee2d7c Add GIT_BRANCH_ALL to git_branch_t enum
git_branch_t is an enum so requesting GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE is not possible as it is not a member of the enum (at least VS2013 C++ complains about it).

This fixes a regression introduced in commit a667ca8298 (PR #1946).

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2014-04-16 18:51:16 +02:00
Vicent Marti
37ab5ecc10 Merge pull request #2269 from libgit2/rb/fix-leading-slash-ignores
Fix core.excludesfile named .gitignore
2014-04-16 10:51:25 +02:00
Vicent Marti
0f7aa47dbd Merge pull request #2235 from jacquesg/cherry-pick
Add cherry pick support
2014-04-15 20:26:23 +02:00
Jacques Germishuys
39206ca256 Added a test case for formatting a binary patch e-mail 2014-04-15 17:22:17 +02:00
Jacques Germishuys
a56b418d85 Sanitize git_diff_format_email_options' summary parameter
It will form part of the subject line and should thus be one line.
2014-04-15 17:22:17 +02:00
Jacques Germishuys
d8cc1fb653 Introduce git_diff_format_email and git_diff_commit_as_email 2014-04-15 17:22:17 +02:00
Jacques Germishuys
360314c9db Introduce git_diff_get_stats, git_diff_stats_files_changed, git_diff_stats_insertions, git_diff_stats_deletions and git_diff_stats_to_buf 2014-04-15 17:22:12 +02:00
Jacques Germishuys
cab39378dc Added git_diff_stats test files 2014-04-15 17:22:03 +02:00
Russell Belfer
a9528b8fdd Fix core.excludesfile named .gitignore
Ignore rules with slashes in them are matched using FNM_PATHNAME
and use the path to the .gitignore file from the root of the
repository along with the path fragment (including slashes) in
the ignore file itself.  Unfortunately, the relative path to the
.gitignore file was being applied to the global core.excludesfile
if that was also named ".gitignore".

This fixes that with more precise matching and includes test for
ignore rules with leading slashes (which were the primary example
of this being broken in the real world).

This also backports an improvement to the file context logic from
the threadsafe-iterators branch where we don't rely on mutating
the key of the attribute file name to generate the context path.
2014-04-14 15:59:48 -07:00
Vicent Marti
289e31cd24 Merge pull request #2264 from jacquesg/fix-warnings
Correct C90 warnings
2014-04-14 23:11:06 +02:00
Jacques Germishuys
6fefb7af84 Capture conflict information in MERGE_MSG for revert and merge 2014-04-14 16:16:22 +02:00
Jacques Germishuys
103b7d2122 Added cherry pick tests 2014-04-14 16:16:22 +02:00
Vicent Marti
06d772d8d4 Merge pull request #2262 from libgit2/rb/fix-ignore-pop
Fix bug popping ignore files during wd iteration
2014-04-14 14:49:01 +02:00
Jacques Germishuys
efaa342cbb Correct C90 warnings 2014-04-11 22:48:42 +02:00
Jacques Germishuys
51297cadb3 Added RFC2822 date format test cases 2014-04-11 21:55:36 +02:00
Russell Belfer
8f7bc6461b Fix bug popping ignore files during wd iteration
There were a couple bugs in popping ignore files during iteration
that could result in incorrect decisions be made and thus ignore
files below the root either not being loaded correctly or not
being popped at the right time.

One bug was an off-by-one in comparing the path of the gitignore
file with the path being exited during iteration.

The second bug was not correctly truncating the path being tracked
during traversal if there were no ignores on the list (i.e. when
you have no .gitignore at the root, but do have some in contained
directories).
2014-04-10 16:33:39 -07:00
Vicent Marti
bcc622934a Merge pull request #2259 from libgit2/vmg/state-cleanup
Rewrite `state-cleanup`
2014-04-09 12:45:49 +02:00
Russell Belfer
eb7e17cc90 Update submodules with parent-tracked content
This updates how libgit2 treats submodule-like directories that
actually have tracked content inside of them.  This is a strange
corner case, but it seems that many people have abortive submodule
setups and then just went ahead and added the files into the
parent repository.  In this case, we should just treat the
submodule as if it was a normal directory.

Libgit2 will still try to skip over real submodules and contained
repositories that do not have tracked files inside them, but this
adds some new handling for cases where the apparently submodule
data is in conflict with the actual list of tracked files.
2014-04-08 14:47:20 -07:00
Vicent Marti
2795fb4ddd Merge pull request #2256 from jacquesg/graph-descendant
Correct grouping of parentheses
2014-04-08 16:37:39 +02:00
Jacques Germishuys
8a8e312792 Added a no path test for git_graph_descendant_of 2014-04-08 16:32:06 +02:00
Edward Thomson
855c66de66 Introduce core.safecrlf handling 2014-04-07 21:09:09 -07:00
Russell Belfer
c813b34550 Fix bug with multiple iconv conversions in one dir
The internal buffer in the `git_path_iconv_t` structure was not
being reset before the calls to `iconv` were made to convert data,
so if there were multiple decomposed Unicode paths in a single
directory, paths after the first one were being appended to the
first instead of treated as independent data.
2014-04-07 11:45:32 -07:00
Jacques Germishuys
c031129510 git_repository_state_cleanup() should remove rebase-merge/, rebase-apply/ and BISECT_LOG 2014-04-07 17:35:28 +02:00
Russell Belfer
c8c91433a8 More ** tests for pattern rules 2014-04-06 10:42:26 -07:00
Russell Belfer
2b6b85f116 Add support for ** matches in ignores
This is an experimental addition to add ** support to fnmatch
pattern matching in libgit2.  It needs more testing.
2014-04-04 17:02:12 -07:00
Vicent Marti
923c84008d Merge pull request #2215 from libgit2/rb/submodule-cache-fixes
Improve submodule cache management
2014-04-04 14:24:08 +02:00
Russell Belfer
eedeeb9e8f Test (and fix) the git_submodule_sync changes
I wrote this stuff a while ago and forgot to write tests.  Wanted
to do so now to wrap up the PR and immediately found problems.
2014-04-03 11:58:51 -07:00
Russell Belfer
18cc7d28c4 Minor code cleanup 2014-04-03 11:29:08 -07:00
Jan Melcher
f2fb4bac68 git_submodule_resolve_url supports relative urls
The base for the relative urls is determined as follows, with descending
priority:

- remote url of HEAD's remote tracking branch
- remote "origin"
- workdir

This follows git.git behaviour
2014-04-03 10:44:08 -07:00
Jan Melcher
12d4ed4de3 Test git_submodule_add_setup with relative url 2014-04-03 10:00:36 -07:00
Vicent Marti
fd61f05ea6 Merge pull request #2238 from libgit2/cmn/upstream-for-unborn
Handle an upstream branch for an unborn one
2014-04-03 09:53:28 +02:00
Vicent Marti
9edc5271e6 Merge pull request #2239 from libgit2/vmg/clar-skip-test
Skip tests on Clar
2014-04-03 09:52:42 +02:00
Carlos Martín Nieto
6f6be8fe41 remote: write tests for cloning from an empty repo
Cloning from an empty repo must set master's upstream to origin's
master, even if neither of them exist.

Fetching from a non-empty origin must then mark the master branch
for-merge. This currently fails.
2014-04-02 20:22:22 +02:00
Vicent Marti
0f65733b08 Clar: skip tests 2014-04-02 18:50:47 +02:00
Vicent Marti
fe23860aac Merge pull request #2230 from anuraggup/revwalk-merge-base
No need to find merge base.
2014-04-02 17:45:25 +02:00
Russell Belfer
ada157b237 Add warning when skipping blame test 2014-04-02 07:45:16 -07:00
Russell Belfer
d1a0900442 Skip blame libgit2 test if not in libgit2 repo
One blame test replies on being run from within the libgit2
repository to leverage having a longer history to play with, but
some bundled versions of libgit2 don't have the whole libgit2
history.  This just skips that test if the repository can't be
opened.
2014-04-01 21:58:48 -07:00
Russell Belfer
a574d584df New tests of status for repo inside repo 2014-04-01 21:32:06 -07:00
Russell Belfer
8f4e5275e4 More tests and fix submodule index refresh
There was a little bug where the submodule cache thought that the
index date was out of date even when it wasn't that was resulting
in some extra scans of index data even when not needed.

Mostly this commit adds a bunch of new tests including adding and
removing submodules in the index and in the HEAD and seeing if we
can automatically pick them up when refreshing.
2014-04-01 16:46:25 -07:00
Russell Belfer
8061d519b3 Remove most submodule reloads from tests
With the new submodule cache validity checks, we generally don't
need to call git_submodule_reload_all to have up-to-date submodule
data.  Some tests are still calling it where I want to actually
test that it can be called safely and doesn't break anything, but
mostly it is not needed.

This also expands some of the existing submodule tests to cover
some variants on the behavior that was already being tested.
2014-04-01 13:24:06 -07:00
Russell Belfer
4ece3e225b Fix submodule accounting for name and path changes
Wrote tests that try adding, removing, and updating the name of
submodules which showed a number of problems with how we account
for changes when incrementally updating the submodule info.  Most
of these issues didn't exist before because reloading would always
blow away the old submodule data.
2014-04-01 12:19:11 -07:00
Russell Belfer
18234b14ad Add efficient git_buf join3 API
There are a few places where we need to join three strings to
assemble a path.  This adds a simple join3 function to avoid the
comparatively expensive join_n (which calls strlen on each string
twice).
2014-04-01 09:45:20 -07:00
Edward Thomson
d67397dd0c Merge pull request #2226 from libgit2/rb/submodule-sorting-fix
Fix submodule sort order during iteration
2014-04-01 09:32:17 -07:00
Vicent Marti
9325460a93 Merge pull request #2206 from libgit2/cmn/inmemory-swap-order
Rename in-memory remote to anonymous and swap url and fetch order
2014-04-01 13:47:44 +02:00
Carlos Martín Nieto
fd536d29c1 remote: rename inmemory to anonymous and swap url and fetch order
The order in this function is the opposite to what
create_with_fetchspec() has, so change this one, as url-then-refspec is
what git does.

As we need to break compilation and the swap doesn't do that, let's take
this opportunity to rename in-memory remotes to anonymous as that's
really what sets them apart.
2014-04-01 13:38:04 +02:00
Edward Thomson
3ab5781601 Merge pull request #2178 from libgit2/rb/fix-short-id
Fix git_odb_short_id and git_odb_exists_prefix bugs
2014-03-31 23:23:32 -07:00
Anurag Gupta
3bc3d79761 No need to find merge base. 2014-03-31 15:15:32 -07:00
Russell Belfer
b76b5d3427 Improve test of submodule name sorting 2014-03-31 13:33:11 -07:00
Edward Thomson
976634c467 Introduce git_merge_head_id 2014-03-31 11:43:38 -05:00
Edward Thomson
ed38bff16c Update clar to 4b75388 2014-03-28 19:15:55 -07:00
Edward Thomson
e0d61c7b1c Sandbox configuration during test runs 2014-03-28 10:39:15 -07:00
Edward Thomson
10be94e9dc Update clar to 587f88a 2014-03-28 10:39:07 -07:00
Russell Belfer
dae8ba6e09 Fix memory leak of test repository object 2014-03-27 15:29:32 -07:00
Russell Belfer
380f864a10 Fix error when submodule path and name differ
When a submodule was inserted with a different path and name, the
return value from khash greater than zero was allowed to propagate
back out to the caller when it should really be zeroed.  This led
to a possible crash when reloading submodules if that was the
first time that submodule data was loaded.
2014-03-26 16:06:21 -07:00
Russell Belfer
22df47cbc5 Fix segfault if gitmodules is invalid
The reload_all call could end up dereferencing a NULL pointer if
there was an error while attempting to load the submodules config
data (i.e. invalid content in the gitmodules file).  This fixes it.
2014-03-26 14:38:26 -07:00
Edward Thomson
2b848e47c1 Decorate unused params as unused in revwalk::hidecb tests 2014-03-26 12:33:37 -05:00
Vicent Marti
dc7efa1aef Merge pull request #2204 from libgit2/rb/submodule-reference-counting
Make submodules externally refcounted
2014-03-26 18:29:34 +01:00
Vicent Marti
77b699e0da Merge pull request #2205 from libgit2/rb/submodule-untracked-vs-ignored
Update behavior for untracked contained repositories
2014-03-26 10:29:11 +01:00
Edward Thomson
f2f2d97f1e Test for giterr_capture 2014-03-25 21:54:41 -07:00
Russell Belfer
d3bc95fd66 Update behavior for untracked sub-repos
When a directory containing a .git directory (or even just a plain
gitlink) was found, libgit2 was going out of its way to treat it
specially.  This seemed like it was necessary because the diff
code was not originally emulating Git's behavior for untracked
directories correctly (i.e. scanning for ignored vs untracked items
inside).  Now that libgit2 diff mimics Git's untracked directory
behavior, the special handling for contained Git repos is actually
incorrect and this commit rips it out.
2014-03-25 12:37:05 -07:00
Edward Thomson
451aaf866a Merge pull request #2181 from anuraggup/hide_cb
Callback function to hide commit and its parents in revision walker
2014-03-25 10:33:18 -07:00
Russell Belfer
a15c7802c8 Make submodules externally refcounted
`git_submodule` objects were already refcounted internally in case
the submodule name was different from the path at which it was
stored.  This makes that refcounting externally used as well, so
`git_submodule_lookup` and `git_submodule_add_setup` return an
object that requires a `git_submodule_free` when done.
2014-03-25 09:14:48 -07:00
Anurag Gupta
34ffe22344 Modified test for revwalk_hidecb 2014-03-24 11:21:01 -07:00
Anurag Gupta
7ca1584b47 Conforming to libgit2 coding style. 2014-03-24 11:20:31 -07:00
Anurag Gupta
3a666071d9 Unit Tests for hide_cb in revwalk 2014-03-24 11:20:13 -07:00
Edward Thomson
fdc54eb2fb env test needs to deref git_buf's ptr 2014-03-24 10:56:11 -07:00
Vicent Marti
85a41fc4bf Merge pull request #2183 from ethomson/merge_refactor
Refactor the `git_merge` API
2014-03-24 18:09:13 +01:00
Carlos Martín Nieto
42dee8ecd7 settings: use git_buf for returning strings
This survived the last round of culling, as the signature is only in the
comments.
2014-03-24 13:21:51 +01:00
Carlos Martín Nieto
8350437112 reflog: follow core.logallrefupdates
On bare by default, or when core.logallrefupdates is false, we must not
write the reflog.
2014-03-20 19:18:49 +01:00
Edward Thomson
58c2b1c421 UNBORN implies FAST_FORWARD 2014-03-20 09:35:22 -07:00
Edward Thomson
ac584fcfd3 Introduce GIT_MERGE_ANALYSIS_UNBORN 2014-03-20 09:25:11 -07:00
Edward Thomson
97f3462ae6 git_merge_status -> git_merge_analysis 2014-03-20 09:25:10 -07:00
Edward Thomson
d9fdee6e4c Remove git_merge_result as it's now unnecessary 2014-03-20 09:25:09 -07:00
Edward Thomson
5aa2ac6de1 Update git_merge_tree_opts to git_merge_options 2014-03-20 09:25:08 -07:00
Edward Thomson
02105a27f0 Change signature of git_merge to take merge and checkout opts 2014-03-20 09:25:07 -07:00
Edward Thomson
1c0b6a38ba Remove fastforward / uptodate from git_merge 2014-03-20 09:25:06 -07:00
Edward Thomson
ccb308273a Add git_merge_status to provide info about an upcoming merge 2014-03-20 09:25:06 -07:00
Edward Thomson
05d47768ca Introduce git_merge_file for consumers 2014-03-20 09:25:05 -07:00
Carlos Martín Nieto
99797c96cd reflog: handle symref chains
Given HEAD -> master -> foo, when updating foo's reflog we should also
update HEAD's, as it's considered the current branch.
2014-03-19 18:14:35 +01:00
Carlos Martín Nieto
6aaae94a70 reflog: handle the birth of a branch
The reflog append function was overzealous in its checking. When passed
an old and new ids, it should not do any checking, but just serialize
the data to a reflog entry.
2014-03-19 16:52:20 +01:00
Carlos Martín Nieto
1afe140043 refdb: don't update when there's no need
If the caller wants to update a ref to point to the same target as it
currently has, we should return early and avoid writing to the reflog.
2014-03-19 15:54:33 +01:00
Carlos Martín Nieto
bac95e6e1e reflog: more comprehensive HEAD tests
The existing ones lack checking zeroed ids when switching back from an
unborn branch as well as what happens when detaching.

The reflog appending function mistakenly wrote zeros when dealing with a
detached HEAD. This explicitly checks for those situations and fixes
them.
2014-03-18 19:58:52 +01:00
Aimeast
0aee025bef Implement git_merge_base_octopus 2014-03-18 22:31:14 +08:00
Carlos Martín Nieto
4b7e1b9e92 refs: append to the HEAD reflog when updating the current branch
When we update the current branch, we must also append to HEAD's reflog
to keep them in sync.

This is a bit of a hack, but as git.git says, it covers 100% of
default cases.
2014-03-17 17:47:47 +01:00
Carlos Martín Nieto
cb562c3fb3 repo: remove test which deletes HEAD
This is not something anybody would ever do; removing HEAD makes the
.git/ directory no longer be a repository, so we wouldn't be expected to
handle such a situation.
2014-03-17 17:47:47 +01:00
Russell Belfer
5302a88538 Fix pqueue sort boundary condition bug
If the pqueue comparison fn returned just 0 or 1 (think "a<b")
then the sort order of returned items could be wrong because there
was a "< 0" that really needed to be "<= 0".  Yikes!!!
2014-03-12 11:21:55 -07:00
Jiri Pospisil
eb46fb2ba9 Add failing test for git_object_short_id 2014-03-10 11:35:14 -07:00
Russell Belfer
8949907887 Fix a number of git_odb_exists_prefix bugs
The git_odb_exists_prefix API was not dealing correctly when a
later backend returned GIT_ENOTFOUND even if an earlier backend
had found the object.

Additionally, the unit tests were not properly exercising the API
and had a couple mistakes in checking the results.

Lastly, since the backends are not expected to behavior correctly
unless all bytes of the short id are zero except for the prefix,
this makes the ODB prefix APIs explicitly clear out the extra
bytes so the user doesn't have to be as careful.
2014-03-10 11:34:50 -07:00
Edward Thomson
dd954a3735 Update clar to e1990d6 2014-03-07 10:53:00 -08:00
Vicent Marti
041cd4a23f Merge pull request #2028 from libgit2/options-names
Rename options structures
2014-03-07 19:02:58 +01:00
Carlos Martín Nieto
ae32c54e58 Plug a few leaks in the tests 2014-03-07 16:03:15 +01:00
Edward Thomson
806571f352 Update clar to a0b00f0 2014-03-07 00:28:18 -08:00
Ben Straub
aa17c3c63c git_revert_opts -> git_revert_options 2014-03-06 09:44:52 -08:00
Ben Straub
6affd71f33 git_checkout_opts -> git_checkout_options 2014-03-06 09:44:51 -08:00
Carlos Martín Nieto
8e52472037 tests: MSVC compat
MSVC doesn't like declaring variables in the middle of a block, so make
sure we only declare variables at the beginning of a block.
2014-03-06 16:56:46 +01:00