Use is_absolute_path() in diff-lib.c, lockfile.c, setup.c, trace.c
Using the helper function to test for absolute paths makes porting easier. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e0fda6abd1
commit
ecf4831d89
@ -231,7 +231,7 @@ static int handle_diff_files_args(struct rev_info *revs,
|
|||||||
static int is_outside_repo(const char *path, int nongit, const char *prefix)
|
static int is_outside_repo(const char *path, int nongit, const char *prefix)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (nongit || !strcmp(path, "-") || path[0] == '/')
|
if (nongit || !strcmp(path, "-") || is_absolute_path(path))
|
||||||
return 1;
|
return 1;
|
||||||
if (prefixcmp(path, "../"))
|
if (prefixcmp(path, "../"))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -94,7 +94,7 @@ static char *resolve_symlink(char *p, size_t s)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link[0] == '/') {
|
if (is_absolute_path(link)) {
|
||||||
/* absolute path simply replaces p */
|
/* absolute path simply replaces p */
|
||||||
if (link_len < s)
|
if (link_len < s)
|
||||||
strcpy(p, link);
|
strcpy(p, link);
|
||||||
|
2
setup.c
2
setup.c
@ -59,7 +59,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
|
|||||||
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||||
{
|
{
|
||||||
static char path[PATH_MAX];
|
static char path[PATH_MAX];
|
||||||
if (!pfx || !*pfx || arg[0] == '/')
|
if (!pfx || !*pfx || is_absolute_path(arg))
|
||||||
return arg;
|
return arg;
|
||||||
memcpy(path, pfx, pfx_len);
|
memcpy(path, pfx, pfx_len);
|
||||||
strcpy(path + pfx_len, arg);
|
strcpy(path + pfx_len, arg);
|
||||||
|
2
trace.c
2
trace.c
@ -37,7 +37,7 @@ static int get_trace_fd(int *need_close)
|
|||||||
return STDERR_FILENO;
|
return STDERR_FILENO;
|
||||||
if (strlen(trace) == 1 && isdigit(*trace))
|
if (strlen(trace) == 1 && isdigit(*trace))
|
||||||
return atoi(trace);
|
return atoi(trace);
|
||||||
if (*trace == '/') {
|
if (is_absolute_path(trace)) {
|
||||||
int fd = open(trace, O_WRONLY | O_APPEND | O_CREAT, 0666);
|
int fd = open(trace, O_WRONLY | O_APPEND | O_CREAT, 0666);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user