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 <arrbee@arrbee.com>2011-11-30 23:27:15 +0400
committerRussell Belfer <arrbee@arrbee.com>2011-12-08 11:08:15 +0400
commit97769280ba9938ae27f6e06cbd0d5e8a768a86b9 (patch)
tree4fe43e99acb55f904f6b586bd7c5158610f9512f /src/refspec.c
parenta22b14d32dd8d5f06f121aa154d45bac3b10a305 (diff)
Use git_buf for path storage instead of stack-based buffers
This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
Diffstat (limited to 'src/refspec.c')
-rw-r--r--src/refspec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/refspec.c b/src/refspec.c
index 62683e7b7..7ce32ba14 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -93,3 +93,21 @@ int git_refspec_transform(char *out, size_t outlen, const git_refspec *spec, con
return GIT_SUCCESS;
}
+
+int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name)
+{
+ if (git_buf_sets(out, spec->dst) < GIT_SUCCESS)
+ return git_buf_lasterror(out);
+
+ /*
+ * No '*' at the end means that it's mapped to one specific local
+ * branch, so no actual transformation is needed.
+ */
+ if (out->size > 0 && out->ptr[out->size - 1] != '*')
+ return GIT_SUCCESS;
+
+ git_buf_truncate(out, out->size - 1); /* remove trailing '*' */
+ git_buf_puts(out, name);
+
+ return git_buf_lasterror(out);
+}