Skip to content

Commit 081966e

Browse files
committed
gogs/gogs#2373 500 when filename starts with ':'
1 parent 2617983 commit 081966e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

git.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
const _VERSION = "0.2.2"
13+
const _VERSION = "0.2.3"
1414

1515
func Version() string {
1616
return _VERSION
@@ -20,7 +20,7 @@ var (
2020
// Debug enables verbose logging on everything.
2121
// This should be false in case Gogs starts in SSH mode.
2222
Debug = false
23-
Prefix = "[git-shell] "
23+
Prefix = "[git-module] "
2424
)
2525

2626
func log(format string, args ...interface{}) {

repo_commit.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ func (repo *Repository) GetTagCommit(name string) (*Commit, error) {
137137
}
138138

139139
func (repo *Repository) getCommitByPathWithID(id sha1, relpath string) (*Commit, error) {
140+
// File name starts with ':' must be escaped.
141+
if relpath[0] == ':' {
142+
relpath = `\` + relpath
143+
}
144+
140145
stdout, err := NewCommand("log", "-1", _PRETTY_LOG_FORMAT, id.String(), "--", relpath).RunInDir(repo.Path)
141146
if err != nil {
142147
return nil, err

0 commit comments

Comments
 (0)