Commit Diff


commit - 7302608848e67227a8541d29907f9875ba7ff3e8
commit + 3b7f9878a38d53f15be7e33cd55c2b68d870710a
blob - 641b24fbfac455d82e70678c29699656df2e9b22
blob + 7257f45c3c44bf2c9a6008a77f988cfa8c03092c
--- lib/object.c
+++ lib/object.c
@@ -895,7 +895,7 @@ got_object_tree_path_changed(int *changed,
 	struct got_tree_object *tree1 = NULL, *tree2 = NULL;
 	struct got_tree_entry *te1 = NULL, *te2 = NULL;
 	const char *seg, *s;
-	size_t seglen, remain = strlen(path);
+	size_t seglen;
 
 	*changed = 0;
 
@@ -911,15 +911,13 @@ got_object_tree_path_changed(int *changed,
 	tree2 = tree02;
 	s = path;
 	s++; /* skip leading '/' */
-	remain--;
 	seg = s;
 	seglen = 0;
-	while (remain > 0) {
+	while (*s) {
 		struct got_tree_object *next_tree1, *next_tree2;
 
 		if (*s != '/') {
 			s++;
-			remain--;
 			seglen++;
 			if (*s)
 				continue;
@@ -947,14 +945,13 @@ got_object_tree_path_changed(int *changed,
 			goto done;
 		}
 
-		if (remain == 0) { /* final path element */
+		if (*s == '\0') { /* final path element */
 			*changed = 1;
 			goto done;
 		}
 
 		seg = s + 1;
 		s++;
-		remain--;
 		seglen = 0;
 		if (*s) {
 			err = got_object_open_as_tree(&next_tree1, repo,