Re: Slight enhancement of GIT wrapper
- From
Petr Baudis <pasky@ucw.cz>
- Date
- Apr 13, 2005, 22:55 UTC
- Message-ID
- <20050413225509.GL25711@pasky.ji.cz>
- In-Reply-To
- <200504132249.16848.pisa@cmp.felk.cvut.cz>
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).
Show 19 quoted lines
> 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