tig icon indicating copy to clipboard operation
tig copied to clipboard

tig not starting in a valid git repository with no commits

Open proski opened this issue 10 years ago • 8 comments

tig (even the current version from git) is not working in a repository without commits, even though it could show what is staged for commit, which would be useful.

$ git init Initialized empty Git repository in /home/proski/src/tig-test/.git/ $ echo staged >file1 $ git add file1 $ echo unstaged >file2 $ tig tig: No revisions match the given arguments.

There are no arguments, so the error message is misleading.

proski avatar Oct 09 '15 05:10 proski

+1. I guess you could directly start in status view with tig status

netei avatar Oct 09 '15 11:10 netei

As @netei points out tig status is the only command that works in such situation. I like the idea of redirecting to tig status but it might also be considered somewhat confusing.

git log says fatal: bad default revision 'HEAD'. Is that better?

jonas avatar Oct 09 '15 12:10 jonas

I expect tig to work just like it works in repositories with revisions. It can show staged changes. It can show unstaged changes to the added files.

It may look like a pathological case from the coding standpoint, but it's not a pathological case for a developer. I create a repository, write code and then I want to use my usual tool to double check what I'm committing. And the tool is suddenly unhappy.

proski avatar Oct 12 '15 04:10 proski

I understand that and my question was mainly to understand how tig should behave. Running tig in a repository without any revisions does not make sense when tig is defined in terms of git-log, so it might be just a case of detecting this and either switch to status view or error our with a message saying No commit log, did you mean to run 'tig status'?.

On Mon, Oct 12, 2015 at 12:08 AM, Pavel Roskin [email protected] wrote:

I expect tig to work just like it works in repositories with revisions. It can show staged changes. It can show unstaged changes to the added files.

It may look like a pathological case from the coding standpoint, but it's not a pathological case for a developer. I create a repository, write code and then I want to use my usual tool to double check what I'm committing. And the tool is suddenly unhappy.

— Reply to this email directly or view it on GitHub https://github.com/jonas/tig/issues/445#issuecomment-147288544.

Jonas Fonseca

jonas avatar Oct 12 '15 14:10 jonas

Printing No commit log, did you mean to run 'tig status'? when it is a git repository without commits is what makes most sense.

Putting you to status view automagically could be misleading (eg, a beginner asking : why don't I have this status view any more when running plain tig after doing a commit ?)

netei avatar Oct 12 '15 14:10 netei

I agree. tig would actually educate its users, which is good.

proski avatar Oct 12 '15 17:10 proski

Why not simply start as usual and simply show a "no commits yet" message in place of the usual commit log. I see no reason why it should refuse to launch.

ulope avatar Nov 10 '15 10:11 ulope

Huh I actually had no idea you could use tig status to work around this issue - that's the view I wanted to get to anyway. +1 for redirecting to it, +1 also for showing a placeholder "no commits yet" in the log, -1 to just hard failing and returning 1.

Asday avatar Aug 23 '22 23:08 Asday