All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: pascal@obry.net
Cc: Luciano Rocha <luciano@eurotux.com>, git list <git@vger.kernel.org>
Subject: Re: something fishy with Git commit and log from file
Date: Wed, 06 Aug 2008 09:50:13 -0700	[thread overview]
Message-ID: <7vy73aqe9m.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <4899D119.1080403@obry.net> (Pascal Obry's message of "Wed, 06 Aug 2008 18:28:09 +0200")

Pascal Obry <pascal@obry.net> writes:

> Junio C Hamano a écrit :
>> Pascal Obry <pascal@obry.net> writes:
>>
>>> So definitely a Git bug! Can be reproduced with:
>>>
>>>    $ mkdir repo && cd repo
>>>    $ git init
>>>    $ mkdir dir
>>>    $ cd dir
>>>    $ echo file > file
>>>    $ echo log > log
>>>    $ git add file
>>>    $ git commit --file=log
>>>    fatal: could not read log file 'log': No such file or directory
>>
>> Try it without cding down to "dir".
>
> Yes it works.

Perhaps something like this.  This must be another one of those
regressions introduced in C rewrite.

diff --git a/builtin-commit.c b/builtin-commit.c
index b783e6e..fcc9c59 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -469,7 +469,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
 			die("could not read log from standard input");
 		hook_arg1 = "message";
 	} else if (logfile) {
-		if (strbuf_read_file(&sb, logfile, 0) < 0)
+		const char *lf = logfile;
+		if (prefix)
+			lf = prefix_filename(prefix, strlen(prefix), logfile);
+		if (strbuf_read_file(&sb, lf, 0) < 0)
 			die("could not read log file '%s': %s",
 			    logfile, strerror(errno));
 		hook_arg1 = "message";

  reply	other threads:[~2008-08-06 16:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 10:30 something fishy with Git commit and log from file Pascal Obry
2008-08-06 10:44 ` Luciano Rocha
2008-08-06 11:01   ` Pascal Obry
2008-08-06 15:38     ` Junio C Hamano
2008-08-06 16:28       ` Pascal Obry
2008-08-06 16:50         ` Junio C Hamano [this message]
2008-08-06 17:08           ` Pascal Obry
2008-08-06 18:43           ` [PATCH] files given on the command line are relative to $cwd Junio C Hamano
2008-08-06 20:14             ` Olivier Marin
2008-08-06 20:19               ` Junio C Hamano
2008-08-06 20:59                 ` Junio C Hamano
2008-08-06 20:40             ` Pierre Habouzit
2008-08-07  8:45             ` Samuel Tardieu
2008-08-07  9:03               ` Luciano Rocha
2008-08-07  9:47                 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vy73aqe9m.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=luciano@eurotux.com \
    --cc=pascal@obry.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.