sshaw / git-link

Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
394 stars 73 forks source link

fix: empty branch name error, use commit hash as fallback always #106

Closed liuyinz closed 1 year ago

liuyinz commented 1 year ago

When you are not on any branch and set git-link-use-commit to nil, function git-link--branch return empty string "", and returned url is wrong. So use commit hash as fallback if branch name is empty.

sshaw commented 1 year ago

Hi, thanks for the PR.

This has come up before in #46 but unfortunately we were unable to come to a conclusion. Have a look a the commentary there are let me know your thoughts.

liuyinz commented 1 year ago

@sshaw oh thanks. I don't notice that since it's about years ago.

  1. For all situations, it must has a commit hash, so use commit should be default setting.
  2. add option named like git-link-prefer-branch rather than git-link-use-commit is more intuitive, you could defalias or depreciate that.

That's how my patch works, just use boolean not use as-fallback thing and it seems git-link-use-commit was only used in git-link--new, it would be very easy to fix that