Re: [PATCH] Reinstate the old behaviour when GIT_DIR is set and GIT_WORK_TREE is unset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subject: [PATCH] Revert 4465f410 and add tests

checkout-index --prefix=<path> does not need a working tree,
even when run from inside a bare repository.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---

 Junio C Hamano <gitster@xxxxxxxxx> writes:

 > Uwe Kleine-König  <ukleinek@xxxxxxxxxxxxxxxxxxxxxxxxxx> writes:
 >
 >> I don't know if you planed to make 
 >>
 >> 	git checkout-index --prefix=/tmp/tra -a
 >>
 >> work (again) in a bare repo.  Probably not, so it's no surprise that it
 >> still doesn't work.
 >
 > I think it is now safe to revert that NEED_WORK_TREE change
 > in git.c for checkout-index.

 How does this look?  I think the second test (no GIT_DIR, just
 being in a bare repository and specifying --prefix to redirect
 the output elsewhere) never worked even before the current
 work-tree feature was started (none of v1.4.4.4, v1.5.0, nor
 v1.5.2 worked that way), so this is not even "work again", but
 more like "now works".  Later tests with exported GIT_DIR would
 work with or without reverting the NEED_WORK_TREE change in
 git.c, so in that sense reverting is probably not such a good
 idea to begin with.  I dunno.

 git.c                            |    3 +-
 t/t2008-checkout-index-prefix.sh |   78 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 2 deletions(-)
 create mode 100755 t/t2008-checkout-index-prefix.sh

diff --git a/git.c b/git.c
index f8c4545..bafbb4b 100644
--- a/git.c
+++ b/git.c
@@ -315,8 +315,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "branch", cmd_branch, RUN_SETUP },
 		{ "bundle", cmd_bundle },
 		{ "cat-file", cmd_cat_file, RUN_SETUP },
-		{ "checkout-index", cmd_checkout_index,
-			RUN_SETUP | NEED_WORK_TREE},
+		{ "checkout-index", cmd_checkout_index, RUN_SETUP},
 		{ "check-ref-format", cmd_check_ref_format },
 		{ "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
 		{ "cherry", cmd_cherry, RUN_SETUP },
diff --git a/t/t2008-checkout-index-prefix.sh b/t/t2008-checkout-index-prefix.sh
new file mode 100755
index 0000000..7727f07
--- /dev/null
+++ b/t/t2008-checkout-index-prefix.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+test_description='checkout-index --prefix=foo/'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+	mkdir filfre &&
+	>frotz &&
+	>filfre/nitfol &&
+	git update-index --add frotz filfre/nitfol
+
+'
+
+rm -fr f*
+
+mv .git repo.git || exit ;# very bad
+GIT_DIR="$(pwd)/repo.git"
+GIT_CONFIG="$GIT_DIR/config" git config core.bare true
+
+test_expect_success 'checkout with --prefix' '
+
+	(
+		cd repo.git &&
+		git checkout-index --prefix=../f- -a
+	) &&
+	test -f f-frotz &&
+	test -d f-filfre &&
+	test -f f-filfre/nitfol
+
+'
+
+export GIT_DIR
+
+rm -fr f*
+
+test_expect_success 'checkout with --prefix and GIT_DIR (0)' '
+
+	(
+		cd repo.git &&
+		git checkout-index --prefix=../f/ -a
+	) &&
+	test -d f &&
+	test -f f/frotz &&
+	test -d f/filfre &&
+	test -f f/filfre/nitfol
+
+'
+
+rm -fr f*
+
+test_expect_success 'checkout with --prefix and GIT_DIR (1)' '
+
+	git checkout-index --prefix=f/ -a &&
+	test -d f &&
+	test -f f/frotz &&
+	test -d f/filfre &&
+	test -f f/filfre/nitfol
+
+'
+
+rm -fr f*
+
+test_expect_success 'checkout with --prefix and GIT_DIR (2)' '
+
+	mkdir f &&
+	(
+		cd f && git checkout-index --prefix=../f1/ -a
+	) &&
+	test -d f1 &&
+	test -f f1/frotz &&
+	test -d f1/filfre &&
+	test -f f1/filfre/nitfol
+
+'
+
+test_done

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux