Commit Diff


commit - 3b7f9878a38d53f15be7e33cd55c2b68d870710a
commit + b7cd37e556aee40e0c6129a18850576cc7e9f25d
blob - 7257f45c3c44bf2c9a6008a77f988cfa8c03092c
blob + 0826de56f5685ef06c7e6af20bfcfc6cce2953bb
--- lib/object.c
+++ lib/object.c
@@ -808,7 +808,7 @@ got_object_id_by_path(struct got_object_id **id, struc
 	struct got_tree_object *tree = NULL;
 	struct got_tree_entry *te = NULL;
 	const char *seg, *s;
-	size_t seglen, len = strlen(path);
+	size_t seglen;
 
 	*id = NULL;
 
@@ -834,15 +834,13 @@ got_object_id_by_path(struct got_object_id **id, struc
 
 	s = path;
 	s++; /* skip leading '/' */
-	len--;
 	seg = s;
 	seglen = 0;
-	while (len > 0) {
+	while (*s) {
 		struct got_tree_object *next_tree;
 
 		if (*s != '/') {
 			s++;
-			len--;
 			seglen++;
 			if (*s)
 				continue;
@@ -854,13 +852,12 @@ got_object_id_by_path(struct got_object_id **id, struc
 			goto done;
 		}
 
-		if (len == 0)
+		if (*s == '\0')
 			break;
 
 		seg = s + 1;
 		seglen = 0;
 		s++;
-		len--;
 		if (*s) {
 			err = got_object_open_as_tree(&next_tree, repo,
 			    te->id);