Commit Graph

2092 Commits

Author SHA1 Message Date
Carlos Martín Nieto
f7367993cb revwalk: add convenience function to push/hide HEAD
It's not unusual to want the walker to act on HEAD, so add a
convencience function for the case that the user doesn't already have
a resolved HEAD reference.
2012-02-27 22:26:37 +01:00
Carlos Martín Nieto
f0fa1c1a73 Add revwalk glob test 2012-02-27 22:07:20 +01:00
Carlos Martín Nieto
155aca2da7 revwalk: introduce pushing and hiding by glob
git_revwalk_{push,hide}_glob() lets you push the OIDs of references
that match the specified glob. This is the basics for what git.git
does with the rev-list options --branches, --tags, --remotes and
--glob.
2012-02-27 22:00:27 +01:00
Carlos Martín Nieto
8f7be6ca8a Move revwalk test to clar 2012-02-27 21:38:22 +01:00
Vicent Martí
eb8f90e523 buffer: Null terminate on rtrim 2012-02-27 17:22:51 +01:00
Vicent Martí
44b1ff4c12 filter: Apply filters before writing a file to the ODB
Initial implementation. The relevant code is in `blob.c`: the blob write
function has been split into smaller functions.

	- Directly write a file to the ODB in streaming mode

	- Directly write a symlink to the ODB in direct mode

	- Apply a filter, and write a file to the ODB in direct mode

When trying to write a file, we first call `git_filter__load_for_file`,
which populates a filters array with the required filters based on the
filename.

If no filters are resolved to the filename, we can write to the ODB in
streaming mode straight from disk. Otherwise, we load the whole file in
memory and use double-buffering to apply the filter chain. We finish
by writing the file as a whole to the ODB.
2012-02-27 05:30:07 +01: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
Vicent Martí
e07c2d225d Merge pull request #574 from carlosmn/remotes
Add git_remote_list()
2012-02-26 10:45:23 -08:00
Carlos Martín Nieto
8171998f8d Add git_remote_list()
Loops through the configuration and generates a list of configured
remotes.
2012-02-26 19:15:36 +01:00
Carlos Martín Nieto
6b63589e35 config: add more comprehensive multivar tests 2012-02-25 19:01:02 +01:00
Carlos Martín Nieto
0a43d7cb19 config: correctly deal with setting a multivar with regex where there are no matches
We used to erroneously consider "^$" as a special case for appending a
value to a multivar. This was a misunderstanding and we should always
append a value if there are no existing values that match.

While we're in the area, replace all the variables in-memory in one
swoop and then replace them on disk so as to avoid matching a value
we've just introduced.
2012-02-25 19:00:06 +01:00
Carlos Martín Nieto
9554cd514c A remote exists with an URL alone
We used to consider it an error if a remote didn't have at least a
fetch refspec. This was too much checking, as a remote doesn't in fact
need to have anything other than an URL configured to be considered
a remote.
2012-02-24 12:14:26 +01:00
Paul Betts
1db9d2c3bb Ensure that commits don't fail if committing content that already exists
Making a commit that results in a blob that already exists in the ODB (i.e.
committing something, then making a revert commit) will result in us trying
to p_rename -> MoveFileExW a temp file into the existing ODB entry. Despite
the MOVEFILE_REPLACE_EXISTING flag is passed in, Win32 does not care and
fails it with STATUS_ACCESS_DENIED.

To fix this, we p_unlink the ODB entry before attempting to rename it. This
call will typically fail, but we don't care, we'll let the p_rename fail if
the file actually does exist and we couldn't delete it for some reason (ACLs,
etc).
2012-02-23 17:11:20 -08:00
Vicent Martí
34ab819ef9 Merge pull request #573 from schu/tests-notes-fix
tests-clar/notes: init oid before using
2012-02-23 14:45:40 -08:00
schu
aa4254d92e tests-clar/notes: init oid before using
Reported-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: schu <schu-github@schulog.org>
2012-02-23 23:38:48 +01:00
Carlos Martín Nieto
82ccb87ef6 tree: break out on write error
If write_tree() returs an error, we used to set the error message and
continued looping. Exit the loop so we return the error.
2012-02-23 23:00:45 +01:00
Russell Belfer
f01fa26690 Fix workdir iterator unit tests
This test is fragile if you leave extra files in the test
data directory, such as a foo.c~ file from editing with
Emacs.  Who would do such a thing?
2012-02-23 11:17:48 -08:00
Russell Belfer
290f240ee0 Fix readdir usage across platforms
This fixes the missing readdir_r from win32 and fixes other
platforms to always use the reentrant readdir_r form for reading
directory contents.
2012-02-23 11:16:47 -08:00
Russell Belfer
1ec1de6d43 Fix warnings about type conversion on win32 2012-02-23 11:15:45 -08:00
Vicent Martí
df16fbcf36 Merge pull request #572 from schu/fix-warning-uninitialized
Fix -Wuninitialized warning
2012-02-23 08:18:54 -08:00
schu
0126954007 Fix -Wuninitialized warning
Signed-off-by: schu <schu-github@schulog.org>
2012-02-23 16:51:07 +01:00
Vicent Martí
36d72a5125 Merge pull request #570 from arrbee/uniform-iterators
Uniform iterators for trees, index, and workdir
2012-02-22 16:06:33 -08:00
Russell Belfer
0534641dfe Fix iterators based on pull request feedback
This update addresses all of the feedback in pull request #570.

The biggest change was to create actual linked list stacks for
storing the tree and workdir iterator state.  This cleaned up
the code a ton.  Additionally, all of the static functions had
their 'git_' prefix removed, and a lot of other unnecessary
changes were removed from the original patch.
2012-02-22 15:15:35 -08:00
Russell Belfer
da337c8064 Iterator improvements from diff implementation
This makes two changes to iterator behavior: first, advance
can optionally do the work of returning the new current value.
This is such a common pattern that it really cleans up usage.

Second, for workdir iterators, this removes automatically
iterating into directories.  That seemed like a good idea,
but when an entirely new directory hierarchy is introduced
into the workdir, there is no reason to iterate into it if
there are no corresponding entries in the tree/index that it
is being compared to.

This second change actually wasn't a lot of code because not
descending into directories was already the behavior for
ignored directories.  This just extends that to all directories.
2012-02-22 11:22:33 -08:00
Vicent Martí
8d36b253e2 Merge pull request #565 from carlosmn/multimap
Add config multivar support
2012-02-22 11:12:20 -08:00
Vicent Martí
20ed8983ea Merge pull request #571 from saurik/development
Export parse_tag_buffer as git_tag__parse_buffer.
2012-02-22 11:09:48 -08:00
Jay Freeman (saurik)
b60deb0235 Export parse_tag_buffer as git_tag__parse_buffer. 2012-02-22 04:45:30 +00:00
Russell Belfer
b6c93aef42 Uniform iterators for trees, index, and workdir
This create a new git_iterator type of object that provides a
uniform interface for iterating over the index, an arbitrary
tree, or the working directory of a repository.

As part of this, git ignore support was extended to support
push and pop of directory-based ignore files as the working
directory is being traversed (so the array of ignores does
not have to be recreated at each directory during traveral).

There are a number of other small utility functions in buffer,
path, vector, and fileops that are included in this patch
that made the iterator implementation cleaner.
2012-02-21 14:46:24 -08:00
Carlos Martín Nieto
9c94a356cc Fix check for writing remote's fetch and push configurations
Fix copy-paste error
2012-02-21 12:15:23 +01:00
Vicent Martí
481f5e2721 Merge pull request #568 from carlosmn/remotes
Remotes improvements
2012-02-20 11:35:08 -08:00
Carlos Martín Nieto
f0f3a18af6 Move git_remote_load() to git_buf 2012-02-20 19:48:41 +01:00
Carlos Martín Nieto
89e5ed98dc Add git_remote_save() 2012-02-20 19:48:41 +01:00
Carlos Martín Nieto
bcb8c007f1 Add git_remote_set_{fetch,push}spec()
Allow setting the fetch and push refspecs, which is useful for
creating new refspecs.
2012-02-20 18:42:05 +01:00
Carlos Martín Nieto
b13dbb91ea regex: fix sign warnings 2012-02-18 01:32:13 +01:00
Carlos Martín Nieto
1eaecf2f18 regex: The world uses utf-8 2012-02-18 01:31:48 +01:00
Carlos Martín Nieto
4a1ecba6d9 regex: Move the defines to a config header and include it unconditionally 2012-02-18 01:31:43 +01:00
Carlos Martín Nieto
2b15f61f48 Add GNU LGPL to COPYING 2012-02-17 22:22:12 +01:00
Carlos Martín Nieto
c17b1d0052 Add POSIX regex sources when needed
Windows doesn't support POSIX regex, so we need to include it
ourselves. The sources come from git, which in turn took them from
gawk.
2012-02-17 22:00:17 +01:00
Carlos Martín Nieto
d9da4ccaa0 Document {get,set}_multivar 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
3005855f7e Implement setting multivars 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
5e0dc4af01 Support getting multivars 2012-02-17 19:43:43 +01:00
Carlos Martín Nieto
78d65f390f tests: add multivar read test 2012-02-17 19:43:43 +01:00
Carlos Martín Nieto
0774d94d31 Store multivars in the multimap 2012-02-17 19:43:43 +01:00
Carlos Martín Nieto
fefd4551a5 First round of config multimap changes
Move the configuration to use a multimap instead of a list. This
commit doesn't provide any functional changes but changes the support
structures.
2012-02-17 19:43:43 +01:00
Vicent Martí
555c81f335 Merge pull request #563 from schu/notes-fixup
notes: fix assert
2012-02-16 04:22:56 -08:00
schu
0691966a73 notes: fix assert
Hopefully fix issue "Don't sleep and code" - #558.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-16 12:01:09 +01:00
Vicent Martí
6117895fef Merge pull request #558 from schu/notes-api
Notes API
2012-02-15 11:38:40 -08:00
schu
bf477ed4a8 Add git notes API
This commit adds basic git notes support to libgit2, namely:

* git_note_read
* git_note_message
* git_note_oid
* git_note_create
* git_note_remove

In the long run, we probably want to provide some convenience callback
mechanism for merging and moving (filter-branch) notes.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-15 20:32:14 +01:00
Vicent Martí
0c3bae6268 zlib: Remove custom git2/zlib.h header
This is legacy compat stuff for when `deflateBound` is not defined, but
we're not embedding zlib and that function is always available. Kill
that with fire.
2012-02-15 16:56:56 +01:00
schu
905919e63b util: add git__ishex
git__ishex allows to check if a string is a hexadecimal representation.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-15 13:07:50 +01:00