git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Change git-rev-parse --show-cdup to output an absolute path

From
Alex Riesen <raa.lkml@gmail.com>
Date
Apr 26, 2007, 11:57 UTC
Message-ID
<81b0412b0704260457p2783ee9t6d08f0a9dca3b54e@mail.gmail.com>
In-Reply-To
<46306A29.4010608@midwinter.com>
On 4/26/07, Steven Grimm <koreth@midwinter.com> wrote:
Show 9 quoted lines
> Alex Riesen wrote:
> > Your implementation will fail if cwd is longer than PATH_MAX.
> > Does not happen often, though.
>
> That limitation is already littered through the code, e.g. in setup.c
> which would already be failing in the existing implementation. Actually
> setup.c goes one better: is_inside_git_dir() hardwires a 1024-character
> limit into the code rather than using PATH_MAX. I didn't think I was
> introducing a new limit here.
It is yet another place to fix when it breaks.
Show 12 quoted lines
> >> A typical failure case:
> >>
> >> $ git clone git://whatever.git foobar
> >> $ ln -s foobar/src/tools/misc/myapp myapp
> >> $ cd myapp
> >
> > Which is a strange thing to do. What is that for?
> > myapp is kind of outside the git repo foobar.
>
> For convenience, mostly; obviously that example was a bit contrived but
> I do have several symlinks to subdirectories of my repository and it's
> faster to type "cd ~/xyz" than "cd ~/repo/src/server/xyz" all the time.

Can't you use your shells variables or aliases (which is even faster to type)?

Show 7 quoted lines
> That was actually my initial approach to fixing this -- I put "cd
> `/bin/pwd`" at the top of the "cd_to_toplevel" function in
> git-sh-setup.sh. But it felt cleaner to make git-rev-parse return the
> actual correct path so it'd work for shell scripts that didn't happen to
> use git-sh-setup.sh. I'm happy to go either way, or of course to keep
> this as a local modification if folks find it too distasteful to include
> in the official source.

I'm not really objecting. It's just a bit unusual so I suspect unusual problems coming out of it. Kind of when you try running with your eyes closed.

Previous: Alex Riesen
Message 6 of 6 in “Change git-rev-parse --show-cdup to output an absolute path”
  1. Change git-rev-parse --show-cdup to output an absolute pathkoreth@midwinter.com, Apr 25, 2007
  2. Alex RiesenApr 26, 2007
  3. Steven GrimmApr 26, 2007
  4. Use PATH_MAX rather than a hardwired constant maximum length.koreth@midwinter.com, Apr 26, 2007
  5. Alex RiesenApr 26, 2007
  6. Alex RiesenApr 26, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.