diff mbox series

[v2,3/3] builtin/index-pack.c: move `.idx` files into place last

Message ID 460b7b915157503df2ebef61f6863ed259586385.1631139433.git.me@ttaylorr.com (mailing list archive)
State New, archived
Headers show
Series prevent opening packs too early | expand

Commit Message

Taylor Blau Sept. 8, 2021, 10:17 p.m. UTC
In a similar spirit as the previous patch, fix the identical problem
in `git index-pack`.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/index-pack.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 8336466865..6ca47c5c03 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1517,14 +1517,6 @@  static void final(const char *final_pack_name, const char *curr_pack_name,
 	} else if (from_stdin)
 		chmod(final_pack_name, 0444);
 
-	if (final_index_name != curr_index_name) {
-		if (!final_index_name)
-			final_index_name = odb_pack_name(&index_name, hash, "idx");
-		if (finalize_object_file(curr_index_name, final_index_name))
-			die(_("cannot store index file"));
-	} else
-		chmod(final_index_name, 0444);
-
 	if (curr_rev_index_name) {
 		if (final_rev_index_name != curr_rev_index_name) {
 			if (!final_rev_index_name)
@@ -1535,6 +1527,14 @@  static void final(const char *final_pack_name, const char *curr_pack_name,
 			chmod(final_rev_index_name, 0444);
 	}
 
+	if (final_index_name != curr_index_name) {
+		if (!final_index_name)
+			final_index_name = odb_pack_name(&index_name, hash, "idx");
+		if (finalize_object_file(curr_index_name, final_index_name))
+			die(_("cannot store index file"));
+	} else
+		chmod(final_index_name, 0444);
+
 	if (do_fsck_object) {
 		struct packed_git *p;
 		p = add_packed_git(final_index_name, strlen(final_index_name), 0);