mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-18 06:59:35 +00:00

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.
36 lines
908 B
C
36 lines
908 B
C
/*
|
|
* Copyright (C) 2009-2011 the libgit2 contributors
|
|
*
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
* a Linking Exception. For full terms see the included COPYING file.
|
|
*/
|
|
#ifndef INCLUDE_refspec_h__
|
|
#define INCLUDE_refspec_h__
|
|
|
|
#include "git2/refspec.h"
|
|
#include "buffer.h"
|
|
|
|
struct git_refspec {
|
|
struct git_refspec *next;
|
|
char *src;
|
|
char *dst;
|
|
unsigned int force :1,
|
|
pattern :1,
|
|
matching :1;
|
|
};
|
|
|
|
int git_refspec_parse(struct git_refspec *refspec, const char *str);
|
|
|
|
/**
|
|
* Transform a reference to its target following the refspec's rules,
|
|
* and writes the results into a git_buf.
|
|
*
|
|
* @param out where to store the target name
|
|
* @param spec the refspec
|
|
* @param name the name of the reference to transform
|
|
* @return GIT_SUCCESS or error if buffer allocation fails
|
|
*/
|
|
int git_refspec_transform_r(git_buf *out, const git_refspec *spec, const char *name);
|
|
|
|
#endif
|