--- /dev/null
+#
+# shared check_dups funciont
+#
+
+check_dups()
+{
+ # "In POSIX sh, 'local' is undefined."
+ # shellcheck disable=SC3043
+ local name base sha dfile
+
+ name="$1"
+ base="$2"
+ sha="$3"
+ dlfile="$top_dir/duplicates/linus/$name"
+ if [ "$base" = "HEAD" ]; then
+ dfile="$top_dir/duplicates/next/$name"
+ else
+ dfile="$dlfile"
+ fi
+
+ # if there is anything in this tree, then check for duplicates
+ if [ "$(git rev-list --count --no-merges "$base".."$sha")" -eq 0 ]; then
+ rm -f "$dfile"
+ return;
+ fi
+
+ dups=$(git cherry "$base" "$sha" | sed -n 's/^- //p' |
+ xargs -r -n 1 "$tools_dir"/clog | sort)
+ if [ "$base" = "HEAD" ] && [ -f "$dlfile" ]; then
+ dups=$(printf '%s\n' "$dups" | comm -23 - "$dlfile")
+ fi
+ if [ -z "$dups" ]; then
+ rm -f "$dfile"
+ elif ! [ -f "$dfile" ]; then
+ printf '%s\n' "$dups" | tee "$dfile"
+ elif ! printf '%s\n' "$dups" | cmp -s - "$dfile"; then
+ printf '%s\n' "$dups" | comm -23 - "$dfile"
+ printf '%s\n' "$dups" >"$dfile"
+ fi
+}
+
+true
fi
}
-check_dups()
-{
- # "In POSIX sh, 'local' is undefined."
- # shellcheck disable=SC3043
- local name base sha dfile
-
- name="$1"
- base="$2"
- sha="$3"
- dlfile="$top_dir/duplicates/linus/$name"
- if [ "$base" = "HEAD" ]; then
- dfile="$top_dir/duplicates/next/$name"
- else
- dfile="$dlfile"
- fi
-
- # if there is anything in this tree, then check for duplicates
- if [ "$(git rev-list --count --no-merges "$base".."$sha")" -eq 0 ]; then
- rm -f "$dfile"
- return;
- fi
-
- dups=$(git cherry "$base" "$sha" | sed -n 's/^- //p' |
- xargs -r -n 1 "$tools_dir"/clog | sort)
- if [ "$base" = "HEAD" ] && [ -f "$dlfile" ]; then
- dups=$(printf '%s\n' "$dups" | comm -23 - "$dlfile")
- fi
- if [ -z "$dups" ]; then
- rm -f "$dfile"
- elif ! [ -f "$dfile" ]; then
- printf '%s\n' "$dups" | tee "$dfile"
- elif ! printf '%s\n' "$dups" | cmp -s - "$dfile"; then
- printf '%s\n' "$dups" | comm -23 - "$dfile"
- printf '%s\n' "$dups" >"$dfile"
- fi
-}
-
true
tools_dir=$(dirname "$0")
. "$tools_dir/common.sh"
+. "$tools_dir/check_dups.sh"
log()
{
tools_dir=$(dirname "$0")
. "$tools_dir/common.sh" ''
+. "$tools_dir/check_dups.sh"
if [ "$1" = '-n' ]; then
shift