Repository: git-big-picture/git-big-picture (language: python)

Issue:
Symbol ' possible in refname, so try define string with '''
Found couple refnames with symbol ' in name.
Proposed change solves problem in my repository, though I do not sure if it correct because I am not Python developer.
Symbol ' possible in refname, so try define string with '''
Found couple refnames with symbol ' in name.
Proposed change solves problem in my repository, though I do not sure if it correct because I am not Python developer.
Migrate from unmaintained Cram to maintained Scruf
Just an idea for consideration.

PS: Not sure why GitHub displays the rename as remove and add. Maybe more fun to review locally :thinking: 


Discussion / hints:
I'd be happy to merge this, if it doesn't break anything.
Can you rebase to master and add a test? Continuous integration is now active.
Pending on a reproducer and a test to expose the bug.
I'd be happy to merge this, if it doesn't break anything.
Can you rebase to master and add a test? Continuous integration is now active.
Pending on a reproducer and a test to expose the bug.


Fix patch:
diff --git a/git-big-picture b/git-big-picture
index ac377d3..806407a 100755
--- a/git-big-picture
+++ b/git-big-picture
@@ -21,6 +21,7 @@
 # along with git-big-picture.  If not, see <http://www.gnu.org/licenses/>.
 
 import argparse
+import ast
 import copy
 import os
 import re
@@ -581,8 +582,8 @@ class Git:
             mapping of non-commit sha1s to sets of strings
         """
 
-        ref_format = "['%(objectname)', '%(*objectname)',  '%(objecttype)', '%(refname)']"
-        output = self(['git', 'for-each-ref', f'--format={ref_format}'])
+        ref_format = '[%(objectname), %(*objectname), %(objecttype), %(refname)]'
+        output = self(['git', 'for-each-ref', f'--format={ref_format}', '--python'])
         lbranch_prefix = 'refs/heads/'
         rbranch_prefix = 'refs/remotes/'
         tag_prefix = 'refs/tags/'
@@ -593,7 +594,7 @@ class Git:
             dic.setdefault(sha1, set()).add(name)
 
         for ref_info in output:
-            sha1, tag_sha1, ref_type, name = eval(ref_info)
+            sha1, tag_sha1, ref_type, name = ast.literal_eval(ref_info)
             if ref_type not in ['commit', 'tag']:
                 continue
             elif name.startswith(lbranch_prefix):
@@ -884,6 +885,7 @@ class CommitGraph:
         for sha_one, labels, color in label_gen():
             label = '\\n'.join(labels + ((with_commit_messages or sha_ones_on_labels) and [
                 format_label(sha_one), ] or list()))
+            label = label.replace('"', '\\"')
             dot_file_lines.append(f'\t"{sha_one}"[label="{label}", color="{color}", style=filled];')
         for sha_one in self.dotdot:
             dot_file_lines.append(


Test patch:
diff --git a/test.scf b/test.scf
index 06daab5..e1fcd44 100755
--- a/test.scf
+++ b/test.scf
@@ -125,3 +125,10 @@ try profiling
     stats
     $ rm stats file.svg
     $ ls
+
+be robust with regard to branch names that contain special characters
+    $ git branch "single'tick"
+    $ git branch "one'two'three"
+    $ git branch 'double"quote'
+    $ git-big-picture -w0 -v true
+    [0]