XDIFF_LIB = xdiff/lib.a
VCSSVN_LIB = vcs-svn/lib.a
-GENERATED_H += common-cmds.h
+GENERATED_H += common-cmds.h command-list.h
LIB_H = $(shell $(FIND) . \
-name .git -prune -o \
common-cmds.h: generate-cmdlist.sh command-list.txt
common-cmds.h: $(wildcard Documentation/git-*.txt)
+ $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh command-list.txt COMMON >$@+ && mv $@+ $@
+
+command-list.h: generate-cmdlist.sh command-list.txt
+
+command-list.h: $(wildcard Documentation/git-*.txt)
$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
# Dependencies on header files, for platforms that do not support
# the gcc -MMD option.
#
-# Dependencies on automatically generated headers such as common-cmds.h
+# Dependencies on automatically generated headers such as common-cmds.h or command-list.h
# should _not_ be included here, since they are necessary even when
# building an object for the first time.
style:
git clang-format --style file --diff --extensions c,h
-check: common-cmds.h
+check: common-cmds.h command-list.h
@if sparse; \
then \
echo >&2 "Use 'make sparse' instead"; \
$(RM) $(TEST_PROGRAMS) $(NO_INSTALL)
$(RM) -r bin-wrappers $(dep_dirs)
$(RM) -r po/build/
- $(RM) *.pyc *.pyo */*.pyc */*.pyo common-cmds.h $(ETAGS_TARGET) tags cscope*
+ $(RM) *.pyc *.pyo */*.pyc */*.pyo common-cmds.h command-list.h $(ETAGS_TARGET) tags cscope*
$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
history grow, mark and tweak your common history
remote collaborate (see also: git help workflows)
-### command list (do not change this line)
-# command name category [deprecated] [common]
+### command list (do not change this line, also do not change alignment)
+# command name category [category] [category]
git-add mainporcelain worktree
git-am mainporcelain
git-annotate ancillaryinterrogators
#!/bin/sh
+die () {
+ echo "$@" >&2
+ exit 1
+}
+
+command_list () {
+ sed '1,/^### command list/d;/^#/d' "$1"
+}
+
+get_categories () {
+ tr ' ' '\n'|
+ grep -v '^$' |
+ sort |
+ uniq
+}
+
+category_list () {
+ command_list "$1" |
+ cut -c 40- |
+ get_categories
+}
+
get_synopsis () {
sed -n '
/^NAME/,/'"$1"'/H
}' "Documentation/$1.txt"
}
+define_categories () {
+ echo
+ echo "/* Command categories */"
+ bit=0
+ category_list "$1" |
+ while read cat
+ do
+ echo "#define CAT_$cat (1UL << $bit)"
+ bit=$(($bit+1))
+ done
+ test "$bit" -gt 32 && die "Urgh.. too many categories?"
+}
+
+print_command_list () {
+ echo "static struct cmdname_help command_list[] = {"
+
+ command_list "$1" |
+ while read cmd rest
+ do
+ printf " { \"$cmd\", $(get_synopsis $cmd), 0"
+ for cat in $(echo "$rest" | get_categories)
+ do
+ printf " | CAT_$cat"
+ done
+ echo " },"
+ done
+ echo "};"
+}
+
echo "/* Automatically generated by generate-cmdlist.sh */
struct cmdname_help {
- char name[16];
- char help[80];
- unsigned char group;
+ const char *name;
+ const char *help;
+ uint32_t group;
};
+"
+if test -z "$2"
+then
+ define_categories "$1"
+ echo
+ print_command_list "$1"
+ exit 0
+fi
-static const char *common_cmd_groups[] = {"
+echo "static const char *common_cmd_groups[] = {"
grps=grps$$.tmp
match=match$$.tmp