Skip to content

Commit c06fa62

Browse files
pcloudsgitster
authored andcommitted
config.c: handle lock file in error case in git_config_rename_...
We could rely on atexit() to clean up everything, but let's be explicit when we can. And it's good anyway because the function is called the second time in the same process, we're in trouble. This function should not affect the successful case because after commit_lock_file() is called, rollback_lock_file() becomes no-op, as long as it is initialized. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6e45b43 commit c06fa62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ int git_config_rename_section_in_file(const char *config_filename,
23142314

23152315
if (new_name && !section_name_is_ok(new_name)) {
23162316
ret = error("invalid section name: %s", new_name);
2317-
goto out;
2317+
goto out_no_rollback;
23182318
}
23192319

23202320
if (!config_filename)
@@ -2396,6 +2396,8 @@ int git_config_rename_section_in_file(const char *config_filename,
23962396
ret = error_errno("could not write config file %s",
23972397
config_filename);
23982398
out:
2399+
rollback_lock_file(lock);
2400+
out_no_rollback:
23992401
free(filename_buf);
24002402
return ret;
24012403
}

0 commit comments

Comments
 (0)