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

Re: How to watch files in a Git repository

From
Jeff King <peff@peff.net>
Date
Jun 8, 2022, 23:55 UTC
Message-ID
<YqE27RU45kjNRwxf@coredump.intra.peff.net>
In-Reply-To
<68627d29-8ffd-2e22-46ca-c28c9e980177@gmail.com>
On Mon, Jun 06, 2022 at 06:04:11PM +0200, R. Diez wrote:
Show 7 quoted lines
> If there is nothing of the sort, I could write my own script in Bash
> or Perl. I can handle cron and sending e-mails, but I do not know much
> about Git's internals. Could someone provide a few pointers about how
> to code this? I would expect there is some command to list commits,
> and all files touched by a particular commit. And there would be some
> way to interface with Bash or Perl, which does not need parsing
> complicated text output from Git.
This sounds kind of like git-multimail:
  https://github.com/git-multimail/git-multimail

That's usually triggered from a hook, I think, but it would not be hard to trigger it with arbitrary segments of history.

You'd probably want to keep a "seen" ref of processed commits, and move from that, like:

  # assuming you just care about one branch on the remote, but this
  # concept can be extended to several
  branch=refs/remotes/origin/main
  seen=refs/heads/seen
  git fetch
  # I don't know what git-multimail expects, but this is similar to what
  # a server-side receive hook would show
  echo "$(git rev-parse $seen) $(git rev-parse $branch) $branch" |
  some-git-multimail-command
  # now move your pointer forward for next time
  git update-ref $seen $branch

If multimail doesn't do what you want, then you can probably just script around:

  git rev-list $seen..$branch -- $paths_you_care_about |
  git diff-tree --stdin -r --name-only --format="Commit %h touched: " -- $paths_you_care_about
depending how you want to format things.
-Peff
Previous: R. DiezNext: rsbecker@nexbridge.com
Message 2 of 5 in “How to watch files in a Git repository”
  1. R. DiezJun 6, 2022
  2. Jeff KingJun 8, 2022
  3. rsbecker@nexbridge.comJun 9, 2022
  4. Jeff KingJun 9, 2022
  5. Son Luong NgocJun 9, 2022

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.