Thread (380 messages) flat view 380 messages, 13 authors, 2026-07-24

Re: [PATCH v9 3/8] cat-file: split test utility functions into a separate library file

From: Peijian Ju <hidden>
Date: 2025-01-14 01:33:22

Thank you Christian. They are all fixed in v10

On Fri, Jan 10, 2025 at 9:26 AM Christian Couder
[off-list ref] wrote:
About the commit subject, maybe something like the following would be
a bit shorter:

t1006: split test utility functions into new "lib-cat-file.sh"

On Wed, Jan 8, 2025 at 7:38 PM Eric Ju [off-list ref] wrote:
quoted
This refactor extracts utility functions from the cat-file's test
s/test/test script/
quoted
t1006-cat-file.sh into a dedicated library file. The goal is to improve
s/a dedicated library file/a new "lib-cat-file.sh" dedicated library file/
quoted
code reuse and readability, enabling future tests to leverage these
utilities without duplicating code
s/code/code./
quoted
diff --git a/t/lib-cat-file.sh b/t/lib-cat-file.sh
new file mode 100644
index 0000000000..9fb20be308
--- /dev/null
+++ b/t/lib-cat-file.sh
@@ -0,0 +1,16 @@
+# Library of git-cat-file related tests.
s/tests/test functions/
quoted
+
+# Print a string without a trailing newline
s/newline/newline./
quoted
+echo_without_newline () {
+       printf '%s' "$*"
+}
+
+# Print a string without newlines and replaces them with a NULL character (\0).
s/replaces/replace/
quoted
+echo_without_newline_nul () {
+       echo_without_newline "$@" | tr '\n' '\0'
+}
+
+# Calculate the length of a string removing any leading spaces.
This might be a bit misleading as leading spaces are removed from the
output from `wc -c`, not from the string.
Yes, I will just change it to "Calculate the length of a string. "
quoted
+strlen () {
+       echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help