git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] git clone: check for non-empty directory

From
Ben Wijen <ben@wijen.net>
Date
Jul 1, 2020, 09:36 UTC
Message-ID
<20200701093653.3706-2-ben@wijen.net>
In-Reply-To
<20200701093653.3706-1-ben@wijen.net>

When using git clone with --separate-git-dir realgitdir and realgitdir already exists, it's content is destroyed.

Extend test to make sure content is left intact
Signed-off-by: Ben Wijen <ben@wijen.net>
---
 t/t5601-clone.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 84ea2a3eb7..03901c55f2 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -271,7 +271,8 @@ test_expect_success 'fetch from gitfile parent' '
 
 test_expect_success 'clone separate gitdir where target already exists' '
 	rm -rf dst &&
-	test_must_fail git clone --separate-git-dir realgitdir src dst
+	test_must_fail git clone --separate-git-dir realgitdir src dst &&
+	test -f realgitdir/config
 '
 
 test_expect_success 'clone --reference from original' '
-- 
2.27.0
Previous: Ben WijenNext: Eric Sunshine
Message 2 of 14 in “git clone with --separate-git-dir destroys existing directory content”
  1. 0/2 git clone with --separate-git-dir destroys existing directory contentBen Wijen, Jul 1, 2020
  2. 1/2 git clone: check for non-empty directoryBen Wijen, Jul 1, 2020
  3. Eric SunshineJul 1, 2020
  4. Eric SunshineJul 1, 2020
  5. Eric SunshineJul 2, 2020
  6. 2/2 git clone: don't clone into non-empty directoryBen Wijen, Jul 1, 2020
  7. Eric SunshineJul 1, 2020
  8. BenJul 2, 2020
  9. Eric SunshineJul 1, 2020
  10. 0/1 git clone: don't clone into non-empty directoryBen Wijen, Jul 2, 2020
  11. 1/1 git clone: don't clone into non-empty directoryBen Wijen, Jul 2, 2020
  12. Junio C HamanoJul 6, 2020
  13. 1/1 git clone: don't clone into non-empty directoryBen Wijen, Jul 10, 2020
  14. 0/1 git clone: don't clone into non-empty directoryBen Wijen, Jul 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.