[PATCH v3] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

2016-03-28 Thread Hui Yiqun
According to strbuf.h, strbuf_detach is the sole supported method to unwrap a memory buffer from its strbuf shell. So we should not return the pointer of strbuf.buf directly. What's more, some memory leakages are solved. --- path.c | 15 ++- 1 file changed, 10 insertions(+), 5 deleti

[PATCH v2] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

2016-03-28 Thread Hui Yiqun
According to strbuf.h, strbuf_detach is the sole supported method to unwrap a memory buffer from its strbuf shell. So we should not return the pointer of strbuf.buf directly. What's more, some memory leakages are solved. --- path.c | 15 ++- 1 file changed, 10 insertions(+), 5 deleti

[PATCH] path.c enter_repo(): fix unproper strbuf unwrapping and memory leakage

2016-03-28 Thread Hui Yiqun
According to strbuf.h, strbuf_detach is the sole supported method to unwrap a memory buffer from its strbuf shell. So we should not return the pointer of strbuf.buf directly. What's more, some memory leakages are solved. --- path.c | 15 ++- 1 file changed, 10 insertions(+), 5 deleti

[PATCH v3/GSoC 5/5] t0301: test credential-cache support of XDG_RUNTIME_DIR

2016-03-23 Thread Hui Yiqun
t0301 now tests git-credential-cache support for XDG user-specific runtime path. Specifically: * if $XDG_RUNTIME_DIR exists, use socket at `$XDG_RUNTIME_DIR/git/credential-cache.sock`. * otherwise, `/tmp/git-$uid/credential-cache.sock` is taken. Helped-by: Jeff King Signed-off-by: Hui Yiqun

[PATCH v3/GSoC 3/5] git-credential-cache: put socket to xdg-compatible path

2016-03-23 Thread Hui Yiqun
move .git-credential-cache/socket to xdg_runtime_dir("credential-cache.sock") Signed-off-by: Hui Yiqun --- credential-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/credential-cache.c b/credential-cache.c index f4afdc6..40d838b 100644 --- a/credential-cac

[PATCH v3/GSoC 4/5] test-lib.sh: unset all environment variables defined in xdg base dir spec[1]

2016-03-23 Thread Hui Yiqun
$XDG_RUNTIME_DIR /tmp/whatever # instead of empty [1] https://specifications.freedesktop.org/basedir-spec /basedir-spec-latest.html Helped-by: Jeff King Signed-off-by: Hui Yiqun --- t/test-lib.sh | 10 ++ 1 file changed, 10 insertions(+) diff --git a/t/test-lib.sh b/t/test-lib.sh

[PATCH v3/GSoC 2/5] path.c: implement xdg_runtime_dir()

2016-03-23 Thread Hui Yiqun
-spec/basedir-spec-latest.html Signed-off-by: Hui Yiqun --- cache.h | 23 +++ path.c | 56 2 files changed, 79 insertions(+) diff --git a/cache.h b/cache.h index ef843c1..f8b649b 100644 --- a/cache.h +++ b/cache.h

[PATCH v3/GSoC 1/5] path.c: implement strbuf_mkpath()

2016-03-23 Thread Hui Yiqun
There were already `mkpath`, `mkpathdup` and `mksnpath` for build filename, but lacked a version of `strbuf_` just like `strbuf_git_path`. It is convenient to build a path and manipulate the result later with strbuf. Signed-off-by: Hui Yiqun --- cache.h | 2 ++ path.c | 21

[PATCH v2/GSoC 2/4] path.c: implement xdg_runtime_dir()

2016-03-20 Thread Hui Yiqun
g the returned string. Signed-off-by: Hui Yiqun --- cache.h | 23 +++ path.c | 56 2 files changed, 79 insertions(+) diff --git a/cache.h b/cache.h index ef843c1..f8b649b 100644 --- a/cache.h +++ b/cache.h @@ -1001,6 +10

[PATCH v2/GSoC 1/4] path.c: implement strbuf_mkpath()

2016-03-19 Thread Hui Yiqun
Common logic of mkpath() and mkpathdup() are collected into a new do_mkpath(). Then, based on do_mkpath(), strbuf_mkpath() is implemented. Signed-off-by: Hui Yiqun --- cache.h | 2 ++ path.c | 21 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cache.h b

[PATCH v2/GSoC 4/4] t0301: test credential-cache support of XDG_RUNTIME_DIR

2016-03-19 Thread Hui Yiqun
-by: Hui Yiqun --- t/t0301-credential-cache.sh | 27 +++ 1 file changed, 27 insertions(+) diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh index 82c8411..892d1ba 100755 --- a/t/t0301-credential-cache.sh +++ b/t/t0301-credential-cache.sh @@ -12,7

[PATCH v2/GSoC 3/4] git-credential-cache: put socket to xdg-compatible path

2016-03-19 Thread Hui Yiqun
move .git-credential-cache/socket to xdg_runtime_dir("credential-cache.sock") Signed-off-by: Hui Yiqun --- credential-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/credential-cache.c b/credential-cache.c index f4afdc6..40d838b 100644 --- a/credential-cac

[PATCH/RFC/GSoC 1/3] path.c: implement xdg_runtime_dir()

2016-03-16 Thread Hui Yiqun
g the returned string. Signed-off-by: Hui Yiqun --- cache.h | 23 +++ path.c | 59 +++ 2 files changed, 82 insertions(+) diff --git a/cache.h b/cache.h index b829410..e640a54 100644 --- a/cache.h +++ b/cache.h @@ -999,6 +9

[PATCH/RFC/GSoC 2/3] git-credential-cache: put socket to xdg-compatible path

2016-03-16 Thread Hui Yiqun
move .git-credential-cache/socket to xdg_runtime_dir("credential-cache.sock") Signed-off-by: Hui Yiqun --- credential-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/credential-cache.c b/credential-cache.c index f4afdc6..40d838b 100644 --- a/credential-cac

[PATCH/RFC/GSoC 3/3] t0301: test credential-cache support of XDG_RUNTIME_DIR

2016-03-16 Thread Hui Yiqun
-by: Hui Yiqun --- t/t0301-credential-cache.sh | 25 + 1 file changed, 25 insertions(+) diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh index 82c8411..0718bb0 100755 --- a/t/t0301-credential-cache.sh +++ b/t/t0301-credential-cache.sh @@ -12,7 +12,32