Commit Graph

824 Commits

Author SHA1 Message Date
Juan Rubén
9e3b901aeb Add unit test 2014-02-24 00:09:29 +01:00
Russell Belfer
72556cc63b Address PR comments
* Make GIT_INLINE an internal definition so it cannot be used in
  public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
2014-02-20 14:27:10 -08:00
Ben Straub
9bda5fb8c1 Improve error propagation in shallow call 2014-02-18 14:05:30 -08:00
Edward Thomson
2a528bc088 Fix filter test for CRLF->LF issues 2014-02-11 19:05:52 -06:00
Russell Belfer
5d195cf76b Merge pull request #2110 from libgit2/ed/crlf_input
Handle `core.autocrlf=input` when checking out
2014-02-11 15:56:04 -08:00
Carlos Martín Nieto
15284a2c5a refs: move current_id before the reflog parameters
Keep the reflog parameters as the last two, as they're the optional
parameters.
2014-02-10 14:52:28 +01:00
Edward Thomson
9780020b18 Tests for crlf filtering into the repository 2014-02-09 13:45:39 -08:00
Edward Thomson
f77127da12 Tests for core.autocrlf and .gitattributes 2014-02-09 13:45:38 -08:00
Edward Thomson
fb6f4539d1 Close files on file diff failure
Not closing the files on a diff failure ensures that clar
cleanup will fail on win32 because we still have the file open.
2014-02-09 13:45:36 -08:00
Russell Belfer
80c29fe93e Add git_commit_amend API
This adds an API to amend an existing commit, basically a shorthand
for creating a new commit filling in missing parameters from the
values of an existing commit.  As part of this, I also added a new
"sys" API to create a commit using a callback to get the parents.
This allowed me to rewrite all the other commit creation APIs so
that temporary allocations are no longer needed.
2014-02-07 16:17:59 -08:00
Russell Belfer
2d9291943c Merge pull request #2099 from libgit2/bs/more-reflog-stuff
More reflogness
2014-02-07 16:14:17 -08:00
Russell Belfer
57c47af107 Merge pull request #2042 from libgit2/cmn/conditional-ref
refs: conditional ref updates
2014-02-07 16:05:19 -08:00
Russell Belfer
3158e2febe Fix some Windows warnings
This fixes a number of warnings with the Windows 64-bit build
including a test failure in test_repo_message__message where an
invalid pointer to a git_buf was being used.
2014-02-07 15:43:37 -08:00
Vicent Marti
c4ee3b54f8 Merge pull request #2100 from libgit2/rb/update-pqueue
Replace priority queue code with implementation from hashsig
2014-02-07 18:32:06 +01:00
Ben Straub
db55bb73ff Correct default reflog message for git_remote_fetch 2014-02-06 11:18:10 -08:00
Ben Straub
5dae3ffe25 Only run clone-failure test on private repo 2014-02-05 19:27:27 -08:00
Ben Straub
78ee7e81f5 More merge.conflictstyle fixes 2014-02-05 14:10:19 -08:00
Ben Straub
3094102f69 Avoid crash when skipping remote test 2014-02-05 14:05:18 -08:00
Ben Straub
fe45922d77 Fix broken clone test 2014-02-05 13:41:12 -08:00
Ben Straub
a2ce19ca68 Prevent user's merge.conflictstyle from breaking tests 2014-02-05 13:35:26 -08:00
Ben Straub
5c8be32559 Fix a few references to changed function signatures 2014-02-05 13:32:45 -08:00
Ben Straub
0de2c4e3a3 Merge remote-tracking branch 'libgit2/development' into bs/more-reflog-stuff 2014-02-05 13:15:57 -08:00
Ben Straub
629ba7f105 Merge pull request #2027 from libgit2/rb/only-windows-is-windows
Some tests of paths that can't actually be written to disk
2014-02-05 13:07:46 -08:00
Carlos Martín Nieto
d18209eef9 revwalk: add a test for pushing all references
This used to be broken, let's make sure we don't break this use-case.
2014-02-05 12:16:44 +01:00
Carlos Martín Nieto
d465e4e980 revwalk: ignore wrong object type in glob pushes
Pushing a whole namespace can cause us to attempt to push non-committish
objects. Catch this situation and special-case it for ignoring this.
2014-02-05 12:16:44 +01:00
Carlos Martín Nieto
b4ef67d5eb revwalk: add a failing test for pushing "tags"
This shows that pusing a whole namespace can be problematic.
2014-02-05 12:16:37 +01:00
Carlos Martín Nieto
5367ec4b84 refs: add an unconditional delete
Add it under the git_reference_remove() name, letting the user pass the
repo and name, analogous to unconditional setting/creation.
2014-02-05 12:07:57 +01:00
Carlos Martín Nieto
b7ae71ecf2 refs: catch cases where the ref type has changed
If the type of the on-disk reference has changed, the old value
comparison should fail.
2014-02-05 12:07:57 +01:00
Carlos Martín Nieto
f44fd59ed7 refs: check the ref's old value when deleting
Recognize when the reference has changed since we loaded it.
2014-02-05 12:07:57 +01:00
Carlos Martín Nieto
878fb66f57 refs: bring conditional symbolic updates to the frontend
Bring the race detection goodness to symbolic references as well.
2014-02-05 12:07:57 +01:00
Carlos Martín Nieto
d6236cf662 refs: add tests for conditional updates 2014-02-05 12:07:56 +01:00
Ben Straub
010cec3ac2 Add reflog params to git_repository_detach_head 2014-02-04 20:50:40 -08:00
Ben Straub
c3ab1e5af4 Add reflog parameters to remote apis
Also added a test for git_remote_fetch.
2014-02-04 20:38:13 -08:00
Ben Straub
491cecfe8c Add reflog parameters to git_push_update_tips 2014-02-04 20:27:44 -08:00
Ben Straub
0adb06065b Fix reflog message when creating commits 2014-02-04 15:32:57 -08:00
Russell Belfer
43709ca878 Fix typo setting sorted flag when reloading index
This fixes a typo I made for setting the sorted flag on the index
after a reload.  That typo didn't actually cause any test failures
so I'm also adding a test that explicitly checks that the index is
correctly sorted after a reload when ignoring case and when not.
2014-02-04 10:33:30 -08:00
Russell Belfer
882c774271 Convert pqueue to just be a git_vector
This updates the git_pqueue to simply be a set of specialized
init/insert/pop functions on a git_vector.

To preserve the pqueue feature of having a fixed size heap, I
converted the "sorted" field in git_vectors to a more general
"flags" field so that pqueue could mix in it's own flag.  This
had a bunch of ramifications because a number of places were
directly looking at the vector "sorted" field - I added a couple
new git_vector helpers (is_sorted, set_sorted) so the specific
representation of this information could be abstracted.
2014-02-04 10:01:37 -08:00
Russell Belfer
af4bc6615d Add some priority queue tests
I forgot that I wrote some tests for the new priority queue code.
2014-02-03 21:04:40 -08:00
Edward Thomson
bb13d39162 Test that emulates a strange filter implementation 2014-02-03 19:56:34 -08:00
Edward Thomson
16eb8b7c06 Tests merging staged files identical to result 2014-02-03 19:56:34 -08:00
Edward Thomson
b60149eced Tests merge when changes exist in workdir/index 2014-02-03 19:56:33 -08:00
Ben Straub
86746b4b3a Add reset tests for reflog 2014-02-03 15:06:47 -08:00
Ben Straub
eec2761f06 Fix warning 2014-02-03 15:06:32 -08:00
Ben Straub
586be3b889 Add reflog parameters to git_reset 2014-02-03 15:05:55 -08:00
Ben Straub
0d847a3159 Reset helpers: use revparse instead 2014-02-03 14:08:40 -08:00
Vicent Marti
3b6a5bac20 Merge pull request #2095 from libgit2/update-head-reflog
Correct "new" id for reattached-HEAD reflog entry
2014-02-03 10:36:04 -08:00
Arthur Schreiber
50ad7cc208 Add git_reference_is_note. 2014-02-02 18:20:38 +01:00
Ben Straub
7ac1b89942 Add failing test case 2014-02-01 11:46:15 -08:00
Russell Belfer
7be88b4c4d Update to latest clar 2014-01-31 13:44:09 -08:00
Ben Straub
db092c1955 Allow tests to run without user config 2014-01-30 16:10:18 -08:00
Ben Straub
a1710a28f6 Enhance testing of signature parameters 2014-01-30 15:53:52 -08:00
Ben Straub
59bb1126e0 Provide good default reflog messages in branch api 2014-01-30 15:53:52 -08:00
Ben Straub
e871d89b28 Ensure moving a branch updates the reflog 2014-01-30 15:52:14 -08:00
Ben Straub
ccf6ce5c89 Ensure renaming a reference updates the reflog 2014-01-30 15:52:13 -08:00
Ben Straub
540c1809f4 Add reflog parameters to git_branch_move 2014-01-30 15:52:13 -08:00
Ben Straub
48110f67e4 Deleting a branch deletes its reflog 2014-01-30 15:52:13 -08:00
Ben Straub
1cc974ab62 Augment clone API with reflog parameters 2014-01-30 15:52:13 -08:00
Ben Straub
b31ebfbc66 Add reflog params to git_branch_create 2014-01-30 15:52:13 -08:00
Ben Straub
67c4716f74 Add passing reflog tests 2014-01-30 15:51:00 -08:00
Ben Straub
2952a9d0f4 Ensure creating HEAD creates its reflog 2014-01-30 15:51:00 -08:00
Ben Straub
a2311f92c2 Ensure updating HEAD updates reflog 2014-01-30 15:51:00 -08:00
Ben Straub
94f263f59b Add reflog params to set-head calls 2014-01-30 15:51:00 -08:00
Vicent Marti
8646b0a068 Merge pull request #2085 from libgit2/rb/index-tree-blob-collision
Index tree-bob collision
2014-01-30 15:10:39 -08:00
Russell Belfer
8606f33bea Expand zstream tests and fix off-by-one error 2014-01-30 10:00:00 -08:00
Russell Belfer
d9b04d78a3 Reorganize zstream API and fix wrap problems
There were some confusing issues mixing up the number of bytes
written to the zstream output buffer with the number of bytes
consumed from the zstream input.  This reorganizes the zstream
API and makes it easier to deflate an arbitrarily large input
while still using a fixed size output.
2014-01-30 09:59:59 -08:00
Russell Belfer
3cf11eef17 Misc cleanups 2014-01-30 09:59:59 -08:00
Russell Belfer
c0644c3fbb Make submodule fetchRecurse match other options
This removes the fetchRecurse compiler warnings and makes the
behavior match the other submodule options (i.e. the in-memory
setting can be reset to the on-disk value).
2014-01-30 09:59:59 -08:00
Edward Thomson
bae8bea051 More index collision tests 2014-01-29 13:15:53 -08:00
Russell Belfer
95fbedcd8e Add test for blob/tree name collisions in index 2014-01-29 13:15:50 -08:00
Edward Thomson
96f12e709b Don't strcmp a git_buf, strcmp its char * 2014-01-29 12:50:42 -08:00
Arthur Schreiber
e7c16943f4 Add git_graph_descendant_of. 2014-01-28 19:39:14 +01:00
Vicent Marti
a1a9d0bd48 Merge pull request #2066 from libgit2/rb/builtin-diff-drivers
Add built in diff drivers
2014-01-27 15:35:39 -08:00
Russell Belfer
daebb59869 Add PHP tests and fix bug in PHP builtin driver 2014-01-27 14:57:03 -08:00
Russell Belfer
082e82dba5 Update Javascript userdiff driver and tests
Writing a sample Javascript driver pointed out some extra
whitespace handling that needed to be done in the diff driver.
This adds some tests with some sample javascript code that I
pulled off of GitHub just to see what would happen.  Also, to
clean up the userdiff test data, I did a "git gc" and packed
up the test objects.
2014-01-27 11:45:06 -08:00
Vicent Marti
93954245e0 Merge pull request #2075 from libgit2/cmn/leftover-oid
Leftover OID -> ID changes
2014-01-27 09:39:36 -08:00
Vicent Marti
46e7fc1853 Merge pull request #2077 from libgit2/cmn/buf-out
Buff up returning strings
2014-01-27 09:36:24 -08:00
Carlos Martín Nieto
66d585c6b3 MSVC doesn't like modern code 2014-01-27 04:58:23 +01:00
Carlos Martín Nieto
bf522e0811 refspec: move to git_buf for outputting strings 2014-01-27 04:44:06 +01:00
Carlos Martín Nieto
e1d7f0035e messsage: use git_buf in prettify()
A lot of the tests were checking for overflow, which we don't have
anymore, so we can remove them.
2014-01-27 04:44:06 +01:00
Carlos Martín Nieto
b25d87c9cd branch: move to git_buf when outputting newly-allocated strings
Internally we already did everything with git_bufs, so this is just
exposing those functions with public names.
2014-01-27 04:44:05 +01:00
Carlos Martín Nieto
7a3bd1e732 repository: move to use a git_buf for outputting strings
Since we now export that type, we can avoid making the user guess a
size.
2014-01-27 04:44:05 +01:00
Arthur Schreiber
991b2840eb Make sure git_remote_dup copies a remote's refspecs correctly. 2014-01-26 19:35:02 +01:00
Edward Thomson
58582cd0b0 Merge pull request #2057 from GrahamDennis/local-file-url-push-fix
Fix local push to file:// URL.
2014-01-26 06:31:38 -08:00
Carlos Martín Nieto
a1bbc0ce20 merge: rename _oid() -> id()
Following the rest of the series, use 'id' when refering to the value.
2014-01-25 08:15:44 +01:00
Carlos Martín Nieto
9950bb4e8d diff: rename the file's 'oid' to 'id'
In the same vein as the previous commits in this series.
2014-01-25 08:15:44 +01:00
Carlos Martín Nieto
d541170c77 index: rename an entry's id to 'id'
This was not converted when we converted the rest, so do it now.
2014-01-25 08:15:44 +01:00
Russell Belfer
027b8edac7 Move userdiff tests to be data driven
This moves the expected and actual test data along with the source
data for the userdiff tests into the tests/resources/userdiff test
repo and updates the test to use that.
2014-01-24 15:45:49 -08:00
Russell Belfer
5d82c0df13 Update all tests for new pattern extraction 2014-01-24 10:54:05 -08:00
Russell Belfer
b8e86c62f7 Implement matched pattern extract for fn headers 2014-01-24 10:54:05 -08:00
Russell Belfer
9bbc53d6d4 Fix filemode updating in diff text 2014-01-24 10:54:05 -08:00
Russell Belfer
2c65602e45 Import git drivers and test HTML driver
Reorganize the builtin driver table slightly so that core Git
builtin definitions can be imported verbatim.  Then take a few of
the core Git drivers and pull them in.

This also creates a test of diffs with the builtin HTML driver
which led to some small error handling fixes in the driver
selection logic.
2014-01-24 10:51:08 -08:00
Carlos Martín Nieto
d0a3de720e note: rename the id getter to git_note_id()
This was left over when we did the general switch.
2014-01-24 11:18:51 +01:00
Vicent Marti
ac8949edb2 Merge pull request #2073 from ethomson/zerobytes
Sometimes a zero byte file is just a zero byte file
2014-01-22 15:41:25 -08:00
Edward Thomson
410a8e6fed Sometimes a zero byte file is just a zero byte file
Don't go to the ODB to resolve zero byte files in the workdir
2014-01-22 18:31:25 -05:00
Edward Thomson
238e814972 Summarize empty messages 2014-01-22 14:41:04 -05:00
Edward Thomson
e8b81c698c Preserve tree filemode in index during checkout
Don't try to determine whether the system supports file modes
when putting the tree data in the index during checkout.  The tree's
mode is canonical and did not come from stat(2) in the first place.
2014-01-22 13:26:30 -05:00
Nicolas Hake
c05cd7924d Drop git_patch_to_str
It's hard or even impossible to correctly free the string buffer
allocated by git_patch_to_str in some circumstances. Drop the function
so people have to use git_patch_to_buf instead - git_buf has a dedicated
destructor.
2014-01-22 17:51:32 +01:00
Edward Thomson
0ef19fe14c Merge submodules 2014-01-20 18:07:17 -05:00
Edward Thomson
db3462ce77 Support union merges 2014-01-20 17:15:15 -05:00
Edward Thomson
0e1ba46cfb Remove the "merge none" flag
The "merge none" (don't automerge) flag was only to aide in
merge trivial tests.  We can easily determine whether merge
trivial resulted in a trivial merge or an automerge by examining
the REUC after automerge has completed.
2014-01-20 17:15:14 -05:00
Edward Thomson
6891a862bb Load merge.conflictstyle setting from config 2014-01-20 17:15:13 -05:00
Edward Thomson
e651e8e2b5 Introduce diff3 mode for checking out conflicts 2014-01-20 17:15:13 -05:00
Edward Thomson
6b92c99bcb Don't try to merge binary files 2014-01-20 17:15:12 -05:00
Edward Thomson
c1d648c5c6 merge_file should use more aggressive levels
The default merge_file level was XDL_MERGE_MINIMAL, which will
produce conflicts where there should not be in the case where
both sides were changed identically.  Change the defaults to be
more aggressive (XDL_MERGE_ZEALOUS) which will more aggressively
compress non-conflicts.  This matches git.git's defaults.

Increase testing around reverting a previously reverted commit to
illustrate this problem.
2014-01-20 17:15:11 -05:00
Edward Thomson
b554ca5dc1 "Uninitialized" submodules are "unmodified"
Extend the "unmodified" submodule workdir test to include
uninitialized submodules, to prevent reporting submodules as
modified when they're not in the workdir at all.
2014-01-20 17:09:31 -05:00
Patrick Reynolds
abdaf93662 add unit tests for git_buf_join corner cases 2014-01-20 11:42:12 -06:00
Graham Dennis
c7015424cc Fix a compile warning. 2014-01-18 08:54:19 +11:00
Graham Dennis
194d077c4f Add test for pushing to a local file:// URL. 2014-01-18 08:43:29 +11:00
Carlos Martín Nieto
0b28217bda refs: remove the _with_log differentiation
Any well-behaved program should write a descriptive message to the
reflog whenever it updates a reference. Let's make this more prominent
by removing the version without the reflog parameters.
2014-01-15 13:32:43 +01:00
Arthur Schreiber
40ef47dd46 Add git_remote_dup. 2014-01-14 21:03:01 +01:00
Ben Straub
426d8456ea Merge pull request #2033 from xtao/blame_orig_commit
Add orig_commit.
2014-01-08 19:43:31 -08:00
XTao
b92b434f5a Add orig & final commit test. 2014-01-09 11:18:38 +08:00
Edward Thomson
6adcaab70c Handle git_buf's from users more liberally 2014-01-08 10:08:23 -08:00
Russell Belfer
79ccb92178 Further tree building tests with hard paths 2014-01-03 14:26:02 -08:00
Russell Belfer
97bbf61e90 Tree accessor tests with hard path names 2014-01-03 12:14:22 -08:00
Vicent Marti
f3a302ad8e Merge pull request #2019 from linquize/recurse-on-demand
Accept 'submodule.*.fetchRecurseSubmodules' config 'on-demand' value
2014-01-02 05:10:04 -08:00
Marek Šuppa
f38cb9815f Updated fetch.c test to pass.
I am not sure why there was 6 in the first place.
2013-12-31 11:27:32 +01:00
Linquize
41ceab2522 Update test related to fetchRecurseSubmodules 2013-12-31 07:34:40 +08:00
Vicent Marti
4e1f517c61 Merge pull request #1920 from libgit2/cmn/ref-with-log
Reference operations with log
2013-12-18 09:33:45 -08:00
Edward Thomson
bf4a577c69 Overwrite ignored directories on checkout 2013-12-13 10:10:32 -05:00
Edward Thomson
81a2012d99 Overwrite ignored files on checkout 2013-12-13 09:29:55 -05:00
Vicent Marti
7a16d54b54 pool: Agh, this test doesn't really apply in 32-bit machines
The size_t is 32-bit already, so it overflows before going into the
function. The `-1` test should handle this gracefully in both cases
anyway.
2013-12-13 12:47:51 +01:00
Vicent Marti
437f7d69b2 pool: Correct overflow checks
Ok, scrap the previous commit. This is the right overflow check that
takes care of 64 bit overflow **and** 32-bit overflow, which needs to be
considered because the pool malloc can only allocate 32-bit elements in
one go.
2013-12-13 12:41:22 +01:00
Russell Belfer
452c7de668 Add git_treebuilder_insert test and clarify doc
This wasn't being tested and since it has a callback, I fixed it
even though the return value of this callback is not treated like
any of the other callbacks in the API.
2013-12-12 14:16:40 -08:00
Russell Belfer
11bd7a034b More tests of canceling from callbacks
This covers diff print, push, and ref foreach.  This also has a
fix for a small memory leak in the push tests.
2013-12-12 11:14:51 -08:00
Russell Belfer
7697e54176 Test cancel from indexer progress callback
This adds tests that try canceling an indexer operation from
within the progress callback.

After writing the tests, I wanted to run this under valgrind and
had a number of errors in that situation because mmap wasn't
working.  I added a CMake option to force emulation of mmap and
consolidated the Amiga-specific code into that new place (so we
don't actually need separate Amiga code now, just have to turn on
-DNO_MMAP).

Additionally, I made the indexer code propagate error codes more
reliably than it used to.
2013-12-11 15:02:20 -08:00
Russell Belfer
8b22d862fb More improvements to callback return value tests
This time actually checking return values in diff notify tests and
actually testing callbacks for the index all-all/update-all/etc
functions.
2013-12-11 11:55:00 -08:00
Russell Belfer
8046b26cb1 Try a test that won't assert on Linux 2013-12-11 10:57:51 -08:00
Russell Belfer
8f1066a05f Update clone doc and tests for callback return val
Clone callbacks can return non-zero values to cancel the clone.
This adds some tests to verify that this actually works and updates
the documentation to be clearer that this can happen and that the
return value will be propagated back by the clone function.
2013-12-11 10:57:51 -08:00
Russell Belfer
cbd048969e Fix checkout notify callback docs and tests
The checkout notify callback behavior on non-zero return values
was not being tested.  This adds tests, fixes a bug with positive
values, and clarifies the documentation to make it clear that the
checkout can be canceled via this mechanism.
2013-12-11 10:57:50 -08:00
Russell Belfer
19853bdd97 Update git_blob_create_fromchunks callback behavr
The callback to supply data chunks could return a negative value
to stop creation of the blob, but we were neither using GIT_EUSER
nor propagating the return value.  This makes things use the new
behavior of returning the negative value back to the user.
2013-12-11 10:57:50 -08:00
Russell Belfer
25e0b1576d Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
2013-12-11 10:57:49 -08:00
Russell Belfer
dab89f9b68 Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper.  As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.

Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up.  A number of
those fixes are included in the this commit as well.
2013-12-11 10:57:49 -08:00
Russell Belfer
96869a4edb Improve GIT_EUSER handling
This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around.  As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally.  To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
2013-12-11 10:57:49 -08:00
Russell Belfer
0eedacb06a Merge pull request #1985 from libgit2/diff-rename-config
Rename detection using diff.renames
2013-12-11 10:39:36 -08:00
Edward Thomson
5588f07360 Clean up warnings 2013-12-09 11:40:44 -05:00
Carlos Martín Nieto
f21051297c refs: expose has_log() on the backend
The frontend used to look at the file directly, but that's obviously not
the right thing to do. Expose it on the backend and use that function
instead.
2013-12-09 15:55:11 +01:00
Carlos Martín Nieto
8d5ec9106a refs: expose a way to ensure a ref has a log
Sometimes (e.g. stash) we want to make sure that a log will be written,
even if it's not in one of the standard locations. Let's make that
easier.
2013-12-09 15:55:11 +01:00
Carlos Martín Nieto
6f13a30565 reflog: write to the reflog following git's rules
git-core only writes to the reflogs of HEAD, refs/heads/ and,
refs/notes/ or if there is already a reflog in place. Adjust our code to
follow these semantics.
2013-12-09 15:55:11 +01:00
Ben Straub
7fb4147f1f Don't clobber whitespace settings 2013-12-06 13:38:59 -08:00
Ben Straub
628e92cdb3 Don't use weird return codes 2013-12-05 14:47:04 -08:00
Ben Straub
c56c6d6945 Implement GIT_DIFF_FIND_BY_CONFIG 2013-12-05 14:13:46 -08:00
Edward Thomson
d192e60b7a Reorder var decls in revert test
Oh, MSVC.
2013-12-03 10:47:18 -05:00
Edward Thomson
eac938d96e Bare naked merge and rebase 2013-12-03 10:18:53 -05:00
Vicent Martí
db0a7e39b3 Merge pull request #1977 from ethomson/revert
Revert support for a single commit
2013-12-03 02:11:55 -08:00
Edward Thomson
300d192f7e Introduce git_revert to revert a single commit 2013-12-02 16:57:41 -06:00
Russell Belfer
f62c174d0d GIT_DIFF_FIND_REMOVE_UNMODIFIED sounds better 2013-12-02 13:49:58 -08:00
Russell Belfer
97ad85b88d Add GIT_DIFF_FIND_DELETE_UNMODIFIED flag
When doing copy detection, it is often necessary to include
UNMODIFIED records in the git_diff so they are available as source
records for GIT_DIFF_FIND_COPIES_FROM_UNMODIFIED.  Yet in the final
diff, often you will not want to have these UNMODIFIED records.
This adds a flag which marks these UNMODIFIED records for deletion
from the diff list so they will be removed after the rename detect
phase is over.
2013-12-02 13:30:05 -08:00
Russell Belfer
2123a17f83 Fix bug making split deltas a COPIED targets
When FIND_COPIES is used in combination with BREAK_REWRITES for
rename detection, there was a bug where the split MODIFIED delta
was only used as a target for RENAME records and not for COPIED
records.  This fixes that, converting the split into a pair of
DELETED and COPIED deltas when that circumstance arises.
2013-12-02 13:27:06 -08:00
Carlos Martín Nieto
13c9e44af9 reflog: remove git_reflog_append_to()
This was a convenience method for the refs front-end to do the reflog
writing. This is now done in the backend and it has no more reason for
being.
2013-11-23 14:55:02 +01:00
Carlos Martín Nieto
a57dd3b7a4 reflog: integrate into the ref writing
Whenever a reference is created or updated, we need to write to the
reflog regardless of whether the user gave us a message, so we shouldn't
leave that to the ref frontend, but integrate it into the backend.

This also eliminates the race between ref update and writing to the
reflog, as we protect the reflog with the ref lock.

As an additional benefit, this reflog append on the backend happens by
appending to the file instead of parsing and rewriting it.
2013-11-23 14:55:02 +01:00
Carlos Martín Nieto
a6b508080c refs: adjust to the new reflog API 2013-11-23 13:35:53 +01:00
nulltoken
ca84e05850 refs: Introduce git_reference_symbolic_set_target_with_log() 2013-11-23 13:35:53 +01:00
nulltoken
14ab0e100e refs: Introduce git_reference_set_target_with_log() 2013-11-23 13:35:51 +01:00
nulltoken
56ad3782e0 refs: Introduce git_reference_symbolic_create_with_log() 2013-11-23 13:34:51 +01:00
nulltoken
bba25f39a2 refs: Introduce git_reference_create_with_log() 2013-11-23 13:34:46 +01:00
Vicent Martí
e479628a01 Merge pull request #1966 from nickh/patch_content_offsets
Add content offset to git_diff_line
2013-11-19 11:36:02 -08:00
nulltoken
65f67857ab tests: Drop unrelated comment 2013-11-19 14:25:30 +01:00
nulltoken
3d5233455b tree-cache: Don't segfault upon corruption 2013-11-19 13:25:37 +01:00
Nick Hengeveld
d8e7ffc2a2 Add content offset to git_diff_line
For additions and deletions, external consumers like subversion
can make use of the content offset to generate diffs in their
proprietary formats.
2013-11-18 14:03:25 -08:00
Russell Belfer
8f2a3d6251 Fix warnings 2013-11-18 12:14:50 -08:00
Edward Thomson
84efffc33a Introduce git_cred_default for NTLM/SPNEGO auth 2013-11-18 12:56:35 -05:00
Edward Thomson
80fc7d6bf0 Propagate auth error codes as GIT_EUSER in winhttp 2013-11-18 12:56:34 -05:00
Ben Straub
83e1efbf46 Update files that reference tests-clar 2013-11-14 14:10:32 -08:00
Ben Straub
1782038144 Rename tests-clar to tests 2013-11-14 14:05:52 -08:00
Vicent Martí
a1d0802576 Backport more test data 2012-05-02 16:33:26 -07:00
Vicent Martí
8c83fead91 Move test resources 2012-05-02 16:18:55 -07:00
Vicent Martí
40879facad Merge branch 'new-error-handling' into development
Conflicts:
	.travis.yml
	include/git2/diff.h
	src/config_file.c
	src/diff.c
	src/diff_output.c
	src/mwindow.c
	src/path.c
	tests-clar/clar_helpers.c
	tests-clar/object/tree/frompath.c
	tests/t00-core.c
	tests/t03-objwrite.c
	tests/t08-tag.c
	tests/t10-refs.c
	tests/t12-repo.c
	tests/t18-status.c
	tests/test_helpers.c
	tests/test_main.c
2012-05-02 15:59:02 -07:00
Russell Belfer
3fc5c65d1a Merge pull request #642 from arrbee/mem-pools
Memory pools and khash hashtables
2012-04-25 15:24:05 -07:00
Russell Belfer
c2b670436f Rename git_khash_str to git_strmap, etc.
This renamed `git_khash_str` to `git_strmap`, `git_hash_oid` to
`git_oidmap`, and deletes `git_hashtable` from the tree, plus
adds unit tests for `git_strmap`.
2012-04-25 15:20:28 -07:00
Carlos Martín Nieto
19dd4e2833 Include the new config test file 2012-04-25 20:42:33 +02:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Carlos Martín Nieto
2c1075d65a config: parse quoted values
Variable values may be quoted to include newlines, literal quotes and
other characters. Add support for these and test it.
2012-04-16 10:25:52 +02:00
nulltoken
3f46f313cb tag: Add git_tag_peel() which recursively peel a tag until a non tag git_object is met 2012-04-10 21:38:49 +02:00
Vicent Martí
16eaa15059 Merge pull request #606 from benstraub/t04_commit_to_clar
Ported t04_commit.c to Clar.
2012-04-02 17:24:16 -07:00
Ben Straub
fd29cd13b7 Moved testing resources to clar, and removed old tests directory.
Removed the BUILD_CLAR CMake flag, and updated the readme.
2012-03-31 16:10:01 -07:00
Ben Straub
9297b6e0a1 Removing test suites that have been ported to Clar:
* t00 / 6e86fb3 (mentioned in #406)
* t01 / fc60c4a (mentioned in #406)
* t03 / bcbabe6
* t04 / PR #606
* t05 / d96f2c3
* t06 / 6c106ee
* t07 / 2ef582b
* t08 / b482c42
* t09 / 9a39a36
* t10 / 00a4893
* t12 / 7c3a4a7
* t13 / 1cb9b31
* t17 / cdaa6ff (mentioned in #406)
* t18 / efabc08
2012-03-31 14:15:18 -07:00
Vicent Martí
9273399bdb Merge pull request #610 from arrbee/status-rewrite
Rewrite status using diff
2012-03-31 08:23:37 -07:00
Ben Straub
b482c420e9 t08_tag.c ported.
Also cleaned up some names for things that used to be macros.
2012-03-30 12:05:36 -07:00
Russell Belfer
277e304149 Fix handling of submodules in trees 2012-03-26 11:22:27 -07:00
Russell Belfer
875bfc5ffc Fix error in tree iterator when popping up trees
There was an error in the tree iterator where it would
delete two tree levels instead of just one when popping
up a tree level.  Unfortunately the test data for the
tree iterator did not have any deep trees with subtrees
in the middle of the tree items, so this problem went
unnoticed.  This contains the 1-line fix plus new test
data and tests that reveal the issue.
2012-03-25 21:26:48 -07:00
Russell Belfer
c8838ee92d Restore default status recursion behavior
This gives `git_status_foreach()` back its old behavior of
emulating the "--untracked=all" behavior of git.  You can
get any of the various --untracked options by passing flags
to `git_status_foreach_ext()` but the basic version will
keep the behavior it has always had.
2012-03-23 11:03:01 -07:00
Russell Belfer
a56aacf4d3 More status testing
This "fixes" the broken t18 status tests to accurately reflect
the new behavior for "created" untracked subdirectories.  See
discussion in the PR for more details.

This also contains the submodules unit test that I forgot to
git add, and ports most of the t18-status.c tests to clar (still
missing a couple of the git_status_file() single file tests).
2012-03-22 12:03:30 -07:00
Russell Belfer
95340398a1 Adding new tests for new status command
This is a work in progress.  This adds two new sets of tests,
the issue_592 tests from @nulltoken's pull request #601 and
some new tests for submodules.  The submodule tests still have
issues where the status is not reported correctly.  That needs
to be fixed before merge.
2012-03-22 09:17:34 -07:00
nulltoken
e285bdc93b test_helpers: fix unepextected closing of file on error 2012-03-21 08:12:25 +01:00
Ben Straub
e0799b6cd0 Ported t04_commit.c to Clar.
Created a copy of tests/resources/testrepo.git that is compatible
with the Clar sandboxing helpers.

Restructured commit test suites to use Clar sandbox helpers.

Now using typed data arrays rather than lots of macros to define test
cases.
2012-03-20 23:11:24 -07:00
Russell Belfer
0d0fa7c368 Convert attr, ignore, mwindow, status to new errors
Also cleaned up some previously converted code that still had
little things to polish.
2012-03-16 15:56:01 -07:00
Vicent Martí
cb8a79617b error-handling: Repository
This also includes droping `git_buf_lasterror` because it makes no sense
in the new system. Note that in most of the places were it has been
dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so
instead it should return a generic `-1` and obviously not throw
anything.
2012-03-07 00:11:43 +01:00
Authmillenon
5621d8097d Rename git_oid_to_string to git_oid_tostr
To conform the naming scheme of git_oid_fromstr we should change the
name of git_oid_to_string to git_oid_tostr.
2012-03-06 17:51:04 +01:00
Vicent Martí
1a48112342 error-handling: References
Yes, this is error handling solely for `refs.c`, but some of the
abstractions leak all ofer the code base.
2012-03-06 00:43:10 +01:00
Russell Belfer
e1bcc19110 Revert GIT_STATUS constants to avoid issues
This reverts the changes to the GIT_STATUS constants and adds a
new enumeration to describe the type of change in a git_diff_delta.
I don't love this solution, but it should prevent strange errors
from occurring for now.  Eventually, I would like to unify the
various status constants, but it needs a larger plan and I just
wanted to eliminate this breakage quickly.
2012-03-02 15:51:55 -08:00
Russell Belfer
854eccbb2d Clean up GIT_UNUSED macros on all platforms
It turns out that commit 31e9cfc4cbcaf1b38cdd3dbe3282a8f57e5366a5
did not fix the GIT_USUSED behavior on all platforms.  This commit
walks through and really cleans things up more thoroughly, getting
rid of the unnecessary stuff.

To remove the use of some GIT_UNUSED, I ended up adding a couple
of new iterators for hashtables that allow you to iterator just
over keys or just over values.

In making this change, I found a bug in the clar tests (where we
were doing *count++ but meant to do (*count)++ to increment the
value).  I fixed that but then found the test failing because it
was not really using an empty repo.  So, I took some of the code
that I wrote for iterator testing and moved it to clar_helpers.c,
then made use of that to make it easier to open fixtures on a
per test basis even within a single test file.
2012-03-02 15:51:55 -08:00
Russell Belfer
74fa4bfae3 Update diff to use iterators
This is a major reorganization of the diff code.  This changes
the diff functions to use the iterators for traversing the
content.  This allowed a lot of code to be simplified.  Also,
this moved the functions relating to outputting a diff into a
new file (diff_output.c).

This includes a number of other changes - adding utility
functions, extending iterators, etc. plus more tests for the
diff code.  This also takes the example diff.c program much
further in terms of emulating git-diff command line options.
2012-03-02 15:49:29 -08:00
Russell Belfer
caf71ec081 Add tests and fix bugs for diff whitespace options
Once I added tests for the whitespace handling options of
diff, I realized that there were some bugs.  This fixes
those and adds the new tests into the test suite.
2012-03-02 15:49:29 -08:00
Russell Belfer
3a4375901a Clean up diff implementation for review
This fixes several bugs, updates tests and docs, eliminates the
FILE* assumption in favor of printing callbacks for the diff patch
formatter helpers, and adds a "diff" example function that can
perform a diff from the command line.
2012-03-02 15:49:28 -08:00
Russell Belfer
cd33323b72 Initial implementation of git_diff_blob
This gets the basic plumbing in place for git_diff_blob.
There is a known issue where additional parameters like
the number of lines of context to display on the diff
are not working correctly (which leads one of the new
unit tests to fail).
2012-03-02 15:49:28 -08:00
Russell Belfer
2705576bfa Simplify GIT_UNUSED macros
Since casting to void works to eliminate errors with unused
parameters on all platforms, avoid the various special cases.
Over time, it will make sense to eliminate the GIT_UNUSED
macro completely and just have GIT_UNUSED_ARG.
2012-03-02 15:49:28 -08:00
Russell Belfer
7e3fc62310 Add test for possible attr bug
This is a test that should replicate an issue that Peff
is setting with git attributes.  But the test doesn't fail.
2012-03-02 15:49:28 -08:00
Vicent Martí
13224ea4aa buffer: Unify git_fbuffer and git_buf
This makes so much sense that I can't believe it hasn't been done
before. Kill the old `git_fbuffer` and read files straight into
`git_buf` objects.

Also: In order to fully support 4GB files in 32-bit systems, the
`git_buf` implementation has been changed from using `ssize_t` for
storage and storing negative values on allocation failure, to using
`size_t` and changing the buffer pointer to a magical pointer on
allocation failure.

Hopefully this won't break anything.
2012-02-27 05:30:07 +01:00
Carlos Martín Nieto
3005855f7e Implement setting multivars 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
78d65f390f tests: add multivar read test 2012-02-17 19:43:43 +01:00
Russell Belfer
e8c96ed2a7 Add unit tests for recent bug fixes
Add unit tests to confirm ignore directory pattern matches and
to confirm that ignore and attribute files are loaded properly
into the attribute file cache.
2012-02-01 12:30:35 -08:00
nulltoken
1e53b52eb9 threads: Make the old test suite TLS aware 2012-01-29 15:11:09 +01:00
Russell Belfer
63ab73bec0 Merge branch 'fix-subdir-attr-paths' into development
This resolves issue #535 and issue #533.
2012-01-20 11:13:17 -08:00
Russell Belfer
1744fafec0 Move path related functions from fileops to path
This takes all of the functions that look up simple data about
paths (such as `git_futils_isdir`) and moves them over to path.h
(becoming `git_path_isdir`).  This leaves fileops.h just with
functions that actually manipulate the filesystem or look at
the file contents in some way.

As part of this, the dir.h header which is really just for win32
support was moved into win32 (with some minor changes).
2012-01-17 15:49:47 -08:00
Russell Belfer
a51cd8e6f6 Fix handling of relative paths for attrs
Per issue #533, the handling of relative paths in attribute
and ignore files was not right.  Fixed this by pre-joining
the relative path of the attribute/ignore file onto the match
string when a full path match is required.

Unfortunately, fixing this required a bit more code than I
would have liked because I had to juggle things around so that
the fnmatch parser would have sufficient information to prepend
the relative path when it was needed.
2012-01-16 16:58:27 -08:00
Russell Belfer
6a67a812c2 Allow ignores (and attribs) for nonexistent files
This fixes issue 532 that attributes (and gitignores) could not
be checked for files that don't exist.  It should be possible to
query such things regardless of the existence of the file.
2012-01-11 16:01:48 -08:00
Russell Belfer
fdaa924037 Fix up status tests 2012-01-11 15:25:13 -08:00
Russell Belfer
df743c7d3a Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and
git_status_file().  This includes refactoring the gitattributes
code to share logic where possible.  The GIT_STATUS_IGNORED flag
will now be passed in for files that are ignored (provided they
are not already in the index or the head of repo).
2012-01-11 14:39:51 -08:00
Vicent Martí
f2114d0a35 Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into development
Conflicts:
	tests-clay/clay.h
	tests-clay/clay_main.c
2012-01-04 22:43:11 +01:00
Russell Belfer
bd370b14fe Improved gitattributes macro implementation
This updates to implementation of gitattribute macros to be much more
similar to core git (albeit not 100%) and to handle expansion of
macros within macros, etc.  It also cleans up the refcounting usage
with macros to be much cleaner.

Also, this adds a new vector function `git_vector_insert_sorted()`
which allows you to maintain a sorted list as you go.  In order to
write that function, this changes the function `git__bsearch()` to
take a somewhat different set of parameters, although the core
functionality is still the same.
2011-12-30 15:00:14 -08:00
Russell Belfer
73b51450a3 Add support for macros and cache flush API.
Add support for git attribute macro definitions.  Also, add
support for cache flush API to clear the attribute file content
cache when needed.

Additionally, improved the handling of global and system files,
making common utility functions in fileops and converting config
and attr to both use the common functions.

Adds a bunch more tests and fixed some memory leaks.  Note that
adding macros required me to use refcounted attribute assignment
definitions, which complicated, but probably improved memory usage.
2011-12-29 00:01:10 -08:00
nulltoken
eb8de7476b util: add git__fromhex() 2011-12-28 20:25:29 +01:00
Russell Belfer
ee1f0b1aed Add APIs for git attributes
This adds APIs for querying git attributes.  In addition to
the new API in include/git2/attr.h, most of the action is in
src/attr_file.[hc] which contains utilities for dealing with
a single attributes file, and src/attr.[hc] which contains
the implementation of the APIs that merge all applicable
attributes files.
2011-12-20 16:32:58 -08:00
Russell Belfer
b5daae68a4 Allow git_buf_joinpath to accept self-joins
It was not safe for git_buf_joinpath to be used with a pointer
into the buf itself because a reallocation could invalidate
the input parameter that pointed into the buffer.  This patch
makes it safe to self join, at least for the leading input to
the join, which is the common "append" case for self joins.

Also added unit tests to explicitly cover this case.

This should actually fix #511
2011-12-14 14:31:06 -08:00
Russell Belfer
97769280ba Use git_buf for path storage instead of stack-based buffers
This converts virtually all of the places that allocate GIT_PATH_MAX
buffers on the stack for manipulating paths to use git_buf objects
instead.  The patch is pretty careful not to touch the public API
for libgit2, so there are a few places that still use GIT_PATH_MAX.

This extends and changes some details of the git_buf implementation
to add a couple of extra functions and to make error handling easier.

This includes serious alterations to all the path.c functions, and
several of the fileops.c ones, too.  Also, there are a number of new
functions that parallel existing ones except that use a git_buf
instead of a stack-based buffer (such as git_config_find_global_r
that exists alongsize git_config_find_global).

This also modifies the win32 version of p_realpath to allocate whatever
buffer size is needed to accommodate the realpath instead of hardcoding
a GIT_PATH_MAX limit, but that change needs to be tested still.
2011-12-07 23:08:15 -08:00
Carlos Martín Nieto
89886d0bbb Plug a bunch of leaks 2011-11-28 21:08:29 +01:00
Vicent Marti
b54b88c465 tests: Add refs folder to the bad_tag.git repo 2011-11-26 08:48:01 +01:00
Vicent Marti
45e79e3701 Rename all _close methods
There's no difference between `_free` and `_close` semantics: keep
everything with the same name to avoid confusions.
2011-11-26 08:48:00 +01:00
Vicent Marti
9462c47143 repository: Change ownership semantics
The ownership semantics have been changed all over the library to be
consistent. There are no more "borrowed" or duplicated references.

Main changes:

	- `git_repository_open2` and `3` have been dropped.

	- Added setters and getters to hotswap all the repository owned
	objects:

		`git_repository_index`
		`git_repository_set_index`
		`git_repository_odb`
		`git_repository_set_odb`
		`git_repository_config`
		`git_repository_set_config`
		`git_repository_workdir`
		`git_repository_set_workdir`

	Now working directories/index files/ODBs and so on can be
	hot-swapped after creating a repository and between operations.

	- All these objects now have proper ownership semantics with
	refcounting: they all require freeing after they are no longer
	needed (the repository always keeps its internal reference).

	- Repository open and initialization has been updated to keep in
	mind the configuration files. Bare repositories are now always
	detected, and a default config file is created on init.

	- All the tests affected by these changes have been dropped from the
	old test suite and ported to the new one.
2011-11-26 08:37:08 +01:00
Russell Belfer
b762e576c6 filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanups
Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT
and make git_filebuf_open and git_filebuf_cleanup safe to be called
multiple times on the same buffer.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-11-22 01:53:56 +01:00
Carlos Martín Nieto
0c49ec2d3b Implement p_rename
Move the callers of git_futils_mv_atomic to use p_rename.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-07 20:34:27 +01:00
Vicent Martí
3b83bdac39 Merge pull request #470 from schu/test-helpers-no-assert
test_helpers: do not rely on assert
2011-11-07 06:25:22 -08:00
Vicent Marti
d4a0b124d0 refs: Partial rewrite for read-only refs
This new version of the references code is significantly faster and
hopefully easier to read.

External API stays the same. A new method `git_reference_reload()` has
been added to force updating a memory reference from disk. In-memory
references are no longer updated automagically -- this was killing us.

If a reference is deleted externally and the user doesn't reload the
memory object, nothing critical happens: any functions using that
reference should fail gracefully (e.g. deletion, renaming, and so on).

All generated references from the API are read only and must be free'd
by the user. There is no reference counting and no traces of generated
references are kept in the library.

There is no longer an internal representation for references. There is
only one reference struct `git_reference`, and symbolic/oid targets are
stored inside an union.

Packfile references are stored using an optimized struct with flex array
for reference names. This should significantly reduce the memory cost of
loading the packfile from disk.
2011-11-06 03:15:34 +01:00
schu
75abd2b924 Free all used references in the source tree
Since references are not owned by the repository anymore we have to free
them manually now.

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:26 +01:00
schu
4fd89fa039 refs: add test case checking "immutable" references
Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:22 +01:00
schu
a46ec45746 refs: split internal and external references
Currently libgit2 shares pointers to its internal reference cache with
the user. This leads to several problems like invalidation of reference
pointers when reordering the cache or manipulation of the cache from
user side.

Give each user its own git_reference instead of leaking the internal
representation (struct reference).

Add the following new API functions:

	* git_reference_free
	* git_reference_is_packed

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:19 +01:00
schu
ec9079443c test_helpers: do not rely on assert
The functions loose_object_mode and loose_object_dir_mode call stat
inside an assert statement which isn't evaluated when compiling in
Release mode (NDEBUG) and leads to failing tests. Replace it.

Signed-off-by: schu <schu-github@schulog.org>
2011-10-30 13:48:00 +01:00
Vicent Martí
d3104fa0a3 Merge pull request #468 from nulltoken/ntk/fix/issue-465
Status: fix segfault (#465) and order issues
2011-10-29 14:06:36 -07:00
nulltoken
a1bd78ea29 status: Add a file in the test repository to cover the correct sorting of entries when the working folder is being read
In this case, "subdir.txt" should be listed before the "subdir" directory.
2011-10-29 22:05:56 +02:00
Vicent Martí
89fb8f025a Merge pull request #456 from brodie/perm-fixes
Create objects, indexes, and directories with the right file permissions
2011-10-28 19:04:23 -07:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Brodie Rao
252840a59f tests: propagate errors from open_temp_repo() instead of exiting
This makes it slightly easier to debug test failures when one test
opens a repo, has a failure, and doesn't get a chance to close it for
the next test. Now, instead of getting no feedback, we at least see
test failure information.
2011-10-14 16:20:23 -07:00
Brodie Rao
01ad7b3a9e *: correct and codify various file permissions
The following files now have 0444 permissions:

- loose objects
- pack indexes
- pack files
- packs downloaded by fetch
- packs downloaded by the HTTP transport

And the following files now have 0666 permissions:

- config files
- repository indexes
- reflogs
- refs

This brings libgit2 more in line with Git.

Note that git_filebuf_commit() and git_filebuf_commit_at() have both
gained a new mode parameter.

The latter change fixes an important issue where filebufs created with
GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3)
usage). Now we chmod() the file before renaming it into place.

Tests have been added to confirm that new commit, tag, and tree
objects are created with the right permissions. I don't have access to
Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
2011-10-14 16:07:47 -07:00
Brodie Rao
ce8cd006ce fileops/repository: create (most) directories with 0777 permissions
To further match how Git behaves, this change makes most of the
directories libgit2 creates in a git repo have a file mode of
0777. Specifically:

- Intermediate directories created with git_futils_mkpath2file() have
  0777 permissions. This affects odb_loose, reflog, and refs.

- The top level folder for bare repos is created with 0777
  permissions.

- The top level folder for non-bare repos is created with 0755
  permissions.

- /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are
  created with 0777 permissions.

Additionally, the following changes have been made:

- fileops functions that create intermediate directories have grown a
  new dirmode parameter. The only exception to this is filebuf's
  lock_file(), which unconditionally creates intermediate directories
  with 0777 permissions when GIT_FILEBUF_FORCE is set.

- The test runner now sets the umask to 0 before running any
  tests. This ensurses all file mode checks are consistent across
  systems.

- t09-tree.c now does a directory permissions check. I've avoided
  adding this check to other tests that might reuse existing
  directories from the prefabricated test repos. Because they're
  checked into the repo, they have 0755 permissions.

- Other assorted directories created by tests have 0777 permissions.
2011-10-14 16:04:34 -07:00
Brodie Rao
33127043b3 fileops/posix: replace usage of "int mode" with "mode_t mode"
Note: Functions exported from fileops take const mode_t, while the
underlying POSIX wrappers take mode_t.
2011-10-14 15:57:15 -07:00
nulltoken
a6c0e4d202 Fix minor indentation issues 2011-10-13 22:49:05 +02:00
nulltoken
b3f993e287 Add test commit containing subtrees and files 2011-10-13 22:48:58 +02:00
Brodie Rao
6f2856f308 signature: don't blow up trying to parse names containing '>'
When trying to find the end of an email, instead of starting at the
beginning of the signature, we start at the end of the name (after the
first '<').

This brings libgit2 more in line with Git's behavior when reading out
existing signatures.

However, note that Git does not allow names like these through the
usual porcelain; instead, it silently strips any '>' characters it
sees.
2011-10-12 16:19:46 -07:00
Brodie Rao
15b0bed2ba tag: allow the tagger field to be missing when parsing tags
Instead of bailing out with an error, this sets tagger to NULL when
the field is missing from the object.

This makes it possible to inspect tags like this one:

http://git.kernel.org/?p=git/git.git;a=tag;h=f25a265a342aed6041ab0cc484224d9ca54b6f41
2011-10-12 16:09:16 -07:00
Brodie Rao
cf7b13f3c3 tag: avoid a double-free when parsing tags without a tagger field
The v0.99 tag in the Git repo triggers this behavior:

http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec5194c87b0fc87103ca4d67251c76f233a

Ideally, we'd allow the tag to be instantiated even though the tagger
field is missing, but this at the very least prevents libgit2 from
crashing.

To test this bug, a new repository has been added based on the test
branch in testrepo.git. It contains a "e90810b" tag that looks like
this:

    object e90810b8df3e80c413d903f631643c716887138d
    type commit
    tag e90810b

    This is a very simple tag.
2011-10-12 16:06:25 -07:00
Brodie Rao
04f788023f commit: properly parse empty commit messages
This ensures commit->message is always non-NULL, even if the commit
message is empty or consists of only a newline.

One such commit can be found in the wild in the jQuery repository:

25b424134f
2011-10-12 15:14:25 -07:00
Carlos Martín Nieto
9ac581bf7f config: behave like git with [section.subsection]
The documentation is a bit misleading. The subsection name is always
case-sensitive, but with a [section.subsection] header, the subsection
is transformed to lowercase when the configuration is parsed.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 19:58:26 +02:00
Vicent Marti
107e30e9c5 core: One last long long 2011-09-30 16:25:03 +02:00
Vicent Marti
fafd471021 config: Proper type declarations for 64 bit ints 2011-09-30 16:08:41 +02:00
Carlos Martín Nieto
40fe5fbea8 Make repo config loading automatic or completely explicit
git_repository_config wants to take the global and system paths again
so that one can be explicit if needed.

The git_repository_config_autoload function is provided for the cases
when it's good enough for the library to guess where those files are
located.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-27 14:40:56 +02:00
Vicent Martí
5911639235 Merge pull request #427 from schu/fix-unused-parameters
t18-status.c: fix unused warnings
2011-09-27 05:35:34 -07:00
Vicent Marti
01d7fded1b Revert "Rewrite getenv to use Win32 version on Windows"
This reverts commit e1b8644467.
2011-09-27 14:33:18 +02:00
schu
ddeaa7fb68 t18-status.c: fix unused warnings
Signed-off-by: schu <schu-github@schulog.org>
2011-09-24 13:41:10 +02:00
nulltoken
ad196c6ae6 config: make git_config_[get|set]_long() able to properly deal with 8 bytes wide values
Should fix issue #419.

Signed-off-by: nulltoken <emeric.fermas@gmail.com>
2011-09-22 18:58:47 +02:00