New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be robust with regard to branch names that contain quotation marks (finishes up on #27) #62
Conversation
2293d77
to
bce2c11
Compare
bce2c11
to
9f84c62
Compare
|
Rebased off of #50 and onto |
|
Turned it back into a draft because: @esc I just learned about git for-each-ref --python --format="[%(objectname), %(*objectname), %(objecttype), %(refname)]"I haven't checked yet when Git started to offer switch |
|
@hartwork I vaguely recall using that a few years ago, I think I never really understood at the time, what the advantage is, but perhaps the magic is in the quoting? |
Exactly: # git for-each-ref --python --format="[%(objectname), %(*objectname), %(objecttype), %(refname)]"
[..]
['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', 'commit', 'refs/heads/double"tick']
[..]
['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', 'commit', 'refs/heads/single\'tick']
[..]
['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', 'commit', 'refs/heads/triple"""tick']
[..]
['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', '', 'commit', 'refs/heads/triple\'\'\'tick']
[..] |
|
@hartwork indeed, in that case perhaps this is a good idea? |
I just checked for the availability of # docker run --rm -it ubuntu:18.04 bash -c 'sed "\/usr\/share\/man/d" -i /etc/dpkg/dpkg.cfg.d/excludes && apt-get update && apt-get install -y --no-install-recommends git man && sed -e 2p -e d /etc/os-release && git --version && git for-each-ref --help | fgrep -i python'
[..]
VERSION="18.04.4 LTS (Bionic Beaver)"
git version 2.17.1
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]
--shell, --perl, --python, --tcl# docker run --rm -it ubuntu:16.04 bash -c 'apt-get update && apt-get install -y --no-install-recommends git man && sed -e 2p -e d /etc/os-release && git --version && git for-each-ref --help | fgrep -i python'
[..]
VERSION="16.04.6 LTS (Xenial Xerus)"
git version 2.7.4
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]
--shell, --perl, --python, --tcl# docker run --rm -it ubuntu:14.04 bash -c 'apt-get update && apt-get install -y --no-install-recommends git man && sed -e 2p -e d /etc/os-release && git --version && git for-each-ref --help | fgrep -i python'
[..]
VERSION="14.04.6 LTS, Trusty Tahr"
git version 1.9.1
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl]
--shell, --perl, --python, --tcl |
9f84c62
to
13193a1
Compare
Done. |
.. and support branch names with e.g. single tick characters ("'")
properly.
To reproduce (with releases 0.9.0 to 0.10.1):
$ git init
$ git commit -m 'Empty first commit' --allow-empty
$ git branch "',subprocess.call('echo'+chr(32)+'owned',shell=True),'"
$ git-big-picture --graphviz 2>/dev/null # or similar
owned
13193a1
to
67eeb4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asking a question about the test, looks good otherwise!
| @@ -125,3 +125,10 @@ try profiling | |||
| stats | |||
| $ rm stats file.svg | |||
| $ ls | |||
|
|
|||
| be robust with regard to branch names that contain special characters | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This look convenient, but seems to be somewhat misusing the scruf testing framework since it's not strictly testing features of the command line interface. But, this is probably a lot harder/laborious to do in "regular" python test code with unitest and friends?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mostly a crash test for now, true, yes. We can make a deal about re-writing it outside of scruf after 1.0.0 if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's include it since it solves the problem in a pragmatic way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Crash tests confirms that it works.
Finishes up on pull request #27 by rebasing onto latest
masterand by adding a simple test.Sits on top of #50 to avoid merge conflicts for the moment.