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

infinite loop on seeing a folder on Windows #1933

Closed
andreynering opened this issue Jun 10, 2017 · 17 comments
Closed

infinite loop on seeing a folder on Windows #1933

andreynering opened this issue Jun 10, 2017 · 17 comments
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP type/bug
Milestone

Comments

@andreynering
Copy link
Contributor

/cc @ethantkoenig Sorry for bothering you again. I tried to fix it, but couldn't.

To reproduce:

  • Have latest Gitea master on Windows
  • Import Gitea source code to the instance
  • Navigate to the routers/ folder in the web UI. Browser waits forever, theres a loop on the server

To debug I added the following line after this line:

fmt.Println(path)

Here's the output log

@andreynering andreynering added type/bug issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP labels Jun 10, 2017
@andreynering andreynering added this to the 1.2.0 milestone Jun 10, 2017
@ethantkoenig
Copy link
Member

Hmm, definitely troubling that SHA1 hashes are being printed. Could you add the print statements I had you add last time (#1836 (comment))?

@andreynering
Copy link
Contributor Author

@ethantkoenig Here you go.

@ethantkoenig
Copy link
Member

ethantkoenig commented Jun 12, 2017

@andreynering Thanks, could you run the following command (from the root of the gitea repo you were testing on), and show me the output?

$ git log --pretty=format:%H --name-only -3 cd1821a7e292b05e04fcc2a969b42d06ab512849^ -- routers\dev routers\org routers\init.go routers\install.go routers\home.go

EDIT: was previously missing the caret ^, but that shouldn't have made a difference (for our purposes)

@andreynering
Copy link
Contributor Author

@ethantkoenig Sorry for the delay.

It's empty. There's no output for this command.

@ethantkoenig
Copy link
Member

@andreynering Weird. You ran the command on Windows, right?

The command that corresponds to the log line

logCommand: startHash=cd1821a7e292b05e04fcc2a969b42d06ab512849, state=&{entries:map[routers\dev:0x127fc640 routers\org:0x127fc900 routers\repo:0x127fc980 routers\user:0x127fca00 routers\init.go:0x127fc740 routers\install.go:0x127fc880 routers\admin:0x127fc540 routers\api:0x127fc5c0 routers\home.go:0x127fc6c0] commits:map[routers\api:0x12e9c000 routers\admin:0x12df89a0 routers\repo:0x12e29500 routers\user:0x12e4c1c0] lastCommitHash:cd1821a7e292b05e04fcc2a969b42d06ab512849 lastCommit:<nil> treePath:routers headCommit:0x12e9c000 nextSearchSize:128}

and the fact that the next log line is different indicates that when this ran in gitea, the output was not empty (becuase the lastCommitHash gets updated)

@ethantkoenig
Copy link
Member

ethantkoenig commented Jun 15, 2017

The UNIX equivalent (forward slashes instead of back slashes)

$ git log --pretty=format:%H --name-only -3 cd1821a7e292b05e04fcc2a969b42d06ab512849^ -- routers/dev routers/org routers/init.go routers/install.go routers/home.go

does not returns a non-empty output on Linux, so it must be something wrong with the formatting of the command for Windows? @andreynering Can you figure what's wrong with the formatting of the command I had you run? Do the backslashes need to be esacped (i.e. \\)?

@andreynering
Copy link
Contributor Author

@ethantkoenig I just tried with forward slash, and got the same output both on Linux and Windows:

8de8e11487ebd729d026c8a71adfa9ea6b926a69
routers/install.go

01d957677f160e4b5e43ce043b05e246493b34ea
routers/init.go

9d2b830275bf766b9f5e48e3be4b785dc1b2134a
routers/home.go

Git requires forward slashes on any OS.

@ethantkoenig
Copy link
Member

@andreynering Just to confirm, so that we can fix this once and for all:

  • On Windows, when someone calls func (tes Entries) GetCommitsInfo(commit *Commit, treePath string), both the TreeEntry elements of tes (in the TreeEntry.name attribute) and the treePath argument will use backslashes (\) as the file separator?
  • On Windows, the git log expects any argument filenames to use forward slashes (/) as a file separator, and the listed files will also use forward slashes (/) as the file separator?

@lafriks
Copy link
Member

lafriks commented Jun 16, 2017

On windows both ways seems to be working for me but in response there is always forward slashes:
git log --pretty=format:%H --name-only -3 cd1821a7e292b05e04fcc2a969b42d06ab512849^ -- routers/dev routers/org routers/init.go routers/install.go routers/home.go

8de8e11487ebd729d026c8a71adfa9ea6b926a69
routers/install.go

01d957677f160e4b5e43ce043b05e246493b34ea
routers/init.go

9d2b830275bf766b9f5e48e3be4b785dc1b2134a
routers/home.go

git log --pretty=format:%H --name-only -3 cd1821a7e292b05e04fcc2a969b42d06ab512849^ -- routers\dev routers\org routers\init.go routers\install.go routers\home.go

8de8e11487ebd729d026c8a71adfa9ea6b926a69
routers/install.go

01d957677f160e4b5e43ce043b05e246493b34ea
routers/init.go

9d2b830275bf766b9f5e48e3be4b785dc1b2134a
routers/home.go

git --version

git version 2.11.0.windows.3

@andreynering
Copy link
Contributor Author

@ethantkoenig

On Windows, when someone calls func (tes Entries) GetCommitsInfo(commit *Commit, treePath string), both the TreeEntry elements of tes (in the TreeEntry.name attribute) and the treePath argument will use backslashes (\) as the file separator?

I debugged again with print statements, and there ist'n any separators, just the folder or file name. Maybe this is the problem?

Browsing Gitea root (/) (no infinite loop):

entryName: .github
entryName: cmd
entryName: conf
entryName: docker
entryName: integrations
entryName: models
entryName: modules
entryName: options
entryName: public
entryName: routers
entryName: scripts
entryName: templates
entryName: vendor
entryName: .dockerignore
entryName: .drone.yml
entryName: .drone.yml.sig
entryName: .editorconfig
entryName: .gitattributes
entryName: .gitignore
entryName: .lgtm
entryName: CHANGELOG.md
entryName: CONTRIBUTING.md
entryName: DCO
entryName: Dockerfile
entryName: Dockerfile.rpi
entryName: LICENSE
entryName: MAINTAINERS
entryName: Makefile
entryName: README.md
entryName: README_ZH.md
entryName: main.go
TreePath:

Browsing Gitea's /routers, folder (infine loop right after the statements get printed):

entryName: admin
entryName: api
entryName: dev
entryName: org
entryName: repo
entryName: user
entryName: home.go
entryName: init.go
entryName: install.go
TreePath: routers

On Windows, the git log expects any argument filenames to use forward slashes (/) as a file separator, and the listed files will also use forward slashes (/) as the file separator?

As I have noticed, yes and yes. Maybe some versions also accept \, as @lafriks noted. In my computer it doesn't. I suggests using /, as it sems to work anywhere.

$ git version
git version 2.10.2.windows.1

@ethantkoenig
Copy link
Member

ethantkoenig commented Jun 17, 2017

@andreynering Sorry to keep bothering you, but could you show me the treePath for a nested directory (e.g. routers/admin)? I need to know if it's routers/admin or routers\admin.

I think you are right that there won't ever be any file separators in the tree entries though.

@andreynering
Copy link
Contributor Author

I'm away from my computer, but will check as soon as possible.

@andreynering
Copy link
Contributor Author

@ethantkoenig For visiting router/api/v1:

entryName: admin
entryName: convert
entryName: misc
entryName: org
entryName: repo
entryName: user
entryName: utils
entryName: api.go
TreePath: routers/api/v1

@ethantkoenig
Copy link
Member

@andreynering Could you checkout https://github.com/ethantkoenig/gitea/tree/debug/get_commit_infos and let me know if it fixes your problem?

@andreynering
Copy link
Contributor Author

@ethantkoenig Sorry, not fixed. Still infinite loop.

@ethantkoenig
Copy link
Member

ethantkoenig commented Jun 19, 2017

@andreynering Added another change to the branch, could you pull and try again?

@andreynering
Copy link
Contributor Author

@ethantkoenig 🎉 🚀 💯 Congrats. It's fixed now.

Here's the log if you are curious. I visited Gitea's root, then /routers/, and then /routers/api/v1/.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/critical This issue should be fixed ASAP. If it is a PR, the PR should be merged ASAP type/bug
Projects
None yet
Development

No branches or pull requests

3 participants