Commit Graph

1182 Commits

Author SHA1 Message Date
Russell Belfer
3d1c9f612d Fix git_repository_message docs
This clarifies the docs for git_repository_message and also adds
to the tests to explicitly check NUL termination of data when the
output buffer is smaller than the message size.  There is a minor
behavior change so that a non-NULL output buffer will always be
NUL terminated (at length zero) if an error occurs.
2013-05-09 06:45:06 -07:00
Vicent Martí
ddc5c05421 Merge pull request #1561 from arrbee/fix-windows-diff-eofnl
Fix windows diff eofnl error
2013-05-09 05:42:37 -07:00
Vicent Martí
af795759a7 Merge pull request #1552 from carlosmn/config-helpers
Config helpers for global/xdg config files
2013-05-07 15:09:11 -07:00
Carlos Martín Nieto
5d8318875f config: convenience function to open global/xdg
The rules for which one to open is a bit silly, so let's make it
easier for our users.
2013-05-07 21:42:56 +02:00
Carlos Martín Nieto
a4b75dcf56 repo: unconditionally create a global config backend
When a repository is initialised, we need to probe to see if there is
a global config to load. If this is not the case, the user isn't able
to write to the global config without creating the backend and adding
it themselves, which is inconvenient and overly complex.

Unconditionally create and add a backend for the global config file
regardless of whether it exists as a convenience for users.

To enable this, we allow creating backends to files that do not exist
yet, changing the semantics somewhat, and making some tests invalid.
2013-05-07 21:42:56 +02:00
Russell Belfer
0f938c6b8f Fix win32 type warnings 2013-05-07 09:59:53 -07:00
Carlos Martín Nieto
505b5d0c81 remote: correctly interpret tagopt '--tags'
When tagopt is set to '--tags', we should only take the default tags
refspec into account and ignore any configured ones.

Bring the code into compliance.
2013-05-07 18:49:47 +02:00
Vicent Martí
33665410d6 Merge pull request #1556 from arrbee/diff-patch-fixes
Diff patch bug fixes
2013-05-07 08:00:44 -07:00
Russell Belfer
c2f602f8a5 Fix line numbering for patches with eofnl
When a patch contained an eofnl change (i.e. the last line either
gained or lost a newline), the oldno and newno line number values
for the lines in the last hunk of the patch were not useful.  This
makes them behave in a more expected manner.
2013-05-07 07:15:39 -07:00
Russell Belfer
fd96f98e14 More tests for files with no newline at end 2013-05-07 04:36:42 -07:00
Russell Belfer
e35e2684f6 Add GIT_DIFF_LINE_CONTEXT_EOFNL
This adds a new line origin constant for the special line that
is used when both files end without a newline.

In the course of writing the tests for this, I was having problems
with modifying a file but not having diff notice because it was
the same size and modified less than one second from the start of
the test, so I decided to start working on nanosecond timestamp
support.  This commit doesn't contain the nanosecond support, but
it contains the reorganization of maybe_modified and the hooks so
that if the nanosecond data were being read by stat() (or rather
being copied by git_index_entry__init_from_stat), then the nsec
would be taken into account.

This new stuff could probably use some more tests, although there
is some amount of it here.
2013-05-07 04:32:17 -07:00
Nikolai Vladimirov
3d42e9a31e git_branch_set_upstream with local branches
Currently git_branch_set_upstream when passed a local branch
creates invalid configuration, for ex. if we setup branch
'tracking_master' to track local 'master' libgit2 generates
the following config

```
[branch "track_master"]
  remote = .
  merge = .refs/heads/track_master
```

The merge value is invalid and calling git_branch_upstream on
'tracking_master' results in invalid reference error.

It should do:

```
[branch "track_master"]
  remote = .
  merge = refs/heads/master
```
2013-05-06 20:33:11 +03:00
Vicent Martí
03c28d92d0 Merge pull request #1526 from arrbee/cleanup-error-return-without-msg
Make sure error messages are set for most error returns
2013-05-06 06:45:53 -07:00
Vicent Martí
d5e5bbd719 Merge pull request #1524 from jamill/clone_tagopts
By default do not set tagopt when cloning
2013-05-06 06:45:40 -07:00
Jameson Miller
6f748f3885 Do not write tagopt configuration option on clone by default 2013-05-04 12:14:40 -04:00
Russell Belfer
6e286e8dc5 Remove obsolete test for peel type
Peeling to an invalid type is now checked via an assert so this
test is no longer relevant.
2013-05-04 01:04:23 -07:00
Edward Thomson
e09d18eed6 allow checkout to proceed when a dir to be removed is in use (win32) 2013-05-03 18:54:47 -05:00
Edward Thomson
d80416384f fix some leaks 2013-05-02 20:43:45 -05:00
Edward Thomson
5e151329fb braces 2013-05-02 15:20:21 -05:00
Edward Thomson
4e7c15608f puns are not funny; type punning especially so 2013-05-02 14:58:40 -05:00
Jeff King
7edb9071da refdb_fs: do not require peeled packed refs to be tags
Older versions of git would only write peeled entries for
items under refs/tags/. Newer versions will write them for
all refs, and we should be prepared to handle that.
2013-05-02 11:07:20 -04:00
Russell Belfer
d82d66c96d Extra threading tests
We need to hammer the packfile open phase harder in the thread
tests, in addition to the cache API.
2013-05-02 03:05:21 -07:00
Edward Thomson
0cc7d8df19 allow empty dirs to exist when doing checkout 2013-05-01 09:50:40 -05:00
Vicent Marti
e1807113c4 merge: Warning noise 2013-05-01 15:31:23 +02:00
Russell Belfer
3e199f4285 Set error message for branch functions
There were a couple of places where an error was being returned
from branch related code but no error message was being set.
2013-05-01 04:18:46 -07:00
Edward Thomson
75d1c8c664 move NAME and REUC extensions to sys/ 2013-04-30 17:33:11 -05:00
Edward Thomson
0462fba538 renames! 2013-04-30 16:01:11 -05:00
Edward Thomson
bec65a5e99 merge! 2013-04-30 15:31:31 -05:00
Russell Belfer
a66c4bc846 More tests for diff untracked directories
This includes more tests for various scenarios when diff includes
an untracked directory in the workdir with contents either ignored
or not.
2013-04-30 04:25:56 -07:00
Russell Belfer
e26b14c034 Update diff handling of untracked directories
When diff encounters an untracked directory, there was a shortcut
that it took which is not compatible with core git.  This makes
the default behavior no longer take that shortcut and instead look
inside the untracked directory to see if there are any untracked
files within it.  If there are not, then the directory is treated
as an ignore directory instead of an untracked directory.  This
has implications for the git_status APIs.
2013-04-30 04:25:56 -07:00
Vicent Martí
cd2ed9f0cc Merge pull request #1518 from arrbee/export-oid-comparison
Remove most inlines from the public API
2013-04-30 04:02:52 -07:00
Vicent Martí
d76fb20ebc Merge pull request #1520 from carlosmn/nth-refspec
Add refspec list accessors
2013-04-30 03:29:48 -07:00
Russell Belfer
0a1755c045 Catch issue in config set with no config file
This prevents a segfault when setting a value in the config of a
repository that doesn't have a config file.
2013-04-30 03:15:45 -07:00
Carlos Martín Nieto
1ffd0806f4 remote: add resfpec list accessors
Bring back a way of acessing the git_refspec* from a remote.

Closes #1514
2013-04-30 12:04:59 +02:00
Russell Belfer
aa8f010120 Add git_oid_strcmp and use it for git_oid_streq
Add a new git_oid_strcmp that compares a string OID with a hex
oid for sort order, and then reimplement git_oid_streq using it.
This actually should speed up git_oid_streq because it only reads
as far into the string as it needs to, whereas previously it would
convert the whole string into an OID and then use git_oid_cmp.
2013-04-29 08:59:46 -07:00
Russell Belfer
8564a0224a Fix fragile git_oid_ncmp
git_oid_ncmp was making some assumptions about the length of
the data - this shifts the check to the top of the loop so it
will work more robustly, limits the max, and adds some tests
to verify the functionality.
2013-04-29 08:51:24 -07:00
Carlos Martín Nieto
d84884571d remote: dwim the refspecs according to the remote's advertised refs
As git allows you to store shorthand refspecs in the configuration, we
need to do this ourselves.
2013-04-28 18:49:51 +02:00
Carlos Martín Nieto
528a4e24c6 Parse shorthand refspecs as valid
Relax the ONELEVEL ref naming rules so the refspec parsing code can
ask for 'master' to be considered valid.
2013-04-28 14:21:10 +02:00
Russell Belfer
b1ff7004ab Improve diff config options handling
This makes diff use the cvar cache for config options where
possible, and also adds support for a number of other config
options to diff including "diff.context", "diff.ignoreSubmodules",
"diff.noprefix", "diff.mnemonicprefix", and "core.abbrev".

To make this natural, this involved a rearrangement of the code
that allocates the diff object vs. the code that initializes it
based on the combination of options passed in by the user and
read from the config.

This commit includes tests for most of these new options as well.
2013-04-23 12:57:30 -07:00
Ben Straub
bd0a07f4bb Clone: replace fetch spec with custom value 2013-04-23 12:28:59 -07:00
Nikolai Vladimirov
dfdf709e3f get last refspec in clone test 2013-04-23 22:04:37 +03:00
Carlos Martín Nieto
05b179648a Make refcounting atomic 2013-04-22 17:12:11 +02:00
Vicent Marti
d877159260 cache: Max cache size, and evict when the cache fills up 2013-04-22 17:04:52 +02:00
Vicent Marti
cf9709b64e tests: Do not warn for unused variable 2013-04-22 16:53:46 +02:00
Vicent Marti
865e2dd444 tests: Cleanup commit parse testing code 2013-04-22 16:52:07 +02:00
Russell Belfer
38eef6113d Make indexer use shared packfile open code
The indexer was creating a packfile object separately from the
code in pack.c which was a problem since I put a call to
git_mutex_init into just pack.c.  This commit updates the pack
function for creating a new pack object (i.e. git_packfile_check())
so that it can be used in both places and then makes indexer.c
use the shared initialization routine.

There are also a few minor formatting and warning message fixes.
2013-04-22 16:52:07 +02:00
Russell Belfer
3f27127d15 Simplify object table parse functions
This unifies the object parse functions into one signature that
takes an odb_object.
2013-04-22 16:52:06 +02:00
Russell Belfer
786062639f Add callback to git_objects_table
This adds create and free callback to the git_objects_table so
that more of the creation and destruction of objects can be table
driven instead of using switch statements.  This also makes the
semantics of certain object creation functions consistent so that
we can make better use of function pointers.  This also fixes a
theoretical error case where an object allocation fails and we
end up storing NULL into the cache.
2013-04-22 16:51:40 +02:00
Russell Belfer
917f60c50b Add tests for oidmap and new cache with threading
This adds some basic tests for the oidmap just to make sure that
collisions, etc. are dealt with correctly.

This also adds some tests for the new caching that check if items
are inserted (or not inserted) properly into the cache, and that
the cache can hold up in a multithreaded environment without error.
2013-04-22 16:50:51 +02:00
Vicent Marti
8842c75f17 What has science done. 2013-04-22 16:50:50 +02:00