@matheusbsbs / matheus-bagliano / commits / ecf4831d89
Fork 0

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>

Steffen Prohaska committed Nov 25, 2007 at 23:29 UTC ecf4831d89ba6986249e1bf232b2e2f5f7536223
4 files changed +4 -4
diff-lib.c
+1 -1
@@ -231,7 +231,7 @@ static int handle_diff_files_args(struct rev_info *revs,
231 static int is_outside_repo(const char *path, int nongit, const char *prefix)
232 {
233 int i;
234 - if (nongit || !strcmp(path, "-") || path[0] == '/')
234 + if (nongit || !strcmp(path, "-") || is_absolute_path(path))
235 return 1;
236 if (prefixcmp(path, "../"))
237 return 0;
lockfile.c
+1 -1
@@ -94,7 +94,7 @@ static char *resolve_symlink(char *p, size_t s)
94 return p;
95 }
96
97 - if (link[0] == '/') {
97 + if (is_absolute_path(link)) {
98 /* absolute path simply replaces p */
99 if (link_len < s)
100 strcpy(p, link);
setup.c
+1 -1
@@ -59,7 +59,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
59 const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
60 {
61 static char path[PATH_MAX];
62 - if (!pfx || !*pfx || arg[0] == '/')
62 + if (!pfx || !*pfx || is_absolute_path(arg))
63 return arg;
64 memcpy(path, pfx, pfx_len);
65 strcpy(path + pfx_len, arg);
trace.c
+1 -1
@@ -37,7 +37,7 @@ static int get_trace_fd(int *need_close)
37 return STDERR_FILENO;
38 if (strlen(trace) == 1 && isdigit(*trace))
39 return atoi(trace);
40 - if (*trace == '/') {
40 + if (is_absolute_path(trace)) {
41 int fd = open(trace, O_WRONLY | O_APPEND | O_CREAT, 0666);
42 if (fd == -1) {
43 fprintf(stderr,