Ivan Morgillo
Ivan Morgillo

Reputation: 3844

git - Track Linux Kernel .config file

Is there a comfortable way to track kernel .config file? Every time I run make menuconfig, .config is edited and it changes even if I do not change any value.

When I perform a diff, .config seems different, but it has just messed up with lines:

same lines, but at different position

From a make point of view, that's the same file. From a git point of view it's a completely different file, with tons of new/edited lines to be committed.

I feel as I'm missing something. It should be a proper way to track a .config file :)

Thank you

Upvotes: 4

Views: 1135

Answers (2)

Jonas Stein
Jonas Stein

Reputation: 7043

I have created a .git/hooks/pre-commit file containing

#!/bin/sh
uname -a > uname.log
lspci -k > lspci.log
grep -e "^#" -v .config | sort > .config.sorted

You can git add .config.sorted and compare it with diff. The two log files keep track of changes in the system. Additionaly one may use /usr/src/linux/scripts/diffconfig .config .anotherconfig for comparisation.

Upvotes: 0

Michal Kottman
Michal Kottman

Reputation: 16753

A stupid (but simple) way to always diff only missing/added lines (not lines placed elsewhere) would be sort the .config file before comparing and adding to repository, and having a "base" sorted .config to compare with.

Note that this will store all the whitespace and empty comment lines a the beginning, but will keep the (un)commented lines at their relevant places. This is an example of my .config:

$ sort /boot/config-2.6.35-24-generic
...
CONFIG_TRACING=y
CONFIG_TRANZPORT=m
# CONFIG_TREE_PREEMPT_RCU is not set
# CONFIG_TREE_RCU_TRACE is not set
CONFIG_TREE_RCU=y
CONFIG_TR=y
CONFIG_TTPCI_EEPROM=m
CONFIG_TULIP=m
# CONFIG_TULIP_MMIO is not set
# CONFIG_TULIP_MWI is not set
# CONFIG_TULIP_NAPI is not set
CONFIG_TUN=y
...

Upvotes: 1

Related Questions