git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Richard Weinberger <richard@nod.at>,
	Philip Oakley <philipoakley@iee.org>,
	Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org
Subject: [DONOTAPPLY PATCH 3/3] setup: treat GIT_DIR without GIT_WORK_TREE as a bare repo
Date: Tue, 26 Mar 2013 16:13:33 -0400	[thread overview]
Message-ID: <20130326201333.GC22522@sigill.intra.peff.net> (raw)
In-Reply-To: <20130326200851.GA22080@sigill.intra.peff.net>

Follow-through on the deprecation warning added by the last
commit.

We can drop all of the IMPLICIT_WORK_TREE code now, since
we default to that case.

Signed-off-by: Jeff King <peff@peff.net>
---
This would obviously come much later than patch 2, in Git 2.0 or
whatever.

But in case anyone did not read the discussion leading up to this
series, this breaks many tests. It's not meant for application, but
merely to look at what kinds of breakage we could see if we followed
this path.

 cache.h               | 12 ------------
 environment.c         |  1 -
 git.c                 |  1 -
 setup.c               | 26 +-------------------------
 t/t1510-repo-setup.sh | 24 ++++++++++--------------
 5 files changed, 11 insertions(+), 53 deletions(-)

diff --git a/cache.h b/cache.h
index c1fe67f..3c6b677 100644
--- a/cache.h
+++ b/cache.h
@@ -366,18 +366,6 @@ static inline enum object_type object_type(unsigned int mode)
 #define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE"
 
 /*
- * This environment variable is expected to contain a boolean indicating
- * whether we should or should not treat:
- *
- *   GIT_DIR=foo.git git ...
- *
- * as if GIT_WORK_TREE=. was given. It's not expected that users will make use
- * of this, but we use it internally to communicate to sub-processes that we
- * are in a bare repo. If not set, defaults to true.
- */
-#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
-
-/*
  * Repository-local GIT_* environment variables; these will be cleared
  * when git spawns a sub-process that runs inside another repository.
  * The array is NULL-terminated, which makes it easy to pass in the "env"
diff --git a/environment.c b/environment.c
index be2e509..255e277 100644
--- a/environment.c
+++ b/environment.c
@@ -85,7 +85,6 @@ const char * const local_repo_env[] = {
 	DB_ENVIRONMENT,
 	GIT_DIR_ENVIRONMENT,
 	GIT_WORK_TREE_ENVIRONMENT,
-	GIT_IMPLICIT_WORK_TREE_ENVIRONMENT,
 	GRAFT_ENVIRONMENT,
 	INDEX_ENVIRONMENT,
 	NO_REPLACE_OBJECTS_ENVIRONMENT,
diff --git a/git.c b/git.c
index 0ffea57..d33f9b3 100644
--- a/git.c
+++ b/git.c
@@ -125,7 +125,6 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			static char git_dir[PATH_MAX+1];
 			is_bare_repository_cfg = 1;
 			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 0);
-			setenv(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, "0", 1);
 			if (envchanged)
 				*envchanged = 1;
 		} else if (!strcmp(cmd, "-c")) {
diff --git a/setup.c b/setup.c
index afc245f..319dbb5 100644
--- a/setup.c
+++ b/setup.c
@@ -437,23 +437,6 @@ const char *read_gitfile(const char *path)
 	return path;
 }
 
-static const char warn_implicit_work_tree_msg[] =
-N_("You have set GIT_DIR (or used --git-dir) without specifying\n"
-   "a working tree. In Git 2.0, the behavior will change from using current\n"
-   "working directory as the working tree to having no working tree at all.\n"
-   "If you wish to continue the current behavior, please set GIT_WORK_TREE\n"
-   "or core.worktree explicitly. See `git help git` for more details.");
-
-static void warn_implicit_work_tree(void)
-{
-	static int warn_once;
-
-	if (warn_once++)
-		return;
-
-	warning("%s", _(warn_implicit_work_tree_msg));
-}
-
 static const char *setup_explicit_git_dir(const char *gitdirenv,
 					  char *cwd, int len,
 					  int *nongit_ok)
@@ -514,16 +497,11 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 			set_git_work_tree(core_worktree);
 		}
 	}
-	else if (!git_env_bool(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, 1)) {
-		/* #16d */
+	else { /* #2, #10, #16d */
 		set_git_dir(gitdirenv);
 		free(gitfile);
 		return NULL;
 	}
-	else { /* #2, #10 */
-		warn_implicit_work_tree();
-		set_git_work_tree(".");
-	}
 
 	/* set_git_work_tree() must have been called by now */
 	worktree = get_git_work_tree();
@@ -600,8 +578,6 @@ static const char *setup_bare_git_dir(char *cwd, int offset, int len, int *nongi
 	if (check_repository_format_gently(".", nongit_ok))
 		return NULL;
 
-	setenv(GIT_IMPLICIT_WORK_TREE_ENVIRONMENT, "0", 1);
-
 	/* --work-tree is set without --git-dir; use discovered one */
 	if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
 		const char *gitdir;
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 0910de1..7db4b3f 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -28,7 +28,7 @@ A few rules for repo setup:
 7. Effective core.worktree conflicts with core.bare
 
 8. If GIT_DIR is set but neither worktree nor bare setting is given,
-   original cwd becomes worktree.
+   we treat the repository as bare.
 
 9. If .git discovery is done inside a repo, the repo becomes a bare
    repo. .git discovery is performed if GIT_DIR is not set.
@@ -240,18 +240,16 @@ test_expect_success '#2b: relative GIT_DIR' '
 	! test -s message
 '
 
-test_expect_success '#2: worktree defaults to cwd with explicit GIT_DIR' '
+test_expect_success '#2: worktree defaults to bare with explicit GIT_DIR' '
 	try_repo 2 unset "$here/2/.git" unset "" unset \
-		"$here/2/.git" "$here/2" "$here/2" "(null)" \
-		"$here/2/.git" "$here/2/sub" "$here/2/sub" "(null)" \
-		2>message &&
-	test_i18ngrep "warning:.*GIT_DIR" message
+		"$here/2/.git" "(null)" "$here/2" "(null)" \
+		"$here/2/.git" "(null)" "$here/2/sub" "(null)"
 '
 
 test_expect_success '#2b: relative GIT_DIR' '
 	try_repo 2b unset ".git" unset "" unset \
-		".git" "$here/2b" "$here/2b" "(null)" \
-		"../.git" "$here/2b/sub" "$here/2b/sub" "(null)"
+		".git" "(null)" "$here/2b" "(null)" \
+		"../.git" "(null)" "$here/2b/sub" "(null)"
 '
 
 test_expect_success '#3: setup' '
@@ -379,16 +377,14 @@ test_expect_success '#10b: relative GIT_DIR can point to gitfile' '
 
 test_expect_success '#10: GIT_DIR can point to gitfile' '
 	try_repo 10 unset "$here/10/.git" unset gitfile unset \
-		"$here/10.git" "$here/10" "$here/10" "(null)" \
-		"$here/10.git" "$here/10/sub" "$here/10/sub" "(null)" \
-		2>message &&
-	test_i18ngrep "warning:.*GIT_DIR" message
+		"$here/10.git" "(null)" "$here/10" "(null)" \
+		"$here/10.git" "(null)" "$here/10/sub" "(null)"
 '
 
 test_expect_success '#10b: relative GIT_DIR can point to gitfile' '
 	try_repo 10b unset .git unset gitfile unset \
-		"$here/10b.git" "$here/10b" "$here/10b" "(null)" \
-		"$here/10b.git" "$here/10b/sub" "$here/10b/sub" "(null)"
+		"$here/10b.git" "(null)" "$here/10b" "(null)" \
+		"$here/10b.git" "(null)" "$here/10b/sub" "(null)"
 '
 
 # case #11: GIT_WORK_TREE works, gitfile case.
-- 
1.8.2.13.g0f18d3c

      parent reply	other threads:[~2013-03-26 20:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 21:38 git ate my home directory :-( Richard Weinberger
2013-03-25 21:43 ` Jonathan Nieder
2013-03-25 22:02   ` Junio C Hamano
2013-03-25 22:08     ` Jonathan Nieder
2013-03-25 22:15       ` Junio C Hamano
2013-03-25 22:06   ` Junio C Hamano
2013-03-25 22:09     ` Richard Weinberger
2013-03-25 22:15       ` Jonathan Nieder
2013-03-25 22:20       ` Junio C Hamano
2013-03-25 22:27         ` Richard Weinberger
2013-03-25 22:13     ` Jonathan Nieder
2013-03-25 22:21       ` Brandon Casey
2013-03-26  8:02     ` Philip Oakley
2013-03-26  9:48       ` Duy Nguyen
2013-03-26 15:04         ` Jeff King
2013-03-26 16:32           ` Junio C Hamano
2013-03-27 13:05           ` Duy Nguyen
2013-03-26 21:47         ` Philip Oakley
2013-03-26 13:07       ` Richard Weinberger
2013-03-26 14:56         ` Jeff King
2013-03-26 17:06           ` Richard Weinberger
2013-03-26 17:20             ` demerphq
2013-03-26 17:48               ` Jeff King
2013-03-26 19:08                 ` demerphq
2013-03-26 17:41             ` Jeff King
2013-03-26 18:20               ` Junio C Hamano
2013-03-26 20:08                 ` Jeff King
2013-03-26 20:11                   ` [DONOTAPPLY PATCH 1/3] environment: set GIT_WORK_TREE when we figure out work tree Jeff King
2013-03-26 20:16                     ` Jonathan Nieder
2013-03-26 20:12                   ` [DONOTAPPLY PATCH 2/3] setup: warn about implicit worktree with $GIT_DIR Jeff King
2013-03-26 20:21                     ` Jonathan Nieder
2013-03-26 20:27                       ` Jeff King
2013-03-26 20:35                         ` Jonathan Nieder
2013-03-27  8:24                         ` Matthieu Moy
2013-03-26 20:13                   ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130326201333.GC22522@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=philipoakley@iee.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).