Git は普通に Gir for Windows をダウンロードしてインストールする(ここは別に小細工はない)
.vimrc の設定
コミット時の文字コードを UTF8 にする
au! FileType gitcommit setl fenc=utf-8
.nyagos の設定
git.exe のあるフォルダーを %PATH% に追加
local function addpath(s) if nyagos.stat(s) and not string.find(string.upper(nyagos.env.path),string.upper(s)) then nyagos.env.path = string.gsub(nyagos.env.path..";"..s,";;",";") end end addpath "C:\\Program Files\\Git\\bin" addpath "C:\\Program Files\\Git\\cmd" addpath "C:\\Program Files (x86)\\Git\\bin" addpath "C:\\Program Files (x86)\\Git\\cmd"
32bit/64bit のフォルダーの両方を確認するようにしてる。フォルダーがなければ追加しない。二重追加もしない。俺えらい
ページャ・エディターを指定
nyagos.env.git_pager="cure.exe" nyagos.env.git_editor="gvim.exe"
cure.exe は自作のカラーページャ。 メッセージに UTF8 と SJIS が混ざっても、文字化けしないようになっている (行単位で文字コード判定をしている)
「git diff
を見やすくするためだけに作った」といっても過言ではない
git のサブコマンドの補完
nyagos.complete_for.git = function(args) while #args > 2 and args[2]:sub(1,1) == "-" do table.remove(args,2) end if #args == 2 then return nyagos.fields([[ add fsck-objects rebase add--interactive gc receive-pack am get-tar-commit-id reflog annotate grep relink apply gui remote archimport gui--askpass remote-ext archive gui--askyesno remote-fd bisect gui.tcl remote-ftp bisect--helper hash-object remote-ftps blame help remote-http branch http-backend remote-https bundle http-fetch repack cat-file http-push replace check-attr imap-send request-pull check-ignore index-pack rerere check-mailmap init reset check-ref-format init-db rev-list checkout instaweb rev-parse checkout-index interpret-trailers revert cherry log rm cherry-pick ls-files send-email citool ls-remote send-pack clean ls-tree sh-i18n--envsubst clone mailinfo shortlog column mailsplit show commit merge show-branch commit-tree merge-base show-index config merge-file show-ref count-objects merge-index stage credential merge-octopus stash credential-manager merge-one-file status credential-store merge-ours stripspace credential-wincred merge-recursive submodule cvsexportcommit merge-resolve submodule--helper cvsimport merge-subtree subtree cvsserver merge-tree svn daemon mergetool symbolic-ref describe mktag tag diff mktree unpack-file diff-files mv unpack-objects diff-index name-rev update-index diff-tree notes update-ref difftool p4 update-server-info difftool--helper pack-objects upload-archive fast-export pack-redundant upload-pack fast-import pack-refs var fetch patch-id verify-commit fetch-pack prune verify-pack filter-branch prune-packed verify-tag fmt-merge-msg pull web--browse for-each-ref push whatchanged format-patch quiltimport worktree fsck read-tree write-tree]]) end if args[#args]:sub(1,1) == "-" then if args[2] == "commit" then return { "--amend" , "-a" , "--cleanup","--dry-run" } end end return nil end
nyagos.d/catalog にあるものと違って、サブコマンドをコード中に直接埋め込んでいるので起動が早い。
git 向けの拡張サブコマンドを用意する
下記のようなテキストファイル:git-new
(拡張子無しの sh スクリプト)を %PATH% の通ったフォルダーに入れておく。git new
でレポジトリの初期設定をしてくれる。
(Windows 上ではあるが、git は MSYS 上で動くので、バッチファイルだと拡張子がひっかかって逆に動かんのだ)
git init
の後に、空コミットを一つ入れる(後から rebase しやすい)- 改行コードの自動変換機能をオフする
.gitattributes
を登録 *commit 時のユーザ名・メールアドレスを設定 - 日本語フォルダー名を化けさせない
#!/bin/sh if [ ! -e .git ] ; then git init git commit -m "empty" --allow-empty fi if [ ! -e .gitattributes ] ; then echo "* -text" > .gitattributes git add .gitattributes git commit -m "Add .gitattributes as autocrlf=false" fi git config --local core.quotepath false git config --local user.email iyahaya@example.com git config --local user.name zetamatta
たぶん、だいたい以上