{"thread":{"id":"46437","subject":"git gc seems to break --symbolic-full-name","startedAt":"2017-07-21T17:40:22Z","lastAt":"2017-07-26T15:06:30Z","messageCount":12,"participants":["Stas Sergeev","Junio C Hamano","Jacob Keller","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"324879","messageId":"234492d7-7fd6-f847-8b85-010732ff43b6@list.ru","threadId":"46437","inReplyTo":null,"subject":"git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-21T17:40:12Z","receivedAt":"2017-07-21T17:40:22Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"Hello.\n\nI do the following:\n\n$ git rev-parse --symbolic-full-name devel\nrefs/heads/devel\n$ ls -l .git/`git rev-parse --symbolic-full-name devel`\n-rw-rw-r-- 1 stas stas 41 июл 21 15:05 .git/refs/heads/devel\n\nThis is fine. But after git gc:\n\n$ git rev-parse --symbolic-full-name devel\nrefs/heads/devel\n$ LC_ALL=C ls -l .git/`git rev-parse --symbolic-full-name devel`\nls: cannot access '.git/refs/heads/devel': No such file or directory\n\nThis is because after git gc there is nothing in .git/refs/heads:\n\n$ LC_ALL=C ls -l .git/refs/heads/\ntotal 8\ndrwxrwxr-x 2 stas stas 4096 Jul 31  2013 feature\ndrwxrwxr-x 2 stas stas 4096 Dec 23  2016 pr\n\nI prepend the path with .git above just as an\nexample: the same happens with rev-parse --git-path.\n\nSo I wonder if it is an expected behaviour for\n--symbolic-full-name to return the invalid pathes?\nIf so, how can I get the path to the needed head file?\nI use that for dependency tracking.\n"},{"id":"324882","messageId":"xmqqbmodhb5h.fsf@gitster.mtv.corp.google.com","threadId":"46437","inReplyTo":"234492d7-7fd6-f847-8b85-010732ff43b6@list.ru","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-07-21T18:56:10Z","receivedAt":"2017-07-21T18:56:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stas Sergeev <stsp@list.ru> writes:\n\n> I do the following:\n>\n> $ git rev-parse --symbolic-full-name devel\n> refs/heads/devel\n> $ ls -l .git/`git rev-parse --symbolic-full-name devel`\n> -rw-rw-r-- 1 stas stas 41 июл 21 15:05 .git/refs/heads/devel\n>\n> This is fine. But after git gc:\n>\n> $ git rev-parse --symbolic-full-name devel\n> refs/heads/devel\n> $ LC_ALL=C ls -l .git/`git rev-parse --symbolic-full-name devel`\n> ls: cannot access '.git/refs/heads/devel': No such file or directory\n\nThis is expected, and in the modern world (like, after year 2007),\na refname \"refs/heads/foo\" does *not* mean that there is a file\nwith such a path under .git/ directory.  \"rev-parse\" does not return\nany \"path\" in the filesystem sense.\n\nSee \"git pack-refs --help\", and depending on what you want to learn\nabout the ref in question, perhaps \"git show-ref refs/heads/devel\"\nis what you want.\n\n"},{"id":"324883","messageId":"223fa7c7-196d-e4fe-85b5-7d7cc576aa52@list.ru","threadId":"46437","inReplyTo":"xmqqbmodhb5h.fsf@gitster.mtv.corp.google.com","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-21T19:03:02Z","receivedAt":"2017-07-21T19:03:12Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"21.07.2017 21:56, Junio C Hamano пишет:\n> Stas Sergeev <stsp@list.ru> writes:\n>\n>> I do the following:\n>>\n>> $ git rev-parse --symbolic-full-name devel\n>> refs/heads/devel\n>> $ ls -l .git/`git rev-parse --symbolic-full-name devel`\n>> -rw-rw-r-- 1 stas stas 41 июл 21 15:05 .git/refs/heads/devel\n>>\n>> This is fine. But after git gc:\n>>\n>> $ git rev-parse --symbolic-full-name devel\n>> refs/heads/devel\n>> $ LC_ALL=C ls -l .git/`git rev-parse --symbolic-full-name devel`\n>> ls: cannot access '.git/refs/heads/devel': No such file or directory\n> This is expected, and in the modern world (like, after year 2007),\n> a refname \"refs/heads/foo\" does *not* mean that there is a file\n> with such a path under .git/ directory.  \"rev-parse\" does not return\n> any \"path\" in the filesystem sense.\n>\n> See \"git pack-refs --help\", and depending on what you want to learn\n> about the ref in question, perhaps \"git show-ref refs/heads/devel\"\n> is what you want.\nI wanted some kind of file to use it as a\nbuild dependency for the files that needs\nto be re-built when the head changes.\nThis works very well besides git gc.\nWhat other method can be used as simply\nas that? git show-ref does not seem to be\ngiving this.\n"},{"id":"324911","messageId":"CA+P7+xrhLf9eS_KkxTmWZgQ+Ho8VN83GS-OvxmboZ=_iY4dY0g@mail.gmail.com","threadId":"46437","inReplyTo":"223fa7c7-196d-e4fe-85b5-7d7cc576aa52@list.ru","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-07-23T08:40:08Z","receivedAt":"2017-07-23T08:43:12Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Jul 21, 2017 at 12:03 PM, Stas Sergeev <stsp@list.ru> wrote:\n> I wanted some kind of file to use it as a\n> build dependency for the files that needs\n> to be re-built when the head changes.\n> This works very well besides git gc.\n> What other method can be used as simply\n> as that? git show-ref does not seem to be\n> giving this.\n\nThere's no real way to do this, and even prior to 2007 when the file\nalways existed, there's no guarantee it's modification time is valid.\n\nI'd suggest you have a phony rule which you always run, that checks\nthe ref, and sees if it's different from \"last time\" and then updates\na different file if that's the case. Then the build can depend on the\ngenerated file, and you'd be able to figure it out.\n\nWhat's the real goal for depending on when the ref changes?\n\nThanks,\nJake\n"},{"id":"324918","messageId":"ed1ddfec-5782-d14b-6717-a1532efc0138@list.ru","threadId":"46437","inReplyTo":"CA+P7+xrhLf9eS_KkxTmWZgQ+Ho8VN83GS-OvxmboZ=_iY4dY0g@mail.gmail.com","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-23T19:23:28Z","receivedAt":"2017-07-23T19:29:46Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"23.07.2017 11:40, Jacob Keller пишет:\n> On Fri, Jul 21, 2017 at 12:03 PM, Stas Sergeev <stsp@list.ru> wrote:\n>> I wanted some kind of file to use it as a\n>> build dependency for the files that needs\n>> to be re-built when the head changes.\n>> This works very well besides git gc.\n>> What other method can be used as simply\n>> as that? git show-ref does not seem to be\n>> giving this.\n> There's no real way to do this, and even prior to 2007 when the file\n> always existed, there's no guarantee it's modification time is valid.\n>\n> I'd suggest you have a phony rule which you always run, that checks\n> the ref, and sees if it's different from \"last time\" and then updates\n> a different file if that's the case. Then the build can depend on the\n> generated file, and you'd be able to figure it out.\nOK, thanks, that looks quite simple too.\nI will have to create the file by hands that\nI expected git to already have, but it appears\nnot.\n\n> What's the real goal for depending on when the ref changes?\nSo that when users fill in the bug report, I can\nsee at what revision have the bug happened. :)\nWhile seemingly \"just a debugging sugar\", the\nhard experience shows this to be exceptionally\nuseful.\nI think even linux kernel does something like\nthis, and solves that task the hard way. For\nexample I can see a script at scripts/setlocalversion\nwhose output seems to go to\ninclude/config/kernel.release and a lot of\nlogic in the toplevel makefile about this.\nSo not liking the fact that every project solves\nthis differently, I was trying to get the solution\ndirectly from git. But I'll try otherwise.\n"},{"id":"324934","messageId":"CA+P7+xrpKTuBTueyGGVz4doWMnbGQo+2qj2wbpPvXBaW-iDV2w@mail.gmail.com","threadId":"46437","inReplyTo":"ed1ddfec-5782-d14b-6717-a1532efc0138@list.ru","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-07-24T04:02:26Z","receivedAt":"2017-07-24T04:02:53Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Jul 23, 2017 at 12:23 PM, Stas Sergeev <stsp@list.ru> wrote:\n> 23.07.2017 11:40, Jacob Keller пишет:\n>>\n>> On Fri, Jul 21, 2017 at 12:03 PM, Stas Sergeev <stsp@list.ru> wrote:\n>>>\n>>> I wanted some kind of file to use it as a\n>>> build dependency for the files that needs\n>>> to be re-built when the head changes.\n>>> This works very well besides git gc.\n>>> What other method can be used as simply\n>>> as that? git show-ref does not seem to be\n>>> giving this.\n>>\n>> There's no real way to do this, and even prior to 2007 when the file\n>> always existed, there's no guarantee it's modification time is valid.\n>>\n>> I'd suggest you have a phony rule which you always run, that checks\n>> the ref, and sees if it's different from \"last time\" and then updates\n>> a different file if that's the case. Then the build can depend on the\n>> generated file, and you'd be able to figure it out.\n>\n> OK, thanks, that looks quite simple too.\n> I will have to create the file by hands that\n> I expected git to already have, but it appears\n> not.\n>\n>> What's the real goal for depending on when the ref changes?\n>\n> So that when users fill in the bug report, I can\n> see at what revision have the bug happened. :)\n> While seemingly \"just a debugging sugar\", the\n> hard experience shows this to be exceptionally\n> useful.\n> I think even linux kernel does something like\n> this, and solves that task the hard way. For\n> example I can see a script at scripts/setlocalversion\n> whose output seems to go to\n> include/config/kernel.release and a lot of\n> logic in the toplevel makefile about this.\n> So not liking the fact that every project solves\n> this differently, I was trying to get the solution\n> directly from git. But I'll try otherwise.\n\ngenerally, I'd suggest using \"git describe\" to output a version based\non tag, and as part of your build system set that in some sort of\n--version output of some kind.\n\nThanks,\nJake\n"},{"id":"324948","messageId":"47a657a1-422d-5947-87bb-8e5db5b8689b@list.ru","threadId":"46437","inReplyTo":"CA+P7+xrpKTuBTueyGGVz4doWMnbGQo+2qj2wbpPvXBaW-iDV2w@mail.gmail.com","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-24T12:50:00Z","receivedAt":"2017-07-24T12:50:22Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"24.07.2017 07:02, Jacob Keller пишет:\n> generally, I'd suggest using \"git describe\" to output a version based\n> on tag, and as part of your build system set that in some sort of\n> --version output of some kind.\nI am not sure I understand that suggestion.\nI can use 'git describe' (and that seems to be\nwhat linux kernel does too), but I don't see\nhow can I get away without a temporary file,\nmaually comparing current 'git describe' with\nthe one stored, and updating that file in case\nof a mismatch.\nCould you please clarify? Maybe I am missing\nsome makefile trick which you assume I am\naware about. :)\n"},{"id":"325108","messageId":"60331e4f-93a7-5ceb-1443-41212b9fb945@list.ru","threadId":"46437","inReplyTo":"CA+P7+xrpKTuBTueyGGVz4doWMnbGQo+2qj2wbpPvXBaW-iDV2w@mail.gmail.com","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-26T00:21:17Z","receivedAt":"2017-07-26T00:21:31Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"24.07.2017 07:02, Jacob Keller пишет:\n> generally, I'd suggest using \"git describe\" to output a version based\n> on tag, and as part of your build system set that in some sort of\n> --version output of some kind.\nI came to the following solution which\nlooks quite simple (avoids comparing the\noutput of git describe):\ngit log -1 --format=%cd --date=rfc | xargs -I {} touch --date={} $TSTAMP\n\nThe care must be taken to put the timestamp\nfile as a pre-requisite of the .LOW_RESOLUTION_TIME\ntarget, and the build seems to work properly.\nThis still smells hackish, but this time I blame\nmake for an inability to specify the timestamps\nexplicitly. :)\n"},{"id":"325109","messageId":"CA+P7+xock9gpYVtxj2n6L5Y9dO1VV01OEOT5i0MR7ay68yS+WQ@mail.gmail.com","threadId":"46437","inReplyTo":"ed1ddfec-5782-d14b-6717-a1532efc0138@list.ru","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-07-26T00:36:04Z","receivedAt":"2017-07-26T00:36:31Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Sun, Jul 23, 2017 at 12:23 PM, Stas Sergeev <stsp@list.ru> wrote:\n> 23.07.2017 11:40, Jacob Keller пишет:\n>>\n>> On Fri, Jul 21, 2017 at 12:03 PM, Stas Sergeev <stsp@list.ru> wrote:\n>>>\n>>> I wanted some kind of file to use it as a\n>>> build dependency for the files that needs\n>>> to be re-built when the head changes.\n>>> This works very well besides git gc.\n>>> What other method can be used as simply\n>>> as that? git show-ref does not seem to be\n>>> giving this.\n>>\n>> There's no real way to do this, and even prior to 2007 when the file\n>> always existed, there's no guarantee it's modification time is valid.\n>>\n>> I'd suggest you have a phony rule which you always run, that checks\n>> the ref, and sees if it's different from \"last time\" and then updates\n>> a different file if that's the case. Then the build can depend on the\n>> generated file, and you'd be able to figure it out.\n>\n> OK, thanks, that looks quite simple too.\n> I will have to create the file by hands that\n> I expected git to already have, but it appears\n> not.\n>\n>> What's the real goal for depending on when the ref changes?\n>\n> So that when users fill in the bug report, I can\n> see at what revision have the bug happened. :)\n> While seemingly \"just a debugging sugar\", the\n> hard experience shows this to be exceptionally\n> useful.\n> I think even linux kernel does something like\n> this, and solves that task the hard way. For\n> example I can see a script at scripts/setlocalversion\n> whose output seems to go to\n> include/config/kernel.release and a lot of\n> logic in the toplevel makefile about this.\n> So not liking the fact that every project solves\n> this differently, I was trying to get the solution\n> directly from git. But I'll try otherwise.\n\nIf your goal is to make it so users filling out bug reports have a\nversion, then using git descrsibe and making that be part of your\nversion (based off your tags, and commits) is how pretty much every\nother project I've worked on does this.\n\nI really don't think that's your goal here, given you're doing things\nin make with timestamps and builds, so I guess I misunderstood your\nanswer?\n\nThanks,\nJake\n"},{"id":"325115","messageId":"a6738cae-ad8d-cf51-0fbb-428cf0f88703@list.ru","threadId":"46437","inReplyTo":"CA+P7+xock9gpYVtxj2n6L5Y9dO1VV01OEOT5i0MR7ay68yS+WQ@mail.gmail.com","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-26T08:40:46Z","receivedAt":"2017-07-26T08:41:01Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"26.07.2017 03:36, Jacob Keller пишет:\n> If your goal is to make it so users filling out bug reports have a\n> version, then using git descrsibe and making that be part of your\n> version (based off your tags, and commits) is how pretty much every\n> other project I've worked on does this.\n>\n> I really don't think that's your goal here, given you're doing things\n> in make with timestamps and builds, so I guess I misunderstood your\n> answer?\nThere are 2 different things:\n1. put git describe output into some header file\n2. make things to rebuild with every new commit\n\nSo I actually stuck at solving 2, because 1 is trivial.\nMy original solution for 2 was to \"depend\" on\nrefs/heads/*. This worked besides git gc, but had\na lot of troubles with worktrees. And this time I\nswitched to the \"touch tmpfile\" trick with the date\ntaken from git log. This requires .LOW_RESOLUTION_TIME\nin makefile, so probably not the best solution again,\nbut should hopefully be more future-proof than the\nprevious one.\n"},{"id":"325125","messageId":"20170726132322.4cfj73tynrko264o@sigill.intra.peff.net","threadId":"46437","inReplyTo":"a6738cae-ad8d-cf51-0fbb-428cf0f88703@list.ru","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-07-26T13:23:23Z","receivedAt":"2017-07-26T13:23:29Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 26, 2017 at 11:40:46AM +0300, Stas Sergeev wrote:\n\n> 26.07.2017 03:36, Jacob Keller пишет:\n> > If your goal is to make it so users filling out bug reports have a\n> > version, then using git descrsibe and making that be part of your\n> > version (based off your tags, and commits) is how pretty much every\n> > other project I've worked on does this.\n> > \n> > I really don't think that's your goal here, given you're doing things\n> > in make with timestamps and builds, so I guess I misunderstood your\n> > answer?\n> There are 2 different things:\n> 1. put git describe output into some header file\n> 2. make things to rebuild with every new commit\n> \n> So I actually stuck at solving 2, because 1 is trivial.\n> My original solution for 2 was to \"depend\" on\n> refs/heads/*. This worked besides git gc, but had\n> a lot of troubles with worktrees. And this time I\n> switched to the \"touch tmpfile\" trick with the date\n> taken from git log. This requires .LOW_RESOLUTION_TIME\n> in makefile, so probably not the best solution again,\n> but should hopefully be more future-proof than the\n> previous one.\n\nIn git.git we do something like:\n\n-- >8 --\nother: version\n\tcat $< >$@\n\n.PHONY: FORCE\nversion: FORCE\n\t@git rev-parse HEAD >$@+\n\t@if cmp $@+ $@ >/dev/null 2>&1; then rm $@+; else mv $@+ $@; fi\n-- >8 --\n\nThe \"version\" commands run always, but they only update the file if\nthere's a change. At least GNU make is smart enough to know that if\n\"version\" was not updated, then \"other\" does not need to be re-built.\nI don't know if all makes would so, though.\n\n-Peff\n"},{"id":"325127","messageId":"5b86f0e2-b44f-a3ea-bb66-c7826619773b@list.ru","threadId":"46437","inReplyTo":"20170726132322.4cfj73tynrko264o@sigill.intra.peff.net","subject":"Re: git gc seems to break --symbolic-full-name","fromName":"Stas Sergeev","fromEmail":"stsp@list.ru","sentAt":"2017-07-26T14:08:01Z","receivedAt":"2017-07-26T15:06:30Z","isPatch":false,"sender":{"key":"stsp@list.ru","avatar":null},"body":"26.07.2017 16:23, Jeff King пишет:\n> In git.git we do something like:\n>\n> -- >8 --\n> other: version\n> \tcat $< >$@\n>\n> .PHONY: FORCE\n> version: FORCE\n> \t@git rev-parse HEAD >$@+\n> \t@if cmp $@+ $@ >/dev/null 2>&1; then rm $@+; else mv $@+ $@; fi\n> -- >8 --\nYes, thats a nice recipe that I would be using\nif not for the fact that I already switched to\n\"touch\", which requires 1 fewer tmp file and\nno comparison.\nBut I'll keep this in mind if something wrong\nhappens with my current solution, thanks!\nI wonder if git can provide some helper script\nfor other projects to solve this in a same way.\n"}]}