bug 370381 - git log - visual polish
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370381
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-log.js b/bundles/org.eclipse.orion.client.git/web/git/git-log.js
index 5bc45e6..67ebc8b 100644
--- a/bundles/org.eclipse.orion.client.git/web/git/git-log.js
+++ b/bundles/org.eclipse.orion.client.git/web/git/git-log.js
@@ -36,8 +36,6 @@
 			new mSshTools.SshService(serviceRegistry);
 			var commandService = new mCommands.CommandService({serviceRegistry: serviceRegistry, selection: selection});
 			var linkService = new mLinks.TextLinkService({serviceRegistry: serviceRegistry});
-			
-			var branch;
 		
 			// Git operations
 			var gitClient = new mGitClient.GitService(serviceRegistry);
@@ -103,49 +101,52 @@
 			
 			var loadResource = function(resource){
 				var fileClient = new mFileClient.FileClient(serviceRegistry);
-				initTitleBar(fileClient, navigator, resource, searcher, commandService);
-				if (resource.Type === "RemoteTrackingBranch"){
-					var gitService = serviceRegistry.getService("orion.git.provider");
-					gitService.getLog(resource.HeadLocation, resource.Id, "Getting git incoming changes", function(scopedCommitsJsonData) {
-							navigator.renderer.setIncomingCommits(scopedCommitsJsonData.Children);
-							navigator.renderer.setOutgoingCommits([]);
-							gitService.doGitLog(resource.CommitLocation + "?" + new dojo._Url(path).query, function(jsonData) {
-								resource.Children = jsonData.Children;
-								if(jsonData.NextLocation){
-									resource.NextLocation = resource.Location + "?" + new dojo._Url(jsonData.NextLocation).query;
-								}
-								if(jsonData.PreviousLocation ){
-									resource.PreviousLocation  = resource.Location + "?" + new dojo._Url(jsonData.PreviousLocation).query;
-								}
-								navigator.loadCommitsList(resource.CommitLocation + "?" + new dojo._Url(path).query, resource);															
+				initTitleBar(fileClient, navigator, resource, searcher, commandService).then(
+					function(){
+						if (resource.Type === "RemoteTrackingBranch"){
+							var gitService = serviceRegistry.getService("orion.git.provider");
+							gitService.getLog(resource.HeadLocation, resource.Id, "Getting git incoming changes", function(scopedCommitsJsonData) {
+									navigator.renderer.setIncomingCommits(scopedCommitsJsonData.Children);
+									navigator.renderer.setOutgoingCommits([]);
+									gitService.doGitLog(resource.CommitLocation + "?" + new dojo._Url(path).query, function(jsonData) {
+										resource.Children = jsonData.Children;
+										if(jsonData.NextLocation){
+											resource.NextLocation = resource.Location + "?" + new dojo._Url(jsonData.NextLocation).query;
+										}
+										if(jsonData.PreviousLocation ){
+											resource.PreviousLocation  = resource.Location + "?" + new dojo._Url(jsonData.PreviousLocation).query;
+										}
+										navigator.loadCommitsList(resource.CommitLocation + "?" + new dojo._Url(path).query, resource);															
+									});
 							});
-					});
-				} else if (resource.toRef){
-					if (resource.toRef.RemoteLocation && resource.toRef.RemoteLocation.length===1 && resource.toRef.RemoteLocation[0].Children && resource.toRef.RemoteLocation[0].Children.length===1)
-						dojo.xhrGet({
-							url : resource.toRef.RemoteLocation[0].Children[0].Location,
-							headers : {
-								"Orion-Version" : "1"
-							},
-							handleAs : "json",
-							timeout : 5000,
-							load : function(remoteJsonData, secondArg) {
-								var gitService = serviceRegistry.getService("orion.git.provider");
-								gitService.getLog(remoteJsonData.CommitLocation, "HEAD", "Getting git outgoing changes", function(scopedCommitsJsonData) {
-										navigator.renderer.setIncomingCommits([]);
-										navigator.renderer.setOutgoingCommits(scopedCommitsJsonData.Children);
+						} else if (resource.toRef){
+							if (resource.toRef.RemoteLocation && resource.toRef.RemoteLocation.length===1 && resource.toRef.RemoteLocation[0].Children && resource.toRef.RemoteLocation[0].Children.length===1)
+								dojo.xhrGet({
+									url : resource.toRef.RemoteLocation[0].Children[0].Location,
+									headers : {
+										"Orion-Version" : "1"
+									},
+									handleAs : "json",
+									timeout : 5000,
+									load : function(remoteJsonData, secondArg) {
+										var gitService = serviceRegistry.getService("orion.git.provider");
+										gitService.getLog(remoteJsonData.CommitLocation, "HEAD", "Getting git outgoing changes", function(scopedCommitsJsonData) {
+												navigator.renderer.setIncomingCommits([]);
+												navigator.renderer.setOutgoingCommits(scopedCommitsJsonData.Children);
+												navigator.loadCommitsList(dojo.hash(), resource);
+										});
+									},
+									error : function(error, ioArgs){
 										navigator.loadCommitsList(dojo.hash(), resource);
+									}
 								});
-							},
-							error : function(error, ioArgs){
+							else
 								navigator.loadCommitsList(dojo.hash(), resource);
-							}
-						});
-					else
-						navigator.loadCommitsList(dojo.hash(), resource);
-				} else {
-					navigator.loadCommitsList(dojo.hash(), resource);
-				}
+						} else {
+							navigator.loadCommitsList(dojo.hash(), resource);
+						}
+					}
+				);
 			};
 			
 			if(secondArg.xhr.status===200){
@@ -222,6 +223,8 @@
 
 function initTitleBar(fileClient, navigator, item, searcher, commandService){
 	
+	var deferred = new dojo.Deferred();
+	
 	var isRemote = (item.Type === "RemoteTrackingBranch");
 	var isBranch = (item.toRef && item.toRef.Type === "Branch");
 	
@@ -236,51 +239,56 @@
 	
 	if(fileURI){
 		fileClient.read(fileURI, true).then(
-				dojo.hitch(this, function(metadata) {
-					mGlobalCommands.setPageTarget(metadata, serviceRegistry, commandService); 
-					var branchName;
-					if (isRemote)
-						branchName = item.Name;
-					else if (isBranch)
-						branchName = item.toRef.Name;
-					else
-						branchName = null;
+			dojo.hitch(this, function(metadata) {
+				mGlobalCommands.setPageTarget(metadata, serviceRegistry, commandService); 
+				var branchName;
+				if (isRemote)
+					branchName = item.Name;
+				else if (isBranch)
+					branchName = item.toRef.Name;
+				else
+					branchName = null;
 
-					if(item && item.CloneLocation){
-						var cloneURI = item.CloneLocation;
-						
-						serviceRegistry.getService("orion.git.provider").getGitClone(cloneURI).then(function(jsonData){
-							if(jsonData.Children && jsonData.Children.length>0) {
-								setPageTitle(branchName, jsonData.Children[0].Name, jsonData.Children[0].Location, isRemote, isBranch);
-							} else {
-								setPageTitle(branchName, jsonData.Name, jsonData.Location, isRemote, isBranch);
-							}
-						});
-					}else{
-						setPageTitle(branchName);
-					}
-					var location = dojo.byId("location");
-					if (location) {
-						//If current location is not the root, set the search location in the searcher
-						searcher.setLocationByMetaData(metadata);
-						dojo.empty(location);
-						var breadcrumb = new mBreadcrumbs.BreadCrumbs({
-							container: "location",
-							resource: metadata ,
-							makeHref:function(seg,location){makeHref(fileClient, seg,location, isRemote);
-							}
-						});
-					}
-					navigator.isDirectory = metadata.Directory;
-					mGitCommands.updateNavTools(serviceRegistry, navigator, "pageActions", "selectionTools", navigator._lastTreeRoot);
-					navigator.updateCommands();
-				}),
-				dojo.hitch(this, function(error) {
-					console.error("Error loading file metadata: " + error.message);
-				})
+				if(item && item.CloneLocation){
+					var cloneURI = item.CloneLocation;
+					
+					serviceRegistry.getService("orion.git.provider").getGitClone(cloneURI).then(function(jsonData){
+						if(jsonData.Children && jsonData.Children.length>0) {
+							setPageTitle(branchName, jsonData.Children[0].Name, jsonData.Children[0].Location, isRemote, isBranch);
+						} else {
+							setPageTitle(branchName, jsonData.Name, jsonData.Location, isRemote, isBranch);
+						}
+					});
+				}else{
+					setPageTitle(branchName);
+				}
+				var location = dojo.byId("location");
+				if (location) {
+					//If current location is not the root, set the search location in the searcher
+					searcher.setLocationByMetaData(metadata);
+					dojo.empty(location);
+					var breadcrumb = new mBreadcrumbs.BreadCrumbs({
+						container: "location",
+						resource: metadata ,
+						makeHref:function(seg,location){makeHref(fileClient, seg,location, isRemote);
+						}
+					});
+				}
+				navigator.isDirectory = metadata.Directory;
+				mGitCommands.updateNavTools(serviceRegistry, navigator, "pageActions", "selectionTools", navigator._lastTreeRoot);
+				navigator.updateCommands();
+				
+				deferred.callback();
+			}),
+			dojo.hitch(this, function(error) {
+				deferred.errback(error);
+			})
 		);
+	} else {
+		deferred.callback();
 	}
 	
+	return deferred;
 };
 
 function makeHref(fileClient, seg, location, isRemote) {
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/git-commit-navigator.js b/bundles/org.eclipse.orion.client.git/web/orion/git/git-commit-navigator.js
index 97b787e..3791e1a 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/git-commit-navigator.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/git-commit-navigator.js
@@ -34,16 +34,18 @@
 		this.isDirectory = true;
 		this.model = null;
 		this.myTree = null;
-		this.renderer = new exports.GitCommitRenderer({checkbox: this.checkbox, cachePrefix: "GitCommitsNavigator", minimal: this.minimal}, this);
+		this.renderer = new exports.GitCommitRenderer({cachePrefix: "GitCommitsNavigator", minimal: this.minimal}, this);
 	}
 	
 	GitCommitNavigator.prototype = new mExplorer.Explorer();
 	
-
 	GitCommitNavigator.prototype.loadCommitsList = function(path, treeRoot, force) {
 
 		var waitDeferred = new dojo.Deferred();
 
+		// show checkboxes only for file commits
+		this.renderer._useCheckboxSelection = !this.isDirectory && this.checkbox;
+		
 		path = mUtil.makeRelative(path);
 		if (path === this._lastHash && !force) {
 			waitDeferred.callback();
@@ -92,8 +94,6 @@
 		dojo.place(b, progress, "last");
 		dojo.place(document.createTextNode("..."), progress, "last");
 
-		var self = this;
-
 		if (this.toolbarId && this.selectionToolsId)
 			mGitCommands.updateNavTools(this.registry, this, this.toolbarId, this.selectionToolsId, treeRoot, this.pageNavId);
 
@@ -192,7 +192,7 @@
 				outgoingCommit = true;
 			}
 		});
-
+		
 		switch(col_no){
 		case 0:
 			var col, div, link;
@@ -200,7 +200,7 @@
 			col = document.createElement('td');
 			div = dojo.create("div", {style: "margin-left: 5px; margin-right: 5px; margin-top: 5px; margin-bottom: 5px; padding-left: 20px;"}, col, "only");
 				
-			link = dojo.create("a", {className: "navlinkonpage", href: "/git/git-commit.html#" + item.Location + "?page=1&pageSize=1"}, div, "last");			
+			link = dojo.create("a", {className: "navlink", href: "/git/git-commit.html#" + item.Location + "?page=1&pageSize=1"}, div, "last");			
 			dojo.place(document.createTextNode(item.Message), link, "only");		
 			
 			var _timer;
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
index 2675628..8dd86f4 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
@@ -35,13 +35,15 @@
 		}
 		var commandService = registry.getService("orion.page.command");
 		commandService.renderCommands(toolbar, "dom", item, explorer, "button"); 
+		
 		if (pageNavId) {
-			toolbar = dojo.byId(pageNavId);
-			if (toolbar) {
-				dojo.empty(toolbar);
-				commandService.renderCommands(toolbar, "dom", item, explorer, "button", true);  
+			var pageNav = dojo.byId(pageNavId);
+			if (pageNav) {
+				dojo.empty(pageNav);
+				commandService.renderCommands(pageNav, "dom", item, explorer, "button", true);  
 			}
 		}
+		
 		if (selectionToolbarId) {
 			var selectionTools = dojo.create("span", {id: selectionToolbarId}, toolbar, "last");
 			commandService.renderCommands(selectionTools, "dom", null, explorer, "button", true);