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

grep open pull requests

From
JBJack Bates <bk874k@nottheoilrig.com>
Date
Jan 19, 2017, 18:12 UTC
Message-ID
<276f6ed9-ff06-a00f-b88a-4d40d55c6d40@nottheoilrig.com>
I have a couple questions around grepping among open pull requests.

First, "git for-each-ref --no-merged": When I run the following, it lists refs/pull/1112/head, even though #1112 was merged in commit ced4da1. I guess this is because the tip of refs/pull/1112/head is 107fc59, not ced4da1?

This maybe shows my lack of familiarity with Git details, but superficially the two commits appear identical -- [1] and [2] -- same parent, etc. Nonetheless they have different SHA-1s. I'm not sure why that is -- I didn't merge the commit -- but regardless, GitHub somehow still connects ced4da1 with #1112.

So my question is, how are they doing that, and why can't "git for-each-ref --no-merged" likewise connect ced4da1 with refs/pull/1112/head?

   $ git clone \
   >   --bare \
   >   --config remote.origin.fetch=+refs/pull/*/head:refs/pull/*/head \
   >   https://github.com/apache/trafficserver.git
   $ cd trafficserver.git
   $ git for-each-ref --no-merged

More generally, what I want is to periodically list open pull requests that add or modify lines containing the string "memset". So far I have the following in a Makefile. Can you recommend any improvements?

.PHONY: all
all: trafficserver.git
	cd trafficserver.git && git fetch
	cd trafficserver.git && git for-each-ref --format '%(refname)' 
refs/pull --no-merged | \
	  while read refname; do \
	    git log -p "master..$$refname" | grep -q '^+.*memset' && echo 
"$$refname"; \
	  done
trafficserver.git:
	git clone \
	  --bare \
	  --config remote.origin.fetch=+refs/pull/*/head:refs/pull/*/head \
	  https://github.com/apache/trafficserver.git

Lastly, a question more about GitHub than Git, but: Given the way GitHub is setup, I hope I can get a list of unmerged pull requests from Git alone. Can you think of a way to list *open* pull requests, or is that status only available out of band?

Thanks!

[1] https://github.com/apache/trafficserver/commit/107fc59104cce2a4b527f04e7ac86695c98b568c [2] https://github.com/apache/trafficserver/commit/ced4da13279f834c381925f2ecd1649bfb459e8b

Next: Jeff King
Message 1 of 4 in “grep open pull requests”
  1. Jack BatesJan 19, 2017
  2. Jeff KingJan 19, 2017
  3. Jack BatesJan 19, 2017
  4. Jeff KingJan 19, 2017

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.