Skip to content

A Python CLI tool to visually compare changes between two Git revisions using Meld. Automatically extracts and organizes changed files for side-by-side review. Ideal for code review, debugging, and tracking changes. GPL v3.0 licensed.

License

Notifications You must be signed in to change notification settings

andridov/gitDiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Diff

A command-line utility to visually compare changes between two Git revisions using the Meld diff tool.
This script automates the extraction of changed files from specified Git revisions, saves them to temporary directories, and launches Meld for side-by-side comparison.

Features

  • Visual Diff: Compares two Git revisions using Meld (can be changed on tool that can compare two folders).
  • Customizable: Supports custom paths for Meld, repository, revisions, and log directory.
  • Automatic Extraction: Extracts only changed files between revisions.
  • Symbolic Linking: Uses symbolic links for current HEAD files for efficiency.
  • Logging: Flexible logging options and error handling.

Requirements

  • Python 3.x
  • Meld installed and available in your system path
  • logger.py (custom logging module included or provided separately)
  • Git installed and available in your system path

Installation

  1. Clone the repository or copy the script files:
    git clone <your-repo-url>
    cd <your-repo-directory>
  2. Ensure logger.py is present in the same directory as the script.
  3. Install Meld (if not already installed):
    • On Ubuntu/Debian: sudo apt-get install meld
    • On macOS: brew install meld
    • On Windows: Download Meld

Usage

python git_meld_diff.py [options] [rev_old] [rev_new]

Options

Option Description Default Value
--meld-exec Path to Meld executable meld
--dir-repo Path to the git repository Current directory
--dir-old Directory for older revision files /home/user/temp/compare/old
--dir-new Directory for newer revision files /home/user/temp/compare/new
--log-dir Directory to save logs (not set)
--rev-old Older git revision HEAD^
--rev-new Newer git revision HEAD
--log-level Logging level (debug, info, etc.) debug

Examples

  • Compare the last commit with the current state:
    python git_meld_diff.py
  • Compare two specific revisions:
    python git_meld_diff.py --rev-old abc123 --rev-new def456
  • Specify a custom Meld path and log directory:
    python git_meld_diff.py --meld-exec /usr/bin/meld --log-dir /tmp/logs

How It Works

  1. Parses command-line arguments.
  2. Identifies changed files between two Git revisions.
  3. Extracts file contents for each revision into separate directories.
  4. Launches Meld to visually compare the directories.

Troubleshooting

  • Meld not found: Ensure Meld is installed and the path is correct.
  • logger.py missing: Make sure logger.py is present in the script directory.
  • Permission issues: Run the script with appropriate permissions to create directories and files.

Other

Helpfull Git Aliases

[alias]
	s = status
	b = branch
	bn = rev-parse --abrev-ref HEAD

	### top n commits in currents branch
	l = log --pretty=format:'%Cred%h%Creset %Cgreen%ad%Creset  %s %C(cyan)<%an>%Creset%C(auto)%d%C(reset)' --abbrev-commit --date=format:'%Y%m%d %H:%M' -15
	lt = log --graph --abbrev-commit --pretty=format:'%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(dim white)%cn <%ce>%C(reset)%C(auto)%d%C(reset)\n\t\t%C(white)%s%C(reset)' --date=format:'%Y%m%d %H:%M' -15
	lg = log --pretty=format:'%Cred%h%Creset - %s %C(auto)%d%C(reset)  %Cgreen(%ad) %C(cyan)<%an>%Creset' --abbrev-commit --date=short
	lgt = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(auto)%d%C(reset) %C(cyan)%ad%C(reset) %C(dim white)%cn <%ce>%C(reset)\n\t\t%C(white)%s%C(reset)' --date=format:'%Y%m%d %H:%M'

	# show files
	sf = diff-tree --name-only -r
	df = !"python /home/user/projects/utils_py/git_diff.py"

License

This project is licensed under the GNU General Public License v3.0.

Author

Andrii Dov. andridov@gmail.com

About

A Python CLI tool to visually compare changes between two Git revisions using Meld. Automatically extracts and organizes changed files for side-by-side review. Ideal for code review, debugging, and tracking changes. GPL v3.0 licensed.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages