隨筆-11  評論-10  文章-8  trackbacks-0
          Fist one, I call it git2svn. We know 'git diff' has the format like this:
          diff --git a/hello.git b/hello.git
          index 808c280..3e60fff 
          100644
          --- a/hello.git
          +++ b/hello.git
          @@ 
          -1,2 +1,3 @@
           
          111111
           sdfsfsdf
          +111

          It's different with svn diff output format which we are familiar with, although patch can work with this format, but it would be strange if we applied a patch with git format to a open source project which use SVN as source repository. That's why i wrote git2svn, which convert git diff format to svn diff format. It's very very simple, only one line:
          #! /bin/sh

          # convert git diff output to svn format:
          # git diff like:
          #
          # diff 
          --git a/hello.git b/hello.git
          # index 90d2950..808c280 
          100644
          --- a/hello.git
          +++ b/hello.git
          #
          # after converting, it
          's our familiar svn diff format
          #
          # Index: hello.git
          =====================================================================
          --- hello.git
          +++ hello.git
          #
          # It
          's useful to apply patch to project using svn as their repository and
          # you use git for your local work

          sed 
          -'/^[iI]ndex/s/^index.*/=====================================================================/' -'/^diff/s/^diff --g\
          it a\//Index: /' -e '/^Index:/s/ b\/.*//' -e '/^--- a\//s/--- a\//--- /' -e '/^+++ b\//s/+++ b\//+++ /' $*

          Another, can't call it as 'tool' exactly, I think, just a convenient way or shortcut to query which files are changed in one or between two commits and their status, like 'svn diff --summarize':
          #! /bin/sh

          #summary changed files which status, in one commit or between two commits

          git
          -diff-tree ---name-status --pretty=format:"%Cgreen%s    %CblueSHA1: %H%Creset" $*

          You can also do it like this:
          alias git-diff-tree ---name-status --pretty=format:"%Cgreen%s    %CblueSHA1: %H%Creset" git-changed-files
          and add this line to your $HOME/.bashrc

          posted on 2008-05-27 00:57 JBahamut 閱讀(274) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 保山市| 汉中市| 枣庄市| 多伦县| 枣强县| 同德县| 津市市| 宽城| 墨玉县| 福州市| 广丰县| 南华县| 明星| 辽阳市| 德保县| 石门县| 聊城市| 贺州市| 宁化县| 丹东市| 桦甸市| 荃湾区| 江安县| 醴陵市| 楚雄市| 滁州市| 双江| 乐业县| 杭州市| 永德县| 大连市| 耒阳市| 阿拉尔市| 金昌市| 鸡泽县| 冷水江市| 察哈| 衡水市| 许昌县| 洪雅县| 乐业县|