summaryrefslogtreecommitdiff
path: root/wt-status.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-10-05 20:32:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-10-06 01:07:17 (GMT)
commit837e34eba47f209a38fc9ab458bd103fd7515325 (patch)
treeab91a9de784eec03c56b431b51dd4649270cfd9c /wt-status.c
parentf132a127eebb8f1b14b87fc317ca68278fceb2e8 (diff)
downloadgit-837e34eba47f209a38fc9ab458bd103fd7515325.zip
git-837e34eba47f209a38fc9ab458bd103fd7515325.tar.gz
git-837e34eba47f209a38fc9ab458bd103fd7515325.tar.bz2
treewide: prefer lockfiles on the stack
There is no longer any need to allocate and leak a `struct lock_file`. The previous patch addressed an instance where we needed a minor tweak alongside the trivial changes. Deal with the remaining instances where we allocate and leak a struct within a single function. Change them to have the `struct lock_file` on the stack instead. These instances were identified by running `git grep "^\s*struct lock_file\s*\*"`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/wt-status.c b/wt-status.c
index 6f730ee..7d88e7c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2299,14 +2299,14 @@ int has_uncommitted_changes(int ignore_submodules)
*/
int require_clean_work_tree(const char *action, const char *hint, int ignore_submodules, int gently)
{
- struct lock_file *lock_file = xcalloc(1, sizeof(*lock_file));
+ struct lock_file lock_file = LOCK_INIT;
int err = 0, fd;
- fd = hold_locked_index(lock_file, 0);
+ fd = hold_locked_index(&lock_file, 0);
refresh_cache(REFRESH_QUIET);
if (0 <= fd)
- update_index_if_able(&the_index, lock_file);
- rollback_lock_file(lock_file);
+ update_index_if_able(&the_index, &lock_file);
+ rollback_lock_file(&lock_file);
if (has_unstaged_changes(ignore_submodules)) {
/* TRANSLATORS: the action is e.g. "pull with rebase" */