{"id":14000,"date":"2024-07-12T17:03:21","date_gmt":"2024-07-12T09:03:21","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=14000"},"modified":"2024-07-24T13:37:51","modified_gmt":"2024-07-24T05:37:51","slug":"git-diff-%e5%b7%a6%e4%be%a7%e6%98%be%e7%a4%ba%e8%a1%8c%e5%8f%b7","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=14000","title":{"rendered":"git diff \u5de6\u4fa7\u663e\u793a\u884c\u53f7"},"content":{"rendered":"<p><a href=\"https:\/\/blog.csdn.net\/TAlice\/article\/details\/117533318\">https:\/\/blog.csdn.net\/TAlice\/article\/details\/117533318<\/a><\/p>\n<pre><code class=\"language-bash\">#!\/bin\/bash\ndiff-lines() {\n        local path=\n        local pathOld=\n        local line=\n        while read; do\n                esc=$&#039;\\033&#039;\n                if [[ $REPLY =~ ---\\ (a\/)?.* ]]; then\n                        continue\n                elif [[ $REPLY =~ \\+\\+\\+\\ (b\/)?([^[:blank:]$esc]+).* ]]; then\n                        path=${BASH_REMATCH[2]}     #\u83b7\u53d6\u6587\u4ef6\u8def\u5f84\n                elif [[ $REPLY =~ @@\\ -[0-9]+(,[0-9]+)?\\ \\+([0-9]+)(,[0-9]+)?\\ @@.* ]]; then\n                        line=${BASH_REMATCH[2]}     #\u83b7\u53d6\u6dfb\u52a0\/\u5220\u9664\/\u4fee\u6539\u7684\u884c\n                elif [[ $REPLY =~ ^($esc\\[[0-9;]+m)*([\\ +-]) ]]; then\n\n                        if [ &quot;$path&quot; != &quot;$pathOld&quot; ]; then\n                                echo -e &quot;\\n\\n$path:$line:$REPLY&quot;  #\u4e0d\u540c\u6587\u4ef6\u95f4\u7684\u4fee\u6539\u7528\u6362\u884c\u9694\u5f00\n                        else\n                                echo &quot;$path:$line:$REPLY&quot;\n                        fi\n\n                        if [[ ${BASH_REMATCH[2]} != - ]]; then\n                                ((line++))\n                        fi\n                        pathOld=$path\n                fi\n        done\n}\n\nif [ &quot;$1&quot; != &quot;&quot; ]; then     #\u53ef\u67e5\u770b\u5355\u4e2a\u6587\u4ef6\u7684\u5dee\u5f02\uff08\u65b9\u6cd5\uff1agit-diff-lines  xxx.c\uff09\n        git diff -U0 --color=always --  &quot;$1&quot; | diff-lines\nelse\n        git diff -U0 --color=always | diff-lines\nfi\n<\/code><\/pre>\n<button class=\"simplefavorite-button\" data-postid=\"14000\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/blog.csdn.net\/TAlice\/article\/details\/11753 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1066],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14000"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14000"}],"version-history":[{"count":1,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14000\/revisions"}],"predecessor-version":[{"id":14001,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/14000\/revisions\/14001"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14000"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}