{"thread":{"id":"21297","subject":"ident hash usage question","startedAt":"2009-10-20T17:24:52Z","lastAt":"2009-10-21T23:32:26Z","messageCount":18,"participants":["Eugene Sajine","Alex Riesen","Johannes Sixt","Junio C Hamano","Nanako Shiraishi","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"125499","messageId":"76c5b8580910201024x58ffdd3bs6f4cc6932ac31868@mail.gmail.com","threadId":"21297","inReplyTo":null,"subject":"ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T17:24:52Z","receivedAt":"2009-10-20T17:24:52Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"Hi,\n\nPlease correct me if I’m missing something, but:\n\nI was able to get the $Id$ keyword to show the SHA-1 hash of the file\ncontent, which is done using ident in gitattributes. Now I’m trying to\nfind a way to get more info about the file using only this hash.\n\nCould you , please, advise if there is a way to get file name and path\ninside the repo by having only this Blob hash?\n\nThank you,\nEugene\n"},{"id":"125501","messageId":"81b0412b0910201116s694d7877rda872b368f1ae09a@mail.gmail.com","threadId":"21297","inReplyTo":"76c5b8580910201024x58ffdd3bs6f4cc6932ac31868@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-20T18:16:21Z","receivedAt":"2009-10-20T18:16:21Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Oct 20, 2009 at 19:24, Eugene Sajine <euguess@gmail.com> wrote:\n> I was able to get the $Id$ keyword to show the SHA-1 hash of the file\n> content, which is done using ident in gitattributes. Now I’m trying to\n> find a way to get more info about the file using only this hash.\n>\n> Could you , please, advise if there is a way to get file name and path\n> inside the repo by having only this Blob hash?\n\nIt is not possible.\n\nBut you can save the commits hash in your blob. Then you'll have everything.\nThat how git knows it's version.\n"},{"id":"125502","messageId":"81b0412b0910201119w7583487ag276cf964d0a85e@mail.gmail.com","threadId":"21297","inReplyTo":"81b0412b0910201116s694d7877rda872b368f1ae09a@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-20T18:19:30Z","receivedAt":"2009-10-20T18:19:30Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Oct 20, 2009 at 20:16, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On Tue, Oct 20, 2009 at 19:24, Eugene Sajine <euguess@gmail.com> wrote:\n>> I was able to get the $Id$ keyword to show the SHA-1 hash of the file\n>> content, which is done using ident in gitattributes. Now I’m trying to\n>> find a way to get more info about the file using only this hash.\n>>\n>> Could you , please, advise if there is a way to get file name and path\n>> inside the repo by having only this Blob hash?\n>\n> It is not possible.\n>\n\nWell, not exactly impossible, but you can end up with multiple paths,\nsome of which may not have anything to do the original path.\n\nJust run git log --no-abbrev --raw --all and grep for the SHA-1\n"},{"id":"125506","messageId":"76c5b8580910201159i75a90f28pb882e83f0c7c40ae@mail.gmail.com","threadId":"21297","inReplyTo":"81b0412b0910201119w7583487ag276cf964d0a85e@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T18:59:53Z","receivedAt":"2009-10-20T18:59:53Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":">\n> Well, not exactly impossible, but you can end up with multiple paths,\n> some of which may not have anything to do the original path.\n>\n> Just run git log --no-abbrev --raw --all and grep for the SHA-1\n>\n\nThis is exactly what I was looking for! Thank you!\n\nI understand that in some cases this can give me two paths instead of\none, but it will only demonstrate that I have absolute copy of a file\ninside my repo, which is also good to diagnose (because the\nprobability of having two meaningful files with the same hash, but\ndifferent content is way too low).\n\nSo, this means that after few little tricks the keyword expansion\nproblem may be resolved by only using $Id$ keyword.\nBecause after having this hash one can build up all necessary info from it:\n\n#finding blobs with SHA indicated in $Id$ keword\n$ git log --no-abbrev --raw --all | grep SHA-1\n\n# little script or regexp here (don’t have it)\n$ pull out path from result\n\n# last commit for the path with all corresponding info\n$ git log -1 HEAD path\n\nSo, this seems to cover most of the needs of people who would like to\nuse keywords expansion, if they are not ready to forget about them…\n\nDoes it make sense?\n\nThanks,\nEugene\n"},{"id":"125509","messageId":"81b0412b0910201219q4d16c472n43cab4b5d17cf63c@mail.gmail.com","threadId":"21297","inReplyTo":"76c5b8580910201159i75a90f28pb882e83f0c7c40ae@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-20T19:19:47Z","receivedAt":"2009-10-20T19:19:47Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Oct 20, 2009 at 20:59, Eugene Sajine <euguess@gmail.com> wrote:\n>>\n>> Well, not exactly impossible, but you can end up with multiple paths,\n>> some of which may not have anything to do the original path.\n>>\n>> Just run git log --no-abbrev --raw --all and grep for the SHA-1\n>\n> This is exactly what I was looking for! Thank you!\n>\n\nVery likely it isn't, but it's your choice.\n\n> Because after having this hash one can build up all necessary info from it:\n\nDepending on your definition of \"necessary\".\n\n> #finding blobs with SHA indicated in $Id$ keword\n> $ git log --no-abbrev --raw --all | grep SHA-1\n\nyeah. These are all starting from commit which introduced\nthe hash under a specific path, ending at the commit where\nthe path contains another SHA-1.\n\n> # little script or regexp here (don’t have it)\n> $ pull out path from result\n>\n> # last commit for the path with all corresponding info\n> $ git log -1 HEAD path\n>\n> So, this seems to cover most of the needs of people who would like to\n> use keywords expansion, if they are not ready to forget about them…\n>\n> Does it make sense?\n\nNot much. You'll always get a long list of commits which didn't\nchange the damned blob. And you have absolutely no way\nto find out exactly which of the commits have produced\nthe blob you're looking at (because you decided to do away\nwith the information).\n\nWhat's so hard with storing the SHA-1 of the *commit*, anyway?\n"},{"id":"125516","messageId":"200910202222.37563.j6t@kdbg.org","threadId":"21297","inReplyTo":"81b0412b0910201219q4d16c472n43cab4b5d17cf63c@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-10-20T20:22:36Z","receivedAt":"2009-10-20T20:22:36Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Dienstag, 20. Oktober 2009, Alex Riesen wrote:\n> What's so hard with storing the SHA-1 of the *commit*, anyway?\n\nThe hard part is that you get a cycle: commit SHA1 depends on contents depends \non commit SHA1.\n\n-- Hannes\n"},{"id":"125518","messageId":"76c5b8580910201330r45cf625k3a41b5b9e24b3e01@mail.gmail.com","threadId":"21297","inReplyTo":"81b0412b0910201219q4d16c472n43cab4b5d17cf63c@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T20:30:27Z","receivedAt":"2009-10-20T20:30:27Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"First, thank you for your answers!\n\n>\n> Very likely it isn't, but it's your choice.\n\n;)\n\n>\n>> Because after having this hash one can build up all necessary info from it:\n>\n> Depending on your definition of \"necessary\".\n\nI'm trying to find a way to get to state where i can do\n\n$ git log <path>\n\nOr any other variants of it without introducing any non-default\nscripts/features/keywords and limiting keywords to one to avoid any\nrelated problem...\n\nOne of my friends said that git is not working for their development\nmodel... C++ development with static linking across the board, where\nthey need to see exactly which version of the file has got to the\nexecutable. Roughly, they are using CVS' keywords and revision numbers\nand a script wich matches them between two versions of the\nexecutables.\n\nI've got curious if Git can support it and how it can be done with\nminimal changes to workflow.\n\n>\n>> #finding blobs with SHA indicated in $Id$ keword\n>> $ git log --no-abbrev --raw --all | grep SHA-1\n>\n> yeah. These are all starting from commit which introduced\n> the hash under a specific path, ending at the commit where\n> the path contains another SHA-1.\n\nActually, grep \"SHA-1 A\" will show added path(s) only, so this is resolved\n\n>\n>> # little script or regexp here (don’t have it)\n>> $ pull out path from result\n>>\n>> # last commit for the path with all corresponding info\n>> $ git log -1 HEAD path\n>>\n>> So, this seems to cover most of the needs of people who would like to\n>> use keywords expansion, if they are not ready to forget about them…\n>>\n>> Does it make sense?\n>\n> Not much. You'll always get a long list of commits which didn't\n> change the damned blob. And you have absolutely no way\n> to find out exactly which of the commits have produced\n> the blob you're looking at (because you decided to do away\n> with the information).\n\nHow is that? It seams to me that git log <path> will show only commits\nwhere <path> was changed/committed? Considering the fact that I've got\nthe initial path from the blob, i should get the exact commit history\n(or last commit in my example) for the file(s) (Files if renaming\noccurred without content change).\n\nThanks,\nEugene\n"},{"id":"125519","messageId":"81b0412b0910201335j3b3340cydf3cbaf3c938190@mail.gmail.com","threadId":"21297","inReplyTo":"200910202222.37563.j6t@kdbg.org","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-20T20:35:10Z","receivedAt":"2009-10-20T20:35:10Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Oct 20, 2009 at 22:22, Johannes Sixt <j6t@kdbg.org> wrote:\n> On Dienstag, 20. Oktober 2009, Alex Riesen wrote:\n>> What's so hard with storing the SHA-1 of the *commit*, anyway?\n>\n> The hard part is that you get a cycle: commit SHA1 depends on contents depends\n> on commit SHA1.\n\nDon't store it in the repo. Store it in the output.\n"},{"id":"125525","messageId":"7veioxn6ee.fsf@alter.siamese.dyndns.org","threadId":"21297","inReplyTo":"76c5b8580910201330r45cf625k3a41b5b9e24b3e01@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-20T20:43:05Z","receivedAt":"2009-10-20T20:43:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eugene Sajine <euguess@gmail.com> writes:\n\n> One of my friends said that git is not working for their development\n> model... C++ development with static linking across the board, where\n> they need to see exactly which version of the file has got to the\n> executable. Roughly, they are using CVS' keywords and revision numbers\n> and a script wich matches them between two versions of the\n> executables.\n>\n> I've got curious if Git can support it and how it can be done with\n> minimal changes to workflow.\n\nIf the project is already arranged to be compiled with decent automation,\nI do not think you need any change to the workflow.\n\nYou would have a version.cc file with\n\n\tstatic char program_version[] = \"My Program \" VERSION_STRING;\n\nin it, and teach the build procedure how to compile and link this file.\nSomething like:\n\n    version.o: version.cc\n    \t$(CXX) -o $@ -DVERSION_STRING=\\\"\"$(git describe HEAD)\"\\\" $?\n"},{"id":"125526","messageId":"81b0412b0910201343r4ff49f9fnbdd9260dcf682416@mail.gmail.com","threadId":"21297","inReplyTo":"76c5b8580910201330r45cf625k3a41b5b9e24b3e01@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-20T20:43:43Z","receivedAt":"2009-10-20T20:43:43Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Tue, Oct 20, 2009 at 22:30, Eugene Sajine <euguess@gmail.com> wrote:\n> One of my friends said that git is not working for their development\n> model... C++ development with static linking across the board, where\n> they need to see exactly which version of the file has got to the\n> executable. Roughly, they are using CVS' keywords and revision numbers\n> and a script wich matches them between two versions of the\n> executables.\n\nAs soon as your friend understand, that a commit describes the complete\nstate of the repository on the moment of commit, he/she will notice that\nthe commit allows to find each what content each file in the product\nhad at the moment of compilation and linking (assuming they weren't\ncompiling uncommitted tree, which RCS/CVS/SVN/Perforce mindset\ntends to encourage).\n\n> I've got curious if Git can support it and how it can be done with\n> minimal changes to workflow.\n\nDepends on workflow, I afraid. And I personally wouldn't bother.\n\n>>> # little script or regexp here (don’t have it)\n>>>\n>>> Does it make sense?\n>>\n>> Not much. You'll always get a long list of commits which didn't\n>> change the damned blob. And you have absolutely no way\n>> to find out exactly which of the commits have produced\n>> the blob you're looking at (because you decided to do away\n>> with the information).\n>\n> How is that? It seams to me that git log <path> will show only commits\n> where <path> was changed/committed? Considering the fact that I've got\n> the initial path from the blob, i should get the exact commit history\n> (or last commit in my example) for the file(s) (Files if renaming\n> occurred without content change).\n\nThe blob is present in each commit since it was introduced. Except\nwhen your project contains only that one blob, isn't the state of\nthe other parts of an interest?\n"},{"id":"125539","messageId":"76c5b8580910201514sc44f1cag222cf8a3710c875@mail.gmail.com","threadId":"21297","inReplyTo":"7veioxn6ee.fsf@alter.siamese.dyndns.org","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T22:14:08Z","receivedAt":"2009-10-20T22:14:08Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"> If the project is already arranged to be compiled with decent automation,\n> I do not think you need any change to the workflow.\n>\n> You would have a version.cc file with\n>\n>        static char program_version[] = \"My Program \" VERSION_STRING;\n>\n> in it, and teach the build procedure how to compile and link this file.\n> Something like:\n>\n>    version.o: version.cc\n>        $(CXX) -o $@ -DVERSION_STRING=\\\"\"$(git describe HEAD)\"\\\" $?\n>\n\nPlease, correct me if I'm mistaken and forgive me if I'm not correct\nin using C++ terms.\n\nYour solution proposes to have a version file which will carry the\ninfo about last state the program was built from.\nBut as I understand in case of static linking the executable will get\nonly obj files from a library, which are necessary and everything\nirrelevant will be thrown away by linker. In this circumstances the\nprogram comparing two executable will not notice any differences\nbetween let's say existing production and new development version of\nthe executable. In case of several libraries linked this gets even\nworse. That's what their basis is for keywords expansion use.\n\nIf there is no other solution in VCS terms how to understand which\nparticular version of file has got linked to the executable except\nkeywords expansion, then I'm talking about the way of reducing the\namount of keywords expanded to a minimum - 1.\n\nIf we can agree on this, then it seems that having the content/blob\nhash in the file $Id$ is enough to get any other relevant info about\nthe file.\n\nAt least by hash you can find the path added/modified. When the path\nis on hands you can easily realize the history for the file. It seems\nto me that using content hash will provide unique results enough to\nmake conclusions, because the probability of having two files with\nsame hash but different content is too low, and only scenario is to\nget the same hash is to get the absolute copy of the file, but such\nfile existence is questionable...\n\nOTOH, Alex was right that there are situation where this is not\nworking as expected from the first run:\nIf the file was modified its blob hash is going to change, but there\nwill be no entry with letter A in the log. So, if\n\n$ git log --no-abbrev --raw --all | grep \"SHA-1 A\"\n\nReturns empty string then, we should do that without \"A\".\nAs I understand this *second* run should always return:\n\n1. only one entry if this is latest hash - one path. Goal reached.\n2. two entries if there was a change afterwards - One path. Goal reached\n3. three entries if rename was committed separately and then renamed\nfile was changed - two paths. Enough to make conclusion about the\nfiles.\n\nIn any case the  goal is to get the path as correct as possible and\nthen proceed with matching and other stuff.\n\n\nThanks,\nEugene\n"},{"id":"125540","messageId":"76c5b8580910201519s29b939f3o3f6af8ca50340db1@mail.gmail.com","threadId":"21297","inReplyTo":"81b0412b0910201343r4ff49f9fnbdd9260dcf682416@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T22:19:56Z","receivedAt":"2009-10-20T22:19:56Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":">> How is that? It seams to me that git log <path> will show only commits\n>> where <path> was changed/committed? Considering the fact that I've got\n>> the initial path from the blob, i should get the exact commit history\n>> (or last commit in my example) for the file(s) (Files if renaming\n>> occurred without content change).\n>\n> The blob is present in each commit since it was introduced. Except\n> when your project contains only that one blob, isn't the state of\n> the other parts of an interest?\n>\nI would question this statement. It seems to me that hash of the file\ncontent is logged only for the commit when it was touched.\nTherefore there is very limited amount of actual commits where the\nsame hash can be met.\n\nThanks,\nEugene\n"},{"id":"125542","messageId":"7vbpk1lmvl.fsf@alter.siamese.dyndns.org","threadId":"21297","inReplyTo":"76c5b8580910201514sc44f1cag222cf8a3710c875@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-20T22:30:06Z","receivedAt":"2009-10-20T22:30:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eugene Sajine <euguess@gmail.com> writes:\n\n>> If the project is already arranged to be compiled with decent automation,\n>> I do not think you need any change to the workflow.\n>>\n>> You would have a version.cc file with\n>>\n>>        static char program_version[] = \"My Program \" VERSION_STRING;\n>>\n>> in it, and teach the build procedure how to compile and link this file.\n>> Something like:\n>>\n>>    version.o: version.cc\n>>        $(CXX) -o $@ -DVERSION_STRING=\\\"\"$(git describe HEAD)\"\\\" $?\n>>\n>\n> Please, correct me if I'm mistaken and forgive me if I'm not correct\n> in using C++ terms.\n>\n> Your solution proposes to have a version file which will carry the\n> info about last state the program was built from.\n> But as I understand in case of static linking the executable will get\n> only obj files from a library, which are necessary and everything\n> irrelevant will be thrown away by linker.\n\nI am not sure what you mean by \"static linking\" anymore.  Usually the word\nmeans that everything you tell the linker to link to the executable is\nlinked, together with objects from libraries.  The resulting executable is\nusable on its own and it does not change behaviour regardless of which\nversion of dynamic libraries you depend on happen to be installed on the\ntarget system (because by definition a statically linked executable does\nnot depend on dynamic libraries---that is the whole point of static\nlinking).\n\nSo as long as you make sure version.o is linked to the final executable,\nyou will be fine.  One way to do so might be to have\n\n\tprintf(\"Program version: %s\", program_version);\n\nat the beginning of main() ;-)\n\nIf your product ships as one main executable _dynamically_ linked with two\ndynamic libraries, and all three components are built from the source\nmaterial under your source control, obviously you would need to make sure\nthat the above version.o or some equivalent of what embeds output from\n\"git describe HEAD\" are linked to the main executable and to the two\nlibraries, but the idea is the same.\n"},{"id":"125551","messageId":"76c5b8580910201649i76d14f8bod9a84afa6ea6bbb0@mail.gmail.com","threadId":"21297","inReplyTo":"7vbpk1lmvl.fsf@alter.siamese.dyndns.org","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-20T23:49:48Z","receivedAt":"2009-10-20T23:49:48Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"> I am not sure what you mean by \"static linking\" anymore.  Usually the word\n> means that everything you tell the linker to link to the executable is\n> linked, together with objects from libraries.  The resulting executable is\n> usable on its own and it does not change behaviour regardless of which\n> version of dynamic libraries you depend on happen to be installed on the\n> target system (because by definition a statically linked executable does\n> not depend on dynamic libraries---that is the whole point of static\n> linking).\n>\n\nThere seems to be no misunderstanding in the static linking - i meant\nthe same thing. But let me put an example:\n\nI have a program.exe\n\nThis program.exe is built basing on two statically linked libraries\nlib1.lib and lib2.lib\n\nI'm not developing any of those libraries, but only my own code of the\nprogram.exe\n\nNow, somebody changed 2 files in lib1.lib and 5 files in lib2.lib. But\ni don't know that they are changed because it is different CVS module\nor because I'm building against latest released libs or for whatever\nreason...\n\nWhen i rebuild my program the build supposed to pick up changes from\nthe libraries I'm using and relink, that will include 7 changed obj\nfiles.\n\nHow can i say which exactly files are changed in my new version of\nexecutable comparing to the previous version?\n\nCurrently they can take a look at the revision number of every\nparticular file included into the executable, which is put there by\nCVS and compare it with the production. If the version is different,\nthen you know which files are changed and you can get diffs on them...\nThey also have file path and date and other stuff expanded...\n\nPlease note, my personal goal is *to prove that git can do that\nbetter*, with less intrusion into the code sources, not other way\naround.So, while keeping the info they want to have they might get\nsome benefits of git. Although, i understand that there might be no\ncure for this state already, you can tell me that and I will close the\ntopic, but I just keep hoping;)\n\n\nThanks a lot,\nEugene\n"},{"id":"125561","messageId":"20091021120910.6117@nanako3.lavabit.com","threadId":"21297","inReplyTo":"7vbpk1lmvl.fsf@alter.siamese.dyndns.org","subject":"Re: ident hash usage question","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-10-21T03:09:10Z","receivedAt":"2009-10-21T03:09:10Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Junio C Hamano <gitster@pobox.com>\n\n> If your product ships as one main executable _dynamically_ linked with two\n> dynamic libraries, and all three components are built from the source\n> material under your source control, obviously you would need to make sure\n> that the above version.o or some equivalent of what embeds output from\n> \"git describe HEAD\" are linked to the main executable and to the two\n> libraries, but the idea is the same.\n\nDoesn't the above strategy also apply to the case where the \nlibraries are linked statically, too? You get the version \nstring from the main program and two version strings from the \nlibraries embedded in the final product.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"125565","messageId":"alpine.LNX.2.00.0910210059090.14365@iabervon.org","threadId":"21297","inReplyTo":"76c5b8580910201649i76d14f8bod9a84afa6ea6bbb0@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-10-21T05:35:16Z","receivedAt":"2009-10-21T05:35:16Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Tue, 20 Oct 2009, Eugene Sajine wrote:\n\n> > I am not sure what you mean by \"static linking\" anymore.  Usually the word\n> > means that everything you tell the linker to link to the executable is\n> > linked, together with objects from libraries.  The resulting executable is\n> > usable on its own and it does not change behaviour regardless of which\n> > version of dynamic libraries you depend on happen to be installed on the\n> > target system (because by definition a statically linked executable does\n> > not depend on dynamic libraries---that is the whole point of static\n> > linking).\n> >\n> \n> There seems to be no misunderstanding in the static linking - i meant\n> the same thing. But let me put an example:\n> \n> I have a program.exe\n> \n> This program.exe is built basing on two statically linked libraries\n> lib1.lib and lib2.lib\n> \n> I'm not developing any of those libraries, but only my own code of the\n> program.exe\n> \n> Now, somebody changed 2 files in lib1.lib and 5 files in lib2.lib. But\n> i don't know that they are changed because it is different CVS module\n> or because I'm building against latest released libs or for whatever\n> reason...\n> \n> When i rebuild my program the build supposed to pick up changes from\n> the libraries I'm using and relink, that will include 7 changed obj\n> files.\n> \n> How can i say which exactly files are changed in my new version of\n> executable comparing to the previous version?\n\nAs Nanako points out, you want a version string from each library, \nprobably with the name of the library in the symbol. So:\n\nstatic char *lib1_version = \"\" VERSION_STRING\n\nin lib1/version.cc.\n\n> Currently they can take a look at the revision number of every\n> particular file included into the executable, which is put there by\n> CVS and compare it with the production. If the version is different,\n> then you know which files are changed and you can get diffs on them...\n> They also have file path and date and other stuff expanded...\n\nOnce you've got the version strings from each of the components, and \nyou've got the repository for each library, you can compare the version in \nthe string with other versions, and that one hash expands to the hashes \nfor all of the files, including things like the Makefile that don't \nactually become object files but affect them.\n\nYou can also do things like: when you build an executable, write it as a \nblob to the repository and make a tag (actually, a note will be \nbetter, but that's newer than I've done this) pointing to it that lists \neverything used to build it. If you encounter the executable again later, \nit'll have the same hash, and git can find the tag with the other \ninformation.\n\nI've actually done something where I tagged the main tree and a few \nlibraries with matching tags, built the executable with a 20-byte \nsequence of zeros, put it into the repository, then wrote its sha1 to \nthose 20 bytes, and tagged the executable with a tag based on the source \ntag. Then I put it on a microcontroller, sealed it in epoxy, mixed it with \nother devices with different firmware revisions, and sent it out. When a \ndevice had a problem, I could ask it for those 20 bytes, ask git for the \ntag that pointed to those 20 bytes, and check out exactly the source used \nto build it.\n\n> Please note, my personal goal is *to prove that git can do that\n> better*, with less intrusion into the code sources, not other way\n> around.So, while keeping the info they want to have they might get\n> some benefits of git. Although, i understand that there might be no\n> cure for this state already, you can tell me that and I will close the\n> topic, but I just keep hoping;)\n\nYou're not going to be able to avoid having different tracking things in \nthe source, but git does give you the major advantage that you can have \nthe build system produce one hash that identifies every single file in the \nproject, rather than having to have each file identify itself (and \nprobably overlook files that don't directly produce object code). It's a \nbig help the day you're trying to figure out if an executable came from \nbefore or after someone's commit to change the compiler options, and it's \nfewer strings than you need with CVS.\n\n\t-Daniel\n*This .sig left intentionally blank*"},{"id":"125568","messageId":"81b0412b0910202325i7a2f440bxcc9ce3ab9b684b2c@mail.gmail.com","threadId":"21297","inReplyTo":"76c5b8580910201519s29b939f3o3f6af8ca50340db1@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2009-10-21T06:25:01Z","receivedAt":"2009-10-21T06:25:01Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On Wed, Oct 21, 2009 at 00:19, Eugene Sajine <euguess@gmail.com> wrote:\n>>> How is that? It seams to me that git log <path> will show only commits\n>>> where <path> was changed/committed? Considering the fact that I've got\n>>> the initial path from the blob, i should get the exact commit history\n>>> (or last commit in my example) for the file(s) (Files if renaming\n>>> occurred without content change).\n>>\n>> The blob is present in each commit since it was introduced. Except\n>> when your project contains only that one blob, isn't the state of\n>> the other parts of an interest?\n>>\n> I would question this statement. It seems to me that hash of the file\n> content is logged only for the commit when it was touched.\n> Therefore there is very limited amount of actual commits where the\n> same hash can be met.\n\ngit rev-list HEAD | while read sha; do git ls-tree $sha; done | grep <blob-sha>\n"},{"id":"125667","messageId":"76c5b8580910211632s313ddc20ub66d9bcc647ac491@mail.gmail.com","threadId":"21297","inReplyTo":"81b0412b0910202325i7a2f440bxcc9ce3ab9b684b2c@mail.gmail.com","subject":"Re: ident hash usage question","fromName":"Eugene Sajine","fromEmail":"euguess@gmail.com","sentAt":"2009-10-21T23:32:26Z","receivedAt":"2009-10-21T23:32:26Z","isPatch":false,"sender":{"key":"euguess@gmail.com","avatar":null},"body":"Many thanks to everybody for your time and comments!\n\nI have plenty of info to think about now...;)\n\nWith best regards,\nEugene\n"}]}