timbrel / GitSavvy

Full git and GitHub integration with Sublime Text
MIT License
1.91k stars 136 forks source link

Compare branch against master #237

Closed stevage closed 9 years ago

stevage commented 9 years ago

Maybe I just haven't found the right way yet, but it would be good to have a way to view changes in a file relative to another branch. Diff obviously compares uncommitted changes in the current file against the current branch. How about comparing committed changes in the current file against some other branch?

(The main use case is code review, evaluating PRs etc.)

stoivo commented 9 years ago

So what you want is: diff current file against a branch

I use

stevage commented 9 years ago

Thanks, I didn't know about those. If there was a way to see the sum of all the diffs (rather than just one diff at a time) it would be perfect.

On Thu, Sep 17, 2015 at 5:20 AM, Simon notifications@github.com wrote:

So what you want is: diff current file against a branch

I use

  • git: branch
  • than I uses H to view all commits between a branch
  • I can enter a commit by pressing Enter

— Reply to this email directly or view it on GitHub https://github.com/divmain/GitSavvy/issues/237#issuecomment-140856631.

sentience commented 9 years ago

Just hit ‘f’ instead of ‘H’ to view the diff between the HEAD and selected branch. This is listed in the keyboard reference in the Branch view.

On 17 Sep 2015, at 11:35 AM, Steve Bennett notifications@github.com wrote:

Thanks, I didn't know about those. If there was a way to see the sum of all the diffs (rather than just one diff at a time) it would be perfect.

On Thu, Sep 17, 2015 at 5:20 AM, Simon notifications@github.com wrote:

So what you want is: diff current file against a branch

I use

  • git: branch
  • than I uses H to view all commits between a branch
  • I can enter a commit by pressing Enter

— Reply to this email directly or view it on GitHub https://github.com/divmain/GitSavvy/issues/237#issuecomment-140856631.

— Reply to this email directly or view it on GitHub https://github.com/divmain/GitSavvy/issues/237#issuecomment-140940216.

Kevin Yank @sentience http://kevinyank.com/

stevage commented 9 years ago

I noticed that shortcut but it doesn't work for me:

'utf-8' codec can't decode byte 0xa2 in position 880619: invalid start byte

divmain commented 9 years ago

@stevage, that's strange. It has been known to happen when you have non-UTF-8 data in your Git history. We have fallbacks in place for a couple of methods, but probably not all. Can you tell me the exact repro steps for reaching this condition? If the repo in question is public, even better, as I would be able to duplicate the error on my own machine.

stevage commented 9 years ago

Ok - actually when I try other branches, some of them do work. So that's exciting :)

Repo is: https://github.com/terriajs/terriajs

On branch region-mapping-advanced-matching, attempting to diff hjson or region-mapping-feedback 788fe78 hjson (origin/hjson) ▸ f4f9a7c region-mapping-advanced-matching (origin/region-mapping-advanced-matching) 7923f05 region-mapping-feedback

Every other branch that failed (another 10-15) seem to be ones that have been deleted from the remote on Github. I don't know if that's significant.

Not sure what other repro steps you need. Sublime build 3083, registered, OSX Mavericks.

divmain commented 9 years ago

Yeah, there's definitely non UTF-8 data in there. Example:

git diff --no-color origin/region-mapping-feedback..region-mapping-advanced-matching wwwroot/data/WW15MGH.DAC

Unfortunately, since this is binary data, even falling back to windows-1252 encoding will fail (windows-1252 will usually render text, if somewhat garbled, if the encoding is unknown). I can't think of a good approach to showing some of the data, especially since it would break user expectations to (for example) only show a partial diff and exclude the changes to the binaries.

Running branch comparisons should work fine for you if no binary files have changed. Otherwise, I'm open to suggestions, but GitSavvy probably isn't well suited to this specific case. ¯\_(ツ)_/¯

stevage commented 9 years ago

Interesting - I've never even seen that file (I assume it's a test case that means something to someone else). Anyway, I have a few suggestions :)

  1. Use gitattributes and git diff --textconv to render something as the binary diff (even if just the words "skipping binary diff")
  2. Show a warning, skip the binary bit and continue. (Yes, it "breaks user expectations"...but much more useful than just flat out refusing.) Maybe control this behaviour with a preference?
  3. If all that too hard, then at least display a sensible error message ("Unable to display diff because one or more binary files with non-UTF8 data have changed. To force Git-savvy to ignore binary diffs, enable preference ...") (Or point out other workarounds.)
divmain commented 9 years ago

1 & 2 are problematic, because the place where to decoding occurs has no context for what else is going on. This could be conditionally handled in multiple places using a custom exception hierarchy (something I'll implement eventually), but option 3 should be good enough for now. (c00374c)