git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: [PATCH] fix git alias
Date: Wed, 14 Jun 2006 06:01:05 -0700	[thread overview]
Message-ID: <7vu06nevse.fsf@assigned-by-dhcp.cox.net> (raw)

When extra command line arguments are given to a command that
was alias-expanded, the code generated a wrong argument list,
leaving the original alias in the result, and forgetting to
terminate the new argv list.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * This would make "git l -n 4" work when you have "alias.l =
   log -M" in your configuration.  The original code generated
   an equivalent of "git log -M l -n 4".

   There is another more grave problem I seem to be hitting but
   haven't figured out (and will probably not figure out while
   away); I'd appreciate if you can track it down.  With
   "alias.wh = whatchanged --patch-with-stat", "git wh HEAD --
   mailinfo.c" segfaults at fclose() in git_config_from_file()
   when it reads the configuration for the second time (the
   first time being getting the alias).  The second call comes
   via init_revisions() calling setup_git_directory().  Oddly
   I do not seem to be able to reproduce this segfault on amd64.

diff --git a/git.c b/git.c
index 9469d44..329ebec 100644
--- a/git.c
+++ b/git.c
@@ -122,9 +122,9 @@ static int handle_alias(int *argcp, cons
 			/* insert after command name */
 			if (*argcp > 1) {
 				new_argv = realloc(new_argv, sizeof(char*) *
-						(count + *argcp - 1));
-				memcpy(new_argv + count, *argv, sizeof(char*) *
-						(*argcp - 1));
+						   (count + *argcp));
+				memcpy(new_argv + count, *argv + 1,
+				       sizeof(char*) * *argcp);
 			}
 
 			*argv = new_argv;

             reply	other threads:[~2006-06-14 13:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-14 13:01 Junio C Hamano [this message]
2006-06-14 13:14 ` [PATCH] fix git alias Johannes Schindelin
2006-06-14 13:38   ` Johannes Schindelin

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=7vu06nevse.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=Johannes.Schindelin@gmx.de \
    --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).