Teaching -p to svn diff

From Xenomai
Jump to: navigation, search

The subversion command line tool does not support the "--show-c-function" option ("-p") of diff natively. But this format makes patches far more readable. To configure svn to generate such diffs by default, a few steps have to be taken:

  • Edit ~/.subversion/config so that it additionally contains these two lines:
[helpers]
diff-cmd = /usr/local/bin/_svndiff
  • Create /usr/local/bin/_svndiff as an executable file with this content
# SVN version 1.5 and better
if [ $# == 7 ]; then
	shift;
fi
/usr/bin/diff -up --label "${2}" "${5}" --label "${4}" "${6}"

# SVN version <1.5
# /usr/bin/diff -up --label "${3}" "${6}" --label "${5}" "${7}"

Now every svn diff you issue under your account will be of the annotated patch format.

Some example for reference:

Index: ksrc/drivers/can/rtcan_socket.h
===================================================================
--- ksrc/drivers/can/rtcan_socket.h     (Revision 1834)
+++ ksrc/drivers/can/rtcan_socket.h     (working copy)
@@ -167,6 +167,10 @@ struct rtcan_socket {
     uint32_t            rx_buf_full;

     struct rtcan_filter_list *flist;
+
+#ifdef CONFIG_XENO_DRIVERS_RTCAN_TX_LOOPBACK
+    int tx_loopback;
+#endif
 };
 
 
Personal tools
Hardware Support