Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Konstantin Kharlamov <hi-angel@yandex.ru>
Cc: git@vger.kernel.org
Subject: Re: Getting path to a file from arbitrary project directory
Date: Fri, 23 Jun 2023 02:52:29 -0700	[thread overview]
Message-ID: <xmqqzg4qbj4y.fsf@gitster.g> (raw)
In-Reply-To: <21c8396c1441dd4f74cd2097ac970a2033b81da4.camel@yandex.ru> (Konstantin Kharlamov's message of "Fri, 23 Jun 2023 11:52:58 +0300")

Konstantin Kharlamov <hi-angel@yandex.ru> writes:

> 1: the usecase is I have a Emacs helper function to pick up a an
> aribtrarily mangled path to a file in the project from the primary
> clipboard and open that file. It's often "mangled", because gdb
> prints it with `../`, then logs print no path whatsoever, just a
> filename… So it's generally useful to have.

Sounds like you are looking for the top (and possibly glob) magic
pathspec, e.g. in the source tree of Git itself, I can go a few
levels down into a random directory and get exactly the same listing
of two files whose name is "rerere.c" located in two directories:

    $ cd t/helper
    $ git ls-files --full-name ':(top,glob)**/rerere.c'
    builtin/rerere.c
    rerere.c

Look for magic pathspec in "git help glossary" to learn more.



  parent reply	other threads:[~2023-06-23  9:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23  8:52 Getting path to a file from arbitrary project directory Konstantin Kharlamov
2023-06-23  9:45 ` SZEDER Gábor
2023-06-23 10:02   ` Konstantin Kharlamov
2023-06-23  9:52 ` Junio C Hamano [this message]
2023-06-23 10:02   ` Konstantin Kharlamov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzg4qbj4y.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hi-angel@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox