git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Kapil Jain <jkapil.cs@gmail.com>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de,
	pclouds@gmail.com, t.gummerer@gmail.com
Subject: Re: [PATCH][RFC] read-cache: read_index_from() accepts repo as arg
Date: Mon, 8 Apr 2019 19:07:49 -0700	[thread overview]
Message-ID: <20190409020749.GC81620@Taylors-MBP.hsd1.wa.comcast.net> (raw)
In-Reply-To: <20190407073712.1642-1-jkapil.cs@gmail.com>

Hi Kapil,

On Sun, Apr 07, 2019 at 01:07:12PM +0530, Kapil Jain wrote:
> Signed-off-by: Kapil Jain <jkapil.cs@gmail.com>
> ---
>
> In read-cache, the read_index_from() function had a TODO task,
> this patch completes that. There are some other functions in the same file
> where this exact TODO needs to be done, will proceed to do them once this patch is accepted.
>
> running test gave 256 not okays, each had a label as `# TODO known breakage`, which i think
> are not concerned to this patch.

Please make sure to wrap your commit messages at 72 characters per-line.
Incidentally, I just wrote another email about this same topic [1],
which has some good advice for how to do this in an automated way.

>  apply.c            | 2 +-
>  builtin/worktree.c | 2 +-
>  cache-tree.c       | 2 +-
>  cache.h            | 4 ++--
>  read-cache.c       | 4 ++--
>  repository.c       | 2 +-
>  revision.c         | 2 +-
>  7 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index f15afa9f6a..3b4d128149 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -4021,7 +4021,7 @@ static int read_apply_cache(struct apply_state *state)
>  {
>  	if (state->index_file)
>  		return read_index_from(state->repo->index, state->index_file,
> -				       get_git_dir());
> +				       get_git_dir(), state->repo);
>  	else
>  		return repo_read_index(state->repo);
>  }
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> index 6cc094a453..874adebd2c 100644
> --- a/builtin/worktree.c
> +++ b/builtin/worktree.c
> @@ -737,7 +737,7 @@ static void validate_no_submodules(const struct worktree *wt)
>  		 */
>  		found_submodules = 1;
>  	} else if (read_index_from(&istate, worktree_git_path(wt, "index"),
> -				   get_worktree_git_dir(wt)) > 0) {
> +				   get_worktree_git_dir(wt), the_repository) > 0) {
>  		for (i = 0; i < istate.cache_nr; i++) {
>  			struct cache_entry *ce = istate.cache[i];
>  			int err;
> diff --git a/cache-tree.c b/cache-tree.c
> index b13bfaf71e..84f19b224e 100644
> --- a/cache-tree.c
> +++ b/cache-tree.c
> @@ -616,7 +616,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
>
>  	hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
>
> -	entries = read_index_from(index_state, index_path, get_git_dir());
> +	entries = read_index_from(index_state, index_path, get_git_dir(), the_repository);
>  	if (entries < 0) {
>  		ret = WRITE_TREE_UNREADABLE_INDEX;
>  		goto out;
> diff --git a/cache.h b/cache.h
> index ac92421f3a..3850c82fc9 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -420,7 +420,7 @@ extern struct index_state the_index;
>  #define active_cache_tree (the_index.cache_tree)
>
>  #define read_cache() repo_read_index(the_repository)
> -#define read_cache_from(path) read_index_from(&the_index, (path), (get_git_dir()))
> +#define read_cache_from(path) read_index_from(&the_index, (path), (get_git_dir()), the_repository)
>  #define read_cache_preload(pathspec) repo_read_index_preload(the_repository, (pathspec), 0)
>  #define is_cache_unborn() is_index_unborn(&the_index)
>  #define read_cache_unmerged() repo_read_index_unmerged(the_repository)
> @@ -678,7 +678,7 @@ extern void preload_index(struct index_state *index,
>  extern int do_read_index(struct index_state *istate, const char *path,
>  			 int must_exist); /* for testting only! */
>  extern int read_index_from(struct index_state *, const char *path,
> -			   const char *gitdir);
> +			   const char *gitdir, const struct repository *repo);
>  extern int is_index_unborn(struct index_state *);
>
>  /* For use with `write_locked_index()`. */
> diff --git a/read-cache.c b/read-cache.c
> index 4dc6de1b55..0444703284 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -2256,7 +2256,7 @@ static void freshen_shared_index(const char *shared_index, int warn)
>  }
>
>  int read_index_from(struct index_state *istate, const char *path,
> -		    const char *gitdir)
> +		    const char *gitdir, const struct repository *repo)
>  {
>  	struct split_index *split_index;
>  	int ret;
> @@ -2292,7 +2292,7 @@ int read_index_from(struct index_state *istate, const char *path,
>  		split_index->base = xcalloc(1, sizeof(*split_index->base));
>
>  	base_oid_hex = oid_to_hex(&split_index->base_oid);
> -	base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
> +	base_path = xstrfmt("%s/sharedindex.%s", repo->gitdir, base_oid_hex);
>  	trace2_region_enter_printf("index", "shared/do_read_index",
>  				   the_repository, "%s", base_path);
>  	ret = do_read_index(split_index->base, base_path, 1);
> diff --git a/repository.c b/repository.c
> index 682c239fe3..8ac2b65f61 100644
> --- a/repository.c
> +++ b/repository.c
> @@ -264,7 +264,7 @@ int repo_read_index(struct repository *repo)
>  	if (!repo->index)
>  		repo->index = xcalloc(1, sizeof(*repo->index));
>
> -	return read_index_from(repo->index, repo->index_file, repo->gitdir);
> +	return read_index_from(repo->index, repo->index_file, repo->gitdir, repo);
>  }
>
>  int repo_hold_locked_index(struct repository *repo,
> diff --git a/revision.c b/revision.c
> index eb8e51bc63..247a4d5704 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1556,7 +1556,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
>
>  		if (read_index_from(&istate,
>  				    worktree_git_path(wt, "index"),
> -				    get_worktree_git_dir(wt)) > 0)
> +				    get_worktree_git_dir(wt), the_repository) > 0)
>  			do_add_index_objects_to_pending(revs, &istate, flags);
>  		discard_index(&istate);
>  	}
> --
> 2.20.1
>
Thanks,
Taylor

[1]: https://public-inbox.org/git/20190409020004.GA81620@Taylors-MBP.hsd1.wa.comcast.net/

      parent reply	other threads:[~2019-04-09  2:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-07  7:37 [PATCH][RFC] read-cache: read_index_from() accepts repo as arg Kapil Jain
2019-04-07 10:00 ` Duy Nguyen
2019-04-07 10:19   ` Duy Nguyen
2019-04-09  2:07 ` Taylor Blau [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190409020749.GC81620@Taylors-MBP.hsd1.wa.comcast.net \
    --to=me@ttaylorr.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=jkapil.cs@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=t.gummerer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).