git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] files given on the command line are relative to $cwd

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 6, 2008, 20:59 UTC
Message-ID
<7vd4kln9le.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<7vtzdxnbgk.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Olivier Marin <dkr+ml.git@free.fr> writes:
>
>> Junio C Hamano a écrit :
>>>  
>>>  static int parse_and_validate_options(int argc, const char *argv[],
>>> -				      const char * const usage[])
>>> +				      const char * const usage[],
>>> +				      const char *prefix)
>>>  {
>>>  	int f = 0;
>>>  
>>>  	argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
>>> +	logfile = parse_options_fix_filename(prefix, logfile);
>>
>> It breaks the "git commit -F -" case, no?
>
> Does it?  Ah, yeah, t7500 #15 does not go down to a subdirectory.
Ok, this squashed in on top of the previous one should cover the case.

Thanks for saving me in time from a major embarrassment. I already tagged 1.5.6.5 with the botched one but haven't pushed it out, so I can safely rewind.

---
 parse-options.c   |    2 +-
 t/t7500-commit.sh |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index d771bf4..12c8822 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -432,7 +432,7 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
  */
 extern const char *parse_options_fix_filename(const char *prefix, const char *file)
 {
-	if (!file || !prefix || is_absolute_path(file))
+	if (!file || !prefix || is_absolute_path(file) || !strcmp("-", file))
 		return file;
 	return prefix_filename(prefix, strlen(prefix), file);
 }
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 2ab791b..823256a 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -159,4 +159,12 @@ test_expect_success 'commit message from file (2)' '
 	commit_msg_is "Log in sub directory"
 '
 
+test_expect_success 'commit message from stdin' '
+	(
+		cd subdir &&
+		echo "Log with foo word" | git commit --allow-empty -F -
+	) &&
+	commit_msg_is "Log with foo word"
+'
+
 test_done
Previous: Junio C HamanoNext: Pierre Habouzit
Message 11 of 15 in “something fishy with Git commit and log from file”
  1. Pascal ObryAug 6, 2008
  2. Luciano RochaAug 6, 2008
  3. Pascal ObryAug 6, 2008
  4. Junio C HamanoAug 6, 2008
  5. Pascal ObryAug 6, 2008
  6. Junio C HamanoAug 6, 2008
  7. Pascal ObryAug 6, 2008
  8. files given on the command line are relative to $cwdJunio C Hamano, Aug 6, 2008
  9. Olivier MarinAug 6, 2008
  10. Junio C HamanoAug 6, 2008
  11. Junio C HamanoAug 6, 2008
  12. Pierre HabouzitAug 6, 2008
  13. Samuel TardieuAug 7, 2008
  14. Luciano RochaAug 7, 2008
  15. Junio C HamanoAug 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.