Commit Graph

109 Commits

Author SHA1 Message Date
Carlos Martín Nieto
0c49ec2d3b 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>
2011-11-07 20:34:27 +01:00
Vicent Martí
89fb8f025a Merge pull request #456 from brodie/perm-fixes
Create objects, indexes, and directories with the right file permissions
2011-10-28 19:04:23 -07: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
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
Carlos Martín Nieto
dd44887ac6 Implment p_access and use it in git_fileutils_exists
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-23 00:00:05 +02: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
Vicent Marti
f978b748bb compat: Move mkstemp to the POSIX compat layer 2011-08-30 13:34:14 +02:00
Carlos Martín Nieto
c3da9f062d Add git_futils_readbuffer_updated
This extends the git_fuitls_readbuffer function to only read in if the
file's modification date is later than the given one. Some code paths
want to check a file's modification date in order to decide whether
they should read it or not. If they do want to read it, another stat
call is done by futils. This function combines these two operations so
we avoid one stat call each time we read a new or updated file.

The git_futils_readbuffer functions is now a wrapper around the new
function.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-23 14:30:40 +02:00
Vicent Marti
858dba58bf refs: Cleanup reference renaming
`git_futils_rmdir_r`: rename, clean up.

`git_reference_rename`: cleanup. Do not use 3x4096 buffers on the stack
or things will get ugly very fast. We can reuse the same buffer.
2011-07-06 18:08:13 +02:00
nulltoken
1b938a5826 Remove duplicated recursive directory removal related code 2011-07-06 12:25:27 +02:00
nulltoken
1ee5fd903d Fix windows specific issues
- msvc compilation warnings
 - not released file handle that prevents file removal
2011-07-06 12:25:27 +02:00
schu
42b3a46097 fileops: add git_futils_rmdir_recurs()
git_futils_rmdir_recurs() shall remove the given directory and all
subdirectories. This happens only if the directories are empty.

Signed-off-by: schu <schu-github@schulog.org>
2011-07-06 12:25:27 +02:00
schu
e190da78f3 fileops: add convenience function is_dot_or_dotdot()
Signed-off-by: schu <schu-github@schulog.org>
2011-07-06 12:25:27 +02:00
Vicent Marti
eec3fe394a fileutils: Finish dropping the old prettify_path 2011-07-05 02:09:05 +02:00
Vicent Marti
19ac1ed702 fileops: Fix stat() on directories for W32
The `stat` methods were having issues when called with a trailing slash
in Windows platforms.

We now use GetFileAttributes() where possible, which doesn't have this
restriction.
2011-07-05 02:08:09 +02:00
Vicent Marti
5ad739e832 fileops: Drop git_fileops_prettify_path
The old `git_fileops_prettify_path` has been replaced with
`git_path_prettify`. This is a much simpler method that uses the OS's
`realpath` call to obtain the full path for directories and resolve
symlinks.

The `realpath` syscall is the original POSIX call in Unix system and
an emulated version under Windows using the Windows API.
2011-07-05 02:06:26 +02:00
Vicent Marti
f79026b491 fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.

fileops.c now contains a set of utility methods for file management used
by the library. These are abstractions on top of the original POSIX
calls.

There's a new file called `posix.c` that contains
emulations/reimplementations of all the POSIX calls the library uses.
These are prefixed with `p_`. There's a specific posix file for each
platform (win32 and unix).

All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
2011-07-05 02:04:03 +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
nulltoken
6ac91dfe52 Hide ".git" directory on Windows upon creation of a non bare repository
Directory which name starts with a dot are hidden on Linux platforms. This patch makes libgit2 behaves similarly on Windows.
2011-06-29 19:22:24 +02:00
Vicent Marti
ab7941b5d9 test: Properly show error messages 2011-06-28 21:10:51 +02:00
schu
28f7869dee gitfo_read: fix read-loop
Signed-off-by: schu <schu-github@schulog.org>
2011-06-20 17:28:59 +02:00
Vicent Marti
e35e9fb4c3 mingw: Fix compilation 2011-06-18 13:23:19 +02:00
Vicent Marti
02285482f1 fileops: Cast the GetProcAddress value 2011-06-17 19:19:30 +02:00
Vicent Marti
9c11bd0a06 fileops: Fix 'GetFinalPathNameByHandleA' in old platforms 2011-06-17 19:09:18 +02:00
Vicent Martí
f2bb894e64 Merge pull request #251 from nulltoken/fix/msvc-warnings
Fix compilation warnings in MSVC
2011-06-15 12:15:11 -07:00
nulltoken
a64bf21bbb blob: Fix git_blob_create_fromfile() 2011-06-15 21:10:10 +02:00
nulltoken
63fadf99dc Add mode_t definition in MSVC compat layer 2011-06-15 19:45:33 +02:00
nulltoken
9e3aa94764 Fix compilation warnings in MSVC 2011-06-12 07:37:50 +02:00
Sebastian Schuberth
3f66c20202 Use "__inline" instead of "inline" with MSVC
MSVC supports "inline" only in C++ code, not in C code.
2011-06-10 13:57:01 +02:00
Sebastian Schuberth
535ff384e2 Prefer to use S_IFLNK instead of _S_IFLNK for consistency 2011-06-10 13:54:47 +02:00
Vicent Marti
ae496955d2 windows: Fix Symlink issues
Handle Symlinks if they can be handled in Win32. This is not even
compiled. Needs review.

The lstat implementation is modified from core Git.
The readlink implementation is modified from PHP.
2011-06-08 17:03:41 +02:00
Vicent Martí
3a12891f53 Merge pull request #243 from jpfender/symlinks2
Symlinks NEW
2011-06-07 07:07:45 -07:00
Vicent Martí
275c6a0b37 Merge pull request #242 from schu/fix-unused-2
fileops.c: fix unused warning v2
2011-06-07 07:03:14 -07:00
Jakob Pfender
fdd1e04ce7 fileops: Allow differentiation between deep and shallow exists()
When calling gitfo_exists() on a symbolic link, sometimes we need to
simply check whether the link exists and sometimes we need to check
whether the file pointed to by the symlink exists.

Introduce a new function gitfo_shallow_exists that only checks if the
link exists and revert gitfo_exists to the original functionality of
checking whether the file pointed to by the link exists.
2011-06-07 14:10:06 +02:00
Jakob Pfender
1869b31e0c index/fileops: Correctly process symbolic links
gitfo_exists() used to error out if the given file was a symbolic link,
due to access() returning an error code. This is not expected behaviour,
as gitfo_exists() should only check whether the file itself exists, not
its link target if it is a symbolic link.

Fix this by calling gitfo_lstat() instead, which is just a wrapper for
lstat().

Also fix the same error in index_init_entry().
2011-06-07 12:54:37 +02:00
schu
05b49b02ef fileops.c: fix unused warning
Signed-off-by: schu <schu-github@schulog.org>
2011-06-06 12:17:58 +02:00
Romain Geissler
a993e4fe06 Fileops: Fixed gitfo_mkdir_recurs so that it proprely works with a path without trailing slash.
It used to discard the last directory if the path didn't have a trailing slash.
2011-06-05 00:20:35 +02:00
Romain Geissler
f2e6b8776e Repository: Added some util functions that we'll need to discover repository path.
retrieve_device returns the file device for a given path (so that we can detect device change while walking through parent directories).
abspath returns a canonicalized path, symbolic link free.
retrieive_ceiling_directories_offset returns the biggest path offset that path match in the ceiling directory list (so that we can stop at ceiling directories).
2011-06-04 00:00:28 +02:00
Romain Geissler
1549cba9a4 Filebuf: Fixed a TODO in filebuf (real lock in lock_file)
Added gitfo_creat_locked and gitfo_creat_locked_force
2011-06-03 23:08:42 +02:00
Romain Geissler
bc6484912e Fileops: Added gitfo_isfile.
Conflicts:

	src/fileops.c
2011-06-03 21:20:20 +02:00
unknown
26a98ec8a2 Fileops: Added a fourth argument to the path prettifying functions to use an alternate basepath.
Fixed a Windows TO-DO in the prettifying functions.
2011-06-03 21:04:02 +02:00
Romain Geissler
04fdc10d35 Fileops:retrieve_path_root_offset is now named gitfo_retrieve_path_root_offset (like other public functions). Added platform specific directory separator definition. 2011-06-03 19:26:45 +02:00
schu
f5a86fefa9 gitfo_isdir: fix error message
Signed-off-by: schu <schu-github@schulog.org>
2011-05-29 17:44:14 +02:00
Vicent Marti
d3ca89fe60 fileops: Cleanup 2011-05-23 21:03:01 +03:00
Jakob Pfender
cc2ac058b3 fileops.c: Move to new error handling mechanism 2011-05-23 21:00:40 +03:00
nulltoken
77c3999ca9 Move fileops.c to the new error handling 2011-05-14 14:46:22 +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
7c80c19e1d Fix compilation in MinGW 2011-03-23 01:58:18 +02:00