Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gitattributes): Add "hex" diff tag to binary files #1367

Merged
merged 1 commit into from Apr 28, 2017

Conversation

jhermsmeier
Copy link
Contributor

@jhermsmeier jhermsmeier commented Apr 28, 2017

This adds a diff tag to binary files in .gitattributes,
enabling git to use an external tool to generate diffable output for binary files
by adding a handler to the local or global git config, i.e:

[diff "hex"]
  textconv = hexdump
  binary = true

screen shot 2017-04-13 at 03 04 23

Change-Type: patch

This adds a `diff` tag to binary files in `.gitattributes`,
enabling git to use an external tool to generate diffable output for binary files
by adding a handler to the local or global git config, i.e:

```
[diff "hex"]
  textconv = hexdump
  binary = true
```

Change-Type: patch
@jviotti
Copy link
Contributor

jviotti commented Apr 28, 2017

Amazing! I must confess I'm really curious about what you're using this for :)

@jhermsmeier
Copy link
Contributor Author

Amazing! I must confess I'm really curious about what you're using this for :)

Hehe 😄

The story behind it: I got a bit frustrated with the test .dmg images in #1248 differing from their source image (the raspberry test image file), and no nice way to diff them. So I started looking for ways to get git to do binary diffs, and found the gitattribute tags and textconv settings deep in the docs.
Then I got a bit frustrated with how slow hexdump was, and wrote hxd, which streams, is pageable and 2x as fast as hexdump – and that's what I'm using now to do bindiffs on test images in Etcher :)

@jviotti
Copy link
Contributor

jviotti commented Apr 28, 2017

Cool stuff. I'm thinking if we could somehow make use of these diffs for something else. Do you it would make sense to display something like that (or allow it to save it somehow) to the user when there is a validation error? Alternatively, if most users won't be able to make sense out of it, would it make sense to send it to us so we can inspect it?

@jviotti jviotti merged commit 0c79c49 into master Apr 28, 2017
@jviotti jviotti deleted the hex-diff-attr branch April 28, 2017 15:46
@lurch
Copy link
Contributor

lurch commented May 3, 2017

@jhermsmeier Would it be worth adding hxd as a devDependency, and then setting up the unit-tests so that if one of the image-writing-tests fails, it automatically outputs the hex diff of the failed file? (or is that best still left as a manual step, due to the large amount of output it'd be likely to generate?)

@jhermsmeier
Copy link
Contributor Author

I don't think so – we'd have to write a bunch more code in the tests to even display the diffs – it'll be a lot easier & faster to just run the failing ones locally and inspect the output.

@lurch
Copy link
Contributor

lurch commented May 3, 2017

Perhaps you could add some notes to one of the docs, explaining how to do this hex-diff for any image that fails the unit-tests? ;)

@jhermsmeier
Copy link
Contributor Author

@lurch yup, good idea! Added in #1380

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.

None yet

3 participants