Commit f3f694b9 authored by Kirill Smelkov's avatar Kirill Smelkov

~gofmt

parent cc6ac54f
...@@ -515,11 +515,10 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) { ...@@ -515,11 +515,10 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
// NOTE repo name is escaped as it can contain e.g. spaces, and refs must not // NOTE repo name is escaped as it can contain e.g. spaces, and refs must not
path_refescape(reprefix(dir, prefix, path)) path_refescape(reprefix(dir, prefix, path))
for _, ref := range refv { for _, ref := range refv {
err = mkref(gb, reporefprefix + "/" + ref.name, ref.sha1) err = mkref(gb, reporefprefix+"/"+ref.name, ref.sha1)
exc.Raiseif(err) exc.Raiseif(err)
} }
// XXX do we want to do full fsck of source git repo on pull as well ? // XXX do we want to do full fsck of source git repo on pull as well ?
return nil return nil
...@@ -605,7 +604,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) { ...@@ -605,7 +604,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
// index is ready - prepare tree and commit // index is ready - prepare tree and commit
backup_tree_sha1 := xgitSha1("write-tree") backup_tree_sha1 := xgitSha1("write-tree")
commit_sha1 := xcommit_tree(gb, backup_tree_sha1, append([]Sha1{HEAD}, backup_refs_parentv...), commit_sha1 := xcommit_tree(gb, backup_tree_sha1, append([]Sha1{HEAD}, backup_refs_parentv...),
"Git-backup " + backup_time) "Git-backup "+backup_time)
xgit("update-ref", "-m", "git-backup pull", "HEAD", commit_sha1, HEAD) xgit("update-ref", "-m", "git-backup pull", "HEAD", commit_sha1, HEAD)
...@@ -637,7 +636,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) { ...@@ -637,7 +636,7 @@ func cmd_pull_(gb *git.Repository, pullspecv []PullSpec) {
// //
// -> what to do is described nearby fetch/mkref call. // -> what to do is described nearby fetch/mkref call.
gitdir := xgit("rev-parse", "--git-dir") gitdir := xgit("rev-parse", "--git-dir")
err = os.RemoveAll(gitdir+"/"+backup_refs_work) err = os.RemoveAll(gitdir + "/" + backup_refs_work)
exc.Raiseif(err) // NOTE err is nil if path does not exist exc.Raiseif(err) // NOTE err is nil if path does not exist
// if we have working copy - update it // if we have working copy - update it
...@@ -720,9 +719,9 @@ func fetch(repo string, alreadyHave Sha1Set) (refv, fetchedv []Ref, err error) { ...@@ -720,9 +719,9 @@ func fetch(repo string, alreadyHave Sha1Set) (refv, fetchedv []Ref, err error) {
// force upload-pack to allow us asking any sha1 we want. // force upload-pack to allow us asking any sha1 we want.
// needed because advertised refs we got at lsremote time could have changed. // needed because advertised refs we got at lsremote time could have changed.
"--upload-pack=git -c uploadpack.allowAnySHA1InWant=true" + "--upload-pack=git -c uploadpack.allowAnySHA1InWant=true"+
// workarounds for git < 2.11.1, which does not have uploadpack.allowAnySHA1InWant: // workarounds for git < 2.11.1, which does not have uploadpack.allowAnySHA1InWant:
" -c uploadpack.allowTipSHA1InWant=true -c uploadpack.allowReachableSHA1InWant=true" + " -c uploadpack.allowTipSHA1InWant=true -c uploadpack.allowReachableSHA1InWant=true"+
// //
" upload-pack", " upload-pack",
...@@ -931,7 +930,7 @@ func (br ByRepoPath) Less(i, j int) bool { return strings.Compare(br[i].repopath ...@@ -931,7 +930,7 @@ func (br ByRepoPath) Less(i, j int) bool { return strings.Compare(br[i].repopath
// also for searching sorted []BackupRepo by repopath prefix // also for searching sorted []BackupRepo by repopath prefix
func (br ByRepoPath) Search(prefix string) int { func (br ByRepoPath) Search(prefix string) int {
return sort.Search(len(br), func (i int) bool { return sort.Search(len(br), func(i int) bool {
return strings.Compare(br[i].repopath, prefix) >= 0 return strings.Compare(br[i].repopath, prefix) >= 0
}) })
} }
...@@ -1093,7 +1092,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec) ...@@ -1093,7 +1092,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec)
xgit2(pack_argv, RunWith{stdin: p.refs.Sha1HeadsStr(), stderr: gitprogress()}) xgit2(pack_argv, RunWith{stdin: p.refs.Sha1HeadsStr(), stderr: gitprogress()})
// verify that extracted repo refs match backup.refs index after extraction // verify that extracted repo refs match backup.refs index after extraction
x_ref_list := xgit("--git-dir=" + p.repopath, x_ref_list := xgit("--git-dir="+p.repopath,
"for-each-ref", "--format=%(objectname) %(refname)") "for-each-ref", "--format=%(objectname) %(refname)")
repo_refs := p.refs.Values() repo_refs := p.refs.Values()
sort.Sort(ByRefname(repo_refs)) sort.Sort(ByRefname(repo_refs))
...@@ -1115,7 +1114,7 @@ func cmd_restore_(gb *git.Repository, HEAD_ string, restorespecv []RestoreSpec) ...@@ -1115,7 +1114,7 @@ func cmd_restore_(gb *git.Repository, 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, _, _ := ggit("--git-dir=" + p.repopath, gerr, _, _ := ggit("--git-dir="+p.repopath,
"rev-list", "--objects", "--stdin", "--quiet", RunWith{stdin: p.refs.Sha1HeadsStr()}) "rev-list", "--objects", "--stdin", "--quiet", RunWith{stdin: p.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:")
......
...@@ -118,15 +118,15 @@ func TestPullRestore(t *testing.T) { ...@@ -118,15 +118,15 @@ func TestPullRestore(t *testing.T) {
// pull from testdata // pull from testdata
my0 := mydir + "/testdata/0" my0 := mydir + "/testdata/0"
cmd_pull(gb, []string{my0+":b0"}) // only empty repo in testdata/0 cmd_pull(gb, []string{my0 + ":b0"}) // only empty repo in testdata/0
my1 := mydir + "/testdata/1" my1 := mydir + "/testdata/1"
cmd_pull(gb, []string{my1+":b1"}) cmd_pull(gb, []string{my1 + ":b1"})
// verify tag/tree/blob encoding is 1) consistent and 2) always the same. // verify tag/tree/blob encoding is 1) consistent and 2) always the same.
// we need it be always the same so different git-backup versions can // we need it be always the same so different git-backup versions can
// interoperate with each other. // interoperate with each other.
var noncommitv = []struct{ var noncommitv = []struct {
sha1 Sha1 // original sha1 Sha1 // original
sha1_ Sha1 // encoded sha1_ Sha1 // encoded
istag bool // is original object a tag object istag bool // is original object a tag object
...@@ -206,7 +206,7 @@ func TestPullRestore(t *testing.T) { ...@@ -206,7 +206,7 @@ func TestPullRestore(t *testing.T) {
// pull again - it should be noop // pull again - it should be noop
h1 := xgitSha1("rev-parse", "HEAD") h1 := xgitSha1("rev-parse", "HEAD")
cmd_pull(gb, []string{my1+":b1"}) cmd_pull(gb, []string{my1 + ":b1"})
afterPull() afterPull()
h2 := xgitSha1("rev-parse", "HEAD") h2 := xgitSha1("rev-parse", "HEAD")
if h1 == h2 { if h1 == h2 {
...@@ -220,7 +220,7 @@ func TestPullRestore(t *testing.T) { ...@@ -220,7 +220,7 @@ func TestPullRestore(t *testing.T) {
// restore backup // restore backup
work1 := workdir + "/1" work1 := workdir + "/1"
cmd_restore(gb, []string{"HEAD", "b1:"+work1}) cmd_restore(gb, []string{"HEAD", "b1:" + work1})
// verify files restored to the same as original // verify files restored to the same as original
gerr, diff, _ := ggit("diff", "--no-index", "--raw", "--exit-code", my1, work1) gerr, diff, _ := ggit("diff", "--no-index", "--raw", "--exit-code", my1, work1)
...@@ -262,12 +262,12 @@ func TestPullRestore(t *testing.T) { ...@@ -262,12 +262,12 @@ func TestPullRestore(t *testing.T) {
for _, repo := range R { for _, repo := range R {
// fsck just in case // fsck just in case
xgit("--git-dir=" + repo.path, "fsck") xgit("--git-dir="+repo.path, "fsck")
// NOTE for-each-ref sorts output by refname // NOTE for-each-ref sorts output by refname
repo.reflist = xgit("--git-dir=" + repo.path, "for-each-ref") repo.reflist = xgit("--git-dir="+repo.path, "for-each-ref")
// NOTE rev-list emits objects in reverse chronological order, // NOTE rev-list emits objects in reverse chronological order,
// starting from refs roots which are also ordered by refname // starting from refs roots which are also ordered by refname
repo.revlist = xgit("--git-dir=" + repo.path, "rev-list", "--all", "--objects") repo.revlist = xgit("--git-dir="+repo.path, "rev-list", "--all", "--objects")
} }
if R[0].reflist != R[1].reflist { if R[0].reflist != R[1].reflist {
...@@ -296,7 +296,7 @@ func TestPullRestore(t *testing.T) { ...@@ -296,7 +296,7 @@ func TestPullRestore(t *testing.T) {
xgit("update-ref", "-d", "refs/backup.locked") xgit("update-ref", "-d", "refs/backup.locked")
}) })
cmd_pull(gb, []string{my2+":b2"}) cmd_pull(gb, []string{my2 + ":b2"})
t.Fatal("pull corrupt.git: did not complain") t.Fatal("pull corrupt.git: did not complain")
}() }()
...@@ -336,7 +336,7 @@ func TestPullRestore(t *testing.T) { ...@@ -336,7 +336,7 @@ func TestPullRestore(t *testing.T) {
err = os.Setenv("HOME", my3+"/incomplete-send-pack.git/"+kind) err = os.Setenv("HOME", my3+"/incomplete-send-pack.git/"+kind)
exc.Raiseif(err) exc.Raiseif(err)
cmd_pull(gb, []string{my3+":b3"}) cmd_pull(gb, []string{my3 + ":b3"})
t.Fatalf("pull incomplete-send-pack.git/%s: did not complain", kind) t.Fatalf("pull incomplete-send-pack.git/%s: did not complain", kind)
} }
...@@ -353,7 +353,7 @@ func TestPullRestore(t *testing.T) { ...@@ -353,7 +353,7 @@ func TestPullRestore(t *testing.T) {
// pulling incomplete-send-pack.git without pack-objects hook must succeed: // pulling incomplete-send-pack.git without pack-objects hook must succeed:
// without $HOME tweaks full and complete pack is sent. // without $HOME tweaks full and complete pack is sent.
cmd_pull(gb, []string{my3+":b3"}) cmd_pull(gb, []string{my3 + ":b3"})
} }
func TestRepoRefSplit(t *testing.T) { func TestRepoRefSplit(t *testing.T) {
......
...@@ -180,7 +180,7 @@ type AuthorInfo git.Signature ...@@ -180,7 +180,7 @@ type AuthorInfo git.Signature
func (ai *AuthorInfo) String() string { func (ai *AuthorInfo) String() string {
_, toffset := ai.When.Zone() _, toffset := ai.When.Zone()
// offset: Git wants in minutes, .Zone() gives in seconds // offset: Git wants in minutes, .Zone() gives in seconds
return fmt.Sprintf("%s <%s> %d %+05d", ai.Name, ai.Email, ai.When.Unix(), toffset / 60) return fmt.Sprintf("%s <%s> %d %+05d", ai.Name, ai.Email, ai.When.Unix(), toffset/60)
} }
var ( var (
......
...@@ -161,7 +161,7 @@ func path_refunescape(s string) (string, error) { ...@@ -161,7 +161,7 @@ func path_refunescape(s string) (string, error) {
if i+2 >= l { if i+2 >= l {
return "", EscapeError(s) return "", EscapeError(s)
} }
b, err := hex.DecodeString(s[i+1:i+3]) b, err := hex.DecodeString(s[i+1 : i+3])
if err != nil { if err != nil {
return "", EscapeError(s) return "", EscapeError(s)
} }
......
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