git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bug] data loss with cyclic alternates
@ 2014-07-11  9:37 Ephrim Khong
  2014-07-11 16:01 ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: Ephrim Khong @ 2014-07-11  9:37 UTC (permalink / raw)
  To: GIT Mailing-list

Hi,

git seems to have issues with alternates when cycles are present (repo A 
has B/objects as alternates, B has A/objects as alternates). In such 
cases, gc and repack might delete objects that are present in only one 
of the alternates, leading to data loss.

I understand that this is no big use case, and requires manual editing 
of objects/info/alternates. But for the sake of preventing unneccesary 
data loss, and since I found no warning regarding alternate cycles in 
the documentation, it might make sense to handle such cases properly 
(maybe it's a simple "after finding all alternates directories, remove 
duplicates"?).

Here is a small test case that adds the object storage of a repository 
as alternate to itsself. After git repack -adl, all objects are deleted.

---
rm -rf test_repo &&
mkdir test_repo &&
cd test_repo &&
git init &&
touch a &&
git add a &&
git commit -m "c1" &&
git repack -adl &&
echo $PWD/.git/objects > .git/objects/info/alternates &&
echo ">> re-packing..." &&
git repack -adl &&
echo ">> git fsck..." &&
git fsck
---

Output:

---
Initialized empty Git repository in /somewhere/test_repo/.git/
[master (root-commit) ab9e123] c1
  1 file changed, 0 insertions(+), 0 deletions(-)
  create mode 100644 a
Counting objects: 3, done.
Writing objects: 100% (3/3), done.
Total 3 (delta 0), reused 0 (delta 0)
 >> re-packing...
Nothing new to pack.
error: refs/heads/master does not point to a valid object!
 >> git fsck...
Checking object directories: 100% (256/256), done.
Checking object directories: 100% (256/256), done.
error: HEAD: invalid sha1 pointer 1494ec24356cbbbd66e19f22cef762dd83de7f54
error: refs/heads/master does not point to a valid object!
notice: No default references
missing blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
---

Thanks
- Eph

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-07-16  6:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-11  9:37 [Bug] data loss with cyclic alternates Ephrim Khong
2014-07-11 16:01 ` Junio C Hamano
2014-07-11 18:01   ` Keller, Jacob E
2014-07-12  5:57     ` Jeff King
2014-07-14 22:05       ` Keller, Jacob E
2014-07-13 10:44   ` Ephrim Khong
2014-07-14  9:02     ` [PATCH] sha1_file: do not add own object directory as alternate Ephrim Khong
2014-07-14 10:47       ` Duy Nguyen
2014-07-14 12:53         ` [PATCH v2] " Ephrim Khong
2014-07-15  5:44           ` Johannes Sixt
2014-07-15 11:29             ` [PATCH v3] " Ephrim Khong
2014-07-15 19:26               ` Junio C Hamano
2014-07-16  6:42                 ` Ephrim Khong
2014-07-15 19:33               ` Eric Sunshine
2014-07-15 19:48               ` Junio C Hamano
2014-07-16  6:47                 ` Ephrim Khong

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).