Skip to content

Fix search when REPO_PATH contains a dot-dir#82

Merged
DannyBen merged 3 commits intomasterfrom
fix/dot-dirs
Oct 28, 2024
Merged

Fix search when REPO_PATH contains a dot-dir#82
DannyBen merged 3 commits intomasterfrom
fix/dot-dirs

Conversation

@DannyBen
Copy link
Copy Markdown
Owner

@DannyBen DannyBen commented Oct 27, 2024

cc #81

@DannyBen DannyBen changed the title Fix search when REPO_PATH had a dot-dir Fix search when REPO_PATH contains a dot-dir Oct 27, 2024
Comment thread src/search_command.sh Outdated
Comment on lines +14 to +17
find "$repo_path" -type d |
grep -v "$repo_path.*/\." |
grep --color=always "$text" |
sed "s#${repo_path}/#${prefix}#g"
Copy link
Copy Markdown

@pcrockett pcrockett Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably works fine for 99% of people, though I'm not super excited about the repo path being treated as a regex. Perhaps slightly more technically correct:

Suggested change
find "$repo_path" -type d |
grep -v "$repo_path.*/\." |
grep --color=always "$text" |
sed "s#${repo_path}/#${prefix}#g"
path_length=$((${#repo_path}+2))
find "$repo_path" -type d |
cut --characters "$path_length-" |
grep -v -F "/." |
grep --color=always "$text" |
sed "s#^#${prefix}#"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not also not crazy about this excessive piping.
Perhaps we should search for dirs that contain main files instead of searching for dirs?

@pcrockett
Copy link
Copy Markdown

pcrockett commented Oct 27, 2024 via email

@DannyBen DannyBen merged commit 851cba9 into master Oct 28, 2024
@DannyBen DannyBen deleted the fix/dot-dirs branch October 28, 2024 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants