Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add alias conflict prompt #444

Merged
merged 1 commit into from
Sep 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,33 @@ install:
$(eval TEMPFILE := $(shell mktemp -q ${TMPDIR:-/tmp}/git-extras.XXXXXX 2>/dev/null || mktemp -q))
@# chmod from rw-------(default) to rwxrwxr-x, so that users can exec the scripts
@chmod 775 $(TEMPFILE)
$(eval EXISTED_ALIASES := $(shell \
git config --get-regexp 'alias.*' | awk '{print "git-" substr($$1, 7)}'))
@$(foreach COMMAND, $(COMMANDS_USED_WITH_GIT_REPO), \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) | cat - $(LIB) ./helper/is-git-repo > $(TEMPFILE); \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
disable=''; \
if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \
read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \
test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \
fi; \
if test -z "$$disable"; then \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) | cat - $(LIB) ./helper/is-git-repo > $(TEMPFILE); \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
fi; \
)
@$(foreach COMMAND, $(COMMANDS_USED_WITHOUT_GIT_REPO), \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) | cat - $(LIB) > $(TEMPFILE); \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
disable=''; \
if test ! -z "$(filter $(COMMAND), $(EXISTED_ALIASES))"; then \
read -p "$(COMMAND) conflicts with an alias, still install it and disable the alias? [y/n]" answer; \
test "$$answer" = 'n' -o "$$answer" = 'N' && disable="true"; \
fi; \
if test -z "$$disable"; then \
echo "... installing $(COMMAND)"; \
head -1 bin/$(COMMAND) | cat - $(LIB) > $(TEMPFILE); \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
fi; \
)
@if [ -z "$(wildcard man/git-*.1)" ]; then \
echo "WARNING: man pages not created, use 'make docs' (which requires 'ronn' ruby lib)"; \
Expand Down