News for hackers. Stuff that matters.
Re:Grep too slow? Use git-grep by gruseom on Tuesday July 09, 2013 @05:42PM (#6015748)
I haven't been able to figure out how to match a one-sided word boundary using git-grep. For example, say a file includes the word "router". You can do this to match the exact word:

  git grep -w router
But what if you want to match just the word boundary at the start ("rout") or at the end ("outer")?
Re:Grep too slow? Use git-grep by moonboots on Tuesday July 09, 2013 @05:56PM (#6015849)
The "--perl-regexp" flag to git grep enables perl flavored regexes, which contain explicit word boundary matching. To match only word starts, you could use the following:

    git grep --perl-regexp "\brout"

and for just word endings

    git grep --perl-regexp "outer\b"
Re:Grep too slow? Use git-grep by gruseom on Tuesday July 09, 2013 @06:53PM (#6016239)
This doesn't work for me, nor do the other two users' suggestions. I even just rebuilt git in case my version was out of date.
Re:Grep too slow? Use git-grep by dfc on Tuesday July 09, 2013 @07:14PM (#6016331)
Are you using homebrew?

  $ brew info git 
  git: stable 1.8.3.2, HEAD
  http://git-scm.com
  /usr/local/Cellar/git/HEAD (1324 files, 29M) *
    Built from source with: --with-blk-sha1 --with-pcre
  From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/git.rb
  ==> Dependencies
  Optional: pcre, gettext
  ==> Options
  --with-blk-sha1
	Compile with the block-optimized SHA1 implementation
  --with-gettext
	Build with gettext support
  --with-pcre
	Build with pcre support
  --without-completions
	Disable bash/zsh completions from "contrib" directory

What does "built from source with" say?
Re:Grep too slow? Use git-grep by gruseom on Tuesday July 09, 2013 @07:28PM (#6016395)
I don't use homebrew, but your comment made me realize what I needed to do to successfully compile git with pcre. As a result, this now works:

  git grep -P "outer\b"
Yay! Thank you and moonboots.

This is an important feature for me, because I organize my code lexically (primarily by being disciplined about using unique names for things) and rely on grep to quickly find what I want. Occasionally one unique name overlaps with another, and then I really want to match the word boundary.

Re:Grep too slow? Use git-grep by emmelaich on Wednesday July 10, 2013 @12:08AM (#6017401)
The standard grep symbols for beginning and end of word are \< and \>

So try those. (I don't have a git repo handy to test)

(edit: I tested and it works)

Re:Grep too slow? Use git-grep by nephyrin on Tuesday July 09, 2013 @05:56PM (#6015847)
git grep -E '\brout|outer\b'
Re:Grep too slow? Use git-grep by gruseom on Tuesday July 09, 2013 @08:40PM (#6016674)
Are you sure this works? I've tried it many times.
Re:Grep too slow? Use git-grep by michaelmior on Tuesday July 09, 2013 @06:40PM (#6016176)
git grep '\<rout'
Re:Grep too slow? Use git-grep by gruseom on Tuesday July 09, 2013 @07:29PM (#6016400)
This is the syntax I use in Emacs, so I would love it if git-grep would do the same. But it doesn't, for me. Are you sure that it does for you?
Re:Grep too slow? Use git-grep by emmelaich on Wednesday July 10, 2013 @12:13AM (#6017405)
Re:Grep too slow? Use git-grep by gruseom on Wednesday July 10, 2013 @02:50AM (#6017882)
Huh. How annoying that it doesn't just work everywhere. Annoying in two ways, actually: one, I want it to work; two, it bugs me not to understand what's going on.