Commit fdaa4a19 authored by Kirill Smelkov's avatar Kirill Smelkov

Rename git() -> ggit()

We are going to use git2go (see next patch) for which canonical import
path is git (import "github.com/libgit2/git2go" results in package name
being autotruncated to just "git") so free up the "git" name for that
package.

Reason is: git() - as function - is used not often, while the package
will be used often.

Regarding naming: not sure it is good choice but ggit() is something
like xgit(), only g is for "GitError".
parent ad6c6853
...@@ -397,7 +397,7 @@ func cmd_pull_(pullspecv []PullSpec) { ...@@ -397,7 +397,7 @@ func cmd_pull_(pullspecv []PullSpec) {
xgit("update-ref", backup_lock, mktree_empty(), Sha1{}) xgit("update-ref", backup_lock, mktree_empty(), Sha1{})
// make sure there is root commit // make sure there is root commit
gerr, _, _ := git("rev-parse", "--verify", "HEAD") gerr, _, _ := ggit("rev-parse", "--verify", "HEAD")
if gerr != nil { if gerr != nil {
infof("# creating root commit") infof("# creating root commit")
// NOTE `git commit` does not work in bare repo - do commit by hand // NOTE `git commit` does not work in bare repo - do commit by hand
...@@ -859,7 +859,7 @@ func cmd_restore_(HEAD_ string, restorespecv []RestoreSpec) { ...@@ -859,7 +859,7 @@ func cmd_restore_(HEAD_ string, restorespecv []RestoreSpec) {
// //
// Compared to fsck we do not re-compute sha1 sum of objects which // Compared to fsck we do not re-compute sha1 sum of objects which
// is significantly faster. // is significantly faster.
gerr, _, _ := git("--git-dir=" + repopath, gerr, _, _ := ggit("--git-dir=" + repopath,
"rev-list", "--objects", "--stdin", "--quiet", RunWith{stdin: repo.refs.Sha1HeadsStr()}) "rev-list", "--objects", "--stdin", "--quiet", RunWith{stdin: repo.refs.Sha1HeadsStr()})
if gerr != nil { if gerr != nil {
fmt.Fprintln(os.Stderr, "E: Problem while checking connectivity of extracted repo:") fmt.Fprintln(os.Stderr, "E: Problem while checking connectivity of extracted repo:")
......
...@@ -101,7 +101,7 @@ func TestPullRestore(t *testing.T) { ...@@ -101,7 +101,7 @@ func TestPullRestore(t *testing.T) {
"7124713e403925bc772cd252b0dec099f3ced9c5", "7124713e403925bc772cd252b0dec099f3ced9c5",
"f735011c9fcece41219729a33f7876cd8791f659"} "f735011c9fcece41219729a33f7876cd8791f659"}
for _, tag := range tags { for _, tag := range tags {
gerr, _, _ := git("cat-file", "-p", tag) gerr, _, _ := ggit("cat-file", "-p", tag)
if gerr == nil { if gerr == nil {
t.Fatalf("tag %s still present in backup.git after git-prune", tag) t.Fatalf("tag %s still present in backup.git after git-prune", tag)
} }
...@@ -112,7 +112,7 @@ func TestPullRestore(t *testing.T) { ...@@ -112,7 +112,7 @@ func TestPullRestore(t *testing.T) {
cmd_restore([]string{"HEAD", "b1:"+work1}) cmd_restore([]string{"HEAD", "b1:"+work1})
// verify files restored to the same as original // verify files restored to the same as original
gerr, diff, _ := git("diff", "--no-index", "--raw", "--exit-code", my1, work1) gerr, diff, _ := ggit("diff", "--no-index", "--raw", "--exit-code", my1, work1)
// 0 - no diff, 1 - has diff, 2 - problem // 0 - no diff, 1 - has diff, 2 - problem
if gerr != nil && gerr.Sys().(syscall.WaitStatus).ExitStatus() > 1 { if gerr != nil && gerr.Sys().(syscall.WaitStatus).ExitStatus() > 1 {
t.Fatal(gerr) t.Fatal(gerr)
......
...@@ -128,7 +128,7 @@ func (e *GitErrContext) Error() string { ...@@ -128,7 +128,7 @@ func (e *GitErrContext) Error() string {
return msg return msg
} }
// argv -> []string, ctx (for passing argv + RunWith handy - see git() for details) // argv -> []string, ctx (for passing argv + RunWith handy - see ggit() for details)
func _gitargv(argv ...interface{}) (argvs []string, ctx RunWith) { func _gitargv(argv ...interface{}) (argvs []string, ctx RunWith) {
ctx_seen := false ctx_seen := false
...@@ -156,11 +156,11 @@ func _gitargv(argv ...interface{}) (argvs []string, ctx RunWith) { ...@@ -156,11 +156,11 @@ func _gitargv(argv ...interface{}) (argvs []string, ctx RunWith) {
// - on other errors - exception is raised // - on other errors - exception is raised
// //
// NOTE err is concrete *GitError, not error // NOTE err is concrete *GitError, not error
func git(argv ...interface{}) (err *GitError, stdout, stderr string) { func ggit(argv ...interface{}) (err *GitError, stdout, stderr string) {
return git2(_gitargv(argv...)) return ggit2(_gitargv(argv...))
} }
func git2(argv []string, ctx RunWith) (err *GitError, stdout, stderr string) { func ggit2(argv []string, ctx RunWith) (err *GitError, stdout, stderr string) {
e, stdout, stderr := _git(argv, ctx) e, stdout, stderr := _git(argv, ctx)
eexec, _ := e.(*exec.ExitError) eexec, _ := e.(*exec.ExitError)
if e != nil && eexec == nil { if e != nil && eexec == nil {
...@@ -179,7 +179,7 @@ func xgit(argv ...interface{}) string { ...@@ -179,7 +179,7 @@ func xgit(argv ...interface{}) string {
} }
func xgit2(argv []string, ctx RunWith) string { func xgit2(argv []string, ctx RunWith) string {
gerr, stdout, _ := git2(argv, ctx) gerr, stdout, _ := ggit2(argv, ctx)
if gerr != nil { if gerr != nil {
raise(gerr) raise(gerr)
} }
...@@ -203,7 +203,7 @@ func (e *GitSha1Error) Error() string { ...@@ -203,7 +203,7 @@ func (e *GitSha1Error) Error() string {
} }
func xgit2Sha1(argv []string, ctx RunWith) Sha1 { func xgit2Sha1(argv []string, ctx RunWith) Sha1 {
gerr, stdout, stderr := git2(argv, ctx) gerr, stdout, stderr := ggit2(argv, ctx)
if gerr != nil { if gerr != nil {
raise(gerr) raise(gerr)
} }
......
...@@ -42,7 +42,7 @@ type Tag struct { ...@@ -42,7 +42,7 @@ type Tag struct {
// reencode commit message and otherwise heavily rely on rev-list traversal // reencode commit message and otherwise heavily rely on rev-list traversal
// machinery -> so we decode commit by hand in a plumbing way. // machinery -> so we decode commit by hand in a plumbing way.
func xload_commit(commit_sha1 Sha1) (commit *Commit, commit_raw string) { func xload_commit(commit_sha1 Sha1) (commit *Commit, commit_raw string) {
gerr, commit_raw, _ := git("cat-file", "commit", commit_sha1, RunWith{raw: true}) gerr, commit_raw, _ := ggit("cat-file", "commit", commit_sha1, RunWith{raw: true})
if gerr != nil { if gerr != nil {
raise(&CommitLoadError{commit_sha1, gerr}) raise(&CommitLoadError{commit_sha1, gerr})
} }
...@@ -94,7 +94,7 @@ func commit_parse(commit_raw string) (*Commit, error) { ...@@ -94,7 +94,7 @@ func commit_parse(commit_raw string) (*Commit, error) {
// load/parse Tag // load/parse Tag
func xload_tag(tag_sha1 Sha1) (tag *Tag, tag_raw string) { func xload_tag(tag_sha1 Sha1) (tag *Tag, tag_raw string) {
gerr, tag_raw, _ := git("cat-file", "tag", tag_sha1, RunWith{raw: true}) gerr, tag_raw, _ := ggit("cat-file", "tag", tag_sha1, RunWith{raw: true})
if gerr != nil { if gerr != nil {
raise(&TagLoadError{tag_sha1, gerr}) raise(&TagLoadError{tag_sha1, gerr})
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment