Skip to content

Commit cc539af

Browse files
dschoGit for Windows Build Agent
authored andcommitted
fixup??? built-in add -i: start implementing the patch functionality in C
Needed by `tg/stash-refresh-index`. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6355d87 commit cc539af

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

add-patch.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,11 @@ static int patch_update_file(struct add_p_state *s,
15511551
NULL, 0, NULL, 0))
15521552
error(_("'git apply' failed"));
15531553
}
1554-
repo_refresh_and_write_index(s->s.r, REFRESH_QUIET, 0);
1554+
if (discard_index(s->s.r->index) < 0 ||
1555+
repo_read_index_preload(s->s.r, NULL, 0) < 0)
1556+
return error(_("could not read index"));
1557+
repo_refresh_and_write_index(s->s.r, REFRESH_QUIET, 0, 1,
1558+
NULL, NULL, NULL);
15551559
}
15561560

15571561
putchar('\n');
@@ -1594,7 +1598,10 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
15941598
s.mode = &patch_mode_stage;
15951599
s.revision = revision;
15961600

1597-
if (repo_refresh_and_write_index(r, REFRESH_QUIET, 0) < 0 ||
1601+
if (repo_read_index_preload(r, NULL, 0) < 0)
1602+
return error(_("could not read index"));
1603+
if (repo_refresh_and_write_index(r, REFRESH_QUIET, 0, 1,
1604+
NULL, NULL, NULL) < 0 ||
15981605
parse_diff(&s, ps) < 0) {
15991606
strbuf_release(&s.plain);
16001607
strbuf_release(&s.colored);

0 commit comments

Comments
 (0)