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

Re: git locate

From
BSBruce Stephens <bruce.stephens@isode.com>
Date
Jun 2, 2010, 10:23 UTC
Message-ID
<80y6ex3f8b.fsf@tiny.isode.net>
In-Reply-To
<AANLkTil38OLw3J6ZPvv2wNu98QuTXJKtNwRZP0NDZPWn@mail.gmail.com>
John Tapsell <johnflux@gmail.com> writes:
[...]
> Actually could someone help me with this.. the trouble is that this
> returns paths relative to the root.
>
> Can I get it to find all the files, but relative to where I am now?

Something like this is probably part of the answer, which allows an alias like this to work:

	locate = !cd $GIT_CWD && sh -c 'git ls-files "*$1*"' -
That doesn't give you all the files (just those below where you are).
diff --git a/git.c b/git.c
index 99f0363..81c877b 100644
--- a/git.c
+++ b/git.c
@@ -178,6 +178,10 @@ static int handle_alias(int *argcp, const char ***argv)
                        }
                        trace_printf("trace: alias to shell cmd: %s => %s\n",
                                     alias_command, alias_string + 1);
+                       if (!subdir || !*subdir)
+                         setenv("GIT_CWD", "./", 1);
+                       else
+                         setenv("GIT_CWD", subdir, 1);
                        ret = system(alias_string + 1);
                        if (ret >= 0 && WIFEXITED(ret) &&
                            WEXITSTATUS(ret) != 127)
Previous: John TapsellNext: Matthieu Moy
Message 14 of 17 in “git locate”
  1. John TapsellJan 20, 2010
  2. Johannes SchindelinJan 20, 2010
  3. Jakub NarebskiJan 20, 2010
  4. Johannes SchindelinJan 20, 2010
  5. Jakub NarebskiJan 20, 2010
  6. John TapsellJan 20, 2010
  7. Johannes SchindelinJan 20, 2010
  8. SungHyun NamJan 21, 2010
  9. Michael J GruberJan 21, 2010
  10. Štěpán NěmecJan 21, 2010
  11. Sverre RabbelierFeb 15, 2010
  12. John TapsellJun 2, 2010
  13. John TapsellJun 2, 2010
  14. Bruce StephensJun 2, 2010
  15. Matthieu MoyJun 2, 2010
  16. Clemens BuchacherJun 3, 2010
  17. Nguyen Thai Ngoc DuyJun 2, 2010

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.