{"thread":{"id":"21362","subject":"[PATCH 0/2] pre-generated completion fix and RFC","startedAt":"2009-10-26T20:31:54Z","lastAt":"2009-10-28T08:19:49Z","messageCount":12,"participants":["Stephen Boyd","Junio C Hamano","Clemens Buchacher","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"125945","messageId":"1256589116-6998-1-git-send-email-bebarino@gmail.com","threadId":"21362","inReplyTo":null,"subject":"[PATCH 0/2] pre-generated completion fix and RFC","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-26T20:31:54Z","receivedAt":"2009-10-26T20:31:54Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"I should have looked at the actual generated completion before hastily\nsending my last fix. Looks like we get the merge strategies twice in the\nmerge strategy list.\n\nThe second patch is a quick hack to have completion lazily load again\nwhile still allowing pre-generated completion.\n\nThese are on top of next.\n\nStephen Boyd (2):\n  completion: ignore custom merge strategies when pre-generating\n  completion: allow use without compiling\n\n contrib/completion/git-completion.bash.generate |    1 +\n contrib/completion/git-completion.bash.in       |  132 +++++++++++++++++++++--\n 2 files changed, 124 insertions(+), 9 deletions(-)\n"},{"id":"125946","messageId":"1256589116-6998-2-git-send-email-bebarino@gmail.com","threadId":"21362","inReplyTo":"1256589116-6998-1-git-send-email-bebarino@gmail.com","subject":"[PATCH 1/2] completion: ignore custom merge strategies when pre-generating","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-26T20:31:55Z","receivedAt":"2009-10-26T20:31:55Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Since the Makefile adds the build directory to PATH, we get the merge\nstrategies twice. Ignore custom merge strategies which are just the\nbuiltin merge strategies (octopus.sh, ours.sh, etc.) anyway.\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n contrib/completion/git-completion.bash.generate |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash.generate b/contrib/completion/git-completion.bash.generate\nindex 6487fd5..b66254a 100755\n--- a/contrib/completion/git-completion.bash.generate\n+++ b/contrib/completion/git-completion.bash.generate\n@@ -9,6 +9,7 @@ __git_merge_strategies ()\n {\n \tgit merge -s help 2>&1 |\n \tsed -n -e '/[Aa]vailable strategies are: /,/^$/{\n+\t\t/^[Aa]vailable custom strategies are: / d\n \t\ts/\\.$//\n \t\ts/.*://\n \t\ts/^[ \t]*//\n-- \n1.6.5.2.181.gd6f41\n"},{"id":"125947","messageId":"1256589116-6998-3-git-send-email-bebarino@gmail.com","threadId":"21362","inReplyTo":"1256589116-6998-1-git-send-email-bebarino@gmail.com","subject":"[PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-26T20:31:56Z","receivedAt":"2009-10-26T20:31:56Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Some users don't want to compile their completion, even when the build\ngenerated completion is 10x faster to load. For example, in my bashrc I\nsource the completion script directly so I can stay up to date with the\nlatest completion by merely pulling changes.\n\nDo this by generating the lists dynamically when the merge strategy and\ncommand lists still have their initial values (__GIT_MERGE_STRATEGYLIST,\n__GIT_ALL_COMMANDLIST).\n\nSigned-off-by: Stephen Boyd <bebarino@gmail.com>\n---\n\n This duplicates code, but I don't know of a way to re-use the dynamic\n code without sourcing a bash script and possibly breaking someone's build.\n\n contrib/completion/git-completion.bash.in |  132 +++++++++++++++++++++++++++--\n 1 files changed, 123 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash.in b/contrib/completion/git-completion.bash.in\nindex d873b98..37d204c 100644\n--- a/contrib/completion/git-completion.bash.in\n+++ b/contrib/completion/git-completion.bash.in\n@@ -60,15 +60,6 @@ __git_merge_strategylist=__GIT_MERGE_STRATEGYLIST\n __git_all_commandlist=__GIT_ALL_COMMANDLIST\n __git_porcelain_commandlist=__GIT_PORCELAIN_COMMANDLIST\n \n-# remind folks that git-completion.bash.in can't be sourced\n-case \"$__git_merge_strategylist\" in\n-__GIT*)\n-\techo \"E: git-completion.bash.in can't be sourced\"\n-\treturn 1 ;;\n-esac\n-\n-\n-\n case \"$COMP_WORDBREAKS\" in\n *:*) : great ;;\n *)   COMP_WORDBREAKS=\"$COMP_WORDBREAKS:\"\n@@ -333,6 +324,22 @@ __git_remotes ()\n \tdone\n }\n \n+__git_merge_strategies ()\n+{\n+\tif [\"$__git_merge_strategylist\" != \"__GIT_MERGE_STRATEGYLIST\"]; then\n+\t\techo \"$__git_merge_strategylist\"\n+\t\treturn\n+\tfi\n+\tgit merge -s help 2>&1 |\n+\tsed -n -e '/[Aa]vailable strategies are: /,/^$/{\n+\t\ts/\\.$//\n+\t\ts/.*://\n+\t\ts/^[ \t]*//\n+\t\ts/[ \t]*$//\n+\t\tp\n+\t}'\n+}\n+__git_merge_strategylist=\"$(__git_merge_strategies 2>/dev/null)\"\n \n __git_complete_file ()\n {\n@@ -481,6 +488,113 @@ __git_complete_strategy ()\n \treturn 1\n }\n \n+__git_all_commands ()\n+{\n+\tif [\"$__git_all_commandlist\" != \"__GIT_ALL_COMMANDLIST\"]; then\n+\t\techo \"$__git_all_commandlist\"\n+\t\treturn\n+\tfi\n+\tlocal i\n+\tfor i in $(git help -a|egrep '^  [a-zA-Z0-9]')\n+\tdo\n+\t\tcase $i in\n+\t\t*--*)             : helper pattern;;\n+\t\t*) echo $i;;\n+\t\tesac\n+\tdone\n+}\n+__git_all_commandlist=\"$(__git_all_commands 2>/dev/null)\"\n+\n+__git_porcelain_commands ()\n+{\n+\tif [\"$__git_porcelain_commandlist\" != \"__GIT_PORCELAIN_COMMANDLIST\"]; then\n+\t\techo \"$__git_porcelain_commandlist\"\n+\t\treturn\n+\tfi\n+\tlocal i\n+\tfor i in \"help\" $(__git_all_commands)\n+\tdo\n+\t\tcase $i in\n+\t\t*--*)             : helper pattern;;\n+\t\tapplymbox)        : ask gittus;;\n+\t\tapplypatch)       : ask gittus;;\n+\t\tarchimport)       : import;;\n+\t\tcat-file)         : plumbing;;\n+\t\tcheck-attr)       : plumbing;;\n+\t\tcheck-ref-format) : plumbing;;\n+\t\tcheckout-index)   : plumbing;;\n+\t\tcommit-tree)      : plumbing;;\n+\t\tcount-objects)    : infrequent;;\n+\t\tcvsexportcommit)  : export;;\n+\t\tcvsimport)        : import;;\n+\t\tcvsserver)        : daemon;;\n+\t\tdaemon)           : daemon;;\n+\t\tdiff-files)       : plumbing;;\n+\t\tdiff-index)       : plumbing;;\n+\t\tdiff-tree)        : plumbing;;\n+\t\tfast-import)      : import;;\n+\t\tfast-export)      : export;;\n+\t\tfsck-objects)     : plumbing;;\n+\t\tfetch-pack)       : plumbing;;\n+\t\tfmt-merge-msg)    : plumbing;;\n+\t\tfor-each-ref)     : plumbing;;\n+\t\thash-object)      : plumbing;;\n+\t\thttp-*)           : transport;;\n+\t\tindex-pack)       : plumbing;;\n+\t\tinit-db)          : deprecated;;\n+\t\tlocal-fetch)      : plumbing;;\n+\t\tlost-found)       : infrequent;;\n+\t\tls-files)         : plumbing;;\n+\t\tls-remote)        : plumbing;;\n+\t\tls-tree)          : plumbing;;\n+\t\tmailinfo)         : plumbing;;\n+\t\tmailsplit)        : plumbing;;\n+\t\tmerge-*)          : plumbing;;\n+\t\tmktree)           : plumbing;;\n+\t\tmktag)            : plumbing;;\n+\t\tpack-objects)     : plumbing;;\n+\t\tpack-redundant)   : plumbing;;\n+\t\tpack-refs)        : plumbing;;\n+\t\tparse-remote)     : plumbing;;\n+\t\tpatch-id)         : plumbing;;\n+\t\tpeek-remote)      : plumbing;;\n+\t\tprune)            : plumbing;;\n+\t\tprune-packed)     : plumbing;;\n+\t\tquiltimport)      : import;;\n+\t\tread-tree)        : plumbing;;\n+\t\treceive-pack)     : plumbing;;\n+\t\treflog)           : plumbing;;\n+\t\trepo-config)      : deprecated;;\n+\t\trerere)           : plumbing;;\n+\t\trev-list)         : plumbing;;\n+\t\trev-parse)        : plumbing;;\n+\t\trunstatus)        : plumbing;;\n+\t\tsh-setup)         : internal;;\n+\t\tshell)            : daemon;;\n+\t\tshow-ref)         : plumbing;;\n+\t\tsend-pack)        : plumbing;;\n+\t\tshow-index)       : plumbing;;\n+\t\tssh-*)            : transport;;\n+\t\tstripspace)       : plumbing;;\n+\t\tsymbolic-ref)     : plumbing;;\n+\t\ttar-tree)         : deprecated;;\n+\t\tunpack-file)      : plumbing;;\n+\t\tunpack-objects)   : plumbing;;\n+\t\tupdate-index)     : plumbing;;\n+\t\tupdate-ref)       : plumbing;;\n+\t\tupdate-server-info) : daemon;;\n+\t\tupload-archive)   : plumbing;;\n+\t\tupload-pack)      : plumbing;;\n+\t\twrite-tree)       : plumbing;;\n+\t\tvar)              : infrequent;;\n+\t\tverify-pack)      : infrequent;;\n+\t\tverify-tag)       : plumbing;;\n+\t\t*) echo $i;;\n+\t\tesac\n+\tdone\n+}\n+__git_porcelain_commandlist=\"$(__git_porcelain_commands 2>/dev/null)\"\n+\n __git_aliases ()\n {\n \tlocal i IFS=$'\\n'\n-- \n1.6.5.2.181.gd6f41\n"},{"id":"125966","messageId":"7vocntd7vt.fsf@alter.siamese.dyndns.org","threadId":"21362","inReplyTo":"1256589116-6998-3-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-26T23:59:18Z","receivedAt":"2009-10-26T23:59:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Some users don't want to compile their completion, even when the build\n> generated completion is 10x faster to load. For example, in my bashrc I\n> source the completion script directly so I can stay up to date with the\n> latest completion by merely pulling changes.\n>\n> Do this by generating the lists dynamically when the merge strategy and\n> command lists still have their initial values (__GIT_MERGE_STRATEGYLIST,\n> __GIT_ALL_COMMANDLIST).\n>\n> Signed-off-by: Stephen Boyd <bebarino@gmail.com>\n> ---\n>\n>  This duplicates code, but I don't know of a way to re-use the dynamic\n>  code without sourcing a bash script and possibly breaking someone's build.\n\nIf we are going to do this, wouldn't it make more sense to revert the\nrename of the script, so that people can keep relying on the name of the\nscript being \"git-completion.bash\", _but_ make it produce a pre-compiled\nform to a separate file when invoked in some particular way?\n\nThen at the runtime:\n\n (0) If the script notices that it has already learned the command list\n     it uses it; otherwise,\n\n (1) If the script notices that there is a file that contains the command\n     list, it sources it; otherwise,\n\n (2) The script lazily builds the command list for its own use.\n\nAnd at the buildtime, Makefile can run the script in \"generation mode\",\nand install the output to where (1) above expects to see.\n"},{"id":"125973","messageId":"20091027003353.GA29205@localhost","threadId":"21362","inReplyTo":"7vocntd7vt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-10-27T00:33:53Z","receivedAt":"2009-10-27T00:33:53Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Mon, Oct 26, 2009 at 04:59:18PM -0700, Junio C Hamano wrote:\n\n> Stephen Boyd <bebarino@gmail.com> writes:\n> \n> >  This duplicates code, but I don't know of a way to re-use the dynamic\n> >  code without sourcing a bash script and possibly breaking someone's build.\n>\n>  (1) If the script notices that there is a file that contains the command\n>      list, it sources it; otherwise,\n\nOr we substitute the command list in-place, so that we still have the entire\ncompletion script in one file.\n\nClemens\n"},{"id":"125974","messageId":"7v4opld631.fsf@alter.siamese.dyndns.org","threadId":"21362","inReplyTo":"20091027003353.GA29205@localhost","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-27T00:38:10Z","receivedAt":"2009-10-27T00:38:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Clemens Buchacher <drizzd@aon.at> writes:\n\n> On Mon, Oct 26, 2009 at 04:59:18PM -0700, Junio C Hamano wrote:\n>\n>> Stephen Boyd <bebarino@gmail.com> writes:\n>> \n>> >  This duplicates code, but I don't know of a way to re-use the dynamic\n>> >  code without sourcing a bash script and possibly breaking someone's build.\n>>\n>>  (1) If the script notices that there is a file that contains the command\n>>      list, it sources it; otherwise,\n>\n> Or we substitute the command list in-place, so that we still have the entire\n> completion script in one file.\n\nThat defeats the whole point of my suggestion, as you would be overwriting\nthe tracked file.\n"},{"id":"125984","messageId":"4AE65FB5.3000905@gmail.com","threadId":"21362","inReplyTo":"7vocntd7vt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-27T02:49:25Z","receivedAt":"2009-10-27T02:49:25Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Junio C Hamano wrote:\n>\n> If we are going to do this, wouldn't it make more sense to revert the\n> rename of the script, so that people can keep relying on the name of the\n> script being \"git-completion.bash\", _but_ make it produce a pre-compiled\n> form to a separate file when invoked in some particular way?\n\nWouldn't relying on \"git-completion.bash\" to produce the pre-compiled\nform cause problems if someone is running the build on a bash-less\nsystem? I thought this issue was already raised by Shawn.\n\nI guess we could ignore that issue now, and just say that you have to\nbuild the pre-compiled form on systems with bash?\n\n>\n> Then at the runtime:\n>\n>  (0) If the script notices that it has already learned the command list\n>      it uses it; otherwise,\n>\n>  (1) If the script notices that there is a file that contains the command\n>      list, it sources it; otherwise,\n>\n>  (2) The script lazily builds the command list for its own use.\n>\n> And at the buildtime, Makefile can run the script in \"generation mode\",\n> and install the output to where (1) above expects to see.\n\nI assume you're suggesting this to ease the upgrade path for users. It\nworks nicely, we could just install the generated lists in the same path\n(contrib/completion/) and then users would be free to copy the two files\nanywhere as long as they're in the same directory. The only downside I\nsee is there's now two files, but that's ok with me.\n"},{"id":"126048","messageId":"20091027185223.GH10505@spearce.org","threadId":"21362","inReplyTo":"1256589116-6998-3-git-send-email-bebarino@gmail.com","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-10-27T18:52:23Z","receivedAt":"2009-10-27T18:52:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> wrote:\n> Some users don't want to compile their completion, even when the build\n> generated completion is 10x faster to load. For example, in my bashrc I\n> source the completion script directly so I can stay up to date with the\n> latest completion by merely pulling changes.\n> \n> Do this by generating the lists dynamically when the merge strategy and\n> command lists still have their initial values (__GIT_MERGE_STRATEGYLIST,\n> __GIT_ALL_COMMANDLIST).\n> \n> Signed-off-by: Stephen Boyd <bebarino@gmail.com>\n> ---\n> \n>  This duplicates code, but I don't know of a way to re-use the dynamic\n>  code without sourcing a bash script and possibly breaking someone's build.\n\nNAK on code duplication, especially this much.  As Junio already\npointed out in this thread we need an approach that doesn't cause\nthis sort of redundant code.\n\nI'm trying to catch up on email right now.  I have no great\nsuggestions on how to implement this to avoid the code duplication\nand still be able to support both compile-time and on-the-fly\ncomputation, but I do know I don't want this code twice.\n\n-- \nShawn.\n"},{"id":"126078","messageId":"4AE7A1B9.5010001@gmail.com","threadId":"21362","inReplyTo":"20091027185223.GH10505@spearce.org","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-28T01:43:21Z","receivedAt":"2009-10-28T01:43:21Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Shawn O. Pearce wrote:\n> NAK on code duplication, especially this much.  As Junio already\n> pointed out in this thread we need an approach that doesn't cause\n> this sort of redundant code.\n\nOk. Following Junio's suggestion I think we would have to do the following:\n\n(1) Revert the rename (git-completion.bash.in -> git-completion.bash)\n\n(2) Add a \"generation\" mode to git-completion.bash.generate to generate \nthe lists and output them to a file\n\n(3) Add logic in git-completion.bash.generate to source the generated \nfile if it exists\n\n(4) Source git-completion.bash.generate in git-completion.bash to get \nthe functions moved there\n\nIn the end we would have git-completion.bash sourcing \ngit-completion.bash.generate which then sources the generated file. I \nassume this is slower than compiling to just one file.\n\nOr we could just not load the caches until they're needed. This just \ndelays the performance hit to completion time, but at least it speeds up \nloading the script without the need to compile and still has the benefit \nof some caching. It also allows users to keep the completion of their \ncustom merge strategies and git programs in their PATH.\n\n----8<----\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex d3fec32..8a7cde3 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -326,10 +326,15 @@ __git_remotes ()\n \n __git_merge_strategies ()\n {\n-\tif [ -n \"${__git_merge_strategylist-}\" ]; then\n+\tif [ -n \"${__git_merge_strategylist-}\" ] || {\n+\t\t__git_merge_strategylist=$(__git_merge_strategies_gen 2>/dev/null)\n+\t}; then\n \t\techo \"$__git_merge_strategylist\"\n-\t\treturn\n \tfi\n+}\n+\n+__git_merge_strategies_gen ()\n+{\n \tgit merge -s help 2>&1 |\n \tsed -n -e '/[Aa]vailable strategies are: /,/^$/{\n \t\ts/\\.$//\n@@ -340,7 +345,6 @@ __git_merge_strategies ()\n \t}'\n }\n __git_merge_strategylist=\n-__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)\n \n __git_complete_file ()\n {\n@@ -491,10 +495,15 @@ __git_complete_strategy ()\n \n __git_all_commands ()\n {\n-\tif [ -n \"${__git_all_commandlist-}\" ]; then\n+\tif [ -n \"${__git_all_commandlist-}\" ] || {\n+\t\t__git_all_commandlist=\"$(__git_all_commands_gen 2>/dev/null)\"\n+\t}; then\n \t\techo \"$__git_all_commandlist\"\n-\t\treturn\n \tfi\n+}\n+\n+__git_all_commands_gen ()\n+{\n \tlocal i IFS=\" \"$'\\n'\n \tfor i in $(git help -a|egrep '^  [a-zA-Z0-9]')\n \tdo\n@@ -505,14 +514,18 @@ __git_all_commands ()\n \tdone\n }\n __git_all_commandlist=\n-__git_all_commandlist=\"$(__git_all_commands 2>/dev/null)\"\n \n __git_porcelain_commands ()\n {\n-\tif [ -n \"${__git_porcelain_commandlist-}\" ]; then\n+\tif [ -n \"${__git_porcelain_commandlist-}\" ] || {\n+\t\t__git_porcelain_commandlist=\"$(__git_porcelain_commands_gen 2>/dev/null)\"\n+\t}; then\n \t\techo \"$__git_porcelain_commandlist\"\n-\t\treturn\n \tfi\n+}\n+\n+__git_porcelain_commands_gen ()\n+{\n \tlocal i IFS=\" \"$'\\n'\n \tfor i in \"help\" $(__git_all_commands)\n \tdo\n@@ -596,7 +609,6 @@ __git_porcelain_commands ()\n \tdone\n }\n __git_porcelain_commandlist=\n-__git_porcelain_commandlist=\"$(__git_porcelain_commands 2>/dev/null)\"\n \n __git_aliases ()\n {\n"},{"id":"126100","messageId":"7v63a0t29l.fsf@alter.siamese.dyndns.org","threadId":"21362","inReplyTo":"4AE7A1B9.5010001@gmail.com","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-10-28T07:18:30Z","receivedAt":"2009-10-28T07:18:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephen Boyd <bebarino@gmail.com> writes:\n\n> Ok. Following Junio's suggestion I think we would have to do the following:\n>\n> (1) Revert the rename (git-completion.bash.in -> git-completion.bash)\n>\n> (2) Add a \"generation\" mode to git-completion.bash.generate to\n> generate the lists and output them to a file\n>\n> (3) Add logic in git-completion.bash.generate to source the generated\n> file if it exists\n>\n> (4) Source git-completion.bash.generate in git-completion.bash to get\n> the functions moved there\n\nSorry, I do not quite see why an extra *.generate script is necessary.\n"},{"id":"126111","messageId":"4AE7F2EB.1020904@gmail.com","threadId":"21362","inReplyTo":"7v63a0t29l.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2009-10-28T07:29:47Z","receivedAt":"2009-10-28T07:29:47Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Junio C Hamano wrote:\n> Stephen Boyd <bebarino@gmail.com> writes:\n>> Ok. Following Junio's suggestion I think we would have to do the following:\n>>\n>> (1) Revert the rename (git-completion.bash.in -> git-completion.bash)\n>>\n>> (2) Add a \"generation\" mode to git-completion.bash.generate to\n>> generate the lists and output them to a file\n>>\n>> (3) Add logic in git-completion.bash.generate to source the generated\n>> file if it exists\n>>\n>> (4) Source git-completion.bash.generate in git-completion.bash to get\n>> the functions moved there\n>\n> Sorry, I do not quite see why an extra *.generate script is necessary.\n\nI'm still assuming the generation mode has to be sh agnostic, therefore \nrequiring those functions to be in another *.generate script. Is that wrong?\n"},{"id":"126113","messageId":"20091028081949.GA25488@localhost","threadId":"21362","inReplyTo":"7v4opld631.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 2/2] completion: allow use without compiling","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-10-28T08:19:49Z","receivedAt":"2009-10-28T08:19:49Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Mon, Oct 26, 2009 at 05:38:10PM -0700, Junio C Hamano wrote:\n> Clemens Buchacher <drizzd@aon.at> writes:\n> \n> > On Mon, Oct 26, 2009 at 04:59:18PM -0700, Junio C Hamano wrote:\n> >\n> >> Stephen Boyd <bebarino@gmail.com> writes:\n> >> \n> >> >  This duplicates code, but I don't know of a way to re-use the dynamic\n> >> >  code without sourcing a bash script and possibly breaking someone's build.\n> >>\n> >>  (1) If the script notices that there is a file that contains the command\n> >>      list, it sources it; otherwise,\n> >\n> > Or we substitute the command list in-place, so that we still have the entire\n> > completion script in one file.\n> \n> That defeats the whole point of my suggestion, as you would be overwriting\n> the tracked file.\n\nOk, not in-place then. What I meant is something like this.\n\ngit-completion.bash.in:\n\n completion script with placeholders for command list generation code and\n static command list\n\ngit-command-list.sh:\n\n bash-agnostic command list generation script\n\ngit-completion.bash.generate:\n\n run git-command-list.sh and replace static command list placeholder in\n git-completion.bash.in, also insert command list generation code into\n git-completion.bash.in, write result to git-completion.bash\n\nWhether or not the command list should be loaded dynamically can be decided\non a per-user basis using a configuration option.\n\nA downside of this approach is that even if we do not need the static\ncommand list, we still need to generate the completion script. I therefore\nrecommend we make this part of the normal build process.\n\nAlternatively, we could source the command list code. But it's inconvenient\nto copy two completion scripts and it will probably cause confusion among\nusers.\n\nClemens\n"}]}