{"thread":{"id":"19","subject":"trying to figure out this git thing - some questions","startedAt":"2005-04-14T19:02:21Z","lastAt":"2005-04-14T23:52:13Z","messageCount":2,"participants":["Ehud Shabtai","tony.luck@intel.com"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"107","messageId":"68b6a2bc05041412025f1cb7c9@mail.gmail.com","threadId":"19","inReplyTo":null,"subject":"trying to figure out this git thing - some questions","fromName":"Ehud Shabtai","fromEmail":"eshabtai.lkml@gmail.com","sentAt":"2005-04-14T19:02:21Z","receivedAt":"2005-04-14T19:02:21Z","isPatch":false,"sender":{"key":"eshabtai.lkml@gmail.com","avatar":null},"body":"I'm trying to understand how it works and I'll appreciate if someone could help.\n\n1. git uses object abstraction for the different types and so\neverything is in one directory (objects). From what I've seen in the\nimplementation, the different kind of objects are not of the same type\n(there aren't any operations which work on two different types) and\nthus in each step when an object is used its type is verified.\nWhat's the benefit of having them all in the same tree? An alternative\nwould be to separate the different object types into different\ndirectories which trivially allows getting a list of all commits, or\ntrees or blobs.\n\n2. A commit can have more than one parent. Can anyone draw an example\nof such a case? When do we get a commit graph which is not linear?\n\n3. How does git handle binary files? I guess it doesn't really care if\nit's binary or text, but how would the diff and merge scripts handle\nthem?\n"},{"id":"169","messageId":"200504142352.j3ENqDB06021@unix-os.sc.intel.com","threadId":"19","inReplyTo":"68b6a2bc05041412025f1cb7c9@mail.gmail.com","subject":"Re: trying to figure out this git thing - some questions","fromName":"","fromEmail":"tony.luck@intel.com","sentAt":"2005-04-14T23:52:13Z","receivedAt":"2005-04-14T23:52:13Z","isPatch":false,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":">I'm trying to understand how it works and I'll appreciate if someone could help.\n\n>1. git uses object abstraction for the different types and so\n>everything is in one directory (objects). From what I've seen in the\n>implementation, the different kind of objects are not of the same type\n>(there aren't any operations which work on two different types) and\n>thus in each step when an object is used its type is verified.\n>What's the benefit of having them all in the same tree? An alternative\n>would be to separate the different object types into different\n>directories which trivially allows getting a list of all commits, or\n>trees or blobs.\n\nIf all the commits were in \".git/objects/commits/xx/xxxxx\", etc. then every\ntime git opened a file the kernel would have one extra level of directory\nto walk to get to the file ... so opens would be fractionally slower. There\nis no normal-use upside to this overhead.  While it would be easier to find\nall the blobs if they were kept separate from the trees and commits, there\nisn't any time that we'd ever want to scan through just the blobs.  Git never\ngoes searching through a directory opening files to see what they are\n(exception: fsck-cache does scan all objects).\n\n>2. A commit can have more than one parent. Can anyone draw an example\n>of such a case? When do we get a commit graph which is not linear?\n\nWhen a merge happens.  E.g. I take a snapshot of Linus' tree when a file\nis at version 1.2.  We both make a couple of changes before I ask him to\npull from my tree:\n\n\t1.1 -> 1.2 -> 1.3 -> 1.4 -> 1.5\n                \\                  /\n                1.2.1 -> 1.2.2 ---/\n\nThe changeset to create 1.5 has two parents ... the changeset that Linus made\nto create 1.4, and the changeset that I made to create 1.2.2\n\n>3. How does git handle binary files? I guess it doesn't really care if\n>it's binary or text, but how would the diff and merge scripts handle\n>them?\n\nYes, git doesn't care.  Diff is somewhat smart about noticing that its\ninput files aren't text:\n\n\t$ diff /bin/cat /bin/ls\n\tBinary files /bin/cat and /bin/ls differ\n\nBut in general this will be an issue for the SCM layer if there are binary\nfiles checked into the tree.\n\n-Tony\n"}]}