GithubHelp home page GithubHelp logo

rtfpessoa / diff2html-cli Goto Github PK

View Code? Open in Web Editor NEW
499.0 9.0 50.0 1.59 MB

Pretty diff to html javascript cli (diff2html-cli)

Home Page: https://diff2html.xyz

License: MIT License

JavaScript 5.81% TypeScript 91.54% HTML 2.47% Shell 0.18%
diff pretty git html syntax-highlighting diff2html cli unified-diffs colorized typescript

diff2html-cli's Introduction

diff2html-cli

npm node npm GitHub Actions

npm weekly downloads npm monthly downloads npm yearly downloads npm downloads

Diff to Html generates pretty HTML diffs from unified and git diff output in your terminal

Table of Contents

Features

  • Unified diff and Git diff input

  • line-by-line and side-by-side diff

  • new and old line numbers

  • inserted and removed lines

  • GitHub like style

  • Code syntax highlight

  • Line similarity matching

Online Example

Go to Diff2HTML

Distributions

Setup

npm install -g diff2html-cli

Usage

Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and options]

flag alias description choices default
-s --style Output style line, side line
--fct --fileContentToggle Adds a viewed checkbox to toggle file content true, false true
--sc --synchronisedScroll Synchronised horizontal scroll true, false true
--hc --highlightCode Highlight code true, false true
--cs --colorScheme Color scheme auto, dark, light auto
--su --summary Show files summary closed, open, hidden closed
-d --diffStyle Diff style word, char word
--lm --matching Diff line matching type lines, words, none none
--lmt --matchWordsThreshold Diff line matching word threshold 0.25
--lmm --matchingMaxComparisons Diff line matching maximum line comparisons of a block of changes 2500
--diffMaxChanges Number of changed lines after which a file diff is deemed as too big and not displayed
--diffMaxLineLength Number of characters in a diff line after which a file diff is deemed as too big and not displayed
--renderNothingWhenEmpty Render nothing if the diff shows no change in its comparison false
--maxLineSizeInBlockForComparison Maximum number of characters of the bigger line in a block to apply comparison 200
--maxLineLengthHighlight Maximum number of characters in a line to apply highlight 10000
--hwt --htmlWrapperTemplate Path to custom template to be rendered when using the html output format [string]
-t --title Page title for html output [string]
-f --format Output format html, json html
-i --input Diff input source file, command, stdin command
-o --output Output destination preview, stdout preview
-u --diffy Upload to diffy.org browser, pbcopy, print
-F --file Send output to file (overrides output option) [string]
--ig --ignore Ignore particular files from the diff [string]
-v --version Show version number
-h --help Show help

Exit Status Codes

  • ๐ŸŽ‰ 0: Success
  • ๐Ÿ˜ต 1: Generic Error
  • ๐Ÿ˜ฐ 3: Input diff is empty
  • ๐Ÿ‘ฎ 4: Value of --hwt | --htmlWrapperTemplate is not a valid file

Custom HTML wrapper template

The template is a very based on a simple replace of several placeholders as coded https://github.com/rtfpessoa/diff2html-cli/blob/master/src/cli.ts#L40

To provide a custom template you need to make sure you have the following comments and imports in your HTML, exactly as they are here:

  • Inside the <head> tag
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />
<!--diff2html-css-->
<!--diff2html-js-ui-->
<script>
  document.addEventListener('DOMContentLoaded', () => {
    const targetElement = document.getElementById('diff');
    const diff2htmlUi = new Diff2HtmlUI(targetElement);
    //diff2html-fileListToggle
    //diff2html-synchronisedScroll
    //diff2html-highlightCode
  });
</script>
  • Inside the <body> tag
<div id="diff">
  <!--diff2html-diff-->
</div>

Examples

diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1

  • diff last commit, line by line, word comparison between lines, previewed in the browser and input from git diff command

diff2html -i file -- my-file-diff.diff

  • reading the input from a file

diff -u file1.txt file2.txt | diff2html -i stdin

  • reading diff from stdin

diff2html -f json -o stdout -- -M HEAD~1

  • print json format to stdout

diff2html -F my-pretty-diff.html -- -M HEAD~1

  • print to file

diff2html -F my-pretty-diff.html --hwt my-custom-template.html -- -M HEAD~1

  • print to file using custom markup templates can include the following variables

diff2html --ig package-lock.json --ig yarn.lock

  • Ignore package-lock.json and yarn.lock from the generated diff

NOTE: notice the -- in the examples

Contribute

This is a developer friendly project, all the contributions are welcome. To contribute just send a pull request with your changes following the guidelines described in CONTRIBUTING.md. I will try to review them as soon as possible.

Developing

Make some changes, yarn build and then ./bin/diff2html ๐Ÿ˜‰

License

Copyright 2014-present Rodrigo Fernandes. Released under the terms of the MIT license.

Thanks

This project is inspired in pretty-diff by Scott Gonzรกlez.


diff2html-cli's People

Contributors

anri-asaturov avatar brendannee avatar daleyjem avatar dependabot-preview[bot] avatar dependabot[bot] avatar jung-kim avatar mvisser-nhb avatar pazner avatar ps7ch3 avatar rtfpessoa avatar thatkookooguy avatar tylerjpeterson avatar whyboris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diff2html-cli's Issues

Still running out of heap memory while allowing node 60GB

$ NODE_OPTIONS="--max-old-space-size=60000" time diff2html -s side -F ~/diff.html --lm none -- -M HEAD~

<--- Last few GCs --->

[1762257:0x1e0fdf0]   558168 ms: Scavenge 31225.4 (34640.4) -> 31225.3 (34645.9) MB, 72.5 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 
[1762257:0x1e0fdf0]   558249 ms: Scavenge 31230.6 (34645.9) -> 31230.6 (34649.9) MB, 74.1 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 
[1762257:0x1e0fdf0]   558342 ms: Scavenge 31234.0 (34649.9) -> 31234.0 (34649.9) MB, 87.5 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 


<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: Scavenger: semi-space copy Allocation failed - JavaScript heap out of memory
 1: 0x7f36b570c46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
 2: 0x7f36b570c4b5  [/lib/x86_64-linux-gnu/libnode.so.64]
 3: 0x7f36b5938e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]

<--- Last few GCs --->

[1762257:0x1e0fdf0]   558168 ms: Scavenge 31225.4 (34640.4) -> 31225.3 (34645.9) MB, 72.5 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 
[1762257:0x1e0fdf0]   558249 ms: Scavenge 31230.6 (34645.9) -> 31230.6 (34649.9) MB, 74.1 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 
[1762257:0x1e0fdf0]   558342 ms: Scavenge 31234.0 (34649.9) -> 31234.0 (34649.9) MB, 87.5 / 0.0 ms  (average mu = 0.951, current mu = 0.951) allocation failure 


<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: Scavenger: semi-space copy Allocation failed - JavaScript heap out of memory
 4: 0x7f36b59390e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
 1: 0x7f36b570c46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
 5: 0x7f36b5cd3c66  [/lib/x86_64-linux-gnu/libnode.so.64]
 2: 0x7f36b570c4b5  [/lib/x86_64-linux-gnu/libnode.so.64]
 6: 0x7f36b5d25a0f v8::internal::Scavenger::ScavengeObject(v8::internal::HeapObjectReference**, v8::internal::HeapObject*) [/lib/x86_64-linux-gnu/libnode.so.64]
 3: 0x7f36b5938e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
 7: 0x7f36b5d29277 v8::internal::Scavenger::Process(v8::internal::OneshotBarrier*) [/lib/x86_64-linux-gnu/libnode.so.64]
 4: 0x7f36b59390e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
 8: 0x7f36b5ccecad v8::internal::ScavengingTask::RunInParallel() [/lib/x86_64-linux-gnu/libnode.so.64]
 5: 0x7f36b5cd3c66  [/lib/x86_64-linux-gnu/libnode.so.64]
 9: 0x7f36b5cf6de3 v8::internal::ItemParallelJob::Task::RunInternal() [/lib/x86_64-linux-gnu/libnode.so.64]
 6: 0x7f36b5d25a0f v8::internal::Scavenger::ScavengeObject(v8::internal::HeapObjectReference**, v8::internal::HeapObject*) [/lib/x86_64-linux-gnu/libnode.so.64]
10: 0x7f36b5cf795a v8::internal::ItemParallelJob::Run(std::shared_ptr<v8::internal::Counters>) [/lib/x86_64-linux-gnu/libnode.so.64]
 7: 0x7f36b5d29277 v8::internal::Scavenger::Process(v8::internal::OneshotBarrier*) [/lib/x86_64-linux-gnu/libnode.so.64]
11: 0x7f36b5cdef0a v8::internal::Heap::Scavenge() [/lib/x86_64-linux-gnu/libnode.so.64]
 8: 0x7f36b5ccecad v8::internal::ScavengingTask::RunInParallel() [/lib/x86_64-linux-gnu/libnode.so.64]
12: 0x7f36b5ce51c7 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
 9: 0x7f36b5cf6de3 v8::internal::ItemParallelJob::Task::RunInternal() [/lib/x86_64-linux-gnu/libnode.so.64]
13: 0x7f36b5ce5930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
10: 0x7f36b57a2228  [/lib/x86_64-linux-gnu/libnode.so.64]
14: 0x7f36b5ce791d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
11: 0x7f36b51c4609  [/lib/x86_64-linux-gnu/libpthread.so.0]
15: 0x7f36b5ce7975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
12: 0x7f36b50e9133 clone [/lib/x86_64-linux-gnu/libc.so.6]
Command terminated by signal 6
756.14user 40.47system 9:22.39elapsed 141%CPU (0avgtext+0avgdata 33122304maxresident)k
8inputs+0outputs (0major+11143007minor)pagefaults 0swaps

error when given 0 byte file (windows?)

me again :)

i'm not sure if this is a platform specific issue, but i'm leaving the option open, given the other issues i ran into on this platform

if i give it a 0 byte file, which on windows was generated from something like 'hg diff -r rev1:rev2 > thing.diff', and converted using dos2unix to unix line endings...(horrible i know, but this utility chokes on them too..for which i will file another issue)

the following happens:

โ””โ”€[$] diff2html.cmd -F TESTHTML.html -i file -- thing.diff [8:36:47]
The input is empty. Try again.
C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\main.js:141
argv.help();
^

TypeError: argv.help is not a function
at onInput (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\main.js:141:10)
at FSReqWrap.readFileAfterClose as oncomplete

i'm not sure exactly how to reproduce this differently. i tried just doing 'touch thing.diff', but that didn't seem to make it choke up.

something seems to be broken when using git HEAD^

when I try to run diff2html HEAD^
it opens the web browser and says it found 0 changes

when I try to run pretty-diff HEAD^
it shows me the correct diff

Not sure what's wrong but seems like something is broken

Platform: MacBook Pro (Retina, 15-inch, Mid 2014) macOS Sierra 10.12.6

Can't run diff2html-cli on linux docker container

Step 0: Describe your environment

  • OS: Docker debian/alpine/ubuntu
  • diff2html version: 5.2.9
  • Using diff2html-cli
  • Extra flags: _

Step 1: Describe the problem:

Nothing seems to be generated from diff2html-cli command.

I have generated a git diff and executed the diff2html-cli command but nos logs and no html output

Steps to reproduce:

  1. run a docker container
docker run debian:latest    Or alpine:latest Or ubuntu:latest
  1. install nodejs/npm and diff2html-cli
apt install -y npm 
npm install -g diff2html-cli
  1. Generate a diff from two git repos or two directories

  2. execute
    diff2html -i file -F pretty-diff.html -- my-diff.diff

diff example:

diff --git describe.c
index fabadb8,cc95eb0..4866510
--- a/describe.c
+++ b/describe.c
@@@ -98,20 -98,12 +98,20 @@@
   return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
 }

Observed Results:

  • No logs, no html file generated.
  • Testing on a a bash with windows it works correctly but when testing in a container, it does not.

Expected Results:

  • Expecting an html report.

What am i missing ?

Dependency update?

Hey, first of all, thank you for this amazing lib and its maintenance.

I've noticed, that the package.json locks the diff2html to 3.1.6 while there's 3.1.9 ready with some bug fixes. Is there a chance for upgrade?

It does not want to use the newer release with yarn:

diff2html-cli@^5.1.1:
  version "5.1.1"
  resolved "https://registry.yarnpkg.com/diff2html-cli/-/diff2html-cli-5.1.1.tgz#f6de2131aca5ca8190aa69f574361212f458a757"
  integrity sha512-toCl99MHN1+jErcwys0DEcDGhF8DDO9C2/WGYQK44oCEKCiTVBKEOD6UJJc7TVL4fYR+zqiH7UZDUiPgH/qD4Q==
  dependencies:
    clipboardy "^2.3.0"
    diff2html "3.1.6"
    node-fetch "^2.6.0"
    open "^7.0.3"
    yargs "^15.3.1"

change page title

It is not possible to change the title of the output html diff from cli?

By default it displays Diff to HTML by rtfpessoa.

I would like to pass a parameter to change it, but wasn't able to find it in the docs.

seems don't support property change

for example, when the input is:

Property changes on: a.c ___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index:a.c
===================================================================
the output html is:
+ *

what I expected is:
src/{a.c (revision 1, filemode 100644) -> src/{a.c (revision 2, filemode 100744)

Impossible to create a diff from file โ€“ 5.2.6

In version 5.2.5, it was possible to create a diff from the file by using the following command:

diff2html -i file -- my-file-diff.diff

Starting from 5.2.6, it is impossible to create a diff from the file, using the same command. The error I receive is:

Unknown argument: my-file-diff.diff
error Command failed with exit code 1.

Custom html diff to send per email

In our internal application I am trying to pick up daily changes on few config files and send those diffs daily per email nicely formatted.
I currently see that pull request: #38 which should make available to override some template options, but I am wondering: is jquery.js and highlight.js at all needed, when I want to produce nicely formatted diff files? I tested a few diffs and it makes no difference if I drop the js files.

Thanks.

Feature Request - cmdline argument to set the report title in the html

I am working on documentation that is production released within our company and we started using this great utility. One of the things we need to do after the report is created is manually alter the text of the title and use the sed utility to change it.

What are your thoughts for a request to allow the user to specify the text of the tile via the commandline?

'--renderNothingWhenEmpty' didn't work when using 'stdin' as input

$ echo "123" > /tmp/test
 
$ diff -u /tmp/test /tmp/test | diff2html --renderNothingWhenEmpty -i stdin -s side -F diff.html 
The input is empty. Try again. []
Usage: diff2html [options] -- [diff args]

Options:
  -s, --style                            Output style
                                     [choices: "line", "side"] [default: "line"]
      --fileContentToggle, --fct         Show viewed checkbox to toggle file
...
...
...

I wonder if there is a way to get the display content like in this issue when using 'stdin' as input source

ignore package-lock.json

Problem

package-lock.json routinely has more than 2000 changes after npm install in a large project.

Solution

Simply exclude package-lock.json from showing up in the diff. Optionally give users an option to include it if this behavior is desired.

Unescaped broken HTML in the output

Hello again, this time a bug report:

Repro:

git clone https://github.com/mensfeld/broken-diff.git
cd https://github.com/mensfeld/broken-diff.git
./run.sh

browser will open and then scroll to file called web/assets/javascripts/application.js it looks as followed:

Zrzut ekranu z 2020-07-24 18-08-07

while on a really, really old version of this cli (2.7.0), it looks like so:

Zrzut ekranu z 2020-07-24 18-08-48

ignore.map is not a function

Currently using the --ig flag does not work:

diff2html --ig package-lock.json

results in:

TypeError: ignore.map is not a function

const ignoreArgs = ignore.map(file => `":(exclude)${file}"`);

I've not looked into it, just reporting ๐Ÿ˜…

New Feature: Use random output file names instead of fixed diff.html

Fixed (default) output file name (e.g. file:///private/var/folders/xz/jt5vrgxj3nb7vnb6hhp8lrvsqy78qg/T/diff.html) makes impossible looking into diffs from different projects at the same time because they override each other.

Please use either random default output file names or make output file name a function of the git repository name.

generates empty html file when diff has windows line endings (CRLF)

when the diff diff2html-cli is given, has CRLF line endings, the generator will generate a valid html file, but it will act as if the source diff was empty.

obviously, this isn't ideal on windows -- especially when everything is so hard coded (cmd, powershell) to always output \r\n.

i'm not sure how fixable this is for you, or if it touches the entire code base (hope not). presently i'm running dos2unix on the diffs i create from hg, but of course that is a real hack and has its own pitfalls.

Improve alignment of diff2html -h

When I type diff2html -h, I see:
image

I find the lack of column-based alignment make the output difficult to read. Compare to other CLI utility help outputs like grep --help:
image


Can you please format the output into clean columns?

Convert to TypeScript?

I'm curious if you think it's worth converting (at least part) of the codebase to TypeScript.

The key benefit would be type annotations for method inputs (to make it clear what the methods expect and what types they will return).

I could test out converting a single file to see whether everything works as expected ๐Ÿ‘Œ but only if you think it worth the effort ๐Ÿ‘

open is not recognized as an internal or external command

โ””โ”€[$] diff2html.cmd -i file -- difftest.diff [14:09:15] 'open' is not recognized as an internal or external command,
operable program or batch file.
child_process.js:507
throw err;
^

Error: Command failed: open /tmp/diff.html
'open' is not recognized as an internal or external command,
operable program or batch file.

at checkExecSyncError (child_process.js:464:13)
at Object.execSync (child_process.js:504:13)
at Utils.runCmd (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\utils.js:58:25)
at Diff2HtmlInterface.preview (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\cli.js:106:11)
at onOutput (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\main.js:157:9)
at Diff2HtmlInterface.getOutput (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\cli.js:77:14)
at onInput (C:\Users\sreich\AppData\Roaming\npm\node_modules\diff2html-cli\src\main.js:145:7)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

ideas on what's wrong?

Return code should be non-zero on error

Hey!

When running diff2html, I would expect that a fatal error would return a status code different of 0. Currently, the error is printed but the status code says 0.

<diff2html-diff> element not working in template specified in --htmlWrapperTemplate

UPDATE: I have confirmed that the "stock" template.html works in my environment. I apologize for the confusion. I suspect the problem is related to how I extended your "author" comment with more text. I would still like some clarification, and ideally some examples, on how these "variables" are to be used.

diff2html is not substiituting the diff content when I insert element in a template specified in --htmlWrapperTemplate. I have tried it with the element being a comment and without. I suspect it's a problem with my template file but it's not clear from the documentation how these "variables" are supposed to be used.

I modified your template and have attached the result that I'm using (diff2html-template.html). Here is the command I'm using:

diff2html --summary open --htmlWrapperTemplate diff2html-template.html --style side -i file -F CHANGELOG-LASTBUILD.html -- CHANGELOG-LASTBUILD.txt

I can change the content in the h1 tag and see the changes, but that Header is all I see in the generated HTML page.

The command works great without the --htmlWrapperTemplate option. It would be nice if the provided template.html was a working example and easy for users to modify.

Expected behavior
When using --htmlWrapperTemplate option, and including the element, I expect the diff content to be inserted in the body of the generated html document, and to be able to see the diff content in the browser.

Here's the template I'm using:

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Firmware CHANGELOG</title>

    <!--
      Custom Template for Diff2HTML Output
      Taken from https://github.com/rtfpessoa/diff2html-cli

      To be used with --hwt arg.

      Templates can include the following variables:
        <!--diff2html-css--> - writes default CSS to page
        <!--diff2html-js-ui--> - writes default JavaScript UI scripts to page
        //diff2html-fileListCloseable - writes code to support selected list interaction, must be within a <script> block
        //diff2html-synchronisedScroll - writes code to support selected scroll interaction, must be within a <script> block
        <!--diff2html-diff--> - writes diff content to page

    -->

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />

    <diff2html-css>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/languages/scala.min.js"></script>

    <!--script>
      $(document).ready(function() {
        var diff2htmlUi = new Diff2HtmlUI();
        //diff2html-fileListCloseable
        //diff2html-synchronisedScroll
        //diff2html-highlightCode
      });
    </script-->

  </head>
  <body style="text-align: center; font-family: 'Source Sans Pro',sans-serif;">
    <h1>Firmware CHANGELOG</h1>

    <div id="diff">
      <diff2html-diff>
    </div>
  </body>
</html>

doesn't work with diff?

Maybe I'm mis-understanding the docs but I tried using diff to generate a .diff file and then using diff2html but it shows no diffs

$ cat > file1.txt
1
2
3
4
5
^D
$ cat > file2.txt
1
2
9
4
5
^D
$ diff file1.txt file2.txt
3c3
< 3
---
> 9
$ diff file1.txt file2.txt > test.diff
$ diff2html -i file -- test.diff
$ 

the result is this

screen shot 2017-04-20 at 6 02 58 pm

Is it supposed to work with diff files?

Output file not showing all changed files when using diff -ru

diff2html handles modifications perfectly, but it seems to ignore both new files and deleted files.

I'm running diff2html via the cli. For reference: diff2html 2.3.0, diff2html-cli 2.5.0. I'm using this to diff between my working SVN directory and my web directory (where I've made several changes).

I've tried pipping the diff directly to diff2html and outputting the diff in a file and then using diff2html with file input, but the result is always the same. I'll get a perfect list/display of all my modified files, but nothing about deleted/new files.

To be sure, I checked the raw diff output, and I definitely see references to both deleted and new files:
-- Only in /localpath/src/views: filename.php (for an added file)
-- Only in /svnpath/src/views: anotherfile.php (for a removed file)

COMMAND: Pipping
diff --exclude=.svn -ru /localpath /svpath | diff2html -F /var/www/html/diff-out.html -i stdin

COMMAND: By File
diff --exclude=.svn -ru /localpath /svpath > diffOut.txt
diff2html -F /var/www/html/diff-out.html -i file "diffOut.txt"

I tried removing the --exclude param, but I still don't see removed or new files in the diff2html output.

I looked around for examples of new and deleted files with diff2html and couldn't find any. I'm assuming diff2html supports deleted/new files because I saw an issue about ordering deleted/new files (github @ rtfpessoa/diff2html#33 ), but I don't see anything about a command line argument to pass for diff2html-cli and was unable to find anyone else with this same problem.

Feature request: line anchor

Well, that's one of the things that GitHub and the like have, the ability to use HTML anchors to locate specific lines. But if you're just displaying a diff, maybe it's enough to provide anchors for the diff locations.
example: https://github.com/rtfpessoa/diff2html-cli/blob/18add5d220d624022dd24a303c55f4a63547b65b/template.html#L18

miss-align when show some diff file

Hello, I'm trying to use this tool to show git diffs but find at my diff file, the side-by-side is not aligned.

diff file:

Click to expand!
--- btree.go	2022-06-18 01:44:55.608132000 +0800
+++ btree_generic.go	2022-06-18 01:44:55.608132000 +0800
@@ -1,4 +1,4 @@
-// Copyright 2014 Google Inc.
+// Copyright 2014-2022 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,8 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

-//go:build !go1.18
-// +build !go1.18
+//go:build go1.18
+// +build go1.18
+
+// In Go 1.18 and beyond, a BTreeG generic is created, and BTree is a specific
+// instantiation of that generic for the Item interface, with a backwards-
+// compatible API.  Before go1.18, generics are not supported,
+// and BTree is just an implementation based around the Item interface.

// Package btree implements in-memory B-Trees of arbitrary degree.
//
@@ -48,6 +53,11 @@
// Its functions, therefore, exactly mirror those of
// llrb.LLRB where possible.  Unlike gollrb, though, we currently don't
// support storing multiple equivalent values.
+//
+// There are two implementations; those suffixed with 'G' are generics, usable
+// for any type, and require a passed-in "less" function to define their ordering.
+// Those without this prefix are specific to the 'Item' interface, and use
+// its 'Less' function for ordering.
package btree

import (
@@ -72,32 +82,27 @@
  DefaultFreeListSize = 32
)

-var (
-	nilItems  = make(items, 16)
-	nilChildren = make(children, 16)
-)
-
-// FreeList represents a free list of btree nodes. By default each
+// FreeListG represents a free list of btree nodes. By default each
// BTree has its own FreeList, but multiple BTrees can share the same
-// FreeList.
+// FreeList, in particular when they're created with Clone.
// Two Btrees using the same freelist are safe for concurrent write access.
-type FreeList struct {
+type FreeListG[T any] struct {
  mu     sync.Mutex
-	freelist []*node
+	freelist []*node[T]
}

-// NewFreeList creates a new free list.
+// NewFreeListG creates a new free list.
// size is the maximum size of the returned free list.
-func NewFreeList(size int) *FreeList {
-	return &FreeList{freelist: make([]*node, 0, size)}
+func NewFreeListG[T any](size int) *FreeListG[T] {
+	return &FreeListG[T]{freelist: make([]*node[T], 0, size)}
}

-func (f *FreeList) newNode() (n *node) {
+func (f *FreeListG[T]) newNode() (n *node[T]) {
  f.mu.Lock()
  index := len(f.freelist) - 1
  if index < 0 {
    f.mu.Unlock()
-		return new(node)
+		return new(node[T])
  }
  n = f.freelist[index]
  f.freelist[index] = nil
@@ -106,9 +111,7 @@
  return
}

-// freeNode adds the given node to the list, returning true if it was added
-// and false if it was discarded.
-func (f *FreeList) freeNode(n *node) (out bool) {
+func (f *FreeListG[T]) freeNode(n *node[T]) (out bool) {
  f.mu.Lock()
  if len(f.freelist) < cap(f.freelist) {
    f.freelist = append(f.freelist, n)
@@ -118,37 +121,55 @@
  return
}

-// ItemIterator allows callers of Ascend* to iterate in-order over portions of
+// ItemIteratorG allows callers of {A/De}scend* to iterate in-order over portions of
// the tree.  When this function returns false, iteration will stop and the
// associated Ascend* function will immediately return.
-type ItemIterator func(i Item) bool
+type ItemIteratorG[T any] func(item T) bool

-// New creates a new B-Tree with the given degree.
+// Ordered represents the set of types for which the '<' operator work.
+type Ordered interface {
+	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | ~string
+}
+
+// Less[T] returns a default LessFunc that uses the '<' operator for types that support it.
+func Less[T Ordered]() LessFunc[T] {
+	return func(a, b T) bool { return a < b }
+}
+
+// NewOrderedG creates a new B-Tree for ordered types.
+func NewOrderedG[T Ordered](degree int) *BTreeG[T] {
+	return NewG[T](degree, Less[T]())
+}
+
+// NewG creates a new B-Tree with the given degree.
//
-// New(2), for example, will create a 2-3-4 tree (each node contains 1-3 items
+// NewG(2), for example, will create a 2-3-4 tree (each node contains 1-3 items
// and 2-4 children).
-func New(degree int) *BTree {
-	return NewWithFreeList(degree, NewFreeList(DefaultFreeListSize))
+//
+// The passed-in LessFunc determines how objects of type T are ordered.
+func NewG[T any](degree int, less LessFunc[T]) *BTreeG[T] {
+	return NewWithFreeListG(degree, less, NewFreeListG[T](DefaultFreeListSize))
}

-// NewWithFreeList creates a new B-Tree that uses the given node free list.
-func NewWithFreeList(degree int, f *FreeList) *BTree {
+// NewWithFreeListG creates a new B-Tree that uses the given node free list.
+func NewWithFreeListG[T any](degree int, less LessFunc[T], f *FreeListG[T]) *BTreeG[T] {
  if degree <= 1 {
    panic("bad degree")
  }
-	return &BTree{
+	return &BTreeG[T]{
    degree: degree,
-		cow:  &copyOnWriteContext{freelist: f},
+		cow:  &copyOnWriteContext[T]{freelist: f, less: less},
  }
}

// items stores items in a node.
-type items []Item
+type items[T any] []T

// insertAt inserts a value into the given index, pushing all subsequent values
// forward.
-func (s *items) insertAt(index int, item Item) {
-	*s = append(*s, nil)
+func (s *items[T]) insertAt(index int, item T) {
+	var zero T
+	*s = append(*s, zero)
  if index < len(*s) {
    copy((*s)[index+1:], (*s)[index:])
  }
@@ -157,100 +178,61 @@

// removeAt removes a value at a given index, pulling all subsequent values
// back.
-func (s *items) removeAt(index int) Item {
+func (s *items[T]) removeAt(index int) T {
  item := (*s)[index]
  copy((*s)[index:], (*s)[index+1:])
-	(*s)[len(*s)-1] = nil
+	var zero T
+	(*s)[len(*s)-1] = zero
  *s = (*s)[:len(*s)-1]
  return item
}

// pop removes and returns the last element in the list.
-func (s *items) pop() (out Item) {
+func (s *items[T]) pop() (out T) {
  index := len(*s) - 1
  out = (*s)[index]
-	(*s)[index] = nil
+	var zero T
+	(*s)[index] = zero
  *s = (*s)[:index]
  return
}

// truncate truncates this instance at index so that it contains only the
// first index items. index must be less than or equal to length.
-func (s *items) truncate(index int) {
-	var toClear items
+func (s *items[T]) truncate(index int) {
+	var toClear items[T]
  *s, toClear = (*s)[:index], (*s)[index:]
-	for len(toClear) > 0 {
-		toClear = toClear[copy(toClear, nilItems):]
+	var zero T
+	for i := 0; i < len(toClear); i++ {
+		toClear[i] = zero
  }
}

// find returns the index where the given item should be inserted into this
// list.  'found' is true if the item already exists in the list at the given
// index.
-func (s items) find(item Item) (index int, found bool) {
+func (s items[T]) find(item T, less func(T, T) bool) (index int, found bool) {
  i := sort.Search(len(s), func(i int) bool {
-		return item.Less(s[i])
+		return less(item, s[i])
  })
-	if i > 0 && !s[i-1].Less(item) {
+	if i > 0 && !less(s[i-1], item) {
    return i - 1, true
  }
  return i, false
}

-// children stores child nodes in a node.
-type children []*node
-
-// insertAt inserts a value into the given index, pushing all subsequent values
-// forward.
-func (s *children) insertAt(index int, n *node) {
-	*s = append(*s, nil)
-	if index < len(*s) {
-		copy((*s)[index+1:], (*s)[index:])
-	}
-	(*s)[index] = n
-}
-
-// removeAt removes a value at a given index, pulling all subsequent values
-// back.
-func (s *children) removeAt(index int) *node {
-	n := (*s)[index]
-	copy((*s)[index:], (*s)[index+1:])
-	(*s)[len(*s)-1] = nil
-	*s = (*s)[:len(*s)-1]
-	return n
-}
-
-// pop removes and returns the last element in the list.
-func (s *children) pop() (out *node) {
-	index := len(*s) - 1
-	out = (*s)[index]
-	(*s)[index] = nil
-	*s = (*s)[:index]
-	return
-}
-
-// truncate truncates this instance at index so that it contains only the
-// first index children. index must be less than or equal to length.
-func (s *children) truncate(index int) {
-	var toClear children
-	*s, toClear = (*s)[:index], (*s)[index:]
-	for len(toClear) > 0 {
-		toClear = toClear[copy(toClear, nilChildren):]
-	}
-}
-
// node is an internal node in a tree.
//
// It must at all times maintain the invariant that either
//   * len(children) == 0, len(items) unconstrained
//   * len(children) == len(items) + 1
-type node struct {
-	items  items
-	children children
-	cow    *copyOnWriteContext
+type node[T any] struct {
+	items  items[T]
+	children items[*node[T]]
+	cow    *copyOnWriteContext[T]
}

-func (n *node) mutableFor(cow *copyOnWriteContext) *node {
+func (n *node[T]) mutableFor(cow *copyOnWriteContext[T]) *node[T] {
  if n.cow == cow {
    return n
  }
@@ -258,20 +240,20 @@
  if cap(out.items) >= len(n.items) {
    out.items = out.items[:len(n.items)]
  } else {
-		out.items = make(items, len(n.items), cap(n.items))
+		out.items = make(items[T], len(n.items), cap(n.items))
  }
  copy(out.items, n.items)
  // Copy children
  if cap(out.children) >= len(n.children) {
    out.children = out.children[:len(n.children)]
  } else {
-		out.children = make(children, len(n.children), cap(n.children))
+		out.children = make(items[*node[T]], len(n.children), cap(n.children))
  }
  copy(out.children, n.children)
  return out
}

-func (n *node) mutableChild(i int) *node {
+func (n *node[T]) mutableChild(i int) *node[T] {
  c := n.children[i].mutableFor(n.cow)
  n.children[i] = c
  return c
@@ -280,7 +262,7 @@
// split splits the given node at the given index.  The current node shrinks,
// and this function returns the item that existed at that index and a new node
// containing all items/children after it.
-func (n *node) split(i int) (Item, *node) {
+func (n *node[T]) split(i int) (T, *node[T]) {
  item := n.items[i]
  next := n.cow.newNode()
  next.items = append(next.items, n.items[i+1:]...)
@@ -294,7 +276,7 @@

// maybeSplitChild checks if a child should be split, and if so splits it.
// Returns whether or not a split occurred.
-func (n *node) maybeSplitChild(i, maxItems int) bool {
+func (n *node[T]) maybeSplitChild(i, maxItems int) bool {
  if len(n.children[i].items) < maxItems {
    return false
  }
@@ -308,70 +290,70 @@
// insert inserts an item into the subtree rooted at this node, making sure
// no nodes in the subtree exceed maxItems items.  Should an equivalent item be
// be found/replaced by insert, it will be returned.
-func (n *node) insert(item Item, maxItems int) Item {
-	i, found := n.items.find(item)
+func (n *node[T]) insert(item T, maxItems int) (_ T, _ bool) {
+	i, found := n.items.find(item, n.cow.less)
  if found {
    out := n.items[i]
    n.items[i] = item
-		return out
+		return out, true
  }
  if len(n.children) == 0 {
    n.items.insertAt(i, item)
-		return nil
+		return
  }
  if n.maybeSplitChild(i, maxItems) {
    inTree := n.items[i]
    switch {
-		case item.Less(inTree):
+		case n.cow.less(item, inTree):
      // no change, we want first split node
-		case inTree.Less(item):
+		case n.cow.less(inTree, item):
      i++ // we want second split node
    default:
      out := n.items[i]
      n.items[i] = item
-			return out
+			return out, true
    }
  }
  return n.mutableChild(i).insert(item, maxItems)
}

// get finds the given key in the subtree and returns it.
-func (n *node) get(key Item) Item {
-	i, found := n.items.find(key)
+func (n *node[T]) get(key T) (_ T, _ bool) {
+	i, found := n.items.find(key, n.cow.less)
  if found {
-		return n.items[i]
+		return n.items[i], true
  } else if len(n.children) > 0 {
    return n.children[i].get(key)
  }
-	return nil
+	return
}

// min returns the first item in the subtree.
-func min(n *node) Item {
+func min[T any](n *node[T]) (_ T, found bool) {
  if n == nil {
-		return nil
+		return
  }
  for len(n.children) > 0 {
    n = n.children[0]
  }
  if len(n.items) == 0 {
-		return nil
+		return
  }
-	return n.items[0]
+	return n.items[0], true
}

// max returns the last item in the subtree.
-func max(n *node) Item {
+func max[T any](n *node[T]) (_ T, found bool) {
  if n == nil {
-		return nil
+		return
  }
  for len(n.children) > 0 {
    n = n.children[len(n.children)-1]
  }
  if len(n.items) == 0 {
-		return nil
+		return
  }
-	return n.items[len(n.items)-1]
+	return n.items[len(n.items)-1], true
}

// toRemove details what item to remove in a node.remove call.
@@ -384,27 +366,27 @@
)

// remove removes an item from the subtree rooted at this node.
-func (n *node) remove(item Item, minItems int, typ toRemove) Item {
+func (n *node[T]) remove(item T, minItems int, typ toRemove) (_ T, _ bool) {
  var i int
  var found bool
  switch typ {
  case removeMax:
    if len(n.children) == 0 {
-			return n.items.pop()
+			return n.items.pop(), true
    }
    i = len(n.items)
  case removeMin:
    if len(n.children) == 0 {
-			return n.items.removeAt(0)
+			return n.items.removeAt(0), true
    }
    i = 0
  case removeItem:
-		i, found = n.items.find(item)
+		i, found = n.items.find(item, n.cow.less)
    if len(n.children) == 0 {
      if found {
-				return n.items.removeAt(i)
+				return n.items.removeAt(i), true
      }
-			return nil
+			return
    }
  default:
    panic("invalid type")
@@ -424,8 +406,9 @@
    // We use our special-case 'remove' call with typ=maxItem to pull the
    // predecessor of item i (the rightmost leaf of our immediate left child)
    // and set it into where we pulled the item from.
-		n.items[i] = child.remove(nil, minItems, removeMax)
-		return out
+		var zero T
+		n.items[i], _ = child.remove(zero, minItems, removeMax)
+		return out, true
  }
  // Final recursive call.  Once we're here, we know that the item isn't in this
  // node and that the child is big enough to remove from.
@@ -451,7 +434,7 @@
// We then simply redo our remove call, and the second time (regardless of
// whether we're in case 1 or 2), we'll have enough items and can guarantee
// that we hit case A.
-func (n *node) growChildAndRemove(i int, item Item, minItems int, typ toRemove) Item {
+func (n *node[T]) growChildAndRemove(i int, item T, minItems int, typ toRemove) (T, bool) {
  if i > 0 && len(n.children[i-1].items) > minItems {
    // Steal from left child
    child := n.mutableChild(i)
@@ -495,6 +478,18 @@
  ascend  = direction(+1)
)

+type optionalItem[T any] struct {
+	item  T
+	valid bool
+}
+
+func optional[T any](item T) optionalItem[T] {
+	return optionalItem[T]{item: item, valid: true}
+}
+func empty[T any]() optionalItem[T] {
+	return optionalItem[T]{}
+}
+
// iterate provides a simple method for iterating over elements in the tree.
//
// When ascending, the 'start' should be less than 'stop' and when descending,
@@ -502,13 +497,13 @@
// will force the iterator to include the first item when it equals 'start',
// thus creating a "greaterOrEqual" or "lessThanEqual" rather than just a
// "greaterThan" or "lessThan" queries.
-func (n *node) iterate(dir direction, start, stop Item, includeStart bool, hit bool, iter ItemIterator) (bool, bool) {
+func (n *node[T]) iterate(dir direction, start, stop optionalItem[T], includeStart bool, hit bool, iter ItemIteratorG[T]) (bool, bool) {
  var ok, found bool
  var index int
  switch dir {
  case ascend:
-		if start != nil {
-			index, _ = n.items.find(start)
+		if start.valid {
+			index, _ = n.items.find(start.item, n.cow.less)
    }
    for i := index; i < len(n.items); i++ {
      if len(n.children) > 0 {
@@ -516,12 +511,12 @@
          return hit, false
        }
      }
-			if !includeStart && !hit && start != nil && !start.Less(n.items[i]) {
+			if !includeStart && !hit && start.valid && !n.cow.less(start.item, n.items[i]) {
        hit = true
        continue
      }
      hit = true
-			if stop != nil && !n.items[i].Less(stop) {
+			if stop.valid && !n.cow.less(n.items[i], stop.item) {
        return hit, false
      }
      if !iter(n.items[i]) {
@@ -534,8 +529,8 @@
      }
    }
  case descend:
-		if start != nil {
-			index, found = n.items.find(start)
+		if start.valid {
+			index, found = n.items.find(start.item, n.cow.less)
      if !found {
        index = index - 1
      }
@@ -547,7 +542,7 @@
        return hit, false
      }

strang output:
174431406-ff498f5d-4aba-4e7d-8381-7fc4c0883154

Not able to run diff2html-cli on both windows and wsl

Hi Recently i've updated DIff2html-cli on my machine. This is the command i've used "diff2html -s side -F output.html -- file1.txt file2.txt" But all i'm getting is unknown arguments file1.txt, file2.txt. Can anyone help me with this.
And also somehow its working on my friends machine. But he is using this flad "--renderNothingWhenEmpty". Here's the command he used "diff2html -s side --renderNothingWhenEmpty -F output.html -- file1.txt file2.txt". But for him the html report is getting generated even when there are no differences.
image

I used a windows 10 machine and we have wsl installed with ubuntu 20.04. the machine is a dell precision5560.

Cannot make to work API from imported library

I'm using:

var diff2html = require('diff2html');
...
        const parsed = diff2html.parse(changes);
        const html = diff2html.html(parsed, diff2html.defaultDiff2HtmlConfig);

Note: Diff content is already stored in variable: changes.

But cannot export html with diff content, only obtained empty template such as:

<div class="d2h-file-list-wrapper">
    <div class="d2h-file-list-header">
        <span class="d2h-file-list-title">Files changed (0)</span>
        <a class="d2h-file-switch d2h-hide">hide</a>
        <a class="d2h-file-switch d2h-show">show</a>
    </div>
    <ol class="d2h-file-list">
    
    </ol>
</div><div class="d2h-wrapper">
    
</div>

Also, tried docs example (with a .diff file exported) without success:
diff2html -i file -- my-file-diff.diff

Kindly, can point to any direction?

--title option not working

Hello, I'm trying using with the '--title' option but it does not seem to work in the output html.

Example:

image

Output:

image

I installed the cli tool with npm install -g diff2html-cli

Thank you

Character-by-character highlighting?

Is there a way to do character by character highlighting in diffs? For example:
image
I would only want the last digit in each number to be dark-highlighted.

ENOBUFS error when comparing large commits

I have a really large commit on my private repository. It contains a new json file that has over 40000 lines.
When I try to compare the commit, it shows the following error.

# diff2html v1.1.5 v1.2.7

<ref *1> Error: spawnSync /bin/sh ENOBUFS
    at Object.spawnSync (internal/child_process.js:1067:20)
    at spawnSync (child_process.js:602:24)
    at Object.execSync (child_process.js:647:15)
    at Object.execute (/usr/local/lib/node_modules/diff2html-cli/lib/utils.js:38:36)
    at runGitDiff (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:87:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:125:32)
    at step (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:63:23)
    at Object.next (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:44:53)
    at /usr/local/lib/node_modules/diff2html-cli/lib/cli.js:38:71
    at new Promise (<anonymous>) {
  errno: -105,
  code: 'ENOBUFS',
  syscall: 'spawnSync /bin/sh',
  path: '/bin/sh',
  spawnargs: [ '-c', 'git diff "v1.1.5" "v1.2.7" --no-color ' ],
  error: [Circular *1],
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 2e 67 69 74 69 67 6e 6f 72 65 20 62 2f 2e 67 69 74 69 67 6e 6f 72 65 0a 69 6e 64 65 78 20 66 35 35 32 37 34 63 ... 1056718 more bytes>,
    <Buffer >
  ],
  pid: 12472,
  stdout: <Buffer 64 69 66 66 20 2d 2d 67 69 74 20 61 2f 2e 67 69 74 69 67 6e 6f 72 65 20 62 2f 2e 67 69 74 69 67 6e 6f 72 65 0a 69 6e 64 65 78 20 66 35 35 32 37 34 63 ... 1056718 more bytes>,
  stderr: <Buffer >
} []

How can I increase the buffer size to complete this compare?

Include commit details in diff content

@rtfpessoa Great Tool! It's going to enable me to implement submodule-aware changelogs in my Jenkins pipeline projects, with just 3 lines in the Jenkinsfile. :-)

Is there a way to coerce diff2html-cli to include diff details (author, commit msg, etc) into the html output? Seems a pretty basic functionality. If this isn't possible currently, I imagine I could do some variable substitution or code generation to inject substrings from the git diff into your html template to provide some of it, but ideally your tool would just include (perhaps optionally, if you omitted it intentionally for some reason) the author/commitmsg/sha as an inline header before the corresponding diff content.

-M flag exists?

Looks like I'm responsible for adding this line:
https://github.com/rtfpessoa/diff2html-cli/blame/master/README.md#L135
diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1

I think I added it after seeing this example:
https://github.com/rtfpessoa/diff2html-cli/blob/master/src/yargs.ts#L181
'diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1',

But I don't know what -- -M is meant to do ๐Ÿ˜…
There is no yargs alias for it -- so maybe it's a leftover from a while ago?

ps - it's not listed in the help (diff2html -h) that you can diff against a branch ๐ŸŽ‰
You can be on a branch with no commits, and then run diff2html master and it will compare all changes against master ๐Ÿฅ‡

"--ig" argument leads to git diff error

Hi,

I encounter a git diff error when I run the following command using diff2html-cli :

diff2html -F my-pretty-diff.html --hwt ci/mail-template.html --ig ci -- --no-prefix -U1000 -M HEAD~1

I get this error :

Error: Command failed: git diff "--no-prefix" "-U1000" "-M" "HEAD~1" --no-color ":(exclude)ci"
fatal: ambiguous argument ':(exclude)ci': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

    at checkExecSyncError (node:child_process:681:11)
    at Object.execSync (node:child_process:718:15)
    at Object.execute (/usr/local/lib/node_modules/diff2html-cli/lib/utils.js:38:36)
    at runGitDiff (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:87:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:125:32)
    at step (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:63:23)
    at Object.next (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:44:53)
    at /usr/local/lib/node_modules/diff2html-cli/lib/cli.js:38:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/lib/node_modules/diff2html-cli/lib/cli.js:34:12) {
  status: 128,
  signal: null,
  output: [
    null,
    <Buffer >,
    <Buffer 66 61 74 61 6c 3a 20 61 6d 62 69 67 75 6f 75 73 20 61 72 67 75 6d 65 6e 74 20 27 3a 28 65 78 63 6c 75 64 65 29 63 69 27 3a 20 75 6e 6b 6e 6f 77 6e 20 ... 143 more bytes>
  ],
  pid: 140,
  stdout: <Buffer >,
  stderr: <Buffer 66 61 74 61 6c 3a 20 61 6d 62 69 67 75 6f 75 73 20 61 72 67 75 6d 65 6e 74 20 27 3a 28 65 78 63 6c 75 64 65 29 63 69 27 3a 20 75 6e 6b 6e 6f 77 6e 20 ... 143 more bytes>
} []

Am I doing something wrong ? What am I missing ?

Version details :

  • npm 7.5.1
  • node 15.8.0
  • diff2html 5.1.7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.