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

Re: [RFC/PATCH] Fix path prefixing in grep_object

From
Phil Hord <phil.hord@gmail.com>
Date
Aug 26, 2013, 17:07 UTC
Message-ID
<CABURp0okEN7cHF2ZWmk-8jf0QFmJN3p-P2bHvF2BH=ws7ne7wA@mail.gmail.com>
In-Reply-To
<CABURp0odEGgZO1yWFgXS+akPb4wJHiTLoQcmqBd00oYnPZ77vA@mail.gmail.com>
On Mon, Aug 26, 2013 at 12:49 PM, Phil Hord <phil.hord@gmail.com> wrote:
> If so, then I would like to point out to you the convenience I
> accidentally encountered using this tool.  Perhaps you didn't realize
> how helpful it was when you chose to use a colon there.

My itch comes from a case where I am looking for references in some other branch and I want to narrow my search.

  $ git grep object origin/master
  origin/master:.gitignore:/git-count-objects
  origin/master:.gitignore:/git-fsck-objects
  origin/master:.gitignore:/git-hash-object
  <8600 lines more deleted>

I find hits in the region that interests me and then I try to zoom in there. Conveniently, the path I want to search is right there on my screen. So I copy the part of the object reference I want to limit my search to, and I try again:

   $ git grep object origin/master:builtin/

Now, I find the file that has the code I wanted. But I want to do something fancier to it than grep, so this time I copy-and-paste the filename into my command line after typing 'git show':

   $ git show origin/master:builtin/pack-objects.c | vim -
But this doesn't work if the delimiter used was a colon.
   $ git show origin/master:builtin:pack-objects.c | vim -

I have to edit my copy-and-pasted text, which means I have think about it a bit, and it interrupts all the other things I was thinking about already. Eventually I might learn to do this edit automatically, except it is not needed most of the time. It is only needed when I provide a tree-path instead of a "branch <space> path". In the latter case, the full path is spelled out for me correctly. And in all other cases the filenames provided by git-grep are valid filenames or object names.

Previous: Phil HordNext: Junio C Hamano
Message 10 of 19 in “Fix path prefixing in grep_object”
  1. Fix path prefixing in grep_objectPhil Hord, Aug 25, 2013
  2. Phil HordAug 25, 2013
  3. Junio C HamanoAug 25, 2013
  4. Jonathan NiederAug 25, 2013
  5. Junio C HamanoAug 25, 2013
  6. Junio C HamanoAug 26, 2013
  7. Phil HordAug 26, 2013
  8. Junio C HamanoAug 26, 2013
  9. Phil HordAug 26, 2013
  10. Phil HordAug 26, 2013
  11. Junio C HamanoAug 26, 2013
  12. Phil HordAug 26, 2013
  13. Junio C HamanoAug 27, 2013
  14. Phil HordAug 27, 2013
  15. Junio C HamanoAug 26, 2013
  16. Phil HordAug 26, 2013
  17. Jeff KingAug 25, 2013
  18. Jonathan NiederAug 25, 2013
  19. Jeff KingAug 25, 2013

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.