Commit Graph

4865 Commits

Author SHA1 Message Date
Russell Belfer
57908bb3a3 Ensure reuc vector is always valid
In theory, if there was a problem reading the REUC data, the
read_reuc() routine could have left uninitialized and invalid
data in the git_index vector.  This moves the line that inserts a
new entry into the vector down to the bottom of the routine so we
know all the content is already valid.  Also, per @linquize, this
uses calloc to ensure no uninitialized data.
2013-05-16 11:03:55 -07:00
Russell Belfer
4a782c82ef Merge pull request #1574 from linquize/calloc
Use calloc() for safety
2013-05-16 11:02:30 -07:00
Russell Belfer
8d78400142 Make examples/diff.c compile vs threadsafe library 2013-05-16 10:43:10 -07:00
Russell Belfer
58206c9ae7 Add cat-file example and increase const use in API
This adds an example implementation that emulates git cat-file.
It is a convenient and relatively simple example of getting data
out of a repository.

Implementing this also revealed that there are a number of APIs
that are still not using const pointers to objects that really
ought to be.  The main cause of this is that `git_vector_bsearch`
may need to call `git_vector_sort` before doing the search, so a
const pointer to the vector is not allowed.  However, for tree
objects, with a little care, we can ensure that the vector of
tree entries is always sorted and allow lookups to take a const
pointer.  Also, the missing const in commit objects just looks
like an oversight.
2013-05-16 10:38:27 -07:00
Linquize
7026ad893b calloc() to initialize memory 2013-05-16 21:11:38 +08:00
Vicent Martí
12f831fa15 Merge pull request #1586 from jamill/fetch_fix
Fetch should not fail when remote HEAD reference is not present locally
2013-05-16 04:41:05 -07:00
Vicent Martí
54e489c21e Merge pull request #1579 from arrbee/index-entry-dup-and-free
Index entry dup and free
2013-05-15 16:35:47 -07:00
Russell Belfer
89251b283b Update index.h docs
Move the git_index_entry to the very top, since it provides the
main structure that needs to be understood by the reader, then
move the bitmasks for the flags and the flags_extended under that
since they are details for looking at particular fields of the
structure.
2013-05-15 16:25:11 -07:00
Russell Belfer
96c01991c1 Remove entry dup/free functions and fix comments
This removes the functions to duplicate and free copies of a
git_index_entry and updates the comments to explain that you
should just use the public definition of the struct as needed.
2013-05-15 16:13:04 -07:00
Russell Belfer
797dfb28fe Add APIs to dup and free git_index_entrys
This adds git_index_entry_dup to make a copy of an existing entry
and git_index_entry_free to release the memory of the copy.  It
also updates the documentation for git_index_get_bypath and
git_index_get_byindex to make it clear that the returned structure
should *not* be modified.
2013-05-15 16:11:31 -07:00
Russell Belfer
487884a930 Improve docs for git_index_entry flag masks
The constants for extracting data from git_index_entry flags and
flags_extended are not named in a way that makes it easy to know
where to use each one.  This improves the docs for the flags (and
slightly reorganizes them), so it should be more obvious.
2013-05-15 16:11:31 -07:00
Vicent Martí
7159620044 Merge pull request #1588 from arrbee/fixes-for-checkout-and-diff
Bug fixes for checkout and diff
2013-05-15 15:47:46 -07:00
Vicent Martí
6957f73cc1 Merge pull request #1578 from nulltoken/fix/whitespaces
Fix trailing whitespaces
2013-05-15 15:47:20 -07:00
Russell Belfer
72b3dd4a5c Use GIT_IDXENTRY_STAGE macro
Since I added the GIT_IDXENTRY_STAGE macro to extract the stage
from a git_index_entry, we probably don't need an internal inline
function to do the same thing.
2013-05-15 15:23:33 -07:00
Russell Belfer
09fae31d45 Improve robustness of diff rename detection
Under some strange circumstances, diffs can end up listing files
that we can't actually open successfully.  Instead of aborting
the git_diff_find_similar, this makes it so that those files just
won't be considered as valid rename/copy targets instead.
2013-05-15 14:58:26 -07:00
Russell Belfer
dcb0f7c061 Fix checkout of submodules with no .gitmodules
It is possible for there to be a submodule in a repository with
no .gitmodules file (for example, if the user forgot to commit
the .gitmodules file).  In this case, core Git will just create
an empty directory as a placeholder for the submodule but
otherwise ignore it.  We were generating an error and stopping
the checkout.  This makes our behavior match that of core git.
2013-05-15 14:54:02 -07:00
Russell Belfer
55d3a39098 Remove old symlinks before updating
Unlike blob updates, symlink updates cannot be done "in place"
writing over an old symlink.  This means that in checkout when we
realize that we can safely update a symlink, we still need to
remove the old one before writing the new.
2013-05-15 14:52:12 -07:00
Russell Belfer
79ef3be449 Fix diff crash when last item is untracked dir
When the last item in a diff was an untracked directory that only
contained ignored items, the loop to scan the contents would run
off the end of the iterator and dereference a NULL pointer.  This
includes a test that reproduces the problem and a fix.
2013-05-15 14:50:05 -07:00
nulltoken
1fed6b07f0 Fix trailing whitespaces 2013-05-15 22:41:30 +02:00
Jameson Miller
6fe02c11a6 Fetch should not fail when remote HEAD reference is not present locally 2013-05-15 14:44:35 -04:00
Brad Morgan
84ac625ddd Added GITERR_CHECK_ALLOC 2013-05-15 12:51:40 -04:00
Brad Morgan
a6b79b9bdc Changed case of FindLibSSH2.cmake to FindLIBSSH2.cmake 2013-05-15 12:49:15 -04:00
Brad Morgan
6cbbd73935 Renamed FindLibSSH2.cmake 2013-05-15 12:48:43 -04:00
Brad Morgan
ccaee222a1 Added GITERR_CHECK_ALLOC 2013-05-15 12:46:33 -04:00
Brad Morgan
e057e41122 Reworked git_cred_ssh_keyfile_passphrase_new method 2013-05-15 12:44:51 -04:00
Brad Morgan
b54ed3efe8 Added error check 2013-05-15 12:41:16 -04:00
Brad Morgan
22011b33da Cleanup 2013-05-15 12:38:40 -04:00
Vicent Marti
f0ab73720a signature: Lenient when dupping, strict when creating 2013-05-15 17:51:57 +02:00
Vicent Martí
86c6f74a79 Merge pull request #1583 from linquize/whitespace
Unify whitespaces to tabs
2013-05-15 08:31:37 -07:00
Linquize
0cb16fe924 Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
Russell Belfer
bc2020d648 Extend valgrind suppressions on Mac 2013-05-14 16:39:19 -07:00
Russell Belfer
00384321d3 Merge pull request #1580 from carlosmn/cmake-describe
CMake: vendor strings
2013-05-14 16:24:16 -07:00
Russell Belfer
33539b109c Merge pull request #1582 from dmgctrl/checkout_symlink_fix
Create directory for symlink before creating symlink
2013-05-14 15:05:52 -07:00
Russell Belfer
103a2c7727 Merge pull request #1581 from nulltoken/fix/leaks
Fix some memory leaks
2013-05-14 15:04:16 -07:00
Carlos Martín Nieto
3bbc87d697 CMake: allow appending a string to the library filename
This helps us install multiple versions of the library side-by-side.
2013-05-14 23:40:20 +02:00
Brad Morgan
fbcab44b20 Create directory for symlink before creating symlink 2013-05-14 16:03:09 -04:00
nulltoken
b4d33e46c4 Fix some memory leaks 2013-05-14 21:54:26 +02:00
Carlos Martín Nieto
000e68961c CMake: don't try to use bundled zlib when the system's path is in the cache
The code surrounding zlib bundling did not take into consideration
that ZLIB_LIBRARY gets cached, and assumed that FIND(ZLIB) would
always set ZLIB_FOUND, which does not hold true, as this variable
signifies that we have found the package and had to look at the
system, as its location was not cached.

Only use the bundled sources if the external zlib is neither
newly-found nor cached.
2013-05-12 15:35:02 +02:00
Carlos Martín Nieto
62221033a8 Merge pull request #1575 from arrbee/ref-iterator-early-exit
Fix refdb iteration early termination bug
2013-05-11 07:48:31 -07:00
Russell Belfer
99d32707b9 Fix refdb iteration early termination bug
There was a problem found in the Rugged test suite where the
refdb_fs_backend__next function could exit too early in some
very specific hashing patterns for packed refs.  This ports
the Rugged test to libgit2 and then fixes the bug.
2013-05-11 06:42:25 -07:00
Vicent Martí
7b5bc8f498 Merge pull request #1569 from linquize/msvc-sdl
Fix broken build when MSVC SDL checks is enabled
2013-05-11 05:15:00 -07:00
Linquize
e583334c00 Fix broken build when MSVC SDL checks is enabled 2013-05-11 20:13:26 +08:00
Edward Thomson
b6cc559a78 Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
2013-05-11 02:42:49 -07:00
Carlos Martín Nieto
c58cac12c2 Introduce a glob-filtering iterator
If the backend doesn't provide support for it, the matching is done in
refdb on top of a normal iterator.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
9bd89d9622 Move a couple more functions to use iterators 2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
2b562c3a1e refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
95727245fd refs: implement _foreach with the iterator 2013-05-11 11:20:37 +02:00
Carlos Martín Nieto
932af0e9eb Add iterator support to the testdb backend 2013-05-11 11:20:37 +02:00
Carlos Martín Nieto
fb592a96eb Remove outdated test
Selecting wether to list loose or packed references is not something
we want to support anymore, so remove a test for this.
2013-05-11 11:20:37 +02:00
Carlos Martín Nieto
51fc5e895d Make sure the ref iterator works in an repo without physical presence 2013-05-11 11:20:37 +02:00