git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ephrim Khong <dr.khong@gmail.com>
To: GIT Mailing-list <git@vger.kernel.org>
Subject: [Bug] data loss with cyclic alternates
Date: Fri, 11 Jul 2014 11:37:25 +0200	[thread overview]
Message-ID: <53BFB055.206@gmail.com> (raw)

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

             reply	other threads:[~2014-07-11  9:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-11  9:37 Ephrim Khong [this message]
2014-07-11 16:01 ` [Bug] data loss with cyclic alternates 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

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=53BFB055.206@gmail.com \
    --to=dr.khong@gmail.com \
    --cc=git@vger.kernel.org \
    /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).