Skip to content

setup: stop ignoring GIT_WORK_TREE (when GIT_DIR is unset)

Jonathan Nieder git 1 version In review

Get series with b4
b4 am 20110119123732.GA23222@burratino

Versions newest first

  1. v1 Latest2 of 3 patches 17 repliesIn review

2 of 3 patches are in this archive. The cover letter announces 3.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3tests: cosmetic improvements to the repo-setup testt/t1510-repo-setup.sh+50 -440 replies
3/3setup: always honor GIT_WORK_TREE and core.worktreesetup.c t/t1510-repo-setup.sh+134 -9216 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchJonathan Nieder
1/3
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH/RFC 0/3] setup: stop ignoring GIT_WORK_TREE (when GIT_DIR is unset)
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Jonathan Nieder

+++ b/setup.c

(quoted diff) +0 -0
@@ -419,6 +419,11 @@ static const char *setup_discovered_git_dir(const char *gitdir,
 		return NULL;
 	}
 
Quoted 8 lines

Review static const char *setup_discovered_git_dir(const char *gitdir, · line 426

Quoted 5 lines
(quoted diff) +5 -0
+	if (getenv(GIT_WORK_TREE_ENVIRONMENT)) {
+		warning("GIT_WORK_TREE without explicit GIT_DIR is deprecated");
+		return setup_explicit_git_dir(gitdir, cwd, offset, nongit_ok);
+	}
+

My knee-jerk reaction is that calling this "deprecated" is probably confusing. git merely failed to notice misconfiguration

After staring at test results, I agree. The rule, before nd/setup, seems to be something like this:

- if GIT_DIR is set, you're safe
- if GIT_DIR is unset and .git is in the current directory, GIT_WORK_TREE will work by accident
- otherwise, git errors out.

The patch below should be more robust. It prints a warning:

warning: pretending GIT_DIR was supplied alongside GIT_WORK_TREE

As the night winds on I am less sure that that warning is a good idea. The .git discovery behavior seems relatively safe. What is more worrisome for the future of the use of GIT_WORK_TREE independent of cwd is the interaction with pathspecs.

Jonathan Nieder (3):
tests: cosmetic improvements to the repo-setup test
tests: make the setup tests briefer
setup: stop ignoring GIT_WORK_TREE and core.worktree

 setup.c               |   27 +-
 t/t1510-repo-setup.sh | 5166 +++++++------------------------------------------
 2 files changed, 729 insertions(+), 4464 deletions(-)