threads / bug / 38266

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

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

## tl;dr

2 messages between Dec 30, 2014 and Dec 30, 2014.

replies: 1people: 2as markdown or json

Josh Bleecher Snyder· Dec 30, 2014, 22:21 UTC · lore
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· Dec 30, 2014, 22:25 UTC · re: Josh Bleecher Snyder · lore

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

On Tue, Dec 30, 2014 at 5:21 PM, Josh Bleecher Snyder <josharian@gmail.com> wrote:

Show 6 quoted lines
> 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
Show 33 quoted lines
> 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

← back to recent threads