Skip to content

quiltimport Git Command Guide

The git quiltimport command applies a quilt patchset onto the current Git branch, preserving patch boundaries, order, and descriptions. It converts quilt-managed patches into Git commits.

Terminal window
git quiltimport [--dry-run | -n] [--author <author>] [--patches <dir>]
[--series <file>] [--keep-non-patch]
OptionDescription
-n, --dry-runCheck patches without applying
--author <author>Default author for patches
--patches <dir>Directory containing patches
--series <file>Series file path
--keep-non-patchKeep non-patch files
Quilt Overview:
├── Quilt is a patch management system for Linux kernel development
├── Manages series of patches applied on top of source code
├── Each patch represents one logical change
├── Patches stored as individual .patch files
├── Series file tracks patch order and application
Quilt Workflow:
├── quilt new <patch-name> # Create new patch
├── quilt add <files> # Add files to patch
├── quilt edit <files> # Edit files in patch context
├── quilt refresh # Update patch with changes
├── quilt pop/push # Remove/apply patches
└── quilt series # Show patch series
Quilt to Git Conversion:
1. Analyze quilt series file for patch order
2. Extract author information from patch descriptions
3. Apply each patch as individual Git commit
4. Preserve patch boundaries and descriptions
5. Handle patch dependencies and conflicts
6. Create Git commit history from patch series
Import Process:
├── Read series file for patch ordering
├── Validate patch files exist
├── Extract metadata (author, subject, description)
├── Apply patches in sequence
├── Create commits with proper authorship
└── Handle merge conflicts if they occur
Quilt Patch Series:
├── patches/ # Directory containing .patch files
├── series # File listing patches in order
├── .pc/ # Quilt internal state (applied patches)
└── [source code] # Modified source files
Series File Format:
├── One patch filename per line
├── Optional comments with #
├── Patch options and metadata
└── Maintains application order
Example series file:
├── # Initial setup patches
├── 001-initial-setup.patch
├── 002-core-functionality.patch
├── # Feature implementation
├── 003-new-feature.patch
└── 004-documentation.patch
Terminal window
# Import quilt patches from default location
git quiltimport
# Import from specific patches directory
git quiltimport --patches patches/
# Import with custom series file
git quiltimport --series my-series.txt
# Dry run to check patches
git quiltimport --dry-run
Terminal window
# Specify default author for all patches
git quiltimport --author "John Doe <john@example.com>"
# Interactive author entry (default when author missing)
git quiltimport # Will prompt for missing authors
# Mixed approach - some specified, others interactive
git quiltimport --author "Default Author <default@example.com>"
Terminal window
# Import with non-patch files preserved
git quiltimport --keep-non-patch
# Import specific series file
git quiltimport --series patches/series.conf
# Combine options
git quiltimport --dry-run --author "Maintainer <maintainer@project.org>" --patches quilt-patches/
Terminal window
# Configure quiltimport behavior
git config quiltimport.defaultAuthor "Default Author <default@example.com>"
# Configure patch handling
git config quiltimport.keepNonPatch false
# Configure series file location
git config quiltimport.seriesFile "series"
Terminal window
# Always backup before import
git branch backup-before-quiltimport
# Test import first
git quiltimport --dry-run
# Verify working tree is clean
git status
# Check patch validity
find patches/ -name "*.patch" -exec git apply --check {} \;
# Review imported commits
git log --oneline -10
Terminal window
# Prepare quilt patches for import
prepare_quilt_patches() {
local quilt_dir="$1"
echo "Preparing quilt patches from $quilt_dir"
# Validate series file
if [ ! -f "$quilt_dir/series" ]; then
echo "Series file not found"
return 1
fi
# Check patch files exist
while read -r line; do
# Skip comments and empty lines
[[ "$line" =~ ^# ]] || [ -z "$line" ] && continue
patch_file="$quilt_dir/$(echo "$line" | awk '{print $1}')"
if [ ! -f "$patch_file" ]; then
echo "Missing patch file: $patch_file"
return 1
fi
done < "$quilt_dir/series"
# Validate patch format
find "$quilt_dir" -name "*.patch" -exec git apply --check {} \; 2>/dev/null
echo "Patch preparation complete"
}
prepare_quilt_patches "quilt-patches/"
#!/bin/bash
# Kernel development quilt integration
kernel_patch_workflow() {
local kernel_version="$1"
local quilt_series="$2"
echo "Importing kernel patches for version $kernel_version"
# Set up kernel repository
git checkout "v$kernel_version"
git checkout -b "kernel-$kernel_version-patched"
# Import quilt patches
git quiltimport --patches "$quilt_series" \
--author "Kernel Team <kernel@project.org>"
# Verify import
imported_commits=$(git rev-list HEAD --count)
echo "Imported $imported_commits commits"
# Run kernel build test
make defconfig && make -j$(nproc) 2>&1 | head -20
echo "Kernel patch import complete"
}
kernel_patch_workflow "5.15" "/path/to/kernel-patches"
Terminal window
# Maintain patches for upstream projects
maintain_upstream_patches() {
local upstream_repo="$1"
local patch_dir="$2"
echo "Maintaining patches for upstream project"
# Sync with upstream
git fetch "$upstream_repo"
git rebase "FETCH_HEAD"
# Apply maintained patches
git quiltimport --patches "$patch_dir" \
--keep-non-patch
# Test integration
run-tests.sh
# Update patch series if needed
echo "Patches maintained and tested"
}
maintain_upstream_patches "upstream" "my-patches/"
Terminal window
# Collaborative patch development workflow
collaborative_patches() {
local patch_repo="$1"
local contributor="$2"
echo "Importing patches from contributor $contributor"
# Clone contributor's patch repository
git clone "$patch_repo" contributor-patches
cd contributor-patches
# Import patches into main branch
git quiltimport --author "$contributor <contributor@example.com>"
# Review imported patches
git log --oneline --author="$contributor" -10
# Merge into main project
cd ..
git remote add contributor contributor-patches
git merge contributor/main
echo "Collaborative patches integrated"
}
collaborative_patches "https://github.com/user/patches.git" "Jane Doe"
Terminal window
# Handle missing author information
fix_missing_authors() {
local patches_dir="$1"
echo "Checking for missing author information"
# Scan patches for author info
find "$patches_dir" -name "*.patch" | while read -r patch; do
if ! grep -q "^From:" "$patch" && ! grep -q "^Author:" "$patch"; then
echo "Missing author in: $patch"
# Extract from git history if possible
patch_name=$(basename "$patch" .patch)
possible_author=$(git log --format="%an <%ae>" --grep="$patch_name" | head -1)
if [ -n "$possible_author" ]; then
echo "Suggested author: $possible_author"
fi
fi
done
echo "Use --author flag to specify default author"
}
fix_missing_authors "patches/"
Terminal window
# Handle patch application failures
debug_patch_failures() {
local failed_patch="$1"
echo "Debugging patch application failure: $failed_patch"
# Check patch format
head -20 "$failed_patch"
# Test patch application
git apply --check "$failed_patch" 2>&1 || {
echo "Patch has conflicts or format issues"
# Try with different options
git apply --whitespace=fix "$failed_patch" 2>&1 || {
echo "Patch needs manual fixing"
return 1
}
}
# Check for quilt-specific issues
if grep -q "^Index:" "$failed_patch"; then
echo "Quilt-style patch detected"
fi
echo "Patch debugging complete"
}
debug_patch_failures "patches/001-broken.patch"
Terminal window
# Fix series file problems
validate_series_file() {
local series_file="$1"
local patches_dir="$2"
echo "Validating series file: $series_file"
# Check series file exists
if [ ! -f "$series_file" ]; then
echo "Series file not found: $series_file"
return 1
fi
# Validate each patch reference
local line_num=1
while read -r line; do
# Skip comments and empty lines
[[ "$line" =~ ^[[:space:]]*# ]] || [ -z "$line" ] && continue
# Extract patch filename
patch_file=$(echo "$line" | awk '{print $1}')
# Check patch exists
if [ ! -f "$patches_dir/$patch_file" ]; then
echo "Missing patch file on line $line_num: $patch_file"
return 1
fi
((line_num++))
done < "$series_file"
echo "Series file validation passed"
}
validate_series_file "patches/series" "patches/"
Terminal window
# Handle encoding and format problems
fix_encoding_issues() {
local patches_dir="$1"
echo "Fixing encoding and format issues"
# Convert patches to UTF-8
find "$patches_dir" -name "*.patch" | while read -r patch; do
if ! file "$patch" | grep -q "UTF-8"; then
echo "Converting $patch to UTF-8"
iconv -f latin1 -t utf8 "$patch" > "${patch}.utf8"
mv "${patch}.utf8" "$patch"
fi
done
# Fix line endings
find "$patches_dir" -name "*.patch" -exec dos2unix {} \;
# Normalize patch format
find "$patches_dir" -name "*.patch" | while read -r patch; do
# Ensure proper patch headers
if ! grep -q "^---" "$patch"; then
echo "Warning: $patch may not be in standard patch format"
fi
done
echo "Encoding fixes applied"
}
fix_encoding_issues "patches/"
Terminal window
# Handle patch dependency problems
resolve_dependencies() {
local series_file="$1"
echo "Analyzing patch dependencies"
# Create dependency graph (simplified)
declare -A patch_deps
# For each patch, check what files it modifies
while read -r line; do
[[ "$line" =~ ^# ]] || [ -z "$line" ] && continue
patch_file=$(echo "$line" | awk '{print $1}')
modified_files=$(grep "^+++ " "$patch_file" | sed 's/+++ [ab]\///')
patch_deps["$patch_file"]="$modified_files"
done < "$series_file"
# Check for conflicts
for patch1 in "${!patch_deps[@]}"; do
for patch2 in "${!patch_deps[@]}"; do
if [ "$patch1" != "$patch2" ]; then
# Check for overlapping files
common_files=$(comm -12 \
<(echo "${patch_deps[$patch1]}" | tr ' ' '\n' | sort) \
<(echo "${patch_deps[$patch2]}" | tr ' ' '\n' | sort))
if [ -n "$common_files" ]; then
echo "Potential conflict between $patch1 and $patch2"
echo "Common files: $common_files"
fi
fi
done
done
echo "Dependency analysis complete"
}
resolve_dependencies "patches/series"
#!/bin/bash
# Kernel patch management with quiltimport
kernel_patch_management() {
local kernel_version="$1"
local quilt_repo="$2"
echo "Managing kernel patches for version $kernel_version"
# Set up kernel tree
git clone "https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
cd linux
git checkout "v$kernel_version"
# Create patch branch
git checkout -b "patches-$kernel_version"
# Import quilt patches
git quiltimport --patches "$quilt_repo/patches" \
--series "$quilt_repo/series" \
--author "Kernel Maintainers <maintainers@kernel.org>"
# Verify kernel builds
make defconfig
make -j$(nproc) modules_prepare 2>&1 | head -20
if [ "${PIPESTATUS[0]}" -eq 0 ]; then
echo "✓ Kernel patches imported successfully"
else
echo "✗ Kernel build failed after patch import"
exit 1
fi
# Create patch documentation
git log --oneline --reverse > "PATCHES-$kernel_version.txt"
echo "Patch list saved to PATCHES-$kernel_version.txt"
}
kernel_patch_management "6.1" "/path/to/kernel-quilt"
Terminal window
# Embedded systems patch management
embedded_patch_workflow() {
local board_config="$1"
local patch_set="$2"
echo "Managing patches for embedded board: $board_config"
# Set up base system
git checkout "base-$board_config"
git checkout -b "patched-$board_config"
# Import board-specific patches
git quiltimport --patches "$patch_set/board-patches" \
--author "Board Team <board@company.com>"
# Import BSP patches
git quiltimport --patches "$patch_set/bsp-patches" \
--author "BSP Team <bsp@company.com>"
# Test build
make BOARD="$board_config" 2>&1 | head -20
# Create release tag
git tag "release-$board_config-$(date +%Y%m%d)"
echo "Embedded patches integrated for $board_config"
}
embedded_patch_workflow "raspberry-pi-4" "/path/to/board-patches"
Terminal window
# Collaborative patch review workflow
patch_review_workflow() {
local patch_repo="$1"
local reviewer="$2"
echo "Reviewing patches from $patch_repo"
# Clone patch repository
git clone "$patch_repo" review-patches
cd review-patches
# Dry run import to check patches
git quiltimport --dry-run --author "$reviewer <reviewer@company.com>"
# Import patches for review
git quiltimport --author "$reviewer <reviewer@company.com>"
# Review each imported commit
git log --oneline --reverse | while read -r commit_line; do
commit=$(echo "$commit_line" | cut -d' ' -f1)
subject=$(echo "$commit_line" | cut -d' ' -f2-)
echo "Reviewing: $subject"
git show "$commit" | head -50
# Interactive review
read -p "Accept this patch? (y/n/skip): " decision
case "$decision" in
"n")
echo "Patch rejected: $subject"
git reset --hard HEAD~1
;;
"skip")
echo "Patch skipped: $subject"
;;
*)
echo "Patch accepted: $subject"
;;
esac
done
# Push reviewed patches
git push origin main
echo "Patch review complete"
}
patch_review_workflow "https://github.com/user/feature-patches.git" "Senior Developer"
Terminal window
# Automated patch testing pipeline
automated_patch_testing() {
local patch_dir="$1"
local test_script="$2"
echo "Running automated patch testing"
# Create test branch
git checkout -b "test-patches-$(date +%Y%m%d-%H%M%S)"
# Import patches
git quiltimport --patches "$patch_dir" \
--author "CI System <ci@company.com>"
# Test each patch individually
git log --oneline --reverse | while read -r commit_line; do
commit=$(echo "$commit_line" | cut -d' ' -f1)
subject=$(echo "$commit_line" | cut -d' ' -f2-)
echo "Testing patch: $subject"
# Run test suite
if $test_script; then
echo "✓ Tests passed for: $subject"
else
echo "✗ Tests failed for: $subject"
echo "Failing commit: $commit"
# Revert failing patch
git reset --hard HEAD~1
break
fi
done
# Report results
successful_patches=$(git rev-list HEAD --count)
echo "Successfully applied $successful_patches patches"
if [ "$successful_patches" -gt 0 ]; then
echo "Test results: PASS"
else
echo "Test results: FAIL"
exit 1
fi
}
automated_patch_testing "patches/" "./run-tests.sh"
Terminal window
# Migrate legacy patches to Git
legacy_migration() {
local legacy_patches="$1"
local target_repo="$2"
echo "Migrating legacy patches to Git repository"
# Set up target repository
git clone "$target_repo" migration-target
cd migration-target
# Create migration branch
git checkout -b "migrated-patches"
# Convert legacy patches to quilt format if needed
if [ -d "$legacy_patches" ]; then
# Assume patches are already in quilt format
patch_dir="$legacy_patches"
else
# Convert from other formats
echo "Converting patches from legacy format..."
# Conversion logic here
patch_dir="converted-patches"
fi
# Import patches
git quiltimport --patches "$patch_dir" \
--keep-non-patch \
--author "Migration Team <migration@company.com>"
# Validate migration
imported_count=$(git rev-list HEAD --count)
echo "Migrated $imported_count patches"
# Test build
if [ -f "Makefile" ] || [ -f "build.sh" ]; then
make clean && make 2>&1 | head -20
if [ "${PIPESTATUS[0]}" -eq 0 ]; then
echo "✓ Build successful after migration"
else
echo "⚠ Build issues detected"
fi
fi
# Create migration report
git log --oneline --reverse > "MIGRATION-REPORT.txt"
echo "Migration report saved"
echo "Legacy migration complete"
}
legacy_migration "/path/to/legacy-patches" "https://github.com/company/project.git"
Terminal window
# Maintain and update patch series
maintain_patch_series() {
local series_name="$1"
local upstream_repo="$2"
echo "Maintaining patch series: $series_name"
# Sync with upstream
git fetch "$upstream_repo"
git rebase "FETCH_HEAD"
# Update patches if needed
if [ -d "patches-$series_name" ]; then
echo "Updating existing patch series"
# Refresh patches
git format-patch --output-directory="patches-$series_name" \
--numbered \
"origin/main..HEAD"
# Update series file
ls patches-$series_name/*.patch | sed 's|.*/||' > "patches-$series_name/series"
echo "Patch series updated"
else
echo "Creating new patch series"
# Export current patches
git quiltimport --patches "patches-$series_name" \
--author "Maintainer <maintainer@project.org>"
echo "Patch series created"
fi
# Archive patch series
tar czf "${series_name}-$(date +%Y%m%d).tar.gz" "patches-$series_name/"
echo "Patch series archived"
}
maintain_patch_series "security-fixes" "upstream"

What’s the difference between quiltimport and git am?

Section titled “What’s the difference between quiltimport and git am?”

quiltimport imports entire patch series preserving boundaries, while git am applies individual patches. quiltimport maintains patch order and descriptions from quilt series.

Ensure patches are in quilt format with proper headers, create a series file listing patches in order, and verify all patches can be applied cleanly.

Can quiltimport handle patch dependencies?

Section titled “Can quiltimport handle patch dependencies?”

Yes, it applies patches in the order specified in the series file, maintaining dependencies between patches.

What if patches have conflicts during import?

Section titled “What if patches have conflicts during import?”

quiltimport will stop at the first conflict. Resolve conflicts manually, then continue with git am —continue or restart the import process.

How do I specify author information for patches?

Section titled “How do I specify author information for patches?”

Use —author “Name ” for all patches, or let quiltimport extract from patch descriptions. Missing authors will prompt for interactive entry.

Can quiltimport work with compressed patches?

Section titled “Can quiltimport work with compressed patches?”

No, patches must be uncompressed text files. Use gunzip or similar to decompress patches before import.

What’s the —keep-non-patch option for?

Section titled “What’s the —keep-non-patch option for?”

—keep-non-patch preserves files in the patches directory that aren’t .patch files, useful for maintaining additional patch-related files.

How do I validate patches before importing?

Section titled “How do I validate patches before importing?”

Use —dry-run to check for missing information and potential issues without applying patches.

Can quiltimport import patches from git format-patch?

Section titled “Can quiltimport import patches from git format-patch?”

Yes, git format-patch creates patches compatible with quiltimport. Use —numbered option for proper ordering.

What’s the difference between series file and patch files?

Section titled “What’s the difference between series file and patch files?”

Series file lists patches in application order; patch files contain the actual diff content with metadata.

How do I handle patches with different encodings?

Section titled “How do I handle patches with different encodings?”

Convert patches to UTF-8 before import. Use iconv or similar tools to handle encoding issues.

No, quiltimport only works with text-based patches. Binary changes should be handled differently.

How do I resume an interrupted quiltimport?

Section titled “How do I resume an interrupted quiltimport?”

Check git status, resolve any conflicts, then use git am —continue if using git am, or restart quiltimport from the failed patch.

What’s the impact of quiltimport on repository history?

Section titled “What’s the impact of quiltimport on repository history?”

quiltimport creates one Git commit per quilt patch, preserving the patch’s author, date, and description.

Can quiltimport handle quilt’s .pc directory?

Section titled “Can quiltimport handle quilt’s .pc directory?”

No, quiltimport doesn’t use quilt’s internal state. It only reads the series file and patch files.

How do I convert existing quilt patches to Git?

Section titled “How do I convert existing quilt patches to Git?”

Use quiltimport directly on the patches directory, or use git am on individual patches if you don’t need to preserve quilt structure.

Can quiltimport work with remote patch repositories?

Section titled “Can quiltimport work with remote patch repositories?”

Yes, clone or download the patch repository first, then run quiltimport on the local patch directory.

Applications of the git quiltimport command

Section titled “Applications of the git quiltimport command”
  1. Legacy Code Migration: Converting quilt-managed patches to Git commits
  2. Kernel Development: Importing kernel patches while preserving patch boundaries
  3. Collaborative Development: Managing patch series from multiple contributors
  4. Embedded Systems: Maintaining board-specific and BSP patches
  5. Open Source Maintenance: Managing patches for upstream project maintenance