Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
dag: add diff tool option #473
This adds a context menu option for each file when viewing commit(s) in the DAG. It opens the external diff tool for
I didn't manage to add Ctrl+D shortcut for that because I don't have that much time (got an error "QAction::eventFilter: Ambiguous shortcut overload: Ctrl+D").
Please check carefully since I don't know the code base / style at all.
I chose not to use
Does that reasoning make sense to you?
The order is what
This reminds me of the same problem we had to solve in
def sha1_diff(git, sha1, filename=None): """Return the diff for a sha1""" # Naively "$sha1^!" is what we'd like to use but that doesn't # give the correct result for merges--the diff is reversed. # Be explicit and compare sha1 against its first parent. args = [sha1 + '~', sha1] opts = common_diff_opts() _add_filename(args, filename) status, out, err = git.diff(*args, **opts) if status != 0: # We probably don't have "$sha1~" because this is the root commit. # "git show" is clever enough to handle the root commit. args = [sha1 + '^!'] _add_filename(args, filename) status, out, err = git.show(pretty='format:', *args, **opts) out = out.lstrip() return out
I think it's okay to ignore root commits for now, since we're launching a difftool. The rationale above is probably what I was thinking about. For a merge, we want to compare the first parent vs. the merge commit. I think
The root commit won't work with this approach but that's fine IMO. It's simpler to just disable the button when the root commit is selected (the
Later, maybe we can special-case the root commit. The way to do that would be to detect that it's a root and then diff it against the empty tree, which is a built-in git constant sha1. Hopefully the resulting code is simpler for this initial version since we only need to know
What do you think?
Hmm I also noticed that when selecting multiple commits in the DAG Log, only the changed files from the topmost commit are shown in "Files". What do you think about changing that to showing all files that changed within that commit range? Then my context menu option for the difftool actually makes sense to use.