{"thread":{"id":"12420","subject":"[PATCH] Fix make_absolute_path() for parameters without a slash","startedAt":"2008-03-02T07:17:49Z","lastAt":"2008-03-02T07:40:33Z","messageCount":3,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"70591","messageId":"alpine.LSU.1.00.0803020717060.22527@racer.site","threadId":"12420","inReplyTo":null,"subject":"[PATCH] Fix make_absolute_path() for parameters without a slash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-02T07:17:49Z","receivedAt":"2008-03-02T07:17:49Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen passing \"xyz\" to make_absolute_path(), make_absolute_path()\nerroneously tried to chdir(\"xyz\"), and then append \"/xyz\".  Instead,\nskip the chdir() completely when no slash was found.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tI should add a test, but I am simply too tired now.  Will do so \n\ttomorrow.\n\n path.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 4260952..bf3e469 100644\n--- a/path.c\n+++ b/path.c\n@@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)\n \t\t\tif (last_slash) {\n \t\t\t\t*last_slash = '\\0';\n \t\t\t\tlast_elem = xstrdup(last_slash + 1);\n-\t\t\t} else\n+\t\t\t} else {\n+\t\t\t\t*buf = '\\0';\n \t\t\t\tlast_elem = xstrdup(buf);\n+\t\t\t}\n \t\t}\n \n \t\tif (*buf) {\n-- \n1.5.4.3.446.gbe8932\n\n"},{"id":"70595","messageId":"alpine.LSU.1.00.0803020730170.22527@racer.site","threadId":"12420","inReplyTo":"alpine.LSU.1.00.0803020717060.22527@racer.site","subject":"Re: [PATCH] Fix make_absolute_path() for parameters without a slash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-02T07:31:21Z","receivedAt":"2008-03-02T07:31:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 2 Mar 2008, Johannes Schindelin wrote:\n\n> diff --git a/path.c b/path.c\n> index 4260952..bf3e469 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)\n>  \t\t\tif (last_slash) {\n>  \t\t\t\t*last_slash = '\\0';\n>  \t\t\t\tlast_elem = xstrdup(last_slash + 1);\n> -\t\t\t} else\n> +\t\t\t} else {\n> +\t\t\t\t*buf = '\\0';\n>  \t\t\t\tlast_elem = xstrdup(buf);\n\nOh, my.  The *buf = '\\0' must come _after the assignment to last_elem, of \ncourse.\n\nWill stop posting patches for today, and fix tomorrow.\n\nCiao,\nDscho\n\n"},{"id":"70597","messageId":"alpine.LSU.1.00.0803020739530.22527@racer.site","threadId":"12420","inReplyTo":"alpine.LSU.1.00.0803020730170.22527@racer.site","subject":"[PATCH] Fix make_absolute_path() for parameters without a slash","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-02T07:40:33Z","receivedAt":"2008-03-02T07:40:33Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen passing \"xyz\" to make_absolute_path(), make_absolute_path()\nerroneously tried to chdir(\"xyz\"), and then append \"/xyz\".  Instead,\nskip the chdir() completely when no slash was found.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\nOn Sun, 2 Mar 2008, Johannes Schindelin wrote:\n\n> Will stop posting patches for today, and fix tomorrow.\n\nIt was just too embarassing.\n\n path.c           |    4 +++-\n t/t0000-basic.sh |    2 ++\n 2 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 4260952..af27161 100644\n--- a/path.c\n+++ b/path.c\n@@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)\n \t\t\tif (last_slash) {\n \t\t\t\t*last_slash = '\\0';\n \t\t\t\tlast_elem = xstrdup(last_slash + 1);\n-\t\t\t} else\n+\t\t\t} else {\n \t\t\t\tlast_elem = xstrdup(buf);\n+\t\t\t\t*buf = '\\0';\n+\t\t\t}\n \t\t}\n \n \t\tif (*buf) {\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 92de088..27b54cb 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -304,6 +304,8 @@ test_expect_success 'absolute path works as expected' '\n \ttest \"$dir\" = \"$(test-absolute-path $dir2)\" &&\n \tfile=\"$dir\"/index &&\n \ttest \"$file\" = \"$(test-absolute-path $dir2/index)\" &&\n+\tbasename=blub &&\n+\ttest \"$dir/$basename\" = $(cd .git && test-absolute-path $basename) &&\n \tln -s ../first/file .git/syml &&\n \tsym=\"$(cd first; pwd -P)\"/file &&\n \ttest \"$sym\" = \"$(test-absolute-path $dir2/syml)\"\n-- \n1.5.4.3.446.gbe8932\n\n"}]}