summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-10-01 12:28:20 +0200
committerJunio C Hamano <gitster@pobox.com>2014-10-01 13:45:13 -0700
commit4f4713df94e2f3d3adbd39b8fce571e2bd69185e (patch)
tree0d01a95bd0f52871359d0fc03a43be0466554a96
parenta1754bcce98fa57b9374440c2717ec1159ed8ffb (diff)
downloadgit-4f4713df94e2f3d3adbd39b8fce571e2bd69185e.tar.gz
commit_lock_file(): inline temporary variable
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--lockfile.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lockfile.c b/lockfile.c
index f8205f6b03..e148227fb1 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -300,12 +300,14 @@ int reopen_lock_file(struct lock_file *lk)
int commit_lock_file(struct lock_file *lk)
{
char result_file[PATH_MAX];
- size_t i;
+
if (close_lock_file(lk))
return -1;
+
strcpy(result_file, lk->filename);
- i = strlen(result_file) - LOCK_SUFFIX_LEN; /* .lock */
- result_file[i] = 0;
+ /* remove ".lock": */
+ result_file[strlen(result_file) - LOCK_SUFFIX_LEN] = 0;
+
if (rename(lk->filename, result_file))
return -1;
lk->filename[0] = 0;