-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgit-now
More file actions
executable file
·92 lines (78 loc) · 2.24 KB
/
Copy pathgit-now
File metadata and controls
executable file
·92 lines (78 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi
GITNOW_DIR=$0
GITNOW_DIR=${GITNOW_DIR%\\*} # for msysGit
GITNOW_DIR=${GITNOW_DIR%/*} # for others
export GITNOW_DIR
prefix_config=`git config now.prefix`
if [ $? -eq 0 ]; then
PREFIX=$prefix_config
else
PREFIX="from now"
fi
bracket_config=`git config now.bracket`
if [ $? -eq 0 ]; then
BRACKET=$bracket_config
else
BRACKET=true
fi
usage() {
echo "usage: git now [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]"
echo " [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]"
echo " [--refresh] [--ignore-errors] [--ignore-missing] [--]"
echo " [<filepattern>...]"
echo
echo " git now <subcommand>"
echo
echo "Available subcommands are:"
echo " add default subcommand."
echo " rebase rebase for temporary commits."
echo " push remove remote branch before push to remote repoistory for rebase commits."
echo " grep grep temporary commits."
echo
echo "Try 'git now <subcommand> help' for details."
}
main() {
# load common functionality
. "$GITNOW_DIR/gitnow-common"
# This environmental variable fixes non-POSIX getopt style argument
# parsing, effectively breaking git-now subcommand parsing on several
# Linux platforms.
export POSIXLY_CORRECT=1
# use the shFlags project to parse the command line arguments
. "$GITNOW_DIR/gitnow-shFlags"
SUBCOMMAND="$1"
if [ ! -e "$GITNOW_DIR/git-now-$SUBCOMMAND" ]; then
if [ "$SUBCOMMAND" = "help" ]; then
usage
exit 0
else
SUBCOMMAND="add"
fi
else
FLAGS_PARENT="git now"
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"; shift
FLAGS_PARENT="git now $SUBCOMMAND"
fi
# run command
. "$GITNOW_DIR/git-now-$SUBCOMMAND"
# test if the first argument is a flag (i.e. starts with '-')
# in that case, we interpret this arg as a flag for the default
# command
SUBACTION="default"
if [ "$1" = "help" ] && { ! echo "$1" | grep -q "^-"; } then
SUBACTION="$1"; shift
fi
#if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
#warn "Unknown subcommand: '$SUBACTION'"
#usage
#exit 1
#fi
# run the specified action
cmd_$SUBACTION "$@"
}
main "$@"