Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeeraj Singh <neerajsi@microsoft.com>2022-04-05 08:20:16 +0300
committerJunio C Hamano <gitster@pobox.com>2022-04-06 23:13:26 +0300
commitd42bab442d7ca6bcc38aefe384e94d4320565b77 (patch)
treef3249ed4e2f3cfdd6d39583476de495c2e45102d /t/lib-unique-files.sh
parentfb2d0db502240231cde9584d2a908ae186a2ae06 (diff)
core.fsyncmethod: tests for batch mode
Add test cases to exercise batch mode for: * 'git add' * 'git stash' * 'git update-index' * 'git unpack-objects' These tests ensure that the added data winds up in the object database. In this change we introduce a new test helper lib-unique-files.sh. The goal of this library is to create a tree of files that have different oids from any other files that may have been created in the current test repo. This helps us avoid missing validation of an object being added due to it already being in the repo. Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/lib-unique-files.sh')
-rw-r--r--t/lib-unique-files.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/t/lib-unique-files.sh b/t/lib-unique-files.sh
new file mode 100644
index 0000000000..a14080fe79
--- /dev/null
+++ b/t/lib-unique-files.sh
@@ -0,0 +1,34 @@
+# Helper to create files with unique contents
+
+# Create multiple files with unique contents within this test run. Takes the
+# number of directories, the number of files in each directory, and the base
+# directory.
+#
+# test_create_unique_files 2 3 my_dir -- Creates 2 directories with 3 files
+# each in my_dir, all with contents
+# different from previous invocations
+# of this command in this run.
+
+test_create_unique_files () {
+ test "$#" -ne 3 && BUG "3 param"
+
+ local dirs="$1" &&
+ local files="$2" &&
+ local basedir="$3" &&
+ local counter="0" &&
+ local i &&
+ local j &&
+ test_tick &&
+ local basedata="$basedir$test_tick" &&
+ rm -rf "$basedir" &&
+ for i in $(test_seq $dirs)
+ do
+ local dir="$basedir/dir$i" &&
+ mkdir -p "$dir" &&
+ for j in $(test_seq $files)
+ do
+ counter=$((counter + 1)) &&
+ echo "$basedata.$counter">"$dir/file$j.txt"
+ done
+ done
+}