Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit aa6912b

Browse files
committed
Merge branch 'mh/ref-api-lazy-loose'
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
2 parents 2c78c91 + 663c129 commit aa6912b

File tree

2 files changed

+247
-137
lines changed

2 files changed

+247
-137
lines changed

bisect.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)
833833
*/
834834
static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
835835
{
836-
const char *filename = git_path("BISECT_ANCESTORS_OK");
836+
char *filename = xstrdup(git_path("BISECT_ANCESTORS_OK"));
837837
struct stat st;
838838
int fd;
839839

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

843843
/* Check if file BISECT_ANCESTORS_OK exists. */
844844
if (!stat(filename, &st) && S_ISREG(st.st_mode))
845-
return;
845+
goto done;
846846

847847
/* Bisecting with no good rev is ok. */
848848
if (good_revs.nr == 0)
849-
return;
849+
goto done;
850850

851851
/* Check if all good revs are ancestor of the bad rev. */
852852
if (check_ancestors(prefix))
@@ -859,6 +859,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
859859
filename, strerror(errno));
860860
else
861861
close(fd);
862+
done:
863+
free(filename);
862864
}
863865

864866
/*

0 commit comments

Comments
 (0)