# [PATCH] cache.h: drop duplicate `ensure_full_index()` declaration

4 messages from 2022-01-10 to 2022-01-10. Participants: Martin Ågren, Victoria Dye, Junio C Hamano.
Thread: https://gitlist.dev/t/57218

## Martin Ågren, 2022-01-10 18:41

Subject: [PATCH] cache.h: drop duplicate `ensure_full_index()` declaration
Message-ID: <20220110184134.18675-1-martin.agren@gmail.com>
URL: https://gitlist.dev/e/20220110184134.18675-1-martin.agren%40gmail.com

```
There are two identical declarations of `ensure_full_index()` in
cache.h.

Commit 3964fc2aae ("sparse-index: add guard to ensure full index",
2021-03-30) provided an empty implementation of `ensure_full_index()`,
declaring it in a new file sparse-index.h. When commit 4300f8442a
("sparse-index: implement ensure_full_index()", 2021-03-30) fleshed out
the implementation, it added an identical declaration to cache.h.

Then 118a2e8bde ("cache: move ensure_full_index() to cache.h",
2021-04-01) favored having the declaration in cache.h. Because of the
double declaration, at that point we could have just dropped the one in
sparse-index.h, but instead it got moved to cache.h.

As a result, cache.h contains the exact same function declaration twice.
Drop the one under "/* Name hashing */", in favor of the one under
"/* Initialize and use the cache information */".

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 cache.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/cache.h b/cache.h
index 5d7463e6fb..281f00ab1b 100644
--- a/cache.h
+++ b/cache.h
@@ -350,8 +350,6 @@ void add_name_hash(struct index_state *istate, struct cache_entry *ce);
 void remove_name_hash(struct index_state *istate, struct cache_entry *ce);
 void free_name_hash(struct index_state *istate);
 
-void ensure_full_index(struct index_state *istate);
-
 /* Cache entry creation and cleanup */
 
 /*
-- 
2.34.1.703.g22d0c6ccf7


```

## Victoria Dye, 2022-01-10 18:57

Subject: Re: [PATCH] cache.h: drop duplicate `ensure_full_index()` declaration
Message-ID: <c0a0798d-96fb-936b-3234-88e500eb86d0@github.com>
URL: https://gitlist.dev/e/c0a0798d-96fb-936b-3234-88e500eb86d0%40github.com
In-Reply-To: <20220110184134.18675-1-martin.agren@gmail.com>

```
Martin Ågren wrote:
> There are two identical declarations of `ensure_full_index()` in
> cache.h.
> 
> Commit 3964fc2aae ("sparse-index: add guard to ensure full index",
> 2021-03-30) provided an empty implementation of `ensure_full_index()`,
> declaring it in a new file sparse-index.h. When commit 4300f8442a
> ("sparse-index: implement ensure_full_index()", 2021-03-30) fleshed out
> the implementation, it added an identical declaration to cache.h.
> 
> Then 118a2e8bde ("cache: move ensure_full_index() to cache.h",
> 2021-04-01) favored having the declaration in cache.h. Because of the
> double declaration, at that point we could have just dropped the one in
> sparse-index.h, but instead it got moved to cache.h.
> 
> As a result, cache.h contains the exact same function declaration twice.
> Drop the one under "/* Name hashing */", in favor of the one under
> "/* Initialize and use the cache information */".
> 
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
>  cache.h | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/cache.h b/cache.h
> index 5d7463e6fb..281f00ab1b 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -350,8 +350,6 @@ void add_name_hash(struct index_state *istate, struct cache_entry *ce);
>  void remove_name_hash(struct index_state *istate, struct cache_entry *ce);
>  void free_name_hash(struct index_state *istate);
>  
> -void ensure_full_index(struct index_state *istate);
> -
>  /* Cache entry creation and cleanup */
>  
>  /*

Thanks for cleaning up the duplicate, looks good to me!

```

## Junio C Hamano, 2022-01-10 19:30

Subject: Re: [PATCH] cache.h: drop duplicate `ensure_full_index()` declaration
Message-ID: <xmqqfspvz8us.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqfspvz8us.fsf%40gitster.g
In-Reply-To: <c0a0798d-96fb-936b-3234-88e500eb86d0@github.com>

```
Victoria Dye <vdye@github.com> writes:

> Martin Ågren wrote:
>> There are two identical declarations of `ensure_full_index()` in
>> cache.h.
>> 
>> Commit 3964fc2aae ("sparse-index: add guard to ensure full index",
>> 2021-03-30) provided an empty implementation of `ensure_full_index()`,
>> declaring it in a new file sparse-index.h. When commit 4300f8442a
>> ("sparse-index: implement ensure_full_index()", 2021-03-30) fleshed out
>> the implementation, it added an identical declaration to cache.h.
>> 
>> Then 118a2e8bde ("cache: move ensure_full_index() to cache.h",
>> 2021-04-01) favored having the declaration in cache.h. Because of the
>> double declaration, at that point we could have just dropped the one in
>> sparse-index.h, but instead it got moved to cache.h.
>> 
>> As a result, cache.h contains the exact same function declaration twice.
>> Drop the one under "/* Name hashing */", in favor of the one under
>> "/* Initialize and use the cache information */".
>> 
>> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
>> ---
>>  cache.h | 2 --
>>  1 file changed, 2 deletions(-)
>> 
>> diff --git a/cache.h b/cache.h
>> index 5d7463e6fb..281f00ab1b 100644
>> --- a/cache.h
>> +++ b/cache.h
>> @@ -350,8 +350,6 @@ void add_name_hash(struct index_state *istate, struct cache_entry *ce);
>>  void remove_name_hash(struct index_state *istate, struct cache_entry *ce);
>>  void free_name_hash(struct index_state *istate);
>>  
>> -void ensure_full_index(struct index_state *istate);
>> -
>>  /* Cache entry creation and cleanup */
>>  
>>  /*
>
> Thanks for cleaning up the duplicate, looks good to me!

Thanks, both.

```

## Junio C Hamano, 2022-01-10 19:52

Subject: A couple more duplicate declarations
Message-ID: <xmqqwnj7xtb2.fsf_-_@gitster.g>
URL: https://gitlist.dev/e/xmqqwnj7xtb2.fsf_-_%40gitster.g
In-Reply-To: <xmqqfspvz8us.fsf@gitster.g>

```
Junio C Hamano <gitster@pobox.com> writes:

>> Thanks for cleaning up the duplicate, looks good to me!
>
> Thanks, both.

This is not urgent at all, given that we are about to enter the
pre-release stabilization period and patches that might result from
this message would become lower priority, but there are a couple of
duplicate declarations, which I'll mention in order to help people
to come back to them later.

* trace2_cmd_exit_fl() was added to git-compat-util.h and to
  trace2.h by ee4512ed (trace2: create new combined trace facility,
  2019-02-22).  Logically it belongs to the latter.  Moving
  inclusion of the latter from <cache.h> to <git-compat-util.h>
  might be the lowest-cost fix, but there may be ramifications.

* xdl_emit_diff() is declared in xdiff/xdiffi.h and xdiff/xemit.h; I
  wonder if there is a caller that only includes one but not the
  other header.  As they came from the same upstream-import commit,
  I wouldn't worry too much about it.


```
