Merge "hackdoc: when redirecting, skip ref if default"
diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go
index e460721..10fb65c 100644
--- a/devtools/hackdoc/main.go
+++ b/devtools/hackdoc/main.go
@@ -205,7 +205,15 @@
 		}
 
 		if file {
-			http.Redirect(r.w, r.r, "/"+fpath+"?ref="+r.ref, 302)
+			ref := r.ref
+			if ref == flagGitwebDefaultBranch {
+				ref = ""
+			}
+			path := "/" + fpath
+			if ref != "" {
+				path += "?ref=" + ref
+			}
+			http.Redirect(r.w, r.r, path, 302)
 			return
 		}
 	}
diff --git a/devtools/hackdoc/markdown.go b/devtools/hackdoc/markdown.go
index 5004642..8923545 100644
--- a/devtools/hackdoc/markdown.go
+++ b/devtools/hackdoc/markdown.go
@@ -21,7 +21,7 @@
 
 	// master is the default branch - do not make special links for that, as
 	// that makes them kinda ugly.
-	if ref == "master" {
+	if ref == flagGitwebDefaultBranch {
 		ref = ""
 	}