{"thread":{"id":"4508","subject":"[PATCH] fix git alias","startedAt":"2006-06-14T13:01:05Z","lastAt":"2006-06-14T13:38:11Z","messageCount":3,"participants":["Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21781","messageId":"7vu06nevse.fsf@assigned-by-dhcp.cox.net","threadId":"4508","inReplyTo":null,"subject":"[PATCH] fix git alias","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-06-14T13:01:05Z","receivedAt":"2006-06-14T13:01:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When extra command line arguments are given to a command that\nwas alias-expanded, the code generated a wrong argument list,\nleaving the original alias in the result, and forgetting to\nterminate the new argv list.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * This would make \"git l -n 4\" work when you have \"alias.l =\n   log -M\" in your configuration.  The original code generated\n   an equivalent of \"git log -M l -n 4\".\n\n   There is another more grave problem I seem to be hitting but\n   haven't figured out (and will probably not figure out while\n   away); I'd appreciate if you can track it down.  With\n   \"alias.wh = whatchanged --patch-with-stat\", \"git wh HEAD --\n   mailinfo.c\" segfaults at fclose() in git_config_from_file()\n   when it reads the configuration for the second time (the\n   first time being getting the alias).  The second call comes\n   via init_revisions() calling setup_git_directory().  Oddly\n   I do not seem to be able to reproduce this segfault on amd64.\n\ndiff --git a/git.c b/git.c\nindex 9469d44..329ebec 100644\n--- a/git.c\n+++ b/git.c\n@@ -122,9 +122,9 @@ static int handle_alias(int *argcp, cons\n \t\t\t/* insert after command name */\n \t\t\tif (*argcp > 1) {\n \t\t\t\tnew_argv = realloc(new_argv, sizeof(char*) *\n-\t\t\t\t\t\t(count + *argcp - 1));\n-\t\t\t\tmemcpy(new_argv + count, *argv, sizeof(char*) *\n-\t\t\t\t\t\t(*argcp - 1));\n+\t\t\t\t\t\t   (count + *argcp));\n+\t\t\t\tmemcpy(new_argv + count, *argv + 1,\n+\t\t\t\t       sizeof(char*) * *argcp);\n \t\t\t}\n \n \t\t\t*argv = new_argv;\n"},{"id":"21783","messageId":"Pine.LNX.4.63.0606141507420.16802@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4508","inReplyTo":"7vu06nevse.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] fix git alias","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-06-14T13:14:50Z","receivedAt":"2006-06-14T13:14:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Jun 2006, Junio C Hamano wrote:\n\n>  * This would make \"git l -n 4\" work when you have \"alias.l =\n>    log -M\" in your configuration.  The original code generated\n>    an equivalent of \"git log -M l -n 4\".\n\nOf course, I tested it only with links... (ln git git-l). Thanks.\n\n>    There is another more grave problem I seem to be hitting but\n>    haven't figured out (and will probably not figure out while\n>    away); I'd appreciate if you can track it down.  With\n>    \"alias.wh = whatchanged --patch-with-stat\", \"git wh HEAD --\n>    mailinfo.c\" segfaults at fclose() in git_config_from_file()\n>    when it reads the configuration for the second time (the\n>    first time being getting the alias).  The second call comes\n>    via init_revisions() calling setup_git_directory().  Oddly\n>    I do not seem to be able to reproduce this segfault on amd64.\n\nI will do that.\n\nNote that I have a mmap()ed version in the pipeline. I just wanted to wait \nwith that until I manage to implement your cool idea about config \nrewriting. Obviously, this mmap()ed version does not have this problem.\n\nCiao,\nDscho\n"},{"id":"21785","messageId":"Pine.LNX.4.63.0606141536320.17539@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4508","inReplyTo":"Pine.LNX.4.63.0606141507420.16802@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] fix git alias","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-06-14T13:38:11Z","receivedAt":"2006-06-14T13:38:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Jun 2006, Johannes Schindelin wrote:\n\n> >    There is another more grave problem I seem to be hitting but\n> >    haven't figured out (and will probably not figure out while\n> >    away); I'd appreciate if you can track it down.  With\n> >    \"alias.wh = whatchanged --patch-with-stat\", \"git wh HEAD --\n> >    mailinfo.c\" segfaults at fclose() in git_config_from_file()\n> >    when it reads the configuration for the second time (the\n> >    first time being getting the alias).  The second call comes\n> >    via init_revisions() calling setup_git_directory().  Oddly\n> >    I do not seem to be able to reproduce this segfault on amd64.\n> \n> I will do that.\n\nI cannot reproduce, sorry. Valgrind says some objects are not released, \nbut I cannot find another error. That's with 'next'.\n\nCiao,\nDscho\n"}]}