From: Duy Nguyen <pclouds@gmail.com>
To: Kapil Jain <jkapil.cs@gmail.com>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de, t.gummerer@gmail.com
Subject: Re: [PATCH][RFC] read-cache: read_index_from() accepts repo as arg
Date: Sun, 7 Apr 2019 17:19:38 +0700 [thread overview]
Message-ID: <20190407101938.GA24126@ash> (raw)
In-Reply-To: <20190407100010.GA23427@ash>
On Sun, Apr 07, 2019 at 05:00:11PM +0700, Duy Nguyen wrote:
> So, with something like a patch below (not tested), you should be able
> to write
>
> worktrees = repo_get_worktrees(revs->repo, 0);
> ...
> struct repository *r = repo_worktree_init(wt);
> if (read_index_from(&istate, r->index_file, r) > 0)
> do_add_index_objects_to_pending(revs, &istate, flags);
> repo_clear(r);
Actually it gets better. You can just use repo_read_index()
diff --git a/revision.c b/revision.c
index eb8e51bc63..93fe8bbbfe 100644
--- a/revision.c
+++ b/revision.c
@@ -1546,19 +1546,18 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
if (revs->single_worktree)
return;
- worktrees = get_worktrees(0);
+ worktrees = repo_get_worktrees(revs->repo);
for (p = worktrees; *p; p++) {
+ struct repository repo;
struct worktree *wt = *p;
- struct index_state istate = { NULL };
if (wt->is_current)
continue; /* current index already taken care of */
- if (read_index_from(&istate,
- worktree_git_path(wt, "index"),
- get_worktree_git_dir(wt)) > 0)
- do_add_index_objects_to_pending(revs, &istate, flags);
- discard_index(&istate);
+ repo_worktree_init(repo, revs->repo, wt);
+ if (repo_read_index(repo) > 0)
+ do_add_index_objects_to_pending(revs, repo->index, flags);
+ repo_clear(&repo);
}
free_worktrees(worktrees);
}
--
Duy
next prev parent reply other threads:[~2019-04-07 10:19 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 [this message]
2019-04-09 2:07 ` Taylor Blau
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190407101938.GA24126@ash \
--to=pclouds@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=jkapil.cs@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.
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 NNTP newsgroup(s).