@@ -34,15 +34,15 @@ func (repo *Repository) ReadTreeToIndex(ctx context.Context, treeish string, ind
34
34
if err != nil {
35
35
return err
36
36
}
37
- return repo .readTreeToIndex (id , indexFilename ... )
37
+ return repo .readTreeToIndex (ctx , id , indexFilename ... )
38
38
}
39
39
40
- func (repo * Repository ) readTreeToIndex (id ObjectID , indexFilename ... string ) error {
40
+ func (repo * Repository ) readTreeToIndex (ctx context. Context , id ObjectID , indexFilename ... string ) error {
41
41
var env []string
42
42
if len (indexFilename ) > 0 {
43
43
env = append (os .Environ (), "GIT_INDEX_FILE=" + indexFilename [0 ])
44
44
}
45
- _ , _ , err := NewCommand ("read-tree" ).AddDynamicArguments (id .String ()).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path , Env : env })
45
+ _ , _ , err := NewCommand ("read-tree" ).AddDynamicArguments (id .String ()).RunStdString (ctx , & RunOpts {Dir : repo .Path , Env : env })
46
46
if err != nil {
47
47
return err
48
48
}
@@ -82,15 +82,15 @@ func (repo *Repository) ReadTreeToTemporaryIndex(ctx context.Context, treeish st
82
82
}
83
83
84
84
// EmptyIndex empties the index
85
- func (repo * Repository ) EmptyIndex () error {
86
- _ , _ , err := NewCommand ("read-tree" , "--empty" ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
85
+ func (repo * Repository ) EmptyIndex (ctx context. Context ) error {
86
+ _ , _ , err := NewCommand ("read-tree" , "--empty" ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
87
87
return err
88
88
}
89
89
90
90
// LsFiles checks if the given filenames are in the index
91
- func (repo * Repository ) LsFiles (filenames ... string ) ([]string , error ) {
91
+ func (repo * Repository ) LsFiles (ctx context. Context , filenames ... string ) ([]string , error ) {
92
92
cmd := NewCommand ("ls-files" , "-z" ).AddDashesAndList (filenames ... )
93
- res , _ , err := cmd .RunStdBytes (repo . Ctx , & RunOpts {Dir : repo .Path })
93
+ res , _ , err := cmd .RunStdBytes (ctx , & RunOpts {Dir : repo .Path })
94
94
if err != nil {
95
95
return nil , err
96
96
}
@@ -103,7 +103,7 @@ func (repo *Repository) LsFiles(filenames ...string) ([]string, error) {
103
103
}
104
104
105
105
// RemoveFilesFromIndex removes given filenames from the index - it does not check whether they are present.
106
- func (repo * Repository ) RemoveFilesFromIndex (filenames ... string ) error {
106
+ func (repo * Repository ) RemoveFilesFromIndex (ctx context. Context , filenames ... string ) error {
107
107
objectFormat , err := repo .GetObjectFormat ()
108
108
if err != nil {
109
109
return err
@@ -118,7 +118,7 @@ func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error {
118
118
buffer .WriteString ("0 blob " + objectFormat .EmptyObjectID ().String () + "\t " + file + "\000 " )
119
119
}
120
120
}
121
- return cmd .Run (repo . Ctx , & RunOpts {
121
+ return cmd .Run (ctx , & RunOpts {
122
122
Dir : repo .Path ,
123
123
Stdin : bytes .NewReader (buffer .Bytes ()),
124
124
Stdout : stdout ,
@@ -133,7 +133,7 @@ type IndexObjectInfo struct {
133
133
}
134
134
135
135
// AddObjectsToIndex adds the provided object hashes to the index at the provided filenames
136
- func (repo * Repository ) AddObjectsToIndex (objects ... IndexObjectInfo ) error {
136
+ func (repo * Repository ) AddObjectsToIndex (ctx context. Context , objects ... IndexObjectInfo ) error {
137
137
cmd := NewCommand ("update-index" , "--add" , "--replace" , "-z" , "--index-info" )
138
138
stdout := new (bytes.Buffer )
139
139
stderr := new (bytes.Buffer )
@@ -142,7 +142,7 @@ func (repo *Repository) AddObjectsToIndex(objects ...IndexObjectInfo) error {
142
142
// using format: mode SP type SP sha1 TAB path
143
143
buffer .WriteString (object .Mode + " blob " + object .Object .String () + "\t " + object .Filename + "\000 " )
144
144
}
145
- return cmd .Run (repo . Ctx , & RunOpts {
145
+ return cmd .Run (ctx , & RunOpts {
146
146
Dir : repo .Path ,
147
147
Stdin : bytes .NewReader (buffer .Bytes ()),
148
148
Stdout : stdout ,
@@ -151,13 +151,13 @@ func (repo *Repository) AddObjectsToIndex(objects ...IndexObjectInfo) error {
151
151
}
152
152
153
153
// AddObjectToIndex adds the provided object hash to the index at the provided filename
154
- func (repo * Repository ) AddObjectToIndex (mode string , object ObjectID , filename string ) error {
155
- return repo .AddObjectsToIndex (IndexObjectInfo {Mode : mode , Object : object , Filename : filename })
154
+ func (repo * Repository ) AddObjectToIndex (ctx context. Context , mode string , object ObjectID , filename string ) error {
155
+ return repo .AddObjectsToIndex (ctx , IndexObjectInfo {Mode : mode , Object : object , Filename : filename })
156
156
}
157
157
158
158
// WriteTree writes the current index as a tree to the object db and returns its hash
159
- func (repo * Repository ) WriteTree () (* Tree , error ) {
160
- stdout , _ , runErr := NewCommand ("write-tree" ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
159
+ func (repo * Repository ) WriteTree (ctx context. Context ) (* Tree , error ) {
160
+ stdout , _ , runErr := NewCommand ("write-tree" ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
161
161
if runErr != nil {
162
162
return nil , runErr
163
163
}
0 commit comments