home | list info | list archive | date index | thread index

[OCLUG-Tech] a (simple?) question about what git can "reuse" across repos

  • Subject: [OCLUG-Tech] a (simple?) question about what git can "reuse" across repos
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Tue, 28 Apr 2015 09:17:21 -0400 (EDT)
  once again, given the git expertise on this mailing list, i'm going
to ask a pedantic question about what git is allowed to recognize as
the same content from another repository for the purpose of reuse (or
something like that).

  i'm curious if git will recognize identical underlying content from
two different repositories depending on how that content was added and
committed.

  as an example, i created local repo "r1" and proceeded to:

1) copy /etc/passwd in, add it and commit it with a short msg
2) copy /etc/group in, add it and commit it with a short msg

at this point, i can list all of the objects in this local repo with:

$ git rev-list --objects --all
f82f683b926ae0f990ab3bc0e2ec32f803048a88
5458ea7a04c3c2472b8eab5c5ac17186fa0b0a3b
aa1f15413a3f034107e0aaff4e5e69c0a066a7d9
89363044efbd01653f8721f3dd3f3819d667800e group
667760e6c1c4aeaf8dbb44e93bf548401ee45f35 passwd
73f78287850c51fab57aaee1e6cbd1bb7cb295b2
$

and i can display the properties of the tree object that contains
them:

$ git ls-tree --full-tree aa1f
100644 blob 89363044efbd01653f8721f3dd3f3819d667800e	group
100644 blob 667760e6c1c4aeaf8dbb44e93bf548401ee45f35	passwd
$

  so far, so good. now i did it all again in repo "r2", except in the
opposite order. unsurprisingly, i got a different set of commits but
the same sha1 sums for the blobs and the tree object:

$ git rev-list --objects --all
ba8d7ee1e7cd6376d3dadb74c482e26e20382256
712505b1abde86005a458c9dfddb6f33bc8fc56e
aa1f15413a3f034107e0aaff4e5e69c0a066a7d9
89363044efbd01653f8721f3dd3f3819d667800e group
667760e6c1c4aeaf8dbb44e93bf548401ee45f35 passwd
73495de0938a648f6899318dc37970bc2cb7cc88
$

$ git ls-tree --full-tree aa1f
100644 blob 89363044efbd01653f8721f3dd3f3819d667800e	group
100644 blob 667760e6c1c4aeaf8dbb44e93bf548401ee45f35	passwd
$

so my question is (i think), while it might be unlikely that two
separate repos will end up with an identical tree object, it's
obviously possible, and i'm curious about how git would recognize/take
advantage of that.

  in what circumstances would an identical tree object result in less
work, or however you want to phrase it?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================