Reviewing moved files with git

This might be a well-known trick already, but just in case it’s not…

Reviewing a patch can be a bit painful when a file that has been changed and moved or renamed at one go (and there can be perfectly valid reasons for doing this). A nice thing about git is that you can reference files in an arbitrary tree while using git diff, so reviewing such changes can become easier if you do something like this:

$ git am 0001-the-thing-I-need-to-review.patch
$ git diff HEAD^:old/path/to/file.c new/path/to/file.c

This just references file.c in its old path, which is available in the commit before HEAD, and compares it to the file at the new path in the patch you just merged.

Of course, you can also use this to diff a file at some arbitrary point in the past, or in some arbitrary branch, with the same file at the current HEAD or any other point.

Hopefully this is helpful to someone out there!

Update: As Alex Elsayed points out in the comments, git diff -M/-C can be used to similar effect. The above example, for example, could be written as:

$ git am 0001-the-thing-I-need-to-review.patch
$ git show -C

C# is killing me

Blame for this:

static inline uint64_t get_ts()
    uint32_t low, high;
        : “=a” (low),
          “=d” (high));
    ts = high;
    return ((uint64_t)high << 32) + low;

/* From kernel sources: include/asm-i386/processor.h / / * Generic CPUID function * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx * resulting in stale register contents being returned. / inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, \ unsigned int *ecx, unsigned int *edx) { asm(“cpuid” : “=a” (eax), “=b” (ebx), “=c” (ecx), “=d” (*edx) : “0” (op), “c”(0)); }

/* Count the number of physical processor cores */ inline uint32_t get_num_cores() { uint32_t eax, ebx, ecx, edx;

/* figure out whether querying core count is allowed */
cpuid(0, &eax, &ebx, &ecx, &edx);

if (eax >= 4) {
    cpuid(4, &eax, &ebx, &ecx, &edx);
    eax = ((eax & 0xFC000000) >> 26) + 1;
    eax = 1;

return eax;


/* To figure out which CPU you’re on */ inline uint32_t get_apic_id() { uint32_t eax, ebx, ecx, edx; cpuid(1, &eax, &ebx, &ecx, &edx); return (ebx >> 24); }

And to all the non-geeks out there … sorry. :-)