`git gc` broken?

6,222 views
Skip to first unread message

Nico Weber

unread,
Dec 12, 2015, 1:04:42 PM12/12/15
to Chromium-dev
Hi,

I noticed git printing

  Auto packing the repository in background for optimum performance.
  See "git help gc" for manual housekeeping.

a lot, so I figured I'd run that manually. I'm getting:

  $ git gc
  fatal: bad object refs/remotes/origin/HEAD
  error: failed to run repack

Does anyone else see this error? Is this something I can fix locally (how?), or is some object on the server bad?

Thanks,
Nico

Alexey Efimov

unread,
Dec 13, 2015, 7:22:18 AM12/13/15
to Chromium-dev
Hello,

Which version of git and OS?
Also will be nice to show `git show-ref refs/remotes/origin/HEAD` output

Trent Apted

unread,
Dec 14, 2015, 12:39:24 AM12/14/15
to aefim...@gmail.com, Chromium-dev
I once had something like the first bit (git gc happening a lot) -- in my case git gc was crashing. Managed to fix it (overnight) by setting pack.threads=1 in the config and doing a `git gc --aggressive`.

Haven't seen the `bad object` thing after a gc though. It seems similar to the error you get after removing the `origin` remote and replacing it with a new URL. Then (assuming you're on [local] master) you need to `git fetch origin && git branch --set-upstream-to=origin/master`.

There's also `git fsck` which might fix "stuff".

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Primiano Tucci

unread,
Dec 14, 2015, 5:10:12 AM12/14/15
to Nico Weber, Chromium-dev
did you happen to have a .git/object/refs/remotes/origin/HEAD (or any file called HEAD under .git/objects)
If that is the case, you might have mistakenly moved some file around at some point in the past.

Otherwise, what is the output of:
git rev-parse  refs/remotes/origin/HEAD
and
git cat-file commit $sha1_from_previous_step ?

I'd expect that if the objects that refs/remotes/origin/HEAD points to was really busted, your repo would be unusable.

> or is some object on the server bad?
Nah this looks a local issue.

--

Nico Weber

unread,
Dec 14, 2015, 9:29:09 AM12/14/15
to Primiano Tucci, Chromium-dev
OS X 10.10.5
$ git --version
git version 2.3.8 (Apple Git-58)

`find .git/objects/ -name HEAD` finds nothing.

$ git rev-parse  refs/remotes/origin/HEAD
warning: ignoring dangling symref refs/remotes/origin/HEAD.
refs/remotes/origin/HEAD
warning: ignoring dangling symref refs/remotes/origin/HEAD.
fatal: ambiguous argument 'refs/remotes/origin/HEAD': unknown revision or path not in the working tree.


Alexey Efimov

unread,
Dec 14, 2015, 9:35:48 AM12/14/15
to Chromium-dev, prim...@chromium.org
Hello, also show:
git symbolic-ref refs/remotes/origin/HEAD

But i think you have wrong refs/remotes/origin/<branch> where you pointed by refs/remotes/origin/HEAD

Nico Weber

unread,
Dec 14, 2015, 9:38:53 AM12/14/15
to aefim...@gmail.com, Chromium-dev, Primiano Tucci
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/trunk

(This is a fairly old checkout that has worked well for years)

Alexey Efimov

unread,
Dec 14, 2015, 9:41:07 AM12/14/15
to Chromium-dev, aefim...@gmail.com, prim...@chromium.org
trunk? Svn branch?

So i guess you might simple replace HEAD to master for example:
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
git fetch --prune

And then maybe your `git gc` starts working.
Reply all
Reply to author
Forward
0 new messages