Skip to content
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fc873d6
Cherry picks with modifications from Ozkan's jdsu-ger branch.
woytowgme2 Nov 24, 2014
94fbe41
Test for more fine grained @{upstream} being set instead of whether a…
woytowgme2 Nov 25, 2014
1d7911c
Ignore stderr when checking for upstream
gunterw Nov 27, 2014
8a4d4b7
Revert to make work with Python 2.7 which is what is on my system
gunterw Nov 27, 2014
80444c3
Add the filename to fat object names to allow easier assocation betwe…
woytowgme2 Nov 28, 2014
500adfd
Update previous commit so that is works with files in subdirectories
woytowgme2 Nov 28, 2014
f8cc1ca
Fixed some bugs with new full path scheme for fat objects
woytowgme2 Nov 29, 2014
2c8926c
Fix git fat verify so it works with full path objdir files.
woytowgme2 Nov 29, 2014
88bbfaa
Default git fat find arg to 0 if not present.
woytowgme2 Nov 29, 2014
3651da5
Cleanup help descriptions
woytowgme2 Nov 29, 2014
079ca7c
Fixed bug with file renames that have same blob but different tree ob…
gunterw Dec 1, 2014
52bf266
Add git2fat script which takes an existing git repo and converts it i…
gunterw Dec 1, 2014
fdd6f50
Remove debug prints accidentally checked in.
gunterw Dec 1, 2014
7a993cd
Added new git fat share command to easily change the share path value
woytowgme2 Dec 2, 2014
55e61e7
Update git2fat to use new default share configuration
gunterw Dec 2, 2014
55036d1
Update the hook scripts if anything is initialized.
gunterw Dec 4, 2014
1bee9a6
Alway call cmd_init, so git fat init is no longer needed (but still p…
gunterw Dec 5, 2014
da155dc
More updates for git share to allow easier recovery from share changing.
gunterw Dec 6, 2014
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
Prev Previous commit
More updates for git share to allow easier recovery from share changing.
  • Loading branch information
gunterw committed Dec 6, 2014
commit da155dc6e43bcb548fb8359a5cba0a6e6474c6f7
62 changes: 43 additions & 19 deletions git-fat
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class GitFat(object):
remote = gitconfig_get('rsync.remote', file=cfgpath)
share = gitconfig_get('git-fat.share')
if share is None:
share = gitconfig_get('share.default', file=cfgpath)
share = gitconfig_get('share.default', file=cfgpath)
if share is None:
share = self.objdir
return remote, share
Expand Down Expand Up @@ -194,7 +194,10 @@ class GitFat(object):
self.verbose('git-fat : %d file(s) found to push to %s' % (cnt, remote))
else:
src = remote
dst = share # If share is set up, smudge filter will take care of linking self.objdir to share during merge|rebase step of 'pull', therefore always pull from remote to share here.
if os.path.exists(share):
dst = share
else:
dst = self.objdir
self.verbose('git-fat : %d file(s) found to pull from %s' % (cnt, remote))
return self.get_rsync_command(src, dst)
def match_digest(self, objpath):
Expand All @@ -216,9 +219,9 @@ class GitFat(object):
shutil.copy(matchpath,objpath)
def symlink_to_share(self, objfile):
'Create self.objdir/objfile (links) pointing at share/objfile if the configuration of share is set up appropriately'
# Do nothing if share is not set up or points at a non-existing path.
# Do nothing if share is not set
(remote, share) = self.get_fat_configs()
if share == self.objdir or not os.path.exists(share):
if share == self.objdir or not os.path.exists(share):
return
objpath = os.path.join(self.objdir, objfile)
if os.path.lexists(objpath):
Expand All @@ -232,8 +235,9 @@ class GitFat(object):
for objfile in files:
objpath = os.path.join(self.objdir, objfile)
sharepath = os.path.join(share, objfile)
os.remove(objpath)
os.symlink(sharepath, objpath)
if os.path.exists(sharepath):
os.remove(objpath)
os.symlink(sharepath, objpath)
def revparse(self, revname):
return subprocess.check_output(['git', 'rev-parse', revname]).strip()
def encode_v1(self, digest, bytes):
Expand Down Expand Up @@ -333,11 +337,9 @@ class GitFat(object):
The clean filter runs when a file is added to the index. It gets the "smudged" (tree)
version of the file on stdin and produces the "clean" (repository) version on stdout.
'''
self.cmd_init()
self.filter_clean(sys.stdin, sys.stdout, fname)

def cmd_filter_smudge(self, fname):
self.cmd_init()
result, bytes = self.decode_stream(sys.stdin)
if isinstance(result, str): # We got a digest
objfile = fname + '.' + result
Expand Down Expand Up @@ -486,7 +488,7 @@ class GitFat(object):
sys.exit(p.returncode)
def push_to_share(self, files):
(remote, share) = self.get_fat_configs()
# Do nothing if share is not set up or points at a non-existing path.
# Do nothing if share is not set up
if share == self.objdir or not os.path.exists(share):
return
if len(files) == 0:
Expand All @@ -499,7 +501,6 @@ class GitFat(object):
sys.exit(p.returncode)
self.convert_objfile_to_symlink(self.catalog_objects(), share)
def cmd_pre_push(self, args):
self.cmd_init()
self.cmd_push("")
def cmd_push(self, args):
'Push all fat files that I have stored and referenced'
Expand Down Expand Up @@ -534,6 +535,12 @@ class GitFat(object):
subprocess.check_call(['git', 'checkout-index', '--index', '--force', fname])
elif show_orphans:
print('Data unavailable: %s' % objfile)
def remove_objdir_broken_symlinks(self, files):
for file in files:
objpath = os.path.join(self.objdir, file)
if os.path.lexists(objpath) and not os.path.exists(objpath):
self.verbose('remove broken symlink %s' % objpath)
os.remove(objpath)
def pull_from_remote(self, files):
'Since this sub is also used by cmd_filter_smudge, stdout needs to be nothing but what git expects => throw away stdout of rsync'
if len(files) == 0:
Expand All @@ -545,18 +552,19 @@ class GitFat(object):
if p.returncode:
sys.exit(p.returncode)
def cmd_post_merge(self, args):
self.cmd_init()
self.cmd_pull("")
def cmd_post_checkout(self, args):
self.cmd_pull("")
def cmd_pre_rebase(self, args):
self.cmd_init()
self.cmd_pull("")
def cmd_pull(self, args):
'Pull anything that I have referenced, but not stored'
(remote, share) = self.get_fat_configs()
if remote is None:
return
self.remove_objdir_broken_symlinks(self.catalog_objects())
refargs = dict()
if '--all' in args:
if not len(args) or '--all' in args:
refargs['all'] = True
for arg in args:
if arg.startswith('-') or len(arg) != 40:
Expand Down Expand Up @@ -630,6 +638,13 @@ class GitFat(object):
f.writelines(lines)
os.chmod(post_merge, 0755)
ret = True
post_checkout = os.path.join(self.gitdir, 'hooks', 'post-checkout')
if not os.path.isfile(post_checkout):
with open(post_checkout, "w") as f:
lines = ["#!/bin/sh\n", "git-fat post-checkout \"$@\"\n"]
f.writelines(lines)
os.chmod(post_checkout, 0755)
ret = True
pre_rebase = os.path.join(self.gitdir, 'hooks', 'pre-rebase')
if not os.path.isfile(pre_rebase):
with open(pre_rebase, "w") as f:
Expand Down Expand Up @@ -760,11 +775,18 @@ class GitFat(object):
gitconfig_unset('git-fat.share')
else:
gitconfig_set('git-fat.share',args[0])
(remote, share) = self.get_fat_configs()
self.convert_objfile_to_symlink(self.catalog_objects(),share)
else:
(remote, share) = self.get_fat_configs()
print('%s' % share)

(remote, share) = self.get_fat_configs()
if share != self.objdir:
try:
mkdir_p(share)
except OSError:
print('Share path \'%s\' does not exist.' % share)
return

(remote, share) = self.get_fat_configs()
print('%s' % share)

def cmd_help(self):
objdir = os.path.join(self.gitroot, self.objdir)
# Directories
Expand Down Expand Up @@ -833,7 +855,7 @@ class GitFat(object):
print('- git fat push --all : Same steps as git fat push except that reference is computed across all git objects,')
print(' not just what your HEAD (including history) is pointing at.')
print('')
print('- git checkout ... : git invokes git-fat filter-smudge for each file configured in .gitattributes and post-merge githook.')
print('- git checkout ... : git invokes git-fat filter-smudge for each file configured in .gitattributes and post-checkout githook.')
print('- git add <path/file> : git invokes git-fat filter-clean for each file configured in .gitattributes.')
print('- git commit -a [...] : See git add.')
print('- git merge ... : git invokes git-fat filter-clean and filter-smudge for each file configured in .gitattributes and post-merge githook.')
Expand All @@ -856,6 +878,8 @@ if __name__ == '__main__':
fat.cmd_pre_rebase(sys.argv[2:])
elif cmd == 'post-merge':
fat.cmd_post_merge(sys.argv[2:])
elif cmd == 'post-checkout':
fat.cmd_post_checkout(sys.argv[2:])
elif cmd == 'init':
fat.cmd_init()
elif cmd == 'status':
Expand Down