unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob b0185a97b281f1086cea9cf699b03d8088a71e7c 2192 bytes (raw)
name: build-aux/git-hooks/pre-push 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
#!/bin/sh
# Check the file list of GNU Emacs change log entries before pushing.

# Copyright 2023 Free Software Foundation, Inc.

# This file is part of GNU Emacs.

# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

# Prefer gawk if available, as it handles NUL bytes properly.
if type gawk >/dev/null 2>&1; then
  awk="gawk"
else
  awk="awk"
fi

# Standard input receives lines of the form:
#   <local ref> SP <local name> SP <remote ref> SP <remote name> LF
$awk -v origin_name="$1" '
  # If the local SHA is all zeroes, ignore it.
  $2 ~ /^0{40}$/ {
    next
  }

  $2 ~ /^[a-z0-9]{40}$/ {
    newref = $2
    # If the remote SHA is all zeroes, this is a new object to be
    # pushed (likely a branch).  Go backwards until we find a SHA on
    # an origin branch.
    if ($4 ~ /^0{40}$/) {
      back = 0
      cmd = ("git branch -r -l '\''" origin_name "/*'\'' --contains " \
             newref "~" back)
      while ((cmd | getline) == 0) {

        # Only look back at most 1000 commits, just in case...
        if (back++ > 1000)
          break;
      }
      close(cmd)

      cmd = ("git rev-parse " newref "~" back)
      cmd | getline oldref
      if (!(oldref ~ /^[a-z0-9]{40}$/)) {
        # The SHA is misformatted!  Skip this line.
        next
      }
      close(cmd)
    } else if ($4 ~ /^[a-z0-9]{40}$/)  {
      oldref = $4
    } else {
      # The SHA is misformatted!  Skip this line.
      next
    }

    # Print every SHA after oldref, up to (and including) newref.
    system("git rev-list --reverse " oldref ".." newref)
  }
' | $awk -v reason=pre-push -f .git/hooks/commit-msg-files.awk

debug log:

solving b0185a97b28 ...
found b0185a97b28 in https://yhetil.org/emacs-devel/9c8826af-a160-d36f-7577-2bc5ec0c2004@gmail.com/ ||
	https://yhetil.org/emacs-devel/b2b335ef-837c-f1e0-8ae2-d433e849c6e7@gmail.com/

applying [1/1] https://yhetil.org/emacs-devel/9c8826af-a160-d36f-7577-2bc5ec0c2004@gmail.com/
diff --git a/build-aux/git-hooks/pre-push b/build-aux/git-hooks/pre-push
new file mode 100755
index 00000000000..b0185a97b28

Checking patch build-aux/git-hooks/pre-push...
Applied patch build-aux/git-hooks/pre-push cleanly.

skipping https://yhetil.org/emacs-devel/b2b335ef-837c-f1e0-8ae2-d433e849c6e7@gmail.com/ for b0185a97b28
index at:
100755 b0185a97b281f1086cea9cf699b03d8088a71e7c	build-aux/git-hooks/pre-push

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).