* [PATCH] bisect: display first bad commit without forking a new process
@ 2009-05-27 5:23 Christian Couder
2009-05-27 19:07 ` Christian Couder
0 siblings, 1 reply; 6+ messages in thread
From: Christian Couder @ 2009-05-27 5:23 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
Previously "git diff-tree --pretty COMMIT" was run using
"run_command_v_opt" to display information about the first bad
commit.
The goal of this patch is to avoid a "fork" and an "exec" call
when displaying that information.
To do that, we manually setup revision information as
"git diff-tree --pretty" would do it, and then use the
"log_tree_commit" function.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/bisect.c b/bisect.c
index c43c120..e94a77b 100644
--- a/bisect.c
+++ b/bisect.c
@@ -7,6 +7,7 @@
#include "quote.h"
#include "sha1-lookup.h"
#include "run-command.h"
+#include "log-tree.h"
#include "bisect.h"
struct sha1_array {
@@ -27,7 +28,6 @@ struct argv_array {
int argv_alloc;
};
-static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL, NULL};
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -816,6 +816,31 @@ static void check_good_are_ancestors_of_bad(const char *prefix)
}
/*
+ * This does "git diff-tree --pretty COMMIT" without one fork+exec.
+ */
+static void show_diff_tree(const char *prefix, struct commit *commit)
+{
+ static struct rev_info opt;
+
+ /* diff-tree init */
+ init_revisions(&opt, prefix);
+ git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+ opt.abbrev = 0;
+ opt.diff = 1;
+
+ /* This is what "--pretty" does */
+ opt.verbose_header = 1;
+ opt.use_terminator = 0;
+ opt.commit_format = CMIT_FMT_DEFAULT;
+
+ /* diff-tree init */
+ if (!opt.diffopt.output_format)
+ opt.diffopt.output_format = DIFF_FORMAT_RAW;
+
+ log_tree_commit(&opt, commit);
+}
+
+/*
* We use the convention that exiting with an exit code 10 means that
* the bisection process finished successfully.
* In this case the calling shell script should exit 0.
@@ -860,8 +885,7 @@ int bisect_next_all(const char *prefix)
if (!hashcmp(bisect_rev, current_bad_sha1)) {
exit_if_skipped_commits(tried, current_bad_sha1);
printf("%s is first bad commit\n", bisect_rev_hex);
- argv_diff_tree[2] = bisect_rev_hex;
- run_command_v_opt(argv_diff_tree, RUN_GIT_CMD);
+ show_diff_tree(prefix, revs.commits->item);
/* This means the bisection process succeeded. */
exit(10);
}
--
1.6.3.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] bisect: display first bad commit without forking a new process
2009-05-27 5:23 Christian Couder
@ 2009-05-27 19:07 ` Christian Couder
2009-05-27 22:38 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Christian Couder @ 2009-05-27 19:07 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
Le Wednesday 27 May 2009, Christian Couder a écrit :
> Previously "git diff-tree --pretty COMMIT" was run using
> "run_command_v_opt" to display information about the first bad
> commit.
>
> The goal of this patch is to avoid a "fork" and an "exec" call
> when displaying that information.
>
> To do that, we manually setup revision information as
> "git diff-tree --pretty" would do it, and then use the
> "log_tree_commit" function.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> bisect.c | 30 +++++++++++++++++++++++++++---
> 1 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index c43c120..e94a77b 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -7,6 +7,7 @@
> #include "quote.h"
> #include "sha1-lookup.h"
> #include "run-command.h"
> +#include "log-tree.h"
> #include "bisect.h"
>
> struct sha1_array {
> @@ -27,7 +28,6 @@ struct argv_array {
> int argv_alloc;
> };
>
> -static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL,
> NULL}; static const char *argv_checkout[] = {"checkout", "-q", NULL,
> "--", NULL}; static const char *argv_show_branch[] = {"show-branch",
> NULL, NULL};
>
> @@ -816,6 +816,31 @@ static void check_good_are_ancestors_of_bad(const
> char *prefix) }
>
> /*
> + * This does "git diff-tree --pretty COMMIT" without one fork+exec.
> + */
> +static void show_diff_tree(const char *prefix, struct commit *commit)
> +{
> + static struct rev_info opt;
Oops, "static" can be removed, it's a copy-paste error, sorry.
Thanks,
Christian.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bisect: display first bad commit without forking a new process
2009-05-27 19:07 ` Christian Couder
@ 2009-05-27 22:38 ` Junio C Hamano
2009-05-28 8:04 ` Andreas Ericsson
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2009-05-27 22:38 UTC (permalink / raw
To: Christian Couder; +Cc: Junio C Hamano, git
Christian Couder <chriscool@tuxfamily.org> writes:
> Le Wednesday 27 May 2009, Christian Couder a écrit :
>> Previously "git diff-tree --pretty COMMIT" was run using
>> "run_command_v_opt" to display information about the first bad
>> commit.
>>
>> The goal of this patch is to avoid a "fork" and an "exec" call
>> when displaying that information.
>>
>> To do that, we manually setup revision information as
>> "git diff-tree --pretty" would do it, and then use the
>> "log_tree_commit" function.
>>
>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>> ---
>> bisect.c | 30 +++++++++++++++++++++++++++---
>> 1 files changed, 27 insertions(+), 3 deletions(-)
>>
>> diff --git a/bisect.c b/bisect.c
>> index c43c120..e94a77b 100644
>> --- a/bisect.c
>> +++ b/bisect.c
>> @@ -816,6 +816,31 @@ static void check_good_are_ancestors_of_bad(const
>> char *prefix) }
>>
>> /*
>> + * This does "git diff-tree --pretty COMMIT" without one fork+exec.
>> + */
>> +static void show_diff_tree(const char *prefix, struct commit *commit)
>> +{
>> + static struct rev_info opt;
>
> Oops, "static" can be removed, it's a copy-paste error, sorry.
Is that "can" or "must"? If the answer is the latter, shouldn't the
function be renamed to make it clear it is a bisect specific thing?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bisect: display first bad commit without forking a new process
2009-05-27 22:38 ` Junio C Hamano
@ 2009-05-28 8:04 ` Andreas Ericsson
2009-05-28 21:20 ` Christian Couder
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Ericsson @ 2009-05-28 8:04 UTC (permalink / raw
To: Junio C Hamano; +Cc: Christian Couder, git
Junio C Hamano wrote:
> Christian Couder <chriscool@tuxfamily.org> writes:
>
>> Le Wednesday 27 May 2009, Christian Couder a écrit :
>>> Previously "git diff-tree --pretty COMMIT" was run using
>>> "run_command_v_opt" to display information about the first bad
>>> commit.
>>>
>>> The goal of this patch is to avoid a "fork" and an "exec" call
>>> when displaying that information.
>>>
>>> To do that, we manually setup revision information as
>>> "git diff-tree --pretty" would do it, and then use the
>>> "log_tree_commit" function.
>>>
>>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
>>> ---
>>> bisect.c | 30 +++++++++++++++++++++++++++---
>>> 1 files changed, 27 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/bisect.c b/bisect.c
>>> index c43c120..e94a77b 100644
>>> --- a/bisect.c
>>> +++ b/bisect.c
>>> @@ -816,6 +816,31 @@ static void check_good_are_ancestors_of_bad(const
>>> char *prefix) }
>>>
>>> /*
>>> + * This does "git diff-tree --pretty COMMIT" without one fork+exec.
>>> + */
>>> +static void show_diff_tree(const char *prefix, struct commit *commit)
>>> +{
>>> + static struct rev_info opt;
>> Oops, "static" can be removed, it's a copy-paste error, sorry.
>
> Is that "can" or "must"? If the answer is the latter, shouldn't the
> function be renamed to make it clear it is a bisect specific thing?
I think he was referring to the 'static' in the variable declarations.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
http://nordicmeetonnagios.op5.org/
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] bisect: display first bad commit without forking a new process
2009-05-28 8:04 ` Andreas Ericsson
@ 2009-05-28 21:20 ` Christian Couder
0 siblings, 0 replies; 6+ messages in thread
From: Christian Couder @ 2009-05-28 21:20 UTC (permalink / raw
To: Andreas Ericsson; +Cc: Junio C Hamano, git
Le Thursday 28 May 2009, Andreas Ericsson a écrit :
> Junio C Hamano wrote:
> > Christian Couder <chriscool@tuxfamily.org> writes:
> >> Le Wednesday 27 May 2009, Christian Couder a écrit :
> >>> Previously "git diff-tree --pretty COMMIT" was run using
> >>> "run_command_v_opt" to display information about the first bad
> >>> commit.
> >>>
> >>> The goal of this patch is to avoid a "fork" and an "exec" call
> >>> when displaying that information.
> >>>
> >>> To do that, we manually setup revision information as
> >>> "git diff-tree --pretty" would do it, and then use the
> >>> "log_tree_commit" function.
> >>>
> >>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> >>> ---
> >>> bisect.c | 30 +++++++++++++++++++++++++++---
> >>> 1 files changed, 27 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/bisect.c b/bisect.c
> >>> index c43c120..e94a77b 100644
> >>> --- a/bisect.c
> >>> +++ b/bisect.c
> >>> @@ -816,6 +816,31 @@ static void
> >>> check_good_are_ancestors_of_bad(const char *prefix) }
> >>>
> >>> /*
> >>> + * This does "git diff-tree --pretty COMMIT" without one fork+exec.
> >>> + */
> >>> +static void show_diff_tree(const char *prefix, struct commit
> >>> *commit) +{
> >>> + static struct rev_info opt;
> >>
> >> Oops, "static" can be removed, it's a copy-paste error, sorry.
> >
> > Is that "can" or "must"? If the answer is the latter, shouldn't the
> > function be renamed to make it clear it is a bisect specific thing?
>
> I think he was referring to the 'static' in the variable declarations.
You are right. I will send a v2 of this patch anyway.
Thanks for this clarification,
Christian.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] bisect: display first bad commit without forking a new process
@ 2009-05-28 21:21 Christian Couder
0 siblings, 0 replies; 6+ messages in thread
From: Christian Couder @ 2009-05-28 21:21 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
Previously "git diff-tree --pretty COMMIT" was run using
"run_command_v_opt" to display information about the first bad
commit.
The goal of this patch is to avoid a "fork" and an "exec" call
when displaying that information.
To do that, we manually setup revision information as
"git diff-tree --pretty" would do it, and then use the
"log_tree_commit" function.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
The only change is that "struct rev_info opt" is not
static anymore.
diff --git a/bisect.c b/bisect.c
index c43c120..edd3cfb 100644
--- a/bisect.c
+++ b/bisect.c
@@ -7,6 +7,7 @@
#include "quote.h"
#include "sha1-lookup.h"
#include "run-command.h"
+#include "log-tree.h"
#include "bisect.h"
struct sha1_array {
@@ -27,7 +28,6 @@ struct argv_array {
int argv_alloc;
};
-static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL, NULL};
static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -816,6 +816,31 @@ static void check_good_are_ancestors_of_bad(const char *prefix)
}
/*
+ * This does "git diff-tree --pretty COMMIT" without one fork+exec.
+ */
+static void show_diff_tree(const char *prefix, struct commit *commit)
+{
+ struct rev_info opt;
+
+ /* diff-tree init */
+ init_revisions(&opt, prefix);
+ git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
+ opt.abbrev = 0;
+ opt.diff = 1;
+
+ /* This is what "--pretty" does */
+ opt.verbose_header = 1;
+ opt.use_terminator = 0;
+ opt.commit_format = CMIT_FMT_DEFAULT;
+
+ /* diff-tree init */
+ if (!opt.diffopt.output_format)
+ opt.diffopt.output_format = DIFF_FORMAT_RAW;
+
+ log_tree_commit(&opt, commit);
+}
+
+/*
* We use the convention that exiting with an exit code 10 means that
* the bisection process finished successfully.
* In this case the calling shell script should exit 0.
@@ -860,8 +885,7 @@ int bisect_next_all(const char *prefix)
if (!hashcmp(bisect_rev, current_bad_sha1)) {
exit_if_skipped_commits(tried, current_bad_sha1);
printf("%s is first bad commit\n", bisect_rev_hex);
- argv_diff_tree[2] = bisect_rev_hex;
- run_command_v_opt(argv_diff_tree, RUN_GIT_CMD);
+ show_diff_tree(prefix, revs.commits->item);
/* This means the bisection process succeeded. */
exit(10);
}
--
1.6.3.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-05-28 21:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-28 21:21 [PATCH] bisect: display first bad commit without forking a new process Christian Couder
-- strict thread matches above, loose matches on Subject: below --
2009-05-27 5:23 Christian Couder
2009-05-27 19:07 ` Christian Couder
2009-05-27 22:38 ` Junio C Hamano
2009-05-28 8:04 ` Andreas Ericsson
2009-05-28 21:20 ` Christian Couder
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).