* Re: Slight enhancement of GIT wrapper
[not found] <200504132249.16848.pisa@cmp.felk.cvut.cz>
@ 2005-04-13 22:55 ` Petr Baudis
2005-04-13 23:07 ` Johannes Schindelin
2005-04-13 23:10 ` Johannes Schindelin
[not found] ` <200505241235.02597.pisa@cmp.felk.cvut.cz>
1 sibling, 2 replies; 5+ messages in thread
From: Petr Baudis @ 2005-04-13 22:55 UTC (permalink / raw)
To: Pavel Pisa; +Cc: git
Dear diary, on Wed, Apr 13, 2005 at 10:49:16PM CEST, I got a letter
where Pavel Pisa <pisa@cmp.felk.cvut.cz> told me that...
> Ahoj Petre,
Hi,
cc'ing git@vger.kernel.org so that we hopefully get less of duplicated
work (and maybe even some more insights).
> Index: commit-id
> ===================================================================
> Index: git
> ===================================================================
> --- 6c355da7a316f50742eeffa49405a15e75526012/git (mode:100755 sha1:f766a87adff6e17d24cd97417d7303f2cdab6f3c)
> +++ 85f2d458ffebf52569e777af222accc1268afdf9/git (mode:100755 sha1:c179a65c3955e39bda18dc8a314b061bc0fb5de7)
> @@ -9,6 +9,7 @@
> # This command mostly only multiplexes to the individual script based
> # on the first argument.
>
> +
> error () {
> echo git: $@ >&2
> }
> @@ -17,6 +18,25 @@
> exit 1
> }
>
> +cwd="`pwd 2> /dev/null`"
Please use $() instead of ``.
Why do you silence stderr?
> +
> +if [ -h "$0" ]; then
> + GIT_DIR=`ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/'`
Well, I don't like this much, but I'm not sure how to do better.
> + GIT_DIR=`dirname "$GIT_DIR"`
> +else
> + GIT_DIR=`dirname "$0"`
> +fi
We use tabs for indentation.
> +cd "$GIT_DIR"
> +GIT_DIR="`pwd 2> /dev/null`"
Why do you silence stderr?
> +cd "$cwd" 2> /dev/null
> +if [ $? -gt 0 ] ; then
> + die "Cannot return back to the CWD $cwd"
> +fi
I'd personally just cd "$cwd" || exit 1
> +
> +export PATH=$GIT_DIR:$PATH
You should add $GIT_DIR to $PATH only when it is not there already. This
way you can still override some of the git tools by stuffing your
overrides to $PATH.
> +
> +#echo GIT_DIR=$GIT_DIR
> +#echo PATH=$PATH
?
>
> help () {
> cat <<__END__
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Slight enhancement of GIT wrapper
2005-04-13 22:55 ` Slight enhancement of GIT wrapper Petr Baudis
@ 2005-04-13 23:07 ` Johannes Schindelin
2005-04-13 23:10 ` Johannes Schindelin
1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2005-04-13 23:07 UTC (permalink / raw)
To: Petr Baudis; +Cc: Pavel Pisa, git
Hi,
On Thu, 14 Apr 2005, Petr Baudis wrote:
> Dear diary, on Wed, Apr 13, 2005 at 10:49:16PM CEST, I got a letter
> where Pavel Pisa <pisa@cmp.felk.cvut.cz> told me that...
>
> > +
> > +if [ -h "$0" ]; then
> > + GIT_DIR=`ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/'`
>
> Well, I don't like this much, but I'm not sure how to do better.
How about
GIT_DIR=$(ls -L "$0")
Ciao,
Dscho
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Slight enhancement of GIT wrapper
2005-04-13 22:55 ` Slight enhancement of GIT wrapper Petr Baudis
2005-04-13 23:07 ` Johannes Schindelin
@ 2005-04-13 23:10 ` Johannes Schindelin
1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2005-04-13 23:10 UTC (permalink / raw)
To: Petr Baudis; +Cc: Pavel Pisa, git
Hi,
please ignore the mail I just sent.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 5+ messages in thread
* GIT and COGITO individual scripts hidding from PATH
[not found] ` <20050524111333.GA11223@pasky.ji.cz>
@ 2005-05-27 16:24 ` Pavel Pisa
2005-05-27 16:29 ` Pavel Pisa
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Pisa @ 2005-05-27 16:24 UTC (permalink / raw)
To: Petr Baudis, git
Hello All,
I prefer to have as small number of executables in /usr/bin
and /user/local/bin as possible. I have tried to push original
Peter's git script to this direction for my strange personal taste.
COGITO has taken different direction than. I have hidden cogito and git
under wrapper to make me happy again. I thing that it is against good
opensource habits to keep changes secret even if I do not expect
interrest in this version. But may it be, that it can make
happy somebody with same taste as I have.
The "cgt" is wrapper for all cogito programs. If cogito is
build and installed to any prefix directory (/opt/git-cogito in my case)
and script is copied to bin subdirectory (/opt/git-cogito/bin),
then only single symbolic link from some searchable directory on PATH
is enough to call all cogito commands
cgt pull
cgt update
so usage is more convenient for my fingers learned to type cvs up, etc.
I think, that addition of intelligent bash completion could be done easier
if number of the first level commands to cover is smaller.
Best wishes
Pavel Pisa
"cgt" script
--------------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.
error () {
echo cgt: $@ >&2
}
die () {
error $@
exit 1
}
if [ -z "$GIT_TOOLS_DIR" ] ; then
GIT_MUXBINARY_DIR="$(dirname "$0")"
if [ -h "$0" ]; then
#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
GIT_TOOLS_DIR="$(readlink -f -n $0)"
GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
else
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
fi
if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ;
then
export PATH="$GIT_TOOLS_DIR:$PATH"
fi
export GIT_TOOLS_DIR
fi
#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit
help () {
echo "cgt recognizes next commands:" >&2
(cd $GIT_TOOLS_DIR ; ls cg-* ) | sed -n -e 's/\<cg-\([^ ]*\)\>/\1/pg' >&2
}
cmd=$1; shift
if [ ! "$cmd" ]; then
error "missing command"
help
exit 1
fi
cgt_cmd_exe="${GIT_TOOLS_DIR}/cg-$cmd"
if [ ! -e "$cgt_cmd_exe" ]; then
error "unrecognized command ${cmd}"
help
exit 1
fi
"$cgt_cmd_exe" "$@"
--------------------------------------------------------------------------------
"git" script
--------------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.
error () {
echo git: $@ >&2
}
die () {
error $@
exit 1
}
if [ -z "$GIT_TOOLS_DIR" ] ; then
GIT_MUXBINARY_DIR="$(dirname "$0")"
if [ -h "$0" ]; then
#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
GIT_TOOLS_DIR="$(readlink -f -n $0)"
GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
else
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
fi
if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ;
then
export PATH="$GIT_TOOLS_DIR:$PATH"
fi
export GIT_TOOLS_DIR
fi
#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit
help () {
echo "git recognizes next commands:" >&2
(cd $GIT_TOOLS_DIR ; ls git-* ) | sed -n -e 's/\<git-\([^ ]*\)\>/\1/pg' >&2
}
cmd=$1; shift
if [ ! "$cmd" ]; then
error "missing command"
help
exit 1
fi
git_cmd_exe="${GIT_TOOLS_DIR}/git-$cmd"
if [ ! -e "$git_cmd_exe" ]; then
error "unrecognized command ${cmd}"
help
exit 1
fi
"$git_cmd_exe" "$@"
--------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: GIT and COGITO individual scripts hidding from PATH
2005-05-27 16:24 ` GIT and COGITO individual scripts hidding from PATH Pavel Pisa
@ 2005-05-27 16:29 ` Pavel Pisa
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Pisa @ 2005-05-27 16:29 UTC (permalink / raw)
To: Petr Baudis; +Cc: git
Excuse me for resending of e-mail again, but I have forget
to disable wrapping of lines. Sending as attachmet would be
more secure, but I do not know, if it is convenient
on the git list.
The "cgt" is wrapper for all cogito programs. If cogito is
build and installed to any prefix directory (/opt/git-cogito in my case)
and script is copied to bin subdirectory (/opt/git-cogito/bin),
then only single symbolic link from some searchable directory on PATH
is enough to call all cogito commands
cgt pull
cgt update
so usage is more convenient for my fingers learned to type cvs up, etc.
I think, that addition of intelligent bash completion could be done easier
if number of the first level commands to cover is smaller.
"cgt" script
---------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.
error () {
echo cgt: $@ >&2
}
die () {
error $@
exit 1
}
if [ -z "$GIT_TOOLS_DIR" ] ; then
GIT_MUXBINARY_DIR="$(dirname "$0")"
if [ -h "$0" ]; then
#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
GIT_TOOLS_DIR="$(readlink -f -n $0)"
GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
else
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
fi
if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ; then
export PATH="$GIT_TOOLS_DIR:$PATH"
fi
export GIT_TOOLS_DIR
fi
#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit
help () {
echo "cgt recognizes next commands:" >&2
(cd $GIT_TOOLS_DIR ; ls cg-* ) | sed -n -e 's/\<cg-\([^ ]*\)\>/\1/pg' >&2
}
cmd=$1; shift
if [ ! "$cmd" ]; then
error "missing command"
help
exit 1
fi
cgt_cmd_exe="${GIT_TOOLS_DIR}/cg-$cmd"
if [ ! -e "$cgt_cmd_exe" ]; then
error "unrecognized command ${cmd}"
help
exit 1
fi
"$cgt_cmd_exe" "$@"
---------------------------------------------------------------------------
"git" script
---------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.
error () {
echo git: $@ >&2
}
die () {
error $@
exit 1
}
if [ -z "$GIT_TOOLS_DIR" ] ; then
GIT_MUXBINARY_DIR="$(dirname "$0")"
if [ -h "$0" ]; then
#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
GIT_TOOLS_DIR="$(readlink -f -n $0)"
GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
else
GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
fi
if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ; then
export PATH="$GIT_TOOLS_DIR:$PATH"
fi
export GIT_TOOLS_DIR
fi
#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit
help () {
echo "git recognizes next commands:" >&2
(cd $GIT_TOOLS_DIR ; ls git-* ) | sed -n -e 's/\<git-\([^ ]*\)\>/\1/pg' >&2
}
cmd=$1; shift
if [ ! "$cmd" ]; then
error "missing command"
help
exit 1
fi
git_cmd_exe="${GIT_TOOLS_DIR}/git-$cmd"
if [ ! -e "$git_cmd_exe" ]; then
error "unrecognized command ${cmd}"
help
exit 1
fi
"$git_cmd_exe" "$@"
---------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-05-27 16:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <200504132249.16848.pisa@cmp.felk.cvut.cz>
2005-04-13 22:55 ` Slight enhancement of GIT wrapper Petr Baudis
2005-04-13 23:07 ` Johannes Schindelin
2005-04-13 23:10 ` Johannes Schindelin
[not found] ` <200505241235.02597.pisa@cmp.felk.cvut.cz>
[not found] ` <20050524111333.GA11223@pasky.ji.cz>
2005-05-27 16:24 ` GIT and COGITO individual scripts hidding from PATH Pavel Pisa
2005-05-27 16:29 ` Pavel Pisa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox