Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dolt status output incorrectly displayed for staged files #1108

Merged
merged 1 commit into from Dec 14, 2020

Conversation

VyasSathya
Copy link
Contributor

The function printStagedDiffs always returned 0, even when there were diffs not staged. This return was also causing it to print in printStatus "nothing to commit, working tree clean". This was not the case.

I changed printStagedDiffs to return the number of the staged tables plus the number of staged docs instead. This prevents it from entering the if statement with the print also.

I've attached a picture of the bug with debug statements:

Bug

and here is it after the fix:

Fixed

@CLAassistant
Copy link

CLAassistant commented Dec 11, 2020

CLA assistant check
All committers have signed the CLA.

@timsehn
Copy link
Sponsor Contributor

timsehn commented Dec 11, 2020

I'm confused as to what exactly the user sees that is broken? Oh I see, it returns the wrong exit code. @bheni ?

@timsehn
Copy link
Sponsor Contributor

timsehn commented Dec 11, 2020

I don't think we should return the number of files changed. This is the exit code of the program. 0 means OK and any other exit code means ERROR. What does Git return?

@VyasSathya
Copy link
Contributor Author

Hi Tim, the zero doesn't represent the error code in this case. The return number is being used to decide whether or not to print the 'nothing to commit' message. I believe it should be similar to the notStaged function.

@VyasSathya
Copy link
Contributor Author

In the file:
dolthub\dolt\go\cmd\dolt\commands\status.go

	n := printStagedDiffs(cli.CliOut, stagedTbls, stagedDocs, true)
	n = printDiffsNotStaged(ctx, dEnv, cli.CliOut, notStagedTbls, notStagedDocs, true, n, workingTblsInConflict)

	if dEnv.RepoState.Merge == nil && n == 0 {
		cli.Println("nothing to commit, working tree clean")
	}

if printStagedDiffs returns zero all the time, even if there are staged files it will output "nothing to commit, working tree clean" whereas in git it won't output that.

@timsehn
@bheni

Copy link
Contributor

@bheni bheni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bheni bheni merged commit 99a87cc into dolthub:master Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants