| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 1 | /* |
| 2 | * We put all the git config variables in this same object |
| 3 | * file, so that programs can link against the config parser |
| 4 | * without having to link against all the rest of git. |
| 5 | * |
| 6 | * In particular, no need to bring in libz etc unless needed, |
| 7 | * even if you might want to know where the git directory etc |
| 8 | * are. |
| 9 | */ |
| 10 | #include "cache.h" |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 11 | #include "refs.h" |
| Ramsay Jones | 273c703 | 2011-10-09 17:33:34 | [diff] [blame] | 12 | #include "fmt-merge-msg.h" |
| Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 13:02:45 | [diff] [blame] | 13 | #include "commit.h" |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 14 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 15 | int trust_executable_bit = 1; |
| Alex Riesen | 1ce4790 | 2008-07-28 06:31:28 | [diff] [blame] | 16 | int trust_ctime = 1; |
| Robin Rosenberg | c08e4d5 | 2013-01-22 07:49:22 | [diff] [blame] | 17 | int check_stat = 1; |
| Johannes Sixt | 78a8d64 | 2007-03-02 21:11:30 | [diff] [blame] | 18 | int has_symlinks = 1; |
| Linus Torvalds | dce9648 | 2010-10-28 18:28:04 | [diff] [blame] | 19 | int minimum_abbrev = 4, default_abbrev = 7; |
| Linus Torvalds | 0a9b88b | 2008-03-21 23:52:46 | [diff] [blame] | 20 | int ignore_case; |
| David Rientjes | 96f1e58 | 2006-08-15 17:23:48 | [diff] [blame] | 21 | int assume_unchanged; |
| 22 | int prefer_symlink_refs; |
| Junio C Hamano | 7d1864c | 2007-01-07 10:00:28 | [diff] [blame] | 23 | int is_bare_repository_cfg = -1; /* unspecified */ |
| Junio C Hamano | 510c5a8 | 2007-01-07 09:35:34 | [diff] [blame] | 24 | int log_all_ref_updates = -1; /* unspecified */ |
| Junio C Hamano | 1b371f5 | 2006-03-24 07:42:40 | [diff] [blame] | 25 | int warn_ambiguous_refs = 1; |
| Jeff King | 25fba78 | 2013-07-12 06:20:05 | [diff] [blame] | 26 | int warn_on_object_refname_ambiguity = 1; |
| Jeff King | 49672f2 | 2015-03-20 18:43:06 | [diff] [blame] | 27 | int ref_paranoia = -1; |
| David Rientjes | 96f1e58 | 2006-08-15 17:23:48 | [diff] [blame] | 28 | int repository_format_version; |
| Shawn O. Pearce | 1a8f274 | 2007-03-12 19:33:18 | [diff] [blame] | 29 | const char *git_commit_encoding; |
| Shawn O. Pearce | 3a55602 | 2007-03-07 01:44:17 | [diff] [blame] | 30 | const char *git_log_output_encoding; |
| Junio C Hamano | 94df250 | 2006-06-10 06:09:49 | [diff] [blame] | 31 | int shared_repository = PERM_UMASK; |
| David Rientjes | 96f1e58 | 2006-08-15 17:23:48 | [diff] [blame] | 32 | const char *apply_default_whitespace; |
| Giuseppe Bilotta | 86c91f9 | 2009-08-04 11:16:49 | [diff] [blame] | 33 | const char *apply_default_ignorewhitespace; |
| Junio C Hamano | 64589a0 | 2011-10-06 18:22:24 | [diff] [blame] | 34 | const char *git_attributes_file; |
| Dana How | 960ccca | 2007-05-09 20:56:50 | [diff] [blame] | 35 | int zlib_compression_level = Z_BEST_SPEED; |
| 36 | int core_compression_level; |
| 37 | int core_compression_seen; |
| Linus Torvalds | aafe9fb | 2008-06-18 22:18:44 | [diff] [blame] | 38 | int fsync_object_files; |
| Shawn O. Pearce | 8c82534 | 2006-12-24 05:46:13 | [diff] [blame] | 39 | size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE; |
| 40 | size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT; |
| David Kastrup | 4874f54 | 2014-05-04 17:13:57 | [diff] [blame] | 41 | size_t delta_base_cache_limit = 96 * 1024 * 1024; |
| Junio C Hamano | 1536628 | 2011-04-05 17:44:11 | [diff] [blame] | 42 | unsigned long big_file_threshold = 512 * 1024 * 1024; |
| Christian Couder | 872da32 | 2008-02-16 05:01:11 | [diff] [blame] | 43 | const char *pager_program; |
| Matthias Lederhofer | aa086eb | 2006-07-29 22:27:43 | [diff] [blame] | 44 | int pager_use_color = 1; |
| Christian Couder | ee9601e | 2008-02-16 05:01:41 | [diff] [blame] | 45 | const char *editor_program; |
| Anselm Kruis | d3e7da8 | 2010-08-30 13:38:38 | [diff] [blame] | 46 | const char *askpass_program; |
| Christian Couder | dfb068b | 2008-02-16 05:01:59 | [diff] [blame] | 47 | const char *excludes_file; |
| Eyvind Bernhardsen | fd6cce9 | 2010-05-19 20:43:10 | [diff] [blame] | 48 | enum auto_crlf auto_crlf = AUTO_CRLF_FALSE; |
| Michael Haggerty | afc711b | 2014-02-18 11:24:55 | [diff] [blame] | 49 | int check_replace_refs = 1; |
| Junio C Hamano | ec70f52 | 2011-05-09 19:52:12 | [diff] [blame] | 50 | enum eol core_eol = EOL_UNSET; |
| Steffen Prohaska | 21e5ad5 | 2008-02-06 11:25:58 | [diff] [blame] | 51 | enum safe_crlf safe_crlf = SAFE_CRLF_WARN; |
| Junio C Hamano | cf1b786 | 2007-12-06 08:14:14 | [diff] [blame] | 52 | unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; |
| Jay Soffian | 9ed36cf | 2008-02-19 16:24:37 | [diff] [blame] | 53 | enum branch_track git_branch_track = BRANCH_TRACK_REMOTE; |
| Dustin Sallings | c998ae9 | 2008-05-10 22:36:29 | [diff] [blame] | 54 | enum rebase_setup_type autorebase = AUTOREBASE_NEVER; |
| Christopher Tiwald | f25950f | 2012-03-20 04:31:33 | [diff] [blame] | 55 | enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED; |
| Johannes Schindelin | 348df16 | 2009-04-27 22:32:25 | [diff] [blame] | 56 | #ifndef OBJECT_CREATION_MODE |
| 57 | #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS |
| Johannes Schindelin | be66a6c | 2009-04-25 09:57:14 | [diff] [blame] | 58 | #endif |
| Johannes Schindelin | 348df16 | 2009-04-27 22:32:25 | [diff] [blame] | 59 | enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE; |
| Johannes Schindelin | a97a746 | 2009-10-09 10:21:57 | [diff] [blame] | 60 | char *notes_ref_name; |
| Johannes Schindelin | 7f3140c | 2009-07-23 15:33:49 | [diff] [blame] | 61 | int grafts_replace_parents = 1; |
| Nguyễn Thái Ngọc Duy | 08aefc9 | 2009-08-20 13:47:08 | [diff] [blame] | 62 | int core_apply_sparse_checkout; |
| Junio C Hamano | 898eacd | 2011-10-07 06:12:09 | [diff] [blame] | 63 | int merge_log_config = -1; |
| Torsten Bögershausen | 76759c7 | 2012-07-08 13:50:25 | [diff] [blame] | 64 | int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */ |
| Nguyễn Thái Ngọc Duy | e37c132 | 2010-08-06 02:40:35 | [diff] [blame] | 65 | struct startup_info *startup_info; |
| Junio C Hamano | 568508e | 2011-10-28 21:48:40 | [diff] [blame] | 66 | unsigned long pack_size_limit_cfg; |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 67 | |
| Jeff King | a42643a | 2014-12-15 23:15:20 | [diff] [blame] | 68 | #ifndef PROTECT_HFS_DEFAULT |
| 69 | #define PROTECT_HFS_DEFAULT 0 |
| 70 | #endif |
| 71 | int protect_hfs = PROTECT_HFS_DEFAULT; |
| 72 | |
| Johannes Schindelin | 2b4c6ef | 2014-12-16 22:46:59 | [diff] [blame] | 73 | #ifndef PROTECT_NTFS_DEFAULT |
| 74 | #define PROTECT_NTFS_DEFAULT 0 |
| 75 | #endif |
| 76 | int protect_ntfs = PROTECT_NTFS_DEFAULT; |
| 77 | |
| Junio C Hamano | eff80a9 | 2013-01-16 19:18:48 | [diff] [blame] | 78 | /* |
| 79 | * The character that begins a commented line in user-editable file |
| 80 | * that is subject to stripspace. |
| 81 | */ |
| 82 | char comment_line_char = '#'; |
| Nguyễn Thái Ngọc Duy | 84c9dc2 | 2014-05-17 01:52:23 | [diff] [blame] | 83 | int auto_comment_line_char; |
| Junio C Hamano | eff80a9 | 2013-01-16 19:18:48 | [diff] [blame] | 84 | |
| Linus Torvalds | 671c9b7 | 2008-11-14 00:36:30 | [diff] [blame] | 85 | /* Parallel index stat data preload? */ |
| Steve Hoelzer | 299e298 | 2014-06-02 16:43:00 | [diff] [blame] | 86 | int core_preload_index = 1; |
| Linus Torvalds | 671c9b7 | 2008-11-14 00:36:30 | [diff] [blame] | 87 | |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 88 | /* This is set by setup_git_dir_gently() and/or git_default_config() */ |
| 89 | char *git_work_tree_cfg; |
| Daniel Barkalow | 19757d8 | 2008-04-27 17:39:21 | [diff] [blame] | 90 | static char *work_tree; |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 91 | |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 92 | static const char *namespace; |
| 93 | static size_t namespace_len; |
| 94 | |
| Pierre Habouzit | c5fba16 | 2006-08-23 10:39:11 | [diff] [blame] | 95 | static const char *git_dir; |
| Jonathan Nieder | 7f7868e | 2010-10-02 08:35:29 | [diff] [blame] | 96 | static char *git_object_dir, *git_index_file, *git_graft_file; |
| Pierre Habouzit | c5fba16 | 2006-08-23 10:39:11 | [diff] [blame] | 97 | |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 98 | /* |
| Jeff King | 2163e5d | 2013-03-08 09:29:08 | [diff] [blame] | 99 | * Repository-local GIT_* environment variables; see cache.h for details. |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 100 | */ |
| Jeff King | 2163e5d | 2013-03-08 09:29:08 | [diff] [blame] | 101 | const char * const local_repo_env[] = { |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 102 | ALTERNATE_DB_ENVIRONMENT, |
| 103 | CONFIG_ENVIRONMENT, |
| Jonathan Nieder | 655e8d9 | 2010-08-24 06:41:14 | [diff] [blame] | 104 | CONFIG_DATA_ENVIRONMENT, |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 105 | DB_ENVIRONMENT, |
| 106 | GIT_DIR_ENVIRONMENT, |
| 107 | GIT_WORK_TREE_ENVIRONMENT, |
| Jeff King | 2cd83d1 | 2013-03-08 09:32:22 | [diff] [blame] | 108 | GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 109 | GRAFT_ENVIRONMENT, |
| 110 | INDEX_ENVIRONMENT, |
| 111 | NO_REPLACE_OBJECTS_ENVIRONMENT, |
| Jeff King | a6f7f9a | 2013-03-08 09:30:25 | [diff] [blame] | 112 | GIT_PREFIX_ENVIRONMENT, |
| Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 13:02:45 | [diff] [blame] | 113 | GIT_SHALLOW_FILE_ENVIRONMENT, |
| Giuseppe Bilotta | 48a7c1c | 2010-02-24 23:34:14 | [diff] [blame] | 114 | NULL |
| 115 | }; |
| 116 | |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 117 | static char *expand_namespace(const char *raw_namespace) |
| 118 | { |
| 119 | struct strbuf buf = STRBUF_INIT; |
| 120 | struct strbuf **components, **c; |
| 121 | |
| 122 | if (!raw_namespace || !*raw_namespace) |
| 123 | return xstrdup(""); |
| 124 | |
| 125 | strbuf_addstr(&buf, raw_namespace); |
| 126 | components = strbuf_split(&buf, '/'); |
| 127 | strbuf_reset(&buf); |
| 128 | for (c = components; *c; c++) |
| 129 | if (strcmp((*c)->buf, "/") != 0) |
| 130 | strbuf_addf(&buf, "refs/namespaces/%s", (*c)->buf); |
| 131 | strbuf_list_free(components); |
| Michael Haggerty | 8d9c501 | 2011-09-15 21:10:25 | [diff] [blame] | 132 | if (check_refname_format(buf.buf, 0)) |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 133 | die("bad git namespace path \"%s\"", raw_namespace); |
| 134 | strbuf_addch(&buf, '/'); |
| 135 | return strbuf_detach(&buf, NULL); |
| 136 | } |
| 137 | |
| Jeff King | cb6c38d | 2014-06-24 20:58:15 | [diff] [blame] | 138 | static char *git_path_from_env(const char *envvar, const char *path) |
| 139 | { |
| 140 | const char *value = getenv(envvar); |
| 141 | return value ? xstrdup(value) : git_pathdup("%s", path); |
| 142 | } |
| 143 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 144 | static void setup_git_env(void) |
| 145 | { |
| Nguyễn Thái Ngọc Duy | 487a2b7 | 2013-08-31 01:04:14 | [diff] [blame] | 146 | const char *gitfile; |
| Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 13:02:45 | [diff] [blame] | 147 | const char *shallow_file; |
| Nguyễn Thái Ngọc Duy | 487a2b7 | 2013-08-31 01:04:14 | [diff] [blame] | 148 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 149 | git_dir = getenv(GIT_DIR_ENVIRONMENT); |
| Lars Hjemli | b44ebb1 | 2008-02-20 22:13:13 | [diff] [blame] | 150 | if (!git_dir) |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 151 | git_dir = DEFAULT_GIT_DIR_ENVIRONMENT; |
| Nguyễn Thái Ngọc Duy | 487a2b7 | 2013-08-31 01:04:14 | [diff] [blame] | 152 | gitfile = read_gitfile(git_dir); |
| 153 | git_dir = xstrdup(gitfile ? gitfile : git_dir); |
| Jeff King | cb6c38d | 2014-06-24 20:58:15 | [diff] [blame] | 154 | git_object_dir = git_path_from_env(DB_ENVIRONMENT, "objects"); |
| 155 | git_index_file = git_path_from_env(INDEX_ENVIRONMENT, "index"); |
| 156 | git_graft_file = git_path_from_env(GRAFT_ENVIRONMENT, "info/grafts"); |
| Christian Couder | 6476b38 | 2009-11-18 06:50:58 | [diff] [blame] | 157 | if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT)) |
| Michael Haggerty | afc711b | 2014-02-18 11:24:55 | [diff] [blame] | 158 | check_replace_refs = 0; |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 159 | namespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT)); |
| 160 | namespace_len = strlen(namespace); |
| Nguyễn Thái Ngọc Duy | 069c053 | 2013-12-05 13:02:45 | [diff] [blame] | 161 | shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT); |
| 162 | if (shallow_file) |
| 163 | set_alternate_shallow_file(shallow_file, 0); |
| Shawn O. Pearce | 0bee591 | 2006-12-14 22:41:17 | [diff] [blame] | 164 | } |
| 165 | |
| Junio C Hamano | 7d1864c | 2007-01-07 10:00:28 | [diff] [blame] | 166 | int is_bare_repository(void) |
| Shawn O. Pearce | 0bee591 | 2006-12-14 22:41:17 | [diff] [blame] | 167 | { |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 168 | /* if core.bare is not 'false', let's see if there is a work tree */ |
| 169 | return is_bare_repository_cfg && !get_git_work_tree(); |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 170 | } |
| 171 | |
| Pierre Habouzit | c5fba16 | 2006-08-23 10:39:11 | [diff] [blame] | 172 | const char *get_git_dir(void) |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 173 | { |
| 174 | if (!git_dir) |
| 175 | setup_git_env(); |
| 176 | return git_dir; |
| 177 | } |
| 178 | |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 179 | const char *get_git_namespace(void) |
| 180 | { |
| 181 | if (!namespace) |
| 182 | setup_git_env(); |
| 183 | return namespace; |
| 184 | } |
| 185 | |
| 186 | const char *strip_namespace(const char *namespaced_ref) |
| 187 | { |
| Christian Couder | 5955654 | 2013-11-30 20:55:40 | [diff] [blame] | 188 | if (!starts_with(namespaced_ref, get_git_namespace())) |
| Josh Triplett | a1bea2c | 2011-07-05 17:54:44 | [diff] [blame] | 189 | return NULL; |
| 190 | return namespaced_ref + namespace_len; |
| 191 | } |
| 192 | |
| Daniel Barkalow | 19757d8 | 2008-04-27 17:39:21 | [diff] [blame] | 193 | static int git_work_tree_initialized; |
| 194 | |
| 195 | /* |
| 196 | * Note. This works only before you used a work tree. This was added |
| 197 | * primarily to support git-clone to work in a new repository it just |
| 198 | * created, and is not meant to flip between different work trees. |
| 199 | */ |
| 200 | void set_git_work_tree(const char *new_work_tree) |
| 201 | { |
| Nguyễn Thái Ngọc Duy | 8351836 | 2010-11-26 15:32:40 | [diff] [blame] | 202 | if (git_work_tree_initialized) { |
| Carlos Martín Nieto | e2a57aa | 2011-03-17 11:26:46 | [diff] [blame] | 203 | new_work_tree = real_path(new_work_tree); |
| Nguyễn Thái Ngọc Duy | 8351836 | 2010-11-26 15:32:40 | [diff] [blame] | 204 | if (strcmp(new_work_tree, work_tree)) |
| 205 | die("internal error: work tree has already been set\n" |
| 206 | "Current worktree: %s\nNew worktree: %s", |
| 207 | work_tree, new_work_tree); |
| 208 | return; |
| 209 | } |
| Daniel Barkalow | 19757d8 | 2008-04-27 17:39:21 | [diff] [blame] | 210 | git_work_tree_initialized = 1; |
| Carlos Martín Nieto | e2a57aa | 2011-03-17 11:26:46 | [diff] [blame] | 211 | work_tree = xstrdup(real_path(new_work_tree)); |
| Daniel Barkalow | 19757d8 | 2008-04-27 17:39:21 | [diff] [blame] | 212 | } |
| 213 | |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 214 | const char *get_git_work_tree(void) |
| 215 | { |
| Johannes Schindelin | e90fdc3 | 2007-08-01 00:30:14 | [diff] [blame] | 216 | return work_tree; |
| 217 | } |
| 218 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 219 | char *get_object_directory(void) |
| 220 | { |
| 221 | if (!git_object_dir) |
| 222 | setup_git_env(); |
| 223 | return git_object_dir; |
| 224 | } |
| 225 | |
| Jonathan Nieder | 463db9b | 2010-11-06 11:45:38 | [diff] [blame] | 226 | int odb_mkstemp(char *template, size_t limit, const char *pattern) |
| 227 | { |
| 228 | int fd; |
| 229 | /* |
| 230 | * we let the umask do its job, don't try to be more |
| 231 | * restrictive except to remove write permission. |
| 232 | */ |
| 233 | int mode = 0444; |
| 234 | snprintf(template, limit, "%s/%s", |
| 235 | get_object_directory(), pattern); |
| 236 | fd = git_mkstemp_mode(template, mode); |
| 237 | if (0 <= fd) |
| 238 | return fd; |
| 239 | |
| 240 | /* slow path */ |
| 241 | /* some mkstemp implementations erase template on failure */ |
| 242 | snprintf(template, limit, "%s/%s", |
| 243 | get_object_directory(), pattern); |
| 244 | safe_create_leading_directories(template); |
| 245 | return xmkstemp_mode(template, mode); |
| 246 | } |
| 247 | |
| Nguyễn Thái Ngọc Duy | 8640d49 | 2014-03-16 13:35:00 | [diff] [blame] | 248 | int odb_pack_keep(char *name, size_t namesz, const unsigned char *sha1) |
| Jonathan Nieder | 463db9b | 2010-11-06 11:45:38 | [diff] [blame] | 249 | { |
| 250 | int fd; |
| 251 | |
| 252 | snprintf(name, namesz, "%s/pack/pack-%s.keep", |
| 253 | get_object_directory(), sha1_to_hex(sha1)); |
| 254 | fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600); |
| 255 | if (0 <= fd) |
| 256 | return fd; |
| 257 | |
| 258 | /* slow path */ |
| 259 | safe_create_leading_directories(name); |
| 260 | return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); |
| 261 | } |
| 262 | |
| Linus Torvalds | e1b1039 | 2005-10-12 01:47:34 | [diff] [blame] | 263 | char *get_index_file(void) |
| 264 | { |
| 265 | if (!git_index_file) |
| 266 | setup_git_env(); |
| 267 | return git_index_file; |
| 268 | } |
| 269 | |
| 270 | char *get_graft_file(void) |
| 271 | { |
| 272 | if (!git_graft_file) |
| 273 | setup_git_env(); |
| 274 | return git_graft_file; |
| 275 | } |
| Johannes Schindelin | d7ac12b | 2007-08-01 00:29:38 | [diff] [blame] | 276 | |
| 277 | int set_git_dir(const char *path) |
| 278 | { |
| 279 | if (setenv(GIT_DIR_ENVIRONMENT, path, 1)) |
| 280 | return error("Could not set GIT_DIR to '%s'", path); |
| 281 | setup_git_env(); |
| 282 | return 0; |
| 283 | } |
| Pat Notz | a6fa599 | 2010-11-02 19:59:07 | [diff] [blame] | 284 | |
| 285 | const char *get_log_output_encoding(void) |
| 286 | { |
| 287 | return git_log_output_encoding ? git_log_output_encoding |
| 288 | : get_commit_output_encoding(); |
| 289 | } |
| 290 | |
| 291 | const char *get_commit_output_encoding(void) |
| 292 | { |
| 293 | return git_commit_encoding ? git_commit_encoding : "UTF-8"; |
| 294 | } |