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

Re: git rev-list with --name-status?

From
Ddemerphq <demerphq@gmail.com>
Date
Dec 25, 2008, 18:24 UTC
Message-ID
<9b18b3110812251024n1a824eedpa127309d48acf351@mail.gmail.com>
In-Reply-To
<2729632a0812241453x4ae50362g4bcd3317e5be0429@mail.gmail.com>
2008/12/24  <skillzero@gmail.com>:
Show 14 quoted lines
> Is there a way to print the equivalent of --name-status with git
> rev-list? The post-receive script that comes with git for sending
> comment emails does this to generate the commit log:
>
> git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
>        git rev-list --pretty --stdin $oldrev..$newrev
>
> I'd like to also include the output of --name-status so the email
> shows which files were changed by each commit (rather than just a
> summary at the end since our pushes sometimes have a lot of commits in
> them).
>
> git rev-list doesn't seem to support --name-status and git log doesn't
> seem to support --stdin. Is there a better way to do what I want?

I wrote the following shell script function which you can add to your post-receive-mail script. Any git rev-list --pretty statements there can have the --pretty removed and have their output redirected to this, and you get what you want. An existing function changed to use it follows. Theres probably prettier ways to do this, but hope it helps. Id send a diff of the script as a whole except that its full of other likely irrelevent changes.

Yves

# show_log_for_sha1s_on_std() # # take a list of sha1's on STDIN and print out their logs. # # if there are # # 0 commits output a notice saying there no changes in this update # # 1 commits - show the log only # # >1 commits - show log with --name-status output (list of files with M/D/A type tags # next to them for Modified Deleted and Added) # # This partly exists because we can't use --name-status with rev-list, and # because we cant use --stdin with git log (even tho the docs might say # otherwise in older gits). Although since we count SHA1's we can also do some # special stuff like dealing with the 0/1/N commits differently.

show_log_for_sha1s_on_stdin()
{
                perl -e'
                        chomp(my @sha1= <>);
                        if (!@sha1) {
                                print "No new revisions added by this update\n";
                        }
                        else {
                            my $ns= @sha1 > 1 ? " --name-status" : "";
                            for my $idx (0..$#sha1) {
                                print $idx ? "\n" :  "" ,
                                      `git-log --pretty$ns -1 $sha1[$idx]`;
                                }
                        }
                '
}
generate_create_branch_email()
{
        # This is a new branch and so oldrev is not valid
        echo "        at  $newrev ($newrev_type)"
        echo ""
        echo $LOGBEGIN
        # This shows all log entries that are not already covered by
        # another ref - i.e. commits that are now accessible from this
        # ref that were previously not accessible
        # (see generate_update_branch_email for the explanation of this
        # command)
        git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
        git rev-list --stdin $newrev | show_log_for_sha1s_on_stdin
        echo $LOGEND
}
-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “git rev-list with --name-status?”
  1. skillzero@gmail.comDec 24, 2008
  2. Junio C HamanoDec 25, 2008
  3. demerphqDec 25, 2008
  4. Junio C HamanoDec 25, 2008
  5. skillzero@gmail.comDec 25, 2008

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.