On Fri, Jun 9, 2017 at 1:40 AM, Brandon Williams <bmw...@google.com> wrote:
> Introduce the repository object 'struct repository' which can be used to
> hold all state pertaining to a git repository.
> [...]
> +static void repo_clear_env(struct repository *repo)
> +{
> +       free(repo->gitdir);
> +       repo->gitdir = NULL;
> +       free(repo->commondir);
> +       repo->commondir = NULL;
> +       free(repo->objectdir);
> +       repo->objectdir = NULL;
> +       free(repo->index_file);
> +       repo->index_file = NULL;
> +       free(repo->graft_file);
> +       repo->graft_file = NULL;
> +       free(repo->namespace);
> +       repo->namespace = NULL;
> +}

When seeing this I wondered if it couldn't be less noisy as:

> +       freez(repo->gitdir);
> +       freez(repo->commondir);
> +       freez(repo->objectdir);
> +       freez(repo->index_file);
> +       freez(repo->graft_file);
> +       freez(repo->namespace);

It's not a problem with your patch, but something I thought would be
nice to have in general, so here's a patch series to implement that.

Ævar Arnfjörð Bjarmason (2):
  git-compat-util: add a freez() wrapper around free(x); x = NULL
  *.[ch] refactoring: make use of the freez() wrapper

 alias.c                  |  6 ++----
 apply.c                  |  3 +--
 attr.c                   |  6 ++----
 blame.c                  |  3 +--
 branch.c                 |  3 +--
 builtin/am.c             | 18 +++++-------------
 builtin/clean.c          |  6 ++----
 builtin/config.c         |  6 ++----
 builtin/index-pack.c     |  6 ++----
 builtin/pack-objects.c   | 12 ++++--------
 builtin/unpack-objects.c |  3 +--
 builtin/worktree.c       |  6 ++----
 commit-slab.h            |  3 +--
 commit.c                 |  3 +--
 config.c                 |  3 +--
 credential.c             |  9 +++------
 diff-lib.c               |  3 +--
 diff.c                   |  6 ++----
 diffcore-rename.c        |  6 ++----
 dir.c                    |  9 +++------
 fast-import.c            |  6 ++----
 git-compat-util.h        |  1 +
 gpg-interface.c          | 15 +++++----------
 grep.c                   | 12 ++++--------
 help.c                   |  3 +--
 http-push.c              | 24 ++++++++----------------
 http.c                   | 15 +++++----------
 imap-send.c              |  3 +--
 line-log.c               |  6 ++----
 ll-merge.c               |  3 +--
 mailinfo.c               |  3 +--
 object.c                 |  3 +--
 pathspec.c               |  3 +--
 prio-queue.c             |  3 +--
 read-cache.c             |  6 ++----
 ref-filter.c             |  3 +--
 refs/files-backend.c     |  3 +--
 refs/ref-cache.c         |  3 +--
 remote-testsvn.c         |  3 +--
 rerere.c                 |  3 +--
 sequencer.c              |  3 +--
 sha1-array.c             |  3 +--
 sha1_file.c              |  3 +--
 split-index.c            |  3 +--
 transport-helper.c       | 27 +++++++++------------------
 transport.c              |  3 +--
 tree-diff.c              |  6 ++----
 tree-walk.c              |  3 +--
 tree.c                   |  3 +--
 49 files changed, 98 insertions(+), 197 deletions(-)

-- 
2.13.0.506.g27d5fe0cd

Reply via email to