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

Re: process committed files in post-receive hook

From
HWHao Wang <billhao@gmail.com>
Date
Dec 15, 2011, 08:19 UTC
Message-ID
<4EE9AD7C.5080107@gmail.com>
In-Reply-To
<20111215072301.GC1327@sigill.intra.peff.net>
Show 8 quoted lines
> If you are scripting, we usually encourage the use of "plumbing"
> commands whose output is guaranteed not to change ("show" is a
> "porcelain" command intended to be used by end-users, and it's possible
> that its behavior might change from version to version).
>
> The plumbing command to get a directory listing for a tree is "git
> ls-tree" (try the "--name-only" option for terse output, and use "-z" if
> you want to be robust in the face of filenames with funny characters).
Jeff, thank you for the information. This is really helpful.
Show 17 quoted lines
>> # get a list of rule files using git show
>> def getRuleFileList(rev):
>>      # run git show
>>      p = subprocess.Popen(['git', 'show', rev], stdout=subprocess.PIPE)
>>      p.wait()
>>      if p.returncode != 0: return None # error
>>
>>      # parse output
>>      i = 0
>>      filelist = []
>>      for line in p.stdout.readlines():
>>          filelist.append(line)
>>      p.stdout.close()
>>      return filelist
>
> Doesn't this put "tree HEAD:foo", as printed by "git show", at the top
> of your filelist? Another reason to use ls-tree.

Yes, the first two items ("tree HEAD:foo" and an empty line) are removed later from filelist.

Hao
Previous: Jeff King
Message 8 of 8 in “process committed files in post-receive hook”
  1. HaoDec 10, 2011
  2. Michael SchubertDec 10, 2011
  3. Ivan HeffnerDec 10, 2011
  4. Alexey ShumkinDec 10, 2011
  5. Neal KreitzingerDec 15, 2011
  6. Hao WangDec 15, 2011
  7. Jeff KingDec 15, 2011
  8. Hao WangDec 15, 2011

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.