git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Andrew Hlynskyi <ahlincq@gmail.com>, git@vger.kernel.org
Subject: Re: [BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command
Date: Fri, 06 Jan 2023 21:40:22 +0900	[thread overview]
Message-ID: <xmqqilhjsuo9.fsf@gitster.g> (raw)
In-Reply-To: <Y7fikyZV1ky2modr@coredump.intra.peff.net> (Jeff King's message of "Fri, 6 Jan 2023 03:57:55 -0500")

Jeff King <peff@peff.net> writes:

> On Thu, Jan 05, 2023 at 06:59:36PM +0200, Andrew Hlynskyi wrote:
>
>> > Can you share the .git directory of a repository that exhibits this
>> > behavior? It's possible there's a bug or something in the packed-refs
>> > code, though I find it pretty unlikely, as it's fairly well exercised in
>> > normal use.
>> 
>> The above excerpts completely describe the issue and there is no more
>> special in the repo.
>
> Thanks for digging. Your explanation makes sense.
> ...
> I don't think we have any fsck checks that the packed-refs file is in
> sorted order. It might be reasonable to have them. Likewise, when
> pack-refs rewrites the file, it should be able to cheaply double-check
> that the input is sorted by comparing each entry against its previous.

True.  I would not mind a patch to make us do so in the code path
where we rewrite the file and add "sorted" trait to the file.
refs/packed-backend.c::sort_snapshot() seems to be already equipped
to do this?

>> I understand that the `.git/packed-refs` file is for machines and not
>> for humans but sometimes
>> it's the fastest way to make several simple corrections in it manually.
>
> Yes, I have certainly done this myself. There are is a header line at
> the top of the file, though, which tells what is guaranteed:
>
>   $ head -1 .git/packed-refs
>   # pack-refs with: peeled fully-peeled sorted
>
> if you are going to muck with the file, deleting that line should be
> sufficient; the reading code will fall back to the older routines which
> don't assume it's sorted.

Thanks, both.

So we can conclude that this discussion thread has an
incorrect Subject: and the symptom was caused by human error?


  reply	other threads:[~2023-01-06 12:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03  3:22 [BUG] `git gc` or `git pack-refs` wipes all notes for `git notes` command Andrew Hlynskyi
2023-01-03  9:04 ` Jeff King
2023-01-05 16:59   ` Andrew Hlynskyi
2023-01-06  8:57     ` Jeff King
2023-01-06 12:40       ` Junio C Hamano [this message]
2023-01-06 13:04         ` Jeff King

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=xmqqilhjsuo9.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=ahlincq@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).