openhatch

Issue745

Title "diffing entire directories" dosn't work with ./foo only foo
Milestone Priority bug
Waiting On Status resolved
Superseder Nosy List DeadDork, daveeloo, jesstess, passstab, paulproteus
Assigned To daveeloo Keywords

Created on 2012-07-03.22:47:54 by passstab, last changed 2013-05-18.23:11:24 by paulproteus.

Files
File name Uploaded Type Edit Remove
issue745.diff jesstess, 2012-10-18.19:26:51 application/octet-stream
Messages
msg3717 (view) Author: paulproteus Date: 2013-05-18.23:11:24
Hi all,

The resolution we came to was to add a new error message for this case.

DeadDork + jesstess, thanks for filing it; and huge thanks to daveeloo for 
submitting a working test + patch! This is now deployed.
msg3705 (view) Author: paulproteus Date: 2013-05-08.18:21:25
Comments left on the pull request!
msg3704 (view) Author: paulproteus Date: 2013-05-08.18:06:33
Pull request here, being reviewed: https://github.com/openhatch/oh-
mainline/pull/111
msg3685 (view) Author: DeadDork Date: 2013-05-03.05:03:57
Uhhh yeah, somebody else should take this. I'm under the C these days, not in Pythonica...
msg3684 (view) Author: paulproteus Date: 2013-05-03.04:48:42
Next steps for whoever wants to address this:

* Prepare a sample file that uses an extra ./ in the path

* Write a small test case that uses these files and generates the error

* Put all that into a commit something like https://github.com/openhatch/oh-
mainline/commit/e7a3294e1e8bb908792b8863203ad9adf6b6af60
msg3476 (view) Author: paulproteus Date: 2012-10-28.01:14:35
Thank you for your research into this. Excellent, through work!

What I'd love to see, given what you've found, is that in the backend, we 
check for this posssibility and indicate the problem to the user. 
Basically, that puts us "in the right" in terms of not accepting bad 
input, and also puts us on the right side of pedagogy, where when we know 
what mistake a student has made, we help them fix it.

A recent commit along those lines is this: 
e7a3294e1e8bb908792b8863203ad9adf6b6af60

That error catching should be supported with a test case in the test 
suite, too.

Is that something I can interest you folks in submitting a patch for?
msg3475 (view) Author: DeadDork Date: 2012-10-28.00:56:31
Antigen & I tested a variety of scenarios, and determined that this is indeed 
not a bug.

The documentation on

<http://openhatch.org/missions/diffpatch/diffrecursive/submit#diffrecursive-
form>

says very clearly: 'It should be possible to apply it [the diff file] with 
"patch -p1" from the "recipes" directory.'

What this means, is that the PATH in the diff header will be offset by one when 
the patch utility is used. For example, when the PATH is 'a/test.txt' and 
'b/test.txt', respectively for the source and the target files, then the patch 
utility will be trying to change the lines in 'test.txt' of b (again, because 
the -p1 says to offset by one).

This is where the issue occurs. If a user, using relative paths, creates a diff 
file using './a/test.txt' and './b/test.txt', then the '-p1' will offset only to 
'a' and 'b', not to 'test.txt'. That is, it will try to patch 'b/test.txt'. 
Since we are trying to patch a file on the server that is presumably in the form 
of 'a/test.txt', trying to patch 'b/test.txt' will fail--which is what you see.

Pedagogically, it is our opinion that the current instructions are a bit vague, 
but correct, and that this is not bug.

We suggest that this issue be labeled resolved.
msg3461 (view) Author: paulproteus Date: 2012-10-22.19:23:34
Awesome -- I take it your next step, DeadDork, is adding tests?

Looking forward to that! And if you need any help with that at all, just get on 
IRC and ping me (paulproteus is my nick). Or email the OH-Dev mailing list. I'm 
always happy to help (at least, when I'm around (which is most of the time))!

-- Asheesh.
msg3459 (view) Author: DeadDork Date: 2012-10-22.01:07:50
jesstess asked me to have this assigned to moi! I happily complied!
msg3457 (view) Author: paulproteus Date: 2012-10-18.19:41:09
I'll add -- it'd be amazing if there were some more structural approach to 
this, rather than handling it through string processing.

For example, it seems like os.path.abspath might help here.

But I'll happily accept any patch that works (preferably along with 
an automated test case).

-- Asheesh.
msg3456 (view) Author: paulproteus Date: 2012-10-18.19:38:01
This patch looks great. It'd be even better with a test case, which should 
be fairly easy to add. That way, future refactorings won't lose the 
support for this case.

Can I interest you in adding that?
msg3455 (view) Author: jesstess Date: 2012-10-18.19:26:51
Whoops, forgot the patch!
msg3454 (view) Author: jesstess Date: 2012-10-18.19:26:12
Our approach was to remove a leading "./" from filenames before processing them.

We manually tested our changes on a test instance of the website, and we ran the test suite to 
confirm that all existing tests still pass.
msg3310 (view) Author: paulproteus Date: 2012-07-05.00:44:17
Thanks for filing this! I think it should be a fairly simple issue -- we 
should probably permit "./Skillet.txt" as a valid path in the check, not 
just "Skillet.txt".
msg3309 (view) Author: passstab Date: 2012-07-03.22:47:47
in the "diffing entire directories" mission submitting the result of 
"diff -ur ./recipes ./us > ./outputt" returns 
'Patch does not modify file "Skillet.txt", which it should modify.'
whereas diff -ur recipes us > ./outputt succeeds
History
Date User Action Args
2013-05-18 23:11:24paulproteussetstatus: in-progress -> resolved
messages: + msg3717
2013-05-08 18:21:33paulproteussetassignedto: DeadDork -> daveeloo
nosy: + daveeloo
2013-05-08 18:21:25paulproteussetstatus: testing -> in-progress
messages: + msg3705
2013-05-08 18:06:33paulproteussetmessages: + msg3704
2013-05-03 05:03:57DeadDorksetmessages: + msg3685
2013-05-03 04:48:42paulproteussetmessages: + msg3684
2012-10-28 01:14:35paulproteussetmessages: + msg3476
2012-10-28 00:56:32DeadDorksetmessages: + msg3475
2012-10-22 19:23:34paulproteussetmessages: + msg3461
2012-10-22 01:07:51DeadDorksetassignedto: jesstess -> DeadDork
messages: + msg3459
nosy: + DeadDork
2012-10-18 19:41:09paulproteussetmessages: + msg3457
2012-10-18 19:38:01paulproteussetmessages: + msg3456
2012-10-18 19:26:52jesstesssetfiles: + issue745.diff
messages: + msg3455
2012-10-18 19:26:12jesstesssetstatus: chatting -> testing
assignedto: jesstess
messages: + msg3454
nosy: + jesstess
2012-07-05 00:44:20paulproteussetstatus: unread -> chatting
messages: + msg3310
2012-07-03 22:47:54passstabcreate