Coder Social home page Coder Social logo

Comments (14)

OliverJAsh avatar OliverJAsh commented on June 30, 2024 1

I've got this working with git diff, but not git add --patch. Any ideas how to make this work ubiquitously?

from icdiff.

rockwelln avatar rockwelln commented on June 30, 2024

After reading your post, I wanted to make a try with Mercurial.

As explain here: http://mercurial.selenic.com/wiki/ExtdiffExtension
It's sufficient to add the following in the file ~/.hgrc

[extensions]
hgext.extdiff=

[extdiff]
cmd.diff=icdiff

Seems working just fine :-).

from icdiff.

k4nar avatar k4nar commented on June 30, 2024

I don't really like changing the default diff tool, so I would like to use an alias instead, like git icdiff.
So far I got GIT_EXTERNAL_DIFF='sh -c "icdiff \"$2\" \"$5\""' git diff working, but I don't know how to turn it into a git alias.

from icdiff.

desyncr avatar desyncr commented on June 30, 2024

I got it configured as my difftool (git difftool --help) with the following configuration in ~/.gitconfig:

[diff]
    tool = icdiff

[difftool "icdiff"]
    cmd = icdiff $LOCAL $REMOTE

It preserves the default behavior of git diff but aliasing git difftool to gd works just fine 👍

from icdiff.

jomo avatar jomo commented on June 30, 2024

@desyncr you might want to quote that: cmd = icdiff "$LOCAL" "$REMOTE"

from icdiff.

blueyed avatar blueyed commented on June 30, 2024

@desyncr
That does not use a pager, does it? Setting pager.difftool = true does that, but then it fails miserable with the vimdiff difftool.

I've also tried passing it the --no-bold option (I am using the Solarized colorscheme, where this is recommended), but that also fails:

[difftool "icdiff"]
cmd = git-icdiff --no-bold "$LOCAL" "$REMOTE"

+ git difftool --no-prompt --extcmd icdiff --no-bold+  /tmp/VbQI5y_pyenv.vim autoload/pyenv.vim
less --no-init --quit-if-one-screen
fatal: invalid diff option/value: --no-bold

Using it via `git-icdiff` does not display the colors, but Escape codes (this is caused by `LESS_IS_MORE=1`), and fails after quitting `less` before everything has been read:
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

Instead of LESS_IS_MORE, less' -F or --quit-if-one-screen option should be used - or just do not set/change it altogether, using the user's config (via Git's core.pager and the $LESS environment variable).

I think I'll be sticking to vimdiff for Git, but having icdiff in general is nice!

from icdiff.

desyncr avatar desyncr commented on June 30, 2024

@k4nar:
To create any git <anything> command you just need to create an executable inside /usr/lib/git-core/ directory (or similar in your system):

$ cat /usr/lib/git-core/git-icdiff
#!/bin/bash
git difftool

Then I can execute git icdiff and git difftool is executed. In order for this to work with icdiff you need to configure your git difftool appropriately:

$ cat ~/.gitconfig
[diff]
    tool = icdiff
[difftool]
    prompt = false
[difftool "icdiff"]
    cmd = icdiff $LOCAL $REMOTE

Remember to chmod u+x your script. If you don't know where to put your script execute locate git-config and the path where git-config file is located is the one you're looking for.

Obviously more advanced things can be implemented.

from icdiff.

desyncr avatar desyncr commented on June 30, 2024

Regarding the original approach it can be reduced to:

$ cat /usr/local/bin/ext-diff
#!/bin/bash
icdiff $2 $5

With the following git configuration:

[diff]
    external = ext-diff
[core]
    pager = 

Hope that helps.

from icdiff.

k4nar avatar k4nar commented on June 30, 2024

@desyncr : Thanks, I'll try that !

from icdiff.

JoseAlban avatar JoseAlban commented on June 30, 2024

As of today, after installing it via brew, I aliased the wrapper coming with icdiff version 1.7.2:
alias gdi="$(brew --prefix icdiff)/bin/git-icdiff $GIT_DIFF_OPTIONS"
and it works fine, compared against the analogous:
git diff $GIT_DIFF_OPTIONS

from icdiff.

JoseAlban avatar JoseAlban commented on June 30, 2024

To get the file labels correctly, plus other personally cool features, I have now in my .gitconfig:

[pager]
    difftool = true
[diff]
    tool = icdiff
[difftool "icdiff"]
    cmd = icdiff --head=5000 --highlight --line-numbers -L \"$BASE\" -L \"$REMOTE\" \"$LOCAL\" \"$REMOTE\"

And I use it like: git difftool

from icdiff.

jez avatar jez commented on June 30, 2024

@JoseAlban What do the first four lines do? Can they be used independently of the last two lines?

Edit: Should have read the documentation first, it's all explained very clearly. Here are the relevant lines from git-config(1):

diff.tool
       Controls which diff tool is used by git-difftool(1). This variable overrides
       the value configured in merge.tool. The list below shows the valid built-in
       values. Any other value is treated as a custom diff tool and requires that a
       corresponding difftool.<tool>.cmd variable is defined.

...

difftool.<tool>.cmd
       Specify the command to invoke the specified diff tool. The specified command is
       evaluated in shell with the following variables available: LOCAL is set to the
       name of the temporary file containing the contents of the diff pre-image and
       REMOTE is set to the name of the temporary file containing the contents of the
       diff post-image.

...

pager.<cmd>
       If the value is boolean, turns on or off pagination of the output of a
       particular Git subcommand when writing to a tty. Otherwise, turns on pagination
       for the subcommand using the pager specified by the value of pager.<cmd>. If
       --paginate or --no-pager is specified on the command line, it takes precedence
       over this option. To disable pagination for all commands, set core.pager or
       GIT_PAGER to cat.

For the record, I also went ahead and set difftool.prompt = false, like others have mentioned:

difftool.prompt
       Prompt before each invocation of the diff tool.

from icdiff.

JoseAlban avatar JoseAlban commented on June 30, 2024

@jez exactly! I just couldn't tie it together nicely with git show :( but it has by itself an inline diff (surprisingly), which is what I use (although I wish I could do icdiff still):

git show --word-diff

from icdiff.

jeffkaufman avatar jeffkaufman commented on June 30, 2024

git-icdiff is now part of the default install (and has been for a while)

from icdiff.

Related Issues (20)

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.