git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Subject: git alias always chdir to top
Date: Wed, 3 Dec 2008 11:08:52 -0500	[thread overview]
Message-ID: <20081203160852.GA3773@osc.edu> (raw)

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

             reply	other threads:[~2008-12-03 16:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-03 16:08 Pete Wyckoff [this message]
2008-12-04 12:34 ` git alias always chdir to top Jeff King
2008-12-05 14:09   ` Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081203160852.GA3773@osc.edu \
    --to=pw@padd.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).