I was having an issue where iq-diff was add'ing all files to my patch, including .svn and patch files, even when those were excluded by .gitignore. After a little heading of the (seemingly infinite) git docs I turned up the -u/--update option to "git add", which only adds files that are already tracked by git - I think makes it work more like I would expect. In my tests I was able to explicitly "git add" new files that I wanted included.

I am not sure if this addresses the "TODO: can we easily ignore *.patch, etc., or easily add only modified files?" fully or only partially, so left that in.

CommentFileSizeAuthor
dash-u.patch2.09 KBowen barton

Comments

greg.1.anderson’s picture

Assigned: Unassigned » greg.1.anderson
Status: Needs review » Needs work

Yes, I agree with this, and will likely commit the change in #0 as suggested, with git add -u ., but might want to change it slightly, e.g. perhaps to git add -A ., which is similar. Now that drush iq-diff works well with multiple commits on the branch (and iq-merge can be used to easily squash them down to a single commit when done), I think that folks will feel more confident in using git add on their own when they want to add new files to a diff.

I set this to "needs work" because I'd like to figure out exactly what modes to use everywhere that git add is called, and commit one fix that adjusts all of them. I'm getting pretty good results with git add -A when applying a patch. If there is a reason for being different in different parts of the code, the difference should be noted in a comment; otherwise, it should behave uniformly.

I'll do this when I have time, but any help is welcome and appreciated.

owen barton’s picture

I am unclear how -A is different from the current behavior (with no flags) in terms of adding untracked files - the help section says:

-A, --all
Like -u, but match against files in the working tree in addition to the index. That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree.

It sounds like the main difference is just that it detects/handles removed files - is that correct?

I often end up with files/patches lying around that I don't want added to the commit - I would generally prefer only files I explicitly request to be tracked to be added to a commit/patch (I don't have a particular preference with removed files). If this is different from what others are expecting, perhaps we need to add an option here?

greg.1.anderson’s picture

No, I agree with you. I was thinking about this some more, and I don't think that iq-apply-patch is going to work correctly until I manually extract the paths to all of the files provided or modified by the patch and explicitly git-add all of the new files. (Note that this is only an issue when applying patches created with diff or git diff, as format-patch will already add the right files.) There is no good heuristic to determine which files that just "happen" to be in the directory should be added to the commit, so by default, extra files that are found should not be added unless the user explicitly requests them.

Supporting --all in iq-diff would be reasonable.

greg.1.anderson’s picture

Status: Needs work » Fixed

Modified iq-apply-patch to also use 'git add -u .', and explicitly added new files using 'git add filename'. Committed this and #0 to the 7.x-1.x branch.

Did not implement --all in iq-diff; that can be handled separately, if desired at all.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.