On 11/26/2014 08:05 AM, Colin Walters wrote:
On Tue, Nov 25, 2014, at 02:50 PM, David Shea wrote:
> - git_files = check_output("git status --porcelain", shell=True)
> + git_files = check_output("git status --porcelain -z", shell=True)
This is not your bug, but seeing "shell=True" always makes me shudder.
It's perfectly safe here, but I've seen it in other contexts where someone later
comes by and adds a user-provided argument. In a web context, that's an instant
remote shell. In a local context, it's a reliability issue with filenames that might
contain shell metacharacters.
I'll change it, especially since all that does matter for the git show
command being added.
> +for gf in git_iter:
> # If the file is being removed, or is not in git, or is not part of this
> # commit, ignore it
> if gf[0] in ('D', '?', ' '):
> continue
> - # If the file is being renamed, grab the target filename
> +
> + # If the file is being renamed, the target filename (which we want) is on
> + # the current line, and the next line is the source, which we want to skip
> if gf[0] == 'R':
> - target = gf[3:].split(' -> ')[1]
> - if is_python(target):
> - pylint_files.append(target)
> - elif is_python(gf[3:]):
> + git_iter.next()
We're also skipping the next file if something is not in git, which is
not what we want, right? Something like:
if gf[0] in ('?', ' '):
continue
elif gf[0] == 'D':
git_iter.next()
I'm not sure I follow you here. To remove the confusion of old context,
the patched code looks like this:
if gf[0] in ('D', '?', ' '):
continue
if gf[0] == 'R':
git_iter.next()
The 'R' status entries are different in that they contain two filenames.
In the --porcelain format (no -z), they come out as:
R source_filename -> target_filename
whereas with -z, it's sent as two records:
R target_filename\0source_filename\0
We don't really care about the source filename, so we can just skip it
and keep processing the first part of the R record the same as a M, A or
U record. For files that are deleted, untracked, or not updated in the
commit, we just ignore the file and continue to the next record in the loop.
_______________________________________________
anaconda-patches mailing list
anaconda-patches(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches