summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-05-28 10:18:05 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-28 15:40:22 +0200
commit94f742bac60656f4f915711b953814477633b984 (patch)
tree2b2cf58cd8268efda0d23d73bd5e019f912c3ae2 /src/fileops.c
parentc1dbfcbb4a5ca92ae90f1bdb7004edb2eb86284c (diff)
downloadlibgit2-94f742bac60656f4f915711b953814477633b984.tar.gz
fileops: allow linking files when copying directory structures
When passed the LINK_FILES flag, the recursive copy will hardlink files instead of copying them.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fileops.c b/src/fileops.c
index 13b8f6a39..bebbae4f9 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -740,9 +740,11 @@ static int _cp_r_callback(void *ref, git_buf *from)
return error;
/* make symlink or regular file */
- if (S_ISLNK(from_st.st_mode))
+ if (info->flags & GIT_CPDIR_LINK_FILES) {
+ error = p_link(from->ptr, info->to.ptr);
+ } else if (S_ISLNK(from_st.st_mode)) {
error = cp_link(from->ptr, info->to.ptr, (size_t)from_st.st_size);
- else {
+ } else {
mode_t usemode = from_st.st_mode;
if ((info->flags & GIT_CPDIR_SIMPLE_TO_MODE) != 0)