Commit Graph

573 Commits

Author SHA1 Message Date
Vicent Martí
c261c272af Merge pull request #702 from arrbee/fix-status-file
Update git_status_file and add ranged iterators
2012-05-16 09:57:45 -07:00
Russell Belfer
41a82592ef Ranged iterators and rewritten git_status_file
The goal of this work is to rewrite git_status_file to use the
same underlying code as git_status_foreach.

This is done in 3 phases:

1. Extend iterators to allow ranged iteration with start and
   end prefixes for the range of file names to be covered.
2. Improve diff so that when there is a pathspec and there is
   a common non-wildcard prefix of the pathspec, it will use
   ranged iterators to minimize excess iteration.
3. Rewrite git_status_file to call git_status_foreach_ext
   with a pathspec that covers just the one file being checked.

Since ranged iterators underlie the status & diff implementation,
this is actually fairly efficient.  The workdir iterator does
end up loading the contents of all the directories down to the
single file, which should ideally be avoided, but it is pretty
good.
2012-05-15 14:34:15 -07:00
Carlos Martín Nieto
73d87a091c Introduce GITERR_INDEXER 2012-05-15 21:42:20 +02:00
Vicent Martí
87d6138e2e Merge pull request #696 from nulltoken/topic/notes-list
Add git_note_foreach()
2012-05-14 13:17:19 -07:00
Vicent Martí
79fdde494f Revert "Specifiy dllimport to MSVC if we're not building libgit2.dll"
This reverts commit 1093e2de22.
2012-05-14 22:15:53 +02:00
nulltoken
86ecd84427 notes: add git_notes_foreach() 2012-05-14 22:07:42 +02:00
Sascha Cunz
1093e2de22 Specifiy dllimport to MSVC if we're not building libgit2.dll
Building a "shared object" (DLL) in Windows includes 2 steps:

- specify __declspec(dllexport)
  when building the library itself. MSVC will disallow itself from
  optimizing these symbols out and reference them in the PE's
  Exports-Table.
  Further, a static link library will be generated. This library
  contains the symbols which are exported via the declsepc above.
  The __declspec(dllexport) becomes part of the symbol-signature
  (like parameter types in C++ are 'mangled' into the symbol name,
  the export specifier is mingled with the name)

- specify __declspec(dllimport)
  when using the library. This again mingles the declspec into the
  name and declares the function / variable with external linkage.

cmake automatically adds -Dgit2_EXPORTS to the compiler arguments
when compiling the libgit2 project.
The 'git2' is the name specified via PROJECT() in CMakeLists.txt.
2012-05-14 20:22:50 +02:00
Vicent Martí
e49cb1687e Merge pull request #671 from nulltoken/topic/blob_create_fromdisk
Add git_blob_create_fromdisk()
2012-05-14 11:03:30 -07:00
Vicent Martí
72bfde9790 Merge pull request #681 from scottjg/solaris-fixes
Fix build/runtime issues on Solaris
2012-05-14 11:01:14 -07:00
Vicent Martí
27f5b7cfed Merge pull request #682 from arrbee/attribute-cache-buster
Attribute cache buster
2012-05-14 10:58:23 -07:00
Sascha Cunz
0c9a5565f7 Add missing GIT_EXTERN declarations 2012-05-14 19:56:35 +02:00
nulltoken
6ca9643c96 blob: Add git_blob_create_fromdisk()
This function will create blobs in the object database from files anywhere on the filesystem. This can be run against bare and non-bare repositories.
2012-05-13 11:28:49 +02:00
Ben Straub
bfc13e7985 Adding comment documentation for rev-parse api. 2012-05-11 11:30:46 -07:00
Ben Straub
ac250c56c7 First stab at implementation of rev-parse.
This version supports refspecs of these kinds:
- Full & partial SHAs
- Output from "git describe"
- "/refs/heads/master" (full ref names)
- "master" (partial ref names)
- "FETCH_HEAD" (named heads)
2012-05-11 11:30:45 -07:00
Scott J. Goldman
b1ec25facc Fix comment typo in common.h 2012-05-10 17:16:38 -07:00
Russell Belfer
dc13f1f7d7 Add cache busting to attribute cache
This makes the git attributes and git ignores cache check
stat information before using the file contents from the
cache.  For cached files from the index, it checks the SHA
of the file instead.  This should reduce the need to ever
call `git_attr_cache_flush()` in most situations.

This commit also fixes the `git_status_should_ignore` API
to use the libgit2 standard parameter ordering.
2012-05-10 11:12:43 -07:00
Vicent Martí
c99bdacf71 Merge pull request #670 from nulltoken/ntk/topic/clean-commit_message
Clean commit and tag messages
2012-05-08 14:13:43 -07:00
Russell Belfer
364f51bdca Merge pull request #668 from nulltoken/topic/binary-blobs
Enhancing the blob diffing experience
2012-05-08 13:56:21 -07:00
Carlos Martín Nieto
baaa8a447e remotes: change git_remote_new's signature
Add a fetch refspec arguemnt and make the arguments (name, url,
refspec), as that order makes more sense.
2012-05-08 21:36:40 +02:00
Carlos Martín Nieto
a209a025c6 remote: add git_remote_add()
Helper function to create a remote with the default settings
2012-05-08 21:36:40 +02:00
nulltoken
d1c4312a02 diff: improve git_diff_blobs() documentation 2012-05-07 12:18:34 +02:00
nulltoken
28ef7f9b28 diff: make git_diff_blobs() able to detect binary blobs 2012-05-07 12:18:32 +02:00
nulltoken
458b94503d commit/tag: ensure the message is cleaned up
'git commit' and 'git tag -a' enforce some conventions, like cleaning up excess whitespace and making sure that the last line ends with a '\n'. This fix replicates this behavior.

Fix libgit2/libgit2sharp#117
2012-05-07 12:16:04 +02:00
Vicent Martí
4ef14af935 Merge pull request #664 from arrbee/attrs-from-index
Support git attrs from index (and bare repo)
2012-05-05 14:22:06 -07:00
Russell Belfer
b709e95146 Fix memory leaks and use after free 2012-05-04 11:06:12 -07:00
Russell Belfer
f917481ee8 Support reading attributes from index
Depending on the operation, we need to consider gitattributes
in both the work dir and the index.  This adds a parameter to
all of the gitattributes related functions that allows user
control of attribute reading behavior (i.e. prefer workdir,
prefer index, only use index).

This fix also covers allowing us to check attributes (and
hence do diff and status) on bare repositories.

This was a somewhat larger change that I hoped because it had
to change the cache key used for gitattributes files.
2012-05-03 16:37:25 -07:00
Michael Schubert
630c5a4a54 notes: add git_note_default_ref()
Add git_note_default_ref to allow easy retrieval of the currently set
default notes reference.
2012-05-03 22:31:29 +02:00
Vicent Martí
3fbcac89c4 Remove old and unused error codes 2012-05-02 19:56:38 -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
16b83019af Fix usage of "new" for fieldname in public header
This should restore the ability to include libgit2 headers
in C++ projects.

Cherry picked 2de60205df from
development into new-error-handling.
2012-05-02 15:34:58 -07:00
Vicent Martí
b88021463f Merge remote-tracking branch 'carlosmn/remaining-errors' into new-error-handling
Conflicts:
	src/refspec.c
2012-05-01 19:16:14 -07:00
nulltoken
1d2dd864ad diff: provide more context to the consumer of the callbacks
Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
2012-04-30 07:12:26 +02:00
Michael Schubert
8af503bc85 remote: add more doc on git_remote_free 2012-04-28 20:49:05 +02:00
Carlos Martín Nieto
3aa351ea0f error handling: move the missing parts over to the new error handling 2012-04-26 15:38:42 +02:00
Carlos Martín Nieto
f184836bd2 remote: run a callback when updating the branch tips
This allows the caller to update an internal structure or update the
user output with the tips that were updated.

While in the area, only try to update the ref if the value is
different from its old one.
2012-04-25 13:25:45 +02:00
Carlos Martín Nieto
dee5515a23 transports: buffer the git requests before sending them
Trying to send every single line immediately won't give us any speed
improvement and duplicates the code we need for other transports. Make
the git transport use the same buffer functions as HTTP.
2012-04-25 12:44:27 +02:00
Carlos Martín Nieto
7a520f5d8a fetch: use the streaming indexer when downloading a pack
This changes the git_remote_download() API, but the existing one is
silly, so you don't get to complain.

The new API allows to know how much data has been downloaded, how many
objects we expect in total and how many we've processed.
2012-04-25 12:39:11 +02:00
Vicent Martí
f9f2344bd4 Merge pull request #632 from arrbee/win64-cleanup
Code clean up, including fixing warnings on Windows 64-bit build
2012-04-23 17:28:11 -07:00
Russell Belfer
26515e73a1 Rename to git_reference_name_to_oid 2012-04-23 10:06:31 -07:00
Sven Strickroth
c02f13925a Check for _WIN32 is sufficient, even for x64 compilers
There is no need to check for _WIN32 and _WIN64. x64 compiler also set _WIN32 (compare http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#Windows).

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2012-04-21 18:43:10 +02:00
Vicent Martí
d59305544e Merge remote-tracking branch 'carlosmn/indexer-stream' into new-error-handling 2012-04-19 11:40:56 -07:00
Russell Belfer
f201d613a8 Add git_reference_lookup_oid and lookup_resolved
Adds a new public reference function `git_reference_lookup_oid`
that directly resolved a reference name to an OID without returning
the intermediate `git_reference` object (hence, no free needed).

Internally, this adds a `git_reference_lookup_resolved` function
that combines looking up and resolving a reference.  This allows
us to be more efficient with memory reallocation.

The existing `git_reference_lookup` and `git_reference_resolve`
are reimplmented on top of the new utility and a few places in the
code are changed to use one of the two new functions.
2012-04-17 10:44:50 -07:00
Russell Belfer
14a513e058 Add support for pathspec to diff and status
This adds preliminary support for pathspecs to diff and status.
The implementation is not very optimized (it still looks at
every single file and evaluated the the pathspec match against
them), but it works.
2012-04-13 15:00:29 -07:00
Carlos Martín Nieto
1c9c081a6a indexer: add git_indexer_stream_free() and _hash() 2012-04-13 22:19:45 +02:00
Carlos Martín Nieto
453ab98da0 indexer: Add git_indexer_stream_finalize()
Resolve any lingering deltas, write out the index file and rename the
packfile.
2012-04-13 22:19:45 +02:00
Carlos Martín Nieto
3f93e16cff indexer: start writing the stream indexer
This will allow us to index a packfile as soon as we receive it from
the network as well as storing it with its final name so we don't need
to pass temporary file names around.
2012-04-13 22:19:44 +02:00
Vicent Martí
d1f331564d Merge remote-tracking branch 'carlosmn/revwalk-merge-base' into new-error-handling 2012-04-13 20:41:06 +02:00
Carlos Martín Nieto
bf787bd87c Move git_merge_base() to is own header and document it 2012-04-12 20:25:25 +02:00
Carlos Martín Nieto
de7ab85dc6 Implement git_merge_base()
It's implemented in revwalk.c so it has access to the revision
walker's commit cache and related functions. The algorithm is the one
used by git, modified so it fits better with the library's functions.
2012-04-12 20:25:24 +02:00
Carlos Martín Nieto
06b9d91590 revwalk: allow pushing/hiding a reference by name
The code was already there, so factor it out and let users push an OID
by giving it a reference name. Only refs to commits are
supported. Annotated tags will throw an error.
2012-04-12 20:25:24 +02:00
Russell Belfer
7784bcbbee Refactor git_repository_open with new options
Add a new command `git_repository_open_ext` with extended options
that control how searching for a repository will be done.  The
existing `git_repository_open` and `git_repository_discover` are
reimplemented on top of it.  We may want to change the default
behavior of `git_repository_open` but this commit does not do that.

Improve support for "gitdir" files where the work dir is separate
from the repo and support for the "separate-git-dir" config.  Also,
add support for opening repos created with `git-new-workdir` script
(although I have only confirmed that they can be opened, not that
all functions work correctly).

There are also a few minor changes that came up:

- Fix `git_path_prettify` to allow in-place prettifying.

- Fix `git_path_root` to support backslashes on Win32.  This fix
  should help many repo open/discover scenarios - it is the one
  function called when opening before prettifying the path.

- Tweak `git_config_get_string` to set the "out" pointer to NULL
  if the config value is not found.  Allows some other cleanup.

- Fix a couple places that should have been calling
  `git_repository_config__weakptr` and were not.

- Fix `cl_git_sandbox_init` clar helper to support bare repos.
2012-04-11 12:11:35 -07:00
Carlos Martín Nieto
4376f7f6f4 error-handling: remote, transport 2012-04-11 19:16:10 +02:00
Carlos Martín Nieto
1a2b87257d Typedefs don't have enum in front 2012-04-11 14:27:40 +02:00
Vicent Martí
0a20eee953 Merge pull request #619 from nulltoken/topic/branches
Basic branch management API
2012-04-11 03:43:30 -07:00
Vicent Martí
dcfdb958e2 Merge branch 'new-error-handling' of github.com:libgit2/libgit2 into new-error-handling 2012-04-11 12:38:45 +02:00
nulltoken
4615f0f71b branch: add git_branch_move() 2012-04-10 21:39:06 +02:00
nulltoken
731df57080 Add basic branch management API: git_branch_create(), git_branch_delete(), git_branch_list() 2012-04-10 21:39:03 +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í
73fe6a8e20 error-handling: Commit (WIP) 2012-04-02 20:41:48 +02:00
Russell Belfer
95dfb031f7 Improve config handling for diff,submodules,attrs
This adds support for a bunch of core.* settings that affect
diff and status, plus fixes up some incorrect implementations
of those settings from before.  Also, this cleans up the
handling of config settings in the new submodules code and
in the old attrs/ignore code.
2012-03-30 14:40:50 -07:00
Russell Belfer
bfc9ca595a Added submodule API and use in status
When processing status for a newly checked out repo, it is
possible that there will be submodules that have not yet been
initialized.  The only way to distinguish these from untracked
directories is to have some knowledge of submodules.  This
commit adds a new submodule API which, given a name or path,
can determine if it appears to be a submodule and can give
information about the submodule.
2012-03-28 16:45:36 -07:00
Russell Belfer
4b136a94d9 Fix crash in new status and add recurse option
This fixes the bug that @nulltoken found (thank you!) where
if there were untracked directories alphabetically after the
last tracked item, the diff implementation would deref a NULL
pointer.

The fix involved the code which decides if it is necessary
to recurse into a directory in the working dir, so it was
easy to add a new option `GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS`
to control if the contents of untracked directories should be
included in status.
2012-03-23 09:26:09 -07:00
Russell Belfer
66142ae031 New status fixes
This adds support for roughly-right tracking of submodules
(although it does not recurse into submodules to detect
internal modifications a la core git), and it adds support
for including unmodified files in diff iteration if requested.
2012-03-22 10:44:36 -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
Russell Belfer
a48ea31d69 Reimplment git_status_foreach using git diff
This is an initial reimplementation of status using diff a la
the way that core git does it.
2012-03-21 12:33:09 -07:00
schu
7826d57759 diff_output: remove unused parameter
Signed-off-by: schu <schu-github@schulog.org>
2012-03-21 11:56:01 +01:00
Russell Belfer
7c7ff7d11e Migrate index, oid, and utils to new errors
This includes a few cleanups that came up while converting
these files.

This commit introduces a could new git error classes, including
the catchall class: GITERR_INVALID which I'm using as the class
for invalid and out of range values which are detected at too low
a level of library to use a higher level classification.  For
example, an overflow error in parsing an integer or a bad letter
in parsing an OID string would generate an error in this class.
2012-03-19 16:10:11 -07:00
Russell Belfer
e3c4751070 Resolve comments from pull request
This converts the map validation function into a macro, tweaks
the GITERR_OS system error automatic appending, and adds a
tentative new error access API and some quick unit tests for
both the old and new error APIs.
2012-03-13 14:23:24 -07:00
Russell Belfer
e1de726c15 Migrate ODB files to new error handling
This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to
the new style of error handling.  Also got the unix and win32
versions of map.c.  There are some minor changes to other
files but no others were completely converted.

This also contains an update to filebuf so that a zeroed out
filebuf will not think that the fd (== 0) is actually open
(and inadvertently call close() on fd 0 if cleaned up).

Lastly, this was built and tested on win32 and contains a
bunch of fixes for the win32 build which was pretty broken.
2012-03-12 22:55:40 -07:00
Vicent Martí
dda708e78f error-handling: On-disk config file backend
Includes:

	- Proper error reporting when encountering syntax errors in a
	config file (file, line number, column).

	- Rewritten `config_write`, now with 99% less goto-spaghetti

	- Error state in `git_filebuf`: filebuf write functions no longer
	need to be checked for error returns. If any of the writes performed
	on a buffer fail, the last call to `git_filebuf_commit` or
	`git_filebuf_hash` will fail accordingly and set the appropiate error
	message. Baller!
2012-03-09 20:09:22 +01:00
Vicent Martí
e54d8d8972 error-handling: Config 2012-03-07 01:37:09 +01: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
Carlos Martín Nieto
864ac49e31 Merge branch 'ssh-urls' into development 2012-03-05 19:32:41 +01:00
Carlos Martín Nieto
4f8efc97c1 Make git_remote_supported_url() public and shorten error string 2012-03-05 19:32:21 +01:00
Russell Belfer
2de60205df Fix usage of "new" for fieldname in public header
This should restore the ability to include libgit2 headers
in C++ projects.
2012-03-04 23:28:36 -08:00
Vicent Martí
45d387ac78 refs: Error handling rework. WIP 2012-03-03 02:28:50 +01:00
Vicent Martí
60bc2d20c4 error-handling: Add new routines
Obviously all the old throw routines are still in place, so we can
gradually port over.
2012-03-03 02:28:00 +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
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
a2e895be82 Continue implementation of git-diff
* Implemented git_diff_index_to_tree
* Reworked git_diff_options structure to handle more options
* Made most of the options in git_diff_options actually work
* Reorganized code a bit to remove some redundancy
* Added option parsing to examples/diff.c to test most options
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
65b09b1ded Implement diff lists and formatters
This reworks the diff API to separate the steps of producing
a diff descriptions from formatting the diff.  This will allow
us to share diff output code with the various diff creation
scenarios and will allow us to implement rename detection as
an optional pass that can be run on a diff list.
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
Vicent Martí
e3d55b2add Merge pull request #575 from libgit2/filters
Filters, yo
2012-03-02 15:44:15 -08:00
Vicent Martí
c63793ee81 attr: Change the attribute check macros
The point of having `GIT_ATTR_TRUE` and `GIT_ATTR_FALSE` macros is to be
able to change the way that true and false values are stored inside of
the returned gitattributes value pointer.

However, if these macros are implemented as a simple rename for the
`git_attr__true` pointer, they will always be used with the `==`
operator, and hence we cannot really change the implementation to any
other way that doesn't imply using special pointer values and comparing
them!

We need to do the same thing that core Git does, which is using a
function macro. With `GIT_ATTR_TRUE(attr)`, we can change
internally the way that these values are stored to anything we want.

This commit does that, and rewrites a large chunk of the attributes test
suite to remove duplicated code for expected attributes, and to
properly test the function macro behavior instead of comparing
pointers.
2012-03-02 03:51:45 +01:00
Vicent Martí
c5e944820a config: Refactor & add git_config_get_mapped
Sane API for real-world usage.
2012-03-01 00:52:21 +01:00
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
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
8171998f8d Add git_remote_list()
Loops through the configuration and generates a list of configured
remotes.
2012-02-26 19:15:36 +01:00
Vicent Martí
8d36b253e2 Merge pull request #565 from carlosmn/multimap
Add config multivar support
2012-02-22 11:12:20 -08: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
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
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
b4b79ac3db commit: actually allow yet to be born update_ref
git_commit_create is supposed to update the given reference
"update_ref", but segfaulted in case of a yet to be born
reference. Fix it.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-15 13:07:41 +01:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Vicent Martí
242a1cea8d libgit2 v0.16.0 "Dutch Fries"
This lovely and much delayed release of libgit2 ships from the cold city
of Brussels, which is currently hosting FOSDEM 2012.

There's been plenty of changes since the latest stable release, here's a
full summary:

- Git Attributes support (see git2/attr.h)
	There is now support to efficiently parse and retrieve information
	from `.gitattribute` files in a repository. Note that this
	information is not yet used e.g. when checking out files.

- .gitignore support
	Likewise, all the operations that are affected by `.gitignore` files
	now take into account the global, user and local ignores when
	skipping the relevant files.

- Cleanup of the object ownership semantics
	The ownership semantics for all repository subparts (index, odb,
	config files, etc) has been redesigned. All these objects are now
	reference counted, and can be hot-swapped in the middle of
	execution, allowing for instance to add a working directory and an
	index to a repository that was previously opened as bare, or to
	change the source of the ODB objects after initialization.

	Consequently, the repository API has been simplified to remove all
	the `_openX` calls that allowed setting these subparts *before*
	initialization.

- git_index_read_tree()
	Git trees can now be read into the index.

- More reflog functionality
	The reference log has been optimized, and new API calls to rename
	and delete the logs for a reference have been added.

- Rewrite of the References code with explicit ownership semantics
	The references code has been mostly rewritten to take into account
	the cases where another Git application was modifying a repository's
	references while the Library was running.

	References are now explicitly loaded and free'd by the user, and
	they may be reloaded in the middle of execution if the user suspects
	that their values may have changed on disk. Despite the new
	ownership semantics, the references API stays the same.

- Simplified the Remotes API
	Some of the more complex Remote calls have been refactored into
	higher level ones, to facilitate the usual `fetch` workflow of a
	repository.

- Greatly improved thread-safety
	The library no longer has race conditions when loading objects from
	the same ODB and different threads at the same time. There's now
	full TLS support, even for error codes. When the library is built
	with `THREADSAFE=1`, the threading support must be globally
	initialized before it can be used (see `git_threads_init()`)

- Tree walking API
	A new API can recursively traverse trees and subtrees issuing callbacks for
	every single entry.

- Tree diff API
	There is basic support for diff'ing an index against two trees.

- Improved windows support
	The Library is now codepage aware under Windows32: new API calls
	allow the user to set the default codepage for the OS in order to
	avoid strange Unicode errors.
2012-02-05 17:14:14 +01:00
Russell Belfer
cfbc880d8a Patch cleanup for merge
After reviewing the gitignore support with Vicent, we came up
with a list of minor cleanups to prepare for merge, including:

* checking git_repository_config error returns
* renaming git_ignore_is_ignored and moving to status.h
* fixing next_line skipping to include \r skips
* commenting on where ignores are and are not included
2012-01-16 15:16:44 -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í
7a704309ae Merge remote-tracking branch 'drizzd/diff-index-tests' into development
Conflicts:
	tests-clay/clay.h
	tests-clay/clay_main.c
2012-01-02 09:58:39 +01:00
Vicent Martí
9191a6d246 Merge remote-tracking branch 'arrbee/git-attributes' into development
Conflicts:
	tests-clay/clay_main.c
2012-01-02 09:56:48 +01:00
Vicent Martí
9dd4c3e806 config: Rename the delete callback name
`delete` is a reserved keyword in C++.
2011-12-31 05:58:26 +01:00
Clemens Buchacher
599f2849ba add git_index_read_tree 2011-12-30 20:14:05 +01: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
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
Carlos Martín Nieto
80a665aaca config: really delete variables
Instead of just setting the value to NULL, which gives unwanted
results when asking for that variable after deleting it, delete the
variable from the list and re-write the file.
2011-12-16 02:28:39 +01:00
Vicent Marti
e923868766 tree: recursive diff-index
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: Vicent Marti <tanoku@gmail.com>

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author:    Carlos Martín Nieto <carlos@cmartin.tk>
#
# On branch development
# Your branch is ahead of 'origin/development' by 11 commits.
#
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#	modified:   include/git2/tree.h
#	modified:   src/tree.c
#	modified:   tests-clay/clay_main.c
#	modified:   tests-clay/object/tree/diff.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	0001-remote-Cleanup-the-remotes-code.patch
#	466.patch
#	466.patch.1
#	488.patch
#	Makefile
#	libgit2.0.15.0.dylib
#	libgit2.0.dylib
#	libgit2.dylib
#	libgit2_clay
#	libgit2_test
#	tests-clay/object/tree/
2011-12-03 18:06:34 +01:00
Carlos Martín Nieto
a1fdea2855 tree: implement tree diffing
For each difference in the trees, the callback gets called with the
relevant information so the user can fill in their own data
structures.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-12-03 17:47:06 +01:00
Vicent Marti
d88d4311c7 remote: Cleanup the remotes code
- Hide the remaining transports code
- Drop `git_headarray`, switch to using a callback to list refs. Makes
the code cleaner.
2011-11-28 08:40:40 +01:00
Vicent Marti
6632c15509 Document all of the things 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
Vicent Martí
e42ea1f488 Merge pull request #491 from schu/refs-cleanup
reference_rename() cleanup
2011-11-25 21:30:08 -08:00
Vicent Marti
2869f404fd transport: Add git_transport_valid_url 2011-11-22 15:49:23 +01:00
Carlos Martín Nieto
6616e20750 Add a note not to free the result from git_remote_ls 2011-11-22 11:18:27 +01:00
Vicent Martí
bec92f78bf Merge pull request #492 from carlosmn/networking
Networking improvements
2011-11-21 17:12:23 -08:00
Vicent Marti
2744806f32 tree: Fix documentation 2011-11-22 02:10:41 +01:00
Carlos Martín Nieto
6ac3b707b1 Add git_remote_connected
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-21 21:00:43 +01:00
Carlos Martín Nieto
4cf01e9a1a Add git_remote_disconnect
It can be useful to separate disconnecting from actually destroying
the object.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-21 21:00:42 +01:00
schu
a5cd086dff reference_rename: don't delete the reflog
reference_rename used to delete an old reflog file when renaming a
reference to not confuse git.git. Don't do this anymore but let the user
take care of writing a reflog entry.

Signed-off-by: schu <schu-github@schulog.org>
2011-11-21 16:38:30 +01:00
schu
b7c93a66e2 Add git_reflog_rename() and git_reflog_delete()
Signed-off-by: schu <schu-github@schulog.org>
2011-11-21 13:15:56 +01:00
Carlos Martín Nieto
617bfdf47f Add a name to a remote created from the API
Make it a bit more resilient.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-18 21:39:34 +01:00
Carlos Martín Nieto
95057b8503 remote: get rid of git_remote_negotiate
There is no good reason to expose the negotiation as a different step
to downloading the packfile.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-18 21:18:39 +01:00
Haitao Li
28ba94ceed Fix typo in repository documentation 2011-11-18 17:47:22 +08:00
Vicent Marti
2cbca8b06c include: Unify internal include strategies
Do not add the `git2` path to internal includes, or that will cause
an extra path dependency.
2011-11-18 01:43:27 +01:00
Vicent Marti
2ba14f2367 tree: Add payload to git_tree_walk 2011-11-18 01:40:35 +01:00
Vicent Marti
9432af36fc Rename git_tree_frompath to git_tree_get_subtree
That makes more sense to me.
2011-11-18 01:40:35 +01:00
Vicent Marti
a15c550db8 threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing.

When libgit2 is built with GIT_THREADS support, the threading system
must be explicitly initialized with `git_threads_init()`.
2011-11-16 14:09:44 +01: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
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
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
Vicent Marti
da37654d04 tree: Add traversal in post-order 2011-10-27 22:33:31 -07:00
Vicent Marti
11d51ca631 windows: Add support for non-UTF codepages
Our previous assumption that all paths in Windows are encoded in UTF-8
is rather weak, specially when considering that Git is
encoding-agnostic.

These set of functions allow the user to change the library's active
codepage globally, so it is possible to access paths and files on all
international versions of Windows.

Note that the default encoding here is UTF-8 because we assume that 99%
of all Git repositories will be in UTF-8.

Also, if you use non-ascii characters in paths, anywhere, please burn on
a fire.
2011-10-26 17:43:44 -07:00
Vicent Marti
28c1451a7c tree: Fix name lookups once and for all
Double-pass binary search. Jeez.
2011-10-20 02:40:14 +02:00
Vicent Marti
8cf2de078d tree: Fix lookups by entry name 2011-10-19 01:34:42 +02:00
nulltoken
3fa735ca3b tree: Add git_tree_frompath() which, given a relative path to a tree entry, retrieves the tree object containing this tree entry 2011-10-13 23:30:07 +02:00
nulltoken
34aff01002 oid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal 2011-10-13 23:15:11 +02:00
Vicent Martí
92e2081f40 Merge pull request #449 from csware/include-win-version-information
Include windows version information in git2.dll
2011-10-12 11:03:58 -07:00
Sven Strickroth
96fab093e3 put version information in separate file
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 18:39:52 +02:00
Sven Strickroth
314f54eb06 fix build for x64
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 05:29:57 +02:00
Vicent Marti
dd3fd68266 msvc: Remove superfluous includes 2011-10-05 13:44:27 -07:00
Vicent Marti
c060854ed5 msvc: Properly handle inttypes.h/stdint.h 2011-10-05 16:21:16 -04:00
Carlos Martín Nieto
dc8e3096d6 Include stdint.h in git2/config.h
Otherwise MSVC doesn't know what we're talking about when we say
int32_t or int64_t.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 02:09:35 +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
c36280a036 repository: export git_repository_config_autoload
Take the opportunity to finish the comment about this function.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-30 06:28:22 +02:00
Vicent Marti
8af4d074cc odb: Let users decide compression level for the loose ODB 2011-09-29 15:34:17 +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
Carlos Martín Nieto
4c562347ae Add git_config_find_system
This allows the library to guess where the system configuration file
should be located.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-27 14:39:38 +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
Vicent Martí
6640266e5a Merge pull request #398 from carlosmn/config-autohome
git_repository_config: open global config file automatically
2011-09-18 19:58:22 -07:00
Vicent Martí
e311519dce Merge pull request #411 from boyski/gcc4
Don't use '__attribute__ visibility' with gcc unless it's at version 4 or better
2011-09-18 19:38:14 -07:00
David Boyce
d2a1861ea1 Don't use '__attribute__ visibility' with gcc unless it's at
version 4 or better.
2011-09-18 21:27:25 -04:00
Vicent Marti
87d9869fc3 Tabify everything
There were quite a few places were spaces were being used instead of
tabs. Try to catch them all. This should hopefully not break anything.
Except for `git blame`. Oh well.
2011-09-19 03:34:49 +03:00
Vicent Marti
bb742ede3d Cleanup legal data
1. The license header is technically not valid if it doesn't have a
copyright signature.

2. The COPYING file has been updated with the different licenses used in
the project.

3. The full GPLv2 header in each file annoys me.
2011-09-19 01:54:32 +03:00
nulltoken
56453d3468 status: enhance determination of status for a single file
- fix retrieval of a file status when working against a newly initialized repository
 - reduce memory pressure
 - prevents a directory from being tested
2011-09-15 01:14:36 +02:00
nulltoken
3601c4bfce repository: Add git_repository_head() 2011-09-15 01:13:50 +02:00
David Boyce
d911172255 Standardized doxygen @return lines for int functions to say "GIT_SUCCESS or an error code". 2011-09-13 12:30:25 -04:00
Carlos Martín Nieto
f9d4b0c395 git_repository_config: open global config file automatically
If the global configuration file is missing, it is ignored.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-12 17:25:46 +02:00
Sebastian Schuberth
26e74c6ace Fix some random size_t vs. int conversion warnings 2011-09-08 17:07:37 +02:00
Carlos Martín Nieto
778e1c739b Add git_remote_new
As we no longer expose the transport functions, this is now the only
way to connect to a remote when given an URL instead of a remote name

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-30 19:37:14 +02:00
Carlos Martín Nieto
b5a8aa94bf Don't hide the transport details
Transports shouldn't get used outside of the library, so don't expose
accessor functions.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-30 19:37:14 +02:00
Carlos Martín Nieto
a1be77cd35 Be smarter about selecting wants
There is no need to inspect what the local repository is like. Only
check whether the objects exist locally.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:09 +02:00
Carlos Martín Nieto
1564db11fe Remove enum git_whn
Instead, use flags inside the git_remote_head structure.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:09 +02:00
Carlos Martín Nieto
441f57c2b7 Add git_remote_update_tips
This function updates the references in the local reference storage to
match the ones in the remote.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
48a65a071d Only wait for pack if we need it
Provide the git_remote_download function to instruct the library to
downlad the packfile and let the user know the temporary location.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
e1d8803068 Don't expose the fetch code to the user
Move the generation of the want-list to be done from the negotiate
function, and keep the filtered references inside the remote
structure.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
65fbc48a17 negotiation 2011-08-18 02:34:07 +02:00
Carlos Martín Nieto
e1f4a76150 Add git_fetch_list_want which creates the "want" list
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
schu
e7be57a98b reflog: assimilate reflog API to return git_oid's
Rather than returning the OIDs out of the reflog as string return them
as git_oid.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-15 21:14:51 +02:00
Lambert CLARA
a6bbb8cab6 Add missing GIT_BEGIN_DECL and GIT_END_DECL to indexer header 2011-08-13 10:56:33 +02:00
Vicent Marti
5ae2f0c013 commit: Add support for Encoding header 2011-08-12 16:24:19 -07:00
Vicent Marti
b2e60e4eb5 Add common.h to types.h 2011-08-10 15:25:37 -07:00
Vicent Martí
31bf5f3857 Merge pull request #345 from carlosmn/gsoc2011/indexer
Implement a pack indexer
2011-08-03 18:59:30 -07:00
schu
63396a3998 signature: adjust API to return error codes
git_signature_new() and git_signature_now() currently don't return error
codes. Change the API to return error codes and not pointers to let the
user handle errors properly.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 16:05:32 +02:00
Carlos Martín Nieto
65cb1586c4 Document the indexer calls
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:49 +02:00
Carlos Martín Nieto
48b3ad4f15 Move pack index writing to a public function
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:49 +02:00
Carlos Martín Nieto
b7c44096ae Implement the indexer
Only v2 index files are supported.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:41 +02:00
Carlos Martín Nieto
ab525a7463 Rename stuff to git_indexer_
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-02 21:41:33 +02:00
Carlos Martín Nieto
f23c4a66bd Start the runner
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-02 21:41:05 +02:00
Carlos Martín Nieto
3412391d4c Intial indexer code 2011-08-02 21:41:02 +02:00
Marcel Groothuis
ede21113a2 Fix compilation in C++: remove double GIT_BEGIN_DECL 2011-07-29 19:31:39 +02:00
Carlos Martín Nieto
1e76676fb4 Fixup network headers
The network headers were still missing some formalities.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-27 01:22:50 +02:00
Johan 't Hart
136e7129d7 On some header files, GIT_END_DECL was absent while GIT_BEGIN_DECL wasn't. 2011-07-27 00:06:19 +02:00
Kirill A. Shutemov
7d9cc9f81a index: fix cast warnings
/home/kas/git/public/libgit2/src/index.c: In function ‘git_index_clear’:
/home/kas/git/public/libgit2/src/index.c:228:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c:235:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘index_insert’:
/home/kas/git/public/libgit2/src/index.c:392:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c:399:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘read_unmerged’:
/home/kas/git/public/libgit2/src/index.c:681:35: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘read_entry’:
/home/kas/git/public/libgit2/src/index.c:716:33: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-25 21:12:47 +02:00
Lambert CLARA
ac2351fdec Modify struct definition to enable forward declare with C++ compiler,
thus avoid including C library's header in C++ header.
2011-07-25 20:24:10 +02:00
nulltoken
e5f365051f tag: Make git_tag_create_lightweight() accessible to bindings 2011-07-14 15:11:31 +02:00
Carlos Martín Nieto
91d8a4c077 typo: one git_remote_fetchspec should be pushspec
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-13 23:55:48 +02:00
Vicent Marti
b08683ffb2 config: Rename del to `delete 2011-07-12 02:38:20 +02:00
nulltoken
bfbb55628b tag: Add creation of lightweight tag 2011-07-11 19:42:21 +02:00
Lambert CLARA
f6e4a98a95 Finish to hide git_pkt from external API. 2011-07-11 13:05:13 +02:00
Lambert CLARA
5f35d0ce77 Remove the last reference of git_net_direction enum 2011-07-11 03:00:34 +02:00
Vicent Marti
bdd18829ad Cleanup external API
Some of the WIP API calls have been hidden in preparation for the next
minor release.
2011-07-11 02:59:18 +02:00
Vicent Marti
f27f29b100 include: Fix unmatched params in documentation 2011-07-11 02:59:17 +02:00
Vicent Marti
c52736fa52 status: Cleanup
The `hashfile` function has been moved to ODB, next to `git_odb_hash`.

Global state has been removed from the dirent call in `status.c`,
because global state is killing the rainforest and causing global
warming.
2011-07-09 15:05:14 +02:00
Jason Penny
20361b2f69 status: get status for single file
Add git_status_file to be able to retrieve status of single file by
supplying a path.
2011-07-09 13:49:50 +02:00
Jason Penny
3af6b34a76 status: get file statuses and run callback
Add git_status_foreach() to run a callback on each file passing the path
and a status value.
2011-07-09 13:49:50 +02:00
Jason Penny
205166d27c status: get blob object id of file on disk
Add git_status_hashfile() to get blob's object id for a file without adding
it to the object database or needing a repository at all.
This functionality is similar to `git hash-object` without '-w'.
2011-07-09 13:49:50 +02:00
schu
27df4275f2 reflog: add API to read or write a reference log
So far libgit2 didn't support reference logs (reflog). Add a new
git_reflog_* API for basic reading and writing of reflogs:

* git_reflog_read
* git_reflog_write
* git_reflog_free

Signed-off-by: schu <schu-github@schulog.org>
2011-07-09 02:40:16 +02:00
nulltoken
2b5af615e1 tag: add pattern based retrieval of list of tag names 2011-07-07 15:37:07 +02:00
Kirill A. Shutemov
245adf4f3c index: introduce git_index_uniq() function
It removes all entries with equal path except last added.

On large indexes git_index_append() + git_index_uniq() before writing is
*much* faster, than git_index_add().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Vicent Martí
f12aa9dc5e Merge pull request #300 from carlosmn/gsoc2011/master
A bit of networking
2011-07-05 04:31:37 -07:00
Carlos Martín Nieto
2601fcfc1e Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:17 +02:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
Vicent Marti
e0fc39da9a config: Fix unmatched parameters in docs 2011-06-30 22:28:19 +02:00
nulltoken
408d733b1f repository: Make head_detached() and head_orphan() convenience methods accessible to bindings 2011-06-30 06:56:58 -07:00
Vicent Marti
cfef5fb779 config: foreach now returns variable values too 2011-06-29 15:09:21 +02:00
Vicent Marti
7376ad9927 refs: Remove duplicate rename method
`git_reference_rename` now takes a `force` flag
2011-06-29 11:01:35 +02:00
Vicent Marti
ab7941b5d9 test: Properly show error messages 2011-06-28 21:10:51 +02:00
Vicent Marti
c682886e8e repo: Rename HEAD-related methods 2011-06-28 21:10:44 +02:00
Vicent Martí
ccd59372d4 Merge pull request #279 from carlosmn/detached-orphan
Add detached and orphan convenience functions
2011-06-28 10:44:19 -07:00
Vicent Marti
d5afc0390c Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API.

- All the reference/tag creation methods with `_f` are gone. The force
flag is now passed as an argument to the normal create methods.

- All the different commit creation methods are gone; commit creation
now always requires a `git_commit` pointer for parents and a `git_tree`
pointer for tree, to ensure that corrupted commits cannot be generated.

- All the different tag creation methods are gone; tag creation now
always requires a `git_object` pointer to ensure that tags are not
created to inexisting objects.
2011-06-28 19:36:27 +02:00
Carlos Martín Nieto
35502d2ec4 Add git_repository_is_detached, git_repository_is_orphan
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-28 16:59:51 +02:00
Carlos Martín Nieto
0ac2726fdf Slim down git_transport
Remove the unused repo and private pointers and make the direction a
flag, as it can only have two states. Change the connect signature to
use an int instead of git_net_direction and remove that enum.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 20:23:47 +02:00
Carlos Martín Nieto
9ba49bb5c8 Add git_remote_connect and git_remote_ls
These allow you to implement git-ls-remote when given a reference name
and a repository.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 02:12:40 +02:00
Carlos Martín Nieto
ce90a407c7 Remove the repo param from git_transport_new
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:48:01 +02:00
Carlos Martín Nieto
4e913309b9 Move transports to an inheritance model
Rather than an 'private' pointer, make the private structures inherit
from the generic git_transport struct. This way, we only have to worry
about one memory allocation instead of two. The structures are so
simple that this may even make the code use less memory overall.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:45 +02:00
Carlos Martín Nieto
fd6790210f Move git_pkt_{gen_proto,send_request} to transport_git.c
This is where they really belong. Remvoe the prefix and make them
static.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
cbf742ac4e Use (s)size_t
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
c4d0fa85b1 Implement and use git_pkt_send_request
This makes it easier to send a requqest for an URL. It assumes there
is a socket where the string should go out to.

Make git_pkt_gen_proto accept a command parameter, which defaults to
git-upload-pack

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
7632e2494a Correctly handle network input
Add a parameter to git_pkt_parse_line to tell it how much data you
have in your buffer. If the buffer is too short, it returns an error
saying so. Adapt the git transport to use this and fix the offset
calculation.

Add the GIT_ESHORTBUFFER error code.
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
be9fe679fc Implement and use git_pkt_free
A git_pkt object can be one of several structs. Add this function for
convenience and clarity.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00
Carlos Martín Nieto
ecb6ca0e1f Implement the git TCP transport up to ls-remote
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00
Carlos Martín Nieto
6a9597c5b5 Add function to generate a request
Add git_pkt_gen_proto to crete a request from an url.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
8b9e8de5ce pkt-line: read capabilities
Try to read the server capabilities and add them to the git_pkt_ref
struct.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
b31803f310 pkt-line: parse other-ref lines
Add support for parsing other-ref lines.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
f7fc68df83 Lay the foundations for pkt-line parsing
This are the types I intend to use for pkt-line parsing and (later)
creation. git_pkt serves as a base pointer type and once you know what
type it is you can use the real one (command, tip list, etc.)

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
d6258debbe Implement ls-remote on local drive
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
8f866daee5 Lay down the fundations for the network code
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
92cb6aa929 Add git_refspec_transform
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
63f91e1ce8 Add git.git's fnmatch, which is really GNU's and the git__fnmatch wrapper
If the strings match, git__fnmatch returns GIT_SUCCESS and
GIT_ENOMATCH on failure to match.

MSVC fixes: Added a test for _MSC_VER and (in that case) defined
HAVE_STRING_H to 1 so it doesn't try to include <strings.h> which
doesn't exist in the MSVC world. Moved the function declarations to
use the modern inline ones so MSVC doesn't have a fit. Added casts
everywhere so MSVC doesn't crap its pants.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
f8f3feb0d3 Add a to-do list for remotes
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
9c82357be7 Add a remotes API
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:10 +02:00
Ankur Sethi
2c0ec236e9 added defines for Haiku in types.h 2011-06-23 13:36:09 +00:00
Vicent Marti
984ed6b6be odb: Add GIT_EPASSTHROUGH
Allows a custom user backend to passthrough one of the callbacks. Used
for e.g. caching backends.
2011-06-19 12:50:45 +02:00
Vicent Marti
bfd5e3e2a2 config: Fix API docs 2011-06-19 12:50:45 +02:00
Vicent Marti
19cb6857a4 config: Bring back git_config_open_global
Scott commands, I obey.
2011-06-18 01:50:48 +02:00
Vicent Marti
07ff881750 config: Cleanup external API
Do not mess with environment variables anymore. The new external API has
more helper methods, and everything is explicit.
2011-06-18 00:39:39 +02:00
Carlos Martín Nieto
b22d147986 Add git_repository_config API
This function puts the global and repository configurations in one
git_config object and gives it to the user.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-17 22:30:29 +02:00
Vicent Marti
d144c569f3 Update documentation
Fix all the missmatched arguments in the docs
2011-06-16 03:06:22 +02:00
Vicent Marti
f1d018513a oid: Uniformize ncmp methods
Drop redundant methods. The ncmp method is now public
2011-06-16 02:50:08 +02:00
Vicent Marti
fa48608ec3 oid: Rename methods
Yeah. Finally. Fuck the old names, this ain't POSIX
and they don't make any sense at all.
2011-06-16 02:36:21 +02:00
Vicent Marti
43521d0688 refs: Rename git_referece_listcb to _foreach
Same name as `git_config_foreach`
2011-06-16 02:27:43 +02:00
Vicent Marti
536955f9d7 Add method to get the compiled version of the lib 2011-06-16 02:21:33 +02:00
Vicent Martí
ef9a6f4cbc Merge pull request #261 from Romain-Geissler/discovery-path-v2
Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
2011-06-15 13:47:41 -07:00