tg.sh: Runtime tg-* command check
PATCH 1/1 tg.sh: Runtime tg-* command check
Check for tg commands at runtime, not the hard coded list inside tg.sh.
--- tg.sh | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-)
tg.sh +21 -5
@@ -152,8 +152,21 @@ switch_to_base() do_help() { if [ -z "$1" ] ; then + ## Build available commands list for help output + + cmds= + sep= + for cmd in "@cmddir@"/tg-*; do + ! [ -r "$cmd" ] && continue + # strip directory part and "tg-" prefix + cmd="$(basename "$cmd")" + cmd="${cmd#tg-}" + cmds="$cmds$sep$cmd" + sep="|" + done + echo "TopGit v0.1 - A different patch queue manager" - echo "Usage: tg (create|delete|info|patch|summary|update|help) ..." + echo "Usage: tg ($cmds|help) ..." elif [ -f "@sharedir@/tg-$1.txt" ] ; then cat "@sharedir@/tg-$1.txt" else
@@ -171,6 +184,8 @@ root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}" setup_ours setup_hook "pre-commit" +[ -d "@cmddir@" ] || + die "No command directory: '@cmddir@'" ## Dispatch
@@ -186,12 +201,13 @@ case "$cmd" in help) do_help "$1" exit 1;; -create|delete|info|patch|summary|update) - . "@cmddir@"/tg-$cmd;; --hooks-path) # Internal command echo "@hooksdir@";; *) - echo "Unknown subcommand: $cmd" >&2 - exit 1;; + [ -r "@cmddir@"/tg-$cmd ] || { + echo "Unknown subcommand: $cmd" >&2 + exit 1 + } + . "@cmddir@"/tg-$cmd;; esac
Signature · 1 line
tg: (e311d15..) t/auto-generate-command-list-for-tg.sh (depends on: master)
PATCH 1/1 tg.sh: Check for read permissions of help files
We currently check only for '-f' but we need to have read permissions as well.
And help files don't need the execution bit set.
--- Makefile | 2 +- tg.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -35,7 +35,7 @@ install:: all install -d -m 755 "$(hooksdir)" install $(hooks_out) "$(hooksdir)" install -d -m 755 "$(sharedir)" - install $(help_out) "$(sharedir)" + install -m 644 $(help_out) "$(sharedir)" clean:: rm -f tg $(commands_out) $(hooks_out) $(help_out)
tg.sh +1 -1
@@ -154,7 +154,7 @@ do_help() if [ -z "$1" ] ; then echo "TopGit v0.1 - A different patch queue manager" echo "Usage: tg (create|delete|info|patch|summary|update|help) ..." - elif [ -f "@sharedir@/tg-$1.txt" ] ; then + elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; then cat "@sharedir@/tg-$1.txt" else echo "`basename $0`: no help for $1" 1>&2
Signature · 1 line
tg: (e311d15..) t/check-read-permissions-of-help-files (depends on: master)
PATCH 1/1 Pretty print the help creation commands in Makefile.
Print "[HELP] cmdname" while compiling the tg-cmdname.txt files.
--- Makefile | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
Makefile +3 -1
@@ -26,7 +26,9 @@ tg $(commands_out) $(hooks_out): % : %.sh mv $@+ $@ $(help_out): README - ./create-help.sh `echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` + @CMD=`echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` && \ + echo '[HELP]' $$CMD && \ + ./create-help.sh $$CMD install:: all install tg "$(bindir)"
Signature · 10 lines
tg: (e311d15..) t/help2 (depends on: master) -- Russell Steicke -- Fortune says: Today is the first day of the rest of your life.
Re: [TopGit PATCH] tg.sh: Check for read permissions of help files
In reply to Bert WesargPetr,
tg.sh do_help() · line 157
Quoted 2 lines · Bert Wesarg
tg.sh +1
-1- elif [ -f "@sharedir@/tg-$1.txt" ] ; then + elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; then
I saw your simplified commit for this, but you should know, that '-r' tests only for read permissions, not for a regular file, so this test succeed also for a pipe/socket for which do you have read permissions.
Bert
Quoted 6 lines
cat "@sharedir@/tg-$1.txt" else echo "`basename $0`: no help for $1" 1>&2--
tg: (e311d15..) t/check-read-permissions-of-help-files (depends on: master)
Re: [TopGit PATCH] tg.sh: Check for read permissions of help files
Quoted 8 lines · Bert Wesarg
Petr,
tg.sh do_help() · line 157
Quoted 2 lines · Bert Wesarg
tg.sh +1
-1- elif [ -f "@sharedir@/tg-$1.txt" ] ; then + elif [ -f "@sharedir@/tg-$1.txt" -a -r "@sharedir@/tg-$1.txt" ] ; thenI saw your simplified commit for this, but you should know, that '-r' tests only for read permissions, not for a regular file, so this test succeed also for a pipe/socket for which do you have read permissions.
Is that a problem? :-)
Petr "Pasky" Baudis
PATCH 1/1 Makefile: mkdir $(bindir)
Mkdir $(bindir) in install target.
--- Makefile | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Makefile +1 -0
@@ -29,6 +29,7 @@ $(help_out): README ./create-help.sh `echo $@ | sed -e 's/tg-//' -e 's/\.txt//'` install:: all + install -d -m 755 "$(bindir)" install tg "$(bindir)" install -d -m 755 "$(cmddir)" install $(commands_out) "$(cmddir)"
Signature · 1 line
tg: (e311d15..) t/mkdir-bindir (depends on: master)
PATCH 1/1 tg.sh: it's info/attributes not info/gitattributes
The merge attribute hasn't any effect, because the wrong attribute file was used.
--- tg.sh | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
tg.sh +2 -2
@@ -45,11 +45,11 @@ setup_hook() # setup_ours (no arguments) setup_ours() { - if [ ! -s "$git_dir/info/gitattributes" ] || ! grep -q topmsg "$git_dir/info/gitattributes"; then + if [ ! -s "$git_dir/info/attributes" ] || ! grep -q topmsg "$git_dir/info/attributes"; then { echo -e ".topmsg\tmerge=ours" echo -e ".topdeps\tmerge=ours" - } >>"$git_dir/info/gitattributes" + } >>"$git_dir/info/attributes" fi if ! git config merge.ours.driver >/dev/null; then git config merge.ours.name '"always keep ours" merge driver'
Signature · 1 line
tg: (e311d15..) t/its-info-attributes (depends on: master)
Re: [PATCH] [TopGit] Pretty print the help creation commands in Makefile.
Hi,
thanks, patches applied (after heavy dose of swearing in the general
direction of git-am and git-apply at #git - now I'm really ashamed I've ever put "git is well-suited for patch-oriented workflows" on any of my slides).
Signature · 3 lines
Petr "Pasky" Baudis The next generation of interesting software will be done on the Macintosh, not the IBM PC. -- Bill Gates