Skip to content

Commit

Permalink
SONAR-21885 LTS Backport: Fix native Git blame with Git CLI >= 2.43
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-vigneau-sonarsource authored and sonartech committed Jun 17, 2024
1 parent 4c564bb commit d7cbd43
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class GitBlameCommand {
private static final String MINIMUM_REQUIRED_GIT_VERSION = "2.24.0";
private static final String DEFAULT_GIT_COMMAND = "git";
private static final String BLAME_LINE_PORCELAIN_FLAG = "--line-porcelain";
private static final String END_OF_OPTIONS_FLAG = "--end-of-options";
private static final String FILENAME_SEPARATOR_FLAG = "--";
private static final String IGNORE_WHITESPACES = "-w";

private static final Pattern whitespaceRegex = Pattern.compile("\\s+");
Expand Down Expand Up @@ -128,7 +128,7 @@ public List<BlameLine> blame(Path baseDir, String fileName) throws Exception {
gitCommand,
GIT_DIR_FLAG, String.format(GIT_DIR_ARGUMENT, baseDir), GIT_DIR_FORCE_FLAG, baseDir.toString(),
BLAME_COMMAND,
BLAME_LINE_PORCELAIN_FLAG, IGNORE_WHITESPACES, END_OF_OPTIONS_FLAG, fileName)
BLAME_LINE_PORCELAIN_FLAG, IGNORE_WHITESPACES, FILENAME_SEPARATOR_FLAG, fileName)
.execute();
} catch (UncommittedLineException e) {
LOG.debug("Unable to blame file '{}' - it has uncommitted changes", fileName);
Expand Down

0 comments on commit d7cbd43

Please sign in to comment.