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

[PATCH 2/6] prefix_filename: move docstring to header file

From
Jeff King <peff@peff.net>
Date
Mar 21, 2017, 01:21 UTC
Message-ID
<20170321012127.qp4lp4zcc3icprzw@sigill.intra.peff.net>
In-Reply-To
<20170321011838.rdhnbfwbigm4s4e3@sigill.intra.peff.net>

This is a public function, so we should make its documentation available near the declaration.

While we're at it, we can give a few details about how it works.

Signed-off-by: Jeff King <peff@peff.net>
---
 abspath.c |  5 -----
 cache.h   | 12 ++++++++++++
 2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/abspath.c b/abspath.c
index b02e068aa..fd30aff08 100644
--- a/abspath.c
+++ b/abspath.c
@@ -246,11 +246,6 @@ char *absolute_pathdup(const char *path)
 	return strbuf_detach(&sb, NULL);
 }
 
-/*
- * Unlike prefix_path, this should be used if the named file does
- * not have to interact with index entry; i.e. name of a random file
- * on the filesystem.
- */
 const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
 {
 	static struct strbuf path = STRBUF_INIT;
diff --git a/cache.h b/cache.h
index 9b2157f59..a01668fc4 100644
--- a/cache.h
+++ b/cache.h
@@ -529,7 +529,19 @@ extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
 extern char *prefix_path(const char *prefix, int len, const char *path);
 extern char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path);
+
+/*
+ * Concatenate "prefix" (if len is non-zero) and "path", with no
+ * connecting characters (so "prefix" should end with a "/").
+ * Unlike prefix_path, this should be used if the named file does
+ * not have to interact with index entry; i.e. name of a random file
+ * on the filesystem.
+ *
+ * The return value may point to static storage which will be overwritten by
+ * further calls.
+ */
 extern const char *prefix_filename(const char *prefix, int len, const char *path);
+
 extern int check_filename(const char *prefix, const char *name);
 extern void verify_filename(const char *prefix,
 			    const char *name,
-- 
2.12.1.683.gcd02edfec
Previous: Jeff KingNext: Jeff King
Message 3 of 11 in “prefix_filename cleanups”
  1. 0/6 prefix_filename cleanupsJeff King, Mar 21, 2017
  2. 1/6 hash-object: fix buffer reuse with --path in a subdirectoryJeff King, Mar 21, 2017
  3. 2/6 prefix_filename: move docstring to header fileJeff King, Mar 21, 2017
  4. 3/6 prefix_filename: drop length parameterJeff King, Mar 21, 2017
  5. 4/6 prefix_filename: return newly allocated stringJeff King, Mar 21, 2017
  6. Junio C HamanoMar 21, 2017
  7. Jeff KingMar 21, 2017
  8. Jeff KingMar 21, 2017
  9. 5/6 prefix_filename: simplify windows #ifdefJeff King, Mar 21, 2017
  10. 6/6 bundle: use prefix_filename with bundle pathJeff King, Mar 21, 2017
  11. Junio C HamanoMar 21, 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.