{"thread":{"id":"33087","subject":"Splitting config.txt","startedAt":"2013-03-06T14:01:42Z","lastAt":"2013-03-06T14:01:42Z","messageCount":1,"participants":["Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"210698","messageId":"20130306140141.GA24386@lanh","threadId":"33087","inReplyTo":null,"subject":"Splitting config.txt","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-03-06T14:01:42Z","receivedAt":"2013-03-06T14:01:42Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"We discussed this before about adding configuration variables into\nindividual command man pages [1]. This may be a step towards\nthat. With this, I could add selected configuration variables to\ngit-push.txt, for example, with a simple patch:\n\n-- 8< --\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 1398025..c130c90 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -348,6 +348,13 @@ you are certain that nobody in the meantime fetched your earlier commit A\n overwrite it. In other words, \"git push --force\" is a method reserved for\n a case where you do mean to lose history.\n \n+CONFIGURATION\n+-------------\n+\n+include::config/push.default.txt[]\n+include::config/remote.name.pushurl.txt[]\n+include::config/remote.name.push.txt[]\n+\n \n Examples\n --------\n-- 8< --\n\nI know it makes man pages longer (and more intimidating for new\nusers), but the point is we could select just important keys for each\nman page, instead of all keys affecting the command.\n\nI don't post the final patch that splits config.txt, just the script I\nuse to split it. You can try it yourself. It puts each config key into\na file under Documentation/config, with some characters mangled to be\nmore fs friendly. Run it inside Documentation/. generated git-config.1\nis the same after the split.\n\n-- 8< --\n#!/usr/bin/perl\n\nsub extract {\n    my ($line) = @_;\n    open CC, \">config/$filename\" || die \"failed to open config/$filename\";\n    foreach $l (@lines[($start - 1)..($line - 2)]) {\n\t$l =~ s/^include::/include::..\\//;\n\tprint CC $l;\n    }\n    close CC;\n    print C \"include::config/$filename\" . \"[]\\n\";\n}\n\nopen C, \"config.txt\" || die \"failed to open config.txt\";\nour @lines = <C>;\nclose C;\n\nour $start = 0;\nour $filename;\n\nopen F, \"grep -n '^[a-z].*::\\$' config.txt|\" || die \"failed to grep\";\nopen C, \">config.txt.new\" || die \"unable to open config.txt.new\";\nwhile (<F>) {\n    chomp;\n    $_ =~ m/([^:]*):(.*)/;\n    my $line = $1;\n    my $name = $2;\n    $name =~ s/\\*/_/g;\n    $name =~ s/<//g;\n    $name =~ s/>//g;\n    $name =~ s/::$//;\n    $name = \"http.speedLimit\" if $name eq \"http.lowSpeedLimit, http.lowSpeedTime\";\n    $name = \"gitcvs.userpass\" if $name eq \"gitcvs.dbuser, gitcvs.dbpass\";\n    next if $line - $start == 1;\n    if ($start > 0) {\n\textract $line;\n    } else {\n\tforeach $l (@lines[0..($line-2)]) {\n\t    print C $l;\n\t}\n    }\n    $start = $line;\n    $filename = $name . \".txt\";\n}\n\nextract $#lines + 2;\nclose C;\nsystem \"mv config.txt.new config.txt\";\n-- 8< --\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/206780/focus=206939\n"}]}