Commit Graph

804 Commits

Author SHA1 Message Date
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
Vicent Martí
a13a30ac30 Merge pull request #801 from nulltoken/fix/ref-renaming
refs and revparse love <3
2012-07-11 05:29:51 -07:00
Russell Belfer
991a56c704 Add flag to write gitlink on setting repo workdir
This added a flag to the `git_repository_set_workdir()` function
that enables generation of a `.git` gitlink file that links the
new workdir to the parent repository.  Essentially, the flag tells
the function to write out the changes to disk to permanently set
the workdir of the repository to the new path.

If you pass this flag as true, then setting the workdir to something
other than the default workdir (i.e. the parent of the .git repo
directory), will create a plain file named ".git" with the standard
gitlink contents "gitdir: <repo-path>", and also update the
"core.worktree" and "core.bare" config values.

Setting the workdir to the default repo workdir will clear the
core.worktree flag (but still permanently set core.bare to false).

BTW, the libgit2 API does not currently provide a function for
clearing the workdir and converting a non-bare repo into a bare one.
2012-07-10 23:19:47 -07:00
Russell Belfer
b3ff1dab31 Adding git_config_foreach_match() iteration fn
Adding a new config iteration function that let's you iterate
over just the config entries that match a particular regular
expression.  The old foreach becomes a simple use of this with
an empty pattern.

This also fixes an apparent bug in the existing `git_config_foreach`
where returning a non-zero value from the iteration callback was
not correctly aborting the iteration and the returned value was
not being propogated back to the caller of foreach.

Added to tests to cover all these changes.
2012-07-10 23:19:47 -07:00
Russell Belfer
4d3a7b7846 Merge pull request #793 from libgit2/tree-entry-by-path
Bring back `entry_bypath`
2012-07-10 21:45:16 -07:00
Russell Belfer
19017a24e3 Merge pull request #797 from yorah/fix/inter-hunk-context
diff: make inter-hunk-context default value git-compliant
2012-07-10 16:24:17 -07:00
nulltoken
33c3370700 refs: deploy git_reference_has_log() 2012-07-07 12:15:29 +02:00
nulltoken
75261421ec refs: add git_reference_has_log() 2012-07-07 12:15:28 +02:00
Kevin Sawicki
4ea7c8c666 Replace incorrect 'it' with 'if' in documentation 2012-07-03 12:35:33 -07:00
Carlos Martín Nieto
521aedad30 odb: add git_odb_foreach()
Go through each backend and list every objects that exists in
them. This allows fsck-like uses.
2012-07-03 12:50:51 +02:00
yorah
29f9186d1b diff: make inter-hunk-context default value git-compliant
Default in git core is 0, not 3
2012-07-02 17:27:49 +02:00
Vicent Marti
46ea40d995 tree: Rename entry_copy to entry_dup 2012-06-29 17:08:36 +02:00
Vicent Marti
0e2fcca850 tree: Bring back entry_bypath
Smaller, simpler, faster.
2012-06-29 02:21:12 +02:00
Carlos Martín Nieto
371599576a indexer: don't use '/objects/pack/' unconditionally
Not everyone who indexes a packfile wants to put it in the standard
git repository location.
2012-06-28 10:24:03 +02:00
Vicent Martí
c6713398ba Merge pull request #785 from nulltoken/topic/refs-fromglob
Topic/refs fromglob
2012-06-25 23:27:35 -07:00
nulltoken
527ed55448 references: introduce git_reference_foreach_glob() 2012-06-22 21:40:24 +02:00
Vicent Marti
798e4d53dc amigaos: Cleanup 2012-06-22 21:25:17 +02:00
Vicent Marti
2ae052d1b1 Merge branch 'pull-req' of https://github.com/chris-y/libgit2 into amigaos 2012-06-22 20:48:50 +02:00
Ben Straub
14741d62d9 Clone: new home for git_checkout_force. 2012-06-21 11:13:19 -07:00
Ben Straub
bb1f6087e4 Add progress reporting to clone. 2012-06-21 09:53:44 -07:00
Ben Straub
764df57e82 Add git_clone and git_clone_bare.
So far they only create a repo, setup the "origin"
remote, and fetch. The API probably needs work as
well; there's no way to get progress information
at this point.

Also uncovered a shortcoming; git_remote_download
doesn't fetch over local transport.
2012-06-21 09:53:44 -07:00
nulltoken
d4827081ea branch: drop git_branch_list() 2012-06-21 18:51:32 +02:00
nulltoken
a8fd805e2f branch: add git_branch_foreach() 2012-06-21 18:51:27 +02:00
Vicent Martí
c3ce8d0c9a Merge pull request #775 from arrbee/fix-index-filemodes
Make index add/append support core.filemode flag
2012-06-19 15:17:35 -07:00
Russell Belfer
77d65af439 Nicer constant 2012-06-19 15:16:38 -07:00
Russell Belfer
da825c92d9 Make index add/append support core.filemode flag
This fixes git_index_add and git_index_append to behave more like
core git, preserving old filemode data in the index when adding
and/or appending with core.filemode = false.

This also has placeholder support for core.symlinks and
core.ignorecase, but those flags are not implemented (well,
symlinks has partial support for preserving mode information in
the same way that git does, but it isn't tested).
2012-06-19 14:27:02 -07:00
nulltoken
743a4b3bdd message: Expose git_message_prettify()
git_commit() and git_tag() no longer prettify the
message by default. This has to be taken care of
by the caller.

This has the nice side effect of putting the
caller in position to actually choose to strip
the comments or not.
2012-06-19 10:02:22 +02:00
Vicent Martí
31eed56b9e Merge pull request #753 from nulltoken/topic/merge-base-many
Expose git_merge_base_many()
2012-06-18 17:36:14 -07:00
Chris Young
a8df98c6fb Updates from comments on OS4 compatibility pull request http://github.com/libgit2/libgit2/pull/766 2012-06-14 18:57:24 +01:00
Chris Young
a21bb1aa33 Merge remote-tracking branch 'source/development' into development 2012-06-13 23:28:51 +01:00
Carlos Martín Nieto
14ebe51832 Expose git_refspec_parse()
This function has been available for some time, but never in a
header. Expose it so we can use it from outside the library.
2012-06-12 15:24:33 +02:00
Chris Young
327fb51cec Fix gethostbyname compatibility 2012-06-09 18:13:07 +01:00
Russell Belfer
145e696b49 Minor fixes, cleanups, and clarifications
There are three actual changes in this commit:

1. When the trailing newline of a file is removed in a diff, the
   change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed
   to the callback.  Previously, the `ADD_EOFNL` constant was given
   which was just an error in my understanding of when the various
   circumstances arose.  `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and
   should never be generated.  A new newline is simply an `ADD`.
2. Rewrote the `diff_delta__merge_like_cgit` function that contains
   the core logic of the `git_diff_merge` implementation.  The new
   version doesn't actually have significantly different behavior,
   but the logic should be much more obvious, I think.
3. Fixed a bug in `git_diff_merge` where it freed a string pool
   while some of the string data was still in use.  This led to
   `git_diff_print_patch` accessing memory that had been freed.

The rest of this commit contains improved documentation in `diff.h`
to make the behavior and the equivalencies with core git clearer,
and a bunch of new tests to cover the various cases, oh and a minor
simplification of `examples/diff.c`.
2012-06-08 12:11:13 -07:00
Russell Belfer
0abd724454 Fix filemode comparison in diffs
File modes were both not being ignored properly on platforms
where they should be ignored, nor be diffed consistently on
platforms where they are supported.

This change adds a number of diff and status filemode change
tests.  This also makes sure that filemode-only changes are
included in the diff output when they occur and that filemode
changes are ignored successfully when core.filemode is false.

There is no code that automatically toggles core.filemode
based on the capabilities of the current platform, so the user
still needs to be careful in their .git/config file.
2012-06-08 12:09:10 -07:00
Chris Young
fa56478fb8 Generic needs compat files 2012-06-08 19:15:11 +01:00
Chris Young
aa5a92d121 OS4 compatibility 2012-06-08 18:57:35 +01:00
Chris Young
519757279e Fix double-defines when using GIT_OLD_ERRORS 2012-06-07 23:13:39 +01:00
Chris Young
0f5e1f3b68 Network byte order is big-endian - the way it should be :) 2012-06-07 21:56:19 +01:00
Vicent Martí
3f0358604e misc: Fix warnings from PVS Studio trial 2012-06-07 22:43:48 +02:00
Vicent Martí
6c08e69fd9 Merge pull request #669 from nulltoken/topic/reset
Add git_reset()
2012-06-07 12:30:20 -07:00
Vicent Martí
b9ebcc59e7 Merge pull request #684 from benstraub/rev-parse
Rev parse
2012-06-07 12:29:31 -07:00
Chris Young
c3f35902f3 Merge remote-tracking branch 'source/development' into update-test
Merging main libgit2!
Conflicts:
	CMakeLists.txt
	src/unix/map.c
2012-06-07 20:29:22 +01:00
nulltoken
edebceffef Add git_reset()
Currently supports Soft and Mixed modes.
2012-06-07 21:27:30 +02:00
Vicent Martí
cddb8efe56 Merge pull request #704 from nulltoken/topic/blob_fromchunks
Add the ability to create blob given a provider of chunks of bytes
2012-06-07 11:34:48 -07:00
nulltoken
cd44576790 blob: add git_blob_create_fromchunks() 2012-06-07 20:33:22 +02:00
nulltoken
b46bdb2204 merge: Expose git_merge_base_many() 2012-06-07 16:25:37 +02:00
Vicent Martí
966fbdcb8e Merge pull request #697 from carlosmn/ssl
Add HTTPS support
2012-06-05 13:53:33 -07:00
Ben Straub
56a5000d58 Merge branch 'development' into rev-parse
Conflicts:
	src/util.h
	tests-clar/refs/branches/listall.c
2012-06-05 12:52:44 -07:00
Chris Young
d0517805d8 Required include for OS4 to typedef int64_t 2012-06-05 11:47:17 +01:00
nulltoken
d05e2c64dd refspec: expose the force update specifier through git_refspec_force() accessor 2012-05-30 01:05:17 +02:00
Carlos Martín Nieto
250b95b24b ssl: allow skipping the server certificate check
Sometimes it's useful not to perform the check. Allow it to be
configurable.
2012-05-26 21:17:08 +02:00
Carlos Martín Nieto
dbb36e1b42 ssl: check certificates against the system's trusted CAs 2012-05-19 17:51:53 +02:00
Bruce Mitchener
d73c94b21c Fix spelling errors. 2012-05-19 20:26:52 +07:00
Vicent Marti
ad5df35a47 libgit2 v0.17.0 "Lord of Diffstruction"
Welcome to yet another libgit2 release, this one being the
biggest we've shipped so far. Highlights on this release
include diff, branches, notes and submodules support. The new
diff API is shiny and powerful. Check it out.

Apologies, one more time, to all the early adopters for the
breaking API changes. We've been iterating on the error
handling for the library until we reached its current state,
which we believe it's significantly more usable both for normal
users and for developers of bindings to other languages.
Also, we've renamed a few legacy calls to ensure that the whole
external API uses a consistent naming scheme.

As always, check the API docs for the full list of new API calls
and backwards-incompatible changes.

	http://libgit2.github.com/libgit2/

Changelog of new features follows:

Attributes:
	- Added function macros to check attribute values instead of having
	to manually compare them
	- Added support for choosing the attribute loading order (workdir files
	vs index) and to skip the systems' default `.gitattributes`
	- Fixed issues when fetching attribute data on bare repositories

Blob:
	- Added support for creating blobs from any file on disk (not
	restricted to the repository's working directory)
	- Aded support for smudge filters when writing blobs to the ODB
		- So far only CRLF normalization is available

Branches:
	- Added a high-level branch API:
		- git_branch_create
		- git_branch_delete
		- git_branch_list
		- git_branch_move

Commit:
	- Commit messages are now filtered to match Git rules (stripping
	comments and adding proper whitespacing rules)

Config:
	- Added support for setting and getting multivars
	- Added `git_config_get_mapped` to map the value of a config
	variable based on its defaults

Diff:
	- Added full diff API:
		- tree to tree
		- index to tree
		- workdir to index
		- workdir to tree
		- blob to blob

	- Added helper functions to print the diffs as valid patchfiles

Error handling:
	- New design for the error handling API, taking into consideration
	the requirements of dynamic languages

Indexer:
	- Added streaming packfile indexer

Merge:
	- Added support for finding the merge base between two commits

Notes:
	- Full git-notes support:
		- git_note_read
		- git_note_message/git_note_oid
		- git_note_create
		- git_note_remove
		- git_note_free
		- git_note_foreach

References:
	- Added `git_reference_name_to_oid` helper to resolve
	a reference to its final OID

	- Added `git_reference_cmp` to compare two references with
	a stable order

Remotes:
	- Added support for writing and saving remotes
		- `git_remote_add`
		- `git_remote_save`
		- Setters for all the attributes of a remote
	- Switched remote download to the new streaming packfile indexer
	- Fixed fetch on HTTP and Git under Windows
	- Added `git_remote_supported_url` helper to check if a protocol
	can be accessed by the library
	- Added `git_remote_list`

Repository:
	- Made `git_repository_open` smarter when finding the `.git` folder.
	- Added `git_repository_open_ext` with extra options when
	opening a repository

Revwalk:
	- Added support for pushing/hiding several references through a glob
	- Added helper to push/hide the current HEAD to the walker
	- Added helper to push/hide a single reference to the walker

Status:
	- Greatly improved Status implementation using the new `diff` code
	as a backend

Submodules:
	- Added a partial submodules API to get information about a
	submodule and list all the submodules in a repository
		- git_submodule_foreach
		- git_submodule_lookup

Tag:
	- Added `git_tag_peel` helper to peel a tag to its pointed object
	- Tag messages are now filtered to match Git rules (stripping comments
	and adding proper whitespacing rules)

Tree:
	- Killed the old `git_tree_diff` API, which is replaced by the
	new diff code.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2012-05-19 01:40:46 +02:00
Vicent Martí
904b67e69f errors: Rename error codes 2012-05-18 01:48:50 +02:00
Vicent Martí
e172cf082e errors: Rename the generic return codes 2012-05-18 01:26:26 +02:00
Vicent Martí
2e2e97858d Properly tag all enums with a _t 2012-05-18 01:26:23 +02:00
Vicent Martí
4fbd1c007e refs: git_reference_listall -> git_reference_list 2012-05-18 01:26:16 +02:00
Vicent Martí
fe3bcf7d7a errors: Remove old comments 2012-05-18 01:25:57 +02:00
Vicent Martí
29e948debe global: Change parameter ordering in API
Consistency is good.
2012-05-18 01:25:57 +02:00
nulltoken
ee7680d53b notes: make git_note_foreach() callback signature easier to cope with from a binding perspective 2012-05-16 21:51:45 +02:00
Vicent Martí
9d0011fd83 tree: Naming conventions 2012-05-16 19:24:35 +02:00
Vicent Martí
cedf9ca955 tree: Kill the git_tree_diff functions
These are deprecated and replaced with the diffing code in git2/diff.h
2012-05-16 19:24:35 +02:00
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
Romain Geissler
0657e46dee Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
GIT_PATH_LIST_SEPARATOR and GIT_PATH_MAX are made public so
that it's can be used by a client.
2011-06-15 22:11:18 +02:00
Scott Chacon
737406b7ab fix gid_ misspelling 2011-06-14 09:31:19 -07:00
Vicent Marti
b023321669 Remove custom backends
All the custom backend code will be moved to a separate project,
	together with the new MySQL backend.
2011-06-14 17:40:17 +02:00
Vicent Martí
e3f56a2b57 Merge pull request #216 from glesserd/development
git_tag_create{,_o,_frombuffer} correction and improvement
2011-06-08 08:11:26 -07:00
Carlos Martín Nieto
a2a305fcf4 config: explain the cfg and file relationship better
It's not clear how git_config and git_config_file relate to one
another. Be more explicit about their relationship in the function
documentation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-07 15:39:40 +02:00
Carlos Martín Nieto
ce78f39e27 config: update the git_config_add_file documentation
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-07 14:18:22 +02:00
Vicent Marti
340fc0d40a threads: Cleanup TLS declarations
This time for good.
2011-06-07 03:39:19 +02:00
Vicent Marti
9d77d83a81 Revert "threads: Fix TLS declarations"
This commit uploaded an old broken test. Oops!
2011-06-07 03:38:09 +02:00
Vicent Martí
1097dacd7d Merge pull request #240 from Romain-Geissler/tree-object-type
Tree: Added a function that returns the type of a tree entry.
2011-06-06 18:33:38 -07:00
Vicent Martí
9b1692ebfc Merge pull request #239 from pegonma/oid_prefix
Search objects of different types given OID prefix
2011-06-06 18:31:21 -07:00
Vicent Martí
1b0d92b141 Merge pull request #238 from pegonma/git_oid_ncmp
Better name for git_oid_match
2011-06-06 18:28:11 -07:00
Vicent Martí
00c31dd293 Merge pull request #234 from Romain-Geissler/entry-count-API-uniformisation
[Tree | Index] API uniformisation
2011-06-06 18:26:50 -07:00
Vicent Marti
64fe8c62f9 threads: Fix TLS declarations
Cleanup the thread-utils file. Do not define TLS if libgit2 is not
threadsafe.
2011-06-07 03:22:32 +02:00
Romain Geissler
ff9a4c130d Tree: Added a function that returns the type of a tree entry. 2011-06-06 17:14:30 +02:00
Marc Pegon
c09093cce2 Renamed git_oid_match to git_oid_ncmp.
As suggested by carlosmn, git_oid_ncmp would probably
be a better name than git_oid_match, for it does the same
as git_oid_cmp but only up to a certain amount of hex digits.
2011-06-06 17:04:37 +02:00
Marc Pegon
790c6c95fe Added methods to search objects of different types
given an OID prefix.
2011-06-06 11:55:48 +02:00
Romain Geissler
f11e079733 Index: API uniformisation: Use unsigned int for all index number.
Feature Added: Search an unmerged entry by path (git_index_get_unmerged
renamed to git_index_get_unmerged_bypath) or by index (git_index_get_unmerged_byindex).
2011-06-05 21:19:03 +02:00
Romain Geissler
e5c8009731 Tree: API uniformasation: Use unsigned int for all index number. 2011-06-05 21:18:05 +02:00
Vicent Marti
602ee38b6e repository: Export all internal paths 2011-06-04 20:45:09 +02:00
David Glesser
f4c925c514 Change a dirty indentation 2011-06-04 16:09:19 +02:00
Vicent Martí
793545ef2b Merge pull request #227 from Romain-Geissler/discovery-path-v2
Discovery path v2
2011-06-03 17:41:53 -07:00
Romain Geissler
fd0574e5ad Repository: Added the git_repository_discover function that finds by itself the git directory that manage a given directory path. 2011-06-04 01:05:36 +02:00
Vicent Marti
3a42e0a370 index: Add git_index_entry_stage method
As suggested by Romain-Geissler
2011-06-03 21:38:55 +02:00
Vicent Marti
d0323a5f63 short-oid: Cleanup 2011-06-01 23:40:42 +02:00
Marc Pegon
da03c9f35b Changed return value of git_oid_match to be consistent with the other compare methods (0 means oids match). Added method to compare prefixes of hex formatted oids. 2011-06-01 23:40:42 +02:00
Marc Pegon
ac2b94ad76 Added a GIT_OID_MINPREFIXLEN constant to define the minimum length allowed for oid prefixes (set to 4, like in git). Consequently updated some object lookup methods and their documentation. 2011-06-01 23:40:41 +02:00
Marc Pegon
dd453c4dbf Added git.git sha1 lookup method to replace simple binary search in pack backend.
Implemented find_unique_short_oid for pack backend, based on git sha1 lookup method;
finding an object given its full oid is just a particular case of searching
the unique object matching an oid prefix (short oid).

Added git_odb_read_unique_short_oid, which iterates over all the backends to
find and read the unique object matching the given oid prefix.

Added a git_object_lookup_short_oid method to find the unique object in
the repository matching a given oid prefix : it generalizes git_object_lookup
which now does nothing but calls git_object_lookup_short_oid.
2011-06-01 23:40:41 +02:00
Marc Pegon
53c0bd81a2 Added error for ambiguous oid prefixes. Added methods to compare the first nth hexadecimal characters (i.e. packets of 4 bits) of OIDs. 2011-06-01 23:40:41 +02:00
Marc Pegon
ecd6fdf1f7 Added a read_unique_short_oid method to backends, to make it possible to find objects from sha1 prefixes in the future. Default implementations throw GIT_ENOTIMPLEMENTED for strict prefixes (i.e. length < GIT_OID_HEXSZ). 2011-06-01 23:40:41 +02:00
Vicent Martí
50b7334e51 Merge pull request #206 from nulltoken/topic/is-bare
Add git_repository_is_bare() accessor
2011-06-01 09:58:21 -07:00
Vicent Marti
f7e59c4dcf index: Change the memory management for repo indexes
The `git_repository_index` call now returns a brand new index that must
be manually free'd.
2011-06-01 18:54:47 +02:00
Vicent Marti
ef5ffed39a object: Update documentation 2011-06-01 18:45:23 +02:00
David Glesser
23123151e0 Set the oid when a tag already exists.
When a tag already exists, it can be useful to directly have the oid
of the existed tag, just after trying to add it.
2011-05-30 09:03:55 +02:00
nulltoken
fa9bcd81f5 Add git_repository_is_bare() accessor 2011-05-24 21:50:02 +02:00
Vicent Marti
b0b527e0ad config: Cleanup & renaming of the external API
"git_config_backend" have been renamed to "git_config_file", which
implements a generic interface to access a configuration file -- be it
either on disk, from a DB or whatever mumbojumbo.

I think this makes more sense.
2011-05-20 03:20:12 +03:00
Vicent Martí
274f2c213f Merge pull request #193 from carlosmn/config
A couple of config improvements
2011-05-19 14:18:57 -07:00
Vicent Marti
f4e2aca29c index: Fix issues in the unmerged entries API 2011-05-19 20:38:17 +03:00
Jakob Pfender
050e8877dd Merge branch 'development' into unmerged 2011-05-17 15:31:05 +02:00
Carlos Martín Nieto
f44cbec479 Add documentation for git_config_add_backend 2011-05-17 14:59:23 +02:00
Carlos Martín Nieto
32234541f6 Implement git_config_open_global
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-17 14:31:57 +02:00
Vicent Marti
128d37316b config_file: Fix compilation 2011-05-17 15:11:19 +03:00
Carlos Martín Nieto
94711cad3b Merge upstream/development 2011-05-17 12:12:59 +02:00
Vicent Marti
f87d9beb8d Change error codes from DEFINEs to an enum 2011-05-15 23:46:39 +03:00
Vicent Marti
f31bd03f7e Include "common.h" in "errors.h" 2011-05-13 04:19:50 +03:00
Vicent Marti
6810bf28f8 Move all error-related defines to git2/errors.h 2011-05-11 00:40:07 +03:00
Vicent Marti
f4a936b56a Bring back git_strerror
We cannot totally deprecate this until the new error handling mechanisms
are all in place.
2011-05-11 00:35:40 +03:00
Carlos Martín Nieto
c033500549 Move config to a backend structure
Configuration options can come from different sources. Currently,
there is only support for reading them from a flat file, but it might
make sense to read it from a database at some point.

Move the parsing code into src/config_file.c and create an include
file include/git2/config_backend.h to allow for other backends to be
developed.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-10 14:47:20 +02:00
kelly.leahy
ab86f159e5 Fix issue #79 - git_lasterror() isn't appearing in git2.dll in windows.
The GIT_EXPORT macro is used to declare a function to be externally
accessible to other libraries.  This commit uses GIT_EXPORT to declare
the git_lasterror() function as externally exported.  I verified with
depends.exe that the function is available to external callers (i.e.
in the exports table of the PE file).
2011-05-09 23:39:32 -07:00
Vicent Marti
5711ca93d1 Merge branch 'error-handling' into development 2011-05-09 21:58:26 +03:00
Vicent Marti
fa59f18d0d Change error handling mechanism once again
Ok, this is the real deal. Hopefully. Here's how it's going to work:

- One main method, called `git__throw`, that sets the error
	code and error message when an error happens.

	This method must be called in every single place where an error
	code was being returned previously, setting an error message
	instead.

	Example, instead of:

		return GIT_EOBJCORRUPTED;

	Use:

		return git__throw(GIT_EOBJCORRUPTED,
			"The object is missing a finalizing line feed");

	And instead of:

		[...] {
			error = GIT_EOBJCORRUPTED;
			goto cleanup;
		}

	Use:

		[...] {
			error = git__throw(GIT_EOBJCORRUPTED, "What an error!");
			goto cleanup;
		}

	The **only** exception to this are the allocation methods, which
	return NULL on failure but already set the message manually.

		/* only place where an error code can be returned directly,
		   because the error message has already been set by the wrapper */
		if (foo == NULL)
			return GIT_ENOMEM;

- One secondary method, called `git__rethrow`, which can be used to
fine-grain an error message and build an error stack.

	Example, instead of:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return error;

	You can now do:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return git__rethrow(error, "Failed to do a major operation");

	The return of the `git_lasterror` method will be a string in the
	shape of:

		"Failed to do a major operation. (Failed to do an internal
		operation)"

	E.g.

		"Failed to open the index. (Not enough permissions to access
		'/path/to/index')."

	NOTE: do not abuse this method. Try to write all `git__throw`
	messages in a descriptive manner, to avoid having to rethrow them to
	clarify their meaning.

	This method should only be used in the places where the original
	error message set by a subroutine is not specific enough.

	It is encouraged to continue using this style as much possible to
	enforce error propagation:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return error; /* `foobar` has set an error message, and
							 we are just propagating it */

The error handling revamp will take place in two phases:

	- Phase 1: Replace all pieces of code that return direct error codes
	with calls to `git__throw`. This can be done semi-automatically
	using `ack` to locate all the error codes that must be replaced.

	- Phase 2: Add some `git__rethrow` calls in those cases where the
	original error messages are not specific enough.

Phase 1 is the main goal. A minor libgit2 release will be shipped once
Phase 1 is ready, and the work will start on gradually improving the
error handling mechanism by refining specific error messages.

OTHER NOTES:

	- When writing error messages, please refrain from using weasel
	words. They add verbosity to the message without giving any real
	information. (<3 Emeric)

	E.g.

		"The reference file appears to be missing a carriage return"
			Nope.

		"The reference file is missing a carriage return"
			Yes.

	- When calling `git__throw`, please try to use more generic error
	codes so we can eventually reduce the list of error codes to
	something more reasonable. Feel free to add new, more generic error
	codes if these are going to replace several of the old ones.

	E.g.

		return GIT_EREFCORRUPTED;

	Can be turned into:

		return git__throw(GIT_EOBJCORRUPTED,
			"The reference is corrupted");
2011-05-09 21:58:02 +03:00
Vicent Marti
5eb0fab846 errors: Update external API with new git_lasterror 2011-05-09 21:58:02 +03:00
Vicent Marti
02f9e637a1 errors: Add error handling function 2011-05-09 21:58:01 +03:00
Carlos Martín Nieto
ca8d2dfc0c Merge remote-tracking branch 'upstream/development' into config 2011-05-05 16:22:06 +02:00
Jason R. McNeil
773bc20dd3 Fix misspelling of git_index_append2 (was git_index_apppend2). 2011-05-03 22:22:42 -07:00
Vicent Marti
1648fbd344 Re-apply missing patches 2011-05-02 01:12:53 +03:00
Vicent Marti
f7a5058aaf index: Refactor add/replace methods
Removed the optional `replace` argument, we now have 4 add methods:

	`git_index_add`: add or update from path
	`git_index_add2`: add or update from struct
	`git_index_append`: add without replacing from path
	`git_index_append2`: add without replacing from struct

Yes, this breaks the bindings.
2011-04-24 00:31:43 +03:00
Jakob Pfender
4c0b6a6dac index: Add API for unmerged entries
New external functions:
	- git_index_unmerged_entrycount: Counts the unmerged entries in
	  the index
	- git_index_get_unmerged: Gets an unmerged entry from the index
	  by name

New internal functions:
	- read_unmerged: Wrapper for read_unmerged_internal
	- read_unmerged_internal: Reads unmerged entries from the index
	  if the index has the INDEX_EXT_UNMERGED_SIG set
	- unmerged_srch: Search function for unmerged vector
	- unmerged_cmp: Compare function for unmerged vector

New data structures:
	- git_index now contains a git_vector unmerged that stores
	  unmerged entries
	- git_index_entry_unmerged: Representation of an unmerged file
	  entry. It represents all three versions of the file at the
	  same time, with one name, three modes and three OIDs
2011-04-21 10:54:54 +02:00
Jakob Pfender
729b6f4900 index: Allow user to toggle whether to replace an index entry
When in the middle of a merge, the index needs to contain several files
with the same name. git_index_insert() used to prevent this by not adding a new entry if an entry with the same name already existed.
2011-04-21 10:40:54 +02:00
Carlos Martín Nieto
e69ac2439f config: export git_config_[sg]et_long
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:38:55 +02:00
Vicent Marti
def3fef197 Add git_tag_list
Lists all the tag references in a repository using a custom callback.
Includes unit tests courtesy of Emeric Fermas <3
2011-04-12 15:55:51 -07:00
Carlos Martín Nieto
55c197cdd3 Merge upstream/development 2011-04-11 17:43:56 +02:00
Vicent Marti
8416c9adcc Rename git_signature_new_now
The new name is more cool.
2011-04-09 15:31:12 -07:00
Carlos Martín Nieto
9e9e6ae177 Add API git_signature_new_now
Most tags will have a timestamp of whenever the code is running and
dealing with time and timezones is error-prone. Optimize for this case
by adding a function which causes the signature to be created with a
current timestamp.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:48 -07:00
Carlos Martín Nieto
b5c00c6d41 Fix the signature documentation
The parameters are given by '@param name' and not '@name'.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:28 -07:00
nulltoken
4a34b3a9ff Add two new accessors to the repository
git_repository_path() and git_repository_workdir() respectively return the path to the git repository and the working directory. Those paths are absolute and normalized.
2011-04-09 15:25:24 -07:00
Vicent Marti
c6e65acae6 Properly check strtol for errors
We are now using a custom `strtol` implementation to make sure we're not
missing any overflow errors.
2011-04-09 15:22:11 -07:00
Vicent Marti
41233c40c0 Add new method git_repository_is_empty 2011-04-08 12:42:18 -07:00
Jakob Pfender
26f2c897b8 index.h: Add IDXENTRY flags needed for index operations
Add several IDXENTRY flags that need to be checked in
order to properly implement update-index --refresh.
2011-04-08 03:33:50 +03:00
Sam
5924b2822c Added git_commit_tree_oid and git_commit_parent_oid. 2011-04-08 03:33:46 +03:00