git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Green <greenrd@greenrd.org>
To: git@vger.kernel.org
To: git@vger.kernel.org
Cc: Robin Green <greenrd@greenrd.org>
Subject: [TopGit PATCH] Make tg help work in any directory
Date: Sun, 24 Oct 2010 14:34:59 +0000	[thread overview]
Message-ID: <1287930899-20186-1-git-send-email-greenrd@greenrd.org> (raw)

tg was checking if the current directory is a git repository,
which isn't necessary if the command is "help" or there is no
command.

Signed-off-by: Robin Green <greenrd@greenrd.org>

---
 tg.sh |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/tg.sh b/tg.sh
index 8264a3b..03ef227 100644
--- a/tg.sh
+++ b/tg.sh
@@ -356,16 +356,25 @@ setup_pager()
 
 ## Initial setup
 
-set -e
-git_dir="$(git rev-parse --git-dir)"
-root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}"
+cmd="$1"
+[ -z "$tg__include" ] || cmd="include" # ensure setup happens
+case "$cmd" in
+help|--help|-h)
+        :;;
+*)
+        if [ -n "$cmd" ]; then
+            set -e
+            git_dir="$(git rev-parse --git-dir)"
+            root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}"
 # Make sure root_dir doesn't end with a trailing slash.
-root_dir="${root_dir%/}"
-base_remote="$(git config topgit.remote 2>/dev/null)" || :
-tg="tg"
+            root_dir="${root_dir%/}"
+            base_remote="$(git config topgit.remote 2>/dev/null)" || :
+            tg="tg"
 # make sure merging the .top* files will always behave sanely
-setup_ours
-setup_hook "pre-commit"
+            setup_ours
+            setup_hook "pre-commit"
+        fi
+esac
 
 ## Dispatch
 
@@ -385,7 +394,6 @@ if [ "$1" = "-r" ]; then
 	tg="$tg -r $base_remote"
 fi
 
-cmd="$1"
 [ -n "$cmd" ] || { do_help; exit 1; }
 shift
 
-- 
tg: (8b0f1f9..) t/help-anywhere (depends on: master)

                 reply	other threads:[~2010-10-24 16:14 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=1287930899-20186-1-git-send-email-greenrd@greenrd.org \
    --to=greenrd@greenrd.org \
    --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).