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

[PATCH] rerere: remove duplicated functions

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Feb 14, 2009, 16:18 UTC
Message-ID
<1234628284-4246-1-git-send-email-szeder@ira.uka.de>

Both rerere.c and builtin-rerere.c define the static functions rr_path() and has_resolution() the exact same way. To eliminate this code duplication this patch turns the functions in rerere.c non-static, and makes builtin-rerere.c use them.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 builtin-rerere.c |   11 -----------
 rerere.c         |    4 ++--
 rerere.h         |    2 ++
 3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/builtin-rerere.c b/builtin-rerere.c
index bd8fc77..b175334 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -13,23 +13,12 @@ static const char git_rerere_usage[] =
 static int cutoff_noresolve = 15;
 static int cutoff_resolve = 60;
 
-static const char *rr_path(const char *name, const char *file)
-{
-	return git_path("rr-cache/%s/%s", name, file);
-}
-
 static time_t rerere_created_at(const char *name)
 {
 	struct stat st;
 	return stat(rr_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
 }
 
-static int has_resolution(const char *name)
-{
-	struct stat st;
-	return !stat(rr_path(name, "postimage"), &st);
-}
-
 static void unlink_rr_item(const char *name)
 {
 	unlink(rr_path(name, "thisimage"));
diff --git a/rerere.c b/rerere.c
index 3518207..ac89b80 100644
--- a/rerere.c
+++ b/rerere.c
@@ -12,12 +12,12 @@ static int rerere_autoupdate;
 
 static char *merge_rr_path;
 
-static const char *rr_path(const char *name, const char *file)
+const char *rr_path(const char *name, const char *file)
 {
 	return git_path("rr-cache/%s/%s", name, file);
 }
 
-static int has_resolution(const char *name)
+int has_resolution(const char *name)
 {
 	struct stat st;
 	return !stat(rr_path(name, "postimage"), &st);
diff --git a/rerere.h b/rerere.h
index f9b0386..45b5087 100644
--- a/rerere.h
+++ b/rerere.h
@@ -5,5 +5,7 @@
 
 extern int setup_rerere(struct string_list *);
 extern int rerere(void);
+extern const char *rr_path(const char *name, const char *file);
+extern int has_resolution(const char *name);
 
 #endif
-- 
1.6.2.rc0.111.g246ed
Next: Johannes Schindelin
Message 1 of 5 in “rerere: remove duplicated functions”
  1. rerere: remove duplicated functionsSZEDER Gábor, Feb 14, 2009
  2. Johannes SchindelinFeb 14, 2009
  3. rerere: remove duplicated functionsSZEDER Gábor, Feb 14, 2009
  4. Johannes SchindelinFeb 14, 2009
  5. Junio C HamanoFeb 15, 2009

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.