{"thread":{"id":"19225","subject":"[PATCH v3] To make GIT-VERSION-FILE, search for git more widely","startedAt":"2009-05-07T09:22:09Z","lastAt":"2009-06-04T08:35:58Z","messageCount":22,"participants":["Matthias Andree","Michael J Gruber","Junio C Hamano","Johannes Sixt","Francis Galiegue","Nanako Shiraishi"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"113198","messageId":"1241688129-31613-1-git-send-email-matthias.andree@gmx.de","threadId":"19225","inReplyTo":null,"subject":"[PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-07T09:22:09Z","receivedAt":"2009-05-07T09:22:09Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Situation: sudo make install rebuilds the whole package even if you've just\nbuilt it before. For instance:\n\nmake configure\n./configure    # defaults to --prefix=/usr/local\nmake all doc\nsudo make install install-doc install-html # REBUILDS HAPPEN HERE\n\nThis causes the \"sudo make install\" to rebuild everything because it believes\nthe version had changed.\nsudo strips $PATH for security reasons.\n\nThe underlying problem flow is:\n\n1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n    GIT-VERSION-FILE early.\n\n2 - GIT-VERSION-FILE depends on a .PHONY target (.FORCE-GIT-VERSION-FILE)\n3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n    sees a different version number.\n5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n    GIT-VERSION-FILE, with up-to-date timestamp.\n6 - GNU make rebuilds everything because GIT-VERSION-FILE is new.\n\nThe patch makes GIT-VERSION-GEN look for the current built git$X executable,\nand in $(prefix)/bin/git, before falling back to plain \"git\" and thus to the\ndefault version in GIT-VERSION-GEN.\n\nSigned-off-by: Matthias Andree <matthias.andree@gmx.de>\n---\n GIT-VERSION-GEN |    9 ++++-----\n Makefile        |    6 +++++-\n 2 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 39cde78..d0dfef3 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -2,6 +2,7 @@\n \n GVF=GIT-VERSION-FILE\n DEF_VER=v1.6.3.GIT\n+test -x \"$GIT\" || GIT=git\n \n LF='\n '\n@@ -12,12 +13,12 @@ if test -f version\n then\n \tVN=$(cat version) || VN=\"$DEF_VER\"\n elif test -d .git -o -f .git &&\n-\tVN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n+\tVN=$($GIT describe --abbrev=4 HEAD 2>/dev/null) &&\n \tcase \"$VN\" in\n \t*$LF*) (exit 1) ;;\n \tv[0-9]*)\n-\t\tgit update-index -q --refresh\n-\t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n+\t\t$GIT update-index -q --refresh\n+\t\ttest -z \"$($GIT diff-index --name-only HEAD --)\" ||\n \t\tVN=\"$VN-dirty\" ;;\n \tesac\n then\n@@ -38,5 +39,3 @@ test \"$VN\" = \"$VC\" || {\n \techo >&2 \"GIT_VERSION = $VN\"\n \techo \"GIT_VERSION = $VN\" >$GVF\n }\n-\n-\ndiff --git a/Makefile b/Makefile\nindex 6e21643..d6be483 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -177,7 +177,11 @@ all::\n # away (some NTFS drivers seem to zero the contents in that scenario).\n \n GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n-\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n+\t@{ GIT=./git$X ; test -x \"$$GIT\" ; } \\\n+\t    || { GIT=$(prefix)/bin/git$X ; test -x \"$$GIT\" ; }\\\n+\t    || GIT=git ; \\\n+\t    export GIT ; \\\n+\t    $(SHELL_PATH) ./GIT-VERSION-GEN\n -include GIT-VERSION-FILE\n \n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n-- \n1.6.3.1.geabc3\n"},{"id":"113203","messageId":"4A02CAD9.9080808@drmicha.warpmail.net","threadId":"19225","inReplyTo":"1241688129-31613-1-git-send-email-matthias.andree@gmx.de","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-07T11:49:45Z","receivedAt":"2009-05-07T11:49:45Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Matthias Andree venit, vidit, dixit 07.05.2009 11:22:\n> Situation: sudo make install rebuilds the whole package even if you've just\n> built it before. For instance:\n> \n> make configure\n> ./configure    # defaults to --prefix=/usr/local\n> make all doc\n> sudo make install install-doc install-html # REBUILDS HAPPEN HERE\n> \n> This causes the \"sudo make install\" to rebuild everything because it believes\n> the version had changed.\n> sudo strips $PATH for security reasons.\n> \n> The underlying problem flow is:\n> \n> 1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n>     GIT-VERSION-FILE early.\n> \n> 2 - GIT-VERSION-FILE depends on a .PHONY target (.FORCE-GIT-VERSION-FILE)\n> 3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n> 4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n>     sees a different version number.\n> 5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n>     GIT-VERSION-FILE, with up-to-date timestamp.\n> 6 - GNU make rebuilds everything because GIT-VERSION-FILE is new.\n> \n> The patch makes GIT-VERSION-GEN look for the current built git$X executable,\n> and in $(prefix)/bin/git, before falling back to plain \"git\" and thus to the\n> default version in GIT-VERSION-GEN.\n\nThanks for the detailed analysis, now I g[oi]t it!\nAccording to the analysis, the problem would also appear with a standard\nmake run (without configure) as long as git is not in the sudoer's $PATH\n($prefix isn't, no distro git in /usr).\n\n> Signed-off-by: Matthias Andree <matthias.andree@gmx.de>\n> ---\n>  GIT-VERSION-GEN |    9 ++++-----\n>  Makefile        |    6 +++++-\n>  2 files changed, 9 insertions(+), 6 deletions(-)\n> \n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index 39cde78..d0dfef3 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -2,6 +2,7 @@\n>  \n>  GVF=GIT-VERSION-FILE\n>  DEF_VER=v1.6.3.GIT\n> +test -x \"$GIT\" || GIT=git\n>  \n>  LF='\n>  '\n> @@ -12,12 +13,12 @@ if test -f version\n>  then\n>  \tVN=$(cat version) || VN=\"$DEF_VER\"\n>  elif test -d .git -o -f .git &&\n> -\tVN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n> +\tVN=$($GIT describe --abbrev=4 HEAD 2>/dev/null) &&\n>  \tcase \"$VN\" in\n>  \t*$LF*) (exit 1) ;;\n>  \tv[0-9]*)\n> -\t\tgit update-index -q --refresh\n> -\t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n> +\t\t$GIT update-index -q --refresh\n> +\t\ttest -z \"$($GIT diff-index --name-only HEAD --)\" ||\n>  \t\tVN=\"$VN-dirty\" ;;\n>  \tesac\n>  then\n> @@ -38,5 +39,3 @@ test \"$VN\" = \"$VC\" || {\n>  \techo >&2 \"GIT_VERSION = $VN\"\n>  \techo \"GIT_VERSION = $VN\" >$GVF\n>  }\n> -\n> -\n> diff --git a/Makefile b/Makefile\n> index 6e21643..d6be483 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -177,7 +177,11 @@ all::\n>  # away (some NTFS drivers seem to zero the contents in that scenario).\n>  \n>  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n> -\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n> +\t@{ GIT=./git$X ; test -x \"$$GIT\" ; } \\\n> +\t    || { GIT=$(prefix)/bin/git$X ; test -x \"$$GIT\" ; }\\\n> +\t    || GIT=git ; \\\n> +\t    export GIT ; \\\n> +\t    $(SHELL_PATH) ./GIT-VERSION-GEN\n>  -include GIT-VERSION-FILE\n>  \n>  uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n\nLooks good to me. So, untested but reviewed by me.\n\nMichael\n"},{"id":"113207","messageId":"op.utj6ikav1e62zd@balu","threadId":"19225","inReplyTo":"4A02CAD9.9080808@drmicha.warpmail.net","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-07T12:04:59Z","receivedAt":"2009-05-07T12:04:59Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 07.05.2009, 13:49 Uhr, schrieb Michael J Gruber  \n<git@drmicha.warpmail.net>:\n\n> Matthias Andree venit, vidit, dixit 07.05.2009 11:22:\n> ...\n>> The underlying problem flow is:\n>>\n>> 1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n>>     GIT-VERSION-FILE early.\n>> 2 - GIT-VERSION-FILE depends on a .PHONY target  \n>> (.FORCE-GIT-VERSION-FILE)\n>> 3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n>> 4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n>>     sees a different version number.\n>> 5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n>>     GIT-VERSION-FILE, with up-to-date timestamp.\n>> 6 - GNU make rebuilds everything because GIT-VERSION-FILE is new.\n>>\n>> The patch makes GIT-VERSION-GEN look for the current built git$X  \n>> executable,\n>> and in $(prefix)/bin/git, before falling back to plain \"git\" and thus  \n>> to the\n>> default version in GIT-VERSION-GEN.\n>\n> Thanks for the detailed analysis, now I g[oi]t it!\n> According to the analysis, the problem would also appear with a standard\n> make run (without configure) as long as git is not in the sudoer's $PATH\n> ($prefix isn't, no distro git in /usr).\n\nI am not sure how useful /this/ example is -- prefix=$HOME is default, no  \nsudo required. make prefix=/opt/git might be a point though.\n\n> [commit/diff]\n> Looks good to me. So, untested but reviewed by me.\n\nThanks.\n\n-- \nMatthias Andree\n"},{"id":"113208","messageId":"4A02CF67.1010401@drmicha.warpmail.net","threadId":"19225","inReplyTo":"op.utj6ikav1e62zd@balu","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-07T12:09:11Z","receivedAt":"2009-05-07T12:09:11Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Matthias Andree venit, vidit, dixit 07.05.2009 14:04:\n> Am 07.05.2009, 13:49 Uhr, schrieb Michael J Gruber  \n> <git@drmicha.warpmail.net>:\n> \n>> Matthias Andree venit, vidit, dixit 07.05.2009 11:22:\n>> ...\n>>> The underlying problem flow is:\n>>>\n>>> 1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n>>>     GIT-VERSION-FILE early.\n>>> 2 - GIT-VERSION-FILE depends on a .PHONY target  \n>>> (.FORCE-GIT-VERSION-FILE)\n>>> 3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n>>> 4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n>>>     sees a different version number.\n>>> 5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n>>>     GIT-VERSION-FILE, with up-to-date timestamp.\n>>> 6 - GNU make rebuilds everything because GIT-VERSION-FILE is new.\n>>>\n>>> The patch makes GIT-VERSION-GEN look for the current built git$X  \n>>> executable,\n>>> and in $(prefix)/bin/git, before falling back to plain \"git\" and thus  \n>>> to the\n>>> default version in GIT-VERSION-GEN.\n>>\n>> Thanks for the detailed analysis, now I g[oi]t it!\n>> According to the analysis, the problem would also appear with a standard\n>> make run (without configure) as long as git is not in the sudoer's $PATH\n>> ($prefix isn't, no distro git in /usr).\n> \n> I am not sure how useful /this/ example is -- prefix=$HOME is default, no  \n> sudo required. make prefix=/opt/git might be a point though.\n\nThat's what I meant by my admittedly fuzzy \"$prefix isn't\".\n\nI just wanted to point out that your PATCH fixes an easy which also\n\"ordinary\" make usage (with prefix and sudo) has, because\nautoconf/configure is considered a 2nd class citizen.\n\n>> [commit/diff]\n>> Looks good to me. So, untested but reviewed by me.\n> \n> Thanks.\n> \n\nCheers,\nMichael\n"},{"id":"113209","messageId":"op.utj6vxqb1e62zd@balu","threadId":"19225","inReplyTo":"4A02CF67.1010401@drmicha.warpmail.net","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-07T12:12:59Z","receivedAt":"2009-05-07T12:12:59Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 07.05.2009, 14:09 Uhr, schrieb Michael J Gruber  \n<git@drmicha.warpmail.net>:\n\n> I just wanted to point out that your PATCH fixes an easy which also\n> \"ordinary\" make usage (with prefix and sudo) has, because\n> autoconf/configure is considered a 2nd class citizen.\n\nWell, configure is documented, so I don't care about the fare it pays for  \ntravelling the git.git repo. :-) I could probably also drop  \n\"prefix=/usr/local\" in config.mak or thereabouts and no longer care about  \nautoconf (that's the only I use it for).\n\n-- \nMatthias Andree\n"},{"id":"113288","messageId":"7v7i0scvcf.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"1241688129-31613-1-git-send-email-matthias.andree@gmx.de","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-08T00:05:36Z","receivedAt":"2009-05-08T00:05:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Andree <matthias.andree@gmx.de> writes:\n\n> The underlying problem flow is:\n>\n> 1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n>     GIT-VERSION-FILE early.\n>\n> 2 - GIT-VERSION-FILE depends on a .PHONY target (.FORCE-GIT-VERSION-FILE)\n> 3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n> 4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n>     sees a different version number.\n> 5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n>     GIT-VERSION-FILE, with up-to-date timestamp.\n\nInteresting.  I wonder if you need the change to the Makefile.\n\nAs long as GIT-VERSION-GEN notices that you have a freshly built git\navailable (test -x) and uses it, falling back to whatever on the PATH, it\nwould not have to touch GIT-VERSION-FILE, no?\n\nIOW, instead of this:\n\n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index 39cde78..d0dfef3 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -2,6 +2,7 @@\n>  \n>  GVF=GIT-VERSION-FILE\n>  DEF_VER=v1.6.3.GIT\n> +test -x \"$GIT\" || GIT=git\n\nwouldn't it make more sense to do\n\n\tif test -x \"git\"\n        then\n        \tGIT=./git\n\telif test -x \"git.exe\"\n        then\n        \tGIT=./git.exe\n\telse\n        \tGIT=git\n\tfi\n\nand use the rest of the patch to GIT-VERSION-GEN, without touching\nMakefile at all?\n"},{"id":"113326","messageId":"op.utlq3vgx1e62zd@merlin.emma.line.org","threadId":"19225","inReplyTo":"7v7i0scvcf.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-08T08:27:21Z","receivedAt":"2009-05-08T08:27:21Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 08.05.2009, 02:05 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n\n> Matthias Andree <matthias.andree@gmx.de> writes:\n>\n>> The underlying problem flow is:\n>>\n>> 1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n>>     GIT-VERSION-FILE early.\n>>\n>> 2 - GIT-VERSION-FILE depends on a .PHONY target  \n>> (.FORCE-GIT-VERSION-FILE)\n>> 3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n>> 4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n>>     sees a different version number.\n>> 5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n>>     GIT-VERSION-FILE, with up-to-date timestamp.\n>\n> Interesting.  I wonder if you need the change to the Makefile.\n>\n> As long as GIT-VERSION-GEN notices that you have a freshly built git\n> available (test -x) and uses it, falling back to whatever on the PATH, it\n> would not have to touch GIT-VERSION-FILE, no?\n\nHi Junio,\n\nMakefile (+ GNU make) is the actual culprit and introduces this cycle, why  \ndo we want to leave Makefile - of all things - alone?\n\nMakefile also has all the info: (1) locations, for VPATH builds, (2)  \n$(prefix), (3) $X (extension), so let's have it communicate that (through  \nthe $GIT variable). Let's not introduce second-guessing into the script.  \nIt would be error prone and manually duplicates efforts that either are  \nalready there or are automatic in Makefile. G-V-GEN is run under  \nMakefile's control, so let's steer it into the right direction.\n\nThe G-V-GEN test -x is only there to fall back to a path search if the  \nvariable is unset when running things directly, rather than through make.\n\nHTH\nMatthias\n\n> IOW, instead of this:\n>\n>> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n>> index 39cde78..d0dfef3 100755\n>> --- a/GIT-VERSION-GEN\n>> +++ b/GIT-VERSION-GEN\n>> @@ -2,6 +2,7 @@\n>>\n>>  GVF=GIT-VERSION-FILE\n>>  DEF_VER=v1.6.3.GIT\n>> +test -x \"$GIT\" || GIT=git\n>\n> wouldn't it make more sense to do\n>\n> \tif test -x \"git\"\n>         then\n>         \tGIT=./git\n> \telif test -x \"git.exe\"\n>         then\n>         \tGIT=./git.exe\n> \telse\n>         \tGIT=git\n> \tfi\n>\n> and use the rest of the patch to GIT-VERSION-GEN, without touching\n> Makefile at all?\n\n\n\n-- \nMatthias Andree\n"},{"id":"113329","messageId":"7vprek0ywq.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"op.utlq3vgx1e62zd@merlin.emma.line.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-08T08:41:41Z","receivedAt":"2009-05-08T08:41:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Matthias Andree\" <matthias.andree@gmx.de> writes:\n\n>> Interesting.  I wonder if you need the change to the Makefile.\n>>\n>> As long as GIT-VERSION-GEN notices that you have a freshly built git\n>> available (test -x) and uses it, falling back to whatever on the PATH, it\n>> would not have to touch GIT-VERSION-FILE, no?\n>\n> Hi Junio,\n>\n> ... Let's not introduce second-guessing into\n> the script....\n\nFine then.  Or you could just append \".\" to the $PATH ;-)\n"},{"id":"113331","messageId":"4A03F2E8.2020907@viscovery.net","threadId":"19225","inReplyTo":"op.utlq3vgx1e62zd@merlin.emma.line.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-08T08:52:56Z","receivedAt":"2009-05-08T08:52:56Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Matthias Andree schrieb:\n> Am 08.05.2009, 02:05 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n>> Interesting.  I wonder if you need the change to the Makefile.\n>>\n>> As long as GIT-VERSION-GEN notices that you have a freshly built git\n>> available (test -x) and uses it, falling back to whatever on the PATH, it\n>> would not have to touch GIT-VERSION-FILE, no?\n> \n> Hi Junio,\n> \n> Makefile (+ GNU make) is the actual culprit and introduces this cycle,\n> why do we want to leave Makefile - of all things - alone?\n\nBecause it is not necessary to change it?\n\nWith Junio's proposed change the following:\n\n   $ make && PATH=/bin:/usr/bin make\n\nbuilds only once[*], whereas previously it built twice.\n\n[*] It still builds twice in git-gui, but I think that your original patch\nwouldn't fix that, either.\n\n-- Hannes\n"},{"id":"113340","messageId":"op.utlylkb61e62zd@balu","threadId":"19225","inReplyTo":"7vprek0ywq.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-08T11:09:11Z","receivedAt":"2009-05-08T11:09:11Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 08.05.2009, 10:41 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n\n> \"Matthias Andree\" <matthias.andree@gmx.de> writes:\n>\n>>> Interesting.  I wonder if you need the change to the Makefile.\n>>>\n>>> As long as GIT-VERSION-GEN notices that you have a freshly built git\n>>> available (test -x) and uses it, falling back to whatever on the PATH,  \n>>> it\n>>> would not have to touch GIT-VERSION-FILE, no?\n>>\n>> Hi Junio,\n>>\n>> ... Let's not introduce second-guessing into\n>> the script....\n>\n> Fine then.  Or you could just append \".\" to the $PATH ;-)\n\n\".\" in the super user's PATH? Cool stuff, and so innovative. Economy  \ncrisis special offer - get the barndoor-sized hole for a piece bird dung.  \nSpecial offer valid only today, while stocks last...\n\nSCNR.\n\n-- \nMatthias Andree\n"},{"id":"113417","messageId":"7vskje6wsy.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"op.utlylkb61e62zd@balu","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-09T16:55:09Z","receivedAt":"2009-05-09T16:55:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Matthias Andree\" <matthias.andree@gmx.de> writes:\n\n>> Fine then.  Or you could just append \".\" to the $PATH ;-)\n>\n> \".\" in the super user's PATH? Cool stuff, and so innovative.\n\nI didn't mean to suggest PATH=$PATH:. *in the user's environment* ;-).\nYou do that inside GIT-VERSION-FILE, which is essentially the same thing\nas running ./git$X from there.\n\nWhat's innovative is whoever is running build as root.\n"},{"id":"113418","messageId":"200905091910.46775.fge@one2team.com","threadId":"19225","inReplyTo":"7vskje6wsy.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Francis Galiegue","fromEmail":"fge@one2team.com","sentAt":"2009-05-09T17:10:46Z","receivedAt":"2009-05-09T17:10:46Z","isPatch":true,"sender":{"key":"fge@one2team.com","avatar":null},"body":"Le Saturday 09 May 2009 18:55:09 Junio C Hamano, vous avez écrit :\n[...]\n>\n> What's innovative is whoever is running build as root.\n>\n\nWell, maybe not if you just download the source and use \nthe \"configure/make/make install\" trinity. But when it comes to packaging, \nit's another story.\n\nI've been doing RPM packaging for quite a few years. I have been fortunate \nenough that my first job was with a Linux distribution (it was called \nMandrake at the time) and, first things first, they taught me how to set up \nan RPM environment to build as a regular user.\n\nBelieve it or not, but even as of today, in 2009, neither RHEL or its \nimmediate derivative (CentOS) manage to build a decent set of rules to build \nas a non-root user. You have to make your own $HOME/.rpmmacros at the very \nleast. So, unless you are a skilled enough packager, you cannot even build a \npackage as a regular user. And some packages out there DO require skills as a \npackager to just be built as packages (qmail is one example).\n\nAnd even as a regular user, and even though you can, say, alter all \nof /usr/local to be writeable by someone else than root, I wouldn't be \nsurprised to hear that a LOT of Linux beginners, seeing that \"make install \ndoesn't work\", resort to being root instead. Because it is a known fact that \nroot can do everything.\n\nInnovative? Not that much.\n\n-- \nFrancis Galiegue\nfge@one2team.com\nIngénieur système\nMob : +33 (0) 683 877 875\nTel : +33 (0) 178 945 552\nOne2team\n40 avenue Raymond Poincaré\n75116 Paris\n"},{"id":"113419","messageId":"op.utoc2njr1e62zd@merlin.emma.line.org","threadId":"19225","inReplyTo":"7vskje6wsy.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-09T18:17:01Z","receivedAt":"2009-05-09T18:17:01Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 09.05.2009, 18:55 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n\n> \"Matthias Andree\" <matthias.andree@gmx.de> writes:\n>\n>>> Fine then.  Or you could just append \".\" to the $PATH ;-)\n>>\n>> \".\" in the super user's PATH? Cool stuff, and so innovative.\n>\n> I didn't mean to suggest PATH=$PATH:. *in the user's environment* ;-).\n> You do that inside GIT-VERSION-FILE, which is essentially the same thing\n> as running ./git$X from there.\n>\n> What's innovative is whoever is running build as root.\n\nBack to the real problem, and that is re-checking GIT-VERSION-FILE as part\nof \"make install\". I wonder if we should just have GIT-VERSION-GEN exit if\ngit isn't in $PATH, and at most copy version there -- rather than stomp\nthe DEF_VER somewhere.\n\n-- \nMatthias Andree\n"},{"id":"113781","messageId":"op.utva2vxh1e62zd@balu","threadId":"19225","inReplyTo":"7vskje6wsy.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-05-13T12:17:09Z","receivedAt":"2009-05-13T12:17:09Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 09.05.2009, 18:55 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n\n> \"Matthias Andree\" <matthias.andree@gmx.de> writes:\n>\n>>> Fine then.  Or you could just append \".\" to the $PATH ;-)\n>>\n>> \".\" in the super user's PATH? Cool stuff, and so innovative.\n>\n> I didn't mean to suggest PATH=$PATH:. *in the user's environment* ;-).\n> You do that inside GIT-VERSION-FILE, which is essentially the same thing\n> as running ./git$X from there.\n\nNo, it is not -- the scope of the GIT variable is much narrower than doing  \nPATH=$PATH:. in the script.\n\nBTW, in the earlier version, I used type(1) to take $PATH search into  \naccount in case GIT=git; test -x does not do path search, unlike type.\n\n> What's innovative is whoever is running build as root.\n\nYes, and that is why I found the PATH-dependent behaviour so irritating  \nand wanted to fix it. I have another approach cooking that entails  \nfactoring out common code from ./git-gui/GIT-VERSION-GEN and  \n./GIT-VERSION-GEN into ./git-gui/GIT-VERSION-SUBR.\n\nFor any approach taken, we'll have to touch both the shell and the  \nMakefile, unless we want to manually redo things in the GIT-VERSION-GEN  \nscript that were already done automatically or programmatically in  \nMakefile.\n\nPlease let me know if you're willing to accept a patch that touches both  \nMakefile and the GIT-VERSION-* shell scripts. If you don't, I can quit  \nhere and not waste further time on submissions that are inacceptable  \nanyhow, but just keep rebasing my local patch instead.\n\nBest regards\n\n-- \nMatthias Andree\n"},{"id":"113829","messageId":"7vy6t03ik0.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"op.utva2vxh1e62zd@balu","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-13T19:32:31Z","receivedAt":"2009-05-13T19:32:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Matthias Andree\" <matthias.andree@gmx.de> writes:\n\n> Am 09.05.2009, 18:55 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n>\n>> \"Matthias Andree\" <matthias.andree@gmx.de> writes:\n>>\n>>>> Fine then.  Or you could just append \".\" to the $PATH ;-)\n>>>\n>>> \".\" in the super user's PATH? Cool stuff, and so innovative.\n>>\n>> I didn't mean to suggest PATH=$PATH:. *in the user's environment* ;-).\n>> You do that inside GIT-VERSION-FILE, which is essentially the same thing\n>> as running ./git$X from there.\n>\n> No, it is not -- the scope of the GIT variable is much narrower than\n> doing  PATH=$PATH:. in the script.\n\nIf you cannot trust the top of your build directory you build git in (that\nis why PATH=$PATH:. while running GIT-VERSION-FILE may be scary) and\nanticipate a malicious third-party can somehow put random things (like\n\"test\" or \"cat\", perhaps) there, you are already lost, don't you think?\n\nThat is where my \"essentially the same\" came from.\n\n> For any approach taken, we'll have to touch both the shell and the\n> Makefile, unless we want to manually redo things in the\n> GIT-VERSION-GEN  script that were already done automatically or\n> programmatically in  Makefile.\n\nI actually like the rationale you mentioned in the thread (perhaps in the\noriginal proposed commit message as well) that we should ask the freshly\nbuilt git to describe the version if available, falling back to whichever\ngit of random vintage found on the original $PATH.\n\nIf it weren't for $X [*1*], my preference would have been (as I said in\nthe discussion) to run ./git if available locally.\n\nBut I think your \"deal with details like $X to figure out the name of the\nfreshly built git binary is in the Makefile, and pass it via GIT variable\nto GIT-VERSION-GEN\" is a sensible approach.  I do not remember if your\npatch gave precedence to an installed git on the original $PATH or a\nfreshly built one, though---the precedent probably does not matter in\npractice, and favoring the one found on $PATH over freshly built one does\nhave an advantage if we were to support cross compilation (I have a\nsuspicion that the current setup does not).\n\nThanks.\n\n\n[Footnote]\n\n*1* ... and perhaps VPATH as you mentioned earlier, but I do not know if\nour current Makefile is set up to allow a layout that separates build\nproducts from the source material, as I've never attempted to build git in\na setting where VPATH is involved.\n"},{"id":"115234","messageId":"20090602195533.6117@nanako3.lavabit.com","threadId":"19225","inReplyTo":"7vy6t03ik0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-06-02T10:55:33Z","receivedAt":"2009-06-02T10:55:33Z","isPatch":true,"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> I actually like the rationale you mentioned in the thread (perhaps in the\n> original proposed commit message as well) that we should ask the freshly\n> built git to describe the version if available, falling back to whichever\n> git of random vintage found on the original $PATH.\n>\n> If it weren't for $X [*1*], my preference would have been (as I said in\n> the discussion) to run ./git if available locally.\n>\n> But I think your \"deal with details like $X to figure out the name of the\n> freshly built git binary is in the Makefile, and pass it via GIT variable\n> to GIT-VERSION-GEN\" is a sensible approach.  I do not remember if your\n> patch gave precedence to an installed git on the original $PATH or a\n> freshly built one, though---the precedent probably does not matter in\n> practice, and favoring the one found on $PATH over freshly built one does\n> have an advantage if we were to support cross compilation (I have a\n> suspicion that the current setup does not).\n>\n> Thanks.\n\nJunio, I think you forgot to take a follow-up action on this thread after sending this message.  The patch favors the git program in the current directory.\n\nDo you want to ask Matthias to resend the patch with an updated log message?\n\n\n\nP.S. a happy birthday ;-)\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"115256","messageId":"7v7hzufxcu.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"20090602195533.6117@nanako3.lavabit.com","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-02T15:50:57Z","receivedAt":"2009-06-02T15:50:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nanako Shiraishi <nanako3@lavabit.com> writes:\n\n> Quoting Junio C Hamano <gitster@pobox.com>:\n>\n>> I actually like the rationale you mentioned in the thread (perhaps in the\n>> original proposed commit message as well) that we should ask the freshly\n>> built git to describe the version if available, falling back to whichever\n>> git of random vintage found on the original $PATH.\n>>\n>> If it weren't for $X [*1*], my preference would have been (as I said in\n>> the discussion) to run ./git if available locally.\n>>\n>> But I think your \"deal with details like $X to figure out the name of the\n>> freshly built git binary is in the Makefile, and pass it via GIT variable\n>> to GIT-VERSION-GEN\" is a sensible approach.  I do not remember if your\n>> patch gave precedence to an installed git on the original $PATH or a\n>> freshly built one, though---the precedent probably does not matter in\n>> practice, and favoring the one found on $PATH over freshly built one does\n>> have an advantage if we were to support cross compilation (I have a\n>> suspicion that the current setup does not).\n>>\n>> Thanks.\n>\n> Junio, I think you forgot to take a follow-up action on this thread after sending this message.  The patch favors the git program in the current directory.\n\nIndeed, I did, and I think I am Ok with the patch.  Thanks for a\nreminder.\n\nI thought there was an \"simplicity\" issue raised by J6t that was not\naddressed, but after re-reading the thread I do not think it applies\n(J6t?)\n\n> Do you want to ask Matthias to resend the patch with an updated log message?\n\nThe proposed commit log message indeed does look somewhat incompatible\nwith the normal style of our log messages, but I think I can rewrite it.\n\n> P.S. a happy birthday ;-)\n\nHeh, depending on where you are, you are a day or so late, but thanks\nanyway.\n\n> -- \n> Nanako Shiraishi\n> http://ivory.ap.teacup.com/nanako3/\n"},{"id":"115266","messageId":"200906022035.30081.j6t@kdbg.org","threadId":"19225","inReplyTo":"7v7hzufxcu.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-06-02T18:35:29Z","receivedAt":"2009-06-02T18:35:29Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Dienstag, 2. Juni 2009, Junio C Hamano wrote:\n> Nanako Shiraishi <nanako3@lavabit.com> writes:\n> > Junio, I think you forgot to take a follow-up action on this thread after\n> > sending this message.  The patch favors the git program in the current\n> > directory.\n>\n> Indeed, I did, and I think I am Ok with the patch.  Thanks for a\n> reminder.\n>\n> I thought there was an \"simplicity\" issue raised by J6t that was not\n> addressed, but after re-reading the thread I do not think it applies\n> (J6t?)\n\nSorry, I don't recall anymore what I said; but since the thread petered out, I \nuse this patch in the repository where I share Matthias' 'sudo make install' \nproblem:\n\nSubject: [PATCH] version-gen: Use just built git if no other git is in PATH\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 39cde78..4779313 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -3,6 +3,9 @@\n GVF=GIT-VERSION-FILE\n DEF_VER=v1.6.3.GIT\n \n+# use git that was just compiled if there is no git elsewhere in PATH\n+PATH=$PATH:.\n+\n LF='\n '\n \n\n-- Hannes\n"},{"id":"115322","messageId":"op.uuxtvv1v1e62zd@merlin.emma.line.org","threadId":"19225","inReplyTo":"200906022035.30081.j6t@kdbg.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-06-03T07:32:09Z","receivedAt":"2009-06-03T07:32:09Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 02.06.2009, 20:35 Uhr, schrieb Johannes Sixt <j6t@kdbg.org>:\n\n> On Dienstag, 2. Juni 2009, Junio C Hamano wrote:\n>> Nanako Shiraishi <nanako3@lavabit.com> writes:\n>> > Junio, I think you forgot to take a follow-up action on this thread  \n>> after\n>> > sending this message.  The patch favors the git program in the current\n>> > directory.\n>>\n>> Indeed, I did, and I think I am Ok with the patch.  Thanks for a\n>> reminder.\n>>\n>> I thought there was an \"simplicity\" issue raised by J6t that was not\n>> addressed, but after re-reading the thread I do not think it applies\n>> (J6t?)\n>\n> Sorry, I don't recall anymore what I said; but since the thread petered  \n> out, I\n> use this patch in the repository where I share Matthias' 'sudo make  \n> install'\n> problem:\n>\n> Subject: [PATCH] version-gen: Use just built git if no other git is in  \n> PATH\n>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n>\n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index 39cde78..4779313 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -3,6 +3,9 @@\n>  GVF=GIT-VERSION-FILE\n>  DEF_VER=v1.6.3.GIT\n> +# use git that was just compiled if there is no git elsewhere in PATH\n> +PATH=$PATH:.\n> +\n>  LF='\n>  '\n\nHi Hannes,\n\nthat's not what I proposed at the time; I'll look how I ordered  \npreferences at the time and will re-submit soon. AFAIR (I'll check the  \narchives), Junio had preferred checking $(prefix) before . in order to  \nsupport cross-builds.\n\nBest regards\n\n-- \nMatthias Andree\n"},{"id":"115401","messageId":"1244074328-20995-1-git-send-email-matthias.andree@gmx.de","threadId":"19225","inReplyTo":"200906022035.30081.j6t@kdbg.org","subject":"[PATCH v4] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-06-04T00:12:08Z","receivedAt":"2009-06-04T00:12:08Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Situation: sudo make install can rebuilds the whole package even if\nyou've just built it before. For instance:\n\nmake configure\n./configure    # defaults to --prefix=/usr/local\nmake all doc\nsudo make install install-doc install-html # REBUILDS HAPPEN HERE\n\nThis causes the \"sudo make install\" to rebuild everything because it believes\nthe version had changed.  sudo strips $PATH for security reasons.\n\nThe underlying problem flow is:\n\n1 - Makefile has \"include GIT-VERSION-FILE\", thus gmake builds\n    GIT-VERSION-FILE early.\n2 - GIT-VERSION-FILE depends on a .PHONY target (.FORCE-GIT-VERSION-FILE)\n3 - Thus, GNU make *always* executes GIT-VERSION-GEN\n4 - GIT-VERSION-GEN now, under the stripped $PATH, cannot find \"git\" and\n    sees a different version number.\n5 - GIT-VERSION-GEN notes the difference in versions and regenerates\n    GIT-VERSION-FILE, with up-to-date timestamp.\n6 - GNU make rebuilds everything because GIT-VERSION-FILE is new.\n\nThe patch makes GIT-VERSION-GEN look for git in $(prefix)/bin, then for\nthe newly built git$X executable, before falling back to plain \"git\" and\nthus to the default version in GIT-VERSION-GEN. This increases chances\nthat we get the same version with the stripped $PATH and get away\nwithout rebuild.\n\nJunio C. Hamano suggested that we look into $(prefix)/bin before the\ncurrent work directory in order to aid cross-compiling.\n\nSigned-off-by: Matthias Andree <matthias.andree@gmx.de>\n---\n GIT-VERSION-GEN         |    9 ++++-----\n Makefile                |    6 +++++-\n git-gui/GIT-VERSION-GEN |   18 ++++++++++--------\n git-gui/Makefile        |    6 +++++-\n 4 files changed, 24 insertions(+), 15 deletions(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 39cde78..2334cc1 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -2,6 +2,7 @@\n \n GVF=GIT-VERSION-FILE\n DEF_VER=v1.6.3.GIT\n+type >/dev/null \"$GIT\" || GIT=git\n \n LF='\n '\n@@ -12,12 +13,12 @@ if test -f version\n then\n \tVN=$(cat version) || VN=\"$DEF_VER\"\n elif test -d .git -o -f .git &&\n-\tVN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n+\tVN=$($GIT describe --abbrev=4 HEAD 2>/dev/null) &&\n \tcase \"$VN\" in\n \t*$LF*) (exit 1) ;;\n \tv[0-9]*)\n-\t\tgit update-index -q --refresh\n-\t\ttest -z \"$(git diff-index --name-only HEAD --)\" ||\n+\t\t$GIT update-index -q --refresh\n+\t\ttest -z \"$($GIT diff-index --name-only HEAD --)\" ||\n \t\tVN=\"$VN-dirty\" ;;\n \tesac\n then\n@@ -38,5 +39,3 @@ test \"$VN\" = \"$VC\" || {\n \techo >&2 \"GIT_VERSION = $VN\"\n \techo \"GIT_VERSION = $VN\" >$GVF\n }\n-\n-\ndiff --git a/Makefile b/Makefile\nindex 06c39e4..7adcf40 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -184,7 +184,11 @@ all::\n # programs as a tar, where bin/ and libexec/ might be on different file systems.\n \n GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n-\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n+\t@{ GIT=$(prefix)/bin/git$X ; test -x \"$$GIT\" ; } \\\n+\t|| { GIT=./git$X ; test -x \"$$GIT\" ; } \\\n+\t|| GIT=git ; \\\n+\texport GIT ; \\\n+\t$(SHELL_PATH) ./GIT-VERSION-GEN\n -include GIT-VERSION-FILE\n \n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\ndiff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN\nindex b3f937e..729e93f 100755\n--- a/git-gui/GIT-VERSION-GEN\n+++ b/git-gui/GIT-VERSION-GEN\n@@ -3,6 +3,8 @@\n GVF=GIT-VERSION-FILE\n DEF_VER=0.12.GITGUI\n \n+type >/dev/null \"$GIT\" || GIT=git\n+\n LF='\n '\n \n@@ -10,10 +12,10 @@ tree_search ()\n {\n \thead=$1\n \ttree=$2\n-\tfor p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)\n+\tfor p in $($GIT rev-list --parents --max-count=1 $head 2>/dev/null)\n \tdo\n-\t\ttest $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&\n-\t\tvn=$(git describe --abbrev=4 $p 2>/dev/null) &&\n+\t\ttest $tree = $($GIT rev-parse $p^{tree} 2>/dev/null) &&\n+\t\tvn=$($GIT describe --abbrev=4 $p 2>/dev/null) &&\n \t\tcase \"$vn\" in\n \t\tgitgui-[0-9]*) echo $vn; break;;\n \t\tesac\n@@ -38,10 +40,10 @@ if test -f version &&\n    VN=$(cat version)\n then\n \t: happy\n-elif prefix=\"$(git rev-parse --show-prefix 2>/dev/null)\"\n+elif prefix=\"$($GIT rev-parse --show-prefix 2>/dev/null)\"\n    test -n \"$prefix\" &&\n-   head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&\n-   tree=$(git rev-parse --verify \"HEAD:$prefix\" 2>/dev/null) &&\n+   head=$($GIT rev-list --max-count=1 HEAD -- . 2>/dev/null) &&\n+   tree=$($GIT rev-parse --verify \"HEAD:$prefix\" 2>/dev/null) &&\n    VN=$(tree_search $head $tree)\n    case \"$VN\" in\n    gitgui-[0-9]*) : happy ;;\n@@ -49,7 +51,7 @@ elif prefix=\"$(git rev-parse --show-prefix 2>/dev/null)\"\n    esac\n then\n \tVN=$(echo \"$VN\" | sed -e 's/^gitgui-//;s/-/./g');\n-elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&\n+elif VN=$($GIT describe --abbrev=4 HEAD 2>/dev/null) &&\n    case \"$VN\" in\n    gitgui-[0-9]*) : happy ;;\n    *) (exit 1) ;;\n@@ -60,7 +62,7 @@ else\n \tVN=\"$DEF_VER\"\n fi\n \n-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=\n+dirty=$(sh -c '$GIT diff-index --name-only HEAD' 2>/dev/null) || dirty=\n case \"$dirty\" in\n '')\n \t;;\ndiff --git a/git-gui/Makefile b/git-gui/Makefile\nindex b3580e9..bbdb4d8 100644\n--- a/git-gui/Makefile\n+++ b/git-gui/Makefile\n@@ -8,7 +8,11 @@ all::\n #\n \n GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n-\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n+\t@{ GIT=$(prefix)/bin/git$X ; test -x \"$$GIT\" ; } \\\n+\t|| { GIT=./git$X ; test -x \"$$GIT\" ; } \\\n+\t|| GIT=git ; \\\n+\texport GIT ; \\\n+\t$(SHELL_PATH) ./GIT-VERSION-GEN\n -include GIT-VERSION-FILE\n \n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n-- \n1.6.3.1.267.gd260a\n"},{"id":"115411","messageId":"7vvdnc37b6.fsf@alter.siamese.dyndns.org","threadId":"19225","inReplyTo":"200906022035.30081.j6t@kdbg.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-04T05:18:53Z","receivedAt":"2009-06-04T05:18:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> On Dienstag, 2. Juni 2009, Junio C Hamano wrote:\n>> Nanako Shiraishi <nanako3@lavabit.com> writes:\n>> > Junio, I think you forgot to take a follow-up action on this thread after\n>> > sending this message.  The patch favors the git program in the current\n>> > directory.\n>>\n>> Indeed, I did, and I think I am Ok with the patch.  Thanks for a\n>> reminder.\n>>\n>> I thought there was an \"simplicity\" issue raised by J6t that was not\n>> addressed, but after re-reading the thread I do not think it applies\n>> (J6t?)\n>\n> Sorry, I don't recall anymore what I said; but since the thread petered out, I \n> use this patch in the repository where I share Matthias' 'sudo make install' \n> problem:\n>\n> Subject: [PATCH] version-gen: Use just built git if no other git is in PATH\n>\n> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n>\n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index 39cde78..4779313 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -3,6 +3,9 @@\n>  GVF=GIT-VERSION-FILE\n>  DEF_VER=v1.6.3.GIT\n>  \n> +# use git that was just compiled if there is no git elsewhere in PATH\n> +PATH=$PATH:.\n> +\n>  LF='\n>  '\n\nI actually think this is much saner and cleaner (it certainly is smaller),\nespecially having seen Matthias's v4, which feels a tad overengineered.\n\nI honestly do not understand why we need to bend backwards to cater to\n\"sudo\".  Real men, when needing to do things as root, have always done\n\"su\", and _if_ the environment is unsuited for the job, they can do:\n\n\t$ su\n        # PATH=$PATH:/usr/local/bin make prefix=/usr/local install\n"},{"id":"115418","messageId":"op.uuzrh8jr1e62zd@balu.cs.uni-paderborn.de","threadId":"19225","inReplyTo":"7vvdnc37b6.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] To make GIT-VERSION-FILE, search for git more widely","fromName":"Matthias Andree","fromEmail":"matthias.andree@gmx.de","sentAt":"2009-06-04T08:35:58Z","receivedAt":"2009-06-04T08:35:58Z","isPatch":true,"sender":{"key":"matthias.andree@gmx.de","avatar":null},"body":"Am 04.06.2009, 07:18 Uhr, schrieb Junio C Hamano <gitster@pobox.com>:\n\n> Johannes Sixt <j6t@kdbg.org> writes:\n>\n>> On Dienstag, 2. Juni 2009, Junio C Hamano wrote:\n>>> Nanako Shiraishi <nanako3@lavabit.com> writes:\n>>> > Junio, I think you forgot to take a follow-up action on this thread  \n>>> after\n>>> > sending this message.  The patch favors the git program in the  \n>>> current\n>>> > directory.\n>>>\n>>> Indeed, I did, and I think I am Ok with the patch.  Thanks for a\n>>> reminder.\n>>>\n>>> I thought there was an \"simplicity\" issue raised by J6t that was not\n>>> addressed, but after re-reading the thread I do not think it applies\n>>> (J6t?)\n>>\n>> Sorry, I don't recall anymore what I said; but since the thread petered  \n>> out, I\n>> use this patch in the repository where I share Matthias' 'sudo make  \n>> install'\n>> problem:\n>>\n>> Subject: [PATCH] version-gen: Use just built git if no other git is in  \n>> PATH\n>>\n>> Signed-off-by: Johannes Sixt <j6t@kdbg.org>\n>>\n>> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n>> index 39cde78..4779313 100755\n>> --- a/GIT-VERSION-GEN\n>> +++ b/GIT-VERSION-GEN\n>> @@ -3,6 +3,9 @@\n>>  GVF=GIT-VERSION-FILE\n>>  DEF_VER=v1.6.3.GIT\n>>\n>> +# use git that was just compiled if there is no git elsewhere in PATH\n>> +PATH=$PATH:.\n>> +\n>>  LF='\n>>  '\n>\n> I actually think this is much saner and cleaner (it certainly is  \n> smaller),\n> especially having seen Matthias's v4, which feels a tad overengineered.\n\nIt's nothing more than\n\n(a) followed your suggestion to look in $(prefix) first for cross-building  \nsupport\n\n(b) ported to git-gui as well (copy & paste-style)\n\nAlso, we certainly do not want to stuff \".\" in root's PATH, not even for  \nsimple scripts like GIT-VERSION-GEN.\n\n> I honestly do not understand why we need to bend backwards to cater to\n> \"sudo\".  Real men, when needing to do things as root, have always done\n> \"su\", and _if_ the environment is unsuited for the job, they can do:\n>\n> \t$ su\n>         # PATH=$PATH:/usr/local/bin make prefix=/usr/local install\n\nsudo caches passwords for a couple of minutes, su does not, and su isn't  \navailable everywhere (\"wheel\" group on BSD and stuff); particularly, sudo  \nis *the* get-root-tool on Ubuntu.\n\nIf you argue \"real men\", then break that damn rebuild cycle and either fix  \ndependencies properly, rather than second-guessing in shell scripts at  \n\"make install\" time, or add post-update hooks (or whatever) to update the  \nGIT-VERSION-FILE...\n\n\".\" doesn't belong in root's $PATH, period.\n\n-- \nMatthias Andree\n"}]}