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

[PATCH v2 1/8] interpret_branch_name: move docstring to header file

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

We generally put docstrings with function declarations, because it's the callers who need to know how the function works. Let's do so for interpret_branch_name().

Signed-off-by: Jeff King <peff@peff.net>
---
 cache.h     | 21 +++++++++++++++++++++
 sha1_name.c | 21 ---------------------
 2 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/cache.h b/cache.h
index 80b6372cf..c67995caa 100644
--- a/cache.h
+++ b/cache.h
@@ -1363,6 +1363,27 @@ extern char *oid_to_hex_r(char *out, const struct object_id *oid);
 extern char *sha1_to_hex(const unsigned char *sha1);	/* static buffer result! */
 extern char *oid_to_hex(const struct object_id *oid);	/* same static buffer as sha1_to_hex */
 
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ *   places the name of the branch in the given buf and returns the
+ *   number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ *   <branch> is configured to merge with (missing <branch> defaults
+ *   to the current branch), and places the name of the branch in the
+ *   given buf and returns the number of characters parsed if
+ *   successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
 extern int interpret_branch_name(const char *str, int len, struct strbuf *);
 extern int get_oid_mb(const char *str, struct object_id *oid);
 
diff --git a/sha1_name.c b/sha1_name.c
index 9b5d14b4b..28865b3a1 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1238,27 +1238,6 @@ static int interpret_branch_mark(const char *name, int namelen,
 	return len + at;
 }
 
-/*
- * This reads short-hand syntax that not only evaluates to a commit
- * object name, but also can act as if the end user spelled the name
- * of the branch from the command line.
- *
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
- *   places the name of the branch in the given buf and returns the
- *   number of characters parsed if successful.
- *
- * - "<branch>@{upstream}" finds the name of the other ref that
- *   <branch> is configured to merge with (missing <branch> defaults
- *   to the current branch), and places the name of the branch in the
- *   given buf and returns the number of characters parsed if
- *   successful.
- *
- * If the input is not of the accepted format, it returns a negative
- * number to signal an error.
- *
- * If the input was ok but there are not N branch switches in the
- * reflog, it returns 0.
- */
 int interpret_branch_name(const char *name, int namelen, struct strbuf *buf)
 {
 	char *at;
-- 
2.12.0.367.gb23790f66
Previous: Jeff KingNext: Jeff King
Message 2 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.