Skip to content

Conversation

@pabs3
Copy link
Contributor

@pabs3 pabs3 commented Jan 19, 2026

No description provided.

fi; \
if [ "$$should_install" = 'yes' ]; then \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) > $(TEMPFILE); \
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about building the script content in a subshell and redirecting it directly to the destination? This avoids mktemp, chmod on temp files from the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe something like this?

  • source the helper/ scripts rather than embedding them
    • add the source command to each script in bin/
  • install the helper/ scripts in /usr/share/git-extras/helper or similar
  • separate out a build target from the install target
  • build each of the to-be-installed scripts in a pattern rule that would just add the install path for the helper/ scripts.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this plan a little complicated? We can just use the subshell's stdout as a temp file, so no need to use a real file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@spacewander Could we keep using the temporary file? Things kind of look complicated enough with this being embedded in a Makefile and all,.

@hyperupcall hyperupcall self-requested a review January 20, 2026 00:41
Copy link
Collaborator

@hyperupcall hyperupcall left a comment

Choose a reason for hiding this comment

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

Looks great so far! Was a little bothersome to learn that git-extras didn't cleanup properly after execution.

Just had a few minor comments; once addressed, I'll approve!

fi; \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
rm -f $(TEMPFILE); \
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're adding this, could this go after the @foreach and before the @if [ -z "$(wildcard man/git-*.1)" ]; then \? The temporary file is created outside of the loop, not inside,.

fi; \
if [ "$$should_install" = 'yes' ]; then \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) > $(TEMPFILE); \
Copy link
Collaborator

Choose a reason for hiding this comment

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

@spacewander Could we keep using the temporary file? Things kind of look complicated enough with this being embedded in a Makefile and all,.


set -euo pipefail

proceed=false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be moved out to a separate PR? For matching the argument, would prefer using $1 == @(--proceed|-p) (enabling extglob) or keeping the existing structure and using group commands ({ true && true; }) instead of subshells.


if [[ -n "$DEBUG" ]] ; then
sort -nr "$DEBUG" &&
rm -f "$DEBUG"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't DEBUG not be removed, so that the user could see the debug output after git guilt runs?

@hyperupcall hyperupcall changed the title Clean up some temporary files Fix cleanup of temporary files Jan 23, 2026
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.

4 participants