* [PATCH] Fix 'git commit -a' in a newly initialized repository
@ 2007-02-22 20:28 Fredrik Kuivinen
2007-02-22 20:42 ` Johannes Schindelin
0 siblings, 1 reply; 9+ messages in thread
From: Fredrik Kuivinen @ 2007-02-22 20:28 UTC (permalink / raw)
To: git
With current git:
$ git init
$ git commit -a
cp: cannot stat `.git/index': No such file or directory
Output a nice error message instead.
Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
---
git-commit.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/git-commit.sh b/git-commit.sh
index ec506d9..476f4f1 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -318,6 +318,10 @@ esac
case "$all,$also" in
t,)
+ if test ! -f "$THIS_INDEX"
+ then
+ die 'nothing to commit (use "git add file1 file2" to include for commit)'
+ fi
save_index &&
(
cd_to_toplevel &&
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 20:28 [PATCH] Fix 'git commit -a' in a newly initialized repository Fredrik Kuivinen
@ 2007-02-22 20:42 ` Johannes Schindelin
2007-02-22 20:54 ` Nicolas Pitre
0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2007-02-22 20:42 UTC (permalink / raw)
To: Fredrik Kuivinen; +Cc: git
Hi,
On Thu, 22 Feb 2007, Fredrik Kuivinen wrote:
> + die 'nothing to commit (use "git add file1 file2" to include for commit)'
Would it not make more sense to tell the user about "git add ."? Maybe
together with a hint about .gitignore?
This error message is important. The most likely recipients are total git
newsters, and we really should try to help them here.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 20:42 ` Johannes Schindelin
@ 2007-02-22 20:54 ` Nicolas Pitre
2007-02-22 20:59 ` Johannes Schindelin
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Pitre @ 2007-02-22 20:54 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Fredrik Kuivinen, git
On Thu, 22 Feb 2007, Johannes Schindelin wrote:
> Hi,
>
> On Thu, 22 Feb 2007, Fredrik Kuivinen wrote:
>
> > + die 'nothing to commit (use "git add file1 file2" to include for commit)'
>
> Would it not make more sense to tell the user about "git add ."?
Isn't what the patch does? IMHO it looks just like the empty commit
message which is good.
> Maybe
> together with a hint about .gitignore?
>
> This error message is important. The most likely recipients are total git
> newsters, and we really should try to help them here.
Sure. But to really help newsters it is better _not_ to talk about
.gitignore at all. It certainly won't exist at that point anyway.
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 20:54 ` Nicolas Pitre
@ 2007-02-22 20:59 ` Johannes Schindelin
2007-02-22 21:09 ` Nicolas Pitre
0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2007-02-22 20:59 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Fredrik Kuivinen, git
Hi,
On Thu, 22 Feb 2007, Nicolas Pitre wrote:
> On Thu, 22 Feb 2007, Johannes Schindelin wrote:
>
> > On Thu, 22 Feb 2007, Fredrik Kuivinen wrote:
> >
> > > + die 'nothing to commit (use "git add file1 file2" to include for commit)'
> >
> > Would it not make more sense to tell the user about "git add ."?
>
> Isn't what the patch does? IMHO it looks just like the empty commit
> message which is good.
I wanted to get at the "." thing. You know, when I start a project with
git, there are usually some files there already. Provided I have a
.gitignore there, I can just say "git add ." and be done.
But maybe that is _not_ common practice?
> > Maybe together with a hint about .gitignore?
> >
> > This error message is important. The most likely recipients are total
> > git newsters, and we really should try to help them here.
>
> Sure. But to really help newsters it is better _not_ to talk about
> .gitignore at all. It certainly won't exist at that point anyway.
Hmm. That is a really good point. Hmmm. I think you're right.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 20:59 ` Johannes Schindelin
@ 2007-02-22 21:09 ` Nicolas Pitre
2007-02-22 21:13 ` Johannes Schindelin
2007-02-22 21:36 ` Junio C Hamano
0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Pitre @ 2007-02-22 21:09 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Fredrik Kuivinen, git
On Thu, 22 Feb 2007, Johannes Schindelin wrote:
> Hi,
>
> On Thu, 22 Feb 2007, Nicolas Pitre wrote:
>
> > On Thu, 22 Feb 2007, Johannes Schindelin wrote:
> >
> > > On Thu, 22 Feb 2007, Fredrik Kuivinen wrote:
> > >
> > > > + die 'nothing to commit (use "git add file1 file2" to include for commit)'
> > >
> > > Would it not make more sense to tell the user about "git add ."?
> >
> > Isn't what the patch does? IMHO it looks just like the empty commit
> > message which is good.
>
> I wanted to get at the "." thing. You know, when I start a project with
> git, there are usually some files there already. Provided I have a
> .gitignore there, I can just say "git add ." and be done.
>
> But maybe that is _not_ common practice?
Well... If you're that acquainted with GIT to perform the above, I'm
sure a message like "use "git add file1 file2" to include for commit"
won't leave you puzzled. ;-)
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 21:09 ` Nicolas Pitre
@ 2007-02-22 21:13 ` Johannes Schindelin
2007-02-22 21:36 ` Junio C Hamano
1 sibling, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2007-02-22 21:13 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Fredrik Kuivinen, git
Hi,
On Thu, 22 Feb 2007, Nicolas Pitre wrote:
> On Thu, 22 Feb 2007, Johannes Schindelin wrote:
>
> > I wanted to get at the "." thing. You know, when I start a project
> > with git, there are usually some files there already. Provided I have
> > a .gitignore there, I can just say "git add ." and be done.
> >
> > But maybe that is _not_ common practice?
>
> Well... If you're that acquainted with GIT to perform the above, I'm
> sure a message like "use "git add file1 file2" to include for commit"
> won't leave you puzzled. ;-)
;-) Yes, you are right!
Ciao,
Dscho
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 21:09 ` Nicolas Pitre
2007-02-22 21:13 ` Johannes Schindelin
@ 2007-02-22 21:36 ` Junio C Hamano
2007-02-23 0:06 ` Nicolas Pitre
1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2007-02-22 21:36 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Johannes Schindelin, Fredrik Kuivinen, git
If we want to limit the help to lone liner, I am with Nicolas and
Fredrik on this one. Suggesting only "git add ." does not feel
helpful.
However, because ! test -f "$THIS_INDEX" is such a special case
(totally new check-in), we can afford to be verbose if we wanted
to, and offer tons of possibilities, say:
die 'nothing to commit. You can use "git add file..."
to include individual files, or use "git add ." if you want to
include all files in the current directory, for your first
commit.'
But if we want to say "for your first commit" in the message, we
should also be checking if HEAD commit really does not exist.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-22 21:36 ` Junio C Hamano
@ 2007-02-23 0:06 ` Nicolas Pitre
2007-02-23 5:03 ` Junio C Hamano
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Pitre @ 2007-02-23 0:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Fredrik Kuivinen, git
On Thu, 22 Feb 2007, Junio C Hamano wrote:
> However, because ! test -f "$THIS_INDEX" is such a special case
> (totally new check-in), we can afford to be verbose if we wanted
> to, and offer tons of possibilities, say:
>
> die 'nothing to commit. You can use "git add file..."
> to include individual files, or use "git add ." if you want to
> include all files in the current directory, for your first
> commit.'
>
> But if we want to say "for your first commit" in the message, we
> should also be checking if HEAD commit really does not exist.
Seems to me that the single line message avoids all those issues.
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Fix 'git commit -a' in a newly initialized repository
2007-02-23 0:06 ` Nicolas Pitre
@ 2007-02-23 5:03 ` Junio C Hamano
0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2007-02-23 5:03 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Johannes Schindelin, Fredrik Kuivinen, git
Nicolas Pitre <nico@cam.org> writes:
> On Thu, 22 Feb 2007, Junio C Hamano wrote:
>
>> However, because ! test -f "$THIS_INDEX" is such a special case
>> (totally new check-in), we can afford to be verbose if we wanted
>> to, and offer tons of possibilities, say:
>>
>> die 'nothing to commit. You can use "git add file..."
>> to include individual files, or use "git add ." if you want to
>> include all files in the current directory, for your first
>> commit.'
>>
>> But if we want to say "for your first commit" in the message, we
>> should also be checking if HEAD commit really does not exist.
>
> Seems to me that the single line message avoids all those issues.
Yup. Will apply Fredrik's original to 'maint'.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-02-23 5:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-22 20:28 [PATCH] Fix 'git commit -a' in a newly initialized repository Fredrik Kuivinen
2007-02-22 20:42 ` Johannes Schindelin
2007-02-22 20:54 ` Nicolas Pitre
2007-02-22 20:59 ` Johannes Schindelin
2007-02-22 21:09 ` Nicolas Pitre
2007-02-22 21:13 ` Johannes Schindelin
2007-02-22 21:36 ` Junio C Hamano
2007-02-23 0:06 ` Nicolas Pitre
2007-02-23 5:03 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).