All of lore.kernel.org
 help / color / mirror / Atom feed
* Getting path to a file from arbitrary project directory
@ 2023-06-23  8:52 Konstantin Kharlamov
  2023-06-23  9:45 ` SZEDER Gábor
  2023-06-23  9:52 ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: Konstantin Kharlamov @ 2023-06-23  8:52 UTC (permalink / raw)
  To: git

(please keep me CC'ed, I'm not subscribed)

Hello! I'm trying to solve a simple problem: while I am inside an arbitrary project directory, I want to get a path to a file `filename.c` located elsewhere in the same project.¹

One way to implement that is with a command chain:

	cd $(git rev-parse --show-toplevel) && git ls-files --full-name -- "*filename.c"

But it is pretty clunky, because that requires you to modify state (changing current directory). It may not matter though, but I'm just wondering if there's a better way to do that, something like `git ls-files --top -- …`, or anything like that? Haven't found nothing similar in `man git-ls-files`.

As a separate note, this doesn't work:

	ls-files --full-name -- $(git rev-parse --show-toplevel)"*filename.c"

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-23 10:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-06-23 10:02   ` Konstantin Kharlamov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.