From: Roel Kluin <roel.kluin@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-cget: prints elements of C code in the git repository
Date: Tue, 24 Mar 2009 14:30:28 +0100 [thread overview]
Message-ID: <49C8E074.4030808@gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0903241257430.7493@intel-tinevez-2-302>
Hi Johannes,
thanks for your pointers.
> - the name is not expressive enough,
How about get-def? If it's too long it will become tiresome to type.
> - the commit message is severely lacking (I had to apply it and run it to
> find out what problem it tries to solve),
This is probably better:
This script shows where elements of C code are defined in the git-repository.
It is still experimental, although it should work in most cases.
As invoking it with -? will tell:
USAGE: git get-def [OPTION]... PATTERN [FILE]...
print elements of C code with name PATTERN in the git repository,
where PATTERN is an extended regular expression
Options to specify which element(s) should be printed:
-f function
-s struct
-d definition
-m macro
-e enum
-u union
Options to alter the output:
-b only print body
-n only print file and lineranges
The pattern is required.
If no files are specified it will search the entire repository for
the specified elements with name PATTERN.
If no element is specified, it will search for any of the above
elements and print these when found.
> - it still uses dashed git commands,
Should be fixed in my next version
> - it might be better to put it into contrib/, otherwise it needs
> documentation with examples, and tests,
Ok.
> - it misdetects functions: trying
>
> $ ./git-cget -f get_sha1.*
>
> shows this, amongst others:
>
> -- snip --
> // vi sha1_name.c +59
> return get_sha1_hex(hex, sha1) == 0;
> return found;
> }
>
> static int match_sha(unsigned len, const unsigned char *a, const unsigned
> char *b)
> {
> do {
> if (*a != *b)
> return 0;
> a++;
> b++;
> len -= 2;
> } while (len > 1);
> if (len)
> if ((*a ^ *b) & 0xf0)
> return 0;
> return 1;
> }
> -- snap --
Yes, it doesn't always work yet, I'll try to fix this in my next version.
> - maybe it would be nicer to integrate this into git grep itself? Maybe
> by allowing multi-line matches and default patterns, or pattern
> templates?
I did attempt to program it in C, but I am more comfortable with bash. Also,
what would be more appropriate for this purpose, I think, is a git sed.
However, allowing multi-line matches may be an option, I'll look into it.
> Ciao,
> Dscho
Thanks,
Roel
next prev parent reply other threads:[~2009-03-24 13:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-24 10:09 [PATCH] git-cget: prints elements of C code in the git repository Roel Kluin
2009-03-24 12:05 ` Johannes Schindelin
2009-03-24 13:30 ` Roel Kluin [this message]
2009-03-24 13:52 ` Johannes Schindelin
2009-03-24 15:08 ` Ping Yin
2009-03-24 13:59 ` Jeff King
2009-03-24 14:04 ` Stefan Karpinski
2009-03-24 14:05 ` Johannes Schindelin
2009-03-24 14:38 ` Mike Ralphson
2009-03-24 14:56 ` Johannes Schindelin
2009-03-24 16:37 ` Mike Ralphson
2009-03-24 16:33 ` Steven Tweed
2009-03-25 4:23 ` Jeff King
2009-03-24 16:17 ` roel kluin
2009-03-27 9:22 ` roel kluin
2009-03-27 11:26 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49C8E074.4030808@gmail.com \
--to=roel.kluin@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).