Commit Graph

1171 Commits

Author SHA1 Message Date
Carlos Martín Nieto
2974aa94c3 Determine variable type at runtime
Config variables should be interpreted at run-time, as we don't know if a
zero means false or zero, or if yes means true or "yes".

As a variable has no intrinsic type, git_cvtype is gone and the public
API takes care of enforcing a few rules.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 13:42:24 +02:00
Carlos Martín Nieto
2e445cacd2 build_varname: allocate memory
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 11:34:04 +02:00
nulltoken
2b9b99b6ed Add test ensuring one can not create an oid reference which targets at an unknown id 2011-03-29 21:29:30 +02:00
nulltoken
4d00dfd438 Replace gitfo_unlink() calls with git_reference_delete() in refs related tests 2011-03-29 21:21:47 +02:00
Olivier Ramonat
a796d24cf6 Fix help message for waf configure --with-sqlite 2011-03-29 20:16:17 +03:00
Carlos Martín Nieto
553fbd640f Check for looser reference names
res/dummy/a and refs/stash must pass. The other rules are already
tested by the rest of the checks.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
83c95128d9 normalize_name: allow more references under refs/
Allow any well-formed reference name to live under refs/ removing the
condition that they be under refs/{heads,tags,remotes}/ as was the
design of git.

An exception is made for HEAD which is allowed to contain an OID
reference in detached HEAD state.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Vicent Marti
9a53df7e0a refs: Don't allow references to inexistent OIDs 2011-03-29 19:58:19 +03:00
Vicent Marti
95cde17ca4 Enforce coding conventions in refs.c
Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
fc1eeb9dfc Make overwrite test more comprehensive
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
ec99193655 force-rename test: check for the right name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
dad4a4d582 rename: don't return early if the target ref exists
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
591a9423f5 Add tests covering overwriting references
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
4cd6ed7566 Fix documentation copy error
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
c7db45e862 Match the comment with the error string
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
fa20496200 Allow forcing the creation or renaming of references
Add internal reference create and rename functions which take a force
parameter, telling them to overwrite an existing reference if it
exists.

These functions try to update the reference if it's of the same type
as the one it's going to be replaced by. Otherwise the old reference
becomes invalid.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
baad182cbc Add GIT_EEXISTS error code
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
9a3c5e55fd Expose config API for setters, getters and foreach
These functions can be used to query or modify the variables in a
given configuration. No sanity checking is done on the variable names.

This is mostly meant as an API preview.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 18:13:47 +02:00
Carlos Martín Nieto
26faa3668f Add build_varname to make a full var name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 18:13:47 +02:00
Carlos Martín Nieto
e15afc8e7c cvar_free: also free the config var's name
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 18:07:01 +02:00
Carlos Martín Nieto
6d7bb4e039 Move git_cvar_type to include/git2/config.h
Include it in src/config.h and fix the header name #define.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 17:35:02 +02:00
Carlos Martín Nieto
3d23b74af7 Free the config var hash contents in git_config_free
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 13:50:37 +02:00
Carlos Martín Nieto
238df5590c Rename git_config_{type,var} to git_cvar{_type,}
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:48:47 +02:00
Carlos Martín Nieto
05314b5bf4 Make GIT_EINVALIDTYPE available for use in config
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:25:46 +02:00
Carlos Martín Nieto
9f7f4122cf Don't leak if config parsing fails
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:19:53 +02:00
Carlos Martín Nieto
4e02504f52 Move config to support the new hash code
The hashes have been copied from the references code

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:17:29 +02:00
Vicent Marti
6dcb09b5b5 libgit2 version 0.11.0, "McSwifty"
Apologies for the massive changes in the external API (that's my fault),
and for the terrible codename for this release (that's @tclem's fault).

The detailed overview for the major API changes can be found in the
commit at 72a3fe42fb.

Major new features in this release:

	- Real caching and refcounting on parsed objects
	- Real caching and refcounting on objects read from the ODB
	- Streaming writes & reads from the ODB
	- Single-method writes for all object types
	- The external API is now partially thread-safe
	- Improved reference handling
	- New method to list references
	- ZLib is now built-in
	- Improvements to the Revision Walker
	- Tons of bug fixes

Thanks to all the contributors who make this possible.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-28 22:35:27 +03:00
Vicent Marti
483526ebec Update the SQLite backend 2011-03-28 22:23:44 +03:00
Carlos Martín Nieto
3b4835c25a Correctly parse the section header
If cfg_readline consumes the line, then parse_section_header will read
past it and if we read a character, parse_variable won't have the full
name.

This solution is a bit hackish, but it's the simplest way to get the
code to parse correctly.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 18:07:22 +02:00
schu
683581a3e9 index.c: Fix tiny typos 2011-03-28 17:59:13 +02:00
schu
9d80d74da5 signature.h: Fix tiny typo 2011-03-28 17:57:08 +02:00
Carlos Martín Nieto
908afb771a parse_section_header: save the name where it belongs
Save the location of the name in section_out instead of returning it
as an int. Use the return code to signal success or failure.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 17:53:04 +02:00
Carlos Martín Nieto
e4c796f1a2 Read and parse the confguration when openingt the config file
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 17:51:18 +02:00
Carlos Martín Nieto
a69053c715 Convert config.c to LF
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 17:12:53 +02:00
Carlos Martín Nieto
5d4cd00305 Move the struct declaration outside config.c
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 17:03:08 +02:00
Carlos Martín Nieto
7b4a16e2c8 Add git_tag_create_frombuffer API
Expose the tag parsing capabilities already present in the
library.

Exporting this function makes it possible to implement the
mktag command without duplicating this functionality.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 13:59:48 +02:00
Carlos Martín Nieto
c15e0db5a9 Fix memory leak in parse_tag_buffer
Free the allocated memory if the signature parsing reports an error.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 13:58:44 +02:00
Vicent Marti
09e8de0f38 New external API method: git_reference_listcb
List all the references in the repository, calling a custom
callback for each one.

The listed references may be filtered by type, or using
a bitwise OR of several types. Use the magic value
`GIT_REF_LISTALL` to obtain all references, including
packed ones.

The `callback` function will be called for each of the references
in the repository, and will receive the name of the reference and
the `payload` value passed to this method.
2011-03-25 23:53:38 +02:00
Jakob Pfender
051d6915d7 index.h: Fix minor typo 2011-03-25 00:49:47 +02:00
Jakob Pfender
12f6d8e145 index.h: Correct documentation for git_index_open_inrepo()
Fix the doxygen comments for git_index_open_inrepo(). Previously they
referred to a param index_path and omitted index (probably a c&p
error).
2011-03-25 00:49:47 +02:00
Jakob Pfender
3bdc0d4c8c index.c: Read index after initialization
The current behaviour of git_index_open{bare,inrepo}() is unexpected.
When an index is opened, an in-memory index object is created that is
linked to the index discovered by git_repository_open(). However, this
index object is empty, as the on-disk index is not read. To fully open
the on-disk index file, git_index_read() has to be called. This leads to
confusing behaviour. Consider the following code:

	git_index *idx;
	git_index_open_inrepo(&idx, repo);
	git_index_write(idx);

You would expect this to have no effect, as the index is never
ostensibly manipulated. However, what actually happens is that the index
entries are removed from the on-disk index because the empty in-memory
index object created by open_inrepo() is written back to the disk.

This patch reads the index after opening it.
2011-03-25 00:49:47 +02:00
Scott Chacon
f3cf7f6df1 add go-git (Go bindings) to the readme 2011-03-23 17:06:49 -07:00
Vicent Marti
815c9bc7de Remove circular dependency in includes 2011-03-23 20:18:34 +02:00
Jakob Pfender
ea269511ad odb.h: Fix minor typo
Fix a doxygen typo ("@para" instead of "@param") in odb.h
2011-03-23 18:55:44 +02:00
Jakob Pfender
c585f55ff4 common.h: Fix minor typos
Fix a few minor typos in the documentation of the GIT_ERROR codes.
2011-03-23 18:55:41 +02:00
Vicent Marti
f6f72d7ef8 Improve the ODB writing backend
Temporary files when doing streaming writes are now stored inside the
Objects folder, to prevent issues when moving files between
disks/partitions.

Add support for block writes to the ODB again (for those backends that
cannot implement streaming).
2011-03-23 18:44:53 +02:00
Vicent Marti
08db1efd3d Add Ocaml bindings to the readme 2011-03-23 15:53:12 +02:00
Vicent Marti
c0ffe51853 Do not return on void helper methods
MSVC doesn't swallow that.
2011-03-23 15:44:52 +02:00
Vicent Marti
f0d08b7cec Remove git_repository_gc from the headers 2011-03-23 15:40:47 +02:00
Carlos Martín Nieto
b0b8313583 Add close wappers for commit, tree, tag and blob
In the same spirit that git_repository_lookup is no longer available,
add wrappers so the users don't have to cast when closing their
objects.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-23 11:08:42 +01:00