Commit Graph

1738 Commits

Author SHA1 Message Date
Carlos Martín Nieto
5fa1bed0f7 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>
2011-10-15 23:25:48 +02:00
Vicent Martí
a014a083d9 Merge pull request #459 from brodie/test-improvements
tests: propagate errors from open_temp_repo() instead of exiting
2011-10-14 16:32:00 -07:00
Brodie Rao
252840a59f 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.
2011-10-14 16:20:23 -07:00
Brodie Rao
01ad7b3a9e *: 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".
2011-10-14 16:07:47 -07:00
Brodie Rao
ce8cd006ce 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.
2011-10-14 16:04:34 -07:00
Brodie Rao
33127043b3 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.
2011-10-14 15:57:15 -07:00
Vicent Martí
1776f5ab49 Merge pull request #457 from khalsah/makefile-fix
Update Makefile.embed with http-parser dependency
2011-10-13 18:08:19 -07:00
Hargobind S. Khalsa
d42eff0344 Add src/transports to Makefile sources 2011-10-13 19:05:03 -06:00
Hargobind S. Khalsa
7fcddeb68b Update Makefile.embed with http-parser dependency 2011-10-13 18:44:14 -06:00
Vicent Martí
b7e1dd1603 Merge pull request #448 from nulltoken/ntk/topic/treeentry-random-access
Add git_tree_frompath()
2011-10-13 14:54:12 -07: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
nulltoken
a6c0e4d202 Fix minor indentation issues 2011-10-13 22:49:05 +02:00
nulltoken
b3f993e287 Add test commit containing subtrees and files 2011-10-13 22:48:58 +02:00
nulltoken
a41e9f131e Fix compilation error on Windows 2011-10-13 22:48:07 +02:00
Vicent Martí
5c3d5fb018 Merge pull request #454 from brodie/parsing-fixes
Improvements to tag, commit, and signature parsing
2011-10-13 12:16:07 -07:00
Vicent Martí
a3e23a7c0a Merge pull request #455 from brodie/pack-fixes
odb_pack: don't do ambiguity checks for fully qualified SHA1 hashes
2011-10-13 12:01:06 -07:00
Brodie Rao
b2a2702da2 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).
2011-10-12 17:34:04 -07:00
Brodie Rao
6f2856f308 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.
2011-10-12 16:19:46 -07:00
Brodie Rao
15b0bed2ba 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
2011-10-12 16:09:16 -07:00
Brodie Rao
cf7b13f3c3 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.
2011-10-12 16:06:25 -07:00
Brodie Rao
04f788023f 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:

25b424134f
2011-10-12 15:14:25 -07:00
Carlos Martín Nieto
3707b331e2 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>
2011-10-12 21:34:25 +02:00
Carlos Martín Nieto
dfafb03bdc Move the transports to their own directory 2011-10-12 21:34:25 +02:00
Carlos Martín Nieto
8c2528748d net: plug a few memory leaks
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
546a3c8f9e 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>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
03e4833b09 remote: bitfield should be unsigned
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
fc3e3c5577 git transport: don't loose received data
Using a different buffer in each function means that some data might
get lost. Store all the data in a buffer in the transport object.

Take this opportunity to use the generic download-pack function.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
2c982daa2e fetch: add a generic pack-download function
Taken mostly from the git transport's version, this can be used by any
transport that takes its pack data from the network.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
51760bc13d pkt: get rid of the chunked support
It was a bad idea.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
e5e92c1fab http: simple negotiation
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
65c86048cb Introduce the git_pkt_buffer_ family of functions
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
f9613325f1 http: parse the response from the server
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
cbb2feded6 http: add a set of common refs
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
3313a05a47 http: move stuff out of negotiate_fetch
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:19 +02:00
Carlos Martín Nieto
1636ba5a0d transport: don't have an extra send-wants step
It's a bit awkward to run it as an extra step, and HTTP may need to
send the wants list several times.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:18 +02:00
Carlos Martín Nieto
747bf5f14c http: Start negotiate_fetch 2011-10-12 21:33:18 +02:00
Carlos Martín Nieto
34bfb4b0d4 net,pkt: add chunked support
As we don't know the length of the message we want to send to the
other end, we send a chunk size before each message. In later
versions, sending the wants might benefit from batching the lines
together.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:18 +02:00
Carlos Martín Nieto
eb07a4d1dd http: add more modularity to the code
Not every request needs a new connection if we're using a keep-alive
connection. Store the HTTP parser, host and port in the transport in
order to have it available in later calls.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:18 +02:00
Vicent Marti
502dd2dadb msvc: Fix resourc embedding 2011-10-12 12:09:56 -07: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
Vicent Martí
bff5f4e396 Merge pull request #452 from carlosmn/cmake-respect-user
Assorted CMake fixes
2011-10-11 15:11:23 -07:00
Carlos Martín Nieto
5cb7a1addf Explain how to build universal OSX binaries
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-11 18:14:13 +02:00
Carlos Martín Nieto
5b216d1a6f CMake: don't overwrite the user's CFLAGS
If either CFLAGS is defined or the user passes -DCMAKE_C_FLAGS to
cmake, the variable already contains flags. Don't overwrite them, but
append them to our settings.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-11 18:08:54 +02:00
Carlos Martín Nieto
dcd62cb2e9 CMake: Only add the STDCALL option when using MSVC
This option is only ever used with MSVC.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-11 17:57:00 +02:00
Carlos Martín Nieto
8f9be31677 fetch: move 'head' so it's visible to the whole function
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-09 21:49:10 +02:00
Vicent Martí
6aac5afb6d Merge pull request #444 from carlosmn/fetch-fixes
A couple of fetch fixes
2011-10-09 12:09:57 -07:00
Sven Strickroth
cf9bf6b787 include version information in git2.dll on Windows
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 18:55:28 +02: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
da2281c7c0 libgit2 doesn't use -LIB define
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 18:35:42 +02:00