Commit Graph

585 Commits

Author SHA1 Message Date
Vicent Marti
01ae1909c5 diff: Cleanup documentation and printf compat 2012-09-06 10:13:38 +02:00
Russell Belfer
510f1bac6b Fix comments and a minor bug
This adds better header comments and also fixes a bug in one of
simple APIs that tells the number of lines in the current hunk.
2012-09-05 15:17:24 -07:00
Russell Belfer
f335ecd6e1 Diff iterators
This refactors the diff output code so that an iterator object
can be used to traverse and generate the diffs, instead of just
the `foreach()` style with callbacks.  The code has been rearranged
so that the two styles can still share most functions.

This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses
that as a common error code for marking the end of iteration when
using a iterator style of object.
2012-09-05 15:17:24 -07:00
Vicent Martí
4d3834038b Merge pull request #856 from libgit2/utf8-win
Windows: Perform UTF-8 path conversion on the Stack
2012-09-04 14:19:24 -07:00
Vicent Marti
c9d223f0de branch: Add missing include 2012-09-04 22:57:31 +02:00
Vicent Marti
6813169ac9 windows: Keep UTF-8 on the stack yo 2012-08-28 23:09:43 -07:00
Vicent Marti
62eafd0620 Merge branch 'branch-delete-ref' into development
Conflicts:
	include/git2/refs.h
2012-08-27 14:54:52 -07:00
Vicent Martí
bd2887a5e5 Merge pull request #904 from arrbee/better-object-peel
Make git_object_peel a bit smarter
2012-08-27 14:52:26 -07:00
Vicent Martí
b9d283d14a Merge pull request #897 from nulltoken/topic/git_reference_check_format
refs: expose git_reference_normalize_name()
2012-08-27 13:39:17 -07:00
Russell Belfer
d8057a5b0e Make git_object_peel a bit smarter
This expands the types of peeling that `git_object_peel` knows
how to do to include TAG -> BLOB peeling, and makes the errors
slightly more consistent depending on the situation.  It also
adds a new special behavior where peeling to ANY will peel until
the object type changes (e.g. chases TAGs to a non-TAG).

Using this expanded peeling, this replaces peeling code that was
embedded in `git_tag_peel` and `git_reset`.
2012-08-27 11:53:59 -07:00
Philip Kelley
c49d328cf4 Expose a malloc function to 3rd party ODB backends 2012-08-27 09:59:13 -04:00
nulltoken
2e0c881670 refs: expose git_reference_normalize_name() 2012-08-27 08:41:26 +02:00
Vicent Marti
1c947daa80 branch: Change git_branch_delete to take a ref 2012-08-26 18:00:10 -07:00
Carlos Martín Nieto
2b175ca972 indexer: kill git_indexer_stats.data_received
It's not really needed with the current code as we have EOS and the
sideband's flush to tell us we're done.

Keep the distinction between processed and received objects.
2012-08-26 00:42:28 +02:00
Vicent Martí
b7e8827b8b Merge pull request #895 from carlosmn/sideband
Add sideband support
2012-08-24 16:29:01 -07:00
Carlos Martín Nieto
e03e71da56 network: add sideband support
This lets us notify the user of what the remote end is doing while we
wait for it to start sending us the packfile.
2012-08-24 20:29:39 +02:00
Russell Belfer
5f4a61aea8 Working implementation of git_submodule_status
This is a big redesign of the git_submodule_status API and the
implementation of the redesigned API.  It also fixes a number of
bugs that I found in other parts of the submodule API while
writing the tests for the status part.

This also fixes a couple of bugs in the iterators that had not
been noticed before - one with iterating when there is a gitlink
(i.e. separate-work-dir) and one where I was treating anything
even vaguely submodule-like as a submodule, more aggressively
than core git does.
2012-08-24 11:00:27 -07:00
Russell Belfer
aa13bf05c8 Major submodule rewrite
This replaces the old submodule API with a new extended API that
supports most of the things that can be done with `git submodule`.
2012-08-24 11:00:26 -07:00
Carlos Martín Nieto
bffa852f89 indexer: recognize and mark when all of the packfile has been downloaded
We can't always rely on the network telling us when the download is
finished. Recognize it from the indexer itself.
2012-08-24 19:01:10 +02:00
Russell Belfer
e9ca852e4d Fix warnings and merge issues on Win64 2012-08-23 09:20:17 -07:00
Russell Belfer
85bd174626 Some cleanup suggested during review
This cleans up a number of items suggested during code review
with @vmg, including:

* renaming "outside repo" config API to `git_config_open_default`
* killing the `git_config_open_global` API
* removing the `git_` prefix from the static functions in fileops
* removing some unnecessary functionality from the "cp" command
2012-08-22 16:16:42 -07:00
Russell Belfer
ca1b6e5409 Add template dir and set gid to repo init
This extends git_repository_init_ext further with support for
initializing the repository from an external template directory
and with support for the "create shared" type flags that make a
set GID repository directory.

This also adds tests for much of the new functionality to the
existing `repo/init.c` test suite.

Also, this adds a bunch of new utility functions including a
very general purpose `git_futils_mkdir` (with the ability to
make paths and to chmod the paths post-creation) and a file
tree copying function `git_futils_cp_r`.  Also, this includes
some new path functions that were useful to keep the code
simple.
2012-08-22 16:07:19 -07:00
Russell Belfer
662880ca60 Add git_repository_init_ext for power initters
The extended version of repository init adds support for many
of the things that you can do with `git init` and sets up
structures that will make it easier to extend further in the
future.
2012-08-22 16:06:22 -07:00
Vicent Martí
cfda29e382 Merge pull request #891 from arrbee/internal-ignore-api
API for managing in-memory ignore rules
2012-08-22 13:15:14 -07:00
Russell Belfer
2fb4e9b3c5 Wrap up ignore API and add tests
This fills out the ignore API and adds tests.
2012-08-22 11:42:00 -07:00
nulltoken
9d7ac675d0 tree entry: rename git_tree_entry_attributes() into git_tree_entry_filemode() 2012-08-21 23:15:13 +02:00
nulltoken
a7dbac0b23 filemode: deploy enum usage 2012-08-21 23:15:10 +02:00
nulltoken
d854d59e31 filemode: introduce enum to ease use of attributes 2012-08-21 23:15:08 +02:00
nulltoken
66439b0b1a treebuilder: enhance attributes handling on insertion 2012-08-19 14:11:59 +02:00
Vicent Martí
f98c32f3fe Merge pull request #778 from ben/clone
Clone
2012-08-19 01:26:06 -07:00
nulltoken
e0db9f1117 refs: fix missing parameter documentation 2012-08-15 17:54:05 +02:00
nulltoken
5fd17fc217 notes: slight documentation enhancements 2012-08-15 17:50:02 +02:00
Carlos Martín Nieto
85f28ba891 Merge pull request #873 from carlosmn/tree-walk
git_tree_walk callback return value semantic does not match documentation
2012-08-14 11:43:20 -07:00
Russell Belfer
3a6bc301c5 Merge pull request #875 from arrbee/fix-message-prettify-length-check
Fix message prettify length check
2012-08-14 11:30:18 -07:00
Russell Belfer
85a0e28b80 Make git_message_prettify return bytes written
If you want to be absolutely safe with git_message_prettify, you
can now pass a NULL pointer for the buffer and get back the number
of bytes that would be copied into the buffer.

This means that an error is a non-negative return code and a
success will be greater than zero from this function.
2012-08-14 10:50:58 -07:00
Vicent Martí
e08ca0d4a7 Merge pull request #871 from joshtriplett/fix-note_foreach-docs
git_note_foreach: Fix documentation for notes_ref parameter
2012-08-13 21:04:27 -07:00
Vicent Martí
a6ee620185 Merge pull request #870 from joshtriplett/fix-note_create-docs
git_note_oid: Fix the documentation to reference parameters using the correct names
2012-08-13 21:02:35 -07:00
Vicent Martí
0374e6abe7 Merge pull request #872 from joshtriplett/fix-note_remove-docs
git_note_create: Copyediting on documentation for the oid parameter
2012-08-13 21:02:12 -07:00
Carlos Martín Nieto
a6bf16878a tree: allow the user to skip an entry or cancel the walk
Returning a negative cancels the walk, and returning a positive one
causes us to skip an entry, which was previously done by a negative
value.

This allows us to stay consistent with the rest of the functions that
take a callback and keeps the skipping functionality.
2012-08-13 14:07:47 +02:00
Josh Triplett
39a60efd39 git_note_remove: Copyediting on documentation for the oid parameter 2012-08-12 11:31:12 -07:00
Josh Triplett
d45ada03cf git_note_foreach: Fix documentation for notes_ref parameter 2012-08-12 06:31:42 -07:00
Josh Triplett
22408f4d5f git_note_oid: Fix the documentation to reference parameters using the correct names 2012-08-12 05:53:30 -07:00
Josh Triplett
b90202bbdd Fix incorrect array size in example for git_config_get_mapped
In the documentation for git_config_get_mapped, the sample mapping
array uses [3] but has 4 entries.  Fix by dropping the size entirely and
letting the compiler figure it out.
2012-08-12 03:56:15 -07:00
Josh Triplett
5389005d93 Export git_attr_value
Commit 0c9eacf3d2 introduced the function
git_attr_value and switched the GIT_ATTR_* macros to use it, but
attempting to use that function leads to a linker error (undefined
reference to `git_attr_value').  Export git_attr_value so programs can
actually call it.
2012-08-11 18:14:07 -07:00
Vicent Marti
51e1d80846 Merge remote-tracking branch 'arrbee/tree-walk-fixes' into development
Conflicts:
	src/notes.c
	src/transports/git.c
	src/transports/http.c
	src/transports/local.c
	tests-clar/odb/foreach.c
2012-08-06 12:41:08 +02:00
Russell Belfer
5dca201072 Update iterators for consistency across library
This updates all the `foreach()` type functions across the library
that take callbacks from the user to have a consistent behavior.
The rules are:

* A callback terminates the loop by returning any non-zero value
* Once the callback returns non-zero, it will not be called again
  (i.e. the loop stops all iteration regardless of state)
* If the callback returns non-zero, the parent fn returns GIT_EUSER
* Although the parent returns GIT_EUSER, no error will be set in
  the library and `giterr_last()` will return NULL if called.

This commit makes those changes across the library and adds tests
for most of the iteration APIs to make sure that they follow the
above rules.
2012-08-03 17:08:01 -07:00
Vicent Marti
e25dda51c4 Merge remote-tracking branch 'nulltoken/topic/amd64-compat' into development
Conflicts:
	src/netops.c
	src/netops.h
	src/oid.c
2012-08-02 01:38:30 +02:00
Vicent Martí
95a1d87614 Merge pull request #850 from libgit2/attr-export
attr: Do not export variables externally
2012-08-01 16:31:00 -07:00
Vicent Martí
e5f495012d Merge pull request #848 from carlosmn/pending-message
repository: add a getter and remove function for git's prepared message
2012-08-01 16:21:41 -07:00
Vicent Marti
0c9eacf3d2 attr: Do not export variables externally
Fixes #824

Exporting variables in a dynamic library is a PITA. Let's keep
these values internally and wrap them through a helper method.

This doesn't break the external API. @arrbee, aren't you glad I turned
the `GIT_ATTR_` macros into function macros? 
2012-08-02 01:15:24 +02:00
Sascha Cunz
e564e4969c Add function to query for compile time settings. 2012-08-01 20:02:32 +02:00
Carlos Martín Nieto
074841ec6a repository: add a getter and remove function for git's prepared message
The 'git revert/cherry-pick/merge -n' commands leave .git/MERGE_MSG
behind so that git-commit can find it. As we don't yet support these
operations, users who are shelling out to let git perform these
operations haven't had a convenient way to get this message.

These functions allow the user to retrieve the message and remove it
when she's created the commit.
2012-08-01 18:39:20 +02:00
Ben Straub
8b67f72b9c Add documentation for clone methods. 2012-07-31 21:25:48 -07:00
Ben Straub
5280f4e698 Add checkout.h to git2.h.
Also correcting some documentation strings.
2012-07-31 19:39:06 -07:00
Vicent Martí
bfb5916468 Merge pull request #833 from carlosmn/odb-one
odb: allow creating an ODB backend from a packfile index
2012-07-31 10:16:21 -07:00
Ben Straub
4bf5115642 Enable stats on git_index_read_tree.
Replace with the contents of 
git_index_read_tree_with_stats() and improve
documentation comments.
2012-07-30 15:48:06 -07:00
Ben Straub
f1587b97a1 Checkout: use git_index_read_tree_with_stats.
New variant of git_index_read_tree that fills in
the 'total' field of a git_indexer_stats struct
as it's walking the tree.
2012-07-30 14:37:40 -07:00
Michael Schubert
f6b26e770f git_oid_cmp: inline memcmp by hand to optimize
git.git uses an inlined hashcmp function instead of memcmp, since it
performes much better when comparing hashes (most hashes compared
diverge within the first byte).

Measurements and rationale for the curious reader:
http://thread.gmane.org/gmane.comp.version-control.git/172286
2012-07-29 20:50:58 +02:00
Ben Straub
b31667fb69 Checkout: add head- and ref-centric checkouts.
Renamed git_checkout_index to what it really was,
and removed duplicate code from clone.c. Added
git_checkout_ref, which updates HEAD and hands off
to git_checkout_head.

Added tests for the options the caller can pass to
git_checkout_*.
2012-07-27 20:31:05 -07:00
Ben Straub
a4827a5b5c Merge remote-tracking branch 'upstream/development' into test-merge 2012-07-27 11:17:21 -07:00
Vicent Martí
60d5cc5747 Merge pull request #834 from carlosmn/network-callbacks
Add a struct for network callbacks
2012-07-27 09:52:44 -07:00
Vicent Marti
f0244463ad branch: Add repository argument to create
Yes, we can get the repository from the owner of the object, but having
it marked explicitly makes the API more consistent.
2012-07-27 18:49:37 +02:00
Vicent Marti
b41a30bdbb Merge remote-tracking branch 'nulltoken/topic/branch-rework' into development 2012-07-27 18:45:55 +02:00
Vicent Marti
b84f75c357 reflog: Rename entry_drop to drop 2012-07-27 18:43:02 +02:00
Vicent Marti
43b67d496b Merge remote-tracking branch 'nulltoken/topic/reflog-delete' into development 2012-07-27 18:39:40 +02:00
Ben Straub
095ccc013f Checkout: implementation of most options 2012-07-26 16:31:49 -07:00
Russell Belfer
2031760c62 Fix git_tree_walk to return user error
This makes sure that an error code returned by the callback function
of `git_tree_walk` will stop the iteration and get propagated back
to the caller verbatim.

Also, this adds a minor helper function `git_tree_entry_byoid` that
searches a `git_tree` for an entry with the given OID.  This isn't
a fast function, but it's easier than writing the loop yourself as
an external user of the library.
2012-07-26 16:10:22 -07:00
Sascha Cunz
765015902a Remotes: Setter for url+pushurl; Getter for pushurl 2012-07-26 23:08:22 +02:00
Ben Straub
b401bace1b Restructure for better checkout options
* Removed the #define for defaults
* Promoted progress structure to top-level API call
  argument
2012-07-26 13:12:21 -07:00
Ben Straub
ef9905c990 checkout: introduce git_checkout_opts
Refactor checkout into several more-sensible
entry points, which consolidates common options
into a single structure that may be passed around.
2012-07-26 12:58:44 -07:00
nulltoken
40c75652d0 reflog: prevent git_reflog_append() from persisting the reflog back to disk 2012-07-25 07:53:32 +02:00
nulltoken
ae8331784e reflog: prevent git_reflog_read() from chocking when no log exists yet 2012-07-25 07:53:31 +02:00
nulltoken
bd72425d16 reflog: introduce git_reflog_write() 2012-07-25 07:53:30 +02:00
nulltoken
d284b3de63 reflog: rename git_reflog_write() to git_reflog_append() 2012-07-25 07:53:30 +02:00
nulltoken
59341a5d59 reflog: introduce git_reflog_entry_drop() 2012-07-25 07:53:29 +02:00
nulltoken
b8457baae2 portability: Improve x86/amd64 compatibility 2012-07-24 16:10:12 +02:00
nulltoken
ef4d795ec5 refs: drop git_reference_remote_tracking_from_branch() 2012-07-24 16:09:49 +02:00
nulltoken
fb910281d6 branch: introduce git_branch_tracking() 2012-07-24 16:09:48 +02:00
nulltoken
bf9e8cc86b branch: make git_branch_move() reference based 2012-07-24 16:09:47 +02:00
nulltoken
abee7bd36a branch: slight git_branch_create() doc improvement 2012-07-24 16:09:46 +02:00
nulltoken
88bcd5153f branch: introduce git_reference_is_branch() 2012-07-24 16:09:45 +02:00
nulltoken
eed378b669 branch: introduce git_branch_lookup() 2012-07-24 16:09:44 +02:00
nulltoken
b308c11e4e branch: change git_branch_create() to make it return a reference 2012-07-24 16:09:43 +02:00
yorah
a1773f9d89 Add flag to turn off pathspec testing for diff and status 2012-07-24 14:03:09 +02:00
Carlos Martín Nieto
b3aaa7a7c8 Add a struct for network callbacks
Currently only update_tips is used, but it prepares the way for
progress output during download.
2012-07-21 18:44:01 +02:00
Vicent Martí
5b78696334 Merge pull request #818 from nulltoken/rework
Revparse rework
2012-07-21 07:56:59 -07:00
Carlos Martín Nieto
6782245e51 repo: add git_repository_wrap_odb() to wrap an ODB
Primarily useful when used together with git_odb_backend_one_pack().
2012-07-21 16:24:13 +02:00
Carlos Martín Nieto
507523c32f odb: allow creating an ODB backend from a packfile index
git_odb_backend_one_packfile() allows us to create an ODB backend out
of an .idx file.
2012-07-21 16:23:49 +02:00
nulltoken
db9be9457d object: introduce git_object_peel()
Partially fix #530
2012-07-17 20:32:40 +02:00
Ben Straub
bfc6563405 Merge branch 'development' into clone 2012-07-17 08:08:34 -07:00
Vicent Marti
227f313119 attr: Rename the git_attr__ exports
Pevents collisions with the original libgit, which also exports those
exact symbols.

Fixes #822
2012-07-15 14:32:51 +02:00
Ben Straub
deac801de9 Fix documentation comment to match actual params. 2012-07-13 15:50:23 -07:00
Carlos Martín Nieto
1ebe432e2f commit: properly export git_commit_nth_gen_ancestor() 2012-07-12 20:33:30 +02:00
Vicent Martí
dd4345b424 Merge pull request #789 from carlosmn/odb-foreach
odb: add git_odb_foreach()
2012-07-12 09:42:54 -07:00
Vicent Martí
0cf6b2f29e Merge pull request #805 from nulltoken/fix/revwalk-email-parsing
Fix revwalk email parsing
2012-07-12 09:37:09 -07:00
Vicent Martí
db2d4061f6 Merge pull request #814 from nulltoken/topic/revparse-refac
Revparse refactoring: a start
2012-07-12 09:35:35 -07:00
Vicent Martí
48bcf81dd2 Merge pull request #812 from arrbee/assorted-tweaks
Assorted goodies
2012-07-12 09:32:44 -07:00
nulltoken
84f18e3587 refs: introduce git_reference_remote_tracking_from_branch() 2012-07-12 01:06:13 +02:00
nulltoken
b1aca6eae0 commit: introduce git_commit_nth_gen_ancestor() 2012-07-12 01:06:11 +02:00
nulltoken
8aedf1d558 signature: prevent angle bracket usage in identity 2012-07-11 20:40:13 +02:00