英汇 TopGit 改进(1): tg push 全部分支TopGit 的项目名称是来自于 Topic Git 的简写,是用于管理多个 Git 的特性分支的工具。如果您对 Hg 的 MQ 有所了解的话,我可以告诉你,TopGit 是用Git 维护补丁列表的工具;TopGit 就是 MQ 在 Git 中的等价物,而且做的更好。
1.什么是 TopGit?参见TopGit 手册
2.TopGit 代码库:/w/topgit.git
英汇终于决定采用 Git 作为公司内部的代码管理工具,就是因为我们发现了TopGit。参见:《英汇版本控制系统的选择:subversion, hg, git》。
在每日的使用过程中,我们也发现了 TopGit 的一些问题,不断的挠到我们的痒处。遵循ESR的理论,我们决定对 TopGit 进行改进,于是就有了我们在 Github 上的 TopGit 版本库:github/ossxp-com/topgit
最近,我又感觉到 TopGit 一个不便利的地方,今天终于临时决定 Hack。Hack 结束之后,就有了写一个系列文章的想法,于是这个系列文章,就从今天这个最新的 Hack 写起。
为 tg push 命令增加 –all 参数
我之前的一篇文章:《Git 如何拆除核弹起爆码,以及 topgit 0.7到0.8的变迁》,曾经提到过,TopGit 0.7 到 0.8 的一个非常大的改变,就是取消了
在 .git/config 中的强制 non-fast-forward 更新的 push 参数。
在 TopGit 0.7 以及之前的版本,可以通过执行一个简单的git push命令,就可以将所有的 TopGit 分支以及相关的 top-bases 分支 PUSH 到服务器上。
但是 TopGit 0.8 版本之后,不再向 .git/config 中添加相关 PUSH 指令,因为强制 non-fast-forward 的 PUSH 会导致多人协同工作时,互相覆盖对方改动!!!但是这么做的结果,也就失去了使用 git push 向远程服务器同步 TopGit 分支的便利。
TopGit 0.8 版本提供了一个新命令tg push,用于向服务器 PUSH TopGit 分支以及关联的 top-bases 分支。这样,就弥补了不能再使用 git push 和服务器同步 TopGit 以及 top-bases 分支的遗憾了。
一个让人痒痒的问题产生了:
•tg push 只能 push 当前工作的 TopGit 分支;
•或者 tg push 后面加上各个分支的名字,实现对分支的 PUSH
•但是 tg push 没有一个 –all 选项,必须一个一个的将需要 PUSH 的 tg 分支罗列出来
•我们有的项目的分支有上百个!!!如果改动的多的话,要一个一个切换或者一个一个写在命令行中,太恐怖了。
问题的解决:
•增加了对 -a 以及 –all 参数的支持
•如果用户没有指定分支,并且提供了-a | –all 参数,则将当前所有 topgit 分支加入同步的分支列表中
•创建新的分支,开始写代码:
•$ tg create t/tg_push_all tgmaster
•tg: Creating t/tg_push_all base •Switched to a new branch 't/tg_push_all'
•tg: Topic branch t/tg_push_all set up. Please fill .topmsg now and make initial commit.
•tg: To abort: git rm -f .top* && git checkout tgmaster && tg delete t/tg_push_all
•# Hack, Hack,
•# Test, Test,
•$ git st
•# On branch t/tg_push_all
•# Changes to be committed:
•#  (use "git reset HEAD <file>..." to unstage)
•#
•#      new file:  .topdeps
•#      new file:  .topmsg
•#
•# Changed but not updated:
•#  (use "git add <file>..." to update what will be committed)
•#  (use "git checkout -- <file>..." to discard changes in working directory)
•#
•#      modified:  .topmsg
•#      modified:  tg-push.sh
•#
•$ git ci -a -m "add --all option support to tg_push"
•[t/tg_push_all 7df16a5] add --all option support to tg_push
•    3 files changed, 22 insertions(+), 1 deletions(-)
• create mode 100644 .topdeps
create mode 100644 .topmsg
切换到 master (debian) 分支,编译新
•的英汇软件包topgit+,并安装
$
•git co master
•$ git br
* master
• t/debian_locations
• t/export_quilt_all
• t/fast_tg_summary
• t/tg_completion_bugfix
• t/tg_patch_cdup
• t/tg_push_all
• tgmaster
•$ make -f debian/rules  debian/patches
rm -rf deb
•ian/patches
•tg export --quilt --all debian/patches
•Exporting t/debian_locations
•Exporting t/export_quilt_all
•Exporting t/fast_tg_summary
•Exporting t/tg_completion_bugfix
•Exporting t/tg_patch_cdup
•Exporting t/tg_push_all
•Exported topic branch  (total 6 topics) to directory debian/patches
•$ git st
•# On branch master
# Changed but
• not updated:
shell代码
•#  (use "git add <file>..." to update what will be committed)
•#  (use "git checkout -- <file>..." to discard changes in working directory)
•#
#      mo
•dified:  debian/patches/series
•#
# Untracked files:
•#  (use "git add <file>..." to include in what will be committed)
•#
•#      debian/patches/t/tg_push_all.diff
•no changes added to commit (use "git add" and/or "git commit -a")
•$ git add debian/patches/t/tg_patch_all.diff
•$ vi debian/changelog
edit, edit,
•$ head -5 debian/changelog
topgit (0.8-1+ossxp7) unstable; urgency=low
• * add --all support to tg patch.
• -- Jiang Xin <jiangxin@ossxp>
git ci -a -m "new patch: add --all option support to tg_push."•$
•[master c927b02] new patch: add --all option support to tg_push.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。