Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(286)

Side by Side Diff: src/pkg/patch/git.go

Issue 156115: code review 156115: gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg (Closed)
Patch Set: code review 156115: gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkg Created 15 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/os/stat_nacl.go ('k') | src/pkg/patch/patch.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package patch 5 package patch
6 6
7 import ( 7 import (
8 "bytes"; 8 "bytes";
9 "compress/zlib"; 9 "compress/zlib";
10 "crypto/sha1"; 10 "crypto/sha1";
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 func getHex(s []byte) (data []byte, rest []byte) { 56 func getHex(s []byte) (data []byte, rest []byte) {
57 n := 0; 57 n := 0;
58 for n < len(s) && unhex(s[n]) != 255 { 58 for n < len(s) && unhex(s[n]) != 255 {
59 n++ 59 n++
60 } 60 }
61 n &^= 1; // Only take an even number of hex digits. 61 n &^= 1; // Only take an even number of hex digits.
62 data = make([]byte, n/2); 62 data = make([]byte, n/2);
63 for i := range data { 63 for i := range data {
64 data[i] = unhex(s[2*i])<<4 | unhex(s[2*i+1]) 64 data[i] = unhex(s[2*i])<<4 | unhex(s[2*i+1])
65 } 65 }
66 » rest = s[n:len(s)]; 66 » rest = s[n:];
67 return; 67 return;
68 } 68 }
69 69
70 // ParseGitBinary parses raw as a Git binary patch. 70 // ParseGitBinary parses raw as a Git binary patch.
71 func ParseGitBinary(raw []byte) (Diff, os.Error) { 71 func ParseGitBinary(raw []byte) (Diff, os.Error) {
72 var oldSHA1, newSHA1 []byte; 72 var oldSHA1, newSHA1 []byte;
73 var sawBinary bool; 73 var sawBinary bool;
74 74
75 for { 75 for {
76 var first []byte; 76 var first []byte;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return nil, os.NewError("Git binary literal SHA1 mismatch") 112 return nil, os.NewError("Git binary literal SHA1 mismatch")
113 } 113 }
114 return &GitBinaryLiteral{oldSHA1, data}, nil; 114 return &GitBinaryLiteral{oldSHA1, data}, nil;
115 } 115 }
116 if !sawBinary { 116 if !sawBinary {
117 return nil, os.NewError("unexpected Git patch header: " + string(first)) 117 return nil, os.NewError("unexpected Git patch header: " + string(first))
118 } 118 }
119 } 119 }
120 panic("unreachable"); 120 panic("unreachable");
121 } 121 }
OLDNEW
« no previous file with comments | « src/pkg/os/stat_nacl.go ('k') | src/pkg/patch/patch.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b