From: "Mohit Marathe via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Mohit Marathe <mohitmarathe@proton.me>,
Mohit Marathe <mohitmarathe@proton.me>
Subject: [PATCH 2/2] test-lib: replace repeated code logic with an existing helper
Date: Mon, 18 Mar 2024 12:47:42 +0000 [thread overview]
Message-ID: <8a730b6ebba4111aaad4e8fc938c52f6e7e54480.1710766062.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1699.git.1710766062.gitgitgadget@gmail.com>
From: Mohit Marathe <mohitmarathe@proton.me>
This patch replaces the code, that changes the path separators,
with the already existing function `change_path_separators()`
Signed-off-by: Mohit Marathe <mohitmarathe@proton.me>
---
t/unit-tests/test-lib.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/t/unit-tests/test-lib.c b/t/unit-tests/test-lib.c
index 66d6980ffbe..b0e26263046 100644
--- a/t/unit-tests/test-lib.c
+++ b/t/unit-tests/test-lib.c
@@ -52,9 +52,7 @@ static const char *make_relative(const char *location)
prefix_len = len - needle_len;
if (prefix[prefix_len + 1] == '/') {
/* Oh, we're not Windows */
- for (size_t i = 0; i < needle_len; i++)
- if (needle[i] == '\\')
- needle[i] = '/';
+ change_path_separators(&needle[0]);
need_bs_to_fs = 0;
} else {
need_bs_to_fs = 1;
@@ -88,9 +86,8 @@ static const char *make_relative(const char *location)
/* convert backslashes to forward slashes */
strlcpy(buf, location + prefix_len, sizeof(buf));
- for (p = buf; *p; p++)
- if (*p == '\\')
- *p = '/';
+ p = buf;
+ change_path_separators(p);
return buf;
}
--
gitgitgadget
next prev parent reply other threads:[~2024-03-18 12:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 12:47 [PATCH 0/2] git-compat-util: move convert_slashes from compat/mingw.h and rename it Mohit Marathe via GitGitGadget
2024-03-18 12:47 ` [PATCH 1/2] git-compat-util: migrate `convert_slashes()` from compat/mingw.h Mohit Marathe via GitGitGadget
2024-03-18 21:57 ` Junio C Hamano
2024-03-18 12:47 ` Mohit Marathe via GitGitGadget [this message]
2024-03-18 21:58 ` [PATCH 2/2] test-lib: replace repeated code logic with an existing helper Junio C Hamano
2024-04-11 21:42 ` Josh Steadmon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a730b6ebba4111aaad4e8fc938c52f6e7e54480.1710766062.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=mohitmarathe@proton.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.