# Bug report: checkout-index --temp path is not always relative to the current directory

2 messages from 2014-12-30 to 2014-12-30. Participants: Josh Bleecher Snyder, Eric Sunshine.
Thread: https://gitlist.dev/t/38266

## Josh Bleecher Snyder, 2014-12-30 22:21

Subject: Bug report: checkout-index --temp path is not always relative to the current directory
Message-ID: <CAFAcib9tz+EDqWx=nohxEbH3FRbwUweabKHTyBF-dioh6G-KKg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFAcib9tz%2BEDqWx%3DnohxEbH3FRbwUweabKHTyBF-dioh6G-KKg%40mail.gmail.com

```
In the section on using --temp, 'git help checkout-index' says:

"The path field is always relative to the current directory and the
temporary file names are always relative to the top level directory."

However, this can be false when an absolute path to the file is provided.

Reproduction:

~$ git version
git version 2.2.1
~$ mkdir demo
~$ cd demo
~/demo$ mkdir a
~/demo$ echo "a" > a/f
~/demo$ mkdir b
~/demo$ echo "b" > b/f
~/demo$ git init .
Initialized empty Git repository in ~/demo/.git/
~/demo$ git add .
~/demo$ git commit -m "init"
[master (root-commit) 2afa910] init
 2 files changed, 2 insertions(+)
 create mode 100644 a/f
 create mode 100644 b/f
~/demo$ echo "b2" > b/f
~/demo$ cd a
~/demo/a$ git checkout-index --temp -- `git rev-parse --show-toplevel`/b/f
.merge_file_xm8RTd f
~/demo/a$ cat ../.merge_file_xm8RTd
b

Note that if f in the checkout-index output is interpreted as relative
to the current directory, it would refer to a/f, whereas in fact is it
b/f.

This led to https://github.com/golang/go/issues/9476.

Thanks,
Josh

```

## Eric Sunshine, 2014-12-30 22:25

Subject: Re: Bug report: checkout-index --temp path is not always relative to the current directory
Message-ID: <CAPig+cRSfb=tQ4zUnzutZsj_R590juPU-jFCdJ6+E=x51tguRQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRSfb%3DtQ4zUnzutZsj_R590juPU-jFCdJ6%2BE%3Dx51tguRQ%40mail.gmail.com
In-Reply-To: <CAFAcib9tz+EDqWx=nohxEbH3FRbwUweabKHTyBF-dioh6G-KKg@mail.gmail.com>

```
On Tue, Dec 30, 2014 at 5:21 PM, Josh Bleecher Snyder
<josharian@gmail.com> wrote:
> In the section on using --temp, 'git help checkout-index' says:
>
> "The path field is always relative to the current directory and the
> temporary file names are always relative to the top level directory."
>
> However, this can be false when an absolute path to the file is provided.

See [1] for a fix.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/261796

> Reproduction:
>
> ~$ git version
> git version 2.2.1
> ~$ mkdir demo
> ~$ cd demo
> ~/demo$ mkdir a
> ~/demo$ echo "a" > a/f
> ~/demo$ mkdir b
> ~/demo$ echo "b" > b/f
> ~/demo$ git init .
> Initialized empty Git repository in ~/demo/.git/
> ~/demo$ git add .
> ~/demo$ git commit -m "init"
> [master (root-commit) 2afa910] init
>  2 files changed, 2 insertions(+)
>  create mode 100644 a/f
>  create mode 100644 b/f
> ~/demo$ echo "b2" > b/f
> ~/demo$ cd a
> ~/demo/a$ git checkout-index --temp -- `git rev-parse --show-toplevel`/b/f
> .merge_file_xm8RTd f
> ~/demo/a$ cat ../.merge_file_xm8RTd
> b
>
> Note that if f in the checkout-index output is interpreted as relative
> to the current directory, it would refer to a/f, whereas in fact is it
> b/f.
>
> This led to https://github.com/golang/go/issues/9476.
>
> Thanks,
> Josh

```
