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

wrong error message when popping an empty stash #2227

Closed
kevgo opened this issue Apr 24, 2023 · 8 comments · Fixed by #2758
Closed

wrong error message when popping an empty stash #2227

kevgo opened this issue Apr 24, 2023 · 8 comments · Fixed by #2758
Labels
Milestone

Comments

@kevgo
Copy link
Contributor

kevgo commented Apr 24, 2023

steps to reproduce:

  • run a Git Town command that stops with an error and asks you to fix it and then run git town continue
  • fix the error and clear the Git stash
  • run git town continue

expected result

Git Town ignores the issue that it cannot pop the Git stash because there is no Git stash.

actual result

Git Town thinks its inability to pop the stash is a failure condition and prints this error:

(other Git Town output here...)

[main] git stash pop
No stash entries found.

Error: conflicts between your uncommmitted changes and the main branch

To abort, run "git-town abort".
To continue after having resolved conflicts, run "git-town continue".
To continue by skipping the current branch, run "git-town skip".
@kevgo kevgo added the bug label Jul 2, 2023
@kevgo kevgo removed the bug label Oct 27, 2023
@IGassmann
Copy link

IGassmann commented Nov 6, 2023

Ever since I upgraded to version 10, I encounter this issue every time I execute git sync on an up-to-date and clean branch, and with an empty stash:

❯ git sync

[main] git fetch --prune --tags

[main] git add -A

[main] git stash
No local changes to save

[main] git rebase origin/main
Current branch main is up to date.

[main] git push --tags
Everything up-to-date

[main] git stash pop
No stash entries found.


Error: conflicts between your uncommmitted changes and the main branch

To abort, run "git-town abort".
To continue after having resolved conflicts, run "git-town continue".
To continue by skipping the current branch, run "git-town skip".

I attempted to run git town status reset in an effort to resolve the issue, but it did not resolve it.

@IGassmann
Copy link

The issue is also occurring with the the git hack command:

❯ git hack new-branch

[main] git fetch --prune --tags

[main] git add -A

[main] git stash
No local changes to save

[main] git rebase origin/main
Current branch main is up to date.

[main] git branch new-branch main

[main] git checkout new-branch
Switched to branch 'new-branch'

[new-branch] git stash pop
No stash entries found.


Error: conflicts between your uncommmitted changes and the main branch

To abort, run "git-town abort".
To continue after having resolved conflicts, run "git-town continue".

@kevgo kevgo added this to the v11 milestone Nov 6, 2023
@kevgo
Copy link
Contributor Author

kevgo commented Nov 6, 2023

Thanks for the bug report, interesting edge case! It seems the problem you experience happens because Git Town wrongfully assumes your branch contains uncommitted changes. It therefore runs git stash (which in your case stashes nothing) and then git stash pop (which in your case fails because there is nothing to unstash, resulting in the misleading error message).

Let's find out why this happens. @IGassmann can you please post the output of this command:

git sync --verbose

Please make sure to scrub any confidential information like your GitHub tokens from the output. It would show up in the beginning when Git Town runs git config -lz. Thanks!

@kevgo kevgo added the bug label Nov 6, 2023
@IGassmann
Copy link

IGassmann commented Nov 6, 2023

@kevgo the issue is actually happening with all commands whenever the stash is empty.

Here is the verbose output:

❯ git sync --verbose

(verbose) git version
git version 2.42.1

(verbose) git config -lz --global
[redacted]

(verbose) git config -lz --local
[redacted]

(verbose) git stash list

(verbose) git branch -vva
* main                                                                     bb97914f [origin/main] Commit message

(verbose) git remote
origin

[main] git fetch --prune --tags

(verbose) git branch -vva
  * main                                                                     bb97914f [origin/main] Commit message

(verbose) git rev-parse --verify --abbrev-ref @{-1}
igor/previous-branch

(verbose) git status --ignore-submodules
## main...origin/main

[main] git add -A

[main] git stash
No local changes to save

[main] git rebase origin/main
Current branch main is up to date.

(verbose) git rev-list --left-right main...origin/main

(verbose) git show-ref --quiet refs/heads/main

[main] git push --tags
Everything up-to-date

(verbose) git show-ref --quiet refs/heads/igor/previous-branch

(verbose) git rev-parse --verify --abbrev-ref @{-1}
igor/previous-branch

[main] git stash pop
No stash entries found.

(verbose) git config -lz --global
[redacted]
(verbose) git config -lz --local
[redacted]
(verbose) git branch -vva
  * main                                                                     bb97914f [origin/main] Commit message

(verbose) git stash list

(verbose) git status --ignore-submodules
## main...origin/main

Ran 25 shell commands.
Error: conflicts between your uncommmitted changes and the main branch

To abort, run "git-town abort".
To continue after having resolved conflicts, run "git-town continue".
To continue by skipping the current branch, run "git-town skip".

@IGassmann
Copy link

I've recorded a video that shows the issue is happening across all commands. It seems that the problem is that commands always try to unstash changes even when they shouldn't.

iTerm2.2023-11-07.at.09.56.24-converted.mp4

My git version: 2.42.1

@kevgo
Copy link
Contributor Author

kevgo commented Nov 7, 2023

Thanks for the details! The video has also been helpful. I notice that the output of git status --ignore-submodules on your machine differs from my machine. When I run this command, I get this:

~/d/git-town [main] > git status --ignore-submodules                                                                                                  (base) 
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/git/backend_commands.go
	modified:   src/git/backend_commands_test.go

no changes added to commit (use "git add" and/or "git commit -a")

When you run the exact same command, it seems you get just something like this:

## main...origin/main

I suspect you enabled the status.short and status.branch config settings of Git. Can you please confirm?

Edit: you can determine this by running git config --get-regexp status and git config --get-regexp branch. Thanks!

@kevgo
Copy link
Contributor Author

kevgo commented Nov 7, 2023

I have released v10.0.2 with a fix for the problem of getting a wrong error message when short output is enabled for Git. Please take it for a ride and let me know if the problem still exists. Thanks!

@IGassmann
Copy link

I suspect you enabled the status.short and status.branch config settings of Git. Can you please confirm?

That's right. I have both enabled.

I have released v10.0.2 with a fix for the problem of getting a wrong error message when short output is enabled for Git. Please take it for a ride and let me know if the problem still exists. Thanks!

That fixed it! Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants