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 -e '/^[iI]ndex/s/^index.*/=====================================================================/' -e '/^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 -r --name-status --pretty=format:"%Cgreen%s %CblueSHA1: %H%Creset" $*
You can also do it like this:
alias git-diff-tree -r --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 阅读(262)
评论(0) 编辑 收藏