@@ -455,16 +455,28 @@ def stale_refs(self):
455
455
remote side, but are still available locally.
456
456
457
457
The IterableList is prefixed, hence the 'origin' must be omitted. See
458
- 'refs' property for an example."""
458
+ 'refs' property for an example.
459
+
460
+ To make things more complicated, it can be possble for the list to include
461
+ other kinds of references, for example, tag references, if these are stale
462
+ as well. This is a fix for the issue described here:
463
+ https://github.com/gitpython-developers/GitPython/issues/260
464
+ """
459
465
out_refs = IterableList (RemoteReference ._id_attribute_ , "%s/" % self .name )
460
466
for line in self .repo .git .remote ("prune" , "--dry-run" , self ).splitlines ()[2 :]:
461
467
# expecting
462
468
# * [would prune] origin/new_branch
463
469
token = " * [would prune] "
464
470
if not line .startswith (token ):
465
471
raise ValueError ("Could not parse git-remote prune result: %r" % line )
466
- fqhn = "%s/%s" % (RemoteReference ._common_path_default , line .replace (token , "" ))
467
- out_refs .append (RemoteReference (self .repo , fqhn ))
472
+ ref_name = line .replace (token , "" )
473
+ # sometimes, paths start with a full ref name, like refs/tags/foo, see #260
474
+ if ref_name .startswith (Reference ._common_path_default + '/' ):
475
+ out_refs .append (SymbolicReference .from_path (self .repo , ref_name ))
476
+ else :
477
+ fqhn = "%s/%s" % (RemoteReference ._common_path_default , ref_name )
478
+ out_refs .append (RemoteReference (self .repo , fqhn ))
479
+ # end special case handlin
468
480
# END for each line
469
481
return out_refs
470
482
0 commit comments