{"thread":{"id":"43543","subject":"[PATCH] Fix git-runstatus for repositories containing a file named HEAD","startedAt":"2006-11-05T21:52:50Z","lastAt":"2006-11-05T22:22:15Z","messageCount":2,"participants":["Rocco Rutte","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295382","messageId":"11627635702846-git-send-email-pdmef@gmx.net","threadId":"43543","inReplyTo":null,"subject":"[PATCH] Fix git-runstatus for repositories containing a file named HEAD","fromName":"Rocco Rutte","fromEmail":"pdmef@gmx.net","sentAt":"2006-11-05T21:52:50Z","receivedAt":"2006-11-05T21:52:50Z","isPatch":true,"sender":{"key":"pdmef@gmx.net","avatar":null},"body":"The wt_status_print_updated() and wt_status_print_untracked() routines\ncall setup_revisions() with 'HEAD' being the reference to the tip of the\ncurrent branch. However, setup_revisions() gets confused if the branch\nalso contains a file named 'HEAD' resulting in a fatal error.\n\nThe fix is to append the '--' delimiter to the setup_revisions() call so\nthat it knows for sure that the 'HEAD' argument is a revision and not a\nfilename.\n\nSigned-off-by: Rocco Rutte <pdmef@gmx.net>\n---\n wt-status.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 7dd6857..7c0dbdb 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -154,10 +154,10 @@ void wt_status_print_initial(struct wt_s\n static void wt_status_print_updated(struct wt_status *s)\n {\n \tstruct rev_info rev;\n-\tconst char *argv[] = { NULL, NULL, NULL };\n+\tconst char *argv[] = { NULL, NULL, \"--\", NULL };\n \targv[1] = s->reference;\n \tinit_revisions(&rev, NULL);\n-\tsetup_revisions(2, argv, &rev, NULL);\n+\tsetup_revisions(3, argv, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_print_updated_cb;\n \trev.diffopt.format_callback_data = s;\n@@ -225,10 +225,10 @@ static void wt_status_print_untracked(co\n static void wt_status_print_verbose(struct wt_status *s)\n {\n \tstruct rev_info rev;\n-\tconst char *argv[] = { NULL, NULL, NULL };\n+\tconst char *argv[] = { NULL, NULL, \"--\", NULL };\n \targv[1] = s->reference;\n \tinit_revisions(&rev, NULL);\n-\tsetup_revisions(2, argv, &rev, NULL);\n+\tsetup_revisions(3, argv, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_PATCH;\n \trev.diffopt.detect_rename = 1;\n \trun_diff_index(&rev, 1);\n-- \n1.4.3.4.g50f39-dirty\n"},{"id":"296277","messageId":"20061105222215.GA29042@coredump.intra.peff.net","threadId":"43543","inReplyTo":"11627635702846-git-send-email-pdmef@gmx.net","subject":"Re: [PATCH] Fix git-runstatus for repositories containing a file named HEAD","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-11-05T22:22:15Z","receivedAt":"2006-11-05T22:22:15Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 05, 2006 at 09:52:50PM +0000, Rocco Rutte wrote:\n\n> The wt_status_print_updated() and wt_status_print_untracked() routines\n> call setup_revisions() with 'HEAD' being the reference to the tip of the\n> current branch. However, setup_revisions() gets confused if the branch\n> also contains a file named 'HEAD' resulting in a fatal error.\n\nAck. This is definitely a bug, and the patch fixes it. I wonder if it\nwould be slightly more readable to simply get rid of the argv nonsense.\nJunio, please apply whichever you find more readable.\n\n-- >8 --\nThe wt_status_print_updated() and wt_status_print_untracked() routines\ncall setup_revisions() with 'HEAD' being the reference to the tip of the\ncurrent branch. However, setup_revisions() gets confused if the branch\nalso contains a file named 'HEAD' resulting in a fatal error.\n\nInstead, don't pass an argv to setup_revisions() at all; simply give it no\narguments, and make 'HEAD' the default revision.\n\nBug noticed by Rocco Rutte <pdmef@gmx.net>.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n wt-status.c |   11 +++--------\n 1 files changed, 3 insertions(+), 8 deletions(-)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 7dd6857..9692dfa 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -154,10 +154,8 @@ void wt_status_print_initial(struct wt_s\n static void wt_status_print_updated(struct wt_status *s)\n {\n \tstruct rev_info rev;\n-\tconst char *argv[] = { NULL, NULL, NULL };\n-\targv[1] = s->reference;\n \tinit_revisions(&rev, NULL);\n-\tsetup_revisions(2, argv, &rev, NULL);\n+\tsetup_revisions(0, NULL, &rev, s->reference);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_print_updated_cb;\n \trev.diffopt.format_callback_data = s;\n@@ -168,9 +166,8 @@ static void wt_status_print_updated(stru\n static void wt_status_print_changed(struct wt_status *s)\n {\n \tstruct rev_info rev;\n-\tconst char *argv[] = { NULL, NULL };\n \tinit_revisions(&rev, \"\");\n-\tsetup_revisions(1, argv, &rev, NULL);\n+\tsetup_revisions(0, NULL, &rev, NULL);\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_print_changed_cb;\n \trev.diffopt.format_callback_data = s;\n@@ -225,10 +222,8 @@ static void wt_status_print_untracked(co\n static void wt_status_print_verbose(struct wt_status *s)\n {\n \tstruct rev_info rev;\n-\tconst char *argv[] = { NULL, NULL, NULL };\n-\targv[1] = s->reference;\n \tinit_revisions(&rev, NULL);\n-\tsetup_revisions(2, argv, &rev, NULL);\n+\tsetup_revisions(0, NULL, &rev, s->reference);\n \trev.diffopt.output_format |= DIFF_FORMAT_PATCH;\n \trev.diffopt.detect_rename = 1;\n \trun_diff_index(&rev, 1);\n-- \n1.4.3.3.ga02d-dirty\n"}]}