Skip to content

Commit

Permalink
builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h
Browse files Browse the repository at this point in the history
Instead of including USE_THE_REPOSITORY_VARIABLE by default on every
builtin, remove it from builtin.h and add it to all the builtins that
include builtin.h (by definition, that means all builtins/*.c).

Also, remove the include statement for repository.h since it gets
brought in through builtin.h.

The next step will be to migrate each builtin
from having to use the_repository.

Signed-off-by: John Cai <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
john-cai authored and gitster committed Sep 13, 2024
1 parent 9b1cb50 commit 03eae9a
Show file tree
Hide file tree
Showing 125 changed files with 147 additions and 92 deletions.
8 changes: 0 additions & 8 deletions builtin.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#ifndef BUILTIN_H
#define BUILTIN_H

/*
* TODO: Almost all of our builtins access `the_repository` by necessity
* because they do not get passed a pointer to it. We should adapt the function
* signature of those main functions to accept a `struct repository *` and then
* remove the macro here.
*/
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "repository.h"

Expand Down
3 changes: 1 addition & 2 deletions builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "advice.h"
#include "config.h"
Expand All @@ -18,7 +18,6 @@
#include "preload-index.h"
#include "diff.h"
#include "read-cache.h"
#include "repository.h"
#include "revision.h"
#include "bulk-checkin.h"
#include "strvec.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Based on git-am.sh by Junio C Hamano.
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
Expand Down Expand Up @@ -38,7 +39,6 @@
#include "string-list.h"
#include "pager.h"
#include "path.h"
#include "repository.h"
#include "pretty.h"

/**
Expand Down
2 changes: 2 additions & 0 deletions builtin/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* Copyright (C) 2006 Ryan Anderson
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "builtin.h"
#include "strvec.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "gettext.h"
#include "repository.h"
#include "hash.h"
#include "apply.h"

Expand Down
2 changes: 1 addition & 1 deletion builtin/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "archive.h"
#include "gettext.h"
#include "transport.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"

static void create_output_file(const char *output_file)
{
Expand Down
1 change: 1 addition & 0 deletions builtin/bisect.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "copy.h"
#include "environment.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
* Copyright (c) 2006, 2014 by its authors
* See COPYING for licensing conditions
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "color.h"
#include "builtin.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "repository.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 2006 Kristian Høgsberg <[email protected]>
* Based on git-branch.sh by Junio C Hamano.
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "color.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/bugreport.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "editor.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/bundle.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
#include "setup.h"
#include "strvec.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
#include "bundle.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "convert.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/check-attr.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "attr.h"
#include "environment.h"
#include "gettext.h"
#include "object-name.h"
#include "quote.h"
#include "repository.h"
#include "setup.h"
#include "parse-options.h"
#include "write-or-die.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/check-ignore.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
#include "quote.h"
#include "pathspec.h"
#include "parse-options.h"
#include "repository.h"
#include "submodule.h"
#include "write-or-die.h"

Expand Down
1 change: 1 addition & 0 deletions builtin/check-mailmap.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/check-ref-format.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* GIT - The information manager from hell
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "refs.h"
#include "setup.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/checkout--worker.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "entry.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* Copyright (C) 2005 Linus Torvalds
*
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "lockfile.h"
#include "quote.h"
#include "repository.h"
#include "cache-tree.h"
#include "parse-options.h"
#include "entry.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "advice.h"
#include "branch.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Based on git-clean.sh by Pavel Roskin
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "config.h"
Expand All @@ -14,7 +14,6 @@
#include "parse-options.h"
#include "path.h"
#include "read-cache-ll.h"
#include "repository.h"
#include "setup.h"
#include "string-list.h"
#include "quote.h"
Expand Down
3 changes: 2 additions & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*
* Clone a repository into a different directory that does not yet exist.
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"

#include "abspath.h"
#include "advice.h"
#include "config.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/column.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/commit-graph.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "commit.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "parse-options.h"
#include "repository.h"
#include "commit-graph.h"
#include "object-store-ll.h"
#include "progress.h"
Expand Down
3 changes: 2 additions & 1 deletion builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "repository.h"

#include "commit.h"
#include "parse-options.h"

Expand Down
2 changes: 1 addition & 1 deletion builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 2007 Kristian Høgsberg <[email protected]>
* Based on git-commit.sh by Junio C Hamano and Linus Torvalds
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "advice.h"
#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/config.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "color.h"
#include "editor.h"
#include "environment.h"
#include "repository.h"
#include "gettext.h"
#include "ident.h"
#include "parse-options.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/count-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
*
* Copyright (c) 2006 Junio C Hamano
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "path.h"
#include "repository.h"
#include "parse-options.h"
#include "quote.h"
#include "packfile.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/credential-cache--daemon.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/credential-cache.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "credential.h"
#include "gettext.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/credential-store.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "gettext.h"
Expand Down
2 changes: 2 additions & 0 deletions builtin/credential.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "credential.h"
#include "builtin.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/describe.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "environment.h"
Expand Down
1 change: 1 addition & 0 deletions builtin/diagnose.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
#include "preload-index.h"
#include "repository.h"
#include "revision.h"

static const char diff_files_usage[] =
Expand Down
2 changes: 1 addition & 1 deletion builtin/diff-index.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
#include "preload-index.h"
#include "repository.h"
#include "revision.h"
#include "setup.h"

Expand Down
2 changes: 1 addition & 1 deletion builtin/diff-tree.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "diff.h"
Expand All @@ -6,7 +7,6 @@
#include "hex.h"
#include "log-tree.h"
#include "read-cache-ll.h"
#include "repository.h"
#include "revision.h"
#include "tmp-objdir.h"
#include "tree.h"
Expand Down
2 changes: 1 addition & 1 deletion builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "config.h"
#include "ewah/ewok.h"
Expand Down
3 changes: 2 additions & 1 deletion builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*
* Copyright (C) 2016 Johannes Schindelin
*/

#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"

#include "abspath.h"
#include "config.h"
#include "copy.h"
Expand Down
Loading

0 comments on commit 03eae9a

Please sign in to comment.