Commit 25743bd7c5f14f2287d9c4fdf953c978e3b16916

Edward Thomson 2013-01-12T13:47:56

add an index_remove_bypath that removes conflicts, renamed add_from_workdir to match

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
diff --git a/include/git2/index.h b/include/git2/index.h
index 2df5103..ad6d197 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -362,7 +362,7 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
 /**@{*/
 
 /**
- * Add or update an index entry from a file in disk
+ * Add or update an index entry from a file on disk
  *
  * The file `path` must be relative to the repository's
  * working folder and must be readable.
@@ -381,7 +381,23 @@ GIT_EXTERN(int) git_index_entry_stage(const git_index_entry *entry);
  * @param path filename to add
  * @return 0 or an error code
  */
-GIT_EXTERN(int) git_index_add_from_workdir(git_index *index, const char *path);
+GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path);
+
+/**
+ * Remove an index entry corresponding to a file on disk
+ *
+ * The file `path` must be relative to the repository's
+ * working folder.  It may exist.
+ *
+ * If this file currently is the result of a merge conflict, this
+ * file will no longer be marked as conflicting.  The data about
+ * the conflict will be moved to the "resolve undo" (REUC) section.
+ *
+ * @param index an existing index object
+ * @param path filename to remove
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_index_remove_bypath(git_index *index, const char *path);
 
 /**
  * Find the first index of any entries which point to given
diff --git a/src/index.c b/src/index.c
index 606a431..7638428 100644
--- a/src/index.c
+++ b/src/index.c
@@ -730,7 +730,7 @@ static int index_conflict_to_reuc(git_index *index, const char *path)
 	return ret;
 }
 
-int git_index_add_from_workdir(git_index *index, const char *path)
+int git_index_add_bypath(git_index *index, const char *path)
 {
 	git_index_entry *entry = NULL;
 	int ret;
@@ -753,6 +753,21 @@ on_error:
 	return ret;
 }
 
+int git_index_remove_bypath(git_index *index, const char *path)
+{
+	int ret;
+
+	assert(index && path);
+
+	if (((ret = git_index_remove(index, path, 0)) < 0 &&
+		ret != GIT_ENOTFOUND) ||
+		((ret = index_conflict_to_reuc(index, path)) < 0 &&
+		ret != GIT_ENOTFOUND))
+		return ret;
+
+	return 0;
+}
+
 int git_index_add(git_index *index, const git_index_entry *source_entry)
 {
 	git_index_entry *entry = NULL;
diff --git a/src/stash.c b/src/stash.c
index e63a362..d4f81ae 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -208,7 +208,7 @@ static int update_index_cb(
 	}
 
 	if (add_path != NULL)
-		data->error = git_index_add_from_workdir(data->index, add_path);
+		data->error = git_index_add_bypath(data->index, add_path);
 
 	return data->error;
 }
diff --git a/src/submodule.c b/src/submodule.c
index a723266..a38ece0 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -332,7 +332,7 @@ int git_submodule_add_finalize(git_submodule *sm)
 	assert(sm);
 
 	if ((error = git_repository_index__weakptr(&index, sm->owner)) < 0 ||
-		(error = git_index_add_from_workdir(index, GIT_MODULES_FILE)) < 0)
+		(error = git_index_add_bypath(index, GIT_MODULES_FILE)) < 0)
 		return error;
 
 	return git_submodule_add_to_index(sm, true);
diff --git a/tests-clar/attr/repo.c b/tests-clar/attr/repo.c
index 1d2b1e8..926a0d8 100644
--- a/tests-clar/attr/repo.c
+++ b/tests-clar/attr/repo.c
@@ -270,7 +270,7 @@ static void assert_proper_normalization(git_index *index, const char *filename, 
 	const git_index_entry *entry;
 
 	add_to_workdir(filename, CONTENT);
-	cl_git_pass(git_index_add_from_workdir(index, filename));
+	cl_git_pass(git_index_add_bypath(index, filename));
 
 	index_pos = git_index_find(index, filename);
 	cl_assert(index_pos >= 0);
diff --git a/tests-clar/checkout/head.c b/tests-clar/checkout/head.c
index 8b30993..46646f8 100644
--- a/tests-clar/checkout/head.c
+++ b/tests-clar/checkout/head.c
@@ -40,7 +40,7 @@ void test_checkout_head__with_index_only_tree(void)
 	p_mkdir("testrepo/newdir", 0777);
     cl_git_mkfile("testrepo/newdir/newfile.txt", "new file\n");
 
-	cl_git_pass(git_index_add_from_workdir(index, "newdir/newfile.txt"));
+	cl_git_pass(git_index_add_bypath(index, "newdir/newfile.txt"));
 	cl_git_pass(git_index_write(index));
 
 	cl_assert(git_path_isfile("testrepo/newdir/newfile.txt"));
diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c
index 2dc0871..9a70f31 100644
--- a/tests-clar/checkout/index.c
+++ b/tests-clar/checkout/index.c
@@ -417,8 +417,8 @@ void test_checkout_index__can_overcome_name_clashes(void)
 	cl_git_pass(p_mkdir("./testrepo/path1", 0777));
 	cl_git_mkfile("./testrepo/path1/file1", "content\r\n");
 
-	cl_git_pass(git_index_add_from_workdir(index, "path0"));
-	cl_git_pass(git_index_add_from_workdir(index, "path1/file1"));
+	cl_git_pass(git_index_add_bypath(index, "path0"));
+	cl_git_pass(git_index_add_bypath(index, "path1/file1"));
 
 	cl_git_pass(p_unlink("./testrepo/path0"));
 	cl_git_pass(git_futils_rmdir_r(
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c
index 80e26a1..176dcce 100644
--- a/tests-clar/checkout/tree.c
+++ b/tests-clar/checkout/tree.c
@@ -406,7 +406,7 @@ void assert_conflict(
 		GIT_EMERGECONFLICT, git_checkout_tree(g_repo, g_object, &g_opts));
 
 	/* Stage the conflicting change */
-	cl_git_pass(git_index_add_from_workdir(index, entry_path));
+	cl_git_pass(git_index_add_bypath(index, entry_path));
 	cl_git_pass(git_index_write(index));
 
 	cl_assert_equal_i(
diff --git a/tests-clar/index/conflicts.c b/tests-clar/index/conflicts.c
index 2fbad3e..4b8a0cf 100644
--- a/tests-clar/index/conflicts.c
+++ b/tests-clar/index/conflicts.c
@@ -154,7 +154,7 @@ void test_index_conflicts__remove(void)
 	}
 }
 
-void test_index_conflicts__moved_to_reuc(void)
+void test_index_conflicts__moved_to_reuc_on_add(void)
 {
 	const git_index_entry *entry;
 	size_t i;
@@ -163,7 +163,7 @@ void test_index_conflicts__moved_to_reuc(void)
 
 	cl_git_mkfile("./mergedrepo/conflicts-one.txt", "new-file\n");
 
-	cl_git_pass(git_index_add_from_workdir(repo_index, "conflicts-one.txt"));
+	cl_git_pass(git_index_add_bypath(repo_index, "conflicts-one.txt"));
 
 	cl_assert(git_index_entrycount(repo_index) == 6);
 
@@ -175,6 +175,25 @@ void test_index_conflicts__moved_to_reuc(void)
 	}
 }
 
+void test_index_conflicts__moved_to_reuc_on_remove(void)
+{
+	const git_index_entry *entry;
+	size_t i;
+
+	cl_assert(git_index_entrycount(repo_index) == 8);
+
+	cl_git_pass(p_unlink("./mergedrepo/conflicts-one.txt"));
+
+	cl_git_pass(git_index_remove_bypath(repo_index, "conflicts-one.txt"));
+
+	cl_assert(git_index_entrycount(repo_index) == 5);
+
+	for (i = 0; i < git_index_entrycount(repo_index); i++) {
+		cl_assert(entry = git_index_get_byindex(repo_index, i));
+		cl_assert(strcmp(entry->path, "conflicts-one.txt") != 0);
+	}
+}
+
 void test_index_conflicts__remove_all_conflicts(void)
 {
 	size_t i;
diff --git a/tests-clar/index/filemodes.c b/tests-clar/index/filemodes.c
index 6140b11..1acd2e3 100644
--- a/tests-clar/index/filemodes.c
+++ b/tests-clar/index/filemodes.c
@@ -56,7 +56,7 @@ static void add_and_check_mode(
 	int pos;
 	const git_index_entry *entry;
 
-	cl_git_pass(git_index_add_from_workdir(index, filename));
+	cl_git_pass(git_index_add_bypath(index, filename));
 
 	pos = git_index_find(index, filename);
 	cl_assert(pos >= 0);
diff --git a/tests-clar/index/inmemory.c b/tests-clar/index/inmemory.c
index a5f72c4..38e91e0 100644
--- a/tests-clar/index/inmemory.c
+++ b/tests-clar/index/inmemory.c
@@ -10,13 +10,13 @@ void test_index_inmemory__can_create_an_inmemory_index(void)
 	git_index_free(index);
 }
 
-void test_index_inmemory__cannot_add_from_workdir_to_an_inmemory_index(void)
+void test_index_inmemory__cannot_add_bypath_to_an_inmemory_index(void)
 {
 	git_index *index;
 
 	cl_git_pass(git_index_new(&index));
 
-	cl_assert_equal_i(GIT_ERROR, git_index_add_from_workdir(index, "test.txt"));
+	cl_assert_equal_i(GIT_ERROR, git_index_add_bypath(index, "test.txt"));
 
 	git_index_free(index);
 }
diff --git a/tests-clar/index/read_tree.c b/tests-clar/index/read_tree.c
index 3ae883d..6c6b401 100644
--- a/tests-clar/index/read_tree.c
+++ b/tests-clar/index/read_tree.c
@@ -24,9 +24,9 @@ void test_index_read_tree__read_write_involution(void)
 	cl_git_mkfile("./read_tree/abc/d", NULL);
 	cl_git_mkfile("./read_tree/abc_d", NULL);
 
-	cl_git_pass(git_index_add_from_workdir(index, "abc-d"));
-	cl_git_pass(git_index_add_from_workdir(index, "abc_d"));
-	cl_git_pass(git_index_add_from_workdir(index, "abc/d"));
+	cl_git_pass(git_index_add_bypath(index, "abc-d"));
+	cl_git_pass(git_index_add_bypath(index, "abc_d"));
+	cl_git_pass(git_index_add_bypath(index, "abc/d"));
 
 	/* write-tree */
 	cl_git_pass(git_index_write_tree(&expected, index));
diff --git a/tests-clar/index/rename.c b/tests-clar/index/rename.c
index adbbcfa..400bbdf 100644
--- a/tests-clar/index/rename.c
+++ b/tests-clar/index/rename.c
@@ -19,7 +19,7 @@ void test_index_rename__single_file(void)
 	cl_git_mkfile("./rename/lame.name.txt", "new_file\n");
 
 	/* This should add a new blob to the object database in 'd4/fa8600b4f37d7516bef4816ae2c64dbf029e3a' */
-	cl_git_pass(git_index_add_from_workdir(index, "lame.name.txt"));
+	cl_git_pass(git_index_add_bypath(index, "lame.name.txt"));
 	cl_assert(git_index_entrycount(index) == 1);
 
 	cl_git_pass(git_oid_fromstr(&expected, "d4fa8600b4f37d7516bef4816ae2c64dbf029e3a"));
@@ -35,7 +35,7 @@ void test_index_rename__single_file(void)
 
 	p_rename("./rename/lame.name.txt", "./rename/fancy.name.txt");
 
-	cl_git_pass(git_index_add_from_workdir(index, "fancy.name.txt"));
+	cl_git_pass(git_index_add_bypath(index, "fancy.name.txt"));
 	cl_assert(git_index_entrycount(index) == 1);
 
 	position = git_index_find(index, "fancy.name.txt");
diff --git a/tests-clar/index/stage.c b/tests-clar/index/stage.c
index 0f3b298..4774568 100644
--- a/tests-clar/index/stage.c
+++ b/tests-clar/index/stage.c
@@ -31,7 +31,7 @@ void test_index_stage__add_always_adds_stage_0(void)
 
     cl_git_mkfile("./mergedrepo/new-file.txt", "new-file\n");
 
-	cl_git_pass(git_index_add_from_workdir(repo_index, "new-file.txt"));
+	cl_git_pass(git_index_add_bypath(repo_index, "new-file.txt"));
 
 	cl_assert((entry_idx = git_index_find(repo_index, "new-file.txt")) >= 0);
 	cl_assert((entry = git_index_get_byindex(repo_index, entry_idx)) != NULL);
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 5c3d4cf..3c2a689 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -233,7 +233,7 @@ void test_index_tests__add(void)
 	cl_git_pass(git_oid_fromstr(&id1, "a8233120f6ad708f843d861ce2b7228ec4e3dec6"));
 
 	/* Add the new file to the index */
-	cl_git_pass(git_index_add_from_workdir(index, "test.txt"));
+	cl_git_pass(git_index_add_bypath(index, "test.txt"));
 
 	/* Wow... it worked! */
 	cl_assert(git_index_entrycount(index) == 1);
@@ -250,7 +250,7 @@ void test_index_tests__add(void)
 	git_repository_free(repo);
 }
 
-void test_index_tests__add_from_workdir_to_a_bare_repository_returns_EBAREPO(void)
+void test_index_tests__add_bypath_to_a_bare_repository_returns_EBAREPO(void)
 {
 	git_repository *bare_repo;
 	git_index *index;
@@ -258,7 +258,7 @@ void test_index_tests__add_from_workdir_to_a_bare_repository_returns_EBAREPO(voi
 	cl_git_pass(git_repository_open(&bare_repo, cl_fixture("testrepo.git")));
 	cl_git_pass(git_repository_index(&index, bare_repo));
 
-	cl_assert_equal_i(GIT_EBAREREPO, git_index_add_from_workdir(index, "test.txt"));
+	cl_assert_equal_i(GIT_EBAREREPO, git_index_add_bypath(index, "test.txt"));
 
 	git_index_free(index);
 	git_repository_free(bare_repo);
@@ -280,7 +280,7 @@ void test_index_tests__write_invalid_filename(void)
 
 	cl_git_mkfile("./read_tree/.git/hello", NULL);
 
-	cl_git_pass(git_index_add_from_workdir(index, ".git/hello"));
+	cl_git_pass(git_index_add_bypath(index, ".git/hello"));
 
 	/* write-tree */
 	cl_git_fail(git_index_write_tree(&expected, index));
@@ -303,7 +303,7 @@ void test_index_tests__remove_entry(void)
 	cl_assert(git_index_entrycount(index) == 0);
 
 	cl_git_mkfile("index_test/hello", NULL);
-	cl_git_pass(git_index_add_from_workdir(index, "hello"));
+	cl_git_pass(git_index_add_bypath(index, "hello"));
 	cl_git_pass(git_index_write(index));
 
 	cl_git_pass(git_index_read(index)); /* reload */
@@ -339,10 +339,10 @@ void test_index_tests__remove_directory(void)
 	cl_git_mkfile("index_test/a/3.txt", NULL);
 	cl_git_mkfile("index_test/b.txt", NULL);
 
-	cl_git_pass(git_index_add_from_workdir(index, "a/1.txt"));
-	cl_git_pass(git_index_add_from_workdir(index, "a/2.txt"));
-	cl_git_pass(git_index_add_from_workdir(index, "a/3.txt"));
-	cl_git_pass(git_index_add_from_workdir(index, "b.txt"));
+	cl_git_pass(git_index_add_bypath(index, "a/1.txt"));
+	cl_git_pass(git_index_add_bypath(index, "a/2.txt"));
+	cl_git_pass(git_index_add_bypath(index, "a/3.txt"));
+	cl_git_pass(git_index_add_bypath(index, "b.txt"));
 	cl_git_pass(git_index_write(index));
 
 	cl_git_pass(git_index_read(index)); /* reload */
diff --git a/tests-clar/object/commit/commitstagedfile.c b/tests-clar/object/commit/commitstagedfile.c
index 55c70d9..9867ab4 100644
--- a/tests-clar/object/commit/commitstagedfile.c
+++ b/tests-clar/object/commit/commitstagedfile.c
@@ -73,7 +73,7 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
 	 */
 	cl_git_mkfile("treebuilder/test.txt", "test\n");
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, "test.txt"));
+	cl_git_pass(git_index_add_bypath(index, "test.txt"));
 
 	entry = git_index_get_byindex(index, 0);
 
diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c
index 2af95c7..16e3d77 100644
--- a/tests-clar/stash/drop.c
+++ b/tests-clar/stash/drop.c
@@ -34,7 +34,7 @@ static void push_three_states(void)
 
 	cl_git_mkfile("stash/zero.txt", "content\n");
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, "zero.txt"));
+	cl_git_pass(git_index_add_bypath(index, "zero.txt"));
 	commit_staged_files(&oid, index, signature);
 	cl_assert(git_path_exists("stash/zero.txt"));
 
diff --git a/tests-clar/stash/save.c b/tests-clar/stash/save.c
index e6033e1..ea2eb28 100644
--- a/tests-clar/stash/save.c
+++ b/tests-clar/stash/save.c
@@ -251,8 +251,8 @@ void test_stash_save__cannot_stash_when_there_are_no_local_change(void)
 	 * 'what' and 'who' are being committed.
 	 * 'when' remain untracked.
 	 */
-	cl_git_pass(git_index_add_from_workdir(index, "what"));
-	cl_git_pass(git_index_add_from_workdir(index, "who"));
+	cl_git_pass(git_index_add_bypath(index, "what"));
+	cl_git_pass(git_index_add_bypath(index, "who"));
 	cl_git_pass(git_index_write(index));
 	commit_staged_files(&commit_oid, index, signature);
 	git_index_free(index);
diff --git a/tests-clar/stash/stash_helpers.c b/tests-clar/stash/stash_helpers.c
index 86a7418..f462a13 100644
--- a/tests-clar/stash/stash_helpers.c
+++ b/tests-clar/stash/stash_helpers.c
@@ -46,10 +46,10 @@ void setup_stash(git_repository *repo, git_signature *signature)
 
 	cl_git_mkfile("stash/.gitignore", "*.ignore\n");
 
-	cl_git_pass(git_index_add_from_workdir(index, "what"));
-	cl_git_pass(git_index_add_from_workdir(index, "how"));
-	cl_git_pass(git_index_add_from_workdir(index, "who"));
-	cl_git_pass(git_index_add_from_workdir(index, ".gitignore"));
+	cl_git_pass(git_index_add_bypath(index, "what"));
+	cl_git_pass(git_index_add_bypath(index, "how"));
+	cl_git_pass(git_index_add_bypath(index, "who"));
+	cl_git_pass(git_index_add_bypath(index, ".gitignore"));
 	cl_git_pass(git_index_write(index));
 
 	commit_staged_files(&commit_oid, index, signature);
@@ -58,8 +58,8 @@ void setup_stash(git_repository *repo, git_signature *signature)
 	cl_git_rewritefile("stash/how", "not so small and\n");	/* e6d64adb2c7f3eb8feb493b556cc8070dca379a3 */
 	cl_git_rewritefile("stash/who", "funky world\n");		/* a0400d4954659306a976567af43125a0b1aa8595 */
 
-	cl_git_pass(git_index_add_from_workdir(index, "what"));
-	cl_git_pass(git_index_add_from_workdir(index, "how"));
+	cl_git_pass(git_index_add_bypath(index, "what"));
+	cl_git_pass(git_index_add_bypath(index, "how"));
 	cl_git_pass(git_index_write(index));
 
 	cl_git_rewritefile("stash/what", "see you later\n");	/* bc99dc98b3eba0e9157e94769cd4d49cb49de449 */
diff --git a/tests-clar/status/worktree_init.c b/tests-clar/status/worktree_init.c
index 6d790b1..0c34dde 100644
--- a/tests-clar/status/worktree_init.c
+++ b/tests-clar/status/worktree_init.c
@@ -38,7 +38,7 @@ void test_status_worktree_init__first_commit_in_progress(void)
 	cl_assert(result.status == GIT_STATUS_WT_NEW);
 
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, "testfile.txt"));
+	cl_git_pass(git_index_add_bypath(index, "testfile.txt"));
 	cl_git_pass(git_index_write(index));
 
 	memset(&result, 0, sizeof(result));
@@ -172,7 +172,7 @@ void test_status_worktree_init__bracket_in_filename(void)
 	/* add the file to the index */
 
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, FILE_WITH_BRACKET));
+	cl_git_pass(git_index_add_bypath(index, FILE_WITH_BRACKET));
 	cl_git_pass(git_index_write(index));
 
 	memset(&result, 0, sizeof(result));
@@ -251,7 +251,7 @@ void test_status_worktree_init__space_in_filename(void)
 	/* add the file to the index */
 
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, FILE_WITH_SPACE));
+	cl_git_pass(git_index_add_bypath(index, FILE_WITH_SPACE));
 	cl_git_pass(git_index_write(index));
 
 	memset(&result, 0, sizeof(result));
@@ -329,7 +329,7 @@ void test_status_worktree_init__new_staged_file_must_handle_crlf(void)
 	cl_git_mkfile("getting_started/testfile.txt", "content\r\n");	// Content with CRLF
 
 	cl_git_pass(git_repository_index(&index, repo));
-	cl_git_pass(git_index_add_from_workdir(index, "testfile.txt"));
+	cl_git_pass(git_index_add_bypath(index, "testfile.txt"));
 	cl_git_pass(git_index_write(index));
 
 	cl_git_pass(git_status_file(&status, repo, "testfile.txt"));