Skip to content

Extend xcdiff to become a git difftool for Xcode Projects #25

@kwridan

Description

@kwridan

Is your feature request related to a problem? Please describe.

xcdiff can diff two standalone Xcode Projects. An interesting use case that can be extended from this is using xcdiff as a git difftool to allow comparing an Xcode project against itself within source control.

Describe the solution you'd like

There a few bits needed to make this work:

  • Support diffing .pbxproj files directly (not just .xcodeproj)

    • Difftools are passed two files to diff, in for Xcode project files this will be the underlying .pbxproj files
  • Add a new renderer that uses terms like "Removed" / "Added" rather than "Only in first" / "Only in second"

    • Optionally this renderer could use terminal colors, green text for added items, red for removed, yellow for modified
  • Update documentation with instructions on how to add xcdiff as a diff tool

e.g.

git config --local difftool.xcdiff.cmd 'xcdiff -p1 $(dirname "$LOCAL") -p2 $(dirname "$REMOTE") -d -v
git diff --tool xcdiff

There might be a way to make git automatically select a diff tool for certain file extensions which we could leverage as well (needs more research).

Describe alternatives you've considered

Instead of extending xcdiff itself, we can leverage a bash script to marshal the .pbxproj files to the desired format that enables xcdiff to read it.

e.g.

#!/bin/bash
tmp_dir_1="$(mktemp -d -t xcdif)"
cp "$1" $tmp_dir_1/project.pbxproj

tmp_dir_2="$(mktemp -d -t xcdiff)"
cp "$2" $tmp_dir_2/project.pbxproj

xcdiff -p1 "$tmp_dir_1" -p2 "$tmp_dir_2" -d -v

Another alternative could be to add an additional executable target xcgitdiff that manages some of this under the hood and uses a special renderer that is more suitable for this use case.

Additional context

I have a prototype of a custom renderer that replaces terms:

  • "Only in first" > "Removed"
  • "Only in second" > "Added"
  • "Value mismatch" > "Modified" or "Changed"

xcdiff --format git

Not sure how useful this feature is, but posting here to collect ideas and see if there's interest to pursue this further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions