Skip to content

Commit

Permalink
Merge branch 'mh/ref-api-lazy-loose'
Browse files Browse the repository at this point in the history
Refs API is updated to lazily read sub-hierarchies of refs/ namespace,
so that we do not have to grab everything from the filesystem when we
are only interested in listing branches, for example.

By Michael Haggerty (17) and Junio C Hamano (1)
* mh/ref-api-lazy-loose:
  refs: fix find_containing_dir() regression
  refs: read loose references lazily
  read_loose_refs(): eliminate ref_cache argument
  struct ref_dir: store a reference to the enclosing ref_cache
  search_for_subdir(): return (ref_dir *) instead of (ref_entry *)
  get_ref_dir(): add function for getting a ref_dir from a ref_entry
  read_loose_refs(): rename function from get_ref_dir()
  refs: wrap top-level ref_dirs in ref_entries
  find_containing_dir(): use strbuf in implementation of this function
  bisect: copy filename string obtained from git_path()
  do_for_each_reflog(): use a strbuf to hold logfile name
  do_for_each_reflog(): return early on error
  get_ref_dir(): take the containing directory as argument
  refs.c: extract function search_for_subdir()
  get_ref_dir(): require that the dirname argument ends in '/'
  get_ref_dir(): rename "base" parameter to "dirname"
  get_ref_dir(): use a strbuf to hold refname
  get_ref_dir(): return early if directory cannot be read
  • Loading branch information
Junio C Hamano committed May 10, 2012
2 parents 2c78c91 + 663c129 commit aa6912b
Show file tree
Hide file tree
Showing 2 changed files with 247 additions and 137 deletions.
8 changes: 5 additions & 3 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)
*/
static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
{
const char *filename = git_path("BISECT_ANCESTORS_OK");
char *filename = xstrdup(git_path("BISECT_ANCESTORS_OK"));
struct stat st;
int fd;

Expand All @@ -842,11 +842,11 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)

/* Check if file BISECT_ANCESTORS_OK exists. */
if (!stat(filename, &st) && S_ISREG(st.st_mode))
return;
goto done;

/* Bisecting with no good rev is ok. */
if (good_revs.nr == 0)
return;
goto done;

/* Check if all good revs are ancestor of the bad rev. */
if (check_ancestors(prefix))
Expand All @@ -859,6 +859,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
filename, strerror(errno));
else
close(fd);
done:
free(filename);
}

/*
Expand Down
Loading

0 comments on commit aa6912b

Please sign in to comment.