|
26 | 26 | REPO_DIR="$1" |
27 | 27 | OVERLAY_UPPER="$2" |
28 | 28 |
|
| 29 | +# Patterns to auto-discard (created by sandbox, should never be merged) |
| 30 | +IGNORE_PATTERNS=( |
| 31 | + ".claude/*" # Claude settings created by bwrap bind |
| 32 | +) |
| 33 | + |
| 34 | +# Check if a path matches any ignore pattern |
| 35 | +should_ignore() { |
| 36 | + local path="$1" |
| 37 | + for pattern in "${IGNORE_PATTERNS[@]}"; do |
| 38 | + # Use case for reliable glob pattern matching |
| 39 | + case "$path" in |
| 40 | + $pattern) return 0 ;; |
| 41 | + esac |
| 42 | + done |
| 43 | + return 1 |
| 44 | +} |
| 45 | + |
29 | 46 | # Validate directories |
30 | 47 | if [[ ! -d "$REPO_DIR" ]]; then |
31 | 48 | echo "Error: Repository directory does not exist: $REPO_DIR" |
@@ -281,12 +298,37 @@ echo "" |
281 | 298 | # Find all files in overlay (including hidden files, excluding . and ..) |
282 | 299 | # We need to handle whiteout files (both .wh. prefix and char devices 0/0) and regular files |
283 | 300 | FILES=() |
| 301 | +IGNORED=() |
284 | 302 | while IFS= read -r -d '' file; do |
285 | 303 | rel_path="${file#$OVERLAY_UPPER/}" |
286 | | - FILES+=("$rel_path") |
| 304 | + if should_ignore "$rel_path"; then |
| 305 | + IGNORED+=("$rel_path") |
| 306 | + # Auto-discard ignored files |
| 307 | + rm -f "$file" |
| 308 | + else |
| 309 | + FILES+=("$rel_path") |
| 310 | + fi |
287 | 311 | done < <(find "$OVERLAY_UPPER" \( -type f -o -type c \) -print0 | sort -z) |
288 | 312 |
|
| 313 | +# Report ignored files |
| 314 | +if [[ ${#IGNORED[@]} -gt 0 ]]; then |
| 315 | + echo "Auto-discarded ${#IGNORED[@]} ignored file(s):" |
| 316 | + for f in "${IGNORED[@]}"; do |
| 317 | + echo " - $f" |
| 318 | + done |
| 319 | + echo "" |
| 320 | +fi |
| 321 | + |
289 | 322 | TOTAL=${#FILES[@]} |
| 323 | + |
| 324 | +# Exit if no files remain after filtering |
| 325 | +if [[ $TOTAL -eq 0 ]]; then |
| 326 | + # Clean up empty directories |
| 327 | + find "$OVERLAY_UPPER" -type d -empty -delete 2>/dev/null || true |
| 328 | + echo "✓ No changes in overlay - nothing to merge" |
| 329 | + exit 0 |
| 330 | +fi |
| 331 | + |
290 | 332 | echo "Found $TOTAL file(s) to review" |
291 | 333 | echo "" |
292 | 334 |
|
|
0 commit comments