git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "R. Diez" <rdiez1999@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How to watch files in a Git repository
Date: Wed, 8 Jun 2022 19:55:25 -0400	[thread overview]
Message-ID: <YqE27RU45kjNRwxf@coredump.intra.peff.net> (raw)
In-Reply-To: <68627d29-8ffd-2e22-46ca-c28c9e980177@gmail.com>

On Mon, Jun 06, 2022 at 06:04:11PM +0200, R. Diez wrote:

> 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

  reply	other threads:[~2022-06-08 23:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 16:04 How to watch files in a Git repository R. Diez
2022-06-08 23:55 ` Jeff King [this message]
2022-06-09  6:16   ` rsbecker
2022-06-09 15:07     ` Jeff King
2022-06-09  8:33 ` Son Luong Ngoc

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YqE27RU45kjNRwxf@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=rdiez1999@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).