From b932aab97767f8bec43908497646054c81bf9c86 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 23 Sep 2013 09:52:48 -0400
Subject: [PATCH] Fix commit log css for branch graphs
---
src/main/java/com/gitblit/utils/JGitUtils.java | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/gitblit/utils/JGitUtils.java b/src/main/java/com/gitblit/utils/JGitUtils.java
index 66dbd60..3c1173c 100644
--- a/src/main/java/com/gitblit/utils/JGitUtils.java
+++ b/src/main/java/com/gitblit/utils/JGitUtils.java
@@ -403,8 +403,22 @@
if (! path.exists()) return -1;
int perm = configShared.getPerm();
- int mode = JnaUtils.getFilemode(path);
+ JnaUtils.Filestat stat = JnaUtils.getFilestat(path);
+ if (stat == null) return -1;
+ int mode = stat.mode;
if (mode < 0) return -1;
+
+ // Now, here is the kicker: Under Linux, chmod'ing a sgid file whose guid is different from the process'
+ // effective guid will reset the sgid flag of the file. Since there is no way to get the sgid flag back in
+ // that case, we decide to rather not touch is and getting the right permissions will have to be achieved
+ // in a different way, e.g. by using an appropriate umask for the Gitblit process.
+ if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {
+ if ( ((mode & (JnaUtils.S_ISGID | JnaUtils.S_ISUID)) != 0)
+ && stat.gid != JnaUtils.getegid() ) {
+ LOGGER.debug("Not adjusting permissions to prevent clearing suid/sgid bits for '" + path + "'" );
+ return 0;
+ }
+ }
// If the owner has no write access, delete it from group and other, too.
if ((mode & JnaUtils.S_IWUSR) == 0) perm &= ~0222;
@@ -728,6 +742,8 @@
try {
if (tree == null) {
ObjectId object = getDefaultBranch(repository);
+ if (object == null)
+ return null;
RevCommit commit = rw.parseCommit(object);
tree = commit.getTree();
}
@@ -1326,14 +1342,17 @@
*/
public static List<RevCommit> searchRevlogs(Repository repository, String objectId,
String value, final com.gitblit.Constants.SearchType type, int offset, int maxCount) {
- final String lcValue = value.toLowerCase();
List<RevCommit> list = new ArrayList<RevCommit>();
+ if (StringUtils.isEmpty(value)) {
+ return list;
+ }
if (maxCount == 0) {
return list;
}
if (!hasCommits(repository)) {
return list;
}
+ final String lcValue = value.toLowerCase();
try {
// resolve branch
ObjectId branchObject;
--
Gitblit v1.9.1