git-off

git off handles large files in git repos
git clone https://noulin.net/git/git-off.git
Log | Files | Refs | README

commit 8587ab18cfa263b1aac67dbf205040dd71f6a464
parent 50d23e825eba6425f88f46efa9c931ed3e0651c1
Author: Remy Noulin <loader2x@gmail.com>
Date:   Wed, 19 Jul 2017 21:13:31 +0200

fix filenames with spaces in coffeescript version, fix rsyncoptions config

c/git-off.c       | 21 +++++++++++----------
c/gitoff.c        | 21 +++++++++++----------
package.json      |  2 +-
src/git-off       |  5 +++--
src/gitoff.coffee |  7 ++++---
5 files changed, 30 insertions(+), 26 deletions(-)

Diffstat:
Mc/git-off.c | 21+++++++++++----------
Mc/gitoff.c | 21+++++++++++----------
Mpackage.json | 2+-
Msrc/git-off | 5+++--
Msrc/gitoff.coffee | 7++++---
5 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/c/git-off.c b/c/git-off.c @@ -365,8 +365,9 @@ void gitConfig_set(char* key, char* value) { char* p = NULL; char* r = NULL; - p = malloc(strlen(key) + strlen(value) + 1 + 5); - sprintf(p, "%s \"%s\"", key, value); + // dont use double quote, problem with rsyncOptions - p = '%s \"%s\"', key, value + p = malloc(strlen(key) + strlen(value) + 1 + 5);; + sprintf(p, "%s '%s'", key, value); r = exec(gitConfigGlobal, p); free(p); free(r); @@ -1989,20 +1990,20 @@ void offCommands_clean() { offCommands_localSetup(); // create file information (size, sha) - file = argv[2]; + file = argv[2]; //print file struct stat st; stat(file, &st); - size = st.st_size; - quotedFile = malloc(strlen(file) + 1 + 4); - sprintf(quotedFile, "\"%s\"", file); - offFile = exec(sha, quotedFile); + size = st.st_size; + char *quotedFile = malloc(strlen(file) + 1 + 4); + sprintf(char *quotedFile, "\"%s\"", file); + offFile = exec(sha, quotedFile); free(quotedFile); - offFilePath = offHelpers_getOffFilePath(offFile); + offFilePath = offHelpers_getOffFilePath(offFile); - fileDir = malloc(strlen(offHelpers_objectPath()) + strlen(offFilePath[1]) + 1 + 1); + fileDir = malloc(strlen(offHelpers_objectPath()) + strlen(offFilePath[1]) + 1 + 1); sprintf(fileDir, "%s/%s", offHelpers_objectPath(), offFilePath[1]); - d = opendir(fileDir); + d = opendir(fileDir); if (d == NULL) { // create the file directory mkdirParents(fileDir); diff --git a/c/gitoff.c b/c/gitoff.c @@ -364,8 +364,9 @@ void gitConfig_set(char* key, char* value) { char* p = NULL; char* r = NULL; - p = malloc(strlen(key) + strlen(value) + 1 + 5); - sprintf(p, "%s \"%s\"", key, value); + // dont use double quote, problem with rsyncOptions - p = '%s \"%s\"', key, value + p = malloc(strlen(key) + strlen(value) + 1 + 5);; + sprintf(p, "%s '%s'", key, value); r = exec(gitConfigGlobal, p); free(p); free(r); @@ -1988,20 +1989,20 @@ void offCommands_clean() { offCommands_localSetup(); // create file information (size, sha) - file = argv[2]; + file = argv[2]; //print file struct stat st; stat(file, &st); - size = st.st_size; - quotedFile = malloc(strlen(file) + 1 + 4); - sprintf(quotedFile, "\"%s\"", file); - offFile = exec(sha, quotedFile); + size = st.st_size; + char *quotedFile = malloc(strlen(file) + 1 + 4); + sprintf(char *quotedFile, "\"%s\"", file); + offFile = exec(sha, quotedFile); free(quotedFile); - offFilePath = offHelpers_getOffFilePath(offFile); + offFilePath = offHelpers_getOffFilePath(offFile); - fileDir = malloc(strlen(offHelpers_objectPath()) + strlen(offFilePath[1]) + 1 + 1); + fileDir = malloc(strlen(offHelpers_objectPath()) + strlen(offFilePath[1]) + 1 + 1); sprintf(fileDir, "%s/%s", offHelpers_objectPath(), offFilePath[1]); - d = opendir(fileDir); + d = opendir(fileDir); if (d == NULL) { // create the file directory mkdirParents(fileDir); diff --git a/package.json b/package.json @@ -1,6 +1,6 @@ { "name": "git-off", - "version": "0.0.13", + "version": "0.0.14", "description": "large file handler for git", "bin": "./src/git-off", "scripts": { diff --git a/src/git-off b/src/git-off @@ -1004,11 +1004,12 @@ offCommands = { } }, 'clean': function() { - var file, offFile, offFilePath, pipe, r, size, writeStream; + var file, offFile, offFilePath, pipe, quotedFile, r, size, writeStream; offCommands.localSetup(); file = process.argv[3]; size = fs.statSync(file).size; - r = exec('sha', [file]); + quotedFile = '"' + file + '"'; + r = exec('sha', [quotedFile]); offFile = r.stdout.split(' ')[0].trim(); offFilePath = offHelpers.getOffFilePath(offFile); if (fs.existsSync(offHelpers.objectPath() + '/' + offFilePath[1]) === false) { diff --git a/src/gitoff.coffee b/src/gitoff.coffee @@ -1059,9 +1059,10 @@ offCommands = offCommands.localSetup() # create file information (size, sha) - file = process.argv[3] - size = fs.statSync(file).size - r = exec 'sha', [file] + file = process.argv[3] + size = fs.statSync(file).size + quotedFile = '"'+file+'"' + r = exec 'sha', [quotedFile] # trim because git hash-object adds \n offFile = r.stdout.split(' ')[0].trim() offFilePath = offHelpers.getOffFilePath(offFile)