diff options
| author | Junio C Hamano <gitster@pobox.com> | 2014-09-19 11:38:35 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2014-09-19 11:38:35 -0700 |
| commit | 4fc72d91066d8fcb6de25596429fd603d3d91d79 (patch) | |
| tree | 6070258b925de87e1d94502b76f356414bc62540 /pack-write.c | |
| parent | 73da5a1e85951ee967edde956021c55adeaa83ce (diff) | |
| parent | d773144417b1a87b4529144ab0530ecfea103754 (diff) | |
| download | git-4fc72d91066d8fcb6de25596429fd603d3d91d79.tar.xz | |
Merge branch 'rs/more-uses-of-skip-prefix'
Code clean-up.
* rs/more-uses-of-skip-prefix:
pack-write: simplify index_pack_lockfile using skip_prefix() and xstrfmt()
connect: simplify check_ref() using skip_prefix() and starts_with()
Diffstat (limited to 'pack-write.c')
| -rw-r--r-- | pack-write.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pack-write.c b/pack-write.c index 9ccf80419b..33293ce2a6 100644 --- a/pack-write.c +++ b/pack-write.c @@ -288,13 +288,12 @@ char *index_pack_lockfile(int ip_out) * case, we need it to remove the corresponding .keep file * 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' && - memcmp(packname, "keep\t", 5) == 0) { - char path[PATH_MAX]; + if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n') { + const char *name; packname[45] = 0; - snprintf(path, sizeof(path), "%s/pack/pack-%s.keep", - get_object_directory(), packname + 5); - return xstrdup(path); + if (skip_prefix(packname, "keep\t", &name)) + return xstrfmt("%s/pack/pack-%s.keep", + get_object_directory(), name); } return NULL; } |
