@@ -34,15 +34,15 @@ func (repo *Repository) ReadTreeToIndex(ctx context.Context, treeish string, ind
3434 if err != nil {
3535 return err
3636 }
37- return repo .readTreeToIndex (id , indexFilename ... )
37+ return repo .readTreeToIndex (ctx , id , indexFilename ... )
3838}
3939
40- func (repo * Repository ) readTreeToIndex (id ObjectID , indexFilename ... string ) error {
40+ func (repo * Repository ) readTreeToIndex (ctx context. Context , id ObjectID , indexFilename ... string ) error {
4141 var env []string
4242 if len (indexFilename ) > 0 {
4343 env = append (os .Environ (), "GIT_INDEX_FILE=" + indexFilename [0 ])
4444 }
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 })
4646 if err != nil {
4747 return err
4848 }
@@ -82,15 +82,15 @@ func (repo *Repository) ReadTreeToTemporaryIndex(ctx context.Context, treeish st
8282}
8383
8484// 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 })
8787 return err
8888}
8989
9090// 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 ) {
9292 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 })
9494 if err != nil {
9595 return nil , err
9696 }
@@ -103,7 +103,7 @@ func (repo *Repository) LsFiles(filenames ...string) ([]string, error) {
103103}
104104
105105// 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 {
107107 objectFormat , err := repo .GetObjectFormat ()
108108 if err != nil {
109109 return err
@@ -118,7 +118,7 @@ func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error {
118118 buffer .WriteString ("0 blob " + objectFormat .EmptyObjectID ().String () + "\t " + file + "\000 " )
119119 }
120120 }
121- return cmd .Run (repo . Ctx , & RunOpts {
121+ return cmd .Run (ctx , & RunOpts {
122122 Dir : repo .Path ,
123123 Stdin : bytes .NewReader (buffer .Bytes ()),
124124 Stdout : stdout ,
@@ -133,7 +133,7 @@ type IndexObjectInfo struct {
133133}
134134
135135// 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 {
137137 cmd := NewCommand ("update-index" , "--add" , "--replace" , "-z" , "--index-info" )
138138 stdout := new (bytes.Buffer )
139139 stderr := new (bytes.Buffer )
@@ -142,7 +142,7 @@ func (repo *Repository) AddObjectsToIndex(objects ...IndexObjectInfo) error {
142142 // using format: mode SP type SP sha1 TAB path
143143 buffer .WriteString (object .Mode + " blob " + object .Object .String () + "\t " + object .Filename + "\000 " )
144144 }
145- return cmd .Run (repo . Ctx , & RunOpts {
145+ return cmd .Run (ctx , & RunOpts {
146146 Dir : repo .Path ,
147147 Stdin : bytes .NewReader (buffer .Bytes ()),
148148 Stdout : stdout ,
@@ -151,13 +151,13 @@ func (repo *Repository) AddObjectsToIndex(objects ...IndexObjectInfo) error {
151151}
152152
153153// 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 })
156156}
157157
158158// 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 })
161161 if runErr != nil {
162162 return nil , runErr
163163 }
0 commit comments