Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-26 23:43:14 +0400
committerRussell Belfer <rb@github.com>2013-02-26 23:43:14 +0400
commit3c42e4ef7428de18784e04c9cac18de3613144cb (patch)
tree37c1e0a586801be43f5da22e840c5b87ecf66302 /src/fileops.h
parent25a0831f2d71c5802bff7c4a247dbd0315b767ba (diff)
Fix initialization of repo directories
When PR #1359 removed the hooks from the test resources/template directory, it made me realize that the tests for git_repository_init_ext using templates must be pretty shabby because we could not have been testing if the hooks were getting created correctly. So, this started with me recreating a couple of hooks, including a sample and symlink, and adding tests that they got created correctly in the various circumstances, including with the SHARED modes, etc. Unfortunately this uncovered some issues with how directories and symlinks were copied and chmod'ed. Also, there was a FIXME in the code related to the chmod behavior as well. Going back over the directory creation logic for setting up a repository, I found it was a little difficult to read and could result in creating and/or chmod'ing directories that the user almost certainly didn't intend. So that let to this work which makes repo initialization much more careful (and hopefully easier to follow). It required a couple of extensions / changes to core fileops utilities, but I also think those are for the better, at least for git_futils_cp_r in terms of being careful about what actions it takes.
Diffstat (limited to 'src/fileops.h')
-rw-r--r--src/fileops.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fileops.h b/src/fileops.h
index 5495b12cd..9e1f7440e 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -65,6 +65,7 @@ extern int git_futils_mkdir_r(const char *path, const char *base, const mode_t m
* * GIT_MKDIR_CHMOD says to chmod the final directory entry after creation
* * GIT_MKDIR_CHMOD_PATH says to chmod each directory component in the path
* * GIT_MKDIR_SKIP_LAST says to leave off the last element of the path
+ * * GIT_MKDIR_SKIP_LAST2 says to leave off the last 2 elements of the path
* * GIT_MKDIR_VERIFY_DIR says confirm final item is a dir, not just EEXIST
*
* Note that the chmod options will be executed even if the directory already
@@ -76,7 +77,8 @@ typedef enum {
GIT_MKDIR_CHMOD = 4,
GIT_MKDIR_CHMOD_PATH = 8,
GIT_MKDIR_SKIP_LAST = 16,
- GIT_MKDIR_VERIFY_DIR = 32,
+ GIT_MKDIR_SKIP_LAST2 = 32,
+ GIT_MKDIR_VERIFY_DIR = 64,
} git_futils_mkdir_flags;
/**
@@ -162,11 +164,11 @@ extern int git_futils_cp(
* Flags that can be passed to `git_futils_cp_r`.
*/
typedef enum {
- GIT_CPDIR_CREATE_EMPTY_DIRS = 1,
- GIT_CPDIR_COPY_SYMLINKS = 2,
- GIT_CPDIR_COPY_DOTFILES = 4,
- GIT_CPDIR_OVERWRITE = 8,
- GIT_CPDIR_CHMOD = 16
+ GIT_CPDIR_CREATE_EMPTY_DIRS = (1u << 0),
+ GIT_CPDIR_COPY_SYMLINKS = (1u << 1),
+ GIT_CPDIR_COPY_DOTFILES = (1u << 2),
+ GIT_CPDIR_OVERWRITE = (1u << 3),
+ GIT_CPDIR_CHMOD = (1u << 4),
} git_futils_cpdir_flags;
/**