git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Next: Johannes Schindelin
Message 1 of 5 in “Re: Slight enhancement of GIT wrapper”
  1. Petr BaudisApr 13, 2005
  2. Johannes SchindelinApr 13, 2005
  3. Johannes SchindelinApr 13, 2005
  4. GIT and COGITO individual scripts hidding from PATHPavel Pisa, May 27, 2005
  5. Pavel PisaMay 27, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.