# "git stash" is not known to git

14 messages from 2007-07-30 to 2007-07-31. Participants: David Kastrup, Matthieu Moy, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/9307

## David Kastrup, 2007-07-30 09:22

Subject: "git stash" is not known to git
Message-ID: <86bqduutz4.fsf@lola.quinscape.zz>
URL: https://gitlist.dev/e/86bqduutz4.fsf%40lola.quinscape.zz

```

One has to use git-stash rather than "git stash".  Oversight?

-- 
David Kastrup

```

## Matthieu Moy, 2007-07-30 09:44

Subject: Re: "git stash" is not known to git
Message-ID: <vpqwswi2pkw.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqwswi2pkw.fsf%40bauges.imag.fr
In-Reply-To: <86bqduutz4.fsf@lola.quinscape.zz>

```
David Kastrup <dak@gnu.org> writes:

> One has to use git-stash rather than "git stash".  Oversight?

This looks like an incorrect installation, with git-stash in your
$PATH, but not in the place git looks for its commands (I don't
remember the exact mechanism).

-- 
Matthieu

```

## David Kastrup, 2007-07-30 09:57

Subject: Re: "git stash" is not known to git
Message-ID: <863az6uscz.fsf@lola.quinscape.zz>
URL: https://gitlist.dev/e/863az6uscz.fsf%40lola.quinscape.zz
In-Reply-To: <vpqwswi2pkw.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> One has to use git-stash rather than "git stash".  Oversight?
>
> This looks like an incorrect installation, with git-stash in your
> $PATH, but not in the place git looks for its commands (I don't
> remember the exact mechanism).

I don't think so: in git.c we have at lines 362ff

                { "show-branch", cmd_show_branch, RUN_SETUP },
                { "show", cmd_show, RUN_SETUP | USE_PAGER },
                { "stripspace", cmd_stripspace },
                { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },

So it really seems like stash is not known to git.c.  Of course, I
have no real clue about git.c's operation (or I'd have proferred a
patch) and not right now the time to look further.

-- 
David Kastrup

```

## Jeff King, 2007-07-30 10:04

Subject: Re: "git stash" is not known to git
Message-ID: <20070730100408.GA8829@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20070730100408.GA8829%40coredump.intra.peff.net
In-Reply-To: <vpqwswi2pkw.fsf@bauges.imag.fr>

```
On Mon, Jul 30, 2007 at 11:44:31AM +0200, Matthieu Moy wrote:

> > One has to use git-stash rather than "git stash".  Oversight?
> 
> This looks like an incorrect installation, with git-stash in your
> $PATH, but not in the place git looks for its commands (I don't
> remember the exact mechanism).

On a related note, is it just me, or is the following comment and related code
in git.c (introduced by Linus in 231af832) totally bogus:

  /*
   * We search for git commands in the following order:
   *  - git_exec_path()
   *  - the path of the "git" command if we could find it
   *    in $0
   *  - the regular PATH.
   */

We never actually look in the regular PATH since we call execv_git_cmd
(although we do still munge the PATH, apparently so shell scripts can
use git-foo syntax; see 77cb17e9). This means you can't drop "git-foo"
into your PATH and have it work as "git foo".

What is the desired behavior?

-Peff

```

## Jeff King, 2007-07-30 10:06

Subject: Re: "git stash" is not known to git
Message-ID: <20070730100609.GB8829@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20070730100609.GB8829%40coredump.intra.peff.net
In-Reply-To: <863az6uscz.fsf@lola.quinscape.zz>

```
On Mon, Jul 30, 2007 at 11:57:00AM +0200, David Kastrup wrote:

> > This looks like an incorrect installation, with git-stash in your
> > $PATH, but not in the place git looks for its commands (I don't
> > remember the exact mechanism).
> 
> I don't think so: in git.c we have at lines 362ff
> 
>                 { "show-branch", cmd_show_branch, RUN_SETUP },
>                 { "show", cmd_show, RUN_SETUP | USE_PAGER },
>                 { "stripspace", cmd_stripspace },
>                 { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
> 
> So it really seems like stash is not known to git.c.  Of course, I
> have no real clue about git.c's operation (or I'd have proferred a
> patch) and not right now the time to look further.

That list is for builtins; git-stash is an external shell script. See
execv_git_cmd for the list of places where it is looking for git-stash.

Since I seem to recall you working some symlink magic with your
installation in a recent message, that might be related. Is it just
git-stash, or are other scripts failing (try "git status")?

-Peff

```

## Junio C Hamano, 2007-07-30 10:12

Subject: Re: "git stash" is not known to git
Message-ID: <7vy7gyjj3c.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7gyjj3c.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <86bqduutz4.fsf@lola.quinscape.zz>

```
David Kastrup <dak@gnu.org> writes:

> One has to use git-stash rather than "git stash".  Oversight?

Does any of the other shell-scripts work without dashes?
E.g. commit, merge, am, checkout?

If they do, then probably you are invoking older versions of
these scripts than what you think you are.  "git" itself looks
at GIT_EXEC_PATH and then the $(gitexecdir) from the Makefile
when it was built for its subcommands.

Perhaps this is your "symlinked install" gone awry?  I dunno.

```

## David Kastrup, 2007-07-30 10:24

Subject: Re: "git stash" is not known to git
Message-ID: <86lkcytci4.fsf@lola.quinscape.zz>
URL: https://gitlist.dev/e/86lkcytci4.fsf%40lola.quinscape.zz
In-Reply-To: <20070730100609.GB8829@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> Since I seem to recall you working some symlink magic with your
> installation in a recent message, that might be related. Is it just
> git-stash, or are other scripts failing (try "git status")?

Hmpf.  On another system (git version 1.5.3.rc3.48.g0d59d) this works.
I don't have the system at hand right now where it doesn't.  So it
would be my guess that either I have not called the install-symlinks
target recently enough, or its implementation on that system has been
broken for some time.

I'll have to check this evening.

On the other hand, I am quite sure that while "git stash" did not
work, "git-stash" had no problem.

So something bogus in git's PATH lookup would definitely appear to be
going on: it should be hard to get the symlinks messed up badly enough
to have one work and not the other.

More this evening.

-- 
David Kastrup

```

## Jeff King, 2007-07-30 10:37

Subject: Re: "git stash" is not known to git
Message-ID: <20070730103720.GA11309@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20070730103720.GA11309%40coredump.intra.peff.net
In-Reply-To: <86lkcytci4.fsf@lola.quinscape.zz>

```
On Mon, Jul 30, 2007 at 12:24:51PM +0200, David Kastrup wrote:

> On the other hand, I am quite sure that while "git stash" did not
> work, "git-stash" had no problem.

Right. git-stash is in your PATH, but not in git's exec path (which is
_not_ the same as PATH).

> So something bogus in git's PATH lookup would definitely appear to be
> going on: it should be hard to get the symlinks messed up badly enough
> to have one work and not the other.

Git doesn't look for subcommands in the PATH.

-Peff

```

## David Kastrup, 2007-07-30 10:52

Subject: Re: "git stash" is not known to git
Message-ID: <86bqdutb7r.fsf@lola.quinscape.zz>
URL: https://gitlist.dev/e/86bqdutb7r.fsf%40lola.quinscape.zz
In-Reply-To: <20070730103720.GA11309@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Mon, Jul 30, 2007 at 12:24:51PM +0200, David Kastrup wrote:
>
>> On the other hand, I am quite sure that while "git stash" did not
>> work, "git-stash" had no problem.
>
> Right. git-stash is in your PATH, but not in git's exec path (which is
> _not_ the same as PATH).

How does it calculate its exec path?  It would appear that it would
not contain _either_ /usr/local/bin _or_ /opt/git/bin in my
installation if it can't find git-stash (which should be statable in
both places).

Have a command handy for checking the exec path?

Ok, this is pretty much idle speculation until I am back at the system
in question, but I have problems envisioning just what kind of goof
might have happened here.

-- 
David Kastrup

```

## Jeff King, 2007-07-30 11:03

Subject: Re: "git stash" is not known to git
Message-ID: <20070730110354.GA11676@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20070730110354.GA11676%40coredump.intra.peff.net
In-Reply-To: <86bqdutb7r.fsf@lola.quinscape.zz>

```
On Mon, Jul 30, 2007 at 12:52:40PM +0200, David Kastrup wrote:

> How does it calculate its exec path?  It would appear that it would
> not contain _either_ /usr/local/bin _or_ /opt/git/bin in my
> installation if it can't find git-stash (which should be statable in
> both places).

See exec_cmd.c:execv_git_cmd. It checks in order:
  1. --exec-path= on command line
  2. $GIT_EXEC_PATH from environment
  3. GIT_EXEC_PATH defined at compile-time (set by Makefile from
      $(gitexecdir), which is generally the same as $(bindir))

So it should have /opt/git/bin in your case, but it's possible since
that is a Makefile variable that you failed to recompile correctly after
changing its value.

> Have a command handy for checking the exec path?

git --exec-path

-Peff

```

## Junio C Hamano, 2007-07-30 17:52

Subject: Re: "git stash" is not known to git
Message-ID: <7vtzrlkccp.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vtzrlkccp.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20070730100408.GA8829@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On a related note, is it just me, or is the following comment and related code
> in git.c (introduced by Linus in 231af832) totally bogus:
>
>   /*
>    * We search for git commands in the following order:
>    *  - git_exec_path()
>    *  - the path of the "git" command if we could find it
>    *    in $0
>    *  - the regular PATH.
>    */
>
> We never actually look in the regular PATH since we call execv_git_cmd
> (although we do still munge the PATH, apparently so shell scripts can
> use git-foo syntax; see 77cb17e9). This means you can't drop "git-foo"
> into your PATH and have it work as "git foo".
>
> What is the desired behavior?

I failed to spot patches to the area without updating the
comment.  What the code does is fine, the comment is stale.

```

## David Kastrup, 2007-07-30 19:30

Subject: Re: "git stash" is not known to git
Message-ID: <85ir81u1t1.fsf@lola.goethe.zz>
URL: https://gitlist.dev/e/85ir81u1t1.fsf%40lola.goethe.zz
In-Reply-To: <20070730110354.GA11676@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Mon, Jul 30, 2007 at 12:52:40PM +0200, David Kastrup wrote:
>
>> How does it calculate its exec path?  It would appear that it would
>> not contain _either_ /usr/local/bin _or_ /opt/git/bin in my
>> installation if it can't find git-stash (which should be statable in
>> both places).
>
> See exec_cmd.c:execv_git_cmd. It checks in order:
>   1. --exec-path= on command line
>   2. $GIT_EXEC_PATH from environment
>   3. GIT_EXEC_PATH defined at compile-time (set by Makefile from
>       $(gitexecdir), which is generally the same as $(bindir))
>
> So it should have /opt/git/bin in your case, but it's possible since
> that is a Makefile variable that you failed to recompile correctly after
> changing its value.
>
>> Have a command handy for checking the exec path?
>
> git --exec-path

dak@lola:/home/tmp/git$ git --exec-path
/opt/git/bin
dak@lola:/home/tmp/git$ git stash --help
Reformatting git-stash(1), please wait...
WARNING: terminal is not fully functional
-  (press RETURN)q
dak@lola:/home/tmp/git$ git-stash --help
dak@lola:/home/tmp/git$ Usage: /usr/local/bin/git-stash [ | list | show | apply | clear]

I think I'll just soak my head in a bucket.  Don't ask me _what_ I
imagined to be experiencing here.

Maybe missing out shell completion when not typing the hyphen or
similar nonsense.  Sorry for the noise.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

```

## Junio C Hamano, 2007-07-31 08:20

Subject: Re: "git stash" is not known to git
Message-ID: <7vps29f0gp.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vps29f0gp.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20070730100408.GA8829@coredump.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> We never actually look in the regular PATH since we call execv_git_cmd
> (although we do still munge the PATH, apparently so shell scripts can
> use git-foo syntax; see 77cb17e9). This means you can't drop "git-foo"
> into your PATH and have it work as "git foo".

Would this be a good replacement?

diff --git a/git.c b/git.c
index 2433355..25b8274 100644
--- a/git.c
+++ b/git.c
@@ -448,11 +448,11 @@ int main(int argc, const char **argv)
 	cmd = argv[0];
 
 	/*
-	 * We search for git commands in the following order:
-	 *  - git_exec_path()
-	 *  - the path of the "git" command if we could find it
-	 *    in $0
-	 *  - the regular PATH.
+	 * We execute external git command via execv_git_cmd(),
+	 * which looks at "--exec-path" option, GIT_EXEC_PATH
+	 * environment, and $(gitexecdir) in Makefile while built,
+	 * in this order.  For scripted commands, we prepend
+	 * the value of the exec_path variable to the PATH.
 	 */
 	if (exec_path)
 		prepend_to_path(exec_path, strlen(exec_path));

```

## Jeff King, 2007-07-31 13:52

Subject: Re: "git stash" is not known to git
Message-ID: <20070731135220.GA20679@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20070731135220.GA20679%40coredump.intra.peff.net
In-Reply-To: <7vps29f0gp.fsf@assigned-by-dhcp.cox.net>

```
On Tue, Jul 31, 2007 at 01:20:54AM -0700, Junio C Hamano wrote:

> +	 * We execute external git command via execv_git_cmd(),
> +	 * which looks at "--exec-path" option, GIT_EXEC_PATH
> +	 * environment, and $(gitexecdir) in Makefile while built,
> +	 * in this order.  For scripted commands, we prepend
> +	 * the value of the exec_path variable to the PATH.
>  	 */

Yes, that matches my reading of the code.

-Jeff

```
