Skip to content

Commit c5fabfb

Browse files
author
Wayne Davison
committed
Set Copyright years and make them easier to update
I replaced git-set-file-times with an improved version that I wrote recently (in python3). A new script uses it to figure out the last-modified year for each *.[ch] file and updates its copyright. It also puts the latest year into the latest-year.h file for the output of --version.
1 parent e2aee6c commit c5fabfb

25 files changed

+196
-66
lines changed

Makefile.in

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ rsync$(EXEEXT): $(OBJS)
9595

9696
$(OBJS): $(HEADERS)
9797
$(CHECK_OBJS): $(HEADERS)
98+
options.o: latest-year.h
9899

99100
flist.o: rounding.h
100101

authenticate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Support rsync daemon authentication.
33
*
44
* Copyright (C) 1998-2000 Andrew Tridgell
5-
* Copyright (C) 2002-2019 Wayne Davison
5+
* Copyright (C) 2002-2020 Wayne Davison
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by

checksum.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1996 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
6-
* Copyright (C) 2004-2019 Wayne Davison
6+
* Copyright (C) 2004-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

cleanup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 1996-2000 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
66
* Copyright (C) 2002 Martin Pool
7-
* Copyright (C) 2003-2019 Wayne Davison
7+
* Copyright (C) 2003-2020 Wayne Davison
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by

clientserver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
55
* Copyright (C) 2001-2002 Martin Pool <mbp@samba.org>
6-
* Copyright (C) 2002-2019 Wayne Davison
6+
* Copyright (C) 2002-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

connection.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Support the max connections option.
33
*
44
* Copyright (C) 1998 Andrew Tridgell
5+
* Copyright (C) 2006-2020 Wayne Davison
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by

flist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 1996 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
66
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
7-
* Copyright (C) 2002-2019 Wayne Davison
7+
* Copyright (C) 2002-2020 Wayne Davison
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by

generator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 1996-2000 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
66
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
7-
* Copyright (C) 2003-2019 Wayne Davison
7+
* Copyright (C) 2003-2020 Wayne Davison
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by

latest-year.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define LATEST_YEAR "2020"

lib/md5.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* RFC 1321 compliant MD5 implementation
33
*
44
* Copyright (C) 2001-2003 Christophe Devine
5+
* Copyright (C) 2007-2020 Wayne Davison
56
*
67
* This program is free software; you can redistribute it and/or modify
78
* it under the terms of the GNU General Public License as published by

loadparm.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
*
1212
* You should have received a copy of the GNU General Public License along
1313
* with this program; if not, visit the http://fsf.org website.
14-
*/
15-
16-
/* This is based on loadparm.c from Samba, written by Andrew Tridgell
14+
*
15+
* This is based on loadparm.c from Samba, written by Andrew Tridgell
1716
* and Karl Auer. Some of the changes are:
1817
*
1918
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
20-
* Copyright (C) 2003-2019 Wayne Davison <wayned@samba.org>
19+
* Copyright (C) 2003-2020 Wayne Davison
2120
*/
2221

2322
/* Load parameters.

log.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
55
* Copyright (C) 2000-2001 Martin Pool <mbp@samba.org>
6-
* Copyright (C) 2003-2019 Wayne Davison
6+
* Copyright (C) 2003-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
55
* Copyright (C) 1996 Paul Mackerras
66
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
7-
* Copyright (C) 2003-2019 Wayne Davison
7+
* Copyright (C) 2003-2020 Wayne Davison
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by

options.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
55
* Copyright (C) 2000, 2001, 2002 Martin Pool <mbp@samba.org>
6-
* Copyright (C) 2002-2019 Wayne Davison
6+
* Copyright (C) 2002-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
2121

2222
#include "rsync.h"
2323
#include "itypes.h"
24+
#include "latest-year.h"
2425
#include <popt.h>
2526
#include <zlib.h>
2627

@@ -614,7 +615,7 @@ static void print_rsync_version(enum logcode f)
614615

615616
rprintf(f, "%s version %s protocol version %d%s\n",
616617
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
617-
rprintf(f, "Copyright (C) 1996-2019 by Andrew Tridgell, Wayne Davison, and others.\n");
618+
rprintf(f, "Copyright (C) 1996-" LATEST_YEAR " by Andrew Tridgell, Wayne Davison, and others.\n");
618619
rprintf(f, "Web site: http://rsync.samba.org/\n");
619620
rprintf(f, "Capabilities:\n");
620621
rprintf(f, " %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n",

progress.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 1996-2000 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
66
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
7-
* Copyright (C) 2003-2019 Wayne Davison
7+
* Copyright (C) 2003-2020 Wayne Davison
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU General Public License as published by

receiver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1996-2000 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
6-
* Copyright (C) 2003-2019 Wayne Davison
6+
* Copyright (C) 2003-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

rounding.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* A pre-compilation helper program to aid in the creation of rounding.h.
33
*
4-
* Copyright (C) 2007-2019 Wayne Davison
4+
* Copyright (C) 2007-2020 Wayne Davison
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by

rsync.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1996 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
6-
* Copyright (C) 2003-2019 Wayne Davison
6+
* Copyright (C) 2003-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

rsync.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (C) 1996, 2000 Andrew Tridgell
33
* Copyright (C) 1996 Paul Mackerras
44
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
5-
* Copyright (C) 2003-2019 Wayne Davison
5+
* Copyright (C) 2003-2020 Wayne Davison
66
*
77
* This program is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by

sender.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (C) 1996 Andrew Tridgell
55
* Copyright (C) 1996 Paul Mackerras
6-
* Copyright (C) 2003-2019 Wayne Davison
6+
* Copyright (C) 2003-2020 Wayne Davison
77
*
88
* This program is free software; you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

support/git-set-file-times

+76-43
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,76 @@
1-
#!/usr/bin/perl
2-
use strict;
3-
use warnings;
4-
5-
# Sets mtime and atime of files to the latest commit time in git.
6-
#
7-
# This is useful after the first clone of the rsync repository BEFORE you
8-
# do any building. It is also safe if you have done a "make distclean".
9-
10-
my %ls;
11-
my $commit_time;
12-
my $prefix = @ARGV && $ARGV[0] =~ s/^--prefix=// ? shift : '';
13-
14-
my $top_dir = `git rev-parse --show-toplevel`;
15-
exit 1 unless $top_dir;
16-
chomp($top_dir);
17-
18-
chdir $top_dir or die "Failed to chdir to $top_dir\: $!\n";
19-
20-
$/ = "\0";
21-
open FH, '-|', qw( git ls-files -z ) or die "Failed to fork: $!";
22-
while (<FH>) {
23-
chomp;
24-
$ls{$_} = $_;
25-
}
26-
close FH;
27-
28-
$/ = "\n";
29-
open FH, '-|', qw( git log -r --name-only --no-color --pretty=raw -z ), @ARGV or die "Failed to fork: $!";
30-
while (<FH>) {
31-
chomp;
32-
if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
33-
$commit_time = $1;
34-
} elsif (s/\0\0commit [a-f0-9]{40}$// || s/\0$//) {
35-
my @files = delete @ls{split(/\0/, $_)};
36-
@files = grep { defined $_ } @files;
37-
next unless @files;
38-
map { s/^/$prefix/ } @files;
39-
utime $commit_time, $commit_time, @files;
40-
}
41-
last unless %ls;
42-
}
43-
close FH;
1+
#!/usr/bin/python3
2+
3+
import os, re, argparse, subprocess
4+
from datetime import datetime
5+
6+
NULL_COMMIT_RE = re.compile(r'\0\0commit [a-f0-9]{40}$|\0$')
7+
8+
def main():
9+
if not args.git_dir:
10+
cmd = 'git rev-parse --show-toplevel 2>/dev/null || echo .'
11+
top_dir = subprocess.check_output(cmd, shell=True).decode('utf-8').strip()
12+
args.git_dir = os.path.join(top_dir, '.git')
13+
if not args.prefix:
14+
os.chdir(top_dir)
15+
16+
git = [ 'git', '--git-dir=' + args.git_dir ]
17+
18+
if args.tree:
19+
cmd = git + 'ls-tree -z -r --name-only'.split() + [ args.tree ]
20+
else:
21+
cmd = git + 'ls-files -z'.split()
22+
23+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
24+
out = proc.communicate()[0].decode('utf-8')
25+
ls = set(out.split('\0'))
26+
ls.discard('')
27+
28+
cmd = git + 'log -r --name-only --no-color --pretty=raw --no-renames -z'.split()
29+
if args.tree:
30+
cmd.append(args.tree)
31+
cmd += ['--'] + args.files
32+
33+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
34+
for line in proc.stdout:
35+
line = line.decode('utf-8').strip()
36+
m = re.match(r'^committer .*? (\d+) [-+]\d+$', line)
37+
if m:
38+
commit_time = int(m[1])
39+
elif NULL_COMMIT_RE.search(line):
40+
line = NULL_COMMIT_RE.sub('', line)
41+
files = set(fn for fn in line.split('\0') if fn in ls)
42+
if not files:
43+
continue
44+
for fn in files:
45+
if args.prefix:
46+
fn = args.prefix + fn
47+
mtime = os.lstat(fn).st_mtime
48+
if args.list:
49+
if args.list > 1:
50+
ts = str(commit_time).rjust(10)
51+
else:
52+
ts = datetime.utcfromtimestamp(commit_time).strftime("%Y-%m-%d %H:%M:%S")
53+
chg = '.' if mtime == commit_time else '*'
54+
print(chg, ts, fn)
55+
elif mtime != commit_time:
56+
if not args.quiet:
57+
print(f"Setting {fn}")
58+
os.utime(fn, (commit_time, commit_time), follow_symlinks = False)
59+
ls -= files
60+
if not ls:
61+
break
62+
proc.communicate()
63+
64+
65+
if __name__ == '__main__':
66+
parser = argparse.ArgumentParser(description="Set the times of the current git checkout to their last-changed time.")
67+
parser.add_argument('--git-dir', metavar='GIT_DIR', help="The git dir to query (defaults to affecting the current git checkout).")
68+
parser.add_argument('--tree', metavar='TREE-ISH', help="The tree-ish to query (defaults to the current branch).")
69+
parser.add_argument('--prefix', metavar='PREFIX_STR', help="Prepend the PREFIX_STR to each filename we tweak.")
70+
parser.add_argument('--quiet', '-q', action='store_true', help="Don't output the changed-file information.")
71+
parser.add_argument('--list', '-l', action='count', help="List the files and their dates instead of changing them. Repeat for Unix Time instead of human reable.")
72+
parser.add_argument('files', metavar='FILE', nargs='*', help="Specify a subset of checked-out files to tweak.")
73+
args = parser.parse_args()
74+
main()
75+
76+
# vim: sw=4 et

0 commit comments

Comments
 (0)