Merge branch 'vd/update-refs-delete'

`git rebase --update-refs` would delete references when all `update-ref`
commands in the sequencer were removed, which has been corrected.

* vd/update-refs-delete:
  rebase --update-refs: avoid unintended ref deletion
This commit is contained in:
Taylor Blau
2022-11-18 18:43:10 -05:00
2 changed files with 113 additions and 3 deletions

View File

@@ -4128,11 +4128,14 @@ static int write_update_refs_state(struct string_list *refs_to_oids)
struct string_list_item *item;
char *path;
if (!refs_to_oids->nr)
return 0;
path = rebase_path_update_refs(the_repository->gitdir);
if (!refs_to_oids->nr) {
if (unlink(path) && errno != ENOENT)
result = error_errno(_("could not unlink: %s"), path);
goto cleanup;
}
if (safe_create_leading_directories(path)) {
result = error(_("unable to create leading directories of %s"),
path);