threads / discuss / 12835

Effects of alias not changing the directory

Subject: Effects of alias not changing the directory

## tl;dr

One message between Mar 24, 2008 and Mar 24, 2008.

replies: 0people: 1as markdown or json

Logan Kennelly· Mar 24, 2008, 05:27 UTC · lore

At the request of some of my coworkers, I created a wrapper script that allows them to use a graphical diff tool when they wish. I effectively add a new command through the use of an alias:

  [alias]
   exdiff = "!GIT_EXTERNAL_DIFF=git_exdiff.sh GIT_PAGER=cat git diff"

This command works extremely well when run by itself (`git exdiff`) but fails when run from a subdirectory and given a relative path because the alias machinery changes the current directory as demonstrated here:

  [alias]
   echopath = "!echo $PWD"
   $ cd /path/git_tracked/a/b
   $ git echopath
   /path/git_tracked

Is there a reason for this behavior? I'd like to submit a patch, but I'm concerned that I'm missing something. If it helps, I believe it is the setup_git_directory_gently logic (called from handle_alias) that results in the chdir.

Thank you.

← back to recent threads