Thanks to visit codestin.com
Credit goes to github.com

Skip to content

filterdiff: Fix header output. - #13

Closed
iazz wants to merge 1 commit into
twaugh:12-git-difffrom
iazz:12-git-diff
Closed

filterdiff: Fix header output.#13
iazz wants to merge 1 commit into
twaugh:12-git-difffrom
iazz:12-git-diff

Conversation

@iazz

@iazz iazz commented Sep 15, 2016

Copy link
Copy Markdown

When outputting header lines, apply prefix changes only to lines
starting with "---" and "+++" but also apply these changes to
arguments of a possibly diff command line.

Adapt tests/fullheader4/run-test and remove it from XFAIL_TESTS.

This fixes #12.

When outputting header lines, apply prefix changes only to lines
starting with "---" and "+++" but also apply these changes to
arguments of a possibly diff command line.

Adapt tests/fullheader4/run-test and remove it from XFAIL_TESTS.

This fixes twaugh#12.

@twaugh twaugh left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! Added a couple of notes, nothing major though.

Comment thread src/filterdiff.c
}
if (strncmp(line, "diff", 4) == 0 && isspace(line[4])) {
size_t args = 0;
const char *end = line + 5, *begin = end, *ws = end;;

@twaugh twaugh Sep 15, 2016

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra semi-colon at the end of the line here.

Comment thread src/filterdiff.c
if (new_prefix_to_add && strncmp (line, "+++", 3) == 0)
fputs (new_prefix_to_add, stdout);
}
if (strncmp(line, "diff", 4) == 0 && isspace(line[4])) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project style is to have a space between the function name and the opening parenthesis.

[ -s errors ] && { cat errors; exit 1; }
cmp output <<"EOF" || exit 1
diff --git a/test.txt b/test.txt
diff --git test.txt test.txt

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks. :)

@iazz

iazz commented Sep 15, 2016

Copy link
Copy Markdown
Author

On Thu, Sep 15, 2016 at 11:17:16AM -0700, thus spake Tim Waugh:

@twaugh approved this pull request.

This looks great, thanks! Added a couple of notes, nothing major though.


In [1]src/filterdiff.c:

  •   fwrite (line, 1, 4, stdout);
    
  •   if (prefix_to_add)
    
  •           fputs (prefix_to_add, stdout);
    
  •   else {
    
  •           if (old_prefix_to_add && strncmp (line, "---", 3) == 0)
    
  •                   fputs (old_prefix_to_add, stdout);
    
  •           if (new_prefix_to_add && strncmp (line, "+++", 3) == 0)
    
  •                   fputs (new_prefix_to_add, stdout);
    
  •   }
    
  •   if (strncmp(line, "diff", 4) == 0 && isspace(line[4])) {
    
  •           size_t          args = 0;
    
  •           const char      *end = line + 5, *begin = end, *ws = end;;
    

There's an extra semi-colon at the end of the line here.

Sure, my bad.

In [2]src/filterdiff.c:

  •   fwrite (line, 1, 4, stdout);
    
  •   if (prefix_to_add)
    
  •           fputs (prefix_to_add, stdout);
    
  •   else {
    
  •           if (old_prefix_to_add && strncmp (line, "---", 3) == 0)
    
  •                   fputs (old_prefix_to_add, stdout);
    
  •           if (new_prefix_to_add && strncmp (line, "+++", 3) == 0)
    
  •                   fputs (new_prefix_to_add, stdout);
    
  •   }
    
  •   if (strncmp(line, "diff", 4) == 0 && isspace(line[4])) {
    

The project style is to have a space between the function name and the
opening parenthesis.

Oh yeah, these escaped my attention.

In [3]tests/fullheader4/run-test:

@@ -19,7 +19,7 @@ EOF
${FILTERDIFF} --strip=1 git-output 2>errors >output || { cat errors; exit 1; }
[ -s errors ] && { cat errors; exit 1; }
cmp output <<"EOF" || exit 1
-diff --git a/test.txt b/test.txt
+diff --git test.txt test.txt

Oops, thanks. :)

I'm not 100% sure about the sense of this, as the resulting diff
command-line looks really awkward, but I suppose it's a reasonable
thing to do anyway.

Cheers,

Ignacy

@twaugh twaugh closed this Sep 16, 2016
twaugh added a commit that referenced this pull request Sep 16, 2016
sergiomb2 pushed a commit to sergiomb2/patchutils that referenced this pull request Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants