Skip to contentSkip to conversation

gitweb filter for patches by a specific person in a specific timeframe

PATCH In review Kai Blin 6 participants 7 messages Jun 15, 2016 Documentation

lore
Share & tools
lore

Kai Blin

author
#0 lore raw

Hi folks,

I have just completed my Google Summer of Code[1] project[2] working for the Wine project. Now, as I was submitting patches to a git repository, I don't have a branch solely containing my patches or something like that. Google seems to want something like this, so I figured maybe I could get gitweb to filter for my patches during the SoC period. Is that possible? If not, does it sound like something feasible to add?

Cheers,
Kai

PS: Please CC me, as I'm not on the list.

[1] http://code.google.com/soc/
[2] http://wiki.winehq.org/NtlmSigningAndSealing

Signature · 5 lines
Kai Blin, <kai Dot blin At gmail Dot com>
WorldForge developer    http://www.worldforge.org/
Wine developer          http://wiki.winehq.org/KaiBlin/
--
Will code for cotton.
#1 lore raw
Quoted 6 lines · Kai Blin

I have just completed my Google Summer of Code[1] project[2] working for the Wine project. Now, as I was submitting patches to a git repository, I don't have a branch solely containing my patches or something like that. Google seems to want something like this, so I figured maybe I could get gitweb to filter for my patches during the SoC period. Is that possible? If not, does it sound like something feasible to add?

You can create an mbox of all of the changes you made. Unfortunately git-rev-list doesn't do author/committer matching, so you'll need a short perl script:

-- >8 --

$ cat >match-who.pl <<'EOF'
#!/usr/bin/perl

my $name = shift;
my $match = qr/$name/i;

my $commit;
while(<>) {
chomp;
next unless $_;
next if /^\s/;
my ($k, $v) = split / /, $_, 2;

  if($k eq 'commit') {
    $commit = $v;
  }
  if($commit && ($k eq 'author' || $k eq 'committer') && $v =~ $match) {
    print "$commit\n";
    $commit = undef;

}
}
-- >8 --

Then you should be able to do:

$ git-rev-list --pretty=raw master |
  perl match-who.pl [email protected] |
  git-diff-tree -p --stdin --pretty=email \
Quoted 1 line

my-patches

You can either look through that, or you can try applying the patches with git-am (though if your patches depend on changes not by you that happened in the intervening time, you'll probably have some rejects).

-Peff

#2 lore raw
Quoted 4 lines · Jeff King

You can create an mbox of all of the changes you made. Unfortunately git-rev-list doesn't do author/committer matching, so you'll need a short perl script:

The author/committer matching is something that people have talked about for a long time, so maybe we should just add it?

It shouldn't be that hard at all. Just add logic to revision.c:
get_revision(), something like the appended (fleshed out and fixed, of course, with all the command line flags added to actually allow setting of "revs->author_pattern" etc..)

A good thing for some beginning git hacker to try doing. Hint, hint.

(The only subtle thing might be to make sure that "save_commit_buffer" is set if author/committer matching is on, so that the "commit->buffer" thing is actually saved after parsing, so that you can match it)

This trivial approach doesn't allow "gitk" to show the results sanely, though (to do that, you'd need to make the commit matching be part of the parent simplification instead - that would be extra bonus points for the intrpid git hacker-wannabe)

Linus
---

revision.c +11 -0
index 1d89d72..88cc1e3 100644
@@ -1011,6 +1011,13 @@ static void mark_boundary_to_show(struct
 	}
 }
 
+static int commit_match(struct commit *commit, const char *field, const char *pattern)
+{
+	if (!pattern)
+		return 1;
+	.. match it here ..
+}
+
 struct commit *get_revision(struct rev_info *revs)
 {
 	struct commit_list *list = revs->commits;
@@ -1070,6 +1077,10 @@ struct commit *get_revision(struct rev_i
 		if (revs->no_merges &&
 		    commit->parents && commit->parents->next)
 			continue;
+		if (!commit_match(commit, "author", revs->author_pattern))
+			continue;
+		if (!commit_match(commit, "committer", revs->committer_pattern))
+			continue;
 		if (revs->prune_fn && revs->dense) {
 			/* Commit without changes? */
 			if (!(commit->object.flags & TREECHANGE)) {
#3 lore raw

PATCH 1/1 Support author and commiter based revision list limiting

Adds the two options: --author=string and --committer=string, which can be used to limit the set of interesting commits to the ones matching the given idents.

---

[ On top of the git-rev-list(1) update posted earlier ... ]

Linus Torvalds <[email protected]> wrote Mon, Aug 28, 2006:

Quoted 4 lines

Th[e] trivial approach doesn't allow "gitk" to show the results sanely, though (to do that, you'd need to make the commit matching be part of the parent simplification instead - that would be extra bonus points for the intrpid git hacker-wannabe)

Hereby serving one patch doing the trivial thing very stupid, since I didn't have the imagination to go and hunt for the bonus points just yet.

 Documentation/git-rev-list.txt |    6 +++++
 builtin-rev-list.c             |    3 ++
 revision.c                     |   53 ++++++++++++++++++++++++++++++++++++++++
 revision.h                     |    2 ++
 4 files changed, 63 insertions(+), 1 deletions(-)
Documentation/git-rev-list.txt +6 -0
index d6c86db..4d5f5ab 100644
@@ -12,6 +12,8 @@ SYNOPSIS
 'git-rev-list' [ \--max-count=number ]
 	     [ \--max-age=timestamp ]
 	     [ \--min-age=timestamp ]
+	     [ \--author=string ]
+	     [ \--committer=string ]
 	     [ \--sparse ]
 	     [ \--no-merges ]
 	     [ \--remove-empty ]
@@ -153,6 +155,10 @@ limiting may be applied.
 
 	Limit the commits output to specified time range.
 
+--author='string', --committer='string'::
+
+	Limit the commits output to specified author and/or committer.
+
 --remove-empty::
 
 	Stop when a given path disappears from the tree.
builtin-rev-list.c +2 -1
index 402af8e..09e3d37 100644
@@ -352,7 +352,8 @@ int cmd_rev_list(int argc, const char **
 	    revs.diff)
 		usage(rev_list_usage);
 
-	save_commit_buffer = revs.verbose_header;
+	if (!revs.author_pattern && !revs.committer_pattern)
+		save_commit_buffer = revs.verbose_header;
 	track_object_refs = 0;
 	if (bisect_list)
 		revs.limited = 1;
revision.c +53 -0

71 lines not on this page · raw message

revision.h +2 -0
index d289781..7688e3a 100644
@@ -71,6 +71,8 @@ struct rev_info {
 	int max_count;
 	unsigned long max_age;
 	unsigned long min_age;
+	const char *author_pattern;
+	const char *committer_pattern;
 
 	/* diff info for patches and for paths limiting */
 	struct diff_options diffopt;
Signature · 4 lines
1.4.2.g2ba6b-dirty

-- 
Jonas Fonseca
#4 lore raw

Re: [PATCH] Support author and commiter based revision list limiting

Quoted 9 lines · Jonas Fonseca

Adds the two options: --author=string and --committer=string, which can be used to limit the set of interesting commits to the ones matching the given idents.

Documentation/git-rev-list.txt +0 -0
index d6c86db..4d5f5ab 100644

Documentation/git-rev-list.txt SYNOPSIS · line 19

Quoted 8 lines
Documentation/git-rev-list.txt +2 -0
@@ -12,6 +12,8 @@ SYNOPSIS
 'git-rev-list' [ \--max-count=number ]
 	     [ \--max-age=timestamp ]
 	     [ \--min-age=timestamp ]
+	     [ \--author=string ]
+	     [ \--committer=string ]
 	     [ \--sparse ]
 	     [ \--no-merges ]
 	     [ \--remove-empty ]

These two separate options are Ok at the level of front-end, but...

Quoted 5 lines
builtin-rev-list.c +0 -0
index 402af8e..09e3d37 100644

builtin-rev-list.c int cmd_rev_list(int argc, const char ** · line 359

Quoted 9 lines
builtin-rev-list.c +2 -1
@@ -352,7 +352,8 @@ int cmd_rev_list(int argc, const char **
 	    revs.diff)
 		usage(rev_list_usage);
 
-	save_commit_buffer = revs.verbose_header;
+	if (!revs.author_pattern && !revs.committer_pattern)
+		save_commit_buffer = revs.verbose_header;
 	track_object_refs = 0;
 	if (bisect_list)
 		revs.limited = 1;

I wonder if it is simpler and yet more powerful to internally use a regex to match the contents of commit buffer, not just specific its header fields.

When --author or --committer is given, you internally synthesize a regex "^author Jonas Fonseca <fonseca@" from the string.

And then, instead of doing commit_match_ident() twice like this:

builtin-rev-list.c struct commit *get_revision(struct rev_i · line 1129

Quoted 8 lines
builtin-rev-list.c +4 -0
@@ -1074,6 +1123,10 @@ struct commit *get_revision(struct rev_i
 		if (revs->no_merges &&
 		    commit->parents && commit->parents->next)
 			continue;
+		if (!commit_match_ident(commit, "author", revs->author_pattern))
+			continue;
+		if (!commit_match_ident(commit, "committer", revs->committer_pattern))
+			continue;

you would just do:

	if (revs->commit_filter_pattern &&
            commit_search_message(commit, revs->commit_filter_pattern))
		continue;

instead.

For an extra bonus point, the matching logic might want to steal from builtin-grep to allow multiple regular expressions, case insensitive match and other bells and whistles. You probably could lift the whole grep_buffer() -- add another option that behaves similarly to opt->name_only (name it opt->status_only) but make it not even print anything upon hit, so that you can tell from the return value if it found the pattern in the buffer, like this:

builtin-grep.c +3 -0
index 8213ce2..714ad50 100644
@@ -128,6 +128,7 @@ struct grep_opt {
 	unsigned linenum:1;
 	unsigned invert:1;
 	unsigned name_only:1;
+	unsigned status_only:1;
 	unsigned unmatch_name_only:1;
 	unsigned count:1;
 	unsigned word_regexp:1;
@@ -492,6 +493,8 @@ static int grep_buffer(struct grep_opt *
 		}
 		if (hit) {
 			count++;
+			if (opt->status_only)
+				return 1;
 			if (binary_match_only) {
 				printf("Binary file %s matches\n", name);
 				return 1;

Hmm?

#5 lore raw

git log --author='Jeff King'

In reply to Linus Torvalds

I have three patch series that makes a part of git-grep available and use it for log filtering:

[PATCH] builtin-grep: make pieces of it available as library. [PATCH] revision traversal: prepare for commit log match. [PATCH] revision traversal: --author, --committer, and --grep.

I didn't implement the boolean combination of patterns like git-grep does, but it should be pretty straightforward to do so in setup_revisions(). The syntax probably would be something like:

    git log --grep-( rev-list gitweb --and --not --author=Jakub --grep-)

to find logs that:

* talk about rev-list, or
* talk about gitweb but not by Jakub

#6 lore raw
In reply to Kai Blin
Quoted 6 lines · Kai Blin

I have just completed my Google Summer of Code[1] project[2] working for the Wine project. Now, as I was submitting patches to a git repository, I don't have a branch solely containing my patches or something like that. Google seems to want something like this, so I figured maybe I could get gitweb to filter for my patches during the SoC period. Is that possible? If not, does it sound like something feasible to add?

It is possible. Simply enter "author:Kai Blin" (without space between ':' and your name as it appears in author field) in the searchbox, and you would get an URL similar to the URL below:

http://www.kernel.org/git/?p=git%2Fgit.git&a=search&h=HEAD&s=author%3AJonas+Fonseca

Of course you should first go to proper branch. If you are giving the link, you can write it in more human-friendly form, e.g.

http://www.kernel.org/git/?p=git/git.git;a=search;h=HEAD;s=author:Jonas+Fonseca

Or you can just search for your name, which gives URL like this one

http://www.kernel.org/git/?p=git/git.git;a=search;h=HEAD;s=Jonas+Fonseca

which will find all commits in the lineage of given branch (HEAD is the current branch) which have specified phrase in commit log (which includes signoff lines)

Quoted 1 line

PS: Please CC me, as I'm not on the list.

You can always read the list using one of the many archives of [email protected] list, or using Usenet (news) client via NNTP gateway at GMane (nntp://news.gmane.org/gmane.comp.version-control.git).

See http://git.or.cz/gitwiki/GitCommunity

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git