threads / patch / 22177

patch, 18 partsdate.c: mark file-local function static

Subject: [PATCH 04/18] date.c: mark file-local function static

## tl;dr

24 messages between Jan 12, 2010 and Jan 13, 2010. Diffs are folded; open one to read it.

replies: 23people: 3as markdown or json

Junio C Hamano· Jan 12, 2010, 07:52 UTC · lore

[PATCH 00/18] mark file-local symbols static

The early part of the series up to [PATCH 12/18] are uncontroversial; they all change "extern" symbols that are not used outside of the file they are defined in to "static".

The remainder remove functions that are not called from anywhere. While the result of applying these patches still compiles, I find removal of some are iffy:

 * map_email(), has_pack_file() and strbuf_tolower() are not even
   documented.  They should go.  It is trivial to reimplement them when a
   new caller needs it.
 * Even though parse_blob() in blob.c is never called, it is part of the
   "object layer" suite that consistently defines their initializers as
   parse_$type().  But it has never been called by anybody since its
   inception at a510bfa (Mark blobs as parsed when they're actually
   parsed, 2005-04-28).
   By the way, Documentation/technical/api-object-access.txt needs some
   love.
 * object_list_append() and object_list_length() in object.c do not have
   any callers, and they are implementations of rather inefficient API.
   Perhaps they should go.
 * I am a bit worried about nobody calling invalidate_lstat_cache() and
   clear_lstat_cache().  Kjetil introduced them in aeabab5 (lstat_cache():
   introduce invalidate_lstat_cache() function, 2009-01-18) and bda6eb0
   (lstat_cache(): introduce clear_lstat_cache() function, 2009-01-18)
   respectively but as far as I can tell there wasn't any user of these
   functions, ever.  They may be broken and nobody knew they were as
   nothing calls them, but more importantly it could be that some existing
   codepaths aren't calling them when they should.

In this series, I am not removing alloc_report(), print_string_list(), and unsorted_string_list_has_string(). Among these three, the first two are clearly for debugging and the latter two are documented interfaces, even though nobody uses them.

I've made sure that they apply to 'master', 'next' and 'pu' (application to 'pu' has two conflicts that are trivial in 04/18 and 08/18) and the result compiles.

Junio C Hamano (18):
  bisect.c: mark file-local function static
  builtin-rev-list.c: mark file-local function static
  pretty.c: mark file-local function static
  date.c: mark file-local function static
  http.c: mark file-local functions static
  entry.c: mark file-local function static
  parse-options.c: mark file-local function static
  read-cache.c: mark file-local functions static
  remote-curl.c: mark file-local function static
  quote.c: mark file-local function static
  submodule.c: mark file-local function static
  utf8.c: mark file-local function static
  mailmap.c: remove unused function
  sha1_file.c: remove unused function
  strbuf.c: remove unused function
  blob.c: remove unused function
  object.c: remove unused functions
  symlinks.c: remove unused functions
 bisect.c           |    2 +-
 bisect.h           |    2 --
 blob.c             |   21 ---------------------
 blob.h             |    2 --
 builtin-rev-list.c |    2 +-
 cache.h            |    8 --------
 commit.h           |    1 -
 date.c             |    2 +-
 entry.c            |    2 +-
 git-compat-util.h  |    1 -
 http.c             |   10 ++++++++--
 http.h             |    9 ---------
 mailmap.c          |    5 -----
 mailmap.h          |    1 -
 object.c           |   21 ---------------------
 object.h           |    5 -----
 parse-options.c    |    7 +++++--
 parse-options.h    |    3 ---
 pretty.c           |    2 +-
 quote.c            |    2 +-
 quote.h            |    1 -
 read-cache.c       |    6 ++++--
 remote-curl.c      |    2 +-
 sha1_file.c        |    8 --------
 strbuf.c           |    7 -------
 strbuf.h           |    1 -
 submodule.c        |    2 +-
 symlinks.c         |   31 -------------------------------
 utf8.c             |    2 +-
 utf8.h             |    1 -
 30 files changed, 26 insertions(+), 143 deletions(-)
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 01/18] bisect.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 bisect.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to bisect.c +1 −1
diff --git a/bisect.c b/bisect.c
index f1a1f84..5c03398 100644
--- a/bisect.c
+++ b/bisect.c
@@ -593,7 +593,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
  * is increased by one between each call, but that should not matter
  * for this application.
  */
-int get_prn(int count) {
+static int get_prn(int count) {
 	count = count * 1103515245 + 12345;
 	return ((unsigned)(count/65536) % PRN_MODULO);
 }
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 02/18] builtin-rev-list.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 bisect.h           |    2 --
 builtin-rev-list.c |    2 +-
 2 files changed, 1 insertions(+), 3 deletions(-)
Show changes to 2 files +1 −3

bisect.h, builtin-rev-list.c

diff --git a/bisect.h b/bisect.h
index 82f8fc1..0862ce5 100644
--- a/bisect.h
+++ b/bisect.h
@@ -27,8 +27,6 @@ struct rev_list_info {
 	const char *header_prefix;
 };
 
-extern int show_bisect_vars(struct rev_list_info *info, int reaches, int all);
-
 extern int bisect_next_all(const char *prefix);
 
 extern int estimate_bisect_steps(int all);
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index cd97ded..c924b3a 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -253,7 +253,7 @@ static void print_var_int(const char *var, int val)
 	printf("%s=%d\n", var, val);
 }
 
-int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
+static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
 {
 	int cnt, flags = info->bisect_show_flags;
 	char hex[41] = "";
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 03/18] pretty.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 commit.h |    1 -
 pretty.c |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)
Show changes to 2 files +1 −2

commit.h, pretty.c

diff --git a/commit.h b/commit.h
index e5332ef..24128d7 100644
--- a/commit.h
+++ b/commit.h
@@ -73,7 +73,6 @@ struct pretty_print_context
 	struct reflog_walk_info *reflog_info;
 };
 
-extern int non_ascii(int);
 extern int has_non_ascii(const char *text);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern char *reencode_commit_message(const struct commit *commit,
diff --git a/pretty.c b/pretty.c
index 8f5bd1a..9001379 100644
--- a/pretty.c
+++ b/pretty.c
@@ -83,7 +83,7 @@ static int get_one_line(const char *msg)
 }
 
 /* High bit set, or ISO-2022-INT */
-int non_ascii(int ch)
+static int non_ascii(int ch)
 {
 	return !isascii(ch) || ch == '\033';
 }
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * Has a trivial conflict in git-compat-util.h when applyed to 'pu'
 date.c            |    2 +-
 git-compat-util.h |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)
Show changes to 2 files +1 −2

date.c, git-compat-util.h

diff --git a/date.c b/date.c
index 5d05ef6..45f3684 100644
--- a/date.c
+++ b/date.c
@@ -9,7 +9,7 @@
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
  */
-time_t tm_to_time_t(const struct tm *tm)
+static time_t tm_to_time_t(const struct tm *tm)
 {
 	static const int mdays[] = {
 	    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
diff --git a/git-compat-util.h b/git-compat-util.h
index 5c59687..85dea12 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -198,7 +198,6 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
 extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
 
 extern int prefixcmp(const char *str, const char *prefix);
-extern time_t tm_to_time_t(const struct tm *tm);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
 {
-- 
1.6.6.280.ge295b7.dirty
Johannes Sixt· Jan 12, 2010, 08:37 UTC · re: Junio C Hamano · lore

Re: [PATCH 04/18] date.c: mark file-local function static

Junio C Hamano schrieb:
Show 25 quoted lines
> diff --git a/date.c b/date.c
> index 5d05ef6..45f3684 100644
> --- a/date.c
> +++ b/date.c
> @@ -9,7 +9,7 @@
>  /*
>   * This is like mktime, but without normalization of tm_wday and tm_yday.
>   */
> -time_t tm_to_time_t(const struct tm *tm)
> +static time_t tm_to_time_t(const struct tm *tm)
>  {
>  	static const int mdays[] = {
>  	    0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 5c59687..85dea12 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -198,7 +198,6 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
>  extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
>  
>  extern int prefixcmp(const char *str, const char *prefix);
> -extern time_t tm_to_time_t(const struct tm *tm);
>  
>  static inline const char *skip_prefix(const char *str, const char *prefix)
>  {

This one is used from compat/mingw.c for the gettimeofday emulation. Please leave it extern.

-- Hannes
Junio C Hamano· Jan 12, 2010, 09:05 UTC · re: Johannes Sixt · lore

Re: [PATCH 04/18] date.c: mark file-local function static

Johannes Sixt <j.sixt@viscovery.net> writes:
Show 15 quoted lines
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index 5c59687..85dea12 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -198,7 +198,6 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
>>  extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_list params));
>>  
>>  extern int prefixcmp(const char *str, const char *prefix);
>> -extern time_t tm_to_time_t(const struct tm *tm);
>>  
>>  static inline const char *skip_prefix(const char *str, const char *prefix)
>>  {
>
> This one is used from compat/mingw.c for the gettimeofday emulation.
> Please leave it extern.

Ouch; I thought I ran "git grep <sym> pu" for all of them. Sorry and thanks.

Johannes Sixt· Jan 12, 2010, 09:43 UTC · re: Junio C Hamano · lore

Re: [PATCH 04/18] date.c: mark file-local function static

Junio C Hamano schrieb:
> Johannes Sixt <j.sixt@viscovery.net> writes:
>> This one is used from compat/mingw.c for the gettimeofday emulation.
>> Please leave it extern.
I'll add this patch to may windows-update series to avoids this hack.
--- 8< ---
From: Johannes Sixt <j6t@kdbg.org>
Subject: [PATCH] compat/mingw.c: do not use tm_to_time_t from date.c

To implement gettimeofday(), a broken-down UTC time was requested from the system using GetSystemTime() and converted using tm_to_time_t() because it does not look at the current timezone, which mktime() would do. But meanwhile we have grown infrastructure in mingw.c, so that we can use a different conversion path. This way we can avoid the ugly back-reference from the compatibility layer to the generic git code.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 compat/mingw.c |   18 +++++-------------
 1 files changed, 5 insertions(+), 13 deletions(-)
Show changes to compat/mingw.c +5 −13
diff --git a/compat/mingw.c b/compat/mingw.c
index faaaade..3c78f39 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -281,19 +281,11 @@ int mkstemp(char *template)
 
 int gettimeofday(struct timeval *tv, void *tz)
 {
-	SYSTEMTIME st;
-	struct tm tm;
-	GetSystemTime(&st);
-	tm.tm_year = st.wYear-1900;
-	tm.tm_mon = st.wMonth-1;
-	tm.tm_mday = st.wDay;
-	tm.tm_hour = st.wHour;
-	tm.tm_min = st.wMinute;
-	tm.tm_sec = st.wSecond;
-	tv->tv_sec = tm_to_time_t(&tm);
-	if (tv->tv_sec < 0)
-		return -1;
-	tv->tv_usec = st.wMilliseconds*1000;
+	FILETIME ft;
+	GetSystemTimeAsFileTime(&ft);
+	tv->tv_sec = filetime_to_time_t(&ft);
+	/* the unit is 100-nanoseconds, ie., a 10th of a microsecond */
+	tv->tv_usec = (ft.dwLowDateTime % 10000000) / 10;
 	return 0;
 }
 
-- 
1.6.6.1207.g714a1.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 05/18] http.c: mark file-local functions static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 http.c |   10 ++++++++--
 http.h |    9 ---------
 2 files changed, 8 insertions(+), 11 deletions(-)
Show changes to 2 files +8 −11

http.c, http.h

diff --git a/http.c b/http.c
index 5c3efb9..deab595 100644
--- a/http.c
+++ b/http.c
@@ -651,7 +651,7 @@ static void closedown_active_slot(struct active_request_slot *slot)
 	slot->in_use = 0;
 }
 
-void release_active_slot(struct active_request_slot *slot)
+static void release_active_slot(struct active_request_slot *slot)
 {
 	closedown_active_slot(slot);
 	if (slot->curl && curl_session_count > min_curl_sessions) {
@@ -834,7 +834,13 @@ int http_get_strbuf(const char *url, struct strbuf *result, int options)
 	return http_request(url, result, HTTP_REQUEST_STRBUF, options);
 }
 
-int http_get_file(const char *url, const char *filename, int options)
+/*
+ * Downloads an url and stores the result in the given file.
+ *
+ * If a previous interrupted download is detected (i.e. a previous temporary
+ * file is still around) the download is resumed.
+ */
+static int http_get_file(const char *url, const char *filename, int options)
 {
 	int ret;
 	struct strbuf tmpfile = STRBUF_INIT;
diff --git a/http.h b/http.h
index f828e1d..5c9441c 100644
--- a/http.h
+++ b/http.h
@@ -81,7 +81,6 @@ extern int start_active_slot(struct active_request_slot *slot);
 extern void run_active_slot(struct active_request_slot *slot);
 extern void finish_active_slot(struct active_request_slot *slot);
 extern void finish_all_active_slots(void);
-extern void release_active_slot(struct active_request_slot *slot);
 
 #ifdef USE_CURL_MULTI
 extern void fill_active_slots(void);
@@ -136,14 +135,6 @@ extern char *get_remote_object_url(const char *url, const char *hex,
 int http_get_strbuf(const char *url, struct strbuf *result, int options);
 
 /*
- * Downloads an url and stores the result in the given file.
- *
- * If a previous interrupted download is detected (i.e. a previous temporary
- * file is still around) the download is resumed.
- */
-int http_get_file(const char *url, const char *filename, int options);
-
-/*
  * Prints an error message using error() containing url and curl_errorstr,
  * and returns ret.
  */
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 06/18] entry.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 cache.h |    3 ---
 entry.c |    2 +-
 2 files changed, 1 insertions(+), 4 deletions(-)
Show changes to 2 files +1 −4

cache.h, entry.c

diff --git a/cache.h b/cache.h
index 3f9ee86..30b9048 100644
--- a/cache.h
+++ b/cache.h
@@ -473,9 +473,6 @@ extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_obje
 extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
 extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
 
-/* "careful lstat()" */
-extern int check_path(const char *path, int len, struct stat *st, int skiplen);
-
 #define REFRESH_REALLY		0x0001	/* ignore_valid */
 #define REFRESH_UNMERGED	0x0002	/* allow unmerged */
 #define REFRESH_QUIET		0x0004	/* be quiet about it */
diff --git a/entry.c b/entry.c
index 06d24f1..55b988e 100644
--- a/entry.c
+++ b/entry.c
@@ -179,7 +179,7 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
  * This is like 'lstat()', except it refuses to follow symlinks
  * in the path, after skipping "skiplen".
  */
-int check_path(const char *path, int len, struct stat *st, int skiplen)
+static int check_path(const char *path, int len, struct stat *st, int skiplen)
 {
 	const char *slash = path + len;
 
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 07/18] parse-options.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 parse-options.c |    7 +++++--
 parse-options.h |    3 ---
 2 files changed, 5 insertions(+), 5 deletions(-)
Show changes to 2 files +5 −5

parse-options.c, parse-options.h

diff --git a/parse-options.c b/parse-options.c
index f559411..7bbed5f 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -3,6 +3,9 @@
 #include "cache.h"
 #include "commit.h"
 
+static int parse_options_usage(const char * const *usagestr,
+			       const struct option *opts);
+
 #define OPT_SHORT 1
 #define OPT_UNSET 2
 
@@ -560,8 +563,8 @@ void usage_msg_opt(const char *msg,
 	usage_with_options(usagestr, options);
 }
 
-int parse_options_usage(const char * const *usagestr,
-			const struct option *opts)
+static int parse_options_usage(const char * const *usagestr,
+			       const struct option *opts)
 {
 	return usage_with_options_internal(usagestr, opts, 0);
 }
diff --git a/parse-options.h b/parse-options.h
index f295a2c..72fa360 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -171,9 +171,6 @@ struct parse_opt_ctx_t {
 	const char *prefix;
 };
 
-extern int parse_options_usage(const char * const *usagestr,
-			       const struct option *opts);
-
 extern void parse_options_start(struct parse_opt_ctx_t *ctx,
 				int argc, const char **argv, const char *prefix,
 				int flags);
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 08/18] read-cache.c: mark file-local functions static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * has conflicts when applied to 'pu' but nothing "am -3" cannot fix.
 * remove_index_entry_at() is left exported even though it can become
   static in 'master'; it is used in 'pu'.
 cache.h      |    2 --
 read-cache.c |    6 ++++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Show changes to 2 files +4 −4

cache.h, read-cache.c

diff --git a/cache.h b/cache.h
index 30b9048..e7bb6b7 100644
--- a/cache.h
+++ b/cache.h
@@ -445,7 +445,6 @@ extern int index_name_pos(const struct index_state *, const char *name, int name
 #define ADD_CACHE_JUST_APPEND 8		/* Append only; tree.c::read_tree() */
 #define ADD_CACHE_NEW_ONLY 16		/* Do not replace existing ones */
 extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
-extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
 extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
 extern int remove_index_entry_at(struct index_state *, int pos);
 extern void remove_marked_cache_entries(struct index_state *istate);
@@ -615,7 +614,6 @@ static inline void hashclr(unsigned char *hash)
 {
 	memset(hash, 0, 20);
 }
-extern int is_empty_blob_sha1(const unsigned char *sha1);
 
 #define EMPTY_TREE_SHA1_HEX \
 	"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
diff --git a/read-cache.c b/read-cache.c
index 9033dd3..9f4f44c 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -15,6 +15,8 @@
 #include "revision.h"
 #include "blob.h"
 
+static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
+
 /* Index extensions.
  *
  * The first letter should be 'A'..'Z' for extensions that are not
@@ -156,7 +158,7 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
 	return 0;
 }
 
-int is_empty_blob_sha1(const unsigned char *sha1)
+static int is_empty_blob_sha1(const unsigned char *sha1)
 {
 	static const unsigned char empty_blob_sha1[20] = {
 		0xe6,0x9d,0xe2,0x9b,0xb2,0xd1,0xd6,0x43,0x4b,0x8b,
@@ -1141,7 +1143,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
 	return has_errors;
 }
 
-struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
+static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
 {
 	return refresh_cache_ent(&the_index, ce, really, NULL);
 }
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 09/18] remote-curl.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 remote-curl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to remote-curl.c +1 −1
diff --git a/remote-curl.c b/remote-curl.c
index 28b2a31..b76dcb2 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -317,7 +317,7 @@ static size_t rpc_out(void *ptr, size_t eltsize,
 }
 
 #ifndef NO_CURL_IOCTL
-curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
+static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
 {
 	struct rpc_state *rpc = clientp;
 
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 10/18] quote.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 quote.c |    2 +-
 quote.h |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)
Show changes to 2 files +1 −2

quote.c, quote.h

diff --git a/quote.c b/quote.c
index 848d174..acb6bf9 100644
--- a/quote.c
+++ b/quote.c
@@ -72,7 +72,7 @@ void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
 	}
 }
 
-char *sq_dequote_step(char *arg, char **next)
+static char *sq_dequote_step(char *arg, char **next)
 {
 	char *dst = arg;
 	char *src = arg;
diff --git a/quote.h b/quote.h
index 66730f2..f83eb23 100644
--- a/quote.h
+++ b/quote.h
@@ -45,7 +45,6 @@ extern char *sq_dequote(char *);
  * next argument that should be passed as first parameter. When there
  * is no more argument to be dequoted, "next" is updated to point to NULL.
  */
-extern char *sq_dequote_step(char *arg, char **next);
 extern int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc);
 
 extern int unquote_c_style(struct strbuf *, const char *quoted, const char **endp);
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 11/18] submodule.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 submodule.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to submodule.c +1 −1
diff --git a/submodule.c b/submodule.c
index 86aad65..3007f7d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -5,7 +5,7 @@
 #include "commit.h"
 #include "revision.h"
 
-int add_submodule_odb(const char *path)
+static int add_submodule_odb(const char *path)
 {
 	struct strbuf objects_directory = STRBUF_INIT;
 	struct alternate_object_database *alt_odb;
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 12/18] utf8.c: mark file-local function static

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 utf8.c |    2 +-
 utf8.h |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)
Show changes to 2 files +1 −2

utf8.c, utf8.h

diff --git a/utf8.c b/utf8.c
index 7ddff23..ab326ac 100644
--- a/utf8.c
+++ b/utf8.c
@@ -163,7 +163,7 @@ static int git_wcwidth(ucs_char_t ch)
  * If the string was not a valid UTF-8, *start pointer is set to NULL
  * and the return value is undefined.
  */
-ucs_char_t pick_one_utf8_char(const char **start, size_t *remainder_p)
+static ucs_char_t pick_one_utf8_char(const char **start, size_t *remainder_p)
 {
 	unsigned char *s = (unsigned char *)*start;
 	ucs_char_t ch;
diff --git a/utf8.h b/utf8.h
index ae30ae4..c9738d8 100644
--- a/utf8.h
+++ b/utf8.h
@@ -3,7 +3,6 @@
 
 typedef unsigned int ucs_char_t;  /* assuming 32bit int */
 
-ucs_char_t pick_one_utf8_char(const char **start, size_t *remainder_p);
 int utf8_width(const char **start, size_t *remainder_p);
 int utf8_strwidth(const char *string);
 int is_utf8(const char *text);
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 13/18] mailmap.c: remove unused function

map_email() is not used anywhere since d20d654 (Change current mailmap usage to do matching on both name and email of author/committer., 2009-02-08).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 mailmap.c |    5 -----
 mailmap.h |    1 -
 2 files changed, 0 insertions(+), 6 deletions(-)
Show changes to 2 files +0 −6

mailmap.c, mailmap.h

diff --git a/mailmap.c b/mailmap.c
index f167c00..b68c1fe 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -243,8 +243,3 @@ int map_user(struct string_list *map,
 	debug_mm("map_user:  --\n");
 	return 0;
 }
-
-int map_email(struct string_list *map, const char *email, char *name, int maxlen)
-{
-	return map_user(map, (char *)email, 0, name, maxlen);
-}
diff --git a/mailmap.h b/mailmap.h
index 4b2ca3a..d5c3664 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -4,7 +4,6 @@
 int read_mailmap(struct string_list *map, char **repo_abbrev);
 void clear_mailmap(struct string_list *map);
 
-int map_email(struct string_list *mailmap, const char *email, char *name, int maxlen);
 int map_user(struct string_list *mailmap,
 	     char *email, int maxlen_email, char *name, int maxlen_name);
 
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 14/18] sha1_file.c: remove unused function

has_pack_file() is not used anywhere.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 cache.h     |    1 -
 sha1_file.c |    8 --------
 2 files changed, 0 insertions(+), 9 deletions(-)
Show changes to 2 files +0 −9

cache.h, sha1_file.c

diff --git a/cache.h b/cache.h
index e7bb6b7..90edb5b 100644
--- a/cache.h
+++ b/cache.h
@@ -683,7 +683,6 @@ extern int has_sha1_pack(const unsigned char *sha1);
 extern int has_sha1_file(const unsigned char *sha1);
 extern int has_loose_object_nonlocal(const unsigned char *sha1);
 
-extern int has_pack_file(const unsigned char *sha1);
 extern int has_pack_index(const unsigned char *sha1);
 
 extern const signed char hexval_table[256];
diff --git a/sha1_file.c b/sha1_file.c
index 63981fb..7086760 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2458,14 +2458,6 @@ int has_pack_index(const unsigned char *sha1)
 	return 1;
 }
 
-int has_pack_file(const unsigned char *sha1)
-{
-	struct stat st;
-	if (stat(sha1_pack_name(sha1), &st))
-		return 0;
-	return 1;
-}
-
 int has_sha1_pack(const unsigned char *sha1)
 {
 	struct pack_entry e;
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 15/18] strbuf.c: remove unused function

strbuf_tolower() is not used anywhere.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 strbuf.c |    7 -------
 strbuf.h |    1 -
 2 files changed, 0 insertions(+), 8 deletions(-)
Show changes to 2 files +0 −8

strbuf.c, strbuf.h

diff --git a/strbuf.c b/strbuf.c
index a6153dc..3fa81b3 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -91,13 +91,6 @@ void strbuf_ltrim(struct strbuf *sb)
 	sb->buf[sb->len] = '\0';
 }
 
-void strbuf_tolower(struct strbuf *sb)
-{
-	int i;
-	for (i = 0; i < sb->len; i++)
-		sb->buf[i] = tolower(sb->buf[i]);
-}
-
 struct strbuf **strbuf_split(const struct strbuf *sb, int delim)
 {
 	int alloc = 2, pos = 0;
diff --git a/strbuf.h b/strbuf.h
index fa07ecf..b37f06a 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -81,7 +81,6 @@ extern void strbuf_trim(struct strbuf *);
 extern void strbuf_rtrim(struct strbuf *);
 extern void strbuf_ltrim(struct strbuf *);
 extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
-extern void strbuf_tolower(struct strbuf *);
 
 extern struct strbuf **strbuf_split(const struct strbuf *, int delim);
 extern void strbuf_list_free(struct strbuf **);
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:52 UTC · re: Junio C Hamano · lore

[PATCH 16/18] blob.c: remove unused function

parse_blob() is not used anywhere since a510bfa (Mark blobs as parsed when they're actually parsed, 2005-04-28).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 blob.c |   21 ---------------------
 blob.h |    2 --
 2 files changed, 0 insertions(+), 23 deletions(-)
Show changes to 2 files +0 −23

blob.c, blob.h

diff --git a/blob.c b/blob.c
index bd7d078..ae320bd 100644
--- a/blob.c
+++ b/blob.c
@@ -23,24 +23,3 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
 	item->object.parsed = 1;
 	return 0;
 }
-
-int parse_blob(struct blob *item)
-{
-        enum object_type type;
-        void *buffer;
-        unsigned long size;
-	int ret;
-
-        if (item->object.parsed)
-                return 0;
-        buffer = read_sha1_file(item->object.sha1, &type, &size);
-        if (!buffer)
-                return error("Could not read %s",
-                             sha1_to_hex(item->object.sha1));
-        if (type != OBJ_BLOB)
-                return error("Object %s not a blob",
-                             sha1_to_hex(item->object.sha1));
-	ret = parse_blob_buffer(item, buffer, size);
-	free(buffer);
-	return ret;
-}
diff --git a/blob.h b/blob.h
index ea5d9e9..1f66b9d 100644
--- a/blob.h
+++ b/blob.h
@@ -13,6 +13,4 @@ struct blob *lookup_blob(const unsigned char *sha1);
 
 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
 
-int parse_blob(struct blob *item);
-
 #endif /* BLOB_H */
-- 
1.6.6.280.ge295b7.dirty
Daniel Barkalow· Jan 12, 2010, 17:37 UTC · re: Junio C Hamano · lore

Re: [PATCH 16/18] blob.c: remove unused function

On Mon, 11 Jan 2010, Junio C Hamano wrote:
> parse_blob() is not used anywhere since a510bfa (Mark blobs as parsed when
> they're actually parsed, 2005-04-28).

Perhaps it should be replaced with a comment that blobs are never parsed, because they don't need to be? We don't need the actual function, but I think it's worth having a note where the function would be.

	-Daniel
*This .sig left intentionally blank*
Junio C Hamano· Jan 13, 2010, 06:56 UTC · re: Daniel Barkalow · lore

Re: [PATCH 16/18] blob.c: remove unused function

Daniel Barkalow <barkalow@iabervon.org> writes:
Show 8 quoted lines
> On Mon, 11 Jan 2010, Junio C Hamano wrote:
>
>> parse_blob() is not used anywhere since a510bfa (Mark blobs as parsed when
>> they're actually parsed, 2005-04-28).
>
> Perhaps it should be replaced with a comment that blobs are never parsed, 
> because they don't need to be? We don't need the actual function, but I 
> think it's worth having a note where the function would be.
I tend to agree.

Care to come up with a patch, with a real description of the reason _why_ they don't need to be parsed, please?

Junio C Hamano· Jan 12, 2010, 07:53 UTC · re: Junio C Hamano · lore

[PATCH 17/18] object.c: remove unused functions

object_list_append() and object_list_length}() are not used anywhere.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 object.c |   21 ---------------------
 object.h |    5 -----
 2 files changed, 0 insertions(+), 26 deletions(-)
Show changes to 2 files +0 −26

object.c, object.h

diff --git a/object.c b/object.c
index fe8eaaf..3ca92c4 100644
--- a/object.c
+++ b/object.c
@@ -217,27 +217,6 @@ struct object_list *object_list_insert(struct object *item,
         return new_list;
 }
 
-void object_list_append(struct object *item,
-			struct object_list **list_p)
-{
-	while (*list_p) {
-		list_p = &((*list_p)->next);
-	}
-	*list_p = xmalloc(sizeof(struct object_list));
-	(*list_p)->next = NULL;
-	(*list_p)->item = item;
-}
-
-unsigned object_list_length(struct object_list *list)
-{
-	unsigned ret = 0;
-	while (list) {
-		list = list->next;
-		ret++;
-	}
-	return ret;
-}
-
 int object_list_contains(struct object_list *list, struct object *obj)
 {
 	while (list) {
diff --git a/object.h b/object.h
index 89dd0c4..82877c8 100644
--- a/object.h
+++ b/object.h
@@ -72,11 +72,6 @@ struct object *lookup_unknown_object(const unsigned  char *sha1);
 struct object_list *object_list_insert(struct object *item,
 				       struct object_list **list_p);
 
-void object_list_append(struct object *item,
-			struct object_list **list_p);
-
-unsigned object_list_length(struct object_list *list);
-
 int object_list_contains(struct object_list *list, struct object *obj);
 
 /* Object array handling .. */
-- 
1.6.6.280.ge295b7.dirty
Junio C Hamano· Jan 12, 2010, 07:53 UTC · re: Junio C Hamano · lore

[PATCH 18/18] symlinks.c: remove unused functions

invalidate_lstat_cache() and clear_lstat_cache() are not used anywhere.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 cache.h    |    2 --
 symlinks.c |   31 -------------------------------
 2 files changed, 0 insertions(+), 33 deletions(-)
Show changes to 2 files +0 −33

cache.h, symlinks.c

diff --git a/cache.h b/cache.h
index 90edb5b..b4b2ba7 100644
--- a/cache.h
+++ b/cache.h
@@ -782,8 +782,6 @@ extern int has_symlink_leading_path(const char *name, int len);
 extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
 extern int has_symlink_or_noent_leading_path(const char *name, int len);
 extern int has_dirs_only_path(const char *name, int len, int prefix_len);
-extern void invalidate_lstat_cache(const char *name, int len);
-extern void clear_lstat_cache(void);
 extern void schedule_dir_for_removal(const char *name, int len);
 extern void remove_scheduled_dirs(void);
 
diff --git a/symlinks.c b/symlinks.c
index 7b0a86d..8860120 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -179,37 +179,6 @@ static int lstat_cache(struct cache_def *cache, const char *name, int len,
 	return ret_flags;
 }
 
-/*
- * Invalidate the given 'name' from the cache, if 'name' matches
- * completely with the cache.
- */
-void invalidate_lstat_cache(const char *name, int len)
-{
-	int match_len, previous_slash;
-	struct cache_def *cache = &default_cache;	/* FIXME */
-
-	match_len = longest_path_match(name, len, cache->path, cache->len,
-				       &previous_slash);
-	if (len == match_len) {
-		if ((cache->track_flags & FL_DIR) && previous_slash > 0) {
-			cache->path[previous_slash] = '\0';
-			cache->len = previous_slash;
-			cache->flags = FL_DIR;
-		} else {
-			reset_lstat_cache(cache);
-		}
-	}
-}
-
-/*
- * Completely clear the contents of the cache
- */
-void clear_lstat_cache(void)
-{
-	struct cache_def *cache = &default_cache;	/* FIXME */
-	reset_lstat_cache(cache);
-}
-
 #define USE_ONLY_LSTAT  0
 
 /*
-- 
1.6.6.280.ge295b7.dirty

← back to recent threads