{"thread":{"id":"14860","subject":"something fishy with Git commit and log from file","startedAt":"2008-08-06T10:30:06Z","lastAt":"2008-08-07T09:47:39Z","messageCount":15,"participants":["Pascal Obry","Luciano Rocha","Junio C Hamano","Olivier Marin","Pierre Habouzit","Samuel Tardieu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"86331","messageId":"48997D2E.9030708@obry.net","threadId":"14860","inReplyTo":null,"subject":"something fishy with Git commit and log from file","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2008-08-06T10:30:06Z","receivedAt":"2008-08-06T10:30:06Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"\nThe following command fails on my repository:\n\n    $ git commit --file=clog\n    fatal: could not read log file 'clog': No such file or directory\n\n    $ cat clog\n    toto\n\nUsing the following command the commit pass without problem:\n\n    $ cat clog | git commit --file=-\n\nWith GDB I get:\n\n$ gdb --args git ci --file=clog\nThis GDB was configured as \"i686-pc-cygwin\"...\n(gdb) break strbuf_read_file\nBreakpoint 1 at 0x44e64a: file strbuf.c, line 301.\n(gdb) run\nStarting program: /usr/local/bin/git.exe ci --file=clog\n\nBreakpoint 1, strbuf_read_file (sb=0x22cac0, path=0x22ccfa \"clog\", \nhint=0) at strbuf.c:301\n301             fd = open(path, O_RDONLY);\n(gdb) print path\n$1 = 0x0\n\n???? outch, this is strange, or a gdb artifact?\n\n(gdb) n\n302             if (fd < 0)\n(gdb) print fd\n$2 = -1\n(gdb) print *0x22ccfa\n$3 = 1735355491\n(gdb) print (char)*0x22ccfa\n$4 = 99 'c'\n(gdb) print (char)*0x22ccfb\n$5 = 108 'l'\n(gdb) print (char)*0x22ccfc\n$6 = 111 'o'\n(gdb) print (char)*0x22ccfd\n$7 = 103 'g'\n(gdb) print (char)*0x22ccfe\n$8 = 0 '\\0'\n\nBut looks like path really contains 'clog'!!!\n\nNo luck for now to find the problem. Note that the same command pass \nfine on other repositories. At this point this looks really like some \nkind of memory corruption...\n\nI'm on Windows, using Git for Cygwin and the compiler is:\n\n$ gcc --version\ngcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"86332","messageId":"20080806104432.GG7121@bit.office.eurotux.com","threadId":"14860","inReplyTo":"48997D2E.9030708@obry.net","subject":"Re: something fishy with Git commit and log from file","fromName":"Luciano Rocha","fromEmail":"luciano@eurotux.com","sentAt":"2008-08-06T10:44:32Z","receivedAt":"2008-08-06T10:44:32Z","isPatch":false,"sender":{"key":"luciano@eurotux.com","avatar":null},"body":"On Wed, Aug 06, 2008 at 12:30:06PM +0200, Pascal Obry wrote:\n> \n>  The following command fails on my repository:\n> \n>     $ git commit --file=clog\n>     fatal: could not read log file 'clog': No such file or directory\n> \n>     $ cat clog\n>     toto\n> \n>  Using the following command the commit pass without problem:\n> \n>     $ cat clog | git commit --file=-\n> \n>  With GDB I get:\n> \n>  $ gdb --args git ci --file=clog\n>  This GDB was configured as \"i686-pc-cygwin\"...\n>  (gdb) break strbuf_read_file\n>  Breakpoint 1 at 0x44e64a: file strbuf.c, line 301.\n>  (gdb) run\n>  Starting program: /usr/local/bin/git.exe ci --file=clog\n> \n>  Breakpoint 1, strbuf_read_file (sb=0x22cac0, path=0x22ccfa \"clog\", hint=0) \n>  at strbuf.c:301\n>  301             fd = open(path, O_RDONLY);\n>  (gdb) print path\n>  $1 = 0x0\n> \n>  ???? outch, this is strange, or a gdb artifact?\n\ngdb artifact. The breakpoint info shows the correct value.\n\nCould you at that point run the following?\n\n(gdb) p get_current_dir_name()\n$1 = ... \"...\"\n\nIf the returned value doesn't match the directory you were in, then\nthere's a bug in git.\n\nIf the function doesn't exist, try:\n(gdb) p getwd(malloc(2048))\n\nRegards,\nLuciano Rocha\n\n-- \nLuciano Rocha <luciano@eurotux.com>\nEurotux Informática, S.A. <http://www.eurotux.com/>\n"},{"id":"86334","messageId":"4899848C.6030800@obry.net","threadId":"14860","inReplyTo":"20080806104432.GG7121@bit.office.eurotux.com","subject":"Re: something fishy with Git commit and log from file","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2008-08-06T11:01:32Z","receivedAt":"2008-08-06T11:01:32Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Luciano,\n\n> If the function doesn't exist, try:\n> (gdb) p getwd(malloc(2048))\n\nI got:\n\n(gdb) p (char *)getwd(malloc(2048))\n$3 = 0x903680 \"/home/obry/dev/repositories/git/AWS\"\n\nAnd this is not the directory I was in. It is the Git root. I was under \n/home/obry/dev/repositories/git/AWS/regtests when running the command.\n\nSo definitely a Git bug! Can be reproduced with:\n\n    $ mkdir repo && cd repo\n    $ git init\n    $ mkdir dir\n    $ cd dir\n    $ echo file > file\n    $ echo log > log\n    $ git add file\n    $ git commit --file=log\n    fatal: could not read log file 'log': No such file or directory\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"86353","messageId":"7v3alirw6b.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"4899848C.6030800@obry.net","subject":"Re: something fishy with Git commit and log from file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-06T15:38:04Z","receivedAt":"2008-08-06T15:38:04Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pascal Obry <pascal@obry.net> writes:\n\n> So definitely a Git bug! Can be reproduced with:\n>\n>    $ mkdir repo && cd repo\n>    $ git init\n>    $ mkdir dir\n>    $ cd dir\n>    $ echo file > file\n>    $ echo log > log\n>    $ git add file\n>    $ git commit --file=log\n>    fatal: could not read log file 'log': No such file or directory\n\nTry it without cding down to \"dir\".\n"},{"id":"86358","messageId":"4899D119.1080403@obry.net","threadId":"14860","inReplyTo":"7v3alirw6b.fsf@gitster.siamese.dyndns.org","subject":"Re: something fishy with Git commit and log from file","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2008-08-06T16:28:09Z","receivedAt":"2008-08-06T16:28:09Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Junio C Hamano a écrit :\n> Pascal Obry <pascal@obry.net> writes:\n> \n>> So definitely a Git bug! Can be reproduced with:\n>>\n>>    $ mkdir repo && cd repo\n>>    $ git init\n>>    $ mkdir dir\n>>    $ cd dir\n>>    $ echo file > file\n>>    $ echo log > log\n>>    $ git add file\n>>    $ git commit --file=log\n>>    fatal: could not read log file 'log': No such file or directory\n> \n> Try it without cding down to \"dir\".\n\nYes it works. It also works if I do:\n\n     $ echo log > ../log\n\ninstead of\n\n     $ echo log > log\n\nGit is looking for the log file at the Git root.\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"86360","messageId":"7vy73aqe9m.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"4899D119.1080403@obry.net","subject":"Re: something fishy with Git commit and log from file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-06T16:50:13Z","receivedAt":"2008-08-06T16:50:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pascal Obry <pascal@obry.net> writes:\n\n> Junio C Hamano a écrit :\n>> Pascal Obry <pascal@obry.net> writes:\n>>\n>>> So definitely a Git bug! Can be reproduced with:\n>>>\n>>>    $ mkdir repo && cd repo\n>>>    $ git init\n>>>    $ mkdir dir\n>>>    $ cd dir\n>>>    $ echo file > file\n>>>    $ echo log > log\n>>>    $ git add file\n>>>    $ git commit --file=log\n>>>    fatal: could not read log file 'log': No such file or directory\n>>\n>> Try it without cding down to \"dir\".\n>\n> Yes it works.\n\nPerhaps something like this.  This must be another one of those\nregressions introduced in C rewrite.\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex b783e6e..fcc9c59 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -469,7 +469,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix)\n \t\t\tdie(\"could not read log from standard input\");\n \t\thook_arg1 = \"message\";\n \t} else if (logfile) {\n-\t\tif (strbuf_read_file(&sb, logfile, 0) < 0)\n+\t\tconst char *lf = logfile;\n+\t\tif (prefix)\n+\t\t\tlf = prefix_filename(prefix, strlen(prefix), logfile);\n+\t\tif (strbuf_read_file(&sb, lf, 0) < 0)\n \t\t\tdie(\"could not read log file '%s': %s\",\n \t\t\t    logfile, strerror(errno));\n \t\thook_arg1 = \"message\";\n"},{"id":"86361","messageId":"4899DA8B.3010105@obry.net","threadId":"14860","inReplyTo":"7vy73aqe9m.fsf@gitster.siamese.dyndns.org","subject":"Re: something fishy with Git commit and log from file","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2008-08-06T17:08:27Z","receivedAt":"2008-08-06T17:08:27Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"Junio C Hamano a écrit :\n> Perhaps something like this.  This must be another one of those\n> regressions introduced in C rewrite.\n\nWorks fine now. Thanks.\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"86364","messageId":"7vr692oufw.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"7vy73aqe9m.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] files given on the command line are relative to $cwd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-06T18:43:47Z","receivedAt":"2008-08-06T18:43:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When running \"git commit -F file\" and \"git tag -F file\" from a\nsubdirectory, we should take it as relative to the directory we started\nfrom, not relative to the top-level directory.\n\nThis adds a helper function \"parse_options_fix_filename()\" to make it more\nconvenient to fix this class of issues.  Ideally, parse_options() should\nsupport a new type of option, \"OPT_FILENAME\", to do this uniformly, but\nthis patch is meant to go to 'maint' to fix it minimally.\n\nOne thing to note is that value for \"commit template file\" that comes from\nthe command line is taken as relative to $cwd just like other parameters,\nbut when it comes from the configuration varilable 'commit.template', it\nis taken as relative to the working tree root as before.  I think this\ndifference actually is sensible (not that I particularly think\ncommit.template itself is sensible).\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-commit.c  |   11 +++++++----\n builtin-tag.c     |    1 +\n parse-options.c   |   12 ++++++++++++\n parse-options.h   |    2 ++\n t/t7500-commit.sh |   11 +++++++++++\n 5 files changed, 33 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex bcbea38..0c6d1f4 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -45,7 +45,7 @@ static enum {\n \tCOMMIT_PARTIAL,\n } commit_style;\n \n-static char *logfile, *force_author;\n+static const char *logfile, *force_author;\n static const char *template_file;\n static char *edit_message, *use_message;\n static char *author_name, *author_email, *author_date;\n@@ -700,11 +700,14 @@ static int message_is_empty(struct strbuf *sb, int start)\n }\n \n static int parse_and_validate_options(int argc, const char *argv[],\n-\t\t\t\t      const char * const usage[])\n+\t\t\t\t      const char * const usage[],\n+\t\t\t\t      const char *prefix)\n {\n \tint f = 0;\n \n \targc = parse_options(argc, argv, builtin_commit_options, usage, 0);\n+\tlogfile = parse_options_fix_filename(prefix, logfile);\n+\ttemplate_file = parse_options_fix_filename(prefix, template_file);\n \n \tif (logfile || message.len || use_message)\n \t\tuse_editor = 0;\n@@ -814,7 +817,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \tif (wt_status_use_color == -1)\n \t\twt_status_use_color = git_use_color_default;\n \n-\targc = parse_and_validate_options(argc, argv, builtin_status_usage);\n+\targc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);\n \n \tindex_file = prepare_index(argc, argv, prefix);\n \n@@ -907,7 +910,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)\n \n \tgit_config(git_commit_config, NULL);\n \n-\targc = parse_and_validate_options(argc, argv, builtin_commit_usage);\n+\targc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);\n \n \tindex_file = prepare_index(argc, argv, prefix);\n \ndiff --git a/builtin-tag.c b/builtin-tag.c\nindex 3c97c69..3f77ba9 100644\n--- a/builtin-tag.c\n+++ b/builtin-tag.c\n@@ -411,6 +411,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tgit_config(git_tag_config, NULL);\n \n \targc = parse_options(argc, argv, options, git_tag_usage, 0);\n+\tmsgfile = parse_options_fix_filename(prefix, msgfile);\n \n \tif (keyid) {\n \t\tsign = 1;\ndiff --git a/parse-options.c b/parse-options.c\nindex f8d52e2..d771bf4 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -425,3 +425,15 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,\n \t*(unsigned long *)(opt->value) = approxidate(arg);\n \treturn 0;\n }\n+\n+/*\n+ * This should really be OPTION_FILENAME type as a part of\n+ * parse_options that take prefix to do this while parsing.\n+ */\n+extern const char *parse_options_fix_filename(const char *prefix, const char *file)\n+{\n+\tif (!file || !prefix || is_absolute_path(file))\n+\t\treturn file;\n+\treturn prefix_filename(prefix, strlen(prefix), file);\n+}\n+\ndiff --git a/parse-options.h b/parse-options.h\nindex 4ee443d..13ad158 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -123,4 +123,6 @@ extern int parse_opt_approxidate_cb(const struct option *, const char *, int);\n \t  \"use <n> digits to display SHA-1s\", \\\n \t  PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 }\n \n+extern const char *parse_options_fix_filename(const char *prefix, const char *file);\n+\n #endif\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex baed6ce..026d787 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -138,4 +138,15 @@ test_expect_success '--signoff' '\n \tdiff expect output\n '\n \n+test_expect_success 'commit message from file' '\n+\tmkdir subdir &&\n+\techo \"Log in top directory\" >log &&\n+\techo \"Log in sub directory\" >subdir/log &&\n+\t(\n+\t\tcd subdir &&\n+\t\tgit commit --allow-empty -F log\n+\t) &&\n+\tcommit_msg_is \"Log in sub directory\"\n+'\n+\n test_done\n"},{"id":"86368","messageId":"489A061B.7010508@free.fr","threadId":"14860","inReplyTo":"7vr692oufw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-08-06T20:14:19Z","receivedAt":"2008-08-06T20:14:19Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Junio C Hamano a écrit :\n>  \n>  static int parse_and_validate_options(int argc, const char *argv[],\n> -\t\t\t\t      const char * const usage[])\n> +\t\t\t\t      const char * const usage[],\n> +\t\t\t\t      const char *prefix)\n>  {\n>  \tint f = 0;\n>  \n>  \targc = parse_options(argc, argv, builtin_commit_options, usage, 0);\n> +\tlogfile = parse_options_fix_filename(prefix, logfile);\n\nIt breaks the \"git commit -F -\" case, no?\n\nOlivier.\n"},{"id":"86370","messageId":"7vtzdxnbgk.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"489A061B.7010508@free.fr","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-06T20:19:07Z","receivedAt":"2008-08-06T20:19:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olivier Marin <dkr+ml.git@free.fr> writes:\n\n> Junio C Hamano a écrit :\n>>  \n>>  static int parse_and_validate_options(int argc, const char *argv[],\n>> -\t\t\t\t      const char * const usage[])\n>> +\t\t\t\t      const char * const usage[],\n>> +\t\t\t\t      const char *prefix)\n>>  {\n>>  \tint f = 0;\n>>  \n>>  \targc = parse_options(argc, argv, builtin_commit_options, usage, 0);\n>> +\tlogfile = parse_options_fix_filename(prefix, logfile);\n>\n> It breaks the \"git commit -F -\" case, no?\n\nDoes it?  Ah, yeah, t7500 #15 does not go down to a subdirectory.\n"},{"id":"86371","messageId":"20080806204002.GB903@artemis.madism.org","threadId":"14860","inReplyTo":"7vr692oufw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-08-06T20:40:02Z","receivedAt":"2008-08-06T20:40:02Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Wed, Aug 06, 2008 at 06:43:47PM +0000, Junio C Hamano wrote:\n> When running \"git commit -F file\" and \"git tag -F file\" from a\n> subdirectory, we should take it as relative to the directory we started\n> from, not relative to the top-level directory.\n> \n> This adds a helper function \"parse_options_fix_filename()\" to make it more\n> convenient to fix this class of issues.  Ideally, parse_options() should\n> support a new type of option, \"OPT_FILENAME\", to do this uniformly, but\n> this patch is meant to go to 'maint' to fix it minimally.\n\n  I'm going in vacation tomorrow so I'm not likely to do that soon, but\nI agree it's sensible.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"86372","messageId":"7vd4kln9le.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"7vtzdxnbgk.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-06T20:59:25Z","receivedAt":"2008-08-06T20:59:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Olivier Marin <dkr+ml.git@free.fr> writes:\n>\n>> Junio C Hamano a écrit :\n>>>  \n>>>  static int parse_and_validate_options(int argc, const char *argv[],\n>>> -\t\t\t\t      const char * const usage[])\n>>> +\t\t\t\t      const char * const usage[],\n>>> +\t\t\t\t      const char *prefix)\n>>>  {\n>>>  \tint f = 0;\n>>>  \n>>>  \targc = parse_options(argc, argv, builtin_commit_options, usage, 0);\n>>> +\tlogfile = parse_options_fix_filename(prefix, logfile);\n>>\n>> It breaks the \"git commit -F -\" case, no?\n>\n> Does it?  Ah, yeah, t7500 #15 does not go down to a subdirectory.\n\nOk, this squashed in on top of the previous one should cover the case.\n\nThanks for saving me in time from a major embarrassment.  I already tagged\n1.5.6.5 with the botched one but haven't pushed it out, so I can safely\nrewind.\n\n---\n\n parse-options.c   |    2 +-\n t/t7500-commit.sh |    8 ++++++++\n 2 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/parse-options.c b/parse-options.c\nindex d771bf4..12c8822 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -432,7 +432,7 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,\n  */\n extern const char *parse_options_fix_filename(const char *prefix, const char *file)\n {\n-\tif (!file || !prefix || is_absolute_path(file))\n+\tif (!file || !prefix || is_absolute_path(file) || !strcmp(\"-\", file))\n \t\treturn file;\n \treturn prefix_filename(prefix, strlen(prefix), file);\n }\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex 2ab791b..823256a 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -159,4 +159,12 @@ test_expect_success 'commit message from file (2)' '\n \tcommit_msg_is \"Log in sub directory\"\n '\n \n+test_expect_success 'commit message from stdin' '\n+\t(\n+\t\tcd subdir &&\n+\t\techo \"Log with foo word\" | git commit --allow-empty -F -\n+\t) &&\n+\tcommit_msg_is \"Log with foo word\"\n+'\n+\n test_done\n"},{"id":"86399","messageId":"2008-08-07-10-45-21+trackit+sam@rfc1149.net","threadId":"14860","inReplyTo":"7vr692oufw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-08-07T08:45:21Z","receivedAt":"2008-08-07T08:45:21Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Junio\" == Junio C Hamano <gitster@pobox.com> writes:\n\nJunio> When running \"git commit -F file\" and \"git tag -F file\" from a\nJunio> subdirectory, we should take it as relative to the directory we\nJunio> started from, not relative to the top-level directory.\n\nDon't we have the same problem with \"git show\"? If you go into\nthe \"gitweb\" directory of the GIT source, \"git show HEAD:README\" will\nshow you the toplevel \"README\" instead of the one in the \"gitweb\"\ndirectory.\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"},{"id":"86411","messageId":"20080807090341.GA6421@bit.office.eurotux.com","threadId":"14860","inReplyTo":"2008-08-07-10-45-21+trackit+sam@rfc1149.net","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Luciano Rocha","fromEmail":"luciano@eurotux.com","sentAt":"2008-08-07T09:03:41Z","receivedAt":"2008-08-07T09:03:41Z","isPatch":true,"sender":{"key":"luciano@eurotux.com","avatar":null},"body":"On Thu, Aug 07, 2008 at 10:45:21AM +0200, Samuel Tardieu wrote:\n> >>>>> \"Junio\" == Junio C Hamano <gitster@pobox.com> writes:\n> \n> Junio> When running \"git commit -F file\" and \"git tag -F file\" from a\n> Junio> subdirectory, we should take it as relative to the directory we\n> Junio> started from, not relative to the top-level directory.\n> \n> Don't we have the same problem with \"git show\"? If you go into\n> the \"gitweb\" directory of the GIT source, \"git show HEAD:README\" will\n> show you the toplevel \"README\" instead of the one in the \"gitweb\"\n> directory.\n\nNo, git show has different semantics. It has been discussed often in\nthis list.\n\nFor instance:\nhttp://thread.gmane.org/gmane.comp.version-control.git/68786/focus=68852\n\n-- \nLuciano Rocha <luciano@eurotux.com>\nEurotux Informática, S.A. <http://www.eurotux.com/>\n"},{"id":"86401","messageId":"7v8wv9jgw4.fsf@gitster.siamese.dyndns.org","threadId":"14860","inReplyTo":"20080807090341.GA6421@bit.office.eurotux.com","subject":"Re: [PATCH] files given on the command line are relative to $cwd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-07T09:47:39Z","receivedAt":"2008-08-07T09:47:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luciano Rocha <luciano@eurotux.com> writes:\n\n> On Thu, Aug 07, 2008 at 10:45:21AM +0200, Samuel Tardieu wrote:\n>> >>>>> \"Junio\" == Junio C Hamano <gitster@pobox.com> writes:\n>> \n>> Junio> When running \"git commit -F file\" and \"git tag -F file\" from a\n>> Junio> subdirectory, we should take it as relative to the directory we\n>> Junio> started from, not relative to the top-level directory.\n>> \n>> Don't we have the same problem with \"git show\"? If you go into\n>> the \"gitweb\" directory of the GIT source, \"git show HEAD:README\" will\n>> show you the toplevel \"README\" instead of the one in the \"gitweb\"\n>> directory.\n>\n> No, git show has different semantics. It has been discussed often in\n> this list.\n\nYou are half correct --- it is not show but tree:path syntax.\n"}]}