Re: [PATCH][RFC] read-cache: read_index_from() accepts repo as arg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux