progit / progit2

Pro Git 2nd Edition
Other
5.85k stars 1.93k forks source link

Incorrect Graph #196

Open qdx opened 9 years ago

qdx commented 9 years ago

I think Figure 2 in book/10-git-internals/sections/objects.asc is incorrect. FYI, the code of the figure from the raw file is shown here:

.The content structure of your current Git data.
image::images/data-model-2.png[The content structure of your current Git data.]

There should be 3 tree objects in the graph, but tree object 0155eb4229851634a0f03eb265b69f5a2d56f341 seems to be missing from the graph.

ben commented 9 years ago

You're right that there's a bug, but it's a bit different than what you're saying. Here are the two command-line sessions from this part of the section:

$ git write-tree
0155eb4229851634a0f03eb265b69f5a2d56f341
$ git cat-file -p 0155eb4229851634a0f03eb265b69f5a2d56f341
100644 blob fa49b077972391ad58037050f2a75f74e3671e92      new.txt
100644 blob 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a      test.txt
$ git read-tree --prefix=bak d8329fc1cc938780ffdd9f94e0d364e0ea74f579
$ git write-tree
3c4e9cd789d88d8d89c1073707c3585e41b0e614
$ git cat-file -p 3c4e9cd789d88d8d89c1073707c3585e41b0e614
040000 tree d8329fc1cc938780ffdd9f94e0d364e0ea74f579      bak
100644 blob fa49b077972391ad58037050f2a75f74e3671e92      new.txt
100644 blob 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a      test.txt

The bak subtree in the second part should be the original tree from the first part, but the SHA hash isn't the right one; we use d8329 where we should be using 0155e. Want to submit a PR that fixes it? :smile:

qdx commented 9 years ago

Sorry if I'm not reading you correctly, but I don't think the SHA hash is the problem here, because it is consistent with with following subsection. Could you take a look at "Figure 3. All the objects in your Git directory." In the "Commit Objects" subsection? I think removing all the commit objects from that graph will give us the correct graph for Figure 2.

ben commented 9 years ago

Aha, right you are! My mistake. :blush:

So now the question is "what is this figure supposed to show?" The intent when I made it was just to show the 3c4e9c tree and all its descendants. It's meant to echo the form of the figure above it, which also only shows one tree. It might be a bit confusing to see all the objects in the repo at this point in the narrative, but we do get to that point further on.

Think like a complete newcomer to Git's object store. Would it be significantly more helpful to show the entire repo at this point in the chapter? My opinion is no, but I'm willing to be convinced.

qdx commented 9 years ago

Thanks for sharing the intent :)

In fact, I am a complete newcomer to Git's object store. It took me a few seconds to figure out that the files shown in Figure 1 does not have anything to do with the test repo which is used throughout this chapter. I did notice that Figure 2 echoes with Figure 1. But it took me another few minutes to convince myself that although the two figures look similar, they are based on different repos and have nothing to do with each other.

Then with this "You can think of the data that Git contains for these structures as being like this:" said, I automatically assume that Figure 2 should be showing all objects in the repo so far, but I can't find tree 0155eb in the graph. At this point I'm confused, and thought I might be wrong, I must be missing something here.

With this confusion and question in mind, I continue to read through. Finally when I encountered Figure 3, which shows the status of the repo, I know my understanding of the current git objects structure is not wrong. Then I go back to the previous section and try to find out what is actually going on there. Which is where I found out that Figure 2 is not showing all of git objects, and does not echo with Figure 3.

After that, when I move on to chapter 10.3, I realized that Figure 3 in 10.2 echoes with Figure 1 in 10.3, which is really nice. Then I think it would be better if Figure 2 in 10.2 also join these figures as a nice series of figures that shows how git objects build up, adding one type of objects at a time.

Going through these trouble, I decided that I should come here to share my little story, and listen to what you guys have in mind when designing these 2 chapters.

YueLinHo commented 8 years ago

How about insert one more image for this example?

$ git write-tree
0155eb4229851634a0f03eb265b69f5a2d56f341
$ git cat-file -p 0155eb4229851634a0f03eb265b69f5a2d56f341
100644 blob fa49b077972391ad58037050f2a75f74e3671e92      new.txt
100644 blob 1f7a7a472abf3dd9643fd615f6da379c4acb3e3a      test.txt

(Need Sketch application again!)

KZiemian commented 2 years ago

Can I ask if we can close this issue now? Or still some work need to be done?

Sherry520 commented 2 months ago

There should be a folder name bak. But I didn't see it. image