git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix git alias
@ 2006-06-14 13:01 Junio C Hamano
  2006-06-14 13:14 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-06-14 13:01 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

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;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix git alias
  2006-06-14 13:01 [PATCH] fix git alias Junio C Hamano
@ 2006-06-14 13:14 ` Johannes Schindelin
  2006-06-14 13:38   ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2006-06-14 13:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Wed, 14 Jun 2006, Junio C Hamano wrote:

>  * 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".

Of course, I tested it only with links... (ln git git-l). Thanks.

>    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.

I will do that.

Note that I have a mmap()ed version in the pipeline. I just wanted to wait 
with that until I manage to implement your cool idea about config 
rewriting. Obviously, this mmap()ed version does not have this problem.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix git alias
  2006-06-14 13:14 ` Johannes Schindelin
@ 2006-06-14 13:38   ` Johannes Schindelin
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2006-06-14 13:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Wed, 14 Jun 2006, Johannes Schindelin wrote:

> >    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.
> 
> I will do that.

I cannot reproduce, sorry. Valgrind says some objects are not released, 
but I cannot find another error. That's with 'next'.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-06-14 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-14 13:01 [PATCH] fix git alias Junio C Hamano
2006-06-14 13:14 ` Johannes Schindelin
2006-06-14 13:38   ` Johannes Schindelin

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).