{"thread":{"id":"10850","subject":"[PATCH 06/11] Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.","startedAt":"2007-11-13T20:04:55Z","lastAt":"2007-11-15T22:24:52Z","messageCount":35,"participants":["Johannes Sixt","Johannes Schindelin","Junio C Hamano","Robin Rosenberg","Steffen Prohaska"],"isPatch":true,"patchVersion":1,"patchTotal":11},"messages":[{"id":"59716","messageId":"1194984306-3181-1-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":null,"subject":"[PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:04:55Z","receivedAt":"2007-11-13T20:04:55Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"This is a series of smallish, unrelated changes that were necessary\nfor the MinGW port.\n\n[PATCH 01/11] t5300-pack-object.sh: Split the big verify-pack test into\n\tsmaller parts.\n[PATCH 02/11] t7501-commit.sh: Not all seds understand option -i\n[PATCH 03/11] t5302-pack-index: Skip tests of 64-bit offsets if necessary.\n[PATCH 04/11] Skip t3902-quoted.sh if the file system does not support\n\tfunny names.\n\nSome changes to the test suite.\n\n[PATCH 05/11] Use is_absolute_path() in sha1_file.c.\n[PATCH 06/11] Move #include <sys/select.h> and <sys/ioctl.h> to\n\tgit-compat-util.h.\n\nThese two are certainly undisputed.\n\n[PATCH 07/11] builtin run_command: do not exit with -1.\n\nReplaces exit(-1) by exit(255). I don't know if this has any bad\nconsequences on *nix.\n\n[PATCH 08/11] Close files opened by lock_file() before unlinking.\n\nThis one was authored by Dscho. It is a definite MUST on Windows.\n\n[PATCH 09/11] Allow a relative builtin template directory.\n[PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n\tof ETC_GITCONFIG.\n[PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n\nThese need probably some discussion. They avoid that $(prefix) is\nhardcoded and so allows that an arbitrary installation directory.\n\n Makefile               |    5 ++++-\n builtin-config.c       |    4 ++--\n builtin-init-db.c      |   16 +++++++++++++---\n cache.h                |    2 ++\n config.c               |   20 ++++++++++++++++++--\n git-compat-util.h      |    2 ++\n git.c                  |    2 +-\n help.c                 |    1 -\n lockfile.c             |   17 ++++++++++-------\n pager.c                |    2 --\n sha1_file.c            |    8 ++++----\n t/t3902-quoted.sh      |    7 +++++++\n t/t5300-pack-object.sh |   34 ++++++++++++++++++----------------\n t/t5302-pack-index.sh  |   25 +++++++++++++++++++++++--\n t/t7501-commit.sh      |    6 ++++--\n 15 files changed, 108 insertions(+), 43 deletions(-)\n\n-- Hannes\n"},{"id":"59718","messageId":"1194984306-3181-2-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-1-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 01/11] t5300-pack-object.sh: Split the big verify-pack test into smaller parts.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:04:56Z","receivedAt":"2007-11-13T20:04:56Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"This makes it easier to spot which of the tests failed.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n t/t5300-pack-object.sh |   34 ++++++++++++++++++----------------\n 1 files changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex ba7579c..f1106e6 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -187,49 +187,51 @@ test_expect_success \\\n \t\t\ttest-3-${packname_3}.idx'\n \n test_expect_success \\\n-    'corrupt a pack and see if verify catches' \\\n+    'verify-pack catches mismatched .idx and .pack files' \\\n     'cat test-1-${packname_1}.idx >test-3.idx &&\n      cat test-2-${packname_2}.pack >test-3.pack &&\n      if git verify-pack test-3.idx\n      then false\n      else :;\n-     fi &&\n+     fi'\n \n-     : PACK_SIGNATURE &&\n-     cat test-1-${packname_1}.pack >test-3.pack &&\n+test_expect_success \\\n+    'verify-pack catches a corrupted pack signature' \\\n+    'cat test-1-${packname_1}.pack >test-3.pack &&\n      dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&\n      if git verify-pack test-3.idx\n      then false\n      else :;\n-     fi &&\n+     fi'\n \n-     : PACK_VERSION &&\n-     cat test-1-${packname_1}.pack >test-3.pack &&\n+test_expect_success \\\n+    'verify-pack catches a corrupted pack version' \\\n+    'cat test-1-${packname_1}.pack >test-3.pack &&\n      dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&\n      if git verify-pack test-3.idx\n      then false\n      else :;\n-     fi &&\n+     fi'\n \n-     : TYPE/SIZE byte of the first packed object data &&\n-     cat test-1-${packname_1}.pack >test-3.pack &&\n+test_expect_success \\\n+    'verify-pack catches a corrupted type/size of the 1st packed object data' \\\n+    'cat test-1-${packname_1}.pack >test-3.pack &&\n      dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&\n      if git verify-pack test-3.idx\n      then false\n      else :;\n-     fi &&\n+     fi'\n \n-     : sum of the index file itself &&\n-     l=`wc -c <test-3.idx` &&\n+test_expect_success \\\n+    'verify-pack catches a corrupted sum of the index file itself' \\\n+    'l=`wc -c <test-3.idx` &&\n      l=`expr $l - 20` &&\n      cat test-1-${packname_1}.pack >test-3.pack &&\n      dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&\n      if git verify-pack test-3.pack\n      then false\n      else :;\n-     fi &&\n-\n-     :'\n+     fi'\n \n test_expect_success \\\n     'build pack index for an existing pack' \\\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59713","messageId":"1194984306-3181-3-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-2-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 02/11] t7501-commit.sh: Not all seds understand option -i","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:04:57Z","receivedAt":"2007-11-13T20:04:57Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Use mv instead.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n t/t7501-commit.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7501-commit.sh b/t/t7501-commit.sh\nindex 4dc35bd..38db2f2 100644\n--- a/t/t7501-commit.sh\n+++ b/t/t7501-commit.sh\n@@ -69,7 +69,8 @@ test_expect_success \\\n \n cat >editor <<\\EOF\n #!/bin/sh\n-sed -i -e \"s/a file/an amend commit/g\" $1\n+sed -e \"s/a file/an amend commit/g\" < $1 > $1-\n+mv $1- $1\n EOF\n chmod 755 editor\n \n@@ -88,7 +89,8 @@ test_expect_success \\\n \n cat >editor <<\\EOF\n #!/bin/sh\n-sed -i -e \"s/amend/older/g\" $1\n+sed -e \"s/amend/older/g\"  < $1 > $1-\n+mv $1- $1\n EOF\n chmod 755 editor\n \n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59714","messageId":"1194984306-3181-4-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-3-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 03/11] t5302-pack-index: Skip tests of 64-bit offsets if necessary.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:04:58Z","receivedAt":"2007-11-13T20:04:58Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"There are platforms where off_t is not 64 bits wide. In this case many tests\nare doomed to fail. Let's skip them.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n t/t5302-pack-index.sh |   25 +++++++++++++++++++++++--\n 1 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh\nindex 4f58c4c..d93abc4 100755\n--- a/t/t5302-pack-index.sh\n+++ b/t/t5302-pack-index.sh\n@@ -61,17 +61,33 @@ test_expect_success \\\n \n test_expect_success \\\n     'index v2: force some 64-bit offsets with pack-objects' \\\n-    'pack3=$(git pack-objects --index-version=2,0x40000 test-3 <obj-list) &&\n-     git verify-pack -v \"test-3-${pack3}.pack\"'\n+    'pack3=$(git pack-objects --index-version=2,0x40000 test-3 <obj-list)'\n+\n+have_64bits=\n+if msg=$(git verify-pack -v \"test-3-${pack3}.pack\" 2>&1) ||\n+\t! echo \"$msg\" | grep \"pack too large .* off_t\"\n+then\n+\thave_64bits=t\n+else\n+\tsay \"skipping tests concerning 64-bit offsets\"\n+fi\n+\n+test \"$have_64bits\" &&\n+test_expect_success \\\n+    'index v2: verify a pack with some 64-bit offsets' \\\n+    'git verify-pack -v \"test-3-${pack3}.pack\"'\n \n+test \"$have_64bits\" &&\n test_expect_failure \\\n     '64-bit offsets: should be different from previous index v2 results' \\\n     'cmp \"test-2-${pack2}.idx\" \"test-3-${pack3}.idx\"'\n \n+test \"$have_64bits\" &&\n test_expect_success \\\n     'index v2: force some 64-bit offsets with index-pack' \\\n     'git-index-pack --index-version=2,0x40000 -o 3.idx \"test-1-${pack1}.pack\"'\n \n+test \"$have_64bits\" &&\n test_expect_success \\\n     '64-bit offsets: index-pack result should match pack-objects one' \\\n     'cmp \"test-3-${pack3}.idx\" \"3.idx\"'\n@@ -113,6 +129,7 @@ test_expect_failure \\\n     '[index v1] 6) newly created pack is BAD !' \\\n     'git verify-pack -v \"test-4-${pack1}.pack\"'\n \n+test \"$have_64bits\" &&\n test_expect_success \\\n     '[index v2] 1) stream pack to repository' \\\n     'rm -f .git/objects/pack/* &&\n@@ -122,6 +139,7 @@ test_expect_success \\\n      cmp \"test-1-${pack1}.pack\" \".git/objects/pack/pack-${pack1}.pack\" &&\n      cmp \"test-3-${pack1}.idx\"  \".git/objects/pack/pack-${pack1}.idx\"'\n \n+test \"$have_64bits\" &&\n test_expect_success \\\n     '[index v2] 2) create a stealth corruption in a delta base reference' \\\n     '# this test assumes a delta smaller than 16 bytes at the end of the pack\n@@ -134,14 +152,17 @@ test_expect_success \\\n \t  bs=1 count=20 conv=notrunc &&\n        git cat-file blob \"$delta_sha1\" > blob_4 )'\n \n+test \"$have_64bits\" &&\n test_expect_failure \\\n     '[index v2] 3) corrupted delta happily returned wrong data' \\\n     'cmp blob_3 blob_4'\n \n+test \"$have_64bits\" &&\n test_expect_failure \\\n     '[index v2] 4) confirm that the pack is actually corrupted' \\\n     'git fsck --full $commit'\n \n+test \"$have_64bits\" &&\n test_expect_failure \\\n     '[index v2] 5) pack-objects refuses to reuse corrupted data' \\\n     'git pack-objects test-5 <obj-list'\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59715","messageId":"1194984306-3181-5-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-4-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 04/11] Skip t3902-quoted.sh if the file system does not support funny names.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:04:59Z","receivedAt":"2007-11-13T20:04:59Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n t/t3902-quoted.sh |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh\nindex 245fb3b..73da45f 100755\n--- a/t/t3902-quoted.sh\n+++ b/t/t3902-quoted.sh\n@@ -20,6 +20,13 @@ LF='\n '\n DQ='\"'\n \n+echo foo > \"Name and an${HT}HT\"\n+test -f \"Name and an${HT}HT\" || {\n+\t# since FAT/NTFS does not allow tabs in filenames, skip this test\n+\tsay 'Your filesystem does not allow tabs in filenames, test skipped.'\n+\ttest_done\n+}\n+\n for_each_name () {\n \tfor name in \\\n \t    Name \"Name and a${LF}LF\" \"Name and an${HT}HT\" \"Name${DQ}\" \\\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59717","messageId":"1194984306-3181-6-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-5-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 05/11] Use is_absolute_path() in sha1_file.c.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:00Z","receivedAt":"2007-11-13T20:05:00Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"There are some places that test for an absolute path. Use the helper\nfunction to ease porting.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n sha1_file.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex f007874..560c0e0 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)\n \tchar *pos = path;\n \tstruct stat st;\n \n-\tif (*pos == '/')\n+\tif (is_absolute_path(path))\n \t\tpos++;\n \n \twhile (pos) {\n@@ -253,7 +253,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative\n \tint entlen = pfxlen + 43;\n \tint base_len = -1;\n \n-\tif (*entry != '/' && relative_base) {\n+\tif (!is_absolute_path(entry) && relative_base) {\n \t\t/* Relative alt-odb */\n \t\tif (base_len < 0)\n \t\t\tbase_len = strlen(relative_base) + 1;\n@@ -262,7 +262,7 @@ static int link_alt_odb_entry(const char * entry, int len, const char * relative\n \t}\n \tent = xmalloc(sizeof(*ent) + entlen);\n \n-\tif (*entry != '/' && relative_base) {\n+\tif (!is_absolute_path(entry) && relative_base) {\n \t\tmemcpy(ent->base, relative_base, base_len - 1);\n \t\tent->base[base_len - 1] = '/';\n \t\tmemcpy(ent->base + base_len, entry, len);\n@@ -333,7 +333,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,\n \t\twhile (cp < ep && *cp != sep)\n \t\t\tcp++;\n \t\tif (last != cp) {\n-\t\t\tif ((*last != '/') && depth) {\n+\t\t\tif (!is_absolute_path(last) && depth) {\n \t\t\t\terror(\"%s: ignoring relative alternate object store %s\",\n \t\t\t\t\t\trelative_base, last);\n \t\t\t} else {\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59711","messageId":"1194984306-3181-7-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-6-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 06/11] Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:01Z","receivedAt":"2007-11-13T20:05:01Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"... since all system headers are pulled in via git-compat-util.h\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n git-compat-util.h |    2 ++\n help.c            |    1 -\n pager.c           |    2 --\n 3 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7b29d1b..6a8b592 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -52,6 +52,8 @@\n #include <fnmatch.h>\n #include <sys/poll.h>\n #include <sys/socket.h>\n+#include <sys/ioctl.h>\n+#include <sys/select.h>\n #include <assert.h>\n #include <regex.h>\n #include <netinet/in.h>\ndiff --git a/help.c b/help.c\nindex 8217d97..d340b6a 100644\n--- a/help.c\n+++ b/help.c\n@@ -7,7 +7,6 @@\n #include \"builtin.h\"\n #include \"exec_cmd.h\"\n #include \"common-cmds.h\"\n-#include <sys/ioctl.h>\n \n /* most GUI terminals set COLUMNS (although some don't export it) */\n static int term_columns(void)\ndiff --git a/pager.c b/pager.c\nindex 8bac9d9..fb7a1a6 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -1,7 +1,5 @@\n #include \"cache.h\"\n \n-#include <sys/select.h>\n-\n /*\n  * This is split up from the rest of git so that we might do\n  * something different on Windows, for example.\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59719","messageId":"1194984306-3181-8-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-7-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 07/11] builtin run_command: do not exit with -1.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:02Z","receivedAt":"2007-11-13T20:05:02Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"There are shells that do not correctly detect an exit code of -1 as a\nfailure. We simply truncate the status code to the lower 8 bits.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n git.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 4a250f7..37d99d6 100644\n--- a/git.c\n+++ b/git.c\n@@ -256,7 +256,7 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)\n \n \tstatus = p->fn(argc, argv, prefix);\n \tif (status)\n-\t\treturn status;\n+\t\treturn status & 0xff;\n \n \t/* Somebody closed stdout? */\n \tif (fstat(fileno(stdout), &st))\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59712","messageId":"1194984306-3181-9-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-8-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 08/11] Close files opened by lock_file() before unlinking.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:03Z","receivedAt":"2007-11-13T20:05:03Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nThis is needed on Windows since open files cannot be unlinked.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n\n\tThis was authored by Dscho, but carries only my sign-off.\n\tIs this ok?\n\n cache.h    |    1 +\n lockfile.c |   17 ++++++++++-------\n 2 files changed, 11 insertions(+), 7 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex f0a25c7..28870c5 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -284,6 +284,7 @@ extern int refresh_index(struct index_state *, unsigned int flags, const char **\n \n struct lock_file {\n \tstruct lock_file *next;\n+\tint fd;\n \tpid_t owner;\n \tchar on_list;\n \tchar filename[PATH_MAX];\ndiff --git a/lockfile.c b/lockfile.c\nindex 9a1f64d..258fb3f 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -12,8 +12,10 @@ static void remove_lock_file(void)\n \n \twhile (lock_file_list) {\n \t\tif (lock_file_list->owner == me &&\n-\t\t    lock_file_list->filename[0])\n+\t\t    lock_file_list->filename[0]) {\n+\t\t\tclose(lock_file_list->fd);\n \t\t\tunlink(lock_file_list->filename);\n+\t\t}\n \t\tlock_file_list = lock_file_list->next;\n \t}\n }\n@@ -120,8 +122,6 @@ static char *resolve_symlink(char *p, size_t s)\n \n static int lock_file(struct lock_file *lk, const char *path)\n {\n-\tint fd;\n-\n \tif (strlen(path) >= sizeof(lk->filename)) return -1;\n \tstrcpy(lk->filename, path);\n \t/*\n@@ -130,8 +130,8 @@ static int lock_file(struct lock_file *lk, const char *path)\n \t */\n \tresolve_symlink(lk->filename, sizeof(lk->filename)-5);\n \tstrcat(lk->filename, \".lock\");\n-\tfd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);\n-\tif (0 <= fd) {\n+\tlk->fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);\n+\tif (0 <= lk->fd) {\n \t\tif (!lock_file_list) {\n \t\t\tsignal(SIGINT, remove_lock_file_on_signal);\n \t\t\tatexit(remove_lock_file);\n@@ -148,7 +148,7 @@ static int lock_file(struct lock_file *lk, const char *path)\n \t}\n \telse\n \t\tlk->filename[0] = 0;\n-\treturn fd;\n+\treturn lk->fd;\n }\n \n int hold_lock_file_for_update(struct lock_file *lk, const char *path, int die_on_error)\n@@ -163,6 +163,7 @@ int commit_lock_file(struct lock_file *lk)\n {\n \tchar result_file[PATH_MAX];\n \tint i;\n+\tclose(lk->fd);\n \tstrcpy(result_file, lk->filename);\n \ti = strlen(result_file) - 5; /* .lock */\n \tresult_file[i] = 0;\n@@ -194,7 +195,9 @@ int commit_locked_index(struct lock_file *lk)\n \n void rollback_lock_file(struct lock_file *lk)\n {\n-\tif (lk->filename[0])\n+\tif (lk->filename[0]) {\n+\t\tclose(lk->fd);\n \t\tunlink(lk->filename);\n+\t}\n \tlk->filename[0] = 0;\n }\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59721","messageId":"1194984306-3181-10-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-9-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 09/11] Allow a relative builtin template directory.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:04Z","receivedAt":"2007-11-13T20:05:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"In order to make git relocatable (i.e. not have the prefix compiled-in)\nthe template directory must depend on the location where this git instance\nis found, which is GIT_EXEC_DIR.\n\nThe exec path is prepended only if the compiled-in default template\ndirectory is to be used and that is relative. Any relative directories\nthat are specified via environment variable or the --exec-dir switch are\ntaken as is.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n builtin-init-db.c |   16 +++++++++++++---\n 1 files changed, 13 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 763fa55..e1393b8 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -5,6 +5,7 @@\n  */\n #include \"cache.h\"\n #include \"builtin.h\"\n+#include \"exec_cmd.h\"\n \n #ifndef DEFAULT_GIT_TEMPLATE_DIR\n #define DEFAULT_GIT_TEMPLATE_DIR \"/usr/share/git-core/templates\"\n@@ -131,10 +132,19 @@ static void copy_templates(const char *git_dir, int len, const char *template_di\n \tint template_len;\n \tDIR *dir;\n \n-\tif (!template_dir) {\n+\tif (!template_dir)\n \t\ttemplate_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);\n-\t\tif (!template_dir)\n-\t\t\ttemplate_dir = DEFAULT_GIT_TEMPLATE_DIR;\n+\tif (!template_dir) {\n+\t\t/*\n+\t\t * if the hard-coded template is relative, it is\n+\t\t * interpreted relative to the exec_dir\n+\t\t */\n+\t\ttemplate_dir = DEFAULT_GIT_TEMPLATE_DIR;\n+\t\tif (!is_absolute_path(template_dir)) {\n+\t\t\tconst char *exec_path = git_exec_path();\n+\t\t\ttemplate_dir = prefix_path(exec_path, strlen(exec_path),\n+\t\t\t\t\t\t   template_dir);\n+\t\t}\n \t}\n \tstrcpy(template_path, template_dir);\n \ttemplate_len = strlen(template_path);\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59722","messageId":"1194984306-3181-11-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-10-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:05Z","receivedAt":"2007-11-13T20:05:05Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"In a subsequent patch the path to the system-wide config file will be\ncomputed. This is a preparation for that change. It turns all accesses\nof ETC_GITCONFIG into function calls. There is no change in behavior.\n\nAs a consequence, config.c is the only file that needs the definition of\nETC_GITCONFIG. Hence, -DETC_GITCONFIG is removed from the CFLAGS and a\nspecial build rule for config.c is introduced. As a side-effect, changing\nthe defintion of ETC_GITCONFIG (e.g. in config.mak) does not trigger a\ncomplete rebuild anymore.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n Makefile         |    5 ++++-\n builtin-config.c |    4 ++--\n cache.h          |    1 +\n config.c         |    9 +++++++--\n 4 files changed, 14 insertions(+), 5 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 18c61f3..e32f07e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -752,7 +752,7 @@ TCLTK_PATH_SQ = $(subst ','\\'',$(TCLTK_PATH))\n LIBS = $(GITLIBS) $(EXTLIBS)\n \n BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \\\n-\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' $(COMPAT_CFLAGS)\n+\t$(COMPAT_CFLAGS)\n LIB_OBJS += $(COMPAT_OBJS)\n \n ALL_CFLAGS += $(BASIC_CFLAGS)\n@@ -901,6 +901,9 @@ exec_cmd.o: exec_cmd.c GIT-CFLAGS\n builtin-init-db.o: builtin-init-db.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"' $<\n \n+config.o: config.c GIT-CFLAGS\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' $<\n+\n http.o: http.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"' $<\n \ndiff --git a/builtin-config.c b/builtin-config.c\nindex e5e243f..f672c9c 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -81,7 +81,7 @@ static int get_value(const char* key_, const char* regex_)\n \t\t\tlocal = repo_config = xstrdup(git_path(\"config\"));\n \t\tif (home)\n \t\t\tglobal = xstrdup(mkpath(\"%s/.gitconfig\", home));\n-\t\tsystem_wide = ETC_GITCONFIG;\n+\t\tsystem_wide = git_etc_gitconfig();\n \t}\n \n \tkey = xstrdup(key_);\n@@ -191,7 +191,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\t\t}\n \t\t}\n \t\telse if (!strcmp(argv[1], \"--system\"))\n-\t\t\tsetenv(CONFIG_ENVIRONMENT, ETC_GITCONFIG, 1);\n+\t\t\tsetenv(CONFIG_ENVIRONMENT, git_etc_gitconfig(), 1);\n \t\telse if (!strcmp(argv[1], \"--file\") || !strcmp(argv[1], \"-f\")) {\n \t\t\tif (argc < 3)\n \t\t\t\tusage(git_config_set_usage);\ndiff --git a/cache.h b/cache.h\nindex 28870c5..0eb7b43 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -551,6 +551,7 @@ extern int git_config_bool(const char *, const char *);\n extern int git_config_set(const char *, const char *);\n extern int git_config_set_multivar(const char *, const char *, const char *, int);\n extern int git_config_rename_section(const char *, const char *);\n+extern const char *git_etc_gitconfig(void);\n extern int check_repository_format_version(const char *var, const char *value);\n \n #define MAX_GITNAME (1000)\ndiff --git a/config.c b/config.c\nindex dc3148d..dd7e9ad 100644\n--- a/config.c\n+++ b/config.c\n@@ -452,6 +452,11 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n \treturn ret;\n }\n \n+const char *git_etc_gitconfig(void)\n+{\n+\treturn ETC_GITCONFIG;\n+}\n+\n int git_config(config_fn_t fn)\n {\n \tint ret = 0;\n@@ -464,8 +469,8 @@ int git_config(config_fn_t fn)\n \t * config file otherwise. */\n \tfilename = getenv(CONFIG_ENVIRONMENT);\n \tif (!filename) {\n-\t\tif (!access(ETC_GITCONFIG, R_OK))\n-\t\t\tret += git_config_from_file(fn, ETC_GITCONFIG);\n+\t\tif (!access(git_etc_gitconfig(), R_OK))\n+\t\t\tret += git_config_from_file(fn, git_etc_gitconfig());\n \t\thome = getenv(\"HOME\");\n \t\tfilename = getenv(CONFIG_LOCAL_ENVIRONMENT);\n \t\tif (!filename)\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59720","messageId":"1194984306-3181-12-git-send-email-johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-11-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:05:06Z","receivedAt":"2007-11-13T20:05:06Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"If ETC_GITCONFIG is not an absolute path, interpret it relative to\n--exec-dir. This makes the installed binaries relocatable because the\nprefix is not compiled-in.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n config.c |   13 ++++++++++++-\n 1 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex dd7e9ad..9f014bb 100644\n--- a/config.c\n+++ b/config.c\n@@ -6,6 +6,7 @@\n  *\n  */\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n \n #define MAXNAME (256)\n \n@@ -454,7 +455,17 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n \n const char *git_etc_gitconfig(void)\n {\n-\treturn ETC_GITCONFIG;\n+\tstatic const char *system_wide;\n+\tif (!system_wide) {\n+\t\tsystem_wide = ETC_GITCONFIG;\n+\t\tif (!is_absolute_path(system_wide)) {\n+\t\t\t/* interpret path relative to exec-dir */\n+\t\t\tconst char *exec_path = git_exec_path();\n+\t\t\tsystem_wide = prefix_path(exec_path, strlen(exec_path),\n+\t\t\t\t\t\tsystem_wide);\n+\t\t}\n+\t}\n+\treturn system_wide;\n }\n \n int git_config(config_fn_t fn)\n-- \n1.5.3.5.1592.g0d6db\n"},{"id":"59724","messageId":"200711132110.29136.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"1194984306-3181-1-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T20:10:28Z","receivedAt":"2007-11-13T20:10:28Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n> [PATCH 09/11] Allow a relative builtin template directory.\n> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> \tof ETC_GITCONFIG.\n> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n>\n> These need probably some discussion. They avoid that $(prefix) is\n> hardcoded and so allows that an arbitrary installation directory.\n\n... and so allow that the compiled binaries are installed in any directory \nthat the user chooses.\n\n-- Hannes\n"},{"id":"59729","messageId":"Pine.LNX.4.64.0711132104060.4362@racer.site","threadId":"10850","inReplyTo":"1194984306-3181-9-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 08/11] Close files opened by lock_file() before unlinking.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:05:32Z","receivedAt":"2007-11-13T21:05:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> From: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> \n> This is needed on Windows since open files cannot be unlinked.\n> \n> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n> ---\n> \n> \tThis was authored by Dscho, but carries only my sign-off.\n> \tIs this ok?\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nBTW: Hannes, many thanks for your efforts.  Much appreciated.\n\nCiao,\nDscho\n"},{"id":"59730","messageId":"7vlk91svgf.fsf@gitster.siamese.dyndns.org","threadId":"10850","inReplyTo":"200711132110.29136.johannes.sixt@telecom.at","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-13T21:10:24Z","receivedAt":"2007-11-13T21:10:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <johannes.sixt@telecom.at> writes:\n\n> On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n>> [PATCH 09/11] Allow a relative builtin template directory.\n>> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n>> \tof ETC_GITCONFIG.\n>> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n>>\n>> These need probably some discussion. They avoid that $(prefix) is\n>> hardcoded and so allows that an arbitrary installation directory.\n>\n> ... and so allow that the compiled binaries are installed in any directory \n> that the user chooses.\n\nIf you can do that without breaking the tests (specifically, the\ntest script should pick up the version of git you just built,\nnot from /usr/bin nor /usr/local/stow/git/bin) that would be\ngreat.\n"},{"id":"59734","messageId":"Pine.LNX.4.64.0711132121440.4362@racer.site","threadId":"10850","inReplyTo":"1194984306-3181-11-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:22:23Z","receivedAt":"2007-11-13T21:22:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> diff --git a/config.c b/config.c\n> index dc3148d..dd7e9ad 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -452,6 +452,11 @@ int git_config_from_file(config_fn_t fn, const char *filename)\n>  \treturn ret;\n>  }\n>  \n> +const char *git_etc_gitconfig(void)\n> +{\n> +\treturn ETC_GITCONFIG;\n> +}\n> +\n\nWouldn't this logically belong into environment.c?\n\nCiao,\nDscho\n"},{"id":"59737","messageId":"200711132232.11730.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"7vlk91svgf.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T21:32:11Z","receivedAt":"2007-11-13T21:32:11Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Tuesday 13 November 2007 22:10, Junio C Hamano wrote:\n> Johannes Sixt <johannes.sixt@telecom.at> writes:\n> > On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n> >> [PATCH 09/11] Allow a relative builtin template directory.\n> >> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> >> \tof ETC_GITCONFIG.\n> >> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n> >>\n> >> These need probably some discussion. They avoid that $(prefix) is\n> >> hardcoded and so allows that an arbitrary installation directory.\n> >\n> > ... and so allow that the compiled binaries are installed in any\n> > directory that the user chooses.\n>\n> If you can do that without breaking the tests (specifically, the\n> test script should pick up the version of git you just built,\n> not from /usr/bin nor /usr/local/stow/git/bin) that would be\n> great.\n\nSorry, I don't understand your statement. Do you see any tests breaking?\n\nThese changes are only about where git-init looks up the templates and where \nthe system configuration is looked for. They change git's behavior only if \nconfig.mak contains relative paths like this:\n\nsysconfdir = ../etc\ntemplate_dir = ../share/git-core\n\nIt has nothing to do with where the test suite looks for the executables.\n\n-- Hannes\n"},{"id":"59738","messageId":"200711132235.13463.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"Pine.LNX.4.64.0711132121440.4362@racer.site","subject":"Re: [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T21:35:13Z","receivedAt":"2007-11-13T21:35:13Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Tuesday 13 November 2007 22:22, Johannes Schindelin wrote:\n> Hi,\n>\n> On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > diff --git a/config.c b/config.c\n> > index dc3148d..dd7e9ad 100644\n> > --- a/config.c\n> > +++ b/config.c\n> > @@ -452,6 +452,11 @@ int git_config_from_file(config_fn_t fn, const char\n> > *filename) return ret;\n> >  }\n> >\n> > +const char *git_etc_gitconfig(void)\n> > +{\n> > +\treturn ETC_GITCONFIG;\n> > +}\n> > +\n>\n> Wouldn't this logically belong into environment.c?\n\nI don't think so. environment.c is about things that concern the repository. \nThis is really only about configuration.\n\n-- Hannes\n"},{"id":"59740","messageId":"Pine.LNX.4.64.0711132138360.4362@racer.site","threadId":"10850","inReplyTo":"1194984306-3181-6-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 05/11] Use is_absolute_path() in sha1_file.c.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:39:20Z","receivedAt":"2007-11-13T21:39:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> diff --git a/sha1_file.c b/sha1_file.c\n> index f007874..560c0e0 100644\n> --- a/sha1_file.c\n> +++ b/sha1_file.c\n> @@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)\n>  \tchar *pos = path;\n>  \tstruct stat st;\n>  \n> -\tif (*pos == '/')\n> +\tif (is_absolute_path(path))\n>  \t\tpos++;\n\nIs this enough?  On Windows, certain \"absolute\" paths would need \"pos += \n3\", no?\n\nCiao,\nDscho\n"},{"id":"59741","messageId":"200711132243.05877.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"Pine.LNX.4.64.0711132138360.4362@racer.site","subject":"Re: [PATCH 05/11] Use is_absolute_path() in sha1_file.c.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T21:43:05Z","receivedAt":"2007-11-13T21:43:05Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Tuesday 13 November 2007 22:39, Johannes Schindelin wrote:\n> Hi,\n>\n> On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > diff --git a/sha1_file.c b/sha1_file.c\n> > index f007874..560c0e0 100644\n> > --- a/sha1_file.c\n> > +++ b/sha1_file.c\n> > @@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)\n> >  \tchar *pos = path;\n> >  \tstruct stat st;\n> >\n> > -\tif (*pos == '/')\n> > +\tif (is_absolute_path(path))\n> >  \t\tpos++;\n>\n> Is this enough?  On Windows, certain \"absolute\" paths would need \"pos +=\n> 3\", no?\n\nTrue, but this series is not yet about the MinGW port itself. It will be \nchanged eventually, but not at this time.\n\n-- Hannes\n"},{"id":"59742","messageId":"Pine.LNX.4.64.0711132140000.4362@racer.site","threadId":"10850","inReplyTo":"200711132235.13463.johannes.sixt@telecom.at","subject":"Re: [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:43:19Z","receivedAt":"2007-11-13T21:43:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> On Tuesday 13 November 2007 22:22, Johannes Schindelin wrote:\n>\n> > On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > > diff --git a/config.c b/config.c\n> > > index dc3148d..dd7e9ad 100644\n> > > --- a/config.c\n> > > +++ b/config.c\n> > > @@ -452,6 +452,11 @@ int git_config_from_file(config_fn_t fn, const char\n> > > *filename) return ret;\n> > >  }\n> > >\n> > > +const char *git_etc_gitconfig(void)\n> > > +{\n> > > +\treturn ETC_GITCONFIG;\n> > > +}\n> > > +\n> >\n> > Wouldn't this logically belong into environment.c?\n> \n> I don't think so. environment.c is about things that concern the \n> repository. This is really only about configuration.\n\nI thought that environment.c is about getting certain settings from the \nenvironment.  In that sense, git_etc_gitconfig() would live a happier life \nthere.\n\nBut I do not care all that deeply.  I know _I_ would have looked for it in \nenvironment.c first, but then, there's always good ole' git-grep.\n\nCiao,\nDscho\n"},{"id":"59744","messageId":"Pine.LNX.4.64.0711132145400.4362@racer.site","threadId":"10850","inReplyTo":"200711132232.11730.johannes.sixt@telecom.at","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:46:59Z","receivedAt":"2007-11-13T21:46:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> On Tuesday 13 November 2007 22:10, Junio C Hamano wrote:\n> > Johannes Sixt <johannes.sixt@telecom.at> writes:\n> > > On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n> > >> [PATCH 09/11] Allow a relative builtin template directory.\n> > >> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> > >> \tof ETC_GITCONFIG.\n> > >> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n> > >>\n> > >> These need probably some discussion. They avoid that $(prefix) is\n> > >> hardcoded and so allows that an arbitrary installation directory.\n> > >\n> > > ... and so allow that the compiled binaries are installed in any\n> > > directory that the user chooses.\n> >\n> > If you can do that without breaking the tests (specifically, the\n> > test script should pick up the version of git you just built,\n> > not from /usr/bin nor /usr/local/stow/git/bin) that would be\n> > great.\n> \n> Sorry, I don't understand your statement. Do you see any tests breaking?\n\nI guess what Junio is getting at: if your changes could lead to our not \nneeding to hard code defaults, that would be awesome.\n\nFor example, a very unhappy camper reported recently that installing git \nwith a different prefix triggers a complete rebuild.\n\nCiao,\nDscho\n"},{"id":"59746","messageId":"Pine.LNX.4.64.0711132148030.4362@racer.site","threadId":"10850","inReplyTo":"200711132243.05877.johannes.sixt@telecom.at","subject":"Re: [PATCH 05/11] Use is_absolute_path() in sha1_file.c.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-13T21:48:16Z","receivedAt":"2007-11-13T21:48:16Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 13 Nov 2007, Johannes Sixt wrote:\n\n> On Tuesday 13 November 2007 22:39, Johannes Schindelin wrote:\n>\n> > On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > > diff --git a/sha1_file.c b/sha1_file.c\n> > > index f007874..560c0e0 100644\n> > > --- a/sha1_file.c\n> > > +++ b/sha1_file.c\n> > > @@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)\n> > >  \tchar *pos = path;\n> > >  \tstruct stat st;\n> > >\n> > > -\tif (*pos == '/')\n> > > +\tif (is_absolute_path(path))\n> > >  \t\tpos++;\n> >\n> > Is this enough?  On Windows, certain \"absolute\" paths would need \"pos +=\n> > 3\", no?\n> \n> True, but this series is not yet about the MinGW port itself. It will be \n> changed eventually, but not at this time.\n\nOkay, fair enough.\n\nCiao,\nDscho\n"},{"id":"59752","messageId":"200711132254.37053.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"Pine.LNX.4.64.0711132145400.4362@racer.site","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-13T21:54:36Z","receivedAt":"2007-11-13T21:54:36Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Tuesday 13 November 2007 22:46, Johannes Schindelin wrote:\n> Hi,\n>\n> On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > On Tuesday 13 November 2007 22:10, Junio C Hamano wrote:\n> > > Johannes Sixt <johannes.sixt@telecom.at> writes:\n> > > > On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n> > > >> [PATCH 09/11] Allow a relative builtin template directory.\n> > > >> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> > > >> \tof ETC_GITCONFIG.\n> > > >> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n> > > >>\n> > > >> These need probably some discussion. They avoid that $(prefix) is\n> > > >> hardcoded and so allows that an arbitrary installation directory.\n> > > >\n> > > > ... and so allow that the compiled binaries are installed in any\n> > > > directory that the user chooses.\n> > >\n> > > If you can do that without breaking the tests (specifically, the\n> > > test script should pick up the version of git you just built,\n> > > not from /usr/bin nor /usr/local/stow/git/bin) that would be\n> > > great.\n> >\n> > Sorry, I don't understand your statement. Do you see any tests breaking?\n>\n> I guess what Junio is getting at: if your changes could lead to our not\n> needing to hard code defaults, that would be awesome.\n>\n> For example, a very unhappy camper reported recently that installing git\n> with a different prefix triggers a complete rebuild.\n\n[PATCH 10/11] is one step into this direction.\n\n-- Hannes\n"},{"id":"59758","messageId":"7v8x51ss3s.fsf@gitster.siamese.dyndns.org","threadId":"10850","inReplyTo":"Pine.LNX.4.64.0711132145400.4362@racer.site","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-13T22:22:47Z","receivedAt":"2007-11-13T22:22:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Tue, 13 Nov 2007, Johannes Sixt wrote:\n>> On Tuesday 13 November 2007 22:10, Junio C Hamano wrote:\n>> > Johannes Sixt <johannes.sixt@telecom.at> writes:\n>> > > On Tuesday 13 November 2007 21:04, Johannes Sixt wrote:\n>> > > ... and so allow that the compiled binaries are installed in any\n>> > > directory that the user chooses.\n>> >\n>> > If you can do that without breaking the tests (specifically, the\n>> > test script should pick up the version of git you just built,\n>> > not from /usr/bin nor /usr/local/stow/git/bin) that would be\n>> > great.\n>> \n>> Sorry, I don't understand your statement. Do you see any tests breaking?\n>\n> I guess what Junio is getting at: if your changes could lead to our not \n> needing to hard code defaults, that would be awesome.\n\nYes.  Another thing I said was that it would be grave regression\nfor testability if the change leads git to look at somewhere\nelse other than it was told to look via GIT_EXEC_PATH\nenvironment,\n"},{"id":"59844","messageId":"7vir45hyyn.fsf@gitster.siamese.dyndns.org","threadId":"10850","inReplyTo":"1194984306-3181-1-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-14T11:02:24Z","receivedAt":"2007-11-14T11:02:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <johannes.sixt@telecom.at> writes:\n\n> This is a series of smallish, unrelated changes that were necessary\n> for the MinGW port.\n\nI was _VERY_ afraid of reviewing this series.\n\n> [PATCH 05/11] Use is_absolute_path() in sha1_file.c.\n> [PATCH 06/11] Move #include <sys/select.h> and <sys/ioctl.h> to\n> \tgit-compat-util.h.\n>\n> These two are certainly undisputed.\n\nExcept on esoteric/broken systems there might be some dependency\non the order the system include files are included, so 06/11\nneeds some testing.  But it is a change in the right direction.\n\n> [PATCH 07/11] builtin run_command: do not exit with -1.\n>\n> Replaces exit(-1) by exit(255). I don't know if this has any bad\n> consequences on *nix.\n\nLinux manual page says \"the value of status & 0377 is returned\nto the parent\", which agrees with POSIX's \"only the least\nsignificant 8 bits(that is, status & 0377) shall be available to\na waiting parent process\".  So I think we are safe on conforming\nplatforms.\n\n> [PATCH 08/11] Close files opened by lock_file() before unlinking.\n>\n> This one was authored by Dscho. It is a definite MUST on Windows.\n\nThis was something we've talked about doing a few times on the\nlist but did not.  It is good that this saw some testing in the\nfield, as it is easy to get wrong while moving the call site of\nclose(2) around.\n\n> [PATCH 09/11] Allow a relative builtin template directory.\n> [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> \tof ETC_GITCONFIG.\n> [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n>\n> These need probably some discussion. They avoid that $(prefix) is\n> hardcoded and so allows that an arbitrary installation directory.\n\nI had to worry a bit about bootstrapping issues in 11/11.  We\nneed to ensure that anybody who wants to read the configuration\ndata first does setup_path() because git_exec_path() reads from\nargv_exec_path and setup_path() is what assigns to that\nvariable.\n\nBut other than that and 08/11, I found everything is trivially\ncorrect and it was a pleasant read.\n\nThanks.\n"},{"id":"59852","messageId":"Pine.LNX.4.64.0711141441530.4362@racer.site","threadId":"10850","inReplyTo":"7vir45hyyn.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-14T14:50:47Z","receivedAt":"2007-11-14T14:50:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Nov 2007, Junio C Hamano wrote:\n\n> Johannes Sixt <johannes.sixt@telecom.at> writes:\n> \n> > This is a series of smallish, unrelated changes that were necessary\n> > for the MinGW port.\n> \n> I was _VERY_ afraid of reviewing this series.\n\nWhy?  Because we get closer to MinGW integration into git.git for real? \n;-)\n\n> > [PATCH 05/11] Use is_absolute_path() in sha1_file.c.\n> > [PATCH 06/11] Move #include <sys/select.h> and <sys/ioctl.h> to\n> > \tgit-compat-util.h.\n> >\n> > These two are certainly undisputed.\n> \n> Except on esoteric/broken systems there might be some dependency\n> on the order the system include files are included, so 06/11\n> needs some testing.  But it is a change in the right direction.\n\nThe safe thing, of course, would be to move them at the end of the include \nlist in git-compat-util.h, since they are now included after cache.h, \n(which includes git-compat-util.h and only strbuf.h, the sha1 header and \nzlib.h).\n\nThis way it should be really certainly undisputed.\n\n> > [PATCH 08/11] Close files opened by lock_file() before unlinking.\n> >\n> > This one was authored by Dscho. It is a definite MUST on Windows.\n> \n> This was something we've talked about doing a few times on the\n> list but did not.  It is good that this saw some testing in the\n> field, as it is easy to get wrong while moving the call site of\n> close(2) around.\n\nNote that we are not strictly _moving_ it around. In fact, we are _adding_ \nmore close() calls...  And even ignoring the errors when close() was \nalready called, so it feels a tad hacky.  But it does the job.\n\n> > [PATCH 09/11] Allow a relative builtin template directory.\n> > [PATCH 10/11] Introduce git_etc_gitconfig() that encapsulates access\n> > \tof ETC_GITCONFIG.\n> > [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.\n> >\n> > These need probably some discussion. They avoid that $(prefix) is\n> > hardcoded and so allows that an arbitrary installation directory.\n> \n> I had to worry a bit about bootstrapping issues in 11/11.  We\n> need to ensure that anybody who wants to read the configuration\n> data first does setup_path() because git_exec_path() reads from\n> argv_exec_path and setup_path() is what assigns to that\n> variable.\n\nJust to be safe in the future, we could check for that condition (by \nintroducing a static variable setup_path_called) and die() should anybody \nintroduce a code path where the order of calls is not maintained.\n\n> But other than that and 08/11, I found everything is trivially correct \n> and it was a pleasant read.\n\nMe, too.\n\nCiao,\nDscho\n"},{"id":"59868","messageId":"7vzlxgfuwc.fsf@gitster.siamese.dyndns.org","threadId":"10850","inReplyTo":"Pine.LNX.4.64.0711141441530.4362@racer.site","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-14T20:13:07Z","receivedAt":"2007-11-14T20:13:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 14 Nov 2007, Junio C Hamano wrote:\n>\n>> Johannes Sixt <johannes.sixt@telecom.at> writes:\n>> \n>> > This is a series of smallish, unrelated changes that were necessary\n>> > for the MinGW port.\n>> \n>> I was _VERY_ afraid of reviewing this series.\n>\n> Why?  Because we get closer to MinGW integration into git.git for real? \n> ;-)\n\nI know you know me better than that.\n\nConversion from \"Too UNIXy\" stuff into another form that \"claims\nto\" run on a different platform that I do not have a good way of\ntesting myself?  I should feel scared, even if I can always punt\nand say \"I'll only make sure UNIX side does not regress,\nWindose, who cares\" ;-).\n"},{"id":"59876","messageId":"Pine.LNX.4.64.0711142040400.4362@racer.site","threadId":"10850","inReplyTo":"7vzlxgfuwc.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 0/11] Miscellaneous MinGW port fallout","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-14T20:45:44Z","receivedAt":"2007-11-14T20:45:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 Nov 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Wed, 14 Nov 2007, Junio C Hamano wrote:\n> >\n> >> Johannes Sixt <johannes.sixt@telecom.at> writes:\n> >> \n> >> > This is a series of smallish, unrelated changes that were necessary\n> >> > for the MinGW port.\n> >> \n> >> I was _VERY_ afraid of reviewing this series.\n> >\n> > Why?  Because we get closer to MinGW integration into git.git for real? \n> > ;-)\n> \n> I know you know me better than that.\n> \n> Conversion from \"Too UNIXy\" stuff into another form that \"claims to\" run \n> on a different platform that I do not have a good way of testing myself?  \n> I should feel scared, even if I can always punt and say \"I'll only make \n> sure UNIX side does not regress, Windose, who cares\" ;-).\n\nYes, I do know you better than that. But I guess git grows up, and there \nis no way that you can guarantee it to perform well everywhere.\n\nBut I know some people who will make sure that it works on Windows.  For \nthem, at least. ;-)\n\nCiao,\nDscho\n"},{"id":"59882","messageId":"200711142257.12962.robin.rosenberg.lists@dewire.com","threadId":"10850","inReplyTo":"200711132243.05877.johannes.sixt@telecom.at","subject":"Re: [PATCH 05/11] Use is_absolute_path() in sha1_file.c.","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2007-11-14T21:57:12Z","receivedAt":"2007-11-14T21:57:12Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"tisdag 13 november 2007 skrev Johannes Sixt:\n> On Tuesday 13 November 2007 22:39, Johannes Schindelin wrote:\n> > Hi,\n> >\n> > On Tue, 13 Nov 2007, Johannes Sixt wrote:\n> > > diff --git a/sha1_file.c b/sha1_file.c\n> > > index f007874..560c0e0 100644\n> > > --- a/sha1_file.c\n> > > +++ b/sha1_file.c\n> > > @@ -86,7 +86,7 @@ int safe_create_leading_directories(char *path)\n> > >  \tchar *pos = path;\n> > >  \tstruct stat st;\n> > >\n> > > -\tif (*pos == '/')\n> > > +\tif (is_absolute_path(path))\n> > >  \t\tpos++;\n> >\n> > Is this enough?  On Windows, certain \"absolute\" paths would need \"pos +=\n> > 3\", no?\n> \n> True, but this series is not yet about the MinGW port itself. It will be \n> changed eventually, but not at this time.\n\nD:/FOO and //deathstar/core work fine in cygwin, which is supported. but git\ndo not work well with such paths in some places.\n\n-- robin\n"},{"id":"59934","messageId":"9D2813B9-8E86-4551-94BF-2B04F5FBB141@zib.de","threadId":"10850","inReplyTo":"1194984306-3181-12-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-11-15T06:53:15Z","receivedAt":"2007-11-15T06:53:15Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Nov 13, 2007, at 9:05 PM, Johannes Sixt wrote:\n\n> If ETC_GITCONFIG is not an absolute path, interpret it relative to\n> --exec-dir. This makes the installed binaries relocatable because the\n> prefix is not compiled-in.\n>\n> Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n> ---\n>  config.c |   13 ++++++++++++-\n>  1 files changed, 12 insertions(+), 1 deletions(-)\n>\n> diff --git a/config.c b/config.c\n> index dd7e9ad..9f014bb 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -6,6 +6,7 @@\n>   *\n>   */\n>  #include \"cache.h\"\n> +#include \"exec_cmd.h\"\n>\n>  #define MAXNAME (256)\n>\n> @@ -454,7 +455,17 @@ int git_config_from_file(config_fn_t fn, const  \n> char *filename)\n>\n>  const char *git_etc_gitconfig(void)\n>  {\n> -\treturn ETC_GITCONFIG;\n> +\tstatic const char *system_wide;\n> +\tif (!system_wide) {\n> +\t\tsystem_wide = ETC_GITCONFIG;\n> +\t\tif (!is_absolute_path(system_wide)) {\n> +\t\t\t/* interpret path relative to exec-dir */\n> +\t\t\tconst char *exec_path = git_exec_path();\n> +\t\t\tsystem_wide = prefix_path(exec_path, strlen(exec_path),\n> +\t\t\t\t\t\tsystem_wide);\n> +\t\t}\n> +\t}\n> +\treturn system_wide;\n>  }\n\nWhen I first stumbled over this code in msysgit I didn't\nunderstand how to use it for making git relocatable. Maybe\nI didn't appreciate the clue about the relative path, which\nindicates to change the Makefile to provide ETC_GITCONFIG\nstarting with \"..\".\n\nI think I stumbled over the idea to build a path by starting\nwith an absolute path to exec_path and than go up with\n\"..\" before going down again to etc/gitconfig. So, a paths\nwould for example be \"C:/msysgit/bin/../etc/gitconfig\".\n\nHence I wrote a function git_install_prefix(), which directly\npoints to \"C:/msysgit\". It is used in the following way:\n\n----\n\t\t\tsystem_wide = prefix_path(exec_path, strlen(exec_path),\n\t\t\t\t\t\tsystem_wide);\n\t\t}\n+#if __MINGW32__\n+\t\t/*\n+\t\t * If it is an absolute Unix path it is prefixed with\n+\t\t * the git_install_prefix().\n+\t\t */\n+\t\telse if (system_wide[0] == '/') {\n+\t\t\tconst char* prefix = git_install_prefix();\n+\t\t\tsystem_wide = prefix_path(prefix, strlen(prefix),\n+\t\t\t                           system_wide);\n+\t\t}\n+#endif\n\t}\n\treturn system_wide;\n}\n\n----\n\nThis is not very portable.  Prefixing _every_ absolute Unix path\nmakes sense for MINGW to map the fake unix root to its real\nlocation in the Windows filesystem. But this probably doesn't\nmake sense on Unix at all.  And it's probably not needed at\nall. I should have just read your code more carefully ;)\n\nYour solution provides a sensible way to handle the issue.\n\nNow I'm wondering if we could make path relocation a bit more\nexplicit.  How about doing something like.\n\n\tsystem_wide = relocate_path(ETC_GITCONFIG);\n\nand relocate_path(const char *) would expand a format\nstring in path.  At this point I see only a single %s\nthat would be expanded with the install prefix.  If\nETC_GITCONFIG is \"%s/etc/gitconfig\" relocate path will return\n\"C:/msysgit/bin/etc/gitconfig\" for my above example.  It is\nbasically a printf with the install prefix path.\n\nThis would support three cases:\n- absolute path\n- relative path\n- paths that will be relocated.  The path includes a '%s'\n   to indicate relocation.\n\nI'm not sure if we ever need to support relative paths\nwithout relocating them.\n\nWhat do you think?  If my comments make any sense to you,\nI could code a patch next weekend.\n\nBTW, if we changed PATCH 11/11 we'd obviously change PATCH\n9/11, too.\n\n\tSteffen\n\n\n>  int git_config(config_fn_t fn)\n> -- \n> 1.5.3.5.1592.g0d6db\n"},{"id":"60010","messageId":"200711151931.29029.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"9D2813B9-8E86-4551-94BF-2B04F5FBB141@zib.de","subject":"Re: [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-15T18:31:28Z","receivedAt":"2007-11-15T18:31:28Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Thursday 15 November 2007 07:53, Steffen Prohaska wrote:\n> Now I'm wondering if we could make path relocation a bit more\n> explicit.  How about doing something like.\n>\n> \tsystem_wide = relocate_path(ETC_GITCONFIG);\n>\n> and relocate_path(const char *) would expand a format\n> string in path.  At this point I see only a single %s\n> that would be expanded with the install prefix.  If\n> ETC_GITCONFIG is \"%s/etc/gitconfig\" relocate path will return\n> \"C:/msysgit/bin/etc/gitconfig\" for my above example.  It is\n> basically a printf with the install prefix path.\n\nI don't see the problem that you are trying to solve.\n\n-- Hannes\n"},{"id":"60017","messageId":"E652EC54-9F94-444F-AF94-2FA990355A78@zib.de","threadId":"10850","inReplyTo":"200711151931.29029.johannes.sixt@telecom.at","subject":"Re: [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-11-15T20:10:32Z","receivedAt":"2007-11-15T20:10:32Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Nov 15, 2007, at 7:31 PM, Johannes Sixt wrote:\n\n> On Thursday 15 November 2007 07:53, Steffen Prohaska wrote:\n>> Now I'm wondering if we could make path relocation a bit more\n>> explicit.  How about doing something like.\n>>\n>> \tsystem_wide = relocate_path(ETC_GITCONFIG);\n>>\n>> and relocate_path(const char *) would expand a format\n>> string in path.  At this point I see only a single %s\n>> that would be expanded with the install prefix.  If\n>> ETC_GITCONFIG is \"%s/etc/gitconfig\" relocate path will return\n>> \"C:/msysgit/bin/etc/gitconfig\" for my above example.  It is\n>> basically a printf with the install prefix path.\n>\n> I don't see the problem that you are trying to solve.\n\nPath relocation would be more explicit:\n1) Paths that need to be relocated are filtered through\n    relocate_path().  That's easy to understand.\n2) All the code prefixing the path is in relocate_path().\n    This avoids code duplication.\n3) Path that should be relocated contain \"%s\" in the Makefile.\n    This indicates that some string expansion may take place.\n\n(1) and (2) would be useful even if you do not agree with (3).\nThe code in PATCH 9/11 and PATCH 11/11 looks very similar.\nIf the prefixing code went into a separate function, we'd\nhave less code.  Also, relocate_path() could be useful at\nother places.  For example, I'd use it to locate the HTML\ndocumentation relative to the installation directory.\n\n\tSteffen\n"},{"id":"60025","messageId":"200711152243.10229.johannes.sixt@telecom.at","threadId":"10850","inReplyTo":"E652EC54-9F94-444F-AF94-2FA990355A78@zib.de","subject":"Re: [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-11-15T21:43:10Z","receivedAt":"2007-11-15T21:43:10Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Thursday 15 November 2007 21:10, Steffen Prohaska wrote:\n> On Nov 15, 2007, at 7:31 PM, Johannes Sixt wrote:\n> > On Thursday 15 November 2007 07:53, Steffen Prohaska wrote:\n> >> Now I'm wondering if we could make path relocation a bit more\n> >> explicit.  How about doing something like.\n> >>\n> >> \tsystem_wide = relocate_path(ETC_GITCONFIG);\n> >>\n> >> and relocate_path(const char *) would expand a format\n> >> string in path.  At this point I see only a single %s\n> >> that would be expanded with the install prefix.  If\n> >> ETC_GITCONFIG is \"%s/etc/gitconfig\" relocate path will return\n> >> \"C:/msysgit/bin/etc/gitconfig\" for my above example.  It is\n> >> basically a printf with the install prefix path.\n> >\n> > I don't see the problem that you are trying to solve.\n>\n> Path relocation would be more explicit:\n> 1) Paths that need to be relocated are filtered through\n>     relocate_path().  That's easy to understand.\n> 2) All the code prefixing the path is in relocate_path().\n>     This avoids code duplication.\n> 3) Path that should be relocated contain \"%s\" in the Makefile.\n>     This indicates that some string expansion may take place.\n>\n> (1) and (2) would be useful even if you do not agree with (3).\n> The code in PATCH 9/11 and PATCH 11/11 looks very similar.\n> If the prefixing code went into a separate function, we'd\n> have less code.  Also, relocate_path() could be useful at\n> other places.  For example, I'd use it to locate the HTML\n> documentation relative to the installation directory.\n\nHow is %s/foo different from ../foo? There are only 2 paths that need to be \nrelocatable. Your proposal is over-engineering, IMHO.\n\n-- Hannes\n"},{"id":"60039","messageId":"1046B46D-585D-47B6-91B3-38F760E68DD4@zib.de","threadId":"10850","inReplyTo":"200711152243.10229.johannes.sixt@telecom.at","subject":"Re: [PATCH 11/11] Allow ETC_GITCONFIG to be a relative path.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-11-15T22:24:52Z","receivedAt":"2007-11-15T22:24:52Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Nov 15, 2007, at 10:43 PM, Johannes Sixt wrote:\n\n> On Thursday 15 November 2007 21:10, Steffen Prohaska wrote:\n>> On Nov 15, 2007, at 7:31 PM, Johannes Sixt wrote:\n>>> On Thursday 15 November 2007 07:53, Steffen Prohaska wrote:\n>>>> Now I'm wondering if we could make path relocation a bit more\n>>>> explicit.  How about doing something like.\n>>>>\n>>>> \tsystem_wide = relocate_path(ETC_GITCONFIG);\n>>>>\n>>>> and relocate_path(const char *) would expand a format\n>>>> string in path.  At this point I see only a single %s\n>>>> that would be expanded with the install prefix.  If\n>>>> ETC_GITCONFIG is \"%s/etc/gitconfig\" relocate path will return\n>>>> \"C:/msysgit/bin/etc/gitconfig\" for my above example.  It is\n>>>> basically a printf with the install prefix path.\n>>>\n>>> I don't see the problem that you are trying to solve.\n>>\n>> Path relocation would be more explicit:\n>> 1) Paths that need to be relocated are filtered through\n>>     relocate_path().  That's easy to understand.\n>> 2) All the code prefixing the path is in relocate_path().\n>>     This avoids code duplication.\n>> 3) Path that should be relocated contain \"%s\" in the Makefile.\n>>     This indicates that some string expansion may take place.\n>>\n>> (1) and (2) would be useful even if you do not agree with (3).\n>> The code in PATCH 9/11 and PATCH 11/11 looks very similar.\n>> If the prefixing code went into a separate function, we'd\n>> have less code.  Also, relocate_path() could be useful at\n>> other places.  For example, I'd use it to locate the HTML\n>> documentation relative to the installation directory.\n>\n> How is %s/foo different from ../foo? There are only 2 paths that  \n> need to be\n> relocatable. Your proposal is over-engineering, IMHO.\n\nfair enough. Let's take your patches.\n\n\tSteffen\n"}]}