Skip to content

Commit 7555b1f

Browse files
committed
PBWebGit: Fix display of commit message when there is no diff
This happens for example in conflictless merge commits.
1 parent b8b92e6 commit 7555b1f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

html/commit.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ var Commit = Class.create({
33
initialize: function(obj) {
44
this.raw = obj.details;
55

6-
var messageStart = this.raw.indexOf("\n\n") + 2;
76
var diffStart = this.raw.indexOf("\ndiff ");
7+
var messageStart = this.raw.indexOf("\n\n") + 2;
8+
9+
if (diffStart > 0) {
10+
this.message = this.raw.substring(messageStart, diffStart);
11+
this.diff = this.raw.substring(diffStart)
12+
} else {
13+
this.message = this.raw.substring(messageStart)
14+
this.diff = ""
15+
}
816
this.header = this.raw.substring(0, messageStart);
917

1018
this.sha = this.header.match(/^commit ([0-9a-f]{40,40})/)[1];
@@ -23,8 +31,6 @@ var Commit = Class.create({
2331
return x.replace("\nparent ","");
2432
});
2533

26-
this.message = this.raw.substring(messageStart, diffStart);
27-
this.diff = this.raw.substring(diffStart);
2834
},
2935
});
3036

@@ -59,6 +65,7 @@ var doeHet = function() {
5965
});
6066

6167
$("message").innerHTML = commit.message.replace(/\n/g,"<br>");
68+
6269
if (commit.diff.length < 10000) {
6370
showDiffs();
6471
} else {

0 commit comments

Comments
 (0)