Bug 20072

Summary: stupid messages in a bare repo
Product: Branch 4.1 Reporter: Ivan Zakharyaschev <imz>
Component: gitAssignee: Nobody's working on this, feel free to take it <nobody>
Status: CLOSED WONTFIX QA Contact: qa-4.1 <qa-4.1>
Severity: minor    
Priority: P3    
Version: unspecified   
Hardware: all   
OS: Linux   

Description Ivan Zakharyaschev 2009-05-16 22:15:09 MSD
git-1.5.5.5-alt1

Stpid messages are printed when working in bare repos (they would make sense inside a working dir): 

[imz@localhost repo.git]$ git reset HEAD^ 
f: needs update
[imz@localhost repo.git]$ 

How to reproduce: 

[imz@localhost git-bare-msgs]$ mkdir repo
[imz@localhost git-bare-msgs]$ cd repo/
[imz@localhost repo]$ git init
Initialized empty Git repository in .git/
[imz@localhost repo]$ echo a > f
[imz@localhost repo]$ git add f
[imz@localhost repo]$ git commit -m a.
Created initial commit a6437c2: a.
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 f
[imz@localhost repo]$ echo b > f
[imz@localhost repo]$ git commit -m b. -a
Created commit 59bec0a: b.
 1 files changed, 1 insertions(+), 1 deletions(-)
[imz@localhost repo]$ git clone --bare ./ ../repo.git
Initialized empty Git repository in /home/imz/SAVED-for-me-and-everyone/bugreports/git-bare-msgs/repo.git/
[imz@localhost repo]$ cd ../repo.git
[imz@localhost repo.git]$ git reset HEAD^ --hard
fatal: hard reset makes no sense in a bare repository
[imz@localhost repo.git]$ git reset HEAD^ 
f: needs update
[imz@localhost repo.git]$ git status
fatal: This operation must be run in a work tree
[imz@localhost repo.git]$ ls
branches  config  description  HEAD  hooks  index  info  objects  ORIG_HEAD  refs
[imz@localhost repo.git]$ git --no-pager log
commit a6437c2fa63c06a550b3e3061671c9504f10a318
Author: Ivan Zakharyaschev <imz@altlinux.org>
Date:   Sat May 16 18:06:56 2009 +0000

    a.
[imz@localhost repo.git]$ 

So, the command "git reset HEAD^" took effect (as can be seen from the log), but it printed confusing messages.
Comment 1 Dmitry V. Levin 2009-06-05 02:16:50 MSD
git-core-1.6.3.1-alt1 has no such problem:

$ git reset HEAD^
fatal: This operation must be run in a work tree
fatal: Could not reset index file to revision 'HEAD^'.
Comment 2 Michael Shigorin 2014-11-05 20:42:44 MSK
В 4.1/branch исправления не будут вноситься уже технически (заглушена очередь на сборку), поэтому прошу ошибки, актуальные для sisyphus/p7/t7, перевесить на текущие ветки или сизиф.