* [PATCH] Fix git-runstatus for repositories containing a file named HEAD
@ 2006-11-05 21:52 Rocco Rutte
2006-11-05 22:22 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Rocco Rutte @ 2006-11-05 21:52 UTC (permalink / raw)
To: git; +Cc: Rocco Rutte
The wt_status_print_updated() and wt_status_print_untracked() routines
call setup_revisions() with 'HEAD' being the reference to the tip of the
current branch. However, setup_revisions() gets confused if the branch
also contains a file named 'HEAD' resulting in a fatal error.
The fix is to append the '--' delimiter to the setup_revisions() call so
that it knows for sure that the 'HEAD' argument is a revision and not a
filename.
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
---
wt-status.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 7dd6857..7c0dbdb 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -154,10 +154,10 @@ void wt_status_print_initial(struct wt_s
static void wt_status_print_updated(struct wt_status *s)
{
struct rev_info rev;
- const char *argv[] = { NULL, NULL, NULL };
+ const char *argv[] = { NULL, NULL, "--", NULL };
argv[1] = s->reference;
init_revisions(&rev, NULL);
- setup_revisions(2, argv, &rev, NULL);
+ setup_revisions(3, argv, &rev, NULL);
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_print_updated_cb;
rev.diffopt.format_callback_data = s;
@@ -225,10 +225,10 @@ static void wt_status_print_untracked(co
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
- const char *argv[] = { NULL, NULL, NULL };
+ const char *argv[] = { NULL, NULL, "--", NULL };
argv[1] = s->reference;
init_revisions(&rev, NULL);
- setup_revisions(2, argv, &rev, NULL);
+ setup_revisions(3, argv, &rev, NULL);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
run_diff_index(&rev, 1);
--
1.4.3.4.g50f39-dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix git-runstatus for repositories containing a file named HEAD
2006-11-05 21:52 [PATCH] Fix git-runstatus for repositories containing a file named HEAD Rocco Rutte
@ 2006-11-05 22:22 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2006-11-05 22:22 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Rocco Rutte
On Sun, Nov 05, 2006 at 09:52:50PM +0000, Rocco Rutte wrote:
> The wt_status_print_updated() and wt_status_print_untracked() routines
> call setup_revisions() with 'HEAD' being the reference to the tip of the
> current branch. However, setup_revisions() gets confused if the branch
> also contains a file named 'HEAD' resulting in a fatal error.
Ack. This is definitely a bug, and the patch fixes it. I wonder if it
would be slightly more readable to simply get rid of the argv nonsense.
Junio, please apply whichever you find more readable.
-- >8 --
The wt_status_print_updated() and wt_status_print_untracked() routines
call setup_revisions() with 'HEAD' being the reference to the tip of the
current branch. However, setup_revisions() gets confused if the branch
also contains a file named 'HEAD' resulting in a fatal error.
Instead, don't pass an argv to setup_revisions() at all; simply give it no
arguments, and make 'HEAD' the default revision.
Bug noticed by Rocco Rutte <pdmef@gmx.net>.
Signed-off-by: Jeff King <peff@peff.net>
---
wt-status.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 7dd6857..9692dfa 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -154,10 +154,8 @@ void wt_status_print_initial(struct wt_s
static void wt_status_print_updated(struct wt_status *s)
{
struct rev_info rev;
- const char *argv[] = { NULL, NULL, NULL };
- argv[1] = s->reference;
init_revisions(&rev, NULL);
- setup_revisions(2, argv, &rev, NULL);
+ setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_print_updated_cb;
rev.diffopt.format_callback_data = s;
@@ -168,9 +166,8 @@ static void wt_status_print_updated(stru
static void wt_status_print_changed(struct wt_status *s)
{
struct rev_info rev;
- const char *argv[] = { NULL, NULL };
init_revisions(&rev, "");
- setup_revisions(1, argv, &rev, NULL);
+ setup_revisions(0, NULL, &rev, NULL);
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_print_changed_cb;
rev.diffopt.format_callback_data = s;
@@ -225,10 +222,8 @@ static void wt_status_print_untracked(co
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
- const char *argv[] = { NULL, NULL, NULL };
- argv[1] = s->reference;
init_revisions(&rev, NULL);
- setup_revisions(2, argv, &rev, NULL);
+ setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
run_diff_index(&rev, 1);
--
1.4.3.3.ga02d-dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-11-05 22:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-05 21:52 [PATCH] Fix git-runstatus for repositories containing a file named HEAD Rocco Rutte
2006-11-05 22:22 ` Jeff King
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).