git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
Cc: git@vger.kernel.org
Subject: Re: Antw: [EXT] Re: bug in "git fsck"?
Date: Thu, 8 Jul 2021 18:36:37 +0200	[thread overview]
Message-ID: <f460e7e0-113e-f19f-fbaa-a22f567105dd@web.de> (raw)
In-Reply-To: <60E6B541020000A1000423C8@gwsmtp.uni-regensburg.de>

Am 08.07.21 um 10:20 schrieb Ulrich Windl:
>>>> René Scharfe <l.s.r@web.de> schrieb am 06.07.2021 um 16:25 in Nachricht
> <fcfd0401-df5b-15ec-29c4-74d2903274cd@web.de>:
>> Am 06.07.21 um 09:12 schrieb Ulrich Windl:
>>>>>> René Scharfe <l.s.r@web.de> schrieb am 05.07.2021 um 16:44 in Nachricht
>>> <77655a4e-8c39-5ccc-71af-d2d8684bf208@web.de>:
>>>> Am 05.07.21 um 09:42 schrieb Ulrich Windl:
>>>>>> You *can* overwrite them using "git branch --force foo" and then
>>>>>> "git branch -d foo" works.
>>>>>
>>>>> Would it be OK to force the branch to any commit (e.g.: "master"),
> relying
>>>
>>>> on
>>>>> the fact that any reference (read: "master") to that commit will prevent
>>>> actual
>>>>> removal of the commit?
>>>>
>>>> Yes, any valid commit would do.  This turns dangling branches into
>>>> normal delete-able ones.  Other branches are unaffected.
>>>
>>> OK, but either it does not work, or I did not understand what to do:
>>>
>>>> git branch --force bitmap-generic
>>> fatal: Not a valid object name: 'bitmap-generic'.
>>>> git fsck
>>> Checking object directories: 100% (256/256), done.
>>> Checking objects: 100% (173/173), done.
>>> notice: HEAD points to an unborn branch (bitmap-generic)
>>> dangling blob 0458be7cf03f35be365c819afe0104ff3c178ca0
>>> dangling blob 3000d29f0a652f3f7ed25572cac9969b90adeca5
>>> dangling commit 90e8531086d3efaeefdf6c8d39b6782e49dd2a0d
>>> dangling commit b598195f859106662bde746f391a7df9162231e9
>>> dangling tree fb4866ab5cc2f0c34a63334b90550ef7199a2098
>>> ...
>>
>> First: Please make backups.
>>
>> Here's what works for me.  First reproducing the error:
>>
>>    $ echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >.git/refs/heads/broken
>
> Hi!
>
> Thanks for the hints. But first the problem is in the repository, not in the
> workspace, so I don't have a ".git/refs/", but "refs/".

So you have a bare repository (one without worktree, i.e. no checked out
files)?

> The other thing is that the only "refs" that is there is "master"; the one
> with the problem isn't there.

You probably had your refs packed (in a file named "packed-refs").

> So I tried:
> % echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >refs/heads/bitmap-generic

I used that command to generate a broken branch.  You already had a
broken branch, so you didn't need to repeat that reproduction step.

> Then "git branch" indicated that "bitmap-generic" would be the current
> branch:
> % cat HEAD
> ref: refs/heads/bitmap-generic

HEAD references the current branch.  So the broken branch was the
current one for you?  I somehow assumed that you'd be on a healthy
branch.  And I'm not fully sure how to use branches in a bare
repository.

> Next I brute-force edited HEAD, repacing bitmap-generic with master.

OK, but at least this moved you to a healthy branch.

> Still, that would not work:
> % git branch --delete --force bitmap-generic
> error: Couldn't look up commit object for 'refs/heads/bitmap-generic'

Expected; you hadn't done anything to that branch, yet.

> But the next command worked:
> % git branch --force bitmap-generic

This made the broken branch point to the same commit as the current
branch, i.e. master.

> Finally, this also worked:
> % git branch --delete bitmap-generic
> Deleted branch bitmap-generic (was 03aa7ca).

Right; the previous command had unbroken the branch, so it had
become deletable.

> Most importantly "git fsck" did no longer complain.
>
> Thanks for the help! Do you want to provide an answer to stackexchange, or may
> I use your procedure to write an answer?

Feel free to use it.  I don't even have an account there.

René

  reply	other threads:[~2021-07-08 16:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02 14:01 bug in "git fsck"? Ulrich Windl
2021-07-02 18:15 ` Junio C Hamano
2021-07-03 20:03   ` René Scharfe
2021-07-05  7:42     ` Antw: [EXT] " Ulrich Windl
2021-07-05 14:44       ` René Scharfe
2021-07-06  7:12         ` Ulrich Windl
2021-07-06 14:25           ` René Scharfe
2021-07-08  8:20             ` Ulrich Windl
2021-07-08 16:36               ` René Scharfe [this message]
2021-07-05 19:52     ` Junio C Hamano
2021-07-05  7:10   ` Antw: [EXT] " Ulrich Windl
2021-07-05  7:26     ` Ævar Arnfjörð Bjarmason
2021-07-05  7:20   ` Ulrich Windl

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=f460e7e0-113e-f19f-fbaa-a22f567105dd@web.de \
    --to=l.s.r@web.de \
    --cc=Ulrich.Windl@rz.uni-regensburg.de \
    --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.
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).