使用-u选项,产生unified格式的patch,默认的格式是normal格式:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | $ diff -u a/lib/route/route.c  b/lib/route/route.c--- a/lib/route/route.c      2017-08-18 21:09:44.000000000 +0800+++ b/lib/route/route.c  2019-08-31 15:15:08.106681703 +0800@@ -24,6 +24,7 @@ #include <netlink/route/rtnl.h> #include <netlink/route/route.h> #include <netlink/route/link.h>+#include <netlink/hashtable.h> static struct nl_cache_ops rtnl_route_ops;@@ -89,6 +90,13 @@        cache->c_iarg1 = family;        cache->c_iarg2 = flags;+       /* skip the hash table of route table.+               it has problem that will filter some route entry out+               with same compare attributes+        */+       nl_hash_table_free(cache->hashtable);+       cache->hashtable = NULL;+        if (sk && (err = nl_cache_refill(sk, cache)) < 0) {                free(cache);                return err; |