qgit reports errors in the git repository

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

qgit reports errors in the git repository

From: Pavel Roskin <hidden>
Date: 2016-06-15 22:42:14

Hello!

qgit reports an error from git-cat-file when run in the git repository.
The error shown in a message box with the text:

Git says:
fatal: git-cat-file 23ea3e201cea0deea909569e08e950a9ec2345f7: bad file

I believe qgit runs "git-cat-file -t tag" on in, but it's a commit.  If
I change the git-cat-file invocation in  src/git_startup.cpp to use
"commit" instead of "tag", qgit complains about
0918385dbd9656cab0d1d81ba7453d49bbc16250.

Maybe qgit should check the type of the object first?  Or maybe there
should another type for git-cat-file that would match both tag and
commit?

-- 
Regards,
Pavel Roskin

Re: qgit reports errors in the git repository

From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-06-15 22:42:14


On Mon, 12 Dec 2005, Pavel Roskin wrote:
Git says:
fatal: git-cat-file 23ea3e201cea0deea909569e08e950a9ec2345f7: bad file

I believe qgit runs "git-cat-file -t tag" on in, but it's a commit.  If
I change the git-cat-file invocation in  src/git_startup.cpp to use
"commit" instead of "tag", qgit complains about
0918385dbd9656cab0d1d81ba7453d49bbc16250.

Maybe qgit should check the type of the object first?  Or maybe there
should another type for git-cat-file that would match both tag and
commit?
Using "git-cat-file commit <object>" already works for both real commits 
and for tags that point to commits.

However, the "0918385dbd9656cab0d1d81ba7453d49bbc16250" object is a tag 
that points to a blob (Junios public gpg key), so you can't use that.

Basically, qgit should do either:

 - check the type of the object by hand first (using "git-cat-file -t" and 
   then follow any tags it finds by hand)

_or_ 

 - just use "git-cat-file commit" and if an error occurs, just silently 
   ignore that ref since it doesn't understand them.

which one is the right strategy depends on usage.

		Linus

Re: qgit reports errors in the git repository

From: Pavel Roskin <hidden>
Date: 2016-06-15 22:42:14

On Mon, 2005-12-12 at 17:06 -0800, Linus Torvalds wrote:
Basically, qgit should do either:

 - check the type of the object by hand first (using "git-cat-file -t" and 
   then follow any tags it finds by hand)
I'm a complete Qt newbie, but this patch seems to work for me.

Signed-off-by: Pavel Roskin <redacted>
diff --git a/src/git_startup.cpp b/src/git_startup.cpp
index e08d466..1f6e9ad 100644
--- a/src/git_startup.cpp
+++ b/src/git_startup.cpp
@@ -111,6 +111,10 @@ bool Git::getRefs() {
 
 		if (itNext != rLst.constEnd() && (*itNext).right(3) == "^{}") {
 			signedTag = true;
+			if (!run("git-cat-file -t " + refSha, &runOutput))
+				continue; // invalid SHA1
+			if (runOutput != "tag\n")
+				continue; // not a tag
 			if (run("git-cat-file tag " + refSha, &runOutput)) {
 				QString msg(runOutput.section("\n\n", 1));
 				if (!msg.isEmpty())

-- 
Regards,
Pavel Roskin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help