隨筆-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 閱讀(271) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 古浪县| 平果县| 濮阳市| 天镇县| 汪清县| 栖霞市| 南靖县| 日土县| 庆元县| 陆丰市| 康乐县| 方正县| 福州市| 即墨市| 贡嘎县| 读书| 东山县| 济源市| 恩施市| 神农架林区| 镇巴县| 盐山县| 丰宁| 息烽县| 瑞昌市| 莆田市| 兴城市| 格尔木市| 纳雍县| 开化县| 修文县| 淮安市| 天柱县| 凤城市| 沙坪坝区| 新巴尔虎左旗| 玛沁县| 翁牛特旗| 平舆县| 普宁市| 镇远县|