Skip to content

Commit dfda002

Browse files
committed
Use AWK to process file renames
1 parent 6a81b02 commit dfda002

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

tools/git/scripts/filename_changes

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#
33
# Prints filename changes.
44
#
5-
# <weekday> <month> <day> <time> <year> <first_name> <last_name>
6-
# R<%> <original_filename> <new_filename>
5+
# <weekday> <month> <day> <time> <year> <first_name> <last_name> <original_filename> <new_filename> <%>
76

87
# * `git log --reverse`
98
# - Show commit logs in reverse order.
@@ -17,10 +16,29 @@
1716
# - Format the log.
1817
# * `--date=format:""`
1918
# - Format the date.
19+
# * `awk '{}'
20+
# - Process each commit.
2021
git log \
2122
--reverse \
2223
--find-renames \
2324
--name-status \
2425
--diff-filter R \
2526
--format=format:"%ad %aN" \
26-
--date=format:"%a %b %d %T %Y"
27+
--date=format:"%a %b %d %T %Y" \
28+
| awk '
29+
# Skip empty lines:
30+
NF == 0 {
31+
next
32+
}
33+
34+
# Date lines:
35+
! /^R/ {
36+
date = $0
37+
next
38+
}
39+
40+
# Filename changes:
41+
{
42+
print date OFS $2 OFS $3 OFS substr($1, 2)
43+
}
44+
'

0 commit comments

Comments
 (0)