Browse Source

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 <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
main
Elijah Newren 2 years ago committed by Junio C Hamano
parent
commit
0b027f6ca7
  1. 4
      abspath.c
  2. 33
      abspath.h
  3. 1
      apply.c
  4. 1
      archive.c
  5. 1
      builtin/am.c
  6. 1
      builtin/bugreport.c
  7. 1
      builtin/bundle.c
  8. 1
      builtin/clean.c
  9. 1
      builtin/clone.c
  10. 1
      builtin/config.c
  11. 1
      builtin/credential-cache--daemon.c
  12. 1
      builtin/diagnose.c
  13. 1
      builtin/difftool.c
  14. 1
      builtin/fast-import.c
  15. 1
      builtin/fsmonitor--daemon.c
  16. 1
      builtin/gc.c
  17. 1
      builtin/hash-object.c
  18. 1
      builtin/init-db.c
  19. 1
      builtin/log.c
  20. 1
      builtin/mailinfo.c
  21. 1
      builtin/merge-file.c
  22. 1
      builtin/merge.c
  23. 1
      builtin/multi-pack-index.c
  24. 1
      builtin/mv.c
  25. 1
      builtin/rebase.c
  26. 1
      builtin/receive-pack.c
  27. 1
      builtin/rev-parse.c
  28. 1
      builtin/stash.c
  29. 1
      builtin/submodule--helper.c
  30. 1
      builtin/worktree.c
  31. 27
      cache.h
  32. 1
      chdir-notify.c
  33. 1
      compat/disk.h
  34. 1
      compat/mingw.c
  35. 1
      compat/simple-ipc/ipc-win32.c
  36. 1
      config.c
  37. 1
      credential.c
  38. 1
      daemon.c
  39. 1
      diff-no-index.c
  40. 1
      diff.c
  41. 1
      dir.c
  42. 1
      editor.c
  43. 1
      environment.c
  44. 1
      exec-cmd.c
  45. 1
      gettext.c
  46. 1
      lockfile.c
  47. 1
      midx.c
  48. 1
      object-file.c
  49. 1
      parse-options.c
  50. 1
      path.c
  51. 1
      pathspec.c
  52. 1
      remote.c
  53. 1
      repository.c
  54. 1
      rerere.c
  55. 1
      scalar.c
  56. 1
      sequencer.c
  57. 1
      setup.c
  58. 1
      strbuf.c
  59. 1
      submodule.c
  60. 1
      t/helper/test-path-utils.c
  61. 1
      tmp-objdir.c
  62. 1
      trace.c
  63. 1
      trace2/tr2_dst.c
  64. 1
      worktree.c
  65. 1
      wrapper.c

4
abspath.c

@ -1,4 +1,6 @@ @@ -1,4 +1,6 @@
#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "strbuf.h"

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

33
abspath.h

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
#ifndef ABSPATH_H
#define ABSPATH_H

int is_directory(const char *);
char *strbuf_realpath(struct strbuf *resolved, const char *path,
int die_on_error);
char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path,
int die_on_error);
char *real_pathdup(const char *path, int die_on_error);
const char *absolute_path(const char *path);
char *absolute_pathdup(const char *path);

/*
* Concatenate "prefix" (if len is non-zero) and "path", with no
* connecting characters (so "prefix" should end with a "/").
* Unlike prefix_path, this should be used if the named file does
* not have to interact with index entry; i.e. name of a random file
* on the filesystem.
*
* The return value is always a newly allocated string (even if the
* prefix was empty).
*/
char *prefix_filename(const char *prefix, const char *path);

/* Likewise, but path=="-" always yields "-" */
char *prefix_filename_except_for_dash(const char *prefix, const char *path);

static inline int is_absolute_path(const char *path)
{
return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
}

#endif /* ABSPATH_H */

1
apply.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "object-store.h"

1
archive.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
builtin/am.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "builtin.h"
#include "exec-cmd.h"

1
builtin/bugreport.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
#include "parse-options.h"
#include "strbuf.h"

1
builtin/bundle.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
#include "strvec.h"
#include "parse-options.h"

1
builtin/clean.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@

#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "config.h"
#include "dir.h"

1
builtin/clone.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@

#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"

1
builtin/config.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "color.h"

1
builtin/credential-cache--daemon.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "gettext.h"
#include "parse-options.h"

1
builtin/diagnose.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
#include "parse-options.h"
#include "diagnose.h"

1
builtin/difftool.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "builtin.h"
#include "run-command.h"

1
builtin/fast-import.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "gettext.h"
#include "hex.h"

1
builtin/fsmonitor--daemon.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
builtin/gc.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
*/

#include "builtin.h"
#include "abspath.h"
#include "hex.h"
#include "repository.h"
#include "config.h"

1
builtin/hash-object.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
* Copyright (C) Junio C Hamano, 2005
*/
#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"

1
builtin/init-db.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"
#include "refs.h"

1
builtin/log.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
* 2006 Junio Hamano
*/
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
builtin/mailinfo.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
* email to figure out authorship and subject
*/
#include "cache.h"
#include "abspath.h"
#include "builtin.h"
#include "gettext.h"
#include "utf8.h"

1
builtin/merge-file.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "config.h"
#include "gettext.h"

1
builtin/merge.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@

#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "environment.h"

1
builtin/multi-pack-index.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "config.h"
#include "gettext.h"

1
builtin/mv.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
builtin/rebase.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@

#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
#include "hex.h"
#include "run-command.h"

1
builtin/receive-pack.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "repository.h"
#include "config.h"
#include "gettext.h"

1
builtin/rev-parse.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "commit.h"

1
builtin/stash.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"

1
builtin/submodule--helper.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "gettext.h"
#include "hex.h"

1
builtin/worktree.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "checkout.h"
#include "config.h"
#include "builtin.h"

27
cache.h

@ -598,21 +598,6 @@ const char *setup_git_directory(void); @@ -598,21 +598,6 @@ const char *setup_git_directory(void);
char *prefix_path(const char *prefix, int len, const char *path);
char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path);

/*
* Concatenate "prefix" (if len is non-zero) and "path", with no
* connecting characters (so "prefix" should end with a "/").
* Unlike prefix_path, this should be used if the named file does
* not have to interact with index entry; i.e. name of a random file
* on the filesystem.
*
* The return value is always a newly allocated string (even if the
* prefix was empty).
*/
char *prefix_filename(const char *prefix, const char *path);

/* Likewise, but path=="-" always yields "-" */
char *prefix_filename_except_for_dash(const char *prefix, const char *path);

int check_filename(const char *prefix, const char *name);
void verify_filename(const char *prefix,
const char *name,
@ -1160,18 +1145,6 @@ char *interpolate_path(const char *path, int real_home); @@ -1160,18 +1145,6 @@ char *interpolate_path(const char *path, int real_home);
/* NEEDSWORK: remove this synonym once in-flight topics have migrated */
#define expand_user_path interpolate_path
const char *enter_repo(const char *path, int strict);
static inline int is_absolute_path(const char *path)
{
return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
}
int is_directory(const char *);
char *strbuf_realpath(struct strbuf *resolved, const char *path,
int die_on_error);
char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path,
int die_on_error);
char *real_pathdup(const char *path, int die_on_error);
const char *absolute_path(const char *path);
char *absolute_pathdup(const char *path);
const char *remove_leading_path(const char *in, const char *prefix);
const char *relative_path(const char *in, const char *prefix, struct strbuf *sb);
int normalize_path_copy_len(char *dst, const char *src, int *prefix_len);

1
chdir-notify.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "chdir-notify.h"
#include "list.h"
#include "strbuf.h"

1
compat/disk.h

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#define COMPAT_DISK_H

#include "git-compat-util.h"
#include "abspath.h"
#include "gettext.h"

static int get_disk_info(struct strbuf *out)

1
compat/mingw.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "../strbuf.h"
#include "../run-command.h"
#include "../cache.h"
#include "../abspath.h"
#include "../alloc.h"
#include "win32/lazyload.h"
#include "../config.h"

1
compat/simple-ipc/ipc-win32.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "gettext.h"
#include "simple-ipc.h"
#include "strbuf.h"

1
config.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
*
*/
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "date.h"
#include "branch.h"

1
credential.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "credential.h"
#include "gettext.h"

1
daemon.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "pkt-line.h"

1
diff-no-index.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "color.h"
#include "commit.h"
#include "blob.h"

1
diff.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
* Copyright (C) 2005 Junio C Hamano
*/
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
dir.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
* Junio Hamano, 2005-2006
*/
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "dir.h"

1
editor.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"
#include "strbuf.h"

1
environment.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
* are.
*/
#include "cache.h"
#include "abspath.h"
#include "branch.h"
#include "environment.h"
#include "gettext.h"

1
exec-cmd.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "quote.h"

1
gettext.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "strbuf.h"

1
lockfile.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "gettext.h"
#include "lockfile.h"


1
midx.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "csum-file.h"

1
object-file.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
* creation etc.
*/
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
parse-options.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "parse-options.h"
#include "abspath.h"
#include "cache.h"
#include "config.h"
#include "commit.h"

1
path.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
* Utilities for paths and pathnames
*/
#include "cache.h"
#include "abspath.h"
#include "gettext.h"
#include "hex.h"
#include "repository.h"

1
pathspec.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"

1
remote.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
repository.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "abspath.h"
#include "repository.h"
#include "object-store.h"
#include "config.h"

1
rerere.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "gettext.h"

1
scalar.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "gettext.h"
#include "parse-options.h"
#include "config.h"

1
sequencer.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "environment.h"

1
setup.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "gettext.h"
#include "repository.h"
#include "config.h"

1
strbuf.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "environment.h"
#include "gettext.h"

1
submodule.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "repository.h"
#include "config.h"

1
t/helper/test-path-utils.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
#include "abspath.h"
#include "string-list.h"
#include "utf8.h"


1
tmp-objdir.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "tmp-objdir.h"
#include "abspath.h"
#include "chdir-notify.h"
#include "dir.h"
#include "sigchain.h"

1
trace.c

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
*/

#include "cache.h"
#include "abspath.h"
#include "quote.h"

struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };

1
trace2/tr2_dst.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "sigchain.h"
#include "trace2/tr2_dst.h"
#include "trace2/tr2_sid.h"

1
worktree.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "abspath.h"
#include "alloc.h"
#include "gettext.h"
#include "repository.h"

1
wrapper.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
* Various trivial helper wrappers around standard functions
*/
#include "cache.h"
#include "abspath.h"
#include "config.h"
#include "gettext.h"


Loading…
Cancel
Save