infinite loop on seeing a folder on Windows #795

Closed
opened 2025-11-02 03:37:01 -06:00 by GiteaMirror · 17 comments
Owner

Originally created by @andreynering on GitHub (Jun 10, 2017).

/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

Originally created by @andreynering on GitHub (Jun 10, 2017). /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](https://github.com/go-gitea/gitea/blob/f2fcd9dcd834b611d2f321829e814a741054c4ea/vendor/code.gitea.io/git/tree_entry.go#L213): ```go fmt.Println(path) ``` [Here's the output log](https://gist.githubusercontent.com/andreynering/0fa81d274194ece4de813d8b13b54230/raw/cd47d4135446073b99dd80851b7959ecdb561577/loop.log)
GiteaMirror added the issue/criticaltype/bug labels 2025-11-02 03:37:01 -06:00
Author
Owner

@ethantkoenig commented on GitHub (Jun 10, 2017):

Hmm, definitely troubling that SHA1 hashes are being printed. Could you add the print statements I had you add last time (https://github.com/go-gitea/gitea/issues/1836#issuecomment-306053014)?

@ethantkoenig commented on GitHub (Jun 10, 2017): Hmm, definitely troubling that SHA1 hashes are being printed. Could you add the print statements I had you add last time (https://github.com/go-gitea/gitea/issues/1836#issuecomment-306053014)?
Author
Owner

@andreynering commented on GitHub (Jun 11, 2017):

@ethantkoenig Here you go.

@andreynering commented on GitHub (Jun 11, 2017): @ethantkoenig [Here you go](https://gist.githubusercontent.com/andreynering/2d973e86ce685394f5e88b01b1af13de/raw/57d5d08cd65fac5fdd35d7f7bc667ad4c1c54ff0/loop2.log).
Author
Owner

@ethantkoenig commented on GitHub (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)

@ethantkoenig commented on GitHub (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)
Author
Owner

@andreynering commented on GitHub (Jun 14, 2017):

@ethantkoenig Sorry for the delay.

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

@andreynering commented on GitHub (Jun 14, 2017): @ethantkoenig Sorry for the delay. It's empty. There's no output for this command.
Author
Owner

@ethantkoenig commented on GitHub (Jun 14, 2017):

@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 commented on GitHub (Jun 14, 2017): @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)
Author
Owner

@ethantkoenig commented on GitHub (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. \\)?

@ethantkoenig commented on GitHub (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. `\\`)?
Author
Owner

@andreynering commented on GitHub (Jun 15, 2017):

@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.

@andreynering commented on GitHub (Jun 15, 2017): @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.
Author
Owner

@ethantkoenig commented on GitHub (Jun 16, 2017):

@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?
@ethantkoenig commented on GitHub (Jun 16, 2017): @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?
Author
Owner

@lafriks commented on GitHub (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
@lafriks commented on GitHub (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 ```
Author
Owner

@andreynering commented on GitHub (Jun 16, 2017):

@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
@andreynering commented on GitHub (Jun 16, 2017): @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): ```bash 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): ```bash 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. ```bash $ git version git version 2.10.2.windows.1 ```
Author
Owner

@ethantkoenig commented on GitHub (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.

@ethantkoenig commented on GitHub (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.
Author
Owner

@andreynering commented on GitHub (Jun 17, 2017):

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

@andreynering commented on GitHub (Jun 17, 2017): I'm away from my computer, but will check as soon as possible.
Author
Owner

@andreynering commented on GitHub (Jun 19, 2017):

@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
@andreynering commented on GitHub (Jun 19, 2017): @ethantkoenig For visiting `router/api/v1`: ```bash entryName: admin entryName: convert entryName: misc entryName: org entryName: repo entryName: user entryName: utils entryName: api.go TreePath: routers/api/v1 ```
Author
Owner

@ethantkoenig commented on GitHub (Jun 19, 2017):

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

@ethantkoenig commented on GitHub (Jun 19, 2017): @andreynering Could you checkout https://github.com/ethantkoenig/gitea/tree/debug/get_commit_infos and let me know if it fixes your problem?
Author
Owner

@andreynering commented on GitHub (Jun 19, 2017):

@ethantkoenig Sorry, not fixed. Still infinite loop.

@andreynering commented on GitHub (Jun 19, 2017): @ethantkoenig Sorry, not fixed. Still infinite loop.
Author
Owner

@ethantkoenig commented on GitHub (Jun 19, 2017):

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

@ethantkoenig commented on GitHub (Jun 19, 2017): @andreynering Added another change to the branch, could you pull and try again?
Author
Owner

@andreynering commented on GitHub (Jun 19, 2017):

@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/.

@andreynering commented on GitHub (Jun 19, 2017): @ethantkoenig 🎉 🚀 💯 Congrats. It's fixed now. [Here's the log if you are curious](https://gist.githubusercontent.com/andreynering/84204d9fa15913ffcaca26d5cc34f708/raw/cc7052146a9badb95b04c176730ab5fbf2c020e3/horray.log). I visited Gitea's root, then `/routers/`, and then `/routers/api/v1/`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#795