From 834c452d8d30c9305b57352a73684c5f007025de Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 22 May 2019 04:13:59 -0400 Subject: [PATCH] Adds dotted notation setting - closes #330 --- CHANGELOG.md | 1 + README.md | 31 ++++++++++++++++--------------- package.json | 6 ++++++ src/config.ts | 1 + src/views/nodes/compareBranchNode.ts | 6 ++++-- src/views/nodes/compareResultsNode.ts | 4 +++- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f7db1d..4c77656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - A context menu provides access to more common file revision commands - **\* Files Changed** — lists all of the files changed between the compared revisions - Adds a `gitlens.views.repositories.showBranchComparison` setting to specify whether to show a comparison of the current branch to a user-selected reference in the _Repositories_ view +- Adds a `gitlens.advanced.useSymmetricDifferenceNotation` setting to specify whether to use the symmetric difference (three-dot) notation or the range (two-dot) notation for comparisions — closes [#330](https://github.com/eamodio/vscode-gitlens/issues/330) - Adds a _Copy Remote Url to Clipboard_ command to commit quick pick menus ## Changed diff --git a/README.md b/README.md index 7041534..7249b83 100644 --- a/README.md +++ b/README.md @@ -858,21 +858,22 @@ See also [View Settings](#view-settings- 'Jump to the View settings') ### Advanced Settings [#](#advanced-settings- 'Advanced Settings') -| Name | Description | -| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of abbreviated commit ids (shas) | -| `gitlens.advanced.blame.customArguments` | Specifies additional arguments to pass to the `git blame` command | -| `gitlens.advanced.blame.delayAfterEdit` | Specifies the time (in milliseconds) to wait before re-blaming an unsaved document after an edit. Use 0 to specify an infinite wait | -| `gitlens.advanced.blame.sizeThresholdAfterEdit` | Specifies the maximum document size (in lines) allowed to be re-blamed after an edit while still unsaved. Use 0 to specify no maximum | -| `gitlens.advanced.caching.enabled` | Specifies whether git output will be cached — changing the default is not recommended | -| `gitlens.advanced.fileHistoryFollowsRenames` | Specifies whether file histories will follow renames -- will affect how merge commits are shown in histories | -| `gitlens.advanced.maxListItems` | Specifies the maximum number of items to show in a list. Use 0 to specify no maximum | -| `gitlens.advanced.maxSearchItems` | Specifies the maximum number of items to show in a search. Use 0 to specify no maximum | -| `gitlens.advanced.messages` | Specifies which messages should be suppressed | -| `gitlens.advanced.quickPick.closeOnFocusOut` | Specifies whether to close QuickPick menus when focus is lost | -| `gitlens.advanced.repositorySearchDepth` | Specifies how many folders deep to search for repositories | -| `gitlens.advanced.similarityThreshold` | Specifies the amount (percent) of similarity a deleted and added file pair must have to be considered a rename | -| `gitlens.advanced.telemetry.enabled` | Specifies whether to enable GitLens telemetry (even if enabled still abides by the overall `telemetry.enableTelemetry` setting | +| Name | Description | +| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of abbreviated commit ids (shas) | +| `gitlens.advanced.blame.customArguments` | Specifies additional arguments to pass to the `git blame` command | +| `gitlens.advanced.blame.delayAfterEdit` | Specifies the time (in milliseconds) to wait before re-blaming an unsaved document after an edit. Use 0 to specify an infinite wait | +| `gitlens.advanced.blame.sizeThresholdAfterEdit` | Specifies the maximum document size (in lines) allowed to be re-blamed after an edit while still unsaved. Use 0 to specify no maximum | +| `gitlens.advanced.caching.enabled` | Specifies whether git output will be cached — changing the default is not recommended | +| `gitlens.advanced.fileHistoryFollowsRenames` | Specifies whether file histories will follow renames -- will affect how merge commits are shown in histories | +| `gitlens.advanced.maxListItems` | Specifies the maximum number of items to show in a list. Use 0 to specify no maximum | +| `gitlens.advanced.maxSearchItems` | Specifies the maximum number of items to show in a search. Use 0 to specify no maximum | +| `gitlens.advanced.messages` | Specifies which messages should be suppressed | +| `gitlens.advanced.quickPick.closeOnFocusOut` | Specifies whether to close QuickPick menus when focus is lost | +| `gitlens.advanced.repositorySearchDepth` | Specifies how many folders deep to search for repositories | +| `gitlens.advanced.similarityThreshold` | Specifies the amount (percent) of similarity a deleted and added file pair must have to be considered a rename | +| `gitlens.advanced.telemetry.enabled` | Specifies whether to enable GitLens telemetry (even if enabled still abides by the overall `telemetry.enableTelemetry` setting | +| `gitlens.advanced.useSymmetricDifferenceNotation` | Specifies whether to use the symmetric difference (three-dot) notation or the range (two-dot) notation for comparisions. See the [Git docs](https://git-scm.com/docs/gitrevisions#_dotted_range_notations) | #### Custom Remotes Settings diff --git a/package.json b/package.json index 27a59df..98292a6 100644 --- a/package.json +++ b/package.json @@ -1752,6 +1752,12 @@ "default": true, "markdownDescription": "Specifies whether to enable GitLens telemetry (even if enabled still abides by the overall `#telemetry.enableTelemetry#` setting", "scope": "window" + }, + "gitlens.advanced.useSymmetricDifferenceNotation": { + "type": "boolean", + "default": true, + "markdownDescription": "Specifies whether to use the symmetric difference (three-dot) notation or the range (two-dot) notation for comparisions. See the [Git docs](https://git-scm.com/docs/gitrevisions#_dotted_range_notations)", + "scope": "window" } } }, diff --git a/src/config.ts b/src/config.ts index d53d2d2..0b81c5e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -224,6 +224,7 @@ export interface AdvancedConfig { telemetry: { enabled: boolean; }; + useSymmetricDifferenceNotation: boolean; } export interface CodeLensConfig { diff --git a/src/views/nodes/compareBranchNode.ts b/src/views/nodes/compareBranchNode.ts index 8d5a37c..e994099 100644 --- a/src/views/nodes/compareBranchNode.ts +++ b/src/views/nodes/compareBranchNode.ts @@ -44,7 +44,7 @@ export class CompareBranchNode extends ViewNode { querying: true } ), - new ResultsFilesNode(this.view, this, this.uri.repoPath!, this.branch.ref, this._compareWith) + new ResultsFilesNode(this.view, this, this.uri.repoPath!, this._compareWith, this.branch.ref) ]; } return this._children; @@ -102,9 +102,11 @@ export class CompareBranchNode extends ViewNode { } private async getCommitsQuery(maxCount: number | undefined): Promise { + const notation = Container.config.advanced.useSymmetricDifferenceNotation ? '...' : '..'; + const log = await Container.git.getLog(this.uri.repoPath!, { maxCount: maxCount, - ref: `${this.branch.ref}...${this._compareWith || 'HEAD'}` + ref: `${this._compareWith || 'HEAD'}${notation}${this.branch.ref}` }); const count = log !== undefined ? log.count : 0; diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts index 8356a2f..d31bf26 100644 --- a/src/views/nodes/compareResultsNode.ts +++ b/src/views/nodes/compareResultsNode.ts @@ -148,9 +148,11 @@ export class CompareResultsNode extends SubscribeableViewNode { } private async getCommitsQuery(maxCount: number | undefined): Promise { + const notation = Container.config.advanced.useSymmetricDifferenceNotation ? '...' : '..'; + const log = await Container.git.getLog(this.uri.repoPath!, { maxCount: maxCount, - ref: `${this._ref1.ref}...${this._ref2.ref || 'HEAD'}` + ref: `${this._ref1.ref}${notation}${this._ref2.ref || 'HEAD'}` }); const count = log !== undefined ? log.count : 0;