git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH 2/4] pack-objects: do not get distracted by stale refs
Date: Thu, 24 Sep 2015 13:03:21 -0400	[thread overview]
Message-ID: <20150924170320.GA14695@sigill.intra.peff.net> (raw)
In-Reply-To: <a3a883ce9d7a8bf4220beb640caca5bed0f7d492.1443085919.git.johannes.schindelin@gmx.de>

On Thu, Sep 24, 2015 at 11:13:44AM +0200, Johannes Schindelin wrote:

> It is quite possible for, say, a remote HEAD to become stale, e.g. when
> the default branch was renamed.
> 
> We should still be able to pack our objects when such a thing happens;
> simply ignore invalid refs (because they cannot matter for the packing
> process anyway).
> [...]
>  	init_revisions(&revs, NULL);
> +	revs.ignore_missing = 1;

I think this is dangerous, because a repack may drop unreferenced
history. Imagine you have a corrupted repository where you are missing
the commit at the tip of "master", but still have "master^" and the rest
of the history, and "git gc --auto" triggers.

Right now, pack-objects will barf and refuse to pack. Your repo is still
corrupted, but you can use git-fsck to recover the history minus the
single commit. With your patch, the repack will delete the entire
history. Of course there are complications like other branches
referencing the history, reflogs if it is a non-bare repo, and the
2-week expiration time. But there's definitely a potential to make
things worse. I think commands that drop objects (like repack and prune)
need to be more careful than other commands about refusing to run when
there is something fishy in the repository.

I think we would want to introduce a flag to ignore dangling
symbolic refs when running for_each_ref, as those should be harmless. In
fact, I think we could omit symrefs completely for reachability
analysis; we would hit the ref they refer to anyway during the rest of
the traversal.

-Peff

  reply	other threads:[~2015-09-24 17:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24  9:13 [PATCH 0/4] Fix gc failure when a remote HEAD goes stale Johannes Schindelin
2015-09-24  9:13 ` [PATCH 1/4] gc: demonstrate failure with stale remote HEAD Johannes Schindelin
2015-09-24  9:13 ` [PATCH 2/4] pack-objects: do not get distracted by stale refs Johannes Schindelin
2015-09-24 17:03   ` Jeff King [this message]
2015-09-24  9:13 ` [PATCH 3/4] mark_reachable_objects(): optionally collect broken refs Johannes Schindelin
2015-09-24 17:56   ` Jeff King
2015-09-24  9:14 ` [PATCH 4/4] gc: remove " Johannes Schindelin
2015-09-24 17:57   ` Jeff King
2015-09-25  0:08     ` Junio C Hamano
2015-09-25  1:35       ` Jeff King
2015-09-28 14:01       ` [PATCH v2 0/4] Fix gc failure when a remote HEAD goes stale Johannes Schindelin
2015-09-28 14:01         ` [PATCH v2 1/4] gc: demonstrate failure with stale remote HEAD Johannes Schindelin
2015-09-28 14:01         ` [PATCH v2 2/4] pack-objects: do not get distracted by broken symrefs Johannes Schindelin
2015-09-28 14:01         ` [PATCH v2 3/4] mark_reachable_objects(): optionally collect " Johannes Schindelin
2015-09-28 14:02         ` [PATCH v2 4/4] gc: remove " Johannes Schindelin
2015-09-28 18:41           ` Junio C Hamano
2015-09-28 18:49             ` Junio C Hamano
2015-09-28 19:58               ` Johannes Schindelin
2015-10-05 22:06                 ` Junio C Hamano
2015-09-28 19:03           ` Jeff King
2015-09-28 20:05             ` Johannes Schindelin
2015-10-06 13:57       ` [PATCH v3 0/2] Fix gc failure when a remote HEAD goes stale Johannes Schindelin
2015-10-06 13:58         ` [PATCH v3 1/2] gc: demonstrate failure with stale remote HEAD Johannes Schindelin
2015-10-06 13:59         ` [PATCH v3 2/2] pack-objects: do not get distracted by broken symrefs Johannes Schindelin
2015-10-07 17:45           ` Junio C Hamano
2015-10-08 19:15             ` Johannes Schindelin
2015-10-08 19:42               ` Junio C Hamano
2015-10-08 20:10                 ` Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20150924170320.GA14695@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).