Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 8 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ BINS = $(wildcard bin/git-*)
MANS = $(wildcard man/git-*.md)
MAN_HTML = $(MANS:.md=.html)
MAN_PAGES = $(MANS:.md=.1)
# Libraries used by all commands
LIB = "helper/reset-env" "helper/git-extra-utility"

COMMANDS_USED_WITHOUT_GIT_REPO = git-alias git-extras git-fork git-setup
COMMANDS_USED_WITH_GIT_REPO = $(filter-out $(COMMANDS_USED_WITHOUT_GIT_REPO), \
$(subst bin/, , $(BINS)))
COMMANDS = $(subst bin/, , $(BINS))

default: install

Expand All @@ -25,28 +24,19 @@ install:
@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), \
@$(foreach COMMAND, $(COMMANDS), \
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), \
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); \
head -1 bin/$(COMMAND) > $(TEMPFILE); \
cat $(LIB) >> $(TEMPFILE); \
if grep "$(COMMAND)" need_git_repo >/dev/null; then \
cat ./helper/is-git-repo >> $(TEMPFILE); \
fi; \
tail -n +2 bin/$(COMMAND) >> $(TEMPFILE); \
cp -f $(TEMPFILE) $(DESTDIR)$(BINPREFIX)/$(COMMAND); \
fi; \
Expand Down
6 changes: 6 additions & 0 deletions need_git_repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# A list of the commands that use is_git_repo, and should have
# it included in the "built" version of the command
git-alias
git-extras
git-fork
git-setup