Skip to content

wslgit prints out additional newline character for single-line git outputs #27

@pe224

Description

@pe224

I noticed this as VSCode gives an error when staging only selected changes.
For this, VSCode calls git hash-object and continues to use the output of this command.

Natively, git hash-object yields a single string, e.g. "b7a2640fdd1d5ead24cc6340275b849e801bf6fe" (no ending newline).

However, the output of wslgit hash-object for the same file will be "b7a2640fdd1d5ead24cc6340275b849e801bf6fe\n" (with ending newline).

This then leads to the error in VSCode.

Reason is line 98-100 where the git output is split into lines, translated, and then printed out (via println).
If the original git output is only a single line without newline character, wslgit will still add a newline character due to println

As a Rust noob, I quick-fixed it with

let output_list: Vec<String> = output_str.lines().map(translate_path_to_win).collect();
print!("{}", output_list.join("\n"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions