Skip to content

Commit 0b027f6

Browse files
newrengitster
authored andcommitted
abspath.h: move absolute path functions from cache.h
This is another step towards letting us remove the include of cache.h in strbuf.c. It does mean that we also need to add includes of abspath.h in a number of C files. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ee24e1 commit 0b027f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+98
-28
lines changed

abspath.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include "cache.h"
1+
#include "git-compat-util.h"
2+
#include "abspath.h"
3+
#include "strbuf.h"
24

35
/*
46
* Do not use this for inspecting *tracked* content. When path is a

abspath.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef ABSPATH_H
2+
#define ABSPATH_H
3+
4+
int is_directory(const char *);
5+
char *strbuf_realpath(struct strbuf *resolved, const char *path,
6+
int die_on_error);
7+
char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path,
8+
int die_on_error);
9+
char *real_pathdup(const char *path, int die_on_error);
10+
const char *absolute_path(const char *path);
11+
char *absolute_pathdup(const char *path);
12+
13+
/*
14+
* Concatenate "prefix" (if len is non-zero) and "path", with no
15+
* connecting characters (so "prefix" should end with a "/").
16+
* Unlike prefix_path, this should be used if the named file does
17+
* not have to interact with index entry; i.e. name of a random file
18+
* on the filesystem.
19+
*
20+
* The return value is always a newly allocated string (even if the
21+
* prefix was empty).
22+
*/
23+
char *prefix_filename(const char *prefix, const char *path);
24+
25+
/* Likewise, but path=="-" always yields "-" */
26+
char *prefix_filename_except_for_dash(const char *prefix, const char *path);
27+
28+
static inline int is_absolute_path(const char *path)
29+
{
30+
return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
31+
}
32+
33+
#endif /* ABSPATH_H */

apply.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include "cache.h"
11+
#include "abspath.h"
1112
#include "alloc.h"
1213
#include "config.h"
1314
#include "object-store.h"

archive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "git-compat-util.h"
2+
#include "abspath.h"
23
#include "alloc.h"
34
#include "config.h"
45
#include "gettext.h"

builtin/am.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#define USE_THE_INDEX_VARIABLE
77
#include "cache.h"
8+
#include "abspath.h"
89
#include "config.h"
910
#include "builtin.h"
1011
#include "exec-cmd.h"

builtin/bugreport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "builtin.h"
2+
#include "abspath.h"
23
#include "gettext.h"
34
#include "parse-options.h"
45
#include "strbuf.h"

builtin/bundle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "builtin.h"
2+
#include "abspath.h"
23
#include "gettext.h"
34
#include "strvec.h"
45
#include "parse-options.h"

builtin/clean.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#define USE_THE_INDEX_VARIABLE
1010
#include "builtin.h"
11+
#include "abspath.h"
1112
#include "cache.h"
1213
#include "config.h"
1314
#include "dir.h"

builtin/clone.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define USE_THE_INDEX_VARIABLE
1212
#include "builtin.h"
13+
#include "abspath.h"
1314
#include "config.h"
1415
#include "gettext.h"
1516
#include "hex.h"

builtin/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "builtin.h"
2+
#include "abspath.h"
23
#include "alloc.h"
34
#include "config.h"
45
#include "color.h"

0 commit comments

Comments
 (0)