summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-11-13 23:05:31 +0100
committerErich Eckner <git@eckner.net>2021-11-13 23:05:31 +0100
commit9ac05a65b68cf60a3ccd15b4e869ae440ce66010 (patch)
treea2b0842813ca1931002a942efd5c371e76b4482b
parent752fb28b19c4c54d3f2bffd415b197a1fc087672 (diff)
downloadcarddav-alpine-converter-9ac05a65b68cf60a3ccd15b4e869ae440ce66010.tar.xz
do not reorder addressbook and uidsHEADmaster
-rwxr-xr-xcarddav-to-alpine5
-rw-r--r--common14
2 files changed, 18 insertions, 1 deletions
diff --git a/carddav-to-alpine b/carddav-to-alpine
index 66d885f..5b4c99e 100755
--- a/carddav-to-alpine
+++ b/carddav-to-alpine
@@ -4,6 +4,11 @@
error=0
+old_uids=$(
+ [ -f "${git_dir}/uids" ] \
+ && awk '{print $1}' "${git_dir}/uids"
+)
+
for file in 'addressbook' 'uids'; do
if [ -n "$(git -C "${git_dir}" diff -- "${file}")" ]; then
>&2 printf 'File "%s" was changed relative to git.\n' "${file##*/}"
diff --git a/common b/common
index 7dfc7dc..ffc74be 100644
--- a/common
+++ b/common
@@ -30,7 +30,19 @@ find_vcfs() {
s@^@'"${git_dir%/}"'/@
'
} \
- | sort -u
+ | sort -u \
+ | if [ -n "${old_uids}" ]; then
+ join -1 1 -2 3 -o 2.1,2.2,2.3 -a 1 -e 1 -t ' ' - <(
+ printf "${git_dir}"'/%s.vcf\n' ${old_uids} \
+ | cat -n \
+ | awk '{print "0 " $1 " " $2}' \
+ | sort -k3,3
+ ) \
+ | sort -k1n,1 -k2n,2 \
+ | awk '{print $3}'
+ else
+ cat
+ fi
}
git_dir="$1"