diff options
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/completion/git-completion.bash | 36 | ||||
-rwxr-xr-x | contrib/examples/git-remote.perl | 5 | ||||
-rwxr-xr-x | contrib/fast-import/import-zips.py | 72 | ||||
-rwxr-xr-x | contrib/hg-to-git/hg-to-git.py | 27 |
4 files changed, 121 insertions, 19 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 3f46149853..27332ed8b1 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -451,6 +451,18 @@ __git_find_subcommand () done } +__git_has_doubledash () +{ + local c=1 + while [ $c -lt $COMP_CWORD ]; do + if [ "--" = "${COMP_WORDS[c]}" ]; then + return 0 + fi + c=$((++c)) + done + return 1 +} + __git_whitespacelist="nowarn warn error error-all strip" _git_am () @@ -497,6 +509,8 @@ _git_apply () _git_add () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) @@ -511,7 +525,9 @@ _git_add () _git_bisect () { - local subcommands="start bad good reset visualize replay log" + __git_has_doubledash && return + + local subcommands="start bad good skip reset visualize replay log run" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" @@ -519,7 +535,7 @@ _git_bisect () fi case "$subcommand" in - bad|good|reset) + bad|good|reset|skip) __gitcomp "$(__git_refs)" ;; *) @@ -546,7 +562,7 @@ _git_branch () --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev - --track --no-track + --track --no-track --contains --merged --no-merged " ;; *) @@ -613,6 +629,8 @@ _git_cherry_pick () _git_commit () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) @@ -632,6 +650,8 @@ _git_describe () _git_diff () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) @@ -734,6 +754,8 @@ _git_ls_tree () _git_log () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --pretty=*) @@ -1086,6 +1108,8 @@ _git_remote () _git_reset () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) @@ -1098,6 +1122,8 @@ _git_reset () _git_shortlog () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" case "$cur" in --*) @@ -1144,6 +1170,8 @@ _git_stash () _git_submodule () { + __git_has_doubledash && return + local subcommands="add status init update" if [ -z "$(__git_find_subcommand "$subcommands")" ]; then local cur="${COMP_WORDS[COMP_CWORD]}" @@ -1350,6 +1378,8 @@ _git () _gitk () { + __git_has_doubledash && return + local cur="${COMP_WORDS[COMP_CWORD]}" local g="$(git rev-parse --git-dir 2>/dev/null)" local merge="" diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl index b30ed734e7..36bd54c985 100755 --- a/contrib/examples/git-remote.perl +++ b/contrib/examples/git-remote.perl @@ -129,10 +129,7 @@ sub update_ls_remote { return if (($harder == 0) || (($harder == 1) && exists $info->{'LS_REMOTE'})); - my @ref = map { - s|^[0-9a-f]{40}\s+refs/heads/||; - $_; - } $git->command(qw(ls-remote --heads), $info->{'URL'}); + my @ref = map { s|refs/heads/||; $_; } keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])}; $info->{'LS_REMOTE'} = \@ref; } diff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py new file mode 100755 index 0000000000..c674fa2d1b --- /dev/null +++ b/contrib/fast-import/import-zips.py @@ -0,0 +1,72 @@ +#!/usr/bin/python + +## zip archive frontend for git-fast-import +## +## For example: +## +## mkdir project; cd project; git init +## python import-zips.py *.zip +## git log --stat import-zips + +from os import popen, path +from sys import argv, exit +from time import mktime +from zipfile import ZipFile + +if len(argv) < 2: + print 'Usage:', argv[0], '<zipfile>...' + exit(1) + +branch_ref = 'refs/heads/import-zips' +committer_name = 'Z Ip Creator' +committer_email = 'zip@example.com' + +fast_import = popen('git fast-import --quiet', 'w') +def printlines(list): + for str in list: + fast_import.write(str + "\n") + +for zipfile in argv[1:]: + commit_time = 0 + next_mark = 1 + common_prefix = None + mark = dict() + + zip = ZipFile(zipfile, 'r') + for name in zip.namelist(): + if name.endswith('/'): + continue + info = zip.getinfo(name) + + if commit_time < info.date_time: + commit_time = info.date_time + if common_prefix == None: + common_prefix = name[:name.rfind('/') + 1] + else: + while not name.startswith(common_prefix): + common_prefix = name[:name.rfind('/') + 1] + + mark[name] = ':' + str(next_mark) + next_mark += 1 + + printlines(('blob', 'mark ' + mark[name], \ + 'data ' + str(info.file_size))) + fast_import.write(zip.read(name) + "\n") + + committer = committer_name + ' <' + committer_email + '> %d +0000' % \ + mktime(commit_time + (0, 0, 0)) + + printlines(('commit ' + branch_ref, 'committer ' + committer, \ + 'data <<EOM', 'Imported from ' + zipfile + '.', 'EOM', \ + '', 'deleteall')) + + for name in mark.keys(): + fast_import.write('M 100644 ' + mark[name] + ' ' + + name[len(common_prefix):] + "\n") + + printlines(('', 'tag ' + path.basename(zipfile), \ + 'from ' + branch_ref, 'tagger ' + committer, \ + 'data <<EOM', 'Package ' + zipfile, 'EOM', '')) + +if fast_import.close(): + exit(1) diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py index f68ef725d4..7b03204ed1 100755 --- a/contrib/hg-to-git/hg-to-git.py +++ b/contrib/hg-to-git/hg-to-git.py @@ -89,7 +89,7 @@ try: if o in ('-v', '--verbose'): verbose = True if len(args) != 1: - raise('params') + raise Exception('params') except: usage() sys.exit(1) @@ -106,7 +106,10 @@ if state: else: print 'State does not exist, first run' -tip = os.popen('hg tip --template "{rev}"').read() +sock = os.popen('hg tip --template "{rev}"') +tip = sock.read() +if sock.close(): + sys.exit(1) if verbose: print 'tip is', tip @@ -149,7 +152,7 @@ for cset in range(1, int(tip) + 1): if not hgvers.has_key("0"): print 'creating repository' - os.system('git-init-db') + os.system('git init') # loop through every hg changeset for cset in range(int(tip) + 1): @@ -191,10 +194,10 @@ for cset in range(int(tip) + 1): if cset != 0: if hgbranch[str(cset)] == "branch-" + str(cset): print 'creating new branch', hgbranch[str(cset)] - os.system('git-checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent])) + os.system('git checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent])) else: print 'checking out branch', hgbranch[str(cset)] - os.system('git-checkout %s' % hgbranch[str(cset)]) + os.system('git checkout %s' % hgbranch[str(cset)]) # merge if mparent: @@ -203,7 +206,7 @@ for cset in range(int(tip) + 1): else: otherbranch = hgbranch[parent] print 'merging', otherbranch, 'into', hgbranch[str(cset)] - os.system(getgitenv(user, date) + 'git-merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch)) + os.system(getgitenv(user, date) + 'git merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch)) # remove everything except .git and .hg directories os.system('find . \( -path "./.hg" -o -path "./.git" \) -prune -o ! -name "." -print | xargs rm -rf') @@ -212,9 +215,9 @@ for cset in range(int(tip) + 1): os.system('hg update -C %d' % cset) # add new files - os.system('git-ls-files -x .hg --others | git-update-index --add --stdin') + os.system('git ls-files -x .hg --others | git update-index --add --stdin') # delete removed files - os.system('git-ls-files -x .hg --deleted | git-update-index --remove --stdin') + os.system('git ls-files -x .hg --deleted | git update-index --remove --stdin') # commit os.system(getgitenv(user, date) + 'git commit --allow-empty -a -F %s' % filecomment) @@ -222,20 +225,20 @@ for cset in range(int(tip) + 1): # tag if tag and tag != 'tip': - os.system(getgitenv(user, date) + 'git-tag %s' % tag) + os.system(getgitenv(user, date) + 'git tag %s' % tag) # delete branch if not used anymore... if mparent and len(hgchildren[str(cset)]): print "Deleting unused branch:", otherbranch - os.system('git-branch -d %s' % otherbranch) + os.system('git branch -d %s' % otherbranch) # retrieve and record the version - vvv = os.popen('git-show --quiet --pretty=format:%H').read() + vvv = os.popen('git show --quiet --pretty=format:%H').read() print 'record', cset, '->', vvv hgvers[str(cset)] = vvv if hgnewcsets >= opt_nrepack and opt_nrepack != -1: - os.system('git-repack -a -d') + os.system('git repack -a -d') # write the state for incrementals if state: |