diff --git a/quilt/add.in b/quilt/add.in index dfd48f8..76d0254 100644 --- a/quilt/add.in +++ b/quilt/add.in @@ -128,6 +128,15 @@ do continue fi + # Add sha checksum of added file to checksum db + if [ -n "$QUILT_USE_SHA1" ]; then + if [ -r $QUILT_PC/$patch/$SUBDIR$file ]; then + shasum $QUILT_PC/$patch/$SUBDIR$file 2>/dev/null | sed -e "s/$QUILT_PC\/$patch\///g">> $QUILT_PC/$patch/.cksum + else + echo "0000000000000000000000000000000000000000 $SUBDIR$file" >>$QUILT_PC/$patch/.cksum + fi + fi + if [ -e "$SUBDIR$file" ] then # The original tree may be read-only. diff --git a/quilt/pop.in b/quilt/pop.in index cd01e56..72366a4 100644 --- a/quilt/pop.in +++ b/quilt/pop.in @@ -154,6 +154,7 @@ remove_patch() if [ $status -eq 0 ] then rm -f "$QUILT_PC/$patch/.timestamp" + rm -f "$QUILT_PC/$patch/.cksum" if [ -z "$(shopt -s nullglob ; echo "$QUILT_PC/$patch/"*)" ] then printf $"Patch %s appears to be empty, removing\n" \ diff --git a/quilt/push.in b/quilt/push.in index 17862fa..9ef0b87 100644 --- a/quilt/push.in +++ b/quilt/push.in @@ -391,6 +391,19 @@ done \ | cleanup_patch_output \ | colorize +# If patch add new files to repo they can't be copied to backup dir +# so let's put somethin in hash db which will never match anything. +if [ -n "$QUILT_USE_SHA1" ]; then + files=( $(files_in_patch_ordered $patches) ) + for file in ${files[@]};do + if [ -r $QUILT_PC/$patches/$file ]; then + shasum $QUILT_PC/$patches/$file 2>/dev/null | sed -e "s/$QUILT_PC\/$patches\///g">> $QUILT_PC/$patches/.cksum + else + echo "0000000000000000000000000000000000000000 $file" >>$QUILT_PC/$patches/.cksum + fi + done +fi + if [ ${PIPESTATUS[0]} -eq 0 ]; then set -- $patches printf $"Now at patch %s\n" "$(print_patch ${!#})" diff --git a/quilt/refresh.in b/quilt/refresh.in index f108892..e3cd48c 100644 --- a/quilt/refresh.in +++ b/quilt/refresh.in @@ -153,11 +153,17 @@ QUILT_DIFF_OPTS="$QUILT_DIFF_OPTS $opt_format" patch=$(find_applied_patch "$1") || exit 1 -if [ -z "$opt_sort" ] -then - files=( $(files_in_patch_ordered $patch) ) +# Get list of changed files, We need to get diff only for them +if [ -n "$QUILT_USE_SHA1" ]; then + failed=$(shasum -c $QUILT_PC/$patch/.cksum 2>/dev/null | grep FAILED|cut -d':' -f 1) + files=$failed else + if [ -z "$opt_sort" ] + then + files=( $(files_in_patch_ordered $patch) ) + else files=( $(files_in_patch $patch | sort) ) + fi fi if [ -n "$opt_fork" -a $# -ne 0 ] @@ -207,6 +213,7 @@ fi tmp_patch=$(gen_tempfile) +# Only files with wrong checksum needs to be diffed. for file in "${files[@]}" do if [ -n "$opt_fork" ]; then @@ -223,6 +230,7 @@ do files_were_shadowed=1 fi fi + if ! diff_file $file $old_file $new_file then printf $"Diff failed, aborting\n" >&2 diff --git a/quilt/remove.in b/quilt/remove.in index 96a4e86..7171f00 100644 --- a/quilt/remove.in +++ b/quilt/remove.in @@ -64,6 +64,7 @@ then fi patch=$(find_applied_patch "$opt_patch") || exit 1 +sum_bcp=$(gen_tempfile) status=0 for file in "$@" @@ -94,6 +95,12 @@ do continue fi + # Remove file hash from hash db + if [ -n "$QUILT_USE_SHA1" ]; then + grep -v $SUBDIR$file $QUILT_PC/$patch/.cksum >/tmp/$sum_bcp + mv -f $sum_bcp $QUILT_PC/$patch/.cksum + fi + if [ -e $(dirname $QUILT_PC/$patch~refresh) -a \ -e $(patch_file_name $patch) ] then