Re: [BUG] git rev-parse :/ "regex" syntax not really regex?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 17, 2016 at 04:10:28PM +0200, Andreas Schwab wrote:
> Andreas Mohr <andi@xxxxxxxx> writes:
> 
> > Unless I happened to misunderstand git's regex flavour, or something else...
> > (hmm, perhaps it's a try-match-single-line vs. multi-line content issue,
> > which perhaps does not work by specifying the trailing $)
> 
> This is exactly the difference.  git log --grep matches individual lines
> (like grep), whereas :/<regexp> matches against the whole commit message
> including embedded (and trailing) newlines, and $ doesn't match an
> embedded newline.  Thus to address the second commit in your example you
> have to use $':/^My commit\n' (using bash's ANSI-C quoting feature).

At first I thought "no way, I already did try trailing \n",
but then I realized that
it's exactly use of that ANSI-C quoting feature
which makes that \n newline be (non-)interpreted correctly here,
and it truly works.

Thank you for a fast and well-inform{ed|ing} response!

Now there's only one question remaining:
do we simply take this as a documentation-supplied-by-mailing-list item ;-),
or should certain parts of the parse-rev :/ documentation
be improved in a certain manner?


No, there's another one:
this syntax seems to be (as indicated) indeed bash-specific,
since a short dash test script (POSIX):
#!/usr/bin/dash

git rev-parse $':/^My commit\n'

simply prints a
$:/^My commit\n
result,
and no amount of syntax fiddling
succeeded in getting the correct commit result on dash.

Well, since that \n simply *is* a newline
(see also
http://unix.stackexchange.com/questions/155367/when-to-use-bash-ansi-c-style-escape-e-g-n ),
a successful way to encode it in dash (all non-bash shells?) is:

git rev-parse :/'^My commit
'

i.e. with an *actual* newline.


BTW, as a (albeit weak) former m68k architecture user,
thank you for your efforts!

Andreas Mohr
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]