git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Drew Northup <n1xim.email@gmail.com>
To: git@vger.kernel.org
Cc: Jonas Fonseca <fonseca@diku.dk>, Drew Northup <n1xim.email@gmail.com>
Subject: [PATCH V2] TIG: Fix to reinstate proper operation with no arguments
Date: Wed, 24 Jul 2013 08:50:27 -0400	[thread overview]
Message-ID: <1374670227-15677-1-git-send-email-n1xim.email@gmail.com> (raw)
In-Reply-To: <51EFC8B1.20405@gmail.com>

Since c7d67ab running "tig" with no options has failed with the
error "tig: No revisions match the given arguments." This was due
to a change in how the arguments for the back-end git call was
being constructed. This change caused the blank field left in
place of "(encoding_arg)" when it is empty to not overwrite
"buf" which then caused the value in "buf" to be copied into
dst_argv twice. The resulting git command failed if there was no
available revision named "log" as shown in the trace.

>From the TIG_TRACE log:
git log log --no-color --pretty=raw --parents --parents --
fatal: bad revision 'log'

This fix works by properly and fully initializing "buf" before each use.

github issue # 167

Helped-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Drew Northup <n1xim.email@gmail.com>
---

This should apply cleanly to the tig public master whether the
mkstemps() patch I wrote has been applied or not. (As of the time I
am sending this for review I haven't yet applied the latest fix to
my mkstemps() patch that has been submitted for git itself.)

This time, knowing for sure now that format->buf is not being used in
the extant code path for any other purpose, I went ahead and
initialized the whole thing to be sure that we don't find any other
ghosts hiding in that buffer between uses. Just initializing the
first byte fixes the near term problem but does not prevent the buffer
initialization issue that this bug highlighted from rising up again
later on.

 tig.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tig.c b/tig.c
index ba9ba98..c65bc43 100644
--- a/tig.c
+++ b/tig.c
@@ -3104,8 +3104,12 @@ format_expand_arg(struct format_context *format, const char *name)
 static bool
 format_append_arg(struct format_context *format, const char ***dst_argv, const char *arg)
 {
+	int i;
 	format->bufpos = 0;
 
+	for (i = 0; i < SIZEOF_STR; i++)
+		format->buf[i] = 0;
+
 	while (arg) {
 		char *next = strstr(arg, "%(");
 		int len = next ? next - arg : strlen(arg);
-- 
1.8.0

  reply	other threads:[~2013-07-24 12:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18  4:51 [PATCH] TIG: Fix to reinstate proper operation with no arguments Drew Northup
2013-07-18 13:30 ` Drew Northup
2013-07-19  4:07   ` Jonas Fonseca
2013-07-19 11:55     ` Drew Northup
2013-07-24 12:29     ` Drew Northup
2013-07-24 12:50       ` Drew Northup [this message]
2013-07-29  1:23         ` [PATCH V2] " Jonas Fonseca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374670227-15677-1-git-send-email-n1xim.email@gmail.com \
    --to=n1xim.email@gmail.com \
    --cc=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).