All of lore.kernel.org
 help / color / mirror / Atom feed
* git fsck: unreachable vs. dangling
@ 2015-04-14  7:16 Sebastian Schuberth
  2015-04-14  8:05 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Schuberth @ 2015-04-14  7:16 UTC (permalink / raw)
  To: Git Mailing List

Hi,

reading through the fsck docs [1] I'm having a hard time understanding
what the difference between "unreachable" and "dangling" objects are.

By example, suppose I have a commit A that is the tip of exactly one
branch (and no tag or other ref points to A). If I delete that branch,
is A now dangling, or unreachable, or both?

[1] http://git-scm.com/docs/git-fsck.html

-- 
Sebastian Schuberth

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  7:16 git fsck: unreachable vs. dangling Sebastian Schuberth
@ 2015-04-14  8:05 ` Junio C Hamano
  2015-04-14  8:50   ` Michael J Gruber
  2015-04-14  8:52   ` Sebastian Schuberth
  0 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2015-04-14  8:05 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: Git Mailing List

On Tue, Apr 14, 2015 at 12:16 AM, Sebastian Schuberth
<sschuberth@gmail.com> wrote:
> Hi,
>
> reading through the fsck docs [1] I'm having a hard time understanding
> what the difference between "unreachable" and "dangling" objects are.
>
> By example, suppose I have a commit A that is the tip of exactly one
> branch (and no tag or other ref points to A). If I delete that branch,
> is A now dangling, or unreachable, or both?

Suppose that branch consists of two commits, A and A^.
When you lose that branch (git branch -D that-branch),
both A and A^ become unreachable. So are trees and
blobs that appear only in A and A^ and nowhere else;
they are also unreachable.

A dangling object is an unreachable object that cannot be
made reachable by any way other than pointing at it
directly with a ref. A^ is not dangling, because you can
make it reachable by pointing A (the tip of the original
branch you just lost) with a ref. A on the other hand is
dangling (if you had a tag object that points at A that
you lost, then A is merely unreachable but not dangling,
because you can point at that tag with a ref and make A
reachable).

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  8:05 ` Junio C Hamano
@ 2015-04-14  8:50   ` Michael J Gruber
  2015-04-14  8:58     ` Sebastian Schuberth
  2015-04-14  8:52   ` Sebastian Schuberth
  1 sibling, 1 reply; 9+ messages in thread
From: Michael J Gruber @ 2015-04-14  8:50 UTC (permalink / raw)
  To: Junio C Hamano, Sebastian Schuberth; +Cc: Git Mailing List

Junio C Hamano venit, vidit, dixit 14.04.2015 10:05:
> On Tue, Apr 14, 2015 at 12:16 AM, Sebastian Schuberth
> <sschuberth@gmail.com> wrote:
>> Hi,
>>
>> reading through the fsck docs [1] I'm having a hard time understanding
>> what the difference between "unreachable" and "dangling" objects are.
>>
>> By example, suppose I have a commit A that is the tip of exactly one
>> branch (and no tag or other ref points to A). If I delete that branch,
>> is A now dangling, or unreachable, or both?
> 
> Suppose that branch consists of two commits, A and A^.
> When you lose that branch (git branch -D that-branch),
> both A and A^ become unreachable. So are trees and
> blobs that appear only in A and A^ and nowhere else;
> they are also unreachable.
> 
> A dangling object is an unreachable object that cannot be
> made reachable by any way other than pointing at it
> directly with a ref. A^ is not dangling, because you can
> make it reachable by pointing A (the tip of the original
> branch you just lost) with a ref. A on the other hand is
> dangling (if you had a tag object that points at A that
> you lost, then A is merely unreachable but not dangling,
> because you can point at that tag with a ref and make A
> reachable).
> 

This terminology is established, but misleading if you try to
understanding things from the word and the technical tree structure:

"to dangle" means "to hang loosely".

So, in the description above, "A^ dangles from A loosely" because it
hangs from A (you can reach it from A) but loosely, because it would
"drop" if A gets dropped and A is "likely" to be dropped (because it is
unreachable by refs). But A^ is not dangling in our terminology.

If you *reverse the arrows*, i.e. consider A^ pointing to A, it becomes
more apparent that A is dangling: it is an unreferenced leaf node.

But really, we're switching directions of the arrows again and again
when, on the one hand, we talk about refs pointing to commits, commits
pointing to parent commits (which they are, of course) but then, on the
other hand, use terms like "root" and "dangling" which make sense only
when you think of the oppositely oriented tree.

Maybe we should introduce the terms DAG and reverse DAG (GAD?) to make
this clearer. Our DAG is technically oriented from commits to their
parents all the way "up" to the root.

Visually, we often orient it from the root towards child commits.

When we do a revision walk, do we walk forward or backwards?

I'd say users think in the ordering in which they create commits (from
root to children), let's call that DAG. It explains "root" and "dangle"
and such, and a revision walk is a walk backwards in that orientation.

Technically, our acyclic graph is oriented the other way, a revision
walk walks forward in that orientation - it couldn't walk any other way
without extensive searching. This orientation (GAD?) explains "points
to", be it "ref to rev" or "commit to parent".

Michael

P.S.: The more mathematically inclined will notice that we can have more
than 2 orientations if our graph is not connected... But I'd say we have
one "technical" orientation (commit->parent) and the opposite and can
forget about others.

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  8:05 ` Junio C Hamano
  2015-04-14  8:50   ` Michael J Gruber
@ 2015-04-14  8:52   ` Sebastian Schuberth
  2015-04-14 14:20     ` Sebastian Schuberth
  1 sibling, 1 reply; 9+ messages in thread
From: Sebastian Schuberth @ 2015-04-14  8:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Tue, Apr 14, 2015 at 10:05 AM, Junio C Hamano <gitster@pobox.com> wrote:

> A dangling object is an unreachable object that cannot be
> made reachable by any way other than pointing at it
> directly with a ref.

Thanks a lot for the prompt explanation!

-- 
Sebastian Schuberth

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  8:50   ` Michael J Gruber
@ 2015-04-14  8:58     ` Sebastian Schuberth
  2015-04-14  9:22       ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Schuberth @ 2015-04-14  8:58 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: Junio C Hamano, Git Mailing List

On Tue, Apr 14, 2015 at 10:50 AM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:

> "to dangle" means "to hang loosely".
>
> So, in the description above, "A^ dangles from A loosely" because it
> hangs from A (you can reach it from A) but loosely, because it would
> "drop" if A gets dropped and A is "likely" to be dropped (because it is
> unreachable by refs). But A^ is not dangling in our terminology.
>
> If you *reverse the arrows*, i.e. consider A^ pointing to A, it becomes
> more apparent that A is dangling: it is an unreferenced leaf node.

That's exactly what confused me. In the very literal sense, something
can only "hang loosely", i.e. dangle, if it's only tied at *one* end,
and that's the case for A (which is only connected to A^) but not for
A^ (which is connected to its parent, and A). Especially when talking
about A as a "leaf" node, like in the leaf of a natural tree, I would
think that A is dangling.

-- 
Sebastian Schuberth

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  8:58     ` Sebastian Schuberth
@ 2015-04-14  9:22       ` Junio C Hamano
  2015-04-14  9:28         ` Sebastian Schuberth
  2015-04-14 16:19         ` Michael J Gruber
  0 siblings, 2 replies; 9+ messages in thread
From: Junio C Hamano @ 2015-04-14  9:22 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: Michael J Gruber, Git Mailing List

Sebastian Schuberth <sschuberth@gmail.com> writes:

> On Tue, Apr 14, 2015 at 10:50 AM, Michael J Gruber
> <git@drmicha.warpmail.net> wrote:
>
>> "to dangle" means "to hang loosely".
>>
>> So, in the description above, "A^ dangles from A loosely" because it
>> hangs from A (you can reach it from A) but loosely, because it would
>> "drop" if A gets dropped and A is "likely" to be dropped (because it is
>> unreachable by refs). But A^ is not dangling in our terminology.
>>
>> If you *reverse the arrows*, i.e. consider A^ pointing to A, it becomes
>> more apparent that A is dangling: it is an unreferenced leaf node.
>
> That's exactly what confused me. In the very literal sense, something
> can only "hang loosely", i.e. dangle, if it's only tied at *one* end,
> and that's the case for A (which is only connected to A^) but not for
> A^ (which is connected to its parent, and A). Especially when talking
> about A as a "leaf" node, like in the leaf of a natural tree, I would
> think that A is dangling.

I am not sure if I follow, but probably it is just me who is not
strong at math, or whose eyesight is not keen enough to notice the
arrow heads on links between the commits.

I just visualize commits to be ping-pong balls with strings between
them, and then grab the root of the graph and lift the whole thing
up, while tips of the branches and tags are anchored.  Commit A will
be dangling in the wind if you shake the whole thing.

But that visualization breaks down once you start thinking about
what will happen to A^{tree} and its blobs; they are attached to A
with thin strings and they will have to float above A (i.e. sit
somewhere closer to the root of the tree) just like A^ will go
closer to the root, to make A appear the "dangling" one, as the
direction of the arrow is from A to A^{tree} just like we have an
arrow from A to A^; just like A^ is not dangling because of A,
A^{tree} is not dangling.

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  9:22       ` Junio C Hamano
@ 2015-04-14  9:28         ` Sebastian Schuberth
  2015-04-14 16:19         ` Michael J Gruber
  1 sibling, 0 replies; 9+ messages in thread
From: Sebastian Schuberth @ 2015-04-14  9:28 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael J Gruber, Git Mailing List

On Tue, Apr 14, 2015 at 11:22 AM, Junio C Hamano <gitster@pobox.com> wrote:

> I just visualize commits to be ping-pong balls with strings between
> them, and then grab the root of the graph and lift the whole thing
> up, while tips of the branches and tags are anchored.  Commit A will
> be dangling in the wind if you shake the whole thing.

I used to have exactly the same visualization in mind, but got
confused in between, unsure whether my understanding was correct. As
it turns out it is, and when sticking to that visualization everything
seems to be consistent in the fsck docs. They could still benefit some
more clarification I guess. I'll see if I can come up with something.

Thanks again.

-- 
Sebastian Schuberth

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  8:52   ` Sebastian Schuberth
@ 2015-04-14 14:20     ` Sebastian Schuberth
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Schuberth @ 2015-04-14 14:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, git

On Tue, Apr 14, 2015 at 10:52 AM, Sebastian Schuberth
<sschuberth@gmail.com> wrote:

>> A dangling object is an unreachable object that cannot be
>> made reachable by any way other than pointing at it
>> directly with a ref.
>
> Thanks a lot for the prompt explanation!

Note to myself: I just realized that both "dangling" and "unreachable"
are also nicely defined in the Git glossary [1].

[1] http://git-scm.com/docs/gitglossary/

-- 
Sebastian Schuberth

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

* Re: git fsck: unreachable vs. dangling
  2015-04-14  9:22       ` Junio C Hamano
  2015-04-14  9:28         ` Sebastian Schuberth
@ 2015-04-14 16:19         ` Michael J Gruber
  1 sibling, 0 replies; 9+ messages in thread
From: Michael J Gruber @ 2015-04-14 16:19 UTC (permalink / raw)
  To: Junio C Hamano, Sebastian Schuberth; +Cc: Git Mailing List

Junio C Hamano venit, vidit, dixit 14.04.2015 11:22:
> Sebastian Schuberth <sschuberth@gmail.com> writes:
> 
>> On Tue, Apr 14, 2015 at 10:50 AM, Michael J Gruber
>> <git@drmicha.warpmail.net> wrote:
>>
>>> "to dangle" means "to hang loosely".
>>>
>>> So, in the description above, "A^ dangles from A loosely" because it
>>> hangs from A (you can reach it from A) but loosely, because it would
>>> "drop" if A gets dropped and A is "likely" to be dropped (because it is
>>> unreachable by refs). But A^ is not dangling in our terminology.
>>>
>>> If you *reverse the arrows*, i.e. consider A^ pointing to A, it becomes
>>> more apparent that A is dangling: it is an unreferenced leaf node.
>>
>> That's exactly what confused me. In the very literal sense, something
>> can only "hang loosely", i.e. dangle, if it's only tied at *one* end,
>> and that's the case for A (which is only connected to A^) but not for
>> A^ (which is connected to its parent, and A). Especially when talking
>> about A as a "leaf" node, like in the leaf of a natural tree, I would
>> think that A is dangling.
> 
> I am not sure if I follow, but probably it is just me who is not
> strong at math, or whose eyesight is not keen enough to notice the
> arrow heads on links between the commits.

"git log --graph" does not show arrow heads, obviously. Many
illustrations about Git do.

The relation between commits is clearly directed: A being a parent
commit of B is different from B being a parent commit of A (and both
cannot be true simultaneously due to the "A" in "DAG")

 > I just visualize commits to be ping-pong balls with strings between
> them, and then grab the root of the graph and lift the whole thing
> up, while tips of the branches and tags are anchored.  Commit A will
> be dangling in the wind if you shake the whole thing.

If you don't have a concept of direction it is difficult to distinguish
roots from tips...

Our commit relationship is certainly a directed one. You can define it
using either "is parent of" or "is child of". They are opposite, and
lead to opposite notions of "root" (a node without predecessors) and
"tip" (a node without successors).

> But that visualization breaks down once you start thinking about
> what will happen to A^{tree} and its blobs; they are attached to A
> with thin strings and they will have to float above A (i.e. sit
> somewhere closer to the root of the tree) just like A^ will go
> closer to the root, to make A appear the "dangling" one, as the
> direction of the arrow is from A to A^{tree} just like we have an
> arrow from A to A^; just like A^ is not dangling because of A,
> A^{tree} is not dangling.
> 

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

end of thread, other threads:[~2015-04-14 16:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14  7:16 git fsck: unreachable vs. dangling Sebastian Schuberth
2015-04-14  8:05 ` Junio C Hamano
2015-04-14  8:50   ` Michael J Gruber
2015-04-14  8:58     ` Sebastian Schuberth
2015-04-14  9:22       ` Junio C Hamano
2015-04-14  9:28         ` Sebastian Schuberth
2015-04-14 16:19         ` Michael J Gruber
2015-04-14  8:52   ` Sebastian Schuberth
2015-04-14 14:20     ` Sebastian Schuberth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.