|
22 | 22 | #include "fmt-merge-msg.h" |
23 | 23 | #include "commit.h" |
24 | 24 | #include "strvec.h" |
25 | | -#include "object-file.h" |
26 | 25 | #include "path.h" |
27 | | -#include "replace-object.h" |
28 | | -#include "tmp-objdir.h" |
29 | 26 | #include "chdir-notify.h" |
30 | 27 | #include "setup.h" |
31 | | -#include "shallow.h" |
32 | | -#include "trace.h" |
33 | 28 | #include "write-or-die.h" |
34 | 29 |
|
35 | 30 | int trust_executable_bit = 1; |
@@ -155,41 +150,6 @@ const char *getenv_safe(struct strvec *argv, const char *name) |
155 | 150 | return argv->v[argv->nr - 1]; |
156 | 151 | } |
157 | 152 |
|
158 | | -void setup_git_env(const char *git_dir) |
159 | | -{ |
160 | | - char *git_replace_ref_base; |
161 | | - const char *shallow_file; |
162 | | - const char *replace_ref_base; |
163 | | - struct set_gitdir_args args = { NULL }; |
164 | | - struct strvec to_free = STRVEC_INIT; |
165 | | - |
166 | | - args.commondir = getenv_safe(&to_free, GIT_COMMON_DIR_ENVIRONMENT); |
167 | | - args.object_dir = getenv_safe(&to_free, DB_ENVIRONMENT); |
168 | | - args.graft_file = getenv_safe(&to_free, GRAFT_ENVIRONMENT); |
169 | | - args.index_file = getenv_safe(&to_free, INDEX_ENVIRONMENT); |
170 | | - args.alternate_db = getenv_safe(&to_free, ALTERNATE_DB_ENVIRONMENT); |
171 | | - if (getenv(GIT_QUARANTINE_ENVIRONMENT)) { |
172 | | - args.disable_ref_updates = 1; |
173 | | - } |
174 | | - |
175 | | - repo_set_gitdir(the_repository, git_dir, &args); |
176 | | - strvec_clear(&to_free); |
177 | | - |
178 | | - if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT)) |
179 | | - disable_replace_refs(); |
180 | | - replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT); |
181 | | - git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base |
182 | | - : "refs/replace/"); |
183 | | - update_ref_namespace(NAMESPACE_REPLACE, git_replace_ref_base); |
184 | | - |
185 | | - shallow_file = getenv(GIT_SHALLOW_FILE_ENVIRONMENT); |
186 | | - if (shallow_file) |
187 | | - set_alternate_shallow_file(the_repository, shallow_file, 0); |
188 | | - |
189 | | - if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0)) |
190 | | - fetch_if_missing = 0; |
191 | | -} |
192 | | - |
193 | 153 | int is_bare_repository(void) |
194 | 154 | { |
195 | 155 | /* if core.bare is not 'false', let's see if there is a work tree */ |
@@ -243,71 +203,6 @@ const char *strip_namespace(const char *namespaced_ref) |
243 | 203 | return NULL; |
244 | 204 | } |
245 | 205 |
|
246 | | -static int git_work_tree_initialized; |
247 | | - |
248 | | -/* |
249 | | - * Note. This works only before you used a work tree. This was added |
250 | | - * primarily to support git-clone to work in a new repository it just |
251 | | - * created, and is not meant to flip between different work trees. |
252 | | - */ |
253 | | -void set_git_work_tree(const char *new_work_tree) |
254 | | -{ |
255 | | - if (git_work_tree_initialized) { |
256 | | - struct strbuf realpath = STRBUF_INIT; |
257 | | - |
258 | | - strbuf_realpath(&realpath, new_work_tree, 1); |
259 | | - new_work_tree = realpath.buf; |
260 | | - if (strcmp(new_work_tree, the_repository->worktree)) |
261 | | - die("internal error: work tree has already been set\n" |
262 | | - "Current worktree: %s\nNew worktree: %s", |
263 | | - the_repository->worktree, new_work_tree); |
264 | | - strbuf_release(&realpath); |
265 | | - return; |
266 | | - } |
267 | | - git_work_tree_initialized = 1; |
268 | | - repo_set_worktree(the_repository, new_work_tree); |
269 | | -} |
270 | | - |
271 | | -static void set_git_dir_1(const char *path) |
272 | | -{ |
273 | | - xsetenv(GIT_DIR_ENVIRONMENT, path, 1); |
274 | | - setup_git_env(path); |
275 | | -} |
276 | | - |
277 | | -static void update_relative_gitdir(const char *name UNUSED, |
278 | | - const char *old_cwd, |
279 | | - const char *new_cwd, |
280 | | - void *data UNUSED) |
281 | | -{ |
282 | | - char *path = reparent_relative_path(old_cwd, new_cwd, |
283 | | - repo_get_git_dir(the_repository)); |
284 | | - struct tmp_objdir *tmp_objdir = tmp_objdir_unapply_primary_odb(); |
285 | | - |
286 | | - trace_printf_key(&trace_setup_key, |
287 | | - "setup: move $GIT_DIR to '%s'", |
288 | | - path); |
289 | | - set_git_dir_1(path); |
290 | | - if (tmp_objdir) |
291 | | - tmp_objdir_reapply_primary_odb(tmp_objdir, old_cwd, new_cwd); |
292 | | - free(path); |
293 | | -} |
294 | | - |
295 | | -void set_git_dir(const char *path, int make_realpath) |
296 | | -{ |
297 | | - struct strbuf realpath = STRBUF_INIT; |
298 | | - |
299 | | - if (make_realpath) { |
300 | | - strbuf_realpath(&realpath, path, 1); |
301 | | - path = realpath.buf; |
302 | | - } |
303 | | - |
304 | | - set_git_dir_1(path); |
305 | | - if (!is_absolute_path(path)) |
306 | | - chdir_notify_register(NULL, update_relative_gitdir, NULL); |
307 | | - |
308 | | - strbuf_release(&realpath); |
309 | | -} |
310 | | - |
311 | 206 | const char *get_log_output_encoding(void) |
312 | 207 | { |
313 | 208 | return git_log_output_encoding ? git_log_output_encoding |
|
0 commit comments