# interactive rebase editor pathname variable

3 messages from 2010-05-13 to 2010-05-14. Participants: Neal Kreitzinger, Jonathan Nieder, Bert Wesarg.
Thread: https://gitlist.dev/t/23798

## Neal Kreitzinger, 2010-05-13 18:32

Subject: interactive rebase editor pathname variable
Message-ID: <hshglg$p2q$1@dough.gmane.org>
URL: https://gitlist.dev/e/hshglg%24p2q%241%40dough.gmane.org

```
Hi,

It appears that git-commit and git-tag pass a partial pathname to the 
core.editor, e.g. ".git/COMMIT_EDITMSG" that is relative to the working tree 
directory.  However, git-rebase -i passes an absolute pathname to the 
core.editor, e.g. 
"home/someuser/someworkingtree/.git/rebase-merge/git-rebase-todo".  This 
causes problems in our shop because our proprietary editor cannot handle 
pathnames beginning with a period (it translates the period to a slash) and 
therefore our entry for core.editor is 'someeditor "$PWD/$1"'.  This breaks 
on git rebase -i when the $1 contains the full pathname.  Can this be added 
to the bugfix list for git to make the $1 value passed to core.editor by all 
git commands to always be relative pathnames (or absolute pathnames).  FWIW, 
I prefer absolute pathnames because a config entry of 'someeditor $1' is 
more straightforward than 'someeditor "$PWD/$1"'.  (Note:  the reason I must 
pass $1 is because the editor runs on top of a runtime and is actually 
called as 'someruntime someeditor "$1"')

v/r,
Neal 

```

## Jonathan Nieder, 2010-05-14 07:59

Subject: Re: interactive rebase editor pathname variable
Message-ID: <20100514075913.GA3690@progeny.tock>
URL: https://gitlist.dev/e/20100514075913.GA3690%40progeny.tock
In-Reply-To: <hshglg$p2q$1@dough.gmane.org>

```
Hi Neal,

Neal Kreitzinger wrote:

> git-rebase -i passes an absolute pathname to the 
> core.editor, e.g. 
> "home/someuser/someworkingtree/.git/rebase-merge/git-rebase-todo".  This 
> causes problems in our shop because our proprietary editor cannot handle 
> pathnames beginning with a period (it translates the period to a slash) and 
> therefore our entry for core.editor is 'someeditor "$PWD/$1"'.

For your example, git uses the shell to run the following command.

  someeditor "$PWD/$1" "$@"

I would suggest something like the following instead.

  [core]
	editor = "sh -c '\
		case \"$1\" in \
		/*|[A-Za-z]:*) file=\"$1\";; \
		*) file=\"$(pwd)/$1\";; \
		esac; \
		someruntime someditor \"$file\"' -"

Hope that helps,
Jonathan

```

## Bert Wesarg, 2010-05-14 12:49

Subject: Re: interactive rebase editor pathname variable
Message-ID: <AANLkTimb8fCQoX31GkPqsjtnKgi6TLlUPToodZcZocHJ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimb8fCQoX31GkPqsjtnKgi6TLlUPToodZcZocHJ%40mail.gmail.com
In-Reply-To: <20100514075913.GA3690@progeny.tock>

```
On Fri, May 14, 2010 at 09:59, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Neal,
>
> Neal Kreitzinger wrote:
>
>> git-rebase -i passes an absolute pathname to the
>> core.editor, e.g.
>> "home/someuser/someworkingtree/.git/rebase-merge/git-rebase-todo".  This
>> causes problems in our shop because our proprietary editor cannot handle
>> pathnames beginning with a period (it translates the period to a slash) and
>> therefore our entry for core.editor is 'someeditor "$PWD/$1"'.
>
> For your example, git uses the shell to run the following command.
>
>  someeditor "$PWD/$1" "$@"
>
> I would suggest something like the following instead.
>
>  [core]
>        editor = "sh -c '\
>                case \"$1\" in \
>                /*|[A-Za-z]:*) file=\"$1\";; \
>                *) file=\"$(pwd)/$1\";; \
>                esac; \
>                someruntime someditor \"$file\"' -"
>

Barely tested:

someditor "$PWD/${1/#$PWD\//}"

Bert

> Hope that helps,
> Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```
