summaryrefslogtreecommitdiff
path: root/src/blob.c
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-03-25 14:42:53 -0700
committerVicent Martí <vicent@github.com>2013-03-25 14:42:53 -0700
commitf17951d6ea4ba18c68716a89d7b7464e40ec98f7 (patch)
tree468b0ba5739118b56d1961063655ffbbf95d8a12 /src/blob.c
parent13640d1bb8376e3f07f66498a5b9bdde9ff3d7d6 (diff)
parent3658e81e3499f874dc9f323d4d9127df7e219e12 (diff)
downloadlibgit2-f17951d6ea4ba18c68716a89d7b7464e40ec98f7.tar.gz
Merge pull request #1431 from libgit2/autocrlf-fixes
Fix crlf handling, particularly when autocrlf=true
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/blob.c b/src/blob.c
index bcb6ac96b..c0514fc13 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -12,6 +12,7 @@
#include "common.h"
#include "blob.h"
#include "filter.h"
+#include "buf_text.h"
const void *git_blob_rawcontent(const git_blob *blob)
{
@@ -221,7 +222,9 @@ int git_blob_create_fromworkdir(git_oid *oid, git_repository *repo, const char *
return -1;
}
- error = blob_create_internal(oid, repo, git_buf_cstr(&full_path), git_buf_cstr(&full_path), true);
+ error = blob_create_internal(
+ oid, repo, git_buf_cstr(&full_path),
+ git_buf_cstr(&full_path) + strlen(workdir), true);
git_buf_free(&full_path);
return error;
@@ -231,13 +234,21 @@ int git_blob_create_fromdisk(git_oid *oid, git_repository *repo, const char *pat
{
int error;
git_buf full_path = GIT_BUF_INIT;
+ const char *workdir, *hintpath;
if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
git_buf_free(&full_path);
return error;
}
- error = blob_create_internal(oid, repo, git_buf_cstr(&full_path), git_buf_cstr(&full_path), true);
+ hintpath = git_buf_cstr(&full_path);
+ workdir = git_repository_workdir(repo);
+
+ if (workdir && !git__prefixcmp(hintpath, workdir))
+ hintpath += strlen(workdir);
+
+ error = blob_create_internal(
+ oid, repo, git_buf_cstr(&full_path), hintpath, true);
git_buf_free(&full_path);
return error;