git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: git@vger.kernel.org
Subject: Splitting config.txt
Date: Wed, 6 Mar 2013 21:01:42 +0700	[thread overview]
Message-ID: <20130306140141.GA24386@lanh> (raw)

We discussed this before about adding configuration variables into
individual command man pages [1]. This may be a step towards
that. With this, I could add selected configuration variables to
git-push.txt, for example, with a simple patch:

-- 8< --
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 1398025..c130c90 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -348,6 +348,13 @@ you are certain that nobody in the meantime fetched your earlier commit A
 overwrite it. In other words, "git push --force" is a method reserved for
 a case where you do mean to lose history.
 
+CONFIGURATION
+-------------
+
+include::config/push.default.txt[]
+include::config/remote.name.pushurl.txt[]
+include::config/remote.name.push.txt[]
+
 
 Examples
 --------
-- 8< --

I know it makes man pages longer (and more intimidating for new
users), but the point is we could select just important keys for each
man page, instead of all keys affecting the command.

I don't post the final patch that splits config.txt, just the script I
use to split it. You can try it yourself. It puts each config key into
a file under Documentation/config, with some characters mangled to be
more fs friendly. Run it inside Documentation/. generated git-config.1
is the same after the split.

-- 8< --
#!/usr/bin/perl

sub extract {
    my ($line) = @_;
    open CC, ">config/$filename" || die "failed to open config/$filename";
    foreach $l (@lines[($start - 1)..($line - 2)]) {
	$l =~ s/^include::/include::..\//;
	print CC $l;
    }
    close CC;
    print C "include::config/$filename" . "[]\n";
}

open C, "config.txt" || die "failed to open config.txt";
our @lines = <C>;
close C;

our $start = 0;
our $filename;

open F, "grep -n '^[a-z].*::\$' config.txt|" || die "failed to grep";
open C, ">config.txt.new" || die "unable to open config.txt.new";
while (<F>) {
    chomp;
    $_ =~ m/([^:]*):(.*)/;
    my $line = $1;
    my $name = $2;
    $name =~ s/\*/_/g;
    $name =~ s/<//g;
    $name =~ s/>//g;
    $name =~ s/::$//;
    $name = "http.speedLimit" if $name eq "http.lowSpeedLimit, http.lowSpeedTime";
    $name = "gitcvs.userpass" if $name eq "gitcvs.dbuser, gitcvs.dbpass";
    next if $line - $start == 1;
    if ($start > 0) {
	extract $line;
    } else {
	foreach $l (@lines[0..($line-2)]) {
	    print C $l;
	}
    }
    $start = $line;
    $filename = $name . ".txt";
}

extract $#lines + 2;
close C;
system "mv config.txt.new config.txt";
-- 8< --

[1] http://thread.gmane.org/gmane.comp.version-control.git/206780/focus=206939

                 reply	other threads:[~2013-03-06 14:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130306140141.GA24386@lanh \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).