Problems with git & other

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
MrPotatoFace
Posts: 4
Joined: July 23rd, 2020, 7:43 pm

Problems with git & other

Post by MrPotatoFace » August 15th, 2020, 2:25 pm

I just finished watching the tutorial 15 video regarding git and github. Yesterday I cloned the framework, created a local branch, and made a function for drawing a line. That worked just as designed, so I commited it, and went to bed. Today this solution won't even build, and I haven't changed a thing. It keeps spitting out warnings about member variables that have to be initialized. Edit: code now works, but Git-problem persists!

I thought I would try to upload this code to github, and then post about the problem here, but that won't work for me either. I have tried several times to follow the video exactly, but after I've created a github page and try to push to it, I'm greeted with the message: "Exception of type 'Microsoft.TeamFoundation.Git.Contracts.GitRemoteRefNotFoundException' was thrown."

So, since I can't seem to get github working properly, here is the fuction I added in graphics(the zipped solution was appearently to large to upload, don't know if I'm doing anything wrong there):

Code: Select all

void Graphics::DrawLine(int x0, int y0, int x1, int y1, Color c)
{
	float xDiff = x1 - x0; //The line is based in 0's coordinates, so if corresponding 1's coordinates are bigger,
	float yDiff = y1 - y0; //we want the Diff to be positive, and if they are smaller, we want the Diff to be negative.
	float xIncrement;	   //This in return means that the corresponding increment will be correspondingly positive or negative,
	float yIncrement;	   //and the line is drawn from 0's coordinates in the right direction. If we switch 0's and 1's coordinates in the evaluation above, the "polarity" of the incrementors are flipped, and the line is drawn mirrored to where it is actually supposed to be.

	if (abs(xDiff) > abs(yDiff)) //Checks what Diff is greater, and sets that one to either 1 or -1. The other Diff will then always be between 1 and -1(never more then abs() = 1. This makes sure the line is whole, and not dotted.
	{
		xIncrement = xDiff / abs(xDiff); //Sets xIncrement equal to either 1 or -1, depending on whether it is positive or negative.
		yIncrement = yDiff / abs(xDiff); //By setting yIncrement this way, we can increment both xIncrement and yIncrement at the same rate until they reach the end of the line.
	}
	else
	{
		yIncrement = yDiff / abs(yDiff); //Sets yIncrement equal to either 1 or -1, depending on whether it is positive or negative.
		xIncrement = xDiff / abs(yDiff); //By setting xIncrement this way, we can increment both xIncrement and yIncrement at the same rate until they reach the end of the line.
	}

	for (float i = 0; i <= std::max(abs(xDiff), abs(yDiff)); ++i) //This loop draws 1 pixel every itteration, moving it slightly closer to 0's coordinates every time.
	{
		if (x0 + i * xIncrement >= 0 && x0 + i * xIncrement <= ScreenWidth - 1 && y0 + i * yIncrement >= 0 && y0 + i * yIncrement <= ScreenHeight - 1) //Safety check for pixels off the screen
		{
			PutPixel(x0 + i * xIncrement, y0 + i * yIncrement, c);
		}
	}
}

"clean" version with no comments:

void Graphics::DrawLine(int x0, int y0, int x1, int y1, Color c)
{
	float xDiff = x1 - x0; 
	float yDiff = y1 - y0;
	float xIncrement;  
	float yIncrement;

	if (abs(xDiff) > abs(yDiff))
	{
		xIncrement = xDiff / abs(xDiff); 
		yIncrement = yDiff / abs(xDiff);
	}
	else
	{
		yIncrement = yDiff / abs(yDiff); 
		xIncrement = xDiff / abs(yDiff); 
	}

	for (float i = 0; i <= std::max(abs(xDiff), abs(yDiff)); ++i)
	{
		if (x0 + i * xIncrement >= 0 && x0 + i * xIncrement <= ScreenWidth - 1 && y0 + i * yIncrement >= 0 && y0 + i * yIncrement <= ScreenHeight - 1)
		{
			PutPixel(x0 + i * xIncrement, y0 + i * yIncrement, c);
		}
	}
}
All help is greatly appreciated!

PS: Sorry for the obnoxious(?) amounts of comments, but I tried to explain this to myself in as much detail as possible, in case I need to modify it in the future.
Also, I use floats because I learned about them before embarking on c++ with chili, so I haven't seen any videos past 15
Last edited by MrPotatoFace on August 15th, 2020, 8:47 pm, edited 1 time in total.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Problems with git & other

Post by albinopapa » August 15th, 2020, 3:24 pm

It keeps spitting out warnings about member variables that have to be initialized.
If they are just warnings, then it shouldn't prevent you from building unless you changed the project properties to "Treat Warnings as Errors". There should actually be something in the Output window saying "error: ...". The increment variables can be set to 0 and that should get rid of the warnings though.

As for the exceptions with Visual Studio's git interface, I'm not sure if that's a VS problem, wrong remote server address ( the address of your github repo ) or if it just can't find the path to the github repository as in the repo is not created on github servers.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

colorlessquark
Posts: 6
Joined: August 13th, 2020, 11:55 pm

Re: Problems with git & other

Post by colorlessquark » August 15th, 2020, 6:26 pm

I messed around with Git, but in my run though the tutorial, I started without a clone (I downloaded the files and built the repository "from scratch-ish" that way). I found that I can't use a remote to my repository to upload the "master" branch, but a locally created branch is fine. This leaves my repository with an empty "master" branch, and my solution explorer with useless branches. I'm not sure if this is intended behavior for Git (since the master branch is basically the "current release" branch, and there should only be one) or if I'm missing something. I get the following details:

Code: Select all

Error: hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Error encountered while pushing to the remote repository: rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again.
If it should be possible to "push master" to my own repository (and effectively sever myself from the repo I cloned from, I don't know how. In this case, my actions were to clone, define a remote to my new repo, and simply attempt to push master. After that fails, just branching from master then pushing the branch with my remote works as expected.

For OP, were you pushing a branch you made or tried to push master? If you merged your changes into master before pushing, I don't think that will fix anything if the problems are similar.

MrPotatoFace
Posts: 4
Joined: July 23rd, 2020, 7:43 pm

Re: Problems with git & other

Post by MrPotatoFace » August 15th, 2020, 8:39 pm

Ok, for some reason the code now works. I restartet visual studio since last I tried, don't know if that has anything to do with it. As for the git problems, I tried creating a new remote repo, but still the same problem.

MrPotatoFace
Posts: 4
Joined: July 23rd, 2020, 7:43 pm

Re: Problems with git & other

Post by MrPotatoFace » August 15th, 2020, 8:42 pm

colorlessquark wrote:
August 15th, 2020, 6:26 pm
For OP, were you pushing a branch you made or tried to push master? If you merged your changes into master before pushing, I don't think that will fix anything if the problems are similar.
I definately tried to push a local branch onto my own github repo.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Problems with git & other

Post by albinopapa » August 16th, 2020, 5:10 am

When you created the remote repository on GitHub, did you create it with a README file first? This will cause VS and Git to see them as two fully functional and unique repositories.
In other words, it has to be completely blank, not even the .gitignore file can be created.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

MrPotatoFace
Posts: 4
Joined: July 23rd, 2020, 7:43 pm

Re: Problems with git & other

Post by MrPotatoFace » August 16th, 2020, 9:01 am

albinopapa wrote:
August 16th, 2020, 5:10 am
When you created the remote repository on GitHub, did you create it with a README file first? This will cause VS and Git to see them as two fully functional and unique repositories.
In other words, it has to be completely blank, not even the .gitignore file can be created.
No, I left everything at default, blank.

Post Reply