git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: git@vger.kernel.org
Cc: tboegi@web.de, zwanzig12@googlemail.com,
	stefanbeller@googlemail.com, kusmabite@gmail.com,
	Johannes.Schindelin@gmx.de, msysgit@googlegroups.com
Subject: [PATCH v2] repack.c: Use move_temp_to_file() instead of rename()
Date: Mon, 27 Jan 2014 21:24:42 +0100	[thread overview]
Message-ID: <201401272124.42978.tboegi@web.de> (raw)

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 <tboegi@web.de>
---
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 *prefix)
 				if (unlink(fname_old))
 					failed = 1;
 
-			if (!failed && rename(fname, fname_old)) {
+			if (!failed && move_temp_to_file(fname, fname_old)) {
 				free(fname);
 				failed = 1;
 				break;
@@ -288,7 +288,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 			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);
 			free(fname);
 		}
@@ -324,7 +324,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 				statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
 				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);
 			free(fname);
 			free(fname_old);
-- 
1.8.5.2

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

             reply	other threads:[~2014-01-27 20:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-27 20:24 Torsten Bögershausen [this message]
2014-01-29 18:17 ` [PATCH v2] repack.c: Use move_temp_to_file() instead of rename() Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201401272124.42978.tboegi@web.de \
    --to=tboegi@web.de \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.com \
    --cc=msysgit@googlegroups.com \
    --cc=stefanbeller@googlemail.com \
    --cc=zwanzig12@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).