]> 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:

add help and diff commands
authorJoey Hess <joey@kodama.kitenet.net>
Thu, 11 Oct 2007 17:38:18 +0000 (13:38 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Thu, 11 Oct 2007 17:38:18 +0000 (13:38 -0400)
INSTALL
debian/rules
mr

diff --git a/INSTALL b/INSTALL
index 69af33f6cb38f1bd0c7c9c79c7258a0273193d25..d2b53703b8a730622de510dabd5f0691a94d5a99 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1 +1,5 @@
+mr is intended to be very self-contained, since it might be useful to check
+it into ~/bin when keeping your home in version control. It has no
+dependencies aside from basic perl.
+
 Just copy mr into your PATH somewhere, and set up ~/.mrconfig
index cb8604b46adcd74392c5ef0f72fc08ce549a1fd9..76c53e8dbdcb590563bde2953abf7d37bf953875 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/make -f
 
 build:
-       pod2man -c mr mr > mr.1
+       ./mr help > mr.1
 
 clean:
        dh_testdir
diff --git a/mr b/mr
index f26b144687cac43bc09abea6ce6ec992e85026f8..17418124d2011194ed5c084afbb2e5eefbc70f8c 100755 (executable)
--- a/mr
+++ b/mr
@@ -14,6 +14,8 @@ B<mr> [options] status
 
 B<mr> [options] commit [-m "message"]
 
+B<mr> [options] diff
+
 B<mr> [options] action [params ...]
 
 =head1 DESCRIPTION
@@ -54,6 +56,14 @@ like git.)
 
 The optional -m parameter allows specifying a commit message.
 
+=item diff
+
+Show a diff of uncommitted changes.
+
+=item help
+
+Displays this help.
+
 =back
 
 Actions can be abbreviated to any unambiguous subsctring, so
@@ -167,7 +177,9 @@ my $result=GetOptions(
        "v" => \$verbose,
 );
 if (! $result || @ARGV < 1) {
-       die("Usage: mr [-d directory] action [params ...]\n");
+       die("Usage: mr [-d directory] action [params ...]\n".
+           "(Use mr help for man page.)\n");
+
 }
 
 loadconfig(\*DATA);
@@ -175,6 +187,11 @@ loadconfig($config);
 #use Data::Dumper;
 #print Dumper(\%config);
 
+eval {
+       use FindBin qw($Bin $Script);
+       $ENV{MR_PATH}=$Bin."/".$Script;
+};
+
 # alias expansion and command stemming
 my $action=shift @ARGV;
 if (! exists $knownactions{$action}) {
@@ -193,6 +210,10 @@ if (! exists $knownactions{$action}) {
        }
 }
 
+if ($action eq 'help') {
+       exec($config{''}{default}{help});
+}
+
 # handle being in a subdir of a repository
 foreach my $topdir (sort keys %config) {
        foreach my $subdir (sort keys %{$config{$topdir}}) {
@@ -217,7 +238,6 @@ foreach my $topdir (sort keys %config) {
                }
 
                action($action, $dir, $topdir, $subdir);
-
        }
 }
 
@@ -436,3 +456,17 @@ commit = \
        else \
                error "unknown repo type"; \
        fi
+diff = \
+       if [ -d .svn ]; then \
+               svn diff "$@"; \
+       elif [ -d .git ]; then \
+               git diff "$@"; \
+       else \
+               error "unknown repo type"; \
+       fi
+help = \
+       if [ ! -e "$MR_PATH" ]; then \
+               error "cannot find program path";\
+       fi; \
+       (pod2man -c mr "$MR_PATH" | man -l -) || \
+               error "pod2man or man failed"