Gitea: infinite loop on seeing a folder on Windows

Created on 10 Jun 2017  路  17Comments  路  Source: go-gitea/gitea

/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

kinbug prioritcritical

Most helpful comment

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

All 17 comments

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 Here you go.

@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 Sorry for the delay.

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

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

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 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 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?

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

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

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

@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 Could you checkout https://github.com/ethantkoenig/gitea/tree/debug/get_commit_infos and let me know if it fixes your problem?

@ethantkoenig Sorry, not fixed. Still infinite loop.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tuxfanou picture tuxfanou  路  3Comments

adpande picture adpande  路  3Comments

jonasfranz picture jonasfranz  路  3Comments

jorise7 picture jorise7  路  3Comments

lunny picture lunny  路  3Comments