]> git.madduck.net Git - code/myrepos.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Perform an "extract variable" refactoring to reduce duplication
authorAdam Spiers <mr@adamspiers.org>
Sun, 4 Dec 2011 21:50:07 +0000 (21:50 +0000)
committerJoey Hess <joey@kitenet.net>
Mon, 12 Dec 2011 17:46:34 +0000 (13:46 -0400)
and the chance of future typos.
(cherry picked from commit bb9a1f48de42059d0db23ece614de6fb29706d1a)

mr

diff --git a/mr b/mr
index e89d01a288285058046a17a9ebac7c359986c131..8883aab95464961498dc0c12adf5deece979299e 100755 (executable)
--- a/mr
+++ b/mr
@@ -546,6 +546,7 @@ my $jobs=1;
 my $trust_all=0;
 my $directory=getcwd();
 
+my $HOME_MR_CONFIG = "$ENV{HOME}/.mrconfig";
 $ENV{MR_CONFIG}=find_mrconfig();
 
 # globals :-(
@@ -1102,14 +1103,14 @@ sub is_trusted_config {
        my $config=shift; # must be abs_pathed already
 
        # We always trust ~/.mrconfig.
-       return 1 if $config eq abs_path("$ENV{HOME}/.mrconfig");
+       return 1 if $config eq abs_path($HOME_MR_CONFIG);
 
        return 1 if $trust_all;
 
        my $trustfile=$ENV{HOME}."/.mrtrust";
 
        if (! %trusted) {
-               $trusted{"$ENV{HOME}/.mrconfig"}=1;
+               $trusted{$HOME_MR_CONFIG}=1;
                if (open (TRUST, "<", $trustfile)) {
                        while (<TRUST>) {
                                chomp;
@@ -1732,7 +1733,7 @@ sub find_mrconfig {
                }
                $dir=~s/\/[^\/]*$//;
        }
-       return "$ENV{HOME}/.mrconfig";
+       return $HOME_MR_CONFIG;
 }
 
 sub getopts {
@@ -1802,7 +1803,7 @@ sub main {
        init();
 
        startingconfig();
-       loadconfig("$ENV{HOME}/.mrconfig");
+       loadconfig($HOME_MR_CONFIG);
        loadconfig($ENV{MR_CONFIG});
        #use Data::Dumper; print Dumper(\%config);