#!/bin/bash ################################################################################ # # Update the id lines of the files git is currently tracking in the index and # which are new, modified, renamed, or copied. # # See set-id.pl for the format of the substitution. # # Uaage: cd git-repo; bin_path/update-id.sh # ################################################################################ bin_dir=$(dirname "$0") set -e for path in $(git status --porcelain -z | $bin_dir/changed-wt-files.pl); do echo 'updating $Id:$ in '$path new_name="$path-new" old_name="$path-old" # make sure the temporary names we are going to use don't already exist if [ -e "$new_name" ]; then echo "$0: $new_name exists -- did a previous update run fail?" exit 1 fi if [ -e "$new_name" ]; then echo "$0: $new_name exists -- did a previous update run fail?" exit 1 fi # update the id "$bin_dir/set-id.pl" "$path" < "$path" > "$new_name" if diff -q "$path" "$new_name" >/dev/null; then rm "$new_name" else cp -p "$path" "$old_name" mv "$new_name" "$path" rm "$old_name" fi done