threads / discuss / 7792

adding file by absolute name -- problem

Subject: adding file by absolute name -- problem

## tl;dr

9 messages between Apr 23, 2007 and Apr 23, 2007.

replies: 8people: 5as markdown or json

Yakov Lerner· Apr 23, 2007, 09:39 UTC · lore

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· Apr 23, 2007, 10:04 UTC · re: Yakov Lerner · lore

Re: adding file by absolute name -- problem

"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· Apr 23, 2007, 10:16 UTC · re: Yakov Lerner · lore

Re: adding file by absolute name -- problem

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· Apr 23, 2007, 10:30 UTC · re: Johannes Schindelin · lore

Re: adding file by absolute name -- problem

On 4/23/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 10 quoted lines
> 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
Johannes Schindelin· Apr 23, 2007, 10:51 UTC · re: Yakov Lerner · lore

Re: adding file by absolute name -- problem

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· Apr 23, 2007, 11:02 UTC · re: Yakov Lerner · lore

Re: adding file by absolute name -- problem

On Mon, 23 Apr 2007, Yakov Lerner wrote:
Show 17 quoted lines
> 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· Apr 23, 2007, 13:39 UTC · re: Johannes Schindelin · lore

Re: adding file by absolute name -- problem

Hi!
2007/4/23, Johannes Schindelin <Johannes.Schindelin@gmx.de>:
Show 10 quoted lines
> 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· Apr 23, 2007, 14:23 UTC · re: Carlos Rica · lore

Re: adding file by absolute name -- problem

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

← back to recent threads