Diffing Individual files error - Using Diff and Patch Mission
  • tilakapash November 2011
    Hello,

    I am getting the following error when I submit the unified diff on the mission assignment. I don't understand why.
    I used the following command:
    diff -u diffsingle_original.txt diffsingle_modified.txt > patchsingle.txt

    Here are my 3 files (original, modified and resultant patch)

    Can someone give me a clue ? I'd really like to understand what I am doing wrong.

    JOnas

    -----original file ---------

    This mission is to have you make modifications to a file and submit a
    diff of them. The changes may seem a bit silly, but they will cause the
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.

    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    3. Delete this step (and the blank line below it). (Don't renumber the
    ones below it.)

    4. Leave this step the way it is.

    5. Move this step so it comes between #1 and #2. (Again, don't
    renumber the steps.)

    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    7. There is a typo in this step, which oyu should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained
    this file.

    Good luck!

    --------modified file--------------

    This mission is to have you make modifications to a file and submit a
    diff of them. The changes may seem a bit silly, but they will cause the
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.

    5. Move this step so it comes between #1 and #2. (Again, don't
    renumber the steps.)

    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    4. Leave this step the way it is.

    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    7. There is a typo in this step, which you should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained
    this file.

    Good luck!

    ------patch file----

    --- diffsingle_original.txt 2011-11-18 16:18:45.000000000 +0000
    +++ diffsingle_modified.txt 2011-11-18 16:54:25.000000000 +0000
    @@ -3,26 +3,26 @@
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    + 6. Make an exact copy of this step and place it before #1; change the
    + copy's step number to be 0.
    +
    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.

    + 5. Move this step so it comes between #1 and #2. (Again, don't
    + renumber the steps.)
    +
    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    - 3. Delete this step (and the blank line below it). (Don't renumber the
    - ones below it.)
    -
    4. Leave this step the way it is.

    - 5. Move this step so it comes between #1 and #2. (Again, don't
    - renumber the steps.)
    -
    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    - 7. There is a typo in this step, which oyu should fix.
    + 7. There is a typo in this step, which you should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained
  • dreamriver December 2011
    i think the only thing you did wrong is not change the 6 to a 0.
  • UXE December 2011
    I also get an error "The file resulting from patching does not have the correct contents."

    here is the unidiff I pasted


    --- o-diffsingle.txt 2011-12-14 02:53:43.000000000 +0200
    +++ co-diffsingle.txt 2011-12-14 03:08:46.721027826 +0200
    @@ -3,26 +3,26 @@
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    + 0. Make an exact copy of this step and place it before #1; change the
    + copy's step number to be 0.
    +
    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.
    -
    +
    + 5. Move this step so it comes between #1 and #2. (Again, don't
    + renumber the steps.)
    +
    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    - 3. Delete this step (and the blank line below it). (Don't renumber the
    - ones below it.)
    -
    4. Leave this step the way it is.

    - 5. Move this step so it comes between #1 and #2. (Again, don't
    - renumber the steps.)
    -
    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    - 7. There is a typo in this step, which oyu should fix.
    + 7. There is a typo in this step, which you should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained

  • Brenden December 2011
    I also get the same error, and my diff is the same as UXE, with different filenames and timestamps.
  • Hi folks,

    Thanks for reporting these problems. We're going to work on making the error reporting more helpful: http://openhatch.org/bugs/issue640

    If you go to that bug and add your username to the "nosy" list, you'll be kept up-to-date with updates on it!
  • zooechometa February 2
    I've had the same problem with this mission and found it kind of frustrating. I think I am doing everything correctly and carefully, and although I don't know for sure what the diff results mean, the notations (plusses and minuses) are logically consistent with the instructed changes.

    When it says the results are not correct, it is frustrating to have no idea what it is complaining about.

    I wonder about the newlines in the source file. Although it has newlines, they just show up as two squares and they don't break to the next line. Everything is mostly on one VERY long line making it a headache to read and work with. However, when I press the enter key, the newline generated inside the notepad application actually does break to the next line, and there is no two squares in sight; the Notepad newline is invisible.

    You don't need to generate any newlines yourself if you cut and paste, but why the difference between the sourcefile and Notepad newlines?
  • zooechometa February 2
    Sorry, maybe it's one square for newline. Two squares together = two newlines to put a space between sections.
  • I am facing the same problem.Can you tell me what my mistake is , this has left me completely clueless .

    original file
    ------------------------------
    This mission is to have you make modifications to a file and submit a
    diff of them. The changes may seem a bit silly, but they will cause the
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.

    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    3. Delete this step (and the blank line below it). (Don't renumber the
    ones below it.)

    4. Leave this step the way it is.

    5. Move this step so it comes between #1 and #2. (Again, don't
    renumber the steps.)

    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    7. There is a typo in this step, which oyu should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained
    this file.

    Good luck!

    patch file

    ------------
    --- diffsingle.txt 2008-10-16 01:20:31.670089680 +0530
    +++ mod.txt 2008-10-16 01:47:43.341079500 +0530
    @@ -3,26 +3,25 @@
    diff to contain examples of different types of changes - additions,
    deletions, and changes. Here is what we want you to do to this file:

    + 0. Make an exact copy of this step and place it before #1; change the
    + copy's step number to be 0.
    1. Keep an unmodified copy of this file handy; you'll need it to
    make the diff once you're finished.

    + 5. Move this step so it comes between #1 and #2. (Again, don't
    + renumber the steps.)
    2. Try to keep the formatting intact, as the result file will be
    compared character-for-character. There is exactly one blank line
    between each paragraph and bullet point, and all indentation is
    done with spaces. There is never trailing whitespace.

    - 3. Delete this step (and the blank line below it). (Don't renumber the
    - ones below it.)
    -
    4. Leave this step the way it is.

    - 5. Move this step so it comes between #1 and #2. (Again, don't
    - renumber the steps.)

    6. Make an exact copy of this step and place it before #1; change the
    copy's step number to be 0.

    - 7. There is a typo in this step, which oyu should fix.
    + 7. There is a typo in this step, which you should fix.

    8. Save the changes and make a unified diff of your changes using the
    diff command. Submit the diff on the page from which you obtained
  • burkaman April 22
    I know this is an old thread, but here's what I did to pass this step.

    First, just make sure you follow the instructions very carefully. Everything needs to be formatted perfectly, so make sure everything looks lined up, there's exactly one newline between every paragraph and step, and there aren't any trailing spaces.

    Then, you want to print the diff to a file, because copying text from the console will screw it up, at least on Windows. So run a command like

    diff oldfile.txt newfile.txt > diff.txt

    This will store the output in diff.txt. Then open that file in a good editor (not Notepad, because it screws up the newlines) like gVim or Notepad++ or gedit or something like that. Copying and pasting from there should work out, at least it did for me.

    EDIT: There's a much better way to do this. If you run

    diff oldfile.txt newfile.txt | clip

    it will copy the output directly to the clipboard and you can just paste it into the box. I didn't do this, but I'm pretty sure it should work.
  • Alec May 8
    Thanks for the help.
  • Alec May 8
    Hello future people who are going to read this,

    The problem stated above is caused most of the time by an unwanted white space, so it would make sense to use a command that saves the patch file without any unwanted white spaces. So instead of using "diff -u originalFile.txt modifiedFile.txt > myPatch.txt" use "diff -uw originalFile.txt modifiedFile.txt > myPatch.txt" this will get rid of all white spaces that were accidentally inserted in your modified file.

    cheers.
  • JCrow May 13
    Currently having issues with this...

    To my knowledge I've followed the instructions to the letter... no extra whitespaces either...

    My diff output is:
    <<BEGIN>>
    --- diffsingle.txt Sun May 13 19:27:14 2012
    +++ diffsingle-modified.txt Sun May 13 20:19:42 2012
    @@ -1,3 +1,6 @@
    +Move this sentence to at the start of the file, ensuring that it
    +starts on the first line (remember about the blank lines!).
    +
    This mission is to have you make modifications to a file and submit a
    diff of them. The changes may seem a bit silly, but they will cause the
    diff to contain examples of different types of changes - additions,
    @@ -19,15 +22,11 @@

    Read this sentence, and leave it alone.

    -Nod your head enthusiastically, and then remove this paragraph
    -(being careful to keep just one blank line between the surrounding paragraphs).
    -
    Take this sentence, and copy it underneath itself (remember the blank line!).

    -Move this sentence to at the start of the file, ensuring that it
    -starts on the first line (remember about the blank lines!).
    +Take this sentence, and copy it underneath itself (remember the blank line!).

    -There is a typo in this sentence, which oyu should fix.
    +There is a typo in this sentence, which you should fix.

    Finally, save your changes in your editor and make a unified diff
    of your changes with the diff command. (If you're not sure how,
    <<END>>

    This file doesn't have the numbering I see in the previous posts, is that the problem? I saw no instruction to number the lines of the file...
    Will continue hacking at it... let me know if anyone has any revelations...
  • Same problem as JCrow, my output looks identical I have also tried several variations of the steps to see if I just did them wrong. No luck...
  • becdot May 15
    I am having the exact same problems as JCrow - I've checked for extra whitespace and paragraph breaks, I have output the diff result into a new file so that I don't have to copy and paste from the command line, but the file stops after "(If you're not sure how," and the mission evaluates it as incorrect. I checked both original files, and both were correct (i.e. the missing section at the end isn't because it was missing in the original diff file). Does anyone have any ideas about what I might be doing wrong, or any suggestions for what to do now?
  • Then we are four having these same problems. Suppose we'll have to look at the source code and see what it really expects of us... this mission became quite a bit harder than expected...
  • candm May 16
    I am fifth with that problem.
    My diff:

    --- diffsingle.txt 2012-05-16 13:46:11.705488605 +0200
    +++ diffsingle-modified.txt 2012-05-16 13:54:30.786467732 +0200
    @@ -1,3 +1,6 @@
    +Move this sentence to at the start of the file, ensuring that it
    +starts on the first line (remember about the blank lines!).
    +
    This mission is to have you make modifications to a file and submit a
    diff of them. The changes may seem a bit silly, but they will cause the
    diff to contain examples of different types of changes - additions,
    @@ -19,15 +22,11 @@

    Read this sentence, and leave it alone.

    -Nod your head enthusiastically, and then remove this paragraph
    -(being careful to keep just one blank line between the surrounding paragraphs).
    -
    Take this sentence, and copy it underneath itself (remember the blank line!).

    -Move this sentence to at the start of the file, ensuring that it
    -starts on the first line (remember about the blank lines!).
    +Take this sentence, and copy it underneath itself (remember the blank line!).

    -There is a typo in this sentence, which oyu should fix.
    +There is a typo in this sentence, which you should fix.

    Finally, save your changes in your editor and make a unified diff
    of your changes with the diff command. (If you're not sure how,

Welcome to the OpenHatch forums!

OpenHatch is a community of people aiming to help newcomers find their way into free software projects. If you like talking about that, please join the conversation!

Sign in or register (ignoreme)