git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] merge: use skip_prefix()

From
René Scharfe <l.s.r@web.de>
Date
Aug 10, 2017, 16:47 UTC
Message-ID
<7ebe2ff6-bc4b-3694-7978-a1f5f8628b8a@web.de>

Get rid of a magic string length constant by using skip_prefix() instead of starts_with().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/merge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 900bafdb45..4facb6fdd0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1117,8 +1117,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 	 * current branch.
 	 */
 	branch = branch_to_free = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
-	if (branch && starts_with(branch, "refs/heads/"))
-		branch += 11;
+	if (branch)
+		skip_prefix(branch, "refs/heads/", &branch);
 	if (!branch || is_null_oid(&head_oid))
 		head_commit = NULL;
 	else
-- 
2.14.0
Message 1 of 1 in “merge: use skip_prefix()”
  1. merge: use skip_prefix()René Scharfe, Aug 10, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.