Git development
 help / color / mirror / Atom feed
* question: what does "garbage" field in "git count-objects -v" represent? Is it broken?
@ 2025-08-28 16:32 Daniele Sassoli
  2025-08-28 16:50 ` Elijah Newren
  2025-08-28 17:05 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Daniele Sassoli @ 2025-08-28 16:32 UTC (permalink / raw)
  To: git

Hi All,

When reading the output `git count-objects -v` there is a `garbage` field. At
first I thought this would highlight objects that are considered "garbage", i.e.
could be garbage collected. However, I kept noticing that this wasn't the case,
despite my repository having plenty of dangling objects (that where removed once
I run `git gc --prune=now`), garbage kept being 0.

I then turned to reading the docs, which state:
garbage: the number of files in the object database that are neither
valid loose objects nor valid packs

I don't think I've ever seen a definition of an invalid object? I tried adding
random chars to an object, effectively corrupting the repository(which `git
fsck` correctly picked up), but count-objects kept returning 0 at the garbage
field.

The only way I've been able to get count-objects to report some garbage is by
creating files in the packs directory (or in any of the sub-directories of
`objects` folder) with random names, like "test", or sometimes I've seen it
report the existence of lock files or even preserved files.

So my question is, am I fundamentally misunderstanding what garbage means, are
the docs simply unclear or is the functionality not working as expected?

Thanks for taking the time to read this and respond.
Dani

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-28 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-28 16:32 question: what does "garbage" field in "git count-objects -v" represent? Is it broken? Daniele Sassoli
2025-08-28 16:50 ` Elijah Newren
2025-08-28 17:05 ` Junio C Hamano
2025-08-28 17:09   ` Daniele Sassoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox