* [PATCH 09/10] bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES"
@ 2009-03-26 4:55 Christian Couder
2009-03-26 6:49 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2009-03-26 4:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
This is needed because "git bisect--helper" must read bisect paths
in "$GIT_DIR/BISECT_NAMES", so that a bisection can be performed only
on commits that touches paths in this file.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 47 insertions(+), 9 deletions(-)
diff --git a/bisect.c b/bisect.c
index ce62696..a6fd826 100644
--- a/bisect.c
+++ b/bisect.c
@@ -4,6 +4,7 @@
#include "revision.h"
#include "refs.h"
#include "list-objects.h"
+#include "quote.h"
#include "bisect.h"
@@ -424,6 +425,33 @@ static int read_bisect_refs(void)
return for_each_bisect_ref(register_ref, NULL);
}
+void read_bisect_paths()
+{
+ struct strbuf str = STRBUF_INIT;
+ const char *filename = git_path("BISECT_NAMES");
+ FILE *fp = fp = fopen(filename, "r");
+
+ if (!fp)
+ die("Could not open file '%s': %s", filename, strerror(errno));
+
+ while (strbuf_getline(&str, fp, '\n') != EOF) {
+ char *quoted, *dequoted;
+ strbuf_trim(&str);
+ quoted = strbuf_detach(&str, NULL);
+ if (!*quoted)
+ continue;
+ dequoted = sq_dequote(quoted);
+ if (!dequoted)
+ die("Badly quoted content in file '%s': %s",
+ filename, quoted);
+ ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
+ rev_argv[rev_argv_nr++] = dequoted;
+ }
+
+ strbuf_release(&str);
+ fclose(fp);
+}
+
static int skipcmp(const void *a, const void *b)
{
return hashcmp(a, b);
@@ -485,14 +513,11 @@ struct commit_list *filter_skipped(struct commit_list *list,
return filtered;
}
-int bisect_next_vars(const char *prefix)
+static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
{
- struct rev_info revs;
- int reaches = 0, all = 0;
-
- init_revisions(&revs, prefix);
- revs.abbrev = 0;
- revs.commit_format = CMIT_FMT_UNSPECIFIED;
+ init_revisions(revs, prefix);
+ revs->abbrev = 0;
+ revs->commit_format = CMIT_FMT_UNSPECIFIED;
/* argv[0] will be ignored by setup_revisions */
ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
@@ -504,9 +529,22 @@ int bisect_next_vars(const char *prefix)
ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
rev_argv[rev_argv_nr++] = xstrdup("--");
- setup_revisions(rev_argv_nr, rev_argv, &revs, NULL);
+ read_bisect_paths();
+
+ ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
+ rev_argv[rev_argv_nr++] = NULL;
+
+ setup_revisions(rev_argv_nr, rev_argv, revs, NULL);
+
+ revs->limited = 1;
+}
+
+int bisect_next_vars(const char *prefix)
+{
+ struct rev_info revs;
+ int reaches = 0, all = 0;
- revs.limited = 1;
+ bisect_rev_setup(&revs, prefix);
if (prepare_revision_walk(&revs))
die("revision walk setup failed");
--
1.6.2.1.317.g3d804
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 09/10] bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES"
2009-03-26 4:55 [PATCH 09/10] bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES" Christian Couder
@ 2009-03-26 6:49 ` Junio C Hamano
2009-03-27 0:18 ` Christian Couder
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-03-26 6:49 UTC (permalink / raw)
To: Christian Couder; +Cc: git, John Tapsell, Johannes Schindelin
Christian Couder <chriscool@tuxfamily.org> writes:
> This is needed because "git bisect--helper" must read bisect paths
> in "$GIT_DIR/BISECT_NAMES", so that a bisection can be performed only
> on commits that touches paths in this file.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Again, very nice.
> bisect.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++---------
> 1 files changed, 47 insertions(+), 9 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index ce62696..a6fd826 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -4,6 +4,7 @@
> #include "revision.h"
> #include "refs.h"
> #include "list-objects.h"
> +#include "quote.h"
> #include "bisect.h"
>
>
> @@ -424,6 +425,33 @@ static int read_bisect_refs(void)
> return for_each_bisect_ref(register_ref, NULL);
> }
>
> +void read_bisect_paths()
> +{
> + struct strbuf str = STRBUF_INIT;
> + const char *filename = git_path("BISECT_NAMES");
> + FILE *fp = fp = fopen(filename, "r");
s/= fp //;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 09/10] bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES"
2009-03-26 6:49 ` Junio C Hamano
@ 2009-03-27 0:18 ` Christian Couder
0 siblings, 0 replies; 3+ messages in thread
From: Christian Couder @ 2009-03-27 0:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
Le jeudi 26 mars 2009, Junio C Hamano a écrit :
> Christian Couder <chriscool@tuxfamily.org> writes:
> > This is needed because "git bisect--helper" must read bisect paths
> > in "$GIT_DIR/BISECT_NAMES", so that a bisection can be performed only
> > on commits that touches paths in this file.
> >
> > Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>
> Again, very nice.
Thanks, but I found a big bug in this patch.
It doesn't work when there is more than one path in "$GIT_DIR/BISECT_NAMES"
because they are all on the same line, not on different lines.
I will try to fix it soon and provide some test cases.
Best regards,
Christian.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-27 0:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-26 4:55 [PATCH 09/10] bisect: implement "read_bisect_paths" to read paths in "$GIT_DIR/BISECT_NAMES" Christian Couder
2009-03-26 6:49 ` Junio C Hamano
2009-03-27 0:18 ` Christian Couder
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).