Re: My git repo is broken, how to fix it ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Mon, 19 Mar 2007, Alexander Litvinov wrote:
> 
> It is pity but my repo was corrupted again. I have WinXP + cygwin + 
> git-1.5.0-572-ge86d552. I was doing 
> git-apply/git-am/git-reset/git-cvsexportcommit and broke repo somehow. I have 
> two broken blobs that should be done by my recent patches.

Ok, can you send me just the two broken blobs? I assume that they are 
loose objects, so when fsck complaines about a corrupt object xyzzy..., 
just take those objects from

	.git/objects/xy/zzy..

and tar the two broken ones up, and send it to me by email. I'll keep it 
private if need be, but if you don't care about that, it would be even 
better if you can send them to the list publicly so that others can see 
what the corruption looks like.

> Is there any way to catch and solve the problem ?

I'd like to see the objects to look at what the corruption looks like, but 
I suspect that it's cygwin and/or WinXP. I'm not at all convinced that 
Windows is all that safe in general when it comes to data consistency, and 
I suspect cygwin makes it much worse by making operations that *should* be 
atomic be non-atomic.

Here's a patch that is probably a good idea to try. It disables the 
hardlinking code for CYGWIN, and it also checks for errors from "close()". 
Those are the two most obvious issues that I could imagine causing 
problems..

		Linus
---
 sha1_file.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 372af60..d829dc7 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1760,6 +1760,14 @@ static void write_sha1_file_prepare(void *buf, unsigned long len,
 	SHA1_Final(sha1, &c);
 }
 
+#ifdef __CYGWIN__
+static int link(const char *old, const char *new)
+{
+	errno = ENOSYS;
+	return -1;
+}
+#endif
+
 /*
  * Link the tempfile to the final place, possibly creating the
  * last directory level as you do so.
@@ -1951,7 +1959,8 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
 	if (write_buffer(fd, compressed, size) < 0)
 		die("unable to write sha1 file");
 	fchmod(fd, 0444);
-	close(fd);
+	if (close(fd))
+		die("error closing sha1 file (%s)", strerror(errno));
 	free(compressed);
 
 	return move_temp_to_file(tmpfile, filename);
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]