In a1bbc6c0 a shell command "mv -f" was replaced with the rename() function.

Use move_temp_to_file() from sha1_file.c instead of rename().
This is in line with the handling of other Git internal tmp files,
and calls adjust_shared_perm()

Signed-off-by: Torsten Bögershausen <>
Thanks for all comments.
I haven't been able to reproduce the problem here.
Tips and information how to reproduce it are wellcome.

I think this patch makes sense to support core.sharedRepository(),
but I haven't made a test case for the pack/idx files.

Jochen, doess this patch fix your problem, or do we need
another patch on top of this?

 builtin/repack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/repack.c b/builtin/repack.c
index ba66c6e..4b6d663 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -271,7 +271,7 @@ int cmd_repack(int argc, const char **argv, const char 
                                if (unlink(fname_old))
                                        failed = 1;
-                       if (!failed && rename(fname, fname_old)) {
+                       if (!failed && move_temp_to_file(fname, fname_old)) {
                                failed = 1;
@@ -288,7 +288,7 @@ int cmd_repack(int argc, const char **argv, const char 
                        char *fname, *fname_old;
                        fname = mkpathdup("%s/%s", packdir, item->string);
                        fname_old = mkpath("%s/old-%s", packdir, item->string);
-                       if (rename(fname_old, fname))
+                       if (move_temp_to_file(fname_old, fname))
                                string_list_append(&rollback_failure, fname);
@@ -324,7 +324,7 @@ int cmd_repack(int argc, const char **argv, const char 
                                statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | 
                                chmod(fname_old, statbuffer.st_mode);
-                       if (rename(fname_old, fname))
+                       if (move_temp_to_file(fname_old, fname))
                                die_errno(_("renaming '%s' failed"), fname_old);

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to