commit_lock_file_to(): refactor a helper out of commit_lock_file()
commit_locked_index(), when writing to an alternate index file, duplicates (poorly) the code in commit_lock_file(). And anyway, it shouldn't have to know so much about the internal workings of lockfile objects. So extract a new function commit_lock_file_to() that does the work common to the two functions, and call it from both commit_lock_file() and commit_locked_index(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0c0d6e8601
commit
751bacedaa
13
read-cache.c
13
read-cache.c
@ -2041,17 +2041,10 @@ void set_alternate_index_output(const char *name)
|
||||
|
||||
static int commit_locked_index(struct lock_file *lk)
|
||||
{
|
||||
if (alternate_index_output) {
|
||||
if (close_lock_file(lk))
|
||||
return -1;
|
||||
if (rename(lk->filename.buf, alternate_index_output))
|
||||
return -1;
|
||||
lk->active = 0;
|
||||
strbuf_reset(&lk->filename);
|
||||
return 0;
|
||||
} else {
|
||||
if (alternate_index_output)
|
||||
return commit_lock_file_to(lk, alternate_index_output);
|
||||
else
|
||||
return commit_lock_file(lk);
|
||||
}
|
||||
}
|
||||
|
||||
static int do_write_locked_index(struct index_state *istate, struct lock_file *lock,
|
||||
|
Reference in New Issue
Block a user