git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Hugo Sales <hugo@hsal.es>
To: git@vger.kernel.org
Cc: Hugo Sales <hugo@hsal.es>
Subject: [PATCH 2/3] mv: Add tests for new -p flag
Date: Tue, 10 Oct 2023 00:34:57 +0100	[thread overview]
Message-ID: <20231009233458.1371351-3-hugo@hsal.es> (raw)
In-Reply-To: <20231009233458.1371351-1-hugo@hsal.es>

Signed-off-by: Hugo Sales <hugo@hsal.es>
---
 t/t7009-mv-parents.sh | 79 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100755 t/t7009-mv-parents.sh

diff --git a/t/t7009-mv-parents.sh b/t/t7009-mv-parents.sh
new file mode 100755
index 0000000000..cc1d9dae08
--- /dev/null
+++ b/t/t7009-mv-parents.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+test_description='git mv -p'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success 'mv fails to move a file if the target directory does not exist' '
+	echo test >test1 &&
+	git add test1 &&
+	test_must_fail git mv test1 foo/
+'
+
+test_expect_success 'mv fails to move multiple files if the target directory does not exist' '
+	echo test >test2-1 &&
+	echo test >test2-2 &&
+	git add test2-1 test2-2 &&
+	test_must_fail git mv test2-1 test2-2 foo/
+'
+
+test_expect_success 'mv fails to move a file if the target refers to a file in a directory that does not exist' '
+	echo test >test3 &&
+	git add test3 &&
+	test_must_fail git mv test3 foo/test3.txt
+'
+
+test_expect_success 'mv succeeds to move a file even if the target directory does not exist' '
+	echo test >test4 &&
+	git add test4 &&
+	git commit -m test4-commit1 &&
+	git mv -p test4 dir4/ &&
+	git commit -m test4-commit2 &&
+	git diff-tree -r -M --name-status HEAD^ HEAD >test4-actual &&
+	grep "^R100..*test4..*dir4/test4" test4-actual
+'
+
+test_expect_success 'mv succeeds to move multiple files even if the target directory does not exist' '
+	echo test >test5-1 &&
+	echo test >test5-2 &&
+	git add test5-1 test5-2 &&
+	git commit -m test5-commit1 &&
+	git mv -p test5-1 test5-2 dir5/ &&
+	git commit -m test5-commit2 &&
+	git diff-tree -r -M --name-status HEAD^ HEAD >test5-actual &&
+	grep -e "^R100..*test5-1..*dir5/test5-1" -e "^R100..*test5-2..*dir5/test5-2" test5-actual
+'
+
+test_expect_success 'mv succeeds to move a file even if the target refers to a file in a directory that does not exist' '
+	echo test >test6 &&
+	git add test6 &&
+	git commit -m test6-commmit-1 &&
+	git mv -p test6 dir6/test6.txt &&
+	git commit -m test6-commit2 &&
+	git diff-tree -r -M --name-status HEAD^ HEAD >test6-actual &&
+	grep "^R100..*test6..*dir6/test6.txt" test6-actual
+'
+
+test_expect_success 'mv succeeds to move a file even if the target refers to a file in a directory inside a directory that does not exist' '
+	echo test >test7 &&
+	git add test7 &&
+	git commit -m test7-commit1 &&
+	git mv -p test7 dir7/dir7/test7.txt &&
+	git commit -m test7-commit2 &&
+	git diff-tree -r -M --name-status HEAD^ HEAD >test7-actual &&
+	grep "^R100..*test7..*dir7/dir7/test7.txt" test7-actual
+'
+
+test_expect_success 'mv succeeds to move a file even if the target refers to a file in a directory inside a directory inside a directory that does not exist' '
+	echo test >test8 &&
+	git add test8 &&
+	git commit -m test8-commit1 &&
+	git mv -p test8 dir8/dir8/dir8/test8.txt &&
+	git commit -m test8-commit2 &&
+	git diff-tree -r -M --name-status HEAD^ HEAD >test8-actual &&
+	grep "^R100..*test8..*dir8/dir8/dir8/test8.txt" test8-actual
+'
+
+test_done
-- 
2.42.0


  parent reply	other threads:[~2023-10-09 23:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 23:34 [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir' Hugo Sales
2023-10-09 23:34 ` [PATCH 1/3] mv: Add -p option to create parent directories Hugo Sales
2023-10-09 23:34 ` Hugo Sales [this message]
2023-10-09 23:34 ` [PATCH 3/3] mv: Add documentation for new `-p' flag Hugo Sales
2023-10-10  0:39 ` [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir' Junio C Hamano
2023-10-10  0:59   ` Junio C Hamano
2023-10-11 12:33   ` Hugo Sales
2023-10-31  4:30     ` Junio C Hamano
2023-10-31  4:54       ` Dragan Simic
2023-10-31  5:58         ` Junio C Hamano
2023-10-31  6:38           ` Dragan Simic

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20231009233458.1371351-3-hugo@hsal.es \
    --to=hugo@hsal.es \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).