# adding file by absolute name -- problem

9 messages from 2007-04-23 to 2007-04-23. Participants: Yakov Lerner, Junio C Hamano, Johannes Schindelin, Julian Phillips, Carlos Rica.
Thread: https://gitlist.dev/t/7792

## Yakov Lerner, 2007-04-23 09:39

Subject: adding file by absolute name -- problem
Message-ID: <f36b08ee0704230239i4892983q4feb4a1872a320ea@mail.gmail.com>
URL: https://gitlist.dev/e/f36b08ee0704230239i4892983q4feb4a1872a320ea%40mail.gmail.com

```
When I give absolute pathname /a/b/repo/d to git add, it
mostly does not work. I get errors from git-add. Is it by design ?

(When I cd to repo and fo 'git-add d', it works. But
'git-add `pwd`/d' gives error. I use scrits that wrap git-add
and give it mostly absolute names, and they fail).

Besides, I get infinite loop in git-add (1.5.1.1) when several
absolute names are given to git-add. I am trying to investigate it

Yakov

```

## Junio C Hamano, 2007-04-23 10:04

Subject: Re: adding file by absolute name -- problem
Message-ID: <7v8xcjh0e8.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v8xcjh0e8.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <f36b08ee0704230239i4892983q4feb4a1872a320ea@mail.gmail.com>

```
"Yakov Lerner" <iler.ml@gmail.com> writes:

> When I give absolute pathname /a/b/repo/d to git add, it
> mostly does not work. I get errors from git-add. Is it by design ?

It's pretty much by design in the sense that none of us felt any
need for accepting absolute pathnames, and I personally still
don't.  But I do not have a strong feeling against accepting a
patch series that adds support for accepting absolute pathnames,
as long as it is done cleanly and obviously.

```

## Johannes Schindelin, 2007-04-23 10:16

Subject: Re: adding file by absolute name -- problem
Message-ID: <Pine.LNX.4.64.0704231215370.8822@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0704231215370.8822%40racer.site
In-Reply-To: <f36b08ee0704230239i4892983q4feb4a1872a320ea@mail.gmail.com>

```
Hi,

On Mon, 23 Apr 2007, Yakov Lerner wrote:

> When I give absolute pathname /a/b/repo/d to git add, it
> mostly does not work. I get errors from git-add. Is it by design ?

AFAICT it is by design. I fail to see why absolute paths should be 
supported, too. You are supposed to be _in_ the working directory when 
adding files...

Ciao,
Dscho

```

## Yakov Lerner, 2007-04-23 10:30

Subject: Re: adding file by absolute name -- problem
Message-ID: <f36b08ee0704230330if89d417udefb8e50062d5a05@mail.gmail.com>
URL: https://gitlist.dev/e/f36b08ee0704230330if89d417udefb8e50062d5a05%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.64.0704231215370.8822@racer.site>

```
On 4/23/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Mon, 23 Apr 2007, Yakov Lerner wrote:
>
> > When I give absolute pathname /a/b/repo/d to git add, it
> > mostly does not work. I get errors from git-add. Is it by design ?
>
> AFAICT it is by design. I fail to see why absolute paths should be
> supported, too. You are supposed to be _in_ the working directory when
> adding files...

Let's say I have $SRC that points to the dir of sources. Let's say
I am testing the software, somewhere under /tmp. I edit sources as
'vi $SRC/something' and I am not in $SRC. I could do 'make -C $SRC' and
I can do everything (incl checkins) without switching cwd back and
forth all the time.

CVS did not accept absolute pathnames, and SVN does. It is really convenient.
I felt perceptible added comfort when I switched from CVS to cvs in this aspect.
CVS's way of not accepting abs paths was not convenient.

But talking about implementation. How would I, generically,  go about
finding the base .git when absolute path is given ? Is dropping basenmes
one-by-one and checking for .git a good method ? Or just demand that GITDIR
be set when absolute name is given ?

Yakov

```

## Yakov Lerner, 2007-04-23 10:32

Subject: Re: adding file by absolute name -- problem
Message-ID: <f36b08ee0704230332o7a54d74bu2ede0e99c0f34799@mail.gmail.com>
URL: https://gitlist.dev/e/f36b08ee0704230332o7a54d74bu2ede0e99c0f34799%40mail.gmail.com
In-Reply-To: <f36b08ee0704230330if89d417udefb8e50062d5a05@mail.gmail.com>

```
Typo correction:
> switched from CVS to cvs in this aspect.
Should be
switched from CVS to SVN in this aspect.

Yakov

```

## Johannes Schindelin, 2007-04-23 10:51

Subject: Re: adding file by absolute name -- problem
Message-ID: <Pine.LNX.4.64.0704231247480.8822@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0704231247480.8822%40racer.site
In-Reply-To: <f36b08ee0704230330if89d417udefb8e50062d5a05@mail.gmail.com>

```
Hi,

On Mon, 23 Apr 2007, Yakov Lerner wrote:

> CVS did not accept absolute pathnames, and SVN does. It is really convenient.

I do not feel very comfortable with the thought. If you have symbolic 
links somewhere along the path, it is easy to get wrong.

This line of thought got me confused: would

$ ln -s /tmp x
$ touch x/y
$ git add x/y

work?

*clicketyclick*

Yes, it does. It ignores the fact that x is not a directory, but a 
symbolic link. Lots of opportunities to shoot yourself in the foot.

Think about the consequences of doing something like this in one 
repository, where "x" points into another one...

Ciao,
Dscho

```

## Julian Phillips, 2007-04-23 11:02

Subject: Re: adding file by absolute name -- problem
Message-ID: <Pine.LNX.4.64.0704231156230.3653@reaper.quantumfyre.co.uk>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0704231156230.3653%40reaper.quantumfyre.co.uk
In-Reply-To: <f36b08ee0704230330if89d417udefb8e50062d5a05@mail.gmail.com>

```
On Mon, 23 Apr 2007, Yakov Lerner wrote:

> On 4/23/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>>  Hi,
>>
>>  On Mon, 23 Apr 2007, Yakov Lerner wrote:
>> 
>> >  When I give absolute pathname /a/b/repo/d to git add, it
>> >  mostly does not work. I get errors from git-add. Is it by design ?
>>
>>  AFAICT it is by design. I fail to see why absolute paths should be
>>  supported, too. You are supposed to be _in_ the working directory when
>>  adding files...
>
> Let's say I have $SRC that points to the dir of sources. Let's say
> I am testing the software, somewhere under /tmp. I edit sources as
> 'vi $SRC/something' and I am not in $SRC. I could do 'make -C $SRC' and
> I can do everything (incl checkins) without switching cwd back and
> forth all the time.

git () { cd $SRC; ~/bin/git "$@"; } ?

-- 
Julian

  ---
Man and wife make one fool.

```

## Carlos Rica, 2007-04-23 13:39

Subject: Re: adding file by absolute name -- problem
Message-ID: <1b46aba20704230639k56fc1839qcad38f1e5ee0e238@mail.gmail.com>
URL: https://gitlist.dev/e/1b46aba20704230639k56fc1839qcad38f1e5ee0e238%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.64.0704231215370.8822@racer.site>

```
Hi!

2007/4/23, Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Hi,
>
> On Mon, 23 Apr 2007, Yakov Lerner wrote:
>
> > When I give absolute pathname /a/b/repo/d to git add, it
> > mostly does not work. I get errors from git-add. Is it by design ?
>
> AFAICT it is by design. I fail to see why absolute paths should be
> supported, too. You are supposed to be _in_ the working directory when
> adding files...

Since it is by design, a posible solution could be support an optional
parameter to give the program the path of the directory (something as
--dir /a/b). Then you could build a command line to be run from
another place, without using absolute paths in the rest of parameters.
Maybe it would be easier to implement by interested people. Anyway, I
don't need this feature, too.

I think that if currently the program does not support absolute paths,
this should be clearly stated in error messages and check for that in
a centralized place.

```

## Johannes Schindelin, 2007-04-23 14:23

Subject: Re: adding file by absolute name -- problem
Message-ID: <Pine.LNX.4.64.0704231622160.8822@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0704231622160.8822%40racer.site
In-Reply-To: <1b46aba20704230639k56fc1839qcad38f1e5ee0e238@mail.gmail.com>

```
Hi,

On Mon, 23 Apr 2007, Carlos Rica wrote:

> Since it is by design, a posible solution could be support an optional
> parameter to give the program the path of the directory (something as
> --dir /a/b).

:-)

You mean something like

	git --git-dir /path/to/repo add relative/path/to/file

Hmm?

Ciao,
Dscho

```
