{"thread":{"id":"25540","subject":"[TopGit PATCH] Make tg help work in any directory","startedAt":"2010-10-24T14:34:59Z","lastAt":"2010-10-24T14:34:59Z","messageCount":1,"participants":["Robin Green"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"154340","messageId":"1287930899-20186-1-git-send-email-greenrd@greenrd.org","threadId":"25540","inReplyTo":null,"subject":"[TopGit PATCH] Make tg help work in any directory","fromName":"Robin Green","fromEmail":"greenrd@greenrd.org","sentAt":"2010-10-24T14:34:59Z","receivedAt":"2010-10-24T14:34:59Z","isPatch":true,"sender":{"key":"greenrd@greenrd.org","avatar":"https://gravatar.com/avatar/fe9d42e91e6aee9f60063d7f29a314449a3e04d3ed3e2c521c464ea8c3a2859e?d=mp&s=160"},"body":"tg was checking if the current directory is a git repository,\nwhich isn't necessary if the command is \"help\" or there is no\ncommand.\n\nSigned-off-by: Robin Green <greenrd@greenrd.org>\n\n---\n tg.sh |   26 +++++++++++++++++---------\n 1 files changed, 17 insertions(+), 9 deletions(-)\n\ndiff --git a/tg.sh b/tg.sh\nindex 8264a3b..03ef227 100644\n--- a/tg.sh\n+++ b/tg.sh\n@@ -356,16 +356,25 @@ setup_pager()\n \n ## Initial setup\n \n-set -e\n-git_dir=\"$(git rev-parse --git-dir)\"\n-root_dir=\"$(git rev-parse --show-cdup)\"; root_dir=\"${root_dir:-.}\"\n+cmd=\"$1\"\n+[ -z \"$tg__include\" ] || cmd=\"include\" # ensure setup happens\n+case \"$cmd\" in\n+help|--help|-h)\n+        :;;\n+*)\n+        if [ -n \"$cmd\" ]; then\n+            set -e\n+            git_dir=\"$(git rev-parse --git-dir)\"\n+            root_dir=\"$(git rev-parse --show-cdup)\"; root_dir=\"${root_dir:-.}\"\n # Make sure root_dir doesn't end with a trailing slash.\n-root_dir=\"${root_dir%/}\"\n-base_remote=\"$(git config topgit.remote 2>/dev/null)\" || :\n-tg=\"tg\"\n+            root_dir=\"${root_dir%/}\"\n+            base_remote=\"$(git config topgit.remote 2>/dev/null)\" || :\n+            tg=\"tg\"\n # make sure merging the .top* files will always behave sanely\n-setup_ours\n-setup_hook \"pre-commit\"\n+            setup_ours\n+            setup_hook \"pre-commit\"\n+        fi\n+esac\n \n ## Dispatch\n \n@@ -385,7 +394,6 @@ if [ \"$1\" = \"-r\" ]; then\n \ttg=\"$tg -r $base_remote\"\n fi\n \n-cmd=\"$1\"\n [ -n \"$cmd\" ] || { do_help; exit 1; }\n shift\n \n-- \ntg: (8b0f1f9..) t/help-anywhere (depends on: master)\n"}]}