@@ -190,6 +190,7 @@ process_file() {
190190 local overlay_file=" $OVERLAY_UPPER /$rel_path "
191191 local repo_file=" $REPO_DIR /$rel_path "
192192 local status
193+ local choice=" $BATCH_MODE "
193194
194195 # Get file status
195196 status=$( get_file_status " $overlay_file " " $repo_file " )
@@ -204,7 +205,7 @@ process_file() {
204205 echo -e " ${RED} [DELETED]${NC} $original_rel_path "
205206
206207 while true ; do
207- read -p " Action [y=accept delete, r=discard (keep file), n=skip, Y=accept all, R=discard all, N=skip all]? " choice
208+ [ -n " $choice " ] || read -p " Action [y=accept delete, r=discard (keep file), n=skip, Y=accept all, R=discard all, N=skip all]? " choice
208209 case " $choice " in
209210 y)
210211 if [[ -e " $original_repo_file " ]]; then
@@ -250,6 +251,7 @@ process_file() {
250251 echo " Invalid choice. Please enter y, r, n, Y, R, or N"
251252 ;;
252253 esac
254+ choice=" "
253255 done
254256 fi
255257
@@ -268,10 +270,17 @@ process_file() {
268270 fi
269271
270272 echo " "
271- echo -e " ${status_color} [$status_label ]${NC} $rel_path "
273+
274+ if cmp -s " $overlay_file " " $repo_file " ; then
275+ printf " ${status_color} [NOT$status_label ]${NC} $rel_path \n"
276+ rm -f " $overlay_file "
277+ return 0
278+ else
279+ printf " ${status_color} [$status_label ]${NC} $rel_path \n"
280+ fi
272281
273282 while true ; do
274- read -p " Action [y=accept, r=discard, n=skip, d=diff, Y=accept all, R=discard all, N=skip all]? " choice
283+ [ -n " $choice " ] || read -p " Action [y=accept, r=discard, n=skip, d=diff, Y=accept all, R=discard all, N=skip all]? " choice
275284 case " $choice " in
276285 y)
277286 mkdir -p " $( dirname " $repo_file " ) "
@@ -318,6 +327,7 @@ process_file() {
318327 echo " Invalid choice. Please enter y, r, n, d, Y, R, or N"
319328 ;;
320329 esac
330+ choice=" "
321331 done
322332}
323333
@@ -422,67 +432,31 @@ for rel_path in "${FILES[@]}"; do
422432 overlay_file=" $OVERLAY_UPPER /$rel_path "
423433 repo_file=" $REPO_DIR /$rel_path "
424434
425- # Skip if file was already processed (e.g., by batch operations)
426- if [[ ! -e " $overlay_file " ] ]; then
435+ # Skip if file was already pro
436+ if [ ! -e " $overlay_file " ]; then
427437 continue
428438 fi
429439
430- # If in batch mode, apply the same action
431- if [[ -n " $BATCH_MODE " ]]; then
432- status=$( get_file_status " $overlay_file " " $repo_file " )
440+ ret=0
441+ process_file " $rel_path " || ret=$?
433442
434- case " $BATCH_MODE " in
435- accept)
436- if [[ " $status " == " deleted" ]]; then
437- original_name=$( get_whiteout_target " $overlay_file " )
438- original_rel_path=" ${original_name# $OVERLAY_UPPER / } "
439- original_repo_file=" $REPO_DIR /$original_rel_path "
440- if [[ -e " $original_repo_file " ]]; then
441- rm -f " $original_repo_file "
442- fi
443- rm -f " $overlay_file "
444- echo -e " ${GREEN} ✓${NC} [DELETED] $original_rel_path "
445- elif [[ " $status " != " directory" ]]; then
446- mkdir -p " $( dirname " $repo_file " ) "
447- cp -a " $overlay_file " " $repo_file "
448- rm -f " $overlay_file "
449- echo -e " ${GREEN} ✓${NC} [$status ] $rel_path "
450- fi
451- (( ACCEPTED++ ))
452- ;;
453- discard)
454- rm -f " $overlay_file "
455- echo -e " ${YELLOW} ✓${NC} [$status ] $rel_path "
456- (( DISCARDED++ ))
457- ;;
458- skip)
459- echo -e " ${CYAN} ○${NC} [$status ] $rel_path "
460- (( SKIPPED++ ))
461- ;;
462- esac
463- else
464- # Interactive mode
465- ret=0
466- process_file " $rel_path " || ret=$?
467-
468- case $ret in
469- 2)
470- BATCH_MODE=" accept"
471- echo " "
472- echo " → Accepting all remaining files..."
473- ;;
474- 3)
475- BATCH_MODE=" discard"
476- echo " "
477- echo " → Discarding all remaining files..."
478- ;;
479- 4)
480- BATCH_MODE=" skip"
481- echo " "
482- echo " → Skipping all remaining files..."
483- ;;
484- esac
485- fi
443+ case $ret in
444+ 2)
445+ BATCH_MODE=" y"
446+ echo " "
447+ echo " → Accepting all remaining files..."
448+ ;;
449+ 3)
450+ BATCH_MODE=" r"
451+ echo " "
452+ echo " → Discarding all remaining files..."
453+ ;;
454+ 4)
455+ BATCH_MODE=" n"
456+ echo " "
457+ echo " → Skipping all remaining files..."
458+ ;;
459+ esac
486460done
487461
488462# Clean up empty directories in overlay
0 commit comments