aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/README5
-rw-r--r--t/helper/test-rot13-filter.c2
-rw-r--r--t/lib-bundle.sh2
-rw-r--r--t/lib-gitweb.sh4
-rw-r--r--t/lib-gpg.sh2
-rw-r--r--t/lib-rebase.sh2
-rw-r--r--t/lib-sudo.sh2
-rwxr-xr-xt/lib-unicode-nfc-nfd.sh2
-rwxr-xr-xt/perf/p7527-builtin-fsmonitor.sh2
-rw-r--r--t/perf/perf-lib.sh4
-rwxr-xr-xt/t0000-basic.sh4
-rwxr-xr-xt/t0021-conversion.sh4
-rwxr-xr-xt/t0028-working-tree-encoding.sh6
-rw-r--r--t/t0212/parse_events.perl2
-rwxr-xr-xt/t0600-reffiles-backend.sh2
-rwxr-xr-xt/t1016-compatObjectFormat.sh2
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh6
-rwxr-xr-xt/t1400-update-ref.sh4
-rwxr-xr-xt/t1401-symbolic-ref.sh2
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh2
-rwxr-xr-xt/t2082-parallel-checkout-attributes.sh4
-rwxr-xr-xt/t3404-rebase-interactive.sh101
-rwxr-xr-xt/t3434-rebase-i18n.sh6
-rwxr-xr-xt/t3900-i18n-commit.sh6
-rwxr-xr-xt/t3901-i18n-patch.sh6
-rwxr-xr-xt/t4041-diff-submodule-option.sh16
-rwxr-xr-xt/t4059-diff-submodule-not-initialized.sh16
-rwxr-xr-xt/t4060-diff-submodule-option-diff-format.sh17
-rwxr-xr-xt/t4201-shortlog.sh12
-rwxr-xr-xt/t4205-log-pretty-formats.sh104
-rwxr-xr-xt/t4210-log-i18n.sh6
-rwxr-xr-xt/t4254-am-corrupt.sh6
-rwxr-xr-xt/t5100-mailinfo.sh14
-rwxr-xr-xt/t5500-fetch-pack.sh14
-rwxr-xr-xt/t5550-http-fetch-dumb.sh4
-rwxr-xr-xt/t5572-pull-submodule.sh20
-rwxr-xr-xt/t5601-clone.sh11
-rwxr-xr-xt/t6006-rev-list-format.sh58
-rwxr-xr-xt/t6050-replace.sh133
-rwxr-xr-xt/t7001-mv.sh12
-rwxr-xr-xt/t7011-skip-worktree-reading.sh22
-rwxr-xr-xt/t7102-reset.sh40
-rwxr-xr-xt/t7300-clean.sh2
-rwxr-xr-xt/t8005-blame-i18n.sh6
-rwxr-xr-xt/t9300-fast-import.sh2
-rwxr-xr-xt/t9350-fast-export.sh10
-rw-r--r--t/test-lib.sh3
-rw-r--r--t/unit-tests/lib-reftable.c4
-rw-r--r--t/unit-tests/lib-reftable.h7
-rw-r--r--t/unit-tests/t-reftable-basics.c18
-rw-r--r--t/unit-tests/t-reftable-block.c53
-rw-r--r--t/unit-tests/t-reftable-merged.c34
-rw-r--r--t/unit-tests/t-reftable-reader.c12
-rw-r--r--t/unit-tests/t-reftable-readwrite.c134
-rw-r--r--t/unit-tests/t-reftable-record.c74
-rw-r--r--t/unit-tests/t-reftable-stack.c96
56 files changed, 690 insertions, 454 deletions
diff --git a/t/README b/t/README
index 8dcb778e26..8c0319b58e 100644
--- a/t/README
+++ b/t/README
@@ -465,8 +465,9 @@ GIT_TEST_DEFAULT_HASH=<hash-algo> specifies which hash algorithm to
use in the test scripts. Recognized values for <hash-algo> are "sha1"
and "sha256".
-GIT_TEST_DEFAULT_REF_FORMAT=<format> specifies which ref storage format
-to use in the test scripts. Recognized values for <format> are "files".
+GIT_TEST_DEFAULT_REF_FORMAT=<format> specifies which ref storage format to use
+in the test scripts. Recognized values for <format> are "files" and
+"reftable".
GIT_TEST_NO_WRITE_REV_INDEX=<boolean>, when true disables the
'pack.writeReverseIndex' setting.
diff --git a/t/helper/test-rot13-filter.c b/t/helper/test-rot13-filter.c
index 7e1d9e0ee4..ff407b575c 100644
--- a/t/helper/test-rot13-filter.c
+++ b/t/helper/test-rot13-filter.c
@@ -9,7 +9,7 @@
* ("clean", "smudge", etc).
*
* When --always-delay is given all pathnames with the "can-delay" flag
- * that don't appear on the list bellow are delayed with a count of 1
+ * that don't appear on the list below are delayed with a count of 1
* (see more below).
*
* This implementation supports special test cases:
diff --git a/t/lib-bundle.sh b/t/lib-bundle.sh
index cf7ed818b2..62b7bb13c8 100644
--- a/t/lib-bundle.sh
+++ b/t/lib-bundle.sh
@@ -11,7 +11,7 @@ convert_bundle_to_pack () {
}
# Check count of objects in a bundle file.
-# We can use "--thin" opiton to check thin pack, which must be fixed by
+# We can use "--thin" option to check thin pack, which must be fixed by
# command `git-index-pack --fix-thin --stdin`.
test_bundle_object_count () {
thin=
diff --git a/t/lib-gitweb.sh b/t/lib-gitweb.sh
index 1f32ca66ea..7f9808ec20 100644
--- a/t/lib-gitweb.sh
+++ b/t/lib-gitweb.sh
@@ -48,8 +48,8 @@ EOF
test -f "$SCRIPT_NAME" ||
error "Cannot find gitweb at $GITWEB_TEST_INSTALLED."
say "# Testing $SCRIPT_NAME"
- else # normal case, use source version of gitweb
- SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.perl"
+ else # normal case, use built version of gitweb
+ SCRIPT_NAME="$GIT_BUILD_DIR/gitweb/gitweb.cgi"
fi
export SCRIPT_NAME
}
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index add11e88fc..3845b6ac44 100644
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -6,7 +6,7 @@
# executed in an eval'ed subshell that changes the working directory to a
# temporary one.
-GNUPGHOME="$PWD/gpghome"
+GNUPGHOME="$(pwd)/gpghome"
export GNUPGHOME
test_lazy_prereq GPG '
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 11d2dc9fe3..0dd764310d 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -187,7 +187,7 @@ set_reword_editor () {
exit 1
fi
fi &&
- # There should be no uncommited changes
+ # There should be no uncommitted changes
git diff --exit-code HEAD &&
# The todo-list should be re-read after a reword
GIT_SEQUENCE_EDITOR="\"$PWD/reword-sequence-editor.sh\"" \
diff --git a/t/lib-sudo.sh b/t/lib-sudo.sh
index b4d7788f4e..477e0fdc04 100644
--- a/t/lib-sudo.sh
+++ b/t/lib-sudo.sh
@@ -6,7 +6,7 @@ run_with_sudo () {
local RUN="$TEST_DIRECTORY/$$.sh"
write_script "$RUN" "$TEST_SHELL_PATH"
# avoid calling "$RUN" directly so sudo doesn't get a chance to
- # override the shell, add aditional restrictions or even reject
+ # override the shell, add additional restrictions or even reject
# running the script because its security policy deem it unsafe
sudo "$TEST_SHELL_PATH" -c "\"$RUN\""
ret=$?
diff --git a/t/lib-unicode-nfc-nfd.sh b/t/lib-unicode-nfc-nfd.sh
index 22232247ef..aed0a4dd44 100755
--- a/t/lib-unicode-nfc-nfd.sh
+++ b/t/lib-unicode-nfc-nfd.sh
@@ -74,7 +74,7 @@ test_lazy_prereq UNICODE_NFD_PRESERVED '
# Yielding: \xcf \x89 + \xcc \x94 + \xcd \x82
#
# Note that I've used the canonical ordering of the
-# combinining characters. It is also possible to
+# combining characters. It is also possible to
# swap them. My testing shows that that non-standard
# ordering also causes a collision in mkdir. However,
# the resulting names don't draw correctly on the
diff --git a/t/perf/p7527-builtin-fsmonitor.sh b/t/perf/p7527-builtin-fsmonitor.sh
index c3f9a4caa4..90164327e8 100755
--- a/t/perf/p7527-builtin-fsmonitor.sh
+++ b/t/perf/p7527-builtin-fsmonitor.sh
@@ -95,7 +95,7 @@ test_expect_success "Setup borrowed repo (fsm+uc)" "
# time is not useful.
#
# Create a temp branch and do all work relative to it so that we don't
-# accidentially alter the real ballast branch.
+# accidentally alter the real ballast branch.
#
test_expect_success "Setup borrowed repo (temp ballast branch)" "
test_might_fail git -C $REPO checkout $BALLAST_BR &&
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index ab0c763411..8ab6d9c469 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -282,7 +282,7 @@ test_perf_ () {
# Run the performance test script specified in perf-test with
# optional prerequisite and setup steps.
# Options:
-# --prereq prerequisites: Skip the test if prequisites aren't met
+# --prereq prerequisites: Skip the test if prerequisites aren't met
# --setup "setup-steps": Run setup steps prior to each measured iteration
#
test_perf () {
@@ -309,7 +309,7 @@ test_size_ () {
# prerequisites and setup steps. Returns the numeric value
# returned by size-test.
# Options:
-# --prereq prerequisites: Skip the test if prequisites aren't met
+# --prereq prerequisites: Skip the test if prerequisites aren't met
# --setup "setup-steps": Run setup steps prior to the size measurement
test_size () {
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 98b81e4d63..35c5c2b4f9 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -684,7 +684,7 @@ test_expect_success 'subtest: tests respect lazy prerequisites' '
write_and_run_sub_test_lib_test lazy-prereqs <<-\EOF &&
test_lazy_prereq LAZY_TRUE true
- test_expect_success LAZY_TRUE "lazy prereq is satisifed" "true"
+ test_expect_success LAZY_TRUE "lazy prereq is satisfied" "true"
test_expect_success !LAZY_TRUE "negative lazy prereq" "false"
test_lazy_prereq LAZY_FALSE false
@@ -695,7 +695,7 @@ test_expect_success 'subtest: tests respect lazy prerequisites' '
EOF
check_sub_test_lib_test lazy-prereqs <<-\EOF
- ok 1 - lazy prereq is satisifed
+ ok 1 - lazy prereq is satisfied
ok 2 # skip negative lazy prereq (missing !LAZY_TRUE)
ok 3 # skip lazy prereq not satisfied (missing LAZY_FALSE)
ok 4 - negative false prereq
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index eeb2714d9d..9e6c6ee0d4 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -1116,11 +1116,11 @@ do
test_delayed_checkout_progress test_terminal git checkout $opt
'
- test_expect_success PERL "delayed checkout ommits progress on non-tty ($mode checkout)" '
+ test_expect_success PERL "delayed checkout omits progress on non-tty ($mode checkout)" '
test_delayed_checkout_progress ! git checkout $opt
'
- test_expect_success PERL,TTY "delayed checkout ommits progress with --quiet ($mode checkout)" '
+ test_expect_success PERL,TTY "delayed checkout omits progress with --quiet ($mode checkout)" '
test_delayed_checkout_progress ! test_terminal git checkout --quiet $opt
'
diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
index ad151a3467..510da4ca12 100755
--- a/t/t0028-working-tree-encoding.sh
+++ b/t/t0028-working-tree-encoding.sh
@@ -12,6 +12,12 @@ TEST_CREATE_REPO_NO_TEMPLATE=1
GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping working tree encoding tests; iconv not available'
+ test_done
+fi
+
test_expect_success 'setup test files' '
git config core.eol lf &&
diff --git a/t/t0212/parse_events.perl b/t/t0212/parse_events.perl
index 30a9f51e9f..7146476c69 100644
--- a/t/t0212/parse_events.perl
+++ b/t/t0212/parse_events.perl
@@ -204,7 +204,7 @@ while (<>) {
}
# A series of potentially nested and threaded region and data events
- # is fundamentally incompatibile with the type of summary record we
+ # is fundamentally incompatible with the type of summary record we
# are building in this script. Since they are intended for
# perf-trace-like analysis rather than a result summary, we ignore
# most of them here.
diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
index 20df336cc3..bef2b70871 100755
--- a/t/t0600-reffiles-backend.sh
+++ b/t/t0600-reffiles-backend.sh
@@ -271,7 +271,7 @@ test_expect_success 'setup worktree' '
# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should
# only appear in the for-each-reflog output if it is called from the correct
# worktree, which is exercised in this test. This test is poorly written for
-# mulitple reasons: 1) it creates invalidly formatted log entres. 2) it uses
+# multiple reasons: 1) it creates invalidly formatted log entries. 2) it uses
# direct FS access for creating the reflogs. 3) PSEUDO-WT and refs/bisect/random
# do not create reflogs by default, so it is not testing a realistic scenario.
test_expect_success 'for_each_reflog()' '
diff --git a/t/t1016-compatObjectFormat.sh b/t/t1016-compatObjectFormat.sh
index be3206a16f..92024fe51d 100755
--- a/t/t1016-compatObjectFormat.sh
+++ b/t/t1016-compatObjectFormat.sh
@@ -117,7 +117,7 @@ do
git config extensions.objectformat $hash &&
git config extensions.compatobjectformat $(compat_hash $hash) &&
git config gpg.program $TEST_DIRECTORY/t1016/gpg &&
- echo "Hellow World!" > hello &&
+ echo "Hello World!" > hello &&
eval hello_${hash}_oid=$(git hash-object hello) &&
git update-index --add hello &&
git commit -m "Initial commit" &&
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 3d44bd7643..2157f37da3 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -708,7 +708,7 @@ test_expect_success 'reset with wildcard pathspec' '
test_all_match git ls-files -s -- deep &&
# The following `git reset`s result in updating the index on files with
- # `skip-worktree` enabled. To avoid failing due to discrepencies in reported
+ # `skip-worktree` enabled. To avoid failing due to discrepancies in reported
# "modified" files, `test_sparse_match` reset is performed separately from
# "full-checkout" reset, then the index contents of all repos are verified.
@@ -824,7 +824,7 @@ test_expect_success 'update-index --remove outside sparse definition' '
# Reset the state
test_all_match git reset --hard &&
- # --force-remove supercedes --ignore-skip-worktree-entries, removing
+ # --force-remove supersedes --ignore-skip-worktree-entries, removing
# a skip-worktree file from the index (and disk) when both are specified
# with --remove
test_sparse_match git update-index --force-remove --ignore-skip-worktree-entries folder1/a &&
@@ -2081,7 +2081,7 @@ test_expect_success 'grep is not expanded' '
test_expect_failure 'grep within submodules is not expanded' '
init_repos_as_submodules &&
- # do not use ensure_not_expanded() here, becasue `grep` should be
+ # do not use ensure_not_expanded() here, because `grep` should be
# run in the superproject, not in "./sparse-index"
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
git grep --cached --recurse-submodules a -- "*/folder1/*" &&
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index eb1691860d..bb057596f1 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -1838,10 +1838,10 @@ do
test_expect_success "stdin $type create dangling symref ref works" '
test_when_finished "git symbolic-ref -d refs/heads/symref" &&
- format_command $type "symref-create refs/heads/symref" "refs/heads/unkown" >stdin &&
+ format_command $type "symref-create refs/heads/symref" "refs/heads/unknown" >stdin &&
git update-ref --stdin $type --no-deref <stdin &&
git symbolic-ref refs/heads/symref >expect &&
- echo refs/heads/unkown >actual &&
+ echo refs/heads/unknown >actual &&
test_cmp expect actual
'
diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
index 5c60d6f812..90af3f955c 100755
--- a/t/t1401-symbolic-ref.sh
+++ b/t/t1401-symbolic-ref.sh
@@ -16,7 +16,7 @@ reset_to_sane() {
test_expect_success 'setup' '
git symbolic-ref HEAD refs/heads/foo &&
test_commit file &&
- "$TAR" cf .git.tar .git/
+ "$TAR" cf .git.tar .git
'
test_expect_success 'symbolic-ref read/write roundtrip' '
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index ef40511d89..a3464976e3 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -195,7 +195,7 @@ test_expect_success 'dotdot is not an empty set' '
'
test_expect_success 'dotdot does not peel endpoints' '
- git tag -a -m "annote" annotated HEAD &&
+ git tag -a -m "annotate" annotated HEAD &&
A=$(git rev-parse annotated) &&
H=$(git rev-parse annotated^0) &&
{
diff --git a/t/t2082-parallel-checkout-attributes.sh b/t/t2082-parallel-checkout-attributes.sh
index aec55496eb..d02d6a5550 100755
--- a/t/t2082-parallel-checkout-attributes.sh
+++ b/t/t2082-parallel-checkout-attributes.sh
@@ -34,7 +34,7 @@ test_expect_success 'parallel-checkout with ident' '
)
'
-test_expect_success 'parallel-checkout with re-encoding' '
+test_expect_success ICONV 'parallel-checkout with re-encoding' '
set_checkout_config 2 0 &&
git init encoding &&
(
@@ -91,7 +91,7 @@ test_expect_success 'parallel-checkout with eol conversions' '
# Entries that require an external filter are not eligible for parallel
# checkout. Check that both the parallel-eligible and non-eligible entries are
-# properly writen in a single checkout operation.
+# properly written in a single checkout operation.
#
test_expect_success 'parallel-checkout and external filter' '
set_checkout_config 2 0 &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 4896a801ee..77cceda14a 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -281,8 +281,9 @@ test_expect_success 'stop on conflicting pick' '
test_cmp expect2 file1 &&
test "$(git diff --name-status |
sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
- test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
- test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
+ grep -v "^#" <.git/rebase-merge/done >actual &&
+ test_line_count = 4 actual &&
+ test 0 = $(grep -c "^[^#]" <.git/rebase-merge/git-rebase-todo)
'
test_expect_success 'show conflicted patch' '
@@ -319,7 +320,8 @@ test_expect_success 'retain authorship' '
GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
git tag twerp &&
git rebase -i --onto primary HEAD^ &&
- git show HEAD | grep "^Author: Twerp Snog"
+ git show HEAD >actual &&
+ grep "^Author: Twerp Snog" actual
'
test_expect_success 'retain authorship w/ conflicts' '
@@ -360,7 +362,8 @@ test_expect_success 'squash' '
'
test_expect_success 'retain authorship when squashing' '
- git show HEAD | grep "^Author: Twerp Snog"
+ git show HEAD >actual &&
+ grep "^Author: Twerp Snog" actual
'
test_expect_success '--continue tries to commit' '
@@ -374,7 +377,8 @@ test_expect_success '--continue tries to commit' '
FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
) &&
test_cmp_rev HEAD^ new-branch1 &&
- git show HEAD | grep chouette
+ git show HEAD >actual &&
+ grep chouette actual
'
test_expect_success 'verbose flag is heeded, even after --continue' '
@@ -397,7 +401,9 @@ test_expect_success 'multi-squash only fires up editor once' '
git rebase -i $base
) &&
test $base = $(git rev-parse HEAD^) &&
- test 1 = $(git show | grep ONCE | wc -l)
+ git show >output &&
+ grep ONCE output >actual &&
+ test_line_count = 1 actual
'
test_expect_success 'multi-fixup does not fire up editor' '
@@ -410,7 +416,8 @@ test_expect_success 'multi-fixup does not fire up editor' '
git rebase -i $base
) &&
test $base = $(git rev-parse HEAD^) &&
- test 0 = $(git show | grep NEVER | wc -l) &&
+ git show >output &&
+ ! grep NEVER output &&
git checkout @{-1} &&
git branch -D multi-fixup
'
@@ -428,7 +435,9 @@ test_expect_success 'commit message used after conflict' '
git rebase --continue
) &&
test $base = $(git rev-parse HEAD^) &&
- test 1 = $(git show | grep ONCE | wc -l) &&
+ git show >output &&
+ grep ONCE output >actual &&
+ test_line_count = 1 actual &&
git checkout @{-1} &&
git branch -D conflict-fixup
'
@@ -446,7 +455,9 @@ test_expect_success 'commit message retained after conflict' '
git rebase --continue
) &&
test $base = $(git rev-parse HEAD^) &&
- test 2 = $(git show | grep TWICE | wc -l) &&
+ git show >output &&
+ grep TWICE output >actual &&
+ test_line_count = 2 actual &&
git checkout @{-1} &&
git branch -D conflict-squash
'
@@ -470,10 +481,10 @@ test_expect_success 'squash and fixup generate correct log messages' '
) &&
git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
test_cmp expect-squash-fixup actual-squash-fixup &&
- git cat-file commit HEAD@{2} |
- grep "^# This is a combination of 3 commits\." &&
- git cat-file commit HEAD@{3} |
- grep "^# This is a combination of 2 commits\." &&
+ git cat-file commit HEAD@{2} >actual &&
+ grep "^# This is a combination of 3 commits\." actual &&
+ git cat-file commit HEAD@{3} >actual &&
+ grep "^# This is a combination of 2 commits\." actual &&
git checkout @{-1} &&
git branch -D squash-fixup
'
@@ -489,7 +500,9 @@ test_expect_success 'squash ignores comments' '
git rebase -i $base
) &&
test $base = $(git rev-parse HEAD^) &&
- test 1 = $(git show | grep ONCE | wc -l) &&
+ git show >output &&
+ grep ONCE output >actual &&
+ test_line_count = 1 actual &&
git checkout @{-1} &&
git branch -D skip-comments
'
@@ -505,7 +518,9 @@ test_expect_success 'squash ignores blank lines' '
git rebase -i $base
) &&
test $base = $(git rev-parse HEAD^) &&
- test 1 = $(git show | grep ONCE | wc -l) &&
+ git show >output &&
+ grep ONCE output >actual &&
+ test_line_count = 1 actual &&
git checkout @{-1} &&
git branch -D skip-blank-lines
'
@@ -572,7 +587,8 @@ test_expect_success '--continue tries to commit, even for "edit"' '
FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
) &&
test edited = $(git show HEAD:file7) &&
- git show HEAD | grep chouette &&
+ git show HEAD >actual &&
+ grep chouette actual &&
test $parent = $(git rev-parse HEAD^)
'
@@ -757,19 +773,23 @@ test_expect_success 'reword' '
set_fake_editor &&
FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \
git rebase -i A &&
- git show HEAD | grep "E changed" &&
+ git show HEAD >actual &&
+ grep "E changed" actual &&
test $(git rev-parse primary) != $(git rev-parse HEAD) &&
test_cmp_rev primary^ HEAD^ &&
FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
git rebase -i A &&
- git show HEAD^ | grep "D changed" &&
+ git show HEAD^ >actual &&
+ grep "D changed" actual &&
FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" \
git rebase -i A &&
- git show HEAD~3 | grep "B changed" &&
+ git show HEAD~3 >actual &&
+ grep "B changed" actual &&
FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" \
git rebase -i A
) &&
- git show HEAD~2 | grep "C changed"
+ git show HEAD~2 >actual &&
+ grep "C changed" actual
'
test_expect_success 'no uncommitted changes when rewording and the todo list is reloaded' '
@@ -1003,8 +1023,10 @@ test_expect_success 'rebase -i --root retain root commit author and message' '
set_fake_editor &&
FAKE_LINES="2" git rebase -i --root
) &&
- git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
- git cat-file commit HEAD | grep -q "^different author$"
+ git cat-file commit HEAD >output &&
+ grep -q "^author Twerp Snog" output &&
+ git cat-file commit HEAD >actual &&
+ grep -q "^different author$" actual
'
test_expect_success 'rebase -i --root temporary sentinel commit' '
@@ -1013,7 +1035,8 @@ test_expect_success 'rebase -i --root temporary sentinel commit' '
set_fake_editor &&
test_must_fail env FAKE_LINES="2" git rebase -i --root
) &&
- git cat-file commit HEAD | grep "^tree $EMPTY_TREE" &&
+ git cat-file commit HEAD >actual &&
+ grep "^tree $EMPTY_TREE" actual &&
git rebase --abort
'
@@ -1036,7 +1059,8 @@ test_expect_success 'rebase -i --root reword original root commit' '
FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
git rebase -i --root
) &&
- git show HEAD^ | grep "A changed" &&
+ git show HEAD^ >actual &&
+ grep "A changed" actual &&
test -z "$(git show -s --format=%p HEAD^)"
'
@@ -1048,7 +1072,8 @@ test_expect_success 'rebase -i --root reword new root commit' '
FAKE_LINES="reword 3 1" FAKE_COMMIT_MESSAGE="C changed" \
git rebase -i --root
) &&
- git show HEAD^ | grep "C changed" &&
+ git show HEAD^ >actual &&
+ grep "C changed" actual &&
test -z "$(git show -s --format=%p HEAD^)"
'
@@ -1917,18 +1942,17 @@ test_expect_success '--update-refs updates refs correctly' '
test_cmp_rev HEAD~1 refs/heads/third &&
test_cmp_rev HEAD refs/heads/no-conflict-branch &&
- cat >expect <<-\EOF &&
+ q_to_tab >expect <<-\EOF &&
Successfully rebased and updated refs/heads/update-refs.
Updated the following refs with --update-refs:
- refs/heads/first
- refs/heads/no-conflict-branch
- refs/heads/second
- refs/heads/third
+ Qrefs/heads/first
+ Qrefs/heads/no-conflict-branch
+ Qrefs/heads/second
+ Qrefs/heads/third
EOF
# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
- sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
- <err >err.trimmed &&
+ sed "s/Rebasing.*Successfully/Successfully/g" <err >err.trimmed &&
test_cmp expect err.trimmed
'
@@ -2178,19 +2202,18 @@ test_expect_success '--update-refs: check failed ref update' '
test_must_fail git rebase --continue 2>err &&
grep "update_ref failed for ref '\''refs/heads/second'\''" err &&
- cat >expect <<-\EOF &&
+ q_to_tab >expect <<-\EOF &&
Updated the following refs with --update-refs:
- refs/heads/first
- refs/heads/no-conflict-branch
- refs/heads/third
+ Qrefs/heads/first
+ Qrefs/heads/no-conflict-branch
+ Qrefs/heads/third
Failed to update the following refs with --update-refs:
- refs/heads/second
+ Qrefs/heads/second
EOF
# Clear "Rebasing (X/Y)" progress lines and drop leading tabs.
tail -n 6 err >err.last &&
- sed -e "s/Rebasing.*Successfully/Successfully/g" -e "s/^\t//g" \
- <err.last >err.trimmed &&
+ sed "s/Rebasing.*Successfully/Successfully/g" <err.last >err.trimmed &&
test_cmp expect err.trimmed
'
diff --git a/t/t3434-rebase-i18n.sh b/t/t3434-rebase-i18n.sh
index 26a48d6b10..97fc9a23f2 100755
--- a/t/t3434-rebase-i18n.sh
+++ b/t/t3434-rebase-i18n.sh
@@ -20,6 +20,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping rebase i18n tests; iconv not available'
+ test_done
+fi
+
compare_msg () {
iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
git cat-file commit HEAD >raw &&
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index db7b403bc1..9d4b5ab1f9 100755
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
@@ -8,6 +8,12 @@ test_description='commit and log output encodings'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping commit i18n tests; iconv not available'
+ test_done
+fi
+
compare_with () {
git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
case "$3" in
diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh
index 5f0b9afc3f..e0659c9293 100755
--- a/t/t3901-i18n-patch.sh
+++ b/t/t3901-i18n-patch.sh
@@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping patch i18n tests; iconv not available'
+ test_done
+fi
+
check_encoding () {
# Make sure characters are not corrupted
cnt="$1" header="$2" i=1 j=0
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 8fc40e75eb..aa149e0085 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -15,12 +15,18 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+ test_encoding="ISO8859-1"
+ # String "added" in German (translated with Google Translate), encoded in UTF-8,
+ # used in sample commit log messages in add_file() function below.
+ added=$(printf "hinzugef\303\274gt")
+else
+ test_encoding="UTF-8"
+ added="added"
+fi
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
add_file () {
(
cd "$1" &&
diff --git a/t/t4059-diff-submodule-not-initialized.sh b/t/t4059-diff-submodule-not-initialized.sh
index 668f526303..28fd3cdb15 100755
--- a/t/t4059-diff-submodule-not-initialized.sh
+++ b/t/t4059-diff-submodule-not-initialized.sh
@@ -12,12 +12,18 @@ initialized previously but the checkout has since been removed.
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+ test_encoding="ISO8859-1"
+ # String "added" in German (translated with Google Translate), encoded in UTF-8,
+ # used in sample commit log messages in add_file() function below.
+ added=$(printf "hinzugef\303\274gt")
+else
+ test_encoding="UTF-8"
+ added="added"
+fi
add_file () {
(
diff --git a/t/t4060-diff-submodule-option-diff-format.sh b/t/t4060-diff-submodule-option-diff-format.sh
index 8ce67442d9..918334fa4c 100755
--- a/t/t4060-diff-submodule-option-diff-format.sh
+++ b/t/t4060-diff-submodule-option-diff-format.sh
@@ -13,12 +13,17 @@ This test tries to verify the sanity of --submodule=diff option of git diff.
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
-
-# String "added" in German (translated with Google Translate), encoded in UTF-8,
-# used in sample commit log messages in add_file() function below.
-added=$(printf "hinzugef\303\274gt")
+# Test non-UTF-8 encoding in case iconv is available.
+if test_have_prereq ICONV
+then
+ test_encoding="ISO8859-1"
+ # String "added" in German (translated with Google Translate), encoded in UTF-8,
+ # used in sample commit log messages in add_file() function below.
+ added=$(printf "hinzugef\303\274gt")
+else
+ test_encoding="UTF-8"
+ added="added"
+fi
add_file () {
(
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index c20c885724..7f47f85c7f 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -105,7 +105,7 @@ test_expect_success 'output from user-defined format is re-wrapped' '
test_cmp expect log.predictable
'
-test_expect_success !MINGW 'shortlog wrapping' '
+test_expect_success !MINGW,ICONV 'shortlog wrapping' '
cat >expect <<\EOF &&
A U Thor (5):
Test
@@ -126,13 +126,13 @@ EOF
test_cmp expect out
'
-test_expect_success !MINGW 'shortlog from non-git directory' '
+test_expect_success !MINGW,ICONV 'shortlog from non-git directory' '
git log --no-expand-tabs HEAD >log &&
GIT_DIR=non-existing git shortlog -w <log >out &&
test_cmp expect out
'
-test_expect_success !MINGW 'shortlog can read --format=raw output' '
+test_expect_success !MINGW,ICONV 'shortlog can read --format=raw output' '
git log --format=raw HEAD >log &&
GIT_DIR=non-existing git shortlog -w <log >out &&
test_cmp expect out
@@ -143,6 +143,10 @@ test_expect_success 'shortlog from non-git directory refuses extra arguments' '
test_grep "too many arguments" out
'
+test_expect_success 'shortlog --author from non-git directory does not segfault' '
+ nongit git shortlog --author=author </dev/null
+'
+
test_expect_success 'shortlog should add newline when input line matches wraplen' '
cat >expect <<\EOF &&
A U Thor (2):
@@ -182,7 +186,7 @@ $DSCHO (2):
EOF
-test_expect_success !MINGW 'shortlog encoding' '
+test_expect_success !MINGW,ICONV 'shortlog encoding' '
git reset --hard "$commit" &&
git config --unset i18n.commitencoding &&
echo 2 > a1 &&
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index eb63ce011f..f9a9c2145e 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -114,19 +114,19 @@ test_expect_success 'alias loop' '
test_must_fail git log --pretty=test-foo
'
-test_expect_success 'NUL separation' '
+test_expect_success ICONV 'NUL separation' '
printf "add bar\0$(commit_msg)" >expected &&
git log -z --pretty="format:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL termination' '
+test_expect_success ICONV 'NUL termination' '
printf "add bar\0$(commit_msg)\0" >expected &&
git log -z --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
-test_expect_success 'NUL separation with --stat' '
+test_expect_success ICONV 'NUL separation with --stat' '
stat0_part=$(git diff --stat HEAD^ HEAD) &&
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -137,7 +137,7 @@ test_expect_success 'NUL separation with --stat' '
test_expect_failure 'NUL termination with --stat' '
stat0_part=$(git diff --stat HEAD^ HEAD) &&
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
- printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
+ printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n\0" >expected &&
git log -z --stat --pretty="tformat:%s" >actual &&
test_cmp expected actual
'
@@ -181,7 +181,7 @@ test_expect_success 'setup more commits' '
head4=$(git rev-parse --verify --short HEAD~3)
'
-test_expect_success 'left alignment formatting' '
+test_expect_success ICONV 'left alignment formatting' '
git log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
message two Z
@@ -192,7 +192,7 @@ test_expect_success 'left alignment formatting' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
message two Z
@@ -203,7 +203,7 @@ test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' '
+test_expect_success ICONV 'left alignment formatting at the nth column' '
git log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two Z
@@ -214,7 +214,7 @@ test_expect_success 'left alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column' '
+test_expect_success ICONV 'left alignment formatting at the nth column' '
COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two Z
@@ -225,7 +225,7 @@ test_expect_success 'left alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
$head1 message two Z
@@ -236,7 +236,7 @@ test_expect_success 'left alignment formatting at the nth column. i18n.logOutput
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with no padding' '
+test_expect_success ICONV 'left alignment formatting with no padding' '
git log --pretty="tformat:%<(1)%s" >actual &&
cat <<-EOF >expected &&
message two
@@ -258,7 +258,7 @@ test_expect_success 'left alignment formatting with no padding. i18n.logOutputEn
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with trunc' '
+test_expect_success ICONV 'left alignment formatting with trunc' '
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<-\EOF >expected &&
message ..
@@ -269,7 +269,7 @@ test_expect_success 'left alignment formatting with trunc' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting with trunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
message ..
@@ -280,7 +280,7 @@ test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncodin
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with ltrunc' '
+test_expect_success ICONV 'left alignment formatting with ltrunc' '
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
..sage two
@@ -291,7 +291,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
..sage two
@@ -302,7 +302,7 @@ test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncodi
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with mtrunc' '
+test_expect_success ICONV 'left alignment formatting with mtrunc' '
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<-\EOF >expected &&
mess.. two
@@ -313,7 +313,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
test_cmp expected actual
'
-test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
mess.. two
@@ -324,7 +324,7 @@ test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncodi
test_cmp expected actual
'
-test_expect_success 'right alignment formatting' '
+test_expect_success ICONV 'right alignment formatting' '
git log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
Z message two
@@ -335,7 +335,7 @@ test_expect_success 'right alignment formatting' '
test_cmp expected actual
'
-test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
+test_expect_success ICONV 'right alignment formatting. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
Z message two
@@ -346,7 +346,7 @@ test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' '
+test_expect_success ICONV 'right alignment formatting at the nth column' '
git log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two
@@ -357,7 +357,7 @@ test_expect_success 'right alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column' '
+test_expect_success ICONV 'right alignment formatting at the nth column' '
COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two
@@ -368,7 +368,7 @@ test_expect_success 'right alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
+test_expect_success ICONV 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
$head1 message two
@@ -381,7 +381,7 @@ test_expect_success 'right alignment formatting at the nth column. i18n.logOutpu
# Note: Space between 'message' and 'two' should be in the same column
# as in previous test.
-test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' '
+test_expect_success ICONV 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual &&
iconv -f utf-8 -t $test_encoding >expected <<-EOF &&
* $head1 message two
@@ -392,7 +392,7 @@ test_expect_success 'right alignment formatting at the nth column with --graph.
test_cmp expected actual
'
-test_expect_success 'right alignment formatting with no padding' '
+test_expect_success ICONV 'right alignment formatting with no padding' '
git log --pretty="tformat:%>(1)%s" >actual &&
cat <<-EOF >expected &&
message two
@@ -403,7 +403,7 @@ test_expect_success 'right alignment formatting with no padding' '
test_cmp expected actual
'
-test_expect_success 'right alignment formatting with no padding and with --graph' '
+test_expect_success ICONV 'right alignment formatting with no padding and with --graph' '
git log --graph --pretty="tformat:%>(1)%s" >actual &&
cat <<-EOF >expected &&
* message two
@@ -414,7 +414,7 @@ test_expect_success 'right alignment formatting with no padding and with --graph
test_cmp expected actual
'
-test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
+test_expect_success ICONV 'right alignment formatting with no padding. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
message two
@@ -425,7 +425,7 @@ test_expect_success 'right alignment formatting with no padding. i18n.logOutputE
test_cmp expected actual
'
-test_expect_success 'center alignment formatting' '
+test_expect_success ICONV 'center alignment formatting' '
git log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
Z message two Z
@@ -436,7 +436,7 @@ test_expect_success 'center alignment formatting' '
test_cmp expected actual
'
-test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
+test_expect_success ICONV 'center alignment formatting. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
Z message two Z
@@ -446,7 +446,7 @@ test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
EOF
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' '
+test_expect_success ICONV 'center alignment formatting at the nth column' '
git log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two Z
@@ -457,7 +457,7 @@ test_expect_success 'center alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column' '
+test_expect_success ICONV 'center alignment formatting at the nth column' '
COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
qz_to_tab_space <<-EOF >expected &&
$head1 message two Z
@@ -468,7 +468,7 @@ test_expect_success 'center alignment formatting at the nth column' '
test_cmp expected actual
'
-test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
+test_expect_success ICONV 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
$head1 message two Z
@@ -479,7 +479,7 @@ test_expect_success 'center alignment formatting at the nth column. i18n.logOutp
test_cmp expected actual
'
-test_expect_success 'center alignment formatting with no padding' '
+test_expect_success ICONV 'center alignment formatting with no padding' '
git log --pretty="tformat:%><(1)%s" >actual &&
cat <<-EOF >expected &&
message two
@@ -493,7 +493,7 @@ test_expect_success 'center alignment formatting with no padding' '
# save HEAD's SHA-1 digest (with no abbreviations) to use it below
# as far as the next test amends HEAD
old_head1=$(git rev-parse --verify HEAD~0)
-test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
+test_expect_success ICONV 'center alignment formatting with no padding. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
message two
@@ -504,7 +504,7 @@ test_expect_success 'center alignment formatting with no padding. i18n.logOutput
test_cmp expected actual
'
-test_expect_success 'left/right alignment formatting with stealing' '
+test_expect_success ICONV 'left/right alignment formatting with stealing' '
git commit --amend -m short --author "long long long <long@me.com>" &&
git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<-\EOF >expected &&
@@ -515,7 +515,7 @@ test_expect_success 'left/right alignment formatting with stealing' '
EOF
test_cmp expected actual
'
-test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
cat <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
short long long long
@@ -564,22 +564,38 @@ test_expect_success 'log decoration properly follows tag chain' '
git tag -d tag1 &&
git commit --amend -m shorter &&
git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
- cat <<-EOF >expected &&
- $head2 (tag: refs/tags/message-one)
- $old_head1 (tag: refs/tags/message-two)
- $head1 (tag: refs/tags/tag2)
- EOF
+ if test_have_prereq ICONV
+ then
+ cat <<-EOF >expected
+ $head2 (tag: refs/tags/message-one)
+ $old_head1 (tag: refs/tags/message-two)
+ $head1 (tag: refs/tags/tag2)
+ EOF
+ else
+ cat <<-EOF >expected
+ $head2 (tag: refs/tags/message-one)
+ $old_head1 (tag: refs/tags/tag2, tag: refs/tags/message-two)
+ EOF
+ fi &&
sort -k3 actual >actual1 &&
test_cmp expected actual1
'
test_expect_success 'clean log decoration' '
git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
- cat >expected <<-EOF &&
- $head2 tag: refs/tags/message-one
- $old_head1 tag: refs/tags/message-two
- $head1 tag: refs/tags/tag2
- EOF
+ if test_have_prereq ICONV
+ then
+ cat <<-EOF >expected
+ $head2 tag: refs/tags/message-one
+ $old_head1 tag: refs/tags/message-two
+ $head1 tag: refs/tags/tag2
+ EOF
+ else
+ cat <<-EOF >expected
+ $head2 tag: refs/tags/message-one
+ $old_head1 tag: refs/tags/tag2, tag: refs/tags/message-two
+ EOF
+ fi &&
sort -k3 actual >actual1 &&
test_cmp expected actual1
'
diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh
index 7120030b5c..4a12b2b497 100755
--- a/t/t4210-log-i18n.sh
+++ b/t/t4210-log-i18n.sh
@@ -5,6 +5,12 @@ test_description='test log with i18n features'
TEST_PASSES_SANITIZE_LEAK=true
. ./lib-gettext.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping log i18n tests; iconv not available'
+ test_done
+fi
+
# two forms of é
utf8_e=$(printf '\303\251')
latin1_e=$(printf '\351')
diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh
index 661feb6070..cb03522d02 100755
--- a/t/t4254-am-corrupt.sh
+++ b/t/t4254-am-corrupt.sh
@@ -5,6 +5,12 @@ test_description='git am with corrupt input'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping am encoding corruption tests; iconv not available'
+ test_done
+fi
+
make_mbox_with_nul () {
space=' '
q_nul_in_subject=
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 065156c1f3..23b2f21872 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -28,7 +28,12 @@ check_mailinfo () {
for mail in 00*
do
- test_expect_success "mailinfo $mail" '
+ case "$mail" in
+ 0004)
+ prereq=ICONV;;
+ esac
+
+ test_expect_success $prereq "mailinfo $mail" '
check_mailinfo "$mail" "" &&
if test -f "$DATA/msg$mail--scissors"
then
@@ -56,7 +61,12 @@ test_expect_success 'split box with rfc2047 samples' \
for mail in rfc2047/00*
do
- test_expect_success "mailinfo $mail" '
+ case "$mail" in
+ rfc2047/0001)
+ prereq=ICONV;;
+ esac
+
+ test_expect_success $prereq "mailinfo $mail" '
git mailinfo -u "$mail-msg" "$mail-patch" <"$mail" >"$mail-info" &&
echo msg &&
test_cmp "$DATA/empty" "$mail-msg" &&
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 605f17240c..416522c86a 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -774,7 +774,7 @@ do
# file with scheme
for p in file
do
- test_expect_success !MINGW "fetch-pack --diag-url $p://$h/$r" '
+ test_expect_success !WINDOWS "fetch-pack --diag-url $p://$h/$r" '
check_prot_path $p://$h/$r $p "/$r"
'
test_expect_success MINGW "fetch-pack --diag-url $p://$h/$r" '
@@ -784,7 +784,7 @@ do
check_prot_path $p:///$r $p "/$r"
'
# No "/~" -> "~" conversion for file
- test_expect_success !MINGW "fetch-pack --diag-url $p://$h/~$r" '
+ test_expect_success !WINDOWS "fetch-pack --diag-url $p://$h/~$r" '
check_prot_path $p://$h/~$r $p "/~$r"
'
test_expect_success MINGW "fetch-pack --diag-url $p://$h/~$r" '
@@ -806,11 +806,17 @@ do
p=ssh
for h in host [::1]
do
- test_expect_success "fetch-pack --diag-url $h:$r" '
+ expectation="success"
+ if test_have_prereq CYGWIN && test "$h" = "[::1]"
+ then
+ expectation="failure"
+ fi
+
+ test_expect_$expectation "fetch-pack --diag-url $h:$r" '
check_prot_host_port_path $h:$r $p "$h" NONE "$r"
'
# Do "/~" -> "~" conversion
- test_expect_success "fetch-pack --diag-url $h:/~$r" '
+ test_expect_$expectation "fetch-pack --diag-url $h:/~$r" '
check_prot_host_port_path $h:/~$r $p "$h" NONE "~$r"
'
done
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 58189c9f7d..3c873de17e 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -344,12 +344,12 @@ test_expect_success 'git client shows text/plain with a charset' '
grep "this is the error message" stderr
'
-test_expect_success 'http error messages are reencoded' '
+test_expect_success ICONV 'http error messages are reencoded' '
test_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr &&
grep "this is the error message" stderr
'
-test_expect_success 'reencoding is robust to whitespace oddities' '
+test_expect_success ICONV 'reencoding is robust to whitespace oddities' '
test_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr &&
grep "this is the error message" stderr
'
diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh
index 916e58c166..9b6cf8d88b 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -230,6 +230,7 @@ test_expect_success 'branch has no merge base with remote-tracking counterpart'
test_create_repo a-submodule &&
test_commit -C a-submodule foo &&
+ test_commit -C a-submodule bar &&
test_create_repo parent &&
git -C parent submodule add "$(pwd)/a-submodule" &&
@@ -246,4 +247,23 @@ test_expect_success 'branch has no merge base with remote-tracking counterpart'
git -C child pull --recurse-submodules --rebase
'
+test_expect_success 'fetch submodule remote of different name from superproject' '
+ git -C child remote rename origin o1 &&
+ git -C child submodule update --init &&
+
+ # Needs to create unreachable commit from current master branch.
+ git -C a-submodule checkout -b newmain HEAD^ &&
+ test_commit -C a-submodule echo &&
+ test_commit -C a-submodule moreecho &&
+ subc=$(git -C a-submodule rev-parse --short HEAD) &&
+
+ git -C parent/a-submodule fetch &&
+ git -C parent/a-submodule checkout "$subc" &&
+ git -C parent commit -m "update submodule" a-submodule &&
+ git -C a-submodule reset --hard HEAD^^ &&
+
+ git -C child pull --no-recurse-submodules &&
+ git -C child submodule update
+'
+
test_done
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 5d7ea147f1..9fe665eadf 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -530,10 +530,17 @@ do
'
done
+# Parsing of paths that look like IPv6 addresses is broken on Cygwin.
+expectation_for_ipv6_tests=success
+if test_have_prereq CYGWIN
+then
+ expectation_for_ipv6_tests=failure
+fi
+
#ipv6
for repo in rep rep/home/project 123
do
- test_expect_success "clone [::1]:$repo" '
+ test_expect_$expectation_for_ipv6_tests "clone [::1]:$repo" '
test_clone_url [::1]:$repo ::1 "$repo"
'
done
@@ -542,7 +549,7 @@ test_expect_success "clone host:/~repo" '
test_clone_url host:/~repo host "~repo"
'
-test_expect_success "clone [::1]:/~repo" '
+test_expect_$expectation_for_ipv6_tests "clone [::1]:/~repo" '
test_clone_url [::1]:/~repo ::1 "~repo"
'
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index f1623b1c06..b0ec2fe865 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -13,21 +13,41 @@ TEST_PASSES_SANITIZE_LEAK=true
. "$TEST_DIRECTORY"/lib-terminal.sh
test_tick
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
-
-# String "added" in German
-# (translated with Google Translate),
-# encoded in UTF-8, used as a commit log message below.
-added_utf8_part=$(printf "\303\274")
-added_utf8_part_iso88591=$(echo "$added_utf8_part" | iconv -f utf-8 -t $test_encoding)
-added=$(printf "added (hinzugef${added_utf8_part}gt) foo")
-added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
-# same but "changed"
-changed_utf8_part=$(printf "\303\244")
-changed_utf8_part_iso88591=$(echo "$changed_utf8_part" | iconv -f utf-8 -t $test_encoding)
-changed=$(printf "changed (ge${changed_utf8_part}ndert) foo")
-changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
+
+if test_have_prereq ICONV
+then
+ # Tested non-UTF-8 encoding
+ test_encoding="ISO8859-1"
+
+ # String "added" in German
+ # (translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ added_utf8_part=$(printf "\303\274")
+ added_utf8_part_iso88591=$(echo "$added_utf8_part" | iconv -f utf-8 -t $test_encoding)
+ added=$(printf "added (hinzugef${added_utf8_part}gt) foo")
+ added_iso88591=$(echo "$added" | iconv -f utf-8 -t $test_encoding)
+ # same but "changed"
+ changed_utf8_part=$(printf "\303\244")
+ changed_utf8_part_iso88591=$(echo "$changed_utf8_part" | iconv -f utf-8 -t $test_encoding)
+ changed=$(printf "changed (ge${changed_utf8_part}ndert) foo")
+ changed_iso88591=$(echo "$changed" | iconv -f utf-8 -t $test_encoding)
+else
+ # Tested non-UTF-8 encoding
+ test_encoding="UTF-8"
+
+ # String "added" in German
+ # (translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ added_utf8_part="u"
+ added_utf8_part_iso88591="u"
+ added=$(printf "added (hinzugef${added_utf8_part}gt) foo")
+ added_iso88591="$added"
+ # same but "changed"
+ changed_utf8_part="a"
+ changed_utf8_part_iso88591="a"
+ changed=$(printf "changed (ge${changed_utf8_part}ndert) foo")
+ changed_iso88591="$changed"
+fi
# Count of char to truncate
# Number is chosen so, that non-ACSII characters
@@ -55,7 +75,7 @@ test_expect_success 'setup' '
git config --unset i18n.commitEncoding
'
-# usage: test_format [argument...] name format_string [failure] <expected_output
+# usage: test_format [argument...] name format_string [success|failure] [prereq] <expected_output
test_format () {
local args=
while true
@@ -69,7 +89,7 @@ test_format () {
esac
done
cat >expect.$1
- test_expect_${3:-success} "format $1" "
+ test_expect_${3:-success} $4 "format $1" "
git rev-list $args --pretty=format:'$2' main >output.$1 &&
test_cmp expect.$1 output.$1
"
@@ -198,7 +218,7 @@ Thu, 7 Apr 2005 15:13:13 -0700
1112911993
EOF
-test_format encoding %e <<EOF
+test_format encoding %e success ICONV <<EOF
commit $head2
$test_encoding
commit $head1
@@ -374,7 +394,7 @@ test_expect_success 'setup complex body' '
head3_short=$(git rev-parse --short $head3)
'
-test_format complex-encoding %e <<EOF
+test_format complex-encoding %e success ICONV <<EOF
commit $head3
$test_encoding
commit $head2
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index d7702fc756..deba3ca430 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -98,30 +98,42 @@ test_expect_success 'set up buggy branch' '
'
test_expect_success 'replace the author' '
- git cat-file commit $HASH2 | grep "author A U Thor" &&
- R=$(git cat-file commit $HASH2 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
- git cat-file commit $R | grep "author O Thor" &&
+ git cat-file commit $HASH2 >actual &&
+ test_grep "author A U Thor" actual &&
+ R=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
+ git cat-file commit $R >actual &&
+ test_grep "author O Thor" actual &&
git update-ref refs/replace/$HASH2 $R &&
- git show HEAD~5 | grep "O Thor" &&
- git show $HASH2 | grep "O Thor"
+ git show HEAD~5 >actual &&
+ test_grep "O Thor" actual &&
+ git show $HASH2 >actual &&
+ test_grep "O Thor" actual
'
test_expect_success 'test --no-replace-objects option' '
- git cat-file commit $HASH2 | grep "author O Thor" &&
- git --no-replace-objects cat-file commit $HASH2 | grep "author A U Thor" &&
- git show $HASH2 | grep "O Thor" &&
- git --no-replace-objects show $HASH2 | grep "A U Thor"
+ git cat-file commit $HASH2 >actual &&
+ test_grep "author O Thor" actual &&
+ git --no-replace-objects cat-file commit $HASH2 >actual &&
+ test_grep "author A U Thor" actual &&
+ git show $HASH2 >actual &&
+ test_grep "O Thor" actual &&
+ git --no-replace-objects show $HASH2 >actual &&
+ test_grep "A U Thor" actual
'
test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '
- GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 | grep "author A U Thor" &&
- GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
+ GIT_NO_REPLACE_OBJECTS=1 git cat-file commit $HASH2 >actual &&
+ test_grep "author A U Thor" actual &&
+ GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 >actual &&
+ test_grep "A U Thor" actual
'
test_expect_success 'test core.usereplacerefs config option' '
test_config core.usereplacerefs false &&
- git cat-file commit $HASH2 | grep "author A U Thor" &&
- git show $HASH2 | grep "A U Thor"
+ git cat-file commit $HASH2 >actual &&
+ test_grep "author A U Thor" actual &&
+ git show $HASH2 >actual &&
+ test_grep "A U Thor" actual
'
cat >tag.sig <<EOF
@@ -148,14 +160,18 @@ test_expect_success 'repack, clone and fetch work' '
git clone --no-hardlinks . clone_dir &&
(
cd clone_dir &&
- git show HEAD~5 | grep "A U Thor" &&
- git show $HASH2 | grep "A U Thor" &&
+ git show HEAD~5 >actual &&
+ test_grep "A U Thor" actual &&
+ git show $HASH2 >actual &&
+ test_grep "A U Thor" actual &&
git cat-file commit $R &&
git repack -a -d &&
test_must_fail git cat-file commit $R &&
git fetch ../ "refs/replace/*:refs/replace/*" &&
- git show HEAD~5 | grep "O Thor" &&
- git show $HASH2 | grep "O Thor" &&
+ git show HEAD~5 >actual &&
+ test_grep "O Thor" actual &&
+ git show $HASH2 >actual &&
+ test_grep "O Thor" actual &&
git cat-file commit $R
)
'
@@ -169,13 +185,15 @@ test_expect_success '"git replace" listing and deleting' '
test_must_fail git replace --delete &&
test_must_fail git replace -l -d $HASH2 &&
git replace -d $HASH2 &&
- git show $HASH2 | grep "A U Thor" &&
+ git show $HASH2 >actual &&
+ test_grep "A U Thor" actual &&
test -z "$(git replace -l)"
'
test_expect_success '"git replace" replacing' '
git replace $HASH2 $R &&
- git show $HASH2 | grep "O Thor" &&
+ git show $HASH2 >actual &&
+ test_grep "O Thor" actual &&
test_must_fail git replace $HASH2 $R &&
git replace -f $HASH2 $R &&
test_must_fail git replace -f &&
@@ -186,7 +204,8 @@ test_expect_success '"git replace" resolves sha1' '
SHORTHASH2=$(git rev-parse --short=8 $HASH2) &&
git replace -d $SHORTHASH2 &&
git replace $SHORTHASH2 $R &&
- git show $HASH2 | grep "O Thor" &&
+ git show $HASH2 >actual &&
+ test_grep "O Thor" actual &&
test_must_fail git replace $HASH2 $R &&
git replace -f $HASH2 $R &&
test_must_fail git replace --force &&
@@ -209,10 +228,12 @@ test_expect_success '"git replace" resolves sha1' '
#
test_expect_success 'create parallel branch without the bug' '
git replace -d $HASH2 &&
- git show $HASH2 | grep "A U Thor" &&
+ git show $HASH2 >actual &&
+ test_grep "A U Thor" actual &&
git checkout $HASH1 &&
git cherry-pick $HASH2 &&
- git show $HASH5 | git apply &&
+ git show $HASH5 >actual &&
+ git apply actual &&
git commit --amend -m "hello: 4 more lines WITHOUT the bug" hello &&
PARA2=$(git rev-parse --verify HEAD) &&
git cherry-pick $HASH3 &&
@@ -225,7 +246,8 @@ test_expect_success 'create parallel branch without the bug' '
git checkout main &&
cur=$(git rev-parse --verify HEAD) &&
test "$cur" = "$HASH7" &&
- git log --pretty=oneline | grep $PARA2 &&
+ git log --pretty=oneline >actual &&
+ test_grep $PARA2 actual &&
git remote add cloned ./clone_dir
'
@@ -234,23 +256,30 @@ test_expect_success 'push to cloned repo' '
(
cd clone_dir &&
git checkout parallel &&
- git log --pretty=oneline | grep $PARA2
+ git log --pretty=oneline >actual &&
+ test_grep $PARA2 actual
)
'
test_expect_success 'push branch with replacement' '
- git cat-file commit $PARA3 | grep "author A U Thor" &&
- S=$(git cat-file commit $PARA3 | sed -e "s/A U/O/" | git hash-object -t commit --stdin -w) &&
- git cat-file commit $S | grep "author O Thor" &&
+ git cat-file commit $PARA3 >actual &&
+ test_grep "author A U Thor" actual &&
+ S=$(sed -e "s/A U/O/" actual | git hash-object -t commit --stdin -w) &&
+ git cat-file commit $S >actual &&
+ test_grep "author O Thor" actual &&
git replace $PARA3 $S &&
- git show $HASH6~2 | grep "O Thor" &&
- git show $PARA3 | grep "O Thor" &&
+ git show $HASH6~2 >actual &&
+ test_grep "O Thor" actual &&
+ git show $PARA3 >actual &&
+ test_grep "O Thor" actual &&
git push cloned $HASH6^:refs/heads/parallel2 &&
(
cd clone_dir &&
git checkout parallel2 &&
- git log --pretty=oneline | grep $PARA3 &&
- git show $PARA3 | grep "A U Thor"
+ git log --pretty=oneline >actual &&
+ test_grep $PARA3 actual &&
+ git show $PARA3 >actual &&
+ test_grep "A U Thor" actual
)
'
@@ -260,14 +289,14 @@ test_expect_success 'fetch branch with replacement' '
cd clone_dir &&
git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
git log --pretty=oneline parallel3 >output.txt &&
- ! grep $PARA3 output.txt &&
+ test_grep ! $PARA3 output.txt &&
git show $PARA3 >para3.txt &&
- grep "A U Thor" para3.txt &&
+ test_grep "A U Thor" para3.txt &&
git fetch origin "refs/replace/*:refs/replace/*" &&
git log --pretty=oneline parallel3 >output.txt &&
- grep $PARA3 output.txt &&
+ test_grep $PARA3 output.txt &&
git show $PARA3 >para3.txt &&
- grep "O Thor" para3.txt
+ test_grep "O Thor" para3.txt
)
'
@@ -284,8 +313,8 @@ test_expect_success 'bisect and replacements' '
'
test_expect_success 'index-pack and replacements' '
- git --no-replace-objects rev-list --objects HEAD |
- git --no-replace-objects pack-objects test- &&
+ git --no-replace-objects rev-list --objects HEAD >actual &&
+ git --no-replace-objects pack-objects test- <actual &&
git index-pack test-*.pack
'
@@ -319,7 +348,8 @@ test_expect_success '-f option bypasses the type check' '
'
test_expect_success 'git cat-file --batch works on replace objects' '
- git replace | grep $PARA3 &&
+ git replace >actual &&
+ test_grep $PARA3 actual &&
echo $PARA3 | git cat-file --batch
'
@@ -344,7 +374,8 @@ test_expect_success 'test --format medium' '
echo "$PARA3 -> $S" &&
echo "$MYTAG -> $HASH1"
} | sort >expected &&
- git replace -l --format medium | sort >actual &&
+ git replace -l --format medium >output &&
+ sort output >actual &&
test_cmp expected actual
'
@@ -356,7 +387,8 @@ test_expect_success 'test --format long' '
echo "$PARA3 (commit) -> $S (commit)" &&
echo "$MYTAG (tag) -> $HASH1 (commit)"
} | sort >expected &&
- git replace --format=long | sort >actual &&
+ git replace --format=long >output &&
+ sort output >actual &&
test_cmp expected actual
'
@@ -374,12 +406,16 @@ test_expect_success 'setup fake editors' '
test_expect_success '--edit with and without already replaced object' '
test_must_fail env GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
GIT_EDITOR=./fakeeditor git replace --force --edit "$PARA3" &&
- git replace -l | grep "$PARA3" &&
- git cat-file commit "$PARA3" | grep "A fake Thor" &&
+ git replace -l >actual &&
+ test_grep "$PARA3" actual &&
+ git cat-file commit "$PARA3" >actual &&
+ test_grep "A fake Thor" actual &&
git replace -d "$PARA3" &&
GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
- git replace -l | grep "$PARA3" &&
- git cat-file commit "$PARA3" | grep "A fake Thor"
+ git replace -l >actual &&
+ test_grep "$PARA3" actual &&
+ git cat-file commit "$PARA3" >actual &&
+ test_grep "A fake Thor" actual
'
test_expect_success '--edit and change nothing or command failed' '
@@ -387,8 +423,10 @@ test_expect_success '--edit and change nothing or command failed' '
test_must_fail env GIT_EDITOR=true git replace --edit "$PARA3" &&
test_must_fail env GIT_EDITOR="./failingfakeeditor" git replace --edit "$PARA3" &&
GIT_EDITOR=./fakeeditor git replace --edit "$PARA3" &&
- git replace -l | grep "$PARA3" &&
- git cat-file commit "$PARA3" | grep "A fake Thor"
+ git replace -l >actual &&
+ test_grep "$PARA3" actual &&
+ git cat-file commit "$PARA3" >actual &&
+ test_grep "A fake Thor" actual
'
test_expect_success 'replace ref cleanup' '
@@ -468,7 +506,8 @@ test_expect_success GPG 'set up a merge commit with a mergetag' '
git checkout main &&
git merge -s ours test_tag &&
HASH10=$(git rev-parse --verify HEAD) &&
- git cat-file commit $HASH10 | grep "^mergetag object"
+ git cat-file commit $HASH10 >actual &&
+ test_grep "^mergetag object" actual
'
test_expect_success GPG '--graft on a commit with a mergetag' '
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 86258f9f43..69c9190772 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -551,4 +551,16 @@ test_expect_success 'moving nested submodules' '
git status
'
+test_expect_failure 'nonsense mv triggers assertion failure and partially updated index' '
+ test_when_finished git reset --hard HEAD &&
+ git reset --hard HEAD &&
+ mkdir -p a &&
+ mkdir -p b &&
+ >a/a.txt &&
+ git add a/a.txt &&
+ test_must_fail git mv a/a.txt a b &&
+ git status --porcelain >actual &&
+ grep "^A[ ]*a/a.txt$" actual
+'
+
test_done
diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh
index 4adac5acd5..c86abd99bf 100755
--- a/t/t7011-skip-worktree-reading.sh
+++ b/t/t7011-skip-worktree-reading.sh
@@ -32,24 +32,24 @@ setup_absent() {
}
test_absent() {
- echo "100644 $EMPTY_BLOB 0 1" > expected &&
- git ls-files --stage 1 > result &&
+ echo "100644 $EMPTY_BLOB 0 1" >expected &&
+ git ls-files --stage 1 >result &&
test_cmp expected result &&
test ! -f 1
}
setup_dirty() {
git update-index --force-remove 1 &&
- echo dirty > 1 &&
+ echo dirty >1 &&
git update-index --add --cacheinfo 100644 $EMPTY_BLOB 1 &&
git update-index --skip-worktree 1
}
test_dirty() {
- echo "100644 $EMPTY_BLOB 0 1" > expected &&
- git ls-files --stage 1 > result &&
+ echo "100644 $EMPTY_BLOB 0 1" >expected &&
+ git ls-files --stage 1 >result &&
test_cmp expected result &&
- echo dirty > expected
+ echo dirty >expected
test_cmp expected 1
}
@@ -59,7 +59,7 @@ test_expect_success 'setup' '
touch ./1 ./2 sub/1 sub/2 &&
git add 1 2 sub/1 sub/2 &&
git update-index --skip-worktree 1 sub/1 &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expect.skip result
'
@@ -86,7 +86,7 @@ test_expect_success 'update-index --remove' '
setup_dirty &&
git update-index --remove 1 &&
test -z "$(git ls-files 1)" &&
- echo dirty > expected &&
+ echo dirty >expected &&
test_cmp expected 1
'
@@ -110,16 +110,16 @@ test_expect_success 'ls-files --modified' '
test -z "$(git ls-files -m)"
'
-echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A 1" > expected
+echo ":000000 100644 $ZERO_OID $EMPTY_BLOB A 1" >expected
test_expect_success 'diff-index does not examine skip-worktree absent entries' '
setup_absent &&
- git diff-index HEAD -- 1 > result &&
+ git diff-index HEAD -- 1 >result &&
test_cmp expected result
'
test_expect_success 'diff-index does not examine skip-worktree dirty entries' '
setup_dirty &&
- git diff-index HEAD -- 1 > result &&
+ git diff-index HEAD -- 1 >result &&
test_cmp expected result
'
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index 2add26d768..e9a6cc7265 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -13,21 +13,31 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
-commit_msg () {
- # String "modify 2nd file (changed)" partly in German
- # (translated with Google Translate),
- # encoded in UTF-8, used as a commit log message below.
- msg="modify 2nd file (ge\303\244ndert)\n"
- if test -n "$1"
- then
- printf "$msg" | iconv -f utf-8 -t "$1"
- else
- printf "$msg"
- fi
-}
-
-# Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
+if test_have_prereq ICONV
+then
+ commit_msg () {
+ # String "modify 2nd file (changed)" partly in German
+ # (translated with Google Translate),
+ # encoded in UTF-8, used as a commit log message below.
+ msg="modify 2nd file (ge\303\244ndert)\n"
+ if test -n "$1"
+ then
+ printf "$msg" | iconv -f utf-8 -t "$1"
+ else
+ printf "$msg"
+ fi
+ }
+
+ # Tested non-UTF-8 encoding
+ test_encoding="ISO8859-1"
+else
+ commit_msg () {
+ echo "modify 2nd file (geandert)"
+ }
+
+ # Tested non-UTF-8 encoding
+ test_encoding="UTF-8"
+fi
test_expect_success 'creating initial files and commits' '
test_tick &&
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 5c97eb0dfe..54fed91e39 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -747,7 +747,7 @@ test_expect_success MINGW 'handle clean & core.longpaths = false nicely' '
test_must_fail git clean -xdf 2>.git/err &&
# grepping for a strerror string is unportable but it is OK here with
# MINGW prereq
- test_grep "too long" .git/err
+ test_grep -e "too long" -e "No such file or directory" .git/err
'
test_expect_success 'clean untracked paths by pathspec' '
diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh
index 75da219ed1..7a1f581c24 100755
--- a/t/t8005-blame-i18n.sh
+++ b/t/t8005-blame-i18n.sh
@@ -3,6 +3,12 @@
test_description='git blame encoding conversion'
. ./test-lib.sh
+if ! test_have_prereq ICONV
+then
+ skip_all='skipping blame i18n tests; iconv not available'
+ test_done
+fi
+
. "$TEST_DIRECTORY"/t8005/utf8.txt
. "$TEST_DIRECTORY"/t8005/euc-japan.txt
. "$TEST_DIRECTORY"/t8005/sjis.txt
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 3b3c371740..6224f54d4d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -3676,7 +3676,7 @@ test_expect_success !MINGW 'W: get-mark & empty orphan commit with erroneous thi
### series X (other new features)
###
-test_expect_success 'X: handling encoding' '
+test_expect_success ICONV 'X: handling encoding' '
test_tick &&
cat >input <<-INPUT_END &&
commit refs/heads/encoding
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index 2bdc02b459..9595dfef2e 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -125,7 +125,7 @@ test_expect_success 'fast-export --show-original-ids | git fast-import' '
test $MUSS = $(git rev-parse --verify refs/tags/muss)
'
-test_expect_success 'reencoding iso-8859-7' '
+test_expect_success ICONV 'reencoding iso-8859-7' '
test_when_finished "git reset --hard HEAD~1" &&
test_config i18n.commitencoding iso-8859-7 &&
@@ -421,7 +421,7 @@ M 100644 :1 there
EOF
-test_expect_success 'dropping tag of filtered out object' '
+test_expect_success ICONV 'dropping tag of filtered out object' '
(
cd limit-by-paths &&
git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
@@ -438,7 +438,7 @@ msg
EOF
-test_expect_success 'rewriting tag of filtered out object' '
+test_expect_success ICONV 'rewriting tag of filtered out object' '
(
cd limit-by-paths &&
git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
@@ -667,7 +667,7 @@ M 100644 :13 file
EOF
-test_expect_success 'avoid uninteresting refs' '
+test_expect_success ICONV 'avoid uninteresting refs' '
> tmp-marks &&
git fast-export --import-marks=tmp-marks \
--export-marks=tmp-marks main > /dev/null &&
@@ -686,7 +686,7 @@ from :14
EOF
-test_expect_success 'refs are updated even if no commits need to be exported' '
+test_expect_success ICONV 'refs are updated even if no commits need to be exported' '
> tmp-marks &&
git fast-export --import-marks=tmp-marks \
--export-marks=tmp-marks main > /dev/null &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index b1a8ee5c00..a278181a05 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1572,7 +1572,7 @@ then
prepend_var LSAN_OPTIONS : dedup_token_length=9999
prepend_var LSAN_OPTIONS : log_exe_name=1
- prepend_var LSAN_OPTIONS : log_path=\"$TEST_RESULTS_SAN_FILE\"
+ prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'"
export LSAN_OPTIONS
elif test "$GIT_TEST_PASSING_SANITIZE_LEAK" = "check" ||
@@ -1743,6 +1743,7 @@ esac
( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
test -z "$NO_CURL" && test_set_prereq LIBCURL
+test -z "$NO_ICONV" && test_set_prereq ICONV
test -z "$NO_PERL" && test_set_prereq PERL
test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
test -z "$NO_PYTHON" && test_set_prereq PYTHON
diff --git a/t/unit-tests/lib-reftable.c b/t/unit-tests/lib-reftable.c
index 54c26c43e7..2ddf480588 100644
--- a/t/unit-tests/lib-reftable.c
+++ b/t/unit-tests/lib-reftable.c
@@ -19,7 +19,7 @@ static int strbuf_writer_flush(void *arg UNUSED)
return 0;
}
-struct reftable_writer *t_reftable_strbuf_writer(struct strbuf *buf,
+struct reftable_writer *t_reftable_strbuf_writer(struct reftable_buf *buf,
struct reftable_write_options *opts)
{
struct reftable_writer *writer;
@@ -29,7 +29,7 @@ struct reftable_writer *t_reftable_strbuf_writer(struct strbuf *buf,
return writer;
}
-void t_reftable_write_to_buf(struct strbuf *buf,
+void t_reftable_write_to_buf(struct reftable_buf *buf,
struct reftable_ref_record *refs,
size_t nrefs,
struct reftable_log_record *logs,
diff --git a/t/unit-tests/lib-reftable.h b/t/unit-tests/lib-reftable.h
index d115419084..d4950fed3d 100644
--- a/t/unit-tests/lib-reftable.h
+++ b/t/unit-tests/lib-reftable.h
@@ -2,15 +2,16 @@
#define LIB_REFTABLE_H
#include "git-compat-util.h"
-#include "strbuf.h"
#include "reftable/reftable-writer.h"
+struct reftable_buf;
+
void t_reftable_set_hash(uint8_t *p, int i, uint32_t id);
-struct reftable_writer *t_reftable_strbuf_writer(struct strbuf *buf,
+struct reftable_writer *t_reftable_strbuf_writer(struct reftable_buf *buf,
struct reftable_write_options *opts);
-void t_reftable_write_to_buf(struct strbuf *buf,
+void t_reftable_write_to_buf(struct reftable_buf *buf,
struct reftable_ref_record *refs,
size_t nrecords,
struct reftable_log_record *logs,
diff --git a/t/unit-tests/t-reftable-basics.c b/t/unit-tests/t-reftable-basics.c
index 1fa77b6faf..65d50df091 100644
--- a/t/unit-tests/t-reftable-basics.c
+++ b/t/unit-tests/t-reftable-basics.c
@@ -54,7 +54,7 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
}
}
- if_test ("names_length retuns size of a NULL-terminated string array") {
+ if_test ("names_length returns size of a NULL-terminated string array") {
const char *a[] = { "a", "b", NULL };
check_int(names_length(a), ==, 2);
}
@@ -99,8 +99,8 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
}
if_test ("common_prefix_size works") {
- struct strbuf a = STRBUF_INIT;
- struct strbuf b = STRBUF_INIT;
+ struct reftable_buf a = REFTABLE_BUF_INIT;
+ struct reftable_buf b = REFTABLE_BUF_INIT;
struct {
const char *a, *b;
int want;
@@ -113,14 +113,14 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
};
for (size_t i = 0; i < ARRAY_SIZE(cases); i++) {
- strbuf_addstr(&a, cases[i].a);
- strbuf_addstr(&b, cases[i].b);
+ check(!reftable_buf_addstr(&a, cases[i].a));
+ check(!reftable_buf_addstr(&b, cases[i].b));
check_int(common_prefix_size(&a, &b), ==, cases[i].want);
- strbuf_reset(&a);
- strbuf_reset(&b);
+ reftable_buf_reset(&a);
+ reftable_buf_reset(&b);
}
- strbuf_release(&a);
- strbuf_release(&b);
+ reftable_buf_release(&a);
+ reftable_buf_release(&b);
}
if_test ("put_be24 and get_be24 work") {
diff --git a/t/unit-tests/t-reftable-block.c b/t/unit-tests/t-reftable-block.c
index d470060e8b..f9af907117 100644
--- a/t/unit-tests/t-reftable-block.c
+++ b/t/unit-tests/t-reftable-block.c
@@ -20,7 +20,7 @@ static void t_ref_block_read_write(void)
const size_t block_size = 1024;
struct reftable_block block = { 0 };
struct block_writer bw = {
- .last_key = STRBUF_INIT,
+ .last_key = REFTABLE_BUF_INIT,
};
struct reftable_record rec = {
.type = BLOCK_TYPE_REF,
@@ -29,12 +29,12 @@ static void t_ref_block_read_write(void)
int ret;
struct block_reader br = { 0 };
struct block_iter it = BLOCK_ITER_INIT;
- struct strbuf want = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
REFTABLE_CALLOC_ARRAY(block.data, block_size);
check(block.data != NULL);
block.len = block_size;
- block_source_from_strbuf(&block.source ,&buf);
+ block_source_from_buf(&block.source ,&buf);
ret = block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
header_off, hash_size(GIT_SHA1_FORMAT_ID));
check(!ret);
@@ -100,8 +100,8 @@ static void t_ref_block_read_write(void)
block_iter_close(&it);
reftable_record_release(&rec);
reftable_block_done(&br.block);
- strbuf_release(&want);
- strbuf_release(&buf);
+ reftable_buf_release(&want);
+ reftable_buf_release(&buf);
for (i = 0; i < N; i++)
reftable_record_release(&recs[i]);
}
@@ -114,7 +114,7 @@ static void t_log_block_read_write(void)
const size_t block_size = 2048;
struct reftable_block block = { 0 };
struct block_writer bw = {
- .last_key = STRBUF_INIT,
+ .last_key = REFTABLE_BUF_INIT,
};
struct reftable_record rec = {
.type = BLOCK_TYPE_LOG,
@@ -123,12 +123,12 @@ static void t_log_block_read_write(void)
int ret;
struct block_reader br = { 0 };
struct block_iter it = BLOCK_ITER_INIT;
- struct strbuf want = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
REFTABLE_CALLOC_ARRAY(block.data, block_size);
check(block.data != NULL);
block.len = block_size;
- block_source_from_strbuf(&block.source ,&buf);
+ block_source_from_buf(&block.source ,&buf);
ret = block_writer_init(&bw, BLOCK_TYPE_LOG, block.data, block_size,
header_off, hash_size(GIT_SHA1_FORMAT_ID));
check(!ret);
@@ -166,8 +166,8 @@ static void t_log_block_read_write(void)
for (i = 0; i < N; i++) {
block_iter_reset(&it);
- strbuf_reset(&want);
- strbuf_addstr(&want, recs[i].u.log.refname);
+ reftable_buf_reset(&want);
+ check(!reftable_buf_addstr(&want, recs[i].u.log.refname));
ret = block_iter_seek_key(&it, &br, &want);
check_int(ret, ==, 0);
@@ -190,8 +190,8 @@ static void t_log_block_read_write(void)
block_iter_close(&it);
reftable_record_release(&rec);
reftable_block_done(&br.block);
- strbuf_release(&want);
- strbuf_release(&buf);
+ reftable_buf_release(&want);
+ reftable_buf_release(&buf);
for (i = 0; i < N; i++)
reftable_record_release(&recs[i]);
}
@@ -204,7 +204,7 @@ static void t_obj_block_read_write(void)
const size_t block_size = 1024;
struct reftable_block block = { 0 };
struct block_writer bw = {
- .last_key = STRBUF_INIT,
+ .last_key = REFTABLE_BUF_INIT,
};
struct reftable_record rec = {
.type = BLOCK_TYPE_OBJ,
@@ -213,12 +213,12 @@ static void t_obj_block_read_write(void)
int ret;
struct block_reader br = { 0 };
struct block_iter it = BLOCK_ITER_INIT;
- struct strbuf want = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
REFTABLE_CALLOC_ARRAY(block.data, block_size);
check(block.data != NULL);
block.len = block_size;
- block_source_from_strbuf(&block.source, &buf);
+ block_source_from_buf(&block.source, &buf);
ret = block_writer_init(&bw, BLOCK_TYPE_OBJ, block.data, block_size,
header_off, hash_size(GIT_SHA1_FORMAT_ID));
check(!ret);
@@ -273,8 +273,8 @@ static void t_obj_block_read_write(void)
block_iter_close(&it);
reftable_record_release(&rec);
reftable_block_done(&br.block);
- strbuf_release(&want);
- strbuf_release(&buf);
+ reftable_buf_release(&want);
+ reftable_buf_release(&buf);
for (i = 0; i < N; i++)
reftable_record_release(&recs[i]);
}
@@ -287,31 +287,34 @@ static void t_index_block_read_write(void)
const size_t block_size = 1024;
struct reftable_block block = { 0 };
struct block_writer bw = {
- .last_key = STRBUF_INIT,
+ .last_key = REFTABLE_BUF_INIT,
};
struct reftable_record rec = {
.type = BLOCK_TYPE_INDEX,
- .u.idx.last_key = STRBUF_INIT,
+ .u.idx.last_key = REFTABLE_BUF_INIT,
};
size_t i = 0;
int ret;
struct block_reader br = { 0 };
struct block_iter it = BLOCK_ITER_INIT;
- struct strbuf want = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
REFTABLE_CALLOC_ARRAY(block.data, block_size);
check(block.data != NULL);
block.len = block_size;
- block_source_from_strbuf(&block.source, &buf);
+ block_source_from_buf(&block.source, &buf);
ret = block_writer_init(&bw, BLOCK_TYPE_INDEX, block.data, block_size,
header_off, hash_size(GIT_SHA1_FORMAT_ID));
check(!ret);
for (i = 0; i < N; i++) {
- strbuf_init(&recs[i].u.idx.last_key, 9);
+ char buf[128];
+ snprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i);
+
+ reftable_buf_init(&recs[i].u.idx.last_key);
recs[i].type = BLOCK_TYPE_INDEX;
- strbuf_addf(&recs[i].u.idx.last_key, "branch%02"PRIuMAX, (uintmax_t)i);
+ check(!reftable_buf_addstr(&recs[i].u.idx.last_key, buf));
recs[i].u.idx.offset = i;
ret = block_writer_add(&bw, &recs[i]);
@@ -362,8 +365,8 @@ static void t_index_block_read_write(void)
block_iter_close(&it);
reftable_record_release(&rec);
reftable_block_done(&br.block);
- strbuf_release(&want);
- strbuf_release(&buf);
+ reftable_buf_release(&want);
+ reftable_buf_release(&buf);
for (i = 0; i < N; i++)
reftable_record_release(&recs[i]);
}
diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index 3c84363e98..4c25ee5334 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -20,7 +20,7 @@ static struct reftable_merged_table *
merged_table_from_records(struct reftable_ref_record **refs,
struct reftable_block_source **source,
struct reftable_reader ***readers, const size_t *sizes,
- struct strbuf *buf, const size_t n)
+ struct reftable_buf *buf, const size_t n)
{
struct reftable_merged_table *mt = NULL;
struct reftable_write_options opts = {
@@ -35,7 +35,7 @@ merged_table_from_records(struct reftable_ref_record **refs,
for (size_t i = 0; i < n; i++) {
t_reftable_write_to_buf(&buf[i], refs[i], sizes[i], NULL, 0, &opts);
- block_source_from_strbuf(&(*source)[i], &buf[i]);
+ block_source_from_buf(&(*source)[i], &buf[i]);
err = reftable_reader_new(&(*readers)[i], &(*source)[i],
"name");
@@ -75,7 +75,7 @@ static void t_merged_single_record(void)
struct reftable_ref_record *refs[] = { r1, r2, r3 };
size_t sizes[] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
- struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
+ struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt =
@@ -97,7 +97,7 @@ static void t_merged_single_record(void)
readers_destroy(readers, 3);
reftable_merged_table_free(mt);
for (size_t i = 0; i < ARRAY_SIZE(bufs); i++)
- strbuf_release(&bufs[i]);
+ reftable_buf_release(&bufs[i]);
reftable_free(bs);
}
@@ -152,7 +152,7 @@ static void t_merged_refs(void)
struct reftable_ref_record *refs[] = { r1, r2, r3 };
size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
- struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
+ struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt =
@@ -192,7 +192,7 @@ static void t_merged_refs(void)
reftable_free(out);
for (i = 0; i < 3; i++)
- strbuf_release(&bufs[i]);
+ reftable_buf_release(&bufs[i]);
readers_destroy(readers, 3);
reftable_merged_table_free(mt);
reftable_free(bs);
@@ -234,8 +234,8 @@ static void t_merged_seek_multiple_times(void)
size_t sizes[] = {
ARRAY_SIZE(r1), ARRAY_SIZE(r2),
};
- struct strbuf bufs[] = {
- STRBUF_INIT, STRBUF_INIT,
+ struct reftable_buf bufs[] = {
+ REFTABLE_BUF_INIT, REFTABLE_BUF_INIT,
};
struct reftable_block_source *sources = NULL;
struct reftable_reader **readers = NULL;
@@ -265,7 +265,7 @@ static void t_merged_seek_multiple_times(void)
}
for (size_t i = 0; i < ARRAY_SIZE(bufs); i++)
- strbuf_release(&bufs[i]);
+ reftable_buf_release(&bufs[i]);
readers_destroy(readers, ARRAY_SIZE(refs));
reftable_ref_record_release(&rec);
reftable_iterator_destroy(&it);
@@ -277,7 +277,7 @@ static struct reftable_merged_table *
merged_table_from_log_records(struct reftable_log_record **logs,
struct reftable_block_source **source,
struct reftable_reader ***readers, const size_t *sizes,
- struct strbuf *buf, const size_t n)
+ struct reftable_buf *buf, const size_t n)
{
struct reftable_merged_table *mt = NULL;
struct reftable_write_options opts = {
@@ -293,7 +293,7 @@ merged_table_from_log_records(struct reftable_log_record **logs,
for (size_t i = 0; i < n; i++) {
t_reftable_write_to_buf(&buf[i], NULL, 0, logs[i], sizes[i], &opts);
- block_source_from_strbuf(&(*source)[i], &buf[i]);
+ block_source_from_buf(&(*source)[i], &buf[i]);
err = reftable_reader_new(&(*readers)[i], &(*source)[i],
"name");
@@ -361,7 +361,7 @@ static void t_merged_logs(void)
struct reftable_log_record *logs[] = { r1, r2, r3 };
size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) };
- struct strbuf bufs[3] = { STRBUF_INIT, STRBUF_INIT, STRBUF_INIT };
+ struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT };
struct reftable_block_source *bs = NULL;
struct reftable_reader **readers = NULL;
struct reftable_merged_table *mt = merged_table_from_log_records(
@@ -412,7 +412,7 @@ static void t_merged_logs(void)
reftable_free(out);
for (i = 0; i < 3; i++)
- strbuf_release(&bufs[i]);
+ reftable_buf_release(&bufs[i]);
readers_destroy(readers, 3);
reftable_merged_table_free(mt);
reftable_free(bs);
@@ -421,7 +421,7 @@ static void t_merged_logs(void)
static void t_default_write_opts(void)
{
struct reftable_write_options opts = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_ref_record rec = {
.refname = (char *) "master",
@@ -442,7 +442,7 @@ static void t_default_write_opts(void)
check(!err);
reftable_writer_free(w);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&rd, &source, "filename");
check(!err);
@@ -457,7 +457,7 @@ static void t_default_write_opts(void)
reftable_reader_decref(rd);
reftable_merged_table_free(merged);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
@@ -467,7 +467,7 @@ int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
TEST(t_merged_logs(), "merged table with multiple log updates for same ref");
TEST(t_merged_refs(), "merged table with multiple updates to same ref");
TEST(t_merged_seek_multiple_times(), "merged table can seek multiple times");
- TEST(t_merged_single_record(), "ref ocurring in only one record can be fetched");
+ TEST(t_merged_single_record(), "ref occurring in only one record can be fetched");
return test_done();
}
diff --git a/t/unit-tests/t-reftable-reader.c b/t/unit-tests/t-reftable-reader.c
index eea86966c0..19cb53b641 100644
--- a/t/unit-tests/t-reftable-reader.c
+++ b/t/unit-tests/t-reftable-reader.c
@@ -16,11 +16,11 @@ static int t_reader_seek_once(void)
struct reftable_ref_record ref = { 0 };
struct reftable_iterator it = { 0 };
struct reftable_reader *reader;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int ret;
t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
ret = reftable_reader_new(&reader, &source, "name");
check(!ret);
@@ -40,7 +40,7 @@ static int t_reader_seek_once(void)
reftable_ref_record_release(&ref);
reftable_iterator_destroy(&it);
reftable_reader_decref(reader);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
return 0;
}
@@ -57,11 +57,11 @@ static int t_reader_reseek(void)
struct reftable_ref_record ref = { 0 };
struct reftable_iterator it = { 0 };
struct reftable_reader *reader;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int ret;
t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
ret = reftable_reader_new(&reader, &source, "name");
check(!ret);
@@ -84,7 +84,7 @@ static int t_reader_reseek(void)
reftable_ref_record_release(&ref);
reftable_iterator_destroy(&it);
reftable_reader_decref(reader);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
return 0;
}
diff --git a/t/unit-tests/t-reftable-readwrite.c b/t/unit-tests/t-reftable-readwrite.c
index 27ce84445e..d279b86df0 100644
--- a/t/unit-tests/t-reftable-readwrite.c
+++ b/t/unit-tests/t-reftable-readwrite.c
@@ -18,13 +18,13 @@ static const int update_index = 5;
static void t_buffer(void)
{
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_block_source source = { 0 };
struct reftable_block out = { 0 };
int n;
uint8_t in[] = "hello";
- strbuf_add(&buf, in, sizeof(in));
- block_source_from_strbuf(&source, &buf);
+ check(!reftable_buf_add(&buf, in, sizeof(in)));
+ block_source_from_buf(&source, &buf);
check_int(block_source_size(&source), ==, 6);
n = block_source_read_block(&source, &out, 0, sizeof(in));
check_int(n, ==, sizeof(in));
@@ -37,10 +37,10 @@ static void t_buffer(void)
reftable_block_done(&out);
block_source_close(&source);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
-static void write_table(char ***names, struct strbuf *buf, int N,
+static void write_table(char ***names, struct reftable_buf *buf, int N,
int block_size, uint32_t hash_id)
{
struct reftable_write_options opts = {
@@ -82,7 +82,7 @@ static void write_table(char ***names, struct strbuf *buf, int N,
static void t_log_buffer_size(void)
{
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_write_options opts = {
.block_size = 4096,
};
@@ -114,12 +114,12 @@ static void t_log_buffer_size(void)
err = reftable_writer_close(w);
check(!err);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_log_overflow(void)
{
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
char msg[256] = { 0 };
struct reftable_write_options opts = {
.block_size = ARRAY_SIZE(msg),
@@ -148,7 +148,7 @@ static void t_log_overflow(void)
err = reftable_writer_add_log(w, &log);
check_int(err, ==, REFTABLE_ENTRY_TOO_BIG_ERROR);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_log_write_read(void)
@@ -161,7 +161,7 @@ static void t_log_write_read(void)
struct reftable_iterator it = { 0 };
struct reftable_reader *reader;
struct reftable_block_source source = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
const struct reftable_stats *stats = NULL;
int N = 2, err, i, n;
@@ -207,7 +207,7 @@ static void t_log_write_read(void)
reftable_writer_free(w);
w = NULL;
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.log");
check(!err);
@@ -247,7 +247,7 @@ static void t_log_write_read(void)
reftable_iterator_destroy(&it);
/* cleanup. */
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(names);
reftable_reader_decref(reader);
}
@@ -260,7 +260,7 @@ static void t_log_zlib_corruption(void)
struct reftable_iterator it = { 0 };
struct reftable_reader *reader;
struct reftable_block_source source = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
const struct reftable_stats *stats = NULL;
char message[100] = { 0 };
@@ -298,7 +298,7 @@ static void t_log_zlib_corruption(void)
/* corrupt the data. */
buf.buf[50] ^= 0x99;
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.log");
check(!err);
@@ -312,13 +312,13 @@ static void t_log_zlib_corruption(void)
/* cleanup. */
reftable_reader_decref(reader);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_table_read_write_sequential(void)
{
char **names;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int N = 50;
struct reftable_iterator it = { 0 };
struct reftable_block_source source = { 0 };
@@ -328,7 +328,7 @@ static void t_table_read_write_sequential(void)
write_table(&names, &buf, N, 256, GIT_SHA1_FORMAT_ID);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.ref");
check(!err);
@@ -352,25 +352,25 @@ static void t_table_read_write_sequential(void)
reftable_iterator_destroy(&it);
reftable_reader_decref(reader);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(names);
}
static void t_table_write_small_table(void)
{
char **names;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int N = 1;
write_table(&names, &buf, N, 4096, GIT_SHA1_FORMAT_ID);
check_int(buf.len, <, 200);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(names);
}
static void t_table_read_api(void)
{
char **names;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int N = 50;
struct reftable_reader *reader;
struct reftable_block_source source = { 0 };
@@ -380,7 +380,7 @@ static void t_table_read_api(void)
write_table(&names, &buf, N, 256, GIT_SHA1_FORMAT_ID);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.ref");
check(!err);
@@ -393,17 +393,17 @@ static void t_table_read_api(void)
err = reftable_iterator_next_log(&it, &log);
check_int(err, ==, REFTABLE_API_ERROR);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(names);
reftable_iterator_destroy(&it);
reftable_reader_decref(reader);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_table_read_write_seek(int index, int hash_id)
{
char **names;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
int N = 50;
struct reftable_reader *reader;
struct reftable_block_source source = { 0 };
@@ -411,12 +411,12 @@ static void t_table_read_write_seek(int index, int hash_id)
int i = 0;
struct reftable_iterator it = { 0 };
- struct strbuf pastLast = STRBUF_INIT;
+ struct reftable_buf pastLast = REFTABLE_BUF_INIT;
struct reftable_ref_record ref = { 0 };
write_table(&names, &buf, N, 256, hash_id);
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.ref");
check(!err);
@@ -443,8 +443,8 @@ static void t_table_read_write_seek(int index, int hash_id)
reftable_iterator_destroy(&it);
}
- strbuf_addstr(&pastLast, names[N - 1]);
- strbuf_addstr(&pastLast, "/");
+ check(!reftable_buf_addstr(&pastLast, names[N - 1]));
+ check(!reftable_buf_addstr(&pastLast, "/"));
err = reftable_reader_init_ref_iterator(reader, &it);
check(!err);
@@ -457,10 +457,10 @@ static void t_table_read_write_seek(int index, int hash_id)
check_int(err, >, 0);
}
- strbuf_release(&pastLast);
+ reftable_buf_release(&pastLast);
reftable_iterator_destroy(&it);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(names);
reftable_reader_decref(reader);
}
@@ -492,7 +492,7 @@ static void t_table_refs_for(int indexed)
struct reftable_ref_record ref = { 0 };
struct reftable_reader *reader;
struct reftable_block_source source = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_iterator it = { 0 };
int N = 50, n, j, err, i;
@@ -538,7 +538,7 @@ static void t_table_refs_for(int indexed)
reftable_writer_free(w);
w = NULL;
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.ref");
check(!err);
@@ -565,7 +565,7 @@ static void t_table_refs_for(int indexed)
}
check_int(j, ==, want_names_len);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
free_names(want_names);
reftable_iterator_destroy(&it);
reftable_reader_decref(reader);
@@ -584,7 +584,7 @@ static void t_table_refs_for_obj_index(void)
static void t_write_empty_table(void)
{
struct reftable_write_options opts = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_block_source source = { 0 };
struct reftable_reader *rd = NULL;
@@ -600,7 +600,7 @@ static void t_write_empty_table(void)
check_int(buf.len, ==, header_size(1) + footer_size(1));
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&rd, &source, "filename");
check(!err);
@@ -615,7 +615,7 @@ static void t_write_empty_table(void)
reftable_iterator_destroy(&it);
reftable_reader_decref(rd);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_write_object_id_min_length(void)
@@ -623,7 +623,7 @@ static void t_write_object_id_min_length(void)
struct reftable_write_options opts = {
.block_size = 75,
};
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_ref_record ref = {
.update_index = 1,
@@ -649,7 +649,7 @@ static void t_write_object_id_min_length(void)
check(!err);
check_int(reftable_writer_stats(w)->object_id_len, ==, 2);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_write_object_id_length(void)
@@ -657,7 +657,7 @@ static void t_write_object_id_length(void)
struct reftable_write_options opts = {
.block_size = 75,
};
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_ref_record ref = {
.update_index = 1,
@@ -684,13 +684,13 @@ static void t_write_object_id_length(void)
check(!err);
check_int(reftable_writer_stats(w)->object_id_len, ==, 16);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_write_empty_key(void)
{
struct reftable_write_options opts = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_ref_record ref = {
.refname = (char *) "",
@@ -706,13 +706,13 @@ static void t_write_empty_key(void)
err = reftable_writer_close(w);
check_int(err, ==, REFTABLE_EMPTY_TABLE_ERROR);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_write_key_order(void)
{
struct reftable_write_options opts = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts);
struct reftable_ref_record refs[2] = {
{
@@ -745,7 +745,7 @@ static void t_write_key_order(void)
reftable_writer_close(w);
reftable_writer_free(w);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
static void t_write_multiple_indices(void)
@@ -753,12 +753,13 @@ static void t_write_multiple_indices(void)
struct reftable_write_options opts = {
.block_size = 100,
};
- struct strbuf writer_buf = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf writer_buf = REFTABLE_BUF_INIT;
struct reftable_block_source source = { 0 };
struct reftable_iterator it = { 0 };
const struct reftable_stats *stats;
struct reftable_writer *writer;
struct reftable_reader *reader;
+ char buf[128];
int err, i;
writer = t_reftable_strbuf_writer(&writer_buf, &opts);
@@ -770,9 +771,8 @@ static void t_write_multiple_indices(void)
.value.val1 = {i},
};
- strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/heads/%04d", i);
- ref.refname = buf.buf,
+ snprintf(buf, sizeof(buf), "refs/heads/%04d", i);
+ ref.refname = buf;
err = reftable_writer_add_ref(writer, &ref);
check(!err);
@@ -788,9 +788,8 @@ static void t_write_multiple_indices(void)
},
};
- strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/heads/%04d", i);
- log.refname = buf.buf,
+ snprintf(buf, sizeof(buf), "refs/heads/%04d", i);
+ log.refname = buf;
err = reftable_writer_add_log(writer, &log);
check(!err);
@@ -807,7 +806,7 @@ static void t_write_multiple_indices(void)
check_int(stats->obj_stats.index_offset, >, 0);
check_int(stats->log_stats.index_offset, >, 0);
- block_source_from_strbuf(&source, &writer_buf);
+ block_source_from_buf(&source, &writer_buf);
err = reftable_reader_new(&reader, &source, "filename");
check(!err);
@@ -823,8 +822,7 @@ static void t_write_multiple_indices(void)
reftable_iterator_destroy(&it);
reftable_writer_free(writer);
reftable_reader_decref(reader);
- strbuf_release(&writer_buf);
- strbuf_release(&buf);
+ reftable_buf_release(&writer_buf);
}
static void t_write_multi_level_index(void)
@@ -832,7 +830,7 @@ static void t_write_multi_level_index(void)
struct reftable_write_options opts = {
.block_size = 100,
};
- struct strbuf writer_buf = STRBUF_INIT, buf = STRBUF_INIT;
+ struct reftable_buf writer_buf = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT;
struct reftable_block_source source = { 0 };
struct reftable_iterator it = { 0 };
const struct reftable_stats *stats;
@@ -848,10 +846,10 @@ static void t_write_multi_level_index(void)
.value_type = REFTABLE_REF_VAL1,
.value.val1 = {i},
};
+ char buf[128];
- strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/heads/%03" PRIuMAX, (uintmax_t)i);
- ref.refname = buf.buf,
+ snprintf(buf, sizeof(buf), "refs/heads/%03" PRIuMAX, (uintmax_t)i);
+ ref.refname = buf;
err = reftable_writer_add_ref(writer, &ref);
check(!err);
@@ -865,7 +863,7 @@ static void t_write_multi_level_index(void)
stats = reftable_writer_stats(writer);
check_int(stats->ref_stats.max_index_level, ==, 2);
- block_source_from_strbuf(&source, &writer_buf);
+ block_source_from_buf(&source, &writer_buf);
err = reftable_reader_new(&reader, &source, "filename");
check(!err);
@@ -880,18 +878,18 @@ static void t_write_multi_level_index(void)
reftable_iterator_destroy(&it);
reftable_writer_free(writer);
reftable_reader_decref(reader);
- strbuf_release(&writer_buf);
- strbuf_release(&buf);
+ reftable_buf_release(&writer_buf);
+ reftable_buf_release(&buf);
}
static void t_corrupt_table_empty(void)
{
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_block_source source = { 0 };
struct reftable_reader *reader;
int err;
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.log");
check_int(err, ==, REFTABLE_FORMAT_ERROR);
}
@@ -899,17 +897,17 @@ static void t_corrupt_table_empty(void)
static void t_corrupt_table(void)
{
uint8_t zeros[1024] = { 0 };
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
struct reftable_block_source source = { 0 };
struct reftable_reader *reader;
int err;
- strbuf_add(&buf, zeros, sizeof(zeros));
+ check(!reftable_buf_add(&buf, zeros, sizeof(zeros)));
- block_source_from_strbuf(&source, &buf);
+ block_source_from_buf(&source, &buf);
err = reftable_reader_new(&reader, &source, "file.log");
check_int(err, ==, REFTABLE_FORMAT_ERROR);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
}
int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c
index a7f67d4d9f..eb98bf2da9 100644
--- a/t/unit-tests/t-reftable-record.c
+++ b/t/unit-tests/t-reftable-record.c
@@ -116,7 +116,7 @@ static void t_reftable_ref_record_compare_name(void)
static void t_reftable_ref_record_roundtrip(void)
{
- struct strbuf scratch = STRBUF_INIT;
+ struct reftable_buf scratch = REFTABLE_BUF_INIT;
for (int i = REFTABLE_REF_DELETION; i < REFTABLE_NR_REF_VALUETYPES; i++) {
struct reftable_record in = {
@@ -124,7 +124,7 @@ static void t_reftable_ref_record_roundtrip(void)
.u.ref.value_type = i,
};
struct reftable_record out = { .type = BLOCK_TYPE_REF };
- struct strbuf key = STRBUF_INIT;
+ struct reftable_buf key = REFTABLE_BUF_INIT;
uint8_t buffer[1024] = { 0 };
struct string_view dest = {
.buf = buffer,
@@ -166,11 +166,11 @@ static void t_reftable_ref_record_roundtrip(void)
GIT_SHA1_RAWSZ));
reftable_record_release(&in);
- strbuf_release(&key);
+ reftable_buf_release(&key);
reftable_record_release(&out);
}
- strbuf_release(&scratch);
+ reftable_buf_release(&scratch);
}
static void t_reftable_log_record_comparison(void)
@@ -262,7 +262,7 @@ static void t_reftable_log_record_roundtrip(void)
.value_type = REFTABLE_LOG_UPDATE,
}
};
- struct strbuf scratch = STRBUF_INIT;
+ struct reftable_buf scratch = REFTABLE_BUF_INIT;
set_hash(in[0].value.update.new_hash, 1);
set_hash(in[0].value.update.old_hash, 2);
set_hash(in[2].value.update.new_hash, 3);
@@ -274,7 +274,7 @@ static void t_reftable_log_record_roundtrip(void)
for (size_t i = 0; i < ARRAY_SIZE(in); i++) {
struct reftable_record rec = { .type = BLOCK_TYPE_LOG };
- struct strbuf key = STRBUF_INIT;
+ struct reftable_buf key = REFTABLE_BUF_INIT;
uint8_t buffer[1024] = { 0 };
struct string_view dest = {
.buf = buffer,
@@ -313,11 +313,11 @@ static void t_reftable_log_record_roundtrip(void)
check(reftable_log_record_equal(&in[i], &out.u.log,
GIT_SHA1_RAWSZ));
reftable_log_record_release(&in[i]);
- strbuf_release(&key);
+ reftable_buf_release(&key);
reftable_record_release(&out);
}
- strbuf_release(&scratch);
+ reftable_buf_release(&scratch);
}
static void t_key_roundtrip(void)
@@ -327,30 +327,30 @@ static void t_key_roundtrip(void)
.buf = buffer,
.len = sizeof(buffer),
};
- struct strbuf last_key = STRBUF_INIT;
- struct strbuf key = STRBUF_INIT;
- struct strbuf roundtrip = STRBUF_INIT;
+ struct reftable_buf last_key = REFTABLE_BUF_INIT;
+ struct reftable_buf key = REFTABLE_BUF_INIT;
+ struct reftable_buf roundtrip = REFTABLE_BUF_INIT;
int restart;
uint8_t extra;
int n, m;
uint8_t rt_extra;
- strbuf_addstr(&last_key, "refs/heads/master");
- strbuf_addstr(&key, "refs/tags/bla");
+ check(!reftable_buf_addstr(&last_key, "refs/heads/master"));
+ check(!reftable_buf_addstr(&key, "refs/tags/bla"));
extra = 6;
n = reftable_encode_key(&restart, dest, last_key, key, extra);
check(!restart);
check_int(n, >, 0);
- strbuf_addstr(&roundtrip, "refs/heads/master");
+ check(!reftable_buf_addstr(&roundtrip, "refs/heads/master"));
m = reftable_decode_key(&roundtrip, &rt_extra, dest);
check_int(n, ==, m);
- check(!strbuf_cmp(&key, &roundtrip));
+ check(!reftable_buf_cmp(&key, &roundtrip));
check_int(rt_extra, ==, extra);
- strbuf_release(&last_key);
- strbuf_release(&key);
- strbuf_release(&roundtrip);
+ reftable_buf_release(&last_key);
+ reftable_buf_release(&key);
+ reftable_buf_release(&roundtrip);
}
static void t_reftable_obj_record_comparison(void)
@@ -413,7 +413,7 @@ static void t_reftable_obj_record_roundtrip(void)
.hash_prefix_len = 5,
},
};
- struct strbuf scratch = STRBUF_INIT;
+ struct reftable_buf scratch = REFTABLE_BUF_INIT;
for (size_t i = 0; i < ARRAY_SIZE(recs); i++) {
uint8_t buffer[1024] = { 0 };
@@ -427,7 +427,7 @@ static void t_reftable_obj_record_roundtrip(void)
.obj = recs[i],
},
};
- struct strbuf key = STRBUF_INIT;
+ struct reftable_buf key = REFTABLE_BUF_INIT;
struct reftable_record out = { .type = BLOCK_TYPE_OBJ };
int n, m;
uint8_t extra;
@@ -443,11 +443,11 @@ static void t_reftable_obj_record_roundtrip(void)
check_int(n, ==, m);
check(reftable_record_equal(&in, &out, GIT_SHA1_RAWSZ));
- strbuf_release(&key);
+ reftable_buf_release(&key);
reftable_record_release(&out);
}
- strbuf_release(&scratch);
+ reftable_buf_release(&scratch);
}
static void t_reftable_index_record_comparison(void)
@@ -456,22 +456,22 @@ static void t_reftable_index_record_comparison(void)
{
.type = BLOCK_TYPE_INDEX,
.u.idx.offset = 22,
- .u.idx.last_key = STRBUF_INIT,
+ .u.idx.last_key = REFTABLE_BUF_INIT,
},
{
.type = BLOCK_TYPE_INDEX,
.u.idx.offset = 32,
- .u.idx.last_key = STRBUF_INIT,
+ .u.idx.last_key = REFTABLE_BUF_INIT,
},
{
.type = BLOCK_TYPE_INDEX,
.u.idx.offset = 32,
- .u.idx.last_key = STRBUF_INIT,
+ .u.idx.last_key = REFTABLE_BUF_INIT,
},
};
- strbuf_addstr(&in[0].u.idx.last_key, "refs/heads/master");
- strbuf_addstr(&in[1].u.idx.last_key, "refs/heads/master");
- strbuf_addstr(&in[2].u.idx.last_key, "refs/heads/branch");
+ check(!reftable_buf_addstr(&in[0].u.idx.last_key, "refs/heads/master"));
+ check(!reftable_buf_addstr(&in[1].u.idx.last_key, "refs/heads/master"));
+ check(!reftable_buf_addstr(&in[2].u.idx.last_key, "refs/heads/branch"));
check(!reftable_record_equal(&in[0], &in[1], GIT_SHA1_RAWSZ));
check(!reftable_record_cmp(&in[0], &in[1]));
@@ -493,7 +493,7 @@ static void t_reftable_index_record_roundtrip(void)
.type = BLOCK_TYPE_INDEX,
.u.idx = {
.offset = 42,
- .last_key = STRBUF_INIT,
+ .last_key = REFTABLE_BUF_INIT,
},
};
uint8_t buffer[1024] = { 0 };
@@ -501,21 +501,21 @@ static void t_reftable_index_record_roundtrip(void)
.buf = buffer,
.len = sizeof(buffer),
};
- struct strbuf scratch = STRBUF_INIT;
- struct strbuf key = STRBUF_INIT;
+ struct reftable_buf scratch = REFTABLE_BUF_INIT;
+ struct reftable_buf key = REFTABLE_BUF_INIT;
struct reftable_record out = {
.type = BLOCK_TYPE_INDEX,
- .u.idx = { .last_key = STRBUF_INIT },
+ .u.idx = { .last_key = REFTABLE_BUF_INIT },
};
int n, m;
uint8_t extra;
- strbuf_addstr(&in.u.idx.last_key, "refs/heads/master");
+ check(!reftable_buf_addstr(&in.u.idx.last_key, "refs/heads/master"));
reftable_record_key(&in, &key);
t_copy(&in);
check(!reftable_record_is_deletion(&in));
- check(!strbuf_cmp(&key, &in.u.idx.last_key));
+ check(!reftable_buf_cmp(&key, &in.u.idx.last_key));
n = reftable_record_encode(&in, dest, GIT_SHA1_RAWSZ);
check_int(n, >, 0);
@@ -527,9 +527,9 @@ static void t_reftable_index_record_roundtrip(void)
check(reftable_record_equal(&in, &out, GIT_SHA1_RAWSZ));
reftable_record_release(&out);
- strbuf_release(&key);
- strbuf_release(&scratch);
- strbuf_release(&in.u.idx.last_key);
+ reftable_buf_release(&key);
+ reftable_buf_release(&scratch);
+ reftable_buf_release(&in.u.idx.last_key);
}
int cmd_main(int argc UNUSED, const char *argv[] UNUSED)
diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
index 874095b9ee..72f6747064 100644
--- a/t/unit-tests/t-reftable-stack.c
+++ b/t/unit-tests/t-reftable-stack.c
@@ -16,7 +16,7 @@ https://developers.google.com/open-source/licenses/bsd
static void clear_dir(const char *dirname)
{
- struct strbuf path = STRBUF_INIT;
+ struct strbuf path = REFTABLE_BUF_INIT;
strbuf_addstr(&path, dirname);
remove_dir_recursively(&path, 0);
strbuf_release(&path);
@@ -105,7 +105,6 @@ static int write_test_ref(struct reftable_writer *wr, void *arg)
static void write_n_ref_tables(struct reftable_stack *st,
size_t n)
{
- struct strbuf buf = STRBUF_INIT;
int disable_auto_compact;
int err;
@@ -117,10 +116,10 @@ static void write_n_ref_tables(struct reftable_stack *st,
.update_index = reftable_stack_next_update_index(st),
.value_type = REFTABLE_REF_VAL1,
};
+ char buf[128];
- strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/heads/branch-%04"PRIuMAX, (uintmax_t)i);
- ref.refname = buf.buf;
+ snprintf(buf, sizeof(buf), "refs/heads/branch-%04"PRIuMAX, (uintmax_t)i);
+ ref.refname = buf;
t_reftable_set_hash(ref.value.val1, i, GIT_SHA1_FORMAT_ID);
err = reftable_stack_add(st, &write_test_ref, &ref);
@@ -128,7 +127,6 @@ static void write_n_ref_tables(struct reftable_stack *st,
}
st->opts.disable_auto_compact = disable_auto_compact;
- strbuf_release(&buf);
}
struct write_log_arg {
@@ -147,7 +145,7 @@ static int write_test_log(struct reftable_writer *wr, void *arg)
static void t_reftable_stack_add_one(void)
{
char *dir = get_tmp_dir(__LINE__);
- struct strbuf scratch = STRBUF_INIT;
+ struct reftable_buf scratch = REFTABLE_BUF_INIT;
int mask = umask(002);
struct reftable_write_options opts = {
.default_permissions = 0660,
@@ -174,17 +172,17 @@ static void t_reftable_stack_add_one(void)
check_int(st->readers_len, >, 0);
#ifndef GIT_WINDOWS_NATIVE
- strbuf_addstr(&scratch, dir);
- strbuf_addstr(&scratch, "/tables.list");
+ check(!reftable_buf_addstr(&scratch, dir));
+ check(!reftable_buf_addstr(&scratch, "/tables.list"));
err = stat(scratch.buf, &stat_result);
check(!err);
check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
- strbuf_reset(&scratch);
- strbuf_addstr(&scratch, dir);
- strbuf_addstr(&scratch, "/");
+ reftable_buf_reset(&scratch);
+ check(!reftable_buf_addstr(&scratch, dir));
+ check(!reftable_buf_addstr(&scratch, "/"));
/* do not try at home; not an external API for reftable. */
- strbuf_addstr(&scratch, st->readers[0]->name);
+ check(!reftable_buf_addstr(&scratch, st->readers[0]->name));
err = stat(scratch.buf, &stat_result);
check(!err);
check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
@@ -194,7 +192,7 @@ static void t_reftable_stack_add_one(void)
reftable_ref_record_release(&dest);
reftable_stack_destroy(st);
- strbuf_release(&scratch);
+ reftable_buf_release(&scratch);
clear_dir(dir);
umask(mask);
}
@@ -416,7 +414,7 @@ static void t_reftable_stack_auto_compaction_fails_gracefully(void)
};
struct reftable_write_options opts = { 0 };
struct reftable_stack *st;
- struct strbuf table_path = STRBUF_INIT;
+ struct reftable_buf table_path = REFTABLE_BUF_INIT;
char *dir = get_tmp_dir(__LINE__);
int err;
@@ -434,7 +432,10 @@ static void t_reftable_stack_auto_compaction_fails_gracefully(void)
* Adding a new table to the stack should not be impacted by this, even
* though auto-compaction will now fail.
*/
- strbuf_addf(&table_path, "%s/%s.lock", dir, st->readers[0]->name);
+ check(!reftable_buf_addstr(&table_path, dir));
+ check(!reftable_buf_addstr(&table_path, "/"));
+ check(!reftable_buf_addstr(&table_path, st->readers[0]->name));
+ check(!reftable_buf_addstr(&table_path, ".lock"));
write_file_buf(table_path.buf, "", 0);
ref.update_index = 2;
@@ -445,7 +446,7 @@ static void t_reftable_stack_auto_compaction_fails_gracefully(void)
check_int(st->stats.failures, ==, 1);
reftable_stack_destroy(st);
- strbuf_release(&table_path);
+ reftable_buf_release(&table_path);
clear_dir(dir);
}
@@ -515,7 +516,7 @@ static void t_reftable_stack_add(void)
char *dir = get_tmp_dir(__LINE__);
struct reftable_ref_record refs[2] = { 0 };
struct reftable_log_record logs[2] = { 0 };
- struct strbuf path = STRBUF_INIT;
+ struct reftable_buf path = REFTABLE_BUF_INIT;
struct stat stat_result;
size_t i, N = ARRAY_SIZE(refs);
@@ -574,17 +575,17 @@ static void t_reftable_stack_add(void)
}
#ifndef GIT_WINDOWS_NATIVE
- strbuf_addstr(&path, dir);
- strbuf_addstr(&path, "/tables.list");
+ check(!reftable_buf_addstr(&path, dir));
+ check(!reftable_buf_addstr(&path, "/tables.list"));
err = stat(path.buf, &stat_result);
check(!err);
check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
- strbuf_reset(&path);
- strbuf_addstr(&path, dir);
- strbuf_addstr(&path, "/");
+ reftable_buf_reset(&path);
+ check(!reftable_buf_addstr(&path, dir));
+ check(!reftable_buf_addstr(&path, "/"));
/* do not try at home; not an external API for reftable. */
- strbuf_addstr(&path, st->readers[0]->name);
+ check(!reftable_buf_addstr(&path, st->readers[0]->name));
err = stat(path.buf, &stat_result);
check(!err);
check_int((stat_result.st_mode & 0777), ==, opts.default_permissions);
@@ -598,7 +599,7 @@ static void t_reftable_stack_add(void)
reftable_ref_record_release(&refs[i]);
reftable_log_record_release(&logs[i]);
}
- strbuf_release(&path);
+ reftable_buf_release(&path);
clear_dir(dir);
}
@@ -1062,7 +1063,7 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void)
.disable_auto_compact = 1,
};
struct reftable_stack *st = NULL;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
char *dir = get_tmp_dir(__LINE__);
int err;
@@ -1077,8 +1078,10 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void)
* size, we expect that auto-compaction will want to compact all of the
* tables. Locking any of the tables will keep it from doing so.
*/
- strbuf_reset(&buf);
- strbuf_addf(&buf, "%s/%s.lock", dir, st->readers[2]->name);
+ check(!reftable_buf_addstr(&buf, dir));
+ check(!reftable_buf_addstr(&buf, "/"));
+ check(!reftable_buf_addstr(&buf, st->readers[2]->name));
+ check(!reftable_buf_addstr(&buf, ".lock"));
write_file_buf(buf.buf, "", 0);
/*
@@ -1093,7 +1096,7 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void)
check_int(st->merged->readers_len, ==, 4);
reftable_stack_destroy(st);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
clear_dir(dir);
}
@@ -1101,7 +1104,6 @@ static void t_reftable_stack_add_performs_auto_compaction(void)
{
struct reftable_write_options opts = { 0 };
struct reftable_stack *st = NULL;
- struct strbuf refname = STRBUF_INIT;
char *dir = get_tmp_dir(__LINE__);
int err;
size_t i, n = 20;
@@ -1115,6 +1117,7 @@ static void t_reftable_stack_add_performs_auto_compaction(void)
.value_type = REFTABLE_REF_SYMREF,
.value.symref = (char *) "master",
};
+ char buf[128];
/*
* Disable auto-compaction for all but the last runs. Like this
@@ -1123,9 +1126,8 @@ static void t_reftable_stack_add_performs_auto_compaction(void)
*/
st->opts.disable_auto_compact = i != n;
- strbuf_reset(&refname);
- strbuf_addf(&refname, "branch-%04"PRIuMAX, (uintmax_t)i);
- ref.refname = refname.buf;
+ snprintf(buf, sizeof(buf), "branch-%04"PRIuMAX, (uintmax_t)i);
+ ref.refname = buf;
err = reftable_stack_add(st, write_test_ref, &ref);
check(!err);
@@ -1142,7 +1144,6 @@ static void t_reftable_stack_add_performs_auto_compaction(void)
}
reftable_stack_destroy(st);
- strbuf_release(&refname);
clear_dir(dir);
}
@@ -1152,7 +1153,7 @@ static void t_reftable_stack_compaction_with_locked_tables(void)
.disable_auto_compact = 1,
};
struct reftable_stack *st = NULL;
- struct strbuf buf = STRBUF_INIT;
+ struct reftable_buf buf = REFTABLE_BUF_INIT;
char *dir = get_tmp_dir(__LINE__);
int err;
@@ -1163,8 +1164,10 @@ static void t_reftable_stack_compaction_with_locked_tables(void)
check_int(st->merged->readers_len, ==, 3);
/* Lock one of the tables that we're about to compact. */
- strbuf_reset(&buf);
- strbuf_addf(&buf, "%s/%s.lock", dir, st->readers[1]->name);
+ check(!reftable_buf_addstr(&buf, dir));
+ check(!reftable_buf_addstr(&buf, "/"));
+ check(!reftable_buf_addstr(&buf, st->readers[1]->name));
+ check(!reftable_buf_addstr(&buf, ".lock"));
write_file_buf(buf.buf, "", 0);
/*
@@ -1177,7 +1180,7 @@ static void t_reftable_stack_compaction_with_locked_tables(void)
check_int(st->merged->readers_len, ==, 3);
reftable_stack_destroy(st);
- strbuf_release(&buf);
+ reftable_buf_release(&buf);
clear_dir(dir);
}
@@ -1303,7 +1306,7 @@ static void t_reftable_stack_reload_with_missing_table(void)
struct reftable_stack *st = NULL;
struct reftable_ref_record rec = { 0 };
struct reftable_iterator it = { 0 };
- struct strbuf table_path = STRBUF_INIT, content = STRBUF_INIT;
+ struct reftable_buf table_path = REFTABLE_BUF_INIT, content = REFTABLE_BUF_INIT;
char *dir = get_tmp_dir(__LINE__);
int err;
@@ -1321,10 +1324,13 @@ static void t_reftable_stack_reload_with_missing_table(void)
* our old readers. This should trigger a partial reload of the stack,
* where we try to reuse our old readers.
*/
- strbuf_addf(&content, "%s\n", st->readers[0]->name);
- strbuf_addf(&content, "%s\n", st->readers[1]->name);
- strbuf_addstr(&content, "garbage\n");
- strbuf_addf(&table_path, "%s.lock", st->list_file);
+ check(!reftable_buf_addstr(&content, st->readers[0]->name));
+ check(!reftable_buf_addstr(&content, "\n"));
+ check(!reftable_buf_addstr(&content, st->readers[1]->name));
+ check(!reftable_buf_addstr(&content, "\n"));
+ check(!reftable_buf_addstr(&content, "garbage\n"));
+ check(!reftable_buf_addstr(&table_path, st->list_file));
+ check(!reftable_buf_addstr(&table_path, ".lock"));
write_file_buf(table_path.buf, content.buf, content.len);
err = rename(table_path.buf, st->list_file);
check(!err);
@@ -1349,8 +1355,8 @@ static void t_reftable_stack_reload_with_missing_table(void)
reftable_ref_record_release(&rec);
reftable_iterator_destroy(&it);
reftable_stack_destroy(st);
- strbuf_release(&table_path);
- strbuf_release(&content);
+ reftable_buf_release(&table_path);
+ reftable_buf_release(&content);
clear_dir(dir);
}