Skip to content

Instantly share code, notes, and snippets.

@mvaisakh
Last active October 10, 2024 09:02
Show Gist options
  • Save mvaisakh/266379bd20a8427c912c1c019323655c to your computer and use it in GitHub Desktop.
Save mvaisakh/266379bd20a8427c912c1c019323655c to your computer and use it in GitHub Desktop.
A Kernel split changes committing script (used for splitting massive OEM kernel commits)
#!/usr/bin/bash
# author: Vaisakh Murali <[email protected]>
#
# Before you start, make sure you squash all split OEM commits into
# one single commit. This will break down the single huge commit
# into multiple smaller commits, helping to cleanup OEM codes easier.
#
# Make sure this script is renamed to rebase.sh as the script
# explicitly removes rebase.sh from being committed during the split
# process.
# Split OEM Changes
echo "Split OEM modifications"
echo "Initial reset"
git reset HEAD^ . >/dev/null 2>&1
echo "Committing a starting point commit (This commit might be authored by the original OEM author)"
git commit -sm "BEGIN OEM Imports" --allow-empty --amend >/dev/null 2>&1
echo "Splitting commits... (This might take a while, do not interrupt)"
DIFFPATHS=(
"arch/arm64/configs"
"arch/arm64/boot"
"arch/arm64"
"arch/arm/boot"
"arch/arm/configs"
"arch/arm"
"arch/x86"
"arch/openrisc"
"arch/ia64"
"arch/nds32"
"arch/mips"
"arch/hexagon"
"arch/c6x"
"arch/sh"
"arch/arc"
"arch/riscv"
"arch/nios2"
"arch/microblaze"
"arch/alpha"
"arch/sparc"
"arch/um"
"arch/h8300"
"arch/xtensa"
"arch/m68k"
"arch/s390"
"arch/parisc"
"arch/unicore32"
"arch/powerpc"
"drivers/accessibility"
"drivers/acpi"
"drivers/amba"
"drivers/android"
"drivers/ata"
"drivers/atm"
"drivers/auxdisplay"
"drivers/base"
"drivers/bcma"
"drivers/block"
"drivers/bluetooth"
"drivers/bus"
"drivers/cdrom"
"drivers/char"
"drivers/clk"
"drivers/clocksource"
"drivers/connector"
"drivers/counter"
"drivers/cpufreq"
"drivers/cpuidle"
"drivers/crypto"
"drivers/dax"
"drivers/dca"
"drivers/devfreq"
"drivers/dio"
"drivers/dma"
"drivers/dma-buf"
"drivers/edac"
"drivers/eisa"
"drivers/extcon"
"drivers/firewire"
"drivers/firmware"
"drivers/fpga"
"drivers/fsi"
"drivers/gnss"
"drivers/gpio"
"drivers/gpu"
"drivers/greybus"
"drivers/hid"
"drivers/hsi"
"drivers/hv"
"drivers/hwmon"
"drivers/hwspinlock"
"drivers/hwtracing"
"drivers/i2c"
"drivers/i3c"
"drivers/ide"
"drivers/idle"
"drivers/iio"
"drivers/infiniband"
"drivers/input"
"drivers/interconnect"
"drivers/iommu"
"drivers/ipack"
"drivers/irqchip"
"drivers/isdn"
"drivers/Kconfig"
"drivers/leds"
"drivers/lightnvm"
"drivers/macintosh"
"drivers/mailbox"
"drivers/Makefile"
"drivers/mcb"
"drivers/md"
"drivers/media"
"drivers/memory"
"drivers/memstick"
"drivers/message"
"drivers/mfd"
"drivers/misc/mediatek/accdet"
"drivers/misc/mediatek/adsp"
"drivers/misc/mediatek/aee"
"drivers/misc/mediatek/apusys/debug"
"drivers/misc/mediatek/apusys/devapc"
"drivers/misc/mediatek/apusys/edma"
"drivers/misc/mediatek/apusys/include"
"drivers/misc/mediatek/apusys/mdla"
"drivers/misc/mediatek/apusys/mem"
"drivers/misc/mediatek/apusys/midware"
"drivers/misc/mediatek/apusys/mnoc"
"drivers/misc/mediatek/apusys/pmu"
"drivers/misc/mediatek/apusys/power"
"drivers/misc/mediatek/apusys/reviser"
"drivers/misc/mediatek/apusys/sample"
"drivers/misc/mediatek/apusys/util"
"drivers/misc/mediatek/apusys/vpu"
"drivers/misc/mediatek/apusys"
"drivers/misc/mediatek/atf"
"drivers/misc/mediatek/audio_ipi"
"drivers/misc/mediatek/audio_scp"
"drivers/misc/mediatek/auxadc"
"drivers/misc/mediatek/base/power/brisket_v1"
"drivers/misc/mediatek/base/power/clkbuf_v1"
"drivers/misc/mediatek/base/power/cm_mgr_v1"
"drivers/misc/mediatek/base/power/cpufreq_v1"
"drivers/misc/mediatek/base/power/cpufreq_v2"
"drivers/misc/mediatek/base/power/cpuhotplug"
"drivers/misc/mediatek/base/power/cpuidle_v3"
"drivers/misc/mediatek/base/power/cpumssv_v1"
"drivers/misc/mediatek/base/power/credit_didt_v1"
"drivers/misc/mediatek/base/power/dcm_v1"
"drivers/misc/mediatek/base/power/drcc_v1"
"drivers/misc/mediatek/base/power/dvfsrc"
"drivers/misc/mediatek/base/power/eem_v2"
"drivers/misc/mediatek/base/power/eemgpu_v2"
"drivers/misc/mediatek/base/power/gpufreq_v1"
"drivers/misc/mediatek/base/power/hps_v1"
"drivers/misc/mediatek/base/power/include"
"drivers/misc/mediatek/base/power/koro"
"drivers/misc/mediatek/base/power/leakage_table_v2"
"drivers/misc/mediatek/base/power/mcdi"
"drivers/misc/mediatek/base/power/mdpm_v1"
"drivers/misc/mediatek/base/power/mdpm_v2"
"drivers/misc/mediatek/base/power/mt6765"
"drivers/misc/mediatek/base/power/mt6768"
"drivers/misc/mediatek/base/power/mt6785"
"drivers/misc/mediatek/base/power/pbm_v3"
"drivers/misc/mediatek/base/power/pbm_v4"
"drivers/misc/mediatek/base/power/power_gs_v1"
"drivers/misc/mediatek/base/power/power_throttling"
"drivers/misc/mediatek/base/power/ppm_v3"
"drivers/misc/mediatek/base/power/ptp3_v1"
"drivers/misc/mediatek/base/power/qos"
"drivers/misc/mediatek/base/power/ses_v1"
"drivers/misc/mediatek/base/power/slbc"
"drivers/misc/mediatek/base/power/spm"
"drivers/misc/mediatek/base/power/spm_v4"
"drivers/misc/mediatek/base/power/srclken_rc_v1"
"drivers/misc/mediatek/base/power/swpm_v1"
"drivers/misc/mediatek/base/power/udi_v1"
"drivers/misc/mediatek/base/power/udi_v2"
"drivers/misc/mediatek/base/power/upower_v2"
"drivers/misc/mediatek/base/power/vcorefs_v3"
"drivers/misc/mediatek/base/power"
"drivers/misc/mediatek/base"
"drivers/misc/mediatek/blocktag"
"drivers/misc/mediatek/boot"
"drivers/misc/mediatek/btif"
"drivers/misc/mediatek/c2k_usb"
"drivers/misc/mediatek/cache-auditor"
"drivers/misc/mediatek/cam_cal"
"drivers/misc/mediatek/camera_ldo"
"drivers/misc/mediatek/camera_security"
"drivers/misc/mediatek/cameraisp"
"drivers/misc/mediatek/ccci_util"
"drivers/misc/mediatek/ccmni"
"drivers/misc/mediatek/ccu"
"drivers/misc/mediatek/chip"
"drivers/misc/mediatek/cirq"
"drivers/misc/mediatek/cmdq"
"drivers/misc/mediatek/cmo"
"drivers/misc/mediatek/conn_md"
"drivers/misc/mediatek/connectivity"
"drivers/misc/mediatek/cqdma"
"drivers/misc/mediatek/dbgtop"
"drivers/misc/mediatek/dcxo"
"drivers/misc/mediatek/debug_latch"
"drivers/misc/mediatek/debug_tracer"
"drivers/misc/mediatek/devapc"
"drivers/misc/mediatek/devinfo"
"drivers/misc/mediatek/devmpu"
"drivers/misc/mediatek/dfd"
"drivers/misc/mediatek/dfrc"
"drivers/misc/mediatek/dramc"
"drivers/misc/mediatek/dws"
"drivers/misc/mediatek/eccci"
"drivers/misc/mediatek/emi"
"drivers/misc/mediatek/emi_bwl"
"drivers/misc/mediatek/emi_mpu"
"drivers/misc/mediatek/ext_disp"
"drivers/misc/mediatek/ext_gic"
"drivers/misc/mediatek/fiq_cache"
"drivers/misc/mediatek/flashlight"
"drivers/misc/mediatek/freqhopping"
"drivers/misc/mediatek/gate_ic"
"drivers/misc/mediatek/gcpu"
"drivers/misc/mediatek/geniezone"
"drivers/misc/mediatek/gpu/ged"
"drivers/misc/mediatek/gpu/gpu_bm"
"drivers/misc/mediatek/gpu/gpu_mali/mali_bifrost"
"drivers/misc/mediatek/gpu/gpu_mali/mali_valhall"
"drivers/misc/mediatek/gpu/gpu_mali"
"drivers/misc/mediatek/gpu/gpu_rgx"
"drivers/misc/mediatek/gpu/hal"
"drivers/misc/mediatek/gpu"
"drivers/misc/mediatek/gud"
"drivers/misc/mediatek/hdmi"
"drivers/misc/mediatek/hifi4dsp_spi"
"drivers/misc/mediatek/hifi_dsp"
"drivers/misc/mediatek/hifidsp_audio_ipi"
"drivers/misc/mediatek/ice_debug"
"drivers/misc/mediatek/imgsensor"
"drivers/misc/mediatek/include"
"drivers/misc/mediatek/io_boost"
"drivers/misc/mediatek/irrx"
"drivers/misc/mediatek/irtx"
"drivers/misc/mediatek/jpeg"
"drivers/misc/mediatek/l3c_part"
"drivers/misc/mediatek/lcd_bias"
"drivers/misc/mediatek/lcm"
"drivers/misc/mediatek/leds"
"drivers/misc/mediatek/log_store"
"drivers/misc/mediatek/lpm"
"drivers/misc/mediatek/m4u"
"drivers/misc/mediatek/masp"
"drivers/misc/mediatek/mcupm"
"drivers/misc/mediatek/mddp"
"drivers/misc/mediatek/mdp"
"drivers/misc/mediatek/memory-amms"
"drivers/misc/mediatek/memory-ssmr"
"drivers/misc/mediatek/met_drv"
"drivers/misc/mediatek/mlog"
"drivers/misc/mediatek/mmdvfs"
"drivers/misc/mediatek/mmp"
"drivers/misc/mediatek/mtee"
"drivers/misc/mediatek/mtprintk"
"drivers/misc/mediatek/mtprof"
"drivers/misc/mediatek/mu3d"
"drivers/misc/mediatek/mu3phy"
"drivers/misc/mediatek/nand"
"drivers/misc/mediatek/nfc"
"drivers/misc/mediatek/otp"
"drivers/misc/mediatek/partition"
"drivers/misc/mediatek/perf"
"drivers/misc/mediatek/performance"
"drivers/misc/mediatek/pidmap"
"drivers/misc/mediatek/pmic"
"drivers/misc/mediatek/pmic_wrap"
"drivers/misc/mediatek/pmsr"
"drivers/misc/mediatek/power"
"drivers/misc/mediatek/pseudo_m4u"
"drivers/misc/mediatek/pwm"
"drivers/misc/mediatek/ram_console"
"drivers/misc/mediatek/rps"
"drivers/misc/mediatek/rt-regmap"
"drivers/misc/mediatek/rtc"
"drivers/misc/mediatek/sched"
"drivers/misc/mediatek/scp"
"drivers/misc/mediatek/sda"
"drivers/misc/mediatek/selinux_warning"
"drivers/misc/mediatek/sensor"
"drivers/misc/mediatek/sensors-1.0"
"drivers/misc/mediatek/smi"
"drivers/misc/mediatek/spi_slave_drv"
"drivers/misc/mediatek/sspm"
"drivers/misc/mediatek/subpmic"
"drivers/misc/mediatek/sync"
"drivers/misc/mediatek/systracker"
"drivers/misc/mediatek/task_turbo"
"drivers/misc/mediatek/tee_sanity"
"drivers/misc/mediatek/teei"
"drivers/misc/mediatek/thermal"
"drivers/misc/mediatek/timer"
"drivers/misc/mediatek/tkcore"
"drivers/misc/mediatek/trusted_mem"
"drivers/misc/mediatek/twam"
"drivers/misc/mediatek/typec"
"drivers/misc/mediatek/uart"
"drivers/misc/mediatek/udi"
"drivers/misc/mediatek/usb11"
"drivers/misc/mediatek/usb20"
"drivers/misc/mediatek/usb2jtag"
"drivers/misc/mediatek/usb_boost"
"drivers/misc/mediatek/vdec_fmt"
"drivers/misc/mediatek/vibrator"
"drivers/misc/mediatek/video"
"drivers/misc/mediatek/videocodec"
"drivers/misc/mediatek/vow"
"drivers/misc/mediatek/vpu"
"drivers/misc/mediatek/xo"
"drivers/misc/mediatek/zone_movable_cma"
"drivers/misc/mediatek"
"drivers/misc"
"drivers/mmc"
"drivers/mtd"
"drivers/mux"
"drivers/net"
"drivers/nfc"
"drivers/ntb"
"drivers/nubus"
"drivers/nvdimm"
"drivers/nvme"
"drivers/nvmem"
"drivers/of"
"drivers/opp"
"drivers/oprofile"
"drivers/parisc"
"drivers/parport"
"drivers/pci"
"drivers/pcmcia"
"drivers/perf"
"drivers/phy"
"drivers/pinctrl"
"drivers/platform"
"drivers/pnp "
"drivers/power"
"drivers/powercap"
"drivers/pps"
"drivers/ps3"
"drivers/ptp"
"drivers/pwm"
"drivers/rapidio"
"drivers/ras"
"drivers/regulator"
"drivers/remoteproc"
"drivers/reset"
"drivers/rpmsg"
"drivers/rtc"
"drivers/s390"
"drivers/sbus"
"drivers/scsi"
"drivers/sfi"
"drivers/sh"
"drivers/siox"
"drivers/slimbus"
"drivers/soc"
"drivers/soundwire"
"drivers/spi"
"drivers/spmi"
"drivers/ssb"
"drivers/staging"
"drivers/target"
"drivers/tc"
"drivers/tee"
"drivers/thermal"
"drivers/thunderbolt"
"drivers/tty"
"drivers/uio"
"drivers/usb"
"drivers/vfio"
"drivers/vhost"
"drivers/video"
"drivers/virt"
"drivers/virtio"
"drivers/visorbus"
"drivers/vlynq"
"drivers/vme"
"drivers/w1"
"drivers/watchdog"
"drivers/xen"
"drivers/zorro"
"firmware"
"fs/fscache"
"fs/afs"
"fs/tracefs"
"fs/quota"
"fs/cachefiles"
"fs/befs"
"fs/f2fs"
"fs/openpromfs"
"fs/ocfs2"
"fs/configfs"
"fs/hfsplus"
"fs/autofs"
"fs/cramfs"
"fs/devpts"
"fs/gfs2"
"fs/efivarfs"
"fs/hpfs"
"fs/romfs"
"fs/udf"
"fs/dlm"
"fs/jbd2"
"fs/cifs"
"fs/ecryptfs"
"fs/affs"
"fs/9p"
"fs/crypto"
"fs/debugfs"
"fs/fat"
"fs/hfs"
"fs/exportfs"
"fs/fuse"
"fs/nls"
"fs/minix"
"fs/ntfs"
"fs/ceph"
"fs/notify"
"fs/lockd"
"fs/ubifs"
"fs/isofs"
"fs/orangefs"
"fs/hugetlbfs"
"fs/omfs"
"fs/jffs2"
"fs/freevxfs"
"fs/adfs"
"fs/proc"
"fs/nfsd"
"fs/qnx6"
"fs/sysv"
"fs/sysfs"
"fs/bfs"
"fs/xfs"
"fs/exfat"
"fs/efs"
"fs/exofs"
"fs/pstore"
"fs/sdcardfs"
"fs/coda"
"fs/ufs"
"fs/nfs"
"fs/ext2"
"fs/nilfs2"
"fs/nfs_common"
"fs/squashfs"
"fs/hostfs"
"fs/btrfs"
"fs/ramfs"
"fs/jfs"
"fs/overlayfs"
"fs/qnx4"
"fs/reiserfs"
"fs/ext4"
"fs/kernfs"
"include/xen"
"include/video"
"include/memory"
"include/net"
"include/target"
"include/misc"
"include/acpi"
"include/asm-generic"
"include/pcmcia"
"include/soc"
"include/scsi"
"include/drm"
"include/crypto"
"include/sound"
"include/linux"
"include/ras"
"include/vservices"
"include/math-emu"
"include/dt-bindings"
"include/clocksource"
"include/rdma"
"include/keys"
"include/trace"
"include/microvisor"
"include/media"
"include/uapi"
"include/kvm"
"kernel/sched"
"kernel/gcov"
"kernel/dma"
"kernel/livepatch"
"kernel/time"
"kernel/events"
"kernel/rcu"
"kernel/printk"
"kernel/configs"
"kernel/locking"
"kernel/bpf"
"kernel/debug"
"kernel/power"
"kernel/trace"
"kernel/cgroup"
"kernel/irq"
"lib/zlib_inflate"
"lib/reed_solomon"
"lib/zstd"
"lib/lzo"
"lib/fonts"
"lib/zlib_deflate"
"lib/mpi"
"lib/lz4"
"lib/raid6"
"lib/842"
"lib/xz"
"net/appletalk"
"net/kcm"
"net/batman-adv"
"net/sched"
"net/sctp"
"net/lapb"
"net/hsr"
"net/ipv6"
"net/phonet"
"net/bluetooth"
"net/strparser"
"net/8021q"
"net/bpfilter"
"net/can"
"net/wimax"
"net/dns_resolver"
"net/packet"
"net/802"
"net/iucv"
"net/xfrm"
"net/psample"
"net/netlink"
"net/core"
"net/l2tp"
"net/key"
"net/unix"
"net/l3mdev"
"net/bridge"
"net/dccp"
"net/6lowpan"
"net/tipc"
"net/9p"
"net/vmw_vsock"
"net/openvswitch"
"net/ncsi"
"net/ethernet"
"net/qrtr"
"net/rds"
"net/rose"
"net/ceph"
"net/dcb"
"net/ife"
"net/netfilter"
"net/ax25"
"net/netrom"
"net/smc"
"net/mpls"
"net/nsh"
"net/decnet"
"net/bpf"
"net/rxrpc"
"net/mac80211"
"net/x25"
"net/netlabel"
"net/ipv4"
"net/caif"
"net/tls"
"net/rfkill"
"net/dsa"
"net/xdp"
"net/nfc"
"net/wireless"
"net/atm"
"net/mac802154"
"net/sunrpc"
"net/ieee802154"
"net/switchdev"
"net/llc"
"mm"
"security"
"sound/xen"
"sound/x86"
"sound/oss"
"sound/ac97"
"sound/synth"
"sound/mips"
"sound/drivers"
"sound/pcmcia"
"sound/soc"
"sound/arm"
"sound/core"
"sound/sh"
"sound/firewire"
"sound/hda"
"sound/usb"
"sound/i2c"
"sound/pci"
"sound/sparc"
"sound/spi"
"sound/aoa"
"sound/atmel"
"sound/isa"
"sound/ppc"
"sound/parisc"
"scripts/mod"
"scripts/coccinelle"
"scripts/basic"
"scripts/selinux"
"scripts/gcc-plugins"
"scripts/dtc"
"scripts/genksyms"
"scripts/kconfig"
"scripts/package"
"scripts/gdb"
"scripts/ksymoops"
"scripts/tracing"
"security/smack"
"security/tomoyo"
"security/selinux"
"security/loadpin"
"security/apparmor"
"security/integrity"
"security/pfe"
"security/keys"
"security/yama"
"techpack/audio"
"techpack/camera"
"techpack/display"
"techpack/stub"
"techpack/video"
"techpack"
"tools"
".gitignore"
"Android.bp"
)
for ELEMENT in ${DIFFPATHS[@]}; do
[[ -d $ELEMENT ]] && git add $ELEMENT -f >/dev/null 2>&1
git commit -sm "$ELEMENT: import OEM changes" >/dev/null 2>&1
done
echo "Done with subdirectories, now committing rest of the changes"
REMNANTDIRS=(
"arch"
"block"
"certs"
"crypto"
"Documentation"
"drivers"
"firmware"
"fs"
"include"
"init"
"ipc"
"kernel"
"lib"
"LICENSES"
"mm"
"net"
"samples"
"scripts"
"security"
"sound"
"techpack"
"usr"
"virt"
)
for ELEMENT in ${REMNANTDIRS[@]}; do
[[ -d $ELEMENT ]] && git add $ELEMENT -f >/dev/null 2>&1
git commit -sm "$ELEMENT: import rest of the OEM changes" >/dev/null 2>&1
done
git add -- . :!rebase.sh :!out >/dev/null 2>&1
git commit -sm "kernel: import rest of misc OEM changes" >/dev/null 2>&1
echo "Committing End point"
git commit -sm "END OEM IMPORTS" --allow-empty >/dev/null 2>&1
echo "Done with imports!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment