mirror of
https://github.com/git/git.git
synced 2024-09-26 13:51:07 +02:00
pack-write: simplify index_pack_lockfile using skip_prefix() and xstrfmt()
Get rid of magic string length constants by using skip_prefix() instead of memcmp() and use xstrfmt() for building a string instead of a PATH_MAX-sized buffer, snprintf() and xstrdup(). Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
be0b3f822b
commit
d773144417
11
pack-write.c
11
pack-write.c
@ -288,13 +288,12 @@ char *index_pack_lockfile(int ip_out)
|
|||||||
* case, we need it to remove the corresponding .keep file
|
* case, we need it to remove the corresponding .keep file
|
||||||
* later on. If we don't get that then tough luck with it.
|
* later on. If we don't get that then tough luck with it.
|
||||||
*/
|
*/
|
||||||
if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
|
if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n') {
|
||||||
memcmp(packname, "keep\t", 5) == 0) {
|
const char *name;
|
||||||
char path[PATH_MAX];
|
|
||||||
packname[45] = 0;
|
packname[45] = 0;
|
||||||
snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",
|
if (skip_prefix(packname, "keep\t", &name))
|
||||||
get_object_directory(), packname + 5);
|
return xstrfmt("%s/pack/pack-%s.keep",
|
||||||
return xstrdup(path);
|
get_object_directory(), name);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user