add SWAP macro
commit568edcb95a8b86ffd0d267b124896df8ea81307c
authorRené Scharfe <l.s.r@web.de>
Sat, 28 Jan 2017 21:38:21 +0000 (28 22:38 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Jan 2017 22:07:45 +0000 (30 14:07 -0800)
treee0701b31ed1e8e7d0a628757d84cd7f236060654
parent4e59582ff70d299f5a88449891e78d15b4b3fabe
add SWAP macro

Add a macro for exchanging the values of variables.  It allows users
to avoid repetition and takes care of the temporary variable for them.
It also makes sure that the storage sizes of its two parameters are the
same.  Its memcpy(1) calls are optimized away by current compilers.

Also add a conservative semantic patch for transforming only swaps of
variables of the same type.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/swap.cocci [new file with mode: 0644]
git-compat-util.h