{"thread":{"id":"6899","subject":"[PATCH 1/2] Add config_boolean() method to the Git perl module","startedAt":"2007-02-20T20:13:42Z","lastAt":"2007-02-20T21:16:01Z","messageCount":3,"participants":["Theodore Ts'o","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"35138","messageId":"11720024233629-git-send-email-tytso@mit.edu","threadId":"6899","inReplyTo":null,"subject":"[PATCH 1/2] Add config_boolean() method to the Git perl module","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2007-02-20T20:13:42Z","receivedAt":"2007-02-20T20:13:42Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"Signed-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n---\n perl/Git.pm |   30 ++++++++++++++++++++++++++++++\n 1 files changed, 30 insertions(+), 0 deletions(-)\n\ndiff --git a/perl/Git.pm b/perl/Git.pm\nindex f2c156c..51bd73e 100644\n--- a/perl/Git.pm\n+++ b/perl/Git.pm\n@@ -516,6 +516,36 @@ sub config {\n }\n \n \n+=item config_boolean ( VARIABLE )\n+\n+Retrieve the boolean configuration C<VARIABLE>.\n+\n+Must be called on a repository instance.\n+\n+This currently wraps command('config') so it is not so fast.\n+\n+=cut\n+\n+sub config_boolean {\n+\tmy ($self, $var) = @_;\n+\t$self->repo_path()\n+\t\tor throw Error::Simple(\"not a repository\");\n+\n+\ttry {\n+\t\treturn $self->command_oneline('config', '--bool', '--get', \n+\t\t\t\t\t      $var);\n+\t} catch Git::Error::Command with {\n+\t\tmy $E = shift;\n+\t\tif ($E->value() == 1) {\n+\t\t\t# Key not found.\n+\t\t\treturn undef;\n+\t\t} else {\n+\t\t\tthrow $E;\n+\t\t}\n+\t};\n+}\n+\n+\n =item ident ( TYPE | IDENTSTR )\n \n =item ident_person ( TYPE | IDENTSTR | IDENTARRAY )\n-- \n1.5.0.1.38.g392d-dirty\n"},{"id":"35139","messageId":"11720024234178-git-send-email-tytso@mit.edu","threadId":"6899","inReplyTo":"11720024233629-git-send-email-tytso@mit.edu","subject":"[PATCH 2/2] Allow git-remote to update named groups of remotes","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2007-02-20T20:13:43Z","receivedAt":"2007-02-20T20:13:43Z","isPatch":true,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"In response to a feature request from Shawn Pearce, this patch allows\na user to update a named group of remotes by using \"git remote update\n<group>\", where the group is defined in the config file by\nremotes.<group>.  The default if the named group is not specified is\nnow fetched group remotes.default, instead of remote.fetch, which is\nwhat had been previously used.\n\nIn addition, if remotes.default is not defined, all remotes defined in\nthe config file will be used, as before, but there is now also\npossible to request that a particular repository to be skipped by\ndefault by using the boolean configuration parameter\nremote.<name>.skipDefaultUpdate.\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n---\n Documentation/config.txt     |   12 ++++++++----\n Documentation/git-remote.txt |   11 +++++++----\n git-remote.perl              |   40 +++++++++++++++++++++++++++++++---------\n 3 files changed, 46 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex d8e696f..c8cba00 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -439,10 +439,6 @@ pull.octopus::\n pull.twohead::\n \tThe default merge strategy to use when pulling a single branch.\n \n-remote.fetch::\n-\tThe list of remotes which are fetched by \"git remote update\".\n-\tSee gitlink:git-remote[1].\n-\n remote.<name>.url::\n \tThe URL of a remote repository.  See gitlink:git-fetch[1] or\n \tgitlink:git-push[1].\n@@ -455,6 +451,10 @@ remote.<name>.push::\n \tThe default set of \"refspec\" for gitlink:git-push[1]. See\n \tgitlink:git-push[1].\n \n+remote.<name>.skipDefaultUpdate::\n+\tIf true, this remote will be skipped by default when updating \n+\tusing the remote subcommand of gitlink:git-remote[1].\n+\n remote.<name>.receivepack::\n \tThe default program to execute on the remote side when pushing.  See\n \toption \\--exec of gitlink:git-push[1].\n@@ -463,6 +463,10 @@ remote.<name>.uploadpack::\n \tThe default program to execute on the remote side when fetching.  See\n \toption \\--exec of gitlink:git-fetch-pack[1].\n \n+remotes.<group>::\n+\tThe list of remotes which are fetched by \"git remote update\n+\t<group>\".  See gitlink:git-remote[1].\n+\n repack.usedeltabaseoffset::\n \tAllow gitlink:git-repack[1] to create packs that uses\n \tdelta-base offset.  Defaults to false.\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 06ba2e6..250761f 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n 'git-remote' add <name> <url>\n 'git-remote' show <name>\n 'git-remote' prune <name>\n-'git-remote' update\n+'git-remote' update [group]\n \n DESCRIPTION\n -----------\n@@ -46,9 +46,12 @@ referenced by <name>, but are still locally available in\n \n 'update'::\n \n-Fetch updates for the remotes in the repository.  By default all remotes\n-are updated, but this can be configured via the configuration parameter\n-'remote.fetch'.   (See gitlink:git-config[1]).\n+Fetch updates for a named set of remotes in the repository as defined by\n+remotes.<group>.  If a named group is not specified on the command line,\n+the configuration parameter remotes.default will get used; if\n+remotes.default is not defined, all remotes which do not the\n+configuration parameter remote.<name>.skipDefaultUpdate set to true will\n+be updated.  (See gitlink:git-config[1]).\n \n \n DISCUSSION\ndiff --git a/git-remote.perl b/git-remote.perl\nindex 6e473ec..5a4e0ed 100755\n--- a/git-remote.perl\n+++ b/git-remote.perl\n@@ -274,6 +274,31 @@ sub add_remote {\n \t}\n }\n \n+sub update_remote {\n+\tmy ($name) = @_;\n+\n+        my $conf = $git->config(\"remotes.\" . $name);\n+\tif (defined($conf)) {\n+\t\t@remotes = split(' ', $conf);\n+\t} elsif ($name eq 'default') {\n+\t    \tundef @remotes;\n+\t\tfor (sort keys %$remote) {\n+\t\t\tmy $do_fetch = $git->config_boolean(\"remote.\" . $_ . \n+\t\t\t\t\t\t    \".skipDefaultUpdate\");\n+\t\t\tif (!defined($do_fetch) || $do_fetch ne \"true\") {\n+\t\t\t\tpush @remotes, $_;\n+\t\t\t}\n+\t\t}\n+\t} else {\n+\t\tprint STDERR \"Remote group $name does not exists.\\n\";\n+\t\texit(1);\n+\t}\n+\tfor (@remotes) {\n+\t\tprint \"Updating $_\\n\";\n+\t\t$git->command('fetch', \"$_\");\n+\t}\n+}\n+\n sub add_usage {\n \tprint STDERR \"Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\\n\";\n \texit(1);\n@@ -304,15 +329,12 @@ elsif ($ARGV[0] eq 'show') {\n \t}\n }\n elsif ($ARGV[0] eq 'update') {\n-        my $conf = $git->config(\"remote.fetch\");\n-\tif (defined($conf)) {\n-\t\t@remotes = split(' ', $conf);\n-\t} else {\n-\t        @remotes = sort keys %$remote;\n+\tif (@ARGV <= 1) {\n+\t\tupdate_remote(\"default\");\n+\t\texit(1);\n \t}\n-\tfor (@remotes) {\n-\t\tprint \"Fetching $_\\n\";\n-\t\t$git->command('fetch', \"$_\");\n+\tfor ($i = 1; $i < @ARGV; $i++) {\n+\t\tupdate_remote($ARGV[$i]);\n \t}\n }\n elsif ($ARGV[0] eq 'prune') {\n@@ -372,6 +394,6 @@ else {\n \tprint STDERR \"       git remote add <name> <url>\\n\";\n \tprint STDERR \"       git remote show <name>\\n\";\n \tprint STDERR \"       git remote prune <name>\\n\";\n-\tprint STDERR \"       git remote update\\n\";\n+\tprint STDERR \"       git remote update [group]\\n\";\n \texit(1);\n }\n-- \n1.5.0.1.38.g392d-dirty\n"},{"id":"35142","messageId":"20070220211601.GA27598@localdomain","threadId":"6899","inReplyTo":"11720024233629-git-send-email-tytso@mit.edu","subject":"Re: [PATCH 1/2] Add config_boolean() method to the Git perl module","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-02-20T21:16:01Z","receivedAt":"2007-02-20T21:16:01Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Theodore Ts'o <tytso@mit.edu> wrote:\n> Signed-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n\nThanks.  I've been meaning to add something like this myself.\n\nconfig_int() would be nice, too :)\n\n-- \nEric Wong\n"}]}