annotate .shell.d/50.git_functions.sh @ 490:10811c923fc0

path handling: stop warning when something isn't in a variable
author Augie Fackler <raf@durin42.com>
date Mon, 11 Jul 2016 14:54:41 -0400
parents 0cd241f35c40
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
210
0590f34b92a0 shell.d: split hg and git functions out of vcs functions
Augie Fackler <durin42@gmail.com>
parents: 204
diff changeset
1 # git utility functions
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2
156
59ea03d7029a vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents: 133
diff changeset
3 function git_next_unmerged_file() {
195
e1a49db5c6ff git-next-unmerged-file: also include "both modified" files
Augie Fackler <durin42@gmail.com>
parents: 184
diff changeset
4 git status | egrep '(unmerged|both modified)' | head -n 1 | sed 's/.*: //'
156
59ea03d7029a vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents: 133
diff changeset
5 }
59ea03d7029a vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents: 133
diff changeset
6 alias git-next-unmerged-file=git_next_unmerged_file
59ea03d7029a vcs_functions: add a function to grab the path of the next unmerged file from git
Augie Fackler <durin42@gmail.com>
parents: 133
diff changeset
7
204
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
8 function git_repack_all() {
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
9 for repo in $(find . | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
10 grep '/objects/pack/' | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
11 sed -e 's%\.git/objects/pack/.*%%' | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
12 sed -e 's%git/objects/pack/.*%git%' | sort | uniq) ; do
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
13 pushd $repo
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
14 git repack -ad --window 100
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
15 git gc --prune="`date`"
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
16 popd
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
17 done
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
18 }
234
0cd241f35c40 git-functions: add a couple of handy aliases
Augie Fackler <durin42@gmail.com>
parents: 210
diff changeset
19 alias git-repack-all=git_repack_all
204
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
20
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
21 function git_fsck_all() {
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
22 for repo in $(find . | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
23 grep '/objects/pack/' | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
24 sed -e 's%\.git/objects/pack/.*%%' | \
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
25 sed -e 's%git/objects/pack/.*%git%' | sort | uniq) ; do
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
26 pushd $repo
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
27 git fsck
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
28 popd
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
29 done
9e45ac5350fd vcs funcs: tools for verifying hg or git repos, packing git repos
Augie Fackler <durin42@gmail.com>
parents: 200
diff changeset
30 }
234
0cd241f35c40 git-functions: add a couple of handy aliases
Augie Fackler <durin42@gmail.com>
parents: 210
diff changeset
31 alias git-fsck-all=git_fsck_all