git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git alias always chdir to top
@ 2008-12-03 16:08 Pete Wyckoff
  2008-12-04 12:34 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Pete Wyckoff @ 2008-12-03 16:08 UTC (permalink / raw)
  To: git

I have a git alias that takes a relative file name argument,
and would like to know from where in the tree it was invoked,
especially if inside a subdirectory of the git tree.

Consider .git/config:

    [alias]
	pwd = !/bin/pwd

Then a git tree:

    /home/me
	topdir/
	    .git/
	    subdir/
		subdir-y.c
	    topdir-x.c

Then inside /home/me/topdir, all is well:

    $ pwd
    /home/me/topdir
    $ git pwd
    /home/me/topdir

But inside /home/me/topdir/subdir, the pwd alias is invoked in the wrong
dir:

    $ pwd
    /home/me/topdir/subdir
    $ git pwd
    /home/me/topdir

The implication of this is that I call an alias command like:

    $ pwd
    /home/me/topdir/subdir
    $ git myalias subdir-y.c
    myalias: No such file subdir-y.c

It looks like handle_alias() uses setup_git_directory_gently() to
find the .git, which chdir()s up until it gets there.  Is there a
way to do this without changing the process current working
directory instead?  I could even handle an environment variable
saving the original cwd, but that's ickier.

		-- Pete

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-05 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-03 16:08 git alias always chdir to top Pete Wyckoff
2008-12-04 12:34 ` Jeff King
2008-12-05 14:09   ` Pete Wyckoff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).