]> git.proxmox.com Git - libgit2.git/log
libgit2.git
12 years agoMerge pull request #493 from euler0/fix-typos-readme
Vicent Martí [Tue, 22 Nov 2011 06:36:19 +0000 (22:36 -0800)]
Merge pull request #493 from euler0/fix-typos-readme

Fix typos in the README file

12 years agoFix to follow the Qt trademark policy
Vincent Lee [Tue, 22 Nov 2011 06:12:57 +0000 (15:12 +0900)]
Fix to follow the Qt trademark policy

Never use the Qt trade mark with both letters capitalized, in the form
"QT".
(http://qt-project.org/trademarkpolicy.html)

12 years agoFix a typo in the README file
Vincent Lee [Tue, 22 Nov 2011 06:04:33 +0000 (15:04 +0900)]
Fix a typo in the README file

12 years agoremote: Assert things that should be asserted
Vicent Marti [Tue, 22 Nov 2011 01:16:20 +0000 (02:16 +0100)]
remote: Assert things that should be asserted

12 years agoMerge pull request #492 from carlosmn/networking
Vicent Martí [Tue, 22 Nov 2011 01:12:23 +0000 (17:12 -0800)]
Merge pull request #492 from carlosmn/networking

Networking improvements

12 years agotree: Fix documentation
Vicent Marti [Tue, 22 Nov 2011 01:10:41 +0000 (02:10 +0100)]
tree: Fix documentation

12 years agoclay: Properly initialize filebuf
Vicent Marti [Tue, 22 Nov 2011 01:06:24 +0000 (02:06 +0100)]
clay: Properly initialize filebuf

12 years agofilebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanups
Russell Belfer [Thu, 17 Nov 2011 23:10:27 +0000 (15:10 -0800)]
filebuf: add GIT_FILEBUF_INIT and protect multiple opens and cleanups

Update all stack allocations of git_filebuf to use GIT_FILEBUF_INIT
and make git_filebuf_open and git_filebuf_cleanup safe to be called
multiple times on the same buffer.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
12 years agoclay: Merge manually @leto's tests from #485
Vicent Marti [Tue, 22 Nov 2011 00:41:22 +0000 (01:41 +0100)]
clay: Merge manually @leto's tests from #485

This uses the new Clay code. As you can see, the diff is minimal... It
works!

12 years agoMerge pull request #489 from lht/fix-doc-bare-repo
Vicent Martí [Tue, 22 Nov 2011 00:37:44 +0000 (16:37 -0800)]
Merge pull request #489 from lht/fix-doc-bare-repo

Fix typo in repository documentation

12 years agoAdd git_remote_connected
Carlos Martín Nieto [Mon, 21 Nov 2011 19:48:59 +0000 (20:48 +0100)]
Add git_remote_connected

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoAdd git_remote_disconnect
Carlos Martín Nieto [Mon, 21 Nov 2011 19:44:03 +0000 (20:44 +0100)]
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>
12 years agorefspec: allow a simple branchname
Carlos Martín Nieto [Sun, 9 Oct 2011 01:07:53 +0000 (03:07 +0200)]
refspec: allow a simple branchname

A simple branchname as refspec is valid and we shouldn't throw an
error when encountering one.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agorefspec: make the structure more complete
Carlos Martín Nieto [Sun, 9 Oct 2011 00:59:01 +0000 (02:59 +0200)]
refspec: make the structure more complete

Add a next pointer to make it a linked list and add the 'pattern' and
'matching' flags.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoAdd a name to a remote created from the API
Carlos Martín Nieto [Fri, 18 Nov 2011 20:28:07 +0000 (21:28 +0100)]
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>
12 years agoremote: get rid of git_remote_negotiate
Carlos Martín Nieto [Fri, 18 Nov 2011 20:18:39 +0000 (21:18 +0100)]
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>
12 years agonet: move the reference storage to common code
Carlos Martín Nieto [Thu, 27 Oct 2011 01:06:36 +0000 (18:06 -0700)]
net: move the reference storage to common code

12 years agoFix typo in repository documentation
Haitao Li [Fri, 18 Nov 2011 09:43:43 +0000 (17:43 +0800)]
Fix typo in repository documentation

12 years agoUpdate clay instructions to use -vtap
Carlos Martín Nieto [Fri, 18 Nov 2011 01:26:10 +0000 (02:26 +0100)]
Update clay instructions to use -vtap

12 years agoAdd test for renaming a file and adding it to the index
Carlos Martín Nieto [Fri, 18 Nov 2011 01:16:24 +0000 (02:16 +0100)]
Add test for renaming a file and adding it to the index

Thanks to Emeric.

12 years agoDon't overwrite existing objects
Carlos Martín Nieto [Thu, 17 Nov 2011 19:32:04 +0000 (20:32 +0100)]
Don't overwrite existing objects

It's redundant to do this (git doesn't) and Windows doesn't allow us
to overwrite a read-only file (which objects are).

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoinclude: Unify internal include strategies
Vicent Marti [Fri, 18 Nov 2011 00:43:27 +0000 (01:43 +0100)]
include: Unify internal include strategies

Do not add the `git2` path to internal includes, or that will cause
an extra path dependency.

12 years agoclay: Bump to 0.9.0, add TAP support
Vicent Marti [Thu, 17 Nov 2011 05:01:09 +0000 (06:01 +0100)]
clay: Bump to 0.9.0, add TAP support

Comes with schu's stress tests for config files. Hopefully the diffs
will stay minimal from now on.

12 years agotree: Add payload to `git_tree_walk`
Vicent Marti [Thu, 17 Nov 2011 01:13:46 +0000 (02:13 +0100)]
tree: Add payload to `git_tree_walk`

12 years agoRename `git_tree_frompath` to `git_tree_get_subtree`
Vicent Marti [Thu, 17 Nov 2011 00:23:19 +0000 (01:23 +0100)]
Rename `git_tree_frompath` to `git_tree_get_subtree`

That makes more sense to me.

12 years agoMerge pull request #486 from petdance/development
Vicent Martí [Thu, 17 Nov 2011 04:35:29 +0000 (20:35 -0800)]
Merge pull request #486 from petdance/development

Quoted the asterisk to avoid markdown highlighter confusion

12 years agoQuoted the asterisk to avoid markdown highlighter confusion
Andy Lester [Wed, 16 Nov 2011 23:33:02 +0000 (17:33 -0600)]
Quoted the asterisk to avoid markdown highlighter confusion

12 years agoMerge pull request #484 from brodie/packed-refs-perms
Vicent Martí [Wed, 16 Nov 2011 19:45:37 +0000 (11:45 -0800)]
Merge pull request #484 from brodie/packed-refs-perms

refs: permissions-related fixes/improvements

12 years agorefs: move GIT_PACKED_REFS_FILE_MODE to refs.h as GIT_PACKEDREFS_FILE_MODE
Brodie Rao [Wed, 16 Nov 2011 19:39:03 +0000 (11:39 -0800)]
refs: move GIT_PACKED_REFS_FILE_MODE to refs.h as GIT_PACKEDREFS_FILE_MODE

This groups the #define with the other ref-related file modes, and it
makes the name consistent with the other packed-refs definitions.

12 years agorefs: use 0666 permissions when writing packed-refs, not 0644
Brodie Rao [Wed, 16 Nov 2011 19:36:13 +0000 (11:36 -0800)]
refs: use 0666 permissions when writing packed-refs, not 0644

This matches stock Git's behavior.

12 years agoMerge pull request #482 from leto/patch-1
Vicent Martí [Wed, 16 Nov 2011 19:34:10 +0000 (11:34 -0800)]
Merge pull request #482 from leto/patch-1

Fix docs about the command to mix the clay tests

12 years agoFix docs about the command to mix the clay tests
Jonathan "Duke" Leto [Wed, 16 Nov 2011 18:22:13 +0000 (10:22 -0800)]
Fix docs about the command to mix the clay tests

12 years agothreads: Fix the shared global state with TLS
Vicent Marti [Wed, 16 Nov 2011 13:09:44 +0000 (14:09 +0100)]
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()`.

12 years agoMerge pull request #475 from carlosmn/perms
Vicent Martí [Mon, 7 Nov 2011 20:04:13 +0000 (12:04 -0800)]
Merge pull request #475 from carlosmn/perms

Fix Windows permissions problems

12 years agoWrite packed-refs with 0644 permissions
Carlos Martín Nieto [Mon, 7 Nov 2011 19:32:03 +0000 (20:32 +0100)]
Write packed-refs with 0644 permissions

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoReword packed-refs error messages so they're easier to track down
Carlos Martín Nieto [Mon, 7 Nov 2011 19:06:01 +0000 (20:06 +0100)]
Reword  packed-refs error messages so they're easier to track down

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoImplement p_rename
Carlos Martín Nieto [Mon, 7 Nov 2011 18:34:24 +0000 (19:34 +0100)]
Implement p_rename

Move the callers of git_futils_mv_atomic to use p_rename.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoMerge pull request #473 from drafnel/bc/update-examples
Vicent Martí [Mon, 7 Nov 2011 14:27:49 +0000 (06:27 -0800)]
Merge pull request #473 from drafnel/bc/update-examples

bc/update examples

12 years agoMerge pull request #470 from schu/test-helpers-no-assert
Vicent Martí [Mon, 7 Nov 2011 14:25:22 +0000 (06:25 -0800)]
Merge pull request #470 from schu/test-helpers-no-assert

test_helpers: do not rely on assert

12 years agoMerge pull request #472 from libgit2/new-references
Vicent Martí [Mon, 7 Nov 2011 12:38:12 +0000 (04:38 -0800)]
Merge pull request #472 from libgit2/new-references

References! References! References!

12 years agoexamples/network/.gitignore: ignore 'git2'
Brandon Casey [Mon, 7 Nov 2011 02:07:27 +0000 (20:07 -0600)]
examples/network/.gitignore: ignore 'git2'

12 years agoexamples/network/git2.c: exit with proper status, and avoid segfault
Brandon Casey [Mon, 7 Nov 2011 01:44:29 +0000 (19:44 -0600)]
examples/network/git2.c: exit with proper status, and avoid segfault

This function should exit after printing usage information if too few
arguments were specified.

Additionally, it should exit with a failure status if the first argument
supplied is not one in the internal command list.

12 years agoexamples/network/git2.c: add newline to usage message
Brandon Casey [Mon, 7 Nov 2011 01:43:44 +0000 (19:43 -0600)]
examples/network/git2.c: add newline to usage message

12 years agoexamples/network/fetch.c: revert overzealous conversion of free to git__free
Brandon Casey [Mon, 7 Nov 2011 01:35:35 +0000 (19:35 -0600)]
examples/network/fetch.c: revert overzealous conversion of free to git__free

Since git__free is not exported (it's actually a macro), it should not be
used in client programs.  Change this call to 'git__free' back to 'free'.

12 years agoreflog: Do not free references before time
Vicent Marti [Sun, 6 Nov 2011 01:52:43 +0000 (02:52 +0100)]
reflog: Do not free references before time

12 years agorefs: Partial rewrite for read-only refs
Vicent Marti [Mon, 31 Oct 2011 04:58:33 +0000 (21:58 -0700)]
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.

12 years agogit_reference_rename: cleanup reference renaming
schu [Sat, 13 Aug 2011 16:14:39 +0000 (18:14 +0200)]
git_reference_rename: cleanup reference renaming

git_reference_rename() didn't properly cleanup old references given by
the user to not break some ugly old tests. Since references don't point
to libgit's internal cache anymore we can cleanup git_reference_rename()
to be somewhat less messy.

Signed-off-by: schu <schu-github@schulog.org>
12 years agoFree all used references in the source tree
schu [Thu, 11 Aug 2011 17:38:13 +0000 (19:38 +0200)]
Free all used references in the source tree

Since references are not owned by the repository anymore we have to free
them manually now.

Signed-off-by: schu <schu-github@schulog.org>
12 years agorefs: add test case checking "immutable" references
schu [Tue, 26 Jul 2011 09:17:32 +0000 (11:17 +0200)]
refs: add test case checking "immutable" references

Signed-off-by: schu <schu-github@schulog.org>
12 years agorefs: split internal and external references
schu [Wed, 10 Aug 2011 14:19:42 +0000 (16:19 +0200)]
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>
12 years agoexamples/general.c: update for recent API renaming of git_config_get_int
Brandon Casey [Sat, 5 Nov 2011 23:01:32 +0000 (18:01 -0500)]
examples/general.c: update for recent API renaming of git_config_get_int

git_config_get_int --> git_config_get_int32

12 years agotest_helpers: do not rely on assert
schu [Sun, 30 Oct 2011 12:48:00 +0000 (13:48 +0100)]
test_helpers: do not rely on assert

The functions loose_object_mode and loose_object_dir_mode call stat
inside an assert statement which isn't evaluated when compiling in
Release mode (NDEBUG) and leads to failing tests. Replace it.

Signed-off-by: schu <schu-github@schulog.org>
12 years agoMerge pull request #468 from nulltoken/ntk/fix/issue-465
Vicent Martí [Sat, 29 Oct 2011 21:06:36 +0000 (14:06 -0700)]
Merge pull request #468 from nulltoken/ntk/fix/issue-465

Status: fix segfault (#465) and order issues

12 years agostatus: Fix a sorting issue in the treewalker
nulltoken [Sat, 29 Oct 2011 15:45:01 +0000 (17:45 +0200)]
status: Fix a sorting issue in the treewalker

This ensures that entries from the working directory are retrieved according to the following rules:

 - The file "subdir" should appear before the file "subdir.txt"
 - The folder "subdir" should appear after the file "subdir.txt"

12 years agostatus: Add a file in the test repository to cover the correct sorting of entries...
nulltoken [Sat, 29 Oct 2011 19:29:31 +0000 (21:29 +0200)]
status: Add a file in the test repository to cover the correct sorting of entries when the working folder is being read

In this case, "subdir.txt" should be listed before the "subdir" directory.

12 years agostatus: Prevent segfaulting when determining the status of a repository
nulltoken [Sat, 29 Oct 2011 15:40:04 +0000 (17:40 +0200)]
status: Prevent segfaulting when determining the status of a repository

Fixes #465

12 years agoMerge pull request #456 from brodie/perm-fixes
Vicent Martí [Sat, 29 Oct 2011 02:04:23 +0000 (19:04 -0700)]
Merge pull request #456 from brodie/perm-fixes

Create objects, indexes, and directories with the right file permissions

12 years agoglobal: Properly use `git__` memory wrappers
Vicent Marti [Fri, 28 Oct 2011 21:51:13 +0000 (14:51 -0700)]
global: Properly use `git__` memory wrappers

Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.

12 years agotree: Add traversal in post-order
Vicent Marti [Fri, 28 Oct 2011 05:33:31 +0000 (22:33 -0700)]
tree: Add traversal in post-order

12 years agoMerge branch 'status' of https://github.com/carlosmn/libgit2 into development
Vicent Marti [Fri, 28 Oct 2011 00:54:17 +0000 (17:54 -0700)]
Merge branch 'status' of https://github.com/carlosmn/libgit2 into development

12 years agostatus: move GIT_STATUS_PATH_* into an enum
Carlos Martín Nieto [Sat, 22 Oct 2011 10:36:30 +0000 (12:36 +0200)]
status: move GIT_STATUS_PATH_* into an enum

Their actual values have no meaning, so pack them in an enum.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agostatus: reorder retrieve_head_tree error checks
Carlos Martín Nieto [Sat, 22 Oct 2011 10:33:49 +0000 (12:33 +0200)]
status: reorder retrieve_head_tree error checks

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agostatus: remove git_tree_entry_bypos
Carlos Martín Nieto [Sat, 22 Oct 2011 09:46:22 +0000 (11:46 +0200)]
status: remove git_tree_entry_bypos

The only caller has been changed to treat a NULL tree as a special
case and use the existing git_tree_entry_byindex.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agostatus: remove git_index_entry_bypos
Carlos Martín Nieto [Sat, 22 Oct 2011 09:36:18 +0000 (11:36 +0200)]
status: remove git_index_entry_bypos

This function is already implemented (better) as git_index_get. Change
the only caller to use that function.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoMerge pull request #467 from oleganza/oa-config-parse-fix
Vicent Martí [Thu, 27 Oct 2011 22:33:53 +0000 (15:33 -0700)]
Merge pull request #467 from oleganza/oa-config-parse-fix

Fixed crash in config parser when empty value is encountered.

12 years agoFixed crash in config parser when empty value is encountered.
Oleg Andreev [Thu, 27 Oct 2011 14:45:44 +0000 (16:45 +0200)]
Fixed crash in config parser when empty value is encountered.

Example:

key1 = value1
key2 =

In this config the value will be a bad pointer which config object will attempt to free() causing a crash.

12 years agoMerge pull request #463 from schu/tests-clay-object-raw
Vicent Martí [Thu, 27 Oct 2011 02:25:18 +0000 (19:25 -0700)]
Merge pull request #463 from schu/tests-clay-object-raw

tests-clay: move t01-rawobj.c to clay

12 years agowindows: Add support for non-UTF codepages
Vicent Marti [Wed, 26 Oct 2011 23:43:55 +0000 (16:43 -0700)]
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.

12 years agotests-clay: move t01-rawobj.c to clay
schu [Wed, 19 Oct 2011 11:48:51 +0000 (13:48 +0200)]
tests-clay: move t01-rawobj.c to clay

Signed-off-by: schu <schu-github@schulog.org>
12 years agoMerge pull request #464 from rtyley/development
Vicent Martí [Mon, 24 Oct 2011 21:43:18 +0000 (14:43 -0700)]
Merge pull request #464 from rtyley/development

Tolerate zlib deflation with window size < 32Kb

12 years agoTolerate zlib deflation with window size < 32Kb
Roberto Tyley [Mon, 24 Oct 2011 21:39:03 +0000 (14:39 -0700)]
Tolerate zlib deflation with window size < 32Kb

libgit2 currently identifies loose objects as corrupt if they've been
deflated using a window size less than 32Kb, because the
is_zlib_compressed_data() function doesn't recognise the header
byte as a zlib header. This patch makes the method tolerant of
all valid window sizes (15-bit to 8-bit) - but doesn't sacrifice
it's accuracy in distingushing the standard loose-object format
from the experimental (now abandoned) format. It's based on a patch
which has been merged into C-Git master branch:

https://github.com/git/git/commit/7f684a2aff636f44a506

On memory constrained systems zlib may use a much smaller window
size - working on Agit, I found that Android uses a 4KB window;
giving a header byte of 0x48, not 0x78. Consequently all loose
objects generated by the Android platform appear 'corrupt' :(

It might appear that this patch changes isStandardFormat() to the
point where it could incorrectly identify the experimental format as
the standard one, but the two criteria (bitmask & checksum) can only
give a false result for an experimental object where both of the
following are true:

1) object size is exactly 8 bytes when uncompressed (bitmask)
2) [single-byte in-pack git type&size header] * 256
   + [1st byte of the following zlib header] % 31 = 0 (checksum)

As it happens, for all possible combinations of valid object type
(1-4) and window bits (0-7), the only time when the checksum will be
divisible by 31 is for 0x1838 - ie object type *1*, a Commit - which,
due the fields all Commit objects must contain, could never be as
small as 8 bytes in size.

Given this, the combination of the two criteria (bitmask & checksum)
always correctly determines the buffer format, and is more tolerant
than the previous version.

References:

Android uses a 4KB window for deflation:
http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/native/java_util_zip_Deflater.cpp;h=c0b2feff196e63a7b85d97cf9ae5bb258

Code snippet searching for false positives with the zlib checksum:
https://gist.github.com/1118177

Change-Id: Ifd84cd2bd6b46f087c9984fb4cbd8309f483dec0

12 years agoCMake: use -O0 in debug mode
Carlos Martín Nieto [Sat, 22 Oct 2011 10:25:55 +0000 (12:25 +0200)]
CMake: use -O0 in debug mode

Otherwise, GCC optimizes variables away and gdb can't tell us what's
in them.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agotree: Fix name lookups once and for all
Vicent Marti [Thu, 20 Oct 2011 00:35:19 +0000 (02:35 +0200)]
tree: Fix name lookups once and for all

Double-pass binary search. Jeez.

12 years agotree: Fix lookups by entry name
Vicent Marti [Tue, 18 Oct 2011 23:34:42 +0000 (01:34 +0200)]
tree: Fix lookups by entry name

12 years agomwindow: close LRU window properly
Carlos Martín Nieto [Sat, 15 Oct 2011 21:09:05 +0000 (23:09 +0200)]
mwindow: close LRU window properly

Remove a wrong call to git_mwindow_close which caused a segfault if it
ever did run. In that same piece of code, if the LRU was from the
first wiindow in the list in a different file, we didn't update that
list, so the first element had been freed.

Fix these two issues.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoMerge pull request #459 from brodie/test-improvements
Vicent Martí [Fri, 14 Oct 2011 23:32:00 +0000 (16:32 -0700)]
Merge pull request #459 from brodie/test-improvements

tests: propagate errors from open_temp_repo() instead of exiting

12 years agotests: propagate errors from open_temp_repo() instead of exiting
Brodie Rao [Thu, 11 Aug 2011 22:18:04 +0000 (15:18 -0700)]
tests: propagate errors from open_temp_repo() instead of exiting

This makes it slightly easier to debug test failures when one test
opens a repo, has a failure, and doesn't get a chance to close it for
the next test. Now, instead of getting no feedback, we at least see
test failure information.

12 years ago*: correct and codify various file permissions
Brodie Rao [Tue, 6 Sep 2011 22:48:45 +0000 (15:48 -0700)]
*: correct and codify various file permissions

The following files now have 0444 permissions:

- loose objects
- pack indexes
- pack files
- packs downloaded by fetch
- packs downloaded by the HTTP transport

And the following files now have 0666 permissions:

- config files
- repository indexes
- reflogs
- refs

This brings libgit2 more in line with Git.

Note that git_filebuf_commit() and git_filebuf_commit_at() have both
gained a new mode parameter.

The latter change fixes an important issue where filebufs created with
GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3)
usage). Now we chmod() the file before renaming it into place.

Tests have been added to confirm that new commit, tag, and tree
objects are created with the right permissions. I don't have access to
Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".

12 years agofileops/repository: create (most) directories with 0777 permissions
Brodie Rao [Wed, 7 Sep 2011 22:32:44 +0000 (15:32 -0700)]
fileops/repository: create (most) directories with 0777 permissions

To further match how Git behaves, this change makes most of the
directories libgit2 creates in a git repo have a file mode of
0777. Specifically:

- Intermediate directories created with git_futils_mkpath2file() have
  0777 permissions. This affects odb_loose, reflog, and refs.

- The top level folder for bare repos is created with 0777
  permissions.

- The top level folder for non-bare repos is created with 0755
  permissions.

- /objects/info/, /objects/pack/, /refs/heads/, and /refs/tags/ are
  created with 0777 permissions.

Additionally, the following changes have been made:

- fileops functions that create intermediate directories have grown a
  new dirmode parameter. The only exception to this is filebuf's
  lock_file(), which unconditionally creates intermediate directories
  with 0777 permissions when GIT_FILEBUF_FORCE is set.

- The test runner now sets the umask to 0 before running any
  tests. This ensurses all file mode checks are consistent across
  systems.

- t09-tree.c now does a directory permissions check. I've avoided
  adding this check to other tests that might reuse existing
  directories from the prefabricated test repos. Because they're
  checked into the repo, they have 0755 permissions.

- Other assorted directories created by tests have 0777 permissions.

12 years agofileops/posix: replace usage of "int mode" with "mode_t mode"
Brodie Rao [Fri, 14 Oct 2011 21:18:02 +0000 (14:18 -0700)]
fileops/posix: replace usage of "int mode" with "mode_t mode"

Note: Functions exported from fileops take const mode_t, while the
underlying POSIX wrappers take mode_t.

12 years agoMerge pull request #457 from khalsah/makefile-fix
Vicent Martí [Fri, 14 Oct 2011 01:08:19 +0000 (18:08 -0700)]
Merge pull request #457 from khalsah/makefile-fix

Update Makefile.embed with http-parser dependency

12 years agoAdd src/transports to Makefile sources
Hargobind S. Khalsa [Fri, 14 Oct 2011 01:05:03 +0000 (19:05 -0600)]
Add src/transports to Makefile sources

12 years agoUpdate Makefile.embed with http-parser dependency
Hargobind S. Khalsa [Fri, 14 Oct 2011 00:36:43 +0000 (18:36 -0600)]
Update Makefile.embed with http-parser dependency

12 years agoMerge pull request #448 from nulltoken/ntk/topic/treeentry-random-access
Vicent Martí [Thu, 13 Oct 2011 21:54:12 +0000 (14:54 -0700)]
Merge pull request #448 from nulltoken/ntk/topic/treeentry-random-access

Add git_tree_frompath()

12 years agotree: Add git_tree_frompath() which, given a relative path to a tree entry, retrieves...
nulltoken [Thu, 13 Oct 2011 21:17:19 +0000 (23:17 +0200)]
tree: Add git_tree_frompath() which, given a relative path to a tree entry, retrieves the tree object containing this tree entry

12 years agooid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal
nulltoken [Wed, 12 Oct 2011 12:06:23 +0000 (14:06 +0200)]
oid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal

12 years agoFix minor indentation issues
nulltoken [Tue, 11 Oct 2011 12:42:48 +0000 (14:42 +0200)]
Fix minor indentation issues

12 years agoAdd test commit containing subtrees and files
nulltoken [Sun, 9 Oct 2011 11:13:49 +0000 (13:13 +0200)]
Add test commit containing subtrees and files

12 years agoFix compilation error on Windows
nulltoken [Thu, 13 Oct 2011 20:48:07 +0000 (22:48 +0200)]
Fix compilation error on Windows

12 years agoMerge pull request #454 from brodie/parsing-fixes
Vicent Martí [Thu, 13 Oct 2011 19:16:07 +0000 (12:16 -0700)]
Merge pull request #454 from brodie/parsing-fixes

Improvements to tag, commit, and signature parsing

12 years agoMerge pull request #455 from brodie/pack-fixes
Vicent Martí [Thu, 13 Oct 2011 19:01:06 +0000 (12:01 -0700)]
Merge pull request #455 from brodie/pack-fixes

odb_pack: don't do ambiguity checks for fully qualified SHA1 hashes

12 years agoodb_pack: don't do ambiguity checks for fully qualified SHA1 hashes
Brodie Rao [Wed, 12 Oct 2011 05:05:12 +0000 (22:05 -0700)]
odb_pack: don't do ambiguity checks for fully qualified SHA1 hashes

This makes libgit2 more closely match Git, which only checks for
ambiguous pack entries when given short hashes.

Note that the only time this is ever relevant is when a pack has the
same object more than once (it's happened in the wild, I promise).

12 years agosignature: don't blow up trying to parse names containing '>'
Brodie Rao [Wed, 5 Oct 2011 22:17:37 +0000 (15:17 -0700)]
signature: don't blow up trying to parse names containing '>'

When trying to find the end of an email, instead of starting at the
beginning of the signature, we start at the end of the name (after the
first '<').

This brings libgit2 more in line with Git's behavior when reading out
existing signatures.

However, note that Git does not allow names like these through the
usual porcelain; instead, it silently strips any '>' characters it
sees.

12 years agotag: allow the tagger field to be missing when parsing tags
Brodie Rao [Thu, 11 Aug 2011 23:12:29 +0000 (16:12 -0700)]
tag: allow the tagger field to be missing when parsing tags

Instead of bailing out with an error, this sets tagger to NULL when
the field is missing from the object.

This makes it possible to inspect tags like this one:

http://git.kernel.org/?p=git/git.git;a=tag;h=f25a265a342aed6041ab0cc484224d9ca54b6f41

12 years agotag: avoid a double-free when parsing tags without a tagger field
Brodie Rao [Thu, 11 Aug 2011 21:05:55 +0000 (14:05 -0700)]
tag: avoid a double-free when parsing tags without a tagger field

The v0.99 tag in the Git repo triggers this behavior:

http://git.kernel.org/?p=git/git.git;a=tag;h=d6602ec5194c87b0fc87103ca4d67251c76f233a

Ideally, we'd allow the tag to be instantiated even though the tagger
field is missing, but this at the very least prevents libgit2 from
crashing.

To test this bug, a new repository has been added based on the test
branch in testrepo.git. It contains a "e90810b" tag that looks like
this:

    object e90810b8df3e80c413d903f631643c716887138d
    type commit
    tag e90810b

    This is a very simple tag.

12 years agocommit: properly parse empty commit messages
Brodie Rao [Wed, 10 Aug 2011 03:49:12 +0000 (20:49 -0700)]
commit: properly parse empty commit messages

This ensures commit->message is always non-NULL, even if the commit
message is empty or consists of only a newline.

One such commit can be found in the wild in the jQuery repository:

https://github.com/jquery/jquery/commit/25b424134f9927a5bf0bab5cba836a0aa6c3cfc1

12 years agopkt: move the protocol strings to the top of the file
Carlos Martín Nieto [Sat, 8 Oct 2011 00:44:31 +0000 (02:44 +0200)]
pkt: move the protocol strings to the top of the file

Put them all together so we know where to find them.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agoMove the transports to their own directory
Carlos Martín Nieto [Thu, 6 Oct 2011 22:44:41 +0000 (00:44 +0200)]
Move the transports to their own directory

12 years agonet: plug a few memory leaks
Carlos Martín Nieto [Wed, 5 Oct 2011 22:51:32 +0000 (00:51 +0200)]
net: plug a few memory leaks

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
12 years agohttp: download pack when fetching
Carlos Martín Nieto [Wed, 5 Oct 2011 22:10:11 +0000 (00:10 +0200)]
http: download pack when fetching

Unfortunately, we can't use the function in fetch.c due to chunked
encoding and keep-alive connections.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>