diff mbox series

[7/9] builtin/index-pack.c: move `.idx` files into place last

Message ID 8d67a715014b9daa9a6ca3a77be647e733324522.1631157880.git.me@ttaylorr.com (mailing list archive)
State Superseded
Headers show
Series packfile: avoid .idx rename races | expand

Commit Message

Taylor Blau Sept. 9, 2021, 3:25 a.m. UTC
In a similar spirit as preceding patches to `git repack` and `git
pack-objects`, fix the identical problem in `git index-pack`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/index-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Sept. 9, 2021, 7:52 a.m. UTC | #1
On Wed, Sep 08 2021, Taylor Blau wrote:

> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Ditto the comment on 4/9 about duplicate Signed-off-by headers, looks
good otherwise!
Junio C Hamano Sept. 9, 2021, 7:45 p.m. UTC | #2
Taylor Blau <me@ttaylorr.com> writes:

> In a similar spirit as preceding patches to `git repack` and `git
> pack-objects`, fix the identical problem in `git index-pack`.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
>  builtin/index-pack.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/index-pack.c b/builtin/index-pack.c
> index cd4e85f5bb..bf294d9083 100644
> --- a/builtin/index-pack.c
> +++ b/builtin/index-pack.c
> @@ -1523,11 +1523,11 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
>  
>  	rename_tmp_packfile(&final_pack_name, curr_pack_name, &pack_name,
>  			    hash, "pack", from_stdin);
> -	rename_tmp_packfile(&final_index_name, curr_index_name, &index_name,
> -			    hash, "idx", 1);
>  	if (curr_rev_index_name)
>  		rename_tmp_packfile(&final_rev_index_name, curr_rev_index_name,
>  				    &rev_index_name, hash, "rev", 1);
> +	rename_tmp_packfile(&final_index_name, curr_index_name, &index_name,
> +			    hash, "idx", 1);

Good.
diff mbox series

Patch

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index cd4e85f5bb..bf294d9083 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1523,11 +1523,11 @@  static void final(const char *final_pack_name, const char *curr_pack_name,
 
 	rename_tmp_packfile(&final_pack_name, curr_pack_name, &pack_name,
 			    hash, "pack", from_stdin);
-	rename_tmp_packfile(&final_index_name, curr_index_name, &index_name,
-			    hash, "idx", 1);
 	if (curr_rev_index_name)
 		rename_tmp_packfile(&final_rev_index_name, curr_rev_index_name,
 				    &rev_index_name, hash, "rev", 1);
+	rename_tmp_packfile(&final_index_name, curr_index_name, &index_name,
+			    hash, "idx", 1);
 
 	if (do_fsck_object) {
 		struct packed_git *p;