]> git.madduck.net Git - code/myrepos.git/blobdiff - mr

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:

allow aliases to override defined commands
[code/myrepos.git] / mr
diff --git a/mr b/mr
index 470927afa04094d00d1a5a61f64db4bc11906f20..01a9feb6ae1001e8c97258423832202fd25f4e82 100755 (executable)
--- a/mr
+++ b/mr
@@ -218,24 +218,22 @@ eval {
 
 # alias expansion and command stemming
 my $action=shift @ARGV;
+if (exists $alias{$action}) {
+       $action=$alias{$action};
+}
 if (! exists $knownactions{$action}) {
-       if (exists $alias{$action}) {
-               $action=$alias{$action};
+       my @matches = grep { /^\Q$action\E/ }
+               keys %knownactions, keys %alias;
+       if (@matches == 1) {
+               $action=$matches[0];
+       }
+       elsif (@matches == 0) {
+               die "mr: unknown action \"$action\" (known actions: ".
+                       join(", ", sort keys %knownactions).")\n";
        }
        else {
-               my @matches = grep { /^\Q$action\E/ }
-                       keys %knownactions, keys %alias;
-               if (@matches == 1) {
-                       $action=$matches[0];
-               }
-               elsif (@matches == 0) {
-                       die "mr: unknown action \"$action\" (known actions: ".
-                               join(", ", sort keys %knownactions).")\n";
-               }
-               else {
-                       die "mr: ambiguous action \"$action\" (matches: ".
-                               join(", ", @matches).")\n";
-               }
+               die "mr: ambiguous action \"$action\" (matches: ".
+                       join(", ", @matches).")\n";
        }
 }
 
@@ -298,10 +296,6 @@ sub action {
        }
        
        $ENV{MR_REPO}=$dir;
-       if (! $nochdir && ! chdir($dir)) {
-               print STDERR "mr $action: failed to chdir to $dir: $!\n";
-               push @skipped, $dir;
-       }
 
        if (exists $config{$topdir}{$subdir}{skip}) {
                my $test="set -e;".$lib.$config{$topdir}{$subdir}{skip};
@@ -313,8 +307,12 @@ sub action {
                        return;
                }
        }
-
-       if (! exists $config{$topdir}{$subdir}{$action}) {
+       
+       if (! $nochdir && ! chdir($dir)) {
+               print STDERR "mr $action: failed to chdir to $dir: $!\n";
+               push @failed, $dir;
+       }
+       elsif (! exists $config{$topdir}{$subdir}{$action}) {
                print STDERR "mr $action: no defined $action command for $topdir$subdir, skipping\n";
                push @skipped, $dir;
        }
@@ -473,12 +471,14 @@ __DATA__
        co = checkout
        ci = commit
        ls = list
+
 [default]
 lib = \
        error() { \
                echo "mr: $@" >&2; \
                exit 1; \
        }
+
 update = \
        if [ -d "$MR_REPO"/.svn ]; then \
                svn update "$@"; \
@@ -530,9 +530,13 @@ log = \
                error "unknown repo type"; \
        fi
 list = true
+
 help = \
        if [ ! -e "$MR_PATH" ]; then \
                error "cannot find program path";\
        fi; \
        (pod2man -c mr "$MR_PATH" | man -l -) || \
                error "pod2man or man failed"
+
+ed = echo "A horse is a horse, of course, of course.."
+T = echo "I pity the fool."