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

[PATCH v2 2/8] strbuf_branchname: drop return value

From
Jeff King <peff@peff.net>
Date
Mar 2, 2017, 08:21 UTC
Message-ID
<20170302082126.dupi3jcclhj6ejtv@sigill.intra.peff.net>
In-Reply-To
<20170302082100.edaretznmlralswa@sigill.intra.peff.net>

The return value from strbuf_branchname() is confusing and useless: it's 0 if the whole name was consumed by an @-mark, but otherwise is the length of the original name we fed.

No callers actually look at the return value, so let's just get rid of it.

Signed-off-by: Jeff King <peff@peff.net>
---
 sha1_name.c | 5 +----
 strbuf.h    | 2 +-
 2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sha1_name.c b/sha1_name.c
index 28865b3a1..4c1e91184 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1279,17 +1279,14 @@ int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
 	return -1;
 }
 
-int strbuf_branchname(struct strbuf *sb, const char *name)
+void strbuf_branchname(struct strbuf *sb, const char *name)
 {
 	int len = strlen(name);
 	int used = interpret_branch_name(name, len, sb);
 
-	if (used == len)
-		return 0;
 	if (used < 0)
 		used = 0;
 	strbuf_add(sb, name + used, len - used);
-	return len;
 }
 
 int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
diff --git a/strbuf.h b/strbuf.h
index cf1b5409e..47df0500d 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -560,7 +560,7 @@ static inline void strbuf_complete_line(struct strbuf *sb)
 	strbuf_complete(sb, '\n');
 }
 
-extern int strbuf_branchname(struct strbuf *sb, const char *name);
+extern void strbuf_branchname(struct strbuf *sb, const char *name);
 extern int strbuf_check_branch_ref(struct strbuf *sb, const char *name);
 
 extern void strbuf_addstr_urlencode(struct strbuf *, const char *,
-- 
2.12.0.367.gb23790f66
Previous: Jeff KingNext: Jeff King
Message 4 of 10 in “fixing corner-cases with interpret_branch_name()”
  1. fixing corner-cases with interpret_branch_name()Jeff King, Mar 2, 2017
  2. 1/8 interpret_branch_name: move docstring to header fileJeff King, Mar 2, 2017
  3. 3/8 strbuf_branchname: add docstringJeff King, Mar 2, 2017
  4. 2/8 strbuf_branchname: drop return valueJeff King, Mar 2, 2017
  5. 4/8 interpret_branch_name: allow callers to restrict expansionsJeff King, Mar 2, 2017
  6. 5/8 t3204: test git-branch @-expansion corner casesJeff King, Mar 2, 2017
  7. 6/8 branch: restrict @-expansions when deletingJeff King, Mar 2, 2017
  8. 7/8 strbuf_check_ref_format(): expand only local branchesJeff King, Mar 2, 2017
  9. Jacob KellerMar 2, 2017
  10. 8/8 checkout: restrict @-expansions when finding branchJeff King, Mar 2, 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.